github.com/teknogeek/dnscontrol@v0.2.8/providers/octodns/TESTING.md (about)

     1  # Testing:
     2  
     3  ## Create the environment.
     4  
     5  These variables are used in all other sections of this doc.
     6  
     7  ```
     8  export DNSCONFIGDIR=~/gitwork/fakeroot/ExternalDNS
     9  export OCTCONFIGDIR=~/gitwork/octodns/dns
    10  export SRCDIR=~/src/github.com/StackExchange/dnscontrol
    11  ```
    12  
    13  ## Code tests
    14  
    15  Unit tests:
    16  
    17  ```
    18  cd $SRCDIR/providers/octodns/octoyaml
    19  go test -v
    20  ```
    21  
    22  Integration tests:
    23  
    24  ```
    25  cd $SRCDIR/integrationTest
    26  go test -v -verbose -provider OCTODNS
    27  ```
    28  
    29  ## Test against OctoDNS-Validate
    30  
    31  ### Download OctoDNS:
    32  
    33  ```
    34  cd $DNSCONFIGDIR
    35  mkdir dns
    36  cd dns
    37  virtualenv env
    38  source env/bin/activate
    39  pip install octodns
    40  ln -s ~/gitwork/fakeroot/ExternalDNS/config config
    41  ```
    42  
    43  ### Modify dnsconfig.js
    44  
    45  Make a copy of dnsconfig.js and modify it to use OCTODNS as a provider. We did it this way:
    46  
    47  ```
    48  cd $DNSCONFIGDIR/dns
    49  cp ../dnsconfig.js .
    50  cp ../creds.json .
    51  ```
    52  
    53  Add:
    54  
    55  ```
    56  var OCT = NewDnsProvider("octodns", "OCTODNS");
    57  ```
    58  
    59  Add:
    60  
    61  ```
    62   DEFAULTS(
    63     DnsProvider(SERVERFAULT, 0),
    64  +  DnsProvider(OCT, 0),
    65     NAMESERVER_TTL("2d"),
    66   END);
    67  ```
    68  
    69  Add:
    70  
    71  ```
    72   var NO_BIND = function(d) {
    73     delete d.dnsProviders[SERVERFAULT];
    74  +  delete d.dnsProviders[OCT];
    75   };
    76  ```
    77  
    78  ## Run the tests:
    79  
    80  ### Step 1: Generate the files
    81  
    82  This builds the software then generates the yaml files in the config directory:
    83  
    84  ```
    85  (cd $SRCDIR && go install ) && cd $DNSCONFIGDIR/dns && rm -f config/*.yaml && dnscontrol push -providers=octodns
    86  ```
    87  
    88  ### Step 2: Run the validator:
    89  
    90  This runs octodns-validate against the YAMl files we generated.  production.yaml should
    91  list each domain.
    92  
    93  We create production.yaml like this:
    94  
    95  ```
    96  cd $DNSCONFIGDIR/dns && $SRCDIR/providers/octodns/mkprodyaml.sh
    97  ```
    98  
    99  Now we can run the validation:
   100  
   101  ```
   102  cd $DNSCONFIGDIR/dns
   103  cp $SRCDIR/providers/octodns/testdata/production.yaml config/. && env/bin/octodns-validate --log-stream-stdout
   104  ```