1 import ./make-test-python.nix ({ pkgs, ...} :
11 meta = with pkgs.lib.maintainers; {
12 maintainers = [ hexa ];
17 services.snapserver = {
27 location = "/run/snapserver/mpd";
28 query.mode = "create";
32 location = "/run/snapserver/bluetooth";
36 location = "127.0.0.1:${toString tcpStreamPort}";
40 location = "/mpd/bluetooth/tcp";
44 environment.systemPackages = [ pkgs.snapcast ];
47 environment.systemPackages = [ pkgs.snapcast ];
54 get_rpc_version = {"id": "1", "jsonrpc": "2.0", "method": "Server.GetRPCVersion"}
58 server.wait_for_unit("snapserver.service")
59 server.wait_until_succeeds("ss -ntl | grep -q ${toString port}")
60 server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpPort}")
61 server.wait_until_succeeds("ss -ntl | grep -q ${toString httpPort}")
62 server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpStreamPort}")
64 with subtest("check that pipes are created"):
65 server.succeed("test -p /run/snapserver/mpd")
66 server.succeed("test -p /run/snapserver/bluetooth")
68 with subtest("test tcp json-rpc"):
69 server.succeed(f"echo '{json.dumps(get_rpc_version)}' | nc -w 1 localhost ${toString tcpPort}")
71 with subtest("test http json-rpc"):
73 "curl --fail http://localhost:${toString httpPort}/jsonrpc -d '{json.dumps(get_rpc_version)}'"
76 with subtest("test a ipv6 connection"):
77 server.execute("systemd-run --unit=snapcast-local-client snapclient -h ::1 -p ${toString port}")
78 server.wait_until_succeeds(
79 "journalctl -o cat -u snapserver.service | grep -q 'Hello from'"
81 server.wait_until_succeeds("journalctl -o cat -u snapcast-local-client | grep -q 'buffer: ${toString bufferSize}'")
83 with subtest("test a connection"):
84 client.execute("systemd-run --unit=snapcast-client snapclient -h server -p ${toString port}")
85 server.wait_until_succeeds(
86 "journalctl -o cat -u snapserver.service | grep -q 'Hello from'"
88 client.wait_until_succeeds("journalctl -o cat -u snapcast-client | grep -q 'buffer: ${toString bufferSize}'")