mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / test / ndbapi / testNodeRestart.cpp
blob8ea0e08855e8ea366bfb483711922e524824cfc2
1 /* Copyright (c) 2003-2008 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #include <NDBT.hpp>
17 #include <NDBT_Test.hpp>
18 #include <HugoTransactions.hpp>
19 #include <UtilTransactions.hpp>
20 #include <NdbRestarter.hpp>
21 #include <NdbRestarts.hpp>
22 #include <Vector.hpp>
23 #include <signaldata/DumpStateOrd.hpp>
24 #include <Bitmask.hpp>
25 #include <RefConvert.hpp>
26 #include <NdbEnv.h>
28 int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
30 int records = ctx->getNumRecords();
31 HugoTransactions hugoTrans(*ctx->getTab());
32 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
33 return NDBT_FAILED;
35 return NDBT_OK;
38 int runFillTable(NDBT_Context* ctx, NDBT_Step* step){
40 HugoTransactions hugoTrans(*ctx->getTab());
41 if (hugoTrans.fillTable(GETNDB(step)) != 0){
42 return NDBT_FAILED;
44 return NDBT_OK;
47 int runInsertUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
48 int result = NDBT_OK;
49 int records = ctx->getNumRecords();
50 int i = 0;
51 HugoTransactions hugoTrans(*ctx->getTab());
52 while (ctx->isTestStopped() == false) {
53 g_info << i << ": ";
54 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
55 return NDBT_FAILED;
57 i++;
59 return result;
62 int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
63 int records = ctx->getNumRecords();
65 UtilTransactions utilTrans(*ctx->getTab());
66 if (utilTrans.clearTable(GETNDB(step), records) != 0){
67 return NDBT_FAILED;
69 return NDBT_OK;
72 int runClearTableUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
73 int records = ctx->getNumRecords();
74 int i = 0;
76 UtilTransactions utilTrans(*ctx->getTab());
77 while (ctx->isTestStopped() == false) {
78 g_info << i << ": ";
79 if (utilTrans.clearTable(GETNDB(step), records) != 0){
80 return NDBT_FAILED;
82 i++;
84 return NDBT_OK;
87 int runScanReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
88 int result = NDBT_OK;
89 int records = ctx->getNumRecords();
90 int i = 0;
91 HugoTransactions hugoTrans(*ctx->getTab());
92 while (ctx->isTestStopped() == false) {
93 g_info << i << ": ";
94 if (hugoTrans.scanReadRecords(GETNDB(step), records) != 0){
95 return NDBT_FAILED;
97 i++;
99 return result;
102 int runPkReadUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
103 int result = NDBT_OK;
104 int records = ctx->getNumRecords();
105 NdbOperation::LockMode lm =
106 (NdbOperation::LockMode)ctx->getProperty("ReadLockMode",
107 (Uint32)NdbOperation::LM_Read);
108 int i = 0;
109 HugoTransactions hugoTrans(*ctx->getTab());
110 while (ctx->isTestStopped() == false) {
111 g_info << i << ": ";
112 int rows = (rand()%records)+1;
113 int batch = (rand()%rows)+1;
114 if (hugoTrans.pkReadRecords(GETNDB(step), rows, batch, lm) != 0){
115 return NDBT_FAILED;
117 i++;
119 return result;
122 int runPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
123 int result = NDBT_OK;
124 int records = ctx->getNumRecords();
125 int multiop = ctx->getProperty("MULTI_OP", 1);
126 Ndb* pNdb = GETNDB(step);
127 int i = 0;
129 HugoOperations hugoOps(*ctx->getTab());
130 while (ctx->isTestStopped() == false)
132 g_info << i << ": ";
133 int batch = (rand()%records)+1;
134 int row = rand() % records;
136 if (batch > 25)
137 batch = 25;
139 if(row + batch > records)
140 batch = records - row;
142 if(hugoOps.startTransaction(pNdb) != 0)
143 goto err;
145 if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
146 goto err;
148 for (int j = 1; j<multiop; j++)
150 if(hugoOps.execute_NoCommit(pNdb) != 0)
151 goto err;
153 if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
154 goto err;
157 if(hugoOps.execute_Commit(pNdb) != 0)
158 goto err;
160 hugoOps.closeTransaction(pNdb);
162 continue;
164 err:
165 NdbConnection* pCon = hugoOps.getTransaction();
166 if(pCon == 0)
167 continue;
168 NdbError error = pCon->getNdbError();
169 hugoOps.closeTransaction(pNdb);
170 if (error.status == NdbError::TemporaryError){
171 NdbSleep_MilliSleep(50);
172 continue;
174 return NDBT_FAILED;
176 i++;
178 return result;
181 int runPkReadPkUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
182 int result = NDBT_OK;
183 int records = ctx->getNumRecords();
184 Ndb* pNdb = GETNDB(step);
185 int i = 0;
186 HugoOperations hugoOps(*ctx->getTab());
187 while (ctx->isTestStopped() == false) {
188 g_info << i++ << ": ";
189 int rows = (rand()%records)+1;
190 int batch = (rand()%rows)+1;
191 int row = (records - rows) ? rand() % (records - rows) : 0;
193 int j,k;
194 for(j = 0; j<rows; j += batch)
196 k = batch;
197 if(j+k > rows)
198 k = rows - j;
200 if(hugoOps.startTransaction(pNdb) != 0)
201 goto err;
203 if(hugoOps.pkReadRecord(pNdb, row+j, k, NdbOperation::LM_Exclusive) != 0)
204 goto err;
206 if(hugoOps.execute_NoCommit(pNdb) != 0)
207 goto err;
209 if(hugoOps.pkUpdateRecord(pNdb, row+j, k, rand()) != 0)
210 goto err;
212 if(hugoOps.execute_Commit(pNdb) != 0)
213 goto err;
215 if(hugoOps.closeTransaction(pNdb) != 0)
216 return NDBT_FAILED;
219 continue;
220 err:
221 NdbConnection* pCon = hugoOps.getTransaction();
222 if(pCon == 0)
223 continue;
224 NdbError error = pCon->getNdbError();
225 hugoOps.closeTransaction(pNdb);
226 if (error.status == NdbError::TemporaryError){
227 NdbSleep_MilliSleep(50);
228 continue;
230 return NDBT_FAILED;
232 return NDBT_OK;
235 int runScanUpdateUntilStopped(NDBT_Context* ctx, NDBT_Step* step){
236 int result = NDBT_OK;
237 int records = ctx->getNumRecords();
238 int parallelism = ctx->getProperty("Parallelism", 1);
239 int abort = ctx->getProperty("AbortProb", (Uint32)0);
240 int i = 0;
241 HugoTransactions hugoTrans(*ctx->getTab());
242 while (ctx->isTestStopped() == false) {
243 g_info << i << ": ";
244 if (hugoTrans.scanUpdateRecords(GETNDB(step), records, abort,
245 parallelism) == NDBT_FAILED){
246 return NDBT_FAILED;
248 i++;
250 return result;
253 int runScanReadVerify(NDBT_Context* ctx, NDBT_Step* step){
254 int records = ctx->getNumRecords();
255 HugoTransactions hugoTrans(*ctx->getTab());
257 if (hugoTrans.scanReadRecords(GETNDB(step), records, 0, 64) != 0){
258 return NDBT_FAILED;
260 return NDBT_OK;
263 int runRestarter(NDBT_Context* ctx, NDBT_Step* step){
264 int result = NDBT_OK;
265 int loops = ctx->getNumLoops();
266 int sync_threads = ctx->getProperty("SyncThreads", (unsigned)0);
267 NdbRestarter restarter;
268 int i = 0;
269 int lastId = 0;
271 if (restarter.getNumDbNodes() < 2){
272 ctx->stopTest();
273 return NDBT_OK;
276 if(restarter.waitClusterStarted() != 0){
277 g_err << "Cluster failed to start" << endl;
278 return NDBT_FAILED;
281 loops *= restarter.getNumDbNodes();
282 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
284 int id = lastId % restarter.getNumDbNodes();
285 int nodeId = restarter.getDbNodeId(id);
286 ndbout << "Restart node " << nodeId << endl;
287 if(restarter.restartOneDbNode(nodeId, false, true, true) != 0){
288 g_err << "Failed to restartNextDbNode" << endl;
289 result = NDBT_FAILED;
290 break;
293 if (restarter.waitNodesNoStart(&nodeId, 1))
295 g_err << "Failed to waitNodesNoStart" << endl;
296 result = NDBT_FAILED;
297 break;
300 if (restarter.startNodes(&nodeId, 1))
302 g_err << "Failed to start node" << endl;
303 result = NDBT_FAILED;
304 break;
307 if(restarter.waitClusterStarted() != 0){
308 g_err << "Cluster failed to start" << endl;
309 result = NDBT_FAILED;
310 break;
313 ctx->sync_up_and_wait("PauseThreads", sync_threads);
315 lastId++;
316 i++;
319 ctx->stopTest();
321 return result;
324 int runCheckAllNodesStarted(NDBT_Context* ctx, NDBT_Step* step){
325 NdbRestarter restarter;
327 if(restarter.waitClusterStarted(1) != 0){
328 g_err << "All nodes was not started " << endl;
329 return NDBT_FAILED;
332 return NDBT_OK;
337 int runRestarts(NDBT_Context* ctx, NDBT_Step* step){
338 int result = NDBT_OK;
339 int loops = ctx->getNumLoops();
340 NDBT_TestCase* pCase = ctx->getCase();
341 NdbRestarts restarts;
342 int i = 0;
343 int timeout = 240;
345 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
347 if(restarts.executeRestart(pCase->getName(), timeout) != 0){
348 g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
349 result = NDBT_FAILED;
350 break;
352 i++;
354 ctx->stopTest();
355 return result;
358 int runDirtyRead(NDBT_Context* ctx, NDBT_Step* step){
359 int result = NDBT_OK;
360 int loops = ctx->getNumLoops();
361 int records = ctx->getNumRecords();
362 NdbRestarter restarter;
363 HugoOperations hugoOps(*ctx->getTab());
364 Ndb* pNdb = GETNDB(step);
366 int i = 0;
367 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
368 g_info << i << ": ";
370 int id = i % restarter.getNumDbNodes();
371 int nodeId = restarter.getDbNodeId(id);
372 ndbout << "Restart node " << nodeId << endl;
373 restarter.insertErrorInNode(nodeId, 5041);
374 restarter.insertErrorInAllNodes(8048 + (i & 1));
376 for(int j = 0; j<records; j++){
377 if(hugoOps.startTransaction(pNdb) != 0)
378 return NDBT_FAILED;
380 if(hugoOps.pkReadRecord(pNdb, j, 1, NdbOperation::LM_CommittedRead) != 0)
381 goto err;
383 int res;
384 if((res = hugoOps.execute_Commit(pNdb)) == 4119)
385 goto done;
387 if(res != 0)
388 goto err;
390 if(hugoOps.closeTransaction(pNdb) != 0)
391 return NDBT_FAILED;
393 done:
394 if(hugoOps.closeTransaction(pNdb) != 0)
395 return NDBT_FAILED;
397 i++;
398 restarter.waitClusterStarted(60) ;
400 return result;
401 err:
402 hugoOps.closeTransaction(pNdb);
403 return NDBT_FAILED;
406 int runLateCommit(NDBT_Context* ctx, NDBT_Step* step){
407 int result = NDBT_OK;
408 int loops = ctx->getNumLoops();
409 int records = ctx->getNumRecords();
410 NdbRestarter restarter;
411 HugoOperations hugoOps(*ctx->getTab());
412 Ndb* pNdb = GETNDB(step);
414 int i = 0;
415 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
416 g_info << i << ": ";
418 if(hugoOps.startTransaction(pNdb) != 0)
419 return NDBT_FAILED;
421 if(hugoOps.pkUpdateRecord(pNdb, 1, 128) != 0)
422 return NDBT_FAILED;
424 if(hugoOps.execute_NoCommit(pNdb) != 0)
425 return NDBT_FAILED;
427 Uint32 transNode= hugoOps.getTransaction()->getConnectedNodeId();
428 int id = i % restarter.getNumDbNodes();
429 int nodeId;
430 while((nodeId = restarter.getDbNodeId(id)) == transNode)
431 id = (id + 1) % restarter.getNumDbNodes();
433 ndbout << "Restart node " << nodeId << endl;
435 restarter.restartOneDbNode(nodeId,
436 /** initial */ false,
437 /** nostart */ true,
438 /** abort */ true);
440 restarter.waitNodesNoStart(&nodeId, 1);
442 int res;
443 if(i & 1)
444 res= hugoOps.execute_Commit(pNdb);
445 else
446 res= hugoOps.execute_Rollback(pNdb);
448 ndbout_c("res= %d", res);
450 hugoOps.closeTransaction(pNdb);
452 restarter.startNodes(&nodeId, 1);
453 restarter.waitNodesStarted(&nodeId, 1);
455 if(i & 1)
457 if(res != 286)
458 return NDBT_FAILED;
460 else
462 if(res != 0)
463 return NDBT_FAILED;
465 i++;
468 return NDBT_OK;
471 int runBug15587(NDBT_Context* ctx, NDBT_Step* step){
472 int result = NDBT_OK;
473 int loops = ctx->getNumLoops();
474 int records = ctx->getNumRecords();
475 NdbRestarter restarter;
477 Uint32 tableId = ctx->getTab()->getTableId();
478 int dump[2] = { DumpStateOrd::LqhErrorInsert5042, 0 };
479 dump[1] = tableId;
481 int nodeId = restarter.getDbNodeId(1);
483 ndbout << "Restart node " << nodeId << endl;
485 if (restarter.restartOneDbNode(nodeId,
486 /** initial */ false,
487 /** nostart */ true,
488 /** abort */ true))
489 return NDBT_FAILED;
491 if (restarter.waitNodesNoStart(&nodeId, 1))
492 return NDBT_FAILED;
494 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
496 if (restarter.dumpStateOneNode(nodeId, val2, 2))
497 return NDBT_FAILED;
499 if (restarter.dumpStateOneNode(nodeId, dump, 2))
500 return NDBT_FAILED;
502 if (restarter.startNodes(&nodeId, 1))
503 return NDBT_FAILED;
505 restarter.waitNodesStartPhase(&nodeId, 1, 3);
507 if (restarter.waitNodesNoStart(&nodeId, 1))
508 return NDBT_FAILED;
510 if (restarter.dumpStateOneNode(nodeId, val2, 1))
511 return NDBT_FAILED;
513 if (restarter.startNodes(&nodeId, 1))
514 return NDBT_FAILED;
516 if (restarter.waitNodesStarted(&nodeId, 1))
517 return NDBT_FAILED;
519 ctx->stopTest();
520 return NDBT_OK;
523 int runBug15632(NDBT_Context* ctx, NDBT_Step* step){
524 int result = NDBT_OK;
525 int loops = ctx->getNumLoops();
526 int records = ctx->getNumRecords();
527 NdbRestarter restarter;
529 int nodeId = restarter.getDbNodeId(1);
531 ndbout << "Restart node " << nodeId << endl;
533 if (restarter.restartOneDbNode(nodeId,
534 /** initial */ false,
535 /** nostart */ true,
536 /** abort */ true))
537 return NDBT_FAILED;
539 if (restarter.waitNodesNoStart(&nodeId, 1))
540 return NDBT_FAILED;
542 if (restarter.insertErrorInNode(nodeId, 7165))
543 return NDBT_FAILED;
545 if (restarter.startNodes(&nodeId, 1))
546 return NDBT_FAILED;
548 if (restarter.waitNodesStarted(&nodeId, 1))
549 return NDBT_FAILED;
551 if (restarter.restartOneDbNode(nodeId,
552 /** initial */ false,
553 /** nostart */ true,
554 /** abort */ true))
555 return NDBT_FAILED;
557 if (restarter.waitNodesNoStart(&nodeId, 1))
558 return NDBT_FAILED;
560 if (restarter.insertErrorInNode(nodeId, 7171))
561 return NDBT_FAILED;
563 if (restarter.startNodes(&nodeId, 1))
564 return NDBT_FAILED;
566 if (restarter.waitNodesStarted(&nodeId, 1))
567 return NDBT_FAILED;
569 ctx->stopTest();
570 return NDBT_OK;
573 int runBug15685(NDBT_Context* ctx, NDBT_Step* step){
575 Ndb* pNdb = GETNDB(step);
576 HugoOperations hugoOps(*ctx->getTab());
577 NdbRestarter restarter;
579 HugoTransactions hugoTrans(*ctx->getTab());
580 if (hugoTrans.loadTable(GETNDB(step), 10) != 0){
581 return NDBT_FAILED;
584 if(hugoOps.startTransaction(pNdb) != 0)
585 goto err;
587 if(hugoOps.pkUpdateRecord(pNdb, 0, 1, rand()) != 0)
588 goto err;
590 if(hugoOps.execute_NoCommit(pNdb) != 0)
591 goto err;
593 if (restarter.insertErrorInAllNodes(5100))
594 return NDBT_FAILED;
596 hugoOps.execute_Rollback(pNdb);
598 if (restarter.waitClusterStarted() != 0)
599 goto err;
601 if (restarter.insertErrorInAllNodes(0))
602 return NDBT_FAILED;
604 ctx->stopTest();
605 return NDBT_OK;
607 err:
608 ctx->stopTest();
609 return NDBT_FAILED;
612 int
613 runBug16772(NDBT_Context* ctx, NDBT_Step* step){
615 NdbRestarter restarter;
616 if (restarter.getNumDbNodes() < 2)
618 ctx->stopTest();
619 return NDBT_OK;
622 int aliveNodeId = restarter.getRandomNotMasterNodeId(rand());
623 int deadNodeId = aliveNodeId;
624 while (deadNodeId == aliveNodeId)
625 deadNodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
627 if (restarter.insertErrorInNode(aliveNodeId, 930))
628 return NDBT_FAILED;
630 if (restarter.restartOneDbNode(deadNodeId,
631 /** initial */ false,
632 /** nostart */ true,
633 /** abort */ true))
634 return NDBT_FAILED;
636 if (restarter.waitNodesNoStart(&deadNodeId, 1))
637 return NDBT_FAILED;
639 if (restarter.startNodes(&deadNodeId, 1))
640 return NDBT_FAILED;
642 // It should now be hanging since we throw away NDB_FAILCONF
643 int ret = restarter.waitNodesStartPhase(&deadNodeId, 1, 3, 10);
644 // So this should fail...i.e it should not reach startphase 3
646 // Now send a NDB_FAILCONF for deadNo
647 int dump[] = { 7020, 323, 252, 0 };
648 dump[3] = deadNodeId;
649 if (restarter.dumpStateOneNode(aliveNodeId, dump, 4))
650 return NDBT_FAILED;
652 if (restarter.waitNodesStarted(&deadNodeId, 1))
653 return NDBT_FAILED;
655 return ret ? NDBT_OK : NDBT_FAILED;
658 int
659 runBug18414(NDBT_Context* ctx, NDBT_Step* step){
661 NdbRestarter restarter;
662 if (restarter.getNumDbNodes() < 2)
664 ctx->stopTest();
665 return NDBT_OK;
668 Ndb* pNdb = GETNDB(step);
669 HugoOperations hugoOps(*ctx->getTab());
670 HugoTransactions hugoTrans(*ctx->getTab());
671 int loop = 0;
674 if(hugoOps.startTransaction(pNdb) != 0)
675 goto err;
677 if(hugoOps.pkUpdateRecord(pNdb, 0, 128, rand()) != 0)
678 goto err;
680 if(hugoOps.execute_NoCommit(pNdb) != 0)
681 goto err;
683 int node1 = hugoOps.getTransaction()->getConnectedNodeId();
684 int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
686 if (node1 == -1 || node2 == -1)
687 break;
689 if (loop & 1)
691 if (restarter.insertErrorInNode(node1, 8050))
692 goto err;
695 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
696 if (restarter.dumpStateOneNode(node2, val2, 2))
697 goto err;
699 if (restarter.insertErrorInNode(node2, 5003))
700 goto err;
702 int res= hugoOps.execute_Rollback(pNdb);
704 if (restarter.waitNodesNoStart(&node2, 1) != 0)
705 goto err;
707 if (restarter.insertErrorInAllNodes(0))
708 goto err;
710 if (restarter.startNodes(&node2, 1) != 0)
711 goto err;
713 if (restarter.waitClusterStarted() != 0)
714 goto err;
716 if (hugoTrans.scanUpdateRecords(pNdb, 128) != 0)
717 goto err;
719 hugoOps.closeTransaction(pNdb);
721 } while(++loop < 5);
723 return NDBT_OK;
725 err:
726 hugoOps.closeTransaction(pNdb);
727 return NDBT_FAILED;
730 int
731 runBug18612(NDBT_Context* ctx, NDBT_Step* step){
733 // Assume two replicas
734 NdbRestarter restarter;
735 if (restarter.getNumDbNodes() < 2)
737 ctx->stopTest();
738 return NDBT_OK;
741 Uint32 cnt = restarter.getNumDbNodes();
743 for(int loop = 0; loop < ctx->getNumLoops(); loop++)
745 int partition0[256];
746 int partition1[256];
747 bzero(partition0, sizeof(partition0));
748 bzero(partition1, sizeof(partition1));
749 Bitmask<4> nodesmask;
751 Uint32 node1 = restarter.getDbNodeId(rand()%cnt);
752 for (Uint32 i = 0; i<cnt/2; i++)
754 do {
755 int tmp = restarter.getRandomNodeOtherNodeGroup(node1, rand());
756 if (tmp == -1)
758 ctx->stopTest();
759 return NDBT_OK;
761 node1 = tmp;
762 } while(nodesmask.get(node1));
764 partition0[i] = node1;
765 partition1[i] = restarter.getRandomNodeSameNodeGroup(node1, rand());
767 ndbout_c("nodes %d %d", node1, partition1[i]);
769 assert(!nodesmask.get(node1));
770 assert(!nodesmask.get(partition1[i]));
771 nodesmask.set(node1);
772 nodesmask.set(partition1[i]);
775 ndbout_c("done");
777 int dump[255];
778 dump[0] = DumpStateOrd::NdbcntrStopNodes;
779 memcpy(dump + 1, partition0, sizeof(int)*cnt/2);
781 Uint32 master = restarter.getMasterNodeId();
783 if (restarter.dumpStateOneNode(master, dump, 1+cnt/2))
784 return NDBT_FAILED;
786 if (restarter.waitNodesNoStart(partition0, cnt/2))
787 return NDBT_FAILED;
789 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
791 if (restarter.dumpStateAllNodes(val2, 2))
792 return NDBT_FAILED;
794 if (restarter.insertErrorInAllNodes(932))
795 return NDBT_FAILED;
797 dump[0] = 9000;
798 memcpy(dump + 1, partition0, sizeof(int)*cnt/2);
799 for (Uint32 i = 0; i<cnt/2; i++)
800 if (restarter.dumpStateOneNode(partition1[i], dump, 1+cnt/2))
801 return NDBT_FAILED;
803 dump[0] = 9000;
804 memcpy(dump + 1, partition1, sizeof(int)*cnt/2);
805 for (Uint32 i = 0; i<cnt/2; i++)
806 if (restarter.dumpStateOneNode(partition0[i], dump, 1+cnt/2))
807 return NDBT_FAILED;
809 if (restarter.startNodes(partition0, cnt/2))
810 return NDBT_FAILED;
812 if (restarter.waitNodesStartPhase(partition0, cnt/2, 2))
813 return NDBT_FAILED;
815 dump[0] = 9001;
816 for (Uint32 i = 0; i<cnt/2; i++)
817 if (restarter.dumpStateAllNodes(dump, 2))
818 return NDBT_FAILED;
820 if (restarter.waitNodesNoStart(partition0, cnt/2))
821 return NDBT_FAILED;
823 for (Uint32 i = 0; i<cnt/2; i++)
824 if (restarter.restartOneDbNode(partition0[i], true, true, true))
825 return NDBT_FAILED;
827 if (restarter.waitNodesNoStart(partition0, cnt/2))
828 return NDBT_FAILED;
830 if (restarter.startAll())
831 return NDBT_FAILED;
833 if (restarter.waitClusterStarted())
834 return NDBT_FAILED;
836 return NDBT_OK;
839 int
840 runBug18612SR(NDBT_Context* ctx, NDBT_Step* step){
842 // Assume two replicas
843 NdbRestarter restarter;
844 if (restarter.getNumDbNodes() < 2)
846 ctx->stopTest();
847 return NDBT_OK;
850 Uint32 cnt = restarter.getNumDbNodes();
852 for(int loop = 0; loop < ctx->getNumLoops(); loop++)
854 int partition0[256];
855 int partition1[256];
856 bzero(partition0, sizeof(partition0));
857 bzero(partition1, sizeof(partition1));
858 Bitmask<4> nodesmask;
860 Uint32 node1 = restarter.getDbNodeId(rand()%cnt);
861 for (Uint32 i = 0; i<cnt/2; i++)
863 do {
864 int tmp = restarter.getRandomNodeOtherNodeGroup(node1, rand());
865 if (tmp == -1)
866 break;
867 node1 = tmp;
868 } while(nodesmask.get(node1));
870 partition0[i] = node1;
871 partition1[i] = restarter.getRandomNodeSameNodeGroup(node1, rand());
873 ndbout_c("nodes %d %d", node1, partition1[i]);
875 assert(!nodesmask.get(node1));
876 assert(!nodesmask.get(partition1[i]));
877 nodesmask.set(node1);
878 nodesmask.set(partition1[i]);
881 ndbout_c("done");
883 if (restarter.restartAll(false, true, false))
884 return NDBT_FAILED;
886 int dump[255];
887 dump[0] = 9000;
888 memcpy(dump + 1, partition0, sizeof(int)*cnt/2);
889 for (Uint32 i = 0; i<cnt/2; i++)
890 if (restarter.dumpStateOneNode(partition1[i], dump, 1+cnt/2))
891 return NDBT_FAILED;
893 dump[0] = 9000;
894 memcpy(dump + 1, partition1, sizeof(int)*cnt/2);
895 for (Uint32 i = 0; i<cnt/2; i++)
896 if (restarter.dumpStateOneNode(partition0[i], dump, 1+cnt/2))
897 return NDBT_FAILED;
899 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
901 if (restarter.dumpStateAllNodes(val2, 2))
902 return NDBT_FAILED;
904 if (restarter.insertErrorInAllNodes(932))
905 return NDBT_FAILED;
907 if (restarter.startAll())
908 return NDBT_FAILED;
910 if (restarter.waitClusterStartPhase(2))
911 return NDBT_FAILED;
913 dump[0] = 9001;
914 for (Uint32 i = 0; i<cnt/2; i++)
915 if (restarter.dumpStateAllNodes(dump, 2))
916 return NDBT_FAILED;
918 if (restarter.waitClusterNoStart(30))
919 if (restarter.waitNodesNoStart(partition0, cnt/2, 10))
920 if (restarter.waitNodesNoStart(partition1, cnt/2, 10))
921 return NDBT_FAILED;
923 if (restarter.startAll())
924 return NDBT_FAILED;
926 if (restarter.waitClusterStarted())
927 return NDBT_FAILED;
929 return NDBT_OK;
932 int runBug20185(NDBT_Context* ctx, NDBT_Step* step){
933 int result = NDBT_OK;
934 int loops = ctx->getNumLoops();
935 int records = ctx->getNumRecords();
936 NdbRestarter restarter;
937 HugoOperations hugoOps(*ctx->getTab());
938 Ndb* pNdb = GETNDB(step);
940 const int masterNode = restarter.getMasterNodeId();
942 int dump[] = { 7090, 20 } ;
943 if (restarter.dumpStateAllNodes(dump, 2))
944 return NDBT_FAILED;
946 NdbSleep_MilliSleep(3000);
947 Vector<int> nodes;
948 for (Uint32 i = 0; i<restarter.getNumDbNodes(); i++)
949 nodes.push_back(restarter.getDbNodeId(i));
951 retry:
952 if(hugoOps.startTransaction(pNdb) != 0)
953 return NDBT_FAILED;
955 if(hugoOps.pkUpdateRecord(pNdb, 1, 1) != 0)
956 return NDBT_FAILED;
958 if (hugoOps.execute_NoCommit(pNdb) != 0)
959 return NDBT_FAILED;
961 const int node = hugoOps.getTransaction()->getConnectedNodeId();
962 if (node != masterNode)
964 hugoOps.closeTransaction(pNdb);
965 goto retry;
968 int nodeId;
969 do {
970 nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
971 } while (nodeId == node);
973 ndbout_c("7031 to %d", nodeId);
974 if (restarter.insertErrorInNode(nodeId, 7031))
975 return NDBT_FAILED;
977 for (Uint32 i = 0; i<nodes.size(); i++)
979 if (nodes[i] != nodeId)
980 if (restarter.insertErrorInNode(nodes[i], 7030))
981 return NDBT_FAILED;
984 NdbSleep_MilliSleep(500);
986 if (hugoOps.execute_Commit(pNdb) == 0)
987 return NDBT_FAILED;
989 NdbSleep_MilliSleep(3000);
991 restarter.waitClusterStarted();
993 if (restarter.dumpStateAllNodes(dump, 1))
994 return NDBT_FAILED;
996 return NDBT_OK;
999 int runBug24717(NDBT_Context* ctx, NDBT_Step* step){
1000 int result = NDBT_OK;
1001 int loops = ctx->getNumLoops();
1002 int records = ctx->getNumRecords();
1003 NdbRestarter restarter;
1004 Ndb* pNdb = GETNDB(step);
1006 HugoTransactions hugoTrans(*ctx->getTab());
1008 int dump[] = { 9002, 0 } ;
1009 Uint32 ownNode = refToNode(pNdb->getReference());
1010 dump[1] = ownNode;
1012 for (; loops; loops --)
1014 int nodeId = restarter.getRandomNotMasterNodeId(rand());
1015 restarter.restartOneDbNode(nodeId, false, true, true);
1016 restarter.waitNodesNoStart(&nodeId, 1);
1018 if (restarter.dumpStateOneNode(nodeId, dump, 2))
1019 return NDBT_FAILED;
1021 restarter.startNodes(&nodeId, 1);
1023 do {
1024 for (Uint32 i = 0; i < 100; i++)
1026 hugoTrans.pkReadRecords(pNdb, 100, 1, NdbOperation::LM_CommittedRead);
1028 } while (restarter.waitClusterStarted(5) != 0);
1031 return NDBT_OK;
1034 int
1035 runBug29364(NDBT_Context* ctx, NDBT_Step* step){
1036 int result = NDBT_OK;
1037 int loops = ctx->getNumLoops();
1038 int records = ctx->getNumRecords();
1039 NdbRestarter restarter;
1040 Ndb* pNdb = GETNDB(step);
1042 HugoTransactions hugoTrans(*ctx->getTab());
1044 if (restarter.getNumDbNodes() < 4)
1045 return NDBT_OK;
1047 int dump0[] = { 9000, 0 } ;
1048 int dump1[] = { 9001, 0 } ;
1049 Uint32 ownNode = refToNode(pNdb->getReference());
1050 dump0[1] = ownNode;
1052 for (; loops; loops --)
1054 int node0 = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
1055 int node1 = restarter.getRandomNodeOtherNodeGroup(node0, rand());
1057 restarter.restartOneDbNode(node0, false, true, true);
1058 restarter.waitNodesNoStart(&node0, 1);
1059 restarter.startNodes(&node0, 1);
1060 restarter.waitClusterStarted();
1062 restarter.restartOneDbNode(node1, false, true, true);
1063 restarter.waitNodesNoStart(&node1, 1);
1064 if (restarter.dumpStateOneNode(node1, dump0, 2))
1065 return NDBT_FAILED;
1067 restarter.startNodes(&node1, 1);
1069 do {
1071 for (Uint32 i = 0; i < 100; i++)
1073 hugoTrans.pkReadRecords(pNdb, 100, 1, NdbOperation::LM_CommittedRead);
1075 } while (restarter.waitClusterStarted(5) != 0);
1077 if (restarter.dumpStateOneNode(node1, dump1, 1))
1078 return NDBT_FAILED;
1081 return NDBT_OK;
1084 int runBug25364(NDBT_Context* ctx, NDBT_Step* step){
1085 int result = NDBT_OK;
1086 NdbRestarter restarter;
1087 Ndb* pNdb = GETNDB(step);
1088 int loops = ctx->getNumLoops();
1090 if (restarter.getNumDbNodes() < 4)
1091 return NDBT_OK;
1093 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1095 for (; loops; loops --)
1097 int master = restarter.getMasterNodeId();
1098 int victim = restarter.getRandomNodeOtherNodeGroup(master, rand());
1099 int second = restarter.getRandomNodeSameNodeGroup(victim, rand());
1101 int dump[] = { 935, victim } ;
1102 if (restarter.dumpStateOneNode(master, dump, 2))
1103 return NDBT_FAILED;
1105 if (restarter.dumpStateOneNode(master, val2, 2))
1106 return NDBT_FAILED;
1108 if (restarter.restartOneDbNode(second, false, true, true))
1109 return NDBT_FAILED;
1111 int nodes[2] = { master, second };
1112 if (restarter.waitNodesNoStart(nodes, 2))
1113 return NDBT_FAILED;
1115 restarter.startNodes(nodes, 2);
1117 if (restarter.waitNodesStarted(nodes, 2))
1118 return NDBT_FAILED;
1121 return NDBT_OK;
1124 int
1125 runBug21271(NDBT_Context* ctx, NDBT_Step* step){
1126 int result = NDBT_OK;
1127 int loops = ctx->getNumLoops();
1128 int records = ctx->getNumRecords();
1129 NdbRestarter restarter;
1130 HugoOperations hugoOps(*ctx->getTab());
1131 Ndb* pNdb = GETNDB(step);
1133 const int masterNode = restarter.getMasterNodeId();
1134 const int nodeId = restarter.getRandomNodeSameNodeGroup(masterNode, rand());
1136 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1137 if (restarter.dumpStateOneNode(nodeId, val2, 2))
1138 return NDBT_FAILED;
1140 Uint32 tableId = ctx->getTab()->getTableId();
1141 int dump[] = { DumpStateOrd::LqhErrorInsert5042, 0, 5044 };
1142 dump[1] = tableId;
1144 if (restarter.dumpStateOneNode(nodeId, dump, 3))
1145 return NDBT_FAILED;
1147 restarter.waitNodesNoStart(&nodeId, 1);
1148 ctx->stopTest();
1150 restarter.startNodes(&nodeId, 1);
1152 if (restarter.waitClusterStarted() != 0)
1153 return NDBT_FAILED;
1155 return NDBT_OK;
1156 return NDBT_OK;
1159 int
1160 runBug24543(NDBT_Context* ctx, NDBT_Step* step){
1161 NdbRestarter restarter;
1163 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1164 if (restarter.dumpStateAllNodes(val2, 2))
1165 return NDBT_FAILED;
1167 int nodes[2];
1168 nodes[0] = restarter.getMasterNodeId();
1169 restarter.insertErrorInNode(nodes[0], 934);
1171 nodes[1] = restarter.getRandomNodeOtherNodeGroup(nodes[0], rand());
1172 if (nodes[1] == -1)
1174 nodes[1] = restarter.getRandomNodeSameNodeGroup(nodes[0], rand());
1177 restarter.restartOneDbNode(nodes[1], false, true, true);
1178 if (restarter.waitNodesNoStart(nodes, 2))
1179 return NDBT_FAILED;
1181 restarter.startNodes(nodes, 2);
1182 if (restarter.waitNodesStarted(nodes, 2))
1184 return NDBT_FAILED;
1186 return NDBT_OK;
1189 int runBug25468(NDBT_Context* ctx, NDBT_Step* step){
1191 int result = NDBT_OK;
1192 int loops = ctx->getNumLoops();
1193 int records = ctx->getNumRecords();
1194 NdbRestarter restarter;
1196 for (int i = 0; i<loops; i++)
1198 int master = restarter.getMasterNodeId();
1199 int node1, node2;
1200 switch(i % 5){
1201 case 0:
1202 node1 = master;
1203 node2 = restarter.getRandomNodeSameNodeGroup(master, rand());
1204 break;
1205 case 1:
1206 node1 = restarter.getRandomNodeSameNodeGroup(master, rand());
1207 node2 = master;
1208 break;
1209 case 2:
1210 case 3:
1211 case 4:
1212 node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());
1213 if (node1 == -1)
1214 node1 = master;
1215 node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
1216 break;
1219 ndbout_c("node1: %d node2: %d master: %d", node1, node2, master);
1221 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1223 if (restarter.dumpStateOneNode(node2, val2, 2))
1224 return NDBT_FAILED;
1226 if (restarter.insertErrorInNode(node1, 7178))
1227 return NDBT_FAILED;
1229 int val1 = 7099;
1230 if (restarter.dumpStateOneNode(master, &val1, 1))
1231 return NDBT_FAILED;
1233 if (restarter.waitNodesNoStart(&node2, 1))
1234 return NDBT_FAILED;
1236 if (restarter.startAll())
1237 return NDBT_FAILED;
1239 if (restarter.waitClusterStarted())
1240 return NDBT_FAILED;
1243 return NDBT_OK;
1246 int runBug25554(NDBT_Context* ctx, NDBT_Step* step){
1248 int result = NDBT_OK;
1249 int loops = ctx->getNumLoops();
1250 int records = ctx->getNumRecords();
1251 NdbRestarter restarter;
1253 if (restarter.getNumDbNodes() < 4)
1254 return NDBT_OK;
1256 for (int i = 0; i<loops; i++)
1258 int master = restarter.getMasterNodeId();
1259 int node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());
1260 restarter.restartOneDbNode(node1, false, true, true);
1262 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1264 if (restarter.dumpStateOneNode(master, val2, 2))
1265 return NDBT_FAILED;
1267 if (restarter.insertErrorInNode(master, 7141))
1268 return NDBT_FAILED;
1270 if (restarter.waitNodesNoStart(&node1, 1))
1271 return NDBT_FAILED;
1273 if (restarter.dumpStateOneNode(node1, val2, 2))
1274 return NDBT_FAILED;
1276 if (restarter.insertErrorInNode(node1, 932))
1277 return NDBT_FAILED;
1279 if (restarter.startNodes(&node1, 1))
1280 return NDBT_FAILED;
1282 int nodes[] = { master, node1 };
1283 if (restarter.waitNodesNoStart(nodes, 2))
1284 return NDBT_FAILED;
1286 if (restarter.startNodes(nodes, 2))
1287 return NDBT_FAILED;
1289 if (restarter.waitClusterStarted())
1290 return NDBT_FAILED;
1293 return NDBT_OK;
1296 int runBug25984(NDBT_Context* ctx, NDBT_Step* step){
1298 int result = NDBT_OK;
1299 int loops = ctx->getNumLoops();
1300 int records = ctx->getNumRecords();
1301 NdbRestarter restarter;
1303 if (restarter.getNumDbNodes() < 2)
1304 return NDBT_OK;
1306 if (restarter.restartAll(true, true, true))
1307 return NDBT_FAILED;
1309 if (restarter.waitClusterNoStart())
1310 return NDBT_FAILED;
1312 if (restarter.startAll())
1313 return NDBT_FAILED;
1315 if (restarter.waitClusterStarted())
1316 return NDBT_FAILED;
1318 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1319 int master = restarter.getMasterNodeId();
1320 int victim = restarter.getRandomNodeOtherNodeGroup(master, rand());
1321 if (victim == -1)
1322 victim = restarter.getRandomNodeSameNodeGroup(master, rand());
1324 restarter.restartOneDbNode(victim, false, true, true);
1326 for (Uint32 i = 0; i<6; i++)
1328 ndbout_c("Loop: %d", i);
1329 if (restarter.waitNodesNoStart(&victim, 1))
1330 return NDBT_FAILED;
1332 if (restarter.dumpStateOneNode(victim, val2, 2))
1333 return NDBT_FAILED;
1335 if (restarter.insertErrorInNode(victim, 7016))
1336 return NDBT_FAILED;
1338 if (restarter.startNodes(&victim, 1))
1339 return NDBT_FAILED;
1341 NdbSleep_SecSleep(3);
1344 if (restarter.waitNodesNoStart(&victim, 1))
1345 return NDBT_FAILED;
1347 if (restarter.dumpStateOneNode(victim, val2, 2))
1348 return NDBT_FAILED;
1350 if (restarter.insertErrorInNode(victim, 7170))
1351 return NDBT_FAILED;
1353 if (restarter.startNodes(&victim, 1))
1354 return NDBT_FAILED;
1356 if (restarter.waitNodesNoStart(&victim, 1))
1357 return NDBT_FAILED;
1359 if (restarter.restartAll(false, true, true))
1360 return NDBT_FAILED;
1362 if (restarter.insertErrorInAllNodes(932))
1363 return NDBT_FAILED;
1365 if (restarter.insertErrorInNode(master, 7170))
1366 return NDBT_FAILED;
1368 if (restarter.dumpStateAllNodes(val2, 2))
1369 return NDBT_FAILED;
1371 restarter.startNodes(&master, 1);
1372 NdbSleep_MilliSleep(3000);
1373 restarter.startAll();
1375 if (restarter.waitClusterNoStart())
1376 return NDBT_FAILED;
1378 if (restarter.restartOneDbNode(victim, true, true, true))
1379 return NDBT_FAILED;
1381 if (restarter.startAll())
1382 return NDBT_FAILED;
1384 if (restarter.waitClusterStarted())
1385 return NDBT_FAILED;
1387 return NDBT_OK;
1391 runBug26457(NDBT_Context* ctx, NDBT_Step* step)
1393 NdbRestarter res;
1394 if (res.getNumDbNodes() < 4)
1395 return NDBT_OK;
1397 int loops = ctx->getNumLoops();
1398 while (loops --)
1400 retry:
1401 int master = res.getMasterNodeId();
1402 int next = res.getNextMasterNodeId(master);
1404 ndbout_c("master: %d next: %d", master, next);
1406 if (res.getNodeGroup(master) == res.getNodeGroup(next))
1408 res.restartOneDbNode(next, false, false, true);
1409 if (res.waitClusterStarted())
1410 return NDBT_FAILED;
1411 goto retry;
1414 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 2 };
1416 if (res.dumpStateOneNode(next, val2, 2))
1417 return NDBT_FAILED;
1419 if (res.insertErrorInNode(next, 7180))
1420 return NDBT_FAILED;
1422 res.restartOneDbNode(master, false, false, true);
1423 if (res.waitClusterStarted())
1424 return NDBT_FAILED;
1427 return NDBT_OK;
1430 int
1431 runBug26481(NDBT_Context* ctx, NDBT_Step* step)
1434 int result = NDBT_OK;
1435 int loops = ctx->getNumLoops();
1436 int records = ctx->getNumRecords();
1437 NdbRestarter res;
1439 int node = res.getRandomNotMasterNodeId(rand());
1440 ndbout_c("node: %d", node);
1441 if (res.restartOneDbNode(node, true, true, true))
1442 return NDBT_FAILED;
1444 if (res.waitNodesNoStart(&node, 1))
1445 return NDBT_FAILED;
1447 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1448 if (res.dumpStateOneNode(node, val2, 2))
1449 return NDBT_FAILED;
1451 if (res.insertErrorInNode(node, 7018))
1452 return NDBT_FAILED;
1454 if (res.startNodes(&node, 1))
1455 return NDBT_FAILED;
1457 res.waitNodesStartPhase(&node, 1, 3);
1459 if (res.waitNodesNoStart(&node, 1))
1460 return NDBT_FAILED;
1462 res.startNodes(&node, 1);
1464 if (res.waitClusterStarted())
1465 return NDBT_FAILED;
1467 return NDBT_OK;
1470 int
1471 runBug26450(NDBT_Context* ctx, NDBT_Step* step)
1473 Uint32 i;
1474 int result = NDBT_OK;
1475 int loops = ctx->getNumLoops();
1476 int records = ctx->getNumRecords();
1477 NdbRestarter res;
1478 Ndb* pNdb = GETNDB(step);
1480 int node = res.getRandomNotMasterNodeId(rand());
1481 Vector<int> nodes;
1482 for (unsigned i = 0; i<res.getNumDbNodes(); i++)
1484 if (res.getDbNodeId(i) != node)
1485 nodes.push_back(res.getDbNodeId(i));
1488 if (res.restartAll())
1489 return NDBT_FAILED;
1491 if (res.waitClusterStarted())
1492 return NDBT_FAILED;
1494 ndbout_c("node: %d", node);
1495 if (res.restartOneDbNode(node, false, true, true))
1496 return NDBT_FAILED;
1498 if (res.waitNodesNoStart(&node, 1))
1499 return NDBT_FAILED;
1501 if (runClearTable(ctx, step))
1502 return NDBT_FAILED;
1504 for (i = 0; i < 2; i++)
1506 if (res.restartAll(false, true, i > 0))
1507 return NDBT_FAILED;
1509 if (res.waitClusterNoStart())
1510 return NDBT_FAILED;
1512 if (res.startNodes(nodes.getBase(), nodes.size()))
1513 return NDBT_FAILED;
1515 if (res.waitNodesStarted(nodes.getBase(), nodes.size()))
1516 return NDBT_FAILED;
1519 if (res.startNodes(&node, 1))
1520 return NDBT_FAILED;
1522 if (res.waitNodesStarted(&node, 1))
1523 return NDBT_FAILED;
1525 HugoTransactions trans (* ctx->getTab());
1526 if (trans.selectCount(pNdb) != 0)
1527 return NDBT_FAILED;
1529 return NDBT_OK;
1533 runBug27003(NDBT_Context* ctx, NDBT_Step* step)
1535 int result = NDBT_OK;
1536 int loops = ctx->getNumLoops();
1537 int records = ctx->getNumRecords();
1538 NdbRestarter res;
1540 static const int errnos[] = { 4025, 4026, 4027, 4028, 0 };
1542 int node = res.getRandomNotMasterNodeId(rand());
1543 ndbout_c("node: %d", node);
1544 if (res.restartOneDbNode(node, true, true, true))
1545 return NDBT_FAILED;
1547 Uint32 pos = 0;
1548 for (Uint32 i = 0; i<loops; i++)
1550 while (errnos[pos] != 0)
1552 ndbout_c("Tesing err: %d", errnos[pos]);
1554 if (res.waitNodesNoStart(&node, 1))
1555 return NDBT_FAILED;
1557 if (res.insertErrorInNode(node, 1000))
1558 return NDBT_FAILED;
1560 if (res.insertErrorInNode(node, errnos[pos]))
1561 return NDBT_FAILED;
1563 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 3 };
1564 if (res.dumpStateOneNode(node, val2, 2))
1565 return NDBT_FAILED;
1567 res.startNodes(&node, 1);
1568 NdbSleep_SecSleep(3);
1569 pos++;
1571 pos = 0;
1574 if (res.waitNodesNoStart(&node, 1))
1575 return NDBT_FAILED;
1577 res.startNodes(&node, 1);
1578 if (res.waitClusterStarted())
1579 return NDBT_FAILED;
1581 return NDBT_OK;
1586 runBug27283(NDBT_Context* ctx, NDBT_Step* step)
1588 int result = NDBT_OK;
1589 int loops = ctx->getNumLoops();
1590 int records = ctx->getNumRecords();
1591 NdbRestarter res;
1593 if (res.getNumDbNodes() < 2)
1595 return NDBT_OK;
1598 static const int errnos[] = { 7181, 7182, 0 };
1600 Uint32 pos = 0;
1601 for (Uint32 i = 0; i<loops; i++)
1603 while (errnos[pos] != 0)
1605 int master = res.getMasterNodeId();
1606 int next = res.getNextMasterNodeId(master);
1607 int next2 = res.getNextMasterNodeId(next);
1609 int node = (i & 1) ? next : next2;
1610 ndbout_c("Tesing err: %d", errnos[pos]);
1611 if (res.insertErrorInNode(next, errnos[pos]))
1612 return NDBT_FAILED;
1614 NdbSleep_SecSleep(3);
1616 if (res.waitClusterStarted())
1617 return NDBT_FAILED;
1619 pos++;
1621 pos = 0;
1624 return NDBT_OK;
1628 runBug27466(NDBT_Context* ctx, NDBT_Step* step)
1630 int result = NDBT_OK;
1631 int loops = ctx->getNumLoops();
1632 int records = ctx->getNumRecords();
1633 NdbRestarter res;
1635 if (res.getNumDbNodes() < 2)
1637 return NDBT_OK;
1640 Uint32 pos = 0;
1641 for (Uint32 i = 0; i<loops; i++)
1643 int node1 = res.getDbNodeId(rand() % res.getNumDbNodes());
1644 int node2 = node1;
1645 while (node1 == node2)
1647 node2 = res.getDbNodeId(rand() % res.getNumDbNodes());
1650 ndbout_c("nodes %u %u", node1, node2);
1652 if (res.restartOneDbNode(node1, false, true, true))
1653 return NDBT_FAILED;
1655 if (res.waitNodesNoStart(&node1, 1))
1656 return NDBT_FAILED;
1658 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1659 if (res.dumpStateOneNode(node1, val2, 2))
1660 return NDBT_FAILED;
1662 if (res.insertErrorInNode(node2, 8039))
1663 return NDBT_FAILED;
1665 res.startNodes(&node1, 1);
1666 NdbSleep_SecSleep(3);
1667 if (res.waitNodesNoStart(&node1, 1))
1668 return NDBT_FAILED;
1669 NdbSleep_SecSleep(5); // Wait for delayed INCL_NODECONF to arrive
1671 res.startNodes(&node1, 1);
1672 if (res.waitClusterStarted())
1673 return NDBT_FAILED;
1676 return NDBT_OK;
1680 runBug28023(NDBT_Context* ctx, NDBT_Step* step)
1682 int result = NDBT_OK;
1683 int loops = ctx->getNumLoops();
1684 int records = ctx->getNumRecords();
1685 Ndb* pNdb = GETNDB(step);
1686 NdbRestarter res;
1688 if (res.getNumDbNodes() < 2)
1690 return NDBT_OK;
1694 HugoTransactions hugoTrans(*ctx->getTab());
1695 if (hugoTrans.loadTable(pNdb, records) != 0){
1696 return NDBT_FAILED;
1699 if (hugoTrans.clearTable(pNdb, records) != 0)
1701 return NDBT_FAILED;
1704 for (Uint32 i = 0; i<loops; i++)
1706 int node1 = res.getDbNodeId(rand() % res.getNumDbNodes());
1708 if (res.restartOneDbNode2(node1,
1709 NdbRestarter::NRRF_ABORT |
1710 NdbRestarter::NRRF_NOSTART))
1711 return NDBT_FAILED;
1713 if (res.waitNodesNoStart(&node1, 1))
1714 return NDBT_FAILED;
1716 if (hugoTrans.loadTable(pNdb, records) != 0){
1717 return NDBT_FAILED;
1720 if (hugoTrans.clearTable(pNdb, records) != 0)
1722 return NDBT_FAILED;
1725 res.startNodes(&node1, 1);
1726 if (res.waitClusterStarted())
1727 return NDBT_FAILED;
1729 if (hugoTrans.loadTable(pNdb, records) != 0){
1730 return NDBT_FAILED;
1733 if (hugoTrans.scanUpdateRecords(pNdb, records) != 0)
1734 return NDBT_FAILED;
1736 if (hugoTrans.clearTable(pNdb, records) != 0)
1738 return NDBT_FAILED;
1742 return NDBT_OK;
1747 runBug28717(NDBT_Context* ctx, NDBT_Step* step)
1749 int result = NDBT_OK;
1750 int loops = ctx->getNumLoops();
1751 int records = ctx->getNumRecords();
1752 Ndb* pNdb = GETNDB(step);
1753 NdbRestarter res;
1755 if (res.getNumDbNodes() < 4)
1757 return NDBT_OK;
1760 int master = res.getMasterNodeId();
1761 int node0 = res.getRandomNodeOtherNodeGroup(master, rand());
1762 int node1 = res.getRandomNodeSameNodeGroup(node0, rand());
1764 ndbout_c("master: %d node0: %d node1: %d", master, node0, node1);
1766 if (res.restartOneDbNode(node0, false, true, true))
1768 return NDBT_FAILED;
1772 int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
1773 NdbLogEventHandle handle =
1774 ndb_mgm_create_logevent_handle(res.handle, filter);
1777 int dump[] = { DumpStateOrd::DihStartLcpImmediately };
1778 struct ndb_logevent event;
1780 for (Uint32 i = 0; i<3; i++)
1782 res.dumpStateOneNode(master, dump, 1);
1783 while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1784 event.type != NDB_LE_LocalCheckpointStarted);
1785 while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
1786 event.type != NDB_LE_LocalCheckpointCompleted);
1790 if (res.waitNodesNoStart(&node0, 1))
1791 return NDBT_FAILED;
1793 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1795 if (res.dumpStateOneNode(node0, val2, 2))
1796 return NDBT_FAILED;
1798 if (res.insertErrorInNode(node0, 5010))
1799 return NDBT_FAILED;
1801 if (res.insertErrorInNode(node1, 1001))
1802 return NDBT_FAILED;
1804 if (res.startNodes(&node0, 1))
1805 return NDBT_FAILED;
1807 NdbSleep_SecSleep(3);
1809 if (res.insertErrorInNode(node1, 0))
1810 return NDBT_FAILED;
1812 if (res.waitNodesNoStart(&node0, 1))
1813 return NDBT_FAILED;
1815 if (res.startNodes(&node0, 1))
1816 return NDBT_FAILED;
1818 if (res.waitClusterStarted())
1819 return NDBT_FAILED;
1821 return NDBT_OK;
1825 runBug31525(NDBT_Context* ctx, NDBT_Step* step)
1827 int result = NDBT_OK;
1828 int loops = ctx->getNumLoops();
1829 int records = ctx->getNumRecords();
1830 Ndb* pNdb = GETNDB(step);
1831 NdbRestarter res;
1833 if (res.getNumDbNodes() < 2)
1835 return NDBT_OK;
1838 int nodes[2];
1839 nodes[0] = res.getMasterNodeId();
1840 nodes[1] = res.getNextMasterNodeId(nodes[0]);
1842 while (res.getNodeGroup(nodes[0]) != res.getNodeGroup(nodes[1]))
1844 ndbout_c("Restarting %u as it not in same node group as %u",
1845 nodes[1], nodes[0]);
1846 if (res.restartOneDbNode(nodes[1], false, true, true))
1847 return NDBT_FAILED;
1849 if (res.waitNodesNoStart(nodes+1, 1))
1850 return NDBT_FAILED;
1852 if (res.startNodes(nodes+1, 1))
1853 return NDBT_FAILED;
1855 if (res.waitClusterStarted())
1856 return NDBT_FAILED;
1858 nodes[1] = res.getNextMasterNodeId(nodes[0]);
1861 ndbout_c("nodes[0]: %u nodes[1]: %u", nodes[0], nodes[1]);
1863 int val = DumpStateOrd::DihMinTimeBetweenLCP;
1864 if (res.dumpStateAllNodes(&val, 1))
1865 return NDBT_FAILED;
1867 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1868 if (res.dumpStateAllNodes(val2, 2))
1869 return NDBT_FAILED;
1871 if (res.insertErrorInAllNodes(932))
1872 return NDBT_FAILED;
1874 if (res.insertErrorInNode(nodes[1], 7192))
1875 return NDBT_FAILED;
1877 if (res.insertErrorInNode(nodes[0], 7191))
1878 return NDBT_FAILED;
1880 if (res.waitClusterNoStart())
1881 return NDBT_FAILED;
1883 if (res.startAll())
1884 return NDBT_FAILED;
1886 if (res.waitClusterStarted())
1887 return NDBT_FAILED;
1889 if (res.restartOneDbNode(nodes[1], false, false, true))
1890 return NDBT_FAILED;
1892 if (res.waitClusterStarted())
1893 return NDBT_FAILED;
1895 return NDBT_OK;
1899 runBug32160(NDBT_Context* ctx, NDBT_Step* step)
1901 int result = NDBT_OK;
1902 int loops = ctx->getNumLoops();
1903 int records = ctx->getNumRecords();
1904 Ndb* pNdb = GETNDB(step);
1905 NdbRestarter res;
1907 if (res.getNumDbNodes() < 2)
1909 return NDBT_OK;
1912 int master = res.getMasterNodeId();
1913 int next = res.getNextMasterNodeId(master);
1915 if (res.insertErrorInNode(next, 7194))
1917 return NDBT_FAILED;
1920 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1921 if (res.dumpStateOneNode(master, val2, 2))
1922 return NDBT_FAILED;
1924 if (res.insertErrorInNode(master, 7193))
1925 return NDBT_FAILED;
1927 int val3[] = { 7099 };
1928 if (res.dumpStateOneNode(master, val3, 1))
1929 return NDBT_FAILED;
1931 if (res.waitNodesNoStart(&master, 1))
1932 return NDBT_FAILED;
1934 if (res.startNodes(&master, 1))
1935 return NDBT_FAILED;
1937 if (res.waitClusterStarted())
1938 return NDBT_FAILED;
1940 return NDBT_OK;
1944 runBug34216(NDBT_Context* ctx, NDBT_Step* step)
1946 int result = NDBT_OK;
1947 int loops = ctx->getNumLoops();
1948 NdbRestarter restarter;
1949 int i = 0;
1950 int lastId = 0;
1951 HugoOperations hugoOps(*ctx->getTab());
1952 int records = ctx->getNumRecords();
1953 Ndb* pNdb = GETNDB(step);
1955 if (restarter.getNumDbNodes() < 2)
1957 ctx->stopTest();
1958 return NDBT_OK;
1961 if(restarter.waitClusterStarted() != 0){
1962 g_err << "Cluster failed to start" << endl;
1963 return NDBT_FAILED;
1966 char buf[100];
1967 const char * off = NdbEnv_GetEnv("NDB_ERR_OFFSET", buf, sizeof(buf));
1968 int offset = off ? atoi(off) : 0;
1970 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped())
1972 int id = lastId % restarter.getNumDbNodes();
1973 int nodeId = restarter.getDbNodeId(id);
1974 int err = 5048 + ((i+offset) % 2);
1976 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
1978 if(hugoOps.startTransaction(pNdb) != 0)
1979 goto err;
1981 nodeId = hugoOps.getTransaction()->getConnectedNodeId();
1982 ndbout << "Restart node " << nodeId << " " << err <<endl;
1984 if (restarter.dumpStateOneNode(nodeId, val2, 2))
1985 return NDBT_FAILED;
1987 if(restarter.insertErrorInNode(nodeId, err) != 0){
1988 g_err << "Failed to restartNextDbNode" << endl;
1989 result = NDBT_FAILED;
1990 break;
1993 if (restarter.insertErrorInNode(nodeId, 8057) != 0)
1995 g_err << "Failed to insert error 8057" << endl;
1996 result = NDBT_FAILED;
1997 break;
2000 int rows = 10;
2001 int batch = 1;
2002 int row = (records - rows) ? rand() % (records - rows) : 0;
2004 if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
2005 goto err;
2007 for (int l = 1; l<5; l++)
2009 if (hugoOps.execute_NoCommit(pNdb) != 0)
2010 goto err;
2012 if(hugoOps.pkUpdateRecord(pNdb, row, batch, rand()) != 0)
2013 goto err;
2016 hugoOps.execute_Commit(pNdb);
2017 hugoOps.closeTransaction(pNdb);
2019 if (restarter.waitNodesNoStart(&nodeId, 1))
2021 g_err << "Failed to waitNodesNoStart" << endl;
2022 result = NDBT_FAILED;
2023 break;
2026 if (restarter.startNodes(&nodeId, 1))
2028 g_err << "Failed to startNodes" << endl;
2029 result = NDBT_FAILED;
2030 break;
2033 if(restarter.waitClusterStarted() != 0){
2034 g_err << "Cluster failed to start" << endl;
2035 result = NDBT_FAILED;
2036 break;
2039 lastId++;
2040 i++;
2043 ctx->stopTest();
2045 return result;
2046 err:
2047 return NDBT_FAILED;
2052 runNF_commit(NDBT_Context* ctx, NDBT_Step* step)
2054 int result = NDBT_OK;
2055 int loops = ctx->getNumLoops();
2056 NdbRestarter restarter;
2057 if (restarter.getNumDbNodes() < 2)
2059 ctx->stopTest();
2060 return NDBT_OK;
2063 if(restarter.waitClusterStarted() != 0){
2064 g_err << "Cluster failed to start" << endl;
2065 return NDBT_FAILED;
2068 int i = 0;
2069 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped())
2071 int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
2072 int err = 5048;
2074 ndbout << "Restart node " << nodeId << " " << err <<endl;
2076 int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
2077 if (restarter.dumpStateOneNode(nodeId, val2, 2))
2078 return NDBT_FAILED;
2080 if(restarter.insertErrorInNode(nodeId, err) != 0){
2081 g_err << "Failed to restartNextDbNode" << endl;
2082 result = NDBT_FAILED;
2083 break;
2086 if (restarter.waitNodesNoStart(&nodeId, 1))
2088 g_err << "Failed to waitNodesNoStart" << endl;
2089 result = NDBT_FAILED;
2090 break;
2093 if (restarter.startNodes(&nodeId, 1))
2095 g_err << "Failed to startNodes" << endl;
2096 result = NDBT_FAILED;
2097 break;
2100 if(restarter.waitClusterStarted() != 0){
2101 g_err << "Cluster failed to start" << endl;
2102 result = NDBT_FAILED;
2103 break;
2106 i++;
2109 ctx->stopTest();
2111 return result;
2115 NDBT_TESTSUITE(testNodeRestart);
2116 TESTCASE("NoLoad",
2117 "Test that one node at a time can be stopped and then restarted "\
2118 "when there are no load on the system. Do this loop number of times"){
2119 INITIALIZER(runCheckAllNodesStarted);
2120 INITIALIZER(runLoadTable);
2121 STEP(runRestarter);
2122 FINALIZER(runClearTable);
2124 TESTCASE("PkRead",
2125 "Test that one node at a time can be stopped and then restarted "\
2126 "perform pk read while restarting. Do this loop number of times"){
2127 TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);
2128 INITIALIZER(runCheckAllNodesStarted);
2129 INITIALIZER(runLoadTable);
2130 STEP(runRestarter);
2131 STEP(runPkReadUntilStopped);
2132 FINALIZER(runClearTable);
2134 TESTCASE("PkReadCommitted",
2135 "Test that one node at a time can be stopped and then restarted "\
2136 "perform pk read while restarting. Do this loop number of times"){
2137 TC_PROPERTY("ReadLockMode", NdbOperation::LM_CommittedRead);
2138 INITIALIZER(runCheckAllNodesStarted);
2139 INITIALIZER(runLoadTable);
2140 STEP(runRestarter);
2141 STEP(runPkReadUntilStopped);
2142 FINALIZER(runClearTable);
2144 TESTCASE("MixedPkRead",
2145 "Test that one node at a time can be stopped and then restarted "\
2146 "perform pk read while restarting. Do this loop number of times"){
2147 TC_PROPERTY("ReadLockMode", -1);
2148 INITIALIZER(runCheckAllNodesStarted);
2149 INITIALIZER(runLoadTable);
2150 STEP(runRestarter);
2151 STEP(runPkReadUntilStopped);
2152 FINALIZER(runClearTable);
2154 TESTCASE("PkReadPkUpdate",
2155 "Test that one node at a time can be stopped and then restarted "\
2156 "perform pk read and pk update while restarting. Do this loop number of times"){
2157 TC_PROPERTY("ReadLockMode", NdbOperation::LM_Read);
2158 INITIALIZER(runCheckAllNodesStarted);
2159 INITIALIZER(runLoadTable);
2160 STEP(runRestarter);
2161 STEP(runPkReadUntilStopped);
2162 STEP(runPkUpdateUntilStopped);
2163 STEP(runPkReadPkUpdateUntilStopped);
2164 STEP(runPkReadUntilStopped);
2165 STEP(runPkUpdateUntilStopped);
2166 STEP(runPkReadPkUpdateUntilStopped);
2167 FINALIZER(runClearTable);
2169 TESTCASE("MixedPkReadPkUpdate",
2170 "Test that one node at a time can be stopped and then restarted "\
2171 "perform pk read and pk update while restarting. Do this loop number of times"){
2172 TC_PROPERTY("ReadLockMode", -1);
2173 INITIALIZER(runCheckAllNodesStarted);
2174 INITIALIZER(runLoadTable);
2175 STEP(runRestarter);
2176 STEP(runPkReadUntilStopped);
2177 STEP(runPkUpdateUntilStopped);
2178 STEP(runPkReadPkUpdateUntilStopped);
2179 STEP(runPkReadUntilStopped);
2180 STEP(runPkUpdateUntilStopped);
2181 STEP(runPkReadPkUpdateUntilStopped);
2182 FINALIZER(runClearTable);
2184 TESTCASE("ReadUpdateScan",
2185 "Test that one node at a time can be stopped and then restarted "\
2186 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){
2187 INITIALIZER(runCheckAllNodesStarted);
2188 INITIALIZER(runLoadTable);
2189 STEP(runRestarter);
2190 STEP(runPkReadUntilStopped);
2191 STEP(runPkUpdateUntilStopped);
2192 STEP(runPkReadPkUpdateUntilStopped);
2193 STEP(runScanReadUntilStopped);
2194 STEP(runScanUpdateUntilStopped);
2195 FINALIZER(runClearTable);
2197 TESTCASE("MixedReadUpdateScan",
2198 "Test that one node at a time can be stopped and then restarted "\
2199 "perform pk read, pk update and scan reads while restarting. Do this loop number of times"){
2200 TC_PROPERTY("ReadLockMode", -1);
2201 INITIALIZER(runCheckAllNodesStarted);
2202 INITIALIZER(runLoadTable);
2203 STEP(runRestarter);
2204 STEP(runPkReadUntilStopped);
2205 STEP(runPkUpdateUntilStopped);
2206 STEP(runPkReadPkUpdateUntilStopped);
2207 STEP(runScanReadUntilStopped);
2208 STEP(runScanUpdateUntilStopped);
2209 FINALIZER(runClearTable);
2211 TESTCASE("Terror",
2212 "Test that one node at a time can be stopped and then restarted "\
2213 "perform all kind of transactions while restarting. Do this loop number of times"){
2214 INITIALIZER(runCheckAllNodesStarted);
2215 INITIALIZER(runLoadTable);
2216 STEP(runRestarter);
2217 STEP(runPkReadUntilStopped);
2218 STEP(runPkUpdateUntilStopped);
2219 STEP(runScanReadUntilStopped);
2220 STEP(runScanUpdateUntilStopped);
2221 FINALIZER(runClearTable);
2223 TESTCASE("FullDb",
2224 "Test that one node at a time can be stopped and then restarted "\
2225 "when db is full. Do this loop number of times"){
2226 INITIALIZER(runCheckAllNodesStarted);
2227 INITIALIZER(runFillTable);
2228 STEP(runRestarter);
2229 FINALIZER(runClearTable);
2231 TESTCASE("RestartRandomNode",
2232 "Test that we can execute the restart RestartRandomNode loop\n"\
2233 "number of times"){
2234 INITIALIZER(runCheckAllNodesStarted);
2235 INITIALIZER(runLoadTable);
2236 STEP(runRestarts);
2237 FINALIZER(runScanReadVerify);
2238 FINALIZER(runClearTable);
2240 TESTCASE("RestartRandomNodeError",
2241 "Test that we can execute the restart RestartRandomNodeError loop\n"\
2242 "number of times"){
2243 INITIALIZER(runCheckAllNodesStarted);
2244 INITIALIZER(runLoadTable);
2245 STEP(runRestarts);
2246 FINALIZER(runScanReadVerify);
2247 FINALIZER(runClearTable);
2249 TESTCASE("RestartRandomNodeInitial",
2250 "Test that we can execute the restart RestartRandomNodeInitial loop\n"\
2251 "number of times"){
2252 INITIALIZER(runCheckAllNodesStarted);
2253 INITIALIZER(runLoadTable);
2254 STEP(runRestarts);
2255 FINALIZER(runScanReadVerify);
2256 FINALIZER(runClearTable);
2258 TESTCASE("RestartNFDuringNR",
2259 "Test that we can execute the restart RestartNFDuringNR loop\n"\
2260 "number of times"){
2261 INITIALIZER(runCheckAllNodesStarted);
2262 INITIALIZER(runLoadTable);
2263 STEP(runRestarts);
2264 STEP(runPkUpdateUntilStopped);
2265 STEP(runScanUpdateUntilStopped);
2266 FINALIZER(runScanReadVerify);
2267 FINALIZER(runClearTable);
2269 TESTCASE("RestartMasterNodeError",
2270 "Test that we can execute the restart RestartMasterNodeError loop\n"\
2271 "number of times"){
2272 INITIALIZER(runCheckAllNodesStarted);
2273 INITIALIZER(runLoadTable);
2274 STEP(runRestarts);
2275 FINALIZER(runScanReadVerify);
2276 FINALIZER(runClearTable);
2279 TESTCASE("TwoNodeFailure",
2280 "Test that we can execute the restart TwoNodeFailure\n"\
2281 "(which is a multiple node failure restart) loop\n"\
2282 "number of times"){
2283 INITIALIZER(runCheckAllNodesStarted);
2284 INITIALIZER(runLoadTable);
2285 STEP(runRestarts);
2286 FINALIZER(runScanReadVerify);
2287 FINALIZER(runClearTable);
2289 TESTCASE("TwoMasterNodeFailure",
2290 "Test that we can execute the restart TwoMasterNodeFailure\n"\
2291 "(which is a multiple node failure restart) loop\n"\
2292 "number of times"){
2293 INITIALIZER(runCheckAllNodesStarted);
2294 INITIALIZER(runLoadTable);
2295 STEP(runRestarts);
2296 FINALIZER(runScanReadVerify);
2297 FINALIZER(runClearTable);
2299 TESTCASE("FiftyPercentFail",
2300 "Test that we can execute the restart FiftyPercentFail\n"\
2301 "(which is a multiple node failure restart) loop\n"\
2302 "number of times"){
2303 INITIALIZER(runCheckAllNodesStarted);
2304 INITIALIZER(runLoadTable);
2305 STEP(runRestarts);
2306 FINALIZER(runScanReadVerify);
2307 FINALIZER(runClearTable);
2309 TESTCASE("RestartAllNodes",
2310 "Test that we can execute the restart RestartAllNodes\n"\
2311 "(which is a system restart) loop\n"\
2312 "number of times"){
2313 INITIALIZER(runCheckAllNodesStarted);
2314 INITIALIZER(runLoadTable);
2315 STEP(runRestarts);
2316 FINALIZER(runScanReadVerify);
2317 FINALIZER(runClearTable);
2319 TESTCASE("RestartAllNodesAbort",
2320 "Test that we can execute the restart RestartAllNodesAbort\n"\
2321 "(which is a system restart) loop\n"\
2322 "number of times"){
2323 INITIALIZER(runCheckAllNodesStarted);
2324 INITIALIZER(runLoadTable);
2325 STEP(runRestarts);
2326 FINALIZER(runScanReadVerify);
2327 FINALIZER(runClearTable);
2329 TESTCASE("RestartAllNodesError9999",
2330 "Test that we can execute the restart RestartAllNodesError9999\n"\
2331 "(which is a system restart) loop\n"\
2332 "number of times"){
2333 INITIALIZER(runCheckAllNodesStarted);
2334 INITIALIZER(runLoadTable);
2335 STEP(runRestarts);
2336 FINALIZER(runScanReadVerify);
2337 FINALIZER(runClearTable);
2339 TESTCASE("FiftyPercentStopAndWait",
2340 "Test that we can execute the restart FiftyPercentStopAndWait\n"\
2341 "(which is a system restart) loop\n"\
2342 "number of times"){
2343 INITIALIZER(runCheckAllNodesStarted);
2344 INITIALIZER(runLoadTable);
2345 STEP(runRestarts);
2346 FINALIZER(runScanReadVerify);
2347 FINALIZER(runClearTable);
2349 TESTCASE("RestartNodeDuringLCP",
2350 "Test that we can execute the restart RestartRandomNode loop\n"\
2351 "number of times"){
2352 INITIALIZER(runCheckAllNodesStarted);
2353 INITIALIZER(runLoadTable);
2354 STEP(runRestarts);
2355 STEP(runPkUpdateUntilStopped);
2356 STEP(runScanUpdateUntilStopped);
2357 FINALIZER(runScanReadVerify);
2358 FINALIZER(runClearTable);
2360 TESTCASE("StopOnError",
2361 "Test StopOnError. A node that has StopOnError set to false "\
2362 "should restart automatically when an error occurs"){
2363 INITIALIZER(runCheckAllNodesStarted);
2364 INITIALIZER(runLoadTable);
2365 STEP(runRestarts);
2366 FINALIZER(runScanReadVerify);
2367 FINALIZER(runClearTable);
2369 TESTCASE("CommittedRead",
2370 "Test committed read"){
2371 INITIALIZER(runLoadTable);
2372 STEP(runDirtyRead);
2373 FINALIZER(runClearTable);
2375 TESTCASE("LateCommit",
2376 "Test commit after node failure"){
2377 INITIALIZER(runLoadTable);
2378 STEP(runLateCommit);
2379 FINALIZER(runClearTable);
2381 TESTCASE("Bug15587",
2382 "Test bug with NF during NR"){
2383 INITIALIZER(runLoadTable);
2384 STEP(runScanUpdateUntilStopped);
2385 STEP(runBug15587);
2386 FINALIZER(runClearTable);
2388 TESTCASE("Bug15632",
2389 "Test bug with NF during NR"){
2390 INITIALIZER(runLoadTable);
2391 STEP(runBug15632);
2392 FINALIZER(runClearTable);
2394 TESTCASE("Bug15685",
2395 "Test bug with NF during abort"){
2396 STEP(runBug15685);
2397 FINALIZER(runClearTable);
2399 TESTCASE("Bug16772",
2400 "Test bug with restarting before NF handling is complete"){
2401 STEP(runBug16772);
2403 TESTCASE("Bug18414",
2404 "Test bug with NF during NR"){
2405 INITIALIZER(runLoadTable);
2406 STEP(runBug18414);
2407 FINALIZER(runClearTable);
2409 TESTCASE("Bug18612",
2410 "Test bug with partitioned clusters"){
2411 INITIALIZER(runLoadTable);
2412 STEP(runBug18612);
2413 FINALIZER(runClearTable);
2415 TESTCASE("Bug18612SR",
2416 "Test bug with partitioned clusters"){
2417 INITIALIZER(runLoadTable);
2418 STEP(runBug18612SR);
2419 FINALIZER(runClearTable);
2421 TESTCASE("Bug20185",
2422 ""){
2423 INITIALIZER(runLoadTable);
2424 STEP(runBug20185);
2425 FINALIZER(runClearTable);
2427 TESTCASE("Bug24543", "")
2429 INITIALIZER(runBug24543);
2431 TESTCASE("Bug21271",
2432 ""){
2433 INITIALIZER(runLoadTable);
2434 STEP(runBug21271);
2435 STEP(runPkUpdateUntilStopped);
2436 FINALIZER(runClearTable);
2438 TESTCASE("Bug31525", ""){
2439 INITIALIZER(runBug31525);
2441 TESTCASE("Bug24717", ""){
2442 INITIALIZER(runBug24717);
2444 TESTCASE("Bug25364", ""){
2445 INITIALIZER(runBug25364);
2447 TESTCASE("Bug25468", ""){
2448 INITIALIZER(runBug25468);
2450 TESTCASE("Bug25554", ""){
2451 INITIALIZER(runBug25554);
2453 TESTCASE("Bug25984", ""){
2454 INITIALIZER(runBug25984);
2456 TESTCASE("Bug26457", ""){
2457 INITIALIZER(runBug26457);
2459 TESTCASE("Bug26481", ""){
2460 INITIALIZER(runBug26481);
2462 TESTCASE("Bug26450", ""){
2463 INITIALIZER(runLoadTable);
2464 INITIALIZER(runBug26450);
2466 TESTCASE("Bug27003", ""){
2467 INITIALIZER(runBug27003);
2469 TESTCASE("Bug27283", ""){
2470 INITIALIZER(runBug27283);
2472 TESTCASE("Bug27466", ""){
2473 INITIALIZER(runBug27466);
2475 TESTCASE("Bug28023", ""){
2476 INITIALIZER(runBug28023);
2478 TESTCASE("Bug28717", ""){
2479 INITIALIZER(runBug28717);
2481 TESTCASE("Bug29364", ""){
2482 INITIALIZER(runBug29364);
2484 TESTCASE("Bug32160", ""){
2485 INITIALIZER(runBug32160);
2487 TESTCASE("Bug34216", ""){
2488 INITIALIZER(runCheckAllNodesStarted);
2489 INITIALIZER(runLoadTable);
2490 STEP(runBug34216);
2491 FINALIZER(runClearTable);
2493 TESTCASE("mixedmultiop", ""){
2494 TC_PROPERTY("MULTI_OP", 5);
2495 INITIALIZER(runCheckAllNodesStarted);
2496 INITIALIZER(runLoadTable);
2497 STEP(runNF_commit);
2498 STEP(runPkUpdateUntilStopped);
2499 STEP(runPkUpdateUntilStopped);
2500 FINALIZER(runClearTable);
2502 NDBT_TESTSUITE_END(testNodeRestart);
2504 int main(int argc, const char** argv){
2505 ndb_init();
2506 #if 0
2507 // It might be interesting to have longer defaults for num
2508 // loops in this test
2509 // Just performing 100 node restarts would not be enough?
2510 // We can have initialisers in the NDBT_Testcase class like
2511 // this...
2512 testNodeRestart.setDefaultLoops(1000);
2513 #endif
2514 return testNodeRestart.execute(argc, argv);