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: Detection Engine Serverless / Bundled Prebuilte Rules Package API Integration Tests.x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules·ts - Detection Engine API - Bundled Prebuilt Rules Package @ess @serverless @skipInQA install_bundled_prebuilt_rules should install prebuilt rules from the package that comes bundled with Kibana #171380

Closed
Tracked by #173469 ...
kibanamachine opened this issue Nov 16, 2023 · 7 comments
Assignees
Labels
8.13 candidate failed-test A test failure on a tracked branch, potentially flaky-test Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area legit-flake Test was triaged and marked as an actual flake. 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.

Comments

@kibanamachine
Copy link
Contributor

kibanamachine commented Nov 16, 2023

A test failed on a tracked branch

JestAssertionError: expect(received).toBeGreaterThan(expected)

Expected: > 0
Received:   0
    at Context.<anonymous> (install_latest_bundled_prebuilt_rules.ts:75:82)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at Object.apply (wrap_function.js:73:16) {
  matcherResult: {
    message: '\x1B[2mexpect(\x1B[22m\x1B[31mreceived\x1B[39m\x1B[2m).\x1B[22mtoBeGreaterThan\x1B[2m(\x1B[22m\x1B[32mexpected\x1B[39m\x1B[2m)\x1B[22m\n' +
      '\n' +
      'Expected: > \x1B[32m0\x1B[39m\n' +
      'Received:   \x1B[31m0\x1B[39m',
    pass: false
  }
}

First failure: CI Build - main

@kibanamachine kibanamachine added the failed-test A test failure on a tracked branch, potentially flaky-test label Nov 16, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Nov 16, 2023
@kibanamachine kibanamachine added the Team:Detection Rule Management Security Detection Rule Management Team label Nov 16, 2023
@botelastic botelastic bot removed the needs-team Issues missing a team label label Nov 16, 2023
@kibanamachine
Copy link
Contributor Author

New failure: CI Build - main

@mistic
Copy link
Member

mistic commented Nov 16, 2023

Skipped.

main: 9e087f4

@banderror banderror added triage_needed Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. labels Dec 15, 2023
@elasticmachine
Copy link
Contributor

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

@elasticmachine
Copy link
Contributor

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

@banderror
Copy link
Contributor

This seems to be a legit flake and looks very similar to #172107 (comment). The error happened here on the last line:

      const bundledInstallResponse = await installPrebuiltRulesPackageByVersion(
        es,
        supertest,
        '99.0.0'
      );

      // As opposed to "registry"
      expect(bundledInstallResponse._meta.install_source).toBe('bundled');

      // Refresh ES indices to avoid race conditions between write and reading of indeces
      // See implementation utility function at x-pack/test/security_solution_api_integration/test_suites/detections_response/utils/rules/prebuilt_rules/install_prebuilt_rules_fleet_package.ts
      await es.indices.refresh({ index: ALL_SAVED_OBJECT_INDICES });

      // Verify that status is updated after package installation
      const statusAfterPackageInstallation = await getPrebuiltRulesStatus(supertest);
      expect(statusAfterPackageInstallation.stats.num_prebuilt_rules_installed).toBe(0);
      expect(statusAfterPackageInstallation.stats.num_prebuilt_rules_to_install).toBeGreaterThan(0);

When both num_prebuilt_rules_installed and num_prebuilt_rules_to_install returned from the endpoint were 0. Which likely means the package wasn't installed by installPrebuiltRulesPackageByVersion or there was a failure with indexing security-rule saved objects or with refreshing that index before the getPrebuiltRulesStatus call.

We need to take a closer look at installPrebuiltRulesPackageByVersion and consider:

  • Changing error handling in it. Maybe this endpoint can return 200 even when something fails internally.
  • Adding retry logic.
  • Making sure await es.indices.refresh works as expected.
  • Doing the same with all the other utils that call fleet/epm endpoints, such as installPrebuiltRulesPackageViaFleetAPI.

@banderror
Copy link
Contributor

This test has been already skipped.

