From: Brian Warner Date: Sun, 27 Feb 2011 02:10:56 +0000 (-0700) Subject: storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers X-Git-Url: https://git.rkrishnan.org/%5B/frontends/index.php?a=commitdiff_plain;h=9b9ea3f73995633b8b98fcc29be93df0467c9c3b;p=tahoe-lafs%2Ftahoe-lafs.git storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers --- diff --git a/src/allmydata/storage_client.py b/src/allmydata/storage_client.py index e1b3f553..8f82097f 100644 --- a/src/allmydata/storage_client.py +++ b/src/allmydata/storage_client.py @@ -71,15 +71,16 @@ class StorageFarmBroker: # own Reconnector, and will give us a RemoteReference when we ask # them for it. self.servers = {} - # self.test_servers are statically configured from unit tests - self.test_servers = {} # serverid -> rref self.introducer_client = None # these two are used in unit tests - def test_add_server(self, serverid, rref): - self.test_servers[serverid] = rref - def test_add_descriptor(self, serverid, dsc): - self.servers[serverid] = dsc + def test_add_rref(self, serverid, rref): + s = NativeStorageServer(serverid, {}) + s.rref = rref + self.servers[serverid] = s + + def test_add_server(self, serverid, s): + self.servers[serverid] = s def use_introducer(self, introducer_client): self.introducer_client = ic = introducer_client @@ -124,7 +125,6 @@ class StorageFarmBroker: def get_all_serverids(self): serverids = set() - serverids.update(self.test_servers.keys()) serverids.update(self.servers.keys()) return frozenset(serverids) @@ -133,13 +133,7 @@ class StorageFarmBroker: if s.get_rref()]) def get_known_servers(self): - servers = [] - for serverid,rref in self.test_servers.items(): - s = NativeStorageServer(serverid, {}) - s.rref = rref - servers.append(s) - servers.extend(self.servers.values()) - return sorted(servers, key=lambda s: s.get_serverid()) + return sorted(self.servers.values(), key=lambda s: s.get_serverid()) def get_nickname_for_serverid(self, serverid): if serverid in self.servers: diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index d1cf86f7..b302c10d 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -28,8 +28,8 @@ class WebResultsRendering(unittest.TestCase, WebRenderingMixin): "my-version": "ver", "oldest-supported": "oldest", } - dsc = NativeStorageServer(peerid, ann_d) - sb.test_add_descriptor(peerid, dsc) + s = NativeStorageServer(peerid, ann_d) + sb.test_add_server(peerid, s) c = FakeClient() c.storage_broker = sb return c diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index b0aea3d5..62ce712c 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -129,11 +129,11 @@ class Basic(testutil.ReallyEqualMixin, unittest.TestCase): def test_permute(self): sb = StorageFarmBroker(None, True) for k in ["%d" % i for i in range(5)]: - sb.test_add_server(k, "rref") + sb.test_add_rref(k, "rref") self.failUnlessReallyEqual(self._permute(sb, "one"), ['3','1','0','4','2']) self.failUnlessReallyEqual(self._permute(sb, "two"), ['0','4','2','1','3']) - sb.test_servers.clear() + sb.servers.clear() self.failUnlessReallyEqual(self._permute(sb, "one"), []) def test_versions(self): diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index 0f49dced..907d497a 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -188,7 +188,7 @@ def make_storagebroker(s=None, num_peers=10): storage_broker = StorageFarmBroker(None, True) for peerid in peerids: fss = FakeStorageServer(peerid, s) - storage_broker.test_add_server(peerid, fss) + storage_broker.test_add_rref(peerid, fss) return storage_broker def make_nodemaker(s=None, num_peers=10): diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index 11259324..e7368604 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -196,8 +196,8 @@ class FakeClient: peers = [ ("%20d"%fakeid, FakeStorageServer(mode[fakeid])) for fakeid in range(self.num_servers) ] self.storage_broker = StorageFarmBroker(None, permute_peers=True) - for (serverid, server) in peers: - self.storage_broker.test_add_server(serverid, server) + for (serverid, rref) in peers: + self.storage_broker.test_add_rref(serverid, rref) self.last_peers = [p[1] for p in peers] def log(self, *args, **kwargs):