nixos/stirling-pdf: add integration tests

Co-authored-by: phanirithvij <phanirithvij2000@gmail.com>
This commit is contained in:
Tim Häring
2026-03-25 18:04:44 +01:00
co-authored by phanirithvij
parent fa1e5b6d79
commit 8a181e033c
4 changed files with 142 additions and 3 deletions
@@ -19,12 +19,13 @@ in
lib.types.oneOf [
lib.types.str
lib.types.int
lib.types.bool
]
);
default = { };
example = {
SERVER_PORT = 8080;
INSTALL_BOOK_AND_ADVANCED_HTML_OPS = "true";
INSTALL_BOOK_AND_ADVANCED_HTML_OPS = true;
};
description = ''
Environment variables for the stirling-pdf app.
@@ -44,7 +45,9 @@ in
config = lib.mkIf cfg.enable {
systemd.services.stirling-pdf = {
environment = lib.mapAttrs (_: toString) cfg.environment;
environment = lib.mapAttrs (
_: v: if (builtins.isBool v) then (lib.boolToString v) else (toString v)
) cfg.environment;
# following https://docs.stirlingpdf.com/Installation/Unix%20Installation
path =
+1
View File
@@ -1507,6 +1507,7 @@ in
stash = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stash.nix { };
static-web-server = runTest ./web-servers/static-web-server.nix;
step-ca = handleTestOn [ "x86_64-linux" ] ./step-ca.nix { };
stirling-pdf-desktop = runTest ./stirling-pdf-desktop.nix;
stratis = handleTest ./stratis { };
strongswan-swanctl = runTest ./strongswan-swanctl.nix;
stub-ld = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./stub-ld.nix { };
+131
View File
@@ -0,0 +1,131 @@
{ lib, hostPkgs, ... }:
let
port = 8080;
server = "http://server:${toString port}";
in
{
name = "stirling-pdf";
meta = {
maintainers = with lib.maintainers; [
timhae
phanirithvij
];
};
enableOCR = true;
globalTimeout = 600;
nodes = {
server =
{ config, pkgs, ... }:
{
services.stirling-pdf = {
enable = true;
package = pkgs.stirling-pdf;
environment = {
SERVER_PORT = port;
DISABLE_ADDITIONAL_FEATURES = false;
SECURITY_ENABLELOGIN = true;
};
};
networking.firewall.allowedTCPPorts = [ port ];
};
client =
{ config, pkgs, ... }:
{
virtualisation = {
memorySize = 4096;
cores = 4;
qemu.options = [
# Force qemu at 640x480 resolution
"-vga none -device virtio-gpu-pci,xres=640,yres=480"
];
};
imports = [ ./common/wayland-cage.nix ];
services.cage.program = lib.getExe pkgs.stirling-pdf-desktop;
systemd.tmpfiles.settings."stirling-provisioning.json"."/etc/stirling-pdf/stirling-provisioning.json"."L+".argument =
builtins.toString (
pkgs.writeText "stirling-provisioning.json" ''
{
"serverUrl": "${server}",
"lockConnectionMode": true
}
''
);
programs.ydotool.enable = true;
users.users.alice.extraGroups = [ "ydotool" ];
};
};
testScript = ''
server.start()
server.wait_for_unit("stirling-pdf.service")
server.wait_for_console_text("Stirling-PDF Started")
# initial login
client.start()
client.wait_for_text("Sign in to Server")
client.send_chars("admin", 0.1)
client.send_key("tab", 1)
client.send_chars("stirling\n", 0.1)
# skip telemetry prompt
client.wait_for_text("analytics")
client.send_key("shift-tab", 1)
client.send_key("tab", 1)
client.send_key("tab", 1)
client.send_key("kp_enter", 1)
# update password
client.wait_for_text("password")
client.send_key("tab", 1)
client.send_key("shift-tab", 1)
client.send_key("shift-tab", 1)
client.send_key("shift-tab", 1)
client.send_chars("stirling2", 0.1)
client.send_key("tab", 1)
client.send_chars("stirling2", 0.1)
client.send_key("tab", 1)
client.send_key("kp_enter", 1)
# final login
client.wait_for_text("Sign in to Server")
client.send_chars("admin", 0.1)
client.send_key("tab", 1)
client.send_chars("stirling2\n", 0.1)
client.wait_for_text("Welcome to Stirling")
client.send_key("kp_enter", 1)
# version prompt
client.wait_for_text("Config")
client.execute("ydotool mousemove -a -- 290 220") # Config button
client.execute("ydotool click 0xC0")
client.wait_for_text("Current Frontend Version")
client.screenshot("stirling-pdf-version")
'';
# Debug interactively with:
# - nix-build -A nixosTests.stirling-pdf-desktop.driverInteractive
# - ./result/bin/nixos-test-driver
# - run_tests()
# ssh -o User=root vsock%3 (can also do vsock/3, but % works with scp etc.)
interactive.sshBackdoor.enable = true;
interactive.nodes.client =
{ pkgs, ... }:
{
# make the mouse visible
services.cage.environment.WLR_NO_HARDWARE_CURSORS = "1";
};
interactive.nodes.server =
{ ... }:
{
virtualisation.forwardPorts = [
{
from = "host";
host.port = port;
guest.port = port;
}
];
# forwarded ports need to be accessible
networking.firewall.allowedTCPPorts = [ port ];
};
}
+5 -1
View File
@@ -21,6 +21,7 @@
webkitgtk_4_1,
nix-update-script,
nixosTests,
isDesktopVariant ? false,
buildWithFrontend ? !isDesktopVariant,
@@ -166,7 +167,10 @@ stdenv.mkDerivation (finalAttrs: {
ln -s ${jre} "$res_dir/runtime/jre"
'';
passthru.updateScript = nix-update-script { };
passthru = {
updateScript = nix-update-script { };
tests = { inherit (nixosTests) stirling-pdf-desktop; };
};
meta = {
changelog = "https://github.com/Stirling-Tools/Stirling-PDF/releases/tag/v${finalAttrs.version}";