Search in sources :

Example 1 with TestResource

use of com.evolveum.midpoint.test.TestResource in project midpoint by Evolveum.

the class TestSystemPerformance method test100Import.

@Test
public void test100Import() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    int usersBefore = repositoryService.countObjects(UserType.class, null, null, result);
    String label = "initial-run-of-";
    for (int taskIndex = 0; taskIndex < TASK_IMPORT_LIST.size(); taskIndex++) {
        String importName = "import #" + taskIndex;
        when(importName);
        TestResource<TaskType> taskImport = TASK_IMPORT_LIST.get(taskIndex);
        lastProgress = 0;
        addTask(taskImport, result);
        waitForTaskFinish(taskImport.oid, false, 0, OTHER_PARAMETERS.taskTimeout, false, 0, builder -> builder.taskConsumer(task1 -> recordProgress(label, task1)));
        then(importName);
        // Note: after first import the number of users should be constant
        int usersAfter = repositoryService.countObjects(UserType.class, null, null, result);
        assertThat(usersAfter - usersBefore).as("users after " + importName).isEqualTo(SOURCES_CONFIGURATION.getNumberOfAccounts());
        PrismObject<TaskType> taskAfter = assertTask(taskImport.oid, "after").display().getObject();
        logTaskFinish(taskAfter, label, result);
    }
    String accountName = SourceInitializer.getAccountName(0);
    DummyAccount account = RESOURCE_SOURCE_LIST.get(0).controller.getDummyResource().getAccountByUsername(accountName);
    Set<String> roles = account.getAttributeValues(SourcesConfiguration.A_ROLE, String.class);
    displayValue("Roles for " + accountName, roles);
    Set<String> memberships = RESOURCE_TARGET_LIST.stream().flatMap(r -> emptyIfNull(getMemberships(accountName, r)).stream()).collect(Collectors.toSet());
    displayValue("Memberships for " + accountName, memberships);
    Set<String> technicalRoles = memberships.stream().map(this::getTechnicalRoleName).collect(Collectors.toSet());
    displayValue("Technical roles for " + accountName, technicalRoles);
    boolean memberOf = ROLES_CONFIGURATION.isMemberOfComputation();
    PrismObject<UserType> user = assertUserAfterByUsername(accountName).assertAssignments(// 1. archetype
    roles.size() + 1).assertLinks(SOURCES_CONFIGURATION.getNumberOfResources() + TARGETS_CONFIGURATION.getNumberOfResources(), 0).extension().assertSize(SOURCES_CONFIGURATION.getSingleValuedMappings() + SOURCES_CONFIGURATION.getMultiValuedMappings() + (memberOf ? 1 : 0)).property(ItemPath.create(getSingleValuedPropertyName(0))).assertSize(1).end().property(ItemPath.create(getMultiValuedPropertyName(0))).assertSize(SOURCES_CONFIGURATION.getAttributeValues() * SOURCES_CONFIGURATION.getNumberOfResources()).end().end().getObject();
    if (memberOf) {
        Collection<String> memberOfValue = ObjectTypeUtil.getExtensionPropertyValues(user.asObjectable(), EXT_MEMBER_OF);
        displayValue("memberOf", memberOfValue);
        assertThat(memberOfValue).as("memberOf").hasSize(memberships.size());
    }
// temporarily disabled
// if (TARGETS_CONFIGURATION.getNumberOfResources() > 0) {
// assertThat(user.asObjectable().getRoleMembershipRef().size())
// .as("# of role membership refs")
// .isEqualTo(roles.size() + technicalRoles.size() + 2); // 1. archetype, 2. role-targets)
// }
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) java.util(java.util) MidPointTestConstants(com.evolveum.midpoint.test.util.MidPointTestConstants) TestReportSection(com.evolveum.midpoint.tools.testng.TestReportSection) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MiscUtil.emptyIfNull(com.evolveum.midpoint.util.MiscUtil.emptyIfNull) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskOperationStatsUtil(com.evolveum.midpoint.schema.util.task.TaskOperationStatsUtil) DummyAuditService(com.evolveum.midpoint.test.DummyAuditService) Test(org.testng.annotations.Test) TestReportUtil(com.evolveum.midpoint.test.util.TestReportUtil) DummyTestResource(com.evolveum.midpoint.test.DummyTestResource) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) Matcher(java.util.regex.Matcher) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) ListUtils(org.apache.commons.collections4.ListUtils) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) TARGET_DIR_PATH(com.evolveum.midpoint.test.util.MidPointTestConstants.TARGET_DIR_PATH) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) ActivityPerformanceInformation(com.evolveum.midpoint.schema.util.task.ActivityPerformanceInformation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) IOException(java.io.IOException) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) TreeNode(com.evolveum.midpoint.util.TreeNode) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) CommonException(com.evolveum.midpoint.util.exception.CommonException) TestResource(com.evolveum.midpoint.test.TestResource) ItemName(com.evolveum.midpoint.prism.path.ItemName) PerformanceTestClassMixin(com.evolveum.midpoint.tools.testng.PerformanceTestClassMixin) SystemException(com.evolveum.midpoint.util.exception.SystemException) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Pattern(java.util.regex.Pattern) PERF_REPORT_PREFIX_PROPERTY_NAME(com.evolveum.midpoint.tools.testng.TestMonitor.PERF_REPORT_PREFIX_PROPERTY_NAME) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) Test(org.testng.annotations.Test) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest)

