testscan.cpp

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

CPP
1,653
字号
    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runEqualAfterOpenScan(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::EqualAfterOpenScan,			      false) == NDBT_OK){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::EqualAfterOpenScan,			      true) == NDBT_OK){    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runOnlyOpenScanOnce(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  g_info << "OnlyOpenScanOnce openScanRead" << endl;  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::OnlyOpenScanOnce,			      false) == 0){    numFailed++;  }  g_info << "OnlyOpenScanOnce openScanExclusive" << endl;  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      6,			      ScanFunctions::OnlyOpenScanOnce,			      true) == 0){    numFailed++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runOnlyOneOpInScanTrans(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runExecuteScanWithoutOpenScan(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runOnlyOneOpBeforeOpenScan(NDBT_Context* ctx, NDBT_Step* step){    return NDBT_OK;}int runOnlyOneScanPerTrans(NDBT_Context* ctx, NDBT_Step* step){  return NDBT_OK;}int runNoCloseTransaction(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  int l = 0;  while(l < loops){    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				6,				ScanFunctions::NoCloseTransaction,				false) != 0){      numFailed++;    }    if (scanF.scanReadFunctions(GETNDB(step), 				records, 				6,				ScanFunctions::NoCloseTransaction,				true) != 0){      numFailed++;    }    l++;  }      if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runCheckInactivityTimeOut(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      1,			      ScanFunctions::CheckInactivityTimeOut,			      false) != NDBT_OK){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      240,			      ScanFunctions::CheckInactivityTimeOut,			      true) != NDBT_OK){    numFailed++;  }    if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runCheckInactivityBeforeClose(NDBT_Context* ctx, NDBT_Step* step){  const NdbDictionary::Table*  pTab = ctx->getTab();  int records = ctx->getNumRecords();  int numFailed = 0;  ScanFunctions scanF(*pTab);  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      16,			      ScanFunctions::CheckInactivityBeforeClose,			      false) != 0){    numFailed++;  }  if (scanF.scanReadFunctions(GETNDB(step), 			      records, 			      240,			      ScanFunctions::CheckInactivityBeforeClose,			      true) != 0){    numFailed++;  }    if(numFailed > 0)    return NDBT_FAILED;  else    return NDBT_OK;}int runScanRestart(NDBT_Context* ctx, NDBT_Step* step){  int loops = ctx->getNumLoops();  int records = ctx->getNumRecords();  Ndb * pNdb = GETNDB(step);  const NdbDictionary::Table*  pTab = ctx->getTab();  HugoCalculator calc(* pTab);  NDBT_ResultRow tmpRow(* pTab);  int i = 0;  while (i<loops && !ctx->isTestStopped()) {    g_info << i++ << ": ";    const int record = (rand() % records);    g_info << " row=" << record;    NdbConnection* pCon = pNdb->startTransaction();    NdbScanOperation* pOp = pCon->getNdbScanOperation(pTab->getName());	    if (pOp == NULL) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }        if( pOp->readTuples() ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }      int check = pOp->interpret_exit_ok();    if( check == -1 ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }        // Define attributes to read      for(int a = 0; a<pTab->getNoOfColumns(); a++){      if((tmpRow.attributeStore(a) = 	  pOp->getValue(pTab->getColumn(a)->getName())) == 0) {	ERR(pCon->getNdbError());	return NDBT_FAILED;      }    }         check = pCon->execute(NoCommit);    if( check == -1 ) {      ERR(pCon->getNdbError());      return NDBT_FAILED;    }    int res;    int row = 0;    while(row < record && (res = pOp->nextResult()) == 0) {      if(calc.verifyRowValues(&tmpRow) != 0){	abort();	return NDBT_FAILED;      }      row++;    }    if(row != record){      ERR(pCon->getNdbError());      abort();      return NDBT_FAILED;    }    g_info << " restarting" << endl;    if((res = pOp->restart()) != 0){      ERR(pCon->getNdbError());      abort();      return NDBT_FAILED;    }          row = 0;    while((res = pOp->nextResult()) == 0) {      if(calc.verifyRowValues(&tmpRow) != 0){	abort();	return NDBT_FAILED;      }      row++;    }    if(res != 1 || row != records){      ERR(pCon->getNdbError());      abort();      return NDBT_FAILED;    }    pCon->close();  }  return NDBT_OK;}int runScanParallelism(NDBT_Context* ctx, NDBT_Step* step){  int loops = ctx->getNumLoops() + 3;  int records = ctx->getNumRecords();  int abort = ctx->getProperty("AbortProb", 15);    Uint32 fib[] = { 1, 2 };  Uint32 parallelism = 0; // start with 0  int i = 0;  HugoTransactions hugoTrans(*ctx->getTab());  while (i<loops && !ctx->isTestStopped()) {    g_info << i << ": ";    if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,				  NdbOperation::LM_Read) != 0){      return NDBT_FAILED;    }    if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,				  NdbOperation::LM_Exclusive) != 0){      return NDBT_FAILED;    }    if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,				  NdbOperation::LM_CommittedRead) != 0){      return NDBT_FAILED;    }    if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism)	!= 0){      return NDBT_FAILED;    }    i++;    parallelism = fib[0];    Uint32 next = fib[0] + fib[1];    fib[0] = fib[1];    fib[1] = next;  }  return NDBT_OK;}intrunBug24447(NDBT_Context* ctx, NDBT_Step* step){  int loops = 1; //ctx->getNumLoops();  int records = ctx->getNumRecords();  int abort = ctx->getProperty("AbortProb", 15);  NdbRestarter restarter;  HugoTransactions hugoTrans(*ctx->getTab());  int i = 0;  while (i<loops && !ctx->isTestStopped())   {    g_info << i++ << ": ";    int nodeId = restarter.getRandomNotMasterNodeId(rand());    if (nodeId == -1)      nodeId = restarter.getMasterNodeId();    if (restarter.insertErrorInNode(nodeId, 8038) != 0)    {      ndbout << "Could not insert error in node="<<nodeId<<endl;      return NDBT_FAILED;    }    for (Uint32 j = 0; i<10; i++)    {      hugoTrans.scanReadRecords(GETNDB(step), records, abort, 0, 				NdbOperation::LM_CommittedRead);    }  }  restarter.insertErrorInAllNodes(0);    return NDBT_OK;}NDBT_TESTSUITE(testScan);TESTCASE("ScanRead", 	 "Verify scan requirement: It should be possible "\	 "to read all records in a table without knowing their "\	 "primary key."){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 1);  STEP(runScanRead);  FINALIZER(runClearTable);}TESTCASE("ScanRead16", 	 "Verify scan requirement: It should be possible to scan read "\	 "with parallelism, test with parallelism 16"){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 16);  STEP(runScanRead);  FINALIZER(runClearTable);}TESTCASE("ScanRead240", 	 "Verify scan requirement: It should be possible to scan read with "\	 "parallelism, test with parallelism 240(240 would automatically be "\	 "downgraded to the maximum parallelism value for the current config)"){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 240);  STEP(runScanRead);  FINALIZER(runClearTable);}TESTCASE("ScanReadCommitted240", 	 "Verify scan requirement: It should be possible to scan read committed with "\	 "parallelism, test with parallelism 240(240 would automatically be "\	 "downgraded to the maximum parallelism value for the current config)"){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 240);  TC_PROPERTY("TupScan", (Uint32)0);  STEP(runScanReadCommitted);  FINALIZER(runClearTable);}TESTCASE("ScanTupReadCommitted240", 	 "Verify scan requirement: It should be possible to scan read committed with "\	 "parallelism, test with parallelism 240(240 would automatically be "\	 "downgraded to the maximum parallelism value for the current config). "\         "Scans TUP pages directly without using ACC."){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 240);  TC_PROPERTY("TupScan", 1);  STEP(runScanReadCommitted);  FINALIZER(runClearTable);}TESTCASE("ScanUpdate", 	 "Verify scan requirement: It should be possible "\	 "to update all records in a table without knowing their"\	 " primary key."){  INITIALIZER(runLoadTable);  STEP(runScanUpdate);  FINALIZER(runClearTable);}TESTCASE("ScanUpdate2", 	 "Verify scan requirement: It should be possible "\	 "to update all records in a table without knowing their"\	 " primary key. Do this efficently by calling nextScanResult(false) "\	 "in order to update the records already fetched to the api in one batch."){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 240);  STEP(runScanUpdate2);  FINALIZER(runClearTable);}TESTCASE("ScanDelete", 	 "Verify scan requirement: It should be possible "\	 "to delete all records in a table without knowing their"\	 " primary key."){  INITIALIZER(runLoadTable);  STEP(runScanDelete);  FINALIZER(runClearTable);}TESTCASE("ScanDelete2", 	 "Verify scan requirement: It should be possible "\	 "to delete all records in a table without knowing their"\	 " primary key. Do this efficently by calling nextScanResult(false) "\	 "in order to delete the records already fetched to the api in one batch."){  INITIALIZER(runLoadTable);  TC_PROPERTY("Parallelism", 240);  STEP(runScanDelete2);  FINALIZER(runClearTable);

⌨️ 快捷键说明

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