@banderror banderror added legit-flake Test was triaged and marked as an actual flake. 8.13 candidate v8.13.0 and removed triage_needed labels Dec 20, 2023
@banderror banderror removed their assignment Dec 20, 2023
@banderror banderror added the Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area label Dec 21, 2023
jpdjere added a commit that referenced this issue Jan 11, 2024
…ion tests (#173998)

**Addresses:**
#172107
#171380

## Summary

Unskip skipped tests in:

1.
`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules.ts`
2.
`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/management/fleet_integration.ts`

- Makes the `retryDelay` in the **RetryService** in
`packages/kbn-ftr-common-functional-services/services/retry/retry.ts` a
configurable parameter - used in our `retry` util to shorten the wait
period to 200ms.
- Creates `retry` wrapper util for our FTR Integration tests, that wraps
`retry.try` from the **RetryService**, to implement maximum attempts.
- Uses this `retry` wrapper in test utils that install the
`security_detection_engine` Fleet package, and asserts that rules have
been succesfully installed - and retries if they haven't.
- Creates `refreshSavedObjectIndices` reusable util that cleans cache
and refreshes indices. Centralizes comment spread around file into this
single file.
- Use this new util to clean the cache in util that install the Fleet
package, and utils that read the prebuilt rule status.

## Flaky test runner

**Before changes:** 
- For both `bundled_prebuilt_rules_package` and `management`:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4688
🟢 (250 and 250 runs)
- `bundled_prebuilt_rules_package`:
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4805
(500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4807
(500 runs)
- `management` 
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4806
(500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4808
(500 runs)
 
**After changes:** 
- `bundled_prebuilt_rules_package`:
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4825
🟢 (500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4826
🟢 (500 runs)
- `management` 
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4827
🟢 (500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4828
🟢 (500 runs)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
@jpdjere
Copy link
Contributor

jpdjere commented Jan 12, 2024

Fixed and unskipped in: #173998

@jpdjere jpdjere closed this as completed Jan 12, 2024
jpdjere added a commit to jpdjere/kibana that referenced this issue Jan 12, 2024
…ion tests (elastic#173998)

**Addresses:**
elastic#172107
elastic#171380

## Summary

Unskip skipped tests in:

1.
`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules.ts`
2.
`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/management/fleet_integration.ts`

- Makes the `retryDelay` in the **RetryService** in
`packages/kbn-ftr-common-functional-services/services/retry/retry.ts` a
configurable parameter - used in our `retry` util to shorten the wait
period to 200ms.
- Creates `retry` wrapper util for our FTR Integration tests, that wraps
`retry.try` from the **RetryService**, to implement maximum attempts.
- Uses this `retry` wrapper in test utils that install the
`security_detection_engine` Fleet package, and asserts that rules have
been succesfully installed - and retries if they haven't.
- Creates `refreshSavedObjectIndices` reusable util that cleans cache
and refreshes indices. Centralizes comment spread around file into this
single file.
- Use this new util to clean the cache in util that install the Fleet
package, and utils that read the prebuilt rule status.

## Flaky test runner

**Before changes:**
- For both `bundled_prebuilt_rules_package` and `management`:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4688
🟢 (250 and 250 runs)
- `bundled_prebuilt_rules_package`:
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4805
(500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4807
(500 runs)
- `management`
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4806
(500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4808
(500 runs)

**After changes:**
- `bundled_prebuilt_rules_package`:
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4825
🟢 (500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4826
🟢 (500 runs)
- `management`
- ESS:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4827
🟢 (500 runs)
- Serverless:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4828
🟢 (500 runs)

### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <[email protected]>
(cherry picked from commit 81d6478)

# Conflicts:
#	x-pack/test/security_solution_api_integration/tsconfig.json
jpdjere added a commit that referenced this issue Jan 12, 2024
…ntegration tests (#173998) (#174761)

# Backport

This will backport the following commits from `main` to `8.12`:
- [[Security Solution] Unskip flaky tests in Prebuilt Rules FTR
Integration tests
(#173998)](#173998)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT [{"author":{"name":"Juan Pablo
Djeredjian","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-01-11T12:35:55Z","message":"[Security
Solution] Unskip flaky tests in Prebuilt Rules FTR Integration tests
(#173998)\n\n**Addresses:**\r\nhttps://github.com//issues/172107\r\nhttps://github.com//issues/171380\r\n\r\n##
Summary\r\n\r\nUnskip skipped tests
in:\r\n\r\n1.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules.ts`\r\n2.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/management/fleet_integration.ts`\r\n\r\n-
Makes the `retryDelay` in the **RetryService**
in\r\n`packages/kbn-ftr-common-functional-services/services/retry/retry.ts`
a\r\nconfigurable parameter - used in our `retry` util to shorten the
wait\r\nperiod to 200ms.\r\n- Creates `retry` wrapper util for our FTR
Integration tests, that wraps\r\n`retry.try` from the **RetryService**,
to implement maximum attempts.\r\n- Uses this `retry` wrapper in test
utils that install the\r\n`security_detection_engine` Fleet package, and
asserts that rules have\r\nbeen succesfully installed - and retries if
they haven't.\r\n- Creates `refreshSavedObjectIndices` reusable util
that cleans cache\r\nand refreshes indices. Centralizes comment spread
around file into this\r\nsingle file.\r\n- Use this new util to clean
the cache in util that install the Fleet\r\npackage, and utils that read
the prebuilt rule status.\r\n\r\n## Flaky test runner\r\n\r\n**Before
changes:** \r\n- For both `bundled_prebuilt_rules_package` and
`management`:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4688\r\n🟢
(250 and 250 runs)\r\n- `bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4805\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4807\r\n(500
runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4806\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4808\r\n(500
runs)\r\n \r\n**After changes:** \r\n-
`bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4825\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4826\r\n🟢
(500 runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4827\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4828\r\n🟢
(500 runs)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"81d6478beedeceedd4ae193c7a5ba0ee874cbf12","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["test","release_note:skip","Team:Detections
and Resp","Team: SecuritySolution","Team:Detection Rule
Management","Feature:Prebuilt Detection
Rules","v8.12.0","v8.12.1","v8.13.0"],"number":173998,"url":"https://github.com/elastic/kibana/pull/173998","mergeCommit":{"message":"[Security
Solution] Unskip flaky tests in Prebuilt Rules FTR Integration tests
(#173998)\n\n**Addresses:**\r\nhttps://github.com//issues/172107\r\nhttps://github.com//issues/171380\r\n\r\n##
Summary\r\n\r\nUnskip skipped tests
in:\r\n\r\n1.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules.ts`\r\n2.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/management/fleet_integration.ts`\r\n\r\n-
Makes the `retryDelay` in the **RetryService**
in\r\n`packages/kbn-ftr-common-functional-services/services/retry/retry.ts`
a\r\nconfigurable parameter - used in our `retry` util to shorten the
wait\r\nperiod to 200ms.\r\n- Creates `retry` wrapper util for our FTR
Integration tests, that wraps\r\n`retry.try` from the **RetryService**,
to implement maximum attempts.\r\n- Uses this `retry` wrapper in test
utils that install the\r\n`security_detection_engine` Fleet package, and
asserts that rules have\r\nbeen succesfully installed - and retries if
they haven't.\r\n- Creates `refreshSavedObjectIndices` reusable util
that cleans cache\r\nand refreshes indices. Centralizes comment spread
around file into this\r\nsingle file.\r\n- Use this new util to clean
the cache in util that install the Fleet\r\npackage, and utils that read
the prebuilt rule status.\r\n\r\n## Flaky test runner\r\n\r\n**Before
changes:** \r\n- For both `bundled_prebuilt_rules_package` and
`management`:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4688\r\n🟢
(250 and 250 runs)\r\n- `bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4805\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4807\r\n(500
runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4806\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4808\r\n(500
runs)\r\n \r\n**After changes:** \r\n-
`bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4825\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4826\r\n🟢
(500 runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4827\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4828\r\n🟢
(500 runs)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"81d6478beedeceedd4ae193c7a5ba0ee874cbf12"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/173998","number":173998,"mergeCommit":{"message":"[Security
Solution] Unskip flaky tests in Prebuilt Rules FTR Integration tests
(#173998)\n\n**Addresses:**\r\nhttps://github.com//issues/172107\r\nhttps://github.com//issues/171380\r\n\r\n##
Summary\r\n\r\nUnskip skipped tests
in:\r\n\r\n1.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/bundled_prebuilt_rules_package/install_latest_bundled_prebuilt_rules.ts`\r\n2.\r\n`x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/management/fleet_integration.ts`\r\n\r\n-
Makes the `retryDelay` in the **RetryService**
in\r\n`packages/kbn-ftr-common-functional-services/services/retry/retry.ts`
a\r\nconfigurable parameter - used in our `retry` util to shorten the
wait\r\nperiod to 200ms.\r\n- Creates `retry` wrapper util for our FTR
Integration tests, that wraps\r\n`retry.try` from the **RetryService**,
to implement maximum attempts.\r\n- Uses this `retry` wrapper in test
utils that install the\r\n`security_detection_engine` Fleet package, and
asserts that rules have\r\nbeen succesfully installed - and retries if
they haven't.\r\n- Creates `refreshSavedObjectIndices` reusable util
that cleans cache\r\nand refreshes indices. Centralizes comment spread
around file into this\r\nsingle file.\r\n- Use this new util to clean
the cache in util that install the Fleet\r\npackage, and utils that read
the prebuilt rule status.\r\n\r\n## Flaky test runner\r\n\r\n**Before
changes:** \r\n- For both `bundled_prebuilt_rules_package` and
`management`:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4688\r\n🟢
(250 and 250 runs)\r\n- `bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4805\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4807\r\n(500
runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4806\r\n(500
runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4808\r\n(500
runs)\r\n \r\n**After changes:** \r\n-
`bundled_prebuilt_rules_package`:\r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4825\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4826\r\n🟢
(500 runs)\r\n- `management` \r\n-
ESS:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4827\r\n🟢
(500 runs)\r\n-
Serverless:\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/4828\r\n🟢
(500 runs)\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for
breaking API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by:
kibanamachine
<[email protected]>","sha":"81d6478beedeceedd4ae193c7a5ba0ee874cbf12"}}]}]
BACKPORT-->

---------

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.13 candidate failed-test A test failure on a tracked branch, potentially flaky-test Feature:Prebuilt Detection Rules Security Solution Prebuilt Detection Rules area legit-flake Test was triaged and marked as an actual flake. 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.
Projects
None yet
Development

No branches or pull requests

5 participants