nixos/tests/moonraker: init

This commit is contained in:
Zhaofeng Li 2022-03-22 15:35:39 -07:00
parent 0527ccaca7
commit b1431381d0
3 changed files with 51 additions and 2 deletions

View File

@ -307,6 +307,7 @@ in
molly-brown = handleTest ./molly-brown.nix {};
mongodb = handleTest ./mongodb.nix {};
moodle = handleTest ./moodle.nix {};
moonraker = handleTest ./moonraker.nix {};
morty = handleTest ./morty.nix {};
mosquitto = handleTest ./mosquitto.nix {};
moosefs = handleTest ./moosefs.nix {};

45
nixos/tests/moonraker.nix Normal file
View File

@ -0,0 +1,45 @@
import ./make-test-python.nix ({ pkgs, ...} : {
name = "moonraker";
meta = with pkgs.lib.maintainers; {
maintainers = [ zhaofengli ];
};
nodes = {
printer = { config, pkgs, ... }: {
security.polkit.enable = true;
services.moonraker = {
enable = true;
allowSystemControl = true;
settings = {
authorization = {
trusted_clients = [ "127.0.0.0/8" "::1/128" ];
};
};
};
services.klipper = {
enable = true;
user = "moonraker";
group = "moonraker";
# No mcu configured so won't even enter `ready` state
settings = {};
};
};
};
testScript = ''
printer.start()
printer.wait_for_unit("klipper.service")
printer.wait_for_unit("moonraker.service")
printer.wait_until_succeeds("curl http://localhost:7125/printer/info | grep -v 'Not Found' >&2", timeout=30)
with subtest("Check that we can perform system-level operations"):
printer.succeed("curl -X POST http://localhost:7125/machine/services/stop?service=klipper | grep ok >&2")
printer.wait_until_succeeds("systemctl --no-pager show klipper.service | grep ActiveState=inactive", timeout=10)
'';
})

View File

@ -1,4 +1,4 @@
{ lib, stdenvNoCC, fetchFromGitHub, python3, makeWrapper, unstableGitUpdater }:
{ lib, stdenvNoCC, fetchFromGitHub, python3, makeWrapper, unstableGitUpdater, nixosTests }:
let
pythonEnv = python3.withPackages (packages: with packages; [
@ -39,7 +39,10 @@ in stdenvNoCC.mkDerivation rec {
--add-flags "$out/lib/moonraker/moonraker.py"
'';
passthru.updateScript = unstableGitUpdater { url = meta.homepage; };
passthru = {
updateScript = unstableGitUpdater { url = meta.homepage; };
tests.moonraker = nixosTests.moonraker;
};
meta = with lib; {
description = "API web server for Klipper";