📄 testindex.cpp
字号:
#endif for(int i = 0; i<loops && !ctx->isTestStopped(); i++){ int randomId = myRandom48(restarter.getNumDbNodes()); int nodeId = restarter.getDbNodeId(randomId); const Uint32 error = 5031 + (i % 3); if(restarter.insertErrorInNode(nodeId, error) != 0){ g_err << "Failed to error insert( " << error << ") in node " << nodeId << endl; return NDBT_FAILED; } } ctx->stopTest(); return NDBT_OK;}int runBug21384(NDBT_Context* ctx, NDBT_Step* step){ Ndb* pNdb = GETNDB(step); HugoTransactions hugoTrans(*ctx->getTab()); NdbRestarter restarter; int loops = ctx->getNumLoops(); const int rows = ctx->getNumRecords(); const int batchsize = ctx->getProperty("BatchSize", 50); while (loops--) { if(restarter.insertErrorInAllNodes(8037) != 0) { g_err << "Failed to error insert(8037)" << endl; return NDBT_FAILED; } if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) == 0) { g_err << "Index succeded (it should have failed" << endl; return NDBT_FAILED; } if(restarter.insertErrorInAllNodes(0) != 0) { g_err << "Failed to error insert(0)" << endl; return NDBT_FAILED; } if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){ g_err << "Index read failed" << endl; return NDBT_FAILED; } } return NDBT_OK;}NDBT_TESTSUITE(testIndex);TESTCASE("CreateAll", "Test that we can create all various indexes on each table\n" "Then drop the indexes\n"){ INITIALIZER(runCreateIndexes);}TESTCASE("CreateAll_O", "Test that we can create all various indexes on each table\n" "Then drop the indexes\n"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); INITIALIZER(runCreateIndexes);}TESTCASE("InsertDeleteGentle", "Create one index, then perform insert and delete in the table\n" "loop number of times. Use batch size 1."){ TC_PROPERTY("BatchSize", 1); INITIALIZER(runInsertDelete); FINALIZER(runClearTable);}TESTCASE("InsertDeleteGentle_O", "Create one index, then perform insert and delete in the table\n" "loop number of times. Use batch size 1."){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", 1); INITIALIZER(runInsertDelete); FINALIZER(runClearTable);}TESTCASE("InsertDelete", "Create one index, then perform insert and delete in the table\n" "loop number of times. Use batchsize 512 to stress db more"){ TC_PROPERTY("BatchSize", 512); INITIALIZER(runInsertDelete); FINALIZER(runClearTable);}TESTCASE("InsertDelete_O", "Create one index, then perform insert and delete in the table\n" "loop number of times. Use batchsize 512 to stress db more"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", 512); INITIALIZER(runInsertDelete); FINALIZER(runClearTable);}TESTCASE("CreateLoadDropGentle", "Try to create, drop and load various indexes \n" "on table loop number of times.Usa batch size 1.\n"){ TC_PROPERTY("BatchSize", 1); INITIALIZER(runCreateLoadDropIndex);}TESTCASE("CreateLoadDropGentle_O", "Try to create, drop and load various indexes \n" "on table loop number of times.Usa batch size 1.\n"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", 1); INITIALIZER(runCreateLoadDropIndex);}TESTCASE("CreateLoadDrop", "Try to create, drop and load various indexes \n" "on table loop number of times. Use batchsize 512 to stress db more\n"){ TC_PROPERTY("BatchSize", 512); INITIALIZER(runCreateLoadDropIndex);}TESTCASE("CreateLoadDrop_O", "Try to create, drop and load various indexes \n" "on table loop number of times. Use batchsize 512 to stress db more\n"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", 512); INITIALIZER(runCreateLoadDropIndex);}TESTCASE("NFNR1", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 2); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions1); STEP(runTransactions1); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR1_O", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 2); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions1); STEP(runTransactions1); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR2", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 2); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions2); STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR2_O", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 1); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions2); //STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR3", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 2); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); STEP(runRestarts); STEP(runTransactions3); STEP(runVerifyIndex); FINALIZER(runVerifyIndex); FINALIZER(createPkIndex_Drop); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR3_O", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 2); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); STEP(runRestarts); STEP(runTransactions3); STEP(runVerifyIndex); FINALIZER(runVerifyIndex); FINALIZER(createPkIndex_Drop); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR4", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 4); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions1); STEP(runTransactions1); STEP(runTransactions2); STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR4_O", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("PauseThreads", 4); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runRestarts); STEP(runTransactions1); STEP(runTransactions1); STEP(runTransactions2); STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR5", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", (unsigned)1); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runLQHKEYREF); STEP(runTransactions1); STEP(runTransactions1); STEP(runTransactions2); STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("NFNR5_O", "Test that indexes are correctly maintained during node fail and node restart"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("BatchSize", (unsigned)1); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runLQHKEYREF); STEP(runTransactions1); STEP(runTransactions1); STEP(runTransactions2); STEP(runTransactions2); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("SR1", "Test that indexes are correctly maintained during SR"){ INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); STEP(runSystemRestart1); FINALIZER(runVerifyIndex); FINALIZER(createPkIndex_Drop); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("MixedTransaction", "Test mixing of index and normal operations"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); INITIALIZER(runClearTable); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runMixed1); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("SR1_O", "Test that indexes are correctly maintained during SR"){ TC_PROPERTY("OrderedIndex", 1); TC_PROPERTY("LoggedIndexes", (unsigned)0); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); STEP(runSystemRestart1); FINALIZER(runVerifyIndex); FINALIZER(createPkIndex_Drop); FINALIZER(createRandomIndex_Drop); FINALIZER(runClearTable);}TESTCASE("BuildDuring", "Test that index build when running transactions work"){ TC_PROPERTY("OrderedIndex", (unsigned)0); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("Threads", 1); // # runTransactions4 INITIALIZER(runClearTable); STEP(runBuildDuring); STEP(runTransactions4); //STEP(runTransactions4); FINALIZER(runClearTable);}TESTCASE("BuildDuring_O", "Test that index build when running transactions work"){ TC_PROPERTY("OrderedIndex", (unsigned)1); TC_PROPERTY("LoggedIndexes", (unsigned)0); TC_PROPERTY("Threads", 1); // # runTransactions4 INITIALIZER(runClearTable); STEP(runBuildDuring); STEP(runTransactions4); //STEP(runTransactions4); FINALIZER(runClearTable);}TESTCASE("UniqueNull", "Test that unique indexes and nulls"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); INITIALIZER(runClearTable); INITIALIZER(createRandomIndex); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runTransactions1); STEP(runTransactions2); STEP(runUniqueNullTransactions); FINALIZER(runVerifyIndex); FINALIZER(createRandomIndex_Drop); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}TESTCASE("Bug21384", "Test that unique indexes and nulls"){ TC_PROPERTY("LoggedIndexes", (unsigned)0); INITIALIZER(runClearTable); INITIALIZER(createPkIndex); INITIALIZER(runLoadTable); STEP(runBug21384); FINALIZER(createPkIndex_Drop); FINALIZER(runClearTable);}NDBT_TESTSUITE_END(testIndex);int main(int argc, const char** argv){ ndb_init(); return testIndex.execute(argc, argv);}template class Vector<Attrib*>;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -