summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2012-05-02 11:19:26 +0000
committerKeith Bostic <keith@wiredtiger.com>2012-05-02 11:19:26 +0000
commitfc8ce08451624ba82f2e86263c44d981f26f602f (patch)
tree20b4b355ce7d5ff1176d34c02a567396b4a666cc /test
parent337934b72f7906a0051b5e3e59d9782519f5524d (diff)
downloadmongo-fc8ce08451624ba82f2e86263c44d981f26f602f.tar.gz
Fix a bug so checking the snapshots now works, add code to smoke-test
snapshot delete, and that an open cursor handle blocks snapshot delete.
Diffstat (limited to 'test')
-rw-r--r--test/snapshot/snapshot.c50
1 files changed, 46 insertions, 4 deletions
diff --git a/test/snapshot/snapshot.c b/test/snapshot/snapshot.c
index a2b31f04736..3b9e05bfb2b 100644
--- a/test/snapshot/snapshot.c
+++ b/test/snapshot/snapshot.c
@@ -40,6 +40,8 @@ struct L {
void add(int, int);
void build(void);
void check(struct L *);
+void cursor_lock(void);
+void drop(void);
void dump_cat(struct L *, const char *);
void dump_snap(struct L *, const char *);
void run(void);
@@ -89,6 +91,7 @@ usage(void)
void
run(void)
{
+ struct L *p;
char config[128];
/* Open the connection and create the file. */
@@ -100,11 +103,18 @@ run(void)
"internal_page_max=512,leaf_page_max=512");
assert(session->create(session, URI, config) == 0);
+ printf("building...\n");
build(); /* Build a set of snapshots */
-#if 0
+
+ printf("checking build...\n");
for (p = list; p->start != 0; ++p)
check(p); /* Check the contents */
-#endif
+
+ printf("checking cursor_lock...\n");
+ cursor_lock();
+
+ printf("checking delete...\n");
+ drop();
assert(conn->close(conn, 0) == 0);
}
@@ -124,7 +134,6 @@ build(void)
snprintf(buf, sizeof(buf), "snapshot=%s", p->name);
assert(session->sync(session, URI, buf) == 0);
-
assert(session->verify(session, URI, NULL) == 0);
}
}
@@ -198,7 +207,7 @@ dump_cat(struct L *snap, const char *f)
assert((fp = fopen(f, "w")) != NULL);
- for (p = list; p < snap; ++p) {
+ for (p = list; p <= snap; ++p) {
for (row = p->start; row < p->stop; ++row)
fprintf(fp,
"%010d KEY------\n%010d VALUE----\n", row, row);
@@ -235,3 +244,36 @@ dump_snap(struct L *snap, const char *f)
assert(cursor->close(cursor) == 0);
assert(fclose(fp) == 0);
}
+
+/*
+ * cursor_lock --
+ * Check that you can't drop a snapshot if it's in use.
+ */
+void
+cursor_lock(void)
+{
+ WT_CURSOR *cursor;
+ char buf[64];
+
+ snprintf(buf, sizeof(buf), "snapshot=%s", list[0].name);
+ assert(session->open_cursor(session, URI, NULL, buf, &cursor) == 0);
+ assert(session->drop(session, URI, buf) != 0);
+ assert(cursor->close(cursor) == 0);
+}
+
+/*
+ * drop --
+ * Delete a snapshot and verify the file.
+ */
+void
+drop(void)
+{
+ struct L *p;
+ char buf[64];
+
+ for (p = list; p->start != 0; ++p) {
+ snprintf(buf, sizeof(buf), "snapshot=%s", p->name);
+ assert(session->drop(session, URI, buf) == 0);
+ assert(session->verify(session, URI, NULL) == 0);
+ }
+}