Skip to content

tests-common: Handle PortInUseException for SSHConsoleConn#15174

Merged
StormLiangMS merged 3 commits intosonic-net:masterfrom
matthew-soulsby:dut_console_clear
Oct 30, 2024
Merged

tests-common: Handle PortInUseException for SSHConsoleConn#15174
StormLiangMS merged 3 commits intosonic-net:masterfrom
matthew-soulsby:dut_console_clear

Conversation

@matthew-soulsby
Copy link
Copy Markdown
Contributor

@matthew-soulsby matthew-soulsby commented Oct 25, 2024

Description of PR

Addresses #15092

Summary:
This PR adds handling for the PortInUseException, which is thrown when an SSHConsoleConn is successfully established (most prominently in dut_console tests) but the console port is occupied, resulting in the connection being terminated by the host.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405

Approach

What is the motivation for this PR?

This PR is intended to add more resilience to the dut_console tests, as if a testbed with a blocked port was selected for a nightly test, it would cause the dut_console tests to fail during setup. This provides a method for auto-recovery for these cases.

How did you do it?

By completing the following:

  • Add connection types for each of the configuration menu types (Digi, Cisco, and Sonic) to allow for different command sequences to be accounted for
  • Add function to clear a DUT's console port
  • Add retry logic to add resilience to main DUT connection set up

How did you verify/test it?

This process was conducted on 5 testbeds, with at least one of each config menu type.

Steps conducted during testing
  1. SSH into testbed using the console IP and console port - simulating a blocked port
  2. In a separate terminal, run any dut_console test individually
  3. During test setup, the connection from step 1 was terminated successfully
  4. The test then runs successfully
Example test output
  • Successful port reset (Digi config):

Screenshot 2024-10-25 165601

  • Successful port reset (Sonic config):

Screenshot 2024-10-25 183646

  • Sample failure
    • Simulating config menu type is not defined (causing the port clear function to exit early), and a more descriptive error message is thrown regarding why the connection to the DUT is failing:

Screenshot 2024-10-25 153008

Any platform specific information?

N/A - this is a generalised solution which accounts for as many types of configuration menus as possible.

Supported testbed topology if it's a new test case?

N/A

Documentation

N/A

* Add Digi, Sonic and Cisco Config connection types (to differentiate
between commands required to clear a port)
* Add function to clear a DUT's console port
* Add retry to set up DUT console connection after clearing port

  Signed-off-by: Matt Soulsby mattsoulsby@microsoft.com
Copy link
Copy Markdown
Contributor

@ZhaohuiS ZhaohuiS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Collaborator

@StormLiangMS StormLiangMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mssonicbld
Copy link
Copy Markdown
Collaborator

@matthew-soulsby PR conflicts with 202311 branch

mssonicbld pushed a commit to mssonicbld/sonic-mgmt that referenced this pull request Oct 30, 2024
…#15174)

What is the motivation for this PR?
This PR is intended to add more resilience to the dut_console tests, as if a testbed with a blocked port was selected for a nightly test, it would cause the dut_console tests to fail during setup. This provides a method for auto-recovery for these cases.

How did you do it?
By completing the following:

Add connection types for each of the configuration menu types (Digi, Cisco, and Sonic) to allow for different command sequences to be accounted for
Add function to clear a DUT's console port
Add retry logic to add resilience to main DUT connection set up
How did you verify/test it?
This process was conducted on 5 testbeds, with at least one of each config menu type.

Steps conducted during testing
SSH into testbed using the console IP and console port - simulating a blocked port
In a separate terminal, run any dut_console test individually
During test setup, the connection from step 1 was terminated successfully
The test then runs successfully
Example test output
Successful port reset (Digi config):
Screenshot 2024-10-25 165601

Successful port reset (Sonic config):
Screenshot 2024-10-25 183646

Sample failure
Simulating config menu type is not defined (causing the port clear function to exit early), and a more descriptive error message is thrown regarding why the connection to the DUT is failing:
Screenshot 2024-10-25 153008

Any platform specific information?
N/A - this is a generalised solution which accounts for as many types of configuration menus as possible.
@mssonicbld
Copy link
Copy Markdown
Collaborator

Cherry-pick PR to 202405: #15260

matthew-soulsby added a commit to matthew-soulsby/sonic-mgmt that referenced this pull request Oct 31, 2024
…#15174)

What is the motivation for this PR?
This PR is intended to add more resilience to the dut_console tests, as
if a testbed with a blocked port was selected for a nightly test, it
would cause the dut_console tests to fail during setup. This provides a
method for auto-recovery for these cases.

How did you do it?
By completing the following:

Add connection types for each of the configuration menu types (Digi,
Cisco, and Sonic) to allow for different command sequences to be
accounted for
Add function to clear a DUT's console port
Add retry logic to add resilience to main DUT connection set up
How did you verify/test it?
This process was conducted on 5 testbeds, with at least one of each
config menu type.

Steps conducted during testing
SSH into testbed using the console IP and console port - simulating a
blocked port
In a separate terminal, run any dut_console test individually
During test setup, the connection from step 1 was terminated
successfully
The test then runs successfully
Example test output
Successful port reset (Digi config):
Screenshot 2024-10-25 165601

