diff options
author | Keith Bostic <keith@wiredtiger.com> | 2016-04-14 12:30:34 -0400 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2016-04-14 12:30:34 -0400 |
commit | f9a525e49351b68f77d416fc68a08d1a1487676b (patch) | |
tree | 0c069413a2a495d98b2eba3549cbc1b86fb18bdc /test | |
parent | 9eacbca4f94881658b5bd043446277db15f36e28 (diff) | |
download | mongo-f9a525e49351b68f77d416fc68a08d1a1487676b.tar.gz |
WT-2103: add incremental backup testing to format
Add support for doing incremental backups.
Diffstat (limited to 'test')
-rw-r--r-- | test/format/backup.c | 55 | ||||
-rw-r--r-- | test/format/format.h | 4 | ||||
-rw-r--r-- | test/format/salvage.c | 4 | ||||
-rw-r--r-- | test/format/t.c | 4 | ||||
-rw-r--r-- | test/format/wts.c | 13 |
5 files changed, 52 insertions, 28 deletions
diff --git a/test/format/backup.c b/test/format/backup.c index 4ab60d37122..837ff27c670 100644 --- a/test/format/backup.c +++ b/test/format/backup.c @@ -38,7 +38,7 @@ check_copy(void) WT_CONNECTION *conn; WT_SESSION *session; - wts_open(g.home_backup, 0, &conn); + wts_open(g.home_backup, false, &conn); testutil_checkfmt( conn->open_session(conn, NULL, NULL, &session), @@ -90,8 +90,9 @@ backup(void *arg) WT_CURSOR *backup_cursor; WT_DECL_RET; WT_SESSION *session; - u_int period; - const char *key; + u_int incremental, period; + bool full; + const char *config, *key; (void)(arg); @@ -105,10 +106,12 @@ backup(void *arg) testutil_check(conn->open_session(conn, NULL, NULL, &session)); /* - * Perform a backup at somewhere under 10 seconds (so we get at - * least one done), and then at 45 second intervals. + * Perform a full backup at somewhere under 10 seconds (that way there's + * at least one), then at larger intervals, optionally do incremental + * backups between full backups. */ - for (period = mmrand(NULL, 1, 10);; period = mmrand(NULL, 30, 45)) { + incremental = 0; + for (period = mmrand(NULL, 1, 10);; period = mmrand(NULL, 20, 45)) { /* Sleep for short periods so we don't make the run wait. */ while (period > 0 && !g.workers_finished) { --period; @@ -122,18 +125,26 @@ backup(void *arg) break; } - /* Re-create the backup directory. */ - testutil_checkfmt( - system(g.home_backup_init), - "%s", "backup directory creation failed"); + if (incremental) { + config = "target=(\"log:\")"; + full = false; + } else { + /* Re-create the backup directory. */ + testutil_checkfmt( + system(g.home_backup_init), + "%s", "backup directory creation failed"); + + config = NULL; + full = true; + } /* - * open_cursor can return EBUSY if a metadata operation is - * currently happening - retry in that case. + * open_cursor can return EBUSY if concurrent with a metadata + * operation, retry in that case. */ - while ((ret = session->open_cursor(session, - "backup:", NULL, NULL, &backup_cursor)) == EBUSY) - sleep(1); + while ((ret = session->open_cursor( + session, "backup:", NULL, config, &backup_cursor)) == EBUSY) + __wt_yield(); if (ret != 0) testutil_die(ret, "session.open_cursor: backup"); @@ -148,9 +159,21 @@ backup(void *arg) testutil_check(backup_cursor->close(backup_cursor)); testutil_check(pthread_rwlock_unlock(&g.backup_lock)); - check_copy(); + /* + * Do some incremental backups after each full backup. If we're + * not doing any more incrementals, verify the backup (we can't + * verify intermediate states, once we verify, we can't do any + * more incremental backups. + */ + if (full) + incremental = mmrand(NULL, 1, 5); + if (--incremental == 0) + check_copy(); } + if (incremental != 0) + check_copy(); + testutil_check(session->close(session, NULL)); return (NULL); diff --git a/test/format/format.h b/test/format/format.h index 55ee8034cca..0d5201309b2 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -324,10 +324,10 @@ void track(const char *, uint64_t, TINFO *); void val_gen(WT_RAND_STATE *, WT_ITEM *, uint64_t); void val_gen_setup(WT_RAND_STATE *, WT_ITEM *); void wts_close(void); -void wts_create(void); void wts_dump(const char *, int); +void wts_init(void); void wts_load(void); -void wts_open(const char *, int, WT_CONNECTION **); +void wts_open(const char *, bool, WT_CONNECTION **); void wts_ops(int); void wts_read_scan(void); void wts_rebalance(void); diff --git a/test/format/salvage.c b/test/format/salvage.c index b2a38e37c8b..8274c556364 100644 --- a/test/format/salvage.c +++ b/test/format/salvage.c @@ -158,7 +158,7 @@ wts_salvage(void) testutil_die(ret, "salvage copy step failed"); /* Salvage, then verify. */ - wts_open(g.home, 1, &g.wts_conn); + wts_open(g.home, true, &g.wts_conn); salvage(); wts_verify("post-salvage verify"); wts_close(); @@ -174,7 +174,7 @@ wts_salvage(void) /* Corrupt the file randomly, salvage, then verify. */ if (corrupt()) { - wts_open(g.home, 1, &g.wts_conn); + wts_open(g.home, true, &g.wts_conn); salvage(); wts_verify("post-corrupt-salvage verify"); wts_close(); diff --git a/test/format/t.c b/test/format/t.c index f991e49a9b0..b4f0fffda54 100644 --- a/test/format/t.c +++ b/test/format/t.c @@ -198,8 +198,8 @@ main(int argc, char *argv[]) if (SINGLETHREADED) bdb_open(); /* Initial file config */ #endif - wts_open(g.home, 1, &g.wts_conn); - wts_create(); + wts_open(g.home, true, &g.wts_conn); + wts_init(); wts_load(); /* Load initial records */ wts_verify("post-bulk verify"); /* Verify */ diff --git a/test/format/wts.c b/test/format/wts.c index 7b114edec1e..2ee01aa75b5 100644 --- a/test/format/wts.c +++ b/test/format/wts.c @@ -126,7 +126,7 @@ static WT_EVENT_HANDLER event_handler = { * Open a connection to a WiredTiger database. */ void -wts_open(const char *home, int set_api, WT_CONNECTION **connp) +wts_open(const char *home, bool set_api, WT_CONNECTION **connp) { WT_CONNECTION *conn; WT_DECL_RET; @@ -138,10 +138,11 @@ wts_open(const char *home, int set_api, WT_CONNECTION **connp) end = config + sizeof(g.wiredtiger_open_config); p += snprintf(p, REMAIN(p, end), - "create,checkpoint_sync=false,cache_size=%" PRIu32 "MB", - g.c_cache); - - p += snprintf(p, REMAIN(p, end), ",error_prefix=\"%s\"", g.progname); + "create=true," + "cache_size=%" PRIu32 "MB," + "checkpoint_sync=false," + "error_prefix=\"%s\"", + g.c_cache, g.progname); /* In-memory configuration. */ if (g.c_in_memory != 0) @@ -287,7 +288,7 @@ wts_reopen(void) * Create the underlying store. */ void -wts_create(void) +wts_init(void) { WT_CONNECTION *conn; WT_SESSION *session; |