Blame SOURCES/0028-Issue-4504-insure-that-repl_monitor_test-use-ldapi-f.patch

1ce915
From 00ccec335792e3fa44712427463c64eb1ff9c5be Mon Sep 17 00:00:00 2001
1ce915
From: progier389 <progier@redhat.com>
1ce915
Date: Tue, 12 Jan 2021 17:45:41 +0100
1ce915
Subject: [PATCH] Issue 4504 - insure that repl_monitor_test use ldapi (for
1ce915
 RHEL) - fix merge issue (#4533)
1ce915
1ce915
(cherry picked from commit a880fddc192414d6283ea6832491b7349e5471dc)
1ce915
---
1ce915
 .../tests/suites/clu/repl_monitor_test.py     | 47 ++++++++++++++-----
1ce915
 1 file changed, 36 insertions(+), 11 deletions(-)
1ce915
1ce915
diff --git a/dirsrvtests/tests/suites/clu/repl_monitor_test.py b/dirsrvtests/tests/suites/clu/repl_monitor_test.py
1ce915
index b2cb840b3..caf6a9099 100644
1ce915
--- a/dirsrvtests/tests/suites/clu/repl_monitor_test.py
1ce915
+++ b/dirsrvtests/tests/suites/clu/repl_monitor_test.py
1ce915
@@ -9,6 +9,7 @@
1ce915
 import time
1ce915
 import subprocess
1ce915
 import pytest
1ce915
+import re
1ce915
 
1ce915
 from lib389.cli_conf.replication import get_repl_monitor_info
1ce915
 from lib389.tasks import *
1ce915
@@ -69,6 +70,25 @@ def check_value_in_log_and_reset(content_list, second_list=None, single_value=No
1ce915
         log.info('Reset log file')
1ce915
         f.truncate(0)
1ce915
 
1ce915
+def get_hostnames_from_log(port1, port2):
1ce915
+    # Get the supplier host names as displayed in replication monitor output
1ce915
+    with open(LOG_FILE, 'r') as logfile:
1ce915
+        logtext = logfile.read()
1ce915
+    # search for Supplier :hostname:port 
1ce915
+    # and use \D to insure there is no more number is after
1ce915
+    # the matched port (i.e that 10 is not matching 101)
1ce915
+    regexp = '(Supplier: )([^:]*)(:' + str(port1) + '\D)'
1ce915
+    match=re.search(regexp, logtext)
1ce915
+    host_m1 = 'localhost.localdomain'
1ce915
+    if (match is not None):
1ce915
+        host_m1 = match.group(2)
1ce915
+    # Same for master 2 
1ce915
+    regexp = '(Supplier: )([^:]*)(:' + str(port2) + '\D)'
1ce915
+    match=re.search(regexp, logtext)
1ce915
+    host_m2 = 'localhost.localdomain'
1ce915
+    if (match is not None):
1ce915
+        host_m2 = match.group(2)
1ce915
+    return (host_m1, host_m2)
1ce915
 
1ce915
 @pytest.mark.ds50545
1ce915
 @pytest.mark.bz1739718
1ce915
@@ -177,20 +197,9 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file):
1ce915
                  '001',
1ce915
                  m1.host + ':' + str(m1.port)]
1ce915
 
1ce915
-    dsrc_content = '[repl-monitor-connections]\n' \
1ce915
-                   'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
1ce915
-                   'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
1ce915
-                   '\n' \
1ce915
-                   '[repl-monitor-aliases]\n' \
1ce915
-                   'M1 = ' + m1.host + ':' + str(m1.port) + '\n' \
1ce915
-                   'M2 = ' + m2.host + ':' + str(m2.port)
1ce915
-
1ce915
     connections = [m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM,
1ce915
                    m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM]
1ce915
 
1ce915
-    aliases = ['M1=' + m1.host + ':' + str(m1.port),
1ce915
-               'M2=' + m2.host + ':' + str(m2.port)]
1ce915
-
1ce915
     args = FakeArgs()
1ce915
     args.connections = connections
1ce915
     args.aliases = None
1ce915
@@ -198,8 +207,24 @@ def test_dsconf_replication_monitor(topology_m2, set_log_file):
1ce915
 
1ce915
     log.info('Run replication monitor with connections option')
1ce915
     get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args)
1ce915
+    (host_m1, host_m2) = get_hostnames_from_log(m1.port, m2.port)
1ce915
     check_value_in_log_and_reset(content_list, connection_content, error_list=error_list)
1ce915
 
1ce915
+    # Prepare the data for next tests
1ce915
+    aliases = ['M1=' + host_m1 + ':' + str(m1.port),
1ce915
+               'M2=' + host_m2 + ':' + str(m2.port)]
1ce915
+
1ce915
+    alias_content = ['Supplier: M1 (' + host_m1 + ':' + str(m1.port) + ')',
1ce915
+                     'Supplier: M2 (' + host_m2 + ':' + str(m2.port) + ')']
1ce915
+
1ce915
+    dsrc_content = '[repl-monitor-connections]\n' \
1ce915
+                   'connection1 = ' + m1.host + ':' + str(m1.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
1ce915
+                   'connection2 = ' + m2.host + ':' + str(m2.port) + ':' + DN_DM + ':' + PW_DM + '\n' \
1ce915
+                   '\n' \
1ce915
+                   '[repl-monitor-aliases]\n' \
1ce915
+                   'M1 = ' + host_m1 + ':' + str(m1.port) + '\n' \
1ce915
+                   'M2 = ' + host_m2 + ':' + str(m2.port)
1ce915
+
1ce915
     log.info('Run replication monitor with aliases option')
1ce915
     args.aliases = aliases
1ce915
     get_repl_monitor_info(m1, DEFAULT_SUFFIX, log, args)
1ce915
-- 
1ce915
2.26.2
1ce915