summaryrefslogtreecommitdiff
path: root/test/suite
diff options
context:
space:
mode:
authorDavid Hows <david.hows@mongodb.com>2016-06-24 17:05:13 +1000
committerDavid Hows <david.hows@mongodb.com>2016-06-24 17:05:13 +1000
commitd8fb874fc40989cb9675e56ca80b3b64e6fa2ee3 (patch)
tree6f03ed5cde97aedc762215c14d23ee5305998a2b /test/suite
parentfb1663e6fc800be97c0ddc697b6f939dc610e08e (diff)
parent1f4aaa4490a82cf947afdabbb9214ee5b1850d13 (diff)
downloadmongo-d8fb874fc40989cb9675e56ca80b3b64e6fa2ee3.tar.gz
Merge branch 'develop' of github.com:wiredtiger/wiredtiger into mongodb-3.4mongodb-3.3.9mongodb-3.3.10mongodb-3.0.1
Diffstat (limited to 'test/suite')
-rw-r--r--test/suite/run.py18
-rw-r--r--test/suite/suite_subprocess.py31
-rw-r--r--test/suite/test_config04.py55
-rw-r--r--test/suite/test_dump.py4
-rw-r--r--test/suite/test_jsondump02.py15
-rw-r--r--test/suite/test_util02.py29
-rw-r--r--test/suite/test_util07.py9
-rw-r--r--test/suite/test_util12.py5
-rw-r--r--test/suite/test_verify.py12
-rw-r--r--test/suite/wttest.py2
10 files changed, 115 insertions, 65 deletions
diff --git a/test/suite/run.py b/test/suite/run.py
index f7f0d1399ff..6e7421b8b96 100644
--- a/test/suite/run.py
+++ b/test/suite/run.py
@@ -51,7 +51,7 @@ elif os.path.isfile(os.path.join(wt_disttop, 'wt.exe')):
wt_builddir = wt_disttop
else:
print 'Unable to find useable WiredTiger build'
- sys.exit(False)
+ sys.exit(1)
# Cannot import wiredtiger and supporting utils until we set up paths
# We want our local tree in front of any installed versions of WiredTiger.
@@ -241,7 +241,7 @@ if __name__ == '__main__':
if option == '-dir' or option == 'D':
if dirarg != None or len(args) == 0:
usage()
- sys.exit(False)
+ sys.exit(2)
dirarg = args.pop(0)
continue
if option == '-debug' or option == 'd':
@@ -252,14 +252,14 @@ if __name__ == '__main__':
continue
if option == '-help' or option == 'h':
usage()
- sys.exit(True)
+ sys.exit(0)
if option == '-long' or option == 'l':
longtest = True
continue
if option == '-parallel' or option == 'j':
if parallel != 0 or len(args) == 0:
usage()
- sys.exit(False)
+ sys.exit(2)
parallel = int(args.pop(0))
continue
if option == '-preserve' or option == 'p':
@@ -271,7 +271,7 @@ if __name__ == '__main__':
if option == '-verbose' or option == 'v':
if len(args) == 0:
usage()
- sys.exit(False)
+ sys.exit(2)
verbose = int(args.pop(0))
if verbose > 3:
verbose = 3
@@ -281,19 +281,19 @@ if __name__ == '__main__':
if option == '-config' or option == 'c':
if configfile != None or len(args) == 0:
usage()
- sys.exit(False)
+ sys.exit(2)
configfile = args.pop(0)
continue
if option == '-configcreate' or option == 'C':
if configfile != None or len(args) == 0:
usage()
- sys.exit(False)
+ sys.exit(2)
configfile = args.pop(0)
configwrite = True
continue
print 'unknown arg: ' + arg
usage()
- sys.exit(False)
+ sys.exit(2)
testargs.append(arg)
# All global variables should be set before any test classes are loaded.
@@ -318,4 +318,4 @@ if __name__ == '__main__':
pdb.set_trace()
result = wttest.runsuite(tests, parallel)
- sys.exit(not result.wasSuccessful())
+ sys.exit(0 if result.wasSuccessful() else 1)
diff --git a/test/suite/suite_subprocess.py b/test/suite/suite_subprocess.py
index df89d82e4c9..c56c8d8e933 100644
--- a/test/suite/suite_subprocess.py
+++ b/test/suite/suite_subprocess.py
@@ -117,13 +117,12 @@ class suite_subprocess:
print 'ERROR: ' + filename + ' should not be empty (this command expected error output)'
self.assertNotEqual(filesize, 0, filename + ': expected to not be empty')
- def runWt(self, args, infilename=None, outfilename=None, errfilename=None, reopensession=True):
- """
- Run the 'wt' process
- """
+ # Run the wt utility.
+ def runWt(self, args, infilename=None,
+ outfilename=None, errfilename=None, reopensession=True, failure=False):
- # we close the connection to guarantee everything is
- # flushed, and that we can open it from another process
+ # Close the connection to guarantee everything is flushed, and that
+ # we can open it from another process.
self.close_conn()
wtoutname = outfilename or "wt.out"
@@ -141,14 +140,26 @@ class suite_subprocess:
infilepart = "<" + infilename + " "
print str(procargs)
print "*********************************************"
- print "**** Run 'wt' via: run " + " ".join(procargs[3:]) + infilepart + ">" + wtoutname + " 2>" + wterrname
+ print "**** Run 'wt' via: run " + \
+ " ".join(procargs[3:]) + infilepart + \
+ ">" + wtoutname + " 2>" + wterrname
print "*********************************************"
- subprocess.call(procargs)
+ returncode = subprocess.call(procargs)
elif infilename:
with open(infilename, "r") as wtin:
- subprocess.call(procargs, stdin=wtin, stdout=wtout, stderr=wterr)
+ returncode = subprocess.call(
+ procargs, stdin=wtin, stdout=wtout, stderr=wterr)
else:
- subprocess.call(procargs, stdout=wtout, stderr=wterr)
+ returncode = subprocess.call(
+ procargs, stdout=wtout, stderr=wterr)
+ if failure:
+ self.assertNotEqual(returncode, 0,
+ 'expected failure: "' + \
+ str(procargs) + '": exited ' + str(returncode))
+ else:
+ self.assertEqual(returncode, 0,
+ 'expected success: "' + \
+ str(procargs) + '": exited ' + str(returncode))
if errfilename == None:
self.check_empty_file(wterrname)
if outfilename == None:
diff --git a/test/suite/test_config04.py b/test/suite/test_config04.py
index 7186bc3a716..dffa7479f1b 100644
--- a/test/suite/test_config04.py
+++ b/test/suite/test_config04.py
@@ -26,7 +26,7 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
-import os
+import os, shutil
import wiredtiger, wttest
from wiredtiger import stat
@@ -34,6 +34,7 @@ from wiredtiger import stat
# Individually test config options
class test_config04(wttest.WiredTigerTestCase):
table_name1 = 'test_config04'
+ log1 = 'WiredTigerLog.0000000001'
nentries = 100
K = 1024
@@ -86,6 +87,10 @@ class test_config04(wttest.WiredTigerTestCase):
self.assertEqual(cursor[stat.conn.cache_bytes_max][2], size)
cursor.close()
+ def common_log_test(self, path, dirname):
+ self.common_test('log=(archive=false,enabled,' + path + ')')
+ self.assertTrue(os.path.exists(dirname + os.sep + self.log1))
+
def test_bad_config(self):
msg = '/unknown configuration key/'
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
@@ -168,24 +173,46 @@ class test_config04(wttest.WiredTigerTestCase):
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda: self.wiredtiger_open('.', '(create='), msg)
- def test_session_max(self):
- # Note: There isn't any direct way to know that this was set,
- # but we'll have a separate functionality test to test for
- # this indirectly.
- self.common_test('session_max=99')
-
- def test_multiprocess(self):
- self.common_test('multiprocess')
- # TODO: how do we verify that it was set?
-
def test_error_prefix(self):
self.common_test('error_prefix="MyOwnPrefix"')
# TODO: how do we verify that it was set?
def test_logging(self):
- self.common_test('log=(enabled=true)')
- # TODO: how do we verify that it was set? For this we could look
- # for the existence of the log file in the home dir.
+ # Test variations on the log configuration. The log test takes
+ # a configuration string as the first arg and the directory pathname
+ # to confirm the existence of the log file. For now we're testing
+ # the log pathname only.
+ #
+ # Test the default in the home directory.
+ self.common_log_test('', '.')
+ self.conn.close()
+
+ # Test a subdir of the home directory.
+ logdirname = 'logdir'
+ logdir = '.' + os.sep + logdirname
+ os.mkdir(logdir)
+ confstr = 'path=' + logdirname
+ self.common_log_test(confstr, logdir)
+ self.conn.close()
+
+ # Test an absolute path directory.
+ if os.name == 'posix':
+ logdir = '/tmp/logdir'
+ os.mkdir(logdir)
+ confstr = 'path=' + logdir
+ self.common_log_test(confstr, logdir)
+ self.conn.close()
+ shutil.rmtree(logdir, ignore_errors=True)
+
+ def test_multiprocess(self):
+ self.common_test('multiprocess')
+ # TODO: how do we verify that it was set?
+
+ def test_session_max(self):
+ # Note: There isn't any direct way to know that this was set,
+ # but we'll have a separate functionality test to test for
+ # this indirectly.
+ self.common_test('session_max=99')
def test_transactional(self):
# Note: this will have functional tests in the future.
diff --git a/test/suite/test_dump.py b/test/suite/test_dump.py
index d0163066639..85196174c1b 100644
--- a/test/suite/test_dump.py
+++ b/test/suite/test_dump.py
@@ -143,8 +143,8 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess):
self.populate_check(self, uri, self.nentries)
# Re-load the object again, but confirm -n (no overwrite) fails.
- self.runWt(['-h', self.dir,
- 'load', '-n', '-f', 'dump.out'], errfilename='errfile.out')
+ self.runWt(['-h', self.dir, 'load', '-n', '-f', 'dump.out'],
+ errfilename='errfile.out', failure=True)
self.check_non_empty_file('errfile.out')
# If there are indices, dump one of them and check the output.
diff --git a/test/suite/test_jsondump02.py b/test/suite/test_jsondump02.py
index 251237f3faf..50931f0f5e6 100644
--- a/test/suite/test_jsondump02.py
+++ b/test/suite/test_jsondump02.py
@@ -208,12 +208,16 @@ class test_jsondump02(wttest.WiredTigerTestCase, suite_subprocess):
# this one should work
self.load_json(self.table_uri2,
- (('"key0" : "KEY002"', '"value0" : 345,\n"value1" : "str2"'),))
+ (('"key0" : "KEY002"', '"value0" : 34,\n"value1" : "str2"'),))
# extraneous/missing space is okay
self.load_json(self.table_uri2,
((' "key0"\n:\t"KEY003" ',
- '"value0":456,"value1"\n\n\r\n:\t\n"str3"'),))
+ '"value0":45,"value1"\n\n\r\n:\t\n"str3"'),))
+
+ table2_json = (
+ ('"key0" : "KEY002"', '"value0" : 34,\n"value1" : "str2"'),
+ ('"key0" : "KEY003"', '"value0" : 45,\n"value1" : "str3"'))
table3_json = (
('"key0" : 1', '"value0" : "\\u0001\\u0002\\u0003"'),
@@ -284,12 +288,11 @@ class test_jsondump02(wttest.WiredTigerTestCase, suite_subprocess):
self.runWt(['load', '-jf', 'jsondump4.out'])
self.session.drop(self.table_uri4)
- # Note: only the first table is loaded.
self.runWt(['load', '-jf', 'jsondump-all.out'])
self.check_json(self.table_uri1, table1_json)
- #self.check_json(self.table_uri2, table2_json)
- #self.check_json(self.table_uri3, table3_json)
- #self.check_json(self.table_uri4, table4_json)
+ self.check_json(self.table_uri2, table2_json)
+ self.check_json(self.table_uri3, table3_json)
+ self.check_json(self.table_uri4, table4_json)
# Generate two byte keys that cover some range of byte values.
# For simplicity, the keys are monotonically increasing.
diff --git a/test/suite/test_util02.py b/test/suite/test_util02.py
index 51e03d8d105..475e856052a 100644
--- a/test/suite/test_util02.py
+++ b/test/suite/test_util02.py
@@ -173,7 +173,7 @@ class test_load_commandline(wttest.WiredTigerTestCase, suite_subprocess):
complex_populate(self, self.uri, "key_format=S,value_format=S", 20)
self.runWt(["dump", self.uri], outfilename="dump.out")
loadargs = ["load", "-f", "dump.out"] + args
- self.runWt(loadargs, errfilename=errfile)
+ self.runWt(loadargs, errfilename=errfile, failure=fail)
if fail:
self.check_non_empty_file(errfile)
else:
@@ -181,23 +181,24 @@ class test_load_commandline(wttest.WiredTigerTestCase, suite_subprocess):
# Empty arguments should suceed.
def test_load_commandline_1(self):
- self.load_commandline([], 0)
+ self.load_commandline([], False)
# Arguments are in pairs.
def test_load_commandline_2(self):
- self.load_commandline(["table"], 1)
- self.load_commandline([self.uri, "block_allocation=first", self.uri], 1)
+ self.load_commandline(["table"], True)
+ self.load_commandline(
+ [self.uri, "block_allocation=first", self.uri], True)
# You can use short-hand URIs for a single object, but cannot match multiple
# objects.
def test_load_commandline_3(self):
- self.load_commandline(["table", "block_allocation=first"], 0)
- self.load_commandline(["colgroup", "block_allocation=first"], 1)
+ self.load_commandline(["table", "block_allocation=first"], False)
+ self.load_commandline(["colgroup", "block_allocation=first"], True)
# You can't reference non-existent objects.
def test_load_commandline_4(self):
- self.load_commandline([self.uri, "block_allocation=first"], 0)
- self.load_commandline(["table:bar", "block_allocation=first"], 1)
+ self.load_commandline([self.uri, "block_allocation=first"], False)
+ self.load_commandline(["table:bar", "block_allocation=first"], True)
# You can specify multipleconfiguration arguments for the same object.
def test_load_commandline_5(self):
@@ -205,19 +206,19 @@ class test_load_commandline(wttest.WiredTigerTestCase, suite_subprocess):
self.uri, "block_allocation=first",
self.uri, "block_allocation=best",
self.uri, "block_allocation=first",
- self.uri, "block_allocation=best"], 0)
+ self.uri, "block_allocation=best"], False)
# You can't modify a format.
def test_load_commandline_6(self):
- self.load_commandline(["table", "key_format=d"], 1)
- self.load_commandline(["table", "value_format=d"], 1)
+ self.load_commandline(["table", "key_format=d"], True)
+ self.load_commandline(["table", "value_format=d"], True)
# You can set the source or version, but it gets stripped; confirm the
# attempt succeeds, so we know they configuration values are stripped.
def test_load_commandline_7(self):
- self.load_commandline(["table", "filename=bar"], 0)
- self.load_commandline(["table", "source=bar"], 0)
- self.load_commandline(["table", "version=(100,200)"], 0)
+ self.load_commandline(["table", "filename=bar"], False)
+ self.load_commandline(["table", "source=bar"], False)
+ self.load_commandline(["table", "version=(100,200)"], False)
if __name__ == '__main__':
diff --git a/test/suite/test_util07.py b/test/suite/test_util07.py
index 2bbb40422bd..602ddbba5ff 100644
--- a/test/suite/test_util07.py
+++ b/test/suite/test_util07.py
@@ -71,7 +71,8 @@ class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
self.session.create('table:' + self.tablename, self.session_params)
outfile = "readout.txt"
errfile = "readerr.txt"
- self.runWt(["read", 'table:' + self.tablename, 'NoMatch'], outfilename=outfile, errfilename=errfile)
+ self.runWt(["read", 'table:' + self.tablename, 'NoMatch'],
+ outfilename=outfile, errfilename=errfile, failure=True)
self.check_empty_file(outfile)
self.check_file_contains(errfile, 'NoMatch: not found\n')
@@ -83,10 +84,12 @@ class test_util07(wttest.WiredTigerTestCase, suite_subprocess):
self.populate(self.tablename)
outfile = "readout.txt"
errfile = "readerr.txt"
- self.runWt(["read", 'table:' + self.tablename, 'KEY49'], outfilename=outfile, errfilename=errfile)
+ self.runWt(["read", 'table:' + self.tablename, 'KEY49'],
+ outfilename=outfile, errfilename=errfile)
self.check_file_content(outfile, 'VAL49\n')
self.check_empty_file(errfile)
- self.runWt(["read", 'table:' + self.tablename, 'key49'], outfilename=outfile, errfilename=errfile)
+ self.runWt(["read", 'table:' + self.tablename, 'key49'],
+ outfilename=outfile, errfilename=errfile, failure=True)
self.check_empty_file(outfile)
self.check_file_contains(errfile, 'key49: not found\n')
diff --git a/test/suite/test_util12.py b/test/suite/test_util12.py
index e8226a3146c..f407c2ce7d6 100644
--- a/test/suite/test_util12.py
+++ b/test/suite/test_util12.py
@@ -57,7 +57,8 @@ class test_util12(wttest.WiredTigerTestCase, suite_subprocess):
self.session.create('table:' + self.tablename, self.session_params)
errfile = 'writeerr.txt'
- self.runWt(['write', 'table:' + self.tablename], errfilename=errfile)
+ self.runWt(['write', 'table:' + self.tablename],
+ errfilename=errfile, failure=True)
self.check_file_contains(errfile, 'usage:')
def test_write_overwrite(self):
@@ -82,7 +83,7 @@ class test_util12(wttest.WiredTigerTestCase, suite_subprocess):
self.session.create('table:' + self.tablename, self.session_params)
errfile = 'writeerr.txt'
self.runWt(['write', 'table:' + self.tablename,
- 'def', '456', 'abc'], errfilename=errfile)
+ 'def', '456', 'abc'], errfilename=errfile, failure=True)
self.check_file_contains(errfile, 'usage:')
diff --git a/test/suite/test_verify.py b/test/suite/test_verify.py
index 5ce926027ef..28a66415b9d 100644
--- a/test/suite/test_verify.py
+++ b/test/suite/test_verify.py
@@ -151,7 +151,8 @@ class test_verify(wttest.WiredTigerTestCase, suite_subprocess):
with self.open_and_position(self.tablename, 75) as f:
for i in range(0, 4096):
f.write(struct.pack('B', 0))
- self.runWt(["verify", "table:" + self.tablename], errfilename="verifyerr.out")
+ self.runWt(["verify", "table:" + self.tablename],
+ errfilename="verifyerr.out", failure=True)
self.check_non_empty_file("verifyerr.out")
def test_verify_process_25pct_junk(self):
@@ -165,7 +166,8 @@ class test_verify(wttest.WiredTigerTestCase, suite_subprocess):
with self.open_and_position(self.tablename, 25) as f:
for i in range(0, 100):
f.write('\x01\xff\x80')
- self.runWt(["verify", "table:" + self.tablename], errfilename="verifyerr.out")
+ self.runWt(["verify", "table:" + self.tablename],
+ errfilename="verifyerr.out", failure=True)
self.check_non_empty_file("verifyerr.out")
def test_verify_process_truncated(self):
@@ -178,7 +180,8 @@ class test_verify(wttest.WiredTigerTestCase, suite_subprocess):
self.populate(self.tablename)
with self.open_and_position(self.tablename, 75) as f:
f.truncate(0)
- self.runWt(["verify", "table:" + self.tablename], errfilename="verifyerr.out")
+ self.runWt(["verify", "table:" + self.tablename],
+ errfilename="verifyerr.out", failure=True)
self.check_non_empty_file("verifyerr.out")
def test_verify_process_zero_length(self):
@@ -190,7 +193,8 @@ class test_verify(wttest.WiredTigerTestCase, suite_subprocess):
self.populate(self.tablename)
with self.open_and_position(self.tablename, 0) as f:
f.truncate(0)
- self.runWt(["verify", "table:" + self.tablename], errfilename="verifyerr.out")
+ self.runWt(["verify", "table:" + self.tablename],
+ errfilename="verifyerr.out", failure=True)
self.check_non_empty_file("verifyerr.out")
diff --git a/test/suite/wttest.py b/test/suite/wttest.py
index f7a2a5c8890..9e430fcdba7 100644
--- a/test/suite/wttest.py
+++ b/test/suite/wttest.py
@@ -551,4 +551,4 @@ def runsuite(suite, parallel):
def run(name='__main__'):
result = runsuite(unittest.TestLoader().loadTestsFromName(name), False)
- sys.exit(not result.wasSuccessful())
+ sys.exit(0 if result.wasSuccessful() else 1)