List:Commits« Previous MessageNext Message »
From:Serge Kozlov Date:January 30 2011 9:09pm
Subject:bzr commit into nuts branch (Serge.Kozlov:389)
View as plain text  
#At file:///home/ksm/oracle/QA/nuts/ based on revid:serge.kozlov@stripped

  389 Serge Kozlov	2011-01-31
      Cumulative patch:
      - redesign rep tests
      - new function ok_diff_databases
      - dump for failures

    modified:
      lib/My/Nuts/Library/DataSource.pm
      lib/My/Nuts/Library/Kernel/Manager.pm
      lib/My/Nuts/Library/Kernel/Replication.pm
      lib/My/Nuts/Library/Kernel/Server.pm
      lib/My/Nuts/Library/Kernel/ServerResult.pm
      lib/My/Nuts/Management/Manager.pm
      lib/My/Nuts/Management/SimpleDeployer.pm
      suites/rep/chained_diff_engine.pm
      suites/rep/client_redirect/client_redirect.pm
      suites/rep/hot_standby.pm
      suites/rep/seconds_behind_master.pm
      suites/rep/semisync.pm
      suites/rep/stress_mixed/DML.txt
      suites/rep/stress_mixed/stress_mixed.pm
      suites/rep_func/crash_safe_master.pm
=== modified file 'lib/My/Nuts/Library/DataSource.pm'
--- a/lib/My/Nuts/Library/DataSource.pm	2011-01-26 20:13:29 +0000
+++ b/lib/My/Nuts/Library/DataSource.pm	2011-01-30 21:09:31 +0000
@@ -39,7 +39,7 @@ sub get_data_from_source
 	my $data_source= $class->new();
 	$queries= $data_source->get_data_from_source();
 	# Store generated queries into log directory
-	my $dumpname= File::Spec->catfile($Parameters::work_dir, "log", "DataSource_" . $Parameters::data_source . ".sql");
+	my $dumpname= File::Spec->catfile($Parameters::work_dir, "tmp", "DataSource_" . $Parameters::data_source . ".sql");
 	$dumpfile= new IO::File($dumpname, "w") 
 	    or die("Cannot open dump file " . $dumpname);
 	print $dumpfile join(";\n", @$queries);

=== modified file 'lib/My/Nuts/Library/Kernel/Manager.pm'
--- a/lib/My/Nuts/Library/Kernel/Manager.pm	2011-01-19 22:37:05 +0000
+++ b/lib/My/Nuts/Library/Kernel/Manager.pm	2011-01-30 21:09:31 +0000
@@ -5,7 +5,7 @@ our @EXPORT =
   qw(get_server start_server ok_start_server stop_server ok_stop_server deploy_server 
     undeploy_server wait_start_server ok_wait_start_server wait_stop_server 
     ok_wait_stop_server get_data_dir get_base_dir get_started_server
-    updown_server ok_updown_server get_test_tmp_dir);
+    updown_server ok_updown_server get_test_tmp_dir get_suites_dir);
 use strict;
 use warnings;
 use My;
@@ -281,6 +281,12 @@ sub get_test_tmp_dir
     return $manager->get_test_tmp_dir ();
 }
 
+sub get_suites_dir
+{
+    my $manager = $My::Nuts::Management::Manager::reference;
+    return $manager->get_suites_dir ();
+}
+
 
 1;
 __END__

=== modified file 'lib/My/Nuts/Library/Kernel/Replication.pm'
--- a/lib/My/Nuts/Library/Kernel/Replication.pm	2011-01-18 23:02:07 +0000
+++ b/lib/My/Nuts/Library/Kernel/Replication.pm	2011-01-30 21:09:31 +0000
@@ -49,7 +49,7 @@ sub replication_mode
 
 sub ok_attach
 {
-    my ( $master, $slave ) = @_;
+    my ( $master, $slave, %param ) = @_;
     if ( is_server ($master) == My::FALSE || is_server ($slave) == My::FALSE )
     {
         ok ( 0, "Error in the parameters for ok_attach" )
@@ -446,13 +446,12 @@ sub ok_synchronize
         return (1);
     }
     my $ret = synchronize (@_);
-    ok (
-         $ret == 0,
-         "synchronize slave "
-           . $slave->get_server_id ()
-           . " with master "
-           . $master->get_server_id ()
-    ) or diag ("Error synchronizing slave and master.");
+    if (! ok($ret == 0, "synchronize slave ". $slave->get_server_id()
+	. " with master " . $master->get_server_id()))
+    {	
+	diag ("Error synchronizing slave and master");
+	
+    }
     return ($ret);
 }
 
@@ -481,8 +480,9 @@ sub get_changemaster
     {
         $command =
           $command
+          . ", MASTER_CONNECT_RETRY = "
           . ( $param{master_connect_retry}
-              ? ", MASTER_CONNECT_RETRY = " . $param{master_connect_retry}
+              ? $param{master_connect_retry}
               : "20" );
         $command =
           $command

=== modified file 'lib/My/Nuts/Library/Kernel/Server.pm'
--- a/lib/My/Nuts/Library/Kernel/Server.pm	2011-01-19 22:37:05 +0000
+++ b/lib/My/Nuts/Library/Kernel/Server.pm	2011-01-30 21:09:31 +0000
@@ -5,7 +5,8 @@ our @EXPORT =
   qw(execute get_buildproperties get_my_properties get_dsn 
   set_buildproperties set_my_properties async_sql async_result 
   async_function async_join ok_sql err_sql sql ok_execute 
-  ok_async_result state check ok_system get_ip_address get_port);
+  ok_async_result state check ok_system get_ip_address get_port 
+  get_server_id);
 use strict;
 use warnings;
 use My;
