From c673e7ade966dc0371794eae2dcfb46830642a5a Mon Sep 17 00:00:00 2001 From: isabel Date: Mon, 17 Mar 2025 18:09:54 +0000 Subject: [PATCH] nixosTests.wakapi: migrate to runTest --- nixos/tests/all-tests.nix | 2 +- nixos/tests/wakapi.nix | 112 +++++++++++++++++++------------------- 2 files changed, 56 insertions(+), 58 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 27124bb953d7..35d6d0c0cfaa 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1295,7 +1295,7 @@ in { vscodium = discoverTests (import ./vscodium.nix); vsftpd = handleTest ./vsftpd.nix {}; waagent = handleTest ./waagent.nix {}; - wakapi = handleTest ./wakapi.nix {}; + wakapi = runTest ./wakapi.nix; warzone2100 = handleTest ./warzone2100.nix {}; wasabibackend = handleTest ./wasabibackend.nix {}; wastebin = handleTest ./wastebin.nix {}; diff --git a/nixos/tests/wakapi.nix b/nixos/tests/wakapi.nix index 1e2ea7105b4f..14b0a9b3ceb5 100644 --- a/nixos/tests/wakapi.nix +++ b/nixos/tests/wakapi.nix @@ -1,67 +1,65 @@ -import ./make-test-python.nix ( - { lib, ... }: - { - name = "Wakapi"; +{ lib, ... }: +{ + name = "Wakapi"; - nodes = { - wakapiPsql = { - services.wakapi = { - enable = true; - settings = { - server.port = 3000; # upstream default, set explicitly in case upstream changes it - db = { - dialect = "postgres"; # `createLocally` only supports postgres - host = "/run/postgresql"; - port = 5432; # service will fail if port is not set - name = "wakapi"; - user = "wakapi"; - }; + nodes = { + wakapiPsql = { + services.wakapi = { + enable = true; + settings = { + server.port = 3000; # upstream default, set explicitly in case upstream changes it + db = { + dialect = "postgres"; # `createLocally` only supports postgres + host = "/run/postgresql"; + port = 5432; # service will fail if port is not set + name = "wakapi"; + user = "wakapi"; }; - - # Automatically create our database - database.createLocally = true; # only works with Postgresql for now - - # Created with `cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1` - # Prefer passwordSaltFile in production. - passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; }; - }; - wakapiSqlite = { - services.wakapi = { - enable = true; - settings = { - server.port = 3001; - db = { - dialect = "sqlite3"; - name = "wakapi"; - user = "wakapi"; - }; - }; + # Automatically create our database + database.createLocally = true; # only works with Postgresql for now - passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; - }; + # Created with `cat /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1` + # Prefer passwordSaltFile in production. + passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; }; }; - # Test that service works under both postgresql and sqlite3 - # by starting all machines, and curling the default address. - # This is not very comprehensive for a test, but it should - # catch very basic mistakes in the module. - testScript = '' - with subtest("Test Wakapi with postgresql backend"): - wakapiPsql.start() - wakapiPsql.wait_for_unit("wakapi.service") - wakapiPsql.wait_for_open_port(3000) - wakapiPsql.succeed("curl --fail http://localhost:3000") + wakapiSqlite = { + services.wakapi = { + enable = true; + settings = { + server.port = 3001; + db = { + dialect = "sqlite3"; + name = "wakapi"; + user = "wakapi"; + }; + }; - with subtest("Test Wakapi with sqlite3 backend"): - wakapiSqlite.start() - wakapiSqlite.wait_for_unit("wakapi.service") - wakapiSqlite.wait_for_open_port(3001) - wakapiSqlite.succeed("curl --fail http://localhost:3001") - ''; + passwordSalt = "NpqCY7eY7fMoIWYmPx5mAgr6YoSlXSuI"; + }; + }; + }; - meta.maintainers = [ lib.maintainers.NotAShelf ]; - } -) + # Test that service works under both postgresql and sqlite3 + # by starting all machines, and curling the default address. + # This is not very comprehensive for a test, but it should + # catch very basic mistakes in the module. + testScript = '' + with subtest("Test Wakapi with postgresql backend"): + wakapiPsql.start() + wakapiPsql.wait_for_unit("wakapi.service") + wakapiPsql.wait_for_open_port(3000) + wakapiPsql.succeed("curl --fail http://localhost:3000") + + with subtest("Test Wakapi with sqlite3 backend"): + wakapiSqlite.start() + wakapiSqlite.wait_for_unit("wakapi.service") + wakapiSqlite.wait_for_open_port(3001) + wakapiSqlite.succeed("curl --fail http://localhost:3001") + ''; + + meta.maintainers = [ lib.maintainers.NotAShelf ]; +}