From: Eric Harney Date: Mon, 19 Jan 2015 19:01:45 +0000 (-0500) Subject: Make test_create_delete_snapshot more robust X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8740e063;p=openstack-build%2Fcinder-build.git 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 --- diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 61b8830de..ad32e6803 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -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')