Skip to content

Commit 55260dd

Browse files
authored
[ML] Functional tests - add more recognize and setup module API tests (#69251)
This PR adds a couple recognize module and setup module API integration tests.
1 parent 3ea717a commit 55260dd

File tree

34 files changed

+19454
-79
lines changed

34 files changed

+19454
-79
lines changed

x-pack/test/api_integration/apis/ml/data_frame_analytics/delete.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export default ({ getService }: FtrProviderContext) => {
162162
});
163163

164164
after(async () => {
165-
await ml.testResources.deleteIndexPattern(destinationIndex);
165+
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
166166
});
167167

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

195195
after(async () => {
196196
await ml.api.deleteIndices(destinationIndex);
197-
await ml.testResources.deleteIndexPattern(destinationIndex);
197+
await ml.testResources.deleteIndexPatternByTitle(destinationIndex);
198198
});
199199

200200
it('should delete job, target index, and index pattern by id', async () => {

x-pack/test/api_integration/apis/ml/index.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,28 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
2222
await ml.securityCommon.cleanMlUsers();
2323
await ml.securityCommon.cleanMlRoles();
2424

25-
await ml.testResources.deleteIndexPattern('kibana_sample_data_logs');
26-
await ml.testResources.deleteIndexPattern('ft_farequote');
25+
await ml.testResources.deleteIndexPatternByTitle('ft_module_apache');
26+
await ml.testResources.deleteIndexPatternByTitle('ft_module_apm');
27+
await ml.testResources.deleteIndexPatternByTitle('ft_module_logs');
28+
await ml.testResources.deleteIndexPatternByTitle('ft_module_nginx');
29+
await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_ecommerce');
30+
await ml.testResources.deleteIndexPatternByTitle('ft_module_sample_logs');
31+
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_auditbeat');
32+
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_packetbeat');
33+
await ml.testResources.deleteIndexPatternByTitle('ft_module_siem_winlogbeat');
34+
await ml.testResources.deleteIndexPatternByTitle('ft_farequote');
2735

2836
await esArchiver.unload('ml/ecommerce');
2937
await esArchiver.unload('ml/categorization');
30-
await esArchiver.unload('ml/sample_logs');
38+
await esArchiver.unload('ml/module_apache');
39+
await esArchiver.unload('ml/module_apm');
40+
await esArchiver.unload('ml/module_logs');
41+
await esArchiver.unload('ml/module_nginx');
42+
await esArchiver.unload('ml/module_sample_ecommerce');
43+
await esArchiver.unload('ml/module_sample_logs');
44+
await esArchiver.unload('ml/module_siem_auditbeat');
45+
await esArchiver.unload('ml/module_siem_packetbeat');
46+
await esArchiver.unload('ml/module_siem_winlogbeat');
3147
await esArchiver.unload('ml/farequote');
3248
await esArchiver.unload('ml/bm_classification');
3349

x-pack/test/api_integration/apis/ml/modules/recognize_module.ts

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,94 @@ export default ({ getService }: FtrProviderContext) => {
1919
const testDataList = [
2020
{
2121
testTitleSuffix: 'for sample logs dataset',
22-
sourceDataArchive: 'ml/sample_logs',
23-
indexPattern: 'kibana_sample_data_logs',
22+
sourceDataArchive: 'ml/module_sample_logs',
23+
indexPattern: 'ft_module_sample_logs',
2424
user: USER.ML_POWERUSER,
2525
expected: {
2626
responseCode: 200,
2727
moduleIds: ['sample_data_weblogs'],
2828
},
2929
},
30+
{
31+
testTitleSuffix: 'for apache dataset',
32+
sourceDataArchive: 'ml/module_apache',
33+
indexPattern: 'ft_module_apache',
34+
user: USER.ML_POWERUSER,
35+
expected: {
36+
responseCode: 200,
37+
moduleIds: ['apache_ecs'],
38+
},
39+
},
40+
{
41+
testTitleSuffix: 'for apm dataset',
42+
sourceDataArchive: 'ml/module_apm',
43+
indexPattern: 'ft_module_apm',
44+
user: USER.ML_POWERUSER,
45+
expected: {
46+
responseCode: 200,
47+
moduleIds: ['apm_jsbase', 'apm_transaction', 'apm_nodejs'],
48+
},
49+
},
50+
{
51+
testTitleSuffix: 'for logs dataset',
52+
sourceDataArchive: 'ml/module_logs',
53+
indexPattern: 'ft_module_logs',
54+
user: USER.ML_POWERUSER,
55+
expected: {
56+
responseCode: 200,
57+
moduleIds: [], // the logs modules don't define a query and can't be recognized
58+
},
59+
},
60+
{
61+
testTitleSuffix: 'for nginx dataset',
62+
sourceDataArchive: 'ml/module_nginx',
63+
indexPattern: 'ft_module_nginx',
64+
user: USER.ML_POWERUSER,
65+
expected: {
66+
responseCode: 200,
67+
moduleIds: ['nginx_ecs'],
68+
},
69+
},
70+
{
71+
testTitleSuffix: 'for sample ecommerce dataset',
72+
sourceDataArchive: 'ml/module_sample_ecommerce',
73+
indexPattern: 'ft_module_sample_ecommerce',
74+
user: USER.ML_POWERUSER,
75+
expected: {
76+
responseCode: 200,
77+
moduleIds: ['sample_data_ecommerce'],
78+
},
79+
},
80+
{
81+
testTitleSuffix: 'for siem auditbeat dataset',
82+
sourceDataArchive: 'ml/module_siem_auditbeat',
83+
indexPattern: 'ft_module_siem_auditbeat',
84+
user: USER.ML_POWERUSER,
85+
expected: {
86+
responseCode: 200,
87+
moduleIds: ['siem_auditbeat', 'siem_auditbeat_auth'],
88+
},
89+
},
90+
{
91+
testTitleSuffix: 'for siem packetbeat dataset',
92+
sourceDataArchive: 'ml/module_siem_packetbeat',
93+
indexPattern: 'ft_module_siem_packetbeat',
94+
user: USER.ML_POWERUSER,
95+
expected: {
96+
responseCode: 200,
97+
moduleIds: ['siem_packetbeat'],
98+
},
99+
},
100+
{
101+
testTitleSuffix: 'for siem winlogbeat dataset',
102+
sourceDataArchive: 'ml/module_siem_winlogbeat',
103+
indexPattern: 'ft_module_siem_winlogbeat',
104+
user: USER.ML_POWERUSER,
105+
expected: {
106+
responseCode: 200,
107+
moduleIds: ['siem_winlogbeat'],
108+
},
109+
},
30110
{
31111
testTitleSuffix: 'for non existent index pattern',
32112
indexPattern: 'non-existent-index-pattern',
@@ -69,8 +149,13 @@ export default ({ getService }: FtrProviderContext) => {
69149
);
70150
expect(rspBody).to.be.an(Array);
71151

72-
const responseModuleIds = rspBody.map((module: { id: string }) => module.id);
73-
expect(responseModuleIds).to.eql(testData.expected.moduleIds);
152+
const responseModuleIds = rspBody.map((module: { id: string }) => module.id).sort();
153+
expect(responseModuleIds).to.eql(
154+
testData.expected.moduleIds.sort(),
155+
`Expected matching module ids for index '${
156+
testData.indexPattern
157+
}' to be '${testData.expected.moduleIds.sort()}' (got '${responseModuleIds}')`
158+
);
74159
});
75160
});
76161
}

0 commit comments

Comments
 (0)