From 74313fb840dff7a76d49f00930ddcfef6b412393 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Mon, 06 Jul 2015 14:32:26 +0000
Subject: [PATCH] Fix ChangelogBackendTestCase randomness. Should be the last one!!
---
opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java | 36 ++++++++++++++++++++++++++----------
1 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
index 4357956..d910708 100644
--- a/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
+++ b/opendj-sdk/opendj-server-legacy/src/test/java/org/opends/server/backends/ChangelogBackendTestCase.java
@@ -446,9 +446,8 @@
isOldestCSNForReplica(DN_OTEST2, csn6);
// test last cookie on root DSE
- MultiDomainServerState expectedLastCookie =
- new MultiDomainServerState("o=test:" + csn5 + " " + csn9 + ";o=test2:" + csn3 + " " + csn8 + ";");
- final String lastCookie = assertLastCookieIsEqualTo(expectedLastCookie.toString());
+ String expectedLastCookie = "o=test:" + csn5 + " " + csn9 + ";o=test2:" + csn3 + " " + csn8 + ";";
+ final String lastCookie = assertLastCookieIsEqualTo(expectedLastCookie);
// test unknown domain in provided cookie
// This case seems to be very hard to obtain in the real life
@@ -476,13 +475,28 @@
private void isOldestCSNForReplica(DN baseDN, CSN csn) throws Exception
{
- final ReplicationDomainDB domainDB = replicationServer.getChangelogDB().getReplicationDomainDB();
- CursorOptions options = new CursorOptions(GREATER_THAN_OR_EQUAL_TO_KEY, ON_MATCHING_KEY);
- try (DBCursor<UpdateMsg> cursor = domainDB.getCursorFrom(baseDN, csn.getServerId(), csn, options))
+ AssertionError ex = null;
+ int cnt = 0;
+ while (cnt < 30)
{
- assertTrue(cursor.next(),
- "Expected to find at least one change in replicaDB(" + baseDN + " " + csn.getServerId() + ")");
- assertEquals(cursor.getRecord().getCSN(), csn);
+ cnt++;
+ final ReplicationDomainDB domainDB = replicationServer.getChangelogDB().getReplicationDomainDB();
+ CursorOptions options = new CursorOptions(GREATER_THAN_OR_EQUAL_TO_KEY, ON_MATCHING_KEY);
+ try (DBCursor<UpdateMsg> cursor = domainDB.getCursorFrom(baseDN, csn.getServerId(), csn, options))
+ {
+ assertTrue(cursor.next(),
+ "Expected to find at least one change in replicaDB(" + baseDN + " " + csn.getServerId() + ")");
+ assertEquals(cursor.getRecord().getCSN(), csn);
+ return;
+ }
+ catch (AssertionError e)
+ {
+ ex = e;
+ }
+ }
+ if (ex != null)
+ {
+ throw ex;
}
}
@@ -1009,7 +1023,9 @@
{
if (msg instanceof UpdateMsg)
{
- debugInfo(testName, " publishes " + ((UpdateMsg) msg).getCSN());
+ final UpdateMsg updateMsg = (UpdateMsg) msg;
+ assertThat(updateMsg.getCSN().getServerId()).isEqualTo(serverId);
+ debugInfo(testName, " publishes " + updateMsg.getCSN());
}
broker.publish(msg);
--
Gitblit v1.10.0