Skip to content

[#116] Deterministic changelog wait in SunDSChangeLogSyncStrategyTests#117

Merged
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:issue-116-deterministic-changelog-wait
Jul 21, 2026
Merged

[#116] Deterministic changelog wait in SunDSChangeLogSyncStrategyTests#117
vharseko merged 2 commits into
OpenIdentityPlatform:masterfrom
vharseko:issue-116-deterministic-changelog-wait

Conversation

@vharseko

Copy link
Copy Markdown
Member

Fixes #116.

Problem

waitForChangeLogToStabilize() treated two equal lastChangeNumber reads 2 s apart as proof the changelog had settled. OpenDJ writes the retro changelog asynchronously, so the heuristic is blind to a record that has not been written yet: on a slow runner (Windows CI) the delete performed by cleanupBaseContext() landed after the "stable" verdict, leaked into the next sync window, and testSimple got two deltas instead of one (expected:<1> but was:<2>). The production sync code is correct — both records genuinely follow the token; the bug is purely in the test's wait.

Fix

Make the wait deterministic — wait for the change number the log is known to owe the caller, instead of betting on timing:

  • SunDSTestBase.cleanupBaseContext() returns the number of entries it deleted.
  • LdapModifyForTests.modify() returns the number of LDIF changes it performed.
  • waitForChangeLogToStabilize() is replaced with waitForChangeLogToReach(conn, expectedChangeNumber): newConnection() waits for the pre-cleanup lastChangeNumber plus the deleted count, and doTest() waits for the sync token plus the LDIF change count. This also closes the mirror-image flake where the test's own change could miss its sync window (expected:<1> but was:<0>).
  • On top of the expected number, the wait still requires two equal consecutive reads as a guard against unaccounted records, and fails with a descriptive AssertionError after 60 s instead of hanging.

The suite also got faster: 100 ms polling replaces the mandatory 2 s sleep per wait.

Testing

mvn -pl OpenICF-ldap-connector -Dtest='SunDSChangeLogSyncStrategyTests,VlvIndexSearchStrategyTests' test — 9/9 pass in ~52 s.

…IdentityPlatform#116)

The stabilization heuristic (two equal lastChangeNumber reads 2s apart)
is blind to changelog records OpenDJ has not written yet, so on slow
runners a cleanup delete could land after the "stable" verdict and leak
into the next test's sync window (expected:<1> but was:<2>).

cleanupBaseContext() and LdapModifyForTests.modify() now report how many
changes they made, and the tests wait until lastChangeNumber reaches the
value read beforehand plus that count (plus two equal consecutive reads
as a guard), with a 60s timeout instead of hanging forever.
@vharseko
vharseko requested a review from maximthomas July 21, 2026 06:26
@vharseko vharseko added bug Something isn't working tests Test additions or fixes connector:ldap LDAP connector labels Jul 21, 2026
@vharseko vharseko changed the title Deterministic changelog wait in SunDSChangeLogSyncStrategyTests (#116) [#116] Deterministic changelog wait in SunDSChangeLogSyncStrategyTests Jul 21, 2026
} finally {
ctx.close();
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} else {
throw new IllegalArgumentException("Unsupported changeType: " + changeType);
}

…tyPlatform#116)

Apply review suggestion: performChange() now throws IllegalArgumentException
for an unsupported changeType instead of silently doing nothing, so a bad
LDIF fails immediately rather than inflating the expected change number and
timing out in waitForChangeLogToReach(). Also pass the missing dn argument
to the "Deleting context" log placeholder.
@vharseko
vharseko merged commit 5b1f0ae into OpenIdentityPlatform:master Jul 21, 2026
14 checks passed
@vharseko
vharseko deleted the issue-116-deterministic-changelog-wait branch July 21, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working connector:ldap LDAP connector tests Test additions or fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky SunDSChangeLogSyncStrategyTests.testSimple: leftover cleanup delete leaks into the sync window

2 participants