aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/openstack
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-04-29 15:56:33 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-04-30 00:34:19 +0200
commit9fb702111ae63824a2e293d327437d0486a565d2 (patch)
tree12ec50cad8ce5bd26be41b04b29447bede9aafc4 /functest/tests/unit/openstack
parentf1fbaabcc46dafe4b9937af600294f042cab31e0 (diff)
Rewrite TempestResourcesManager
It now leverages on OpenStack Shade to allow gating OpenStack master as asked by TSC. Switching to OpenStack master (OpenStack SDK Rocky) requires to change only one line. It stops dedicating the network to the user possibly created because the support is incomplete (the users have to be registed in tempest.conf and the multiprocessing has to be enforced). It also writes the second image and the second flavor in tempest.conf. Change-Id: I9fe2c90a6073ebc240e9aa8fdf2ef93d5dd5f15f Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/tests/unit/openstack')
-rw-r--r--functest/tests/unit/openstack/tempest/test_conf_utils.py75
-rw-r--r--functest/tests/unit/openstack/tempest/test_tempest.py49
2 files changed, 40 insertions, 84 deletions
diff --git a/functest/tests/unit/openstack/tempest/test_conf_utils.py b/functest/tests/unit/openstack/tempest/test_conf_utils.py
index 8988e96a1..91108e10d 100644
--- a/functest/tests/unit/openstack/tempest/test_conf_utils.py
+++ b/functest/tests/unit/openstack/tempest/test_conf_utils.py
@@ -16,67 +16,34 @@ import mock
from functest.opnfv_tests.openstack.tempest import conf_utils
from functest.opnfv_tests.openstack.tempest import tempest
from functest.utils import config
-from snaps.openstack.os_credentials import OSCreds
class OSTempestConfUtilsTesting(unittest.TestCase):
# pylint: disable=too-many-public-methods
- def setUp(self):
- self.os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=None)
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=mock.Mock())
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_net_dic(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create private network'
self.assertTrue(msg in context.exception)
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=None)
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_image(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create image'
self.assertTrue(msg in context.exception, msg=str(context.exception))
- @mock.patch('snaps.openstack.utils.deploy_utils.create_project',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_user',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_network',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
- return_value=mock.Mock())
- @mock.patch('snaps.openstack.utils.keystone_utils.keystone_client')
- @mock.patch('snaps.openstack.utils.keystone_utils.get_project')
- @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
- return_value=None)
+ @mock.Mock('os_client_config.make_shade')
def test_create_res_missing_flavor(self, *mock_args):
# pylint: disable=unused-argument
- tempest_resources = tempest.TempestResourcesManager(
- os_creds=self.os_creds)
+ tempest_resources = tempest.TempestResourcesManager()
with self.assertRaises(Exception) as context:
tempest_resources.create()
msg = 'Failed to create flavor'
@@ -188,7 +155,7 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
self.assertTrue(mock_get_vid.called)
self.assertTrue(mock_get_did.called)
- def _test_missing_param(self, params, image_id, flavor_id):
+ def _test_missing_param(self, params, image_id, flavor_id, alt=False):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
'conf_utils.ConfigParser.RawConfigParser.'
'set') as mset, \
@@ -202,10 +169,16 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
mock.patch('functest.utils.functest_utils.yaml.safe_load',
return_value={'validation': {'ssh_timeout': 300}}):
os.environ['OS_ENDPOINT_TYPE'] = ''
- conf_utils.configure_tempest_update_params(
- 'test_conf_file', image_id=image_id,
- flavor_id=flavor_id)
- mset.assert_any_call(params[0], params[1], params[2])
+ if not alt:
+ conf_utils.configure_tempest_update_params(
+ 'test_conf_file', image_id=image_id,
+ flavor_id=flavor_id)
+ mset.assert_any_call(params[0], params[1], params[2])
+ else:
+ conf_utils.configure_tempest_update_params(
+ 'test_conf_file', image_alt_id=image_id,
+ flavor_alt_id=flavor_id)
+ mset.assert_any_call(params[0], params[1], params[2])
self.assertTrue(mread.called)
self.assertTrue(mwrite.called)
@@ -214,20 +187,18 @@ class OSTempestConfUtilsTesting(unittest.TestCase):
'test_image_id', None)
def test_upd_missing_image_id_alt(self):
- conf_utils.IMAGE_ID_ALT = 'test_image_id_alt'
- self._test_missing_param(('compute', 'image_ref_alt',
- 'test_image_id_alt'), None, None)
+ self._test_missing_param(
+ ('compute', 'image_ref_alt', 'test_image_id_alt'),
+ 'test_image_id_alt', None, alt=True)
def test_upd_missing_flavor_id(self):
- setattr(config.CONF, 'tempest_use_custom_flavors', 'True')
self._test_missing_param(('compute', 'flavor_ref', 'test_flavor_id'),
None, 'test_flavor_id')
def test_upd_missing_flavor_id_alt(self):
- setattr(config.CONF, 'tempest_use_custom_flavors', 'True')
- conf_utils.FLAVOR_ID_ALT = 'test_flavor_id_alt'
- self._test_missing_param(('compute', 'flavor_ref_alt',
- 'test_flavor_id_alt'), None, None)
+ self._test_missing_param(
+ ('compute', 'flavor_ref_alt', 'test_flavor_id_alt'),
+ None, 'test_flavor_id_alt', alt=True)
def test_verif_missing_conf_file(self):
with mock.patch('functest.opnfv_tests.openstack.tempest.'
diff --git a/functest/tests/unit/openstack/tempest/test_tempest.py b/functest/tests/unit/openstack/tempest/test_tempest.py
index fc8c9cc85..25737d123 100644
--- a/functest/tests/unit/openstack/tempest/test_tempest.py
+++ b/functest/tests/unit/openstack/tempest/test_tempest.py
@@ -12,7 +12,6 @@ import os
import unittest
import mock
-from snaps.openstack.os_credentials import OSCreds
from xtesting.core import testcase
from functest.opnfv_tests.openstack.tempest import tempest
@@ -23,25 +22,19 @@ class OSTempestTesting(unittest.TestCase):
# pylint: disable=too-many-public-methods
def setUp(self):
- os_creds = OSCreds(
- username='user', password='pass',
- auth_url='http://foo.com:5000/v3', project_name='bar')
-
with mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'conf_utils.get_verifier_id',
return_value='test_deploy_id'), \
- mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
- 'conf_utils.get_verifier_deployment_id',
- return_value='test_deploy_id'), \
- mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
- 'conf_utils.get_verifier_repo_dir',
- return_value='test_verifier_repo_dir'), \
- mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
- 'conf_utils.get_verifier_deployment_dir',
- return_value='test_verifier_deploy_dir'), \
- mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_credentials',
- return_value=os_creds):
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_deployment_id',
+ return_value='test_deploy_id'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_repo_dir',
+ return_value='test_verifier_repo_dir'), \
+ mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'conf_utils.get_verifier_deployment_dir',
+ return_value='test_verifier_deploy_dir'), \
+ mock.patch('os_client_config.make_shade'):
self.tempestcommon = tempest.TempestCommon()
self.tempestsmoke_serial = tempest.TempestSmokeSerial()
self.tempestsmoke_parallel = tempest.TempestSmokeParallel()
@@ -189,6 +182,8 @@ class OSTempestTesting(unittest.TestCase):
'os.path.exists', return_value=False)
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs',
side_effect=Exception)
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'TempestResourcesManager.cleanup')
def test_run_makedirs_ko(self, *args):
# pylint: disable=unused-argument
self.assertEqual(self.tempestcommon.run(),
@@ -199,6 +194,8 @@ class OSTempestTesting(unittest.TestCase):
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'TempestResourcesManager.create', side_effect=Exception)
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'TempestResourcesManager.cleanup')
def test_run_create_resources_ko(self, *args):
# pylint: disable=unused-argument
self.assertEqual(self.tempestcommon.run(),
@@ -209,20 +206,8 @@ class OSTempestTesting(unittest.TestCase):
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'TempestResourcesManager.create', return_value={})
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_active_compute_cnt', side_effect=Exception)
- def test_run_get_active_comp_cnt_ko(self, *args):
- # pylint: disable=unused-argument
- self.assertEqual(self.tempestcommon.run(),
- testcase.TestCase.EX_RUN_ERROR)
-
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
- 'os.path.exists', return_value=False)
- @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
- @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
- 'TempestResourcesManager.create', return_value={})
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_active_compute_cnt', return_value=2)
+ 'TempestResourcesManager.cleanup')
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'TempestCommon.configure', side_effect=Exception)
def test_run_configure_tempest_ko(self, *args):
@@ -235,8 +220,8 @@ class OSTempestTesting(unittest.TestCase):
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.os.makedirs')
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'TempestResourcesManager.create', return_value={})
- @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
- 'get_active_compute_cnt', return_value=2)
+ @mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
+ 'TempestResourcesManager.cleanup')
@mock.patch('functest.opnfv_tests.openstack.tempest.tempest.'
'TempestCommon.configure')
def _test_run(self, status, *args):