diff --git a/dirsrvtests/tests/suites/replication/acceptance_test.py b/dirsrvtests/tests/suites/replication/acceptance_test.py index 66368774b..c2f3f2572 100644 --- a/dirsrvtests/tests/suites/replication/acceptance_test.py +++ b/dirsrvtests/tests/suites/replication/acceptance_test.py @@ -85,158 +85,6 @@ def fin(): request.addfinalizer(fin) -def test_multi_subsuffix_replication(topo_m4): - """Check that replication works with multiple subsuffixes - - :id: ac1aaeae-173e-48e7-847f-03b9867443c4 - :setup: Four suppliers replication setup - :steps: - 1. Create additional suffixes - 2. Setup replication for all suppliers - 3. Generate test data for each suffix (add, modify, remove) - 4. Wait for replication to complete across all suppliers for each suffix - 5. Check that all expected data is present on all suppliers - :expectedresults: - 1. Success - 2. Success - 3. Success - 4. Success - 5. Success (the data is replicated everywhere) - """ - - SUFFIX_2 = "dc=test2" - SUFFIX_3 = f"dc=test3,{DEFAULT_SUFFIX}" - all_suffixes = [DEFAULT_SUFFIX, SUFFIX_2, SUFFIX_3] - - test_users_by_suffix = {suffix: [] for suffix in all_suffixes} - created_backends = [] - - suppliers = [ - topo_m4.ms["supplier1"], - topo_m4.ms["supplier2"], - topo_m4.ms["supplier3"], - topo_m4.ms["supplier4"] - ] - - try: - # Setup additional backends and replication for the new suffixes - for suffix in [SUFFIX_2, SUFFIX_3]: - repl = ReplicationManager(suffix) - for supplier in suppliers: - # Create a new backend for this suffix - props = { - 'cn': f'userRoot_{suffix.split(",")[0][3:]}', - 'nsslapd-suffix': suffix - } - be = Backend(supplier) - be.create(properties=props) - be.create_sample_entries('001004002') - - # Track the backend so we can remove it later - created_backends.append((supplier, props['cn'])) - - # Enable replication - if supplier == suppliers[0]: - repl.create_first_supplier(supplier) - else: - repl.join_supplier(suppliers[0], supplier) - - # Create a full mesh topology for this suffix - for i, supplier_i in enumerate(suppliers): - for j, supplier_j in enumerate(suppliers): - if i != j: - repl.ensure_agreement(supplier_i, supplier_j) - - # Generate test data for each suffix (add, modify, remove) - for suffix in all_suffixes: - # Create some user entries in supplier1 - for i in range(20): - user_dn = f'uid=test_user_{i},{suffix}' - test_user = UserAccount(suppliers[0], user_dn) - test_user.create(properties={ - 'uid': f'test_user_{i}', - 'cn': f'Test User {i}', - 'sn': f'User{i}', - 'userPassword': 'password', - 'uidNumber': str(1000 + i), - 'gidNumber': '2000', - 'homeDirectory': f'/home/test_user_{i}' - }) - test_users_by_suffix[suffix].append(test_user) - - # Perform modifications on these entries - for user in test_users_by_suffix[suffix]: - # Add some attributes - for j in range(3): - user.add('description', f'Description {j}') - # Replace an attribute - user.replace('cn', f'Modified User {user.get_attr_val_utf8("uid")}') - # Delete the attributes we added - for j in range(3): - try: - user.remove('description', f'Description {j}') - except Exception: - pass - - # Wait for replication to complete across all suppliers, for each suffix - for suffix in all_suffixes: - repl = ReplicationManager(suffix) - for i, supplier_i in enumerate(suppliers): - for j, supplier_j in enumerate(suppliers): - if i != j: - repl.wait_for_replication(supplier_i, supplier_j) - - # Verify that each user and modification replicated to all suppliers - for suffix in all_suffixes: - for i in range(20): - user_dn = f'uid=test_user_{i},{suffix}' - # Retrieve this user from all suppliers - all_user_objs = topo_m4.all_get_dsldapobject(user_dn, UserAccount) - # Ensure it exists in all 4 suppliers - assert len(all_user_objs) == 4, ( - f"User {user_dn} not found on all suppliers. " - f"Found only on {len(all_user_objs)} suppliers." - ) - # Check modifications: 'cn' should now be 'Modified User test_user_{i}' - for user_obj in all_user_objs: - expected_cn = f"Modified User test_user_{i}" - actual_cn = user_obj.get_attr_val_utf8("cn") - assert actual_cn == expected_cn, ( - f"User {user_dn} has unexpected 'cn': {actual_cn} " - f"(expected '{expected_cn}') on supplier {user_obj._instance.serverid}" - ) - # And check that 'description' attributes were removed - desc_vals = user_obj.get_attr_vals_utf8('description') - for j in range(3): - assert f"Description {j}" not in desc_vals, ( - f"User {user_dn} on supplier {user_obj._instance.serverid} " - f"still has 'Description {j}'" - ) - finally: - for suffix, test_users in test_users_by_suffix.items(): - for user in test_users: - try: - if user.exists(): - user.delete() - except Exception: - pass - - for suffix in [SUFFIX_2, SUFFIX_3]: - repl = ReplicationManager(suffix) - for supplier in suppliers: - try: - repl.remove_supplier(supplier) - except Exception: - pass - - for (supplier, backend_name) in created_backends: - be = Backend(supplier, backend_name) - try: - be.delete() - except Exception: - pass - - def test_add_entry(topo_m4, create_entry): """Check that entries are replicated after add operation @@ -477,6 +325,158 @@ def test_modify_stripattrs(topo_m4): assert attr_value in entries[0].data['nsds5replicastripattrs'] +def test_multi_subsuffix_replication(topo_m4): + """Check that replication works with multiple subsuffixes + + :id: ac1aaeae-173e-48e7-847f-03b9867443c4 + :setup: Four suppliers replication setup + :steps: + 1. Create additional suffixes + 2. Setup replication for all suppliers + 3. Generate test data for each suffix (add, modify, remove) + 4. Wait for replication to complete across all suppliers for each suffix + 5. Check that all expected data is present on all suppliers + :expectedresults: + 1. Success + 2. Success + 3. Success + 4. Success + 5. Success (the data is replicated everywhere) + """ + + SUFFIX_2 = "dc=test2" + SUFFIX_3 = f"dc=test3,{DEFAULT_SUFFIX}" + all_suffixes = [DEFAULT_SUFFIX, SUFFIX_2, SUFFIX_3] + + test_users_by_suffix = {suffix: [] for suffix in all_suffixes} + created_backends = [] + + suppliers = [ + topo_m4.ms["supplier1"], + topo_m4.ms["supplier2"], + topo_m4.ms["supplier3"], + topo_m4.ms["supplier4"] + ] + + try: + # Setup additional backends and replication for the new suffixes + for suffix in [SUFFIX_2, SUFFIX_3]: + repl = ReplicationManager(suffix) + for supplier in suppliers: + # Create a new backend for this suffix + props = { + 'cn': f'userRoot_{suffix.split(",")[0][3:]}', + 'nsslapd-suffix': suffix + } + be = Backend(supplier) + be.create(properties=props) + be.create_sample_entries('001004002') + + # Track the backend so we can remove it later + created_backends.append((supplier, props['cn'])) + + # Enable replication + if supplier == suppliers[0]: + repl.create_first_supplier(supplier) + else: + repl.join_supplier(suppliers[0], supplier) + + # Create a full mesh topology for this suffix + for i, supplier_i in enumerate(suppliers): + for j, supplier_j in enumerate(suppliers): + if i != j: + repl.ensure_agreement(supplier_i, supplier_j) + + # Generate test data for each suffix (add, modify, remove) + for suffix in all_suffixes: + # Create some user entries in supplier1 + for i in range(20): + user_dn = f'uid=test_user_{i},{suffix}' + test_user = UserAccount(suppliers[0], user_dn) + test_user.create(properties={ + 'uid': f'test_user_{i}', + 'cn': f'Test User {i}', + 'sn': f'User{i}', + 'userPassword': 'password', + 'uidNumber': str(1000 + i), + 'gidNumber': '2000', + 'homeDirectory': f'/home/test_user_{i}' + }) + test_users_by_suffix[suffix].append(test_user) + + # Perform modifications on these entries + for user in test_users_by_suffix[suffix]: + # Add some attributes + for j in range(3): + user.add('description', f'Description {j}') + # Replace an attribute + user.replace('cn', f'Modified User {user.get_attr_val_utf8("uid")}') + # Delete the attributes we added + for j in range(3): + try: + user.remove('description', f'Description {j}') + except Exception: + pass + + # Wait for replication to complete across all suppliers, for each suffix + for suffix in all_suffixes: + repl = ReplicationManager(suffix) + for i, supplier_i in enumerate(suppliers): + for j, supplier_j in enumerate(suppliers): + if i != j: + repl.wait_for_replication(supplier_i, supplier_j) + + # Verify that each user and modification replicated to all suppliers + for suffix in all_suffixes: + for i in range(20): + user_dn = f'uid=test_user_{i},{suffix}' + # Retrieve this user from all suppliers + all_user_objs = topo_m4.all_get_dsldapobject(user_dn, UserAccount) + # Ensure it exists in all 4 suppliers + assert len(all_user_objs) == 4, ( + f"User {user_dn} not found on all suppliers. " + f"Found only on {len(all_user_objs)} suppliers." + ) + # Check modifications: 'cn' should now be 'Modified User test_user_{i}' + for user_obj in all_user_objs: + expected_cn = f"Modified User test_user_{i}" + actual_cn = user_obj.get_attr_val_utf8("cn") + assert actual_cn == expected_cn, ( + f"User {user_dn} has unexpected 'cn': {actual_cn} " + f"(expected '{expected_cn}') on supplier {user_obj._instance.serverid}" + ) + # And check that 'description' attributes were removed + desc_vals = user_obj.get_attr_vals_utf8('description') + for j in range(3): + assert f"Description {j}" not in desc_vals, ( + f"User {user_dn} on supplier {user_obj._instance.serverid} " + f"still has 'Description {j}'" + ) + finally: + for suffix, test_users in test_users_by_suffix.items(): + for user in test_users: + try: + if user.exists(): + user.delete() + except Exception: + pass + + for suffix in [SUFFIX_2, SUFFIX_3]: + repl = ReplicationManager(suffix) + for supplier in suppliers: + try: + repl.remove_supplier(supplier) + except Exception: + pass + + for (supplier, backend_name) in created_backends: + be = Backend(supplier, backend_name) + try: + be.delete() + except Exception: + pass + + def test_new_suffix(topo_m4, new_suffix): """Check that we can enable replication on a new suffix