Skip to content

Commit

Permalink
Enhance CI tests for the resolvconf role
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Neumann <[email protected]>
  • Loading branch information
sbstnnmnn committed Sep 18, 2024
1 parent b884bb2 commit 8f35c54
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions molecule/delegated/tests/resolvconf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import socket

from .util.util import (
get_ansible,
Expand Down Expand Up @@ -105,3 +106,31 @@ def test_resolvconf_file_is_symlink(host):
resolvconf_file = get_variable(host, "resolvconf_file")
f = host.file(resolvconf_file)
assert f.is_symlink


def test_dns_resolution(host):
"""Check if DNS resolution is working correctly."""
expected_nameservers = get_variable(host, "resolvconf_nameserver")
expected_nameservers_default = get_variable(host, "resolvconf_nameserver_default")
expected_nameservers_extra = get_variable(host, "resolvconf_nameserver_extra")

expected_nameservers = jinja_list_concat(
expected_nameservers, [expected_nameservers_default, expected_nameservers_extra]
)

for nameserver in expected_nameservers:
cmd = host.run(f"dig @{nameserver} osism.tech +short")
assert cmd.rc == 0
assert cmd.stdout.strip() != ""


def test_dns_reverse_lookup(host):
"""Check if reverse DNS lookup is working."""
nameservers = get_variable(host, "resolvconf_nameserver_default")
for nameserver in nameservers:
ip = socket.gethostbyname("osism.tech")
cmd = host.run(f"dig @{nameserver} -x {ip} +short")
assert cmd.rc == 0
assert cmd.stdout.strip() != ""

assert False

0 comments on commit 8f35c54

Please sign in to comment.