test_system: add deep-stats test
authorBrian Warner <warner@lothar.com>
Wed, 10 Sep 2008 05:56:34 +0000 (22:56 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 10 Sep 2008 05:56:34 +0000 (22:56 -0700)
src/allmydata/test/test_system.py

index 1a62d0a9c171c368702d4f5bba2728c415165c8e..83c12c93eeb7996232a1847404567248f814c497 100644 (file)
@@ -2084,10 +2084,35 @@ class DeepCheck(SystemTestMixin, unittest.TestCase):
         self.basedir = self.mktemp()
         d = self.set_up_nodes()
         d.addCallback(self.set_up_tree)
+        d.addCallback(self.do_stats)
         d.addCallback(self.do_test_good)
         d.addCallback(self.do_test_web)
         return d
 
+    def do_stats(self, ignored):
+        d = defer.succeed(None)
+        d.addCallback(lambda ign: self.root.deep_stats())
+        d.addCallback(self.check_stats)
+        return d
+
+    def check_stats(self, s):
+        self.failUnlessEqual(s["count-directories"], 1)
+        self.failUnlessEqual(s["count-files"], 3)
+        self.failUnlessEqual(s["count-immutable-files"], 1)
+        self.failUnlessEqual(s["count-literal-files"], 1)
+        self.failUnlessEqual(s["count-mutable-files"], 1)
+        # don't check directories: their size will vary
+        # s["largest-directory"]
+        # s["size-directories"]
+        self.failUnlessEqual(s["largest-directory-children"], 4)
+        self.failUnlessEqual(s["largest-immutable-file"], 13000)
+        self.failUnlessEqual(s["size-files-histogram"],
+                             [(11, 31, 1),
+                              (10001, 31622, 1),
+                              ])
+        self.failUnlessEqual(s["size-immutable-files"], 13000)
+        self.failUnlessEqual(s["size-literal-files"], 22)
+
     def do_test_good(self, ignored):
         d = defer.succeed(None)
         # check the individual items