mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[ML] Automates geographic anomaly screenshots (#146502)
Co-authored-by: Robert Oskamp <robert.oskamp@elastic.co>
This commit is contained in:
parent
c38315f91c
commit
e20ab5883b
6 changed files with 39 additions and 12 deletions
|
@ -62,7 +62,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
await ml.api.createAndRunAnomalyDetectionLookbackJob(
|
||||
ml.commonConfig.getADFqSingleMetricJobConfig(adJobId),
|
||||
ml.commonConfig.getADFqDatafeedConfig(adJobId),
|
||||
idSpace1
|
||||
{ space: idSpace1 }
|
||||
);
|
||||
await ml.api.assertJobSpaces(adJobId, 'anomaly-detector', [idSpace1]);
|
||||
});
|
||||
|
|
|
@ -87,7 +87,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
// @ts-expect-error not full interface
|
||||
testJobConfig,
|
||||
testDatafeedConfig,
|
||||
idSpace1
|
||||
{ space: idSpace1 }
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ export default ({ getService }: FtrProviderContext) => {
|
|||
// @ts-expect-error not full interface
|
||||
testJobConfig,
|
||||
testDatafeedConfig,
|
||||
idSpace1
|
||||
{ space: idSpace1 }
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -860,12 +860,13 @@ export function MachineLearningAPIProvider({ getService }: FtrProviderContext) {
|
|||
async createAndRunAnomalyDetectionLookbackJob(
|
||||
jobConfig: Job,
|
||||
datafeedConfig: Datafeed,
|
||||
space?: string
|
||||
options: { space?: string; end?: string } = {}
|
||||
) {
|
||||
const { space = undefined, end = `${Date.now()}` } = options;
|
||||
await this.createAnomalyDetectionJob(jobConfig, space);
|
||||
await this.createDatafeed(datafeedConfig, space);
|
||||
await this.openAnomalyDetectionJob(jobConfig.job_id);
|
||||
await this.startDatafeed(datafeedConfig.datafeed_id, { start: '0', end: `${Date.now()}` });
|
||||
await this.startDatafeed(datafeedConfig.datafeed_id, { start: '0', end });
|
||||
await this.waitForDatafeedState(datafeedConfig.datafeed_id, DATAFEED_STATE.STOPPED);
|
||||
await this.waitForJobState(jobConfig.job_id, JOB_STATE.CLOSED);
|
||||
},
|
||||
|
|
|
@ -5,10 +5,12 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { UI_SETTINGS } from '@kbn/data-plugin/common';
|
||||
import { FtrProviderContext } from '../../ftr_provider_context';
|
||||
|
||||
export function SampleDataTestResourcesServiceProvider({ getService }: FtrProviderContext) {
|
||||
const supertest = getService('supertest');
|
||||
const kibanaServer = getService('kibanaServer');
|
||||
|
||||
return {
|
||||
async installKibanaSampleData(sampleDataId: 'ecommerce' | 'flights' | 'logs') {
|
||||
|
@ -26,6 +28,22 @@ export function SampleDataTestResourcesServiceProvider({ getService }: FtrProvid
|
|||
await this.installKibanaSampleData('ecommerce');
|
||||
await this.installKibanaSampleData('flights');
|
||||
await this.installKibanaSampleData('logs');
|
||||
|
||||
// Sample data is shifted to be relative to current time
|
||||
// This means that a static timerange will return different documents
|
||||
// Setting the time range to a window larger than the sample data set
|
||||
// ensures all documents are coverered by time query so the ES results will always be the same
|
||||
const SAMPLE_DATA_RANGE = `[
|
||||
{
|
||||
"from": "now-180d",
|
||||
"to": "now+180d",
|
||||
"display": "sample data range"
|
||||
}
|
||||
]`;
|
||||
|
||||
await kibanaServer.uiSettings.update({
|
||||
[UI_SETTINGS.TIMEPICKER_QUICK_RANGES]: SAMPLE_DATA_RANGE,
|
||||
});
|
||||
},
|
||||
|
||||
async removeAllKibanaSampleData() {
|
||||
|
|
|
@ -13,10 +13,11 @@ import { ECOMMERCE_INDEX_PATTERN, LOGS_INDEX_PATTERN } from '..';
|
|||
|
||||
export default function ({ getPageObject, getService }: FtrProviderContext) {
|
||||
const elasticChart = getService('elasticChart');
|
||||
const maps = getPageObject('maps');
|
||||
const ml = getService('ml');
|
||||
const commonScreenshots = getService('commonScreenshots');
|
||||
const renderable = getService('renderable');
|
||||
const maps = getPageObject('maps');
|
||||
const timePicker = getPageObject('timePicker');
|
||||
|
||||
const screenshotDirectories = ['ml_docs', 'anomaly_detection'];
|
||||
|
||||
|
@ -76,9 +77,12 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
|
|||
|
||||
describe('geographic data', function () {
|
||||
before(async () => {
|
||||
// Stop the sample data feed about three months after the current date to capture anomaly
|
||||
const dateStopString = new Date(Date.now() + 131400 * 60 * 1000).toISOString();
|
||||
await ml.api.createAndRunAnomalyDetectionLookbackJob(
|
||||
ecommerceGeoJobConfig as Job,
|
||||
ecommerceGeoDatafeedConfig as Datafeed
|
||||
ecommerceGeoDatafeedConfig as Datafeed,
|
||||
{ end: dateStopString }
|
||||
);
|
||||
await ml.api.createAndRunAnomalyDetectionLookbackJob(
|
||||
weblogGeoJobConfig as Job,
|
||||
|
@ -222,8 +226,7 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
|
|||
);
|
||||
});
|
||||
|
||||
// the job stopped to produce an anomaly, needs investigation
|
||||
it.skip('ecommerce anomaly explorer screenshots', async () => {
|
||||
it('ecommerce anomaly explorer screenshots', async () => {
|
||||
await ml.testExecution.logTestStep('navigate to job list');
|
||||
await ml.navigation.navigateToMl();
|
||||
await ml.navigation.navigateToJobManagement();
|
||||
|
@ -233,6 +236,13 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
|
|||
await ml.jobTable.filterWithSearchString(ecommerceGeoJobConfig.job_id, 1);
|
||||
await ml.jobTable.clickOpenJobInAnomalyExplorerButton(ecommerceGeoJobConfig.job_id);
|
||||
await ml.commonUI.waitForMlLoadingIndicatorToDisappear();
|
||||
await ml.testExecution.logTestStep('Choose time range...');
|
||||
await timePicker.setCommonlyUsedTime('sample_data range');
|
||||
|
||||
await ml.testExecution.logTestStep('open anomaly list actions and take screenshot');
|
||||
await ml.anomaliesTable.scrollTableIntoView();
|
||||
await ml.anomaliesTable.ensureAnomalyActionsMenuOpen(0);
|
||||
await commonScreenshots.takeScreenshot('view-in-maps', screenshotDirectories);
|
||||
|
||||
await ml.testExecution.logTestStep('select swim lane tile');
|
||||
const cells = await ml.swimLane.getCells(overallSwimLaneTestSubj);
|
||||
|
@ -242,11 +252,9 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
|
|||
y: sampleCell.y + cellSize,
|
||||
});
|
||||
await ml.swimLane.waitForSwimLanesToLoad();
|
||||
|
||||
await ml.testExecution.logTestStep('take screenshot');
|
||||
await ml.testExecution.logTestStep('open anomaly list details and take screenshot');
|
||||
await ml.anomaliesTable.ensureDetailsOpen(0);
|
||||
await ml.anomalyExplorer.scrollChartsContainerIntoView();
|
||||
|
||||
await commonScreenshots.takeScreenshot(
|
||||
'ecommerce-anomaly-explorer-geopoint',
|
||||
screenshotDirectories
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue