-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Test/107515 RestoreTemplateWithMatchOnlyTextMapperIT #120392
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
Test/107515 RestoreTemplateWithMatchOnlyTextMapperIT #120392
Conversation
Hi @drempapis, I've created a changelog YAML for you. |
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
@elastic/es-core-infra, can you please have a look to the provided solution? |
Can you give an example of how the sizes could be different but the content is the same? (it's unclear from the linked issue exactly what the difference is) |
I found it debugging the failing test case. The string representation of the cluster state was the following for both
|
So the main way to check that two xcontent things are the same is to convert them to maps, and check the map equality. That way it doesnt consider order. There's other methods on |
Thank you, @thecoop, for the feedback. Do you want me to update this pr using the 'XContentTestUtils` or to assign it to core-infra for a second look? |
Could you update it to use |
assertEquals("cluster state size does not match", masterClusterStateSize, localClusterStateSize); | ||
|
||
// Compare the steMaps for equality. | ||
assertNull(XContentTestUtils.differenceBetweenMapsIgnoringArrayOrder(masterStateMap, localStateMap)); |
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.
@thecoop, I updated the code using the XContentTestUtils
to compare the stateMaps. Please review the proposed solution
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
💔 Backport failed
You can use sqren/backport to manually backport by running |
This is a manual backport of #120392 to 8.x
Closes #107515
I observed that when comparing the cluster states,
local
andmaster
were equal, but the order was different in some cases. Converting to a byte array and getting the length can introduce junk data. Alternatively, the comparison can be made by checking if the returned state strings are anagrams, they contain the same characters.