2019-06-26 13:57:25 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Note: execute this file from the project root directory
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# Build tar image and install it using liveimg kickstart command
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
. /usr/share/beakerlib/beakerlib.sh
|
|
|
|
. $(dirname $0)/lib/lib.sh
|
|
|
|
|
|
|
|
CLI="${CLI:-./src/bin/composer-cli}"
|
|
|
|
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartSetup
|
2019-10-30 23:28:54 +00:00
|
|
|
TMP_DIR=$(mktemp -d /tmp/composer.XXXXX)
|
|
|
|
SSH_KEY_DIR=$(mktemp -d /tmp/composer-ssh-keys.XXXXXX)
|
|
|
|
|
|
|
|
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
|
|
|
|
PUB_KEY=$(cat "$SSH_KEY_DIR/id_rsa.pub")
|
|
|
|
|
|
|
|
cat > "$TMP_DIR/test-tar.toml" << __EOF__
|
|
|
|
name = "test-tar"
|
2019-06-26 13:57:25 +00:00
|
|
|
description = "tar image test"
|
|
|
|
version = "0.0.1"
|
|
|
|
modules = []
|
|
|
|
|
2019-10-30 23:28:54 +00:00
|
|
|
[[groups]]
|
|
|
|
name = "anaconda-tools"
|
|
|
|
|
|
|
|
[[packages]]
|
|
|
|
name = "kernel"
|
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[[packages]]
|
|
|
|
name = "beakerlib"
|
|
|
|
version = "*"
|
|
|
|
|
2019-06-26 13:57:25 +00:00
|
|
|
[[packages]]
|
|
|
|
name = "openssh-server"
|
|
|
|
version = "*"
|
|
|
|
|
2019-10-31 18:05:02 +00:00
|
|
|
[[packages]]
|
|
|
|
name = "openssh-clients"
|
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[[packages]]
|
|
|
|
name = "passwd"
|
2019-06-26 13:57:25 +00:00
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[[customizations.user]]
|
|
|
|
name = "root"
|
2019-10-30 23:28:54 +00:00
|
|
|
key = "$PUB_KEY"
|
2019-06-26 13:57:25 +00:00
|
|
|
|
|
|
|
__EOF__
|
2019-10-30 23:28:54 +00:00
|
|
|
rlRun -t -c "$CLI blueprints push $TMP_DIR/test-tar.toml"
|
2019-06-26 13:57:25 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose start"
|
|
|
|
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
|
2019-10-30 23:28:54 +00:00
|
|
|
UUID=$($CLI compose start test-tar tar)
|
2019-06-26 13:57:25 +00:00
|
|
|
rlAssertEquals "exit code should be zero" $? 0
|
|
|
|
|
2019-10-30 23:28:54 +00:00
|
|
|
UUID=$(echo "$UUID" | cut -f 2 -d' ')
|
2019-06-26 13:57:25 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose finished"
|
2019-10-30 23:28:54 +00:00
|
|
|
wait_for_compose "$UUID"
|
2019-06-26 13:57:25 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "Install tar image using kickstart liveimg command"
|
2019-10-30 23:28:54 +00:00
|
|
|
cat > "$TMP_DIR/test-liveimg.ks" << __EOF__
|
2019-06-26 13:57:25 +00:00
|
|
|
cmdline
|
|
|
|
lang en_US.UTF-8
|
|
|
|
timezone America/New_York
|
|
|
|
keyboard us
|
|
|
|
rootpw --lock
|
2019-10-30 23:28:54 +00:00
|
|
|
sshkey --username root "$PUB_KEY"
|
2019-06-26 13:57:25 +00:00
|
|
|
bootloader --location=mbr
|
|
|
|
zerombr
|
|
|
|
clearpart --initlabel --all
|
|
|
|
autopart
|
|
|
|
# reboot is used together with --no-reboot qemu-kvm parameter, which makes the qemu-kvm
|
|
|
|
# process exit after the installation is complete and anaconda reboots the system
|
|
|
|
# (using 'poweroff' ks command just halted the machine without powering it off)
|
|
|
|
reboot
|
|
|
|
|
2019-10-30 23:28:54 +00:00
|
|
|
liveimg --url file:///var/lib/lorax/composer/results/$UUID/root.tar.xz
|
2019-06-26 13:57:25 +00:00
|
|
|
|
|
|
|
__EOF__
|
2019-10-30 23:28:54 +00:00
|
|
|
# Build the disk image directly in the results directory
|
|
|
|
rlRun -t -c "mkdir -p /var/tmp/test-results/"
|
|
|
|
rlRun -t -c "fallocate -l 5G /var/tmp/test-results/disk.img"
|
2019-06-26 13:57:25 +00:00
|
|
|
|
2019-10-30 23:28:54 +00:00
|
|
|
rlLogInfo "Starting installation from tar image using anaconda"
|
|
|
|
rlRun -t -c "anaconda --image=/var/tmp/test-results/disk.img --kickstart=$TMP_DIR/test-liveimg.ks"
|
2019-06-26 13:57:25 +00:00
|
|
|
rlLogInfo "Installation of the image finished."
|
|
|
|
|
2019-10-30 23:28:54 +00:00
|
|
|
# Include the ssh key needed to log into the image
|
|
|
|
rlRun -t -c "cp $SSH_KEY_DIR/* /var/tmp/test-results"
|
2019-06-26 13:57:25 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartCleanup
|
2019-10-30 23:28:54 +00:00
|
|
|
rlRun -t -c "$CLI compose delete $UUID"
|
|
|
|
rlRun -t -c "rm -rf $TMP_DIR $SSH_KEY_DIR"
|
2019-06-26 13:57:25 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
rlJournalEnd
|
|
|
|
rlJournalPrintText
|