Skip to content

Commit cb8bda1

Browse files
kibanamachinerylnd
andauthored
[9.0] [Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive (#222691) (#222893)
# Backport This will backport the following commits from `main` to `9.0`: - [[Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive (#222691)](#222691) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ryland Herrick","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-06-05T20:05:06Z","message":"[Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive (#222691)\n\n## Summary\n\nThis test has [failed a few times\nrecently](#219112) with a\n`version_conflict_engine_exception`, stating explicitly that the\ndocuments we're trying to load already exist in elasticsearch. In one\ncase the reason was obvious (the suite was retried), but in another it\nwas not clear why the data was there to cause this exception.\n\nRegardless, adding this sanity check (deleting all the alerts) should\nensure that this behavior does not recur.\n\nCloses #219112.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n([200x](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8329))\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"7fe71b3f4ee4b68e22bb424aa7b8ccc2e3c40f1a","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","backport:all-open","Team:Detection Engine","8.19 candidate","v9.1.0"],"title":"[Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive","number":222691,"url":"https://github.com/elastic/kibana/pull/222691","mergeCommit":{"message":"[Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive (#222691)\n\n## Summary\n\nThis test has [failed a few times\nrecently](#219112) with a\n`version_conflict_engine_exception`, stating explicitly that the\ndocuments we're trying to load already exist in elasticsearch. In one\ncase the reason was obvious (the suite was retried), but in another it\nwas not clear why the data was there to cause this exception.\n\nRegardless, adding this sanity check (deleting all the alerts) should\nensure that this behavior does not recur.\n\nCloses #219112.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n([200x](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8329))\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"7fe71b3f4ee4b68e22bb424aa7b8ccc2e3c40f1a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/222691","number":222691,"mergeCommit":{"message":"[Detection Engine][Test Fix] Ensure that alerts are absent before loading our alerts archive (#222691)\n\n## Summary\n\nThis test has [failed a few times\nrecently](#219112) with a\n`version_conflict_engine_exception`, stating explicitly that the\ndocuments we're trying to load already exist in elasticsearch. In one\ncase the reason was obvious (the suite was retried), but in another it\nwas not clear why the data was there to cause this exception.\n\nRegardless, adding this sanity check (deleting all the alerts) should\nensure that this behavior does not recur.\n\nCloses #219112.\n\n\n- [x] [Unit or functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere updated or added to match the most common scenarios\n- [x] [Flaky Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\nused on any tests changed\n([200x](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8329))\n- [x] The PR description includes the appropriate Release Notes section,\nand the correct `release_note:*` label is applied per the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"7fe71b3f4ee4b68e22bb424aa7b8ccc2e3c40f1a"}}]}] BACKPORT--> Co-authored-by: Ryland Herrick <[email protected]>
1 parent 99a90a3 commit cb8bda1

File tree

1 file changed

+6
-0
lines changed
  • x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/alerts/trial_license_complete_tier

1 file changed

+6
-0
lines changed

x-pack/test/security_solution_api_integration/test_suites/detections_response/detection_engine/alerts/trial_license_complete_tier/document_level_security.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import expect from '@kbn/expect';
99

1010
import { DETECTION_ENGINE_QUERY_SIGNALS_URL } from '@kbn/security-solution-plugin/common/constants';
1111
import { FtrProviderContext } from '../../../../../ftr_provider_context';
12+
import { deleteAllAlerts } from '../../../../../../common/utils/security_solution';
1213

1314
const roleToAccessSecuritySolution = {
1415
name: 'sec_all_spaces',
@@ -73,6 +74,10 @@ export default ({ getService }: FtrProviderContext) => {
7374
const supertestWithoutAuth = getService('supertestWithoutAuth');
7475
const esArchiver = getService('esArchiver');
7576
const security = getService('security');
77+
const supertest = getService('supertest');
78+
const log = getService('log');
79+
const es = getService('es');
80+
7681
// Notes: Similar tests should be added for serverless once infrastructure
7782
// is in place to test roles in MKI enviornment.
7883
describe('@ess @skipInServerless find alert with/without doc level security', () => {
@@ -98,6 +103,7 @@ export default ({ getService }: FtrProviderContext) => {
98103
email: userAllSecWithDls.email,
99104
});
100105

106+
await deleteAllAlerts(supertest, log, es);
101107
await esArchiver.load(
102108
'x-pack/test/functional/es_archives/security_solution/alerts/8.8.0_multiple_docs',
103109
{

0 commit comments

Comments
 (0)