self.summary = []
self.scenario_dir = ''
self.smoke = None
- self.test_name = None
self.start_time = None
self.result = None
self.details = None
'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)
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()
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')
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')
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
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)
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')
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()
'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')