OpenSearch: [BUG] `./gradlew run` task is broken for plugins

Describe the bug The ./gradlew run task allows plugin developers to launch a test cluster with the plugin pre-installed. This allows for quick development and testing cycles. This worked fine until 7.9 but has been broken since 7.10, and therefore in OpenSearch.

Plugin developers end up having to manually configure the ‘run’ task in their build.gradle file to launch a test cluster with the required plugins (and extended plugins) pre-installed.

Issues

  1. The ‘run’ task doesn’t launch a test cluster.
  2. The test cluster launched by the ‘integTest’ task doesn’t have the plugin pre-installed.

To Reproduce

  1. Create a simple OpenSearch plugin. For convenience, clone this OpenSearch plugin template - https://github.com/ketanv3/opensearch-plugin-boilerplate
  2. In the project’s root directory, run ./gradlew run.
  3. Gradle will be stuck at the :run task but no cluster will be launched.

Expected behavior A test cluster should be launched with the plugin (and extended plugins) pre-installed.

  1. A new test cluster should be created and registered for the ‘run’ task.
  2. For the test clusters launched by ‘run’ and ‘integTest’ tasks, pre-install the bundled plugin ZIP.

Host/Environment

  • OS: Tested on macOS 11.2.3, Ubuntu 20.04.2 LTS
  • Version: 1.0.0-rc1

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

Hi, @AmiStrn !

This one fell through the cracks among other tasks. I’ll come up with a PR for this over the weekend. 😃

I believe I have identified where a fix needs to go.

  1. We need to create and register a new test cluster to be launched with the ‘run’ task. https://github.com/opensearch-project/OpenSearch/blob/4fff57014fd9ce6b0c65c36f07c87729fd9b43ca/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy#L136-L139

  2. Then we need to install the bundled plugin ZIP on the required test clusters. https://github.com/opensearch-project/OpenSearch/blob/4fff57014fd9ce6b0c65c36f07c87729fd9b43ca/buildSrc/src/main/groovy/org/opensearch/gradle/plugin/PluginBuildPlugin.groovy#L181-L185

I’ll try to come up with a fix for this.

@AmiStrn Also, a great blog post! I’ll take inspirations from the README file and make my plugin template friendlier to use 😃

@AmiStrn Thanks for your inputs! I’ll update this issue to explicitly call out that the plugins currently use a workaround to get the test clusters working.

You’re also right about the fact that the test clusters launched by the yaml-rest-tests have the plugin installed. I encountered this myself when I was building the Kotlin template plugin. This is because the YamlRestTestPlugin registers a RestIntegTestTask. When registering this task, the bundled plugin is also installed in this process as seen here.

Note that the JavaRestTestPlugin also registers a RestIntegTestTask, so it’ll also have the plugin installed.