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
1=== modified file 'bin/pt-heartbeat'
2--- bin/pt-heartbeat 2013-02-11 17:31:15 +0000
3+++ bin/pt-heartbeat 2013-04-04 23:27:28 +0000
4@@ -5071,6 +5071,14 @@
5 $sth->finish();
6 return ($delay, $hostname, $pk_val);
7 };
8+
9+ # https://bugs.launchpad.net/percona-toolkit/+bug/1163372
10+ # "pt-heartbeat --utc --check always returns 0"
11+ if ( $utc ) {
12+ my $sql = "SET time_zone='+0:00'";
13+ PTDEBUG && _d($sql);
14+ $dbh->do($sql);
15+ }
16 }
17
18 # Do a little check just to make sure the table is there, so there's one last
19
20=== renamed file 't/pt-heartbeat/bugs.t' => 't/pt-heartbeat/utc.t'
21--- t/pt-heartbeat/bugs.t 2013-01-22 23:51:33 +0000
22+++ t/pt-heartbeat/utc.t 2013-04-04 23:27:28 +0000
23@@ -55,7 +55,7 @@
24 my $cmd = "$trunk/bin/pt-heartbeat";
25 exec { $cmd } $cmd, qw(-h 127.0.0.1 -u msandbox -p msandbox -P), $port,
26 qw(--database test --table heartbeat --create-table),
27- qw(--update --interval 0.5 --pid), $pidfile;
28+ qw(--utc --update --interval 0.5 --pid), $pidfile;
29 exit 1;
30 }
31 push @exec_pids, $pid;
32@@ -131,6 +131,43 @@
33 "Hi-res timestamp (bug 1103221)"
34 );
35
36+
37+# #############################################################################
38+# Bug 1163372: pt-heartbeat --utc --check always returns 0
39+# #############################################################################
40+
41+my ($sec, $min, $hour, $mday, $mon, $year) = gmtime(time);
42+$mon += 1;
43+$year += 1900;
44+
45+# Make the ts seem like it 1 hour ago, so the output should show at least
46+# 1 hour lag, i.e. 1.00, or maybe 1.02 etc. on a slow test box, but definately
47+# not 0.\d+.
48+$hour -= 1;
49+
50+my $old_utc_ts = sprintf(
51+ "%d-%02d-%02dT%02d:%02d:%02d",
52+ $year, $mon, $mday, $hour, $min, $sec);
53+
54+$master_dbh->do("truncate table test.heartbeat");
55+$master_dbh->do("insert into test.heartbeat (ts, server_id) values ('$old_utc_ts', 1)");
56+$sb->wait_for_slaves;
57+
58+($output) = output(
59+ sub {
60+ pt_heartbeat::main(
61+ $slave1_dsn, qw(--database test --table heartbeat),
62+ qw(--utc --check --master-server-id), $master_port
63+ )
64+ },
65+);
66+
67+like(
68+ $output,
69+ qr/^1\.\d+/,
70+ "--utc --check (bug 1163372"
71+);
72+
73 # ############################################################################
74 # Done.
75 # ############################################################################

Subscribers

People subscribed via source and target branches