Skip to content

Commit

Permalink
Merge pull request #945 from jglick/iterateAfterSuspend
Browse files Browse the repository at this point in the history
`CpsFlowExecutionTest.iterateAfterSuspend` flaky
  • Loading branch information
jglick authored Oct 15, 2024
2 parents 79cf4fd + 2d85ada commit 567e2a1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1676,7 +1676,7 @@ public static void suspendAll() {
if (cpsExec.programPromise != null) {
cpsExec.runInCpsVmThread(new FutureCallback<>() {
@Override public void onSuccess(CpsThreadGroup g) {
LOGGER.fine(() -> "shutting down CPS VM threadin for " + cpsExec);
LOGGER.fine(() -> "shutting down CPS VM for " + cpsExec);
g.shutdown();
}
@Override public void onFailure(Throwable t) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
import java.util.stream.Collectors;
import jenkins.model.Jenkins;
import org.apache.commons.io.FileUtils;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.arrayContaining;
import static org.hamcrest.Matchers.contains;
Expand Down Expand Up @@ -207,6 +208,7 @@ private static List<String> stepNames(ListenableFuture<List<StepExecution>> exec

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

0 comments on commit 567e2a1

Please sign in to comment.