File: replication_gtid.sb.pl

package info (click to toggle)
mysql-sandbox 3.2.05-1.1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 916 kB
  • sloc: perl: 9,878; sh: 191; makefile: 8
file content (123 lines) | stat: -rw-r--r-- 3,467 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#
# Test GTID enabling
# Requires MySQL 5.6 - 5.7+
#
my $TEST_VERSION = $ENV{TEST_VERSION};
my ($version, $name_version) = get_bare_version($TEST_VERSION);
my $replication_dir = "rsandbox_$name_version";

my $GTID_OPTION= ' --gtid';
if ( $ENV{'GTID_FROM_FILE'})
{
    $GTID_OPTION='';
}

ok_exec({
    command     => "make_replication_sandbox $GTID_OPTION $TEST_VERSION",
    expected    => 'replication directory installed',
    msg         => 'replication directory installed',
});

if ( $ENV{'GTID_FROM_FILE'})
{
    ok( (-f "$sandbox_home/$replication_dir/enable_gtid" ), "file enable_gtid found ");

    my $result = qx( $sandbox_home/$replication_dir/enable_gtid );

    ok( $? == 0 , 'enable_gtid ran without errors');

    ok( $result && ($result =~ /# option 'gtid_mode=ON' added to \w+ configuration file/), "enable_gtid added options successfully");
}

ok_sql({
    path    => "$sandbox_home/$replication_dir/master",
    query   => 'select @@global.gtid_mode',
    expected => 'ON',
    msg      => 'Master GTID is enabled',    
});

# When GTID is enabled, the slaves take some time to get the synchronization info.
sleep 3;

ok_sql({
    path    => "$sandbox_home/$replication_dir/master",
    query   => 'select @@global.server_uuid',
    expected => '1111-111111111111',
    msg      => 'Master UUID was modified',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/node1",
    query   => 'select @@global.server_uuid',
    expected => '2222-222222222222',
    msg      => 'slave 1 UUID was modified',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/node2",
    query   => 'select @@global.server_uuid',
    expected => '3333-333333333333',
    msg      => 'slave 2 UUID was modified',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/node1",
    query   => 'select @@global.gtid_mode',
    expected => 'ON',
    msg      => 'Slave1 GTID is enabled',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/master",
    query   => "create table test.t1 (id int not null primary key); show tables from test",
    expected => 't1',
    msg      => 'Master created a table',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/master",
    query   => "insert into test.t1 values(12345); select * from test.t1",
    expected => '12345',
    msg      => 'Master inserted a row',    
});

sleep 2;

ok_sql({
    path    => "$sandbox_home/$replication_dir/node1",
    query   => "show tables from test",
    expected => 't1',
    msg      => 'slave replicated the table',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/node1",
    query   => "select * from test.t1",
    expected => '12345',
    msg      => 'Slave retrieved a row',    
});

ok_sql({
    path    => "$sandbox_home/$replication_dir/master",
    query   => 'select @@global.gtid_executed',
    expected => '1111-111111111111:1-',
    msg      => 'Master has produced a GTID',    
});

#my $executed_set = `$sandbox_home/$replication_dir/m -BN -e 'select \@\@global.gtid_executed'`;
#chomp $executed_set;
my $executed_set = $ENV{SQL_RESULT};

ok_sql({
    path    => "$sandbox_home/$replication_dir/node1",
    query   => 'select @@global.gtid_executed',
    expected => $executed_set,
    msg      => 'Slave has retrieved a GTID',    
});

ok_exec( {
    command => "sbtool -o delete -s $sandbox_home/$replication_dir ", 
    expected => 'has been removed',
    msg      => "$replication_dir removed"
});