From: David Stainton Date: Fri, 3 Jul 2015 01:14:24 +0000 (-0700) Subject: fix some tests X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=79863efab5cf28d9c0f2917fdd6e6d98354631f5;p=tahoe-lafs%2Ftahoe-lafs.git fix some tests --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 3d005fb7..208b9cbf 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -53,6 +53,7 @@ class MagicFolder(service.MultiService): self._download_scan_batch = {} self._download_lazy_tail = defer.succeed(None) self._download_pending = set() + self._collective_dirnode = None self._client = client self._stats_provider = client.stats_provider self._convergence = client.convergence @@ -114,8 +115,6 @@ class MagicFolder(service.MultiService): recursive=True) - self._scan_remote_collective() - def _should_download(self, path, remote_version): """ _should_download returns a bool indicating whether or not a remote object should be downloaded. @@ -145,6 +144,8 @@ class MagicFolder(service.MultiService): return listing_d def _scan_remote_collective(self): + if self._collective_dirnode is None: + return upload_readonly_dircap = self._upload_dirnode.get_readonly_uri() collective_dirmap_d = self._collective_dirnode.list() def do_filter(result): @@ -271,7 +272,7 @@ class MagicFolder(service.MultiService): self._log("magic folder upload deque is now empty") self._download_lazy_tail = defer.succeed(None) self._download_lazy_tail.addCallback(lambda ign: task.deferLater(reactor, self._remote_scan_delay, self._scan_remote_collective)) - self._download_lazy_tail.addCallback(lambda ign: task.deferLater(reactor, 0, self._turn_download_deque)) + #self._download_lazy_tail.addCallback(lambda ign: task.deferLater(reactor, 0, self._turn_download_deque)) return self._download_lazy_tail.addCallback(lambda ign: task.deferLater(reactor, 0, self._download_file, file_path, file_node)) self._download_lazy_tail.addCallback(lambda ign: task.deferLater(reactor, self._remote_scan_delay, self._turn_download_deque)) diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index df8b84a6..f716df3f 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -107,7 +107,10 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): def cleanup(self, res): d = defer.succeed(None) if self.magicfolder is not None: + print "CLEANUP" d.addCallback(lambda ign: self.magicfolder.finish(for_tests=True)) + else: + print "cannot CLEANUP self.magicfolder is None" d.addCallback(lambda ign: res) return d diff --git a/src/allmydata/test/test_magic_folder.py b/src/allmydata/test/test_magic_folder.py index 3c848e80..bfd29362 100644 --- a/src/allmydata/test/test_magic_folder.py +++ b/src/allmydata/test/test_magic_folder.py @@ -74,7 +74,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual db = self._createdb() path = abspath_expanduser_unicode(u"myFile1", base=self.basedir) - db.did_upload_file('URI:LIT:1', path, 0, 0, 33) + db.did_upload_file('URI:LIT:1', path, 1, 0, 0, 33) c = db.cursor c.execute("SELECT size,mtime,ctime,fileid" @@ -92,7 +92,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual size = s[stat.ST_SIZE] ctime = s[stat.ST_CTIME] mtime = s[stat.ST_MTIME] - db.did_upload_file('URI:LIT:2', path, mtime, ctime, size) + db.did_upload_file('URI:LIT:2', path, 1, mtime, ctime, size) r = db.check_file(path) self.failUnless(r.was_uploaded()) @@ -207,9 +207,10 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual self.client = self.g.clients[0] self.stats_provider = self.client.stats_provider + self.collective_dircap = "" + d = self.create_invite_join_magic_folder(u"Alice", self.local_dir) d.addCallback(self._create_magicfolder) - def create_test_file(result): d2 = defer.Deferred() self.magicfolder.set_processed_callback(d2.callback, ignore_count=0) @@ -220,20 +221,22 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual 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)) - - def _restart(ign): + + def restart(ignore): tahoe_config_file = os.path.join(self.get_clientdir(), "tahoe.cfg") tahoe_config = fileutil.read(tahoe_config_file) + d3 = defer.succeed(None) 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) + def setup_stats(result): + self.set_up_grid(client_config_hooks={0: write_config}) + self.client = self.g.clients[0] + self.stats_provider = self.client.stats_provider + d3.addBoth(self.cleanup) + d3.addCallback(setup_stats) + d3.addCallback(self._create_magicfolder) + return d3 + d.addCallback(restart) 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) @@ -250,6 +253,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual d = self.client.create_dirnode() d.addCallback(self._made_upload_dir) + self.collective_dircap = "" d.addCallback(self._create_magicfolder) # Write something short enough for a LIT file.