Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Apr 16, 2019
2 parents c666c54 + 2cdb024 commit a4cab40
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 14 deletions.
Expand Up @@ -44,7 +44,6 @@
import com.evolveum.midpoint.prism.query.*;
import com.evolveum.midpoint.schema.processor.*;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.opends.server.types.Entry;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -271,7 +270,7 @@ public void test003Connection() throws Exception {

Collection<ObjectClassComplexTypeDefinition> objectClasses = parsedSchema.getObjectClassDefinitions();
List<QName> objectClassesToGenerate = ResourceTypeUtil.getSchemaGenerationConstraints(resourceTypeRepoAfter);
if (CollectionUtils.isNotEmpty(objectClassesToGenerate)) {
if (objectClassesToGenerate != null && !objectClasses.isEmpty()) {
assertEquals("Unexpected object classes in generate schema", objectClassesToGenerate.size(), objectClasses.size());
}

Expand Down
Expand Up @@ -245,7 +245,8 @@ public void test030ResourceSchema() throws Exception {

PrismContainerValue<ConnectorConfigurationType> configContainer = resourceType.getConnectorConfiguration().asPrismContainerValue();
display("Configuration container", configContainer);
cc.configure(configContainer, ResourceTypeUtil.getSchemaGenerationConstraints(resourceType), result);
//ResourceTypeUtil.getSchemaGenerationConstraints(resourceType)
cc.configure(configContainer, null, result);

// WHEN
resourceSchema = cc.fetchResourceSchema(result);
Expand Down Expand Up @@ -295,9 +296,9 @@ public void test031ResourceSchemaAccountObjectClass() throws Exception {

// THEN
display("Generated resource schema", resourceSchema);
assertEquals("Unexpected number of definitions", 4, resourceSchema.getDefinitions().size());
assertEquals("Unexpected number of definitions", 1, resourceSchema.getDefinitions().size());

assertEquals("Unexpected number of object class definitions", 4, resourceSchema.getObjectClassDefinitions().size());
assertEquals("Unexpected number of object class definitions", 1, resourceSchema.getObjectClassDefinitions().size());

display("RESOURCE SCHEMA DEFINITION" + resourceSchema.getDefinitions().iterator().next().getTypeName());
}
Expand Down
Expand Up @@ -31,4 +31,5 @@ public interface CounterManager {
void cleanupCounters(String taskOid);
Collection<CounterSepcification> listCounters();
void removeCounter(CounterSepcification counterSpecification);
void resetCounters(String taskOid);
}
Expand Up @@ -112,6 +112,23 @@ public void cleanupCounters(String taskOid) {
}
}

@Override
public void resetCounters(String taskOid) {
Set<CounterKey> keys = countersMap.keySet();

Set<CounterKey> counersToReset = new HashSet<>();
for (CounterKey key : keys) {
if (taskOid.equals(key.oid)) {
counersToReset.add(key);
}
}

for (CounterKey counerToReset : counersToReset) {
CounterSepcification spec = countersMap.get(counerToReset);
spec.setCount(0);
}
}

private CounterSepcification initCleanCounter(CounterKey key, TaskType task, PolicyRuleType policyRule) {
CounterSepcification counterSpec = new CounterSepcification(task, key.policyRuleId, policyRule);
counterSpec.setCounterStart(clock.currentTimeMillis());
Expand Down
Expand Up @@ -16,6 +16,7 @@
package com.evolveum.midpoint.task.quartzimpl.handlers;

import java.util.Comparator;
import java.util.Iterator;
import java.util.List;

import javax.annotation.PostConstruct;
Expand Down Expand Up @@ -113,7 +114,10 @@ public TaskRunResult run(RunningTask task, TaskPartitionDefinitionType taskParti
};

partitions.sort(comparator);
for (TaskPartitionDefinitionType partition : partitions) {

Iterator<TaskPartitionDefinitionType> partitionsIterator = partitions.iterator();
while(partitionsIterator.hasNext()) {
TaskPartitionDefinitionType partition = partitionsIterator.next();
TaskHandler handler = taskManager.getHandler(partition.getHandlerUri());
LOGGER.trace("Starting to execute handler {} defined in partition {}", handler, partition);
TaskRunResult subHandlerResult = handlerExecutor.executeHandler((RunningTaskQuartzImpl) task, partition, handler, opResult);
Expand All @@ -137,8 +141,39 @@ public TaskRunResult run(RunningTask task, TaskPartitionDefinitionType taskParti
LOGGER.error("Unexpected error during cleaning work state: " + e.getMessage(), e);
throw new IllegalStateException(e);
}

if (partitionsIterator.hasNext()) {
counterManager.resetCounters(task.getOid());
}

}

// for (TaskPartitionDefinitionType partition : partitions) {
// TaskHandler handler = taskManager.getHandler(partition.getHandlerUri());
// LOGGER.trace("Starting to execute handler {} defined in partition {}", handler, partition);
// TaskRunResult subHandlerResult = handlerExecutor.executeHandler((RunningTaskQuartzImpl) task, partition, handler, opResult);
// OperationResult subHandlerOpResult = subHandlerResult.getOperationResult();
// opResult.addSubresult(subHandlerOpResult);
// runResult = subHandlerResult;
// runResult.setProgress(task.getProgress());
//
// if (!canContinue(task, subHandlerResult)) {
// break;
// }
//
// if (subHandlerOpResult.isError()) {
// break;
// }
//
// try {
// LOGGER.trace("Cleaning up work state in task {}, workState: {}", task, task.getWorkState());
// cleanupWorkState(task, runResult.getOperationResult());
// } catch (ObjectNotFoundException | SchemaException | ObjectAlreadyExistsException e) {
// LOGGER.error("Unexpected error during cleaning work state: " + e.getMessage(), e);
// throw new IllegalStateException(e);
// }
// }

runResult.setProgress(runResult.getProgress() + 1);
opResult.computeStatusIfUnknown();
counterManager.cleanupCounters(task.getOid());
Expand Down
Expand Up @@ -33,6 +33,7 @@
import com.evolveum.midpoint.xml.ns._public.common.common_3.RoleType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.SynchronizationInformationType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TaskType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType;

/**
* @author katka
Expand All @@ -50,7 +51,7 @@ public class TestThresholdsReconFull extends TestThresholds {

private static final File TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_FILE = new File(TEST_DIR, "task-opendj-reconcile-simulate-execute.xml");
private static final String TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID = "00000000-838f-11e8-93a6-4b1dd0ab58e4";

@Override
protected File getTaskFile() {
return TASK_RECONCILE_OPENDJ_FULL_FILE;
Expand Down Expand Up @@ -109,12 +110,58 @@ public void test610testFullRecon() throws Exception {
Task taskAfter = taskManager.getTaskWithResult(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, result);

assertTaskExecutionStatus(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, TaskExecutionStatus.RUNNABLE);
// assertUsers(getNumberOfUsers() + getProcessedUsers()*2);

assertSynchronizationStatisticsFull(taskAfter);

}


@Test
public void test611testFullRecon() throws Exception {
final String TEST_NAME = "test611testFullRecon";
displayTestTitle(TEST_NAME);
OperationResult result = new OperationResult(TEST_NAME);

openDJController.delete("uid=user10,ou=People,dc=example,dc=com");
openDJController.delete("uid=user11,ou=People,dc=example,dc=com");
openDJController.delete("uid=user12,ou=People,dc=example,dc=com");
openDJController.delete("uid=user13,ou=People,dc=example,dc=com");
openDJController.delete("uid=user14,ou=People,dc=example,dc=com");
openDJController.delete("uid=user15,ou=People,dc=example,dc=com");

//WHEN
displayWhen(TEST_NAME);
OperationResult reconResult = waitForTaskNextRun(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000, false);
assertSuccess(reconResult);

//THEN

Task taskAfter = taskManager.getTaskWithResult(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, result);

assertTaskExecutionStatus(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, TaskExecutionStatus.RUNNABLE);

IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation();
assertEquals(infoType.getTotalFailureCount(), 0);

PrismObject<UserType> user10 = findUserByUsername("user10");
assertNull(user10);

PrismObject<UserType> user11 = findUserByUsername("user11");
assertNull(user11);

PrismObject<UserType> user12 = findUserByUsername("user12");
assertNull(user12);

PrismObject<UserType> user13 = findUserByUsername("user13");
assertNull(user13);

PrismObject<UserType> user14 = findUserByUsername("user14");
assertNull(user14);

PrismObject<UserType> user15 = findUserByUsername("user15");
assertNull(user15);

}


@Override
protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws Exception {
Expand Down
Expand Up @@ -198,7 +198,7 @@
<situation>deleted</situation>
<synchronize>true</synchronize>
<action>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteShadow</handlerUri>
<handlerUri>http://midpoint.evolveum.com/xml/ns/public/model/action-3#deleteFocus</handlerUri>
</action>
</reaction>
<reaction>
Expand Down
Expand Up @@ -25,11 +25,8 @@
</modification>
</policyConstraints>
<policyThreshold>
<!-- <timeInterval> -->
<!-- <interval>PT1H</interval> -->
<!-- </timeInterval> -->
<lowWaterMark>
<count>1</count>
<count>6</count>
</lowWaterMark>
</policyThreshold>
<policyActions>
Expand Down

0 comments on commit a4cab40

Please sign in to comment.