Skip to content

Commit

Permalink
Experimental useProposedShadows for manual connectors.
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jul 31, 2017
1 parent b277d40 commit 31dd2ce
Show file tree
Hide file tree
Showing 19 changed files with 587 additions and 106 deletions.
12 changes: 12 additions & 0 deletions infra/prism/src/main/resources/xml/ns/public/annotation-3.xsd
Expand Up @@ -220,6 +220,18 @@
<xsd:annotation>
<xsd:documentation>
Marks deprecated parts of the schema.
Deprecated parts are supposed to work, but their use is discouraged.
Deprecated functionality may be removed in any future release.
</xsd:documentation>
</xsd:annotation>
</xsd:element>

<xsd:element name="experimental" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
Marks experimental functionality.
Experimental functionality is not stable and it may be changed in any
future release without any warning. Use at your own risk.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -4432,6 +4432,22 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="useProposedShadows" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
If set to true then midPoint will try to create shadows in "proposed" lifecycle
state even before an operation is executed. The proposed shadows may be used
in combination with shadowConstraintsCheck to reduce probability of identifier
conflicts for resources with slow create/rename operations.

This feature is EXPERIMENTAL. Use with care.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.6.1</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="validateSchema" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
Expand Down
6 changes: 6 additions & 0 deletions model/model-intest/pom.xml
Expand Up @@ -210,6 +210,12 @@
<version>3.7-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.evolveum.midpoint.provisioning</groupId>
<artifactId>ucf-impl-builtin</artifactId>
<version>3.7-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.evolveum.polygon</groupId>
<artifactId>connector-ldap</artifactId>
Expand Down
Expand Up @@ -27,6 +27,7 @@
import com.evolveum.midpoint.prism.delta.ReferenceDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.schema.PrismSchema;
import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.internals.InternalsConfig;
Expand Down Expand Up @@ -513,6 +514,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Except
super.initSystem(initTask, initResult);

modelService.postInit(initResult);
ManualConnectorInstance.setRandomDelayRange(0);

// System Configuration
try {
Expand Down
Expand Up @@ -110,6 +110,9 @@ public abstract class AbstractManualResourceTest extends AbstractConfiguredModel

protected static final File RESOURCE_SEMI_MANUAL_DISABLE_FILE = new File(TEST_DIR, "resource-semi-manual-disable.xml");
protected static final String RESOURCE_SEMI_MANUAL_DISABLE_OID = "5e497cb0-5cdb-11e7-9cfe-4bfe0342d181";

protected static final File RESOURCE_SEMI_MANUAL_SLOW_PROPOSED_FILE = new File(TEST_DIR, "resource-semi-manual-slow-proposed.xml");
protected static final String RESOURCE_SEMI_MANUAL_SLOW_PROPOSED_OID = "512d749a-75ff-11e7-8176-8be7fb6f4e45";

protected static final File ROLE_ONE_MANUAL_FILE = new File(TEST_DIR, "role-one-manual.xml");
protected static final String ROLE_ONE_MANUAL_OID = "9149b3ca-5da1-11e7-8e84-130a91fb5876";
Expand All @@ -120,6 +123,9 @@ public abstract class AbstractManualResourceTest extends AbstractConfiguredModel
protected static final File ROLE_ONE_SEMI_MANUAL_DISABLE_FILE = new File(TEST_DIR, "role-one-semi-manual-disable.xml");
protected static final String ROLE_ONE_SEMI_MANUAL_DISABLE_OID = "3b8cb17a-5da2-11e7-b260-a760972b54fb";

protected static final File ROLE_ONE_SEMI_MANUAL_SLOW_PROPOSED_FILE = new File(TEST_DIR, "role-one-semi-manual-slow-proposed.xml");
protected static final String ROLE_ONE_SEMI_MANUAL_SLOW_PROPOSED_OID = "ca7fefc6-75ff-11e7-9833-572f6bf86a81";

public static final QName RESOURCE_ACCOUNT_OBJECTCLASS = new QName(MidPointConstants.NS_RI, "AccountObjectClass");

private static final Trace LOGGER = TraceManager.getTrace(AbstractManualResourceTest.class);
Expand Down Expand Up @@ -2574,7 +2580,7 @@ public void test900ConcurrentConstructions() throws Exception {
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();

final int THREADS = 4;
final int THREADS = getConcurrentTestNumberOfThreads();
final long TIMEOUT = 60000L;

// WHEN
Expand All @@ -2583,7 +2589,7 @@ public void test900ConcurrentConstructions() throws Exception {
for (int i = 0; i < THREADS; i++) {
threads[i] = new Thread(() -> {
try {
Thread.sleep(RND.nextInt(1000)); // Random start delay
Thread.sleep(RND.nextInt(getConcurrentTestRandomStartDelayRange())); // Random start delay
LOGGER.info("{} starting", Thread.currentThread().getName());
login(userAdministrator);
Task localTask = createTask(TEST_NAME + ".local");
Expand All @@ -2610,6 +2616,14 @@ public void test900ConcurrentConstructions() throws Exception {
assertEquals("Wrong # of links", 1, barbossa.asObjectable().getLinkRef().size());
}

protected int getConcurrentTestNumberOfThreads() {
return 4;
}

protected int getConcurrentTestRandomStartDelayRange() {
return 1000;
}

protected void backingStoreProvisionWill(String interest) throws IOException {
// nothing to do here
}
Expand Down
Expand Up @@ -19,57 +19,29 @@
*/
package com.evolveum.midpoint.model.intest.manual;

import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertNull;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import javax.xml.namespace.QName;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.AssertJUnit;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import org.w3c.dom.Element;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.PointInTimeType;
import com.evolveum.midpoint.schema.SelectorOptions;
import com.evolveum.midpoint.schema.constants.MidPointConstants;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.exception.CommunicationException;
import com.evolveum.midpoint.util.exception.ConfigurationException;
import com.evolveum.midpoint.util.exception.ExpressionEvaluationException;
import com.evolveum.midpoint.util.exception.ObjectNotFoundException;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.util.exception.SecurityViolationException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowKindType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;

/**
* @author Radovan Semancik
Expand Down
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
*
*/
package com.evolveum.midpoint.model.intest.manual;

import java.io.File;

import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.annotation.DirtiesContext.ClassMode;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.Listeners;

import com.evolveum.midpoint.provisioning.ucf.impl.builtin.ManualConnectorInstance;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;

/**
* Tests a slow semi manual resource with the use of proposed shadows.
* The resource is "slow" in a way that it takes approx. a second to process a ticket.
* This may cause all sorts of race conditions.
*
* @author Radovan Semancik
*/
@ContextConfiguration(locations = {"classpath:ctx-model-intest-test-main.xml"})
@DirtiesContext(classMode = ClassMode.AFTER_CLASS)
@Listeners({ com.evolveum.midpoint.tools.testng.AlphabeticalMethodInterceptor.class })
public class TestSemiManualSlowProposed extends TestSemiManual {

private static final Trace LOGGER = TraceManager.getTrace(TestSemiManualSlowProposed.class);

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
initManualConnector();
}

@Override
protected String getResourceOid() {
return RESOURCE_SEMI_MANUAL_SLOW_PROPOSED_OID;
}

@Override
protected File getResourceFile() {
return RESOURCE_SEMI_MANUAL_SLOW_PROPOSED_FILE;
}

@Override
protected String getRoleOneOid() {
return ROLE_ONE_SEMI_MANUAL_SLOW_PROPOSED_OID;
}

@Override
protected File getRoleOneFile() {
return ROLE_ONE_SEMI_MANUAL_SLOW_PROPOSED_FILE;
}

// Make the test fast ...
@Override
protected int getConcurrentTestRandomStartDelayRange() {
return 300;
}

// ... and intense ...
@Override
protected int getConcurrentTestNumberOfThreads() {
return 10;
}

// TODO: .. and make the resource slow.
private void initManualConnector() {
ManualConnectorInstance.setRandomDelayRange(1000);
}

}
2 changes: 1 addition & 1 deletion model/model-intest/src/test/resources/logback-test.xml
Expand Up @@ -77,7 +77,7 @@
<logger name="com.evolveum.midpoint.model.impl.util" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync" level="DEBUG" />
<logger name="com.evolveum.midpoint.model.impl.sync.CorrelationConfirmationEvaluator" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning" level="TRACE" />
<logger name="com.evolveum.midpoint.provisioning.impl.ResourceManager" level="DEBUG" />
<logger name="com.evolveum.midpoint.provisioning.consistency" level="DEBUG" />
<logger name="com.evolveum.midpoint.expression" level="DEBUG" />
Expand Down

0 comments on commit 31dd2ce

Please sign in to comment.