From: Brian Warner Date: Mon, 10 Mar 2008 22:42:56 +0000 (-0700) Subject: mutable: minor refactoring of _do_read, to make other tests easier X-Git-Tag: allmydata-tahoe-0.9.0~46 X-Git-Url: https://git.rkrishnan.org/pf/content/en/service/simplejson/?a=commitdiff_plain;h=d6cde55c63ed4c16b9932e488b300b2b4f7f5d0e;p=tahoe-lafs%2Ftahoe-lafs.git mutable: minor refactoring of _do_read, to make other tests easier --- diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py index 8d861ea6..c57e5d69 100644 --- a/src/allmydata/mutable.py +++ b/src/allmydata/mutable.py @@ -1098,10 +1098,15 @@ class Publish: # the permuted peerlist. return d + def _do_read(self, ss, peerid, storage_index, shnums, readv): + # isolate the callRemote to a separate method, so tests can subclass + # Publish and override it + d = ss.callRemote("slot_readv", storage_index, shnums, readv) + return d + def _do_query(self, ss, peerid, storage_index): self.log("querying %s" % idlib.shortnodeid_b2a(peerid)) - d = ss.callRemote("slot_readv", - storage_index, [], [(0, self._read_size)]) + d = self._do_read(ss, peerid, storage_index, [], [(0, self._read_size)]) return d def _got_query_results(self, datavs, peerid, permutedid, @@ -1302,8 +1307,8 @@ class Publish: def _do_privkey_query(self, rref, peerid, shnum, offset, length): started = time.time() - d = rref.callRemote("slot_readv", self._storage_index, - [shnum], [(offset, length)] ) + d = self._do_read(rref, peerid, self._storage_index, + [shnum], [(offset, length)]) d.addCallback(self._privkey_query_response, peerid, shnum, started) return d diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index bc640366..18469836 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -47,8 +47,9 @@ class FakeFilenode(mutable.MutableFileNode): return defer.succeed(None) class FakePublish(mutable.Publish): - def _do_query(self, ss, peerid, storage_index): + def _do_read(self, ss, peerid, storage_index, shnums, readv): assert ss[0] == peerid + assert shnums == [] shares = self._peers[peerid] return defer.succeed(shares) @@ -275,6 +276,7 @@ class Publish(unittest.TestCase): p = FakePublish(fn) p._storage_index = "\x00"*32 p._new_seqnum = 3 + p._read_size = 1000 #r = mutable.Retrieve(fn) p._peers = {} for peerid in c._peerids: