Skip to content

Commit d83d34d

Browse files
committed
Merge branch '3.3.x'
2 parents 76226f9 + fe7f247 commit d83d34d

File tree

1 file changed

+26
-1
lines changed
  • spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo

1 file changed

+26
-1
lines changed

spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.io.FileWriter;
2121
import java.io.IOException;
2222
import java.io.PrintWriter;
23+
import java.time.Duration;
2324
import java.util.ArrayList;
2425
import java.util.List;
2526
import java.util.function.Consumer;
@@ -267,7 +268,7 @@ void plainWarApp() throws Exception {
267268
writeServletInitializerClass();
268269
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
269270
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
270-
BuildResult result = buildImage(imageName);
271+
BuildResult result = buildImageWithRetry(imageName);
271272
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
272273
assertThat(result.getOutput()).contains("Running creator");
273274
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
@@ -378,6 +379,30 @@ void classDataSharingApp() throws Exception {
378379
}
379380
}
380381

382+
private BuildResult buildImageWithRetry(String imageName, String... arguments) {
383+
long start = System.nanoTime();
384+
while (true) {
385+
try {
386+
return buildImage(imageName, arguments);
387+
}
388+
catch (Exception ex) {
389+
if (Duration.ofNanos(System.nanoTime() - start).toMinutes() > 6) {
390+
throw ex;
391+
}
392+
sleep(500);
393+
}
394+
}
395+
}
396+
397+
private void sleep(long time) {
398+
try {
399+
Thread.sleep(time);
400+
}
401+
catch (InterruptedException ex) {
402+
Thread.currentThread().interrupt();
403+
}
404+
}
405+
381406
private BuildResult buildImage(String imageName, String... arguments) {
382407
List<String> args = new ArrayList<>(List.of(arguments));
383408
args.add("bootBuildImage");

0 commit comments

Comments
 (0)