summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-06-05 23:49:01 -0400
committerMichael Cahill <michael.cahill@mongodb.com>2016-06-06 13:49:01 +1000
commit36b0757c3c0d0af725ebea4290f0302274f16646 (patch)
tree3c7bdadd9d72a3437e5269fa18f5ed34a80718ca
parent7d5c484b3c422ba26f57f5c93a2cff275fad963d (diff)
downloadmongo-36b0757c3c0d0af725ebea4290f0302274f16646.tar.gz
WT-2687 test suite should verify the exit status of the wt utility (#2778)
* Change runWt to assert the wt utility exited with the expected status, then we don't have to hunt for core dumps, the test will assert instead. * Fixes that allow multiple JSON tables dumped in a single file to be read in. Before this change, the first JSON table would be accepted, and 'wt load' would exit in error.
-rw-r--r--src/utilities/util_load.c2
-rw-r--r--src/utilities/util_load_json.c10
-rw-r--r--test/suite/suite_subprocess.py31
-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
9 files changed, 72 insertions, 45 deletions
diff --git a/src/utilities/util_load.c b/src/utilities/util_load.c
index a81d06c6866..ac18df80851 100644
--- a/src/utilities/util_load.c
+++ b/src/utilities/util_load.c
@@ -211,6 +211,8 @@ config_list_free(CONFIG_LIST *clp)
free(*entry);
free(clp->list);
clp->list = NULL;
+ clp->entry = 0;
+ clp->max_entry = 0;
}
/*
diff --git a/src/utilities/util_load_json.c b/src/utilities/util_load_json.c
index f1f6675e99c..45688e5e107 100644
--- a/src/utilities/util_load_json.c
+++ b/src/utilities/util_load_json.c
@@ -427,6 +427,9 @@ json_top_level(WT_SESSION *session, JSON_INPUT_STATE *ins, uint32_t flags)
flags)) != 0)
goto err;
config_list_free(&cl);
+ free(ins->kvraw);
+ ins->kvraw = NULL;
+ config_list_free(&cl);
break;
}
else
@@ -544,15 +547,14 @@ json_skip(WT_SESSION *session, JSON_INPUT_STATE *ins, const char **matches)
const char *hit;
const char **match;
- if (ins->kvraw != NULL)
- return (1);
-
+ WT_ASSERT((WT_SESSION_IMPL *)session, ins->kvraw == NULL);
hit = NULL;
while (!ins->ateof) {
for (match = matches; *match != NULL; match++)
if ((hit = strstr(ins->p, *match)) != NULL)
goto out;
- if (util_read_line(session, &ins->line, true, &ins->ateof)) {
+ if (util_read_line(session, &ins->line, true, &ins->ateof)
+ != 0) {
ins->toktype = -1;
return (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_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")