From 60518d6a5245bbd48b0d043549d6e22209474873 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 24 Dec 2023 22:23:15 +0100 Subject: [PATCH] nixos/pyload: init test --- nixos/tests/all-tests.nix | 1 + nixos/tests/pyload.nix | 33 +++++++++++++++++++ .../networking/pyload-ng/default.nix | 24 +++++++++----- 3 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 nixos/tests/pyload.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 25ee587e8f7a..fc1f047d42cf 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -387,6 +387,7 @@ in { installed-tests = pkgs.recurseIntoAttrs (handleTest ./installed-tests {}); invidious = handleTest ./invidious.nix {}; livebook-service = handleTest ./livebook-service.nix {}; + pyload = handleTest ./pyload.nix {}; oci-containers = handleTestOn ["aarch64-linux" "x86_64-linux"] ./oci-containers.nix {}; odoo = handleTest ./odoo.nix {}; odoo15 = handleTest ./odoo.nix { package = pkgs.odoo15; }; diff --git a/nixos/tests/pyload.nix b/nixos/tests/pyload.nix new file mode 100644 index 000000000000..f913e822b2ff --- /dev/null +++ b/nixos/tests/pyload.nix @@ -0,0 +1,33 @@ +import ./make-test-python.nix ({ lib, ... }: { + name = "pyload"; + meta.maintainers = with lib.maintainers; [ ambroisie ]; + + nodes = { + machine = { ... }: { + services.pyload = { + enable = true; + + listenAddress = "0.0.0.0"; + port = 9876; + }; + + networking.firewall.allowedTCPPorts = [ 9876 ]; + }; + + client = { }; + }; + + testScript = '' + start_all() + + machine.wait_for_unit("pyload.service") + + with subtest("Web interface accessible locally"): + machine.wait_until_succeeds("curl -fs localhost:9876") + + client.wait_for_unit("network.target") + + with subtest("Web interface accessible from a different machine"): + client.wait_until_succeeds("curl -fs machine:9876") + ''; +}) diff --git a/pkgs/applications/networking/pyload-ng/default.nix b/pkgs/applications/networking/pyload-ng/default.nix index eb0b6af94efe..1f638d43daef 100644 --- a/pkgs/applications/networking/pyload-ng/default.nix +++ b/pkgs/applications/networking/pyload-ng/default.nix @@ -1,4 +1,4 @@ -{ lib, fetchPypi, python3 }: +{ lib, fetchPypi, nixosTests, python3 }: python3.pkgs.buildPythonApplication rec { version = "0.5.0b3.dev75"; @@ -43,14 +43,20 @@ python3.pkgs.buildPythonApplication rec { setuptools ]; - passthru.optional-dependencies = { - plugins = with python3.pkgs; [ - beautifulsoup4 # for some plugins - colorlog # colorful console logging - pillow # for some CAPTCHA plugin - send2trash # send some files to trash instead of deleting them - slixmpp # XMPP plugin - ]; + passthru = { + optional-dependencies = { + plugins = with python3.pkgs; [ + beautifulsoup4 # for some plugins + colorlog # colorful console logging + pillow # for some CAPTCHA plugin + send2trash # send some files to trash instead of deleting them + slixmpp # XMPP plugin + ]; + }; + + tests = { + inherit (nixosTests) pyload; + }; }; meta = with lib; {