MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:August 27 2010 12:12pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3729) Bug#56185
View as plain text  
#At file:///home/msvensson/mysql/7.0-bug56185/ based on revid:magnus.blaudd@stripped0

 3729 Magnus Blåudd	2010-08-27
      ndb
       - Unit test for the new CI_BITMASK type for configuration parameters, also add
        some tests for CI_ENUM
       - mtr test to check that it's possible to specify CI_BITMASK and CI_ENUM
        in both my.nf and config.ini
       - This to make sure that functionality added for bug#56185 works

    added:
      mysql-test/suite/ndb/bug56185.ini
    modified:
      mysql-test/suite/ndb/ndb_config_mycnf1.cnf
      mysql-test/suite/ndb/r/ndb_config.result
      mysql-test/suite/ndb/t/ndb_config.test
      storage/ndb/src/mgmsrv/testConfig.cpp
=== added file 'mysql-test/suite/ndb/bug56185.ini'
--- a/mysql-test/suite/ndb/bug56185.ini	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/bug56185.ini	2010-08-27 12:12:51 +0000
@@ -0,0 +1,19 @@
+[ndbd default]
+
+[ndb_mgmd]
+Id=1
+Hostname=localhost
+
+[ndbd]
+Id=2
+Hostname=localhost
+Arbitration=WaitExternal
+LockExecuteThreadToCPU=37-48
+
+[ndbd]
+Id=3
+Hostname=localhost
+Arbitration=Default
+LockExecuteThreadToCPU=1-2
+
+[mysqld]

=== modified file 'mysql-test/suite/ndb/ndb_config_mycnf1.cnf'
--- a/mysql-test/suite/ndb/ndb_config_mycnf1.cnf	2009-12-07 13:10:38 +0000
+++ b/mysql-test/suite/ndb/ndb_config_mycnf1.cnf	2010-08-27 12:12:51 +0000
@@ -19,3 +19,14 @@ NoOfReplicas=2
 ndbd = 192.168.0.1,192.168.0.2,192.168.0.3,192.168.0.4
 ndb_mgmd = 192.168.0.1
 mysqld = 192.168.0.1
+
+[cluster_config.bug56185]
+NoOfReplicas=1
+ndbd = localhost
+ndb_mgmd = localhost
+mysql = localhost, localhost
+
+[cluster_config.ndbd.1.bug56185]
+LockExecuteThreadToCPU=0-65535
+Arbitration=Disabled
+

=== modified file 'mysql-test/suite/ndb/r/ndb_config.result'
--- a/mysql-test/suite/ndb/r/ndb_config.result	2010-06-02 16:45:36 +0000
+++ b/mysql-test/suite/ndb/r/ndb_config.result	2010-08-27 12:12:51 +0000
@@ -32,3 +32,6 @@ tcp,3,4,55,3 tcp,3,5,55,3 tcp,3,6,55,3 t
 == 17 == bug49400
  ERROR    -- at line 25: TCP connection is a duplicate of the existing TCP link from line 14
  ERROR    -- at line 25: Could not store section of configuration file.
+== 18 == bug56185
+0,0-65535
+2,37-48 1,1-2

=== modified file 'mysql-test/suite/ndb/t/ndb_config.test'
--- a/mysql-test/suite/ndb/t/ndb_config.test	2010-06-02 16:45:36 +0000
+++ b/mysql-test/suite/ndb/t/ndb_config.test	2010-08-27 12:12:51 +0000
@@ -54,3 +54,10 @@ echo == 17 == bug49400;
 --error 255
 --exec $NDB_CONFIG --no-defaults --config-file=$MYSQL_TEST_DIR/suite/ndb/bug49400.ini 2>&1
 
+echo == 18 == bug56185;
+# Read bitmask value and enum from my.cnf
+--exec $NDB_CONFIG --defaults-file=$MYSQL_TEST_DIR/suite/ndb/ndb_config_mycnf1.cnf --defaults-group-suffix=.bug56185 --query=Arbitration,LockExecuteThreadToCPU --type=ndbd --mycnf
+
+# Read bitmask value and enum from config.ini
+--exec $NDB_CONFIG --config-file=$MYSQL_TEST_DIR/suite/ndb/bug56185.ini --query=Arbitration,LockExecuteThreadToCPU --type=ndbd
+

=== modified file 'storage/ndb/src/mgmsrv/testConfig.cpp'
--- a/storage/ndb/src/mgmsrv/testConfig.cpp	2010-08-27 11:58:29 +0000
+++ b/storage/ndb/src/mgmsrv/testConfig.cpp	2010-08-27 12:12:51 +0000
@@ -21,9 +21,7 @@
 #include "InitConfigFileParser.hpp"
 #include "ConfigInfo.hpp"
 #include "Config.hpp"
-
-my_bool opt_core= 1;
-
+#include <portlib/NdbDir.hpp>
 
 #define CHECK(x) \
   if (!(x)) {\
@@ -84,8 +82,6 @@ check_param(const ConfigInfo::ParamInfo 
   rewind(config_file);
 
   // Run the config file through InitConfigFileParser
-  // throw away the error messages for now.
-
   InitConfigFileParser parser;
   Config* conf = parser.parseConfig(config_file);
   fclose(config_file);
@@ -142,12 +138,62 @@ create_config(const char* first, ...)
 
   InitConfigFileParser parser;
   Config* conf = parser.parseConfig(config_file);
-  CHECK(conf);
   fclose(config_file);
 
   return conf;
 }
 
+// Global variable for my_getopt
+extern "C" const char* my_defaults_file;
+
+Config*
+create_mycnf(const char* first, ...)
+{
+  va_list args;
+
+  NdbDir::Temp tempdir;
+  BaseString mycnf_file;
+  mycnf_file.assfmt("%s%s%s",
+                    tempdir.path(), DIR_SEPARATOR, "test_my.cnf");
+
+  FILE* config_file= fopen(mycnf_file.c_str(), "w+");
+  CHECK(config_file);
+
+  va_start(args, first);
+  const char* str= first;
+  do
+    fprintf(config_file, "%s\n", str);
+  while((str= va_arg(args, const char*)) != NULL);
+  va_end(args);
+
+#if 0
+  rewind(config_file);
+
+  char buf[100];
+  while(fgets(buf, sizeof(buf), config_file))
+    printf("%s", buf);
+#endif
+
+  rewind(config_file);
+
+  // Trick handle_options to read from the temp file
+  const char* save_defaults_file = my_defaults_file;
+  my_defaults_file = mycnf_file.c_str();
+
+  InitConfigFileParser parser;
+  Config* conf = parser.parse_mycnf();
+
+  // Restore the global variable
+  my_defaults_file = save_defaults_file;
+
+  fclose(config_file);
+
+  // Remove file
+  unlink(mycnf_file.c_str());
+
+  return conf;
+}
+
 
 
 
@@ -158,10 +204,12 @@ diff_config(void)
     create_config("[ndbd]", "NoOfReplicas=1",
                   "[ndb_mgmd]", "HostName=localhost",
                   "[mysqld]", NULL);
+  CHECK(c1);
   Config* c2=
     create_config("[ndbd]", "NoOfReplicas=1",
                   "[ndb_mgmd]", "HostName=localhost",
                   "[mysqld]", "[mysqld]", NULL);
+  CHECK(c2);
 
   CHECK(c1->equal(c1));
 
@@ -188,6 +236,7 @@ diff_config(void)
                     "DataMemory=100M", "IndexMemory=100M",
                     "[ndb_mgmd]", "HostName=localhost",
                     "[mysqld]", NULL);
+    CHECK(c1_bug47306);
 
     ndbout_c("c1->print_diff(c1_bug47306)");
     c1->print_diff(c1_bug47306);
@@ -268,10 +317,12 @@ checksum_config(void)
     create_config("[ndbd]", "NoOfReplicas=1",
                   "[ndb_mgmd]", "HostName=localhost",
                   "[mysqld]", NULL);
+  CHECK(c1);
   Config* c2=
     create_config("[ndbd]", "NoOfReplicas=1",
                   "[ndb_mgmd]", "HostName=localhost",
                   "[mysqld]", "[mysqld]", NULL);
