diff options
author | Keith Bostic <keith@wiredtiger.com> | 2014-11-21 21:26:10 -0500 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2014-11-21 21:26:10 -0500 |
commit | 47a3bd9bdfa84690fe8256ffff5d8a94b0b6aa8b (patch) | |
tree | f19d58a06d1aba494da4f84d2dc7734f03cbd0df /test/fops | |
parent | ef68e3e50b40657a779c85f7465ebaf9933d7c81 (diff) | |
download | mongo-47a3bd9bdfa84690fe8256ffff5d8a94b0b6aa8b.tar.gz |
Add tests for creating bulk and non-bulk items that we know will succeed;
I did this change to test for #1397, but it's a reasonable way to do more
testing in fops.
Diffstat (limited to 'test/fops')
-rw-r--r-- | test/fops/file.c | 71 | ||||
-rw-r--r-- | test/fops/fops.c | 19 | ||||
-rw-r--r-- | test/fops/t.c | 14 | ||||
-rw-r--r-- | test/fops/thread.h | 4 |
4 files changed, 97 insertions, 11 deletions
diff --git a/test/fops/file.c b/test/fops/file.c index 49b8c1c4a87..1f8a084c404 100644 --- a/test/fops/file.c +++ b/test/fops/file.c @@ -27,6 +27,8 @@ #include "thread.h" +static u_int uid = 1; + void obj_bulk(void) { @@ -42,10 +44,9 @@ obj_bulk(void) die(ret, "session.create"); if (ret == 0) { + sched_yield(); if ((ret = session->open_cursor( session, uri, NULL, "bulk", &c)) == 0) { - /* Yield so that other threads can interfere. */ - sched_yield(); if ((ret = c->close(c)) != 0) die(ret, "cursor.close"); } else if (ret != ENOENT && ret != EBUSY && ret != EINVAL) @@ -56,6 +57,43 @@ obj_bulk(void) } void +obj_bulk_unique(void) +{ + WT_CURSOR *c; + WT_SESSION *session; + int ret; + char new_uri[64]; + + if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + die(ret, "conn.session"); + + /* Generate a unique object name. */ + if ((ret = pthread_rwlock_wrlock(&single)) != 0) + die(ret, "pthread_rwlock_wrlock single"); + (void)snprintf(new_uri, sizeof(new_uri), "%s.%u", uri, ++uid); + if ((ret = pthread_rwlock_unlock(&single)) != 0) + die(ret, "pthread_rwlock_unlock single"); + + if ((ret = session->create(session, new_uri, config)) != 0) + die(ret, "session.create: %s", new_uri); + + sched_yield(); + if ((ret = + session->open_cursor(session, new_uri, NULL, "bulk", &c)) != 0) + die(ret, "session.open_cursor: %s", new_uri); + + if ((ret = c->close(c)) != 0) + die(ret, "cursor.close"); + + while ((ret = session->drop(session, new_uri, NULL)) != 0) + if (ret != EBUSY) + die(ret, "session.drop: %s", new_uri); + + if ((ret = session->close(session, NULL)) != 0) + die(ret, "session.close"); +} + +void obj_cursor(void) { WT_SESSION *session; @@ -95,6 +133,35 @@ obj_create(void) } void +obj_create_unique(void) +{ + WT_SESSION *session; + int ret; + char new_uri[64]; + + if ((ret = conn->open_session(conn, NULL, NULL, &session)) != 0) + die(ret, "conn.session"); + + /* Generate a unique object name. */ + if ((ret = pthread_rwlock_wrlock(&single)) != 0) + die(ret, "pthread_rwlock_wrlock single"); + (void)snprintf(new_uri, sizeof(new_uri), "%s.%d", uri, ++uid); + if ((ret = pthread_rwlock_unlock(&single)) != 0) + die(ret, "pthread_rwlock_unlock single"); + + if ((ret = session->create(session, new_uri, config)) != 0) + die(ret, "session.create"); + + sched_yield(); + while ((ret = session->drop(session, new_uri, NULL)) != 0) + if (ret != EBUSY) + die(ret, "session.drop: %s", new_uri); + + if ((ret = session->close(session, NULL)) != 0) + die(ret, "session.close"); +} + +void obj_drop(void) { WT_SESSION *session; diff --git a/test/fops/fops.c b/test/fops/fops.c index 6dc3904fb2f..0a5cce87ea3 100644 --- a/test/fops/fops.c +++ b/test/fops/fops.c @@ -32,8 +32,10 @@ static void print_stats(u_int); typedef struct { int bulk; /* bulk load */ + int bulk_unique; /* bulk load of new file */ int ckpt; /* session.checkpoint */ int create; /* session.create */ + int create_unique; /* session.create of new file */ int cursor; /* session.open_cursor */ int drop; /* session.drop */ int upgrade; /* session.upgrade */ @@ -117,16 +119,16 @@ static void * fop(void *arg) { STATS *s; + uintptr_t id; u_int i; - int id; - id = (int)(uintptr_t)arg; + id = (uintptr_t)arg; sched_yield(); /* Get all the threads created. */ s = &run_stats[id]; for (i = 0; i < nops; ++i, sched_yield()) - switch (r() % 7) { + switch (r() % 9) { case 0: ++s->bulk; obj_bulk(); @@ -155,6 +157,14 @@ fop(void *arg) ++s->verify; obj_verify(); break; + case 7: + ++s->bulk_unique; + obj_bulk_unique(); + break; + case 8: + ++s->create_unique; + obj_create_unique(); + break; } return (NULL); @@ -175,6 +185,7 @@ print_stats(u_int nthreads) printf( "%2d: bulk %3d, ckpt %3d, create %3d, cursor %3d, " "drop %3d, upg %3d, vrfy %3d\n", - id, s->bulk, s->ckpt, s->create, s->cursor, + id, s->bulk + s->bulk_unique, s->ckpt, + s->create + s->create_unique, s->cursor, s->drop, s->upgrade, s->verify); } diff --git a/test/fops/t.c b/test/fops/t.c index edce91c6d09..769d3562f0f 100644 --- a/test/fops/t.c +++ b/test/fops/t.c @@ -28,6 +28,7 @@ #include "thread.h" WT_CONNECTION *conn; /* WiredTiger connection */ +pthread_rwlock_t single; /* Single thread */ u_int nops; /* Operations */ const char *uri; /* Object */ const char *config; /* Object config */ @@ -55,16 +56,16 @@ main(int argc, char *argv[]) const char *desc; const char *config; } *cp, configs[] = { - { "file:__wt", NULL, NULL }, - { "table:__wt", NULL, NULL }, + { "file:wt", NULL, NULL }, + { "table:wt", NULL, NULL }, /* Configure for a modest cache size. */ #define LSM_CONFIG "lsm=(chunk_size=1m,merge_max=2),leaf_page_max=4k" - { "lsm:__wt", NULL, LSM_CONFIG }, - { "table:__wt", " [lsm]", "type=lsm," LSM_CONFIG }, + { "lsm:wt", NULL, LSM_CONFIG }, + { "table:wt", " [lsm]", "type=lsm," LSM_CONFIG }, { NULL, NULL, NULL } }; u_int nthreads; - int ch, cnt, runs; + int ch, cnt, ret, runs; char *config_open; if ((progname = strrchr(argv[0], '/')) == NULL) @@ -72,6 +73,9 @@ main(int argc, char *argv[]) else ++progname; + if ((ret = pthread_rwlock_init(&single, NULL)) != 0) + die(ret, "pthread_rwlock_init: single"); + config_open = NULL; nops = 1000; nthreads = 10; diff --git a/test/fops/thread.h b/test/fops/thread.h index 3e3e683740f..ccd3c84150c 100644 --- a/test/fops/thread.h +++ b/test/fops/thread.h @@ -46,10 +46,14 @@ extern u_int nops; /* Operations per thread */ extern const char *uri; /* Object */ extern const char *config; /* Object config */ +extern pthread_rwlock_t single; /* Single-thread */ + int fop_start(u_int); void obj_bulk(void); +void obj_bulk_unique(void); void obj_checkpoint(void); void obj_create(void); +void obj_create_unique(void); void obj_cursor(void); void obj_drop(void); void obj_upgrade(void); |