3
0
Fork 0
forked from mirrors/nixpkgs

nixos/tests/mediatomb: fix test when running with gerbera

This commit is contained in:
Fabian Möller 2022-09-05 17:06:54 +02:00
parent f3e08ac0b1
commit 86bfd15732
No known key found for this signature in database
GPG key ID: 70B29D65DD8A7E31

View file

@ -1,81 +1,44 @@
import ./make-test-python.nix ({ pkgs, ... }: import ./make-test-python.nix {
{
name = "mediatomb"; name = "mediatomb";
nodes = { nodes = {
serverGerbera = server = {
{ ... }: services.mediatomb = {
let port = 49152; enable = true;
in { serverName = "Gerbera";
imports = [ ../modules/profiles/minimal.nix ]; interface = "eth1";
services.mediatomb = { openFirewall = true;
enable = true; mediaDirectories = [
serverName = "Gerbera"; {
package = pkgs.gerbera; path = "/var/lib/gerbera/pictures";
interface = "eth1"; # accessible from test recursive = false;
openFirewall = true; hidden-files = false;
mediaDirectories = [ }
{ path = "/var/lib/gerbera/pictures"; recursive = false; hidden-files = false; } {
{ path = "/var/lib/gerbera/audio"; recursive = true; hidden-files = false; } path = "/var/lib/gerbera/audio";
]; recursive = true;
}; hidden-files = false;
}
];
}; };
systemd.tmpfiles.rules = [
"d /var/lib/gerbera/pictures 0770 mediatomb mediatomb"
"d /var/lib/gerbera/audio 0770 mediatomb mediatomb"
];
};
serverMediatomb = client = {};
{ ... }:
let port = 49151;
in {
imports = [ ../modules/profiles/minimal.nix ];
services.mediatomb = {
enable = true;
serverName = "Mediatomb";
package = pkgs.mediatomb;
interface = "eth1";
inherit port;
mediaDirectories = [
{ path = "/var/lib/mediatomb/pictures"; recursive = false; hidden-files = false; }
{ path = "/var/lib/mediatomb/audio"; recursive = true; hidden-files = false; }
];
};
networking.firewall.interfaces.eth1 = {
allowedUDPPorts = [ 1900 port ];
allowedTCPPorts = [ port ];
};
};
client = { ... }: { };
}; };
testScript = testScript = ''
''
start_all() start_all()
port = 49151 server.wait_for_unit("mediatomb")
serverMediatomb.succeed("mkdir -p /var/lib/mediatomb/{pictures,audio}") server.wait_until_succeeds("nc -z 192.168.1.2 49152")
serverMediatomb.succeed("chown -R mediatomb:mediatomb /var/lib/mediatomb") server.succeed("curl -v --fail http://server:49152/")
serverMediatomb.wait_for_unit("mediatomb")
serverMediatomb.wait_for_open_port(port)
serverMediatomb.succeed(f"curl --fail http://serverMediatomb:{port}/")
page = client.succeed(f"curl --fail http://serverMediatomb:{port}/")
assert "MediaTomb" in page and "Gerbera" not in page
serverMediatomb.shutdown()
port = 49152 client.wait_for_unit("multi-user.target")
serverGerbera.succeed("mkdir -p /var/lib/mediatomb/{pictures,audio}") page = client.succeed("curl -v --fail http://server:49152/")
serverGerbera.succeed("chown -R mediatomb:mediatomb /var/lib/mediatomb")
# service running gerbera fails the first time claiming something is already bound
# gerbera[715]: 2020-07-18 23:52:14 info: Please check if another instance of Gerbera or
# gerbera[715]: 2020-07-18 23:52:14 info: another application is running on port TCP 49152 or UDP 1900.
# I did not find anything so here I work around this
serverGerbera.succeed("sleep 2")
serverGerbera.wait_until_succeeds("systemctl restart mediatomb")
serverGerbera.wait_for_unit("mediatomb")
serverGerbera.succeed(f"curl --fail http://serverGerbera:{port}/")
page = client.succeed(f"curl --fail http://serverGerbera:{port}/")
assert "Gerbera" in page and "MediaTomb" not in page assert "Gerbera" in page and "MediaTomb" not in page
serverGerbera.shutdown()
client.shutdown()
''; '';
}) }