From 0aa6ecb08390dcbd13290f977e8fbdadf316b969 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Sat, 5 Apr 2025 18:29:55 +0200 Subject: [PATCH 1/2] nixosTests.calibre-web: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/calibre-web.nix | 74 ++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index c71655064c11..2dfcfabcd256 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -274,7 +274,7 @@ in cadvisor = handleTestOn [ "x86_64-linux" ] ./cadvisor.nix { }; cage = handleTest ./cage.nix { }; cagebreak = handleTest ./cagebreak.nix { }; - calibre-web = handleTest ./calibre-web.nix { }; + calibre-web = runTest ./calibre-web.nix; calibre-server = handleTest ./calibre-server.nix { }; canaille = handleTest ./canaille.nix { }; castopod = handleTest ./castopod.nix { }; diff --git a/nixos/tests/calibre-web.nix b/nixos/tests/calibre-web.nix index d14f1b540809..cf66ed1f1921 100644 --- a/nixos/tests/calibre-web.nix +++ b/nixos/tests/calibre-web.nix @@ -1,44 +1,42 @@ -import ./make-test-python.nix ( - { pkgs, lib, ... }: +{ lib, ... }: - let - port = 3142; - defaultPort = 8083; - in - { - name = "calibre-web"; - meta.maintainers = with lib.maintainers; [ pborzenkov ]; +let + port = 3142; + defaultPort = 8083; +in +{ + name = "calibre-web"; + meta.maintainers = with lib.maintainers; [ pborzenkov ]; - nodes = { - customized = - { pkgs, ... }: - { - services.calibre-web = { - enable = true; - listen.port = port; - options = { - calibreLibrary = "/tmp/books"; - reverseProxyAuth = { - enable = true; - header = "X-User"; - }; + nodes = { + customized = + { pkgs, ... }: + { + services.calibre-web = { + enable = true; + listen.port = port; + options = { + calibreLibrary = "/tmp/books"; + reverseProxyAuth = { + enable = true; + header = "X-User"; }; }; - environment.systemPackages = [ pkgs.calibre ]; }; - }; - testScript = '' - start_all() + environment.systemPackages = [ pkgs.calibre ]; + }; + }; + testScript = '' + start_all() - customized.succeed( - "mkdir /tmp/books && calibredb --library-path /tmp/books add -e --title test-book" - ) - customized.succeed("systemctl restart calibre-web") - customized.wait_for_unit("calibre-web.service") - customized.wait_for_open_port(${toString port}) - customized.succeed( - "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep test-book" - ) - ''; - } -) + customized.succeed( + "mkdir /tmp/books && calibredb --library-path /tmp/books add -e --title test-book" + ) + customized.succeed("systemctl restart calibre-web") + customized.wait_for_unit("calibre-web.service") + customized.wait_for_open_port(${toString port}) + customized.succeed( + "curl --fail -H X-User:admin 'http://localhost:${toString port}' | grep test-book" + ) + ''; +} From 38d86e4725804449cce4a38e3fc964ff5edc3f88 Mon Sep 17 00:00:00 2001 From: Piotr Kwiecinski <2151333+piotrkwiecinski@users.noreply.github.com> Date: Sat, 5 Apr 2025 18:35:52 +0200 Subject: [PATCH 2/2] nixosTests.calibre-server: migrate to runTest Part of #386873 --- nixos/tests/all-tests.nix | 2 +- nixos/tests/calibre-server.nix | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 2dfcfabcd256..3898413d2da1 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -275,7 +275,7 @@ in cage = handleTest ./cage.nix { }; cagebreak = handleTest ./cagebreak.nix { }; calibre-web = runTest ./calibre-web.nix; - calibre-server = handleTest ./calibre-server.nix { }; + calibre-server = import ./calibre-server.nix { inherit pkgs runTest; }; canaille = handleTest ./canaille.nix { }; castopod = handleTest ./castopod.nix { }; cassandra_3_0 = handleTest ./cassandra.nix { testPackage = pkgs.cassandra_3_0; }; diff --git a/nixos/tests/calibre-server.nix b/nixos/tests/calibre-server.nix index 2a04dd8cfba4..059058778526 100644 --- a/nixos/tests/calibre-server.nix +++ b/nixos/tests/calibre-server.nix @@ -1,11 +1,10 @@ { - system ? builtins.currentSystem, - config ? { }, - pkgs ? import ../.. { inherit system config; }, + pkgs, + runTest, + ... }: let - inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest; inherit (pkgs.lib) concatStringsSep maintainers @@ -74,7 +73,7 @@ let in mapAttrs ( test: testConfig: - (makeTest ( + (runTest ( let nodeName = testConfig.nodeName or test; calibreConfig = {