Fix WatcherRestartIT.testWatcherRestart (#54237)

This commit adjusts testWatcherRestart to vary the template version number it
checks for based on the ES version being upgraded from, because the v11 template
is only installed on clusters with all nodes >=7.7.0.
This commit is contained in:
Gordon Brown 2020-03-26 08:12:15 -06:00 committed by GitHub
parent 8176f1c7f8
commit bbc6bc0299
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -22,8 +22,9 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase {
private static final Version UPGRADE_FROM_VERSION = private static final Version UPGRADE_FROM_VERSION =
Version.fromString(System.getProperty("tests.upgrade_from_version")); Version.fromString(System.getProperty("tests.upgrade_from_version"));
private static final String templatePrefix = ".watch-history-";
public void testWatcherRestart() throws Exception { public void testWatcherRestart() throws Exception {
assumeFalse("https://github.com/elastic/elasticsearch/issues/54220", UPGRADE_FROM_VERSION.onOrAfter(Version.V_7_7_0));
client().performRequest(new Request("POST", "/_watcher/_stop")); client().performRequest(new Request("POST", "/_watcher/_stop"));
ensureWatcherStopped(); ensureWatcherStopped();
@ -34,8 +35,14 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase {
} }
private void validateHistoryTemplate() throws Exception { private void validateHistoryTemplate() throws Exception {
// v7.7.0 contains a Watch history template (version 11) that can't be used unless all nodes in the cluster are >=7.7.0, so
// in a mixed cluster with some nodes <7.7.0 it will install template version 10, but if all nodes are <=7.7.0 template v11
// is used.
final String expectedMixedClusterTemplate = templatePrefix + (UPGRADE_FROM_VERSION.before(Version.V_7_7_0) ? "10" : "11");
final String expectedFinalTemplate = templatePrefix + "11";
if (ClusterType.MIXED == CLUSTER_TYPE) { if (ClusterType.MIXED == CLUSTER_TYPE) {
final Request request = new Request("HEAD", "/_template/.watch-history-10"); final Request request = new Request("HEAD", "/_template/" + expectedMixedClusterTemplate);
request.addParameter("include_type_name", "false"); request.addParameter("include_type_name", "false");
RequestOptions.Builder builder = request.getOptions().toBuilder(); RequestOptions.Builder builder = request.getOptions().toBuilder();
builder.setWarningsHandler(WarningsHandler.PERMISSIVE); builder.setWarningsHandler(WarningsHandler.PERMISSIVE);
@ -43,7 +50,7 @@ public class WatcherRestartIT extends AbstractUpgradeTestCase {
Response response = client().performRequest(request); Response response = client().performRequest(request);
assertThat(response.getStatusLine().getStatusCode(), is(200)); assertThat(response.getStatusLine().getStatusCode(), is(200));
} else if (ClusterType.UPGRADED == CLUSTER_TYPE) { } else if (ClusterType.UPGRADED == CLUSTER_TYPE) {
Response response = client().performRequest(new Request("HEAD", "/_template/.watch-history-11")); Response response = client().performRequest(new Request("HEAD", "/_template/" + expectedFinalTemplate));
assertThat(response.getStatusLine().getStatusCode(), is(200)); assertThat(response.getStatusLine().getStatusCode(), is(200));
} }
} }