From: Daira Hopwood Date: Tue, 21 Apr 2015 22:52:26 +0000 (+0100) Subject: For persistence test, use a new client (with the same backupdb). X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/running.html?a=commitdiff_plain;h=af80b58b8373501f4afeeacd3bc57c8aae65a4ac;p=tahoe-lafs%2Ftahoe-lafs.git For persistence test, use a new client (with the same backupdb). Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index 4399a9c8..77711e44 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -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"))