2018-09-21 09:46:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Note: execute this file from the project root directory
|
|
|
|
|
2019-06-25 09:50:37 +00:00
|
|
|
set -e
|
|
|
|
|
2018-09-21 09:46:54 +00:00
|
|
|
. /usr/share/beakerlib/beakerlib.sh
|
2019-06-25 09:50:37 +00:00
|
|
|
. $(dirname $0)/lib/lib.sh
|
2018-09-21 09:46:54 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
CLI="${CLI:-./src/bin/composer-cli}"
|
2018-09-21 09:46:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartTest "compose types"
|
2019-11-29 13:09:11 +00:00
|
|
|
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"
|
2021-03-27 19:26:26 +00:00
|
|
|
TYPE_IOT="rhel-edge-commit rhel-edge-container rhel-edge-installer"
|
2019-11-29 13:09:11 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# arch specific compose type selections
|
2020-01-09 10:40:02 +00:00
|
|
|
if [ "$(uname -m)" == "x86_64" ]; then
|
2019-11-29 13:09:11 +00:00
|
|
|
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"
|
2020-01-09 22:19:44 +00:00
|
|
|
elif [ "$(uname -m)" == "aarch64" ]; then
|
|
|
|
# ami is supported on aarch64
|
2019-11-29 13:09:11 +00:00
|
|
|
SUPPORTED_TYPES="ami $TYPE_EXT4 $TYPE_LIVE_ISO $TYPE_LIVEIMG openstack $TYPE_PARTITIONED_DISK qcow2 $TYPE_TAR"
|
2019-12-10 19:34:42 +00:00
|
|
|
else
|
2019-11-29 13:09:11 +00:00
|
|
|
SUPPORTED_TYPES="$TYPE_EXT4 $TYPE_LIVE_ISO $TYPE_LIVEIMG openstack $TYPE_PARTITIONED_DISK qcow2 $TYPE_TAR"
|
2019-12-10 19:34:42 +00:00
|
|
|
fi
|
2019-11-29 13:09:11 +00:00
|
|
|
|
|
|
|
# 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"
|
2018-09-21 09:46:54 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose start"
|
2019-11-29 12:23:28 +00:00
|
|
|
rlRun -t -c "$CLI blueprints push $(dirname $0)/lib/test-http-server.toml"
|
|
|
|
UUID=`$CLI compose start test-http-server qcow2`
|
2020-01-03 13:17:56 +00:00
|
|
|
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..."
|
2020-07-24 09:53:29 +00:00
|
|
|
if $CLI compose info $UUID | grep 'FAILED'; then
|
|
|
|
rlFail "Compose FAILED!"
|
|
|
|
break
|
|
|
|
fi
|
2020-01-03 13:17:56 +00:00
|
|
|
done;
|
|
|
|
else
|
|
|
|
rlFail "Compose UUID is empty!"
|
|
|
|
fi
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "cancel compose"
|
|
|
|
rlRun -t -c "$CLI compose cancel $UUID"
|
2020-07-15 07:49:43 +00:00
|
|
|
if [ "$BACKEND" == "lorax-composer" ]; then
|
|
|
|
rlRun -t -c "$CLI compose info $UUID" 1 "compose is canceled"
|
|
|
|
fi
|
2020-01-03 13:17:56 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
2020-07-24 09:53:29 +00:00
|
|
|
if [ -z "$SKIP_IMAGE_BUILD" ]; then
|
2020-01-03 13:17:56 +00:00
|
|
|
rlPhaseStartTest "compose start again"
|
2019-11-29 12:23:28 +00:00
|
|
|
UUID=`$CLI compose start test-http-server qcow2`
|
2018-09-21 09:46:54 +00:00
|
|
|
rlAssertEquals "exit code should be zero" $? 0
|
|
|
|
|
|
|
|
UUID=`echo $UUID | cut -f 2 -d' '`
|
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose image"
|
2019-09-06 16:56:19 +00:00
|
|
|
wait_for_compose $UUID
|
2018-09-21 09:46:54 +00:00
|
|
|
if [ -n "$UUID" ]; then
|
2019-07-10 15:58:24 +00:00
|
|
|
check_compose_status "$UUID"
|
2018-09-21 09:46:54 +00:00
|
|
|
|
|
|
|
rlRun -t -c "$CLI compose image $UUID"
|
2019-11-29 12:23:28 +00:00
|
|
|
rlAssertExists "$UUID-disk.qcow2"
|
2019-12-03 23:38:43 +00:00
|
|
|
fi
|
2019-04-08 09:12:28 +00:00
|
|
|
|
2019-12-03 23:38:43 +00:00
|
|
|
if [ "$BACKEND" != "osbuild-composer" ]; then
|
2019-04-08 09:12:28 +00:00
|
|
|
# because this path is listed in the documentation
|
|
|
|
rlAssertExists "/var/lib/lorax/composer/results/$UUID/"
|
2019-11-29 12:23:28 +00:00
|
|
|
rlAssertExists "/var/lib/lorax/composer/results/$UUID/disk.qcow2"
|
|
|
|
rlAssertNotDiffer "/var/lib/lorax/composer/results/$UUID/disk.qcow2" "$UUID-disk.qcow2"
|
2018-09-21 09:46:54 +00:00
|
|
|
fi
|
|
|
|
rlPhaseEnd
|
2020-07-24 09:53:29 +00:00
|
|
|
else
|
|
|
|
rlLogInfo "Skipping image build phases"
|
|
|
|
fi
|
2018-09-21 09:46:54 +00:00
|
|
|
|
2019-12-10 12:28:41 +00:00
|
|
|
rlPhaseStartCleanup
|
2020-07-24 09:53:29 +00:00
|
|
|
if [ "$($CLI compose list | grep -c $UUID)" == "1" ]; then
|
|
|
|
rlRun -t -c "$CLI compose delete $UUID"
|
|
|
|
fi
|
2019-12-10 12:28:41 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
2018-09-21 09:46:54 +00:00
|
|
|
rlJournalEnd
|
|
|
|
rlJournalPrintText
|