~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to storage/ndb/test/ndbapi/testSystemRestart.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

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; version 2 of the License.
 
6
 
 
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.
 
11
 
 
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 */
 
15
 
 
16
#include <NDBT.hpp>
 
17
#include <NDBT_Test.hpp>
 
18
#include <HugoTransactions.hpp>
 
19
#include <UtilTransactions.hpp>
 
20
#include <NdbRestarter.hpp>
 
21
#include <Vector.hpp>
 
22
#include <signaldata/DumpStateOrd.hpp>
 
23
#include <NdbBackup.hpp>
 
24
 
 
25
int runLoadTable(NDBT_Context* ctx, NDBT_Step* step){
 
26
 
 
27
  int records = ctx->getNumRecords();
 
28
  HugoTransactions hugoTrans(*ctx->getTab());
 
29
  if (hugoTrans.loadTable(GETNDB(step), records) != 0){
 
30
    return NDBT_FAILED;
 
31
  }
 
32
  return NDBT_OK;
 
33
}
 
34
 
 
35
#define CHECK(b) if (!(b)) { \
 
36
  g_err << "ERR: "<< step->getName() \
 
37
         << " failed on line " << __LINE__ << endl; \
 
38
  result = NDBT_FAILED; \
 
39
  continue; } 
 
40
 
 
41
int runSystemRestart1(NDBT_Context* ctx, NDBT_Step* step){
 
42
  Ndb* pNdb = GETNDB(step);
 
43
  int result = NDBT_OK;
 
44
  int timeout = 300;
 
45
  Uint32 loops = ctx->getNumLoops();
 
46
  int records = ctx->getNumRecords();
 
47
  int count;
 
48
  NdbRestarter restarter;
 
49
  Uint32 i = 1;
 
50
 
 
51
  UtilTransactions utilTrans(*ctx->getTab());
 
52
  HugoTransactions hugoTrans(*ctx->getTab());
 
53
  while(i<=loops && result != NDBT_FAILED){
 
54
 
 
55
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
56
    /*
 
57
      1. Load data
 
58
      2. Restart cluster and verify records
 
59
      3. Update records
 
60
      4. Restart cluster and verify records
 
61
      5. Delete half of the records
 
62
      6. Restart cluster and verify records
 
63
      7. Delete all records
 
64
      8. Restart cluster and verify records
 
65
      9. Insert, update, delete records
 
66
      10. Restart cluster and verify records
 
67
      11. Insert, update, delete records
 
68
      12. Restart cluster with error insert 5020 and verify records
 
69
    */
 
70
    ndbout << "Loading records..." << endl;
 
71
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
72
 
 
73
    ndbout << "Restarting cluster" << endl;
 
74
    CHECK(restarter.restartAll() == 0);
 
75
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
76
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
77
 
 
78
    ndbout << "Verifying records..." << endl;
 
79
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
80
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
81
    CHECK(count == records);
 
82
 
 
83
    ndbout << "Updating records..." << endl;
 
84
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
85
 
 
86
    ndbout << "Restarting cluster..." << endl;
 
87
    CHECK(restarter.restartAll() == 0);
 
88
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
89
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
90
 
 
91
    ndbout << "Verifying records..." << endl;
 
92
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
93
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
94
    CHECK(count == records);
 
95
    
 
96
    ndbout << "Deleting 50% of records..." << endl;
 
97
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
98
 
 
99
    ndbout << "Restarting cluster..." << endl;
 
100
    CHECK(restarter.restartAll() == 0);
 
101
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
102
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
103
 
 
104
    ndbout << "Verifying records..." << endl;
 
105
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
106
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
107
    CHECK(count == (records/2));
 
108
 
 
109
    ndbout << "Deleting all records..." << endl;
 
110
    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
 
111
 
 
112
    ndbout << "Restarting cluster..." << endl;
 
113
    CHECK(restarter.restartAll() == 0);
 
114
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
115
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
116
 
 
117
    ndbout << "Verifying records..." << endl;
 
118
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
119
    CHECK(count == 0);
 
120
 
 
121
    ndbout << "Doing it all..." << endl;
 
122
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
123
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
124
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
125
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
 
126
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
127
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
128
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
129
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
130
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
131
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
132
 
 
133
    ndbout << "Restarting cluster..." << endl;
 
134
    CHECK(restarter.restartAll() == 0);
 
135
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
136
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
137
 
 
138
    ndbout << "Verifying records..." << endl;
 
139
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
140
    CHECK(count == 0);
 
141
 
 
142
    ndbout << "Doing it all..." << endl;
 
143
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
144
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
145
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
146
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
 
147
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
148
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
149
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
150
 
 
151
    ndbout << "Restarting cluster with error insert 5020..." << endl;
 
152
    CHECK(restarter.restartAll(false, true) == 0);
 
153
    CHECK(restarter.waitClusterNoStart(timeout) == 0);
 
154
    CHECK(restarter.insertErrorInAllNodes(5020) == 0);
 
155
    CHECK(restarter.startAll() == 0);
 
156
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
157
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
158
    
 
159
    i++;
 
160
  }
 
161
 
 
162
  ndbout << "runSystemRestart1 finished" << endl;  
 
163
 
 
164
  return result;
 
165
}
 
166
 
 
167
int runSystemRestart2(NDBT_Context* ctx, NDBT_Step* step){
 
168
  Ndb* pNdb = GETNDB(step);
 
169
  int result = NDBT_OK;
 
170
///  int timeout = 300;
 
171
  int timeout = 120;
 
172
  Uint32 loops = ctx->getNumLoops();
 
173
  int records = ctx->getNumRecords();
 
174
  int count;
 
175
  NdbRestarter restarter;
 
176
  Uint32 i = 1;
 
177
 
 
178
  UtilTransactions utilTrans(*ctx->getTab());
 
179
  HugoTransactions hugoTrans(*ctx->getTab());
 
180
  while(i<=loops && result != NDBT_FAILED && !ctx->isTestStopped()){
 
181
 
 
182
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
183
    /* Use error 7070 to set time between LCP to it's min value
 
184
      1. Load data
 
185
      2. Restart cluster and verify records
 
186
      3. Update records
 
187
      4. Restart cluster and verify records
 
188
      5. Delete half of the records
 
189
      6. Restart cluster and verify records
 
190
      7. Delete all records
 
191
      8. Restart cluster and verify records
 
192
      9. Insert, update, delete records
 
193
      10. Restart cluster and verify records
 
194
    */
 
195
    int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
196
    CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
197
 
 
198
    ndbout << "Loading records..." << endl;
 
199
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
200
 
 
201
    ndbout << "Restarting cluster" << endl;
 
202
    CHECK(restarter.restartAll() == 0);
 
203
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
204
    {
 
205
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
206
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
207
    }
 
208
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
209
 
 
210
    ndbout << "Verifying records..." << endl;
 
211
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
212
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
213
    CHECK(count == records);
 
214
 
 
215
    ndbout << "Updating records..." << endl;
 
216
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
217
 
 
218
    ndbout << "Restarting cluster..." << endl;
 
219
    CHECK(restarter.restartAll() == 0);
 
220
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
221
    {
 
222
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
223
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
224
    }
 
225
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
226
 
 
227
    ndbout << "Verifying records..." << endl;
 
228
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
229
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
230
    CHECK(count == records);
 
231
    
 
232
    ndbout << "Deleting 50% of records..." << endl;
 
233
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
234
 
 
235
    ndbout << "Restarting cluster..." << endl;
 
236
    CHECK(restarter.restartAll() == 0);
 
237
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
238
    {
 
239
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
240
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
241
    }
 
242
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
243
 
 
244
    ndbout << "Verifying records..." << endl;
 
245
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
246
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
247
    CHECK(count == (records/2));
 
248
 
 
249
    ndbout << "Deleting all records..." << endl;
 
250
    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
 
251
 
 
252
    ndbout << "Restarting cluster..." << endl;
 
253
    CHECK(restarter.restartAll() == 0);
 
254
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
255
    {
 
256
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
257
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
258
    }
 
259
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
260
 
 
261
    ndbout << "Verifying records..." << endl;
 
262
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
263
    CHECK(count == 0);
 
264
 
 
265
    ndbout << "Doing it all..." << endl;
 
266
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
267
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
268
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
269
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
 
270
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
271
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
272
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
273
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
274
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
275
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
276
 
 
277
    ndbout << "Restarting cluster..." << endl;
 
278
    CHECK(restarter.restartAll() == 0);
 
279
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
280
    {
 
281
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
282
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
283
    }
 
284
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
285
 
 
286
    ndbout << "Verifying records..." << endl;
 
287
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
288
    CHECK(count == 0);
 
289
 
 
290
    i++;
 
291
  }
 
292
 
 
293
  ndbout << "runSystemRestart2 finished" << endl;  
 
294
 
 
295
  return result;
 
296
}
 
297
 
 
298
int runSystemRestartTestUndoLog(NDBT_Context* ctx, NDBT_Step* step){
 
299
  Ndb* pNdb = GETNDB(step);
 
300
  int result = NDBT_OK;
 
301
  int timeout = 300;
 
302
  Uint32 loops = ctx->getNumLoops();
 
303
  int records = ctx->getNumRecords();
 
304
  int count;
 
305
  NdbRestarter restarter;
 
306
  Uint32 i = 1;
 
307
 
 
308
  int dump7080[2];
 
309
  dump7080[0] = 7080;
 
310
  dump7080[1] = ctx->getTab()->getTableId();
 
311
 
 
312
  UtilTransactions utilTrans(*ctx->getTab());
 
313
  HugoTransactions hugoTrans(*ctx->getTab());
 
314
  while(i<=loops && result != NDBT_FAILED){
 
315
 
 
316
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
317
    /*
 
318
      1. Start LCP, turn on undologging but delay write of datapages.
 
319
      2. Insert, update, delete records
 
320
      3. Complete writing of data pages and finish LCP.
 
321
      4. Restart cluster and verify records
 
322
    */
 
323
    // Use dump state 7080 to delay writing of datapages
 
324
    // for the current table
 
325
    ndbout << "Dump state: "<<dump7080[0]<<", "<<dump7080[1]<<endl;
 
326
    CHECK(restarter.dumpStateAllNodes(dump7080, 2) == 0);    
 
327
    NdbSleep_SecSleep(10);
 
328
 
 
329
    ndbout << "Doing it all..." << endl;
 
330
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
331
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
332
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
333
    CHECK(hugoTrans.scanUpdateRecords(pNdb, records/2) == 0);
 
334
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
335
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
336
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
337
 
 
338
    // Reset error and let LCP continue
 
339
    CHECK(restarter.insertErrorInAllNodes(0) == 0);
 
340
    NdbSleep_SecSleep(60);
 
341
 
 
342
    ndbout << "Restarting cluster..." << endl;
 
343
    CHECK(restarter.restartAll() == 0);
 
344
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
345
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
346
 
 
347
    ndbout << "Verifying records..." << endl;
 
348
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
349
    CHECK(count == 0);
 
350
 
 
351
    // Use dump state 7080 to delay writing of datapages
 
352
    // for the current table
 
353
    ndbout << "Dump state: "<<dump7080[0]<<", "<<dump7080[1]<<endl;
 
354
    CHECK(restarter.dumpStateAllNodes(dump7080, 2) == 0);
 
355
    NdbSleep_SecSleep(10);
 
356
 
 
357
    ndbout << "Doing it all, delete 50%..." << endl;
 
358
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
359
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
360
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
361
 
 
362
    // Reset error and let LCP continue
 
363
    CHECK(restarter.insertErrorInAllNodes(0) == 0);
 
364
    NdbSleep_SecSleep(20);
 
365
 
 
366
    ndbout << "Restarting cluster..." << endl;
 
367
    CHECK(restarter.restartAll() == 0);
 
368
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
369
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
370
 
 
371
    ndbout << "Verifying records..." << endl;
 
372
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
373
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
374
    CHECK(count == (records/2));
 
375
    CHECK(utilTrans.clearTable(pNdb, records) == 0);
 
376
 
 
377
    i++;
 
378
  }
 
379
 
 
380
  ndbout << "runSystemRestartTestUndoLog finished" << endl;  
 
381
 
 
382
  return result;
 
383
}
 
384
 
 
385
int runSystemRestartTestFullDb(NDBT_Context* ctx, NDBT_Step* step){
 
386
  Ndb* pNdb = GETNDB(step);
 
387
  int result = NDBT_OK;
 
388
  int timeout = 300;
 
389
  Uint32 loops = ctx->getNumLoops();
 
390
  int count1, count2;
 
391
  NdbRestarter restarter;
 
392
  Uint32 i = 1;
 
393
 
 
394
  UtilTransactions utilTrans(*ctx->getTab());
 
395
  HugoTransactions hugoTrans(*ctx->getTab());
 
396
  while(i<=loops && result != NDBT_FAILED){
 
397
 
 
398
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
399
    /*
 
400
      1. Load data until db reports it's full
 
401
      2. Restart cluster and verify records
 
402
    */
 
403
    ndbout << "Filling up table..." << endl;
 
404
    CHECK(hugoTrans.fillTable(pNdb) == 0);
 
405
    CHECK(utilTrans.selectCount(pNdb, 64, &count1) == 0);
 
406
    ndbout << "Db is full. Table has "<<count1 <<" records."<< endl;
 
407
    
 
408
    ndbout << "Restarting cluster" << endl;
 
409
    CHECK(restarter.restartAll() == 0);
 
410
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
411
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
412
 
 
413
    ndbout << "Verifying records..." << endl;
 
414
    CHECK(hugoTrans.scanReadRecords(pNdb, count1) == 0);
 
415
    CHECK(utilTrans.selectCount(pNdb, 64, &count2) == 0);
 
416
    CHECK(count1 == count2);
 
417
 
 
418
    ndbout << "Deleting all records..." << endl;
 
419
    CHECK(utilTrans.clearTable2(pNdb, count1) == 0);
 
420
 
 
421
    ndbout << "Restarting cluster..." << endl;
 
422
    CHECK(restarter.restartAll() == 0);
 
423
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
424
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
425
 
 
426
    ndbout << "Verifying records..." << endl;
 
427
    CHECK(utilTrans.selectCount(pNdb, 64, &count1) == 0);
 
428
    CHECK(count1 == 0);
 
429
 
 
430
    i++;
 
431
  }
 
432
 
 
433
  ndbout << "runSystemRestartTestFullDb finished" << endl;  
 
434
 
 
435
  return result;
 
436
}
 
437
 
 
438
int runSystemRestart3(NDBT_Context* ctx, NDBT_Step* step){
 
439
  Ndb* pNdb = GETNDB(step);
 
440
  int result = NDBT_OK;
 
441
  int timeout = 300;
 
442
  Uint32 loops = ctx->getNumLoops();
 
443
  int records = ctx->getNumRecords();
 
444
  int count;
 
445
  NdbRestarter restarter;
 
446
  Uint32 i = 1;
 
447
 
 
448
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
449
  if(nodeCount < 2){
 
450
    g_info << "SR3 - Needs atleast 2 nodes to test" << endl;
 
451
    return NDBT_OK;
 
452
  }
 
453
 
 
454
  Vector<int> nodeIds;
 
455
  for(i = 0; i<nodeCount; i++)
 
456
    nodeIds.push_back(restarter.getDbNodeId(i));
 
457
  
 
458
  Uint32 currentRestartNodeIndex = 0;
 
459
  UtilTransactions utilTrans(*ctx->getTab());
 
460
  HugoTransactions hugoTrans(*ctx->getTab());
 
461
  
 
462
  while(i<=loops && result != NDBT_FAILED){
 
463
    
 
464
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
465
    /**
 
466
     * 1. Load data
 
467
     * 2. Restart 1 node -nostart
 
468
     * 3. Update records
 
469
     * 4. Restart cluster and verify records
 
470
     * 5. Restart 1 node -nostart
 
471
     * 6. Delete half of the records
 
472
     * 7. Restart cluster and verify records
 
473
     * 8. Restart 1 node -nostart
 
474
     * 9. Delete all records
 
475
     * 10. Restart cluster and verify records
 
476
     */
 
477
    g_info << "Loading records..." << endl;
 
478
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
479
 
 
480
    /*** 1 ***/
 
481
    g_info << "1 - Stopping one node" << endl;
 
482
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
483
                                     false, 
 
484
                                     true,
 
485
                                     false) == 0);
 
486
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
487
 
 
488
    g_info << "Updating records..." << endl;
 
489
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
490
    
 
491
    g_info << "Restarting cluster..." << endl;
 
492
    CHECK(restarter.restartAll() == 0);
 
493
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
494
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
495
 
 
496
    g_info << "Verifying records..." << endl;
 
497
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
498
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
499
    CHECK(count == records);
 
500
 
 
501
    g_info << "2 - Stopping one node" << endl;
 
502
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
503
                                     false, 
 
504
                                     true,
 
505
                                     false) == 0);
 
506
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
507
 
 
508
    g_info << "Deleting 50% of records..." << endl;
 
509
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
510
    
 
511
    g_info << "Restarting cluster..." << endl;
 
512
    CHECK(restarter.restartAll() == 0);
 
513
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
514
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
515
 
 
516
    g_info << "Verifying records..." << endl;
 
517
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
518
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
519
    CHECK(count == (records/2));
 
520
 
 
521
    g_info << "3 - Stopping one node" << endl;
 
522
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
523
                                     false, 
 
524
                                     true,
 
525
                                     false) == 0);
 
526
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
527
    g_info << "Deleting all records..." << endl;
 
528
    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
 
529
 
 
530
    g_info << "Restarting cluster..." << endl;
 
531
    CHECK(restarter.restartAll() == 0);
 
532
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
533
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
534
    
 
535
    ndbout << "Verifying records..." << endl;
 
536
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
537
    CHECK(count == 0);
 
538
    
 
539
    i++;
 
540
  }
 
541
 
 
542
  g_info << "runSystemRestart3 finished" << endl;  
 
543
 
 
544
  return result;
 
545
}
 
546
 
 
547
int runSystemRestart4(NDBT_Context* ctx, NDBT_Step* step){
 
548
  Ndb* pNdb = GETNDB(step);
 
549
  int result = NDBT_OK;
 
550
  int timeout = 300;
 
551
  Uint32 loops = ctx->getNumLoops();
 
552
  int records = ctx->getNumRecords();
 
553
  int count;
 
554
  NdbRestarter restarter;
 
555
  Uint32 i = 1;
 
556
 
 
557
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
558
  if(nodeCount < 2){
 
559
    g_info << "SR4 - Needs atleast 2 nodes to test" << endl;
 
560
    return NDBT_OK;
 
561
  }
 
562
 
 
563
  Vector<int> nodeIds;
 
564
  for(i = 0; i<nodeCount; i++)
 
565
    nodeIds.push_back(restarter.getDbNodeId(i));
 
566
  
 
567
  Uint32 currentRestartNodeIndex = 0;
 
568
  UtilTransactions utilTrans(*ctx->getTab());
 
569
  HugoTransactions hugoTrans(*ctx->getTab());
 
570
 
 
571
  {
 
572
    int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
573
    if(restarter.dumpStateAllNodes(&val, 1) != 0){
 
574
      g_err << "ERR: "<< step->getName() 
 
575
            << " failed on line " << __LINE__ << endl; 
 
576
      return NDBT_FAILED;
 
577
    }
 
578
  }
 
579
  
 
580
  while(i<=loops && result != NDBT_FAILED){
 
581
    
 
582
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
583
    /**
 
584
     * 1. Load data
 
585
     * 2. Restart 1 node -nostart
 
586
     * 3. Update records
 
587
     * 4. Restart cluster and verify records
 
588
     * 5. Restart 1 node -nostart
 
589
     * 6. Delete half of the records
 
590
     * 7. Restart cluster and verify records
 
591
     * 8. Restart 1 node -nostart
 
592
     * 9. Delete all records
 
593
     * 10. Restart cluster and verify records
 
594
     */
 
595
    g_info << "Loading records..." << endl;
 
596
    CHECK(hugoTrans.loadTable(pNdb, records) == 0);
 
597
 
 
598
    /*** 1 ***/
 
599
    g_info << "1 - Stopping one node" << endl;
 
600
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
601
                                     false, 
 
602
                                     true,
 
603
                                     false) == 0);
 
604
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
605
 
 
606
    g_info << "Updating records..." << endl;
 
607
    CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
 
608
    
 
609
    g_info << "Restarting cluster..." << endl;
 
610
    CHECK(restarter.restartAll() == 0);
 
611
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
612
    {
 
613
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
614
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
615
    }
 
616
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
617
 
 
618
    g_info << "Verifying records..." << endl;
 
619
    CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
 
620
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
621
    CHECK(count == records);
 
622
 
 
623
    g_info << "2 - Stopping one node" << endl;
 
624
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
625
                                     false, 
 
626
                                     true,
 
627
                                     false) == 0);
 
628
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
629
 
 
630
    g_info << "Deleting 50% of records..." << endl;
 
631
    CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
 
632
    
 
633
    g_info << "Restarting cluster..." << endl;
 
634
    CHECK(restarter.restartAll() == 0);
 
635
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
636
    {
 
637
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
638
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
639
    }
 
640
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
641
 
 
642
    g_info << "Verifying records..." << endl;
 
643
    CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
 
644
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
645
    CHECK(count == (records/2));
 
646
 
 
647
    g_info << "3 - Stopping one node" << endl;
 
648
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
649
                                     false, 
 
650
                                     true,
 
651
                                     false) == 0);
 
652
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
653
    g_info << "Deleting all records..." << endl;
 
654
    CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
 
655
 
 
656
    g_info << "Restarting cluster..." << endl;
 
657
    CHECK(restarter.restartAll() == 0);
 
658
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
659
    {
 
660
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
661
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
662
    }
 
663
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
664
    
 
665
    ndbout << "Verifying records..." << endl;
 
666
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
667
    CHECK(count == 0);
 
668
    
 
669
    i++;
 
670
  }
 
671
 
 
672
  g_info << "runSystemRestart4 finished" << endl;  
 
673
 
 
674
  return result;
 
675
}
 
676
 
 
677
int runSystemRestart5(NDBT_Context* ctx, NDBT_Step* step){
 
678
  Ndb* pNdb = GETNDB(step);
 
679
  int result = NDBT_OK;
 
680
  int timeout = 300;
 
681
  Uint32 loops = ctx->getNumLoops();
 
682
  int records = ctx->getNumRecords();
 
683
  int count;
 
684
  NdbRestarter restarter;
 
685
  Uint32 i = 1;
 
686
 
 
687
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
688
  if(nodeCount < 2){
 
689
    g_info << "SR5 - Needs atleast 2 nodes to test" << endl;
 
690
    return NDBT_OK;
 
691
  }
 
692
 
 
693
  Vector<int> nodeIds;
 
694
  for(i = 0; i<nodeCount; i++)
 
695
    nodeIds.push_back(restarter.getDbNodeId(i));
 
696
  
 
697
  Uint32 currentRestartNodeIndex = 0;
 
698
  UtilTransactions utilTrans(*ctx->getTab());
 
699
  HugoTransactions hugoTrans(*ctx->getTab());
 
700
 
 
701
  {
 
702
    int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
703
    if(restarter.dumpStateAllNodes(&val, 1) != 0){
 
704
      g_err << "ERR: "<< step->getName() 
 
705
            << " failed on line " << __LINE__ << endl; 
 
706
      return NDBT_FAILED;
 
707
    }
 
708
  }
 
709
  
 
710
  while(i<=loops && result != NDBT_FAILED){
 
711
    
 
712
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
713
    /**
 
714
     * 1. Load data
 
715
     * 2. Restart 1 node -nostart
 
716
     * 3. Update records
 
717
     * 4. Restart cluster and verify records
 
718
     * 5. Restart 1 node -nostart
 
719
     * 6. Delete half of the records
 
720
     * 7. Restart cluster and verify records
 
721
     * 8. Restart 1 node -nostart
 
722
     * 9. Delete all records
 
723
     * 10. Restart cluster and verify records
 
724
     */
 
725
    g_info << "Loading records..." << endl;
 
726
    hugoTrans.loadTable(pNdb, records);
 
727
 
 
728
    /*** 1 ***/
 
729
    g_info << "1 - Stopping one node" << endl;
 
730
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
731
                                     false, 
 
732
                                     true,
 
733
                                     false) == 0);
 
734
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
735
 
 
736
    g_info << "Updating records..." << endl;
 
737
    hugoTrans.pkUpdateRecords(pNdb, records);
 
738
    
 
739
    g_info << "Restarting cluster..." << endl;
 
740
    CHECK(restarter.restartAll(false, false, true) == 0);
 
741
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
742
    {
 
743
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
744
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
745
    }
 
746
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
747
 
 
748
    g_info << "Verifying records..." << endl;
 
749
    hugoTrans.pkReadRecords(pNdb, records);
 
750
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
751
    //CHECK(count == records);
 
752
 
 
753
    g_info << "2 - Stopping one node" << endl;
 
754
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
755
                                     false, 
 
756
                                     true,
 
757
                                     false) == 0);
 
758
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
759
 
 
760
    g_info << "Deleting 50% of records..." << endl;
 
761
    hugoTrans.pkDelRecords(pNdb, records/2);
 
762
    
 
763
    g_info << "Restarting cluster..." << endl;
 
764
    CHECK(restarter.restartAll(false, false, true) == 0);
 
765
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
766
    {
 
767
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
768
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
769
    }
 
770
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
771
 
 
772
    g_info << "Verifying records..." << endl;
 
773
    hugoTrans.scanReadRecords(pNdb, records/2, 0, 64);
 
774
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
775
    //CHECK(count == (records/2));
 
776
 
 
777
    g_info << "3 - Stopping one node" << endl;
 
778
    CHECK(restarter.restartOneDbNode(nodeIds[currentRestartNodeIndex],
 
779
                                     false, 
 
780
                                     true,
 
781
                                     false) == 0);
 
782
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
783
    g_info << "Deleting all records..." << endl;
 
784
    utilTrans.clearTable(pNdb, records/2);
 
785
 
 
786
    g_info << "Restarting cluster..." << endl;
 
787
    CHECK(restarter.restartAll(false, false, true) == 0);
 
788
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
789
    {
 
790
      int val = DumpStateOrd::DihMinTimeBetweenLCP;
 
791
      CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
792
    }
 
793
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
794
    
 
795
    ndbout << "Verifying records..." << endl;
 
796
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
797
    //CHECK(count == 0);
 
798
    
 
799
    CHECK(utilTrans.clearTable(pNdb) == 0);    
 
800
    i++;
 
801
  }
 
802
 
 
803
  g_info << "runSystemRestart5 finished" << endl;  
 
804
 
 
805
  return result;
 
806
}
 
807
 
 
808
int runSystemRestart6(NDBT_Context* ctx, NDBT_Step* step){
 
809
  Ndb* pNdb = GETNDB(step);
 
810
  int result = NDBT_OK;
 
811
  int timeout = 300;
 
812
  Uint32 loops = ctx->getNumLoops();
 
813
  int records = ctx->getNumRecords();
 
814
  NdbRestarter restarter;
 
815
  Uint32 i = 1;
 
816
 
 
817
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
818
  if(nodeCount < 2){
 
819
    g_info << "SR6 - Needs atleast 2 nodes to test" << endl;
 
820
    return NDBT_OK;
 
821
  }
 
822
 
 
823
  Vector<int> nodeIds;
 
824
  for(i = 0; i<nodeCount; i++)
 
825
    nodeIds.push_back(restarter.getDbNodeId(i));
 
826
  
 
827
  Uint32 currentRestartNodeIndex = 0;
 
828
  UtilTransactions utilTrans(*ctx->getTab());
 
829
  HugoTransactions hugoTrans(*ctx->getTab());
 
830
 
 
831
  while(i<=loops && result != NDBT_FAILED){
 
832
    
 
833
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
834
    /**
 
835
     * 1. Load data
 
836
     * 2. Restart all node -nostart
 
837
     * 3. Restart some nodes -i -nostart
 
838
     * 4. Start all nodes verify records
 
839
     */
 
840
    g_info << "Loading records..." << endl;
 
841
    hugoTrans.loadTable(pNdb, records);
 
842
 
 
843
    CHECK(restarter.restartAll(false, true, false) == 0);
 
844
 
 
845
    Uint32 nodeId = nodeIds[currentRestartNodeIndex];
 
846
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
847
    
 
848
    CHECK(restarter.restartOneDbNode(nodeId, true, true,false) == 0);
 
849
    CHECK(restarter.waitClusterNoStart(timeout) == 0);
 
850
    CHECK(restarter.startAll() == 0);
 
851
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
852
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
853
    int count = records - 1;
 
854
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
855
    CHECK(count == records);
 
856
    CHECK(utilTrans.clearTable(pNdb) == 0);    
 
857
    i++;
 
858
  }
 
859
 
 
860
  g_info << "runSystemRestart6 finished" << endl;  
 
861
 
 
862
  return result;
 
863
}
 
