ReplicationDomainTest.java revision 6c5c0af35aabc59a56c71e9c9296a7398a3e9176
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at legal-notices/CDDLv1_0.txt.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2010 Sun Microsystems, Inc.
* Portions Copyright 2011-2015 ForgeRock AS
*/
/**
* Test the Generic Replication Service.
*/
@SuppressWarnings("javadoc")
public class ReplicationDomainTest extends ReplicationTestCase
{
public Object[][] createpublishAndReceiveData()
{
return new Object[][] {
{1, 2, 3, 4},
{1, 2, 1, 2},
{1, 2, 45891, 45672},
{45610, 45720, 1, 2},
{45610, 45720, 45891, 45672}
};
}
/**
* Test that a ReplicationDomain is able to publish and receive UpdateMsg.
* Also test the ReplicationDomain.resetReplicationLog() method.
*/
public void publishAndReceive(
int replServerID1, int replServerID2,
int domain1ServerId, int domain2ServerId)
throws Exception
{
try
{
domain1 = new FakeReplicationDomain(
domain2 = new FakeReplicationDomain(
/*
* Publish a message from domain1,
* Check that domain2 receives it shortly after.
*/
{
// The generation Id of the remote should be 1
"Unexpected value of generationId in RSInfo for RS=" + replServerInfo);
}
{
}
{
// The generation Id of the remote should now be 2
"Unexpected value of generationId in RSInfo for RS=" + replServerInfo);
}
int sleepTime = 50;
while (true)
{
try
{
// if we reach this point all tests are OK
break;
}
catch (AssertionError e)
{
if (sleepTime >= 30000)
{
throw e;
}
sleepTime *= 2;
}
}
}
finally
{
}
}
/**
* Publish information to the Replication Service (not assured mode).
*
* @param msg The byte array containing the information that should
* be sent to the remote entities.
*/
{
synchronized (this)
{
// If assured replication is configured,
// this will prepare blocking mechanism.
// If assured replication is disabled, this returns immediately
}
try
{
// If assured replication is enabled,
// this will wait for the matching ack or time out.
// If assured replication is disabled, this returns immediately
}
catch (TimeoutException ex)
{
// This exception may only be raised if assured replication is enabled
}
}
int domain1ServerId, int domain2ServerId)
{
{
{
}
else
{
}
}
}
/**
* Publish performance test.
* The test loops calling the publish methods of the ReplicationDomain.
* It should not be enabled by default as it will use a lot of time.
* Its call is only to investigate performance issues with the replication.
*/
public void publishPerf() throws Exception
{
int replServerID1 = 10;
int domain1ServerId = 1;
try
{
domain1 = new FakeReplicationDomain(
/*
* Publish a message from domain1,
* Check that domain2 receives it shortly after.
*/
}
finally
{
}
}
{
for (int i = 0; i < 100000; i++)
{
}
return timeNow;
}
{
return createReplicationServer(serverId, replicationPort, dirName, windowSize, newTreeSet(replServers));
}
{
return new ReplicationServer(
new ReplServerFakeConfiguration(replicationPort, dirName, 0, serverId, 0, windowSize, replServers));
}
{
{
{
}
}
}
public Object[][] createExportAndimportData()
{
return new Object[][] {
{1, 2},
{45610, 45720}
};
}
/**
* Test that a ReplicationDomain is able to export and import its database
* When there is only one replication server.
*/
{
final int ENTRYCOUNT=5000;
int replServerID = 11;
try
{
"exportAndImportData", 100);
domain1 = new FakeReplicationDomain(
domain2 = new FakeReplicationDomain(
/*
* Trigger a total update from domain1 to domain2.
* Check that the exported data is correctly received on domain2.
*/
}
finally
{
}
}
{
{
{
return true;
}
}
return false;
}
/**
* Test that a ReplicationDomain is able to export and import its database
* across 2 replication servers.
*/
public void exportAndImportAcross2ReplServers() throws Exception
{
final int ENTRYCOUNT=5000;
int replServerID = 11;
int replServerID2 = 12;
try
{
"exportAndImportservice1", 100);
domain1 = new FakeReplicationDomain(
domain2 = new FakeReplicationDomain(
}
finally
{
}
}
{
for (int i = 0; i < ENTRYCOUNT; i++)
{
}
}
{
int count = 0;
{
count ++;
}
}
{
}
{
{
return ieContext.getLeftEntryCount();
}
}
/**
* Sender side of the Total Update Perf test.
* The goal of this test is to measure the performance
* of the total update code.
* It is not intended to be run as part of the daily unit test but
* should only be used manually by developer in need of testing the
* performance improvement or non-regression of the total update code.
* Use this test in combination with the receiverInitialize() :
* - enable the test
* - start the senderInitialize first using
* ./build.sh \
* -Dorg.opends.test.suppressOutput=false \
* -Dtest.methods=org.opends.server.replication.service.ReplicationDomainTest.senderInitialize test
* - start the receiverInitialize second.
* - you may want to change HOST1 and HOST2 to use 2 different hosts
* if you don't want to do a loopback test.
* - don't forget to disable again the tests after running them
*/
final int SENDERPORT = 10102;
final int RECEIVERPORT = 10101;
public void senderInitialize() throws Exception
{
int replServerID = 12;
try
{
}
finally
{
}
}
/**
* See comments in senderInitialize() above.
*/
public void receiverInitialize() throws Exception
{
int replServerID = 11;
try
{
/*
* Trigger a total update from domain1 to domain2.
* Check that the exported data is correctly received on domain2.
*/
while (!initializeFromRemote(domain1))
{
}
}
finally
{
}
}
}