diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-18 22:35:46 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-18 22:35:46 +0200 |
| commit | b84c9c7382dc05d1ff5f3bdaf2bac7ce3c332007 (patch) | |
| tree | 42b64963341fc7e6251e16c68dfbdb4b3be54aa1 /tests/by-name/ru | |
| parent | scripts/update_hosts.sh: Use faster `nix copy` and ping hosts after update (diff) | |
| download | nixos-server-b84c9c7382dc05d1ff5f3bdaf2bac7ce3c332007.zip | |
tests: Refactor to unify tests and avoid duplicated code
Diffstat (limited to 'tests/by-name/ru')
| -rw-r--r-- | tests/by-name/ru/rust-motd/test.nix | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/tests/by-name/ru/rust-motd/test.nix b/tests/by-name/ru/rust-motd/test.nix index 6623c0c..43a905d 100644 --- a/tests/by-name/ru/rust-motd/test.nix +++ b/tests/by-name/ru/rust-motd/test.nix @@ -1,25 +1,11 @@ { - nixos-lib, - pkgsUnstable, - nixpkgs-unstable, - vhackPackages, - pkgs, extraModules, - nixLib, + vhack, ... }: -nixos-lib.runTest { - hostPkgs = pkgs; - +vhack.runTest { name = "rust-motd"; - node = { - specialArgs = {inherit pkgsUnstable extraModules vhackPackages nixpkgs-unstable nixLib;}; - - # Use the nixpkgs as constructed by the `nixpkgs.*` options - pkgs = null; - }; - nodes = { server = {config, ...}: { imports = @@ -34,29 +20,18 @@ nixos-lib.runTest { }; }; + services = [ + { + server = "rust-motd.service"; + start = true; + } + ]; + testScript = {nodes, ...}: - /* - python - */ + # Python '' - from time import sleep - - start_all() - - # Give the service time to run. - sleep(3) - - with subtest("All services running"): - import json - def all_services_running(host): - (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json") - host_failed = json.loads(output) - assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}" - all_services_running(server) - with subtest("Motd generated"): - sleep(1) - server.succeed("cat /var/lib/rust-motd/motd | tee /dev/stderr | grep --invert-match Error") + server.succeed("cat /var/lib/rust-motd/motd | tee /dev/stderr | grep --invert-match --ignore-case Error") server.copy_from_vm("/var/lib/rust-motd/motd") ''; |
