Merge branch '2862-introducers'

closes tahoe-lafs/tahoe-lafs#391
This commit is contained in:
Brian Warner 2017-01-08 23:00:05 -08:00
commit 8913ebfaf7
4 changed files with 42 additions and 5 deletions

View File

@ -919,8 +919,10 @@ introducer.furl``. To use two or more Introducers, choose a locally-unique
``private/introducers.yaml`` like this::
introducers:
petname2: furl = FURL2
petname3: furl = FURL3
petname2:
furl: FURL2
petname3:
furl: FURL3
Servers will announce themselves to all configured introducers. Clients will
merge the announcements they receive from all introducers. Nothing will

View File

@ -265,11 +265,12 @@ class Client(node.Node, pollmixin.PollMixin):
for petname, introducer in introducers.items():
introducer_cache_filepath = FilePath(os.path.join(self.basedir, "private", "introducer_{}_cache.yaml".format(petname)))
ic = IntroducerClient(self.tub, introducer['furl'],
ic = IntroducerClient(self.tub, introducer['furl'].encode("ascii"),
self.nickname,
str(allmydata.__full_version__),
str(self.OLDEST_SUPPORTED_VERSION),
self.get_app_versions(), self._sequencer, introducer_cache_filepath)
self.get_app_versions(), self._sequencer,
introducer_cache_filepath)
self.introducer_clients.append(ic)
self.introducer_furls.append(introducer['furl'])
ic.setServiceParent(self)

View File

@ -92,6 +92,20 @@ class MultiIntroTests(unittest.TestCase):
e = self.assertRaises(ValueError, Client, self.basedir)
self.assertEquals(str(e), "'default' introducer furl cannot be specified in introducers.yaml; please fix impossible configuration.")
SIMPLE_YAML = """
introducers:
one:
furl: furl1
"""
# this format was recommended in docs/configuration.rst in 1.12.0, but it
# isn't correct (the "furl = furl1" line is recorded as the string value of
# the ["one"] key, instead of being parsed as a single-key dictionary).
EQUALS_YAML = """
introducers:
one: furl = furl1
"""
class NoDefault(unittest.TestCase):
def setUp(self):
# setup tahoe.cfg and basedir/private/introducers
@ -119,6 +133,17 @@ class NoDefault(unittest.TestCase):
tahoe_cfg_furl = myclient.introducer_furls[0]
self.assertEquals(tahoe_cfg_furl, 'furl1')
def test_real_yaml(self):
self.yaml_path.setContent(SIMPLE_YAML)
myclient = Client(self.basedir)
tahoe_cfg_furl = myclient.introducer_furls[0]
self.assertEquals(tahoe_cfg_furl, 'furl1')
def test_invalid_equals_yaml(self):
self.yaml_path.setContent(EQUALS_YAML)
e = self.assertRaises(TypeError, Client, self.basedir)
self.assertEquals(str(e), "string indices must be integers")
def test_introducerless(self):
connections = {'introducers': {} }
self.yaml_path.setContent(yamlutil.safe_dump(connections))

View File

@ -477,7 +477,9 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
f.close()
config = "[client]\n"
config += "introducer.furl = %s\n" % self.introducer_furl
if i != 1:
# clients[1] uses private/introducers.yaml, not tahoe.cfg
config += "introducer.furl = %s\n" % self.introducer_furl
if self.stats_gatherer_furl:
config += "stats_gatherer.furl = %s\n" % self.stats_gatherer_furl
@ -496,6 +498,13 @@ class SystemTestMixin(pollmixin.PollMixin, testutil.StallMixin):
config += "timeout.keepalive = 600\n"
config += "[helper]\n"
config += "enabled = True\n"
elif i == 1:
# clients[1] uses private/introducers.yaml, not tahoe.cfg
iyaml = ("introducers:\n"
" petname2:\n"
" furl: %s\n") % self.introducer_furl
iyaml_fn = os.path.join(basedir, "private", "introducers.yaml")
fileutil.write(iyaml_fn, iyaml)
elif i == 3:
# clients[3] runs a webserver and uses a helper
config += nodeconfig