Skip to content

[action] [PR:23342] fix(console): fix intermittent login failures in dut_console tests#23396

Merged
mssonicbld merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/23342
Mar 30, 2026
Merged

[action] [PR:23342] fix(console): fix intermittent login failures in dut_console tests#23396
mssonicbld merged 1 commit intosonic-net:202511from
mssonicbld:cherry/202511/23342

Conversation

@mssonicbld
Copy link
Copy Markdown
Collaborator

Fix two intermittent failures in dut_console tests: an accumulation-buffer fix for the Password prompt detection race, and a splitlines()[0] fix for reliable TMOUT value extraction in test_idle_timeout.

Description of PR

Summary:

Fix two independent intermittent failures in dut_console tests:

  1. ssh_console_conn.pylogin_stage_2() checked re.search(pwd_pattern, output) where output is only the most recent read_channel() chunk. The DUT's Password: prompt can arrive split across multiple TCP reads (e.g. Pa + ssword:), causing no chunk to match and the password never being sent — resulting in an intermittent "Socket is closed" failure in create_duthost_console (~1 in 5 runs). Fix: check return_msg (accumulated read buffer) instead of output.

  2. test_idle_timeout.pysplitlines()[-1] could return a partial prompt string (e.g. admin@hostname:) instead of the numeric TMOUT value when the prompt was not fully stripped from the command output. Fix: use splitlines()[0] to always read the first output line, which is always the numeric value.

Both fixes were validated on internal branch dev/xuliping/20260325_202511_console_login_fix across 5 full test runs with no failures.

Related: follows up on #23295 (blank Enter fix in the same login path — already merged).

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
  • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Approach

What is the motivation for this PR?

dut_console tests were failing intermittently (~1 in 5 runs) with "Socket is closed" errors during console login. Root cause: the DUT's Password: prompt sometimes arrives split across multiple TCP reads, so per-chunk pattern matching never matches. A second independent failure in test_idle_timeout caused by splitlines()[-1] returning a prompt fragment instead of the numeric TMOUT value.

How did you do it?

  • ssh_console_conn.py: Changed re.search(pwd_pattern, output) to re.search(pwd_pattern, return_msg) in login_stage_2(), where return_msg is the accumulated read buffer across all chunks.
  • test_idle_timeout.py: Changed splitlines()[-1] to splitlines()[0] in the TMOUT value extraction, so we always get the first output line regardless of trailing prompt remnants.

How did you verify/test it?

Ran all dut_console test cases on a physical testbed using internal branch dev/xuliping/20260325_202511_console_login_fix for 5 full iterations. All tests passed with no failures.

Any platform specific information?

None — applies to all platforms using SSH console connections.

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

N/A (bug fix only)

Documentation

N/A

…onic-net#23342)

What is the motivation for this PR?
dut_console tests were failing intermittently (~1 in 5 runs) with "Socket is closed" errors during console login. Root cause: the DUT's Password: prompt sometimes arrives split across multiple TCP reads, so per-chunk pattern matching never matches. A second independent failure in test_idle_timeout caused by splitlines()[-1] returning a prompt fragment instead of the numeric TMOUT value.

How did you do it?
ssh_console_conn.py: Changed re.search(pwd_pattern, output) to re.search(pwd_pattern, return_msg) in login_stage_2(), where return_msg is the accumulated read buffer across all chunks.
test_idle_timeout.py: Changed splitlines()[-1] to splitlines()[0] in the TMOUT value extraction, so we always get the first output line regardless of trailing prompt remnants.
How did you verify/test it?
Ran all dut_console test cases on a physical testbed using internal branch dev/xuliping/20260325_202511_console_login_fix for 5 full iterations. All tests passed with no failures.

Any platform specific information?
None — applies to all platforms using SSH console connections.

Supported testbed topology if it's a new test case?
N/A (bug fix only)

Signed-off-by: mssonicbld <sonicbld@microsoft.com>
@mssonicbld
Copy link
Copy Markdown
Collaborator Author

Original PR: #23342

@mssonicbld
Copy link
Copy Markdown
Collaborator Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@lolyu
Copy link
Copy Markdown
Collaborator

lolyu commented Mar 30, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld mssonicbld merged commit db48e3f into sonic-net:202511 Mar 30, 2026
16 checks passed
venu-nexthop pushed a commit to nexthop-ai/sonic-mgmt that referenced this pull request Mar 30, 2026
…onic-net#23342) (sonic-net#23396)

What is the motivation for this PR?
dut_console tests were failing intermittently (~1 in 5 runs) with "Socket is closed" errors during console login. Root cause: the DUT's Password: prompt sometimes arrives split across multiple TCP reads, so per-chunk pattern matching never matches. A second independent failure in test_idle_timeout caused by splitlines()[-1] returning a prompt fragment instead of the numeric TMOUT value.

How did you do it?
ssh_console_conn.py: Changed re.search(pwd_pattern, output) to re.search(pwd_pattern, return_msg) in login_stage_2(), where return_msg is the accumulated read buffer across all chunks.
test_idle_timeout.py: Changed splitlines()[-1] to splitlines()[0] in the TMOUT value extraction, so we always get the first output line regardless of trailing prompt remnants.
How did you verify/test it?
Ran all dut_console test cases on a physical testbed using internal branch dev/xuliping/20260325_202511_console_login_fix for 5 full iterations. All tests passed with no failures.

Any platform specific information?
None — applies to all platforms using SSH console connections.

Supported testbed topology if it's a new test case?
N/A (bug fix only)

Signed-off-by: mssonicbld <sonicbld@microsoft.com>
Co-authored-by: Liping Xu <108326363+lipxu@users.noreply.github.com>
venu-nexthop pushed a commit to nexthop-ai/sonic-mgmt that referenced this pull request Mar 30, 2026
…onic-net#23342) (sonic-net#23396)

What is the motivation for this PR?
dut_console tests were failing intermittently (~1 in 5 runs) with "Socket is closed" errors during console login. Root cause: the DUT's Password: prompt sometimes arrives split across multiple TCP reads, so per-chunk pattern matching never matches. A second independent failure in test_idle_timeout caused by splitlines()[-1] returning a prompt fragment instead of the numeric TMOUT value.

How did you do it?
ssh_console_conn.py: Changed re.search(pwd_pattern, output) to re.search(pwd_pattern, return_msg) in login_stage_2(), where return_msg is the accumulated read buffer across all chunks.
test_idle_timeout.py: Changed splitlines()[-1] to splitlines()[0] in the TMOUT value extraction, so we always get the first output line regardless of trailing prompt remnants.
How did you verify/test it?
Ran all dut_console test cases on a physical testbed using internal branch dev/xuliping/20260325_202511_console_login_fix for 5 full iterations. All tests passed with no failures.

Any platform specific information?
None — applies to all platforms using SSH console connections.

Supported testbed topology if it's a new test case?
N/A (bug fix only)

Signed-off-by: mssonicbld <sonicbld@microsoft.com>
Co-authored-by: Liping Xu <108326363+lipxu@users.noreply.github.com>
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.

3 participants