864
 
 
865
int runSystemRestart7(NDBT_Context* ctx, NDBT_Step* step){
 
866
  Ndb* pNdb = GETNDB(step);
 
867
  int result = NDBT_OK;
 
868
  Uint32 loops = ctx->getNumLoops();
 
869
  int records = ctx->getNumRecords();
 
870
  NdbRestarter restarter;
 
871
  Uint32 i = 1;
 
872
 
 
873
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
874
  if(nodeCount < 2){
 
875
    g_info << "SR7 - Needs atleast 2 nodes to test" << endl;
 
876
    return NDBT_OK;
 
877
  }
 
878
 
 
879
  Vector<int> nodeIds;
 
880
  for(i = 0; i<nodeCount; i++)
 
881
    nodeIds.push_back(restarter.getDbNodeId(i));
 
882
 
 
883
  int a_nodeIds[64];
 
884
  if(nodeCount > 64)
 
885
    abort();
 
886
 
 
887
  Uint32 currentRestartNodeIndex = 1;
 
888
  UtilTransactions utilTrans(*ctx->getTab());
 
889
  HugoTransactions hugoTrans(*ctx->getTab());
 
890
 
 
891
  while(i<=loops && result != NDBT_FAILED){
 
892
    
 
893
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
894
    /**
 
895
     * 1. Load data
 
896
     * 2. Restart all node -nostart
 
897
     * 3. Start all but one node
 
898
     * 4. Wait for startphase >= 2
 
899
     * 5. Start last node
 
900
     * 6. Verify records
 
901
     */
 
902
    g_info << "Loading records..." << endl;
 
903
    hugoTrans.loadTable(pNdb, records);
 
904
    
 
905
    CHECK(restarter.restartAll(false, true, false) == 0);
 
906
    
 
907
    int nodeId = nodeIds[currentRestartNodeIndex];
 
908
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
909
 
 
910
    Uint32 j = 0;
 
911
    for(Uint32 k = 0; k<nodeCount; k++){
 
912
      if(nodeIds[k] != nodeId){
 
913
        a_nodeIds[j++] = nodeIds[k];
 
914
      }
 
915
    }
 
916
 
 
917
    CHECK(restarter.startNodes(a_nodeIds, nodeCount - 1) == 0);
 
918
    CHECK(restarter.waitNodesStarted(a_nodeIds, nodeCount - 1, 120) == 0);
 
919
    CHECK(pNdb->waitUntilReady(5) == 0);
 
920
    int count = records - 1;
 
921
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
922
    CHECK(count == records);
 
923
    
 
924
    CHECK(restarter.startNodes(&nodeId, 1) == 0);
 
925
    CHECK(restarter.waitNodesStarted(&nodeId, 1, 120) == 0);
 
926
    
 
927
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
928
    CHECK(count == records);
 
929
    CHECK(utilTrans.clearTable(pNdb) == 0);    
 
930
 
 
931
    i++;
 
932
  }
 
933
  
 
934
  g_info << "runSystemRestart7 finished" << endl;  
 
935
 
 
936
  return result;
 
937
}
 
938
 
 
939
int runSystemRestart8(NDBT_Context* ctx, NDBT_Step* step){
 
940
  Ndb* pNdb = GETNDB(step);
 
941
  int result = NDBT_OK;
 
942
  int timeout = 300;
 
943
  Uint32 loops = ctx->getNumLoops();
 
944
  int records = ctx->getNumRecords();
 
945
  NdbRestarter restarter;
 
946
  Uint32 i = 1;
 
947
 
 
948
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
949
  if(nodeCount < 2){
 
950
    g_info << "SR8 - Needs atleast 2 nodes to test" << endl;
 
951
    return NDBT_OK;
 
952
  }
 
953
 
 
954
  Vector<int> nodeIds;
 
955
  for(i = 0; i<nodeCount; i++)
 
956
    nodeIds.push_back(restarter.getDbNodeId(i));
 
957
 
 
958
  int a_nodeIds[64];
 
959
  if(nodeCount > 64)
 
960
    abort();
 
961
 
 
962
  Uint32 currentRestartNodeIndex = 1;
 
963
  UtilTransactions utilTrans(*ctx->getTab());
 
964
  HugoTransactions hugoTrans(*ctx->getTab());
 
965
 
 
966
  while(i<=loops && result != NDBT_FAILED){
 
967
    
 
968
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
969
    /**
 
970
     * 1. Load data
 
971
     * 2. Restart all node -nostart
 
972
     * 3. Start all but one node
 
973
     * 4. Verify records
 
974
     * 5. Start last node
 
975
     * 6. Verify records
 
976
     */
 
977
    g_info << "Loading records..." << endl;
 
978
    hugoTrans.loadTable(pNdb, records);
 
979
    
 
980
    CHECK(restarter.restartAll(false, true, false) == 0);
 
981
    
 
982
    int nodeId = nodeIds[currentRestartNodeIndex];
 
983
    currentRestartNodeIndex = (currentRestartNodeIndex + 1 ) % nodeCount;
 
984
 
 
985
    Uint32 j = 0;
 
986
    for(Uint32 k = 0; k<nodeCount; k++){
 
987
      if(nodeIds[k] != nodeId){
 
988
        a_nodeIds[j++] = nodeIds[k];
 
989
      }
 
990
    }
 
991
    
 
992
    CHECK(restarter.startNodes(a_nodeIds, nodeCount-1) == 0);
 
993
    CHECK(restarter.waitNodesStartPhase(a_nodeIds, nodeCount-1, 3, 120) == 0);
 
994
    CHECK(restarter.startNodes(&nodeId, 1) == 0);
 
995
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
996
    
 
997
    int count = records - 1;
 
998
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
999
    CHECK(count == records);
 
1000
    CHECK(utilTrans.clearTable(pNdb) == 0);    
 
1001
    i++;
 
1002
  }
 
1003
  
 
1004
  g_info << "runSystemRestart8 finished" << endl;  
 
1005
 
 
1006
  return result;
 
1007
}
 
1008
 
 
1009
int runSystemRestart9(NDBT_Context* ctx, NDBT_Step* step){
 
1010
  Ndb* pNdb = GETNDB(step);
 
1011
  int result = NDBT_OK;
 
1012
  int timeout = 300;
 
1013
  Uint32 loops = ctx->getNumLoops();
 
1014
  int records = ctx->getNumRecords();
 
1015
  NdbRestarter restarter;
 
1016
  Uint32 i = 1;
 
1017
  
 
1018
  Uint32 currentRestartNodeIndex = 1;
 
1019
  UtilTransactions utilTrans(*ctx->getTab());
 
1020
  HugoTransactions hugoTrans(*ctx->getTab());
 
1021
 
 
1022
  int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
 
1023
  int dump[] = { DumpStateOrd::DihStartLcpImmediately };
 
1024
  
 
1025
  do {
 
1026
    CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
 
1027
    
 
1028
    HugoOperations ops(* ctx->getTab());
 
1029
    CHECK(ops.startTransaction(pNdb) == 0);
 
1030
    for(i = 0; i<10; i++){
 
1031
      CHECK(ops.pkInsertRecord(pNdb, i, 1, 1) == 0);
 
1032
      CHECK(ops.execute_NoCommit(pNdb) == 0);
 
1033
    }
 
1034
    for(i = 0; i<10; i++){
 
1035
      CHECK(ops.pkUpdateRecord(pNdb, i, 1) == 0);
 
1036
      CHECK(ops.execute_NoCommit(pNdb) == 0);
 
1037
    }
 
1038
    NdbSleep_SecSleep(10);
 
1039
    CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
 
1040
    NdbSleep_SecSleep(10);
 
1041
    CHECK(ops.execute_Commit(pNdb) == 0);  
 
1042
    
 
1043
    CHECK(restarter.restartAll() == 0);
 
1044
    CHECK(restarter.waitClusterStarted(timeout) == 0);
 
1045
    CHECK(pNdb->waitUntilReady(timeout) == 0);
 
1046
    ops.closeTransaction(pNdb);
 
1047
  } while(0);
 
1048
  
 
1049
  g_info << "runSystemRestart9 finished" << endl;  
 
1050
 
 
1051
  return result;
 
1052
}
 
1053
 
 
1054
int runBug18385(NDBT_Context* ctx, NDBT_Step* step){
 
1055
  NdbRestarter restarter;
 
1056
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
1057
  if(nodeCount < 2){
 
1058
    g_info << "Bug18385 - Needs atleast 2 nodes to test" << endl;
 
1059
    return NDBT_OK;
 
1060
  }
 
1061
 
 
1062
  int node1 = restarter.getDbNodeId(rand() % nodeCount);
 
1063
  int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
 
1064
 
 
1065
  if (node1 == -1 || node2 == -1)
 
1066
    return NDBT_OK;
 
1067
  
 
1068
  int dump[] = { DumpStateOrd::DihSetTimeBetweenGcp, 300 };
 
1069
  
 
1070
  int result = NDBT_OK;
 
1071
  do {
 
1072
    CHECK(restarter.dumpStateAllNodes(dump, 2) == 0);
 
1073
    CHECK(restarter.restartOneDbNode(node1, false, true, false) == 0);
 
1074
    NdbSleep_SecSleep(3);
 
1075
    CHECK(restarter.restartAll(false, true, false) == 0);
 
1076
    
 
1077
    Uint32 cnt = 0;
 
1078
    int nodes[128];
 
1079
    for(Uint32 i = 0; i<nodeCount; i++)
 
1080
      if ((nodes[cnt] = restarter.getDbNodeId(i)) != node2)
 
1081
        cnt++;
 
1082
    
 
1083
    assert(cnt == nodeCount - 1);
 
1084
    
 
1085
    CHECK(restarter.startNodes(nodes, cnt) == 0);
 
1086
    CHECK(restarter.waitNodesStarted(nodes, cnt, 300) == 0);
 
1087
    
 
1088
    CHECK(restarter.insertErrorInNode(node2, 7170) == 0);
 
1089
    CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);
 
1090
    CHECK(restarter.restartOneDbNode(node2, true, false, true) == 0);
 
1091
    CHECK(restarter.waitNodesStarted(&node2, 1) == 0);
 
1092
 
 
1093
  } while(0);
 
1094
  
 
1095
  g_info << "Bug18385 finished" << endl;  
 
1096
  
 
1097
  return result;
 
1098
}
 
1099
 
 
1100
int runWaitStarted(NDBT_Context* ctx, NDBT_Step* step){
 
1101
 
 
1102
  NdbRestarter restarter;
 
1103
  restarter.waitClusterStarted(300);
 
1104
 
 
1105
  NdbSleep_SecSleep(3);
 
1106
  return NDBT_OK;
 
1107
}
 
1108
 
 
1109
int runClearTable(NDBT_Context* ctx, NDBT_Step* step){
 
1110
  int records = ctx->getNumRecords();
 
1111
  
 
1112
  Ndb* pNdb = GETNDB(step);
 
1113
  if(pNdb->waitUntilReady(5) != 0){
 
1114
    return NDBT_FAILED;
 
1115
  }
 
1116
 
 
1117
  UtilTransactions utilTrans(*ctx->getTab());  
 
1118
  if (utilTrans.clearTable2(pNdb,  records) != 0){
 
1119
    return NDBT_FAILED;
 
1120
  }
 
1121
  return NDBT_OK;
 
1122
}
 
1123
 
 
1124
int 
 
1125
runBug21536(NDBT_Context* ctx, NDBT_Step* step)
 
1126
{
 
1127
  NdbRestarter restarter;
 
1128
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
1129
  if(nodeCount != 2){
 
1130
    g_info << "Bug21536 - 2 nodes to test" << endl;
 
1131
    return NDBT_OK;
 
1132
  }
 
1133
 
 
1134
  int node1 = restarter.getDbNodeId(rand() % nodeCount);
 
1135
  int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
 
1136
 
 
1137
  if (node1 == -1 || node2 == -1)
 
1138
    return NDBT_OK;
 
1139
  
 
1140
  int result = NDBT_OK;
 
1141
  do {
 
1142
    CHECK(restarter.restartOneDbNode(node1, false, true, true) == 0);
 
1143
    CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);    
 
1144
    CHECK(restarter.insertErrorInNode(node1, 1000) == 0);    
 
1145
    int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
 
1146
    CHECK(restarter.dumpStateOneNode(node1, val2, 2) == 0);
 
1147
    CHECK(restarter.startNodes(&node1, 1) == 0);    
 
1148
    restarter.waitNodesStartPhase(&node1, 1, 3, 120);
 
1149
    CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);    
 
1150
    
 
1151
    CHECK(restarter.restartOneDbNode(node2, true, true, true) == 0);
 
1152
    CHECK(restarter.waitNodesNoStart(&node2, 1) == 0);    
 
1153
    CHECK(restarter.startNodes(&node1, 1) == 0);   
 
1154
    CHECK(restarter.waitNodesStarted(&node1, 1) == 0);
 
1155
    CHECK(restarter.startNodes(&node2, 1) == 0);   
 
1156
    CHECK(restarter.waitClusterStarted() == 0);
 
1157
 
 
1158
  } while(0);
 
1159
  
 
1160
  g_info << "Bug21536 finished" << endl;  
 
1161
  
 
1162
  return result;
 
1163
}
 
1164
 
 
1165
int 
 
1166
runBug24664(NDBT_Context* ctx, NDBT_Step* step)
 
1167
{
 
1168
  int result = NDBT_OK;
 
1169
  NdbRestarter restarter;
 
1170
  Ndb* pNdb = GETNDB(step);
 
1171
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
1172
 
 
1173
  int records = ctx->getNumRecords();
 
1174
  UtilTransactions utilTrans(*ctx->getTab());
 
1175
  HugoTransactions hugoTrans(*ctx->getTab());
 
1176
 
 
1177
  int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
 
1178
  int dump[] = { DumpStateOrd::DihStartLcpImmediately };
 
1179
  
 
1180
  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
 
1181
  NdbLogEventHandle handle = 
 
1182
    ndb_mgm_create_logevent_handle(restarter.handle, filter);
 
1183
 
 
1184
  struct ndb_logevent event;
 
1185
 
 
1186
  do {
 
1187
    CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
 
1188
    CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
 
1189
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1190
          event.type != NDB_LE_LocalCheckpointStarted);
 
1191
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1192
          event.type != NDB_LE_LocalCheckpointCompleted);
 
1193
    
 
1194
    if (hugoTrans.loadTable(GETNDB(step), records) != 0){
 
1195
      return NDBT_FAILED;
 
1196
    }
 
1197
  
 
1198
    restarter.insertErrorInAllNodes(10036); // Hang LCP
 
1199
    CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
 
1200
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1201
          event.type != NDB_LE_LocalCheckpointStarted);
 
1202
    NdbSleep_SecSleep(3);
 
1203
    CHECK(utilTrans.clearTable(pNdb,  records) == 0);
 
1204
    if (hugoTrans.loadTable(GETNDB(step), records) != 0){
 
1205
      return NDBT_FAILED;
 
1206
    }
 
1207
 
 
1208
    restarter.insertErrorInAllNodes(10037); // Resume LCP
 
1209
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1210
          event.type != NDB_LE_LocalCheckpointCompleted);
 
1211
 
 
1212
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1213
          event.type != NDB_LE_GlobalCheckpointCompleted);
 
1214
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1215
          event.type != NDB_LE_GlobalCheckpointCompleted);
 
1216
    restarter.restartAll(false, false, true);
 
1217
    CHECK(restarter.waitClusterStarted() == 0);
 
1218
  } while(false);
 
1219
  
 
1220
  return result;
 
1221
}
 
1222
 
 
1223
int 
 
1224
runBug29167(NDBT_Context* ctx, NDBT_Step* step)
 
1225
{
 
1226
  int result = NDBT_OK;
 
1227
  NdbRestarter restarter;
 
1228
  Ndb* pNdb = GETNDB(step);
 
1229
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
1230
 
 
1231
  if (nodeCount < 2)
 
1232
    return NDBT_OK;
 
1233
 
 
1234
  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
 
1235
  NdbLogEventHandle handle = 
 
1236
    ndb_mgm_create_logevent_handle(restarter.handle, filter);
 
1237
 
 
1238
  struct ndb_logevent event;
 
1239
  int master = restarter.getMasterNodeId();
 
1240
  do {
 
1241
    int node1 = restarter.getRandomNodeOtherNodeGroup(master, rand());
 
1242
    int node2 = restarter.getRandomNodeSameNodeGroup(node1, rand());
 
1243
    
 
1244
    int val2[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };    
 
1245
    restarter.dumpStateAllNodes(val2, 2);
 
1246
    int dump[] = { DumpStateOrd::DihSetTimeBetweenGcp, 30000 };
 
1247
    restarter.dumpStateAllNodes(dump, 2);
 
1248
    
 
1249
    while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1250
          event.type != NDB_LE_GlobalCheckpointCompleted);
 
1251
    
 
1252
    CHECK(restarter.insertErrorInAllNodes(932) == 0);
 
1253
    
 
1254
    CHECK(restarter.insertErrorInNode(node1, 7183) == 0);
 
1255
    CHECK(restarter.insertErrorInNode(node2, 7183) == 0);
 
1256
 
 
1257
    CHECK(restarter.waitClusterNoStart() == 0);
 
1258
    restarter.startAll();
 
1259
    CHECK(restarter.waitClusterStarted() == 0);  
 
1260
  } while(false);
 
1261
  
 
1262
  return result;
 
1263
}
 
1264
 
 
1265
int
 
1266
runBug28770(NDBT_Context* ctx, NDBT_Step* step) {
 
1267
  Ndb* pNdb = GETNDB(step);
 
1268
  NdbRestarter restarter;
 
1269
  int result = NDBT_OK;
 
1270
  int count = 0;
 
1271
  Uint32 i = 0;
 
1272
  Uint32 loops = ctx->getNumLoops();
 
1273
  int records = ctx->getNumRecords();
 
1274
  UtilTransactions utilTrans(*ctx->getTab());
 
1275
  HugoTransactions hugoTrans(*ctx->getTab());
 
1276
 
 
1277
  g_info << "Loading records..." << endl;  hugoTrans.loadTable(pNdb, 
 
1278
 records);
 
1279
 
 
1280
 
 
1281
  while(i<=loops && result != NDBT_FAILED){
 
1282
    g_info << "Loop " << i << "/"<< loops <<" started" << endl;
 
1283
    CHECK(restarter.restartAll(false, true, false) == 0);
 
1284
    NdbSleep_SecSleep(3);
 
1285
    CHECK(restarter.waitClusterNoStart() == 0);
 
1286
    restarter.insertErrorInAllNodes(6007);
 
1287
    CHECK(restarter.startAll()== 0);
 
1288
    CHECK(restarter.waitClusterStarted() == 0);
 
1289
    CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
 
1290
    CHECK(count == records);
 
1291
    i++;
 
1292
  }
 
1293
  ndbout << " runBug28770 finished" << endl;
 
1294
  return result;
 
1295
}
 
1296
 
 
1297
int
 
1298
runStopper(NDBT_Context* ctx, NDBT_Step* step)
 
1299
{
 
1300
  NdbRestarter restarter;
 
1301
  Uint32 stop = 0;
 
1302
loop:
 
1303
  while (!ctx->isTestStopped() && 
 
1304
         ((stop = ctx->getProperty("StopAbort", Uint32(0))) == 0))
 
1305
  {
 
1306
    NdbSleep_MilliSleep(30);
 
1307
  }
 
1308
 
 
1309
  if (ctx->isTestStopped())
 
1310
  {
 
1311
    return NDBT_OK;
 
1312
  }
 
1313
  
 
1314
  ndbout << "Killing in " << stop << "ms..." << flush;
 
1315
  NdbSleep_MilliSleep(stop);
 
1316
  restarter.restartAll(false, true, true);
 
1317
  ctx->setProperty("StopAbort", Uint32(0));
 
1318
  goto loop;
 
1319
}
 
1320
 
 
1321
int runSR_DD_1(NDBT_Context* ctx, NDBT_Step* step)
 
1322
{
 
1323
  Ndb* pNdb = GETNDB(step);
 
1324
  int result = NDBT_OK;
 
1325
  Uint32 loops = ctx->getNumLoops();
 
1326
  int count;
 
1327
  NdbRestarter restarter;
 
1328
  NdbBackup backup(GETNDB(step)->getNodeId()+1);
 
1329
  bool lcploop = ctx->getProperty("LCP", (unsigned)0);
 
1330
  bool all = ctx->getProperty("ALL", (unsigned)0);
 
1331
 
 
1332
  Uint32 i = 1;
 
1333
  Uint32 backupId;
 
1334
 
 
1335
  int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
 
1336
  int lcp = DumpStateOrd::DihMinTimeBetweenLCP;
 
1337
 
 
1338
  int startFrom = 0;
 
1339
 
 
1340
  HugoTransactions hugoTrans(*ctx->getTab());
 
1341
  while(i<=loops && result != NDBT_FAILED)
 
1342
  {
 
1343
 
 
1344
    if (lcploop)
 
1345
    {
 
1346
      CHECK(restarter.dumpStateAllNodes(&lcp, 1) == 0);
 
1347
    }
 
1348
 
 
1349
    int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
 
1350
    //CHECK(restarter.dumpStateAllNodes(&val, 1) == 0);
 
1351
    
 
1352
    ndbout << "Loop " << i << "/"<< loops <<" started" << endl;
 
1353
    ndbout << "Loading records..." << startFrom << endl;
 
1354
    CHECK(hugoTrans.loadTable(pNdb, startFrom) == 0);
 
1355
 
 
1356
    if (!all)
 
1357
    {
 
1358
      ndbout << "Making " << nodeId << " crash" << endl;
 
1359
      int kill[] = { 9999, 1000, 3000 };
 
1360
      CHECK(restarter.dumpStateOneNode(nodeId, val, 2) == 0);
 
1361
      CHECK(restarter.dumpStateOneNode(nodeId, kill, 3) == 0);
 
1362
    }
 
1363
    else
 
1364
    {
 
1365
      ndbout << "Crashing cluster" << endl;
 
1366
      ctx->setProperty("StopAbort", 1000 + rand() % (3000 - 1000));
 
1367
    }
 
1368
    Uint64 end = NdbTick_CurrentMillisecond() + 4000;
 
1369
    Uint32 row = startFrom;
 
1370
    do {
 
1371
      ndbout << "Loading from " << row << " to " << row + 1000 << endl;
 
1372
      if (hugoTrans.loadTableStartFrom(pNdb, row, 1000) != 0)
 
1373
        break;
 
1374
      row += 1000;
 
1375
    } while (NdbTick_CurrentMillisecond() < end);
 
1376
 
 
1377
    if (!all)
 
1378
    {
 
1379
      ndbout << "Waiting for " << nodeId << " to restart" << endl;
 
1380
      CHECK(restarter.waitNodesNoStart(&nodeId, 1) == 0);
 
1381
      ndbout << "Restarting cluster" << endl;
 
1382
      CHECK(restarter.restartAll(false, true, true) == 0);
 
1383
    }
 
1384
    else
 
1385
    {
 
1386
      ndbout << "Waiting for cluster to restart" << endl;
 
1387
    }
 
1388
    CHECK(restarter.waitClusterNoStart() == 0);
 
1389
    CHECK(restarter.startAll() == 0);
 
1390
    CHECK(restarter.waitClusterStarted() == 0);
 
1391
    
 
1392
    ndbout << "Starting backup..." << flush;
 
1393
    CHECK(backup.start(backupId) == 0);
 
1394
    ndbout << "done" << endl;
 
1395
 
 
1396
    int cnt = 0;
 
1397
    CHECK(hugoTrans.selectCount(pNdb, 0, &cnt) == 0);
 
1398
    ndbout << "Found " << cnt << " records..." << endl;
 
1399
    ndbout << "Clearing..." << endl;    
 
1400
    CHECK(hugoTrans.clearTable(pNdb,
 
1401
                               NdbScanOperation::SF_TupScan, cnt) == 0);
 
1402
    
 
1403
    if (cnt > startFrom)
 
1404
    {
 
1405
      startFrom = cnt;
 
1406
    }
 
1407
    startFrom += 1000;
 
1408
    i++;
 
1409
  }
 
1410
  
 
1411
  ndbout << "runSR_DD_1 finished" << endl;  
 
1412
  ctx->stopTest();
 
1413
  return result;
 
1414
}
 
1415
 
 
1416
int runSR_DD_2(NDBT_Context* ctx, NDBT_Step* step)
 
1417
{
 
1418
  Ndb* pNdb = GETNDB(step);
 
1419
  int result = NDBT_OK;
 
1420
  Uint32 loops = ctx->getNumLoops();
 
1421
  Uint32 rows = ctx->getNumRecords();
 
1422
  int count;
 
1423
  NdbRestarter restarter;
 
1424
  NdbBackup backup(GETNDB(step)->getNodeId()+1);
 
1425
  bool lcploop = ctx->getProperty("LCP", (unsigned)0);
 
1426
  bool all = ctx->getProperty("ALL", (unsigned)0);
 
1427
 
 
1428
  Uint32 i = 1;
 
1429
  Uint32 backupId;
 
1430
 
 
1431
  int val[] = { DumpStateOrd::CmvmiSetRestartOnErrorInsert, 1 };
 
1432
  int lcp = DumpStateOrd::DihMinTimeBetweenLCP;
 
1433
 
 
1434
  int startFrom = 0;
 
1435
 
 
1436
  HugoTransactions hugoTrans(*ctx->getTab());
 
1437
  while(i<=loops && result != NDBT_FAILED)
 
1438
  {
 
1439
 
 
1440
    if (lcploop)
 
1441
    {
 
1442
      CHECK(restarter.dumpStateAllNodes(&lcp, 1) == 0);
 
1443
    }
 
1444
 
 
1445
    int nodeId = restarter.getDbNodeId(rand() % restarter.getNumDbNodes());
 
1446
    
 
1447
    if (!all)
 
1448
    {
 
1449
      ndbout << "Making " << nodeId << " crash" << endl;
 
1450
      int kill[] = { 9999, 3000, 10000 };
 
1451
      CHECK(restarter.dumpStateOneNode(nodeId, val, 2) == 0);
 
1452
      CHECK(restarter.dumpStateOneNode(nodeId, kill, 3) == 0);
 
1453
    }
 
1454
    else
 
1455
    {
 
1456
      ndbout << "Crashing cluster" << endl;
 
1457
      ctx->setProperty("StopAbort", 1000 + rand() % (3000 - 1000));
 
1458
    }
 
1459
 
 
1460
    Uint64 end = NdbTick_CurrentMillisecond() + 11000;
 
1461
    Uint32 row = startFrom;
 
1462
    do {
 
1463
      if (hugoTrans.loadTable(pNdb, rows) != 0)
 
1464
        break;
 
1465
      
 
1466
      if (hugoTrans.clearTable(pNdb, NdbScanOperation::SF_TupScan, rows) != 0)
 
1467
        break;
 
1468
    } while (NdbTick_CurrentMillisecond() < end);
 
1469
    
 
1470
    if (!all)
 
1471
    {
 
1472
      ndbout << "Waiting for " << nodeId << " to restart" << endl;
 
1473
      CHECK(restarter.waitNodesNoStart(&nodeId, 1) == 0);
 
1474
      ndbout << "Restarting cluster" << endl;
 
1475
      CHECK(restarter.restartAll(false, true, true) == 0);
 
1476
    }
 
1477
    else
 
1478
    {
 
1479
      ndbout << "Waiting for cluster to restart" << endl;
 
1480
    }
 
1481
 
 
1482
    CHECK(restarter.waitClusterNoStart() == 0);
 
1483
    CHECK(restarter.startAll() == 0);
 
1484
    CHECK(restarter.waitClusterStarted() == 0);
 
1485
    
 
1486
    ndbout << "Starting backup..." << flush;
 
1487
    CHECK(backup.start(backupId) == 0);
 
1488
    ndbout << "done" << endl;
 
1489
 
 
1490
    int cnt = 0;
 
1491
    CHECK(hugoTrans.selectCount(pNdb, 0, &cnt) == 0);
 
1492
    ndbout << "Found " << cnt << " records..." << endl;
 
1493
    ndbout << "Clearing..." << endl;    
 
1494
    CHECK(hugoTrans.clearTable(pNdb,
 
1495
                               NdbScanOperation::SF_TupScan, cnt) == 0);
 
1496
    i++;
 
1497
  }
 
1498
  
 
1499
  ndbout << "runSR_DD_2 finished" << endl;  
 
1500
  ctx->stopTest();  
 
1501
  return result;
 
1502
}
 
1503
 
 
1504
int runBug22696(NDBT_Context* ctx, NDBT_Step* step)
 
1505
{
 
1506
  Ndb* pNdb = GETNDB(step);
 
1507
  int result = NDBT_OK;
 
1508
  Uint32 loops = ctx->getNumLoops();
 
1509
  Uint32 rows = ctx->getNumRecords();
 
1510
  NdbRestarter restarter;
 
1511
  HugoTransactions hugoTrans(*ctx->getTab());
 
1512
 
 
1513
  Uint32 i = 0;
 
1514
  while(i<=loops && result != NDBT_FAILED)
 
1515
  {
 
1516
    for (Uint32 j = 0; j<10 && result != NDBT_FAILED; j++)
 
1517
      CHECK(hugoTrans.scanUpdateRecords(pNdb, rows) == 0);
 
1518
    
 
1519
    CHECK(restarter.restartAll(false, true, i > 0 ? true : false) == 0);
 
1520
    CHECK(restarter.waitClusterNoStart() == 0);
 
1521
    CHECK(restarter.insertErrorInAllNodes(7072) == 0);
 
1522
    CHECK(restarter.startAll() == 0);
 
1523
    CHECK(restarter.waitClusterStarted() == 0);
 
1524
 
 
1525
    i++;
 
1526
    if (i < loops)
 
1527
    {
 
1528
      NdbSleep_SecSleep(5); // Wait for a few gcp
 
1529
    }
 
1530
  }
 
1531
  
 
1532
  ctx->stopTest();  
 
1533
  return result;
 
1534
}
 
1535
 
 
1536
int 
 
1537
runBug27434(NDBT_Context* ctx, NDBT_Step* step)
 
1538
{
 
1539
  int result = NDBT_OK;
 
1540
  NdbRestarter restarter;
 
1541
  Ndb* pNdb = GETNDB(step);
 
1542
  const Uint32 nodeCount = restarter.getNumDbNodes();
 
1543
 
 
1544
  if (nodeCount < 2)
 
1545
    return NDBT_OK;
 
1546
 
 
1547
  int args[] = { DumpStateOrd::DihMaxTimeBetweenLCP };
 
1548
  int dump[] = { DumpStateOrd::DihStartLcpImmediately };
 
1549
 
 
1550
  int filter[] = { 15, NDB_MGM_EVENT_CATEGORY_CHECKPOINT, 0 };
 
1551
  NdbLogEventHandle handle = 
 
1552
    ndb_mgm_create_logevent_handle(restarter.handle, filter);
 
1553
 
 
1554
  struct ndb_logevent event;
 
1555
 
 
1556
  do {
 
1557
    int node1 = restarter.getDbNodeId(rand() % nodeCount);
 
1558
    CHECK(restarter.restartOneDbNode(node1, false, true, true) == 0);
 
1559
    NdbSleep_SecSleep(3);
 
1560
    CHECK(restarter.waitNodesNoStart(&node1, 1) == 0);
 
1561
 
 
1562
    CHECK(restarter.dumpStateAllNodes(args, 1) == 0);
 
1563
 
 
1564
    for (Uint32 i = 0; i<3; i++)
 
1565
    {
 
1566
      CHECK(restarter.dumpStateAllNodes(dump, 1) == 0);
 
1567
      while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1568
            event.type != NDB_LE_LocalCheckpointStarted);
 
1569
      while(ndb_logevent_get_next(handle, &event, 0) >= 0 &&
 
1570
            event.type != NDB_LE_LocalCheckpointCompleted);
 
1571
    }      
 
1572
    
 
1573
    restarter.restartAll(false, true, true);
 
1574
    NdbSleep_SecSleep(3);
 
1575
    CHECK(restarter.waitClusterNoStart() == 0);
 
1576
    restarter.insertErrorInNode(node1, 5046);
 
1577
    restarter.startAll();
 
1578
    CHECK(restarter.waitClusterStarted() == 0);
 
1579
  } while(false);
 
1580
  
 
1581
  return result;
 
1582
}
 
1583
 
 
1584
NDBT_TESTSUITE(testSystemRestart);
 
1585
TESTCASE("SR1", 
 
1586
         "Basic system restart test. Focus on testing restart from REDO log.\n"
 
1587
         "NOTE! Time between lcp's and gcp's should be left at default, \n"
 
1588
         "so that Ndb  uses the Redo log when restarting\n" 
 
1589
         "1. Load records\n"
 
1590
         "2. Restart cluster and verify records \n"
 
1591
         "3. Update records\n"
 
1592
         "4. Restart cluster and verify records \n"
 
1593
         "5. Delete half of the records \n"
 
1594
         "6. Restart cluster and verify records \n"
 
1595
         "7. Delete all records \n"
 
1596
         "8. Restart cluster and verify records \n"
 
1597
         "9. Insert, update, delete records \n"
 
1598
         "10. Restart cluster and verify records\n"
 
1599
         "11. Insert, update, delete records \n"
 
1600
         "12. Restart cluster with error insert 5020 and verify records\n"){ 
 
1601
  INITIALIZER(runWaitStarted);
 
1602
  STEP(runSystemRestart1);
 
1603
  FINALIZER(runClearTable);
 
1604
}
 
1605
TESTCASE("SR2", 
 
1606
         "Basic system restart test. Focus on testing restart from LCP\n"
 
1607
         "NOTE! Time between lcp's is automatically set to it's  min value\n"
 
1608
         "so that Ndb  uses LCP's when restarting.\n" 
 
1609
         "1. Load records\n"
 
1610
         "2. Restart cluster and verify records \n"
 
1611
         "3. Update records\n"
 
1612
         "4. Restart cluster and verify records \n"
 
1613
         "5. Delete half of the records \n"
 
1614
         "6. Restart cluster and verify records \n"
 
1615
         "7. Delete all records \n"
 
1616
         "8. Restart cluster and verify records \n"
 
1617
         "9. Insert, update, delete records \n"
 
1618
         "10. Restart cluster and verify records\n"){
 
1619
  INITIALIZER(runWaitStarted);
 
1620
  STEP(runSystemRestart2);
 
1621
  FINALIZER(runClearTable);
 
1622
}
 
1623
TESTCASE("SR_UNDO", 
 
1624
         "System restart test. Focus on testing of undologging\n"
 
1625
         "in DBACC and DBTUP.\n"
 
1626
         "This is done by starting a LCP, turn on undologging \n"
 
1627
         "but don't start writing the datapages. This will force all\n"
 
1628
         "operations to be written into the undolog.\n"
 
1629
         "Then write datapages and complete LCP.\n"
 
1630
         "Restart the system\n"){
 
1631
  INITIALIZER(runWaitStarted);
 
1632
  STEP(runSystemRestartTestUndoLog);
 
1633
  FINALIZER(runClearTable);
 
1634
}
 
1635
TESTCASE("SR_FULLDB", 
 
1636
         "System restart test. Test to restart when DB is full.\n"){
 
1637
  INITIALIZER(runWaitStarted);
 
1638
  STEP(runSystemRestartTestFullDb);
 
1639
  FINALIZER(runClearTable);
 
1640
}
 
1641
TESTCASE("SR3", 
 
1642
         "System restart test. Focus on testing restart from with\n"
 
1643
         "not all nodes alive when system went down\n"
 
1644
         "* 1. Load data\n"
 
1645
         "* 2. Restart 1 node -nostart\n"
 
1646
         "* 3. Update records\n"
 
1647
         "* 4. Restart cluster and verify records\n"
 
1648
         "* 5. Restart 1 node -nostart\n"
 
1649
         "* 6. Delete half of the records\n"
 
1650
         "* 7. Restart cluster and verify records\n"
 
1651
         "* 8. Restart 1 node -nostart\n"
 
1652
         "* 9. Delete all records\n"
 
1653
         "* 10. Restart cluster and verify records\n"){
 
1654
  INITIALIZER(runWaitStarted);
 
1655
  STEP(runSystemRestart3);
 
1656
  FINALIZER(runClearTable);
 
1657
}
 
