summaryrefslogtreecommitdiff
path: root/nova/tests/functional/db/test_archive.py
diff options
context:
space:
mode:
Diffstat (limited to 'nova/tests/functional/db/test_archive.py')
-rw-r--r--nova/tests/functional/db/test_archive.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/nova/tests/functional/db/test_archive.py b/nova/tests/functional/db/test_archive.py
index 0bda64eb43..68ddb327ba 100644
--- a/nova/tests/functional/db/test_archive.py
+++ b/nova/tests/functional/db/test_archive.py
@@ -114,6 +114,19 @@ class TestDatabaseArchive(integrated_helpers._IntegratedTestBase):
# Verify we have some system_metadata since we'll check that later.
self.assertTrue(len(instance.system_metadata),
'No system_metadata for instance: %s' % server_id)
+ # Create a pci_devices record to simulate an instance that had a PCI
+ # device allocated at the time it was deleted. There is a window of
+ # time between deletion of the instance record and freeing of the PCI
+ # device in nova-compute's _complete_deletion method during RT update.
+ db.pci_device_update(admin_context, 1, 'fake-address',
+ {'compute_node_id': 1,
+ 'address': 'fake-address',
+ 'vendor_id': 'fake',
+ 'product_id': 'fake',
+ 'dev_type': 'fake',
+ 'label': 'fake',
+ 'status': 'allocated',
+ 'instance_uuid': instance.uuid})
# Now try and archive the soft deleted records.
results, deleted_instance_uuids, archived = \
db.archive_deleted_rows(max_rows=100)
@@ -128,6 +141,8 @@ class TestDatabaseArchive(integrated_helpers._IntegratedTestBase):
self.assertIn('instance_actions', results)
self.assertIn('instance_actions_events', results)
self.assertEqual(sum(results.values()), archived)
+ # Verify that the pci_devices record has not been dropped
+ self.assertNotIn('pci_devices', results)
def _get_table_counts(self):
engine = sqlalchemy_api.get_engine()