Skip to content
Browse files

[FIXED JENKINS-44453] - JenkinsRule should ensure that Jenkins reache…

…s the COMPLETED milestone.

It should make issues like 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 fc7ef54f6aadfbf457e746847adbad0d4616dc56
Showing with 8 additions and 0 deletions.
  1. +8 −0 src/main/java/org/jvnet/hudson/test/
@@ -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;
@@ -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");

0 comments on commit fc7ef54

Please sign in to comment.
You can’t perform that action at this time.