Browse Source

Restart scheduler in TestNovaManagePlacementHealAllocations

TestNovaManagePlacementHealAllocations tests rely on the
CachingScheduler specifically because it does not use
placement and therefore does not create allocations during
scheduling, which gives us instances that need to heal
allocations.

However, we have a race in the test setup where the scheduler
is started before the compute services. The CachingScheduler
runs a periodic task on startup to fetch the hosts from the
DB to initialize it's cache, and then uses that during scheduling
until the periodic runs again. So what we can hit is the
scheduler starts, loads an empty cache, then we start the computes
and try to create an instance but because of the empty cache we
fail with a NoValidHost error.

This restarts and resets the CachingScheduler cache *after* we have
started the computes and asserted they are available in the API.

Change-Id: I32f607a436e9851a96877123ae3d1fe51f444f73
Closes-Bug: #1781648
tags/19.0.0.0rc1
Matt Riedemann 1 year ago
parent
commit
4fe4fbe7a4
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      nova/tests/functional/test_nova_manage.py

+ 8
- 0
nova/tests/functional/test_nova_manage.py View File

@@ -387,6 +387,14 @@ class TestNovaManagePlacementHealAllocations(
387 387
         self.flavor = self.api.get_flavors()[0]
388 388
         self.output = StringIO()
389 389
         self.useFixture(fixtures.MonkeyPatch('sys.stdout', self.output))
390
+        # On startup, the CachingScheduler runs a periodic task to pull the
391
+        # initial set of compute nodes out of the database which it then puts
392
+        # into a cache (hence the name of the driver). This can race with
393
+        # actually starting the compute services so we need to restart the
394
+        # scheduler to refresh the cache.
395
+        self.scheduler_service.stop()
396
+        self.scheduler_service.manager.driver.all_host_states = None
397
+        self.scheduler_service.start()
390 398
 
391 399
     def _boot_and_assert_no_allocations(self, flavor, hostname):
392 400
         """Creates a server on the given host and asserts neither have usage

Loading…
Cancel
Save