aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2017-07-14 21:05:17 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2017-07-17 03:07:30 +0200
commit8ff44552c3019305afa9faa92f788c9895676d33 (patch)
treee00d7d39adf5d90c2fd10dde9c2aecd6fddd3b2f
parent78d54dcc2d1131b791c0a111595844ef4506823d (diff)
Wait for refstack-client to finish
The previous implementation waited for /bin/sh to finish instead of refstack-client. Then tempest still ran in background even if the tescase was considered as finished. Now all tempest logs are only printed in the dedicated file. Change-Id: I94cd7c6fe68f3bc21782d8d9c43feee338c103ae Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py49
1 files changed, 18 insertions, 31 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 6ac721762..76bee19d1 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -65,39 +65,26 @@ class RefstackClient(testcase.OSGCTestCase):
ft_utils.execute_command(cmd)
def run_defcore_default(self):
- """Run default defcare sys command."""
- cmd = ("refstack-client test {0} -c {1} -v --test-list {2}"
- .format(self.insecure, self.confpath, self.defcorelist))
+ """Run default defcore sys command."""
+ options = ["-v"] if not self.insecure else ["-v", self.insecure]
+ cmd = (["refstack-client", "test", "-c", self.confpath] +
+ options + ["--test-list", self.defcorelist])
LOGGER.info("Starting Refstack_defcore test case: '%s'.", cmd)
- header = ("Refstack environment:\n"
- " SUT: %s\n Scenario: %s\n Node: %s\n Date: %s\n" %
- (CONST.__getattribute__('INSTALLER_TYPE'),
- CONST.__getattribute__('DEPLOY_SCENARIO'),
- CONST.__getattribute__('NODE_NAME'),
- time.strftime("%a %b %d %H:%M:%S %Z %Y")))
-
- f_stdout = open(
- os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
- "refstack.log"), 'w+')
- f_env = open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
- "environment.log"), 'w+')
- f_env.write(header)
-
- process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT, bufsize=1)
-
- with process.stdout:
- for line in iter(process.stdout.readline, b''):
- if 'Tests' in line:
- break
- if re.search(r"\} tempest\.", line):
- LOGGER.info(line.replace('\n', ''))
- f_stdout.write(line)
- process.wait()
-
- f_stdout.close()
- f_env.close()
+ with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
+ "environment.log"), 'w+') as f_env:
+ f_env.write(
+ ("Refstack environment:\n"
+ " SUT: {}\n Scenario: {}\n Node: {}\n Date: {}\n").format(
+ CONST.__getattribute__('INSTALLER_TYPE'),
+ CONST.__getattribute__('DEPLOY_SCENARIO'),
+ CONST.__getattribute__('NODE_NAME'),
+ time.strftime("%a %b %d %H:%M:%S %Z %Y")))
+
+ with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
+ "refstack.log"), 'w+') as f_stdout:
+ subprocess.call(cmd, shell=False, stdout=f_stdout,
+ stderr=subprocess.STDOUT)
def parse_refstack_result(self):
"""Parse Refstact results."""