Merge lp:~percona-toolkit-dev/percona-toolkit/pt-mysql-summary-fails-to-parse-wsrep_provider_options-1264580 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 618
Merged at revision: 618
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-mysql-summary-fails-to-parse-wsrep_provider_options-1264580
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11
Diff against target: 138 lines (+32/-45)
5 files modified
bin/pt-mysql-summary (+13/-20)
lib/bash/report_mysql_info.sh (+15/-24)
sandbox/start-sandbox (+1/-1)
t/lib/bash/report_mysql_info.sh (+1/-0)
t/pt-mysql-summary/samples/my.cnf-001.txt (+2/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-mysql-summary-fails-to-parse-wsrep_provider_options-1264580
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+233822@code.launchpad.net

Description of the change

Changed awk for perl in the pretty_print_cnf_file() function. This allowed better regexp handling.

Added test case for this.

To post a comment you must log in.
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-mysql-summary'
2--- bin/pt-mysql-summary 2014-08-05 20:37:42 +0000
3+++ bin/pt-mysql-summary 2014-09-08 21:46:20 +0000
4@@ -1353,26 +1353,19 @@
5
6 [ -e "$file" ] || return
7
8- awk '
9- BEGIN {
10- FS="="
11- }
12- /^[ \t]*[a-zA-Z[]/ {
13- if (length($2)) {
14- gsub(/^[ \t]*/, "", $1);
15- gsub(/^[ \t]*/, "", $2);
16- gsub(/[ \t]*$/, "", $1);
17- gsub(/[ \t]*$/, "", $2);
18- printf("%-35s = %s\n", $1, $2);
19- }
20- else if ( $0 ~ /\[/ ) {
21- print "";
22- print $1;
23- }
24- else {
25- print $1;
26- }
27- }' "$file"
28+ perl -n -l -e '
29+ my $line = $_;
30+ if ( $line =~ /^[ \t]*[a-zA-Z[]/ ) {
31+ if ( $line=~/\s*(.*?)\s*=\s*(.*)\s*$/ ) {
32+ printf("%-35s = %s\n", $1, $2)
33+ }
34+ elsif ( $line =~ /\s*\[/ ) {
35+ print "\n$line"
36+ } else {
37+ print $line
38+ }
39+ }' "$file"
40+
41 }
42
43 find_checkpoint_age() {
44
45=== modified file 'lib/bash/report_mysql_info.sh'
46--- lib/bash/report_mysql_info.sh 2013-12-12 05:49:59 +0000
47+++ lib/bash/report_mysql_info.sh 2014-09-08 21:46:20 +0000
48@@ -345,37 +345,28 @@
49 echo
50 }
51
52-# Pretty-prints the my.cnf file. It's super annoying, but some *modern*
53-# versions of awk don't support POSIX character sets in regular
54-# expressions, like [[:space:]] (looking at you, Debian). So
55-# the below patterns contain [<space><tab>] and must remain that way.
56+# Pretty-prints the my.cnf file.
57 pretty_print_cnf_file () {
58 local file="$1"
59
60 [ -e "$file" ] || return
61
62- awk '
63- BEGIN {
64- FS="="
65- }
66- /^[ \t]*[a-zA-Z[]/ {
67- if (length($2)) {
68- gsub(/^[ \t]*/, "", $1);
69- gsub(/^[ \t]*/, "", $2);
70- gsub(/[ \t]*$/, "", $1);
71- gsub(/[ \t]*$/, "", $2);
72- printf("%-35s = %s\n", $1, $2);
73- }
74- else if ( $0 ~ /\[/ ) {
75- print "";
76- print $1;
77- }
78- else {
79- print $1;
80- }
81- }' "$file"
82+ perl -n -l -e '
83+ my $line = $_;
84+ if ( $line =~ /^\s*[a-zA-Z[]/ ) {
85+ if ( $line=~/\s*(.*?)\s*=\s*(.*)\s*$/ ) {
86+ printf("%-35s = %s\n", $1, $2)
87+ }
88+ elsif ( $line =~ /\s*\[/ ) {
89+ print "\n$line"
90+ } else {
91+ print $line
92+ }
93+ }' "$file"
94+
95 }
96
97+
98 find_checkpoint_age() {
99 local file="$1"
100 awk '
101
102=== modified file 'sandbox/start-sandbox'
103--- sandbox/start-sandbox 2014-04-30 14:53:04 +0000
104+++ sandbox/start-sandbox 2014-09-08 21:46:20 +0000
105@@ -240,7 +240,7 @@
106
107 if [ $type = "cluster" -o $APP = "pxc" ]; then
108 ip=$(perl -MNet::Address::IP::Local -le 'print Net::Address::IP::Local->public')
109- version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V --bind-address $ip 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
110+ version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V --query_cache_size=0 --query_cache_type=0 --bind-address $ip 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
111 else
112 version=`$PERCONA_TOOLKIT_SANDBOX/$mysqld -V 2>/dev/null | awk '{print $3}' | cut -d. -f 1,2`;
113 fi
114
115=== modified file 't/lib/bash/report_mysql_info.sh'
116--- t/lib/bash/report_mysql_info.sh 2013-12-12 05:49:59 +0000
117+++ t/lib/bash/report_mysql_info.sh 2014-09-08 21:46:20 +0000
118@@ -172,6 +172,7 @@
119 ssl = 1
120 server-id = 1
121 log-bin = sl1-bin
122+wsrep_provider_options = "gcache.size=64M;base_host=10.1.2.102; base_port=4567; cert.log_conflicts=no;etc=etc;"
123
124 [mysql.server]
125 user = mysql
126
127=== modified file 't/pt-mysql-summary/samples/my.cnf-001.txt'
128--- t/pt-mysql-summary/samples/my.cnf-001.txt 2011-07-01 16:29:50 +0000
129+++ t/pt-mysql-summary/samples/my.cnf-001.txt 2014-09-08 21:46:20 +0000
130@@ -24,6 +24,8 @@
131 server-id = 1
132 log-bin=sl1-bin
133
134+wsrep_provider_options = "gcache.size=64M;base_host=10.1.2.102; base_port=4567; cert.log_conflicts=no;etc=etc;"
135+
136 [mysql.server]
137 user=mysql
138 ####basedir=/var/lib

Subscribers

People subscribed via source and target branches

to all changes: