# 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
def get_all_serverids(self):
serverids = set()
- serverids.update(self.test_servers.keys())
serverids.update(self.servers.keys())
return frozenset(serverids)
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:
"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
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):
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):
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):