From 48b30739f33d1eb526dbdd45c820129c4a4c4bcb Mon Sep 17 00:00:00 2001 From: progier389 <72748589+progier389@users.noreply.github.com> Date: Tue, 12 Jan 2021 11:06:24 +0100 Subject: [PATCH] Issue 4504 - Insure ldapi is enabled in repl_monitor_test.py (Needed on RHEL) (#4527) (cherry picked from commit 279556bc78ed743d7a053069621d999ec045866f) --- .../tests/suites/clu/repl_monitor_test.py | 67 +++++++++---------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/dirsrvtests/tests/suites/clu/repl_monitor_test.py b/dirsrvtests/tests/suites/clu/repl_monitor_test.py index eb18d2da2..b2cb840b3 100644 --- a/dirsrvtests/tests/suites/clu/repl_monitor_test.py +++ b/dirsrvtests/tests/suites/clu/repl_monitor_test.py @@ -9,7 +9,6 @@ import time import subprocess import pytest -import re from lib389.cli_conf.replication import get_repl_monitor_info from lib389.tasks import * @@ -18,6 +17,8 @@ from lib389.topologies import topology_m2 from lib389.cli_base import FakeArgs from lib389.cli_base.dsrc import dsrc_arg_concat from lib389.cli_base import connect_instance +from lib389.replica import Replicas + pytestmark = pytest.mark.tier0 @@ -68,25 +69,6 @@ def check_value_in_log_and_reset(content_list, second_list=None, single_value=No log.info('Reset log file') f.truncate(0) -def get_hostnames_from_log(port1, port2): - # Get the supplier host names as displayed in replication monitor output - with open(LOG_FILE, 'r') as logfile: - logtext = logfile.read() - # search for Supplier :hostname:port - # and use \D to insure there is no more number is after - # the matched port (i.e that 10 is not matching 101) - regexp = '(Supplier: )([^:]*)(:' + str(port1) + '\D)' - match=re.search(regexp, logtext) - host_m1 = 'localhost.localdomain' - if (match is not None): - host_m1 = match.group(2) - # Same for master 2 - regexp = '(Supplier: )([^:]*)(:' + str(port2) + '\D)' - match=re.search(regexp, logtext) - host_m2 = 'localhost.localdomain' - if (match is not None): - host_m2 = match.group(2) - return (host_m1, host_m2) @pytest.mark.ds50545 @pytest.mark.bz1739718 @@ -115,6 +97,24 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file): m1 = topology_m2.ms["master1"] m2 = topology_m2.ms["master2"] + # Enable ldapi if not already done. + for inst in [topology_m2.ms["master1"], topology_m2.ms["master2"]]: + if not inst.can_autobind(): + # Update ns-slapd instance + inst.config.set('nsslapd-ldapilisten', 'on') + inst.config.set('nsslapd-ldapiautobind', 'on') + inst.restart() + # Ensure that updates have been sent both ways. + replicas = Replicas(m1) + replica = replicas.get(DEFAULT_SUFFIX) + replica.test_replication([m2]) + replicas = Replicas(m2) + replica = replicas.get(DEFAULT_SUFFIX) + replica.test_replication([m1]) + + alias_content = ['Supplier: M1 (' + m1.host + ':' + str(m1.port) + ')', + 'Supplier: M2 (' + m2.host + ':' + str(m2.port) + ')'] + connection_content = 'Supplier: '+ m1.host + ':' + str(m1.port) content_list = ['Replica Root: dc=example,dc=com', 'Replica ID: 1', @@ -177,9 +177,20 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file): '001', m1.host + ':' + str(m1.port)] + dsrc_content = '[repl-monitor-connections]\n' \ + 'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \ + 'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \ + '\n' \ + '[repl-monitor-aliases]\n' \ + 'M1 = ' + m1.host + ':' + str(m1.port) + '\n' \ + 'M2 = ' + m2.host + ':' + str(m2.port) + connections = [m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM, m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM] + aliases = ['M1=' + m1.host + ':' + str(m1.port), + 'M2=' + m2.host + ':' + str(m2.port)] + args = FakeArgs() args.connections = connections args.aliases = None @@ -187,24 +198,8 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file): log.info('Run replication monitor with connections option') get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args) - (host_m1, host_m2) = get_hostnames_from_log(m1.port, m2.port) check_value_in_log_and_reset(content_list, connection_content, error_list=error_list) - # Prepare the data for next tests - aliases = ['M1=' + host_m1 + ':' + str(m1.port), - 'M2=' + host_m2 + ':' + str(m2.port)] - - alias_content = ['Supplier: M1 (' + host_m1 + ':' + str(m1.port) + ')', - 'Supplier: M2 (' + host_m2 + ':' + str(m2.port) + ')'] - - dsrc_content = '[repl-monitor-connections]\n' \ - 'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \ - 'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \ - '\n' \ - '[repl-monitor-aliases]\n' \ - 'M1 = ' + host_m1 + ':' + str(m1.port) + '\n' \ - 'M2 = ' + host_m2 + ':' + str(m2.port) - log.info('Run replication monitor with aliases option') args.aliases = aliases get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args) -- 2.26.2