-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Unskip bulk actions integration tests (#174757)
**Resolves: #173804** 500 runs of the flaky test file in ESS env: [Buildkite 4833](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4833) Even though I couldn't reproduce flakiness (1.5K runs), I've updated the test to fix a suspected race condition. What seems to be happening: In the `beforeEach` [here](https://github.com/nikitaindik/kibana/blob/b7b95111e010cc9fba618b625bb6f8c8969de1ec/x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_bulk_actions/perform_bulk_action_ess.ts#L477), three rules are created: - one with investigation_fields equal to `['client.address', 'agent.name']` - one with investigation_fields equal to `[]` - one with investigation_fields equal to `{ field_names: ['host.name'] }` Then, in the [test](https://github.com/nikitaindik/kibana/blob/b7b95111e010cc9fba618b625bb6f8c8969de1ec/x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_bulk_actions/perform_bulk_action_ess.ts#L506), we read all three rules and check them in that same order. But if the `[]` rule is created on the backend before the `['client.address', 'agent.name']` rule, our first check would fail. Other tests in this file don't expect rules to come in a particular order. Instead, they search for a needed rule in the array. I used the same approach for this flaky test. (cherry picked from commit 3213541)
- Loading branch information
1 parent
5ebb15e
commit a689e5b
Showing
3 changed files
with
189 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
x-pack/test/detection_engine_api_integration/utils/check_investigation_field_in_so.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 { Client } from '@elastic/elasticsearch'; | ||
import { SavedObjectReference } from '@kbn/core/server'; | ||
import { InvestigationFields } from '@kbn/security-solution-plugin/common/api/detection_engine'; | ||
import { Rule } from '@kbn/alerting-plugin/common'; | ||
import { BaseRuleParams } from '@kbn/security-solution-plugin/server/lib/detection_engine/rule_schema'; | ||
import { isEqual } from 'lodash/fp'; | ||
import { getRuleSOById } from './get_rule_so_by_id'; | ||
|
||
interface RuleSO { | ||
alert: Rule<BaseRuleParams>; | ||
references: SavedObjectReference[]; | ||
} | ||
|
||
export const checkInvestigationFieldSoValue = async ( | ||
ruleSO: RuleSO | undefined, | ||
expectedSoValue: undefined | InvestigationFields, | ||
es?: Client, | ||
ruleId?: string | ||
): Promise<boolean> => { | ||
if (!ruleSO && es && ruleId) { | ||
const { | ||
hits: { | ||
hits: [{ _source: rule }], | ||
}, | ||
} = await getRuleSOById(es, ruleId); | ||
|
||
return isEqual(rule?.alert.params.investigationFields, expectedSoValue); | ||
} | ||
|
||
return isEqual(ruleSO?.alert.params.investigationFields, expectedSoValue); | ||
}; |
Oops, something went wrong.