diff options
author | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-04-15 20:48:47 -0400 |
---|---|---|
committer | Siddharth Ravikumar <sravik@bgsu.edu> | 2015-04-15 20:48:47 -0400 |
commit | 098ae99641d5c848af1d0d25c29b254e7cd9d12e (patch) | |
tree | 0a95deb907b5a952ad42e288968617389f67c387 /tests/events_test.py | |
parent | 7c29a7dc5f592aff38e4c71a777a8cd6fdac9daf (diff) |
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 (*)
Diffstat (limited to 'tests/events_test.py')
-rw-r--r-- | tests/events_test.py | 55 |
1 files changed, 55 insertions, 0 deletions
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. |