From 0362fa3fc65ea74496da89aafd315eed59d97844 Mon Sep 17 00:00:00 2001 From: Akshay Adhikari Date: Feb 05 2020 11:36:03 +0000 Subject: [PATCH 1/3] Issue 50117 - Add a new CI test case Bug Description: After certain failed import operation, impossible to replay an import operation. Fix Description: Added a test case to Check after certain failed import operation, is it possible to replay an import operation. Relates: https://pagure.io/389-ds-base/issue/50117 Review by: mhonek,tbordaz --- diff --git a/dirsrvtests/tests/suites/import/regression_test.py b/dirsrvtests/tests/suites/import/regression_test.py index d169a92..7be9e39 100644 --- a/dirsrvtests/tests/suites/import/regression_test.py +++ b/dirsrvtests/tests/suites/import/regression_test.py @@ -12,6 +12,12 @@ from lib389.utils import time, ldap, os, logging from lib389.topologies import topology_st as topo from lib389.dbgen import dbgen from lib389._constants import DEFAULT_SUFFIX +from lib389.tasks import * +from lib389.idm.user import UserAccounts +import threading +import time + +from lib389.idm.directorymanager import DirectoryManager pytestmark = pytest.mark.tier1 @@ -30,6 +36,88 @@ TEST_DEFAULT_SUFFIX = "dc=default,dc=com" TEST_DEFAULT_NAME = "default" +class AddDelUsers(threading.Thread): + def __init__(self, inst): + threading.Thread.__init__(self) + self.daemon = True + self.inst = inst + self._should_stop = False + self._ran = False + + def run(self): + # Add 1000 entries + log.info('Run.') + conn = DirectoryManager(self.inst.standalone).bind() + + time.sleep(30) + log.info('Adding users.') + for i in range(1000): + user = UserAccounts(conn, DEFAULT_SUFFIX) + users = user.create_test_user(uid=i) + users.delete() + self._ran = True + if self._should_stop: + break + if not self._should_stop: + raise RuntimeError('We finished too soon.') + conn.close() + + def stop(self): + self._should_stop = True + + def has_started(self): + return self._ran + + +def test_replay_import_operation(topo): + """ Check after certain failed import operation, is it + possible to replay an import operation + + :id: 5f5ca532-8e18-4f7b-86bc-ac585215a473 + :feature: Import + :setup: Standalone instance + :steps: + 1. Export the backend into an ldif file + 2. Perform high load of operation on the server (Add/Del users) + 3. Perform an import operation + 4. Again perform an import operation (same as 3) + :expectedresults: + 1. It should be successful + 2. It should be successful + 3. It should be unsuccessful, should give OPERATIONS_ERROR + 4. It should be successful now + """ + log.info("Exporting LDIF online...") + ldif_dir = topo.standalone.get_ldif_dir() + export_ldif = ldif_dir + '/export.ldif' + + r = ExportTask(topo.standalone) + r.export_suffix_to_ldif(ldiffile=export_ldif, suffix=DEFAULT_SUFFIX) + r.wait() + add_del_users1 = AddDelUsers(topo) + add_del_users1.start() + + log.info("Importing LDIF online, should raise operation error.") + + trials = 0 + while not add_del_users1.has_started() and trials < 10: + trials += 1 + time.sleep(1) + r = ImportTask(topo.standalone) + try: + r.import_suffix_from_ldif(ldiffile=export_ldif, suffix=DEFAULT_SUFFIX) + except ldap.OPERATIONS_ERROR: + break + log.info(f'Looping. Tried {trials} times so far.') + add_del_users1.stop() + add_del_users1.join() + + log.info("Importing LDIF online") + + r = ImportTask(topo.standalone) + r.import_suffix_from_ldif(ldiffile=export_ldif, suffix=DEFAULT_SUFFIX) + + def test_import_be_default(topo): """ Create a backend using the name "default". previously this name was used int @@ -129,7 +217,7 @@ def test_del_suffix_backend(topo): log.info('Adding suffix:{} and backend: {}'.format(TEST_SUFFIX2, TEST_BACKEND2)) backends = Backends(topo.standalone) backend = backends.create(properties={'nsslapd-suffix': TEST_SUFFIX2, - 'name': TEST_BACKEND2}) + 'name': TEST_BACKEND2}) log.info('Create LDIF file and import it') ldif_dir = topo.standalone.get_ldif_dir() From 26d7599442789ceb2d171e8592a8bddf779e8d83 Mon Sep 17 00:00:00 2001 From: Akshay Adhikari Date: Feb 05 2020 11:36:03 +0000 Subject: [PATCH 2/3] Issue 49946 - Add a new CI test case Bug Description: Upgrade of 389-ds-base could remove replication agreements. Fix Description: Added a test case to check if agreement starts with "cn=->..." then after upgrade does it get removed. Relates: https://pagure.io/389-ds-base/issue/49946 Review by: mhonek --- diff --git a/dirsrvtests/tests/suites/replication/regression_test.py b/dirsrvtests/tests/suites/replication/regression_test.py index a948b53..844d762 100644 --- a/dirsrvtests/tests/suites/replication/regression_test.py +++ b/dirsrvtests/tests/suites/replication/regression_test.py @@ -12,14 +12,14 @@ import subprocess from lib389.idm.user import TEST_USER_PROPERTIES, UserAccounts from lib389.pwpolicy import PwPolicyManager from lib389.utils import * -from lib389.topologies import topology_m2 as topo_m2, TopologyMain, topology_m3 as topo_m3, create_topology, _remove_ssca_db +from lib389.topologies import topology_m2 as topo_m2, TopologyMain, topology_m3 as topo_m3, create_topology, _remove_ssca_db, topology_i2 as topo_i2 from lib389._constants import * from lib389.idm.organizationalunit import OrganizationalUnits from lib389.idm.user import UserAccount from lib389.idm.group import Groups, Group from lib389.idm.domain import Domain from lib389.idm.directorymanager import DirectoryManager -from lib389.replica import Replicas, ReplicationManager, Changelog5 +from lib389.replica import Replicas, ReplicationManager, Changelog5, BootstrapReplicationManager from lib389.agreement import Agreements from lib389 import pid_from_file @@ -181,6 +181,57 @@ def add_ldapsubentry(server, parent): pwp.create_subtree_policy(parent, policy_props) +def test_special_symbol_replica_agreement(topo_i2): + """ Check if agreement starts with "cn=->..." then + after upgrade does it get removed. + + :id: 68aa0072-4dd4-4e33-b107-cb383a439125 + :setup: two standalone instance + :steps: + 1. Create and Enable Replication on standalone2 and role as consumer + 2. Create and Enable Replication on standalone1 and role as master + 3. Create a Replication agreement starts with "cn=->..." + 4. Perform an upgrade operation over the master + 5. Check if the agreement is still present or not. + :expectedresults: + 1. It should be successful + 2. It should be successful + 3. It should be successful + 4. It should be successful + 5. It should be successful + """ + + master = topo_i2.ins["standalone1"] + consumer = topo_i2.ins["standalone2"] + consumer.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.CONSUMER, replicaId=CONSUMER_REPLICAID) + repl = ReplicationManager(DEFAULT_SUFFIX) + repl.create_first_master(master) + + properties = {RA_NAME: '-\\3meTo_{}:{}'.format(consumer.host, + str(consumer.port)), + RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], + RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], + RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], + RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]} + + master.agreement.create(suffix=SUFFIX, + host=consumer.host, + port=consumer.port, + properties=properties) + + master.agreement.init(SUFFIX, consumer.host, consumer.port) + + replica_server = Replicas(master).get(DEFAULT_SUFFIX) + + master.upgrade('online') + + agmt = replica_server.get_agreements().list()[0] + + assert agmt.get_attr_val_utf8('cn') == '-\\3meTo_{}:{}'.format(consumer.host, + str(consumer.port)) + + + def test_double_delete(topo_m2, create_entry): """Check that double delete of the entry doesn't crash server From c6ad848118500991cfbc790a7c16e74179c3ce95 Mon Sep 17 00:00:00 2001 From: Akshay Adhikari Date: Feb 05 2020 11:36:03 +0000 Subject: [PATCH 3/3] Issue 50028 - Add a new CI test case Bug Description: There was a request for having -y option for ds-replcheck. Fix Description: Added a test to Check ds-replcheck works if password file is provided with -y option. Relates: https://pagure.io/389-ds-base/issue/50028 Review by: mhonek --- diff --git a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py index 7264a4c..010340a 100644 --- a/dirsrvtests/tests/suites/ds_tools/replcheck_test.py +++ b/dirsrvtests/tests/suites/ds_tools/replcheck_test.py @@ -464,6 +464,38 @@ def test_check_missing_tombstones(topo_tls_ldapi): topo_tls_ldapi.resume_all_replicas() +def test_dsreplcheck_with_password_file(topo_tls_ldapi, tmpdir): + """Check ds-replcheck works if password file is provided + with -y option. + + :id: 0d847ec7-6eaf-4cb5-a9c6-e4a5a1778f93 + :setup: Two master replication + :steps: + 1. Create a password file with the default password of the server. + 2. Run ds-replcheck with -y option (used to pass password file) + :expectedresults: + 1. It should be successful + 2. It should be successful + """ + m1 = topo_tls_ldapi.ms["master1"] + m2 = topo_tls_ldapi.ms["master2"] + + ds_replcheck_path = os.path.join(m1.ds_paths.bin_dir, 'ds-replcheck') + f = tmpdir.mkdir("my_dir").join("password_file.txt") + f.write(PW_DM) + + if ds_is_newer("1.4.1.2"): + tool_cmd = [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-y', f.strpath, + '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), + '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport)] + else: + tool_cmd = [ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-y', f.strpath, + '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), + '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport)] + + subprocess.Popen(tool_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, encoding='utf-8') + + if __name__ == '__main__': # Run isolated # -s for DEBUG mode