summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStamatis Katsaounis <mokats@intracom-telecom.com>2019-02-08 18:56:16 +0200
committerStamatis Katsaounis <mokats@intracom-telecom.com>2019-02-13 16:23:12 +0200
commitd0cb38d7ad5046700564f2700df9b8c92706b32c (patch)
tree50f5efa3e53738295ae099590b93357fef4f2a07
parent2df7a0728d687de9a24d8432ef30bbd2ecd771c8 (diff)
Specify which rally tests to run
This patch adds the ability to specify which rally test to run by setting the appropriate configuration value. Change-Id: I6cbc9d12aada4f8eab68d2219d94ae1391a79021 Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
-rw-r--r--functest/opnfv_tests/openstack/rally/rally.py32
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py8
2 files changed, 16 insertions, 24 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py
index b6b285a7c..ecffd3f44 100644
--- a/functest/opnfv_tests/openstack/rally/rally.py
+++ b/functest/opnfv_tests/openstack/rally/rally.py
@@ -83,7 +83,6 @@ class RallyBase(singlevm.VmReady2):
self.summary = []
self.scenario_dir = ''
self.smoke = None
- self.test_name = None
self.start_time = None
self.result = None
self.details = None
@@ -401,16 +400,15 @@ class RallyBase(singlevm.VmReady2):
'task_status': self.task_succeed(json_raw)}
self.summary.append(scenario_summary)
- def prepare_run(self):
+ def prepare_run(self, **kwargs):
"""Prepare resources needed by test scenarios."""
assert self.cloud
- LOGGER.debug('Validating the test name...')
- if self.test_name == 'all':
- self.tests = self.TESTS
- elif self.test_name in self.TESTS:
- self.tests = [self.test_name]
- else:
- raise Exception("Test name '%s' is invalid" % self.test_name)
+ LOGGER.debug('Validating run tests...')
+ for test in kwargs.get('tests', self.TESTS):
+ if test in self.TESTS:
+ self.tests.append(test)
+ else:
+ raise Exception("Test name '%s' is invalid" % test)
if not os.path.exists(self.TASK_DIR):
os.makedirs(self.TASK_DIR)
@@ -567,7 +565,7 @@ class RallyBase(singlevm.VmReady2):
except Exception: # pylint: disable=broad-except
pass
conf_utils.create_rally_deployment(environ=environ)
- self.prepare_run()
+ self.prepare_run(**kwargs)
self.run_tests(**kwargs)
self._generate_report()
self.generate_html_report()
@@ -588,7 +586,6 @@ class RallySanity(RallyBase):
if "case_name" not in kwargs:
kwargs["case_name"] = "rally_sanity"
super(RallySanity, self).__init__(**kwargs)
- self.test_name = 'all'
self.smoke = True
self.scenario_dir = os.path.join(self.RALLY_SCENARIO_DIR, 'sanity')
@@ -601,7 +598,6 @@ class RallyFull(RallyBase):
if "case_name" not in kwargs:
kwargs["case_name"] = "rally_full"
super(RallyFull, self).__init__(**kwargs)
- self.test_name = 'all'
self.smoke = False
self.scenario_dir = os.path.join(self.RALLY_SCENARIO_DIR, 'full')
@@ -616,20 +612,20 @@ class RallyJobs(RallyBase):
if "case_name" not in kwargs:
kwargs["case_name"] = "rally_jobs"
super(RallyJobs, self).__init__(**kwargs)
- self.test_name = 'all'
self.task_file = os.path.join(self.RALLY_DIR, 'rally_jobs.yaml')
self.task_yaml = None
- def prepare_run(self):
+ def prepare_run(self, **kwargs):
"""Create resources needed by test scenarios."""
- super(RallyJobs, self).prepare_run()
+ super(RallyJobs, self).prepare_run(**kwargs)
with open(os.path.join(self.RALLY_DIR,
'rally_jobs.yaml'), 'r') as task_file:
self.task_yaml = yaml.safe_load(task_file)
- if not all(task in self.task_yaml for task in self.tests):
- raise Exception("Test '%s' not in '%s'" %
- (self.test_name, self.tests))
+ for task in self.task_yaml:
+ if task not in self.tests:
+ raise Exception("Test '%s' not in '%s'" %
+ (task, self.tests))
def apply_blacklist(self, case_file_name, result_file_name):
# pylint: disable=too-many-branches
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index fa307be24..0a605dd4c 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -32,7 +32,6 @@ class OSRallyTesting(unittest.TestCase):
self.rally_base.image = munch.Munch(name='foo')
self.rally_base.flavor = munch.Munch(name='foo')
self.rally_base.flavor_alt = munch.Munch(name='bar')
- self.rally_base.test_name = 'all'
self.assertTrue(mock_get_config.called)
self.assertTrue(mock_shade.called)
self.assertTrue(mock_new_project.called)
@@ -264,9 +263,8 @@ class OSRallyTesting(unittest.TestCase):
def test_prepare_run_testname_invalid(self):
self.rally_base.TESTS = ['test1', 'test2']
- self.rally_base.test_name = 'test'
with self.assertRaises(Exception):
- self.rally_base.prepare_run()
+ self.rally_base.prepare_run(tests=['test'])
@mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists')
@mock.patch('functest.opnfv_tests.openstack.rally.rally.shutil.copyfile')
@@ -275,14 +273,13 @@ class OSRallyTesting(unittest.TestCase):
def test_prepare_run_flavor_alt_creation_failed(self, *args):
# pylint: disable=unused-argument
self.rally_base.TESTS = ['test1', 'test2']
- self.rally_base.test_name = 'test1'
with mock.patch.object(self.rally_base.cloud,
'list_hypervisors') as mock_list_hyperv, \
mock.patch.object(self.rally_base, 'create_flavor_alt',
side_effect=Exception) \
as mock_create_flavor:
with self.assertRaises(Exception):
- self.rally_base.prepare_run()
+ self.rally_base.prepare_run(tests=['test1'])
mock_list_hyperv.assert_called_once()
mock_create_flavor.assert_called_once()
@@ -292,7 +289,6 @@ class OSRallyTesting(unittest.TestCase):
'run_task')
def test_run_tests_all(self, mock_run_task, mock_prepare_task):
self.rally_base.tests = ['test1', 'test2']
- self.rally_base.test_name = 'all'
self.rally_base.run_tests()
mock_prepare_task.assert_any_call('test1')
mock_prepare_task.assert_any_call('test2')