]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
For persistence test, use a new client (with the same backupdb).
authorDaira Hopwood <daira@jacaranda.org>
Tue, 21 Apr 2015 22:52:26 +0000 (23:52 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 28 Apr 2015 18:46:48 +0000 (19:46 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/test/test_drop_upload.py

index 4399a9c865fd4e00b21983e286d5f8a653bc1a25..77711e441b35b92c85cfb09acdfd9f44b1d91a59 100644 (file)
@@ -45,6 +45,8 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         self.failUnless(IDirectoryNode.providedBy(n))
         self.upload_dirnode = n
         self.upload_dircap = n.get_uri()
+
+    def _create_uploader(self, ign):
         self.uploader = DropUploader(self.client, self.upload_dircap, self.local_dir.encode('utf-8'),
                                          "magicfolderdb.sqlite", inotify=self.inotify, pending_delay=0.2)
         self.uploader.setServiceParent(self.client)
@@ -72,6 +74,7 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
 
         d = self.client.create_dirnode()
         d.addCallback(self._made_upload_dir)
+        d.addCallback(self._create_uploader)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.dirs_monitored'), 1))
         d.addBoth(self._cleanup)
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.dirs_monitored'), 0))
@@ -89,6 +92,7 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
 
         d = self.client.create_dirnode()
         d.addCallback(self._made_upload_dir)
+        d.addCallback(self._create_uploader)
 
         def testMoveEmptyTree(res):
             tree_name = 'empty_tree'
@@ -139,11 +143,13 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         self.set_up_grid()
         self.local_dir = os.path.join(self.basedir, u"test_persistence")
         self.mkdir_nonascii(self.local_dir)
+
         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.addCallback(self._create_uploader)
+
         def create_file(val):
             d2 = defer.Deferred()
             self.uploader.set_uploaded_callback(d2.callback)
@@ -157,13 +163,16 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         d.addCallback(self._cleanup)
-        d.addCallback(lambda ign: self.client.removeService(self.uploader))
-        def msg(val):
-            print "stopped and removed uploader service."
-        d.addCallback(msg)
-        d.addCallback(self._made_upload_dir)
+
+        def _restart(ign):
+            print "in _restart"
+            self.set_up_grid()
+            self.client = self.g.clients[0]
+            self.stats_provider = self.client.stats_provider
+        d.addCallback(_restart)
+        d.addCallback(self._create_uploader)
         d.addCallback(lambda ign: time.sleep(3))
-        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 0))
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
         d.addBoth(self._cleanup)
         return d
@@ -181,6 +190,7 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         d = self.client.create_dirnode()
 
         d.addCallback(self._made_upload_dir)
+        d.addCallback(self._create_uploader)
 
         # Write something short enough for a LIT file.
         d.addCallback(lambda ign: self._test_file(u"short", "test"))