use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class BatchLogIndexerTest method index.
@Test
void index() {
final List<Long> ids = List.of(1L, 2L);
when(launchRepository.findIdsByProjectIdAndModeAndStatusNotEq(eq(1L), any(JLaunchModeEnum.class), any(JStatusEnum.class), anyInt())).thenReturn(ids);
final IndexLaunch firstIndex = new IndexLaunch();
firstIndex.setTestItems(List.of(new IndexTestItem()));
final IndexLaunch secondIndex = new IndexLaunch();
secondIndex.setTestItems(List.of(new IndexTestItem()));
when(launchPreparerService.prepare(eq(ids), any(AnalyzerConfig.class))).thenReturn(List.of(firstIndex, secondIndex));
final List<Long> secondPortionIds = List.of(3L);
when(launchRepository.findIdsByProjectIdAndModeAndStatusNotEqAfterId(eq(1L), any(JLaunchModeEnum.class), any(JStatusEnum.class), eq(2L), anyInt())).thenReturn(secondPortionIds);
final IndexLaunch thirdIndex = new IndexLaunch();
thirdIndex.setTestItems(List.of(new IndexTestItem()));
when(launchPreparerService.prepare(eq(secondPortionIds), any(AnalyzerConfig.class))).thenReturn(List.of(thirdIndex));
batchLogIndexer.index(1L, analyzerConfig());
verify(indexerServiceClient, times(2)).index(anyList());
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class ConfigProvider method getConfig.
public static final GenerateClustersConfig getConfig(boolean forUpdate) {
final GenerateClustersConfig config = new GenerateClustersConfig();
final AnalyzerConfig analyzerConfig = new AnalyzerConfig();
analyzerConfig.setNumberOfLogLines(1);
config.setAnalyzerConfig(analyzerConfig);
config.setProject(1L);
config.setLaunchId(1L);
config.setForUpdate(forUpdate);
config.setCleanNumbers(false);
return config;
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class LogIndexerService method indexItemsLogs.
@Override
@Transactional(readOnly = true)
public // TODO same refactoring as for the method above
Long indexItemsLogs(Long projectId, Long launchId, List<Long> itemIds, AnalyzerConfig analyzerConfig) {
try {
indexerStatusCache.indexingStarted(projectId);
Launch launch = launchRepository.findById(launchId).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, launchId));
return launchPreparerService.prepare(launch, testItemRepository.findAllById(itemIds), analyzerConfig).map(it -> indexerServiceClient.index(Lists.newArrayList(it))).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 UpdateLaunchHandlerImpl method createClusters.
@Override
@Transactional
public OperationCompletionRS createClusters(CreateClustersRQ createClustersRQ, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
final Launch launch = getLaunchHandler.getLaunch(createClustersRQ.getLaunchId());
launchAccessValidator.validate(launch, projectDetails, user);
// TODO should be put inside *Validator after validators refactoring
expect(launch.getStatus(), not(statusIn(StatusEnum.IN_PROGRESS))).verify(INCORRECT_REQUEST, "Cannot analyze launch in progress.");
final Project project = getProjectHandler.getProject(projectDetails);
AnalyzerConfig analyzerConfig = getAnalyzerConfig(project);
final GenerateClustersConfig config = new GenerateClustersConfig();
config.setAnalyzerConfig(analyzerConfig);
config.setLaunchId(launch.getId());
config.setProject(project.getId());
config.setForUpdate(false);
config.setCleanNumbers(createClustersRQ.isRemoveNumbers());
clusterGenerator.generate(config);
return new OperationCompletionRS(Suppliers.formattedSupplier("Clusters generation for launch with ID='{}' started.", launch.getId()).get());
}
use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.
the class TestItemFinishedEventHandler method onApplicationEvent.
@Async
@Transactional(propagation = Propagation.REQUIRES_NEW)
@TransactionalEventListener
public void onApplicationEvent(ItemFinishedEvent itemFinishedEvent) {
Project project = projectRepository.findById(itemFinishedEvent.getProjectId()).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, itemFinishedEvent.getProjectId()));
AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
logIndexer.indexItemsLogs(itemFinishedEvent.getProjectId(), itemFinishedEvent.getLaunchId(), Lists.newArrayList(itemFinishedEvent.getItemId()), analyzerConfig);
}
Aggregations