2019-02-27 13:01:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Note: execute this file from the project root directory
|
|
|
|
|
|
|
|
#####
|
|
|
|
#
|
|
|
|
# Builds live-iso image and test it with QEMU-KVM
|
|
|
|
#
|
|
|
|
#####
|
|
|
|
|
2019-06-17 12:35:31 +00:00
|
|
|
set -e
|
|
|
|
|
2019-02-27 13:01:28 +00:00
|
|
|
. /usr/share/beakerlib/beakerlib.sh
|
2019-06-17 12:35:31 +00:00
|
|
|
. $(dirname $0)/lib/lib.sh
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-03-08 10:29:11 +00:00
|
|
|
CLI="${CLI:-./src/bin/composer-cli}"
|
2019-02-27 13:01:28 +00:00
|
|
|
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartSetup
|
2019-08-02 12:01:30 +00:00
|
|
|
OPTIONAL_REPO="/etc/yum.repos.d/rhel7-rel-eng-optional.repo"
|
|
|
|
|
|
|
|
if [ ! -f "$OPTIONAL_REPO" ]; then
|
2019-11-11 13:17:41 +00:00
|
|
|
composer_stop
|
|
|
|
cat > $OPTIONAL_REPO << __EOF__
|
2019-08-02 12:01:30 +00:00
|
|
|
[rhel7-rel-eng-optional]
|
|
|
|
gpgcheck=0
|
|
|
|
enabled=1
|
|
|
|
skip_if_unavailable=0
|
|
|
|
name=rhel7-rel-eng-optional
|
|
|
|
baseurl=http://download-node-02.eng.bos.redhat.com/rhel-7/rel-eng/latest-RHEL-7/compose/Server-optional/\$basearch/os/
|
|
|
|
__EOF__
|
2019-11-11 13:17:41 +00:00
|
|
|
composer_start
|
2019-08-02 12:01:30 +00:00
|
|
|
fi
|
2019-02-27 13:01:28 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartTest "compose start"
|
|
|
|
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
|
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
TMP_DIR=$(mktemp -d /tmp/composer.XXXXX)
|
|
|
|
SSH_KEY_DIR=$(mktemp -d /tmp/composer-ssh-keys.XXXXXX)
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
rlRun -t -c "ssh-keygen -t rsa -N '' -f $SSH_KEY_DIR/id_rsa"
|
|
|
|
PUB_KEY=$(cat "$SSH_KEY_DIR/id_rsa.pub")
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
cat > "$TMP_DIR/with-ssh.toml" << __EOF__
|
|
|
|
name = "with-ssh"
|
|
|
|
description = "HTTP image with SSH"
|
|
|
|
version = "0.0.1"
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
[[packages]]
|
|
|
|
name = "httpd"
|
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[[packages]]
|
|
|
|
name = "openssh-server"
|
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[[packages]]
|
|
|
|
name = "beakerlib"
|
|
|
|
version = "*"
|
|
|
|
|
|
|
|
[customizations.services]
|
|
|
|
enabled = ["sshd"]
|
2019-02-27 13:01:28 +00:00
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
[[customizations.user]]
|
|
|
|
name = "root"
|
|
|
|
key = "$PUB_KEY"
|
|
|
|
|
|
|
|
[customizations.kernel]
|
2019-11-14 16:48:58 +00:00
|
|
|
append = "custom_cmdline_arg console=ttyS0,115200n8 console=tty0"
|
2019-10-15 23:48:13 +00:00
|
|
|
__EOF__
|
|
|
|
|
|
|
|
rlRun -t -c "$CLI blueprints push $TMP_DIR/with-ssh.toml"
|
|
|
|
|
|
|
|
# NOTE: live-iso.ks explicitly disables sshd but test_cli.sh enables it
|
|
|
|
UUID=$($CLI compose start with-ssh live-iso)
|
|
|
|
rlAssertEquals "exit code should be zero" $? 0
|
|
|
|
|
|
|
|
UUID=$(echo "$UUID" | cut -f 2 -d' ')
|
2019-02-27 13:01:28 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
2019-10-15 23:48:13 +00:00
|
|
|
rlPhaseStartTest "compose finished"
|
|
|
|
wait_for_compose "$UUID"
|
|
|
|
|
|
|
|
# Save the results for boot test
|
|
|
|
rlAssertExists "/var/lib/lorax/composer/results/$UUID/live.iso"
|
|
|
|
rlRun -t -c "mkdir -p /var/tmp/test-results/"
|
|
|
|
rlRun -t -c "cp /var/lib/lorax/composer/results/$UUID/live.iso /var/tmp/test-results/"
|
|
|
|
# Include the ssh key needed to log into the image
|
|
|
|
rlRun -t -c "cp $SSH_KEY_DIR/* /var/tmp/test-results"
|
2019-02-27 13:01:28 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlPhaseStartCleanup
|
|
|
|
rlRun -t -c "$CLI compose delete $UUID"
|
2019-10-15 23:48:13 +00:00
|
|
|
rlRun -t -c "rm -rf $OPTIONAL_REPO $TMP_DIR $SSH_KEY_DIR"
|
2019-02-27 13:01:28 +00:00
|
|
|
rlPhaseEnd
|
|
|
|
|
|
|
|
rlJournalEnd
|
|
|
|
rlJournalPrintText
|