Skip to content

Commit

Permalink
Made small modifications to ESRestTestCase.
Browse files Browse the repository at this point in the history
Backporting elastic#70531 to the 7.11 branch.

* Don't try to invoke delete component/index templates APIs if there are no templates to delete.
* Don't delete deprecation templates by marking these as xpack templates.

Relates to elastic#69973
  • Loading branch information
martijnvg committed Mar 18, 2021
1 parent 314cc0a commit 6b5cfc2
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,12 @@ private void wipeCluster() throws Exception {
.collect(Collectors.toList());
for (String name : names) {
if (isXPackTemplate(name)) {
continue;
continue;
}
try {
adminClient().performRequest(new Request("DELETE", "_index_template/" + name));
} catch (ResponseException e) {
logger.debug(new ParameterizedMessage("unable to remove index template {}", name), e);
try {
adminClient().performRequest(new Request("DELETE", "_index_template/" + name));
} catch (ResponseException e) {
logger.warn(new ParameterizedMessage("unable to remove index template {}", name), e);
}
}
} catch (Exception e) {
Expand All @@ -640,7 +640,7 @@ private void wipeCluster() throws Exception {
}
adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate));
} catch (ResponseException e) {
logger.debug(new ParameterizedMessage("unable to remove component template {}", componentTemplate), e);
logger.warn(new ParameterizedMessage("unable to remove component template {}", componentTemplate), e);
}
}
} catch (Exception e) {
Expand All @@ -660,7 +660,7 @@ private void wipeCluster() throws Exception {
try {
adminClient().performRequest(new Request("DELETE", "_template/" + name));
} catch (ResponseException e) {
logger.debug(new ParameterizedMessage("unable to remove index template {}", name), e);
logger.warn(new ParameterizedMessage("unable to remove index template {}", name), e);
}
}
} else {
Expand Down Expand Up @@ -1397,6 +1397,9 @@ protected static boolean isXPackTemplate(String name) {
if (name.startsWith(".transform-")) {
return true;
}
if (name.startsWith(".deprecation-")) {
return true;
}
switch (name) {
case ".watches":
case "logstash-index-template":
Expand All @@ -1405,7 +1408,6 @@ protected static boolean isXPackTemplate(String name) {
case ".slm-history":
case ".async-search":
case "saml-service-provider":
case "ilm-history":
case "logs":
case "logs-settings":
case "logs-mappings":
Expand All @@ -1416,7 +1418,7 @@ protected static boolean isXPackTemplate(String name) {
case "synthetics-settings":
case "synthetics-mappings":
case ".snapshot-blob-cache":
case ".deprecation-indexing-template":
case "ilm-history":
case "security-index-template":
return true;
default:
Expand Down

0 comments on commit 6b5cfc2

Please sign in to comment.