commit 460cf7664ead390bc2c1d8c65ceb396e292c9202 Author: Petr Písař <ppisar@xxxxxxxxxx> Date: Thu Aug 21 14:23:35 2014 +0200 Fix t/01-starter.t race (bug #1100158) ...Synchronize-to-PID-in-t-05-killolddelay.t.patch | 85 ++++++++++++++++++++ perl-Server-Starter.spec | 8 ++- 2 files changed, 92 insertions(+), 1 deletions(-) --- diff --git a/Server-Starter-0.17-Synchronize-to-PID-in-t-05-killolddelay.t.patch b/Server-Starter-0.17-Synchronize-to-PID-in-t-05-killolddelay.t.patch new file mode 100644 index 0000000..7dad7e0 --- /dev/null +++ b/Server-Starter-0.17-Synchronize-to-PID-in-t-05-killolddelay.t.patch @@ -0,0 +1,85 @@ +From 046fb1328e76851a1398a624b77e746c37c62a67 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@xxxxxxxxxx> +Date: Thu, 21 Aug 2014 14:17:25 +0200 +Subject: [PATCH] Synchronize to PID in t/05-killolddelay.t +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +There were races between various sleeps and the restarting server. +This patch fixes it by waiting for complete generation change in the +status file. + +Similar to CPAN RT#73711. + +Signed-off-by: Petr Písař <ppisar@xxxxxxxxxx> +--- + t/05-killolddelay.t | 36 +++++++++++++++++++++++++----------- + 1 file changed, 25 insertions(+), 11 deletions(-) + +diff --git a/t/05-killolddelay.t b/t/05-killolddelay.t +index 19856af..457bdd9 100644 +--- a/t/05-killolddelay.t ++++ b/t/05-killolddelay.t +@@ -3,7 +3,7 @@ use warnings; + + use File::Temp (); + use Test::TCP; +-use Test::More tests => 28; ++use Test::More tests => 26; + + use Server::Starter qw(start_server); + +@@ -45,17 +45,18 @@ for my $signal_on_hup ('TERM', 'USR1') { + $buf =~ /^(\d+):/; + my $worker_pid = $1; + # switch to next gen +- sleep 2; +- my $status = get_status(); +- like(get_status(), qr/^1:\d+\n$/s, 'status before restart'); ++ my $previous_generation = get_single_generation(); ++ like($previous_generation, qr/^1:\d+\n$/s, 'status before restart'); + kill 'HUP', $server_pid; +- sleep 4; +- like(get_status(), qr/^1:\d+\n2:\d+$/s, 'status during restart'); +- # Child process has finished in 2 seconds but the parent +- # checks and calls waitpid every second, so wait for an +- # additional 1 second. +- sleep 3; +- like(get_status(), qr/^2:\d+\n$/s, 'status after restart'); ++ my $current_generation; ++ while (($current_generation = get_single_generation()) eq ++ $previous_generation) { ++ sleep 1; ++ } ++ diag "Server changed from <$previous_generation> ", ++ "to <$current_generation>\n"; ++ ++ like($current_generation, qr/^2:\d+\n$/s, 'status after restart'); + is( + do { + open my $fh, '<', "$tempdir/signame" +@@ -81,7 +82,20 @@ for my $signal_on_hup ('TERM', 'USR1') { + } + + sub get_status { ++ while (! -e "$tempdir/status") { ++ sleep 1; ++ } + open my $fh, '<', "$tempdir/status" + or die "failed to open file:$tempdir/status:$!"; + do { undef $/; <$fh> }; + } ++ ++sub get_single_generation { ++ my $status; ++ do { ++ sleep 1 if defined $status; ++ $status = get_status; ++ } until ($status =~ /\A\d+:\d+\n\z/); ++ chomp $status; ++ $status; ++} +-- +1.9.3 + diff --git a/perl-Server-Starter.spec b/perl-Server-Starter.spec index 784a305..4e07142 100644 --- a/perl-Server-Starter.spec +++ b/perl-Server-Starter.spec @@ -1,6 +1,6 @@ Name: perl-Server-Starter Version: 0.17 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Superdaemon for hot-deploying server programs License: GPL+ or Artistic Group: Development/Libraries @@ -14,6 +14,8 @@ Patch1: Server-Starter-0.17-Fix-loading-envdir.patch Patch2: Server-Starter-0.17-Synchronize-to-PID-in-t-06-autorestart.t.patch # Fix t/01-starter.t race, bug #1100158, CPAN RT#73711 Patch3: Server-Starter-0.17-Synchronize-to-PID-in-t-01-starter.t.patch +# Fix t/05-killolddelay.t race, bug #1100158, CPAN RT#73711 +Patch4: Server-Starter-0.17-Synchronize-to-PID-in-t-05-killolddelay.t.patch BuildArch: noarch BuildRequires: perl(ExtUtils::MakeMaker) >= 6.42 @@ -51,6 +53,7 @@ perl-Server-Starter's start_server script. %patch1 -p1 %patch2 -p1 %patch3 -p1 +%patch4 -p1 %build # --skipdeps causes ExtUtils::AutoInstall not to try auto-installing @@ -81,6 +84,9 @@ make test %{_mandir}/man1/start_server.* %changelog +* Thu Aug 21 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 0.17-6 +- Fix t/05-killolddelay.t race (bug #1100158) + * Fri Aug 08 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 0.17-5 - Fix t/01-starter.t race (bug #1100158) -- Fedora Extras Perl SIG http://www.fedoraproject.org/wiki/Extras/SIGs/Perl perl-devel mailing list perl-devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/perl-devel