blob: c53a95903291c6a9b368c554da492bef9d9b76e7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
{ system ? builtins.currentSystem
, config ? {}
, pkgs ? import ../.. { inherit system config; }
# bool: whether to use networkd in the tests
, networkd ? false
} @ args:
# Test whether `avahi-daemon' and `libnss-mdns' work as expected.
import ./make-test-python.nix {
name = "avahi";
meta = with pkgs.lib.maintainers; {
maintainers = [ eelco ];
};
nodes = let
cfg = { ... }: {
services.avahi = {
enable = true;
nssmdns = true;
publish.addresses = true;
publish.domain = true;
publish.enable = true;
publish.userServices = true;
publish.workstation = true;
extraServiceFiles.ssh = "${pkgs.avahi}/etc/avahi/services/ssh.service";
};
} // pkgs.lib.optionalAttrs (networkd) {
networking = {
useNetworkd = true;
useDHCP = false;
};
};
in {
one = cfg;
two = cfg;
};
testScript = ''
start_all()
# mDNS.
one.wait_for_unit("network.target")
two.wait_for_unit("network.target")
one.succeed("avahi-resolve-host-name one.local | tee out >&2")
one.succeed('test "`cut -f1 < out`" = one.local')
one.succeed("avahi-resolve-host-name two.local | tee out >&2")
one.succeed('test "`cut -f1 < out`" = two.local')
two.succeed("avahi-resolve-host-name one.local | tee out >&2")
two.succeed('test "`cut -f1 < out`" = one.local')
two.succeed("avahi-resolve-host-name two.local | tee out >&2")
two.succeed('test "`cut -f1 < out`" = two.local')
# Basic DNS-SD.
one.succeed("avahi-browse -r -t _workstation._tcp | tee out >&2")
one.succeed("test `wc -l < out` -gt 0")
two.succeed("avahi-browse -r -t _workstation._tcp | tee out >&2")
two.succeed("test `wc -l < out` -gt 0")
# More DNS-SD.
one.execute('avahi-publish -s "This is a test" _test._tcp 123 one=1 >&2 &')
one.sleep(5)
two.succeed("avahi-browse -r -t _test._tcp | tee out >&2")
two.succeed("test `wc -l < out` -gt 0")
# NSS-mDNS.
one.succeed("getent hosts one.local >&2")
one.succeed("getent hosts two.local >&2")
two.succeed("getent hosts one.local >&2")
two.succeed("getent hosts two.local >&2")
# extra service definitions
one.succeed("avahi-browse -r -t _ssh._tcp | tee out >&2")
one.succeed("test `wc -l < out` -gt 0")
two.succeed("avahi-browse -r -t _ssh._tcp | tee out >&2")
two.succeed("test `wc -l < out` -gt 0")
'';
} args
|