use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class RecoveryIndexerTest method successfully_recover_indexing_requests.
@Test
public void successfully_recover_indexing_requests() {
EsQueueDto item1a = insertItem(FOO_TYPE, "f1");
EsQueueDto item1b = insertItem(FOO_TYPE, "f2");
IndexMainType type2 = IndexType.main(Index.simple("bars"), "bar");
EsQueueDto item2 = insertItem(type2, "b1");
SuccessfulFakeIndexer indexer1 = new SuccessfulFakeIndexer(FOO_TYPE);
SuccessfulFakeIndexer indexer2 = new SuccessfulFakeIndexer(type2);
advanceInTime();
underTest = newRecoveryIndexer(indexer1, indexer2);
underTest.recover();
assertThatQueueHasSize(0);
assertThatLogsContain(INFO, "Elasticsearch recovery - 3 documents processed [0 failures]");
assertThat(indexer1.called).hasSize(1);
assertThat(indexer1.called.get(0)).extracting(EsQueueDto::getUuid).containsExactlyInAnyOrder(item1a.getUuid(), item1b.getUuid());
assertThatLogsContain(TRACE, "Elasticsearch recovery - processing 2 [foos/foo]");
assertThat(indexer2.called).hasSize(1);
assertThat(indexer2.called.get(0)).extracting(EsQueueDto::getUuid).containsExactlyInAnyOrder(item2.getUuid());
assertThatLogsContain(TRACE, "Elasticsearch recovery - processing 1 [bars/bar]");
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class RecoveryIndexerTest method failing_always_on_same_document_does_not_generate_infinite_loop.
@Test
public void failing_always_on_same_document_does_not_generate_infinite_loop() {
EsQueueDto buggy = insertItem(FOO_TYPE, "buggy");
IntStream.range(0, 10).forEach(i -> insertItem(FOO_TYPE, "" + i));
advanceInTime();
FailingAlwaysOnSameElementIndexer indexer = new FailingAlwaysOnSameElementIndexer(FOO_TYPE, buggy);
underTest = newRecoveryIndexer(indexer);
underTest.recover();
assertThatLogsContain(ERROR, "Elasticsearch recovery - too many failures [1/1 documents], waiting for next run");
assertThatQueueHasSize(1);
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class IssueIndexerTest method recovery_does_not_fail_if_unsupported_docIdType.
@Test
public void recovery_does_not_fail_if_unsupported_docIdType() {
EsQueueDto item = EsQueueDto.create(TYPE_ISSUE.format(), "I1", "unknown", "P1");
db.getDbClient().esQueueDao().insert(db.getSession(), item);
db.commit();
recover();
assertThat(logTester.logs(LoggerLevel.ERROR)).filteredOn(l -> l.contains("Unsupported es_queue.doc_id_type for issues. Manual fix is required: ")).hasSize(1);
assertThatEsQueueTableHasSize(1);
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class PermissionIndexerTest method indexPermissions.
private IndexingResult indexPermissions(ComponentDto project, ProjectIndexer.Cause cause) {
DbSession dbSession = db.getSession();
Collection<EsQueueDto> items = underTest.prepareForRecovery(dbSession, singletonList(project.uuid()), cause);
dbSession.commit();
return underTest.index(dbSession, items);
}
use of org.sonar.db.es.EsQueueDto in project sonarqube by SonarSource.
the class OneToManyResilientIndexingListenerTest method ES_QUEUE_rows_are_not_deleted_on_partial_error.
@Test
public void ES_QUEUE_rows_are_not_deleted_on_partial_error() {
EsQueueDto item1 = insertInQueue(TYPE_ISSUE, "P1");
EsQueueDto item2 = insertInQueue(TYPE_ISSUE, "P2");
EsQueueDto outOfScopeItem = insertInQueue(ComponentIndexDefinition.TYPE_COMPONENT, "P1");
db.commit();
// does not contain outOfScopeItem
IndexingListener underTest = newListener(asList(item1, item2));
DocId issue1 = newDocId(TYPE_ISSUE, "I1");
DocId issue2 = newDocId(TYPE_ISSUE, "I2");
underTest.onSuccess(asList(issue1, issue2));
assertThatEsTableContainsOnly(item1, item2, outOfScopeItem);
// one failure among the 2 indexing requests of issues
IndexingResult result = new IndexingResult();
result.incrementSuccess().incrementRequests();
result.incrementRequests();
underTest.onFinish(result);
assertThatEsTableContainsOnly(item1, item2, outOfScopeItem);
}
Aggregations