Harden Rally generate report 47/63847/2
authorCédric Ollivier <cedric.ollivier@orange.com>
Sun, 21 Oct 2018 15:03:51 +0000 (17:03 +0200)
committerCédric Ollivier <cedric.ollivier@orange.com>
Sun, 21 Oct 2018 15:45:41 +0000 (17:45 +0200)
It converts html_file to str and raises all possible exceptions.
It sometimes fails when locally generating reports.

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

functest/opnfv_tests/openstack/tempest/tempest.py
functest/tests/unit/openstack/tempest/test_tempest.py

index 910b546..4d5a0f5 100644 (file)
@@ -314,9 +314,8 @@ class TempestCommon(singlevm.VmReady2):
         html_file = os.path.join(self.res_dir,
                                  "tempest-report.html")
         cmd = ["rally", "verify", "report", "--type", "html", "--uuid",
-               self.verification_id, "--to", html_file]
-        subprocess.Popen(cmd, stdout=subprocess.PIPE,
-                         stderr=subprocess.STDOUT)
+               self.verification_id, "--to", str(html_file)]
+        subprocess.check_output(cmd)
 
     def update_rally_regex(self, rally_conf='/etc/rally/rally.conf'):
         """Set image name as tempest img_name_regex"""
index c87c0b0..67e7dd4 100644 (file)
@@ -170,8 +170,7 @@ class OSTempestTesting(unittest.TestCase):
                 mock_logger_info. \
                     assert_any_call("Starting Tempest test suite: '%s'.", cmd)
 
-    @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
-                'subprocess.Popen')
+    @mock.patch('subprocess.check_output')
     def test_generate_report(self, mock_popen):
         self.tempestcommon.verification_id = "1234"
         html_file = os.path.join(
@@ -182,8 +181,7 @@ class OSTempestTesting(unittest.TestCase):
         cmd = ["rally", "verify", "report", "--type", "html", "--uuid",
                "1234", "--to", html_file]
         self.tempestcommon.generate_report()
-        mock_popen.assert_called_once_with(cmd, stdout=mock.ANY,
-                                           stderr=mock.ANY)
+        mock_popen.assert_called_once_with(cmd)
 
     @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
                 'os.path.exists', return_value=False)