diff options
author | Shobhi Jain <shobhi.jain@intel.com> | 2018-03-22 16:45:13 +0000 |
---|---|---|
committer | Shobhi Jain <shobhi.jain@intel.com> | 2018-04-23 10:25:50 +0100 |
commit | 069d7a13d1f8b6b465ae164e2a440c25270f7e8e (patch) | |
tree | 6024beb9620be71dc29c335543faf65296c270b1 /yardstick/tests/unit/common/test_openstack_utils.py | |
parent | 14615e286e67ca74a8c0ae55ffe043170e5ecbb6 (diff) |
Replace nova create instance with shade client.
Remove redundant functions:
*get_instances
*get_instance_status
*get_instance_by_name
Function create_instance_and_wait_for_active now uses shade client.
JIRA: YARDSTICK-1088
Change-Id: I766da333dabbb1b83a7b4ede4bf73567ec70eb8c
Signed-off-by: Shobhi Jain <shobhi.jain@intel.com>
Diffstat (limited to 'yardstick/tests/unit/common/test_openstack_utils.py')
-rw-r--r-- | yardstick/tests/unit/common/test_openstack_utils.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/yardstick/tests/unit/common/test_openstack_utils.py b/yardstick/tests/unit/common/test_openstack_utils.py index f03f2516c..a7c5aa5a8 100644 --- a/yardstick/tests/unit/common/test_openstack_utils.py +++ b/yardstick/tests/unit/common/test_openstack_utils.py @@ -337,3 +337,32 @@ class SecurityGroupTestCase(unittest.TestCase): mock_create_security_group_rule.assert_called() self.mock_shade_client.delete_security_group(self.sg_name) self.assertEqual(self._uuid, output) + +# ********************************************* +# NOVA +# ********************************************* + + +class CreateInstanceTestCase(unittest.TestCase): + + def test_create_instance_and_wait_for_active(self): + self.mock_shade_client = mock.Mock() + name = 'server_name' + image = 'image_name' + flavor = 'flavor_name' + self.mock_shade_client.create_server.return_value = ( + {'name': name, 'image': image, 'flavor': flavor}) + output = openstack_utils.create_instance_and_wait_for_active( + self.mock_shade_client, name, image, flavor) + self.assertEqual( + {'name': name, 'image': image, 'flavor': flavor}, output) + + @mock.patch.object(openstack_utils, 'log') + def test_create_instance_and_wait_for_active_fail(self, mock_logger): + self.mock_shade_client = mock.Mock() + self.mock_shade_client.create_server.side_effect = ( + exc.OpenStackCloudException('error message')) + output = openstack_utils.create_instance_and_wait_for_active( + self.mock_shade_client, 'server_name', 'image_name', 'flavor_name') + mock_logger.error.assert_called_once() + self.assertIsNone(output) |