Fennel: BTreeTxnTest Class Reference (original) (raw)
Inheritance diagram for BTreeTxnTest:

| Public Member Functions | |
|---|---|
| BTreeTxnTest () | |
| virtual void | testCaseSetUp () |
| Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked. | |
| virtual void | testCaseTearDown () |
| Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
| virtual void | threadInit () |
| virtual void | threadTerminate () |
| virtual bool | testThreadedOp (int iOp) |
| Test implementation must be supplied by derived test class. | |
| TestSuite * | releaseTestSuite () |
| void | beforeTestCase (std::string testCaseName) |
| void | afterTestCase (std::string testCaseName) |
| virtual void | notifyTrace (std::string source, TraceLevel level, std::string message) |
| Receives notification when a trace event occurs. | |
| virtual TraceLevel | getSourceTraceLevel (std::string source) |
| Gets the level at which a particular source should be traced. | |
| Static Public Member Functions | |
| static void | readParams (int argc, char **argv) |
| Parses the command line. | |
| Static Public Attributes | |
| static ParamName | paramTestSuiteName |
| static ParamName | paramTraceFileName |
| static ParamName | paramDictionaryFileName |
| static ParamName | paramTraceLevel |
| static ParamName | paramStatsFileName |
| static ParamName | paramTraceStdout |
| static ParamName | paramDegreeOfParallelism |
| static ConfigMap | configMap |
| Configuration parameters. | |
| Protected Member Functions | |
| void | runThreadedTestCase () |
| Executes specified test threads. | |
| void | snooze (uint nSeconds) |
| Protected Attributes | |
| uint | nSeconds |
| Duration of multi-threaded test. | |
| std::vector< int > | threadCounts |
| Number of threads to run for each type of operation. | |
| TestSuite * | pTestSuite |
| Boost test suite. | |
| boost::shared_ptr< TestBase > | pTestObj |
| std::ofstream | traceStream |
| Output file stream for tracing. | |
| StrictMutex | traceMutex |
| Protects traceStream. | |
| std::string | testName |
| Name of test. | |
| TraceLevel | traceLevel |
| Level at which to trace test execution. | |
| FileStatsTarget | statsTarget |
| Output for stats. | |
| StatsTimer | statsTimer |
| Timer for stats collection. | |
| bool | traceStdout |
| Copy trace output to stdout. | |
| bool | traceFile |
| Copy trace output to file. | |
| TestCaseGroup | defaultTests |
| TestCaseGroup | extraTests |
| Static Protected Attributes | |
| static bool | runAll |
| Run all test cases, including the extra tests. | |
| static std::string | runSingle |
| Run only the test case of this name. | |
| Private Types | |
| enum | OpType { OP_INSERT, OP_DELETE, OP_SCAN, OP_CHECKPOINT, OP_MAX } |
| The various operations that can be run in the multi-threaded test. More... | |
| Private Member Functions | |
| void | testTxns () |
| void | insertTxn () |
| void | deleteTxn () |
| void | scanTxn () |
| void | testCheckpoint () |
| void | endTxn (SharedLogicalTxn pTxn) |
| uint | generateRandomNumber (uint iMax) |
| void | createTree () |
| RecordNum | verifyTree () |
| BTreeReader & | getReader () |
| BTreeWriter & | getWriter () |
| TupleData & | getKeyData () |
| void | bindKey (int32_t &key) |
| Private Attributes | |
| SharedCache | pCache |
| SharedDatabase | pDatabase |
| BTreeDescriptor | treeDescriptor |
| boost::thread_specific_ptr< TestThreadData > | pTestThreadData |
| PageId | rootPageId |
| bool | testRollback |
| uint | iKeyMax |
| uint | nInsertsPerTxn |
| uint | nDeletesPerTxn |
| uint | nKeysPerScan |
| uint | nSecondsBetweenCheckpoints |
| Classes | |
| struct | Record |
| struct | TestThreadData |
Detailed Description
Definition at line 49 of file BTreeTxnTest.cpp.
Member Enumeration Documentation
The various operations that can be run in the multi-threaded test.
Enumerator:
| OP_INSERT | | | ---------------- | | | OP_DELETE | | | OP_SCAN | | | OP_CHECKPOINT | | | OP_MAX | |
Definition at line 63 of file BTreeTxnTest.cpp.
Constructor & Destructor Documentation
| BTreeTxnTest::BTreeTxnTest | ( | | ) | [explicit] | | -------------------------- | - | | - | ------------ |
Definition at line 123 of file BTreeTxnTest.cpp.
References TestBase::configMap, ConfigMap::getIntParam(), iKeyMax, nDeletesPerTxn, nInsertsPerTxn, nKeysPerScan, ThreadedTestBase::nSeconds, nSecondsBetweenCheckpoints, OP_CHECKPOINT, OP_DELETE, OP_INSERT, OP_MAX, OP_SCAN, testRollback, testTxns(), and ThreadedTestBase::threadCounts.
00124 { 00125 nInsertsPerTxn = configMap.getIntParam("insertsPerTxn",5); 00126 nDeletesPerTxn = configMap.getIntParam("deletesPerTxn",5); 00127 nKeysPerScan = configMap.getIntParam("keysPerScan",5); 00128 iKeyMax = configMap.getIntParam("maxKey",1000000); 00129 nSecondsBetweenCheckpoints = configMap.getIntParam("checkpointInterval",20); 00130 testRollback = configMap.getIntParam( 00131 "testRollback",1); 00132 00133 threadCounts.resize(OP_MAX,-1); 00134 00135 threadCounts[OP_INSERT] = configMap.getIntParam( 00136 "insertThreads",-1); 00137 threadCounts[OP_DELETE] = configMap.getIntParam( 00138 "deleteThreads",-1); 00139 threadCounts[OP_SCAN] = configMap.getIntParam( 00140 "scanThreads",-1); 00141 00142 if (nSecondsBetweenCheckpoints < nSeconds) { 00143 threadCounts[OP_CHECKPOINT] = 1; 00144 } else { 00145 threadCounts[OP_CHECKPOINT] = 0; 00146 } 00147 00148 FENNEL_UNIT_TEST_CASE(BTreeTxnTest,testTxns); 00149 }
Member Function Documentation
| void BTreeTxnTest::testTxns | ( | | ) | [private] | | --------------------------- | - | | - | ----------- |
Definition at line 259 of file BTreeTxnTest.cpp.
References StatsTimer::addSource(), CHECKPOINT_DISCARD, TestBase::configMap, DeviceMode::load, Database::newDatabase(), pCache, pDatabase, SegmentAccessor::pSegment, SegmentAccessor::reset(), ThreadedTestBase::runThreadedTestCase(), BTreeDescriptor::segmentAccessor, StatsTimer::start(), TestBase::statsTimer, StatsTimer::stop(), treeDescriptor, and verifyTree().
Referenced by BTreeTxnTest().
| void BTreeTxnTest::insertTxn | ( | | ) | [private] | | ---------------------------- | - | | - | ----------- |
| void BTreeTxnTest::deleteTxn | ( | | ) | [private] | | ---------------------------- | - | | - | ----------- |
Definition at line 319 of file BTreeTxnTest.cpp.
References bindKey(), BTreeWriter::deleteCurrent(), DUP_SEEK_ANY, BTreeReader::endSearch(), endTxn(), generateRandomNumber(), getKeyData(), getWriter(), iKeyMax, nDeletesPerTxn, pCache, pDatabase, pTestThreadData, and BTreeReader::searchForKey().
Referenced by testThreadedOp().
| void BTreeTxnTest::scanTxn | ( | | ) | [private] | | -------------------------- | - | | - | ----------- |
| void BTreeTxnTest::testCheckpoint | ( | | ) | [private] | | --------------------------------- | - | | - | ----------- |
| uint BTreeTxnTest::generateRandomNumber | ( | uint | iMax | ) | [private] |
|---|
| void BTreeTxnTest::createTree | ( | | ) | [private] | | ----------------------------- | - | | - | ----------- |
Definition at line 193 of file BTreeTxnTest.cpp.
References BTreeDescriptor::keyProjection, StandardTypeDescriptorFactory::newDataType(), pCache, SegmentAccessor::pCacheAccessor, pDatabase, SegmentAccessor::pSegment, rootPageId, BTreeDescriptor::rootPageId, BTreeDescriptor::segmentAccessor, STANDARD_TYPE_INT_32, treeDescriptor, and BTreeDescriptor::tupleDescriptor.
Referenced by testCaseSetUp().
| RecordNum BTreeTxnTest::verifyTree | ( | | ) | [private] | | -------------------------------------------------------------------------------------- | - | | - | ----------- |
| TupleData & BTreeTxnTest::getKeyData | ( | | ) | [private] | | ----------------------------------------------------------- | - | | - | ----------- |
| void BTreeTxnTest::bindKey | ( | int32_t & | key | ) | [private] |
|---|
| void BTreeTxnTest::testCaseSetUp | ( | | ) | [virtual] | | -------------------------------- | - | | - | ----------- |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
Default is no-op.
Reimplemented from TestBase.
Definition at line 151 of file BTreeTxnTest.cpp.
References StatsTimer::addSource(), TestBase::configMap, DeviceMode::createNew, createTree(), ConfigMap::isParamSet(), Cache::newCache(), Database::newDatabase(), NULL_PAGE_ID, Database::paramDatabaseDir, pCache, pDatabase, CacheParams::readConfig(), rootPageId, ConfigMap::setStringParam(), StatsTimer::start(), and TestBase::statsTimer.
| void BTreeTxnTest::testCaseTearDown | ( | | ) | [virtual] | | ----------------------------------- | - | | - | ----------- |
| void BTreeTxnTest::threadInit | ( | | ) | [virtual] | | ----------------------------- | - | | - | ----------- |
| void BTreeTxnTest::threadTerminate | ( | | ) | [virtual] | | ---------------------------------- | - | | - | ----------- |
| bool BTreeTxnTest::testThreadedOp | ( | int | iOp | ) | [virtual] |
|---|
Test implementation must be supplied by derived test class.
Parameters:
| iOp | operation type to test |
|---|
Returns:
true if test should run again
Implements ThreadedTestBase.
Definition at line 363 of file BTreeTxnTest.cpp.
References deleteTxn(), insertTxn(), OP_CHECKPOINT, OP_DELETE, OP_INSERT, OP_MAX, OP_SCAN, pDatabase, scanTxn(), and testCheckpoint().
00364 { 00365 SXMutexSharedGuard checkpointSharedGuard( 00366 pDatabase->getCheckpointThread()->getActionMutex(),false); 00367 assert(iOp < OP_MAX); 00368 OpType op = static_cast(iOp); 00369 switch (op) { 00370 case OP_INSERT: 00371 checkpointSharedGuard.lock(); 00372 insertTxn(); 00373 break; 00374 case OP_DELETE: 00375 checkpointSharedGuard.lock(); 00376 deleteTxn(); 00377 break; 00378 case OP_SCAN: 00379 scanTxn(); 00380 break; 00381 case OP_CHECKPOINT: 00382 testCheckpoint(); 00383 break; 00384 default: 00385 permAssert(false); 00386 } 00387 return true; 00388 }
| void ThreadedTestBase::runThreadedTestCase | ( | | ) | [protected, inherited] | | ------------------------------------------ | - | | - | ------------------------ |
| void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
|---|
| void TestBase::readParams | ( | int | argc, |
|---|---|---|---|
| char ** | argv | ||
| ) | [static, inherited] |
Parses the command line.
format: [-v] [-t TEST | -all] {param=val}* [CONFIGFILE | -] Normally, the test program runs the default test cases. With the option "-all", runs the extra test cases as well. With the option "-t TEST", runs only the single test case named TEST. CONFIGFILE is read to load configuration parameters. Configuration parameters can also be set ad hoc, from the command line, as pairs name=val. These take precedence.
Definition at line 108 of file TestBase.cpp.
References TestBase::configMap, ConfigMap::dumpParams(), ConfigMap::isParamSet(), ConfigMap::mergeFrom(), TestBase::paramDictionaryFileName, ConfigMap::readParams(), TestBase::runAll, TestBase::runSingle, ConfigMap::setStringParam(), and verbose.
00109 {
00110 bool verbose = false;
00111 ConfigMap adhocMap;
00112
00113 for (int i = 1; i < argc; ++i) {
00114 std::string arg = argv[i];
00115 if (argv[i][0] == '-') {
00116 if (arg == "-v") {
00117 verbose = true;
00118 } else if (arg == "-") {
00119 configMap.readParams(std::cin);
00120 } else if (arg == "-all") {
00121 runAll = true;
00122 } else if (arg == "-t") {
00123 permAssert(i + 1 < argc);
00124 runSingle = argv[++i];
00125 } else if (arg[1] == 't') {
00126 runSingle = arg.substr(2);
00127 }
00128 } else {
00129 int i = arg.find("=");
00130 if ((0 < i) && (i < arg.size())) {
00131
00132 std::string key = arg.substr(0,i);
00133 std::string val = arg.substr(i + 1);
00134 adhocMap.setStringParam(key,val);
00135 } else {
00136
00137 std::ifstream configFile(arg.c_str());
00138 assert(configFile.good());
00139 configMap.readParams(configFile);
00140 }
00141 }
00142 }
00143 configMap.mergeFrom(adhocMap);
00144
00145
00146
00147 if (.isParamSet(paramDictionaryFileName)) {
00148 std::string dictFileName = "dictWords";
00149 configMap.setStringParam(paramDictionaryFileName,dictFileName);
00150 }
00151
00152 if (verbose) {
00153 configMap.dumpParams(std::cout);
00154 }
00155 }
| TestSuite * TestBase::releaseTestSuite | ( | | ) | [inherited] | | ---------------------------------------------------------------------------------------------- | - | | - | ------------- |
| void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
|---|
| void TestBase::notifyTrace | ( | std::string | source, |
|---|---|---|---|
| TraceLevel | level, | ||
| std::string | message | ||
| ) | [virtual, inherited] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
|---|
Member Data Documentation
Configuration parameters.
The reason this is static is so that no constructor parameters (which burden virtual bases) are needed.
Definition at line 155 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest::DatabaseTest(), TestOptionsTest::extra(), DatabaseTest::loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), testCaseSetUp(), testCheckpoint(), DatabaseTest::testCreateEmpty(), DatabaseTest::testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().
The documentation for this class was generated from the following file:
- /home/pub/open/dev/fennel/test/BTreeTxnTest.cpp
