Skip to content

Commit 567e2a1

Browse files
authored
Merge pull request #945 from jglick/iterateAfterSuspend
`CpsFlowExecutionTest.iterateAfterSuspend` flaky
2 parents 79cf4fd + 2d85ada commit 567e2a1

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

plugin/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@
240240
</exclusion>
241241
</exclusions>
242242
</dependency>
243+
<dependency>
244+
<groupId>org.awaitility</groupId>
245+
<artifactId>awaitility</artifactId>
246+
<version>4.2.2</version>
247+
<scope>test</scope>
248+
</dependency>
243249
</dependencies>
244250
<build>
245251
<resources>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ public static void suspendAll() {
16761676
if (cpsExec.programPromise != null) {
16771677
cpsExec.runInCpsVmThread(new FutureCallback<>() {
16781678
@Override public void onSuccess(CpsThreadGroup g) {
1679-
LOGGER.fine(() -> "shutting down CPS VM threadin for " + cpsExec);
1679+
LOGGER.fine(() -> "shutting down CPS VM for " + cpsExec);
16801680
g.shutdown();
16811681
}
16821682
@Override public void onFailure(Throwable t) {

plugin/src/test/java/org/jenkinsci/plugins/workflow/cps/CpsFlowExecutionTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import java.util.stream.Collectors;
7474
import jenkins.model.Jenkins;
7575
import org.apache.commons.io.FileUtils;
76+
import static org.awaitility.Awaitility.await;
7677
import static org.hamcrest.MatcherAssert.assertThat;
7778
import static org.hamcrest.Matchers.arrayContaining;
7879
import static org.hamcrest.Matchers.contains;
@@ -207,6 +208,7 @@ private static List<String> stepNames(ListenableFuture<List<StepExecution>> exec
207208

208209
@Test public void iterateAfterSuspend() throws Throwable {
209210
sessions.then(r -> {
211+
logger.record(CpsFlowExecution.class, Level.FINE);
210212
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "iterateAfterSuspend");
211213
p.setDefinition(new CpsFlowDefinition("semaphore 'wait'", true));
212214
SemaphoreStep.waitForStart("wait/1", p.scheduleBuild2(0).waitForStart());
@@ -226,7 +228,7 @@ private static List<String> stepNames(ListenableFuture<List<StepExecution>> exec
226228
return; // different test
227229
}
228230
try {
229-
assertThat(p.getLastBuild().getExecution().getCurrentExecutions(false).get(), empty());
231+
await().until(() -> p.getLastBuild().getExecution().getCurrentExecutions(false).get(), empty());
230232
} catch (Throwable t) {
231233
iterateAfterSuspendError.set(t);
232234
}

0 commit comments

Comments
 (0)