lol

nixos/tests/slimserver: add end to end with squeezelite

+40 -5
+35 -4
nixos/tests/slimserver.nix
··· 4 4 5 5 nodes.machine = { ... }: { 6 6 services.slimserver.enable = true; 7 + services.squeezelite = { 8 + enable = true; 9 + extraArguments = "-s 127.0.0.1 -d slimproto=info"; 10 + }; 11 + sound.enable = true; 12 + boot.initrd.kernelModules = ["snd-dummy"]; 7 13 }; 8 14 9 15 testScript = 10 16 '' 11 - machine.wait_for_unit("slimserver.service") 12 - machine.wait_for_open_port(9000) 13 - machine.succeed("curl http://localhost:9000") 14 - machine.wait_until_succeeds("journalctl -eu slimserver.service | grep 'Completed dbOptimize Scan'") 17 + import json 18 + rpc_get_player = { 19 + "id": 1, 20 + "method": "slim.request", 21 + "params":[0,["player", "id", "0", "?"]] 22 + } 23 + 24 + with subtest("slimserver is started"): 25 + machine.wait_for_unit("slimserver.service") 26 + # give slimserver a moment to report errors 27 + machine.sleep(2) 28 + 29 + with subtest('slimserver module errors are not reported'): 30 + machine.fail("journalctl -u slimserver.service | grep 'throw_exception'") 31 + machine.fail("journalctl -u slimserver.service | grep 'not installed'") 32 + machine.fail("journalctl -u slimserver.service | grep 'not found'") 33 + machine.fail("journalctl -u slimserver.service | grep 'The following CPAN modules were found but cannot work with Logitech Media Server'") 34 + machine.fail("journalctl -u slimserver.service | grep 'please use the buildme.sh'") 35 + 36 + with subtest('slimserver is ready'): 37 + machine.wait_for_open_port(9000) 38 + machine.wait_until_succeeds("journalctl -u slimserver.service | grep 'Completed dbOptimize Scan'") 39 + 40 + with subtest("squeezelite player successfully connects to slimserver"): 41 + machine.wait_for_unit("squeezelite.service") 42 + machine.wait_until_succeeds("journalctl -u squeezelite.service | grep 'slimproto:937 connected'") 43 + player_mac = machine.wait_until_succeeds("journalctl -eu squeezelite.service | grep 'sendHELO:148 mac:'").strip().split(" ")[-1] 44 + player_id = machine.succeed(f"curl http://localhost:9000/jsonrpc.js -g -X POST -d '{json.dumps(rpc_get_player)}'") 45 + assert player_mac == json.loads(player_id)["result"]["_id"], "squeezelite player not found" 15 46 ''; 16 47 })
+5 -1
pkgs/applications/audio/squeezelite/default.nix
··· 22 22 , openssl 23 23 , portaudioSupport ? stdenv.isDarwin 24 24 , portaudio 25 + , slimserver 25 26 , AudioToolbox 26 27 , AudioUnit 27 28 , Carbon ··· 95 96 runHook postInstall 96 97 ''; 97 98 98 - passthru.updateScript = ./update.sh; 99 + passthru = { 100 + inherit (slimserver) tests; 101 + updateScript = ./update.sh; 102 + }; 99 103 100 104 meta = with lib; { 101 105 description = "Lightweight headless squeezebox client emulator";