testnoderestart.cpp

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

CPP
1,384
字号
  int records = ctx->getNumRecords();  NdbRestarter restarter;  Ndb* pNdb = GETNDB(step);    HugoTransactions hugoTrans(*ctx->getTab());  int dump[] = { 9002, 0 } ;  Uint32 ownNode = refToNode(pNdb->getReference());  dump[1] = ownNode;  for (; loops; loops --)  {    int nodeId = restarter.getRandomNotMasterNodeId(rand());    restarter.restartOneDbNode(nodeId, false, true, true);    restarter.waitNodesNoStart(&nodeId, 1);        if (restarter.dumpStateOneNode(nodeId, dump, 2))      return NDBT_FAILED;        restarter.startNodes(&nodeId, 1);        for (Uint32 i = 0; i < 100; i++)    {      hugoTrans.pkReadRecords(pNdb, 100, 1, NdbOperation::LM_CommittedRead);    }        restarter.waitClusterStarted();  }    return NDBT_OK;}int runBug25364(NDBT_Context* ctx, NDBT_Step* step){  int result = NDBT_OK;  NdbRestarter restarter;  Ndb* pNdb = GETNDB(step);  int loops = ctx->getNumLoops();    if (restarter.getNumDbNodes() < 4)    return NDBT_OK;  int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };  for (; loops; loops --)  {    int master = restarter.getMasterNodeId();    int victim = restarter.getRandomNodeOtherNodeGroup(master, rand());    int second = restarter.getRandomNodeSameNodeGroup(victim, rand());        int dump[] = { 935, victim } ;    if (restarter.dumpStateOneNode(master, dump, 2))      return NDBT_FAILED;      if (restarter.dumpStateOneNode(master, val2, 2))      return NDBT_FAILED;      if (restarter.restartOneDbNode(second, false, true, true))      return NDBT_FAILED;    int nodes[2] = { master, second };    if (restarter.waitNodesNoStart(nodes, 2))      return NDBT_FAILED;    restarter.startNodes(nodes, 2);    if (restarter.waitNodesStarted(nodes, 2))      return NDBT_FAILED;  }    return NDBT_OK;}int runBug25554(NDBT_Context* ctx, NDBT_Step* step){    int result = NDBT_OK;  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  NdbRestarter restarter;    if (restarter.getNumDbNodes() < 4)    return NDBT_OK;  for (int i = 0; i<loops; i++)  {    int master = restarter.getMasterNodeId();    int node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());    restarter.restartOneDbNode(node1, false, true, true);    int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };      if (restarter.dumpStateOneNode(master, val2, 2))      return NDBT_FAILED;    if (restarter.insertErrorInNode(master, 7141))      return NDBT_FAILED;    if (restarter.waitNodesNoStart(&node1, 1))      return NDBT_FAILED;    if (restarter.dumpStateOneNode(node1, val2, 2))      return NDBT_FAILED;    if (restarter.insertErrorInNode(node1, 932))      return NDBT_FAILED;    if (restarter.startNodes(&node1, 1))      return NDBT_FAILED;    int nodes[] = { master, node1 };    if (restarter.waitNodesNoStart(nodes, 2))      return NDBT_FAILED;    if (restarter.startNodes(nodes, 2))      return NDBT_FAILED;    if (restarter.waitClusterStarted())      return NDBT_FAILED;  }      return NDBT_OK;}NDBT_TESTSUITE(testNodeRestart);TESTCASE("NoLoad", 	 "Test that one node at a time can be stopped and then restarted "\	 "when there are no load on the system. Do this loop number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  FINALIZER(runClearTable);}TESTCASE("PkRead", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  FINALIZER(runClearTable);}TESTCASE("PkReadCommitted", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", NdbOperation::LM_CommittedRead);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  FINALIZER(runClearTable);}TESTCASE("MixedPkRead", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", -1);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  FINALIZER(runClearTable);}TESTCASE("PkReadPkUpdate", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read and pk update while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  FINALIZER(runClearTable);}TESTCASE("MixedPkReadPkUpdate", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read and pk update while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", -1);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  FINALIZER(runClearTable);}TESTCASE("ReadUpdateScan", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  STEP(runScanReadUntilStopped);  STEP(runScanUpdateUntilStopped);  FINALIZER(runClearTable);}TESTCASE("MixedReadUpdateScan", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){   TC_PROPERTY("ReadLockMode", -1);  INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runPkReadPkUpdateUntilStopped);  STEP(runScanReadUntilStopped);  STEP(runScanUpdateUntilStopped);  FINALIZER(runClearTable);}TESTCASE("Terror", 	 "Test that one node at a time can be stopped and then restarted "\	 "perform all kind of transactions while restarting. Do this loop number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarter);  STEP(runPkReadUntilStopped);  STEP(runPkUpdateUntilStopped);  STEP(runScanReadUntilStopped);  STEP(runScanUpdateUntilStopped);  FINALIZER(runClearTable);}TESTCASE("FullDb", 	 "Test that one node at a time can be stopped and then restarted "\	 "when db is full. Do this loop number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runFillTable);  STEP(runRestarter);  FINALIZER(runClearTable);}TESTCASE("RestartRandomNode", 	 "Test that we can execute the restart RestartRandomNode loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartRandomNodeError", 	 "Test that we can execute the restart RestartRandomNodeError loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartRandomNodeInitial", 	 "Test that we can execute the restart RestartRandomNodeInitial loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartNFDuringNR", 	 "Test that we can execute the restart RestartNFDuringNR loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  STEP(runPkUpdateUntilStopped);  STEP(runScanUpdateUntilStopped);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartMasterNodeError", 	 "Test that we can execute the restart RestartMasterNodeError loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("TwoNodeFailure", 	 "Test that we can execute the restart TwoNodeFailure\n"\	 "(which is a multiple node failure restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("TwoMasterNodeFailure", 	 "Test that we can execute the restart TwoMasterNodeFailure\n"\	 "(which is a multiple node failure restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("FiftyPercentFail", 	 "Test that we can execute the restart FiftyPercentFail\n"\	 "(which is a multiple node failure restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartAllNodes", 	 "Test that we can execute the restart RestartAllNodes\n"\	 "(which is a system  restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartAllNodesAbort", 	 "Test that we can execute the restart RestartAllNodesAbort\n"\	 "(which is a system  restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartAllNodesError9999", 	 "Test that we can execute the restart RestartAllNodesError9999\n"\	 "(which is a system  restart) loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("FiftyPercentStopAndWait", 	 "Test that we can execute the restart FiftyPercentStopAndWait\n"\	 "(which is a system  restart) loop\n"\	 "number of times"){  INITIALIZER(runCheckAllNodesStarted);   INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("RestartNodeDuringLCP", 	 "Test that we can execute the restart RestartRandomNode loop\n"\	 "number of times"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  STEP(runPkUpdateUntilStopped);  STEP(runScanUpdateUntilStopped);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("StopOnError", 	 "Test StopOnError. A node that has StopOnError set to false "\	 "should restart automatically when an error occurs"){   INITIALIZER(runCheckAllNodesStarted);  INITIALIZER(runLoadTable);  STEP(runRestarts);  FINALIZER(runScanReadVerify);  FINALIZER(runClearTable);}TESTCASE("CommittedRead", 	 "Test committed read"){   INITIALIZER(runLoadTable);  STEP(runDirtyRead);  FINALIZER(runClearTable);}TESTCASE("LateCommit",	 "Test commit after node failure"){  INITIALIZER(runLoadTable);  STEP(runLateCommit);  FINALIZER(runClearTable);}TESTCASE("Bug15587",	 "Test bug with NF during NR"){  INITIALIZER(runLoadTable);  STEP(runScanUpdateUntilStopped);  STEP(runBug15587);  FINALIZER(runClearTable);}TESTCASE("Bug15632",	 "Test bug with NF during NR"){  INITIALIZER(runLoadTable);  STEP(runBug15632);  FINALIZER(runClearTable);}TESTCASE("Bug15685",	 "Test bug with NF during abort"){  STEP(runBug15685);  FINALIZER(runClearTable);}TESTCASE("Bug16772",	 "Test bug with restarting before NF handling is complete"){  STEP(runBug16772);}TESTCASE("Bug18414",	 "Test bug with NF during NR"){  INITIALIZER(runLoadTable);  STEP(runBug18414);  FINALIZER(runClearTable);}TESTCASE("Bug18612",	 "Test bug with partitioned clusters"){  INITIALIZER(runLoadTable);  STEP(runBug18612);  FINALIZER(runClearTable);}TESTCASE("Bug18612SR",	 "Test bug with partitioned clusters"){  INITIALIZER(runLoadTable);  STEP(runBug18612SR);  FINALIZER(runClearTable);}TESTCASE("Bug20185",	 ""){  INITIALIZER(runLoadTable);  STEP(runBug20185);  FINALIZER(runClearTable);}TESTCASE("Bug24717", ""){  INITIALIZER(runBug24717);}TESTCASE("Bug25364", ""){  INITIALIZER(runBug25364);}TESTCASE("Bug25554", ""){  INITIALIZER(runBug25554);}NDBT_TESTSUITE_END(testNodeRestart);int main(int argc, const char** argv){  ndb_init();#if 0  // It might be interesting to have longer defaults for num  // loops in this test  // Just performing 100 node restarts would not be enough?  // We can have initialisers in the NDBT_Testcase class like   // this...  testNodeRestart.setDefaultLoops(1000);#endif  return testNodeRestart.execute(argc, argv);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?