Search in sources :

Example 1 with ConnectorOperationalStatus

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);
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)

Example 2 with ConnectorOperationalStatus

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();
}
Also used : Task(com.evolveum.midpoint.task.api.Task) DummyConnector(com.evolveum.icf.dummy.connector.DummyConnector) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) Test(org.testng.annotations.Test)

Example 3 with ConnectorOperationalStatus

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());
}
Also used : DummyConnector(com.evolveum.icf.dummy.connector.DummyConnector) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) Test(org.testng.annotations.Test)

Example 4 with ConnectorOperationalStatus

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);
}
Also used : ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.provisioning.ucf.api.ResultHandler) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) PrismObject(com.evolveum.midpoint.prism.PrismObject) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) Test(org.testng.annotations.Test)

Example 5 with ConnectorOperationalStatus

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());
}
Also used : PrismObject(com.evolveum.midpoint.prism.PrismObject) ShadowType(com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType) ArrayList(java.util.ArrayList) ObjectClassComplexTypeDefinition(com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ResultHandler(com.evolveum.midpoint.provisioning.ucf.api.ResultHandler) ConnectorOperationalStatus(com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test)

Aggregations

ConnectorOperationalStatus (com.evolveum.midpoint.schema.statistics.ConnectorOperationalStatus)14 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)9 Test (org.testng.annotations.Test)6 Task (com.evolveum.midpoint.task.api.Task)4 ArrayList (java.util.ArrayList)4 DummyConnector (com.evolveum.icf.dummy.connector.DummyConnector)3 PrismObject (com.evolveum.midpoint.prism.PrismObject)3 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)3 ResultHandler (com.evolveum.midpoint.provisioning.ucf.api.ResultHandler)3 ObjectClassComplexTypeDefinition (com.evolveum.midpoint.schema.processor.ObjectClassComplexTypeDefinition)3 CommunicationException (com.evolveum.midpoint.util.exception.CommunicationException)3 ConfigurationException (com.evolveum.midpoint.util.exception.ConfigurationException)3 ExpressionEvaluationException (com.evolveum.midpoint.util.exception.ExpressionEvaluationException)3 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)3 ResourceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ResourceType)2 ConnectorInstance (com.evolveum.midpoint.provisioning.ucf.api.ConnectorInstance)1 List (java.util.List)1 Label (org.apache.wicket.markup.html.basic.Label)1