2010-10-07 18:58:07 +02:00
|
|
|
{ pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs;
|
|
|
|
|
|
|
|
{
|
|
|
|
nodes = {
|
|
|
|
one =
|
|
|
|
{ config, pkgs, ... }: {
|
|
|
|
services.avahi.enable = true;
|
|
|
|
services.avahi.nssmdns = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
two =
|
|
|
|
{ config, pkgs, ... }: {
|
|
|
|
services.avahi.enable = true;
|
|
|
|
services.avahi.nssmdns = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Test whether `avahi-daemon' and `libnss-mdns' work as expected.
|
|
|
|
testScript =
|
|
|
|
'' startAll;
|
|
|
|
|
|
|
|
# mDNS.
|
2012-10-24 12:58:58 +02:00
|
|
|
$one->waitForJob("network.target");
|
2011-03-21 14:01:23 +01:00
|
|
|
$one->mustSucceed("avahi-resolve-host-name one.local | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$one->mustSucceed("test \"`cut -f1 < out`\" = one.local");
|
2011-03-21 14:01:23 +01:00
|
|
|
$one->mustSucceed("avahi-resolve-host-name two.local | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$one->mustSucceed("test \"`cut -f1 < out`\" = two.local");
|
|
|
|
|
2012-10-24 12:58:58 +02:00
|
|
|
$two->waitForJob("network.target");
|
2011-03-21 14:01:23 +01:00
|
|
|
$two->mustSucceed("avahi-resolve-host-name one.local | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$two->mustSucceed("test \"`cut -f1 < out`\" = one.local");
|
2011-03-21 14:01:23 +01:00
|
|
|
$two->mustSucceed("avahi-resolve-host-name two.local | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$two->mustSucceed("test \"`cut -f1 < out`\" = two.local");
|
|
|
|
|
|
|
|
# Basic DNS-SD.
|
2011-03-21 14:01:23 +01:00
|
|
|
$one->mustSucceed("avahi-browse -r -t _workstation._tcp | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$one->mustSucceed("test `wc -l < out` -gt 0");
|
2011-03-21 14:01:23 +01:00
|
|
|
$two->mustSucceed("avahi-browse -r -t _workstation._tcp | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$two->mustSucceed("test `wc -l < out` -gt 0");
|
|
|
|
|
|
|
|
# More DNS-SD.
|
|
|
|
$one->execute("avahi-publish -s \"This is a test\" _test._tcp 123 one=1 &");
|
2011-01-10 15:41:16 +01:00
|
|
|
$one->sleep(5);
|
2011-03-21 14:01:23 +01:00
|
|
|
$two->mustSucceed("avahi-browse -r -t _test._tcp | tee out >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
$two->mustSucceed("test `wc -l < out` -gt 0");
|
|
|
|
|
|
|
|
# NSS-mDNS.
|
2011-03-21 14:01:23 +01:00
|
|
|
$one->mustSucceed("getent hosts one.local >&2");
|
|
|
|
$one->mustSucceed("getent hosts two.local >&2");
|
|
|
|
$two->mustSucceed("getent hosts one.local >&2");
|
|
|
|
$two->mustSucceed("getent hosts two.local >&2");
|
2010-10-07 18:58:07 +02:00
|
|
|
'';
|
|
|
|
}
|