[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Omaha.pm] Testing DNS servers



We're taking over DNS services for 113 domains on 3 new DNS servers w/ firewall mappings to the Internet.... How can I KNOW that everything is working?

I'm using Perl (surprise! -laugh-).

Now I can just run "prove -r" from inside and outside our networks and 180 tests pass or fail. Across 3 DNS servers it'll be some 600ish tests.

:)

j


e.g.:  dns_from_inside.t

use Test::More;

eval { require Sys::HostIP };
plan skip_all => "Sys::HostIP required" if $@;

my $ip_address = Sys::HostIP->ip;
if ($ip_address =~ /^10\./) {
   plan tests => 88;
} else {
plan skip_all => "You can only run these tests from inside the Omni network. Your IP: [$ip_address]";
}

my @servers = (
   '@10.0.64.14 -p53',    # royal
   '@10.0.33.164 -p53',  # omares-netservices
   # etc...
);

my @expect = qw(
   omnihotels.com                    A   63.241.199.252
   www.omnihotels.com                A   63.241.199.252
   omnihotels.com                    MX  mail.omnihotels.com
   # etc...
);

run_tests(\@servers, \@expect);

sub run_tests {
   my ($servers, $expect) = @_;
   for ($j = 0; $j < @$expect; $j += 3) {
      foreach my $server (@$servers) {
         my ($q, $type, $a) = @$expect[$j .. $j + 2];
         my $cmd = "dig $server $q $type +noall +answer";
         #print "[$cmd]\n";
         my $resp = `$cmd`;
         #print "[$resp]\n";
         ok($resp =~ /\Q$a\E/, "'$cmd' returns $a");
      }
   }
}