Successful port reset (Sonic config):
Screenshot 2024-10-25 183646

Sample failure
Simulating config menu type is not defined (causing the port clear
function to exit early), and a more descriptive error message is thrown
regarding why the connection to the DUT is failing:
Screenshot 2024-10-25 153008

Any platform specific information?
N/A - this is a generalised solution which accounts for as many types of
configuration menus as possible.
bingwang-ms pushed a commit that referenced this pull request Nov 1, 2024
…15293)

What is the motivation for this PR?
This PR is intended to add more resilience to the dut_console tests, as
if a testbed with a blocked port was selected for a nightly test, it
would cause the dut_console tests to fail during setup. This provides a
method for auto-recovery for these cases.

How did you do it?
By completing the following:

Add connection types for each of the configuration menu types (Digi,
Cisco, and Sonic) to allow for different command sequences to be
accounted for
Add function to clear a DUT's console port
Add retry logic to add resilience to main DUT connection set up
How did you verify/test it?
This process was conducted on 5 testbeds, with at least one of each
config menu type.

Steps conducted during testing
SSH into testbed using the console IP and console port - simulating a
blocked port
In a separate terminal, run any dut_console test individually
During test setup, the connection from step 1 was terminated
successfully
The test then runs successfully
Example test output
Successful port reset (Digi config):
Screenshot 2024-10-25 165601

Successful port reset (Sonic config):
Screenshot 2024-10-25 183646

Sample failure
Simulating config menu type is not defined (causing the port clear
function to exit early), and a more descriptive error message is thrown
regarding why the connection to the DUT is failing:
Screenshot 2024-10-25 153008

Any platform specific information?
N/A - this is a generalised solution which accounts for as many types of
configuration menus as possible.
@vperumal
Copy link
Copy Markdown
Collaborator

vperumal commented Nov 3, 2024

@abdosi @yejianquan - Can we get this merged to 202405 - this is causing breakage because it is now looking for both console_type in some cases and console_menu_type in some cases. For now I have defined both

@matthew-soulsby
Copy link
Copy Markdown
Contributor Author

matthew-soulsby commented Nov 3, 2024

Hi @vperumal, this was merged into 202405 in this PR (due to issues with the auto cherry-pick PR): #15293

Did you have any logs/more information regarding the issue you're facing? Happy to look into it if so.

To my knowledge as long as there is a 'Console_menu_type' column in the relevant console_links.csv file, it should parse the values correctly - even if each row has no value for that column (in which case it will skip the added function with a warning)

sreejithsreekumaran pushed a commit to sreejithsreekumaran/sonic-mgmt that referenced this pull request Nov 15, 2024
…#15174)

What is the motivation for this PR?
This PR is intended to add more resilience to the dut_console tests, as if a testbed with a blocked port was selected for a nightly test, it would cause the dut_console tests to fail during setup. This provides a method for auto-recovery for these cases.

How did you do it?
By completing the following:

Add connection types for each of the configuration menu types (Digi, Cisco, and Sonic) to allow for different command sequences to be accounted for
Add function to clear a DUT's console port
Add retry logic to add resilience to main DUT connection set up
How did you verify/test it?
This process was conducted on 5 testbeds, with at least one of each config menu type.

Steps conducted during testing
SSH into testbed using the console IP and console port - simulating a blocked port
In a separate terminal, run any dut_console test individually
During test setup, the connection from step 1 was terminated successfully
The test then runs successfully
Example test output
Successful port reset (Digi config):
Screenshot 2024-10-25 165601

Successful port reset (Sonic config):
Screenshot 2024-10-25 183646

Sample failure
Simulating config menu type is not defined (causing the port clear function to exit early), and a more descriptive error message is thrown regarding why the connection to the DUT is failing:
Screenshot 2024-10-25 153008

Any platform specific information?
N/A - this is a generalised solution which accounts for as many types of configuration menus as possible.
yutongzhang-microsoft pushed a commit to yutongzhang-microsoft/sonic-mgmt that referenced this pull request Nov 21, 2024
…#15174)

What is the motivation for this PR?
This PR is intended to add more resilience to the dut_console tests, as if a testbed with a blocked port was selected for a nightly test, it would cause the dut_console tests to fail during setup. This provides a method for auto-recovery for these cases.

How did you do it?
By completing the following:

Add connection types for each of the configuration menu types (Digi, Cisco, and Sonic) to allow for different command sequences to be accounted for
Add function to clear a DUT's console port
Add retry logic to add resilience to main DUT connection set up
How did you verify/test it?
This process was conducted on 5 testbeds, with at least one of each config menu type.

Steps conducted during testing
SSH into testbed using the console IP and console port - simulating a blocked port
In a separate terminal, run any dut_console test individually
During test setup, the connection from step 1 was terminated successfully
The test then runs successfully
Example test output
Successful port reset (Digi config):
Screenshot 2024-10-25 165601

Successful port reset (Sonic config):
Screenshot 2024-10-25 183646

Sample failure
Simulating config menu type is not defined (causing the port clear function to exit early), and a more descriptive error message is thrown regarding why the connection to the DUT is failing:
Screenshot 2024-10-25 153008

Any platform specific information?
N/A - this is a generalised solution which accounts for as many types of configuration menus as possible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants