FractionalReplicationTest.java revision 9aa1482c49865483f798f91ef7d16f03cc3ec811
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License, Version 1.0 only 1N/A * (the "License"). You may not use this file except in compliance 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2009-2010 Sun Microsystems, Inc. 1N/A * Portions Copyright 2011-2015 ForgeRock AS 1N/A * Various tests around fractional replication 1N/A /** Represents the real domain to test (replays and filters) */ 1N/A /** The domain used to send updates to the real domain */ 1N/A /** Ids of servers */ 1N/A private static final int DS1_ID =
1;
// fractional domain 1N/A private static final int DS2_ID =
2;
// fake domain 1N/A private static final int RS_ID =
91;
// replication server 1N/A /** Fractional mode */ 1N/A /** The tracer object for the debug logger */ 1N/A /** Number of seconds before generating an error if some conditions not met */ 1N/A /** Uuid of the manipulated entry */ 1N/A "11111111-1111-1111-1111-111111111111";
1N/A "22222222-2222-2222-2222-222222222222";
1N/A "33333333-3333-3333-3333-333333333333";
1N/A /** Dn of the manipulated entry */ 1N/A * Optional attribute not part of concerned attributes of the fractional 1N/A * configuration during tests. It should not be impacted by fractional 1N/A * Optional attribute used as synchronization attribute to know when the 1N/A * modify operation has been processed (used as add new attribute in the 1N/A * modify operation) It may or may not be part of the filtered attributes, 1N/A * depending on the fractional test mode : exclusive or inclusive 1N/A /** Second test backend */ * Before starting the tests configure some stuff * Returns a bunch of single values for fractional-exclude configuration {
1,
new String[] {
"inetOrgPerson",
"displayName"}}
* Returns a bunch of single values for fractional-exclude configuration {
1,
new String[] {
"INETORGPERSON",
"DISPLAYNAME"}},
{
2,
new String[] {
"inetOrgPerson",
"2.16.840.1.113730.3.1.241"}},
{
3,
new String[] {
"2.16.840.1.113730.3.2.2",
"displayName"}},
{
4,
new String[] {
"2.16.840.1.113730.3.2.2",
"2.16.840.1.113730.3.1.241"}},
{
5,
new String[] {
"inetOrgPerson",
"displayName",
"carLicense"}},
{
6,
new String[] {
"organizationalPerson",
"title",
"postalCode"}},
{
7,
new String[] {
"2.5.6.7",
"title",
"postalCode"}},
{
8,
new String[] {
"2.5.6.7",
"TITLE",
"2.5.4.17"}},
{
9,
new String[] {
"2.5.6.7",
"2.5.4.12",
"2.5.4.17"}},
{
10,
new String[] {
"*",
"roomNumber"}},
{
11,
new String[] {
"*",
"0.9.2342.19200300.100.1.6"}},
{
12,
new String[] {
"*",
"postOfficeBox",
"0.9.2342.19200300.100.1.6"}},
{
13,
new String[] {
"*",
"2.5.4.18",
"0.9.2342.19200300.100.1.6"}}
* Calls the testExclude test with a small set of data, for precommit test * Calls the testExclude test with a larger set of data, for nightly tests * Performs Add and Modify operations including attributes that are excluded * with the passed fractional configuration and checks that these attributes * are not part of the concerned entry. * Note: testProviderLineId just here to know what is the provider problematic * line if the test fail: prevent some display like: * [testng] parameter[0]: [Ljava.lang.String;@151e824 * [testng] parameter[0]: 6 * [testng] parameter[1]: [Ljava.lang.String;@151e824 // create fake domain to send operations // check that entry has been created and that it does not contain // perform modify operation (modify forbidden attributes + // modify authorized attribute (not a no op)) // Wait for modify operation being replayed and // check that entry does not contain forbidden attributes * Returns a bunch of single values for fractional-include configuration {
1,
new String[] {
"inetOrgPerson",
"displayName"}}
* Returns a bunch of single values for fractional-include configuration {
1,
new String[] {
"INETORGPERSON",
"DISPLAYNAME"}},
{
2,
new String[] {
"inetOrgPerson",
"2.16.840.1.113730.3.1.241"}},
{
3,
new String[] {
"2.16.840.1.113730.3.2.2",
"displayName"}},
{
4,
new String[] {
"2.16.840.1.113730.3.2.2",
"2.16.840.1.113730.3.1.241"}},
{
5,
new String[] {
"inetOrgPerson",
"displayName",
"carLicense"}},
{
6,
new String[] {
"organizationalPerson",
"title",
"postalCode"}},
{
7,
new String[] {
"2.5.6.7",
"title",
"postalCode"}},
{
8,
new String[] {
"2.5.6.7",
"TITLE",
"2.5.4.17"}},
{
9,
new String[] {
"2.5.6.7",
"2.5.4.12",
"2.5.4.17"}},
{
10,
new String[] {
"*",
"roomNumber"}},
{
11,
new String[] {
"*",
"0.9.2342.19200300.100.1.6"}},
{
12,
new String[] {
"*",
"postOfficeBox",
"0.9.2342.19200300.100.1.6"}},
{
13,
new String[] {
"*",
"2.5.4.18",
"0.9.2342.19200300.100.1.6"}}
* Calls the testInclude test with a small set of data, for precommit test * Calls the testInclude test with a larger set of data, for nightly tests * Performs Add and Modify operations including attributes that are excluded * with the passed fractional configuration and checks that these attributes * are not part of the concerned entry. * Note: testProviderLineId just here to know what is the provider problematic * line if the test fail: prevent some display like: * [testng] parameter[0]: [Ljava.lang.String;@151e824 * [testng] parameter[0]: 6 * [testng] parameter[1]: [Ljava.lang.String;@151e824 // create fake domain to send operations // check that entry has been created and that it does not contain // perform modify operation (modify forbidden attributes + // modify authorized attribute (not a no op)) * Creates connects (to the RS) and starts the fake replication domain * Use the passed generation id. // Check connected server port * Creates a fractional domain with the passed configuration. * Before that, initializes the backend with the root entry and if requested * with the correct fractional configuration in it // For inclusive mode, we use an attribute that is added in the modify // operation to know when the modify operation has been played. The added // attribute can only be part of the include config to be taken into account fail(
"Unexpected fractional mode.");
* Create a root entry with potentially with fractional configuration before domain creation // Create base entry with correct fractional config // Add first backend top entry "objectClass: organization\n" +
// First string is the class // Other strings are attributes // Add second backend top entry "objectClass: domain\n" +
* Create the domain with the passed fractional configuration // Create a config entry ldif, matching passed settings "objectClass: ds-cfg-replication-domain\n" +
"cn: " +
testName +
"\n" +
"ds-cfg-server-id: " +
DS1_ID +
"\n";
// First string is the class // Other strings are attributes // Add the config entry to create the replicated domain * Creates a new ReplicationServer. * Send the AddMsg (from the fake replication domain) for the passed entry * containing the attributes defined in the passed fractional configuration "objectClass: person\n" +
"objectClass: organizationalPerson\n";
"sn: snValue\n" +
"cn: cnValue\n" +
// Add attributes concerned by fractional configuration // First string is the class // Create an update message to add an entry. * Send (from the fake replication domain) a ModifyMsg for the passed entry * modifying attributes defined in the passed fractional configuration // Create modifications on the fractional attributes // First string is the class // Add modification for the special attribute (modified attribute) // Add modification for the synchro attribute (added attribute) * Utility method : Add an entry in the database * Check that the just added entry (newEntry) meets the fractional criteria * regarding the passed configuration : mode and attributes to be filtered/not // Is the added entry of the expected object class ? // Go through each interesting attribute and check it is present or not // according to the fractional mode // Exclude mode: attributes should not be there, but OPTIONAL_ATTR // Include mode: attributes should be there, but OPTIONAL_ATTR fail(
"Unexpected fractional mode.");
* Check that the just modified entry (entry) meets the fractional criteria * regarding the passed configuration : mode and attributes to be filtered/not // Is the added entry of the expected object class ? // Go through each interesting attribute and check it has been modifed or // not according to the fractional mode // Exclude mode: attributes should not be there, but OPTIONAL_ATTR // attribute should have been modified // Include mode: attributes should have been modified, but OPTIONAL_ATTR // attribute should not be there fail(
"Unexpected fractional mode.");
// In both modes, SYNCHRO_OPTIONAL_ATTR attribute should have been added * Check that the provided entry has a single value attribute which has the * expected attribute value * Returns a bunch of single values for fractional configuration {
1,
true,
new String[] {
"inetOrgPerson",
"displayName"}}
* Returns a bunch of single values for fractional configuration {
1,
false,
new String[] {
"inetOrgPerson",
"displayName"}}
* Calls the testInitWithFullUpdateExclude test with a small set of data, for precommit test * Calls the testInitWithFullUpdateExclude test with a larger set of data, for nightly tests * Configures a domain which is not fractional to fractional exclusive, * then emulates an online full update to initialize the fractional domain and * Note: testProviderLineId just here to know what is the provider problematic * line if the test fail: prevent some display like: * [testng] parameter[0]: [Ljava.lang.String;@151e824 * [testng] parameter[0]: 6 * [testng] parameter[1]: [Ljava.lang.String;@151e824 // We need a backend with a real configuration in cn=config as at import time // the real domain will check for backend existence in cn=config. So we use // dc=example,dc=com for this particular test. * Create replication server and connect fractional domain to it then fake // create fractional domain with the passed fractional configuration // without initializing the backend // The domain should go in bad gen as backend is not initialized with // create fake domain to perform the full update * Create the LDIF that will be used to initialize the domain from the * fake one. Initialize the fake domain with it. "objectClass: domain\n" +
// First string is the class // Other strings are attributes "objectClass: organization\n" +
"objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"uid: 1\n" +
"entryUUID: " +
// Add attributes concerned by fractional configuration // First string is the class // Perform full update from fake domain to fractional domain * Check fractional domain is operational and that filtering has been done // The domain should go back in normal status // check that entry has been created and that it does not contain // perform modify operation (modify forbidden attributes + // modify authorized attribute (not a no op)) // Wait for modify operation being replayed and // check that entry does not contain forbidden attributes * Wait for the passed domain to have the desired status or fail if timeout debugInfo(
"waitForDomainStatus: expected replication " +
"domain status obtained after " + (
toWait-
nSec) +
" second(s).");
* Returns a bunch of single values for fractional configuration {
1,
true,
new String[] {
"inetOrgPerson",
"displayName"}}
* Returns a bunch of single values for fractional configuration {
1,
false,
new String[] {
"inetOrgPerson",
"displayName"}}
* Calls the testInitWithFullUpdateExclude test with a small set of data, for precommit test * Calls the testInitWithFullUpdateExclude test with a larger set of data, for nightly tests * Configures a domain which is not fractional to fractional inclusive, * then emulates an online full update to initialize the fractional domain and * Note: testProviderLineId just here to know what is the provider problematic * line if the test fail: prevent some display like: * [testng] parameter[0]: [Ljava.lang.String;@151e824 * [testng] parameter[0]: 6 * [testng] parameter[1]: [Ljava.lang.String;@151e824 // We need a backend with a real configuration in cn=config as at import time // the real domain will check for backend existence in cn=config. So we use // dc=example,dc=com for this particular test. * Create replication server and connect fractional domain to it then fake // create fractional domain with the passed fractional configuration // without initializing the backend // The domain should go in bad gen as backend is not initialized with // create fake domain to perform the full update * Create the LDIF that will be used to initialize the domain from the * fake one. Initialize the fake domain with it. "objectClass: domain\n" +
// First string is the class // Other strings are attributes "objectClass: organization\n" +
"objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"uid: 1\n" +
"entryUUID: " +
// Add attributes concerned by fractional configuration // First string is the class // Perform full update from fake domain to fractional domain * Check fractional domain is operational and that filtering has been done // The domain should go back in normal status // check that entry has been created and that it does not contain // perform modify operation (modify forbidden attributes + // modify authorized attribute (not a no op)) * Tests an add operation on an entry with RDN containing forbidden attribute * by fractional exclude configuration "displayName",
"description");
// create fake domain to send operations // Perform add operation with forbidden attribute in RDN "objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"displayName: ValueToBeKept\ndisplayName: displayNameValue\n";
// Create an update message to add an entry. * check that entry has been created and has attribute values from RDN * Now perform same test, but with 2 forbidden attributes in RDN, using '+' // Perform add operation with forbidden attribute in RDN entryLdif =
"dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," +
"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";
// Create an update message to add an entry. * check that entry has been created and has attribute values from RDN * Tests an add operation on an entry with RDN containing forbidden attribute * by fractional include configuration // create fake domain to send operations // Perform add operation with forbidden attribute in RDN "objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"displayName: ValueToBeKept\ndisplayName: displayNameValue\n" +
"carLicense: cirLicenseValue\n";
// Create an update message to add an entry. * check that entry has been created and has attribute values from RDN * Now perform same test, but with 2 forbidden attributes in RDN, using '+' // Perform add operation with forbidden attribute in RDN entryLdif =
"dn: displayName=ValueToBeKept+description=ValueToBeKeptToo," +
"objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"displayName: ValueToBeKept\ndisplayName: displayNameValue\n" +
"description: descriptionValue\ndescription: ValueToBeKeptToo\n" +
"carLicense: cirLicenseValue\n";
// Create an update message to add an entry. * check that entry has been created and has attribute values from RDN * Tests modify dn operation on an entry with old RDN containing forbidden * attribute by fractional exclude configuration "displayName",
"description");
// create fake domain to send operations // Perform add operation with forbidden attribute in RDN "objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"displayName: ValueToBeKept\ndescription: ValueToBeRemoved\n";
// Create an update message to add an entry. // check that entry has been created and has attribute values from RDN * Perform modify dn operation by renaming the entry keeping only one of * the forbidden attributes // Create modify dn message to modify the entry. "displayName=ValueToBeKept",
null);
* check that entry has been renamed and has only attribute left in the * Tests modify dn operation on an entry with old RDN containing forbidden * attribute by fractional include configuration // create fake domain to send operations // Perform add operation with forbidden attribute in RDN "objectClass: person\n" +
"objectClass: organizationalPerson\n" +
"objectClass: inetOrgPerson\n" +
"sn: snValue\n" +
"cn: cnValue\n" +
"displayName: ValueToBeKept\ndescription: ValueToBeRemoved\n";
// Create an update message to add an entry. // check that entry has been created and has attribute values from RDN * Perform modify dn operation by renaming the entry keeping only one of * the forbidden attributes // Create modify dn message to modify the entry. "displayName=ValueToBeKept",
null);
* check that entry has been renamed and has only attribute left in the