-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
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 which XContent is tested via org.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 to XContent on the REST layer, and then client side is deserialized from XContent 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 of org.elasticsearch.client.core.AcknowledgedResponse, converts this to XContent via non-production test code, and then checks that that XContent can be converted back to an instance of org.elasticsearch.client.core.AcknowledgedResponse. This does not give us confidence that the translation between a serialized XContent of org.elasticsearch.action.support.master.AcknowledgedResponse is properly deserialized to an instance of org.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.