Search in sources :

Example 41 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class SqaleAuditSearchIterativeTest method test100SearchIterativeWithNoneFilter.

@Test
public void test100SearchIterativeWithNoneFilter() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with top level NONE filter");
    ObjectQuery query = prismContext.queryFor(UserType.class).none().build();
    when("calling search iterative");
    SearchResultMetadata searchResultMetadata = searchObjectsIterative(query, operationResult);
    then("no operation is performed");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(searchResultMetadata).isNotNull();
    assertThat(searchResultMetadata.getApproxNumberOfAllResults()).isZero();
    // this is not the main part, just documenting that currently we short circuit the operation
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 0);
    // this is important - no actual search was called
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE_PAGE, 0);
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 42 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class SqaleAuditSearchIterativeTest method test115SearchIterativeWithBreakingConditionCheckingOidOrdering.

@Test
public void test115SearchIterativeWithBreakingConditionCheckingOidOrdering() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("condition that breaks iterative search based on parameter (count)");
    testHandler.setStoppingPredicate(aer -> aer.getParameter().equals(paramString(ITERATION_PAGE_SIZE)));
    when("calling search iterative with null query");
    SearchResultMetadata metadata = searchObjectsIterative(null, operationResult);
    then("result metadata is not null and reports partial result (because of the break)");
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.processedCount());
    // extremely likely with enough items
    assertThat(metadata.isPartialResults()).isTrue();
    and("search operations were called");
    assertOperationRecordedCount(AUDIT_OP_PREFIX + AuditService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects up to specified parameter value were processed");
    assertThat(testHandler.processedCount()).isEqualTo(count(aer, aer.parameter.loe(paramString(ITERATION_PAGE_SIZE))));
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 43 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class SqaleRepoSearchIterativeTest method test125SearchIterativeWithCustomOrdering.

@Test
public void test125SearchIterativeWithCustomOrdering() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with custom ordering");
    ObjectQuery query = prismContext.queryFor(UserType.class).asc(UserType.F_COST_CENTER).maxSize(// see the limit below
    47).build();
    when("calling search iterative");
    SearchResultMetadata metadata = searchObjectsIterative(query, operationResult);
    then("result metadata is not null and reports partial result (because of the break)");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.getCounter());
    // everything was processed
    assertThat(metadata.isPartialResults()).isFalse();
    and("search operations were called");
    assertOperationRecordedCount(REPO_OP_PREFIX + RepositoryService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects were processed in proper order");
    QUser u = aliasFor(QUser.class);
    try (JdbcSession jdbcSession = startReadOnlyTransaction()) {
        List<String> result = jdbcSession.newQuery().from(u).orderBy(u.costCenter.asc(), u.oid.asc()).select(u.employeeNumber).limit(// must match the maxSize above
        47).fetch();
        for (int i = 1; i < result.size(); i++) {
            // order matches
            assertThat(result.get(i)).isEqualTo(getTestNumber() + "-" + i);
        }
    }
}
Also used : JdbcSession(com.evolveum.midpoint.repo.sqlbase.JdbcSession) QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) UserType(com.evolveum.midpoint.xml.ns._public.common.common_3.UserType) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 44 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class SqaleRepoSearchIterativeTest method test120SearchIterativeWithMaxSize.

@Test
public void test120SearchIterativeWithMaxSize() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    given("query with maxSize specified");
    ObjectQuery query = prismContext.queryFor(UserType.class).maxSize(101).build();
    when("calling search iterative");
    SearchResultMetadata metadata = searchObjectsIterative(query, operationResult);
    then("result metadata is not null and reports partial result (because of the break)");
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.getCounter());
    assertThat(metadata.isPartialResults()).isFalse();
    and("search operations were called");
    assertOperationRecordedCount(REPO_OP_PREFIX + RepositoryService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("specified amount of objects was processed");
    assertThat(testHandler.getCounter()).isEqualTo(101);
}
Also used : SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Example 45 with SearchResultMetadata

use of com.evolveum.midpoint.schema.SearchResultMetadata in project midpoint by Evolveum.

the class SqaleRepoSearchIterativeTest method test110SearchIterativeWithEmptyFilter.

@Test
public void test110SearchIterativeWithEmptyFilter() throws Exception {
    OperationResult operationResult = createOperationResult();
    SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
    pm.clearGlobalPerformanceInformation();
    when("calling search iterative with null query");
    SearchResultMetadata metadata = searchObjectsIterative(null, operationResult);
    then("result metadata is not null and reports the handled objects");
    assertThatOperationResult(operationResult).isSuccess();
    assertThat(metadata).isNotNull();
    assertThat(metadata.getApproxNumberOfAllResults()).isEqualTo(testHandler.getCounter());
    assertThat(metadata.isPartialResults()).isFalse();
    // page cookie is not null and it's OID in UUID format
    assertThat(UUID.fromString(metadata.getPagingCookie())).isNotNull();
    and("search operations were called");
    assertOperationRecordedCount(REPO_OP_PREFIX + RepositoryService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
    assertTypicalPageOperationCount(metadata);
    and("all objects of the specified type (here User) were processed");
    assertThat(testHandler.getCounter()).isEqualTo(count(QUser.class));
}
Also used : QUser(com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser) SqlPerformanceMonitorImpl(com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl) SearchResultMetadata(com.evolveum.midpoint.schema.SearchResultMetadata) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) Test(org.testng.annotations.Test) SqaleRepoBaseTest(com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)

Aggregations

SearchResultMetadata (com.evolveum.midpoint.schema.SearchResultMetadata)84 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)83 Test (org.testng.annotations.Test)80 ObjectQuery (com.evolveum.midpoint.prism.query.ObjectQuery)76 PrismObject (com.evolveum.midpoint.prism.PrismObject)70 Task (com.evolveum.midpoint.task.api.Task)67 ObjectPaging (com.evolveum.midpoint.prism.query.ObjectPaging)35 AbstractAdLdapTest (com.evolveum.midpoint.testing.conntest.ad.AbstractAdLdapTest)19 SqaleRepoBaseTest (com.evolveum.midpoint.repo.sqale.SqaleRepoBaseTest)13 SqlPerformanceMonitorImpl (com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl)13 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)11 AbstractIntegrationTest (com.evolveum.midpoint.test.AbstractIntegrationTest)9 AbstractLdapSynchronizationTest (com.evolveum.midpoint.testing.conntest.AbstractLdapSynchronizationTest)8 QUser (com.evolveum.midpoint.repo.sqale.qmodel.focus.QUser)5 JdbcSession (com.evolveum.midpoint.repo.sqlbase.JdbcSession)3 ResultHandler (com.evolveum.midpoint.schema.ResultHandler)3 SelectorOptions (com.evolveum.midpoint.schema.SelectorOptions)3 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)3 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3