From: Daira Hopwood Date: Mon, 18 May 2015 15:54:08 +0000 (+0100) Subject: debugging X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/frontends/running.html?a=commitdiff_plain;h=9b805127682933b84117a922b95d7a4b33697abb;p=tahoe-lafs%2Ftahoe-lafs.git debugging Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/frontends/drop_upload.py b/src/allmydata/frontends/drop_upload.py index 38f51ba2..4dc59798 100644 --- a/src/allmydata/frontends/drop_upload.py +++ b/src/allmydata/frontends/drop_upload.py @@ -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) diff --git a/src/allmydata/test/test_drop_upload.py b/src/allmydata/test/test_drop_upload.py index cf84e6e1..8cfddb1e 100644 --- a/src/allmydata/test/test_drop_upload.py +++ b/src/allmydata/test/test_drop_upload.py @@ -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))