-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Compute cluster state chunk count in tests #99282
Conversation
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.
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())) |
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.
Is the Iterators.map
needed here?
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 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>
.
This is great. I wasn't clear on chunk arithmetic when I was updating the magic numbers. Now I almost sort of get it. |
Yeah nor me I just hard-coded the numbers to make the tests pass in #92285, it's been bugging me ever since. |
Compiling with `Werror` indicates these test files implicitly do a lossy conversion. Making the final conversion explicit in the tests. Relates: #99282
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.