@@ -242,6 +243,14 @@ sub get_port
     return $server->get_port();
 }
 
+sub get_server_id
+{
+    my ($server) = @_;
+    return $server->get_server_id();
+}
+
+
+
 1;
 __END__
 

=== modified file 'lib/My/Nuts/Library/Kernel/ServerResult.pm'
--- a/lib/My/Nuts/Library/Kernel/ServerResult.pm	2011-01-19 22:37:05 +0000
+++ b/lib/My/Nuts/Library/Kernel/ServerResult.pm	2011-01-30 21:09:31 +0000
@@ -2,8 +2,8 @@ package My::Nuts::Library::Kernel::Serve
 use Exporter;
 our @ISA = qw(Exporter);
 our @EXPORT =
-  qw(ok_diff_databases diff_databases compare_dbs ok_compare_dbs get_supported_engines get_table_list get_variable get_status 
-    get_errmsg_by_num ok_wait_status ok_wait_sql);
+  qw(ok_diff_databases diff_databases get_supported_engines get_table_list get_variable get_status 
+    get_errmsg_by_num ok_wait_status ok_wait_sql dump_sql dump_server_state);
 use strict;
 use warnings;
 use My;
@@ -15,10 +15,12 @@ use My::Nuts::Library::Kernel::Manager;
 use My::Nuts::Library::File;
 use My::Nuts::Report::Debug;
 use My::Nuts::util::mysql;
+use IO::File;
 use Test::More;
 
 my $errmsg = undef;
 my $diff = "/usr/bin/diff";
+my $fail_index= 1;
 
 sub diff_databases
 {
@@ -27,7 +29,7 @@ sub diff_databases
     # Sort input
     for (my $i = 0; $i < scalar(@_); $i=$i+2)
     {
-	push(@$data, {"connection" => $_[$i], "database" => $_[$i+1], "index" => ($i/2 + 1)} );
+	push(@$data, {"connection" => $_[$i], "database" => $_[$i+1], "index" => get_server_id($_[$i])} );
     }
     # Get the list of table names
     my $tablelist_p;
@@ -59,37 +61,39 @@ sub diff_databases
 	{
 	    foreach my $tname ( @tablelist )
 	    {
-		$data_item->{"table_count"}->{$tname}= sql_result($data_item->{"connection"}, "SELECT COUNT(*) FROM $tname");
-	        
+		$data_item->{"table_count"}->{$tname}= sql_result($data_item->{"connection"}, "SELECT COUNT(*) FROM $tname");	        
+		$data_item->{"table_dumpfile"}->{$tname}= File::Spec->catfile(get_test_tmp_dir(), 
+		"server_".$data_item->{"index"} . "." . $data_item->{"database"} . "." . $tname .  ".dump");
 	    }
 	}
 	# Compare number of records for same tables for different connections 
 	foreach my $data_item ( @$data )
 	{
-	    $data_item->{"mysqldump"}= find_mysql_bin(get_base_dir($data_item->{"connection"}), "mysqldump");
+	    $data_item->{"mysql"}= find_mysql_bin(get_base_dir($data_item->{"connection"}), "mysql");
 	    foreach my $tname ( @tablelist )
 	    {
-		$data_item->{"table_dumpfile"}->{$tname}= File::Spec->catfile(get_test_tmp_dir(), 
-		    $data_item->{"index"} . "_" . $data_item->{"database"} . "." . $tname . ".sql");
 		if ($data->[0]->{"table_count"}->{$tname} != $data_item->{"table_count"}->{$tname})
 		{
-		    push(@result, 1, "Query 'SELECT COUNT(*) FROM $tname' returns different number of rows: " 
-			. $data->[0]->{"table_count"}->{$tname} . ", " 
-			. $data_item->{"table_count"}->{$tname});			
-		    diag("Dump file 1: " . $data->[0]->{"table_dumpfile"}->{$tname}); 
-		    diag("Dump file " . $data_item->{"index"}. ": " . $data_item->{"table_dumpfile"}->{$tname});
 		    # Dump data to file
-		    system($data->[0]->{"mysqldump"} . " -uroot --compact --no-create-info --skip-extended-insert --host=" 
+		    system($data->[0]->{"mysql"} . " -uroot -t --host=" 
 			. get_ip_address($data->[0]->{"connection"})
 			. " --port=" . get_port($data->[0]->{"connection"})
-			. " " . $data->[0]->{"database"} . " " . $tname 
+			. " -e 'SELECT * FROM " . $data->[0]->{"database"} . "." . $tname . "'"
 			. " > " . $data->[0]->{"table_dumpfile"}->{$tname});   
-		    system($data_item->{"mysqldump"} . " -uroot --compact --no-create-info --skip-extended-insert --host=" 
+		    _sort_lines_in_file($data->[0]->{"table_dumpfile"}->{$tname});		    
+		    system($data_item->{"mysql"} . " -uroot -t --host=" 
 			. get_ip_address($data_item->{"connection"})
 			. " --port=" . get_port($data_item->{"connection"})
-			. " " . $data_item->{"database"} . " " . $tname 
+			. " -e 'SELECT * FROM " . $data_item->{"database"} . "." . $tname . "'"
 			. " > " . $data_item->{"table_dumpfile"}->{$tname});   
 			
+		    _sort_lines_in_file($data_item->{"table_dumpfile"}->{$tname});		    
+		    push(@result, 1, "Query 'SELECT COUNT(*) FROM $tname' returns different number of rows: " 
+			. $data->[0]->{"table_count"}->{$tname} . ", " 
+			. $data_item->{"table_count"}->{$tname} . "\n Table dumps are:\n"			
+			    . _rename_file_with_prefix($data->[0]->{"table_dumpfile"}->{$tname}, "failure_$fail_index.") . ",\n" 
+			    . _rename_file_with_prefix($data_item->{"table_dumpfile"}->{$tname}, "failure_$fail_index.")
+		    );
 		    last;
 		}		
 	    }	
@@ -103,7 +107,7 @@ sub diff_databases
 	{
 	    foreach my $data_item ( @$data )
 	    {
-		my $mysqldump = find_mysql_bin(get_base_dir($data_item->{"connection"}), "mysqldump");
+		my $mysqldump = find_mysql_bin(get_base_dir($data_item->{"connection"}), "mysql");
 		foreach my $tname ( @tablelist )
 		{
 		    my $order_list = get_table_pk_column_list($data_item->{"connection"}, $tname);
@@ -113,11 +117,12 @@ sub diff_databases
 			$order_list = $select_list;
 		    }
 		    # Dump data to file
-		    system($data_item->{"mysqldump"} . " -uroot --compact --no-create-info --skip-extended-insert --host=" 
+		    system($data_item->{"mysql"} . " -uroot -t --host=" 
 			. get_ip_address($data_item->{"connection"})
 			. " --port=" . get_port($data_item->{"connection"})
-			. " " . $data_item->{"database"} . " " . $tname 
+			. " -e 'SELECT * FROM " . $data_item->{"database"} . "." . $tname  . "'"
 			. " > " . $data_item->{"table_dumpfile"}->{$tname});   
+		    _sort_lines_in_file($data_item->{"table_dumpfile"}->{$tname});		    
 		}		
 	    }		    
     	    # Run diff
@@ -129,9 +134,10 @@ sub diff_databases
 		    my $diff_res = `$diff_line`;
 		    if ($diff_res =~ m/^.+$/)
 		    {
-			push(@result, 1, "Found diff for dump files of table $tname: " 
-			    . $data->[0]->{"table_dumpfile"}->{$tname} . ", " 
-			    . $data_item->{"table_dumpfile"}->{$tname});
+			push(@result, 1, "Found diff for dump files of table $tname:\n" 
+			    . _rename_file_with_prefix($data->[0]->{"table_dumpfile"}->{$tname}, "failure_$fail_index.") . ",\n" 
+			    . _rename_file_with_prefix($data_item->{"table_dumpfile"}->{$tname}, "failure_$fail_index.")
+			);
 			last;
 		    }
 		}	
@@ -139,7 +145,19 @@ sub diff_databases
 		{
 		    last;
 		}
-	    }        
+	    }
+	    #  Remove dump files except ones where the diff found
+	    foreach my $data_item ( @$data )
+	    {
+		foreach my $tname ( @tablelist )
+		{
+		    my $curfile= $data_item->{"table_dumpfile"}->{$tname};
+		    if ( -e $curfile )
+		    {
+			unlink($curfile);
+		    }
+		}
+	    }	    
         }
         # Final conclusion: databases have no diff
 	if (scalar(@result) == 0)
@@ -152,91 +170,16 @@ sub diff_databases
 
 sub ok_diff_databases
 {
-  my @result = diff_databases(@_);
-  ok ( $result[0] == 0, $result[1]) or diag ($result[1]);
-}
-
-sub compare_dbs
-{
-  my $params = shift;
-  my $ok = 1;
-  my $table_list = {};
-  my $server_ids = {};
-  my $text = "Compare DBs:";
-  # Find tables
-  foreach my $option (@$params)
-  {
-    my $conn = $option->{"conn"};
-    my $dbname = $option->{"dbname"};
-    my $rs = sql ( $conn, "SHOW TABLES FROM $dbname;" );
-    my @rs_data = get_next($rs);
-    while (defined $rs_data[0])
-    {
-      $table_list->{$rs_data[0]}->{($conn,$dbname)} = 1;
-      @rs_data = get_next($rs);
-    }
-    $server_ids->{$conn} = My::Nuts::Instance::Server::get_server_id($conn);;
-  }
-  # Compare table lists
-  foreach my $table_name (keys %$table_list)
-  {
-    if (keys(%{$table_list->{$table_name}}) < scalar(@$params))
+    my @result = diff_databases(@_);
+    if (!ok ( $result[0] == 0, "comparison of databases"))
     {
-      $ok= 0;
-      foreach my $option (@$params)
-      {
-	my $conn = $option->{"conn"};
-	my $dbname = $option->{"dbname"};
-	if (!defined($table_list->{$table_name}->{($conn,$dbname)}))
-	{
-    	  $text .= " table $dbname\.$table_name does not exist on server " . $server_ids->{$conn} . ";";	
-	}
-      }
-      last;
-    }
-  }  
-  if ($ok == 1)
-  { 
-    # Compare data on tables   
-    foreach my $table_name (keys %$table_list)
-    {
-      my $conn1 = undef;
-      my $dbname1 = undef;
-      foreach my $option (@$params)
-      {
-        my $conn = $option->{"conn"};
-        my $dbname = $option->{"dbname"};
-        if (defined $conn1)
-        {
-          my $rs = sql ($conn, "SELECT * FROM $dbname\.$table_name;" );
-          my $rs1 = sql ($conn1, "SELECT * FROM $dbname1\.$table_name;" );
-          if ( (compare_results($rs, $rs1)) != 1)
-          {
-            $ok = 0;
-    	    $text .= " table $dbname1\.$table_name on server " . $server_ids->{$conn1} . " and table $dbname\.$table_name on server " . $server_ids->{$conn} . " are different;";
-    	    last;
-          }
-        }
-        else
+        diag ($result[1]);
+        for (my $i = 0; $i < scalar(@_); $i = $i + 2)
         {
-          $conn1 = $conn;
-          $dbname1 = $dbname;
+    	    dump_server_state($_[$i]);
         }
-      }
+	$fail_index++;
     }
-  }
-  if ($ok == 1)
-  {
-    $text .= " Databases are equal";
-  }
-  return ($ok, $text);
-}
-
-sub ok_compare_dbs
-{
-  my $params = shift;
-  my @result = compare_dbs($params);
-  ok ( $result[0] == 1, $result[1]) or diag ($result[1]);
 }
 
 sub sql_result
@@ -399,12 +342,12 @@ sub ok_wait_status
 {
     my ($server, $var_name, $var_value, $timeout) = @_;
     $timeout= 30 if (!defined($timeout));
-    my $cur_value = get_status({"conn" => $server, "var" => $var_name});
+    my $cur_value = get_status($server, $var_name);
     if (defined($cur_value))
     {
 	while ($var_value !~ m/^$cur_value$/ && $timeout > 0)
 	{
-	    $cur_value= get_status({"conn" => $server, "var" => $var_name});
+	    $cur_value= get_status($server, $var_name);
 	    $timeout--;
 	    sleep 1;
 	}
@@ -429,6 +372,72 @@ sub ok_wait_sql
     ok($timeout > 0, "Waiting " . $query);
 }
 
+sub dump_sql
+{
+    my ($conn, $query, $filename) = @_;
+    my $mysql= find_mysql_bin(get_base_dir($conn), "mysql");
+    my $path= File::Spec->catfile(get_test_tmp_dir(), $filename);
+    diag("Dump query '$query' to file '$path'");
+    system($mysql . " -uroot -t --host=" . get_ip_address($conn)
+	. " --port=" . get_port($conn)
+	. " -e '$query'"
+	. " > " . $path);   
+}
+
+sub dump_server_state
+{
+    my ($conn)= @_;
+    my @queries = (
+	"SHOW MASTER STATUS", 
+	"SHOW BINLOG EVENTS", 
+	"SHOW SLAVE STATUS\\G", 
+	"SHOW RELAYLOG EVENTS",
+	"SHOW PROCESSLIST",
+	"SHOW STATUS"
+    );
+    my $tag = "failure_$fail_index";
+    diag("Dump server " . get_server_id($conn). " state. Prefix is '$tag'");
+    foreach my $query (@queries)
+    {
+	my $filename= $query;
+	$filename =~ s/\ /_/g;
+	$filename =~ s/\\G//g;
+	$filename = $tag . ".server_" . get_server_id($conn) . "." . $filename . ".dump";
+	dump_sql($conn, $query, $filename);
+    }
+}
+
+sub _sort_lines_in_file
+{
+    my ($filename)= @_;
+    my $fh= new IO::File($filename, "r");
+    my @lines= $fh->getlines();
+    $fh= undef;
+    my @header = ();
+    if (scalar(@lines) > 2)
+    {
+	push(@header, shift @lines, shift @lines, shift @lines);
+    }
+    my $bottom = "";
+    if (scalar(@lines) > 0)
+    {
+	$bottom = pop @lines;
+    }
+    $fh= new IO::File($filename, "w");
+    print $fh join("", @header) . join("", sort @lines) . $bottom;
+    $fh= undef;
+}
+
+sub _rename_file_with_prefix
+{
+    my ($origfile, $prefix)= @_;
+    my ($vol, $path, $filename)= File::Spec->splitpath($origfile);
+    $filename = $prefix.$filename;
+    my $newfile = File::Spec->catfile($vol, $path, $filename);
+    rename($origfile,$newfile) or diag("Cannot rename: ". $!);
+    return $newfile;
+}
+
 1;
 
 __END__;

=== modified file 'lib/My/Nuts/Management/Manager.pm'
--- a/lib/My/Nuts/Management/Manager.pm	2011-01-19 22:37:05 +0000
+++ b/lib/My/Nuts/Management/Manager.pm	2011-01-30 21:09:31 +0000
@@ -441,4 +441,12 @@ sub get_test_tmp_dir
   return $active_tests_data{$ident}{$current_test}{"test_tmpdir"};
 }
 
+sub get_suites_dir
+{
+  my ($self) = @_;
+  my $ident = ident ($self);
+  return $Parameters::suites_dir;
+}
+
+
 1;

=== modified file 'lib/My/Nuts/Management/SimpleDeployer.pm'
--- a/lib/My/Nuts/Management/SimpleDeployer.pm	2010-07-20 17:16:26 +0000
+++ b/lib/My/Nuts/Management/SimpleDeployer.pm	2011-01-30 21:09:31 +0000
@@ -512,8 +512,10 @@ sub _start_server
           . $full_base_dir
           . " --datadir="
           . $full_data_dir
-	  . $lang
-          . " --log-slave-updates";
+	  . $lang;
+	  # Add option only for replication test cases
+	  # Should be fixed in future
+	  $command .= " --log-slave-updates" if (join(";", values %INC) =~ m/My(\/|\\)Nuts(\/|\\)Library(\/|\\)Kernel(\/|\\)Replication\.pm\;/i);          
     }
     else
     {

=== modified file 'suites/rep/chained_diff_engine.pm'
--- a/suites/rep/chained_diff_engine.pm	2010-08-17 20:30:52 +0000
+++ b/suites/rep/chained_diff_engine.pm	2011-01-30 21:09:31 +0000
@@ -13,12 +13,12 @@ use My::Nuts::Library::Kernel::Replicati
 use My::Nuts::Library::DataSource;
 use Test::More;
 my @combinations = (
-    "row", "mixed", "stmt"
+    "row", "mix", "stmt"
 );
     
 my %decode_combination = (
     "row" => "ROW",
-    "mixed" => "MIXED",
+    "mix" => "MIXED",
     "stmt" => "STATEMENT"
 );
                 
@@ -31,7 +31,7 @@ sub combinations
         {
             # Skip cases when replication can not work properly
     	    next if ($comb1 eq "row" && $comb2 ne "row");
-            next if ($comb1 eq "mixed" && $comb2 eq "stmt");
+            next if ($comb1 eq "mix" && $comb2 eq "stmt");
             push (@pairs, "$comb1-$comb2");
         }
     }
