
Testcontainers for real integration tests with Elasticsearch
How are you testing with your database?
- Mocking is not an option since you want to test the actual system.
- In-memory databases, like H2 or HSQLDB, have subtle differences and not all datastores have in-memory cousins.
- Managing and running tests in parallel against the actual datastore is a pain.
So what is the solution? There are some very neat solutions based on containers, namely the Docker-Maven-Plugin and Testcontainers. From your tests you can start a lightweight, throwaway instance of your datastore and this talk will walk you through how to do that.
And we will introduce the module we built for Elasticsearch: https://www.testcontainers.org/modules/elasticsearch/.
Resources
- Demo: Elasticsearch Integration Tests β This demo shows how you can test your Elasticsearch integration with Testcontainers.
- Repository: Elasticsearch Module for TestContainers β This repository contains the code for the Elasticsearch Module for TestContainers.
- Documentation: Elasticsearch TestContainers module β This documentation contains the information about the Elasticsearch TestContainers module.