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] Tests: Filter by rule execution status #160502

Merged

Conversation

nikitaindik
Copy link
Contributor

@nikitaindik nikitaindik commented Jun 26, 2023

Resolves: #138903

Summary

Adds an E2E Cypress test to check filtering by execution status in the rules table.
Screenshot 2023-06-26 at 14 10 10

@nikitaindik nikitaindik force-pushed the rule-execution-status-filter-e2e-tests branch from b23c964 to 802ab7f Compare June 26, 2023 12:08
@nikitaindik nikitaindik self-assigned this Jun 26, 2023
@nikitaindik nikitaindik added v8.9.0 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. Feature:Rule Management Security Solution Detection Rule Management area Team:Detection Rule Management Security Detection Rule Management Team labels Jun 26, 2023
@nikitaindik nikitaindik marked this pull request as ready for review June 26, 2023 14:05
@nikitaindik nikitaindik requested review from a team as code owners June 26, 2023 14:05
@nikitaindik nikitaindik requested a review from maximpn June 26, 2023 14:05
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@maximpn maximpn left a 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.

@nikitaindik nikitaindik force-pushed the rule-execution-status-filter-e2e-tests branch from 985dc82 to ccb807f Compare June 30, 2023 14:16
@yctercero
Copy link
Contributor

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

@nikitaindik nikitaindik requested a review from yctercero July 4, 2023 13:55
Copy link
Contributor

@yctercero yctercero left a 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.

@nikitaindik nikitaindik force-pushed the rule-execution-status-filter-e2e-tests branch from 494f880 to 664f0c7 Compare July 5, 2023 21:16
Copy link
Contributor

@banderror banderror left a 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.

Comment on lines 40 to 80
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();
Copy link
Contributor

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');
    });

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! 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?

Copy link
Contributor

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.

Comment on lines 71 to 72
// Setting a crazy large "Additional look-back time" to force a failure
from: 'now-9007199254746990s',
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Complains about invalid time value. Ideally the UI shouldn't allow sending invalid input, right?

Screenshot 2023-07-06 at 16 37 32

Copy link
Contributor

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.

@nikitaindik nikitaindik force-pushed the rule-execution-status-filter-e2e-tests branch from 664f0c7 to 6cd5f2b Compare July 6, 2023 14:49
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Explore - Security Solution Tests #2 / Entity Analytics Dashboard With anomalies data enables a job
  • [job] [logs] Security Solution Tests #6 / Export rules shows a modal saying that no rules can be exported if all the selected rules are prebuilt

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 11.0MB 11.0MB +146.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 410 414 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 489 493 +4
total +6

History

  • 💔 Build #140459 failed 664f0c7bc98cd2145d52dda8cd9f0135a0cb7a9a
  • 💚 Build #139646 succeeded 494f880d934f337ddde4bb3cf7cd824a234a98f8
  • 💔 Build #139467 failed ccb807fcf70bf03963512d44112cb906d4cda20f
  • 💛 Build #138066 was flaky 985dc825404eaf9d59835a58ff871d224e9574e5
  • 💔 Build #138028 failed b23c9648da1c8637b686bc07fa97eb1ffee4900e

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

cc @nikitaindik

Copy link
Contributor

@banderror banderror left a 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.

@banderror banderror merged commit c30a7d4 into elastic:main Jul 11, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 11, 2023
…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)
@kibanamachine
Copy link
Contributor

💚 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

kibanamachine added a commit that referenced this pull request Jul 11, 2023
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Rule Management Security Solution Detection Rule Management area 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. test_ui_functional test v8.9.0 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution] Add a filter by rule execution status to the Rules table
7 participants