summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/checkpoint/smoke.sh3
-rw-r--r--test/csuite/wt2246_col_append/main.c2
-rw-r--r--test/csuite/wt2323_join_visibility/main.c7
-rw-r--r--test/csuite/wt2535_insert_race/main.c2
-rw-r--r--test/csuite/wt2695_checksum/main.c2
-rw-r--r--test/csuite/wt2719_reconfig/main.c2
-rw-r--r--test/csuite/wt2834_join_bloom_fix/main.c7
-rw-r--r--test/csuite/wt2853_perf/main.c2
-rw-r--r--test/format/lrt.c16
-rw-r--r--test/format/t.c2
-rw-r--r--test/format/util.c22
-rw-r--r--test/format/wts.c6
-rw-r--r--test/java/com/wiredtiger/test/ConcurrentCloseTest.java21
-rw-r--r--test/recovery/random-abort.c2
-rw-r--r--test/suite/test_inmem02.py64
-rw-r--r--test/utility/test_util.h56
16 files changed, 189 insertions, 27 deletions
diff --git a/test/checkpoint/smoke.sh b/test/checkpoint/smoke.sh
index 2f1d4345ad7..123d4e00df5 100755
--- a/test/checkpoint/smoke.sh
+++ b/test/checkpoint/smoke.sh
@@ -6,6 +6,9 @@ set -e
echo "checkpoint: 3 mixed tables"
$TEST_WRAPPER ./t -T 3 -t m
+# We are done if short tests are requested
+test -z "$TESTUTIL_DISABLE_LONG_TESTS" || exit 0
+
echo "checkpoint: 6 column-store tables"
$TEST_WRAPPER ./t -T 6 -t c
diff --git a/test/csuite/wt2246_col_append/main.c b/test/csuite/wt2246_col_append/main.c
index b795816c76f..1da8732abb4 100644
--- a/test/csuite/wt2246_col_append/main.c
+++ b/test/csuite/wt2246_col_append/main.c
@@ -104,6 +104,8 @@ main(int argc, char *argv[])
char buf[100];
opts = &_opts;
+ if (testutil_disable_long_tests())
+ return (0);
memset(opts, 0, sizeof(*opts));
opts->table_type = TABLE_ROW;
opts->n_append_threads = N_APPEND_THREADS;
diff --git a/test/csuite/wt2323_join_visibility/main.c b/test/csuite/wt2323_join_visibility/main.c
index bbf1626fe82..5987b77fd7d 100644
--- a/test/csuite/wt2323_join_visibility/main.c
+++ b/test/csuite/wt2323_join_visibility/main.c
@@ -96,6 +96,8 @@ main(int argc, char *argv[])
opts = &_opts;
sharedopts = &_sharedopts;
+ if (testutil_disable_long_tests())
+ return (0);
memset(opts, 0, sizeof(*opts));
memset(sharedopts, 0, sizeof(*sharedopts));
@@ -225,7 +227,8 @@ test_join(TEST_OPTS *opts, SHARED_OPTS *sharedopts, bool bloom,
testutil_check(session->close(session, NULL));
}
-static void *thread_insert(void *arg)
+static void *
+thread_insert(void *arg)
{
SHARED_OPTS *sharedopts;
TEST_OPTS *opts;
@@ -239,7 +242,7 @@ static void *thread_insert(void *arg)
threadargs = (THREAD_ARGS *)arg;
opts = threadargs->testopts;
sharedopts = threadargs->sharedopts;
- testutil_check(__wt_random_init_seed(NULL, &rnd));
+ __wt_random_init_seed(NULL, &rnd);
testutil_check(opts->conn->open_session(
opts->conn, NULL, NULL, &session));
diff --git a/test/csuite/wt2535_insert_race/main.c b/test/csuite/wt2535_insert_race/main.c
index 5eaca3279b6..ee567df8749 100644
--- a/test/csuite/wt2535_insert_race/main.c
+++ b/test/csuite/wt2535_insert_race/main.c
@@ -52,6 +52,8 @@ main(int argc, char *argv[])
int i;
opts = &_opts;
+ if (testutil_disable_long_tests())
+ return (0);
memset(opts, 0, sizeof(*opts));
opts->nthreads = 10;
opts->nrecords = 1000;
diff --git a/test/csuite/wt2695_checksum/main.c b/test/csuite/wt2695_checksum/main.c
index afb9d0788bd..50f118bf828 100644
--- a/test/csuite/wt2695_checksum/main.c
+++ b/test/csuite/wt2695_checksum/main.c
@@ -61,7 +61,7 @@ main(int argc, char *argv[])
wiredtiger_open(opts->home, NULL, "create", &opts->conn));
/* Initialize the RNG. */
- testutil_check(__wt_random_init_seed(NULL, &rnd));
+ __wt_random_init_seed(NULL, &rnd);
/* Allocate aligned memory for the data. */
data = dcalloc(DATASIZE, sizeof(uint8_t));
diff --git a/test/csuite/wt2719_reconfig/main.c b/test/csuite/wt2719_reconfig/main.c
index b67dae6d647..64a47ea49a6 100644
--- a/test/csuite/wt2719_reconfig/main.c
+++ b/test/csuite/wt2719_reconfig/main.c
@@ -256,7 +256,7 @@ main(int argc, char *argv[])
session, opts->uri, "type=lsm,key_format=S,value_format=S"));
/* Initialize the RNG. */
- testutil_check(__wt_random_init_seed(NULL, &rnd));
+ __wt_random_init_seed(NULL, &rnd);
/* Allocate memory for the config. */
len = WT_ELEMENTS(list) * 64;
diff --git a/test/csuite/wt2834_join_bloom_fix/main.c b/test/csuite/wt2834_join_bloom_fix/main.c
index 1e2d919d3c7..1d6abcfb179 100644
--- a/test/csuite/wt2834_join_bloom_fix/main.c
+++ b/test/csuite/wt2834_join_bloom_fix/main.c
@@ -62,6 +62,8 @@ main(int argc, char *argv[])
char joinuri[256];
opts = &_opts;
+ if (testutil_disable_long_tests())
+ return (0);
memset(opts, 0, sizeof(*opts));
testutil_check(testutil_parse_opts(argc, argv, opts));
@@ -159,7 +161,8 @@ main(int argc, char *argv[])
return (0);
}
-void populate(TEST_OPTS *opts)
+void
+populate(TEST_OPTS *opts)
{
WT_CURSOR *maincur;
WT_SESSION *session;
@@ -167,7 +170,7 @@ void populate(TEST_OPTS *opts)
int balance, i, flag, post;
WT_RAND_STATE rnd;
- testutil_check(__wt_random_init_seed(NULL, &rnd));
+ __wt_random_init_seed(NULL, &rnd);
testutil_check(opts->conn->open_session(
opts->conn, NULL, NULL, &session));
diff --git a/test/csuite/wt2853_perf/main.c b/test/csuite/wt2853_perf/main.c
index 67ba4a20ada..27591fdf214 100644
--- a/test/csuite/wt2853_perf/main.c
+++ b/test/csuite/wt2853_perf/main.c
@@ -201,7 +201,7 @@ thread_insert(void *arg)
threadargs = (THREAD_ARGS *)arg;
opts = threadargs->testopts;
- testutil_check(__wt_random_init_seed(NULL, &rnd));
+ __wt_random_init_seed(NULL, &rnd);
(void)time(&prevtime);
testutil_check(opts->conn->open_session(
diff --git a/test/format/lrt.c b/test/format/lrt.c
index 937525522fa..69d6b22d71f 100644
--- a/test/format/lrt.c
+++ b/test/format/lrt.c
@@ -96,6 +96,22 @@ lrt(void *arg)
pinned = 0;
} else {
/*
+ * Test named snapshots: create a snapshot, wait to
+ * give the transaction state time to move forward,
+ * then start a transaction with the named snapshot,
+ * drop it, then commit the transaction. This exercises
+ * most of the named snapshot logic under load.
+ */
+ testutil_check(session->snapshot(session, "name=test"));
+ sleep(1);
+ testutil_check(session->begin_transaction(
+ session, "snapshot=test"));
+ testutil_check(session->snapshot(
+ session, "drop=(all)"));
+ testutil_check(session->commit_transaction(
+ session, NULL));
+
+ /*
* Begin transaction: without an explicit transaction,
* the snapshot is only kept around while a cursor is
* positioned. As soon as the cursor loses its position
diff --git a/test/format/t.c b/test/format/t.c
index 12258af8e51..41bdea11e73 100644
--- a/test/format/t.c
+++ b/test/format/t.c
@@ -115,7 +115,7 @@ main(int argc, char *argv[])
argv += __wt_optind;
/* Initialize the global RNG. */
- testutil_check(__wt_random_init_seed(NULL, &g.rnd));
+ __wt_random_init_seed(NULL, &g.rnd);
/* Set up paths. */
path_setup(home);
diff --git a/test/format/util.c b/test/format/util.c
index 667f6d6bcb1..a709aa93a2e 100644
--- a/test/format/util.c
+++ b/test/format/util.c
@@ -78,7 +78,7 @@ key_gen_setup(WT_ITEM *key)
}
static void
-key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
+key_gen_common(WT_ITEM *key, uint64_t keyno, const char * const suffix)
{
int len;
char *p;
@@ -86,11 +86,15 @@ key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
p = key->mem;
/*
- * The key always starts with a 10-digit string (the specified cnt)
+ * The key always starts with a 10-digit string (the specified row)
* followed by two digits, a random number between 1 and 15 if it's
* an insert, otherwise 00.
*/
- len = sprintf(p, "%010" PRIu64 ".%02d", keyno, suffix);
+ u64_to_string_zf(keyno, key->mem, 11);
+ p[10] = '.';
+ p[11] = suffix[0];
+ p[12] = suffix[1];
+ len = 13;
/*
* In a column-store, the key is only used for Berkeley DB inserts,
@@ -118,13 +122,19 @@ key_gen_common(WT_ITEM *key, uint64_t keyno, int suffix)
void
key_gen(WT_ITEM *key, uint64_t keyno)
{
- key_gen_common(key, keyno, 0);
+ key_gen_common(key, keyno, "00");
}
void
key_gen_insert(WT_RAND_STATE *rnd, WT_ITEM *key, uint64_t keyno)
{
- key_gen_common(key, keyno, (int)mmrand(rnd, 1, 15));
+ static const char * const suffix[15] = {
+ "01", "02", "03", "04", "05",
+ "06", "07", "08", "09", "10",
+ "11", "12", "13", "14", "15"
+ };
+
+ key_gen_common(key, keyno, suffix[mmrand(rnd, 1, 15) - 1]);
}
static uint32_t val_dup_data_len; /* Length of duplicate data items */
@@ -221,7 +231,7 @@ val_gen(WT_RAND_STATE *rnd, WT_ITEM *value, uint64_t keyno)
p[10] = '/';
value->size = val_dup_data_len;
} else {
- (void)sprintf(p, "%010" PRIu64, keyno);
+ u64_to_string_zf(keyno, p, 11);
p[10] = '/';
value->size =
value_len(rnd, keyno, g.c_value_min, g.c_value_max);
diff --git a/test/format/wts.c b/test/format/wts.c
index 74c4bb902b3..1600786855a 100644
--- a/test/format/wts.c
+++ b/test/format/wts.c
@@ -546,6 +546,7 @@ wts_stats(void)
WT_DECL_RET;
WT_SESSION *session;
FILE *fp;
+ size_t len;
char *stat_name;
const char *pval, *desc;
uint64_t v;
@@ -582,8 +583,9 @@ wts_stats(void)
/* Data source statistics. */
fprintf(fp, "\n\n====== Data source statistics:\n");
- stat_name = dmalloc(strlen("statistics:") + strlen(g.uri) + 1);
- sprintf(stat_name, "statistics:%s", g.uri);
+ len = strlen("statistics:") + strlen(g.uri) + 1;
+ stat_name = dmalloc(len);
+ snprintf(stat_name, len, "statistics:%s", g.uri);
testutil_check(session->open_cursor(
session, stat_name, NULL, NULL, &cursor));
free(stat_name);
diff --git a/test/java/com/wiredtiger/test/ConcurrentCloseTest.java b/test/java/com/wiredtiger/test/ConcurrentCloseTest.java
index fece0353bf0..fead0b0bf38 100644
--- a/test/java/com/wiredtiger/test/ConcurrentCloseTest.java
+++ b/test/java/com/wiredtiger/test/ConcurrentCloseTest.java
@@ -34,6 +34,7 @@ import com.wiredtiger.db.WiredTigerException;
import com.wiredtiger.db.wiredtiger;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.BufferedReader;
import java.io.File;
@@ -69,7 +70,7 @@ class InsertThread extends Thread {
Session session = conn.open_session(null);
Cursor cursor = session.open_cursor("table:cclose", null,
"overwrite");
- cursor.putKeyString("key"+threadId + "-" + i);
+ cursor.putKeyString("key" + threadId + "-" + i);
cursor.putValueString("value1");
ret = cursor.insert();
cursor.close();
@@ -127,36 +128,36 @@ public class ConcurrentCloseTest {
setup();
try {
List<Thread> threads = new ArrayList<Thread>();
- int i, ret;
+ int i;
- ret = session.create("table:cclose", "key_format=S,value_format=S");
+ assertEquals(0, session.create("table:cclose",
+ "key_format=S,value_format=S"));
Cursor cursor = session.open_cursor("table:cclose", null,
"overwrite");
cursor.putKeyString("key1");
cursor.putValueString("value1");
- ret = cursor.insert();
+ assertEquals(0, cursor.insert());
cursor.close();
- ret = session.close(null);
+ assertEquals(0, session.close(null));
for (i = 0; i < NUM_THREADS; i++) {
Thread insertThread = new InsertThread(conn, i);
- Thread scanThread = new InsertThread(conn, i);
+ Thread scanThread = new ScanThread(conn);
insertThread.start();
scanThread.start();
threads.add(insertThread);
threads.add(scanThread);
}
-
for (Thread thread : threads)
try {
thread.join();
- ret = -1;
}
catch (InterruptedException ie) {
+ fail();
}
- ret = conn.close(null);
- System.exit(ret);
+ assertEquals(0, conn.close(null));
+ System.exit(0);
}
catch (WiredTigerException wte) {
System.err.println("Exception: " + wte);
diff --git a/test/recovery/random-abort.c b/test/recovery/random-abort.c
index 16065cec29e..22a163bedff 100644
--- a/test/recovery/random-abort.c
+++ b/test/recovery/random-abort.c
@@ -245,7 +245,7 @@ main(int argc, char *argv[])
if (!verify_only) {
testutil_make_work_dir(home);
- testutil_assert(__wt_random_init_seed(NULL, &rnd) == 0);
+ __wt_random_init_seed(NULL, &rnd);
if (rand_time) {
timeout = __wt_random(&rnd) % MAX_TIME;
if (timeout < MIN_TIME)
diff --git a/test/suite/test_inmem02.py b/test/suite/test_inmem02.py
new file mode 100644
index 00000000000..9eb8330b2a3
--- /dev/null
+++ b/test/suite/test_inmem02.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+#
+# Public Domain 2014-2016 MongoDB, Inc.
+# Public Domain 2008-2014 WiredTiger, Inc.
+#
+# This is free and unencumbered software released into the public domain.
+#
+# Anyone is free to copy, modify, publish, use, compile, sell, or
+# distribute this software, either in source code form or as a compiled
+# binary, for any purpose, commercial or non-commercial, and by any
+# means.
+#
+# In jurisdictions that recognize copyright laws, the author or authors
+# of this software dedicate any and all copyright interest in the
+# software to the public domain. We make this dedication for the benefit
+# of the public at large and to the detriment of our heirs and
+# successors. We intend this dedication to be an overt act of
+# relinquishment in perpetuity of all present and future rights to this
+# software under copyright law.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+import wiredtiger, wttest
+from time import sleep
+from helper import simple_populate, simple_populate_check
+from helper import key_populate, value_populate
+from wtscenario import make_scenarios
+
+# test_inmem02.py
+# Test in-memory with ignore-cache-size setting.
+class test_inmem02(wttest.WiredTigerTestCase):
+ uri = 'table:inmem02'
+ conn_config = \
+ 'cache_size=3MB,file_manager=(close_idle_time=0),in_memory=true'
+ table_config = 'key_format=S,value_format=S,memory_page_max=32k,leaf_page_max=4k'
+
+ # Add more data than fits into the configured cache and verify it fails.
+ def test_insert_over_allowed(self):
+
+ # Create a new table that is allowed to exceed the cache size, do this
+ # before filling the cache so that the create succeeds
+ self.session.create(
+ self.uri + '_over', 'ignore_in_memory_cache_size=true')
+
+ # Populate a table with enough data to fill the cache.
+ msg = '/WT_CACHE_FULL.*/'
+ self.assertRaisesHavingMessage(wiredtiger.WiredTigerError,
+ lambda:simple_populate(
+ self, self.uri, self.table_config, 10000000), msg)
+
+ # Add some content to the new table
+ cursor = self.session.open_cursor(self.uri + '_over', None)
+ for i in range(1, 1000):
+ cursor[str('%015d' % i)] = str(i) + ': abcdefghijklmnopqrstuvwxyz'
+ cursor.close()
+
+if __name__ == '__main__':
+ wttest.run()
diff --git a/test/utility/test_util.h b/test/utility/test_util.h
index 3c1d0e2630a..1047d1ca8a0 100644
--- a/test/utility/test_util.h
+++ b/test/utility/test_util.h
@@ -108,6 +108,62 @@ typedef struct {
__func__, __LINE__, #call, __VA_ARGS__); \
} while (0)
+/*
+ * u64_to_string --
+ * Convert a uint64_t to a text string.
+ *
+ * Algorithm from Andrei Alexandrescu's talk: "Three Optimization Tips for C++"
+ */
+static inline void
+u64_to_string(uint64_t n, char **pp)
+{
+ static const char hundred_lookup[201] =
+ "0001020304050607080910111213141516171819"
+ "2021222324252627282930313233343536373839"
+ "4041424344454647484950515253545556575859"
+ "6061626364656667686970717273747576777879"
+ "8081828384858687888990919293949596979899";
+ u_int i;
+ char *p;
+
+ /*
+ * The argument pointer references the last element of a buffer (which
+ * must be large enough to hold any possible value).
+ *
+ * Nul-terminate the buffer.
+ */
+ for (p = *pp, *p-- = '\0'; n >= 100; n /= 100) {
+ i = (n % 100) * 2;
+ *p-- = hundred_lookup[i + 1];
+ *p-- = hundred_lookup[i];
+ }
+
+ /* Handle the last two digits. */
+ i = (u_int)n * 2;
+ *p = hundred_lookup[i + 1];
+ if (n >= 10)
+ *--p = hundred_lookup[i];
+
+ /* Return a pointer to the first byte of the text string. */
+ *pp = p;
+}
+
+/*
+ * u64_to_string_zf --
+ * Convert a uint64_t to a text string, zero-filling the buffer.
+ */
+static inline void
+u64_to_string_zf(uint64_t n, char *buf, size_t len)
+{
+ char *p;
+
+ p = buf + (len - 1);
+ u64_to_string(n, &p);
+
+ while (p > buf)
+ *--p = '0';
+}
+
/* Allow tests to add their own death handling. */
extern void (*custom_die)(void);