-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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] [Elastic AI Assistant] Adds internal Get Evaluate API and migrates Post Evaluate API to OAS #176025
Conversation
Pinging @elastic/security-solution (Team: SecuritySolution) |
@@ -22,7 +22,6 @@ window.HTMLElement.prototype.scrollIntoView = jest.fn(); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon further testing locally, I was able to isolate the issue to this test here:
kibana/x-pack/plugins/security_solution/public/common/components/top_n/index.test.tsx
Lines 358 to 377 in 15ca37f
describe('rendering in alerts context', () => { | |
detectionAlertsTables.forEach((tableId) => { | |
test(`defaults to the 'Alert events' option when rendering in Alerts`, async () => { | |
const wrapper = mount( | |
<TestProviders store={store}> | |
<StatefulTopN | |
{...{ | |
...testProps, | |
scopeId: tableId, | |
}} | |
/> | |
</TestProviders> | |
); | |
await waitFor(() => { | |
const props = wrapper.find('[data-test-subj="top-n"]').first().props() as Props; | |
expect(props.defaultView).toEqual('alert'); | |
}); | |
}); | |
}); | |
}); |
Fix to this test is provided in: 0b4028c
@@ -372,6 +372,7 @@ describe('StatefulTopN', () => { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flakey Test runner added in cebd519
Tests results: 🟢 25/25
, build link 🎉
Flakey test runner reverted in d44e4af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 <[email protected]>
… 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 <[email protected]>
… 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 <[email protected]>
Important
This PR is a reintroduction of #175338, which was reverted due to sporadic jest failures within the
security_solution
plugin. 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 Evaluate
route/internal/elastic_assistant/evaluate
to be backed by an OAS, and adds a basicGet Evaluate
route for rounding out the enhancements outlined in https://github.com/elastic/security-team/issues/8167 (to be in a subsequent PR).Changes include:
Post Evaluate
route to OASPost Evaluate
route to use versioned routerevaluate
API calls fromx-pack/packages/kbn-elastic-assistant/impl/assistant/api/api.tsx
tox-pack/packages/kbn-elastic-assistant/impl/assistant/api/evaluate/evaluate.tsx
use_perform_evaluation
hookGet Evaluate
route, and correspondinguse_evaluation_data
hook. Currently only returnsagentExecutors
to be selected for evaluation.x-pack/packages/kbn-elastic-assistant-common/impl/schemas/index.ts
buildRouteValidationWithZod
function tox-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.