+  CHECK(c2);
 
   ndbout_c("== checksum tests ==");
   Uint32 c1_check = c1->checksum();
@@ -294,14 +345,126 @@ checksum_config(void)
   delete c2;
 }
 
+static void
+test_param_values(void)
+{
+  struct test {
+    const char* param;
+    bool result;
+  } tests [] = {
+    // CI_ENUM
+    { "Arbitration=Disabled", true },
+    { "Arbitration=Invalid", false },
+    { "Arbitration=", false },
+    // CI_BITMASK
+    { "LockExecuteThreadToCPU=0", true },
+    { "LockExecuteThreadToCPU=1", true },
+    { "LockExecuteThreadToCPU=65535", true },
+    { "LockExecuteThreadToCPU=0-65535", true },
+    { "LockExecuteThreadToCPU=0-1,65534-65535", true },
+    { "LockExecuteThreadToCPU=17-256", true },
+    { "LockExecuteThreadToCPU=1-2,36-37,17-256,11-12,1-2", true },
+    { "LockExecuteThreadToCPU=", false }, // Zero size value not allowed
+    { "LockExecuteThreadToCPU=1-", false },
+    { "LockExecuteThreadToCPU=1--", false },
+    { "LockExecuteThreadToCPU=1-2,34-", false },
+    { "LockExecuteThreadToCPU=x", false },
+    { "LockExecuteThreadToCPU=x-1", false },
+    { "LockExecuteThreadToCPU=x-x", false },
+    { 0, false }
+  };
+
+  for (struct test* t = tests; t->param; t++)
+  {
+    ndbout_c("testing %s", t->param);
+    {
+      const Config* c =
+        create_config("[ndbd]", "NoOfReplicas=1",
+                      t->param,
+                      "[ndb_mgmd]", "HostName=localhost",
+                      "[mysqld]", NULL);
+      if (t->result)
+      {
+        CHECK(c);
+        delete c;
+      }
+      else
+      {
+        CHECK(c == NULL);
+      }
+    }
+    {
+      const Config* c =
+        create_mycnf("[cluster_config]",
+                     "ndb_mgmd=localhost",
+                     "ndbd=localhost,localhost",
+                     "ndbapi=localhost",
+                     "NoOfReplicas=1",
+                     t->param,
+                     NULL);
+      if (t->result)
+      {
+        CHECK(c);
+        delete c;
+      }
+      else
+      {
+        CHECK(c == NULL);
+      }
+    }
+  }
+
+}
+
+static void
+test_hostname_mycnf(void)
+{
+  // Check the special rule for my.cnf that says
+  // the two hostname specs must match
+  {
+    // Valid config, ndbd=localhost, matches HostName=localhost
+    const Config* c =
+      create_mycnf("[cluster_config]",
+                   "ndb_mgmd=localhost",
+                   "ndbd=localhost,localhost",
+                   "ndbapi=localhost",
+                   "NoOfReplicas=1",
+                   "[cluster_config.ndbd.1]",
+                   "HostName=localhost",
+                   NULL);
+    CHECK(c);
+    delete c;
+  }
+
+  {
+    // Invalid config, ndbd=localhost, does not match HostName=host1
+    const Config* c =
+      create_mycnf("[cluster_config]",
+                   "ndb_mgmd=localhost",
+                   "ndbd=localhost,localhost",
+                   "ndbapi=localhost",
+                   "NoOfReplicas=1",
+                   "[cluster_config.ndbd.1]",
+                   "HostName=host1",
+                   NULL);
+    CHECK(c == NULL);
+  }
+}
+
 #include <NdbTap.hpp>
 
+#include <EventLogger.hpp>
+extern EventLogger* g_eventLogger;
+
 TAPTEST(MgmConfig)
 {
   ndb_init();
+  g_eventLogger->createConsoleHandler();
   diff_config();
   CHECK(check_params());
   checksum_config();
+  test_param_values();
+  test_hostname_mycnf();
 #if 0
   print_restart_info();
 #endif

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20100827121251-w23xe3ot52jib34v.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3729) Bug#56185Magnus Blåudd27 Aug