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!
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!
I'm sorry it took me time to respond. Managing DNS is indeed pain.
I've checked DNS::Oterica. It's hard to fully grasp its ability because of the lack of documentation and examples, but I think I understood the idea. It's got the basic stuff that needed, but we have more edge cases (that are considered common here) and we require much more metadata, replication-awareness, inheritance and (unfortunately) multiple inheritance or (hopefully) a wide variety of roles. It's nice to see DNS::Oterica already works on the concept of roles.
Overall, I don't think DNS::Oterica would be able to handle our edge cases without serious tweaking and changing. We're looking into using PowerDNS for our stuff. Perhaps it would be possible to use DNS::Oterica with the PowerDNS infrastructure (which is more than just zone files) with some adjustments.
It would definitely be easier than the current state where DNS zone files are created manually and edited manually (or using Perl one-liners) :(
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.