From 4514e8090ab288a3bddde56c04d8014735fe95d1 Mon Sep 17 00:00:00 2001 From: Mohammad Rizwan Date: Apr 07 2022 12:19:28 +0000 Subject: ipatests: fix the topologysegment-reinitialize command There is no guarantee for the topologysegement name, it could be master-to-replica or replica-to-master. If it is master-to-replica then --right should be used with the command else --left. Fixes: https://pagure.io/freeipa/issue/9137 Signed-off-by: Mohammad Rizwan Reviewed-By: Florence Blanc-Renaud --- diff --git a/ipatests/test_integration/test_backup_and_restore.py b/ipatests/test_integration/test_backup_and_restore.py index a10c96f..390c065 100644 --- a/ipatests/test_integration/test_backup_and_restore.py +++ b/ipatests/test_integration/test_backup_and_restore.py @@ -35,6 +35,7 @@ from ipatests.test_integration.base import IntegrationTest from ipatests.pytest_ipa.integration import tasks from ipatests.test_integration.test_dnssec import wait_until_record_is_signed from ipatests.test_integration.test_simple_replication import check_replication +from ipatests.test_integration.test_topology import find_segment from ipatests.util import assert_deepequal from ldap.dn import escape_dn_chars @@ -862,13 +863,14 @@ class TestReplicaInstallAfterRestore(IntegrationTest): stdin_text=dirman_password + '\nyes') # re-initialize topology after restore. - topo_name = "{}-to-{}".format(master.hostname, replica1.hostname) for topo_suffix in 'domain', 'ca': - arg = ['ipa', - 'topologysegment-reinitialize', - topo_suffix, - topo_name, - '--left'] + topo_name = find_segment(master, replica1, topo_suffix) + arg = ['ipa', 'topologysegment-reinitialize', + topo_suffix, topo_name] + if topo_name.split('-to-', maxsplit=1)[0] != master.hostname: + arg.append('--left') + else: + arg.append('--right') replica1.run_command(arg) # wait sometime for re-initialization