1 /* Copyright (c) 2003-2005 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 "HugoAsynchTransactions.hpp"
20 #include "UtilTransactions.hpp"
22 #define GETNDB(ps) ((NDBT_NdbApiStep*)ps)->getNdb()
24 int runLoadTable(NDBT_Context
* ctx
, NDBT_Step
* step
){
26 int records
= ctx
->getNumRecords();
27 int batchSize
= ctx
->getProperty("BatchSize", 1);
28 int transactions
= (records
/ 100) + 1;
29 int operations
= (records
/ transactions
) + 1;
31 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
32 if (hugoTrans
.loadTableAsynch(GETNDB(step
), records
, batchSize
,
33 transactions
, operations
) != 0){
39 int runInsert(NDBT_Context
* ctx
, NDBT_Step
* step
){
41 int records
= ctx
->getNumRecords();
42 int batchSize
= ctx
->getProperty("BatchSize", 1);
43 int transactions
= (records
/ 100) + 1;
44 int operations
= (records
/ transactions
) + 1;
46 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
47 // Insert records, dont allow any
48 // errors(except temporary) while inserting
49 if (hugoTrans
.loadTableAsynch(GETNDB(step
), records
, batchSize
,
50 transactions
, operations
) != 0){
56 int runVerifyInsert(NDBT_Context
* ctx
, NDBT_Step
* step
){
57 int records
= ctx
->getNumRecords();
58 int batchSize
= ctx
->getProperty("BatchSize", 1);
59 int transactions
= (records
/ 100) + 1;
60 int operations
= (records
/ transactions
) + 1;
62 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
63 if (hugoTrans
.pkDelRecordsAsynch(GETNDB(step
), records
, batchSize
,
64 transactions
, operations
) != 0){
70 int runClearTable(NDBT_Context
* ctx
, NDBT_Step
* step
){
71 int records
= ctx
->getNumRecords();
72 int batchSize
= ctx
->getProperty("BatchSize", 1);
73 int transactions
= (records
/ 100) + 1;
74 int operations
= (records
/ transactions
) + 1;
76 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
77 if (hugoTrans
.pkDelRecordsAsynch(GETNDB(step
), records
, batchSize
,
78 transactions
, operations
) != 0){
84 int runPkDelete(NDBT_Context
* ctx
, NDBT_Step
* step
){
86 int loops
= ctx
->getNumLoops();
87 int records
= ctx
->getNumRecords();
88 int batchSize
= ctx
->getProperty("BatchSize", 1);
89 int transactions
= (records
/ 100) + 1;
90 int operations
= (records
/ transactions
) + 1;
93 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
96 if (hugoTrans
.pkDelRecordsAsynch(GETNDB(step
), records
, batchSize
,
97 transactions
, operations
) != 0){
100 // Load table, don't allow any primary key violations
101 if (hugoTrans
.loadTableAsynch(GETNDB(step
), records
, batchSize
,
102 transactions
, operations
) != 0){
111 int runPkRead(NDBT_Context
* ctx
, NDBT_Step
* step
){
112 int loops
= ctx
->getNumLoops();
113 int records
= ctx
->getNumRecords();
114 int batchSize
= ctx
->getProperty("BatchSize", 1);
115 int transactions
= (records
/ 100) + 1;
116 int operations
= (records
/ transactions
) + 1;
119 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
122 if (hugoTrans
.pkReadRecordsAsynch(GETNDB(step
), records
, batchSize
,
123 transactions
, operations
) != NDBT_OK
){
131 int runPkUpdate(NDBT_Context
* ctx
, NDBT_Step
* step
){
132 int loops
= ctx
->getNumLoops();
133 int records
= ctx
->getNumRecords();
134 int batchSize
= ctx
->getProperty("BatchSize", 1);
135 int transactions
= (records
/ 100) + 1;
136 int operations
= (records
/ transactions
) + 1;
139 HugoAsynchTransactions
hugoTrans(*ctx
->getTab());
142 if (hugoTrans
.pkUpdateRecordsAsynch(GETNDB(step
), records
,
143 batchSize
, transactions
,
152 NDBT_TESTSUITE(testBasicAsynch
);
153 TESTCASE("PkInsertAsynch",
154 "Verify that we can insert and delete from this table using PK"
155 " NOTE! No errors are allowed!" ){
156 INITIALIZER(runInsert
);
157 VERIFIER(runVerifyInsert
);
159 TESTCASE("PkReadAsynch",
160 "Verify that we can insert, read and delete from this table"
162 INITIALIZER(runLoadTable
);
164 FINALIZER(runClearTable
);
166 TESTCASE("PkUpdateAsynch",
167 "Verify that we can insert, update and delete from this table"
169 INITIALIZER(runLoadTable
);
171 FINALIZER(runClearTable
);
173 TESTCASE("PkDeleteAsynch",
174 "Verify that we can delete from this table using PK"){
175 INITIALIZER(runLoadTable
);
177 FINALIZER(runClearTable
);
180 NDBT_TESTSUITE_END(testBasicAsynch
);
182 int main(int argc
, const char** argv
){
184 return testBasicAsynch
.execute(argc
, argv
);