Skip to content

Commit

Permalink
Test for JENKINS-43055.
Browse files Browse the repository at this point in the history
Note that I can't consistently reproduce JENKINS-43055 in the test
environment in the first place.
  • Loading branch information
abayer committed May 16, 2017
1 parent 2671aeb commit 6c449af
Showing 1 changed file with 11 additions and 0 deletions.
Expand Up @@ -27,9 +27,11 @@
import hudson.model.labels.LabelAtom;
import hudson.slaves.DumbSlave;
import hudson.slaves.EnvironmentVariablesNodeProperty;
import org.hamcrest.Matchers;
import org.jenkinsci.plugins.pipeline.modeldefinition.config.GlobalConfig;
import org.jenkinsci.plugins.workflow.actions.WorkspaceAction;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.graph.FlowGraphWalker;
import org.jenkinsci.plugins.workflow.graph.FlowNode;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
Expand All @@ -41,14 +43,17 @@
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.LoggerRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.logging.Level;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

public class DurabilityTest {
@ClassRule
Expand All @@ -57,6 +62,9 @@ public class DurabilityTest {
@Rule
public RestartableJenkinsRule story = new RestartableJenkinsRule();

@Rule
public LoggerRule logger = new LoggerRule();

@Issue("JENKINS-42027")
@Test
public void globalConfigPersists() throws Exception {
Expand All @@ -80,6 +88,7 @@ public void evaluate() throws Throwable {
public void survivesRestart() throws Exception {
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
logger.record(CpsFlowExecution.class, Level.WARNING).capture(100);
DumbSlave s = story.j.createOnlineSlave();
s.setLabelString("remote quick");
s.getNodeProperties().add(new EnvironmentVariablesNodeProperty(new EnvironmentVariablesNodeProperty.Entry("ONAGENT", "true")));
Expand Down Expand Up @@ -131,6 +140,8 @@ public void survivesRestart() throws Exception {
}
assertEquals(1, actions.size());
assertEquals(new HashSet<LabelAtom>(Arrays.asList(LabelAtom.get("remote"), LabelAtom.get("quick"))), actions.get(0).getLabels());
assertThat(logger.getRecords(), Matchers.hasSize(Matchers.equalTo(0)));

}
});

Expand Down

0 comments on commit 6c449af

Please sign in to comment.