mySQL 5.0.11 sources for tomato
[tomato.git] / release / src / router / mysql / storage / ndb / test / ndbapi / testOperations.cpp
blobd002038c06db043ac8efa0a59becb476514a66fd
1 /* Copyright (c) 2003-2007 MySQL AB
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; version 2 of the License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
16 #include "NDBT_Test.hpp"
17 #include "NDBT_ReturnCodes.h"
18 #include "HugoTransactions.hpp"
19 #include "UtilTransactions.hpp"
20 #include <NdbRestarter.hpp>
22 struct OperationTestCase {
23 const char * name;
24 bool preCond; // start transaction | insert | commit
26 // start transaction
27 const char * op1;
28 const int res1;
29 const int val1;
31 // no commit
33 const char * op2;
34 const int res2;
35 const int val2;
36 // Commit
38 // start transaction
39 // op3 = READ
40 const int res3;
41 const int val3;
42 // commit transaction
45 OperationTestCase matrix[] = {
46 { "ReadRead", true, "READ", 0, 0, "READ", 0, 0, 0, 0 },
47 { "ReadReadEx", true, "READ", 0, 0, "READ-EX", 0, 0, 0, 0 },
48 { "ReadSimpleRead", true, "READ", 0, 0, "S-READ", 0, 0, 0, 0 },
49 { "ReadDirtyRead", true, "READ", 0, 0, "D-READ", 0, 0, 0, 0 },
50 { "ReadInsert", true, "READ", 0, 0, "INSERT", 630, 1, 0, 0 },
51 { "ReadUpdate", true, "READ", 0, 0, "UPDATE", 0, 1, 0, 1 },
52 { "ReadDelete", true, "READ", 0, 0, "DELETE", 0, 0, 626, 0 },
54 { "FReadRead", false, "READ", 626, 0, "READ", 626, 0, 626, 0 },
55 { "FReadReadEx", false, "READ", 626, 0, "READ-EX", 626, 0, 626, 0 },
56 { "FReadSimpleRead", false, "READ", 626, 0, "S-READ", 626, 0, 626, 0 },
57 { "FReadDirtyRead", false, "READ", 626, 0, "D-READ", 626, 0, 626, 0 },
58 { "FReadInsert", false, "READ", 626, 0, "INSERT", 0, 1, 0, 1 },
59 { "FReadUpdate", false, "READ", 626, 0, "UPDATE", 626, 0, 626, 0 },
60 { "FReadDelete", false, "READ", 626, 0, "DELETE", 626, 0, 626, 0 },
62 { "ReadExRead", true, "READ-EX", 0, 0, "READ", 0, 0, 0, 0 },
63 { "ReadExReadEx", true, "READ-EX", 0, 0, "READ-EX", 0, 0, 0, 0 },
64 { "ReadExSimpleRead", true, "READ-EX", 0, 0, "S-READ", 0, 0, 0, 0 },
65 { "ReadExDirtyRead", true, "READ-EX", 0, 0, "D-READ", 0, 0, 0, 0 },
66 { "ReadExInsert", true, "READ-EX", 0, 0, "INSERT", 630, 1, 0, 0 },
67 { "ReadExUpdate", true, "READ-EX", 0, 0, "UPDATE", 0, 1, 0, 1 },
68 { "ReadExDelete", true, "READ-EX", 0, 0, "DELETE", 0, 0, 626, 0 },
70 { "InsertRead", false, "INSERT", 0, 0, "READ", 0, 0, 0, 0 },
71 { "InsertReadEx", false, "INSERT", 0, 0, "READ-EX", 0, 0, 0, 0 },
72 { "InsertSimpleRead",false, "INSERT", 0, 0, "S-READ", 0, 0, 0, 0 },
73 { "InsertDirtyRead", false, "INSERT", 0, 0, "D-READ", 0, 0, 0, 0 },
74 { "InsertInsert", false, "INSERT", 0, 0, "INSERT", 630, 0, 626, 0 },
75 { "InsertUpdate", false, "INSERT", 0, 0, "UPDATE", 0, 1, 0, 1 },
76 { "InsertDelete", false, "INSERT", 0, 0, "DELETE", 0, 0, 626, 0 },
78 { "UpdateRead", true, "UPDATE", 0, 1, "READ", 0, 1, 0, 1 },
79 { "UpdateReadEx", true, "UPDATE", 0, 1, "READ-EX", 0, 1, 0, 1 },
80 { "UpdateSimpleRead", true, "UPDATE", 0, 1, "S-READ", 0, 1, 0, 1 },
81 { "UpdateDirtyRead", true, "UPDATE", 0, 1, "D-READ", 0, 1, 0, 1 },
82 { "UpdateInsert", true, "UPDATE", 0, 1, "INSERT", 630, 0, 0, 0 },
83 { "UpdateUpdate", true, "UPDATE", 0, 1, "UPDATE", 0, 2, 0, 2 },
84 { "UpdateDelete", true, "UPDATE", 0, 1, "DELETE", 0, 0, 626, 0 },
86 { "DeleteRead", true, "DELETE", 0, 0, "READ", 626, 0, 0, 0 },
87 { "DeleteReadEx", true, "DELETE", 0, 0, "READ-EX", 626, 0, 0, 0 },
88 { "DeleteSimpleRead", true, "DELETE", 0, 0, "S-READ", 626, 0, 0, 0 },
89 { "DeleteDirtyRead", true, "DELETE", 0, 0, "D-READ", 626, 0, 626, 0 },
90 { "DeleteInsert", true, "DELETE", 0, 0, "INSERT", 0, 1, 0, 1 },
91 { "DeleteUpdate", true, "DELETE", 0, 0, "UPDATE", 626, 1, 0, 0 },
92 { "DeleteDelete", true, "DELETE", 0, 0, "DELETE", 626, 0, 0, 0 }
95 #define CHECK(b) if (!(b)) { \
96 g_err << "ERR: "<< step->getName() \
97 << " failed on line " << __LINE__ << endl; \
98 result = NDBT_FAILED; \
99 break; }
101 #define C3(b) if (!(b)) { \
102 g_err << "ERR: failed on line " << __LINE__ << endl; \
103 return NDBT_FAILED; }
106 runOp(HugoOperations & hugoOps,
107 Ndb * pNdb,
108 const char * op,
109 int value){
111 #define C2(x, y) { int r = (x); int s = (y); if(r != s) {\
112 g_err << "ERR: failed on line " << __LINE__ << ": " \
113 << r << " != " << s << endl; \
114 return NDBT_FAILED; }}
116 if(strcmp(op, "READ") == 0){
117 C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read), 0);
118 } else if(strcmp(op, "READ-EX") == 0){
119 C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Exclusive), 0);
120 } else if(strcmp(op, "S-READ") == 0){
121 C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_Read), 0);
122 } else if(strcmp(op, "D-READ") == 0){
123 C2(hugoOps.pkReadRecord(pNdb, 1, 1, NdbOperation::LM_CommittedRead), 0);
124 } else if(strcmp(op, "INSERT") == 0){
125 C2(hugoOps.pkInsertRecord(pNdb, 1, 1, value), 0);
126 } else if(strcmp(op, "UPDATE") == 0){
127 C2(hugoOps.pkUpdateRecord(pNdb, 1, 1, value), 0);
128 } else if(strcmp(op, "DELETE") == 0){
129 C2(hugoOps.pkDeleteRecord(pNdb, 1, 1), 0);
130 } else {
131 g_err << __FILE__ << " - " << __LINE__
132 << ": Unknown operation" << op << endl;
133 return NDBT_FAILED;
136 return NDBT_OK;
140 checkVal(HugoOperations & hugoOps,
141 const char * op,
142 int value,
143 int result){
144 if(result != 0)
145 return NDBT_OK;
147 if(strcmp(op, "READ") == 0){
148 } else if(strcmp(op, "READ-EX") == 0){
149 } else if(strcmp(op, "S-READ") == 0){
150 } else if(strcmp(op, "D-READ") == 0){
151 } else {
152 return NDBT_OK;
155 return hugoOps.verifyUpdatesValue(value);
158 int
159 runTwoOperations(NDBT_Context* ctx, NDBT_Step* step){
160 int result = NDBT_OK;
161 HugoOperations hugoOps(*ctx->getTab());
162 Ndb* pNdb = GETNDB(step);
164 const char * op1 = ctx->getProperty("op1", "NONE");
165 const int val1 = ctx->getProperty("val1", ~0);
166 const int res1 = ctx->getProperty("res1", ~0);
167 const char * op2 = ctx->getProperty("op2", "NONE");
168 const int res2 = ctx->getProperty("res2", ~0);
169 const int val2 = ctx->getProperty("val2", ~0);
171 const int res3 = ctx->getProperty("res3", ~0);
172 const int val3 = ctx->getProperty("val3", ~0);
174 do {
175 // Insert, read
176 CHECK(hugoOps.startTransaction(pNdb) == 0);
177 CHECK(runOp(hugoOps, pNdb, op1, val1) == 0);
178 AbortOption oa = (res1 == 0) ? AbortOnError : AO_IgnoreError;
179 CHECK(hugoOps.execute_NoCommit(pNdb, oa) == res1);
180 CHECK(checkVal(hugoOps, op1, val1, res1) == 0);
182 ndbout_c("-- running op 2");
184 CHECK(runOp(hugoOps, pNdb, op2, val2) == 0);
185 CHECK(hugoOps.execute_Commit(pNdb) == res2);
186 CHECK(checkVal(hugoOps, op2, val2, res2) == 0);
188 } while(false);
189 hugoOps.closeTransaction(pNdb);
191 if(result != NDBT_OK)
192 return result;
194 do {
195 CHECK(hugoOps.startTransaction(pNdb) == 0);
196 CHECK(runOp(hugoOps, pNdb, "READ", 0) == 0);
197 CHECK(hugoOps.execute_Commit(pNdb) == res3);
198 CHECK(checkVal(hugoOps, "READ", val3, res3) == 0);
199 } while(false);
200 hugoOps.closeTransaction(pNdb);
202 return result;
205 int
206 runInsertRecord(NDBT_Context* ctx, NDBT_Step* step){
207 int result = NDBT_OK;
208 HugoOperations hugoOps(*ctx->getTab());
209 Ndb* pNdb = GETNDB(step);
212 // Insert, insert
213 CHECK(hugoOps.startTransaction(pNdb) == 0);
214 CHECK(hugoOps.pkInsertRecord(pNdb, 1) == 0);
215 CHECK(hugoOps.execute_Commit(pNdb) == 0);
217 } while(false);
219 hugoOps.closeTransaction(pNdb);
221 return result;
225 runClearTable(NDBT_Context* ctx, NDBT_Step* step){
226 int records = ctx->getNumRecords();
228 UtilTransactions utilTrans(*ctx->getTab());
229 if (utilTrans.clearTable2(GETNDB(step), records, 240) != 0){
230 return NDBT_FAILED;
233 NdbRestarter r;
234 int lcp = 7099;
235 r.dumpStateAllNodes(&lcp, 1);
237 return NDBT_OK;
240 enum OPS { o_DONE= 0, o_INS= 1, o_UPD= 2, o_DEL= 3 };
241 typedef Vector<OPS> Sequence;
243 static
244 bool
245 valid(const Sequence& s)
247 if(s.size() == 0)
248 return false;
250 for(size_t i = 1; i<s.size(); i++)
252 switch(s[i]){
253 case o_INS:
254 if(s[i-1] != o_DEL)
255 return false;
256 break;
257 case o_UPD:
258 case o_DEL:
259 if(s[i-1] == o_DEL)
260 return false;
261 break;
262 case o_DONE:
263 return true;
266 return true;
269 static
270 NdbOut& operator<<(NdbOut& out, const Sequence& s)
272 out << "[ ";
273 for(size_t i = 0; i<s.size(); i++)
275 switch(s[i]){
276 case o_INS:
277 out << "INS ";
278 break;
279 case o_DEL:
280 out << "DEL ";
281 break;
282 case o_UPD:
283 out << "UPD ";
284 break;
285 case o_DONE:
286 abort();
289 out << "]";
290 return out;
293 static
294 void
295 generate(Sequence& out, int no)
297 while(no & 3)
299 out.push_back((OPS)(no & 3));
300 no >>= 2;
304 static
305 void
306 generate(Vector<int>& out, size_t len)
308 int max= 1;
309 while(len)
311 max <<= 2;
312 len--;
315 len= 1;
316 for(int i = 0; i<max; i++)
318 Sequence tmp;
319 generate(tmp, i);
321 if(tmp.size() >= len && valid(tmp))
323 out.push_back(i);
324 len= tmp.size();
326 else
328 //ndbout << "DISCARD: " << tmp << endl;
333 static const Uint32 DUMMY = 0;
334 static const Uint32 ROW = 1;
337 verify_other(NDBT_Context* ctx,
338 Ndb* pNdb, int seq, OPS latest, bool initial_row, bool commit)
340 Uint32 no_wait = NdbOperation::LM_CommittedRead*
341 ctx->getProperty("NoWait", (Uint32)1);
343 for(size_t j = no_wait; j<3; j++)
345 HugoOperations other(*ctx->getTab());
346 C3(other.startTransaction(pNdb) == 0);
347 C3(other.pkReadRecord(pNdb, ROW, 1, (NdbOperation::LockMode)j) == 0);
348 int tmp= other.execute_Commit(pNdb);
349 if(seq == 0){
350 if(j == NdbOperation::LM_CommittedRead)
352 C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626);
354 else
356 C3(tmp == 266);
359 else if(commit)
361 switch(latest){
362 case o_INS:
363 case o_UPD:
364 C3(tmp == 0 && other.verifyUpdatesValue(seq) == 0);
365 break;
366 case o_DEL:
367 C3(tmp == 626);
368 break;
369 case o_DONE:
370 abort();
373 else
375 // rollback
376 C3(initial_row? tmp==0 && other.verifyUpdatesValue(0) == 0 : tmp==626);
380 return NDBT_OK;
384 verify_savepoint(NDBT_Context* ctx,
385 Ndb* pNdb, int seq, OPS latest,
386 Uint64 transactionId)
388 bool initial_row= (seq == 0) && latest == o_INS;
390 for(size_t j = 0; j<3; j++)
392 const NdbOperation::LockMode lm= (NdbOperation::LockMode)j;
394 HugoOperations same(*ctx->getTab());
395 C3(same.startTransaction(pNdb) == 0);
396 same.setTransactionId(transactionId); // Cheat
399 * Increase savepoint to <em>k</em>
401 for(size_t l = 1; l<=seq; l++)
403 C3(same.pkReadRecord(pNdb, DUMMY, 1, lm) == 0); // Read dummy row
404 C3(same.execute_NoCommit(pNdb) == 0);
405 g_info << "savepoint: " << l << endl;
408 g_info << "op(" << seq << "): "
409 << " lock mode " << lm << endl;
411 C3(same.pkReadRecord(pNdb, ROW, 1, lm) == 0); // Read real row
412 int tmp= same.execute_Commit(pNdb);
413 if(seq == 0)
415 if(initial_row)
417 C3(tmp == 0 && same.verifyUpdatesValue(0) == 0);
418 } else
420 C3(tmp == 626);
423 else
425 switch(latest){
426 case o_INS:
427 case o_UPD:
428 C3(tmp == 0 && same.verifyUpdatesValue(seq) == 0);
429 break;
430 case o_DEL:
431 C3(tmp == 626);
432 break;
433 case o_DONE:
434 abort();
438 return NDBT_OK;
441 int
442 runOperations(NDBT_Context* ctx, NDBT_Step* step)
444 int tmp;
445 Ndb* pNdb = GETNDB(step);
447 Uint32 seqNo = ctx->getProperty("Sequence", (Uint32)0);
448 Uint32 commit= ctx->getProperty("Commit", (Uint32)1);
450 if(seqNo == 0)
452 return NDBT_FAILED;
455 Sequence seq;
456 generate(seq, seqNo);
459 // Dummy row
460 HugoOperations hugoOps(*ctx->getTab());
461 C3(hugoOps.startTransaction(pNdb) == 0);
462 C3(hugoOps.pkInsertRecord(pNdb, DUMMY, 1, 0) == 0);
463 C3(hugoOps.execute_Commit(pNdb) == 0);
466 const bool initial_row= (seq[0] != o_INS);
467 if(initial_row)
469 HugoOperations hugoOps(*ctx->getTab());
470 C3(hugoOps.startTransaction(pNdb) == 0);
471 C3(hugoOps.pkInsertRecord(pNdb, ROW, 1, 0) == 0);
472 C3(hugoOps.execute_Commit(pNdb) == 0);
475 HugoOperations trans1(*ctx->getTab());
476 C3(trans1.startTransaction(pNdb) == 0);
477 for(size_t i = 0; i<seq.size(); i++)
480 * Perform operation
482 switch(seq[i]){
483 case o_INS:
484 C3(trans1.pkInsertRecord(pNdb, ROW, 1, i+1) == 0);
485 break;
486 case o_UPD:
487 C3(trans1.pkUpdateRecord(pNdb, ROW, 1, i+1) == 0);
488 break;
489 case o_DEL:
490 C3(trans1.pkDeleteRecord(pNdb, ROW, 1) == 0);
491 break;
492 case o_DONE:
493 abort();
495 C3(trans1.execute_NoCommit(pNdb) == 0);
498 * Verify other transaction
500 if(verify_other(ctx, pNdb, 0, seq[0], initial_row, commit) != NDBT_OK)
501 return NDBT_FAILED;
504 * Verify savepoint read
506 Uint64 transactionId= trans1.getTransaction()->getTransactionId();
508 for(size_t k=0; k<=i+1; k++)
510 if(verify_savepoint(ctx, pNdb, k,
511 k>0 ? seq[k-1] : initial_row ? o_INS : o_DONE,
512 transactionId) != NDBT_OK)
513 return NDBT_FAILED;
517 if(commit)
519 C3(trans1.execute_Commit(pNdb) == 0);
521 else
523 C3(trans1.execute_Rollback(pNdb) == 0);
526 if(verify_other(ctx, pNdb, seq.size(), seq.back(),
527 initial_row, commit) != NDBT_OK)
528 return NDBT_FAILED;
530 return NDBT_OK;
534 runLockUpgrade1(NDBT_Context* ctx, NDBT_Step* step){
535 // Verify that data in index match
536 // table data
537 Ndb* pNdb = GETNDB(step);
538 HugoOperations hugoOps(*ctx->getTab());
539 HugoTransactions hugoTrans(*ctx->getTab());
541 if(hugoTrans.loadTable(pNdb, 1) != 0){
542 g_err << "Load table failed" << endl;
543 return NDBT_FAILED;
546 int result= NDBT_OK;
549 CHECK(hugoOps.startTransaction(pNdb) == 0);
550 if(ctx->getProperty("LOCK_UPGRADE", 1) == 1)
552 CHECK(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Read) == 0);
553 CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
555 ctx->setProperty("READ_DONE", 1);
556 ctx->broadcast();
557 ndbout_c("wait 2");
558 ctx->getPropertyWait("READ_DONE", 2);
559 ndbout_c("wait 2 - done");
561 else
563 ctx->setProperty("READ_DONE", 1);
564 ctx->broadcast();
565 ctx->getPropertyWait("READ_DONE", 2);
566 ndbout_c("wait 2 - done");
567 CHECK(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Read) == 0);
568 CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
570 if(ctx->getProperty("LU_OP", o_INS) == o_INS)
572 CHECK(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
573 CHECK(hugoOps.pkInsertRecord(pNdb, 0, 1, 2) == 0);
575 else if(ctx->getProperty("LU_OP", o_UPD) == o_UPD)
577 CHECK(hugoOps.pkUpdateRecord(pNdb, 0, 1, 2) == 0);
579 else
581 CHECK(hugoOps.pkDeleteRecord(pNdb, 0, 1) == 0);
583 ctx->setProperty("READ_DONE", 3);
584 ctx->broadcast();
585 ndbout_c("before update");
586 ndbout_c("wait update");
587 CHECK(hugoOps.execute_Commit(pNdb) == 0);
588 CHECK(hugoOps.closeTransaction(pNdb) == 0);
590 CHECK(hugoOps.startTransaction(pNdb) == 0);
591 CHECK(hugoOps.pkReadRecord(pNdb, 0, 1) == 0);
592 int res= hugoOps.execute_Commit(pNdb);
593 if(ctx->getProperty("LU_OP", o_INS) == o_INS)
595 CHECK(res == 0);
596 CHECK(hugoOps.verifyUpdatesValue(2) == 0);
598 else if(ctx->getProperty("LU_OP", o_UPD) == o_UPD)
600 CHECK(res == 0);
601 CHECK(hugoOps.verifyUpdatesValue(2) == 0);
603 else
605 CHECK(res == 626);
608 } while(0);
610 return result;
614 runLockUpgrade2(NDBT_Context* ctx, NDBT_Step* step){
615 // Verify that data in index match
616 // table data
617 Ndb* pNdb = GETNDB(step);
618 HugoOperations hugoOps(*ctx->getTab());
619 HugoTransactions hugoTrans(*ctx->getTab());
622 int result= NDBT_OK;
625 CHECK(hugoOps.startTransaction(pNdb) == 0);
626 ndbout_c("wait 1");
627 ctx->getPropertyWait("READ_DONE", 1);
628 ndbout_c("wait 1 - done");
629 CHECK(hugoOps.pkReadRecord(pNdb, 0, 1, NdbOperation::LM_Read) == 0);
630 CHECK(hugoOps.execute_NoCommit(pNdb) == 0);
631 ctx->setProperty("READ_DONE", 2);
632 ctx->broadcast();
633 ndbout_c("wait 3");
634 ctx->getPropertyWait("READ_DONE", 3);
635 ndbout_c("wait 3 - done");
637 NdbSleep_MilliSleep(200);
638 if(ctx->getProperty("LU_COMMIT", (Uint32)0) == 0)
640 CHECK(hugoOps.execute_Commit(pNdb) == 0);
642 else
644 CHECK(hugoOps.execute_Rollback(pNdb) == 0);
646 } while(0);
648 return result;
652 main(int argc, const char** argv){
653 ndb_init();
655 Vector<int> tmp;
656 generate(tmp, 5);
658 NDBT_TestSuite ts("testOperations");
660 ts.setTemporaryTables(true);
662 for(Uint32 i = 0; i < 12; i++)
664 if(false && (i == 6 || i == 8 || i == 10))
665 continue;
667 BaseString name("bug_9749");
668 name.appfmt("_%d", i);
669 NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts,
670 name.c_str(), "");
672 pt->setProperty("LOCK_UPGRADE", 1 + (i & 1));
673 pt->setProperty("LU_OP", 1 + ((i >> 1) % 3));
674 pt->setProperty("LU_COMMIT", i / 6);
676 pt->addInitializer(new NDBT_Initializer(pt,
677 "runClearTable",
678 runClearTable));
680 pt->addStep(new NDBT_ParallelStep(pt,
681 "thread1",
682 runLockUpgrade1));
685 pt->addStep(new NDBT_ParallelStep(pt,
686 "thread2",
687 runLockUpgrade2));
689 pt->addFinalizer(new NDBT_Finalizer(pt,
690 "runClearTable",
691 runClearTable));
692 ts.addTest(pt);
695 for(size_t i = 0; i<tmp.size(); i++)
697 BaseString name;
698 Sequence s;
699 generate(s, tmp[i]);
700 for(size_t j = 0; j<s.size(); j++){
701 switch(s[j]){
702 case o_INS:
703 name.append("_INS");
704 break;
705 case o_DEL:
706 name.append("_DEL");
707 break;
708 case o_UPD:
709 name.append("_UPD");
710 break;
711 case o_DONE:
712 abort();
716 BaseString n1;
717 n1.append(name);
718 n1.append("_COMMIT");
720 NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts,
721 n1.c_str()+1, "");
723 pt->setProperty("Sequence", tmp[i]);
724 pt->addInitializer(new NDBT_Initializer(pt,
725 "runClearTable",
726 runClearTable));
728 pt->addStep(new NDBT_ParallelStep(pt,
729 "run",
730 runOperations));
732 pt->addFinalizer(new NDBT_Finalizer(pt,
733 "runClearTable",
734 runClearTable));
736 ts.addTest(pt);
738 name.append("_ABORT");
739 pt = new NDBT_TestCaseImpl1(&ts, name.c_str()+1, "");
740 pt->setProperty("Sequence", tmp[i]);
741 pt->setProperty("Commit", (Uint32)0);
742 pt->addInitializer(new NDBT_Initializer(pt,
743 "runClearTable",
744 runClearTable));
746 pt->addStep(new NDBT_ParallelStep(pt,
747 "run",
748 runOperations));
750 pt->addFinalizer(new NDBT_Finalizer(pt,
751 "runClearTable",
752 runClearTable));
754 ts.addTest(pt);
757 for(Uint32 i = 0; i<sizeof(matrix)/sizeof(matrix[0]); i++){
758 NDBT_TestCaseImpl1 *pt = new NDBT_TestCaseImpl1(&ts, matrix[i].name, "");
760 pt->addInitializer(new NDBT_Initializer(pt,
761 "runClearTable",
762 runClearTable));
764 if(matrix[i].preCond){
765 pt->addInitializer(new NDBT_Initializer(pt,
766 "runInsertRecord",
767 runInsertRecord));
770 pt->setProperty("op1", matrix[i].op1);
771 pt->setProperty("res1", matrix[i].res1);
772 pt->setProperty("val1", matrix[i].val1);
774 pt->setProperty("op2", matrix[i].op2);
775 pt->setProperty("res2", matrix[i].res2);
776 pt->setProperty("val2", matrix[i].val2);
778 pt->setProperty("res3", matrix[i].res3);
779 pt->setProperty("val3", matrix[i].val3);
781 pt->addStep(new NDBT_ParallelStep(pt,
782 matrix[i].name,
783 runTwoOperations));
784 pt->addFinalizer(new NDBT_Finalizer(pt,
785 "runClearTable",
786 runClearTable));
788 ts.addTest(pt);
791 return ts.execute(argc, argv);
794 template class Vector<OPS>;
795 template class Vector<Sequence>;