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

[Discover] Unskip Discover-Lens functional test suite #200687

Merged
merged 6 commits into from
Nov 20, 2024

Conversation

kertal
Copy link
Member

@kertal kertal commented Nov 19, 2024

Summary

Fixes #184600

The PR catches propagating an invalid state of properties to the Lens embeddable, that causes this error, when e.g. ad hoc data views are being edited causing the following error when rendering the histogram in Discover:

image

Note: this midigates and catches an invalid state, that we ideally should catch before it happens, but the current approach fixes the problem, but we should to refactor this to stabilize and ideally simplify.

Testing

There was a reliable way to run into this error before this PR:

  • Install all sample data.
  • On Discover page, create an ad hoc data view kib* with @timetamp as the time field.
  • Edit data view and set timestamp as the time field.
  • Edit again and remove the time field.
  • Edit again and set timestamp as the time field.

This caused the histogram to fail, but this should no longer be the case

Checklist

@kertal kertal self-assigned this Nov 19, 2024
@kertal
Copy link
Member Author

kertal commented Nov 19, 2024

/ci

Comment on lines 207 to 221
if (
dataView.id &&
(dataView.id !== visContext.requestData.dataViewId ||
(!dataView.isPersisted() && !lensProps.attributes.state.adHocDataViews?.[dataView.id]))
) {
// to prevent a race condition when the data view changes id
// the ids of the data view and the lens props and visContextDataView should be the same
// console.log('flakydebugging', {
// dataViewId: dataView.id,
// visContextDataViewId: visContext.requestData.dataViewId,
// lensProps: lensProps.attributes.references.find((r) => r.id === dataView.id),
// });

return <></>;
}
Copy link
Member Author

@kertal kertal Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this seems to prevent the history to fail, because we have different data views in different props that are passed into the Lens embeddable. Ideally this should be caught on a higher level, so this kind of situation can't happen. So just display a loading state until props are aligned
However, if this resolves the race condition, it's now clear what's causing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's unskip the test suite and run the flaky test runner too.
I was not able to reproduce the dave view error on this branch!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! Thx! This is great news!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, another update to tests would be necessary once you unskip them as in e9d5c25

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests are green, and flaky test runner too

@kertal
Copy link
Member Author

kertal commented Nov 19, 2024

/ci

@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#7427

[✅] test/functional/apps/discover/group3/config.ts: 25/25 tests passed.

see run history

