~vlad-lesin/percona-server/mysql-5.0.33-original

« back to all changes in this revision

Viewing changes to ndb/test/ndbapi/testIndex.cpp

  • Committer: Vlad Lesin
  • Date: 2012-07-31 09:21:34 UTC
  • Revision ID: vladislav.lesin@percona.com-20120731092134-zfodx022b7992wsi
VirginĀ 5.0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2003 MySQL AB
 
2
 
 
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; either version 2 of the License, or
 
6
   (at your option) any later version.
 
7
 
 
8
   This program is distributed in the hope that it will be useful,
 
9
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
   GNU General Public License for more details.
 
12
 
 
13
   You should have received a copy of the GNU General Public License
 
14
   along with this program; if not, write to the Free Software
 
15
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
16
 
 
17
#include <NDBT.hpp>
 
18
#include <NDBT_Test.hpp>
 
19
#include <HugoTransactions.hpp>
 
20
#include <UtilTransactions.hpp>
 
21
#include <NdbRestarter.hpp>
 
22
#include <NdbRestarts.hpp>
 
23
#include <Vector.hpp>
 
24
#include <signaldata/DumpStateOrd.hpp>
 
25
 
 
26
#define CHECK(b) if (!(b)) { \
 
27
  g_err << "ERR: "<< step->getName() \
 
28
         << " failed on line " << __LINE__ << endl; \
 
29
  result = NDBT_FAILED; break;\
 
30
 
31
 
 
32
 
 
33
struct Attrib {
 
34
  bool indexCreated;
 
35
  int numAttribs;
 
36
  int attribs[1024];
 
37
  Attrib(){
 
38
    numAttribs = 0;
 
39
    indexCreated = false;
 
40
  }
 
41
};
 
42
class AttribList {
 
43
public:
 
44
  AttribList(){};
 
45
  ~AttribList(){
 
46
    for(size_t i = 0; i < attriblist.size(); i++){      
 
47
      delete attriblist[i];
 
48
    }
 
49
  };
 
50
  void buildAttribList(const NdbDictionary::Table* pTab); 
 
51
  Vector<Attrib*> attriblist;
 
52
};
 
53
 
 
54
void AttribList::buildAttribList(const NdbDictionary::Table* pTab){
 
55
  attriblist.clear();
 
56
 
 
57
  Attrib* attr;
 
58
  // Build attrib definitions that describes which attributes to build index
 
59
  // Try to build strange combinations, not just "all" or all PK's
 
60
 
 
61
  int i;
 
62
 
 
63
  for(i = 1; i <= pTab->getNoOfColumns(); i++){
 
64
    attr = new Attrib;
 
65
    attr->numAttribs = i;
 
66
    for(int a = 0; a<i; a++)
 
67
      attr->attribs[a] = a;
 
68
    attriblist.push_back(attr);
 
69
  }
 
70
  int b = 0;
 
71
  for(i = pTab->getNoOfColumns()-1; i > 0; i--){
 
72
    attr = new Attrib;
 
73
    attr->numAttribs = i;
 
74
    b++;
 
75
    for(int a = 0; a<i; a++)
 
76
      attr->attribs[a] = a+b;
 
77
    attriblist.push_back(attr);
 
78
  }
 
79
  for(i = pTab->getNoOfColumns(); i > 0;  i--){
 
80
    attr = new Attrib;
 
81
    attr->numAttribs = pTab->getNoOfColumns() - i;
 
82
    for(int a = 0; a<pTab->getNoOfColumns() - i; a++)
 
83
      attr->attribs[a] = pTab->getNoOfColumns()-a-1;
 
84
    attriblist.push_back(attr); 
 
85
  }  
 
86
  for(i = 1; i < pTab->getNoOfColumns(); i++){
 
87
    attr = new Attrib;
 
88
    attr->numAttribs = pTab->getNoOfColumns() - i;
 
89
    for(int a = 0; a<pTab->getNoOfColumns() - i; a++)
 
90
      attr->attribs[a] = pTab->getNoOfColumns()-a-1;
 
91
    attriblist.push_back(attr); 
 
92
  }  
 
93
  for(i = 1; i < pTab->getNoOfColumns(); i++){
 
94
    attr = new Attrib;
 
95
    attr->numAttribs = 2;
 
96
    for(int a = 0; a<2; a++){
 
97
      attr->attribs[a] = i%pTab->getNoOfColumns();
 
98
    }
 
99
    attriblist.push_back(attr);
 
100
  }
 
101
 
 
102
  // Last 
 
103
  attr = new Attrib;
 
104
  attr->numAttribs = 1;
 
105
  attr->attribs[0] = pTab->getNoOfColumns()-1;
 
106
  attriblist.push_back(attr);
 
107
 
 
108
  // Last and first
 
109
  attr = new Attrib;
 
110
  attr->numAttribs = 2;
 
111
  attr->attribs[0] = pTab->getNoOfColumns()-1;
 
112
  attr->attribs[1] = 0;
 
113
  attriblist.push_back(attr); 
 
114
 
 
115
  // First and last
 
116
  attr = new Attrib;
 
117
  attr->numAttribs = 2;
 
118
  attr->attribs[0] = 0;
 
119
  attr->attribs[1] = pTab->getNoOfColumns()-1;
 
120
  attriblist.push_back(attr);  
 
121
 
 
122
#if 0
 
123
  for(size_t i = 0; i < attriblist.size(); i++){
 
124
 
 
125
    ndbout << attriblist[i]->numAttribs << ": " ;
 
126
    for(int a = 0; a < attriblist[i]->numAttribs; a++)
 
127
      ndbout << attriblist[i]->attribs[a] << ", ";
 
128
    ndbout << endl;
 
129
  }
 
130
#endif
 
131
 
 
132
}
 
133
 
 
134
char idxName[255];
 
135
char pkIdxName[255];
 
136
 
 
137
static const int SKIP_INDEX = 99;
 
