aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--functest/opnfv_tests/openstack/tempest/conf_utils.py14
-rw-r--r--functest/opnfv_tests/openstack/tempest/tempest.py13
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py34
3 files changed, 18 insertions, 43 deletions
diff --git a/functest/opnfv_tests/openstack/tempest/conf_utils.py b/functest/opnfv_tests/openstack/tempest/conf_utils.py
index 80f78e979..d3f7a7b1f 100644
--- a/functest/opnfv_tests/openstack/tempest/conf_utils.py
+++ b/functest/opnfv_tests/openstack/tempest/conf_utils.py
@@ -81,6 +81,7 @@ def create_rally_deployment(environ=None):
cmd = ['rally', 'deployment', 'check']
output = subprocess.check_output(cmd)
LOGGER.info("%s\n%s", " ".join(cmd), output)
+ return get_verifier_deployment_id()
def create_verifier():
@@ -101,6 +102,7 @@ def create_verifier():
'--type', 'tempest', '--system-wide']
output = subprocess.check_output(cmd)
LOGGER.info("%s\n%s", " ".join(cmd), output)
+ return get_verifier_id()
def get_verifier_id():
@@ -114,9 +116,6 @@ def get_verifier_id():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
verifier_uuid = proc.stdout.readline().rstrip()
- if verifier_uuid == "":
- LOGGER.error("Tempest verifier not found.")
- raise Exception('Error with command:%s' % cmd)
return verifier_uuid
@@ -131,9 +130,6 @@ def get_verifier_deployment_id():
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
deployment_uuid = proc.stdout.readline().rstrip()
- if deployment_uuid == "":
- LOGGER.error("Rally deployment not found.")
- raise Exception('Error with command:%s' % cmd)
return deployment_uuid
@@ -261,10 +257,8 @@ def configure_verifier(deployment_dir):
if not os.path.isfile(tempest_conf_file):
LOGGER.error("Tempest configuration file %s NOT found.",
tempest_conf_file)
- raise Exception("Tempest configuration file %s NOT found."
- % tempest_conf_file)
- else:
- return tempest_conf_file
+ return None
+ return tempest_conf_file
def convert_dict_to_ini(value):
diff --git a/functest/opnfv_tests/openstack/tempest/tempest.py b/functest/opnfv_tests/openstack/tempest/tempest.py
index f30bbc552..a11d132dd 100644
--- a/functest/opnfv_tests/openstack/tempest/tempest.py
+++ b/functest/opnfv_tests/openstack/tempest/tempest.py
@@ -62,12 +62,15 @@ class TempestCommon(singlevm.VmReady2):
OS_PROJECT_NAME=self.project.project.name,
OS_PROJECT_ID=self.project.project.id,
OS_PASSWORD=self.project.password)
- conf_utils.create_rally_deployment(environ=environ)
- conf_utils.create_verifier()
- self.verifier_id = conf_utils.get_verifier_id()
+ self.deployment_id = conf_utils.create_rally_deployment(
+ environ=environ)
+ if not self.deployment_id:
+ raise Exception("Deployment create failed")
+ self.verifier_id = conf_utils.create_verifier()
+ if not self.verifier_id:
+ raise Exception("Verifier create failed")
self.verifier_repo_dir = conf_utils.get_verifier_repo_dir(
self.verifier_id)
- self.deployment_id = conf_utils.get_verifier_deployment_id()
self.deployment_dir = conf_utils.get_verifier_deployment_dir(
self.verifier_id, self.deployment_id)
self.verification_id = None
@@ -390,6 +393,8 @@ class TempestCommon(singlevm.VmReady2):
LOGGER.debug("flavor: %s", self.flavor_alt)
self.conf_file = conf_utils.configure_verifier(self.deployment_dir)
+ if not self.conf_file:
+ raise Exception("Tempest verifier configuring failed")
conf_utils.configure_tempest_update_params(
self.conf_file, network_name=self.network.name,
image_id=self.image.id,
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 7c493372f..c456c3997 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -20,9 +20,12 @@ from functest.utils import config
class OSTempestConfUtilsTesting(unittest.TestCase):
# pylint: disable=too-many-public-methods
+ @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils'
+ '.get_verifier_deployment_id', return_value='foo')
@mock.patch('subprocess.check_output')
- def test_create_rally_deployment(self, mock_exec):
- self.assertEqual(conf_utils.create_rally_deployment(), None)
+ def test_create_rally_deployment(self, mock_exec, mock_get_id):
+ # pylint: disable=unused-argument
+ self.assertEqual(conf_utils.create_rally_deployment(), 'foo')
calls = [
mock.call(['rally', 'deployment', 'destroy', '--deployment',
str(getattr(config.CONF, 'rally_deployment_name'))]),
@@ -51,22 +54,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
'create_verifier', return_value=mock.Mock())
@mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.'
'create_rally_deployment', return_value=mock.Mock())
- def test_get_verif_id_missing_verif(self, mock_rally, mock_tempest):
- # pylint: disable=unused-argument
- setattr(config.CONF, 'tempest_verifier_name', 'test_verifier_name')
- with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.subprocess.Popen') as mock_popen, \
- self.assertRaises(Exception):
- mock_stdout = mock.Mock()
- attrs = {'stdout.readline.return_value': ''}
- mock_stdout.configure_mock(**attrs)
- mock_popen.return_value = mock_stdout
- conf_utils.get_verifier_id()
-
- @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.'
- 'create_verifier', return_value=mock.Mock())
- @mock.patch('functest.opnfv_tests.openstack.tempest.conf_utils.'
- 'create_rally_deployment', return_value=mock.Mock())
def test_get_verifier_id_default(self, mock_rally, mock_tempest):
# pylint: disable=unused-argument
setattr(config.CONF, 'tempest_verifier_name', 'test_verifier_name')
@@ -80,17 +67,6 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
self.assertEqual(conf_utils.get_verifier_id(),
'test_deploy_id')
- def test_get_depl_id_missing_rally(self):
- setattr(config.CONF, 'tempest_verifier_name', 'test_deploy_name')
- with mock.patch('functest.opnfv_tests.openstack.tempest.'
- 'conf_utils.subprocess.Popen') as mock_popen, \
- self.assertRaises(Exception):
- mock_stdout = mock.Mock()
- attrs = {'stdout.readline.return_value': ''}
- mock_stdout.configure_mock(**attrs)
- mock_popen.return_value = mock_stdout
- conf_utils.get_verifier_deployment_id()
-
def test_get_depl_id_default(self):
setattr(config.CONF, 'tempest_verifier_name', 'test_deploy_name')
with mock.patch('functest.opnfv_tests.openstack.tempest.'