test: new weldr client compatibility for test scripts

- Handle the array responses from the new weldr-client (>= 35.6).
- Move the `get_build_info` function to shared_libs.sh to source and
  reuse in multiple places.
This commit is contained in:
Achilleas Koutsou 2022-08-30 15:59:01 +02:00 committed by Tom Gundersen
parent 8e24f5720d
commit 3b14828669
25 changed files with 57 additions and 247 deletions

View file

@ -10,21 +10,13 @@
set -euo pipefail set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output. # Colorful output.
function greenprint { function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Container image used for cloud provider CLI tools # Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
@ -111,14 +103,6 @@ get_compose_metadata () {
sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
} }
is_weldr_client_installed () {
if rpm --quiet -q weldr-client; then
echo true
else
echo false
fi
}
# Write an AWS TOML file # Write an AWS TOML file
tee "$AWS_CONFIG" > /dev/null << EOF tee "$AWS_CONFIG" > /dev/null << EOF
provider = "aws" provider = "aws"

View file

@ -11,6 +11,8 @@ shopt -s expand_aliases
set -euo pipefail set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
BRANCH_NAME="${CI_COMMIT_BRANCH:-local}" BRANCH_NAME="${CI_COMMIT_BRANCH:-local}"
BUILD_ID="${CI_BUILD_ID:-$(uuidgen)}" BUILD_ID="${CI_BUILD_ID:-$(uuidgen)}"
HYPER_V_GEN="${HYPER_V_GEN:-V1}" HYPER_V_GEN="${HYPER_V_GEN:-V1}"
@ -20,15 +22,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Container image used for cloud provider CLI tools # Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
@ -138,14 +131,6 @@ get_compose_metadata () {
sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
} }
is_weldr_client_installed () {
if rpm --quiet -q weldr-client; then
echo true
else
echo false
fi
}
# Export Azure credentials if running on Jenkins # Export Azure credentials if running on Jenkins
set +u set +u
if [ -n "$AZURE_CREDS" ] if [ -n "$AZURE_CREDS" ]

View file

@ -6,16 +6,8 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# #
# Provision the software under test. # Provision the software under test.

View file

@ -6,16 +6,8 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# #
# Provision the software under test. # Provision the software under test.

View file

