aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/openstack/rally/test_rally.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2019-02-09 11:32:26 +0100
committerCedric Ollivier <cedric.ollivier@orange.com>2019-02-12 21:00:42 +0000
commit2df7a0728d687de9a24d8432ef30bbd2ecd771c8 (patch)
treec5acbbb6f7d1b7646db585507dc76e03613008fd /functest/tests/unit/openstack/rally/test_rally.py
parent38cba4aa2c2cdfd17ea1aa0c29ee14ed7b2bf035 (diff)
Generate one single report for Rally testcases
It eases sharing one single report including all task results. For the time being, rally_jobs only generates neutron.html. Then it only adds one report for rally_full and rally_sanity. We may consider generating only one json file but it asks for a refactoring (result parsing) which can be done in a second change. Change-Id: I8fa75ae80750336950f355c2aedc3dd4dc621cc5 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/openstack/rally/test_rally.py')
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index bd691b8ab..fa307be24 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -10,6 +10,7 @@
import json
import logging
import os
+import subprocess
import unittest
import mock
@@ -17,6 +18,7 @@ import munch
from xtesting.core import testcase
from functest.opnfv_tests.openstack.rally import rally
+from functest.utils import config
class OSRallyTesting(unittest.TestCase):
@@ -324,6 +326,8 @@ class OSRallyTesting(unittest.TestCase):
'run_tests')
@mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.'
'_generate_report')
+ @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.'
+ 'generate_html_report')
def test_run_default(self, *args):
self.assertEqual(self.rally_base.run(), testcase.TestCase.EX_OK)
for func in args:
@@ -370,6 +374,26 @@ class OSRallyTesting(unittest.TestCase):
self.assertEqual(self.rally_base.is_successful(), 424)
mock_super(rally.RallyBase, self).is_successful.assert_called()
+ @mock.patch('subprocess.check_output',
+ side_effect=subprocess.CalledProcessError('', ''))
+ def test_generate_html_report_ko(self, *args):
+ with self.assertRaises(subprocess.CalledProcessError):
+ self.rally_base.generate_html_report()
+ cmd = ["rally", "task", "report", "--deployment",
+ str(getattr(config.CONF, 'rally_deployment_name')),
+ "--out", "{}/{}.html".format(
+ self.rally_base.results_dir, self.rally_base.case_name)]
+ args[0].assert_called_with(cmd, stderr=subprocess.STDOUT)
+
+ @mock.patch('subprocess.check_output', return_value=None)
+ def test_generate_html_report(self, *args):
+ self.assertEqual(self.rally_base.generate_html_report(), None)
+ cmd = ["rally", "task", "report", "--deployment",
+ str(getattr(config.CONF, 'rally_deployment_name')),
+ "--out", "{}/{}.html".format(
+ self.rally_base.results_dir, self.rally_base.case_name)]
+ args[0].assert_called_with(cmd, stderr=subprocess.STDOUT)
+
if __name__ == "__main__":
logging.disable(logging.CRITICAL)