Commit 41f1d7ab authored by Yoni Fogel's avatar Yoni Fogel

Addresses #2225 refs[t:2225] Make fileops unit tests (recovery) more comprehensive.

Add usage of table locking log entry

git-svn-id: file:///svn/toku/tokudb@16307 c7de825b-a66e-492c-adef-691d508d4ae1
parent af6f7057
...@@ -539,8 +539,14 @@ recovery_fileops_unit.tdbrun: recovery_fileops_unit.tdb$(BINSUF) $(PTHREAD_LOCAL ...@@ -539,8 +539,14 @@ recovery_fileops_unit.tdbrun: recovery_fileops_unit.tdb$(BINSUF) $(PTHREAD_LOCAL
for f in $$fset; do \ for f in $$fset; do \
for g in $$gset; do \ for g in $$gset; do \
for h in $$hset; do \ for h in $$hset; do \
errorfile=dir.$@.errors/crash.$$O.$$a.$$b.$$c.$$d.$$e.$$f.$$g.$$h; \ if test \( $$O != c \) -a \( $$c -eq 0 \) -a \( \( $$b -eq 0 \) -o \( $$e -eq 0 \) -o \( $$d -eq 1 \) \) ; then \
combination="-O $$O -A $$a -B $$b -C $$c -D $$d -E $$e -F $$f -G $$g -H $$"; \ iset="0 1"; \
else \
iset="0"; \
fi; \
for i in $$iset; do \
errorfile=dir.$@.errors/crash.$$O.$$a.$$b.$$c.$$d.$$e.$$f.$$g.$$h.$$i; \
combination="-O $$O -A $$a -B $$b -C $$c -D $$d -E $$e -F $$f -G $$g -H $$h -I $$i"; \
./$< $(VERBVERBOSE) -c $$combination 2> $$errorfile && { cat dir.$@.errors/crash; echo Error: no crash in $$errorfile ; exit 1; }; \ ./$< $(VERBVERBOSE) -c $$combination 2> $$errorfile && { cat dir.$@.errors/crash; echo Error: no crash in $$errorfile ; exit 1; }; \
grep 'HAPPY CRASH' $$errorfile >/dev/null || { cat $$errorfile; echo Error: incorrect crash in $$errorfile ; exit 1; }; \ grep 'HAPPY CRASH' $$errorfile >/dev/null || { cat $$errorfile; echo Error: incorrect crash in $$errorfile ; exit 1; }; \
./$< $(VERBVERBOSE) -r $$combination 2>> $$errorfile || { cat $$errorfile ; echo Error: during recovery in $$errorfile ; exit 1; }; \ ./$< $(VERBVERBOSE) -r $$combination 2>> $$errorfile || { cat $$errorfile ; echo Error: during recovery in $$errorfile ; exit 1; }; \
...@@ -554,6 +560,7 @@ recovery_fileops_unit.tdbrun: recovery_fileops_unit.tdb$(BINSUF) $(PTHREAD_LOCAL ...@@ -554,6 +560,7 @@ recovery_fileops_unit.tdbrun: recovery_fileops_unit.tdb$(BINSUF) $(PTHREAD_LOCAL
done; \ done; \
done; \ done; \
done; \ done; \
done; \
echo $$count tests passed; \ echo $$count tests passed; \
) $(SUMMARIZE_CMD) ) $(SUMMARIZE_CMD)
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
static int do_recover; static int do_recover;
static int do_crash; static int do_crash;
static char fileop; static char fileop;
static int choices['H'-'A'+1]; static int choices['I'-'A'+1];
const int num_choices = sizeof(choices)/sizeof(choices[0]); const int num_choices = sizeof(choices)/sizeof(choices[0]);
static DB_TXN *txn; static DB_TXN *txn;
const char *oldname = "oldfoo"; const char *oldname = "oldfoo";
...@@ -21,24 +21,25 @@ DB *db; ...@@ -21,24 +21,25 @@ DB *db;
static int crash_during_checkpoint; static int crash_during_checkpoint;
static char *cmd; static char *cmd;
#define usage() assert(FALSE)
#if 0
static void static void
usage(void) { usage(void) {
fprintf(stderr, "Usage:\n%s [-v|-q]* [-h] (-c|-r) -O fileop -A# -B# -C# -D# -E# [-F# -G#]\n" fprintf(stderr, "Usage:\n%s [-v|-q]* [-h] (-c|-r) -O fileop -A# -B# -C# -D# -E# -F# [-G# -H# -I#]\n"
" fileop = c/r/d (create/rename/delete)\n" " fileop = c/r/d (create/rename/delete)\n"
" Where # is a single digit number > 0.\n" " Where # is a single digit number > 0.\n"
" A-F are required for fileop=create\n" " A-F are required for fileop=create\n"
" A-H are required for fileop=delete, fileop=rename\n", cmd); " A-I are required for fileop=delete, fileop=rename\n", cmd);
exit(1); exit(1);
} }
#endif
enum { CLOSE_TXN_COMMIT, CLOSE_TXN_ABORT, CLOSE_TXN_NONE }; enum { CLOSE_TXN_COMMIT, CLOSE_TXN_ABORT, CLOSE_TXN_NONE };
enum {CREATE_CREATE, CREATE_CHECKPOINT, CREATE_COMMIT_NEW, enum {CREATE_CREATE, CREATE_CHECKPOINT, CREATE_COMMIT_NEW,
CREATE_COMMIT_NEW_CHECKPOINT, CREATE_COMMIT_CHECKPOINT_NEW, CREATE_COMMIT_NEW_CHECKPOINT, CREATE_COMMIT_CHECKPOINT_NEW,
CREATE_CHECKPOINT_COMMIT_NEW}; CREATE_CHECKPOINT_COMMIT_NEW};
static int fileop_did_commit(void);
static void close_txn(int type);
static int static int
get_x_choice(char c, int possibilities) { get_x_choice(char c, int possibilities) {
assert(c < 'A' + num_choices); assert(c < 'A' + num_choices);
...@@ -103,6 +104,14 @@ get_choice_txn_does_open_close_before_fileop(void) { ...@@ -103,6 +104,14 @@ get_choice_txn_does_open_close_before_fileop(void) {
return get_bool_choice('H'); return get_bool_choice('H');
} }
static int
get_choice_lock_table_split_fcreate(void) {
int choice = get_bool_choice('I');
if (choice)
assert(fileop_did_commit());
return choice;
}
static void static void
do_args(int argc, char *argv[]) { do_args(int argc, char *argv[]) {
cmd = argv[0]; cmd = argv[0];
...@@ -113,7 +122,7 @@ do_args(int argc, char *argv[]) { ...@@ -113,7 +122,7 @@ do_args(int argc, char *argv[]) {
} }
char c; char c;
while ((c = getopt(argc, argv, "vqhcrO:A:B:C:D:E:F:G:H:")) != -1) { while ((c = getopt(argc, argv, "vqhcrO:A:B:C:D:E:F:G:H:I:")) != -1) {
switch(c) { switch(c) {
case 'v': case 'v':
verbose++; verbose++;
...@@ -154,6 +163,7 @@ do_args(int argc, char *argv[]) { ...@@ -154,6 +163,7 @@ do_args(int argc, char *argv[]) {
case 'F': case 'F':
case 'G': case 'G':
case 'H': case 'H':
case 'I':
if (fileop == '\0') if (fileop == '\0')
usage(); usage();
int num = atoi(optarg); int num = atoi(optarg);
...@@ -247,6 +257,7 @@ maybe_make_oldest_living_txn(void) { ...@@ -247,6 +257,7 @@ maybe_make_oldest_living_txn(void) {
static void static void
make_txn(void) { make_txn(void) {
int r; int r;
assert(!txn);
r = env->txn_begin(env, NULL, &txn, 0); r = env->txn_begin(env, NULL, &txn, 0);
CKERR(r); CKERR(r);
} }
...@@ -258,6 +269,20 @@ fcreate(void) { ...@@ -258,6 +269,20 @@ fcreate(void) {
CKERR(r); CKERR(r);
r = db->open(db, txn, oldname, NULL, DB_BTREE, DB_CREATE|DB_EXCL, 0666); r = db->open(db, txn, oldname, NULL, DB_BTREE, DB_CREATE|DB_EXCL, 0666);
CKERR(r); CKERR(r);
if (fileop!='c' && get_choice_lock_table_split_fcreate()) {
r = db->close(db, 0);
CKERR(r);
close_txn(CLOSE_TXN_COMMIT);
make_txn();
r = db_create(&db, env, 0);
CKERR(r);
r = db->open(db, txn, oldname, NULL, DB_BTREE, 0, 0666);
CKERR(r);
r = db->pre_acquire_table_lock(db, txn);
CKERR(r);
}
DBT key, val; DBT key, val;
dbt_init(&key, choices, sizeof(choices)); dbt_init(&key, choices, sizeof(choices));
dbt_init(&val, NULL, 0); dbt_init(&val, NULL, 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