On 06/29/2016 06:49 PM, Petr Spacek wrote:
On 29.6.2016 18:39, Oleg Fayans wrote:
In fact, I believe /etc/hosts file should not be touched at all.
Hostname resolution is usually governed by the DNS system of the lab in
which tests are running. We do not modify it when perform tests
manually, so I'd rather remove this method at all.
+1, it should not be need. Let me know if it is needed for some reason and I
will have a look.

Petr^2 Spacek
Hi,

providing new (and renamed) patch as was suggested in the discussion above - removing manipulation with /etc/hosts file from the tests. The "fix_etc_hosts" function was completely removed from the tasks file. Verification that nothing is broken by this change was done by running some random integration test (trust tests), and also on Milan's suggestion by running a test requiring two replicas (replica promotion tests).

Lenka

On 06/29/2016 06:27 PM, Lenka Doudova wrote:
Hi all,

a function 'fix_etc_hosts' in ipatests/test_integration/tasks.py
produces incorrect /etc/hosts file (solitary IPv6 address), and
currently parser is not able to resolve the issue, causing
ipa-server-install to fail with 'list index out of range' error.

Hence I'm attaching patch to fix this issue before parser is fixed
(related ticket to it #6014). The fix is just change of regexs
responsible for creating incorrect file so that all the lines containing
defined hostname are removed, not just specific IP/hostname/shortname
strings.


Lenka

From eb73a40d4294c062a646b8d6cf9fe495382896ed Mon Sep 17 00:00:00 2001
From: Lenka Doudova <ldoud...@redhat.com>
Date: Tue, 19 Jul 2016 13:12:05 +0200
Subject: [PATCH] Tests: Removing manipulation with /etc/hosts file from
 integration tests

---
 ipatests/test_integration/tasks.py | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/ipatests/test_integration/tasks.py b/ipatests/test_integration/tasks.py
index cee6c15ccdc260f6ebe4cdebbc2cf6ec84931f27..55cc902b490c57b8741a644ed691254c7d83dc24 100644
--- a/ipatests/test_integration/tasks.py
+++ b/ipatests/test_integration/tasks.py
@@ -96,7 +96,6 @@ def allow_sync_ptr(host):
 
 
 def apply_common_fixes(host):
-    fix_etc_hosts(host)
     fix_hostname(host)
     prepare_host(host)
 
@@ -118,24 +117,6 @@ def backup_file(host, filename):
         return False
 
 
-def fix_etc_hosts(host):
-    backup_file(host, paths.HOSTS)
-    contents = host.get_file_contents(paths.HOSTS)
-    # Remove existing mentions of the host's FQDN, short name, and IP
-    # Removing of IP must be done as first, otherwise hosts file may be
-    # corrupted
-    contents = re.sub('^%s.*' % re.escape(host.ip), '', contents,
-                      flags=re.MULTILINE)
-    contents = re.sub('\s%s(\s|$)' % re.escape(host.hostname), ' ', contents,
-                      flags=re.MULTILINE)
-    contents = re.sub('\s%s(\s|$)' % re.escape(host.shortname), ' ', contents,
-                      flags=re.MULTILINE)
-    # Add the host's info again
-    contents += '\n%s %s %s\n' % (host.ip, host.hostname, host.shortname)
-    log.debug('Writing the following to /etc/hosts:\n%s', contents)
-    host.put_file_contents(paths.HOSTS, contents)
-
-
 def fix_hostname(host):
     backup_file(host, paths.ETC_HOSTNAME)
     host.put_file_contents(paths.ETC_HOSTNAME, host.hostname + '\n')
-- 
2.7.4

-- 
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