1658
TESTCASE("SR4", 
 
1659
         "System restart test. Focus on testing restart from with\n"
 
1660
         "not all nodes alive when system went down but running LCP at\n"
 
1661
         "high speed so that sometimes a TO is required to start cluster\n"
 
1662
         "* 1. Load data\n"
 
1663
         "* 2. Restart 1 node -nostart\n"
 
1664
         "* 3. Update records\n"
 
1665
         "* 4. Restart cluster and verify records\n"
 
1666
         "* 5. Restart 1 node -nostart\n"
 
1667
         "* 6. Delete half of the records\n"
 
1668
         "* 7. Restart cluster and verify records\n"
 
1669
         "* 8. Restart 1 node -nostart\n"
 
1670
         "* 9. Delete all records\n"
 
1671
         "* 10. Restart cluster and verify records\n"){
 
1672
  INITIALIZER(runWaitStarted);
 
1673
  STEP(runSystemRestart4);
 
1674
  FINALIZER(runClearTable);
 
1675
}
 
1676
TESTCASE("SR5", 
 
1677
         "As SR4 but making restart aborts\n"
 
1678
         "* 1. Load data\n"
 
1679
         "* 2. Restart 1 node -nostart\n"
 
1680
         "* 3. Update records\n"
 
1681
         "* 4. Restart cluster and verify records\n"
 
1682
         "* 5. Restart 1 node -nostart\n"
 
1683
         "* 6. Delete half of the records\n"
 
1684
         "* 7. Restart cluster and verify records\n"
 
1685
         "* 8. Restart 1 node -nostart\n"
 
1686
         "* 9. Delete all records\n"
 
1687
         "* 10. Restart cluster and verify records\n"){
 
1688
  INITIALIZER(runWaitStarted);
 
1689
  STEP(runSystemRestart5);
 
1690
  FINALIZER(runClearTable);
 
1691
}
 
1692
TESTCASE("SR6", 
 
1693
         "Perform system restart with some nodes having FS others wo/\n"
 
1694
         "* 1. Load data\n"
 
1695
         "* 2. Restart all node -nostart\n"
 
1696
         "* 3. Restart some nodes -i -nostart\n"
 
1697
         "* 4. Start all nodes verify records\n"){
 
1698
  INITIALIZER(runWaitStarted);
 
1699
  INITIALIZER(runClearTable);
 
1700
  STEP(runSystemRestart6);
 
1701
  FINALIZER(runClearTable);
 
1702
}
 
1703
TESTCASE("SR7", 
 
1704
         "Perform partition win system restart\n"
 
1705
         "* 1. Load data\n"
 
1706
         "* 2. Restart all node -nostart\n"
 
1707
         "* 3. Start all but one node\n"
 
1708
         "* 4. Verify records\n"
 
1709
         "* 5. Start last node\n"
 
1710
         "* 6. Verify records\n"){
 
1711
  INITIALIZER(runWaitStarted);
 
1712
  INITIALIZER(runClearTable);
 
1713
  STEP(runSystemRestart7);
 
1714
  FINALIZER(runClearTable);
 
1715
}
 
1716
TESTCASE("SR8", 
 
1717
         "Perform partition win system restart with other nodes delayed\n"
 
1718
         "* 1. Load data\n"
 
1719
         "* 2. Restart all node -nostart\n"
 
1720
         "* 3. Start all but one node\n"
 
1721
         "* 4. Wait for startphase >= 2\n"
 
1722
         "* 5. Start last node\n"
 
1723
         "* 6. Verify records\n"){
 
1724
  INITIALIZER(runWaitStarted);
 
1725
  INITIALIZER(runClearTable);
 
1726
  STEP(runSystemRestart8);
 
1727
  FINALIZER(runClearTable);
 
1728
}
 
1729
TESTCASE("SR9", 
 
1730
         "Perform partition win system restart with other nodes delayed\n"
 
1731
         "* 1. Start transaction\n"
 
1732
         "* 2. insert (1,1)\n"
 
1733
         "* 3. update (1,2)\n"
 
1734
         "* 4. start lcp\n"
 
1735
         "* 5. commit\n"
 
1736
         "* 6. restart\n"){
 
1737
  INITIALIZER(runWaitStarted);
 
1738
  INITIALIZER(runClearTable);
 
1739
  STEP(runSystemRestart9);
 
1740
  FINALIZER(runClearTable);
 
1741
}
 
1742
TESTCASE("Bug18385", 
 
1743
         "Perform partition system restart with other nodes with higher GCI"){
 
1744
  INITIALIZER(runWaitStarted);
 
1745
  INITIALIZER(runClearTable);
 
1746
  STEP(runBug18385);
 
1747
  FINALIZER(runClearTable);
 
1748
}
 
1749
TESTCASE("Bug21536", 
 
1750
         "Perform partition system restart with other nodes with higher GCI"){
 
1751
  INITIALIZER(runWaitStarted);
 
1752
  INITIALIZER(runClearTable);
 
1753
  STEP(runBug21536);
 
1754
  FINALIZER(runClearTable);
 
1755
}
 
1756
TESTCASE("Bug24664",
 
1757
         "Check handling of LCP skip/keep")
 
1758
{
 
1759
  INITIALIZER(runWaitStarted);
 
1760
  INITIALIZER(runClearTable);
 
1761
  STEP(runBug24664);
 
1762
  FINALIZER(runClearTable);
 
1763
}
 
1764
TESTCASE("Bug27434",
 
1765
         "")
 
1766
{
 
1767
  INITIALIZER(runWaitStarted);
 
1768
  STEP(runBug27434);
 
1769
}
 
1770
TESTCASE("SR_DD_1", "")
 
1771
{
 
1772
  TC_PROPERTY("ALL", 1);
 
1773
  INITIALIZER(runWaitStarted);
 
1774
  STEP(runStopper);
 
1775
  STEP(runSR_DD_1);
 
1776
  FINALIZER(runClearTable);
 
1777
}
 
1778
TESTCASE("SR_DD_1b", "")
 
1779
{
 
1780
  INITIALIZER(runWaitStarted);
 
1781
  STEP(runSR_DD_1);
 
1782
  FINALIZER(runClearTable);
 
1783
}
 
1784
TESTCASE("SR_DD_1_LCP", "")
 
1785
{
 
1786
  TC_PROPERTY("ALL", 1);
 
1787
  TC_PROPERTY("LCP", 1);
 
1788
  INITIALIZER(runWaitStarted);
 
1789
  STEP(runStopper);
 
1790
  STEP(runSR_DD_1);
 
1791
  FINALIZER(runClearTable);
 
1792
}
 
1793
TESTCASE("SR_DD_1b_LCP", "")
 
1794
{
 
1795
  TC_PROPERTY("LCP", 1);
 
1796
  INITIALIZER(runWaitStarted);
 
1797
  STEP(runSR_DD_1);
 
1798
  FINALIZER(runClearTable);
 
1799
}
 
1800
TESTCASE("SR_DD_2", "")
 
1801
{
 
1802
  TC_PROPERTY("ALL", 1);
 
1803
  INITIALIZER(runWaitStarted);
 
1804
  STEP(runStopper);
 
1805
  STEP(runSR_DD_2);
 
1806
  FINALIZER(runClearTable);
 
1807
}
 
1808
TESTCASE("SR_DD_2b", "")
 
1809
{
 
1810
  INITIALIZER(runWaitStarted);
 
1811
  STEP(runSR_DD_2);
 
1812
  FINALIZER(runClearTable);
 
1813
}
 
1814
TESTCASE("SR_DD_2_LCP", "")
 
1815
{
 
1816
  TC_PROPERTY("ALL", 1);
 
1817
  TC_PROPERTY("LCP", 1);
 
1818
  INITIALIZER(runWaitStarted);
 
1819
  STEP(runStopper);
 
1820
  STEP(runSR_DD_2);
 
1821
  FINALIZER(runClearTable);
 
1822
}
 
1823
TESTCASE("SR_DD_2b_LCP", "")
 
1824
{
 
1825
  TC_PROPERTY("LCP", 1);
 
1826
  INITIALIZER(runWaitStarted);
 
1827
  STEP(runSR_DD_2);
 
1828
  FINALIZER(runClearTable);
 
1829
}
 
1830
TESTCASE("Bug29167", "")
 
1831
{
 
1832
  INITIALIZER(runWaitStarted);
 
1833
  STEP(runBug29167);
 
1834
}
 
1835
TESTCASE("Bug28770",
 
1836
         "Check readTableFile1 fails, readTableFile2 succeeds\n"
 
1837
         "1. Restart all node -nostart\n"
 
1838
         "2. Insert error 6100 into all nodes\n"
 
1839
         "3. Start all nodes\n"
 
1840
         "4. Ensure cluster start\n"
 
1841
         "5. Read and verify reocrds\n"
 
1842
         "6. Repeat until looping is completed\n"){
 
1843
  INITIALIZER(runWaitStarted);
 
1844
  INITIALIZER(runClearTable);
 
1845
  STEP(runBug28770);
 
1846
  FINALIZER(runClearTable);
 
1847
}
 
1848
TESTCASE("Bug22696", "")
 
1849
{
 
1850
  INITIALIZER(runWaitStarted);
 
1851
  INITIALIZER(runLoadTable);
 
1852
  INITIALIZER(runBug22696);
 
1853
  FINALIZER(runClearTable);
 
1854
}
 
1855
NDBT_TESTSUITE_END(testSystemRestart);
 
1856
 
 
1857
int main(int argc, const char** argv){
 
1858
  ndb_init();
 
1859
  return testSystemRestart.execute(argc, argv);
 
1860
}
 
1861
 
 
1862