diff --git a/zaza/openstack/charm_tests/tempest/setup.py b/zaza/openstack/charm_tests/tempest/setup.py index 214b816..9789d1e 100644 --- a/zaza/openstack/charm_tests/tempest/setup.py +++ b/zaza/openstack/charm_tests/tempest/setup.py @@ -15,7 +15,7 @@ """Code for configuring tempest.""" import urllib.parse import os -#import shutil +import shutil import subprocess import zaza.model @@ -154,10 +154,17 @@ def render_tempest_config(target_file, ctxt, tempest_template): def setup_tempest(tempest_template, accounts_template): - try: - os.makedirs('tempest/etc/') - except FileExistsError: - pass + #try: + # os.makedirs('tempest/etc/') + #except FileExistsError: + # pass + if os.path.isdir('tempest-workspace'): + try: + subprocess.check_call(['tempest', 'workspace', 'remove', '--rmdir', '--name', 'tempest-workspace']) + except subprocess.CalledProcessError: + pass + #shutil.rmtree('tempest-workspace') + subprocess.check_call(['tempest', 'init', 'tempest-workspace']) #config_dir = '.tempest' #config_etc_dir = os.path.join(config_dir, 'etc') #config_etc_tempest = os.path.join(config_etc_dir, 'tempest.conf') @@ -183,12 +190,12 @@ def setup_tempest(tempest_template, accounts_template): #_exec_tempest = the_app.run(tempest_options) # This was mising /etc/tempest/ and just going to /etc/ render_tempest_config( - 'tempest/etc/tempest.conf', + 'tempest-workspace/etc/tempest.conf', #workspace_etc_tempest, get_tempest_context(), tempest_template) render_tempest_config( - 'tempest/etc/accounts.yaml', + 'tempest-workspace/etc/accounts.yaml', #workspace_etc_accounts, get_tempest_context(), accounts_template) diff --git a/zaza/openstack/charm_tests/tempest/tests.py b/zaza/openstack/charm_tests/tempest/tests.py index 5e949aa..a4360a9 100644 --- a/zaza/openstack/charm_tests/tempest/tests.py +++ b/zaza/openstack/charm_tests/tempest/tests.py @@ -1,4 +1,5 @@ import os +import subprocess import zaza import zaza.charm_lifecycle.utils @@ -14,7 +15,8 @@ class TempestTest(): def run(self): charm_config = zaza.charm_lifecycle.utils.get_charm_config() - tempest_options = ['run', '--config', 'tempest/etc/tempest.conf'] + tempest_options = ['run', '--workspace', 'tempest-workspace', + '--config', 'tempest-workspace/etc/tempest.conf'] #config_dir = '.tempest' #config_workspace_yaml = os.path.join(config_dir, 'workspace.yaml') #workspace_name = 'workspace' @@ -54,10 +56,12 @@ class TempestTest(): f.write('\n') tempest_options.extend(['--blacklist-file', black_file]) print(tempest_options) - the_app = tempest.cmd.main.Main() - project_root = os.getcwd() - _exec_tempest = the_app.run(tempest_options) - os.chdir(project_root) - if _exec_tempest != 0: + #the_app = tempest.cmd.main.Main() + #project_root = os.getcwd() + #_exec_tempest = the_app.run(tempest_options) + #os.chdir(project_root) + try: + subprocess.check_call(tempest_options) + except subprocess.CalledProcessError: return False return True