Hi Martin,

Updated the test according to our discussion.
There are 2 patches: the one related to the dynamic segment naming and the one that xfails one of the tests which fails due to trac ticket 6250.

Please, disregard my previous patch

On 08/12/2016 04:05 PM, Martin Basti wrote:

On 12.08.2016 15:48, Oleg Fayans wrote:
Hi Martin,

On 08/11/2016 10:05 AM, Martin Basti wrote:

On 10.08.2016 20:32, Oleg Fayans wrote:


before we jump into fixing tests, my question is: Was this planned
change and not reflected by test, or switched values are unwanted side
effect and thus bug for us?

That's a marvelous question! The test used to pass, which means that
at some point the convention of naming the segments must have changed.
Is it a bug? I do not think so: the feature still works as expected.

Ludwig, do you know details about this change, why positions of server
names are different than used to be in topology name?

Ticket contains almost no info, except a traceback and it says nothing.
Commit message says at least something.

I'm not sure if this patch fixes that ticket, because traceback in test
shows error message that "removal of segment will disconnect topology",
but this patch only swap order of replica names in segment name. I would
expect that you should get different error, something like segment does
not exist.
Which I do get in jenkins job N 37: "segment not found"

In fact, the error in the issue is unrelated to the fix, you are right.

To tell the truth, I just put a random error from one of the jenkins
topology testruns into the issue.
This is very good way how to report tickets:
* nobody knows what happened
* nobody can search in current tickets,  what is wrong without proper
* developers cannot investigate issue, because there is even no name of
exact test in ticket, no steps to reproduce, nothing
* without proper tickets it is hard to backport patches correctly, if
patch fixes different issue than is reported

I'm closing ticket as invalid, please follow
http://www.chiark.greenend.org.uk/~sgtatham/bugs.html and file a new
proper ticket.

This particular error message was caused by a previous replica
installation failure, which resulted in existing only one segment
instead of three:
master <-> replica1
instead of:
master <-> replica1,
master <-> replica2
replica1 <-> replica2

In fact the patch supplied fixes 2 tests at once:
The first test tries to remove the unexisting segment master <->
replica2 and fails, the second test expects the line topology
master <-> replica1 <-> replica2.
It removes the connection between replica1 and replica2, expects the
operation to fail but it does not because the connection between
master and replica2 exists

the output from the testrun with the patch applied:

-bash-4.3$ ipa-run-tests test_integration/test_topology.py --pdb
WARNING: Couldn't write lextab module 'pycparser.lextab'. [Errno 13]
Permission denied: 'lextab.py'
WARNING: yacc table file version is out of date
WARNING: Couldn't create 'pycparser.yacctab'. [Errno 13] Permission
denied: 'yacctab.py'
test session starts

platform linux2 -- Python 2.7.11, pytest-2.9.2, py-1.4.31, pluggy-0.3.1
rootdir: /usr/lib/python2.7/site-packages/ipatests, inifile: pytest.ini
plugins: sourceorder-0.5, multihost-1.0
collected 3 items

test_integration/test_topology.py ...

3 passed in 2156.82 seconds

I don't care about test output until there is no valid description of
problem, fixing test may just cover real issue.


Oleg Fayans
Quality Engineer
FreeIPA team
From 6be984e1ff3ffa0dcbe3bc9fc415b7355a833c24 Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Wed, 24 Aug 2016 13:48:56 +0200
Subject: [PATCH] Fixed segment naming in topology tests

As the segment name is a stochastic valu, which can have either of the two
nodes as the left node, we need to adapt the tests to not expect some
particular segment name but rather to calculate it dynamically based on node
names and the output of topologysegment-find ipa call
 ipatests/test_integration/test_topology.py | 33 ++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/ipatests/test_integration/test_topology.py b/ipatests/test_integration/test_topology.py
index e956563c27eafd84deed5786274a73d0d3594642..a3e0488eacc116d5ac3fe83b021b8bf85bcc2ef3 100644
--- a/ipatests/test_integration/test_topology.py
+++ b/ipatests/test_integration/test_topology.py
@@ -15,6 +15,18 @@ from ipatests.util import assert_deepequal
 config = get_global_config()
 reasoning = "Topology plugin disabled due to domain level 0"
