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] Enable Cypress tests in Serverless: Detection Engine area #161539

Closed
Tracked by #153633
banderror opened this issue Jul 10, 2023 · 3 comments
Closed
Tracked by #153633
Assignees
Labels
8.12 candidate Team:Detection Engine Security Solution Detection Engine Area Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. test test-coverage issues & PRs for improving code test coverage

Comments

@banderror
Copy link
Contributor

banderror commented Jul 10, 2023

Epic: #153633
Depends on: #161537, #164441

Summary

We need to create a suite of Cypress E2E tests that will run against Serverless environments.

In x-pack/test/security_solution_cypress, we already have existing Cypress tests that run "in ESS", meaning against non-serverless environments. We need to start gradually including these Cypress tests in the Serverless suite by:

  • Fixing the tests tagged as BROKEN_IN_SERVERLESS and removing this tag
  • Unskipping the tests tagged as SKIP_IN_SERVERLESS and removing this tag
  • Tagging any test that should run in Serverless as SERVERLESS
  • Making sure that every test we include is not flaky in Serverless and ESS

Ideally, we'd do it gradually, in multiple PRs, starting from covering the most critical features and use cases, and proceeding with less important ones.

@botelastic botelastic bot added the needs-team Issues missing a team label label Jul 10, 2023
@banderror banderror changed the title Add Serverless tests: Detection Engine area [Security Solution] Add Serverless tests: Detection Engine area Jul 10, 2023
@banderror banderror added test test-coverage issues & PRs for improving code test coverage Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Engine Security Solution Detection Engine Area 8.10 candidate labels Jul 10, 2023
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jul 10, 2023
@banderror banderror changed the title [Security Solution] Add Serverless tests: Detection Engine area [Security Solution] Enable existing Cypress tests in Serverless: Detection Engine area Aug 22, 2023
@banderror banderror changed the title [Security Solution] Enable existing Cypress tests in Serverless: Detection Engine area [Security Solution] Enable Cypress tests in Serverless: Detection Engine area Aug 22, 2023
banderror added a commit that referenced this issue Sep 9, 2023
…rverless (#165966)

**Resolves: #164441

## Summary

Skips all Cypress tests owned by
@elastic/security-detection-rule-management and
@elastic/security-detection-engine teams in Serverless using the new
`@skipInServerless` tag.

- Adds a new `@skipInServerless` tag
- Updates `x-pack/test/security_solution_cypress/cypress/README.md` to
explain when to use what tags
- Explicitly adds missing tags to all D&R tests
- Adds `// TODO:` comments to tests with links to follow-up tickets
- Fixes the
`x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts`
script (see below)

Follow-up work:

- #161540
- #161539

## Context

> Serverless test failures will soon block PR merge

> During the development of the serverless test infrastructure, we
decided that serverless tests will only soft-fail. That means you see
the test failure in your PR but you're still able to merge. We did that
mainly in order to not block delivery of stateful features and bug fixes
while serverless tests and pipelines were implemented and stabilized.
We now have the major building blocks for the serverless test
infrastructure in place and will integrate serverless tests in our
regular pipelines. As part of this process, we're skipping failing and
flaky serverless tests that came in during the soft-fail phase. Once
this is done, a PR with serverless test failures can no longer be
merged, similar to how we have it for stateful test failures.

> We plan to merge this in the next few days and we'll send out another
notification when it's done.

## Fixing `parallel.ts`

There were two problems with the
`x-pack/plugins/security_solution/scripts/run_cypress/parallel.ts`
script we use for running Cypress tests:

- The script was broken in #162673
(here on [this
line](https://github.com/elastic/kibana/pull/162673/files#diff-9f40ced6d29c4fc2709af881680400293d8ce1bc9ebb07b9138d6d99c83c09c9R67))
- I think it has never supported situations when all tests matching a
spec pattern (such as
`./cypress/e2e/!(investigations|explore)/**/*.cy.ts`) end up being
skipped via Cypress tags (such as `@skipInServerless`)

Both the issues are fixed in this PR.

Code owners are added for this script in the CODEOWNERS file to prevent
breaking this script in future PRs.
maximpn added a commit that referenced this issue Sep 21, 2023
**Related to:** #161540, #161539

## Summary

Always force the last breadcrumb to be inactive.

## Details

Usual UX expects the last breadcrumb to be inactive as it represents the current page. The same can be seen from EUI [examples](https://eui.elastic.co/#/navigation/breadcrumbs). It turns out Serverless Security Solution plugin does't remove `href` and `onClick` fields from the last breadcrumb and passes it to `chrome.setBreadcrumbs()` or `serverless.setBreadcrumbs()` which renders the last breadcrumb as active but clicking on it only refreshes the page. ESS Security Solution on the other hand processes breadcrumbs currently. The same behavior may be the case for the other plungs as well.

As it's much simpler to strip off undesired fields at one place instead of processing them in plugins it's done in `packages/core/chrome/core-chrome-browser-internal/src/ui/header/header_breadcrumbs.tsx`. Security Solution codebase has been updated accordingly.

A side effect of this PR is consistent ESS and Serverless breadcrumbs behavior and it will help to reuse ESS tests for Serverless.
maximpn added a commit that referenced this issue Oct 4, 2023
… test (#167083)

**Addresses:** #161539

## Summary

This PR unskips Threshold rule creation Cypress tests.

## Details

To unskip the test with minimal changes it required to refactor navigation via breadcrumbs and update rules table breadcrumb selectors to make navigation back to the rules table work seamlessly between ESS and Serverless.

## Flaky Test runner

Serverless [threshold_rule.cy.ts  150 runs](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3213) 🟢
@banderror banderror assigned jpdjere and unassigned maximpn Oct 16, 2023
@banderror banderror assigned yctercero and unassigned WafaaNasr Oct 16, 2023
@jpdjere
Copy link
Contributor

jpdjere commented Nov 6, 2023

Overview of Detection Engine Cypress tests

Folder Test File ESS Serverless Comments
/exceptions/alerts_table_flow/rule_exceptions auto_populate_with_alert_data.cy Fully skipped, needs rework
/exceptions/alerts_table_flow/rule_exceptions closing_all_matching_alerts.cy.cy Needs rework
/exceptions/alerts_table_flow endpoint_exceptions.cy Fully skipped, needs rework
/exceptions/entry flyout_validation.cy Fully skipped, needs rework
/exceptions/entry match_any.cy See PR
/exceptions/entry multiple_conditions.cy See PR
/exceptions/entry use_value_list.cy See PR
/exceptions/rule_details_flow add_edit_endpoint_exception.cy Working on both, see flaky test run, and pending PR to enable (needs merging still)
/exceptions/rule_details_flow add_edit_exception_data_view.cy Broken on serverless, see PR
/exceptions/rule_details_flow add_edit_exception.cy Broken on serverless, see PR
/exceptions/rule_details_flow read_only_view.cy Probably needs roles rework on serverless, not activated currently. See PR
/exceptions/shared_exception_lists_management/list_detail_page list_details.cy See PR
/exceptions/shared_exception_lists_management/shared_exception_list_page duplicate_lists.cy See PR
/exceptions/shared_exception_lists_management/shared_exception_list_page filter_table.cy See PR
/exceptions/shared_exception_lists_management/shared_exception_list_page import_lists.cy See PR
/exceptions/shared_exception_lists_management/shared_exception_list_page manage_lists.cy See PR
/exceptions/shared_exception_lists_management/shared_exception_list_page read_only.cy Needs rework for serverless roles
/exceptions/shared_exception_lists_management manage_exceptions.cy See pending PR
/overview cti_link_panel.cy Fully broken, tests needs fix, see PR and related tickets (1 and 2)
/entity_analytics enrichments.cy Whole test reported as flaky, see PR that investigated (was reenabled but flake reappeared), see Kibana Machine reported issue
/entity_analytics entity_analytics_management_page.cy See PR
/value_lists permissions.cy See PR, serverless needs roles fix
/value_lists value_lists.cy See PR
/rule_actions rule_actions_pli_complete.cy See flaky test runner linked in PR
/rule_actions rule_actions_pli_essentials.cy See flaky test runner linked in PR
/rule_actions rule_actions_pli_essentials.cy Test is flaky on serverless, see flaky test runner linked in PR
/detection_response/rule_creation common_flows.cy See PR
/detection_response/rule_creation custom_query_rule_data_view.cy.ts See PR
/detection_response/rule_creation custom_query_rule.cy.ts See PR
/detection_response/rule_creation custom_saved_query_rule.cy.ts Broken in serverless, see PR
/detection_response/rule_creation esql_rule_ess.cy.ts See PR
/detection_response/rule_creation esql_rule_serverless.cy.ts See PR
/detection_response/rule_creation event_correlation_rule.cy.ts See PR
/detection_response/rule_creation indicator_match_rule.cy.ts Broken in serverless, see PR
/detection_response/rule_creation machine_learning_rule.cy.ts See PR
/detection_response/rule_creation new_terms_rule.cy.ts See PR
/detection_response/rule_creation override.cy.ts See PR
/detection_response/rule_creation threshold_rule.cy.ts See PR
/detection_response/rule_edit esql_rule.cy.ts See PR and flaky test runner linked
/detection_response/rule_edit custom_query_rule.cy.ts See PR and flaky test runner linked
/detection_response/sourcerer create_runtime_field.cyts See PR
/detection_response/sourcerer sourcerer_permissions.cyts Needs roles rework on serverless, see PR
/detection_response/sourcerer sourcerer_timeline.cy.ts Test fully skipped, see PR and issue
/detection_response/sourcerer sourcerer_timeline.cy.ts See PR
/detection_response/detection_alerts alert_status.cy.ts Whole test suite showing signs of flakiness. See issue
/detection_response/detection_alerts alert_tags.cy.ts See PR
/detection_response/detection_alerts alerts_detection_callouts_index_outdated.cy.ts See PR
/detection_response/detection_alerts missing_privileges_callout.cy.ts See PR
/detection_response/detection_alerts threat_match_enrichments.cy.ts See PR

PRs used for investigation/enabling tests

@banderror
Copy link
Contributor Author

Hey @yctercero, as we discussed over zoom, @jpdjere did a great research on what tests owned by the Detection Engine team can be unskipped and enabled in ESS and Serverless, and also enabled many of them. The result of these efforts is the wonderful table above that shows what tests are still broken/flaky and thus skipped in Serverless and/or ESS. Having that, I'd like to consider this ticket addressed and close it. Please feel free to reopen it when you get back to fixing the rest of the Detection Engine tests, or open a new ticket - whichever you will find more convenient.

@yctercero
Copy link
Contributor

Thanks @banderror - I created a follow up issue for our team - #171366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.12 candidate Team:Detection Engine Security Solution Detection Engine Area Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. test test-coverage issues & PRs for improving code test coverage
Projects
None yet
Development

No branches or pull requests

5 participants