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

Failing test: Jest Tests.x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/utils - CreateDetectionRuleFromVulnerability generateVulnerabilitiesRuleQuery should generate correct query for a vulnerability #195634

Closed
kibanamachine opened this issue Oct 9, 2024 · 4 comments · Fixed by #195681
Assignees
Labels
failed-test A test failure on a tracked branch, potentially flaky-test Team:Cloud Security Cloud Security team related

Comments

@kibanamachine
Copy link
Contributor

kibanamachine commented Oct 9, 2024

A test failed on a tracked branch

Error: expect(received).toEqual(expected) // deep equality

Expected: "vulnerability.id: \"CVE-2024-00005\" AND event.ingested >= \"2024-10-09T15:21:23.658Z\""
Received: "vulnerability.id: \"CVE-2024-00005\" AND event.ingested >= \"2024-10-09T15:21:23.659Z\""
    at Object.toEqual (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/x-pack/plugins/cloud_security_posture/public/pages/vulnerabilities/utils/create_detection_rule_from_vulnerability.test.ts:93:21)
    at Promise.then.completed (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/utils.js:298:28)
    at new Promise (<anonymous>)
    at callAsyncCircusFn (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/utils.js:231:10)
    at _callCircusTest (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:316:40)
    at _runTest (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:252:3)
    at _runTestsForDescribeBlock (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:126:9)
    at _runTestsForDescribeBlock (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:121:9)
    at _runTestsForDescribeBlock (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:121:9)
    at run (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/run.js:71:3)
    at runAndTransformResultsToJestFormat (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21)
    at jestAdapter (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19)
    at runTestInternal (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-runner/build/runTest.js:367:16)
    at runTest (/opt/buildkite-agent/builds/bk-agent-prod-gcp-1728486417824840686/elastic/kibana-on-merge/kibana/node_modules/jest-runner/build/runTest.js:444:34)

First failure: kibana-on-merge - main

@kibanamachine kibanamachine added the failed-test A test failure on a tracked branch, potentially flaky-test label Oct 9, 2024
@botelastic botelastic bot added the needs-team Issues missing a team label label Oct 9, 2024
@kibanamachine kibanamachine added the Team:Cloud Security Cloud Security team related label Oct 9, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-cloud-security-posture (Team:Cloud Security)

@botelastic botelastic bot removed the needs-team Issues missing a team label label Oct 9, 2024
@opauloh opauloh self-assigned this Oct 9, 2024
@kibanamachine
Copy link
Contributor Author

New failure: kibana-on-merge - 8.x

@kibanamachine
Copy link
Contributor Author

New failure: kibana-on-merge - 8.x

@kibanamachine
Copy link
Contributor Author

New failure: kibana-on-merge - main

@opauloh opauloh linked a pull request Oct 9, 2024 that will close this issue
opauloh added a commit that referenced this issue Oct 10, 2024
## Summary

It fixes the flaky test raised on #195634 by adding the possibility to
pass the timestamp to the function. That helps to eliminate flakiness,
by passing the same `currentTimestamp` to both the test and the
function. Also, it's a simpler approach that doesn't require mocking
global objects or using Jest's fake timers, keeping your test
straightforward and easy to understand.
kibanamachine pushed a commit to kibanamachine/kibana that referenced this issue Oct 10, 2024
## Summary

It fixes the flaky test raised on elastic#195634 by adding the possibility to
pass the timestamp to the function. That helps to eliminate flakiness,
by passing the same `currentTimestamp` to both the test and the
function. Also, it's a simpler approach that doesn't require mocking
global objects or using Jest's fake timers, keeping your test
straightforward and easy to understand.

(cherry picked from commit b51ba0a)
kibanamachine added a commit that referenced this issue Oct 10, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [fix flaky test with timestamp
(#195681)](#195681)

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

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

<!--BACKPORT [{"author":{"name":"Paulo
Silva","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-10T00:36:33Z","message":"fix
flaky test with timestamp (#195681)\n\n## Summary\r\n\r\nIt fixes the
flaky test raised on #195634 by adding the possibility to\r\npass the
timestamp to the function. That helps to eliminate flakiness,\r\nby
passing the same `currentTimestamp` to both the test and
the\r\nfunction. Also, it's a simpler approach that doesn't require
mocking\r\nglobal objects or using Jest's fake timers, keeping your
test\r\nstraightforward and easy to
understand.","sha":"b51ba0a27c852f967b922130d01ac7cf2ec11d64","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Cloud
Security","v8.16.0","backport:version"],"title":"Fix flaky Jest test on
generateVulnerabilitiesRuleQuery","number":195681,"url":"https://github.com/elastic/kibana/pull/195681","mergeCommit":{"message":"fix
flaky test with timestamp (#195681)\n\n## Summary\r\n\r\nIt fixes the
flaky test raised on #195634 by adding the possibility to\r\npass the
timestamp to the function. That helps to eliminate flakiness,\r\nby
passing the same `currentTimestamp` to both the test and
the\r\nfunction. Also, it's a simpler approach that doesn't require
mocking\r\nglobal objects or using Jest's fake timers, keeping your
test\r\nstraightforward and easy to
understand.","sha":"b51ba0a27c852f967b922130d01ac7cf2ec11d64"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/195681","number":195681,"mergeCommit":{"message":"fix
flaky test with timestamp (#195681)\n\n## Summary\r\n\r\nIt fixes the
flaky test raised on #195634 by adding the possibility to\r\npass the
timestamp to the function. That helps to eliminate flakiness,\r\nby
passing the same `currentTimestamp` to both the test and
the\r\nfunction. Also, it's a simpler approach that doesn't require
mocking\r\nglobal objects or using Jest's fake timers, keeping your
test\r\nstraightforward and easy to
understand.","sha":"b51ba0a27c852f967b922130d01ac7cf2ec11d64"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Paulo Silva <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
failed-test A test failure on a tracked branch, potentially flaky-test Team:Cloud Security Cloud Security team related
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants