From 67de027d986df6c20fe6eeac7da653ebb49b8576 Mon Sep 17 00:00:00 2001 From: Corey Bryant Date: Tue, 10 Mar 2020 20:53:40 +0000 Subject: [PATCH] Move tempest init to setup.py and use a local workspace path --- zaza/openstack/charm_tests/tempest/setup.py | 17 +++++++++++------ zaza/openstack/charm_tests/tempest/tests.py | 11 ++--------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/zaza/openstack/charm_tests/tempest/setup.py b/zaza/openstack/charm_tests/tempest/setup.py index 2fd95f4..9ffe663 100644 --- a/zaza/openstack/charm_tests/tempest/setup.py +++ b/zaza/openstack/charm_tests/tempest/setup.py @@ -15,6 +15,7 @@ """Code for configuring tempest.""" import urllib.parse import os +import shutil import subprocess import zaza.model @@ -24,6 +25,7 @@ import zaza.openstack.charm_tests.glance.setup as glance_setup import zaza.openstack.charm_tests.tempest.templates.tempest_v2 as tempest_v2 import zaza.openstack.charm_tests.tempest.templates.tempest_v3 as tempest_v3 import zaza.openstack.charm_tests.tempest.templates.accounts as accounts +import tempest.cmd.main import keystoneauth1 import novaclient @@ -148,16 +150,18 @@ def render_tempest_config(target_file, ctxt, tempest_template): def setup_tempest(tempest_template, accounts_template): - try: - os.makedirs('tempest_workspace/etc/') - except FileExistsError: - pass + tempest_workspace = 'tempest_workspace' + the_app = tempest.cmd.main.Main() + tempest_options = ['init', '--workspace-path', './.tempest/workspace.yaml', + tempest_workspace] + print(tempest_options) + _exec_tempest = the_app.run(tempest_options) render_tempest_config( - 'tempest_workspace/etc/tempest.conf', + os.path.join(tempest_workspace, 'etc/tempest.conf'), get_tempest_context(), tempest_template) render_tempest_config( - 'tempest_workspace/etc/accounts.yaml', + os.path.join(tempest_workspace, 'etc/accounts.yaml'), get_tempest_context(), accounts_template) @@ -216,3 +220,4 @@ def add_tempest_roles(): keystone_client.roles.create(role_name) except keystoneauth1.exceptions.http.Conflict: pass + diff --git a/zaza/openstack/charm_tests/tempest/tests.py b/zaza/openstack/charm_tests/tempest/tests.py index 1626dc5..a4f97e4 100644 --- a/zaza/openstack/charm_tests/tempest/tests.py +++ b/zaza/openstack/charm_tests/tempest/tests.py @@ -13,18 +13,11 @@ class TempestTest(): test_runner = zaza.charm_lifecycle.test.DIRECT def run(self): - tempest_workspace = 'tempest_workspace' - tempest_options = ['init', tempest_workspace] - if not os.path.isdir(tempest_workspace): - the_app = tempest.cmd.main.Main() - print(tempest_options) - _exec_tempest = the_app.run(tempest_options) - if _exec_tempest != 0: - return False - charm_config = zaza.charm_lifecycle.utils.get_charm_config() + tempest_workspace = 'tempest_workspace' tempest_options = ['run', '--config', os.path.join(tempest_workspace, 'etc/tempest.conf'), + '--workspace-path', './.tempest/workspace.yaml', '--workspace', 'tempest_workspace'] for model_alias in zaza.model.get_juju_model_aliases().keys(): tempest_test_key = model_alias