From ab7ae2fd06d636915199bf9ca5804f2a0a41fa66 Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 17 Oct 2013 13:50:45 +0000
Subject: [PATCH] Fixed GenerationIdTest.generationIdTest(): test was failing precisely because the directory server's broker was not connected to a replication domain, hence it was impossible to add the changes to the changelogDB and then find them when querying the changelogDB.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
index f5ccd53..43a04de 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java
@@ -660,7 +660,7 @@
debugInfo(testCase + " ** TEST ** The part of the topology with the right gen ID should work well");
// Now create a change that must be replicated
- assertConnectedToReplicationDomain();
+ waitConnectionToReplicationDomain(baseDN, 1000);
addTestEntriesToDB(createEntry(UUID.randomUUID()));
// Verify that RS1 does contain the change related to this ADD.
@@ -766,7 +766,7 @@
"Expecting that DS3 with old gen ID is in bad gen id from RS1");
debugInfo("Add entries to DS1, update should not be sent to DS2 and DS3 that are in bad gen id");
- assertConnectedToReplicationDomain();
+ waitConnectionToReplicationDomain(baseDN, 1000);
addTestEntriesToDB(createEntry(UUID.randomUUID()));
debugInfo("RS1 must have stored that update.");
@@ -861,11 +861,25 @@
}
}
- private void assertConnectedToReplicationDomain()
+ /**
+ * Waits for the connection from server1 to the replication domain to
+ * establish itself up automagically.
+ */
+ private void waitConnectionToReplicationDomain(DN baseDN, int timeout)
{
+ long start = System.currentTimeMillis();
+ while (System.currentTimeMillis() - start <= timeout)
+ {
+ LDAPReplicationDomain domain = MultimasterReplication.findDomain(baseDN, null);
+ if (domain != null && domain.isConnected())
+ {
+ break;
+ }
+ }
assertTrue(MultimasterReplication.findDomain(baseDN, null).isConnected(),
- "The server should be connected to replication domain" + baseDN
- + " at this point");
+ "After waiting " + (System.currentTimeMillis() - start)
+ + " ms, server should have been connected to replication domain "
+ + baseDN);
}
private Entry createSetGenerationIdTask(Long genId, String additionalAttribute) throws Exception
@@ -1065,7 +1079,7 @@
assertEquals(readGenIdFromSuffixRootEntry(), -1,
"genId attribute should not be retrievable since there are NO entry in the backend");
- assertConnectedToReplicationDomain();
+ waitConnectionToReplicationDomain(baseDN, 1000);
addTestEntriesToDB(updatedEntries);
assertEquals(readGenIdFromSuffixRootEntry(), EMPTY_DN_GENID,
"genId attribute should be retrievable since there IS one entry in the backend");
--
Gitblit v1.10.0