Browse Source

Merge "functional: Rework '_delete_server'"

changes/42/631242/39
Zuul 2 weeks ago
parent
commit
80a4929bca
11 changed files with 65 additions and 64 deletions
  1. +5
    -5
      nova/tests/functional/db/test_archive.py
  2. +4
    -4
      nova/tests/functional/libvirt/test_numa_servers.py
  3. +1
    -1
      nova/tests/functional/libvirt/test_pci_sriov_servers.py
  4. +1
    -1
      nova/tests/functional/libvirt/test_rt_servers.py
  5. +4
    -4
      nova/tests/functional/regressions/test_bug_1670627.py
  6. +4
    -4
      nova/tests/functional/regressions/test_bug_1675570.py
  7. +2
    -2
      nova/tests/functional/regressions/test_bug_1678326.py
  8. +1
    -1
      nova/tests/functional/test_images.py
  9. +2
    -2
      nova/tests/functional/test_instance_actions.py
  10. +40
    -39
      nova/tests/functional/test_servers.py
  11. +1
    -1
      nova/tests/functional/wsgi/test_interfaces.py

+ 5
- 5
nova/tests/functional/db/test_archive.py View File

@@ -83,7 +83,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
actions = self.api.get_instance_actions(server_id)
self.assertTrue(len(actions),
'No instance actions for server: %s' % server_id)
self._delete_server(server_id)
self._delete_server(server)
# Verify we have the soft deleted instance in the database.
admin_context = context.get_admin_context(read_deleted='yes')
# This will raise InstanceNotFound if it's not found.
@@ -118,7 +118,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
actions = self.api.get_instance_actions(server_id)
self.assertTrue(len(actions),
'No instance actions for server: %s' % server_id)
self._delete_server(server_id)
self._delete_server(server)
# Verify we have the soft deleted instance in the database.
admin_context = context.get_admin_context(read_deleted='yes')
# This will raise InstanceNotFound if it's not found.
@@ -168,7 +168,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
def test_archive_then_purge_all(self):
server = self._create_server()
server_id = server['id']
self._delete_server(server_id)
self._delete_server(server)
results, deleted_ids, archived = db.archive_deleted_rows(max_rows=1000)
self.assertEqual([server_id], deleted_ids)

