From: Brian Warner Date: Wed, 10 Sep 2008 06:14:16 +0000 (-0700) Subject: test_system: add deep-check-JSON tests, fix a bug X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/install.html?a=commitdiff_plain;h=12ff8a6eaedeb6385313b6cf92f44f233fe032b5;p=tahoe-lafs%2Ftahoe-lafs.git test_system: add deep-check-JSON tests, fix a bug --- diff --git a/src/allmydata/checker_results.py b/src/allmydata/checker_results.py index 59297ba4..f25a39b1 100644 --- a/src/allmydata/checker_results.py +++ b/src/allmydata/checker_results.py @@ -84,7 +84,7 @@ class DeepResultsBase: if root_storage_index is None: self.root_storage_index_s = "" 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 diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index c430a699..d8871a6d 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -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