Skip to content

Commit

Permalink
Provisioning operation grouping implementation in progress (MID-4347)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Jan 3, 2018
1 parent 0175669 commit a2992f1
Show file tree
Hide file tree
Showing 19 changed files with 3,602 additions and 2,705 deletions.
Expand Up @@ -15,6 +15,8 @@
*/
package com.evolveum.midpoint.schema.result;

import com.evolveum.midpoint.util.ShortDumpable;

/**
* Primary goal of this class is to support asynchronous operations.
* The call to operation may return even if the resource operation
Expand All @@ -30,7 +32,7 @@
* @author semancik
*
*/
public class AsynchronousOperationResult {
public class AsynchronousOperationResult implements ShortDumpable {

private OperationResult operationResult;

Expand All @@ -51,4 +53,11 @@ public static AsynchronousOperationResult wrap(OperationResult result) {
public boolean isInProgress() {
return operationResult.isInProgress();
}

@Override
public void shortDump(StringBuilder sb) {
if (operationResult != null) {
sb.append(operationResult.getStatus());
}
}
}
Expand Up @@ -4884,6 +4884,35 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="operationGroupingInterval" type="xsd:duration" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
<p>
Turns on operation grouping feature and specifies a grouping interval.
Operation grouping is feature that groups several operations on a resource
into a single operation. This can be used in case midPoint creates a lot of
small operations. But we want to group all of them into a single big operation.
This means that small operations are deplayed for a specified interval. Then
all the operations are grouped into a single operation and executed at once.
This approach slightly delays the operations. But it may be huge advantage for
resources where the operations are constly (manual resources, slow resources).
</p>
<p>
This parameter specifies a maximum interval between the operation is requested
and the operation is started. First operation will be postponed for the specified
interval. When the interval is over the operation will be executed. All the
operations that have accumulated during the interval will be grouped together
and executed.
</p>
<p>
Note: provisioning propagation task must be running to execute the operations.
</p>
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7.1</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="validateSchema" type="xsd:boolean" minOccurs="0" default="false">
<xsd:annotation>
<xsd:documentation>
Expand All @@ -4908,7 +4937,14 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="postpone" type="xsd:boolean" minOccurs="0" default="true"/>
<xsd:element name="postpone" type="xsd:boolean" minOccurs="0" default="true">
<xsd:annotation>
<xsd:documentation>
Postpone the operation in case that an error is encountered. The operation
will be re-tried later (consistency mechanism).
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="discovery" type="xsd:boolean" minOccurs="0" default="true"/>
<xsd:element name="connectorErrorCriticality" type="tns:ErrorSelectorType" minOccurs="0">
<xsd:annotation>
Expand Down

Large diffs are not rendered by default.

@@ -0,0 +1,153 @@
/*
* Copyright (c) 2010-2018 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 static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertFalse;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;

import java.io.File;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

import javax.xml.bind.JAXBElement;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.namespace.QName;

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.common.refinery.RefinedResourceSchemaImpl;
import com.evolveum.midpoint.model.intest.AbstractConfiguredModelIntegrationTest;
import com.evolveum.midpoint.prism.Containerable;
import com.evolveum.midpoint.prism.Item;
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerDefinition;
import com.evolveum.midpoint.prism.PrismContext;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.util.PrismTestUtil;
import com.evolveum.midpoint.schema.CapabilityUtil;
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.internals.InternalsConfig;
import com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceAttributeDefinition;
import com.evolveum.midpoint.schema.processor.ResourceSchema;
import com.evolveum.midpoint.schema.processor.ResourceSchemaImpl;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.schema.util.ObjectTypeUtil;
import com.evolveum.midpoint.schema.util.ResourceTypeUtil;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.test.IntegrationTestTools;
import com.evolveum.midpoint.test.util.ParallelTestThread;
import com.evolveum.midpoint.test.util.TestUtil;
import com.evolveum.midpoint.util.exception.SchemaException;
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.ActivationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentPolicyEnforcementType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CachingMetadataType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilitiesType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CapabilityCollectionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConflictResolutionActionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConflictResolutionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ConnectorType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ExpressionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationExecutionStatusType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.PendingOperationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceAttributeDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
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.SystemConfigurationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.XmlSchemaType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.AbstractWriteCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ActivationCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.CreateCapabilityType;
import com.evolveum.midpoint.xml.ns._public.resource.capabilities_3.ReadCapabilityType;
import com.evolveum.prism.xml.ns._public.types_3.ChangeTypeType;
import com.evolveum.prism.xml.ns._public.types_3.ItemDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType;
import com.evolveum.prism.xml.ns._public.types_3.ObjectType;
import com.evolveum.prism.xml.ns._public.types_3.ProtectedStringType;
import com.evolveum.prism.xml.ns._public.types_3.RawType;

/**
* @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 abstract class AbstractGroupingManualResourceTest extends AbstractManualResourceTest {

protected static final File TEST_DIR = new File("src/test/resources/manual/");

protected static final File RESOURCE_MANUAL_GROUPING_FILE = new File(TEST_DIR, "resource-manual-grouping.xml");
protected static final String RESOURCE_MANUAL_GROUPING_OID = "a6e228a0-f092-11e7-b5bc-579f2e54e15c";

protected static final File ROLE_ONE_MANUAL_GROUPING_FILE = new File(TEST_DIR, "role-one-manual-grouping.xml");
protected static final String ROLE_ONE_MANUAL_GROUPING_OID = "bc586500-f092-11e7-9cda-f7cd4203a755";

protected static final File ROLE_TWO_MANUAL_GROUPING_FILE = new File(TEST_DIR, "role-two-manual-grouping.xml");
protected static final String ROLE_TWO_MANUAL_GROUPING_OID = "c9de1300-f092-11e7-8c5f-3ff8ea609a1d";

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


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

// Grouping execution. The operation is delayed for a while.
@Override
protected PendingOperationExecutionStatusType getExpectedExecutionStatus(PendingOperationExecutionStatusType executionStage) {
return executionStage;
}

@Override
protected OperationResultStatusType getExpectedResultStatus(PendingOperationExecutionStatusType executionStage) {
if (executionStage == PendingOperationExecutionStatusType.EXECUTION_PENDING) {
return null;
} if (executionStage == PendingOperationExecutionStatusType.EXECUTING) {
return OperationResultStatusType.IN_PROGRESS;
}
return null;
}

}

0 comments on commit a2992f1

Please sign in to comment.