summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSiddharth Ravikumar <sravik@bgsu.edu>2015-04-08 20:49:09 -0400
committerSiddharth Ravikumar <sravik@bgsu.edu>2015-04-08 20:49:09 -0400
commita6a2c35dbdcae1a1a69e348d8fc2ffe07eee4be3 (patch)
tree2a3183d20e48952b2b3cf11ee76cd160745ef352 /tests
parentf15ce63ba11ad101349ee51a0baa4109400d7329 (diff)
rewrote combox.events.NodeDirMonitor.on_modified method.
- Now the the node monitor waits for all shards of the file, which was modified on a remote computer, to arrive on this computer, before it re-constructs the file into the respective location in the combox directory. - Tests for it is at tests.events_test.TestEvents.test_NDM_onmodified method. modified: combox/events.py modified: tests/events_test.py Part of this was done while listening to Avril's "Complicated" ; I think this is the only modern Pop song which I like.
Diffstat (limited to 'tests')
-rw-r--r--tests/events_test.py58
1 files changed, 58 insertions, 0 deletions
diff --git a/tests/events_test.py b/tests/events_test.py
index a0001b5..ae626b8 100644
--- a/tests/events_test.py
+++ b/tests/events_test.py
@@ -303,6 +303,64 @@ class TestEvents(object):
observers[i].join()
+ def test_NDM_onmodified(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)
+
+ # Test - shard modification
+ self.lorem_file = path.join(self.FILES_DIR, 'lorem.txt')
+ lorem_content = read_file(self.lorem_file)
+ self.lorem_file_copy = "%s.copy" % self.lorem_file
+
+ copyfile(self.lorem_file, self.lorem_file_copy)
+ split_and_encrypt(self.lorem_file_copy, self.config,
+ lorem_content)
+
+ self.silo.update(self.lorem_file_copy)
+ shardedp(self.lorem_file_copy)
+
+ self.silo.reload()
+ lorem_file_copy_hash = self.silo.db.get(self.lorem_file_copy)
+
+ self.ipsum_file = path.join(self.FILES_DIR, 'ipsum.txt')
+ ipsum_content = read_file(self.ipsum_file)
+ lorem_copy_content = "%s\n%s" % (lorem_content, ipsum_content)
+
+ split_and_encrypt(self.lorem_file_copy, self.config,
+ lorem_copy_content)
+ time.sleep(1)
+ assert lorem_copy_content == read_file(self.lorem_file_copy)
+
+ ## check if the lorem_file_copy's info is updated in silo
+ self.silo.reload()
+ assert lorem_file_copy_hash != self.silo.db.get(self.lorem_file_copy)
+ assert_equal(None, self.silo.node_get('file_modified',
+ self.lorem_file_copy))
+
+ self.purge_list.append(self.lorem_file_copy)
+
+ # stop the zarking observers.
+ for i in range(num_nodes):
+ observers[i].stop()
+ observers[i].join()
+
+
def untest_NDM(self):
"""
Tests the NodeDirMonitor class.