From: Zooko O'Whielacronx Date: Wed, 30 Jul 2008 23:54:20 +0000 (-0700) Subject: tests: test that checker doesn't cause reads on the storage servers X-Git-Url: https://git.rkrishnan.org/vdrive/%22file:/running.html?a=commitdiff_plain;h=86160c3fc9c1dc27e7f2d00d536109a09d709586;p=tahoe-lafs%2Ftahoe-lafs.git tests: test that checker doesn't cause reads on the storage servers It would still pass the test if it noticed a corrupted share. (It won't notice, of course.) But it is required to do its work without causing storage servers to read blocks from the filesystem. --- diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 17e5bf8c..70620333 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -1800,6 +1800,13 @@ class Checker(SystemTestMixin, unittest.TestCase): return d + def _count_reads(self): + sum_of_read_counts = 0 + for client in self.clients: + counters = client.stats_provider.get_stats()['counters'] + sum_of_read_counts += counters.get('storage_server.read', 0) + return sum_of_read_counts + def test_check_without_verify(self): """ Check says the file is healthy when none of the shares have been touched. It says that the file is unhealthy when all of them have @@ -1807,23 +1814,43 @@ class Checker(SystemTestMixin, unittest.TestCase): has been flipped.""" d = defer.succeed(self.filenode) def _check1(filenode): + before_check_reads = self._count_reads() + d2 = filenode.check(verify=False, repair=False) - d2.addCallback(lambda checkres: self.failUnless(checkres.is_healthy())) + def _after_check(checkresults): + after_check_reads = self._count_reads() + self.failIf(after_check_reads - before_check_reads > 0, after_check_reads - before_check_reads) + self.failUnless(checkresults.is_healthy()) + + d2.addCallback(_after_check) return d2 d.addCallback(_check1) d.addCallback(self._corrupt_a_share) def _check2(ignored): + before_check_reads = self._count_reads() d2 = self.filenode.check(verify=False, repair=False) - d2.addCallback(lambda checkres: self.failUnless(checkres.is_healthy())) + + def _after_check(checkresults): + after_check_reads = self._count_reads() + self.failIf(after_check_reads - before_check_reads > 0, after_check_reads - before_check_reads) + + d2.addCallback(_after_check) return d2 d.addCallback(_check2) return d d.addCallback(lambda ignore: self._replace_shares({})) def _check3(ignored): + before_check_reads = self._count_reads() d2 = self.filenode.check(verify=False, repair=False) - d2.addCallback(lambda checkres: self.failIf(checkres.is_healthy())) + + def _after_check(checkresults): + after_check_reads = self._count_reads() + self.failIf(after_check_reads - before_check_reads > 0, after_check_reads - before_check_reads) + self.failIf(checkresults.is_healthy()) + + d2.addCallback(_after_check) return d2 d.addCallback(_check3)