Skip to content

Commit 2ecc6a2

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

1 file changed

Lines changed: 85 additions & 3 deletions

File tree

qubes/tests/integ/vm_update.py

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

161+
ARCH_PACKAGE = [
162+
(b"pkgname=test-pkg\n"
163+
b"pkgver=1.0\n"
164+
b"pkgrel=1\n"
165+
b"arch=(any)\n"
166+
b"options=(\"!debug\")\n"
167+
),
168+
(b"pkgname=test-pkg\n"
169+
b"pkgver=1.1\n"
170+
b"pkgrel=1\n"
171+
b"arch=(any)\n"
172+
b"options=(\"!debug\")\n"
173+
),
174+
]
175+
161176
@classmethod
162177
def setUpClass(cls):
163178
super(VmUpdatesMixin, cls).setUpClass()
@@ -202,7 +217,7 @@ def setUp(self):
202217
"""
203218
if not self.template.count("debian") and not self.template.count(
204219
"fedora"
205-
):
220+
) and not self.template.count("archlinux"):
206221
self.skipTest(
207222
"Template {} not supported by this test".format(self.template)
208223
)
@@ -235,6 +250,14 @@ def setUp(self):
235250
self.install_test_cmd = "rpm -q {}"
236251
self.upgrade_test_cmd = "rpm -q {} | grep 1.1"
237252
self.ret_code_ok = [0, 100]
253+
elif self.template.count("archlinux"):
254+
self.update_cmd = "pacman -Syy"
255+
self.upgrade_cmd = "pacman -Syu --noconfirm"
256+
self.install_cmd = "pacman -Sy --noconfirm {}"
257+
self.install_test_cmd = "pacman -Q {}"
258+
self.upgrade_test_cmd = "pacman -Q {} | grep 1.1"
259+
self.ret_code_ok = [0]
260+
238261

239262
self.init_default_template(self.template)
240263
self.init_networking()
@@ -381,6 +404,33 @@ def create_repo_yum(self, version=0):
381404
self.netvm_repo.run_for_stdio("createrepo_c /tmp/yum-repo")
382405
)
383406

407+
def create_repo_arch(self, version=0):
408+
"""
409+
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
410+
:type version: int
411+
"""
412+
self.loop.run_until_complete(
413+
self.netvm_repo.run_for_stdio(
414+
"""mkdir -p /tmp/pkg \
415+
&& cd /tmp/pkg \
416+
&& cat > PKGBUILD \
417+
&& makepkg""",
418+
input=self.ARCH_PACKAGE[version]
419+
))
420+
pkg_file_name = "test-pkg-1.{}-1-any.pkg.tar.zst".format(version)
421+
self.loop.run_until_complete(
422+
self.netvm_repo.run_for_stdio(
423+
"""
424+
mkdir -p /tmp/arch-repo \
425+
&& cd /tmp/arch-repo \
426+
&& cp /tmp/pkg/{0} ./ \
427+
&& repo-add ./testrepo.db.tar.zst {0}
428+
""".format(
429+
pkg_file_name
430+
),
431+
)
432+
)
433+
384434
def create_repo_and_serve(self):
385435
"""
386436
:type self: qubes.tests.SystemTestCase | VmUpdatesMixin
@@ -405,6 +455,16 @@ def create_repo_and_serve(self):
405455
stderr=subprocess.DEVNULL,
406456
)
407457
)
458+
elif self.template.count("archlinux"):
459+
self.create_repo_arch()
460+
self.repo_proc = self.loop.run_until_complete(
461+
self.netvm_repo.run(
462+
"cd /tmp/arch-repo && python3 -m http.server 8080",
463+
stdin=subprocess.DEVNULL,
464+
stdout=subprocess.DEVNULL,
465+
stderr=subprocess.DEVNULL,
466+
)
467+
)
408468
else:
409469
# not reachable...
410470
self.skipTest(
@@ -426,6 +486,8 @@ def add_update_to_repo(self):
426486
self.create_repo_apt(1)
427487
elif self.template.count("fedora"):
428488
self.create_repo_yum(1)
489+
elif self.template.count("archlinux"):
490+
self.create_repo_arch(1)
429491

430492
def configure_test_repo(self):
431493
"""
@@ -458,6 +520,18 @@ def configure_test_repo(self):
458520
user="root",
459521
)
460522
)
523+
elif self.template.count("archlinux"):
524+
self.loop.run_until_complete(
525+
self.testvm1.run_for_stdio(
526+
"rm -f /etc/pacman.d/*.conf &&"
527+
"echo '[testrepo]' > /etc/pacman.d/70-test.conf &&"
528+
"echo 'SigLevel = Optional TrustAll'"
529+
" >> /etc/pacman.d/70-test.conf &&"
530+
"echo 'Server = http://localhost:8080/'"
531+
" >> /etc/pacman.d/70-test.conf",
532+
user="root",
533+
)
534+
)
461535
else:
462536
# not reachable...
463537
self.skipTest(
@@ -744,19 +818,27 @@ def test_121_updates_available_notification_qubes_vm_update_cli(self):
744818
)
745819

746820
def test_130_no_network_qubes_vm_update(self):
821+
expected_ret_codes = (23,)
822+
if self.template.count("archlinux"):
823+
# updater on Arch doesn't have separate metadata refresh step
824+
expected_ret_codes = (23,24,)
747825
self.update_via_proxy_qubes_vm_update_impl(
748826
method="qubes-vm-update",
749827
options=(),
750-
expected_ret_codes=(23,),
828+
expected_ret_codes=expected_ret_codes,
751829
break_repo=True,
752830
expect_updated=False,
753831
)
754832

755833
def test_131_no_network_qubes_vm_update_cli(self):
834+
expected_ret_codes = (23,)
835+
if self.template.count("archlinux"):
836+
# updater on Arch doesn't have separate metadata refresh step
837+
expected_ret_codes = (23,24,)
756838
self.update_via_proxy_qubes_vm_update_impl(
757839
method="qubes-vm-update",
758840
options=("--no-progress",),
759-
expected_ret_codes=(23,),
841+
expected_ret_codes=expected_ret_codes,
760842
break_repo=True,
761843
expect_updated=False,
762844
)

0 commit comments

Comments
 (0)