From 2b96ea454523354de88da661219395e02694ee84 Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Fri, 1 May 2015 09:36:46 -0400 Subject: Updated combox.events.NodeDirMonitor.housekeep's 're-construct file' functionality. - Now the housekeep method re-contructs the files, whose shards were created when combox was off, in the combox directory only if all of its shards have made it to the respective node directories. - If it finds only some of all the shards of a file missing, it stores this information in the `file_created' dict inside the silo. - tests.events_tests.TestEvents.test_NDM_housekeep_create tests the 're-construct file' functionality of combox.events.NodeDirMonitor.housekeep method. modified: combox/events.py modified: tests/events_test.py --- tests/events_test.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/events_test.py b/tests/events_test.py index abb490a..a8b25ab 100644 --- a/tests/events_test.py +++ b/tests/events_test.py @@ -599,6 +599,36 @@ class TestEvents(object): self.purge_list.append(testf2) + def test_NDM_housekeep_create(self): + """Testing NodeDirMonitor's housekeep method's delete functionality.""" + + # test shard creation + hmutant = "%s.mutant" % self.TEST_FILE + hmutant_content = read_file(self.TEST_FILE) + split_and_encrypt(hmutant, self.config, + hmutant_content) + + lorem_c = "%s.c" % self.lorem + split_and_encrypt(lorem_c, self.config, + read_file(self.lorem)) + # delete lorem_c's shard0 + remove(node_paths(lorem_c, self.config, True)[0]) + + ndm = NodeDirMonitor(self.config, self.silo_lock, + self.nodem_lock) + ndm.housekeep() + + assert path.exists(hmutant) + assert hmutant_content == read_file(hmutant) + + assert not path.exists(lorem_c) + assert_equal(len(get_nodedirs(self.config))-1, + self.silo.node_get('file_created', lorem_c)) + + self.purge_list.append(hmutant) + self.purge_list.append(lorem_c) + + def untest_NDM_housekeep(self): """Testing NodeDirMonitor's housekeep method.""" -- cgit v1.2.3