From a33166c79680cdc1154b99df37987140c9bd2e9c Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Mon, 31 May 2010 09:07:29 +0000
Subject: [PATCH] Improve error message when querying the External Changelog with an invalid cookie. Improve unit tests reliabililty  for replication. 

---
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java |    9 +++++----
 opends/src/server/org/opends/server/replication/server/ECLServerHandler.java                       |    4 ++--
 opends/tests/unit-tests-testng/src/server/org/opends/server/replication/GenerationIdTest.java      |    6 +++---
 opends/src/messages/messages/replication.properties                                                |    4 +++-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/opends/src/messages/messages/replication.properties b/opends/src/messages/messages/replication.properties
index a85b57e..439bb79 100644
--- a/opends/src/messages/messages/replication.properties
+++ b/opends/src/messages/messages/replication.properties
@@ -376,7 +376,9 @@
 SEVERE_ERR_REPLICATION_PROTOCOL_MESSAGE_TYPE_157=Replication \
  protocol error. Bad message type. %s received, %s required  
 SEVERE_ERR_RESYNC_REQUIRED_MISSING_DOMAIN_IN_PROVIDED_COOKIE_158=Full resync \
- required. Reason: The provided cookie is missing the replicated domain(s) %s
+ required because the provided cookie is missing the replicated domain(s) %s. \
+ The following cookie value can be used to retrieve the missing changes, \
+ including the COMPLETE record of changes for the missing domain(s) : %s
 SEVERE_ERR_BYTE_COUNT_159=The Server Handler byte count is not correct (Fixed)
 NOTICE_ERR_FRACTIONAL_CONFIG_UNKNOWN_OBJECT_CLASS_160=Wrong fractional \
  replication configuration: could not find object class definition for %s in \
diff --git a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
index 0373d72..e481158 100644
--- a/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
+++ b/opends/src/server/org/opends/server/replication/server/ECLServerHandler.java
@@ -826,8 +826,8 @@
         // the request is rejected and a full resync is required.
         throw new DirectoryException(ResultCode.UNWILLING_TO_PERFORM,
           ERR_RESYNC_REQUIRED_MISSING_DOMAIN_IN_PROVIDED_COOKIE.get(
-              missingDomains +
-              ". Possible cookie: <" + (providedCookie + missingDomains)+ ">"));
+              missingDomains,
+              "<" + (providedCookie + missingDomains)+ ">"));
       }
 
       domainCtxts = tmpSet.toArray(new DomainContext[0]);
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
index ade001b..a4fefed 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/ExternalChangeLogTest.java
@@ -1184,11 +1184,12 @@
       
       waitOpResult(searchOp, ResultCode.UNWILLING_TO_PERFORM);
       assertEquals(searchOp.getSearchEntries().size(), 0);
-      assertTrue(searchOp.getErrorMessage().toString().equalsIgnoreCase(
-          "Full resync required. Reason: The provided cookie is missing the replicated domain(s) o=test:;. Possible cookie: <" 
-          + newCookie + "o=test:;>"), "Server output:" +
+      String expectedError = 
+        "Full resync required because the provided cookie is missing the replicated domain(s) o=test:;. The following cookie value can be used to retrieve the missing changes, including the COMPLETE record of changes for the missing domain(s) : <"
+        + newCookie + "o=test:;>";
+      assertTrue(searchOp.getErrorMessage().toString().equalsIgnoreCase(expectedError),
+          "Expected: " + expectedError + "Server output:" +
           searchOp.getErrorMessage().toString());
-
       s1test.stop();
       s1test2.stop();
       s2test.stop();
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 4dd1246..dbcca20 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
@@ -22,7 +22,7 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2006-2009 Sun Microsystems, Inc.
+ *      Copyright 2006-2010 Sun Microsystems, Inc.
  */
 package org.opends.server.replication;
 
@@ -444,13 +444,13 @@
 
       int waitCo=0;
       LDAPReplicationDomain doToco=null;
-      while(waitCo<30)
+      while(waitCo<50)
       {
         doToco =
           LDAPReplicationDomain.retrievesReplicationDomain(baseDn);
         if ((doToco!=null) && (doToco.isConnected()))
           break;
-        Thread.sleep(200);
+        Thread.sleep(waitCo * 200);
         waitCo++;
       }
       assertTrue(doToco.isConnected(), "not connected after #attempt="+waitCo);

--
Gitblit v1.10.0