From: Daira Hopwood Date: Thu, 5 Sep 2013 16:37:47 +0000 (+0100) Subject: Thu Jun 21 20:42:44 BST 2012 david-sarah@jacaranda.org X-Git-Url: https://git.rkrishnan.org/junkers?a=commitdiff_plain;h=17779ef2d80a38145e256b63ba42a44c5e1821b3;p=tahoe-lafs%2Ftahoe-lafs.git Thu Jun 21 20:42:44 BST 2012 david-sarah@jacaranda.org * Rollback last patch, which was pushed unintentionally to the 1.9.2 branch (Add assertions to make sure that set_default_encoding_parameters is always called...) refs #1212 --- diff --git a/src/allmydata/immutable/upload.py b/src/allmydata/immutable/upload.py index 75d26be6..013aca97 100644 --- a/src/allmydata/immutable/upload.py +++ b/src/allmydata/immutable/upload.py @@ -16,7 +16,7 @@ from allmydata.util import base32, dictutil, idlib, log, mathutil from allmydata.util.happinessutil import servers_of_happiness, \ shares_by_server, merge_servers, \ failure_message -from allmydata.util.assertutil import precondition, _assert +from allmydata.util.assertutil import precondition from allmydata.util.rrefutil import add_version_to_remote_reference from allmydata.interfaces import IUploadable, IUploader, IUploadResults, \ IEncryptedUploadable, RIEncryptedUploadable, IUploadStatus, \ @@ -573,8 +573,6 @@ class EncryptAnUploadable: CHUNKSIZE = 50*1024 def __init__(self, original, log_parent=None): - precondition(original.default_params_set, - "set_default_encoding_parameters not called on %r before wrapping with EncryptAnUploadable" % (original,)) self.original = IUploadable(original) self._log_number = log_parent self._encryptor = None @@ -1250,7 +1248,9 @@ class AssistedUploader: class BaseUploadable: # this is overridden by max_segment_size default_max_segment_size = DEFAULT_MAX_SEGMENT_SIZE - default_params_set = False + default_encoding_param_k = 3 # overridden by encoding_parameters + default_encoding_param_happy = 7 + default_encoding_param_n = 10 max_segment_size = None encoding_param_k = None @@ -1276,10 +1276,8 @@ class BaseUploadable: self.default_encoding_param_n = default_params["n"] if "max_segment_size" in default_params: self.default_max_segment_size = default_params["max_segment_size"] - self.default_params_set = True def get_all_encoding_parameters(self): - _assert(self.default_params_set, "set_default_encoding_parameters not called on %r" % (self,)) if self._all_encoding_parameters: return defer.succeed(self._all_encoding_parameters) diff --git a/src/allmydata/test/test_encode.py b/src/allmydata/test/test_encode.py index b3f72d33..c06fbbd3 100644 --- a/src/allmydata/test/test_encode.py +++ b/src/allmydata/test/test_encode.py @@ -268,8 +268,10 @@ class Encode(unittest.TestCase): # force use of multiple segments e = encode.Encoder() u = upload.Data(data, convergence="some convergence string") - u.set_default_encoding_parameters({'max_segment_size': max_segment_size, - 'k': 25, 'happy': 75, 'n': 100}) + u.max_segment_size = max_segment_size + u.encoding_param_k = 25 + u.encoding_param_happy = 75 + u.encoding_param_n = 100 eu = upload.EncryptAnUploadable(u) d = e.set_encrypted_uploadable(eu) diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index 098a18d0..224b8bd5 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -20,7 +20,6 @@ from allmydata.util.happinessutil import servers_of_happiness, \ shares_by_server, merge_servers from allmydata.storage_client import StorageFarmBroker from allmydata.storage.server import storage_index_to_dir -from allmydata.client import Client MiB = 1024*1024 @@ -634,52 +633,42 @@ class ServerSelection(unittest.TestCase): class StorageIndex(unittest.TestCase): def test_params_must_matter(self): DATA = "I am some data" - PARAMS = Client.DEFAULT_ENCODING_PARAMETERS - u = upload.Data(DATA, convergence="") - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d1 = eu.get_storage_index() # CHK means the same data should encrypt the same way u = upload.Data(DATA, convergence="") - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d1a = eu.get_storage_index() # but if we use a different convergence string it should be different u = upload.Data(DATA, convergence="wheee!") - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d1salt1 = eu.get_storage_index() # and if we add yet a different convergence it should be different again u = upload.Data(DATA, convergence="NOT wheee!") - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d1salt2 = eu.get_storage_index() # and if we use the first string again it should be the same as last time u = upload.Data(DATA, convergence="wheee!") - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d1salt1a = eu.get_storage_index() # and if we change the encoding parameters, it should be different (from the same convergence string with different encoding parameters) u = upload.Data(DATA, convergence="") - u.set_default_encoding_parameters(PARAMS) u.encoding_param_k = u.default_encoding_param_k + 1 eu = upload.EncryptAnUploadable(u) d2 = eu.get_storage_index() # and if we use a random key, it should be different than the CHK u = upload.Data(DATA, convergence=None) - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d3 = eu.get_storage_index() # and different from another instance u = upload.Data(DATA, convergence=None) - u.set_default_encoding_parameters(PARAMS) eu = upload.EncryptAnUploadable(u) d4 = eu.get_storage_index() @@ -776,7 +765,9 @@ class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin, broker = self.g.clients[0].storage_broker sh = self.g.clients[0]._secret_holder data = upload.Data("data" * 10000, convergence="") - data.set_default_encoding_parameters({'k': 3, 'happy': 4, 'n': 10}) + data.encoding_param_k = 3 + data.encoding_param_happy = 4 + data.encoding_param_n = 10 uploadable = upload.EncryptAnUploadable(data) encoder = encode.Encoder() encoder.set_encrypted_uploadable(uploadable)