diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-06-03 14:19:03 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2014-06-03 14:19:03 +1000 |
commit | 15b32aec97d444ec0b16bde452b5a3f6d7ab927a (patch) | |
tree | 4ef5092de1addf316c55cf344e6fc5e27c715775 /test | |
parent | 23077e4c98473569996071a61c979f09f68fcd80 (diff) | |
download | mongo-15b32aec97d444ec0b16bde452b5a3f6d7ab927a.tar.gz |
Exercise all isolation levels in test/format.
motivated by reviewing #1040
Diffstat (limited to 'test')
-rw-r--r-- | test/format/config.c | 34 | ||||
-rw-r--r-- | test/format/config.h | 4 | ||||
-rw-r--r-- | test/format/format.h | 1 | ||||
-rw-r--r-- | test/format/ops.c | 8 |
4 files changed, 44 insertions, 3 deletions
diff --git a/test/format/config.c b/test/format/config.c index c28d2785e9d..46ca80a9173 100644 --- a/test/format/config.c +++ b/test/format/config.c @@ -33,6 +33,7 @@ static void config_compression(void); static const char *config_file_type(u_int); static CONFIG *config_find(const char *, size_t); static int config_find_is_perm(const char *, size_t); +static void config_isolation(void); static void config_map_checksum(const char *, u_int *); static void config_map_compression(const char *, u_int *); static void config_map_file_type(const char *, u_int *); @@ -137,6 +138,7 @@ config_setup(void) config_checksum(); config_compression(); + config_isolation(); /* Clear operations values if the whole run is read-only. */ if (g.c_ops == 0) @@ -285,6 +287,34 @@ config_compression(void) } /* + * config_isolation -- + * Isolation configuration. + */ +static void +config_isolation(void) +{ + CONFIG *cp; + const char *cstr; + + /* + * Isolation: choose something if isolation wasn't specified. + */ + cp = config_find("isolation", strlen("isolation")); + if (!(cp->flags & C_PERM)) { + switch (MMRAND(1, 3)) { + case 1: + cstr = "isolation=read-uncommitted"; + case 2: + cstr = "isolation=read-committed"; + case 3: + cstr = "isolation=snapshot"; + break; + } + config_single(cstr, 0); + } +} + +/* * config_error -- * Display configuration information on error. */ @@ -428,6 +458,10 @@ config_single(const char *s, int perm) s, "compression", strlen("compression")) == 0) { config_map_compression(ep, &g.c_compression_flag); *cp->vstr = strdup(ep); + } else if (strncmp(s, "isolation", strlen("isolation")) == 0) { + *cp->vstr = + malloc(strlen("isolation=") + strlen(ep) + 1); + sprintf(*cp->vstr, "isolation=%s", ep); } else if (strncmp(s, "file_type", strlen("file_type")) == 0) { config_map_file_type(ep, &g.type); *cp->vstr = strdup(config_file_type(g.type)); diff --git a/test/format/config.h b/test/format/config.h index 64f739372d8..fe94ba3b696 100644 --- a/test/format/config.h +++ b/test/format/config.h @@ -167,6 +167,10 @@ static CONFIG c[] = { "maximum size of Btree internal nodes", 0x0, 0x0, 9, 17, 27, &g.c_intl_page_max, NULL }, + { "isolation", + "isolation level (read-uncommitted | read-committed | snapshot)", + 0x0, C_IGNORE|C_STRING, 1, 3, 3, NULL, &g.c_isolation }, + { "key_gap", "gap between instantiated keys on a Btree page", 0x0, 0x0, 0, 20, 20, &g.c_key_gap, NULL }, diff --git a/test/format/format.h b/test/format/format.h index 93e0d1e45db..b339cb9a938 100644 --- a/test/format/format.h +++ b/test/format/format.h @@ -164,6 +164,7 @@ typedef struct { uint32_t c_insert_pct; uint32_t c_internal_key_truncation; uint32_t c_intl_page_max; + char *c_isolation; uint32_t c_key_gap; uint32_t c_key_max; uint32_t c_key_min; diff --git a/test/format/ops.c b/test/format/ops.c index 4035ccf716a..eec599e3670 100644 --- a/test/format/ops.c +++ b/test/format/ops.c @@ -68,7 +68,8 @@ wts_ops(void) /* Open a session. */ if (g.logging != 0) { - if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + if ((ret = conn->open_session( + conn, NULL, g.c_isolation, &session)) != 0) die(ret, "connection.open_session"); (void)g.wt_api->msg_printf(g.wt_api, session, "=============== thread ops start ==============="); @@ -218,7 +219,7 @@ ops(void *arg) die(ret, "session.close"); if ((ret = conn->open_session( - conn, NULL, NULL, &session)) != 0) + conn, NULL, g.c_isolation, &session)) != 0) die(ret, "connection.open_session"); /* @@ -464,7 +465,8 @@ wts_read_scan(void) key_gen_setup(&keybuf); /* Open a session and cursor pair. */ - if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + if ((ret = conn->open_session( + conn, NULL, g.c_isolation, &session)) != 0) die(ret, "connection.open_session"); if ((ret = session->open_cursor( session, g.uri, NULL, NULL, &cursor)) != 0) |