From 21cd9775ec314421949259b825bb05dcbfab9f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Cami?= Date: Mon, 29 Jul 2019 17:53:36 +0200 Subject: [PATCH] test_nfs.py: switch to tasks.config_replica_resolvconf_with_master_data() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously test_nfs.py would implement its own method to configure resolv.conf leading to cleanup failures in some cases. Use tasks.config_replica_resolvconf_with_master_data() instead. Also simplify and fix client uninstall. Fixes: https://pagure.io/freeipa/issue/7949 Signed-off-by: François Cami Reviewed-By: Sergey Orlov Reviewed-By: Rob Crittenden --- ipatests/test_integration/test_nfs.py | 43 ++++++--------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/ipatests/test_integration/test_nfs.py b/ipatests/test_integration/test_nfs.py index b9dc5d67f..67eb5574a 100644 --- a/ipatests/test_integration/test_nfs.py +++ b/ipatests/test_integration/test_nfs.py @@ -15,47 +15,21 @@ from __future__ import absolute_import -import time +import os import re +import time from ipatests.test_integration.base import IntegrationTest from ipatests.pytest_ipa.integration import tasks from ipaplatform.paths import paths -import os - # give some time for units to stabilize # otherwise we get transient errors WAIT_AFTER_INSTALL = 5 WAIT_AFTER_UNINSTALL = WAIT_AFTER_INSTALL -class TestInit(IntegrationTest): - - @classmethod - def fix_resolv_conf(cls, client, server): - - contents = client.get_file_contents(paths.RESOLV_CONF, - encoding='utf-8') - nameserver = 'nameserver %s\n' % server.ip - if not contents.startswith(nameserver): - contents = nameserver + contents.replace(nameserver, '') - client.run_command([ - '/usr/bin/cp', paths.RESOLV_CONF, - '%s.sav' % paths.RESOLV_CONF - ]) - client.put_file_contents(paths.RESOLV_CONF, contents) - - @classmethod - def restore_resolv_conf(cls, client): - client.run_command([ - '/usr/bin/cp', - '%s.sav' % paths.RESOLV_CONF, - paths.RESOLV_CONF - ]) - - -class TestNFS(TestInit): +class TestNFS(IntegrationTest): num_replicas = 2 num_clients = 1 @@ -67,7 +41,10 @@ class TestNFS(TestInit): tasks.install_master(cls.master, setup_dns=True) clients = (cls.clients[0], cls.replicas[0], cls.replicas[1]) for client in clients: - cls.fix_resolv_conf(client, cls.master) + tasks.backup_file(client, paths.RESOLV_CONF) + tasks.config_replica_resolvconf_with_master_data( + cls.master, client + ) tasks.install_client(cls.master, client) client.run_command(["cat", "/etc/resolv.conf"]) @@ -89,8 +66,6 @@ class TestNFS(TestInit): nfssrv.run_command(["rm", "-rf", "/exports"]) - tasks.uninstall_client(nfsclt) - tasks.uninstall_client(nfssrv) self.master.run_command([ "ipa", "host-mod", automntclt.hostname, "--location", "''" @@ -101,9 +76,9 @@ class TestNFS(TestInit): ]) nfsclt.run_command(["systemctl", "restart", "nfs-utils"]) nfssrv.run_command(["systemctl", "restart", "nfs-utils"]) + for client in (nfssrv, nfsclt, automntclt): - self.restore_resolv_conf(client) - tasks.uninstall_master(self.master) + tasks.restore_files(client) def test_prepare_users(self):