aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit
diff options
context:
space:
mode:
authorJuha Kosonen <juha.kosonen@nokia.com>2017-09-20 10:15:07 +0300
committerJuha Kosonen <juha.kosonen@nokia.com>2017-09-20 13:01:45 +0300
commit3b98874f010329198b8c3a13a4711c17a593b9cc (patch)
tree1470d2997149f6965a2de407a883aec608953cbf /functest/tests/unit
parent6c9b7cee6284ca187565989120b2b9829a30a9a4 (diff)
Dedicated flavors for rally tests
Create flavors and use them in rally scenarios instead of expecting certain flavors to pre-exist. Change-Id: I77c94ab80fcabd7b80ffb36f9856a48121858009 Signed-off-by: Juha Kosonen <juha.kosonen@nokia.com>
Diffstat (limited to 'functest/tests/unit')
-rw-r--r--functest/tests/unit/openstack/rally/test_rally.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py
index 63c0192b..191722dc 100644
--- a/functest/tests/unit/openstack/rally/test_rally.py
+++ b/functest/tests/unit/openstack/rally/test_rally.py
@@ -328,6 +328,52 @@ class OSRallyTesting(unittest.TestCase):
mock_get_net.assert_called()
mock_create_router.assert_called()
+ @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+ 'get_ext_net_name', return_value='test_net_name')
+ @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
+ 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_router',
+ return_value=mock.Mock())
+ @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
+ return_value=None)
+ def test_prepare_env_flavor_creation_failed(
+ self, mock_create_flavor, mock_create_router, mock_create_net,
+ mock_get_img, mock_get_net):
+ self.rally_base.TESTS = ['test1', 'test2']
+ self.rally_base.test_name = 'test1'
+ with self.assertRaises(Exception):
+ self.rally_base._prepare_env()
+ mock_create_net.assert_called()
+ mock_get_img.assert_called()
+ mock_get_net.assert_called()
+ mock_create_router.assert_called()
+ mock_create_flavor.assert_called_once()
+
+ @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+ 'get_ext_net_name', return_value='test_net_name')
+ @mock.patch('snaps.openstack.utils.deploy_utils.create_image',
+ 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_router',
+ return_value=mock.Mock())
+ @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
+ side_effect=[mock.Mock, None])
+ def test_prepare_env_flavor_alt_creation_failed(
+ self, mock_create_flavor, mock_create_router, mock_create_net,
+ mock_get_img, mock_get_net):
+ self.rally_base.TESTS = ['test1', 'test2']
+ self.rally_base.test_name = 'test1'
+ with self.assertRaises(Exception):
+ self.rally_base._prepare_env()
+ mock_create_net.assert_called()
+ mock_get_img.assert_called()
+ mock_get_net.assert_called()
+ mock_create_router.assert_called()
+ self.assertEqual(mock_create_flavor.call_count, 2)
+
@mock.patch('functest.opnfv_tests.openstack.rally.rally.RallyBase.'
'_run_task', return_value=mock.Mock())
def test_run_tests_all(self, mock_run_task):