Fennel: DatabaseTest Class Reference (original) (raw)
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 |
| **Returns:**the LogicalTxnClassId for this participant; this will be used during recovery to find the correct LogicalTxnParticipantFactory | |
| 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 () |
| Returns:LogicalTxn being participated in, or null if no txn in progress; null is also returned during recovery | |
| bool | isLoggingEnabled () const |
| **Returns:**true if actions should be logged; this is false during recovery | |
| 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 |
Detailed Description
Definition at line 43 of file DatabaseTest.cpp.
Member Typedef Documentation
Constructor & Destructor Documentation
| 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
00094
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] | | ------------------------------------ | - | | - | ------------------- |
Member Function Documentation
| void DatabaseTest::loadDatabase | ( | | ) | [private] | | ------------------------------- | - | | - | ----------- |
| void DatabaseTest::executeIncrementAction | ( | int | i | ) | [private] |
|---|
| void DatabaseTest::executeIncrementAction | ( | int | i, |
|---|---|---|---|
| LogicalActionType | action | ||
| ) | [private] |
| void DatabaseTest::executeIncrementTxn | ( | int | i | ) | [private] |
|---|
| void DatabaseTest::executeCheckpointedTxn | ( | int | i, |
|---|---|---|---|
| int | j, | ||
| bool | commit, | ||
| CheckpointType | = CHECKPOINT_FLUSH_ALL | ||
| ) | [private] |
| void DatabaseTest::verifyData | ( | uint | x | ) | [private] |
|---|
| PageId DatabaseTest::writeData | ( | uint | x | ) | [private] |
|---|
| 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.
| void DatabaseTest::testCreateEmpty | ( | | ) | | ---------------------------------- | - | | - |
| void DatabaseTest::testLoadEmpty | ( | | ) | | -------------------------------- | - | | - |
| void DatabaseTest::testRecoverEmpty | ( | | ) | | ----------------------------------- | - | | - |
| void DatabaseTest::testCreateData | ( | | ) | | --------------------------------- | - | | - |
| void DatabaseTest::testLoadData | ( | | ) | | ------------------------------- | - | | - |
| void DatabaseTest::testRecoverData | ( | bool | | ) | | ---------------------------------- | - | ---- | | - |
| void DatabaseTest::testRecoverDataFromCheckpoint | ( | | ) | | ------------------------------------------------ | - | | - |
| void DatabaseTest::testRecoverDataFromFuzzyCheckpoint | ( | | ) | | ----------------------------------------------------- | - | | - |
| void DatabaseTest::testRecoverDataFromRollback | ( | | ) | | ---------------------------------------------- | - | | - |
| void DatabaseTest::testRecoverDataWithFlush | ( | | ) | | ------------------------------------------- | - | | - |
| void DatabaseTest::testRecoverDataWithoutFlush | ( | | ) | | ---------------------------------------------- | - | | - |
| void DatabaseTest::testForceTxns | ( | | ) | | -------------------------------- | - | | - |
| void DatabaseTest::executeForceTxn | ( | | ) | | ---------------------------------- | - | | - |
| LogicalTxnClassId DatabaseTest::getParticipantClassId | ( | | ) | const [virtual] | | ----------------------------------------------------- | - | | - | ----------------- |
| 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.
Parameters:
| logStream | stream to which the participant description should be written |
|---|
Implements LogicalTxnParticipant.
Definition at line 323 of file DatabaseTest.cpp.
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.
Parameters:
| classId | the LogicalTxnClassId recorded when the participant was logged while online |
|---|---|
| logStream | the log information written by the participant's describeParticipant() implementation |
Returns:
reference to loaded participant
Implements LogicalTxnParticipantFactory.
Definition at line 359 of file DatabaseTest.cpp.
References getParticipantClassId().
00362 { 00363 assert(classId == getParticipantClassId()); 00364 return boost::dynamic_pointer_cast( 00365 shared_from_this()); 00366 }
| 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::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] |
| TraceLevel TestBase::getSourceTraceLevel | ( | std::string | source | ) | [virtual, inherited] |
|---|
| LogicalTxn * LogicalTxnParticipant::getLogicalTxn | ( | | ) | [inline, protected, inherited] | | -------------------------------------------------------------------------- | - | | - | -------------------------------- |
Returns:
LogicalTxn being participated in, or null if no txn in progress; null is also returned during recovery
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] | | -------------------------------------------- | - | | - | -------------------------------------- |
Member Data Documentation
Definition at line 61 of file DatabaseTest.cpp.
Referenced by DatabaseTest(), executeCheckpointedTxn(), executeForceTxn(), executeIncrementAction(), executeIncrementTxn(), loadDatabase(), redoLogicalAction(), testCreateEmpty(), testForceTxns(), undoLogicalAction(), verifyData(), and writeData().
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().
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().
The documentation for this class was generated from the following file:
- /home/pub/open/dev/fennel/test/DatabaseTest.cpp
