Skip to content

[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

Merged
merged 1 commit into from
Jun 9, 2017

Conversation

cbuescher
Copy link
Member

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.

@cbuescher cbuescher requested a review from javanna June 8, 2017 11:08
@@ -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);
Copy link
Member Author

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).

@cbuescher cbuescher added :Java High Level REST Client >test Issues or PRs that are addressing/adding tests v6.0.0 labels Jun 8, 2017
@cbuescher cbuescher requested a review from tlrx June 8, 2017 11:10
Copy link
Member

@javanna javanna left a 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
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the comments

@cbuescher cbuescher merged commit 79057b1 into elastic:master Jun 9, 2017
cbuescher added a commit that referenced this pull request Jun 9, 2017
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.
@javanna javanna added the v5.6.0 label Jun 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>test Issues or PRs that are addressing/adding tests v5.6.0 v6.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants