List:Commits« Previous MessageNext Message »
From:magnus.blaudd Date:April 27 2012 8:05am
Subject:bzr push into mysql-trunk branch (magnus.blaudd:3895 to 3896) WL#5960
View as plain text  
 3896 magnus.blaudd@stripped	2012-04-27
      WL#5960 Start memcached from mysql-test-run.pl
       - Merge in removal of hardcoded port for memcached
        plus some review fixes.

    modified:
      mysql-test/lib/My/ConfigFactory.pm
      mysql-test/mysql-test-run.pl
 3895 Bjorn Munch	2012-04-19
      Removed some trailing whitespace

    modified:
      mysql-test/mysql-test-run.pl
=== modified file 'mysql-test/lib/My/ConfigFactory.pm'
--- a/mysql-test/lib/My/ConfigFactory.pm	2011-09-07 10:08:09 +0000
+++ b/mysql-test/lib/My/ConfigFactory.pm	2012-04-27 07:50:48 +0000
@@ -309,6 +309,16 @@ my @ndbd_rules=
 
 
 #
+# Rules to run for each memcached in the config
+#  - will be run in order listed here
+#
+my @memcached_rules=
+(
+ { '#host' => \&fix_host },
+ { 'port' => \&fix_port },
+);
+
+#
 # Rules to run for each cluster_config section
 #  - will be run in order listed here
 #
@@ -678,6 +688,10 @@ sub new_config {
 			   'mysqld.',
 			   @mysqld_rules);
 
