Make test_create_delete_snapshot more robust
This patch does two things to improve this test, and help debug issues with it failing. - Add additional checks for contents of the first two expected notifications. - Assert the length of the notifications list after checking its contents so that if it contains unexpected items, we can see what they are. This should help with the current gate failures. Change-Id: Ib92247389fb3be6d65a658880fd47e634f1da8d1 Related-Bug: #1412513
This commit is contained in:
parent
b3fd4e1450
commit
8740e06309
|
@ -1760,13 +1760,24 @@ class VolumeTestCase(BaseVolumeTestCase):
|
|||
**self.volume_params)
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 0)
|
||||
self.volume.create_volume(self.context, volume['id'])
|
||||
msg = fake_notifier.NOTIFICATIONS[0]
|
||||
self.assertEqual(msg['event_type'], 'volume.create.start')
|
||||
self.assertEqual(msg['payload']['status'], 'creating')
|
||||
self.assertEqual(msg['priority'], 'INFO')
|
||||
msg = fake_notifier.NOTIFICATIONS[1]
|
||||
self.assertEqual(msg['event_type'], 'volume.create.end')
|
||||
self.assertEqual(msg['payload']['status'], 'available')
|
||||
self.assertEqual(msg['priority'], 'INFO')
|
||||
if len(fake_notifier.NOTIFICATIONS) > 2:
|
||||
# Cause an assert to print the unexpected item
|
||||
self.assertFalse(fake_notifier.NOTIFICATIONS[2])
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 2)
|
||||
|
||||
snapshot_id = self._create_snapshot(volume['id'])['id']
|
||||
self.volume.create_snapshot(self.context, volume['id'], snapshot_id)
|
||||
self.assertEqual(snapshot_id,
|
||||
db.snapshot_get(context.get_admin_context(),
|
||||
snapshot_id).id)
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 4)
|
||||
msg = fake_notifier.NOTIFICATIONS[2]
|
||||
self.assertEqual(msg['event_type'], 'snapshot.create.start')
|
||||
expected = {
|
||||
|
@ -1787,8 +1798,13 @@ class VolumeTestCase(BaseVolumeTestCase):
|
|||
expected['status'] = 'available'
|
||||
self.assertDictMatch(msg['payload'], expected)
|
||||
|
||||
if len(fake_notifier.NOTIFICATIONS) > 4:
|
||||
# Cause an assert to print the unexpected item
|
||||
self.assertFalse(fake_notifier.NOTIFICATIONS[4])
|
||||
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 4)
|
||||
|
||||
self.volume.delete_snapshot(self.context, snapshot_id)
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 6)
|
||||
msg = fake_notifier.NOTIFICATIONS[4]
|
||||
self.assertEqual(msg['event_type'], 'snapshot.delete.start')
|
||||
expected['status'] = 'available'
|
||||
|
@ -1797,6 +1813,12 @@ class VolumeTestCase(BaseVolumeTestCase):
|
|||
self.assertEqual(msg['event_type'], 'snapshot.delete.end')
|
||||
self.assertDictMatch(msg['payload'], expected)
|
||||
|
||||
if len(fake_notifier.NOTIFICATIONS) > 6:
|
||||
# Cause an assert to print the unexpected item
|
||||
self.assertFalse(fake_notifier.NOTIFICATIONS[6])
|
||||
|
||||
self.assertEqual(len(fake_notifier.NOTIFICATIONS), 6)
|
||||
|
||||
snap = db.snapshot_get(context.get_admin_context(read_deleted='yes'),
|
||||
snapshot_id)
|
||||
self.assertEqual(snap['status'], 'deleted')
|
||||
|
|
Loading…
Reference in New Issue