138
 
 
139
int create_index(NDBT_Context* ctx, int indxNum, 
 
140
                 const NdbDictionary::Table* pTab, 
 
141
                 Ndb* pNdb, Attrib* attr, bool logged){
 
142
  bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
 
143
  int result  = NDBT_OK;
 
144
 
 
145
  HugoCalculator calc(*pTab);
 
146
 
 
147
  if (attr->numAttribs == 1 && 
 
148
      calc.isUpdateCol(attr->attribs[0]) == true){
 
149
    // Don't create index for the Hugo update column
 
150
    // since it's not unique
 
151
    return SKIP_INDEX;
 
152
  }
 
153
 
 
154
  // Create index    
 
155
  BaseString::snprintf(idxName, 255, "IDC%d", indxNum);
 
156
  if (orderedIndex)
 
157
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "<<idxName << " (";
 
158
  else
 
159
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "<<idxName << " (";
 
160
  ndbout << flush;
 
161
  NdbDictionary::Index pIdx(idxName);
 
162
  pIdx.setTable(pTab->getName());
 
163
  if (orderedIndex)
 
164
    pIdx.setType(NdbDictionary::Index::OrderedIndex);
 
165
  else
 
166
    pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
 
167
  for (int c = 0; c< attr->numAttribs; c++){
 
168
    int attrNo = attr->attribs[c];
 
169
    pIdx.addIndexColumn(pTab->getColumn(attrNo)->getName());
 
170
    ndbout << pTab->getColumn(attrNo)->getName()<<" ";
 
171
  }
 
172
  
 
173
  pIdx.setStoredIndex(logged);
 
174
  ndbout << ") ";
 
175
  if (pNdb->getDictionary()->createIndex(pIdx) != 0){
 
176
    attr->indexCreated = false;
 
177
    ndbout << "FAILED!" << endl;
 
178
    const NdbError err = pNdb->getDictionary()->getNdbError();
 
179
    ERR(err);
 
180
    if(err.classification == NdbError::ApplicationError)
 
181
      return SKIP_INDEX;
 
182
    
 
183
    return NDBT_FAILED;
 
184
  } else {
 
185
    ndbout << "OK!" << endl;
 
186
    attr->indexCreated = true;
 
187
  }
 
188
  return result;
 
189
}
 
190
 
 
191
 
 
192
int drop_index(int indxNum, Ndb* pNdb, 
 
193
               const NdbDictionary::Table* pTab, Attrib* attr){
 
194
  int result = NDBT_OK;
 
195
 
 
196
  if (attr->indexCreated == false)
 
197
    return NDBT_OK;     
 
198
 
 
199
  BaseString::snprintf(idxName, 255, "IDC%d", indxNum);
 
200
  
 
201
  // Drop index
 
202
  ndbout << "Dropping index "<<idxName<<"(" << pTab->getName() << ") ";
 
203
  if (pNdb->getDictionary()->dropIndex(idxName, pTab->getName()) != 0){
 
204
    ndbout << "FAILED!" << endl;
 
205
    ERR(pNdb->getDictionary()->getNdbError());
 
206
    result = NDBT_FAILED;
 
207
  } else {
 
208
    ndbout << "OK!" << endl;
 
209
  }     
 
210
  return result;
 
211
}
 
212
 
 
213
int runCreateIndexes(NDBT_Context* ctx, NDBT_Step* step){
 
214
  int loops = ctx->getNumLoops();
 
215
  int l = 0;
 
216
  const NdbDictionary::Table* pTab = ctx->getTab();
 
217
  Ndb* pNdb = GETNDB(step);
 
218
  int result = NDBT_OK;
 
219
  // NOTE If we need to test creating both logged and non logged indexes
 
220
  // this should be divided into two testcases
 
221
  // The paramater logged should then be specified 
 
222
  // as a TC_PROPERTY. ex TC_PROPERTY("LoggedIndexes", 1);
 
223
  // and read into the test step like
 
224
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
225
 
 
226
  AttribList attrList;
 
227
  attrList.buildAttribList(pTab);
 
228
 
 
229
 
 
230
  while (l < loops && result == NDBT_OK){
 
231
    unsigned int i;
 
232
    for (i = 0; i < attrList.attriblist.size(); i++){
 
233
      
 
234
      // Try to create index
 
235
      if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
 
236
        result = NDBT_FAILED;      
 
237
    }
 
238
    
 
239
    // Now drop all indexes that where created
 
240
    for (i = 0; i < attrList.attriblist.size(); i++){
 
241
            
 
242
      // Try to drop index
 
243
      if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
 
244
        result = NDBT_FAILED;                        
 
245
    }
 
246
    
 
247
    l++;
 
248
  }
 
249
  
 
250
  return result;
 
251
}
 
252
 
 
253
int createRandomIndex(NDBT_Context* ctx, NDBT_Step* step){
 
254
  const NdbDictionary::Table* pTab = ctx->getTab();
 
255
  Ndb* pNdb = GETNDB(step);
 
256
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
257
 
 
258
  AttribList attrList;
 
259
  attrList.buildAttribList(pTab);
 
260
 
 
261
  int retries = 100;
 
262
  while(retries > 0){
 
263
    const Uint32 i = rand() % attrList.attriblist.size();
 
264
    int res = create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], 
 
265
                           logged);
 
266
    if (res == SKIP_INDEX){
 
267
      retries--;
 
268
      continue;
 
269
    }
 
270
 
 
271
    if (res == NDBT_FAILED){
 
272
      return NDBT_FAILED;
 
273
    }
 
274
    
 
275
    ctx->setProperty("createRandomIndex", i);
 
276
    // Now drop all indexes that where created
 
277
    
 
278
    return NDBT_OK;
 
279
  }
 
280
  
 
281
  return NDBT_FAILED;
 
282
}
 
283
 
 
284
int createRandomIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
 
285
  Ndb* pNdb = GETNDB(step);
 
286
 
 
287
  Uint32 i = ctx->getProperty("createRandomIndex");
 
288
  
 
289
  BaseString::snprintf(idxName, 255, "IDC%d", i);
 
290
  
 
291
  // Drop index
 
292
  ndbout << "Dropping index " << idxName << " ";
 
293
  if (pNdb->getDictionary()->dropIndex(idxName, 
 
294
                                       ctx->getTab()->getName()) != 0){
 
295
    ndbout << "FAILED!" << endl;
 
296
    ERR(pNdb->getDictionary()->getNdbError());
 
297
    return NDBT_FAILED;
 
298
  } else {
 
299
    ndbout << "OK!" << endl;
 
300
  }     
 
301
  
 
302
  return NDBT_OK;
 
303
}
 
304
 
 
305
int createPkIndex(NDBT_Context* ctx, NDBT_Step* step){
 
306
  bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
 
307
 
 
308
  const NdbDictionary::Table* pTab = ctx->getTab();
 
309
  Ndb* pNdb = GETNDB(step);
 
310
 
 
311
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
312
 
 
313
  // Create index    
 
314
  BaseString::snprintf(pkIdxName, 255, "IDC_PK_%s", pTab->getName());
 
315
  if (orderedIndex)
 
316
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "
 
317
           << pkIdxName << " (";
 
318
  else
 
319
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "
 
320
           << pkIdxName << " (";
 
321
 
 
322
  NdbDictionary::Index pIdx(pkIdxName);
 
323
  pIdx.setTable(pTab->getName());
 
324
  if (orderedIndex)
 
325
    pIdx.setType(NdbDictionary::Index::OrderedIndex);
 
326
  else
 
327
    pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
 
328
  for (int c = 0; c< pTab->getNoOfColumns(); c++){
 
329
    const NdbDictionary::Column * col = pTab->getColumn(c);
 
330
    if(col->getPrimaryKey()){
 
331
      pIdx.addIndexColumn(col->getName());
 
332
      ndbout << col->getName() <<" ";
 
333
    }
 
334
  }
 
335
  
 
336
  pIdx.setStoredIndex(logged);
 
337
  ndbout << ") ";
 
338
  if (pNdb->getDictionary()->createIndex(pIdx) != 0){
 
339
    ndbout << "FAILED!" << endl;
 
340
    const NdbError err = pNdb->getDictionary()->getNdbError();
 
341
    ERR(err);
 
342
    return NDBT_FAILED;
 
343
  }
 
344
 
 
345
  ndbout << "OK!" << endl;
 
346
  return NDBT_OK;
 
347
}
 
348
 
 
349
int createPkIndex_Drop(NDBT_Context* ctx, NDBT_Step* step){
 
350
  const NdbDictionary::Table* pTab = ctx->getTab();
 
351
  Ndb* pNdb = GETNDB(step);
 
352
 
 
353
  // Drop index
 
354
  ndbout << "Dropping index " << pkIdxName << " ";
 
355
  if (pNdb->getDictionary()->dropIndex(pkIdxName, 
 
356
                                       pTab->getName()) != 0){
 
357
    ndbout << "FAILED!" << endl;
 
358
    ERR(pNdb->getDictionary()->getNdbError());
 
359
    return NDBT_FAILED;
 
360
  } else {
 
361
    ndbout << "OK!" << endl;
 
362
  }
 
363
  
 
364
  return NDBT_OK;
 
365
}
 
366
 
 
367
int
 
368
runVerifyIndex(NDBT_Context* ctx, NDBT_Step* step){
 
369
  // Verify that data in index match 
 
370
  // table data
 
371
  Ndb* pNdb = GETNDB(step);
 
372
  UtilTransactions utilTrans(*ctx->getTab());
 
373
  const int batchSize = ctx->getProperty("BatchSize", 16);
 
374
  const int parallelism = batchSize > 240 ? 240 : batchSize;
 
375
 
 
376
  do {
 
377
    if (utilTrans.verifyIndex(pNdb, idxName, parallelism, true) != 0){
 
378
      g_err << "Inconsistent index" << endl;
 
379
      return NDBT_FAILED;
 
380
    }
 
381
  } while(ctx->isTestStopped() == false);
 
382
  return NDBT_OK;
 
383
}
 
384
 
 
385
int
 
386
runTransactions1(NDBT_Context* ctx, NDBT_Step* step){
 
387
  // Verify that data in index match 
 
388
  // table data
 
389
  Ndb* pNdb = GETNDB(step);
 
390
  HugoTransactions hugoTrans(*ctx->getTab());
 
391
  const int batchSize = ctx->getProperty("BatchSize", 50);
 
392
 
 
393
  int rows = ctx->getNumRecords();
 
394
  while (ctx->isTestStopped() == false) {
 
395
    if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
 
396
      g_err << "Updated table failed" << endl;
 
397
      return NDBT_FAILED;
 
398
    }    
 
399
 
 
400
    ctx->sync_down("PauseThreads");
 
401
    if(ctx->isTestStopped())
 
402
      break;
 
403
    
 
404
    if (hugoTrans.scanUpdateRecords(pNdb, rows, batchSize) != 0){
 
405
      g_err << "Updated table failed" << endl;
 
406
      return NDBT_FAILED;
 
407
    }    
 
408
    
 
409
    ctx->sync_down("PauseThreads");
 
410
  }
 
