19 #include <ndb_global.h>
20 #include "InitConfigFileParser.hpp"
21 #include "ConfigInfo.hpp"
23 #include <portlib/NdbDir.hpp>
27 fprintf(stderr, "testConfig: '"#x"' failed on line %d\n", __LINE__); \
41 FILE* config_file= tmpfile();
44 const char* section= g_info.nameToAlias(param.
_section);
48 if (param._type == ConfigInfo::CI_SECTION)
62 fprintf(config_file,
"[%s]\n", section);
63 fprintf(config_file,
"%s=%s\n", param._fname,
68 if (strcmp(section,
"NDBD") != 0)
69 fprintf(config_file,
"[ndbd]\n");
70 if (strcmp(param._fname,
"NoOfReplicas") != 0)
71 fprintf(config_file,
"NoOfReplicas=1\n");
73 if (strcmp(section,
"NDB_MGMD") != 0)
74 fprintf(config_file,
"[ndb_mgmd]\n");
75 if (strcmp(param._fname,
"Hostname") != 0)
76 fprintf(config_file,
"HostName=localhost\n");
78 if (strcmp(section,
"MYSQLD") != 0)
79 fprintf(config_file,
"[mysqld]\n");
99 for (
int j=0; j<g_info.m_NoOfParams; j++) {
101 printf(
"Checking %s...\n", param._fname);
102 if (!check_param(param))
114 create_config(
const char* first, ...)
118 FILE* config_file= tmpfile();
121 va_start(args, first);
122 const char* str= first;
124 fprintf(config_file,
"%s\n", str);
125 while((str= va_arg(args,
const char*)) != NULL);
132 while(fgets(buf,
sizeof(buf), config_file))
146 extern "C" const char* my_defaults_file;
153 return (
unsigned)GetCurrentProcessId();
155 return (
unsigned)getpid();
160 create_mycnf(
const char* first, ...)
166 mycnf_file.
assfmt(
"%s%stest_my.%u.cnf",
167 tempdir.path(), DIR_SEPARATOR, ndb_procid());
169 FILE* config_file= fopen(mycnf_file.
c_str(),
"w+");
172 va_start(args, first);
173 const char* str= first;
175 fprintf(config_file,
"%s\n", str);
176 while((str= va_arg(args,
const char*)) != NULL);
183 while(fgets(buf,
sizeof(buf), config_file))
191 const char* save_defaults_file = my_defaults_file;
192 my_defaults_file = mycnf_file.
c_str();
198 my_defaults_file = save_defaults_file;
203 unlink(mycnf_file.
c_str());
215 create_config(
"[ndbd]",
"NoOfReplicas=1",
216 "[ndb_mgmd]",
"HostName=localhost",
220 create_config(
"[ndbd]",
"NoOfReplicas=1",
221 "[ndb_mgmd]",
"HostName=localhost",
222 "[mysqld]",
"[mysqld]", NULL);
225 CHECK(c1->equal(c1));
227 CHECK(!c1->equal(c2));
228 CHECK(!c2->equal(c1));
229 CHECK(!c2->illegal_change(c1));
230 CHECK(!c1->illegal_change(c2));
232 ndbout_c(
"==================");
233 ndbout_c(
"c1->print_diff(c2)");
235 ndbout_c(
"==================");
236 ndbout_c(
"c2->print_diff(c1)");
238 ndbout_c(
"==================");
246 create_config(
"[ndbd]",
"NoOfReplicas=1",
247 "DataMemory=100M",
"IndexMemory=100M",
248 "[ndb_mgmd]",
"HostName=localhost",
252 ndbout_c(
"c1->print_diff(c1_bug47306)");
253 c1->print_diff(c1_bug47306);
256 unsigned exclude[]= {CFG_SECTION_SYSTEM, 0};
257 c1->
diff(c1_bug47306, diff_list, exclude);
261 CHECK(diff_list.get(
"NodeId=1", §ion));
265 int count= 0, found = 0;
267 while ((name = prop_it.next())){
268 if (strcmp(name,
"IndexMemory") == 0)
270 if (strcmp(name,
"DataMemory") == 0)
276 ndbout_c(
"==================");
287 print_restart_info(
void)
293 for (
int i = 0;
i < g_info.m_NoOfParams;
i++) {
295 if ((param._flags & ConfigInfo::CI_RESTART_INITIAL) &&
296 (param._flags & ConfigInfo::CI_RESTART_SYSTEM))
297 initial_system.push_back(param._fname);
298 else if (param._flags & (ConfigInfo::CI_RESTART_SYSTEM))
299 system.push_back(param._fname);
300 else if (param._flags & (ConfigInfo::CI_RESTART_INITIAL))
301 initial_node.push_back(param._fname);
304 fprintf(stderr,
"*** initial node restart ***\n");
305 for (
size_t i = 0;
i < initial_node.size();
i++) {
306 fprintf(stderr,
"%s\n", initial_node[
i]);
308 fprintf(stderr,
"\n");
310 fprintf(stderr,
"*** system restart ***\n");
311 for (
size_t i = 0;
i < system.size();
i++) {
312 fprintf(stderr,
"%s\n", system[
i]);
314 fprintf(stderr,
"\n");
316 fprintf(stderr,
"*** initial system restart ***\n");
317 for (
size_t i = 0;
i < initial_system.size();
i++) {
318 fprintf(stderr,
"%s\n", initial_system[
i]);
320 fprintf(stderr,
"\n");
325 checksum_config(
void)
328 create_config(
"[ndbd]",
"NoOfReplicas=1",
329 "[ndb_mgmd]",
"HostName=localhost",
333 create_config(
"[ndbd]",
"NoOfReplicas=1",
334 "[ndb_mgmd]",
"HostName=localhost",
335 "[mysqld]",
"[mysqld]", NULL);
338 ndbout_c(
"== checksum tests ==");
339 Uint32 c1_check = c1->checksum();
340 Uint32 c2_check = c2->checksum();
341 ndbout_c(
"c1->checksum(): 0x%x", c1_check);
342 ndbout_c(
"c2->checksum(): 0x%x", c2_check);
344 CHECK(c1_check != c2_check);
347 CHECK(c1_check == c1->checksum());
351 CHECK(c1_check == c1_copy.checksum());
353 ndbout_c(
"==================");
360 test_param_values(
void)
367 {
"Arbitration=Disabled",
true },
368 {
"Arbitration=Invalid",
false },
369 {
"Arbitration=",
false },
371 {
"LockExecuteThreadToCPU=0",
true },
372 {
"LockExecuteThreadToCPU=1",
true },
373 {
"LockExecuteThreadToCPU=65535",
true },
374 {
"LockExecuteThreadToCPU=0-65535",
true },
375 {
"LockExecuteThreadToCPU=0-1,65534-65535",
true },
376 {
"LockExecuteThreadToCPU=17-256",
true },
377 {
"LockExecuteThreadToCPU=1-2,36-37,17-256,11-12,1-2",
true },
378 {
"LockExecuteThreadToCPU=",
false },
379 {
"LockExecuteThreadToCPU=1-",
false },
380 {
"LockExecuteThreadToCPU=1--",
false },
381 {
"LockExecuteThreadToCPU=1-2,34-",
false },
382 {
"LockExecuteThreadToCPU=x",
false },
383 {
"LockExecuteThreadToCPU=x-1",
false },
384 {
"LockExecuteThreadToCPU=x-x",
false },
388 for (
struct test* t = tests; t->param; t++)
390 ndbout_c(
"testing %s", t->param);
393 create_config(
"[ndbd]",
"NoOfReplicas=1",
395 "[ndb_mgmd]",
"HostName=localhost",
409 create_mycnf(
"[cluster_config]",
410 "ndb_mgmd=localhost",
411 "ndbd=localhost,localhost",
431 test_hostname_mycnf(
void)
438 create_mycnf(
"[cluster_config]",
439 "ndb_mgmd=localhost",
440 "ndbd=localhost,localhost",
443 "[cluster_config.ndbd.1]",
444 "HostName=localhost",
453 create_mycnf(
"[cluster_config]",
454 "ndb_mgmd=localhost",
455 "ndbd=localhost,localhost",
458 "[cluster_config.ndbd.1]",
465 #include <NdbTap.hpp>
467 #include <EventLogger.hpp>
475 CHECK(check_params());
478 test_hostname_mycnf();
480 print_restart_info();