From 9848f4cd9f6ebe5b91722d97ecfa1d70ccc356bb Mon Sep 17 00:00:00 2001 From: James Nord Date: Tue, 13 Apr 2021 15:38:26 +0100 Subject: [PATCH 1/2] wait for max 60 seconds for Jenkins to terminate --- .../java/org/jvnet/hudson/test/RealJenkinsRule.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java index a3a54d06b..763428826 100644 --- a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java @@ -411,8 +411,14 @@ public void startJenkins() throws Throwable { public void stopJenkins() throws Throwable { endpoint("exit").openStream().close(); - if (proc.waitFor() != 0) { - throw new AssertionError("nonzero exit code"); + if (!proc.waitFor(60, TimeUnit.SECONDS) ) { + System.err.println("Jenkins failed to stop within 60 seconds, attempting to kill the Jenkins process"); + proc.destroyForcibly(); + throw new AssertionError("Jenkins failed to terminate within 60 seconds"); + } + int exitValue = proc.exitValue(); + if (exitValue != 0) { + throw new AssertionError("onzero exit code: " + exitValue); } proc = null; } From c79b00568b20e02c12e834b0a286afd31ee280d7 Mon Sep 17 00:00:00 2001 From: James Nord Date: Tue, 13 Apr 2021 15:45:09 +0100 Subject: [PATCH 2/2] Update src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java Co-authored-by: Jesse Glick --- src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java index 763428826..298bdfdd3 100644 --- a/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java +++ b/src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java @@ -418,7 +418,7 @@ public void stopJenkins() throws Throwable { } int exitValue = proc.exitValue(); if (exitValue != 0) { - throw new AssertionError("onzero exit code: " + exitValue); + throw new AssertionError("nonzero exit code: " + exitValue); } proc = null; }