From f73b655466092169abac34833fb628fce1fcdebe Mon Sep 17 00:00:00 2001
From: jcduff <jcduff@localhost>
Date: Thu, 23 Oct 2008 14:04:24 +0000
Subject: [PATCH] The commit will bring the following features : - An updated version of the underlying database. BDB JE 3.3 is now used. - Attribute API refactoring providing a better abstraction and offering improved performances. - A new GUI called the Control-Panel to replace the Status-Panel: the specifications for this GUI are available on OpenDS Wiki and contains a link to a mockup. See <https://www.opends.org/wiki/page/ControlPanelUISpecification>. - Some changes in the replication protocol to implement "Assured Replication Mode". The specifications are on OpenDS Wiki at <https://www.opends.org/wiki/page/AssuredMode> and section 7 described some of the replication changes required to support this. Assured Replication is not finished, but the main replication protocol changes to support it are done. As explained by Gilles on an email on the Dev mailing list (http://markmail.org/message/46rgo3meq3vriy4a), with these changes the newer versions of OpenDS may not be able to replicate with OpenDS 1.0 instances. - Support for Service Tags on the platforms where the functionality is available and enabled. Specifications are published at <https://www.opends.org/wiki/page/OpenDSServiceTagEnabled>. For more information on Service Tags see <http://wikis.sun.com/display/ServiceTag/Sun+Service+Tag+FAQ>. - The Admin Connector service. In order to provide agentry of the OpenDS server at any time, a new service has been added, dedicated to the administration, configuration and monitoring of the server. An overview of the Admin Connector service and it's use is available on the OpenDS wiki <https://www.opends.org/wiki/page/ManagingAdministrationTrafficToTheServer> - Updates to the various command line tools to support the Admin Connector service. - Some internal re-architecting of the server to put the foundation of future developments such as virtual directory services. The new NetworkGroups and WorkFlow internal services which have been specified in <https://www.opends.org/wiki/page/BasicOperationRoutingThroughNetworkGroup> are now implemented. - Many bug fixes...
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java | 219 ++++++++++++++++++++++++++++--------------------------
1 files changed, 112 insertions(+), 107 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
index e164da4..b388847 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/SchemaReplicationTest.java
@@ -34,7 +34,6 @@
import java.io.FileInputStream;
import java.net.ServerSocket;
import java.util.ArrayList;
-import java.util.LinkedHashSet;
import java.util.List;
import org.opends.server.TestCaseUtils;
@@ -49,11 +48,11 @@
import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.replication.common.ChangeNumberGenerator;
import org.opends.server.replication.plugin.ReplicationBroker;
+import org.opends.server.replication.protocol.DeleteMsg;
import org.opends.server.replication.protocol.ModifyMsg;
-import org.opends.server.replication.protocol.ReplicationMessage;
+import org.opends.server.replication.protocol.ReplicationMsg;
import org.opends.server.types.Attribute;
-import org.opends.server.types.AttributeType;
-import org.opends.server.types.AttributeValue;
+import org.opends.server.types.Attributes;
import org.opends.server.types.DN;
import org.opends.server.types.Modification;
import org.opends.server.types.ModificationType;
@@ -82,8 +81,9 @@
@BeforeClass
public void setUp() throws Exception
{
+ super.setUp();
+
// This test suite depends on having the schema available.
- TestCaseUtils.startServer();
// find a free port for the replicationServer
ServerSocket socket = TestCaseUtils.bindFreePort();
@@ -93,29 +93,24 @@
// Create an internal connection
connection = InternalClientConnection.getRootConnection();
- // top level synchro provider
- String synchroStringDN = "cn=Synchronization Providers,cn=config";
-
- // Multimaster Synchro plugin
- synchroPluginStringDN = "cn=Multimaster Synchronization, "
- + synchroStringDN;
-
// Change log
String replServerLdif =
- "dn: " + "cn=Replication Server, " + synchroPluginStringDN + "\n"
+ "dn: " + "cn=Replication Server, " + SYNCHRO_PLUGIN_DN + "\n"
+ "objectClass: top\n"
+ "objectClass: ds-cfg-replication-server\n"
+ "cn: Replication Server\n"
+ "ds-cfg-replication-port: " + replServerPort + "\n"
- + "ds-cfg-replication-server-id: 1\n";
+ + "ds-cfg-replication-db-directory: SchemaReplicationTest\n"
+ + "ds-cfg-replication-server-id: 105\n";
replServerEntry = TestCaseUtils.entryFromLdifString(replServerLdif);
// suffix synchronized
+ String testName = "schemaReplicationTest";
String domainLdif =
- "dn: cn=example, cn=domains, " + synchroPluginStringDN + "\n"
+ "dn: cn=" + testName + ", cn=domains, " + SYNCHRO_PLUGIN_DN + "\n"
+ "objectClass: top\n"
+ "objectClass: ds-cfg-replication-domain\n"
- + "cn: example\n"
+ + "cn: " + testName + "\n"
+ "ds-cfg-base-dn: cn=schema\n"
+ "ds-cfg-replication-server: localhost:" + replServerPort + "\n"
+ "ds-cfg-server-id: 1\n";
@@ -142,11 +137,8 @@
try
{
// Modify the schema
- AttributeType attrType =
- DirectoryServer.getAttributeType("attributetypes", true);
- LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
- values.add(new AttributeValue(attrType, "( 2.5.44.77.33 NAME 'dummy' )"));
- Attribute attr = new Attribute(attrType, "attributetypes", values);
+ Attribute attr = Attributes.create("attributetypes",
+ "( 2.5.44.77.33 NAME 'dummy' )");
List<Modification> mods = new ArrayList<Modification>();
Modification mod = new Modification(ModificationType.ADD, attr);
mods.add(mod);
@@ -161,7 +153,7 @@
"The original operation failed: " + code.getResultCodeName());
// See if the client has received the msg
- ReplicationMessage msg = broker.receive();
+ ReplicationMsg msg = broker.receive();
assertTrue(msg instanceof ModifyMsg,
"The received replication message is not a MODIFY msg");
@@ -201,7 +193,13 @@
code = modOp.getResultCode();
assertTrue(code.equals(ResultCode.SUCCESS),
- "The original operation failed");
+ "The original operation failed" + code.getResultCodeName());
+
+ // See if the client has received the msg
+ msg = broker.receive();
+
+ assertTrue(msg instanceof ModifyMsg,
+ "The received replication message is not a MODIFY msg");
}
finally
{
@@ -224,18 +222,25 @@
ReplicationBroker broker =
openReplicationSession(baseDn, (short) 2, 100, replServerPort, 5000, true);
- ChangeNumberGenerator gen = new ChangeNumberGenerator((short)2, 0);
+ try
+ {
+ ChangeNumberGenerator gen = new ChangeNumberGenerator((short) 2, 0);
- ModifyMsg modMsg = new ModifyMsg(gen.newChangeNumber(),
- baseDn, rcvdMods, "cn=schema");
- broker.publish(modMsg);
+ ModifyMsg modMsg = new ModifyMsg(gen.newChangeNumber(),
+ baseDn, rcvdMods, "cn=schema");
+ broker.publish(modMsg);
- boolean found = checkEntryHasAttribute(baseDn, "attributetypes",
- "( 2.5.44.77.33 NAME 'dummy' )",
- 10000, true);
+ boolean found = checkEntryHasAttribute(baseDn, "attributetypes",
+ "( 2.5.44.77.33 NAME 'dummy' )",
+ 10000, true);
- if (found == false)
- fail("The modification has not been correctly replayed.");
+ if (found == false)
+ fail("The modification has not been correctly replayed.");
+ }
+ finally
+ {
+ broker.stop();
+ }
}
/**
@@ -256,89 +261,89 @@
ReplicationBroker broker =
openReplicationSession(baseDn, (short) 3, 100, replServerPort, 5000, true);
-
- // create a schema change Notification
- AttributeType attrType =
- DirectoryServer.getAttributeType("attributetypes", true);
- LinkedHashSet<AttributeValue> values = new LinkedHashSet<AttributeValue>();
- values.add(new AttributeValue(attrType, "( 2.5.44.76.35 NAME 'push' )"));
- Attribute attr = new Attribute(attrType, "attributetypes", values);
- List<Modification> mods = new ArrayList<Modification>();
- Modification mod = new Modification(ModificationType.ADD, attr);
- mods.add(mod);
-
- for (SynchronizationProvider<SynchronizationProviderCfg> provider :
- DirectoryServer.getSynchronizationProviders())
+
+ try
{
- provider.processSchemaChange(mods);
- }
+ // create a schema change Notification
+ Attribute attr = Attributes.create("attributetypes",
+ "( 2.5.44.76.35 NAME 'push' )");
+ List<Modification> mods = new ArrayList<Modification>();
+ Modification mod = new Modification(ModificationType.ADD, attr);
+ mods.add(mod);
- // receive the message on the broker side.
- ReplicationMessage msg = broker.receive();
-
- assertTrue(msg instanceof ModifyMsg,
- "The received replication message is not a MODIFY msg");
- ModifyMsg modMsg = (ModifyMsg) msg;
-
- Operation receivedOp = modMsg.createOperation(connection);
- assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0,
- "The received message is not for cn=schema");
-
- assertTrue(receivedOp instanceof ModifyOperation,
- "The received replication message is not a MODIFY msg");
- ModifyOperation receivedModifyOperation = (ModifyOperation) receivedOp;
-
- List<RawModification> rcvdRawMods =
- receivedModifyOperation.getRawModifications();
-
- this.rcvdMods = new ArrayList<Modification>();
- for (RawModification m : rcvdRawMods)
- {
- this.rcvdMods.add(m.toModification());
- }
-
- assertTrue(this.rcvdMods.contains(mod),
- "The received mod does not contain the original change");
-
- // check that the schema files were updated with the new ServerState.
- // by checking that the ChangeNUmber of msg we just received has been
- // added to the user schema file.
-
- // build the string to find in the schema file
- String stateStr = modMsg.getChangeNumber().toString();
-
- // open the schema file
- String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
- String path = buildRoot + File.separator + "build" + File.separator +
- "unit-tests" + File.separator + "package-instance" +
- File.separator +
- "config" + File.separator + "schema" + File.separator +
- "99-user.ldif";
-
- // it is necessary to loop on this check because the state is not
- // written immediately but only every so often.
- int count = 0;
- while (true)
- {
- File file = new File(path);
- FileInputStream input = new FileInputStream(file);
- byte[] bytes = new byte[input.available()];
- input.read(bytes);
- String fileStr = new String(bytes);
- if (fileStr.indexOf(stateStr) != -1)
+ for (SynchronizationProvider<SynchronizationProviderCfg> provider : DirectoryServer.
+ getSynchronizationProviders())
{
- break;
+ provider.processSchemaChange(mods);
}
- else
+
+ // receive the message on the broker side.
+ ReplicationMsg msg = broker.receive();
+
+ assertTrue(msg instanceof ModifyMsg,
+ "The received replication message is not a MODIFY msg");
+ ModifyMsg modMsg = (ModifyMsg) msg;
+
+ Operation receivedOp = modMsg.createOperation(connection);
+ assertTrue(DN.decode(modMsg.getDn()).compareTo(baseDn) == 0,
+ "The received message is not for cn=schema");
+
+ assertTrue(receivedOp instanceof ModifyOperation,
+ "The received replication message is not a MODIFY msg");
+ ModifyOperation receivedModifyOperation = (ModifyOperation) receivedOp;
+
+ List<RawModification> rcvdRawMods =
+ receivedModifyOperation.getRawModifications();
+
+ this.rcvdMods = new ArrayList<Modification>();
+ for (RawModification m : rcvdRawMods)
{
- if (count++ > 50)
+ this.rcvdMods.add(m.toModification());
+ }
+
+ assertTrue(this.rcvdMods.contains(mod),
+ "The received mod does not contain the original change");
+
+ // check that the schema files were updated with the new ServerState.
+ // by checking that the ChangeNUmber of msg we just received has been
+ // added to the user schema file.
+
+ // build the string to find in the schema file
+ String stateStr = modMsg.getChangeNumber().toString();
+
+ // open the schema file
+ String buildRoot = System.getProperty(TestCaseUtils.PROPERTY_BUILD_ROOT);
+ String path = buildRoot + File.separator + "build" + File.separator +
+ "unit-tests" + File.separator + "package-instance" + File.separator +
+ "config" + File.separator + "schema" + File.separator +
+ "99-user.ldif";
+
+ // it is necessary to loop on this check because the state is not
+ // written immediately but only every so often.
+ int count = 0;
+ while (true)
+ {
+ File file = new File(path);
+ FileInputStream input = new FileInputStream(file);
+ byte[] bytes = new byte[input.available()];
+ input.read(bytes);
+ String fileStr = new String(bytes);
+ if (fileStr.indexOf(stateStr) != -1)
{
- fail("The Schema persistentState (changenumber:"
- + stateStr + ") has not been saved to " + path + " : " + fileStr);
+ break;
+ } else
+ {
+ if (count++ > 50)
+ {
+ fail("The Schema persistentState (changenumber:" + stateStr +
+ ") has not been saved to " + path + " : " + fileStr);
+ } else
+ TestCaseUtils.sleep(100);
}
- else
- TestCaseUtils.sleep(100);
}
+ } finally
+ {
+ broker.stop();
}
}
}
--
Gitblit v1.10.0