Inheritance diagram for DatabaseTest:
Public Member Functions | |
DatabaseTest () | |
virtual | ~DatabaseTest () |
virtual void | testCaseTearDown () |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked. | |
void | testCreateEmpty () |
void | testLoadEmpty () |
void | testRecoverEmpty () |
void | testCreateData () |
void | testLoadData () |
void | testRecoverData (bool) |
void | testRecoverDataFromCheckpoint (CheckpointType) |
void | testRecoverDataFromCheckpoint () |
void | testRecoverDataFromFuzzyCheckpoint () |
void | testRecoverDataFromRollback () |
void | testRecoverDataWithFlush () |
void | testRecoverDataWithoutFlush () |
void | testForceTxns () |
void | executeForceTxn () |
virtual LogicalTxnClassId | getParticipantClassId () const |
| |
virtual void | describeParticipant (ByteOutputStream &logStream) |
Called by LogicalTxn the first time an action is logged for this participant. | |
virtual void | redoLogicalAction (LogicalActionType actionType, ByteInputStream &logStream) |
Performs redo for one logical action during recovery. | |
virtual void | undoLogicalAction (LogicalActionType actionType, ByteInputStream &logStream) |
Performs undo for one logical action during rollback or recovery. | |
virtual SharedLogicalTxnParticipant | loadParticipant (LogicalTxnClassId classId, ByteInputStream &logStream) |
Recovers a LogicalTxnParticipant from the log. | |
TestSuite * | releaseTestSuite () |
void | beforeTestCase (std::string testCaseName) |
void | afterTestCase (std::string testCaseName) |
virtual void | testCaseSetUp () |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked. | |
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 | snooze (uint nSeconds) |
LogicalTxn * | getLogicalTxn () |
| |
bool | isLoggingEnabled () const |
| |
Protected Attributes | |
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 | |
typedef SegNodeLock< TestNode > | TestPageLock |
Private Member Functions | |
void | loadDatabase () |
void | executeIncrementAction (int i) |
void | executeIncrementAction (int i, LogicalActionType action) |
void | executeIncrementTxn (int i) |
void | executeCheckpointedTxn (int i, int j, bool commit, CheckpointType=CHECKPOINT_FLUSH_ALL) |
void | verifyData (uint x) |
PageId | writeData (uint x) |
void | addTxnParticipant (SharedLogicalTxn) |
Private Attributes | |
SharedCache | pCache |
SharedDatabase | pDatabase |
PageId | persistentPageId |
Static Private Attributes | |
static const LogicalActionType | ACTION_INCREMENT |
static const LogicalActionType | ACTION_INCREMENT_FORCE |
Classes | |
struct | TestNode |
Definition at line 43 of file DatabaseTest.cpp.
typedef SegNodeLock<TestNode> DatabaseTest::TestPageLock [private] |
Definition at line 59 of file DatabaseTest.cpp.
DatabaseTest::DatabaseTest | ( | ) | [inline, explicit] |
Definition at line 76 of file DatabaseTest.cpp.
References TestBase::configMap, Cache::newCache(), Database::paramDatabaseDir, pCache, CacheParams::readConfig(), ConfigMap::setStringParam(), testCreateData(), testCreateEmpty(), testForceTxns(), testLoadData(), testLoadEmpty(), testRecoverDataFromCheckpoint(), testRecoverDataFromFuzzyCheckpoint(), testRecoverDataFromRollback(), testRecoverDataWithFlush(), testRecoverDataWithoutFlush(), and testRecoverEmpty().
00077 { 00078 configMap.setStringParam( 00079 Database::paramDatabaseDir,"."); 00080 configMap.setStringParam( 00081 "databaseInitSize","1000"); 00082 configMap.setStringParam( 00083 "tempInitSize","1000"); 00084 configMap.setStringParam( 00085 "databaseShadowLogInitSize","1000"); 00086 configMap.setStringParam( 00087 "databaseTxnLogInitSize","1000"); 00088 00089 CacheParams cacheParams; 00090 cacheParams.readConfig(configMap); 00091 pCache = Cache::newCache(cacheParams); 00092 00093 // FIXME jvs 6-Mar-2006: some of these tests depend on 00094 // being run in this sequence; make each test self-contained 00095 00096 FENNEL_UNIT_TEST_CASE(DatabaseTest,testCreateEmpty); 00097 FENNEL_UNIT_TEST_CASE(DatabaseTest,testLoadEmpty); 00098 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverEmpty); 00099 FENNEL_UNIT_TEST_CASE(DatabaseTest,testCreateData); 00100 FENNEL_UNIT_TEST_CASE(DatabaseTest,testLoadData); 00101 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverDataWithFlush); 00102 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverDataWithoutFlush); 00103 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverDataFromCheckpoint); 00104 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverDataFromFuzzyCheckpoint); 00105 FENNEL_UNIT_TEST_CASE(DatabaseTest,testRecoverDataFromRollback); 00106 00107 FENNEL_UNIT_TEST_CASE(DatabaseTest,testForceTxns); 00108 }
virtual DatabaseTest::~DatabaseTest | ( | ) | [inline, virtual] |
void DatabaseTest::loadDatabase | ( | ) | [private] |
Definition at line 309 of file DatabaseTest.cpp.
References TestBase::configMap, DeviceMode::load, Database::newDatabase(), pCache, and pDatabase.
Referenced by testForceTxns(), testLoadEmpty(), testRecoverData(), testRecoverDataFromCheckpoint(), testRecoverDataFromRollback(), and testRecoverEmpty().
00310 { 00311 pDatabase = Database::newDatabase( 00312 pCache, 00313 configMap, 00314 DeviceMode::load, 00315 shared_from_this()); 00316 }
void DatabaseTest::executeIncrementAction | ( | int | i | ) | [private] |
Definition at line 368 of file DatabaseTest.cpp.
References ACTION_INCREMENT.
Referenced by executeCheckpointedTxn(), executeForceTxn(), and executeIncrementTxn().
00369 { 00370 executeIncrementAction(i, ACTION_INCREMENT); 00371 }
void DatabaseTest::executeIncrementAction | ( | int | i, | |
LogicalActionType | action | |||
) | [private] |
Definition at line 373 of file DatabaseTest.cpp.
References LogicalTxn::beginLogicalAction(), LogicalTxn::endLogicalAction(), LogicalTxnParticipant::getLogicalTxn(), pCache, pDatabase, persistentPageId, and ByteOutputStream::writeValue().
00374 { 00375 ByteOutputStream &logStream = 00376 getLogicalTxn()->beginLogicalAction(*this,action); 00377 logStream.writeValue(i); 00378 getLogicalTxn()->endLogicalAction(); 00379 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00380 TestPageLock pageLock(segmentAccessor); 00381 pageLock.lockExclusive(persistentPageId); 00382 pageLock.getNodeForWrite().x += i; 00383 }
void DatabaseTest::executeIncrementTxn | ( | int | i | ) | [private] |
Definition at line 392 of file DatabaseTest.cpp.
References addTxnParticipant(), executeIncrementAction(), pCache, pDatabase, and LogicalTxnParticipant::pTxn.
Referenced by testCreateData(), testRecoverData(), testRecoverDataFromCheckpoint(), and testRecoverDataFromRollback().
00393 { 00394 SharedLogicalTxn pTxn = pDatabase->getTxnLog()->newLogicalTxn(pCache); 00395 addTxnParticipant(pTxn); 00396 executeIncrementAction(i); 00397 pTxn->commit(); 00398 }
void DatabaseTest::executeCheckpointedTxn | ( | int | i, | |
int | j, | |||
bool | commit, | |||
CheckpointType | = CHECKPOINT_FLUSH_ALL | |||
) | [private] |
Definition at line 400 of file DatabaseTest.cpp.
References addTxnParticipant(), executeIncrementAction(), pCache, pDatabase, and LogicalTxnParticipant::pTxn.
Referenced by testRecoverDataFromCheckpoint(), and testRecoverDataFromRollback().
00402 { 00403 SharedLogicalTxn pTxn = pDatabase->getTxnLog()->newLogicalTxn(pCache); 00404 addTxnParticipant(pTxn); 00405 executeIncrementAction(i); 00406 pDatabase->checkpointImpl(checkpointType); 00407 executeIncrementAction(j); 00408 if (commit) { 00409 pTxn->commit(); 00410 } else { 00411 pTxn->rollback(); 00412 } 00413 }
void DatabaseTest::verifyData | ( | uint | x | ) | [private] |
Definition at line 415 of file DatabaseTest.cpp.
References pCache, pDatabase, and persistentPageId.
Referenced by executeForceTxn(), testForceTxns(), testLoadData(), testRecoverData(), testRecoverDataFromCheckpoint(), and testRecoverDataFromRollback().
00416 { 00417 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00418 TestPageLock pageLock(segmentAccessor); 00419 pageLock.lockShared(persistentPageId); 00420 BOOST_CHECK_EQUAL(pageLock.getNodeForRead().x,x); 00421 }
PageId DatabaseTest::writeData | ( | uint | x | ) | [private] |
Definition at line 423 of file DatabaseTest.cpp.
References pCache, and pDatabase.
Referenced by testCreateData(), and testForceTxns().
00424 { 00425 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00426 TestPageLock pageLock(segmentAccessor); 00427 PageId pageId = pageLock.allocatePage(); 00428 pageLock.getNodeForWrite().x = x; 00429 pageLock.unlock(); 00430 return pageId; 00431 }
void DatabaseTest::addTxnParticipant | ( | SharedLogicalTxn | ) | [private] |
Definition at line 385 of file DatabaseTest.cpp.
Referenced by executeCheckpointedTxn(), executeForceTxn(), and executeIncrementTxn().
00386 { 00387 pTxn->addParticipant( 00388 boost::dynamic_pointer_cast<LogicalTxnParticipant>( 00389 shared_from_this())); 00390 }
virtual void DatabaseTest::testCaseTearDown | ( | ) | [inline, virtual] |
Equivalent to JUnit TestCase.tearDown; this is called after each test case method is invoked.
Default is no-op.
Reimplemented from TestBase.
Definition at line 114 of file DatabaseTest.cpp.
References pDatabase.
00115 { 00116 pDatabase.reset(); 00117 }
void DatabaseTest::testCreateEmpty | ( | ) |
Definition at line 156 of file DatabaseTest.cpp.
References TestBase::configMap, DeviceMode::createNew, Database::newDatabase(), pCache, and pDatabase.
Referenced by DatabaseTest(), testCreateData(), and testRecoverEmpty().
00157 { 00158 pDatabase = Database::newDatabase( 00159 pCache, 00160 configMap, 00161 DeviceMode::createNew, 00162 shared_from_this()); 00163 BOOST_CHECK(!pDatabase->isRecoveryRequired()); 00164 }
void DatabaseTest::testLoadEmpty | ( | ) |
Definition at line 174 of file DatabaseTest.cpp.
References loadDatabase(), and pDatabase.
Referenced by DatabaseTest(), and testLoadData().
00175 { 00176 loadDatabase(); 00177 BOOST_CHECK(!pDatabase->isRecoveryRequired()); 00178 }
void DatabaseTest::testRecoverEmpty | ( | ) |
Definition at line 186 of file DatabaseTest.cpp.
References CHECKPOINT_DISCARD, loadDatabase(), pDatabase, and testCreateEmpty().
Referenced by DatabaseTest().
00187 { 00188 testCreateEmpty(); 00189 // Flush the pages that have been created in the empty db, 00190 // then discard the checkpoint to simulate a crash 00191 pDatabase->checkpointImpl(); 00192 pDatabase->checkpointImpl(CHECKPOINT_DISCARD); 00193 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00194 pDatabase.reset(); 00195 loadDatabase(); 00196 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00197 pDatabase->recover(*this); 00198 }
void DatabaseTest::testCreateData | ( | ) |
Definition at line 166 of file DatabaseTest.cpp.
References executeIncrementTxn(), pDatabase, persistentPageId, testCreateEmpty(), and writeData().
Referenced by DatabaseTest(), testForceTxns(), testRecoverData(), testRecoverDataFromCheckpoint(), and testRecoverDataFromRollback().
00167 { 00168 testCreateEmpty(); 00169 persistentPageId = writeData(0); 00170 pDatabase->checkpointImpl(); 00171 executeIncrementTxn(5); 00172 }
void DatabaseTest::testLoadData | ( | ) |
Definition at line 180 of file DatabaseTest.cpp.
References testLoadEmpty(), and verifyData().
Referenced by DatabaseTest().
00181 { 00182 testLoadEmpty(); 00183 verifyData(5); 00184 }
void DatabaseTest::testRecoverData | ( | bool | ) |
Definition at line 210 of file DatabaseTest.cpp.
References CHECKPOINT_DISCARD, executeIncrementTxn(), loadDatabase(), pDatabase, testCreateData(), and verifyData().
Referenced by testRecoverDataWithFlush(), and testRecoverDataWithoutFlush().
00211 { 00212 testCreateData(); 00213 executeIncrementTxn(10); 00214 executeIncrementTxn(30); 00215 if (flush) { 00216 pDatabase->getDataSegment()->checkpoint(); 00217 } 00218 pDatabase->checkpointImpl(CHECKPOINT_DISCARD); 00219 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00220 pDatabase.reset(); 00221 loadDatabase(); 00222 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00223 pDatabase->recover(*this); 00224 verifyData(45); 00225 }
void DatabaseTest::testRecoverDataFromCheckpoint | ( | CheckpointType | ) |
Definition at line 227 of file DatabaseTest.cpp.
References CHECKPOINT_DISCARD, executeCheckpointedTxn(), executeIncrementTxn(), loadDatabase(), pDatabase, testCreateData(), and verifyData().
00228 { 00229 testCreateData(); 00230 executeIncrementTxn(10); 00231 executeCheckpointedTxn(25,70,true,checkpointType); 00232 pDatabase->checkpointImpl(CHECKPOINT_DISCARD); 00233 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00234 pDatabase.reset(); 00235 loadDatabase(); 00236 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00237 pDatabase->recover(*this); 00238 verifyData(110); 00239 }
void DatabaseTest::testRecoverDataFromCheckpoint | ( | ) |
Definition at line 241 of file DatabaseTest.cpp.
References CHECKPOINT_FLUSH_ALL.
Referenced by DatabaseTest(), and testRecoverDataFromFuzzyCheckpoint().
00242 { 00243 testRecoverDataFromCheckpoint(CHECKPOINT_FLUSH_ALL); 00244 }
void DatabaseTest::testRecoverDataFromFuzzyCheckpoint | ( | ) |
Definition at line 246 of file DatabaseTest.cpp.
References CHECKPOINT_FLUSH_FUZZY, and testRecoverDataFromCheckpoint().
Referenced by DatabaseTest().
00247 { 00248 testRecoverDataFromCheckpoint(CHECKPOINT_FLUSH_FUZZY); 00249 }
void DatabaseTest::testRecoverDataFromRollback | ( | ) |
Definition at line 251 of file DatabaseTest.cpp.
References CHECKPOINT_DISCARD, executeCheckpointedTxn(), executeIncrementTxn(), loadDatabase(), pDatabase, testCreateData(), and verifyData().
Referenced by DatabaseTest().
00252 { 00253 testCreateData(); 00254 executeIncrementTxn(10); 00255 executeCheckpointedTxn(25,70,false); 00256 pDatabase->checkpointImpl(CHECKPOINT_DISCARD); 00257 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00258 pDatabase.reset(); 00259 loadDatabase(); 00260 BOOST_CHECK(pDatabase->isRecoveryRequired()); 00261 pDatabase->recover(*this); 00262 verifyData(15); 00263 }
void DatabaseTest::testRecoverDataWithFlush | ( | ) |
Definition at line 205 of file DatabaseTest.cpp.
References testRecoverData().
Referenced by DatabaseTest().
00206 { 00207 testRecoverData(true); 00208 }
void DatabaseTest::testRecoverDataWithoutFlush | ( | ) |
Definition at line 200 of file DatabaseTest.cpp.
References testRecoverData().
Referenced by DatabaseTest().
00201 { 00202 testRecoverData(false); 00203 }
void DatabaseTest::testForceTxns | ( | ) |
Definition at line 265 of file DatabaseTest.cpp.
References TestBase::configMap, executeForceTxn(), loadDatabase(), pCache, pDatabase, ConfigMap::setStringParam(), testCreateData(), verifyData(), and writeData().
Referenced by DatabaseTest().
00266 { 00267 configMap.setStringParam( 00268 "forceTxns","true"); 00269 configMap.setStringParam( 00270 "disableSnapshots","true"); 00271 testCreateData(); 00272 pDatabase->checkpointImpl(); 00273 verifyData(5); 00274 00275 // Allocate an extra page for use below. 00276 PageId extraPageId = writeData(42); 00277 00278 pDatabase.reset(); 00279 loadDatabase(); 00280 00281 // Pin the extra page to make sure that doesn't cause problems 00282 // for rollback on unrelated data. 00283 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00284 TestPageLock pageLock(segmentAccessor); 00285 pageLock.lockShared(extraPageId); 00286 00287 executeForceTxn(); 00288 executeForceTxn(); 00289 00290 pageLock.unlock(); 00291 00292 pDatabase.reset(); 00293 }
void DatabaseTest::executeForceTxn | ( | ) |
Definition at line 295 of file DatabaseTest.cpp.
References ACTION_INCREMENT_FORCE, addTxnParticipant(), executeIncrementAction(), pCache, pDatabase, LogicalTxnParticipant::pTxn, TestBase::snooze(), and verifyData().
Referenced by testForceTxns().
00296 { 00297 SharedLogicalTxn pTxn = pDatabase->getTxnLog()->newLogicalTxn(pCache); 00298 addTxnParticipant(pTxn); 00299 executeIncrementAction(10, ACTION_INCREMENT_FORCE); 00300 verifyData(15); 00301 pTxn->rollback(); 00302 pTxn.reset(); 00303 // Give the background flush thread time to flush the data page 00304 snooze(3); 00305 pDatabase->recoverOnline(); 00306 verifyData(5); 00307 }
LogicalTxnClassId DatabaseTest::getParticipantClassId | ( | ) | const [virtual] |
Implements LogicalTxnParticipant.
Definition at line 318 of file DatabaseTest.cpp.
Referenced by loadParticipant().
void DatabaseTest::describeParticipant | ( | ByteOutputStream & | logStream | ) | [virtual] |
Called by LogicalTxn the first time an action is logged for this participant.
The participant must implement this by writing a description of itself to the given output stream. This information must be sufficient for reconstructing the participant during recovery.
logStream | stream to which the participant description should be written |
Implements LogicalTxnParticipant.
Definition at line 323 of file DatabaseTest.cpp.
void DatabaseTest::redoLogicalAction | ( | LogicalActionType | actionType, | |
ByteInputStream & | logStream | |||
) | [virtual] |
Performs redo for one logical action during recovery.
The implementation must consume ALL log data for this action, even if some of it turns out to be unneeded.
actionType | the type of action to redo; the rest of the action parameters should be read from the LogicalTxn's input stream | |
logStream | stream from which to read action data |
Implements LogicalTxnParticipant.
Definition at line 343 of file DatabaseTest.cpp.
References ACTION_INCREMENT, ACTION_INCREMENT_FORCE, pCache, pDatabase, persistentPageId, and ByteInputStream::readValue().
00346 { 00347 int i; 00348 logStream.readValue(i); 00349 if (actionType == ACTION_INCREMENT_FORCE) { 00350 return; 00351 } 00352 assert(actionType == ACTION_INCREMENT); 00353 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00354 TestPageLock pageLock(segmentAccessor); 00355 pageLock.lockExclusive(persistentPageId); 00356 pageLock.getNodeForWrite().x += i; 00357 }
void DatabaseTest::undoLogicalAction | ( | LogicalActionType | actionType, | |
ByteInputStream & | logStream | |||
) | [virtual] |
Performs undo for one logical action during rollback or recovery.
The implementation must consume ALL log data for this action, even if some of it turns out to be unneeded.
actionType | the type of action to undo; the rest of the action parameters should be read from the LogicalTxn's input stream | |
logStream | stream from which to read action data |
Implements LogicalTxnParticipant.
Definition at line 327 of file DatabaseTest.cpp.
References ACTION_INCREMENT, ACTION_INCREMENT_FORCE, pCache, pDatabase, persistentPageId, and ByteInputStream::readValue().
00330 { 00331 int i; 00332 logStream.readValue(i); 00333 if (actionType == ACTION_INCREMENT_FORCE) { 00334 return; 00335 } 00336 assert(actionType == ACTION_INCREMENT); 00337 SegmentAccessor segmentAccessor(pDatabase->getDataSegment(),pCache); 00338 TestPageLock pageLock(segmentAccessor); 00339 pageLock.lockExclusive(persistentPageId); 00340 pageLock.getNodeForWrite().x -= i; 00341 }
SharedLogicalTxnParticipant DatabaseTest::loadParticipant | ( | LogicalTxnClassId | classId, | |
ByteInputStream & | logStream | |||
) | [virtual] |
Recovers a LogicalTxnParticipant from the log.
Using the classId to determine the participant type to create, the factory reads required constructor parameters from the log input stream. The factory may peool participant instances; i.e. when the same constructor parameters are encountered a second time, the factory can return the same instance. (TODO: refine this when parallelized recovery is implemented.) The implementation must consume ALL log data for this record, even if some of it turns out to be unneeded.
classId | the LogicalTxnClassId recorded when the participant was logged while online | |
logStream | the log information written by the participant's describeParticipant() implementation |
Implements LogicalTxnParticipantFactory.
Definition at line 359 of file DatabaseTest.cpp.
References getParticipantClassId().
00362 { 00363 assert(classId == getParticipantClassId()); 00364 return boost::dynamic_pointer_cast<LogicalTxnParticipant>( 00365 shared_from_this()); 00366 }
void TestBase::snooze | ( | uint | nSeconds | ) | [protected, inherited] |
Definition at line 263 of file TestBase.cpp.
Referenced by executeForceTxn(), ThreadedTestBase::runThreadedTestCase(), PagingTestBase::testCacheResize(), BTreeTxnTest::testCheckpoint(), PagingTestBase::testCheckpointGuarded(), PagingTestBase::testPrefetch(), and PagingTestBase::testPrefetchBatch().
00264 { 00265 #ifdef __MSVC__ 00266 ::_sleep(nSeconds*1000); 00267 #else 00268 ::sleep(nSeconds); 00269 #endif 00270 }
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") { // -t TEST 00123 permAssert(i + 1 < argc); 00124 runSingle = argv[++i]; 00125 } else if (arg[1] == 't') { // allow -tTEST 00126 runSingle = arg.substr(2); 00127 } 00128 } else { 00129 int i = arg.find("="); 00130 if ((0 < i) && (i < arg.size())) { 00131 // an ad hoc parameter 00132 std::string key = arg.substr(0,i); 00133 std::string val = arg.substr(i + 1); 00134 adhocMap.setStringParam(key,val); 00135 } else { 00136 // a config file name 00137 std::ifstream configFile(arg.c_str()); 00138 assert(configFile.good()); 00139 configMap.readParams(configFile); 00140 } 00141 } 00142 } 00143 configMap.mergeFrom(adhocMap); 00144 00145 // set a default dictionary file location for use by tests that need a 00146 // small non-random sorted data set 00147 if (!configMap.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] |
Definition at line 157 of file TestBase.cpp.
References TestBase::TestCaseGroup::addAllToTestSuite(), TestBase::defaultTests, TestBase::extraTests, TestBase::TestCaseGroup::findTest(), TestBase::pTestObj, TestBase::pTestSuite, TestBase::runAll, TestBase::runSingle, and TestBase::testName.
00158 { 00159 assert(pTestObj); 00160 assert(pTestObj.use_count() > 1); 00161 00162 // release self-reference now that all test cases have been registered 00163 pTestObj.reset(); 00164 00165 TestSuite* pTestSuite = BOOST_TEST_SUITE(testName.c_str()); 00166 00167 if (runSingle.size()) { 00168 test_unit *p = defaultTests.findTest(runSingle); 00169 if (!p) { 00170 p = extraTests.findTest(runSingle); 00171 } 00172 if (!p) { 00173 std::cerr << "test " << runSingle << " not found\n"; 00174 exit(2); 00175 } 00176 pTestSuite->add(p); 00177 } else { 00178 defaultTests.addAllToTestSuite(pTestSuite); 00179 if (runAll) { 00180 extraTests.addAllToTestSuite(pTestSuite); 00181 } 00182 } 00183 return pTestSuite; 00184 }
void TestBase::beforeTestCase | ( | std::string | testCaseName | ) | [inherited] |
Definition at line 214 of file TestBase.cpp.
References TestBase::configMap, TraceSource::initTraceSource(), AutoBacktrace::install(), TestBase::notifyTrace(), AutoBacktrace::setOutputStream(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.
00215 { 00216 notifyTrace(testName,TRACE_INFO,"ENTER: " + testCaseName); 00217 00218 // Install the AutoBacktrace signal handler now, after 00219 // boost::execution_monitor::catch_signals() has installed its own, so that 00220 // on SIGABRT AutoBacktrace goes first, prints the backtrace, then chains 00221 // to boost, which handles the error. 00222 AutoBacktrace::setOutputStream(); 00223 AutoBacktrace::setTraceTarget(shared_from_this()); 00224 AutoBacktrace::install(); 00225 configMap.initTraceSource(shared_from_this(), "testConfig"); 00226 }
void TestBase::afterTestCase | ( | std::string | testCaseName | ) | [inherited] |
Definition at line 228 of file TestBase.cpp.
References TestBase::configMap, TraceSource::disableTracing(), TestBase::notifyTrace(), AutoBacktrace::setTraceTarget(), TestBase::testName, and TRACE_INFO.
00229 { 00230 AutoBacktrace::setTraceTarget(); 00231 configMap.disableTracing(); 00232 notifyTrace(testName,TRACE_INFO,"LEAVE: " + testCaseName); 00233 }
void TestBase::testCaseSetUp | ( | ) | [virtual, inherited] |
Equivalent to JUnit TestCase.setUp; this is called before each test case method is invoked.
Default is no-op.
Reimplemented in LbmEntryTest, LbmExecStreamTestBase, LbmLoadBitmapTest, LbmSearchTest, LbmSplicerExecStreamTest, LcsClusterAppendExecStreamTest, LcsClusterReplaceExecStreamTest, LcsMultiClusterAppendTest, LcsRowScanExecStreamTest, BTreeReadersTest, BTreeTest, BTreeTxnTest, ExecStreamGovernorTest, ExecStreamTestBase, ExecStreamUnitTestBase, ExternalSortExecStreamTest, LhxHashTableTest, LogicalTxnTest, and SnapshotSegmentTestBase.
Definition at line 235 of file TestBase.cpp.
Referenced by ExecStreamTestBase::testCaseSetUp().
void TestBase::notifyTrace | ( | std::string | source, | |
TraceLevel | level, | |||
std::string | message | |||
) | [virtual, inherited] |
Receives notification when a trace event occurs.
source | the facility from which the message originated | |
level | the trace event severity level | |
message | the text of the message |
Implements TraceTarget.
Definition at line 243 of file TestBase.cpp.
References TestBase::traceFile, TestBase::traceMutex, TestBase::traceStdout, and TestBase::traceStream.
Referenced by TestBase::afterTestCase(), and TestBase::beforeTestCase().
00244 { 00245 if (traceFile || traceStdout) { 00246 StrictMutexGuard traceMutexGuard(traceMutex); 00247 if (traceFile) { 00248 traceStream << "[" << source << "] " << message << std::endl; 00249 traceStream.flush(); 00250 } 00251 if (traceStdout) { 00252 std::cout << "[" << source << "] " << message << std::endl; 00253 std::cout.flush(); 00254 } 00255 } 00256 }
TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
Gets the level at which a particular source should be traced.
source | name of source to be traced |
Implements TraceTarget.
Definition at line 258 of file TestBase.cpp.
References TestBase::traceLevel.
Referenced by LbmExecStreamTestBase::generateBitmaps().
00259 { 00260 return traceLevel; 00261 }
LogicalTxn * LogicalTxnParticipant::getLogicalTxn | ( | ) | [inline, protected, inherited] |
Definition at line 111 of file LogicalTxnParticipant.h.
References LogicalTxnParticipant::pTxn.
Referenced by LogicalTxnTest::commit(), BTreeWriter::deleteCurrent(), FtrsTableWriter::execute(), executeIncrementAction(), BTreeWriter::insertTupleFromBuffer(), LogicalTxnTest::rollbackFull(), LogicalTxnTest::testActions(), LogicalTxnTest::testCheckpointCommitSavepoint(), LogicalTxnTest::testRollbackSavepoint(), LogicalTxnTest::testTxn(), and LogicalTxnTest::testTxnIdSequence().
00112 { 00113 return pTxn; 00114 }
bool LogicalTxnParticipant::isLoggingEnabled | ( | ) | const [inline, protected, inherited] |
Definition at line 116 of file LogicalTxnParticipant.h.
References LogicalTxnParticipant::loggingEnabled.
Referenced by BTreeWriter::deleteCurrent(), FtrsTableWriter::execute(), BTreeWriter::insertTupleFromBuffer(), and BTreeWriter::updateCurrent().
00117 { 00118 return loggingEnabled; 00119 }
const LogicalActionType DatabaseTest::ACTION_INCREMENT [static, private] |
Definition at line 48 of file DatabaseTest.cpp.
Referenced by executeIncrementAction(), redoLogicalAction(), and undoLogicalAction().
const LogicalActionType DatabaseTest::ACTION_INCREMENT_FORCE [static, private] |
Definition at line 50 of file DatabaseTest.cpp.
Referenced by executeForceTxn(), redoLogicalAction(), and undoLogicalAction().
SharedCache DatabaseTest::pCache [private] |
Definition at line 61 of file DatabaseTest.cpp.
Referenced by DatabaseTest(), executeCheckpointedTxn(), executeForceTxn(), executeIncrementAction(), executeIncrementTxn(), loadDatabase(), redoLogicalAction(), testCreateEmpty(), testForceTxns(), undoLogicalAction(), verifyData(), and writeData().
SharedDatabase DatabaseTest::pDatabase [private] |
Definition at line 62 of file DatabaseTest.cpp.
Referenced by executeCheckpointedTxn(), executeForceTxn(), executeIncrementAction(), executeIncrementTxn(), loadDatabase(), redoLogicalAction(), testCaseTearDown(), testCreateData(), testCreateEmpty(), testForceTxns(), testLoadEmpty(), testRecoverData(), testRecoverDataFromCheckpoint(), testRecoverDataFromRollback(), testRecoverEmpty(), undoLogicalAction(), verifyData(), and writeData().
PageId DatabaseTest::persistentPageId [private] |
Definition at line 63 of file DatabaseTest.cpp.
Referenced by executeIncrementAction(), redoLogicalAction(), testCreateData(), undoLogicalAction(), and verifyData().
TestSuite* TestBase::pTestSuite [protected, inherited] |
Boost test suite.
Definition at line 59 of file TestBase.h.
Referenced by TestBase::releaseTestSuite().
boost::shared_ptr<TestBase> TestBase::pTestObj [protected, inherited] |
Definition at line 61 of file TestBase.h.
Referenced by TestBase::releaseTestSuite(), and TestBase::TestBase().
std::ofstream TestBase::traceStream [protected, inherited] |
Output file stream for tracing.
Definition at line 66 of file TestBase.h.
Referenced by TestBase::notifyTrace(), TestBase::TestBase(), and TestBase::~TestBase().
StrictMutex TestBase::traceMutex [protected, inherited] |
Protects traceStream.
Definition at line 71 of file TestBase.h.
Referenced by TestBase::notifyTrace().
std::string TestBase::testName [protected, inherited] |
Name of test.
Definition at line 76 of file TestBase.h.
Referenced by TestBase::afterTestCase(), TestBase::beforeTestCase(), TestBase::releaseTestSuite(), TestBase::TestBase(), LhxHashTableTest::testInsert1Ka(), and LhxHashTableTest::testInsert1Kb().
TraceLevel TestBase::traceLevel [protected, inherited] |
Level at which to trace test execution.
Definition at line 81 of file TestBase.h.
Referenced by TestBase::getSourceTraceLevel(), and TestBase::TestBase().
FileStatsTarget TestBase::statsTarget [protected, inherited] |
StatsTimer TestBase::statsTimer [protected, inherited] |
Timer for stats collection.
Definition at line 91 of file TestBase.h.
Referenced by CacheTestBase::closeStorage(), CacheTestBase::openStorage(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCaseTearDown(), and BTreeTxnTest::testTxns().
bool TestBase::traceStdout [protected, inherited] |
Copy trace output to stdout.
Definition at line 99 of file TestBase.h.
Referenced by TestBase::notifyTrace(), and TestBase::TestBase().
bool TestBase::traceFile [protected, inherited] |
Copy trace output to file.
Definition at line 104 of file TestBase.h.
Referenced by TestBase::notifyTrace(), and TestBase::TestBase().
bool TestBase::runAll [static, protected, inherited] |
Run all test cases, including the extra tests.
(static, since set by readParams())
Definition at line 110 of file TestBase.h.
Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().
std::string TestBase::runSingle [static, protected, inherited] |
Run only the test case of this name.
(static, since set by readParams())
Definition at line 116 of file TestBase.h.
Referenced by TestBase::readParams(), and TestBase::releaseTestSuite().
TestCaseGroup TestBase::defaultTests [protected, inherited] |
TestCaseGroup TestBase::extraTests [protected, inherited] |
ParamName TestBase::paramTestSuiteName [static, inherited] |
ParamName TestBase::paramTraceFileName [static, inherited] |
ParamName TestBase::paramDictionaryFileName [static, inherited] |
Definition at line 145 of file TestBase.h.
Referenced by TestBase::readParams(), SegStreamTest::testRead(), and SegStreamTest::testWrite().
ParamName TestBase::paramTraceLevel [static, inherited] |
ParamName TestBase::paramStatsFileName [static, inherited] |
Definition at line 147 of file TestBase.h.
ParamName TestBase::paramTraceStdout [static, inherited] |
ParamName TestBase::paramDegreeOfParallelism [static, inherited] |
Definition at line 149 of file TestBase.h.
Referenced by ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest().
ConfigMap TestBase::configMap [static, inherited] |
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::BTreeTxnTest(), CacheTestBase::CacheTestBase(), BackupRestoreTest::createSnapshotData(), DatabaseTest(), TestOptionsTest::extra(), loadDatabase(), SparseBitmapTest::openStorage(), PagingTestBase::PagingTestBase(), ParallelExecStreamSchedulerTest::ParallelExecStreamSchedulerTest(), RandomAccessFileDeviceTest::RandomAccessFileDeviceTest(), TestBase::readParams(), SegStorageTestBase::SegStorageTestBase(), TestOptionsTest::test1(), TestOptionsTest::test2(), BackupRestoreTest::testBackupCleanup(), TestBase::TestBase(), BTreeTxnTest::testCaseSetUp(), BTreeTxnTest::testCheckpoint(), testCreateEmpty(), testForceTxns(), BackupRestoreTest::testHeaderBackupRestore(), SegPageEntryIterTest::testIter(), SegStreamTest::testRead(), BTreeTxnTest::testTxns(), SegStreamTest::testWrite(), ThreadedTestBase::ThreadedTestBase(), and TestBase::~TestBase().