Browse Source

functional: Remove 'api' parameter

Pretty much every test case in 'nova.tests.functional' defines an 'api'
attribute, and many define an 'admin_api' attribute. We can pull these
from the class rather than explicitly passing them to helpers. Rework
things so this happens.

Note that the bulk of the changes here are in the
'nova/tests/functional/integrated_helpers.py' file. The rest of the
changes were auto-generated using the following script (my sed-fu is
non-existent):

  $ cd nova/tests/functional
  $ python3
  >>> import glob
  >>> import re
  >>> pattern = r'_state_change\((\n\s+)?self\.(admin_)?api,\s+'
  >>> replace = r'_state_change(\1'
  >>> for path in glob.glob('*.py') + glob.glob('*/*.py'):
  ...     with open(path) as fh:
  ...         data = fh.read()
  ...     new = re.sub(pattern, replace, data, flags=re.MULTILINE)
  ...     if new != data:
  ...         with open(path, 'w') as fh:
  ...             fh.write(new)
  ...
  >>> quit()

(ditto for the other substitutions)

Some manual fixups were required after, which pre-commit highlighted :)

Change-Id: I8c96b337f32148f8f5899c9b87af331b1fa41424
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
changes/94/697694/1
Stephen Finucane 2 years ago
parent
commit
7ae1a10913
  1. 2
      nova/tests/functional/api_sample_tests/test_instance_actions.py
  2. 4
      nova/tests/functional/api_sample_tests/test_multinic.py
  3. 13
      nova/tests/functional/compute/test_init_host.py
  4. 4
      nova/tests/functional/compute/test_live_migration.py
  5. 91
      nova/tests/functional/integrated_helpers.py
  6. 10
      nova/tests/functional/libvirt/test_shared_resource_provider.py
  7. 30
      nova/tests/functional/libvirt/test_vpmem.py
  8. 4
      nova/tests/functional/notification_sample_tests/notification_sample_base.py
  9. 89
      nova/tests/functional/notification_sample_tests/test_instance.py
  10. 2
      nova/tests/functional/regressions/test_bug_1404867.py
  11. 8
      nova/tests/functional/regressions/test_bug_1669054.py
  12. 8
      nova/tests/functional/regressions/test_bug_1679750.py
  13. 4
      nova/tests/functional/regressions/test_bug_1682693.py
  14. 4
      nova/tests/functional/regressions/test_bug_1689692.py
  15. 6
      nova/tests/functional/regressions/test_bug_1702454.py
  16. 7
      nova/tests/functional/regressions/test_bug_1713783.py
  17. 4
      nova/tests/functional/regressions/test_bug_1718455.py
  18. 10
      nova/tests/functional/regressions/test_bug_1718512.py
  19. 3
      nova/tests/functional/regressions/test_bug_1719730.py
  20. 2
      nova/tests/functional/regressions/test_bug_1732947.py
  21. 10
      nova/tests/functional/regressions/test_bug_1735407.py
  22. 6
      nova/tests/functional/regressions/test_bug_1741125.py
  23. 7
      nova/tests/functional/regressions/test_bug_1741307.py
  24. 2
      nova/tests/functional/regressions/test_bug_1746483.py
  25. 9
      nova/tests/functional/regressions/test_bug_1764556.py
  26. 4
      nova/tests/functional/regressions/test_bug_1764883.py
  27. 4
      nova/tests/functional/regressions/test_bug_1780373.py
  28. 10
      nova/tests/functional/regressions/test_bug_1781286.py
  29. 5
      nova/tests/functional/regressions/test_bug_1781710.py
  30. 2
      nova/tests/functional/regressions/test_bug_1784353.py
  31. 3
      nova/tests/functional/regressions/test_bug_1794996.py
  32. 11
      nova/tests/functional/regressions/test_bug_1797580.py
  33. 2
      nova/tests/functional/regressions/test_bug_1806064.py
  34. 2
      nova/tests/functional/regressions/test_bug_1806515.py
  35. 7
      nova/tests/functional/regressions/test_bug_1815153.py
  36. 4
      nova/tests/functional/regressions/test_bug_1823370.py
  37. 6
      nova/tests/functional/regressions/test_bug_1825020.py
  38. 2
      nova/tests/functional/regressions/test_bug_1825034.py
  39. 2
      nova/tests/functional/regressions/test_bug_1825537.py
  40. 7
      nova/tests/functional/regressions/test_bug_1830747.py
  41. 11
      nova/tests/functional/regressions/test_bug_1835822.py
  42. 4
      nova/tests/functional/regressions/test_bug_1837955.py
  43. 14
      nova/tests/functional/regressions/test_bug_1843090.py
  44. 8
      nova/tests/functional/regressions/test_bug_1845291.py
  45. 9
      nova/tests/functional/regressions/test_bug_1848343.py
  46. 8
      nova/tests/functional/regressions/test_bug_1849165.py
  47. 4
      nova/tests/functional/regressions/test_bug_1849409.py
  48. 27
      nova/tests/functional/test_aggregates.py
  49. 8
      nova/tests/functional/test_availability_zones.py
  50. 16
      nova/tests/functional/test_boot_from_volume.py
  51. 6
      nova/tests/functional/test_conf_max_attach_disk_devices.py
  52. 15
      nova/tests/functional/test_cross_az_attach.py
  53. 22
      nova/tests/functional/test_cross_cell_migrate.py
  54. 4
      nova/tests/functional/test_json_filter.py
  55. 4
      nova/tests/functional/test_multiattach.py
  56. 22
      nova/tests/functional/test_nova_manage.py
  57. 8
      nova/tests/functional/test_policy.py
  58. 6
      nova/tests/functional/test_scheduler.py
  59. 10
      nova/tests/functional/test_server_external_events.py
  60. 10
      nova/tests/functional/test_server_faults.py
  61. 36
      nova/tests/functional/test_server_group.py
  62. 286
      nova/tests/functional/test_servers.py
  63. 4
      nova/tests/functional/test_servers_provider_tree.py
  64. 4
      nova/tests/functional/wsgi/test_servers.py
  65. 12
      nova/tests/functional/wsgi/test_services.py

