From 54ce49a8524a81939f5d8e3df8a43519534e5199 Mon Sep 17 00:00:00 2001 From: Mario Cattamo Date: Wed, 26 Apr 2023 18:51:19 +0200 Subject: [PATCH] Test fedora minimal embedded container --- test/cases/ostree-ng.sh | 10 +++++++ test/cases/ostree.sh | 10 +++++++ test/data/ansible/check_ostree.yaml | 45 +++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/test/cases/ostree-ng.sh b/test/cases/ostree-ng.sh index edcf687cb..fe0475dad 100755 --- a/test/cases/ostree-ng.sh +++ b/test/cases/ostree-ng.sh @@ -85,6 +85,8 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml QUAY_CONFIG=${TEMPDIR}/quay_config.toml COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json +FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b" +FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1" # SSH setup. SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5) @@ -406,6 +408,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then tee -a "$BLUEPRINT_FILE" > /dev/null << EOF [[containers]] source = "quay.io/fedora/fedora:latest" + +[[containers]] +source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}" +name = "${FEDORA_LOCAL_NAME}" EOF fi @@ -763,6 +769,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then tee -a "$BLUEPRINT_FILE" > /dev/null << EOF [[containers]] source = "quay.io/fedora/fedora:latest" + +[[containers]] +source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}" +name = "${FEDORA_LOCAL_NAME}" EOF fi diff --git a/test/cases/ostree.sh b/test/cases/ostree.sh index cdb01f772..5661e7220 100755 --- a/test/cases/ostree.sh +++ b/test/cases/ostree.sh @@ -188,6 +188,8 @@ BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml KS_FILE=${TEMPDIR}/ks.cfg COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json +FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b" +FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1" # SSH setup. SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5) @@ -362,6 +364,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then tee -a "$BLUEPRINT_FILE" > /dev/null << EOF [[containers]] source = "quay.io/fedora/fedora:latest" + +[[containers]] +source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}" +name = "${FEDORA_LOCAL_NAME}" EOF fi @@ -597,6 +603,10 @@ if [[ "${EMBEDED_CONTAINER}" == "true" ]]; then tee -a "$BLUEPRINT_FILE" > /dev/null << EOF [[containers]] source = "quay.io/fedora/fedora:latest" + +[[containers]] +source = "registry.gitlab.com/redhat/services/products/image-builder/ci/osbuild-composer/fedora-minimal@${FEDORA_IMAGE_DIGEST}" +name = "${FEDORA_LOCAL_NAME}" EOF fi diff --git a/test/data/ansible/check_ostree.yaml b/test/data/ansible/check_ostree.yaml index 0dbae3b48..b451f5f2a 100644 --- a/test/data/ansible/check_ostree.yaml +++ b/test/data/ansible/check_ostree.yaml @@ -485,6 +485,22 @@ failed_counter: "{{ failed_counter | int + 1 }}" when: embeded_container == "true" + - name: embedded fedora-minimal container image should be listed by podman images + block: + - assert: + that: + - "'localhost/fedora-minimal' in result_podman_images.stdout" + fail_msg: "fedora-minimal image is not built in image" + success_msg: "fedora-minimal image is built in image" + always: + - set_fact: + total_counter: "{{ total_counter | int + 1 }}" + rescue: + - name: failed count + 1 + set_fact: + failed_counter: "{{ failed_counter | int + 1 }}" + when: embeded_container == "true" + # case: check running container with podman - name: run ubi8 image command: podman run registry.access.redhat.com/ubi8/ubi-minimal:latest cat /etc/redhat-release @@ -536,6 +552,35 @@ set_fact: failed_counter: "{{ failed_counter | int + 1 }}" + # case: check fedora-minimal container with podman + - name: run fedora-minimal image + command: podman run localhost/fedora-minimal@sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b cat /etc/os-release + register: fminimal_container_result + become: yes + retries: 30 # due to https://github.com/osbuild/osbuild-composer/issues/2492 + delay: 2 + until: fminimal_container_result is success + ignore_errors: yes # due to https://bugzilla.redhat.com/show_bug.cgi?id=1903983 + when: embeded_container == "true" + + - name: run fedora-minimal container test + block: + - assert: + that: + - fminimal_container_result is succeeded + - "'Fedora Linux 36 (Container Image)' in fminimal_container_result.stdout" + - "'Trying to pull' not in fminimal_container_result.stdout" + fail_msg: "failed run fedora-minimal container with podman" + success_msg: "running fedora-minimal container with podman successed" + always: + - set_fact: + total_counter: "{{ total_counter | int + 1 }}" + rescue: + - name: failed count + 1 + set_fact: + failed_counter: "{{ failed_counter | int + 1 }}" + when: embeded_container == "true" + # case: check dnf package and it should not be installed # https://github.com/osbuild/osbuild-composer/blob/master/internal/distro/rhel8/distro.go#L642 - name: dnf should not be installed