From 40bbe6cd80940e3ed320dca8b8ac7917353b5fcd Mon Sep 17 00:00:00 2001 From: boucherv Date: Tue, 19 Jul 2016 16:05:11 +0200 Subject: Catch timeout exception in vIMS JIRA: FUNCTEST-368 Change-Id: Ifeec4b89e9a05ee02d5a0829ee787dbd6ef528b2 Signed-off-by: boucherv --- testcases/vnf/vIMS/orchestrator.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'testcases/vnf') diff --git a/testcases/vnf/vIMS/orchestrator.py b/testcases/vnf/vIMS/orchestrator.py index f52afe1b..7917e77e 100644 --- a/testcases/vnf/vIMS/orchestrator.py +++ b/testcases/vnf/vIMS/orchestrator.py @@ -176,7 +176,7 @@ class orchestrator: dep_name + " --timeout 1800; ") cmd = "/bin/bash -c '" + script + "'" - error = execute_command(cmd, self.logger) + error = execute_command(cmd, self.logger, 2000) if error: return error if self.logger: @@ -205,10 +205,18 @@ def execute_command(cmd, logger, timeout=1800): """ if logger: logger.debug('Executing command : {}'.format(cmd)) + timeout_exception = False output_file = "output.txt" f = open(output_file, 'w+') - p = subprocess.call(cmd, shell=True, stdout=f, - stderr=subprocess.STDOUT, timeout=timeout) + try: + p = subprocess.call(cmd, shell=True, stdout=f, + stderr=subprocess.STDOUT, timeout=timeout) + except subprocess.TimeoutExpired: + timeout_exception = True + if logger: + logger.error("TIMEOUT when executing command %s" % cmd) + pass + f.close() f = open(output_file, 'r') result = f.read() @@ -217,7 +225,7 @@ def execute_command(cmd, logger, timeout=1800): if p == 0: return False else: - if logger: + if logger and not timeout_exception: logger.error("Error when executing command %s" % cmd) f = open(output_file, 'r') lines = f.readlines() -- cgit 1.2.3-korg