summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric Ollivier <cedric.ollivier@orange.com>2017-08-24 13:19:11 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-24 13:19:11 +0000
commit671b3356e8fc7c6219919f978a3dee6b69e8c663 (patch)
tree3e311884dde7947a743b79bb29f50d308432296e
parentc67c6687976a486af880ece2e6831d7ef7fbbdcc (diff)
parent07e73e65dea6526ea835cbfe3f864a7e102f658c (diff)
Merge "Fix the tempest error when creating snapshot"
-rw-r--r--functest/opnfv_tests/openstack/refstack_client/refstack_client.py28
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py3
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py9
-rw-r--r--functest/tests/unit/openstack/refstack_client/test_refstack_client.py4
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py16
5 files changed, 27 insertions, 33 deletions
diff --git a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
index 220b08fe7..4f71b5f5d 100644
--- a/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
+++ b/functest/opnfv_tests/openstack/refstack_client/refstack_client.py
@@ -42,10 +42,10 @@ class RefstackClient(testcase.TestCase):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
+ self.tempestconf = None
self.conf_path = pkg_resources.resource_filename(
'functest',
'opnfv_tests/openstack/refstack_client/refstack_tempest.conf')
- self.tempestconf = None
self.functest_test = pkg_resources.resource_filename(
'functest', 'opnfv_tests')
self.defcore_list = 'openstack/refstack_client/defcore.txt'
@@ -59,6 +59,13 @@ class RefstackClient(testcase.TestCase):
CONST.__getattribute__('OS_INSECURE').lower() == 'true'):
self.insecure = '-k'
+ def generate_conf(self):
+ if not os.path.exists(conf_utils.REFSTACK_RESULTS_DIR):
+ os.makedirs(conf_utils.REFSTACK_RESULTS_DIR)
+
+ self.tempestconf = TempestConf()
+ self.tempestconf.generate_tempestconf()
+
def run_defcore(self, conf, testlist):
"""Run defcore sys command."""
cmd = ("refstack-client test {0} -c {1} -v --test-list {2}"
@@ -89,7 +96,7 @@ class RefstackClient(testcase.TestCase):
stderr=subprocess.STDOUT)
def parse_refstack_result(self):
- """Parse Refstact results."""
+ """Parse Refstack results."""
try:
with open(os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
"refstack.log"), 'r') as logfile:
@@ -146,12 +153,10 @@ class RefstackClient(testcase.TestCase):
"""
self.start_time = time.time()
- if not os.path.exists(conf_utils.REFSTACK_RESULTS_DIR):
- os.makedirs(conf_utils.REFSTACK_RESULTS_DIR)
-
try:
- self.tempestconf = TempestConf()
- self.tempestconf.generate_tempestconf()
+ # Make sure that Tempest is configured
+ if not self.tempestconf:
+ self.generate_conf()
self.run_defcore_default()
self.parse_refstack_result()
res = testcase.TestCase.EX_OK
@@ -207,8 +212,9 @@ class RefstackClient(testcase.TestCase):
"""
LOGGER.info("Initializing the saved state of the OpenStack deployment")
- # Make sure that the verifier is configured
- conf_utils.configure_verifier(self.tempestconf.DEPLOYMENT_DIR)
+ # Make sure that Tempest is configured
+ if not self.tempestconf:
+ self.generate_conf()
os_utils.init_tempest_cleanup(
self.tempestconf.DEPLOYMENT_DIR, 'tempest.conf',
@@ -223,9 +229,9 @@ class RefstackClient(testcase.TestCase):
Run the Tempest cleanup utility to delete and destroy OS resources.
For details, see https://docs.openstack.org/tempest/latest/cleanup.html
"""
- LOGGER.info("Initializing the saved state of the OpenStack deployment")
+ LOGGER.info("Destroying the resources created for tempest")
- os_utils.init_tempest_cleanup(
+ os_utils.perform_tempest_cleanup(
self.tempestconf.DEPLOYMENT_DIR, 'tempest.conf',
os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
"tempest-cleanup.log")
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index fccfebcef..52fa60032 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -130,9 +130,6 @@ def backup_tempest_config(conf_file):
"""
Copy config file to tempest results directory
"""
- if not os.path.exists(TEMPEST_RESULTS_DIR):
- os.makedirs(TEMPEST_RESULTS_DIR)
-
shutil.copyfile(conf_file,
os.path.join(TEMPEST_RESULTS_DIR, 'tempest.conf'))
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index 5129a56e3..c7ad4df2f 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -261,6 +261,9 @@ class TempestCommon(testcase.TestCase):
"""
logger.info("Initializing the saved state of the OpenStack deployment")
+ if not os.path.exists(conf_utils.TEMPEST_RESULTS_DIR):
+ os.makedirs(conf_utils.TEMPEST_RESULTS_DIR)
+
# Make sure that the verifier is configured
conf_utils.configure_verifier(self.DEPLOYMENT_DIR)
@@ -277,11 +280,11 @@ class TempestCommon(testcase.TestCase):
Run the Tempest cleanup utility to delete and destroy OS resources
created by Tempest.
"""
- logger.info("Initializing the saved state of the OpenStack deployment")
+ logger.info("Destroying the resources created for refstack")
- os_utils.init_tempest_cleanup(
+ os_utils.perform_tempest_cleanup(
self.DEPLOYMENT_DIR, 'tempest.conf',
- os.path.join(conf_utils.REFSTACK_RESULTS_DIR,
+ os.path.join(conf_utils.TEMPEST_RESULTS_DIR,
"tempest-cleanup.log")
)
diff --git a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
index 5a2013181..ca0974832 100644
--- a/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
+++ b/functest/tests/unit/openstack/refstack_client/test_refstack_client.py
@@ -36,7 +36,9 @@ class OSRefstackClientTesting(unittest.TestCase):
username='user', password='pass',
auth_url='http://foo.com:5000/v3', project_name='bar')
- def _create_client(self):
+ @mock.patch('functest.opnfv_tests.openstack.refstack_client.tempest_conf.'
+ 'TempestConf', return_value=mock.Mock())
+ def _create_client(self, mock_conf):
with mock.patch('snaps.openstack.tests.openstack_tests.'
'get_credentials', return_value=self.os_creds):
return RefstackClient()
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 22017a7a2..77558086b 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -170,23 +170,9 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
def test_backup_tempest_config_default(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.os.path.exists',
- return_value=False), \
- mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.os.makedirs') as m1, \
- mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.shutil.copyfile') as m2:
+ 'conf_utils.shutil.copyfile') as m1:
conf_utils.backup_tempest_config('test_conf_file')
self.assertTrue(m1.called)
- self.assertTrue(m2.called)
-
- with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.os.path.exists',
- return_value=True), \
- mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.shutil.copyfile') as m2:
- conf_utils.backup_tempest_config('test_conf_file')
- self.assertTrue(m2.called)
def test_configure_tempest_default(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'