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

@ -43,11 +43,13 @@ def run_log(machine: Machine, *commands: str, timeout: int | None = 60) -> str:
@beartype
def get_config_file() -> dict[str, Any]:
machine.wait_for_unit("harmonia.service")
pid = int(machine.get_unit_property("harmonia.service", "MainPID"))
env_lines: list[str] = machine.succeed(f"cat /proc/{pid}/environ").replace("\0", "\n").splitlines()
pairs: list[list[str]] = [line.split("=", maxsplit=1) for line in env_lines]
env = dict(pairs)
# FIXME: this doesn't work if any of the environment variables have spaces,
# but idk what else to do.
systemd_environ = machine.get_unit_property("harmonia.service", "Environment").split(" ")
pairs: list[list[str]] = [elem.split("=", maxsplit=1) for elem in systemd_environ]
env = dict(pairs)
config_file = Path(env["CONFIG_FILE"])
machine.log(f"copying from VM: {config_file=}")
@ -105,8 +107,6 @@ def run_all_tests(machine: Machine, *, use_daemon: bool):
run_log(machine, "systemctl start dynix-daemon.service")
machine.wait_for_unit("dynix-daemon.service")
machine.log("Checking initial harmonia.service conditions")
# Config should have our initial values.
config_toml = get_config_file()
assert int(config_toml['workers']) == 4, f"{config_toml['workers']=} != 4"
@ -127,8 +127,6 @@ def run_all_tests(machine: Machine, *, use_daemon: bool):
machine.log("Testing that workers, but not max_connection_rate, changed")
# Workers, but not max connection rate, should have changed.
config_toml = get_config_file()
from pprint import pformat
machine.log(pformat(config_toml))
assert int(config_toml['workers']) == new_workers, f"{config_toml['workers']=} != {new_workers}"
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"