-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ML] Explain Log Rate Spikes: Basic functional tests. (#138387)
Adds first functional tests for Explain Log Rate Spikes. The test clicks the menu item, selects an index, clicks the "Use full data" button and asserts the page's elements.
- Loading branch information
Showing
15 changed files
with
273 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
||
export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
const functionalConfig = await readConfigFile(require.resolve('../../config.base.js')); | ||
|
||
return { | ||
...functionalConfig.getAll(), | ||
testFiles: [require.resolve('.')], | ||
junit: { | ||
reportName: 'Chrome X-Pack UI Functional Tests - aiops', | ||
}, | ||
}; | ||
} |
87 changes: 87 additions & 0 deletions
87
x-pack/test/functional/apps/aiops/explain_log_rate_spikes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* 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 type { FtrProviderContext } from '../../ftr_provider_context'; | ||
import type { TestData } from './types'; | ||
import { farequoteDataViewTestData } from './test_data'; | ||
|
||
export default function ({ getPageObject, getService }: FtrProviderContext) { | ||
const headerPage = getPageObject('header'); | ||
const esArchiver = getService('esArchiver'); | ||
const aiops = getService('aiops'); | ||
|
||
// aiops / Explain Log Rate Spikes lives in the ML UI so we need some related services. | ||
const ml = getService('ml'); | ||
|
||
function runTests(testData: TestData) { | ||
it(`${testData.suiteTitle} loads the source data in explain log rate spikes`, async () => { | ||
await ml.testExecution.logTestStep( | ||
`${testData.suiteTitle} loads the saved search selection page` | ||
); | ||
await aiops.explainLogRateSpikes.navigateToIndexPatternSelection(); | ||
|
||
await ml.testExecution.logTestStep( | ||
`${testData.suiteTitle} loads the explain log rate spikes page` | ||
); | ||
await ml.jobSourceSelection.selectSourceForExplainLogRateSpikes( | ||
testData.sourceIndexOrSavedSearch | ||
); | ||
}); | ||
|
||
it(`${testData.suiteTitle} displays index details`, async () => { | ||
await ml.testExecution.logTestStep(`${testData.suiteTitle} displays the time range step`); | ||
await aiops.explainLogRateSpikes.assertTimeRangeSelectorSectionExists(); | ||
|
||
await ml.testExecution.logTestStep(`${testData.suiteTitle} loads data for full time range`); | ||
await aiops.explainLogRateSpikes.clickUseFullDataButton( | ||
testData.expected.totalDocCountFormatted | ||
); | ||
await headerPage.waitUntilLoadingHasFinished(); | ||
|
||
await ml.testExecution.logTestStep( | ||
`${testData.suiteTitle} displays elements in the doc count panel correctly` | ||
); | ||
await aiops.explainLogRateSpikes.assertTotalDocCountHeaderExist(); | ||
await aiops.explainLogRateSpikes.assertTotalDocCountChartExist(); | ||
|
||
await ml.testExecution.logTestStep( | ||
`${testData.suiteTitle} displays elements in the page correctly` | ||
); | ||
|
||
await aiops.explainLogRateSpikes.assertSearchPanelExist(); | ||
|
||
await ml.testExecution.logTestStep('displays empty prompt'); | ||
await aiops.explainLogRateSpikes.assertNoWindowParametersEmptyPromptExist(); | ||
}); | ||
} | ||
|
||
describe('explain log rate spikes', function () { | ||
this.tags(['aiops']); | ||
before(async () => { | ||
await esArchiver.loadIfNeeded('x-pack/test/functional/es_archives/ml/farequote'); | ||
|
||
await ml.testResources.createIndexPatternIfNeeded('ft_farequote', '@timestamp'); | ||
await ml.testResources.setKibanaTimeZoneToUTC(); | ||
|
||
await ml.securityUI.loginAsMlPowerUser(); | ||
}); | ||
|
||
after(async () => { | ||
await ml.testResources.deleteIndexPatternByTitle('ft_farequote'); | ||
}); | ||
|
||
describe('with farequote', function () { | ||
// Run tests on full farequote index. | ||
it(`${farequoteDataViewTestData.suiteTitle} loads the explain log rate spikes page`, async () => { | ||
// Start navigation from the base of the ML app. | ||
await ml.navigation.navigateToMl(); | ||
}); | ||
|
||
runTests(farequoteDataViewTestData); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export default function ({ getService, loadTestFile }: FtrProviderContext) { | ||
const esArchiver = getService('esArchiver'); | ||
|
||
// aiops / Explain Log Rate Spikes lives in the ML UI so we need some related services. | ||
const ml = getService('ml'); | ||
|
||
describe('aiops', function () { | ||
this.tags(['skipFirefox', 'aiops']); | ||
|
||
before(async () => { | ||
await ml.securityCommon.createMlRoles(); | ||
await ml.securityCommon.createMlUsers(); | ||
}); | ||
|
||
after(async () => { | ||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior | ||
await ml.securityUI.logout(); | ||
|
||
await ml.securityCommon.cleanMlUsers(); | ||
await ml.securityCommon.cleanMlRoles(); | ||
|
||
await esArchiver.unload('x-pack/test/functional/es_archives/ml/farequote'); | ||
|
||
await ml.testResources.resetKibanaTimeZone(); | ||
}); | ||
|
||
loadTestFile(require.resolve('./explain_log_rate_spikes')); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* 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 { TestData } from './types'; | ||
|
||
export const farequoteDataViewTestData: TestData = { | ||
suiteTitle: 'farequote index pattern', | ||
isSavedSearch: false, | ||
sourceIndexOrSavedSearch: 'ft_farequote', | ||
expected: { | ||
totalDocCountFormatted: '86,274', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface TestData { | ||
suiteTitle: string; | ||
isSavedSearch?: boolean; | ||
sourceIndexOrSavedSearch: string; | ||
rowsPerPage?: 10 | 25 | 50; | ||
expected: { | ||
totalDocCountFormatted: string; | ||
}; | ||
} |
64 changes: 64 additions & 0 deletions
64
x-pack/test/functional/services/aiops/explain_log_rate_spikes.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* 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 expect from '@kbn/expect'; | ||
|
||
import type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export function ExplainLogRateSpikesProvider({ getService }: FtrProviderContext) { | ||
const testSubjects = getService('testSubjects'); | ||
const retry = getService('retry'); | ||
|
||
return { | ||
async assertTimeRangeSelectorSectionExists() { | ||
await testSubjects.existOrFail('aiopsTimeRangeSelectorSection'); | ||
}, | ||
|
||
async assertTotalDocumentCount(expectedFormattedTotalDocCount: string) { | ||
await retry.tryForTime(5000, async () => { | ||
const docCount = await testSubjects.getVisibleText('aiopsTotalDocCount'); | ||
expect(docCount).to.eql( | ||
expectedFormattedTotalDocCount, | ||
`Expected total document count to be '${expectedFormattedTotalDocCount}' (got '${docCount}')` | ||
); | ||
}); | ||
}, | ||
|
||
async clickUseFullDataButton(expectedFormattedTotalDocCount: string) { | ||
await retry.tryForTime(30 * 1000, async () => { | ||
await testSubjects.clickWhenNotDisabled('aiopsExplainLogRatesSpikeButtonUseFullData'); | ||
await testSubjects.clickWhenNotDisabled('superDatePickerApplyTimeButton'); | ||
await this.assertTotalDocumentCount(expectedFormattedTotalDocCount); | ||
}); | ||
}, | ||
|
||
async assertTotalDocCountHeaderExist() { | ||
await retry.tryForTime(5000, async () => { | ||
await testSubjects.existOrFail(`aiopsTotalDocCountHeader`); | ||
}); | ||
}, | ||
|
||
async assertTotalDocCountChartExist() { | ||
await retry.tryForTime(5000, async () => { | ||
await testSubjects.existOrFail(`aiopsDocumentCountChart`); | ||
}); | ||
}, | ||
|
||
async assertSearchPanelExist() { | ||
await testSubjects.existOrFail(`aiopsSearchPanel`); | ||
}, | ||
|
||
async assertNoWindowParametersEmptyPromptExist() { | ||
await testSubjects.existOrFail(`aiopsNoWindowParametersEmptyPrompt`); | ||
}, | ||
|
||
async navigateToIndexPatternSelection() { | ||
await testSubjects.click('mlMainTab explainLogRateSpikes'); | ||
await testSubjects.existOrFail('mlPageSourceSelection'); | ||
}, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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 type { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
import { ExplainLogRateSpikesProvider } from './explain_log_rate_spikes'; | ||
|
||
export function AiopsProvider(context: FtrProviderContext) { | ||
const explainLogRateSpikes = ExplainLogRateSpikesProvider(context); | ||
|
||
return { | ||
explainLogRateSpikes, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters