Search in sources :

Example 11 with AnalyzerConfig

use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.

the class LaunchAutoAnalysisSubscriber method handleEvent.

@Override
public void handleEvent(LaunchFinishedEvent launchFinishedEvent, Project project, Launch launch) {
    AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
    if (BooleanUtils.isTrue(analyzerConfig.getIsAutoAnalyzerEnabled())) {
        List<Long> itemIds = analyzeCollectorFactory.getCollector(AnalyzeItemsMode.TO_INVESTIGATE).collectItems(project.getId(), launch.getId(), launchFinishedEvent.getUser());
        logIndexer.indexLaunchLogs(project.getId(), launch.getId(), analyzerConfig).join();
        analyzerServiceAsync.analyze(launch, itemIds, analyzerConfig).thenRunAsync(() -> eventPublisher.publishEvent(new LaunchAutoAnalysisFinishEvent(launch.getId()))).join();
        // TODO provide executor
        CompletableFuture.supplyAsync(() -> logIndexer.indexItemsLogs(project.getId(), launch.getId(), itemIds, analyzerConfig));
    } else {
        logIndexer.indexLaunchLogs(project.getId(), launch.getId(), analyzerConfig);
        eventPublisher.publishEvent(new LaunchAutoAnalysisFinishEvent(launch.getId()));
    }
}
Also used : LaunchAutoAnalysisFinishEvent(com.epam.reportportal.extension.event.LaunchAutoAnalysisFinishEvent) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)

Example 12 with AnalyzerConfig

use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.

the class AnalyzerServiceServiceTest method analyze.

@Test
void analyze() {
    int itemsCount = 2;
    Launch launch = launch();
    List<TestItem> items = testItemsTI(itemsCount);
    items.forEach(item -> item.setLaunchId(launch.getId()));
    AnalyzerConfig analyzerConfig = analyzerConfig();
    final IndexLaunch indexLaunch = new IndexLaunch();
    indexLaunch.setLaunchId(launch.getId());
    indexLaunch.setAnalyzerConfig(analyzerConfig);
    final List<IndexTestItem> indexTestItems = items.stream().map(AnalyzerUtils::fromTestItem).peek(item -> item.setLogs(errorLogs(2))).collect(Collectors.toList());
    indexLaunch.setTestItems(indexTestItems);
    when(testItemRepository.findAllById(anyList())).thenReturn(items);
    when(launchPreparerService.prepare(any(Launch.class), anyList(), any(AnalyzerConfig.class))).thenReturn(Optional.of(indexLaunch));
    when(analyzerServiceClient.analyze(any())).thenReturn(analyzedItems(itemsCount));
    when(issueTypeHandler.defineIssueType(anyLong(), eq("pb001"))).thenReturn(issueProductBug().getIssueType());
    issuesAnalyzer.runAnalyzers(launch, items.stream().map(TestItem::getItemId).collect(Collectors.toList()), analyzerConfig);
    verify(analyzerServiceClient, times(1)).analyze(any());
    verify(testItemRepository, times(itemsCount)).save(any());
    verify(messageBus, times(4)).publishActivity(any());
}
Also used : AnalyzedItemRs(com.epam.ta.reportportal.ws.model.analyzer.AnalyzedItemRs) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) java.util(java.util) Project(com.epam.ta.reportportal.entity.project.Project) IssueTypeHandler(com.epam.ta.reportportal.core.item.impl.IssueTypeHandler) TestItem(com.epam.ta.reportportal.entity.item.TestItem) LogLevel(com.epam.ta.reportportal.entity.enums.LogLevel) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) LaunchPreparerService(com.epam.ta.reportportal.core.analyzer.auto.impl.preparer.LaunchPreparerService) Launch(com.epam.ta.reportportal.entity.launch.Launch) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) ALL_LAUNCHES(com.epam.ta.reportportal.entity.AnalyzeMode.ALL_LAUNCHES) Collectors(java.util.stream.Collectors) Test(org.junit.jupiter.api.Test) Mockito(org.mockito.Mockito) VerificationModeFactory.times(org.mockito.internal.verification.VerificationModeFactory.times) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) PRODUCT_BUG(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup.PRODUCT_BUG) IndexLog(com.epam.ta.reportportal.ws.model.analyzer.IndexLog) AnalyzerServiceClient(com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) IndexLaunch(com.epam.ta.reportportal.ws.model.analyzer.IndexLaunch) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem) IndexTestItem(com.epam.ta.reportportal.ws.model.analyzer.IndexTestItem) Test(org.junit.jupiter.api.Test)

Example 13 with AnalyzerConfig

use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.

the class AnalyzerServiceServiceTest method analyzerConfig.

private AnalyzerConfig analyzerConfig() {
    AnalyzerConfig analyzerConfig = new AnalyzerConfig();
    analyzerConfig.setAnalyzerMode(ALL_LAUNCHES.getValue());
    return analyzerConfig;
}
Also used : AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)

Example 14 with AnalyzerConfig

use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.

the class AnalyzerUtilsTest method testAnalyzerConfig.

@Test
void testAnalyzerConfig() {
    AnalyzerConfig config = AnalyzerUtils.getAnalyzerConfig(project());
    assertEquals(String.valueOf(config.getIsAutoAnalyzerEnabled()), ProjectAttributeEnum.AUTO_ANALYZER_ENABLED.getDefaultValue());
    assertEquals(String.valueOf(config.getNumberOfLogLines()), ProjectAttributeEnum.NUMBER_OF_LOG_LINES.getDefaultValue());
    assertEquals(config.getAnalyzerMode(), ProjectAttributeEnum.AUTO_ANALYZER_MODE.getDefaultValue());
    assertEquals(String.valueOf(config.getMinShouldMatch()), ProjectAttributeEnum.MIN_SHOULD_MATCH.getDefaultValue());
    assertEquals(String.valueOf(config.getSearchLogsMinShouldMatch()), ProjectAttributeEnum.SEARCH_LOGS_MIN_SHOULD_MATCH.getDefaultValue());
    assertEquals(String.valueOf(config.isIndexingRunning()), ProjectAttributeEnum.INDEXING_RUNNING.getDefaultValue());
    assertEquals(String.valueOf(config.isAllMessagesShouldMatch()), ProjectAttributeEnum.ALL_MESSAGES_SHOULD_MATCH.getDefaultValue());
}
Also used : AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) Test(org.junit.jupiter.api.Test)

Example 15 with AnalyzerConfig

use of com.epam.ta.reportportal.ws.model.project.AnalyzerConfig in project service-api by reportportal.

the class LogIndexerServiceTest method analyzerConfig.

private AnalyzerConfig analyzerConfig() {
    AnalyzerConfig analyzerConfig = new AnalyzerConfig();
    analyzerConfig.setAnalyzerMode(ALL_LAUNCHES.getValue());
    return analyzerConfig;
}
Also used : AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)

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