[7.x] Be lenient when deleting index and component templates a… (#54538)

We previously checked for a 405 response, but on 7.x BWC tests may be hitting versions that don't
support the 405 response (returning 400 or 500), so be more lenient in those cases.

Relates to #54513
This commit is contained in:
Lee Hinman 2020-03-31 16:24:05 -06:00 committed by GitHub
parent 0f312c8b38
commit 987b6ecffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 10 deletions

View File

@ -582,11 +582,7 @@ public abstract class ESRestTestCase extends ESTestCase {
adminClient().performRequest(new Request("DELETE", "_index_template/*")); adminClient().performRequest(new Request("DELETE", "_index_template/*"));
adminClient().performRequest(new Request("DELETE", "_component_template/*")); adminClient().performRequest(new Request("DELETE", "_component_template/*"));
} catch (ResponseException e) { } catch (ResponseException e) {
if (e.getResponse().getStatusLine().getStatusCode() == 405 || e.getResponse().getStatusLine().getStatusCode() == 500) {
// We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore
} else {
throw e;
}
} }
} else { } else {
logger.debug("Clearing all templates"); logger.debug("Clearing all templates");
@ -595,11 +591,7 @@ public abstract class ESRestTestCase extends ESTestCase {
adminClient().performRequest(new Request("DELETE", "_index_template/*")); adminClient().performRequest(new Request("DELETE", "_index_template/*"));
adminClient().performRequest(new Request("DELETE", "_component_template/*")); adminClient().performRequest(new Request("DELETE", "_component_template/*"));
} catch (ResponseException e) { } catch (ResponseException e) {
if (e.getResponse().getStatusLine().getStatusCode() == 405 || e.getResponse().getStatusLine().getStatusCode() == 500) {
// We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore
} else {
throw e;
}
} }
} }
} }