Skip to content

Commit

Permalink
Issue 6258 - Mitigate race condition in paged_results_test.py (#6433)
Browse files Browse the repository at this point in the history
The regression test dirsrvtests/tests/suites/paged_results/paged_results_test.py::test_multi_suffix_search has a race condition causing it to fail due to multiple queries potentially writing their logs out of chronological order.

This failure is mitigated by sorting the retrieved access_log_lines by their "op" value. This ensures the log lines are in chronological order, as expected by the assertions at the end of test_multi_suffix_search().

Helps fix: #6258

Reviewed by: @droideck , @progier389 (Thanks!)

Co-authored-by: Anuar Beisembayev <[email protected]>
  • Loading branch information
mmatsuya and abeisemb authored Feb 5, 2025
1 parent 6e52b8e commit 41cd44a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dirsrvtests/tests/suites/paged_results/paged_results_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# --- END COPYRIGHT BLOCK ---
#
import socket
import re
from random import sample, randrange

import pytest
Expand Down Expand Up @@ -1126,6 +1127,8 @@ def test_multi_suffix_search(topology_st, create_user, new_suffixes):
topology_st.standalone.restart(timeout=10)

access_log_lines = topology_st.standalone.ds_access_log.match('.*pr_cookie=.*')
# Sort access_log_lines by op number to mitigate race condition effects.
access_log_lines.sort(key=lambda x: int(re.search(r"op=(\d+) RESULT", x).group(1)))
pr_cookie_list = ([line.rsplit('=', 1)[-1] for line in access_log_lines])
pr_cookie_list = [int(pr_cookie) for pr_cookie in pr_cookie_list]
log.info('Assert that last pr_cookie == -1 and others pr_cookie == 0')
Expand Down

0 comments on commit 41cd44a

Please sign in to comment.