Skip to content

Commit bb69882

Browse files
committed
tests: add support for testing updates of Archlinux template
1 parent f1896ae commit bb69882

1 file changed

Lines changed: 96 additions & 4 deletions

File tree

qubes/tests/integ/vm_update.py

Lines changed: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,23 @@ class VmUpdatesMixin(object):
158158
),
159159
]
160160

161+
ARCH_PACKAGE = [
162+
(
163+
b"pkgname=test-pkg\n"
164+
b"pkgver=1.0\n"
165+
b"pkgrel=1\n"
166+
b"arch=(any)\n"
167+
b'options=("!debug")\n'
168+
),
169+
(
170+
b"pkgname=test-pkg\n"
171+
b"pkgver=1.1\n"
172+
b"pkgrel=1\n"
173+
b"arch=(any)\n"
174+
b'options=("!debug")\n'
175+
),
176+
]
177+
161178
@classmethod
162179
def setUpClass(cls):
163180
super(VmUpdatesMixin, cls).setUpClass()
@@ -200,8 +217,10 @@ def setUp(self):
200217
"""
201218
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
202219
"""
203-
if not self.template.count("debian") and not self.template.count(
204-
"fedora"
220+
if (
221+
not self.template.count("debian")
222+
and not self.template.count("fedora")
223+
and not self.template.count("archlinux")
205224
):
206225
self.skipTest(
207226
"Template {} not supported by this test".format(self.template)
@@ -235,6 +254,13 @@ def setUp(self):
235254
self.install_test_cmd = "rpm -q {}"
236255
self.upgrade_test_cmd = "rpm -q {} | grep 1.1"
237256
self.ret_code_ok = [0, 100]
257+
elif self.template.count("archlinux"):
258+
self.update_cmd = "pacman -Syy"
259+
self.upgrade_cmd = "pacman -Syu --noconfirm"
260+
self.install_cmd = "pacman -Sy --noconfirm {}"
261+
self.install_test_cmd = "pacman -Q {}"
262+
self.upgrade_test_cmd = "pacman -Q {} | grep 1.1"
263+
self.ret_code_ok = [0]
238264

239265
self.init_default_template(self.template)
240266
self.init_networking()
@@ -381,6 +407,34 @@ def create_repo_yum(self, version=0):
381407
self.netvm_repo.run_for_stdio("createrepo_c /tmp/yum-repo")
382408
)
383409

410+
def create_repo_arch(self, version=0):
411+
"""
412+
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
413+
:type version: int
414+
"""
415+
self.loop.run_until_complete(
416+
self.netvm_repo.run_for_stdio(
417+
"""mkdir -p /tmp/pkg \
418+
&& cd /tmp/pkg \
419+
&& cat > PKGBUILD \
420+
&& makepkg""",
421+
input=self.ARCH_PACKAGE[version],
422+
)
423+
)
424+
pkg_file_name = "test-pkg-1.{}-1-any.pkg.tar.zst".format(version)
425+
self.loop.run_until_complete(
426+
self.netvm_repo.run_for_stdio(
427+
"""
428+
mkdir -p /tmp/arch-repo \
429+
&& cd /tmp/arch-repo \
430+
&& cp /tmp/pkg/{0} ./ \
431+
&& repo-add ./testrepo.db.tar.zst {0}
432+
""".format(
433+
pkg_file_name
434+
),
435+
)
436+
)
437+
384438
def create_repo_and_serve(self):
385439
"""
386440
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
@@ -405,6 +459,16 @@ def create_repo_and_serve(self):
405459
stderr=subprocess.DEVNULL,
406460
)
407461
)
462+
elif self.template.count("archlinux"):
463+
self.create_repo_arch()
464+
self.repo_proc = self.loop.run_until_complete(
465+
self.netvm_repo.run(
466+
"cd /tmp/arch-repo && python3 -m http.server 8080",
467+
stdin=subprocess.DEVNULL,
468+
stdout=subprocess.DEVNULL,
469+
stderr=subprocess.DEVNULL,
470+
)
471+
)
408472
else:
409473
# not reachable...
410474
self.skipTest(
@@ -426,6 +490,8 @@ def add_update_to_repo(self):
426490
self.create_repo_apt(1)
427491
elif self.template.count("fedora"):
428492
self.create_repo_yum(1)
493+
elif self.template.count("archlinux"):
494+
self.create_repo_arch(1)
429495

430496
def configure_test_repo(self):
431497
"""
@@ -458,6 +524,18 @@ def configure_test_repo(self):
458524
user="root",
459525
)
460526
)
527+
elif self.template.count("archlinux"):
528+
self.loop.run_until_complete(
529+
self.testvm1.run_for_stdio(
530+
"rm -f /etc/pacman.d/*.conf &&"
531+
"echo '[testrepo]' > /etc/pacman.d/70-test.conf &&"
532+
"echo 'SigLevel = Optional TrustAll'"
533+
" >> /etc/pacman.d/70-test.conf &&"
534+
"echo 'Server = http://localhost:8080/'"
535+
" >> /etc/pacman.d/70-test.conf",
536+
user="root",
537+
)
538+
)
461539
else:
462540
# not reachable...
463541
self.skipTest(
@@ -744,19 +822,33 @@ def test_121_updates_available_notification_qubes_vm_update_cli(self):
744822
)
745823

746824
def test_130_no_network_qubes_vm_update(self):
825+
expected_ret_codes = (23,)
826+
if self.template.count("archlinux"):
827+
# updater on Arch doesn't have separate metadata refresh step
828+
expected_ret_codes = (
829+
23,
830+
24,
831+
)
747832
self.update_via_proxy_qubes_vm_update_impl(
748833
method="qubes-vm-update",
749834
options=(),
750-
expected_ret_codes=(23,),
835+
expected_ret_codes=expected_ret_codes,
751836
break_repo=True,
752837
expect_updated=False,
753838
)
754839

755840
def test_131_no_network_qubes_vm_update_cli(self):
841+
expected_ret_codes = (23,)
842+
if self.template.count("archlinux"):
843+
# updater on Arch doesn't have separate metadata refresh step
844+
expected_ret_codes = (
845+
23,
846+
24,
847+
)
756848
self.update_via_proxy_qubes_vm_update_impl(
757849
method="qubes-vm-update",
758850
options=("--no-progress",),
759-
expected_ret_codes=(23,),
851+
expected_ret_codes=expected_ret_codes,
760852
break_repo=True,
761853
expect_updated=False,
762854
)

0 commit comments

Comments
 (0)