From: Brian Warner Date: Wed, 10 Sep 2008 06:54:57 +0000 (-0700) Subject: test_system: check t=deep-stats too X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/css/rgr-080307.php?a=commitdiff_plain;h=28a9f8f07665b0003cba12bc5d283be9f2c4d2f2;p=tahoe-lafs%2Ftahoe-lafs.git test_system: check t=deep-stats too --- diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index d8871a6d..1260692f 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -2106,10 +2106,14 @@ class DeepCheck(SystemTestMixin, unittest.TestCase): # s["size-directories"] self.failUnlessEqual(s["largest-directory-children"], 4) self.failUnlessEqual(s["largest-immutable-file"], 13000) - self.failUnlessEqual(s["size-files-histogram"], - [(11, 31, 1), - (10001, 31622, 1), - ]) + # to re-use this function for both the local dirnode.deep_stats() and + # the webapi t=deep-stats, we coerce the result into a list of + # tuples. dirnode.deep_stats() returns a list of tuples, but JSON + # only knows about lists., so t=deep-stats returns a list of lists. + histogram = [tuple(stuff) for stuff in s["size-files-histogram"]] + self.failUnlessEqual(histogram, [(11, 31, 1), + (10001, 31622, 1), + ]) self.failUnlessEqual(s["size-immutable-files"], 13000) self.failUnlessEqual(s["size-literal-files"], 22) @@ -2203,9 +2207,12 @@ class DeepCheck(SystemTestMixin, unittest.TestCase): def web_json(self, n, **kwargs): kwargs["output"] = "json" + return self.web(n, "POST", **kwargs) + + def web(self, n, method="GET", **kwargs): url = (self.webish_url + "uri/%s" % urllib.quote(n.get_uri()) + "?" + "&".join(["%s=%s" % (k,v) for (k,v) in kwargs.items()])) - d = getPage(url, method="POST") + d = getPage(url, method=method) def _decode(s): try: data = simplejson.loads(s) @@ -2291,9 +2298,16 @@ class DeepCheck(SystemTestMixin, unittest.TestCase): self.failUnlessEqual(data["storage-index"], "", where) self.failUnlessEqual(data["results"]["healthy"], True, where) + def json_check_stats(self, data, where): + self.check_stats(data) + def do_test_web(self, ignored): d = defer.succeed(None) + # stats + d.addCallback(lambda ign: self.web(self.root, t="deep-stats")) + d.addCallback(self.json_check_stats, "deep-stats") + # check, no verify d.addCallback(lambda ign: self.web_json(self.root, t="check")) d.addCallback(self.json_check_is_healthy, self.root, "root")