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

Clean up XPackInfoResponse class and related tests #35547

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Nov 14, 2018

This is a follow-up of something that I raised in a previous PR.

Response classes in Elasticsearch (and xpack) only need to implement ToXContent, which is needed to print their output put in the REST layer and return the response in json (or others) format. On the other hand, response classes that are added to the high-level REST client, need to do the opposite: parse xcontent and create a new object based on that.

At the moment, both variants of XPackInfoResponse (xpack and client) do both: parsing and printing. This is redundant, it leads to code duplication, and redundant testing too. Now that we have a way to test these classes from a single test (see AbstractHlrcStreamableXContentTestCase base class), we should remove code duplication and only maintain the needed portions in each response class.

This PR removes the parsing code from the XPackInfoResponse server variant, and the toXContent portion from the corresponding client variant. It also removes a client specific test class that looks redundant now that we have a single test class for both classes. I will mark this for discussion to see whether this is the approach that we want to take moving forward.

Response classes in Elasticsearch (and xpack) only need to implement ToXContent, which is needed to print their output put in the REST layer and return the response in json (or others) format. On the other hand, response classes that are added to the high-level REST client, need to do the opposite: parse xcontent and create a new object based on that.

At the moment, both variants of XPackInfoResponse (xpack and client) do both: parsing and printing. This is redundant, it leads to code duplication, and redundant testing too. Now that we have a way to test these classes from a single test (see `AbstractHlrcStreamableXContentTestCase` base class), we should remove code duplication and only maintain the needed portions in each response class.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

LGTM

@nik9000
Copy link
Member

nik9000 commented Nov 14, 2018

You marked it as discuss, but I think this is the right way to do it. We need to make sure we don't accidentally remove tests for parsing at all, but I love that we're testing if the client can parse stuff sent from the server now.

@javanna
Copy link
Member Author

javanna commented Nov 14, 2018

We need to make sure we don't accidentally remove tests for parsing at all, but I love that we're testing if the client can parse stuff sent from the server now.

Agreed, please double check that I have only removed duplicated tests, that was my intention, but I may have missed some subtleties.

@javanna
Copy link
Member Author

javanna commented Nov 14, 2018

retest this please

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

It looks right.

I don't really that the test is in x-pack instead of the client, but I think it kind of has to be.

@nik9000
Copy link
Member

nik9000 commented Nov 14, 2018

I don't really that the test is in x-pack instead of the client, but I think it kind of has to be.

And that isn't a thing you changed, either.

@javanna
Copy link
Member Author

javanna commented Nov 14, 2018

@vladimirdolzhenko are you ok with this?

@vladimirdolzhenko
Copy link
Contributor

@javanna sure, please go ahead 💯

@javanna javanna merged commit 8e2c84a into elastic:master Nov 15, 2018
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 19, 2018
This commit removes the parsing code from the PostStartBasicResponse server variant, and the toXContent portion from the corresponding client variant (StartBasicResponse).

Relates to elastic#35547
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 19, 2018
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant.

Relates to elastic#35547
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 19, 2018
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant.

Relates to elastic#35547
javanna added a commit to javanna/elasticsearch that referenced this pull request Nov 19, 2018
This commit removes the parsing code from the PostStartBasicResponse server variant. It also makes the server response implement StatusToXContent which allows us to save a couple of lines of code in the corredponding REST action.

Relates to elastic#35547
javanna added a commit that referenced this pull request Nov 21, 2018
This commit removes the parsing code from the PostStartBasicResponse server variant. It also makes the server response implement StatusToXContent which allows us to save a couple of lines of code in the corredponding REST action.

Relates to #35547
javanna added a commit that referenced this pull request Nov 21, 2018
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant.

Relates to #35547
javanna added a commit that referenced this pull request Nov 23, 2018
Response classes in Elasticsearch (and xpack) only need to implement ToXContent, which is needed to print their output put in the REST layer and return the response in json (or others) format. On the other hand, response classes that are added to the high-level REST client, need to do the opposite: parse xcontent and create a new object based on that.

This commit removes the parsing code from the XPackInfoResponse server variant, and the toXContent portion from the corresponding client variant. It also removes a client specific test class that looks redundant now that we have a single test class for both classes.
javanna added a commit that referenced this pull request Nov 23, 2018
This commit removes the parsing code from the PostStartBasicResponse server variant. It also makes the server response implement StatusToXContent which allows us to save a couple of lines of code in the corredponding REST action.

Relates to #35547
javanna added a commit that referenced this pull request Nov 23, 2018
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant.

Relates to #35547
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants