tests: Add kickstart tar installation test
Related: rhbz#1733504
This commit is contained in:
parent
2795969126
commit
22acf067cd
1
Makefile
1
Makefile
@ -56,6 +56,7 @@ test_images:
|
||||
sudo -E ./tests/test_cli.sh tests/cli/test_compose_ext4-filesystem.sh \
|
||||
tests/cli/test_compose_partitioned-disk.sh \
|
||||
tests/cli/test_compose_tar.sh \
|
||||
tests/cli/test_compose_tar_kickstart.sh \
|
||||
tests/cli/test_compose_qcow2.sh \
|
||||
tests/cli/test_compose_live-iso.sh
|
||||
|
||||
|
@ -27,9 +27,6 @@ class TestImages(composertest.ComposerTestCase):
|
||||
def test_partitioned_disk(self):
|
||||
self.runCliTest("/tests/cli/test_compose_partitioned-disk.sh")
|
||||
|
||||
def test_tar(self):
|
||||
self.runCliTest("/tests/cli/test_compose_tar.sh")
|
||||
|
||||
|
||||
@unittest.skip('Disabled due to issues with nested KVM')
|
||||
class TestQcow2(composertest.ComposerTestCase):
|
||||
@ -43,5 +40,13 @@ class TestLiveIso(composertest.ComposerTestCase):
|
||||
self.runCliTest("/tests/cli/test_compose_live-iso.sh")
|
||||
|
||||
|
||||
class TestTar(composertest.ComposerTestCase):
|
||||
def test_tar(self):
|
||||
self.runCliTest("/tests/cli/test_compose_tar.sh")
|
||||
|
||||
def test_tar_kickstart(self):
|
||||
self.runCliTest("/tests/cli/test_compose_tar_kickstart.sh")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
composertest.main()
|
||||
|
2
test/run
2
test/run
@ -9,6 +9,8 @@ if [ -n "$TEST_SCENARIO" ]; then
|
||||
test/check-cli TestLiveIso
|
||||
elif [ "$TEST_SCENARIO" == "qcow2" ]; then
|
||||
test/check-cli TestQcow2
|
||||
elif [ "$TEST_SCENARIO" == "tar" ]; then
|
||||
test/check-cli TestTar
|
||||
else
|
||||
test/check-cloud TestCloud.test_$TEST_SCENARIO
|
||||
fi
|
||||
|
@ -16,14 +16,14 @@ if [ "$COMPOSER_TEST_FAIL_FAST" == "1" ]; then
|
||||
}
|
||||
fi
|
||||
|
||||
export QEMU_BIN="/usr/bin/qemu-system-$(uname -m)"
|
||||
export QEMU_BIN="/usr/libexec/qemu-kvm"
|
||||
export QEMU="$QEMU_BIN -machine accel=kvm:tcg"
|
||||
export SSH_PORT=2222
|
||||
|
||||
boot_image() {
|
||||
QEMU_BOOT=$1
|
||||
TIMEOUT=$2
|
||||
rlRun -t -c "$QEMU -m 2048 $QEMU_BOOT -nographic -monitor none \
|
||||
rlRun -t -c "$QEMU -m 2048 $QEMU_BOOT -nographic \
|
||||
-net user,id=nic0,hostfwd=tcp::$SSH_PORT-:22 -net nic &"
|
||||
# wait for ssh to become ready (yes, http is the wrong protocol, but it returns the header)
|
||||
tries=0
|
||||
|
130
tests/cli/test_compose_tar_kickstart.sh
Executable file
130
tests/cli/test_compose_tar_kickstart.sh
Executable file
@ -0,0 +1,130 @@
|
||||
#!/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
|
||||
rlAssertExists $QEMU_BIN
|
||||
if ! rlCheckRpm httpd; then
|
||||
yum -y install httpd
|
||||
fi
|
||||
systemctl start httpd
|
||||
|
||||
ks_path="/var/www/html/ks-tar.cfg"
|
||||
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)
|
||||
|
||||
bp_name="test-tar"
|
||||
blueprint="$bp_name.toml"
|
||||
cat > $blueprint << __EOF__
|
||||
name = "$bp_name"
|
||||
description = "tar image test"
|
||||
version = "0.0.1"
|
||||
modules = []
|
||||
|
||||
[[packages]]
|
||||
name = "openssh-server"
|
||||
version = "*"
|
||||
|
||||
[[groups]]
|
||||
name = "anaconda-tools"
|
||||
version = "*"
|
||||
|
||||
[[customizations.user]]
|
||||
name = "root"
|
||||
key = "$pub_key"
|
||||
|
||||
__EOF__
|
||||
rlRun -t -c "$CLI blueprints push $blueprint"
|
||||
image_path="/var/www/html/root.tar.xz"
|
||||
|
||||
version=$(awk -F = '$1 == "VERSION_ID" { print $2 }' /etc/os-release | tr -d \")
|
||||
arch=$(uname -m)
|
||||
baseurl="http://download.eng.bos.redhat.com/rel-eng/latest-RHEL-${version}/compose/Server/x86_64/os/"
|
||||
rlRun -t -c "curl --remote-name-all $baseurl/images/pxeboot/{vmlinuz,initrd.img}"
|
||||
|
||||
rlRun -t -c "fallocate -l 5G disk.img"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "compose start"
|
||||
rlAssertEquals "SELinux operates in enforcing mode" "$(getenforce)" "Enforcing"
|
||||
uuid=$($CLI compose start $bp_name tar)
|
||||
rlAssertEquals "exit code should be zero" $? 0
|
||||
|
||||
uuid=$(echo $uuid | cut -f 2 -d' ')
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "compose finished"
|
||||
if [ -n "$uuid" ]; then
|
||||
until $CLI compose status | grep -E "$uuid (FINISHED|FAILED)"; do
|
||||
sleep 60
|
||||
rlLogInfo "Waiting for compose to finish ..."
|
||||
done;
|
||||
else
|
||||
rlFail "Compose uuid is empty!"
|
||||
fi
|
||||
|
||||
rlRun -t -c "$CLI compose image $uuid"
|
||||
image="$uuid-root.tar.xz"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "Install tar image using kickstart liveimg command"
|
||||
cat > $ks_path << __EOF__
|
||||
cmdline
|
||||
lang en_US.UTF-8
|
||||
timezone America/New_York
|
||||
keyboard us
|
||||
rootpw --lock
|
||||
sshkey --username root "$pub_key"
|
||||
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
|
||||
|
||||
liveimg --url http://10.0.2.2/root.tar.xz
|
||||
|
||||
__EOF__
|
||||
mv $image $image_path
|
||||
restorecon $image_path
|
||||
rlLogInfo "Starting installation from tar image in a VM"
|
||||
$QEMU -m 2048 -drive file=disk.img,format=raw -nographic -kernel vmlinuz -initrd initrd.img \
|
||||
-append "inst.ks=http://10.0.2.2/ks-tar.cfg inst.stage2=$baseurl console=ttyS0" --no-reboot
|
||||
|
||||
rlLogInfo "Installation of the image finished."
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartTest "Boot and check the installed system"
|
||||
boot_image "-drive file=disk.img,format=raw" 600
|
||||
# run generic tests to verify the instance
|
||||
CHECK_CMDLINE=0 verify_image root localhost "-i $ssh_key_dir/id_rsa -p 2222"
|
||||
rlPhaseEnd
|
||||
|
||||
rlPhaseStartCleanup
|
||||
rlRun -t -c "killall -9 $QEMU_BIN"
|
||||
rlRun -t -c "rm -rf $image $blueprint $image_path vmlinuz initrd.img disk.img $ks_path"
|
||||
rlRun -t -c "$CLI blueprints delete $bp_name"
|
||||
rlRun -t -c "$CLI compose delete $uuid"
|
||||
rlRun -t -c "systemctl stop httpd"
|
||||
rlPhaseEnd
|
||||
|
||||
rlJournalEnd
|
||||
rlJournalPrintText
|
Loading…
Reference in New Issue
Block a user