Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bwc tests for plugins #1051

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ public void plugin(String pluginProjectPath) {
nodes.all(each -> each.plugin(pluginProjectPath));
}

@Override
public void upgradePlugin(List<Provider<RegularFile>> plugins) {
nodes.all(each -> each.upgradePlugin(plugins));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the only valid case for this function is during restart upgrades.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had to override it since it is added in interface TestClusterConfiguration.

}

@Override
public void module(Provider<RegularFile> module) {
nodes.all(each -> each.module(module));
Expand Down Expand Up @@ -387,20 +392,27 @@ public void goToNextVersion() {
writeUnicastHostsFiles();
}

public void upgradeAllNodesAndPluginsToNextVersion(List<Provider<RegularFile>> plugins) {
stop(false);
nodes.all(OpenSearchNode::goToNextVersion);
upgradePlugin(plugins);
start();
writeUnicastHostsFiles();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious: Do we need to writeUnicastHostFiles?
Unicast is used for discovery of cluster nodes, if the cluster has the same ports already published and written to unicast_host.txt and upgrading the nodes the new version, wouldnt the framework start the new version of OpenSearch with the same ports?

}

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<Provider<RegularFile>> plugins) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is nice. It works for rolling upgrade/mixed cluster cases where we upgrade node by node.
For full cluster restarts/restart upgrades we need another function to handle it for plugins.
Take a look at:

public void goToNextVersion() 

Minor nit: I wish we didn't duplicate it but I dont see another way too :/

Copy link
Collaborator Author

@VachaShah VachaShah Aug 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed that! I will add that method as well since we are adding bwc support. For the duplication, yeah I had to create a new method since the plugins have to be added before starting the node and this would otherwise affect OpenSearch bwc tests :/

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added support for full cluster restarts/restart upgrades. I have also tried to reduce duplication where possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, we should be able to leverage restart cluster infra for snapshot upgrades. Essentially its taking snapshot one old version, store it in a repo, restart the cluster to new version and restore the snapshot.
Lets open an issue to take care fo snapshot upgrades.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, opened an issue for tracking snapshot upgrade tests #1088.

OpenSearchNode node = upgradeNodeToNextVersion();
node.upgradePlugin(plugins);
node.start();
}

Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,14 @@ public void plugin(Provider<RegularFile> plugin) {
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
public void plugin(String pluginProjectPath) {
plugin(maybeCreatePluginOrModuleDependency(pluginProjectPath));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public interface TestClusterConfiguration {

void plugin(String pluginProjectPath);

void upgradePlugin(List<Provider<RegularFile>> plugins);

void module(Provider<RegularFile> module);

void module(String moduleProjectPath);
Expand Down