]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
webapi: add 'summary' string to checker results JSON
authorBrian Warner <warner@allmydata.com>
Wed, 19 Nov 2008 01:28:26 +0000 (18:28 -0700)
committerBrian Warner <warner@allmydata.com>
Wed, 19 Nov 2008 01:28:26 +0000 (18:28 -0700)
docs/frontends/webapi.txt
src/allmydata/immutable/checker.py
src/allmydata/test/test_system.py
src/allmydata/web/checker_results.py

index a91a478d0bbc7ce3f150e2bcb48ae7f77da55b11..2ecba41015b09a86a0b56bbbec8b4b3670bcae15 100644 (file)
@@ -750,6 +750,7 @@ POST $URL?t=check
 
    storage-index: a base32-encoded string with the objects's storage index,
                   or an empty string for LIT files
+   summary: a string, with a one-line summary of the stats of the file
    results: a dictionary that describes the state of the file. For LIT files,
             this dictionary has only the 'healthy' key, which will always be
             True. For distributed files, this dictionary has the following
index 91bced9953407aa4bb7cd2694da37210591de8b4..3c6218eeda83f610cb2033d8035d93c1a2ff5b7d 100644 (file)
@@ -109,7 +109,11 @@ class SimpleCHKFileChecker:
                           ",".join(["sh%d" % shnum
                                     for shnum in sorted(missing)]))
         r.set_report(report)
-        # TODO: r.set_summary(summary)
+        if healthy:
+            r.set_summary("Healthy")
+        else:
+            r.set_summary("Not Healthy")
+            # TODO: more detail
         return r
 
 class VerifyingOutput:
@@ -123,6 +127,7 @@ class VerifyingOutput:
         self._results = results
         results.set_healthy(False)
         results.set_recoverable(False)
+        results.set_summary("Not Healthy")
 
     def setup_hashtrees(self, plaintext_hashtree, crypttext_hashtree):
         self._crypttext_hash_tree = crypttext_hashtree
@@ -145,6 +150,7 @@ class VerifyingOutput:
     def finish(self):
         self._results.set_healthy(True)
         self._results.set_recoverable(True)
+        self._results.set_summary("Healthy")
         # the return value of finish() is passed out of FileDownloader._done,
         # but SimpleCHKFileVerifier overrides this with the CheckerResults
         # instance instead.
index 716544ee14a9bbe2b45659067c4eaf633748283a..c519dfaa63387ebcd31fea3195ec7871a884a81e 100644 (file)
@@ -2204,6 +2204,9 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase):
 
         self.failUnlessEqual(data["storage-index"],
                              base32.b2a(n.get_storage_index()), where)
+        self.failUnless("summary" in data, (where, data))
+        self.failUnlessEqual(data["summary"].lower(), "healthy",
+                             "%s: '%s'" % (where, data["summary"]))
         r = data["results"]
         self.failUnlessEqual(r["healthy"], True, where)
         needs_rebalancing = bool( len(self.clients) < 10 )
index ff19aa084341379f49650b77c6a895017a44b4d0..d59344eb9139f811d7c28d619797d2601362471e 100644 (file)
@@ -82,6 +82,7 @@ class ResultsBase:
     def _json_check_results(self, r):
         data = {}
         data["storage-index"] = r.get_storage_index_string()
+        data["summary"] = r.get_summary()
         data["results"] = self._json_check_counts(r.get_data())
         data["results"]["needs-rebalancing"] = r.needs_rebalancing()
         data["results"]["healthy"] = r.is_healthy()