Commit d0b43dcb authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

refs #5372 Merging to main: new cachetable helper functions to simulate CACHEFILE callbacks.

git-svn-id: file:///svn/toku/tokudb@47778 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0abe7c36
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
CACHETABLE ct;
......@@ -27,7 +28,8 @@ run_test (void) {
unlink(fname1);
f1 = NULL;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
void* v2;
long s1;
......
......@@ -7,6 +7,7 @@
#include "test.h"
#include <stdio.h>
#include <unistd.h>
#include "cachetable-test.h"
#include "checkpoint.h"
static int N; // how many items in the table
......@@ -100,10 +101,6 @@ do_checkpoint (void *UU(v))
// make sure that the stuff that was checkpointed includes only the old versions
// then do a flush and make sure the new items are written
static int dummy_pin_unpin(CACHEFILE UU(cfu), void* UU(v)) {
return 0;
}
static void checkpoint_pending(void) {
if (verbose) { printf("%s:%d n=%d\n", __FUNCTION__, __LINE__, N); fflush(stdout); }
const int test_limit = N;
......@@ -112,9 +109,8 @@ static void checkpoint_pending(void) {
char fname1[] = __SRCFILE__ "test1.dat";
r = unlink(fname1); if (r!=0) CKERR2(get_error_errno(), ENOENT);
r = toku_cachetable_openf(&cf, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
toku_cachefile_set_userdata(cf, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dummy_pin_unpin, dummy_pin_unpin);
create_dummy_functions(cf);
// Insert items into the cachetable. All dirty.
int i;
for (i=0; i<N; i++) {
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
uint64_t clean_val = 0;
uint64_t dirty_val = 0;
......@@ -72,6 +73,7 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
void* v2;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
uint64_t clean_val = 0;
uint64_t dirty_val = 0;
......@@ -74,6 +75,7 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
bool doing_prefetch = false;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(&dirty_val);
......
......@@ -3,6 +3,7 @@
#ident "$Id$"
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "test.h"
#include "cachetable-test.h"
#include <stdio.h>
#include <unistd.h>
......@@ -54,10 +55,6 @@ static void checkpoint_callback2(void * extra) {
// put n items into the cachetable, maybe mark them dirty, do a checkpoint, and
// verify that all of the items have been written and are clean.
static int dummy_pin_unpin(CACHEFILE UU(cfu), void* UU(v)) {
return 0;
}
static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
if (verbose) printf("%s:%d n=%d dirty=%d\n", __FUNCTION__, __LINE__, n, (int) dirty);
const int test_limit = n;
......@@ -68,9 +65,8 @@ static void cachetable_checkpoint_test(int n, enum cachetable_dirty dirty) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
toku_cachefile_set_userdata(f1, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dummy_pin_unpin, dummy_pin_unpin);
create_dummy_functions(f1);
// insert items into the cachetable. all should be dirty
int i;
for (i=0; i<n; i++) {
......
......@@ -6,6 +6,7 @@
#include "includes.h"
#include "test.h"
#include "cachetable-internal.h"
#include "cachetable-test.h"
//
// Wrapper for the checkpointer and necessary
......@@ -27,47 +28,6 @@ struct checkpointer_test {
uint32_t k);
};
//
// Dummy callbacks for checkpointing
//
static int dummy_log_fassociate(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_log_rollback(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_close_usr(CACHEFILE UU(cf), int UU(i), void* UU(p), char** UU(c), bool UU(b), LSN UU(lsn))
{ return 0; }
static int dummy_chckpnt_usr(CACHEFILE UU(cf), int UU(i), void* UU(p))
{ return 0; }
static int dummy_begin(LSN UU(lsn), void* UU(p))
{ return 0; }
static int dummy_end(CACHEFILE UU(cf), int UU(i), void* UU(p))
{ return 0; }
static int dummy_note_pin(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_note_unpin(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
//
// Helper function to set dummy functions in given cachefile.
//
static void
create_dummy_functions(CACHEFILE cf)
{
void *ud = NULL;
toku_cachefile_set_userdata (cf,
ud,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
&dummy_chckpnt_usr,
&dummy_begin,
&dummy_end,
&dummy_note_pin,
&dummy_note_unpin);
}
//------------------------------------------------------------------------------
// test_begin_checkpoint() -
//
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
CACHEFILE f1;
......@@ -66,6 +67,7 @@ cachetable_test (void) {
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
//void* v2;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
CACHEFILE f1;
......@@ -66,6 +67,7 @@ cachetable_test (void) {
char fname1[] = __SRCFILE__ "test1.dat";
unlink(fname1);
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
//void* v2;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
//
// simple tests for cleaner thread with an empty cachetable
......@@ -21,7 +22,8 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
usleep(4000000);
CHECKPOINTER cp = toku_cachetable_get_checkpointer(ct);
r = toku_cachetable_begin_checkpoint(cp, NULL); assert(r == 0);
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
static void
clone_callback(void* UU(value_data), void** cloned_value_data, PAIR_ATTR* new_attr, bool UU(for_checkpoint), void* UU(write_extraargs))
......@@ -65,7 +65,8 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool flush_completed;
bool pf_called;
......@@ -58,7 +58,8 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool flush_completed;
bool pf_called;
......@@ -63,7 +63,8 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,6 +4,8 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
static void
clone_callback(void* UU(value_data), void** cloned_value_data, PAIR_ATTR* new_attr, bool UU(for_checkpoint), void* UU(write_extraargs))
......@@ -43,7 +45,8 @@ cachetable_test (enum cachetable_dirty dirty, bool cloneable) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool flush_completed;
bool evict_called;
......@@ -56,7 +56,8 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
//
// This test ensures that get_and_pin with dependent nodes works
......@@ -344,14 +344,14 @@ cachetable_test (void) {
toku_cachefile_set_userdata(
f1,
NULL,
NULL,
NULL,
NULL,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
dummy_int_checkpoint_userdata,
test_begin_checkpoint, // called in begin_checkpoint
dummy_int_checkpoint_userdata,
NULL,
NULL
&dummy_note_pin,
&dummy_note_unpin
);
toku_pthread_t time_tid;
......
......@@ -4,12 +4,12 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
CACHETABLE ct;
CACHEFILE f1;
static void
run_test (void) {
const int test_limit = 20;
......@@ -20,7 +20,8 @@ run_test (void) {
unlink(fname1);
f1 = NULL;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
void* v2;
long s1;
......
......@@ -8,7 +8,7 @@
#include "test.h"
#include <stdio.h>
#include <unistd.h>
#include "cachetable-test.h"
#include "checkpoint.h"
......@@ -59,9 +59,6 @@ static int fetch(
return 0;
}
static int dummy_pin_unpin(CACHEFILE UU(cfu), void* UU(v)) {
return 0;
}
// put n items into the cachetable, maybe mark them dirty, do a checkpoint, and
// verify that all of the items have been written and are clean.
static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dirty) {
......@@ -76,8 +73,7 @@ static void cachetable_prefetch_checkpoint_test(int n, enum cachetable_dirty dir
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
toku_cachefile_set_userdata(f1, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
dummy_pin_unpin, dummy_pin_unpin);
create_dummy_functions(f1);
// prefetch block n+1. this will take 10 seconds.
{
......
......@@ -4,7 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
//
// This test ensures that get_and_pin with dependent nodes works
......@@ -478,14 +478,14 @@ cachetable_test (void) {
toku_cachefile_set_userdata(
f1,
NULL,
NULL,
NULL,
NULL,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
dummy_int_checkpoint_userdata,
test_begin_checkpoint, // called in begin_checkpoint
dummy_int_checkpoint_userdata,
NULL,
NULL
&dummy_note_pin,
&dummy_note_unpin
);
toku_pthread_t time_tid;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool clone_called;
bool check_flush;
......@@ -68,7 +69,8 @@ test_clean (enum cachetable_dirty dirty, bool cloneable) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool clone_called;
bool check_flush;
......@@ -55,6 +56,7 @@ test_clean (enum cachetable_dirty dirty, bool cloneable) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
check_flush = false;
void* v1;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
//
// simple tests for maybe_get_and_pin(_clean)
......@@ -19,6 +20,7 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
void* v1;
......
......@@ -4,8 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool v1_written;
uint64_t val1;
......@@ -14,7 +13,6 @@ uint64_t val2;
uint64_t val3;
bool check_me;
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
......@@ -76,6 +74,7 @@ cachetable_test (bool write_first, bool write_second, bool start_checkpoint) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
void* v2;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool foo;
......@@ -66,7 +67,7 @@ run_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
long s1;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool foo;
bool check_me;
......@@ -58,7 +59,8 @@ run_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
//void* v2;
long s1;
......
......@@ -4,8 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
bool v1_written;
uint64_t val1;
......@@ -14,7 +13,6 @@ uint64_t val2;
uint64_t val3;
bool check_me;
static void
flush (CACHEFILE f __attribute__((__unused__)),
int UU(fd),
......@@ -83,7 +81,8 @@ cachetable_test (bool write_first, bool write_second, bool start_checkpoint) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);//toku_cachefile_set_userdata(ft, NULL, NULL,
void* v1;
void* v2;
long s1;
......
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
static void remove_key_expect_checkpoint(
CACHEKEY* UU(cachekey),
......@@ -33,6 +34,7 @@ cachetable_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
void* v1;
//void* v2;
......
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
#ident "$Id: cachetable-checkpointer_test.cc 45903 2012-07-19 13:06:39Z leifwalsh $"
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "cachetable-internal.h"
//
// Dummy callbacks for checkpointing
//
static int dummy_log_fassociate(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_log_rollback(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_close_usr(CACHEFILE UU(cf), int UU(i), void* UU(p), char** UU(c), bool UU(b), LSN UU(lsn))
{ return 0; }
static int dummy_chckpnt_usr(CACHEFILE UU(cf), int UU(i), void* UU(p))
{ return 0; }
static int dummy_begin(LSN UU(lsn), void* UU(p))
{ return 0; }
static int dummy_end(CACHEFILE UU(cf), int UU(i), void* UU(p))
{ return 0; }
static int dummy_note_pin(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
static int dummy_note_unpin(CACHEFILE UU(cf), void* UU(p))
{ return 0; }
//
// Helper function to set dummy functions in given cachefile.
//
static UU() void
create_dummy_functions(CACHEFILE cf)
{
void *ud = NULL;
toku_cachefile_set_userdata (cf,
ud,
&dummy_log_fassociate,
&dummy_log_rollback,
&dummy_close_usr,
&dummy_chckpnt_usr,
&dummy_begin,
&dummy_end,
&dummy_note_pin,
&dummy_note_unpin);
};
\ No newline at end of file
......@@ -4,6 +4,7 @@
#ident "Copyright (c) 2007-2012 Tokutek Inc. All rights reserved."
#include "includes.h"
#include "test.h"
#include "cachetable-test.h"
CACHETABLE ct;
......@@ -34,7 +35,8 @@ run_test (void) {
unlink(fname1);
CACHEFILE f1;
r = toku_cachetable_openf(&f1, ct, fname1, O_RDWR|O_CREAT, S_IRWXU|S_IRWXG|S_IRWXO); assert(r == 0);
create_dummy_functions(f1);
CACHETABLE_WRITE_CALLBACK wc = def_write_callback(NULL);
void* v1;
//void* v2;
......
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