Add a waiter when checking pci allocation

Intermittently the SR-IOV Live Migration Macvtap test would fail due to
the fact that the DB had the PCI allocation of the device as 2 after
migration instead of 1. This is due to the DB simply not updating in
time before the check is done.

Looking at Amit's working for evactuation [1] it makes sense to follow a
similar approach and have a waiter check the DB until it updates versus
doing a one time check.

[1] https://review.opendev.org/c/openstack/whitebox-tempest-plugin/+/915393/24/whitebox_tempest_plugin/api/compute/base.py#455

Change-Id: Icc152aa77cdced04cb67e15ab225c4bf754ca89e
This commit is contained in:
jamepark4 2024-05-07 15:49:05 -04:00
parent ff7b954ef1
commit 2ae480517a
1 changed files with 16 additions and 10 deletions

View File

@ -694,6 +694,20 @@ class SRIOVMigration(SRIOVBase):
self.physical_net)
self._create_subnet(self.network['network']['id'])
def _validate_pci_allocation(self, pci_device_status_regex):
"""Check PCI allocation count and confirm it updates to 1"""
start_time = int(time.time())
timeout = self.os_admin.services_client.build_timeout
while int(time.time()) - start_time <= timeout:
pci_allocated_count = self._get_pci_status_count(
pci_device_status_regex)
if pci_allocated_count == 1:
return
time.sleep(self.os_admin.services_client.build_interval + 1)
raise lib_exc.TimeoutException(
pci_allocated_count, 1, 'Total allocated pci devices should be 1 '
'but instead is %s' % pci_allocated_count)
@classmethod
def skip_checks(cls):
super(SRIOVMigration, cls).skip_checks()
@ -746,11 +760,7 @@ class SRIOVMigration(SRIOVBase):
# Validate the total allocation of pci devices is one and only one
# after instance migration
pci_allocated_count = self._get_pci_status_count(
pci_device_status_regex)
self.assertEqual(pci_allocated_count, 1, 'Total allocated pci devices '
'after first migration should be 1 but instead '
'is %s' % pci_allocated_count)
self._validate_pci_allocation(pci_device_status_regex)
if CONF.compute_feature_enabled.live_migrate_back_and_forth:
# Migrate server back to the original host
@ -779,11 +789,7 @@ class SRIOVMigration(SRIOVBase):
# Confirm total port allocations still remains one after final
# migration
pci_allocated_count = self._get_pci_status_count(
pci_device_status_regex)
self.assertEqual(pci_allocated_count, 1, 'Total allocated pci '
'devices after second migration should be 1 but '
'instead is %s' % pci_allocated_count)
self._validate_pci_allocation(pci_device_status_regex)
def test_sriov_direct_live_migration(self):
"""Verify sriov live migration using direct type ports