diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl index 5abc85d5a4..4e0e42015d 100644 --- a/.terraform.lock.hcl +++ b/.terraform.lock.hcl @@ -42,14 +42,14 @@ provider "registry.terraform.io/chainguard-dev/cosign" { } provider "registry.terraform.io/chainguard-dev/imagetest" { - version = "0.0.14" + version = "0.0.15" hashes = [ - "h1:s0YOuywxEcQTtLYESjG3CuFV/KiZzaLVLNQgKF4IS2E=", - "zh:3b312b9d6c8e62720cd10f543998dfa99c14b4b6d0b023f861b9eb1fc215d8ce", - "zh:45f128b50dd763f14440a3283ff099a11ee3a98febfa48a202055fe6f9b94010", + "h1:l14VgkvJfRLbbE7CEOnNoy88i2g+pkYUa8nkeJOujYU=", + "zh:6c0f636a35d39b38a9a3043cb79c98a1b6500624ec6acc266368b6b46e13e511", + "zh:76d75433235e6a84d65df7476386b766efd67ae74a7dea487c14365859c68d99", "zh:890df766e9b839623b1f0437355032a3c006226a6c200cd911e15ee1a9014e9f", - "zh:c194b8456c3842ef8430b433ce9c3b1c4c9bcfdd8783f87dde8062fc043d1182", - "zh:e8bd48f901103cf96da6504c04dc6baf82e4dbd988baeed95b4cd4ac8a32f15f", + "zh:b6f3106de4a364e2c11efb306b873cd06bdc640aea5a2b7c70dc6f1a118c35fd", + "zh:ea4d40dc366edc60c21886d71350dab1d64c72cdff3c8686a09eebd08984d958", ] } diff --git a/images/jre/tests/02-hello-world.sh b/images/jre/tests/02-hello-world.sh deleted file mode 100755 index 8a57349299..0000000000 --- a/images/jre/tests/02-hello-world.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset -o errtrace -o pipefail - -SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) -TMP=$(mktemp -d) -JAVA_SOURCE_VERSION="${JAVA_SOURCE_VERSION:-8}" -JAVA_TARGET_VERSION="${JAVA_TARGET_VERSION:-8}" - -function cleanup() { - rm -rf "${TMP}" -} -trap cleanup EXIT - -cp "${SCRIPT_DIR}"/*.java "${TMP}" - -# Make this writeable by the nonroot container user -chmod 777 "${TMP}" - -docker run --rm -v "${TMP}:/tmp" \ - `# Build using the latest JDK image` \ - --entrypoint "javac" "${SDK_IMAGE}" \ - `# Targeting Java 8 so that all our JREs can run the produced .class file` \ - -source ${JAVA_SOURCE_VERSION} -target ${JAVA_TARGET_VERSION} \ - /tmp/HelloWorld.java -d /tmp - -# Now we have the .class file, run it to test our JRE. -docker run --rm -v "${TMP}:/tmp" --entrypoint "java" "${IMAGE_NAME}" -cp /tmp HelloWorld diff --git a/images/jre/tests/main.tf b/images/jre/tests/main.tf index 3ee1f1e16a..1a8a78e88c 100644 --- a/images/jre/tests/main.tf +++ b/images/jre/tests/main.tf @@ -1,6 +1,7 @@ terraform { required_providers { - oci = { source = "chainguard-dev/oci" } + oci = { source = "chainguard-dev/oci" } + imagetest = { source = "chainguard-dev/imagetest" } } } @@ -25,24 +26,76 @@ variable "sdk-image" { default = "cgr.dev/chainguard/jdk" } -data "oci_exec_test" "version" { - digest = var.digest - script = "docker run --rm --entrypoint /usr/bin/java $IMAGE_NAME -version" +data "imagetest_inventory" "this" {} + +resource "imagetest_container_volume" "volume" { + name = "scratch-volume" + inventory = data.imagetest_inventory.this } -data "oci_exec_test" "hello-world" { - digest = var.digest - script = "${path.module}/02-hello-world.sh" - env { - name = "SDK_IMAGE" - value = var.sdk-image - } - env { - name = "JAVA_SOURCE_VERSION" - value = var.java-source-version - } - env { - name = "JAVA_TARGET_VERSION" - value = var.java-target-version +resource "imagetest_harness_docker" "this" { + name = "jre" + inventory = data.imagetest_inventory.this + + volumes = [ + { + source = imagetest_container_volume.volume + destination = "/data" + } + ] + + mounts = [ + { + source = path.module + destination = "/tests" + } + ] + + envs = { + "SDK_IMAGE" : var.sdk-image + "IMAGE_NAME" : var.digest + "JAVA_SOURCE_VERSION" : var.java-source-version + "JAVA_TARGET_VERSION" : var.java-target-version + "VOLUME_NAME" : imagetest_container_volume.volume.id } } + +resource "imagetest_feature" "basic" { + name = "basic test" + harness = imagetest_harness_docker.this + + steps = [ + { + name = "Version check" + cmd = <