@@ -54,15 +54,15 @@ sub fire
     # Get combination
     my @binlog_formats = split("-", get_combination($test));
     # Server A
-    my $master = ok_server ($test);
+    my $master = server ($test);
     # Supported engines for A
     my $engines_a = get_supported_engines($master, "(^MYISAM|INNODB|MEMORY)");
     # Server B (middle)
-    my $master_middle = ok_server ($test);
+    my $master_middle = server ($test);
     # Supported engines for B
     my $engines_b = get_supported_engines($master_middle, "(^MYISAM|INNODB|MEMORY)");
     # Server C
-    my $slave = ok_server ($test);
+    my $slave = server ($test);
     # Test DB name
     my $dbname  = "test";
     
@@ -87,6 +87,7 @@ sub fire
 	  push(@$data, [$master_middle, undef, "USE " . $dbname]);
 	  push(@$data, [$master_middle, $slave, "TEST: synchronize"]);
 	  push(@$data, [$slave, undef, "USE " . $dbname]);
+	  $test_plan= $test_plan + 2;
 	  foreach my $query (@$src_data)
 	  {
 	    my $rs;
@@ -125,6 +126,7 @@ sub fire
 	      push(@$data, [$master_middle, undef, "ALTER TABLE $table_name ENGINE = $engine_b;"]);
 	      push(@$data, [$master_middle, $slave, "TEST: synchronize"]);
 	      push(@$data, [$slave, undef, "ALTER TABLE $table_name ENGINE = $engine_a;"]);
+	      $test_plan= $test_plan + 2;
 	    }
 	    else
 	    {
@@ -137,21 +139,22 @@ sub fire
 	  push(@$data, [$master, $master_middle, "TEST: synchronize"]);
 	  push(@$data, [$master_middle, $slave, "TEST: synchronize"]);
 	  push(@$data, [undef, undef, "TEST: compare_db"]);	          
+	  $test_plan= $test_plan + 3;
 	}	
       }	
     }
