From dd9eb03be634eaa46a89b85cd0c640ec99533b77 Mon Sep 17 00:00:00 2001 From: Juha Kosonen Date: Wed, 19 Dec 2018 16:09:53 +0200 Subject: Add task arguments to rally_jobs Define floating network as a Rally task argument. Enable rally_jobs subtest. Change-Id: I37d7c4718cfb3de3ad1980878e0529d652013ccb Signed-off-by: Juha Kosonen --- docker/smoke/testcases.yaml | 1 - functest/ci/testcases.yaml | 1 - functest/opnfv_tests/openstack/rally/rally.py | 18 ++++++++++++++---- functest/tests/unit/openstack/rally/test_rally.py | 8 ++++---- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/docker/smoke/testcases.yaml b/docker/smoke/testcases.yaml index d4e2ef1c6..c7f110a70 100644 --- a/docker/smoke/testcases.yaml +++ b/docker/smoke/testcases.yaml @@ -55,7 +55,6 @@ tiers: - case_name: rally_jobs project_name: functest - enabled: false criteria: 100 blocking: false description: >- diff --git a/functest/ci/testcases.yaml b/functest/ci/testcases.yaml index e209e1f80..0f8366418 100644 --- a/functest/ci/testcases.yaml +++ b/functest/ci/testcases.yaml @@ -227,7 +227,6 @@ tiers: - case_name: rally_jobs project_name: functest - enabled: false criteria: 100 blocking: false description: >- diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 594905b26..d40645972 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -94,9 +94,9 @@ class RallyBase(singlevm.VmReady2): self.run_cmd = '' self.network_extensions = [] - def _build_task_args(self, test_file_name): + def build_task_args(self, test_name): """Build arguments for the Rally task.""" - task_args = {'service_list': [test_file_name]} + task_args = {'service_list': [test_name]} task_args['image_name'] = str(self.image.name) task_args['flavor_name'] = str(self.flavor.name) task_args['flavor_alt_name'] = str(self.flavor_alt.name) @@ -456,7 +456,7 @@ class RallyBase(singlevm.VmReady2): return False self.run_cmd = (["rally", "task", "start", "--abort-on-sla-failure", "--task", self.task_file, "--task-args", - str(self._build_task_args(test_name))]) + str(self.build_task_args(test_name))]) return True def run_tests(self): @@ -662,6 +662,15 @@ class RallyJobs(RallyBase): with open(result_file_name, 'w') as fname: template.dump(cases, fname) + def build_task_args(self, test_name): + """Build arguments for the Rally task.""" + task_args = {} + if self.ext_net: + task_args['floating_network'] = str(self.ext_net.name) + else: + task_args['floating_network'] = '' + return task_args + @staticmethod def _remove_plugins_extra(): inst_dir = getattr(config.CONF, 'dir_rally_inst') @@ -692,7 +701,8 @@ class RallyJobs(RallyBase): os.makedirs(self.TEMP_DIR) task_file_name = os.path.join(self.TEMP_DIR, task_name) self.apply_blacklist(task, task_file_name) - self.run_cmd = (["rally", "task", "start", "--task", task_file_name]) + self.run_cmd = (["rally", "task", "start", "--task", task_file_name, + "--task-args", str(self.build_task_args(test_name))]) return True def clean(self): diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index 149925730..bd691b8ab 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -38,13 +38,13 @@ class OSRallyTesting(unittest.TestCase): def test_build_task_args_missing_floating_network(self): os.environ['OS_AUTH_URL'] = '' self.rally_base.ext_net = None - task_args = self.rally_base._build_task_args('test_file_name') + task_args = self.rally_base.build_task_args('test_name') self.assertEqual(task_args['floating_network'], '') def test_build_task_args_missing_net_id(self): os.environ['OS_AUTH_URL'] = '' self.rally_base.network = None - task_args = self.rally_base._build_task_args('test_file_name') + task_args = self.rally_base.build_task_args('test_name') self.assertEqual(task_args['netid'], '') @staticmethod @@ -206,7 +206,7 @@ class OSRallyTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' 'file_is_empty', return_value=False) @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' - '_build_task_args', return_value={}) + 'build_task_args', return_value={}) @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' 'get_task_id', return_value=None) @mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists', @@ -226,7 +226,7 @@ class OSRallyTesting(unittest.TestCase): @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' 'file_is_empty', return_value=False) @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' - '_build_task_args', return_value={}) + 'build_task_args', return_value={}) @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' 'get_task_id', return_value='1') @mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.' -- cgit 1.2.3-korg