DependencyTest.java revision 0d397efc4b781ef5b60108708fa1131467d2c3c8
/*
* 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
* 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
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. 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 2007-2009 Sun Microsystems, Inc.
*/
/**
* Test that the dependencies are computed correctly when replaying
* sequences of operations that requires to follow a given order
* such as : ADD an entry, ADD a children entry.
*/
public class DependencyTest extends ReplicationTestCase
{
/**
* Check that a sequence of dependents adds and mods is correctly ordered:
* Using a deep dit :
* TEST_ROOT_DN_STRING
* |
* dc=dependency1
* |
* dc=dependency2
* |
* dc=dependency3
* |
*
* |
* dc=dependencyN
* This test sends a sequence of interleaved ADD operations and MODIFY
* operations to build such a dit.
*
* Then test that the sequence of Delete necessary to remove
* all those entries is also correctly ordered.
*/
@SuppressWarnings("unchecked")
public void addModDelDependencyTest() throws Exception
{
int brokerId = 2;
int serverId = 1;
int replServerId = 81;
int AddSequenceLength = 30;
cleanDB();
try
{
/*
* FIRST PART :
* Check that a sequence of dependent ADD is correctly ordered.
*
* - Create replication server
* - Send sequence of ADD messages to the replication server
* - Configure replication server
* - check that the last entry has been correctly added
*/
+ "objectClass: top\n"
+ "objectClass: organization\n"
// find a free port for the replicationServer
replicationPlugin = new MultimasterReplication();
false, CLEAN_DB_GENERATION_ID);
// send a sequence of add operation
int sequence;
{
new LinkedList<AttributeValue>());
}
// configure and start replication of TEST_ROOT_DN_STRING on the server
// check that last entry in sequence got added.
"The last entry of the ADD sequence was not added.");
// Check that all the modify have been replayed
// (all the entries should have a description).
{
boolean found =
10000, true);
if (!found)
{
}
}
/*
* SECOND PART
*
* Now check that the dependencies between delete are correctly
* managed.
*
* disable the domain while we publish the delete message to
* to replication server so that when we enable it it receives the
* delete operation in bulk.
*/
// for full termination of all threads. (issue 1571)
while (sequence-->1)
{
}
// check that entry just below the base entry was deleted.
// (we can't delete the base entry because some other tests might
// have added other children)
"The last entry of the DEL sequence was not deleted.");
}
finally
{
if (replServer != null)
replServer.remove();
if (replicationPlugin != null)
}
}
/**
* Check the dependency between moddn and delete operation
* when an entry is renamed to a new dn and then deleted.
* Disabled: need investigations to fix random failures
*/
@SuppressWarnings("unchecked")
public void moddnDelDependencyTest() throws Exception
{
int brokerId = 2;
int serverId = 1;
int replServerId = 82;
cleanDB();
try
{
//
// Create replication server, replication domain and broker.
//
+ "objectClass: top\n"
+ "objectClass: organization\n";
int renamedEntryUuid = 100;
// find a free port for the replicationServer
replicationPlugin = new MultimasterReplication();
200, null);
// configure and start replication of TEST_ROOT_DN_STRING on the server
false, CLEAN_DB_GENERATION_ID);
// add an entry to play with.
new LinkedList<AttributeValue>());
stringUID(1),
// check that the entry was correctly added
boolean found =
30000, true);
// disable the domain to make sure that the messages are
// all sent in a row.
// rename and delete the entry.
// enable back the domain to trigger message replay.
// check that entry does not exist anymore.
"entryuuid",
30000, false);
}
finally
{
if (replServer != null)
replServer.remove();
if (replicationPlugin != null)
}
}
private final long CLEAN_DB_GENERATION_ID = 7933L;
/**
* Clean the database and replace with a single entry.
*
* @throws FileNotFoundException
* @throws IOException
* @throws Exception
*/
{
// Clear backend
TestCaseUtils.initializeTestBackend(false);
// Create top entry with uuid
+ "objectClass: top\n"
+ "objectClass: organization\n"
+ "o: test\n"
}
/**
* the second entry is in the database.
* The unique id of the entry is used to check that the correct entry
* has been added.
*/
@SuppressWarnings("unchecked")
public void addDelAddDependencyTest() throws Exception
{
int brokerId = 2;
int serverId = 1;
int replServerId = 83;
int AddSequenceLength = 30;
cleanDB();
try
{
+ "objectClass: top\n"
+ "objectClass: organization\n";
// find a free port for the replicationServer
replicationPlugin = new MultimasterReplication();
false, CLEAN_DB_GENERATION_ID);
int sequence;
{
// add the entry a first time
new LinkedList<AttributeValue>());
stringUID(1),
// delete the entry
// add again the entry with a new entryuuid.
new LinkedList<AttributeValue>());
addMsg =
stringUID(1),
}
// configure and start replication of TEST_ROOT_DN_STRING on the server
// check that all entries have been deleted and added
// again by checking that they do have the correct entryuuid
{
boolean found =
30000, true);
if (!found)
{
}
}
{
}
// check that the database was cleaned successfully
"The entry were not removed succesfully after test completion.");
}
finally
{
if (replServer != null)
replServer.remove();
if (replicationPlugin != null)
}
}
/**
* Check that the dependency of moddn operation are working by
* issuing a set of Add operation followed by a modrdn of the added entry.
*/
@SuppressWarnings("unchecked")
public void addModdnDependencyTest() throws Exception
{
int brokerId = 2;
int serverId = 1;
int replServerId = 84;
int AddSequenceLength = 30;
cleanDB();
try
{
+ "objectClass: top\n"
+ "objectClass: organization\n";
// find a free port for the replicationServer
replicationPlugin = new MultimasterReplication();
false, CLEAN_DB_GENERATION_ID);
int sequence;
{
// add the entry
new LinkedList<AttributeValue>());
stringUID(1),
// rename the entry
}
// configure and start replication of TEST_ROOT_DN_STRING on the server
// check that all entries have been renamed
{
"The rename was not applied correctly on :" + addDn);
}
// delete the entries to clean the database.
{
}
}
finally
{
if (replServer != null)
replServer.remove();
if (replicationPlugin != null)
}
}
/**
* Builds and return a uuid from an integer.
* This methods assume that unique integers are used and does not make any
* unicity checks. It is only responsible for generating a uid with a
* correct syntax.
*/
{
}
}