use of com.evolveum.midpoint.util.aspect.ProfilingDataManager in project midpoint by Evolveum.
the class ProfilingTest method prof_03_profManagerRequestTest.
@Test
public void prof_03_profManagerRequestTest() {
ProfilingDataManager manager = ProfilingDataManager.getInstance();
ProfilingDataLog event1 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", FASTEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event2 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", MIDDLE_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event3 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
//WHEN - adding 3 custom events
manager.prepareRequestProfilingEvent(event1);
manager.prepareRequestProfilingEvent(event2);
manager.prepareRequestProfilingEvent(event3);
Map<String, MethodUsageStatistics> perfMap = manager.getPerformanceMap();
//THEN
assertSame(1, perfMap.keySet().size());
assertSame(3, perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().size());
//Here, we are testing, if ProfilingEventList - slowestMethodMap is ordered correctly - we must use this
//strange approach, because testNG somehow thinks, that long 5000 != long 5000
boolean first = false;
boolean second = false;
boolean third = false;
if (SLOWEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(0).getEstimatedTime())
first = true;
if (MIDDLE_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(1).getEstimatedTime())
second = true;
if (FASTEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().get(2).getEstimatedTime())
third = true;
assertSame(true, first);
assertSame(true, second);
assertSame(true, third);
boolean max = false;
boolean min = false;
boolean mean = false;
if (SLOWEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getMax())
max = true;
if (FASTEST_METHOD_EST == perfMap.get(REQUEST_FILTER_TEST_URI).getMin())
min = true;
long meanVal = (FASTEST_METHOD_EST + MIDDLE_METHOD_EST + SLOWEST_METHOD_EST) / 3;
if (meanVal == perfMap.get(REQUEST_FILTER_TEST_URI).getMean())
mean = true;
assertSame(true, max);
assertSame(true, min);
assertSame(true, mean);
}
use of com.evolveum.midpoint.util.aspect.ProfilingDataManager in project midpoint by Evolveum.
the class ProfilingTest method prof_04_testMaxEventsInList.
@Test
public void prof_04_testMaxEventsInList() {
//Here, we create 7 events
ProfilingDataManager manager = ProfilingDataManager.getInstance();
ProfilingDataLog event1 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", FASTEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event2 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", MIDDLE_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event3 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event4 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event5 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event6 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
ProfilingDataLog event7 = new ProfilingDataLog("GET", REQUEST_FILTER_TEST_URI, "sessionID", SLOWEST_METHOD_EST, System.currentTimeMillis());
manager.prepareRequestProfilingEvent(event1);
manager.prepareRequestProfilingEvent(event2);
manager.prepareRequestProfilingEvent(event3);
manager.prepareRequestProfilingEvent(event4);
manager.prepareRequestProfilingEvent(event5);
manager.prepareRequestProfilingEvent(event6);
manager.prepareRequestProfilingEvent(event7);
//Only 5 slowest requests should be saved in methodList
assertNotSame(7, manager.getPerformanceMap().get(REQUEST_FILTER_TEST_URI).getSlowestMethodList().size());
}
use of com.evolveum.midpoint.util.aspect.ProfilingDataManager in project midpoint by Evolveum.
the class TestLdap method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
modelService.postInit(initResult);
// System Configuration
PrismObject<SystemConfigurationType> config;
try {
config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
}
// to get profiling facilities (until better API is available)
// LoggingConfigurationManager.configure(
// ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
// config.asObjectable().getVersion(), initResult);
// administrator
PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
login(userAdministrator);
// Users
repoAddObjectFromFile(USER_BARBOSSA_FILE, initResult);
repoAddObjectFromFile(USER_GUYBRUSH_FILE, initResult);
// Roles
repoAddObjectFromFile(ROLE_PIRATE_FILE, initResult);
// Resources
resourceOpenDj = importAndGetObjectFromFile(ResourceType.class, RESOURCE_OPENDJ_FILE, RESOURCE_OPENDJ_OID, initTask, initResult);
resourceOpenDjType = resourceOpenDj.asObjectable();
openDJController.setResource(resourceOpenDj);
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
//initProfiling - start
ProfilingDataManager profilingManager = ProfilingDataManager.getInstance();
Map<ProfilingDataManager.Subsystem, Boolean> subsystems = new HashMap<>();
subsystems.put(ProfilingDataManager.Subsystem.MODEL, true);
subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true);
profilingManager.configureProfilingDataManagerForTest(subsystems, true);
profilingManager.appendProfilingToTest();
//initProfiling - end
display("initial LDAP content", openDJController.dumpEntries());
}
use of com.evolveum.midpoint.util.aspect.ProfilingDataManager in project midpoint by Evolveum.
the class AbstractLdapTest method initSystem.
@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
super.initSystem(initTask, initResult);
// System Configuration
PrismObject<SystemConfigurationType> config;
try {
config = repoAddObjectFromFile(SYSTEM_CONFIGURATION_FILE, initResult);
} catch (ObjectAlreadyExistsException e) {
throw new ObjectAlreadyExistsException("System configuration already exists in repository;" + "looks like the previous test haven't cleaned it up", e);
}
modelService.postInit(initResult);
// to get profiling facilities (until better API is available)
// LoggingConfigurationManager.configure(
// ProfilingConfigurationManager.checkSystemProfilingConfiguration(config),
// config.asObjectable().getVersion(), initResult);
// administrator
PrismObject<UserType> userAdministrator = repoAddObjectFromFile(USER_ADMINISTRATOR_FILE, initResult);
repoAddObjectFromFile(ROLE_SUPERUSER_FILE, initResult);
login(userAdministrator);
// Resources
if (isImportResourceAtInit()) {
resource = importAndGetObjectFromFile(ResourceType.class, getResourceFile(), getResourceOid(), initTask, initResult);
resourceType = resource.asObjectable();
}
assumeAssignmentPolicy(AssignmentPolicyEnforcementType.RELATIVE);
//initProfiling - start
ProfilingDataManager profilingManager = ProfilingDataManager.getInstance();
Map<ProfilingDataManager.Subsystem, Boolean> subsystems = new HashMap<>();
subsystems.put(ProfilingDataManager.Subsystem.MODEL, true);
subsystems.put(ProfilingDataManager.Subsystem.REPOSITORY, true);
profilingManager.configureProfilingDataManagerForTest(subsystems, true);
profilingManager.appendProfilingToTest();
//initProfiling - end
ciMatchingRule = matchingRuleRegistry.getMatchingRule(StringIgnoreCaseMatchingRule.NAME, DOMUtil.XSD_STRING);
dnMatchingRule = matchingRuleRegistry.getMatchingRule(DistinguishedNameMatchingRule.NAME, DOMUtil.XSD_STRING);
logTrustManagers();
if (isAssertOpenFiles()) {
lsof = new Lsof(TestUtil.getPid());
}
}
use of com.evolveum.midpoint.util.aspect.ProfilingDataManager in project midpoint by Evolveum.
the class ProfilingTest method prof_02_profManagerConfigurationTest.
@Test
public void prof_02_profManagerConfigurationTest() {
Map<ProfilingDataManager.Subsystem, Boolean> profMap = new HashMap<>();
profMap.put(ProfilingDataManager.Subsystem.MODEL, true);
profMap.put(ProfilingDataManager.Subsystem.PROVISIONING, false);
profMap.put(ProfilingDataManager.Subsystem.REPOSITORY, false);
profMap.put(ProfilingDataManager.Subsystem.SYNCHRONIZATION_SERVICE, false);
profMap.put(ProfilingDataManager.Subsystem.TASK_MANAGER, false);
profMap.put(ProfilingDataManager.Subsystem.UCF, false);
profMap.put(ProfilingDataManager.Subsystem.WORKFLOW, false);
profMap.put(ProfilingDataManager.Subsystem.WEB, false);
ProfilingDataManager.getInstance().configureProfilingDataManager(profMap, TEST_MINUTE_DUMP_INTERVAL, true, false, false);
ProfilingDataManager profManager = ProfilingDataManager.getInstance();
assertSame(profManager.getMinuteDumpInterval(), TEST_MINUTE_DUMP_INTERVAL);
}
Aggregations