Ticket #1758: 1758-approach-b.diff
File 1758-approach-b.diff, 4.5 KB (added by davidsarah, at 2013-01-02T03:22:13Z) |
---|
-
src/allmydata/scripts/tahoe_check.py
diff --git a/src/allmydata/scripts/tahoe_check.py b/src/allmydata/scripts/tahoe_check.py index adb0ccc..5e87c08 100644
a b def check(options): 77 77 else: 78 78 stdout.write(" repair failed\n") 79 79 else: 80 stdout.write("Summary: %s\n" % quote_output(data["summary"], quotemarks=False)) 80 summary = data.get("summary", "Healthy (LIT)") 81 stdout.write("Summary: %s\n" % quote_output(summary, quotemarks=False)) 81 82 cr = data["results"] 82 83 stdout.write(" storage index: %s\n" % quote_output(data["storage-index"], quotemarks=False)) 83 stdout.write(" good-shares: %r (encoding is %r-of-%r)\n" 84 % (cr["count-shares-good"], 85 cr["count-shares-needed"], 86 cr["count-shares-expected"])) 87 stdout.write(" wrong-shares: %r\n" % cr["count-wrong-shares"]) 88 corrupt = cr["list-corrupt-shares"] 89 if corrupt: 90 stdout.write(" corrupt shares:\n") 91 for (serverid, storage_index, sharenum) in corrupt: 92 stdout.write(" %s\n" % _quote_serverid_index_share(serverid, storage_index, sharenum)) 84 if "summary" in data: 85 stdout.write(" good-shares: %r (encoding is %r-of-%r)\n" 86 % (cr["count-shares-good"], 87 cr["count-shares-needed"], 88 cr["count-shares-expected"])) 89 stdout.write(" wrong-shares: %r\n" % cr["count-wrong-shares"]) 90 corrupt = cr["list-corrupt-shares"] 91 if corrupt: 92 stdout.write(" corrupt shares:\n") 93 for (serverid, storage_index, sharenum) in corrupt: 94 stdout.write(" %s\n" % _quote_serverid_index_share(serverid, storage_index, sharenum)) 93 95 return 0 94 96 95 97 -
src/allmydata/test/test_cli.py
diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 0edcd78..2d5c752 100644
a b class Check(GridTestMixin, CLITestMixin, unittest.TestCase): 2953 2953 self.failUnlessReallyEqual(rc, 0) 2954 2954 data = simplejson.loads(out) 2955 2955 self.failUnlessReallyEqual(to_str(data["summary"]), "Healthy") 2956 self.failUnlessReallyEqual(data["results"]["healthy"], True) 2956 2957 d.addCallback(_check2) 2957 2958 2959 d.addCallback(lambda ign: c0.upload(upload.Data("literal", convergence=""))) 2960 def _stash_lit_uri(n): 2961 self.lit_uri = n.get_uri() 2962 d.addCallback(_stash_lit_uri) 2963 2964 d.addCallback(lambda ign: self.do_cli("check", self.lit_uri)) 2965 def _check_lit((rc, out, err)): 2966 self.failUnlessReallyEqual(err, "") 2967 self.failUnlessReallyEqual(rc, 0) 2968 lines = out.splitlines() 2969 self.failUnless("Summary: Healthy (LIT)" in lines, out) 2970 d.addCallback(_check_lit) 2971 2972 d.addCallback(lambda ign: self.do_cli("check", "--raw", self.lit_uri)) 2973 def _check_lit((rc, out, err)): 2974 self.failUnlessReallyEqual(err, "") 2975 self.failUnlessReallyEqual(rc, 0) 2976 data = simplejson.loads(out) 2977 self.failUnlessReallyEqual(data["results"]["healthy"], True) 2978 d.addCallback(_check_lit) 2979 2958 2980 def _clobber_shares(ignored): 2959 2981 # delete one, corrupt a second 2960 2982 shares = self.find_uri_shares(self.uri) … … class Check(GridTestMixin, CLITestMixin, unittest.TestCase): 2984 3006 self.failUnless(self._corrupt_share_line in lines, out) 2985 3007 d.addCallback(_check3) 2986 3008 3009 d.addCallback(lambda ign: self.do_cli("check", "--verify", "--raw", self.uri)) 3010 def _check3_raw((rc, out, err)): 3011 self.failUnlessReallyEqual(err, "") 3012 self.failUnlessReallyEqual(rc, 0) 3013 data = simplejson.loads(out) 3014 self.failUnlessReallyEqual(data["results"]["healthy"], False) 3015 self.failUnlessIn("Unhealthy: 8 shares (enc 3-of-10)", data["summary"]) 3016 self.failUnlessReallyEqual(data["results"]["count-shares-good"], 8) 3017 self.failUnlessReallyEqual(data["results"]["count-corrupt-shares"], 1) 3018 self.failUnlessIn("list-corrupt-shares", data["results"]) 3019 d.addCallback(_check3_raw) 3020 2987 3021 d.addCallback(lambda ign: 2988 3022 self.do_cli("check", "--verify", "--repair", self.uri)) 2989 3023 def _check4((rc, out, err)):