Skip to content

Commit

Permalink
[FIXED JENKINS-44453] - JenkinsRule should ensure that Jenkins reache…
Browse files Browse the repository at this point in the history
…s the COMPLETED milestone.

It should make issues like https://issues.jenkins-ci.org/browse/JENKINS-37759 much more explicit in funtional tests.
From what I see there is no valid use-case for proceeding with the test if the initialization fails.
  • Loading branch information
oleg-nenashev committed May 23, 2017
1 parent 8d42c69 commit fc7ef54
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Expand Up @@ -206,6 +206,7 @@
import org.junit.runners.model.Statement;
import com.gargoylesoftware.htmlunit.html.DomNodeUtil;
import com.gargoylesoftware.htmlunit.html.HtmlFormUtil;
import hudson.init.InitMilestone;
import hudson.maven.MavenRequest;
import hudson.model.Job;
import hudson.model.queue.QueueTaskFuture;
Expand Down Expand Up @@ -368,6 +369,13 @@ public void before() throws Throwable {

try {
jenkins = hudson = newHudson();
// If the initialization graph is corrupted, we cannot expect that Jenkins is in the good shape.
// Likely it is an issue in @Initializer() definitions (see JENKINS-37759).
// So we just fail the test.
if (jenkins.getInitLevel() != InitMilestone.COMPLETED) {
throw new Exception("Jenkins initialization has not reached the COMPLETED initialization stage. Current state is " + jenkins.getInitLevel() +
". Likely there is and issue with the Initialization task graph (e.g. usage of @Initializer(after = InitMilestone.COMPLETED)). See JENKINS-37759 for more info");
}
} catch (Exception e) {
// if Hudson instance fails to initialize, it leaves the instance field non-empty and break all the rest of the tests, so clean that up.
Field f = Jenkins.class.getDeclaredField("theInstance");
Expand Down

0 comments on commit fc7ef54

Please sign in to comment.