summaryrefslogtreecommitdiff
path: root/buildscripts/smoke.py
diff options
context:
space:
mode:
authorGreg Studer <greg@10gen.com>2014-09-12 13:41:12 -0400
committerGreg Studer <greg@10gen.com>2014-09-18 14:37:45 -0400
commite88273ac940cdef9e12c94a6bdbd2694b706a635 (patch)
tree76ca1becd98156bd852adc67f4262b0a4d176826 /buildscripts/smoke.py
parent9ad364efb8bfd01d5653a8d085e23c70a0dcfb29 (diff)
downloadmongo-e88273ac940cdef9e12c94a6bdbd2694b706a635.tar.gz
SERVER-1424 (re)smoke tag parsing and new test library, v0
Includes: - Smoke.py options for filtering by jstest tags - New resmoke.py test utility in v0 alpha - Lots of example resmoke configurations - SCons integration for unittests - Sample tagged jstests
Diffstat (limited to 'buildscripts/smoke.py')
-rwxr-xr-xbuildscripts/smoke.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/buildscripts/smoke.py b/buildscripts/smoke.py
index 37b533f2cc5..9c185079462 100755
--- a/buildscripts/smoke.py
+++ b/buildscripts/smoke.py
@@ -54,6 +54,7 @@ from pymongo import Connection
from pymongo.errors import OperationFailure
import cleanbb
+import smoke
import utils
try:
@@ -1002,11 +1003,36 @@ def expand_suites(suites,expandUseDB=True):
return tests
+
+def filter_tests_by_tag(tests, tag_query):
+ """Selects tests from a list based on a query over the tags in the tests."""
+
+ test_map = {}
+ roots = []
+ for test in tests:
+ root = os.path.abspath(test[0])
+ roots.append(root)
+ test_map[root] = test
+
+ new_style_tests = smoke.tests.build_tests(roots, extract_metadata=True)
+ new_style_tests = smoke.suites.build_suite(new_style_tests, tag_query)
+
+ print "\nTag query matches %s tests out of %s.\n" % (len(new_style_tests),
+ len(tests))
+
+ tests = []
+ for new_style_test in new_style_tests:
+ tests.append(test_map[os.path.abspath(new_style_test.filename)])
+
+ return tests
+
+
def add_exe(e):
if os.sys.platform.startswith( "win" ) and not e.endswith( ".exe" ):
e += ".exe"
return e
+
def set_globals(options, tests):
global mongod_executable, mongod_port, shell_executable, continue_on_failure
global small_oplog, small_oplog_rs
@@ -1259,6 +1285,14 @@ def main():
parser.add_option('--shell-write-mode', dest='shell_write_mode', default="commands",
help='Sets the shell to use a specific write mode: commands/compatibility/legacy (default:legacy)')
+ parser.add_option('--include-tags', dest='include_tags', default="", action='store',
+ help='Filters jstests run by tag regex(es) - a tag in the test must match the regexes. ' +
+ 'Specify single regex string or JSON array.')
+
+ parser.add_option('--exclude-tags', dest='exclude_tags', default="", action='store',
+ help='Filters jstests run by tag regex(es) - no tags in the test must match the regexes. ' +
+ 'Specify single regex string or JSON array.')
+
global tests
(options, tests) = parser.parse_args()
@@ -1313,6 +1347,22 @@ def main():
tests = filter( ignore_test, tests )
+ if options.include_tags or options.exclude_tags:
+
+ def to_regex_array(tags_option):
+ if not tags_option:
+ return []
+
+ tags_list = smoke.json_options.json_coerce(tags_option)
+ if isinstance(tags_list, basestring):
+ tags_list = [tags_list]
+
+ return map(re.compile, tags_list)
+
+ tests = filter_tests_by_tag(tests,
+ smoke.suites.RegexQuery(include_res=to_regex_array(options.include_tags),
+ exclude_res=to_regex_array(options.exclude_tags)))
+
if not tests:
print "warning: no tests specified"
return