Skip to content

Commit

Permalink
test: build rhel bootc image with bib
Browse files Browse the repository at this point in the history
Signed-off-by: Xiaofeng Wang <[email protected]>
  • Loading branch information
henrywang committed Apr 10, 2024
1 parent 0e58fee commit 37ecd39
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
26 changes: 17 additions & 9 deletions bib-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ INVENTORY_FILE="${TEMPDIR}/inventory"
REPLACE_CLOUD_USER=""

greenprint "Login quay.io"
podman login -u "${QUAY_USERNAME}" -p "${QUAY_PASSWORD}" quay.io
sudo podman login -u "${QUAY_USERNAME}" -p "${QUAY_PASSWORD}" quay.io

case "$TEST_OS" in
"rhel-9-4")
Expand Down Expand Up @@ -87,7 +87,8 @@ VERSION_ID=$(skopeo inspect --tls-verify=false "docker://${TIER1_IMAGE_URL}" | j
TEST_IMAGE_NAME="${IMAGE_NAME}-test"
# bootc-image-builder does not support private image repo,
# use temporary public image repo as workaround
TEST_IMAGE_URL="quay.io/rhel-edge/${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}"
TEST_IMAGE_URL="quay.io/redhat_emp1/${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}"
LOCAL_IMAGE_URL="localhost/${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}"

greenprint "Configure container build arch"
case "$ARCH" in
Expand Down Expand Up @@ -124,10 +125,10 @@ greenprint "Check $TEST_OS installation Containerfile"
cat "$INSTALL_CONTAINERFILE"

greenprint "Build $TEST_OS installation container image"
podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR"
sudo podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$LAYERED_DIR"

greenprint "Push $TEST_OS installation container image"
podman push --tls-verify=false --quiet "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL"
sudo podman push --tls-verify=false --quiet "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL"

greenprint "Prepare inventory file"
tee -a "$INVENTORY_FILE" > /dev/null << EOF
Expand Down Expand Up @@ -163,6 +164,7 @@ case "$IMAGE_TYPE" in
--pull=newer \
--tls-verify=false \
--security-opt label=type:unconfined_t \
-v /var/lib/containers/storage:/var/lib/containers/storage \
--env AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" \
--env AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" \
quay.io/centos-bootc/bootc-image-builder:latest \
Expand All @@ -171,7 +173,8 @@ case "$IMAGE_TYPE" in
--aws-ami-name "$AMI_NAME" \
--aws-bucket "$AWS_BUCKET_NAME" \
--aws-region "$AWS_REGION" \
"$TEST_IMAGE_URL"
--local \
"$LOCAL_IMAGE_URL"

greenprint "Get uploaded AMI ID and snapshot ID"
AMI_ID=$(
Expand Down Expand Up @@ -200,10 +203,12 @@ case "$IMAGE_TYPE" in
--tls-verify=false \
--security-opt label=type:unconfined_t \
-v "$(pwd)/output":/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type qcow2 \
--target-arch "$ARCH" \
"$TEST_IMAGE_URL"
--local \
"$LOCAL_IMAGE_URL"

sudo mv output/qcow2/disk.qcow2 /var/lib/libvirt/images && sudo rm -rf output

Expand All @@ -228,10 +233,12 @@ case "$IMAGE_TYPE" in
--tls-verify=false \
--security-opt label=type:unconfined_t \
-v "$(pwd)/output":/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type vmdk \
--target-arch "$ARCH" \
"$TEST_IMAGE_URL"
--local \
"$LOCAL_IMAGE_URL"

greenprint "Deploy $IMAGE_TYPE instance"
DATACENTER_70="Datacenter7.0"
Expand Down Expand Up @@ -364,13 +371,14 @@ RUN dnf -y install wget && \
EOF

greenprint "Build $TEST_OS upgrade container image"
podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" -f "$UPGRADE_CONTAINERFILE" .
sudo podman build --platform "$BUILD_PLATFORM" --tls-verify=false --retry=5 --retry-delay=10 -t "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" -f "$UPGRADE_CONTAINERFILE" .
greenprint "Push $TEST_OS upgrade container image"
podman push --tls-verify=false --quiet "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL"
sudo podman push --tls-verify=false --quiet "${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}" "$TEST_IMAGE_URL"

greenprint "Upgrade $TEST_OS system"
ansible-playbook -v \
-i "$INVENTORY_FILE" \
-e bootc_image="$TEST_IMAGE_URL" \
playbooks/upgrade.yaml

greenprint "Run ostree checking test after upgrade on $PLATFORM instance"
Expand Down
1 change: 1 addition & 0 deletions playbooks/check-system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
when: "'localhost' not in installed_image"

# case: check ostree-remount service status
- name: check ostree-remount service status
Expand Down
6 changes: 6 additions & 0 deletions playbooks/rollback.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
register: result_rollback_image_digest
become: true

- name: determine installed image from localhost or quay.io
shell: bootc status --json | jq -r '.status.booted.image.image.image'
become: true
register: result_bootc_status

- name: check booted cachedUpdate and rollback image digest
block:
- assert:
Expand All @@ -50,6 +55,7 @@
failed_counter: "{{ failed_counter | int + 1 }}"
when:
- air_gapped_dir | default('') == ""
- "'localhost' not in result_bootc_status.stdout"

- name: check installed package
shell: rpm -qa | sort
Expand Down
17 changes: 17 additions & 0 deletions playbooks/upgrade.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- hosts: guest
become: false
vars:
bootc_image: ""

tasks:
- name: Air-gapped upgrade
Expand All @@ -23,11 +25,22 @@
when:
- air_gapped_dir | default('') != ""

- name: determine installed image from localhost or quay.io
shell: bootc status --json | jq -r '.status.booted.image.image.image'
become: true
register: result_bootc_status

- name: switch to quay.io for upgrade
command: bootc switch {{ bootc_image }}
become: true
when: "'localhost' in result_bootc_status.stdout"

- name: bootc upgrade
command: bootc upgrade
become: true
when:
- air_gapped_dir | default('') == ""
- "'localhost' not in result_bootc_status.stdout"

# 10 minutes reboot timeout is for bare metal test
- name: Reboot to deploy new system
Expand All @@ -40,3 +53,7 @@
- name: Wait for connection to become reachable/usable
wait_for_connection:
delay: 30

- name: bootc booted status
command: bootc status --booted
become: true

0 comments on commit 37ecd39

Please sign in to comment.