From 8fc700c3ed0bd12de28d11421dd663002b6179b7 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 19 Jan 2024 16:57:38 -0500 Subject: [PATCH] Make the plugin compatible with 2.x. Signed-off-by: dblock --- README.md | 8 ++++---- build.gradle | 2 +- src/test/java/org/opensearch/plugin/api/APIPluginIT.java | 9 ++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index d30354e..cdf1905 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Build a distribution. ./gradlew assemble ``` -This produces `./build/distributions/opensearch-api-3.0.0.0-SNAPSHOT.zip`. +This produces `./build/distributions/opensearch-api-2.12.0.0-SNAPSHOT.zip`. ### Install @@ -21,7 +21,7 @@ Check out OpenSearch code, run it once with `./gradlew run`. Install the plugin, you may need to adjust `darwin-arm64-tar` below to your platform, and use the location of your plugin zip (mine is `~/source/opensearch-project/opensearch-api/dblock-opensearch-api`). ```sh -$ ./distribution/archives/darwin-arm64-tar/build/install/opensearch-3.0.0-SNAPSHOT/bin/opensearch-plugin install file:///Users/dblock/source/opensearch-project/opensearch-api/dblock-opensearch-api/build/distributions/opensearch-api-3.0.0.0-SNAPSHOT.zip +$ ./distribution/archives/darwin-arm64-tar/build/install/opensearch-2.12.0-SNAPSHOT/bin/opensearch-plugin install file:///Users/dblock/source/opensearch-project/opensearch-api/dblock-opensearch-api/build/distributions/opensearch-api-2.12.0.0-SNAPSHOT.zip -> Installed opensearch-api with folder name opensearch-api ``` @@ -46,7 +46,7 @@ Returns an OpenAPI spec. "info": { "title": "opensearch", "description": "The OpenSearch Project: https://opensearch.org/", - "version": "3.0.0-SNAPSHOT" + "version": "2.12.0-SNAPSHOT" }, ... } @@ -55,7 +55,7 @@ Returns an OpenAPI spec. ### Uninstall ```sh -./distribution/archives/darwin-arm64-tar/build/install/opensearch-3.0.0-SNAPSHOT/bin/opensearch-plugin remove opensearch-api +./distribution/archives/darwin-arm64-tar/build/install/opensearch-2.12.0-SNAPSHOT/bin/opensearch-plugin remove opensearch-api -> removing [opensearch-api]... ``` diff --git a/build.gradle b/build.gradle index b44d492..00cd829 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ def pluginClassName = 'APIPlugin' buildscript { ext { - opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") + opensearch_version = System.getProperty("opensearch.version", "2.12.0-SNAPSHOT") isSnapshot = "true" == System.getProperty("build.snapshot", "true") } diff --git a/src/test/java/org/opensearch/plugin/api/APIPluginIT.java b/src/test/java/org/opensearch/plugin/api/APIPluginIT.java index ae836c9..5c70aff 100644 --- a/src/test/java/org/opensearch/plugin/api/APIPluginIT.java +++ b/src/test/java/org/opensearch/plugin/api/APIPluginIT.java @@ -9,8 +9,7 @@ import com.carrotsearch.randomizedtesting.annotations.ThreadLeakScope; -import org.apache.hc.core5.http.ParseException; -import org.apache.hc.core5.http.io.entity.EntityUtils; +import org.apache.http.util.EntityUtils; import org.opensearch.client.Request; import org.opensearch.client.Response; import org.opensearch.plugins.Plugin; @@ -30,15 +29,15 @@ protected Collection> nodePlugins() { return Collections.singletonList(APIPlugin.class); } - public void testPluginInstalled() throws IOException, ParseException { + public void testPluginInstalled() throws IOException { Response response = getRestClient().performRequest(new Request("GET", "/_cat/plugins")); String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); - logger.info("response body: {}", body.toString()); + logger.info("response body: {}", body); assertTrue(body.contains("api")); } - public void testPluginGetAPI() throws IOException, ParseException { + public void testPluginGetAPI() throws IOException { Response response = getRestClient().performRequest(new Request("GET", "/_plugins/api")); String body = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); logger.info("response body: {}", body);