From: Kevan Carstensen Date: Thu, 7 Jan 2010 19:13:25 +0000 (-0700) Subject: Alter various unit tests to work with the new happy behavior X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/index.php?a=commitdiff_plain;h=d360ee0d2ef5336cf11c83289c45344efb401093;p=tahoe-lafs%2Ftahoe-lafs.git Alter various unit tests to work with the new happy behavior --- diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index f1bfe3dc..054c0fd1 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -938,6 +938,9 @@ class ShareManglingMixin(SystemTestMixin): # We need multiple segments to test crypttext hash trees that are # non-trivial (i.e. they have more than just one hash in them). cl0.DEFAULT_ENCODING_PARAMETERS['max_segment_size'] = 12 + # Tests that need to test servers of happiness using this should + # set their own value for happy -- the default (7) breaks stuff. + cl0.DEFAULT_ENCODING_PARAMETERS['happy'] = 1 d2 = cl0.upload(immutable.upload.Data(TEST_DATA, convergence="")) def _after_upload(u): filecap = u.uri diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index cc2e6c90..67e745dd 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -280,6 +280,7 @@ class AddLease(GridTestMixin, unittest.TestCase): self.basedir = "checker/AddLease/875" self.set_up_grid(num_servers=1) c0 = self.g.clients[0] + c0.DEFAULT_ENCODING_PARAMETERS['happy'] = 1 self.uris = {} DATA = "data" * 100 d = c0.upload(Data(DATA, convergence="")) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 5b301b84..c1b1f7fa 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -90,6 +90,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d = self.set_up_nodes() def _check_connections(res): for c in self.clients: + c.DEFAULT_ENCODING_PARAMETERS['happy'] = 5 all_peerids = c.get_storage_broker().get_all_serverids() self.failUnlessEqual(len(all_peerids), self.numclients) sb = c.storage_broker @@ -201,6 +202,7 @@ class SystemTest(SystemTestMixin, unittest.TestCase): add_to_sparent=True)) def _added(extra_node): self.extra_node = extra_node + self.extra_node.DEFAULT_ENCODING_PARAMETERS['happy'] = 5 d.addCallback(_added) HELPER_DATA = "Data that needs help to upload" * 1000 @@ -700,6 +702,10 @@ class SystemTest(SystemTestMixin, unittest.TestCase): self.basedir = "system/SystemTest/test_filesystem" self.data = LARGE_DATA d = self.set_up_nodes(use_stats_gatherer=True) + def _new_happy_semantics(ign): + for c in self.clients: + c.DEFAULT_ENCODING_PARAMETERS['happy'] = 1 + d.addCallback(_new_happy_semantics) d.addCallback(self._test_introweb) d.addCallback(self.log, "starting publish") d.addCallback(self._do_publish1) @@ -1120,6 +1126,11 @@ class SystemTest(SystemTestMixin, unittest.TestCase): d.addCallback(self.failUnlessEqual, "new.txt contents") # and again with something large enough to use multiple segments, # and hopefully trigger pauseProducing too + def _new_happy_semantics(ign): + for c in self.clients: + # these get reset somewhere? Whatever. + c.DEFAULT_ENCODING_PARAMETERS['happy'] = 1 + d.addCallback(_new_happy_semantics) d.addCallback(lambda res: self.PUT(public + "/subdir3/big.txt", "big" * 500000)) # 1.5MB d.addCallback(lambda res: self.GET(public + "/subdir3/big.txt")) diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index d5c7d687..985fc578 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -175,7 +175,7 @@ class FakeBucketWriter: class FakeClient: DEFAULT_ENCODING_PARAMETERS = {"k":25, - "happy": 75, + "happy": 25, "n": 100, "max_segment_size": 1*MiB, } @@ -313,7 +313,7 @@ class GoodServer(unittest.TestCase, ShouldFailMixin, SetDEPMixin): data = self.get_data(SIZE_LARGE) segsize = int(SIZE_LARGE / 2.5) # we want 3 segments, since that's not a power of two - self.set_encoding_parameters(25, 75, 100, segsize) + self.set_encoding_parameters(25, 25, 100, segsize) d = upload_data(self.u, data) d.addCallback(extract_uri) d.addCallback(self._check_large, SIZE_LARGE) @@ -392,6 +392,7 @@ class ServerErrors(unittest.TestCase, ShouldFailMixin, SetDEPMixin): def test_first_error(self): mode = dict([(0,"good")] + [(i,"first-fail") for i in range(1,10)]) self.make_node(mode) + self.set_encoding_parameters(k=25, happy=1, n=50) d = upload_data(self.u, DATA) d.addCallback(extract_uri) d.addCallback(self._check_large, SIZE_LARGE) @@ -509,7 +510,8 @@ class PeerSelection(unittest.TestCase): self.make_client() data = self.get_data(SIZE_LARGE) - self.set_encoding_parameters(50, 75, 100) + # if there are 50 peers, then happy needs to be <= 50 + self.set_encoding_parameters(50, 50, 100) d = upload_data(self.u, data) d.addCallback(extract_uri) d.addCallback(self._check_large, SIZE_LARGE) @@ -555,7 +557,9 @@ class PeerSelection(unittest.TestCase): self.make_client() data = self.get_data(SIZE_LARGE) - self.set_encoding_parameters(100, 150, 200) + # if there are 50 peers, then happy should be no more than 50 if + # we want this to work. + self.set_encoding_parameters(100, 50, 200) d = upload_data(self.u, data) d.addCallback(extract_uri) d.addCallback(self._check_large, SIZE_LARGE) @@ -573,7 +577,7 @@ class PeerSelection(unittest.TestCase): self.make_client(3) data = self.get_data(SIZE_LARGE) - self.set_encoding_parameters(3, 5, 10) + self.set_encoding_parameters(3, 3, 10) d = upload_data(self.u, data) d.addCallback(extract_uri) d.addCallback(self._check_large, SIZE_LARGE) diff --git a/src/allmydata/test/test_web.py b/src/allmydata/test/test_web.py index 77a71fb9..0df0bbed 100644 --- a/src/allmydata/test/test_web.py +++ b/src/allmydata/test/test_web.py @@ -4074,6 +4074,7 @@ class Grid(GridTestMixin, WebErrorMixin, unittest.TestCase, ShouldFailMixin): self.basedir = "web/Grid/exceptions" self.set_up_grid(num_clients=1, num_servers=2) c0 = self.g.clients[0] + c0.DEFAULT_ENCODING_PARAMETERS['happy'] = 2 self.fileurls = {} DATA = "data" * 100 d = c0.create_dirnode()