19 #include <NDBT_Test.hpp>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <NdbRestarter.hpp>
24 #include "ScanFunctions.hpp"
26 #include <signaldata/DumpStateOrd.hpp>
29 getTable(
Ndb* pNdb,
int i){
40 int records = ctx->getProperty(
"Rows", ctx->getNumRecords());
43 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
52 int a = NDBT_Tables::createAllTables(GETNDB(step),
false,
true);
58 for (
int i=0; i < NDBT_Tables::getNumTables(); i++){
62 return NDBT_ProgramExit(NDBT_FAILED);
65 GETNDB(step)->getDictionary()->dropTable(tab->
getName());
72 int records = ctx->getNumRecords();
73 for (
int i=0; i < NDBT_Tables::getNumTables(); i++){
81 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
88 char orderedPkIdxName[255];
93 Ndb* pNdb = GETNDB(step);
97 "IDC_O_PK_%s", pTab->
getName());
101 pIdx.setLogging(
false);
106 pIdx.addIndexColumn(col->
getName());
111 ndbout <<
"FAILED! to create index" << endl;
122 Ndb* pNdb = GETNDB(step);
127 ndbout <<
"FAILED! to drop index" << endl;
137 int loops = ctx->getNumLoops();
138 int records = ctx->getNumRecords();
139 int parallelism = ctx->getProperty(
"Parallelism", 240);
140 int abort = ctx->getProperty(
"AbortProb", 5);
145 int tabNum = myRandom48(NDBT_Tables::getNumTables());
148 g_info <<
"tab == NULL" << endl;
152 g_info <<
"Scan reading from table " << tab->
getName() << endl;
156 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism) != 0){
165 int loops = ctx->getNumLoops();
166 int records = ctx->getNumRecords();
167 int parallelism = ctx->getProperty(
"Parallelism", 240);
168 int abort = ctx->getProperty(
"AbortProb", 5);
173 bool chosenTable=
false;
176 int tabNum = myRandom48(NDBT_Tables::getNumTables());
177 tab = getTable(GETNDB(step), tabNum);
179 g_info <<
"tab == NULL" << endl;
186 g_info <<
"Scan reading from table " << tab->
getName() << endl;
190 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism) != 0){
199 int records = ctx->getNumRecords();
202 while (ctx->isTestStopped() ==
false) {
204 if (hugoTrans.loadTable(GETNDB(step), records, 1) != 0){
213 int result = NDBT_OK;
214 int records = ctx->getNumRecords();
215 int loops = ctx->getNumLoops();
221 if (hugoTrans.loadTable(GETNDB(step), records, 1) != 0){
222 result = NDBT_FAILED;
225 if (utilTrans.clearTable(GETNDB(step), records) != 0){
226 result = NDBT_FAILED;
238 int records = ctx->getNumRecords();
241 if (utilTrans.clearTable2(GETNDB(step), records) != 0){
248 int loops = ctx->getNumLoops();
249 int records = ctx->getNumRecords();
256 if (utilTrans.clearTable(GETNDB(step), records) != 0){
260 if (hugoTrans.loadTable(GETNDB(step), records, 512,
false) != 0){
269 int loops = ctx->getNumLoops();
270 int records = ctx->getNumRecords();
278 if (utilTrans.clearTable2(GETNDB(step), records) != 0){
282 if (hugoTrans.loadTable(GETNDB(step), records, 512,
false) != 0){
295 int loops = ctx->getNumLoops();
296 int records = ctx->getProperty(
"Rows", ctx->getNumRecords());
297 int parallelism = ctx->getProperty(
"Parallelism", 240);
298 int abort = ctx->getProperty(
"AbortProb", 5);
299 int tupscan = ctx->getProperty(
"TupScan", (Uint32)0);
304 while (i<loops && !ctx->isTestStopped()) {
310 scan_flags |= NdbScanOperation::SF_TupScan;
311 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
316 else if (hugoTrans.scanReadRecords(GETNDB(step), records, abort,
328 int loops = ctx->getNumLoops();
329 int records = ctx->getNumRecords();
330 int parallelism = ctx->getProperty(
"Parallelism", 240);
331 int abort = ctx->getProperty(
"AbortProb", 5);
332 int tupscan = ctx->getProperty(
"TupScan", (Uint32)0);
333 int lmarg = ctx->getProperty(
"LockMode", ~Uint32(0));
334 int nocount = ctx->getProperty(
"NoCount", Uint32(0));
341 while (i<loops && !ctx->isTestStopped()) {
349 scan_flags |= NdbScanOperation::SF_TupScan;
350 else if (tupscan == 2 && ((rand() & 0x800)))
352 scan_flags |= NdbScanOperation::SF_TupScan;
355 if (hugoTrans.scanReadRecords(GETNDB(step),
356 records, abort, parallelism,
367 int loops = ctx->getNumLoops();
368 int records = ctx->getProperty(
"Rows", ctx->getNumRecords());
369 int parallelism = ctx->getProperty(
"Parallelism", 240);
370 int abort = ctx->getProperty(
"AbortProb", 5);
372 int rand_mode = ctx->getProperty(
"RandScanOptions", Uint32(1));
374 GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName,
379 while (pIdx && i<loops && !ctx->isTestStopped()) {
381 bool sort = (rand() % 100) > 50 ?
true :
false;
382 bool desc = (rand() % 100) > 50 ?
true :
false;
392 (NdbScanOperation::SF_OrderBy & -(int)sort) |
393 (NdbScanOperation::SF_Descending & -(int)desc);
394 if (hugoTrans.scanReadRecords(GETNDB(step), pIdx,
395 records, abort, parallelism,
406 int loops = ctx->getNumLoops();
407 int records = ctx->getNumRecords();
408 int parallelism = ctx->getProperty(
"Parallelism", 240);
409 int abort = ctx->getProperty(
"AbortProb", 5);
410 bool tupScan = ctx->getProperty(
"TupScan");
411 int scan_flags = (NdbScanOperation::SF_TupScan & -(int)tupScan);
415 while (i<loops && !ctx->isTestStopped()) {
417 if (hugoTrans.scanReadRecords(GETNDB(step), records,
429 int result = NDBT_OK;
430 int loops = ctx->getNumLoops();
431 int records = ctx->getNumRecords();
432 int parallelism = 240;
433 int error = ctx->getProperty(
"ErrorCode");
438 while (i<loops && !ctx->isTestStopped()) {
441 ndbout <<
"insertErrorInAllNodes("<<error<<
")"<<endl;
442 if (restarter.insertErrorInAllNodes(error) != 0){
443 ndbout <<
"Could not insert error in all nodes "<<endl;
447 if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, parallelism) != 0){
448 result = NDBT_FAILED;
453 restarter.insertErrorInAllNodes(0);
459 int error = ctx->getProperty(
"ErrorCode");
462 ctx->setProperty(
"ErrorCode", (Uint32)0);
463 if (restarter.insertErrorInAllNodes(error) != 0){
464 ndbout <<
"Could not insert error in all nodes "<<endl;
471 int result = NDBT_OK;
472 int loops = ctx->getNumLoops();
473 int records = ctx->getNumRecords();
474 int parallelism = 240;
475 int error = ctx->getProperty(
"ErrorCode");
479 if (restarter.getNumDbNodes() < 2){
486 while (i<loops && result == NDBT_OK) {
489 int nodeId = restarter.getDbNodeId(lastId);
490 lastId = (lastId + 1) % restarter.getNumDbNodes();
491 ndbout <<
"insertErrorInNode("<<nodeId<<
", "<<error<<
")"<<endl;
492 if (restarter.insertErrorInNode(nodeId, error) != 0){
493 ndbout <<
"Could not insert error in node="<<nodeId<<endl;
497 for (
int j=0; j<10; j++){
498 if (hugoTrans.scanReadRecords(GETNDB(step),
499 records, 0, parallelism) != 0)
500 result = NDBT_FAILED;
504 if(restarter.waitClusterStarted(120) != 0){
505 g_err <<
"Cluster failed to restart" << endl;
506 result = NDBT_FAILED;
508 restarter.insertErrorInAllNodes(0);
512 restarter.insertErrorInAllNodes(0);
520 if (restarter.restartAll() != 0){
521 ndbout <<
"Could not restart all nodes"<<endl;
525 if (restarter.waitClusterStarted(120) != 0){
526 ndbout <<
"Could not restarted" << endl;
533 static int RANDOM_PARALLELISM = 9999;
536 int records = ctx->getNumRecords();
539 int parallelism = ctx->getProperty(
"Parallelism", 240);
540 int para = parallelism;
543 while (ctx->isTestStopped() ==
false) {
544 if (parallelism == RANDOM_PARALLELISM)
545 para = myRandom48(239)+1;
548 if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, para) != 0){
559 while (ctx->isTestStopped() ==
false) {
561 if (hugoTrans.scanReadRecords(GETNDB(step), 0) != 0){
570 int records = ctx->getNumRecords();
572 int parallelism = ctx->getProperty(
"Parallelism", 240);
574 Ndb* ndb = GETNDB(step);
578 while (ctx->isTestStopped() ==
false) {
584 if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, parallelism) != 0)
587 if ((timer.elapsedTime()/1000) > 1)
588 timer.printTotalTime();
596 int loops = ctx->getNumLoops();
597 int records = ctx->getNumRecords();
602 if (hugoTrans.pkReadRecords(GETNDB(step), records) != 0){
611 int loops = ctx->getNumLoops();
612 int records = ctx->getNumRecords();
613 int parallelism = ctx->getProperty(
"Parallelism", 1);
614 int abort = ctx->getProperty(
"AbortProb", 5);
620 if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism) != 0){
632 int parallelism = ctx->getProperty(
"Parallelism", 240);
633 int para = parallelism;
636 while (ctx->isTestStopped() ==
false) {
637 if (parallelism == RANDOM_PARALLELISM)
638 para = myRandom48(239)+1;
641 if (hugoTrans.scanUpdateRecords(GETNDB(step), 0, 0, para) == NDBT_FAILED){
651 int loops = ctx->getNumLoops();
652 int records = ctx->getNumRecords();
653 int parallelism = ctx->getProperty(
"Parallelism", 240);
654 int abort = ctx->getProperty(
"AbortProb", 5);
659 if (hugoTrans.scanUpdateRecords2(GETNDB(step), records, abort, parallelism) != 0){
668 int result = NDBT_OK;
669 int records = ctx->getNumRecords();
672 if (hugoTrans.lockRecords(GETNDB(step), records, 5, 500) != 0){
673 result = NDBT_FAILED;
681 int result = NDBT_OK;
682 int loops = ctx->getNumLoops();
688 if (restarter.getNumDbNodes() < 2){
692 while(i<loops && result != NDBT_FAILED){
693 if(restarter.waitClusterStarted(timeout) != 0){
694 g_err <<
"Cluster failed to start 1" << endl;
695 result = NDBT_FAILED;
698 NdbSleep_SecSleep(10);
700 int nodeId = restarter.getDbNodeId(lastId);
701 lastId = (lastId + 1) % restarter.getNumDbNodes();
702 if(restarter.restartOneDbNode(nodeId,
false,
false,
true) != 0){
703 g_err <<
"Failed to restartNextDbNode" << endl;
704 result = NDBT_FAILED;
709 if(restarter.waitClusterStarted(timeout) != 0){
710 g_err <<
"Cluster failed to start 2" << endl;
711 result = NDBT_FAILED;
721 int result = NDBT_OK;
722 int loops = ctx->getNumLoops();
728 if (restarter.getNumDbNodes() < 2){
732 while(i<loops && result != NDBT_FAILED){
733 if(restarter.waitClusterStarted(timeout) != 0){
734 g_err <<
"Cluster failed to start 1" << endl;
735 result = NDBT_FAILED;
738 NdbSleep_SecSleep(1);
739 int nodeId = restarter.getDbNodeId(lastId);
740 lastId = (lastId + 1) % restarter.getNumDbNodes();
741 g_err <<
"Stopping node " << nodeId << endl;
743 if(restarter.restartOneDbNode(nodeId,
false,
true) != 0){
744 g_err <<
"Failed to restartOneDbNode" << endl;
745 result = NDBT_FAILED;
749 if(restarter.waitNodesNoStart(&nodeId, 1, timeout) != 0){
750 g_err <<
"Node failed to reach NoStart" << endl;
751 result = NDBT_FAILED;
755 g_info <<
"Sleeping for 10 secs" << endl;
756 NdbSleep_SecSleep(10);
758 g_err <<
"Starting node " << nodeId << endl;
759 if(restarter.startNodes(&nodeId, 1) != 0){
760 g_err <<
"Failed to start the node" << endl;
761 result = NDBT_FAILED;
767 if(restarter.waitClusterStarted(timeout) != 0){
768 g_err <<
"Cluster failed to start 2" << endl;
769 result = NDBT_FAILED;
778 int result = NDBT_OK;
779 int loops = ctx->getNumLoops();
784 if (restarter.getNumDbNodes() < 2){
788 while(i<loops && result != NDBT_FAILED){
789 if(restarter.waitClusterStarted(120) != 0){
790 g_err <<
"Cluster failed to start" << endl;
791 result = NDBT_FAILED;
794 NdbSleep_SecSleep(10);
796 int nodeId = restarter.getDbNodeId(lastId);
797 lastId = (lastId + 1) % restarter.getNumDbNodes();
798 if(restarter.insertErrorInNode(nodeId, 9999) != 0){
799 g_err <<
"Failed to insertErrorInNode="<<nodeId << endl;
800 result = NDBT_FAILED;
803 NdbSleep_SecSleep(10);
806 if(restarter.waitClusterStarted(120) != 0){
807 g_err <<
"Cluster failed to start" << endl;
808 result = NDBT_FAILED;
819 int parallelism = ctx->getProperty(
"Parallelism", 1);
820 int records = ctx->getNumRecords();
823 alist.buildAttribList(pTab);
825 for(
size_t i = 0; i < alist.attriblist.size(); i++){
826 g_info << (unsigned)i << endl;
827 if(utilTrans.scanReadRecords(GETNDB(step),
831 alist.attriblist[i]->numAttribs,
832 alist.attriblist[i]->attribs) != 0){
835 if(utilTrans.scanReadRecords(GETNDB(step),
839 alist.attriblist[i]->numAttribs,
840 alist.attriblist[i]->attribs) != 0){
853 int records = ctx->getNumRecords();
857 for (
int p = 1; p<240; p++){
858 g_info << p <<
" CloseWithoutStop openScan" << endl;
859 if (scanF.scanReadFunctions(GETNDB(step),
862 ScanFunctions::CloseWithoutStop,
866 g_info << p <<
" CloseWithoutStop openScanExclusive" << endl;
867 if (scanF.scanReadFunctions(GETNDB(step),
870 ScanFunctions::CloseWithoutStop,
884 int records = ctx->getNumRecords();
887 if (scanF.scanReadFunctions(GETNDB(step),
890 ScanFunctions::NextScanWhenNoMore,
894 if (scanF.scanReadFunctions(GETNDB(step),
897 ScanFunctions::NextScanWhenNoMore,
911 int records = ctx->getNumRecords();
914 if (scanF.scanReadFunctions(GETNDB(step),
917 ScanFunctions::EqualAfterOpenScan,
921 if (scanF.scanReadFunctions(GETNDB(step),
924 ScanFunctions::EqualAfterOpenScan,
938 int records = ctx->getNumRecords();
941 g_info <<
"OnlyOpenScanOnce openScanRead" << endl;
942 if (scanF.scanReadFunctions(GETNDB(step),
945 ScanFunctions::OnlyOpenScanOnce,
949 g_info <<
"OnlyOpenScanOnce openScanExclusive" << endl;
950 if (scanF.scanReadFunctions(GETNDB(step),
953 ScanFunctions::OnlyOpenScanOnce,
983 int loops = ctx->getNumLoops();
984 int records = ctx->getNumRecords();
990 if (scanF.scanReadFunctions(GETNDB(step),
993 ScanFunctions::NoCloseTransaction,
997 if (scanF.scanReadFunctions(GETNDB(step),
1000 ScanFunctions::NoCloseTransaction,
1017 int records = ctx->getNumRecords();
1021 if (scanF.scanReadFunctions(GETNDB(step),
1024 ScanFunctions::CheckInactivityTimeOut,
1028 if (scanF.scanReadFunctions(GETNDB(step),
1031 ScanFunctions::CheckInactivityTimeOut,
1045 int records = ctx->getNumRecords();
1049 if (scanF.scanReadFunctions(GETNDB(step),
1052 ScanFunctions::CheckInactivityBeforeClose,
1056 if (scanF.scanReadFunctions(GETNDB(step),
1059 ScanFunctions::CheckInactivityBeforeClose,
1073 int loops = ctx->getNumLoops() + 3;
1074 int records = ctx->getNumRecords();
1075 int abort = ctx->getProperty(
"AbortProb", 15);
1077 Uint32 fib[] = { 1, 2 };
1078 Uint32 parallelism = 0;
1081 while (i<loops && !ctx->isTestStopped()) {
1082 g_info << i <<
": ";
1084 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1088 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1092 if (hugoTrans.scanReadRecords(GETNDB(step), records, abort, parallelism,
1096 if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort, parallelism)
1101 parallelism = fib[0];
1102 Uint32 next = fib[0] + fib[1];
1114 Ndb * pNdb = GETNDB(step);
1124 for (
int batch = 0; batch < 100; batch += (1 + batch + (batch >> 3)))
1126 for (
int par = 0; par < 16; par += 1 + (rand() % 3))
1128 bool disk =
flags & 1;
1129 bool tups =
flags & 2;
1130 g_info <<
"lm: " << lm
1131 <<
" disk: " << disk
1132 <<
" tup scan: " << tups
1134 <<
" batch: " << batch
1145 tups ? NdbScanOperation::SF_TupScan : 0,
1154 bool found_disk =
false;
1156 if (pTab->
getColumn(a)->getStorageType() ==
1157 NdbDictionary::Column::StorageTypeDisk)
1170 if (! (disk && !found_disk))
1172 int check = pCon->
execute(NoCommit);
1192 Ndb * pNdb = GETNDB(step);
1208 if( pOp->
getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1232 int records = ctx->getNumRecords();
1233 int abort = ctx->getProperty(
"AbortProb", 15);
1237 while (i<loops && !ctx->isTestStopped())
1239 g_info << i++ <<
": ";
1241 int nodeId = restarter.getRandomNotMasterNodeId(rand());
1243 nodeId = restarter.getMasterNodeId();
1244 if (restarter.insertErrorInNode(nodeId, 8038) != 0)
1246 ndbout <<
"Could not insert error in node="<<nodeId<<endl;
1250 for (Uint32 j = 0; j<10; j++)
1252 hugoTrans.scanReadRecords(GETNDB(step), records, abort, 0,
1257 restarter.insertErrorInAllNodes(0);
1264 int loops = ctx->getNumLoops();
1266 Ndb* pNdb = GETNDB(step);
1269 if (res.getNumDbNodes() < 2)
1276 GETNDB(step)->getDictionary()->getIndex(orderedPkIdxName,
1281 while (pIdx && i++ < loops && !ctx->isTestStopped())
1283 g_info << i <<
": ";
1293 translist.push_back(p2);
1298 for (
size_t t = 0; t < translist.size(); t++)
1299 translist[t]->close();
1307 NdbScanOperation::SF_OrderBy);
1309 ndbout <<
"Restart node " << nodeId << endl;
1310 res.restartOneDbNode(nodeId,
false,
true,
true);
1315 res.waitNodesNoStart(&nodeId, 1);
1316 res.startNodes(&nodeId, 1);
1317 res.waitNodesStarted(&nodeId, 1);
1324 ndbout_c(
"r0: %d r1: %d r2: %d", r0, r1, r2);
1335 int dump[] = { 7017 };
1337 res.dumpStateAllNodes(dump, 1);
1344 int dump[] = { 7017, 1 };
1346 res.dumpStateAllNodes(dump, 2);
1356 int loops = ctx->getNumLoops();
1359 Ndb* pNdb = GETNDB(step);
1362 if (res.getNumDbNodes() < 2)
1370 int node = res.getNode(NdbRestarter::NS_RANDOM);
1372 printf(
"node: %u ", node);
1375 if (res.getNumDbNodes() >= 2)
1378 int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1379 res.dumpStateOneNode(node, val, 2);
1380 res.insertErrorInNode(node, 8088);
1381 ndbout_c(
"error 8088");
1387 res.insertErrorInNode(node, 5057);
1388 ndbout_c(
"error 5057");
1392 for (
int i = 0; i< 25; i++)
1407 if( pOp->
getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1418 res.waitNodesNoStart(&node, 1);
1420 res.waitClusterStarted();
1430 Ndb * pNdb = GETNDB(step);
1432 const Uint32 codeWords= 1;
1433 Uint32 codeSpace[ codeWords ];
1437 if ((
code.interpret_exit_last_row() != 0) ||
1438 (
code.finalise() != 0))
1440 ERR(
code.getNdbError());
1466 if (pOp->
getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1495 if (pOp->
getValue(NdbDictionary::Column::ROW_COUNT) == 0)
1507 #define CHK_RET_FAILED(x) if (!(x)) { ndbout_c("Failed on line: %u", __LINE__); return NDBT_FAILED; }
1512 Ndb* pNdb = GETNDB(step);
1515 unsigned seed = (unsigned)NdbTick_CurrentMillisecond();
1517 const int rows = ctx->getNumRecords();
1518 const int loops = 10 * ctx->getNumLoops();
1519 const int until_stopped = ctx->getProperty(
"UntilStopped");
1520 const int batch = ctx->getProperty(
"Batch", Uint32(50));
1523 CHK_RET_FAILED(pRowRecord != 0);
1525 const Uint32 len = NdbDictionary::getRecordRowLength(pRowRecord);
1526 Uint8 * pRow =
new Uint8[len];
1529 int count_failed = 0;
1530 for (
int i = 0; i < loops || (until_stopped && !ctx->isTestStopped()); i++)
1533 CHK_RET_FAILED(pTrans != 0);
1537 for (
int rowNo = 0; rowNo < batch; rowNo++)
1539 int left = rows - lastrow;
1540 int rowId = lastrow;
1543 rowId += ndb_rand_r(&seed) % (left / 10 + 1);
1554 calc.setValues(pRow, pRowRecord, rowId, rand());
1557 bzero(&opts,
sizeof(opts));
1560 switch(ndb_rand_r(&seed) % 3){
1562 pOp = pTrans->writeTuple(pRowRecord, (
char*)pRow,
1563 pRowRecord, (
char*)pRow,
1569 pOp = pTrans->deleteTuple(pRowRecord, (
char*)pRow,
1570 pRowRecord, (
char*)pRow,
1576 pOp = pTrans->updateTuple(pRowRecord, (
char*)pRow,
1577 pRowRecord, (
char*)pRow,
1583 CHK_RET_FAILED(pOp != 0);
1584 result = pTrans->
execute(NoCommit, AO_IgnoreError);
1591 result = pTrans->
execute(Commit, AO_IgnoreError);
1597 ndbout << err << endl;
1609 ndbout_c(
"count_ok: %d count_failed: %d",
1610 count_ok, count_failed);
1616 NDBT_TESTSUITE(testScan);
1617 TESTCASE(
"ScanRead",
1618 "Verify scan requirement: It should be possible "\
1619 "to read all records in a table without knowing their "\
1621 INITIALIZER(runLoadTable);
1622 TC_PROPERTY(
"Parallelism", 1);
1624 FINALIZER(runClearTable);
1626 TESTCASE(
"ScanRead16",
1627 "Verify scan requirement: It should be possible to scan read "\
1628 "with parallelism, test with parallelism 16"){
1629 INITIALIZER(runLoadTable);
1630 TC_PROPERTY(
"Parallelism", 16);
1632 FINALIZER(runClearTable);
1634 TESTCASE(
"ScanRead240",
1635 "Verify scan requirement: It should be possible to scan read with "\
1636 "parallelism, test with parallelism 240(240 would automatically be "\
1637 "downgraded to the maximum parallelism value for the current config)"){
1638 INITIALIZER(runLoadTable);
1639 TC_PROPERTY(
"Parallelism", 240);
1641 FINALIZER(runClearTable);
1643 TESTCASE(
"ScanReadCommitted240",
1644 "Verify scan requirement: It should be possible to scan read committed with "\
1645 "parallelism, test with parallelism 240(240 would automatically be "\
1646 "downgraded to the maximum parallelism value for the current config)"){
1647 INITIALIZER(runLoadTable);
1648 TC_PROPERTY(
"Parallelism", 240);
1649 TC_PROPERTY(
"TupScan", (Uint32)0);
1650 STEP(runScanReadCommitted);
1651 FINALIZER(runClearTable);
1653 TESTCASE(
"ScanUpdate",
1654 "Verify scan requirement: It should be possible "\
1655 "to update all records in a table without knowing their"\
1657 INITIALIZER(runLoadTable);
1658 STEP(runScanUpdate);
1659 FINALIZER(runClearTable);
1661 TESTCASE(
"ScanUpdate2",
1662 "Verify scan requirement: It should be possible "\
1663 "to update all records in a table without knowing their"\
1664 " primary key. Do this efficently by calling nextScanResult(false) "\
1665 "in order to update the records already fetched to the api in one batch."){
1666 INITIALIZER(runLoadTable);
1667 TC_PROPERTY(
"Parallelism", 240);
1668 STEP(runScanUpdate2);
1669 FINALIZER(runClearTable);
1671 TESTCASE(
"ScanDelete",
1672 "Verify scan requirement: It should be possible "\
1673 "to delete all records in a table without knowing their"\
1675 INITIALIZER(runLoadTable);
1676 STEP(runScanDelete);
1677 FINALIZER(runClearTable);
1679 TESTCASE(
"ScanDelete2",
1680 "Verify scan requirement: It should be possible "\
1681 "to delete all records in a table without knowing their"\
1682 " primary key. Do this efficently by calling nextScanResult(false) "\
1683 "in order to delete the records already fetched to the api in one batch."){
1684 INITIALIZER(runLoadTable);
1685 TC_PROPERTY(
"Parallelism", 240);
1686 STEP(runScanDelete2);
1687 FINALIZER(runClearTable);
1689 TESTCASE(
"ScanUpdateAndScanRead",
1690 "Verify scan requirement: It should be possible to run "\
1691 "scan read and scan update at the same time"){
1692 INITIALIZER(runLoadTable);
1693 TC_PROPERTY(
"Parallelism", 16);
1695 STEP(runScanUpdate);
1696 FINALIZER(runClearTable);
1698 TESTCASE(
"ScanReadAndLocker",
1699 "Verify scan requirement: The locks are not kept throughout "\
1700 "the entire scan operation. This means that a scan does not "\
1701 "lock the entire table, only the records it's currently "\
1702 "operating on. This will test how scan performs when there are "\
1703 " a number of 1 second locks in the table"){
1704 INITIALIZER(runLoadTable);
1705 STEP(runScanReadUntilStopped);
1707 FINALIZER(runClearTable);
1709 TESTCASE(
"ScanReadAndPkRead",
1710 "Verify scan requirement: The locks are not kept throughout "\
1711 "the entire scan operation. This means that a scan does not "\
1712 "lock the entire table, only the records it's currently "\
1713 "operating on. This will test how scan performs when there are "\
1715 INITIALIZER(runLoadTable);
1716 STEPS(runScanRead, 2);
1717 STEPS(runPkRead, 2);
1718 FINALIZER(runClearTable);
1720 TESTCASE(
"ScanRead488",
1721 "Verify scan requirement: It's only possible to have 11 concurrent "\
1722 "scans per fragment running in Ndb kernel at the same time. "\
1723 "When this limit is exceeded the scan will be aborted with errorcode "\
1725 INITIALIZER(runLoadTable);
1726 STEPS(runRandScanRead, 70);
1727 FINALIZER(runClearTable);
1729 TESTCASE(
"ScanRead488T",
1730 "Verify scan requirement: It's only possible to have 11 concurrent "\
1731 "scans per fragment running in Ndb kernel at the same time. "\
1732 "When this limit is exceeded the scan will be aborted with errorcode "\
1734 TC_PROPERTY(
"TupScan", 1);
1735 INITIALIZER(runLoadTable);
1736 STEPS(runRandScanRead, 70);
1737 FINALIZER(runClearTable);
1739 TESTCASE(
"ScanRead488O",
1740 "Verify scan requirement: It's only possible to have 11 concurrent "\
1741 "scans per fragment running in Ndb kernel at the same time. "\
1742 "When this limit is exceeded the scan will be aborted with errorcode "\
1744 INITIALIZER(createOrderedPkIndex);
1745 INITIALIZER(runLoadTable);
1746 STEPS(runScanReadIndex, 70);
1747 FINALIZER(createOrderedPkIndex_Drop);
1748 FINALIZER(runClearTable);
1750 TESTCASE(
"ScanRead488_Mixed",
1751 "Verify scan requirement: It's only possible to have 11 concurrent "\
1752 "scans per fragment running in Ndb kernel at the same time. "\
1753 "When this limit is exceeded the scan will be aborted with errorcode "\
1755 TC_PROPERTY(
"TupScan", 2);
1756 INITIALIZER(createOrderedPkIndex);
1757 INITIALIZER(runLoadTable);
1758 STEPS(runRandScanRead, 50);
1759 STEPS(runScanReadIndex, 50);
1760 FINALIZER(createOrderedPkIndex_Drop);
1761 FINALIZER(runClearTable);
1763 TESTCASE(
"ScanRead488Timeout",
1765 INITIALIZER(runLoadTable);
1766 TC_PROPERTY(
"ErrorCode", 5034);
1767 STEPS(runScanRead, 30);
1768 STEP(runScanReadError);
1769 FINALIZER(runClearTable);
1771 TESTCASE(
"ScanRead40",
1772 "Verify scan requirement: Scan with 40 simultaneous threads"){
1773 INITIALIZER(runLoadTable);
1774 STEPS(runScanRead, 40);
1775 FINALIZER(runClearTable);
1777 TESTCASE(
"ScanRead100",
1778 "Verify scan requirement: Scan with 100 simultaneous threads"){
1779 INITIALIZER(runLoadTable);
1780 STEPS(runScanRead, 100);
1781 FINALIZER(runClearTable);
1783 TESTCASE(
"TupScanRead100",
1784 "Verify scan requirement: Scan with 100 simultaneous threads"){
1785 TC_PROPERTY(
"TupScan", 1);
1786 INITIALIZER(runLoadTable);
1787 STEPS(runScanRead, 100);
1788 FINALIZER(runClearTable);
1790 TESTCASE(
"Scan-bug8262",
1792 TC_PROPERTY(
"Rows", 1);
1793 TC_PROPERTY(
"ErrorCode", 8035);
1794 INITIALIZER(runLoadTable);
1795 INITIALIZER(runInsertError);
1796 STEPS(runScanRead, 25);
1797 FINALIZER(runInsertError);
1798 FINALIZER(runClearTable);
1800 TESTCASE(
"ScanRead40RandomTable",
1801 "Verify scan requirement: Scan with 40 simultaneous threads. "\
1802 "Use random table for the scan"){
1803 INITIALIZER(runCreateAllTables);
1804 INITIALIZER(runLoadAllTables);
1805 STEPS(runScanReadRandomTable, 40);
1806 FINALIZER(runDropAllTablesExceptTestTable);
1808 TESTCASE(
"ScanRead100RandomTable",
1809 "Verify scan requirement: Scan with 100 simultaneous threads. "\
1810 "Use random table for the scan"){
1811 INITIALIZER(runCreateAllTables);
1812 INITIALIZER(runLoadAllTables);
1813 STEPS(runScanReadRandomTable, 100);
1814 FINALIZER(runDropAllTablesExceptTestTable);
1816 TESTCASE(
"ScanReadRandomPrepare",
1817 "Create and load tables for ScanRead40RandomNoTableCreate."){
1818 INITIALIZER(runCreateAllTables);
1819 INITIALIZER(runLoadAllTables);
1821 TESTCASE(
"ScanRead40RandomNoTableCreate",
1822 "Verify scan requirement: Scan with 40 simultaneous threads. "\
1823 "Use random table for the scan. Dont create or load the tables."){
1824 STEPS(runScanReadRandomTableExceptTestTable, 40);
1826 TESTCASE(
"ScanRead100RandomNoTableCreate",
1827 "Verify scan requirement: Scan with 100 simultaneous threads. "\
1828 "Use random table for the scan. Dont create or load the tables."){
1829 STEPS(runScanReadRandomTableExceptTestTable, 100);
1831 TESTCASE(
"ScanWithLocksAndInserts",
1832 "TR457: This test is added to verify that an insert of a records "\
1833 "that is already in the database does not delete the record"){
1834 INITIALIZER(runLoadTable);
1835 STEPS(runScanReadUntilStopped, 2);
1837 STEP(runInsertUntilStopped);
1838 FINALIZER(runClearTable);
1840 TESTCASE(
"ScanReadAbort",
1841 "Scan requirement: A scan may be aborted by the application "\
1842 "at any time. This can be performed even if there are more "\
1844 INITIALIZER(runLoadTable);
1845 TC_PROPERTY(
"AbortProb", 90);
1846 STEPS(runScanRead, 3);
1847 FINALIZER(runClearTable);
1849 TESTCASE(
"ScanReadAbort15",
1850 "Scan requirement: A scan may be aborted by the application "\
1851 "at any time. This can be performed even if there are more "\
1852 "tuples to scan. Use parallelism 15"){
1853 INITIALIZER(runLoadTable);
1854 TC_PROPERTY(
"Parallelism", 15);
1855 TC_PROPERTY(
"AbortProb", 90);
1856 STEPS(runScanRead, 3);
1857 FINALIZER(runClearTable);
1859 TESTCASE(
"ScanReadAbort240",
1860 "Scan requirement: A scan may be aborted by the application "\
1861 "at any time. This can be performed even if there are more "\
1862 "tuples to scan. Use parallelism 240(it will be downgraded to max para for this config)"){
1863 INITIALIZER(runLoadTable);
1864 TC_PROPERTY(
"Parallelism", 240);
1865 TC_PROPERTY(
"AbortProb", 90);
1866 STEPS(runScanRead, 3);
1867 FINALIZER(runClearTable);
1869 TESTCASE(
"ScanUpdateAbort16",
1870 "Scan requirement: A scan may be aborted by the application "\
1871 "at any time. This can be performed even if there are more "\
1872 "tuples to scan. Use parallelism 16"){
1873 INITIALIZER(runLoadTable);
1874 TC_PROPERTY(
"Parallelism", 16);
1875 TC_PROPERTY(
"AbortProb", 90);
1876 STEPS(runScanUpdate, 3);
1877 FINALIZER(runClearTable);
1879 TESTCASE(
"ScanUpdateAbort240",
1880 "Scan requirement: A scan may be aborted by the application "\
1881 "at any time. This can be performed even if there are more "\
1882 "tuples to scan. Use parallelism 240(it will be downgraded to max para for this config)"){
1883 INITIALIZER(runLoadTable);
1884 TC_PROPERTY(
"Parallelism", 240);
1885 TC_PROPERTY(
"AbortProb", 90);
1886 STEPS(runScanUpdate, 3);
1887 FINALIZER(runClearTable);
1889 TESTCASE(
"CheckGetValue",
1890 "Check that we can call getValue to read attributes"\
1891 "Especially interesting to see if we can read only the"\
1892 " first, last or any two attributes from the table"){
1893 INITIALIZER(runLoadTable);
1894 STEP(runCheckGetValue);
1895 VERIFIER(runScanRead);
1896 FINALIZER(runClearTable);
1898 TESTCASE(
"CloseWithoutStop",
1899 "Check that we can close the scanning transaction without calling "\
1901 INITIALIZER(runLoadTable);
1902 STEP(runCloseWithoutStop);
1903 VERIFIER(runScanRead);
1904 FINALIZER(runClearTable);
1906 TESTCASE(
"NextScanWhenNoMore",
1907 "Check that we can call nextScanResult when there are no more "\
1908 "records, and that it returns a valid value"){
1909 INITIALIZER(runLoadTable);
1910 STEP(runNextScanWhenNoMore);
1911 VERIFIER(runScanRead);
1912 FINALIZER(runClearTable);
1914 TESTCASE(
"EqualAfterOpenScan",
1915 "Check that we can't call equal after openScan"){
1916 STEP(runEqualAfterOpenScan);
1918 TESTCASE(
"ExecuteScanWithoutOpenScan",
1919 "Check that we can't call executeScan without defining a scan "\
1921 INITIALIZER(runLoadTable);
1922 STEP(runExecuteScanWithoutOpenScan);
1923 VERIFIER(runScanRead);
1924 FINALIZER(runClearTable);
1926 TESTCASE(
"OnlyOpenScanOnce",
1927 "Check that we may only call openScan once in the same trans"){
1928 INITIALIZER(runLoadTable);
1929 STEP(runOnlyOpenScanOnce);
1930 VERIFIER(runScanRead);
1931 FINALIZER(runClearTable);
1933 TESTCASE(
"OnlyOneOpInScanTrans",
1934 "Check that we can have only one operation in a scan trans"){
1935 INITIALIZER(runLoadTable);
1936 STEP(runOnlyOneOpInScanTrans);
1937 VERIFIER(runScanRead);
1938 FINALIZER(runClearTable);
1940 TESTCASE(
"OnlyOneOpBeforeOpenScan",
1941 "Check that we can have only one operation in a trans defined "\
1942 "when calling openScan "){
1943 INITIALIZER(runLoadTable);
1944 STEP(runOnlyOneOpBeforeOpenScan);
1945 VERIFIER(runScanRead);
1946 FINALIZER(runClearTable);
1948 TESTCASE(
"OnlyOneScanPerTrans",
1949 "Check that we can have only one scan operation in a trans"){
1950 INITIALIZER(runLoadTable);
1951 STEP(runOnlyOneScanPerTrans);
1952 VERIFIER(runScanRead);
1953 FINALIZER(runClearTable);
1955 TESTCASE(
"NoCloseTransaction",
1956 "Check behaviour when close transaction is not called "){
1957 INITIALIZER(runLoadTable);
1958 STEP(runNoCloseTransaction);
1959 VERIFIER(runScanRead);
1960 FINALIZER(runClearTable);
1962 TESTCASE(
"CheckInactivityTimeOut",
1963 "Check behaviour when the api sleeps for a long time before continuing scan "){
1964 INITIALIZER(runLoadTable);
1965 STEP(runCheckInactivityTimeOut);
1966 VERIFIER(runScanRead);
1967 FINALIZER(runClearTable);
1969 TESTCASE(
"CheckInactivityBeforeClose",
1970 "Check behaviour when the api sleeps for a long time before calling close scan "){
1971 INITIALIZER(runLoadTable);
1972 STEP(runCheckInactivityBeforeClose);
1973 VERIFIER(runScanRead);
1974 FINALIZER(runClearTable);
1976 TESTCASE(
"ScanReadError5021",
1977 "Scan and insert error 5021, one node is expected to crash"){
1978 INITIALIZER(runLoadTable);
1979 TC_PROPERTY(
"ErrorCode", 5021);
1980 STEP(runScanReadErrorOneNode);
1981 FINALIZER(runClearTable);
1983 TESTCASE(
"ScanReadError5022",
1984 "Scan and insert error 5022, one node is expected to crash"){
1985 INITIALIZER(runLoadTable);
1986 TC_PROPERTY(
"ErrorCode", 5022);
1987 TC_PROPERTY(
"NodeNumber", 2);
1988 STEP(runScanReadErrorOneNode);
1989 FINALIZER(runClearTable);
1991 TESTCASE(
"ScanReadError5023",
1992 "Scan and insert error 5023"){
1993 INITIALIZER(runLoadTable);
1994 TC_PROPERTY(
"ErrorCode", 5023);
1995 STEP(runScanReadError);
1996 FINALIZER(runClearTable);
1998 TESTCASE(
"ScanReadError5024",
1999 "Scan and insert error 5024"){
2000 INITIALIZER(runLoadTable);
2001 TC_PROPERTY(
"ErrorCode", 5024);
2002 STEP(runScanReadError);
2003 FINALIZER(runClearTable);
2005 TESTCASE(
"ScanReadError5025",
2006 "Scan and insert error 5025"){
2007 INITIALIZER(runLoadTable);
2008 TC_PROPERTY(
"ErrorCode", 5025);
2009 STEP(runScanReadError);
2010 FINALIZER(runClearTable);
2012 TESTCASE(
"ScanReadError8081",
2013 "Scan and insert error 8081"){
2014 INITIALIZER(runLoadTable);
2015 TC_PROPERTY(
"ErrorCode", 8081);
2016 STEP(runScanReadError);
2017 FINALIZER(runClearTable);
2019 TESTCASE(
"ScanReadError5030",
2020 "Scan and insert error 5030."\
2021 "Drop all SCAN_NEXTREQ signals in LQH until the node is "\
2022 "shutdown with SYSTEM_ERROR because of scan fragment timeout"){
2023 INITIALIZER(runLoadTable);
2024 TC_PROPERTY(
"ErrorCode", 5030);
2025 STEP(runScanReadErrorOneNode);
2026 FINALIZER(runClearTable);
2028 TESTCASE(
"ScanReadRestart",
2029 "Scan requirement:A scan should be able to start and "\
2030 "complete during node recovery and when one or more nodes "\
2031 "in the cluster is down.Use random parallelism "){
2032 INITIALIZER(runLoadTable);
2033 TC_PROPERTY(
"Parallelism", RANDOM_PARALLELISM);
2034 STEP(runScanReadUntilStopped);
2036 FINALIZER(runClearTable);
2038 TESTCASE(
"ScanUpdateRestart",
2039 "Scan requirement:A scan should be able to start and "\
2040 "complete during node recovery and when one or more nodes "\
2041 "in the cluster is down. Use random parallelism"){
2042 INITIALIZER(runLoadTable);
2043 TC_PROPERTY(
"Parallelism", RANDOM_PARALLELISM);
2044 STEP(runScanUpdateUntilStopped);
2046 FINALIZER(runClearTable);
2049 TESTCASE(
"ScanReadRestart9999",
2050 "Scan requirement:A scan should be able to start and "\
2051 "complete during node recovery and when one or more nodes "\
2052 "in the cluster is down. Use parallelism 240."\
2053 "Restart using error insert 9999"){
2054 INITIALIZER(runLoadTable);
2055 TC_PROPERTY(
"Parallelism", 240);
2056 STEP(runScanReadUntilStopped);
2057 STEP(runRestarter9999);
2058 FINALIZER(runClearTable);
2060 TESTCASE(
"ScanUpdateRestart9999",
2061 "Scan requirement:A scan should be able to start and "\
2062 "complete during node recovery and when one or more nodes "\
2063 "in the cluster is down. Use parallelism 240."\
2064 "Restart using error insert 9999"){
2065 INITIALIZER(runLoadTable);
2066 TC_PROPERTY(
"Parallelism", 240);
2067 STEP(runScanReadUntilStopped);
2068 STEP(runScanUpdateUntilStopped);
2069 STEP(runRestarter9999);
2070 FINALIZER(runClearTable);
2073 TESTCASE(
"InsertDelete",
2074 "Load and delete all while scan updating and scan reading\n"\
2075 "Alexander Lukas special"){
2076 INITIALIZER(runClearTable);
2077 STEP(runScanReadUntilStoppedNoCount);
2078 STEP(runScanUpdateUntilStopped);
2079 STEP(runInsertDelete);
2080 FINALIZER(runClearTable);
2082 TESTCASE(
"Bug48700",
2083 "Load and delete all while scan updating and scan reading\n"\
2084 "Alexander Lukas special"){
2085 TC_PROPERTY(
"AbortProb", Uint32(0));
2086 TC_PROPERTY(
"NoCount", 1);
2088 INITIALIZER(runClearTable);
2089 STEPS(runRandScanRead, 10);
2090 STEP(runInsertDelete);
2091 FINALIZER(runClearTable);
2093 TESTCASE(
"CheckAfterTerror",
2094 "Check that we can still scan read after this terror of NdbApi"){
2095 INITIALIZER(runLoadTable);
2096 STEPS(runScanRead, 5);
2097 FINALIZER(runClearTable);
2099 TESTCASE(
"ScanReadWhileNodeIsDown",
2100 "Scan requirement:A scan should be able to run as fast when "\
2101 "one or more nodes in the cluster is down."){
2102 INITIALIZER(runLoadTable);
2103 STEP(runScanReadUntilStoppedPrintTime);
2104 STEP(runStopAndStartNode);
2105 FINALIZER(runClearTable);
2107 TESTCASE(
"ScanParallelism",
2108 "Test scan with different parallelism"){
2109 INITIALIZER(runLoadTable);
2110 STEP(runScanParallelism);
2111 FINALIZER(runClearTable);
2113 TESTCASE(
"ScanVariants",
2114 "Test different scan variants"){
2115 INITIALIZER(runLoadTable);
2116 STEP(runScanVariants);
2117 FINALIZER(runClearTable);
2119 TESTCASE(
"Bug24447",
2121 INITIALIZER(runLoadTable);
2123 FINALIZER(runClearTable);
2125 TESTCASE(
"Bug36124",
2126 "Old interpreted Api usage"){
2127 INITIALIZER(runLoadTable);
2129 FINALIZER(runClearTable);
2131 TESTCASE(
"Bug42545",
"")
2133 INITIALIZER(createOrderedPkIndex);
2134 INITIALIZER(runLoadTable);
2136 FINALIZER(createOrderedPkIndex_Drop);
2137 FINALIZER(runClearTable);
2139 TESTCASE(
"Bug42559",
"")
2141 INITIALIZER(initBug42559);
2142 INITIALIZER(createOrderedPkIndex);
2143 INITIALIZER(runLoadTable);
2144 STEPS(runScanReadIndex, 70);
2145 FINALIZER(createOrderedPkIndex_Drop);
2146 FINALIZER(finalizeBug42559);
2147 FINALIZER(runClearTable);
2149 TESTCASE(
"CloseRefresh",
"")
2151 INITIALIZER(runCloseRefresh);
2153 TESTCASE(
"Bug54945",
"")
2155 INITIALIZER(runBug54945);
2157 TESTCASE(
"Bug12324191",
"")
2160 TC_PROPERTY(
"TupScan", Uint32(1));
2161 TC_PROPERTY(
"Rows", Uint32(0));
2162 INITIALIZER(runLoadTable);
2164 STEPS(runMixedDML,10);
2166 NDBT_TESTSUITE_END(testScan);
2168 int main(
int argc,
const char** argv){
2170 myRandom48Init((
long)NdbTick_CurrentMillisecond());
2171 NDBT_TESTSUITE_INSTANCE(testScan);
2172 return testScan.execute(argc, argv);