Merge lp:~percona-toolkit-dev/percona-toolkit/fixed-various-test-issues-1365085 into lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11

Proposed by Frank Cizmich
Status: Merged
Approved by: Daniel Nichter
Approved revision: 617
Merged at revision: 621
Proposed branch: lp:~percona-toolkit-dev/percona-toolkit/fixed-various-test-issues-1365085
Merge into: lp:~percona-toolkit-dev/percona-toolkit/release-2.2.11
Diff against target: 86 lines (+48/-1)
3 files modified
t/lib/Percona/Toolkit.t (+16/-0)
t/pt-duplicate-key-checker/standard_options.t (+26/-1)
t/pt-fifo-split/pt-fifo-split.t (+6/-0)
To merge this branch: bzr merge lp:~percona-toolkit-dev/percona-toolkit/fixed-various-test-issues-1365085
Reviewer Review Type Date Requested Status
Daniel Nichter Approve
Review via email: mp+233800@code.launchpad.net

Description of the change

t/lib/Percona/Toolkit.t :

Created an aux function to correctly sort version numbers (some bzr versions do not do it).
This enables the test to correctly fetch the latest version number from the tags.

t/pt-duplicate-key-checker/standard_options.t :

Sometimes the test command hanged. Set a timeout of 5 seconds

t/pt-fifo-split/pt-fifo-split.t :

Sometimes freezes on CentOS despite the coded precautions. Resorted to simply sleeping 3 seconds to avoid deadlock.

To post a comment you must log in.
Revision history for this message
Daniel Nichter (daniel-nichter) wrote :

I don't really understand the problems and thus fixes, but you know more about the tests than me, so if it works for you then great.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 't/lib/Percona/Toolkit.t'
2--- t/lib/Percona/Toolkit.t 2013-08-08 19:34:29 +0000
3+++ t/lib/Percona/Toolkit.t 2014-09-08 20:20:20 +0000
4@@ -75,6 +75,8 @@
5 unless $root eq $trunk;
6
7 my @tags = split /\n/, `$bzr tags`;
8+ # sort the version numbers (some bzr versions do not sort them)
9+ @tags = sort { calc_value($a) <=> calc_value($b) } @tags;
10 my ($current_tag) = $tags[-1] =~ /^(\S+)/;
11
12 is(
13@@ -84,4 +86,18 @@
14 );
15 }
16
17+# we use this function to help sort version numbers
18+sub calc_value {
19+ my $version = shift;
20+ $version =~ s/ +[^ ]*$//;
21+ my $value = 0;
22+ my $exp = 0;
23+ foreach my $num (reverse split /\./, $version) {
24+ $value += $num * 10 ** $exp++;
25+ }
26+ print "$version = $value\n";
27+ return $value;
28+}
29+
30+
31 done_testing;
32
33=== modified file 't/pt-duplicate-key-checker/standard_options.t'
34--- t/pt-duplicate-key-checker/standard_options.t 2013-12-12 02:17:16 +0000
35+++ t/pt-duplicate-key-checker/standard_options.t 2014-09-08 20:20:20 +0000
36@@ -28,7 +28,32 @@
37
38 diag(`touch $pid_file`);
39
40-$output = `$cmd -d issue_295 --pid $pid_file 2>&1`;
41+
42+# to test this issue I must set a timeout in case the command doesn't come back
43+
44+eval {
45+ # we define an alarm signal handler
46+ local $SIG{'ALRM'} = sub { die "timed out\n" };
47+
48+ # and set the alarm 'clock' to 5 seconds
49+ alarm(5);
50+
51+ # here's the actual command. correct bahaviour is to die with messsage "PID file <pid_file> exists"
52+ # Incorrect behavior is anything else, including not returning control after 5 seconds
53+ $output = `$cmd -d issue_295 --pid $pid_file 2>&1`;
54+
55+};
56+
57+if ($@) {
58+ if ($@ eq "timed out\n") {
59+ print "I timed out\n";
60+ }
61+ else {
62+ print "Something else went wrong: $@\n";
63+ }
64+}
65+
66+
67 like(
68 $output,
69 qr{PID file $pid_file exists},
70
71=== modified file 't/pt-fifo-split/pt-fifo-split.t'
72--- t/pt-fifo-split/pt-fifo-split.t 2013-03-04 19:06:34 +0000
73+++ t/pt-fifo-split/pt-fifo-split.t 2014-09-08 20:20:20 +0000
74@@ -47,6 +47,12 @@
75 my ($n_reads) = @_;
76 my $last_inode = 0;
77 my @data;
78+
79+ # This test still freezes on some centos systems,
80+ # so we're going to bluntly sleep for a few secs to avoid deadlock
81+ # TODO: figure out if there is a proper way to do this.
82+ sleep(3);
83+
84 for (1..$n_reads) {
85 PerconaTest::wait_until(sub {
86 my $inode;

Subscribers

People subscribed via source and target branches

to all changes: