Skip to content

Commit

Permalink
[ML] Functional tests - add more recognize and setup module API tests (
Browse files Browse the repository at this point in the history
…#69251) (#69395)

This PR adds a couple recognize module and setup module API integration tests.
  • Loading branch information
pheyos authored Jun 17, 2020
1 parent d1f3b7e commit 6c7727e
Show file tree
Hide file tree
Showing 34 changed files with 19,454 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default ({ getService }: FtrProviderContext) => {
});

after(async () => {
await ml.testResources.deleteIndexPattern(destinationIndex);
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
});

it('should delete job and index pattern by id', async () => {
Expand Down Expand Up @@ -194,7 +194,7 @@ export default ({ getService }: FtrProviderContext) => {

after(async () => {
await ml.api.deleteIndices(destinationIndex);
await ml.testResources.deleteIndexPattern(destinationIndex);
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
});

it('should delete job, target index, and index pattern by id', async () => {
Expand Down
22 changes: 19 additions & 3 deletions x-pack/test/api_integration/apis/ml/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,28 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
await ml.securityCommon.cleanMlUsers();
await ml.securityCommon.cleanMlRoles();

await ml.testResources.deleteIndexPattern('kibana_sample_data_logs');
await ml.testResources.deleteIndexPattern('ft_farequote');
await ml.testResources.deleteIndexPatternByTitle('ft_module_apache');
await ml.testResources.deleteIndexPatternByTitle('ft_module_apm');
await ml.testResources.deleteIndexPatternByTitle('ft_module_logs');
await ml.testResources.deleteIndexPatternByTitle('ft_module_nginx');
await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_ecommerce');
await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_logs');
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_auditbeat');
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_packetbeat');
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_winlogbeat');
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');

await esArchiver.unload('ml/ecommerce');
await esArchiver.unload('ml/categorization');
await esArchiver.unload('ml/sample_logs');
await esArchiver.unload('ml/module_apache');
await esArchiver.unload('ml/module_apm');
await esArchiver.unload('ml/module_logs');
await esArchiver.unload('ml/module_nginx');
await esArchiver.unload('ml/module_sample_ecommerce');
await esArchiver.unload('ml/module_sample_logs');
await esArchiver.unload('ml/module_siem_auditbeat');
await esArchiver.unload('ml/module_siem_packetbeat');
await esArchiver.unload('ml/module_siem_winlogbeat');
await esArchiver.unload('ml/farequote');
await esArchiver.unload('ml/bm_classification');

Expand Down
93 changes: 89 additions & 4 deletions x-pack/test/api_integration/apis/ml/modules/recognize_module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,94 @@ export default ({ getService }: FtrProviderContext) => {
const testDataList = [
{
testTitleSuffix: 'for sample logs dataset',
sourceDataArchive: 'ml/sample_logs',
indexPattern: 'kibana_sample_data_logs',
sourceDataArchive: 'ml/module_sample_logs',
indexPattern: 'ft_module_sample_logs',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['sample_data_weblogs'],
},
},
{
testTitleSuffix: 'for apache dataset',
sourceDataArchive: 'ml/module_apache',
indexPattern: 'ft_module_apache',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['apache_ecs'],
},
},
{
testTitleSuffix: 'for apm dataset',
sourceDataArchive: 'ml/module_apm',
indexPattern: 'ft_module_apm',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['apm_jsbase', 'apm_transaction', 'apm_nodejs'],
},
},
{
testTitleSuffix: 'for logs dataset',
sourceDataArchive: 'ml/module_logs',
indexPattern: 'ft_module_logs',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: [], // the logs modules don't define a query and can't be recognized
},
},
{
testTitleSuffix: 'for nginx dataset',
sourceDataArchive: 'ml/module_nginx',
indexPattern: 'ft_module_nginx',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['nginx_ecs'],
},
},
{
testTitleSuffix: 'for sample ecommerce dataset',
sourceDataArchive: 'ml/module_sample_ecommerce',
indexPattern: 'ft_module_sample_ecommerce',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['sample_data_ecommerce'],
},
},
{
testTitleSuffix: 'for siem auditbeat dataset',
sourceDataArchive: 'ml/module_siem_auditbeat',
indexPattern: 'ft_module_siem_auditbeat',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['siem_auditbeat', 'siem_auditbeat_auth'],
},
},
{
testTitleSuffix: 'for siem packetbeat dataset',
sourceDataArchive: 'ml/module_siem_packetbeat',
indexPattern: 'ft_module_siem_packetbeat',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['siem_packetbeat'],
},
},
{
testTitleSuffix: 'for siem winlogbeat dataset',
sourceDataArchive: 'ml/module_siem_winlogbeat',
indexPattern: 'ft_module_siem_winlogbeat',
user: USER.ML_POWERUSER,
expected: {
responseCode: 200,
moduleIds: ['siem_winlogbeat'],
},
},
{
testTitleSuffix: 'for non existent index pattern',
indexPattern: 'non-existent-index-pattern',
Expand Down Expand Up @@ -69,8 +149,13 @@ export default ({ getService }: FtrProviderContext) => {
);
expect(rspBody).to.be.an(Array);

const responseModuleIds = rspBody.map((module: { id: string }) => module.id);
expect(responseModuleIds).to.eql(testData.expected.moduleIds);
const responseModuleIds = rspBody.map((module: { id: string }) => module.id).sort();
expect(responseModuleIds).to.eql(
testData.expected.moduleIds.sort(),
`Expected matching module ids for index '${
testData.indexPattern
}' to be '${testData.expected.moduleIds.sort()}' (got '${responseModuleIds}')`
);
});
});
}
Expand Down
Loading

0 comments on commit 6c7727e

Please sign in to comment.