From: Brian Warner Date: Tue, 4 Dec 2007 22:55:27 +0000 (-0700) Subject: improve test coverage on FileNode.check X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/rgr-080307.php?a=commitdiff_plain;h=1a5257c388164f36448d2145b35df7c84e8e7ba2;p=tahoe-lafs%2Ftahoe-lafs.git improve test coverage on FileNode.check --- diff --git a/src/allmydata/checker.py b/src/allmydata/checker.py index 22811916..af11ecc3 100644 --- a/src/allmydata/checker.py +++ b/src/allmydata/checker.py @@ -228,10 +228,10 @@ class Checker(service.MultiService): self.results = InMemoryCheckerResults() def check(self, uri_to_check): - uri_to_check = IVerifierURI(uri_to_check) if uri_to_check is None: return defer.succeed(True) - elif isinstance(uri_to_check, uri.CHKFileVerifierURI): + uri_to_check = IVerifierURI(uri_to_check) + if isinstance(uri_to_check, uri.CHKFileVerifierURI): peer_getter = self.parent.get_permuted_peers c = SimpleCHKFileChecker(peer_getter, uri_to_check) d = c.check() diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 76c5a804..328f692b 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -141,6 +141,7 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin): # end of the string. Flip one of its bits and make sure we # detect the corruption. new_contents = testutil.flip_bit(old_contents, -10) + # TODO: also test flipping bits in the other portions filenode.all_contents[si] = new_contents d.addCallback(_corrupt) def _check2(res): @@ -300,6 +301,7 @@ class Dirnode(unittest.TestCase, testutil.ShouldFailMixin): return d + netstring = hashutil.netstring split_netstring = dirnode.split_netstring diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index a9016cbd..97119914 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -577,6 +577,11 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase): d.addCallback(self._test_web_start) d.addCallback(self._test_control) d.addCallback(self._test_cli) + # P now has four top-level children: + # P/personal/sekrit data + # P/s2-ro/ + # P/s2-rw/ + # P/test_put/ (empty) d.addCallback(self._test_checker) d.addCallback(self._test_verifier) return d @@ -1196,8 +1201,37 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase): all_results.append(those_results) _check_checker_results(all_results) d.addCallback(_check_stored_results) + + d.addCallback(self._test_checker_3) + return d + + def _test_checker_3(self, res): + # check one file, through FileNode.check() + d = self._private_node.get_child_at_path("personal/sekrit data") + d.addCallback(lambda n: n.check()) + def _checked(results): + # 'sekrit data' is small, and fits in a LiteralFileNode, so + # checking it is trivial and always returns True + self.failUnlessEqual(results, True) + d.addCallback(_checked) + + c0 = self.clients[1] + n = c0.create_node_from_uri(self._root_directory_uri) + d.addCallback(lambda res: n.get_child_at_path("subdir1/mydata567")) + d.addCallback(lambda n: n.check()) + def _checked2(results): + # mydata567 is large and lives in a CHK + (needed, total, found, sharemap) = results + self.failUnlessEqual(needed, 3) + self.failUnlessEqual(total, 10) + self.failUnlessEqual(found, 10) + self.failUnlessEqual(len(sharemap), 10) + for shnum in range(10): + self.failUnlessEqual(len(sharemap[shnum]), 1) + d.addCallback(_checked2) return d + def _test_verifier(self, res): checker1 = self.clients[1].getServiceNamed("checker") d = self._private_node.build_manifest()