forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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: Additional API integration tests (elast…
…ic#146113) Additional API integration tests. - The test data was moved to its own file `test_data.ts` and types for its structure defined in `types.ts` to be in line with the structure used for functional tests. - The file that runs the test was extended so it can run an array of test data definitions. - The datasets used in the funcional tests (`ecommerce` with some additional documents added to create a significant spike and the computationally generated spike data set to create distinct groups) were moved to a service `ExplainLogRateSpikesDataGenerator` so they can be generated and used across functional and API integration tests. - The computationally generated spike data set `artificial_logs_with_spike` is now also used for API integration tests. - Additional assertions have been added to check the grouping result. `ecommerce` does not return any groups whereas `artificial_logs_with_spike` does. - The functional tests code is now consolidated and one test file is able to run multiple test data definitions too. (cherry picked from commit 5481f07)
- Loading branch information
Showing
12 changed files
with
667 additions
and
589 deletions.
There are no files selected for viewing
426 changes: 208 additions & 218 deletions
426
x-pack/test/api_integration/apis/aiops/explain_log_rate_spikes.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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,157 @@ | ||
/* | ||
* 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 { TestData } from './types'; | ||
|
||
export const explainLogRateSpikesTestData: TestData[] = [ | ||
{ | ||
testName: 'ecommerce', | ||
esArchive: 'x-pack/test/functional/es_archives/ml/ecommerce', | ||
requestBody: { | ||
baselineMax: 1561719083292, | ||
baselineMin: 1560954147006, | ||
deviationMax: 1562254538692, | ||
deviationMin: 1561986810992, | ||
end: 2147483647000, | ||
index: 'ft_ecommerce', | ||
searchQuery: '{"bool":{"filter":[],"must":[{"match_all":{}}],"must_not":[]}}', | ||
start: 0, | ||
timeFieldName: 'order_date', | ||
grouping: true, | ||
}, | ||
expected: { | ||
chunksLength: 35, | ||
actionsLength: 34, | ||
noIndexChunksLength: 4, | ||
noIndexActionsLength: 3, | ||
changePointFilter: 'add_change_points', | ||
groupFilter: 'add_change_point_group', | ||
groupHistogramFilter: 'add_change_point_group_histogram', | ||
histogramFilter: 'add_change_points_histogram', | ||
errorFilter: 'add_error', | ||
changePoints: [ | ||
{ | ||
fieldName: 'day_of_week', | ||
fieldValue: 'Wednesday', | ||
doc_count: 145, | ||
bg_count: 142, | ||
score: 36.31595998561873, | ||
pValue: 1.6911377077437753e-16, | ||
normalizedScore: 0.8055203624020835, | ||
total_doc_count: 0, | ||
total_bg_count: 0, | ||
}, | ||
{ | ||
fieldName: 'day_of_week', | ||
fieldValue: 'Thursday', | ||
doc_count: 157, | ||
bg_count: 224, | ||
score: 20.366950718358762, | ||
pValue: 1.428057484826135e-9, | ||
normalizedScore: 0.7661649691018979, | ||
total_doc_count: 0, | ||
total_bg_count: 0, | ||
}, | ||
], | ||
groups: [], | ||
histogramLength: 20, | ||
}, | ||
}, | ||
{ | ||
testName: 'artificial_logs_with_spike', | ||
dataGenerator: 'artificial_logs_with_spike', | ||
requestBody: { | ||
start: 1668760018793, | ||
end: 1668931954793, | ||
searchQuery: '{"match_all":{}}', | ||
timeFieldName: '@timestamp', | ||
index: 'artificial_logs_with_spike', | ||
baselineMin: 1668769200000, | ||
baselineMax: 1668837600000, | ||
deviationMin: 1668855600000, | ||
deviationMax: 1668924000000, | ||
grouping: true, | ||
}, | ||
expected: { | ||
chunksLength: 25, | ||
actionsLength: 24, | ||
noIndexChunksLength: 4, | ||
noIndexActionsLength: 3, | ||
changePointFilter: 'add_change_points', | ||
groupFilter: 'add_change_point_group', | ||
groupHistogramFilter: 'add_change_point_group_histogram', | ||
histogramFilter: 'add_change_points_histogram', | ||
errorFilter: 'add_error', | ||
changePoints: [ | ||
{ | ||
fieldName: 'response_code', | ||
fieldValue: '500', | ||
doc_count: 1821, | ||
bg_count: 553, | ||
total_doc_count: 4671, | ||
total_bg_count: 1975, | ||
score: 26.546201745993947, | ||
pValue: 2.9589053032077285e-12, | ||
normalizedScore: 0.7814127409489161, | ||
}, | ||
{ | ||
fieldName: 'url', | ||
fieldValue: 'home.php', | ||
doc_count: 1742, | ||
bg_count: 632, | ||
total_doc_count: 4671, | ||
total_bg_count: 1975, | ||
score: 4.53094842981472, | ||
pValue: 0.010770456205312423, | ||
normalizedScore: 0.10333028878375965, | ||
}, | ||
{ | ||
fieldName: 'url', | ||
fieldValue: 'login.php', | ||
doc_count: 1742, | ||
bg_count: 632, | ||
total_doc_count: 4671, | ||
total_bg_count: 1975, | ||
score: 4.53094842981472, | ||
pValue: 0.010770456205312423, | ||
normalizedScore: 0.10333028878375965, | ||
}, | ||
{ | ||
fieldName: 'user', | ||
fieldValue: 'Peter', | ||
doc_count: 1981, | ||
bg_count: 553, | ||
total_doc_count: 4671, | ||
total_bg_count: 1975, | ||
score: 47.34435085428873, | ||
pValue: 2.7454255728359757e-21, | ||
normalizedScore: 0.8327337555873047, | ||
}, | ||
], | ||
groups: [ | ||
{ | ||
id: '2038579476', | ||
group: [ | ||
{ fieldName: 'response_code', fieldValue: '500', duplicate: false }, | ||
{ fieldName: 'url', fieldValue: 'home.php', duplicate: false }, | ||
{ fieldName: 'url', fieldValue: 'home.php', duplicate: false }, | ||
{ fieldName: 'url', fieldValue: 'login.php', duplicate: false }, | ||
], | ||
docCount: 792, | ||
pValue: 0.010770456205312423, | ||
}, | ||
{ | ||
id: '817080373', | ||
group: [{ fieldName: 'user', fieldValue: 'Peter', duplicate: false }], | ||
docCount: 1981, | ||
pValue: 2.7454255728359757e-21, | ||
}, | ||
], | ||
histogramLength: 20, | ||
}, | ||
}, | ||
]; |
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,30 @@ | ||
/* | ||
* 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 { ApiExplainLogRateSpikes } from '@kbn/aiops-plugin/common/api'; | ||
import type { ChangePoint, ChangePointGroup } from '@kbn/ml-agg-utils'; | ||
|
||
export interface TestData { | ||
testName: string; | ||
esArchive?: string; | ||
dataGenerator?: string; | ||
requestBody: ApiExplainLogRateSpikes['body']; | ||
expected: { | ||
chunksLength: number; | ||
actionsLength: number; | ||
noIndexChunksLength: number; | ||
noIndexActionsLength: number; | ||
changePointFilter: 'add_change_points'; | ||
groupFilter: 'add_change_point_group'; | ||
groupHistogramFilter: 'add_change_point_group_histogram'; | ||
histogramFilter: 'add_change_points_histogram'; | ||
errorFilter: 'add_error'; | ||
changePoints: ChangePoint[]; | ||
groups: ChangePointGroup[]; | ||
histogramLength: number; | ||
}; | ||
} |
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 { FtrProviderContext } from '../../functional/ftr_provider_context'; | ||
|
||
import { ExplainLogRateSpikesDataGeneratorProvider } from '../../functional/services/aiops/explain_log_rate_spikes_data_generator'; | ||
|
||
export function AiopsProvider(context: FtrProviderContext) { | ||
const explainLogRateSpikesDataGenerator = ExplainLogRateSpikesDataGeneratorProvider(context); | ||
|
||
return { | ||
explainLogRateSpikesDataGenerator, | ||
}; | ||
} |
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
Oops, something went wrong.