]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
debugging
authorDaira Hopwood <daira@jacaranda.org>
Mon, 18 May 2015 15:54:08 +0000 (16:54 +0100)
committerDaira Hopwood <daira@jacaranda.org>
Fri, 29 May 2015 20:42:58 +0000 (21:42 +0100)
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index 38f51ba23336e3f50dd2b7fc1cc5073b8b993f78..4dc59798f05701eef08f06cf023432732750c9d2 100644 (file)
@@ -175,7 +175,12 @@ class DropUploader(service.MultiService):
         if path_u not in self._pending:
             self._append_to_deque(path_u)
 
+    def _print(self, res, msg):
+        print msg
+        return res
+
     def _process(self, path):
+        print "herez1"
         d = defer.succeed(None)
 
         # FIXME (ticket #1712): if this already exists as a mutable file, we replace the
@@ -236,10 +241,12 @@ class DropUploader(service.MultiService):
         d.addCallback(_maybe_upload)
 
         def _succeeded(ign):
+            d.addCallback(self._print, "herez2")
             self._stats_provider.count('drop_upload.objects_queued', -1)
             self._stats_provider.count('drop_upload.objects_uploaded', 1)
 
         def _failed(f):
+            d.addCallback(self._print, "herez3")
             self._stats_provider.count('drop_upload.objects_queued', -1)
             if os.path.exists(path):
                 self._log("drop-upload: %r failed to upload due to %r" % (path, f))
@@ -251,10 +258,12 @@ class DropUploader(service.MultiService):
                 return None
 
         d.addCallbacks(_succeeded, _failed)
+        d.addCallback(self._print, "herez4")
         d.addBoth(self._do_upload_callback)
         return d
 
     def _do_upload_callback(self, res):
+        print "herey"
         if self._ignore_count == 0:
             self._uploaded_callback(res)
         else:
@@ -264,6 +273,7 @@ class DropUploader(service.MultiService):
         """
         This sets a function that will be called after a file has been uploaded.
         """
+        print "herex", ignore_count
         self._uploaded_callback = callback
         self._ignore_count = ignore_count
 
@@ -279,5 +289,6 @@ class DropUploader(service.MultiService):
         return service.MultiService.disownServiceParent(self)
 
     def _log(self, msg):
+        print msg
         self._client.log(msg)
         #open("events", "ab+").write(msg)
index cf84e6e143e74de3878712878ff1b863cd25124c..8cfddb1e33afc4b4b02e9985eabd245284d5f208 100644 (file)
@@ -228,6 +228,7 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
     def test_drop_upload(self):
         self.set_up_grid()
         self.local_dir = os.path.join(self.basedir, self.unicode_or_fallback(u"loc\u0101l_dir", u"local_dir"))
+        print "local_dir = %r" % (self.local_dir,)
         self.mkdir_nonascii(self.local_dir)
 
         self.client = self.g.clients[0]
@@ -238,25 +239,35 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         d.addCallback(self._made_upload_dir)
         d.addCallback(self._create_uploader)
 
+        def _print(res, msg):
+            print msg
+            return res
         # Write something short enough for a LIT file.
+        d.addCallback(_print, "here1")
         d.addCallback(lambda ign: self._check_file(u"short", "test"))
 
         # Write to the same file again with different data.
+        d.addCallback(_print, "here2")
         d.addCallback(lambda ign: self._check_file(u"short", "different"))
 
         # Test that temporary files are not uploaded.
+        d.addCallback(_print, "here3")
         d.addCallback(lambda ign: self._check_file(u"tempfile", "test", temporary=True))
 
         # Test that we tolerate creation of a subdirectory.
+        d.addCallback(_print, "here4")
         d.addCallback(lambda ign: os.mkdir(os.path.join(self.local_dir, u"directory")))
 
         # Write something longer, and also try to test a Unicode name if the fs can represent it.
         name_u = self.unicode_or_fallback(u"l\u00F8ng", u"long")
+        d.addCallback(_print, "here5")
         d.addCallback(lambda ign: self._check_file(name_u, "test"*100))
 
         # TODO: test that causes an upload failure.
+        d.addCallback(_print, "here6")
         d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_failed'), 0))
 
+        d.addCallback(_print, "here7")
         d.addBoth(self._cleanup)
         return d
 
@@ -287,15 +298,23 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
         fileutil.flush_volume(path_u)
         self.notify_close_write(path)
 
+        def _print(res, msg):
+            print msg
+            return res
         if temporary:
+            d.addCallback(_print, "here8")
             d.addCallback(lambda ign: self.shouldFail(NoSuchChildError, 'temp file not uploaded', None,
                                                       self.upload_dirnode.get, name_u))
             d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_disappeared'),
                                                                  previously_disappeared + 1))
         else:
+            d.addCallback(_print, "here9")
             d.addCallback(lambda ign: self.upload_dirnode.get(name_u))
+            d.addCallback(_print, "here10")
             d.addCallback(download_to_data)
+            d.addCallback(_print, "here11")
             d.addCallback(lambda actual_data: self.failUnlessReallyEqual(actual_data, data))
+            d.addCallback(_print, "here12")
             d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'),
                                                                  previously_uploaded + 1))