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
This commit is contained in:
Nhat Nguyen 2019-02-02 12:09:14 -05:00 committed by GitHub
parent 50cdc61874
commit 75abb5b8a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;
}