From: Brian Warner Date: Tue, 11 Mar 2008 01:08:23 +0000 (-0700) Subject: test_mutable: exercise short reads too X-Git-Tag: allmydata-tahoe-0.9.0~41 X-Git-Url: https://git.rkrishnan.org/specifications/banana.xhtml?a=commitdiff_plain;h=11445b510996d66369018798acaa16f57778f8c6;p=tahoe-lafs%2Ftahoe-lafs.git test_mutable: exercise short reads too --- diff --git a/src/allmydata/mutable.py b/src/allmydata/mutable.py index 188075fc..03725f58 100644 --- a/src/allmydata/mutable.py +++ b/src/allmydata/mutable.py @@ -328,6 +328,13 @@ class Retrieve: self._status.set_helper(False) self._status.set_progress(0.0) self._status.set_active(True) + # how much data should be read on the first fetch? It would be nice + # if we could grab small directories in a single RTT. The way we pack + # dirnodes consumes about 112 bytes per child. The way we pack + # mutable files puts about 935 bytes of pubkey+sig+hashes, then our + # data, then about 1216 bytes of encprivkey. So 2kB ought to get us + # about 9 entries, which seems like a good default. + self._read_size = 2000 def log(self, msg, **kwargs): prefix = self._log_prefix @@ -379,13 +386,6 @@ class Retrieve: # remove that share from the sharemap. and start step#6 again. initial_query_count = 5 - # how much data should be read on the first fetch? It would be nice - # if we could grab small directories in a single RTT. The way we pack - # dirnodes consumes about 112 bytes per child. The way we pack - # mutable files puts about 935 bytes of pubkey+sig+hashes, then our - # data, then about 1216 bytes of encprivkey. So 2kB ought to get us - # about 9 entries, which seems like a good default. - self._read_size = 2000 # we might not know how many shares we need yet. self._required_shares = self._node.get_required_shares() diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 83a78e2e..5f0a5786 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -611,3 +611,18 @@ class Roundtrip(unittest.TestCase): # a corrupted privkey won't even be noticed by the reader return self._corrupt_all("enc_privkey", None, should_succeed=True) + def test_short_read(self): + c, s, fn, p, r = self.setup_for_publish(20) + contents = "New contents go here" + d = p.publish(contents) + def _published(res): + # force a short read, to make Retrieve._got_results re-send the + # queries. But don't make it so short that we can't read the + # header. + r._read_size = mutable.HEADER_LENGTH + 10 + return r.retrieve() + d.addCallback(_published) + def _retrieved(new_contents): + self.failUnlessEqual(contents, new_contents) + d.addCallback(_retrieved) + return d