411
  return NDBT_OK;
 
412
}
 
413
 
 
414
int
 
415
runTransactions2(NDBT_Context* ctx, NDBT_Step* step){
 
416
  // Verify that data in index match 
 
417
  // table data
 
418
  Ndb* pNdb = GETNDB(step);
 
419
  HugoTransactions hugoTrans(*ctx->getTab());
 
420
  const int batchSize = ctx->getProperty("BatchSize", 50);
 
421
 
 
422
  int rows = ctx->getNumRecords();
 
423
  while (ctx->isTestStopped() == false) {
 
424
#if 1
 
425
    if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
 
426
      g_err << "Index read failed" << endl;
 
427
      return NDBT_FAILED;
 
428
    }
 
429
#endif
 
430
    ctx->sync_down("PauseThreads");
 
431
    if(ctx->isTestStopped())
 
432
      break;
 
433
#if 1
 
434
    if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
 
435
      g_err << "Index update failed" << endl;
 
436
      return NDBT_FAILED;
 
437
    }
 
438
#endif
 
439
    ctx->sync_down("PauseThreads");
 
440
  }
 
441
  return NDBT_OK;
 
442
}
 
443
 
 
444
int
 
445
runTransactions3(NDBT_Context* ctx, NDBT_Step* step){
 
446
  // Verify that data in index match 
 
447
  // table data
 
448
  Ndb* pNdb = GETNDB(step);
 
449
  HugoTransactions hugoTrans(*ctx->getTab());
 
450
  UtilTransactions utilTrans(*ctx->getTab());
 
451
  const int batchSize = ctx->getProperty("BatchSize", 32);
 
452
  const int parallel = batchSize > 240 ? 240 : batchSize;
 
453
 
 
454
  int rows = ctx->getNumRecords();
 
455
  while (ctx->isTestStopped() == false) {
 
456
    if(hugoTrans.loadTable(pNdb, rows, batchSize, false) != 0){
 
457
      g_err << "Load table failed" << endl;
 
458
      return NDBT_FAILED;
 
459
    }
 
460
    ctx->sync_down("PauseThreads");
 
461
    if(ctx->isTestStopped())
 
462
      break;
 
463
 
 
464
    if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
 
465
      g_err << "Updated table failed" << endl;
 
466
      return NDBT_FAILED;
 
467
    }    
 
468
 
 
469
    ctx->sync_down("PauseThreads");
 
470
    if(ctx->isTestStopped())
 
471
      break;
 
472
    
 
473
    if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchSize) != 0){
 
474
      g_err << "Index read failed" << endl;
 
475
      return NDBT_FAILED;
 
476
    }
 
477
    
 
478
    ctx->sync_down("PauseThreads");
 
479
    if(ctx->isTestStopped())
 
480
      break;
 
481
    
 
482
    if (hugoTrans.indexUpdateRecords(pNdb, pkIdxName, rows, batchSize) != 0){
 
483
      g_err << "Index update failed" << endl;
 
484
      return NDBT_FAILED;
 
485
    }
 
486
    
 
487
    ctx->sync_down("PauseThreads");
 
488
    if(ctx->isTestStopped())
 
489
      break;
 
490
 
 
491
    if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
 
492
      g_err << "Scan updated table failed" << endl;
 
493
      return NDBT_FAILED;
 
494
    }
 
495
 
 
496
    ctx->sync_down("PauseThreads");
 
497
    if(ctx->isTestStopped())
 
498
      break;
 
499
 
 
500
    if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
 
501
      g_err << "Clear table failed" << endl;
 
502
      return NDBT_FAILED;
 
503
    }
 
504
 
 
505
    ctx->sync_down("PauseThreads");
 
506
    if(ctx->isTestStopped())
 
507
      break;
 
508
    
 
509
    int count = -1;
 
510
    if(utilTrans.selectCount(pNdb, 64, &count) != 0 || count != 0)
 
511
      return NDBT_FAILED;
 
512
    ctx->sync_down("PauseThreads");
 
513
  }
 
514
  return NDBT_OK;
 
515
}
 
516
 
 
517
int runRestarts(NDBT_Context* ctx, NDBT_Step* step){
 
518
  int result = NDBT_OK;
 
519
  int loops = ctx->getNumLoops();
 
520
  NDBT_TestCase* pCase = ctx->getCase();
 
521
  NdbRestarts restarts;
 
522
  int i = 0;
 
523
  int timeout = 240;
 
524
  int sync_threads = ctx->getProperty("Threads", (unsigned)0);
 
525
 
 
526
  while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
 
527
    if(restarts.executeRestart("RestartRandomNodeAbort", timeout) != 0){
 
528
      g_err << "Failed to executeRestart(" <<pCase->getName() <<")" << endl;
 
529
      result = NDBT_FAILED;
 
530
      break;
 
531
    }    
 
532
    ctx->sync_up_and_wait("PauseThreads", sync_threads);
 
533
    i++;
 
534
  }
 
535
  ctx->stopTest();
 
536
  return result;
 
537
}
 
538
 
 
539
int runCreateLoadDropIndex(NDBT_Context* ctx, NDBT_Step* step){
 
540
  int loops = ctx->getNumLoops();
 
541
  int records = ctx->getNumRecords();
 
542
  int l = 0;
 
543
  const NdbDictionary::Table* pTab = ctx->getTab();
 
544
  Ndb* pNdb = GETNDB(step);
 
545
  int result = NDBT_OK;
 
546
  int batchSize = ctx->getProperty("BatchSize", 1);
 
547
  int parallelism = batchSize > 240? 240: batchSize;
 
548
  ndbout << "batchSize="<<batchSize<<endl;
 
549
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
550
 
 
551
  HugoTransactions hugoTrans(*pTab);
 
552
  UtilTransactions utilTrans(*pTab);
 
553
  AttribList attrList;
 
554
  attrList.buildAttribList(pTab);
 
555
 
 
556
  for (unsigned int i = 0; i < attrList.attriblist.size(); i++){
 
557
        
 
558
    while (l < loops && result == NDBT_OK){
 
559
 
 
560
      if ((l % 2) == 0){
 
561
        // Create index first and then load
 
562
        
 
563
        // Try to create index
 
564
        if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED){
 
565
          result = NDBT_FAILED;      
 
566
        }
 
567
        
 
568
        // Load the table with data
 
569
        ndbout << "Loading data after" << endl;
 
570
        CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
 
571
        
 
572
        
 
573
      } else {
 
574
        // Load table then create index
 
575
        
 
576
        // Load the table with data
 
577
        ndbout << "Loading data before" << endl;
 
578
        CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
 
579
        
 
580
        // Try to create index
 
581
        if (create_index(ctx, i, pTab, pNdb, attrList.attriblist[i], logged) == NDBT_FAILED)
 
582
          result = NDBT_FAILED;      
 
583
        
 
584
      }
 
585
      
 
586
      // Verify that data in index match 
 
587
      // table data
 
588
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
589
      
 
590
      // Do it all...
 
591
      ndbout <<"Doing it all"<<endl;
 
592
      int count;
 
593
      ndbout << "  pkUpdateRecords" << endl;
 
594
      CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
 
595
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
596
      CHECK(hugoTrans.pkUpdateRecords(pNdb, records, batchSize) == 0);
 
597
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
598
      ndbout << "  pkDelRecords half" << endl;
 
599
      CHECK(hugoTrans.pkDelRecords(pNdb, records/2, batchSize) == 0);
 
600
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
601
      ndbout << "  scanUpdateRecords" << endl;
 
602
      CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2, parallelism) == 0);
 
603
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
604
      ndbout << "  clearTable" << endl;
 
605
      CHECK(utilTrans.clearTable(pNdb, records/2, parallelism) == 0);
 
606
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
607
      CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
