From: Daira Hopwood Date: Mon, 9 Feb 2015 19:48:06 +0000 (+0000) Subject: Add tests for combining autodetected and statically configured locations. refs #754 X-Git-Tag: allmydata-tahoe-1.10.1a1~70^2~2 X-Git-Url: https://git.rkrishnan.org/%5B/frontends/flags/%22doc.html/htmlfontify-example.html?a=commitdiff_plain;h=759512da28fc1b4ae3f80a20229dc1155c324ab6;p=tahoe-lafs%2Ftahoe-lafs.git Add tests for combining autodetected and statically configured locations. refs #754 Signed-off-by: Daira Hopwood --- diff --git a/src/allmydata/test/test_node.py b/src/allmydata/test/test_node.py index cf7d0f57..ef1abe06 100644 --- a/src/allmydata/test/test_node.py +++ b/src/allmydata/test/test_node.py @@ -9,7 +9,7 @@ from mock import patch from foolscap.api import flushEventualQueue from twisted.application import service from allmydata.node import Node, formatTimeTahoeStyle, MissingConfigEntry -from allmydata.util import fileutil +from allmydata.util import fileutil, iputil import allmydata.test.common_util as testutil class LoggingMultiService(service.MultiService): @@ -33,7 +33,7 @@ class TestCase(testutil.SignalMixin, unittest.TestCase): d.addCallback(flushEventualQueue) return d - def _test_location(self, basedir, expected_addresses, tub_port=None, tub_location=None): + def _test_location(self, basedir, expected_addresses, tub_port=None, tub_location=None, local_addresses=None): fileutil.make_dirs(basedir) f = open(os.path.join(basedir, 'tahoe.cfg'), 'wt') f.write("[node]\n") @@ -43,6 +43,9 @@ class TestCase(testutil.SignalMixin, unittest.TestCase): f.write("tub.location = %s\n" % (tub_location,)) f.close() + if local_addresses: + self.patch(iputil, 'get_local_addresses_async', lambda target=None: defer.succeed(local_addresses)) + n = TestNode(basedir) n.setServiceParent(self.parent) d = n.when_tub_ready() @@ -65,6 +68,20 @@ class TestCase(testutil.SignalMixin, unittest.TestCase): expected_addresses=["192.0.2.0:1234", "example.org:8091"], tub_location="192.0.2.0:1234,example.org:8091") + 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"]) + + 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"]) def test_tahoe_cfg_utf8(self): basedir = "test_node/test_tahoe_cfg_utf8"