testindex.cpp

来自「MySQL源码文件5.X系列, 可自已编译到服务器」· C++ 代码 · 共 1,639 行 · 第 1/4 页

CPP
1,639
字号
        if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){      g_err << "Index read failed" << endl;      return NDBT_FAILED;    }  }    return NDBT_OK;}int runBug25059(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  NdbDictionary::Dictionary * dict = pNdb->getDictionary();  const NdbDictionary::Index * idx = dict->getIndex(pkIdxName, *ctx->getTab());  HugoOperations ops(*ctx->getTab(), idx);    int res = NDBT_OK;  int loops = ctx->getNumLoops();  const int rows = ctx->getNumRecords();    while (res == NDBT_OK && loops--)  {    ops.startTransaction(pNdb);    ops.pkReadRecord(pNdb, 10 + rand() % rows, rows);    int tmp;    if (tmp = ops.execute_Commit(pNdb, AO_IgnoreError))    {      if (tmp == 4012)	res = NDBT_FAILED;      else	if (ops.getTransaction()->getNdbError().code == 4012)	  res = NDBT_FAILED;    }    ops.closeTransaction(pNdb);  }    loops = ctx->getNumLoops();  while (res == NDBT_OK && loops--)  {    ops.startTransaction(pNdb);    ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows);    int tmp;    int arg;    switch(rand() % 2){    case 0:      arg = AbortOnError;      break;    case 1:      arg = AO_IgnoreError;      ndbout_c("ignore error");      break;    }    if (tmp = ops.execute_Commit(pNdb, (AbortOption)arg))    {      if (tmp == 4012)	res = NDBT_FAILED;      else	if (ops.getTransaction()->getNdbError().code == 4012)	  res = NDBT_FAILED;    }    ops.closeTransaction(pNdb);  }      return res;}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);}TESTCASE("Bug25059", 	 "Test that unique indexes and nulls"){   TC_PROPERTY("LoggedIndexes", (unsigned)0);  INITIALIZER(createPkIndex);  INITIALIZER(runLoadTable);  STEP(runBug25059);  FINALIZER(createPkIndex_Drop);}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 + =
减小字号Ctrl + -
显示快捷键?