@ -10,20 +10,13 @@ source /etc/os-release
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output. # Colorful output.
function greenprint { function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
TEST_UUID=$(uuidgen) TEST_UUID=$(uuidgen)
IMAGE_KEY="osbuild-composer-test-${TEST_UUID}" IMAGE_KEY="osbuild-composer-test-${TEST_UUID}"
@ -60,12 +53,8 @@ build_image() {
greenprint "🚀 Starting compose" greenprint "🚀 Starting compose"
# this needs "|| true" at the end for the fail case scenario # this needs "|| true" at the end for the fail case scenario
sudo composer-cli --json compose start "$blueprint_name" "$image_type" | tee "$COMPOSE_START" || true sudo composer-cli --json compose start "$blueprint_name" "$image_type" | tee "$COMPOSE_START" || true
if rpm -q --quiet weldr-client; then STATUS=$(get_build_info ".status" "$COMPOSE_START")
STATUS=$(jq -r '.body.status' "$COMPOSE_START")
else
STATUS=$(jq -r '.status' "$COMPOSE_START")
fi
if [[ $want_fail == "$STATUS" ]]; then if [[ $want_fail == "$STATUS" ]]; then
echo "Something went wrong with the compose. 😢" echo "Something went wrong with the compose. 😢"
sudo pkill -P ${WORKER_JOURNAL_PID} sudo pkill -P ${WORKER_JOURNAL_PID}
@ -74,11 +63,9 @@ build_image() {
elif [[ $want_fail == true && $STATUS == false ]]; then elif [[ $want_fail == true && $STATUS == false ]]; then
sudo pkill -P ${WORKER_JOURNAL_PID} sudo pkill -P ${WORKER_JOURNAL_PID}
trap - EXIT trap - EXIT
if rpm -q --quiet weldr-client; then # use get_build_info to extract errors before picking the first
ERROR_MSG=$(jq 'first(.body.errors[] | select(.id == "ManifestCreationFailed")) | .msg' "$COMPOSE_START") errors=$(get_build_info ".errors" "$COMPOSE_START")
else ERROR_MSG=$(jq 'first(.[] | select(.id == "ManifestCreationFailed")) | .msg' <<< "${errors}")
ERROR_MSG=$(jq 'first(.errors[] | select(.id == "ManifestCreationFailed")) | .msg' "$COMPOSE_START")
fi
return return
else else
COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START") COMPOSE_ID=$(get_build_info ".build_id" "$COMPOSE_START")

View file

@ -8,6 +8,7 @@
# #
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
set -euo pipefail set -euo pipefail
@ -16,15 +17,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Container image used for cloud provider CLI tools # Container image used for cloud provider CLI tools
CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest" CONTAINER_IMAGE_CLOUD_TOOLS="quay.io/osbuild/cloud-tools:latest"
@ -206,14 +198,6 @@ get_compose_metadata () {
sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null sudo cat "${COMPOSE_ID}".json | jq -M '.' | tee "$METADATA_FILE" > /dev/null
} }
is_weldr_client_installed () {
if rpm --quiet -q weldr-client; then
echo true
else
echo false
fi
}
# Write an GCP TOML file # Write an GCP TOML file
tee "$GCP_CONFIG" > /dev/null << EOF tee "$GCP_CONFIG" > /dev/null << EOF
provider = "gcp" provider = "gcp"

View file

@ -200,21 +200,13 @@ build_image() {
# Start the compose. # Start the compose.
greenprint "🚀 Starting compose" greenprint "🚀 Starting compose"
sudo composer-cli --json compose start "$blueprint_name" "$image_type" | tee "$COMPOSE_START" sudo composer-cli --json compose start "$blueprint_name" "$image_type" | tee "$COMPOSE_START"
if rpm -q --quiet weldr-client; then COMPOSE_ID=$(get_build_info ".build_id" "${COMPOSE_START}")
COMPOSE_ID=$(jq -r '.body.build_id' "$COMPOSE_START")
else
COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START")
fi
# Wait for the compose to finish. # Wait for the compose to finish.
greenprint "⏱ Waiting for compose to finish: ${COMPOSE_ID}" greenprint "⏱ Waiting for compose to finish: ${COMPOSE_ID}"
while true; do while true; do
sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
if rpm -q --quiet weldr-client; then COMPOSE_STATUS=$(get_build_info ".queue_status" "${COMPOSE_INFO}")
COMPOSE_STATUS=$(jq -r '.body.queue_status' "$COMPOSE_INFO")
else
COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO")
fi
# Is the compose finished? # Is the compose finished?
if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then

View file

@ -9,6 +9,8 @@ OSBUILD_COMPOSER_TEST_DATA=/usr/share/tests/osbuild-composer/
# Get OS data. # Get OS data.
source /etc/os-release source /etc/os-release
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output. # Colorful output.
function greenprint { function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
@ -125,15 +127,6 @@ gen_iso () {
# scans and check results # scans and check results
sudo dnf install -y xmlstarlet openscap-utils scap-security-guide sudo dnf install -y xmlstarlet openscap-utils scap-security-guide
get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1

View file

@ -13,15 +13,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Install openshift client # Install openshift client
greenprint "🔧 Installing oenshift client(oc)" greenprint "🔧 Installing oenshift client(oc)"

View file

@ -4,6 +4,8 @@ set -euo pipefail
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Get OS data. # Get OS data.
source /etc/os-release source /etc/os-release
ARCH=$(uname -m) ARCH=$(uname -m)
@ -13,15 +15,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".[0].body${key}"
fi
jq -r "${key}" "${fname}"
}
# Start libvirtd and test it. # Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon" greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd sudo systemctl start libvirtd

View file

@ -4,6 +4,8 @@ set -euo pipefail
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Get compose url if it's running on unsubscried RHEL # Get compose url if it's running on unsubscried RHEL
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
source /usr/libexec/osbuild-composer-test/define-compose-url.sh source /usr/libexec/osbuild-composer-test/define-compose-url.sh
@ -17,15 +19,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Start libvirtd and test it. # Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon" greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd sudo systemctl start libvirtd

View file

@ -3,6 +3,7 @@ set -euo pipefail
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Get compose url if it's running on unsubscried RHEL # Get compose url if it's running on unsubscried RHEL
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
@ -17,15 +18,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Start libvirtd and test it. # Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon" greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd sudo systemctl start libvirtd

View file

@ -13,14 +13,7 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() { source /usr/libexec/tests/osbuild-composer/shared_lib.sh
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Start firewalld # Start firewalld
sudo systemctl enable --now firewalld sudo systemctl enable --now firewalld

View file

@ -3,6 +3,7 @@ set -euo pipefail
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Get compose url if it's running on unsubscried RHEL # Get compose url if it's running on unsubscried RHEL
if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then if [[ ${ID} == "rhel" ]] && ! sudo subscription-manager status; then
@ -115,15 +116,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Start libvirtd and test it. # Start libvirtd and test it.
greenprint "🚀 Starting libvirt daemon" greenprint "🚀 Starting libvirt daemon"
sudo systemctl start libvirtd sudo systemctl start libvirtd

View file

@ -4,16 +4,9 @@
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
set -xeuo pipefail source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function get_build_info() { set -xeuo pipefail
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none

View file

@ -11,15 +11,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
function generate_certificates { function generate_certificates {
# Generate CA root key # Generate CA root key
sudo openssl genrsa -out ca.key sudo openssl genrsa -out ca.key
@ -39,6 +30,7 @@ function generate_certificates {
} }
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Provision the software under tet. # Provision the software under tet.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none

View file

@ -12,15 +12,6 @@ function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
function generate_certificates { function generate_certificates {
# Generate CA root key # Generate CA root key
sudo openssl genrsa -out ca.key sudo openssl genrsa -out ca.key
@ -68,6 +59,7 @@ function cleanup {
} }
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Provision the software under tet. # Provision the software under tet.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none

View file

@ -14,16 +14,9 @@
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
set -xeuo pipefail source /usr/libexec/tests/osbuild-composer/shared_lib.sh
function get_build_info() { set -xeuo pipefail
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none

View file

@ -15,6 +15,7 @@
set -xeuo pipefail set -xeuo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
@ -41,21 +42,13 @@ EOF
sudo composer-cli blueprints push "$BLUEPRINT_FILE" sudo composer-cli blueprints push "$BLUEPRINT_FILE"
sudo composer-cli blueprints depsolve nss-devel sudo composer-cli blueprints depsolve nss-devel
sudo composer-cli --json compose start nss-devel qcow2 | tee "${COMPOSE_START}" sudo composer-cli --json compose start nss-devel qcow2 | tee "${COMPOSE_START}"
if rpm -q --quiet weldr-client; then COMPOSE_ID=$(get_build_info '.build_id' "$COMPOSE_START")
COMPOSE_ID=$(jq -r '.body.build_id' "$COMPOSE_START")
else
COMPOSE_ID=$(jq -r '.build_id' "$COMPOSE_START")
fi
# Wait for the compose to finish. # Wait for the compose to finish.
echo "⏱ Waiting for compose to finish: ${COMPOSE_ID}" echo "⏱ Waiting for compose to finish: ${COMPOSE_ID}"
while true; do while true; do
sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null sudo composer-cli --json compose info "${COMPOSE_ID}" | tee "$COMPOSE_INFO" > /dev/null
if rpm -q --quiet weldr-client; then COMPOSE_STATUS=$(get_build_info '.queue_status' "$COMPOSE_INFO")
COMPOSE_STATUS=$(jq -r '.body.queue_status' "$COMPOSE_INFO")
else
COMPOSE_STATUS=$(jq -r '.queue_status' "$COMPOSE_INFO")
fi
# Is the compose finished? # Is the compose finished?
if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then if [[ $COMPOSE_STATUS != RUNNING ]] && [[ $COMPOSE_STATUS != WAITING ]]; then

View file

@ -11,6 +11,7 @@ function greenprint {
} }
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
@ -138,21 +139,13 @@ if [[ "${dummysourceurl}" != "${expectedurl}" ]]; then
fi fi
sudo composer-cli --json compose start dummy qcow2 | tee "${composestart}" sudo composer-cli --json compose start dummy qcow2 | tee "${composestart}"
if rpm -q --quiet weldr-client; then composeid=$(get_build_info '.build_id' "${composestart}")
composeid=$(jq -r '.body.build_id' "$composestart")
else
composeid=$(jq -r '.build_id' "${composestart}")
fi
# Wait for the compose to finish. # Wait for the compose to finish.
echo "⏱ Waiting for compose to finish: ${composeid}" echo "⏱ Waiting for compose to finish: ${composeid}"
while true; do while true; do
sudo composer-cli --json compose info "${composeid}" | tee "${composeinfo}" > /dev/null sudo composer-cli --json compose info "${composeid}" | tee "${composeinfo}" > /dev/null
if rpm -q --quiet weldr-client; then composestatus=$(get_build_info '.queue_status' "${composeinfo}")
composestatus=$(jq -r '.body.queue_status' "${composeinfo}")
else
composestatus=$(jq -r '.queue_status' "${composeinfo}")
fi
# Is the compose finished? # Is the compose finished?
if [[ ${composestatus} != RUNNING ]] && [[ ${composestatus} != WAITING ]]; then if [[ ${composestatus} != RUNNING ]] && [[ ${composestatus} != WAITING ]]; then

View file

@ -5,21 +5,13 @@
# Get OS data. # Get OS data.
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
set -xeuo pipefail set -xeuo pipefail
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Provision the software under test. # Provision the software under test.
BLUEPRINT_FILE=/tmp/blueprint.toml BLUEPRINT_FILE=/tmp/blueprint.toml
COMPOSE_START=/tmp/compose-start.json COMPOSE_START=/tmp/compose-start.json

View file

@ -15,6 +15,7 @@ function greenprint {
ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}" ARTIFACTS="${ARTIFACTS:-/tmp/artifacts}"
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Only run this on x86 and rhel8 GA # Only run this on x86 and rhel8 GA
if [ "$ARCH" != "x86_64" ] || [ "$ID" != rhel ] || ! sudo subscription-manager status; then if [ "$ARCH" != "x86_64" ] || [ "$ID" != rhel ] || ! sudo subscription-manager status; then

View file

@ -7,12 +7,12 @@ function nvrGreaterOrEqual {
set +e set +e
rpm_version=$(rpm -q --qf "%{version}" "${rpm_name}") rpm_version=$(rpm -q --qf "%{version}" "${rpm_name}")
rpmdev-vercmp "${rpm_version}" "${min_version}" rpmdev-vercmp "${rpm_version}" "${min_version}" 1>&2
if [ "$?" != "12" ]; then if [ "$?" != "12" ]; then
# 0 - rpm_version == min_version # 0 - rpm_version == min_version
# 11 - rpm_version > min_version # 11 - rpm_version > min_version
# 12 - rpm_version < min_version # 12 - rpm_version < min_version
echo "DEBUG: ${rpm_version} >= ${min_version}" echo "DEBUG: ${rpm_version} >= ${min_version}" 1>&2
set -e set -e
return return
fi fi
@ -20,3 +20,16 @@ function nvrGreaterOrEqual {
set -e set -e
false false
} }
function get_build_info() {
local key="$1"
local fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
if nvrGreaterOrEqual "weldr-client" "35.6"; then
key=".[0]${key}"
fi
fi
jq -r "${key}" "${fname}"
}

View file

@ -10,21 +10,13 @@
set -euo pipefail set -euo pipefail
source /usr/libexec/osbuild-composer-test/set-env-variables.sh source /usr/libexec/osbuild-composer-test/set-env-variables.sh
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
# Colorful output. # Colorful output.
function greenprint { function greenprint {
echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m" echo -e "\033[1;32m[$(date -Isecond)] ${1}\033[0m"
} }
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Provision the software under test. # Provision the software under test.
/usr/libexec/osbuild-composer-test/provision.sh none /usr/libexec/osbuild-composer-test/provision.sh none

View file

@ -2,6 +2,8 @@
set -euxo pipefail set -euxo pipefail
source /usr/libexec/tests/osbuild-composer/shared_lib.sh
WORKSPACE=$(mktemp -d) WORKSPACE=$(mktemp -d)
function cleanup() { function cleanup() {
echo "== Script execution stopped or finished - Cleaning up ==" echo "== Script execution stopped or finished - Cleaning up =="
@ -9,15 +11,6 @@ function cleanup() {
} }
trap cleanup EXIT trap cleanup EXIT
function get_build_info() {
key="$1"
fname="$2"
if rpm -q --quiet weldr-client; then
key=".body${key}"
fi
jq -r "${key}" "${fname}"
}
# Get the compose log. # Get the compose log.
get_compose_log () { get_compose_log () {
COMPOSE_ID=$1 COMPOSE_ID=$1