Test fedora minimal embedded container

This commit is contained in:
Mario Cattamo 2023-04-26 18:51:19 +02:00 committed by Achilleas Koutsou
parent 70949fddf0
commit 54ce49a852
3 changed files with 65 additions and 0 deletions

View file

@ -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

View file

@ -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

View file

@ -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