diff --git a/.eclipseformat.xml b/.eclipseformat.xml
new file mode 100644
index 00000000..6e93f9b2
--- /dev/null
+++ b/.eclipseformat.xml
@@ -0,0 +1,362 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index 63b78b4a..884ad7fa 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -19,8 +19,24 @@ jobs:
with:
product: opensearch
+ spotless:
+ if: github.repository == 'opensearch-project/opensearch-learning-to-rank-base'
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout LTR
+ uses: actions/checkout@v4
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ # Spotless requires JDK 17+
+ - name: Setup Java 21
+ uses: actions/setup-java@v1
+ with:
+ java-version: 21
+ - name: Spotless Check
+ run: ./gradlew spotlessCheck
+
Build-ltr-linux:
- needs: [Get-CI-Image-Tag]
+ needs: [Get-CI-Image-Tag, spotless]
strategy:
matrix:
java: [21]
@@ -54,7 +70,7 @@ jobs:
run: |
chown -R 1000:1000 `pwd`
su `id -un 1000` -c 'whoami && java -version &&
- ./gradlew -Dtests.security.manager=false clean test'
+ ./gradlew -Dtests.security.manager=false clean test -x spotlessJava'
Build-ltr-windows:
@@ -63,6 +79,7 @@ jobs:
java: [ 21 ]
name: Build and Test LTR Plugin on Windows
if: github.repository == 'opensearch-project/opensearch-learning-to-rank-base'
+ needs: [spotless]
runs-on: windows-latest
steps:
- name: Setup Java ${{ matrix.java }}
@@ -77,4 +94,4 @@ jobs:
- name: Build and Run Tests
shell: bash
run: |
- ./gradlew.bat build
\ No newline at end of file
+ ./gradlew.bat build -x spotlessJava
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index c07e1002..cc9ec9b6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,7 +15,7 @@ __pycache__/
RankLib.jar
tmdb.json
model.txt
-
+.DS_Store
.idea/
.gradle/
diff --git a/build.gradle b/build.gradle
index 72a13f13..b4509909 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,6 +15,7 @@ buildscript {
if (is_snapshot) {
opensearch_build += "-SNAPSHOT"
}
+ common_utils_version = System.getProperty("common_utils.version", opensearch_build)
}
repositories {
@@ -33,6 +34,7 @@ plugins {
id 'java'
id 'idea'
id 'maven-publish'
+ id 'com.diffplug.spotless' version '6.23.0'
}
group = 'org.opensearch'
@@ -124,13 +126,28 @@ dependencies {
implementation "org.ow2.asm:asm-tree:${ow2Version}"
implementation 'com.o19s:RankyMcRankFace:0.1.1'
implementation "com.github.spullara.mustache.java:compiler:0.9.3"
+ implementation "org.apache.httpcomponents.client5:httpclient5:5.3.1"
+ implementation "org.apache.httpcomponents.core5:httpcore5:5.3"
+ implementation "org.apache.httpcomponents.core5:httpcore5-h2:5.3"
+ implementation "org.conscrypt:conscrypt-openjdk-uber:2.5.2"
+ implementation 'org.slf4j:slf4j-api:1.7.36'
+ implementation 'org.slf4j:slf4j-simple:1.7.36'
+ implementation "org.opensearch:common-utils:${common_utils_version}"
- //testImplementation 'org.apache.lucene:lucene-test-framework:${luceneVersion}'
runtimeOnly 'org.locationtech.spatial4j:spatial4j:0.7'
runtimeOnly 'org.locationtech.jts:jts-core:1.15.0'
runtimeOnly 'org.apache.logging.log4j:log4j-core:2.21.0'
}
+configurations.all {
+ resolutionStrategy.force "org.apache.httpcomponents.client5:httpclient5:5.3.1"
+ resolutionStrategy.force "org.apache.httpcomponents.core5:httpcore5:5.3"
+ resolutionStrategy.force "org.apache.httpcomponents.core5:httpcore5-h2:5.3"
+ resolutionStrategy.force 'org.apache.httpcomponents:httpclient:4.5.14'
+ resolutionStrategy.force "com.google.guava:guava:32.1.3-jre"
+ resolutionStrategy.force 'org.eclipse.platform:org.eclipse.core.runtime:3.29.0'
+}
+
// see https://github.com/opensearch-project/OpenSearch/blob/0ba0e7cc26060f964fcbf6ee45bae53b3a9941d0/buildSrc/src/main/java/org/opensearch/gradle/precommit/DependencyLicensesTask.java
dependencyLicenses {
mapping from: /lucene-.*/, to: 'lucene'
@@ -187,19 +204,63 @@ testClusters.integTest {
plugin(project.tasks.bundlePlugin.archiveFile)
}
+tasks.named("check").configure { dependsOn(integTest) }
+
+integTest {
+ dependsOn "bundlePlugin"
+ systemProperty 'tests.security.manager', 'false'
+
+ systemProperty "https", System.getProperty("https")
+ systemProperty "user", System.getProperty("user")
+ systemProperty "password", System.getProperty("password")
+
+ // The --debug-jvm command-line option makes the cluster debuggable; this makes the tests debuggable
+ if (System.getProperty("test.debug") != null) {
+ jvmArgs '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005'
+ }
+}
+
+task integTestRemote(type: RestIntegTestTask) {
+ description = "Run integration tests from src/javaRestTest"
+ testClassesDirs = sourceSets.javaRestTest.output.classesDirs
+ classpath = sourceSets.javaRestTest.runtimeClasspath
+
+ systemProperty 'tests.security.manager', 'false'
+ systemProperty "https", System.getProperty("https")
+ systemProperty "user", System.getProperty("user")
+ systemProperty "password", System.getProperty("password")
+}
+
tasks.withType(Test).configureEach { task ->
- if (JavaVersion.current().compareTo(JavaVersion.VERSION_17) > 0 && JavaVersion.current().compareTo(JavaVersion.VERSION_21) < 0) {
- def policyFile = file("${projectDir}/src/main/plugin-metadata/plugin-security.policy").absolutePath
- task.jvmArgs += [
+ if (JavaVersion.current().compareTo(JavaVersion.VERSION_17) > 0 && JavaVersion.current().compareTo(JavaVersion.VERSION_21) < 0) {
+ def policyFile = file("${projectDir}/src/main/plugin-metadata/plugin-security.policy").absolutePath
+ task.jvmArgs += [
"--add-opens", "java.base/java.lang=ALL-UNNAMED",
"-Djava.security.manager",
"-Djava.security.policy=" + policyFile
- ]
- }
+ ]
+ }
}
-['forbiddenApisTest', 'testingConventions'].each { taskName ->
+['forbiddenApisTest', 'testingConventions', 'forbiddenApisJavaRestTest'].each { taskName ->
tasks.named(taskName).configure {
enabled = false
}
}
+
+tasks.named('dependencyLicenses') {
+ enabled = false
+}
+
+thirdPartyAudit {
+ ignoreViolations('org.conscrypt.Platform')
+}
+
+spotless {
+ java {
+ removeUnusedImports()
+ importOrder 'java', 'javax', 'org', 'com'
+
+ eclipse().configFile rootProject.file('.eclipseformat.xml')
+ }
+}
\ No newline at end of file
diff --git a/licenses/httpclient5-5.3.1.jar.sha1 b/licenses/httpclient5-5.3.1.jar.sha1
new file mode 100644
index 00000000..c8f32c1e
--- /dev/null
+++ b/licenses/httpclient5-5.3.1.jar.sha1
@@ -0,0 +1 @@
+56b53c8f4bcdaada801d311cf2ff8a24d6d96883
\ No newline at end of file
diff --git a/licenses/httpcore5-5.3.jar.sha1 b/licenses/httpcore5-5.3.jar.sha1
new file mode 100644
index 00000000..1721b75f
--- /dev/null
+++ b/licenses/httpcore5-5.3.jar.sha1
@@ -0,0 +1 @@
+a30e0b837732ac0e034c196dbdfcd8208d347a72
\ No newline at end of file
diff --git a/src/javaRestTest/java/com/o19s/es/ltr/LtrQueryClientYamlTestSuiteIT.java b/src/javaRestTest/java/com/o19s/es/ltr/LtrQueryClientYamlTestSuiteIT.java
index 1fe666e8..ad76f565 100644
--- a/src/javaRestTest/java/com/o19s/es/ltr/LtrQueryClientYamlTestSuiteIT.java
+++ b/src/javaRestTest/java/com/o19s/es/ltr/LtrQueryClientYamlTestSuiteIT.java
@@ -15,16 +15,48 @@
*/
package com.o19s.es.ltr;
-import com.carrotsearch.randomizedtesting.annotations.Name;
-import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+import static org.opensearch.client.RestClientBuilder.DEFAULT_MAX_CONN_PER_ROUTE;
+import static org.opensearch.client.RestClientBuilder.DEFAULT_MAX_CONN_TOTAL;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.stream.Collectors;
+
+import org.apache.hc.client5.http.auth.AuthScope;
+import org.apache.hc.client5.http.auth.UsernamePasswordCredentials;
+import org.apache.hc.client5.http.impl.auth.BasicCredentialsProvider;
+import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManager;
+import org.apache.hc.client5.http.impl.nio.PoolingAsyncClientConnectionManagerBuilder;
+import org.apache.hc.client5.http.ssl.ClientTlsStrategyBuilder;
+import org.apache.hc.client5.http.ssl.NoopHostnameVerifier;
+import org.apache.hc.core5.http.Header;
+import org.apache.hc.core5.http.HttpHost;
+import org.apache.hc.core5.http.message.BasicHeader;
+import org.apache.hc.core5.http.nio.ssl.TlsStrategy;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.util.Timeout;
+import org.junit.After;
+import org.opensearch.client.Request;
+import org.opensearch.client.Response;
+import org.opensearch.client.RestClient;
+import org.opensearch.client.RestClientBuilder;
+import org.opensearch.common.settings.Settings;
+import org.opensearch.common.unit.TimeValue;
+import org.opensearch.common.util.concurrent.ThreadContext;
+import org.opensearch.core.xcontent.DeprecationHandler;
+import org.opensearch.core.xcontent.MediaType;
+import org.opensearch.core.xcontent.NamedXContentRegistry;
+import org.opensearch.core.xcontent.XContentParser;
import org.opensearch.test.rest.yaml.ClientYamlTestCandidate;
import org.opensearch.test.rest.yaml.OpenSearchClientYamlSuiteTestCase;
+import com.carrotsearch.randomizedtesting.annotations.Name;
+import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
+
/**
* Created by doug on 12/30/16.
*/
public class LtrQueryClientYamlTestSuiteIT extends OpenSearchClientYamlSuiteTestCase {
-
public LtrQueryClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testCandidate) {
super(testCandidate);
}
@@ -33,4 +65,114 @@ public LtrQueryClientYamlTestSuiteIT(@Name("yaml") ClientYamlTestCandidate testC
public static Iterable