From: David Stainton Date: Mon, 29 Jun 2015 23:23:18 +0000 (-0700) Subject: Add cleanup to Alice+Bob test + bug fix X-Git-Url: https://git.rkrishnan.org/%5B/frontends/flags/%22file:/%22news.html/?a=commitdiff_plain;h=7ebb240fd939146eaa3a653d999b0d9d6552b439;p=tahoe-lafs%2Ftahoe-lafs.git Add cleanup to Alice+Bob test + bug fix bug fix == don't clobber the alice bob magicfolder instances --- diff --git a/src/allmydata/frontends/magic_folder.py b/src/allmydata/frontends/magic_folder.py index 4827b245..8131cad7 100644 --- a/src/allmydata/frontends/magic_folder.py +++ b/src/allmydata/frontends/magic_folder.py @@ -304,5 +304,5 @@ class MagicFolder(service.MultiService): def _log(self, msg): self._client.log("drop-upload: " + msg) - print "_log %s" % (msg,) + #print "_log %s" % (msg,) #open("events", "ab+").write(msg) diff --git a/src/allmydata/test/test_cli_magic_folder.py b/src/allmydata/test/test_cli_magic_folder.py index 12e5bde9..407a048c 100644 --- a/src/allmydata/test/test_cli_magic_folder.py +++ b/src/allmydata/test/test_cli_magic_folder.py @@ -111,10 +111,11 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): def init_magicfolder(self, client_num, upload_dircap, collective_dircap, local_magic_dir): dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.get_clientdir(i=client_num)) - self.magicfolder = MagicFolder(self.get_client(client_num), upload_dircap, collective_dircap, local_magic_dir, + magicfolder = MagicFolder(self.get_client(client_num), upload_dircap, collective_dircap, local_magic_dir, dbfile, inotify=self.inotify, pending_delay=0.2) - self.magicfolder.setServiceParent(self.get_client(client_num)) - self.magicfolder.upload_ready() + magicfolder.setServiceParent(self.get_client(client_num)) + magicfolder.upload_ready() + return magicfolder def setup_alice_and_bob(self): self.set_up_grid(num_clients=2) @@ -126,7 +127,6 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): self.mkdir_nonascii(bob_dir) bob_magic_dir = abspath_expanduser_unicode(u"Bob-magic", base=self.basedir) self.mkdir_nonascii(bob_magic_dir) - d = self.create_magic_folder(0) d.addCallback(lambda x: self.invite_n(0, x)) d.addCallback(lambda x: self.join(0, alice_magic_dir, x)) @@ -135,8 +135,10 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): d.addCallback(get_alice_caps) d.addCallback(lambda x: self.check_joined_config(0, alice_upload_dircap)) d.addCallback(lambda x: self.check_config(0, alice_magic_dir)) - d.addCallback(lambda x: self.init_magicfolder(0, alice_upload_dircap, alice_collective_dircap, alice_magic_dir)) - + def get_Alice_magicfolder(result): + self.alice_magicfolder = self.init_magicfolder(0, alice_upload_dircap, alice_collective_dircap, alice_magic_dir) + return result + d.addCallback(get_Alice_magicfolder) d.addCallback(lambda x: self.invite_n(0, u"Bob")) d.addCallback(lambda x: self.join(1, bob_magic_dir, x)) def get_bob_caps(x): @@ -144,8 +146,18 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin): d.addCallback(get_bob_caps) d.addCallback(lambda x: self.check_joined_config(1, bob_upload_dircap)) d.addCallback(lambda x: self.check_config(1, bob_magic_dir)) - d.addCallback(lambda x: self.init_magicfolder(1, bob_upload_dircap, bob_collective_dircap, bob_magic_dir)) - + def get_Bob_magicfolder(result): + self.bob_magicfolder = self.init_magicfolder(1, bob_upload_dircap, bob_collective_dircap, bob_magic_dir) + return result + d.addCallback(get_Bob_magicfolder) + + def cleanup_Alice_and_Bob(result): + d = defer.succeed(None) + d.addCallback(lambda ign: self.alice_magicfolder.finish(for_tests=True)) + d.addCallback(lambda ign: self.bob_magicfolder.finish(for_tests=True)) + d.addCallback(lambda ign: result) + return d + d.addCallback(cleanup_Alice_and_Bob) return d class CreateMagicFolder(MagicFolderCLITestMixin, unittest.TestCase):