Thread.sleep(1000);
// ---
// 2. Now set up a very short purge delay on the replication changelogs
// so that this test can play with a trimmed changelog.
ReplicationServerDomain d1 = replicationServer.getReplicationServerDomain("o=test", false);
ReplicationServerDomain d2 = replicationServer.getReplicationServerDomain("o=test2", false);
d1.setPurgeDelay(1);
d2.setPurgeDelay(1);
// Sleep longer than this delay - so that the changelog is trimmed
Thread.sleep(1000);
//
LDIFWriter ldifWriter = getLDIFWriter();
// ---
// 3. Assert that a request with an empty cookie returns nothing
String cookie= "";
// search on 'cn=changelog'
LinkedHashSet<String> attributes = new LinkedHashSet<String>();
attributes.add("+");
attributes.add("*");
debugInfo(tn, "1. Search with cookie=" + cookie + "\"");
InternalSearchOperation searchOp =
connection.processSearch(
ByteString.valueOf("cn=changelog"),
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
LDAPFilter.decode("(targetDN=*)"),
attributes,
createControls(cookie),
null);
waitOpResult(searchOp, ResultCode.SUCCESS);
cookie="";
LinkedList<SearchResultEntry> entries = searchOp.getSearchEntries();
if (entries != null)
{
for (SearchResultEntry entry : entries)
{
debugInfo(tn, " RESULT entry returned:" + entry.toSingleLineString());
ldifWriter.writeEntry(entry);
}
}
// Assert ECL is empty since replication changelog has been trimmed
assertEquals(searchOp.getSearchEntries().size(), 0);
// 4. Assert that a request with the current last cookie returns nothing
cookie = readLastCookie(tn);
debugInfo(tn, "2. Search with last cookie=" + cookie + "\"");
searchOp =
connection.processSearch(
ByteString.valueOf("cn=changelog"),
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
LDAPFilter.decode("(targetDN=*)"),
attributes,
createControls(cookie),
null);
waitOpResult(searchOp, ResultCode.SUCCESS);
entries = searchOp.getSearchEntries();
if (entries != null)
{
for (SearchResultEntry entry : entries)
{
debugInfo(tn, " RESULT entry returned:" + entry.toSingleLineString());
ldifWriter.writeEntry(entry);
}
}
// Assert ECL is empty since replication changelog has been trimmed
assertEquals(searchOp.getSearchEntries().size(), 0);
// ---
// 5. Assert that a request with an "old" cookie - one that refers to
// changes that have been removed by the replication changelog trimming
// returns the appropriate error.
cn1 = new ChangeNumber(TimeThread.getTime(), ts++, 1201);
delMsg =
new DeleteMsg("uid="+tn+"1," + TEST_ROOT_DN_STRING, cn1, tn+"uuid1");
server01.publish(delMsg);
debugInfo(tn, " publishes " + delMsg.getChangeNumber());
attributes = new LinkedHashSet<String>();
attributes.add("+");
attributes.add("*");
debugInfo(tn, "3. Search with cookie=\"" + cookieNotEmpty + "\"");
debugInfo(tn, "d1 trimdate" + d1.getStartState());
debugInfo(tn, "d2 trimdate" + d2.getStartState());
searchOp =
connection.processSearch(
ByteString.valueOf("cn=changelog"),
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES,
0, // Size limit
0, // Time limit
false, // Types only
LDAPFilter.decode("(targetDN=*)"),
attributes,
createControls(cookieNotEmpty),
null);
waitOpResult(searchOp, ResultCode.UNWILLING_TO_PERFORM);
assertEquals(searchOp.getSearchEntries().size(), 0);
assertTrue(searchOp.getErrorMessage().toString().startsWith(
ERR_RESYNC_REQUIRED_TOO_OLD_DOMAIN_IN_PROVIDED_COOKIE.get("o=test")
.toString()),
searchOp.getErrorMessage().toString());
// Clean
server01.stop();
// And reset changelog purge delay for the other tests.
d1.setPurgeDelay(15 * 1000);
d2.setPurgeDelay(15 * 1000);
}
catch(Exception e)
{
fail("Ending test " + tn + "with exception:\n"