Skip to content

Commit

Permalink
Merge pull request #4981 from jelly/allow-reboot
Browse files Browse the repository at this point in the history
webui: tests: extend the TestInstallationProgress test to include reboot
  • Loading branch information
KKoukiou authored Aug 8, 2023
2 parents 4e559a1 + 508c953 commit 76d3f3d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 28 deletions.
18 changes: 2 additions & 16 deletions ui/webui/test/check-basic
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import anacondalib
from installer import Installer
from language import Language
from review import Review
from utils import add_public_key
from testlib import nondestructive, test_main # pylint: disable=import-error


Expand Down Expand Up @@ -108,18 +109,7 @@ class TestBasic(anacondalib.VirtInstallMachineCase):
b.click(".pf-c-button[aria-label='Close Dialog']")
b.wait_not_present("#about-modal")

class TestQuit(anacondalib.VirtInstallMachineCase):

def testQuitInstallation(self):
b = self.browser
m = self.machine
i = Installer(b, m)

i.open()
i.quit()
m.wait_poweroff()


class TestBasicDestructive(anacondalib.VirtInstallMachineCase):
# TODO: Try converting this to a non-destructive test
def testErrorHandling(self):
b = self.browser
Expand All @@ -140,9 +130,5 @@ class TestQuit(anacondalib.VirtInstallMachineCase):
b.reload()
b.wait_visible("#critical-error-modal")

# Exit installer
b.click("#critical-error-modal .pf-c-button.pf-m-secondary")
m.wait_poweroff()

if __name__ == '__main__':
test_main()
9 changes: 9 additions & 0 deletions ui/webui/test/check-progress
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import anacondalib

from installer import Installer
from progress import Progress
from storage import Storage
from utils import add_public_key
from testlib import test_main # pylint: disable=import-error


Expand All @@ -29,7 +31,9 @@ class TestInstallationProgress(anacondalib.VirtInstallMachineCase):
self.allow_journal_messages(".*denied.*comm=\"tar\" name=\"/\".*")

b = self.browser
m = self.machine
i = Installer(b, self.machine)
p = Progress(b)
s = Storage(b, self.machine)

i.open()
Expand All @@ -49,5 +53,10 @@ class TestInstallationProgress(anacondalib.VirtInstallMachineCase):
wait_animations=False,
)

p.wait_done()
add_public_key(self.machine)
p.reboot()
m.wait_reboot()

if __name__ == '__main__':
test_main()
2 changes: 2 additions & 0 deletions ui/webui/test/check-review
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import anacondalib
from installer import Installer
from storage import Storage # pylint: disable=import-error
from review import Review
from progress import Progress
from utils import add_public_key
from testlib import nondestructive, test_main # pylint: disable=import-error


Expand Down
13 changes: 2 additions & 11 deletions ui/webui/test/helpers/end2end.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
from storage import Storage
from review import Review
from progress import Progress
from utils import add_public_key
from testlib import MachineCase # pylint: disable=import-error
from machine_install import VirtInstallMachine
from step_logger import log_step
Expand All @@ -51,16 +52,6 @@ def setUp(self):
os.makedirs(self.logs_dir)
os.environ["END2END"] = '1' # pylint: disable=environment-modify

def __add_public_key(self):
with open(self.machine.identity_file + '.pub', 'r') as pub:
public_key = pub.read()

sysroot_ssh = '/mnt/sysroot/root/.ssh'
authorized_keys = os.path.join(sysroot_ssh, 'authorized_keys')
self.machine.execute(fr'''mkdir -p {sysroot_ssh}
echo "{public_key}" >> {authorized_keys}
chmod 700 {sysroot_ssh}''')

def __download_logs(self):
self.machine.download('/tmp/anaconda.log', 'anaconda.log', self.logs_dir)
self.machine.download('/tmp/packaging.log', 'packaging.log', self.logs_dir)
Expand Down Expand Up @@ -88,7 +79,7 @@ def monitor_progress(self):
self._progress.wait_done()

def reboot_to_installed_system(self):
self.__add_public_key()
add_public_key(self.machine)
self.__download_logs()
self.__installation_finished = True
self._progress.reboot()
Expand Down
27 changes: 27 additions & 0 deletions ui/webui/test/helpers/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python3
#
# Copyright (C) 2023 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; If not, see <http://www.gnu.org/licenses/>.

import os

def add_public_key(machine):
with open(machine.identity_file + '.pub', 'r') as pub:
public_key = pub.read()

sysroot_ssh = '/mnt/sysroot/root/.ssh'
authorized_keys = os.path.join(sysroot_ssh, 'authorized_keys')
machine.execute(f"chmod 700 {sysroot_ssh}")
machine.write(authorized_keys, public_key, perm="0600")
3 changes: 2 additions & 1 deletion ui/webui/test/machine_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def start(self):
try:
self._execute(
"virt-install "
"--wait "
"--connect qemu:///session "
"--quiet "
f"--name {self.label} "
Expand All @@ -134,7 +135,7 @@ def start(self):
f"--initrd-inject {self.payload_ks_path} "
f"--extra-args 'inst.ks=file:/{os.path.basename(self.payload_ks_path)}' "
f"--disk path={disk_image},bus=virtio,cache=unsafe "
f"--location {os.getcwd()}/bots/images/{self.image}"
f"--location {os.getcwd()}/bots/images/{self.image} &"
)
Machine.wait_boot(self)

Expand Down

0 comments on commit 76d3f3d

Please sign in to comment.