forked from jenkinsci/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXES JENKINS-47439] Setup wizard does not resume after restart (jen…
…kinsci#3166) * [JENKINS-47439] Add a failing test On first startup, the setup wizard goes into state NEW and the filter to force display the setup wizard is installed. On second startup, the setup wizard goes into state RESTART (which assumes the setup wizard is done), and the setup wizard is skipped completely. This test expects that state NEW is retained upon restart when nothing is done. * [JENKINS-47439] Persist InstallState In some cases, the heuristics to determine the current setup wizard state are fragile. It is safer to persist the install state so that upon restart, the setup wizard can resume where it was left off. * Missing javadoc and since for new public methods * s/XXX/FIXME/ * Missed that one * Setup wizard filter should be removed when entering a state where setup is complete * Use parameterized logging * Improvements over previous impl * Removed static isUsingSecurityToken. Now only determined from install state. * Call onInstallStateUpdate before InstallState#initializeState as the latter can update state. * Triggering a new build
- Loading branch information
1 parent
18d7ed5
commit 30ab448
Showing
6 changed files
with
143 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
test/src/test/java/jenkins/install/SetupWizardRestartTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package jenkins.install; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runners.model.Statement; | ||
import org.jvnet.hudson.test.Issue; | ||
import org.jvnet.hudson.test.RestartableJenkinsRule; | ||
|
||
import hudson.Main; | ||
import jenkins.model.Jenkins; | ||
|
||
public class SetupWizardRestartTest { | ||
@Rule | ||
public RestartableJenkinsRule rr = new RestartableJenkinsRule(); | ||
|
||
@Issue("JENKINS-47439") | ||
@Test | ||
public void restartKeepsSetupWizardState() { | ||
rr.addStep(new Statement() { | ||
@Override | ||
public void evaluate() throws IOException { | ||
// Modify state so that we get into the same conditions as a real start | ||
Main.isUnitTest = false; | ||
FileUtils.write(InstallUtil.getLastExecVersionFile(), ""); | ||
Jenkins j = rr.j.getInstance(); | ||
// Re-evaluate current state based on the new context | ||
InstallUtil.proceedToNextStateFrom(InstallState.UNKNOWN); | ||
assertEquals("Unexpected install state", InstallState.NEW, j.getInstallState()); | ||
assertTrue("Expecting setup wizard filter to be up", j.getSetupWizard().hasSetupWizardFilter()); | ||
InstallUtil.saveLastExecVersion(); | ||
} | ||
}); | ||
// Check that the state is retained after a restart | ||
rr.addStep(new Statement() { | ||
@Override | ||
public void evaluate() { | ||
Jenkins j = rr.j.getInstance(); | ||
assertEquals("Unexpected install state", InstallState.NEW, j.getInstallState()); | ||
assertTrue("Expecting setup wizard filter to be up after restart", j.getSetupWizard().hasSetupWizardFilter()); | ||
} | ||
}); | ||
} | ||
|
||
} |