-
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.
adds functional test for log rate analysis embeddable
- Loading branch information
Showing
6 changed files
with
236 additions
and
1 deletion.
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
104 changes: 104 additions & 0 deletions
104
x-pack/test/functional/apps/aiops/log_rate_analysis_dashboard_embeddable.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,104 @@ | ||
/* | ||
* 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 { EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE } from '@kbn/aiops-log-rate-analysis/constants'; | ||
|
||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
import { logRateAnalysisTestData } from './log_rate_analysis_test_data'; | ||
|
||
const testDataSetup = logRateAnalysisTestData[0]; | ||
const testDataPanel = { | ||
type: 'testData', | ||
suiteSuffix: 'with multi metric job', | ||
panelTitle: `AIOps log rate analysis for ${testDataSetup.sourceIndexOrSavedSearch}`, | ||
dashboardTitle: `AIOps log rate analysis for ${ | ||
testDataSetup.sourceIndexOrSavedSearch | ||
} ${Date.now()}`, | ||
}; | ||
export default function ({ getService, getPageObjects }: FtrProviderContext) { | ||
const PageObjects = getPageObjects([ | ||
'common', | ||
'console', | ||
'dashboard', | ||
'header', | ||
'home', | ||
'security', | ||
'timePicker', | ||
]); | ||
const aiops = getService('aiops'); | ||
|
||
// AIOps / Log Rate Analysis lives in the ML UI so we need some related services. | ||
const ml = getService('ml'); | ||
|
||
const from = 'Apr 16, 2023 @ 00:39:02.912'; | ||
const to = 'Jun 15, 2023 @ 21:45:26.749'; | ||
|
||
describe('log rate analysis in dashboard', function () { | ||
before(async () => { | ||
await aiops.logRateAnalysisDataGenerator.generateData(testDataSetup.dataGenerator); | ||
|
||
await ml.testResources.setKibanaTimeZoneToUTC(); | ||
|
||
await ml.securityUI.loginAsMlPowerUser(); | ||
await ml.testResources.createDataViewIfNeeded( | ||
testDataSetup.sourceIndexOrSavedSearch, | ||
'@timestamp' | ||
); | ||
|
||
await PageObjects.common.setTime({ from, to }); | ||
}); | ||
|
||
after(async () => { | ||
await ml.testResources.deleteDataViewByTitle(testDataSetup.sourceIndexOrSavedSearch); | ||
await aiops.logRateAnalysisDataGenerator.removeGeneratedData(testDataSetup.dataGenerator); | ||
await PageObjects.common.unsetTime(); | ||
}); | ||
|
||
describe(testDataPanel.suiteSuffix, function () { | ||
before(async () => { | ||
await PageObjects.dashboard.navigateToApp(); | ||
}); | ||
|
||
after(async () => { | ||
await ml.testResources.deleteDashboardByTitle(testDataPanel.dashboardTitle); | ||
}); | ||
|
||
it('should open initializer flyout', async () => { | ||
await PageObjects.dashboard.clickNewDashboard(); | ||
await aiops.dashboardEmbeddables.assertDashboardIsEmpty(); | ||
await aiops.dashboardEmbeddables.openEmbeddableInitializer( | ||
EMBEDDABLE_LOG_RATE_ANALYSIS_TYPE | ||
); | ||
}); | ||
|
||
it('should select data view', async () => { | ||
await aiops.dashboardEmbeddables.assertLogRateAnalysisEmbeddableDataViewSelectorExists(); | ||
await aiops.dashboardEmbeddables.selectLogRateAnalysisEmbeddableDataView( | ||
testDataSetup.sourceIndexOrSavedSearch | ||
); | ||
}); | ||
|
||
it('should create new log rate analysis panel', async () => { | ||
await aiops.dashboardEmbeddables.clickLogRateAnalysisInitializerConfirmButtonEnabled(); | ||
await PageObjects.timePicker.pauseAutoRefresh(); | ||
await aiops.dashboardEmbeddables.assertDashboardPanelExists(testDataPanel.panelTitle); | ||
await aiops.logRateAnalysisPage.assertAutoRunButtonExists(); | ||
await PageObjects.dashboard.saveDashboard(testDataPanel.dashboardTitle); | ||
}); | ||
|
||
it('should run log rate analysis', async () => { | ||
await aiops.dashboardEmbeddables.assertDashboardPanelExists(testDataPanel.panelTitle); | ||
await aiops.logRateAnalysisPage.clickAutoRunButton(); | ||
// Wait for the analysis to finish | ||
await aiops.logRateAnalysisPage.assertAnalysisComplete( | ||
testDataSetup.analysisType, | ||
testDataSetup.dataGenerator | ||
); | ||
}); | ||
}); | ||
}); | ||
} |
110 changes: 110 additions & 0 deletions
110
x-pack/test/functional/services/aiops/dashboard_embeddables.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,110 @@ | ||
/* | ||
* 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 { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
export function AiopsDashboardEmbeddablesProvider({ getService }: FtrProviderContext) { | ||
const comboBox = getService('comboBox'); | ||
const retry = getService('retry'); | ||
const testSubjects = getService('testSubjects'); | ||
const find = getService('find'); | ||
const dashboardAddPanel = getService('dashboardAddPanel'); | ||
|
||
return { | ||
async assertLogRateAnalysisEmbeddableInitializerExists() { | ||
await retry.tryForTime(10 * 1000, async () => { | ||
await testSubjects.existOrFail('aiopsLogRateAnalysisEmbeddableInitializer', { | ||
timeout: 1000, | ||
}); | ||
}); | ||
}, | ||
|
||
async assertLogRateAnalysisEmbeddableInitializerNotExists() { | ||
await retry.tryForTime(10 * 1000, async () => { | ||
await testSubjects.missingOrFail('aiopsLogRateAnalysisEmbeddableInitializer', { | ||
timeout: 1000, | ||
}); | ||
}); | ||
}, | ||
|
||
async assertInitializerConfirmButtonEnabled(subj: string) { | ||
await retry.tryForTime(60 * 1000, async () => { | ||
await testSubjects.existOrFail(subj); | ||
await testSubjects.isEnabled(subj); | ||
}); | ||
}, | ||
|
||
async assertDashboardIsEmpty() { | ||
await retry.tryForTime(60 * 1000, async () => { | ||
await testSubjects.existOrFail('emptyDashboardWidget'); | ||
}); | ||
}, | ||
|
||
async assertDashboardPanelExists(title: string) { | ||
await retry.tryForTime(5000, async () => { | ||
await find.existsByLinkText(title); | ||
}); | ||
}, | ||
|
||
async assertLogsAiopsSectionExists(expectExist = true) { | ||
await retry.tryForTime(60 * 1000, async () => { | ||
await dashboardAddPanel.clickEditorMenuButton(); | ||
await dashboardAddPanel.verifyEmbeddableFactoryGroupExists('logs-aiops', expectExist); | ||
}); | ||
}, | ||
|
||
async clickLogRateAnalysisInitializerConfirmButtonEnabled() { | ||
const subj = 'aiopsLogRateAnalysisConfirmButton'; | ||
await retry.tryForTime(60 * 1000, async () => { | ||
await this.assertInitializerConfirmButtonEnabled(subj); | ||
await testSubjects.clickWhenNotDisabledWithoutRetry(subj); | ||
await this.assertLogRateAnalysisEmbeddableInitializerNotExists(); | ||
}); | ||
}, | ||
|
||
async openEmbeddableInitializer(mlEmbeddableType: 'aiopsLogRateAnalysisEmbeddable') { | ||
const name = { | ||
aiopsLogRateAnalysisEmbeddable: 'Log rate analysis', | ||
}; | ||
await retry.tryForTime(60 * 1000, async () => { | ||
await dashboardAddPanel.clickEditorMenuButton(); | ||
await testSubjects.existOrFail('dashboardPanelSelectionFlyout', { timeout: 2000 }); | ||
|
||
await dashboardAddPanel.verifyEmbeddableFactoryGroupExists('logs-aiops'); | ||
|
||
await dashboardAddPanel.clickAddNewPanelFromUIActionLink(name[mlEmbeddableType]); | ||
await testSubjects.existOrFail('aiopsLogRateAnalysisControls', { timeout: 2000 }); | ||
}); | ||
}, | ||
|
||
async assertLogRateAnalysisEmbeddableDataViewSelectorExists() { | ||
await testSubjects.existOrFail( | ||
'aiopsLogRateAnalysisEmbeddableDataViewSelector > comboBoxInput' | ||
); | ||
}, | ||
|
||
async assertLogRateAnalysisEmbeddableDataViewSelection(dataViewValue: string) { | ||
const comboBoxSelectedOptions = await comboBox.getComboBoxSelectedOptions( | ||
'aiopsLogRateAnalysisEmbeddableDataViewSelector > comboBoxInput' | ||
); | ||
expect(comboBoxSelectedOptions).to.eql( | ||
[dataViewValue], | ||
`Expected data view selection to be '${dataViewValue}' (got '${comboBoxSelectedOptions}')` | ||
); | ||
}, | ||
|
||
async selectLogRateAnalysisEmbeddableDataView(dataViewValue: string) { | ||
await comboBox.set( | ||
'aiopsLogRateAnalysisEmbeddableDataViewSelector > comboBoxInput', | ||
dataViewValue | ||
); | ||
await this.assertLogRateAnalysisEmbeddableDataViewSelection(dataViewValue); | ||
}, | ||
}; | ||
} |
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