andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone

Blame SOURCES/0075-Ticket-49460-replica_write_ruv-log-a-failure-even-wh.patch

96373c
From a0c4a8d69735cb37e5b52b195ec632ce6d1f028f Mon Sep 17 00:00:00 2001
96373c
From: Thierry Bordaz <tbordaz@redhat.com>
96373c
Date: Tue, 21 Nov 2017 17:23:29 +0100
96373c
Subject: [PATCH] Ticket 49460 - replica_write_ruv log a failure even when it
96373c
 succeeds
96373c
96373c
Bug Description:
96373c
	Minor issue
96373c
	If the update of the DB RUV returns a success LDAP_SUCCESS (internal modify),
96373c
	it however logs an error as if it failed
96373c
96373c
	side effect of https://pagure.io/389-ds-base/issue/48118
96373c
96373c
Fix Description:
96373c
	Log a message only on failure
96373c
96373c
https://pagure.io/389-ds-base/issue/49460
96373c
96373c
Reviewed by: Ludwig Krispenz, William Brown
96373c
96373c
Platforms tested: F23
96373c
96373c
Flag Day: no
96373c
96373c
Doc impact: no
96373c
---
96373c
 dirsrvtests/tests/tickets/ticket49460_test.py    | 115 +++++++++++++++++++++++
96373c
 ldap/servers/plugins/replication/repl5_replica.c |   3 +-
96373c
 2 files changed, 116 insertions(+), 2 deletions(-)
96373c
 create mode 100644 dirsrvtests/tests/tickets/ticket49460_test.py
96373c
96373c
diff --git a/dirsrvtests/tests/tickets/ticket49460_test.py b/dirsrvtests/tests/tickets/ticket49460_test.py
96373c
new file mode 100644
96373c
index 000000000..296b3c9aa
96373c
--- /dev/null
96373c
+++ b/dirsrvtests/tests/tickets/ticket49460_test.py
96373c
@@ -0,0 +1,115 @@
96373c
+import time
96373c
+import ldap
96373c
+import logging
96373c
+import pytest
96373c
+import os
96373c
+import re
96373c
+from lib389._constants import *
96373c
+from lib389.config import Config
96373c
+from lib389 import DirSrv, Entry
96373c
+from lib389.topologies import topology_m3 as topo
96373c
+
96373c
+DEBUGGING = os.getenv("DEBUGGING", default=False)
96373c
+if DEBUGGING:
96373c
+    logging.getLogger(__name__).setLevel(logging.DEBUG)
96373c
+else:
96373c
+    logging.getLogger(__name__).setLevel(logging.INFO)
96373c
+log = logging.getLogger(__name__)
96373c
+
96373c
+USER_CN="user"
96373c
+
96373c
+def add_user(server, no, desc='dummy', sleep=True):
96373c
+    cn = '%s%d' % (USER_CN, no)
96373c
+    dn = 'cn=%s,ou=people,%s' % (cn, SUFFIX)
96373c
+    log.fatal('Adding user (%s): ' % dn)
96373c
+    server.add_s(Entry((dn, {'objectclass': ['top', 'person', 'inetuser', 'userSecurityInformation'],
96373c
+                             'sn': ['_%s' % cn],
96373c
+                             'description': [desc]})))
96373c
+    time.sleep(1)
96373c
+
96373c
+def check_user(server, no, timeout=10):
96373c
+
96373c
+    cn = '%s%d' % (USER_CN, no)
96373c
+    dn = 'cn=%s,ou=people,%s' % (cn, SUFFIX)
96373c
+    found = False
96373c
+    cpt = 0
96373c
+    while cpt < timeout:
96373c
+        try:
96373c
+            server.getEntry(dn, ldap.SCOPE_BASE, "(objectclass=*)")
96373c
+            found = True
96373c
+            break
96373c
+        except ldap.NO_SUCH_OBJECT:
96373c
+            time.sleep(1)
96373c
+            cpt += 1
96373c
+    return found
96373c
+
96373c
+def pattern_errorlog(server, log_pattern):
96373c
+    file_obj = open(server.errlog, "r")
96373c
+
96373c
+    found = None
96373c
+    # Use a while true iteration because 'for line in file: hit a
96373c
+    while True:
96373c
+        line = file_obj.readline()
96373c
+        found = log_pattern.search(line)
96373c
+        if ((line == '') or (found)):
96373c
+            break
96373c
+
96373c
+    return found
96373c
+
96373c
+def test_ticket_49460(topo):
96373c
+    """Specify a test case purpose or name here
96373c
+
96373c
+    :id: d1aa2e8b-e6ab-4fc6-9c63-c6f622544f2d
96373c
+    :setup: Fill in set up configuration here
96373c
+    :steps:
96373c
+        1. Enable replication logging
96373c
+        2. Do few updates to generatat RUV update
96373c
+    :expectedresults:
96373c
+        1. No report of failure when the RUV is updated
96373c
+    """
96373c
+
96373c
+    M1 = topo.ms["master1"]
96373c
+    M2 = topo.ms["master2"]
96373c
+    M3 = topo.ms["master3"]
96373c
+
96373c
+    for i in (M1, M2, M3):
96373c
+        i.config.loglevel(vals=[256 + 4], service='access')
96373c
+        i.config.loglevel(vals=[LOG_REPLICA, LOG_DEFAULT], service='error')
96373c
+
96373c
+    add_user(M1, 11, desc="add to M1")
96373c
+    add_user(M2, 21, desc="add to M2")
96373c
+    add_user(M3, 31, desc="add to M3")
96373c
+
96373c
+    for i in (M1, M2, M3):
96373c
+            assert check_user(i, 11)
96373c
+            assert check_user(i, 21)
96373c
+            assert check_user(i, 31)
96373c
+
96373c
+    time.sleep(10)
96373c
+
96373c
+    #M1.tasks.cleanAllRUV(suffix=SUFFIX, replicaid='3',
96373c
+    #                    force=False, args={TASK_WAIT: True})
96373c
+    #time.sleep(10)
96373c
+    regex = re.compile(".*Failed to update RUV tombstone.*LDAP error - 0")
96373c
+    assert not pattern_errorlog(M1, regex)
96373c
+    assert not pattern_errorlog(M2, regex)
96373c
+    assert not pattern_errorlog(M3, regex)
96373c
+
96373c
+    # If you need any test suite initialization,
96373c
+    # please, write additional fixture for that (including finalizer).
96373c
+    # Topology for suites are predefined in lib389/topologies.py.
96373c
+
96373c
+    # If you need host, port or any other data about instance,
96373c
+    # Please, use the instance object attributes for that (for example, topo.ms["master1"].serverid)
96373c
+
96373c
+    if DEBUGGING:
96373c
+        # Add debugging steps(if any)...
96373c
+        pass
96373c
+
96373c
+
96373c
+if __name__ == '__main__':
96373c
+    # Run isolated
96373c
+    # -s for DEBUG mode
96373c
+    CURRENT_FILE = os.path.realpath(__file__)
96373c
+    pytest.main("-s %s" % CURRENT_FILE)
96373c
+
96373c
diff --git a/ldap/servers/plugins/replication/repl5_replica.c b/ldap/servers/plugins/replication/repl5_replica.c
96373c
index e3ddd783d..c6d6ee746 100644
96373c
--- a/ldap/servers/plugins/replication/repl5_replica.c
96373c
+++ b/ldap/servers/plugins/replication/repl5_replica.c
96373c
@@ -2829,8 +2829,7 @@ replica_write_ruv(Replica *r)
96373c
         /* this includes an internal operation - but since this only happens
96373c
            during server startup - its ok that we have lock around it */
96373c
         rc = _replica_configure_ruv(r, PR_TRUE);
96373c
-    } else /* error */
96373c
-    {
96373c
+    } else if (rc != LDAP_SUCCESS) { /* error */
96373c
         slapi_log_err(SLAPI_LOG_REPL, repl_plugin_name,
96373c
                       "replica_write_ruv - Failed to update RUV tombstone for %s; "
96373c
                       "LDAP error - %d\n",
96373c
-- 
96373c
2.13.6
96373c