cleanup in tests

This commit is contained in:
Qyriad 2026-02-18 14:01:39 +01:00
parent 6931853de3
commit f447fd0a99
5 changed files with 29 additions and 35 deletions

View file

@ -1,20 +1,6 @@
{ lib, modulesPath, ... }:
let
moduleList = import "${modulesPath}/module-list.nix";
{ ... }:
dynixFromSearchPath = let
res = builtins.tryEval <dynix>;
in lib.optional res.success res.value;
in
{
imports = [
#"${modulesPath}/testing/test-instrumentation.nix"
#./hardware-configuration.nix
] ++ lib.concatLists [
#dynixFromSearchPath
moduleList
];
dynamicism.for.harmonia.enable = true;
services.harmonia = {
enable = true;

View file

@ -1,6 +1,5 @@
import functools
from pathlib import Path
from pprint import pformat
import shlex
import textwrap
import tomllib
@ -72,12 +71,13 @@ def do_apply():
""".strip())
machine.wait_for_unit("default.target")
assert "lix" in machine.succeed("nix --version").lower()
machine.log("INIT")
machine.wait_for_unit("install-dynix.service")
dynix_out = machine.succeed("dynix --version")
assert "dynix" in dynix_out, f"dynix not in {dynix_out=}"
# Config should have our initial values.
config_toml = get_config_file()
machine.log(f"config.toml BEFORE first rebuild (initial): {indent(pformat(config_toml))}")
assert int(config_toml['workers']) == 4, f"{config_toml['workers']=} != 4"
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
@ -86,7 +86,6 @@ with machine.nested("must succeed: initial nixos-rebuild switch"):
# Config should not have changed.
config_toml = get_config_file()
machine.log(f"config.toml after first rebuild: {indent(pformat(config_toml))}")
assert int(config_toml['workers']) == 4, f"{config_toml['workers']=} != 4"
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
@ -96,7 +95,6 @@ do_apply()
# Workers, but not max connection rate, should have changed.
config_toml = get_config_file()
machine.log(f"config.toml after DYNAMIC ACTIVATION: {indent(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"
@ -104,16 +102,14 @@ new_max_connection_rate = 100
dynix_append("services.harmonia.settings.max_connection_rate", new_max_connection_rate)
do_apply()
# Max connection rate should have changed, but workers should have reverted.
# Max connection rate should have changed, and workers should be the same as before.
config_toml = get_config_file()
machine.log(f"config_toml after SECOND dynamic activation: {indent(pformat(config_toml))}")
assert int(config_toml['max_connection_rate']) == new_max_connection_rate, f"{config_toml['max_connection_rate']=} != {new_max_connection_rate}"
assert int(config_toml['workers']) == new_workers, f"{config_toml['workers']=} != {new_workers}"
# And this should set everything back.
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
machine.systemctl("restart harmonia.service")
machine.wait_for_unit("harmonia.service")
config_toml = get_config_file()
machine.log(f"config_toml after NORMAL activation: {indent(pformat(config_toml))}")
assert int(config_toml['max_connection_rate']) == 256, f'{config_toml["max_connection_rate"]=} != 256'
assert int(config_toml['workers']) == 4, f'{config_toml["workers"]=} != 4'