From a481c0b48a248bb9163f6064247f6a24d2203b15 Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Thu, 1 Oct 2015 16:25:17 -0400 Subject: [PATCH] Tests: print fake_notifier queue upon mismatch If these tests fail, output more information so it's easier to figure out where things went wrong. Related-Bug: #1501745 Related-Bug: #1501839 Change-Id: Id78802834821c791a22c22f49260a8480122cc06 --- cinder/tests/unit/test_volume.py | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cinder/tests/unit/test_volume.py b/cinder/tests/unit/test_volume.py index 5000f2698..e5a9a20aa 100644 --- a/cinder/tests/unit/test_volume.py +++ b/cinder/tests/unit/test_volume.py @@ -3038,7 +3038,9 @@ class VolumeTestCase(BaseVolumeTestCase): self.assertEqual('INFO', msg['priority']) if len(self.notifier.notifications) > 2: # Cause an assert to print the unexpected item - self.assertFalse(self.notifier.notifications[2]) + # and all of the notifications. + self.assertFalse(self.notifier.notifications[2], + self.notifier.notifications) self.assertEqual(2, len(self.notifier.notifications), self.notifier.notifications) @@ -3071,7 +3073,9 @@ class VolumeTestCase(BaseVolumeTestCase): if len(self.notifier.notifications) > 4: # Cause an assert to print the unexpected item - self.assertFalse(self.notifier.notifications[4]) + # and all of the notifications. + self.assertFalse(self.notifier.notifications[4], + self.notifier.notifications) self.assertEqual(4, len(self.notifier.notifications), self.notifier.notifications) @@ -3087,7 +3091,9 @@ class VolumeTestCase(BaseVolumeTestCase): if len(self.notifier.notifications) > 6: # Cause an assert to print the unexpected item - self.assertFalse(self.notifier.notifications[6]) + # and all of the notifications. + self.assertFalse(self.notifier.notifications[6], + self.notifier.notifications) self.assertEqual(6, len(self.notifier.notifications), self.notifier.notifications) @@ -5092,14 +5098,16 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase): self.assertDictMatch(expected, msg['payload']) if len(self.notifier.notifications) > 6: - self.assertFalse(self.notifier.notifications[6]) + self.assertFalse(self.notifier.notifications[6], + self.notifier.notifications) self.assertEqual(6, len(self.notifier.notifications), self.notifier.notifications) self.volume.delete_consistencygroup(self.context, group2) if len(self.notifier.notifications) > 10: - self.assertFalse(self.notifier.notifications[10]) + self.assertFalse(self.notifier.notifications[10], + self.notifier.notifications) self.assertEqual(10, len(self.notifier.notifications), self.notifier.notifications) @@ -5291,7 +5299,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase): self.volume.create_volume(self.context, volume_id) if len(self.notifier.notifications) > 2: - self.assertFalse(self.notifier.notifications[2]) + self.assertFalse(self.notifier.notifications[2], + self.notifier.notifications) self.assertEqual(2, len(self.notifier.notifications), self.notifier.notifications) @@ -5303,7 +5312,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase): cgsnapshot_id).id) if len(self.notifier.notifications) > 6: - self.assertFalse(self.notifier.notifications[6]) + self.assertFalse(self.notifier.notifications[6], + self.notifier.notifications) msg = self.notifier.notifications[2] self.assertEqual('cgsnapshot.create.start', msg['event_type']) @@ -5331,7 +5341,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase): self.volume.delete_cgsnapshot(self.context, cgsnapshot_id) if len(self.notifier.notifications) > 10: - self.assertFalse(self.notifier.notifications[10]) + self.assertFalse(self.notifier.notifications[10], + self.notifier.notifications) msg = self.notifier.notifications[6] self.assertEqual('cgsnapshot.delete.start', msg['event_type']) -- 2.45.2