Skip to content

Commit

Permalink
Merge pull request #60 from oleg-nenashev/JENKINS-44453
Browse files Browse the repository at this point in the history
[FIXED JENKINS-44453] - JenkinsRule should ensure that Jenkins reaches the COMPLETED milestone.
  • Loading branch information
jglick committed May 25, 2017
2 parents 8d42c69 + 5e14b5c commit a775211
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 an 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 a775211

Please sign in to comment.