ipatests: disable systemd-resolved cache

systemd-resolved enables positive and negative cache by default which
affects test scenarios where dns records are being created and deleted and
then verified using any tools that utilize default system resolver
(i.e. `dig` or `curl`).

Related to https://pagure.io/freeipa/issue/8703

Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Sergey Orlov 2021-02-09 18:13:54 +01:00
parent 01f455f424
commit 1853695d22
No known key found for this signature in database
GPG Key ID: ADF8C90EDD04503D

View File

@ -65,6 +65,7 @@ from ipatests.create_external_ca import ExternalCA
from .env_config import env_to_script
from .host import Host
from .firewall import Firewall
from .resolver import ResolvedResolver
logger = logging.getLogger(__name__)
@ -143,10 +144,26 @@ def rpcbind_kadmin_workaround(host):
break
def disable_systemd_resolved_cache(host):
if not ResolvedResolver.is_our_resolver(host):
return
resolved_conf_file = (
'/etc/systemd/resolved.conf.d/zzzz-ipatests-disable-cache.conf')
resolved_conf = textwrap.dedent('''
# generated by IPA tests
[Resolve]
Cache=no
''')
host.run_command(['mkdir', '-p', os.path.dirname(resolved_conf_file)])
host.put_file_contents(resolved_conf_file, resolved_conf)
host.run_command(['systemctl', 'restart', 'systemd-resolved'])
def apply_common_fixes(host):
prepare_host(host)
fix_hostname(host)
rpcbind_kadmin_workaround(host)
disable_systemd_resolved_cache(host)
def prepare_dse_changes(host, log_level=8192):