-- 
Oleg Fayans
Quality Engineer
FreeIPA team
RedHat.
From b866ff5336f742e170895b575df7a09419c2d731 Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Fri, 29 Jan 2016 16:04:17 +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).

[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 27d2449ec71e0bf55a576cc495175a5ae41da1d6..b5e3d1a8106d389e2027fb2535726b3a93eb2d5c 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