diff options
author | Florian Klink <flokli@flokli.de> | 2020-02-14 00:26:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-14 00:26:16 +0100 |
commit | 591fca255e9ade01b4066588513f87419248624b (patch) | |
tree | 4453aa9fdcbdc3adb91a4b4fe12e8de13a595ccf /nixos/tests | |
parent | b2f603e3bd7efc6be9d3ac0f15e0e284a192a016 (diff) | |
parent | de9bac3b86f69500e9a5293e235f0ec17bc2625d (diff) | |
download | nixlib-591fca255e9ade01b4066588513f87419248624b.tar nixlib-591fca255e9ade01b4066588513f87419248624b.tar.gz nixlib-591fca255e9ade01b4066588513f87419248624b.tar.bz2 nixlib-591fca255e9ade01b4066588513f87419248624b.tar.lz nixlib-591fca255e9ade01b4066588513f87419248624b.tar.xz nixlib-591fca255e9ade01b4066588513f87419248624b.tar.zst nixlib-591fca255e9ade01b4066588513f87419248624b.zip |
Merge pull request #80065 from tfc/port-nsd-test
nixosTests.nsd: Port to python
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/nsd.nix | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/nixos/tests/nsd.nix b/nixos/tests/nsd.nix index c3c91e71b5ca..bcc14e817a87 100644 --- a/nixos/tests/nsd.nix +++ b/nixos/tests/nsd.nix @@ -5,7 +5,7 @@ let # for a host utility with IPv6 support environment.systemPackages = [ pkgs.bind ]; }; -in import ./make-test.nix ({ pkgs, ...} : { +in import ./make-test-python.nix ({ pkgs, ...} : { name = "nsd"; meta = with pkgs.stdenv.lib.maintainers; { maintainers = [ aszlig ]; @@ -65,37 +65,35 @@ in import ./make-test.nix ({ pkgs, ...} : { }; testScript = '' - startAll; + start_all() - $clientv4->waitForUnit("network.target"); - $clientv6->waitForUnit("network.target"); - $server->waitForUnit("nsd.service"); + clientv4.wait_for_unit("network.target") + clientv6.wait_for_unit("network.target") + 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) { - subtest "ipv$_", sub { - assertHost($_, "a", "example.com", qr/has no [^ ]+ record/); - assertHost($_, "aaaa", "example.com", qr/has no [^ ]+ record/); + def assert_host(type, rr, query, expected): + self = clientv4 if type == 4 else clientv6 + out = self.succeed(f"host -{type} -t {rr} {query}").rstrip() + 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$/); - assertHost($_, "aaaa", "deleg.example.com", qr/address fedc::bbaa$/); + for ipv in 4, 6: + 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$/); - assertHost($_, "aaaa", "root", qr/address acbd::4$/); - }; - } + assert_host(ipv, "soa", "example.com", "SOA.*?noc\.example\.com") + 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$") ''; }) |