Skip to content

Commit 5ed1d9c

Browse files
committed
Split Jest integration tests across 4 configs
1 parent b23dac4 commit 5ed1d9c

39 files changed

+98
-34
lines changed

x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_management_ui/pages/rule_management/__integration_tests__/rules_upgrade/upgrade_rule_after_preview/common_fields/jest.integration.config.js

Lines changed: 0 additions & 17 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
/* eslint-disable import/no-nodejs-modules */
9+
import fs from 'fs';
10+
import path from 'path';
11+
12+
const fieldsDir = __dirname;
13+
14+
// Discover all test files in the fields directory
15+
const allTestFiles = fs
16+
.readdirSync(fieldsDir)
17+
.filter((f) => f.endsWith('.test.ts'))
18+
.sort();
19+
20+
// Count config_* directories to determine total groups
21+
const totalGroups = fs.readdirSync(fieldsDir).filter((dir) => {
22+
const fullPath = path.join(fieldsDir, dir);
23+
return fs.statSync(fullPath).isDirectory() && dir.startsWith('config_');
24+
}).length;
25+
26+
/**
27+
* Discovers all field test files and distributes them using round-robin
28+
* across the available configs.
29+
*/
30+
function getTestsForConfig(configNumber) {
31+
const groupIndex = configNumber - 1;
32+
const configTestFiles = allTestFiles.filter((file, index) => index % totalGroups === groupIndex);
33+
34+
console.log(
35+
`Rule Upgrade - Fields integration tests. config_${configNumber}: Running ${configTestFiles.length} test files:`,
36+
configTestFiles
37+
);
38+
39+
return configTestFiles;
40+
}
41+
42+
/**
43+
* Base Jest configuration shared by all field test configs
44+
*/
45+
export function createFieldTestingConfig(configNumber) {
46+
const testFiles = getTestsForConfig(configNumber);
47+
48+
return {
49+
preset: '@kbn/test/jest_integration',
50+
rootDir: '../../../../../../../../../../../../../../..',
51+
roots: [
52+
'<rootDir>/x-pack/solutions/security/plugins/security_solution/public/detection_engine/rule_management_ui/pages/rule_management',
53+
],
54+
testMatch: testFiles.map((file) => `**/fields/${file}`),
55+
openHandlesTimeout: 0,
56+
forceExit: true,
57+
};
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { createFieldTestingConfig } from '../base.jest.integration.config';
9+
10+
export default createFieldTestingConfig(1);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { createFieldTestingConfig } from '../base.jest.integration.config';
9+
10+
export default createFieldTestingConfig(2);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { createFieldTestingConfig } from '../base.jest.integration.config';
9+
10+
export default createFieldTestingConfig(3);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import { createFieldTestingConfig } from '../base.jest.integration.config';
9+
10+
export default createFieldTestingConfig(4);

0 commit comments

Comments
 (0)