From 9ad3f2ec1167a820f944b17406242a3f8e6aa97f Mon Sep 17 00:00:00 2001
From: dugan <dugan@localhost>
Date: Mon, 29 Oct 2007 19:18:38 +0000
Subject: [PATCH] Fix SEVERE_WARNING error message on replicationChanges database. Also, added implementations of missing methods and fixed null pointer exception when doing export-ldif without running as a task. Issue 2350.
---
opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java | 78 ++++++++++++++++++++++----------------
1 files changed, 45 insertions(+), 33 deletions(-)
diff --git a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
index e23c770..51f7c91 100644
--- a/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
+++ b/opends/tests/unit-tests-testng/src/server/org/opends/server/replication/server/ReplicationServerTest.java
@@ -54,6 +54,7 @@
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.protocols.asn1.ASN1OctetString;
import org.opends.server.protocols.internal.InternalSearchOperation;
+import org.opends.server.protocols.internal.InternalClientConnection;
import org.opends.server.protocols.ldap.LDAPFilter;
import org.opends.server.replication.ReplicationTestCase;
import org.opends.server.replication.common.ChangeNumber;
@@ -74,21 +75,10 @@
import org.opends.server.replication.protocol.UpdateMessage;
import org.opends.server.replication.protocol.WindowMessage;
import org.opends.server.replication.protocol.WindowProbe;
-import org.opends.server.types.Attribute;
-import org.opends.server.types.DN;
-import org.opends.server.types.DereferencePolicy;
-import org.opends.server.types.DirectoryConfig;
-import org.opends.server.types.Entry;
-import org.opends.server.types.LDIFExportConfig;
-import org.opends.server.types.Modification;
-import org.opends.server.types.ModificationType;
-import org.opends.server.types.RDN;
-import org.opends.server.types.ResultCode;
-import org.opends.server.types.SearchFilter;
-import org.opends.server.types.SearchResultEntry;
-import org.opends.server.types.SearchScope;
+import org.opends.server.types.*;
import org.opends.server.util.LDIFWriter;
import org.opends.server.util.TimeThread;
+import static org.opends.server.util.ServerConstants.OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE;
import org.opends.server.workflowelement.localbackend.LocalBackendModifyDNOperation;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
@@ -1000,14 +990,14 @@
}
- /*
+ /*
* Test backup and restore of the Replication server backend
*/
@Test(enabled=false)
public void backupRestore() throws Exception
{
debugInfo("Starting backupRestore");
-
+
Entry backupTask = createBackupTask();
Entry restoreTask = createRestoreTask();
@@ -1016,11 +1006,11 @@
addTask(restoreTask, ResultCode.SUCCESS, null);
waitTaskState(restoreTask, TaskState.COMPLETED_SUCCESSFULLY, null);
-
+
debugInfo("Ending backupRestore");
}
- /*
+ /*
* Test export of the Replication server backend
* - Creates 2 brokers connecting to the replication for 2 differents baseDN
* - Make these brokers publish changes to the replication server
@@ -1031,7 +1021,7 @@
public void exportBackend() throws Exception
{
debugInfo("Starting exportBackend");
-
+
ReplicationBroker server1 = null;
ReplicationBroker server2 = null;
@@ -1044,7 +1034,7 @@
1000, true);
}
catch(Exception e) {}
-
+
debugInfo("Publish changes");
List<UpdateMessage> msgs = createChanges("dc=example,dc=com", (short)1);
for(UpdateMessage msg : msgs )
@@ -1102,7 +1092,7 @@
"ds-backup-directory-path: bak" + File.separator +
"replicationChanges");
}
-
+
private Entry createExportAllTask()
throws Exception
{
@@ -1154,7 +1144,7 @@
// - Add
String lentry = new String("dn: "+suffix+"\n"
- + "objectClass: top\n"
+ + "objectClass: top\n"
+ "objectClass: domain\n"
+ "entryUUID: 11111111-1111-1111-1111-111111111111\n");
Entry entry = TestCaseUtils.entryFromLdifString(lentry);
@@ -1167,7 +1157,7 @@
// - Add
String luentry = new String(
"dn: uid=new person,ou=People,"+suffix+"\n"
- + "objectClass: top\n"
+ + "objectClass: top\n"
+ "objectclass: person\n"
+ "objectclass: organizationalPerson\n"
+ "objectclass: inetOrgPerson\n"
@@ -1179,12 +1169,12 @@
Entry uentry = TestCaseUtils.entryFromLdifString(luentry);
cn = new ChangeNumber(time, ts++, serverId);
AddMsg addMsg2 = new AddMsg(
- cn,
+ cn,
"uid=new person,ou=People,"+suffix,
- user1entryUUID,
- baseUUID,
- uentry.getObjectClassAttribute(),
- uentry.getAttributes(),
+ user1entryUUID,
+ baseUUID,
+ uentry.getObjectClassAttribute(),
+ uentry.getAttributes(),
new ArrayList<Attribute>());
l.add(addMsg2);
@@ -1203,7 +1193,7 @@
cn = new ChangeNumber(time, ts++, serverId);
DN dn = DN.decode("o=test,"+suffix);
- ModifyMsg modMsg = new ModifyMsg(cn, dn,
+ ModifyMsg modMsg = new ModifyMsg(cn, dn,
mods, "fakeuniqueid");
l.add(modMsg);
@@ -1225,6 +1215,7 @@
return l;
}
+
/**
* Testing searches on the backend of the replication server.
* @throws Exception
@@ -1233,9 +1224,9 @@
public void searchBackend() throws Exception
{
debugInfo("Starting searchBackend");
-
+
replicationServer.clearDb();
-
+
LDIFWriter ldifWriter = null;
ByteArrayOutputStream stream = new ByteArrayOutputStream();
LDIFExportConfig exportConfig = new LDIFExportConfig(stream);
@@ -1267,6 +1258,27 @@
ReplicationBackend b =
(ReplicationBackend)DirectoryServer.getBackend("replicationChanges");
b.setServer(replicationServer);
+ assertTrue(b.getEntryCount() == msgs.size());
+ assertTrue(b.entryExists(DN.decode("dc=replicationChanges")));
+ SearchFilter filter=SearchFilter.createFilterFromString("(objectclass=*)");
+ assertTrue(b.isIndexed(filter));
+ InternalClientConnection conn =
+ InternalClientConnection.getRootConnection();
+ LinkedList<Control> requestControls = new LinkedList<Control>();
+ requestControls.add(new Control(OID_INTERNAL_GROUP_MEMBERSHIP_UPDATE,
+ false));
+ DN baseDN=DN.decode("dc=replicationChanges");
+ //Test the group membership control causes search to be skipped.
+ InternalSearchOperation internalSearch =
+ new InternalSearchOperation(conn, conn.nextOperationID(),
+ conn.nextMessageID(), requestControls,
+ baseDN,
+ SearchScope.WHOLE_SUBTREE,
+ DereferencePolicy.NEVER_DEREF_ALIASES,
+ 0, 0, false, filter, null, null);
+ internalSearch.run();
+ assertTrue(internalSearch.getResultCode() == ResultCode.SUCCESS);
+ assertTrue(internalSearch.getSearchEntries().isEmpty());
// General search
InternalSearchOperation op = connection.processSearch(
@@ -1347,7 +1359,7 @@
SearchFilter ALLMATCH;
ALLMATCH = SearchFilter.createFilterFromString("(changetype=moddn)");
op =
- connection.processSearch(DN.decode("dc=replicationChanges"),
+ connection.processSearch(DN.decode("dc=replicationChanges"),
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, ALLMATCH,
attrs);
@@ -1368,7 +1380,7 @@
attrs.add("*");
ALLMATCH = SearchFilter.createFilterFromString("(changetype=*)");
op =
- connection.processSearch(DN.decode("dc=replicationChanges"),
+ connection.processSearch(DN.decode("dc=replicationChanges"),
SearchScope.WHOLE_SUBTREE,
DereferencePolicy.NEVER_DEREF_ALIASES, 0, 0, false, ALLMATCH,
attrs2);
@@ -1378,6 +1390,6 @@
if (server1 != null)
server1.stop();
- debugInfo("Successfully ending searchBackend");
+ debugInfo("Successfully ending searchBackend");
}
}
--
Gitblit v1.10.0