From e2a5751d02dc1aea393c7515d96d84ad8f5d1d53 Mon Sep 17 00:00:00 2001 From: meejah Date: Tue, 8 Aug 2017 10:42:11 -0600 Subject: [PATCH] at least use random port --- src/allmydata/test/test_node.py | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index cd19eea45..bb74c41c0 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -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) @@ -70,18 +74,29 @@ class TestCase(testutil.SignalMixin, unittest.TestCase): 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"