Skip to content

Commit

Permalink
Make the plugin compatible with 2.x.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Jan 19, 2024
1 parent 23bd5c1 commit dc973d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]...
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions src/test/java/org/opensearch/plugin/api/APIPluginIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,15 +29,15 @@ protected Collection<Class<? extends Plugin>> 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);
Expand Down

0 comments on commit dc973d7

Please sign in to comment.