tests: Use the same asserts as before

after the changes around live-iso and qcow2 test cases the asserts
used have also changed. This commit utilizes the existing test lib.

Cherry-picked from d67745d755

Related: rhbz#1769525
This commit is contained in:
Alexander Todorov 2019-10-23 05:50:33 -04:00 committed by Alexander Todorov
parent 471adbd8de
commit 4a052314f4
5 changed files with 12 additions and 3 deletions

View File

@ -44,6 +44,10 @@ class TestQcow2(composertest.ComposerTestCase):
# Boot the image
self.setUpTestMachine(tmpdir + "/disk.qcow2", tmpdir + "/id_rsa")
# Upload SSH keys to the machine so we can use the existing assertions
# by ssh'ing to localhost
self.machine.upload([tmpdir + "/id_rsa", tmpdir + "/id_rsa.pub"], "/root/.ssh")
# Upload the contents of the ./tests/ directory to the machine
self.machine.upload(["../tests"], "/")
@ -87,6 +91,10 @@ class TestTar(composertest.ComposerTestCase):
# Boot the image, login using the ssh key
self.setUpTestMachine(tmpdir + "/disk.img", tmpdir + "/id_rsa")
# Upload SSH keys to the machine so we can use the existing assertions
# by ssh'ing to localhost
self.machine.upload([tmpdir + "/id_rsa", tmpdir + "/id_rsa.pub"], "/root/.ssh")
# Upload the contents of the ./tests/ directory to the machine
self.machine.upload(["../tests"], "/")

View File

@ -122,7 +122,7 @@ check_root_account() {
fi
if [ $ROOT_ACCOUNT_LOCKED == 0 ]; then
rlRun -t -c "ssh $SSH_OPTS ${SSH_USER}@${SSH_MACHINE} \"sudo grep '^root::' /etc/shadow\"" \
rlRun -t -c "ssh $SSH_OPTS ${SSH_USER}@${SSH_MACHINE} \"sudo passwd --status root | grep -E '^root\s+NP?'\"" \
0 "Password for root account in /etc/shadow is empty"
else
# ssh returns 255 in case of any ssh error, so it's better to grep the specific error message

View File

@ -15,7 +15,7 @@ set -e
rlJournalStart
rlPhaseStartTest "Verify live iso"
# Just the fact that this is running means the image can boot and ssh is working
rlRun -t -c "passwd --status root | grep -E '^root\s+NP?'" 0 "root account has no password set"
ROOT_ACCOUNT_LOCKED=0 verify_image liveuser localhost "-p 22"
rlAssertGrep "liveuser" /etc/passwd
rlAssertGrep "custom_cmdline_arg" /proc/cmdline
rlPhaseEnd

View File

@ -15,8 +15,8 @@ set -e
rlJournalStart
rlPhaseStartTest "Verify VM instance"
# Just the fact that this is running means the image can boot and ssh is working
verify_image root localhost "-p 22"
rlAssertExists "/root/.ssh/authorized_keys"
rlAssertGrep "custom_cmdline_arg" /proc/cmdline
rlPhaseEnd
rlJournalEnd
rlJournalPrintText

View File

@ -15,6 +15,7 @@ set -e
rlJournalStart
rlPhaseStartTest "Verify VM instance"
# Just the fact that this is running means the image can boot and ssh is working
CHECK_CMDLINE=0 verify_image root localhost "-p 22"
rlAssertExists "/root/.ssh/authorized_keys"
rlPhaseEnd
rlJournalEnd