cleanup in tests
This commit is contained in:
parent
6931853de3
commit
f447fd0a99
5 changed files with 29 additions and 35 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
{ ... }:
|
{ ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
services.distccd = {
|
services.distccd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
jobTimeout = 900;
|
jobTimeout = 900;
|
||||||
maxJobs = 12;
|
maxJobs = 12;
|
||||||
|
logLevel = "warning";
|
||||||
nice = -10;
|
nice = -10;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,10 @@ def do_apply():
|
||||||
""".strip())
|
""".strip())
|
||||||
|
|
||||||
machine.wait_for_unit("default.target")
|
machine.wait_for_unit("default.target")
|
||||||
assert "lix" in machine.succeed("nix --version").lower()
|
machine.wait_for_unit("install-dynix.service")
|
||||||
machine.log("INIT")
|
|
||||||
|
dynix_out = machine.succeed("dynix --version")
|
||||||
|
assert "dynix" in dynix_out, f"dynix not in {dynix_out=}"
|
||||||
|
|
||||||
# Config should have our initial values.
|
# Config should have our initial values.
|
||||||
args = get_cli_args()
|
args = get_cli_args()
|
||||||
|
|
@ -99,17 +101,13 @@ args = get_cli_args()
|
||||||
assert args.jobs == 12, f'{args.jobs=} != 12'
|
assert args.jobs == 12, f'{args.jobs=} != 12'
|
||||||
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
||||||
assert args.log_level == 'warning', f'{args.log_level=} != warning'
|
assert args.log_level == 'warning', f'{args.log_level=} != warning'
|
||||||
#machine.log(f"config.toml after first rebuild: {indent(pformat(args))}")
|
|
||||||
#assert int(args['workers']) == 4, f"{args['workers']=} != 4"
|
|
||||||
#assert int(args['max_connection_rate']) == 256, f"{args['max_connection_rate']=} != 256"
|
|
||||||
|
|
||||||
new_jobs = 4
|
new_jobs = 4
|
||||||
dynix_append("services.distccd.maxJobs", new_jobs)
|
dynix_append("services.distccd.maxJobs", new_jobs)
|
||||||
do_apply()
|
do_apply()
|
||||||
|
|
||||||
args = get_cli_args()
|
|
||||||
|
|
||||||
# Only jobs should have changed. The others should still be default.
|
# Only jobs should have changed. The others should still be default.
|
||||||
|
args = get_cli_args()
|
||||||
assert args.jobs == new_jobs, f'{args.jobs=} != {new_jobs=}'
|
assert args.jobs == new_jobs, f'{args.jobs=} != {new_jobs=}'
|
||||||
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
||||||
assert args.log_level == 'warning', f'{args.log_level=} != warning'
|
assert args.log_level == 'warning', f'{args.log_level=} != warning'
|
||||||
|
|
@ -119,6 +117,13 @@ dynix_append("services.distccd.logLevel", f'"{new_log_level}"')
|
||||||
do_apply()
|
do_apply()
|
||||||
|
|
||||||
args = get_cli_args()
|
args = get_cli_args()
|
||||||
#assert args.jobs == new_jobs, f'{args.jobs=} != {new_jobs=}'
|
assert args.jobs == new_jobs, f'{args.jobs=} != {new_jobs=}'
|
||||||
#assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
||||||
assert args.log_level == new_log_level, f'{args.log_level=} != {new_log_level=}'
|
assert args.log_level == new_log_level, f'{args.log_level=} != {new_log_level=}'
|
||||||
|
|
||||||
|
# And this should set everything back.
|
||||||
|
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
|
||||||
|
args = get_cli_args()
|
||||||
|
assert args.jobs == 12, f'{args.jobs=} != 12'
|
||||||
|
assert args.job_lifetime == 900, f'{args.job_lifetime} != 900'
|
||||||
|
assert args.log_level == 'warning', f'{args.log_level=} != warning'
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,6 @@ def do_apply():
|
||||||
|
|
||||||
|
|
||||||
machine.wait_for_unit("default.target")
|
machine.wait_for_unit("default.target")
|
||||||
assert "lix" in machine.succeed("nix --version").lower()
|
|
||||||
machine.wait_for_unit("install-dynix.service")
|
machine.wait_for_unit("install-dynix.service")
|
||||||
|
|
||||||
dynix_out = machine.succeed("dynix --version")
|
dynix_out = machine.succeed("dynix --version")
|
||||||
|
|
@ -89,6 +88,12 @@ except StopIteration:
|
||||||
raise AssertionError(f"no 'application-name:' found in config file: {textwrap.indent(config_text, " ")}")
|
raise AssertionError(f"no 'application-name:' found in config file: {textwrap.indent(config_text, " ")}")
|
||||||
assert "gotosocial-for-machine" in application_name, f"'gotosocial-for-machine' should be in {application_name=}"
|
assert "gotosocial-for-machine" in application_name, f"'gotosocial-for-machine' should be in {application_name=}"
|
||||||
|
|
||||||
|
try:
|
||||||
|
host = next(line for line in lines if line.startswith("host:"))
|
||||||
|
except StopIteration:
|
||||||
|
raise AssertionError(f"no 'host:' found in config file: {textwrap.indent(config_text, " ")}")
|
||||||
|
assert "gotosocial-machine" in host, f"'gotosocial-machine' should be in {host=}"
|
||||||
|
|
||||||
new_app_name = "yay!"
|
new_app_name = "yay!"
|
||||||
dynix_append("services.gotosocial.settings.application-name", f'"{new_app_name}"')
|
dynix_append("services.gotosocial.settings.application-name", f'"{new_app_name}"')
|
||||||
do_apply()
|
do_apply()
|
||||||
|
|
|
||||||
|
|
@ -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;
|
dynamicism.for.harmonia.enable = true;
|
||||||
services.harmonia = {
|
services.harmonia = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
import functools
|
import functools
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pprint import pformat
|
|
||||||
import shlex
|
import shlex
|
||||||
import textwrap
|
import textwrap
|
||||||
import tomllib
|
import tomllib
|
||||||
|
|
@ -72,12 +71,13 @@ def do_apply():
|
||||||
""".strip())
|
""".strip())
|
||||||
|
|
||||||
machine.wait_for_unit("default.target")
|
machine.wait_for_unit("default.target")
|
||||||
assert "lix" in machine.succeed("nix --version").lower()
|
machine.wait_for_unit("install-dynix.service")
|
||||||
machine.log("INIT")
|
|
||||||
|
dynix_out = machine.succeed("dynix --version")
|
||||||
|
assert "dynix" in dynix_out, f"dynix not in {dynix_out=}"
|
||||||
|
|
||||||
# Config should have our initial values.
|
# Config should have our initial values.
|
||||||
config_toml = get_config_file()
|
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['workers']) == 4, f"{config_toml['workers']=} != 4"
|
||||||
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
|
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 should not have changed.
|
||||||
config_toml = get_config_file()
|
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['workers']) == 4, f"{config_toml['workers']=} != 4"
|
||||||
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
|
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.
|
# Workers, but not max connection rate, should have changed.
|
||||||
config_toml = get_config_file()
|
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['workers']) == new_workers, f"{config_toml['workers']=} != {new_workers}"
|
||||||
assert int(config_toml['max_connection_rate']) == 256, f"{config_toml['max_connection_rate']=} != 256"
|
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)
|
dynix_append("services.harmonia.settings.max_connection_rate", new_max_connection_rate)
|
||||||
do_apply()
|
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()
|
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['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.
|
# And this should set everything back.
|
||||||
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
|
machine.succeed("env PAGER= nixos-rebuild switch --log-format raw-with-logs --fallback")
|
||||||
machine.systemctl("restart harmonia.service")
|
|
||||||
machine.wait_for_unit("harmonia.service")
|
machine.wait_for_unit("harmonia.service")
|
||||||
config_toml = get_config_file()
|
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['max_connection_rate']) == 256, f'{config_toml["max_connection_rate"]=} != 256'
|
||||||
assert int(config_toml['workers']) == 4, f'{config_toml["workers"]=} != 4'
|
assert int(config_toml['workers']) == 4, f'{config_toml["workers"]=} != 4'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue