diff --git a/test/cases/ostree-ami-image.sh b/test/cases/ostree-ami-image.sh
index 93d58f1d191..2b771a57cac 100755
--- a/test/cases/ostree-ami-image.sh
+++ b/test/cases/ostree-ami-image.sh
@@ -4,51 +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
-# 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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -70,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)
@@ -103,149 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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"
@@ -254,6 +74,7 @@ check_result () {
else
redprint "โ Failed"
clean_up
+ aws_clean_up
exit 1
fi
}
@@ -423,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"
@@ -620,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"
@@ -935,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"
@@ -1063,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 00000000000..54f6113974d
--- /dev/null
+++ b/test/cases/ostree-common-functions.sh
@@ -0,0 +1,257 @@
+#!/bin/bash
+# A script that's full of common functions
+# used throughout our ostree tests. Can be
+# sourced at beginning of those scripts.
+
+function CommonInit() {
+ # 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
+}
+
+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() {
+ greenprint "๐งผ Cleaning up"
+
+ # Clear integration network
+ sudo virsh net-destroy integration
+ sudo virsh net-undefine integration
+
+ # Remove tag from quay.io repo
+ command skopeo && { 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
+}
+
+function vsphere_clean_up() {
+ # Remove vSphere VM
+ govc vm.destroy -dc="${DATACENTER_70}" "${DC70_VSPHERE_VM_NAME}"
+}
+
+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() {
+ 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
+}
+
+function build_image() {
+ cmd="compose start-ostree --json --ref $OSTREE_REF"
+ while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -b|--blue-print)
+ local blue_print=$2
+ shift 2
+ ;;
+ -t|--image-type)
+ local image_type=$2
+ shift 2
+ ;;
+ -u|--url)
+ local cmd+=" --url $2"
+ shift 2
+ ;;
+ -c|--registry-config)
+ local registry_config=$2
+ shift 2
+ ;;
+ -k|--image-key)
+ local 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=$!
+ # Stop watching the worker journal when exiting.
+ trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
+
+ # Start the compose.
+ greenprint "๐ Starting compose"
+ composer-cli "$cmd" "$blue_print" "$image_type" "$key" "$registry_config" | 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 immediately and remove the trap
+ sudo pkill -P ${WORKER_JOURNAL_PID}
+ trap - EXIT
+
+ # Did the compose finish with success?
+ if [[ $COMPOSE_STATUS != FINISHED ]]; then
+ redprint "Something went wrong with the compose. ๐ข"
+ exit 1
+ fi
+}
diff --git a/test/cases/ostree-ignition.sh b/test/cases/ostree-ignition.sh
index 82df2e91bda..c19a11c4779 100755
--- a/test/cases/ostree-ignition.sh
+++ b/test/cases/ostree-ignition.sh
@@ -4,62 +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
-# 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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -88,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}"
@@ -123,134 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -315,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"
@@ -480,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"
@@ -628,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"
@@ -766,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"
@@ -904,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 9533a5d1d03..e9738f6bd9f 100755
--- a/test/cases/ostree-iot-qcow2.sh
+++ b/test/cases/ostree-iot-qcow2.sh
@@ -4,61 +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
-# 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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -78,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)
@@ -100,142 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -292,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"
@@ -394,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"
@@ -555,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 9fa579a0cc4..890bf9daeac 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
+CommonInit
# 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"
@@ -215,146 +168,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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -470,7 +283,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" -u "${QUAY_REPO_URL}:${QUAY_REPO_TAG}" -c "$QUAY_CONFIG"
# Run edge stage repo
greenprint "๐ฐ Running edge stage repo"
@@ -533,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"
@@ -825,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 9939277a66b..df15c0a0e2c 100644
--- a/test/cases/ostree-pulp.sh
+++ b/test/cases/ostree-pulp.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
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
@@ -32,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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -94,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)"
@@ -113,134 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -327,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 e639bd27687..44764443770 100755
--- a/test/cases/ostree-raw-image.sh
+++ b/test/cases/ostree-raw-image.sh
@@ -4,61 +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
-# 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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -81,8 +34,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)
@@ -142,142 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -365,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"
@@ -481,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"
@@ -661,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"
@@ -948,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 d193bf3c1c7..b2ac9b641ee 100755
--- a/test/cases/ostree-simplified-installer.sh
+++ b/test/cases/ostree-simplified-installer.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
@@ -33,55 +34,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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -106,8 +59,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)
@@ -184,98 +137,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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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 () {
@@ -287,41 +148,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
@@ -396,7 +222,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"
@@ -468,7 +294,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"
@@ -635,7 +461,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"
@@ -819,7 +645,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"
@@ -987,7 +813,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"
@@ -1152,7 +978,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"
@@ -1303,7 +1129,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 8d6f90eebe0..07567dc95fb 100755
--- a/test/cases/ostree-vsphere.sh
+++ b/test/cases/ostree-vsphere.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,50 +15,7 @@ source /usr/libexec/tests/osbuild-composer/shared_lib.sh
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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -76,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)
@@ -120,121 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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"
@@ -243,6 +86,7 @@ check_result () {
else
greenprint "โ Failed"
clean_up
+ vsphere_clean_up
exit 1
fi
}
@@ -309,7 +153,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"
@@ -464,7 +308,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"
@@ -580,7 +424,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 b75ba17fad1..5c7014646a6 100755
--- a/test/cases/ostree.sh
+++ b/test/cases/ostree.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
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
@@ -90,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
+CommonInit
# Set up variables.
TEST_UUID=$(uuidgen)
@@ -152,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
@@ -164,133 +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=$!
- # Stop watching the worker journal when exiting.
- trap 'sudo pkill -P ${WORKER_JOURNAL_PID}' EXIT
-
- # 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 immediately and remove the trap
- sudo pkill -P ${WORKER_JOURNAL_PID}
- trap - EXIT
-
- # 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
@@ -378,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"
@@ -635,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"