Skip to content

Commit

Permalink
Fix ntegrationTest builds for JDK-11 sourcesets
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Redko <[email protected]>
  • Loading branch information
reta committed May 6, 2024
1 parent a6c7dc9 commit d57dd45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 6 additions & 1 deletion java-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,12 @@ if (runtimeJavaVersion >= JavaVersion.VERSION_11) {
sourceCompatibility = JavaVersion.VERSION_11.toString()
}

tasks.test {
tasks.named<Test>("integrationTest") {
testClassesDirs += java11.output.classesDirs
classpath = sourceSets["java11"].runtimeClasspath
}

tasks.named<Test>("unitTest") {
testClassesDirs += java11.output.classesDirs
classpath = sourceSets["java11"].runtimeClasspath
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import org.junit.Test;
import org.opensearch.Version;
Expand Down Expand Up @@ -65,6 +66,7 @@ public void shouldReturnSearchResults() throws Exception {
@Test
public void hybridSearchShouldReturnSearchResults() throws Exception {
assumeTrue("Hybrid search is supported from 2.10.0", getServerVersion().onOrAfter(Version.V_2_10_0));
assumeTrue("Hybrid search needs opensearch-neural-search plugin to be installed", isNeuralSearchPluginInstalled());
final String index = "hybrid_search_request";
try {
createIndex(index);
Expand Down Expand Up @@ -138,6 +140,10 @@ public void shouldReturnSearchResultsWithExt() throws Exception {
assertEquals(response.hits().hits().size(), 8);
}

private boolean isNeuralSearchPluginInstalled() throws IOException {
return javaClient().cat().plugins().valueBody().stream().anyMatch(p -> Objects.equals(p.component(), "opensearch-neural-search"));
}

private void createTestDocuments(String index) throws IOException {
javaClient().create(_1 -> _1.index(index).id("1").document(createItem("hummer", "huge", "yes", 2)));
javaClient().create(_1 -> _1.index(index).id("2").document(createItem("jammer", "huge", "yes", 1)));
Expand Down

0 comments on commit d57dd45

Please sign in to comment.