[perl-Server-Starter] Fix t/01-starter.t race

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit a77af9e1c5c0443ad99acc8743f8bd4d4f53cb85
Author: Petr Písař <ppisar@xxxxxxxxxx>
Date:   Fri Aug 8 13:06:27 2014 +0200

    Fix t/01-starter.t race

 ...0.17-Synchronize-to-PID-in-t-01-starter.t.patch |   82 ++++++++++++++++++++
 perl-Server-Starter.spec                           |    8 ++-
 2 files changed, 89 insertions(+), 1 deletions(-)
---
diff --git a/Server-Starter-0.17-Synchronize-to-PID-in-t-01-starter.t.patch b/Server-Starter-0.17-Synchronize-to-PID-in-t-01-starter.t.patch
new file mode 100644
index 0000000..e194cf3
--- /dev/null
+++ b/Server-Starter-0.17-Synchronize-to-PID-in-t-01-starter.t.patch
@@ -0,0 +1,82 @@
+From f7d5f6bfb5e94a3ea01e53c5b69186ff7172b4bf Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@xxxxxxxxxx>
+Date: Fri, 8 Aug 2014 12:58:40 +0200
+Subject: [PATCH] Synchronize to PID in t/01-starter.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.
+
+This fixes CPAN RT#73711.
+
+Signed-off-by: Petr Písař <ppisar@xxxxxxxxxx>
+---
+ t/01-starter.t | 33 +++++++++++++++++++++++++--------
+ 1 file changed, 25 insertions(+), 8 deletions(-)
+
+diff --git a/t/01-starter.t b/t/01-starter.t
+index ec671f0..1ddb925 100644
+--- a/t/01-starter.t
++++ b/t/01-starter.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);
+ 
+@@ -43,14 +43,17 @@ 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 3;
+-            like(get_status(), qr/^1:\d+\n2:\d+$/s, 'status during restart');
+-            sleep 2;
+-            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"
+@@ -76,7 +79,21 @@ 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 cb1b22b..784a305 100644
--- a/perl-Server-Starter.spec
+++ b/perl-Server-Starter.spec
@@ -1,6 +1,6 @@
 Name:           perl-Server-Starter
 Version:        0.17
-Release:        4%{?dist}
+Release:        5%{?dist}
 Summary:        Superdaemon for hot-deploying server programs
 License:        GPL+ or Artistic
 Group:          Development/Libraries
@@ -12,6 +12,8 @@ Patch0:         Server-Starter-0.17-Synchronize-to-PID-in-t-07-envdir.t.patch
 Patch1:         Server-Starter-0.17-Fix-loading-envdir.patch
 # Fix t/06-autorestart.t race, bug #1100158, CPAN RT#73711
 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
 BuildArch:      noarch
 
 BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.42
@@ -48,6 +50,7 @@ perl-Server-Starter's start_server script.
 %patch0 -p1
 %patch1 -p1
 %patch2 -p1
+%patch3 -p1
 
 %build
 # --skipdeps causes ExtUtils::AutoInstall not to try auto-installing
@@ -78,6 +81,9 @@ make test
 %{_mandir}/man1/start_server.*
 
 %changelog
+* Fri Aug 08 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 0.17-5
+- Fix t/01-starter.t race (bug #1100158)
+
 * Thu Jul 10 2014 Petr Pisar <ppisar@xxxxxxxxxx> - 0.17-4
 - Fix t/06-autorestart.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





[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux