-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Security Solution] Parallelize slow Rule Management tests #234930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b23dac4
5ed1d9c
4b95753
a408aca
832e848
825ac58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| /* eslint-disable import/no-nodejs-modules */ | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
|
|
||
| const fieldsDir = __dirname; | ||
|
|
||
| // Discover all test files in the fields directory | ||
| const allTestFiles = fs | ||
| .readdirSync(fieldsDir) | ||
| .filter((f) => f.endsWith('.test.ts')) | ||
| .sort(); | ||
|
|
||
| // Count config_* directories to determine total groups | ||
| const totalGroups = fs.readdirSync(fieldsDir).filter((dir) => { | ||
| const fullPath = path.join(fieldsDir, dir); | ||
| return fs.statSync(fullPath).isDirectory() && dir.startsWith('config_'); | ||
| }).length; | ||
|
|
||
| /** | ||
| * Discovers all field test files and distributes them using round-robin | ||
| * across the available configs. | ||
| */ | ||
| function getTestsForConfig(configNumber) { | ||
| const groupIndex = configNumber - 1; | ||
| const configTestFiles = allTestFiles.filter((file, index) => index % totalGroups === groupIndex); | ||
|
||
|
|
||
| console.log( | ||
| `Rule Upgrade - Fields integration tests. config_${configNumber}: Running ${configTestFiles.length} test files:`, | ||
| configTestFiles | ||
| ); | ||
|
|
||
| return configTestFiles; | ||
| } | ||
|
|
||
| /** | ||
| * Base Jest configuration shared by all field test configs | ||
| */ | ||
| export function createFieldTestingConfig(configNumber) { | ||
| const testFiles = getTestsForConfig(configNumber); | ||
|
|
||
| return { | ||
| preset: '@kbn/test/jest_integration', | ||
| rootDir: '../../../../../../../../../../../../../../..', | ||
| roots: [ | ||
| '<rootDir>/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_management_ui/pages/rule_management', | ||
| ], | ||
| testMatch: testFiles.map((file) => `**/fields/${file}`), | ||
| openHandlesTimeout: 0, | ||
| forceExit: true, | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * 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 { createFieldTestingConfig } from '../base.jest.integration.config'; | ||
|
|
||
| export default createFieldTestingConfig(1); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * 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 { createFieldTestingConfig } from '../base.jest.integration.config'; | ||
|
|
||
| export default createFieldTestingConfig(2); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * 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 { createFieldTestingConfig } from '../base.jest.integration.config'; | ||
|
|
||
| export default createFieldTestingConfig(3); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| /* | ||
| * 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 { createFieldTestingConfig } from '../base.jest.integration.config'; | ||
|
|
||
| export default createFieldTestingConfig(4); |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
|
||
| export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
| const functionalConfig = await readConfigFile( | ||
| require.resolve('../../../../configs/ess/rules_management.trial.config') | ||
| ); | ||
|
|
||
| const testConfig = { | ||
| ...functionalConfig.getAll(), | ||
| testFiles: [require.resolve('..')], | ||
| junit: { | ||
| reportName: | ||
| 'Rules Management - Prebuilt Rules Upgrade Notifications (Customization Enabled) - ESS Env', | ||
| }, | ||
| }; | ||
|
|
||
| return testConfig; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * 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 { createCompleteTierTestConfig } from '../../../../configs/serverless/rules_management.complete.config'; | ||
|
|
||
| export default createCompleteTierTestConfig({ | ||
| testFiles: [require.resolve('..')], | ||
| junit: { | ||
| reportName: | ||
| 'Rules Management - Prebuilt Rules Upgrade Notifications (Customization Enabled) - Serverless Env', | ||
| }, | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* | ||
| * 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 { FtrConfigProviderContext } from '@kbn/test'; | ||
|
|
||
| export default async function ({ readConfigFile }: FtrConfigProviderContext) { | ||
| const functionalConfig = await readConfigFile( | ||
| require.resolve('../../../../configs/ess/rules_management.trial.config') | ||
| ); | ||
|
|
||
| const testConfig = { | ||
| ...functionalConfig.getAll(), | ||
| testFiles: [require.resolve('..')], | ||
| junit: { | ||
| reportName: 'Rules Management - Prebuilt Rules Upgrade (Customization Enabled) - ESS Env', | ||
| }, | ||
| }; | ||
|
|
||
| return testConfig; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| /* | ||
| * 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 { createCompleteTierTestConfig } from '../../../../configs/serverless/rules_management.complete.config'; | ||
|
|
||
| export default createCompleteTierTestConfig({ | ||
| testFiles: [require.resolve('..')], | ||
| junit: { | ||
| reportName: | ||
| 'Rules Management - Prebuilt Rules Upgrade (Customization Enabled) - Serverless Env', | ||
| }, | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.