diff options
author | Juha Kosonen <juha.kosonen@nokia.com> | 2017-09-20 10:15:07 +0300 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2017-09-20 22:00:09 +0200 |
commit | e6b3c6fe942672461d448d13bd614b3b6e598e62 (patch) | |
tree | 188d54257ce60168341d77c688af6c9c152eef92 /functest/tests | |
parent | e171c13059358d32d9263076aeceb211942af3cd (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>
(cherry picked from commit 3b98874f010329198b8c3a13a4711c17a593b9cc)
Diffstat (limited to 'functest/tests')
-rw-r--r-- | functest/tests/unit/openstack/rally/test_rally.py | 46 |
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 63c0192ba..191722dc0 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): |