]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
tests: test that checker doesn't cause reads on the storage servers
authorZooko O'Whielacronx <zooko@zooko.com>
Wed, 30 Jul 2008 23:54:20 +0000 (16:54 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Wed, 30 Jul 2008 23:54:20 +0000 (16:54 -0700)
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.

src/allmydata/test/test_system.py

index 17e5bf8cd7c12283b4bf0ecd3d008849fe6d8943..7062033369cae67533e900ebf2be3185a8615007 100644 (file)
@@ -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)