Skip to content

Commit

Permalink
[ML] Adds functional tests for data frame analytics jobs with filters (
Browse files Browse the repository at this point in the history
…#139935)

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
peteharverson and kibanamachine authored Sep 7, 2022
1 parent cda1e3d commit 2c5fae2
Show file tree
Hide file tree
Showing 5 changed files with 453 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp');
await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small');
await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small');
// Need to use the saved searches with filters that match multiple airlines
await ml.testResources.createSavedSearchFarequoteFilterTwoAndLuceneIfNeeded(
'ft_farequote_small'
);
await ml.testResources.createSavedSearchFarequoteFilterTwoAndKueryIfNeeded(
'ft_farequote_small'
);
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.securityUI.loginAsMlPowerUser();
Expand Down Expand Up @@ -134,6 +141,110 @@ export default function ({ getService }: FtrProviderContext) {
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and lucene query',
jobType: 'classification',
jobId: `fq_saved_search_4_${dateNow}`,
jobDescription: 'Classification job based on a saved search with filter and lucene query',
source: 'ft_farequote_filter_two_and_lucene',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
dependentVariable: 'airline',
trainingPercent: 20,
modelMemory: '20mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
rocCurveColorState: [
// tick/grid/axis
{ color: '#DDDDDD', percentage: 38 },
// line
{ color: '#98A2B3', percentage: 7 },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'classification',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_4_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":135,"test_docs_count":544,"skipped_docs_count":0}',
description:
'Classification job based on a saved search with filter and lucene query',
},
},
{ section: 'progress', expectedEntries: { Phase: '8/8' } },
],
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and kuery query',
jobType: 'classification',
jobId: `fq_saved_search_5_${dateNow}`,
jobDescription: 'Classification job based on a saved search with filter and kuery query',
source: 'ft_farequote_filter_two_and_kuery',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
dependentVariable: 'airline',
trainingPercent: 20,
modelMemory: '20mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
rocCurveColorState: [
// tick/grid/axis
{ color: '#DDDDDD', percentage: 38 },
// line
{ color: '#98A2B3', percentage: 7 },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'classification',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_5_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":109,"test_docs_count":436,"skipped_docs_count":0}',
description:
'Classification job based on a saved search with filter and kuery query',
},
},
{ section: 'progress', expectedEntries: { Phase: '8/8' } },
],
} as AnalyticsTableRowDetails,
},
},
];

for (const testData of testDataList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp');
await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small');
await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small');
await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded(
'ft_farequote_small'
);
await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded('ft_farequote_small');
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.securityUI.loginAsMlPowerUser();
Expand Down Expand Up @@ -56,22 +60,6 @@ export default function ({ getService }: FtrProviderContext) {
{ chartAvailable: true, id: 'responsetime', legend: '4.91 - 171.08' },
{ chartAvailable: true, id: 'airline', legend: '5 categories' },
],
scatterplotMatrixColorsWizard: [
// markers
{ color: '#52B398', percentage: 15 },
// grey boilerplate
{ color: '#6A717D', percentage: 13 },
],
scatterplotMatrixColorStatsResults: [
// red markers
{ color: '#D98071', percentage: 1 },
// tick/grid/axis, grey markers
{ color: '#6A717D', percentage: 12 },
{ color: '#D3DAE6', percentage: 8 },
{ color: '#98A1B3', percentage: 12 },
// anti-aliasing
{ color: '#F5F7FA', percentage: 30 },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
Expand Down Expand Up @@ -120,22 +108,6 @@ export default function ({ getService }: FtrProviderContext) {
{ chartAvailable: true, id: 'responsetime', legend: '9.91 - 171.08' },
{ chartAvailable: true, id: 'airline', legend: '5 categories' },
],
scatterplotMatrixColorsWizard: [
// markers
{ color: '#52B398', percentage: 15 },
// grey boilerplate
{ color: '#6A717D', percentage: 13 },
],
scatterplotMatrixColorStatsResults: [
// red markers
{ color: '#D98071', percentage: 1 },
// tick/grid/axis, grey markers
{ color: '#6A717D', percentage: 12 },
{ color: '#D3DAE6', percentage: 8 },
{ color: '#98A1B3', percentage: 12 },
// anti-aliasing
{ color: '#F5F7FA', percentage: 30 },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
Expand All @@ -160,6 +132,105 @@ export default function ({ getService }: FtrProviderContext) {
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and kuery query',
jobType: 'outlier_detection',
jobId: `fq_saved_search_4_${dateNow}`,
jobDescription: 'Outlier detection job based on a saved search with filter and kuery query',
source: 'ft_farequote_filter_and_kuery',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
modelMemory: '65mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
histogramCharts: [
{ chartAvailable: true, id: 'uppercase_airline', legend: '1 category' },
{ chartAvailable: true, id: 'responsetime', legend: '57.2 - 96.77' },
{ chartAvailable: true, id: 'airline', legend: '1 category' },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'outlier_detection',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_4_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":290,"test_docs_count":0,"skipped_docs_count":0}',
description:
'Outlier detection job based on a saved search with filter and kuery query',
},
},
{ section: 'progress', expectedEntries: { Phase: '4/4' } },
],
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and lucene query',
jobType: 'outlier_detection',
jobId: `fq_saved_search_5_${dateNow}`,
jobDescription:
'Outlier detection job based on a saved search with filter and lucene query',
source: 'ft_farequote_filter_and_lucene',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
modelMemory: '65mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
histogramCharts: [
{ chartAvailable: true, id: 'uppercase_airline', legend: '1 category' },
{ chartAvailable: true, id: 'responsetime', legend: '57.2 - 96.77' },
{ chartAvailable: true, id: 'airline', legend: '1 category' },
],
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'outlier_detection',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_5_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":290,"test_docs_count":0,"skipped_docs_count":0}',
description:
'Outlier detection job based on a saved search with filter and lucene query',
},
},
{ section: 'progress', expectedEntries: { Phase: '4/4' } },
],
} as AnalyticsTableRowDetails,
},
},
];

for (const testData of testDataList) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ export default function ({ getService }: FtrProviderContext) {
await ml.testResources.createIndexPatternIfNeeded('ft_farequote_small', '@timestamp');
await ml.testResources.createSavedSearchFarequoteLuceneIfNeeded('ft_farequote_small');
await ml.testResources.createSavedSearchFarequoteKueryIfNeeded('ft_farequote_small');
await ml.testResources.createSavedSearchFarequoteFilterAndLuceneIfNeeded(
'ft_farequote_small'
);
await ml.testResources.createSavedSearchFarequoteFilterAndKueryIfNeeded('ft_farequote_small');
await ml.testResources.setKibanaTimeZoneToUTC();

await ml.securityUI.loginAsMlPowerUser();
Expand Down Expand Up @@ -122,6 +126,97 @@ export default function ({ getService }: FtrProviderContext) {
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and kuery query',
jobType: 'regression',
jobId: `fq_saved_search_4_${dateNow}`,
jobDescription: 'Regression job based on a saved search with filter and kuery query',
source: 'ft_farequote_filter_and_kuery',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
dependentVariable: 'responsetime',
trainingPercent: 20,
modelMemory: '20mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'regression',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_4_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":58,"test_docs_count":232,"skipped_docs_count":0}',
description: 'Regression job based on a saved search with filter and kuery query',
},
},
{ section: 'progress', expectedEntries: { Phase: '8/8' } },
],
} as AnalyticsTableRowDetails,
},
},
{
suiteTitle: 'with filter and lucene query',
jobType: 'regression',
jobId: `fq_saved_search_5_${dateNow}`,
jobDescription: 'Regression job based on a saved search with filter and lucene query',
source: 'ft_farequote_filter_and_lucene',
get destinationIndex(): string {
return `user-${this.jobId}`;
},
runtimeFields: {
uppercase_airline: {
type: 'keyword',
script: 'emit(params._source.airline.toUpperCase())',
},
},
dependentVariable: 'responsetime',
trainingPercent: 20,
modelMemory: '20mb',
createIndexPattern: true,
expected: {
source: 'ft_farequote_small',
runtimeFieldsEditorContent: ['{', ' "uppercase_airline": {', ' "type": "keyword",'],
row: {
memoryStatus: 'ok',
type: 'regression',
status: 'stopped',
progress: '100',
},
rowDetails: {
jobDetails: [
{
section: 'state',
expectedEntries: {
id: `fq_saved_search_5_${dateNow}`,
state: 'stopped',
data_counts:
'{"training_docs_count":58,"test_docs_count":232,"skipped_docs_count":0}',
description:
'Regression job based on a saved search with filter and lucene query',
},
},
{ section: 'progress', expectedEntries: { Phase: '8/8' } },
],
} as AnalyticsTableRowDetails,
},
},
];

for (const testData of testDataList) {
Expand Down
Loading

0 comments on commit 2c5fae2

Please sign in to comment.