- Timestamp:
- 03/05/26 18:20:36 (10 hours ago)
- Location:
- branches/stable
- Files:
-
- 3 edited
- 3 copied
-
. (modified) (1 prop)
-
Makefile (modified) (1 diff)
-
t (copied) (copied from trunk/t )
-
t/DNSTest.pm (modified) (3 diffs, 1 prop)
-
t/dns-unitbase.sql (copied) (copied from trunk/t/dns-unitbase.sql ) (10 diffs)
-
t/dropall.sql (copied) (copied from trunk/t/dropall.sql )
Legend:
- Unmodified
- Added
- Removed
-
branches/stable
- Property svn:mergeinfo changed
/trunk merged: 943-948,957,961,965,971,985
- Property svn:mergeinfo changed
-
branches/stable/Makefile
r1047 r1050 115 115 done 116 116 117 test: 118 prove -I. --recurse t -v 119 117 120 #clean: 118 121 # @for i in $(DIRS) ; do \ -
branches/stable/t/DNSTest.pm
-
Property svn:keywords
set to
Date Rev Author Id
r943 r1050 21 21 ## 22 22 23 package DNS DB::DNSTest;23 package DNSTest; 24 24 use strict; 25 25 use warnings; 26 use Exporter; 27 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); 28 @ISA = qw(Exporter); 29 @EXPORT = qw($dnsdb $dbh); 26 30 27 31 use Test::More; … … 32 36 our $dnsdb; 33 37 our $dbh; 38 our $debug; 34 39 35 40 sub new { 41 my $this = shift; 42 my $class = ref($this) || $this; 43 my %args = @_; 44 36 45 $dnsdb = new DNSDB( 37 46 dbhost => 'localhost', … … 43 52 ok( $dnsdb->isa('DNSDB') ); 44 53 54 $debug = 1 if $args{debug}; 55 45 56 ## Prepare the DB 46 57 # Check that we aren't in an obviously production DB before blowing it away. 47 # A DB instantiated for these tests should NEVER have more than a handful of domains and maybe 20-30 records. 48 49 my ($dcount) = $dbh->selectrow_array("SELECT count(*) FROM domains"); 50 BAIL_OUT("# DB looks like it may not be a test DB, found $dcount > 10 domains!\n") 51 if $dcount > 10; 52 cmp_ok( $dcount, '<=', 10, "domain count: looks like a test DB" ); 53 54 my ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records"); 55 BAIL_OUT("# DB looks like it may not be a test DB, found $rcount > 30 records!\n") 56 if $rcount > 30; 57 cmp_ok( $rcount, '<=', 30, "record count: looks like a test DB" ); 58 # A DB instantiated for these tests should have a known set of domains and records. 58 59 59 60 $dbh = $dnsdb->{dbh}; 60 } 61 62 my ($dcount) = $dbh->selectrow_array("SELECT count(*) FROM domains WHERE NOT domain IN ". 63 "('example.com','example.net','example.org','expiry1.test','expiry2.test')"); 64 BAIL_OUT("# DB looks like it may not be a test DB, found $dcount > 0 non-test domains!\n") 65 if $dcount > 0; 66 cmp_ok( $dcount, '==', 0, "non-test domain count ($dcount): looks like a test DB" ); 67 68 my ($rcount) = $dbh->selectrow_array(qq{SELECT count(*) FROM records WHERE NOT ( 69 host like '%example.com' or host like '%example.net' or host like '%example.org' or 70 host like '%expiry1.test' or host like '%expiry2.test' or inetlazy(val) << '192.168.2.0/27' 71 )}); 72 my $maxrecs = 0; 73 BAIL_OUT("# DB looks like it may not be a test DB, found $rcount > $maxrecs records!\n") 74 if $rcount > $maxrecs; 75 cmp_ok( $rcount, '<=', $maxrecs, "non-test record ($rcount): looks like a test DB" ); 76 77 # drop all tables etc 78 $ENV{PGPASSWORD} = $dnsdb->{dbpass}; 79 # neither diag or note seem to suppress output from qx 80 my $dropdata = qx( psql -h $dnsdb->{dbhost} -U $dnsdb->{dbuser} $dnsdb->{dbname} 2>&1 < t/dropall.sql ); 81 diag( $dropdata ) if $debug; 82 # load some standard test data 83 my $reload = qx( psql -h $dnsdb->{dbhost} -U $dnsdb->{dbuser} $dnsdb->{dbname} 2>&1 < t/dns-unitbase.sql ); 84 diag( $reload ) if $debug; 85 undef $ENV{PGPASSWORD}; 86 } # new() 61 87 62 88 sub DESTROY { -
Property svn:keywords
set to
-
branches/stable/t/dns-unitbase.sql
r944 r1050 654 654 655 655 COPY public.domains (domain_id, domain, group_id, description, status, zserial, sertype, changed, default_location) FROM stdin; 656 1 example.com 1 1 2025123002 D f 656 657 2 example.org 1 1 2025121800 D f ac 657 658 3 example.net 1 1 2025121800 D f ab 658 4 example.dev 1 1 1765992407 D f 659 1 example.com 1 1 2025122201 D t 659 4 expiry1.test 1 1 1765992407 D f 660 660 \. 661 661 … … 734 734 26 3 1 1 admin Initial User [new example.net] Added record 'www.example.net CNAME example.net', TTL 10800 2025-12-17 12:26:35.195757-05 0 20 735 735 27 3 1 1 admin Initial User [new example.net] Added record 'example.net TXT "v=spf1 a mx -all"', TTL 10800 2025-12-17 12:26:35.195757-05 0 20 736 28 4 1 1 admin Initial User Added active domain ex ample.dev2025-12-17 12:26:47.718202-05 0 0737 29 4 1 1 admin Initial User [new ex ample.dev] Added SOA record [contact ns1.example.com] [master hostmaster.example.dev] [refresh 10800] [retry 3600] [expire 604800] [minttl 5400], TTL 86400 2025-12-17 12:26:47.718202-05 0 28738 30 4 1 1 admin Initial User [new ex ample.dev] Added record 'example.devNS ns2.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28739 31 4 1 1 admin Initial User [new ex ample.dev] Added record 'example.devNS ns1.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28740 32 4 1 1 admin Initial User [new ex ample.dev] Added record 'example.devA 10.0.0.4', TTL 7200 2025-12-17 12:26:47.718202-05 0 28741 33 4 1 1 admin Initial User [new ex ample.dev] Added record 'example.devMX [distance 10] mx1.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28742 34 4 1 1 admin Initial User [new ex ample.dev] Added record 'www.example.dev CNAME example.dev', TTL 10800 2025-12-17 12:26:47.718202-05 0 28743 35 4 1 1 admin Initial User [new ex ample.dev] Added record 'example.devTXT "v=spf1 a mx -all"', TTL 10800 2025-12-17 12:26:47.718202-05 0 28736 28 4 1 1 admin Initial User Added active domain expiry1.test 2025-12-17 12:26:47.718202-05 0 0 737 29 4 1 1 admin Initial User [new expiry1.test] Added SOA record [contact ns1.example.com] [master hostmaster.expiry1.test] [refresh 10800] [retry 3600] [expire 604800] [minttl 5400], TTL 86400 2025-12-17 12:26:47.718202-05 0 28 738 30 4 1 1 admin Initial User [new expiry1.test] Added record 'expiry1.test NS ns2.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28 739 31 4 1 1 admin Initial User [new expiry1.test] Added record 'expiry1.test NS ns1.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28 740 32 4 1 1 admin Initial User [new expiry1.test] Added record 'expiry1.test A 10.0.0.4', TTL 7200 2025-12-17 12:26:47.718202-05 0 28 741 33 4 1 1 admin Initial User [new expiry1.test] Added record 'expiry1.test MX [distance 10] mx1.example.com', TTL 7200 2025-12-17 12:26:47.718202-05 0 28 742 34 4 1 1 admin Initial User [new expiry1.test] Added record 'www.expiry1.test CNAME expiry1.test', TTL 10800 2025-12-17 12:26:47.718202-05 0 28 743 35 4 1 1 admin Initial User [new expiry1.test] Added record 'expiry1.test TXT "v=spf1 a mx -all"', TTL 10800 2025-12-17 12:26:47.718202-05 0 28 744 744 36 0 1 1 admin Initial User Added active reverse zone 192.168.2.0/24 2025-12-17 12:27:28.623209-05 1 0 745 745 37 0 1 1 admin Initial User [new 192.168.2.0/24] Added SOA record [contact hostmaster.example.com] [master ns1.example.com] [refresh 3600] [retry 900] [expire 1048576] [minttl 2560], TTL 3600 2025-12-17 12:27:28.623209-05 1 0 … … 760 760 52 0 1 1 admin Initial User Added record '192.168.2.16 CNAME 16.16-29.2.168.192.in-addr.arpa', TTL 2560 2025-12-23 11:29:50.084066-05 1 0 761 761 53 0 1 1 admin Initial User Added record '192.168.2.17 TXT imma blocker!', TTL 2560 2025-12-23 13:06:20.492137-05 1 0 762 55 0 1 1 admin Initial User Added record '192.168.2.18 CNAME 18-2.arpa.example.com', TTL 2560 2026-01-07 16:37:03.094557-05 1 0 762 763 \. 763 764 … … 767 768 -- 768 769 769 SELECT pg_catalog.setval('public.log_log_id_seq', 5 3, true);770 SELECT pg_catalog.setval('public.log_log_id_seq', 55, true); 770 771 771 772 … … 829 830 3 20 www.example.net 5 example.net 0 0 0 10800 \N 0 ab 1969-12-31 19:00:00-05 f f \N 830 831 3 21 example.net 16 "v=spf1 a mx -all" 0 0 0 10800 \N 0 ab 1969-12-31 19:00:00-05 f f \N 831 4 22 ns1.example.com:hostmaster.ex ample.dev6 10800:3600:604800:5400 0 0 0 86400 \N 0 1969-12-31 19:00:00-05 f f \N832 4 23 ex ample.dev2 ns2.example.com 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N833 4 24 ex ample.dev2 ns1.example.com 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N834 4 25 ex ample.dev1 10.0.0.4 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N835 4 26 ex ample.dev15 mx1.example.com 10 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N836 4 27 www.ex ample.dev 5 example.dev0 0 0 10800 \N 0 1969-12-31 19:00:00-05 f f \N837 4 28 ex ample.dev16 "v=spf1 a mx -all" 0 0 0 10800 \N 0 1969-12-31 19:00:00-05 f f \N832 4 22 ns1.example.com:hostmaster.expiry1.test 6 10800:3600:604800:5400 0 0 0 86400 \N 0 1969-12-31 19:00:00-05 f f \N 833 4 23 expiry1.test 2 ns2.example.com 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N 834 4 24 expiry1.test 2 ns1.example.com 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N 835 4 25 expiry1.test 1 10.0.0.4 0 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N 836 4 26 expiry1.test 15 mx1.example.com 10 0 0 7200 \N 0 1969-12-31 19:00:00-05 f f \N 837 4 27 www.expiry1.test 5 expiry1.test 0 0 0 10800 \N 0 1969-12-31 19:00:00-05 f f \N 838 4 28 expiry1.test 16 "v=spf1 a mx -all" 0 0 0 10800 \N 0 1969-12-31 19:00:00-05 f f \N 838 839 0 29 hostmaster.example.com:ns1.example.com 6 3600:900:1048576:2560 0 0 0 3600 \N 1 1969-12-31 19:00:00-05 f f \N 839 840 0 30 ns2.example.com 2 192.168.2.0/24 0 0 0 7200 \N 1 1969-12-31 19:00:00-05 f f \N … … 844 845 2 35 %r.example.org 65283 192.168.2.8/29 0 0 0 2560 \N 1 1969-12-31 19:00:00-05 f f \N 845 846 2 36 floop.example.org 65280 192.168.2.14 0 0 0 2560 \N 1 1969-12-31 19:00:00-05 f f \N 846 1 37 mail.example.com 5 mx1.example.com 0 0 0 5400 \N 0 1969-12-31 19:00:00-05 f f \N847 1 37 mail.example.com 5 mx1.example.com 0 0 0 900 \N 0 1969-12-31 19:00:00-05 f f \N 847 848 1 38 mx1.example.com 16 v=spf1 ip4:192.168.2.42 0 0 0 5400 \N 0 1969-12-31 19:00:00-05 f f \N 848 1 39 smtp.example.com 1 192.168.2.11 0 0 0 5400 \N 0 1969-12-31 19:00:00-05 f f \N849 1 39 smtp.example.com 1 192.168.2.11 0 0 0 900 \N 0 1969-12-31 19:00:00-05 f f \N 849 850 1 40 webthing.example.com 5 example.com 0 0 0 5400 \N 0 1969-12-31 19:00:00-05 f f \N 850 851 1 41 stuff.example.com 5 example.com 0 0 0 5400 \N 0 1969-12-31 19:00:00-05 f f \N … … 853 854 0 44 16.16-29.2.168.192.in-addr.arpa 5 192.168.2.16 0 0 0 2560 \N 1 1969-12-31 19:00:00-05 f f \N 854 855 0 45 imma blocker! 16 192.168.2.17 0 0 0 2560 \N 1 1969-12-31 19:00:00-05 f f \N 856 0 46 18-2.arpa.example.com 5 192.168.2.18 0 0 0 2560 \N 1 1969-12-31 19:00:00-05 f f \N 855 857 \. 856 858 … … 860 862 -- 861 863 862 SELECT pg_catalog.setval('public.records_record_id_seq', 4 5, true);864 SELECT pg_catalog.setval('public.records_record_id_seq', 46, true); 863 865 864 866 … … 975 977 example.org ac 1765992379 add 976 978 example.net ab 1765992395 add 977 ex ample.dev1765992408 add979 expiry1.test 1765992408 add 978 980 2.168.192.in-addr.arpa 1765992449 add 979 981 \. … … 985 987 986 988 COPY public.revzones (rdns_id, revnet, group_id, description, status, zserial, sertype, changed, default_location) FROM stdin; 987 1 192.168.2.0/24 1 1 202 5122301D t989 1 192.168.2.0/24 1 1 2026010700 D t 988 990 \. 989 991
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)