Commit dbdbeff1 authored by Yoni Fogel's avatar Yoni Fogel

Add scribble, sleep.


git-svn-id: file:///svn/toku/tokudb@11494 c7de825b-a66e-492c-adef-691d508d4ae1
parent 2e3262a9
...@@ -14,8 +14,8 @@ TODO: This test is not yet complete ...@@ -14,8 +14,8 @@ TODO: This test is not yet complete
- write scribble_n function to scribble over expected data (and maybe do some random inserts?) - write scribble_n function to scribble over expected data (and maybe do some random inserts?)
- create separate thread to do scribbling - create separate thread to do scribbling
- have drop_dead function sleep a random time (0.1 to 5 seconds?) before sigsegv - have drop_dead function sleep a random time (0.1 to 5 seconds?) before sigsegv
- find some way to force disk I/O
- operate on multiple dictionaries - find some way to force disk I/O (Make cachetable very small)
...@@ -49,6 +49,32 @@ Each iteration does: ...@@ -49,6 +49,32 @@ Each iteration does:
#define NUM_DICTIONARIES 5 #define NUM_DICTIONARIES 5
const int oper_per_iter = 5001; // nice odd number (not a multiple of a power of two)
static void UU()
scribble(DB* db, int iter) {
int64_t firstkey; // first key to verify/insert
int64_t numkeys; // number of keys to verify/insert
if (iter > 0){
if (iter == 1) {
firstkey = 0;
numkeys = oper_per_iter;
}
else {
firstkey = (iter - 2) * oper_per_iter;
numkeys = oper_per_iter * 2;
}
}
// now insert new rows for this iteration
firstkey = iter * oper_per_iter;
numkeys = oper_per_iter;
insert_n_broken(db, NULL, NULL, firstkey, numkeys);
}
// assert that correct values are in expected rows // assert that correct values are in expected rows
static void static void
...@@ -108,10 +134,14 @@ verify_sequential_rows(DB* compare_db, int64_t firstkey, int64_t numkeys) { ...@@ -108,10 +134,14 @@ verify_sequential_rows(DB* compare_db, int64_t firstkey, int64_t numkeys) {
static void static void
drop_dead(void) { drop_dead(void) {
// deliberate zerodivide or sigsegv // deliberate zerodivide or sigsegv
printf("Simulate crash with deliberate sigsegv\n"); fprintf(stderr, "HAPPY CRASH\n");
fflush(stdout); fflush(stdout);
fflush(stderr);
int zero = 0;
int infinity = 1/zero;
void * intothevoid = NULL; void * intothevoid = NULL;
(*(int*)intothevoid)++; (*(int*)intothevoid)++;
printf("intothevoid = %p, infinity = %d\n", intothevoid, infinity);
printf("This line should never be printed\n"); printf("This line should never be printed\n");
fflush(stdout); fflush(stdout);
} }
...@@ -120,8 +150,6 @@ drop_dead(void) { ...@@ -120,8 +150,6 @@ drop_dead(void) {
void void
verify_and_insert (DB* db, int iter) { verify_and_insert (DB* db, int iter) {
int oper_per_iter = 1025;
int64_t firstkey; // first key to verify/insert int64_t firstkey; // first key to verify/insert
int64_t numkeys; // number of keys to verify/insert int64_t numkeys; // number of keys to verify/insert
...@@ -151,11 +179,12 @@ run_test (int iter, int die) { ...@@ -151,11 +179,12 @@ run_test (int iter, int die) {
int i; int i;
env_startup();
if (iter == 0) if (iter == 0)
dir_create(); // create directory if first time through dir_create(); // create directory if first time through
// run with 32K cachesize to force lots of disk I/O
env_startup(0, 1<<15);
// create array of dictionaries // create array of dictionaries
// for each dictionary verify previous iterations and perform new inserts // for each dictionary verify previous iterations and perform new inserts
...@@ -173,14 +202,32 @@ run_test (int iter, int die) { ...@@ -173,14 +202,32 @@ run_test (int iter, int die) {
snapshot(NULL, 1); snapshot(NULL, 1);
if (die) { if (die) {
// first scribble over correct data, then die //TODO: in separate thread do random inserts/deletes/queries
// in this thread:
// first scribble over correct data
// sleep a random amount of time and drop dead
DB* db = dictionaries[0].db;
scribble(db, iter);
u_int32_t delay = myrandom();
delay &= 0xFFF; // select lower 12 bits, shifted up 8
delay = delay << 8; // sleep up to one second
usleep(delay);
drop_dead(); drop_dead();
} }
else else {
for (i = 0; i < NUM_DICTIONARIES; i++) {
db_shutdown(&dictionaries[i]);
}
env_shutdown(); env_shutdown();
}
} }
static void
usage(char *progname) {
fprintf(stderr, "Usage:\n%s [-i n] [-q|-v]\n"
" \n%s [-h]\n", progname, progname);
}
int int
...@@ -193,23 +240,38 @@ test_main (int argc, char *argv[]) { ...@@ -193,23 +240,38 @@ test_main (int argc, char *argv[]) {
int iter = -1; int iter = -1;
int c; int c;
while ((c = getopt(argc, argv, "i:vq")) != -1) { int crash = 0;
while ((c = getopt(argc, argv, "cChi:qv")) != -1) {
switch(c) { switch(c) {
case 'c':
crash = 1;
break;
case 'C':
crash = 0;
break;
case 'i': case 'i':
iter = atoi(optarg); iter = atoi(optarg);
printf(" setting iter = %d\n", iter); printf(" setting iter = %d\n", iter);
break; break;
case 'v': case 'v':
verbose++;
break;
case 'q': case 'q':
case 'h': verbose--;
// handled by parse_args() if (verbose<0) verbose=0;
break; break;
case 'h':
case '?':
usage(argv[0]);
return 1;
default: default:
printf(" unknown argument 0x%0x\n", c); assert(FALSE);
break; return 1;
} }
} }
if (argc!=optind) { usage(argv[0]); return 1; }
// for developing this test
if (iter <0) { if (iter <0) {
printf("No argument, just run five times without crash\n"); printf("No argument, just run five times without crash\n");
for (iter = 0; iter<5; iter++) { for (iter = 0; iter<5; iter++) {
...@@ -218,7 +280,7 @@ test_main (int argc, char *argv[]) { ...@@ -218,7 +280,7 @@ test_main (int argc, char *argv[]) {
} }
else { else {
printf("checkpoint_stress running one iteration, iter = %d\n", iter); printf("checkpoint_stress running one iteration, iter = %d\n", iter);
run_test(iter, 1); run_test(iter, crash);
} }
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