From ed8e7b8652de43e9879f6ccc15a730c1db25949a Mon Sep 17 00:00:00 2001 From: Pavol Mederly Date: Fri, 6 Mar 2020 01:19:23 +0100 Subject: [PATCH] Adapt and fix TestThresholds et al These tests were adapted to recent changes in counting of objects in various synchronization situations (see the commit for MID-5406). Also, treatment of disabled objects was fixed: the policy rule was not quite correct and so was LDIF import of changes. --- .../xml/ns/public/common/common-core-3.xsd | 2 +- .../midpoint/test/ldap/OpenDJController.java | 32 ++++--- .../model/impl/lens/LensElementContext.java | 36 ++------ .../model/impl/lens/LensFocusContext.java | 5 +- .../impl/lens/LensProjectionContext.java | 14 +-- .../intest/mapping/TestMappingInbound.java | 2 +- .../test/AbstractModelIntegrationTest.java | 4 +- .../test/AbstractIntegrationTest.java | 4 +- .../midpoint/task/api/TaskManager.java | 2 +- .../quartzimpl/TaskManagerQuartzImpl.java | 2 +- .../testing/story/TestThresholds.java | 87 ++++++++++++++----- .../story/TestThresholdsLiveSyncFull.java | 24 +++-- .../story/TestThresholdsLiveSyncSimulate.java | 21 +++-- .../story/TestThresholdsReconFull.java | 41 +++++---- .../story/TestThresholdsReconSimulate.java | 35 +++++--- .../role-policy-rule-change-activation.xml | 4 +- .../thresholds/task-opendj-livesync-full.xml | 3 +- .../task-opendj-livesync-simulate.xml | 1 - .../thresholds/task-opendj-reconcile-full.xml | 9 +- ...task-opendj-reconcile-simulate-execute.xml | 1 - .../task-opendj-reconcile-simulate.xml | 1 - 21 files changed, 193 insertions(+), 137 deletions(-) diff --git a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd index b892d733c21..7534e40b98b 100755 --- a/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd +++ b/infra/schema/src/main/resources/xml/ns/public/common/common-core-3.xsd @@ -5553,7 +5553,7 @@ AssignmentType.target AssignmentType.target.help - tns:FocusType + tns:AssignmentHolderType diff --git a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java index 47f01b7bcd6..6195f33bdcf 100755 --- a/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java +++ b/infra/test-util/src/main/java/com/evolveum/midpoint/test/ldap/OpenDJController.java @@ -26,6 +26,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.Validate; +import org.jetbrains.annotations.NotNull; import org.opends.messages.Message; import org.opends.messages.MessageBuilder; import org.opends.server.config.ConfigException; @@ -883,28 +884,37 @@ public ChangeRecordEntry executeLdifChange(File file) throws IOException, LDIFEx LDIFReader ldifReader = new LDIFReader(importConfig); ChangeRecordEntry entry = ldifReader.readChangeRecord(false); - ModifyOperation modifyOperation = getInternalConnection() - .processModify((ModifyChangeRecordEntry) entry); + return executeChangeInternal(entry); + } + + @NotNull + private ChangeRecordEntry executeChangeInternal(ChangeRecordEntry entry) { + ModifyOperation modifyOperation = getInternalConnection().processModify((ModifyChangeRecordEntry) entry); if (ResultCode.SUCCESS != modifyOperation.getResultCode()) { - throw new RuntimeException("LDAP operation error: "+modifyOperation.getResultCode()+": "+modifyOperation.getErrorMessage()); + throw new RuntimeException("LDAP operation error: " + modifyOperation.getResultCode() + ": " + modifyOperation.getErrorMessage()); } return entry; } + public void executeLdifChanges(File file) throws IOException, LDIFException { + LDIFImportConfig importConfig = new LDIFImportConfig(file.getPath()); + LDIFReader ldifReader = new LDIFReader(importConfig); + for (;;) { + ChangeRecordEntry entry = ldifReader.readChangeRecord(false); + if (entry == null) { + break; + } + executeChangeInternal(entry); + } + } + public ChangeRecordEntry executeLdifChange(String ldif) throws IOException, LDIFException { InputStream ldifInputStream = IOUtils.toInputStream(ldif, StandardCharsets.UTF_8); LDIFImportConfig importConfig = new LDIFImportConfig(ldifInputStream); LDIFReader ldifReader = new LDIFReader(importConfig); ChangeRecordEntry entry = ldifReader.readChangeRecord(false); - - ModifyOperation modifyOperation = getInternalConnection() - .processModify((ModifyChangeRecordEntry) entry); - - if (ResultCode.SUCCESS != modifyOperation.getResultCode()) { - throw new RuntimeException("LDAP operation error: "+modifyOperation.getResultCode()+": "+modifyOperation.getErrorMessage()); - } - return entry; + return executeChangeInternal(entry); } public ChangeRecordEntry modifyReplace(String entryDn, String attributeName, String value) throws IOException, LDIFException { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java index ba5355cdc3e..f9e45fa0853 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensElementContext.java @@ -339,45 +339,25 @@ public void addToPendingAssignmentPolicyStateModifications(@NotNull AssignmentTy pendingAssignmentPolicyStateModifications.computeIfAbsent(spec, k -> new ArrayList<>()).add(modification); } - public boolean isAdd() { - if (ObjectDelta.isAdd(getPrimaryDelta())) { - return true; - } - if (ObjectDelta.isAdd(getSecondaryDelta())) { - return true; - } - return false; - } + public abstract boolean isAdd(); public boolean isModify() { - if (ObjectDelta.isModify(getPrimaryDelta())) { - return true; - } - if (ObjectDelta.isModify(getSecondaryDelta())) { - return true; - } - return false; + // TODO I'm not sure why isModify checks both primary and secondary deltas for focus context, while + // isAdd and isDelete care only for the primary delta. + return ObjectDelta.isModify(getPrimaryDelta()) || ObjectDelta.isModify(getSecondaryDelta()); } - public boolean isDelete() { - if (ObjectDelta.isDelete(getPrimaryDelta())) { - return true; - } - if (ObjectDelta.isDelete(getSecondaryDelta())) { - return true; - } - return false; - } + public abstract boolean isDelete(); @NotNull public SimpleOperationName getOperation() { if (isAdd()) { return SimpleOperationName.ADD; - } - if (isDelete()) { + } else if (isDelete()) { return SimpleOperationName.DELETE; + } else { + return SimpleOperationName.MODIFY; } - return SimpleOperationName.MODIFY; } @NotNull diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java index 30ef72357de..58a13b23884 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensFocusContext.java @@ -102,14 +102,13 @@ public ObjectDelta getProjectionWavePrimaryDelta() throws SchemaException { } public boolean isDelete() { - return getPrimaryDelta() != null && getPrimaryDelta().isDelete(); + return ObjectDelta.isDelete(getPrimaryDelta()); } public boolean isAdd() { - return getPrimaryDelta() != null && getPrimaryDelta().isAdd(); + return ObjectDelta.isAdd(getPrimaryDelta()); } - @Override public ObjectDelta getSecondaryDelta() { try { diff --git a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java index 32f2f8437f3..f6403ba90d3 100644 --- a/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java +++ b/model/model-impl/src/main/java/com/evolveum/midpoint/model/impl/lens/LensProjectionContext.java @@ -406,10 +406,11 @@ public void addAccountSyncDelta(ObjectDelta delta) throws SchemaExce public boolean isAdd() { if (synchronizationPolicyDecision == SynchronizationPolicyDecision.ADD) { return true; - } else if (synchronizationPolicyDecision != null){ + } else if (synchronizationPolicyDecision != null) { return false; + } else { + return ObjectDelta.isAdd(getPrimaryDelta()) || ObjectDelta.isAdd(getSecondaryDelta()); } - return super.isAdd(); } public boolean isModify() { @@ -417,8 +418,9 @@ public boolean isModify() { return true; } else if (synchronizationPolicyDecision != null) { return false; + } else { + return super.isModify(); } - return super.isModify(); } public boolean isDelete() { @@ -426,11 +428,9 @@ public boolean isDelete() { return true; } else if (synchronizationPolicyDecision != null) { return false; + } else { + return ObjectDelta.isDelete(syncDelta) || ObjectDelta.isDelete(getPrimaryDelta()) || ObjectDelta.isDelete(getSecondaryDelta()); } - if (syncDelta != null && syncDelta.isDelete()) { - return true; - } - return super.isDelete(); } public ResourceType getResource() { diff --git a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java index 7ee0521a493..f991e41a4ef 100644 --- a/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java +++ b/model/model-intest/src/test/java/com/evolveum/midpoint/model/intest/mapping/TestMappingInbound.java @@ -378,7 +378,7 @@ public void test300DeleteDummyTeaGreenAccountMancomb() throws Exception { display("Dummy (tea green) resource", getDummyResource(RESOURCE_DUMMY_TEA_GREEN_NAME).debugDump()); // Make sure we have steady state - waitForTaskResume(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 20000); + resumeTaskAndWaitForNextFinish(TASK_LIVE_SYNC_DUMMY_TEA_GREEN_OID, false, 20000); waitForSyncTaskNextRun(); // THEN diff --git a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java index 2f92537f920..3c1f8e7e215 100644 --- a/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java +++ b/model/model-test/src/main/java/com/evolveum/midpoint/model/test/AbstractModelIntegrationTest.java @@ -3519,7 +3519,7 @@ private static OperationResult getSubresult(OperationResult result, boolean chec return result; } - protected OperationResult waitForTaskResume(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { + protected OperationResult resumeTaskAndWaitForNextFinish(final String taskOid, final boolean checkSubresult, final int timeout) throws Exception { final OperationResult waitResult = new OperationResult(AbstractIntegrationTest.class + ".waitForTaskResume"); Task origTask = taskManager.getTaskWithResult(taskOid, waitResult); @@ -3569,7 +3569,7 @@ public void timeout() { } } }; - IntegrationTestTools.waitFor("Waiting for task " + origTask + " resume", checker, timeout, DEFAULT_TASK_SLEEP_TIME); + IntegrationTestTools.waitFor("Waiting for resumed task " + origTask + " finish", checker, timeout, DEFAULT_TASK_SLEEP_TIME); Task freshTask = taskManager.getTaskWithResult(origTask.getOid(), waitResult); logger.debug("Final task:\n{}", freshTask.debugDump()); diff --git a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java index c4dcdab15ca..c5e80c74f81 100644 --- a/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java +++ b/repo/repo-test-util/src/main/java/com/evolveum/midpoint/test/AbstractIntegrationTest.java @@ -2882,8 +2882,8 @@ protected void setGlobalTracingOverrideAll(@NotNull TracingProfileType profile) taskManager.setGlobalTracingOverride(Arrays.asList(TracingRootType.values()), profile); } - protected void removeGlobalTracingOverride() { - taskManager.removeGlobalTracingOverride(); + protected void unsetGlobalTracingOverride() { + taskManager.unsetGlobalTracingOverride(); } protected Consumer> workerThreadsCustomizer(int threads) { diff --git a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java index cb8510e7a85..16e26239b43 100644 --- a/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java +++ b/repo/task-api/src/main/java/com/evolveum/midpoint/task/api/TaskManager.java @@ -785,7 +785,7 @@ String recordTaskThreadsDump(String taskOid, String cause, OperationResult paren void setGlobalTracingOverride(@NotNull Collection roots, @NotNull TracingProfileType profile); // EXPERIMENTAL - void removeGlobalTracingOverride(); + void unsetGlobalTracingOverride(); /** * @return true if we consider this node to be "up" (alive). This is determined by looking at operational state diff --git a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskManagerQuartzImpl.java b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskManagerQuartzImpl.java index 4cfe84bedec..ba400b55882 100644 --- a/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskManagerQuartzImpl.java +++ b/repo/task-quartz-impl/src/main/java/com/evolveum/midpoint/task/quartzimpl/TaskManagerQuartzImpl.java @@ -2633,7 +2633,7 @@ public void setGlobalTracingOverride(@NotNull Collection roots, } @Override - public void removeGlobalTracingOverride() { + public void unsetGlobalTracingOverride() { globalTracingOverride = null; } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java index 454f47d825c..458288f5bf9 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholds.java @@ -10,6 +10,13 @@ import static org.testng.Assert.assertNotNull; import java.io.File; +import java.util.List; + +import com.evolveum.midpoint.prism.delta.ItemDelta; +import com.evolveum.midpoint.schema.statistics.SynchronizationInformation; +import com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException; +import com.evolveum.midpoint.util.exception.ObjectNotFoundException; +import com.evolveum.midpoint.util.exception.SchemaException; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; @@ -45,14 +52,14 @@ public abstract class TestThresholds extends AbstractStoryTest { private static final String ROLE_POLICY_RULE_CREATE_OID = "00000000-role-0000-0000-999111111112"; private static final File ROLE_POLICY_RULE_CHANGE_ACTIVATION_FILE = new File(TEST_DIR, "role-policy-rule-change-activation.xml"); - protected static final String ROLE_POLICY_RULE_CHANGE_ACTIVATION_OID = "00000000-role-0000-0000-999111111223"; + private static final String ROLE_POLICY_RULE_CHANGE_ACTIVATION_OID = "00000000-role-0000-0000-999111111223"; private static final File TASK_IMPORT_BASE_USERS_FILE = new File(TEST_DIR, "task-opendj-import-base-users.xml"); private static final String TASK_IMPORT_BASE_USERS_OID = "fa25e6dc-a858-11e7-8ebc-eb2b71ecce1d"; private static final int TASK_IMPORT_TIMEOUT = 60000; - protected int getDefaultUsers() { + int getDefaultUsers() { return 6; } @@ -88,6 +95,9 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti repoAddObjectFromFile(getTaskFile(), initResult); } + /** + * Imports base users in an auxiliary task ("import base users"). + */ @Test public void test001testImportBaseUsers() throws Exception { OperationResult result = createOperationResult(); @@ -127,14 +137,19 @@ protected int getNumberOfUsers() { return super.getNumberOfUsers() + getDefaultUsers(); } + /** + * Assigns the rule of "Stop after 4 created users" to the main task. + */ @Test - public void test100assignPolicyRuleCreateToTask() throws Exception { - // WHEN + public void test100AssignCreationLimitToTask() throws Exception { + Task task = createPlainTask(); OperationResult result = task.getResult(); + + when(); assignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CREATE_OID, task, result); - //THEN + then(); PrismObject taskAfter = getObject(TaskType.class, getTaskOid()); display("Task after:", taskAfter); assertAssignments(taskAfter, 1); @@ -143,20 +158,23 @@ public void test100assignPolicyRuleCreateToTask() throws Exception { } + /** + * Runs the main task and checks if it stopped after processing expected number of users. + */ @Test - public void test110importAccounts() throws Exception { + public void test110ImportAccounts() throws Exception { Task task = createPlainTask(); OperationResult result = task.getResult(); openDJController.addEntriesFromLdifFile(LDIF_CREATE_USERS_FILE); assertUsers(getNumberOfUsers()); - //WHEN + when(); - OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); + OperationResult reconResult = resumeTaskAndWaitForNextFinish(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); - //THEN + then(); assertUsers(getProcessedUsers() + getNumberOfUsers()); assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED); @@ -164,37 +182,52 @@ public void test110importAccounts() throws Exception { assertSynchronizationStatisticsAfterImport(taskAfter); } + /** + * Adds more users. Runs the main task again and checks if it again stopped after processing expected number of users. + */ @Test - public void test111importAccountsAgain() throws Exception { + public void test111ImportAccountsAgain() throws Exception { Task task = createPlainTask(); OperationResult result = task.getResult(); + given(); openDJController.addEntriesFromLdifFile(LDIF_CREATE_USERS_NEXT_FILE); - assertUsers(getNumberOfUsers() + getProcessedUsers()); - //WHEN + clearTaskOperationalStats(result); + when(); - OperationResult reconResult = waitForTaskResume(getTaskOid(), false, TASK_IMPORT_TIMEOUT); + OperationResult reconResult = resumeTaskAndWaitForNextFinish(getTaskOid(), false, TASK_IMPORT_TIMEOUT); assertFailure(reconResult); - //THEN + then(); assertUsers(getProcessedUsers() * 2 + getNumberOfUsers()); assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED); Task taskAfter = taskManager.getTaskWithResult(getTaskOid(), result); assertSynchronizationStatisticsAfterSecondImport(taskAfter); + } + private void clearTaskOperationalStats(OperationResult result) throws SchemaException, ObjectAlreadyExistsException, + ObjectNotFoundException { + List> modifications = deltaFor(TaskType.class) + .item(TaskType.F_OPERATION_STATS).replace() + .asItemDeltas(); + repositoryService.modifyObject(TaskType.class, getTaskOid(), modifications, result); } + /** + * Changes the rule to "Stop after having 2 users with changed activation/administrativeStatus". + */ @Test - public void test500changeTaskPolicyRule() throws Exception { - //WHEN + public void test500AssignModificationLimitToTask() throws Exception { Task task = createPlainTask(); OperationResult result = task.getResult(); + + when(); unassignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CREATE_OID, task, result); assignRole(TaskType.class, getTaskOid(), ROLE_POLICY_RULE_CHANGE_ACTIVATION_OID, task, result); - //THEN + then(); PrismObject taskAfter = getObject(TaskType.class, getTaskOid()); display("Task after:", taskAfter); assertAssignments(taskAfter, 1); @@ -202,24 +235,30 @@ public void test500changeTaskPolicyRule() throws Exception { assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED); } + /** + * Disables accounts for users1..6 on the resource. Expects to stop after processing 2 of them. + */ @Test - public void test520changeActivationThreeAccounts() throws Exception { + public void test520ImportDisabledAccounts() throws Exception { OperationResult result = createOperationResult(); - //GIVEN - openDJController.executeLdifChange(LDIF_CHANGE_ACTIVATION_FILE); + given(); + openDJController.executeLdifChanges(LDIF_CHANGE_ACTIVATION_FILE); + clearTaskOperationalStats(result); - //WHEN when(); - OperationResult reconResult = waitForTaskResume(getTaskOid(), false, 20000); + OperationResult reconResult = resumeTaskAndWaitForNextFinish(getTaskOid(), false, 20000); assertFailure(reconResult); - //THEN - + then(); Task taskAfter = taskManager.getTaskWithResult(getTaskOid(), result); assertTaskExecutionStatus(getTaskOid(), TaskExecutionStatus.SUSPENDED); assertSynchronizationStatisticsActivation(taskAfter); } + + void dumpSynchronizationInformation(SynchronizationInformationType synchronizationInformation) { + display("Synchronization information", SynchronizationInformation.format(synchronizationInformation)); + } } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncFull.java index 4bdaf0c8ec5..3094ee9c73b 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncFull.java @@ -10,6 +10,8 @@ import java.io.File; +import com.evolveum.midpoint.schema.statistics.SynchronizationInformation; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -45,6 +47,7 @@ protected int getProcessedUsers() { @Override protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws Exception { SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); assertSyncToken(taskAfter, 4, taskAfter.getResult()); @@ -53,7 +56,7 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws assertEquals(syncInfo.getCountLinked(), 0); assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 1); // this is the one that failed assertEquals(syncInfo.getCountDeletedAfter(), 0); assertEquals(syncInfo.getCountLinkedAfter(), getProcessedUsers()); assertEquals(syncInfo.getCountUnlinkedAfter(), 0); @@ -61,18 +64,21 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws } protected void assertSynchronizationStatisticsActivation(Task taskAfter) { - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatched(), 3); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), 8); // this is because LiveSync re-processes changes by default (FIXME) - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); + + // It's actually not much clear how these numbers are obtained. The task processes various (yet unprocessed) changes + // and stops after seeing third disabled account. + assertEquals(syncInfo.getCountUnmatched(), 3); + assertEquals(syncInfo.getCountDeleted(), 0); + assertEquals(syncInfo.getCountLinked(), 9); + assertEquals(syncInfo.getCountUnlinked(), 0); } - /* (non-Javadoc) - * @see com.evolveum.midpoint.testing.story.TestThresholds#assertSynchronizationStatisticsAfterSecondImport(com.evolveum.midpoint.task.api.Task) - */ @Override protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) throws Exception { SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); assertSyncToken(taskAfter, 4, taskAfter.getResult()); @@ -81,7 +87,7 @@ protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) assertEquals(syncInfo.getCountLinked(), 4); // this is because LiveSync re-processes changes by default (FIXME) assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 1); // this is the one that failed assertEquals(syncInfo.getCountDeletedAfter(), 0); assertEquals(syncInfo.getCountLinkedAfter(), 8); // this is because LiveSync re-processes changes by default (FIXME) assertEquals(syncInfo.getCountUnlinkedAfter(), 0); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncSimulate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncSimulate.java index 304e42c3d60..15e7a315e12 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncSimulate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsLiveSyncSimulate.java @@ -45,10 +45,12 @@ protected int getProcessedUsers() { @Override protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws Exception { SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); assertSyncToken(taskAfter, 4, taskAfter.getResult()); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + // user5, user6, user7, user8, user9 (why not user4? -- because token is preset to 4) + assertEquals(syncInfo.getCountUnmatchedAfter(), 5); assertEquals(syncInfo.getCountDeletedAfter(), 0); assertEquals(syncInfo.getCountLinkedAfter(), 0); assertEquals(syncInfo.getCountUnlinkedAfter(), 0); @@ -56,10 +58,15 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) throws } protected void assertSynchronizationStatisticsActivation(Task taskAfter) { - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatched(), 3); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); + + // new users: user5, user6, user7, user8, user9, user10, user11, user12, user13, user14, user15 (11 users) + assertEquals(syncInfo.getCountUnmatched(), 11); + assertEquals(syncInfo.getCountDeleted(), 0); + // existing users: user1, user2 (disabled - passes), user3 (disabled - fails) -- these users were created during initial import + assertEquals(syncInfo.getCountLinked(), 3); // 2 + 1 + assertEquals(syncInfo.getCountUnlinked(), 0); } /* (non-Javadoc) @@ -68,10 +75,12 @@ protected void assertSynchronizationStatisticsActivation(Task taskAfter) { @Override protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) throws Exception { SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); assertSyncToken(taskAfter, 4, taskAfter.getResult()); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + // user5, user6, user7, user8, user9 + assertEquals(syncInfo.getCountUnmatchedAfter(), 5); assertEquals(syncInfo.getCountDeletedAfter(), 0); assertEquals(syncInfo.getCountLinkedAfter(), 0); assertEquals(syncInfo.getCountUnlinkedAfter(), 0); diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java index 5c64d3ab314..5861da8a0cc 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconFull.java @@ -11,6 +11,10 @@ import java.io.File; +import com.evolveum.midpoint.schema.statistics.IterativeTaskInformation; + +import com.evolveum.midpoint.schema.statistics.SynchronizationInformation; + import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; import org.springframework.test.context.ContextConfiguration; @@ -62,7 +66,7 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti } @Test - public void test600changeTaskPolicyRule() throws Exception { + public void test600ChangeTaskPolicyRule() throws Exception { //WHEN Task task = createPlainTask(); OperationResult result = task.getResult(); @@ -77,12 +81,12 @@ public void test600changeTaskPolicyRule() throws Exception { } @Test - public void test610testFullRecon() throws Exception { + public void test610TestFullRecon() throws Exception { OperationResult result = createOperationResult(); //WHEN when(); - OperationResult reconResult = waitForTaskResume(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000); + OperationResult reconResult = resumeTaskAndWaitForNextFinish(TASK_RECONCILE_OPENDJ_SIMULATE_EXECUTE_OID, true, 20000); assertSuccess(reconResult); //THEN @@ -95,7 +99,7 @@ public void test610testFullRecon() throws Exception { } @Test - public void test611testFullRecon() throws Exception { + public void test611TestFullRecon() throws Exception { OperationResult result = createOperationResult(); openDJController.delete("uid=user10,ou=People,dc=example,dc=com"); @@ -151,7 +155,7 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) { assertEquals(syncInfo.getCountLinked(), getDefaultUsers()); assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 1); // There is 1 unmatched because it's recorded after "stop" policy rule triggered assertEquals(syncInfo.getCountDeleted(), 0); assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers() + getProcessedUsers()); assertEquals(syncInfo.getCountUnlinked(), 0); @@ -164,9 +168,6 @@ private void assertSynchronizationStatisticsFull(Task taskAfter) { } - /* (non-Javadoc) - * @see com.evolveum.midpoint.testing.story.TestThresholds#assertSynchronizationStatisticsAfterSecondImport(com.evolveum.midpoint.task.api.Task) - */ @Override protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) { IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation(); @@ -179,7 +180,7 @@ protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) assertEquals(syncInfo.getCountLinked(), getDefaultUsers() + getProcessedUsers()); assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 1); // There is 1 unmatched because it's recorded after "stop" policy rule triggered assertEquals(syncInfo.getCountDeleted(), 0); assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers() + getProcessedUsers() * 2); assertEquals(syncInfo.getCountUnlinked(), 0); @@ -188,15 +189,21 @@ protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) protected void assertSynchronizationStatisticsActivation(Task taskAfter) { IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation(); assertEquals(infoType.getTotalFailureCount(), 1); + display("Iterative task information", IterativeTaskInformation.format(infoType)); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatched(), 3); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), 14); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + SynchronizationInformationType synchronizationInformation = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(synchronizationInformation); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatchedAfter(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), 14); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + assertEquals(synchronizationInformation.getCountUnmatched(), 0); + assertEquals(synchronizationInformation.getCountDeleted(), 0); + // 1. gibbs, 2. barbossa, 3. beckett (unchanged), 4. user1, 5. user2 (disabled), 6. user3 (tried to be disabled but failed because of the rule) + assertEquals(synchronizationInformation.getCountLinked(), 6); + assertEquals(synchronizationInformation.getCountUnlinked(), 0); + + assertEquals(synchronizationInformation.getCountUnmatchedAfter(), 0); + assertEquals(synchronizationInformation.getCountDeleted(), 0); + assertEquals(synchronizationInformation.getCountLinked(), 6); + assertEquals(synchronizationInformation.getCountUnlinked(), 0); } + } diff --git a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconSimulate.java b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconSimulate.java index 6858c459461..79ad5095709 100644 --- a/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconSimulate.java +++ b/testing/story/src/test/java/com/evolveum/midpoint/testing/story/TestThresholdsReconSimulate.java @@ -49,15 +49,18 @@ protected void assertSynchronizationStatisticsAfterImport(Task taskAfter) { assertEquals(infoType.getTotalFailureCount(), 1); SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); + // user4, user5, user6, user7, user8 assertEquals(syncInfo.getCountUnmatched(), 5); assertEquals(syncInfo.getCountDeleted(), 0); + // jgibbs, hbarbossa, jbeckett, user1, user2, user3 assertEquals(syncInfo.getCountLinked(), getDefaultUsers()); assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 5); assertEquals(syncInfo.getCountDeletedAfter(), 0); - assertEquals(syncInfo.getCountLinkedAfter(), 0); + assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers()); assertEquals(syncInfo.getCountUnlinkedAfter(), 0); } @@ -70,15 +73,18 @@ protected void assertSynchronizationStatisticsAfterSecondImport(Task taskAfter) assertEquals(infoType.getTotalFailureCount(), 1); SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); + // user4, user5, user6, user7, user8 assertEquals(syncInfo.getCountUnmatched(), 5); assertEquals(syncInfo.getCountDeleted(), 0); + // jgibbs, hbarbossa, jbeckett, user1, user2, user3 assertEquals(syncInfo.getCountLinked(), getDefaultUsers() + getProcessedUsers()); assertEquals(syncInfo.getCountUnlinked(), 0); - assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountUnmatchedAfter(), 5); assertEquals(syncInfo.getCountDeletedAfter(), 0); - assertEquals(syncInfo.getCountLinkedAfter(), 0); + assertEquals(syncInfo.getCountLinkedAfter(), getDefaultUsers() + getProcessedUsers()); assertEquals(syncInfo.getCountUnlinkedAfter(), 0); } @@ -87,14 +93,19 @@ protected void assertSynchronizationStatisticsActivation(Task taskAfter) { IterativeTaskInformationType infoType = taskAfter.getStoredOperationStats().getIterativeTaskInformation(); assertEquals(infoType.getTotalFailureCount(), 1); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatched(), 3); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), getDefaultUsers() + getProcessedUsers()); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + SynchronizationInformationType syncInfo = taskAfter.getStoredOperationStats().getSynchronizationInformation(); + dumpSynchronizationInformation(syncInfo); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnmatchedAfter(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountDeleted(), 0); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountLinked(), getDefaultUsers() + getProcessedUsers()); - assertEquals(taskAfter.getStoredOperationStats().getSynchronizationInformation().getCountUnlinked(), 0); + assertEquals(syncInfo.getCountUnmatched(), 0); + assertEquals(syncInfo.getCountDeleted(), 0); + // jgibbs, hbarbossa, jbeckett, user1 (disabled-#1), user2 (disabled-#2), user3 (disabled-#3-fails) + assertEquals(syncInfo.getCountLinked(), getDefaultUsers() + getProcessedUsers()); + assertEquals(syncInfo.getCountUnlinked(), 0); + + assertEquals(syncInfo.getCountUnmatchedAfter(), 0); + assertEquals(syncInfo.getCountDeleted(), 0); + // jgibbs, hbarbossa, jbeckett, user1 (disabled-#1), user2 (disabled-#2), user3 (disabled-#3-fails) + assertEquals(syncInfo.getCountLinked(), getDefaultUsers() + getProcessedUsers()); + assertEquals(syncInfo.getCountUnlinked(), 0); } } diff --git a/testing/story/src/test/resources/thresholds/role-policy-rule-change-activation.xml b/testing/story/src/test/resources/thresholds/role-policy-rule-change-activation.xml index 7fe6fbba8e9..bd2c46eb00b 100644 --- a/testing/story/src/test/resources/thresholds/role-policy-rule-change-activation.xml +++ b/testing/story/src/test/resources/thresholds/role-policy-rule-change-activation.xml @@ -6,13 +6,13 @@ --> - Metarole stop on activation change (3) + Metarole stop on activation change (2) Change activation - add + modify activation/administrativeStatus diff --git a/testing/story/src/test/resources/thresholds/task-opendj-livesync-full.xml b/testing/story/src/test/resources/thresholds/task-opendj-livesync-full.xml index a1537f47380..3f7f61d7b7d 100644 --- a/testing/story/src/test/resources/thresholds/task-opendj-livesync-full.xml +++ b/testing/story/src/test/resources/thresholds/task-opendj-livesync-full.xml @@ -16,8 +16,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - - LiveSync Simulate: Dummy + LiveSync Full: Dummy ri:inetOrgPerson diff --git a/testing/story/src/test/resources/thresholds/task-opendj-livesync-simulate.xml b/testing/story/src/test/resources/thresholds/task-opendj-livesync-simulate.xml index cbc7767d069..caa338d7ea1 100644 --- a/testing/story/src/test/resources/thresholds/task-opendj-livesync-simulate.xml +++ b/testing/story/src/test/resources/thresholds/task-opendj-livesync-simulate.xml @@ -16,7 +16,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - LiveSync Simulate: Dummy diff --git a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-full.xml b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-full.xml index c088a160e48..c268250d1db 100644 --- a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-full.xml +++ b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-full.xml @@ -10,18 +10,17 @@ - Reconciliation Full: Dummy - ri:inetOrgPerson - account - default + ri:inetOrgPerson + account + default 20335c7c-838f-11e8-93a6-4b1dd0ab58e4 diff --git a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate-execute.xml b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate-execute.xml index 39718fc0d1c..bc1d23b51df 100644 --- a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate-execute.xml +++ b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate-execute.xml @@ -15,7 +15,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - Reconciliation Simulate Execute: Dummy diff --git a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate.xml b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate.xml index d6dd490e607..448b4624025 100644 --- a/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate.xml +++ b/testing/story/src/test/resources/thresholds/task-opendj-reconcile-simulate.xml @@ -15,7 +15,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> - Reconciliation Simulate: Dummy