···
with subtest("Unit ${name} should be ${state}"):
17
-
machine.require_unit_state("${name}", "${state}")
17
+
if "${state}" == "active":
18
+
machine.wait_for_unit("${name}")
20
+
machine.require_unit_state("${name}", "${state}")
···
unit "atop.service" "active"
47
-
with subtest("atop.service should have written some data to /var/log/atop"):
48
-
files = int(machine.succeed("ls -1 /var/log/atop | wc -l"))
49
-
assert files > 0, "Expected at least 1 data file"
50
+
with subtest("atop.service should write some data to /var/log/atop"):
52
+
def has_data_files(last: bool) -> bool:
53
+
files = int(machine.succeed("ls -1 /var/log/atop | wc -l"))
55
+
machine.log("Did not find at least one 1 data file")
57
+
machine.log("Will retry...")
61
+
with machine.nested("Waiting for data files"):
62
+
retry(has_data_files)
'' else unit "atop.service" "inactive";
atopRotateTimer = present:
unit "atop-rotate.timer" (if present then "active" else "inactive");
···
unit "atopacct.service" "active"
with subtest("atopacct.service should enable process accounting"):
58
-
machine.succeed("test -f /run/pacct_source")
71
+
machine.wait_until_succeeds("test -f /run/pacct_source")
with subtest("atopacct.service should write data to /run/pacct_shadow.d"):
61
-
files = int(machine.succeed("ls -1 /run/pacct_shadow.d | wc -l"))
62
-
assert files >= 1, "Expected at least 1 pacct_shadow.d file"
75
+
def has_data_files(last: bool) -> bool:
76
+
files = int(machine.succeed("ls -1 /run/pacct_shadow.d | wc -l"))
78
+
machine.log("Did not find at least one 1 data file")
80
+
machine.log("Will retry...")
84
+
with machine.nested("Waiting for data files"):
85
+
retry(has_data_files)
'' else unit "atopacct.service" "inactive";