diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java index b5d26696a41f1..1e3d714fe186b 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -186,6 +186,11 @@ public void plugin(String pluginProjectPath) { nodes.all(each -> each.plugin(pluginProjectPath)); } + @Override + public void upgradePlugin(List> plugins) { + nodes.all(each -> each.upgradePlugin(plugins)); + } + @Override public void module(Provider module) { nodes.all(each -> each.module(module)); @@ -387,20 +392,27 @@ public void goToNextVersion() { writeUnicastHostsFiles(); } + public void upgradeAllNodesAndPluginsToNextVersion(List> plugins) { + stop(false); + nodes.all(OpenSearchNode::goToNextVersion); + upgradePlugin(plugins); + start(); + writeUnicastHostsFiles(); + } + public void fullRestart() { stop(false); start(); } public void nextNodeToNextVersion() { - if (nodeIndex + 1 > nodes.size()) { - throw new TestClustersException("Ran out of nodes to take to the next version"); - } - OpenSearchNode node = nodes.getByName(clusterName + "-" + nodeIndex); - node.stop(false); - node.goToNextVersion(); - commonNodeConfig(node, null, null); - nodeIndex += 1; + OpenSearchNode node = upgradeNodeToNextVersion(); + node.start(); + } + + public void upgradeNodeAndPluginToNextVersion(List> plugins) { + OpenSearchNode node = upgradeNodeToNextVersion(); + node.upgradePlugin(plugins); node.start(); } @@ -435,6 +447,18 @@ private void writeUnicastHostsFiles() { }); } + private OpenSearchNode upgradeNodeToNextVersion() { + if (nodeIndex + 1 > nodes.size()) { + throw new TestClustersException("Ran out of nodes to take to the next version"); + } + OpenSearchNode node = nodes.getByName(clusterName + "-" + nodeIndex); + node.stop(false); + node.goToNextVersion(); + commonNodeConfig(node, null, null); + nodeIndex += 1; + return node; + } + @Override @Internal public String getHttpSocketURI() { diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java index a06fc8aedf2fc..17f8d455f6a27 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchNode.java @@ -408,6 +408,14 @@ public void plugin(Provider plugin) { this.plugins.add(plugin.map(RegularFile::getAsFile)); } + @Override + public void upgradePlugin(List> plugins) { + this.plugins.clear(); + for (Provider plugin : plugins) { + this.plugins.add(plugin.map(RegularFile::getAsFile)); + } + } + @Override public void plugin(String pluginProjectPath) { plugin(maybeCreatePluginOrModuleDependency(pluginProjectPath)); diff --git a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java index 0204a59ccff88..a46e6ca876b35 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/TestClusterConfiguration.java @@ -59,6 +59,8 @@ public interface TestClusterConfiguration { void plugin(String pluginProjectPath); + void upgradePlugin(List> plugins); + void module(Provider module); void module(String moduleProjectPath);