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)
// }
}
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);
}
}
}
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);
}
}
}
Aggregations