From e616879313445edcc010eed2bfe1555b0282d4ee Mon Sep 17 00:00:00 2001 From: Vacha Date: Thu, 5 Aug 2021 11:38:16 -0700 Subject: [PATCH 1/2] Support for bwc tests for plugins Signed-off-by: Vacha --- .../gradle/testclusters/OpenSearchCluster.java | 18 ++++++++++++++++++ .../gradle/testclusters/OpenSearchNode.java | 8 ++++++++ .../testclusters/TestClusterConfiguration.java | 2 ++ 3 files changed, 28 insertions(+) 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..0c46769e10aed 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)); @@ -404,6 +409,19 @@ public void nextNodeToNextVersion() { node.start(); } + public void upgradeNodeAndPluginToNextVersion(List> plugins) { + 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; + node.upgradePlugin(plugins); + node.start(); + } + @Override public void extraConfigFile(String destination, File from) { nodes.all(node -> node.extraConfigFile(destination, from)); 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); From 7216b78089f1be17536ecc04a4a5f3bd9405e1c0 Mon Sep 17 00:00:00 2001 From: Vacha Date: Tue, 10 Aug 2021 14:09:24 -0700 Subject: [PATCH 2/2] Adding support for restart upgrades for plugins bwc Signed-off-by: Vacha --- .../testclusters/OpenSearchCluster.java | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) 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 0c46769e10aed..1e3d714fe186b 100644 --- a/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java +++ b/buildSrc/src/main/java/org/opensearch/gradle/testclusters/OpenSearchCluster.java @@ -392,32 +392,26 @@ 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) { - 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.upgradePlugin(plugins); node.start(); } @@ -453,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() {