From fae892b634a015dea95b4dcfb22baedb08946a7a Mon Sep 17 00:00:00 2001 From: Jakub Vavra Date: Mon, 23 Oct 2023 09:41:08 +0200 Subject: [PATCH] Tests: Fix autofs cleanups Autofs tests were not cleaning properly leaving behind stuck/unresponsive mounts. This was failing other tests that were executed after these suites. Tests were stuck when trying to create a new local users or listing dirs. --- src/tests/multihost/alltests/test_automount.py | 5 +++-- src/tests/multihost/alltests/test_automount_from_bash.py | 7 ++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tests/multihost/alltests/test_automount.py b/src/tests/multihost/alltests/test_automount.py index 523e4797648..b822656b144 100644 --- a/src/tests/multihost/alltests/test_automount.py +++ b/src/tests/multihost/alltests/test_automount.py @@ -294,10 +294,9 @@ def test_two_automount_maps(self, multihost, time.sleep(2) MIT_export = multihost.client[0].run_command("ls /home/MIT") mit_export = multihost.client[0].run_command("ls /home/mit") - assert 'export1' in MIT_export.stdout_text - assert 'export2' in mit_export.stdout_text restore = 'cp -af /etc/exports.backup /etc/exports' multihost.master[0].run_command(restore) + multihost.client[0].run_command("systemctl stop autofs", raiseonerr=False) stop_nfs = 'systemctl stop nfs-server' multihost.master[0].run_command(stop_nfs) for dn_dn in [f'automountinformation={nfs_server_ip}:/export1,' @@ -312,6 +311,8 @@ def test_two_automount_maps(self, multihost, multihost.master[0].run_command(f'ldapdelete -x -D ' f'"cn=Directory Manager" ' f'-w Secret123 -H ldap:// {dn_dn}') + assert 'export1' in MIT_export.stdout_text + assert 'export2' in mit_export.stdout_text @pytest.mark.parametrize('add_nisobject', ['/export'], indirect=True) @pytest.mark.tier2 diff --git a/src/tests/multihost/alltests/test_automount_from_bash.py b/src/tests/multihost/alltests/test_automount_from_bash.py index fdab6b3b012..0bf632adb44 100644 --- a/src/tests/multihost/alltests/test_automount_from_bash.py +++ b/src/tests/multihost/alltests/test_automount_from_bash.py @@ -50,11 +50,12 @@ def common_sssd_setup(multihost): @pytest.fixture(scope='function') -def ldap_autofs(multihost): +def ldap_autofs(multihost, request): """ This is common sssd setup used in this test suite. """ tools = sssdTools(multihost.client[0]) + multihost.client[0].run_command("mount") tools.sssd_conf("nss", {'filter_groups': 'root', 'filter_users': 'root', 'debug_level': '9'}, action='update') @@ -71,6 +72,10 @@ def ldap_autofs(multihost): "ldap_autofs_entry_value": "nisMapEntry"}, action='update') tools.clear_sssd_cache() + def restore(): + """Will restore client after test.""" + multihost.client[0].run_command("systemctl restart autofs", raiseonerr=False) + request.addfinalizer(restore) @pytest.fixture(scope='class') def nfs_server_setup(multihost, request):