From 719b0c62247e0d0f6bb053e1b908e5143ddd61e7 Mon Sep 17 00:00:00 2001 From: Nhat Nguyen Date: Sat, 2 Feb 2019 03:08:45 -0500 Subject: [PATCH] Adapt LLRest warning exception in FullClusterRestartIT --- .../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 f997255959256..93b3354afdc82 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.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 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion 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; }