@@ -194,7 +194,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
def test_archive_then_purge_by_date(self):
server = self._create_server()
server_id = server['id']
self._delete_server(server_id)
self._delete_server(server)
results, deleted_ids, archived = db.archive_deleted_rows(max_rows=1000)
self.assertEqual([server_id], deleted_ids)
self.assertEqual(sum(results.values()), archived)
@@ -229,7 +229,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
"""
server = self._create_server()
server_id = server['id']
self._delete_server(server_id)
self._delete_server(server)
results, deleted_ids, archived = db.archive_deleted_rows(max_rows=1000)
self.assertEqual([server_id], deleted_ids)
date = dateutil_parser.parse('oct 21 2015', fuzzy=True)

+ 4
- 4
nova/tests/functional/libvirt/test_numa_servers.py View File

@@ -113,7 +113,7 @@ class NUMAServersTest(NUMAServersTestBase):

self.assertEqual(end_status, found_server['status'])

self.addCleanup(self._delete_server, created_server_id)
self.addCleanup(self._delete_server, found_server)
return created_server

def test_create_server_with_numa_topology(self):
@@ -743,9 +743,9 @@ class ReshapeForPCPUsTest(NUMAServersTestBase):
{'DISK_GB': 20, 'MEMORY_MB': 2048, 'PCPU': 2},
allocations[compute_rp_uuid]['resources'])

self._delete_server(server1['id'])
self._delete_server(server2['id'])
self._delete_server(server3['id'])
self._delete_server(server1)
self._delete_server(server2)
self._delete_server(server3)


class NUMAServersWithNetworksTest(NUMAServersTestBase):

+ 1
- 1
nova/tests/functional/libvirt/test_pci_sriov_servers.py View File

@@ -80,7 +80,7 @@ class _PCIServersTestBase(base.ServersTestBase):
found_server = self._wait_for_state_change(found_server, 'BUILD')

self.assertEqual(end_status, found_server['status'])
self.addCleanup(self._delete_server, created_server_id)
self.addCleanup(self._delete_server, found_server)
return created_server



+ 1
- 1
nova/tests/functional/libvirt/test_rt_servers.py View File

@@ -67,4 +67,4 @@ class RealTimeServersTest(base.ServersTestBase):
instance = self._wait_for_state_change(instance, 'BUILD')

self.assertEqual('ACTIVE', instance['status'])
self._delete_server(instance['id'])
self._delete_server(instance)

+ 4
- 4
nova/tests/functional/regressions/test_bug_1670627.py View File

@@ -98,9 +98,9 @@ class TestDeleteFromCell0CheckQuota(test.TestCase):
(server_id, server['OS-EXT-STS:vm_state'],
server['OS-EXT-STS:task_state']))

def _delete_server(self, server_id):
def _delete_server(self, server):
try:
self.api.delete_server(server_id)
self.api.delete_server(server['id'])
except client.OpenStackApiNotFoundException:
pass

@@ -123,7 +123,7 @@ class TestDeleteFromCell0CheckQuota(test.TestCase):
imageRef=self.image_id,
flavorRef=self.flavor_id)
server = self.api.post_server({'server': server})
self.addCleanup(self._delete_server, server['id'])
self.addCleanup(self._delete_server, server)
self._wait_for_instance_status(server['id'], 'ERROR')

# Check quota to see we've incremented usage by 1.
@@ -132,7 +132,7 @@ class TestDeleteFromCell0CheckQuota(test.TestCase):
current_usage['absolute']['totalInstancesUsed'])

# Now delete the server and wait for it to be gone.
self._delete_server(server['id'])
self._delete_server(server)
self._wait_for_instance_delete(server['id'])

# Now check the quota again. Since the bug is fixed, ending usage

+ 4
- 4
nova/tests/functional/regressions/test_bug_1675570.py View File

@@ -100,9 +100,9 @@ class TestLocalDeleteAttachedVolumes(test.TestCase):
(server_id, server['OS-EXT-STS:vm_state'],
server['OS-EXT-STS:task_state']))

def _delete_server(self, server_id):
def _delete_server(self, server):
try:
self.api.delete_server(server_id)
self.api.delete_server(server['id'])
except client.OpenStackApiNotFoundException:
pass

@@ -135,7 +135,7 @@ class TestLocalDeleteAttachedVolumes(test.TestCase):
networks='none')
server = self.api.post_server({'server': server})
server_id = server['id']
self.addCleanup(self._delete_server, server_id)
self.addCleanup(self._delete_server, server)
self._wait_for_instance_status(server_id, 'ACTIVE')

LOG.info('Shelve-offloading server %s', server_id)
@@ -160,7 +160,7 @@ class TestLocalDeleteAttachedVolumes(test.TestCase):
# At this point the instance.host is no longer set, so deleting
# the server will take the local delete path in the API.
LOG.info('Deleting shelved-offloaded server %s.', server_id)
self._delete_server(server_id)
self._delete_server(server)
# Now wait for the server to be gone.
self._wait_for_instance_delete(server_id)


+ 2
- 2
nova/tests/functional/regressions/test_bug_1678326.py View File

@@ -53,7 +53,7 @@ class TestDeleteFromCell0CheckQuotaRollback(
imageRef=self.image_id,
flavorRef=self.flavor_id)
server = self.api.post_server({'server': server})
self.addCleanup(self._delete_server, server['id'])
self.addCleanup(self._delete_server, server)
self._wait_for_instance_status(server['id'], 'ERROR')

# Check quota to see we've incremented usage by 1.
@@ -71,7 +71,7 @@ class TestDeleteFromCell0CheckQuotaRollback(
fake_instance_destroy)

# Now delete the server and wait for it to be gone.
self._delete_server(server['id'])
self._delete_server(server)

# Reset the stub so we can actually delete the instance on tearDown.
self.stub_out('nova.objects.instance.Instance.destroy',

+ 1
- 1
nova/tests/functional/test_images.py View File

@@ -60,7 +60,7 @@ class ImagesTest(test_servers.ServersTestBase):
self.assertFalse(found_image)

# Cleanup
self._delete_server(server_id)
self._delete_server(found_server)

def test_admin_snapshot_user_image_access_member(self):
"""Tests a scenario where a user in project A creates a server and

+ 2
- 2
nova/tests/functional/test_instance_actions.py View File

@@ -50,7 +50,7 @@ class InstanceActionsTestV2(test_servers.ServersTestBase):

def test_get_instance_actions_deleted(self):
server = self._create_server()
self._delete_server(server['id'])
self._delete_server(server)
self.assertRaises(client.OpenStackApiNotFoundException,
self.api.get_instance_actions,
server['id'])
@@ -69,7 +69,7 @@ class InstanceActionsTestV221(InstanceActionsTestV21):

def test_get_instance_actions_deleted(self):
server = self._create_server()
self._delete_server(server['id'])
self._delete_server(server)
actions = self.api.get_instance_actions(server['id'])
self.assertEqual('delete', actions[0]['action'])
self.assertEqual('create', actions[1]['action'])

+ 40
- 39
nova/tests/functional/test_servers.py View File

@@ -102,10 +102,10 @@ class ServersTestBase(integrated_helpers._IntegratedTestBase):
# Should be gone
self.assertFalse(found_server)

def _delete_server(self, server_id):
def _delete_server(self, server):
# Delete the server
self.api.delete_server(server_id)
self._wait_for_deletion(server_id)
self.api.delete_server(server['id'])
self._wait_for_deletion(server['id'])

def _get_access_ips_params(self):
return {self._access_ipv4_parameter: "172.19.0.2",
@@ -168,7 +168,7 @@ class ServersTest(ServersTestBase):
found_server = self._wait_for_state_change(found_server, 'BUILD')

self.assertEqual('ERROR', found_server['status'])
self._delete_server(created_server_id)
self._delete_server(created_server)

# We should have no (persisted) build failures until we update
# resources, after which we should have one
@@ -222,7 +222,7 @@ class ServersTest(ServersTestBase):
found_server = self._wait_for_state_change(found_server, 'BUILD')

self.assertEqual('ERROR', found_server['status'])
self._delete_server(created_server_id)
self._delete_server(created_server)

return len(fails)

@@ -306,7 +306,7 @@ class ServersTest(ServersTestBase):
self.assertIn("image", server)
self.assertIn("flavor", server)

self._delete_server(created_server_id)
self._delete_server(found_server)

def _force_reclaim(self):
# Make sure that compute manager thinks the instance is
@@ -502,7 +502,7 @@ class ServersTest(ServersTestBase):
self.assertFalse(found_server.get('metadata'))

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_server_metadata_actions_negative_invalid_state(self):
# Create server with metadata
@@ -543,7 +543,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('SHELVED', found_server['status'])

# Cleanup
self._delete_server(server_id)
self._delete_server(found_server)

def test_create_and_rebuild_server(self):
# Rebuild a server with metadata.
@@ -608,7 +608,7 @@ class ServersTest(ServersTestBase):
self._verify_access_ips(found_server)

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_rename_server(self):
# Test building and renaming a server.
@@ -628,7 +628,7 @@ class ServersTest(ServersTestBase):
self.assertEqual(created_server['name'], 'new-name')

# Cleanup
self._delete_server(server_id)
self._delete_server(created_server)

def test_create_multiple_servers(self):
# Creates multiple servers and checks for reservation_id.
@@ -664,9 +664,9 @@ class ServersTest(ServersTestBase):
self.assertEqual(len(server_map), 2)

# Cleanup
self._delete_server(created_server_id)
for server_id in server_map:
self._delete_server(server_id)
self._delete_server(created_server)
for server in server_map.values():
self._delete_server(server)

def test_create_server_with_injected_files(self):
# Creates a server with injected_files.
@@ -705,7 +705,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('ACTIVE', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_stop_start_servers_negative_invalid_state(self):
# Create server
@@ -747,7 +747,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('SHUTOFF', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_revert_resized_server_negative_invalid_state(self):
# Create server
@@ -770,7 +770,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('ACTIVE', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_resize_server_negative_invalid_state(self):
# Avoid migration
@@ -802,7 +802,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('VERIFY_RESIZE', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_confirm_resized_server_negative_invalid_state(self):
# Create server
@@ -825,7 +825,7 @@ class ServersTest(ServersTestBase):
self.assertEqual('ACTIVE', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

def test_resize_server_overquota(self):
self.flags(cores=1, group='quota')
@@ -911,10 +911,9 @@ class ServersTestV219(ServersTestBase):
def _create_server_and_verify(self, set_desc = True, expected_desc = None):
# Creates a server with a description and verifies it is
# in the GET responses.
created_server_id = self._create_server(set_desc,
expected_desc)[1]['id']
self._verify_server_description(created_server_id, expected_desc)
self._delete_server(created_server_id)
created_server = self._create_server(set_desc, expected_desc)[1]
self._verify_server_description(created_server['id'], expected_desc)
self._delete_server(created_server)

def _update_server_and_verify(self, server_id, set_desc = True,
expected_desc = None):
@@ -990,7 +989,8 @@ class ServersTestV219(ServersTestBase):
def test_update_server_with_description(self):
self.api.microversion = '2.19'
# Create a server with an initial description
server_id = self._create_server(True, 'test desc 1')[1]['id']
server = self._create_server(True, 'test desc 1')[1]
server_id = server['id']

# Update and get the server with a description
self._update_server_and_verify(server_id, True, 'updated desc')
@@ -1004,7 +1004,7 @@ class ServersTestV219(ServersTestBase):
self._update_server_and_verify(server_id, True, 'updated desc2')

# Cleanup
self._delete_server(server_id)
self._delete_server(server)

def test_rebuild_server_with_description(self):
self.api.microversion = '2.19'
@@ -1026,12 +1026,13 @@ class ServersTestV219(ServersTestBase):
self._rebuild_server_and_verify(server_id, True, 'updated desc2')

# Cleanup
self._delete_server(server_id)
self._delete_server(server)

def test_version_compatibility(self):
# Create a server with microversion v2.19 and a description.
self.api.microversion = '2.19'
server_id = self._create_server(True, 'test desc 1')[1]['id']
server = self._create_server(True, 'test desc 1')[1]
server_id = server['id']
# Verify that the description is not included on V2.18 GETs
self.api.microversion = '2.18'
self._verify_server_description(server_id, desc_in_resp = False)
@@ -1043,17 +1044,17 @@ class ServersTestV219(ServersTestBase):
self._rebuild_assertRaisesRegex(server_id, 'test rebuild 2.18')

# Cleanup
self._delete_server(server_id)
self._delete_server(server)

# Create a server on V2.18 and verify that the description
# defaults to the name on a V2.19 GET
server_req, response = self._create_server(False)
server_id = response['id']
server_req, server = self._create_server(False)
server_id = server['id']
self.api.microversion = '2.19'
self._verify_server_description(server_id, server_req['name'])

# Cleanup
self._delete_server(server_id)
self._delete_server(server)

# Verify that creating a server with description on V2.18
# results in a 400 error
@@ -1152,7 +1153,7 @@ class ServerTestV220(ServersTestBase):
(server_id, attachment_id))
self.assertTrue(mock_clean_vols.called)

self._delete_server(server_id)
self._delete_server(found_server)


class ServerTestV269(ServersTestBase):
@@ -6490,7 +6491,7 @@ class ServerMoveWithPortResourceRequestTest(
return self._wait_for_state_change(self.admin_api, server, 'ACTIVE')

def _delete_server_and_check_allocations(
self, qos_port, qos_sriov_port, server):
self, server, qos_port, qos_sriov_port):
self._delete_and_check_allocations(server)

# assert that unbind removes the allocation from the binding of the
@@ -6555,7 +6556,7 @@ class ServerMoveWithPortResourceRequestTest(
self.assertEqual({}, migration_allocations)

self._delete_server_and_check_allocations(
qos_normal_port, qos_sriov_port, server)
server, qos_normal_port, qos_sriov_port)

def test_migrate_server_with_qos_port_old_dest_compute_alternate(self):
"""Create a situation where the first migration target host returned
@@ -6623,7 +6624,7 @@ class ServerMoveWithPortResourceRequestTest(
self.assertEqual({}, migration_allocations)

self._delete_server_and_check_allocations(
qos_normal_port, qos_sriov_port, server)
server, qos_normal_port, qos_sriov_port)

def _test_resize_or_migrate_server_with_qos_ports(self, new_flavor=None):
non_qos_normal_port = self.neutron.port_1
@@ -6667,7 +6668,7 @@ class ServerMoveWithPortResourceRequestTest(
self.assertEqual({}, migration_allocations)

self._delete_server_and_check_allocations(
qos_normal_port, qos_sriov_port, server)
server, qos_normal_port, qos_sriov_port)

def test_migrate_server_with_qos_ports(self):
self._test_resize_or_migrate_server_with_qos_ports()
@@ -6724,7 +6725,7 @@ class ServerMoveWithPortResourceRequestTest(
self.assertEqual({}, migration_allocations)

self._delete_server_and_check_allocations(
qos_port, qos_sriov_port, server)
server, qos_port, qos_sriov_port)

def test_migrate_revert_with_qos_ports(self):
self._test_resize_or_migrate_revert_with_qos_ports()
@@ -6802,7 +6803,7 @@ class ServerMoveWithPortResourceRequestTest(
self.assertEqual({}, migration_allocations)

self._delete_server_and_check_allocations(
qos_port, qos_sriov_port, server)
server, qos_port, qos_sriov_port)

def test_migrate_server_with_qos_port_reschedule_success(self):
self._test_resize_or_migrate_server_with_qos_port_reschedule_success()
@@ -7159,7 +7160,7 @@ class ServerMoveWithPortResourceRequestTest(
non_qos_normal_port, qos_normal_port, qos_sriov_port)

self._delete_server_and_check_allocations(
qos_normal_port, qos_sriov_port, server)
server, qos_normal_port, qos_sriov_port)

def test_evacuate_with_target_host_with_qos_port(self):
self.test_evacuate_with_qos_port(host='host2')
@@ -7215,7 +7216,7 @@ class ServerMoveWithPortResourceRequestTest(
qos_normal_port, qos_sriov_port, self.flavor_with_group_policy)

self._delete_server_and_check_allocations(
qos_normal_port, qos_sriov_port, server)
server, qos_normal_port, qos_sriov_port)

def test_evacuate_with_qos_port_pci_update_fail(self):
# Update the name of the network device RP of PF2 on host2 to something

+ 1
- 1
nova/tests/functional/wsgi/test_interfaces.py View File

@@ -144,4 +144,4 @@ class InterfaceFullstackWithNeutron(test_servers.ServersTestBase):
self.assertEqual('SUSPENDED', found_server['status'])

# Cleanup
self._delete_server(created_server_id)
self._delete_server(found_server)

Loading…
Cancel
Save