Skip to content

Commit

Permalink
tests: fix testing qubes-vm-update error reporting
Browse files Browse the repository at this point in the history
Previously the expected_ret_codes applied to both qubes-vm-update and
later check if a package was updated (`rpm -q|grep ...` etc). With
unified qubes-vm-update exit codes, this approach is too broad as
qubes-vm-update is now expected to exit with very specific error, not
just "any error" - and this doesn't match grep's exit code anymore.
Fix this by adding another parameter for expected grep result (whether
updated package is expected or not).
  • Loading branch information
marmarek committed Jul 4, 2024
1 parent 2ed5a1e commit 212ff69
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions qubes/tests/integ/vm_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,8 @@ def update_via_proxy_qubes_vm_update_impl(
method="direct",
options=(),
expected_ret_codes=None,
break_repo=False
break_repo=False,
expect_updated=True,
):
"""
Test both whether updates proxy works and whether is actually used
Expand All @@ -502,6 +503,7 @@ def update_via_proxy_qubes_vm_update_impl(
:type options: tuple
:type expected_ret_codes: tuple
:type break_repo: bool
:type: expect_updated: bool
"""
if self.template.count("minimal"):
self.skipTest("Template {} not supported by this test".format(
Expand Down Expand Up @@ -545,7 +547,7 @@ def update_via_proxy_qubes_vm_update_impl(
self.assertRunCommandReturnCode(
self.testvm1,
self.upgrade_test_cmd.format('test-pkg'),
expected_ret_codes
(0,) if expect_updated else (1,)
)

def test_010_update_via_proxy(self):
Expand All @@ -570,13 +572,14 @@ def upgrade_status_notify(self):
))

def updates_available_notification_qubes_vm_update_impl(
self, method="direct", options=()):
self, method="direct", options=(), expect_updated=True):
"""
Test if updates-available flags is updated.
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
:type method: str
:type options: tuple
:type expect_updated: bool
"""
self.start_standalone_vm_with_repo()

Expand Down Expand Up @@ -608,7 +611,7 @@ def updates_available_notification_qubes_vm_update_impl(
self.assertRunCommandReturnCode(
self.testvm1,
self.upgrade_test_cmd.format('test-pkg'),
self.ret_code_ok
(0,) if expect_updated else (1,)
)

def test_020_updates_available_notification(self):
Expand Down Expand Up @@ -640,15 +643,17 @@ def test_130_no_network_qubes_vm_update(self):
method="qubes-vm-update",
options=(),
expected_ret_codes=(23,),
break_repo=True
break_repo=True,
expect_updated=False,
)

def test_131_no_network_qubes_vm_update_cli(self):
self.update_via_proxy_qubes_vm_update_impl(
method="qubes-vm-update",
options=("--no-progress",),
expected_ret_codes=(23,),
break_repo=True
break_repo=True,
expect_updated=False,
)


Expand Down

0 comments on commit 212ff69

Please sign in to comment.