2
nova/tests/functional/api_sample_tests/test_instance_actions.py

@ -34,7 +34,7 @@ class ServerActionsSampleJsonTest(test_servers.ServersSampleBase,
response_data = api_samples_test_base.pretty_data(response.content)
actions = api_samples_test_base.objectify(response_data)
self.action_stop = actions['instanceActions'][0]
self._wait_for_state_change(self.api, {'id': self.uuid}, 'SHUTOFF')
self._wait_for_state_change({'id': self.uuid}, 'SHUTOFF')
def _get_subs(self):
return {

4
nova/tests/functional/api_sample_tests/test_multinic.py

@ -32,14 +32,14 @@ class MultinicSampleJsonTest(integrated_helpers.InstanceHelperMixin,
def _boot_a_server(self, expected_status='ACTIVE', extra_params=None):
server = self._build_minimal_create_server_request(
self.api, 'MultinicSampleJsonTestServer')
'MultinicSampleJsonTestServer')
if extra_params:
server.update(extra_params)
created_server = self.api.post_server({'server': server})
# Wait for it to finish being created
found_server = self._wait_for_state_change(self.api, created_server,
found_server = self._wait_for_state_change(created_server,
expected_status)
return found_server

13
nova/tests/functional/compute/test_init_host.py

@ -40,10 +40,10 @@ class ComputeManagerInitHostTestCase(
# Create a server, it does not matter on which host it lands.
name = 'test_migrate_disk_and_power_off_crash_finish_revert_migration'
server = self._build_minimal_create_server_request(
self.api, name, image_uuid=fake_image.get_valid_image_id(),
name, image_uuid=fake_image.get_valid_image_id(),
networks='auto')
server = self.api.post_server({'server': server})
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# Save the source hostname for assertions later.
source_host = server['OS-EXT-SRV-ATTR:host']
@ -66,8 +66,7 @@ class ComputeManagerInitHostTestCase(
self.admin_api.post_server_action(server['id'], {'migrate': None})
# Now wait for the task_state to be reset to None during
# _init_instance.
server = self._wait_for_server_parameter(
self.admin_api, server, {
server = self._wait_for_server_parameter(server, {
'status': 'ACTIVE',
'OS-EXT-STS:task_state': None,
'OS-EXT-SRV-ATTR:host': source_host
@ -158,7 +157,7 @@ class TestComputeRestartInstanceStuckInBuild(
# instance_claim() to stop it. This is less realistic but it works in
# the test env.
server_req = self._build_minimal_create_server_request(
self.api, 'interrupted-server', flavor_id=self.flavor1['id'],
'interrupted-server', flavor_id=self.flavor1['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
@ -170,7 +169,7 @@ class TestComputeRestartInstanceStuckInBuild(
mock_instance_claim.side_effect = sleep_forever
server = self.api.post_server({'server': server_req})
self._wait_for_state_change(self.admin_api, server, 'BUILD')
self._wait_for_state_change(server, 'BUILD')
# the instance.create.start is the closest thing to the
# instance_claim call we can wait for in the test
@ -182,7 +181,7 @@ class TestComputeRestartInstanceStuckInBuild(
# We expect that the instance is pushed to ERROR state during the
# compute restart.
self._wait_for_state_change(self.admin_api, server, 'ERROR')
self._wait_for_state_change(server, 'ERROR')
mock_log.assert_called_with(
'Instance spawn was interrupted before instance_claim, setting '
'instance to ERROR state',

4
nova/tests/functional/compute/test_live_migration.py

@ -69,7 +69,7 @@ class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase,
'uuid': uuids.working_volume,
'source_type': 'volume',
'destination_type': 'volume'}]}})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
source = server['OS-EXT-SRV-ATTR:host']
if source == self.compute.host:
@ -87,7 +87,7 @@ class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase,
self.stub_out('nova.volume.cinder.API.attachment_delete',
stub_attachment_delete)
self.api.post_server_action(server['id'], post)
self._wait_for_server_parameter(self.api, server,
self._wait_for_server_parameter(server,
{'OS-EXT-SRV-ATTR:host': dest,
'status': 'ACTIVE'})
self.assertEqual(2, stub_attachment_delete.call_count)

91
nova/tests/functional/integrated_helpers.py

@ -73,11 +73,14 @@ def generate_new_element(items, prefix, numeric=False):
class InstanceHelperMixin(object):
def _wait_for_server_parameter(self, admin_api, server, expected_params,
max_retries=10):
def _wait_for_server_parameter(
self, server, expected_params, max_retries=10, api=None):
api = api or getattr(self, 'admin_api', self.api)
retry_count = 0
while True:
server = admin_api.get_server(server['id'])
server = api.get_server(server['id'])
if all([server[attr] == expected_params[attr]
for attr in expected_params]):
break
@ -90,22 +93,21 @@ class InstanceHelperMixin(object):
return server
def _wait_for_state_change(self, admin_api, server, expected_status,
max_retries=10):
def _wait_for_state_change(self, server, expected_status, max_retries=10):
return self._wait_for_server_parameter(
admin_api, server, {'status': expected_status}, max_retries)
server, {'status': expected_status}, max_retries)
def _build_minimal_create_server_request(
self, name=None, image_uuid=None, flavor_id=None, networks=None,
az=None, host=None):
def _build_minimal_create_server_request(self, api, name=None,
image_uuid=None, flavor_id=None,
networks=None, az=None,
host=None):
server = {}
if not image_uuid:
# NOTE(takashin): In API version 2.36, image APIs were deprecated.
# In API version 2.36 or greater, self.api.get_images() returns
# a 404 error. In that case, 'image_uuid' should be specified.
image_uuid = api.get_images()[0]['id']
image_uuid = self.api.get_images()[0]['id']
server['imageRef'] = image_uuid
if not name:
@ -115,7 +117,7 @@ class InstanceHelperMixin(object):
if not flavor_id:
# Set a valid flavorId
flavor_id = api.get_flavors()[0]['id']
flavor_id = self.api.get_flavors()[0]['id']
server['flavorRef'] = 'http://fake.server/%s' % flavor_id
if networks is not None:
@ -142,40 +144,43 @@ class InstanceHelperMixin(object):
return
def _wait_for_action_fail_completion(
self, server, expected_action, event_name, api=None):
self, server, expected_action, event_name):
"""Polls instance action events for the given instance, action and
action event name until it finds the action event with an error
result.
"""
if api is None:
api = self.api
return self._wait_for_instance_action_event(
api, server, expected_action, event_name, event_result='error')
server, expected_action, event_name, event_result='error')
def _wait_for_instance_action_event(
self, api, server, action_name, event_name, event_result):
self, server, action_name, event_name, event_result):
"""Polls the instance action events for the given instance, action,
event, and event result until it finds the event.
"""
api = getattr(self, 'admin_api', self.api)
actions = []
events = []
for attempt in range(10):
actions = api.get_instance_actions(server['id'])
# The API returns the newest event first
for action in actions:
if action['action'] == action_name:
events = (
api.api_get(
'/servers/%s/os-instance-actions/%s' %
(server['id'], action['request_id'])
).body['instanceAction']['events'])
# Look for the action event being in error state.
for event in events:
result = event['result']
if (event['event'] == event_name and
result is not None and
result.lower() == event_result.lower()):
return event
if action['action'] != action_name:
continue
events = api.api_get(
'/servers/%s/os-instance-actions/%s' % (
server['id'], action['request_id'])
).body['instanceAction']['events']
# Look for the action event being in error state.
for event in events:
result = event['result']
if (event['event'] == event_name and
result is not None and
result.lower() == event_result.lower()):
return event
# We didn't find the completion event yet, so wait a bit.
time.sleep(0.5)
@ -192,9 +197,8 @@ class InstanceHelperMixin(object):
:param action: Either "resize" or "migrate" instance action.
:param error_in_tb: Some expected part of the error event traceback.
"""
api = self.admin_api if hasattr(self, 'admin_api') else self.api
event = self._wait_for_action_fail_completion(
server, action, 'conductor_migrate_server', api=api)
server, action, 'conductor_migrate_server')
self.assertIn(error_in_tb, event['traceback'])
def _wait_for_migration_status(self, server, expected_statuses):
@ -202,9 +206,7 @@ class InstanceHelperMixin(object):
for the given server, else the test fails. The migration record, if
found, is returned.
"""
api = getattr(self, 'admin_api', None)
if api is None:
api = self.api
api = getattr(self, 'admin_api', self.api)
statuses = [status.lower() for status in expected_statuses]
for attempt in range(10):
@ -296,10 +298,14 @@ class _IntegratedTestBase(test.TestCase):
self.api = self.api_fixture.admin_api
else:
self.api = self.api_fixture.api
self.admin_api = self.api_fixture.admin_api
if hasattr(self, 'microversion'):
self.api.microversion = self.microversion
if not self.ADMIN_API:
self.admin_api.microversion = self.microversion
def get_unused_server_name(self):
servers = self.api.get_servers()
server_names = [server['name'] for server in servers]
@ -725,14 +731,13 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
:return: the API representation of the booted instance
"""
server_req = self._build_minimal_create_server_request(
self.api, 'some-server', flavor_id=flavor['id'],
'some-server', flavor_id=flavor['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks=networks)
server_req['availability_zone'] = 'nova:%s' % source_hostname
LOG.info('booting on %s', source_hostname)
created_server = self.api.post_server({'server': server_req})
server = self._wait_for_state_change(
self.admin_api, created_server, 'ACTIVE')
server = self._wait_for_state_change(created_server, 'ACTIVE')
# Verify that our source host is what the server ended up on
self.assertEqual(source_hostname, server['OS-EXT-SRV-ATTR:host'])
@ -846,7 +851,7 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
def _move_and_check_allocations(self, server, request, old_flavor,
new_flavor, source_rp_uuid, dest_rp_uuid):
self.api.post_server_action(server['id'], request)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
def _check_allocation():
self.assertFlavorMatchesUsage(source_rp_uuid, old_flavor)
@ -908,7 +913,7 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
}
}
self.api.post_server_action(server['id'], resize_req)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self.assertFlavorMatchesUsage(rp_uuid, old_flavor, new_flavor)
@ -978,15 +983,15 @@ class ProviderUsageBaseTestCase(test.TestCase, InstanceHelperMixin):
def _confirm_resize(self, server):
self.api.post_server_action(server['id'], {'confirmResize': None})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_instance_action_event(
self.api, server, instance_actions.CONFIRM_RESIZE,
server, instance_actions.CONFIRM_RESIZE,
'compute_confirm_resize', 'success')
return server
def _revert_resize(self, server):
self.api.post_server_action(server['id'], {'revertResize': None})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_migration_status(server, ['reverted'])
# Note that the migration status is changed to "reverted" in the
# dest host revert_resize method but the allocations are cleaned up

10
nova/tests/functional/libvirt/test_shared_resource_provider.py

@ -77,7 +77,7 @@ class SharedStorageProviderUsageTestCase(
}
# create server
server = self.api.post_server(server_req_body)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# get shared_rp and cn_rp usages
shared_rp_usages = self._get_provider_usages(shared_RP['uuid'])
@ -135,7 +135,7 @@ class SharedStorageProviderUsageTestCase(
}
# create server
server = self.api.post_server(server_req_body)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
rebuild_image_ref = (
nova.tests.unit.image.fake.AUTO_DISK_CONFIG_ENABLED_IMAGE_UUID)
@ -152,7 +152,7 @@ class SharedStorageProviderUsageTestCase(
self.api.api_post('/servers/%s/action' % server['id'],
rebuild_req_body)
self._wait_for_server_parameter(
self.api, server, {'OS-EXT-STS:task_state': None})
server, {'OS-EXT-STS:task_state': None})
# get shared_rp and cn_rp usages
shared_rp_usages = self._get_provider_usages(shared_rp_uuid)
@ -198,7 +198,7 @@ class SharedStorageProviderUsageTestCase(
}
# create server
server = self.api.post_server(server_req_body)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
rebuild_image_ref = (
nova.tests.unit.image.fake.AUTO_DISK_CONFIG_ENABLED_IMAGE_UUID)
@ -216,7 +216,7 @@ class SharedStorageProviderUsageTestCase(
rebuild_req_body)
# Look for the failed rebuild action.
self._wait_for_action_fail_completion(
server, instance_actions.REBUILD, 'rebuild_server', self.admin_api)
server, instance_actions.REBUILD, 'rebuild_server')
# Assert the server image_ref was rolled back on failure.
server = self.api.get_server(server['id'])
self.assertEqual(org_image_id, server['image']['id'])

30
nova/tests/functional/libvirt/test_vpmem.py

@ -126,7 +126,7 @@ class VPMEMTestBase(integrated_helpers.LibvirtProviderUsageBaseTestCase):
def _create_server(self, flavor_id, hostname):
server_req = self._build_minimal_create_server_request(
self.api, 'some-server', flavor_id=flavor_id,
'some-server', flavor_id=flavor_id,
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
server_req['availability_zone'] = 'nova:%s' % hostname
@ -173,22 +173,22 @@ class VPMEMTests(VPMEMTestBase):
# Boot two servers with pmem
server1 = self._create_server(self.flavor, self.compute1.host)
self._wait_for_state_change(self.api, server1, 'ACTIVE')
self._wait_for_state_change(server1, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server1['id'], cn1_uuid)
server2 = self._create_server(self.flavor, self.compute1.host)
self._wait_for_state_change(self.api, server2, 'ACTIVE')
self._wait_for_state_change(server2, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server2['id'], cn1_uuid)
# 'SMALL' VPMEM resource has used up
server3 = self._create_server(self.flavor, self.compute1.host)
self._wait_for_state_change(self.api, server3, 'ERROR')
self._wait_for_state_change(server3, 'ERROR')
# Delete server2, one 'SMALL' VPMEM will be released
self._delete_server(server2)
server3 = self._create_server(self.flavor, self.compute1.host)
self._wait_for_state_change(self.api, server3, 'ACTIVE')
self._wait_for_state_change(server3, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server3['id'], cn1_uuid)
@ -237,29 +237,29 @@ class VPMEMResizeTests(VPMEMTestBase):
# Boot one server with pmem, then resize the server
server = self._create_server(self.flavor1, self.compute1.host)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
# Revert resize
self._resize_server(server, self.flavor2)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn2_uuid)
self._revert_resize(server)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
# Confirm resize
self._resize_server(server, self.flavor2)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn2_uuid)
self._confirm_resize(server)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn2_uuid)
@ -272,29 +272,29 @@ class VPMEMResizeTests(VPMEMTestBase):
# Boot one server with pmem, then resize the server
server = self._create_server(self.flavor1, self.compute1.host)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
# Revert resize
self._resize_server(server, self.flavor2)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
self._revert_resize(server)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
# Confirm resize
self._resize_server(server, self.flavor2)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)
self._confirm_resize(server)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._check_vpmem_allocations({'CUSTOM_PMEM_NAMESPACE_4GB': 1,
'CUSTOM_PMEM_NAMESPACE_SMALL': 1},
server['id'], cn1_uuid)

4
nova/tests/functional/notification_sample_tests/notification_sample_base.py

@ -220,7 +220,7 @@ class NotificationSampleTestBase(test.TestCase,
actual=fake_notifier.VERSIONED_NOTIFICATIONS.pop(0))
server = self._build_minimal_create_server_request(
self.api, 'some-server',
'some-server',
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
flavor_id=flavor_id)
@ -246,7 +246,7 @@ class NotificationSampleTestBase(test.TestCase,
self.assertTrue(created_server['id'])
# Wait for it to finish being created
found_server = self._wait_for_state_change(self.api, created_server,
found_server = self._wait_for_state_change(created_server,
expected_status)
found_server['reservation_id'] = reservation_id

89
nova/tests/functional/notification_sample_tests/test_instance.py

@ -59,7 +59,7 @@ class TestInstanceNotificationSampleWithMultipleCompute(
fake_notifier.reset()
action(server)
# Ensure that instance is in active state after an action
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
@mock.patch('nova.compute.manager.ComputeManager.'
'_live_migration_cleanup_flags', return_value=[True, False])
@ -188,13 +188,13 @@ class TestInstanceNotificationSampleWithMultipleCompute(
}
self.admin_api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'MIGRATING')
self._wait_for_state_change(server, 'MIGRATING')
migrations = self._wait_and_get_migrations(server)
self.admin_api.delete_migration(server['id'], migrations[0]['id'])
self._wait_for_notification('instance.live_migration_abort.start')
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# NOTE(gibi): the intance.live_migration_rollback notification emitted
# after the instance.live_migration_abort notification so we have to
# wait for the rollback to ensure we can assert both notifications
@ -261,10 +261,8 @@ class TestInstanceNotificationSampleWithMultipleCompute(
}
self.admin_api.post_server_action(server['id'], evacuate)
self._wait_for_state_change(self.api, server,
expected_status='REBUILD')
self._wait_for_state_change(self.api, server,
expected_status='ACTIVE')
self._wait_for_state_change(server, expected_status='REBUILD')
self._wait_for_state_change(server, expected_status='ACTIVE')
notifications = self._get_notifications('instance.evacuate')
self.assertEqual(1, len(notifications),
@ -286,7 +284,7 @@ class TestInstanceNotificationSampleWithMultipleCompute(
}
self.admin_api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'MIGRATING')
self._wait_for_state_change(server, 'MIGRATING')
migrations = self._wait_and_get_migrations(server)
migration_id = migrations[0]['id']
@ -390,7 +388,7 @@ class TestInstanceNotificationSample(
fake_notifier.reset()
action(server)
# Ensure that instance is in active state after an action
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# if the test step did not raised then we consider the step as
# succeeded. We drop the logs to avoid causing subunit parser
@ -520,10 +518,8 @@ class TestInstanceNotificationSample(
}
}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server,
expected_status='REBUILD')
self._wait_for_state_change(self.api, server,
expected_status='ACTIVE')
self._wait_for_state_change(server, expected_status='REBUILD')
self._wait_for_state_change(server, expected_status='ACTIVE')
notifications = self._get_notifications('instance.exists')
self._verify_notification(
@ -751,11 +747,9 @@ class TestInstanceNotificationSample(
def _test_power_off_on_server(self, server):
self.api.post_server_action(server['id'], {'os-stop': {}})
self._wait_for_state_change(self.api, server,
expected_status='SHUTOFF')
self._wait_for_state_change(server, expected_status='SHUTOFF')
self.api.post_server_action(server['id'], {'os-start': {}})
self._wait_for_state_change(self.api, server,
expected_status='ACTIVE')
self._wait_for_state_change(server, expected_status='ACTIVE')
self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -788,8 +782,7 @@ class TestInstanceNotificationSample(
def _test_shelve_and_shelve_offload_server(self, server):
self.flags(shelved_offload_time=-1)
self.api.post_server_action(server['id'], {'shelve': {}})
self._wait_for_state_change(self.api, server,
expected_status='SHELVED')
self._wait_for_state_change(server, expected_status='SHELVED')
self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -812,7 +805,7 @@ class TestInstanceNotificationSample(
# we can unshelve to make sure that the unshelve.start notification
# payload is stable as the compute manager first sets the instance
# state then a bit later sets the instance.host to None.
self._wait_for_server_parameter(self.api, server,
self._wait_for_server_parameter(server,
{'status': 'SHELVED_OFFLOADED',
'OS-EXT-SRV-ATTR:host': None})
@ -832,7 +825,7 @@ class TestInstanceNotificationSample(
actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
self.api.post_server_action(server['id'], {'unshelve': None})
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_notification('instance.unshelve.end')
def _test_unshelve_server(self, server):
@ -844,13 +837,13 @@ class TestInstanceNotificationSample(
# we can unshelve to make sure that the unshelve.start notification
# payload is stable as the compute manager first sets the instance
# state then a bit later sets the instance.host to None.
self._wait_for_server_parameter(self.api, server,
self._wait_for_server_parameter(server,
{'status': 'SHELVED_OFFLOADED',
'OS-EXT-SRV-ATTR:host': None})
post = {'unshelve': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_notification('instance.unshelve.end')
self.assertEqual(9, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -870,11 +863,11 @@ class TestInstanceNotificationSample(
def _test_suspend_resume_server(self, server):
post = {'suspend': {}}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.admin_api, server, 'SUSPENDED')
self._wait_for_state_change(server, 'SUSPENDED')
post = {'resume': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# Four versioned notification are generated.
# 0. instance-suspend-start
@ -913,10 +906,10 @@ class TestInstanceNotificationSample(
def _test_pause_unpause_server(self, server):
self.api.post_server_action(server['id'], {'pause': {}})
self._wait_for_state_change(self.api, server, 'PAUSED')
self._wait_for_state_change(server, 'PAUSED')
self.api.post_server_action(server['id'], {'unpause': {}})
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# Four versioned notifications are generated
# 0. instance-pause-start
@ -997,7 +990,7 @@ class TestInstanceNotificationSample(
}
}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
self._pop_and_verify_dest_select_notification(server['id'],
replacements={
@ -1034,7 +1027,7 @@ class TestInstanceNotificationSample(
# the following is the revert server request
post = {'revertResize': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1170,7 +1163,7 @@ class TestInstanceNotificationSample(
self.addCleanup(patcher.stop)
patcher.start()
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, expected_status='ERROR')
self._wait_for_state_change(server, expected_status='ERROR')
self._wait_for_notification('compute.exception')
# There should be the following notifications after scheduler's
# select_destination notifications:
@ -1248,10 +1241,8 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], post)
# Before going back to ACTIVE state
# server state need to be changed to REBUILD state
self._wait_for_state_change(self.api, server,
expected_status='REBUILD')
self._wait_for_state_change(self.api, server,
expected_status='ACTIVE')
self._wait_for_state_change(server, expected_status='REBUILD')
self._wait_for_state_change(server, expected_status='ACTIVE')
self._pop_and_verify_dest_select_notification(server['id'],
replacements={
@ -1345,10 +1336,8 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], post)
# Before going back to ACTIVE state
# server state need to be changed to REBUILD state
self._wait_for_state_change(self.api, server,
expected_status='REBUILD')
self._wait_for_state_change(self.api, server,
expected_status='ACTIVE')
self._wait_for_state_change(server, expected_status='REBUILD')
self._wait_for_state_change(server, expected_status='ACTIVE')
self._pop_and_verify_dest_select_notification(server['id'],
replacements={
@ -1434,7 +1423,7 @@ class TestInstanceNotificationSample(
}
self.api.post_server_action(server['id'], post)
mock_rebuild.side_effect = _virtual_interface_create_failed
self._wait_for_state_change(self.api, server, expected_status='ERROR')
self._wait_for_state_change(server, expected_status='ERROR')
notification = self._get_notifications('instance.rebuild.error')
self.assertEqual(1, len(notification),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1455,11 +1444,11 @@ class TestInstanceNotificationSample(
def _test_restore_server(self, server):
self.flags(reclaim_instance_interval=30)
self.api.delete_server(server['id'])
self._wait_for_state_change(self.api, server, 'SOFT_DELETED')
self._wait_for_state_change(server, 'SOFT_DELETED')
# we don't want to test soft_delete here
fake_notifier.reset()
self.api.post_server_action(server['id'], {'restore': {}})
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1641,12 +1630,12 @@ class TestInstanceNotificationSample(
self.flags(allow_resize_to_same_host=True)
post = {'resize': {'flavorRef': '2'}}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
self._wait_for_state_change(server, 'VERIFY_RESIZE')
fake_notifier.reset()
post = {'confirmResize': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1733,7 +1722,7 @@ class TestInstanceNotificationSample(
}
}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.admin_api, server, 'RESCUE')
self._wait_for_state_change(server, 'RESCUE')
# 0. instance.rescue.start
# 1. instance.exists
@ -1759,7 +1748,7 @@ class TestInstanceNotificationSample(
'unrescue': None
}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1779,7 +1768,7 @@ class TestInstanceNotificationSample(
def _test_soft_delete_server(self, server):
self.flags(reclaim_instance_interval=30)
self.api.delete_server(server['id'])
self._wait_for_state_change(self.api, server, 'SOFT_DELETED')
self._wait_for_state_change(server, 'SOFT_DELETED')
self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
fake_notifier.VERSIONED_NOTIFICATIONS)
@ -1948,9 +1937,9 @@ class TestInstanceNotificationSample(
def _test_lock_unlock_instance(self, server):
self.api.post_server_action(server['id'], {'lock': {}})
self._wait_for_server_parameter(self.api, server, {'locked': True})
self._wait_for_server_parameter(server, {'locked': True})
self.api.post_server_action(server['id'], {'unlock': {}})
self._wait_for_server_parameter(self.api, server, {'locked': False})
self._wait_for_server_parameter(server, {'locked': False})
# Two versioned notifications are generated
# 0. instance-lock
# 1. instance-unlock
@ -1973,9 +1962,9 @@ class TestInstanceNotificationSample(
def _test_lock_unlock_instance_with_reason(self, server):
self.api.post_server_action(
server['id'], {'lock': {"locked_reason": "global warming"}})
self._wait_for_server_parameter(self.api, server, {'locked': True})
self._wait_for_server_parameter(server, {'locked': True})
self.api.post_server_action(server['id'], {'unlock': {}})
self._wait_for_server_parameter(self.api, server, {'locked': False})
self._wait_for_server_parameter(server, {'locked': False})
# Two versioned notifications are generated
# 0. instance-lock
# 1. instance-unlock

2
nova/tests/functional/regressions/test_bug_1404867.py

@ -55,7 +55,7 @@ class DeleteWithReservedVolumes(integrated_helpers._IntegratedTestBase,
]
}
})
return self._wait_for_state_change(self.api, server, 'ERROR')
return self._wait_for_state_change(server, 'ERROR')
def test_delete_with_reserved_volumes_new(self):
self.cinder = self.useFixture(

8
nova/tests/functional/regressions/test_bug_1669054.py

@ -42,7 +42,7 @@ class ResizeEvacuateTestCase(integrated_helpers._IntegratedTestBase,
flavor1 = flavors[0]['id']
server = self._build_server(flavor1)
server = self.api.post_server({'server': server})
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# Start up another compute service so we can resize.
host2 = self.start_service('compute', host='host2')
@ -51,10 +51,10 @@ class ResizeEvacuateTestCase(integrated_helpers._IntegratedTestBase,
flavor2 = flavors[1]['id']
req = {'resize': {'flavorRef': flavor2}}
self.api.post_server_action(server['id'], req)
server = self._wait_for_state_change(self.api, server, 'VERIFY_RESIZE')
server = self._wait_for_state_change(server, 'VERIFY_RESIZE')
self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
self.api.post_server_action(server['id'], {'confirmResize': None})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# Disable the host on which the server is now running (host2).
host2.stop()
@ -62,7 +62,7 @@ class ResizeEvacuateTestCase(integrated_helpers._IntegratedTestBase,
# Now try to evacuate the server back to the original source compute.
req = {'evacuate': {'onSharedStorage': False}}
self.api.post_server_action(server['id'], req)
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# The evacuate flow in the compute manager is annoying in that it
# sets the instance status to ACTIVE before updating the host, so we
# have to wait for the migration record to be 'done' to avoid a race.

8
nova/tests/functional/regressions/test_bug_1679750.py

@ -81,10 +81,10 @@ class TestLocalDeleteAllocations(test.TestCase,
self.assertEqual(0, usage)
# Create a server.
server = self._build_minimal_create_server_request(self.api,
server = self._build_minimal_create_server_request(
'local-delete-test', self.image_id, self.flavor_id, 'none')
server = self.admin_api.post_server({'server': server})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# Assert usages are non zero now.
usages_during = self._get_usages(placement_api, rp_uuid)
@ -136,10 +136,10 @@ class TestLocalDeleteAllocations(test.TestCase,
self.assertEqual(0, usage)
# Create a server.
server = self._build_minimal_create_server_request(self.api,
server = self._build_minimal_create_server_request(
'local-delete-test', self.image_id, self.flavor_id, 'none')
server = self.admin_api.post_server({'server': server})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# Assert usages are non zero now.
usages_during = self._get_usages(placement_api, rp_uuid)

4
nova/tests/functional/regressions/test_bug_1682693.py

@ -59,10 +59,10 @@ class ServerTagsFilteringTest(test.TestCase,
for x in range(2):
server = self.api.post_server(
dict(server=self._build_minimal_create_server_request(
self.api, 'test-list-server-tag-filters%i' % x, image_id,
'test-list-server-tag-filters%i' % x, image_id,
networks='none')))
self.addCleanup(self.api.delete_server, server['id'])
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
self.servers.append(server)
# now apply two tags to the first server

4
nova/tests/functional/regressions/test_bug_1689692.py

@ -66,10 +66,10 @@ class ServerListLimitMarkerCell0Test(test.TestCase,
for x in range(3):
server = self.api.post_server(
dict(server=self._build_minimal_create_server_request(
self.api, 'test-list-server-limit%i' % x, self.image_id,
'test-list-server-limit%i' % x, self.image_id,
networks='none')))
self.addCleanup(self.api.delete_server, server['id'])
self._wait_for_state_change(self.api, server, 'ERROR')
self._wait_for_state_change(server, 'ERROR')
servers = self.api.get_servers()
self.assertEqual(3, len(servers))

6
nova/tests/functional/regressions/test_bug_1702454.py

@ -95,11 +95,11 @@ class SchedulerOnlyChecksTargetTest(test.TestCase,
# We first create the instance
server = self.admin_api.post_server(
dict(server=self._build_minimal_create_server_request(
self.api, 'my-pretty-instance-to-evacuate', self.image_id,
'my-pretty-instance-to-evacuate', self.image_id,
networks='none')))
server_id = server['id']
self.addCleanup(self.api.delete_server, server_id)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# We need to get instance details for knowing its host
server = self.admin_api.get_server(server_id)
@ -125,7 +125,7 @@ class SchedulerOnlyChecksTargetTest(test.TestCase,
}
self.admin_api.post_server_action(server['id'], evacuate)
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
server = self.admin_api.get_server(server_id)
# Yeepee, that works!

7
nova/tests/functional/regressions/test_bug_1713783.py

@ -84,13 +84,12 @@ class FailedEvacuateStateTests(test.TestCase,
def _boot_a_server(self):
server_req = self._build_minimal_create_server_request(
self.api, 'some-server', flavor_id=self.flavor1['id'],
'some-server', flavor_id=self.flavor1['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
LOG.info('booting on %s', self.hostname)
created_server = self.api.post_server({'server': server_req})
return self._wait_for_state_change(
self.api, created_server, 'ACTIVE')
return self._wait_for_state_change(created_server, 'ACTIVE')
def test_evacuate_no_valid_host(self):
# Boot a server
@ -110,7 +109,7 @@ class FailedEvacuateStateTests(test.TestCase,
self._wait_for_notification_event_type('compute_task.rebuild_server')
server = self._wait_for_state_change(self.api, server, 'ERROR')
server = self._wait_for_state_change(server, 'ERROR')
self.assertEqual(self.hostname, server['OS-EXT-SRV-ATTR:host'])
# Check migrations

4
nova/tests/functional/regressions/test_bug_1718455.py

@ -70,7 +70,7 @@ class TestLiveMigrateOneOfConcurrentlyCreatedInstances(
def _boot_servers(self, num_servers=1):
server_req = self._build_minimal_create_server_request(
self.api, 'some-server', flavor_id=self.flavor1['id'],
'some-server', flavor_id=self.flavor1['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
server_req.update({'min_count': str(num_servers),
@ -81,7 +81,7 @@ class TestLiveMigrateOneOfConcurrentlyCreatedInstances(
servers = self.api.get_servers(detail=True,
search_opts={'reservation_id': reservation_id})
for idx, server in enumerate(servers):
servers[idx] = self._wait_for_state_change(self.api, server,
servers[idx] = self._wait_for_state_change(server,
'ACTIVE')
return servers

10
nova/tests/functional/regressions/test_bug_1718512.py

@ -103,9 +103,9 @@ class TestRequestSpecRetryReschedule(test.TestCase,
# create the instance which should go to host1
server = self.admin_api.post_server(
dict(server=self._build_minimal_create_server_request(
self.api, 'test_resize_with_reschedule_then_live_migrate',
'test_resize_with_reschedule_then_live_migrate',
self.image_id, flavor_id=flavor1['id'], networks='none')))
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual('host1', server['OS-EXT-SRV-ATTR:host'])
# Stub out the resize to fail on host2, which will trigger a reschedule
@ -116,17 +116,17 @@ class TestRequestSpecRetryReschedule(test.TestCase,
# on host3.
data = {'resize': {'flavorRef': flavor2['id']}}
self.api.post_server_action(server['id'], data)
server = self._wait_for_state_change(self.admin_api, server,
server = self._wait_for_state_change(server,
'VERIFY_RESIZE')
self.assertEqual('host3', server['OS-EXT-SRV-ATTR:host'])
self.api.post_server_action(server['id'], {'confirmResize': None})
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# Now live migrate the server to host2 specifically, which previously
# failed the resize attempt but here it should pass.
data = {'os-migrateLive': {'host': 'host2', 'block_migration': 'auto'}}
self.admin_api.post_server_action(server['id'], data)
server = self._wait_for_state_change(self.admin_api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
self.assertEqual('host2', server['OS-EXT-SRV-ATTR:host'])
# NOTE(mriedem): The instance status effectively goes to ACTIVE before
# the migration status is changed to "completed" since

3
nova/tests/functional/regressions/test_bug_1719730.py

@ -104,8 +104,7 @@ class TestRescheduleWithServerGroup(test.TestCase,
hints = {'group': created_group['id']}
created_server = self.api.post_server({'server': server,
'os:scheduler_hints': hints})
found_server = self._wait_for_state_change(self.admin_api,
created_server, 'ACTIVE')
found_server = self._wait_for_state_change(created_server, 'ACTIVE')
# Assert that the host is not the failed host.
self.assertNotEqual(self.failed_host,
found_server['OS-EXT-SRV-ATTR:host'])

2
nova/tests/functional/regressions/test_bug_1732947.py

@ -64,7 +64,7 @@ class RebuildVolumeBackedSameImage(integrated_helpers._IntegratedTestBase,
}
}
server = self.api.post_server(server_req_body)
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# For a volume-backed server, the image ref will be an empty string
# in the server response.
self.assertEqual('', server['image'])

10
nova/tests/functional/regressions/test_bug_1735407.py

@ -99,13 +99,11 @@ class TestParallelEvacuationWithServerGroup(
hints = {'group': group['id']}
created_server1 = self.api.post_server({'server': server,
'os:scheduler_hints': hints})
server1 = self._wait_for_state_change(self.api,
created_server1, 'ACTIVE')
server1 = self._wait_for_state_change(created_server1, 'ACTIVE')
created_server2 = self.api.post_server({'server': server,
'os:scheduler_hints': hints})
server2 = self._wait_for_state_change(self.api,
created_server2, 'ACTIVE')
server2 = self._wait_for_state_change(created_server2, 'ACTIVE')
# assert that the anti-affinity policy is enforced during the boot
self.assertNotEqual(server1['OS-EXT-SRV-ATTR:host'],
@ -134,9 +132,9 @@ class TestParallelEvacuationWithServerGroup(
fake_notifier.wait_for_versioned_notifications(
'instance.rebuild.start', n_events=1)
server1 = self._wait_for_server_parameter(
self.api, server1, {'OS-EXT-STS:task_state': None})
server1, {'OS-EXT-STS:task_state': None})
server2 = self._wait_for_server_parameter(
self.api, server2, {'OS-EXT-STS:task_state': None})
server2, {'OS-EXT-STS:task_state': None})
# NOTE(gibi): The instance.host set _after_ the instance state and
# tast_state is set back to normal so it is not enough to wait for

6
nova/tests/functional/regressions/test_bug_1741125.py

@ -48,13 +48,13 @@ class TestServerResizeReschedule(integrated_helpers.ProviderUsageBaseTestCase):
supplied host_list, and does not call the scheduler.
"""
server_req = self._build_minimal_create_server_request(
self.api, 'some-server', flavor_id=self.flavor1['id'],
'some-server', flavor_id=self.flavor1['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
self.first_attempt = True
created_server = self.api.post_server({'server': server_req})
server = self._wait_for_state_change(self.api, created_server,
server = self._wait_for_state_change(created_server,
'ACTIVE')
actual_prep_resize = compute_manager.ComputeManager._prep_resize
@ -74,7 +74,7 @@ class TestServerResizeReschedule(integrated_helpers.ProviderUsageBaseTestCase):
data = {"resize": {"flavorRef": self.flavor2['id']}}
self.api.post_server_action(server_uuid, data)
server = self._wait_for_state_change(self.api, created_server,
server = self._wait_for_state_change(created_server,
'VERIFY_RESIZE')
self.assertEqual(self.flavor2['name'],
server['flavor']['original_name'])

7
nova/tests/functional/regressions/test_bug_1741307.py

@ -77,11 +77,11 @@ class TestResizeWithNoAllocationScheduler(
def test_resize(self):
# Create our server without networking just to keep things simple.
server_req = self._build_minimal_create_server_request(
self.api, 'test-resize', flavor_id=self.old_flavor['id'],
'test-resize', flavor_id=self.old_flavor['id'],
image_uuid='155d900f-4e14-4e4c-a73d-069cbf4541e6',
networks='none')
server = self.api.post_server({'server': server_req})
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
original_host = server['OS-EXT-SRV-ATTR:host']
target_host = 'host1' if original_host == 'host2' else 'host2'
@ -95,8 +95,7 @@ class TestResizeWithNoAllocationScheduler(
self.api.post_server_action(server['id'], post)
# Poll the server until the resize is done.
server = self._wait_for_state_change(
self.api, server, 'VERIFY_RESIZE')
server = self._wait_for_state_change(server, 'VERIFY_RESIZE')
# Assert that the server was migrated to the other host.
self.assertEqual(target_host, server['OS-EXT-SRV-ATTR:host'])
# Confirm the resize.

2
nova/tests/functional/regressions/test_bug_1746483.py

@ -90,7 +90,7 @@ class TestBootFromVolumeIsolatedHostsFilter(
# networks='none'.
with utils.temporary_mutation(self.api, microversion='2.37'):
server = self.api.post_server(server_req_body)
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
# NOTE(mriedem): The instance is successfully scheduled but since
# the image_id from the volume_image_metadata isn't stored in the
# RequestSpec.image.id, and restrict_isolated_hosts_to_isolated_images

9
nova/tests/functional/regressions/test_bug_1764556.py

@ -62,13 +62,12 @@ class InstanceListWithDeletedServicesTestCase(
def _migrate_server(self, server, target_host):
self.admin_api.api_post('/servers/%s/action' % server['id'],
{'migrate': None})
server = self._wait_for_state_change(
self.admin_api, server, 'VERIFY_RESIZE')
server = self._wait_for_state_change(server, 'VERIFY_RESIZE')
self.assertEqual(target_host, server['OS-EXT-SRV-ATTR:host'])
self.admin_api.api_post('/servers/%s/action' % server['id'],
{'confirmResize': None},
check_response_status=[204])
server = self._wait_for_state_change(self.api, server, 'ACTIVE')
server = self._wait_for_state_change(server, 'ACTIVE')
return server
def test_instance_list_deleted_service_with_no_uuid(self):
@ -87,10 +86,10 @@ class InstanceListWithDeletedServicesTestCase(
# Create an instance which will be on host1 since it's the only host.
server_req = self._build_minimal_create_server_request(
self.api, 'test_instance_list_deleted_service_with_no_uuid',
'test_instance_list_deleted_service_with_no_uuid',
image_uuid=self.image_id, networks='none')
server = self.api.post_server({'server': server_req})
self._wait_for_state_change(self.api, server, 'ACTIVE')
self._wait_for_state_change(server, 'ACTIVE')
# Now we start a 2nd compute which is "upgraded" (has a uuid) and
# we'll migrate the instance to that host.