Use Testcontainers for integration tests#2033
Open
lsh1215 wants to merge 4 commits into
Open
Conversation
b151d92 to
389d48e
Compare
Signed-off-by: sanghun <vitash1215@gmail.com>
389d48e to
5923c09
Compare
Signed-off-by: sanghun <vitash1215@gmail.com>
Signed-off-by: sanghun <vitash1215@gmail.com>
reta
requested changes
Jun 30, 2026
Signed-off-by: sanghun <vitash1215@gmail.com>
reta
reviewed
Jul 2, 2026
| testImplementation("org.opensearch.test", "framework", opensearchVersion) { | ||
| exclude(group = "org.hamcrest") | ||
| } | ||
| // opensearch-testcontainers exposes OpenSearchContainer as a GenericContainer subclass, but publishes |
Collaborator
There was a problem hiding this comment.
Please just use:
Suggested change
| // opensearch-testcontainers exposes OpenSearchContainer as a GenericContainer subclass, but publishes | |
| testImplementation("org.opensearch:opensearch-testcontainers:4.1.0") | |
| testImplementation"("org.testcontainers:testcontainers:2.0.4") | |
| testImplementation"("org.testcontainers:testcontainers-junit-jupiter:2.0.4") |
reta
reviewed
Jul 2, 2026
|
|
||
| import org.junit.Test; | ||
|
|
||
| public class OpenSearchTestContainerTests { |
Collaborator
There was a problem hiding this comment.
I don't think we need these tests - opensearch-testcontainers has bunch of them
reta
reviewed
Jul 2, 2026
|
|
||
| import org.opensearch.testcontainers.OpenSearchContainer; | ||
|
|
||
| final class OpenSearchTestContainer { |
Collaborator
There was a problem hiding this comment.
Please move under java-client/src/test/java21. Also, we should be using JUnit Jupiter extentions mechanism with proper pre / post lifycycle (see please examples here https://www.baeldung.com/junit-5-registerextension-annotation)
reta
reviewed
Jul 2, 2026
|
|
||
| import com.carrotsearch.randomizedtesting.ThreadFilter; | ||
|
|
||
| public final class TestcontainersThreadFilter implements ThreadFilter { |
Collaborator
There was a problem hiding this comment.
Please remove, we should not see any leaking threads after https://github.com/opensearch-project/opensearch-java/pull/2033/changes#r3514648791 (the extension part)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds Testcontainers-backed OpenSearch startup for Java client integration tests so developers and the released integration workflow no longer need to start OpenSearch with Docker Compose before running
integrationTest.The Testcontainers path is enabled by default for the
integrationTesttask. Existing externally managed clusters remain supported by settingtests.rest.clusteror disabling the test container with-Dtests.opensearch.testcontainers.enabled=false.The Docker/Testcontainers startup path is limited to the
integrationTesttask. The released integration CI path remains Ubuntu-only, and the macOS/Windows build and unit-test jobs do not get a Docker runtime requirement.Closes #1916.
Changes
OpenSearchTestContainerhelper for integration tests.OpenSearchRestTestCaseinitializes its REST client.cluster.blocks.create_index=trueduring tests.Verification
git diff --check./gradlew integrationTest --tests "org.opensearch.client.opensearch.integTest.OpenSearchTestContainerTests"./gradlew spotlessJavaCheck./gradlew integrationTest --tests "org.opensearch.client.opensearch.integTest.restclient.PingAndInfoIT" -Dtests.opensearch.version=3.2.0