[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] stem: log stem's exceptions setting runtime torrc
commit 6c8639d2cc0517c82882296b4693fec46f14c402
Author: juga0 <juga@xxxxxxxxxx>
Date: Fri Dec 7 10:28:03 2018 +0000
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.
---
sbws/util/stem.py | 8 ++++----
tests/integration/util/test_stem.py | 8 ++++++++
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/sbws/util/stem.py b/sbws/util/stem.py
index ead812b..359e020 100644
--- a/sbws/util/stem.py
+++ b/sbws/util/stem.py
@@ -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):
diff --git a/tests/integration/util/test_stem.py b/tests/integration/util/test_stem.py
index 33fee81..51a425a 100644
--- a/tests/integration/util/test_stem.py
+++ b/tests/integration/util/test_stem.py
@@ -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
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits