mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 21:43:09 +00:00
Fix magic-folder Persistence test
here we teach this test to create invite join a magic-folder using the CLI... and then we go on to fix various bugs.
This commit is contained in:
parent
a2ed2965e3
commit
6046abbb39
@ -499,6 +499,9 @@ class Client(node.Node, pollmixin.PollMixin):
|
|||||||
|
|
||||||
if self.get_config("magic_folder", "enabled", False, boolean=True):
|
if self.get_config("magic_folder", "enabled", False, boolean=True):
|
||||||
upload_dircap = self.get_or_create_private_config("magic_folder_dircap")
|
upload_dircap = self.get_or_create_private_config("magic_folder_dircap")
|
||||||
|
upload_dircap is not None
|
||||||
|
# XXX correcto?
|
||||||
|
#local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
|
||||||
local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
|
local_dir_config = self.get_config("magic_folder", "local.directory").decode("utf-8")
|
||||||
local_dir = abspath_expanduser_unicode(local_dir_config, base=self.basedir)
|
local_dir = abspath_expanduser_unicode(local_dir_config, base=self.basedir)
|
||||||
|
|
||||||
@ -510,6 +513,7 @@ class Client(node.Node, pollmixin.PollMixin):
|
|||||||
collective_dircap_path = os.path.join(self.basedir, "private", "collective_dircap")
|
collective_dircap_path = os.path.join(self.basedir, "private", "collective_dircap")
|
||||||
collective_dircap_path = abspath_expanduser_unicode(collective_dircap_path)
|
collective_dircap_path = abspath_expanduser_unicode(collective_dircap_path)
|
||||||
collective_dircap = fileutil.read(collective_dircap_path).strip()
|
collective_dircap = fileutil.read(collective_dircap_path).strip()
|
||||||
|
assert collective_dircap is not None
|
||||||
|
|
||||||
s = magic_folder.MagicFolder(self, upload_dircap, collective_dircap, local_dir, dbfile)
|
s = magic_folder.MagicFolder(self, upload_dircap, collective_dircap, local_dir, dbfile)
|
||||||
s.setServiceParent(self)
|
s.setServiceParent(self)
|
||||||
|
@ -105,7 +105,7 @@ class MagicFolder(service.MultiService):
|
|||||||
r = self._db.check_file(childpath)
|
r = self._db.check_file(childpath)
|
||||||
filecap = r.was_uploaded()
|
filecap = r.was_uploaded()
|
||||||
if filecap is False:
|
if filecap is False:
|
||||||
return True
|
return False
|
||||||
|
|
||||||
def _scan(self, localpath):
|
def _scan(self, localpath):
|
||||||
if not os.path.isdir(localpath):
|
if not os.path.isdir(localpath):
|
||||||
@ -136,7 +136,7 @@ class MagicFolder(service.MultiService):
|
|||||||
self._scan(childpath)
|
self._scan(childpath)
|
||||||
elif isfile:
|
elif isfile:
|
||||||
is_uploaded = self._db_file_is_uploaded(childpath)
|
is_uploaded = self._db_file_is_uploaded(childpath)
|
||||||
if not is_uploaded:
|
if not is_uploaded:
|
||||||
self._append_to_deque(childpath)
|
self._append_to_deque(childpath)
|
||||||
else:
|
else:
|
||||||
self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
|
self.warn("WARNING: cannot backup special file %s" % quote_local_unicode_path(childpath))
|
||||||
@ -192,7 +192,6 @@ class MagicFolder(service.MultiService):
|
|||||||
return self._upload_dirnode.add_file(name, u, overwrite=True)
|
return self._upload_dirnode.add_file(name, u, overwrite=True)
|
||||||
|
|
||||||
def _add_dir(name):
|
def _add_dir(name):
|
||||||
print "MEOWMEOW!"
|
|
||||||
self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True)
|
self._notifier.watch(to_filepath(path), mask=self.mask, callbacks=[self._notify], recursive=True)
|
||||||
u = Data("", self._convergence)
|
u = Data("", self._convergence)
|
||||||
name += "@_"
|
name += "@_"
|
||||||
|
@ -76,8 +76,7 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
|
|||||||
|
|
||||||
def _check_config(self, result):
|
def _check_config(self, result):
|
||||||
client_config = fileutil.read(os.path.join(self.get_clientdir(), "tahoe.cfg"))
|
client_config = fileutil.read(os.path.join(self.get_clientdir(), "tahoe.cfg"))
|
||||||
print "CLIENT CONFIG", client_config
|
# XXX utf-8?
|
||||||
# XXX utf-8
|
|
||||||
ret = re.search("\[magic_folder\]\nenabled = True\nlocal.directory = %s" % (self.local_dir.encode('utf-8'),), client_config)
|
ret = re.search("\[magic_folder\]\nenabled = True\nlocal.directory = %s" % (self.local_dir.encode('utf-8'),), client_config)
|
||||||
self.failIf(ret is None)
|
self.failIf(ret is None)
|
||||||
return result
|
return result
|
||||||
@ -191,7 +190,6 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
|
|||||||
d.addCallback(self._create_magicfolder)
|
d.addCallback(self._create_magicfolder)
|
||||||
|
|
||||||
def _check_move_empty_tree(res):
|
def _check_move_empty_tree(res):
|
||||||
print "MEOW 0"
|
|
||||||
self.mkdir_nonascii(empty_tree_dir)
|
self.mkdir_nonascii(empty_tree_dir)
|
||||||
d2 = defer.Deferred()
|
d2 = defer.Deferred()
|
||||||
self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
|
self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
|
||||||
@ -205,14 +203,12 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
|
|||||||
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 1))
|
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 1))
|
||||||
|
|
||||||
def _check_move_small_tree(res):
|
def _check_move_small_tree(res):
|
||||||
print "MEOW 1"
|
|
||||||
self.mkdir_nonascii(small_tree_dir)
|
self.mkdir_nonascii(small_tree_dir)
|
||||||
fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when")
|
fileutil.write(abspath_expanduser_unicode(u"what", base=small_tree_dir), "say when")
|
||||||
d2 = defer.Deferred()
|
d2 = defer.Deferred()
|
||||||
self.magicfolder.set_processed_callback(d2.callback, ignore_count=1)
|
self.magicfolder.set_processed_callback(d2.callback, ignore_count=1)
|
||||||
os.rename(small_tree_dir, new_small_tree_dir)
|
os.rename(small_tree_dir, new_small_tree_dir)
|
||||||
self.notify(to_filepath(new_small_tree_dir), self.inotify.IN_MOVED_TO)
|
self.notify(to_filepath(new_small_tree_dir), self.inotify.IN_MOVED_TO)
|
||||||
print "end of MEOW 1"
|
|
||||||
return d2
|
return d2
|
||||||
d.addCallback(_check_move_small_tree)
|
d.addCallback(_check_move_small_tree)
|
||||||
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3))
|
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_succeeded'), 3))
|
||||||
@ -221,7 +217,6 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
|
|||||||
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 2))
|
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.directories_created'), 2))
|
||||||
|
|
||||||
def _check_moved_tree_is_watched(res):
|
def _check_moved_tree_is_watched(res):
|
||||||
print "MEOW 2"
|
|
||||||
d2 = defer.Deferred()
|
d2 = defer.Deferred()
|
||||||
self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
|
self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
|
||||||
fileutil.write(abspath_expanduser_unicode(u"another", base=new_small_tree_dir), "file")
|
fileutil.write(abspath_expanduser_unicode(u"another", base=new_small_tree_dir), "file")
|
||||||
@ -266,29 +261,33 @@ class MagicFolderTestMixin(CLITestMixin, GridTestMixin, ShouldFailMixin, ReallyE
|
|||||||
|
|
||||||
self.client = self.g.clients[0]
|
self.client = self.g.clients[0]
|
||||||
self.stats_provider = self.client.stats_provider
|
self.stats_provider = self.client.stats_provider
|
||||||
d = self.client.create_dirnode()
|
d = self._create_invite_join_magic_folder()
|
||||||
d.addCallback(self._made_upload_dir)
|
|
||||||
d.addCallback(self._create_magicfolder)
|
d.addCallback(self._create_magicfolder)
|
||||||
|
|
||||||
def create_file(val):
|
def create_test_file(result):
|
||||||
d2 = defer.Deferred()
|
d2 = defer.Deferred()
|
||||||
self.magicfolder.set_processed_callback(d2.callback)
|
self.magicfolder.set_processed_callback(d2.callback, ignore_count=0)
|
||||||
test_file = abspath_expanduser_unicode(u"what", base=self.local_dir)
|
test_file = abspath_expanduser_unicode(u"what", base=self.local_dir)
|
||||||
fileutil.write(test_file, "meow")
|
fileutil.write(test_file, "meow")
|
||||||
self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
|
self.notify(to_filepath(test_file), self.inotify.IN_CLOSE_WRITE)
|
||||||
return d2
|
return d2
|
||||||
d.addCallback(create_file)
|
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_succeeded'), 1))
|
||||||
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
|
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
|
||||||
d.addCallback(self._cleanup)
|
|
||||||
|
|
||||||
def _restart(ign):
|
def _restart(ign):
|
||||||
self.set_up_grid()
|
tahoe_config_file = os.path.join(self.get_clientdir(), "tahoe.cfg")
|
||||||
|
tahoe_config = fileutil.read(tahoe_config_file)
|
||||||
|
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.client = self.g.clients[0]
|
||||||
self.stats_provider = self.client.stats_provider
|
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)
|
d.addCallback(_restart)
|
||||||
d.addCallback(self._create_magicfolder)
|
|
||||||
d.addCallback(lambda ign: time.sleep(3))
|
|
||||||
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_succeeded'), 0))
|
||||||
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
|
d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('magic_folder.objects_queued'), 0))
|
||||||
d.addBoth(self._cleanup)
|
d.addBoth(self._cleanup)
|
||||||
|
Loading…
Reference in New Issue
Block a user