Commit 30296c52 authored by Barry Perlman's avatar Barry Perlman Committed by Yoni Fogel

[t:2892] Added tests of partially upgraded trees.

git-svn-id: file:///svn/toku/tokudb@26117 c7de825b-a66e-492c-adef-691d508d4ae1
parent 631ecce8
...@@ -11,7 +11,21 @@ ...@@ -11,7 +11,21 @@
#include "test_kv_gen.h" #include "test_kv_gen.h"
/* /****************************************************************************************
*
* open dbs
* read and verify first n rows of primary, a few interspersed rows of secondaries (n is very small so only a few nodes of secondaries are upgraded, even with prefetch)
* close dbs (dictionaries now partially upgraded)
* open dbs
* read and verify a few more rows of primary, a few more interspersed rows of secondaries
* close dbs (some more nodes now upgraded)
* open dbs
* insert more rows (at end of primary and interspersed in secondary dictionaries)
* close dbs
* open dbs
* verify all rows (including newly inserted ones)
* close dbs
*
*/ */
DB_ENV *env; DB_ENV *env;
...@@ -32,16 +46,15 @@ char *db_v4_dir_node4k = OLDDATADIR "env_preload.4.1.1.node4k.cleanshutdown"; ...@@ -32,16 +46,15 @@ char *db_v4_dir_node4k = OLDDATADIR "env_preload.4.1.1.node4k.cleanshutdown";
enum {ROWS_PER_TRANSACTION=10000}; enum {ROWS_PER_TRANSACTION=10000};
static int idx[MAX_DBS];
static void upgrade_test_4(DB **dbs) { static void
open_dbs(DB **dbs) {
int r; int r;
// open the DBS
{
DBT desc; DBT desc;
dbt_init(&desc, "foo", sizeof("foo")); dbt_init(&desc, "foo", sizeof("foo"));
char name[MAX_NAME*2]; char name[MAX_NAME*2];
int idx[MAX_DBS];
for(int i=0;i<NUM_DBS;i++) { for(int i=0;i<NUM_DBS;i++) {
idx[i] = i; idx[i] = i;
r = db_create(&dbs[i], env, 0); CKERR(r); r = db_create(&dbs[i], env, 0); CKERR(r);
...@@ -50,7 +63,48 @@ static void upgrade_test_4(DB **dbs) { ...@@ -50,7 +63,48 @@ static void upgrade_test_4(DB **dbs) {
snprintf(name, sizeof(name), "db_%04x", i); snprintf(name, sizeof(name), "db_%04x", i);
r = dbs[i]->open(dbs[i], NULL, name, NULL, DB_BTREE, DB_CREATE, 0666); CKERR(r); r = dbs[i]->open(dbs[i], NULL, name, NULL, DB_BTREE, DB_CREATE, 0666); CKERR(r);
} }
}
static void
close_dbs(DB **dbs) {
for(int i=0;i<NUM_DBS;i++) {
int r = dbs[i]->close(dbs[i], 0); CKERR(r);
dbs[i] = NULL;
}
}
static void upgrade_test_4(DB **dbs) {
int r;
int n = 4; // number of rows to check to partially upgrade dictionary
// open the DBS
open_dbs(dbs);
// check first few rows of primary, some (pseudo)random rows of secondaries
{
check_results(env, dbs, NUM_DBS, n);
if (verbose)
printf("First %d rows checked, now insert some more\n", n);
}
// close and reopen
close_dbs(dbs);
open_dbs(dbs);
// check first few rows of primary, some (pseudo)random rows of secondaries
{
n *= 2;
check_results(env, dbs, NUM_DBS, n);
if (verbose)
printf("First %d rows checked, now insert some more\n", n);
} }
// close and reopen
close_dbs(dbs);
open_dbs(dbs);
// append some rows // append some rows
DB_TXN *txn; DB_TXN *txn;
DBT skey, sval; DBT skey, sval;
...@@ -88,28 +142,10 @@ static void upgrade_test_4(DB **dbs) { ...@@ -88,28 +142,10 @@ static void upgrade_test_4(DB **dbs) {
if ( val.flags ) { toku_free(val.data); key.data = NULL; } if ( val.flags ) { toku_free(val.data); key.data = NULL; }
// close // close
{ close_dbs(dbs);
for(int i=0;i<NUM_DBS;i++) {
r = dbs[i]->close(dbs[i], 0); CKERR(r);
dbs[i] = NULL;
}
}
// open
{
DBT desc;
dbt_init(&desc, "foo", sizeof("foo"));
char name[MAX_NAME*2];
int idx[MAX_DBS]; // open
for(int i=0;i<NUM_DBS;i++) { open_dbs(dbs);
idx[i] = i;
r = db_create(&dbs[i], env, 0); CKERR(r);
r = dbs[i]->set_descriptor(dbs[i], 1, &desc); CKERR(r);
dbs[i]->app_private = &idx[i];
snprintf(name, sizeof(name), "db_%04x", i);
r = dbs[i]->open(dbs[i], NULL, name, NULL, DB_BTREE, DB_CREATE, 0666); CKERR(r);
}
}
// read and verify all rows // read and verify all rows
{ {
...@@ -191,7 +227,6 @@ static void run_test(void) ...@@ -191,7 +227,6 @@ static void run_test(void)
static void do_args(int argc, char * const argv[]); static void do_args(int argc, char * const argv[]);
int test_main(int argc, char * const *argv) { int test_main(int argc, char * const *argv) {
do_args(argc, argv);
do_args(argc, argv); do_args(argc, argv);
littlenode = 0; littlenode = 0;
setup(); setup();
......
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