1
/* Copyright (C) 2003 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
#include <NDBT_Test.hpp>
18
#include <HugoTransactions.hpp>
19
#include <UtilTransactions.hpp>
20
#include <NdbRestarter.hpp>
21
#include <NdbRestarts.hpp>
23
#include <signaldata/DumpStateOrd.hpp>
25
#define CHECK(b) if (!(b)) { \
26
g_err << "ERR: "<< step->getName() \
27
<< " failed on line " << __LINE__ << endl; \
28
result = NDBT_FAILED; break;\
45
for(size_t i = 0; i < attriblist.size(); i++){
49
void buildAttribList(const NdbDictionary::Table* pTab);
50
Vector<Attrib*> attriblist;
53
void AttribList::buildAttribList(const NdbDictionary::Table* pTab){
57
// Build attrib definitions that describes which attributes to build index
58
// Try to build strange combinations, not just "all" or all PK's
62
for(i = 1; i <= pTab->getNoOfColumns(); i++){
65
for(int a = 0; a<i; a++)
67
attriblist.push_back(attr);
70
for(i = pTab->getNoOfColumns()-1; i > 0; i--){
74
for(int a = 0; a<i; a++)
75
attr->attribs[a] = a+b;
76
attriblist.push_back(attr);
78
for(i = pTab->getNoOfColumns(); i > 0; i--){
80
attr->numAttribs = pTab->getNoOfColumns() - i;
81
for(int a = 0; a<pTab->getNoOfColumns() - i; a++)
82
attr->attribs[a] = pTab->getNoOfColumns()-a-1;
83
attriblist.push_back(attr);
85
for(i = 1; i < pTab->getNoOfColumns(); i++){
87
attr->numAttribs = pTab->getNoOfColumns() - i;
88
for(int a = 0; a<pTab->getNoOfColumns() - i; a++)
89
attr->attribs[a] = pTab->getNoOfColumns()-a-1;
90
attriblist.push_back(attr);
92
for(i = 1; i < pTab->getNoOfColumns(); i++){
95
for(int a = 0; a<2; a++){
96
attr->attribs[a] = i%pTab->getNoOfColumns();
98
attriblist.push_back(attr);
103
attr->numAttribs = 1;
104
attr->attribs[0] = pTab->getNoOfColumns()-1;
105
attriblist.push_back(attr);
109
attr->numAttribs = 2;
110
attr->attribs[0] = pTab->getNoOfColumns()-1;
111
attr->attribs[1] = 0;
112
attriblist.push_back(attr);
116
attr->numAttribs = 2;
117
attr->attribs[0] = 0;
118
attr->attribs[1] = pTab->getNoOfColumns()-1;
119
attriblist.push_back(attr);
122
for(size_t i = 0; i < attriblist.size(); i++){
124
ndbout << attriblist[i]->numAttribs << ": " ;
125
for(int a = 0; a < attriblist[i]->numAttribs; a++)
126
ndbout << attriblist[i]->attribs[a] << ", ";
136
static const int SKIP_INDEX = 99;
138
int create_index(NDBT_Context* ctx, int indxNum,
139
const NdbDictionary::Table* pTab,
140
Ndb* pNdb, Attrib* attr, bool logged){
141
bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
142
int result = NDBT_OK;
144
HugoCalculator calc(*pTab);
146
if (attr->numAttribs == 1 &&
147
calc.isUpdateCol(attr->attribs[0]) == true){
148
// Don't create index for the Hugo update column
149
// since it's not unique
154
BaseString::snprintf(idxName, 255, "IDC%d", indxNum);
156
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "<<idxName << " (";
158
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "<<idxName << " (";
160
NdbDictionary::Index pIdx(idxName);
161
pIdx.setTable(pTab->getName());
163
pIdx.setType(NdbDictionary::Index::OrderedIndex);
165
pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
166
for (int c = 0; c< attr->numAttribs; c++){
167
int attrNo = attr->attribs[c];
168
pIdx.addIndexColumn(pTab->getColumn(attrNo)->getName());
169
ndbout << pTab->getColumn(attrNo)->getName()<<" ";
172
pIdx.setStoredIndex(logged);
174
if (pNdb->getDictionary()->createIndex(pIdx) != 0){
175
attr->indexCreated = false;
176
ndbout << "FAILED!" << endl;
177
const NdbError err = pNdb->getDictionary()->getNdbError();
179
if(err.classification == NdbError::ApplicationError)
184
ndbout << "OK!" << endl;
185
attr->indexCreated = true;
191
int drop_index(int indxNum, Ndb* pNdb,
192
const NdbDictionary::Table* pTab, Attrib* attr){
193
int result = NDBT_OK;
195
if (attr->indexCreated == false)
198
BaseString::snprintf(idxName, 255, "IDC%d", indxNum);
201
ndbout << "Dropping index "<<idxName<<"(" << pTab->getName() << ") ";
202
if (pNdb->getDictionary()->dropIndex(idxName, pTab->getName()) != 0){
203
ndbout << "FAILED!" << endl;
204
ERR(pNdb->getDictionary()->getNdbError());
205
result = NDBT_FAILED;
207
ndbout << "OK!" << endl;
212
int runCreateIndexes(NDBT_Context* ctx, NDBT_Step* step){
213
int loops = ctx->getNumLoops();
215
const NdbDictionary::Table* pTab = ctx->getTab();
216
Ndb* pNdb = GETNDB(step);
217
int result = NDBT_OK;
218
// NOTE If we need to test creating both logged and non logged indexes
219
// this should be divided into two testcases
220
// The paramater logged should then be specified
221
// as a TC_PROPERTY. ex TC_PROPERTY("LoggedIndexes", 1);
222
// and read into the test step like
223
bool logged = ctx->getProperty("LoggedIndexes", 1);
226
attrList.buildAttribList(pTab);
229
while (l < loops && result == NDBT_OK){
231
for (i = 0; i < attrList.attriblist.size(); i++){
233
// Try to create index
234
if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
235
result = NDBT_FAILED;
238
// Now drop all indexes that where created
239
for (i = 0; i < attrList.attriblist.size(); i++){
242
if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
243
result = NDBT_FAILED;
252
int createRandomIndex(NDBT_Context* ctx, NDBT_Step* step){
253
const NdbDictionary::Table* pTab = ctx->getTab();
254
Ndb* pNdb = GETNDB(step);
255
bool logged = ctx->getProperty("LoggedIndexes", 1);
258
attrList.buildAttribList(pTab);
262
const Uint32 i = rand() % attrList.attriblist.size();
263
int res = create_index(ctx, i, pTab, pNdb, attrList.attriblist[i],
265
if (res == SKIP_INDEX){
270
if (res == NDBT_FAILED){
274
ctx->setProperty("createRandomIndex", i);
275
// Now drop all indexes that where created
283
int createRandomIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
284
Ndb* pNdb = GETNDB(step);
286
Uint32 i = ctx->getProperty("createRandomIndex");
288
BaseString::snprintf(idxName, 255, "IDC%d", i);
291
ndbout << "Dropping index " << idxName << " ";
292
if (pNdb->getDictionary()->dropIndex(idxName,
293
ctx->getTab()->getName()) != 0){
294
ndbout << "FAILED!" << endl;
295
ERR(pNdb->getDictionary()->getNdbError());
298
ndbout << "OK!" << endl;
304
int createPkIndex(NDBT_Context* ctx, NDBT_Step* step){
305
bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
307
const NdbDictionary::Table* pTab = ctx->getTab();
308
Ndb* pNdb = GETNDB(step);
310
bool logged = ctx->getProperty("LoggedIndexes", 1);
313
BaseString::snprintf(pkIdxName, 255, "IDC_PK_%s", pTab->getName());
315
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "
316
<< pkIdxName << " (";
318
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "
319
<< pkIdxName << " (";
321
NdbDictionary::Index pIdx(pkIdxName);
322
pIdx.setTable(pTab->getName());
324
pIdx.setType(NdbDictionary::Index::OrderedIndex);
326
pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
327
for (int c = 0; c< pTab->getNoOfColumns(); c++){
328
const NdbDictionary::Column * col = pTab->getColumn(c);
329
if(col->getPrimaryKey()){
330
pIdx.addIndexColumn(col->getName());
331
ndbout << col->getName() <<" ";
335
pIdx.setStoredIndex(logged);
337
if (pNdb->getDictionary()->createIndex(pIdx) != 0){
338
ndbout << "FAILED!" << endl;
339
const NdbError err = pNdb->getDictionary()->getNdbError();
344
ndbout << "OK!" << endl;
348
int createPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
349
const NdbDictionary::Table* pTab = ctx->getTab();
350
Ndb* pNdb = GETNDB(step);
353
ndbout << "Dropping index " << pkIdxName << " ";
354
if (pNdb->getDictionary()->dropIndex(pkIdxName,
355
pTab->getName()) != 0){
356
ndbout << "FAILED!" << endl;
357
ERR(pNdb->getDictionary()->getNdbError());
360
ndbout << "OK!" << endl;
367
runVerifyIndex(NDBT_Context* ctx, NDBT_Step* step){
368
// Verify that data in index match
370
Ndb* pNdb = GETNDB(step);
371
UtilTransactions utilTrans(*ctx->getTab());
372
const int batchSize = ctx->getProperty("BatchSize", 16);
373
const int parallelism = batchSize > 240 ? 240 : batchSize;
376
if (utilTrans.verifyIndex(pNdb, idxName, parallelism, true) != 0){
377
g_err << "Inconsistent index" << endl;
380
} while(ctx->isTestStopped() == false);
385
runTransactions1(NDBT_Context* ctx, NDBT_Step* step){
386
// Verify that data in index match
388
Ndb* pNdb = GETNDB(step);
389
HugoTransactions hugoTrans(*ctx->getTab());
390
const int batchSize = ctx->getProperty("BatchSize", 50);
392
int rows = ctx->getNumRecords();
393
while (ctx->isTestStopped() == false) {
394
if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
395
g_err << "Updated table failed" << endl;
399
ctx->sync_down("PauseThreads");
400
if(ctx->isTestStopped())
403
if (hugoTrans.scanUpdateRecords(pNdb, rows, batchSize) != 0){
404
g_err << "Updated table failed" << endl;
408
ctx->sync_down("PauseThreads");
414
runTransactions2(NDBT_Context* ctx, NDBT_Step* step){
415
// Verify that data in index match
417
Ndb* pNdb = GETNDB(step);
418
HugoTransactions hugoTrans(*ctx->getTab());
419
const int batchSize = ctx->getProperty("BatchSize", 50);
421
int rows = ctx->getNumRecords();
422
while (ctx->isTestStopped() == false) {
424
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
425
g_err << "Index read failed" << endl;
429
ctx->sync_down("PauseThreads");
430
if(ctx->isTestStopped())
433
if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
434
g_err << "Index update failed" << endl;
438
ctx->sync_down("PauseThreads");
444
runTransactions3(NDBT_Context* ctx, NDBT_Step* step){
445
// Verify that data in index match
447
Ndb* pNdb = GETNDB(step);
448
HugoTransactions hugoTrans(*ctx->getTab());
449
UtilTransactions utilTrans(*ctx->getTab());
450
const int batchSize = ctx->getProperty("BatchSize", 32);
451
const int parallel = batchSize > 240 ? 240 : batchSize;
453
int rows = ctx->getNumRecords();
454
while (ctx->isTestStopped() == false) {
455
if(hugoTrans.loadTable(pNdb, rows, batchSize, false) != 0){
456
g_err << "Load table failed" << endl;
459
ctx->sync_down("PauseThreads");
460
if(ctx->isTestStopped())
463
if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
464
g_err << "Updated table failed" << endl;
468
ctx->sync_down("PauseThreads");
469
if(ctx->isTestStopped())
472
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
473
g_err << "Index read failed" << endl;
477
ctx->sync_down("PauseThreads");
478
if(ctx->isTestStopped())
481
if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
482
g_err << "Index update failed" << endl;
486
ctx->sync_down("PauseThreads");
487
if(ctx->isTestStopped())
490
if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
491
g_err << "Scan updated table failed" << endl;
495
ctx->sync_down("PauseThreads");
496
if(ctx->isTestStopped())
499
if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
500
g_err << "Clear table failed" << endl;
504
ctx->sync_down("PauseThreads");
505
if(ctx->isTestStopped())
509
if(utilTrans.selectCount(pNdb, 64, &count) != 0 || count != 0)
511
ctx->sync_down("PauseThreads");
516
int runRestarts(NDBT_Context* ctx, NDBT_Step* step){
517
int result = NDBT_OK;
518
int loops = ctx->getNumLoops();
519
NDBT_TestCase* pCase = ctx->getCase();
520
NdbRestarts restarts;
523
int sync_threads = ctx->getProperty("Threads", (unsigned)0);
525
while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
526
if(restarts.executeRestart("RestartRandomNodeAbort", timeout) != 0){
527
g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
528
result = NDBT_FAILED;
531
ctx->sync_up_and_wait("PauseThreads", sync_threads);
538
int runCreateLoadDropIndex(NDBT_Context* ctx, NDBT_Step* step){
539
int loops = ctx->getNumLoops();
540
int records = ctx->getNumRecords();
542
const NdbDictionary::Table* pTab = ctx->getTab();
543
Ndb* pNdb = GETNDB(step);
544
int result = NDBT_OK;
545
int batchSize = ctx->getProperty("BatchSize", 1);
546
int parallelism = batchSize > 240? 240: batchSize;
547
ndbout << "batchSize="<<batchSize<<endl;
548
bool logged = ctx->getProperty("LoggedIndexes", 1);
550
HugoTransactions hugoTrans(*pTab);
551
UtilTransactions utilTrans(*pTab);
553
attrList.buildAttribList(pTab);
555
for (unsigned int i = 0; i < attrList.attriblist.size(); i++){
557
while (l < loops && result == NDBT_OK){
560
// Create index first and then load
562
// Try to create index
563
if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED){
564
result = NDBT_FAILED;
567
// Load the table with data
568
ndbout << "Loading data after" << endl;
569
CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
573
// Load table then create index
575
// Load the table with data
576
ndbout << "Loading data before" << endl;
577
CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
579
// Try to create index
580
if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
581
result = NDBT_FAILED;
585
// Verify that data in index match
587
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
590
ndbout <<"Doing it all"<<endl;
592
ndbout << " pkUpdateRecords" << endl;
593
CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
594
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
595
CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
596
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
597
ndbout << " pkDelRecords half" << endl;
598
CHECK(hugoTrans.pkDelRecords(pNdb, records/2, batchSize) == 0);
599
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
600
ndbout << " scanUpdateRecords" << endl;
601
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2, parallelism) == 0);
602
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
603
ndbout << " clearTable" << endl;
604
CHECK(utilTrans.clearTable(pNdb, records/2, parallelism) == 0);
605
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
606
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
608
ndbout << " loadTable" << endl;
609
CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
610
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
611
ndbout << " loadTable again" << endl;
612
CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
613
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
614
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
615
CHECK(count == records);
619
// Drop index first and then clear
621
// Try to create index
622
if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK){
623
result = NDBT_FAILED;
627
ndbout << "Clearing table after" << endl;
628
CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
632
// Clear table then drop index
635
ndbout << "Clearing table before" << endl;
636
CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
639
if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
640
result = NDBT_FAILED;
643
ndbout << " Done!" << endl;
647
// Make sure index is dropped
648
drop_index(i, pNdb, pTab, attrList.attriblist[i]);
655
int runInsertDelete(NDBT_Context* ctx, NDBT_Step* step){
656
int loops = ctx->getNumLoops();
657
int records = ctx->getNumRecords();
658
const NdbDictionary::Table* pTab = ctx->getTab();
659
Ndb* pNdb = GETNDB(step);
660
int result = NDBT_OK;
661
int batchSize = ctx->getProperty("BatchSize", 1);
662
int parallelism = batchSize > 240? 240: batchSize;
663
ndbout << "batchSize="<<batchSize<<endl;
664
bool logged = ctx->getProperty("LoggedIndexes", 1);
666
HugoTransactions hugoTrans(*pTab);
667
UtilTransactions utilTrans(*pTab);
670
attrList.buildAttribList(pTab);
672
for (unsigned int i = 0; i < attrList.attriblist.size(); i++){
674
Attrib* attr = attrList.attriblist[i];
676
if (create_index(ctx, i, pTab, pNdb, attr, logged) == NDBT_OK){
678
while (l <= loops && result == NDBT_OK){
680
CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
681
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
682
CHECK(utilTrans.clearTable(pNdb, records, parallelism) == 0);
683
CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
688
if (drop_index(i, pNdb, pTab, attr) != NDBT_OK)
689
result = NDBT_FAILED;
695
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
696
int records = ctx->getNumRecords();
698
HugoTransactions hugoTrans(*ctx->getTab());
699
int batchSize = ctx->getProperty("BatchSize", 1);
700
if(hugoTrans.loadTable(GETNDB(step), records, batchSize) != 0){
707
int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
708
int records = ctx->getNumRecords();
710
UtilTransactions utilTrans(*ctx->getTab());
711
if (utilTrans.clearTable(GETNDB(step), records) != 0){
717
int runSystemRestart1(NDBT_Context* ctx, NDBT_Step* step){
718
Ndb* pNdb = GETNDB(step);
719
int result = NDBT_OK;
721
Uint32 loops = ctx->getNumLoops();
722
int records = ctx->getNumRecords();
724
NdbRestarter restarter;
727
UtilTransactions utilTrans(*ctx->getTab());
728
HugoTransactions hugoTrans(*ctx->getTab());
729
const char * name = ctx->getTab()->getName();
730
while(i<=loops && result != NDBT_FAILED){
732
ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
735
2. Restart cluster and verify records
737
4. Restart cluster and verify records
738
5. Delete half of the records
739
6. Restart cluster and verify records
740
7. Delete all records
741
8. Restart cluster and verify records
742
9. Insert, update, delete records
743
10. Restart cluster and verify records
744
11. Insert, update, delete records
745
12. Restart cluster with error insert 5020 and verify records
747
ndbout << "Loading records..." << endl;
748
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
749
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
751
ndbout << "Restarting cluster" << endl;
752
CHECK(restarter.restartAll() == 0);
753
CHECK(restarter.waitClusterStarted(timeout) == 0);
754
CHECK(pNdb->waitUntilReady(timeout) == 0);
756
ndbout << "Verifying records..." << endl;
757
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
758
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
759
CHECK(count == records);
760
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
762
ndbout << "Updating records..." << endl;
763
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
764
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
766
ndbout << "Restarting cluster..." << endl;
767
CHECK(restarter.restartAll() == 0);
768
CHECK(restarter.waitClusterStarted(timeout) == 0);
769
CHECK(pNdb->waitUntilReady(timeout) == 0);
771
ndbout << "Verifying records..." << endl;
772
CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
773
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
774
CHECK(count == records);
775
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
777
ndbout << "Deleting 50% of records..." << endl;
778
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
779
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
781
ndbout << "Restarting cluster..." << endl;
782
CHECK(restarter.restartAll() == 0);
783
CHECK(restarter.waitClusterStarted(timeout) == 0);
784
CHECK(pNdb->waitUntilReady(timeout) == 0);
786
ndbout << "Verifying records..." << endl;
787
CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
788
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
789
CHECK(count == (records/2));
790
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
792
ndbout << "Deleting all records..." << endl;
793
CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
794
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
796
ndbout << "Restarting cluster..." << endl;
797
CHECK(restarter.restartAll() == 0);
798
CHECK(restarter.waitClusterStarted(timeout) == 0);
799
CHECK(pNdb->waitUntilReady(timeout) == 0);
801
ndbout << "Verifying records..." << endl;
802
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
804
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
806
ndbout << "Doing it all..." << endl;
807
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
808
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
809
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
810
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
811
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
812
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
813
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
814
CHECK(utilTrans.clearTable(pNdb, records) == 0);
815
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
816
CHECK(utilTrans.clearTable(pNdb, records) == 0);
817
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
818
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
819
CHECK(utilTrans.clearTable(pNdb, records) == 0);
821
ndbout << "Restarting cluster..." << endl;
822
CHECK(restarter.restartAll() == 0);
823
CHECK(restarter.waitClusterStarted(timeout) == 0);
824
CHECK(pNdb->waitUntilReady(timeout) == 0);
826
ndbout << "Verifying records..." << endl;
827
CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
830
ndbout << "Doing it all..." << endl;
831
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
832
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
833
CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
834
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
835
CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
836
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
837
CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
838
CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
839
CHECK(utilTrans.clearTable(pNdb, records) == 0);
840
CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
841
CHECK(utilTrans.clearTable(pNdb, records) == 0);
843
ndbout << "Restarting cluster with error insert 5020..." << endl;
844
CHECK(restarter.restartAll(false, true) == 0);
845
CHECK(restarter.waitClusterNoStart(timeout) == 0);
846
CHECK(restarter.insertErrorInAllNodes(5020) == 0);
847
CHECK(restarter.startAll() == 0);
848
CHECK(restarter.waitClusterStarted(timeout) == 0);
849
CHECK(pNdb->waitUntilReady(timeout) == 0);
855
ndbout << "runSystemRestart1 finished" << endl;
860
#define CHECK2(b, t) if(!b){ g_err << __LINE__ << ": " << t << endl; break;}
863
runMixed1(NDBT_Context* ctx, NDBT_Step* step){
864
// Verify that data in index match
866
Ndb* pNdb = GETNDB(step);
867
HugoOperations hugoOps(*ctx->getTab());
872
g_err << "pkRead, indexRead, Commit" << endl;
873
CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
874
CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
875
CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
876
CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
877
CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
880
g_err << "pkRead, indexRead, Commit" << endl;
881
CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
882
CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
883
CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
884
CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
885
CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
889
g_err << "pkRead, indexRead, NoCommit, Commit" << endl;
890
CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
891
CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
892
CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
894
CHECK2(hugoOps.execute_NoCommit(pNdb) == 0, "executeNoCommit");
895
CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
896
CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
899
g_err << "pkRead, pkRead, Commit" << endl;
900
CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction ");
901
CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecords ");
902
CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecords ");
903
CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
904
CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction ");
907
g_err << "indexRead, indexRead, Commit" << endl;
909
CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction ");
910
CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
911
CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
912
CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
914
CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction ");
920
hugoOps.closeTransaction(pNdb);
925
runBuildDuring(NDBT_Context* ctx, NDBT_Step* step){
926
// Verify that data in index match
928
const int Threads = ctx->getProperty("Threads", (Uint32)0);
929
const int loops = ctx->getNumLoops();
931
for(int i = 0; i<loops; i++){
933
if(createPkIndex(ctx, step) != NDBT_OK){
934
g_err << "Failed to create index" << endl;
939
if(ctx->isTestStopped())
943
if(createRandomIndex(ctx, step) != NDBT_OK){
944
g_err << "Failed to create index" << endl;
949
if(ctx->isTestStopped())
952
ctx->setProperty("pause", 1);
954
for(int j = 0; count < Threads && !ctx->isTestStopped();
955
j = (j+1) % Threads){
957
sprintf(buf, "Thread%d_paused", j);
958
int tmp = ctx->getProperty(buf, (Uint32)0);
962
if(ctx->isTestStopped())
966
if(createPkIndex_Drop(ctx, step) != NDBT_OK){
967
g_err << "Failed to drop index" << endl;
972
if(ctx->isTestStopped())
976
if(createRandomIndex_Drop(ctx, step) != NDBT_OK){
977
g_err << "Failed to drop index" << endl;
982
ctx->setProperty("pause", (Uint32)0);
983
NdbSleep_SecSleep(2);
990
static NdbLockable g_lock;
991
static int threadCounter = 0;
994
wait_paused(NDBT_Context* ctx, int id){
995
if(ctx->getProperty("pause", (Uint32)0) == 1){
997
sprintf(buf, "Thread%d_paused", id);
998
ctx->setProperty(buf, 1);
999
while(!ctx->isTestStopped() && ctx->getProperty("pause", (Uint32)0) == 1){
1000
NdbSleep_MilliSleep(250);
1002
ctx->setProperty(buf, (Uint32)0);
1007
runTransactions4(NDBT_Context* ctx, NDBT_Step* step){
1010
const int ThreadId = threadCounter++;
1013
// Verify that data in index match
1015
Ndb* pNdb = GETNDB(step);
1016
HugoTransactions hugoTrans(*ctx->getTab());
1017
UtilTransactions utilTrans(*ctx->getTab());
1018
const int batchSize = ctx->getProperty("BatchSize", 32);
1019
const int parallel = batchSize > 240 ? 240 : batchSize;
1021
int rows = ctx->getNumRecords();
1022
while (ctx->isTestStopped() == false) {
1023
if(hugoTrans.loadTable(pNdb, rows, batchSize, false) != 0){
1024
g_err << "Load table failed" << endl;
1028
wait_paused(ctx, ThreadId);
1030
if(ctx->isTestStopped())
1033
if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
1034
g_err << "Updated table failed" << endl;
1038
wait_paused(ctx, ThreadId);
1040
if(ctx->isTestStopped())
1043
if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
1044
g_err << "Scan updated table failed" << endl;
1048
wait_paused(ctx, ThreadId);
1050
if(ctx->isTestStopped())
1053
if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
1054
g_err << "Clear table failed" << endl;
1062
runUniqueNullTransactions(NDBT_Context* ctx, NDBT_Step* step){
1063
Ndb* pNdb = GETNDB(step);
1065
bool logged = ctx->getProperty("LoggedIndexes", 1);
1066
bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
1067
NdbConnection * pTrans = 0;
1069
const NdbDictionary::Table* pTab = ctx->getTab();
1071
char nullIndex[255];
1072
BaseString::snprintf(nullIndex, 255, "IDC_PK_%s_NULL", pTab->getName());
1074
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "
1075
<< pkIdxName << " (";
1077
ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "
1078
<< pkIdxName << " (";
1080
NdbDictionary::Index pIdx(pkIdxName);
1081
pIdx.setTable(pTab->getName());
1083
pIdx.setType(NdbDictionary::Index::OrderedIndex);
1085
pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
1086
pIdx.setStoredIndex(logged);
1088
for (c = 0; c< pTab->getNoOfColumns(); c++){
1089
const NdbDictionary::Column * col = pTab->getColumn(c);
1090
if(col->getPrimaryKey()){
1091
pIdx.addIndexColumn(col->getName());
1092
ndbout << col->getName() <<" ";
1097
for (c = 0; c< pTab->getNoOfColumns(); c++){
1098
const NdbDictionary::Column * col = pTab->getColumn(c);
1099
if(col->getNullable()){
1100
pIdx.addIndexColumn(col->getName());
1101
ndbout << col->getName() <<" ";
1109
ndbout << endl << "No nullable column found -> NDBT_FAILED" << endl;
1113
if (pNdb->getDictionary()->createIndex(pIdx) != 0){
1114
ndbout << "FAILED!" << endl;
1115
const NdbError err = pNdb->getDictionary()->getNdbError();
1120
int result = NDBT_OK;
1122
HugoTransactions hugoTrans(*ctx->getTab());
1123
const int batchSize = ctx->getProperty("BatchSize", 50);
1124
int loops = ctx->getNumLoops();
1125
int rows = ctx->getNumRecords();
1126
while (loops-- > 0 && ctx->isTestStopped() == false) {
1127
if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
1128
g_err << "Updated table failed" << endl;
1129
result = NDBT_FAILED;
1134
if(ctx->isTestStopped()){
1139
while(ctx->getNoOfRunningSteps() > 1){
1140
NdbSleep_MilliSleep(100);
1143
result = NDBT_FAILED;
1144
pTrans = pNdb->startTransaction();
1145
NdbScanOperation * sOp;
1148
if(!pTrans) goto done;
1149
sOp = pTrans->getNdbScanOperation(pTab->getName());
1151
if(sOp->readTuples(NdbScanOperation::LM_Exclusive)) goto done;
1152
if(pTrans->execute(NoCommit) == -1) goto done;
1153
while((eof = sOp->nextResult(true)) == 0){
1155
NdbOperation * uOp = sOp->updateCurrentTuple();
1156
if(uOp == 0) goto done;
1157
uOp->setValue(colId, 0);
1158
} while((eof = sOp->nextResult(false)) == 0);
1159
eof = pTrans->execute(Commit);
1160
if(eof == -1) goto done;
1164
if(pTrans) pNdb->closeTransaction(pTrans);
1165
pNdb->getDictionary()->dropIndex(nullIndex, pTab->getName());
1169
int runLQHKEYREF(NDBT_Context* ctx, NDBT_Step* step){
1170
int result = NDBT_OK;
1171
int loops = ctx->getNumLoops() * 100;
1172
NdbRestarter restarter;
1174
myRandom48Init(NdbTick_CurrentMillisecond());
1177
int val = DumpStateOrd::DihMinTimeBetweenLCP;
1178
if(restarter.dumpStateAllNodes(&val, 1) != 0){
1179
g_err << "Failed to dump DihMinTimeBetweenLCP" << endl;
1184
for(int i = 0; i<loops && !ctx->isTestStopped(); i++){
1185
int randomId = myRandom48(restarter.getNumDbNodes());
1186
int nodeId = restarter.getDbNodeId(randomId);
1188
const Uint32 error = 5031 + (i % 3);
1190
if(restarter.insertErrorInNode(nodeId, error) != 0){
1191
g_err << "Failed to error insert( " << error << ") in node "
1202
runBug21384(NDBT_Context* ctx, NDBT_Step* step)
1204
Ndb* pNdb = GETNDB(step);
1205
HugoTransactions hugoTrans(*ctx->getTab());
1206
NdbRestarter restarter;
1208
int loops = ctx->getNumLoops();
1209
const int rows = ctx->getNumRecords();
1210
const int batchsize = ctx->getProperty("BatchSize", 50);
1214
if(restarter.insertErrorInAllNodes(8037) != 0)
1216
g_err << "Failed to error insert(8037)" << endl;
1220
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) == 0)
1222
g_err << "Index succeded (it should have failed" << endl;
1226
if(restarter.insertErrorInAllNodes(0) != 0)
1228
g_err << "Failed to error insert(0)" << endl;
1232
if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){
1233
g_err << "Index read failed" << endl;
1242
runBug25059(NDBT_Context* ctx, NDBT_Step* step)
1244
Ndb* pNdb = GETNDB(step);
1245
NdbDictionary::Dictionary * dict = pNdb->getDictionary();
1246
const NdbDictionary::Index * idx = dict->getIndex(pkIdxName,
1247
ctx->getTab()->getName());
1249
HugoOperations ops(*ctx->getTab(), idx);
1252
int loops = ctx->getNumLoops();
1253
const int rows = ctx->getNumRecords();
1255
while (res == NDBT_OK && loops--)
1257
ops.startTransaction(pNdb);
1258
ops.pkReadRecord(pNdb, 10 + rand() % rows, rows);
1260
if (tmp = ops.execute_Commit(pNdb, AO_IgnoreError))
1265
if (ops.getTransaction()->getNdbError().code == 4012)
1268
ops.closeTransaction(pNdb);
1271
loops = ctx->getNumLoops();
1272
while (res == NDBT_OK && loops--)
1274
ops.startTransaction(pNdb);
1275
ops.pkUpdateRecord(pNdb, 10 + rand() % rows, rows);
1283
arg = AO_IgnoreError;
1284
ndbout_c("ignore error");
1287
if (tmp = ops.execute_Commit(pNdb, (AbortOption)arg))
1292
if (ops.getTransaction()->getNdbError().code == 4012)
1295
ops.closeTransaction(pNdb);
1301
int tcSaveINDX_test(NDBT_Context* ctx, NDBT_Step* step, int inject_err)
1303
int result= NDBT_OK;
1304
Ndb* pNdb = GETNDB(step);
1305
NdbDictionary::Dictionary * dict = pNdb->getDictionary();
1306
const NdbDictionary::Index * idx = dict->getIndex(pkIdxName,
1307
ctx->getTab()->getName());
1309
HugoOperations ops(*ctx->getTab(), idx);
1311
g_err << "Using INDEX: " << pkIdxName << endl;
1313
NdbRestarter restarter;
1315
int loops = ctx->getNumLoops();
1316
const int rows = ctx->getNumRecords();
1317
const int batchsize = ctx->getProperty("BatchSize", 1);
1319
for(int bs=1; bs < loops; bs++)
1324
g_err << "BS " << bs << " LOOP #" << c << endl;
1326
g_err << "inserting error on op#" << c << endl;
1328
CHECK(ops.startTransaction(pNdb) == 0);
1329
for(int i=1;i<=c;i++)
1333
if(restarter.insertErrorInAllNodes(inject_err)!=0)
1335
g_err << "**** FAILED to insert error" << endl;
1336
result= NDBT_FAILED;
1340
CHECK(ops.indexReadRecords(pNdb, pkIdxName, i,false,1) == 0);
1345
if(ops.execute_NoCommit(pNdb, AO_IgnoreError)!=NDBT_OK)
1347
g_err << "**** executeNoCommit should have succeeded" << endl;
1348
result= NDBT_FAILED;
1353
if(ops.execute_NoCommit(pNdb, AO_IgnoreError)!=289)
1355
g_err << "**** executeNoCommit should have failed with 289"
1357
result= NDBT_FAILED;
1359
g_err << "NdbError.code= " <<
1360
ops.getTransaction()->getNdbError().code << endl;
1366
CHECK(ops.closeTransaction(pNdb) == 0);
1368
if(restarter.insertErrorInAllNodes(0) != 0)
1370
g_err << "**** Failed to error insert(0)" << endl;
1374
CHECK(ops.startTransaction(pNdb) == 0);
1375
if (ops.indexReadRecords(pNdb, pkIdxName,0,0,rows) != 0){
1376
g_err << "**** Index read failed" << endl;
1379
CHECK(ops.closeTransaction(pNdb) == 0);
1387
runBug28804(NDBT_Context* ctx, NDBT_Step* step)
1389
return tcSaveINDX_test(ctx, step, 8052);
1393
runBug28804_ATTRINFO(NDBT_Context* ctx, NDBT_Step* step)
1395
return tcSaveINDX_test(ctx, step, 8051);
1398
NDBT_TESTSUITE(testIndex);
1399
TESTCASE("CreateAll",
1400
"Test that we can create all various indexes on each table\n"
1401
"Then drop the indexes\n"){
1402
INITIALIZER(runCreateIndexes);
1404
TESTCASE("CreateAll_O",
1405
"Test that we can create all various indexes on each table\n"
1406
"Then drop the indexes\n"){
1407
TC_PROPERTY("OrderedIndex", 1);
1408
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1409
INITIALIZER(runCreateIndexes);
1411
TESTCASE("InsertDeleteGentle",
1412
"Create one index, then perform insert and delete in the table\n"
1413
"loop number of times. Use batch size 1."){
1414
TC_PROPERTY("BatchSize", 1);
1415
INITIALIZER(runInsertDelete);
1416
FINALIZER(runClearTable);
1418
TESTCASE("InsertDeleteGentle_O",
1419
"Create one index, then perform insert and delete in the table\n"
1420
"loop number of times. Use batch size 1."){
1421
TC_PROPERTY("OrderedIndex", 1);
1422
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1423
TC_PROPERTY("BatchSize", 1);
1424
INITIALIZER(runInsertDelete);
1425
FINALIZER(runClearTable);
1427
TESTCASE("InsertDelete",
1428
"Create one index, then perform insert and delete in the table\n"
1429
"loop number of times. Use batchsize 512 to stress db more"){
1430
TC_PROPERTY("BatchSize", 512);
1431
INITIALIZER(runInsertDelete);
1432
FINALIZER(runClearTable);
1435
TESTCASE("InsertDelete_O",
1436
"Create one index, then perform insert and delete in the table\n"
1437
"loop number of times. Use batchsize 512 to stress db more"){
1438
TC_PROPERTY("OrderedIndex", 1);
1439
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1440
TC_PROPERTY("BatchSize", 512);
1441
INITIALIZER(runInsertDelete);
1442
FINALIZER(runClearTable);
1445
TESTCASE("CreateLoadDropGentle",
1446
"Try to create, drop and load various indexes \n"
1447
"on table loop number of times.Usa batch size 1.\n"){
1448
TC_PROPERTY("BatchSize", 1);
1449
INITIALIZER(runCreateLoadDropIndex);
1451
TESTCASE("CreateLoadDropGentle_O",
1452
"Try to create, drop and load various indexes \n"
1453
"on table loop number of times.Usa batch size 1.\n"){
1454
TC_PROPERTY("OrderedIndex", 1);
1455
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1456
TC_PROPERTY("BatchSize", 1);
1457
INITIALIZER(runCreateLoadDropIndex);
1459
TESTCASE("CreateLoadDrop",
1460
"Try to create, drop and load various indexes \n"
1461
"on table loop number of times. Use batchsize 512 to stress db more\n"){
1462
TC_PROPERTY("BatchSize", 512);
1463
INITIALIZER(runCreateLoadDropIndex);
1465
TESTCASE("CreateLoadDrop_O",
1466
"Try to create, drop and load various indexes \n"
1467
"on table loop number of times. Use batchsize 512 to stress db more\n"){
1468
TC_PROPERTY("OrderedIndex", 1);
1469
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1470
TC_PROPERTY("BatchSize", 512);
1471
INITIALIZER(runCreateLoadDropIndex);
1474
"Test that indexes are correctly maintained during node fail and node restart"){
1475
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1476
TC_PROPERTY("PauseThreads", 2);
1477
INITIALIZER(runClearTable);
1478
INITIALIZER(createRandomIndex);
1479
INITIALIZER(runLoadTable);
1481
STEP(runTransactions1);
1482
STEP(runTransactions1);
1483
FINALIZER(runVerifyIndex);
1484
FINALIZER(createRandomIndex_Drop);
1485
FINALIZER(runClearTable);
1488
"Test that indexes are correctly maintained during node fail and node restart"){
1489
TC_PROPERTY("OrderedIndex", 1);
1490
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1491
TC_PROPERTY("PauseThreads", 2);
1492
INITIALIZER(runClearTable);
1493
INITIALIZER(createRandomIndex);
1494
INITIALIZER(runLoadTable);
1496
STEP(runTransactions1);
1497
STEP(runTransactions1);
1498
FINALIZER(runVerifyIndex);
1499
FINALIZER(createRandomIndex_Drop);
1500
FINALIZER(runClearTable);
1503
"Test that indexes are correctly maintained during node fail and node restart"){
1504
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1505
TC_PROPERTY("PauseThreads", 2);
1506
INITIALIZER(runClearTable);
1507
INITIALIZER(createRandomIndex);
1508
INITIALIZER(createPkIndex);
1509
INITIALIZER(runLoadTable);
1511
STEP(runTransactions2);
1512
STEP(runTransactions2);
1513
FINALIZER(runVerifyIndex);
1514
FINALIZER(createRandomIndex_Drop);
1515
FINALIZER(createPkIndex_Drop);
1516
FINALIZER(runClearTable);
1519
"Test that indexes are correctly maintained during node fail and node restart"){
1520
TC_PROPERTY("OrderedIndex", 1);
1521
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1522
TC_PROPERTY("PauseThreads", 1);
1523
INITIALIZER(runClearTable);
1524
INITIALIZER(createRandomIndex);
1525
INITIALIZER(createPkIndex);
1526
INITIALIZER(runLoadTable);
1528
STEP(runTransactions2);
1529
//STEP(runTransactions2);
1530
FINALIZER(runVerifyIndex);
1531
FINALIZER(createRandomIndex_Drop);
1532
FINALIZER(createPkIndex_Drop);
1533
FINALIZER(runClearTable);
1536
"Test that indexes are correctly maintained during node fail and node restart"){
1537
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1538
TC_PROPERTY("PauseThreads", 2);
1539
INITIALIZER(runClearTable);
1540
INITIALIZER(createRandomIndex);
1541
INITIALIZER(createPkIndex);
1543
STEP(runTransactions3);
1544
STEP(runVerifyIndex);
1545
FINALIZER(runVerifyIndex);
1546
FINALIZER(createPkIndex_Drop);
1547
FINALIZER(createRandomIndex_Drop);
1548
FINALIZER(runClearTable);
1551
"Test that indexes are correctly maintained during node fail and node restart"){
1552
TC_PROPERTY("OrderedIndex", 1);
1553
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1554
TC_PROPERTY("PauseThreads", 2);
1555
INITIALIZER(runClearTable);
1556
INITIALIZER(createRandomIndex);
1557
INITIALIZER(createPkIndex);
1559
STEP(runTransactions3);
1560
STEP(runVerifyIndex);
1561
FINALIZER(runVerifyIndex);
1562
FINALIZER(createPkIndex_Drop);
1563
FINALIZER(createRandomIndex_Drop);
1564
FINALIZER(runClearTable);
1567
"Test that indexes are correctly maintained during node fail and node restart"){
1568
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1569
TC_PROPERTY("PauseThreads", 4);
1570
INITIALIZER(runClearTable);
1571
INITIALIZER(createRandomIndex);
1572
INITIALIZER(createPkIndex);
1573
INITIALIZER(runLoadTable);
1575
STEP(runTransactions1);
1576
STEP(runTransactions1);
1577
STEP(runTransactions2);
1578
STEP(runTransactions2);
1579
FINALIZER(runVerifyIndex);
1580
FINALIZER(createRandomIndex_Drop);
1581
FINALIZER(createPkIndex_Drop);
1582
FINALIZER(runClearTable);
1585
"Test that indexes are correctly maintained during node fail and node restart"){
1586
TC_PROPERTY("OrderedIndex", 1);
1587
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1588
TC_PROPERTY("PauseThreads", 4);
1589
INITIALIZER(runClearTable);
1590
INITIALIZER(createRandomIndex);
1591
INITIALIZER(createPkIndex);
1592
INITIALIZER(runLoadTable);
1594
STEP(runTransactions1);
1595
STEP(runTransactions1);
1596
STEP(runTransactions2);
1597
STEP(runTransactions2);
1598
FINALIZER(runVerifyIndex);
1599
FINALIZER(createRandomIndex_Drop);
1600
FINALIZER(createPkIndex_Drop);
1601
FINALIZER(runClearTable);
1604
"Test that indexes are correctly maintained during node fail and node restart"){
1605
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1606
TC_PROPERTY("BatchSize", (unsigned)1);
1607
INITIALIZER(runClearTable);
1608
INITIALIZER(createRandomIndex);
1609
INITIALIZER(createPkIndex);
1610
INITIALIZER(runLoadTable);
1612
STEP(runTransactions1);
1613
STEP(runTransactions1);
1614
STEP(runTransactions2);
1615
STEP(runTransactions2);
1616
FINALIZER(runVerifyIndex);
1617
FINALIZER(createRandomIndex_Drop);
1618
FINALIZER(createPkIndex_Drop);
1619
FINALIZER(runClearTable);
1622
"Test that indexes are correctly maintained during node fail and node restart"){
1623
TC_PROPERTY("OrderedIndex", 1);
1624
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1625
TC_PROPERTY("BatchSize", (unsigned)1);
1626
INITIALIZER(runClearTable);
1627
INITIALIZER(createRandomIndex);
1628
INITIALIZER(createPkIndex);
1629
INITIALIZER(runLoadTable);
1631
STEP(runTransactions1);
1632
STEP(runTransactions1);
1633
STEP(runTransactions2);
1634
STEP(runTransactions2);
1635
FINALIZER(runVerifyIndex);
1636
FINALIZER(createRandomIndex_Drop);
1637
FINALIZER(createPkIndex_Drop);
1638
FINALIZER(runClearTable);
1641
"Test that indexes are correctly maintained during SR"){
1642
INITIALIZER(runClearTable);
1643
INITIALIZER(createRandomIndex);
1644
INITIALIZER(createPkIndex);
1645
STEP(runSystemRestart1);
1646
FINALIZER(runVerifyIndex);
1647
FINALIZER(createPkIndex_Drop);
1648
FINALIZER(createRandomIndex_Drop);
1649
FINALIZER(runClearTable);
1651
TESTCASE("MixedTransaction",
1652
"Test mixing of index and normal operations"){
1653
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1654
INITIALIZER(runClearTable);
1655
INITIALIZER(createPkIndex);
1656
INITIALIZER(runLoadTable);
1658
FINALIZER(createPkIndex_Drop);
1659
FINALIZER(runClearTable);
1662
"Test that indexes are correctly maintained during SR"){
1663
TC_PROPERTY("OrderedIndex", 1);
1664
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1665
INITIALIZER(runClearTable);
1666
INITIALIZER(createRandomIndex);
1667
INITIALIZER(createPkIndex);
1668
STEP(runSystemRestart1);
1669
FINALIZER(runVerifyIndex);
1670
FINALIZER(createPkIndex_Drop);
1671
FINALIZER(createRandomIndex_Drop);
1672
FINALIZER(runClearTable);
1674
TESTCASE("BuildDuring",
1675
"Test that index build when running transactions work"){
1676
TC_PROPERTY("OrderedIndex", (unsigned)0);
1677
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1678
TC_PROPERTY("Threads", 1); // # runTransactions4
1679
INITIALIZER(runClearTable);
1680
STEP(runBuildDuring);
1681
STEP(runTransactions4);
1682
//STEP(runTransactions4);
1683
FINALIZER(runClearTable);
1685
TESTCASE("BuildDuring_O",
1686
"Test that index build when running transactions work"){
1687
TC_PROPERTY("OrderedIndex", (unsigned)1);
1688
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1689
TC_PROPERTY("Threads", 1); // # runTransactions4
1690
INITIALIZER(runClearTable);
1691
STEP(runBuildDuring);
1692
STEP(runTransactions4);
1693
//STEP(runTransactions4);
1694
FINALIZER(runClearTable);
1696
TESTCASE("UniqueNull",
1697
"Test that unique indexes and nulls"){
1698
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1699
INITIALIZER(runClearTable);
1700
INITIALIZER(createRandomIndex);
1701
INITIALIZER(createPkIndex);
1702
INITIALIZER(runLoadTable);
1703
STEP(runTransactions1);
1704
STEP(runTransactions2);
1705
STEP(runUniqueNullTransactions);
1706
FINALIZER(runVerifyIndex);
1707
FINALIZER(createRandomIndex_Drop);
1708
FINALIZER(createPkIndex_Drop);
1709
FINALIZER(runClearTable);
1711
TESTCASE("Bug21384",
1712
"Test that unique indexes and nulls"){
1713
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1714
INITIALIZER(runClearTable);
1715
INITIALIZER(createPkIndex);
1716
INITIALIZER(runLoadTable);
1718
FINALIZER(createPkIndex_Drop);
1719
FINALIZER(runClearTable);
1721
TESTCASE("Bug25059",
1722
"Test that unique indexes and nulls"){
1723
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1724
INITIALIZER(createPkIndex);
1725
INITIALIZER(runLoadTable);
1727
FINALIZER(createPkIndex_Drop);
1729
TESTCASE("Bug28804",
1730
"Test behaviour on out of TransactionBufferMemory for index lookup"){
1731
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1732
INITIALIZER(runClearTable);
1733
INITIALIZER(createPkIndex);
1734
INITIALIZER(runLoadTable);
1736
FINALIZER(createPkIndex_Drop);
1737
FINALIZER(runClearTable);
1739
TESTCASE("Bug28804_ATTRINFO",
1740
"Test behaviour on out of TransactionBufferMemory for index lookup"
1741
" in saveINDXATTRINFO"){
1742
TC_PROPERTY("LoggedIndexes", (unsigned)0);
1743
INITIALIZER(runClearTable);
1744
INITIALIZER(createPkIndex);
1745
INITIALIZER(runLoadTable);
1746
STEP(runBug28804_ATTRINFO);
1747
FINALIZER(createPkIndex_Drop);
1748
FINALIZER(runClearTable);
1750
NDBT_TESTSUITE_END(testIndex);
1752
int main(int argc, const char** argv){
1754
return testIndex.execute(argc, argv);
1757
template class Vector<Attrib*>;