Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: add support for testing updates of Archlinux template #648

Merged
merged 6 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions qubes/tests/integ/dom0_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ def start_repo(self):
self.repo_proc = self.loop.run_until_complete(
self.updatevm.run(
"cd /tmp/repo && python3 -m http.server 8080",
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.STDOUT,
)
Expand Down
2 changes: 1 addition & 1 deletion qubes/tests/integ/network_ipv6.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
class VmIPv6NetworkingMixin(VmNetworkingMixin):
test_ip6 = "2000:abcd::1"

ping6_cmd = "ping6 -W 1 -n -c 1 {target}"
ping6_cmd = "ping -6 -W 1 -n -c 1 {target}"

def setUp(self):
super(VmIPv6NetworkingMixin, self).setUp()
Expand Down
2 changes: 2 additions & 0 deletions qubes/tests/integ/salt.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ class SaltVMTestMixin(SaltTestMixin):
def setUp(self):
if self.template.startswith("whonix"):
self.skipTest("Whonix not supported as salt VM")
if self.template.startswith("archlinux"):
self.skipTest("Archlinux not supported as salt VM")
super(SaltVMTestMixin, self).setUp()
self.init_default_template(self.template)

Expand Down
4 changes: 3 additions & 1 deletion qubes/tests/integ/vm_qrexec_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ def test_011_run_gnome_terminal(self):
self.skipTest("Whonix template doesn't have 'gnome-terminal'")
if "xfce" in self.template:
self.skipTest("Xfce template doesn't have 'gnome-terminal'")
if "archlinux" in self.template:
self.skipTest("Arch template doesn't have 'gnome-terminal'")
self.loop.run_until_complete(self.testvm1.start())
self.assertEqual(self.testvm1.get_power_state(), "Running")
self.loop.run_until_complete(self.wait_for_session(self.testvm1))
p = self.loop.run_until_complete(
self.testvm1.run("gnome-terminal || " "ptyxis")
self.testvm1.run("gnome-terminal || ptyxis")
)
try:
title = "user@{}".format(self.testvm1.name)
Expand Down
102 changes: 98 additions & 4 deletions qubes/tests/integ/vm_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ class VmUpdatesMixin(object):
),
]

ARCH_PACKAGE = [
(
b"pkgname=test-pkg\n"
b"pkgver=1.0\n"
b"pkgrel=1\n"
b"arch=(any)\n"
b'options=("!debug")\n'
),
(
b"pkgname=test-pkg\n"
b"pkgver=1.1\n"
b"pkgrel=1\n"
b"arch=(any)\n"
b'options=("!debug")\n'
),
]

@classmethod
def setUpClass(cls):
super(VmUpdatesMixin, cls).setUpClass()
Expand Down Expand Up @@ -200,8 +217,10 @@ def setUp(self):
"""
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
"""
if not self.template.count("debian") and not self.template.count(
"fedora"
if (
not self.template.count("debian")
and not self.template.count("fedora")
and not self.template.count("archlinux")
):
self.skipTest(
"Template {} not supported by this test".format(self.template)
Expand Down Expand Up @@ -235,6 +254,13 @@ def setUp(self):
self.install_test_cmd = "rpm -q {}"
self.upgrade_test_cmd = "rpm -q {} | grep 1.1"
self.ret_code_ok = [0, 100]
elif self.template.count("archlinux"):
self.update_cmd = "pacman -Syy"
self.upgrade_cmd = "pacman -Syu --noconfirm"
self.install_cmd = "pacman -Sy --noconfirm {}"
self.install_test_cmd = "pacman -Q {}"
self.upgrade_test_cmd = "pacman -Q {} | grep 1.1"
self.ret_code_ok = [0]

self.init_default_template(self.template)
self.init_networking()
Expand Down Expand Up @@ -381,6 +407,34 @@ def create_repo_yum(self, version=0):
self.netvm_repo.run_for_stdio("createrepo_c /tmp/yum-repo")
)

def create_repo_arch(self, version=0):
"""
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
:type version: int
"""
self.loop.run_until_complete(
self.netvm_repo.run_for_stdio(
"""mkdir -p /tmp/pkg \
&& cd /tmp/pkg \
&& cat > PKGBUILD \
&& makepkg""",
input=self.ARCH_PACKAGE[version],
)
)
pkg_file_name = "test-pkg-1.{}-1-any.pkg.tar.zst".format(version)
self.loop.run_until_complete(
self.netvm_repo.run_for_stdio(
"""
mkdir -p /tmp/arch-repo \
&& cd /tmp/arch-repo \
&& cp /tmp/pkg/{0} ./ \
&& repo-add ./testrepo.db.tar.zst {0}
""".format(
pkg_file_name
),
)
)

def create_repo_and_serve(self):
"""
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
Expand All @@ -390,6 +444,7 @@ def create_repo_and_serve(self):
self.repo_proc = self.loop.run_until_complete(
self.netvm_repo.run(
"cd /tmp/apt-repo && python3 -m http.server 8080",
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
Expand All @@ -399,6 +454,17 @@ def create_repo_and_serve(self):
self.repo_proc = self.loop.run_until_complete(
self.netvm_repo.run(
"cd /tmp/yum-repo && python3 -m http.server 8080",
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
)
elif self.template.count("archlinux"):
self.create_repo_arch()
self.repo_proc = self.loop.run_until_complete(
self.netvm_repo.run(
"cd /tmp/arch-repo && python3 -m http.server 8080",
stdin=subprocess.DEVNULL,
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
Expand All @@ -424,6 +490,8 @@ def add_update_to_repo(self):
self.create_repo_apt(1)
elif self.template.count("fedora"):
self.create_repo_yum(1)
elif self.template.count("archlinux"):
self.create_repo_arch(1)

def configure_test_repo(self):
"""
Expand Down Expand Up @@ -456,6 +524,18 @@ def configure_test_repo(self):
user="root",
)
)
elif self.template.count("archlinux"):
self.loop.run_until_complete(
self.testvm1.run_for_stdio(
"rm -f /etc/pacman.d/*.conf &&"
"echo '[testrepo]' > /etc/pacman.d/70-test.conf &&"
"echo 'SigLevel = Optional TrustAll'"
" >> /etc/pacman.d/70-test.conf &&"
"echo 'Server = http://localhost:8080/'"
" >> /etc/pacman.d/70-test.conf",
user="root",
)
)
else:
# not reachable...
self.skipTest(
Expand Down Expand Up @@ -742,19 +822,33 @@ def test_121_updates_available_notification_qubes_vm_update_cli(self):
)

def test_130_no_network_qubes_vm_update(self):
expected_ret_codes = (23,)
if self.template.count("archlinux"):
# updater on Arch doesn't have separate metadata refresh step
expected_ret_codes = (
23,
24,
)
self.update_via_proxy_qubes_vm_update_impl(
method="qubes-vm-update",
options=(),
expected_ret_codes=(23,),
expected_ret_codes=expected_ret_codes,
break_repo=True,
expect_updated=False,
)

def test_131_no_network_qubes_vm_update_cli(self):
expected_ret_codes = (23,)
if self.template.count("archlinux"):
# updater on Arch doesn't have separate metadata refresh step
expected_ret_codes = (
23,
24,
)
self.update_via_proxy_qubes_vm_update_impl(
method="qubes-vm-update",
options=("--no-progress",),
expected_ret_codes=(23,),
expected_ret_codes=expected_ret_codes,
break_repo=True,
expect_updated=False,
)
Expand Down