]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix magic-folder Persistence test
authorDavid Stainton <dstainton415@gmail.com>
Wed, 24 Jun 2015 23:45:01 +0000 (16:45 -0700)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 30 Sep 2015 15:45:22 +0000 (16:45 +0100)
here we teach this test to create invite join
a magic-folder using the CLI... and then we go
on to fix various bugs.

src/allmydata/client.py
src/allmydata/frontends/magic_folder.py
src/allmydata/test/test_magic_folder.py

index 86ae9ac23a4cfaf31bfbf533d287a7fa46688a28..1175882cdafa509caedf79056b1900a0fa512593 100644 (file)
@@ -499,6 +499,9 @@ class Client(node.Node, pollmixin.PollMixin):
 
         if self.get_config("magic_folder", "enabled", False, boolean=True):
             upload_dircap = self.get_or_create_private_config("magic_folder_dircap")
+            upload_dircap is not None
+            # XXX correcto?
+            #local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
             local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
             local_dir = abspath_expanduser_unicode(local_dir_config, base=self.basedir)
 
@@ -510,6 +513,7 @@ class Client(node.Node, pollmixin.PollMixin):
                 collective_dircap_path = os.path.join(self.basedir, "private", "collective_dircap")
                 collective_dircap_path = abspath_expanduser_unicode(collective_dircap_path)
                 collective_dircap = fileutil.read(collective_dircap_path).strip()
+                assert collective_dircap is not None
 
                 s = magic_folder.MagicFolder(self, upload_dircap, collective_dircap, local_dir, dbfile)
                 s.setServiceParent(self)
index 4a7fc4cad12c7c1c1087ed235d93a2e2d82c5283..85cdd04f27d1b7bde5941b2b22f502b37959b4a7 100644 (file)
@@ -105,7 +105,7 @@ class MagicFolder(service.MultiService):
         r = self._db.check_file(childpath)
         filecap = r.was_uploaded()
         if filecap is False:
-            return True
+            return False
 
     def _scan(self, localpath):
         if not os.path.isdir(localpath):
@@ -136,7 +136,7 @@ class MagicFolder(service.MultiService):
                 self._scan(childpath)
             elif isfile:
                 is_uploaded = self._db_file_is_uploaded(childpath)
-                if not is_uploaded: 
+                if not is_uploaded:
                     self._append_to_deque(childpath)
             else:
                 self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
@@ -192,7 +192,6 @@ class MagicFolder(service.MultiService):
             return self._upload_dirnode.add_file(name, u, overwrite=True)
 
         def _add_dir(name):
-            print "MEOWMEOW!"
             self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True)
             u = Data("", self._convergence)
             name += "@_"
index 2eeb52908c837ff90041cd4f3c99698cf03672db..406c865b7eb857b424cc61dd7b726eee9a487a4c 100644 (file)
@@ -76,8 +76,7 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
 
     def _check_config(self, result):
         client_config = fileutil.read(os.path.join(self.get_clientdir(), "tahoe.cfg"))
-        print "CLIENT CONFIG", client_config
-        # XXX utf-8
+        # XXX utf-8?
         ret = re.search("\[magic_folder\]\nenabled = True\nlocal.directory = %s" % (self.local_dir.encode('utf-8'),), client_config)
         self.failIf(ret is None)
         return result
@@ -191,7 +190,6 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
         d.addCallback(self._create_magicfolder)
 
         def _check_move_empty_tree(res):
-            print "MEOW 0"
             self.mkdir_nonascii(empty_tree_dir)
             d2 = defer.Deferred()
             self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
@@ -205,14 +203,12 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 1))
         
         def _check_move_small_tree(res):
-            print "MEOW 1"
             self.mkdir_nonascii(small_tree_dir)
             fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when")
             d2 = defer.Deferred()
             self.magicfolder.set_processed_callback(d2.callback, ignore_count=1)
             os.rename(small_tree_dir, new_small_tree_dir)
             self.notify(to_filepath(new_small_tree_dir), self.inotify.IN_MOVED_TO)
-            print "end of MEOW 1"
             return d2
         d.addCallback(_check_move_small_tree)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3))
@@ -221,7 +217,6 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 2))
 
         def _check_moved_tree_is_watched(res):
-            print "MEOW 2"
             d2 = defer.Deferred()
             self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
             fileutil.write(abspath_expanduser_unicode(u"another", base=new_small_tree_dir), "file")
@@ -266,29 +261,33 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
 
         self.client = self.g.clients[0]
         self.stats_provider = self.client.stats_provider
-        d = self.client.create_dirnode()
-        d.addCallback(self._made_upload_dir)
+        d = self._create_invite_join_magic_folder()
         d.addCallback(self._create_magicfolder)
 
-        def create_file(val):
+        def create_test_file(result):
             d2 = defer.Deferred()
-            self.magicfolder.set_processed_callback(d2.callback)
+            self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
             test_file = abspath_expanduser_unicode(u"what", base=self.local_dir)
             fileutil.write(test_file, "meow")
             self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
             return d2
-        d.addCallback(create_file)
+        d.addCallback(create_test_file)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 1))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
-        d.addCallback(self._cleanup)
 
         def _restart(ign):
-            self.set_up_grid()
+            tahoe_config_file = os.path.join(self.get_clientdir(), "tahoe.cfg")
+            tahoe_config = fileutil.read(tahoe_config_file)
+            def write_config(client_node_dir):
+                fileutil.write(os.path.join(client_node_dir, "tahoe.cfg"), tahoe_config)
+            self.set_up_grid(client_config_hooks={0: write_config})
             self.client = self.g.clients[0]
             self.stats_provider = self.client.stats_provider
+            d.addCallback(self._create_magicfolder)
+            d.addCallback(lambda x: time.sleep(1))
+
+        d.addCallback(self._cleanup)
         d.addCallback(_restart)
-        d.addCallback(self._create_magicfolder)
-        d.addCallback(lambda ign: time.sleep(3))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
         d.addBoth(self._cleanup)