Skip to content

Commit 316ce17

Browse files
authored
Merge pull request #573 from jglick/waitForSuspension
Deprecating `waitForSuspension`
2 parents a1599c6 + a913f06 commit 316ce17

File tree

4 files changed

+4
-17
lines changed

4 files changed

+4
-17
lines changed

src/main/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecution.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,9 @@ public void onFailure(Throwable t) {
962962

963963
/**
964964
* Waits for the workflow to move into the SUSPENDED state.
965+
* @deprecated Use some other idiom, like {@code SemaphoreStep}.
965966
*/
967+
@Deprecated
966968
public void waitForSuspension() throws InterruptedException, ExecutionException {
967969
if (programPromise==null)
968970
return; // the execution has already finished and we are not loading program state anymore

src/test/java/org/jenkinsci/plugins/workflow/SerializationTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ public boolean start() throws Exception {
132132
story.addStep(new Statement() {
133133
@Override public void evaluate() throws Throwable {
134134
rebuildContext(story.j);
135-
assertThatWorkflowIsSuspended();
136135
SemaphoreStep.success("wait/1", null);
137136
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
138137
}

src/test/java/org/jenkinsci/plugins/workflow/SingleJobTestBase.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.jenkinsci.plugins.workflow.cps.CpsFlowExecution;
3232
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
3333
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
34+
import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep;
3435
import org.junit.Assert;
3536
import org.junit.ClassRule;
3637
import org.junit.Rule;
@@ -70,25 +71,14 @@ public void rebuildContext(JenkinsRule j) throws Exception {
7071
e = (CpsFlowExecution) b.getExecution();
7172
}
7273

73-
/**
74-
* Asserts that {@link #e} is in the suspended state and has nothing more to execute.
75-
*/
76-
public void assertThatWorkflowIsSuspended() throws Exception {
77-
assertThatWorkflowIsSuspended(b, e);
78-
}
79-
80-
public void assertThatWorkflowIsSuspended(WorkflowRun b, CpsFlowExecution e) throws Exception {
81-
e.waitForSuspension(); // it should be in the suspended state
82-
assert b.isBuilding();
83-
}
84-
8574
/** @deprecated use {@link JenkinsRule#waitForCompletion} instead */
8675
public void waitForWorkflowToComplete() throws Exception {
8776
do {
8877
waitForWorkflowToSuspend(e);
8978
} while (!e.isComplete());
9079
}
9180

81+
/** @deprecated Use some other idiom, like {@link SemaphoreStep}. */
9282
public void waitForWorkflowToSuspend() throws Exception {
9383
waitForWorkflowToSuspend(e);
9484
}

src/test/java/org/jenkinsci/plugins/workflow/WorkflowTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ public void evaluate() throws Throwable {
9696
@Override
9797
public void evaluate() throws Throwable {
9898
rebuildContext(story.j);
99-
assertThatWorkflowIsSuspended();
10099
for (int i = 0; i < 600 && !Queue.getInstance().isEmpty(); i++) {
101100
Thread.sleep(100);
102101
}
@@ -141,7 +140,6 @@ private void liveness() {
141140
story.addStep(new Statement() {
142141
@Override public void evaluate() throws Throwable {
143142
rebuildContext(story.j);
144-
assertThatWorkflowIsSuspended();
145143

146144
// resume execution and cause the retry to invoke the body again
147145
SemaphoreStep.success("wait/1", null);
@@ -177,7 +175,6 @@ private void liveness() {
177175
@Override public void evaluate() throws Throwable {
178176
assertEquals(JenkinsRule.DummySecurityRealm.class, jenkins().getSecurityRealm().getClass());
179177
rebuildContext(story.j);
180-
assertThatWorkflowIsSuspended();
181178
story.j.waitForMessage("again running as someone", b);
182179
CheckAuth.finish(true);
183180
story.j.assertLogContains("finally running as someone", story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b)));
@@ -319,7 +316,6 @@ public void onNewHead(FlowNode node) {
319316
story.addStep(new Statement() {
320317
@Override public void evaluate() throws Throwable {
321318
rebuildContext(story.j);
322-
assertThatWorkflowIsSuspended();
323319
SemaphoreStep.success("env/1", null);
324320
story.j.assertBuildStatusSuccess(story.j.waitForCompletion(b));
325321
story.j.assertLogContains("tag=jenkins-demo-1 PERMACHINE=set", b);

0 commit comments

Comments
 (0)