diff --git a/test/cases/ostree-ami-image.sh b/test/cases/ostree-ami-image.sh
index 5c9df5632f..5379e1c81a 100755
--- a/test/cases/ostree-ami-image.sh
+++ b/test/cases/ostree-ami-image.sh
@@ -4,58 +4,14 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -77,8 +33,8 @@ OBJECT_URL="http://${BUCKET_NAME}.s3.${AWS_DEFAULT_REGION}.amazonaws.com"
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# SSH setup.
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -110,146 +66,6 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli compose start-ostree \
- --json \
- --ref "$OSTREE_REF" \
- --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli compose start-ostree \
- --json \
- --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli compose info \
- --json \
- "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-
- # Deregister edge AMI image
- aws ec2 deregister-image \
- --image-id "${AMI_ID}"
-
- # Remove snapshot
- aws ec2 delete-snapshot \
- --snapshot-id "${SNAPSHOT_ID}"
-
- # Delete Key Pair
- aws ec2 delete-key-pair \
- --key-name "${AMI_KEY_NAME}"
-
- # Terminate running instance
- if [[ -v INSTANCE_ID ]]; then
- aws ec2 terminate-instances \
- --instance-ids "${INSTANCE_ID}"
- aws ec2 wait instance-terminated \
- --instance-ids "${INSTANCE_ID}"
- fi
-
- # Remove bucket content and bucket itself quietly
- aws s3 rb "${BUCKET_URL}" --force > /dev/null
-}
-
# Test result checking
check_result () {
greenprint "๐ Checking for test result"
@@ -258,6 +74,7 @@ check_result () {
else
redprint "โ Failed"
clean_up
+ aws_clean_up
exit 1
fi
}
@@ -427,7 +244,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -624,7 +441,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve ami
# Build ami.
-build_image ami "${AMI_IMAGE_TYPE}" "${PROD_REPO_URL}"
+build_image -b ami -t "${AMI_IMAGE_TYPE}" -u "${PROD_REPO_URL}"
# Download the image
greenprint "๐ฅ Downloading the ami image"
@@ -939,7 +756,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
@@ -1067,5 +884,6 @@ check_result
# Final success clean up
clean_up
+aws_clean_up
exit 0
diff --git a/test/cases/ostree-common-functions.sh b/test/cases/ostree-common-functions.sh
new file mode 100644
index 0000000000..c7e0855d1c
--- /dev/null
+++ b/test/cases/ostree-common-functions.sh
@@ -0,0 +1,272 @@
+#!/bin/bash
+# A script that's full of common functions
+# used throughout our ostree tests. Can be
+# sourced at beginning of those scripts.
+
+function common_init() {
+ trap cleanup_on_exit EXIT
+ # Start libvirtd and test it.
+ greenprint "๐ Starting libvirt daemon"
+ sudo systemctl start libvirtd
+ sudo virsh list --all > /dev/null
+
+ # Install and start firewalld
+ greenprint "๐ง Install and start firewalld"
+ sudo dnf install -y firewalld
+ sudo systemctl enable --now firewalld
+ # vsphere specific step
+ command -v govc && { sudo firewall-cmd --permanent --zone=public --add-service=http; sudo firewall-cmd --reload; }
+
+ # Set a customized dnsmasq configuration for libvirt so we always get the
+ # same address on bootup.
+ sudo tee /tmp/integration.xml > /dev/null << EOF
+
+integration
+1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+EOF
+ # Simplified installer needs a different dnsmasq.
+ [ -d /etc/fdo/aio ] && sudo sed -i "s///g" /tmp/integration.xml
+
+ if ! sudo virsh net-info integration > /dev/null 2>&1; then
+ sudo virsh net-define /tmp/integration.xml
+ sudo virsh net-start integration
+ fi
+
+ # Allow anyone in the wheel group to talk to libvirt.
+ greenprint "๐ช Allowing users in wheel group to talk to libvirt"
+ WHEEL_GROUP=wheel
+ if [[ $ID == rhel ]]; then
+ WHEEL_GROUP=adm
+ fi
+ sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
+polkit.addRule(function(action, subject) {
+ if (action.id == "org.libvirt.unix.manage" &&
+ subject.isInGroup("${WHEEL_GROUP}")) {
+ return polkit.Result.YES;
+ }
+});
+EOF
+}
+
+function get_compose_log() {
+ COMPOSE_ID=$1
+ LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
+
+ # Download the logs.
+ sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
+}
+
+function get_compose_metadata() {
+ COMPOSE_ID=$1
+ METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
+
+ # Download the metadata.
+ sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
+
+ # Find the tarball and extract it.
+ TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
+ sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
+ sudo rm -f "$TARBALL"
+
+ # Move the JSON file into place.
+ sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
+}
+
+function clean_up() {
+ set +u
+ greenprint "๐งผ Cleaning up"
+
+ # Clear integration network
+ sudo virsh net-destroy integration
+ sudo virsh net-undefine integration
+
+ # Remove tag from quay.io repo
+ [ -n "$QUAY_REPO_URL" ] && skopeo delete --creds "${V2_QUAY_USERNAME}:${V2_QUAY_PASSWORD}" "docker://${QUAY_REPO_URL}:${QUAY_REPO_TAG}"
+
+ { virsh list --all | grep "${IMAGE_KEY}"; } && {
+ sudo virsh destroy "${IMAGE_KEY}";
+ sudo virsh destroy "${IMAGE_KEY}-uefi";
+ sudo virsh undefine "${IMAGE_KEY}" --nvram
+ sudo virsh undefine "${IMAGE_KEY}-uefi" --nvram
+ }
+
+ # Remove any status containers if exist
+ sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
+ # Remove all images
+ sudo podman rmi -f -a
+
+ # Remove a bunch of directories
+ [ -d "$LIBVIRT_IMAGE_PATH" ] && sudo rm -f "$LIBVIRT_IMAGE_PATH"
+ [ -d "$PROD_REPO" ] && sudo rm -rf "$PROD_REPO"
+ [ -d "$PROD_REPO_1" ] && sudo rm -rf "$PROD_REPO_1"
+ [ -d "$PROD_REPO_2" ] && sudo rm -rf "$PROD_REPO_2"
+ [ -d "$IGNITION_SERVER_FOLDER" ] && sudo rm -rf "$IGNITION_SERVER_FOLDER"
+
+ # Remove "remote" repo.
+ [ -d "$HTTPD_PATH" ] && sudo rm -rf "${HTTPD_PATH}"/{repo,compose.json}
+
+ # Remomve tmp dir.
+ [ -d "$TEMPDIR" ] && sudo rm -rf "$TEMPDIR"
+
+ # Stop prod repo http service
+ sudo systemctl disable --now httpd
+
+ # vsphere specific cleanup
+ [ -n "$DATACENTER_70" ] && govc vm.destroy -dc="${DATACENTER_70}" "${DC70_VSPHERE_VM_NAME}"
+ set -u
+}
+
+function aws_clean_up() {
+ greenprint "๐งผ AWS specific cleaning up"
+ # Deregister edge AMI image
+ aws ec2 deregister-image \
+ --image-id "${AMI_ID}"
+
+ # Remove snapshot
+ aws ec2 delete-snapshot \
+ --snapshot-id "${SNAPSHOT_ID}"
+
+ # Delete Key Pair
+ aws ec2 delete-key-pair \
+ --key-name "${AMI_KEY_NAME}"
+
+ # Terminate running instance
+ if [[ -v INSTANCE_ID ]]; then
+ aws ec2 terminate-instances \
+ --instance-ids "${INSTANCE_ID}"
+ aws ec2 wait instance-terminated \
+ --instance-ids "${INSTANCE_ID}"
+ fi
+
+ # Remove bucket content and bucket itself quietly
+ aws s3 rb "${BUCKET_URL}" --force > /dev/null
+}
+
+function check_result() {
+ greenprint "๐ Checking for test result"
+ if [[ $RESULTS == 1 ]]; then
+ greenprint "๐ Success"
+ else
+ redprint "โ Failed"
+ clean_up
+ exit 1
+ fi
+}
+
+function wait_for_ssh_up() {
+ # Ignition user name is 'core'.
+ [ -f "$TEMPDIR/config.ign" ] && SSH_USER="core" || SSH_USER="admin"
+ SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" "${SSH_USER}"@"${1}" '/bin/bash -c "echo -n READY"')
+ if [[ $SSH_STATUS == READY ]]; then
+ echo 1
+ else
+ echo 0
+ fi
+}
+
+function build_image() {
+ cmd=("--json" "compose" "start-ostree" "--ref" "$OSTREE_REF")
+ local blue_print="" image_type="" key="" registry_config=""
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -b|--blue-print)
+ blue_print=$2
+ shift 2
+ ;;
+ -t|--image-type)
+ image_type=$2
+ shift 2
+ ;;
+ -u|--url)
+ cmd+=("--url" "$2")
+ shift 2
+ ;;
+ -c|--registry-config)
+ registry_config=$2
+ shift 2
+ ;;
+ -k|--image-key)
+ key=$2
+ shift 2
+ ;;
+ -p|--parent)
+ cmd+=("--parent" "$2")
+ shift 2
+ ;;
+ *)
+ redprint "Unknown argument: $1"
+ return 1
+ ;;
+ esac
+ done
+
+ # Get worker unit file so we can watch the journal.
+ WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
+ sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
+ WORKER_JOURNAL_PID=$!
+
+ # Start the compose.
+ greenprint "๐ Starting compose"
+ [ -n "$blue_print" ] && cmd+=("$blue_print")
+ [ -n "$image_type" ] && cmd+=("$image_type")
+ [ -n "$key" ] && cmd+=("$key")
+ [ -n "$registry_config" ] && cmd+=("$registry_config")
+ echo -e "The composer-cli command is\nsudo composer-cli ${cmd[*]} | tee $COMPOSE_START"
+ sudo composer-cli "${cmd[@]}" | tee "$COMPOSE_START"
+ COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
+
+ # Wait for the compose to finish.
+ greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
+ while true; do
+ sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
+ COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
+
+ # Is the compose finished?
+ if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
+ break
+ fi
+
+ # Wait 30 seconds and try again.
+ sleep 5
+ done
+
+ # Capture the compose logs from osbuild.
+ greenprint "๐ฌ Getting compose log and metadata"
+ get_compose_log "$COMPOSE_ID"
+ get_compose_metadata "$COMPOSE_ID"
+
+ # Kill the journal monitor
+ sudo pkill -P ${WORKER_JOURNAL_PID}
+
+ # Did the compose finish with success?
+ if [[ $COMPOSE_STATUS != FINISHED ]]; then
+ redprint "Something went wrong with the compose. ๐ข"
+ exit 1
+ fi
+}
+
+function cleanup_on_exit() {
+ greenprint "== Script execution stopped or finished - Cleaning up =="
+ # kill dangling journalctl processes to prevent GitLab CI from hanging
+ sudo pkill journalctl || echo "Nothing killed"
+}
\ No newline at end of file
diff --git a/test/cases/ostree-ignition.sh b/test/cases/ostree-ignition.sh
index 7af59f2a9c..05dcc5c113 100755
--- a/test/cases/ostree-ignition.sh
+++ b/test/cases/ostree-ignition.sh
@@ -4,69 +4,14 @@ set -euox pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("adm")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -95,8 +40,8 @@ BOOT_ARGS="uefi"
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# Setup log artifacts folder
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
@@ -130,131 +75,6 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-installer-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-installer-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
-
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
-
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" "${IGNITION_USER}@${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO_1"
- sudo rm -rf "$PROD_REPO_2"
- sudo rm -rf "$IGNITION_SERVER_FOLDER"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -319,7 +139,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -484,7 +304,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve installer
# Build installer image.
-build_image installer "${INSTALLER_TYPE}" "${PROD_REPO_1_URL}"
+build_image -b installer -t "${INSTALLER_TYPE}" -u "${PROD_REPO_1_URL}"
# Download the image
greenprint "๐ฅ Downloading the installer image"
@@ -632,7 +452,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_1_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_1_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
@@ -770,7 +590,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve installer
# Build installer image.
-build_image installer "${INSTALLER_TYPE}" "${PROD_REPO_2_URL}"
+build_image -b installer -t "${INSTALLER_TYPE}" -u "${PROD_REPO_2_URL}"
# Download the image
greenprint "๐ฅ Downloading the installer image"
@@ -908,7 +728,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve raw
# Build raw image.
-build_image raw "$RAW_TYPE" "${PROD_REPO_2_URL}"
+build_image -b raw -t "$RAW_TYPE" -u "${PROD_REPO_2_URL}"
# Download raw image
greenprint "๐ฅ Downloading the raw image"
diff --git a/test/cases/ostree-iot-qcow2.sh b/test/cases/ostree-iot-qcow2.sh
index bd6bbf3e29..efc290518c 100755
--- a/test/cases/ostree-iot-qcow2.sh
+++ b/test/cases/ostree-iot-qcow2.sh
@@ -4,68 +4,14 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("adm")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -85,8 +31,8 @@ EDGE_USER_PASSWORD=foobar
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# SSH setup.
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -107,139 +53,6 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- elif [ $# -eq 4 ]; then
- repo_url=$3
- parent_ref=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --parent "$parent_ref" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- echo "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear vm
- if [[ $(sudo virsh domstate "${IMAGE_KEY}-uefi") == "running" ]]; then
- sudo virsh destroy "${IMAGE_KEY}-uefi"
- fi
- sudo virsh undefine "${IMAGE_KEY}-uefi" --nvram
- # Remove qcow2 file.
- sudo rm -f "$LIBVIRT_IMAGE_PATH"
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- greenprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -296,7 +109,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -398,7 +211,7 @@ sudo composer-cli blueprints depsolve iot-qcow2
# Build raw image.
# Test --url arg following by URL with tailling slash for bz#1942029
-build_image iot-qcow2 "${IOT_QCOW2_IMAGE_TYPE}" "${PROD_REPO_URL}/"
+build_image -b iot-qcow2 -t "${IOT_QCOW2_IMAGE_TYPE}" -u "${PROD_REPO_URL}/"
# Download the image
greenprint "๐ฅ Downloading the iot-qcow2-image"
@@ -559,7 +372,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
diff --git a/test/cases/ostree-ng.sh b/test/cases/ostree-ng.sh
index 30e86aefb6..a77e6e4590 100755
--- a/test/cases/ostree-ng.sh
+++ b/test/cases/ostree-ng.sh
@@ -4,6 +4,7 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
@@ -14,55 +15,7 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
greenprint "๐ง Installing oenshift client(oc)"
curl https://osbuild-storage.s3.amazonaws.com/oc-4.9.0-linux.tar.gz | sudo tar -xz -C /usr/local/bin/
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("adm")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -89,8 +42,8 @@ BOOT_ARGS="uefi"
TEMPDIR=$(mktemp -d)
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
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b"
FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1"
@@ -157,21 +110,11 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-isomount=$(mktemp -d --tmpdir=/var/tmp/)
-kspath=$(mktemp -d --tmpdir=/var/tmp/)
-cleanup() {
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-
- sudo umount -v "${isomount}" || echo
- rmdir -v "${isomount}"
- rm -rv "${kspath}"
-}
-trap cleanup EXIT
-
# modify existing kickstart by prepending and appending commands
function modksiso {
sudo dnf install -y lorax # for mkksiso
+ isomount=$(mktemp -d --tmpdir=/var/tmp/)
+ kspath=$(mktemp -d --tmpdir=/var/tmp/)
iso="$1"
newiso="$2"
@@ -179,6 +122,14 @@ function modksiso {
echo "Mounting ${iso} -> ${isomount}"
sudo mount -v -o ro "${iso}" "${isomount}"
+ cleanup() {
+ sudo umount -v "${isomount}"
+ rmdir -v "${isomount}"
+ rm -rv "${kspath}"
+ }
+
+ trap cleanup RETURN
+
# When sudo-nopasswd is specified, a second kickstart file is added which
# includes the %post section for creating sudoers drop-in files. This
# kickstart file is called osbuild.ks and it %includes osbuild-base.ks at
@@ -213,143 +164,6 @@ EOFKS
echo "============================"
}
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 2 ]; then
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- if [ $# -eq 4 ]; then
- image_repo_url=$3
- registry_config=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" "$image_repo_url" "$registry_config" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-# Test user admin added by edge-container bp
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
- # Remove tag from quay.io repo
- skopeo delete --creds "${V2_QUAY_USERNAME}:${V2_QUAY_PASSWORD}" "docker://${QUAY_REPO_URL}:${QUAY_REPO_TAG}"
-
- # Clear vm
- if [[ $(sudo virsh domstate "${IMAGE_KEY}-uefi") == "running" ]]; then
- sudo virsh destroy "${IMAGE_KEY}-uefi"
- fi
- sudo virsh undefine "${IMAGE_KEY}-uefi" --nvram
- # Remove qcow2 file.
- sudo rm -f "$LIBVIRT_UEFI_IMAGE_PATH"
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -465,7 +279,7 @@ password = "$V2_QUAY_PASSWORD"
EOF
# Build container image.
-build_image container "$CONTAINER_TYPE" "${QUAY_REPO_URL}:${QUAY_REPO_TAG}" "$QUAY_CONFIG"
+build_image -b container -t "$CONTAINER_TYPE" -k "${QUAY_REPO_URL}:${QUAY_REPO_TAG}" -c "$QUAY_CONFIG"
# Run edge stage repo
greenprint "๐ฐ Running edge stage repo"
@@ -532,7 +346,7 @@ sudo composer-cli blueprints depsolve installer
# Build installer image.
# Test --url arg following by URL with tailling slash for bz#1942029
-build_image installer "${INSTALLER_TYPE}" "${PROD_REPO_URL}/"
+build_image -b installer -t "${INSTALLER_TYPE}" -u "${PROD_REPO_URL}/"
# Download the image
greenprint "๐ฅ Downloading the installer image"
@@ -824,7 +638,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
diff --git a/test/cases/ostree-pulp.sh b/test/cases/ostree-pulp.sh
index 49833d6bb1..1192edde7b 100644
--- a/test/cases/ostree-pulp.sh
+++ b/test/cases/ostree-pulp.sh
@@ -4,16 +4,10 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
# Get compose url if it's running on unsubscried RHEL
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
source /usr/libexec/osbuild-composer-test/define-compose-url.sh
@@ -39,56 +33,7 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-WHEEL_GROUP=wheel
-if [[ $ID == rhel ]]; then
- WHEEL_GROUP=adm
-fi
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("${WHEEL_GROUP}")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -101,13 +46,13 @@ ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
TEMPDIR=$(mktemp -d)
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
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
PROD_REPO_URL=http://192.168.100.1/repo
PROD_REPO=/var/www/html/repo
# SSH setup.
-SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
+export SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
SSH_DATA_DIR=$(/usr/libexec/osbuild-composer-test/gen-ssh.sh)
SSH_KEY=${SSH_DATA_DIR}/id_rsa
SSH_KEY_PUB="$(cat "${SSH_KEY}".pub)"
@@ -120,131 +65,6 @@ PULP_PASSWORD="foobar"
PULP_REPO="commit"
PULP_BASEPATH="commit"
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- blueprint_name=$1
- image_type=$2
- # for pulp first build
- if [ $# -eq 4 ]; then
- image_key=$3
- pulp_config=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" "$image_key" "$pulp_config" | tee "$COMPOSE_START"
- # for pulp upgrade build
- else
- image_key=$3
- pulp_config=$4
- repo_url=$5
- parent_ref=$6
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --parent "$parent_ref" --url "$repo_url" "$blueprint_name" "$image_type" "$image_key" "$pulp_config" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" "${SSH_USER}@${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
- sudo virsh destroy "${IMAGE_KEY}"
- if [[ $ARCH == aarch64 ]]; then
- sudo virsh undefine "${IMAGE_KEY}" --nvram
- else
- sudo virsh undefine "${IMAGE_KEY}"
- fi
- # Remove qcow2 file.
- sudo rm -f "$LIBVIRT_IMAGE_PATH"
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
- # Stop httpd
- sudo systemctl disable httpd --now
-}
-
-# Test result checking
-check_result () {
- greenprint "Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
##################################################
##
## Upload ostree commit to pulp test
@@ -331,7 +151,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve ostree
# Build commit image
-build_image ostree "$IMAGE_TYPE" test "$PULP_CONFIG_FILE"
+build_image -b ostree -t "$IMAGE_TYPE" -k test -c "$PULP_CONFIG_FILE"
# Start httpd to serve ostree repo.
greenprint "๐ Starting httpd daemon"
diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh
index d1187e007d..655bab4739 100755
--- a/test/cases/ostree-raw-image.sh
+++ b/test/cases/ostree-raw-image.sh
@@ -4,68 +4,14 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("adm")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -81,15 +27,15 @@ CONTAINER_TYPE=edge-container
CONTAINER_FILENAME=container.tar
RAW_IMAGE_TYPE=edge-raw-image
RAW_IMAGE_FILENAME=image.raw.xz
-OSTREE_OSNAME=rhel-edge
+OSTREE_OSNAME=redhat-edge
BOOT_ARGS="uefi"
REF_PREFIX="rhel-edge"
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# SSH setup.
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -149,139 +95,6 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- elif [ $# -eq 4 ]; then
- repo_url=$3
- parent_ref=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --parent "$parent_ref" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear vm
- if [[ $(sudo virsh domstate "${IMAGE_KEY}-uefi") == "running" ]]; then
- sudo virsh destroy "${IMAGE_KEY}-uefi"
- fi
- sudo virsh undefine "${IMAGE_KEY}-uefi" --nvram
- # Remove qcow2 file.
- sudo rm -f "$LIBVIRT_IMAGE_PATH"
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -369,7 +182,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -485,7 +298,7 @@ sudo composer-cli blueprints depsolve raw-image
# Build raw image.
# Test --url arg following by URL with tailling slash for bz#1942029
-build_image raw-image "${RAW_IMAGE_TYPE}" "${PROD_REPO_URL}/"
+build_image -b raw-image -t "${RAW_IMAGE_TYPE}" -u "${PROD_REPO_URL}/"
# Download the image
greenprint "๐ฅ Downloading the raw image"
@@ -665,7 +478,7 @@ EOF
# Build rebase image.
OSTREE_REF="test/redhat/x/${ARCH}/edge"
- build_image rebase "$CONTAINER_TYPE" "$PROD_REPO_URL" "$PARENT_REF"
+ build_image -b rebase -t "$CONTAINER_TYPE" -u "$PROD_REPO_URL" -p "$PARENT_REF"
# Download the image
greenprint "๐ฅ Downloading the rebase image"
@@ -952,7 +765,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
diff --git a/test/cases/ostree-simplified-installer.sh b/test/cases/ostree-simplified-installer.sh
index 9a7017c67e..fce50f1036 100755
--- a/test/cases/ostree-simplified-installer.sh
+++ b/test/cases/ostree-simplified-installer.sh
@@ -4,23 +4,15 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-# Start firewalld
sudo systemctl enable --now firewalld
sudo pip3 install yq==v3.2.1
-
sudo dnf install -y fdo-admin-cli
# Start fdo-aio to have /etc/fdo/aio folder
@@ -40,55 +32,7 @@ if [[ "$VERSION_ID" == "9.4" || "$VERSION_ID" == "9" ]]; then
fi
sudo systemctl restart fdo-aio
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("adm")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -113,8 +57,8 @@ REF_PREFIX="rhel-edge"
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# SSH setup.
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -191,95 +135,6 @@ until [ "$(curl -X POST http://${FDO_SERVER_ADDRESS}:8080/ping)" == "pong" ]; do
sleep 1;
done;
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- elif [ $# -eq 4 ]; then
- repo_url=$3
- parent_ref=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --parent "$parent_ref" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" admin@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
# Wait for FDO onboarding finished.
wait_for_fdo () {
@@ -291,41 +146,6 @@ wait_for_fdo () {
fi
}
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -400,7 +220,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -472,7 +292,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve simplified_iso_without_fdo
# Build simplified installer iso image.
-build_image simplified_iso_without_fdo "${INSTALLER_TYPE}" "${PROD_REPO_URL}/"
+build_image -b simplified_iso_without_fdo -t "${INSTALLER_TYPE}" -u "${PROD_REPO_URL}"
# Download the image
greenprint "๐ฅ Downloading the simplified_iso_without_fdo image"
@@ -639,7 +459,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve installer
# Build installer image.
-build_image installer "${INSTALLER_TYPE}" "${PROD_REPO_URL}"
+build_image -b installer -t "${INSTALLER_TYPE}" -u "${PROD_REPO_URL}"
# Download the image
greenprint "๐ฅ Downloading the installer image"
@@ -823,7 +643,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve fdosshkey
# Build fdosshkey image.
-build_image fdosshkey "${INSTALLER_TYPE}" "${PROD_REPO_URL}"
+build_image -b fdosshkey -t "${INSTALLER_TYPE}" -u "${PROD_REPO_URL}"
# Download the image
greenprint "๐ฅ Downloading the fdosshkey image"
@@ -991,7 +811,7 @@ sudo composer-cli blueprints depsolve rebase
# Build upgrade image.
OSTREE_REF="test/redhat/x/${ARCH}/edge"
-build_image rebase "$CONTAINER_TYPE" "$PROD_REPO_URL" "$PARENT_REF"
+build_image -b rebase -t "$CONTAINER_TYPE" -u "$PROD_REPO_URL" -p "$PARENT_REF"
# Download the image
greenprint "๐ฅ Downloading the rebase image"
@@ -1156,7 +976,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve fdorootcert
# Build fdorootcert image.
-build_image fdorootcert "${INSTALLER_TYPE}" "${PROD_REPO_URL}/"
+build_image -b fdorootcert -t "${INSTALLER_TYPE}" -u "${PROD_REPO_URL}/"
# Download the image
greenprint "๐ฅ Downloading the fdorootcert image"
@@ -1307,7 +1127,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
diff --git a/test/cases/ostree-vsphere.sh b/test/cases/ostree-vsphere.sh
index e772c091aa..ce4aa5ee8a 100755
--- a/test/cases/ostree-vsphere.sh
+++ b/test/cases/ostree-vsphere.sh
@@ -4,68 +4,18 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
# Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-
# Install govc
GOVC_VERSION="v0.30.5"
sudo curl -L -o - "https://github.com/vmware/govmomi/releases/download/${GOVC_VERSION}/govc_Linux_x86_64.tar.gz" | sudo tar -C /usr/local/bin -xvzf - govc
-# Start firewall
-sudo systemctl enable --now firewalld
-# Allow http service in firewall to enable ignition
-sudo firewall-cmd --permanent --zone=public --add-service=http
-sudo firewall-cmd --reload
-
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
-fi
-if [[ $(sudo virsh net-info integration | grep 'Active' | awk '{print $2}') == 'no' ]]; then
- sudo virsh net-start integration
-fi
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -84,8 +34,8 @@ VSPHERE_FILENAME=image.vmdk
# Set up temporary files.
TEMPDIR=$(mktemp -d)
BLUEPRINT_FILE=${TEMPDIR}/blueprint.toml
-COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
-COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
# SSH setup.
SSH_OPTIONS=(-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5)
@@ -128,130 +78,6 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 3 ]; then
- repo_url=$3
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- echo "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" "${IGNITION_USER}"@"${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
-
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove any status containers if exist
- sudo podman ps -a -q --format "{{.ID}}" | sudo xargs --no-run-if-empty podman rm -f
- # Remove all images
- sudo podman rmi -f -a
-
- # Remove prod repo
- sudo rm -rf "$PROD_REPO"
-
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
-
- # Stop prod repo http service
- sudo systemctl disable --now httpd
-
- # Remove vm
- govc vm.destroy -dc="${DATACENTER_70}" "${DC70_VSPHERE_VM_NAME}"
-}
-
-# Test result checking
-check_result () {
- greenprint "๐ Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- greenprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
###########################################################
##
## Prepare edge prod and stage repo
@@ -314,7 +140,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve container
# Build container image.
-build_image container "${CONTAINER_TYPE}"
+build_image -b container -t "${CONTAINER_TYPE}"
# Download the image
greenprint "๐ฅ Downloading the container image"
@@ -469,7 +295,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve vmdk
# Build simplified installer iso image.
-build_image vmdk "${VSPHERE_IMAGE_TYPE}" "${PROD_REPO_URL}/"
+build_image -b vmdk -t "${VSPHERE_IMAGE_TYPE}" -u "${PROD_REPO_URL}/"
# Download the image
greenprint "๐ฅ Downloading the vmdk image"
@@ -585,7 +411,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve upgrade
# Build upgrade image.
-build_image upgrade "${CONTAINER_TYPE}" "$PROD_REPO_URL"
+build_image -b upgrade -t "${CONTAINER_TYPE}" -u "$PROD_REPO_URL"
# Download the image
greenprint "๐ฅ Downloading the upgrade image"
diff --git a/test/cases/ostree.sh b/test/cases/ostree.sh
index 2b85bc6e36..d99431dac7 100755
--- a/test/cases/ostree.sh
+++ b/test/cases/ostree.sh
@@ -4,17 +4,10 @@ set -euo pipefail
# Get OS data.
source /etc/os-release
ARCH=$(uname -m)
+source /usr/libexec/tests/osbuild-composer/ostree-common-functions.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
-function cleanup_on_exit() {
- greenprint "== Script execution stopped or finished - Cleaning up =="
- # kill dangling journalctl processes to prevent GitLab CI from hanging
- sudo pkill journalctl || echo "Nothing killed"
-}
-trap cleanup_on_exit EXIT
-
-
# Get compose url if it's running on unsubscried RHEL
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
source /usr/libexec/osbuild-composer-test/define-compose-url.sh
@@ -98,56 +91,7 @@ case "${ID}-${VERSION_ID}" in
exit 1;;
esac
-# Start libvirtd and test it.
-greenprint "๐ Starting libvirt daemon"
-sudo systemctl start libvirtd
-sudo virsh list --all > /dev/null
-
-# Install and start firewalld
-greenprint "๐ง Install and start firewalld"
-sudo dnf install -y firewalld
-sudo systemctl enable --now firewalld
-
-# Set a customized dnsmasq configuration for libvirt so we always get the
-# same address on bootup.
-sudo tee /tmp/integration.xml > /dev/null << EOF
-
- integration
- 1c8fe98c-b53a-4ca4-bbdb-deb0f26b3579
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-EOF
-if ! sudo virsh net-info integration > /dev/null 2>&1; then
- sudo virsh net-define /tmp/integration.xml
- sudo virsh net-start integration
-fi
-
-# Allow anyone in the wheel group to talk to libvirt.
-greenprint "๐ช Allowing users in wheel group to talk to libvirt"
-WHEEL_GROUP=wheel
-if [[ $ID == rhel ]]; then
- WHEEL_GROUP=adm
-fi
-sudo tee /etc/polkit-1/rules.d/50-libvirt.rules > /dev/null << EOF
-polkit.addRule(function(action, subject) {
- if (action.id == "org.libvirt.unix.manage" &&
- subject.isInGroup("${WHEEL_GROUP}")) {
- return polkit.Result.YES;
- }
-});
-EOF
+common_init
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -160,8 +104,8 @@ ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
TEMPDIR=$(mktemp -d)
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
+export COMPOSE_START=${TEMPDIR}/compose-start-${IMAGE_KEY}.json
+export COMPOSE_INFO=${TEMPDIR}/compose-info-${IMAGE_KEY}.json
FEDORA_IMAGE_DIGEST="sha256:4d76a7480ce1861c95975945633dc9d03807ffb45c64b664ef22e673798d414b"
FEDORA_LOCAL_NAME="localhost/fedora-minimal:v1"
PROD_REPO_URL=http://192.168.100.1/repo
@@ -172,130 +116,6 @@ SSH_DATA_DIR=$(/usr/libexec/osbuild-composer-test/gen-ssh.sh)
SSH_KEY=${SSH_DATA_DIR}/id_rsa
SSH_KEY_PUB="$(cat "${SSH_KEY}".pub)"
-# Get the compose log.
-get_compose_log () {
- COMPOSE_ID=$1
- LOG_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.log
-
- # Download the logs.
- sudo composer-cli compose log "$COMPOSE_ID" | tee "$LOG_FILE" > /dev/null
-}
-
-# Get the compose metadata.
-get_compose_metadata () {
- COMPOSE_ID=$1
- METADATA_FILE=${ARTIFACTS}/osbuild-${ID}-${VERSION_ID}-${COMPOSE_ID}.json
-
- # Download the metadata.
- sudo composer-cli compose metadata "$COMPOSE_ID" > /dev/null
-
- # Find the tarball and extract it.
- TARBALL=$(basename "$(find . -maxdepth 1 -type f -name "*-metadata.tar")")
- sudo tar -xf "$TARBALL" -C "${TEMPDIR}"
- sudo rm -f "$TARBALL"
-
- # Move the JSON file into place.
- sudo cat "${TEMPDIR}"/"${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
-}
-
-# Build ostree image.
-build_image() {
- blueprint_name=$1
- image_type=$2
-
- # Get worker unit file so we can watch the journal.
- WORKER_UNIT=$(sudo systemctl list-units | grep -o -E "osbuild.*worker.*\.service")
- sudo journalctl -af -n 1 -u "${WORKER_UNIT}" &
- WORKER_JOURNAL_PID=$!
-
- # Start the compose.
- greenprint "๐ Starting compose"
- if [ $# -eq 4 ]; then
- repo_url=$3
- parent_ref=$4
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" --parent "$parent_ref" --url "$repo_url" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- else
- sudo composer-cli --json compose start-ostree --ref "$OSTREE_REF" "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
- fi
- COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")
-
- # Wait for the compose to finish.
- greenprint "โฑ Waiting for compose to finish: ${COMPOSE_ID}"
- while true; do
- sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
- COMPOSE_STATUS=$(get_build_info ".queue_status" "$COMPOSE_INFO")
-
- # Is the compose finished?
- if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then
- break
- fi
-
- # Wait 30 seconds and try again.
- sleep 5
- done
-
- # Capture the compose logs from osbuild.
- greenprint "๐ฌ Getting compose log and metadata"
- get_compose_log "$COMPOSE_ID"
- get_compose_metadata "$COMPOSE_ID"
-
- # Kill the journal monitor
- sudo pkill -P ${WORKER_JOURNAL_PID}
-
- # Did the compose finish with success?
- if [[ $COMPOSE_STATUS != FINISHED ]]; then
- redprint "Something went wrong with the compose. ๐ข"
- exit 1
- fi
-}
-
-# Wait for the ssh server up to be.
-wait_for_ssh_up () {
- SSH_STATUS=$(sudo ssh "${SSH_OPTIONS[@]}" -i "${SSH_KEY}" "${SSH_USER}@${1}" '/bin/bash -c "echo -n READY"')
- if [[ $SSH_STATUS == READY ]]; then
- echo 1
- else
- echo 0
- fi
-}
-
-# Clean up our mess.
-clean_up () {
- greenprint "๐งผ Cleaning up"
- sudo virsh destroy "${IMAGE_KEY}"
- if [[ $ARCH == aarch64 ]]; then
- sudo virsh undefine "${IMAGE_KEY}" --nvram
- else
- sudo virsh undefine "${IMAGE_KEY}"
- fi
- # Remove qcow2 file.
- sudo rm -f "$LIBVIRT_IMAGE_PATH"
- # Clear integration network
- sudo virsh net-destroy integration
- sudo virsh net-undefine integration
-
- # Remove extracted upgrade image-tar.
- sudo rm -rf "$UPGRADE_PATH"
- # Remove "remote" repo.
- sudo rm -rf "${HTTPD_PATH}"/{repo,compose.json}
- # Remomve tmp dir.
- sudo rm -rf "$TEMPDIR"
- # Stop httpd
- sudo systemctl disable httpd --now
-}
-
-# Test result checking
-check_result () {
- greenprint "Checking for test result"
- if [[ $RESULTS == 1 ]]; then
- greenprint "๐ Success"
- else
- redprint "โ Failed"
- clean_up
- exit 1
- fi
-}
-
##################################################
##
## ostree image/commit installation
@@ -383,7 +203,7 @@ sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve ostree
# Build installation image.
-build_image ostree "$IMAGE_TYPE"
+build_image -b ostree -t "$IMAGE_TYPE"
# Start httpd to serve ostree repo.
greenprint "๐ Starting httpd daemon"
@@ -640,7 +460,7 @@ greenprint "๐น Get ostree installed commit value"
PARENT_HASH=$(curl "${PROD_REPO_URL}/refs/heads/${OSTREE_REF}")
# Build upgrade image.
-build_image upgrade "$IMAGE_TYPE" "$PROD_REPO_URL" "$PARENT_HASH"
+build_image -b upgrade -t "$IMAGE_TYPE" -u "$PROD_REPO_URL" -p "$PARENT_HASH"
# Download the image and extract tar into web server root folder.
greenprint "๐ฅ Downloading and extracting the image"