use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.
the class SqaleRepoSearchIterativeTest method test115SearchIterativeWithBreakingConditionCheckingOidOrdering.
@Test
public void test115SearchIterativeWithBreakingConditionCheckingOidOrdering() throws Exception {
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
String midOid = "80000000-0000-0000-0000-000000000000";
given("condition that breaks iterative search based on UUID");
testHandler.setStoppingPredicate(u -> u.getOid().compareTo(midOid) >= 0);
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.getCounter());
// extremely likely with enough items
assertThat(metadata.isPartialResults()).isTrue();
and("search operations were called");
assertOperationRecordedCount(REPO_OP_PREFIX + RepositoryService.OP_SEARCH_OBJECTS_ITERATIVE, 1);
assertTypicalPageOperationCount(metadata);
and("all objects up to specified UUID were processed");
QUser u = aliasFor(QUser.class);
assertThat(testHandler.getCounter()).isEqualTo(count(u, u.oid.lt(UUID.fromString(midOid))) + 1);
}
use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.
the class SqaleRepoSmokeTest method test110DeleteObject.
@Test
public void test110DeleteObject() throws Exception {
OperationResult result = createOperationResult();
given("existing user");
UserType user = new UserType(prismContext).name("user" + getTestNumber());
String userOid = repositoryService.addObject(user.asPrismObject(), null, result);
and("cleared performance information");
SqlPerformanceMonitorImpl pm = repositoryService.getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
when("user is deleted from the repository");
DeleteObjectResult deleteResult = repositoryService.deleteObject(UserType.class, userOid, result);
then("added object is assigned OID and operation is success");
assertThat(deleteResult).isNotNull();
assertThatOperationResult(result).isSuccess();
assertThat(selectNullableObjectByOid(QUser.class, userOid)).isNull();
assertSingleOperationRecorded(REPO_OP_PREFIX + RepositoryService.OP_DELETE_OBJECT);
}
use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.
the class SqaleRepoSmokeTest method test210GetVersion.
@Test
public void test210GetVersion() throws Exception {
OperationResult result = createOperationResult();
given("existing user and cleared performance information");
UserType user = new UserType(prismContext).name("user" + getTestNumber());
String userOid = repositoryService.addObject(user.asPrismObject(), null, result);
SqlPerformanceMonitorImpl pm = repositoryService.getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
when("getVersion is called for known OID");
String version = repositoryService.getVersion(UserType.class, userOid, result);
then("non-null version string is obtained and performance monitor is updated");
assertThatOperationResult(result).isSuccess();
assertThat(version).isNotNull();
assertSingleOperationRecorded(REPO_OP_PREFIX + RepositoryService.OP_GET_VERSION);
}
use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.
the class SqaleRepoSearchIterativeTest method test111SearchIterativeWithLastPageNotFull.
@Test
public void test111SearchIterativeWithLastPageNotFull() throws Exception {
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
given("total result count not multiple of the page size");
long totalCount = count(QObject.CLASS);
int iterativePageSize = 47;
repositoryConfiguration.setIterativeSearchByPagingBatchSize(iterativePageSize);
assertThat(totalCount % repositoryConfiguration.getIterativeSearchByPagingBatchSize()).isNotZero();
queryRecorder.clearBufferAndStartRecording();
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 were processed");
assertThat(testHandler.getCounter()).isEqualTo(count(QUser.class));
and("last iteration query has proper conditions");
List<SqlRecorder.QueryEntry> iterativeSelects = queryRecorder.getQueryBuffer().stream().filter(e -> e.sql.contains("order by u.oid asc")).collect(Collectors.toList());
// +1 for the last page
assertThat(iterativeSelects).hasSize((int) totalCount / iterativePageSize + 1);
SqlRecorder.QueryEntry lastEntry = iterativeSelects.get(iterativeSelects.size() - 1);
// we want to be sure no accidental filter accumulation happens
assertThat(lastEntry.sql).contains("where u.oid > ?\norder by u.oid asc");
}
use of com.evolveum.midpoint.repo.sqlbase.perfmon.SqlPerformanceMonitorImpl in project midpoint by Evolveum.
the class SqaleRepoSearchIterativeTest method test112SearchIterativeWithLastPageNotFullWithAndFilter.
@Test
public void test112SearchIterativeWithLastPageNotFullWithAndFilter() throws Exception {
// Like test111 but detects error when conditions are accumulating in provided AND filter with each page.
OperationResult operationResult = createOperationResult();
SqlPerformanceMonitorImpl pm = getPerformanceMonitor();
pm.clearGlobalPerformanceInformation();
given("total result count not multiple of the page size");
long totalCount = count(QUser.class);
int iterativePageSize = 47;
repositoryConfiguration.setIterativeSearchByPagingBatchSize(iterativePageSize);
assertThat(totalCount % repositoryConfiguration.getIterativeSearchByPagingBatchSize()).isNotZero();
queryRecorder.clearBufferAndStartRecording();
when("calling search iterative with query containing condition");
SearchResultMetadata metadata = searchObjectsIterative(prismContext.queryFor(UserType.class).not().item(UserType.F_NAME).isNull().and().item(UserType.F_GIVEN_NAME).isNull().build(), 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 were processed");
assertThat(testHandler.getCounter()).isEqualTo(count(QUser.class));
and("last iteration query has proper conditions");
List<SqlRecorder.QueryEntry> iterativeSelects = queryRecorder.getQueryBuffer().stream().filter(e -> e.sql.contains("order by u.oid asc")).collect(Collectors.toList());
// +1 for the last page
assertThat(iterativeSelects).hasSize((int) totalCount / iterativePageSize + 1);
SqlRecorder.QueryEntry lastEntry = iterativeSelects.get(iterativeSelects.size() - 1);
// We want to be sure no accidental filter accumulation happens, see ObjectQueryUtil.filterAnd() vs createAnd().
assertThat(lastEntry.sql).contains("where not (u.nameNorm is null and u.nameOrig is null)" + " and (u.givenNameNorm is null and u.givenNameOrig is null) and u.oid > ?\norder");
}
Aggregations