Blame SOURCES/0026-Issue-4504-Insure-ldapi-is-enabled-in-repl_monitor_t.patch

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