]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
immutable: tests: assert that verifier gives a clean bill of health after corruption...
authorZooko O'Whielacronx <zooko@zooko.com>
Tue, 10 Feb 2009 03:08:41 +0000 (20:08 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Tue, 10 Feb 2009 03:08:41 +0000 (20:08 -0700)
src/allmydata/test/common.py
src/allmydata/test/test_repairer.py

index 10f14b3b5652014bc485707429130d47b6754cb1..7c54b9386aef2d707e71ae43fe3444afe4ce5417 100644 (file)
@@ -984,7 +984,7 @@ class ShareManglingMixin(SystemTestMixin):
         ks = shares.keys()
         k = random.choice(ks)
         self._corrupt_a_share(unused, corruptor_func, k[1])
-        return corruptor_func
+        return k[1]
 
     def _count_reads(self):
         sum_of_read_counts = 0
index ed74e572ce53130799829bea3ffc39ace85b242a..e1a84d4d560b39c34aadbc000d12db712409652f 100644 (file)
@@ -60,7 +60,7 @@ class Verifier(common.ShareManglingMixin, unittest.TestCase):
             self.replace_shares(stash[0], storage_index=self.uri.storage_index)
             return ignored
 
-        def _verify_after_corruption(corruptor_func):
+        def _verify_after_corruption(shnum, corruptor_func):
             before_check_reads = self._count_reads()
             d2 = self.filenode.check(Monitor(), verify=True)
             def _after_check(checkresults):
@@ -77,7 +77,7 @@ class Verifier(common.ShareManglingMixin, unittest.TestCase):
 
         for corruptor_func in corruptor_funcs:
             d.addCallback(self._corrupt_a_random_share, corruptor_func)
-            d.addCallback(_verify_after_corruption)
+            d.addCallback(_verify_after_corruption, corruptor_func)
             d.addCallback(_put_it_all_back)
 
         return d
@@ -496,13 +496,21 @@ class Repairer(common.ShareManglingMixin, unittest.TestCase):
                 shares = self.find_shares()
                 self.failIf(len(shares) < 10)
 
+                # Now we assert that the verifier reports the file as healthy.
+                d3 = self.filenode.check(Monitor(), verify=True)
+                def _after_verify(verifyresults):
+                    self.failUnless(verifyresults.is_healthy())
+                d3.addCallback(_after_verify)
+
                 # Now we delete seven random shares, then try to download the
                 # file and assert that it succeeds at downloading and has the
                 # right contents.
-                for i in range(7):
-                    self._delete_a_share()
-
-                return self._download_and_check_plaintext()
+                def _then_delete_7_and_try_a_download(unused=None):
+                    for i in range(7):
+                        self._delete_a_share()
+                    return self._download_and_check_plaintext()
+                d3.addCallback(_then_delete_7_and_try_a_download)
+                return d3
 
             d2.addCallback(_after_repair)
             return d2
@@ -522,7 +530,7 @@ class Repairer(common.ShareManglingMixin, unittest.TestCase):
             self.replace_shares(stash[0], storage_index=self.uri.storage_index)
             return ignored
 
-        def _repair_from_corruption(unused, corruptor_func):
+        def _repair_from_corruption(shnum, corruptor_func):
             before_repair_reads = self._count_reads()
             before_repair_allocates = self._count_writes()
 
@@ -545,7 +553,31 @@ class Repairer(common.ShareManglingMixin, unittest.TestCase):
                 self.failIf(prerepairres.is_healthy(), (prerepairres.data, corruptor_func))
                 self.failUnless(postrepairres.is_healthy(), (postrepairres.data, corruptor_func))
 
-                return self._download_and_check_plaintext()
+                # Now we inspect the filesystem to make sure that it has 10
+                # shares.
+                shares = self.find_shares()
+                self.failIf(len(shares) < 10)
+
+                # Now we assert that the verifier reports the file as healthy.
+                d3 = self.filenode.check(Monitor(), verify=True)
+                def _after_verify(verifyresults):
+                    self.failUnless(verifyresults.is_healthy())
+                d3.addCallback(_after_verify)
+
+                # Now we delete seven of the other shares, then try to
+                # download the file and assert that it succeeds at
+                # downloading and has the right contents. This can't work
+                # unless it has already repaired the previously-corrupted share.
+                def _then_delete_7_and_try_a_download(unused=None):
+                    shnums = range(10)
+                    shnums.remove(shnum)
+                    random.shuffle(shnums)
+                    for sharenum in shnums[:7]:
+                        self._delete_a_share(sharenum=sharenum)
+
+                    return self._download_and_check_plaintext()
+                d3.addCallback(_then_delete_7_and_try_a_download)
+                return d3
 
             d2.addCallback(_after_repair)
             return d2