+  $self->run_section_rules($config,
+			   'memcached.',
+			   @memcached_rules);
+               
   # [mysqlbinlog] need additional settings
   $self->run_rules_for_group($config,
 			     $config->insert('mysqlbinlog'),

=== modified file 'mysql-test/mysql-test-run.pl'
--- a/mysql-test/mysql-test-run.pl	2012-04-19 08:31:11 +0000
+++ b/mysql-test/mysql-test-run.pl	2012-04-27 07:50:48 +0000
@@ -248,7 +248,6 @@ our @opt_experimentals;
 our $experimental_test_cases= [];
 
 my $baseport;
-my $memcached_base_port;
 # $opt_build_thread may later be set from $opt_port_base
 my $opt_build_thread= $ENV{'MTR_BUILD_THREAD'} || "auto";
 my $opt_port_base= $ENV{'MTR_PORT_BASE'} || "auto";
@@ -1822,7 +1821,6 @@ sub set_build_thread_ports($) {
 
   mtr_report("Using MTR_BUILD_THREAD $build_thread,",
 	     "with reserved ports $baseport..".($baseport+9));
-  $memcached_base_port = $baseport + 8;
 
 }
 
@@ -3084,40 +3082,26 @@ sub ndbd_start {
 
 
 sub memcached_start {
-  my ($cluster, $memcached, $port_number) = @_;
+  my ($cluster, $memcached) = @_;
 
-  mtr_verbose("memcached_start");
+  my $name = $memcached->name();
+  mtr_verbose("memcached_start '$name'");
 
-  my $found_perl_source = my_find_file($basedir, 
+  my $found_perl_source = my_find_file($basedir,
      ["storage/ndb/memcache",        # source
       "mysql-test/lib",              # install
-      "share/mysql-test/lib"],       # install 
+      "share/mysql-test/lib"],       # install
       "memcached_path.pl", NOT_REQUIRED);
 
+  mtr_verbose("Found memcache script: '$found_perl_source'");
+  $found_perl_source ne "" or return;
+
   my $found_so = my_find_file($bindir,
-    ["storage/ndb/memcache/",       # source or build
+    ["storage/ndb/memcache",        # source or build
      "lib", "lib64"],               # install
-    "ndb_engine.so", NOT_REQUIRED);
-
-  mtr_verbose("Found memcache script: $found_perl_source");
-  mtr_verbose("Found memcache plugin: $found_so");
-
-  my $mgm_host;
-  my $mgm_port;
-  foreach my $mgmd ( in_cluster($cluster, ndb_mgmds()) ) {
-    $mgm_host = $mgmd->value('HostName');
-    $mgm_port = $mgmd->value('PortNumber');
-    last;
-  }
-  my $ndb_opt_string = "connectstring=$mgm_host:$mgm_port";
-  my $options = $memcached->value("options");
-  if($options) {
-    $ndb_opt_string = $ndb_opt_string . ";" . $options;
-  }
+    "ndb_engine.so");
+  mtr_verbose("Found memcache plugin: '$found_so'");
 
-
-  $found_perl_source ne "" or return;
-  $found_so ne "" or mtr_error("Failed to find ndb_engine.so");
   require "$found_perl_source";
   if(! memcached_is_available())
   {
@@ -3138,14 +3122,21 @@ sub memcached_start {
 
   my $args;
   mtr_init_args(\$args);
-  mtr_add_arg($args, "-p");
-  mtr_add_arg($args, $port_number);
-  mtr_add_arg($args, "-c");
-  mtr_add_arg($args,"100");   # max 100 connections
+  # TCP port number to listen on
+  mtr_add_arg($args, "-p %d", $memcached->value('port'));
+  # Max simultaneous connections
+  mtr_add_arg($args, "-c %d", $memcached->value('max_connections'));
+  # Load engine as storage engine, ie. /path/ndb_engine.so
   mtr_add_arg($args, "-E");
-  mtr_add_arg($args, $found_so);  # /path/ndb_engine.so
-  mtr_add_arg($args, "-e");
-  mtr_add_arg($args, "$ndb_opt_string");
+  mtr_add_arg($args, $found_so);
+  # Config options for loaded storage engine
+  {
+    my @opts;
+    push(@opts, "connectstring=" . $memcached->value('ndb_connectstring'));
+    push(@opts, $memcached->if_exist("options"));
+    mtr_add_arg($args, "-e");
+    mtr_add_arg($args, join(";", @opts));
+  }
 
   if($opt_gdb)
   {
@@ -3153,12 +3144,13 @@ sub memcached_start {
   }
 
   my $proc = My::SafeProcess->new
-  ( name     =>  "memcached",
+  ( name     =>  $name,
     path     =>  $exe,
     args     => \$args,
-    output   =>  "$opt_vardir/log/memcached.out",
-    error    =>  "$opt_vardir/log/memcached.out",
+    output   =>  "$opt_vardir/log/$name.out",
+    error    =>  "$opt_vardir/log/$name.out",
     append   =>  1,
+    verbose  => $opt_verbose,
   );
   mtr_verbose("Started $proc");
 
@@ -3171,22 +3163,22 @@ sub memcached_start {
 sub memcached_load_metadata($) {
   my $cluster= shift;
 
+  foreach my $mysqld (mysqlds())
+  {
+    if(-d $mysqld->value('datadir') . "/" . "ndbmemcache")
+    {
+      mtr_verbose("skipping memcache metadata (already stored)");
+      return;
+    }
+  }
+
   my $sql_script= my_find_file($bindir,
                               ["share/mysql/memcache-api", # RPM install
                                "share/memcache-api",       # Other installs
                                "scripts"                   # Build tree
                               ],
                               "ndb_memcache_metadata.sql", NOT_REQUIRED);
-
-  foreach my $mysqld (mysqlds()) {
-    if(-d $mysqld->value('datadir') . "/" . "ndbmemcache") {
-      mtr_verbose("skipping memcache metadata (already stored)");
-      return;
-    }
-  }
-
-  mtr_verbose("memcached_load_metadata: $sql_script");
-
+  mtr_verbose("memcached_load_metadata: '$sql_script'");
   if (-f $sql_script )
   {
     my $args;
@@ -3194,8 +3186,6 @@ sub memcached_load_metadata($) {
     mtr_add_arg($args, "--defaults-file=%s", $path_config_file);
     mtr_add_arg($args, "--defaults-group-suffix=%s", $cluster->suffix());
     mtr_add_arg($args, "--connect-timeout=20");
-
-    mtr_verbose("Script: $sql_script");
     if ( My::SafeProcess->run(
            name   => "ndbmemcache config loader",
            path   => $exe_mysql,
@@ -4383,7 +4373,7 @@ sub run_testcase ($) {
     }
 
     # Try to dump core for mysqltest and all servers
-    foreach my $proc ($test, started(all_servers())) 
+    foreach my $proc ($test, started(all_servers()))
     {
       mtr_print("Trying to dump core for $proc");
       if ($proc->dump_core())
@@ -5678,24 +5668,19 @@ sub start_servers($) {
     }
   }
 
-  # Start memcached if needed
-  foreach my $cluster (clusters())
-  { 
-    if(memcacheds())
-    {
-      my $avail_port = $memcached_base_port;
-      my $memcached;
-      memcached_load_metadata($cluster);
+  # Start memcached(s) for each cluster
+  foreach my $cluster ( clusters() )
+  {
+    next if !in_cluster($cluster, memcacheds());
 
-      # Start them
-      foreach $memcached( in_cluster($cluster, memcacheds()) )
-      {
-        if(! started($memcached))
-        {
-          memcached_start($cluster, $memcached, $avail_port);
-        }
-        $avail_port += 1;
-      }
+    # Load the memcache metadata into this cluster
+    memcached_load_metadata($cluster);
+
+    # Start memcached(s)
+    foreach my $memcached ( in_cluster($cluster, memcacheds()))
+    {
+      next if started($memcached);
+      memcached_start($cluster, $memcached);
     }
   }
 

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (magnus.blaudd:3895 to 3896) WL#5960magnus.blaudd27 Apr