diff --git a/tests/common/connections/ssh_console_conn.py b/tests/common/connections/ssh_console_conn.py index ef3122e9176..89b975242ee 100644 --- a/tests/common/connections/ssh_console_conn.py +++ b/tests/common/connections/ssh_console_conn.py @@ -135,7 +135,9 @@ def login_stage_2(self, user_sent = True # Search for password pattern / send password - if user_sent and not password_sent and re.search(pwd_pattern, output, flags=re.I): + # Use return_msg (accumulated) instead of output to handle cases where + # 'Password:' prompt is split across multiple TCP reads (e.g. 'Pa' + 'ssword:') + if user_sent and not password_sent and re.search(pwd_pattern, return_msg, flags=re.I): self.write_channel(password + self.RETURN) time.sleep(0.5 * delay_factor) output = self.read_channel() diff --git a/tests/dut_console/test_idle_timeout.py b/tests/dut_console/test_idle_timeout.py index 0ec7b20df0a..06a5e760f8f 100644 --- a/tests/dut_console/test_idle_timeout.py +++ b/tests/dut_console/test_idle_timeout.py @@ -1,5 +1,6 @@ import logging import time + import pytest from tests.common.helpers.assertions import pytest_assert @@ -17,12 +18,12 @@ def test_timeout(duthost_console, duthosts, enum_rand_one_per_hwsku_hostname): duthost = duthosts[enum_rand_one_per_hwsku_hostname] logger.info("Get default session idle timeout") - default_tmout = duthost_console.send_command('echo $TMOUT') + default_tmout = duthost_console.send_command('echo $TMOUT').strip().splitlines()[0].strip() pytest_assert(default_tmout == DEFAULT_TMOUT, "default timeout on dut is not {} seconds".format(DEFAULT_TMOUT)) logger.info("Set session idle timeout") duthost_console.send_command('export TMOUT={}'.format(SET_TMOUT)) - set_tmout = duthost_console.send_command('echo $TMOUT') + set_tmout = duthost_console.send_command('echo $TMOUT').strip().splitlines()[0].strip() pytest_assert(set_tmout == SET_TMOUT, "set timeout fail") time.sleep(15)