Skip to content

Commit

Permalink
nixos/tests: add snapcast
Browse files Browse the repository at this point in the history
Checks
- if all configured ports are listened on
- if all pipes for multiple streams get set up
- if rpc interaction is possible
  • Loading branch information
mweinelt committed Aug 2, 2020
1 parent cc4f533 commit 0a9dd49
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 1 deletion.
1 change: 1 addition & 0 deletions nixos/tests/all-tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ in
simple = handleTest ./simple.nix {};
slurm = handleTest ./slurm.nix {};
smokeping = handleTest ./smokeping.nix {};
snapcast = handleTest ./snapcast.nix {};
snapper = handleTest ./snapper.nix {};
sogo = handleTest ./sogo.nix {};
solr = handleTest ./solr.nix {};
Expand Down
58 changes: 58 additions & 0 deletions nixos/tests/snapcast.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import ./make-test-python.nix ({ pkgs, ...} :

let
port = 10004;
tcpPort = 10005;
httpPort = 10080;
in {
name = "snapcast";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ hexa ];
};

nodes = {
server = {
services.snapserver = {
enable = true;
port = port;
tcp.port = tcpPort;
http.port = httpPort;
streams = {
mpd = {
type = "pipe";
location = "/run/snapserver/mpd";
};
bluetooth = {
type = "pipe";
location = "/run/snapserver/bluetooth";
};
};
};
};
};

testScript = ''
import json
get_rpc_version = {"id": "1", "jsonrpc": "2.0", "method": "Server.GetRPCVersion"}
start_all()
server.wait_for_unit("snapserver.service")
server.wait_until_succeeds("ss -ntl | grep -q ${toString port}")
server.wait_until_succeeds("ss -ntl | grep -q ${toString tcpPort}")
server.wait_until_succeeds("ss -ntl | grep -q ${toString httpPort}")
with subtest("check that pipes are created"):
server.succeed("test -p /run/snapserver/mpd")
server.succeed("test -p /run/snapserver/bluetooth")
with subtest("test tcp json-rpc"):
server.succeed(f"echo '{json.dumps(get_rpc_version)}' | nc -w 1 localhost ${toString tcpPort}")
with subtest("test http json-rpc"):
server.succeed(
"curl --fail http://localhost:${toString httpPort}/jsonrpc -d '{json.dumps(get_rpc_version)}'"
)
'';
})
5 changes: 4 additions & 1 deletion pkgs/applications/audio/snapcast/default.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{ stdenv, lib, fetchFromGitHub, cmake, pkgconfig
, alsaLib, asio, avahi, boost170, flac, libogg, libvorbis, soxr }:
, alsaLib, asio, avahi, boost170, flac, libogg, libvorbis, soxr
, nixosTests }:

let

Expand Down Expand Up @@ -57,6 +58,8 @@ stdenv.mkDerivation rec {
cp -r ../doc/* ../*.md $out/share/doc/snapcast
'';

passthru.tests.snapcast = nixosTests.snapcast;

meta = with lib; {
description = "Synchronous multi-room audio player";
homepage = "https://github.com/badaix/snapcast";
Expand Down

0 comments on commit 0a9dd49

Please sign in to comment.