mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-21 05:53:12 +00:00
storage_client.py: clean up test_add_server/test_add_descriptor, remove .test_servers
This commit is contained in:
parent
cba3de04a4
commit
9b9ea3f739
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user