[Security Solution] [Elastic AI Assistant] Adds internal Get Evaluate API and migrates Post Evaluate API to OAS#176025
Conversation
|
Pinging @elastic/security-solution (Team: SecuritySolution) |
| export const MockAssistantProviderComponent: React.FC<Props> = ({ children }) => { | ||
| const actionTypeRegistry = actionTypeRegistryMock.create(); | ||
| const mockHttp = httpServiceMock.createStartContract({ basePath: '/test' }); | ||
| mockHttp.get.mockResolvedValue([]); |
There was a problem hiding this comment.
This was the mock causing the 'async issue' which resulted in the revert discussed in #176005 (comment). Removing the mock to see what tests fail, and then will update the mocks accordingly.
There was a problem hiding this comment.
And there's a 🟢 build with this mock removed. 🎉 Guess it wasn't needed? 😅 Let's verify and re-run the flakey test runner on the security solution tests.
Committed flakey-test runner changes (from #176005) in ef5b297 to ensure there really isn't an error on the security solution side. Will remove once test cycle is complete.
There was a problem hiding this comment.
🟢 25/25, and that's a success! Here's the build link. Flakey-test runner changes reverted in c2fc97b. This is ready for re-review @stephmilovic.
cc @jbudz
There was a problem hiding this comment.
Upon further testing locally, I was able to isolate the issue to this test here:
Fix to this test is provided in: 0b4028c
| const props = wrapper.find('[data-test-subj="top-n"]').first().props() as Props; | ||
| expect(props.defaultView).toEqual('alert'); | ||
| }); | ||
| wrapper.unmount(); |
There was a problem hiding this comment.
FYI @elastic/security-threat-hunting-explore, this test here was a ⏲️ 💣 waiting for just the right conditions to 💥. I just so happened to stumble upon those conditions with this PR here: #175338 (comment)
Will run the flakey-test runner again with this change to make sure everything is 👍 .
There was a problem hiding this comment.
Flakey Test runner added in cebd519
Tests results: 🟢 25/25, build link 🎉
Flakey test runner reverted in d44e4af
stephmilovic
left a comment
There was a problem hiding this comment.
LGTM, sorry jest was mean to you!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
History
To update your PR or re-run it, just comment with: cc @spong |
… API and migrates Post Evaluate API to OAS (elastic#176025) > [!IMPORTANT] > This PR is a reintroduction of elastic#175338, which was [reverted](elastic#175338 (comment)) due to sporadic jest failures within the `security_solution` plugin. Root cause was identified and detailed in elastic#176005 (comment). ## Summary In elastic#174317 we added support for OpenAPI codegen, this PR builds on that functionality by migrating the `Post Evaluate` route `/internal/elastic_assistant/evaluate` to be backed by an OAS, and adds a basic `Get Evaluate` route for rounding out the enhancements outlined in elastic/security-team#8167 (to be in a subsequent PR). Changes include: * Migration of `Post Evaluate` route to OAS * Migration of `Post Evaluate` route to use versioned router * Extracted `evaluate` API calls from `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/api.tsx` to `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/evaluate/evaluate.tsx` * Co-located relevant `use_perform_evaluation` hook * Adds `Get Evaluate` route, and corresponding `use_evaluation_data` hook. Currently only returns `agentExecutors` to be selected for evaluation. * API versioning constants added to `x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts` * Adds new `buildRouteValidationWithZod` function to `x-pack/plugins/elastic_assistant/server/schemas/common.ts` for validating routes against OAS generated zod schemas. ### Checklist Delete any items that are not applicable to this PR. - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
… API and migrates Post Evaluate API to OAS (elastic#176025) > [!IMPORTANT] > This PR is a reintroduction of elastic#175338, which was [reverted](elastic#175338 (comment)) due to sporadic jest failures within the `security_solution` plugin. Root cause was identified and detailed in elastic#176005 (comment). ## Summary In elastic#174317 we added support for OpenAPI codegen, this PR builds on that functionality by migrating the `Post Evaluate` route `/internal/elastic_assistant/evaluate` to be backed by an OAS, and adds a basic `Get Evaluate` route for rounding out the enhancements outlined in elastic/security-team#8167 (to be in a subsequent PR). Changes include: * Migration of `Post Evaluate` route to OAS * Migration of `Post Evaluate` route to use versioned router * Extracted `evaluate` API calls from `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/api.tsx` to `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/evaluate/evaluate.tsx` * Co-located relevant `use_perform_evaluation` hook * Adds `Get Evaluate` route, and corresponding `use_evaluation_data` hook. Currently only returns `agentExecutors` to be selected for evaluation. * API versioning constants added to `x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts` * Adds new `buildRouteValidationWithZod` function to `x-pack/plugins/elastic_assistant/server/schemas/common.ts` for validating routes against OAS generated zod schemas. ### Checklist Delete any items that are not applicable to this PR. - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
… API and migrates Post Evaluate API to OAS (elastic#176025) > [!IMPORTANT] > This PR is a reintroduction of elastic#175338, which was [reverted](elastic#175338 (comment)) due to sporadic jest failures within the `security_solution` plugin. Root cause was identified and detailed in elastic#176005 (comment). ## Summary In elastic#174317 we added support for OpenAPI codegen, this PR builds on that functionality by migrating the `Post Evaluate` route `/internal/elastic_assistant/evaluate` to be backed by an OAS, and adds a basic `Get Evaluate` route for rounding out the enhancements outlined in elastic/security-team#8167 (to be in a subsequent PR). Changes include: * Migration of `Post Evaluate` route to OAS * Migration of `Post Evaluate` route to use versioned router * Extracted `evaluate` API calls from `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/api.tsx` to `x-pack/packages/kbn-elastic-assistant/impl/assistant/api/evaluate/evaluate.tsx` * Co-located relevant `use_perform_evaluation` hook * Adds `Get Evaluate` route, and corresponding `use_evaluation_data` hook. Currently only returns `agentExecutors` to be selected for evaluation. * API versioning constants added to `x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts` * Adds new `buildRouteValidationWithZod` function to `x-pack/plugins/elastic_assistant/server/schemas/common.ts` for validating routes against OAS generated zod schemas. ### Checklist Delete any items that are not applicable to this PR. - [X] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [X] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>


Important
This PR is a reintroduction of #175338, which was reverted due to sporadic jest failures within the
security_solutionplugin. Root cause was identified and detailed in #176005 (comment).Summary
In #174317 we added support for OpenAPI codegen, this PR builds on that functionality by migrating the
Post Evaluateroute/internal/elastic_assistant/evaluateto be backed by an OAS, and adds a basicGet Evaluateroute for rounding out the enhancements outlined in https://github.com/elastic/security-team/issues/8167 (to be in a subsequent PR).Changes include:
Post Evaluateroute to OASPost Evaluateroute to use versioned routerevaluateAPI calls fromx-pack/packages/kbn-elastic-assistant/impl/assistant/api/api.tsxtox-pack/packages/kbn-elastic-assistant/impl/assistant/api/evaluate/evaluate.tsxuse_perform_evaluationhookGet Evaluateroute, and correspondinguse_evaluation_datahook. Currently only returnsagentExecutorsto be selected for evaluation.x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.tsbuildRouteValidationWithZodfunction tox-pack/plugins/elastic_assistant/server/schemas/common.tsfor validating routes against OAS generated zod schemas.Checklist
Delete any items that are not applicable to this PR.