From 3b12a5efe959f142ee44413367b36d59e097a59c Mon Sep 17 00:00:00 2001 From: Scott Frederick Date: Mon, 29 Nov 2021 12:24:04 -0600 Subject: [PATCH] Update system tests for Paketo Java buildpack 6.0.0 Paketo Java buildpack version 6.0.0 adds a buildpack and removes support for the SBOM in the format that the system tests attempt to verify. Fixes gh-28823 --- .../assertions/ContainerConfigAssert.java | 12 --------- .../boot/image/paketo/PaketoBuilderTests.java | 26 ++++++------------- 2 files changed, 8 insertions(+), 30 deletions(-) diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/assertions/ContainerConfigAssert.java b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/assertions/ContainerConfigAssert.java index 1ddbd73598..d8297ac471 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/assertions/ContainerConfigAssert.java +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/assertions/ContainerConfigAssert.java @@ -24,9 +24,7 @@ import org.assertj.core.api.AbstractAssert; import org.assertj.core.api.AbstractListAssert; import org.assertj.core.api.AbstractObjectAssert; import org.assertj.core.api.AbstractStringAssert; -import org.assertj.core.api.Assertions; import org.assertj.core.api.AssertionsForClassTypes; -import org.assertj.core.api.InstanceOfAssertFactories; import org.assertj.core.api.ListAssert; import org.assertj.core.api.ObjectAssert; @@ -91,16 +89,6 @@ public class ContainerConfigAssert extends AbstractAssert bomDependencies() { - return this.actual - .extractingJsonPathArrayValue("$.bom[?(@.name=='dependencies')].metadata.dependencies[*].name"); - } - - public AbstractStringAssert bomJavaVersion(String javaType) { - return this.actual.extractingJsonPathArrayValue("$.bom[?(@.name=='%s')].metadata.version", javaType) - .singleElement(Assertions.as(InstanceOfAssertFactories.STRING)); - } - public AbstractObjectAssert processOfType(String type) { return this.actual.extractingJsonPathArrayValue("$.processes[?(@.type=='%s')]", type).singleElement(); } diff --git a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java index ffe9eca8fb..98f4dbf8c0 100644 --- a/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java +++ b/spring-boot-system-tests/spring-boot-image-tests/src/systemTest/java/org/springframework/boot/image/paketo/PaketoBuilderTests.java @@ -21,6 +21,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.function.Consumer; @@ -79,13 +80,9 @@ class PaketoBuilderTests { container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); assertLabelsMatchManifestAttributes(config); - ImageAssertions.assertThat(config).buildMetadata().buildpacks().containsExactly( + ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains( "paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot"); - ImageAssertions.assertThat(config).buildMetadata().bomDependencies().contains("spring-beans", "spring-boot", - "spring-boot-autoconfigure", "spring-boot-jarmode-layertools", "spring-context", "spring-core", - "spring-web"); - ImageAssertions.assertThat(config).buildMetadata().bomJavaVersion("jre").startsWith(javaMajorVersion()); ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args") .containsExactly("java", Collections.singletonList("org.springframework.boot.loader.JarLauncher")); ImageAssertions.assertThat(config).buildMetadata().processOfType("executable-jar") @@ -146,10 +143,9 @@ class PaketoBuilderTests { try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); - ImageAssertions.assertThat(config).buildMetadata().buildpacks().containsExactly( + ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains( "paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot"); - ImageAssertions.assertThat(config).buildMetadata().bomJavaVersion("jre").startsWith(javaMajorVersion()); ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args") .containsExactly("/workspace/" + projectName + "-boot/bin/" + projectName, Collections.emptyList()); ImageAssertions.assertThat(config).buildMetadata().processOfType("dist-zip").extracting("command", "args") @@ -175,10 +171,9 @@ class PaketoBuilderTests { try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); - ImageAssertions.assertThat(config).buildMetadata().buildpacks().containsExactly( + ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains( "paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot"); - ImageAssertions.assertThat(config).buildMetadata().bomJavaVersion("jre").startsWith(javaMajorVersion()); ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args") .containsExactly("/workspace/" + projectName + "/bin/" + projectName, Collections.emptyList()); ImageAssertions.assertThat(config).buildMetadata().processOfType("dist-zip").extracting("command", "args") @@ -208,13 +203,9 @@ class PaketoBuilderTests { container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); assertLabelsMatchManifestAttributes(config); - ImageAssertions.assertThat(config).buildMetadata().buildpacks().containsExactly( + ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains( "paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/executable-jar", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot"); - ImageAssertions.assertThat(config).buildMetadata().bomDependencies().contains("spring-beans", "spring-boot", - "spring-boot-autoconfigure", "spring-boot-jarmode-layertools", "spring-context", "spring-core", - "spring-web"); - ImageAssertions.assertThat(config).buildMetadata().bomJavaVersion("jre").startsWith(javaMajorVersion()); ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args") .containsExactly("java", Collections.singletonList("org.springframework.boot.loader.WarLauncher")); ImageAssertions.assertThat(config).buildMetadata().processOfType("executable-jar") @@ -238,14 +229,13 @@ class PaketoBuilderTests { try (GenericContainer container = new GenericContainer<>(imageName).withExposedPorts(8080)) { container.waitingFor(Wait.forHttp("/test")).start(); ContainerConfig config = container.getContainerInfo().getConfig(); - ImageAssertions.assertThat(config).buildMetadata().buildpacks().containsExactly( + ImageAssertions.assertThat(config).buildMetadata().buildpacks().contains( "paketo-buildpacks/ca-certificates", "paketo-buildpacks/bellsoft-liberica", "paketo-buildpacks/apache-tomcat", "paketo-buildpacks/dist-zip", "paketo-buildpacks/spring-boot"); - ImageAssertions.assertThat(config).buildMetadata().bomJavaVersion("jre").startsWith(javaMajorVersion()); ImageAssertions.assertThat(config).buildMetadata().processOfType("web").extracting("command", "args") - .containsExactly("catalina.sh", Collections.singletonList("run")); + .containsExactly("bash", Arrays.asList("catalina.sh", "run")); ImageAssertions.assertThat(config).buildMetadata().processOfType("tomcat").extracting("command", "args") - .containsExactly("catalina.sh", Collections.singletonList("run")); + .containsExactly("bash", Arrays.asList("catalina.sh", "run")); DigestCapturingCondition digests = new DigestCapturingCondition(); ImageAssertions.assertThat(config).lifecycleMetadata().appLayerShas().haveExactly(1, digests); ImageAssertions.assertThat(imageReference).hasLayer(digests.getDigest(0)).entries()