Skip to content

Commit

Permalink
Adapt LLRest warning exception in FullClusterRestartIT (#38253)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
dnhatn authored Feb 2, 2019
1 parent 50cdc61 commit 75abb5b
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 75abb5b

Please sign in to comment.