From 75abb5b8a6b7b3cb9e54cd40c4afaa635fda2e87 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 2 Feb 2019 12:09:14 -0500 Subject: [PATCH] Adapt LLRest warning exception in FullClusterRestartIT (#38253) We now throw a WarningFailureException instead of ResponseException if there's any warning in a response. This change leads to the failures of testSnapshotRestore in the BWC builds for the last two days. Relates #37247 --- .../upgrades/FullClusterRestartIT.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index f9972559592..93b3354afdc 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -26,6 +26,7 @@ import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.RestClient; +import org.elasticsearch.client.WarningFailureException; import org.elasticsearch.client.WarningsHandler; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.common.Booleans; @@ -1059,15 +1060,19 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase { Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); client().performRequest(clearRoutingFromSettings); - } catch (ResponseException e) { - if (e.getResponse().hasWarnings() - && (isRunningAgainstOldCluster() == false || getOldClusterVersion().onOrAfter(Version.V_6_5_0))) { - e.getResponse().getWarnings().stream().forEach(warning -> { + } catch (WarningFailureException e) { + /* + * If this test is executed on the upgraded mode before testRemoteClusterSettingsUpgraded, + * we will hit a warning exception because we put some deprecated settings in that test. + */ + if (isRunningAgainstOldCluster() == false + && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().before(Version.V_6_5_0)) { + for (String warning : e.getResponse().getWarnings()) { assertThat(warning, containsString( - "setting was deprecated in Elasticsearch and will be removed in a future release! " + "setting was deprecated in Elasticsearch and will be removed in a future release! " + "See the breaking changes documentation for the next major version.")); assertThat(warning, startsWith("[search.remote.")); - }); + } } else { throw e; }