Skip to content
Permalink
Browse files

Merge pull request #146 from jglick/standard-test-utils-JENKINS-26399

[JENKINS-26399] Standard test utils
Originally-Committed-As: 2f6a9d24d2c8432e9b0abf6a31e00067fafd7ae0
  • Loading branch information
jglick committed Jul 20, 2015
3 parents 1b1eae0 + 90be82d + d254d17 commit 7ef7a8a1bbc1a2e68fdb452ba645297f67ae1772
@@ -34,6 +34,7 @@
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Rule;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

@@ -116,7 +116,7 @@ public void evaluate() throws Throwable {
}
liveness();
SemaphoreStep.success("wait/1", null);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
}
});
}
@@ -162,7 +162,7 @@ private void liveness() {
rebuildContext(story.j);
assertThatWorkflowIsSuspended();
SemaphoreStep.success("wait/1", null);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
}
});
}
@@ -198,7 +198,7 @@ private void liveness() {
rebuildContext(story.j);
assertThatWorkflowIsSuspended();
SemaphoreStep.success("wait/1", null);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));

story.j.assertLogContains("before=demo", b);
story.j.assertLogContains("ONSLAVE=true", b);
@@ -232,7 +232,7 @@ private void liveness() {
@Override public void evaluate() throws Throwable {
rebuildContext(story.j);
SemaphoreStep.success("wait/1", null);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
}
});
}
@@ -300,7 +300,7 @@ private void startJnlpProc() throws Exception {
while (f2.isFile()) {
Thread.sleep(100);
}
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
story.j.assertLogContains("finished waiting", b);
story.j.assertLogContains("OK, done", b);
killJnlpProc();
@@ -349,7 +349,7 @@ private void startJnlpProc() throws Exception {
while (f2.isFile()) {
Thread.sleep(100);
}
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
story.j.assertLogContains("finished waiting", b); // TODO sometimes is not printed to log, despite f2 having been removed
story.j.assertLogContains("OK, done", b);
killJnlpProc();
@@ -472,7 +472,7 @@ private void startJnlpProc() throws Exception {
SemaphoreStep.success("wait/2", null);
SemaphoreStep.success("wait/3", null);

story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
assertTrue(e.programPromise.get().closures.isEmpty());
}
});
@@ -490,21 +490,21 @@ private void startJnlpProc() throws Exception {
startBuilding();
waitForWorkflowToSuspend();
assertTrue(b.isBuilding());
JenkinsRuleExt.waitForMessage("running as someone", b);
story.j.waitForMessage("running as someone", b);
CheckAuth.finish(false);
waitForWorkflowToSuspend();
assertTrue(b.isBuilding());
JenkinsRuleExt.waitForMessage("still running as someone", b);
story.j.waitForMessage("still running as someone", b);
}
});
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
assertEquals(JenkinsRule.DummySecurityRealm.class, jenkins().getSecurityRealm().getClass());
rebuildContext(story.j);
assertThatWorkflowIsSuspended();
JenkinsRuleExt.waitForMessage("again running as someone", b);
story.j.waitForMessage("again running as someone", b);
CheckAuth.finish(true);
story.j.assertLogContains("finally running as someone", story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b)));
story.j.assertLogContains("finally running as someone", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)));
}
});
}
@@ -586,7 +586,7 @@ public static void finish(final boolean terminate) {
rebuildContext(story.j);
assertThatWorkflowIsSuspended();
SemaphoreStep.success("env/1", null);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b));
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
story.j.assertLogContains("tag=jenkins-demo-1 PERMACHINE=set", b);
story.j.assertLogContains("tag2=custom", b);
story.j.assertLogContains("tag3=custom2 stuff=more", b);
@@ -608,15 +608,15 @@ public static void finish(final boolean terminate) {
p = jenkins().createProject(WorkflowJob.class, "demo");
p.setDefinition(new CpsFlowDefinition("node('special') {echo 'OK ran'}"));
startBuilding();
JenkinsRuleExt.waitForMessage("Still waiting to schedule task", b);
story.j.waitForMessage("Still waiting to schedule task", b);
}
});
story.addStep(new Statement() {
@Override public void evaluate() throws Throwable {
story.j.createSlave("special", null);
rebuildContext(story.j);
// TODO JENKINS-27532 sometimes two copies of the WorkflowRun are loaded
story.j.assertLogContains("OK ran", story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b)));
story.j.assertLogContains("OK ran", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)));
}
});
}
@@ -26,8 +26,6 @@

import hudson.Functions;
import java.io.File;
import org.jenkinsci.plugins.workflow.BuildWatcher;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
@@ -36,6 +34,7 @@
import org.junit.Test;
import org.junit.Rule;
import org.junit.runners.model.Statement;
import org.jvnet.hudson.test.BuildWatcher;
import org.jvnet.hudson.test.RestartableJenkinsRule;

public class PushdStepTest {
@@ -70,7 +69,7 @@ private String pwdStep() {
@Override public void evaluate() throws Throwable {
SemaphoreStep.success("restarting/1", null);
WorkflowRun b = story.j.jenkins.getItemByFullName("p", WorkflowJob.class).getLastBuild();
story.j.assertLogContains(File.separator + "subdir", story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b)));
story.j.assertLogContains(File.separator + "subdir", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)));
}
});
}

0 comments on commit 7ef7a8a

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