Add task arguments to rally_jobs 83/65983/1
authorJuha Kosonen <juha.kosonen@nokia.com>
Wed, 19 Dec 2018 14:09:53 +0000 (16:09 +0200)
committerJuha Kosonen <juha.kosonen@nokia.com>
Wed, 19 Dec 2018 14:09:53 +0000 (16:09 +0200)
Define floating network as a Rally task argument.

Enable rally_jobs subtest.

Change-Id: I37d7c4718cfb3de3ad1980878e0529d652013ccb
Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
docker/smoke/testcases.yaml
functest/ci/testcases.yaml
functest/opnfv_tests/openstack/rally/rally.py
functest/tests/unit/openstack/rally/test_rally.py

index d4e2ef1..c7f110a 100644 (file)
@@ -55,7 +55,6 @@ tiers:
             -
                 case_name: rally_jobs
                 project_name: functest
-                enabled: false
                 criteria: 100
                 blocking: false
                 description: >-
index e209e1f..0f83664 100644 (file)
@@ -227,7 +227,6 @@ tiers:
             -
                 case_name: rally_jobs
                 project_name: functest
-                enabled: false
                 criteria: 100
                 blocking: false
                 description: >-
index 594905b..d406459 100644 (file)
@@ -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):
index 1499257..bd691b8 100644 (file)
@@ -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.'