Skip to content

Commit

Permalink
Returned test_corrupt_all_block_hash_tree_late to its original semant…
Browse files Browse the repository at this point in the history
…ics. Added functions to clear the cache in slotreadproxy.

Signed-off-by: Andrew Miller <amiller@dappervision.com>
  • Loading branch information
amiller committed Nov 8, 2012
1 parent 8d68da2 commit d754999
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/allmydata/mutable/layout.py
Expand Up @@ -1235,9 +1235,12 @@ def __init__(self,
# The way callers interact with cache in the filenode returns
# None if there isn't any cached data, but the way we index the
# cached data requires a string, so convert None to "".
if self._data == None:
if self._data is None:
self._data = ""

def _clear_cache(self):
self._data = ""
self._data_is_everything = False

def _maybe_fetch_offsets_and_header(self, force_remote=False):
"""
Expand Down
7 changes: 7 additions & 0 deletions src/allmydata/mutable/servermap.py
Expand Up @@ -377,6 +377,13 @@ def set_update_data_for_share_and_verinfo(self, shnum, verinfo, data):
self.update_data.setdefault(shnum , []).append((verinfo, data))


def _test_clear_cache(self):
# Force each of the slotread proxies to clear their data cache.
# This is useful for unit tests.
for _,proxy in self.proxies.iteritems():
proxy._clear_cache()


class ServermapUpdater:
def __init__(self, filenode, storage_broker, monitor, servermap,
mode=MODE_READ, add_lease=False, update_range=None):
Expand Down
7 changes: 4 additions & 3 deletions src/allmydata/test/test_mutable.py
Expand Up @@ -1377,6 +1377,7 @@ def _test_corrupt_all(self, offset, substring,
d.addCallback(corrupt, self._storage, offset)
def _do_retrieve(servermap):
ver = servermap.best_recoverable_version()
servermap._test_clear_cache()
if ver is None and not should_succeed:
# no recoverable versions == not succeeding. The problem
# should be noted in the servermap's list of problems.
Expand Down Expand Up @@ -1515,7 +1516,7 @@ def _check(res):
self.failUnless(f.check(NotEnoughSharesError))
return self._test_corrupt_all("block_hash_tree",
"block hash tree failure",
corrupt_early=True,
corrupt_early=False,
failure_checker=_check)


Expand Down Expand Up @@ -1599,7 +1600,7 @@ def test_corrupt_mdmf_block_hash_tree(self):
d.addCallback(lambda ignored:
self._test_corrupt_all(("block_hash_tree", 12 * 32),
"block hash tree failure",
corrupt_early=False,
corrupt_early=True,
should_succeed=False))
return d

Expand All @@ -1609,7 +1610,7 @@ def test_corrupt_mdmf_block_hash_tree_late(self):
d.addCallback(lambda ignored:
self._test_corrupt_all(("block_hash_tree", 12 * 32),
"block hash tree failure",
corrupt_early=True,
corrupt_early=False,
should_succeed=False))
return d

Expand Down

0 comments on commit d754999

Please sign in to comment.