Debian Codegraph @

dirsrvtests/tests/suites/export/export_reindex_tombstone_test.py

raw
1 # --- BEGIN COPYRIGHT BLOCK ---
2 # Copyright (C) 2026 Red Hat, Inc.
3 # All rights reserved.
4 #
5 # License: GPL (version 3 or any later version).
6 # See LICENSE for details.
7 # --- END COPYRIGHT BLOCK ---
8
9 import os
10 import time
11 import pytest
12 import ldap
13 from lib389.idm.user import UserAccounts
14 from lib389.idm.domain import Domain
15 from lib389.tombstone import Tombstones
16 from test389.topologies import topology_m2 as topo_m2
17 from lib389._constants import DEFAULT_SUFFIX, DEFAULT_BENAME, ErrorLog
18 from lib389.utils import *
19 from lib389.backend import Backends
20 from lib389.replica import Replicas, ReplicationManager
21
22 pytestmark = pytest.mark.tier1
23
24
25 def test_export_after_reindex_and_tombstone_purge(topo_m2):
26 """Test that export with -s works after reindex and tombstone purge.
27
28 :id: 8c5cb603-1f43-46ad-9935-5f518d6d7fe0
29 :setup: Two supplier replication topology
30 :steps:
31 1. Add entries under ou=people on S1, wait for replication to S2
32 2. Delete the entries on S1, wait for replication
33 3. Perform additional modifications to advance the RUV
34 4. Reindex S1
35 5. Configure aggressive tombstone purging and wait for tombstones to be purged on S1
36 6. Export ou=people,dc=example,dc=com with -s
37 :expectedresults:
38 1. Success
39 2. Success
40 3. Success
41 4. Success
42 5. Success
43 6. Export completes successfully
44 """
45 S1 = topo_m2.ms["supplier1"]
46 S2 = topo_m2.ms["supplier2"]
47 PEOPLE = f"ou=people,{DEFAULT_SUFFIX}"
48
49 users = UserAccounts(S1, DEFAULT_SUFFIX, rdn="ou=people")
50 test_users = []
51 for i in range(5):
52 user = users.create_test_user(uid=1234 + i)
53 test_users.append(user)
54 log.info("Added 5 test entries under ou=people")
55
56 repl = ReplicationManager(DEFAULT_SUFFIX)
57 repl.wait_for_replication(S1, S2)
58
59 for user in test_users:
60 user.delete()
61 log.info("Deleted 5 test entries")
62
63 repl.wait_for_replication(S1, S2)
64
65 domain = Domain(S1, DEFAULT_SUFFIX)
66 for i in range(10):
67 domain.replace("description", f"advancing RUV {i}")
68 repl.wait_for_replication(S1, S2)
69
70 domain2 = Domain(S2, DEFAULT_SUFFIX)
71 for i in range(10):
72 domain2.replace("description", f"advancing RUV from S2 {i}")
73 repl.wait_for_replication(S2, S1)
74 log.info("RUV advanced on both suppliers")
75
76 S1.stop()
77 S1.db2index(DEFAULT_BENAME)
78 log.info("Reindex completed on S1")
79 S1.start()
80
81 replica = Replicas(S1).get(DEFAULT_SUFFIX)
82 replica.replace("nsDS5ReplicaPurgeDelay", "1")
83 replica.replace("nsDS5ReplicaTombstonePurgeInterval", "1")
84
85 S1.config.loglevel((ErrorLog.REPLICA,), "error")
86
87 log.info("Waiting for tombstone purge on S1...")
88 tombstones = Tombstones(S1, PEOPLE)
89 for attempt in range(60):
90 time.sleep(2)
91 ts_list = tombstones.list()
92 if len(ts_list) == 0:
93 log.info(f"All tombstones purged after {(attempt + 1) * 2}s")
94 break
95 log.info(f"Attempt {attempt + 1}: {len(ts_list)} tombstones remaining")
96 else:
97 pytest.fail("Tombstones not purged after 120s")
98
99 S1.deleteErrorLogs()
100
101 backends = Backends(S1)
102 task = backends.export_ldif(be_names=[DEFAULT_BENAME], include_suffixes=[PEOPLE])
103 task.wait()
104 assert task.is_complete()
105 assert task.get_exit_code() == 0
106
107 log.info("Export after reindex + tombstone purge succeeded")