verify behavior if there is a poorly behaved plugin

This commit is contained in:
Jean-Paul Calderone 2019-06-19 12:40:34 -04:00
parent fd9ae24149
commit 1c68157c1f
2 changed files with 32 additions and 0 deletions

View File

@ -42,6 +42,9 @@ class DummyStorage(object):
name = attr.ib()
def get_storage_server(self, configuration, get_anonymous_storage_server):
if u"invalid" in configuration:
raise Exception("The plugin is unhappy.")
announcement = {u"value": configuration.get(u"some", u"default-value")}
storage_server = DummyStorageServer(get_anonymous_storage_server)
return succeed(

View File

@ -27,9 +27,11 @@ from testtools.matchers import (
MatchesListwise,
MatchesDict,
MatchesStructure,
Always,
)
from testtools.twistedsupport import (
succeeded,
failed,
)
import allmydata
@ -1320,3 +1322,30 @@ introducer.furl = pb://abcde@nowhere/fake
]),
)),
)
def test_broken_storage_plugin(self):
"""
A storage plugin that raises an exception from ``get_storage_server``
causes ``client.create_client_from_config`` to return ``Deferred``
that fails.
"""
self.useFixture(UseTestPlugins())
config = client.config_from_string(
self.basedir,
u"tub.port",
self.get_config(
storage_enabled=True,
more_storage=b"plugins=tahoe-lafs-dummy-v1",
more_sections=(
b"[storageserver.plugins.tahoe-lafs-dummy-v1]\n"
# This will make it explode on instantiation.
b"invalid = configuration\n"
)
),
)
self.assertThat(
client.create_client_from_config(config, introducer_factory=MemoryIntroducerClient),
failed(Always()),
)