Commit 36aaf769 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

test_db_curs4 is good, but too much randomness

git-svn-id: file:///svn/tokudb@1057 c7de825b-a66e-492c-adef-691d508d4ae1
parent dafce7dc
...@@ -139,3 +139,6 @@ make_libs: ...@@ -139,3 +139,6 @@ make_libs:
clean: clean:
rm -f $(ALL_TESTS) *.o rm -f $(ALL_TESTS) *.o
rm -rf dir.*.tdb dir.*.bdb rm -rf dir.*.tdb dir.*.bdb
test_db_curs4.tdb: trace.h
...@@ -274,25 +274,58 @@ void do_create (void) { ...@@ -274,25 +274,58 @@ void do_create (void) {
assert(n_named==n_prim); assert(n_named==n_prim);
} }
int rcount=0;
void insert_person (void) { void insert_person (void) {
int namelen = 5+random()%245; int namelen = 5+random()%245;
rcount++;
struct primary_key pk; struct primary_key pk;
struct primary_data pd; struct primary_data pd;
char keyarray[1000], dataarray[1000]; char keyarray[1000], dataarray[1000];
unsigned char namearray[1000];
pk.rand = random(); pk.rand = random();
rcount++;
gettod(&pk.ts); gettod(&pk.ts);
pd.creationtime = pk.ts; pd.creationtime = pk.ts;
pd.expiretime = pk.ts; pd.expiretime = pk.ts;
pd.expiretime.tv_sec += 24*60*60*366; pd.expiretime.tv_sec += 24*60*60*366;
pd.doesexpire = (random()%10==0); pd.doesexpire = 0;
int i; random();
pd.name.name = namearray; rcount++;
pd.name.name[0] = 'A'+random()%26; if (opnum==2 || opnum==10 || opnum==22 || opnum==86) {
for (i=1; i<namelen; i++) { pd.doesexpire = 1;
pd.name.name[i] = 'a'+random()%26;
} }
pd.name.name[i]=0; int i;
for (i=0; i<namelen; i++) { random(); rcount++; }
namelen=i=2;
char *newnamearray;
if (oppass==1 && opnum==1) newnamearray="Cd";
else if (oppass==1 && opnum==2) newnamearray="Ew";
else if (oppass==1 && opnum==5) newnamearray="Zq";
else if (oppass==1 && opnum==6) newnamearray="Ug";
else if (oppass==1 && opnum==9) newnamearray="Ib";
else if (oppass==1 && opnum==10) newnamearray="Cf";
else if (oppass==1 && opnum==13) newnamearray="Qf";
else if (oppass==1 && opnum==14) newnamearray="Pp";
else if (oppass==1 && opnum==15) newnamearray="Dz";
else if (oppass==1 && opnum==16) newnamearray="Dd";
else if (oppass==1 && opnum==22) newnamearray="Uy";
else if (oppass==1 && opnum==24) newnamearray="Wm";
else if (oppass==1 && opnum==25) newnamearray="Qw";
else if (oppass==1 && opnum==26) newnamearray="Fg";
else if (oppass==1 && opnum==30) newnamearray="Iv";
else if (oppass==2 && opnum==9) newnamearray="Dq";
else if (oppass==2 && opnum==15) newnamearray="Rr";
else if (oppass==2 && opnum==36) newnamearray="Sp";
else if (oppass==2 && opnum==37) newnamearray="Uo";
else if (oppass==2 && opnum==39) newnamearray="Je";
else if (oppass==2 && opnum==73) newnamearray="Kg";
else if (oppass==2 && opnum==74) newnamearray="Gp";
else if (oppass==2 && opnum==76) newnamearray="Iv";
else if (oppass==2 && opnum==86) newnamearray="Sk";
else if (oppass==2 && opnum==100) newnamearray="Tq";
else abort();
pd.name.name=(unsigned char*)newnamearray;
//printf("%2d %d: pk.rand=%u;\n", oppass, opnum, pk.rand);
DBT key,data; DBT key,data;
memset(&key,0,sizeof(DBT)); memset(&key,0,sizeof(DBT));
memset(&data,0,sizeof(DBT)); memset(&data,0,sizeof(DBT));
...@@ -307,7 +340,7 @@ void insert_person (void) { ...@@ -307,7 +340,7 @@ void insert_person (void) {
int r=dbp->put(dbp, null_txn, &key, &data,0); CKERR(r); int r=dbp->put(dbp, null_txn, &key, &data,0); CKERR(r);
// If the cursor is to the left of the current item, then increment count_items // If the cursor is to the left of the current item, then increment count_items
{ {
int compare=strcmp((char*)namearray, nc_key.data); int compare=strcmp((char*)newnamearray, nc_key.data);
//printf("%s:%d compare=%d insert %s, cursor at %s\n", __FILE__, __LINE__, compare, namearray, (char*)nc_key.data); //printf("%s:%d compare=%d insert %s, cursor at %s\n", __FILE__, __LINE__, compare, namearray, (char*)nc_key.data);
if (compare>0) calc_n_items++; if (compare>0) calc_n_items++;
count_all_items++; count_all_items++;
...@@ -327,19 +360,21 @@ void delete_oldest_expired (void) { ...@@ -327,19 +360,21 @@ void delete_oldest_expired (void) {
printf("%s:%d %d:%d delete\n", __FILE__, __LINE__, oppass, opnum); printf("%s:%d %d:%d delete\n", __FILE__, __LINE__, oppass, opnum);
int r; int r;
random(); random();
rcount++;
if (delete_cursor==0) { if (delete_cursor==0) {
r = expiredb->cursor(expiredb, null_txn, &delete_cursor, 0); CKERR(r); r = expiredb->cursor(expiredb, null_txn, &delete_cursor, 0); CKERR(r);
} }
DBT key,pkey,data, savepkey; DBT pkey;
memset(&key, 0, sizeof(key)); {
memset(&pkey, 0, sizeof(pkey)); DBT key,data;
memset(&data, 0, sizeof(data)); memset(&key, 0, sizeof(key));
#if 1 memset(&pkey, 0, sizeof(pkey));
r = delete_cursor->c_pget(delete_cursor, &key, &pkey, &data, DB_FIRST); memset(&data, 0, sizeof(data));
if (r==DB_NOTFOUND) return; r = delete_cursor->c_pget(delete_cursor, &key, &pkey, &data, DB_FIRST);
CKERR(r); if (r==DB_NOTFOUND) return;
#endif CKERR(r);
}
printf("%s:%d oppass==%d opnum==%d ", __FILE__, __LINE__, oppass, opnum); printf("%s:%d oppass==%d opnum==%d ", __FILE__, __LINE__, oppass, opnum);
{ {
if (oppass==2 && opnum==8) { if (oppass==2 && opnum==8) {
...@@ -361,12 +396,16 @@ void delete_oldest_expired (void) { ...@@ -361,12 +396,16 @@ void delete_oldest_expired (void) {
} }
} }
count_all_items--; count_all_items--;
savepkey = pkey; DBT savepkey = pkey;
savepkey.data = malloc(pkey.size); savepkey.data = malloc(pkey.size);
memcpy(savepkey.data, pkey.data, pkey.size); memcpy(savepkey.data, pkey.data, pkey.size);
r = dbp->del(dbp, null_txn, &pkey, 0); CKERR(r); r = dbp->del(dbp, null_txn, &pkey, 0); CKERR(r);
// Make sure it's really gone. // Make sure it's really gone.
r = dbp->get(dbp, null_txn, &savepkey, &data, 0); {
DBT data;
memset(&data, 0, sizeof(data));
r = dbp->get(dbp, null_txn, &savepkey, &data, 0);
}
assert(r==DB_NOTFOUND); assert(r==DB_NOTFOUND);
free(savepkey.data); free(savepkey.data);
} }
...@@ -399,13 +438,20 @@ void step_name (void) { ...@@ -399,13 +438,20 @@ void step_name (void) {
int cursor_load=2; /* Set this to a higher number to do more cursor work for every insertion. Needed to get to the end. */ int cursor_load=2; /* Set this to a higher number to do more cursor work for every insertion. Needed to get to the end. */
void activity (void) { void activity (void) {
if (random()%20==0) { random();
rcount++;
if (oppass==2 && (opnum==8 || opnum==53 || opnum==57 || opnum==65 || opnum==78 || opnum==97)) {
// Delete the oldest expired one. Keep the cursor open // Delete the oldest expired one. Keep the cursor open
delete_oldest_expired(); delete_oldest_expired();
} else if (random()%cursor_load==0) {
insert_person();
} else { } else {
step_name(); random();
rcount++;
if ((oppass==2 && (opnum==9 || opnum==15 || opnum==36 || opnum==37 || opnum==39 || opnum==73 || opnum==74 || opnum==76 || opnum==86 || opnum==100))
|| (oppass==1 && (opnum==1 || opnum==2 || opnum==5 || opnum==6 || opnum==9 || opnum==10 || opnum==13 || opnum==14 || opnum==15 || opnum==16 || opnum==22 || opnum==24 || opnum==25 || opnum==26 || opnum==30))) {
insert_person();
} else {
step_name();
}
} }
//assert(count_all_items==count_entries(dbp)); //assert(count_all_items==count_entries(dbp));
} }
......
This diff is collapsed.
This diff is collapsed.
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