[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] More selective options for running integ tests



commit 9fb52210494558a63d494d5ceab7a01282e8f88b
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Tue Nov 22 09:53:30 2011 -0800

    More selective options for running integ tests
    
    Providing targets for all of the tor connection configurations so the user can
    opt for any combination of targets. Previously you needed to run the
    'CONNECTION' target which exercised them all and took around forty seconds to
    run (kinda a pita if you just want to test cookie auth).
---
 run_tests.py       |   31 +++++++++++++++++++++++++------
 test/runner.py     |    6 +++---
 test/testrc.sample |   21 +++++++++++++++++----
 3 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/run_tests.py b/run_tests.py
index 93a715a..3f12a44 100755
--- a/run_tests.py
+++ b/run_tests.py
@@ -47,12 +47,18 @@ INTEG_TESTS = (("stem.types.ControlMessage", test.integ.types.control_message.Te
               )
 
 # Integration tests above the basic suite.
-TARGETS = stem.util.enum.Enum(*[(v, v) for v in ("ONLINE", "RELATIVE", "CONNECTION")])
+TARGETS = stem.util.enum.Enum(*[(v, v) for v in ("ONLINE", "RELATIVE", "CONN_NONE", "CONN_OPEN", "CONN_PASSWORD", "CONN_COOKIE", "CONN_MULTIPLE", "CONN_SOCKET", "CONN_ALL")])
 
 TARGET_ATTR = {
   TARGETS.ONLINE: ("test.integ.target.online", "Includes tests that require network activity."),
   TARGETS.RELATIVE: ("test.integ.target.relative_data_dir", "Uses a relative path for tor's data directory."),
-  TARGETS.CONNECTION: ("test.integ.target.connection", "Runs the suite over multiple connection configurations."),
+  TARGETS.CONN_NONE: ("test.integ.target.connection.none", "Configuration without a way for controllers to connect."),
+  TARGETS.CONN_OPEN: ("test.integ.target.connection.open", "Configuration with an open control port (default)."),
+  TARGETS.CONN_PASSWORD: ("test.integ.target.connection.password", "Configuration with password authentication."),
+  TARGETS.CONN_COOKIE: ("test.integ.target.connection.cookie", "Configuration with an authentication cookie."),
+  TARGETS.CONN_MULTIPLE: ("test.integ.target.connection.multiple", "Configuration with both password and cookie authentication."),
+  TARGETS.CONN_SOCKET: ("test.integ.target.connection.socket", "Configuration with a control socket."),
+  TARGETS.CONN_ALL: ("test.integ.target.connection.all", "Runs integration tests for all connection configurations."),
 }
 
 HELP_MSG = """Usage runTests.py [OPTION]
@@ -191,13 +197,26 @@ if __name__ == '__main__':
     integ_runner = test.runner.get_runner()
     stem_logger = logging.getLogger("stem")
     
-    # just a single integ run with the default connection method unless we've
-    # set the 'CONNECTION' target, in which case we run 'em all
+    # queue up all of the tor configurations we want to run the integration
+    # tests on
     
-    if test_config.get("test.integ.target.connection", False):
+    connection_types = []
+    
+    if test_config.get("test.integ.target.connection.all", False):
       connection_types = list(test.runner.TorConnection)
     else:
-      connection_types = [test.runner.DEFAULT_TOR_CONNECTION]
+      conn_type_mappings = {
+        "none": test.runner.TorConnection.NONE,
+        "open": test.runner.TorConnection.OPEN,
+        "password": test.runner.TorConnection.PASSWORD,
+        "cookie": test.runner.TorConnection.COOKIE,
+        "multiple": test.runner.TorConnection.MULTIPLE,
+        "socket": test.runner.TorConnection.SOCKET,
+      }
+      
+      for type_key in conn_type_mappings:
+        if test_config.get("test.integ.target.connection.%s" % type_key, False):
+          connection_types.append(conn_type_mappings[type_key])
     
     for connection_type in connection_types:
       try:
diff --git a/test/runner.py b/test/runner.py
index b9b77f4..e1c9f0b 100644
--- a/test/runner.py
+++ b/test/runner.py
@@ -42,8 +42,8 @@ DEFAULT_CONFIG = {
 # Methods for connecting to tor. General integration tests only run with the
 # DEFAULT_TOR_CONNECTION, but expanded integ tests will run with all of them.
 
-TorConnection = stem.util.enum.Enum("NONE", "NO_AUTH", "PASSWORD", "COOKIE", "MULTIPLE", "SOCKET")
-DEFAULT_TOR_CONNECTION = TorConnection.NO_AUTH
+TorConnection = stem.util.enum.Enum("NONE", "OPEN", "PASSWORD", "COOKIE", "MULTIPLE", "SOCKET")
+DEFAULT_TOR_CONNECTION = TorConnection.OPEN
 
 STATUS_ATTR = (term.Color.BLUE, term.Attr.BOLD)
 SUBSTATUS_ATTR = (term.Color.BLUE, )
@@ -75,7 +75,7 @@ OPT_SOCKET = "ControlSocket %s" % CONTROL_SOCKET_PATH
 
 CONNECTION_OPTS = {
   TorConnection.NONE: [],
-  TorConnection.NO_AUTH: [OPT_PORT],
+  TorConnection.OPEN: [OPT_PORT],
   TorConnection.PASSWORD: [OPT_PORT, OPT_PASSWORD],
   TorConnection.COOKIE: [OPT_PORT, OPT_COOKIE],
   TorConnection.MULTIPLE: [OPT_PORT, OPT_PASSWORD, OPT_COOKIE],
diff --git a/test/testrc.sample b/test/testrc.sample
index c7ae7d1..28874e9 100644
--- a/test/testrc.sample
+++ b/test/testrc.sample
@@ -19,13 +19,26 @@
 # test.integ.target.relative_data_dir
 #   Uses a relative path for the tor data directory if set.
 #
-# test.integ.target.connection
-#   Runs integration tests for multiple connection and authentiction methods if
-#   true. Otherwise they'll only be run for a single connection type.
+# test.integ.target.connection.none
+# test.integ.target.connection.open
+# test.integ.target.connection.password
+# test.integ.target.connection.cookie
+# test.integ.target.connection.muiltipe
+# test.integ.target.connection.socket
+# test.integ.target.connection.all
+#   Runs the integration test suite for all of the given connection and
+#   authentication configurations. If the 'all' option is set then the other
+#   flags are ignored.
 
 test.integ.test_directory ./test/data
 test.integ.log ./test/data/log
 test.integ.target.online false
 test.integ.target.relative_data_dir false
-test.integ.target.connection false
+test.integ.target.connection.none false
+test.integ.target.connection.open true
+test.integ.target.connection.password false
+test.integ.target.connection.cookie false
+test.integ.target.connection.muiltipe false
+test.integ.target.connection.socket false
+test.integ.target.connection.all false
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits