Debian Codegraph @

dirsrvtests/tests/suites/healthcheck/health_system_indexes_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
10 import pytest
11 import os
12
13 from lib389.backend import Backends
14 from lib389.index import Index
15 from lib389.plugins import (
16 USNPlugin,
17 RetroChangelogPlugin,
18 )
19 from lib389.utils import logging, ds_is_newer
20 from lib389.cli_base import FakeArgs
21 from test389.topologies import topology_st
22 from lib389.cli_ctl.health import health_check_run
23
24 pytestmark = pytest.mark.tier1
25
26 CMD_OUTPUT = "No issues found."
27 JSON_OUTPUT = "[]"
28 log = logging.getLogger(__name__)
29
30
31 def stop_and_flush(inst):
32 inst.stop()
33 inst.lint_clear_dse_cache()
34
35
36 @pytest.fixture(scope="function")
37 def usn_plugin_enabled(topology_st, request):
38 """Fixture to enable USN plugin and ensure cleanup after test"""
39 standalone = topology_st.standalone
40
41 log.info("Enable USN plugin")
42 usn_plugin = USNPlugin(standalone)
43 usn_plugin.enable()
44 standalone.restart()
45
46 def cleanup():
47 log.info("Disable USN plugin")
48 usn_plugin.disable()
49 standalone.restart()
50
51 request.addfinalizer(cleanup)
52 return usn_plugin
53
54
55 @pytest.fixture(scope="function")
56 def retrocl_plugin_enabled(topology_st, request):
57 """Fixture to enable RetroCL plugin and ensure cleanup after test"""
58 standalone = topology_st.standalone
59
60 log.info("Enable RetroCL plugin")
61 retrocl_plugin = RetroChangelogPlugin(standalone)
62 retrocl_plugin.enable()
63 standalone.restart()
64
65 def cleanup():
66 log.info("Disable RetroCL plugin")
67 retrocl_plugin.disable()
68 standalone.restart()
69
70 request.addfinalizer(cleanup)
71 return retrocl_plugin
72
73
74 @pytest.fixture(scope="function")
75 def log_buffering_enabled(topology_st, request):
76 """Fixture to enable log buffering and restore original setting after test"""
77 standalone = topology_st.standalone
78
79 original_value = standalone.config.get_attr_val_utf8("nsslapd-accesslog-logbuffering")
80
81 log.info("Enable log buffering")
82 standalone.config.set("nsslapd-accesslog-logbuffering", "on")
83
84 def cleanup():
85 log.info("Restore original log buffering setting")
86 standalone.config.set("nsslapd-accesslog-logbuffering", original_value)
87
88 request.addfinalizer(cleanup)
89 return standalone
90
91
92 def run_healthcheck_and_flush_log(topology, instance, searched_code, json, searched_code2=None):
93 # If we are using BDB as a backend, we will get error DSBLE0006 on new versions
94 if (
95 ds_is_newer("3.0.0")
96 and instance.get_db_lib() == "bdb"
97 and (searched_code is CMD_OUTPUT or searched_code is JSON_OUTPUT)
98 ):
99 searched_code = "DSBLE0006"
100
101 args = FakeArgs()
102 args.instance = instance.serverid
103 args.verbose = instance.verbose
104 args.list_errors = False
105 args.list_checks = False
106 args.exclude_check = []
107 args.check = [
108 "config",
109 "refint",
110 "backends",
111 "monitor-disk-space",
112 "logs",
113 "memberof",
114 ]
115 args.dry_run = False
116
117 if json:
118 log.info("Use healthcheck with --json option")
119 args.json = json
120 health_check_run(instance, topology.logcap.log, args)
121 assert topology.logcap.contains(searched_code)
122 log.info("healthcheck returned searched code: %s" % searched_code)
123
124 if searched_code2 is not None:
125 assert topology.logcap.contains(searched_code2)
126 log.info("healthcheck returned searched code: %s" % searched_code2)
127 else:
128 log.info("Use healthcheck without --json option")
129 args.json = json
130 health_check_run(instance, topology.logcap.log, args)
131
132 assert topology.logcap.contains(searched_code)
133 log.info("healthcheck returned searched code: %s" % searched_code)
134
135 if searched_code2 is not None:
136 assert topology.logcap.contains(searched_code2)
137 log.info("healthcheck returned searched code: %s" % searched_code2)
138
139 log.info("Clear the log")
140 topology.logcap.flush()
141
142
143 def test_missing_parentid(topology_st, log_buffering_enabled):
144 """Check if healthcheck returns DSBLE0007 code when parentId system index is missing
145
146 :id: 2653f16f-cc9c-4fad-9d8c-86a3457c6d0d
147 :setup: Standalone instance
148 :steps:
149 1. Create DS instance
150 2. Remove parentId index
151 3. Use healthcheck without --json option
152 4. Use healthcheck with --json option
153 5. Re-add the parentId index
154 6. Use healthcheck without --json option
155 7. Use healthcheck with --json option
156 :expectedresults:
157 1. Success
158 2. Success
159 3. healthcheck reports DSBLE0007 code and related details
160 4. healthcheck reports DSBLE0007 code and related details
161 5. Success
162 6. healthcheck reports no issues found
163 7. healthcheck reports no issues found
164 """
165
166 RET_CODE = "DSBLE0007"
167 PARENTID_DN = "cn=parentid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
168
169 standalone = topology_st.standalone
170
171 log.info("Remove parentId index")
172 parentid_index = Index(standalone, PARENTID_DN)
173 parentid_index.delete()
174
175 stop_and_flush(standalone)
176 try:
177 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
178 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
179 finally:
180 if not standalone.status():
181 standalone.start()
182
183 # The server adds the index config entry at server startup so we need to
184 # delete it again
185 parentid_index.delete()
186 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
187 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
188
189 log.info("Re-add the parentId index")
190 backend = Backends(standalone).get("userRoot")
191 backend.add_index("parentid", ["eq"], matching_rules=["integerOrderingMatch"])
192
193 stop_and_flush(standalone)
194 try:
195 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
196 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
197 finally:
198 if not standalone.status():
199 standalone.start()
200
201 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
202 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
203
204
205 def test_missing_matching_rule(topology_st, log_buffering_enabled):
206 """Check that healthcheck does NOT report DSBLE0007 when parentId index is missing integerOrderingMatch.
207 Both lexicographic and integer orderings are valid for parentid.
208
209 :id: 7ffa71db-8995-430a-bed8-59bce944221c
210 :setup: Standalone instance
211 :steps:
212 1. Create DS instance
213 2. Remove integerOrderingMatch matching rule from parentId index
214 3. Use healthcheck without --json option
215 4. Use healthcheck with --json option
216 5. Re-add the matching rule
217 :expectedresults:
218 1. Success
219 2. Success
220 3. healthcheck reports no issues found
221 4. healthcheck reports no issues found
222 5. Success
223 """
224
225 PARENTID_DN = "cn=parentid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
226
227 standalone = topology_st.standalone
228
229 log.info("Remove integerOrderingMatch matching rule from parentId index")
230 parentid_index = Index(standalone, PARENTID_DN)
231 parentid_index.remove("nsMatchingRule", "integerOrderingMatch")
232
233 stop_and_flush(standalone)
234 try:
235 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
236 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
237 finally:
238 if not standalone.status():
239 standalone.start()
240 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
241 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
242
243 log.info("Re-add the integerOrderingMatch matching rule")
244 parentid_index = Index(standalone, PARENTID_DN)
245 parentid_index.add("nsMatchingRule", "integerOrderingMatch")
246 standalone.restart()
247
248
249 def test_usn_plugin_missing_entryusn(topology_st, usn_plugin_enabled, log_buffering_enabled):
250 """Check if healthcheck returns DSBLE0007 code when USN plugin is enabled but entryusn index is missing
251
252 :id: 4879dfc8-cd96-43e6-9ebc-053fc8e64ad0
253 :setup: Standalone instance
254 :steps:
255 1. Create DS instance
256 2. Enable USN plugin
257 3. Remove entryusn index
258 4. Use healthcheck without --json option
259 5. Use healthcheck with --json option
260 6. Re-add the entryusn index
261 7. Use healthcheck without --json option
262 8. Use healthcheck with --json option
263 :expectedresults:
264 1. Success
265 2. Success
266 3. Success
267 4. healthcheck reports DSBLE0007 code and related details
268 5. healthcheck reports DSBLE0007 code and related details
269 6. Success
270 7. healthcheck reports no issues found
271 8. healthcheck reports no issues found
272 """
273
274 RET_CODE = "DSBLE0007"
275 ENTRYUSN_DN = "cn=entryusn,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
276
277 standalone = topology_st.standalone
278
279 log.info("Remove entryusn index")
280 entryusn_index = Index(standalone, ENTRYUSN_DN)
281 entryusn_index.delete()
282
283 stop_and_flush(standalone)
284 try:
285 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
286 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
287 finally:
288 if not standalone.status():
289 standalone.start()
290
291 # The server adds the index config entry at server startup so we need to
292 # delete it again
293 entryusn_index.delete()
294 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
295 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
296
297 log.info("Re-add the entryusn index")
298 backend = Backends(standalone).get("userRoot")
299 backend.add_index("entryusn", ["eq"], matching_rules=["integerOrderingMatch"])
300
301 stop_and_flush(standalone)
302 try:
303 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
304 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
305 finally:
306 if not standalone.status():
307 standalone.start()
308 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
309 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
310
311
312 def test_usn_plugin_missing_matching_rule(topology_st, usn_plugin_enabled, log_buffering_enabled):
313 """Check if healthcheck returns DSBLE0007 code when USN plugin is enabled but entryusn index is missing integerOrderingMatch
314
315 :id: b00b419f-2ca6-451f-a9b2-f22ad6b10718
316 :setup: Standalone instance
317 :steps:
318 1. Create DS instance
319 2. Enable USN plugin
320 3. Remove integerOrderingMatch matching rule from entryusn index
321 4. Use healthcheck without --json option
322 5. Use healthcheck with --json option
323 6. Re-add the matching rule
324 7. Use healthcheck without --json option
325 8. Use healthcheck with --json option
326 :expectedresults:
327 1. Success
328 2. Success
329 3. Success
330 4. healthcheck reports DSBLE0007 code and related details
331 5. healthcheck reports DSBLE0007 code and related details
332 6. Success
333 7. healthcheck reports no issues found
334 8. healthcheck reports no issues found
335 """
336
337 RET_CODE = "DSBLE0007"
338 ENTRYUSN_DN = "cn=entryusn,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
339
340 standalone = topology_st.standalone
341
342 log.info("Create or modify entryusn index without integerOrderingMatch")
343 entryusn_index = Index(standalone, ENTRYUSN_DN)
344 entryusn_index.remove("nsMatchingRule", "integerOrderingMatch")
345
346 stop_and_flush(standalone)
347 try:
348 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
349 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
350 finally:
351 if not standalone.status():
352 standalone.start()
353 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
354 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
355
356 log.info("Re-add the integerOrderingMatch matching rule")
357 entryusn_index = Index(standalone, ENTRYUSN_DN)
358 entryusn_index.add("nsMatchingRule", "integerOrderingMatch")
359
360 stop_and_flush(standalone)
361 try:
362 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
363 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
364 finally:
365 if not standalone.status():
366 standalone.start()
367 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
368 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
369
370
371 def test_retrocl_plugin_missing_changenumber(topology_st, retrocl_plugin_enabled, log_buffering_enabled):
372 """Check if healthcheck returns DSBLE0007 code when RetroCL plugin is enabled but changeNumber index is missing from changelog backend
373
374 :id: 3e1a3625-4e6f-4e23-868d-6f32e018ad7e
375 :setup: Standalone instance
376 :steps:
377 1. Create DS instance
378 2. Enable RetroCL plugin
379 3. Remove changeNumber index from changelog backend
380 4. Use healthcheck without --json option
381 5. Use healthcheck with --json option
382 6. Re-add the changeNumber index
383 7. Use healthcheck without --json option
384 8. Use healthcheck with --json option
385 :expectedresults:
386 1. Success
387 2. Success
388 3. Success
389 4. healthcheck reports DSBLE0007 code and related details
390 5. healthcheck reports DSBLE0007 code and related details
391 6. Success
392 7. healthcheck reports no issues found
393 8. healthcheck reports no issues found
394 """
395
396 RET_CODE = "DSBLE0007"
397
398 standalone = topology_st.standalone
399
400 log.info("Remove changeNumber index from changelog backend")
401 changenumber_dn = "cn=changenumber,cn=index,cn=changelog,cn=ldbm database,cn=plugins,cn=config"
402 changenumber_index = Index(standalone, changenumber_dn)
403 changenumber_index.delete()
404
405 stop_and_flush(standalone)
406 try:
407 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
408 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
409 finally:
410 if not standalone.status():
411 standalone.start()
412
413 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
414 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
415
416 log.info("Re-add the changeNumber index")
417 backends = Backends(standalone)
418 changelog_backend = backends.get("changelog")
419 changelog_backend.add_index("changenumber", ["eq"], matching_rules=["integerOrderingMatch"])
420 log.info("Successfully re-added changeNumber index")
421
422 stop_and_flush(standalone)
423 try:
424 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
425 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
426 finally:
427 if not standalone.status():
428 standalone.start()
429 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
430 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
431
432
433 def test_retrocl_plugin_missing_matching_rule(topology_st, retrocl_plugin_enabled, log_buffering_enabled):
434 """Check if healthcheck returns DSBLE0007 code when RetroCL plugin is enabled but changeNumber index is missing integerOrderingMatch
435
436 :id: 1c68b1b2-90a9-4ec0-815a-a626b20744fe
437 :setup: Standalone instance
438 :steps:
439 1. Create DS instance
440 2. Enable RetroCL plugin
441 3. Remove integerOrderingMatch matching rule from changeNumber index
442 4. Use healthcheck without --json option
443 5. Use healthcheck with --json option
444 6. Re-add the matching rule
445 7. Use healthcheck without --json option
446 8. Use healthcheck with --json option
447 :expectedresults:
448 1. Success
449 2. Success
450 3. Success
451 4. healthcheck reports DSBLE0007 code and related details
452 5. healthcheck reports DSBLE0007 code and related details
453 6. Success
454 7. healthcheck reports no issues found
455 8. healthcheck reports no issues found
456 """
457
458 RET_CODE = "DSBLE0007"
459
460 standalone = topology_st.standalone
461
462 log.info("Remove integerOrderingMatch matching rule from changeNumber index")
463 changenumber_dn = "cn=changenumber,cn=index,cn=changelog,cn=ldbm database,cn=plugins,cn=config"
464 changenumber_index = Index(standalone, changenumber_dn)
465 changenumber_index.remove("nsMatchingRule", "integerOrderingMatch")
466
467 stop_and_flush(standalone)
468 try:
469 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
470 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
471 finally:
472 if not standalone.status():
473 standalone.start()
474 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
475 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
476
477 log.info("Re-add the integerOrderingMatch matching rule")
478 changenumber_index = Index(standalone, changenumber_dn)
479 changenumber_index.add("nsMatchingRule", "integerOrderingMatch")
480 log.info("Successfully re-added integerOrderingMatch to changeNumber index")
481
482 stop_and_flush(standalone)
483 try:
484 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
485 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
486 finally:
487 if not standalone.status():
488 standalone.start()
489 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
490 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
491
492
493 def test_multiple_missing_indexes(topology_st, log_buffering_enabled):
494 """Check if healthcheck returns DSBLE0007 code when multiple system indexes are missing
495
496 :id: f7cfcd6e-3c47-4ba5-bb2b-1f8e7a29c899
497 :setup: Standalone instance
498 :steps:
499 1. Create DS instance
500 2. Remove multiple system indexes (parentId, nsUniqueId)
501 3. Use healthcheck without --json option
502 4. Use healthcheck with --json option
503 5. Re-add the missing indexes
504 6. Use healthcheck without --json option
505 7. Use healthcheck with --json option
506 :expectedresults:
507 1. Success
508 2. Success
509 3. healthcheck reports DSBLE0007 code and related details
510 4. healthcheck reports DSBLE0007 code and related details
511 5. Success
512 6. healthcheck reports no issues found
513 7. healthcheck reports no issues found
514 """
515
516 RET_CODE = "DSBLE0007"
517 PARENTID_DN = "cn=parentid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
518 NSUNIQUEID_DN = "cn=nsuniqueid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
519
520 standalone = topology_st.standalone
521
522 log.info("Remove multiple system indexes")
523 for index_dn in [PARENTID_DN, NSUNIQUEID_DN]:
524 index = Index(standalone, index_dn)
525 index.delete()
526 log.info(f"Successfully removed index: {index_dn}")
527
528 stop_and_flush(standalone)
529 try:
530 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
531 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
532 finally:
533 if not standalone.status():
534 standalone.start()
535
536 # The server adds the index config entries at server startup so we need to
537 # delete it again
538 for index_dn in [PARENTID_DN, NSUNIQUEID_DN]:
539 index = Index(standalone, index_dn)
540 index.delete()
541 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=RET_CODE)
542 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=RET_CODE)
543
544 log.info("Re-add the missing system indexes")
545 backend = Backends(standalone).get("userRoot")
546 backend.add_index("parentid", ["eq"], matching_rules=["integerOrderingMatch"])
547 backend.add_index("nsuniqueid", ["eq"])
548 standalone.restart()
549
550 stop_and_flush(standalone)
551 try:
552 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
553 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
554 finally:
555 if not standalone.status():
556 standalone.start()
557 run_healthcheck_and_flush_log(topology_st, standalone, json=False, searched_code=CMD_OUTPUT)
558 run_healthcheck_and_flush_log(topology_st, standalone, json=True, searched_code=JSON_OUTPUT)
559
560
561 def test_upgrade_removes_parentid_scanlimit(topology_st):
562 """Check if upgrade function removes nsIndexIDListScanLimit from parentid index
563
564 :id: 2808886e-c1c1-441d-b3a3-299c4ef1ab4a
565 :setup: Standalone instance
566 :steps:
567 1. Create DS instance
568 2. Stop the server
569 3. Use DSEldif to add nsIndexIDListScanLimit to parentid index
570 4. Start the server (triggers upgrade)
571 5. Verify nsIndexIDListScanLimit is removed from parentid index
572 :expectedresults:
573 1. Success
574 2. Success
575 3. Success
576 4. Success
577 5. nsIndexIDListScanLimit is no longer present
578 """
579 from lib389.dseldif import DSEldif
580
581 standalone = topology_st.standalone
582 PARENTID_DN = "cn=parentid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
583 SCANLIMIT_VALUE = "limit=5000 type=eq flags=AND"
584
585 log.info("Stop the server")
586 standalone.stop()
587
588 log.info("Add nsIndexIDListScanLimit to parentid index using DSEldif")
589 dse_ldif = DSEldif(standalone)
590 dse_ldif.add(PARENTID_DN, "nsIndexIDListScanLimit", SCANLIMIT_VALUE)
591
592 # Verify it was added
593 scanlimit = dse_ldif.get(PARENTID_DN, "nsIndexIDListScanLimit")
594 assert scanlimit is not None, "Failed to add nsIndexIDListScanLimit"
595 log.info(f"Added nsIndexIDListScanLimit: {scanlimit}")
596
597 log.info("Start the server (triggers upgrade)")
598 standalone.start()
599
600 log.info("Verify nsIndexIDListScanLimit was removed by upgrade")
601 # Check via LDAP - the upgrade should have removed it
602 parentid_index = Index(standalone, PARENTID_DN)
603 scanlimit_after = parentid_index.get_attr_vals_utf8("nsIndexIDListScanLimit")
604 log.info(f"nsIndexIDListScanLimit after upgrade: {scanlimit_after}")
605
606 # The upgrade function should have removed nsIndexIDListScanLimit
607 assert not scanlimit_after, \
608 f"nsIndexIDListScanLimit should have been removed but found: {scanlimit_after}"
609
610 log.info("Upgrade successfully removed nsIndexIDListScanLimit from parentid index")
611
612 # Verify idempotency - restart again and ensure no errors
613 log.info("Restart server again to verify idempotency (no errors on second run)")
614 standalone.restart()
615 # Verify the attribute is still absent
616 scanlimit_after_second = parentid_index.get_attr_vals_utf8("nsIndexIDListScanLimit")
617 assert not scanlimit_after_second, \
618 f"nsIndexIDListScanLimit should still be absent after second restart but found: {scanlimit_after_second}"
619 log.info("Idempotency verified - no issues on second restart")
620
621
622 def test_upgrade_removes_ancestorid_index_config(topology_st):
623 """Check if upgrade function removes ancestorid index config entry
624
625 :id: 3f3d6e9b-75ac-4f0d-b2ce-7204e6eacd0a
626 :setup: Standalone instance
627 :steps:
628 1. Create DS instance
629 2. Stop the server
630 3. Use DSEldif to add an ancestorid index config entry
631 4. Start the server (triggers upgrade)
632 5. Verify ancestorid index config entry is removed
633 :expectedresults:
634 1. Success
635 2. Success
636 3. Success
637 4. Success
638 5. ancestorid index config entry is no longer present
639 """
640 from lib389.dseldif import DSEldif
641
642 standalone = topology_st.standalone
643 ANCESTORID_DN = "cn=ancestorid,cn=index,cn=userroot,cn=ldbm database,cn=plugins,cn=config"
644
645 log.info("Stop the server")
646 standalone.stop()
647
648 log.info("Add ancestorid index config entry using DSEldif")
649 dse_ldif = DSEldif(standalone)
650
651 # Create a fake ancestorid index entry
652 ancestorid_entry = [
653 "dn: {}\n".format(ANCESTORID_DN),
654 "objectClass: top\n",
655 "objectClass: nsIndex\n",
656 "cn: ancestorid\n",
657 "nsSystemIndex: true\n",
658 "nsIndexType: eq\n",
659 "nsMatchingRule: integerOrderingMatch\n",
660 "\n"
661 ]
662 dse_ldif.add_entry(ancestorid_entry)
663
664 # Verify it was added by re-reading dse.ldif
665 dse_ldif2 = DSEldif(standalone)
666 cn_value = dse_ldif2.get(ANCESTORID_DN, "cn")
667 assert cn_value is not None, "Failed to add ancestorid index config entry"
668 log.info(f"Added ancestorid index entry with cn: {cn_value}")
669
670 log.info("Start the server (triggers upgrade)")
671 standalone.start()
672
673 log.info("Verify ancestorid index config entry was removed by upgrade")
674 # Check via LDAP - the upgrade should have removed the entry
675 try:
676 ancestorid_index = Index(standalone, ANCESTORID_DN)
677 # If we can get the entry, it wasn't removed - this is a failure
678 cn_after = ancestorid_index.get_attr_vals_utf8("cn")
679 assert False, f"ancestorid index config entry should have been removed but still exists: {cn_after}"
680 except Exception as e:
681 # Entry should not exist - this is expected
682 log.info(f"ancestorid index config entry correctly removed (got exception: {e})")
683
684 log.info("Upgrade successfully removed ancestorid index config entry")
685
686 # Verify idempotency - restart again and ensure no errors
687 log.info("Restart server again to verify idempotency (no errors on second run)")
688 standalone.restart()
689 # Verify the entry is still absent
690 try:
691 ancestorid_index = Index(standalone, ANCESTORID_DN)
692 cn_after_second = ancestorid_index.get_attr_vals_utf8("cn")
693 assert False, f"ancestorid index config entry should still be absent after second restart but found: {cn_after_second}"
694 except Exception as e:
695 log.info(f"Idempotency verified - ancestorid still absent after second restart (got exception: {e})")
696
697
698 def test_index_check_basic(topology_st):
699 """Check if dsctl index-check works correctly
700
701 :id: 8a4e5c2d-1f3b-4a7c-9e8d-2b6f0c4a5d3e
702 :setup: Standalone instance
703 :steps:
704 1. Create DS instance
705 2. Run dsctl index-check while server is running (should fail)
706 3. Stop the server
707 4. Run dsctl index-check (should pass)
708 5. Start the server
709 :expectedresults:
710 1. Success
711 2. index-check returns False and logs error
712 3. Success
713 4. index-check returns True (no mismatches)
714 5. Success
715 """
716 from lib389.cli_ctl.dbtasks import dbtasks_index_check
717
718 standalone = topology_st.standalone
719
720 log.info("Run index-check while server is running")
721 args = FakeArgs()
722 args.backend = None
723 args.fix = False
724
725 # Server should be running, index-check should fail
726 assert standalone.status()
727 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
728 assert result is False
729 assert topology_st.logcap.contains("index-check requires the instance to be stopped")
730 topology_st.logcap.flush()
731
732 log.info("Stop the server")
733 standalone.stop()
734
735 log.info("Run index-check with server stopped")
736 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
737 assert result is True
738 assert topology_st.logcap.contains("All checks passed")
739 topology_st.logcap.flush()
740
741 log.info("Start the server")
742 standalone.start()
743
744
745 def test_index_check_specific_backend(topology_st):
746 """Check if dsctl index-check works with a specific backend
747
748 :id: 407d8fcc-62e0-43dd-90fa-70e7090a5cfd
749 :setup: Standalone instance
750 :steps:
751 1. Create DS instance
752 2. Stop the server
753 3. Run dsctl index-check with specific backend (userRoot)
754 4. Run dsctl index-check with non-existent backend
755 5. Start the server
756 :expectedresults:
757 1. Success
758 2. Success
759 3. index-check returns True for userRoot
760 4. index-check returns False for non-existent backend
761 5. Success
762 """
763 from lib389.cli_ctl.dbtasks import dbtasks_index_check
764
765 standalone = topology_st.standalone
766
767 log.info("Stop the server")
768 standalone.stop()
769
770 log.info("Run index-check for userRoot backend")
771 args = FakeArgs()
772 args.backend = "userRoot"
773 args.fix = False
774
775 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
776 assert result is True
777 # Check for backend name in any case
778 assert topology_st.logcap.contains("Checking backend:")
779 topology_st.logcap.flush()
780
781 log.info("Run index-check for non-existent backend")
782 args.backend = "nonExistentBackend"
783 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
784 assert result is False
785 assert topology_st.logcap.contains("not found")
786 topology_st.logcap.flush()
787
788 log.info("Start the server")
789 standalone.start()
790
791
792 def test_index_check_mismatch_detection(topology_st):
793 """Check if dsctl index-check detects ordering mismatch
794
795 :id: 50d14520-b0bf-4243-9fe6-b097928d4351
796 :setup: Standalone instance
797 :steps:
798 1. Create DS instance
799 2. Stop the server
800 3. Run dsctl index-check (without --fix)
801 4. Verify output format
802 5. Start the server
803 :expectedresults:
804 1. Success
805 2. Success
806 3. index-check returns True (no mismatch on fresh instance)
807 4. Log contains expected format
808 5. Success
809 """
810 from lib389.cli_ctl.dbtasks import dbtasks_index_check
811
812 standalone = topology_st.standalone
813
814 log.info("Stop the server")
815 standalone.stop()
816
817 log.info("Run index-check to verify detection logic")
818 args = FakeArgs()
819 args.backend = "userRoot"
820 args.fix = False
821
822 # On a fresh instance, there should be no mismatch
823 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
824 # Fresh instance should have matching config and disk ordering
825 assert result is True
826 # Check that the backend was checked (may skip indexes if ordering can't be determined)
827 assert topology_st.logcap.contains("Checking backend:")
828 topology_st.logcap.flush()
829
830 log.info("Start the server")
831 standalone.start()
832
833
834 def test_index_check_with_fix(topology_st):
835 """Check if dsctl index-check --fix triggers reindexing
836
837 :id: 38ae36e4-c861-4771-ae7d-354370376a2f
838 :setup: Standalone instance
839 :steps:
840 1. Create DS instance
841 2. Stop the server
842 3. Run dsctl index-check --fix (should pass since no mismatch)
843 4. Verify output indicates check passed
844 5. Start the server
845 :expectedresults:
846 1. Success
847 2. Success
848 3. index-check returns True
849 4. Log contains "All checks passed"
850 5. Success
851 """
852 from lib389.cli_ctl.dbtasks import dbtasks_index_check
853
854 standalone = topology_st.standalone
855
856 log.info("Stop the server")
857 standalone.stop()
858
859 log.info("Run index-check with --fix option")
860 args = FakeArgs()
861 args.backend = None
862 args.fix = True
863
864 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
865 # On a fresh instance, there should be no mismatch, so no reindexing needed
866 assert result is True
867 assert topology_st.logcap.contains("All checks passed")
868 topology_st.logcap.flush()
869
870 log.info("Start the server")
871 standalone.start()
872
873
874 def test_index_check_fixes_scanlimit(topology_st):
875 """Check if dsctl index-check --fix removes nsIndexIDListScanLimit
876
877 :id: 4a9b2c7d-8e1f-4b3a-9c5d-6e7f8a0b1c2d
878 :setup: Standalone instance
879 :steps:
880 1. Create DS instance
881 2. Stop the server
882 3. Add nsIndexIDListScanLimit to parentid index using DSEldif
883 4. Run dsctl index-check (should detect issue)
884 5. Run dsctl index-check --fix
885 6. Verify nsIndexIDListScanLimit was removed
886 7. Start the server
887 :expectedresults:
888 1. Success
889 2. Success
890 3. Success
891 4. index-check returns False and detects scanlimit
892 5. index-check returns True after fix
893 6. nsIndexIDListScanLimit no longer present
894 7. Success
895 """
896 from lib389.cli_ctl.dbtasks import dbtasks_index_check
897 from lib389.dseldif import DSEldif
898
899 standalone = topology_st.standalone
900
901 log.info("Stop the server")
902 standalone.stop()
903
904 log.info("Add nsIndexIDListScanLimit to parentid index using DSEldif")
905 dse_ldif = DSEldif(standalone)
906 parentid_dn = "cn=parentid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
907 dse_ldif.add(parentid_dn, "nsIndexIDListScanLimit", "4000")
908
909 # Verify it was added
910 scanlimit = dse_ldif.get(parentid_dn, "nsIndexIDListScanLimit", single=True)
911 assert scanlimit == "4000", f"Failed to add nsIndexIDListScanLimit, got: {scanlimit}"
912 log.info("Added nsIndexIDListScanLimit to parentid index")
913
914 log.info("Run index-check without --fix (should detect issue)")
915 args = FakeArgs()
916 args.backend = "userRoot"
917 args.fix = False
918
919 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
920 assert result is False, "index-check should detect scanlimit issue"
921 assert topology_st.logcap.contains("nsIndexIDListScanLimit")
922 topology_st.logcap.flush()
923
924 log.info("Run index-check with --fix")
925 args.fix = True
926 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
927 assert result is True, "index-check --fix should succeed"
928 assert topology_st.logcap.contains("Removed nsIndexIDListScanLimit")
929 topology_st.logcap.flush()
930
931 log.info("Verify nsIndexIDListScanLimit was removed")
932 dse_ldif = DSEldif(standalone) # Reload to get fresh data
933 scanlimit = dse_ldif.get(parentid_dn, "nsIndexIDListScanLimit", single=True)
934 assert scanlimit is None, f"nsIndexIDListScanLimit should be removed, but got: {scanlimit}"
935 log.info("nsIndexIDListScanLimit successfully removed")
936
937 log.info("Start the server")
938 standalone.start()
939
940
941 def test_index_check_fixes_ancestorid_config(topology_st):
942 """Check if dsctl index-check --fix removes ancestorid config entries
943
944 :id: 5b0c3d8e-9f2a-4c4b-0d6e-7f8a9b1c2d3e
945 :setup: Standalone instance
946 :steps:
947 1. Create DS instance
948 2. Stop the server
949 3. Add ancestorid index config entry using DSEldif
950 4. Run dsctl index-check (should detect issue)
951 5. Run dsctl index-check --fix
952 6. Verify ancestorid config entry was removed
953 7. Start the server
954 :expectedresults:
955 1. Success
956 2. Success
957 3. Success
958 4. index-check returns False and detects ancestorid config
959 5. index-check returns True after fix
960 6. ancestorid config entry no longer present
961 7. Success
962 """
963 from lib389.cli_ctl.dbtasks import dbtasks_index_check
964 from lib389.dseldif import DSEldif
965
966 standalone = topology_st.standalone
967
968 log.info("Stop the server")
969 standalone.stop()
970
971 log.info("Add ancestorid index config entry using DSEldif")
972 dse_ldif = DSEldif(standalone)
973 ancestorid_entry = [
974 "dn: cn=ancestorid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config\n",
975 "objectClass: top\n",
976 "objectClass: nsIndex\n",
977 "cn: ancestorid\n",
978 "nsSystemIndex: true\n",
979 "nsIndexType: eq\n",
980 ]
981 dse_ldif.add_entry(ancestorid_entry)
982
983 # Verify it was added
984 ancestorid_dn = "cn=ancestorid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
985 dse_ldif = DSEldif(standalone) # Reload
986 cn_value = dse_ldif.get(ancestorid_dn, "cn", single=True)
987 assert cn_value is not None, "Failed to add ancestorid index config entry"
988 log.info(f"Added ancestorid index entry with cn: {cn_value}")
989
990 log.info("Run index-check without --fix (should detect issue)")
991 args = FakeArgs()
992 args.backend = "userRoot"
993 args.fix = False
994
995 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
996 assert result is False, "index-check should detect ancestorid config issue"
997 assert topology_st.logcap.contains("ancestorid") and topology_st.logcap.contains("config entry exists")
998 topology_st.logcap.flush()
999
1000 log.info("Run index-check with --fix")
1001 args.fix = True
1002 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1003 assert result is True, "index-check --fix should succeed"
1004 assert topology_st.logcap.contains("Removed ancestorid config entry")
1005 topology_st.logcap.flush()
1006
1007 log.info("Verify ancestorid config entry was removed")
1008 dse_ldif = DSEldif(standalone) # Reload to get fresh data
1009 cn_value = dse_ldif.get(ancestorid_dn, "cn", single=True)
1010 assert cn_value is None, f"ancestorid config entry should be removed, but got: {cn_value}"
1011 log.info("ancestorid config entry successfully removed")
1012
1013 log.info("Start the server")
1014 standalone.start()
1015
1016
1017 def test_index_check_fixes_missing_matching_rule(topology_st):
1018 """Check that removing integerOrderingMatch from parentid config is not
1019 flagged as an issue when disk ordering cannot be determined.
1020 Both lexicographic and integer orderings are valid for parentid.
1021
1022 :id: 6c1d4e9f-0a3b-4d5c-1e7f-8a9b0c2d3e4f
1023 :setup: Standalone instance
1024 :steps:
1025 1. Create DS instance
1026 2. Stop the server
1027 3. Remove integerOrderingMatch from parentid index using DSEldif
1028 4. Run dsctl index-check (should NOT detect issue since disk ordering is unknown)
1029 5. Start the server
1030 :expectedresults:
1031 1. Success
1032 2. Success
1033 3. Success
1034 4. index-check returns True (no issues, disk ordering unknown)
1035 5. Success
1036 """
1037 from lib389.cli_ctl.dbtasks import dbtasks_index_check
1038 from lib389.dseldif import DSEldif
1039
1040 standalone = topology_st.standalone
1041
1042 log.info("Stop the server")
1043 standalone.stop()
1044
1045 log.info("Remove integerOrderingMatch from parentid index using DSEldif")
1046 dse_ldif = DSEldif(standalone)
1047 parentid_dn = "cn=parentid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
1048
1049 # Check current matching rules
1050 matching_rules = dse_ldif.get(parentid_dn, "nsMatchingRule")
1051 log.info(f"Current matching rules: {matching_rules}")
1052
1053 # Remove integerOrderingMatch if present
1054 if matching_rules:
1055 for mr in matching_rules:
1056 if "integerorderingmatch" in mr.lower():
1057 dse_ldif.delete(parentid_dn, "nsMatchingRule", mr)
1058 log.info(f"Removed matching rule: {mr}")
1059
1060 # Verify it was removed
1061 dse_ldif = DSEldif(standalone) # Reload
1062 matching_rules = dse_ldif.get(parentid_dn, "nsMatchingRule")
1063 if matching_rules:
1064 for mr in matching_rules:
1065 assert "integerorderingmatch" not in mr.lower(), \
1066 f"integerOrderingMatch should be removed, but found: {mr}"
1067 log.info("integerOrderingMatch removed from parentid index")
1068
1069 log.info("Run index-check (should NOT detect issue - disk ordering unknown)")
1070 args = FakeArgs()
1071 args.backend = "userRoot"
1072 args.fix = False
1073
1074 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1075 assert result is True, \
1076 "index-check should not flag missing integerOrderingMatch when disk ordering is unknown"
1077 assert topology_st.logcap.contains("could not determine disk ordering")
1078 topology_st.logcap.flush()
1079
1080 log.info("Restore integerOrderingMatch and start the server")
1081 dse_ldif = DSEldif(standalone)
1082 dse_ldif.add(parentid_dn, "nsMatchingRule", "integerOrderingMatch")
1083
1084 log.info("Start the server")
1085 standalone.start()
1086
1087
1088 def test_index_check_fixes_default_ancestorid(topology_st):
1089 """Check if dsctl index-check --fix removes ancestorid from default indexes
1090
1091 :id: 7d2e5f0a-1b4c-4e6d-2f8a-9b0c1d3e4f5a
1092 :setup: Standalone instance
1093 :steps:
1094 1. Create DS instance
1095 2. Stop the server
1096 3. Add ancestorid to cn=default indexes using DSEldif
1097 4. Run dsctl index-check (should detect issue)
1098 5. Run dsctl index-check --fix
1099 6. Verify ancestorid was removed from default indexes
1100 7. Start the server
1101 :expectedresults:
1102 1. Success
1103 2. Success
1104 3. Success
1105 4. index-check returns False and detects ancestorid in default indexes
1106 5. index-check returns True after fix
1107 6. ancestorid no longer in default indexes
1108 7. Success
1109 """
1110 from lib389.cli_ctl.dbtasks import dbtasks_index_check
1111 from lib389.dseldif import DSEldif
1112
1113 standalone = topology_st.standalone
1114
1115 log.info("Stop the server")
1116 standalone.stop()
1117
1118 log.info("Add ancestorid to cn=default indexes using DSEldif")
1119 dse_ldif = DSEldif(standalone)
1120 ancestorid_default_entry = [
1121 "dn: cn=ancestorid,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config\n",
1122 "objectClass: top\n",
1123 "objectClass: nsIndex\n",
1124 "cn: ancestorid\n",
1125 "nsSystemIndex: true\n",
1126 "nsIndexType: eq\n",
1127 ]
1128 dse_ldif.add_entry(ancestorid_default_entry)
1129
1130 # Verify it was added
1131 ancestorid_default_dn = "cn=ancestorid,cn=default indexes,cn=config,cn=ldbm database,cn=plugins,cn=config"
1132 dse_ldif = DSEldif(standalone) # Reload
1133 cn_value = dse_ldif.get(ancestorid_default_dn, "cn", single=True)
1134 assert cn_value is not None, "Failed to add ancestorid to default indexes"
1135 log.info(f"Added ancestorid to default indexes with cn: {cn_value}")
1136
1137 log.info("Run index-check without --fix (should detect issue)")
1138 args = FakeArgs()
1139 args.backend = None # Check all backends including default indexes
1140 args.fix = False
1141
1142 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1143 assert result is False, "index-check should detect ancestorid in default indexes"
1144 assert topology_st.logcap.contains("ancestorid found in cn=default indexes")
1145 topology_st.logcap.flush()
1146
1147 log.info("Run index-check with --fix")
1148 args.fix = True
1149 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1150 assert result is True, "index-check --fix should succeed"
1151 assert topology_st.logcap.contains("Removed ancestorid from default indexes")
1152 topology_st.logcap.flush()
1153
1154 log.info("Verify ancestorid was removed from default indexes")
1155 dse_ldif = DSEldif(standalone) # Reload to get fresh data
1156 cn_value = dse_ldif.get(ancestorid_default_dn, "cn", single=True)
1157 assert cn_value is None, f"ancestorid should be removed from default indexes, but got: {cn_value}"
1158 log.info("ancestorid successfully removed from default indexes")
1159
1160 log.info("Start the server")
1161 standalone.start()
1162
1163
1164 def test_index_check_fixes_multiple_issues(topology_st):
1165 """Check if dsctl index-check --fix handles multiple issues at once
1166
1167 :id: 8e3f6a1b-2c5d-4f7e-3a9b-0c1d2e4f5a6b
1168 :setup: Standalone instance
1169 :steps:
1170 1. Create DS instance
1171 2. Stop the server
1172 3. Add multiple issues: scanlimit and ancestorid config
1173 4. Run dsctl index-check (should detect all issues)
1174 5. Run dsctl index-check --fix
1175 6. Verify all issues were fixed
1176 7. Run dsctl index-check again (should pass)
1177 8. Start the server
1178 :expectedresults:
1179 1. Success
1180 2. Success
1181 3. Success
1182 4. index-check returns False and detects all issues
1183 5. index-check returns True after fix
1184 6. All issues resolved
1185 7. index-check returns True (no issues)
1186 8. Success
1187 """
1188 from lib389.cli_ctl.dbtasks import dbtasks_index_check
1189 from lib389.dseldif import DSEldif
1190
1191 standalone = topology_st.standalone
1192
1193 log.info("Stop the server")
1194 standalone.stop()
1195
1196 dse_ldif = DSEldif(standalone)
1197 parentid_dn = "cn=parentid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
1198 ancestorid_dn = "cn=ancestorid,cn=index,cn=userRoot,cn=ldbm database,cn=plugins,cn=config"
1199
1200 log.info("Add issue 1: nsIndexIDListScanLimit to parentid")
1201 dse_ldif.add(parentid_dn, "nsIndexIDListScanLimit", "4000")
1202
1203 log.info("Add issue 2: ancestorid index config entry")
1204 ancestorid_entry = [
1205 f"dn: {ancestorid_dn}\n",
1206 "objectClass: top\n",
1207 "objectClass: nsIndex\n",
1208 "cn: ancestorid\n",
1209 "nsSystemIndex: true\n",
1210 "nsIndexType: eq\n",
1211 ]
1212 dse_ldif.add_entry(ancestorid_entry)
1213
1214 log.info("Run index-check without --fix (should detect all issues)")
1215 args = FakeArgs()
1216 args.backend = "userRoot"
1217 args.fix = False
1218
1219 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1220 assert result is False, "index-check should detect multiple issues"
1221 # Check that multiple issues were detected
1222 assert topology_st.logcap.contains("nsIndexIDListScanLimit")
1223 assert topology_st.logcap.contains("ancestorid")
1224 topology_st.logcap.flush()
1225
1226 log.info("Run index-check with --fix")
1227 args.fix = True
1228 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1229 assert result is True, "index-check --fix should succeed"
1230 assert topology_st.logcap.contains("All issues fixed")
1231 topology_st.logcap.flush()
1232
1233 log.info("Verify all issues were fixed")
1234 dse_ldif = DSEldif(standalone) # Reload
1235
1236 # Check scanlimit removed
1237 scanlimit = dse_ldif.get(parentid_dn, "nsIndexIDListScanLimit", single=True)
1238 assert scanlimit is None, f"nsIndexIDListScanLimit should be removed, got: {scanlimit}"
1239
1240 # Check ancestorid config removed
1241 cn_value = dse_ldif.get(ancestorid_dn, "cn", single=True)
1242 assert cn_value is None, f"ancestorid config should be removed, got: {cn_value}"
1243
1244 log.info("All issues verified as fixed")
1245
1246 log.info("Run index-check again to confirm all clear")
1247 args.fix = False
1248 result = dbtasks_index_check(standalone, topology_st.logcap.log, args)
1249 assert result is True, "index-check should pass after fix"
1250 assert topology_st.logcap.contains("All checks passed")
1251 topology_st.logcap.flush()
1252
1253 log.info("Start the server")
1254 standalone.start()
1255
1256
1257 if __name__ == "__main__":
1258 # Run isolated
1259 # -s for DEBUG mode
1260 CURRENT_FILE = os.path.realpath(__file__)