From: Brian Warner Date: Thu, 7 Feb 2008 00:51:11 +0000 (-0700) Subject: offloaded: oops, need more tricks to make the unit tests pass X-Git-Tag: allmydata-tahoe-0.8.0~117 X-Git-Url: https://git.rkrishnan.org/pf/content/frontends/webapi.rst?a=commitdiff_plain;h=75e4332462cbe950487defcf4444db9d458bfcd5;p=tahoe-lafs%2Ftahoe-lafs.git offloaded: oops, need more tricks to make the unit tests pass --- diff --git a/src/allmydata/offloaded.py b/src/allmydata/offloaded.py index 2e2c4877..319e05ae 100644 --- a/src/allmydata/offloaded.py +++ b/src/allmydata/offloaded.py @@ -194,7 +194,6 @@ class CHKUploadHelper(Referenceable, upload.CHKUploader): (uri_extension_hash, needed_shares, total_shares, size) = res r = self._results r.uri_extension_hash = uri_extension_hash - r.uri_extension_data = self._encoder.get_uri_extension_data() f_times = self._fetcher.get_times() r.timings["cumulative_fetch"] = f_times["cumulative_fetch"] r.ciphertext_fetched = self._fetcher.get_ciphertext_fetched() diff --git a/src/allmydata/test/test_helper.py b/src/allmydata/test/test_helper.py index e1e8b0c6..b45811a8 100644 --- a/src/allmydata/test/test_helper.py +++ b/src/allmydata/test/test_helper.py @@ -12,6 +12,8 @@ from pycryptopp.cipher.aes import AES MiB = 1024*1024 +DATA = "I need help\n" * 1000 + class CHKUploadHelper_fake(offloaded.CHKUploadHelper): def start_encrypted(self, eu): d = eu.get_size() @@ -19,6 +21,12 @@ class CHKUploadHelper_fake(offloaded.CHKUploadHelper): d2 = eu.get_all_encoding_parameters() def _got_parms(parms): needed_shares, happy, total_shares, segsize = parms + ueb_data = {"needed_shares": needed_shares, + "total_shares": total_shares, + "segment_size": segsize, + "size": size, + } + self._results.uri_extension_data = ueb_data return (hashutil.uri_extension_hash(""), needed_shares, total_shares, size) d2.addCallback(_got_parms) @@ -30,6 +38,18 @@ class CHKUploadHelper_already_uploaded(offloaded.CHKUploadHelper): def start(self): res = upload.UploadResults() res.uri_extension_hash = hashutil.uri_extension_hash("") + + # we're pretending that the file they're trying to upload was already + # present in the grid. We return some information about the file, so + # the client can decide if they like the way it looks. The parameters + # used here are chosen to match the defaults. + PARAMS = FakeClient.DEFAULT_ENCODING_PARAMETERS + ueb_data = {"needed_shares": PARAMS["k"], + "total_shares": PARAMS["n"], + "segment_size": min(PARAMS["max_segment_size"], len(DATA)), + "size": len(DATA), + } + res.uri_extension_data = ueb_data return (res, None) class FakeClient(service.MultiService): @@ -96,7 +116,6 @@ class AssistedUpload(unittest.TestCase): def _ready(res): assert u._helper - DATA = "I need help\n" * 1000 return upload_data(u, DATA) d.addCallback(_ready) def _uploaded(results): @@ -116,7 +135,6 @@ class AssistedUpload(unittest.TestCase): def test_previous_upload_failed(self): self.basedir = "helper/AssistedUpload/test_previous_upload_failed" self.setUpHelper(self.basedir) - DATA = "I need help\n" * 1000 # we want to make sure that an upload which fails (leaving the # ciphertext in the CHK_encoding/ directory) does not prevent a later @@ -172,7 +190,6 @@ class AssistedUpload(unittest.TestCase): def _ready(res): assert u._helper - DATA = "I need help\n" * 1000 return upload_data(u, DATA) d.addCallback(_ready) def _uploaded(results): diff --git a/src/allmydata/upload.py b/src/allmydata/upload.py index 2662f6a2..8e43e02c 100644 --- a/src/allmydata/upload.py +++ b/src/allmydata/upload.py @@ -668,6 +668,7 @@ class CHKUploader: r.timings["storage_index"] = self._storage_index_elapsed r.timings["peer_selection"] = self._peer_selection_elapsed r.timings.update(self._encoder.get_times()) + r.uri_extension_data = self._encoder.get_uri_extension_data() return res def _compute_uri(self, (uri_extension_hash,