]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
WIP
authorDavid Stainton <dstainton415@gmail.com>
Fri, 11 Sep 2015 19:40:15 +0000 (21:40 +0200)
committerDaira Hopwood <daira@jacaranda.org>
Tue, 15 Sep 2015 17:43:00 +0000 (18:43 +0100)
src/allmydata/frontends/magic_folder.py
src/allmydata/test/no_network.py
src/allmydata/test/test_cli_magic_folder.py
src/allmydata/test/test_magic_folder.py

index dedb29eff68622032b306cdd0207a7b8c67ef499..7d114e21966856f7b10a335a7ca988b1414f7950 100644 (file)
@@ -50,6 +50,7 @@ class MagicFolder(service.MultiService):
 
         service.MultiService.__init__(self)
 
+        print "MagicFolder __init__"
         db = backupdb.get_backupdb(dbfile, create_version=(backupdb.SCHEMA_v3, 3))
         if db is None:
             return Failure(Exception('ERROR: Unable to load magic folder db.'))
@@ -154,6 +155,7 @@ class Uploader(QueueMixin):
     def __init__(self, client, local_path_u, db, upload_dircap, inotify, pending_delay):
         QueueMixin.__init__(self, client, local_path_u, db, 'uploader')
 
+        print "Magic-Folder: Uploader: __init__"
         self.is_ready = False
 
         # TODO: allow a path rather than a cap URI.
@@ -393,6 +395,7 @@ class Downloader(QueueMixin):
     def __init__(self, client, local_path_u, db, collective_dircap):
         QueueMixin.__init__(self, client, local_path_u, db, 'downloader')
 
+        print "Magic-Folder: Downloader: __init__"
         # TODO: allow a path rather than a cap URI.
         self._collective_dirnode = self._client.create_node_from_uri(collective_dircap)
 
index 4e6249e5edc70c5c4d6c31b953abfcee4e79d4f0..e3b4ef884bfca021f02da25d255151d89706ddd0 100644 (file)
@@ -380,14 +380,19 @@ class GridTestMixin:
     def get_clientdir(self, i=0):
         return self.g.clients[i].basedir
 
+    def set_clientdir(self, basedir, i=0):
+        self.g.clients[i].basedir = basedir
+
     def get_client(self, i=0):
         return self.g.clients[i]
 
     def restart_client(self, i=0):
         client = self.g.clients[i]
+        #client_basedir = self.get_clientdir()
         d = defer.succeed(None)
         d.addCallback(lambda ign: self.g.removeService(client))
         def _make_client(ign):
+            #self.set_clientdir(client_basedir, i)
             c = self.g.make_client(i, write_config=False)
             self.g.clients[i] = c
             self._record_webports_and_baseurls()
index 9d3880e665f4a8f03efc7a4543813dedfdacf1e2..412995bc7c816b95806970d39b7ab736f277f4ce 100644 (file)
@@ -108,6 +108,16 @@ class MagicFolderCLITestMixin(CLITestMixin, GridTestMixin):
         magicfolder.ready()
         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)
+
+        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()
+
+
     def setup_alice_and_bob(self):
         self.set_up_grid(num_clients=2)
 
index 5ce83fba19ab88da0569566d4f00a72e10b9ad41..265d2c3d44c129e0d9ee263eb84ad0882be85c71 100644 (file)
@@ -55,14 +55,14 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
         return self.magicfolder.ready()
 
     def _create_magicfolder(self, ign):
+        print "_create_magicfolder self.basedir %s" % (self.basedir,)
         dbfile = abspath_expanduser_unicode(u"magicfolderdb.sqlite", base=self.basedir)
+        print "<>--< dbfile %s" % (dbfile,)
         self.magicfolder = MagicFolder(self.get_client(), self.upload_dircap, self.collective_dircap, self.local_dir,
                                        dbfile, inotify=self.inotify, pending_delay=0.2)
         self.magicfolder.setServiceParent(self.get_client())
         self.magicfolder.ready()
 
-    # Prevent unclean reactor errors.
-
     def test_db_basic(self):
         fileutil.make_dirs(self.basedir)
         self._createdb()
@@ -195,14 +195,21 @@ 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 = ""
 
-        d = self.create_invite_join_magic_folder(u"Alice", self.local_dir)
-        d.addCallback(self._create_magicfolder)
-
+        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)
+        
         def create_test_file(result, filename):
             d2 = self.magicfolder.uploader.set_hook('processed')
             test_file = abspath_expanduser_unicode(filename, base=self.local_dir)
@@ -224,7 +231,7 @@ class MagicFolderTestMixin(MagicFolderCLITestMixin, ShouldFailMixin, ReallyEqual
             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