Skip to content

[Security Solution] Support rule id in wait for rule status helper#153410

Merged
maximpn merged 2 commits intoelastic:mainfrom
maximpn:support-rule-id-in-wait-for-rule-status
Mar 27, 2023
Merged

[Security Solution] Support rule id in wait for rule status helper#153410
maximpn merged 2 commits intoelastic:mainfrom
maximpn:support-rule-id-in-wait-for-rule-status

Conversation

@maximpn
Copy link
Copy Markdown
Contributor

@maximpn maximpn commented Mar 21, 2023

Relates to: #152900

Summary

This PR adds an ability to wait for rule status by its rule id in functional tests. It is a result of splitting of #150553 into isolated parts.

Details

Based on what kind of id is used (SO id or rule id) it leads to different behaviour under the hood. SO id related functionality consumes ES Get API while rule id related functionality consumes ES Search API. This way it may require to add some delay to let ES to refresh the data if the testing logic consumes ES Search API while rule status was awaited via SO id so that handled by ES Get API. This PR removes such a delay at rule exporting functional tests.

@maximpn maximpn added technical debt Improvement of the software architecture and operational architecture release_note:skip Skip the PR/issue when compiling release notes Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Rule Management Security Detection Rule Management Team backport:prev-minor v8.8.0 labels Mar 21, 2023
@maximpn maximpn self-assigned this Mar 21, 2023
@kibana-ci
Copy link
Copy Markdown

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @maximpn

@maximpn maximpn marked this pull request as ready for review March 22, 2023 10:37
@maximpn maximpn requested review from a team as code owners March 22, 2023 10:37
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-detections-response (Team:Detections and Resp)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-solution (Team: SecuritySolution)

@xcrzx xcrzx self-requested a review March 22, 2023 11:28
Copy link
Copy Markdown
Contributor

@xcrzx xcrzx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for cleaning this up, @maximpn. That part of our codebase truly needed some refactoring 🙌

Comment on lines -68 to +67
await waitForRuleSuccessOrStatus(
await waitForRulePartialFailure({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, this is much more readable now 👍

@maximpn maximpn merged commit 519185f into elastic:main Mar 27, 2023
@maximpn maximpn deleted the support-rule-id-in-wait-for-rule-status branch March 27, 2023 09:04
@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
8.7 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 153410

Questions ?

Please refer to the Backport tool documentation

@maximpn
Copy link
Copy Markdown
Contributor Author

maximpn commented Apr 4, 2023

💚 All backports created successfully

Status Branch Result
8.7

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

maximpn added a commit to maximpn/kibana that referenced this pull request Apr 4, 2023
…lastic#153410)

**Relates to:** elastic#152900

## Summary

This PR adds an ability to wait for rule status by its rule id in functional tests. It is a result of splitting of elastic#150553 into isolated parts.

## Details

Based on what kind of id is used (SO id or rule id) it leads to different behaviour under the hood. SO id related functionality consumes ES Get API while rule id related functionality consumes ES Search API. This way it may require to add some delay to let ES to refresh the data if the testing logic consumes ES Search API while rule status was awaited via SO id so that handled by ES Get API. This PR removes such a delay at rule exporting functional tests.

(cherry picked from commit 519185f)

# Conflicts:
#	x-pack/test/cases_api_integration/common/lib/alerts.ts
maximpn added a commit that referenced this pull request Apr 4, 2023
…per (#153410) (#154328)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Security Solution] Support rule id in wait for rule status helper
(#153410)](#153410)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Maxim
Palenov","email":"maxim.palenov@elastic.co"},"sourceCommit":{"committedDate":"2023-03-27T09:03:15Z","message":"[Security
Solution] Support rule id in wait for rule status helper
(#153410)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/152900\r\n\r\n##
Summary\r\n\r\nThis PR adds an ability to wait for rule status by its
rule id in functional tests. It is a result of splitting of
#150553 into isolated
parts.\r\n\r\n## Details\r\n\r\nBased on what kind of id is used (SO id
or rule id) it leads to different behaviour under the hood. SO id
related functionality consumes ES Get API while rule id related
functionality consumes ES Search API. This way it may require to add
some delay to let ES to refresh the data if the testing logic consumes
ES Search API while rule status was awaited via SO id so that handled by
ES Get API. This PR removes such a delay at rule exporting functional
tests.","sha":"519185ffa88aeea05626f71b303a7daf1ce9d14b","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["refactoring","technical
debt","release_note:skip","test-api-integration","Team:Detections and
Resp","Team: SecuritySolution","Team:Detection
Rules","backport:prev-minor","v8.8.0"],"number":153410,"url":"https://github.com/elastic/kibana/pull/153410","mergeCommit":{"message":"[Security
Solution] Support rule id in wait for rule status helper
(#153410)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/152900\r\n\r\n##
Summary\r\n\r\nThis PR adds an ability to wait for rule status by its
rule id in functional tests. It is a result of splitting of
#150553 into isolated
parts.\r\n\r\n## Details\r\n\r\nBased on what kind of id is used (SO id
or rule id) it leads to different behaviour under the hood. SO id
related functionality consumes ES Get API while rule id related
functionality consumes ES Search API. This way it may require to add
some delay to let ES to refresh the data if the testing logic consumes
ES Search API while rule status was awaited via SO id so that handled by
ES Get API. This PR removes such a delay at rule exporting functional
tests.","sha":"519185ffa88aeea05626f71b303a7daf1ce9d14b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/153410","number":153410,"mergeCommit":{"message":"[Security
Solution] Support rule id in wait for rule status helper
(#153410)\n\n**Relates to:**
https://github.com/elastic/kibana/pull/152900\r\n\r\n##
Summary\r\n\r\nThis PR adds an ability to wait for rule status by its
rule id in functional tests. It is a result of splitting of
#150553 into isolated
parts.\r\n\r\n## Details\r\n\r\nBased on what kind of id is used (SO id
or rule id) it leads to different behaviour under the hood. SO id
related functionality consumes ES Get API while rule id related
functionality consumes ES Search API. This way it may require to add
some delay to let ES to refresh the data if the testing logic consumes
ES Search API while rule status was awaited via SO id so that handled by
ES Get API. This PR removes such a delay at rule exporting functional
tests.","sha":"519185ffa88aeea05626f71b303a7daf1ce9d14b"}}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring release_note:skip Skip the PR/issue when compiling release notes Team:Detection Rule Management Security Detection Rule Management Team Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. technical debt Improvement of the software architecture and operational architecture test-api-integration v8.7.1 v8.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants