use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LogIndexerService method indexLaunchLogs.
@Override
@Transactional(readOnly = true)
public // TODO Probably we should implement AsyncLogIndexer and use this service as sync delegate with transaction
CompletableFuture<Long> indexLaunchLogs(Long projectId, Long launchId, AnalyzerConfig analyzerConfig) {
return CompletableFuture.supplyAsync(() -> {
try {
indexerStatusCache.indexingStarted(projectId);
Launch launch = launchRepository.findById(launchId).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, launchId));
Optional<IndexLaunch> indexLaunch = launchPreparerService.prepare(launch, testItemRepository.findTestItemsByLaunchId(launch.getId()), analyzerConfig);
return indexLaunch.map(it -> {
LOGGER.info("Start indexing for {} launches", 1);
Long indexed = indexerServiceClient.index(Lists.newArrayList(it));
LOGGER.info("Indexed {} logs", indexed);
return indexed;
}).orElse(0L);
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
throw new ReportPortalException(e.getMessage());
} finally {
indexerStatusCache.indexingFinished(projectId);
}
});
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class SearchLogServiceImpl method composeRequest.
private Optional<SearchRq> composeRequest(SearchLogRq request, Project project, TestItem item, Launch launch) {
SearchLogsMode searchMode = SearchLogsMode.fromString(request.getSearchMode()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, request.getSearchMode()));
SearchRq searchRq = new SearchRq();
searchRq.setFilteredLaunchIds(searchCollectorFactory.getCollector(searchMode).collect(request.getFilterId(), launch));
// TODO fix query - select messages from `Nested Step` descendants too
List<String> logMessages = logRepository.findMessagesByLaunchIdAndItemIdAndPathAndLevelGte(launch.getId(), item.getItemId(), item.getPath(), LogLevel.ERROR_INT);
if (CollectionUtils.isEmpty(logMessages)) {
return Optional.empty();
}
searchRq.setLogMessages(logMessages);
final AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
searchRq.setAnalyzerConfig(analyzerConfig);
searchRq.setLogLines(analyzerConfig.getNumberOfLogLines());
searchRq.setItemId(item.getItemId());
searchRq.setLaunchId(launch.getId());
searchRq.setLaunchName(launch.getName());
searchRq.setProjectId(project.getId());
return Optional.of(searchRq);
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LaunchAutoAnalysisStrategy method analyze.
public void analyze(AnalyzeLaunchRQ analyzeRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
expect(analyzerServiceAsync.hasAnalyzers(), Predicate.isEqual(true)).verify(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "There are no analyzer services are deployed.");
AnalyzeMode analyzeMode = AnalyzeMode.fromString(analyzeRQ.getAnalyzerHistoryMode()).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, analyzeRQ.getAnalyzerHistoryMode()));
Launch launch = launchRepository.findById(analyzeRQ.getLaunchId()).orElseThrow(() -> new ReportPortalException(LAUNCH_NOT_FOUND, analyzeRQ.getLaunchId()));
validateLaunch(launch, projectDetails);
Project project = projectRepository.findById(projectDetails.getProjectId()).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectDetails.getProjectId()));
AnalyzerConfig analyzerConfig = getAnalyzerConfig(project);
analyzerConfig.setAnalyzerMode(analyzeMode.getValue());
List<Long> itemIds = collectItemsByModes(launch.getId(), analyzeRQ.getAnalyzeItemsModes(), project, user);
eventPublisher.publishEvent(new AnalysisEvent(launch, itemIds, analyzerConfig));
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class AnalyzerUtils method getAnalyzerConfig.
public static AnalyzerConfig getAnalyzerConfig(Project project) {
Map<String, String> configParameters = ProjectUtils.getConfigParameters(project.getProjectAttributes());
AnalyzerConfig analyzerConfig = new AnalyzerConfig();
analyzerConfig.setIsAutoAnalyzerEnabled(BooleanUtils.toBoolean(configParameters.get(AUTO_ANALYZER_ENABLED.getAttribute())));
analyzerConfig.setMinShouldMatch(Integer.valueOf(ofNullable(configParameters.get(MIN_SHOULD_MATCH.getAttribute())).orElse(MIN_SHOULD_MATCH.getDefaultValue())));
analyzerConfig.setSearchLogsMinShouldMatch(Integer.valueOf(ofNullable(configParameters.get(SEARCH_LOGS_MIN_SHOULD_MATCH.getAttribute())).orElse(SEARCH_LOGS_MIN_SHOULD_MATCH.getDefaultValue())));
analyzerConfig.setNumberOfLogLines(Integer.valueOf(ofNullable(configParameters.get(NUMBER_OF_LOG_LINES.getAttribute())).orElse(NUMBER_OF_LOG_LINES.getDefaultValue())));
analyzerConfig.setIndexingRunning(BooleanUtils.toBoolean(configParameters.get(INDEXING_RUNNING.getAttribute())));
analyzerConfig.setAnalyzerMode(configParameters.get(AUTO_ANALYZER_MODE.getAttribute()));
analyzerConfig.setAllMessagesShouldMatch(BooleanUtils.toBoolean(configParameters.get(ALL_MESSAGES_SHOULD_MATCH.getAttribute())));
return analyzerConfig;
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LogIndexerServiceTest method testIndexWithZeroCount.
@Test
void testIndexWithZeroCount() {
Long launchId = 2L;
final IndexLaunch indexLaunch = new IndexLaunch();
indexLaunch.setLaunchId(launchId);
when(batchLogIndexer.index(eq(1L), any(AnalyzerConfig.class))).thenReturn(0L);
Long result = logIndexerService.index(1L, analyzerConfig()).join();
assertThat(result, org.hamcrest.Matchers.equalTo(0L));
verify(indexerStatusCache, times(1)).indexingFinished(1L);
}
Aggregations