From 67d545e90f8046e686d3877c245b123c8b5fa58b Mon Sep 17 00:00:00 2001 From: Christian Schwede Date: Sat, 4 Feb 2017 05:50:28 +0000 Subject: [PATCH] Fix timing test error when rebalancing The reported timing can be 00:59:59 sometimes, but is still valid. This will fail in the tests, as seen in [1]. This patch fixes this by mocking the current time, ensuring that the first two rebalances happen at the same time. [1] http://logs.openstack.org/97/337297/32/check/gate-swift-python27-ubuntu-xenial/46203f1/console.html#_2017-02-08_07_28_42_589176 Change-Id: I0fd43d5bb13d0e88126f4f6ba14fb87faab6df9c --- test/unit/cli/test_ringbuilder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/cli/test_ringbuilder.py b/test/unit/cli/test_ringbuilder.py index ba8247ccfa..cbd4be3449 100644 --- a/test/unit/cli/test_ringbuilder.py +++ b/test/unit/cli/test_ringbuilder.py @@ -1889,9 +1889,9 @@ class TestCommands(unittest.TestCase, RunSwiftRingBuilderMixin): def test_time_remaining(self): self.create_sample_ring() - self.run_srb('rebalance') now = time.time() with mock.patch('swift.common.ring.builder.time', return_value=now): + self.run_srb('rebalance') out, err = self.run_srb('rebalance') self.assertIn('No partitions could be reassigned', out) self.assertIn('must be at least min_part_hours', out)