Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] [Detection Engine] Fix exception comment flakiness #162807

Merged
merged 11 commits into from
Aug 1, 2023

Conversation

WafaaNasr
Copy link
Contributor

@WafaaNasr WafaaNasr commented Jul 31, 2023

Summary

@WafaaNasr WafaaNasr added WIP Work in progress release_note:skip Skip the PR/issue when compiling release notes test-failure-flaky Team:Detection Engine Security Solution Detection Engine Area labels Jul 31, 2023
@WafaaNasr WafaaNasr requested a review from a team as a code owner July 31, 2023 14:54
@WafaaNasr WafaaNasr self-assigned this Jul 31, 2023
@WafaaNasr WafaaNasr requested a review from a team as a code owner July 31, 2023 14:54
@kibanamachine kibanamachine requested a review from a team as a code owner July 31, 2023 18:16
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

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

cc @WafaaNasr

namespace_type: NamespaceType;
};
}
describe('Add, copy comments in different exceptions type and validate sharing them between users', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I would advocate for leaving at least one UI test for comments. Not necessary it should be complicated test with 2 different users. Just one user, creating one simple comment.
I think that would be beneficial to keep as it will give us confidence that UI is not broken

Copy link
Contributor

Choose a reason for hiding this comment

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

Resort to only one user, should fix this issue? Is that correct? From observations

Navigating to Exceptions from the Rules table after logging in with the second user

That leaves us with:

Asserting that the exception table has two exceptions because the created exception doesn't appear immediately in the
table after the addition, as well asserting that comment is created successfully

Maybe page reload/retry might help with it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, Vitalii for the review :)

I would advocate for leaving at least one UI test for comments

We have UI coverage for the comments panel in Cypress in other tests one of them x-pack/plugins/security_solution/cypress/e2e/exceptions/alerts_table_flow/rule_exceptions/auto_populate_with_alert_data.cy.ts

Unfortunately, the test sometimes is quite flaky in the first steps because the Exception flyout keeps re-rendering which was the reason behind skipping the Exception Flyout validation suite as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, I agree with you that it is not clear in the issue that the issue is not related to the logic.

I will update it with the issue related to multiple rendering

Copy link
Contributor

@vitaliidm vitaliidm Aug 1, 2023

Choose a reason for hiding this comment

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

@WafaaNasr

pack/plugins/security_solution/cypress/e2e/exceptions/alerts_table_flow/rule_exceptions/auto_populate_with_alert_data.cy.ts

is there tested functionality related to comments? I don't see any calls for addExceptionComment. It looks like we don't have any tests that cover this part of UI anymore after merge

Copy link
Contributor Author

@WafaaNasr WafaaNasr Aug 1, 2023

Choose a reason for hiding this comment

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

The addExceptionComment util I added it to open the comment panel and add a comment, and it is indeed unused now (so it should be removed) in the auto_populate_with_alert_data.cy.ts when the user opens the exception, the comment panel will be opened, and pre-filled that's why the test is not flaky because Cypress, in that case, will assert only that the comment panel is opened, the correct comments count is populated along with the text without clicking on the panel and going through the element got lost when the flyout gets rendered multiple times

Copy link
Contributor

@dhurley14 dhurley14 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -6,15 +6,16 @@
*/

import { ToolingLog } from '@kbn/tooling-log';
import expect from '@kbn/expect';
import expect from 'expect';
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we moving away from our local fork of expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

'm not certain if it has been recently recommended as a best practice, but I noticed that the new tests are using import expect from 'expect;' instead of @kbn/expect. Additionally, I had to utilize expect.arrayContaining and expect.objectContaining to perform assertions on specific data parts rather than the entire data, resulting in reduced test flakiness.🤞

@WafaaNasr WafaaNasr merged commit a2275dd into elastic:main Aug 1, 2023
@WafaaNasr WafaaNasr deleted the fix-comment-flakiness branch August 1, 2023 13:58
@kibanamachine kibanamachine added v8.10.0 backport:skip This commit does not require backporting labels Aug 1, 2023
ThomThomson pushed a commit to ThomThomson/kibana that referenced this pull request Aug 1, 2023
elastic#162807)

## Summary

- Addresses elastic#162565 
- Converting the `Comments` related Cypress test to a FTR test according
to these
[observations](elastic#162565 (comment))

---------

Co-authored-by: kibanamachine <[email protected]>
@WafaaNasr WafaaNasr added v8.9.2 and removed backport:skip This commit does not require backporting labels Aug 23, 2023
@WafaaNasr WafaaNasr restored the fix-comment-flakiness branch August 23, 2023 12:23
@WafaaNasr
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
8.9

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

Questions ?

Please refer to the Backport tool documentation

WafaaNasr added a commit that referenced this pull request Aug 24, 2023
…akiness (#162807) (#164621)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Security Solution] [Detection Engine] Fix exception comment
flakiness (#162807)](#162807)

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

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

<!--BACKPORT [{"author":{"name":"Wafaa
Nasr","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-08-01T13:58:40Z","message":"[Security
Solution] [Detection Engine] Fix exception comment flakiness
(#162807)\n\n## Summary\r\n\r\n- Addresses
#162565 \r\n- Converting the
`Comments` related Cypress test to a FTR test according\r\nto
these\r\n[observations](https://github.com/elastic/kibana/issues/162565#issuecomment-1653410937)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"a2275dd346b027db0224e7afa5df58158eb9b641","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["WIP","release_note:skip","test-failure-flaky","Team:Detection
Engine","v8.10.0","v8.9.2"],"number":162807,"url":"https://github.com/elastic/kibana/pull/162807","mergeCommit":{"message":"[Security
Solution] [Detection Engine] Fix exception comment flakiness
(#162807)\n\n## Summary\r\n\r\n- Addresses
#162565 \r\n- Converting the
`Comments` related Cypress test to a FTR test according\r\nto
these\r\n[observations](https://github.com/elastic/kibana/issues/162565#issuecomment-1653410937)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"a2275dd346b027db0224e7afa5df58158eb9b641"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/162807","number":162807,"mergeCommit":{"message":"[Security
Solution] [Detection Engine] Fix exception comment flakiness
(#162807)\n\n## Summary\r\n\r\n- Addresses
#162565 \r\n- Converting the
`Comments` related Cypress test to a FTR test according\r\nto
these\r\n[observations](https://github.com/elastic/kibana/issues/162565#issuecomment-1653410937)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"a2275dd346b027db0224e7afa5df58158eb9b641"}},{"branch":"8.9","label":"v8.9.2","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->
@WafaaNasr WafaaNasr deleted the fix-comment-flakiness branch February 6, 2024 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Detection Engine Security Solution Detection Engine Area test-failure-flaky v8.9.2 v8.10.0 WIP Work in progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants