Browse Source

Use SpawnIsSynchronousFixture in reschedule functional tests

We see that in successful tests that are usually running some
kind of negative or reschedule scenario that they will dump
a stacktrace to the subunit output buffer because
_allocate_network_async will raise an error. Too many of these
can eventually blow up the subunit output buffer and cause
tests to fail.

To guard against this, we use the SpawnIsSynchronousFixture in
the base class of two known test classes [1][2] that show a
stacktace with _allocate_network_async in successful runs. As a
result, one of the tests has to be fixed due to improper stubbing.

[1] UnsupportedPortResourceRequestBasedSchedulingTest
[2] PortResourceRequestReSchedulingTest

Change-Id: Ib18ecaebbeccc9c9cea32ca8949175fcea0414ac
Related-Bug: #1813147
tags/20.0.0.0rc1
Matt Riedemann 2 months ago
parent
commit
bb2b7cad29
1 changed files with 13 additions and 7 deletions
  1. +13
    -7
      nova/tests/functional/test_servers.py

+ 13
- 7
nova/tests/functional/test_servers.py View File

@@ -36,6 +36,7 @@ from nova.compute import instance_actions
from nova.compute import manager as compute_manager
from nova import context
from nova import exception
from nova.network.neutronv2 import api as neutronapi
from nova.network.neutronv2 import constants
from nova import objects
from nova.objects import block_device as block_device_obj
@@ -5506,6 +5507,9 @@ class PortResourceRequestBasedSchedulingTestBase(
FakeDriverWithPciResourcesConfigFixture())

super(PortResourceRequestBasedSchedulingTestBase, self).setUp()
# Make ComputeManager._allocate_network_async synchronous to detect
# errors in tests that involve rescheduling.
self.useFixture(nova_fixtures.SpawnIsSynchronousFixture())
self.compute1 = self._start_compute('host1')
self.compute1_rp_uuid = self._get_provider_uuid_by_host('host1')
self.ovs_bridge_rp_per_host = {}
@@ -6800,15 +6804,17 @@ class PortResourceRequestReSchedulingTest(
# First call is during boot, we want that to succeed normally. Then the
# fake virt driver triggers a re-schedule. During that re-schedule the
# fill is called again, and we simulate that call raises.
fill = nova.scheduler.utils.fill_provider_mapping
original_fill = nova.scheduler.utils.fill_provider_mapping

def stub_fill_provider_mapping(*args, **kwargs):
if not mock_fill.called:
return original_fill(*args, **kwargs)
raise exception.ResourceProviderTraitRetrievalFailed(
uuid=uuids.rp1)

with mock.patch(
'nova.scheduler.utils.fill_provider_mapping',
side_effect=[
fill,
exception.ResourceProviderTraitRetrievalFailed(
uuid=uuids.rp1)],
autospec=True):
side_effect=stub_fill_provider_mapping) as mock_fill:
server = self._create_server(
flavor=self.flavor,
networks=[{'port': port['id']}])
@@ -6823,5 +6829,5 @@ class PortResourceRequestReSchedulingTest(

# assert that unbind removes the allocation from the binding
updated_port = self.neutron.show_port(port['id'])['port']
binding_profile = updated_port['binding:profile']
binding_profile = neutronapi.get_binding_profile(updated_port)
self.assertNotIn('allocation', binding_profile)

Loading…
Cancel
Save