~giuseppe-maxia/mysql-sandbox/mysql-sandbox-3

« back to all changes in this revision

Viewing changes to t/replication_gtid.sb.pl

  • Committer: g.maxia at gmail
  • Date: 2015-08-02 15:15:16 UTC
  • Revision ID: g.maxia@gmail.com-20150802151516-3blys2q56v788sc1
- Added default name for relay log files.
- Added 'show_binlog' script in each sandbox
- improved tests by getting all the version components from a single function call
- Added GTID initialization options for MySQL 5.6, 5.7, and MariaDB 10
- Added GTID enabling test for MySQL 5.6 and 5.7
- added and improved more tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Test GTID enabling
 
3
# Requires MySQL 5.6 - 5.7+
 
4
#
 
5
my $TEST_VERSION = $ENV{TEST_VERSION};
 
6
my ($version, $name_version) = get_bare_version($TEST_VERSION);
 
7
my $replication_dir = "rsandbox_$name_version";
 
8
 
 
9
ok_exec({
 
10
    command     => "make_replication_sandbox $TEST_VERSION ",
 
11
    expected    => 'replication directory installed',
 
12
    msg         => 'replication directory installed',
 
13
});
 
14
 
 
15
ok( (-f "$sandbox_home/$replication_dir/enable_gtid" ), "file enable_gtid found ");
 
16
 
 
17
my $result = qx( $sandbox_home/$replication_dir/enable_gtid );
 
18
 
 
19
ok( $? == 0 , 'enable_gtid ran without errors');
 
20
 
 
21
ok( $result && ($result =~ /# option 'gtid_mode=ON' added to \w+ configuration file/), "enable_gtid added options successfully");
 
22
 
 
23
ok_sql({
 
24
    path    => "$sandbox_home/$replication_dir/master",
 
25
    query   => 'select @@global.gtid_mode',
 
26
    expected => 'ON',
 
27
    msg      => 'Master GTID is enabled',    
 
28
});
 
29
 
 
30
ok_sql({
 
31
    path    => "$sandbox_home/$replication_dir/node1",
 
32
    query   => 'select @@global.gtid_mode',
 
33
    expected => 'ON',
 
34
    msg      => 'Slave1 GTID is enabled',    
 
35
});
 
36
 
 
37
ok_sql({
 
38
    path    => "$sandbox_home/$replication_dir/master",
 
39
    query   => "create table test.t1 (id int not null primary key); show tables from test",
 
40
    expected => 't1',
 
41
    msg      => 'Master created a table',    
 
42
});
 
43
 
 
44
ok_sql({
 
45
    path    => "$sandbox_home/$replication_dir/master",
 
46
    query   => "insert into test.t1 values(12345); select * from test.t1",
 
47
    expected => '12345',
 
48
    msg      => 'Master inserted a row',    
 
49
});
 
50
 
 
51
sleep 2;
 
52
 
 
53
ok_sql({
 
54
    path    => "$sandbox_home/$replication_dir/node1",
 
55
    query   => "show tables from test",
 
56
    expected => 't1',
 
57
    msg      => 'slave replicated the table',    
 
58
});
 
59
 
 
60
ok_sql({
 
61
    path    => "$sandbox_home/$replication_dir/node1",
 
62
    query   => "select * from test.t1",
 
63
    expected => '12345',
 
64
    msg      => 'Slave retrieved a row',    
 
65
});
 
66
 
 
67
ok_sql({
 
68
    path    => "$sandbox_home/$replication_dir/master",
 
69
    query   => 'select @@global.gtid_executed',
 
70
    expected => '-2',
 
71
    msg      => 'Master has produced a GTID',    
 
72
});
 
73
 
 
74
ok_sql({
 
75
    path    => "$sandbox_home/$replication_dir/node1",
 
76
    query   => 'select @@global.gtid_executed',
 
77
    expected => '-2',
 
78
    msg      => 'Slave has retrieved a GTID',    
 
79
});
 
80
 
 
81
ok_exec( {
 
82
    command => "sbtool -o delete -s $sandbox_home/$replication_dir ", 
 
83
    expected => 'has been removed',
 
84
    msg      => "$replication_dir removed"
 
85
});
 
86