Fix timing races in replication recovery tests (#1333)
## Summary
The expected CSN list could change while AssertJ was formatting a
transient mismatch in the recovery restart tests. The resulting
`ConcurrentModificationException` ended the test before the changelog
could catch up. [Failing Ubuntu Java 27 job on
master](https://github.com/OpenIdentityPlatform/OpenDJ/actions/runs/45762735252/job/139756560535)
Wait for the publisher to record the third CSN, then compare every read
of the changelog with the same immutable list. All three recovery
failure scenarios keep their exact ordering check and verify that the
next change is published after recovery. This follows the
synchronization used in #1274.
The first PR run passed all 70 `HistoricalCsnOrderingTest` cases on
Ubuntu with Java 27. The same job exposed a timing race in
`MissedUpdateRecoveryTest`. The test can receive the expected CSN before
the writer returns to the in-memory queue. Use the existing
`waitForFollowing(handler)` helper to verify that transition after
checking the delivered CSN and the warning. [Failing PR
job](https://github.com/OpenIdentityPlatform/OpenDJ/actions/runs/45784766650/job/139788644886)
## Validation
- The initial Maven precommit reactor `verify` on macOS with Java 27
passed all 98 tests across `HistoricalCsnOrderingTest`,
`HistoricalTest`, `AssuredReplicationPluginTest`, and
`LDAPReplicationDomainConfigChangeTest`.
- The follow-up Maven precommit reactor `verify` on macOS with Java 27
passed all 78 tests across `HistoricalCsnOrderingTest` and
`MissedUpdateRecoveryTest`, with zero failures, errors, or skips.
- `git diff --check` passed.
| | |
| | | |
| | | // The session started again recovers them, and the first round of its recovery fails, with a |
| | | // change done meanwhile: the recovery keeps it, and the next one publishes it. |
| | | final CountDownLatch changeDone = new CountDownLatch(1); |
| | | rd1.setMissingChangesSearchHook(onTheFirstSearch(search -> |
| | | { |
| | | unchecked(() -> |
| | | { |
| | | replace(dnA, "displayName", "while the failing round searches"); |
| | | done.add(rd1.getLastLocalChange()); |
| | | changeDone.countDown(); |
| | | }).run(); |
| | | failure.accept(search); |
| | | })); |
| | | rd1.disable(); |
| | | rd1.enable(); |
| | | |
| | | assertTrue(changeDone.await(30, SECONDS), "the publisher recorded the third change"); |
| | | final List<CSN> expected = List.copyOf(done); |
| | | new TestTimer.Builder() |
| | | .maxSleep(30, SECONDS) |
| | | .sleepTimes(100, MILLISECONDS) |
| | | .toTimer() |
| | | .repeatUntilSuccess(() -> assertThat(changelogAfter(rs, baseDN, rsMaxCSN)) |
| | | .as("the changes the replication server holds after the ones it had") |
| | | .isEqualTo(done)); |
| | | .isEqualTo(expected)); |
| | | waitUntilTheRecoveryIsOver(rd1); |
| | | replace(dnA, "description", "once the recovery is over"); |
| | | assertInTheChangelog(rs, baseDN, rd1.getLastLocalChange()); |
| | |
| | | .as("the warning names the state of the replica and the state of the domain") |
| | | .contains(ownCSN.toString()) |
| | | .contains(csn.toString()); |
| | | assertThat(handler.isFollowing()) |
| | | .as("the replica is served from the queue again once it has been sent the change") |
| | | .isTrue(); |
| | | // The writer can deliver the change before it returns to the in-memory queue. |
| | | waitForFollowing(handler); |
| | | } |
| | | finally |
| | | { |