From 3be885b70108e0efd3cd8508c1a0b6169a8003cd Mon Sep 17 00:00:00 2001
From: Valery Kharseko <vharseko@3a-systems.ru>
Date: Mon, 30 Nov 2026 06:33:08 +0000
Subject: [PATCH] Wait for replication monitor counters in ProtocolWindowTest (#1348)
---
opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java | 47 +++++++++++++++++++++++++++++------------------
1 files changed, 29 insertions(+), 18 deletions(-)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
index eab1333..09af219 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/ProtocolWindowTest.java
@@ -17,12 +17,14 @@
*/
package org.opends.server.replication;
+import static java.util.concurrent.TimeUnit.*;
import static org.forgerock.opendj.ldap.SearchScope.*;
import static org.opends.server.TestCaseUtils.*;
import static org.opends.server.protocols.internal.Requests.*;
import static org.testng.Assert.*;
import java.net.SocketTimeoutException;
+import java.util.Arrays;
import java.util.List;
import java.util.NoSuchElementException;
@@ -47,6 +49,8 @@
import org.opends.server.types.Modification;
import org.opends.server.types.Operation;
import org.opends.server.types.OperationType;
+import org.opends.server.types.SearchResultEntry;
+import org.opends.server.util.TestTimer;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -61,6 +65,7 @@
private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass();
+ private static final int BROKER_SERVER_ID = 12;
private static final int WINDOW_SIZE = 10;
private static final int REPLICATION_QUEUE_SIZE = 100;
@@ -110,7 +115,7 @@
"Unable to add the synchronized server");
configEntriesToCleanup.add(repDomainEntry.getName());
- ReplicationBroker broker = openReplicationSession(baseDN, 12,
+ ReplicationBroker broker = openReplicationSession(baseDN, BROKER_SERVER_ID,
WINDOW_SIZE, replServerPort, 1000);
try {
@@ -148,11 +153,7 @@
int count = WINDOW_SIZE * 2 + REPLICATION_QUEUE_SIZE;
processModify(count);
- // let some time to the message to reach the replicationServer client
- Thread.sleep(2000);
-
- // check that the replicationServer only sent WINDOW_SIZE messages
- searchUpdateSent();
+ waitForSaturatedWindow();
int rcvCount=0;
try
@@ -217,19 +218,29 @@
return searchNbMonitorEntries("(max-rcv-window=" + windowSize + ")");
}
- /**
- * Search that the replicationServer has stopped sending changes after
- * having reach the limit of the window size.
- * And that the number of waiting changes is accurate.
- * Do this by checking the monitoring information.
- */
- private void searchUpdateSent() throws Exception
+ /** Waits for the broker's monitor entry to report a full window and the remaining changes. */
+ private void waitForSaturatedWindow() throws Exception
{
- assertEquals(searchNbMonitorEntries("(sent-updates=" + WINDOW_SIZE + ")"), 1);
-
- final int nb = searchNbMonitorEntries(
- "(missing-changes=" + (REPLICATION_QUEUE_SIZE + WINDOW_SIZE) + ")");
- assertEquals(nb, 1);
+ String monitorFilter = "(&(cn=Connected directory server*)(server-id=" + BROKER_SERVER_ID
+ + ")(domain-name=" + baseDN + "))";
+ // The monitor publisher refreshes missing-changes in the background.
+ TestTimer timer = new TestTimer.Builder()
+ .maxSleep(30, SECONDS)
+ .sleepTimes(200, MILLISECONDS)
+ .toTimer();
+ timer.repeatUntilSuccess(() ->
+ {
+ InternalSearchOperation op = connection.processSearch(
+ newSearchRequest("cn=replication,cn=monitor", WHOLE_SUBTREE, monitorFilter));
+ assertEquals(op.getResultCode(), ResultCode.SUCCESS);
+ assertEquals(op.getEntriesSent(), 1, "Monitor entry for replication broker " + BROKER_SERVER_ID);
+ SearchResultEntry entry = op.getSearchEntries().getFirst();
+ Long sentUpdates = entry.parseAttribute("sent-updates").asLong();
+ Long missingChanges = entry.parseAttribute("missing-changes").asLong();
+ Assertions.assertThat(Arrays.asList(sentUpdates, missingChanges))
+ .as("sent-updates and missing-changes for replication broker %s", BROKER_SERVER_ID)
+ .containsExactly((long) WINDOW_SIZE, (long) REPLICATION_QUEUE_SIZE + WINDOW_SIZE);
+ });
}
/**
--
Gitblit v1.10.0