summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Fayans <ofayans@redhat.com>2016-08-24 13:48:56 +0200
committerMartin Basti <mbasti@redhat.com>2016-09-15 10:21:56 +0200
commit49fbbb0641df2adab28fd3440686cb7430645c85 (patch)
treed7baf788556a4512c2cd9d05b7f79ac53305abb1
parentd13a4c2f395c08b514a51a19eaad3fa7d32e7538 (diff)
downloadfreeipa-49fbbb0641df2adab28fd3440686cb7430645c85.tar.gz
freeipa-49fbbb0641df2adab28fd3440686cb7430645c85.tar.xz
freeipa-49fbbb0641df2adab28fd3440686cb7430645c85.zip
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 Reviewed-By: Martin Basti <mbasti@redhat.com>
-rw-r--r--ipatests/test_integration/test_topology.py33
1 files changed, 22 insertions, 11 deletions
diff --git a/ipatests/test_integration/test_topology.py b/ipatests/test_integration/test_topology.py
index e956563c2..a3e0488ea 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.*')
@classmethod
def install(cls, mh):
@@ -62,15 +75,11 @@ class TestTopologyOptions(IntegrationTest):
tasks.kinit_admin(self.master)
result1 = self.master.run_command(['ipa', 'topologysegment-find',
DOMAIN_SUFFIX_NAME]).stdout_text
- 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,
setup_dns=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