Commit 1edd94cd authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

refs #5469, expand test to include abort of transaction taht did the puts

git-svn-id: file:///svn/toku/tokudb@47798 c7de825b-a66e-492c-adef-691d508d4ae1
parent 10b3b236
...@@ -21,7 +21,7 @@ static int put_multiple_generate(DB *UU(dest_db), DB *UU(src_db), DBT *dest_key, ...@@ -21,7 +21,7 @@ static int put_multiple_generate(DB *UU(dest_db), DB *UU(src_db), DBT *dest_key,
} }
static void static void
test_loader_abort (bool use_puts, bool abort_loader) { test_loader_abort (bool use_puts, bool abort_loader, bool abort_txn) {
DB_ENV * env; DB_ENV * env;
DB *db; DB *db;
DB_TXN *txn; DB_TXN *txn;
...@@ -77,15 +77,22 @@ test_loader_abort (bool use_puts, bool abort_loader) { ...@@ -77,15 +77,22 @@ test_loader_abort (bool use_puts, bool abort_loader) {
k = num_elements; k = num_elements;
v = num_elements; v = num_elements;
r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0); r = db->put(db, txn, dbt_init(&key, &k, sizeof k), dbt_init(&val, &v, sizeof v), 0);
if (abort_txn) {
r = txn->abort(txn);
CKERR(r);
}
else {
r = txn->commit(txn, 0); r = txn->commit(txn, 0);
CKERR(r); CKERR(r);
}
r = env->txn_begin(env, NULL, &txn, 0); r = env->txn_begin(env, NULL, &txn, 0);
CKERR(r); CKERR(r);
r = db->cursor(db, txn, &cursor, 0); assert(r == 0); r = db->cursor(db, txn, &cursor, 0); assert(r == 0);
DBT k1; memset(&k1, 0, sizeof k1); DBT k1; memset(&k1, 0, sizeof k1);
DBT v1; memset(&v1, 0, sizeof v1); DBT v1; memset(&v1, 0, sizeof v1);
if (!abort_txn) {
if (!abort_loader) { if (!abort_loader) {
for (uint32_t i = 0; i < num_elements; i++) { for (uint32_t i = 0; i < num_elements; i++) {
r = cursor->c_get(cursor, &k1, &v1, DB_NEXT); assert(r == 0); r = cursor->c_get(cursor, &k1, &v1, DB_NEXT); assert(r == 0);
...@@ -100,6 +107,7 @@ test_loader_abort (bool use_puts, bool abort_loader) { ...@@ -100,6 +107,7 @@ test_loader_abort (bool use_puts, bool abort_loader) {
assert(v1.size == sizeof(uint32_t)); assert(v1.size == sizeof(uint32_t));
assert(*(uint32_t *)k1.data == num_elements); assert(*(uint32_t *)k1.data == num_elements);
assert(*(uint32_t *)v1.data == num_elements); assert(*(uint32_t *)v1.data == num_elements);
}
r = cursor->c_get(cursor, &k1, &v1, DB_NEXT); assert(r == DB_NOTFOUND); r = cursor->c_get(cursor, &k1, &v1, DB_NEXT); assert(r == DB_NOTFOUND);
r = cursor->c_close(cursor); assert(r == 0); r = cursor->c_close(cursor); assert(r == 0);
...@@ -113,9 +121,13 @@ test_loader_abort (bool use_puts, bool abort_loader) { ...@@ -113,9 +121,13 @@ test_loader_abort (bool use_puts, bool abort_loader) {
int int
test_main(int argc, char *const argv[]) { test_main(int argc, char *const argv[]) {
parse_args(argc, argv); parse_args(argc, argv);
test_loader_abort(false, false); test_loader_abort(false, false, true);
test_loader_abort(false, true); test_loader_abort(false, true, true);
test_loader_abort(true, false); test_loader_abort(true, false, true);
test_loader_abort(true, true); test_loader_abort(true, true, true);
test_loader_abort(false, false, false);
test_loader_abort(false, true, false);
test_loader_abort(true, false, false);
test_loader_abort(true, true, false);
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment