IT WORKS
This commit is contained in:
parent
da509d97c7
commit
3765e918d6
18 changed files with 348 additions and 226 deletions
|
|
@ -55,6 +55,27 @@ def get_config_file() -> dict[str, Any]:
|
|||
config_file_path.unlink()
|
||||
return config_data
|
||||
|
||||
@beartype
|
||||
def dynix_append(option: str, value: Any):
|
||||
machine.succeed(f'''
|
||||
dynix append {shlex.quote(option)} {shlex.quote(str(value))}
|
||||
'''.strip())
|
||||
|
||||
@beartype
|
||||
def do_apply():
|
||||
expr = textwrap.dedent("""
|
||||
let
|
||||
nixos = import <nixpkgs/nixos> { };
|
||||
in nixos.config.dynamicism.applyDynamicConfiguration {
|
||||
baseConfiguration = /etc/nixos/configuration.nix;
|
||||
newConfiguration = /etc/nixos/dynamic.nix;
|
||||
}
|
||||
""").strip()
|
||||
|
||||
machine.succeed(rf"""
|
||||
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
|
||||
""".strip())
|
||||
|
||||
machine.wait_for_unit("default.target")
|
||||
assert "lix" in machine.succeed("nix --version").lower()
|
||||
machine.log("INIT")
|
||||
|
|
@ -75,17 +96,8 @@ 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"
|
||||
|
||||
new_workers = 20
|
||||
expr = textwrap.dedent(f"""
|
||||
let
|
||||
nixos = import <nixpkgs/nixos> {{ }};
|
||||
in nixos.config.dynamicism.doChange {{
|
||||
option = "services.harmonia.settings.workers";
|
||||
value = {new_workers};
|
||||
}}
|
||||
""").strip()
|
||||
machine.succeed(rf"""
|
||||
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
|
||||
""".strip())
|
||||
dynix_append("services.harmonia.settings.workers", new_workers)
|
||||
do_apply()
|
||||
|
||||
# Workers, but not max connection rate, should have changed.
|
||||
config_toml = get_config_file()
|
||||
|
|
@ -94,17 +106,8 @@ assert int(config_toml['workers']) == new_workers, f"{config_toml['workers']=} !
|
|||
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
|
||||
|
||||
new_max_connection_rate = 100
|
||||
expr = textwrap.dedent(f"""
|
||||
let
|
||||
nixos = import <nixpkgs/nixos> {{ }};
|
||||
in nixos.config.dynamicism.doChange {{
|
||||
option = [ "services" "harmonia" "settings" "max_connection_rate" ];
|
||||
value = {new_max_connection_rate};
|
||||
}}
|
||||
""").strip()
|
||||
machine.succeed(rf"""
|
||||
nix run --show-trace --log-format raw-with-logs --impure -E {shlex.quote(expr)}
|
||||
""".strip())
|
||||
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.
|
||||
config_toml = get_config_file()
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
{ mkDynixConfigurationDotNix, config, ... }:
|
||||
let
|
||||
testName = config.name;
|
||||
in
|
||||
{
|
||||
name = "nixos-test-dynamicism-harmonia";
|
||||
|
||||
|
|
@ -6,21 +9,13 @@
|
|||
|
||||
extraPythonPackages = p: [ p.beartype ];
|
||||
|
||||
nodes.machine = { name, pkgs, ... }: {
|
||||
nodes.machine = { ... }: {
|
||||
imports = [ ./configuration.nix ];
|
||||
|
||||
environment.systemPackages = let
|
||||
#configFileTree = pkgs.runCommand "${name}-configuration-dot-nix" { } ''
|
||||
# set -euo pipefail
|
||||
# install -Dm a=r ${./configuration.nix} "$out/share/nixos/configuration.nix"
|
||||
#'';
|
||||
configFileTree = mkDynixConfigurationDotNix {
|
||||
inherit (config) name;
|
||||
configuration = ./configuration.nix;
|
||||
};
|
||||
in [
|
||||
configFileTree
|
||||
];
|
||||
passthru.configurationDotNix = mkDynixConfigurationDotNix {
|
||||
name = testName;
|
||||
configuration = ./configuration.nix;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = builtins.readFile ./test-script.py;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue