Skip to content

Commit

Permalink
make attachments tests more data agnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrtj committed Nov 27, 2024
1 parent 31a3be7 commit d4c36b3
Showing 1 changed file with 87 additions and 66 deletions.
153 changes: 87 additions & 66 deletions x-pack/test/functional/apps/aiops/log_rate_analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
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 @@ -323,6 +324,92 @@ 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 @@ -349,72 +436,6 @@ 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();
});

it(`${testData.suiteTitle} attaches log rate analysis to a case`, 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('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 dashboard 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);

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

runTests(testData);
});
}
Expand Down

0 comments on commit d4c36b3

Please sign in to comment.