opends/tests/unit-tests-testng/src/server/org/opends/server/replication/common/ServerStateTest.java
@@ -30,17 +30,9 @@ import java.util.Set; import org.opends.server.TestCaseUtils; import org.opends.server.core.AddOperationBasis; import org.opends.server.core.DirectoryServer; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.replication.ReplicationTestCase; import org.opends.server.replication.common.ChangeNumber; import org.opends.server.replication.common.ServerState; import org.opends.server.replication.plugin.LDAPReplicationDomain; import org.opends.server.types.DN; import org.opends.server.types.Entry; import org.opends.server.types.ResultCode; import org.opends.server.util.TimeThread; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; @@ -136,85 +128,4 @@ } /** * Ensures that the Directory Server is able to * translate a ruv entry to a sever state. * * @throws Exception If an unexpected problem occurs. */ @Test(enabled = false) public void translateRuvEntryTest() throws Exception { Entry synchroServerEntry = null; String RuvString = "dn: nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff, o=test\n" +"objectClass: top\n" +"objectClass: extensibleobject\n" +"objectClass: ldapSubEntry\n" +"o: test\n" +"nsds50ruv: {replicageneration} 49098853000000010000\n" +"nsds50ruv: {replica 3 ldap://kawax:3389} 491d517b000000030000 " +"491d564a000000030000\n" +"nsds50ruv: {replica 1 ldap://kawax:1389} 490989e8000000010000 " +"490989e8000000010000\n" +"ds6ruv: {PRIO 3 ldap://kawax:3389}\n" +"ds6ruv: {PRIO 1 ldap://kawax:1389}\n" +"entryUUID: ffffffff-ffff-ffff-ffff-ffffffffffff\n"; Entry RuvEntry = TestCaseUtils.entryFromLdifString(RuvString); AddOperationBasis addOp = new AddOperationBasis(InternalClientConnection. getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), null, RuvEntry.getDN(), RuvEntry.getObjectClasses(), RuvEntry.getUserAttributes(), RuvEntry.getOperationalAttributes()); addOp.setInternalOperation(true); addOp.run(); assertTrue(addOp.getResultCode() == ResultCode.SUCCESS); // Instantiate a Replication domain // suffix synchronized String synchroServerLdif = "dn: cn=o=test, cn=domains, cn=Multimaster Synchronization, cn=Synchronization Providers,cn=config\n" + "objectClass: top\n" + "objectClass: ds-cfg-replication-domain\n" + "cn: o=test\n" + "ds-cfg-base-dn: o=test\n" + "ds-cfg-replication-server: localhost:3389\n" + "ds-cfg-server-id: 1\n" + "ds-cfg-receive-status: true\n" + "ds-cfg-window-size: 10"; // When adding the replicationDomain entry the checkRUVCompat // method is called and should translate the RuvEntry Added // into a serverState + generationId synchroServerEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif); DirectoryServer.getConfigHandler().addEntry(synchroServerEntry, null); assertNotNull(DirectoryServer.getConfigEntry(synchroServerEntry.getDN()), "Unable to add the synchronized server"); LDAPReplicationDomain replDomain = LDAPReplicationDomain. retrievesReplicationDomain(DN.decode("o=test")); // Then check serverSate and GenId assertTrue(replDomain.getGenerationID() == 1225361491); ServerState state = replDomain.getServerState(); assertTrue(state.getMaxChangeNumber((short) 1). compareTo(new ChangeNumber("0000011d4d42b240000100000000")) == 0); assertTrue(state.getMaxChangeNumber((short) 3). compareTo(new ChangeNumber("0000011d9a991110000300000000")) == 0); // Remove the configuration entry DirectoryServer.getConfigHandler().deleteEntry(synchroServerEntry.getDN(), null); assertNull(DirectoryServer.getConfigEntry(synchroServerEntry.getDN()), "Unable to remove the synchronized server"); } } opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/DomainFakeCfg.java
@@ -22,7 +22,7 @@ * CDDL HEADER END * * * Copyright 2007-2008 Sun Microsystems, Inc. * Copyright 2007-2009 Sun Microsystems, Inc. */ package org.opends.server.replication.plugin; @@ -49,7 +49,7 @@ private SortedSet<String> replicationServers; private long heartbeatInterval = 1000; private IsolationPolicy policy = IsolationPolicy.REJECT_ALL_UPDATES; // Is assured mode enabled or not ? private boolean assured = false; // Assured sub mode (used when assured is true) @@ -73,7 +73,7 @@ this.serverId = serverId; this.replicationServers = replServers; } /** * Creates a new Domain with the provided information * (assured mode disabled, group id provided) @@ -84,7 +84,7 @@ this(baseDn, serverId, replServers); this.groupId = groupId; } /** * Creates a new Domain with the provided information * (assured mode info provided as well as group id) @@ -113,6 +113,24 @@ } /** * Create a new Domain from the provided arguments. * * @param string The baseDN in string form. * @param serverId The serverID. * @param replServer The replication Server that will be used. * * @throws DirectoryException When the provided string is not a valid DN. */ public DomainFakeCfg(String string, int serverId, String replServer) throws DirectoryException { this.replicationServers = new TreeSet<String>(); this.replicationServers.add(replServer); this.baseDn = DN.decode(string); this.serverId = serverId; } /** * {@inheritDoc} */ public void addChangeListener( @@ -277,7 +295,7 @@ { return assuredType; } public boolean isAssured() { return assured; opends/tests/unit-tests-testng/src/server/org/opends/server/replication/plugin/PersistentServerStateTest.java
@@ -22,18 +22,26 @@ * CDDL HEADER END * * * Copyright 2006-2008 Sun Microsystems, Inc. * Copyright 2006-2009 Sun Microsystems, Inc. */ package org.opends.server.replication.plugin; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; import org.opends.server.TestCaseUtils; import org.opends.server.api.SynchronizationProvider; import org.opends.server.core.AddOperationBasis; import org.opends.server.core.DirectoryServer; import org.opends.server.protocols.internal.InternalClientConnection; import org.opends.server.replication.common.ServerState; import org.opends.server.replication.ReplicationTestCase; import org.opends.server.replication.common.ChangeNumber; import org.opends.server.replication.common.ChangeNumberGenerator; import org.opends.server.types.DN; import org.opends.server.types.Entry; import org.opends.server.types.ResultCode; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import static org.opends.server.TestCaseUtils.*; @@ -103,4 +111,73 @@ "cn1 has not been saved after clear for " + dn); } /** * Ensures that the Directory Server is able to * translate a ruv entry to a sever state. * * @throws Exception If an unexpected problem occurs. */ @SuppressWarnings("unchecked") @Test(enabled = false) public void translateRuvEntryTest() throws Exception { SynchronizationProvider replicationPlugin = null; LDAPReplicationDomain replDomain = null; try { String RuvString = "dn: nsuniqueid=ffffffff-ffffffff-ffffffff-ffffffff, o=test\n" +"objectClass: top\n" +"objectClass: ldapsubentry\n" +"objectClass: extensibleobject\n" +"nsds50ruv: {replicageneration} 49098853000000010000\n" +"nsds50ruv: {replica 3 ldap://kawax:3389} 491d517b000000030000 " +"491d564a000000030000\n" +"nsds50ruv: {replica 1 ldap://kawax:1389} 490989e8000000010000 " +"490989e8000000010000\n" +"ds6ruv: {PRIO 3 ldap://kawax:3389}\n" +"ds6ruv: {PRIO 1 ldap://kawax:1389}\n" +"entryUUID: ffffffff-ffff-ffff-ffff-ffffffffffff\n"; Entry RuvEntry = TestCaseUtils.entryFromLdifString(RuvString); AddOperationBasis addOp = new AddOperationBasis(InternalClientConnection. getRootConnection(), InternalClientConnection.nextOperationID(), InternalClientConnection.nextMessageID(), null, RuvEntry.getDN(), RuvEntry.getObjectClasses(), RuvEntry.getUserAttributes(), RuvEntry.getOperationalAttributes()); addOp.setInternalOperation(true); addOp.run(); assertTrue(addOp.getResultCode() == ResultCode.SUCCESS); replicationPlugin = new MultimasterReplication(); DirectoryServer.registerSynchronizationProvider(replicationPlugin); DomainFakeCfg domainConf = new DomainFakeCfg("o=test", 1, "localhost:3389"); replDomain = MultimasterReplication.createNewDomain(domainConf); replicationPlugin.completeSynchronizationProvider(); // Then check serverSate and GenId assertTrue(replDomain.getGenerationID() == 1225361491); ServerState state = replDomain.getServerState(); assertTrue(state.getMaxChangeNumber((short) 1). compareTo(new ChangeNumber("0000011d4d42b240000100000000")) == 0); assertTrue(state.getMaxChangeNumber((short) 3). compareTo(new ChangeNumber("0000011d9a991110000300000000")) == 0); } finally { if (replDomain != null) MultimasterReplication.deleteDomain(DN.decode("o=test")); if (replicationPlugin != null) DirectoryServer.deregisterSynchronizationProvider(replicationPlugin); } } }