Example 2 with TestResource

use of com.evolveum.midpoint.test.TestResource in project midpoint by Evolveum.

the class TestSystemPerformance method test110ImportAgain.

@Test
public void test110ImportAgain() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    int usersBefore = repositoryService.countObjects(UserType.class, null, null, result);
    for (int retry = 0; retry < IMPORTS_CONFIGURATION.getNoOpRuns(); retry++) {
        String label = String.format("no-op-run-%d-of-", retry + 1);
        for (int taskIndex = 0; taskIndex < TASK_IMPORT_LIST.size(); taskIndex++) {
            String importName = String.format("re-import #%d of resource #%d", retry + 1, taskIndex);
            when(importName);
            TestResource<TaskType> taskImport = TASK_IMPORT_LIST.get(taskIndex);
            lastProgress = 0;
            restartTask(taskImport.oid, result);
            Thread.sleep(500);
            waitForTaskFinish(taskImport.oid, false, 0, OTHER_PARAMETERS.taskTimeout, false, 0, builder -> builder.taskConsumer(task1 -> recordProgress(label, task1)));
            then(importName);
            int usersAfter = repositoryService.countObjects(UserType.class, null, null, result);
            assertThat(usersAfter - usersBefore).as("users created").isEqualTo(0);
            PrismObject<TaskType> taskAfter = assertTask(taskImport.oid, "after").display().getObject();
            logTaskFinish(taskAfter, label, result);
        }
    }
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) java.util(java.util) MidPointTestConstants(com.evolveum.midpoint.test.util.MidPointTestConstants) TestReportSection(com.evolveum.midpoint.tools.testng.TestReportSection) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MiscUtil.emptyIfNull(com.evolveum.midpoint.util.MiscUtil.emptyIfNull) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskOperationStatsUtil(com.evolveum.midpoint.schema.util.task.TaskOperationStatsUtil) DummyAuditService(com.evolveum.midpoint.test.DummyAuditService) Test(org.testng.annotations.Test) TestReportUtil(com.evolveum.midpoint.test.util.TestReportUtil) DummyTestResource(com.evolveum.midpoint.test.DummyTestResource) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) Matcher(java.util.regex.Matcher) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) ListUtils(org.apache.commons.collections4.ListUtils) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) TARGET_DIR_PATH(com.evolveum.midpoint.test.util.MidPointTestConstants.TARGET_DIR_PATH) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) ActivityPerformanceInformation(com.evolveum.midpoint.schema.util.task.ActivityPerformanceInformation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) IOException(java.io.IOException) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) TreeNode(com.evolveum.midpoint.util.TreeNode) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) CommonException(com.evolveum.midpoint.util.exception.CommonException) TestResource(com.evolveum.midpoint.test.TestResource) ItemName(com.evolveum.midpoint.prism.path.ItemName) PerformanceTestClassMixin(com.evolveum.midpoint.tools.testng.PerformanceTestClassMixin) SystemException(com.evolveum.midpoint.util.exception.SystemException) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Pattern(java.util.regex.Pattern) PERF_REPORT_PREFIX_PROPERTY_NAME(com.evolveum.midpoint.tools.testng.TestMonitor.PERF_REPORT_PREFIX_PROPERTY_NAME) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest)

Example 3 with TestResource

use of com.evolveum.midpoint.test.TestResource in project midpoint by Evolveum.

the class TestSystemPerformance method test120Reconciliation.

