From 7c0b0f34716cabbdc48edf959935b37a21883238 Mon Sep 17 00:00:00 2001 From: François Cami Date: Dec 14 2018 09:15:04 +0000 Subject: ipatests: add a test for ipa-client-automount Add an automount location then configure a client to use it. Only runs nightly. Related-to: https://pagure.io/freeipa/issue/7780 Related-to: https://pagure.io/freeipa/issue/7781 Related to: https://pagure.io/freeipa/issue/7783 Signed-off-by: François Cami Reviewed-By: Alexander Bokovoy --- diff --git a/ipatests/prci_definitions/nightly_master.yaml b/ipatests/prci_definitions/nightly_master.yaml index 2d7b9ab..ec1b772 100644 --- a/ipatests/prci_definitions/nightly_master.yaml +++ b/ipatests/prci_definitions/nightly_master.yaml @@ -1146,3 +1146,15 @@ jobs: template: *ci-master-f29 timeout: 3600 topology: *master_1repl + + fedora-29/test_automount_locations: + requires: [fedora-29/build] + priority: 50 + job: + class: RunPytest + args: + build_url: '{fedora-29/build_url}' + test_suite: test_integration/test_automount_locations.py + template: *ci-master-f29 + timeout: 6300 + topology: *master_1repl diff --git a/ipatests/test_integration/test_automount_locations.py b/ipatests/test_integration/test_automount_locations.py new file mode 100644 index 0000000..646d1d0 --- /dev/null +++ b/ipatests/test_integration/test_automount_locations.py @@ -0,0 +1,84 @@ +# +# Copyright (C) 2018 FreeIPA Contributors see COPYING for license +# + +"""This module provides tests for the automount location feature. +""" + +from __future__ import absolute_import + +import time +import re + +from ipatests.test_integration.base import IntegrationTest +from ipatests.pytest_ipa.integration import tasks + +# give some time for units to stabilize +# otherwise we get transient errors +WAIT_AFTER_INSTALL = 5 +WAIT_AFTER_UNINSTALL = WAIT_AFTER_INSTALL + + +class TestAutomountInstallUninstall(IntegrationTest): + """ + Test if ipa-client-automount behaves as expected + """ + + num_replicas = 1 + topology = 'star' + + @classmethod + def install(cls, mh): + tasks.install_master(cls.master, setup_dns=False) + client = cls.replicas[0] + tasks.install_client(cls.master, client) + + def test_use_automount_location(self): + + client = self.replicas[0] + + self.master.run_command([ + "ipa", "automountlocation-add", "baltimore" + ]) + + self.master.run_command([ + "ipa", "host-mod", client.hostname, + "--location", "baltimore" + ]) + + # systemctl non-fatal errors will only be displayed + # if ipa-client-automount is launched with --debug + result1 = client.run_command([ + 'ipa-client-automount', '--location', 'baltimore', + '-U', '--debug' + ]) + + # systemctl non-fatal errors will show up like this: + # stderr=Failed to restart nfs-secure.service: \ + # Unit nfs-secure.service not found. + # normal output: + # stderr= + m1 = re.search(r'(?<=stderr\=Failed).+', result1.stderr_text) + # maybe re-use m1.group(0) if it exists. + assert m1 is None + + time.sleep(WAIT_AFTER_INSTALL) + + result2 = client.run_command([ + 'ipa-client-automount', '--uninstall', + '-U', '--debug' + ]) + + m2 = re.search(r'(?<=stderr\=Failed).+', result2.stderr_text) + assert m2 is None + + time.sleep(WAIT_AFTER_UNINSTALL) + + self.master.run_command([ + "ipa", "host-mod", client.hostname, + "--location", "''" + ]) + + self.master.run_command([ + "ipa", "automountlocation-del", "baltimore" + ])