608
      CHECK(count == 0);
 
609
      ndbout << "  loadTable" << endl;
 
610
      CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
 
611
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
612
      ndbout << "  loadTable again" << endl;
 
613
      CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
 
614
      CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
615
      CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
616
      CHECK(count == records);
 
617
 
 
618
 
 
619
      if ((l % 2) == 0){
 
620
        // Drop index first and then clear
 
621
        
 
622
        // Try to create index
 
623
        if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK){
 
624
          result = NDBT_FAILED;      
 
625
        }
 
626
        
 
627
        // Clear table
 
628
        ndbout << "Clearing table after" << endl;
 
629
        CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
 
630
        
 
631
        
 
632
      } else {
 
633
        // Clear table then drop index
 
634
        
 
635
        //Clear table
 
636
        ndbout << "Clearing table before" << endl;
 
637
        CHECK(hugoTrans.clearTable(pNdb, records, parallelism) == 0);
 
638
        
 
639
        // Try to drop index
 
640
        if (drop_index(i, pNdb, pTab, attrList.attriblist[i]) != NDBT_OK)
 
641
          result = NDBT_FAILED;         
 
642
      }
 
643
      
 
644
      ndbout << "  Done!" << endl;
 
645
      l++;
 
646
    }
 
647
      
 
648
    // Make sure index is dropped
 
649
    drop_index(i, pNdb, pTab, attrList.attriblist[i]);
 
650
 
 
651
  }
 
652
 
 
653
  return result;
 
654
}
 
655
 
 
656
int runInsertDelete(NDBT_Context* ctx, NDBT_Step* step){
 
657
  int loops = ctx->getNumLoops();
 
658
  int records = ctx->getNumRecords();
 
659
  const NdbDictionary::Table* pTab = ctx->getTab();
 
660
  Ndb* pNdb = GETNDB(step);
 
661
  int result = NDBT_OK;
 
662
  int batchSize = ctx->getProperty("BatchSize", 1);
 
663
  int parallelism = batchSize > 240? 240: batchSize;
 
664
  ndbout << "batchSize="<<batchSize<<endl;
 
665
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
666
 
 
667
  HugoTransactions hugoTrans(*pTab);
 
668
  UtilTransactions utilTrans(*pTab);  
 
669
 
 
670
  AttribList attrList;
 
671
  attrList.buildAttribList(pTab);
 
672
 
 
673
  for (unsigned int i = 0; i < attrList.attriblist.size(); i++){
 
674
    
 
675
    Attrib* attr = attrList.attriblist[i]; 
 
676
    // Create index
 
677
    if (create_index(ctx, i, pTab, pNdb, attr, logged) == NDBT_OK){
 
678
      int l = 1;
 
679
      while (l <= loops && result == NDBT_OK){
 
680
  
 
681
        CHECK(hugoTrans.loadTable(pNdb, records, batchSize) == 0);
 
682
        CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
683
        CHECK(utilTrans.clearTable(pNdb, records, parallelism) == 0);
 
684
        CHECK(utilTrans.verifyIndex(pNdb, idxName, parallelism) == 0);
 
685
        l++;        
 
686
      }            
 
687
      
 
688
      // Drop index
 
689
      if (drop_index(i, pNdb, pTab, attr) != NDBT_OK)
 
690
        result = NDBT_FAILED;                        
 
691
    }    
 
692
  }
 
693
  
 
694
  return result;
 
695
}
 
696
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
 
697
  int records = ctx->getNumRecords();
 
698
  
 
699
  HugoTransactions hugoTrans(*ctx->getTab());
 
700
  int batchSize = ctx->getProperty("BatchSize", 1);
 
701
  if(hugoTrans.loadTable(GETNDB(step), records, batchSize) != 0){
 
702
    return NDBT_FAILED;
 
703
  }
 
704
  return NDBT_OK;
 
705
}
 
706
 
 
707
 
 
708
int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
 
709
  int records = ctx->getNumRecords();
 
710
  
 
711
  UtilTransactions utilTrans(*ctx->getTab());
 
712
  if (utilTrans.clearTable(GETNDB(step),  records) != 0){
 
713
    return NDBT_FAILED;
 
714
  }
 
715
  return NDBT_OK;
 
716
}
 
717
 
 
718
int runSystemRestart1(NDBT_Context* ctx, NDBT_Step* step){
 
719
  Ndb* pNdb = GETNDB(step);
 
720
  int result = NDBT_OK;
 
721
  int timeout = 300;
 
722
  Uint32 loops = ctx->getNumLoops();
 
723
  int records = ctx->getNumRecords();
 
724
  int count;
 
725
  NdbRestarter restarter;
 
726
  Uint32 i = 1;
 
727
 
 
728
  UtilTransactions utilTrans(*ctx->getTab());
 
729
  HugoTransactions hugoTrans(*ctx->getTab());
 
730
  const char * name = ctx->getTab()->getName();
 
731
  while(i<=loops && result != NDBT_FAILED){
 
732
 
 
733
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
734
    /*
 
735
      1. Load data
 
736
      2. Restart cluster and verify records
 
737
      3. Update records
 
738
      4. Restart cluster and verify records
 
739
      5. Delete half of the records
 
740
      6. Restart cluster and verify records
 
741
      7. Delete all records
 
742
      8. Restart cluster and verify records
 
743
      9. Insert, update, delete records
 
744
      10. Restart cluster and verify records
 
745
      11. Insert, update, delete records
 
746
      12. Restart cluster with error insert 5020 and verify records
 
747
    */
 
748
    ndbout << "Loading records..." << endl;
 
749
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
750
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
751
    
 
752
    ndbout << "Restarting cluster" << endl;
 
753
    CHECK(restarter.restartAll() == 0);
 
754
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
755
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
756
 
 
757
    ndbout << "Verifying records..." << endl;
 
758
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
759
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
760
    CHECK(count == records);
 
761
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
762
 
 
763
    ndbout << "Updating records..." << endl;
 
764
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
765
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
766
 
 
767
    ndbout << "Restarting cluster..." << endl;
 
768
    CHECK(restarter.restartAll() == 0);
 
769
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
770
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
771
 
 
772
    ndbout << "Verifying records..." << endl;
 
773
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
774
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
775
    CHECK(count == records);
 
776
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
777
    
 
778
    ndbout << "Deleting 50% of records..." << endl;
 
779
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
780
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
781
 
 
782
    ndbout << "Restarting cluster..." << endl;
 
783
    CHECK(restarter.restartAll() == 0);
 
784
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
785
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
786
 
 
787
    ndbout << "Verifying records..." << endl;
 
788
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
789
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
790
    CHECK(count == (records/2));
 
791
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
792
 
 
793
    ndbout << "Deleting all records..." << endl;
 
794
    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
 
795
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
796
 
 
797
    ndbout << "Restarting cluster..." << endl;
 
798
    CHECK(restarter.restartAll() == 0);
 
799
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
800
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
801
 
 
802
    ndbout << "Verifying records..." << endl;
 
803
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
804
    CHECK(count == 0);
 
805
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
806
 
 
807
    ndbout << "Doing it all..." << endl;
 
808
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
809
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
810
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
811
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
812
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
813
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records) == 0);
 
814
    CHECK(utilTrans.verifyIndex(pNdb, idxName, 16, false) == 0);
 
815
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
816
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
817
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
818
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
819
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
820
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
821
 
 
822
    ndbout << "Restarting cluster..." << endl;
 
823
    CHECK(restarter.restartAll() == 0);
 
824
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
825
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
826
 
 
827
    ndbout << "Verifying records..." << endl;
 
828
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
829
    CHECK(count == 0);
 
830
 
 
831
    ndbout << "Doing it all..." << endl;
 
832
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
833
    CHECK(utilTrans.verifyIndex(pNdb, idxName,  16, false) == 0);
 
834
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
835
    CHECK(utilTrans.verifyIndex(pNdb, idxName,  16, false) == 0);
 
836
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
837
    CHECK(utilTrans.verifyIndex(pNdb, idxName,  16, false) == 0);
 
838
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records) == 0);
 
839
    CHECK(utilTrans.verifyIndex(pNdb, idxName,  16, false) == 0);
 
840
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
841
    CHECK(hugoTrans.loadTable(pNdb, records, 1) == 0);
 
842
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
843
 
 
844
    ndbout << "Restarting cluster with error insert 5020..." << endl;
 
845
    CHECK(restarter.restartAll(false, true) == 0);
 
846
    CHECK(restarter.waitClusterNoStart(timeout) == 0);
 
847
    CHECK(restarter.insertErrorInAllNodes(5020) == 0);
 
848
    CHECK(restarter.startAll() == 0);
 
849
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
850
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
851
    
 
852
    i++;
 
853
  }
 
854
 
 
855
  ctx->stopTest();
 
856
  ndbout << "runSystemRestart1 finished" << endl;  
 
857
 
 
858
  return result;
 
859
}
 
860
 
 
861
#define CHECK2(b, t) if(!b){ g_err << __LINE__ << ": " << t << endl; break;}
 
862
 
 
863
int
 
864
runMixed1(NDBT_Context* ctx, NDBT_Step* step){
 
865
  // Verify that data in index match 
 
866
  // table data
 
867
  Ndb* pNdb = GETNDB(step);
 
868
  HugoOperations hugoOps(*ctx->getTab());
 
869
 
 
870
 
 
871
  do {
 
872
    // TC1
 
873
    g_err << "pkRead, indexRead, Commit" << endl;
 
874
    CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
 
875
    CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
 
876
    CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
 
877
    CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
 
878
    CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
 
879
 
 
880
    // TC1
 
881
    g_err << "pkRead, indexRead, Commit" << endl;
 
882
    CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
 
883
    CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
 
884
    CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
 
885
    CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
 
886
    CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
 
887
    
 
888
 
 
889
    // TC2
 
890
    g_err << "pkRead, indexRead, NoCommit, Commit" << endl;
 
891
    CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction");
 
892
    CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecord");
 
893
    CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0,
 
894
           "indexReadRecords");
 
895
    CHECK2(hugoOps.execute_NoCommit(pNdb) == 0, "executeNoCommit");
 
896
    CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
 
897
    CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction");
 
898
 
 
899
    // TC3
 
900
    g_err << "pkRead, pkRead, Commit" << endl;
 
901
    CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction ");
 
902
    CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecords ");
 
903
    CHECK2(hugoOps.pkReadRecord(pNdb, 0) == 0, "pkReadRecords ");
 
904
    CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
 
905
    CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction ");
 
906
 
 
907
    // TC4
 
908
    g_err << "indexRead, indexRead, Commit" << endl;
 
909
 
 
910
    CHECK2(hugoOps.startTransaction(pNdb) == 0, "startTransaction ");
 
911
    CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
 
912
    CHECK2(hugoOps.indexReadRecords(pNdb, pkIdxName, 0) == 0, "indexReadRecords");
 
913
    CHECK2(hugoOps.execute_Commit(pNdb) == 0, "executeCommit");
 
914
 
 
915
    CHECK2(hugoOps.closeTransaction(pNdb) == 0, "closeTransaction ");
 
916
 
 
917
    return NDBT_OK;
 
918
  } while(false);
 
919
 
 
920
 
 
921
  hugoOps.closeTransaction(pNdb);
 
922
  return NDBT_FAILED;
 
923
}
 
924
 
 
925
int
 
926
runBuildDuring(NDBT_Context* ctx, NDBT_Step* step){
 
927
  // Verify that data in index match 
 
928
  // table data
 
929
  const int Threads = ctx->getProperty("Threads", (Uint32)0);
 
930
  const int loops = ctx->getNumLoops();
 
931
 
 
932
  for(int i = 0; i<loops; i++){
 
933
#if 1
 
934
    if(createPkIndex(ctx, step) != NDBT_OK){
 
935
      g_err << "Failed to create index" << endl;
 
936
      return NDBT_FAILED;
 
937
    }
 
938
#endif
 
939
 
 
940
    if(ctx->isTestStopped())
 
941
      break;
 
942
 
 
943
#if 1
 
944
    if(createRandomIndex(ctx, step) != NDBT_OK){
 
945
      g_err << "Failed to create index" << endl;
 
946
      return NDBT_FAILED;
 
947
    }
 
948
#endif
 
949
 
 
950
    if(ctx->isTestStopped())
 
951
      break;
 
952
 
 
953
    ctx->setProperty("pause", 1);
 
954
    int count = 0;
 
955
    for(int j = 0; count < Threads && !ctx->isTestStopped(); 
 
956
        j = (j+1) % Threads){
 
957
      char buf[255];
 
958
      sprintf(buf, "Thread%d_paused", j);
 
959
      int tmp = ctx->getProperty(buf, (Uint32)0);
 
960
      count += tmp;
 
961
    }
 
962
    
 
963
    if(ctx->isTestStopped())
 
964
      break;
 
965
 
 
966
#if 1
 
967
    if(createPkIndex_Drop(ctx, step) != NDBT_OK){
 
968
      g_err << "Failed to drop index" << endl;
 
969
      return NDBT_FAILED;
 
970
    }
 
971
#endif
 
972
 
 
973
    if(ctx->isTestStopped())
 
974
      break;
 
975
    
 
976
#if 1
 
977
    if(createRandomIndex_Drop(ctx, step) != NDBT_OK){
 
978
      g_err << "Failed to drop index" << endl;
 
979
      return NDBT_FAILED;
 
980
    }
 
981
#endif
 
982
 
 
983
    ctx->setProperty("pause", (Uint32)0);
 
984
    NdbSleep_SecSleep(2);
 
985
  }
 
986
 
 
987
  ctx->stopTest();
 
988
  return NDBT_OK;
 
989
}
 
990
 
 
991
static NdbLockable g_lock;
 
992
static int threadCounter = 0;
 
993
 
 
994
void
 
995
wait_paused(NDBT_Context* ctx, int id){
 
996
  if(ctx->getProperty("pause", (Uint32)0) == 1){
 
997
    char buf[255];
 
998
    sprintf(buf, "Thread%d_paused", id);
 
999
    ctx->setProperty(buf, 1);
 
1000
    while(!ctx->isTestStopped() && ctx->getProperty("pause", (Uint32)0) == 1){
 
1001
      NdbSleep_MilliSleep(250);
 
1002
    }
 
1003
    ctx->setProperty(buf, (Uint32)0);
 
1004
  }
 
1005
}
 
1006
 
 
1007
int
 
1008
runTransactions4(NDBT_Context* ctx, NDBT_Step* step){
 
1009
 
 
1010
  g_lock.lock();
 
1011
  const int ThreadId = threadCounter++;
 
1012
  g_lock.unlock();
 
1013
  
 
1014
  // Verify that data in index match 
 
1015
  // table data
 
1016
  Ndb* pNdb = GETNDB(step);
 
1017
  HugoTransactions hugoTrans(*ctx->getTab());
 
1018
  UtilTransactions utilTrans(*ctx->getTab());
 
1019
  const int batchSize = ctx->getProperty("BatchSize", 32);
 
1020
  const int parallel = batchSize > 240 ? 240 : batchSize;
 
1021
 
 
1022
  int rows = ctx->getNumRecords();
 
1023
  while (ctx->isTestStopped() == false) {
 
1024
    if(hugoTrans.loadTable(pNdb, rows, batchSize, false) != 0){
 
1025
      g_err << "Load table failed" << endl;
 
1026
      return NDBT_FAILED;
 
1027
    }
 
1028
 
 
1029
    wait_paused(ctx, ThreadId);
 
1030
 
 
1031
    if(ctx->isTestStopped())
 
1032
      break;
 
1033
 
 
1034
    if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
 
1035
      g_err << "Updated table failed" << endl;
 
1036
      return NDBT_FAILED;
 
1037
    }    
 
1038
 
 
1039
    wait_paused(ctx, ThreadId);
 
1040
    
 
1041
    if(ctx->isTestStopped())
 
1042
      break;
 
1043
    
 
1044
    if (hugoTrans.scanUpdateRecords(pNdb, rows, 5, parallel) != 0){
 
1045
      g_err << "Scan updated table failed" << endl;
 
1046
      return NDBT_FAILED;
 
1047
    }
 
1048
 
 
1049
    wait_paused(ctx, ThreadId);
 
1050
 
 
1051
    if(ctx->isTestStopped())
 
1052
      break;
 
1053
 
 
1054
    if(utilTrans.clearTable(pNdb, rows, parallel) != 0){
 
1055
      g_err << "Clear table failed" << endl;
 
1056
      return NDBT_FAILED;
 
1057
    }
 
1058
  }
 
1059
  return NDBT_OK;
 
1060
}
 
1061
 
 
1062
int
 
1063
runUniqueNullTransactions(NDBT_Context* ctx, NDBT_Step* step){
 
1064
  Ndb* pNdb = GETNDB(step);
 
1065
 
 
1066
  bool logged = ctx->getProperty("LoggedIndexes", 1);
 
1067
  bool orderedIndex = ctx->getProperty("OrderedIndex", (unsigned)0);
 
1068
  NdbConnection * pTrans = 0;
 
1069
 
 
1070
  const NdbDictionary::Table* pTab = ctx->getTab();
 
1071
  // Create index    
 
1072
  char nullIndex[255];
 
1073
  BaseString::snprintf(nullIndex, 255, "IDC_PK_%s_NULL", pTab->getName());
 
1074
  if (orderedIndex)
 
1075
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "ordered index "
 
1076
           << pkIdxName << " (";
 
1077
  else
 
1078
    ndbout << "Creating " << ((logged)?"logged ": "temporary ") << "unique index "
 
1079
           << pkIdxName << " (";
 
1080
 
 
1081
  NdbDictionary::Index pIdx(pkIdxName);
 
1082
  pIdx.setTable(pTab->getName());
 
1083
  if (orderedIndex)
 
1084
    pIdx.setType(NdbDictionary::Index::OrderedIndex);
 
1085
  else
 
1086
    pIdx.setType(NdbDictionary::Index::UniqueHashIndex);
 
1087
  pIdx.setStoredIndex(logged);
 
1088
  int c;
 
1089
  for (c = 0; c< pTab->getNoOfColumns(); c++){
 
1090
    const NdbDictionary::Column * col = pTab->getColumn(c);
 
1091
    if(col->getPrimaryKey()){
 
1092
      pIdx.addIndexColumn(col->getName());
 
1093
      ndbout << col->getName() <<" ";
 
1094
    }
 
1095
  }
 
1096
  
 
1097
  int colId = -1;
 
1098
  for (c = 0; c< pTab->getNoOfColumns(); c++){
 
1099
    const NdbDictionary::Column * col = pTab->getColumn(c);
 
1100
    if(col->getNullable()){
 
1101
      pIdx.addIndexColumn(col->getName());
 
1102
      ndbout << col->getName() <<" ";
 
1103
      colId = c;
 
1104
      break;
 
1105
    }
 
1106
  }
 
1107
  ndbout << ") ";
 
1108
 
 
1109
  if(colId == -1){
 
1110
    ndbout << endl << "No nullable column found -> NDBT_FAILED" << endl; 
 
1111
    return NDBT_FAILED;
 
1112
  }
 
1113
  
 
1114
  if (pNdb->getDictionary()->createIndex(pIdx) != 0){
 
1115
    ndbout << "FAILED!" << endl;
 
1116
    const NdbError err = pNdb->getDictionary()->getNdbError();
 
1117
    ERR(err);
 
1118
    return NDBT_FAILED;
 
1119
  }
 
1120
  
 
1121
  int result = NDBT_OK;
 
1122
 
 
1123
  HugoTransactions hugoTrans(*ctx->getTab());
 
1124
  const int batchSize = ctx->getProperty("BatchSize", 50);
 
1125
  int loops = ctx->getNumLoops();
 
1126
  int rows = ctx->getNumRecords();
 
1127
  while (loops-- > 0 && ctx->isTestStopped() == false) {
 
1128
    if (hugoTrans.pkUpdateRecords(pNdb, rows, batchSize) != 0){
 
1129
      g_err << "Updated table failed" << endl;
 
1130
      result = NDBT_FAILED;
 
1131
      goto done;
 
1132
    }    
 
1133
  }
 
1134
 
 
1135
  if(ctx->isTestStopped()){
 
1136
    goto done;
 
1137
  }
 
1138
 
 
1139
  ctx->stopTest();
 
1140
  while(ctx->getNoOfRunningSteps() > 1){
 
1141
    NdbSleep_MilliSleep(100);
 
1142
  }
 
1143
 
 
1144
  result = NDBT_FAILED;
 
1145
  pTrans = pNdb->startTransaction();
 
1146
  NdbScanOperation * sOp;
 
1147
  NdbOperation * uOp;
 
1148
  int eof;
 
1149
  if(!pTrans) goto done;
 
1150
  sOp = pTrans->getNdbScanOperation(pTab->getName());
 
1151
  if(!sOp) goto done;
 
1152
  if(sOp->readTuples(NdbScanOperation::LM_Exclusive)) goto done;
 
1153
  if(pTrans->execute(NoCommit) == -1) goto done;
 
1154
  while((eof = sOp->nextResult(true)) == 0){
 
1155
    do {
 
1156
      NdbOperation * uOp = sOp->updateCurrentTuple();
 
1157
      if(uOp == 0) goto done;
 
1158
      uOp->setValue(colId, 0);
 
1159
    } while((eof = sOp->nextResult(false)) == 0);
 
1160
    eof = pTrans->execute(Commit);
 
1161
    if(eof == -1) goto done;
 
1162
  }
 
1163
  
 
1164
 done:
 
1165
  if(pTrans) pNdb->closeTransaction(pTrans);
 
1166
  pNdb->getDictionary()->dropIndex(nullIndex, pTab->getName());
 
1167
  return result;
 
1168
}
 
1169
 
 
1170
int runLQHKEYREF(NDBT_Context* ctx, NDBT_Step* step){
 
1171
  int result = NDBT_OK;
 
1172
  int loops = ctx->getNumLoops() * 100;
 
1173
  NdbRestarter restarter;
 
1174
  
 
1175
  myRandom48Init(NdbTick_CurrentMillisecond());
 
1176
 
 
1177
#if 0
 
1178
  int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
1179
  if(restarter.dumpStateAllNodes(&val, 1) != 0){
 
1180
    g_err << "Failed to dump DihMinTimeBetweenLCP" << endl;
 
1181
    return NDBT_FAILED;
 
1182
  }
 
1183
#endif
 
1184
 
 
1185
  for(int i = 0; i<loops && !ctx->isTestStopped(); i++){
 
1186
    int randomId = myRandom48(restarter.getNumDbNodes());
 
1187
    int nodeId = restarter.getDbNodeId(randomId);
 
1188
 
 
1189
    const Uint32 error = 5031 + (i % 3);
 
1190
    
 
1191
    if(restarter.insertErrorInNode(nodeId, error) != 0){
 
1192
      g_err << "Failed to error insert( " << error << ") in node "
 
1193
            << nodeId << endl;
 
1194
      return NDBT_FAILED;
 
1195
    }
 
1196
  }
 
1197
  
 
1198
  ctx->stopTest();
 
1199
  return NDBT_OK;
 
1200
}
 
1201
 
 
1202
int 
 
1203
runBug21384(NDBT_Context* ctx, NDBT_Step* step)
 
1204
{
 
1205
  Ndb* pNdb = GETNDB(step);
 
1206
  HugoTransactions hugoTrans(*ctx->getTab());
 
1207
  NdbRestarter restarter;
 
1208
  
 
1209
  int loops = ctx->getNumLoops();
 
1210
  const int rows = ctx->getNumRecords();
 
1211
  const int batchsize = ctx->getProperty("BatchSize", 50);
 
1212
  
 
1213
  while (loops--)
 
1214
  {
 
1215
    if(restarter.insertErrorInAllNodes(8037) != 0)
 
1216
    {
 
1217
      g_err << "Failed to error insert(8037)" << endl;
 
1218
      return NDBT_FAILED;
 
1219
    }
 
1220
    
 
1221
    if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) == 0)
 
1222
    {
 
1223
      g_err << "Index succeded (it should have failed" << endl;
 
1224
      return NDBT_FAILED;
 
1225
    }
 
1226
    
 
1227
    if(restarter.insertErrorInAllNodes(0) != 0)
 
1228
    {
 
1229
      g_err << "Failed to error insert(0)" << endl;
 
1230
      return NDBT_FAILED;
 
1231
    }
 
