lorax/tests/cli/test_compose_sanity.sh
Alexander Todorov 6240df6caf tests: Special case compose types for osbuild-composer
- alibaba - will be added later
- google - will be added later, low priority b/c
  GCE doesn't fully support RHEL8
- live-iso - not supported for now
- ext4 & partitioned disk - removed from osbuild-composer
- hyper-v & liveimg-tar are available only on master branch

Cherry-picked from 4dd7cf8798

Related: rhbz#1825190
2020-07-28 14:21:47 -07:00

115 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
# Note: execute this file from the project root directory
set -e
. /usr/share/beakerlib/beakerlib.sh
. $(dirname $0)/lib/lib.sh
CLI="${CLI:-./src/bin/composer-cli}"
rlJournalStart
rlPhaseStartTest "compose types"
TYPE_LIVE_ISO="live-iso"
TYPE_ALIBABA="alibaba"
TYPE_GOOGLE="google"
TYPE_HYPER_V=""
TYPE_LIVEIMG=""
TYPE_EXT4="ext4-filesystem"
TYPE_PARTITIONED_DISK="partitioned-disk"
TYPE_TAR="tar"
TYPE_IOT=""
# backend specific compose type overrides
if [ "$BACKEND" == "osbuild-composer" ]; then
TYPE_LIVE_ISO=""
TYPE_ALIBABA=""
TYPE_GOOGLE=""
TYPE_HYPER_V=""
TYPE_LIVEIMG=""
TYPE_EXT4=""
TYPE_PARTITIONED_DISK=""
TYPE_TAR="tar"
TYPE_IOT="rhel-edge-commit"
fi
# arch specific compose type selections
if [ "$(uname -m)" == "x86_64" ]; then
SUPPORTED_TYPES="$TYPE_ALIBABA ami $TYPE_EXT4 $TYPE_GOOGLE $TYPE_HYPER_V $TYPE_LIVE_ISO $TYPE_LIVEIMG openstack $TYPE_PARTITIONED_DISK qcow2 $TYPE_IOT $TYPE_TAR vhd vmdk"
elif [ "$(uname -m)" == "aarch64" ]; then
# ami is supported on aarch64
SUPPORTED_TYPES="ami $TYPE_EXT4 $TYPE_LIVE_ISO $TYPE_LIVEIMG openstack $TYPE_PARTITIONED_DISK qcow2 $TYPE_TAR"
else
SUPPORTED_TYPES="$TYPE_EXT4 $TYPE_LIVE_ISO $TYPE_LIVEIMG openstack $TYPE_PARTITIONED_DISK qcow2 $TYPE_TAR"
fi
# truncate white space in case some types are not available
SUPPORTED_TYPES=$(echo "$SUPPORTED_TYPES" | tr -s ' ' | sed 's/^[[:space:]]*//')
rlAssertEquals "lists all supported types" "`$CLI compose types | xargs`" "$SUPPORTED_TYPES"
rlPhaseEnd
rlPhaseStartTest "compose start"
UUID=`$CLI compose start example-http-server ami`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`
if [ -n "$UUID" ]; then
until $CLI compose info $UUID | grep 'RUNNING'; do
sleep 20
rlLogInfo "Waiting for compose to start running..."
if $CLI compose info $UUID | grep 'FAILED'; then
rlFail "Compose FAILED!"
break
fi
done;
else
rlFail "Compose UUID is empty!"
fi
# check if anaconda is really running
until ps -axo comm,pid | grep '^anaconda'; do
sleep 10
rlLogInfo "Waiting for anaconda to start running..."
done;
rlPhaseEnd
rlPhaseStartTest "cancel compose"
rlRun -t -c "$CLI compose cancel $UUID"
rlRun -t -c "$CLI compose info $UUID" 1 "compose is canceled"
rlAssertNotExists "/var/run/anaconda.pid"
rlPhaseEnd
rlPhaseStartTest "compose start again"
UUID=`$CLI compose start example-http-server ami`
rlAssertEquals "exit code should be zero" $? 0
UUID=`echo $UUID | cut -f 2 -d' '`
rlPhaseEnd
rlPhaseStartTest "compose info"
if [ -n "$UUID" ]; then
rlRun -t -c "$CLI compose info $UUID | egrep 'RUNNING|WAITING'"
else
rlFail "Compose UUID is empty!"
fi
rlPhaseEnd
rlPhaseStartTest "compose image"
wait_for_compose $UUID
if [ -n "$UUID" ]; then
check_compose_status "$UUID"
rlRun -t -c "$CLI compose image $UUID"
rlAssertExists "$UUID-root.tar.xz"
# because this path is listed in the documentation
rlAssertExists "/var/lib/lorax/composer/results/$UUID/"
rlAssertExists "/var/lib/lorax/composer/results/$UUID/root.tar.xz"
rlAssertNotDiffer "/var/lib/lorax/composer/results/$UUID/root.tar.xz" "$UUID-root.tar.xz"
fi
rlPhaseEnd
rlJournalEnd
rlJournalPrintText