Use testcontainers-scala in tests to launch Elasticsearch instance
If I understood correctly, running tests locally now requires manually launching elasticsearch instance. Also it is done this way in GitHub Actions build script. This can be improved by using https://github.com/testcontainers/testcontainers-scala that will start elasticsearch container automatically when tests are running.
Article with explanation of the approach: https://www.baeldung.com/scala/testcontainers-scala.
Pros:
- Fresh instance of Elastic for each test suite, so the leftovers from other suites (for example, the data that was created and not cleaned up) won't intervene
- No need to configure the env to run tests, just running
sbt testwill start needed containers
Cons:
- Instance is started per test suite, which may take too long to start
Ideally we would indeed switch to testcontainers-scala, a PR would be very welcome.
It would also be very nice to have the tests that require an elasticsearch instance separate in an integration-test configuration or separate project as is the currently recommended way in sbt (https://eed3si9n.com/sbt-1.9.0).
An update: I've tried adding testcontainers and it conflicts with ScrollPublisherVerificationTest and BulkIndexingSubscriberWhiteboxTest, that extend TestNGSuiteLike because both new Testcontainer trait and TestNGSuiteLike define runTest method. Didn't have enough time to think how to overcome this yet.
Update: it takes awhile for elastic to start, which won't align with how testcontainers work (service starting per test suite), closing the issue