Hi Petr,

On 02/03/2016 02:19 PM, Petr Spacek wrote:
> On 3.2.2016 10:22, Oleg Fayans wrote:
>> Guys, can anyone take a look at this?
> 
> The commit message does not explain why you are setting search path.

Fixed.

> 
> I have to say that I do not like touching resolv.conf, as stated many times
> earlier. Why the test has to reconfigure the host and cannot use values
> provided by the provisioning system?

This patch exactly removes this messing around with nameservers in
resolv.conf
It introduces the possibility to put ipa domain in the search directive
of resolv.conf so that we could test service autodiscovery during client
installation.

> 

-- 
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From 9d11bc937adb425f504de345504f01f81714353b Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Thu, 4 Feb 2016 08:45:03 +0100
Subject: [PATCH] Moved NM configuration calls to the IntegrationTest base
 class

Reconfiguring and restarting of NetworkManager in the middle of test execution
sometimes causes unexpected results. See [1] for details.
It is better to have it configured in advance during test class initialization
with default configuration applied at test teardown

Also, disabled manual resetting nameservers in resolv.conf before replica and
client installations (as per discussion with pspacek). Added possibility to
update the "search" directive in resolv.conf to test service auto-discovery
during client installation.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1303095
---
 ipatests/test_integration/base.py  |  5 +++++
 ipatests/test_integration/tasks.py | 11 +++--------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ipatests/test_integration/base.py b/ipatests/test_integration/base.py
index 4f57e959032a5fda0ad002fca95501da1160605b..fef202b8e203806f711de4062b1a429482c411bb 100644
--- a/ipatests/test_integration/base.py
+++ b/ipatests/test_integration/base.py
@@ -64,6 +64,9 @@ class IntegrationTest(object):
     def install(cls, mh):
         if cls.topology is None:
             return
+        for host in cls.get_all_hosts():
+            # Tell NetworkManager to not mess around with resolv.conf
+            tasks.modify_nm_resolv_conf_settings(host)
         else:
             tasks.install_topo(cls.topology,
                                cls.master, cls.replicas, cls.clients)
@@ -78,6 +81,8 @@ class IntegrationTest(object):
             tasks.uninstall_master(replica)
         for client in cls.clients:
             tasks.uninstall_client(client)
+        for host in cls.get_all_hosts():
+            tasks.undo_nm_resolv_conf_settings(host)
 
 
 IntegrationTest.log = log_mgr.get_logger(IntegrationTest())
diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index 318c8c880fe0df22c9b5089cbd88e017936e4df5..42d2e109c7b91cf8f5ca47c5028c80aa7a927db1 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -91,7 +91,6 @@ def allow_sync_ptr(host):
 def apply_common_fixes(host, fix_resolv=True):
     fix_etc_hosts(host)
     fix_hostname(host)
-    modify_nm_resolv_conf_settings(host)
     if fix_resolv:
         fix_resolv_conf(host)
     prepare_host(host)
@@ -175,11 +174,9 @@ def undo_nm_resolv_conf_settings(host):
 
 def fix_resolv_conf(host):
     backup_file(host, paths.RESOLV_CONF)
-    lines = host.get_file_contents(paths.RESOLV_CONF).splitlines()
-    lines = ['#' + l if l.startswith('nameserver') else l for l in lines]
-    for other_host in host.domain.hosts:
-        if other_host.role in ('master', 'replica'):
-            lines.append('nameserver %s' % other_host.ip)
+    lines_read = host.get_file_contents(paths.RESOLV_CONF).splitlines()
+    lines = ['#' + l if l.startswith('search') else l for l in lines_read]
+    lines[0] = "search %s\n" % host.domain.name
     contents = '\n'.join(lines)
     log.debug('Writing the following to /etc/resolv.conf:\n%s', contents)
     host.put_file_contents(paths.RESOLV_CONF, contents)
@@ -201,8 +198,6 @@ def fix_apache_semaphores(master):
 def unapply_fixes(host):
     restore_files(host)
     restore_hostname(host)
-    undo_nm_resolv_conf_settings(host)
-
     # Clean up the test directory
     host.run_command(['rm', '-rvf', host.config.test_dir])
 
-- 
2.4.3

-- 
Manage your subscription for the Freeipa-devel mailing list:
https://www.redhat.com/mailman/listinfo/freeipa-devel
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to