17 #include <NDBT_Test.hpp>
18 #include <HugoTransactions.hpp>
19 #include <UtilTransactions.hpp>
20 #include <NdbRestarter.hpp>
26 int records = ctx->getNumRecords();
29 if (utilTrans.clearTable2(GETNDB(step), records) != 0){
37 create_index_on_pk(
Ndb* pNdb,
const char* tabName)
44 const char* idxName =
"IDX_ON_PK";
45 ndbout <<
"Create: " <<idxName <<
"( ";
47 pIdx.setTable(tabName);
56 ndbout <<
"FAILED!" << endl;
61 ndbout <<
"OK!" << endl;
68 drop_index_on_pk(
Ndb* pNdb,
const char* tabName)
71 const char* idxName =
"IDX_ON_PK";
72 ndbout <<
"Drop: " << idxName;
74 ndbout <<
"FAILED!" << endl;
79 ndbout <<
"OK!" << endl;
85 #define CHECK(b) if (!(b)) { \
86 g_err << "ERR: "<< step->getName() \
87 << " failed on line " << __LINE__ << endl; \
88 result = NDBT_FAILED; \
96 int loops = ctx->getNumLoops();
97 int records = ctx->getNumRecords();
98 Ndb* pNdb = GETNDB(step);
101 strncpy(tabName, ctx->getTab()->
getName(), 255);
102 ndbout <<
"tabName="<<tabName<<endl;
108 while (i<loops && result == NDBT_OK) {
111 int nodeId = restarter.getMasterNodeId();
113 CHECK(restarter.enterSingleUserMode(pNdb->
getNodeId()) == 0);
114 CHECK(restarter.waitClusterSingleUser(timeout) == 0);
115 CHECK(restarter.restartOneDbNode(nodeId) != 0)
116 CHECK(restarter.exitSingleUserMode() == 0);
117 CHECK(restarter.waitClusterStarted(timeout) == 0);
120 CHECK(restarter.enterSingleUserMode(pNdb->
getNodeId()) == 0);
121 CHECK(restarter.waitClusterSingleUser(timeout) == 0);
122 CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
123 CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
124 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
125 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
126 CHECK(count == records);
127 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
128 CHECK(hugoTrans.scanReadRecords(pNdb, records/2, 0, 64) == 0);
129 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
130 CHECK(count == (records/2));
131 CHECK(utilTrans.clearTable(pNdb, records/2) == 0);
132 CHECK(restarter.exitSingleUserMode() == 0);
133 CHECK(restarter.waitClusterStarted(timeout) == 0);
136 CHECK(restarter.enterSingleUserMode(pNdb->
getNodeId()) == 0);
137 CHECK(restarter.waitClusterSingleUser(timeout) == 0);
138 CHECK(create_index_on_pk(pNdb, tabName) == 0);
139 CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
140 CHECK(hugoTrans.pkReadRecords(pNdb, records) == 0);
141 CHECK(hugoTrans.pkUpdateRecords(pNdb, records) == 0);
142 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
143 CHECK(count == records);
144 CHECK(hugoTrans.pkDelRecords(pNdb, records/2) == 0);
145 CHECK(drop_index_on_pk(pNdb, tabName) == 0);
146 CHECK(restarter.exitSingleUserMode() == 0);
147 CHECK(restarter.waitClusterStarted(timeout) == 0);
150 CHECK(create_index_on_pk(pNdb, tabName) == 0);
151 CHECK(hugoTrans.loadTable(pNdb, records, 128) == 0);
152 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
153 CHECK(restarter.enterSingleUserMode(pNdb->
getNodeId()) == 0);
154 CHECK(restarter.waitClusterSingleUser(timeout) == 0);
155 CHECK(drop_index_on_pk(pNdb, tabName) == 0);
156 CHECK(utilTrans.selectCount(pNdb, 64, &count) == 0);
157 CHECK(create_index_on_pk(pNdb, tabName) == 0);
158 CHECK(restarter.exitSingleUserMode() == 0);
159 CHECK(restarter.waitClusterStarted(timeout) == 0);
160 CHECK(drop_index_on_pk(pNdb, tabName) == 0);
162 CHECK(utilTrans.clearTable(GETNDB(step), records) == 0);
164 ndbout <<
"Restarting cluster" << endl;
165 CHECK(restarter.restartAll() == 0);
166 CHECK(restarter.waitClusterStarted(timeout) == 0);
176 NDBT_TESTSUITE(testSingleUserMode);
177 TESTCASE(
"SingleUserMode",
178 "Test single user mode"){
179 INITIALIZER(runTestSingleUserMode);
180 FINALIZER(runClearTable);
182 NDBT_TESTSUITE_END(testSingleUserMode);
185 int main(
int argc,
const char** argv){
187 NDBT_TESTSUITE_INSTANCE(testSingleUserMode);
188 return testSingleUserMode.execute(argc, argv);