-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] Tests: Filter by rule execution status #160502
[Security Solution] Tests: Filter by rule execution status #160502
Conversation
b23c964
to
802ab7f
Compare
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikitaindik thank you for adding tests 👍 The changes look good to me, I just left some nit comments.
x-pack/plugins/security_solution/cypress/e2e/detection_rules/rule_fiters.cy.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Outdated
Show resolved
Hide resolved
985dc82
to
ccb807f
Compare
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Outdated
Show resolved
Hide resolved
Running this through the flakey test runner by the way! Just to make sure. 8.10 we're working through test flakes/failures so want to try and scrutinize (that sounds too harsh 😅 ) new tests a bit. https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/2547 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - we have rule failures in the flakey test runner but unrelated it seems. This test past all 50 runs.
494f880
to
664f0c7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall @nikitaindik, I just left a few comments.
x-pack/plugins/security_solution/cypress/screens/alerts_detection_rules.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/elasticsearch.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/cypress/tasks/api_calls/rules.ts
Outdated
Show resolved
Hide resolved
deleteIndex('test_index'); | ||
|
||
createIndex('test_index', { | ||
'@timestamp': { | ||
type: 'date', | ||
}, | ||
}); | ||
|
||
indexDocument('test_index', {}); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Successful rule', | ||
rule_id: 'successful_rule', | ||
index: ['test_index'], | ||
}) | ||
); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Warning rule', | ||
rule_id: 'warning_rule', | ||
index: ['non_existent_index'], | ||
}) | ||
); | ||
|
||
createRule( | ||
getNewRule({ | ||
name: 'Failed rule', | ||
rule_id: 'failed_rule', | ||
index: ['test_index'], | ||
// Setting a crazy large "Additional look-back time" to force a failure | ||
from: 'now-9007199254746990s', | ||
}) | ||
); | ||
|
||
waitForRulesToFinishExecution(['successful_rule', 'warning_rule', 'failed_rule']); | ||
|
||
visitWithoutDateRange(SECURITY_DETECTIONS_RULES_URL); | ||
|
||
waitForRulesTableToBeLoaded(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we need this in beforeEach
-- were you thinking about expanding the rules you created with more properties in the future, to be able to test other filtering scenarios?
If we keep it as is, let's maybe also do some cleanup after the test:
afterEach(() => {
deleteAlertsAndRules();
deleteIndex('test_index');
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I think it's a good idea to move non-common actions inside their respective it
blocks.
Can please elaborate on why it would be beneficial to also clean up in afterEach
? Wouldn't we do same actions twice then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can please elaborate on why it would be beneficial to also clean up in afterEach? Wouldn't we do same actions twice then?
@nikitaindik Yep, this is a good question. If we don't clean up, the rules we create in this test will continue to run in the next (and other) tests until a test cleans them up. This can have 2 downsides:
- The tests left running after this test will be generating load on the system when other tests will be starting/running. This could increase flakiness.
- If you ever need to debug those tests, you will see weird rule executions in the logs not related to the test you're debugging. This can be confusing.
// Setting a crazy large "Additional look-back time" to force a failure | ||
from: 'now-9007199254746990s', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! Just curious what failure does it cause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally the UI shouldn't allow sending invalid input, right?
@nikitaindik Yep. Neither the rule creation/editing UI nor the API should allow invalid parameter values. It would be great if you could open a bug ticket for this.
664f0c7
to
6cd5f2b
Compare
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Async chunks
Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @nikitaindik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for all the fixes @nikitaindik! 🎉
The only outstanding comment is the one about afterEach
. Please merge at will if/when you address it.
…60502) **Resolves: elastic#138903 ## Summary Adds an E2E Cypress test to check filtering by execution status in the rules table. <img width="953" alt="Screenshot 2023-06-26 at 14 10 10" src="https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc"> (cherry picked from commit c30a7d4)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…0502) (#161618) # Backport This will backport the following commits from `main` to `8.9`: - [[Security Solution] Tests: Filter by rule execution status (#160502)](#160502) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nikita Indik","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-07-11T08:12:37Z","message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","test_ui_functional","release_note:skip","Team:Detections and Resp","Team: SecuritySolution","Feature:Rule Management","Team:Detection Rule Management","v8.9.0","v8.10.0"],"number":160502,"url":"https://github.com/elastic/kibana/pull/160502","mergeCommit":{"message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160502","number":160502,"mergeCommit":{"message":"[Security Solution] Tests: Filter by rule execution status (#160502)\n\n**Resolves: https://github.com/elastic/kibana/issues/138903**\r\n\r\n## Summary\r\n\r\nAdds an E2E Cypress test to check filtering by execution status in the\r\nrules table.\r\n<img width=\"953\" alt=\"Screenshot 2023-06-26 at 14 10 10\"\r\nsrc=\"https://github.com/elastic/kibana/assets/15949146/e1eb67ed-779c-42ad-8194-04a26598cfbc\">","sha":"c30a7d47eb4a467734b08bfea1d8d3c3c301b5cb"}}]}] BACKPORT--> Co-authored-by: Nikita Indik <[email protected]>
Resolves: #138903
Summary
Adds an E2E Cypress test to check filtering by execution status in the rules table.