fix flakey tests

This commit is contained in:
Qyriad 2026-03-26 12:44:48 +01:00
parent 513627a677
commit ef1a6054ee
3 changed files with 49 additions and 23 deletions

View file

@ -41,15 +41,34 @@ def run_log(machine: Machine, *commands: str, timeout: int | None = 60) -> str:
return output
@beartype
def parse_systemd_exec(prop: str) -> str:
# idk why, but systemd exec lines are secretly DBus dictionaries,
# which `systemctl show -p` represents as an equals-delimited, semicolon-separated,
# key-value pair, all in curly braces. e.g.:
# { path=/nix/store/… ; argv[]=foobar ; ignore_errors=no ; … }
inside = prop.removeprefix('{ ').removesuffix(' }')
as_dict = dict()
for pair in inside.split(';'):
k, v = pair.split('=', maxsplit=1)
# They have whitespace around the equals but I don't think that's guaranteed.
as_dict[k.strip()] = v.strip()
# If argv is non-empty, use that entirely.
if argv := as_dict["argv[]"]:
return argv
# Otherwise, just use the path, I guess?
return as_dict["path"]
@beartype
def get_config_file() -> str:
machine.wait_for_unit("gotosocial.service")
gotosocial_pid = int(machine.get_unit_property("gotosocial.service", "MainPID"))
cmdline = machine.succeed(f"cat /proc/{gotosocial_pid}/cmdline")
cmdline_args = cmdline.split("\0")
execstart = machine.get_unit_property("gotosocial.service", "ExecStart")
cmdline_args = parse_systemd_exec(execstart).split()
config_file_idx = cmdline_args.index("--config-path") + 1
config_file = Path(cmdline_args[config_file_idx])
machine.log(f"copying from VM: {config_file=}")