Package: pydnstest
pydnstestPython tool for testing DNS changes (add, remove, rename, change records)
against a staging DNS server, verifying the same changes against production,
or confirming that a record returns the same result in both environments.pydnstest is licensed under the GNU Affero General Public License version 3.RequirementsPython 2.7 or 3.4+ (currently tested with 2.7, 3.4, 3.5, 3.6)PythonVirtualEnvandpip(recommended installation method; your OS/distribution should have packages for these)orthe following packages:pydns(python2) orpy3dns(python3)pyparsingInstallationIt’s recommended that you install into a virtual environment (virtualenv /
venv). See thevirtualenv usage documentationfor information on how to create a venv. If you really want to install
system-wide, you can (using sudo).pipinstallpydnstestConfigurationEither runpydnstest--promptconfigto interactively build and write out a configuration file
(to~/.dnstest.ini) or runpydnstest--example-config>~/.dnstest.iniand edit the
resulting file as desired.You can view your current configuration with the--configprintoption.Usagepydnstest takes one or more specifications for DNS changes to be made, in a natural-language-like grammar, and tests a staging DNS server (and optionally verifies against a production/live server once the changes are live). For each specification, it prints out a simple one-line OK/NG summary, and optionally some helpful secondary messages and/or warnings. At the moment, it takes input either on STDIN or read from a file.The following usage examples all assume that you’ve installed pydnstest in a
virtualenv located at~/venv_dir. If you installed system-wide, simply
omit the first two lines (cd ~/venv_dirandsource bin/activate).Grammaradd[record|name|entry]<hostname_or_fqdn>[with][value|address|target]<hostname_fqdn_or_ip>remove[record|name|entry]<hostname_or_fqdn>rename[record|name|entry]<hostname_or_fqdn>[with][value|address|target]<value>to<hostname_or_fqdn>change[record|name|entry]<hostname_or_fqdn>to<hostname_fqdn_or_ip>confirm<hostname_or_fqdn>(checksthatTESTandPRODreturnidenticalresults)Sample input fileaddfoo.example.comwithaddress1.2.3.4removebar.example.comrenamebaz.example.comwithvalue1.2.3.5toblam.example.comchangequux.example.comto1.2.3.6confirmblam.example.comUsage with input fileWrite a test file with the following content, at ~/inputfile.txt:addrecordnewhost.example.comwithaddress10.188.8.90addrecordnewhost-console.example.comwithaddress10.188.15.90And then run the tests on it:jantman@phoenix$cd~/venv_dirjantman@phoenix$sourcebin/activate(venv_dir)jantman@phoenix$pydnstest-f~/inputfile.txtOK:newhost.example.com=>10.188.8.90(TEST)PRODserverreturnsNXDOMAINfornewhost.example.com(PROD)REVERSEOK:10.188.8.90=>newhost.example.com(TEST)OK:newhost-console.example.com=>10.188.15.90(TEST)PRODserverreturnsNXDOMAINfornewhost-console.example.com(PROD)REVERSEOK:10.188.15.90=>newhost-console.example.com(TEST)++++All2testspassed.(pydnstest0.1.0)Verify once in prodAfter making the above changes live, verify them in production:jantman@phoenix$cd~/venv_dirjantman@phoenix$sourcebin/activate(venv_dir)jantman@phoenix$pydnstest-f~/inputfile.txt-VOK:newhost.example.com=>10.188.8.90(PROD)REVERSEOK:10.188.8.90=>newhost.example.com(PROD)OK:newhost-console.example.com=>10.188.15.90(PROD)REVERSEOK:10.188.15.90=>newhost-console.example.com(PROD)++++All2testspassed.(pydnstest0.1.0)Run one quick testDo a quick one-off test passed in on stdin, to confirm that prod and test
return the same result for a given name:jantman@phoenix$cd~/venv_dirjantman@phoenix$sourcebin/activate(venv_dir)jantman@phoenix$echo"confirm foo.example.com"|pydnstestOK:prodandtestserversreturnsameresponsefor'foo.example.com'response:{'name':'foo.example.com','data':'10.10.8.2','typename':'A','classstr':'IN','ttl':360,'type':1,'class':1,'rdlength':4}++++All1testspassed.(pydnstest0.1.0)Run interactively from STDINYou can also provide test data on STDIN. This is mainly useful when pulling test data
from another file, such as:jantman@phoenix:pts/12:~/tmp$catsample_zone.txt$ORIGINexample.com.;PYDNSTESTaddrecordfoo.example.comwithaddress10.10.8.2fooINA10.10.8.2;PYDNSTESTaddrecordbar.example.comwithaddress10.10.8.3barINA10.10.8.3;PYDNSTESTaddrecordbaz.example.comwithaddress10.10.8.4bazINA10.10.8.4jantman@phoenix$cd~/venv_dirjantman@phoenix$sourcebin/activate(venv_dir)jantman@phoenix$grep"^;PYDNSTEST"~/tmp/sample_zone.txt|sed's/^;PYDNSTEST //'|pydnstestOK:prodandtestserversreturnsameresponsefor'foo.example.com'response:{'name':'foo.example.com','data':'10.10.8.2','typename':'A','classstr':'IN','ttl':360,'type':1,'class':1,'rdlength':4}OK:prodandtestserversreturnsameresponsefor'bar.example.com'response:{'name':'bar.example.com','data':'10.10.8.3','typename':'A','classstr':'IN','ttl':360,'type':1,'class':1,'rdlength':4}OK:prodandtestserversreturnsameresponsefor'baz.example.com'response:{'name':'baz.example.com','data':'10.10.8.4','typename':'A','classstr':'IN','ttl':360,'type':1,'class':1,'rdlength':4}++++All3testspassed.(pydnstest0.2.2)Bugs and Feature RequestsBug reports and feature requests are happily accepted via theGitHub Issue Tracker. Pull requests are
welcome. Issues that don’t have an accompanying pull request will be worked on
as my time and priority allows.Licensepydnstest is licensed under theGNU Affero General Public
Licenseversion 3, with the
additional term that the Copyright and Authors attributions may not be removed
or otherwise altered, except to add the Author attribution of a contributor to
the work. (Additional Terms pursuant to Section 7b of the AGPL v3).I chose AGPL mostly because I want this software to continue to evolve and
benefit from community involvement and improvement.DevelopmentTo install for development:Fork thepydnstestrepository on GitHubCreate a new branch off of master in your fork.$virtualenvpydnstest$cdpydnstest&&sourcebin/activate$pipinstall-egit+git@github.com:YOURNAME/pydnstest.git@BRANCHNAME#egg=pydnstest$cdsrc/pydnstestThe git clone you’re now in will probably be checked out to a specific commit,
so you may want togit checkout BRANCHNAME.Guidelinespep8 compliant with some exceptions (see pytest.ini)100% test coverage with pytest (with valid tests) (note that untilhttps://github.com/lemurheavy/coveralls-public/issues/31is fixed, you
need to check thecovoutput for branch coverage, coveralls can’t
be relied on).TestingTesting is done viapytest, driven bytoxand currently encompasses testing for both the input language parsing, and the
DNS testing logic (via stubbing the DNS lookup methods and returning known
results).Be aware that the tests also run a few live DNS queries (dnstest_dns_test.py /
TestDNS class) against domains that I control, mostly as a sanity check for
changes in the underlying pydns library. These may occasionally timeout or
fail, as is the case with any live network tests.testing is as simple as:pip install toxtoxIf you want to see code coverage:tox-ecovthis produces two coverage reports - a summary on STDOUT and a full report in thehtmlcov/directoryIf you want to pass additional arguments to pytest, add them to the tox command line after “–”. i.e., for verbose pytext output on py27 tests:tox-epy27---vRelease ChecklistOpen an issue for the release; cut a branch off master for that issue.Confirm that there are CHANGES.rst entries for all major changes.Ensure that Travis tests passing in all environments.Ensure that test coverage is no less than the last release (ideally, 100%).Increment the version number in pydnstest/version.py and add version and release date to CHANGES.rst, then push to GitHub.Confirm that README.rst renders correctly on GitHub.Upload package to testpypi, confirm that README.rst renders correctly.Make sure your ~/.pypirc file is correctpython setup.py register-rhttps://testpypi.python.org/pypipython setup.py sdist upload-rhttps://testpypi.python.org/pypiCheck that the README renders athttps://testpypi.python.org/pypi/pydnstestCreate a pull request for the release to be merge into master. Upon successful Travis build, merge it.Tag the release in Git, push tag to GitHub:tag the release. for now the message is quite simple:git tag-avX.Y.Z-m'X.Y.Z releasedYYYY-MM-DD'push the tag to GitHub:git push origin vX.Y.ZUpload package to live pypi:python setup.py sdist uploadmake sure any GH issues fixed in the release were closed.Changelog0.4.0 (2017-12-24)Drop support for Python 2.6 and Python3 < 3.4Add testing for Python 3.5 and 3.6Stop testing Python 2.6, 3.3 and pypy0.3.1 (2015-01-12)(issue #34) Fix edge case where we have two A records, a valid PTR pointing to one of them, and we remove the other.pydnstest.checks.check_removed_name()was only checking for theexistenceof a PTR, it wasn’t confirming that the PTR actually pointed back to the removed name. Added a warning for this specific case.0.3.0 (2014-06-17)(issue #6) add grammar to –help usage outputadd develop branch build status image to README.rstupdate release procedure documentation(issue #12) add postional argument passthru support for tox to pytestgot rid of develop branch alltogether - everything on mastersome PEP-8 fixes and test fixesadded python3 to package classifiersadded pypi version and download badges to README.rstsetup coveralls.io for coverage reportsadded missing description of sleep parameter in README.rstupdated comments in example config to be more clearupdated README.rst example config to match the one in the packageadded –example-config option to print and example config file and then exitadded –configprint option to print current config file and then exitadded mock as a test dependency(issue #7) added –promptconfig option to interactively build configuration file(issue #20) add warning when reading from stdin(issue #19) make grammar in usage message come from parser class0.2.2 (2013-12-07)(issue #2) add ‘sleep’ cli and config file option to sleep X seconds
between tests(issue #3) add cli and config option to ignore TTL when comparing
responses from DNS servers(issue #5) document release procedure(issue #4) support one-character hostnames(issue #8) support leading underscore in hostnamesadd coverage reports to tox and travis-cifix pep8 tests and remove superfluous double test run from toxfix coverage report excluded linesadd test coverage for util module0.2.1 (2013-11-06)fix README.rst markup erroradd doc parsing tests0.2.0 (2013-11-06)Documentation updatesSupport py26-py33some test fixes for py26-33 support0.1.0 (2013-11-01)Inital development release