diff options
author | Matteo Sposato <msposato.developer@gmail.com> | 2020-12-08 15:03:23 +0100 |
---|---|---|
committer | Matteo Sposato <msposato.developer@gmail.com> | 2020-12-15 16:46:16 +0100 |
commit | b2781b98dd13b5fac9201a640c77231be7f21f7c (patch) | |
tree | 2d7366c82b1c7c13cacc5039e12504c58bfb90ac /nova/tests/functional/test_servers.py | |
parent | 032bbc396072f2221526e1e88e5194294f595eca (diff) | |
download | nova-b2781b98dd13b5fac9201a640c77231be7f21f7c.tar.gz |
Functional tests removed direct post call
- notification_sample_tests.test_instance
- test_servers
Removed direct post api call
Added _evacuate_server helper
Change-Id: Icfea1321a6550f2b776a3177dbc4a880f2a5b268
Diffstat (limited to 'nova/tests/functional/test_servers.py')
-rw-r--r-- | nova/tests/functional/test_servers.py | 82 |
1 files changed, 33 insertions, 49 deletions
diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py index 8568a8876b..34235e2165 100644 --- a/nova/tests/functional/test_servers.py +++ b/nova/tests/functional/test_servers.py @@ -2201,17 +2201,14 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): # evacuate the server and force the destination host which bypasses # the scheduler + post = { - 'evacuate': { - 'host': dest_hostname, - 'force': True - } + 'host': dest_hostname, + 'force': True } - self.api.post_server_action(server['id'], post) - expected_params = {'OS-EXT-SRV-ATTR:host': dest_hostname, - 'status': 'ACTIVE'} - server = self._wait_for_server_parameter(server, - expected_params) + + server = self._evacuate_server( + server, extra_post_args=post, expected_host=dest_hostname) # Run the periodics to show those don't modify allocations. self._run_periodics() @@ -2308,15 +2305,11 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): # evacuate the server specify the target but do not force the # destination host to use the scheduler to validate the target host post = { - 'evacuate': { - 'host': dest_hostname, - } + 'host': dest_hostname } - self.api.post_server_action(server['id'], post) - expected_params = {'OS-EXT-SRV-ATTR:host': dest_hostname, - 'status': 'ACTIVE'} - server = self._wait_for_server_parameter(server, - expected_params) + + server = self._evacuate_server( + server, extra_post_args=post, expected_host=dest_hostname) # Run the periodics to show those don't modify allocations. self._run_periodics() @@ -3055,14 +3048,9 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase): self.admin_api.put_service( source_compute_id, {'forced_down': 'true'}) - post = { - 'evacuate': {} - } - self.api.post_server_action(created_server['id'], post) - expected_params = {'OS-EXT-SRV-ATTR:host': dest_hostname, - 'status': 'ACTIVE'} - new_server = self._wait_for_server_parameter(created_server, - expected_params) + new_server = self._evacuate_server( + created_server, expected_host=dest_hostname) + inst_dest_host = new_server["OS-EXT-SRV-ATTR:host"] self.assertEqual(dest_hostname, inst_dest_host) @@ -5067,16 +5055,17 @@ class ConsumerGenerationConflictTest( with mock.patch('keystoneauth1.adapter.Adapter.put', autospec=True) as mock_put: mock_put.return_value = rsp + post = { - 'evacuate': { - 'force': force - } + 'force': force, } + if force: - post['evacuate']['host'] = dest_hostname + post['host'] = dest_hostname - self.api.post_server_action(server['id'], post) - server = self._wait_for_state_change(server, 'ERROR') + server = self._evacuate_server( + server, expected_state='ERROR', extra_post_args=post, + expected_migration_status='error') self.assertEqual(1, mock_put.call_count) @@ -5289,17 +5278,14 @@ class ServerMovingTestsWithNestedResourceRequests( # evacuate the server and force the destination host which bypasses # the scheduler post = { - 'evacuate': { - 'host': dest_hostname, - 'force': True - } + 'host': dest_hostname, + 'force': True } - self.api.post_server_action(server['id'], post) - self._wait_for_migration_status(server, ['error']) - expected_params = {'OS-EXT-SRV-ATTR:host': source_hostname, - 'status': 'ACTIVE'} - server = self._wait_for_server_parameter(server, - expected_params) + + server = self._evacuate_server( + server, extra_post_args=post, expected_migration_status='error', + expected_host=source_hostname) + self.assertIn('Unable to move instance %s to host host2. The instance ' 'has complex allocations on the source host so move ' 'cannot be forced.' % @@ -5498,20 +5484,18 @@ class ServerMovingTestsFromFlatToNested( # try to force evacuate from flat to nested. post = { - 'evacuate': { - 'host': 'host2', - 'force': True, - } + 'host': 'host2', + 'force': True, } - self.api.post_server_action(server['id'], post) + self._evacuate_server( + server, extra_post_args=post, expected_host='host1', + expected_migration_status='error') + # We expect that the evacuation will fail as force evacuate tries to # blindly copy the source allocation to the destination but on the # destination there is no inventory of CUSTOM_MAGIC on the compute node # provider as that resource is reported on a child provider. - self._wait_for_server_parameter(server, - {'OS-EXT-SRV-ATTR:host': 'host1', - 'status': 'ACTIVE'}) migration = self._wait_for_migration_status(server, ['error']) self.assertEqual('host1', migration['source_compute']) |