Skip to content

Commit

Permalink
[JENKINS-26399] JenkinsRuleExt.waitForCompletion/Message
Browse files Browse the repository at this point in the history
Originally-Committed-As: fac5ce62db53f18cabb2347f0bb6ae9e3f3ea1f9
  • Loading branch information
jglick committed Mar 18, 2015
1 parent dce0f0d commit f676d4c
Showing 1 changed file with 11 additions and 33 deletions.
Expand Up @@ -29,6 +29,7 @@
import jenkins.model.CauseOfInterruption;
import jenkins.model.InterruptedBuildAction;
import org.jenkinsci.plugins.workflow.BuildWatcher;
import org.jenkinsci.plugins.workflow.JenkinsRuleExt;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
Expand Down Expand Up @@ -118,9 +119,7 @@ public class StageTest {
assertTrue(b1.isBuilding());
e2.waitForSuspension();
e3.waitForSuspension();
Thread.sleep(1000); // TODO why is this necessary?
assertFalse(b2.isBuilding());
assertEquals(Result.NOT_BUILT, b2.getResult());
story.j.assertBuildStatus(Result.NOT_BUILT, JenkinsRuleExt.waitForCompletion(b2));
InterruptedBuildAction iba = b2.getAction(InterruptedBuildAction.class);
assertNotNull(iba);
List<CauseOfInterruption> causes = iba.getCauses();
Expand Down Expand Up @@ -183,24 +182,13 @@ public class StageTest {
WorkflowRun b1 = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("serializability/1", b1);
WorkflowRun b2 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b2).contains("Waiting for builds [1]")) {
// TODO similar to JENKINS-26399 though waiting for a particular message rather than completion
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [1]", b2);
WorkflowRun b3 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b3).contains("Waiting for builds [1]")) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [1]", b3);
SemaphoreStep.success("serializability/1", null); // b1
while (b1.isBuilding()) {
Thread.sleep(100);
}
story.j.assertBuildStatusSuccess(b1);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b1));
SemaphoreStep.success("serializability/2", null); // b3
while (b3.isBuilding()) {
Thread.sleep(100);
}
story.j.assertBuildStatusSuccess(b3);
story.j.assertBuildStatusSuccess(JenkinsRuleExt.waitForCompletion(b3));
story.j.assertBuildStatus(Result.NOT_BUILT, b2);
story.j.assertLogContains("Canceled since #3 got here", b2);
story.j.assertLogContains("in finally", b2);
Expand All @@ -222,16 +210,12 @@ public class StageTest {
WorkflowRun b1 = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("holdingAfterUnblockA/1", b1); // about to leave A
WorkflowRun b2 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b2).contains("Waiting for builds [1]")) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [1]", b2);
SemaphoreStep.success("holdingAfterUnblockA/1", null);
SemaphoreStep.waitForStart("holdingAfterUnblockB/1", b1); // now in B
SemaphoreStep.waitForStart("holdingAfterUnblockA/2", b2); // b2 unblocked, now in A
WorkflowRun b3 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b3).contains("Waiting for builds [2]")) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [2]", b3);
}
});
}
Expand All @@ -248,18 +232,12 @@ public class StageTest {
WorkflowRun b1 = p.scheduleBuild2(0).waitForStart();
SemaphoreStep.waitForStart("holdingAfterExitUnblock/1", b1); // about to leave
WorkflowRun b2 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b2).contains("Waiting for builds [1]")) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [1]", b2);
SemaphoreStep.success("holdingAfterExitUnblock/1", null);
while (b1.isBuilding()) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForCompletion(b1);
SemaphoreStep.waitForStart("holdingAfterExitUnblock/2", b2); // b2 unblocked
WorkflowRun b3 = p.scheduleBuild2(0).waitForStart();
while (!JenkinsRule.getLog(b3).contains("Waiting for builds [2]")) {
Thread.sleep(100);
}
JenkinsRuleExt.waitForMessage("Waiting for builds [2]", b3);
}
});
}
Expand Down

0 comments on commit f676d4c

Please sign in to comment.