List:Commits« Previous MessageNext Message »
From:Serge Kozlov Date:December 21 2010 9:11pm
Subject:bzr commit into nuts branch (Serge.Kozlov:385) WL#5569
View as plain text  
#At file:///home/ksm/oracle/repo/QA/nuts-1222/ based on revid:serge.kozlov@stripped

  385 Serge Kozlov	2010-12-22
      1) WL#5569 test case for NUTS
      2) Fix input for get_variable/get_status and related test cases

    added:
      suites/rep_exp/
      suites/rep_exp/mts.pm
    modified:
      lib/My/Nuts/Library/Kernel/ServerResult.pm
      suites/rep/data_types/data_type_conv.pl
      suites/rep/data_types/data_type_test.pl
      suites/rep/seconds_behind_master.pm
=== modified file 'lib/My/Nuts/Library/Kernel/ServerResult.pm'
--- a/lib/My/Nuts/Library/Kernel/ServerResult.pm	2010-03-30 19:58:02 +0000
+++ b/lib/My/Nuts/Library/Kernel/ServerResult.pm	2010-12-21 21:11:46 +0000
@@ -161,9 +161,7 @@ sub get_table_list
 
 sub get_variable
 {
-    my $params = shift;
-    my $conn = $params->{"conn"};
-    my $var = $params->{"var"};
+    my ($conn, $var)= @_;
     my $result = undef;
     my $rs = sql ($conn, "SHOW VARIABLES LIKE '" . $var . "';");
     my @rs_data = get_next($rs);
@@ -176,9 +174,7 @@ sub get_variable
 
 sub get_status
 {
-    my $params = shift;
-    my $conn = $params->{"conn"};
-    my $var = $params->{"var"};
+    my ($conn, $var)= @_;
     my $result = undef;
     my $rs = sql ($conn, "SHOW STATUS LIKE '" . $var . "';");
     my @rs_data = get_next($rs);

=== modified file 'suites/rep/data_types/data_type_conv.pl'
--- a/suites/rep/data_types/data_type_conv.pl	2010-03-08 22:33:46 +0000
+++ b/suites/rep/data_types/data_type_conv.pl	2010-12-21 21:11:46 +0000
@@ -23,7 +23,7 @@ sub main_test
 	"master:create_db_test");    
     
     # Check the support of type conversion on slave
-    my $type_conv = get_variable( {"conn" => $slave, "var" => "SLAVE_TYPE_CONVERSIONS"} );
+    my $type_conv = get_variable( $slave, "SLAVE_TYPE_CONVERSIONS" );
     if (! defined ($type_conv) )
     {
 	plan tests => 1;

=== modified file 'suites/rep/data_types/data_type_test.pl'
--- a/suites/rep/data_types/data_type_test.pl	2010-03-17 10:40:10 +0000
+++ b/suites/rep/data_types/data_type_test.pl	2010-12-21 21:11:46 +0000
@@ -66,7 +66,7 @@ sub main_test
     # Detect type converions on slave
     my $conv_dir = "";
     my @slave_type_conversion = ("DEFAULT");
-    my $type_conv = get_variable( {"conn" => $slaves->[0], "var" => "SLAVE_TYPE_CONVERSIONS"} );
+    my $type_conv = get_variable( $slaves->[0], "SLAVE_TYPE_CONVERSIONS" );
     if ( defined ($type_conv) && ($binlog_format =~ m/row/i ))
     {
 	@slave_type_conversion = ("", "ALL_LOSSY", "ALL_NON_LOSSY", "ALL_LOSSY,ALL_NON_LOSSY");
@@ -95,7 +95,7 @@ sub main_test
 		push (@test_engines, {"master_engine" => $master_engine, "slave_engine" => $slave_engine});
 	    }
 	}
-	
+	 
 	push(@slave_data_types, keys(%$types));
     }
     elsif ($mode eq "eq")

=== modified file 'suites/rep/seconds_behind_master.pm'
--- a/suites/rep/seconds_behind_master.pm	2010-03-30 19:58:02 +0000
+++ b/suites/rep/seconds_behind_master.pm	2010-12-21 21:11:46 +0000
@@ -106,7 +106,7 @@ sub fire
     dbug_set($master, "dec_event_time_by_1_hour", My::TRUE);
     ok (insert_rows($master, 10000) == 0, "Test 4. Insert rows");
     ok_wait_sql($slave, "SELECT COUNT(*) > 0 FROM t1;", 90);    
-    my $hb = get_status({"conn" => $slave, "var" => "slave_received_heartbeats"});
+    my $hb = get_status( $slave, "slave_received_heartbeats" );
     $sbm = retrieve_slave_status($slave, "Seconds_Behind_Master");
     ok( $sbm >= 3600, "Test 4a. Seconds_Behind_Master before heartbeat event must be >= 3600. Current value is $sbm");
     ok_synchronize($master, $slave);

=== added directory 'suites/rep_exp'
=== added file 'suites/rep_exp/mts.pm'
--- a/suites/rep_exp/mts.pm	1970-01-01 00:00:00 +0000
+++ b/suites/rep_exp/mts.pm	2010-12-21 21:11:46 +0000
@@ -0,0 +1,177 @@
+package rep_exp::mts;
+use Exporter;
+our @ISA = qw(Exporter My::Nuts::Library::Tests::SimpleTest);
+use strict;
+use warnings;
+use DBI;
+use IO::File;
+use My;
+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 Test::More;
+
+# Number of independent databases
+my @db_numbers = (5, 10, 50);
+# Number of workers on slave
+my @workers = (1, 2, 4, 8, 16);
+
+sub combinations
+{
+    my @combinations = ();
+    foreach my $dbnum ( @db_numbers )
+    {
+	foreach my $i ( @workers )
+	{
+	    push(@combinations, "row-db$dbnum-workers$i");
+	}
+    }
+    return @combinations;
+}
+
+sub prepare
+{
+    return;
+}
+
+sub startup
+{
+    return;
+}
+
+sub fire
+{
+    my ($test) = @_;
+    my $dbnum;
+    my $workers;
+    my $binlog_format;
+    # Decode combination
+    if ( get_combination($test) =~ m/(row|stmt|mix)\-db(\d+)\-workers(\d+)/)
+    {
+	$binlog_format=$1;
+	$dbnum= $2;
+	$workers= $3;
+    }
+
+    # Subtests number
+    my $subtests= 8;
+    $subtests-- if ( $workers == 1);
+
+    # Skip test if servers do not support binlog format and MTS
+    SKIP: 
+    {
+	# Start master and check binlog format
+	my $master = server ($test);
+	if ( ! defined ( get_variable( $master, "binlog_format" ) ) )
+	{
+	    skip "Require binlog format support for master ", $subtests;
+	}
+	# Start slave and check MTS support
+	my $slave = server ($test);
+        if ( ! defined ( get_variable( $slave, "mts_slave_parallel_workers" ) ) )
+	{
+	    skip "Require MTS support for slave ", $subtests;
+	}
+	# Set number of subtests
+	plan tests => $subtests;
+	
+	# Read list of statements from data source
+	my $data = get_data_from_source();
+    
+	# Setup topology, binlog format, prepare test db
+	ok_sql ( $slave, "SET GLOBAL BINLOG_FORMAT='ROW'");
+	if ( $workers > 1)
+	{
+	    ok_sql ( $slave, "SET GLOBAL mts_slave_parallel_workers=".$workers);
+	}
+	ok_attach ( $master, $slave );
+	ok_synchronize ( $master, $slave );
+	
+	# Stop SQL thread because we need to fill relay log
+	ok_sql ( $slave, "STOP SLAVE SQL_THREAD");
+
+	# Main test
+	my $dsn = get_dsn($master);
+	my @dbh = ();
+	# Do pool of connections to server and create databases
+	foreach ( my $idx = 1; $idx <= $dbnum; $idx++  )
+	{
+	
+	    $dbh[$idx]= DBI->connect( $dsn, "root", "", {PrintError => 0} );
+	    my $dbname= "test_".$idx;
+	    $dbh[$idx]->do( "CREATE DATABASE ".$dbname );
+	    $dbh[$idx]->do( "USE ".$dbname );
+	    $dbh[$idx]->do( "SET SESSION BINLOG_FORMAT='$binlog_format'" );
+	}
+	# Run queries for all pool
+	foreach my $query (@$data)
+	{
+	    foreach ( my $idx = 1; $idx <= $dbnum; $idx++  )
+	    {
+		$dbh[$idx]->do( $query );
+	    }
+	}
+	# Close connections
+	foreach ( my $idx = 1; $idx <= $dbnum; $idx++  )
+	{
+	    $dbh[$idx]->disconnect;
+	}
+	# Sync master and slave and measure the time in seconds for SQL thread
+	my $started = time();
+	ok_start_replication( $slave);
+	ok_wait_start_replication( $slave);
+	ok_synchronize ( $master, $slave );    
+	note("Slave SQL Thread spent " . (time() - $started) . " seconds");
+    }
+}
+
+sub shutdown
+{
+    return;
+}
+
+1;
+__END__;
+
+=head1 NAME
+
+rep::mts - Multi-thread slave
+
+=head1 SYNOPSIS
+
+The mission of the test case is to create a relay log with mixed events from different databases and start slave SQL thread in multi-thread mode. 
+For this purpose the test generates events on master via several DBI connections. The list of random statements requested from DataSource.
+
+The the following parameters are used for combinations: 
+
+=over
+
+=item Binlog format (currently fixed to ROW)
+
+=item Number of independent databases (5, 10, 50)
+
+=item Number of MTS workers (1, 2, 4, 8)
+
+=back
+
+=head1 REFERENCES
+
+=over
+
+=item * WL#5569
+
+=back
+
+=head1 AUTHOR
+
+Serge Kozlov S<< <Serge.Kozlov@stripped> >>
+
+=head1 COPYRIGHT
+
+Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+
+=cut
\ No newline at end of file


Attachment: [text/bzr-bundle] bzr/serge.kozlov@oracle.com-20101221211146-tqs4dldwsifah9bv.bundle
Thread
bzr commit into nuts branch (Serge.Kozlov:385) WL#5569Serge Kozlov21 Dec