Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a random port #435

Merged
merged 1 commit into from Aug 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/allmydata/test/test_node.py
Expand Up @@ -26,10 +26,14 @@ class TestNode(Node):
PORTNUMFILE='DEFAULT_PORTNUMFILE_BLANK'

class TestCase(testutil.SignalMixin, unittest.TestCase):

@defer.inlineCallbacks
def setUp(self):
testutil.SignalMixin.setUp(self)
self.parent = LoggingMultiService()
self.parent.startService()
self._available_port = yield iputil.allocate_tcp_port()

def tearDown(self):
log.msg("%s.tearDown" % self.__class__.__name__)
testutil.SignalMixin.tearDown(self)
Expand Down Expand Up @@ -70,18 +74,29 @@ def test_location2(self):

def test_location_not_set(self):
"""Checks the autogenerated furl when tub.location is not set."""
return self._test_location(basedir="test_node/test_location3",
expected_addresses=["127.0.0.1:1234", "192.0.2.0:1234"],
tub_port=1234,
local_addresses=["127.0.0.1", "192.0.2.0"])
return self._test_location(
basedir="test_node/test_location3",
expected_addresses=[
"127.0.0.1:{}".format(self._available_port),
"192.0.2.0:{}".format(self._available_port),
],
tub_port=self._available_port,
local_addresses=["127.0.0.1", "192.0.2.0"],
)

def test_location_auto_and_explicit(self):
"""Checks the autogenerated furl when tub.location contains 'AUTO'."""
return self._test_location(basedir="test_node/test_location4",
expected_addresses=["127.0.0.1:1234", "192.0.2.0:1234", "example.com:4321"],
tub_port=1234,
tub_location="AUTO,example.com:4321",
local_addresses=["127.0.0.1", "192.0.2.0", "example.com:4321"])
return self._test_location(
basedir="test_node/test_location4",
expected_addresses=[
"127.0.0.1:{}".format(self._available_port),
"192.0.2.0:{}".format(self._available_port),
"example.com:4321",
],
tub_port=self._available_port,
tub_location="AUTO,example.com:{}".format(self._available_port),
local_addresses=["127.0.0.1", "192.0.2.0", "example.com:4321"],
)

def test_tahoe_cfg_utf8(self):
basedir = "test_node/test_tahoe_cfg_utf8"
Expand Down