Merge lp:~percona-toolkit-dev/percona-toolkit/fix-1086018-pt-config-diff-wsrep_provider_options into lp:percona-toolkit/2.2

Proposed by Brian Fraser
Status: Merged
Approved by: Daniel Nichter
Approved revision: 549
Merged at revision: 554
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fix-1086018-pt-config-diff-wsrep_provider_options
Merge into: lp:percona-toolkit/2.2
Diff against target: 211 lines (+158/-2)
4 files modified
bin/pt-config-diff (+25/-1)
lib/MySQLConfig.pm (+26/-1)
t/pt-config-diff/pxc.t (+65/-0)
t/pt-config-diff/samples/pxc.cnf (+42/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fix-1086018-pt-config-diff-wsrep_provider_options
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Brian Fraser (community) Approve
Review via email: mp+151766@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brian Fraser (fraserbn) :
review: Approve
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

103 -version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
104 +version="5.5"

That doesn't look correct?

No test case?

review: Needs Fixing
548. By Brian Fraser

Revert a debugging change to start-sandbox that should've never been commited

549. By Brian Fraser

Add missing test files

Revision history for this message
Daniel Nichter (daniel-nichter) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/pt-config-diff'
2--- bin/pt-config-diff 2013-03-04 17:28:43 +0000
3+++ bin/pt-config-diff 2013-03-06 21:15:27 +0000
4@@ -2784,9 +2784,33 @@
5 die "Unknown config source";
6 }
7
8+ handle_special_vars(\%config_data);
9+
10 return %config_data;
11 }
12
13+sub handle_special_vars {
14+ my ($config_data) = @_;
15+
16+ if ( $config_data->{vars}->{wsrep_provider_options} ) {
17+ my $vars = $config_data->{vars};
18+ my $dupes = $config_data->{duplicate_vars};
19+ for my $wpo ( $vars->{wsrep_provider_options}, @{$dupes->{wsrep_provider_options} || [] } ) {
20+ my %opts = $wpo =~ /(\S+)\s*=\s*(\S*)(?:;|;?$)/g;
21+ while ( my ($var, $val) = each %opts ) {
22+ $val =~ s/;$//;
23+ if ( exists $vars->{$var} ) {
24+ push @{$dupes->{$var} ||= []}, $val;
25+ }
26+ $vars->{$var} = $val;
27+ }
28+ }
29+ delete $vars->{wsrep_provider_options};
30+ }
31+
32+ return;
33+}
34+
35 sub _parse_config_output {
36 my ( %args ) = @_;
37 my @required_args = qw(output TextResultSetParser);
38@@ -2829,7 +2853,7 @@
39 vars => $vars,
40 );
41 }
42-
43+
44 return (
45 format => $format,
46 vars => $vars,
47
48=== modified file 'lib/MySQLConfig.pm'
49--- lib/MySQLConfig.pm 2013-01-03 00:19:16 +0000
50+++ lib/MySQLConfig.pm 2013-03-06 21:15:27 +0000
51@@ -121,9 +121,34 @@
52 die "Unknown config source";
53 }
54
55+ handle_special_vars(\%config_data);
56+
57 return %config_data;
58 }
59
60+sub handle_special_vars {
61+ my ($config_data) = @_;
62+
63+ if ( $config_data->{vars}->{wsrep_provider_options} ) {
64+ my $vars = $config_data->{vars};
65+ my $dupes = $config_data->{duplicate_vars};
66+ for my $wpo ( $vars->{wsrep_provider_options}, @{$dupes->{wsrep_provider_options} || [] } ) {
67+ my %opts = $wpo =~ /(\S+)\s*=\s*(\S*)(?:;|;?$)/g;
68+ while ( my ($var, $val) = each %opts ) {
69+ $val =~ s/;$//;
70+ if ( exists $vars->{$var} ) {
71+ push @{$dupes->{$var} ||= []}, $val;
72+ }
73+ $vars->{$var} = $val;
74+ }
75+ }
76+ # Delete from vars, but not from dupes, since we still want that
77+ delete $vars->{wsrep_provider_options};
78+ }
79+
80+ return;
81+}
82+
83 sub _parse_config_output {
84 my ( %args ) = @_;
85 my @required_args = qw(output TextResultSetParser);
86@@ -166,7 +191,7 @@
87 vars => $vars,
88 );
89 }
90-
91+
92 return (
93 format => $format,
94 vars => $vars,
95
96=== added file 't/pt-config-diff/pxc.t'
97--- t/pt-config-diff/pxc.t 1970-01-01 00:00:00 +0000
98+++ t/pt-config-diff/pxc.t 2013-03-06 21:15:27 +0000
99@@ -0,0 +1,65 @@
100+#!/usr/bin/env perl
101+
102+BEGIN {
103+ die "The PERCONA_TOOLKIT_BRANCH environment variable is not set.\n"
104+ unless $ENV{PERCONA_TOOLKIT_BRANCH} && -d $ENV{PERCONA_TOOLKIT_BRANCH};
105+ unshift @INC, "$ENV{PERCONA_TOOLKIT_BRANCH}/lib";
106+};
107+
108+use strict;
109+use warnings FATAL => 'all';
110+use English qw(-no_match_vars);
111+use Test::More;
112+use Data::Dumper;
113+
114+# Hostnames make testing less accurate. Tests need to see
115+# that such-and-such happened on specific slave hosts, but
116+# the sandbox servers are all on one host so all slaves have
117+# the same hostname.
118+$ENV{PERCONA_TOOLKIT_TEST_USE_DSN_NAMES} = 1;
119+
120+use PerconaTest;
121+use Sandbox;
122+require "$trunk/bin/pt-config-diff";
123+
124+my $dp = new DSNParser(opts=>$dsn_opts);
125+my $sb = new Sandbox(basedir => '/tmp', DSNParser => $dp);
126+my $node1 = $sb->get_dbh_for('node1');
127+my $node2 = $sb->get_dbh_for('node2');
128+my $node3 = $sb->get_dbh_for('node3');
129+
130+if ( !$node1 ) {
131+ plan skip_all => 'Cannot connect to cluster node1';
132+}
133+elsif ( !$node2 ) {
134+ plan skip_all => 'Cannot connect to cluster node2';
135+}
136+elsif ( !$node3 ) {
137+ plan skip_all => 'Cannot connect to cluster node3';
138+}
139+elsif ( !$sb->is_cluster_mode ) {
140+ plan skip_all => "PXC tests";
141+}
142+
143+my $node1_dsn = $sb->dsn_for('node1');
144+my $node2_dsn = $sb->dsn_for('node2');
145+
146+my $output = output(sub { pt_config_diff::main($node1_dsn, $node2_dsn) });
147+
148+like(
149+ $output,
150+ qr/gcache.dir .+\ngcache.name/,
151+ "pt-config-diff parses & detects differences in each member of wsrep_provider_options"
152+);
153+
154+$output = output(sub { pt_config_diff::main($node1_dsn, "$trunk/t/pt-config-diff/samples/pxc.cnf") });
155+
156+like(
157+ $output,
158+ qr/pc.ignore_sb\s*false\s*true/,
159+ "wsrep_provider_options, node vs config file"
160+);
161+
162+
163+
164+done_testing;
165
166=== added file 't/pt-config-diff/samples/pxc.cnf'
167--- t/pt-config-diff/samples/pxc.cnf 1970-01-01 00:00:00 +0000
168+++ t/pt-config-diff/samples/pxc.cnf 2013-03-06 21:15:27 +0000
169@@ -0,0 +1,42 @@
170+[client]
171+user = msandbox
172+password = msandbox
173+port = 12345
174+socket = /tmp/12345/mysql_sandbox12345.sock
175+
176+[mysqld]
177+port = 12345
178+socket = /tmp/12345/mysql_sandbox12345.sock
179+pid-file = /tmp/12345/data/mysql_sandbox12345.pid
180+basedir = /home/hugmeir/mysql/Percona-XtraDB-Cluster-5.5.28-23.7.373.Linux.x86_64/
181+datadir = /tmp/12345/data
182+key_buffer_size = 16M
183+innodb_buffer_pool_size = 16M
184+innodb_data_home_dir = /tmp/12345/data
185+innodb_log_group_home_dir = /tmp/12345/data
186+innodb_data_file_path = ibdata1:10M:autoextend
187+innodb_log_file_size = 5M
188+log-bin = mysql-bin
189+relay_log = mysql-relay-bin
190+log_slave_updates
191+server-id = 12345
192+report-host = 127.0.0.1
193+report-port = 12345
194+log-error = /tmp/12345/data/mysqld.log
195+innodb_lock_wait_timeout = 3
196+general_log
197+general_log_file = genlog
198+
199+binlog_format = ROW
200+wsrep_provider = /home/hugmeir/mysql/Percona-XtraDB-Cluster-5.5.28-23.7.373.Linux.x86_64//lib/libgalera_smm.so
201+wsrep_cluster_address = gcomm://192.168.1.34:12356
202+wsrep_sst_receive_address = 192.168.1.34:12365
203+wsrep_node_incoming_address= 192.168.1.34
204+wsrep_slave_threads = 2
205+wsrep_cluster_name = pt_sandbox_cluster
206+wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.1.34:12355; pc.ignore_sb = true;"
207+wsrep_sst_method = rsync
208+wsrep_node_name = 12345
209+innodb_locks_unsafe_for_binlog = 1
210+innodb_autoinc_lock_mode = 2
211+wsrep-replicate-myisam

Subscribers

People subscribed via source and target branches