mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Valery Kharseko
12 hours ago e0e1e42df98bdb3bff8dfd69daaaa321e7f8efb4
[#1305] Wait for replication generation IDs to converge (#1306)

## Problem

`ReplicationDomainTest.publishAndReceive` checks the replication server
generation IDs 500 ms after resetting the replication log. The reset and
the resulting topology messages are asynchronous, and
`checkGenerationID()` accepts `-1`, so the check can still see `-1` even
though the reset to `2` is in progress.

## Change

Wait up to 30 seconds for both expected replication servers to appear in
the directory server's topology with generation ID `2`, and for both
replication servers to hold `2` themselves. A missing server or a
generation ID that never converges still fails the test.

Fixes #1305

## Validation

- `ReplicationDomainTest`: 40 tests passed on macOS / JDK 21, with no
failures or skips.
- A temporary diagnostic delayed the handling of reset to `2` by 1.5
seconds. The original 500 ms check reproduced the reported failure; the
updated test passed after the reset and topology converged.
- A temporary diagnostic discarded reset to `2`. The updated test failed
after the bounded wait with the generation ID still at `-1`.
- `git diff --check` passed.

The diagnostics demonstrate a sufficient timing mechanism, not the exact
CI interleaving.
1 files modified
17 ■■■■■ changed files
opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java 17 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java
@@ -19,6 +19,7 @@
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static java.util.stream.Collectors.toSet;
import static org.opends.messages.ReplicationMessages.*;
import static org.opends.server.util.CollectionUtils.*;
import static org.testng.Assert.*;
@@ -157,14 +158,24 @@
      domain1.setGenerationID(2);
      domain1.resetReplicationLog();
      Thread.sleep(500);
      for (RSInfo replServerInfo : domain1.getRsInfos())
      // The reset and the resulting topology messages are processed asynchronously.
      final FakeReplicationDomain receivingDomain = domain1;
      final ReplicationServer server1 = replServer1;
      final ReplicationServer server2 = replServer2;
      newTimer().repeatUntilSuccess(() -> {
        List<RSInfo> rsInfos = receivingDomain.getRsInfos();
        assertEquals(rsInfos.size(), 2, "replication servers in DS1 topology: " + rsInfos);
        assertEquals(rsInfos.stream().map(RSInfo::getId).collect(toSet()),
            newHashSet(replServerID1, replServerID2), "replication server IDs in DS1 topology");
        for (RSInfo replServerInfo : rsInfos)
      {
        // The generation Id of the remote should now be 2
        assertEquals(replServerInfo.getGenerationId(), 2,
            "Unexpected value of generationId in RSInfo for RS=" + replServerInfo);
      }
        assertEquals(server1.getGenerationId(testService), 2, "generation ID of RS(" + replServerID1 + ")");
        assertEquals(server2.getGenerationId(testService), 2, "generation ID of RS(" + replServerID2 + ")");
      });
      int sleepTime = 50;
      while (true)