19 #include <ndb_global.h>
21 #include <readline/readline.h>
22 #include <../../ndbapi/SignalSender.hpp>
26 ndbout <<
"The test menu" << endl;
27 ndbout <<
"1 - Sending of long signals w/ segmented sections" << endl;
28 ndbout <<
"2 - As 1 but using receiver group" << endl;
29 ndbout <<
"3 - Sending of long signals w/ linear sections" << endl;
30 ndbout <<
"4 - As 3 but using receiver group" << endl;
31 ndbout <<
"5 - Sending of manually fragmented signals w/ segmented sections"
33 ndbout <<
"6 - As 5 but using receiver group" << endl;
34 ndbout <<
"7 - Sending of manually fragmented signals w/ linear sections"
36 ndbout <<
"8 - As but using receiver group" << endl;
38 ndbout <<
"9 - Sending of CONTINUEB fragmented signals w/ segmented sections"
40 ndbout <<
"10 - As 9 but using receiver group" << endl;
41 ndbout <<
"11 - Sending of CONTINUEB fragmented signals w/ linear sections"
43 ndbout <<
"12 - As but using receiver group" << endl;
44 ndbout <<
"13 - As 5 but with no release" << endl;
45 ndbout <<
"14 - As 13 but using receiver group" << endl;
46 ndbout <<
"15 - Send 100 * 1000 25 len signals wo/ sections" << endl;
47 ndbout <<
"r - Recive signal from anyone" << endl;
48 ndbout <<
"a - Run tests 1 - 14 with variable sizes - 10 loops" << endl;
49 ndbout <<
"b - Run tests 1 - 14 with variable sizes - 100 loops" << endl;
50 ndbout <<
"c - Run tests 1 - 14 with variable sizes - 1000k loops" << endl;
57 randRange(Uint32 min, Uint32 max){
59 float f = (max - min + 1);
60 float d = (float)RAND_MAX + 1.0;
61 return min + (int)(f * r / d);
66 randRange(
const Uint32 odds[], Uint32 count){
67 Uint32 val = randRange((Uint32)0, 100);
71 while(sum <= val && i < count){
87 main(
int argc,
char** argv) {
90 srand(NdbTick_CurrentMillisecond());
92 for(
int i = 0; i<100; i++)
93 ndbout_c(
"randRange(0, 3) = %d", randRange(0, 3));
99 ndbout <<
"No connectstring given, usage : " << argv[0]
100 <<
" <connectstring>" << endl;
105 ndbout <<
"Connecting...";
108 ndbout <<
"Unable to connect to management server." << endl;
113 ndbout <<
"Cluster nodes not ready in 30 seconds." << endl;
116 ndbout <<
"done" << endl;
120 ndbout_c(
"Connected as block=%d node=%d",
121 refToBlock(ss.getOwnRef()), refToNode(ss.getOwnRef()));
128 data[0] = ss.getOwnRef();
136 const Uint32 theDataLen = 18;
138 for(Uint32 i = 0; i<70; i++)
141 for(Uint32 i = 0; i<123; i++)
144 for(Uint32 i = 0; i<10; i++)
145 sec2[i] = (i + 1)*(i + 1);
148 signal1.set(ss, 0, CMVMI, GSN_TESTSIG, theDataLen + 2);
149 signal1.header.m_noOfSections = 1;
150 signal1.header.m_fragmentInfo = 1;
152 memcpy(&signal1.theData[0], data, 4 * theDataLen );
153 signal1.theData[theDataLen + 0] = 0;
154 signal1.theData[theDataLen + 1] = 7;
156 signal1.ptr[0].sz = 60;
157 signal1.ptr[0].p = &sec0[0];
162 memcpy(&signal2.theData[0], data, 4 * theDataLen );
163 signal2.theData[theDataLen + idx] = 0; idx++;
164 signal2.theData[theDataLen + idx] = 1; idx++;
166 signal2.theData[theDataLen + idx] = 7; idx++;
168 signal2.set(ss, 0, CMVMI, GSN_TESTSIG, theDataLen + idx);
169 signal2.header.m_fragmentInfo = 3;
170 signal2.header.m_noOfSections = idx - 1;
172 signal2.ptr[0].sz = 10;
173 signal2.ptr[0].p = &sec0[60];
175 signal2.ptr[1].sz = 123;
176 signal2.ptr[1].p = &sec1[0];
178 signal2.ptr[2].sz = 10;
179 signal2.ptr[2].p = &sec2[0];
182 while((buf = readline(
"Enter command: "))){
185 if(strcmp(buf,
"r") == 0){
190 if(strcmp(buf,
"a") == 0){
191 runTest(ss, 10,
true);
195 if(strcmp(buf,
"b") == 0){
196 runTest(ss, 100,
false);
200 if(strcmp(buf,
"c") == 0){
201 runTest(ss, 1000000,
false);
206 if(data[1] >= 1 && data[1] <= 14){
207 Uint32 nodeId = ss.getAliveNode();
208 ndbout_c(
"Sending 2 fragmented to node %d", nodeId);
209 ss.sendSignal(nodeId, &signal1);
210 ss.sendSignal(nodeId, &signal2);
215 ndbout_c(
"Waiting for signal from %d", nodeId);
219 Uint32 count = ret1->theData[4] - 1;
221 ndbout <<
"Waiting for " << count <<
" signals... ";
223 ndbout_c(
"received from node %d",
224 refToNode(ret1->header.theSendersBlockRef));
228 }
else if (data[1] == 15) {
229 const Uint32 count = 3500;
230 const Uint32 loop = 1000;
232 signal1.set(ss, 0, CMVMI, GSN_TESTSIG, 25);
233 signal1.header.m_fragmentInfo = 0;
234 signal1.header.m_noOfSections = 0;
235 signal1.theData[1] = 14;
236 signal1.theData[3] = 0;
237 signal1.theData[8] = count;
238 signal1.theData[9] = loop;
239 Uint32 nodeId = ss.getAliveNode();
240 ndbout_c(
"Sending 25 len signal to node %d", nodeId);
241 ss.sendSignal(nodeId, &signal1);
246 ndbout_c(
"received from node %d",
247 refToNode(ret1->header.theSendersBlockRef));
248 total = ret1->theData[10] - 1;
252 ndbout <<
"Waiting for " << total <<
" signals... " << flush;
254 ndbout_c(
"received from node %d",
255 refToNode(ret1->header.theSendersBlockRef));
262 ndbout <<
"Exiting" << endl;
273 for(Uint32 i = 0; i<256; i++){
279 sig.theData[0] = ss.getOwnRef();
281 sig.theData[2] = 128;
285 sig.ptr[0].p = &sec0[0];
286 sig.ptr[1].p = &sec1[0];
287 sig.ptr[2].p = &sec2[0];
289 for(
unsigned loop = 0; loop < count; loop++){
290 const Uint32 odds[] = { 5, 40, 30, 25 };
291 const Uint32 secs = randRange(odds, 4);
292 sig.ptr[0].sz = randRange(1, 256);
293 sig.ptr[1].sz = randRange(1, 256);
294 sig.ptr[2].sz = randRange(1, 256);
295 sig.header.m_noOfSections = secs;
296 const Uint32 len = 5 + (secs > 0 ? 1 : 0) * (25 - 5 - 7);
297 sig.set(ss, 0, CMVMI, GSN_TESTSIG, len);
298 ndbout <<
"Loop " << loop <<
" #secs = " << secs <<
" sizes = [ ";
302 for(
unsigned i = 0; i<secs; i++){
303 const Uint32 sz = sig.ptr[
i].sz;
305 min = (min < sz ? min : sz);
306 max = (max > sz ? max : sz);
308 sig.theData[5+
i] = sz;
310 ndbout_c(
"] len = %d", len);
312 sig.theData[1] =
test;
313 Uint32 nodeId = ss.getAliveNode();
315 ndbout <<
" Test " <<
test <<
" node " << nodeId <<
"...";
318 SendStatus r = ss.sendSignal(nodeId, &sig);
319 assert(r == SEND_OK);
322 Uint32 count = ret1->theData[4] - 1;
329 ndbout <<
"done" << endl;
331 Uint32 nodes = ss.getNoOfConnectedNodes();
337 if(ret->header.m_fragmentInfo == 0){
338 for(Uint32 i = 0; i<ret->header.m_noOfSections; i++)
339 sum2 += ret->ptr[i].sz;
341 for(Uint32 i = 0; i<ret->header.m_noOfSections; i++)
342 if(ret->theData[i] != 3)
343 sum2 += ret->ptr[
i].sz;
345 if(ret->header.m_fragmentInfo == 0 ||
346 ret->header.m_fragmentInfo == 3){
351 ndbout_c(
"done sum=%d sum2=%d", sum, sum2);