diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2016-01-28 09:25:16 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2016-01-28 09:30:32 +1100 |
commit | 67e412d4c578e203505446496c67fc1517931cad (patch) | |
tree | 5d1e780ea1e14b1d32ef34aa33716be9bc284f8c /test | |
parent | 3c2ad56b507d82d8d5599dc1ebb50d3ccc087bfb (diff) | |
parent | 7fea169e425b2a56d88351f362d746d5b5dd77f5 (diff) | |
download | mongo-67e412d4c578e203505446496c67fc1517931cad.tar.gz |
Merge branch 'develop' into mongodb-3.2
Diffstat (limited to 'test')
205 files changed, 1658 insertions, 747 deletions
diff --git a/test/bloom/test_bloom.c b/test/bloom/test_bloom.c index 2ad548ed18a..04fc8d1c371 100644 --- a/test/bloom/test_bloom.c +++ b/test/bloom/test_bloom.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/checkpoint/checkpointer.c b/test/checkpoint/checkpointer.c index c4f36ac69ba..ef49a9492ce 100644 --- a/test/checkpoint/checkpointer.c +++ b/test/checkpoint/checkpointer.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -98,7 +98,7 @@ real_checkpointer(void) "Checkpoint thread started stopped\n", EINVAL, 1)); while (g.ntables > g.ntables_created) - sched_yield(); + __wt_yield(); if ((ret = g.conn->open_session(g.conn, NULL, NULL, &session)) != 0) return (log_print_err("conn.open_session", ret, 1)); diff --git a/test/checkpoint/test_checkpoint.c b/test/checkpoint/test_checkpoint.c index 3131a30bba4..1914ad0188a 100644 --- a/test/checkpoint/test_checkpoint.c +++ b/test/checkpoint/test_checkpoint.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/checkpoint/test_checkpoint.h b/test/checkpoint/test_checkpoint.h index dd2426ef2f2..09edaeb84bc 100644 --- a/test/checkpoint/test_checkpoint.h +++ b/test/checkpoint/test_checkpoint.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/checkpoint/workers.c b/test/checkpoint/workers.c index b8ca5a37d2b..e4fe7bd1b29 100644 --- a/test/checkpoint/workers.c +++ b/test/checkpoint/workers.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -195,7 +195,7 @@ real_worker(void) goto err; } - for (i = 0; i < g.nops && g.running; ++i, sched_yield()) { + for (i = 0; i < g.nops && g.running; ++i, __wt_yield()) { if ((ret = session->begin_transaction(session, NULL)) != 0) { (void)log_print_err( "real_worker:begin_transaction", ret, 1); diff --git a/test/fops/file.c b/test/fops/file.c index c2eb9593056..4cd92e7b590 100644 --- a/test/fops/file.c +++ b/test/fops/file.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -45,7 +45,7 @@ obj_bulk(void) testutil_die(ret, "session.create"); if (ret == 0) { - sched_yield(); + __wt_yield(); if ((ret = session->open_cursor( session, uri, NULL, "bulk", &c)) == 0) { if ((ret = c->close(c)) != 0) @@ -78,7 +78,7 @@ obj_bulk_unique(int force) if ((ret = session->create(session, new_uri, config)) != 0) testutil_die(ret, "session.create: %s", new_uri); - sched_yield(); + __wt_yield(); if ((ret = session->open_cursor(session, new_uri, NULL, "bulk", &c)) != 0) testutil_die(ret, "session.open_cursor: %s", new_uri); @@ -154,7 +154,7 @@ obj_create_unique(int force) if ((ret = session->create(session, new_uri, config)) != 0) testutil_die(ret, "session.create"); - sched_yield(); + __wt_yield(); while ((ret = session->drop( session, new_uri, force ? "force" : NULL)) != 0) if (ret != EBUSY) @@ -200,6 +200,23 @@ obj_checkpoint(void) } void +obj_rebalance(void) +{ + WT_SESSION *session; + int ret; + + if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + testutil_die(ret, "conn.session"); + + if ((ret = session->rebalance(session, uri, NULL)) != 0) + if (ret != ENOENT && ret != EBUSY) + testutil_die(ret, "session.rebalance"); + + if ((ret = session->close(session, NULL)) != 0) + testutil_die(ret, "session.close"); +} + +void obj_upgrade(void) { WT_SESSION *session; diff --git a/test/fops/fops.c b/test/fops/fops.c index 0a83e8511f4..fbc9d9c6048 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -39,6 +39,7 @@ typedef struct { int create_unique; /* session.create of new file */ int cursor; /* session.open_cursor */ int drop; /* session.drop */ + int rebalance; /* session.rebalance */ int upgrade; /* session.upgrade */ int verify; /* session.verify */ } STATS; @@ -102,12 +103,12 @@ fop(void *arg) u_int i; id = (uintptr_t)arg; - sched_yield(); /* Get all the threads created. */ + __wt_yield(); /* Get all the threads created. */ s = &run_stats[id]; __wt_random_init(&rnd); - for (i = 0; i < nops; ++i, sched_yield()) + for (i = 0; i < nops; ++i, __wt_yield()) switch (__wt_random(&rnd) % 9) { case 0: ++s->bulk; @@ -134,14 +135,18 @@ fop(void *arg) obj_upgrade(); break; case 6: + ++s->rebalance; + obj_rebalance(); + break; + case 7: ++s->verify; obj_verify(); break; - case 7: + case 8: ++s->bulk_unique; obj_bulk_unique(__wt_random(&rnd) & 1); break; - case 8: + case 9: ++s->create_unique; obj_create_unique(__wt_random(&rnd) & 1); break; @@ -163,9 +168,10 @@ print_stats(u_int nthreads) s = run_stats; for (id = 0; id < nthreads; ++id, ++s) printf( - "%2d: bulk %3d, ckpt %3d, create %3d, cursor %3d, " - "drop %3d, upg %3d, vrfy %3d\n", + "%2d:" + "\t" "bulk %3d, checkpoint %3d, create %3d, cursor %3d,\n" + "\t" "drop %3d, rebalance %3d, upgrade %3d, verify %3d\n", id, s->bulk + s->bulk_unique, s->ckpt, s->create + s->create_unique, s->cursor, - s->drop, s->upgrade, s->verify); + s->drop, s->rebalance, s->upgrade, s->verify); } diff --git a/test/fops/t.c b/test/fops/t.c index 12535f152fd..0881c23d7d4 100644 --- a/test/fops/t.c +++ b/test/fops/t.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/fops/thread.h b/test/fops/thread.h index 79c081592c1..f9707c14590 100644 --- a/test/fops/thread.h +++ b/test/fops/thread.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -63,5 +63,6 @@ void obj_create(void); void obj_create_unique(int); void obj_cursor(void); void obj_drop(int); +void obj_rebalance(void); void obj_upgrade(void); void obj_verify(void); diff --git a/test/format/Makefile.am b/test/format/Makefile.am index 17cbd53222b..8a2e2b49e4b 100644 --- a/test/format/Makefile.am +++ b/test/format/Makefile.am @@ -9,7 +9,7 @@ noinst_PROGRAMS = t noinst_SCRIPTS = s_dumpcmp t_SOURCES =\ config.h format.h backup.c bulk.c compact.c config.c lrt.c ops.c \ - salvage.c t.c util.c wts.c + rebalance.c salvage.c t.c util.c wts.c if HAVE_BERKELEY_DB t_SOURCES += bdb.c diff --git a/test/format/backup.c b/test/format/backup.c index 5805012e1e0..748494bf841 100644 --- a/test/format/backup.c +++ b/test/format/backup.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/format/bdb.c b/test/format/bdb.c index fec23112549..d7b4bca62f2 100644 --- a/test/format/bdb.c +++ b/test/format/bdb.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/format/bulk.c b/test/format/bulk.c index 75a158af741..28189e25b65 100644 --- a/test/format/bulk.c +++ b/test/format/bulk.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -52,23 +52,17 @@ wts_load(void) /* * No bulk load with data-sources. * - * XXX - * No bulk load with in-memory configurations (currently, WiredTiger - * fails in the column-store case unless you specify the key). - * * No bulk load with custom collators, the order of insertion will not * match the collation order. */ is_bulk = true; if (DATASOURCE("kvsbdb") && DATASOURCE("helium")) is_bulk = false; - if (g.c_in_memory) - is_bulk = false; if (g.c_reverse) is_bulk = false; if ((ret = session->open_cursor(session, g.uri, NULL, - is_bulk ? "bulk" : NULL, &cursor)) != 0) + is_bulk ? "bulk,append" : NULL, &cursor)) != 0) die(ret, "session.open_cursor"); /* Set up the key/value buffers. */ diff --git a/test/format/compact.c b/test/format/compact.c index ad603504023..fdfa597e07e 100644 --- a/test/format/compact.c +++ b/test/format/compact.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/format/config.c b/test/format/config.c index 7aa4575efbd..866e210e556 100644 --- a/test/format/config.c +++ b/test/format/config.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -327,10 +327,14 @@ config_in_memory(void) g.c_backups = 0; if (!config_is_perm("checkpoints")) g.c_checkpoints = 0; - if (!config_is_perm("compression")) - g.c_compression = 0; + if (!config_is_perm("compression")) { + g.c_compression = dstrdup("none"); + g.c_compression_flag = COMPRESS_NONE; + } if (!config_is_perm("logging")) g.c_logging = 0; + if (!config_is_perm("rebalance")) + g.c_rebalance = 0; if (!config_is_perm("salvage")) g.c_salvage = 0; if (!config_is_perm("verify")) @@ -496,7 +500,7 @@ config_clear(void) F_CLR(cp, C_TEMP); if (!F_ISSET(cp, C_PERM) && F_ISSET(cp, C_STRING) && cp->vstr != NULL) { - free(*cp->vstr); + free((void *)*cp->vstr); *cp->vstr = NULL; } } @@ -561,7 +565,7 @@ config_single(const char *s, int perm) &g.c_logging_compression_flag); *cp->vstr = strdup(ep); } else { - free(*cp->vstr); + free((void *)*cp->vstr); *cp->vstr = strdup(ep); } if (*cp->vstr == NULL) diff --git a/test/format/config.h b/test/format/config.h index a259217690c..a5190469c7f 100644 --- a/test/format/config.h +++ b/test/format/config.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -263,8 +263,12 @@ static CONFIG c[] = { "the number of runs", C_IGNORE, 0, UINT_MAX, UINT_MAX, &g.c_runs, NULL }, + { "rebalance", + "rebalance testing", /* 100% */ + C_BOOL, 100, 1, 0, &g.c_rebalance, NULL }, + { "salvage", - "verify integrity via salvage", /* 100% */ + "salvage testing", /* 100% */ C_BOOL, 100, 1, 0, &g.c_salvage, NULL }, { "split_pct", diff --git a/test/format/format.h b/test/format/format.h index 88300c28292..bf4d1c0a277 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -122,6 +122,8 @@ typedef struct { char *helium_mount; /* Helium volume */ + char wiredtiger_open_config[8 * 1024]; /* Database open config */ + #ifdef HAVE_BERKELEY_DB void *bdb; /* BDB comparison handle */ void *dbc; /* BDB cursor handle */ @@ -176,26 +178,26 @@ typedef struct { uint32_t c_cache; uint32_t c_compact; uint32_t c_checkpoints; - char *c_checksum; + char *c_checksum; uint32_t c_chunk_size; - char *c_compression; - char *c_encryption; - char *c_config_open; + char *c_compression; + char *c_encryption; + char *c_config_open; uint32_t c_data_extend; - char *c_data_source; + char *c_data_source; uint32_t c_delete_pct; uint32_t c_dictionary; uint32_t c_direct_io; uint32_t c_evict_max; uint32_t c_firstfit; - char *c_file_type; + char *c_file_type; uint32_t c_huffman_key; uint32_t c_huffman_value; uint32_t c_in_memory; uint32_t c_insert_pct; uint32_t c_internal_key_truncation; uint32_t c_intl_page_max; - char *c_isolation; + char *c_isolation; uint32_t c_key_gap; uint32_t c_key_max; uint32_t c_key_min; @@ -203,7 +205,7 @@ typedef struct { uint32_t c_leak_memory; uint32_t c_logging; uint32_t c_logging_archive; - char *c_logging_compression; + char *c_logging_compression; uint32_t c_logging_prealloc; uint32_t c_long_running_txn; uint32_t c_lsm_worker_threads; @@ -216,6 +218,7 @@ typedef struct { uint32_t c_reverse; uint32_t c_rows; uint32_t c_runs; + uint32_t c_rebalance; uint32_t c_salvage; uint32_t c_split_pct; uint32_t c_statistics; @@ -309,6 +312,7 @@ void config_print(int); void config_setup(void); void config_single(const char *, int); void *dmalloc(size_t); +char *dstrdup(const char *); void fclose_and_clear(FILE **); void key_gen(uint8_t *, size_t *, uint64_t); void key_gen_insert(WT_RAND_STATE *, uint8_t *, size_t *, uint64_t); @@ -328,6 +332,8 @@ void wts_load(void); void wts_open(const char *, int, WT_CONNECTION **); void wts_ops(int); void wts_read_scan(void); +void wts_rebalance(void); +void wts_reopen(void); void wts_salvage(void); void wts_stats(void); void wts_verify(const char *); diff --git a/test/format/lrt.c b/test/format/lrt.c index 85b6e29f224..b7392829d30 100644 --- a/test/format/lrt.c +++ b/test/format/lrt.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/format/ops.c b/test/format/ops.c index c705d362fe8..36d56df1505 100644 --- a/test/format/ops.c +++ b/test/format/ops.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -504,7 +504,7 @@ skip_insert: if (col_update(tinfo, */ if (!insert) { dir = (int)mmrand(&tinfo->rnd, 0, 1); - for (np = 0; np < mmrand(&tinfo->rnd, 1, 8); ++np) { + for (np = 0; np < mmrand(&tinfo->rnd, 1, 100); ++np) { if (notfound) break; if (nextprev(cursor, dir, ¬found)) diff --git a/test/format/rebalance.c b/test/format/rebalance.c new file mode 100644 index 00000000000..8e8fa1a371f --- /dev/null +++ b/test/format/rebalance.c @@ -0,0 +1,84 @@ +/*- + * 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. + */ + +#include "format.h" + +void +wts_rebalance(void) +{ + WT_CONNECTION *conn; + WT_SESSION *session; + int ret; + char cmd[1024]; + + if (g.c_rebalance == 0) + return; + + track("rebalance", 0ULL, NULL); + + /* Dump the current object. */ + (void)snprintf(cmd, sizeof(cmd), + "../../wt -h %s dump -f %s/rebalance.orig %s", + g.home, g.home, g.uri); + if ((ret = system(cmd)) != 0) + die(ret, "command failed: %s", cmd); + + /* Rebalance, then verify the object. */ + wts_reopen(); + conn = g.wts_conn; + if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + die(ret, "connection.open_session"); + if (g.logging != 0) + (void)g.wt_api->msg_printf(g.wt_api, session, + "=============== rebalance start ==============="); + + if ((ret = session->rebalance(session, g.uri, NULL)) != 0) + die(ret, "session.rebalance: %s: %s", g.uri); + + if (g.logging != 0) + (void)g.wt_api->msg_printf(g.wt_api, session, + "=============== rebalance stop ==============="); + if ((ret = session->close(session, NULL)) != 0) + die(ret, "session.close"); + + wts_verify("post-rebalance verify"); + wts_close(); + + (void)snprintf(cmd, sizeof(cmd), + "../../wt -h %s dump -f %s/rebalance.new %s", + g.home, g.home, g.uri); + if ((ret = system(cmd)) != 0) + die(ret, "command failed: %s", cmd); + + /* Compare the old/new versions of the object. */ + (void)snprintf(cmd, sizeof(cmd), + "cmp %s/rebalance.orig %s/rebalance.new > /dev/null", + g.home, g.home); + if ((ret = system(cmd)) != 0) + die(ret, "command failed: %s", cmd); +} diff --git a/test/format/salvage.c b/test/format/salvage.c index 33902525786..d0358e998b4 100644 --- a/test/format/salvage.c +++ b/test/format/salvage.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/format/t.c b/test/format/t.c index 603706e0ba1..37ba982c987 100644 --- a/test/format/t.c +++ b/test/format/t.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -238,6 +238,11 @@ main(int argc, char *argv[]) wts_close(); /* + * Rebalance testing. + */ + wts_rebalance(); + + /* * If single-threaded, we can dump and compare the WiredTiger * and Berkeley DB data sets. */ diff --git a/test/format/util.c b/test/format/util.c index 88a41f2eef1..2b6b9d67fc3 100644 --- a/test/format/util.c +++ b/test/format/util.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -50,7 +50,7 @@ dmalloc(size_t len) * dstrdup -- * Call strdup, dying on failure. */ -static char * +char * dstrdup(const char *str) { char *p; diff --git a/test/format/wts.c b/test/format/wts.c index c1ea469d7b5..b75a0c793eb 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -132,12 +132,12 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp) { WT_CONNECTION *conn; int ret; - char config[4096], *end, *p; + char *config, *end, *p, helium_config[1024]; *connp = NULL; - p = config; - end = config + sizeof(config); + config = p = g.wiredtiger_open_config; + end = config + sizeof(g.wiredtiger_open_config); p += snprintf(p, REMAIN(p, end), "create,checkpoint_sync=false,cache_size=%" PRIu32 "MB", @@ -257,22 +257,36 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp) if (DATASOURCE("helium")) { if (g.helium_mount == NULL) die(EINVAL, "no Helium mount point specified"); - (void)snprintf(config, sizeof(config), + (void)snprintf(helium_config, sizeof(helium_config), "entry=wiredtiger_extension_init,config=[" "helium_verbose=0," "dev1=[helium_devices=\"he://./%s\"," "helium_o_volume_truncate=1]]", g.helium_mount); - if ((ret = - conn->load_extension(conn, HELIUM_PATH, config)) != 0) + if ((ret = conn->load_extension( + conn, HELIUM_PATH, helium_config)) != 0) die(ret, "WT_CONNECTION.load_extension: %s:%s", - HELIUM_PATH, config); + HELIUM_PATH, helium_config); } *connp = conn; } /* + * wts_reopen -- + * Re-open a connection to a WiredTiger database. + */ +void +wts_reopen(void) +{ + int ret; + + if ((ret = wiredtiger_open(g.home, + &event_handler, g.wiredtiger_open_config, &g.wts_conn)) != 0) + die(ret, "wiredtiger_open: %s", g.home); +} + +/* * wts_create -- * Create the underlying store. */ @@ -452,6 +466,8 @@ wts_close(void) if ((ret = conn->close(conn, config)) != 0) die(ret, "connection.close"); + g.wts_conn = NULL; + g.wt_api = NULL; } void diff --git a/test/huge/huge.c b/test/huge/huge.c index 097dce16acb..d09f6f375fb 100644 --- a/test/huge/huge.c +++ b/test/huge/huge.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/AsyncTest.java b/test/java/com/wiredtiger/test/AsyncTest.java index 326a86b93cb..fc28e669313 100644 --- a/test/java/com/wiredtiger/test/AsyncTest.java +++ b/test/java/com/wiredtiger/test/AsyncTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/AutoCloseTest.java b/test/java/com/wiredtiger/test/AutoCloseTest.java index b55dbb0df03..d7304bb8a44 100644 --- a/test/java/com/wiredtiger/test/AutoCloseTest.java +++ b/test/java/com/wiredtiger/test/AutoCloseTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/BackupCursorTest.java b/test/java/com/wiredtiger/test/BackupCursorTest.java index c27b85619fc..dd25e4df7d6 100644 --- a/test/java/com/wiredtiger/test/BackupCursorTest.java +++ b/test/java/com/wiredtiger/test/BackupCursorTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/ConfigTest.java b/test/java/com/wiredtiger/test/ConfigTest.java new file mode 100644 index 00000000000..2afde7df2dc --- /dev/null +++ b/test/java/com/wiredtiger/test/ConfigTest.java @@ -0,0 +1,192 @@ +/*- + * 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. + */ +package com.wiredtiger.test; + +import com.wiredtiger.db.Connection; +import com.wiredtiger.db.Cursor; +import com.wiredtiger.db.Session; +import com.wiredtiger.db.WiredTigerException; +import com.wiredtiger.db.wiredtiger; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.junit.Assert; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +public class ConfigTest { + Connection conn; + Session session; + + public static final String uri = "table:test_config06"; + public static final String key = "keyABCDEFGHIJKLMNOPQRSTUVWXYZ"; + public static final String value = "valueABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public void session_config(String config) { + Exception e = null; + + try { + session.create(uri, config); + } + catch (WiredTigerException wte) { + e = wte; + } + + Assert.assertTrue(e != null && + e.toString().indexOf("Invalid argument") >= 0); + } + + // Edge cases for key/value formats. + @Test + public void test_session_config() + throws WiredTigerException { + setup(); + System.err.println("\n-- expect error output --"); + session_config("key_format=A,value_format=S"); + session_config("key_format=S,value_format=A"); + session_config("key_format=0s,value_format=s"); + session_config("key_format=s,value_format=0s"); + session_config("key_format=0t,value_format=4t"); + session_config("key_format=4t,value_format=0t"); + System.err.println("-- end expected error output --"); + teardown(); + } + + // Smoke-test the string formats with length specifiers; both formats should + // ignore trailing bytes, verify that. + public void format_string(String fmt, int len) + throws WiredTigerException { + setup(); + session.create(uri, "key_format=" + len + fmt + + ",value_format=" + len + fmt); + Cursor cursor = session.open_cursor(uri, null, null); + cursor.putKeyString(key); + cursor.putValueString(value); + cursor.insert(); + cursor.putKeyString(key.substring(0,len)); + assertEquals(0, cursor.search()); + assertEquals(value.substring(0,len), cursor.getValueString()); + cursor.close(); + session.drop(uri, null); + teardown(); + } + + @Test + public void test_format_string_S_1() + throws WiredTigerException { + format_string("S", 1); + } + @Test + public void test_format_string_S_4() + throws WiredTigerException { + format_string("S", 4); + } + @Test + public void test_format_string_S_10() + throws WiredTigerException { + format_string("S", 10); + } + @Test + public void test_format_string_s_1() + throws WiredTigerException { + format_string("s", 1); + } + @Test + public void test_format_string_s_4() + throws WiredTigerException { + format_string("s", 4); + } + @Test + public void test_format_string_s_10() + throws WiredTigerException { + format_string("s", 10); + } + + @Test + public void test_format_string_S_default() + throws WiredTigerException { + setup(); + session.create(uri, "key_format=S,value_format=S"); + Cursor cursor = session.open_cursor(uri, null, null); + cursor.putKeyString(key); + cursor.putValueString(value); + cursor.insert(); + cursor.putKeyString(key); + assertEquals(0, cursor.search()); + assertEquals(value, cursor.getValueString()); + cursor.close(); + session.drop(uri, null); + teardown(); + } + + @Test + public void test_format_string_s_default() + throws WiredTigerException { + setup(); + session.create(uri, "key_format=s,value_format=s"); + Cursor cursor = session.open_cursor(uri, null, null); + cursor.putKeyString(key); + cursor.putValueString(value); + cursor.insert(); + cursor.putKeyString(key.substring(0,1)); + assertEquals(0, cursor.search()); + assertEquals(value.substring(0,1), cursor.getValueString()); + cursor.close(); + session.drop(uri, null); + teardown(); + } + + public static void main(String[] args) { + ConfigTest tester = new ConfigTest(); + try { + tester.test_session_config(); + tester.test_format_string_S_1(); + tester.test_format_string_S_4(); + tester.test_format_string_S_10(); + tester.test_format_string_s_1(); + tester.test_format_string_s_4(); + tester.test_format_string_s_10(); + tester.test_format_string_S_default(); + tester.test_format_string_s_default(); + } catch (WiredTigerException wte) { + System.err.println("WiredTigerException: " + wte); + } + } + + private void setup() { + conn = wiredtiger.open("WT_HOME", "create"); + session = conn.open_session(null); + } + + private void teardown() { + session.close(""); + conn.close(""); + } + +} diff --git a/test/java/com/wiredtiger/test/CursorTest.java b/test/java/com/wiredtiger/test/CursorTest.java index f332382dc34..4cd244e5b10 100644 --- a/test/java/com/wiredtiger/test/CursorTest.java +++ b/test/java/com/wiredtiger/test/CursorTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/CursorTest02.java b/test/java/com/wiredtiger/test/CursorTest02.java index 87eec66f71a..f107bf0b8f2 100644 --- a/test/java/com/wiredtiger/test/CursorTest02.java +++ b/test/java/com/wiredtiger/test/CursorTest02.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/ExceptionTest.java b/test/java/com/wiredtiger/test/ExceptionTest.java index b6330c62e0e..0c71ea4371b 100644 --- a/test/java/com/wiredtiger/test/ExceptionTest.java +++ b/test/java/com/wiredtiger/test/ExceptionTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/PackTest.java b/test/java/com/wiredtiger/test/PackTest.java index ed60db86d96..f24ca6e2def 100644 --- a/test/java/com/wiredtiger/test/PackTest.java +++ b/test/java/com/wiredtiger/test/PackTest.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/PackTest02.java b/test/java/com/wiredtiger/test/PackTest02.java index 63f4283710b..847e3c4ab08 100644 --- a/test/java/com/wiredtiger/test/PackTest02.java +++ b/test/java/com/wiredtiger/test/PackTest02.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/PackTest03.java b/test/java/com/wiredtiger/test/PackTest03.java index 2f19f3f8f04..c3ae854dcaf 100644 --- a/test/java/com/wiredtiger/test/PackTest03.java +++ b/test/java/com/wiredtiger/test/PackTest03.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/java/com/wiredtiger/test/WiredTigerSuite.java b/test/java/com/wiredtiger/test/WiredTigerSuite.java index a690b094323..5bd98d53fac 100644 --- a/test/java/com/wiredtiger/test/WiredTigerSuite.java +++ b/test/java/com/wiredtiger/test/WiredTigerSuite.java @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -35,6 +35,7 @@ import org.junit.runners.Suite; AsyncTest.class, AutoCloseTest.class, BackupCursorTest.class, + ConfigTest.class, CursorTest.class, CursorTest02.class, ExceptionTest.class, diff --git a/test/packing/intpack-test.c b/test/packing/intpack-test.c index 361ee696b20..a48f9fc4fe4 100644 --- a/test/packing/intpack-test.c +++ b/test/packing/intpack-test.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/packing/intpack-test2.c b/test/packing/intpack-test2.c index 02df8447908..68f794f0bf5 100644 --- a/test/packing/intpack-test2.c +++ b/test/packing/intpack-test2.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/packing/intpack-test3.c b/test/packing/intpack-test3.c index 7005bda8546..2bce88c3568 100644 --- a/test/packing/intpack-test3.c +++ b/test/packing/intpack-test3.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/packing/packing-test.c b/test/packing/packing-test.c index 0c3eb78da02..1d2194bee50 100644 --- a/test/packing/packing-test.c +++ b/test/packing/packing-test.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -43,7 +43,7 @@ check(const char *fmt, ...) assert(__wt_struct_sizev(NULL, &len, fmt, ap) == 0); va_end(ap); - assert(len < sizeof(buf)); + assert(len > 0 && len < sizeof(buf)); va_start(ap, fmt); assert(__wt_struct_packv(NULL, buf, sizeof(buf), fmt, ap) == 0); @@ -61,6 +61,7 @@ main(void) check("iii", 0, 101, -99); check("3i", 0, 101, -99); check("iS", 42, "forty two"); + check("s", "a big string"); #if 0 /* TODO: need a WT_ITEM */ check("u", r"\x42" * 20) diff --git a/test/recovery/recovery.c b/test/recovery/recovery.c index f7fbf76038b..5772865f030 100644 --- a/test/recovery/recovery.c +++ b/test/recovery/recovery.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/salvage/salvage.c b/test/salvage/salvage.c index a23c95c694c..c2ad6224b11 100644 --- a/test/salvage/salvage.c +++ b/test/salvage/salvage.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -518,7 +518,7 @@ build(int ikey, int ivalue, int cnt) } CHECK(session->create(session, "file:" LOAD, config) == 0); CHECK(session->open_cursor( - session, "file:" LOAD, NULL, "bulk", &cursor) == 0); + session, "file:" LOAD, NULL, "bulk,append", &cursor) == 0); for (; cnt > 0; --cnt, ++ikey, ++ivalue) { switch (page_type) { /* Build the key. */ case WT_PAGE_COL_FIX: diff --git a/test/suite/helper.py b/test/suite/helper.py index 35803eaa843..3c460e23d08 100644 --- a/test/suite/helper.py +++ b/test/suite/helper.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/run.py b/test/suite/run.py index 5e7b76a79b9..f7f0d1399ff 100644 --- a/test/suite/run.py +++ b/test/suite/run.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/suite_random.py b/test/suite/suite_random.py index edb59b80e15..fd580cec43b 100644 --- a/test/suite/suite_random.py +++ b/test/suite/suite_random.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/suite_subprocess.py b/test/suite/suite_subprocess.py index 66381ed8a0d..df89d82e4c9 100644 --- a/test/suite/suite_subprocess.py +++ b/test/suite/suite_subprocess.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_async01.py b/test/suite/test_async01.py index fee5e8232f1..71a18a68121 100644 --- a/test/suite/test_async01.py +++ b/test/suite/test_async01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -28,7 +28,7 @@ import sys, threading, wiredtiger, wttest from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, WiredTigerError +from wiredtiger import WiredTigerError from wtscenario import check_scenarios # TODO - tmp code @@ -132,18 +132,10 @@ class test_async01(wttest.WiredTigerTestCase, suite_subprocess): ('table-row', dict(tablekind='row',uri='table')), ]) - # Overrides WiredTigerTestCase so that we can configure - # async operations. - def setUpConnectionOpen(self, dir): - self.home = dir - conn_params = \ - 'create,error_prefix="%s: ",' % self.shortid() + \ - 'async=(enabled=true,ops_max=%s,' % self.async_ops + \ - 'threads=%s)' % self.async_threads - sys.stdout.flush() - conn = wiredtiger_open(dir, conn_params) - self.pr(`conn`) - return conn + # Enable async for this test. + def conn_config(self, dir): + return 'async=(enabled=true,ops_max=%s,' % self.async_ops + \ + 'threads=%s)' % self.async_threads def genkey(self, i): if self.tablekind == 'row': diff --git a/test/suite/test_async02.py b/test/suite/test_async02.py index c878e8dd114..7aa1b85a2f3 100644 --- a/test/suite/test_async02.py +++ b/test/suite/test_async02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -28,15 +28,9 @@ import sys, threading, wiredtiger, wttest from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, WiredTigerError +from wiredtiger import WiredTigerError from wtscenario import check_scenarios -# TODO - tmp code -def tty_pr(s): - o = open('/dev/tty', 'w') - o.write(s + '\n') - o.close() - class Callback(wiredtiger.AsyncCallback): def __init__(self, current): self.current = current @@ -49,7 +43,7 @@ class Callback(wiredtiger.AsyncCallback): self.lock = threading.RLock() def notify_error(self, key, value, optype, exp, desc): - tty_pr('ERROR: notify(' + str(key) + ',' + str(value) + ',' + + self.tty('ERROR: notify(' + str(key) + ',' + str(value) + ',' + str(optype) + '): ' + 'Expected: ' + str(exp) + ' ' + desc) def notify(self, op, op_ret, flags): @@ -105,7 +99,7 @@ class Callback(wiredtiger.AsyncCallback): self.nerror += 1 self.lock.release() except (BaseException) as err: - tty_pr('ERROR: exception in notify: ' + str(err)) + self.tty('ERROR: exception in notify: ' + str(err)) raise return 0 @@ -135,18 +129,10 @@ class test_async02(wttest.WiredTigerTestCase, suite_subprocess): ('table-row', dict(tablekind='row',uri='table')), ]) - # Overrides WiredTigerTestCase so that we can configure - # async operations. - def setUpConnectionOpen(self, dir): - self.home = dir - conn_params = \ - 'create,error_prefix="%s: ",' % self.shortid() + \ - 'async=(enabled=true,ops_max=%s,' % self.async_ops + \ - 'threads=%s)' % self.async_threads - sys.stdout.flush() - conn = wiredtiger_open(dir, conn_params) - self.pr(`conn`) - return conn + # Enable async for this test. + def conn_config(self, dir): + return 'async=(enabled=true,ops_max=%s,' % self.async_ops + \ + 'threads=%s)' % self.async_threads def genkey(self, i): if self.tablekind == 'row': diff --git a/test/suite/test_async03.py b/test/suite/test_async03.py index ea62f8c525b..41939bb578a 100644 --- a/test/suite/test_async03.py +++ b/test/suite/test_async03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -26,7 +26,7 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR # OTHER DEALINGS IN THE SOFTWARE. -from wiredtiger import wiredtiger_open, WiredTigerError +from wiredtiger import WiredTigerError import sys, threading, wiredtiger, wttest class Callback(wiredtiger.AsyncCallback): @@ -47,19 +47,9 @@ class test_async03(wttest.WiredTigerTestCase): """ table_name1 = 'test_async03' - # Overrides WiredTigerTestCase so that we can configure - # async operations. - def setUpConnectionOpen(self, dir): - self.home = dir - # Note: this usage is intentionally wrong, - # it is missing async=(enabled=true,... - conn_params = \ - 'create,error_prefix="%s: ",' % self.shortid() + \ - 'async=(ops_max=50,threads=3)' # missing enabled=true ! - sys.stdout.flush() - conn = wiredtiger_open(dir, conn_params) - self.pr(`conn`) - return conn + # Note: this usage is intentionally wrong, it is missing + # async=(enabled=true,... + conn_config = 'async=(ops_max=50,threads=3)' def test_ops(self): tablearg = 'table:' + self.table_name1 diff --git a/test/suite/test_autoclose.py b/test/suite/test_autoclose.py index 166e4190283..c5633d5a21e 100644 --- a/test/suite/test_autoclose.py +++ b/test/suite/test_autoclose.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_backup01.py b/test/suite/test_backup01.py index f6e9cd87291..92d39514440 100644 --- a/test/suite/test_backup01.py +++ b/test/suite/test_backup01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -98,7 +98,7 @@ class test_backup(wttest.WiredTigerTestCase, suite_subprocess): # Check that a URI doesn't exist, both the meta-data and the file names. def confirmPathDoesNotExist(self, uri): - conn = wiredtiger.wiredtiger_open(self.dir) + conn = self.wiredtiger_open(self.dir) session = conn.open_session() self.assertRaises(wiredtiger.WiredTigerError, lambda: session.open_cursor(uri, None, None)) diff --git a/test/suite/test_backup02.py b/test/suite/test_backup02.py index 79044e04986..095bfbe404a 100644 --- a/test/suite/test_backup02.py +++ b/test/suite/test_backup02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_backup03.py b/test/suite/test_backup03.py index 880469c2486..e810a2ec714 100644 --- a/test/suite/test_backup03.py +++ b/test/suite/test_backup03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -75,13 +75,8 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess): ] scenarios = number_scenarios(multiply_scenarios('.', list)) - # Create a large cache, otherwise this test runs quite slowly. - def setUpConnectionOpen(self, dir): - wtopen_args = 'create,cache_size=1G' - conn = wiredtiger.wiredtiger_open(dir, wtopen_args) - self.pr(`conn`) - return conn + conn_config = 'cache_size=1G' # Populate a set of objects. def populate(self): @@ -102,7 +97,7 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess): # Check that a URI doesn't exist, both the meta-data and the file names. def confirmPathDoesNotExist(self, uri): - conn = wiredtiger.wiredtiger_open(self.dir) + conn = self.wiredtiger_open(self.dir) session = conn.open_session() self.assertRaises(wiredtiger.WiredTigerError, lambda: session.open_cursor(uri, None, None)) diff --git a/test/suite/test_backup04.py b/test/suite/test_backup04.py index a0a52f49817..852a22c1e0c 100644 --- a/test/suite/test_backup04.py +++ b/test/suite/test_backup04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -59,13 +59,9 @@ class test_backup_target(wttest.WiredTigerTestCase, suite_subprocess): ]) # Create a large cache, otherwise this test runs quite slowly. - def setUpConnectionOpen(self, dir): - wtopen_args = \ - 'create,cache_size=1G,log=(archive=false,enabled,file_max=%s)' % \ + def conn_config(self, dir): + return 'cache_size=1G,log=(archive=false,enabled,file_max=%s)' % \ self.logmax - conn = wiredtiger.wiredtiger_open(dir, wtopen_args) - self.pr(`conn`) - return conn def populate(self, uri, dsize, rows): self.pr('populate: ' + uri + ' with ' + str(rows) + ' rows') diff --git a/test/suite/test_backup05.py b/test/suite/test_backup05.py index 8ab329f761a..8b176d0f7d7 100644 --- a/test/suite/test_backup05.py +++ b/test/suite/test_backup05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -35,7 +35,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios from helper import copy_wiredtiger_home import wttest diff --git a/test/suite/test_base01.py b/test/suite/test_base01.py index 8d4c03e2bda..2a5f96cbae2 100644 --- a/test/suite/test_base01.py +++ b/test/suite/test_base01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_base02.py b/test/suite/test_base02.py index 491899fd0ed..70117573241 100644 --- a/test/suite/test_base02.py +++ b/test/suite/test_base02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_base03.py b/test/suite/test_base03.py index 6a9a53112b9..fe6fa53c288 100644 --- a/test/suite/test_base03.py +++ b/test/suite/test_base03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_base04.py b/test/suite/test_base04.py index feb68bf8a08..973ee1327a5 100644 --- a/test/suite/test_base04.py +++ b/test/suite/test_base04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_base05.py b/test/suite/test_base05.py index 7d5ff59b2c9..f191f23561f 100644 --- a/test/suite/test_base05.py +++ b/test/suite/test_base05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_baseconfig.py b/test/suite/test_baseconfig.py index 6ac3654af11..89b3b29544e 100644 --- a/test/suite/test_baseconfig.py +++ b/test/suite/test_baseconfig.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -35,7 +35,7 @@ class test_baseconfig(wttest.WiredTigerTestCase): def test_baseconfig(self): # Open up another database and modify the baseconfig os.mkdir("A") - conn = wiredtiger.wiredtiger_open("A", 'create') + conn = self.wiredtiger_open("A", 'create') self.assertTrue(os.path.exists("A/WiredTiger.basecfg")) with open("A/WiredTiger.basecfg", "a") as basecfg_file: basecfg_file.write("foo!") @@ -44,10 +44,10 @@ class test_baseconfig(wttest.WiredTigerTestCase): # Open a database, we should assert here as the basecfg is invalid self.assertRaisesWithMessage( wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open("A", ''), + lambda: self.wiredtiger_open("A", ''), '/unknown configuration key/') - conn = wiredtiger.wiredtiger_open("A", "create,config_base=false") + conn = self.wiredtiger_open("A", "create,config_base=false") conn.close() if __name__ == '__main__': diff --git a/test/suite/test_bug001.py b/test/suite/test_bug001.py index 08177369309..79ade05d2c7 100644 --- a/test/suite/test_bug001.py +++ b/test/suite/test_bug001.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug003.py b/test/suite/test_bug003.py index e4a2196e7d8..739279a0141 100644 --- a/test/suite/test_bug003.py +++ b/test/suite/test_bug003.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug004.py b/test/suite/test_bug004.py index 5f8d35f2404..a8b9a0a0dde 100644 --- a/test/suite/test_bug004.py +++ b/test/suite/test_bug004.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug005.py b/test/suite/test_bug005.py index 3e06bea8694..6e888c3b00b 100644 --- a/test/suite/test_bug005.py +++ b/test/suite/test_bug005.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug006.py b/test/suite/test_bug006.py index fbf83b84e7f..e522cdf96f7 100644 --- a/test/suite/test_bug006.py +++ b/test/suite/test_bug006.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -58,9 +58,6 @@ class test_bug006(wttest.WiredTigerTestCase): self.assertRaises( wiredtiger.WiredTigerError, lambda: self.session.salvage(uri, None)) self.assertRaises( - wiredtiger.WiredTigerError, - lambda: self.session.truncate(uri, None, None, None)) - self.assertRaises( wiredtiger.WiredTigerError, lambda: self.session.upgrade(uri, None)) self.assertRaises( wiredtiger.WiredTigerError, lambda: self.session.verify(uri, None)) diff --git a/test/suite/test_bug007.py b/test/suite/test_bug007.py index 8a10175d28b..1add6512df3 100644 --- a/test/suite/test_bug007.py +++ b/test/suite/test_bug007.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug008.py b/test/suite/test_bug008.py index 75cbd989cd1..8f0526d9cef 100644 --- a/test/suite/test_bug008.py +++ b/test/suite/test_bug008.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug009.py b/test/suite/test_bug009.py index 6f66674944a..4d10e4391d9 100644 --- a/test/suite/test_bug009.py +++ b/test/suite/test_bug009.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug010.py b/test/suite/test_bug010.py index 0266cb82446..89f21e1da04 100644 --- a/test/suite/test_bug010.py +++ b/test/suite/test_bug010.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -39,14 +39,9 @@ class test_bug010(wttest.WiredTigerTestCase): uri = 'table:' + name num_tables = 1000 - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - # Disable checkpoint sync, to make checkpoints faster and - # increase the likelyhood of triggering the symptom - conn_params = ',create,checkpoint_sync=false' - conn = wiredtiger.wiredtiger_open(dir, conn_params) - return conn + # Disable checkpoint sync, to make checkpoints faster and + # increase the likelyhood of triggering the symptom + conn_config = 'checkpoint_sync=false' def test_checkpoint_dirty(self): # Create a lot of tables diff --git a/test/suite/test_bug011.py b/test/suite/test_bug011.py index b93fc3a75b7..50dba1c48be 100644 --- a/test/suite/test_bug011.py +++ b/test/suite/test_bug011.py @@ -1,6 +1,6 @@ #!usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -40,15 +40,9 @@ class test_bug011(wttest.WiredTigerTestCase): ntables = 50 nrows = 10000 nops = 10000 - - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - conn_params = 'create,cache_size=10MB,' \ - 'hazard_max=' + str(self.ntables / 2) - conn = wiredtiger.wiredtiger_open(dir, conn_params) - self.pr(`conn`) - return conn + # Add connection configuration for this test. + def conn_config(self, dir): + return 'cache_size=10MB,hazard_max=' + str(self.ntables / 2) def test_eviction(self): cursors = [] diff --git a/test/suite/test_bug012.py b/test/suite/test_bug012.py index 921940df255..a28834f36d2 100644 --- a/test/suite/test_bug012.py +++ b/test/suite/test_bug012.py @@ -1,6 +1,6 @@ #!usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug013.py b/test/suite/test_bug013.py index e22e21b5eeb..a42809aea5f 100644 --- a/test/suite/test_bug013.py +++ b/test/suite/test_bug013.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug014.py b/test/suite/test_bug014.py index 4df5f39d89f..c951cb45293 100644 --- a/test/suite/test_bug014.py +++ b/test/suite/test_bug014.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bug015.py b/test/suite/test_bug015.py index 65b5b8e1755..7892f66759d 100644 --- a/test/suite/test_bug015.py +++ b/test/suite/test_bug015.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_bulk01.py b/test/suite/test_bulk01.py index 4c8747033d2..1add11af26b 100644 --- a/test/suite/test_bulk01.py +++ b/test/suite/test_bulk01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -60,36 +60,126 @@ class test_bulk_load(wttest.WiredTigerTestCase): self.session.create(uri, 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) cursor = self.session.open_cursor(uri, None, "bulk") - for i in range(1, 100): + for i in range(1, 1000): cursor[key_populate(cursor, i)] = value_populate(cursor, i) + + # Test a bulk-load triggers variable-length column-store RLE correctly. + def test_bulk_load_var_rle(self): + if self.keyfmt != 'r' or self.valfmt == '8t': + return + + # We can't directly test RLE, it's internal to WiredTiger. However, + # diagnostic builds catch records that should have been RLE compressed, + # but weren't, so setting matching values should be sufficient. + uri = self.type + self.name + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) + cursor = self.session.open_cursor(uri, None, "bulk") + for i in range(1, 1000): + cursor[key_populate(cursor, i)] = value_populate(cursor, i/7) + + # Test a bulk-load variable-length column-store append ignores any key. + def test_bulk_load_var_append(self): + if self.keyfmt != 'r': + return + + uri = self.type + self.name + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) + cursor = self.session.open_cursor(uri, None, "bulk,append") + for i in range(1, 1000): + cursor[key_populate(cursor, 37)] = value_populate(cursor, i) cursor.close() + cursor = self.session.open_cursor(uri, None, None) + for i in range(1, 1000): + cursor.set_key(key_populate(cursor, i)) + cursor.search() + self.assertEqual(cursor.get_value(), value_populate(cursor, i)) + # Test that column-store bulk-load handles skipped records correctly. + def test_bulk_load_col_delete(self): + if self.keyfmt != 'r': + return -# Test that out-of-order insert in a row-store fails by default, but -# works if key order validation is turned off. -class test_bulk_load_row_order(wttest.WiredTigerTestCase): - name = 'test_bulk' + uri = self.type + self.name + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) + cursor = self.session.open_cursor(uri, None, "bulk") + for i in range(1, 1000): + if i % 7 == 0: + cursor[key_populate(cursor, i)] = value_populate(cursor, i) - scenarios = check_scenarios([ - ('file', dict(type='file:')), - ('table', dict(type='table:')) - ]) + # Ensure we create all the missing records. + i = i + 1 + cursor[key_populate(cursor, i)] = value_populate(cursor, i) + + cursor.close() + cursor = self.session.open_cursor(uri, None, None) + + # Verify all the records are there, in their proper state. + for i in range(1, 1000): + cursor.set_key(key_populate(cursor, i)) + if i % 7 == 0: + cursor.search() + self.assertEqual(cursor.get_value(), value_populate(cursor, i)) + elif cursor.value_format == '8t': + cursor.search() + self.assertEqual(cursor.get_value(), 0) + else: + self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND) + + # Test that variable-length column-store bulk-load efficiently creates big + # records. + def test_bulk_load_col_big(self): + if self.keyfmt != 'r' or self.valfmt == '8t': + return - def test_bulk_load_row_order_check(self): uri = self.type + self.name - self.session.create(uri, 'key_format=S,value_format=S') + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) + cursor = self.session.open_cursor(uri, None, "bulk") + for i in range(1, 10): + cursor[key_populate(cursor, i)] = value_populate(cursor, i) + + # A big record -- if it's not efficient, we'll just hang. + big = 18446744073709551606 + cursor[key_populate(cursor, big)] = value_populate(cursor, big) + + cursor.close() + cursor = self.session.open_cursor(uri, None, None) + cursor.set_key(key_populate(cursor, big)) + cursor.search() + self.assertEqual(cursor.get_value(), value_populate(cursor, big)) + + # Test that bulk-load out-of-order fails. + def test_bulk_load_order_check(self): + uri = self.type + self.name + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) cursor = self.session.open_cursor(uri, None, "bulk") cursor[key_populate(cursor, 10)] = value_populate(cursor, 10) - cursor.set_key(key_populate(cursor, 1)) - cursor.set_value(value_populate(cursor, 1)) - msg = '/compares smaller than previously inserted key/' - self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: cursor.insert(), msg) + for i in [1, 9, 10]: + cursor.set_key(key_populate(cursor, 1)) + cursor.set_value(value_populate(cursor, 1)) + msg = '/than previously inserted key/' + self.assertRaisesWithMessage( + wiredtiger.WiredTigerError, lambda: cursor.insert(), msg) + cursor[key_populate(cursor, 11)] = value_populate(cursor, 11) + + # Test that row-store bulk-load out-of-order can succeed. def test_bulk_load_row_order_nocheck(self): + # Row-store offers an optional fast-past that skips the relatively + # expensive key-order checks, used when the input is known to be + # correct. Column-store comparisons are cheap, so it doesn't have + # that fast-path support. + if self.keyfmt != 'S': + return + uri = self.type + self.name - self.session.create(uri, 'key_format=S,value_format=S') + self.session.create(uri, + 'key_format=' + self.keyfmt + ',value_format=' + self.valfmt) cursor = self.session.open_cursor(uri, None, "bulk,skip_sort_check") cursor[key_populate(cursor, 10)] = value_populate(cursor, 10) cursor[key_populate(cursor, 1)] = value_populate(cursor, 1) @@ -102,16 +192,7 @@ class test_bulk_load_row_order(wttest.WiredTigerTestCase): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.conn.close(), msg) - -# Test that inserting into the file blocks a subsequent bulk-load. -class test_bulk_load_not_empty(wttest.WiredTigerTestCase): - name = 'test_bulk' - - scenarios = check_scenarios([ - ('file', dict(type='file:')), - ('table', dict(type='table:')) - ]) - + # Test bulk-load only permitted on newly created objects. def test_bulk_load_not_empty(self): uri = self.type + self.name self.session.create(uri, 'key_format=S,value_format=S') @@ -123,6 +204,7 @@ class test_bulk_load_not_empty(wttest.WiredTigerTestCase): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.open_cursor(uri, None, "bulk"), msg) + # Test that bulk-load objects cannot be opened by other cursors. def test_bulk_load_busy(self): uri = self.type + self.name self.session.create(uri, 'key_format=S,value_format=S') diff --git a/test/suite/test_bulk02.py b/test/suite/test_bulk02.py index 4af1314c0d8..eeca6a56967 100644 --- a/test/suite/test_bulk02.py +++ b/test/suite/test_bulk02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -104,7 +104,7 @@ class test_bulkload_backup(wttest.WiredTigerTestCase, suite_subprocess): self.backup(backupdir, session) # Open the target directory, and confirm the object has no contents. - conn = wiredtiger.wiredtiger_open(backupdir) + conn = self.wiredtiger_open(backupdir) session = conn.open_session() cursor = session.open_cursor(self.uri, None, None) self.assertEqual(cursor.next(), wiredtiger.WT_NOTFOUND) diff --git a/test/suite/test_checkpoint01.py b/test/suite/test_checkpoint01.py index 799e6ded1ea..7d4503b84b7 100644 --- a/test/suite/test_checkpoint01.py +++ b/test/suite/test_checkpoint01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_checkpoint02.py b/test/suite/test_checkpoint02.py index cf625493f7c..71c8792359c 100644 --- a/test/suite/test_checkpoint02.py +++ b/test/suite/test_checkpoint02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_colgap.py b/test/suite/test_colgap.py index 4192f14c5e6..46682c23167 100644 --- a/test/suite/test_colgap.py +++ b/test/suite/test_colgap.py @@ -1,6 +1,6 @@ #!usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -28,6 +28,7 @@ import wiredtiger, wttest from helper import simple_populate, key_populate, value_populate +from wtscenario import check_scenarios, multiply_scenarios, number_scenarios # test_colgap.py # Test variable-length column-store gap performance. @@ -119,5 +120,90 @@ class test_column_store_gap(wttest.WiredTigerTestCase): self.backward(cursor, list(reversed(v))) +# Basic testing of variable-length column-store with big records. +class test_colmax(wttest.WiredTigerTestCase): + name = 'test_colmax' + + types = [ + ('file', dict(type='file:')), + ('table', dict(type='table:')) + ] + valfmt = [ + ('integer', dict(valfmt='i')), + ('string', dict(valfmt='S')), + ] + record_number = [ + ('big', dict(recno=18446744073709551606)), + ('max', dict(recno=18446744073709551615)), + ] + bulk = [ + ('bulk', dict(bulk=1)), + ('not-bulk', dict(bulk=0)), + ] + reopen = [ + ('reopen', dict(reopen=1)), + ('not-reopen', dict(reopen=0)), + ] + single = [ + ('single', dict(single=1)), + ('not-single', dict(single=0)), + ] + + scenarios = number_scenarios(multiply_scenarios(\ + '.', types, valfmt, record_number, bulk, reopen, single)) + + # Test that variable-length column-store correctly/efficiently handles big + # records (if it's not efficient, we'll just hang). + def test_colmax_op(self): + recno = self.recno + + uri = self.type + self.name + self.session.create(uri, 'key_format=r' +',value_format=' + self.valfmt) + + # Insert a big record with/without a bulk cursor. + bulk_config = "" + if self.bulk: + bulk_config = "bulk" + cursor = self.session.open_cursor(uri, None, bulk_config) + + # Optionaly make the big record the only record in the table. + if not self.single: + for i in range(1, 723): + cursor[key_populate(cursor, i)] = value_populate(cursor, i) + + # Confirm searching past the end of the table works. + if not self.bulk: + cursor.set_key(recno) + self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND) + + # Insert the big record. + cursor[key_populate(cursor, recno)] = value_populate(cursor, recno) + + # Optionally flush to disk; re-open the cursor as necessary. + if self.bulk or self.reopen: + cursor.close() + if self.reopen == 1: + self.reopen_conn() + if self.bulk or self.reopen: + cursor = self.session.open_cursor(uri, None, None) + + # Search for the large record. + cursor.set_key(recno) + self.assertEqual(cursor.search(), 0) + self.assertEqual(cursor.get_value(), value_populate(cursor, recno)) + + # Update it. + cursor[key_populate(cursor, recno)] = value_populate(cursor, 37) + cursor.set_key(recno) + self.assertEqual(cursor.search(), 0) + self.assertEqual(cursor.get_value(), value_populate(cursor, 37)) + + # Remove it. + cursor.set_key(recno) + self.assertEqual(cursor.remove(), 0) + cursor.set_key(key_populate(cursor, recno)) + self.assertEqual(cursor.search(), wiredtiger.WT_NOTFOUND) + + if __name__ == '__main__': wttest.run() diff --git a/test/suite/test_compact.py b/test/suite/test_compact01.py index c7269785115..3af550708ed 100644 --- a/test/suite/test_compact.py +++ b/test/suite/test_compact01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -54,14 +54,9 @@ class test_compact(wttest.WiredTigerTestCase, suite_subprocess): ('utility', dict(utility=1,reopen=0)), ] scenarios = number_scenarios(multiply_scenarios('.', types, compact)) - - # Override WiredTigerTestCase, we want a large cache so that eviction - # doesn't happen (which could skew our compaction results). - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,cache_size=250MB,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + # We want a large cache so that eviction doesn't happen + # (which could skew our compaction results). + conn_config = 'cache_size=250MB,statistics=(all)' # Test compaction. def test_compact(self): diff --git a/test/suite/test_compact02.py b/test/suite/test_compact02.py new file mode 100644 index 00000000000..14781b0f050 --- /dev/null +++ b/test/suite/test_compact02.py @@ -0,0 +1,152 @@ +#!/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. +# +# test_compact02.py +# Test that compact reduces the file size. +# + +import wiredtiger, wttest +from wiredtiger import stat +from wtscenario import multiply_scenarios, number_scenarios + +# Test basic compression +class test_compact02(wttest.WiredTigerTestCase): + + types = [ + ('file', dict(uri='file:test_compact02')), + ] + cacheSize = [ + ('default', dict(cacheSize='')), + ('1mb', dict(cacheSize='cache_size=1MB')), + ('10gb', dict(cacheSize='cache_size=10GB')), + ] + + # There's a balance between the pages we create and the size of the records + # being stored: compaction doesn't work on tables with many overflow items + # because we don't rewrite them. Experimentally, 8KB is as small as the test + # can go. Additionally, we can't set the maximum page size too large because + # there won't be enough pages to rewrite. Experimentally, 32KB (the default) + # is as large as the test can go. + fileConfig = [ + ('default', dict(fileConfig='')), + ('8KB', dict(fileConfig='leaf_page_max=8kb')), + ] + scenarios = \ + number_scenarios(multiply_scenarios('.', types, cacheSize, fileConfig)) + + # We want about 22K records that total about 130Mb. That is an average + # of 6196 bytes per record. Half the records should be smaller, about + # 2700 bytes (about 30Mb) and the other half should be larger, 9666 bytes + # per record (about 100Mb). + # + # Test flow is as follows. + # + # 1. Create a table with the data, alternating record size. + # 2. Checkpoint and get stats on the table to confirm the size. + # 3. Delete the half of the records with the larger record size. + # 4. Call compact. + # 5. Get stats on compacted table. + # + nrecords = 22000 + bigvalue = "abcdefghi" * 1074 # 9*1074 == 9666 + smallvalue = "ihgfedcba" * 303 # 9*303 == 2727 + + fullsize = nrecords / 2 * len(bigvalue) + nrecords / 2 * len(smallvalue) + + # Return the size of the file + def getSize(self): + cstat = self.session.open_cursor( + 'statistics:' + self.uri, None, 'statistics=(size)') + sz = cstat[stat.dsrc.block_size][2] + cstat.close() + return sz + + # This test varies the cache size and so needs to set up its own connection. + # Override the standard methods. + def setUpConnectionOpen(self, dir): + return None + def setUpSessionOpen(self, conn): + return None + def ConnectionOpen(self, cacheSize): + self.home = '.' + conn_params = 'create,' + \ + cacheSize + ',error_prefix="%s: ",' % self.shortid() + \ + 'statistics=(fast)' + try: + self.conn = wiredtiger.wiredtiger_open(self.home, conn_params) + except wiredtiger.WiredTigerError as e: + print "Failed conn at '%s' with config '%s'" % (dir, conn_params) + self.session = self.conn.open_session(None) + + # Create a table, add keys with both big and small values. + def test_compact02(self): + self.ConnectionOpen(self.cacheSize) + + mb = 1024 * 1024 + params = 'key_format=i,value_format=S,' + self.fileConfig + + # 1. Create a table with the data, alternating record size. + self.session.create(self.uri, params) + c = self.session.open_cursor(self.uri, None) + for i in range(self.nrecords): + if i % 2 == 0: + c[i] = str(i) + self.bigvalue + else: + c[i] = str(i) + self.smallvalue + c.close() + + # 2. Checkpoint and get stats on the table to confirm the size. + self.session.checkpoint() + sz = self.getSize() + self.pr('After populate ' + str(sz / mb) + 'MB') + self.assertGreater(sz, self.fullsize) + + # 3. Delete the half of the records with the larger record size. + c = self.session.open_cursor(self.uri, None) + count = 0 + for i in range(self.nrecords): + if i % 2 == 0: + count += 1 + c.set_key(i) + c.remove() + c.close() + self.pr('Removed total ' + str((count * 9666) / mb) + 'MB') + + # 4. Call compact. + self.session.compact(self.uri, None) + + # 5. Get stats on compacted table. + sz = self.getSize() + self.pr('After compact ' + str(sz / mb) + 'MB') + + # After compact, the file size should be less than half the full size. + self.assertLess(sz, self.fullsize / 2) + + +if __name__ == '__main__': + wttest.run() diff --git a/test/suite/test_compress01.py b/test/suite/test_compress01.py index 17d87403a0f..e97953a53cd 100644 --- a/test/suite/test_compress01.py +++ b/test/suite/test_compress01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -52,13 +52,9 @@ class test_compress01(wttest.WiredTigerTestCase): nrecords = 10000 bigvalue = "abcdefghij" * 1000 - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open( dir, 'create,' + - ('error_prefix="%s: ",' % self.shortid()) + - self.extensionArg(self.compress)) - self.pr(`conn`) - return conn + # Load the compression extension, compression is enabled elsewhere. + def conn_config(self, dir): + return self.extensionArg(self.compress) # Return the wiredtiger_open extension argument for a shared library. def extensionArg(self, name): diff --git a/test/suite/test_config01.py b/test/suite/test_config01.py index f40f9df3b20..cbcb6835525 100644 --- a/test/suite/test_config01.py +++ b/test/suite/test_config01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -41,7 +41,7 @@ class test_config01(test_base03.test_base03): wtopen_args = 'create' if hasattr(self, 'cache_size'): wtopen_args += ',cache_size=' + str(self.cache_size) - conn = wiredtiger.wiredtiger_open(dir, wtopen_args) + conn = self.wiredtiger_open(dir, wtopen_args) self.pr(`conn`) return conn diff --git a/test/suite/test_config02.py b/test/suite/test_config02.py index 53c9989eb5d..112a93ef2e0 100644 --- a/test/suite/test_config02.py +++ b/test/suite/test_config02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -82,7 +82,7 @@ class test_config02(wttest.WiredTigerTestCase): else: os.putenv('WIREDTIGER_HOME', homeenv) try: - self.conn = wiredtiger.wiredtiger_open(homearg, configarg) + self.conn = self.wiredtiger_open(homearg, configarg) self.session = self.conn.open_session(None) self.populate_and_check() finally: @@ -144,7 +144,7 @@ class test_config02(wttest.WiredTigerTestCase): def test_home_does_not_exist(self): dir = 'nondir' self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open(dir, 'create'), + lambda: self.wiredtiger_open(dir, 'create'), '/(No such file or directory|The system cannot find the path specified)/') def test_home_not_writeable(self): @@ -154,7 +154,7 @@ class test_config02(wttest.WiredTigerTestCase): os.mkdir(dir) os.chmod(dir, 0555) self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open(dir, 'create'), + lambda: self.wiredtiger_open(dir, 'create'), '/Permission denied/') if __name__ == '__main__': diff --git a/test/suite/test_config03.py b/test/suite/test_config03.py index 3a1bbd76773..e91c5de62f8 100644 --- a/test/suite/test_config03.py +++ b/test/suite/test_config03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -127,7 +127,7 @@ class test_config03(test_base03.test_base03): args = successargs self.verbose(3, 'wiredtiger_open with args: ' + args) - conn = wiredtiger.wiredtiger_open(dir, args) + conn = self.wiredtiger_open(dir, args) self.pr(`conn`) return conn diff --git a/test/suite/test_config04.py b/test/suite/test_config04.py index 31deced73d0..7186bc3a716 100644 --- a/test/suite/test_config04.py +++ b/test/suite/test_config04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -76,7 +76,7 @@ class test_config04(wttest.WiredTigerTestCase): configarg = 'create,statistics=(fast)' if configextra != None: configarg += ',' + configextra - self.conn = wiredtiger.wiredtiger_open('.', configarg) + self.conn = self.wiredtiger_open('.', configarg) self.session = self.conn.open_session(None) self.populate_and_check() @@ -89,7 +89,7 @@ class test_config04(wttest.WiredTigerTestCase): def test_bad_config(self): msg = '/unknown configuration key/' self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', 'not_valid,another_bad=10'), + lambda: self.wiredtiger_open('.', 'not_valid,another_bad=10'), msg) def test_cache_size_number(self): @@ -123,14 +123,14 @@ class test_config04(wttest.WiredTigerTestCase): def test_cache_too_small(self): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', 'create,cache_size=900000'), + lambda: self.wiredtiger_open('.', 'create,cache_size=900000'), "/Value too small for key 'cache_size' the minimum is/") def test_cache_too_large(self): T11 = 11 * self.T # 11 Terabytes configstr = 'create,cache_size=' + str(T11) self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', configstr), + lambda: self.wiredtiger_open('.', configstr), "/Value too large for key 'cache_size' the maximum is/") def test_eviction(self): @@ -139,20 +139,35 @@ class test_config04(wttest.WiredTigerTestCase): def test_eviction_bad(self): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: - wiredtiger.wiredtiger_open('.', 'create,eviction_target=91,' + - 'eviction_trigger=81'), + self.wiredtiger_open('.', 'create,eviction_target=91,' + + 'eviction_trigger=81'), "/eviction target must be lower than the eviction trigger/") def test_eviction_bad2(self): self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: - wiredtiger.wiredtiger_open('.', 'create,eviction_target=86,' + - 'eviction_trigger=86'), + self.wiredtiger_open('.', 'create,eviction_target=86,' + + 'eviction_trigger=86'), "/eviction target must be lower than the eviction trigger/") def test_hazard_max(self): # Note: There isn't any direct way to know that this was set. self.common_test('hazard_max=50') + def test_invalid_config(self): + msg = '/Unbalanced brackets/' + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.wiredtiger_open('.', '}'), msg) + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.wiredtiger_open('.', '{'), msg) + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.wiredtiger_open('.', '{}}'), msg) + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.wiredtiger_open('.', '(]}'), msg) + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.wiredtiger_open('.', '(create=]}'), msg) + 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 diff --git a/test/suite/test_config05.py b/test/suite/test_config05.py index 8687552eefe..bee63d48da6 100644 --- a/test/suite/test_config05.py +++ b/test/suite/test_config05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -75,35 +75,35 @@ class test_config05(wttest.WiredTigerTestCase): cursor.close() def test_one(self): - self.conn = wiredtiger.wiredtiger_open('.', 'create') + self.conn = self.wiredtiger_open('.', 'create') self.session = self.conn.open_session(None) self.populate(self.session) self.verify_entries(self.session) def test_one_session(self): - self.conn = wiredtiger.wiredtiger_open('.', 'create,session_max=1') + self.conn = self.wiredtiger_open('.', 'create,session_max=1') self.session = self.conn.open_session(None) self.populate(self.session) self.verify_entries(self.session) def test_too_many_sessions(self): - self.conn = wiredtiger.wiredtiger_open('.', 'create,session_max=1') + self.conn = self.wiredtiger_open('.', 'create,session_max=1') self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: [self.conn.open_session(None) for i in range(100)], '/configured to support/') def test_exclusive_create(self): - self.conn = wiredtiger.wiredtiger_open('.', 'create,exclusive') + self.conn = self.wiredtiger_open('.', 'create,exclusive') self.conn.close() self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', 'exclusive'), + lambda: self.wiredtiger_open('.', 'exclusive'), '/WiredTiger database already exists/') def test_multi_create(self): - self.conn = wiredtiger.wiredtiger_open('.', 'create') + self.conn = self.wiredtiger_open('.', 'create') self.session = self.conn.open_session(None) self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', 'create'), + lambda: self.wiredtiger_open('.', 'create'), '/WiredTiger database is already being managed/') if __name__ == '__main__': diff --git a/test/suite/test_config06.py b/test/suite/test_config06.py new file mode 100644 index 00000000000..d426bfe2de9 --- /dev/null +++ b/test/suite/test_config06.py @@ -0,0 +1,93 @@ +#!/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 + +# test_config06.py +# Test session.create configurations. +class test_config06(wttest.WiredTigerTestCase): + uri = 'table:test_config06' + key = 'keyABCDEFGHIJKLMNOPQRSTUVWXYZ' + value = 'valueABCDEFGHIJKLMNOPQRSTUVWXYZ' + + def session_config(self, config): + msg = '/Invalid argument/' + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.session.create(self.uri, config), msg) + + # Edge cases for key/value formats. + def test_session_config(self): + self.session_config('key_format=A,value_format=S') + self.session_config('key_format=S,value_format=A') + self.session_config('key_format=0s,value_format=s') + self.session_config('key_format=s,value_format=0s') + self.session_config('key_format=0t,value_format=4t') + self.session_config('key_format=4t,value_format=0t') + + # Smoke-test the string formats with length specifiers; both formats should + # ignore trailing bytes, verify that. + def format_string(self, fmt, len): + k = self.key + v = self.value + self.session.create(self.uri, \ + "key_format=" + str(len) + fmt + ",value_format=" + str(len) + fmt) + cursor = self.session.open_cursor(self.uri, None) + cursor[k] = v + self.assertEquals(cursor[k[:len]], v[:len]) + def test_format_string_S_1(self): + self.format_string('S', 1) + def test_format_string_S_4(self): + self.format_string('S', 4) + def test_format_string_S_10(self): + self.format_string('S', 10) + def test_format_string_s_1(self): + self.format_string('s', 1) + def test_format_string_s_4(self): + self.format_string('s', 4) + def test_format_string_s_10(self): + self.format_string('s', 10) + + def test_format_string_S_default(self): + k = self.key + v = self.value + self.session.create(self.uri, "key_format=S,value_format=S") + cursor = self.session.open_cursor(self.uri, None) + cursor[k] = v + self.assertEquals(cursor[k], v) + + def test_format_string_s_default(self): + k = self.key + v = self.value + self.session.create(self.uri, "key_format=s,value_format=s") + cursor = self.session.open_cursor(self.uri, None) + cursor[k] = v + self.assertEquals(cursor[k[:1]], v[:1]) + + +if __name__ == '__main__': + wttest.run() diff --git a/test/suite/test_cursor01.py b/test/suite/test_cursor01.py index 47cc7f6c5b7..cf39d4a4ba4 100644 --- a/test/suite/test_cursor01.py +++ b/test/suite/test_cursor01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor02.py b/test/suite/test_cursor02.py index e2b3ec69f86..eb1ba4dfc41 100644 --- a/test/suite/test_cursor02.py +++ b/test/suite/test_cursor02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor03.py b/test/suite/test_cursor03.py index d27c578bafd..63237f942ca 100644 --- a/test/suite/test_cursor03.py +++ b/test/suite/test_cursor03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor04.py b/test/suite/test_cursor04.py index 08f1a7240a5..6576c623f8a 100644 --- a/test/suite/test_cursor04.py +++ b/test/suite/test_cursor04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor05.py b/test/suite/test_cursor05.py index c98bcf63fa8..4c276f06ff4 100644 --- a/test/suite/test_cursor05.py +++ b/test/suite/test_cursor05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor06.py b/test/suite/test_cursor06.py index fdda4bfe8a5..ff7c1144344 100644 --- a/test/suite/test_cursor06.py +++ b/test/suite/test_cursor06.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor07.py b/test/suite/test_cursor07.py index 1fadf58c81f..d8de0874d7f 100644 --- a/test/suite/test_cursor07.py +++ b/test/suite/test_cursor07.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import check_scenarios import wttest @@ -48,23 +48,10 @@ class test_cursor07(wttest.WiredTigerTestCase, suite_subprocess): ('regular', dict(reopen=False)), ('reopen', dict(reopen=True)) ]) - - # Overrides WiredTigerTestCase - add logging - def setUpConnectionOpen(self, dir): - self.home = dir - self.txn_sync = '(method=dsync,enabled)' - conn_params = \ - 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \ - ',create,error_prefix="%s: ",' % self.shortid() + \ - 'transaction_sync="%s",' % self.txn_sync - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except wiredtiger.WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - self.session2 = conn.open_session() - return conn + # Enable logging for this test. + def conn_config(self, dir): + return 'log=(archive=false,enabled,file_max=%s),' % self.logmax + \ + 'transaction_sync="(method=dsync,enabled)"' def test_log_cursor(self): # print "Creating %s with config '%s'" % (self.uri, self.create_params) diff --git a/test/suite/test_cursor08.py b/test/suite/test_cursor08.py index 663451eb5b5..f7bd37a2a3c 100644 --- a/test/suite/test_cursor08.py +++ b/test/suite/test_cursor08.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat, WiredTigerError +from wiredtiger import stat, WiredTigerError from wtscenario import multiply_scenarios, number_scenarios, check_scenarios import wttest @@ -54,6 +54,12 @@ class test_cursor08(wttest.WiredTigerTestCase, suite_subprocess): ('none', dict(compress='none')), ]) scenarios = number_scenarios(multiply_scenarios('.', reopens, compress)) + # Load the compression extension, and enable it for logging. + def conn_config(self, dir): + return 'log=(archive=false,enabled,file_max=%s,' % self.logmax + \ + 'compressor=%s),' % self.compress + \ + 'transaction_sync="(method=dsync,enabled)",' + \ + self.extensionArg(self.compress) # Return the wiredtiger_open extension argument for a shared library. def extensionArg(self, name): @@ -68,25 +74,6 @@ class test_cursor08(wttest.WiredTigerTestCase, suite_subprocess): self.skipTest('compression extension "' + extfile + '" not built') return ',extensions=["' + extfile + '"]' - # Overrides WiredTigerTestCase - add logging - def setUpConnectionOpen(self, dir): - self.home = dir - self.txn_sync = '(method=dsync,enabled)' - conn_params = \ - 'log=(archive=false,enabled,file_max=%s,' % self.logmax + \ - 'compressor=%s)' % self.compress + \ - ',create,error_prefix="%s: ",' % self.shortid() + \ - 'transaction_sync="%s",' % self.txn_sync + \ - self.extensionArg(self.compress) - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - self.session2 = conn.open_session() - return conn - def test_log_cursor(self): # print "Creating %s with config '%s'" % (self.uri, self.create_params) create_params = 'key_format=i,value_format=S' diff --git a/test/suite/test_cursor09.py b/test/suite/test_cursor09.py index 185c5fe88bb..b77336bc1d7 100644 --- a/test/suite/test_cursor09.py +++ b/test/suite/test_cursor09.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor_compare.py b/test/suite/test_cursor_compare.py index 07bc533839d..130f4e8ca96 100644 --- a/test/suite/test_cursor_compare.py +++ b/test/suite/test_cursor_compare.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor_pin.py b/test/suite/test_cursor_pin.py index b739a69892a..329759d8fc8 100644 --- a/test/suite/test_cursor_pin.py +++ b/test/suite/test_cursor_pin.py @@ -1,6 +1,6 @@ #!usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor_random.py b/test/suite/test_cursor_random.py index b424dbbc7e3..2cef62b218a 100644 --- a/test/suite/test_cursor_random.py +++ b/test/suite/test_cursor_random.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_cursor_random02.py b/test/suite/test_cursor_random02.py new file mode 100644 index 00000000000..84ac0279fc4 --- /dev/null +++ b/test/suite/test_cursor_random02.py @@ -0,0 +1,84 @@ +#!/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 helper import complex_populate, simple_populate +from helper import key_populate, value_populate +from wtscenario import check_scenarios, multiply_scenarios, number_scenarios + +# test_cursor_random02.py +# Cursor next_random operations +class test_cursor_random02(wttest.WiredTigerTestCase): + type = 'table:random' + config = [ + ('not-sample', dict(config='next_random=true')) + ] + records = [ + ('1', dict(records=1)), + ('250', dict(records=250)), + ('500', dict(records=500)), + ('5000', dict(records=5000)), + ('10000', dict(records=10000)), + ('50000', dict(records=50000)), + ] + scenarios = number_scenarios(multiply_scenarios('.', config, records)) + + # Check that next_random works in the presence of a larger set of values, + # where the values are in an insert list. + def test_cursor_random_reasonable_distribution(self): + uri = self.type + num_entries = self.records + + # Set the leaf-page-max value, otherwise the page might split. + simple_populate(self, uri, + 'leaf_page_max=100MB,key_format=S', num_entries) + # Setup an array to track which keys are seen + visitedKeys = [0] * (num_entries + 1) + + cursor = self.session.open_cursor(uri, None, 'next_random=true') + for i in range(0, num_entries): + self.assertEqual(cursor.next(), 0) + current = cursor.get_key() + current = int(current) + visitedKeys[current] = visitedKeys[current] + 1 + + differentKeys = sum(x > 0 for x in visitedKeys) + + #print visitedKeys + #print differentKeys + ''' + self.tty('differentKeys: ' + str(differentKeys) + ' of ' + \ + str(num_entries) + ', ' + \ + str((int)((differentKeys * 100) / num_entries)) + '%') + ''' + + self.assertGreater(differentKeys, num_entries / 4, + 'next_random random distribution not adequate') + +if __name__ == '__main__': + wttest.run() diff --git a/test/suite/test_cursor_tracker.py b/test/suite/test_cursor_tracker.py index 742dea4c32b..a703e6cea70 100644 --- a/test/suite/test_cursor_tracker.py +++ b/test/suite/test_cursor_tracker.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_drop.py b/test/suite/test_drop.py index 8ca63f0b191..5663b85d661 100644 --- a/test/suite/test_drop.py +++ b/test/suite/test_drop.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_drop_create.py b/test/suite/test_drop_create.py index 9cd6a32c9bf..654f054a583 100644 --- a/test/suite/test_drop_create.py +++ b/test/suite/test_drop_create.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_dump.py b/test/suite/test_dump.py index 6d81c102028..c850d1b5d3f 100644 --- a/test/suite/test_dump.py +++ b/test/suite/test_dump.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -109,7 +109,7 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess): self.runWt(['-h', self.dir, 'load', '-f', 'dump.out']) # Check the contents - conn = wiredtiger.wiredtiger_open(self.dir) + conn = self.wiredtiger_open(self.dir) session = conn.open_session() cursor = session.open_cursor(uri, None, None) self.populate_check(self, cursor, self.nentries) @@ -119,7 +119,7 @@ class test_dump(wttest.WiredTigerTestCase, suite_subprocess): self.runWt(['-h', self.dir, 'load', '-f', 'dump.out']) # Check the contents, they shouldn't have changed. - conn = wiredtiger.wiredtiger_open(self.dir) + conn = self.wiredtiger_open(self.dir) session = conn.open_session() cursor = session.open_cursor(uri, None, None) self.populate_check(self, cursor, self.nentries) diff --git a/test/suite/test_dupc.py b/test/suite/test_dupc.py index c28dd928ab6..ec55a36df4c 100644 --- a/test/suite/test_dupc.py +++ b/test/suite/test_dupc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_durability01.py b/test/suite/test_durability01.py index 8d00d05fa14..f578a79baf1 100644 --- a/test/suite/test_durability01.py +++ b/test/suite/test_durability01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -34,7 +34,6 @@ import fnmatch, os, shutil, time from helper import copy_wiredtiger_home from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest diff --git a/test/suite/test_empty.py b/test/suite/test_empty.py index 93ec65e1f94..50b79db70e4 100644 --- a/test/suite/test_empty.py +++ b/test/suite/test_empty.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_encrypt01.py b/test/suite/test_encrypt01.py index 9feaa7f88a3..0521f7c8e8a 100644 --- a/test/suite/test_encrypt01.py +++ b/test/suite/test_encrypt01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -79,7 +79,7 @@ class test_encrypt01(wttest.WiredTigerTestCase): ('encryptors', self.file_encrypt), ('compressors', self.block_compress), ('compressors', self.log_compress)]) - conn = wiredtiger.wiredtiger_open(dir, + conn = self.wiredtiger_open(dir, 'create,error_prefix="{0}: ",{1}{2}{3}'.format( self.shortid(), encarg, comparg, extarg)) self.pr(`conn`) diff --git a/test/suite/test_encrypt02.py b/test/suite/test_encrypt02.py index db6cdedf983..0376b3e42e4 100644 --- a/test/suite/test_encrypt02.py +++ b/test/suite/test_encrypt02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -81,7 +81,7 @@ class test_encrypt02(wttest.WiredTigerTestCase, suite_subprocess): extarg = self.extensionArg([('encryptors', self.encrypt)]) connarg = 'create,error_prefix="{0}: ",{1},{2}'.format( self.shortid(), encarg, extarg) - conn = wiredtiger.wiredtiger_open(dir, connarg) + conn = self.wiredtiger_open(dir, connarg) self.pr(`conn`) return conn diff --git a/test/suite/test_encrypt03.py b/test/suite/test_encrypt03.py index 0e19ad39263..702d0a2369f 100644 --- a/test/suite/test_encrypt03.py +++ b/test/suite/test_encrypt03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -57,7 +57,7 @@ class test_encrypt03(wttest.WiredTigerTestCase): extarg = self.extensionArg([('encryptors', self.sys_encrypt), ('encryptors', self.file_encrypt)]) self.pr('encarg = ' + encarg + ' extarg = ' + extarg) - conn = wiredtiger.wiredtiger_open(dir, + conn = self.wiredtiger_open(dir, 'create,error_prefix="{0}: ",{1}{2}'.format( self.shortid(), encarg, extarg)) self.pr(`conn`) diff --git a/test/suite/test_encrypt04.py b/test/suite/test_encrypt04.py index 41fd0f6dd48..d7c12d2cba8 100644 --- a/test/suite/test_encrypt04.py +++ b/test/suite/test_encrypt04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -107,7 +107,7 @@ class test_encrypt04(wttest.WiredTigerTestCase, suite_subprocess): self.pr('encarg = ' + encarg + ' extarg = ' + extarg) completed = False try: - conn = wiredtiger.wiredtiger_open(dir, + conn = self.wiredtiger_open(dir, 'create,error_prefix="{0}: ",{1}{2}'.format( self.shortid(), encarg, extarg)) except (BaseException) as err: diff --git a/test/suite/test_encrypt05.py b/test/suite/test_encrypt05.py index 8a69e5f909f..afd8a8103f9 100644 --- a/test/suite/test_encrypt05.py +++ b/test/suite/test_encrypt05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -61,7 +61,7 @@ class test_encrypt05(wttest.WiredTigerTestCase): ('encryptors', self.file_encrypt), ('compressors', self.block_compress), ('compressors', self.log_compress)]) - conn = wiredtiger.wiredtiger_open(dir, + conn = self.wiredtiger_open(dir, 'create,error_prefix="{0}: ",{1}{2}{3}'.format( self.shortid(), encarg, comparg, extarg)) self.pr(`conn`) diff --git a/test/suite/test_encrypt06.py b/test/suite/test_encrypt06.py index 5b2007fe6e7..5c88b698aeb 100644 --- a/test/suite/test_encrypt06.py +++ b/test/suite/test_encrypt06.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -99,7 +99,7 @@ class test_encrypt06(wttest.WiredTigerTestCase): ('encryptors', self.file1_encrypt)]) self.open_params = 'create,error_prefix="{0}: ",{1}{2}{3}'.format( self.shortid(), encarg, comparg, extarg) - conn = wiredtiger.wiredtiger_open(dir, self.open_params) + conn = self.wiredtiger_open(dir, self.open_params) self.pr(`conn`) return conn diff --git a/test/suite/test_encrypt07.py b/test/suite/test_encrypt07.py index cf55e4f16b4..30f28e096a8 100644 --- a/test/suite/test_encrypt07.py +++ b/test/suite/test_encrypt07.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -50,7 +50,7 @@ class test_encrypt07(test_salvage.test_salvage): encarg = 'encryption=(name={0}{1}),'.format( self.sys_encrypt, self.sys_encrypt_args) extarg = self.extensionArg([('encryptors', self.sys_encrypt)]) - conn = wiredtiger.wiredtiger_open(dir, + conn = self.wiredtiger_open(dir, 'create,error_prefix="{0}: ",{1}{2}'.format( self.shortid(), encarg, extarg)) self.pr(`conn`) diff --git a/test/suite/test_env01.py b/test/suite/test_env01.py index 0d650426383..491ef9e8eac 100644 --- a/test/suite/test_env01.py +++ b/test/suite/test_env01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -99,7 +99,7 @@ class test_priv01(wttest.WiredTigerTestCase): else: os.putenv('WIREDTIGER_HOME', homeenv) try: - self.conn = wiredtiger.wiredtiger_open(homearg, configarg) + self.conn = self.wiredtiger_open(homearg, configarg) self.session = self.conn.open_session(None) self.populate_and_check() finally: diff --git a/test/suite/test_excl.py b/test/suite/test_excl.py index 960e653e723..90926f51877 100644 --- a/test/suite/test_excl.py +++ b/test/suite/test_excl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_home.py b/test/suite/test_home.py index ed85a3224c2..2cdcf2429af 100644 --- a/test/suite/test_home.py +++ b/test/suite/test_home.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -70,8 +70,9 @@ class test_base_config(wttest.WiredTigerTestCase): # Open up another database, configure without base configuration. os.mkdir("A") - conn = wiredtiger.wiredtiger_open("A", "create,config_base=false") + conn = self.wiredtiger_open("A", "create,config_base=false") self.assertFalse(os.path.exists("A/WiredTiger.basecfg")) + conn.close() if __name__ == '__main__': diff --git a/test/suite/test_huffman01.py b/test/suite/test_huffman01.py index 786841b29f7..d71198e3151 100644 --- a/test/suite/test_huffman01.py +++ b/test/suite/test_huffman01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_huffman02.py b/test/suite/test_huffman02.py index 2f75758e8ff..aa4329415a4 100644 --- a/test/suite/test_huffman02.py +++ b/test/suite/test_huffman02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_index01.py b/test/suite/test_index01.py index f2398fee5e8..bebeb191ef0 100644 --- a/test/suite/test_index01.py +++ b/test/suite/test_index01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -39,11 +39,6 @@ class test_index01(wttest.WiredTigerTestCase): NUM_INDICES = 6 index = ['%s:index%d' % (indexbase, i) for i in xrange(NUM_INDICES)] - def reopen(self): - self.conn.close() - self.conn = wiredtiger.wiredtiger_open('.', None) - self.session = self.conn.open_session() - def create_table(self): self.pr('create table') self.session.create(self.tablename, 'key_format=Si,value_format=SSii,columns=(name,ID,dept,job,salary,year)') @@ -222,5 +217,20 @@ class test_index01(wttest.WiredTigerTestCase): self.assertEqual(list(self.index_iter(i)), []) self.drop_table() + def test_exclusive(self): + '''Create indices, then try to create another index exclusively''' + self.create_table() + # non-exclusive recreate is allowed + self.session.create(self.index[0], 'columns=(dept)') + # exclusive recreate + self.assertRaises(wiredtiger.WiredTigerError, + lambda: self.session.create(self.index[0], + 'columns=(dept),exclusive')) + # non-exclusive create with differing configuration + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.session.create(self.index[0], + 'columns=(salary)'), '/does not match existing configuration/') + self.drop_table() + if __name__ == '__main__': wttest.run() diff --git a/test/suite/test_inmem01.py b/test/suite/test_inmem01.py index fa7ca787056..875ebb2bfa7 100644 --- a/test/suite/test_inmem01.py +++ b/test/suite/test_inmem01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -54,12 +54,9 @@ class test_inmem01(wttest.WiredTigerTestCase): ('row', dict(tablekind='row')) ]) - # Override WiredTigerTestCase to create an in-memory database - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'cache_size=5MB,create,' + - 'file_manager=(close_idle_time=0),in_memory=true,cache_size=5MB') - return conn + # create an in-memory database + conn_config = 'cache_size=5MB,' + \ + 'file_manager=(close_idle_time=0),in_memory=true' def get_table_config(self): kf = 'key_format=' diff --git a/test/suite/test_intpack.py b/test/suite/test_intpack.py index efe4bfc0421..187b2d7f579 100644 --- a/test/suite/test_intpack.py +++ b/test/suite/test_intpack.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_join01.py b/test/suite/test_join01.py index ca6e5fbcabb..f03c7c6f06c 100644 --- a/test/suite/test_join01.py +++ b/test/suite/test_join01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -40,12 +40,8 @@ class test_join01(wttest.WiredTigerTestCase): ('table', dict(ref='table')), ('index', dict(ref='index')) ] - - # Override WiredTigerTestCase, we have statistics tests. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + 'error_prefix="%s: "' % self.shortid()) - return conn + # We need statistics for these tests. + conn_config = 'statistics=(all)' def gen_key(self, i): return [ i + 1 ] @@ -245,10 +241,22 @@ class test_join01(wttest.WiredTigerTestCase): # Joining a non positioned cursor self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.join(jc, ic0, 'compare=ge'), - '/requires key be set/') + '/requires reference cursor be positioned/') + ic0.set_key('val1') + # Joining a non positioned cursor (no search or next has been done) + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.session.join(jc, ic0, 'compare=ge'), + '/requires reference cursor be positioned/') + ic0.set_key('valXX') + self.assertEqual(ic0.search(), wiredtiger.WT_NOTFOUND) + # Joining a non positioned cursor after failed search + self.assertRaisesWithMessage(wiredtiger.WiredTigerError, + lambda: self.session.join(jc, ic0, 'compare=ge'), + '/requires reference cursor be positioned/') - # minimally position the cursors now - ic0.next() + # position the cursors now + ic0.set_key('val1') + ic0.search() ic0again.next() icB.next() @@ -260,7 +268,7 @@ class test_join01(wttest.WiredTigerTestCase): # The cursor must be positioned self.assertRaisesWithMessage(wiredtiger.WiredTigerError, lambda: self.session.join(jc, ic1, 'compare=ge'), - '/requires key be set/') + '/requires reference cursor be positioned/') ic1.next() # The first cursor joined cannot be bloom diff --git a/test/suite/test_join02.py b/test/suite/test_join02.py index bf376575103..d122de8a0eb 100644 --- a/test/suite/test_join02.py +++ b/test/suite/test_join02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_join03.py b/test/suite/test_join03.py index 552e3b41748..613d2396b07 100644 --- a/test/suite/test_join03.py +++ b/test/suite/test_join03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -61,7 +61,7 @@ class test_join03(wttest.WiredTigerTestCase): extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')]) connarg = 'create,error_prefix="{0}: ",{1}'.format( self.shortid(), extarg) - conn = wiredtiger.wiredtiger_open(dir, connarg) + conn = self.wiredtiger_open(dir, connarg) self.pr(`conn`) return conn diff --git a/test/suite/test_join04.py b/test/suite/test_join04.py new file mode 100644 index 00000000000..7e2afb15285 --- /dev/null +++ b/test/suite/test_join04.py @@ -0,0 +1,169 @@ +#!/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 os +import wiredtiger, wttest, run +from wtscenario import check_scenarios, multiply_scenarios, number_scenarios + +# test_join04.py +# Join operations +# Joins with a custom extractor, using equality joins +class test_join04(wttest.WiredTigerTestCase): + table_name1 = 'test_join04' + nentries = 100 + + # Return the wiredtiger_open extension argument for a shared library. + def extensionArg(self, exts): + extfiles = [] + for ext in exts: + (dirname, name, libname) = ext + if name != None and name != 'none': + testdir = os.path.dirname(__file__) + extdir = os.path.join(run.wt_builddir, 'ext', dirname) + extfile = os.path.join( + extdir, name, '.libs', 'libwiredtiger_' + libname + '.so') + if not os.path.exists(extfile): + self.skipTest('extension "' + extfile + '" not built') + if not extfile in extfiles: + extfiles.append(extfile) + if len(extfiles) == 0: + return '' + else: + return ',extensions=["' + '","'.join(extfiles) + '"]' + + # Override WiredTigerTestCase, we have extensions. + def setUpConnectionOpen(self, dir): + extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')]) + connarg = 'create,error_prefix="{0}: ",{1}'.format( + self.shortid(), extarg) + conn = self.wiredtiger_open(dir, connarg) + self.pr(`conn`) + return conn + + # JIRA WT-2308: + # Test extractors with equality joins + def test_join_extractor(self): + self.session.create('table:join04', + 'key_format=i,value_format=S,columns=(k,v)') + self.session.create('index:join04:index1', + 'key_format=i,extractor=csv,' + + 'app_metadata={"format" : "i", "field" : "0"}') + self.session.create('index:join04:index2', + 'key_format=i,extractor=csv,' + + 'app_metadata={"format" : "i", "field" : "1"}') + + cursor1 = self.session.open_cursor('table:join04', None, None) + cursor1[1] = '10,21' + cursor1[2] = '10,22' + cursor1.close() + + cursor1 = self.session.open_cursor('index:join04:index1', None, None) + cursor1.set_key(10) + cursor1.search() + cursor2 = self.session.open_cursor('index:join04:index2', None, None) + cursor2.set_key(22) + cursor2.search() + + jcursor = self.session.open_cursor('join:table:join04', None, None) + self.session.join(jcursor, cursor1, 'compare=eq') + self.session.join(jcursor, cursor2, 'compare=eq') + + found = 0 + while jcursor.next() == 0: + [k] = jcursor.get_keys() + [v] = jcursor.get_values() + self.assertEqual(k, 2) + self.assertEqual(v, '10,22') + found += 1 + self.assertEqual(found, 1) + jcursor.close() + cursor1.close() + cursor2.close() + + # More tests using extractors with equality joins + def test_join_extractor_more(self): + self.session.create('table:join04', + 'key_format=i,value_format=S,columns=(k,v)') + self.session.create('index:join04:index1', + 'key_format=i,extractor=csv,' + + 'app_metadata={"format" : "i", "field" : "0"}') + self.session.create('index:join04:index2', + 'key_format=i,extractor=csv,' + + 'app_metadata={"format" : "i", "field" : "1"}') + self.session.create('index:join04:index3', + 'key_format=i,extractor=csv,' + + 'app_metadata={"format" : "i", "field" : "2"}') + + jcursor = self.session.open_cursor('join:table:join04', None, None) + cursor1 = self.session.open_cursor('table:join04', None, None) + k = 1 + for v in ['10,21,30','10,22,30','10,23,30', + '11,21,30','11,22,30','11,23,30', + '10,21,31','10,22,31','10,23,31', + '10,21,30','11,22,31','12,23,32']: + cursor1[k] = v + k += 1 + cursor1.close() + + # A list of tests, one per line, each entry is: + # [[list of inputs], [list of outputs]] + tests = [ + [[10,22,30], ['10,22,30']], + [[10,21,30], ['10,21,30','10,21,30']], + [[11], ['11,21,30','11,22,30','11,23,30','11,22,31']], + [[None,22], ['10,22,30','11,22,30','10,22,31','11,22,31']]] + + for t in tests: + jcursor = self.session.open_cursor('join:table:join04', None, None) + ins = t[0] + outs = t[1] + cursors = [] + n = 0 + for k in ins: + n += 1 + if k == None: continue + uri = 'index:join04:index' + str(n) + c = self.session.open_cursor(uri, None, None) + c.set_key(k) + self.assertEqual(c.search(), 0) + cursors.append(c) + self.session.join(jcursor, c, 'compare=eq') + while jcursor.next() == 0: + [k] = jcursor.get_keys() + [v] = jcursor.get_values() + #self.tty('got=' + str(v) + ' at key=' + str(k)) + self.assertTrue(v in outs) + outs.remove(v) + self.assertEqual(len(outs), 0) + jcursor.close() + for c in cursors: + c.close() + + +if __name__ == '__main__': + wttest.run() diff --git a/test/suite/test_jsondump01.py b/test/suite/test_jsondump01.py index b483b4db429..ddf871d9a24 100644 --- a/test/suite/test_jsondump01.py +++ b/test/suite/test_jsondump01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_jsondump02.py b/test/suite/test_jsondump02.py index 790f651fd2f..c6cd464e453 100644 --- a/test/suite/test_jsondump02.py +++ b/test/suite/test_jsondump02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -209,7 +209,7 @@ class test_jsondump02(wttest.WiredTigerTestCase): self.check_json(self.table_uri3, ( ('"key0" : 1', '"value0" : "\\u0001\\u0002\\u0003"'), ('"key0" : 2', - '"value0" : "\\u0077\\u0088\\u0099\\u0000\\u00FF\\u00FE"'))) + '"value0" : "\\u0077\\u0088\\u0099\\u0000\\u00ff\\u00fe"'))) self.check_json(self.table_uri4, ( ('"ikey" : 1,\n"Skey" : "key1"', '"S1" : "val1",\n"i2" : 1,\n"S3" : "val1",\n"i4" : 1'), diff --git a/test/suite/test_lsm01.py b/test/suite/test_lsm01.py index f2561278edd..1f89cf38d77 100644 --- a/test/suite/test_lsm01.py +++ b/test/suite/test_lsm01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_lsm02.py b/test/suite/test_lsm02.py index afa5c47a77e..85067665017 100644 --- a/test/suite/test_lsm02.py +++ b/test/suite/test_lsm02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_metadata_cursor01.py b/test/suite/test_metadata_cursor01.py index 706b8a4132a..e759c14f846 100644 --- a/test/suite/test_metadata_cursor01.py +++ b/test/suite/test_metadata_cursor01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_nsnap01.py b/test/suite/test_nsnap01.py index 19253ec7631..5207b577ba4 100644 --- a/test/suite/test_nsnap01.py +++ b/test/suite/test_nsnap01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_nsnap02.py b/test/suite/test_nsnap02.py index fb0d798bedc..e4ed65ef72a 100644 --- a/test/suite/test_nsnap02.py +++ b/test/suite/test_nsnap02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_nsnap03.py b/test/suite/test_nsnap03.py index 969a217a868..0e853522940 100644 --- a/test/suite/test_nsnap03.py +++ b/test/suite/test_nsnap03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_nsnap04.py b/test/suite/test_nsnap04.py index 61b7bdd8bab..e8a5c9b6140 100644 --- a/test/suite/test_nsnap04.py +++ b/test/suite/test_nsnap04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_overwrite.py b/test/suite/test_overwrite.py index f710035c086..e22cdab4dea 100644 --- a/test/suite/test_overwrite.py +++ b/test/suite/test_overwrite.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_pack.py b/test/suite/test_pack.py index 451c6fbb9a9..9d833f49e16 100644 --- a/test/suite/test_pack.py +++ b/test/suite/test_pack.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_perf001.py b/test/suite/test_perf001.py index 4f99e552b79..1280639c9dd 100644 --- a/test/suite/test_perf001.py +++ b/test/suite/test_perf001.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -44,12 +44,7 @@ class test_perf001(wttest.WiredTigerTestCase): #('lsm-file', dict(tabletype='lsm',indextype='file')), #('lsm-lsm', dict(tabletype='lsm',indextype='lsm')), ]) - - def setUpConnectionOpen(self, dir): - wtopen_args = 'create,cache_size=512M' - conn = wiredtiger.wiredtiger_open(dir, wtopen_args) - self.pr(`conn`) - return conn + conn_config = 'cache_size=512M' def test_performance_of_indices(self): uri = 'table:' + self.table_name diff --git a/test/suite/test_rebalance.py b/test/suite/test_rebalance.py new file mode 100644 index 00000000000..80cce6ed514 --- /dev/null +++ b/test/suite/test_rebalance.py @@ -0,0 +1,81 @@ +#!/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 os, time +import wiredtiger, wttest +from helper import complex_populate, simple_populate +from wtscenario import check_scenarios + +# test_rebalance.py +# session level rebalance operation +class test_rebalance(wttest.WiredTigerTestCase): + name = 'test_rebalance' + + # Use small pages so we generate some internal layout + # Setup LSM so multiple chunks are present + config = 'key_format=S,allocation_size=512,internal_page_max=512' + \ + ',leaf_page_max=1k,lsm=(chunk_size=512k,merge_min=10)' + + scenarios = check_scenarios([ + ('file', dict(uri='file:')), + ('table', dict(uri='table:')), + ('lsm', dict(uri='lsm:')) + ]) + + # Populate an object, then rebalance it. + def rebalance(self, populate, with_cursor): + uri = self.uri + self.name + populate(self, uri, self.config, 10000) + + # Force to disk, we don't rebalance in-memory objects. + self.reopen_conn() + + # Open cursors should cause failure. + if with_cursor: + cursor = self.session.open_cursor(uri, None, None) + self.assertRaises(wiredtiger.WiredTigerError, + lambda: self.session.drop(uri, None)) + cursor.close() + + self.session.rebalance(uri, None) + self.session.drop(uri) + + # Test rebalance of an object. + def test_rebalance(self): + # Simple file or table object. + self.rebalance(simple_populate, False) + self.rebalance(simple_populate, True) + + # A complex, multi-file table object. + if self.uri == "table:": + self.rebalance(complex_populate, False) + self.rebalance(complex_populate, True) + + +if __name__ == '__main__': + wttest.run() diff --git a/test/suite/test_reconfig01.py b/test/suite/test_reconfig01.py index 2528f856a08..876de1fe5af 100644 --- a/test/suite/test_reconfig01.py +++ b/test/suite/test_reconfig01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_reconfig02.py b/test/suite/test_reconfig02.py index e0981a887fb..aee8ee4458b 100644 --- a/test/suite/test_reconfig02.py +++ b/test/suite/test_reconfig02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_rename.py b/test/suite/test_rename.py index 9ab4cb13da3..af968a4a38d 100644 --- a/test/suite/test_rename.py +++ b/test/suite/test_rename.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_salvage.py b/test/suite/test_salvage.py index 4bdffb262ab..3b648a7f170 100644 --- a/test/suite/test_salvage.py +++ b/test/suite/test_salvage.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_schema01.py b/test/suite/test_schema01.py index 44c4462cdc2..52bff7a13ff 100644 --- a/test/suite/test_schema01.py +++ b/test/suite/test_schema01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -56,11 +56,6 @@ class test_schema01(wttest.WiredTigerTestCase): wttest.WiredTigerTestCase.__init__(self, *args, **kwargs) self.reconcile = False - def reopen(self): - self.conn.close() - self.conn = wiredtiger.wiredtiger_open('.', None) - self.session = self.conn.open_session() - def create_table(self): self.pr('create table') self.session.create(self.tablename, 'key_format=5s,value_format=HQ,' + @@ -89,7 +84,7 @@ class test_schema01(wttest.WiredTigerTestCase): c.close() if reopen: - self.reopen() + self.reopen_conn() c = self.cursor() expectpos = 0 diff --git a/test/suite/test_schema02.py b/test/suite/test_schema02.py index 96347a2abf3..6895e947efe 100644 --- a/test/suite/test_schema02.py +++ b/test/suite/test_schema02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -99,6 +99,14 @@ class test_schema02(wttest.WiredTigerTestCase): # expect this to work self.session.create("colgroup:main:c1", "columns=(S1,i2)") + # exclusive: no error message + self.expect_failure_colgroup("main:c1", "columns=(S1,i2),exclusive", + "") + + # exists with different config + self.expect_failure_colgroup("main:c1", "columns=(S1,i4)", + "/does not match existing configuration/") + # colgroup not declared in initial create self.expect_failure_colgroup("main:c3", "columns=(S3,i4)", "/Column group 'c3' not found in" diff --git a/test/suite/test_schema03.py b/test/suite/test_schema03.py index 6e535b60850..f48bfdf3cf8 100644 --- a/test/suite/test_schema03.py +++ b/test/suite/test_schema03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -219,6 +219,9 @@ class test_schema03(wttest.WiredTigerTestCase): - between each step, whether to close/reopen the connection """ + # Boost cache size and number of sessions for this test + conn_config = 'cache_size=100m,session_max=1000' + ################################################################ # These three variables can be altered to help generate # and pare down failing test cases. @@ -297,12 +300,6 @@ class test_schema03(wttest.WiredTigerTestCase): resource.setrlimit(resource.RLIMIT_NOFILE, newlimit) super(test_schema03, self).setUp() - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,cache_size=100m,session_max=1000') - self.pr(`conn`) - return conn - def tearDown(self): super(test_schema03, self).tearDown() resource.setrlimit(resource.RLIMIT_NOFILE, self.origFileLimit) diff --git a/test/suite/test_schema04.py b/test/suite/test_schema04.py index a66e1ea2411..cd41138deb0 100644 --- a/test/suite/test_schema04.py +++ b/test/suite/test_schema04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_schema05.py b/test/suite/test_schema05.py index b0562f7983c..89722d5f89a 100644 --- a/test/suite/test_schema05.py +++ b/test/suite/test_schema05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -81,7 +81,7 @@ class test_schema05(wttest.WiredTigerTestCase): extarg = self.extensionArg([('extractors', 'csv', 'csv_extractor')]) connarg = 'create,error_prefix="{0}: ",{1}'.format( self.shortid(), extarg) - conn = wiredtiger.wiredtiger_open(dir, connarg) + conn = self.wiredtiger_open(dir, connarg) self.pr(`conn`) return conn diff --git a/test/suite/test_schema06.py b/test/suite/test_schema06.py index c1a39465db4..e72959edf2a 100644 --- a/test/suite/test_schema06.py +++ b/test/suite/test_schema06.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_shared_cache01.py b/test/suite/test_shared_cache01.py index b5abc047334..896a1e569ef 100644 --- a/test/suite/test_shared_cache01.py +++ b/test/suite/test_shared_cache01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -72,7 +72,7 @@ class test_shared_cache01(wttest.WiredTigerTestCase): for name in connections: shutil.rmtree(name, True) os.mkdir(name) - next_conn = wiredtiger.wiredtiger_open( + next_conn = self.wiredtiger_open( name, 'create,error_prefix="' + self.shortid() + ': "' + pool_opts + extra_opts) diff --git a/test/suite/test_shared_cache02.py b/test/suite/test_shared_cache02.py index ffe27360399..4afccbe59f7 100644 --- a/test/suite/test_shared_cache02.py +++ b/test/suite/test_shared_cache02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -72,7 +72,7 @@ class test_shared_cache02(wttest.WiredTigerTestCase): for name in connections: shutil.rmtree(name, True) os.mkdir(name) - next_conn = wiredtiger.wiredtiger_open( + next_conn = self.wiredtiger_open( name, 'create,error_prefix="' + self.shortid() + ': "' + pool_opts + extra_opts) diff --git a/test/suite/test_split.py b/test/suite/test_split.py index dbed0956c94..d09613e1c52 100644 --- a/test/suite/test_split.py +++ b/test/suite/test_split.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_stat01.py b/test/suite/test_stat01.py index 96f246e3c8a..5c3259696eb 100644 --- a/test/suite/test_stat01.py +++ b/test/suite/test_stat01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -51,11 +51,7 @@ class test_stat01(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(multiply_scenarios('.', types, keyfmt)) - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def statstr_to_int(self, str): """ diff --git a/test/suite/test_stat02.py b/test/suite/test_stat02.py index 8643d700793..88371947b5b 100644 --- a/test/suite/test_stat02.py +++ b/test/suite/test_stat02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -60,13 +60,9 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase): scenarios = number_scenarios( multiply_scenarios('.', uri, data_config, cursor_config)) - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,' + - 'statistics=(' + self.data_config + '),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + # Turn on statistics for this test. + def conn_config(self, dir): + return 'statistics=(%s)' % self.data_config # For each database/cursor configuration, confirm the right combinations # succeed or fail. @@ -87,13 +83,7 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase): # Test the connection "clear" configuration. class test_stat_cursor_conn_clear(wttest.WiredTigerTestCase): pfx = 'test_stat_cursor_conn_clear' - - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def test_stat_cursor_conn_clear(self): uri = 'table:' + self.pfx @@ -123,13 +113,7 @@ class test_stat_cursor_dsrc_clear(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(multiply_scenarios('.', uri)) - - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def test_stat_cursor_dsrc_clear(self): self.pop(self, self.uri, 'key_format=S', 100) @@ -159,13 +143,7 @@ class test_stat_cursor_fast(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(multiply_scenarios('.', uri)) - - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def test_stat_cursor_fast(self): self.pop(self, self.uri, 'key_format=S', 100) @@ -194,7 +172,7 @@ class test_stat_cursor_conn_error(wttest.WiredTigerTestCase): config = 'create,statistics=(' + i[0] + ',' + i[1] + ')' msg = '/only one statistics configuration value/' self.assertRaisesWithMessage(wiredtiger.WiredTigerError, - lambda: wiredtiger.wiredtiger_open('.', config), msg) + lambda: self.wiredtiger_open('.', config), msg) # Test data-source error combinations. @@ -209,13 +187,7 @@ class test_stat_cursor_dsrc_error(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(multiply_scenarios('.', uri)) - - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def test_stat_cursor_dsrc_error(self): self.pop(self, self.uri, 'key_format=S', 100) diff --git a/test/suite/test_stat03.py b/test/suite/test_stat03.py index 2e2af16f953..039ad1f7f8d 100644 --- a/test/suite/test_stat03.py +++ b/test/suite/test_stat03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -52,13 +52,7 @@ class test_stat_cursor_reset(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(multiply_scenarios('.', uri)) - - # Override WiredTigerTestCase, we have extensions. - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(all)' def stat_cursor(self, uri): return self.session.open_cursor( diff --git a/test/suite/test_stat04.py b/test/suite/test_stat04.py index 33e7a925c6a..e7c39371f80 100644 --- a/test/suite/test_stat04.py +++ b/test/suite/test_stat04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -50,13 +50,7 @@ class test_stat04(wttest.WiredTigerTestCase, suite_subprocess): ('jumboval', dict(nentries=100, valuesize=4200000)), ] scenarios = number_scenarios(multiply_scenarios('.', keyfmt, nentries)) - - # Override WiredTigerTestCase - def setUpConnectionOpen(self, dir): - return wiredtiger.wiredtiger_open(dir, - 'create,' + - 'statistics=(all),' + - 'error_prefix="%s: "' % self.shortid()) + conn_config = 'statistics=(all)' def init_test(self): self.valuepfx = self.valuesize * 'X' diff --git a/test/suite/test_stat05.py b/test/suite/test_stat05.py index f147b93ce81..6a93ec2c84d 100644 --- a/test/suite/test_stat05.py +++ b/test/suite/test_stat05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -49,14 +49,7 @@ class test_stat_cursor_config(wttest.WiredTigerTestCase): ] scenarios = number_scenarios(uri) - - # Override WiredTigerTestCase to enable statistics - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,' + - 'statistics=(fast),' + - 'error_prefix="%s: "' % self.shortid()) - return conn + conn_config = 'statistics=(fast)' def openAndWalkStatCursor(self): c = self.session.open_cursor( diff --git a/test/suite/test_stat_log01.py b/test/suite/test_stat_log01.py index 6b0ba52cae1..f6033d940c5 100644 --- a/test/suite/test_stat_log01.py +++ b/test/suite/test_stat_log01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -47,21 +47,21 @@ class test_stat_log01(wttest.WiredTigerTestCase): return None def test_stats_log_default(self): - self.conn = wiredtiger.wiredtiger_open( + self.conn = self.wiredtiger_open( None, "create,statistics=(fast),statistics_log=(wait=1)") # Wait for the default interval, to ensure stats have been written. time.sleep(2) self.check_stats_file("WiredTigerStat") def test_stats_log_name(self): - self.conn = wiredtiger.wiredtiger_open( + self.conn = self.wiredtiger_open( None, "create,statistics=(fast),statistics_log=(wait=1,path=foo)") # Wait for the default interval, to ensure stats have been written. time.sleep(2) self.check_stats_file("foo") def test_stats_log_on_close_and_log(self): - self.conn = wiredtiger.wiredtiger_open(None, + self.conn = self.wiredtiger_open(None, "create,statistics=(fast),statistics_log=(on_close=true,wait=1)") # Wait for the default interval, to ensure stats have been written. time.sleep(2) @@ -69,7 +69,7 @@ class test_stat_log01(wttest.WiredTigerTestCase): self.check_stats_file("WiredTigerStat") def test_stats_log_on_close(self): - self.conn = wiredtiger.wiredtiger_open(None, + self.conn = self.wiredtiger_open(None, "create,statistics=(fast),statistics_log=(on_close=true)") # Close the connection to ensure the statistics get generated. self.close_conn() diff --git a/test/suite/test_sweep01.py b/test/suite/test_sweep01.py index 13422a75a61..f996dbfa06d 100644 --- a/test/suite/test_sweep01.py +++ b/test/suite/test_sweep01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -33,7 +33,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -42,6 +42,9 @@ class test_sweep01(wttest.WiredTigerTestCase, suite_subprocess): uri = 'table:' + tablebase numfiles = 50 numkv = 1000 + conn_config = 'file_manager=(close_handle_minimum=0,' + \ + 'close_idle_time=6,close_scan_interval=2),' + \ + 'statistics=(fast),' types = [ ('row', dict(tabletype='row', @@ -54,26 +57,6 @@ class test_sweep01(wttest.WiredTigerTestCase, suite_subprocess): scenarios = types - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - self.backup_dir = os.path.join(self.home, "WT_BACKUP") - # Configure sweep to run every 2 seconds with a 6 second timeout. - # That matches the ratio of the default 10 and 30 seconds. - conn_params = \ - ',create,error_prefix="%s: ",' % self.shortid() + \ - 'file_manager=(close_handle_minimum=0,' + \ - 'close_idle_time=6,close_scan_interval=2),' + \ - 'statistics=(fast),' - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except wiredtiger.WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - self.session2 = conn.open_session() - return conn - def test_ops(self): # # Set up numfiles with numkv entries. We just want some data in there diff --git a/test/suite/test_sweep02.py b/test/suite/test_sweep02.py index ac389418b7e..cff45e0d2f9 100644 --- a/test/suite/test_sweep02.py +++ b/test/suite/test_sweep02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -31,7 +31,6 @@ # import wiredtiger, wttest -from wiredtiger import wiredtiger_open from wttest import unittest class test_sweep02(wttest.WiredTigerTestCase): @@ -49,23 +48,23 @@ class test_sweep02(wttest.WiredTigerTestCase): return None def test_config01(self): - self.conn = wiredtiger_open(self.dir, + self.conn = self.wiredtiger_open(self.dir, self.base_config + "file_manager=()") def test_config02(self): - self.conn = wiredtiger_open(self.dir, + self.conn = self.wiredtiger_open(self.dir, self.base_config + "file_manager=(close_scan_interval=1)") def test_config03(self): - self.conn = wiredtiger_open(self.dir, + self.conn = self.wiredtiger_open(self.dir, self.base_config + "file_manager=(close_idle_time=1)") def test_config04(self): - self.conn = wiredtiger_open(self.dir, + self.conn = self.wiredtiger_open(self.dir, self.base_config + "file_manager=(close_handle_minimum=500)") def test_config05(self): - self.conn = wiredtiger_open(self.dir, self.base_config + \ + self.conn = self.wiredtiger_open(self.dir, self.base_config + \ "file_manager=(close_scan_interval=1,close_idle_time=1)") if __name__ == '__main__': diff --git a/test/suite/test_sweep03.py b/test/suite/test_sweep03.py index 684c87695c5..061c2f5b37b 100644 --- a/test/suite/test_sweep03.py +++ b/test/suite/test_sweep03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -41,6 +41,9 @@ class test_sweep03(wttest.WiredTigerTestCase, suite_subprocess): uri = 'table:' + tablebase numfiles = 400 # Make this more than the default close_handle_minimum numkv = 100 + conn_config = 'file_manager=(close_handle_minimum=10,' + \ + 'close_idle_time=0,close_scan_interval=1),' + \ + 'statistics=(fast),' types = [ ('row', dict(tabletype='row', @@ -53,24 +56,6 @@ class test_sweep03(wttest.WiredTigerTestCase, suite_subprocess): scenarios = types - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - - conn_params = \ - ',create,error_prefix="%s: ",' % self.shortid() + \ - 'file_manager=(close_handle_minimum=10,' + \ - 'close_idle_time=0,close_scan_interval=1),' + \ - 'statistics=(fast),' - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except wiredtiger.WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - self.session2 = conn.open_session() - return conn - def test_disable_idle_timeout1(self): # # Set up numfiles with numkv entries. We just want some data in there diff --git a/test/suite/test_truncate01.py b/test/suite/test_truncate01.py index dd91a7868ec..77a476e40c1 100644 --- a/test/suite/test_truncate01.py +++ b/test/suite/test_truncate01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_truncate02.py b/test/suite/test_truncate02.py index a11de6cc5da..6c11302787c 100644 --- a/test/suite/test_truncate02.py +++ b/test/suite/test_truncate02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_truncate03.py b/test/suite/test_truncate03.py index 85826841814..e2db355f0ef 100644 --- a/test/suite/test_truncate03.py +++ b/test/suite/test_truncate03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_txn01.py b/test/suite/test_txn01.py index cbb771273a6..eb6963791fd 100644 --- a/test/suite/test_txn01.py +++ b/test/suite/test_txn01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -42,13 +42,6 @@ class test_txn01(wttest.WiredTigerTestCase): ('row-t', dict(uri='table:text_txn01',key_format='S',value_format='S')), ]) - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, 'create,' + - ('error_prefix="%s: ",' % self.shortid())) - self.pr(`conn`) - return conn - # Return the number of records visible to the cursor. def cursor_count(self, cursor): count = 0 diff --git a/test/suite/test_txn02.py b/test/suite/test_txn02.py index 17d0b97b50f..fccf123d3bc 100644 --- a/test/suite/test_txn02.py +++ b/test/suite/test_txn02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -119,7 +118,7 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess): 'create,error_prefix="%s: ",' % self.shortid() + \ 'transaction_sync="%s",' % self.txn_sync # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - conn = wiredtiger_open(dir, conn_params) + conn = self.wiredtiger_open(dir, conn_params) self.pr(`conn`) self.session2 = conn.open_session() return conn @@ -154,7 +153,7 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess): # recovery and see the committed results. self.backup(self.backup_dir) backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) finally: @@ -178,7 +177,8 @@ class test_txn02(wttest.WiredTigerTestCase, suite_subprocess): endcount = 2 count = 0 while count < endcount: - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, + backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) finally: diff --git a/test/suite/test_txn03.py b/test/suite/test_txn03.py index e2efef1742e..97180a75949 100644 --- a/test/suite/test_txn03.py +++ b/test/suite/test_txn03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -46,13 +46,6 @@ class test_txn03(wttest.WiredTigerTestCase): ('var', dict(create_params = "key_format=S,value_format=S")), ]) - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, 'create,' + - ('error_prefix="%s: ",' % self.shortid())) - self.pr(`conn`) - return conn - def test_ops(self): self.session.create(self.uri1, self.create_params) self.session.create(self.uri2, self.create_params) diff --git a/test/suite/test_txn04.py b/test/suite/test_txn04.py index f9f660223da..de49c5fe235 100644 --- a/test/suite/test_txn04.py +++ b/test/suite/test_txn04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import shutil, os from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios import wttest @@ -78,7 +77,7 @@ class test_txn04(wttest.WiredTigerTestCase, suite_subprocess): 'create,error_prefix="%s: ",' % self.shortid() + \ 'transaction_sync="%s",' % self.txn_sync # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - conn = wiredtiger_open(dir, conn_params) + conn = self.wiredtiger_open(dir, conn_params) self.pr(`conn`) self.session2 = conn.open_session() return conn @@ -124,7 +123,7 @@ class test_txn04(wttest.WiredTigerTestCase, suite_subprocess): self.runWt(cmd.split()) self.exception='false' backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) except: diff --git a/test/suite/test_txn05.py b/test/suite/test_txn05.py index d427b893b17..bb68034ca04 100644 --- a/test/suite/test_txn05.py +++ b/test/suite/test_txn05.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios import wttest @@ -79,7 +78,7 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess): 'create,error_prefix="%s: ",' % self.shortid() + \ 'transaction_sync="%s",' % self.txn_sync # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - conn = wiredtiger_open(dir, conn_params) + conn = self.wiredtiger_open(dir, conn_params) self.pr(`conn`) self.session2 = conn.open_session() return conn @@ -114,7 +113,7 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess): # recovery and see the committed results. self.backup(self.backup_dir) backup_conn_params = 'log=(enabled,file_max=%s)' % self.logmax - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) finally: @@ -138,7 +137,8 @@ class test_txn05(wttest.WiredTigerTestCase, suite_subprocess): endcount = 2 count = 0 while count < endcount: - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, + backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) finally: diff --git a/test/suite/test_txn06.py b/test/suite/test_txn06.py index 4e3416c2235..9c1d0335d47 100644 --- a/test/suite/test_txn06.py +++ b/test/suite/test_txn06.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_txn07.py b/test/suite/test_txn07.py index fa522582a8e..94c26990178 100644 --- a/test/suite/test_txn07.py +++ b/test/suite/test_txn07.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import multiply_scenarios, number_scenarios import wttest @@ -90,7 +90,7 @@ class test_txn07(wttest.WiredTigerTestCase, suite_subprocess): 'transaction_sync="%s",' % self.txn_sync # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) try: - conn = wiredtiger_open(dir, conn_params) + conn = self.wiredtiger_open(dir, conn_params) except wiredtiger.WiredTigerError as e: print "Failed conn at '%s' with config '%s'" % (dir, conn_params) self.pr(`conn`) @@ -142,7 +142,7 @@ class test_txn07(wttest.WiredTigerTestCase, suite_subprocess): backup_conn_params = 'log=(enabled,file_max=%s,' % self.logmax + \ 'compressor=%s)' % self.compress + \ self.extensionArg(self.compress) - backup_conn = wiredtiger_open(self.backup_dir, backup_conn_params) + backup_conn = self.wiredtiger_open(self.backup_dir, backup_conn_params) try: self.check(backup_conn.open_session(), None, committed) finally: diff --git a/test/suite/test_txn08.py b/test/suite/test_txn08.py index d35a0c70b3b..36253856285 100644 --- a/test/suite/test_txn08.py +++ b/test/suite/test_txn08.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import multiply_scenarios, number_scenarios import wttest @@ -41,24 +41,10 @@ class test_txn08(wttest.WiredTigerTestCase, suite_subprocess): tablename = 'test_txn08' uri = 'table:' + tablename - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - # Cycle through the different transaction_sync values in a - # deterministic manner. - self.txn_sync = '(method=dsync,enabled)' - conn_params = \ - 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \ - ',create,error_prefix="%s: ",' % self.shortid() + \ - 'transaction_sync="%s",' % self.txn_sync - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except wiredtiger.WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - self.session2 = conn.open_session() - return conn + # Turn on logging for this test. + def conn_config(self, dir): + return 'log=(archive=false,enabled,file_max=%s),' % self.logmax + \ + 'transaction_sync="(method=dsync,enabled)"' def test_printlog_unicode(self): # print "Creating %s with config '%s'" % (self.uri, self.create_params) @@ -82,6 +68,11 @@ class test_txn08(wttest.WiredTigerTestCase, suite_subprocess): self.runWt(['printlog'], outfilename='printlog.out') self.check_file_contains('printlog.out', '\\u0001\\u0002abcd\\u0003\\u0004') + self.runWt(['printlog', '-x'], outfilename='printlog-hex.out') + self.check_file_contains('printlog-hex.out', + '\\u0001\\u0002abcd\\u0003\\u0004') + self.check_file_contains('printlog-hex.out', + '0102616263640304') if __name__ == '__main__': wttest.run() diff --git a/test/suite/test_txn09.py b/test/suite/test_txn09.py index df085a75d67..f536d65205d 100644 --- a/test/suite/test_txn09.py +++ b/test/suite/test_txn09.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -91,7 +90,7 @@ class test_txn09(wttest.WiredTigerTestCase, suite_subprocess): 'transaction_sync=(enabled=false),' # print "Opening conn at '%s' with config '%s'" % (dir, conn_params) - conn = wiredtiger_open(dir, conn_params) + conn = self.wiredtiger_open(dir, conn_params) self.pr(`conn`) self.session2 = conn.open_session() return conn diff --git a/test/suite/test_txn10.py b/test/suite/test_txn10.py index 49ef2b10abe..cf9c11dd4ab 100644 --- a/test/suite/test_txn10.py +++ b/test/suite/test_txn10.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -40,13 +39,8 @@ class test_txn10(wttest.WiredTigerTestCase, suite_subprocess): t1 = 'table:test_txn10_1' t2 = 'table:test_txn10_2' create_params = 'key_format=i,value_format=i' - - # Overrides WiredTigerTestCase, add extra config params - def setUpConnectionOpen(self, dir): - self.conn_config = \ - 'log=(archive=false,enabled,file_max=100K),' + \ + conn_config = 'log=(archive=false,enabled,file_max=100K),' + \ 'transaction_sync=(method=dsync,enabled)' - return wttest.WiredTigerTestCase.setUpConnectionOpen(self, dir) def simulate_crash_restart(self, olddir, newdir): ''' Simulate a crash from olddir and restart in newdir. ''' diff --git a/test/suite/test_txn11.py b/test/suite/test_txn11.py index b97df689905..ab87283c014 100644 --- a/test/suite/test_txn11.py +++ b/test/suite/test_txn11.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, time from suite_subprocess import suite_subprocess from helper import simple_populate -from wiredtiger import wiredtiger_open import wttest class test_txn11(wttest.WiredTigerTestCase, suite_subprocess): @@ -44,15 +43,11 @@ class test_txn11(wttest.WiredTigerTestCase, suite_subprocess): source_uri = 'table:' + tablename + "_src" uri = 'table:' + tablename - def setUpConnectionOpen(self, dir): - self.home = dir - conn_params = \ - 'create,error_prefix="%s: ",' % self.shortid() + \ - 'log=(archive=%s,enabled,file_max=%s,prealloc=false),' % (self.archive, self.logmax) + \ + # Turn on logging for this test. + def conn_config(self, dir): + return 'log=(archive=%s,' % self.archive + \ + 'enabled,file_max=%s,prealloc=false),' % self.logmax + \ 'transaction_sync=(enabled=false),' - conn = wiredtiger_open(dir, conn_params) - self.pr(`conn`) - return conn def run_checkpoints(self): orig_logs = fnmatch.filter(os.listdir(self.home), "*Log*") diff --git a/test/suite/test_txn12.py b/test/suite/test_txn12.py index 71e57ea7432..8ae9df33990 100644 --- a/test/suite/test_txn12.py +++ b/test/suite/test_txn12.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_txn13.py b/test/suite/test_txn13.py index d60fee65bce..dd6a6dbcd6d 100644 --- a/test/suite/test_txn13.py +++ b/test/suite/test_txn13.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -33,7 +33,6 @@ #import fnmatch, os, shutil, run, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import check_scenarios import wiredtiger, wttest @@ -50,19 +49,10 @@ class test_txn13(wttest.WiredTigerTestCase, suite_subprocess): ('4gb', dict(expect_err=True, valuesize=4194304)) ]) - # Overrides WiredTigerTestCase - def setUpConnectionOpen(self, dir): - self.home = dir - conn_params = \ - 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \ - ',create,cache_size=8G,error_prefix="%s: ",' % self.shortid() - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - try: - conn = wiredtiger_open(dir, conn_params) - except wiredtiger.WiredTigerError as e: - print "Failed conn at '%s' with config '%s'" % (dir, conn_params) - self.pr(`conn`) - return conn + # Turn on logging for this test. + def conn_config(self, dir): + return 'log=(archive=false,enabled,file_max=%s)' % self.logmax + \ + ',cache_size=8G' @wttest.longtest('txn tests with huge values') def test_large_values(self): diff --git a/test/suite/test_txn14.py b/test/suite/test_txn14.py index a126f843768..371f4402567 100644 --- a/test/suite/test_txn14.py +++ b/test/suite/test_txn14.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,6 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -41,6 +40,7 @@ class test_txn14(wttest.WiredTigerTestCase, suite_subprocess): create_params = 'key_format=i,value_format=i' entries = 10000 extra_entries = 5 + conn_config = 'log=(archive=false,enabled,file_max=100K)' sync_list = [ ('write', dict(sync='off')), @@ -49,11 +49,6 @@ class test_txn14(wttest.WiredTigerTestCase, suite_subprocess): ] scenarios = multiply_scenarios('.', sync_list) - # Overrides WiredTigerTestCase, add extra config params - def setUpConnectionOpen(self, dir): - self.conn_config = 'log=(archive=false,enabled,file_max=100K),' - return wttest.WiredTigerTestCase.setUpConnectionOpen(self, dir) - def simulate_crash_restart(self, olddir, newdir): ''' Simulate a crash from olddir and restart in newdir. ''' # with the connection still open, copy files to new directory diff --git a/test/suite/test_txn15.py b/test/suite/test_txn15.py index e36e8556d1e..809dce4ebfa 100644 --- a/test/suite/test_txn15.py +++ b/test/suite/test_txn15.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -32,7 +32,7 @@ import fnmatch, os, shutil, time from suite_subprocess import suite_subprocess -from wiredtiger import wiredtiger_open, stat +from wiredtiger import stat from wtscenario import multiply_scenarios, number_scenarios, prune_scenarios import wttest @@ -40,6 +40,13 @@ class test_txn15(wttest.WiredTigerTestCase, suite_subprocess): uri = 'table:test_txn15_1' create_params = 'key_format=i,value_format=i' entries = 100 + # Turn on logging for this test. + def conn_config(self, dir): + return 'statistics=(fast),' + \ + 'log=(archive=false,enabled,file_max=100K),' + \ + 'use_environment=false,' + \ + 'transaction_sync=(enabled=%s),' % self.conn_enable + \ + 'transaction_sync=(method=%s),' % self.conn_method conn_sync_enabled = [ ('en_off', dict(conn_enable='false')), @@ -67,23 +74,6 @@ class test_txn15(wttest.WiredTigerTestCase, suite_subprocess): scenarios = multiply_scenarios('.', conn_sync_enabled, conn_sync_method, begin_sync, commit_sync) - # Overrides WiredTigerTestCase, add extra config params - def setUpConnectionOpen(self, dir): - self.home = dir - # - # Turn off using any environment variables that may be set by the - # testing infrastructure. - # - conn_params = \ - 'create,statistics=(fast),error_prefix="%s: ",' % self.shortid() + \ - 'log=(archive=false,enabled,file_max=100K),' + \ - 'use_environment=false,' + \ - 'transaction_sync=(enabled=%s),' % self.conn_enable + \ - 'transaction_sync=(method=%s),' % self.conn_method - # print "Creating conn at '%s' with config '%s'" % (dir, conn_params) - conn = wiredtiger_open(dir, conn_params) - return conn - # Given the different configuration settings determine if this group # of settings would result in either a wait for write or sync. # Returns None, "write" or "sync". None means no waiting for either. diff --git a/test/suite/test_unicode01.py b/test/suite/test_unicode01.py index 76ebd886319..0796abf4607 100644 --- a/test/suite/test_unicode01.py +++ b/test/suite/test_unicode01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_upgrade.py b/test/suite/test_upgrade.py index df8024413cc..357e437f14d 100644 --- a/test/suite/test_upgrade.py +++ b/test/suite/test_upgrade.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util01.py b/test/suite/test_util01.py index 29033fb43ba..726a53eb5ca 100644 --- a/test/suite/test_util01.py +++ b/test/suite/test_util01.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util02.py b/test/suite/test_util02.py index 33672411671..51e03d8d105 100644 --- a/test/suite/test_util02.py +++ b/test/suite/test_util02.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util03.py b/test/suite/test_util03.py index 9e3c81334ec..c3ea48b8f5e 100644 --- a/test/suite/test_util03.py +++ b/test/suite/test_util03.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util04.py b/test/suite/test_util04.py index 09b4facb220..d165d350adb 100644 --- a/test/suite/test_util04.py +++ b/test/suite/test_util04.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util07.py b/test/suite/test_util07.py index 37de647cae1..2bbb40422bd 100644 --- a/test/suite/test_util07.py +++ b/test/suite/test_util07.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util08.py b/test/suite/test_util08.py index 7c4c5cfcf85..b2bb1e067e0 100644 --- a/test/suite/test_util08.py +++ b/test/suite/test_util08.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util09.py b/test/suite/test_util09.py index e5b0b57a23c..ddf01b980ea 100644 --- a/test/suite/test_util09.py +++ b/test/suite/test_util09.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util11.py b/test/suite/test_util11.py index d9b226b506a..6bf87525164 100644 --- a/test/suite/test_util11.py +++ b/test/suite/test_util11.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_util12.py b/test/suite/test_util12.py index 0faa8dbf8bd..e8226a3146c 100644 --- a/test/suite/test_util12.py +++ b/test/suite/test_util12.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_verify.py b/test/suite/test_verify.py index 5889054f269..5ce926027ef 100644 --- a/test/suite/test_verify.py +++ b/test/suite/test_verify.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/test_version.py b/test/suite/test_version.py index 4d59ea6d279..f8835e5bd05 100644 --- a/test/suite/test_version.py +++ b/test/suite/test_version.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/wtscenario.py b/test/suite/wtscenario.py index 0f8e8c30c1f..7fad7c228fb 100644 --- a/test/suite/wtscenario.py +++ b/test/suite/wtscenario.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. diff --git a/test/suite/wttest.py b/test/suite/wttest.py index 443fabb00b2..b5a58d1566f 100644 --- a/test/suite/wttest.py +++ b/test/suite/wttest.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -135,9 +135,31 @@ class CapturedFd(object): self.expectpos = os.path.getsize(self.filename) +class TestSuiteConnection(object): + def __init__(self, conn, connlist): + connlist.append(conn) + self._conn = conn + self._connlist = connlist + + def close(self): + self._connlist.remove(self._conn) + return self._conn.close() + + # Proxy everything except what we explicitly define to the + # wrapped connection + def __getattr__(self, attr): + if attr in self.__dict__: + return getattr(self, attr) + else: + return getattr(self._conn, attr) + + class WiredTigerTestCase(unittest.TestCase): _globalSetup = False _printOnceSeen = {} + + # conn_config can be overridden to add to basic connection configuration. + # Can be a string or a callable function or lambda expression. conn_config = '' @staticmethod @@ -198,13 +220,32 @@ class WiredTigerTestCase(unittest.TestCase): return "%s.%s.%s" % (self.__module__, self.className(), self._testMethodName) - # Can be overridden - def setUpConnectionOpen(self, dir): - conn = wiredtiger.wiredtiger_open(dir, - 'create,error_prefix="%s",%s' % (self.shortid(), self.conn_config)) + # Can be overridden, but first consider setting self.conn_config . + def setUpConnectionOpen(self, home): + self.home = home + config = self.conn_config + if hasattr(config, '__call__'): + config = config(home) + # In case the open starts additional threads, flush first to + # avoid confusion. + sys.stdout.flush() + conn_param = 'create,error_prefix="%s: ",%s' % (self.shortid(), config) + try: + conn = self.wiredtiger_open(home, conn_param) + except wiredtiger.WiredTigerError as e: + print "Failed wiredtiger_open: dir '%s', config '%s'" % \ + (home, conn_param) + raise e self.pr(`conn`) return conn + # Replacement for wiredtiger.wiredtiger_open that returns + # a proxied connection that knows to close it itself at the + # end of the run, unless it was already closed. + def wiredtiger_open(self, home=None, config=''): + conn = wiredtiger.wiredtiger_open(home, config) + return TestSuiteConnection(conn, self._connections) + # Can be overridden def setUpSessionOpen(self, conn): return conn.open_session(None) @@ -244,6 +285,8 @@ class WiredTigerTestCase(unittest.TestCase): self.__class__.wt_ntests += 1 if WiredTigerTestCase._verbose > 2: self.prhead('started in ' + self.testdir, True) + # tearDown needs connections list, set it here in case the open fails. + self._connections = [] self.origcwd = os.getcwd() shutil.rmtree(self.testdir, ignore_errors=True) if os.path.exists(self.testdir): @@ -269,10 +312,18 @@ class WiredTigerTestCase(unittest.TestCase): skipped = (excinfo[0] == unittest.SkipTest) self.pr('finishing') - try: - self.close_conn() - except: - pass + # Close all connections that weren't explicitly closed. + # Connections left open (as a result of a test failure) + # can result in cascading errors. We also make sure + # self.conn is on the list of active connections. + if not self.conn in self._connections: + self._connections.append(self.conn) + for conn in self._connections: + try: + conn.close() + except: + pass + self._connections = [] try: self.fdTearDown() diff --git a/test/suite/wtthread.py b/test/suite/wtthread.py index 33c5c61e00f..046a915394d 100644 --- a/test/suite/wtthread.py +++ b/test/suite/wtthread.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Public Domain 2014-2015 MongoDB, Inc. +# Public Domain 2014-2016 MongoDB, Inc. # Public Domain 2008-2014 WiredTiger, Inc. # # This is free and unencumbered software released into the public domain. @@ -70,30 +70,35 @@ class backup_thread(threading.Thread): cursor.close() - bkp_conn = wiredtiger.wiredtiger_open(self.backup_dir) - bkp_session = bkp_conn.open_session() - # Verify that the backup was OK. - uris = list() - for next_file in files: - if next_file.startswith("WiredTiger"): - continue - uri = "file:" + next_file - uris.append(uri) + bkp_conn = None + try: + bkp_conn = wiredtiger.wiredtiger_open(self.backup_dir) + bkp_session = bkp_conn.open_session() + # Verify that the backup was OK. + uris = list() + for next_file in files: + if next_file.startswith("WiredTiger"): + continue + uri = "file:" + next_file + uris.append(uri) - # TODO: We want a self.assertTrue here - but need to be a wttest to - # do that.. - if not compare_tables( + # TODO: We want a self.assertTrue here - be need to be a + # wttest to do that.. + if not compare_tables( self, sess, uris, "checkpoint=WiredTigerCheckpoint"): - print "Error: checkpoint tables differ." - else: - wttest.WiredTigerTestCase.printVerbose( - 3, "Checkpoint tables match") + print "Error: checkpoint tables differ." + else: + wttest.WiredTigerTestCase.printVerbose( + 3, "Checkpoint tables match") - if not compare_tables(self, bkp_session, uris): - print "Error: backup tables differ." - else: - wttest.WiredTigerTestCase.printVerbose(3, "Backup tables match") - bkp_conn.close() + if not compare_tables(self, bkp_session, uris): + print "Error: backup tables differ." + else: + wttest.WiredTigerTestCase.printVerbose( + 3, "Backup tables match") + finally: + if bkp_conn != None: + bkp_conn.close() sess.close() diff --git a/test/thread/file.c b/test/thread/file.c index d2cd7f157ab..81ec6ad44f8 100644 --- a/test/thread/file.c +++ b/test/thread/file.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/thread/rw.c b/test/thread/rw.c index c9e2e78ec35..913fa6e6c25 100644 --- a/test/thread/rw.c +++ b/test/thread/rw.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -205,10 +205,10 @@ reader(void *arg) printf(" read thread %2d starting: tid: %s, file: %s\n", id, tid, s->name); - sched_yield(); /* Get all the threads created. */ + __wt_yield(); /* Get all the threads created. */ if (session_per_op) { - for (i = 0; i < s->nops; ++i, ++s->reads, sched_yield()) { + for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield()) { if ((ret = conn->open_session( conn, NULL, NULL, &session)) != 0) testutil_die(ret, "conn.open_session"); @@ -226,7 +226,7 @@ reader(void *arg) if ((ret = session->open_cursor( session, s->name, NULL, NULL, &cursor)) != 0) testutil_die(ret, "session.open_cursor"); - for (i = 0; i < s->nops; ++i, ++s->reads, sched_yield()) + for (i = 0; i < s->nops; ++i, ++s->reads, __wt_yield()) reader_op(session, cursor, s); if ((ret = session->close(session, NULL)) != 0) testutil_die(ret, "session.close"); @@ -306,10 +306,10 @@ writer(void *arg) printf("write thread %2d starting: tid: %s, file: %s\n", id, tid, s->name); - sched_yield(); /* Get all the threads created. */ + __wt_yield(); /* Get all the threads created. */ if (session_per_op) { - for (i = 0; i < s->nops; ++i, sched_yield()) { + for (i = 0; i < s->nops; ++i, __wt_yield()) { if ((ret = conn->open_session( conn, NULL, NULL, &session)) != 0) testutil_die(ret, "conn.open_session"); @@ -327,7 +327,7 @@ writer(void *arg) if ((ret = session->open_cursor( session, s->name, NULL, NULL, &cursor)) != 0) testutil_die(ret, "session.open_cursor"); - for (i = 0; i < s->nops; ++i, sched_yield()) + for (i = 0; i < s->nops; ++i, __wt_yield()) writer_op(session, cursor, s); if ((ret = session->close(session, NULL)) != 0) testutil_die(ret, "session.close"); diff --git a/test/thread/stats.c b/test/thread/stats.c index 9ea8e6482cb..67a2c02719b 100644 --- a/test/thread/stats.c +++ b/test/thread/stats.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/thread/t.c b/test/thread/t.c index 71df65d8419..e72b54bf62a 100644 --- a/test/thread/t.c +++ b/test/thread/t.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/thread/thread.h b/test/thread/thread.h index bf2447573de..36cdbebd210 100644 --- a/test/thread/thread.h +++ b/test/thread/thread.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/utility/test_util.i b/test/utility/test_util.i index 00948e1f74a..73141bc9be7 100644 --- a/test/utility/test_util.i +++ b/test/utility/test_util.i @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. diff --git a/test/windows/windows_shim.c b/test/windows/windows_shim.c index a59060d56e8..6e8da8f86d4 100644 --- a/test/windows/windows_shim.c +++ b/test/windows/windows_shim.c @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -29,13 +29,6 @@ #include "windows_shim.h" int -sched_yield(void) -{ - (void)SwitchToThread(); - return (0); -} - -int sleep(int seconds) { Sleep(seconds * 1000); diff --git a/test/windows/windows_shim.h b/test/windows/windows_shim.h index c124cda6092..c35c27cb7b0 100644 --- a/test/windows/windows_shim.h +++ b/test/windows/windows_shim.h @@ -1,5 +1,5 @@ /*- - * Public Domain 2014-2015 MongoDB, Inc. + * Public Domain 2014-2016 MongoDB, Inc. * Public Domain 2008-2014 WiredTiger, Inc. * * This is free and unencumbered software released into the public domain. @@ -70,11 +70,6 @@ struct timeval { int gettimeofday(struct timeval* tp, void* tzp); /* - * Emulate <sched.h> - */ -int sched_yield(void); - -/* * Emulate <unistd.h> */ typedef uint32_t useconds_t; |