From dc973d72ba90097c25dae90c7b6b383be1633cea 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 | 6 +++--- build.gradle | 2 +- src/test/java/org/opensearch/plugin/api/APIPluginIT.java | 9 ++++----- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 261c883..9e849d2 100644 --- a/README.md +++ b/README.md @@ -21,12 +21,12 @@ 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. ```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.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.zip -> Installed opensearch-api with folder name opensearch-api ``` -When you run OpenSeaerch with `./gradlew run` you should see the plugin loaded in the logs. +When you run OpenSearch with `./gradlew run` you should see the plugin loaded in the logs. ``` [2023-09-27T08:35:48,627][INFO ][o.o.p.PluginsService] [runTask-0] loaded plugin [opensearch-api] @@ -41,7 +41,7 @@ $ curl http://localhost:9200/_plugins/api ### 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 4284537..4b877d6 100644 --- a/build.gradle +++ b/build.gradle @@ -65,7 +65,7 @@ javadoc.enabled = false buildscript { ext { - opensearch_version = System.getProperty("opensearch.version", "3.0.0-SNAPSHOT") + opensearch_version = System.getProperty("opensearch.version", "2.12.0-SNAPSHOT") } repositories { 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);