From d44689728243d6716a9a678bbf5792ab3a213482 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 25 May 2012 00:13:13 -0700 Subject: [PATCH] CheckResults: simplify self._data --- src/allmydata/check_results.py | 5 +---- src/allmydata/test/common.py | 2 ++ src/allmydata/test/test_checker.py | 6 +++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/allmydata/check_results.py b/src/allmydata/check_results.py index 7224a6f8..445eed73 100644 --- a/src/allmydata/check_results.py +++ b/src/allmydata/check_results.py @@ -12,9 +12,6 @@ class CheckResults: self.uri = uri self.storage_index = storage_index self.problems = [] - self._data = {"count-corrupt-shares": 0, - "list-corrupt-shares": [], - } self.summary = "" self.report = [] @@ -34,7 +31,7 @@ class CheckResults: def set_needs_rebalancing(self, needs_rebalancing): self.needs_rebalancing_p = bool(needs_rebalancing) def set_data(self, data): - self._data.update(data) + self._data = data def set_summary(self, summary): assert isinstance(summary, str) # should be a single string self.summary = summary diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 77b1d08c..ff9db980 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -73,6 +73,7 @@ class FakeCHKFileNode: data["count-good-share-hosts"] = 10 data["count-wrong-shares"] = 0 nodeid = "\x00"*20 + data["count-corrupt-shares"] = 0 data["list-corrupt-shares"] = [] data["sharemap"] = {1: [nodeid]} data["servers-responding"] = [nodeid] @@ -281,6 +282,7 @@ class FakeMutableFileNode: data["count-shares-expected"] = 10 data["count-good-share-hosts"] = 10 data["count-wrong-shares"] = 0 + data["count-corrupt-shares"] = 0 data["list-corrupt-shares"] = [] nodeid = "\x00"*20 data["sharemap"] = {"seq1-abcd-sh0": [nodeid]} diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index dc7d90fd..816c57fd 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -89,6 +89,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): "count-shares-expected": 9, "count-shares-good": 10, "count-good-share-hosts": 11, + "count-corrupt-shares": 0, "list-corrupt-shares": [], "count-wrong-shares": 0, "sharemap": {"shareid1": [serverid_1, serverid_f]}, @@ -121,6 +122,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): cr.set_healthy(False) cr.set_recoverable(False) cr.set_summary("rather dead") + data["count-corrupt-shares"] = 1 data["list-corrupt-shares"] = [(serverid_1, u.get_storage_index(), 2)] cr.set_data(data) html = self.render2(w) @@ -159,7 +161,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): 'count-good-share-hosts': 11, 'count-wrong-shares': 0, 'count-shares-good': 10, - 'count-corrupt-shares': 0, + 'count-corrupt-shares': 1, 'servers-responding': [], 'recoverable': False, } @@ -189,6 +191,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): "count-shares-expected": 10, "count-shares-good": 6, "count-good-share-hosts": 7, + "count-corrupt-shares": 0, "list-corrupt-shares": [], "count-wrong-shares": 0, "sharemap": {"shareid1": [serverid_1, serverid_f]}, @@ -207,6 +210,7 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): "count-shares-expected": 10, "count-shares-good": 10, "count-good-share-hosts": 11, + "count-corrupt-shares": 0, "list-corrupt-shares": [], "count-wrong-shares": 0, "sharemap": {"shareid1": [serverid_1, serverid_f]}, -- 2.45.2