[nyx/master] Move log util tests to their own module

commit e3797bd6bcef5347f118e0208d9ed95b08b42fad Author: Damian Johnson <atagar@torproject.org> Date: Sun Apr 12 14:37:55 2015 -0700 Move log util tests to their own module About to add some more so better to group them in a module. --- test/util/__init__.py | 2 +- test/util/data/malformed_date | 21 ---------- test/util/data/malformed_line | 21 ---------- test/util/data/malformed_runlevel | 21 ---------- test/util/data/multiple_tor_instances | 33 ---------------- test/util/data/tor_log | 21 ---------- test/util/log/__init__.py | 7 ++++ test/util/log/data/malformed_date | 21 ++++++++++ test/util/log/data/malformed_line | 21 ++++++++++ test/util/log/data/malformed_runlevel | 21 ++++++++++ test/util/log/data/multiple_tor_instances | 33 ++++++++++++++++ test/util/log/data/tor_log | 21 ++++++++++ test/util/log/read_tor_log.py | 59 +++++++++++++++++++++++++++++ test/util/read_tor_log.py | 59 ----------------------------- 14 files changed, 184 insertions(+), 177 deletions(-) diff --git a/test/util/__init__.py b/test/util/__init__.py index cc6042f..a03ad4f 100644 --- a/test/util/__init__.py +++ b/test/util/__init__.py @@ -2,4 +2,4 @@ Unit tests for nyx's utilities. """ -__all__ = ['bandwidth_from_state'] +__all__ = ['log', 'tracker'] diff --git a/test/util/data/empty_file b/test/util/data/empty_file deleted file mode 100644 index e69de29..0000000 diff --git a/test/util/data/malformed_date b/test/util/data/malformed_date deleted file mode 100644 index 712149d..0000000 --- a/test/util/data/malformed_date +++ /dev/null @@ -1,21 +0,0 @@ -Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. -Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting -Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors -Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors -Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors -Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network -Zed 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit -Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. -Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done -Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/data/malformed_line b/test/util/data/malformed_line deleted file mode 100644 index ac9a367..0000000 --- a/test/util/data/malformed_line +++ /dev/null @@ -1,21 +0,0 @@ -Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. -Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting -Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors -Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors -Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors -Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network -Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit -Apr 06 11:03:53.000 -Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done -Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/data/malformed_runlevel b/test/util/data/malformed_runlevel deleted file mode 100644 index dd8810b..0000000 --- a/test/util/data/malformed_runlevel +++ /dev/null @@ -1,21 +0,0 @@ -Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. -Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting -Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors -Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors -Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors -Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network -Apr 06 11:03:52.000 [unrecognized] Bootstrapped 90%: Establishing a Tor circuit -Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. -Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done -Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/data/multiple_tor_instances b/test/util/data/multiple_tor_instances deleted file mode 100644 index 1793ce5..0000000 --- a/test/util/data/multiple_tor_instances +++ /dev/null @@ -1,33 +0,0 @@ -Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. -Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting -Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors -Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors -Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors -Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network -Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit -Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. -Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done -Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. -Apr 06 11:53:54.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening log file. -Apr 06 11:53:54.392 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:53:54.392 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:53:54.392 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:53:54.392 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:53:54.396 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:53:54.396 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:53:54.000 [warn] Your log may contain sensitive information - you're logging more than "notice". Don't log unless it serves an important reason. Overwrite the log afterwards. -Apr 06 11:53:54.000 [debug] tor_disable_debugger_attach(): Attemping to disable debugger attachment to Tor for unprivileged users. -Apr 06 11:53:54.000 [debug] tor_disable_debugger_attach(): Debugger attachment disabled for unprivileged users. -Apr 06 11:53:54.000 [info] tor_lockfile_lock(): Locking "/home/atagar/.tor/lock" -Apr 06 11:53:54.000 [debug] parse_dir_authority_line(): Trusted 100 dirserver at 128.31.0.39:9131 (9695) diff --git a/test/util/data/tor_log b/test/util/data/tor_log deleted file mode 100644 index 0a4464e..0000000 --- a/test/util/data/tor_log +++ /dev/null @@ -1,21 +0,0 @@ -Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. -Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. -Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning -Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. -Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". -Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 -Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 -Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting -Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors -Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors -Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors -Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors -Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network -Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit -Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. -Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done -Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. -Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/log/__init__.py b/test/util/log/__init__.py new file mode 100644 index 0000000..b2fb6f7 --- /dev/null +++ b/test/util/log/__init__.py @@ -0,0 +1,7 @@ +""" +Unit tests for nyx's log utilities. +""" + +__all__ = [ + 'read_tor_log', +] diff --git a/test/util/log/data/empty_file b/test/util/log/data/empty_file new file mode 100644 index 0000000..e69de29 diff --git a/test/util/log/data/malformed_date b/test/util/log/data/malformed_date new file mode 100644 index 0000000..712149d --- /dev/null +++ b/test/util/log/data/malformed_date @@ -0,0 +1,21 @@ +Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. +Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting +Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors +Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors +Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors +Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network +Zed 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit +Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. +Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done +Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/log/data/malformed_line b/test/util/log/data/malformed_line new file mode 100644 index 0000000..ac9a367 --- /dev/null +++ b/test/util/log/data/malformed_line @@ -0,0 +1,21 @@ +Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. +Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting +Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors +Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors +Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors +Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network +Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit +Apr 06 11:03:53.000 +Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done +Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/log/data/malformed_runlevel b/test/util/log/data/malformed_runlevel new file mode 100644 index 0000000..dd8810b --- /dev/null +++ b/test/util/log/data/malformed_runlevel @@ -0,0 +1,21 @@ +Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. +Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting +Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors +Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors +Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors +Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network +Apr 06 11:03:52.000 [unrecognized] Bootstrapped 90%: Establishing a Tor circuit +Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. +Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done +Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/log/data/multiple_tor_instances b/test/util/log/data/multiple_tor_instances new file mode 100644 index 0000000..1793ce5 --- /dev/null +++ b/test/util/log/data/multiple_tor_instances @@ -0,0 +1,33 @@ +Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. +Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting +Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors +Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors +Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors +Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network +Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit +Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. +Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done +Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. +Apr 06 11:53:54.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening log file. +Apr 06 11:53:54.392 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:53:54.392 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:53:54.392 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:53:54.392 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:53:54.396 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:53:54.396 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:53:54.000 [warn] Your log may contain sensitive information - you're logging more than "notice". Don't log unless it serves an important reason. Overwrite the log afterwards. +Apr 06 11:53:54.000 [debug] tor_disable_debugger_attach(): Attemping to disable debugger attachment to Tor for unprivileged users. +Apr 06 11:53:54.000 [debug] tor_disable_debugger_attach(): Debugger attachment disabled for unprivileged users. +Apr 06 11:53:54.000 [info] tor_lockfile_lock(): Locking "/home/atagar/.tor/lock" +Apr 06 11:53:54.000 [debug] parse_dir_authority_line(): Trusted 100 dirserver at 128.31.0.39:9131 (9695) diff --git a/test/util/log/data/tor_log b/test/util/log/data/tor_log new file mode 100644 index 0000000..0a4464e --- /dev/null +++ b/test/util/log/data/tor_log @@ -0,0 +1,21 @@ +Apr 06 11:03:39.000 [notice] Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file. +Apr 06 11:03:39.832 [notice] Tor v0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) running on Linux with Libevent 2.0.16-stable, OpenSSL 1.0.1 and Zlib 1.2.3.4. +Apr 06 11:03:39.832 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning +Apr 06 11:03:39.833 [notice] This version is not a stable Tor release. Expect more bugs than usual. +Apr 06 11:03:39.833 [notice] Read configuration file "/home/atagar/.tor/torrc". +Apr 06 11:03:39.838 [notice] Opening Socks listener on 127.0.0.1:9050 +Apr 06 11:03:39.838 [notice] Opening Control listener on 127.0.0.1:9051 +Apr 06 11:03:39.000 [notice] Bootstrapped 0%: Starting +Apr 06 11:03:42.000 [notice] Bootstrapped 45%: Asking for relay descriptors +Apr 06 11:03:43.000 [notice] Bootstrapped 50%: Loading relay descriptors +Apr 06 11:03:49.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:03:51.000 [notice] Bootstrapped 55%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 63%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 69%: Loading relay descriptors +Apr 06 11:03:51.000 [notice] Bootstrapped 74%: Loading relay descriptors +Apr 06 11:03:52.000 [notice] Bootstrapped 80%: Connecting to the Tor network +Apr 06 11:03:52.000 [notice] Bootstrapped 90%: Establishing a Tor circuit +Apr 06 11:03:53.000 [notice] Tor has successfully opened a circuit. Looks like client functionality is working. +Apr 06 11:03:53.000 [notice] Bootstrapped 100%: Done +Apr 06 11:03:55.000 [notice] New control connection opened from 127.0.0.1. +Apr 06 11:53:46.000 [notice] Interrupt: exiting cleanly. diff --git a/test/util/log/read_tor_log.py b/test/util/log/read_tor_log.py new file mode 100644 index 0000000..7f84c41 --- /dev/null +++ b/test/util/log/read_tor_log.py @@ -0,0 +1,59 @@ +import os +import unittest + +from nyx.util.log import LogEntry, read_tor_log + + +def data_path(filename): + return os.path.join(os.path.dirname(__file__), 'data', filename) + + +class TestReadTorLog(unittest.TestCase): + def test_general_log(self): + entries = list(read_tor_log(data_path('tor_log'))) + self.assertEqual(21, len(entries)) + + self.assertEqual(LogEntry(1333738426, 'NOTICE', 'Interrupt: exiting cleanly.'), entries[0]) + self.assertEqual(LogEntry(1333735419, 'NOTICE', 'Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file.'), entries[-1]) + + def test_with_multiple_tor_instances(self): + entries = list(read_tor_log(data_path('multiple_tor_instances'))) + self.assertEqual(12, len(entries)) + + self.assertEqual(LogEntry(1333738434, 'DEBUG', 'parse_dir_authority_line(): Trusted 100 dirserver at 128.31.0.39:9131 (9695)'), entries[0]) + self.assertEqual(LogEntry(1333738434, 'INFO', 'tor_lockfile_lock(): Locking "/home/atagar/.tor/lock"'), entries[1]) + self.assertEqual(LogEntry(1333738434, 'NOTICE', 'Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening log file.'), entries[-1]) + + def test_with_read_limit(self): + entries = list(read_tor_log(data_path('tor_log'), 5)) + self.assertEqual(5, len(entries)) + self.assertEqual('Interrupt: exiting cleanly.', entries[0].message) + self.assertEqual('Bootstrapped 90%: Establishing a Tor circuit', entries[-1].message) + + def test_with_empty_file(self): + entries = list(read_tor_log(data_path('empty_file'))) + self.assertEqual(0, len(entries)) + + def test_with_missing_path(self): + self.assertRaises(IOError, list, read_tor_log(data_path('no_such_path'))) + + def test_with_malformed_line(self): + try: + list(read_tor_log(data_path('malformed_line'))) + self.fail("Malformed content should've raised a ValueError") + except ValueError as exc: + self.assertTrue("has a line that doesn't match the format we expect: Apr 06 11:03:53.000" in str(exc)) + + def test_with_malformed_runlevel(self): + try: + list(read_tor_log(data_path('malformed_runlevel'))) + self.fail("Malformed content should've raised a ValueError") + except ValueError as exc: + self.assertTrue('has an unrecognized runlevel: [unrecognized]' in str(exc)) + + def test_with_malformed_date(self): + try: + list(read_tor_log(data_path('malformed_date'))) + self.fail("Malformed content should've raised a ValueError") + except ValueError as exc: + self.assertTrue("has a timestamp we don't recognize: Zed 06 11:03:52.000" in str(exc)) diff --git a/test/util/read_tor_log.py b/test/util/read_tor_log.py deleted file mode 100644 index 7f84c41..0000000 --- a/test/util/read_tor_log.py +++ /dev/null @@ -1,59 +0,0 @@ -import os -import unittest - -from nyx.util.log import LogEntry, read_tor_log - - -def data_path(filename): - return os.path.join(os.path.dirname(__file__), 'data', filename) - - -class TestReadTorLog(unittest.TestCase): - def test_general_log(self): - entries = list(read_tor_log(data_path('tor_log'))) - self.assertEqual(21, len(entries)) - - self.assertEqual(LogEntry(1333738426, 'NOTICE', 'Interrupt: exiting cleanly.'), entries[0]) - self.assertEqual(LogEntry(1333735419, 'NOTICE', 'Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening new log file.'), entries[-1]) - - def test_with_multiple_tor_instances(self): - entries = list(read_tor_log(data_path('multiple_tor_instances'))) - self.assertEqual(12, len(entries)) - - self.assertEqual(LogEntry(1333738434, 'DEBUG', 'parse_dir_authority_line(): Trusted 100 dirserver at 128.31.0.39:9131 (9695)'), entries[0]) - self.assertEqual(LogEntry(1333738434, 'INFO', 'tor_lockfile_lock(): Locking "/home/atagar/.tor/lock"'), entries[1]) - self.assertEqual(LogEntry(1333738434, 'NOTICE', 'Tor 0.2.7.0-alpha-dev (git-4247ce99e5d9b7b2) opening log file.'), entries[-1]) - - def test_with_read_limit(self): - entries = list(read_tor_log(data_path('tor_log'), 5)) - self.assertEqual(5, len(entries)) - self.assertEqual('Interrupt: exiting cleanly.', entries[0].message) - self.assertEqual('Bootstrapped 90%: Establishing a Tor circuit', entries[-1].message) - - def test_with_empty_file(self): - entries = list(read_tor_log(data_path('empty_file'))) - self.assertEqual(0, len(entries)) - - def test_with_missing_path(self): - self.assertRaises(IOError, list, read_tor_log(data_path('no_such_path'))) - - def test_with_malformed_line(self): - try: - list(read_tor_log(data_path('malformed_line'))) - self.fail("Malformed content should've raised a ValueError") - except ValueError as exc: - self.assertTrue("has a line that doesn't match the format we expect: Apr 06 11:03:53.000" in str(exc)) - - def test_with_malformed_runlevel(self): - try: - list(read_tor_log(data_path('malformed_runlevel'))) - self.fail("Malformed content should've raised a ValueError") - except ValueError as exc: - self.assertTrue('has an unrecognized runlevel: [unrecognized]' in str(exc)) - - def test_with_malformed_date(self): - try: - list(read_tor_log(data_path('malformed_date'))) - self.fail("Malformed content should've raised a ValueError") - except ValueError as exc: - self.assertTrue("has a timestamp we don't recognize: Zed 06 11:03:52.000" in str(exc))
participants (1)
-
atagar@torproject.org