)]}'
{"test/unit/cli/test_ringbuilder.py":[{"author":{"_account_id":4608,"name":"Kota Tsuyuzaki","email":"bloodeagle40234@gmail.com","username":"tsuyuzaki-kota"},"change_message_id":"9b498b0b12cfb397308973436ce90397ddbae7b0","unresolved":false,"context_lines":[{"line_number":1889,"context_line":""},{"line_number":1890,"context_line":"    def test_time_remaining(self):"},{"line_number":1891,"context_line":"        self.create_sample_ring()"},{"line_number":1892,"context_line":"        self.run_srb(\u0027rebalance\u0027)"},{"line_number":1893,"context_line":"        now \u003d time.time()"},{"line_number":1894,"context_line":"        with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dnow):"},{"line_number":1895,"context_line":"            out, err \u003d self.run_srb(\u0027rebalance\u0027)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a430d35_13fc143d","side":"PARENT","line":1892,"updated":"2017-02-08 11:24:20.000000000","message":"Ok, so the reason why we can get \"0:59:59 remaining\" is we could spend 1 sec (excactly it\u0027s actually less than 1 sec but the last_part_moves_epoch is truncated as int[1]) so that it could happen easily with int(xxxx.9999) sec in last_part_moves and the time() call L1893 is being xxxy.0001 (assuming x + 1 \u003d y). And then the integer will be different with 1 sec delta, make sense.\n\n1: https://github.com/openstack/swift/blob/master/swift/common/ring/builder.py#L878","commit_id":"38cebabbebcd4a79c01830f7fc8ad2bca88dc734"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"f2671412af045510a804bcbb9acca93778ab5091","unresolved":false,"context_lines":[{"line_number":1891,"context_line":"        self.create_sample_ring()"},{"line_number":1892,"context_line":"        now \u003d time.time()"},{"line_number":1893,"context_line":"        with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dnow):"},{"line_number":1894,"context_line":"            self.run_srb(\u0027rebalance\u0027)"},{"line_number":1895,"context_line":"            out, err \u003d self.run_srb(\u0027rebalance\u0027)"},{"line_number":1896,"context_line":"        self.assertIn(\u0027No partitions could be reassigned\u0027, out)"},{"line_number":1897,"context_line":"        self.assertIn(\u0027must be at least min_part_hours\u0027, out)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a430d35_bf186476","line":1894,"updated":"2017-02-08 10:56:56.000000000","message":"I thought at first you could just do this\n\n    diff --git a/test/unit/cli/test_ringbuilder.py b/test/unit/cli/test_ringbuilder.py\n    index ba8247c..9cc4a6a 100644\n    --- a/test/unit/cli/test_ringbuilder.py\n    +++ b/test/unit/cli/test_ringbuilder.py\n    @@ -1889,8 +1889,8 @@ class TestCommands(unittest.TestCase, RunSwiftRingBuilderMixin):\n     \n         def test_time_remaining(self):\n             self.create_sample_ring()\n    -        self.run_srb(\u0027rebalance\u0027)\n             now \u003d time.time()\n    +        self.run_srb(\u0027rebalance\u0027)\n             with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dnow):\n                 out, err \u003d self.run_srb(\u0027rebalance\u0027)\n             self.assertIn(\u0027No partitions could be reassigned\u0027, out)\n\nBut that\u0027s the same problem the other way - if the call to time *inside* rebalance is different than the result of time called outside - it\u0027s not gunna line up!\n\nMaybe something like this tells a better story?\n\n    diff --git a/test/unit/cli/test_ringbuilder.py b/test/unit/cli/test_ringbuilder.py\n    index ba8247c..61ef01d 100644\n    --- a/test/unit/cli/test_ringbuilder.py\n    +++ b/test/unit/cli/test_ringbuilder.py\n    @@ -1889,14 +1889,17 @@ class TestCommands(unittest.TestCase, RunSwiftRingBuilderMixin):\n     \n         def test_time_remaining(self):\n             self.create_sample_ring()\n    -        self.run_srb(\u0027rebalance\u0027)\n    -        now \u003d time.time()\n    -        with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dnow):\n    +        start \u003d time.time()\n    +        with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dstart):\n    +            self.run_srb(\u0027rebalance\u0027)\n    +        next_rebalance \u003d start + 10\n    +        with mock.patch(\u0027swift.common.ring.builder.time\u0027,\n    +                        return_value\u003dnext_rebalance):\n                 out, err \u003d self.run_srb(\u0027rebalance\u0027)\n             self.assertIn(\u0027No partitions could be reassigned\u0027, out)\n             self.assertIn(\u0027must be at least min_part_hours\u0027, out)\n    -        self.assertIn(\u00271 hours (1:00:00 remaining)\u0027, out)\n    -        the_future \u003d now + 3600\n    +        self.assertIn(\u00271 hours (0:59:50 remaining)\u0027, out)\n    +        the_future \u003d start + 3600\n             with mock.patch(\u0027swift.common.ring.builder.time\u0027,\n                             return_value\u003dthe_future):\n                 out, err \u003d self.run_srb(\u0027rebalance\u0027)","commit_id":"67d545e90f8046e686d3877c245b123c8b5fa58b"},{"author":{"_account_id":4608,"name":"Kota Tsuyuzaki","email":"bloodeagle40234@gmail.com","username":"tsuyuzaki-kota"},"change_message_id":"9b498b0b12cfb397308973436ce90397ddbae7b0","unresolved":false,"context_lines":[{"line_number":1891,"context_line":"        self.create_sample_ring()"},{"line_number":1892,"context_line":"        now \u003d time.time()"},{"line_number":1893,"context_line":"        with mock.patch(\u0027swift.common.ring.builder.time\u0027, return_value\u003dnow):"},{"line_number":1894,"context_line":"            self.run_srb(\u0027rebalance\u0027)"},{"line_number":1895,"context_line":"            out, err \u003d self.run_srb(\u0027rebalance\u0027)"},{"line_number":1896,"context_line":"        self.assertIn(\u0027No partitions could be reassigned\u0027, out)"},{"line_number":1897,"context_line":"        self.assertIn(\u0027must be at least min_part_hours\u0027, out)"}],"source_content_type":"text/x-python","patch_set":1,"id":"1a430d35_b314204d","line":1894,"in_reply_to":"1a430d35_bf186476","updated":"2017-02-08 11:24:20.000000000","message":"Ok, it\u0027s safe, now. the time() call in the ring builder is always consistent with now.\n\nI think the more tests Clay suggested looks good but it\u0027s ok to merge this one as this is, because this fixes the failure we hit freaky in the gate.","commit_id":"67d545e90f8046e686d3877c245b123c8b5fa58b"}]}
