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

Compute cluster state chunk count in tests #99282

Merged

Conversation

DaveCTurner
Copy link
Contributor

Today in tests we hard-code the expected chunk count for cluster state
responses, which means we have to change several magic numbers whenever
anything about the serialization changes. This commit adjusts these
tests to compute the expected chunk count based on the contents of the
cluster state instead, which removes the need for those magic numbers.

Today in tests we hard-code the expected chunk count for cluster state
responses, which means we have to change several magic numbers whenever
anything about the serialization changes. This commit adjusts these
tests to compute the expected chunk count based on the contents of the
cluster state instead, which removes the need for those magic numbers.
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Core/Infra/REST API REST infrastructure and utilities v8.11.0 labels Sep 7, 2023
@elasticsearchmachine elasticsearchmachine added the Team:Core/Infra Meta label for core/infra team label Sep 7, 2023
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

} else {
// could be anything, we have to just try it
chunkCount += Iterables.size(
(Iterable<ToXContent>) (() -> Iterators.map(custom.toXContentChunked(params), Function.identity()))
Copy link
Member

Choose a reason for hiding this comment

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

Is the Iterators.map needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah or at least I couldn't work out a nicer way to satisfy the typechecker that an Iterator<? extends ToXContent> is a cromulent Iterator<ToXContent>.

@DaveCTurner DaveCTurner merged commit c2dc599 into elastic:main Sep 7, 2023
@DaveCTurner DaveCTurner deleted the 2023/09/06/cluster-state-chunk-count branch September 7, 2023 11:07
@williamrandolph
Copy link
Contributor

This is great. I wasn't clear on chunk arithmetic when I was updating the magic numbers. Now I almost sort of get it.

@DaveCTurner
Copy link
Contributor Author

Yeah nor me I just hard-coded the numbers to make the tests pass in #92285, it's been bugging me ever since.

elasticsearchmachine pushed a commit that referenced this pull request Sep 13, 2023
Compiling with `Werror` indicates these test files implicitly do a lossy
conversion.

Making the final conversion explicit in the tests.

Relates: #99282
@DaveCTurner DaveCTurner restored the 2023/09/06/cluster-state-chunk-count branch June 17, 2024 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/REST API REST infrastructure and utilities Team:Core/Infra Meta label for core/infra team >test Issues or PRs that are addressing/adding tests v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants