20 #include <ndb_global.h>
25 #include <mgmapi_debug.h>
57 struct test_case test_connect_disconnect[] = {
58 {
"testConnect", &testConnect},
59 {
"testDisconnect", &testDisconnect}
63 {
"testStatus", &testStatus },
64 {
"testFilterClusterLog", &testFilterClusterLog },
67 {
"testRestartNode", &testRestartNode },
68 {
"testGetStatPort", &testGetStatPort },
70 {
"testLogSignals", &testLogSignals },
71 {
"testStartSignalLog", &testStartSignalLog },
72 {
"testStopSignalLog", &testStopSignalLog },
73 {
"testSetTrace", &testSetTrace },
74 {
"testDumpState", &testDumpState },
75 {
"testInsertError", &testInsertError }
79 static int no_of_tests =
sizeof(tests) /
sizeof(
struct test_case);
80 static int testFailed = 0;
82 static const char * g_connect_string =
"localhost:2200";
85 main(
int argc,
const char** argv){
92 g_connect_string = argv[1];
94 ndbout_c(
"Using connectstring: %s", g_connect_string);
96 for (i = 0; i < 2; i++) {
97 ndbout_c(
"-- %s --", test_connect_disconnect[i].
name);
98 if (test_connect_disconnect[i].func(h, &
reply) == 0) {
99 ndbout_c(
"-- Passed --");
102 ndbout_c(
"-- Failed --");
105 ndbout_c(
"-- %d passed, %d failed --", (2 - testFailed), testFailed);
111 for (i = 0; i < no_of_tests; i ++) {
112 ndbout_c(
"-- %s --", tests[i].
name);
113 if (tests[i].func(h, &
reply) == 0) {
114 ndbout_c(
"-- Passed --");
117 ndbout_c(
"-- Failed --");
122 ndbout_c(
"-- %d passed, %d failed --", (no_of_tests - testFailed),
135 ndbout_c(g_connect_string);
139 ndbout_c(
"Connected to localhost:37123");
143 ndbout_c(
"Unable to create a NdbMgmHandle...");
161 if (config != NULL) {
164 ndbout_c(
"Unable to get config");
174 if (cluster != NULL) {
175 ndbout_c(
"Number of nodes: %d", cluster->
no_of_nodes);
178 ndbout_c(
"NodeId: %d (%s)-- %s", state.
node_id,
185 ndbout_c(
"Unable to get node status.");
199 if (cluster != NULL) {
205 ndbout_c(
"Unable to get node status.");
216 ndbout_c(
"%s", reply->
message);
226 if (cluster != NULL) {
232 ndbout_c(
"Unable to get node status.");
236 rc = ndb_mgm_start_signallog(h, nodeId, reply);
241 ndbout_c(
"%s", reply->
message);
252 if (cluster != NULL) {
258 ndbout_c(
"Unable to get node status.");
262 rc = ndb_mgm_stop_signallog(h, nodeId, reply);
267 ndbout_c(
"%s", reply->
message);
278 if (cluster != NULL) {
284 ndbout_c(
"Unable to get node status.");
288 rc = ndb_mgm_set_trace(h, nodeId, 2, reply);
293 ndbout_c(
"%s", reply->
message);
304 if (cluster != NULL) {
310 ndbout_c(
"Unable to get node status.");
314 rc = ndb_mgm_insert_error(h, nodeId, 9999, reply);
319 ndbout_c(
"%s", reply->
message);
333 if (cluster != NULL) {
339 ndbout_c(
"Unable to get node status.");
352 ndbout_c(
"%s", reply->
message);
363 rc = ndb_mgm_filter_clusterlog(h, NDB_MGM_CLUSTERLOG_INFO, reply);
366 ndbout_c(
"%s", reply->
message);
370 ndbout_c(
"%s", reply->
message);
372 rc = ndb_mgm_filter_clusterlog(h, NDB_MGM_CLUSTERLOG_DEBUG, reply);
375 ndbout_c(
"%s", reply->
message);
379 ndbout_c(
"%s", reply->
message);
391 if (cluster != NULL) {
397 ndbout_c(
"Unable to get node status.");
401 rc = ndb_mgm_set_loglevel_clusterlog(h, nodeId,
409 ndbout_c(
"%s", reply->
message);
421 if (cluster != NULL) {
427 ndbout_c(
"Unable to get node status.");
439 ndbout_c(
"%s", reply->
message);
451 ndbout_c(
"No nodes restarted...");
454 ndbout_c(
"%d nodes restarted...", restarts);
464 rc = ndb_mgm_get_stat_port(h, reply);
466 ndbout_c(
"stat port %s", reply->
message);