From 359889cdda9aeaf91bc293b9dd33349329710084 Mon Sep 17 00:00:00 2001 From: Daira Hopwood Date: Mon, 20 Apr 2015 17:56:34 +0100 Subject: [PATCH] Try to fix potential race conditions in testMoveEmptyTree. Signed-off-by: Daira Hopwood --- src/allmydata/test/test_drop_upload.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index b324f6fd..3072e1b0 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -4,7 +4,8 @@ import shutil import time from twisted.trial import unittest -from twisted.python import filepath, runtime +from twisted.python import runtime +from twisted.python.filepath import FilePath from twisted.internet import defer from allmydata.interfaces import IDirectoryNode, NoSuchChildError @@ -89,11 +90,15 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA def testMoveEmptyTree(res): print "moving tree into %s" % self.local_dir tree_dir = os.path.join(self.basedir, 'apple_tree') + tree_dir_fp = FilePath(tree_dir) + d2 = defer.Deferred() + self.uploader.set_uploaded_callback(d2.callback, ignore_count=0) + os.mkdir(tree_dir) + self.notify_close_write(tree_dir_fp) os.rename(tree_dir, os.path.join(self.local_dir, 'apple_tree')) - d = defer.Deferred() - self.uploader.set_uploaded_callback(d.callback) - return d + self.notify_close_write(tree_dir_fp) + return d2 d.addCallback(testMoveEmptyTree) 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.files_uploaded'), 0)) @@ -199,9 +204,9 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA path_u = os.path.join(self.local_dir, name_u) if sys.platform == "win32": - path = filepath.FilePath(path_u) + path = FilePath(path_u) else: - path = filepath.FilePath(path_u.encode(get_filesystem_encoding())) + path = FilePath(path_u.encode(get_filesystem_encoding())) # We don't use FilePath.setContent() here because it creates a temporary file that # is renamed into place, which causes events that the test is not expecting. -- 2.45.2