Hello Clarity

For two weeks we've been working hard on defining a rather complex construct of DNS zone files, using multiple servers for multiple domains with cross referencing them and a lot of other complex-sounding terms.

We wrote DNS tests for the zones to make sure all the servers are configured correctly and the general DNS fetching provides correct information. This turned out to be quite difficult.

The original script is 130 lines. This is without taking into account even more testing we wanted. There was a lot of analyzing done which was rather repetitive and the overall code was ugly and not fun to read (to put it in mild terms). I decided to write a testing module for DNS zones - Test::DNS.

Using Test::DNS, we rewrote the script with a lot more options, which we wanted. The resulting script (with the addons) is 20 lines. It's clean and readable.

Here is how Test::DNS looks:

use Test::More tests => 5 * $num_of_domains;
use Test::DNS;
my $dns = Test::DNS->new();
foreach my $domain (@domains) {
# assuming $domain is an object
$dns->is_ptr( $domain->ns1 => $domain->ptr1 );
$dns->is_ptr( $domain->ns2 => $domain->ptr2 );

$dns->is_ns( $domain => [ map { "ns$_.$domain" } 1 .. 2 ] );

# assuming there's overloading here
$dns->is_a( "ns1.$domain" => $domain->ns1 );
$dns->is_a( "ns2.$domain" => $domain->ns2 );

}

Test::DNS will be available soon on CPAN.

Enjoy!

3 Comments

I'd be interested whether you have any thoughts on DNS::Oterica, our DNS zone file (well, djbdns tinydns-data file) generator.

Managing DNS is a pain!

Thanks for the report back! I know the documentation is sorely lacking -- but it's hard to get motivated to write docs when I feel so unsure it would get used anyway -- it's just a vicious cycle.

There are definitely some features we *know* are missing and vital, like better split horizons and reverse DNS. We had to omit those at the last minute to meet a deadline.

Someday, talk a little about the weird edge cases and I'll be able to keep them in mind when I do more work on the product.

Thanks again.

Leave a comment

About Sawyer X

user-pic Gots to do the bloggingz