Skip to content

Commit 75abb5b

Browse files
authored
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
1 parent 50cdc61 commit 75abb5b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.elasticsearch.client.Response;
2727
import org.elasticsearch.client.ResponseException;
2828
import org.elasticsearch.client.RestClient;
29+
import org.elasticsearch.client.WarningFailureException;
2930
import org.elasticsearch.client.WarningsHandler;
3031
import org.elasticsearch.cluster.metadata.IndexMetaData;
3132
import org.elasticsearch.common.Booleans;
@@ -1059,15 +1060,19 @@ private void checkSnapshot(String snapshotName, int count, Version tookOnVersion
10591060
Request clearRoutingFromSettings = new Request("PUT", "/_cluster/settings");
10601061
clearRoutingFromSettings.setJsonEntity("{\"persistent\":{\"cluster.routing.allocation.exclude.test_attr\": null}}");
10611062
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()) {
10661071
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! "
10681073
+ "See the breaking changes documentation for the next major version."));
10691074
assertThat(warning, startsWith("[search.remote."));
1070-
});
1075+
}
10711076
} else {
10721077
throw e;
10731078
}

0 commit comments

Comments
 (0)