Merge branch '3.2.x' into 3.3.x
This commit is contained in:
commit
fe7f247018
@ -20,6 +20,7 @@ import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
@ -262,7 +263,7 @@ class PaketoBuilderTests {
|
||||
writeServletInitializerClass();
|
||||
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName();
|
||||
ImageReference imageReference = ImageReference.of(ImageName.of(imageName));
|
||||
BuildResult result = buildImage(imageName);
|
||||
BuildResult result = buildImageWithRetry(imageName);
|
||||
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS);
|
||||
try (GenericContainer<?> container = new GenericContainer<>(imageName)) {
|
||||
container.withExposedPorts(8080);
|
||||
@ -375,6 +376,30 @@ class PaketoBuilderTests {
|
||||
}
|
||||
}
|
||||
|
||||
private BuildResult buildImageWithRetry(String imageName, String... arguments) {
|
||||
long start = System.nanoTime();
|
||||
while (true) {
|
||||
try {
|
||||
return buildImage(imageName, arguments);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (Duration.ofNanos(System.nanoTime() - start).toMinutes() > 6) {
|
||||
throw ex;
|
||||
}
|
||||
sleep(500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sleep(long time) {
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
}
|
||||
catch (InterruptedException ex) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
private BuildResult buildImage(String imageName, String... arguments) {
|
||||
String[] buildImageArgs = { "bootBuildImage", "--imageName=" + imageName, "--pullPolicy=IF_NOT_PRESENT" };
|
||||
String[] args = StringUtils.concatenateStringArrays(arguments, buildImageArgs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user