new ReplServerFakeConfiguration(replServerPort, "dependencyTestAddDelAddDependencyTestDb", 0,
replServerId,
0, 5*AddSequenceLength+100, null);
replServer = new ReplicationServer(conf);
ReplicationBroker broker =
openReplicationSession(baseDn, brokerId, 100, replServerPort, 1000,
false, CLEAN_DB_GENERATION_ID);
// send a sequence of add/del/add operations
ChangeNumberGenerator gen = new ChangeNumberGenerator(brokerId, 0L);
int sequence;
for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
{
// add the entry a first time
entry.removeAttribute(uidType);
entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1)),
new LinkedList<AttributeValue>());
String addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
AddMsg addMsg =
new AddMsg(gen.newChangeNumber(), addDn, stringUID(sequence+1),
stringUID(1),
entry.getObjectClassAttribute(),
entry.getAttributes(), null );
broker.publish(addMsg);
// delete the entry
DeleteMsg delMsg = new DeleteMsg(addDn, gen.newChangeNumber(),
stringUID(sequence+1));
broker.publish(delMsg);
// add again the entry with a new entryuuid.
entry.removeAttribute(uidType);
entry.addAttribute(Attributes.create("entryuuid", stringUID(sequence+1025)),
new LinkedList<AttributeValue>());
addMsg =
new AddMsg(gen.newChangeNumber(), addDn, stringUID(sequence+1025),
stringUID(1),
entry.getObjectClassAttribute(),
entry.getAttributes(), null );
broker.publish(addMsg);
}
// configure and start replication of TEST_ROOT_DN_STRING on the server
SortedSet<String> replServers = new TreeSet<String>();
replServers.add("localhost:"+replServerPort);
DomainFakeCfg domainConf =
new DomainFakeCfg(baseDn, serverId, replServers);
domain = MultimasterReplication.createNewDomain(domainConf);
domain.start();
// check that all entries have been deleted and added
// again by checking that they do have the correct entryuuid
for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
{
String addDn = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
boolean found =
checkEntryHasAttribute(DN.decode(addDn), "entryuuid",
stringUID(sequence+1025),
30000, true);
if (!found)
{
fail("The second add was not replayed on entry " + addDn);
}
}
for (sequence = 1; sequence<=AddSequenceLength; sequence ++)
{
String deleteDN = "dc=dependency" + sequence + "," + TEST_ROOT_DN_STRING;
DeleteMsg delMsg = new DeleteMsg(deleteDN,
gen.newChangeNumber(),
stringUID(sequence + 1025));
broker.publish(delMsg);
}
// check that the database was cleaned successfully
DN node1 = DN.decode("dc=dependency1," + TEST_ROOT_DN_STRING);
Entry baseEntry = getEntry(node1, 30000, false);