|
|
|
@ -20,6 +20,7 @@ import java.io.File; |
|
|
|
import java.io.FileWriter; |
|
|
|
import java.io.FileWriter; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
import java.io.PrintWriter; |
|
|
|
import java.io.PrintWriter; |
|
|
|
|
|
|
|
import java.time.Duration; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
@ -262,7 +263,7 @@ class PaketoBuilderTests { |
|
|
|
writeServletInitializerClass(); |
|
|
|
writeServletInitializerClass(); |
|
|
|
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName(); |
|
|
|
String imageName = "paketo-integration/" + this.gradleBuild.getProjectDir().getName(); |
|
|
|
ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); |
|
|
|
ImageReference imageReference = ImageReference.of(ImageName.of(imageName)); |
|
|
|
BuildResult result = buildImage(imageName); |
|
|
|
BuildResult result = buildImageWithRetry(imageName); |
|
|
|
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
|
|
|
assertThat(result.task(":bootBuildImage").getOutcome()).isEqualTo(TaskOutcome.SUCCESS); |
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName)) { |
|
|
|
try (GenericContainer<?> container = new GenericContainer<>(imageName)) { |
|
|
|
container.withExposedPorts(8080); |
|
|
|
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) { |
|
|
|
private BuildResult buildImage(String imageName, String... arguments) { |
|
|
|
String[] buildImageArgs = { "bootBuildImage", "--imageName=" + imageName, "--pullPolicy=IF_NOT_PRESENT" }; |
|
|
|
String[] buildImageArgs = { "bootBuildImage", "--imageName=" + imageName, "--pullPolicy=IF_NOT_PRESENT" }; |
|
|
|
String[] args = StringUtils.concatenateStringArrays(arguments, buildImageArgs); |
|
|
|
String[] args = StringUtils.concatenateStringArrays(arguments, buildImageArgs); |
|
|
|
|