Readability: TestCaseUtils.entryFromLdifString() => TestCaseUtils.makeEntry()
| | |
| | | * - Configure replication server |
| | | * - check that the last entry has been correctly added |
| | | */ |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n" |
| | | + "entryuuid: " + stringUID(1) + "\n"); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn:" + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "entryuuid: " + stringUID(1)); |
| | | |
| | | replServer = newReplicationServer(replServerId, addSequenceLength * 5 + 100, "dependencyTestAddModDelDependencyTestDb"); |
| | | |
| | |
| | | try |
| | | { |
| | | // Create replication server, replication domain and broker. |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n"); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn:" + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organization"); |
| | | |
| | | CSNGenerator gen = new CSNGenerator(brokerId, 0L); |
| | | int renamedEntryUuid = 100; |
| | |
| | | TestCaseUtils.initializeTestBackend(false); |
| | | |
| | | // Create top entry with uuid |
| | | Entry topEntry = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n" |
| | | + "o: test\n" |
| | | + "entryuuid: " + stringUID(1) + "\n"); |
| | | Entry topEntry = TestCaseUtils.makeEntry( |
| | | "dn:" + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organization", |
| | | "o: test", |
| | | "entryuuid: " + stringUID(1)); |
| | | |
| | | MemoryBackend memoryBackend = (MemoryBackend) DirectoryServer.getBackend(TEST_BACKEND_ID); |
| | | memoryBackend.addEntry(topEntry, null); |
| | |
| | | |
| | | try |
| | | { |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n"); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn:" + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organization"); |
| | | |
| | | replServer = newReplicationServer(replServerId, 5 * addSequenceLength + 100, "dependencyTestAddDelAddDependencyTestDb"); |
| | | |
| | |
| | | |
| | | try |
| | | { |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn:" + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organization\n"); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn:" + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organization"); |
| | | |
| | | replServer = newReplicationServer(replServerId, 5 * addSequenceLength + 100, "dependencyTestAddModdnDependencyTestDb"); |
| | | |
| | |
| | | |
| | | String user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | | String user1dn = "uid=user1,ou=People," + baseDnStr; |
| | | Entry personWithUUIDEntry = TestCaseUtils.entryFromLdifString( |
| | | "dn: "+ user1dn + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" + "uid: user.1\n" |
| | | + "homePhone: 951-245-7634\n" |
| | | + "description: This is the description for Aaccf Amar.\n" + "st: NC\n" |
| | | + "mobile: 027-085-0537\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" + "l: Rockford\n" + "pager: 508-763-4246\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "telephoneNumber: 216-564-6748\n" + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" + "givenName: Aaccf\n" + "postalCode: 85762\n" |
| | | + "userPassword: password\n" + "initials: AA\n" |
| | | + "entryUUID: " + user1entryUUID + "\n"); |
| | | // @formatter:off |
| | | Entry personWithUUIDEntry = TestCaseUtils.makeEntry( |
| | | "dn: "+ user1dn, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "homePhone: 951-245-7634", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "mobile: 027-085-0537", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "pager: 508-763-4246", |
| | | "street: 17984 Thirteenth Street", |
| | | "telephoneNumber: 216-564-6748", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA", |
| | | "entryUUID: " + user1entryUUID); |
| | | // @formatter:on |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | return new AddMsg(gen.newCSN(), |
| | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.adapter.server3x.Converters; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.AddOperation; |
| | |
| | | import org.opends.server.replication.server.ReplServerFakeConfiguration; |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.Operation; |
| | |
| | | |
| | | // suffix synchronized |
| | | String testName = "protocolWindowTest"; |
| | | String synchroServerLdif = |
| | | "dn: " + "cn=" + testName + ", cn=domains, " + SYNCHRO_PLUGIN_DN + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: ds-cfg-replication-domain\n" |
| | | + "cn: " + testName + "\n" |
| | | + "ds-cfg-base-dn: " + TEST_ROOT_DN_STRING + "\n" |
| | | + "ds-cfg-replication-server: localhost:" + replServerPort + "\n" |
| | | + "ds-cfg-server-id: 1\n" |
| | | + "ds-cfg-receive-status: true\n" |
| | | + "ds-cfg-window-size: " + WINDOW_SIZE; |
| | | Entry repDomainEntry = TestCaseUtils.entryFromLdifString(synchroServerLdif); |
| | | // @formatter:off |
| | | Entry repDomainEntry = TestCaseUtils.makeEntry( |
| | | "dn: " + "cn=" + testName + ", cn=domains, " + SYNCHRO_PLUGIN_DN, |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-replication-domain", |
| | | "cn: " + testName, |
| | | "ds-cfg-base-dn: " + TEST_ROOT_DN_STRING, |
| | | "ds-cfg-replication-server: localhost:" + replServerPort, |
| | | "ds-cfg-server-id: 1", |
| | | "ds-cfg-receive-status: true", |
| | | "ds-cfg-window-size: " + WINDOW_SIZE); |
| | | // @formatter:on |
| | | |
| | | // Configure replication domain |
| | | DirectoryServer.getConfigurationHandler().addEntry(Converters.from(repDomainEntry)); |
| | |
| | | replicationServer = new ReplicationServer(new ReplServerFakeConfiguration( |
| | | replServerPort, "protocolWindowTestDb", 0, 1, REPLICATION_QUEUE_SIZE, WINDOW_SIZE, null)); |
| | | |
| | | String personLdif = "dn: uid=user.windowTest," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" + "uid: user.1\n" |
| | | + "homePhone: 951-245-7634\n" |
| | | + "description: This is the description for Aaccf Amar.\n" + "st: NC\n" |
| | | + "mobile: 027-085-0537\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" + "l: Rockford\n" + "pager: 508-763-4246\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "telephoneNumber: 216-564-6748\n" + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" + "givenName: Aaccf\n" + "postalCode: 85762\n" |
| | | + "userPassword: password\n" + "initials: AA\n"; |
| | | personEntry = TestCaseUtils.entryFromLdifString(personLdif); |
| | | // @formatter:off |
| | | personEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=user.windowTest," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "homePhone: 951-245-7634", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "mobile: 027-085-0537", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "pager: 508-763-4246", |
| | | "street: 17984 Thirteenth Street", |
| | | "telephoneNumber: 216-564-6748", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA\n"); |
| | | // @formatter:on |
| | | } |
| | | |
| | | private void processModify(int count) |
| | |
| | | // data. So for this particular test, we use a classical backend. Let's |
| | | // clear it and create the root entry |
| | | TestCaseUtils.clearBackend("userRoot"); |
| | | addEntry("dn: dc=example,dc=com\n" + "objectClass: top\n" |
| | | + "objectClass: domain\n"); |
| | | addEntry("dn: dc=example,dc=com", |
| | | "objectClass: top", |
| | | "objectClass: domain"); |
| | | |
| | | // Change log |
| | | String replServerLdif = |
| | |
| | | Thread.sleep(1000); |
| | | |
| | | // Create a dummy entry |
| | | addEntry("dn: dc=dummy," + EXAMPLE_DN + "\n" |
| | | + "objectClass: top\n" + "objectClass: domain\n"); |
| | | addEntry("dn: dc=dummy," + EXAMPLE_DN, |
| | | "objectClass: top", |
| | | "objectClass: domain"); |
| | | } |
| | | |
| | | /** |
| | | * Utility function. Can be used to create and add and entry |
| | | * in the local DS from its ldif description. |
| | | * |
| | | * @param entryString The entry in ldif from. |
| | | * @param ldif The entry in ldif from. |
| | | * @return The ResultCode of the operation. |
| | | * @throws Exception If something went wrong. |
| | | */ |
| | | private ResultCode addEntry(String entryString) throws Exception |
| | | private ResultCode addEntry(String... ldif) throws Exception |
| | | { |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryString); |
| | | Entry entry = TestCaseUtils.makeEntry(ldif); |
| | | AddOperation addOp = connection.processAdd(entry); |
| | | entriesToCleanup.add(entry.getName()); |
| | | return addOp.getResultCode(); |
| | |
| | | + "ds-task-backup-all: TRUE\n"); |
| | | |
| | | debugInfo("testResyncAfterRestore: backup done"); |
| | | addEntry("dn: dc=fooUniqueName1," + EXAMPLE_DN + "\n" |
| | | + "objectClass: top\n" + "objectClass: domain\n"); |
| | | addEntry("dn: dc=fooUniqueName1," + EXAMPLE_DN, |
| | | "objectClass: top", |
| | | "objectClass: domain"); |
| | | debugInfo("testResyncAfterRestore: entry added"); |
| | | |
| | | task("dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks\n" |
| | |
| | | + "ds-task-export-ldif-file: " + path + "\n"); |
| | | |
| | | debugInfo("testResyncAfterImport: export done"); |
| | | addEntry("dn: dc=fooUniqueName2," + EXAMPLE_DN + "\n" |
| | | + "objectClass: top\n" + "objectClass: domain\n"); |
| | | addEntry("dn: dc=fooUniqueName2," + EXAMPLE_DN, |
| | | "objectClass: top", |
| | | "objectClass: domain"); |
| | | debugInfo("testResyncAfterImport: entry added"); |
| | | |
| | | task("dn: ds-task-id=" + UUID.randomUUID() + ",cn=Scheduled Tasks,cn=Tasks\n" |
| | |
| | | import org.forgerock.opendj.config.server.ConfigException; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.forgerock.opendj.server.config.server.MonitorProviderCfg; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.MonitorData; |
| | | import org.forgerock.opendj.server.config.server.MonitorProviderCfg; |
| | | import org.opends.server.api.MonitorProvider; |
| | | import org.opends.server.core.AddOperation; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | connection = InternalClientConnection.getRootConnection(); |
| | | |
| | | // Create necessary backend top level entry |
| | | String topEntry = "dn: ou=People," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organizationalUnit\n" |
| | | + "entryUUID: 11111111-1111-1111-1111-111111111111\n"; |
| | | TestCaseUtils.addEntry(topEntry); |
| | | TestCaseUtils.addEntry( |
| | | "dn: ou=People," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit", |
| | | "entryUUID: 11111111-1111-1111-1111-111111111111"); |
| | | |
| | | replServerPort = TestCaseUtils.findFreePort(); |
| | | |
| | |
| | | + "ds-cfg-replication-server: localhost:" + replServerPort + "\n" |
| | | + "ds-cfg-server-id: 1\n" + "ds-cfg-receive-status: true\n"; |
| | | |
| | | String personLdif = "dn: uid=user.1,ou=People," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" + "uid: user.1\n" |
| | | + "homePhone: 951-245-7634\n" |
| | | + "description: This is the description for Aaccf Amar.\n" + "st: NC\n" |
| | | + "mobile: 027-085-0537\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" + "l: Rockford\n" + "pager: 508-763-4246\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "telephoneNumber: 216-564-6748\n" + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" + "givenName: Aaccf\n" + "postalCode: 85762\n" |
| | | + "userPassword: password\n" + "initials: AA\n"; |
| | | personEntry = TestCaseUtils.entryFromLdifString(personLdif); |
| | | // @formatter:off |
| | | personEntry = TestCaseUtils.makeEntry( |
| | | "dn: uid=user.1,ou=People," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "homePhone: 951-245-7634", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "mobile: 027-085-0537", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "pager: 508-763-4246", |
| | | "street: 17984 Thirteenth Street", |
| | | "telephoneNumber: 216-564-6748", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA"); |
| | | // @formatter:on |
| | | |
| | | configureReplication(replServerLdif, synchroServerLdif); |
| | | } |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static org.assertj.core.data.MapEntry.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.InetSocketAddress; |
| | | import java.net.ServerSocket; |
| | | import java.net.Socket; |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.StringTokenizer; |
| | | import java.util.UUID; |
| | | |
| | | import org.assertj.core.api.Assertions; |
| | | import org.assertj.core.data.MapEntry; |
| | |
| | | import org.opends.server.protocols.internal.InternalSearchOperation; |
| | | import org.opends.server.protocols.internal.SearchRequest; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.*; |
| | | import org.opends.server.replication.protocol.*; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.replication.common.AssuredMode; |
| | | import org.opends.server.replication.common.CSNGenerator; |
| | | import org.opends.server.replication.common.DSInfo; |
| | | import org.opends.server.replication.common.RSInfo; |
| | | import org.opends.server.replication.common.ServerState; |
| | | import org.opends.server.replication.common.ServerStatus; |
| | | import org.opends.server.replication.protocol.AckMsg; |
| | | import org.opends.server.replication.protocol.AddMsg; |
| | | import org.opends.server.replication.protocol.ReplServerStartMsg; |
| | | import org.opends.server.replication.protocol.ReplSessionSecurity; |
| | | import org.opends.server.replication.protocol.ReplicationMsg; |
| | | import org.opends.server.replication.protocol.ServerStartMsg; |
| | | import org.opends.server.replication.protocol.Session; |
| | | import org.opends.server.replication.protocol.StartSessionMsg; |
| | | import org.opends.server.replication.protocol.StopMsg; |
| | | import org.opends.server.replication.protocol.TopologyMsg; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.Operation; |
| | | import org.opends.server.types.SearchFilter; |
| | | import org.opends.server.types.SearchResultEntry; |
| | | import org.opends.server.util.StaticUtils; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static org.assertj.core.data.MapEntry.*; |
| | | import static org.opends.server.TestCaseUtils.*; |
| | | import static org.opends.server.protocols.internal.Requests.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Test the client part (plugin) of the assured feature in both safe data and |
| | | * safe read modes. We use a fake RS and control the behaviour of the client |
| | |
| | | replServerPort = TestCaseUtils.findFreePort(); |
| | | |
| | | // Create base dns for each tested modes |
| | | String topEntry = "dn: " + SAFE_DATA_DN + "\n" + "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(topEntry)); |
| | | topEntry = "dn: " + SAFE_READ_DN + "\n" + "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(topEntry)); |
| | | topEntry = "dn: " + NOT_ASSURED_DN + "\n" + "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(topEntry)); |
| | | addEntry("dn: " + SAFE_DATA_DN, |
| | | "objectClass: top" + |
| | | "objectClass: organizationalUnit"); |
| | | addEntry("dn: " + SAFE_READ_DN, |
| | | "objectClass: top" + |
| | | "objectClass: organizationalUnit"); |
| | | addEntry("dn: " + NOT_ASSURED_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | |
| | | /** Add an entry in the database. */ |
| | | private void addEntry(Entry entry) throws Exception |
| | | private void addEntry(String... ldifLines) throws Exception |
| | | { |
| | | Entry entry = TestCaseUtils.makeEntry(ldifLines); |
| | | debugInfo("AddEntry " + entry.getName()); |
| | | AddOperation addOp = connection.processAdd(entry); |
| | | waitOpResult(addOp, ResultCode.SUCCESS); |
| | |
| | | private Entry createNotAssuredDomain() throws Exception |
| | | { |
| | | // Create a not assured config entry ldif |
| | | String configEntryLdif = "dn: cn=" + testName + ", cn=domains, " + |
| | | SYNCHRO_PLUGIN_DN + "\n" + "objectClass: top\n" + |
| | | "objectClass: ds-cfg-replication-domain\n" + "cn: " + testName + "\n" + |
| | | "ds-cfg-base-dn: " + NOT_ASSURED_DN + "\n" + |
| | | "ds-cfg-replication-server: localhost:" + replServerPort + "\n" + |
| | | "ds-cfg-server-id: 1\n" + "ds-cfg-receive-status: true\n" + |
| | | // @formatter:off |
| | | Entry domainCfgEntry = TestCaseUtils.makeEntry( |
| | | "dn: cn=" + testName + ", cn=domains, " + SYNCHRO_PLUGIN_DN, |
| | | "objectClass: top", |
| | | "objectClass: ds-cfg-replication-domain", |
| | | "cn: " + testName, |
| | | "ds-cfg-base-dn: " + NOT_ASSURED_DN, |
| | | "ds-cfg-replication-server: localhost:" + replServerPort, |
| | | "ds-cfg-server-id: 1", |
| | | "ds-cfg-receive-status: true", |
| | | // heartbeat = 10 min so no need to emulate heartbeat in fake RS: session |
| | | // not closed by client |
| | | "ds-cfg-heartbeat-interval: 600000ms\n" + |
| | | "ds-cfg-changetime-heartbeat-interval: 0ms\n"; |
| | | |
| | | Entry domainCfgEntry = TestCaseUtils.entryFromLdifString(configEntryLdif); |
| | | "ds-cfg-heartbeat-interval: 600000ms", |
| | | "ds-cfg-changetime-heartbeat-interval: 0ms"); |
| | | // @formatter:on |
| | | |
| | | // Add the config entry to create the replicated domain |
| | | DirectoryServer.getConfigurationHandler().addEntry(Converters.from(domainCfgEntry)); |
| | | assertNotNull(DirectoryServer.getEntry(domainCfgEntry.getName()), |
| | | "Unable to add the domain config entry: " + configEntryLdif); |
| | | "Unable to add the domain config entry: " + domainCfgEntry); |
| | | |
| | | return domainCfgEntry; |
| | | } |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sd-timeout-entry" + rsGroupId + "," + SAFE_DATA_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sd-timeout-entry" + rsGroupId + "," + SAFE_DATA_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sd-timeout-entry" + rsGroupId + "," + NOT_ASSURED_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sd-timeout-entry" + rsGroupId + "," + NOT_ASSURED_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sr-timeout-entry" + rsGroupId + "," + SAFE_READ_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sr-timeout-entry" + rsGroupId + "," + SAFE_READ_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | else |
| | | { |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sr-timeout-entry" + rsGroupId + "," + NOT_ASSURED_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sr-timeout-entry" + rsGroupId + "," + NOT_ASSURED_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | long endTime = System.currentTimeMillis(); |
| | | |
| | |
| | | waitForConnectionToRs(testcase, replicationServer); |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | String entry = "dn: ou=not-assured-entry," + NOT_ASSURED_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=not-assured-entry," + NOT_ASSURED_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | // Wait for entry received by RS |
| | | waitForScenarioExecutedOnRs(testcase, replicationServer); |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | long startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sd-no-timeout-entry," + SAFE_DATA_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sd-no-timeout-entry," + SAFE_DATA_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedForLessThanTimeout(startTime, TIMEOUT); |
| | | assertTrue(replicationServer.isScenarioExecuted()); |
| | |
| | | |
| | | // Make an LDAP update (add an entry) |
| | | long startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entry = "dn: ou=assured-sr-no-timeout-entry," + SAFE_READ_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: ou=assured-sr-no-timeout-entry," + SAFE_READ_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedForLessThanTimeout(startTime, TIMEOUT); |
| | | assertTrue(replicationServer.isScenarioExecuted()); |
| | |
| | | /* Send an update from the RS and get the ack */ |
| | | |
| | | // Make the RS send an assured add message |
| | | String entryStr = "dn: ou=assured-sr-reply-entry," + SAFE_READ_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryStr); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: ou=assured-sr-reply-entry," + SAFE_READ_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | String parentUid = getEntryUUID(DN.valueOf(SAFE_READ_DN)); |
| | | |
| | | try { |
| | |
| | | |
| | | // Make the RS send an assured add message: we expect a read timeout as |
| | | // safe data should be ignored by DS |
| | | String entryStr = "dn: ou=assured-sd-reply-entry," + SAFE_DATA_DN + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryStr); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: ou=assured-sd-reply-entry," + SAFE_DATA_DN, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | String parentUid = getEntryUUID(DN.valueOf(SAFE_DATA_DN)); |
| | | |
| | | AckMsg ackMsg = replicationServer.sendAssuredAddMsg(entry, parentUid); |
| | |
| | | // Make a first LDAP update (add an entry) |
| | | long startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entryDn = "ou=assured-sd-many-errors-entry," + SAFE_DATA_DN; |
| | | String entry = "dn: " + entryDn + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: " + entryDn, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedForLessThanTimeout(startTime, TIMEOUT); |
| | | |
| | |
| | | |
| | | // Make a third LDAP update (re-add the entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: " + entryDn, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedLongerThanTimeout(startTime, System.currentTimeMillis(), TIMEOUT); |
| | | assertTrue(replicationServer.isScenarioExecuted()); |
| | |
| | | // Make a first LDAP update (add an entry) |
| | | long startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | String entryDn = "ou=assured-sr-many-errors-entry," + SAFE_READ_DN; |
| | | String entry = "dn: " + entryDn + "\n" + |
| | | "objectClass: top\n" + |
| | | "objectClass: organizationalUnit\n"; |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: " + entryDn, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedForLessThanTimeout(startTime, TIMEOUT); |
| | | |
| | |
| | | |
| | | // Make a third LDAP update (re-add the entry) |
| | | startTime = System.currentTimeMillis(); // Time the update has been initiated |
| | | addEntry(TestCaseUtils.entryFromLdifString(entry)); |
| | | addEntry("dn: " + entryDn, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | |
| | | assertBlockedLongerThanTimeout(startTime, System.currentTimeMillis(), TIMEOUT); |
| | | assertTrue(replicationServer.isScenarioExecuted()); |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.SortedSet; |
| | | import java.util.TreeSet; |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | |
| | | import org.forgerock.opendj.ldap.ByteString; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.ModificationType; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.backends.task.Task; |
| | | import org.opends.server.core.DirectoryServer; |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.FakeReplicationDomain; |
| | | import org.opends.server.replication.service.ReplicationDomain; |
| | | import org.forgerock.opendj.ldap.schema.AttributeType; |
| | | import org.opends.server.types.*; |
| | | import org.opends.server.types.Attribute; |
| | | import org.opends.server.types.Attributes; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.types.HostPort; |
| | | import org.opends.server.types.Modification; |
| | | import org.opends.server.types.ObjectClass; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Various tests around fractional replication |
| | | */ |
| | | /** Various tests around fractional replication */ |
| | | @SuppressWarnings("javadoc") |
| | | public class FractionalReplicationTest extends ReplicationTestCase { |
| | | |
| | |
| | | * Returns a bunch of single values for fractional-exclude configuration |
| | | * attribute |
| | | */ |
| | | @SuppressWarnings("unused") |
| | | @DataProvider(name = "testExcludeNightlyProvider") |
| | | private Object[][] testExcludeNightlyProvider() |
| | | { |
| | |
| | | first = false; |
| | | } |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(TestCaseUtils.entryFromLdifString(entryLdif), ENTRY_UUID)); |
| | | } |
| | | |
| | | /** |
| | |
| | | // First string is the class |
| | | Attribute attr = |
| | | Attributes.create(fracCfgValue.toLowerCase(), fracCfgValue + "NewValue"); |
| | | Modification mod = new Modification(ModificationType.REPLACE, attr); |
| | | mods.add(mod); |
| | | mods.add(new Modification(ModificationType.REPLACE, attr)); |
| | | } |
| | | first = false; |
| | | } |
| | |
| | | // Add modification for the special attribute (modified attribute) |
| | | Attribute attr = |
| | | Attributes.create(OPTIONAL_ATTR.toLowerCase(), OPTIONAL_ATTR + "NewValue"); |
| | | Modification mod = new Modification(ModificationType.REPLACE, attr); |
| | | mods.add(mod); |
| | | mods.add(new Modification(ModificationType.REPLACE, attr)); |
| | | |
| | | // Add modification for the synchro attribute (added attribute) |
| | | attr = Attributes.create(SYNCHRO_OPTIONAL_ATTR.toLowerCase(), SYNCHRO_OPTIONAL_ATTR + "Value"); |
| | | mod = new Modification(ModificationType.ADD, attr); |
| | | mods.add(mod); |
| | | mods.add(new Modification(ModificationType.ADD, attr)); |
| | | |
| | | DN entryDn = DN.valueOf(firstBackend ? ENTRY_DN : ENTRY_DN2); |
| | | ModifyMsg modifyMsg = new ModifyMsg(gen.newCSN(), entryDn, mods, ENTRY_UUID); |
| | |
| | | createFakeReplicationDomain(true, readGenIdFromSuffixRootEntry(TEST_ROOT_DN_STRING)); |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | String entryLdif = "dn: displayName=ValueToBeKept," + |
| | | TEST_ROOT_DN_STRING + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "sn: snValue\n" + "cn: cnValue\n" + |
| | | "entryUUID: " + ENTRY_UUID + "\n" + |
| | | "displayName: ValueToBeKept\ndisplayName: displayNameValue\n"; |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: displayName=ValueToBeKept," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "entryUUID: " + ENTRY_UUID, |
| | | "displayName: ValueToBeKept", |
| | | "displayName: displayNameValue"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID)); |
| | | |
| | | /* |
| | | * check that entry has been created and has attribute values from RDN |
| | |
| | | */ |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | entryLdif = "dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," + |
| | | TEST_ROOT_DN_STRING + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "entryUUID: " + ENTRY_UUID2 + "\n" + |
| | | "sn: snValue\n" + "cn: cnValue\n" + |
| | | "displayName: ValueToBeKept\ndisplayName: displayNameValue\n" + |
| | | "description: descriptionValue\ndescription: ValueToBeKeptToo\n"; |
| | | |
| | | entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | entry = TestCaseUtils.makeEntry( |
| | | "dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "entryUUID: " + ENTRY_UUID2, |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "displayName: ValueToBeKept", |
| | | "displayName: displayNameValue", |
| | | "description: descriptionValue", |
| | | "description: ValueToBeKeptToo"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID2, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID2)); |
| | | |
| | | /* |
| | | * check that entry has been created and has attribute values from RDN |
| | |
| | | // create fake domain to send operations |
| | | createFakeReplicationDomain(true, readGenIdFromSuffixRootEntry(TEST_ROOT_DN_STRING)); |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | String entryLdif = "dn: displayName=ValueToBeKept," + |
| | | TEST_ROOT_DN_STRING + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "sn: snValue\n" + "cn: cnValue\n" + |
| | | "entryUUID: " + ENTRY_UUID + "\n" + |
| | | "displayName: ValueToBeKept\ndisplayName: displayNameValue\n" + |
| | | "carLicense: cirLicenseValue\n"; |
| | | |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: displayName=ValueToBeKept," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "entryUUID: " + ENTRY_UUID, |
| | | "displayName: ValueToBeKept", |
| | | "displayName: displayNameValue", |
| | | "carLicense: cirLicenseValue"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID)); |
| | | |
| | | /* |
| | | * check that entry has been created and has attribute values from RDN |
| | |
| | | */ |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | entryLdif = "dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," + |
| | | TEST_ROOT_DN_STRING + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "sn: snValue\n" + "cn: cnValue\n" + |
| | | "entryUUID: " + ENTRY_UUID2 + "\n" + |
| | | "displayName: ValueToBeKept\ndisplayName: displayNameValue\n" + |
| | | "description: descriptionValue\ndescription: ValueToBeKeptToo\n" + |
| | | "carLicense: cirLicenseValue\n"; |
| | | |
| | | entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | entry = TestCaseUtils.makeEntry( |
| | | "dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "entryUUID: " + ENTRY_UUID2, |
| | | "displayName: ValueToBeKept", |
| | | "displayName: displayNameValue", |
| | | "description: descriptionValue", |
| | | "description: ValueToBeKeptToo", |
| | | "carLicense: cirLicenseValue"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID2, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID2)); |
| | | |
| | | /* |
| | | * check that entry has been created and has attribute values from RDN |
| | |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | String entryName = "displayName=ValueToBeKept+description=ValueToBeRemoved," + TEST_ROOT_DN_STRING ; |
| | | String entryLdif = "dn: " + entryName + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "sn: snValue\n" + "cn: cnValue\n" + |
| | | "entryUUID: " + ENTRY_UUID + "\n" + |
| | | "displayName: ValueToBeKept\ndescription: ValueToBeRemoved\n"; |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: " + entryName, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "entryUUID: " + ENTRY_UUID, |
| | | "displayName: ValueToBeKept", |
| | | "description: ValueToBeRemoved"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID)); |
| | | |
| | | // check that entry has been created and has attribute values from RDN |
| | | Entry newEntry = getEntry(entry.getName(), TIMEOUT, true); |
| | |
| | | } |
| | | } |
| | | |
| | | private AddMsg newAddMsg(Entry e, String entryUUID) |
| | | { |
| | | return new AddMsg(gen.newCSN(), e.getName(), entryUUID, null, e.getObjectClassAttribute(), e.getAttributes(), null); |
| | | } |
| | | |
| | | /** |
| | | * Tests modify dn operation on an entry with old RDN containing forbidden |
| | | * attribute by fractional include configuration |
| | |
| | | |
| | | // Perform add operation with forbidden attribute in RDN |
| | | String entryName = "displayName=ValueToBeKept+description=ValueToBeRemoved," + TEST_ROOT_DN_STRING ; |
| | | String entryLdif = "dn: " + entryName + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + "sn: snValue\n" + "cn: cnValue\n" + |
| | | "entryUUID: " + ENTRY_UUID + "\n" + |
| | | "displayName: ValueToBeKept\ndescription: ValueToBeRemoved\n"; |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString(entryLdif); |
| | | // @formatter:off |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: " + entryName, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "sn: snValue", |
| | | "cn: cnValue", |
| | | "entryUUID: " + ENTRY_UUID, |
| | | "displayName: ValueToBeKept", |
| | | "description: ValueToBeRemoved"); |
| | | // @formatter:on |
| | | |
| | | // Create an update message to add an entry. |
| | | AddMsg addMsg = new AddMsg(gen.newCSN(), |
| | | entry.getName(), |
| | | ENTRY_UUID, |
| | | null, |
| | | entry.getObjectClassAttribute(), |
| | | entry.getAttributes(), new ArrayList<Attribute>()); |
| | | |
| | | replicationDomain.publish(addMsg); |
| | | replicationDomain.publish(newAddMsg(entry, ENTRY_UUID)); |
| | | |
| | | // check that entry has been created and has attribute values from RDN |
| | | Entry newEntry = getEntry(entry.getName(), TIMEOUT, true); |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.TreeSet; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.forgerock.opendj.ldap.ResultCode; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.server.config.meta.ReplicationDomainCfgDefn.IsolationPolicy; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.core.ModifyDNOperation; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | |
| | | import org.opends.server.replication.protocol.ModifyDNMsg; |
| | | import org.opends.server.replication.protocol.UpdateMsg; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.forgerock.opendj.ldap.RDN; |
| | | import org.testng.annotations.AfterMethod; |
| | | import org.testng.annotations.BeforeMethod; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | private Entry createAndAddEntry(String commonName) throws Exception |
| | | { |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn: cn=" + commonName + ", " + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" |
| | | + "uid: user.1\n" |
| | | + "description: This is the description for Aaccf Amar.\n" |
| | | + "st: NC\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" |
| | | + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" |
| | | + "l: Rockford\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" |
| | | + "givenName: Aaccf\n" |
| | | + "postalCode: 85762\n" |
| | | + "userPassword: password\n" |
| | | + "initials: AA\n"); |
| | | TestCaseUtils.addEntry(entry); |
| | | return entry; |
| | | // @formatter:off |
| | | return TestCaseUtils.addEntry( |
| | | "dn: cn=" + commonName + ", " + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "street: 17984 Thirteenth Street", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA"); |
| | | // @formatter:on |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | private Entry createParentEntry() throws Exception |
| | | { |
| | | return TestCaseUtils.entryFromLdifString( |
| | | "dn: ou=rpConflict, "+ TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: organizationalUnit\n"); |
| | | return TestCaseUtils.makeEntry( |
| | | "dn: ou=rpConflict, "+ TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: organizationalUnit"); |
| | | } |
| | | |
| | | private Entry createChildEntry() throws Exception |
| | | { |
| | | return TestCaseUtils.entryFromLdifString( |
| | | "dn: cn=child, ou=rpConflict,"+ TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" |
| | | + "uid: user.1\n" |
| | | + "description: This is the description for Aaccf Amar.\n" |
| | | + "st: NC\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" |
| | | + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" |
| | | + "l: Rockford\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" |
| | | + "givenName: Aaccf\n" |
| | | + "postalCode: 85762\n" |
| | | + "userPassword: password\n" |
| | | + "initials: AA\n"); |
| | | // @formatter:off |
| | | return TestCaseUtils.makeEntry( |
| | | "dn: cn=child, ou=rpConflict,"+ TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "street: 17984 Thirteenth Street", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA"); |
| | | // @formatter:on |
| | | } |
| | | |
| | | private void replayMsg(UpdateMsg updateMsg) throws InterruptedException |
| | |
| | | */ |
| | | package org.opends.server.replication.plugin; |
| | | |
| | | import static java.util.concurrent.TimeUnit.*; |
| | | |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.net.SocketTimeoutException; |
| | | import java.util.ArrayList; |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.forgerock.opendj.config.server.ConfigurationChangeListener; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.forgerock.opendj.server.config.server.ReplicationSynchronizationProviderCfg; |
| | | import org.forgerock.opendj.server.config.server.SynchronizationProviderCfg; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.api.SynchronizationProvider; |
| | | import org.opends.server.core.DirectoryServer; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | |
| | | import org.opends.server.replication.server.ReplicationServer; |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.opends.server.util.TestTimer; |
| | | import org.testng.annotations.AfterClass; |
| | |
| | | import org.testng.annotations.DataProvider; |
| | | import org.testng.annotations.Test; |
| | | |
| | | import static java.util.concurrent.TimeUnit.*; |
| | | |
| | | import static org.mockito.Mockito.*; |
| | | import static org.opends.server.util.CollectionUtils.*; |
| | | import static org.testng.Assert.*; |
| | | |
| | | /** |
| | | * Some tests to go through the DS state machine and validate we get the |
| | | * expected status according to the actions we perform. |
| | |
| | | String userEntryUUID = "11111111-1111-1111-1111-111111111111"; |
| | | long curId = userId++; |
| | | String userdn = "uid=user" + curId + "," + EXAMPLE_DN; |
| | | String entryWithUUIDldif = "dn: " + userdn + "\n" + "objectClass: top\n" + |
| | | "objectClass: person\n" + "objectClass: organizationalPerson\n" + |
| | | "objectClass: inetOrgPerson\n" + |
| | | "uid: user" + curId + "\n" + |
| | | "homePhone: 951-245-7634\n" + |
| | | "description: This is the description for Aaccf Amar.\n" + "st: NC\n" + |
| | | "mobile: 027-085-0537\n" + |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street" + |
| | | "$Rockford, NC 85762\n" + "mail: user.1@example.com\n" + |
| | | "cn: Aaccf Amar\n" + "l: Rockford\n" + "pager: 508-763-4246\n" + |
| | | "street: 17984 Thirteenth Street\n" + "telephoneNumber: 216-564-6748\n" + |
| | | "employeeNumber: 1\n" + "sn: Amar\n" + "givenName: Aaccf\n" + |
| | | "postalCode: 85762\n" + "userPassword: password\n" + "initials: AA\n" + |
| | | "entryUUID: " + userEntryUUID + "\n"; |
| | | |
| | | Entry personWithUUIDEntry = null; |
| | | try |
| | | { |
| | | personWithUUIDEntry = TestCaseUtils.entryFromLdifString( |
| | | entryWithUUIDldif); |
| | | // @Formatter:off |
| | | personWithUUIDEntry = TestCaseUtils.makeEntry( |
| | | "dn: " + userdn, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user" + curId + "", |
| | | "homePhone: 951-245-7634", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "mobile: 027-085-0537", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "pager: 508-763-4246", |
| | | "street: 17984 Thirteenth Street", |
| | | "telephoneNumber: 216-564-6748", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA", |
| | | "entryUUID: " + userEntryUUID); |
| | | // @Formatter:on |
| | | } catch (Exception e) |
| | | { |
| | | throw new RuntimeException(e); |
| | |
| | | |
| | | import org.forgerock.i18n.LocalizableMessage; |
| | | import org.forgerock.i18n.slf4j.LocalizedLogger; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.TestCaseUtils; |
| | | import org.opends.server.replication.ReplicationTestCase; |
| | | import org.opends.server.replication.common.CSN; |
| | |
| | | import org.opends.server.replication.service.ReplicationBroker; |
| | | import org.opends.server.tools.LDAPSearch; |
| | | import org.opends.server.types.Attribute; |
| | | import org.forgerock.opendj.ldap.DN; |
| | | import org.opends.server.types.Entry; |
| | | import org.testng.annotations.BeforeClass; |
| | | import org.testng.annotations.Test; |
| | |
| | | |
| | | user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | | user1dn = "uid=user1,ou=People," + baseDnStr; |
| | | String entryWithUUIDldif = "dn: "+ user1dn + "\n" |
| | | + "objectClass: top\n" + "objectClass: person\n" |
| | | + "objectClass: organizationalPerson\n" |
| | | + "objectClass: inetOrgPerson\n" + "uid: user.1\n" |
| | | + "homePhone: 951-245-7634\n" |
| | | + "description: This is the description for Aaccf Amar.\n" + "st: NC\n" |
| | | + "mobile: 027-085-0537\n" |
| | | + "postalAddress: Aaccf Amar$17984 Thirteenth Street" |
| | | + "$Rockford, NC 85762\n" + "mail: user.1@example.com\n" |
| | | + "cn: Aaccf Amar\n" + "l: Rockford\n" + "pager: 508-763-4246\n" |
| | | + "street: 17984 Thirteenth Street\n" |
| | | + "telephoneNumber: 216-564-6748\n" + "employeeNumber: 1\n" |
| | | + "sn: Amar\n" + "givenName: Aaccf\n" + "postalCode: 85762\n" |
| | | + "userPassword: password\n" + "initials: AA\n" |
| | | + "entryUUID: " + user1entryUUID + "\n"; |
| | | |
| | | personWithUUIDEntry = TestCaseUtils.entryFromLdifString(entryWithUUIDldif); |
| | | // @formatter:off |
| | | personWithUUIDEntry = TestCaseUtils.makeEntry( |
| | | "dn: "+ user1dn, |
| | | "objectClass: top", |
| | | "objectClass: person", |
| | | "objectClass: organizationalPerson", |
| | | "objectClass: inetOrgPerson", |
| | | "uid: user.1", |
| | | "homePhone: 951-245-7634", |
| | | "description: This is the description for Aaccf Amar.", |
| | | "st: NC", |
| | | "mobile: 027-085-0537", |
| | | "postalAddress: Aaccf Amar$17984 Thirteenth Street$Rockford, NC 85762", |
| | | "mail: user.1@example.com", |
| | | "cn: Aaccf Amar", |
| | | "l: Rockford", |
| | | "pager: 508-763-4246", |
| | | "street: 17984 Thirteenth Street", |
| | | "telephoneNumber: 216-564-6748", |
| | | "employeeNumber: 1", |
| | | "sn: Amar", |
| | | "givenName: Aaccf", |
| | | "postalCode: 85762", |
| | | "userPassword: password", |
| | | "initials: AA", |
| | | "entryUUID: " + user1entryUUID); |
| | | // @formatter:on |
| | | |
| | | // Create and publish an update message to add an entry. |
| | | return new AddMsg(csn, |
| | |
| | | String user1entryUUID = "33333333-3333-3333-3333-333333333333"; |
| | | String baseUUID = "22222222-2222-2222-2222-222222222222"; |
| | | |
| | | Entry entry = TestCaseUtils.entryFromLdifString( |
| | | "dn: o=example," + TEST_ROOT_DN_STRING + "\n" |
| | | + "objectClass: top\n" |
| | | + "objectClass: domain\n" |
| | | + "entryUUID: " + user1entryUUID + "\n"); |
| | | Entry entry = TestCaseUtils.makeEntry( |
| | | "dn: o=example," + TEST_ROOT_DN_STRING, |
| | | "objectClass: top", |
| | | "objectClass: domain", |
| | | "entryUUID: " + user1entryUUID); |
| | | return new AddMsg(csnGen.newCSN(), EXAMPLE_DN, user1entryUUID, baseUUID, |
| | | entry.getObjectClassAttribute(), entry.getAttributes(), new ArrayList<Attribute>()); |
| | | } |