Changeset 1050 for branches


Ignore:
Timestamp:
03/05/26 18:20:36 (10 hours ago)
Author:
Kris Deugau
Message:

/branches/stable

Merge baseline test suite changes

Location:
branches/stable
Files:
3 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/stable

  • branches/stable/Makefile

    r1047 r1050  
    115115        done
    116116
     117test:
     118        prove -I. --recurse t -v
     119
    117120#clean:
    118121#       @for i in $(DIRS) ; do \
  • branches/stable/t/DNSTest.pm

    • Property svn:keywords set to Date Rev Author Id
    r943 r1050  
    2121##
    2222
    23 package DNSDB::DNSTest;
     23package DNSTest;
    2424use strict;
    2525use warnings;
     26use Exporter;
     27use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
     28@ISA            = qw(Exporter);
     29@EXPORT         = qw($dnsdb $dbh);
    2630
    2731use Test::More;
     
    3236our $dnsdb;
    3337our $dbh;
     38our $debug;
    3439
    3540sub new {
     41  my $this = shift;
     42  my $class = ref($this) || $this;
     43  my %args = @_;
     44
    3645  $dnsdb = new DNSDB(
    3746        dbhost => 'localhost',
     
    4352  ok( $dnsdb->isa('DNSDB') );
    4453
     54  $debug = 1 if $args{debug};
     55
    4556  ## Prepare the DB
    4657  # 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.
    5859
    5960  $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()
    6187
    6288sub DESTROY {
  • branches/stable/t/dns-unitbase.sql

    r944 r1050  
    654654
    655655COPY public.domains (domain_id, domain, group_id, description, status, zserial, sertype, changed, default_location) FROM stdin;
     6561       example.com     1               1       2025123002      D       f       
    6566572       example.org     1               1       2025121800      D       f       ac
    6576583       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       
     6594       expiry1.test    1               1       1765992407      D       f       
    660660\.
    661661
     
    73473426      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
    73573527      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 example.dev 2025-12-17 12:26:47.718202-05   0       0
    737 29      4       1       1       admin   Initial User    [new example.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       28
    738 30      4       1       1       admin   Initial User    [new example.dev] Added record 'example.dev 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 example.dev] Added record 'example.dev 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 example.dev] Added record 'example.dev 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 example.dev] Added record 'example.dev 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 example.dev] Added record 'www.example.dev CNAME example.dev', TTL 10800   2025-12-17 12:26:47.718202-05   0       28
    743 35      4       1       1       admin   Initial User    [new example.dev] Added record 'example.dev TXT "v=spf1 a mx -all"', TTL 10800  2025-12-17 12:26:47.718202-05   0       28
     73628      4       1       1       admin   Initial User    Added active domain expiry1.test        2025-12-17 12:26:47.718202-05   0       0
     73729      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
     73830      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
     73931      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
     74032      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
     74133      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
     74234      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
     74335      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
    74474436      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
    74574537      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
     
    76076052      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
    76176153      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
     76255      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
    762763\.
    763764
     
    767768--
    768769
    769 SELECT pg_catalog.setval('public.log_log_id_seq', 53, true);
     770SELECT pg_catalog.setval('public.log_log_id_seq', 55, true);
    770771
    771772
     
    8298303       20      www.example.net 5       example.net     0       0       0       10800   \N      0       ab      1969-12-31 19:00:00-05  f       f       \N
    8308313       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.example.dev  6       10800:3600:604800:5400  0       0       0       86400   \N      0               1969-12-31 19:00:00-05  f       f       \N
    832 4       23      example.dev     2       ns2.example.com 0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
    833 4       24      example.dev     2       ns1.example.com 0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
    834 4       25      example.dev     1       10.0.0.4        0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
    835 4       26      example.dev     15      mx1.example.com 10      0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
    836 4       27      www.example.dev 5       example.dev     0       0       0       10800   \N      0               1969-12-31 19:00:00-05  f       f       \N
    837 4       28      example.dev     16      "v=spf1 a mx -all"      0       0       0       10800   \N      0               1969-12-31 19:00:00-05  f       f       \N
     8324       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
     8334       23      expiry1.test    2       ns2.example.com 0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
     8344       24      expiry1.test    2       ns1.example.com 0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
     8354       25      expiry1.test    1       10.0.0.4        0       0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
     8364       26      expiry1.test    15      mx1.example.com 10      0       0       7200    \N      0               1969-12-31 19:00:00-05  f       f       \N
     8374       27      www.expiry1.test        5       expiry1.test    0       0       0       10800   \N      0               1969-12-31 19:00:00-05  f       f       \N
     8384       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
    8388390       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
    8398400       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
     
    8448452       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
    8458462       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       \N
     8471       37      mail.example.com        5       mx1.example.com 0       0       0       900     \N      0               1969-12-31 19:00:00-05  f       f       \N
    8478481       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       \N
     8491       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
    8498501       40      webthing.example.com    5       example.com     0       0       0       5400    \N      0               1969-12-31 19:00:00-05  f       f       \N
    8508511       41      stuff.example.com       5       example.com     0       0       0       5400    \N      0               1969-12-31 19:00:00-05  f       f       \N
     
    8538540       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
    8548550       45      imma blocker!   16      192.168.2.17    0       0       0       2560    \N      1               1969-12-31 19:00:00-05  f       f       \N
     8560       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
    855857\.
    856858
     
    860862--
    861863
    862 SELECT pg_catalog.setval('public.records_record_id_seq', 45, true);
     864SELECT pg_catalog.setval('public.records_record_id_seq', 46, true);
    863865
    864866
     
    975977example.org     ac      1765992379      add
    976978example.net     ab      1765992395      add
    977 example.dev             1765992408      add
     979expiry1.test            1765992408      add
    9789802.168.192.in-addr.arpa          1765992449      add
    979981\.
     
    985987
    986988COPY 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       2025122301      D       t       
     9891       192.168.2.0/24  1               1       2026010700      D       t       
    988990\.
    989991
Note: See TracChangeset for help on using the changeset viewer.