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
Add an integration test to check a runtime option fails.
parent 1d836ec5
...@@ -173,10 +173,10 @@ def set_torrc_runtime_options(controller): ...@@ -173,10 +173,10 @@ def set_torrc_runtime_options(controller):
"""Set torrc options at runtime.""" """Set torrc options at runtime."""
try: try:
controller.set_options(TORRC_RUNTIME_OPTIONS) controller.set_options(TORRC_RUNTIME_OPTIONS)
except (ControllerError, InvalidArguments, InvalidRequest) as e: # Only the first option that fails will be logged here.
log.exception("Error trying to launch tor: %s. " # Just log stem's exceptions.
"Maybe the tor directory is being used by other " except (ControllerError, InvalidRequest, InvalidArguments) as e:
"sbws instance?", e) log.exception(e)
exit(1) exit(1)
def launch_tor(conf): def launch_tor(conf):
...@@ -10,3 +10,11 @@ def test_set_torrc_runtime_option_succesful(persistent_launch_tor): ...@@ -10,3 +10,11 @@ def test_set_torrc_runtime_option_succesful(persistent_launch_tor):
controller = persistent_launch_tor controller = persistent_launch_tor
runtime_options = controller.get_conf_map(['__LeaveStreamsUnattached']) runtime_options = controller.get_conf_map(['__LeaveStreamsUnattached'])
assert runtime_options == {'__LeaveStreamsUnattached': ['1']} assert runtime_options == {'__LeaveStreamsUnattached': ['1']}
def test_set_torrc_runtime_invalidrequest_option_fail(persistent_launch_tor):
controller = persistent_launch_tor
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