use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.
the class TestConnectorMultiInstance method assertConnectorInstances.
private void assertConnectorInstances(String msg, String resourceOid, int expectedActive, int expectedIdle) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
Task task = taskManager.createTaskInstance(TestConnectorMultiInstance.class.getName() + ".assertConnectorInstances");
OperationResult result = task.getResult();
List<ConnectorOperationalStatus> opStats = modelInteractionService.getConnectorOperationalStatus(resourceOid, task, result);
display("connector stats " + msg, opStats);
assertConnectorInstances(msg, opStats.get(0), expectedActive, expectedIdle);
}
use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.
the class AbstractBasicDummyTest method test090ConnectorStatsAfterSomeUse.
@Test
public void test090ConnectorStatsAfterSomeUse() throws Exception {
final String TEST_NAME = "test090ConnectorStatsAfterSomeUse";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
Task task = createTask(TEST_NAME);
OperationResult result = task.getResult();
// WHEN
List<ConnectorOperationalStatus> operationalStatuses = provisioningService.getConnectorOperationalStatus(RESOURCE_DUMMY_OID, task, result);
// THEN
result.computeStatus();
TestUtil.assertSuccess(result);
display("Connector operational status", operationalStatuses);
assertNotNull("null operational status", operationalStatuses);
assertEquals("Unexpected size of operational status", 1, operationalStatuses.size());
ConnectorOperationalStatus operationalStatus = operationalStatuses.get(0);
assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName());
assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize());
assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize());
assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle());
assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle());
assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout());
assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime());
assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle());
assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive());
assertSteadyResource();
}
use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.
the class TestUcfDummy method test033ConnectorStatsInitialized.
@Test
public void test033ConnectorStatsInitialized() throws Exception {
final String TEST_NAME = "test033ConnectorStatsInitialized";
TestUtil.displayTestTile(TEST_NAME);
// WHEN
ConnectorOperationalStatus operationalStatus = cc.getOperationalStatus();
// THEN
display("Connector operational status", operationalStatus);
assertNotNull("null operational status", operationalStatus);
assertEquals("Wrong connectorClassName", DummyConnector.class.getName(), operationalStatus.getConnectorClassName());
assertEquals("Wrong poolConfigMinSize", null, operationalStatus.getPoolConfigMinSize());
assertEquals("Wrong poolConfigMaxSize", (Integer) 10, operationalStatus.getPoolConfigMaxSize());
assertEquals("Wrong poolConfigMinIdle", (Integer) 1, operationalStatus.getPoolConfigMinIdle());
assertEquals("Wrong poolConfigMaxIdle", (Integer) 10, operationalStatus.getPoolConfigMaxIdle());
assertEquals("Wrong poolConfigWaitTimeout", (Long) 150000L, operationalStatus.getPoolConfigWaitTimeout());
assertEquals("Wrong poolConfigMinEvictableIdleTime", (Long) 120000L, operationalStatus.getPoolConfigMinEvictableIdleTime());
assertEquals("Wrong poolStatusNumIdle", (Integer) 1, operationalStatus.getPoolStatusNumIdle());
assertEquals("Wrong poolStatusNumActive", (Integer) 0, operationalStatus.getPoolStatusNumActive());
}
use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.
the class TestUcfDummyMulti method test210TwoBlockingSearches.
@Test
public void test210TwoBlockingSearches() throws Exception {
final String TEST_NAME = "test210TwoBlockingSearches";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
// Determine object class from the schema
final OperationResult result1 = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
final List<PrismObject<ShadowType>> searchResults1 = new ArrayList<PrismObject<ShadowType>>();
final ResultHandler<ShadowType> handler1 = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> shadow) {
checkUcfShadow(shadow, accountDefinition);
searchResults1.add(shadow);
return true;
}
};
final OperationResult result2 = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
final List<PrismObject<ShadowType>> searchResults2 = new ArrayList<PrismObject<ShadowType>>();
final ResultHandler<ShadowType> handler2 = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> shadow) {
checkUcfShadow(shadow, accountDefinition);
searchResults2.add(shadow);
return true;
}
};
dummyResource.setBlockOperations(true);
// WHEN
Thread t1 = new Thread(new Runnable() {
@Override
public void run() {
try {
cc.search(accountDefinition, new ObjectQuery(), handler1, null, null, null, null, result1);
} catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
LOGGER.error("Error in the search: {}", e.getMessage(), e);
}
}
});
t1.setName("search1");
t1.start();
// Give the new thread a chance to get blocked
Thread.sleep(500);
ConnectorOperationalStatus opStat = cc.getOperationalStatus();
display("stats (blocked 1)", opStat);
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
assertEquals("Unexpected number of search results", 0, searchResults1.size());
Thread t2 = new Thread(new Runnable() {
@Override
public void run() {
try {
cc.search(accountDefinition, new ObjectQuery(), handler2, null, null, null, null, result2);
} catch (CommunicationException | GenericFrameworkException | SchemaException | SecurityViolationException | ObjectNotFoundException e) {
LOGGER.error("Error in the search: {}", e.getMessage(), e);
}
}
});
t2.setName("search2");
t2.start();
// Give the new thread a chance to get blocked
Thread.sleep(500);
opStat = cc.getOperationalStatus();
display("stats (blocked 2)", opStat);
assertEquals("Wrong pool active", (Integer) 2, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumIdle());
assertEquals("Unexpected number of search results", 0, searchResults1.size());
dummyResource.unblockAll();
t1.join();
t2.join();
dummyResource.setBlockOperations(false);
// THEN
assertEquals("Unexpected number of search results 1", 1, searchResults1.size());
assertEquals("Unexpected number of search results 2", 1, searchResults2.size());
opStat = cc.getOperationalStatus();
display("stats (final)", opStat);
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 2, opStat.getPoolStatusNumIdle());
PrismObject<ShadowType> searchResult1 = searchResults1.get(0);
display("Search result 1", searchResult1);
PrismObject<ShadowType> searchResult2 = searchResults2.get(0);
display("Search result 2", searchResult2);
}
use of com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus in project midpoint by Evolveum.
the class TestUcfDummyMulti method test110SearchNonBlocking.
@Test
public void test110SearchNonBlocking() throws Exception {
final String TEST_NAME = "test100SearchNonBlocking";
TestUtil.displayTestTile(TEST_NAME);
// GIVEN
final ObjectClassComplexTypeDefinition accountDefinition = resourceSchema.findDefaultObjectClassDefinition(ShadowKindType.ACCOUNT);
// Determine object class from the schema
final List<PrismObject<ShadowType>> searchResults = new ArrayList<PrismObject<ShadowType>>();
ResultHandler<ShadowType> handler = new ResultHandler<ShadowType>() {
@Override
public boolean handle(PrismObject<ShadowType> shadow) {
System.out.println("Search: found: " + shadow);
checkUcfShadow(shadow, accountDefinition);
searchResults.add(shadow);
return true;
}
};
OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME);
// WHEN
cc.search(accountDefinition, new ObjectQuery(), handler, null, null, null, null, result);
// THEN
assertEquals("Unexpected number of search results", 1, searchResults.size());
ConnectorOperationalStatus opStat = cc.getOperationalStatus();
display("stats", opStat);
assertEquals("Wrong pool active", (Integer) 0, opStat.getPoolStatusNumActive());
assertEquals("Wrong pool active", (Integer) 1, opStat.getPoolStatusNumIdle());
}
Aggregations