Skip to content

Commit 99475c3

Browse files
authored
Deflake PipelineApiTest#parameterizedFreestyleTest (#2666)
1 parent a6e70e5 commit 99475c3

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

blueocean-rest-impl/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,12 @@
129129
<artifactId>powermock-reflect</artifactId>
130130
<scope>test</scope>
131131
</dependency>
132+
<dependency>
133+
<groupId>org.awaitility</groupId>
134+
<artifactId>awaitility</artifactId>
135+
<version>4.3.0</version>
136+
<scope>test</scope>
137+
</dependency>
132138
</dependencies>
133139

134140
<build>

blueocean-rest-impl/src/test/java/io/jenkins/blueocean/service/embedded/PipelineApiTest.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
import java.util.concurrent.ExecutionException;
6464
import java.util.concurrent.TimeUnit;
6565

66+
import static org.awaitility.Awaitility.await;
6667
import static org.junit.Assert.*;
6768

6869
/**
@@ -781,10 +782,14 @@ public void parameterizedFreestyleTest() throws Exception {
781782
Collections.singletonList(MapsHelper.of("name", "version", "value", "2.0"))
782783
), 200);
783784
assertEquals("pp", resp.get("pipeline"));
784-
Thread.sleep(1000);
785-
resp = get("/organizations/jenkins/pipelines/pp/runs/1/");
786-
assertEquals("SUCCESS", resp.get("result"));
787-
assertEquals("FINISHED", resp.get("state"));
785+
await().until(() -> {
786+
var build = p.getLastBuild();
787+
return build != null && !build.isBuilding() && build.getResult() == Result.SUCCESS;
788+
});
789+
await().until(() -> {
790+
Map runResp = get("/organizations/jenkins/pipelines/pp/runs/1/");
791+
return "SUCCESS".equals(runResp.get("result")) && "FINISHED".equals(runResp.get("state"));
792+
});
788793
}
789794

790795
public static class TestStringParameterDefinition extends StringParameterDefinition{

0 commit comments

Comments
 (0)