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] Add functional tests for file data visualizer (elastic#60413)
This PR adds basic functional tests for the file data visualizer, covering a file import and error messages for non-log files. It also moves the file input path handling to a common location in order to avoid code duplication.
- Loading branch information
Showing
18 changed files
with
275 additions
and
15 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
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/machine_learning/data_visualizer/file_data_visualizer.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; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import path from 'path'; | ||
|
||
import { FtrProviderContext } from '../../../ftr_provider_context'; | ||
|
||
// eslint-disable-next-line import/no-default-export | ||
export default function({ getService }: FtrProviderContext) { | ||
const ml = getService('ml'); | ||
|
||
const testDataListPositive = [ | ||
{ | ||
suiteSuffix: 'with an artificial server log', | ||
filePath: path.join(__dirname, 'files_to_import', 'artificial_server_log'), | ||
indexName: 'user-import_1', | ||
createIndexPattern: false, | ||
expected: { | ||
results: { | ||
title: 'artificial_server_log', | ||
}, | ||
}, | ||
}, | ||
]; | ||
|
||
const testDataListNegative = [ | ||
{ | ||
suiteSuffix: 'with a non-log file', | ||
filePath: path.join(__dirname, 'files_to_import', 'not_a_log_file'), | ||
}, | ||
]; | ||
|
||
describe('file based', function() { | ||
this.tags(['smoke', 'mlqa']); | ||
before(async () => { | ||
await ml.securityUI.loginAsMlPowerUser(); | ||
await ml.navigation.navigateToMl(); | ||
}); | ||
|
||
for (const testData of testDataListPositive) { | ||
describe(testData.suiteSuffix, function() { | ||
after(async () => { | ||
await ml.api.deleteIndices(testData.indexName); | ||
}); | ||
|
||
it('loads the data visualizer selector page', async () => { | ||
await ml.navigation.navigateToDataVisualizer(); | ||
}); | ||
|
||
it('loads the file upload page', async () => { | ||
await ml.dataVisualizer.navigateToFileUpload(); | ||
}); | ||
|
||
it('selects a file and loads visualizer results', async () => { | ||
await ml.dataVisualizerFileBased.selectFile(testData.filePath); | ||
}); | ||
|
||
it('displays the components of the file details page', async () => { | ||
await ml.dataVisualizerFileBased.assertFileTitle(testData.expected.results.title); | ||
await ml.dataVisualizerFileBased.assertFileContentPanelExists(); | ||
await ml.dataVisualizerFileBased.assertSummaryPanelExists(); | ||
await ml.dataVisualizerFileBased.assertFileStatsPanelExists(); | ||
}); | ||
|
||
it('loads the import settings page', async () => { | ||
await ml.dataVisualizerFileBased.navigateToFileImport(); | ||
}); | ||
|
||
it('sets the index name', async () => { | ||
await ml.dataVisualizerFileBased.setIndexName(testData.indexName); | ||
}); | ||
|
||
it('sets the create index pattern checkbox', async () => { | ||
await ml.dataVisualizerFileBased.setCreateIndexPatternCheckboxState( | ||
testData.createIndexPattern | ||
); | ||
}); | ||
|
||
it('imports the file', async () => { | ||
await ml.dataVisualizerFileBased.startImportAndWaitForProcessing(); | ||
}); | ||
}); | ||
} | ||
|
||
for (const testData of testDataListNegative) { | ||
describe(testData.suiteSuffix, function() { | ||
it('loads the data visualizer selector page', async () => { | ||
await ml.navigation.navigateToDataVisualizer(); | ||
}); | ||
|
||
it('loads the file upload page', async () => { | ||
await ml.dataVisualizer.navigateToFileUpload(); | ||
}); | ||
|
||
it('selects a file and displays an error', async () => { | ||
await ml.dataVisualizerFileBased.selectFile(testData.filePath, true); | ||
}); | ||
}); | ||
} | ||
}); | ||
} |
19 changes: 19 additions & 0 deletions
19
...st/functional/apps/machine_learning/data_visualizer/files_to_import/artificial_server_log
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,19 @@ | ||
2018-01-06 16:56:14.295748 INFO host:'Server A' Incoming connection from ip 123.456.789.0 | ||
2018-01-06 16:56:15.295748 INFO host:'Server A' Incoming connection from ip 123.456.789.1 | ||
2018-01-06 16:56:16.295748 INFO host:'Server A' Incoming connection from ip 123.456.789.2 | ||
2018-01-06 16:56:17.295748 INFO host:'Server A' Incoming connection from ip 123.456.789.3 | ||
2018-01-06 16:56:18.295748 INFO host:'Server B' Incoming connection from ip 123.456.789.0 | ||
2018-01-06 16:56:19.295748 INFO host:'Server B' Incoming connection from ip 123.456.789.2 | ||
2018-01-06 16:56:20.295748 INFO host:'Server B' Incoming connection from ip 123.456.789.3 | ||
2018-01-06 16:56:21.295748 INFO host:'Server B' Incoming connection from ip 123.456.789.4 | ||
2018-01-06 16:56:22.295748 WARN host:'Server A' Disk watermark 80% | ||
2018-01-06 17:16:23.295748 WARN host:'Server A' Disk watermark 90% | ||
2018-01-06 17:36:10.295748 ERROR host:'Server A' Main process crashed | ||
2018-01-06 17:36:14.295748 INFO host:'Server A' Connection from ip 123.456.789.0 closed | ||
2018-01-06 17:36:15.295748 INFO host:'Server A' Connection from ip 123.456.789.1 closed | ||
2018-01-06 17:36:16.295748 INFO host:'Server A' Connection from ip 123.456.789.2 closed | ||
2018-01-06 17:36:17.295748 INFO host:'Server A' Connection from ip 123.456.789.3 closed | ||
2018-01-06 17:46:11.295748 INFO host:'Server B' Some special characters °!"§$%&/()=?`'^²³{[]}\+*~#'-_.:,;µ|<>äöüß | ||
2018-01-06 17:46:12.295748 INFO host:'Server B' Shutting down | ||
|
||
|
8 changes: 8 additions & 0 deletions
8
x-pack/test/functional/apps/machine_learning/data_visualizer/files_to_import/not_a_log_file
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,8 @@ | ||
This | ||
is | ||
not | ||
a | ||
log | ||
file | ||
|
||
|
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
Oops, something went wrong.