Reproduce bug 1721652 in the functional test env
When bug 1709902 was fixed in I0df401a7c91f012fdb25cb0e6b344ca51de8c309 the fix assumed that when the _destroy_evacuated_instances() is called during the init of the nova-compute service the resource tracker already knows the compute node ids associated to the given compute host. This is not true and therefore _destroy_evacuated_instances fails with an exception and does not clean up the evacuated instance. The solution for the original bug included a functional regression test. However the functional test env is not capable of fully simulate a nova-compute service restart. The service only stopped then started again. This allows some in memory state of the compute service to survive the simulated restart. This caused that the functional test was not able to catch that the above described assumption is not correct. Related-Bug: #1721652 Related-Bug: #1709902 Change-Id: Icaf1bae8cb040b939f916a19ce026031ddb84af7
This commit is contained in:
@@ -1613,6 +1613,20 @@ class ServerMovingTests(ProviderUsageBaseTestCase):
|
||||
self._delete_and_check_allocations(
|
||||
server, source_rp_uuid, dest_rp_uuid)
|
||||
|
||||
def _restart_compute_service(self, compute):
|
||||
# NOTE(gibi): The service interface cannot be used to simulate a real
|
||||
# service restart as the manager object will not be recreated after a
|
||||
# service.stop() and service.start() therefore the manager state will
|
||||
# survive. For example the resource tracker will not be recreated after
|
||||
# a stop start. The service.kill() call cannot help as it deletes
|
||||
# the service from the DB which is unrealistic and causes that some
|
||||
# operation that refers to the killed host (e.g. evacuate) fails.
|
||||
# So this helper method tries to simulate a better compute service
|
||||
# restart by cleaning up some of the internal state of the compute
|
||||
# manager.
|
||||
compute.manager._resource_tracker = None
|
||||
compute.start()
|
||||
|
||||
def test_evacuate(self):
|
||||
source_hostname = self.compute1.host
|
||||
dest_hostname = self.compute2.host
|
||||
@@ -1656,23 +1670,44 @@ class ServerMovingTests(ProviderUsageBaseTestCase):
|
||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
||||
|
||||
# start up the source compute
|
||||
self.compute1.start()
|
||||
# NOTE(gibi): This is bug 1721652. The restart should go through
|
||||
# without exception.
|
||||
self.assertRaises(KeyError, self._restart_compute_service,
|
||||
self.compute1)
|
||||
|
||||
self.admin_api.put_service(
|
||||
source_compute_id, {'forced_down': 'false'})
|
||||
|
||||
# NOTE(gibi): This is bug 1721652. After the source host is started up
|
||||
# the allocation should be cleaned.
|
||||
source_usages = self._get_provider_usages(source_rp_uuid)
|
||||
self.assertEqual({'VCPU': 0,
|
||||
'MEMORY_MB': 0,
|
||||
'DISK_GB': 0},
|
||||
source_usages)
|
||||
self.assertFlavorMatchesAllocation(self.flavor1, source_usages)
|
||||
|
||||
dest_usages = self._get_provider_usages(dest_rp_uuid)
|
||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
||||
|
||||
allocations = self._get_allocations_by_server_uuid(server['id'])
|
||||
self.assertEqual(1, len(allocations))
|
||||
self.assertEqual(2, len(allocations))
|
||||
dest_allocation = allocations[dest_rp_uuid]['resources']
|
||||
self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
||||
source_allocation = allocations[source_rp_uuid]['resources']
|
||||
self.assertFlavorMatchesAllocation(self.flavor1, source_allocation)
|
||||
|
||||
# NOTE(gibi): Once the bug 1721652 is fixed this should be the expected
|
||||
# behavior
|
||||
# source_usages = self._get_provider_usages(source_rp_uuid)
|
||||
# self.assertEqual({'VCPU': 0,
|
||||
# 'MEMORY_MB': 0,
|
||||
# 'DISK_GB': 0},
|
||||
# source_usages)
|
||||
#
|
||||
# dest_usages = self._get_provider_usages(dest_rp_uuid)
|
||||
# self.assertFlavorMatchesAllocation(self.flavor1, dest_usages)
|
||||
#
|
||||
# allocations = self._get_allocations_by_server_uuid(server['id'])
|
||||
# self.assertEqual(1, len(allocations))
|
||||
# dest_allocation = allocations[dest_rp_uuid]['resources']
|
||||
# self.assertFlavorMatchesAllocation(self.flavor1, dest_allocation)
|
||||
|
||||
self._delete_and_check_allocations(
|
||||
server, source_rp_uuid, dest_rp_uuid)
|
||||
|
||||
Reference in New Issue
Block a user