From: Zooko O'Whielacronx Date: Thu, 25 Sep 2008 22:07:12 +0000 (-0700) Subject: repairer: add a test that repairer fixes corrupted shares (in addition to the test... X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/frontends/%22news.html/?a=commitdiff_plain;h=73f92ea571202bc57adc0ec518e9d75c528206bd;p=tahoe-lafs%2Ftahoe-lafs.git repairer: add a test that repairer fixes corrupted shares (in addition to the test that it fixes deleted shares) --- diff --git a/src/allmydata/test/test_immutable_checker.py b/src/allmydata/test/test_immutable_checker.py index 05382ded..1252ae8e 100644 --- a/src/allmydata/test/test_immutable_checker.py +++ b/src/allmydata/test/test_immutable_checker.py @@ -198,7 +198,7 @@ class Test(ShareManglingMixin, unittest.TestCase): d = defer.succeed(self.filenode) d.addCallback(self._delete_a_share) - def _repair(filenode): + def _repair_from_deletion(filenode): before_repair_reads = self._count_reads() before_repair_allocates = self._count_allocates() @@ -221,6 +221,34 @@ class Test(ShareManglingMixin, unittest.TestCase): d2.addCallback(_after_repair) return d2 - d.addCallback(_repair) + d.addCallback(_repair_from_deletion) + + d.addCallback(self._corrupt_a_share) + + def _repair_from_corruption(filenode): + before_repair_reads = self._count_reads() + before_repair_allocates = self._count_allocates() + + d2 = filenode.check_and_repair(verify=False) + def _after_repair(checkandrepairresults): + prerepairres = checkandrepairresults.get_pre_repair_results() + postrepairres = checkandrepairresults.get_post_repair_results() + after_repair_reads = self._count_reads() + after_repair_allocates = self._count_allocates() + + # print "delta was ", after_repair_reads - before_repair_reads, after_repair_allocates - before_repair_allocates + self.failIf(after_repair_reads - before_repair_reads > DELTA_READS) + self.failIf(after_repair_allocates - before_repair_allocates > DELTA_ALLOCATES) + self.failIf(prerepairres.is_healthy()) + self.failUnless(postrepairres.is_healthy()) + + # Now we inspect the filesystem to make sure that it is really there. + shares = self.find_shares() + self.failIf(len(shares) < 10) + + d2.addCallback(_after_repair) + return d2 + d.addCallback(_repair_from_corruption) + return d - test_repair.todo = "We haven't implemented a checker yet." + test_repair.todo = "We haven't implemented a repairer yet."