-
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
[Search] Fixes EQL search strategy #83064
Conversation
The shared search utilities expect that response data exists in the response's body field. However, in an EQL response this information also exists as a sibling to the body field, and so we must normalize this data into the body before we can leverage these utilities with EQL queries.
These were previously needed to work around an index resolution but, but this has since been resolved upstream in elasticsearch via elastic/elasticsearch#63573.
Previously, custom preview histograms were passing a data-test-subj prop to our general histogram, but the general histogram did not know/care about this prop and it did not become a data property on the underlying DOM element. While most of our tests leveraged enzyme, they could still query by this react prop and everything worked as expected. However, now that we want to exercise this behavior in cypress, we need something to propagate to the DOM so that we can determine which histogram has rendered, so the prop has been updated to be `dataTestSubj`, which then becomes a data-test-subj on the histogram's panel. Tests have been updated accordingly.
* Asserts that the preview displays a histogram * Asserts that no error toast is displayed
Pinging @elastic/kibana-app-arch (Team:AppArch) |
@elasticmachine merge upstream |
cy.get(EQL_QUERY_VALIDATION_SPINNER).should('not.exist'); | ||
cy.get(QUERY_PREVIEW_BUTTON).should('not.be.disabled').click({ force: true }); | ||
cy.get(EQL_QUERY_PREVIEW_HISTOGRAM).should('contain.text', 'Hits'); | ||
cy.get(NOTIFICATION_TOASTS).children().should('not.have.class', TOAST_ERROR_CLASS); // asserts no error toast on page |
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.
@MadameSheema I wanted to call out this addition as it might be a nice sanity check throughout the suite
@@ -51,7 +51,7 @@ describe('PreviewCustomQueryHistogram', () => { | |||
|
|||
expect(wrapper.find('[data-test-subj="queryPreviewLoading"]').exists()).toBeTruthy(); | |||
expect( | |||
wrapper.find('[data-test-subj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') | |||
wrapper.find('[dataTestSubj="queryPreviewCustomHistogram"]').at(0).prop('subtitle') |
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.
@yctercero I tried to make as few changes to these tests as possible to maintain behavior while allowing a custom data-test-subj
on each histogram; see 471595f for details
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.
Looks great!
@@ -64,7 +67,7 @@ export const eqlSearchStrategyProvider = ( | |||
(response) => response.body.id, | |||
request.id, | |||
options | |||
).pipe(utils.toKibanaSearchResponse()); | |||
).pipe(normalizeEqlResponse(), utils.toKibanaSearchResponse()); |
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 is the crux of the fix; details are in 9e5abf4
@elasticmachine merge upstream |
|
||
export const NOTIFICATION_TOASTS = '[data-test-subj="globalToastList"]'; | ||
|
||
export const TOAST_ERROR_CLASS = 'euiToast--danger'; |
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.
Always a bummer when we have to use a class for part of a selector but I get when we have to do it.
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.
Yeah, this was the best identifier I could find for now. I'll make a note to add a data-test-subj upstream in notifications next time I come through here 👍
@@ -74,8 +74,6 @@ export const useEqlPreview = (): [ | |||
.search<EqlSearchStrategyRequest, EqlSearchStrategyResponse<EqlSearchResponse<Source>>>( | |||
{ | |||
params: { | |||
// @ts-expect-error allow_no_indices is missing on EqlSearch | |||
allow_no_indices: true, |
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.
👍 Nice!
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.
Reviewed code, everything looks great from my end 👍
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 looks great! Pulled down and tested. The endpoint is intermittently giving a 404, but confirmed that it is due to an unrelated and known issue.
👍
@elasticmachine merge upstream |
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
Just an FYI, we have another refactoring happening here: #82545. I'll update that PR with these changes, and thanks for adding the tests so we can be sure not to break this in the future! |
@elasticmachine merge upstream |
These were updated on an upstream refactor.
💚 Build SucceededMetrics [docs]Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
* Ensure that data is not lost when parsing EQL responses The shared search utilities expect that response data exists in the response's body field. However, in an EQL response this information also exists as a sibling to the body field, and so we must normalize this data into the body before we can leverage these utilities with EQL queries. * Remove unused EQL parameters These were previously needed to work around an index resolution but, but this has since been resolved upstream in elasticsearch via elastic/elasticsearch#63573. * Allow custom test subj for Preview Histogram to propagate to DOM Previously, custom preview histograms were passing a data-test-subj prop to our general histogram, but the general histogram did not know/care about this prop and it did not become a data property on the underlying DOM element. While most of our tests leveraged enzyme, they could still query by this react prop and everything worked as expected. However, now that we want to exercise this behavior in cypress, we need something to propagate to the DOM so that we can determine which histogram has rendered, so the prop has been updated to be `dataTestSubj`, which then becomes a data-test-subj on the histogram's panel. Tests have been updated accordingly. * Exercise Query Preview during EQL rule creation * Asserts that the preview displays a histogram * Asserts that no error toast is displayed * Add integration tests around EQL sequence signal generation * Clearer assertion * Simplify test assertion * Fix typings These were updated on an upstream refactor. Co-authored-by: Kibana Machine <[email protected]> # Conflicts: # x-pack/plugins/security_solution/cypress/tasks/create_new_rule.ts
Summary
#82900
Between search types being too permissive and a lack of test coverage, a recent refactor altered the EQL search strategy responses such that some features in Security Solution were broken. This PR fixes those issues, and adds unit & functional tests to prevent regressions in this area. I also added some integration tests around EQL signal generation to generally bump coverage there as well.
Checklist
Delete any items that are not applicable to this PR.
For maintainers