+def find_segment(master, replica):
+    result = master.run_command(['ipa', 'topologysegment-find',
+                                 DOMAIN_SUFFIX_NAME]).stdout_text
+    segment_re = re.compile('Left node: (?P<left>\S+)\n.*Right node: '
+                            '(?P<right>\S+)\n')
+    allsegments = segment_re.findall(result)
+    for segment in allsegments:
+        if master.hostname in segment and replica.hostname in segment:
+            return '-to-'.join(segment)
 @pytest.mark.skipif(config.domain_level == 0, reason=reasoning)
 class TestTopologyOptions(IntegrationTest):
     num_replicas = 2
@@ -25,6 +37,7 @@ class TestTopologyOptions(IntegrationTest):
                      '\s+Connectivity: (?P<connectivity>\S+)')
     segment_re = re.compile("\n".join(rawsegment_re))
     noentries_re = re.compile("Number of entries returned (\d+)")
+    segmentnames_re = re.compile('.*Segment name: (\S+?)\n.*')
     def install(cls, mh):
@@ -62,15 +75,11 @@ class TestTopologyOptions(IntegrationTest):
         result1 = self.master.run_command(['ipa', 'topologysegment-find',
-        first_segment_name = "%s-to-%s" % (self.master.hostname,
-                                           self.replicas[0].hostname)
-        expected_segment = {
-            'connectivity': 'both',
-            'leftnode': self.master.hostname,
-            'name': first_segment_name,
-            'rightnode': self.replicas[0].hostname}
-        firstsegment = self.tokenize_topologies(result1)[0]
-        assert_deepequal(expected_segment, firstsegment)
+        segment_name = self.segmentnames_re.findall(result1)[0]
+        assert(self.master.hostname in segment_name), (
+            "Segment %s does not contain master hostname" % segment_name)
+        assert(self.replicas[0].hostname in segment_name), (
+            "Segment %s does not contain replica hostname" % segment_name)
         tasks.install_replica(self.master, self.replicas[1], setup_ca=False,
         # We need to make sure topology information is consistent across all
@@ -117,8 +126,10 @@ class TestTopologyOptions(IntegrationTest):
             "%s: segment not found" % segment['name'])
         # Remove master <-> replica2 segment and make sure that the changes get
         # there through replica1
-        deleteme = "%s-to-%s" % (self.master.hostname,
-                                 self.replicas[1].hostname)
+        # Since segment name can be one of master-to-replica2 or
+        # replica2-to-master, we need to determine the segment name dynamically
+        deleteme = find_segment(self.master, self.replicas[1])
         returncode, error = tasks.destroy_segment(self.master, deleteme)
         assert returncode == 0, error
         # Wait till replication ends and make sure replica1 does not have

From 2b7ce994f03187eeb8a97e8e729d301e18e5db68 Mon Sep 17 00:00:00 2001
From: Oleg Fayans <ofay...@redhat.com>
Date: Wed, 24 Aug 2016 13:53:17 +0200
Subject: [PATCH] Xfailed a test that fails due to 6250

Also created a decorator that removes the segment that the next test does not

 ipatests/test_integration/test_topology.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/ipatests/test_integration/test_topology.py b/ipatests/test_integration/test_topology.py
index a3e0488eacc116d5ac3fe83b021b8bf85bcc2ef3..4cdcd46a175fa8b8415ffd7eb35fa9e7a9978030 100644
--- a/ipatests/test_integration/test_topology.py
+++ b/ipatests/test_integration/test_topology.py
@@ -27,6 +27,26 @@ def find_segment(master, replica):
             return '-to-'.join(segment)
+def remove_segment(master, host1, host2):
+    """
+    This removes a segment between host1 and host2 on master. The function is
+    needed because test_add_remove_segment expects only one segment, but due to
+    track tickete N 6250, the test_topology_updated_on_replica_install_remove
+    leaves 2 topology segments
+    """
+    def wrapper(func):
+        def wrapped(*args, **kwargs):
+            try:
+                func(*args, **kwargs)
+            finally:
+                segment = find_segment(host1, host2)
+                master.run_command(['ipa', 'topologysegment-del',
+                                    DOMAIN_SUFFIX_NAME, segment],
+                                   raiseonerr=False)
+        return wrapped
+    return wrapper
 @pytest.mark.skipif(config.domain_level == 0, reason=reasoning)
 class TestTopologyOptions(IntegrationTest):
     num_replicas = 2
@@ -64,6 +84,10 @@ class TestTopologyOptions(IntegrationTest):
         return result
+    @pytest.mark.xfail(reason="Trac 6250", strict=True)
+    @remove_segment(config.domains[0].master,
+                    config.domains[0].master,
+                    config.domains[0].replicas[1])
     def test_topology_updated_on_replica_install_remove(self):
         Install and remove a replica and make sure topology information is

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

Reply via email to