Commit ba41c2e3 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

Make all those tests run again. Fixes #635.

git-svn-id: file:///svn/tokudb@3250 c7de825b-a66e-492c-adef-691d508d4ae1
parent 93b4002d
...@@ -46,48 +46,49 @@ build default: bins libs tdb-recover tdb_logprint ...@@ -46,48 +46,49 @@ build default: bins libs tdb-recover tdb_logprint
# Put these one-per-line so that if we insert a new one the svn diff can understand it better. # Put these one-per-line so that if we insert a new one the svn diff can understand it better.
# Also keep them sorted. # Also keep them sorted.
REGRESSION_TESTS = \ REGRESSION_TESTS = \
ybt-test \
test-gpma-glassbox \
brt-serialize-test \ brt-serialize-test \
cachetable-test \
cachetable-test2 \
fifo-test \
fifo-test-exp \
test-gpma-blackbox \
test-gpma-glassbox \
test-gpma-worstinsert \
test-brt-delete-both \
brt-test \ brt-test \
brt-test-cursor \
brt-test-cursor-2 \
brt-test-named-db \
brt-test0 \ brt-test0 \
brt-test1 \ brt-test1 \
brt-test2 \ brt-test2 \
brt-test3 \ brt-test3 \
brt-test4 \ brt-test4 \
test-brt-overflow \ cachetable-test \
brt-test-named-db \ cachetable-test2 \
brt-test-cursor \ fifo-test \
brt-test-cursor-2 \ fifo-test-exp \
log-test \ list-test \
log-test2 \ log-test2 \
log-test3 \ log-test3 \
log-test4 \ log-test4 \
log-test5 \ log-test5 \
log-test6 \ log-test6 \
test_oexcl \
test-assert \ test-assert \
test-primes \ test-brt-delete-both \
list-test \ test-brt-overflow \
test-inc-split \
test-del-inorder \ test-del-inorder \
test-gpma-blackbox \
test-gpma-glassbox \
test-gpma-glassbox \
test-inc-split \
test-primes \
test_oexcl \
test_toku_malloc_plain_free \
ybt-test \
log-test \
# This line intentially kept commented so I can have a \ on the end of the previous line # This line intentially kept commented so I can have a \ on the end of the previous line
# Add in the binaries that must be run in various ways.
BINS = $(REGRESSION_TESTS) \ BINS = $(REGRESSION_TESTS) \
benchmark-test \ benchmark-test \
test-gpma-worstinsert \
brtdump \ brtdump \
randbrt \ randbrt \
randdb4 \ randdb4 \
tdb_logprint \ tdb_logprint \
test_toku_malloc_plain_free \
# This line intentially kept commented so I can have a \ on the end of the previous line # This line intentially kept commented so I can have a \ on the end of the previous line
tdb_logprint: LDFLAGS+=-lz tdb_logprint: LDFLAGS+=-lz
...@@ -108,33 +109,25 @@ log_code.c: logformat ...@@ -108,33 +109,25 @@ log_code.c: logformat
libs: log.o libs: log.o
bins: $(BINS) bins: $(BINS)
# Put the benchmarktest_256 first since it takes the longest (and we want to use parallelism in the make)
CHECKS = \ CHECKS = \
test_oexcl \ benchmarktest_256 \
ybt-test \ test-gpma-worstinsert-a \
cachetable-test \ test-gpma-worstinsert-b \
cachetable-test2 \ test-gpma-worstinsert-c \
brt-serialize-test \ $(REGRESSION_TESTS) \
test-brt-delete-both \
brt-test \
brt-test-cursor \
brt-test-cursor-2 \
brt-test0 \
brt-test1 \
brt-test2 \
brt-test3 \
brt-test4 \
test-brt-overflow \
brt-test-named-db \
fifo-test \
test_toku_malloc_plain_free \
test-primes \
list-test \
# This line intentially kept commented so I can have a \ on the previous line # This line intentially kept commented so I can have a \ on the previous line
# Put check_benchmarktest_256 first because it is long-running (and therefore on the critical path, so get it started) # Put check_benchmarktest_256 first because it is long-running (and therefore on the critical path, so get it started)
check: bins check_benchmarktest_256 $(patsubst %,check_%,$(CHECKS)) check: bins $(patsubst %,check_%,$(CHECKS))
check_benchmarktest_256: benchmark-test check_benchmarktest_256: benchmark-test
$(VGRIND) ./benchmark-test $(VERBVERBOSE) --valsize 256 --verify 1 $(VGRIND) ./benchmark-test $(VERBVERBOSE) --valsize 256 --verify 1
check_test-gpma-worstinsert-a: test-gpma-worstinsert
$(VGRIND) ./test-gpma-worstinsert $(VERBVERBOSE) -a
check_test-gpma-worstinsert-b: test-gpma-worstinsert
$(VGRIND) ./test-gpma-worstinsert $(VERBVERBOSE) -b
check_test-gpma-worstinsert-c: test-gpma-worstinsert
$(VGRIND) ./test-gpma-worstinsert $(VERBVERBOSE) -c
check_test-assert: test-assert check_test-assert: test-assert
@# no arguments, should err @# no arguments, should err
...@@ -227,7 +220,7 @@ else ...@@ -227,7 +220,7 @@ else
endif endif
clean: clean:
rm -rf $(REGRESSION_TESTS) $(BINS) *.o *.bb *.bbg *.da *.gcov *.gcno *.gcda rm -rf $(BINS) *.o *.bb *.bbg *.da *.gcov *.gcno *.gcda
rm -rf test_oexcl.c.tmp *.brt rm -rf test_oexcl.c.tmp *.brt
randdb4: LOADLIBES=-ldb randdb4: LOADLIBES=-ldb
......
...@@ -6,6 +6,7 @@ int toku_testsetup_leaf(BRT brt, DISKOFF *diskoff) { ...@@ -6,6 +6,7 @@ int toku_testsetup_leaf(BRT brt, DISKOFF *diskoff) {
int r = toku_read_and_pin_brt_header(brt->cf, &brt->h); int r = toku_read_and_pin_brt_header(brt->cf, &brt->h);
if (r!=0) return r; if (r!=0) return r;
toku_create_new_brtnode(brt, &node, 0, (TOKULOGGER)0); toku_create_new_brtnode(brt, &node, 0, (TOKULOGGER)0);
*diskoff = node->thisnodename; *diskoff = node->thisnodename;
r = toku_unpin_brtnode(brt, node); r = toku_unpin_brtnode(brt, node);
if (r!=0) return r; if (r!=0) return r;
...@@ -22,6 +23,8 @@ int toku_testsetup_nonleaf (BRT brt, int height, DISKOFF *diskoff, int n_childre ...@@ -22,6 +23,8 @@ int toku_testsetup_nonleaf (BRT brt, int height, DISKOFF *diskoff, int n_childre
if (r!=0) return r; if (r!=0) return r;
toku_create_new_brtnode(brt, &node, height, (TOKULOGGER)0); toku_create_new_brtnode(brt, &node, height, (TOKULOGGER)0);
node->u.n.n_children=n_children; node->u.n.n_children=n_children;
MALLOC_N(n_children+1, node->u.n.childinfos);
MALLOC_N(n_children, node->u.n.childkeys);
node->u.n.totalchildkeylens=0; node->u.n.totalchildkeylens=0;
node->u.n.n_bytes_in_buffers=0; node->u.n.n_bytes_in_buffers=0;
int i; int i;
...@@ -72,7 +75,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, DISKOFF diskoff, char *key, int keyl ...@@ -72,7 +75,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, DISKOFF diskoff, char *key, int keyl
BRTNODE node=node_v; BRTNODE node=node_v;
assert(node->height==0); assert(node->height==0);
struct kv_pair *kv = kv_pair_malloc(key, keylen, val, vallen); struct kv_pair *kv = brtnode_malloc_kv_pair(node->u.l.buffer, &node->u.l.buffer_mempool, key, keylen, val, vallen);
struct lc_pair lc = {brt, node->flags & TOKU_DB_DUPSORT}; struct lc_pair lc = {brt, node->flags & TOKU_DB_DUPSORT};
u_int32_t storedlen; u_int32_t storedlen;
void *storeddata; void *storeddata;
......
...@@ -31,86 +31,98 @@ static int delete_callback (u_int32_t slotnum __attribute__((__unused__)), u_int ...@@ -31,86 +31,98 @@ static int delete_callback (u_int32_t slotnum __attribute__((__unused__)), u_int
return 0; return 0;
} }
void test_worst_insert_up(void) { static const int initial_N=1000;
int r; static const int N=100000;
GPMA pma; static const int w=6;
r = toku_gpma_create(&pma, 0);
static void insert_n (GPMA pma, int n) {
char buf[w+1];
int l = snprintf(buf, sizeof(buf), "%0*d", w, n);
assert(l==w);
int r = toku_gpma_insert(pma, strlen(buf)+1, strdup(buf), compare_strings, 0, rcall_ok, 0, 0);
assert(r==0); assert(r==0);
count_frees=0; }
int i; static void delete_n (GPMA pma, int n) {
int initial_N=1000; char buf[w+1];
int N=100000; int l = snprintf(buf, sizeof(buf), "%0*d", w, n);
int w=6; assert(l==w);
int next_to_delete=0; int r = toku_gpma_delete_item(pma,
for (i=0; i<initial_N; i++) {
char buf[w+1];
snprintf(buf, sizeof(buf), "%0*d", w, i);
r = toku_gpma_insert(pma, strlen(buf)+1, strdup(buf), compare_strings, 0, rcall_ok, 0, 0);
assert(r==0);
}
for (; i<N; i++) {
char buf[w+1];
snprintf(buf, sizeof(buf), "%0*d", w, i);
r = toku_gpma_insert(pma, strlen(buf)+1, strdup(buf), compare_strings, 0, rcall_ok, 0, 0);
assert(r==0);
snprintf(buf, sizeof(buf), "%0*d", w, next_to_delete);
r = toku_gpma_delete_item(pma,
strlen(buf)+1, buf, strlen(buf)+1, buf,
compare_strings, 0, compare_strings, 0,
delete_callback, buf, delete_callback, buf,
0, 0); 0, 0);
if (r!=0) printf("deleted %d\n", n);
assert(r==0);
}
static int inum (int direction, int itemnum) {
switch (direction) {
case 1:
// Insert things from left to right
return itemnum;
case -1:
// Insert things from right to left
return 2*N-1-itemnum;
case 0:
// Insert things at the outer edges
if (itemnum%2) {
return itemnum/2;
} else {
return 2*N-1-itemnum/2;
}
default: assert(0); return 0;
} }
toku_gpma_free(&pma, free_callback, &verbose);
assert(count_frees==0);
} }
void test_worst_insert_down(void) { static void test_worst_insert(int direction) {
int r; int r;
GPMA pma; GPMA pma;
r = toku_gpma_create(&pma, 0); r = toku_gpma_create(&pma, 0);
assert(r==0); assert(r==0);
count_frees=0; count_frees=0;
int i; int i;
int initial_N=1000; int next_to_insert=0;
int N=100000;
int w=6;
int next_to_delete=0; int next_to_delete=0;
int max_size = 0;
for (i=0; i<initial_N; i++) { for (i=0; i<initial_N; i++) {
char buf[w+1]; insert_n(pma, inum(direction,next_to_insert++));
snprintf(buf, sizeof(buf), "%0*d", w, N-1-i);
r = toku_gpma_insert(pma, strlen(buf)+1, strdup(buf), compare_strings, 0, rcall_ok, 0, 0);
assert(r==0);
} }
for (; i<N; i++) { for (; i<N; i++) {
char buf[w+1]; insert_n(pma, inum(direction,next_to_insert++));
snprintf(buf, sizeof(buf), "%0*d", w, N-1-i); if (i%10==0) continue; // Make the table get slowly larger
r = toku_gpma_insert(pma, strlen(buf)+1, strdup(buf), compare_strings, 0, rcall_ok, 0, 0); delete_n(pma, inum(direction, next_to_delete++));
assert(r==0); }
snprintf(buf, sizeof(buf), "%0*d", w, N-1-next_to_delete); for (; i<2*N; i++) {
r = toku_gpma_delete_item(pma, int this_size = toku_gpma_index_limit(pma);
strlen(buf)+1, buf, if (this_size>max_size) max_size=this_size;
compare_strings, 0, delete_n(pma, inum(direction,next_to_delete++));
delete_callback, buf, if (i%20==0) continue; // Make the table get slowly smaller
0, 0); insert_n(pma, inum(direction,next_to_insert++));
assert(r==0);
next_to_delete++;
} }
toku_gpma_free(&pma, free_callback, &verbose);
assert(count_frees==0); assert(count_frees==0);
if (verbose) printf("size=%d max_size=%d\n", toku_gpma_index_limit(pma), max_size);
toku_gpma_free(&pma, free_callback, &verbose);
} }
int main (int argc, const char *argv[]) { int main (int argc, const char *argv[]) {
int i; int i;
int which = 0;
for (i = 1; i < argc; i++) { for (i = 1; i < argc; i++) {
const char *arg = argv[i]; const char *arg = argv[i];
if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose")) if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose"))
verbose = 1; verbose = 1;
else if (0 == strcmp(arg, "-q") || 0 == strcmp(arg, "--quiet")) else if (0 == strcmp(arg, "-q") || 0 == strcmp(arg, "--quiet"))
verbose = 0; verbose = 0;
else if (0 == strcmp(arg, "-a"))
which = 1;
else if (0 == strcmp(arg, "-b"))
which = 2;
else if (0 == strcmp(arg, "-c"))
which = 3;
} }
test_worst_insert_up(); if (which==0 || which==1) test_worst_insert(+1);
test_worst_insert_down(); if (which==0 || which==2) test_worst_insert(-1);
if (which==0 || which==3) test_worst_insert( 0);
return 0; return 0;
} }
...@@ -47,7 +47,7 @@ BRT t; ...@@ -47,7 +47,7 @@ BRT t;
int fnamelen; int fnamelen;
char *fname; char *fname;
void doit (int ksize) { void doit (int ksize __attribute__((__unused__))) {
DISKOFF cnodes[BRT_FANOUT], bnode, anode; DISKOFF cnodes[BRT_FANOUT], bnode, anode;
u_int32_t fingerprints[BRT_FANOUT]; u_int32_t fingerprints[BRT_FANOUT];
...@@ -65,6 +65,7 @@ void doit (int ksize) { ...@@ -65,6 +65,7 @@ void doit (int ksize) {
unlink(fname); unlink(fname);
r = toku_open_brt(fname, 0, 1, &t, NODESIZE, ct, null_txn, toku_default_compare_fun, null_db); r = toku_open_brt(fname, 0, 1, &t, NODESIZE, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0); assert(r==0);
toku_free(fname);
for (i=0; i<BRT_FANOUT; i++) { for (i=0; i<BRT_FANOUT; i++) {
r=toku_testsetup_leaf(t, &cnodes[i]); r=toku_testsetup_leaf(t, &cnodes[i]);
...@@ -88,10 +89,14 @@ void doit (int ksize) { ...@@ -88,10 +89,14 @@ void doit (int ksize) {
r = toku_testsetup_nonleaf(t, 1, &bnode, BRT_FANOUT, cnodes, fingerprints, keys, keylens); r = toku_testsetup_nonleaf(t, 1, &bnode, BRT_FANOUT, cnodes, fingerprints, keys, keylens);
assert(r==0); assert(r==0);
for (i=0; i+1<BRT_FANOUT; i++) {
toku_free(keys[i]);
}
u_int32_t bfingerprint=0; u_int32_t bfingerprint=0;
{ {
const int magic_size = (NODESIZE-toku_testsetup_get_sersize(t, bnode))/2-25; const int magic_size = (NODESIZE-toku_testsetup_get_sersize(t, bnode))/2-25;
printf("magic_size=%d\n", magic_size); //printf("magic_size=%d\n", magic_size);
char key [KSIZE]; char key [KSIZE];
int keylen = 1+snprintf(key, KSIZE, "%08d%0*d", 150002, magic_size, 0); int keylen = 1+snprintf(key, KSIZE, "%08d%0*d", 150002, magic_size, 0);
char val[1]; char val[1];
...@@ -101,7 +106,7 @@ void doit (int ksize) { ...@@ -101,7 +106,7 @@ void doit (int ksize) {
keylen = 1+snprintf(key, KSIZE, "%08d%0*d", 2, magic_size-1, 0); keylen = 1+snprintf(key, KSIZE, "%08d%0*d", 2, magic_size-1, 0);
r=toku_testsetup_insert_to_nonleaf(t, bnode, BRT_INSERT, key, keylen, val, vallen, &bfingerprint); r=toku_testsetup_insert_to_nonleaf(t, bnode, BRT_INSERT, key, keylen, val, vallen, &bfingerprint);
} }
printf("%lld sersize=%d\n", bnode, toku_testsetup_get_sersize(t, bnode)); //printf("%lld sersize=%d\n", bnode, toku_testsetup_get_sersize(t, bnode));
// Now we have an internal node which has full children and the buffers are nearly full // Now we have an internal node which has full children and the buffers are nearly full
r = toku_testsetup_nonleaf(t, 2, &anode, 1, &bnode, &bfingerprint, 0, 0); r = toku_testsetup_nonleaf(t, 2, &anode, 1, &bnode, &bfingerprint, 0, 0);
...@@ -134,16 +139,19 @@ void doit (int ksize) { ...@@ -134,16 +139,19 @@ void doit (int ksize) {
r = toku_close_brt(t); assert(r==0); r = toku_close_brt(t); assert(r==0);
r = toku_cachetable_close(&ct); assert(r==0); r = toku_cachetable_close(&ct); assert(r==0);
printf("ksize=%d, unused\n", ksize); //printf("ksize=%d, unused\n", ksize);
} }
int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) { int main (int argc __attribute__((__unused__)), char *argv[] __attribute__((__unused__))) {
int i; int i;
doit(53); exit(0); doit(53);
toku_malloc_cleanup();
exit(0);
for (i=1; i<NODESIZE/2; i++) { for (i=1; i<NODESIZE/2; i++) {
printf("extrasize=%d\n", i); printf("extrasize=%d\n", i);
doit(i); doit(i);
} }
toku_malloc_cleanup();
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