Merge lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-utc-bug-1163372-2.1 into lp:percona-toolkit/2.1

Proposed by Daniel Nichter
Status: Merged
Merged at revision: 531
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-utc-bug-1163372-2.1
Merge into: lp:percona-toolkit/2.1
Diff against target: 75 lines (+46/-1)
2 files modified
bin/pt-heartbeat (+8/-0)
t/pt-heartbeat/utc.t (+38/-1)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/pt-heartbeat-utc-bug-1163372-2.1
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+157253@code.launchpad.net
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
=== modified file 'bin/pt-heartbeat'
--- bin/pt-heartbeat 2013-02-11 17:31:15 +0000
+++ bin/pt-heartbeat 2013-04-04 23:27:28 +0000
@@ -5071,6 +5071,14 @@
5071 $sth->finish();5071 $sth->finish();
5072 return ($delay, $hostname, $pk_val);5072 return ($delay, $hostname, $pk_val);
5073 };5073 };
5074
5075 # https://bugs.launchpad.net/percona-toolkit/+bug/1163372
5076 # "pt-heartbeat --utc --check always returns 0"
5077 if ( $utc ) {
5078 my $sql = "SET time_zone='+0:00'";
5079 PTDEBUG && _d($sql);
5080 $dbh->do($sql);
5081 }
5074 }5082 }
50755083
5076 # Do a little check just to make sure the table is there, so there's one last5084 # Do a little check just to make sure the table is there, so there's one last
50775085
=== renamed file 't/pt-heartbeat/bugs.t' => 't/pt-heartbeat/utc.t'
--- t/pt-heartbeat/bugs.t 2013-01-22 23:51:33 +0000
+++ t/pt-heartbeat/utc.t 2013-04-04 23:27:28 +0000
@@ -55,7 +55,7 @@
55 my $cmd = "$trunk/bin/pt-heartbeat";55 my $cmd = "$trunk/bin/pt-heartbeat";
56 exec { $cmd } $cmd, qw(-h 127.0.0.1 -u msandbox -p msandbox -P), $port,56 exec { $cmd } $cmd, qw(-h 127.0.0.1 -u msandbox -p msandbox -P), $port,
57 qw(--database test --table heartbeat --create-table),57 qw(--database test --table heartbeat --create-table),
58 qw(--update --interval 0.5 --pid), $pidfile;58 qw(--utc --update --interval 0.5 --pid), $pidfile;
59 exit 1;59 exit 1;
60 }60 }
61 push @exec_pids, $pid;61 push @exec_pids, $pid;
@@ -131,6 +131,43 @@
131 "Hi-res timestamp (bug 1103221)"131 "Hi-res timestamp (bug 1103221)"
132);132);
133133
134
135# #############################################################################
136# Bug 1163372: pt-heartbeat --utc --check always returns 0
137# #############################################################################
138
139my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
140$mon += 1;
141$year += 1900;
142
143# Make the ts seem like it 1 hour ago, so the output should show at least
144# 1 hour lag, i.e. 1.00, or maybe 1.02 etc. on a slow test box, but definately
145# not 0.\d+.
146$hour -= 1;
147
148my $old_utc_ts = sprintf(
149 "%d-%02d-%02dT%02d:%02d:%02d",
150 $year, $mon, $mday, $hour, $min, $sec);
151
152$master_dbh->do("truncate table test.heartbeat");
153$master_dbh->do("insert into test.heartbeat (ts, server_id) values ('$old_utc_ts', 1)");
154$sb->wait_for_slaves;
155
156($output) = output(
157 sub {
158 pt_heartbeat::main(
159 $slave1_dsn, qw(--database test --table heartbeat),
160 qw(--utc --check --master-server-id), $master_port
161 )
162 },
163);
164
165like(
166 $output,
167 qr/^1\.\d+/,
168 "--utc --check (bug 1163372"
169);
170
134# ############################################################################171# ############################################################################
135# Done.172# Done.
136# ############################################################################173# ############################################################################

Subscribers

People subscribed via source and target branches