]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Teach test_persistence to only use one clientdir
authorDavid Stainton <dstainton415@gmail.com>
Sat, 12 Sep 2015 12:02:53 +0000 (14:02 +0200)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:43:00 +0000 (18:43 +0100)
This effectively fixes the bug where upon restart the client
uses a different clientdir

src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index 412995bc7c816b95806970d39b7ab736f277f4ce..3349fac30dd9faca296888ec34f24aa54aa97715 100644 (file)
@@ -109,13 +109,15 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
         return magicfolder
 
     def create_magicfolder(self, client_num=0):
-        dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.get_clientdir(i=client_num))
-        self.collective_dircap, self.upload_dircap = self.get_caps_from_files(0)
+        print "create_magicfolder clientdir %s" % (self.get_clientdir(i=client_num),)
+        dbfile = abspath_expanduser_unicode(u"private/magicfolderdb.sqlite", base=self.get_clientdir(i=client_num))
+        print "create_magicfolder: dbfile: %s" % (dbfile,)
+        self.collective_dircap, self.upload_dircap = self.get_caps_from_files(client_num)
 
         self.magicfolder = MagicFolder(self.get_client(client_num), self.upload_dircap, self.collective_dircap, self.local_dir,
                                        dbfile, inotify=self.inotify, pending_delay=0.2)
-        magicfolder.setServiceParent(self.get_client(client_num))
-        return magicfolder.ready()
+        self.magicfolder.setServiceParent(self.get_client(client_num))
+        return self.magicfolder.ready()
 
 
     def setup_alice_and_bob(self):
index 265d2c3d44c129e0d9ee263eb84ad0882be85c71..2942be3e02916b4df09ecf441285e2301b93ab98 100644 (file)
@@ -195,21 +195,15 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         a second time. This test is meant to test the database persistence along with
         the startup and shutdown code paths of the magic-folder service.
         """
-        print "test_persistence"
-        print "basedir = %s" % (self.basedir,)
-
         self.set_up_grid()
         self.local_dir = abspath_expanduser_unicode(u"test_persistence", base=self.basedir)
         self.mkdir_nonascii(self.local_dir)
         self.collective_dircap = ""
 
-        print "calling create_invite_join_magic_folder with self.local_dir %s" % (self.local_dir,)
         d = defer.succeed(None)
         d.addCallback(lambda ign: self.create_invite_join_magic_folder(u"Alice", self.local_dir))
-        #d.addCallback(self._create_magicfolder)
-        d.addCallback(self.create_magicfolder())
-        #d.addCallback(self._restart_client)
-        
+        d.addCallback(lambda ign: self.create_magicfolder())
+
         def create_test_file(result, filename):
             d2 = self.magicfolder.uploader.set_hook('processed')
             test_file = abspath_expanduser_unicode(filename, base=self.local_dir)
@@ -224,14 +218,13 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
         d.addCallback(self.cleanup)
         d.addCallback(self._restart_client)
-
         d.addCallback(lambda ign: create_test_file(ign, u"what2"))
 
         def fu2(ign):
             print "2nd upload complete"
         d.addBoth(fu2)
 
-        #d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_succeeded'), 1))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('uploader.objects_queued'), 0))
         d.addBoth(self.cleanup)
         return d