Added per-test priority support
In each module, a variable test_prio[] may be added which
is indexed by the test name.
Currently the only application of this is to exclude tests
from the "default" set of tests that are run: If a test
has a negative priority, then it is not run by default. This
addresses the issue with "fill exact match table" taking almost
an hour to run.
diff --git a/tests/basic.py b/tests/basic.py
index 0e91ad5..465a3c9 100644
--- a/tests/basic.py
+++ b/tests/basic.py
@@ -38,6 +38,8 @@
#@var basic_config Local copy of global configuration data
basic_config = None
+test_prio = {}
+
def test_set_init(config):
"""
Set up function for basic test classes
@@ -101,6 +103,8 @@
basic_logger.error("** FAILED ASSERTION: " + msg)
unittest.TestCase.assertTrue(self, cond, msg)
+test_prio["SimpleProtocol"] = 1
+
class SimpleDataPlane(SimpleProtocol):
"""
Root class that sets up the controller and dataplane
diff --git a/tests/caps.py b/tests/caps.py
index 1146cf1..439c434 100644
--- a/tests/caps.py
+++ b/tests/caps.py
@@ -25,6 +25,9 @@
#@var caps_config Local copy of global configuration data
caps_config = None
+# For test priority
+test_prio = {}
+
def test_set_init(config):
"""
Set up function for caps test classes
@@ -93,7 +96,7 @@
while True:
request.match.nw_src += 1
rv = obj.controller.message_send(request)
- do_barrier(obj.controller)
+# do_barrier(obj.controller)
flow_count += 1
if flow_count % count_check == 0:
response, pkt = obj.controller.transact(tstats, timeout=2)
@@ -133,6 +136,7 @@
caps_logger.info("Running " + str(self))
flow_caps_common(self)
+test_prio["FillTableExact"] = -1
class FillTableWC(basic.SimpleProtocol):
"""
diff --git a/tests/oft b/tests/oft
index c851ae9..b4314fe 100755
--- a/tests/oft
+++ b/tests/oft
@@ -39,6 +39,12 @@
value is a list of functions in that module
</pre>
+Each test may be assigned a priority by setting test_prio["TestName"] in
+the respective module. For now, the only use of this is to avoid
+automatic inclusion of tests into the default list. This is done by
+setting the test_prio value less than 0. Eventually we may add ordering
+of test execution by test priority.
+
To add a test to the system, either: edit an existing test case file (like
basic.py) to add a test class which inherits from unittest.TestCase (directly
or indirectly); or add a new file which includes a function definition
@@ -159,6 +165,9 @@
"port_map" : {}
}
+# Default test priority
+TEST_PRIO_DEFAULT=100
+
#@todo Set up a dict of config params so easier to manage:
# <param> <cmdline flags> <default value> <help> <optional parser>
@@ -334,6 +343,17 @@
return " " * spaces
return " "
+def test_prio_get(mod, test):
+ """
+ Return the priority of a test
+ If set in the test_prio variable for the module, return
+ that value. Otherwise return 100 (default)
+ """
+ if 'test_prio' in dir(mod):
+ if test in mod.test_prio.keys():
+ return mod.test_prio[test]
+ return TEST_PRIO_DEFAULT
+
#
# Main script
#
@@ -359,11 +379,16 @@
for test in config["all_tests"][mod]:
desc = eval('mod.' + test + '.__doc__.strip()')
desc = desc.split('\n')[0]
- start_str = " " + test + ":"
+ if test_prio_get(mod, test) < 0:
+ start_str = " * " + test + ":"
+ else:
+ start_str = " " + test + ":"
print start_str + _space_to(22, start_str) + desc
print
if not did_print:
print "No tests found for " + config["test_spec"]
+ else:
+ print "Tests marked * are not run by default"
sys.exit(0)
logging_setup(config)
@@ -373,10 +398,13 @@
#@todo Decide if multiple suites are ever needed
suite = unittest.TestSuite()
+#@todo Allow specification of priority to override prio check
if config["test_spec"] == "all":
for mod in config["all_tests"].keys():
for test in config["all_tests"][mod]:
- add_test(suite, mod, test)
+ # For now, a way to avoid tests
+ if test_prio_get(mod, test) >= 0:
+ add_test(suite, mod, test)
else:
for ts_entry in config["test_spec"].split(","):