Skip to content

Commit fe7f247

Browse files
committed
Merge branch '3.2.x' into 3.3.x
2 parents dba395d + 7d1cc78 commit fe7f247

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;
@@ -262,7 +263,7 @@ void plainWarApp() throws Exception {
262263
writeServletInitializerClass();
263264
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
264265
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
265-
BuildResult result = buildImage(imageName);
266+
BuildResult result = buildImageWithRetry(imageName);
266267
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
267268
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
268269
container.withExposedPorts(8080);
@@ -375,6 +376,30 @@ void classDataSharingApp() throws Exception {
375376
}
376377
}
377378

379+
private BuildResult buildImageWithRetry(String imageName, String... arguments) {
380+
long start = System.nanoTime();
381+
while (true) {
382+
try {
383+
return buildImage(imageName, arguments);
384+
}
385+
catch (Exception ex) {
386+
if (Duration.ofNanos(System.nanoTime() - start).toMinutes() > 6) {
387+
throw ex;
388+
}
389+
sleep(500);
390+
}
391+
}
392+
}
393+
394+
private void sleep(long time) {
395+
try {
396+
Thread.sleep(time);
397+
}
398+
catch (InterruptedException ex) {
399+
Thread.currentThread().interrupt();
400+
}
401+
}
402+
378403
private BuildResult buildImage(String imageName, String... arguments) {
379404
String[] buildImageArgs = { "bootBuildImage", "--imageName=" + imageName, "--pullPolicy=IF_NOT_PRESENT" };
380405
String[] args = StringUtils.concatenateStringArrays(arguments, buildImageArgs);

0 commit comments

Comments
 (0)