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
Clean up XPackInfoResponse class and related tests #35547
Conversation
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.
Pinging @elastic/es-core-infra |
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
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. |
Agreed, please double check that I have only removed duplicated tests, that was my intention, but I may have missed some subtleties. |
retest this please |
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.
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.
And that isn't a thing you changed, either. |
@vladimirdolzhenko are you ok with this? |
@javanna sure, please go ahead 💯 |
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
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant. Relates to elastic#35547
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant. Relates to elastic#35547
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
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
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant. Relates to #35547
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.
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
This commit removes the parsing code from the PutLicenseResponse server variant, and the toXContent portion from the corresponding client variant. Relates to #35547
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 thetoXContent
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.