test_system: add deep-check-JSON tests, fix a bug
authorBrian Warner <warner@lothar.com>
Wed, 10 Sep 2008 06:14:16 +0000 (23:14 -0700)
committerBrian Warner <warner@lothar.com>
Wed, 10 Sep 2008 06:14:16 +0000 (23:14 -0700)
src/allmydata/checker_results.py
src/allmydata/test/test_system.py

index 59297ba47073c84d23aeeee3e3926ae0b8423508..f25a39b182692234433699381d868d191751ed72 100644 (file)
@@ -84,7 +84,7 @@ class DeepResultsBase:
         if root_storage_index is None:
             self.root_storage_index_s = "<none>"
         else:
-            self.root_storage_index_s = base32.b2a(root_storage_index)[:6]
+            self.root_storage_index_s = base32.b2a(root_storage_index)
 
         self.objects_checked = 0
         self.objects_healthy = 0
index c430a699f973726c0623d43b147e17684503da40..d8871a6db9b237a94883b6d876f790bf1eaa6ada 100644 (file)
@@ -2255,6 +2255,38 @@ class DeepCheck(SystemTestMixin, unittest.TestCase):
         self.json_check_is_healthy(data["post-repair-results"],
                                    n, where, incomplete)
 
+    def json_full_deepcheck_is_healthy(self, data, n, where):
+        self.failUnlessEqual(data["root-storage-index"],
+                             base32.b2a(n.get_storage_index()), where)
+        self.failUnlessEqual(data["count-objects-checked"], 3, where)
+        self.failUnlessEqual(data["count-objects-healthy"], 3, where)
+        self.failUnlessEqual(data["count-objects-unhealthy"], 0, where)
+        self.failUnlessEqual(data["count-corrupt-shares"], 0, where)
+        self.failUnlessEqual(data["list-corrupt-shares"], [], where)
+        self.failUnlessEqual(data["list-unhealthy-files"], [], where)
+
+    def json_full_deepcheck_and_repair_is_healthy(self, data, n, where):
+        self.failUnlessEqual(data["root-storage-index"],
+                             base32.b2a(n.get_storage_index()), where)
+        self.failUnlessEqual(data["count-objects-checked"], 3, where)
+
+        self.failUnlessEqual(data["count-objects-healthy-pre-repair"], 3, where)
+        self.failUnlessEqual(data["count-objects-unhealthy-pre-repair"], 0, where)
+        self.failUnlessEqual(data["count-corrupt-shares-pre-repair"], 0, where)
+
+        self.failUnlessEqual(data["count-objects-healthy-post-repair"], 3, where)
+        self.failUnlessEqual(data["count-objects-unhealthy-post-repair"], 0, where)
+        self.failUnlessEqual(data["count-corrupt-shares-post-repair"], 0, where)
+
+        self.failUnlessEqual(data["list-corrupt-shares"], [], where)
+        self.failUnlessEqual(data["list-remaining-corrupt-shares"], [], where)
+        self.failUnlessEqual(data["list-unhealthy-files"], [], where)
+
+        self.failUnlessEqual(data["count-repairs-attempted"], 0, where)
+        self.failUnlessEqual(data["count-repairs-successful"], 0, where)
+        self.failUnlessEqual(data["count-repairs-unsuccessful"], 0, where)
+
+
     def json_check_lit(self, data, n, where):
         self.failUnlessEqual(data["storage-index"], "", where)
         self.failUnlessEqual(data["results"]["healthy"], True, where)
@@ -2314,4 +2346,19 @@ class DeepCheck(SystemTestMixin, unittest.TestCase):
                       self.web_json(self.small, t="check", repair="true", verify="true"))
         d.addCallback(self.json_check_lit, self.small, "small")
 
+        # now run a deep-check. When done through the web, this can only be
+        # run on a directory.
+        d.addCallback(lambda ign:
+                      self.web_json(self.root, t="deep-check"))
+        d.addCallback(self.json_full_deepcheck_is_healthy, self.root, "root")
+        d.addCallback(lambda ign:
+                      self.web_json(self.root, t="deep-check", verify="true"))
+        d.addCallback(self.json_full_deepcheck_is_healthy, self.root, "root")
+        d.addCallback(lambda ign:
+                      self.web_json(self.root, t="deep-check", repair="true"))
+        d.addCallback(self.json_full_deepcheck_and_repair_is_healthy, self.root, "root")
+        d.addCallback(lambda ign:
+                      self.web_json(self.root, t="deep-check", verify="true", repair="true"))
+        d.addCallback(self.json_full_deepcheck_and_repair_is_healthy, self.root, "root")
+
         return d