-
Notifications
You must be signed in to change notification settings - Fork 25.2k
[Tests] Check Suggestion parsers robustness for new fields #25132
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
Conversation
@@ -90,7 +90,7 @@ public void testFromXContent() throws IOException { | |||
Suggest suggest = createTestItem(); | |||
XContentType xContentType = randomFrom(XContentType.values()); | |||
boolean humanReadable = randomBoolean(); | |||
BytesReference originalBytes = toXContent(suggest, xContentType, params, humanReadable); | |||
BytesReference originalBytes = toShuffledXContent(suggest, xContentType, params, humanReadable); |
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.
Note: this test doesn't need any field randomization I think. The suggest element is a object containing names Suggestions, which we already test elsewhere. I think it is not possible that we add anything other inside this object unless we change the whole structure of the xContent (which is another story).
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
if (addRandomFields) { | ||
// - "contexts" is an object consisting of key/array pairs, we shouldn't add anything random there | ||
// - there can be inner search hits fields inside this option where we cannot add random stuff | ||
// - the root object should be excluded since it contains the named suggestion arrays |
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.
Thanks for the comments
When parsing responses we should be ignoring any new unknown fields or inner objects in most cases to be forward compatible with changes in core on the client side. This change adds test for this for Suggestions and its various subclasses to check if we are able to ignore new fields and objects in the xContent.
When parsing resonses we should be ignoring any new unknown fields or inner objects in most cases to be forward compatible with changes in core on the
client side. This change adds test for this for Suggestions and its various subclasses to check if we are able to ignore new fields and objects in the xContent.