Skip to content

Commit fbbf4f5

Browse files
committed
tests: update dom0 via salt too
Test if updating dom0 using salt works. QubesOS/qubes-issues#10543
1 parent a9a692a commit fbbf4f5

1 file changed

Lines changed: 45 additions & 14 deletions

File tree

qubes/tests/integ/dom0_update.py

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,7 @@ def start_repo(self):
283283
)
284284
self.repo_running = True
285285

286-
def test_000_update(self):
287-
"""Dom0 update tests
288-
289-
Check if package update is:
290-
- detected
291-
- installed
292-
- "updates pending" flag is cleared
293-
"""
294-
filename = self.create_pkg(self.tmpdir, self.pkg_name, "1.0")
295-
subprocess.check_call(["rpm", "-i", filename])
296-
filename = self.create_pkg(self.tmpdir, self.pkg_name, "2.0")
297-
self.send_pkg(filename)
298-
self.app.domains[0].features["updates-available"] = True
299-
286+
def update_func_direct(self):
300287
logpath = os.path.join(self.tmpdir, "dom0-update-output.txt")
301288
with open(logpath, "w") as f_log:
302289
proc = self.loop.run_until_complete(
@@ -315,6 +302,44 @@ def test_000_update(self):
315302
self.fail("qubes-dom0-update failed: " + f_log.read())
316303
del proc
317304

305+
def update_func_salt(self):
306+
logpath = os.path.join(self.tmpdir, "dom0-update-output.txt")
307+
with open(logpath, "w") as f_log:
308+
proc = self.loop.run_until_complete(
309+
asyncio.create_subprocess_exec(
310+
"qubesctl",
311+
"state.single",
312+
"pkg.uptodate",
313+
"update",
314+
"refresh=true",
315+
"fromrepo=test",
316+
stdout=f_log,
317+
stderr=subprocess.STDOUT,
318+
)
319+
)
320+
self.loop.run_until_complete(proc.wait())
321+
if proc.returncode:
322+
del proc
323+
with open(logpath) as f_log:
324+
self.fail("salt pkg.uptodate failed: " + f_log.read())
325+
del proc
326+
327+
def _test_000_update(self, do_update_func):
328+
"""Dom0 update tests
329+
330+
Check if package update is:
331+
- detected
332+
- installed
333+
- "updates pending" flag is cleared
334+
"""
335+
filename = self.create_pkg(self.tmpdir, self.pkg_name, "1.0")
336+
subprocess.check_call(["rpm", "-i", filename])
337+
filename = self.create_pkg(self.tmpdir, self.pkg_name, "2.0")
338+
self.send_pkg(filename)
339+
self.app.domains[0].features["updates-available"] = True
340+
341+
do_update_func()
342+
318343
retcode = subprocess.call(
319344
["rpm", "-q", "{}-1.0".format(self.pkg_name)],
320345
stdout=subprocess.DEVNULL,
@@ -340,6 +365,12 @@ def test_000_update(self):
340365
"'updates pending' flag not cleared",
341366
)
342367

368+
def test_000_update(self):
369+
self._test_000_update(self.update_func_direct)
370+
371+
def test_000_update_salt(self):
372+
self._test_000_update(self.update_func_salt)
373+
343374
def test_001_update_check(self):
344375
"""Check if dom0 updates check works"""
345376
self.app.domains[0].features["updates-available"] = False

0 commit comments

Comments
 (0)