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

Randomize Content-Type in REST tests #23245

Merged
merged 8 commits into from
Feb 27, 2017

Conversation

javanna
Copy link
Member

@javanna javanna commented Feb 17, 2017

This PR introduces randomization of the content type for requests sent as part of our REST tests. Requests can be sent in any supported format, and responses can be read from any of the supported formats too, according to the returned Content-Type header.

This new randomization revealed a couple of problems:

@javanna javanna added review >test Issues or PRs that are addressing/adding tests v5.4.0 v6.0.0-alpha1 labels Feb 17, 2017
@javanna javanna requested a review from jaymode February 17, 2017 22:15
@javanna javanna changed the title Test/randomize xcontent type Randomize Content-Type in REST tests Feb 17, 2017
@javanna javanna added WIP and removed review labels Feb 19, 2017
@KodrAus
Copy link

KodrAus commented Feb 19, 2017

So... Why randomise it instead of always testing all content types?

@javanna
Copy link
Member Author

javanna commented Feb 20, 2017

hi @KodrAus , this suite runs around 700 tests and takes a few minutes to run. The content type that is most important is json, the one that we've been using up until now. Running all the same tests with yaml, cbor and smile too would take too long, that is why randomizing helps. I think I will also go back and give a bit more importance to json though, given that it is the most widely used format.

@KodrAus
Copy link

KodrAus commented Feb 20, 2017

@javanna I thought that might be the case :) Thanks for taking the time to clarify!

@javanna javanna force-pushed the test/randomize_xcontent_type branch 6 times, most recently from 7904c42 to fc2d893 Compare February 21, 2017 14:08
Copy link
Member

@jaymode jaymode left a comment

Choose a reason for hiding this comment

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

This is great; thanks for doing this @javanna. I left a few small comments but other than that LGTM

String key = entry.getKey();
String value = entry.getValue();
Map<String, Object> settings = new HashMap<>();
if (request.hasContent()) {
Copy link
Member

Choose a reason for hiding this comment

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

this is a nit IMO, but might be cleaner if the request#contentOrSourceParamParserOrNull method is used?

binary:
type: binary
doc_values: true
#binary:
Copy link
Member

Choose a reason for hiding this comment

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

should we remove all of these commented lines since it seems they have been moved to another test?

Copy link
Member Author

Choose a reason for hiding this comment

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

leftover, will remove

if (bodies.size() == 1) {
return bodyAsString(stash.replaceStashedValues(bodies.get(0)));
XContentType xContentType = null;
String contentType = headers.get("Content-Type");
Copy link
Member

Choose a reason for hiding this comment

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

I think we may want to document that the headers used in the yaml tests are case sensitive or fix the map to be case insensitive?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was hoping you wouldn't catch this :)

@javanna
Copy link
Member Author

javanna commented Feb 22, 2017

heya @jaymode thanks for the review, FYI I took out the script changes and opened #23308 . I am contemplating taking also out other changes outside of tests to their own PRs.

@javanna javanna force-pushed the test/randomize_xcontent_type branch 4 times, most recently from 0a8b356 to d4d8cec Compare February 27, 2017 09:57
This allows to set content-type together with the body itself. At the moment it is always json, but this change allows makes it easier to randomize it later
…g tests

This test makes little sense when sent from the REST layer, as WrapperQueryBuilder is supposed to be used from the Java api. Also, providing the inner query as base64 string will work only for string formats and break for binary formats like SMILE and CBOR, whcih doesn't play well with randomizing content type in our REST tests
Rather test that the size is present and greather than zero. The actual size depends on the content-type, which is randomized.
@javanna javanna merged commit 756e26c into elastic:master Feb 27, 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.4.0 v6.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants