summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDon Anderson <dda@ddanderson.com>2013-12-19 12:48:50 -0500
committerDon Anderson <dda@ddanderson.com>2013-12-19 12:48:50 -0500
commitabd318e5f16edf7e694c5faca2c2dbb3f200213b (patch)
tree5bfeddeaf6ec066c90875f99362ea29639b592cd
parentee597c75a8775256cc74ea88c0443466d60a701f (diff)
downloadmongo-abd318e5f16edf7e694c5faca2c2dbb3f200213b.tar.gz
Add '--parallel N' option to run.py. Using '--parallel' requires
that some additional packages are installed: testtools, extras, python-subunit and concurrencytest. ref #788
-rw-r--r--test/suite/run.py10
-rw-r--r--test/suite/test_checkpoint01.py8
-rw-r--r--test/suite/test_checkpoint02.py4
-rw-r--r--test/suite/test_cursor03.py2
-rw-r--r--test/suite/test_dupc.py8
-rw-r--r--test/suite/test_empty.py8
-rw-r--r--test/suite/test_overwrite.py11
-rw-r--r--test/suite/test_txn01.py12
-rw-r--r--test/suite/wttest.py26
9 files changed, 55 insertions, 34 deletions
diff --git a/test/suite/run.py b/test/suite/run.py
index af21c8014de..933e272841f 100644
--- a/test/suite/run.py
+++ b/test/suite/run.py
@@ -63,6 +63,7 @@ Options:\n\
-g | --gdb all subprocesses (like calls to wt) use gdb\n\
-h | --help show this message\n\
-p | --preserve preserve output files in WT_TEST/<testname>\n\
+ -P N | --parallel N run all tests in parallel using N processes\n\
-t | --timestamp name WT_TEST according to timestamp\n\
-v N | --verbose N set verboseness to N (0<=N<=3, default=1)\n\
\n\
@@ -200,6 +201,7 @@ if __name__ == '__main__':
# Turn numbers and ranges into test module names
preserve = timestamp = debug = gdbSub = False
+ parallel = 0
configfile = None
configwrite = False
dirarg = None
@@ -222,6 +224,12 @@ if __name__ == '__main__':
if option == '-debug' or option == 'd':
debug = True
continue
+ if option == '-parallel' or option == 'P':
+ if parallel != 0 or len(args) == 0:
+ usage()
+ sys.exit(False)
+ parallel = int(args.pop(0))
+ continue
if option == '-preserve' or option == 'p':
preserve = True
continue
@@ -283,5 +291,5 @@ if __name__ == '__main__':
import pdb
pdb.set_trace()
- result = wttest.runsuite(tests)
+ result = wttest.runsuite(tests, parallel)
sys.exit(not result.wasSuccessful())
diff --git a/test/suite/test_checkpoint01.py b/test/suite/test_checkpoint01.py
index e3f23f7298c..a8ed71d5409 100644
--- a/test/suite/test_checkpoint01.py
+++ b/test/suite/test_checkpoint01.py
@@ -255,10 +255,10 @@ class test_checkpoint_target(wttest.WiredTigerTestCase):
# Check that you can't write checkpoint cursors.
class test_checkpoint_cursor_update(wttest.WiredTigerTestCase):
scenarios = [
- ('file', dict(uri='file:checkpoint',fmt='r')),
- ('file', dict(uri='file:checkpoint',fmt='S')),
- ('table', dict(uri='table:checkpoint',fmt='r')),
- ('table', dict(uri='table:checkpoint',fmt='S'))
+ ('file-r', dict(uri='file:checkpoint',fmt='r')),
+ ('file-S', dict(uri='file:checkpoint',fmt='S')),
+ ('table-r', dict(uri='table:checkpoint',fmt='r')),
+ ('table-S', dict(uri='table:checkpoint',fmt='S'))
]
def test_checkpoint_cursor_update(self):
diff --git a/test/suite/test_checkpoint02.py b/test/suite/test_checkpoint02.py
index 107359c3938..e2dc1d84c00 100644
--- a/test/suite/test_checkpoint02.py
+++ b/test/suite/test_checkpoint02.py
@@ -35,8 +35,8 @@ from helper import key_populate, simple_populate
# operations in another thread
class test_checkpoint02(wttest.WiredTigerTestCase):
scenarios = [
- ('table', dict(uri='table:test',fmt='L',dsize=100,nops=50000,nthreads=10)),
- ('table', dict(uri='table:test',fmt='L',dsize=10,nops=50000,nthreads=30))
+ ('table-100', dict(uri='table:test',fmt='L',dsize=100,nops=50000,nthreads=10)),
+ ('table-10', dict(uri='table:test',fmt='L',dsize=10,nops=50000,nthreads=30))
]
diff --git a/test/suite/test_cursor03.py b/test/suite/test_cursor03.py
index 362b00ebf60..292bd6c948c 100644
--- a/test/suite/test_cursor03.py
+++ b/test/suite/test_cursor03.py
@@ -41,7 +41,7 @@ class test_cursor03(TestCursorTracker):
"""
scenarios = multiply_scenarios('.', [
('row', dict(tablekind='row', keysize=None, valsize=None, uri='table')),
- ('row', dict(tablekind='row', keysize=None, valsize=None, uri='lsm')),
+ ('lsm-row', dict(tablekind='row', keysize=None, valsize=None, uri='lsm')),
('col', dict(tablekind='col', keysize=None, valsize=None, uri='table')),
#('fix', dict(tablekind='fix', keysize=None, valsize=None))
('row.val10k', dict(tablekind='row', keysize=None, valsize=[10, 10000], uri='table')),
diff --git a/test/suite/test_dupc.py b/test/suite/test_dupc.py
index 4e183ddfff6..9b72f77c454 100644
--- a/test/suite/test_dupc.py
+++ b/test/suite/test_dupc.py
@@ -41,10 +41,10 @@ class test_duplicate_cursor(wttest.WiredTigerTestCase):
config = 'key_format='
scenarios = [
- ('file', dict(uri='file:', fmt='r')),
- ('file', dict(uri='file:', fmt='S')),
- ('table', dict(uri='table:', fmt='r')),
- ('table', dict(uri='table:', fmt='S'))
+ ('file-r', dict(uri='file:', fmt='r')),
+ ('file-S', dict(uri='file:', fmt='S')),
+ ('table-r', dict(uri='table:', fmt='r')),
+ ('table-S', dict(uri='table:', fmt='S'))
]
# Iterate through an object, duplicate the cursor and checking that it
diff --git a/test/suite/test_empty.py b/test/suite/test_empty.py
index c4d745e9a6f..15a3e14ae4e 100644
--- a/test/suite/test_empty.py
+++ b/test/suite/test_empty.py
@@ -35,10 +35,10 @@ class test_empty(wttest.WiredTigerTestCase):
name = 'test_empty'
scenarios = [
- ('file', dict(type='file:', fmt='r')),
- ('file', dict(type='file:', fmt='S')),
- ('table', dict(type='table:', fmt='r')),
- ('table', dict(type='table:', fmt='S'))
+ ('file-r', dict(type='file:', fmt='r')),
+ ('file-S', dict(type='file:', fmt='S')),
+ ('table-r', dict(type='table:', fmt='r')),
+ ('table-S', dict(type='table:', fmt='S'))
]
# Creating an object and then closing it shouldn't write any blocks.
diff --git a/test/suite/test_overwrite.py b/test/suite/test_overwrite.py
index 77c3ecd2fdd..80362903ab2 100644
--- a/test/suite/test_overwrite.py
+++ b/test/suite/test_overwrite.py
@@ -27,17 +27,18 @@
import wiredtiger, wttest
from helper import key_populate, simple_populate
+from wtscenario import multiply_scenarios, number_scenarios
# test_overwrite.py
# cursor overwrite configuration method
class test_overwrite(wttest.WiredTigerTestCase):
name = 'overwrite'
scenarios = [
- ('file', dict(type='file:',keyfmt='r')),
- ('file', dict(type='file:',keyfmt='S')),
- ('lsm', dict(type='lsm:',keyfmt='S')),
- ('table', dict(type='table:',keyfmt='r')),
- ('table', dict(type='table:',keyfmt='S')),
+ ('file-r', dict(type='file:',keyfmt='r')),
+ ('file-S', dict(type='file:',keyfmt='S')),
+ ('lsm-S', dict(type='lsm:',keyfmt='S')),
+ ('table-r', dict(type='table:',keyfmt='r')),
+ ('table-S', dict(type='table:',keyfmt='S')),
]
# Confirm a cursor configured with/without overwrite correctly handles
diff --git a/test/suite/test_txn01.py b/test/suite/test_txn01.py
index 0499c2dad13..76bb3e964a2 100644
--- a/test/suite/test_txn01.py
+++ b/test/suite/test_txn01.py
@@ -32,12 +32,12 @@ import wiredtiger, wttest
class test_txn01(wttest.WiredTigerTestCase):
nentries = 1000
scenarios = [
- ('col', dict(uri='file:text_txn01',key_format='r',value_format='S')),
- ('col', dict(uri='table:text_txn01',key_format='r',value_format='S')),
- ('fix', dict(uri='file:text_txn01',key_format='r',value_format='8t')),
- ('fix', dict(uri='table:text_txn01',key_format='r',value_format='8t')),
- ('row', dict(uri='file:text_txn01',key_format='S',value_format='S')),
- ('row', dict(uri='table:text_txn01',key_format='S',value_format='S')),
+ ('col-f', dict(uri='file:text_txn01',key_format='r',value_format='S')),
+ ('col-t', dict(uri='table:text_txn01',key_format='r',value_format='S')),
+ ('fix-f', dict(uri='file:text_txn01',key_format='r',value_format='8t')),
+ ('fix-t', dict(uri='table:text_txn01',key_format='r',value_format='8t')),
+ ('row-f', dict(uri='file:text_txn01',key_format='S',value_format='S')),
+ ('row-t', dict(uri='table:text_txn01',key_format='S',value_format='S')),
]
# Overrides WiredTigerTestCase
diff --git a/test/suite/wttest.py b/test/suite/wttest.py
index 247fd4042d6..74e176744e3 100644
--- a/test/suite/wttest.py
+++ b/test/suite/wttest.py
@@ -148,13 +148,15 @@ class WiredTigerTestCase(unittest.TestCase):
shutil.rmtree(d, ignore_errors=True)
os.makedirs(d)
WiredTigerTestCase._parentTestdir = d
+ WiredTigerTestCase._origcwd = os.getcwd()
WiredTigerTestCase._resultfile = open(os.path.join(d, 'results.txt'), "w", 0) # unbuffered
WiredTigerTestCase._gdbSubprocess = gdbSub
WiredTigerTestCase._verbose = verbose
WiredTigerTestCase._dupout = os.dup(sys.stdout.fileno())
- WiredTigerTestCase._globalSetup = True
WiredTigerTestCase._stdout = sys.stdout
WiredTigerTestCase._stderr = sys.stderr
+ WiredTigerTestCase._concurrent = False
+ WiredTigerTestCase._globalSetup = True
def fdSetUp(self):
self.captureout = CapturedFd('stdout.txt', 'standard output')
@@ -225,7 +227,11 @@ class WiredTigerTestCase(unittest.TestCase):
def setUp(self):
if not hasattr(self.__class__, 'wt_ntests'):
self.__class__.wt_ntests = 0
- self.testdir = os.path.join(WiredTigerTestCase._parentTestdir, self.className() + '.' + str(self.__class__.wt_ntests))
+ if WiredTigerTestCase._concurrent:
+ self.testsubdir = self.shortid() + '.' + str(self.__class__.wt_ntests)
+ else:
+ self.testsubdir = self.className() + '.' + str(self.__class__.wt_ntests)
+ self.testdir = os.path.join(WiredTigerTestCase._parentTestdir, self.testsubdir)
self.__class__.wt_ntests += 1
if WiredTigerTestCase._verbose > 2:
self.prhead('started in ' + self.testdir, True)
@@ -272,7 +278,7 @@ class WiredTigerTestCase(unittest.TestCase):
self.pr('preserving directory ' + self.testdir)
if not passed:
- print "ERROR"
+ print "ERROR in " + self.testsubdir
self.pr('FAIL')
self.prexception(excinfo)
self.pr('preserving directory ' + self.testdir)
@@ -420,16 +426,22 @@ class WiredTigerTestCase(unittest.TestCase):
def className(self):
return self.__class__.__name__
-
-def runsuite(suite):
+def runsuite(suite, parallel):
+ suite_to_run = suite
+ if parallel > 0:
+ from concurrencytest import ConcurrentTestSuite, fork_for_tests
+ if not WiredTigerTestCase._globalSetup:
+ WiredTigerTestCase.globalSetup()
+ WiredTigerTestCase._concurrent = True
+ suite_to_run = ConcurrentTestSuite(suite, fork_for_tests(parallel))
try:
return unittest.TextTestRunner(
- verbosity=WiredTigerTestCase._verbose).run(suite)
+ verbosity=WiredTigerTestCase._verbose).run(suite_to_run)
except BaseException as e:
# This should not happen for regular test errors, unittest should catch everything
print('ERROR: running test: ', e)
raise e
def run(name='__main__'):
- result = runsuite(unittest.TestLoader().loadTestsFromName(name))
+ result = runsuite(unittest.TestLoader().loadTestsFromName(name), False)
sys.exit(not result.wasSuccessful())