From c52a22bad13ca79358d1ca0d9a62d3415363eead Mon Sep 17 00:00:00 2001
From: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Date: Wed, 01 Apr 2026 19:24:10 +0000
Subject: [PATCH] Fix flaky testMultiRS: replace Thread.sleep with deterministic domain-ready wait

---
 opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
index b452ce0..771c18e 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/GenerationIdTest.java
@@ -921,7 +921,7 @@
       replServer3 = createReplicationServer(replServerId3, true, testCase);
 
       connectServer1ToReplServer(replServer1);
-      Thread.sleep(2000); //wait for all RS handshakes to complete
+      waitForDomainsOnAllReplicationServers();
 
       debugInfo("Expect genId are set in all replServers.");
       waitForStableGenerationId(EMPTY_DN_GENID);
@@ -990,6 +990,24 @@
     }
   }
 
+  private void waitForDomainsOnAllReplicationServers() throws Exception
+  {
+    TestTimer timer = new TestTimer.Builder()
+      .maxSleep(30, SECONDS)
+      .sleepTimes(100, MILLISECONDS)
+      .toTimer();
+    timer.repeatUntilSuccess(new CallableVoid()
+    {
+      @Override
+      public void call() throws Exception
+      {
+        assertNotNull(replServer1.getReplicationServerDomain(baseDN), "domain missing on replServer1");
+        assertNotNull(replServer2.getReplicationServerDomain(baseDN), "domain missing on replServer2");
+        assertNotNull(replServer3.getReplicationServerDomain(baseDN), "domain missing on replServer3");
+      }
+    });
+  }
+
   private void waitForStableGenerationId(final long expectedGenId) throws Exception
   {
     TestTimer timer = new TestTimer.Builder()

--
Gitblit v1.10.0