@Test
public void test120Reconciliation() throws Exception {
    given();
    Task task = getTestTask();
    OperationResult result = task.getResult();
    for (int run = 0; run < RECONCILIATIONS_CONFIGURATION.getRuns(); run++) {
        String label = String.format("run-%d-of-", run + 1);
        for (int taskIndex = 0; taskIndex < TASK_RECONCILIATION_LIST.size(); taskIndex++) {
            String importName = String.format("reconciliation #%d of resource #%d", run + 1, taskIndex);
            when(importName);
            TestResource<TaskType> reconTask = TASK_RECONCILIATION_LIST.get(taskIndex);
            lastProgress = 0;
            if (run == 0) {
                addTask(reconTask, result);
            } else {
                restartTask(reconTask.oid, result);
                Thread.sleep(500);
            }
            waitForTaskFinish(reconTask.oid, false, 0, OTHER_PARAMETERS.taskTimeout, false, 0, builder -> builder.taskConsumer(task1 -> recordProgress(label, task1)));
            then(importName);
            PrismObject<TaskType> taskAfter = assertTask(reconTask.oid, "after").display().getObject();
            logTaskFinish(taskAfter, label, result);
        }
    }
}
Also used : DirtiesContext(org.springframework.test.annotation.DirtiesContext) java.util(java.util) MidPointTestConstants(com.evolveum.midpoint.test.util.MidPointTestConstants) TestReportSection(com.evolveum.midpoint.tools.testng.TestReportSection) com.evolveum.midpoint.xml.ns._public.common.common_3(com.evolveum.midpoint.xml.ns._public.common.common_3) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) MiscUtil.emptyIfNull(com.evolveum.midpoint.util.MiscUtil.emptyIfNull) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) TaskOperationStatsUtil(com.evolveum.midpoint.schema.util.task.TaskOperationStatsUtil) DummyAuditService(com.evolveum.midpoint.test.DummyAuditService) Test(org.testng.annotations.Test) TestReportUtil(com.evolveum.midpoint.test.util.TestReportUtil) DummyTestResource(com.evolveum.midpoint.test.DummyTestResource) InternalsConfig(com.evolveum.midpoint.schema.internals.InternalsConfig) PrismObjectDefinition(com.evolveum.midpoint.prism.PrismObjectDefinition) Matcher(java.util.regex.Matcher) ObjectTypeUtil(com.evolveum.midpoint.schema.util.ObjectTypeUtil) ListUtils(org.apache.commons.collections4.ListUtils) PrismContainerDefinition(com.evolveum.midpoint.prism.PrismContainerDefinition) TARGET_DIR_PATH(com.evolveum.midpoint.test.util.MidPointTestConstants.TARGET_DIR_PATH) DummyAccount(com.evolveum.icf.dummy.resource.DummyAccount) XmlTypeConverter(com.evolveum.midpoint.prism.xml.XmlTypeConverter) ActivityPerformanceInformation(com.evolveum.midpoint.schema.util.task.ActivityPerformanceInformation) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) IOException(java.io.IOException) PrismObject(com.evolveum.midpoint.prism.PrismObject) Task(com.evolveum.midpoint.task.api.Task) Collectors(java.util.stream.Collectors) TreeNode(com.evolveum.midpoint.util.TreeNode) File(java.io.File) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) CommonException(com.evolveum.midpoint.util.exception.CommonException) TestResource(com.evolveum.midpoint.test.TestResource) ItemName(com.evolveum.midpoint.prism.path.ItemName) PerformanceTestClassMixin(com.evolveum.midpoint.tools.testng.PerformanceTestClassMixin) SystemException(com.evolveum.midpoint.util.exception.SystemException) ContextConfiguration(org.springframework.test.context.ContextConfiguration) Pattern(java.util.regex.Pattern) PERF_REPORT_PREFIX_PROPERTY_NAME(com.evolveum.midpoint.tools.testng.TestMonitor.PERF_REPORT_PREFIX_PROPERTY_NAME) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest) Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) AbstractStoryTest(com.evolveum.midpoint.testing.story.AbstractStoryTest)

Aggregations

DummyAccount (com.evolveum.icf.dummy.resource.DummyAccount)3 PrismContainerDefinition (com.evolveum.midpoint.prism.PrismContainerDefinition)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 PrismObjectDefinition (com.evolveum.midpoint.prism.PrismObjectDefinition)3 ItemName (com.evolveum.midpoint.prism.path.ItemName)3 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)3 XmlTypeConverter (com.evolveum.midpoint.prism.xml.XmlTypeConverter)3 InternalsConfig (com.evolveum.midpoint.schema.internals.InternalsConfig)3 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)3 ObjectTypeUtil (com.evolveum.midpoint.schema.util.ObjectTypeUtil)3 ActivityPerformanceInformation (com.evolveum.midpoint.schema.util.task.ActivityPerformanceInformation)3 TaskOperationStatsUtil (com.evolveum.midpoint.schema.util.task.TaskOperationStatsUtil)3 Task (com.evolveum.midpoint.task.api.Task)3 DummyAuditService (com.evolveum.midpoint.test.DummyAuditService)3 DummyTestResource (com.evolveum.midpoint.test.DummyTestResource)3 TestResource (com.evolveum.midpoint.test.TestResource)3 MidPointTestConstants (com.evolveum.midpoint.test.util.MidPointTestConstants)3 TARGET_DIR_PATH (com.evolveum.midpoint.test.util.MidPointTestConstants.TARGET_DIR_PATH)3 TestReportUtil (com.evolveum.midpoint.test.util.TestReportUtil)3 AbstractStoryTest (com.evolveum.midpoint.testing.story.AbstractStoryTest)3