Skip to content

Commit

Permalink
Tests for resource read (resource caching)
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Oct 2, 2017
1 parent fc6c1e4 commit c6c509f
Show file tree
Hide file tree
Showing 8 changed files with 295 additions and 161 deletions.
Expand Up @@ -23,6 +23,8 @@ public enum InternalCounters {
RESOURCE_SCHEMA_PARSE_COUNT("resourceSchemaParseCount", "resource schema parse count", InternalOperationClasses.RESOURCE_SCHEMA_OPERATIONS),

RESOURCE_SCHEMA_FETCH_COUNT("resourceSchemaFetchCount", "resource schema fetch count", InternalOperationClasses.REPOSITORY_OPERATIONS),

RESOURCE_REPOSITORY_READ_COUNT("resourceRepositoryReadCount", "resource repository read count", null),

CONNECTOR_INSTANCE_INITIALIZATION_COUNT("connectorInstanceInitializationCount", "connector instance initialization count", InternalOperationClasses.CONNECTOR_OPERATIONS),

Expand Down
Expand Up @@ -111,15 +111,15 @@ public void initSystem(Task initTask, OperationResult initResult)
@Test
public void test000Sanity() throws Exception {
final String TEST_NAME="test000Sanity";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

assertShadows(5);
}

@Test
public void test131ModifyUserJackAssignAccount() throws Exception {
final String TEST_NAME="test131ModifyUserJackAssignAccount";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME);
Expand All @@ -132,7 +132,7 @@ public void test131ModifyUserJackAssignAccount() throws Exception {
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);

// THEN
Expand Down Expand Up @@ -174,7 +174,7 @@ public void test131ModifyUserJackAssignAccount() throws Exception {
@Test
public void test133SeachAccountShadows() throws Exception {
final String TEST_NAME="test133SeachAccountShadows";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME);
Expand All @@ -186,7 +186,7 @@ public void test133SeachAccountShadows() throws Exception {
rememberCounter(InternalCounters.SHADOW_FETCH_OPERATION_COUNT);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
SearchResultList<PrismObject<ShadowType>> foundShadows = modelService.searchObjects(ShadowType.class, query, null, task, result);

// THEN
Expand Down Expand Up @@ -228,7 +228,7 @@ public void test133SeachAccountShadows() throws Exception {
@Test
public void test139ModifyUserJackUnassignAccount() throws Exception {
final String TEST_NAME = "test139ModifyUserJackUnassignAccount";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

// GIVEN
Task task = taskManager.createTaskInstance(TestCaseIgnore.class.getName() + "." + TEST_NAME);
Expand Down Expand Up @@ -268,7 +268,7 @@ public void test139ModifyUserJackUnassignAccount() throws Exception {
@Test
public void test150JackAssignRoleX() throws Exception {
final String TEST_NAME = "test150JackAssignRoleX";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -280,7 +280,7 @@ public void test150JackAssignRoleX() throws Exception {
assignRole(USER_JACK_OID, ROLE_X_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand Down Expand Up @@ -315,7 +315,7 @@ public void test150JackAssignRoleX() throws Exception {
@Test
public void test152GetJack() throws Exception {
final String TEST_NAME = "test152GetJack";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -324,7 +324,7 @@ public void test152GetJack() throws Exception {
PrismObject<UserType> userJack = modelService.getObject(UserType.class, USER_JACK_OID, null, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand Down Expand Up @@ -357,7 +357,7 @@ public void test152GetJack() throws Exception {
@Test
public void test159JackUnAssignRoleX() throws Exception {
final String TEST_NAME = "test159JackUnAssignRoleX";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -369,7 +369,7 @@ public void test159JackUnAssignRoleX() throws Exception {
unassignRole(USER_JACK_OID, ROLE_X_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand All @@ -389,7 +389,7 @@ public void test159JackUnAssignRoleX() throws Exception {
@Test
public void test160JackAssignRoleBasic() throws Exception {
final String TEST_NAME = "test160JackAssignRoleBasic";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -398,11 +398,11 @@ public void test160JackAssignRoleBasic() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand Down Expand Up @@ -438,7 +438,7 @@ public void test160JackAssignRoleBasic() throws Exception {
@Test
public void test161JackAssignRoleJoker() throws Exception {
final String TEST_NAME = "test161JackAssignRoleJoker";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -447,11 +447,11 @@ public void test161JackAssignRoleJoker() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand Down Expand Up @@ -491,7 +491,7 @@ public void test161JackAssignRoleJoker() throws Exception {
@Test
public void test165JackUnAssignRoleJoker() throws Exception {
final String TEST_NAME = "test165JackUnAssignRoleJoker";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -500,11 +500,11 @@ public void test165JackUnAssignRoleJoker() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand Down Expand Up @@ -540,7 +540,7 @@ public void test165JackUnAssignRoleJoker() throws Exception {
@Test
public void test169JackUnAssignRoleBasic() throws Exception {
final String TEST_NAME = "test169JackUnAssignRoleBasic";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -549,11 +549,11 @@ public void test169JackUnAssignRoleBasic() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
unassignRole(USER_JACK_OID, ROLE_UPCASE_BASIC_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);

Expand All @@ -575,7 +575,7 @@ public void test169JackUnAssignRoleBasic() throws Exception {
@Test
public void test170JackAssignRoleJoker() throws Exception {
final String TEST_NAME = "test170JackAssignRoleJoker";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -584,13 +584,12 @@ public void test170JackAssignRoleJoker() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
assignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
displayThen(TEST_NAME);
assertSuccess(result);

// Make sure this is repository so we do not destroy the "evidence" yet.
PrismObject<UserType> userJack = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
Expand Down Expand Up @@ -624,7 +623,7 @@ public void test170JackAssignRoleJoker() throws Exception {
@Test
public void test179JackUnAssignRoleJoker() throws Exception {
final String TEST_NAME = "test179JackUnAssignRoleJoker";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -633,13 +632,12 @@ public void test179JackUnAssignRoleJoker() throws Exception {
display("User jack before", userBefore);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
unassignRole(USER_JACK_OID, ROLE_JOKER_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
displayThen(TEST_NAME);
assertSuccess(result);

// Make sure this is repository so we do not destroy the "evidence" yet.
PrismObject<UserType> userJack = repositoryService.getObject(UserType.class, USER_JACK_OID, null, result);
Expand Down Expand Up @@ -668,7 +666,7 @@ public void test179JackUnAssignRoleJoker() throws Exception {
@Test
public void test200GuybrushAssignRoleFools() throws Exception {
final String TEST_NAME = "test200GuybrushAssignRoleFools";
TestUtil.displayTestTitle(this, TEST_NAME);
displayTestTitle(TEST_NAME);

Task task = taskManager.createTaskInstance(TestRbac.class.getName() + "." + TEST_NAME);
OperationResult result = task.getResult();
Expand All @@ -689,13 +687,12 @@ public void test200GuybrushAssignRoleFools() throws Exception {
assertShadows(4);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
assignRole(USER_GUYBRUSH_OID, ROLE_FOOL_OID, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess(result);
displayThen(TEST_NAME);
assertSuccess(result);

assertShadows(6);

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2015 Evolveum
* Copyright (c) 2010-2017 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -15,8 +15,6 @@
*/
package com.evolveum.midpoint.model.intest;

import static com.evolveum.midpoint.test.IntegrationTestTools.display;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -82,13 +80,12 @@ public void test131ModifyUserJackAssignAccountDefault() throws Exception {
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
displayThen(TEST_NAME);
assertSuccess(result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 0);

Expand Down Expand Up @@ -143,13 +140,12 @@ public void test132ModifyUserJackAssignAccountTest() throws Exception {
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
displayThen(TEST_NAME);
assertSuccess(result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

Expand Down Expand Up @@ -210,13 +206,12 @@ public void test135ModifyUserJackFullName() throws Exception {
preTestCleanup(AssignmentPolicyEnforcementType.RELATIVE);

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
modifyUserReplace(USER_JACK_OID, UserType.F_FULL_NAME, task, result, PrismTestUtil.createPolyString("cpt. Jack Sparrow"));

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
displayThen(TEST_NAME);
assertSuccess(result);
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 2);

PrismObject<UserType> userJack = getUser(USER_JACK_OID);
Expand Down Expand Up @@ -280,13 +275,12 @@ public void test147ModifyUserJackUnAssignAccountDefault() throws Exception {
XMLGregorianCalendar startTime = clock.currentTimeXMLGregorianCalendar();

// WHEN
TestUtil.displayWhen(TEST_NAME);
displayWhen(TEST_NAME);
modelService.executeChanges(deltas, null, task, result);

// THEN
TestUtil.displayThen(TEST_NAME);
result.computeStatus();
TestUtil.assertSuccess("executeChanges result", result);
displayThen(TEST_NAME);
assertSuccess(result);
XMLGregorianCalendar endTime = clock.currentTimeXMLGregorianCalendar();
assertCounterIncrement(InternalCounters.SHADOW_FETCH_OPERATION_COUNT, 1);

Expand Down
Expand Up @@ -1574,7 +1574,10 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc
// the previous command changes resource, therefore let's explicitly re-read it before test
// to refresh the cache and not affect the performance results (monitor).
modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT, 1);
assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1);

assertSteadyResources();

// WHEN
displayWhen(TEST_NAME);
Expand Down Expand Up @@ -1634,7 +1637,9 @@ public void test148ModifyUserJackUnassignAccountPositiveEnforcement() throws Exc
// the previous command changes resource, therefore let's explicitly re-read it before test
// to refresh the cache and not affect the performance results (monitor).
modelService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, task, result);
assertCounterIncrement(InternalCounters.RESOURCE_REPOSITORY_READ_COUNT, 1);
assertCounterIncrement(InternalCounters.RESOURCE_SCHEMA_PARSE_COUNT, 1);
assertSteadyResources();
}

/**
Expand Down

0 comments on commit c6c509f

Please sign in to comment.