mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-19 03:06:33 +00:00
And for the NoNetworkGrid clients' web port config
This commit is contained in:
parent
2898b2477b
commit
4265cc8afd
@ -32,7 +32,10 @@ from allmydata.util import fileutil, idlib, hashutil
|
||||
from allmydata.util.hashutil import permute_server_hash
|
||||
from allmydata.util.fileutil import abspath_expanduser_unicode
|
||||
from allmydata.interfaces import IStorageBroker, IServer
|
||||
from .common import TEST_RSA_KEY_SIZE
|
||||
from .common import (
|
||||
TEST_RSA_KEY_SIZE,
|
||||
SameProcessStreamEndpointAssigner,
|
||||
)
|
||||
|
||||
|
||||
class IntentionalError(Exception):
|
||||
@ -267,9 +270,10 @@ class SimpleStats:
|
||||
return ret
|
||||
|
||||
class NoNetworkGrid(service.MultiService):
|
||||
def __init__(self, basedir, num_clients=1, num_servers=10,
|
||||
client_config_hooks={}):
|
||||
def __init__(self, basedir, num_clients, num_servers,
|
||||
client_config_hooks, port_assigner):
|
||||
service.MultiService.__init__(self)
|
||||
self.port_assigner = port_assigner
|
||||
self.basedir = basedir
|
||||
fileutil.make_dirs(basedir)
|
||||
|
||||
@ -298,10 +302,12 @@ class NoNetworkGrid(service.MultiService):
|
||||
|
||||
tahoe_cfg_path = os.path.join(clientdir, "tahoe.cfg")
|
||||
if write_config:
|
||||
from twisted.internet import reactor
|
||||
_, port_endpoint = self.port_assigner.assign(reactor)
|
||||
f = open(tahoe_cfg_path, "w")
|
||||
f.write("[node]\n")
|
||||
f.write("nickname = client-%d\n" % i)
|
||||
f.write("web.port = tcp:0:interface=127.0.0.1\n")
|
||||
f.write("web.port = {}\n".format(port_endpoint))
|
||||
f.write("[storage]\n")
|
||||
f.write("enabled = false\n")
|
||||
f.close()
|
||||
@ -409,10 +415,15 @@ class GridTestMixin(object):
|
||||
def set_up_grid(self, num_clients=1, num_servers=10,
|
||||
client_config_hooks={}, oneshare=False):
|
||||
# self.basedir must be set
|
||||
port_assigner = SameProcessStreamEndpointAssigner()
|
||||
port_assigner.setUp()
|
||||
self.addCleanup(port_assigner.tearDown)
|
||||
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,
|
||||
port_assigner=port_assigner,
|
||||
)
|
||||
self.g.setServiceParent(self.s)
|
||||
if oneshare:
|
||||
c = self.get_client(0)
|
||||
|
@ -7,23 +7,37 @@ from allmydata.test.no_network import NoNetworkGrid
|
||||
from allmydata.immutable.upload import Data
|
||||
from allmydata.util.consumer import download_to_data
|
||||
|
||||
from .common import (
|
||||
SameProcessStreamEndpointAssigner,
|
||||
)
|
||||
|
||||
class Harness(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.s = service.MultiService()
|
||||
self.s.startService()
|
||||
self.addCleanup(self.s.stopService)
|
||||
self.port_assigner = SameProcessStreamEndpointAssigner()
|
||||
self.port_assigner.setUp()
|
||||
self.addCleanup(self.port_assigner.tearDown)
|
||||
|
||||
def tearDown(self):
|
||||
return self.s.stopService()
|
||||
def grid(self, basedir):
|
||||
return NoNetworkGrid(
|
||||
basedir,
|
||||
num_clients=1,
|
||||
num_servers=10,
|
||||
client_config_hooks={},
|
||||
port_assigner=self.port_assigner,
|
||||
)
|
||||
|
||||
def test_create(self):
|
||||
basedir = "no_network/Harness/create"
|
||||
g = NoNetworkGrid(basedir)
|
||||
g = self.grid(basedir)
|
||||
g.startService()
|
||||
return g.stopService()
|
||||
|
||||
def test_upload(self):
|
||||
basedir = "no_network/Harness/upload"
|
||||
g = NoNetworkGrid(basedir)
|
||||
g = self.grid(basedir)
|
||||
g.setServiceParent(self.s)
|
||||
|
||||
c0 = g.clients[0]
|
||||
@ -39,4 +53,3 @@ class Harness(unittest.TestCase):
|
||||
d.addCallback(_check)
|
||||
|
||||
return d
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user