Commit 6c8639d2 authored by juga  's avatar juga
Browse files

stem: log stem's exceptions setting runtime torrc

The log message might not correspond to the reason.
Only the first one that fails will be logged, but not refactoring
here.
Add an integration test to check a runtime option fails.
parent 1d836ec5
......@@ -173,10 +173,10 @@ def set_torrc_runtime_options(controller):
"""Set torrc options at runtime."""
try:
controller.set_options(TORRC_RUNTIME_OPTIONS)
except (ControllerError, InvalidArguments, InvalidRequest) as e:
log.exception("Error trying to launch tor: %s. "
"Maybe the tor directory is being used by other "
"sbws instance?", e)
# Only the first option that fails will be logged here.
# Just log stem's exceptions.
except (ControllerError, InvalidRequest, InvalidArguments) as e:
log.exception(e)
exit(1)
def launch_tor(conf):
......
......@@ -10,3 +10,11 @@ def test_set_torrc_runtime_option_succesful(persistent_launch_tor):
controller = persistent_launch_tor
runtime_options = controller.get_conf_map(['__LeaveStreamsUnattached'])
assert runtime_options == {'__LeaveStreamsUnattached': ['1']}
def test_set_torrc_runtime_invalidrequest_option_fail(persistent_launch_tor):
controller = persistent_launch_tor
try:
controller.set_conf('ControlSocket', '/tmp/dummy')
except stem_utils.InvalidRequest as e:
assert "Unable to set option" in e.message
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment