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
=== modified file 't/lib/Percona/Toolkit.t'
--- t/lib/Percona/Toolkit.t 2013-08-08 19:34:29 +0000
+++ t/lib/Percona/Toolkit.t 2014-09-08 20:20:20 +0000
@@ -75,6 +75,8 @@
75 unless $root eq $trunk;75 unless $root eq $trunk;
76 76
77 my @tags = split /\n/, `$bzr tags`;77 my @tags = split /\n/, `$bzr tags`;
78 # sort the version numbers (some bzr versions do not sort them)
79 @tags = sort { calc_value($a) <=> calc_value($b) } @tags;
78 my ($current_tag) = $tags[-1] =~ /^(\S+)/;80 my ($current_tag) = $tags[-1] =~ /^(\S+)/;
7981
80 is(82 is(
@@ -84,4 +86,18 @@
84 );86 );
85}87}
8688
89# we use this function to help sort version numbers
90sub calc_value {
91 my $version = shift;
92 $version =~ s/ +[^ ]*$//;
93 my $value = 0;
94 my $exp = 0;
95 foreach my $num (reverse split /\./, $version) {
96 $value += $num * 10 ** $exp++;
97 }
98 print "$version = $value\n";
99 return $value;
100}
101
102
87done_testing;103done_testing;
88104
=== modified file 't/pt-duplicate-key-checker/standard_options.t'
--- t/pt-duplicate-key-checker/standard_options.t 2013-12-12 02:17:16 +0000
+++ t/pt-duplicate-key-checker/standard_options.t 2014-09-08 20:20:20 +0000
@@ -28,7 +28,32 @@
2828
29diag(`touch $pid_file`);29diag(`touch $pid_file`);
3030
31$output = `$cmd -d issue_295 --pid $pid_file 2>&1`;31
32# to test this issue I must set a timeout in case the command doesn't come back
33
34eval {
35 # we define an alarm signal handler
36 local $SIG{'ALRM'} = sub { die "timed out\n" };
37
38 # and set the alarm 'clock' to 5 seconds
39 alarm(5);
40
41 # here's the actual command. correct bahaviour is to die with messsage "PID file <pid_file> exists"
42 # Incorrect behavior is anything else, including not returning control after 5 seconds
43 $output = `$cmd -d issue_295 --pid $pid_file 2>&1`;
44
45};
46
47if ($@) {
48 if ($@ eq "timed out\n") {
49 print "I timed out\n";
50 }
51 else {
52 print "Something else went wrong: $@\n";
53 }
54}
55
56
32like(57like(
33 $output,58 $output,
34 qr{PID file $pid_file exists},59 qr{PID file $pid_file exists},
3560
=== modified file 't/pt-fifo-split/pt-fifo-split.t'
--- t/pt-fifo-split/pt-fifo-split.t 2013-03-04 19:06:34 +0000
+++ t/pt-fifo-split/pt-fifo-split.t 2014-09-08 20:20:20 +0000
@@ -47,6 +47,12 @@
47 my ($n_reads) = @_;47 my ($n_reads) = @_;
48 my $last_inode = 0;48 my $last_inode = 0;
49 my @data;49 my @data;
50
51 # This test still freezes on some centos systems,
52 # so we're going to bluntly sleep for a few secs to avoid deadlock
53 # TODO: figure out if there is a proper way to do this.
54 sleep(3);
55
50 for (1..$n_reads) {56 for (1..$n_reads) {
51 PerconaTest::wait_until(sub {57 PerconaTest::wait_until(sub {
52 my $inode;58 my $inode;

Subscribers

People subscribed via source and target branches

to all changes: