MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Serge Kozlov Date:September 19 2009 4:44pm
Subject:Re: bzr commit into nuts branch (Serge.Kozlov:349) WL#5061
View as plain text  
Hi, Luis.

Now ok_compare_dbs, compare_dbs is part of 
My::Nuts::Library::Kernel::ServerResult

New patch (test case) is here: http://lists.mysql.com/commits/83799

Luís Soares пишет:
> Hi Serge,
> 
>   Nice work. Please, find the review below. Alfranio has said most of it
> on his review, I have little to add.
> 
> STATUS
> ------
> 
>   Not Approved (a minor change is requested and I share Alfranio's 
>                 concerns).
> 
> REQUIRED CHANGES
> ----------------
> 
>   RC1. Please, add compare_dbs and supported_engines to NUTS
>        standard library. These are good candidates to be reused
>        in other tests, and can even be used to internally to
>        provide some more functionality (eg, in the future if one
>        implements have_innodb() as part of NUTS - I don't think
>        we have done it - we can build it on top of the
>        supported_engines function).
> 
> REQUESTS
> --------
>  n/a
> 
> SUGGESTIONS
> -----------
>  n/a
> 
> DETAILS 
> -------
>  n/a
> 
> On Mon, 2009-09-14 at 15:20 +0400, Serge Kozlov wrote:
>> #At file:///home/ksm/sun/repo/WL5061/nuts-commit/ based on
> revid:serge.kozlov@stripped
>>
>>   349 Serge Kozlov	2009-09-14
>>       WL#5061. Test case.
>>       added:
>>         suites/rep/chained_diff_engine.pm
>>
>> === added file 'suites/rep/chained_diff_engine.pm'
>> --- a/suites/rep/chained_diff_engine.pm	1970-01-01 00:00:00 +0000
>> +++ b/suites/rep/chained_diff_engine.pm	2009-09-14 11:20:17 +0000
>> @@ -0,0 +1,206 @@
>> +package rep::chained_diff_engine;
>> +use Exporter;
>> +our @ISA = qw(Exporter My::Nuts::Library::Tests::SimpleTest);
>> +use strict;
>> +use warnings;
>> +use My;
>> +use My::Nuts::Library::Kernel::Server;
>> +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 Test::More;
>> +use DataSource;
>> +
>> +sub prepare
>> +{
>> +    return;
>> +}
>> +
>> +sub startup
>> +{
>> +    return;
>> +}
>> +
>> +sub fire
>> +{
>> +    my ($test) = @_;
>> +    # Server A
>> +    my $master = ok_server ($test);
>> +    # Supported engines for A
>> +    my $engines_a = supported_engines($master);
>> +    # Server B (middle)
>> +    my $master_middle = ok_server ($test);
>> +    # Supported engines for B
>> +    my $engines_b = supported_engines($master_middle);
>> +    # Server C
>> +    my $slave = ok_server ($test);
>> +    my $dbname  = "test";
>> +    
>> +    # Read list of statements from data source
>> +    my $data = get_data_from_source();
>> +    # Add drop/create test database
>> +    unshift @$data, ("DROP DATABASE IF EXISTS " . $dbname, "CREATE DATABASE " .
> $dbname);
>> +    
>> +    # Calculate test plan
>> +    my $test_plan= 0;
>> +    foreach my $engine_a (@$engines_a)
>> +    {
>> +      foreach my $engine_b (@$engines_b)
>> +      {
>> +	if ($engine_a ne $engine_b)
>> +	{
>> +	  foreach my $query (@$data)
>> +	  {
>> +	    if ($query =~ m/CREATE\ +TABLE\ +([a-zA-Z0-9_]+)/i)
>> +	    {
>> +	      $test_plan = $test_plan + 8;
>> +	    }
>> +            $test_plan++;
>> +	  }
>> +          $test_plan++;
>> +	}	
>> +      }	
>> +    }
>> +    plan tests => $test_plan;
>> +
>> +    # Setup topology
>> +    attach ( $master, $master_middle );
>> +    attach ( $master_middle, $slave );
>> +
>> +    # Main loop of test
>> +    # Engin on server A
>> +    foreach my $engine_a (@$engines_a)
>> +    {
>> +      # Engine on server B
>> +      foreach my $engine_b (@$engines_b)
>> +      {
>> +	if ($engine_a ne $engine_b)
>> +	{
>> +	  foreach my $query (@$data)
>> +	  {
>> +	    # For CREATE statement we change engine on B and C
>> +	    if ($query =~ m/CREATE\ +TABLE\ +([a-zA-Z0-9_]+)/i)
>> +	    {
>> +	      my $table_name = $1;
>> +	      #print "$engine_a -> $engine_b: $table_name\n";
>> +	      ok_sql ( $master, "USE " . $dbname );
>> +              ok_sql ( $master, $query );
>> +	      ok_sql ( $master,  "ALTER TABLE $table_name ENGINE = $engine_a");
>> +	      ok_synchronize ( $master, $master_middle );
>> +	      ok_sql ( $master_middle, "USE " . $dbname );
>> +	      ok_sql ( $master_middle,  "ALTER TABLE $table_name ENGINE = $engine_b");
>> +	      ok_synchronize ( $master_middle, $slave );
>> +	      ok_sql ( $slave,   "USE " . $dbname );
>> +	      ok_sql ( $slave,  "ALTER TABLE $table_name ENGINE = $engine_a");	    	   
> 
>> +	    }
>> +	    else
>> +	    {
>> +              ok_sql ( $master, $query );
>> +            }
>> +	  }
>> +	  # Compare DBs
>> +	  ok ( (compare_dbs([
>> +    	    {"conn" => $master, "dbname" => $dbname}, 
>> +    	    {"conn" => $master_middle, "dbname" => $dbname}, 
>> +    	    {"conn" => $slave, "dbname" => $dbname}
>> +	  ]) == 1), "DBs are equal");
>> +	}	
>> +      }	
>> +    }
>> +}
>> +
>> +sub shutdown
>> +{
>> +    return;
>> +}
>> +
>> +# Compare databases
>> +sub compare_dbs
>> +{
>> +  my $params = shift;
>> +  my $ok = 1;
>> +  my $table_list = {};
>> +  my $text = "DBs are equal";
>> +  # 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} = 1;
>> +      @rs_data = get_next($rs);
>> +    }
>> +  }
>> +  # Compare table lists
>> +  foreach my $table_name (keys %$table_list)
>> +  {
>> +    if (keys(%{$table_list->{$table_name}}) < scalar(@$params))
>> +    {
>> +      $ok= 0;
>> +      last;
>> +      $text = "DBs have different output for SHOW TABLE statement";
>> +    }
>> +  }  
>> +  if ($ok == 1)
>> +  {    
>> +    foreach my $table_name (keys %$table_list)
>> +    {
>> +      my $conn1 = undef;
>> +      foreach my $option (@$params)
>> +      {
>> +        my $conn = $option->{"conn"};
>> +        if (defined $conn1)
>> +        {
>> +          my $rs = sql ($conn, "SELECT * FROM $table_name;" );
>> +          my $rs1 = sql ($conn1, "SELECT * FROM $table_name;" );
>> +          if ( (compare_results($rs, $rs1)) != 1)
>> +          {
>> +            $ok = 0;
>> +    	    $text = "Table $table_name has different output for different DBs";
>> +    	    last;
>> +          }
>> +        }
>> +        else
>> +        {
>> +          $conn1 = $conn;
>> +        }
>> +      }
>> +    }
>> +  }
>> +  #print $text;
>> +  return $ok;
>> +}
>> +
>> +sub supported_engines
>> +{
>> +  my $conn = shift;
>> +  my $engines = [];
>> +  my $rs = sql ( $conn, "SHOW ENGINES;" );
>> +  my @rs_data = get_next($rs);
>> +  while (defined $rs_data[0])
>> +  {
>> +    if ($rs_data[1] =~ m/(YES|DEFAULT)/ig && $rs_data[0] !~
> m/(CSV|MRG_MYISAM)/ig)
>> +    {
>> +	push(@$engines, $rs_data[0]);
>> +    }
>> +    @rs_data = get_next($rs);
>> +  }
>> +  return $engines;
>> +}
>> +
>> +1;
>> +__END__;
>> +
>> +=head1 NAME
>> +
>> +rep::chained_diff_engine - Replication for chain A->B->C, where B has
> different engine than A,C
>> +
>> +=head1 SYNOPSIS
>> +
>> +Replication for chain A->B->C, where tables on B have different engine
> than A and C
>> +
>> +=back
>>
>>


-- 
Serge Kozlov, QA Developer
MySQL AB, Moscow, Russia, www.mysql.com
Office:

Are you MySQL certified?  www.mysql.com/certification
Thread
bzr commit into nuts branch (Serge.Kozlov:349) WL#5061Serge Kozlov14 Sep
  • Re: bzr commit into nuts branch (Serge.Kozlov:349) WL#5061Luís Soares15 Sep
    • Re: bzr commit into nuts branch (Serge.Kozlov:349) WL#5061Serge Kozlov19 Sep