Skip to content

Commit

Permalink
test: Clean up preload disabling/enabling
Browse files Browse the repository at this point in the history
Now that we have commit f0f4976 everywhere (Cockpit 265), we can
use overrides in /etc/cockpit/ instead of mucking around in /usr.
  • Loading branch information
martinpitt authored and mvollmer committed Feb 16, 2023
1 parent 435af12 commit e2ff6b8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 18 deletions.
16 changes: 6 additions & 10 deletions test/common/testlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,19 +1404,15 @@ def is_nondestructive(self):
def is_devel_build(self):
return os.environ.get('NODE_ENV') == 'development'

def disable_preload(self, *packages):
def disable_preload(self, *packages, machine=None):
if machine is None:
machine = self.machine
for pkg in packages:
path = "/usr/share/cockpit/%s" % pkg
if self.file_exists(path):
if self.machine.ostree_image:
# get a writable directory
self.restore_dir(path)
self.write_file("%s/override.json" % path, '{ "preload": [ ] }')
machine.write(f"/etc/cockpit/{pkg}.override.json", '{ "preload": [ ] }')

def enable_preload(self, package, *pages):
path = "/usr/share/cockpit/%s" % package
if self.file_exists(path):
self.write_file(path + '/override.json', '{ "preload": [%s]}' % ', '.join('"{0}"'.format(page) for page in pages))
pages_str = ', '.join(f'"{page}"' for page in pages)
self.machine.write(f"/etc/cockpit/{package}.override.json", f'{{ "preload": [ {pages_str} ] }}')

def system_before(self, version):
try:
Expand Down
3 changes: 1 addition & 2 deletions test/verify/check-shell-host-switching
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ class TestHostSwitching(MachineCase, HostSwitcherHelpers):
# In these tests we actually switch between machines in quick succession which can make things even worse
if self.is_devel_build():
for machine in ["machine2", "machine3"]:
for pkg in ["packagekit", "systemd", "playground"]:
self.machines[machine].write(f"/etc/cockpit/{pkg}.override.json", '{ "preload": [ ] }')
self.disable_preload("packagekit", "playground", "systemd", machine=self.machines[machine])
# Also, quick logouts cause async preloads to run into "ReferenceError: cockpit is not defined"
self.disable_preload("packagekit", "playground", "systemd")

Expand Down
6 changes: 2 additions & 4 deletions test/verify/check-shell-multi-machine
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ class TestMultiMachineAdd(MachineCase):
# Preloading on machines with debug build can overload the browser and cause slowness and browser crashes
# In these tests we actually switch between machines in quick succession which can make things even worse
if self.is_devel_build():
m.write("/etc/cockpit/packagekit.override.json", '{ "preload": [ ] }')
m.write("/etc/cockpit/systemd.override.json", '{ "preload": [ ] }')
self.disable_preload("packagekit", "playground", "systemd")

self.setup_ssh_auth()

Expand Down Expand Up @@ -277,8 +276,7 @@ class TestMultiMachine(MachineCase):
# Preloading on machines with debug build can overload the browser and cause slowness and browser crashes
# In these tests we actually switch between machines in quick succession which can make things even worse
if self.is_devel_build():
m.write("/etc/cockpit/packagekit.override.json", '{ "preload": [ ] }')
m.write("/etc/cockpit/systemd.override.json", '{ "preload": [ ] }')
self.disable_preload("packagekit", "playground", "systemd")

def checkDirectLogin(self, root='/', known_host=False):
b = self.browser
Expand Down
3 changes: 1 addition & 2 deletions test/verify/check-shell-multi-machine-key
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ class TestMultiMachineKeyAuth(MachineCase):
# Preloading on machines with debug build can overload the browser and cause slowness and browser crashes
# In these tests we actually switch between machines in quick succession which can make things even worse
if self.is_devel_build():
self.machine2.write("/etc/cockpit/packagekit.override.json", '{ "preload": [ ] }')
self.machine2.write("/etc/cockpit/systemd.override.json", '{ "preload": [ ] }')
self.disable_preload("packagekit", "playground", "systemd", machine=self.machine2)

# Possible workaround - ssh as `admin` and just do `m.execute()`
@skipBrowser("Firefox cannot do `cockpit.spawn`", "firefox")
Expand Down

0 comments on commit e2ff6b8

Please sign in to comment.