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] Test rule_details_ui/pages/rule_details/index.test.tsx is too heavy and can fail by timeout #147064

Closed
Tracked by #161507
kibanamachine opened this issue Dec 6, 2022 · 3 comments · Fixed by #164825
Assignees
Labels
8.10 candidate failed-test A test failure on a tracked branch, potentially flaky-test 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

Comments

@kibanamachine
Copy link
Contributor

A test failed on a tracked branch

Error: thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
    at /var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.test.tsx:214:3
    at _dispatchDescribe (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/index.js:98:26)
    at describe (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/index.js:60:5)
    at Object.<anonymous> (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.test.tsx:174:1)
    at Runtime._execModule (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-runtime/build/index.js:1646:24)
    at Runtime._loadModule (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-runtime/build/index.js:1185:12)
    at Runtime.requireModule (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-runtime/build/index.js:1009:12)
    at jestAdapter (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:13)
    at runTestInternal (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-runner/build/runTest.js:389:16)
    at runTest (/var/lib/buildkite-agent/builds/kb-n2-4-spot-f2a6a39154e81d67/elastic/kibana-on-merge/kibana/node_modules/jest-runner/build/runTest.js:475:34)

First failure: CI Build - 8.6

@kibanamachine kibanamachine added the failed-test A test failure on a tracked branch, potentially flaky-test label Dec 6, 2022
@botelastic botelastic bot added the needs-team Issues missing a team label label Dec 6, 2022
@kibanamachine kibanamachine added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Dec 6, 2022
@elasticmachine
Copy link
Contributor

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

@botelastic botelastic bot removed the needs-team Issues missing a team label label Dec 6, 2022
@MadameSheema MadameSheema added Team:Detections and Resp Security Detection Response Team Team:Detection Rule Management Security Detection Rule Management Team labels May 23, 2023
@elasticmachine
Copy link
Contributor

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

@banderror
Copy link
Contributor

This is indeed a heavy and long-running test suite:

 PASS  x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.test.tsx (20.831 s)
  RuleDetailsPageComponent
    ✓ renders correctly with no outcome property on rule (713 ms)
    ✓ renders correctly with outcome === "exactMatch" (298 ms)
    ✓ renders correctly with outcome === "aliasMatch" (284 ms)
    ✓ renders correctly when outcome = conflict (290 ms)
    ✓ renders exceptions tab (273 ms)
    ✓ renders endpoint exceptions tab when rule includes endpoint list (261 ms)

I think we shouldn't have unit tests for whole pages because they are too heavy, too brittle, require a lot of mocking, and are expensive in maintenance. We should probably just delete this test file or try to replace it with finer-grained and lightweight tests.

@banderror banderror changed the title Failing test: Jest Tests.x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details - RuleDetailsPageComponent renders correctly with outcome === "exactMatch" [Security Solution] rule_details_ui/pages/rule_details/index.test.tsx is too heavy and can fail by timeout May 25, 2023
@banderror banderror changed the title [Security Solution] rule_details_ui/pages/rule_details/index.test.tsx is too heavy and can fail by timeout [Security Solution] Test rule_details_ui/pages/rule_details/index.test.tsx is too heavy and can fail by timeout May 25, 2023
jpdjere added a commit that referenced this issue Aug 28, 2023
…siness logic refactor (#164825)

Fixes: #147064

## Summary

- `rule_details_ui/pages/rule_details/index.test.tsx` was too heavy and
can fail by timeout
- The unit test was mounting the whole rule details component to test:
    - redirection logic
    - which tabs are visible

This PR:
- extracts that logic into two new hooks and one component:
    - `useLegacyUrlRedirect` (for redirection logic)
- `useRuleDetailsTabs` (to calculate which tabs should be displayed)
    - `LegacyUrlConflictCallOut`
- adds tests for the two hooks and the component, covering all the logic
that was previously covered by the
`rule_details_ui/pages/rule_details/index.test.tsx` file
- deletes the `rule_details_ui/pages/rule_details/index.test.tsx` file

---------

Co-authored-by: kibanamachine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.10 candidate failed-test A test failure on a tracked branch, potentially flaky-test 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
Projects
None yet
5 participants