1232
    
 
1233
    if (hugoTrans.indexReadRecords(pNdb, pkIdxName, rows, batchsize) != 0){
 
1234
      g_err << "Index read failed" << endl;
 
1235
      return NDBT_FAILED;
 
1236
    }
 
1237
  }
 
1238
  
 
1239
  return NDBT_OK;
 
1240
}
 
1241
 
 
1242
 
 
1243
 
 
1244
NDBT_TESTSUITE(testIndex);
 
1245
TESTCASE("CreateAll", 
 
1246
         "Test that we can create all various indexes on each table\n"
 
1247
         "Then drop the indexes\n"){
 
1248
  INITIALIZER(runCreateIndexes);
 
1249
}
 
1250
TESTCASE("CreateAll_O",
 
1251
         "Test that we can create all various indexes on each table\n"
 
1252
         "Then drop the indexes\n"){
 
1253
  TC_PROPERTY("OrderedIndex", 1);
 
1254
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1255
  INITIALIZER(runCreateIndexes);
 
1256
}
 
1257
TESTCASE("InsertDeleteGentle", 
 
1258
         "Create one index, then perform insert and delete in the table\n"
 
1259
         "loop number of times. Use batch size 1."){
 
1260
  TC_PROPERTY("BatchSize", 1);
 
1261
  INITIALIZER(runInsertDelete);
 
1262
  FINALIZER(runClearTable);
 
1263
}
 
1264
TESTCASE("InsertDeleteGentle_O",
 
1265
         "Create one index, then perform insert and delete in the table\n"
 
1266
         "loop number of times. Use batch size 1."){
 
1267
  TC_PROPERTY("OrderedIndex", 1);
 
1268
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1269
  TC_PROPERTY("BatchSize", 1);
 
1270
  INITIALIZER(runInsertDelete);
 
1271
  FINALIZER(runClearTable);
 
1272
}
 
1273
TESTCASE("InsertDelete", 
 
1274
         "Create one index, then perform insert and delete in the table\n"
 
1275
         "loop number of times. Use batchsize 512 to stress db more"){
 
1276
  TC_PROPERTY("BatchSize", 512);
 
1277
  INITIALIZER(runInsertDelete);
 
1278
  FINALIZER(runClearTable);
 
1279
 
 
1280
}
 
1281
TESTCASE("InsertDelete_O", 
 
1282
         "Create one index, then perform insert and delete in the table\n"
 
1283
         "loop number of times. Use batchsize 512 to stress db more"){
 
1284
  TC_PROPERTY("OrderedIndex", 1);
 
1285
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1286
  TC_PROPERTY("BatchSize", 512);
 
1287
  INITIALIZER(runInsertDelete);
 
1288
  FINALIZER(runClearTable);
 
1289
 
 
1290
}
 
1291
TESTCASE("CreateLoadDropGentle", 
 
1292
         "Try to create, drop and load various indexes \n"
 
1293
         "on table loop number of times.Usa batch size 1.\n"){
 
1294
  TC_PROPERTY("BatchSize", 1);
 
1295
  INITIALIZER(runCreateLoadDropIndex);
 
1296
}
 
1297
TESTCASE("CreateLoadDropGentle_O", 
 
1298
         "Try to create, drop and load various indexes \n"
 
1299
         "on table loop number of times.Usa batch size 1.\n"){
 
1300
  TC_PROPERTY("OrderedIndex", 1);
 
1301
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1302
  TC_PROPERTY("BatchSize", 1);
 
1303
  INITIALIZER(runCreateLoadDropIndex);
 
1304
}
 
1305
TESTCASE("CreateLoadDrop", 
 
1306
         "Try to create, drop and load various indexes \n"
 
1307
         "on table loop number of times. Use batchsize 512 to stress db more\n"){
 
1308
  TC_PROPERTY("BatchSize", 512);
 
1309
  INITIALIZER(runCreateLoadDropIndex);
 
1310
}
 
1311
TESTCASE("CreateLoadDrop_O", 
 
1312
         "Try to create, drop and load various indexes \n"
 
1313
         "on table loop number of times. Use batchsize 512 to stress db more\n"){
 
1314
  TC_PROPERTY("OrderedIndex", 1);
 
1315
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1316
  TC_PROPERTY("BatchSize", 512);
 
1317
  INITIALIZER(runCreateLoadDropIndex);
 
1318
}
 
1319
TESTCASE("NFNR1", 
 
1320
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1321
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1322
  TC_PROPERTY("PauseThreads", 2);
 
1323
  INITIALIZER(runClearTable);
 
1324
  INITIALIZER(createRandomIndex);
 
1325
  INITIALIZER(runLoadTable);
 
1326
  STEP(runRestarts);
 
1327
  STEP(runTransactions1);
 
1328
  STEP(runTransactions1);
 
1329
  FINALIZER(runVerifyIndex);
 
1330
  FINALIZER(createRandomIndex_Drop);
 
1331
  FINALIZER(runClearTable);
 
1332
}
 
1333
TESTCASE("NFNR1_O", 
 
1334
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1335
  TC_PROPERTY("OrderedIndex", 1);
 
1336
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1337
  TC_PROPERTY("PauseThreads", 2);
 
1338
  INITIALIZER(runClearTable);
 
1339
  INITIALIZER(createRandomIndex);
 
1340
  INITIALIZER(runLoadTable);
 
1341
  STEP(runRestarts);
 
1342
  STEP(runTransactions1);
 
1343
  STEP(runTransactions1);
 
1344
  FINALIZER(runVerifyIndex);
 
1345
  FINALIZER(createRandomIndex_Drop);
 
1346
  FINALIZER(runClearTable);
 
1347
}
 
1348
TESTCASE("NFNR2", 
 
1349
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1350
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1351
  TC_PROPERTY("PauseThreads", 2);
 
1352
  INITIALIZER(runClearTable);
 
1353
  INITIALIZER(createRandomIndex);
 
1354
  INITIALIZER(createPkIndex);
 
1355
  INITIALIZER(runLoadTable);
 
1356
  STEP(runRestarts);
 
1357
  STEP(runTransactions2);
 
1358
  STEP(runTransactions2);
 
1359
  FINALIZER(runVerifyIndex);
 
1360
  FINALIZER(createRandomIndex_Drop);
 
1361
  FINALIZER(createPkIndex_Drop);
 
1362
  FINALIZER(runClearTable);
 
1363
}
 
1364
TESTCASE("NFNR2_O", 
 
1365
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1366
  TC_PROPERTY("OrderedIndex", 1);
 
1367
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1368
  TC_PROPERTY("PauseThreads", 1);
 
1369
  INITIALIZER(runClearTable);
 
1370
  INITIALIZER(createRandomIndex);
 
1371
  INITIALIZER(createPkIndex);
 
1372
  INITIALIZER(runLoadTable);
 
1373
  STEP(runRestarts);
 
1374
  STEP(runTransactions2);
 
1375
  //STEP(runTransactions2);
 
1376
  FINALIZER(runVerifyIndex);
 
1377
  FINALIZER(createRandomIndex_Drop);
 
1378
  FINALIZER(createPkIndex_Drop);
 
1379
  FINALIZER(runClearTable);
 
1380
}
 
1381
TESTCASE("NFNR3", 
 
1382
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1383
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1384
  TC_PROPERTY("PauseThreads", 2);
 
1385
  INITIALIZER(runClearTable);
 
1386
  INITIALIZER(createRandomIndex);
 
1387
  INITIALIZER(createPkIndex);
 
1388
  STEP(runRestarts);
 
1389
  STEP(runTransactions3);
 
1390
  STEP(runVerifyIndex);
 
1391
  FINALIZER(runVerifyIndex);
 
1392
  FINALIZER(createPkIndex_Drop);
 
1393
  FINALIZER(createRandomIndex_Drop);
 
1394
  FINALIZER(runClearTable);
 
1395
}
 
1396
TESTCASE("NFNR3_O", 
 
1397
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1398
  TC_PROPERTY("OrderedIndex", 1);
 
1399
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1400
  TC_PROPERTY("PauseThreads", 2);
 
1401
  INITIALIZER(runClearTable);
 
1402
  INITIALIZER(createRandomIndex);
 
1403
  INITIALIZER(createPkIndex);
 
1404
  STEP(runRestarts);
 
1405
  STEP(runTransactions3);
 
1406
  STEP(runVerifyIndex);
 
1407
  FINALIZER(runVerifyIndex);
 
1408
  FINALIZER(createPkIndex_Drop);
 
1409
  FINALIZER(createRandomIndex_Drop);
 
1410
  FINALIZER(runClearTable);
 
1411
}
 