-    plan tests => scalar(@$data) + 6;
-    sql ($slave, "DROP DATABASE " . $dbname);    
+    plan tests => $test_plan + 9;
+    ok_sql ($slave, "DROP DATABASE " . $dbname);    
 
     # Setup topology	
     ok_sql ( $master, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $master, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $master_middle, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     ok_sql ( $master_middle, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
-    attach ( $master, $master_middle );
+    ok_attach ( $master, $master_middle );
     ok_sql ( $slave, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     ok_sql ( $slave, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
-    attach ( $master_middle, $slave );
+    ok_attach ( $master_middle, $slave );
 
     # Main loop of test: run all statements
     foreach my $qinfo (@$data)
@@ -162,15 +165,15 @@ sub fire
       }
       elsif ($qinfo->[2] =~ m/TEST\: compare\_db/i)
       {
-        ok_compare_dbs([
-    	  {"conn" => $master, "dbname" => "test"},
-    	  {"conn" => $master_middle, "dbname" => "test"},
-    	  {"conn" => $slave, "dbname" => "test"}        
-        ]);
+        ok_diff_databases(
+    	  $master, "test",
+    	  $master_middle, "test",
+    	  $slave, "test"
+        );
       }
       else
       {
-        ok_sql($qinfo->[0], $qinfo->[2]);
+        sql($qinfo->[0], $qinfo->[2]);
       }
     }
 }

=== modified file 'suites/rep/client_redirect/client_redirect.pm'
--- a/suites/rep/client_redirect/client_redirect.pm	2011-01-18 23:02:07 +0000
+++ b/suites/rep/client_redirect/client_redirect.pm	2011-01-30 21:09:31 +0000
@@ -9,31 +9,27 @@ use My::Nuts::Library::Kernel::Server;
 use My::Nuts::Library::Kernel::ServerResult;
 use My::Nuts::Library::Kernel::Manager;
 use My::Nuts::Library::Kernel::Result;
-use My::Nuts::Library::Tests::SimpleTest;
 use My::Nuts::Library::Kernel::Replication;
 use My::Nuts::Library::DataSource;
+use My::Nuts::Library::Tests::SimpleTest;
 use Test::More;
 
-my @combinations = (
-    "row", "mixed", "stmt"
-);
-    
 my %decode_combination = (
     "row" => "ROW",
-    "mixed" => "MIXED",
+    "mix" => "MIXED",
     "stmt" => "STATEMENT"
 );
         
 sub combinations
 {
     my @pairs = ();
-    foreach my $comb1 (@combinations)
+    foreach my $comb1 (keys %decode_combination)
     {
-        foreach my $comb2 (@combinations)
+        foreach my $comb2 (keys %decode_combination)
         {
     	    # Skip cases when replication can not work properly
     	    next if ($comb1 eq "row" && $comb2 ne "row");
-    	    next if ($comb1 eq "mixed" && $comb2 eq "stmt");
+    	    next if ($comb1 eq "mix" && $comb2 eq "stmt");
     	    push (@pairs, "$comb1-$comb2");
         }
     }
@@ -55,12 +51,18 @@ sub fire
     my ($test) = @_;
     # Get combination
     my @binlog_formats = split("-", get_combination($test));
+
+    # Set test plan
+    plan tests => 31;
+
     # Server A
     my $master = ok_server ($test);
-    my $master_dsn = My::Nuts::Instance::Server::get_dsn($master);
+    my $master_dsn = get_dsn($master);
+    
     # Server B (middle)
     my $master_middle = ok_server ($test);
-    my $middle_dsn = My::Nuts::Instance::Server::get_dsn($master_middle);
+    my $middle_dsn = get_dsn($master_middle);
+    
     # Server C
     my $slave = ok_server ($test);
 
@@ -72,24 +74,32 @@ sub fire
     # Read list of statements from data source and write into dump
     # It will be used external clients.
     my $data = get_data_from_source();
-    my $orig_table_num = scalar((grep(/^CREATE.+TABLE/ig, @$data)));
-    my $qfile = $Parameters::work_dir . "/tmp/data_source_dump";
+    my $orig_table_num= 0;
+    foreach my $query ( @$data )
+    {
+	if ($query =~ m/^create +table/i)
+	{
+	    $orig_table_num++;
+	}
+	elsif ($query =~ m/^[a-z]+/i)
+	{
+	    last;
+	}
+    }
+    my $qfile = File::Spec->catfile(get_test_tmp_dir(), "data_source.dump");
     my $dump_file = new IO::File($qfile, "w+");
     print $dump_file join ("\n", @$data);
     $dump_file = undef;
     
-    # Set test plan
-    plan tests => scalar(@$data) + 26;
-
     # Setup topology
     ok_sql ( $master, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $master, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $master_middle, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     ok_sql ( $master_middle, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
-    attach ( $master, $master_middle );
+    ok_attach ( $master, $master_middle );
     ok_sql ( $slave, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     ok_sql ( $slave, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
-    attach ( $master_middle, $slave );
+    ok_attach ( $master_middle, $slave );
     
     # Initialization
     ok_sql ( $master, "DROP DATABASE IF EXISTS $dbname1;");
@@ -133,7 +143,7 @@ sub fire
             my $cur_tables;
 	    while (($cur_table_num < $orig_table_num) && ($timeout > 0))
 	    {
-	      $cur_tables = get_table_list($master_middle, $dbname1});
+	      $cur_tables = get_table_list($master_middle, $dbname1);
 	      $cur_table_num = scalar(@$cur_tables);
 	      sleep 1;
 	      $timeout--;
@@ -151,23 +161,27 @@ sub fire
     	ok($? == 0, "Client 2 exit status");
       }
     }
+    
     # Create initial DB on Server C
     ok_sql ( $slave, "DROP DATABASE IF EXISTS $dbname3;");
     ok_sql ( $slave, "CREATE DATABASE $dbname3;");
     ok_sql ( $slave, "USE $dbname3;");
     foreach my $query (@$data)
     {
-	ok_sql($slave, $query);
+	sql($slave, $query);
     }
-    # Compare dbs
+    
+    # Compare databases
     # Since we use same data source for both external clients and for initial DB 
     # all databases should be equivalent
     ok_synchronize( $master_middle, $slave );
-    ok_compare_dbs([
-      {"conn" => $slave, "dbname" => $dbname1},
-      {"conn" => $slave, "dbname" => $dbname2},
-      {"conn" => $slave, "dbname" => $dbname3}    
-    ]);
+    ok_diff_databases(
+      $slave, $dbname1,
+      $slave, $dbname2,
+      $slave, $dbname3    
+    );
+    
+    # Clean up
     ok_sql ( $master_middle, "DROP DATABASE IF EXISTS $dbname1;");
     ok_sql ( $master_middle, "DROP DATABASE IF EXISTS $dbname2;");
     ok_synchronize( $master_middle, $slave );
@@ -217,4 +231,4 @@ and the original.
 
 =head1 AUTHOR
 
-Serge Kozlov S<< <Serge.Kozlov@stripped> >>
+Serge Kozlov S<< <Serge.Kozlov@stripped.> >>

=== modified file 'suites/rep/hot_standby.pm'
--- a/suites/rep/hot_standby.pm	2010-08-17 20:30:52 +0000
+++ b/suites/rep/hot_standby.pm	2011-01-30 21:09:31 +0000
@@ -14,12 +14,12 @@ use My::Nuts::Library::DataSource;
 use Test::More;
 
 my @combinations = (
-    "row", "mixed", "stmt" 
+    "row", "mix", "stmt" 
 );
 
 my %decode_combination = (
     "row" => "ROW", 
-    "mixed" => "MIXED",
+    "mix" => "MIXED",
     "stmt" => "STATEMENT"
 );
 
@@ -32,7 +32,7 @@ sub combinations
 	{
 	    # Skip cases when replication can not work properly
 	    next if ($comb1 eq "row" && $comb2 ne "row");
-	    next if ($comb1 eq "mixed" && $comb2 eq "stmt");
+	    next if ($comb1 eq "mix" && $comb2 eq "stmt");
 	    push (@pairs, "$comb1-$comb2");
 	}
     }
@@ -53,6 +53,10 @@ sub fire
 {
     my ($test) = @_;
     my @binlog_formats = split("-", get_combination($test));
+
+    # Number of subtests
+    plan tests => 32;
+
     my $master = ok_server ($test);
     my $master_extra = ok_server ($test);
     my $slave = ok_server ($test);
@@ -60,9 +64,6 @@ sub fire
     # read list of statements from data source
     my $data = get_data_from_source();
     
-    # summarize number of statements and ok_* command in test
-    plan tests => scalar(@$data) + 26;
-
     # Setup topology
     ok_sql ( $master, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $master, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
@@ -70,8 +71,8 @@ sub fire
     ok_sql ( $master_extra, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $slave, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
     ok_sql ( $slave, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[0]} . "'");
-    attach ( $master, $slave );
-    attach ( $master, $master_extra );
+    ok_attach ( $master, $slave );
+    ok_attach ( $master, $master_extra );
 
     # Initial workload
     my $dbname  = "test";
@@ -89,17 +90,17 @@ sub fire
     my $next_i;
     for ($next_i = 0; $next_i < ((scalar(@$data))/2);$next_i++)
     {
-      ok_sql ( $master, $data->[$next_i] );
+      sql ( $master, $data->[$next_i] );
     }
 
     # Compare DBs
     ok_synchronize ( $master, $slave );
     ok_synchronize ( $master, $master_extra );
-    ok_compare_dbs([
-      {"conn" => $master, "dbname" => $dbname}, 
-      {"conn" => $master_extra, "dbname" => $dbname}, 
-      {"conn" => $slave, "dbname" => $dbname}
-    ]);
+    ok_diff_databases(
+      $master, $dbname,
+      $master_extra, $dbname, 
+      $slave, $dbname
+    );
 
     # Start switchover {A->B, A->C} -> {B->C}
     ok_stop_replication ($slave);
@@ -126,21 +127,24 @@ sub fire
     # Run 2nd piece of statements on extra master (B) from stored position
     for (my $i = $next_i; $i < scalar(@$data);$i++)
     {
-      ok_sql ( $master_extra, $data->[$i] );
+      sql ( $master_extra, $data->[$i] );
     }    
 
     # Start B->C, stop A
-    attach ( $master_extra, $slave, $master_extra_file, $master_extra_pos );
+    ok_attach ( $master_extra, $slave, 
+	master_log_file 	=> $master_extra_file, 
+	master_log_pos 		=> $master_extra_pos
+    );
     ok_sql ( $master_extra, "SET GLOBAL BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     ok_sql ( $master_extra, "SET SESSION BINLOG_FORMAT= '" . $decode_combination{$binlog_formats[1]} . "'");
     stop_server ($master);
 
     # Check that B and C have same data
     ok_synchronize ( $master_extra, $slave );
-    ok_compare_dbs([
-      {"conn" => $master_extra, "dbname" => $dbname}, 
-      {"conn" => $slave, "dbname" => $dbname}
-    ]);
+    ok_diff_databases(
+      $master_extra, $dbname, 
+      $slave, $dbname
+    );
 }
 
 sub shutdown

=== modified file 'suites/rep/seconds_behind_master.pm'
--- a/suites/rep/seconds_behind_master.pm	2010-12-21 21:34:08 +0000
+++ b/suites/rep/seconds_behind_master.pm	2011-01-30 21:09:31 +0000
@@ -16,7 +16,7 @@ use Test::More;
 
 my %combinations = (
     "row"	=> "ROW",
-    "mixed"	=> "MIXED",
+    "mix"	=> "MIXED",
     "stmt"	=> "STATEMENT"
 );
 

=== modified file 'suites/rep/semisync.pm'
--- a/suites/rep/semisync.pm	2010-08-17 20:30:52 +0000
+++ b/suites/rep/semisync.pm	2011-01-30 21:09:31 +0000
@@ -15,7 +15,7 @@ use Test::More;
 
 my %combinations = (
     "row" 	=> "ROW",
-    "mixed" 	=> "MIXED",
+    "mix" 	=> "MIXED",
     "stmt" 	=> "STATEMENT"
 );
 

=== modified file 'suites/rep/stress_mixed/DML.txt'
--- a/suites/rep/stress_mixed/DML.txt	2009-11-25 19:05:08 +0000
+++ b/suites/rep/stress_mixed/DML.txt	2011-01-30 21:09:31 +0000
@@ -4,7 +4,6 @@ INSERT INTO test.t1 (b,c,d,z_comment) VA
 INSERT INTO test.t1 (b,c,d,z_comment) VALUES (NULL, FOUND_ROWS(), NULL, 'FOUND_ROWS()')
 INSERT INTO test.t1 (b,c,d,z_comment) VALUES (NULL, TRUNCATE(1000*RAND(),0), NULL, 'RAND()')
 INSERT INTO test.t1 (b,c,d,z_comment) VALUES (NULL, NULL, SYSDATE(), 'SYSDATE()')
-INSERT DELAYED INTO test.t1 (b,c,d,z_comment) VALUES (NULL, NULL, NULL, 'INSERT DELAYED')
 INSERT INTO test.t2 SELECT * FROM test.t1 WHERE a > (5*RAND())
 UPDATE test.t1 SET b = CURRENT_USER() WHERE a = 1;
 UPDATE test.t1 SET b = UUID() WHERE a = 2;

=== modified file 'suites/rep/stress_mixed/stress_mixed.pm'
--- a/suites/rep/stress_mixed/stress_mixed.pm	2010-08-17 20:30:52 +0000
+++ b/suites/rep/stress_mixed/stress_mixed.pm	2011-01-30 21:09:31 +0000
@@ -40,30 +40,30 @@ sub fire
     my $client_num = get_combination($test);
     $client_num =~ s/(\d+)(.+)/$1/g;
     
-    # Get servers
-    my $master = ok_server ($test);
-    my $slave = ok_server ($test);
-
     # Read list of statements from data source
     my $data = get_data_from_source();
     
     # Store queries to file for clients
-    my $qfile = $Parameters::work_dir . "/tmp/stress_mixed_dump";
+    my $qfile = File::Spec->catfile(get_test_tmp_dir, "stress_mixed.dump");
     my $dump_file = new IO::File($qfile, "w+");
     print $dump_file join("\n", @$data);
     $dump_file = undef;
 
     # Read DDL file
-    my $ddl_file = new IO::File($Parameters::suites_dir . "/rep/stress_mixed/DDL.txt", "r");
+    my $ddl_file = new IO::File(File::Spec->catfile(get_suites_dir(), "rep", "stress_mixed", "DDL.txt"), "r");
     my @ddl_lines = $ddl_file->getlines();
     
     # Read DML file
-    my $dml_file_path = $Parameters::suites_dir . "/rep/stress_mixed/DML.txt";
+    my $dml_file_path = File::Spec->catfile(get_suites_dir(), "rep", "stress_mixed", "DML.txt");
     my $dml_file = new IO::File($dml_file_path, "r");
     my @dml_lines = $dml_file->getlines();
     
     # Summarize number of statements and ok_* command in test
-    plan tests => 9 + scalar(@ddl_lines) + scalar(@dml_lines);
+    plan tests => 11 + scalar(@ddl_lines) + scalar(@dml_lines);
+
+    # Run servers
+    my $master = ok_server ($test);
+    my $slave = ok_server ($test);
 
     # Setup topology, binlog format, prepare test db
     ok_sql ( $master, "SET GLOBAL BINLOG_FORMAT= 'MIXED'");

=== modified file 'suites/rep_func/crash_safe_master.pm'
--- a/suites/rep_func/crash_safe_master.pm	2011-01-26 20:13:29 +0000
+++ b/suites/rep_func/crash_safe_master.pm	2011-01-30 21:09:31 +0000
@@ -31,7 +31,7 @@ my @engines = ("myisam", "innodb");
 sub combinations
 {
     my @combinations = ();
-    foreach my $binlog_format ( ("row", "mixed", "stmt") )
+    foreach my $binlog_format ( ("row", "mix", "stmt") )
     {
 	foreach my $engine ( @engines )
 	{
@@ -64,12 +64,13 @@ sub fire
     # Parameters
     my $dbname = "test";
     my $timeout= 30;
-    
+
     # Decode combination
     my ($binlog_format, $engine, $crash_point) = split(/\-/, get_combination($test));
     $binlog_format = uc $binlog_format;
     $engine = uc $engine;
     $binlog_format = "STATEMENT" if ($binlog_format eq "STMT");
+    $binlog_format = "MIXED" if ($binlog_format eq "MIX");
     $crash_point =~ s/[a-z\_]+//ig;
     $crash_point = $crash_points[$crash_point];
     
@@ -77,7 +78,7 @@ sub fire
     my $data = get_data_from_source();
     
     # Set number of subtests
-    my $subtests = 16;
+    my $subtests = 17;
     
     # Skip test if servers compiled withot debug support
     SKIP: 
@@ -102,9 +103,10 @@ sub fire
 	# Setup topology, binlog format, default engine, prepare test db
 	ok_sql ( $master, "SET GLOBAL BINLOG_FORMAT='$binlog_format'");
 	ok_sql ( $master, "SET SESSION BINLOG_FORMAT='$binlog_format'");
-	ok_sql ( $master, "SET STORAGE_ENGINE='$engine'");
+	ok_sql ( $master, "SET GLOBAL DEFAULT_STORAGE_ENGINE='$engine'");
+	ok_sql ( $master, "SET SESSION DEFAULT_STORAGE_ENGINE='$engine'");
 	ok_sql ( $slave, "SET GLOBAL BINLOG_FORMAT='$binlog_format'");
-	ok_sql ( $slave, "SET STORAGE_ENGINE='$engine'");
+	ok_sql ( $slave, "SET GLOBAL DEFAULT_STORAGE_ENGINE='$engine'");
 	ok_attach ( $master, $slave );
 	ok_synchronize ( $master, $slave );
 	ok_sql ( $master, "CREATE DATABASE IF NOT EXISTS $dbname");
@@ -117,7 +119,7 @@ sub fire
 	my $crash_pos = int(rand($query_count/2) + $query_count/4);
 	
 	# Fix position for special cases
-	if ($crash_point =~ m/(crash_commit_after|half_binlogged_transaction)/)
+	if ($crash_point =~ m/(crash_commit_after|half_binlogged_transaction)/ && $engine =~ m/innodb/i)
 	{
 	    my ($b_pos, $c_pos) = find_rand_trans($data);
 	    if (defined($c_pos))
@@ -130,27 +132,12 @@ sub fire
 		{
 		    $crash_pos = $b_pos + int(($c_pos - $b_pos)/2);
 		}
-		# Print via diag() where we will do a crash
-		for (my $pos = $b_pos; $pos <= $c_pos; $pos++)
-		{
-		    if ($pos == $crash_pos)
-		    {
-			diag("SET SESSION DEBUG='d,$crash_point'");
-		    }
-		    diag($data->[$pos]);
-		}
 	    }
 	    else
 	    {
 		skip "Statement list has no transactions", 7;
 	    }
 	}
-	else 
-	{
-	    diag($data->[$crash_pos-1]) if ($crash_pos > 0);
-	    diag("SET SESSION DEBUG='d,$crash_point'");
-	    diag($data->[$crash_pos+1]) if ($crash_pos < (scalar(@$data)-1));  
-	}
 	
 	# Run queries against master
 	# We do not stop executing even server crashed
@@ -161,6 +148,8 @@ sub fire
 	    {
     		ok_sql ( $master, "SET SESSION DEBUG='d,$crash_point'");
 	    }
+	    # Remove transaction for MyISAM engine
+	    next if ($query =~ m/^(begin|commit|rollback)/i && $engine =~ m/myisam/i);
 	    sql ( $master, $query );
 	    $query_num++;
 	}
@@ -191,6 +180,7 @@ sub fire
 
 	# Sync slave with master
 	ok_synchronize($master, $slave);
+
 	# Compare databases
 	ok_diff_databases($master, "test", $slave, "test");
     }


Attachment: [text/bzr-bundle] bzr/serge.kozlov@oracle.com-20110130210931-fcfsb5snu2fehjdm.bundle
Thread
bzr commit into nuts branch (Serge.Kozlov:389) Serge Kozlov30 Jan