Skip to content

[Security Solution] [Attack discovery] Improves Attack discovery code coverage#186679

Merged
andrew-goldstein merged 2 commits intoelastic:mainfrom
andrew-goldstein:attack_discovery_code_coverage
Jun 25, 2024
Merged

[Security Solution] [Attack discovery] Improves Attack discovery code coverage#186679
andrew-goldstein merged 2 commits intoelastic:mainfrom
andrew-goldstein:attack_discovery_code_coverage

Conversation

@andrew-goldstein
Copy link
Contributor

[Security Solution] [Attack discovery] Improves Attack discovery code coverage

Summary

This PR improves unit test coverage for the Attack discovery feature.

Desk testing

Run node scripts/jest --watch x-pack/plugins/security_solution/public/attack_discovery --coverage

@andrew-goldstein andrew-goldstein added release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Security Generative AI Security Generative AI v8.15.0 Feature:Attack Discovery Attack discovery uses generative AI to identify active attacks labels Jun 21, 2024
@andrew-goldstein andrew-goldstein self-assigned this Jun 21, 2024
@andrew-goldstein andrew-goldstein requested review from a team as code owners June 21, 2024 23:57
@elasticmachine
Copy link
Contributor

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

@andrew-goldstein andrew-goldstein force-pushed the attack_discovery_code_coverage branch from 56bf759 to 3168bdd Compare June 24, 2024 13:47
…ode coverage

### Summary

This PR improves unit test coverage for the [Attack discovery](elastic#181818) feature.

### Desk testing

Run `node scripts/jest --watch x-pack/plugins/security_solution/public/attack_discovery --coverage`
@andrew-goldstein andrew-goldstein force-pushed the attack_discovery_code_coverage branch from 3168bdd to 1e3c9a5 Compare June 25, 2024 21:16
Copy link
Contributor

@stephmilovic stephmilovic left a comment

Choose a reason for hiding this comment

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

Nice work Andrew! LGTM

Here is the before/after on code coverage. Awesome job!
| % Stmts | % Branch | % Funcs | % Lines |
| 83.31. | 61.64 | 72.36. | 85.1 |
| 92.1 | 77 | 86.95 | 92.76 |

@kibana-ci
Copy link

💛 Build succeeded, but was flaky

Failed CI Steps

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 13.7MB 13.7MB +26.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
elasticAssistant 41 44 +3

Total ESLint disabled count

id before after diff
elasticAssistant 41 44 +3

History

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

cc @andrew-goldstein

@andrew-goldstein andrew-goldstein merged commit f775a6a into elastic:main Jun 25, 2024
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Jun 25, 2024
@andrew-goldstein andrew-goldstein deleted the attack_discovery_code_coverage branch June 25, 2024 23:42
andrew-goldstein added a commit to andrew-goldstein/kibana that referenced this pull request Aug 29, 2024
andrew-goldstein added a commit that referenced this pull request Aug 29, 2024
)

Fixes a flakey jest test that failed twice since it was introduced ~2 months ago in [this pr](#186679), as tracked by #189757

### CI and desk flake testing

To test the fix for fakyness, it ran `10,000` times in CI, and locally, with a `100%` success rate. (The test was wrapped in a loop to execute 10,000 times.)

- Tested in CI 10,000 times via following Buildkite build:

:green_heart: Build Succeeded
[Buildkite Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)

The 10,000 passing test runs are included in the following (abbreviated) build log output:

```
Ran all test suites.
$ node scripts/jest --config x-pack/plugins/security_solution/public/attack_discovery/jest.config.js
actual full command is:
NODE_OPTIONS="--max-old-space-size=12288 --trace-warnings" node ./scripts/jest --config="x-pack/plugins/security_solution/public/attack_discovery/jest.config.js" --runInBand --coverage=false --passWithNoTests
 PASS  x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx (742.054 s)
# other passing tests...

Test Suites: 54 passed, 54 total
Tests:       10297 passed, 10297 total
Snapshots:   0 total
Time:        962.106 s
```

- Tested locally 10,000 times, as illustrated by the following console output:

```
    ✓ renders the expected the timer text - iteration 9996 (43 ms)
    ✓ renders the expected the timer text - iteration 9997 (44 ms)
    ✓ renders the expected the timer text - iteration 9998 (48 ms)
    ✓ renders the expected the timer text - iteration 9999 (49 ms)
    ✓ renders the expected the timer text - iteration 10000 (46 ms)

Test Suites: 1 passed, 1 total
Tests:       10002 passed, 10002 total
Snapshots:   0 total
Time:        294.54 s
Ran all test suites matching /x-pack\/plugins\/security_solution\/public\/attack_discovery\/pages\/loading_callout\/countdown\/index.test.tsx/i.
```
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Aug 29, 2024
…tic#191736)

Fixes a flakey jest test that failed twice since it was introduced ~2 months ago in [this pr](elastic#186679), as tracked by elastic#189757

### CI and desk flake testing

To test the fix for fakyness, it ran `10,000` times in CI, and locally, with a `100%` success rate. (The test was wrapped in a loop to execute 10,000 times.)

- Tested in CI 10,000 times via following Buildkite build:

:green_heart: Build Succeeded
[Buildkite Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)

The 10,000 passing test runs are included in the following (abbreviated) build log output:

```
Ran all test suites.
$ node scripts/jest --config x-pack/plugins/security_solution/public/attack_discovery/jest.config.js
actual full command is:
NODE_OPTIONS="--max-old-space-size=12288 --trace-warnings" node ./scripts/jest --config="x-pack/plugins/security_solution/public/attack_discovery/jest.config.js" --runInBand --coverage=false --passWithNoTests
 PASS  x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx (742.054 s)
# other passing tests...

Test Suites: 54 passed, 54 total
Tests:       10297 passed, 10297 total
Snapshots:   0 total
Time:        962.106 s
```

- Tested locally 10,000 times, as illustrated by the following console output:

```
    ✓ renders the expected the timer text - iteration 9996 (43 ms)
    ✓ renders the expected the timer text - iteration 9997 (44 ms)
    ✓ renders the expected the timer text - iteration 9998 (48 ms)
    ✓ renders the expected the timer text - iteration 9999 (49 ms)
    ✓ renders the expected the timer text - iteration 10000 (46 ms)

Test Suites: 1 passed, 1 total
Tests:       10002 passed, 10002 total
Snapshots:   0 total
Time:        294.54 s
Ran all test suites matching /x-pack\/plugins\/security_solution\/public\/attack_discovery\/pages\/loading_callout\/countdown\/index.test.tsx/i.
```

(cherry picked from commit e0f8eb1)
kibanamachine added a commit that referenced this pull request Aug 29, 2024
#191736) (#191774)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Security Solution] [Attack discovery] Fixes a flakey jest test
(#191736)](#191736)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Andrew
Macri","email":"andrew.macri@elastic.co"},"sourceCommit":{"committedDate":"2024-08-29T21:29:52Z","message":"[Security
Solution] [Attack discovery] Fixes a flakey jest test (#191736)\n\nFixes
a flakey jest test that failed twice since it was introduced ~2 months
ago in [this pr](#186679), as
tracked by https://github.com/elastic/kibana/issues/189757\r\n\r\n### CI
and desk flake testing\r\n\r\nTo test the fix for fakyness, it ran
`10,000` times in CI, and locally, with a `100%` success rate. (The test
was wrapped in a loop to execute 10,000 times.)\r\n\r\n- Tested in CI
10,000 times via following Buildkite build:\r\n\r\n:green_heart: Build
Succeeded\r\n[Buildkite
Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)\r\n\r\nThe
10,000 passing test runs are included in the following (abbreviated)
build log output:\r\n\r\n```\r\nRan all test suites.\r\n$ node
scripts/jest --config
x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\r\nactual
full command is:\r\nNODE_OPTIONS=\"--max-old-space-size=12288
--trace-warnings\" node ./scripts/jest
--config=\"x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\"
--runInBand --coverage=false --passWithNoTests\r\n PASS
x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx
(742.054 s)\r\n# other passing tests...\r\n\r\nTest Suites: 54 passed,
54 total\r\nTests: 10297 passed, 10297 total\r\nSnapshots: 0
total\r\nTime: 962.106 s\r\n```\r\n\r\n- Tested locally 10,000 times, as
illustrated by the following console output:\r\n\r\n```\r\n ✓ renders
the expected the timer text - iteration 9996 (43 ms)\r\n ✓ renders the
expected the timer text - iteration 9997 (44 ms)\r\n ✓ renders the
expected the timer text - iteration 9998 (48 ms)\r\n ✓ renders the
expected the timer text - iteration 9999 (49 ms)\r\n ✓ renders the
expected the timer text - iteration 10000 (46 ms)\r\n\r\nTest Suites: 1
passed, 1 total\r\nTests: 10002 passed, 10002 total\r\nSnapshots: 0
total\r\nTime: 294.54 s\r\nRan all test suites matching
/x-pack\\/plugins\\/security_solution\\/public\\/attack_discovery\\/pages\\/loading_callout\\/countdown\\/index.test.tsx/i.\r\n```","sha":"e0f8eb1b6bf0f609b7b2b0b6a34216745a3be29f","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Security
Generative AI","v8.16.0","v8.15.1"],"title":"[Security Solution] [Attack
discovery] Fixes a flakey jest
test","number":191736,"url":"https://github.com/elastic/kibana/pull/191736","mergeCommit":{"message":"[Security
Solution] [Attack discovery] Fixes a flakey jest test (#191736)\n\nFixes
a flakey jest test that failed twice since it was introduced ~2 months
ago in [this pr](#186679), as
tracked by https://github.com/elastic/kibana/issues/189757\r\n\r\n### CI
and desk flake testing\r\n\r\nTo test the fix for fakyness, it ran
`10,000` times in CI, and locally, with a `100%` success rate. (The test
was wrapped in a loop to execute 10,000 times.)\r\n\r\n- Tested in CI
10,000 times via following Buildkite build:\r\n\r\n:green_heart: Build
Succeeded\r\n[Buildkite
Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)\r\n\r\nThe
10,000 passing test runs are included in the following (abbreviated)
build log output:\r\n\r\n```\r\nRan all test suites.\r\n$ node
scripts/jest --config
x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\r\nactual
full command is:\r\nNODE_OPTIONS=\"--max-old-space-size=12288
--trace-warnings\" node ./scripts/jest
--config=\"x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\"
--runInBand --coverage=false --passWithNoTests\r\n PASS
x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx
(742.054 s)\r\n# other passing tests...\r\n\r\nTest Suites: 54 passed,
54 total\r\nTests: 10297 passed, 10297 total\r\nSnapshots: 0
total\r\nTime: 962.106 s\r\n```\r\n\r\n- Tested locally 10,000 times, as
illustrated by the following console output:\r\n\r\n```\r\n ✓ renders
the expected the timer text - iteration 9996 (43 ms)\r\n ✓ renders the
expected the timer text - iteration 9997 (44 ms)\r\n ✓ renders the
expected the timer text - iteration 9998 (48 ms)\r\n ✓ renders the
expected the timer text - iteration 9999 (49 ms)\r\n ✓ renders the
expected the timer text - iteration 10000 (46 ms)\r\n\r\nTest Suites: 1
passed, 1 total\r\nTests: 10002 passed, 10002 total\r\nSnapshots: 0
total\r\nTime: 294.54 s\r\nRan all test suites matching
/x-pack\\/plugins\\/security_solution\\/public\\/attack_discovery\\/pages\\/loading_callout\\/countdown\\/index.test.tsx/i.\r\n```","sha":"e0f8eb1b6bf0f609b7b2b0b6a34216745a3be29f"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/191736","number":191736,"mergeCommit":{"message":"[Security
Solution] [Attack discovery] Fixes a flakey jest test (#191736)\n\nFixes
a flakey jest test that failed twice since it was introduced ~2 months
ago in [this pr](#186679), as
tracked by https://github.com/elastic/kibana/issues/189757\r\n\r\n### CI
and desk flake testing\r\n\r\nTo test the fix for fakyness, it ran
`10,000` times in CI, and locally, with a `100%` success rate. (The test
was wrapped in a loop to execute 10,000 times.)\r\n\r\n- Tested in CI
10,000 times via following Buildkite build:\r\n\r\n:green_heart: Build
Succeeded\r\n[Buildkite
Build](https://buildkite.com/elastic/kibana-pull-request/builds/230901)\r\n\r\nThe
10,000 passing test runs are included in the following (abbreviated)
build log output:\r\n\r\n```\r\nRan all test suites.\r\n$ node
scripts/jest --config
x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\r\nactual
full command is:\r\nNODE_OPTIONS=\"--max-old-space-size=12288
--trace-warnings\" node ./scripts/jest
--config=\"x-pack/plugins/security_solution/public/attack_discovery/jest.config.js\"
--runInBand --coverage=false --passWithNoTests\r\n PASS
x-pack/plugins/security_solution/public/attack_discovery/pages/loading_callout/countdown/index.test.tsx
(742.054 s)\r\n# other passing tests...\r\n\r\nTest Suites: 54 passed,
54 total\r\nTests: 10297 passed, 10297 total\r\nSnapshots: 0
total\r\nTime: 962.106 s\r\n```\r\n\r\n- Tested locally 10,000 times, as
illustrated by the following console output:\r\n\r\n```\r\n ✓ renders
the expected the timer text - iteration 9996 (43 ms)\r\n ✓ renders the
expected the timer text - iteration 9997 (44 ms)\r\n ✓ renders the
expected the timer text - iteration 9998 (48 ms)\r\n ✓ renders the
expected the timer text - iteration 9999 (49 ms)\r\n ✓ renders the
expected the timer text - iteration 10000 (46 ms)\r\n\r\nTest Suites: 1
passed, 1 total\r\nTests: 10002 passed, 10002 total\r\nSnapshots: 0
total\r\nTime: 294.54 s\r\nRan all test suites matching
/x-pack\\/plugins\\/security_solution\\/public\\/attack_discovery\\/pages\\/loading_callout\\/countdown\\/index.test.tsx/i.\r\n```","sha":"e0f8eb1b6bf0f609b7b2b0b6a34216745a3be29f"}},{"branch":"8.15","label":"v8.15.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Andrew Macri <andrew.macri@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Feature:Attack Discovery Attack discovery uses generative AI to identify active attacks release_note:skip Skip the PR/issue when compiling release notes Team:Security Generative AI Security Generative AI Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.15.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants