]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Add further refinements to move tree uploader test
authorDavid Stainton <dstainton415@gmail.com>
Sat, 18 Apr 2015 03:25:49 +0000 (04:25 +0100)
committerDavid Stainton <dstainton415@gmail.com>
Sat, 18 Apr 2015 03:25:49 +0000 (04:25 +0100)
- test empty tree and small tree test cases using various stats counters

src/allmydata/frontends/drop_upload.py
src/allmydata/test/test_drop_upload.py

index 07f109f920e0f0bfc0987a54027904fa3b009209..5e6cba468c57953f8dcf6855f71e5bd7f8d5b819 100644 (file)
@@ -183,9 +183,11 @@ class DropUploader(service.MultiService):
 
             if os.path.isdir(path.path):
                 d.addCallback(_add_dir)
+                self._stats_provider.count('drop_upload.directories_created', 1)
                 return None
             elif os.path.isfile(path.path):
                 d.addCallback(_add_file)
+                self._stats_provider.count('drop_upload.files_uploaded', 1)
                 return None
             else:
                 self._log("operator ERROR: non-directory/non-regular file not being processed.")
index d33ba97e033eda60cf69e2ac6d35e8c416206bb8..700ecec01a376fb9aabbbe72bf83864363072f47 100644 (file)
@@ -89,6 +89,27 @@ class DropUploadTestMixin(GridTestMixin, ShouldFailMixin, ReallyEqualMixin, NonA
 
         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))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.directories_created'), 1))
+
+        def testMoveSmallTree(res):
+            tree_dir = os.path.join(self.basedir, 'creepy_tree')
+            os.mkdir(tree_dir)
+            os.path.join(tree_dir, u"tree_frog")
+            f = open(path.path, "wb")
+            f.write("meow")
+            f.close()
+            shutil.move(tree_dir, self.local_dir)
+            d = defer.Deferred()
+            self.uploader.set_uploaded_callback(d.callback)
+            return d
+        d.addCallback(testMoveSmallTree)
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_uploaded'), 2))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.files_uploaded'), 1))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.objects_queued'), 0))
+        d.addCallback(lambda ign: self.failUnlessReallyEqual(self._get_count('drop_upload.directories_created'), 1))
+
         d.addBoth(self._cleanup)
         return d