diff options
author | Cedric Ollivier <cedric.ollivier@orange.com> | 2018-10-16 16:32:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-10-16 16:32:41 +0000 |
commit | 18932f364b3bdc9c3c18cae98e5616b5178db499 (patch) | |
tree | c67b6598ec6c03c0ada5af113bfcd5f02ffde603 | |
parent | 5a5f4fea5727b26a48d1943eacd10440960bc540 (diff) | |
parent | 0d3c30ea25a91f5fb37c49643094e362dcbc286b (diff) |
Merge "Do not create files in site-package directory" into stable/gambia
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 27 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/rally/task.yaml | 4 | ||||
-rw-r--r-- | functest/tests/unit/openstack/rally/test_rally.py | 3 |
3 files changed, 25 insertions, 9 deletions
diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index ac44de118..1d7d75ff4 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -56,7 +56,8 @@ class RallyBase(singlevm.VmReady2): ITERATIONS_AMOUNT = 10 CONCURRENCY = 4 BLACKLIST_FILE = os.path.join(RALLY_DIR, "blacklist.txt") - TEMP_DIR = os.path.join(RALLY_DIR, "var") + TASK_DIR = os.path.join(getattr(config.CONF, 'dir_rally_data'), 'task') + TEMP_DIR = os.path.join(TASK_DIR, 'var') visibility = 'public' shared_network = True @@ -78,7 +79,7 @@ class RallyBase(singlevm.VmReady2): domain=self.project.domain.id) self.results_dir = os.path.join( getattr(config.CONF, 'dir_results'), self.case_name) - self.task_file = os.path.join(self.RALLY_DIR, 'task.yaml') + self.task_file = '' self.creators = [] self.summary = [] self.scenario_dir = '' @@ -420,10 +421,26 @@ class RallyBase(singlevm.VmReady2): else: raise Exception("Test name '%s' is invalid" % self.test_name) - if not os.path.exists(self.task_file): - LOGGER.error("Task file '%s' does not exist.", self.task_file) + if not os.path.exists(self.TASK_DIR): + os.makedirs(self.TASK_DIR) + + task = os.path.join(self.RALLY_DIR, 'task.yaml') + if not os.path.exists(task): + LOGGER.error("Task file '%s' does not exist.", task) raise Exception("Task file '{}' does not exist.". - format(self.task_file)) + format(task)) + self.task_file = os.path.join(self.TASK_DIR, 'task.yaml') + shutil.copyfile(task, self.task_file) + + task_macro = os.path.join(self.RALLY_DIR, 'macro') + if not os.path.exists(task_macro): + LOGGER.error("Task macro dir '%s' does not exist.", task_macro) + raise Exception("Task macro dir '{}' does not exist.". + format(task_macro)) + macro_dir = os.path.join(self.TASK_DIR, 'macro') + if os.path.exists(macro_dir): + shutil.rmtree(macro_dir) + shutil.copytree(task_macro, macro_dir) self.update_keystone_default_role() self.compute_cnt = len(self.cloud.list_hypervisors()) diff --git a/functest/opnfv_tests/openstack/rally/task.yaml b/functest/opnfv_tests/openstack/rally/task.yaml index fe9304fc2..14d4e718c 100644 --- a/functest/opnfv_tests/openstack/rally/task.yaml +++ b/functest/opnfv_tests/openstack/rally/task.yaml @@ -42,7 +42,3 @@ {% if "heat" in service_list %} {%- include "var/opnfv-heat.yaml"-%} {% endif %} - -{% if "vm" in service_list %} -{%- include "var/opnfv-vm.yaml"-%} -{% endif %} diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index 22ddb1cc5..149925730 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -267,6 +267,9 @@ class OSRallyTesting(unittest.TestCase): self.rally_base.prepare_run() @mock.patch('functest.opnfv_tests.openstack.rally.rally.os.path.exists') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.shutil.copyfile') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.shutil.copytree') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.shutil.rmtree') def test_prepare_run_flavor_alt_creation_failed(self, *args): # pylint: disable=unused-argument self.rally_base.TESTS = ['test1', 'test2'] |