⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testsystemrestart.cpp

📁 mysql-5.0.22.tar.gz源码包
💻 CPP
📖 第 1 页 / 共 3 页
字号:
  int result = NDBT_OK;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR7 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));  int a_nodeIds[64];  if(nodeCount > 64)    abort();  Uint32 currentRestartNodeIndex = 1;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart all node -nostart     * 3. Start all but one node     * 4. Wait for startphase >= 2     * 5. Start last node     * 6. Verify records     */    g_info << "Loading records..." << endl;    hugoTrans.loadTable(pNdb, records);        CHECK(restarter.restartAll(false, true, false) == 0);        int nodeId = nodeIds[currentRestartNodeIndex];    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    Uint32 j = 0;    for(Uint32 k = 0; k<nodeCount; k++){      if(nodeIds[k] != nodeId){	a_nodeIds[j++] = nodeIds[k];      }    }    CHECK(restarter.startNodes(a_nodeIds, nodeCount - 1) == 0);    CHECK(restarter.waitNodesStarted(a_nodeIds, nodeCount - 1, 120) == 0);    CHECK(pNdb->waitUntilReady(5) == 0);    int count = records - 1;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);        CHECK(restarter.startNodes(&nodeId, 1) == 0);    CHECK(restarter.waitNodesStarted(&nodeId, 1, 120) == 0);        CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    CHECK(utilTrans.clearTable(pNdb) == 0);        i++;  }    g_info << "runSystemRestart7 finished" << endl;    return result;}int runSystemRestart8(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  NdbRestarter restarter;  Uint32 i = 1;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "SR8 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  Vector<int> nodeIds;  for(i = 0; i<nodeCount; i++)    nodeIds.push_back(restarter.getDbNodeId(i));  int a_nodeIds[64];  if(nodeCount > 64)    abort();  Uint32 currentRestartNodeIndex = 1;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  while(i<=loops && result != NDBT_FAILED){        g_info << "Loop " << i << "/"<< loops <<" started" << endl;    /**     * 1. Load data     * 2. Restart all node -nostart     * 3. Start all but one node     * 4. Verify records     * 5. Start last node     * 6. Verify records     */    g_info << "Loading records..." << endl;    hugoTrans.loadTable(pNdb, records);        CHECK(restarter.restartAll(false, true, false) == 0);        int nodeId = nodeIds[currentRestartNodeIndex];    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;    Uint32 j = 0;    for(Uint32 k = 0; k<nodeCount; k++){      if(nodeIds[k] != nodeId){	a_nodeIds[j++] = nodeIds[k];      }    }        CHECK(restarter.startNodes(a_nodeIds, nodeCount-1) == 0);    CHECK(restarter.waitNodesStartPhase(a_nodeIds, nodeCount-1, 3, 120) == 0);    CHECK(restarter.startNodes(&nodeId, 1) == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);        int count = records - 1;    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);    CHECK(count == records);    CHECK(utilTrans.clearTable(pNdb) == 0);        i++;  }    g_info << "runSystemRestart8 finished" << endl;    return result;}int runSystemRestart9(NDBT_Context* ctx, NDBT_Step* step){  Ndb* pNdb = GETNDB(step);  int result = NDBT_OK;  int timeout = 300;  Uint32 loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  NdbRestarter restarter;  Uint32 i = 1;    Uint32 currentRestartNodeIndex = 1;  UtilTransactions utilTrans(*ctx->getTab());  HugoTransactions hugoTrans(*ctx->getTab());  int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };  int dump[] = { DumpStateOrd::DihStartLcpImmediately };    do {    CHECK(restarter.dumpStateAllNodes(args, 1) == 0);        HugoOperations ops(* ctx->getTab());    CHECK(ops.startTransaction(pNdb) == 0);    for(i = 0; i<10; i++){      CHECK(ops.pkInsertRecord(pNdb, i, 1, 1) == 0);      CHECK(ops.execute_NoCommit(pNdb) == 0);    }    for(i = 0; i<10; i++){      CHECK(ops.pkUpdateRecord(pNdb, i, 1) == 0);      CHECK(ops.execute_NoCommit(pNdb) == 0);    }    NdbSleep_SecSleep(10);    CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);    NdbSleep_SecSleep(10);    CHECK(ops.execute_Commit(pNdb) == 0);          CHECK(restarter.restartAll() == 0);    CHECK(restarter.waitClusterStarted(timeout) == 0);    CHECK(pNdb->waitUntilReady(timeout) == 0);    ops.closeTransaction(pNdb);  } while(0);    g_info << "runSystemRestart9 finished" << endl;    return result;}int runBug18385(NDBT_Context* ctx, NDBT_Step* step){  NdbRestarter restarter;  const Uint32 nodeCount = restarter.getNumDbNodes();  if(nodeCount < 2){    g_info << "Bug18385 - Needs atleast 2 nodes to test" << endl;    return NDBT_OK;  }  int node1 = restarter.getDbNodeId(rand() % nodeCount);  int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());  if (node1 == -1 || node2 == -1)    return NDBT_OK;    int dump[] = { DumpStateOrd::DihSetTimeBetweenGcp, 300 };    int result = NDBT_OK;  do {    CHECK(restarter.dumpStateAllNodes(dump, 2) == 0);    CHECK(restarter.restartOneDbNode(node1, false, true, false) == 0);    NdbSleep_SecSleep(3);    CHECK(restarter.restartAll(false, true, false) == 0);        Uint32 cnt = 0;    int nodes[128];    for(Uint32 i = 0; i<nodeCount; i++)      if ((nodes[cnt] = restarter.getDbNodeId(i)) != node2)	cnt++;        assert(cnt == nodeCount - 1);        CHECK(restarter.startNodes(nodes, cnt) == 0);    CHECK(restarter.waitNodesStarted(nodes, cnt, 300) == 0);        CHECK(restarter.insertErrorInNode(node2, 7170) == 0);    CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);    CHECK(restarter.restartOneDbNode(node2, true, false, true) == 0);    CHECK(restarter.waitNodesStarted(&node2, 1) == 0);  } while(0);    g_info << "Bug18385 finished" << endl;      return result;}int runWaitStarted(NDBT_Context* ctx, NDBT_Step* step){  NdbRestarter restarter;  restarter.waitClusterStarted(300);  NdbSleep_SecSleep(3);  return NDBT_OK;}int runClearTable(NDBT_Context* ctx, NDBT_Step* step){  int records = ctx->getNumRecords();    Ndb* pNdb = GETNDB(step);  if(pNdb->waitUntilReady(5) != 0){    return NDBT_FAILED;  }  UtilTransactions utilTrans(*ctx->getTab());    if (utilTrans.clearTable2(pNdb,  records) != 0){    return NDBT_FAILED;  }  return NDBT_OK;}NDBT_TESTSUITE(testSystemRestart);TESTCASE("SR1", 	 "Basic system restart test. Focus on testing restart from REDO log.\n"	 "NOTE! Time between lcp's and gcp's should be left at default, \n"	 "so that Ndb  uses the Redo log when restarting\n" 	 "1. Load records\n"	 "2. Restart cluster and verify records \n"	 "3. Update records\n"	 "4. Restart cluster and verify records \n"	 "5. Delete half of the records \n"	 "6. Restart cluster and verify records \n"	 "7. Delete all records \n"	 "8. Restart cluster and verify records \n"	 "9. Insert, update, delete records \n"	 "10. Restart cluster and verify records\n"	 "11. Insert, update, delete records \n"	 "12. Restart cluster with error insert 5020 and verify records\n"){   INITIALIZER(runWaitStarted);  STEP(runSystemRestart1);  FINALIZER(runClearTable);}TESTCASE("SR2", 	 "Basic system restart test. Focus on testing restart from LCP\n"	 "NOTE! Time between lcp's is automatically set to it's  min value\n"	 "so that Ndb  uses LCP's when restarting.\n" 	 "1. Load records\n"	 "2. Restart cluster and verify records \n"	 "3. Update records\n"	 "4. Restart cluster and verify records \n"	 "5. Delete half of the records \n"	 "6. Restart cluster and verify records \n"	 "7. Delete all records \n"	 "8. Restart cluster and verify records \n"	 "9. Insert, update, delete records \n"	 "10. Restart cluster and verify records\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestart2);  FINALIZER(runClearTable);}TESTCASE("SR_UNDO", 	 "System restart test. Focus on testing of undologging\n"	 "in DBACC and DBTUP.\n"	 "This is done by starting a LCP, turn on undologging \n"	 "but don't start writing the datapages. This will force all\n"	 "operations to be written into the undolog.\n"	 "Then write datapages and complete LCP.\n"	 "Restart the system\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestartTestUndoLog);  FINALIZER(runClearTable);}TESTCASE("SR_FULLDB", 	 "System restart test. Test to restart when DB is full.\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestartTestFullDb);  FINALIZER(runClearTable);}TESTCASE("SR3", 	 "System restart test. Focus on testing restart from with\n"	 "not all nodes alive when system went down\n"	 "* 1. Load data\n"	 "* 2. Restart 1 node -nostart\n"	 "* 3. Update records\n"	 "* 4. Restart cluster and verify records\n"	 "* 5. Restart 1 node -nostart\n"	 "* 6. Delete half of the records\n"	 "* 7. Restart cluster and verify records\n"	 "* 8. Restart 1 node -nostart\n"	 "* 9. Delete all records\n"	 "* 10. Restart cluster and verify records\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestart3);  FINALIZER(runClearTable);}TESTCASE("SR4", 	 "System restart test. Focus on testing restart from with\n"	 "not all nodes alive when system went down but running LCP at\n"	 "high speed so that sometimes a TO is required to start cluster\n"	 "* 1. Load data\n"	 "* 2. Restart 1 node -nostart\n"	 "* 3. Update records\n"	 "* 4. Restart cluster and verify records\n"	 "* 5. Restart 1 node -nostart\n"	 "* 6. Delete half of the records\n"	 "* 7. Restart cluster and verify records\n"	 "* 8. Restart 1 node -nostart\n"	 "* 9. Delete all records\n"	 "* 10. Restart cluster and verify records\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestart4);  FINALIZER(runClearTable);}TESTCASE("SR5", 	 "As SR4 but making restart aborts\n"	 "* 1. Load data\n"	 "* 2. Restart 1 node -nostart\n"	 "* 3. Update records\n"	 "* 4. Restart cluster and verify records\n"	 "* 5. Restart 1 node -nostart\n"	 "* 6. Delete half of the records\n"	 "* 7. Restart cluster and verify records\n"	 "* 8. Restart 1 node -nostart\n"	 "* 9. Delete all records\n"	 "* 10. Restart cluster and verify records\n"){  INITIALIZER(runWaitStarted);  STEP(runSystemRestart5);  FINALIZER(runClearTable);}TESTCASE("SR6", 	 "Perform system restart with some nodes having FS others wo/\n"	 "* 1. Load data\n"	 "* 2. Restart all node -nostart\n"	 "* 3. Restart some nodes -i -nostart\n"	 "* 4. Start all nodes verify records\n"){  INITIALIZER(runWaitStarted);  INITIALIZER(runClearTable);  STEP(runSystemRestart6);  FINALIZER(runClearTable);}TESTCASE("SR7", 	 "Perform partition win system restart\n"	 "* 1. Load data\n"	 "* 2. Restart all node -nostart\n"	 "* 3. Start all but one node\n"	 "* 4. Verify records\n"	 "* 5. Start last node\n"	 "* 6. Verify records\n"){  INITIALIZER(runWaitStarted);  INITIALIZER(runClearTable);  STEP(runSystemRestart7);  FINALIZER(runClearTable);}TESTCASE("SR8", 	 "Perform partition win system restart with other nodes delayed\n"	 "* 1. Load data\n"	 "* 2. Restart all node -nostart\n"	 "* 3. Start all but one node\n"	 "* 4. Wait for startphase >= 2\n"	 "* 5. Start last node\n"	 "* 6. Verify records\n"){  INITIALIZER(runWaitStarted);  INITIALIZER(runClearTable);  STEP(runSystemRestart8);  FINALIZER(runClearTable);}TESTCASE("SR9", 	 "Perform partition win system restart with other nodes delayed\n"	 "* 1. Start transaction\n"	 "* 2. insert (1,1)\n"	 "* 3. update (1,2)\n"	 "* 4. start lcp\n"	 "* 5. commit\n"	 "* 6. restart\n"){  INITIALIZER(runWaitStarted);  INITIALIZER(runClearTable);  STEP(runSystemRestart9);  FINALIZER(runClearTable);}TESTCASE("Bug18385", 	 "Perform partition system restart with other nodes with higher GCI"){  INITIALIZER(runWaitStarted);  INITIALIZER(runClearTable);  STEP(runBug18385);  FINALIZER(runClearTable);}NDBT_TESTSUITE_END(testSystemRestart);int main(int argc, const char** argv){  ndb_init();  return testSystemRestart.execute(argc, argv);}

⌨️ 快捷键说明

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