Skip to content

Commit

Permalink
FT-304 Add stress test coverage for db->get_fragmentation(db)
Browse files Browse the repository at this point in the history
  • Loading branch information
esmet committed Jul 22, 2014
1 parent 54f9828 commit 7c03c64
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/tests/test_stress7.cc
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
//

if (verbose) printf("starting creation of pthreads\n");
const int num_threads = 4 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
const int num_threads = 5 + cli_args->num_update_threads + cli_args->num_ptquery_threads;
struct arg myargs[num_threads];
for (int i = 0; i < num_threads; i++) {
arg_init(&myargs[i], dbp, env, cli_args);
Expand All @@ -129,19 +129,21 @@ stress_table(DB_ENV *env, DB **dbp, struct cli_args *cli_args) {
myargs[1].operation_extra = &soe[1];
myargs[1].operation = scan_op;

// make the guy that runs HOT in the background
// make the guys that run hot optimize, keyrange, and frag stats in the background
myargs[2].operation = hot_op;
myargs[3].operation = keyrange_op;
myargs[4].operation = frag_op;
myargs[4].sleep_ms = 100;

struct update_op_args uoe = get_update_op_args(cli_args, NULL);
// make the guy that updates the db
for (int i = 4; i < 4 + cli_args->num_update_threads; ++i) {
for (int i = 5; i < 5 + cli_args->num_update_threads; ++i) {
myargs[i].operation_extra = &uoe;
myargs[i].operation = update_op;
}

// make the guy that does point queries
for (int i = 4 + cli_args->num_update_threads; i < num_threads; i++) {
for (int i = 5 + cli_args->num_update_threads; i < num_threads; i++) {
myargs[i].operation = ptquery_op;
}
run_workers(myargs, num_threads, cli_args->num_seconds, false, cli_args);
Expand Down
10 changes: 10 additions & 0 deletions src/tests/threaded_stress_test_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,16 @@ static int UU() keyrange_op(DB_TXN *txn, ARG arg, void* UU(operation_extra), voi
return r;
}

static int UU() frag_op(DB_TXN *UU(txn), ARG arg, void* UU(operation_extra), void *UU(stats_extra)) {
int db_index = myrandom_r(arg->random_data)%arg->cli->num_DBs;
DB *db = arg->dbp[db_index];

TOKU_DB_FRAGMENTATION_S frag;
int r = db->get_fragmentation(db, &frag);
invariant_zero(r);
return r;
}

static void UU() get_key_after_bytes_callback(const DBT *UU(end_key), uint64_t UU(skipped), void *UU(extra)) {
// nothing
}
Expand Down

0 comments on commit 7c03c64

Please sign in to comment.