-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
High level REST client XContent tests are misleading #39745
Comments
Pinging @elastic/es-core-features |
Yes I agree with you. @jtibshirani brought this up to me recently-ish and we arrived at the conclusion that if the Do you think this is enough to mimic production code? cc @martijnvg who was on the other issue as well. |
Yes, that is similar to what I did (although I did not go from client to server to Lines 65 to 76 in bae7e71
|
At least for xpack hlrc, I think this the best we can do without pulling in xpack modules as a test dependency for hlrc tests. Maybe we should consider adding xpack-core as test dependency to hlrc? This will make the request/response unit tests much more realistic. |
The base class facilitates generating a server side response test instance, that gets serialized as xcontent, which then gets parsed into a hlrc response instance, which then gets asserted against the server side response instance. This way of testing is more realistic then how hlrc response classes are tested today, which basically tests that serialization works by generating hlrc response instance, serialize that to xcontent and then parse it back to a hlrc response instance. Besides adding a base test class, this change also cuts AcknowledgedResponseTests and BroadcastResponseTests over to use this base class. Relates to elastic#39745
Cool, let me eyeball this. going from server to |
also Im perfectly fine with having a test dependency on server/xpack, since we are testing that those do ser/deser properly from server (and to server, as we discussed as well @martijnvg ) |
The base class facilitates generating a server side response test instance, that gets serialized as xcontent, which then gets parsed into a hlrc response instance, which then gets asserted against the server side response instance. This way of testing is more realistic then how hlrc response classes are tested today, which basically tests that serialization works by generating hlrc response instance, serialize that to xcontent and then parse it back to a hlrc response instance. Besides adding a base test class, this change also cuts AcknowledgedResponseTests and BroadcastResponseTests over to use this base class. Relates to #39745
The base class facilitates generating a server side response test instance, that gets serialized as xcontent, which then gets parsed into a hlrc response instance, which then gets asserted against the server side response instance. This way of testing is more realistic then how hlrc response classes are tested today, which basically tests that serialization works by generating hlrc response instance, serialize that to xcontent and then parse it back to a hlrc response instance. Besides adding a base test class, this change also cuts AcknowledgedResponseTests and BroadcastResponseTests over to use this base class. Relates to #39745
…lass. This way the response classes are tested in a more realistic setting. Relates to elastic#39745
change hlrc ccr request tests to use AbstractRequestTestCase base class. This way the request classes are tested in a more realistic setting. Note this change also adds a test dependency on xpack core module. Similar to elastic#39844 but then for hlrc request serialization tests. Relates to elastic#39745
…lass This way the response classes are tested in a more realistic setting. Note this change also adds a test dependency on xpack core module. Relates to elastic#39745
changed hlrc ccr request tests to use AbstractRequestTestCase base class. This way the request classes are tested in a more realistic setting. Note this change also adds a test dependency on xpack core module. Similar to #39844 but then for hlrc request serialization tests. Removed iterators from hlrc parsing tests. Use empty xcontent registries. Relates to #39745
changed hlrc ccr request tests to use AbstractRequestTestCase base class. This way the request classes are tested in a more realistic setting. Note this change also adds a test dependency on xpack core module. Similar to #39844 but then for hlrc request serialization tests. Removed iterators from hlrc parsing tests. Use empty xcontent registries. Relates to #39745
…lass. (elastic#40257) This way the response classes are tested in a more realistic setting. Relates to elastic#39745
…#40362) changed hlrc ccr request tests to use AbstractRequestTestCase base class. This way the request classes are tested in a more realistic setting. Note this change also adds a test dependency on xpack core module. Similar to elastic#39844 but then for hlrc request serialization tests. Removed iterators from hlrc parsing tests. Use empty xcontent registries. Relates to elastic#39745
The AbstractHlrcWriteableXContentTestCase was replaced by a better test case a while ago, and this is the last two instances using it. They have been converted and the test is now deleted. Ref elastic#39745
The AbstractHlrcWriteableXContentTestCase was replaced by a better test case a while ago, and this is the last two instances using it. They have been converted and the test is now deleted. Ref #39745
The AbstractHlrcWriteableXContentTestCase was replaced by a better test case a while ago, and this is the last two instances using it. They have been converted and the test is now deleted. Ref #39745
The old graph tests were duplicated a lot and used a deprecated parent class. This commit cleans that up and removes one of the duplicated tests. Ref elastic#39745
This test uses a deprecated base class, and this commit moves it over to the new class. Ref elastic#39745
The old graph tests were duplicated a lot and used a deprecated parent class. This commit cleans that up and removes one of the duplicated tests. Ref #39745
This test uses a deprecated base class, and this commit moves it over to the new class. Ref #39745
This commit finishes cleaning up the AbstractHlrcXContentTestCase work and removes this class. All classes that were using this are now using the updated base class. Ref elastic#39745
This commit finishes cleaning up the AbstractHlrcXContentTestCase work and removes this class. All classes that were using this are now using the updated base class. Ref #39745
The old graph tests were duplicated a lot and used a deprecated parent class. This commit cleans that up and removes one of the duplicated tests. Ref #39745
This test uses a deprecated base class, and this commit moves it over to the new class. Ref #39745
This commit finishes cleaning up the AbstractHlrcXContentTestCase work and removes this class. All classes that were using this are now using the updated base class. Ref #39745
Chatted w @martijnvg and we think this can be closed with those two old base tests gone. |
Many high-level REST client XContent tests where we use a dedicated client class (e.g.,
org.elasticsearch.client.core.AcknowledgeResponse
) are misleading and not actually testing what occurs in production.For example, let us consider the case of
org.elasticsearch.core.AcknowledgedResponse
for whichXContent
is tested viaorg.elasticsearch.client.core.AcknowledgedResponseTests
. However, this test does not actually test what occurs in production.What occurs in production is that a concrete instance of
org.elasticsearch.action.support.master.AcknowledgedResponse
is serialized toXContent
on the REST layer, and then client side is deserialized fromXContent
by the HLRC. We need confidence that this translation is working.The test that we have today based on
AbstractXContentTestCase#xContentTester
does not actually test this. Instead, it creates a concrete instance oforg.elasticsearch.client.core.AcknowledgedResponse
, converts this toXContent
via non-production test code, and then checks that thatXContent
can be converted back to an instance oforg.elasticsearch.client.core.AcknowledgedResponse
. This does not give us confidence that the translation between a serializedXContent
oforg.elasticsearch.action.support.master.AcknowledgedResponse
is properly deserialized to an instance oforg.elasticsearch.client.core.AcknowledgedResponse
in the HLRC. That's the production code path that we want to test.We probably want a dedicated framework like
AbstractXContentTestCase#xContentTester
for this. See #39713 comment for the discussion that triggered this issue, and a test that is based on production code rather than non-production code.The text was updated successfully, but these errors were encountered: