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