summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-08-09 16:22:12 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-08-10 18:14:09 +0200
commitc4b3f91c6bb79c50adc1c5a4397666ebcd1f7375 (patch)
treeff8c942dcde5f5a72fc3ba621b55aedb911f36f4
parent78435bee2c41e269b9151954d0ce2a84e6ea0008 (diff)
Publish rally logs to ease debugging.
It also redirect stderr to stdout as tempest mainly prints in stderr. JIRA: FUNCTEST-999 Change-Id: I64bfa31b01aa2ce5444b6e0f0ac46f8cde8dbaa3 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py27
1 files changed, 17 insertions, 10 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 05f13c051..452c82d26 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -112,10 +112,10 @@ class TempestCommon(singlevm.VmReady1):
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
for line in proc.stdout:
+ LOGGER.info(line.rstrip())
new_line = line.replace(' ', '').split('|')
if 'Tests' in new_line:
break
- LOGGER.info(line)
if 'Testscount' in new_line:
result['num_tests'] = int(new_line[2])
elif 'Success' in new_line:
@@ -204,32 +204,27 @@ class TempestCommon(singlevm.VmReady1):
f_stdout = open(
os.path.join(self.res_dir, "tempest.log"), 'w+')
- f_stderr = open(
- os.path.join(self.res_dir,
- "tempest-error.log"), 'w+')
proc = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
- stderr=f_stderr,
+ stderr=subprocess.STDOUT,
bufsize=1)
with proc.stdout:
for line in iter(proc.stdout.readline, b''):
if re.search(r"\} tempest\.", line):
- LOGGER.info(line.replace('\n', ''))
+ LOGGER.info(line.rstrip())
elif re.search(r'(?=\(UUID=(.*)\))', line):
self.verification_id = re.search(
r'(?=\(UUID=(.*)\))', line).group(1)
- LOGGER.info('Verification UUID: %s', self.verification_id)
f_stdout.write(line)
proc.wait()
-
f_stdout.close()
- f_stderr.close()
if self.verification_id is None:
raise Exception('Verification UUID not found')
+ LOGGER.info('Verification UUID: %s', self.verification_id)
def parse_verifier_result(self):
"""Parse and save test results."""
@@ -247,7 +242,7 @@ class TempestCommon(singlevm.VmReady1):
return
with open(os.path.join(self.res_dir,
- "tempest-error.log"), 'r') as logfile:
+ "tempest.log"), 'r') as logfile:
output = logfile.read()
success_testcases = []
@@ -309,6 +304,17 @@ class TempestCommon(singlevm.VmReady1):
with open(rally_conf, 'wb') as config_file:
rconfig.write(config_file)
+ def update_rally_logs(self, rally_conf='/etc/rally/rally.conf'):
+ """Print rally logs in res dir"""
+ if not os.path.exists(self.res_dir):
+ os.makedirs(self.res_dir)
+ rconfig = configparser.RawConfigParser()
+ rconfig.read(rally_conf)
+ rconfig.set('DEFAULT', 'log-file', 'rally.log')
+ rconfig.set('DEFAULT', 'log_dir', self.res_dir)
+ with open(rally_conf, 'wb') as config_file:
+ rconfig.write(config_file)
+
def configure(self, **kwargs): # pylint: disable=unused-argument
"""
Create all openstack resources for tempest-based testcases and write
@@ -339,6 +345,7 @@ class TempestCommon(singlevm.VmReady1):
**kwargs) == testcase.TestCase.EX_OK
self.update_rally_regex()
self.update_default_role()
+ self.update_rally_logs()
self.configure(**kwargs)
self.generate_test_list(**kwargs)
self.apply_tempest_blacklist()