@kertal kertal added Feature:Discover Discover Application Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. labels Nov 20, 2024
@@ -204,6 +230,10 @@ export function Histogram({
}
`;

if (!checkValidDataViewConfig(dataView, visContext, lensProps.attributes.state.adHocDataViews)) {
return <></>;
Copy link
Member Author

@kertal kertal Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jughosta do we have an alternative here? we need to prevent the rendering for the flaky case, should we render something, given we move forward with this PR (it woulld need to be investigated or refactored later on, since the given state causing the flakiness ideally should not happen)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an alternative right now. What I've tried was causing other test failures and extra fetches. So let's go with your solution.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so we should open an issue to remove this code, given we resolve the root cause, which might be a bigger refactoring

@kertal kertal added release_note:skip Skip the PR/issue when compiling release notes backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development and removed backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) labels Nov 20, 2024
@kertal kertal marked this pull request as ready for review November 20, 2024 10:20
@kertal kertal requested a review from a team as a code owner November 20, 2024 10:20
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

@kertal kertal requested a review from jughosta November 20, 2024 10:36
@kertal kertal changed the title [Discover] Attempt to catch data view id race condition in the histogram [Discover] Unskip Discover-Lens functional test suite Nov 20, 2024
@dej611 dej611 mentioned this pull request Nov 20, 2024
74 tasks
Copy link
Contributor

@jughosta jughosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @kertal!

@kertal

This comment was marked as outdated.

@kertal kertal enabled auto-merge (squash) November 20, 2024 16:14
@kertal kertal merged commit e082cd1 into elastic:main Nov 20, 2024
26 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.15, 8.16, 8.x

https://github.com/elastic/kibana/actions/runs/11938778024

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
unifiedHistogram 71.3KB 71.4KB +161.0B

cc @kertal

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Nov 20, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.

(cherry picked from commit e082cd1)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.15 Backport failed because of merge conflicts
8.16 Backport failed because of merge conflicts
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Manual backport

To create the backport manually run:

node scripts/backport --pr 200687

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Nov 20, 2024
…#201013)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Discover] Unskip Discover-Lens functional test suite
(#200687)](#200687)

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

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

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-20T17:38:05Z","message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-major"],"title":"[Discover]
Unskip Discover-Lens functional test suite
","number":200687,"url":"https://github.com/elastic/kibana/pull/200687","mergeCommit":{"message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200687","number":200687,"mergeCommit":{"message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c"}}]}]
BACKPORT-->

Co-authored-by: Matthias Wilhelm <[email protected]>
kertal added a commit to kertal/kibana that referenced this pull request Nov 21, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.

(cherry picked from commit e082cd1)

# Conflicts:
#	test/functional/apps/discover/group3/_lens_vis.ts
@kertal
Copy link
Member Author

kertal commented Nov 21, 2024

💚 All backports created successfully

Status Branch Result
8.16
8.15

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kertal added a commit to kertal/kibana that referenced this pull request Nov 21, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.

(cherry picked from commit e082cd1)

# Conflicts:
#	src/plugins/unified_histogram/public/chart/histogram.tsx
#	test/functional/apps/discover/group3/_lens_vis.ts
kertal added a commit that referenced this pull request Nov 21, 2024
#201076)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Discover] Unskip Discover-Lens functional test suite
(#200687)](#200687)

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

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

<!--BACKPORT [{"author":{"name":"Matthias
Wilhelm","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-20T17:38:05Z","message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:skip","v9.0.0","Team:DataDiscovery","backport:prev-major","v8.17.0"],"number":200687,"url":"https://github.com/elastic/kibana/pull/200687","mergeCommit":{"message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200687","number":200687,"mergeCommit":{"message":"[Discover]
Unskip Discover-Lens functional test suite (#200687)\n\nCatching an
invalid state of properties propagated to the UnifiedHistogram which is
using the Lens embeddable in Discover, that causes a rendering error
when e.g. ad hoc data views are being edited. Therefore the skipped
testview can be
unskipped.","sha":"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c"}},{"branch":"8.x","label":"v8.17.0","labelRegex":"^v8.17.0$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/201013","number":201013,"state":"MERGED","mergeCommit":{"sha":"e2c0c94b52a4fe3486a0e85b84e9856821c27afc","message":"[8.x]
[Discover] Unskip Discover-Lens functional test suite (#200687)
(#201013)\n\n# Backport\n\nThis will backport the following commits from
`main` to `8.x`:\n- [[Discover] Unskip Discover-Lens functional test
suite\n(#200687)](https://github.com/elastic/kibana/pull/200687)\n\n<!---
Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the
[Backport
tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT
[{\"author\":{\"name\":\"Matthias\nWilhelm\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-11-20T17:38:05Z\",\"message\":\"[Discover]\nUnskip
Discover-Lens functional test suite (#200687)\\n\\nCatching an\ninvalid
state of properties propagated to the UnifiedHistogram which is\nusing
the Lens embeddable in Discover, that causes a rendering error\nwhen
e.g. ad hoc data views are being edited. Therefore the skipped\ntestview
can
be\nunskipped.\",\"sha\":\"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"Feature:Discover\",\"release_note:skip\",\"v9.0.0\",\"Team:DataDiscovery\",\"backport:prev-major\"],\"title\":\"[Discover]\nUnskip
Discover-Lens functional test
suite\n\",\"number\":200687,\"url\":\"https://github.com/elastic/kibana/pull/200687\",\"mergeCommit\":{\"message\":\"[Discover]\nUnskip
Discover-Lens functional test suite (#200687)\\n\\nCatching an\ninvalid
state of properties propagated to the UnifiedHistogram which is\nusing
the Lens embeddable in Discover, that causes a rendering error\nwhen
e.g. ad hoc data views are being edited. Therefore the skipped\ntestview
can
be\nunskipped.\",\"sha\":\"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/200687\",\"number\":200687,\"mergeCommit\":{\"message\":\"[Discover]\nUnskip
Discover-Lens functional test suite (#200687)\\n\\nCatching an\ninvalid
state of properties propagated to the UnifiedHistogram which is\nusing
the Lens embeddable in Discover, that causes a rendering error\nwhen
e.g. ad hoc data views are being edited. Therefore the skipped\ntestview
can
be\nunskipped.\",\"sha\":\"e082cd1dfaa79c6fdfc5d7f1d2842b6ca0a5db6c\"}}]}]\nBACKPORT-->\n\nCo-authored-by:
Matthias Wilhelm <[email protected]>"}}]}] BACKPORT-->
@kertal
Copy link
Member Author

kertal commented Nov 21, 2024

was not backported to 8.15 since it was not skipped there

@mistic
Copy link
Member

mistic commented Nov 21, 2024

This PR didn't make it into the latest BC of v8.16.1. Updating the labels.

@mistic mistic added v8.16.2 and removed v8.16.1 labels Nov 21, 2024
TattdCodeMonkey pushed a commit to TattdCodeMonkey/kibana that referenced this pull request Nov 21, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.
paulinashakirova pushed a commit to paulinashakirova/kibana that referenced this pull request Nov 26, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.
CAWilson94 pushed a commit to CAWilson94/kibana that referenced this pull request Dec 12, 2024
Catching an invalid state of properties propagated to the UnifiedHistogram which is using the Lens embeddable in Discover, that causes a rendering error when e.g. ad hoc data views are being edited. Therefore the skipped testview can be unskipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-major Backport to (8.x, 8.17, 8.16) the previous major branch and other branches in development Feature:Discover Discover Application release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (e.g. data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. v8.16.2 v8.17.0 v9.0.0
Projects
None yet
5 participants