]> xenbits.xensource.com Git - osstest/openstack-nova.git/commitdiff
Fix race in test_volume_swap_server_with_error
authorMatt Riedemann <mriedem@us.ibm.com>
Wed, 23 Nov 2016 21:18:18 +0000 (16:18 -0500)
committerMatt Riedemann <mriedem@us.ibm.com>
Wed, 23 Nov 2016 21:18:18 +0000 (16:18 -0500)
This functional test is waiting for a flag to be set in
the CinderFixture which is called when swap_volume calls
volume_api.unreserve_volume after the swap_volume error
occurs. That happens after the two swap-volume notifications
are sent (for start and error).

The test was asserting a 5th notification for the generic
instance fault, which happens, but might not happen before
the CinderFixture flag is set and the test checks for 5
notifications.

This test really only cares that there are the two swap-volume
notifications, so to avoid a race this change just makes
the test assert that there are at least 4 versioned notifications
by the time the swap-volume error occurs, which is all it was
checking after that anyway.

Change-Id: I8fd44b083f109c034958a305a4e41f9d810c4389
Closes-Bug: #1639894

nova/tests/functional/notification_sample_tests/test_instance.py

index f1f295e2e9d9d048293991add82ee1b0e025a61a..cc432e0082a60be2279aed616b3f991b7a9703de 100644 (file)
@@ -561,13 +561,20 @@ class TestInstanceNotificationSample(
                                  self.cinder.SWAP_ERR_NEW_VOL)
         self._wait_until_swap_volume_error()
 
-        # Five versioned notifications are generated.
+        # Five versioned notifications are generated. We only rely on the
+        # first four because _wait_until_swap_volume_error will return True
+        # after volume_api.unreserve is called on the cinder fixture, and that
+        # happens before the instance fault is handled in the compute manager
+        # which generates the 5th notification (compute.exception).
         # 0. instance-create-start
         # 1. instance-create-start
         # 2. instance-volume_swap-start
         # 3. instance-volume_swap-error
         # 4. compute.exception
-        self.assertEqual(5, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+        self.assertTrue(len(fake_notifier.VERSIONED_NOTIFICATIONS) >= 4,
+                        'Unexpected number of versioned notifications. '
+                        'Expected at least 4, got: %s' %
+                        len(fake_notifier.VERSIONED_NOTIFICATIONS))
         self._verify_notification(
             'instance-volume_swap-start',
             replacements={