From 1853695d22dec0585cfa4ab4ffd70fbb8c57e6f1 Mon Sep 17 00:00:00 2001 From: Sergey Orlov Date: Tue, 9 Feb 2021 18:13:54 +0100 Subject: [PATCH] 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 --- ipatests/pytest_ipa/integration/tasks.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ipatests/pytest_ipa/integration/tasks.py b/ipatests/pytest_ipa/integration/tasks.py index 865f6dc80..7c0cb20d9 100755 --- a/ipatests/pytest_ipa/integration/tasks.py +++ b/ipatests/pytest_ipa/integration/tasks.py @@ -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):