Skip to content
Snippets Groups Projects
Commit e77c42b0 authored by ale's avatar ale
Browse files

Add simple DNS probes

parent 5343724d
No related branches found
No related tags found
1 merge request!227Add DNS tests
Pipeline #20548 passed
FROM debian:stable FROM debian:stable
RUN apt-get -q update && env DEBIAN_FRONTEND=noninteractive \ RUN apt-get -q update && env DEBIAN_FRONTEND=noninteractive \
apt-get install --no-install-recommends -y python3 python3-pip python3-setuptools python3-yaml python3-jinja2 python3-nose apt-get install --no-install-recommends -y python3 python3-pip python3-setuptools python3-yaml python3-jinja2 python3-nose python3-dnspython
ADD . /src ADD . /src
WORKDIR /src WORKDIR /src
......
...@@ -52,6 +52,11 @@ class TestBase(unittest.TestCase): ...@@ -52,6 +52,11 @@ class TestBase(unittest.TestCase):
host = random.choice(hosts_in_group('frontend')) host = random.choice(hosts_in_group('frontend'))
return ANSIBLE_VARS['hostvars'][host]['ip'] return ANSIBLE_VARS['hostvars'][host]['ip']
def all_frontend_ips(self):
"""Return all IPs in the 'frontend' group."""
return [ANSIBLE_VARS['hostvars'][x]['ip']
for x in hosts_in_group('frontend')]
def sso_conversation(self, sso_username=None, sso_password=None): def sso_conversation(self, sso_username=None, sso_password=None):
url = _ansible_eval( url = _ansible_eval(
'{{ sso_server_url | default("https://login." + domain_public[0]) }}') '{{ sso_server_url | default("https://login." + domain_public[0]) }}')
......
import json import json
import time import time
import unittest import unittest
from dns.resolver import Resolver
from float_integration_test import TestBase, ANSIBLE_VARS from float_integration_test import TestBase, ANSIBLE_VARS
...@@ -34,6 +35,26 @@ class TestHTTPRouter(URLTestBase): ...@@ -34,6 +35,26 @@ class TestHTTPRouter(URLTestBase):
self.assertTrue(UNKNOWN_DOMAIN_MSG in result['body']) self.assertTrue(UNKNOWN_DOMAIN_MSG in result['body'])
class TestDNS(TestBase):
def setUp(self):
self.resolver = Resolver(configure=False)
self.resolver.nameservers = self.all_frontend_ips()
def test_public_dns_entries_for_services(self):
frontend_ips = set(self.all_frontend_ips())
for service in ANSIBLE_VARS['services'].values():
for pe in service.get('public_endpoints', []):
if pe.get('skip_dns', False):
continue
name = '%s.%s' % (pe['name'],
ANSIBLE_VARS['domain_public'][0])
print(f'querying {name}')
resp = self.resolver.query(name, 'A')
for record in resp:
self.assertTrue(str(record) in frontend_ips)
class TestBuiltinServiceURLs(URLTestBase): class TestBuiltinServiceURLs(URLTestBase):
"""Verify that all the public_endpoints are reachable. """Verify that all the public_endpoints are reachable.
......
...@@ -11,7 +11,7 @@ setup( ...@@ -11,7 +11,7 @@ setup(
url="https://git.autistici.org/ai3/float", url="https://git.autistici.org/ai3/float",
install_requires=["Jinja2", install_requires=["Jinja2",
"PyYAML", "PyYAML",
], "dnspython"],
setup_requires=[], setup_requires=[],
zip_safe=True, zip_safe=True,
packages=find_packages(), packages=find_packages(),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment