Search in sources :

Example 6 with AnalyzerConfig

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());
}
Also used : JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) JLaunchModeEnum(com.epam.ta.reportportal.jooq.enums.JLaunchModeEnum) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) Test(org.junit.jupiter.api.Test)

Example 7 with AnalyzerConfig

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;
}
Also used : AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig)

Example 8 with AnalyzerConfig

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);
    }
}
Also used : Async(org.springframework.scheduling.annotation.Async) IndexerStatusCache(com.epam.ta.reportportal.core.analyzer.auto.indexer.IndexerStatusCache) TestItem(com.epam.ta.reportportal.entity.item.TestItem) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) CompletableFuture(java.util.concurrent.CompletableFuture) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) Lists(com.google.common.collect.Lists) BatchLogIndexer(com.epam.ta.reportportal.core.analyzer.auto.indexer.BatchLogIndexer) Service(org.springframework.stereotype.Service) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) TaskExecutor(org.springframework.core.task.TaskExecutor) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) LaunchPreparerService(com.epam.ta.reportportal.core.analyzer.auto.impl.preparer.LaunchPreparerService) Logger(org.slf4j.Logger) Launch(com.epam.ta.reportportal.entity.launch.Launch) LogIndexer(com.epam.ta.reportportal.core.analyzer.auto.LogIndexer) Collection(java.util.Collection) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) Collectors(java.util.stream.Collectors) List(java.util.List) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) CollectionUtils(org.springframework.util.CollectionUtils) IndexerServiceClient(com.epam.ta.reportportal.core.analyzer.auto.client.IndexerServiceClient) Optional(java.util.Optional) Transactional(org.springframework.transaction.annotation.Transactional) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with AnalyzerConfig

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());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) AnalyzerUtils.getAnalyzerConfig(com.epam.ta.reportportal.core.analyzer.auto.impl.AnalyzerUtils.getAnalyzerConfig) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) Launch(com.epam.ta.reportportal.entity.launch.Launch) GenerateClustersConfig(com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) Transactional(org.springframework.transaction.annotation.Transactional)

Example 10 with AnalyzerConfig

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);
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Async(org.springframework.scheduling.annotation.Async) TransactionalEventListener(org.springframework.transaction.event.TransactionalEventListener) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

AnalyzerConfig (com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)18 IndexLaunch (com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch)6 Test (org.junit.jupiter.api.Test)6 Launch (com.epam.ta.reportportal.entity.launch.Launch)5 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)5 Project (com.epam.ta.reportportal.entity.project.Project)4 Transactional (org.springframework.transaction.annotation.Transactional)4 LaunchPreparerService (com.epam.ta.reportportal.core.analyzer.auto.impl.preparer.LaunchPreparerService)3 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)3 TestItem (com.epam.ta.reportportal.entity.item.TestItem)3 IndexTestItem (com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem)3 Collectors (java.util.stream.Collectors)3 Async (org.springframework.scheduling.annotation.Async)3 LogIndexer (com.epam.ta.reportportal.core.analyzer.auto.LogIndexer)2 IndexerServiceClient (com.epam.ta.reportportal.core.analyzer.auto.client.IndexerServiceClient)2 GenerateClustersConfig (com.epam.ta.reportportal.core.analyzer.auto.client.model.cluster.GenerateClustersConfig)2 AnalyzerUtils.getAnalyzerConfig (com.epam.ta.reportportal.core.analyzer.auto.impl.AnalyzerUtils.getAnalyzerConfig)2 BatchLogIndexer (com.epam.ta.reportportal.core.analyzer.auto.indexer.BatchLogIndexer)2 IndexerStatusCache (com.epam.ta.reportportal.core.analyzer.auto.indexer.IndexerStatusCache)2 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)2