nixosTests.nsd: Port to python
This commit is contained in:
parent
21b31c4e51
commit
de9bac3b86
@ -5,7 +5,7 @@ let
|
|||||||
# for a host utility with IPv6 support
|
# for a host utility with IPv6 support
|
||||||
environment.systemPackages = [ pkgs.bind ];
|
environment.systemPackages = [ pkgs.bind ];
|
||||||
};
|
};
|
||||||
in import ./make-test.nix ({ pkgs, ...} : {
|
in import ./make-test-python.nix ({ pkgs, ...} : {
|
||||||
name = "nsd";
|
name = "nsd";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ aszlig ];
|
maintainers = [ aszlig ];
|
||||||
@ -65,37 +65,35 @@ in import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
start_all()
|
||||||
|
|
||||||
$clientv4->waitForUnit("network.target");
|
clientv4.wait_for_unit("network.target")
|
||||||
$clientv6->waitForUnit("network.target");
|
clientv6.wait_for_unit("network.target")
|
||||||
$server->waitForUnit("nsd.service");
|
server.wait_for_unit("nsd.service")
|
||||||
|
|
||||||
sub assertHost {
|
|
||||||
my ($type, $rr, $query, $expected) = @_;
|
|
||||||
my $self = $type eq 4 ? $clientv4 : $clientv6;
|
|
||||||
my $out = $self->succeed("host -$type -t $rr $query");
|
|
||||||
$self->log("output: $out");
|
|
||||||
chomp $out;
|
|
||||||
die "DNS IPv$type query on $query gave '$out' instead of '$expected'"
|
|
||||||
if ($out !~ $expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (4, 6) {
|
def assert_host(type, rr, query, expected):
|
||||||
subtest "ipv$_", sub {
|
self = clientv4 if type == 4 else clientv6
|
||||||
assertHost($_, "a", "example.com", qr/has no [^ ]+ record/);
|
out = self.succeed(f"host -{type} -t {rr} {query}").rstrip()
|
||||||
assertHost($_, "aaaa", "example.com", qr/has no [^ ]+ record/);
|
self.log(f"output: {out}")
|
||||||
|
assert re.search(
|
||||||
|
expected, out
|
||||||
|
), f"DNS IPv{type} query on {query} gave '{out}' instead of '{expected}'"
|
||||||
|
|
||||||
assertHost($_, "soa", "example.com", qr/SOA.*?noc\.example\.com/);
|
|
||||||
assertHost($_, "a", "ipv4.example.com", qr/address 1.2.3.4$/);
|
|
||||||
assertHost($_, "aaaa", "ipv6.example.com", qr/address abcd::eeff$/);
|
|
||||||
|
|
||||||
assertHost($_, "a", "deleg.example.com", qr/address 9.8.7.6$/);
|
for ipv in 4, 6:
|
||||||
assertHost($_, "aaaa", "deleg.example.com", qr/address fedc::bbaa$/);
|
with subtest(f"IPv{ipv}"):
|
||||||
|
assert_host(ipv, "a", "example.com", "has no [^ ]+ record")
|
||||||
|
assert_host(ipv, "aaaa", "example.com", "has no [^ ]+ record")
|
||||||
|
|
||||||
assertHost($_, "a", "root", qr/address 1.8.7.4$/);
|
assert_host(ipv, "soa", "example.com", "SOA.*?noc\.example\.com")
|
||||||
assertHost($_, "aaaa", "root", qr/address acbd::4$/);
|
assert_host(ipv, "a", "ipv4.example.com", "address 1.2.3.4$")
|
||||||
};
|
assert_host(ipv, "aaaa", "ipv6.example.com", "address abcd::eeff$")
|
||||||
}
|
|
||||||
|
assert_host(ipv, "a", "deleg.example.com", "address 9.8.7.6$")
|
||||||
|
assert_host(ipv, "aaaa", "deleg.example.com", "address fedc::bbaa$")
|
||||||
|
|
||||||
|
assert_host(ipv, "a", "root", "address 1.8.7.4$")
|
||||||
|
assert_host(ipv, "aaaa", "root", "address acbd::4$")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user