Skip to content

Commit aefa70d

Browse files
banderrormaximpn
andauthored
[9.1] [Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689) (#231823)
# Backport This will backport the following commits from `main` to `9.1`: - [[Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689)](#229689) <!--- Backport version: 10.0.1 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Maxim Palenov","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-08-13T12:31:26Z","message":"[Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689)\n\n**Resolves: https://github.com/elastic/kibana/issues/182441**\n**Resolves: https://github.com/elastic/kibana/issues/182442**\n**Resolves: https://github.com/elastic/kibana/issues/228942**\n**Relates to: https://github.com/elastic/kibana/pull/227689**\n\n## Summary\n\nThis PR installs mock prebuilt rules package for e2e Cypress test to\nreduce flakniess caused by accessing to the real EPR. It's similar to\nthe mock package installation in integration tests\n[PR](https://github.com/elastic/kibana/pull/227689).\n\n**Flaky test runner**\n- ESS:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9120\n- Serverless:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9121","sha":"980add17c585d370d555e93b9146bbaad5d7a2d4","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","release_note:skip","impact:high","Team:Detections and Resp","Team: SecuritySolution","Team:Detection Rule Management","Feature:Prebuilt Detection Rules","backport:version","v9.2.0","v9.1.3","v8.19.3","v9.0.6","v8.18.6"],"title":"[Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness","number":229689,"url":"https://github.com/elastic/kibana/pull/229689","mergeCommit":{"message":"[Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689)\n\n**Resolves: https://github.com/elastic/kibana/issues/182441**\n**Resolves: https://github.com/elastic/kibana/issues/182442**\n**Resolves: https://github.com/elastic/kibana/issues/228942**\n**Relates to: https://github.com/elastic/kibana/pull/227689**\n\n## Summary\n\nThis PR installs mock prebuilt rules package for e2e Cypress test to\nreduce flakniess caused by accessing to the real EPR. It's similar to\nthe mock package installation in integration tests\n[PR](https://github.com/elastic/kibana/pull/227689).\n\n**Flaky test runner**\n- ESS:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9120\n- Serverless:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9121","sha":"980add17c585d370d555e93b9146bbaad5d7a2d4"}},"sourceBranch":"main","suggestedTargetBranches":["9.1"],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/229689","number":229689,"mergeCommit":{"message":"[Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689)\n\n**Resolves: https://github.com/elastic/kibana/issues/182441**\n**Resolves: https://github.com/elastic/kibana/issues/182442**\n**Resolves: https://github.com/elastic/kibana/issues/228942**\n**Relates to: https://github.com/elastic/kibana/pull/227689**\n\n## Summary\n\nThis PR installs mock prebuilt rules package for e2e Cypress test to\nreduce flakniess caused by accessing to the real EPR. It's similar to\nthe mock package installation in integration tests\n[PR](https://github.com/elastic/kibana/pull/227689).\n\n**Flaky test runner**\n- ESS:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9120\n- Serverless:\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/9121","sha":"980add17c585d370d555e93b9146bbaad5d7a2d4"}},{"branch":"9.1","label":"v9.1.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.19","label":"v8.19.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/231613","number":231613,"state":"OPEN"},{"branch":"9.0","label":"v9.0.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/231625","number":231625,"state":"MERGED","mergeCommit":{"sha":"486b8164ee7c6eabf4cd31d183409fe5c366a553","message":"[9.0] [Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689) (#231625)\n\n# Backport\n\nThis will backport the following commits from `main` to `9.0`:\n- [[Security Solution] Install mock prebuilt rules package in Cypress to\nreduce flakiness\n(#229689)](https://github.com/elastic/kibana/pull/229689)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}},{"branch":"8.18","label":"v8.18.6","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/231628","number":231628,"state":"MERGED","mergeCommit":{"sha":"931e5ea6edad4fad74a3b116fea66e8f440eab43","message":"[8.18] [Security Solution] Install mock prebuilt rules package in Cypress to reduce flakiness (#229689) (#231628)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.18`:\n- [[Security Solution] Install mock prebuilt rules package in Cypress to\nreduce flakiness\n(#229689)](https://github.com/elastic/kibana/pull/229689)\n\n\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sorenlouv/backport)\n\n"}}]}] BACKPORT--> Co-authored-by: Maxim Palenov <[email protected]>
1 parent 2b24193 commit aefa70d

37 files changed

+551
-384
lines changed

x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/authorization/all_rules_read_only.cy.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
import { ROLES } from '@kbn/security-solution-plugin/common/test';
99

10-
import { getNewRule } from '../../../../objects/rule';
10+
import { installMockPrebuiltRulesPackage } from '../../../../tasks/api_calls/prebuilt_rules';
11+
import { getCustomQueryRuleParams, getNewRule } from '../../../../objects/rule';
1112
import {
1213
COLLAPSED_ACTION_BTN,
1314
RULE_CHECKBOX,
@@ -28,12 +29,16 @@ import { deleteAlertsAndRules } from '../../../../tasks/api_calls/common';
2829
// TODO: https://github.com/elastic/kibana/issues/164451 We should find a way to make this spec work in Serverless
2930
// TODO: https://github.com/elastic/kibana/issues/161540
3031
describe('All rules - read only', { tags: ['@ess', '@serverless', '@skipInServerless'] }, () => {
32+
before(() => {
33+
installMockPrebuiltRulesPackage();
34+
});
35+
3136
beforeEach(() => {
3237
deleteAlertsAndRules();
33-
createRule(getNewRule({ rule_id: '1', enabled: false }));
38+
createRule(getCustomQueryRuleParams({ rule_id: '1', enabled: false }));
3439
login(ROLES.t1_analyst);
3540
visitRulesManagementTable();
36-
cy.get(RULE_NAME).should('have.text', getNewRule().name);
41+
cy.get(RULE_NAME).should('have.text', getCustomQueryRuleParams().name);
3742
});
3843

3944
it('Does not display select boxes for rules', () => {

x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/coverage_overview/coverage_overview.cy.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ import { createRule } from '../../../../tasks/api_calls/rules';
2222
import { visit } from '../../../../tasks/navigation';
2323
import { RULES_COVERAGE_OVERVIEW_URL } from '../../../../urls/rules_management';
2424
import { createRuleAssetSavedObject } from '../../../../helpers/rules';
25-
import { getNewRule } from '../../../../objects/rule';
25+
import { getCustomQueryRuleParams, getNewRule } from '../../../../objects/rule';
2626
import {
2727
createAndInstallMockedPrebuiltRules,
28+
installMockPrebuiltRulesPackage,
2829
preventPrebuiltRulesPackageInstallation,
2930
} from '../../../../tasks/api_calls/prebuilt_rules';
3031
import {
@@ -191,6 +192,10 @@ const prebuiltRules = [
191192

192193
// https://github.com/elastic/kibana/issues/179052
193194
describe('Coverage overview', { tags: ['@ess', '@serverless', '@skipInServerless'] }, () => {
195+
before(() => {
196+
installMockPrebuiltRulesPackage();
197+
});
198+
194199
describe('base cases', () => {
195200
beforeEach(() => {
196201
login();
@@ -199,15 +204,15 @@ describe('Coverage overview', { tags: ['@ess', '@serverless', '@skipInServerless
199204
preventPrebuiltRulesPackageInstallation();
200205
createAndInstallMockedPrebuiltRules(prebuiltRules);
201206
createRule(
202-
getNewRule({
207+
getCustomQueryRuleParams({
203208
rule_id: 'enabled_custom_rule',
204209
enabled: true,
205210
name: 'Enabled custom rule',
206211
threat: [MockEnabledCustomRuleThreat],
207212
})
208213
);
209214
createRule(
210-
getNewRule({
215+
getCustomQueryRuleParams({
211216
rule_id: 'disabled_custom_rule',
212217
name: 'Disabled custom rule',
213218
enabled: false,

x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/maintenance_windows/maintenance_window_callout.cy.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import { INTERNAL_ALERTING_API_MAINTENANCE_WINDOW_PATH } from '@kbn/alerting-plugin/common';
99
import type { MaintenanceWindowCreateBody } from '@kbn/alerting-plugin/common';
1010
import type { AsApiContract } from '@kbn/alerting-plugin/server/routes/lib';
11+
import { installMockPrebuiltRulesPackage } from '../../../../tasks/api_calls/prebuilt_rules';
1112
import { login } from '../../../../tasks/login';
1213
import { visit } from '../../../../tasks/navigation';
1314
import { RULES_MANAGEMENT_URL } from '../../../../urls/rules_management';
@@ -17,6 +18,10 @@ describe(
1718
'Maintenance window callout on Rule Management page',
1819
{ tags: ['@ess', '@serverless', '@skipInServerless'] },
1920
() => {
21+
before(() => {
22+
installMockPrebuiltRulesPackage();
23+
});
24+
2025
let maintenanceWindowId = '';
2126

2227
beforeEach(() => {

x-pack/solutions/security/test/security_solution_cypress/cypress/e2e/detection_response/rule_management/prebuilt_rules/customization/revert_prebuilt_rule.cy.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import {
2929
} from '../../../../../tasks/api_calls/common';
3030
import {
3131
createAndInstallMockedPrebuiltRules,
32+
installMockPrebuiltRulesPackage,
3233
preventPrebuiltRulesPackageInstallation,
3334
} from '../../../../../tasks/api_calls/prebuilt_rules';
3435
import { createRule, patchRule } from '../../../../../tasks/api_calls/rules';
@@ -44,6 +45,10 @@ describe(
4445

4546
() => {
4647
describe('Reverting prebuilt rules', () => {
48+
before(() => {
49+
installMockPrebuiltRulesPackage();
50+
});
51+
4752
const PREBUILT_RULE = createRuleAssetSavedObject({
4853
name: 'Non-customized prebuilt rule',
4954
rule_id: 'rule_1',
@@ -52,12 +57,13 @@ describe(
5257
});
5358

5459
beforeEach(() => {
55-
login();
5660
deleteAlertsAndRules();
5761
deletePrebuiltRulesAssets();
5862
preventPrebuiltRulesPackageInstallation();
5963
/* Create a new rule and install it */
6064
createAndInstallMockedPrebuiltRules([PREBUILT_RULE]);
65+
66+
login();
6167
visitRulesManagementTable();
6268
});
6369

0 commit comments

Comments
 (0)