Redirect stderr to stdout when running tempest 05/61305/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Thu, 9 Aug 2018 14:22:12 +0000 (16:22 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Thu, 23 Aug 2018 21:50:11 +0000 (23:50 +0200)
JIRA: FUNCTEST-999

Change-Id: I64bfa31b01aa2ce5444b6e0f0ac46f8cde8dbaa3
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
(cherry picked from commit c4b3f91c6bb79c50adc1c5a4397666ebcd1f7375)

functest/opnfv_tests/openstack/tempest/tempest.py

index 4965244..aaa2d3d 100644 (file)
@@ -79,10 +79,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:
@@ -171,20 +171,17 @@ 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('Starting verification', line):
                     LOGGER.info(line.replace('\n', ''))
                     first_pos = line.index("UUID=") + len("UUID=")
@@ -193,12 +190,11 @@ class TempestCommon(singlevm.VmReady1):
                     LOGGER.debug('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)
 
         shutil.copy(
             "{}/tempest.log".format(self.deployment_dir),