Subject: | 'kill $pid' tests fail on a slow/loaded machine |
I've been seeing a lot of failure for MooseX::Daemonize tests on our Jenkins build server. This seems to be because it can take more than two seconds to completely kill the process.
I've attached a patch that will:
- only sleep if it needs to (removing the existing mandatory 2 second sleep)
- added a loop that will sleep for 2 seconds, up to 10 times and exit as soon as the $pid has been killed
I hope the 20 seconds is enough for even sluggish systems.
Subject: | MooseX-Daemonize-0.17-killpid.patch |
diff -Naur MooseX-Daemonize-0.17/t/20.core.t MooseX-Daemonize-0.17-patch/t/20.core.t
--- MooseX-Daemonize-0.17/t/20.core.t 2013-04-21 01:13:45.000000000 +0100
+++ MooseX-Daemonize-0.17-patch/t/20.core.t 2013-05-13 13:56:42.000000000 +0100
@@ -87,7 +87,14 @@
}
kill INT => $p->pid;
diag "killed $pid" if DEBUG;
-sleep(2);
+
+# give the process time to be killed on slow/loaded systems
+for (1..10) {
+ last unless kill 0 => $pid;
+ # sleep a little before retrying
+ sleep(2);
+}
+
if (DEBUG) {
diag `ps $pid`;
diag "-------";
diff -Naur MooseX-Daemonize-0.17/t/21.core-back-compat.t MooseX-Daemonize-0.17-patch/t/21.core-back-compat.t
--- MooseX-Daemonize-0.17/t/21.core-back-compat.t 2013-04-21 01:13:45.000000000 +0100
+++ MooseX-Daemonize-0.17-patch/t/21.core-back-compat.t 2013-05-13 13:56:45.000000000 +0100
@@ -88,7 +88,14 @@
}
kill INT => $p->pid;
diag "killed $pid" if DEBUG;
-sleep(2);
+
+# give the process time to be killed on slow/loaded systems
+for (1..10) {
+ last unless kill 0 => $pid;
+ # sleep a little before retrying
+ sleep(2);
+}
+
if (DEBUG) {
diag `ps $pid`;
diag "-------";
diff -Naur MooseX-Daemonize-0.17/t/30.with_pid_file.t MooseX-Daemonize-0.17-patch/t/30.with_pid_file.t
--- MooseX-Daemonize-0.17/t/30.with_pid_file.t 2013-04-21 01:13:45.000000000 +0100
+++ MooseX-Daemonize-0.17-patch/t/30.with_pid_file.t 2013-05-13 13:56:49.000000000 +0100
@@ -96,7 +96,14 @@
}
kill INT => $p->pid;
diag "killed $pid" if DEBUG;
-sleep(2);
+
+# give the process time to be killed on slow/loaded systems
+for (1..10) {
+ last unless kill 0 => $pid;
+ # sleep a little before retrying
+ sleep(2);
+}
+
if (DEBUG) {
diag `ps $pid`;
diag "-------";