18 #include <NDBT_Test.hpp>
19 #include <NDBT_ReturnCodes.h>
20 #include <HugoTransactions.hpp>
21 #include <UtilTransactions.hpp>
22 #include <NdbRestarter.hpp>
23 #include <signaldata/DictTabInfo.hpp>
24 #include <Bitmask.hpp>
26 #include <HugoQueryBuilder.hpp>
27 #include <HugoQueries.hpp>
32 int records = ctx->getNumRecords();
34 if (hugoTrans.loadTable(GETNDB(step), records) != 0){
44 if (utilTrans.clearTable(GETNDB(step)) != 0){
57 oldValue = ctx->getProperty(name);
58 Uint32 newValue = oldValue | val;
59 if (ctx->casProperty(name, oldValue, newValue) == oldValue)
61 NdbSleep_MilliSleep(5);
67 int loops = ctx->getNumLoops();
68 int joinlevel = ctx->getProperty(
"JoinLevel", 3);
69 int records = ctx->getNumRecords();
70 int until_stopped = ctx->getProperty(
"UntilStopped", (Uint32)0);
71 Uint32 stepNo = step->getStepNo();
75 qb.setJoinLevel(joinlevel);
78 while ((i<loops || until_stopped) && !ctx->isTestStopped())
81 if (hugoTrans.runLookupQuery(GETNDB(step), records))
86 addMask(ctx, (1 << stepNo),
"Running");
95 int loops = ctx->getNumLoops();
96 int joinlevel = ctx->getProperty(
"JoinLevel", 3);
97 int until_stopped = ctx->getProperty(
"UntilStopped", (Uint32)0);
98 Uint32 stepNo = step->getStepNo();
102 qb.setJoinLevel(joinlevel);
103 const NdbQueryDef * query = qb.createQuery(GETNDB(step));
105 while ((i<loops || until_stopped) && !ctx->isTestStopped())
108 if (hugoTrans.runScanQuery(GETNDB(step)))
113 addMask(ctx, (1 << stepNo),
"Running");
122 int loops = ctx->getNumLoops();
123 int joinlevel = ctx->getProperty(
"JoinLevel", 3);
124 int records = ctx->getNumRecords();
125 int until_stopped = ctx->getProperty(
"UntilStopped", (Uint32)0);
126 Uint32 stepNo = step->getStepNo();
131 qb1.setJoinLevel(joinlevel);
132 qb2.setJoinLevel(joinlevel);
133 const NdbQueryDef * q1 = qb1.createQuery(GETNDB(step));
134 const NdbQueryDef * q2 = qb2.createQuery(GETNDB(step));
137 while ((i<loops || until_stopped) && !ctx->isTestStopped())
140 if (hugoTrans1.runScanQuery(GETNDB(step)))
145 if (hugoTrans2.runLookupQuery(GETNDB(step), records))
151 addMask(ctx, (1 << stepNo),
"Running");
160 int result = NDBT_OK;
161 int loops = ctx->getNumLoops();
162 int waitprogress = ctx->getProperty(
"WaitProgress", (
unsigned)0);
163 int randnode = ctx->getProperty(
"RandNode", (
unsigned)0);
168 if (restarter.getNumDbNodes() < 2){
173 if(restarter.waitClusterStarted() != 0){
174 g_err <<
"Cluster failed to start" << endl;
178 loops *= (restarter.getNumDbNodes() > 2 ? 2 : restarter.getNumDbNodes());
179 if (loops < restarter.getNumDbNodes())
180 loops = restarter.getNumDbNodes();
182 NdbSleep_MilliSleep(200);
183 Uint32 running = ctx->getProperty(
"Running", (Uint32)0);
184 while (running == 0 && !ctx->isTestStopped())
186 NdbSleep_MilliSleep(100);
187 running = ctx->getProperty(
"Running", (Uint32)0);
190 if (ctx->isTestStopped())
193 while(i<loops && result != NDBT_FAILED && !ctx->isTestStopped()){
195 int id = lastId % restarter.getNumDbNodes();
198 id = rand() % restarter.getNumDbNodes();
200 int nodeId = restarter.getDbNodeId(
id);
201 ndbout <<
"Restart node " << nodeId << endl;
203 if(restarter.restartOneDbNode(nodeId,
false,
true,
true) != 0){
204 g_err <<
"Failed to restartNextDbNode" << endl;
205 result = NDBT_FAILED;
209 if (restarter.waitNodesNoStart(&nodeId, 1))
211 g_err <<
"Failed to waitNodesNoStart" << endl;
212 result = NDBT_FAILED;
219 ndbout_c(
"running: 0x%.8x", running);
220 for (Uint32 checks = 0; checks < 3 && !ctx->isTestStopped(); checks++)
222 ctx->setProperty(
"Running", (Uint32)0);
223 for (; maxwait != 0 && !ctx->isTestStopped(); maxwait--)
225 if ((ctx->getProperty(
"Running", (Uint32)0) & running) == running)
227 NdbSleep_SecSleep(1);
230 if (ctx->isTestStopped())
232 g_err <<
"Test stopped while waiting for progress!" << endl;
236 g_err <<
"No progress made!!" << endl;
239 g_err <<
"Progress made!! " << endl;
243 if (restarter.startNodes(&nodeId, 1))
245 g_err <<
"Failed to start node" << endl;
246 result = NDBT_FAILED;
250 if(restarter.waitClusterStarted() != 0){
251 g_err <<
"Cluster failed to start" << endl;
252 result = NDBT_FAILED;
259 ndbout_c(
"running: 0x%.8x", running);
260 for (Uint32 checks = 0; checks < 3 && !ctx->isTestStopped(); checks++)
262 ctx->setProperty(
"Running", (Uint32)0);
263 for (; maxwait != 0 && !ctx->isTestStopped(); maxwait--)
265 if ((ctx->getProperty(
"Running", (Uint32)0) & running) == running)
267 NdbSleep_SecSleep(1);
270 if (ctx->isTestStopped())
272 g_err <<
"Test stopped while waiting for progress!" << endl;
276 g_err <<
"No progress made!!" << endl;
279 g_err <<
"Progress made!! " << endl;
280 ctx->setProperty(
"Running", (Uint32)0);
293 NDBT_TESTSUITE(testSpj);
294 TESTCASE(
"LookupJoin",
""){
295 INITIALIZER(runLoadTable);
297 VERIFIER(runClearTable);
299 TESTCASE(
"ScanJoin",
""){
300 INITIALIZER(runLoadTable);
302 FINALIZER(runClearTable);
304 TESTCASE(
"MixedJoin",
""){
305 INITIALIZER(runLoadTable);
307 FINALIZER(runClearTable);
309 TESTCASE(
"NF_Join",
""){
310 TC_PROPERTY(
"UntilStopped", 1);
311 TC_PROPERTY(
"WaitProgress", 20);
312 INITIALIZER(runLoadTable);
317 FINALIZER(runClearTable);
319 NDBT_TESTSUITE_END(testSpj);
322 int main(
int argc,
const char** argv){
324 NDBT_TESTSUITE_INSTANCE(testSpj);
325 return testSpj.execute(argc, argv);