Skip to content

Commit

Permalink
move log rate cases functional test to a separate file
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtj committed Nov 29, 2024
1 parent 7fec42e commit a16acf2
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 88 deletions.
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/aiops/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./log_rate_analysis'));
loadTestFile(require.resolve('./log_rate_analysis_anomaly_table'));
loadTestFile(require.resolve('./log_rate_analysis_dashboard_embeddable'));
loadTestFile(require.resolve('./log_rate_analysis_cases'));
loadTestFile(require.resolve('./change_point_detection'));
loadTestFile(require.resolve('./change_point_detection_dashboard'));
loadTestFile(require.resolve('./change_point_detection_cases'));
Expand Down
106 changes: 18 additions & 88 deletions x-pack/test/functional/apps/aiops/log_rate_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import expect from '@kbn/expect';
import type { FtrProviderContext } from '../../ftr_provider_context';
import { isTestDataExpectedWithSampleProbability, type TestData } from './types';
import { logRateAnalysisTestData } from './log_rate_analysis_test_data';
import { USER } from '../../services/ml/security_common';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'console', 'header', 'home', 'security']);
const browser = getService('browser');
const elasticChart = getService('elasticChart');
const aiops = getService('aiops');
const retry = getService('retry');
const cases = getService('cases');

// AIOps / Log Rate Analysis lives in the ML UI so we need some related services.
const ml = getService('ml');
Expand Down Expand Up @@ -324,92 +322,6 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
}

