]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make test_nvp_sync.SyncLoopingCallTestCase reliable
authorSalvatore Orlando <salv.orlando@gmail.com>
Sat, 19 Oct 2013 09:06:37 +0000 (02:06 -0700)
committerSalvatore Orlando <salv.orlando@gmail.com>
Sat, 19 Oct 2013 10:01:26 +0000 (03:01 -0700)
This patch removes the previous check that verified the mocked
looping call had an exact number of calls, and replaces it with a
simpler check that just verifies that the mock has been called.

As a consequence, this patch also shortens the test duration.

Closes-Bug: 1241969

Change-Id: Ia7bc66e1f2f631e46ddcbe0eacc1d5b2481274cb

neutron/tests/unit/nicira/test_nvp_sync.py

index 23ffc510ada5de6135caca3fa5da0a9be7bc9395..a39441b1d7acf156cc40173fefffe0dc4817d3ea 100644 (file)
@@ -243,15 +243,15 @@ class SyncLoopingCallTestCase(base.BaseTestCase):
         # Avoid runs of the synchronization process - just start
         # the looping call
         with mock.patch.object(
-            sync.NvpSynchronizer, '_synchronize_state',
-            return_value=0.01):
+            sync.NvpSynchronizer, '_synchronize_state', return_value=0.01):
             synchronizer = sync.NvpSynchronizer(None, None,
                                                 100, 0, 0)
-            time.sleep(0.04999)
+            time.sleep(0.03)
             # stop looping call before asserting
             synchronizer._sync_looping_call.stop()
-            self.assertEqual(
-                5, synchronizer._synchronize_state.call_count)
+            # Just verify the looping call has been called, trying
+            # to assess the exact number of calls would be unreliable
+            self.assertTrue(synchronizer._synchronize_state.call_count)
 
 
 class NvpSyncTestCase(base.BaseTestCase):