mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-01 16:58:10 +00:00
Teach UseNode to use a port assigner for tub.port
Then use it to assign ports for tub.port unless the caller supplied their own value.
This commit is contained in:
parent
797e099459
commit
31649890ef
@ -267,8 +267,12 @@ class UseNode(object):
|
|||||||
node_config = attr.ib(default=attr.Factory(dict))
|
node_config = attr.ib(default=attr.Factory(dict))
|
||||||
|
|
||||||
config = attr.ib(default=None)
|
config = attr.ib(default=None)
|
||||||
|
reactor = attr.ib(default=None)
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
self.assigner = SameProcessStreamEndpointAssigner()
|
||||||
|
self.assigner.setUp()
|
||||||
|
|
||||||
def format_config_items(config):
|
def format_config_items(config):
|
||||||
return "\n".join(
|
return "\n".join(
|
||||||
" = ".join((key, value))
|
" = ".join((key, value))
|
||||||
@ -292,6 +296,23 @@ class UseNode(object):
|
|||||||
"default",
|
"default",
|
||||||
self.introducer_furl,
|
self.introducer_furl,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
node_config = self.node_config.copy()
|
||||||
|
if "tub.port" not in node_config:
|
||||||
|
if "tub.location" in node_config:
|
||||||
|
raise ValueError(
|
||||||
|
"UseNode fixture does not support specifying tub.location "
|
||||||
|
"without tub.port"
|
||||||
|
)
|
||||||
|
|
||||||
|
# Don't use the normal port auto-assignment logic. It produces
|
||||||
|
# collisions and makes tests fail spuriously.
|
||||||
|
tub_location, tub_endpoint = self.assigner.assign(self.reactor)
|
||||||
|
node_config.update({
|
||||||
|
"tub.port": tub_endpoint,
|
||||||
|
"tub.location": tub_location,
|
||||||
|
})
|
||||||
|
|
||||||
self.config = config_from_string(
|
self.config = config_from_string(
|
||||||
self.basedir.asTextMode().path,
|
self.basedir.asTextMode().path,
|
||||||
"tub.port",
|
"tub.port",
|
||||||
@ -304,7 +325,7 @@ storage.plugins = {storage_plugin}
|
|||||||
{plugin_config_section}
|
{plugin_config_section}
|
||||||
""".format(
|
""".format(
|
||||||
storage_plugin=self.storage_plugin,
|
storage_plugin=self.storage_plugin,
|
||||||
node_config=format_config_items(self.node_config),
|
node_config=format_config_items(node_config),
|
||||||
plugin_config_section=plugin_config_section,
|
plugin_config_section=plugin_config_section,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -316,7 +337,7 @@ storage.plugins = {storage_plugin}
|
|||||||
)
|
)
|
||||||
|
|
||||||
def cleanUp(self):
|
def cleanUp(self):
|
||||||
pass
|
self.assigner.tearDown()
|
||||||
|
|
||||||
|
|
||||||
def getDetails(self):
|
def getDetails(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user