URL: https://github.com/freeipa/freeipa/pull/1766
Author: rcritten
 Title: #1766: Change remove_segment to take a config object
Action: opened

PR body:
"""
This is to handle the case where there is no integration test
YAML provided where config.domains is an empty list.

https://pagure.io/freeipa/issue/7483

Note that I considered populating config with an empty set of domains and 
replicas but that would have required much more code and IMHO been more 
fragile. Given there is only a single caller to remove_segment I think this is 
fastest, safest route. If we end up with more callers needing it we can revisit.

The use-case for this is to:

- Install IPA
- Install the test pkgs
- mkdir ~/.ipa
- ln -s /etc/ipa/default.conf ~/.ipa/default.conf
- ln -s /etc/ipa/ca.crt ~/.ipa/ca.crt
- kinit admin
- ipa-run-tests

The simplest possible way to execute the tests in IPA.
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1766/head:pr1766
git checkout pr1766
From 9cdbf313fa74c2569810dcb29069ad21539b58c2 Mon Sep 17 00:00:00 2001
From: Rob Crittenden <rcrit...@redhat.com>
Date: Tue, 3 Apr 2018 15:34:34 -0400
Subject: [PATCH] Change remove_segment to take a config object

This is to handle the case where there is no integration test
YAML provided where config.domains is an empty list.

https://pagure.io/freeipa/issue/7483
---
 ipatests/test_integration/test_topology.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/ipatests/test_integration/test_topology.py b/ipatests/test_integration/test_topology.py
index fb7047e32c..27007cf01d 100644
--- a/ipatests/test_integration/test_topology.py
+++ b/ipatests/test_integration/test_topology.py
@@ -27,7 +27,7 @@ def find_segment(master, replica):
             return '-to-'.join(segment)
 
 
-def remove_segment(master, host1, host2):
+def remove_segment(config):
     """
     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
@@ -39,6 +39,10 @@ def wrapped(*args, **kwargs):
             try:
                 func(*args, **kwargs)
             finally:
+                master = config.domains[0].master
+                host1 = config.domains[0].master
+                host2 = config.domains[0].replicas[1]
+
                 segment = find_segment(host1, host2)
                 master.run_command(['ipa', 'topologysegment-del',
                                     DOMAIN_SUFFIX_NAME, segment],
@@ -84,10 +88,9 @@ def tokenize_topologies(self, command_output):
                               )
         return result
 
+    @pytest.mark.skipif(len(config.domains) == 0, reason='single master')
     @pytest.mark.xfail(reason="Trac 6250", strict=True)
-    @remove_segment(config.domains[0].master,
-                    config.domains[0].master,
-                    config.domains[0].replicas[1])
+    @remove_segment(config)
     def test_topology_updated_on_replica_install_remove(self):
         """
         Install and remove a replica and make sure topology information is
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to