describe('log rate analysis', function () {
describe('attachments', function () {
const testData = logRateAnalysisTestData[0];

before(async () => {
await aiops.logRateAnalysisDataGenerator.generateData(testData.dataGenerator);
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
await ml.testResources.createDataViewIfNeeded(
testData.sourceIndexOrSavedSearch,
'@timestamp'
);
await ml.navigation.navigateToMl();
});

after(async () => {
await elasticChart.setNewChartUiDebugFlag(false);
await ml.testResources.deleteDataViewByTitle(testData.sourceIndexOrSavedSearch);
await aiops.logRateAnalysisDataGenerator.removeGeneratedData(testData.dataGenerator);
await cases.api.deleteAllCases();
});

it('attaches log rate analysis to a dashboard', async () => {
await aiops.logRateAnalysisPage.navigateToDataViewSelection();

await ml.testExecution.logTestStep(
`${testData.suiteTitle} loads the log rate analysis page with selected data source`
);
await ml.jobSourceSelection.selectSourceForLogRateAnalysis(
testData.sourceIndexOrSavedSearch
);

await ml.testExecution.logTestStep(
`${testData.suiteTitle} starting dashboard attachment process`
);
await aiops.logRateAnalysisPage.attachToDashboard();
});

it('attaches log rate analysis to a case', async () => {
await ml.navigation.navigateToMl();

await aiops.logRateAnalysisPage.navigateToDataViewSelection();

await ml.testExecution.logTestStep(
`${testData.suiteTitle} loads the log rate analysis page with selected data source`
);
await ml.jobSourceSelection.selectSourceForLogRateAnalysis(
testData.sourceIndexOrSavedSearch
);

await ml.testExecution.logTestStep('asserts the attach to case button is disabled');
await aiops.logRateAnalysisPage.openAttachmentsMenu();
await aiops.logRateAnalysisPage.assertAttachToCaseButtonDisabled();

await ml.testExecution.logTestStep(`${testData.suiteTitle} loads data for full time range`);

await aiops.logRateAnalysisPage.clickUseFullDataButton(
testData.expected.totalDocCountFormatted
);

await ml.testExecution.logTestStep('clicks the document count chart to start analysis');
await aiops.logRateAnalysisPage.clickDocumentCountChart(testData.chartClickCoordinates);

if (!testData.autoRun) {
await aiops.logRateAnalysisPage.assertNoAutoRunButtonExists();
await aiops.logRateAnalysisPage.clickNoAutoRunButton();
}

await aiops.logRateAnalysisPage.assertAnalysisSectionExists();

await ml.testExecution.logTestStep(
`${testData.suiteTitle} starting cases attachment process`
);

const caseParams = {
title: testData.suiteTitle,
description: `Description for ${testData.suiteTitle}`,
tag: 'ml_log_rate_analysis',
reporter: USER.ML_POWERUSER,
};

await aiops.logRateAnalysisPage.attachToCase(caseParams);

await ml.cases.assertCaseWithLogRateAnalysisAttachment(caseParams);
});
});

for (const testData of logRateAnalysisTestData) {
describe(`with '${testData.sourceIndexOrSavedSearch}'`, function () {
before(async () => {
Expand All @@ -436,6 +348,24 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
await elasticChart.setNewChartUiDebugFlag(true);
});

it(`${testData.suiteTitle} attaches log rate analysis to a dashboard`, async () => {
await aiops.logRateAnalysisPage.navigateToDataViewSelection();

await ml.testExecution.logTestStep(
`${testData.suiteTitle} loads the log rate analysis page with selected data source`
);
await ml.jobSourceSelection.selectSourceForLogRateAnalysis(
testData.sourceIndexOrSavedSearch
);

await ml.testExecution.logTestStep(
`${testData.suiteTitle} starting dashboard attachment process`
);
await aiops.logRateAnalysisPage.attachToDashboard();

await ml.navigation.navigateToMl();
});

runTests(testData);
});
}
Expand Down
67 changes: 67 additions & 0 deletions x-pack/test/functional/apps/aiops/log_rate_analysis_cases.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';
import { USER } from '../../services/ml/security_common';
import { logRateAnalysisTestData } from './log_rate_analysis_test_data';

export default function ({ getPageObjects, getService }: FtrProviderContext) {
const elasticChart = getService('elasticChart');
const aiops = getService('aiops');
const cases = getService('cases');

const testData = logRateAnalysisTestData[0];

// aiops lives in the ML UI so we need some related services.
const ml = getService('ml');

describe('log rate analysis in cases', function () {
before(async () => {
await aiops.logRateAnalysisDataGenerator.generateData(testData.dataGenerator);
await ml.testResources.setKibanaTimeZoneToUTC();
await ml.securityUI.loginAsMlPowerUser();
await ml.testResources.createDataViewIfNeeded(
testData.sourceIndexOrSavedSearch,
'@timestamp'
);
await elasticChart.setNewChartUiDebugFlag(true);
await ml.navigation.navigateToMl();
});

after(async () => {
await ml.testResources.deleteDataViewByTitle(testData.sourceIndexOrSavedSearch);
await aiops.logRateAnalysisDataGenerator.removeGeneratedData(testData.dataGenerator);
await elasticChart.setNewChartUiDebugFlag(false);
await cases.api.deleteAllCases();
});

it('attaches log rate analysis to a case', async () => {
await aiops.logRateAnalysisPage.navigateToDataViewSelection();
await ml.jobSourceSelection.selectSourceForLogRateAnalysis(testData.sourceIndexOrSavedSearch);

await aiops.logRateAnalysisPage.openAttachmentsMenu();
await aiops.logRateAnalysisPage.assertAttachToCaseButtonDisabled();

await aiops.logRateAnalysisPage.clickUseFullDataButton(
testData.expected.totalDocCountFormatted
);

await aiops.logRateAnalysisPage.clickDocumentCountChart(testData.chartClickCoordinates);

const caseParams = {
title: 'Log rate analysis case',
description: 'Case with log rate analysis attachment',
tag: 'ml_log_rate_analysis',
reporter: USER.ML_POWERUSER,
};

await aiops.logRateAnalysisPage.attachToCase(caseParams);

await ml.cases.assertCaseWithLogRateAnalysisAttachment(caseParams);
});
});
}

0 comments on commit a16acf2

Please sign in to comment.