|
26 | 26 | import org.elasticsearch.client.Response; |
27 | 27 | import org.elasticsearch.client.ResponseException; |
28 | 28 | import org.elasticsearch.client.RestClient; |
| 29 | +import org.elasticsearch.client.WarningFailureException; |
29 | 30 | import org.elasticsearch.client.WarningsHandler; |
30 | 31 | import org.elasticsearch.cluster.metadata.IndexMetaData; |
31 | 32 | import org.elasticsearch.common.Booleans; |
@@ -1059,15 +1060,19 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion |
1059 | 1060 | Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings"); |
1060 | 1061 | clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}"); |
1061 | 1062 | client().performRequest(clearRoutingFromSettings); |
1062 | | - } catch (ResponseException e) { |
1063 | | - if (e.getResponse().hasWarnings() |
1064 | | - && (isRunningAgainstOldCluster() == false || getOldClusterVersion().onOrAfter(Version.V_6_5_0))) { |
1065 | | - e.getResponse().getWarnings().stream().forEach(warning -> { |
| 1063 | + } catch (WarningFailureException e) { |
| 1064 | + /* |
| 1065 | + * If this test is executed on the upgraded mode before testRemoteClusterSettingsUpgraded, |
| 1066 | + * we will hit a warning exception because we put some deprecated settings in that test. |
| 1067 | + */ |
| 1068 | + if (isRunningAgainstOldCluster() == false |
| 1069 | + && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().before(Version.V_6_5_0)) { |
| 1070 | + for (String warning : e.getResponse().getWarnings()) { |
1066 | 1071 | assertThat(warning, containsString( |
1067 | | - "setting was deprecated in Elasticsearch and will be removed in a future release! " |
| 1072 | + "setting was deprecated in Elasticsearch and will be removed in a future release! " |
1068 | 1073 | + "See the breaking changes documentation for the next major version.")); |
1069 | 1074 | assertThat(warning, startsWith("[search.remote.")); |
1070 | | - }); |
| 1075 | + } |
1071 | 1076 | } else { |
1072 | 1077 | throw e; |
1073 | 1078 | } |
|
0 commit comments