From e0e1e42df98bdb3bff8dfd69daaaa321e7f8efb4 Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Wed, 18 Nov 2026 06:42:08 +0000
Subject: [PATCH] [#1305] Wait for replication generation IDs to converge (#1306)

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java |   25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java
index 08b86dc..2aec71f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/service/ReplicationDomainTest.java
+++ b/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 generation Id of the remote should now be 2
-        assertEquals(replServerInfo.getGenerationId(), 2,
-            "Unexpected value of generationId in RSInfo for RS=" + replServerInfo);
-      }
+      // 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)
+        {
+          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)

--
Gitblit v1.10.0