Commit 7c1150b9 authored by Yoni Fogel's avatar Yoni Fogel

Addresses #2037 refs[t:2037] Added comments on transactional fileops tests,...

Addresses #2037 refs[t:2037] Added comments on transactional fileops tests, minor changes from code review.

git-svn-id: file:///svn/toku/tokudb.2037b@15657 c7de825b-a66e-492c-adef-691d508d4ae1
parent d817c605
......@@ -73,7 +73,7 @@ print_engine_status(DB_ENV * UU(env)) {
char buff[buffsize];
env->get_engine_status_text(env, buff, buffsize);
printf("Engine status:\n");
printf(buff);
printf("%s", buff);
}
#endif
}
......
......@@ -5,15 +5,70 @@
/* Purpose of this test is to verify correct behavior of transactional file
* operations. File operations to be tested (and expected results) are:
* - open (dictionary is closed when transaction is complete)
* - open
* - create (dictionary is created only if transaction is committed)
* - rename (dictionary is renamed only if transaction is committed)
* - delete (dictionary is deleted only if transaction is committed)
*
*
* TODO:
* - verify that commit() will close an open db (is this necessary?)
* - verify correct behavior with "subdb" names (e.g. foo/bar)
* - Yoni Notes
* - Directory based stuff (lock types?)
* - Done:
* - Create commit
* - verify before operation, after operation, and after commit
* - Create abort
* - verify before operation, after operation, and after abort
* - Remove commit
* - verify before operation, after operation, and after commit
* - Remove abort
* - verify before operation, after operation, and after abort
* - Rename commit
* - verify before operation, after operation, and after commit
* - Rename abort
* - verify before operation, after operation, and after abort
* - Open commit
* - verify before operation, after operation, and after commit
* - Open abort
* - verify before operation, after operation, and after abort
* - Maybe have tests for:
* - Create EXCL
* - Create failed lock
* - Due to another txn 'dbremove' but didn't commit yet
* - Open failed lock
* - Due to other txn 'creating' but didn't yet commit
* - Remove (oldname) failed lock
* - Some other txn renamed (oldname->newname)
* - Rename (oldname->newname) failed lock
* - Some other txn renamed (foo->oldname)
* - Rename (oldname->newname) failed lock
* - Some other txn renamed (newname->foo)
*
* - Remove fail on open db EINVAL
* - Rename fail on open (oldname) db EINVAL
* - Rename fail on open (newname) db EINVAL
*
* - Remove fail on non-existant ENOENT
* - Rename fail on non-existant oldname db ENOENT
*
* - Rename fail on not open but existant newname db EEXIST
*
* - In one txn:
* - Rename a->b
* - create a
* - In one txn: (Truncate table foo)
* - 'x' was in a from prev transaction
* - Remove a
* - Create a
* - insert 'y' into a.
* - commit: a has 'y' but not 'x'
* - abort: a has 'x' but not 'y'
* - In one txn:
* - Create a
* - remove a
* - create a
* - remove a...
*
*
* overview:
......@@ -104,15 +159,16 @@ create_abc(void) {
r=db_create(&db_b, env, 0); CKERR(r);
r=db_create(&db_c, env, 0); CKERR(r);
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, DB_CREATE, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, DB_CREATE, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, DB_CREATE, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_a->close(db_a, 0); CKERR(r);
r=db_b->close(db_b, 0); CKERR(r);
r=db_c->close(db_c, 0); CKERR(r);
r=txn->commit(txn, 0); CKERR(r);
r=db_c->close(db_c, 0); CKERR(r); //Should work whether close is before or after commit. Do one after.
}
......@@ -130,8 +186,8 @@ perform_ops(DB_TXN * txn) {
r = env->dbrename(env, txn, "c.db", NULL, "c2.db", 0); CKERR(r);
r=db_create(&db_x, env, 0); CKERR(r);
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_x->close(db_x, 0); CKERR(r); // commit will close but abort requires db be closed first
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, DB_CREATE, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_x->close(db_x, 0); CKERR(r); // abort requires db be closed first
}
......@@ -156,13 +212,13 @@ verify_abc(void) {
r=db_create(&db_c2, env, 0); CKERR(r);
// should exist:
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
// should not exist:
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR2(r, ENOENT);
r=db_c2->open(db_c2, txn, "c2.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR2(r, ENOENT);
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR2(r, ENOENT);
r=db_c2->open(db_c2, txn, "c2.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR2(r, ENOENT);
r=db_a->close(db_a, 0); CKERR(r);
r=db_b->close(db_b, 0); CKERR(r);
......@@ -197,13 +253,13 @@ verify_ac2x(DB_TXN * parent_txn) {
r=db_create(&db_c2, env, 0); CKERR(r);
// should exist:
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_c2->open(db_c2, txn, "c2.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r);
r=db_a->open(db_a, txn, "a.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_c2->open(db_c2, txn, "c2.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
r=db_x->open(db_x, txn, "x.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR(r);
// should not exist:
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR2(r, ENOENT);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, 0, S_IRWXU+S_IRWXG+S_IRWXO); CKERR2(r, ENOENT);
r=db_b->open(db_b, txn, "b.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR2(r, ENOENT);
r=db_c->open(db_c, txn, "c.db", 0, DB_BTREE, 0, S_IRWXU|S_IRWXG|S_IRWXO); CKERR2(r, ENOENT);
r=db_a->close(db_a, 0); CKERR(r);
r=db_b->close(db_b, 0); CKERR(r);
......@@ -233,6 +289,7 @@ test_fileops(void) {
r=env->txn_begin(env, 0, &txn, 0); CKERR(r);
perform_ops(txn);
verify_ac2x(txn); // verify that operations appear effective within this txn
r=txn->commit(txn, 0); CKERR(r);
// verify that committed transaction actually changed db
......
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