Persistent dig container running dns tests

* Sidekick to pi-hole links and queries DNS
* Lookup the default pi.hole against what was fed in as ServerIP
* Lookup a couple outside popular static DNS servers hostnames too
* a little pre-optimized to persist the dig container since docker start adds half a second (no virtually nothing for digs)
This commit is contained in:
diginc
2016-09-07 23:07:38 -05:00
parent e8cb52b23a
commit 1e6eda27eb
2 changed files with 37 additions and 8 deletions

View File

@@ -24,10 +24,20 @@ def test_ServerIP_missing_triggers_start_error(Docker):
@pytest.fixture
def RunningPiHole(DockerPersist, Slow, persist_webserver):
''' Persist a docker and provide some parameterized data for re-use '''
Slow(lambda: DockerPersist.run( 'pgrep {}'.format(persist_webserver) ).rc == 0)
''' Persist a working docker-pi-hole to help speed up subsequent tests '''
Slow(lambda: DockerPersist.run('pgrep {}'.format(persist_webserver) ).rc == 0)
return DockerPersist
@pytest.mark.parametrize('hostname,expected_ip', [
('pi.hole', '192.168.100.2'),
('google-public-dns-a.google.com', '8.8.8.8'),
('b.resolvers.Level3.net', '4.2.2.2')
])
def test_dns_responses(RunningPiHole, hostname, expected_ip):
dig_cmd = "dig +noall +answer {} @pihole | awk '{{ print $5 }}'".format(hostname)
lookup = RunningPiHole.dig.run(dig_cmd).stdout.rstrip('\n')
assert lookup == expected_ip
def test_indecies_are_present(RunningPiHole):
File = RunningPiHole.get_module('File')
File('/var/www/html/pihole/index.html').exists