Unit Test Case for the High Level Rest Client?

I am in the process of moving our applications search functionality from Elasticsearch 1.x to 7.x, and from the TransportClient to the HighLevelRestClient, while trying to avoid using all the deprecated (or known to become deprecated or removed in 8) functionality.

Adding actual tests (unit or integration) would be a huge improvement.

The current documentation (https://www.elastic.co/guide/en/elasticsearch/reference/current/unit-tests.html and https://www.elastic.co/guide/en/elasticsearch/reference/current/integration-tests.html and https://github.com/elastic/elasticsearch/blob/master/TESTING.asciidoc ) all point to ESTestCase and ESIntegTestCase - both of which are based on the TransportClient.

There is a ESHighLevelRestTestCase, but it does not appear to actually be packaged and shipped.

Given that the foundation of your testing is being deleted in version 8, what is the timeline for migrating all of it to the Rest Clients?

Is there any infrastructure provided for testing application code that is using the HighLevelRestClient? Given the above sited documentation, I was really hoping that there was, but I haven't been able to find it outside of github, if I missed something I would love pointers.

-Clark

To run integration tests (not unit tests) you would probably prefer running that in something close to a production environment, like a real elasticsearch server instance. I shared some ideas about integration testing in this thread: In memory testing with RestHighLevelClient

Also this sample project shows how to use Elasticsearch Test Classes:

David, thank you for you reply. Had found all that information already and since most of it is over 2 years old, it may predate the announcement of the demise of the TransportClient, which is what led me to my question:

With Elasticsearch 8, the TransportClient is being deleted. All of the provided Java unit testing infrastructure appears (from documentation and reading the code) to be based entirely on the TransportClient. While there is a ESHighLevelRestTestCase in github, it is not packaged for use by 3rd party developers (ie, me).

Given all that, is there any publicly available testing infrastructure for Elasticsearch that is based on the Java Rest Clients? Or do I just need to roll my own?

Since we are migrating all of our elasticsearch code to the Java Rest Clients, it makes absolutely no sense to base our testing infrastructure on code that is highly dependent on the (soon to be deleted) TransportClient unless there is a clearly stated roadmap from the elasticsearch dev's on how and when that testing infrastructure is going to be migrated.

I'd never rely on the elasticsearch test framework unless I'm building a plugin for elasticsearch. And I think this framework is mainly to test elasticsearch not to test an application calling elasticsearch. But I might be wrong.
And @rjernst can tell more probably.

That's why I prefer starting always my own clusters when it comes to integration tests.

I suspect that you are right that the testing framework is intended just for elasticsearch development (including plugins) and not for 3rd party developers.

That its documented (somewhat extensively) in the released documentation under "Testing" may be more misleading than helpful for developers who are not contributors.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.