Skip to content

Commit

Permalink
Merge pull request #297 from jtnord/do-notwait-forever
Browse files Browse the repository at this point in the history
RealJenkinsRule: wait for max 60 seconds for Jenkins to terminate
  • Loading branch information
jglick authored Apr 13, 2021
2 parents 4fd5baf + c79b005 commit 9d0c8b5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/jvnet/hudson/test/RealJenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("nonzero exit code: " + exitValue);
}
proc = null;
}
Expand Down

0 comments on commit 9d0c8b5

Please sign in to comment.