diff options
author | boucherv <valentin.boucher@orange.com> | 2016-07-19 16:05:11 +0200 |
---|---|---|
committer | boucherv <valentin.boucher@orange.com> | 2016-07-19 16:18:18 +0200 |
commit | 40bbe6cd80940e3ed320dca8b8ac7917353b5fcd (patch) | |
tree | 597a0a4ed687c7b3b22646c0c226dae19b40e7e8 | |
parent | 0f5113627629c6f858b697a0b3ff141c9492d564 (diff) |
Catch timeout exception in vIMS
JIRA: FUNCTEST-368
Change-Id: Ifeec4b89e9a05ee02d5a0829ee787dbd6ef528b2
Signed-off-by: boucherv <valentin.boucher@orange.com>
-rw-r--r-- | testcases/vnf/vIMS/orchestrator.py | 16 |
1 files changed, 12 insertions, 4 deletions
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() |