aboutsummaryrefslogtreecommitdiffstats
path: root/tests/default.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-19 22:53:34 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-07-19 22:53:34 +0200
commit4ee2db00225db217329b79294fc5a7e55a6ac808 (patch)
tree821d7028dd69d145b2e64c10a1454c5abc7aed71 /tests/default.nix
parenttests/common/acme: Start all test machines concurrently (diff)
downloadnixos-server-4ee2db00225db217329b79294fc5a7e55a6ac808.zip
tests/default.nix: Work around a race-condition in the acme cert waiting
Diffstat (limited to '')
-rw-r--r--tests/default.nix26
1 files changed, 21 insertions, 5 deletions
diff --git a/tests/default.nix b/tests/default.nix
index 48fa9ec..9bab516 100644
--- a/tests/default.nix
+++ b/tests/default.nix
@@ -136,21 +136,37 @@
return status == 0
wasAlive: bool
+ deadCounter: int
def run_and_wait(host, unit: str):
global wasAlive
+ global deadCounter
+
wasAlive = False
+ deadCounter = 0
+
def wait_state(_last_try: bool) -> bool:
global wasAlive
+ global deadCounter
state = host.get_unit_property(unit, "SubState")
- if state == "failed":
- assert False, f'Unit "{unit}" reached state "{state}"'
+ host.log(f"(waiting) {unit} -> {state}")
- if state == "start" or state == "active" or state == "running":
+ match state:
+ case "failed":
+ assert False, f'Unit "{unit}" reached state "{state}"'
+ case "start" | "active" | "running":
wasAlive = True
+ case "dead":
+ if wasAlive:
+ return True
+ else:
+ if deadCounter >= 5:
+ return True
- host.log(f"(waiting) {unit} -> {state}")
- return wasAlive and state == "dead"
+ deadCounter = deadCounter + 1
+ return False
+
+ return False
with host.nested(f"Waiting for unit {unit}"):
retry(wait_state)