Support for bwc tests for plugins (#1051)

* Support for bwc tests for plugins

Signed-off-by: Vacha <vachshah@amazon.com>

* Adding support for restart upgrades for plugins bwc

Signed-off-by: Vacha <vachshah@amazon.com>
This commit is contained in:
Vacha 2021-08-12 13:28:08 -07:00 committed by GitHub
parent af6fbc77eb
commit 072ccda932
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 8 deletions

View File

@ -186,6 +186,11 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
nodes.all(each -> each.plugin(pluginProjectPath)); nodes.all(each -> each.plugin(pluginProjectPath));
} }
@Override
public void upgradePlugin(List<Provider<RegularFile>> plugins) {
nodes.all(each -> each.upgradePlugin(plugins));
}
@Override @Override
public void module(Provider<RegularFile> module) { public void module(Provider<RegularFile> module) {
nodes.all(each -> each.module(module)); nodes.all(each -> each.module(module));
@ -387,20 +392,27 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
writeUnicastHostsFiles(); writeUnicastHostsFiles();
} }
public void upgradeAllNodesAndPluginsToNextVersion(List<Provider<RegularFile>> plugins) {
stop(false);
nodes.all(OpenSearchNode::goToNextVersion);
upgradePlugin(plugins);
start();
writeUnicastHostsFiles();
}
public void fullRestart() { public void fullRestart() {
stop(false); stop(false);
start(); start();
} }
public void nextNodeToNextVersion() { public void nextNodeToNextVersion() {
if (nodeIndex + 1 > nodes.size()) { OpenSearchNode node = upgradeNodeToNextVersion();
throw new TestClustersException("Ran out of nodes to take to the next version"); node.start();
} }
OpenSearchNode node = nodes.getByName(clusterName + "-" + nodeIndex);
node.stop(false); public void upgradeNodeAndPluginToNextVersion(List<Provider<RegularFile>> plugins) {
node.goToNextVersion(); OpenSearchNode node = upgradeNodeToNextVersion();
commonNodeConfig(node, null, null); node.upgradePlugin(plugins);
nodeIndex += 1;
node.start(); node.start();
} }
@ -435,6 +447,18 @@ public class OpenSearchCluster implements TestClusterConfiguration, Named {
}); });
} }
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 @Override
@Internal @Internal
public String getHttpSocketURI() { public String getHttpSocketURI() {

View File

@ -408,6 +408,14 @@ public class OpenSearchNode implements TestClusterConfiguration {
this.plugins.add(plugin.map(RegularFile::getAsFile)); this.plugins.add(plugin.map(RegularFile::getAsFile));
} }
@Override
public void upgradePlugin(List<Provider<RegularFile>> plugins) {
this.plugins.clear();
for (Provider<RegularFile> plugin : plugins) {
this.plugins.add(plugin.map(RegularFile::getAsFile));
}
}
@Override @Override
public void plugin(String pluginProjectPath) { public void plugin(String pluginProjectPath) {
plugin(maybeCreatePluginOrModuleDependency(pluginProjectPath)); plugin(maybeCreatePluginOrModuleDependency(pluginProjectPath));

View File

@ -59,6 +59,8 @@ public interface TestClusterConfiguration {
void plugin(String pluginProjectPath); void plugin(String pluginProjectPath);
void upgradePlugin(List<Provider<RegularFile>> plugins);
void module(Provider<RegularFile> module); void module(Provider<RegularFile> module);
void module(String moduleProjectPath); void module(String moduleProjectPath);