20 #include <NDBT_Test.hpp>
21 #include <HugoTransactions.hpp>
22 #include <UtilTransactions.hpp>
23 #include <NdbBackup.hpp>
25 #include "bank/Bank.hpp"
26 #include <NdbMixRestarter.hpp>
30 #define CHECK(b) if (!(b)) { \
31 g_err << "ERR: "<< step->getName() \
32 << " failed on line " << __LINE__ << endl; \
33 result = NDBT_FAILED; \
37 Bank bank(ctx->m_cluster_connection);
38 int overWriteExisting =
true;
39 if (bank.createAndLoadBank(overWriteExisting, disk, 10) != NDBT_OK)
55 ctx->incProperty(NMR_SR_THREADS);
56 while (!ctx->isTestStopped())
58 Bank bank(ctx->m_cluster_connection);
59 while(!ctx->isTestStopped() &&
60 ctx->getProperty(NMR_SR) <= NdbMixRestarter::SR_STOPPING)
62 if(bank.performIncreaseTime(wait, yield) == NDBT_FAILED)
66 ndbout_c(
"runBankTimer is stopped");
67 ctx->incProperty(NMR_SR_THREADS_STOPPED);
68 if(ctx->getPropertyWait(NMR_SR, NdbMixRestarter::SR_RUNNING))
78 ctx->incProperty(NMR_SR_THREADS);
79 while (!ctx->isTestStopped())
81 Bank bank(ctx->m_cluster_connection);
82 while(!ctx->isTestStopped() &&
83 ctx->getProperty(NMR_SR) <= NdbMixRestarter::SR_STOPPING)
84 if(bank.performTransactions(wait, yield) == NDBT_FAILED)
87 ndbout_c(
"runBankTransactions is stopped");
88 ctx->incProperty(NMR_SR_THREADS_STOPPED);
89 if(ctx->getPropertyWait(NMR_SR, NdbMixRestarter::SR_RUNNING))
99 ctx->incProperty(NMR_SR_THREADS);
100 while (ctx->isTestStopped() ==
false)
102 Bank bank(ctx->m_cluster_connection);
103 while(!ctx->isTestStopped() &&
104 ctx->getProperty(NMR_SR) <= NdbMixRestarter::SR_STOPPING)
105 if (bank.performMakeGLs(yield) != NDBT_OK)
107 Uint32 state = ctx->getProperty(NMR_SR);
108 if(state != NdbMixRestarter::SR_RUNNING)
110 ndbout <<
"bank.performMakeGLs FAILED: " << state << endl;
115 ndbout_c(
"runBankGL is stopped");
116 ctx->incProperty(NMR_SR_THREADS_STOPPED);
117 if(ctx->getPropertyWait(NMR_SR, NdbMixRestarter::SR_RUNNING))
127 ctx->incProperty(NMR_SR_VALIDATE_THREADS);
129 while(!ctx->isTestStopped())
131 if (ctx->getPropertyWait(NMR_SR, NdbMixRestarter::SR_VALIDATING))
136 Bank bank(ctx->m_cluster_connection);
137 if (bank.performSumAccounts(wait, yield) != 0)
139 ndbout <<
"bank.performSumAccounts FAILED" << endl;
144 if (bank.performValidateAllGLs() != 0)
146 ndbout <<
"bank.performValidateAllGLs FAILED" << endl;
151 ctx->incProperty(NMR_SR_VALIDATE_THREADS_DONE);
153 if (ctx->getPropertyWait(NMR_SR, NdbMixRestarter::SR_RUNNING))
162 Bank bank(ctx->m_cluster_connection);
165 int result = NDBT_OK;
167 while (ctx->isTestStopped() ==
false)
169 if (bank.performSumAccounts(wait, yield) != NDBT_OK){
170 ndbout <<
"bank.performSumAccounts FAILED" << endl;
171 result = NDBT_FAILED;
184 int runtime = ctx->getNumLoops();
185 int sleeptime = ctx->getNumRecords();
186 Uint32 mask = ctx->getProperty(
"Type", ~(Uint32)0);
187 res.setRestartTypeMask(mask);
189 if (res.runPeriod(ctx, step, runtime, sleeptime))
201 Bank bank(ctx->m_cluster_connection);
202 if (bank.dropBank() != NDBT_OK)
208 NDBT_TESTSUITE(testSRBank);
210 " Test that a consistent bank is restored after graceful shutdown\n"
212 "2. Start bank and let it run\n"
213 "3. Restart ndb and verify consistency\n"
216 TC_PROPERTY(
"Type", NdbMixRestarter::RTM_SR);
217 INITIALIZER(runCreateBank);
219 STEPS(runBankTransactions, 10);
221 STEP(runBankSrValidator);
223 FINALIZER(runDropBank);
226 " Test that a consistent bank is restored after graceful shutdown\n"
228 "2. Start bank and let it run\n"
229 "3. Restart ndb and verify consistency\n"
232 TC_PROPERTY(
"Type", NdbMixRestarter::RTM_NR);
233 INITIALIZER(runCreateBank);
235 STEPS(runBankTransactions, 10);
238 FINALIZER(runDropBank);
241 " Test that a consistent bank is restored after graceful shutdown\n"
243 "2. Start bank and let it run\n"
244 "3. Restart ndb and verify consistency\n"
247 TC_PROPERTY(
"Type", NdbMixRestarter::RTM_ALL);
248 INITIALIZER(runCreateBank);
250 STEPS(runBankTransactions, 10);
253 STEP(runBankSrValidator);
254 FINALIZER(runDropBank);
256 NDBT_TESTSUITE_END(testSRBank);
259 main(
int argc,
const char** argv){
261 for (
int i = 0;
i<argc;
i++)
263 if (strcmp(argv[
i],
"--disk") == 0)
272 NDBT_TESTSUITE_INSTANCE(testSRBank);
273 return testSRBank.execute(argc, argv);