From 431237d2ee01de357bb31f36fdf7b786015d2209 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 14 Nov 2019 11:21:54 +0000 Subject: functional: Make '_wait_for_state_change' behave consistently Both 'ServersTestBase' and 'InstanceHelperMixin' provide implementations of '_wait_for_state_change' but they behave differently. The former waits for an instance to transition *from* the provided state, while the latter, somewhat more sanely, waits for the transition *to* the provided state. Switch to using the latter everywhere and make the necessary changes. Due to class hierarchies, we end up with two nearly identical implementations but these will be merged in a future change. Change-Id: I80cdc0a33ec27b1389130c22f9c3a8ff69f6b1a0 Signed-off-by: Stephen Finucane --- nova/tests/functional/test_images.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'nova/tests/functional/test_images.py') diff --git a/nova/tests/functional/test_images.py b/nova/tests/functional/test_images.py index 7c3ec85748..0edb3f29cb 100644 --- a/nova/tests/functional/test_images.py +++ b/nova/tests/functional/test_images.py @@ -24,14 +24,13 @@ class ImagesTest(test_servers.ServersTestBase): server = self._build_minimal_create_server_request() created_server = self.api.post_server({"server": server}) server_id = created_server['id'] - found_server = self._wait_for_state_change(created_server, 'BUILD') - self.assertEqual('ACTIVE', found_server['status']) + found_server = self._wait_for_state_change(created_server, 'ACTIVE') # Create image name = 'Snapshot 1' self.api.post_server_action( server_id, {'createImage': {'name': name}}) - self.assertEqual('ACTIVE', found_server['status']) + # Confirm that the image was created images = self.api.get_images(detail=False) image_map = {image['name']: image for image in images} @@ -41,8 +40,7 @@ class ImagesTest(test_servers.ServersTestBase): # Change server status from ACTIVE to SHELVED for negative test self.flags(shelved_offload_time = -1) self.api.post_server_action(server_id, {'shelve': {}}) - found_server = self._wait_for_state_change(found_server, 'ACTIVE') - self.assertEqual('SHELVED', found_server['status']) + found_server = self._wait_for_state_change(found_server, 'SHELVED') # Create image in SHELVED (not ACTIVE, etc.) name = 'Snapshot 2' @@ -51,7 +49,6 @@ class ImagesTest(test_servers.ServersTestBase): server_id, {'createImage': {'name': name}}) self.assertEqual(409, ex.response.status_code) - self.assertEqual('SHELVED', found_server['status']) # Confirm that the image was not created images = self.api.get_images(detail=False) @@ -71,8 +68,7 @@ class ImagesTest(test_servers.ServersTestBase): # Create a server using the tenant user project. server = self._build_minimal_create_server_request() server = self.api.post_server({"server": server}) - server = self._wait_for_state_change(server, 'BUILD') - self.assertEqual('ACTIVE', server['status']) + server = self._wait_for_state_change(server, 'ACTIVE') # Create an admin API fixture with a unique project ID. admin_api = self.useFixture( -- cgit v1.2.1