Commit b8940404 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 7481d53f
......@@ -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.
# Also keep them sorted.
REGRESSION_TESTS = \
ybt-test \
test-gpma-glassbox \
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-cursor \
brt-test-cursor-2 \
brt-test-named-db \
brt-test0 \
brt-test1 \
brt-test2 \
brt-test3 \
brt-test4 \
test-brt-overflow \
brt-test-named-db \
brt-test-cursor \
brt-test-cursor-2 \
log-test \
cachetable-test \
cachetable-test2 \
fifo-test \
fifo-test-exp \
list-test \
log-test2 \
log-test3 \
log-test4 \
log-test5 \
log-test6 \
test_oexcl \
test-assert \
test-primes \
list-test \
test-inc-split \
test-brt-delete-both \
test-brt-overflow \
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
# Add in the binaries that must be run in various ways.
BINS = $(REGRESSION_TESTS) \
benchmark-test \
test-gpma-worstinsert \
brtdump \
randbrt \
randdb4 \
tdb_logprint \
test_toku_malloc_plain_free \
# This line intentially kept commented so I can have a \ on the end of the previous line
tdb_logprint: LDFLAGS+=-lz
......@@ -108,33 +109,25 @@ log_code.c: logformat
libs: log.o
bins: $(BINS)
# Put the benchmarktest_256 first since it takes the longest (and we want to use parallelism in the make)
CHECKS = \
test_oexcl \
ybt-test \
cachetable-test \
cachetable-test2 \
brt-serialize-test \
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 \
benchmarktest_256 \
test-gpma-worstinsert-a \
test-gpma-worstinsert-b \
test-gpma-worstinsert-c \
$(REGRESSION_TESTS) \
# 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)
check: bins check_benchmarktest_256 $(patsubst %,check_%,$(CHECKS))
check: bins $(patsubst %,check_%,$(CHECKS))
check_benchmarktest_256: benchmark-test
$(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
@# no arguments, should err
......@@ -227,7 +220,7 @@ else
endif
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
randdb4: LOADLIBES=-ldb
......
......@@ -6,6 +6,7 @@ int toku_testsetup_leaf(BRT brt, DISKOFF *diskoff) {
int r = toku_read_and_pin_brt_header(brt->cf, &brt->h);
if (r!=0) return r;
toku_create_new_brtnode(brt, &node, 0, (TOKULOGGER)0);
*diskoff = node->thisnodename;
r = toku_unpin_brtnode(brt, node);
if (r!=0) return r;
......@@ -22,6 +23,8 @@ int toku_testsetup_nonleaf (BRT brt, int height, DISKOFF *diskoff, int n_childre
if (r!=0) return r;
toku_create_new_brtnode(brt, &node, height, (TOKULOGGER)0);
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.n_bytes_in_buffers=0;
int i;
......@@ -72,7 +75,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, DISKOFF diskoff, char *key, int keyl
BRTNODE node=node_v;
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};
u_int32_t storedlen;
void *storeddata;
......
......@@ -31,86 +31,98 @@ static int delete_callback (u_int32_t slotnum __attribute__((__unused__)), u_int
return 0;
}
void test_worst_insert_up(void) {
int r;
GPMA pma;
r = toku_gpma_create(&pma, 0);
static const int initial_N=1000;
static const int N=100000;
static const int w=6;
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);
count_frees=0;
}
int i;
int initial_N=1000;
int N=100000;
int w=6;
int next_to_delete=0;
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,
static void delete_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_delete_item(pma,
strlen(buf)+1, buf,
compare_strings, 0,
delete_callback, buf,
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;
GPMA pma;
r = toku_gpma_create(&pma, 0);
assert(r==0);
count_frees=0;
int i;
int initial_N=1000;
int N=100000;
int w=6;
int next_to_insert=0;
int next_to_delete=0;
int max_size = 0;
for (i=0; i<initial_N; i++) {
char buf[w+1];
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);
insert_n(pma, inum(direction,next_to_insert++));
}
for (; i<N; i++) {
char buf[w+1];
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);
snprintf(buf, sizeof(buf), "%0*d", w, N-1-next_to_delete);
r = toku_gpma_delete_item(pma,
strlen(buf)+1, buf,
compare_strings, 0,
delete_callback, buf,
0, 0);
assert(r==0);
next_to_delete++;
insert_n(pma, inum(direction,next_to_insert++));
if (i%10==0) continue; // Make the table get slowly larger
delete_n(pma, inum(direction, next_to_delete++));
}
for (; i<2*N; i++) {
int this_size = toku_gpma_index_limit(pma);
if (this_size>max_size) max_size=this_size;
delete_n(pma, inum(direction,next_to_delete++));
if (i%20==0) continue; // Make the table get slowly smaller
insert_n(pma, inum(direction,next_to_insert++));
}
toku_gpma_free(&pma, free_callback, &verbose);
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 i;
int which = 0;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
if (0 == strcmp(arg, "-v") || 0 == strcmp(arg, "--verbose"))
verbose = 1;
else if (0 == strcmp(arg, "-q") || 0 == strcmp(arg, "--quiet"))
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();
test_worst_insert_down();
if (which==0 || which==1) test_worst_insert(+1);
if (which==0 || which==2) test_worst_insert(-1);
if (which==0 || which==3) test_worst_insert( 0);
return 0;
}
......@@ -47,7 +47,7 @@ BRT t;
int fnamelen;
char *fname;
void doit (int ksize) {
void doit (int ksize __attribute__((__unused__))) {
DISKOFF cnodes[BRT_FANOUT], bnode, anode;
u_int32_t fingerprints[BRT_FANOUT];
......@@ -65,6 +65,7 @@ void doit (int ksize) {
unlink(fname);
r = toku_open_brt(fname, 0, 1, &t, NODESIZE, ct, null_txn, toku_default_compare_fun, null_db);
assert(r==0);
toku_free(fname);
for (i=0; i<BRT_FANOUT; i++) {
r=toku_testsetup_leaf(t, &cnodes[i]);
......@@ -88,10 +89,14 @@ void doit (int ksize) {
r = toku_testsetup_nonleaf(t, 1, &bnode, BRT_FANOUT, cnodes, fingerprints, keys, keylens);
assert(r==0);
for (i=0; i+1<BRT_FANOUT; i++) {
toku_free(keys[i]);
}
u_int32_t bfingerprint=0;
{
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];
int keylen = 1+snprintf(key, KSIZE, "%08d%0*d", 150002, magic_size, 0);
char val[1];
......@@ -101,7 +106,7 @@ void doit (int ksize) {
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);
}
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
r = toku_testsetup_nonleaf(t, 2, &anode, 1, &bnode, &bfingerprint, 0, 0);
......@@ -134,16 +139,19 @@ void doit (int ksize) {
r = toku_close_brt(t); 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 i;
doit(53); exit(0);
doit(53);
toku_malloc_cleanup();
exit(0);
for (i=1; i<NODESIZE/2; i++) {
printf("extrasize=%d\n", i);
doit(i);
}
toku_malloc_cleanup();
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