1412
TESTCASE("NFNR4", 
 
1413
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1414
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1415
  TC_PROPERTY("PauseThreads", 4);
 
1416
  INITIALIZER(runClearTable);
 
1417
  INITIALIZER(createRandomIndex);
 
1418
  INITIALIZER(createPkIndex);
 
1419
  INITIALIZER(runLoadTable);
 
1420
  STEP(runRestarts);
 
1421
  STEP(runTransactions1);
 
1422
  STEP(runTransactions1);
 
1423
  STEP(runTransactions2);
 
1424
  STEP(runTransactions2);
 
1425
  FINALIZER(runVerifyIndex);
 
1426
  FINALIZER(createRandomIndex_Drop);
 
1427
  FINALIZER(createPkIndex_Drop);
 
1428
  FINALIZER(runClearTable);
 
1429
}
 
1430
TESTCASE("NFNR4_O", 
 
1431
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1432
  TC_PROPERTY("OrderedIndex", 1);
 
1433
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1434
  TC_PROPERTY("PauseThreads", 4);
 
1435
  INITIALIZER(runClearTable);
 
1436
  INITIALIZER(createRandomIndex);
 
1437
  INITIALIZER(createPkIndex);
 
1438
  INITIALIZER(runLoadTable);
 
1439
  STEP(runRestarts);
 
1440
  STEP(runTransactions1);
 
1441
  STEP(runTransactions1);
 
1442
  STEP(runTransactions2);
 
1443
  STEP(runTransactions2);
 
1444
  FINALIZER(runVerifyIndex);
 
1445
  FINALIZER(createRandomIndex_Drop);
 
1446
  FINALIZER(createPkIndex_Drop);
 
1447
  FINALIZER(runClearTable);
 
1448
}
 
1449
TESTCASE("NFNR5", 
 
1450
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1451
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1452
  TC_PROPERTY("BatchSize", (unsigned)1);
 
1453
  INITIALIZER(runClearTable);
 
1454
  INITIALIZER(createRandomIndex);
 
1455
  INITIALIZER(createPkIndex);
 
1456
  INITIALIZER(runLoadTable);
 
1457
  STEP(runLQHKEYREF);
 
1458
  STEP(runTransactions1);
 
1459
  STEP(runTransactions1);
 
1460
  STEP(runTransactions2);
 
1461
  STEP(runTransactions2);
 
1462
  FINALIZER(runVerifyIndex);
 
1463
  FINALIZER(createRandomIndex_Drop);
 
1464
  FINALIZER(createPkIndex_Drop);
 
1465
  FINALIZER(runClearTable);
 
1466
}
 
1467
TESTCASE("NFNR5_O", 
 
1468
         "Test that indexes are correctly maintained during node fail and node restart"){ 
 
1469
  TC_PROPERTY("OrderedIndex", 1);
 
1470
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1471
  TC_PROPERTY("BatchSize", (unsigned)1);
 
1472
  INITIALIZER(runClearTable);
 
1473
  INITIALIZER(createRandomIndex);
 
1474
  INITIALIZER(createPkIndex);
 
1475
  INITIALIZER(runLoadTable);
 
1476
  STEP(runLQHKEYREF);
 
1477
  STEP(runTransactions1);
 
1478
  STEP(runTransactions1);
 
1479
  STEP(runTransactions2);
 
1480
  STEP(runTransactions2);
 
1481
  FINALIZER(runVerifyIndex);
 
1482
  FINALIZER(createRandomIndex_Drop);
 
1483
  FINALIZER(createPkIndex_Drop);
 
1484
  FINALIZER(runClearTable);
 
1485
}
 
1486
TESTCASE("SR1", 
 
1487
         "Test that indexes are correctly maintained during SR"){ 
 
1488
  INITIALIZER(runClearTable);
 
1489
  INITIALIZER(createRandomIndex);
 
1490
  INITIALIZER(createPkIndex);
 
1491
  STEP(runSystemRestart1);
 
1492
  FINALIZER(runVerifyIndex);
 
1493
  FINALIZER(createPkIndex_Drop);
 
1494
  FINALIZER(createRandomIndex_Drop);
 
1495
  FINALIZER(runClearTable);
 
1496
}
 
1497
TESTCASE("MixedTransaction", 
 
1498
         "Test mixing of index and normal operations"){ 
 
1499
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1500
  INITIALIZER(runClearTable);
 
1501
  INITIALIZER(createPkIndex);
 
1502
  INITIALIZER(runLoadTable);
 
1503
  STEP(runMixed1);
 
1504
  FINALIZER(createPkIndex_Drop);
 
1505
  FINALIZER(runClearTable);
 
1506
}
 
1507
TESTCASE("SR1_O", 
 
1508
         "Test that indexes are correctly maintained during SR"){ 
 
1509
  TC_PROPERTY("OrderedIndex", 1);
 
1510
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1511
  INITIALIZER(runClearTable);
 
1512
  INITIALIZER(createRandomIndex);
 
1513
  INITIALIZER(createPkIndex);
 
1514
  STEP(runSystemRestart1);
 
1515
  FINALIZER(runVerifyIndex);
 
1516
  FINALIZER(createPkIndex_Drop);
 
1517
  FINALIZER(createRandomIndex_Drop);
 
1518
  FINALIZER(runClearTable);
 
1519
}
 
1520
TESTCASE("BuildDuring", 
 
1521
         "Test that index build when running transactions work"){ 
 
1522
  TC_PROPERTY("OrderedIndex", (unsigned)0);
 
1523
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1524
  TC_PROPERTY("Threads", 1); // # runTransactions4
 
1525
  INITIALIZER(runClearTable);
 
1526
  STEP(runBuildDuring);
 
1527
  STEP(runTransactions4);
 
1528
  //STEP(runTransactions4);
 
1529
  FINALIZER(runClearTable);
 
1530
}
 
1531
TESTCASE("BuildDuring_O", 
 
1532
         "Test that index build when running transactions work"){ 
 
1533
  TC_PROPERTY("OrderedIndex", (unsigned)1);
 
1534
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1535
  TC_PROPERTY("Threads", 1); // # runTransactions4
 
1536
  INITIALIZER(runClearTable);
 
1537
  STEP(runBuildDuring);
 
1538
  STEP(runTransactions4);
 
1539
  //STEP(runTransactions4);
 
1540
  FINALIZER(runClearTable);
 
1541
}
 
1542
TESTCASE("UniqueNull", 
 
1543
         "Test that unique indexes and nulls"){ 
 
1544
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1545
  INITIALIZER(runClearTable);
 
1546
  INITIALIZER(createRandomIndex);
 
1547
  INITIALIZER(createPkIndex);
 
1548
  INITIALIZER(runLoadTable);
 
1549
  STEP(runTransactions1);
 
1550
  STEP(runTransactions2);
 
1551
  STEP(runUniqueNullTransactions);
 
1552
  FINALIZER(runVerifyIndex);
 
1553
  FINALIZER(createRandomIndex_Drop);
 
1554
  FINALIZER(createPkIndex_Drop);
 
1555
  FINALIZER(runClearTable);
 
1556
}
 
1557
TESTCASE("Bug21384", 
 
1558
         "Test that unique indexes and nulls"){ 
 
1559
  TC_PROPERTY("LoggedIndexes", (unsigned)0);
 
1560
  INITIALIZER(runClearTable);
 
1561
  INITIALIZER(createPkIndex);
 
1562
  INITIALIZER(runLoadTable);
 
1563
  STEP(runBug21384);
 
1564
  FINALIZER(createPkIndex_Drop);
 
1565
  FINALIZER(runClearTable);
 
1566
}
 
1567
NDBT_TESTSUITE_END(testIndex);
 
1568
 
 
1569
int main(int argc, const char** argv){
 
1570
  ndb_init();
 
1571
  return testIndex.execute(argc, argv);
 
1572
}
 
1573
 
 
1574
template class Vector<Attrib*>;