Commit 786a742b authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

[2856] With no readers, make complete_update() from UPDATING go directly to READY

parent 4f96d3ab
......@@ -169,7 +169,7 @@ class SegmentInfo:
self.__state = self.SYNCHRONIZING
self.__old_readers = self.__readers
self.__readers = set()
return self.__sync_reader_helper(self.SYNCHRONIZING)
return self.__sync_reader_helper(self.READY)
elif self.__state == self.COPYING:
self.__state = self.READY
return None
......
......@@ -175,6 +175,18 @@ class TestSegmentInfo(unittest.TestCase):
self.assertIsNone(e) # old_readers is not empty
self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.SYNCHRONIZING)
# c) with no readers, complete_update() from UPDATING must go
# directly to READY state
self.__si_to_ready_state()
self.__sgmt_info.add_event((42,))
e = self.__sgmt_info.start_update()
self.assertTupleEqual(e, (42,))
self.assertSetEqual(self.__sgmt_info.get_readers(), set())
self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.UPDATING)
e = self.__sgmt_info.complete_update()
self.assertTupleEqual(e, (42,))
self.assertEqual(self.__sgmt_info.get_state(), SegmentInfo.READY)
# in SYNCHRONIZING state
self.__si_to_synchronizing_state()
self.assertRaises(SegmentInfoError, self.__sgmt_info.complete_update)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment