From d1d8f2b387d3fd625ac98bc5bc37ff344b98ead8 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Wed, 25 Apr 2018 08:36:52 +0200 Subject: FIX: SSH socket reading error Currently if the command timeouts due to the nature of script execution we are trying to again read from socket after timeout on seesion expired. This patch is supposed to fix the behaviour and eliminate the second read from channel after it was cloed. Change-Id: Ib0028e901eb6ff4d10ca77d2ea19f9e770e6cef4 Signed-off-by: Peter Mikus --- resources/libraries/python/TrafficScriptExecutor.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'resources/libraries/python/TrafficScriptExecutor.py') diff --git a/resources/libraries/python/TrafficScriptExecutor.py b/resources/libraries/python/TrafficScriptExecutor.py index 58d48d3ca9..13696dee8d 100644 --- a/resources/libraries/python/TrafficScriptExecutor.py +++ b/resources/libraries/python/TrafficScriptExecutor.py @@ -13,8 +13,6 @@ """Traffic script executor library.""" -from robot.api import logger - from resources.libraries.python.constants import Constants from resources.libraries.python.ssh import SSH @@ -55,7 +53,6 @@ class TrafficScriptExecutor(object): :raises RuntimeError: ARP reply timeout. :raises RuntimeError: Traffic script execution failed. """ - logger.trace("{}".format(timeout)) ssh = SSH() ssh.connect(node) cmd = ("cd {}; " + @@ -65,12 +62,9 @@ class TrafficScriptExecutor(object): "resources/traffic_scripts/{} {}") \ .format(Constants.REMOTE_FW_DIR, script_file_name, script_args) - (ret_code, stdout, stderr) = ssh.exec_command_sudo( - 'sh -c "{}"'.format(TrafficScriptExecutor._escape(cmd)), + ret_code, stdout, stderr = ssh.exec_command_sudo( + 'sh -c "{cmd}"'.format(cmd=TrafficScriptExecutor._escape(cmd)), timeout=timeout) - logger.debug("stdout: {}".format(stdout)) - logger.debug("stderr: {}".format(stderr)) - logger.debug("ret_code: {}".format(ret_code)) if ret_code != 0: if "RuntimeError: ICMP echo Rx timeout" in stderr: raise RuntimeError("ICMP echo Rx timeout") -- cgit 1.2.3-korg