From 098ae99641d5c848af1d0d25c29b254e7cd9d12e Mon Sep 17 00:00:00 2001 From: Siddharth Ravikumar Date: Wed, 15 Apr 2015 20:48:47 -0400 Subject: rewrote combox.events.NodeDirMonitor.on_deleted method. - Now the the node monitor waits for all shards of the file, which was deleted on a remote computer, to get deleted on this computer, before it finally deletes the respective file in the combox directory. - Tests for it is at tests.events_test.TestEvents.test_NDM_ondeleted method. modified: combox/events.py modified: tests/events_test.py Did some of this while listening to Cat Stevens' (Yusuf): - Just Another Night - Wild World - Father and son (*) - Peace train - Moonshadow (*) --- tests/events_test.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) (limited to 'tests') diff --git a/tests/events_test.py b/tests/events_test.py index ae626b8..9d90f0e 100644 --- a/tests/events_test.py +++ b/tests/events_test.py @@ -361,6 +361,61 @@ class TestEvents(object): observers[i].join() + def test_NDM_ondeleted(self): + """Testing on_modified method in NodeDirMonitor""" + nodes = get_nodedirs(self.config) + num_nodes = len(get_nodedirs(self.config)) + + nmonitors = [] + observers = [] + + # create an observer for each node directory and make it + # monitor them. + for node in nodes: + nmonitor = NodeDirMonitor(self.config, self.silo_lock, + self.nodem_lock) + observer = Observer() + observer.schedule(nmonitor, node, recursive=True) + observer.start() + + nmonitors.append(nmonitor) + observers.append(observer) + + BAR_DIR = path.join(self.FILES_DIR, 'bar') + mk_nodedir(BAR_DIR, self.config) + # wait for the `bar' directory to be created inside combox + # directory. + time.sleep(1) + + # Test - directory deletion inside node directory. + rm_nodedir(BAR_DIR, self.config) + time.sleep(1) + assert not path.exists(BAR_DIR) + + the_guide = path.join(self.FILES_DIR, 'the.guide') + split_and_encrypt(the_guide, self.config, + read_file(self.TEST_FILE)) + time.sleep(1) + assert path.exists(the_guide) + + # Test - Shard deletion. + rm_shards(the_guide, self.config) + time.sleep(1) + assert not path.exists(the_guide) + + ## check if the new file's info is removed from silo + silo = ComboxSilo(self.config, self.silo_lock) + assert not silo.exists(the_guide) + + self.purge_list.append(BAR_DIR) + self.purge_list.append(the_guide) + + # stop the zarking observers. + for i in range(num_nodes): + observers[i].stop() + observers[i].join() + + def untest_NDM(self): """ Tests the NodeDirMonitor class. -- cgit v1.2.3