From fc90eedb089a6deaf16159e1cf495ca5ce9fe85d Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 14 Aug 2024 14:15:43 +0800 Subject: [PATCH] Improve test_ssh_limit test case not receive EOF issue --- tests/ssh/test_ssh_limit.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tests/ssh/test_ssh_limit.py b/tests/ssh/test_ssh_limit.py index 9c4734fa159..85c02f87ee0 100755 --- a/tests/ssh/test_ssh_limit.py +++ b/tests/ssh/test_ssh_limit.py @@ -43,17 +43,19 @@ def get_device_type(duthost): return dut_type +def exec_command(admin_session, command): + stdin, stdout, stderr = admin_session.exec_command(command) + outstr = stdout.readlines() + errstr = stderr.readlines() + logging.info("Command: '{}' stdout: {} stderr: {}".format(command, outstr, errstr)) + + def modify_template(admin_session, template_path, additional_content, hwsku, type): - admin_session.exec_command(TEMPLATE_BACKUP_COMMAND.format(template_path)) - admin_session.exec_command(TEMPLATE_CREATE_COMMAND.format(template_path)) - admin_session.exec_command( - LIMITS_CONF_TEMPLATE_TO_HOME.format(hwsku, type, additional_content)) - admin_session.exec_command(TEMPLATE_MOVE_COMMAND.format(template_path)) - - stdin, stdout, stderr = admin_session.exec_command( - 'sudo cat {0}'.format(template_path)) - config_file_content = stdout.readlines() - logging.info("Updated template file: {0}".format(config_file_content)) + exec_command(admin_session, TEMPLATE_BACKUP_COMMAND.format(template_path)) + exec_command(admin_session, TEMPLATE_CREATE_COMMAND.format(template_path)) + exec_command(admin_session, LIMITS_CONF_TEMPLATE_TO_HOME.format(hwsku, type, additional_content)) + exec_command(admin_session, TEMPLATE_MOVE_COMMAND.format(template_path)) + exec_command(admin_session, 'sudo cat {0}'.format(template_path)) def modify_templates(duthost, tacacs_creds, creds): # noqa F811