mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 11:16:24 +00:00
test/no_network: do startService on the storage servers, make it easier to customize the storage servers
This commit is contained in:
parent
ef4ff21ae7
commit
e357b8a679
@ -148,12 +148,8 @@ class NoNetworkGrid(service.MultiService):
|
|||||||
self.clients = []
|
self.clients = []
|
||||||
|
|
||||||
for i in range(num_servers):
|
for i in range(num_servers):
|
||||||
serverid = hashutil.tagged_hash("serverid", str(i))[:20]
|
ss = self.make_server(i)
|
||||||
serverdir = os.path.join(basedir, "servers",
|
self.add_server(i, ss)
|
||||||
idlib.shortnodeid_b2a(serverid))
|
|
||||||
fileutil.make_dirs(serverdir)
|
|
||||||
ss = StorageServer(serverdir, serverid)
|
|
||||||
self.add_server(i, serverid, ss)
|
|
||||||
|
|
||||||
for i in range(num_clients):
|
for i in range(num_clients):
|
||||||
clientid = hashutil.tagged_hash("clientid", str(i))[:20]
|
clientid = hashutil.tagged_hash("clientid", str(i))[:20]
|
||||||
@ -180,12 +176,21 @@ class NoNetworkGrid(service.MultiService):
|
|||||||
c.setServiceParent(self)
|
c.setServiceParent(self)
|
||||||
self.clients.append(c)
|
self.clients.append(c)
|
||||||
|
|
||||||
def add_server(self, i, serverid, ss):
|
def make_server(self, i):
|
||||||
# TODO: ss.setServiceParent(self), but first deal with the fact that
|
serverid = hashutil.tagged_hash("serverid", str(i))[:20]
|
||||||
# all StorageServers are named 'storage'. At the moment, Storage
|
serverdir = os.path.join(self.basedir, "servers",
|
||||||
# doesn't really need to be startService'd, but it will in the
|
idlib.shortnodeid_b2a(serverid))
|
||||||
# future.
|
fileutil.make_dirs(serverdir)
|
||||||
#ss.setServiceParent(self)
|
ss = StorageServer(serverdir, serverid)
|
||||||
|
return ss
|
||||||
|
|
||||||
|
def add_server(self, i, ss):
|
||||||
|
# to deal with the fact that all StorageServers are named 'storage',
|
||||||
|
# we interpose a middleman
|
||||||
|
middleman = service.MultiService()
|
||||||
|
middleman.setServiceParent(self)
|
||||||
|
ss.setServiceParent(middleman)
|
||||||
|
serverid = ss.my_nodeid
|
||||||
self.servers_by_number[i] = ss
|
self.servers_by_number[i] = ss
|
||||||
self.servers_by_id[serverid] = wrap(ss, "storage")
|
self.servers_by_id[serverid] = wrap(ss, "storage")
|
||||||
self.all_servers = frozenset(self.servers_by_id.items())
|
self.all_servers = frozenset(self.servers_by_id.items())
|
||||||
@ -200,9 +205,12 @@ class GridTestMixin:
|
|||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
return self.s.stopService()
|
return self.s.stopService()
|
||||||
|
|
||||||
def set_up_grid(self, num_clients=1, client_config_hooks={}):
|
def set_up_grid(self, num_clients=1, num_servers=10,
|
||||||
|
client_config_hooks={}):
|
||||||
# self.basedir must be set
|
# self.basedir must be set
|
||||||
self.g = NoNetworkGrid(self.basedir, num_clients=num_clients,
|
self.g = NoNetworkGrid(self.basedir,
|
||||||
|
num_clients=num_clients,
|
||||||
|
num_servers=num_servers,
|
||||||
client_config_hooks=client_config_hooks)
|
client_config_hooks=client_config_hooks)
|
||||||
self.g.setServiceParent(self.s)
|
self.g.setServiceParent(self.s)
|
||||||
self.client_webports = [c.getServiceNamed("webish").listener._port.getHost().port
|
self.client_webports = [c.getServiceNamed("webish").listener._port.getHost().port
|
||||||
|
Loading…
Reference in New Issue
Block a user