Skip to content

Commit

Permalink
Made small modifications to ESRestTestCase. (#70544)
Browse files Browse the repository at this point in the history
Backporting #70531 to the 7.12 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 #69973
  • Loading branch information
martijnvg committed Mar 18, 2021
1 parent de82200 commit a3cf281
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -615,12 +615,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 @@ -642,7 +642,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 @@ -662,7 +662,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 @@ -1421,13 +1421,15 @@ protected static boolean isXPackTemplate(String name) {
if (name.startsWith(".transform-")) {
return true;
}
if (name.startsWith(".deprecation-")) {
return true;
}
switch (name) {
case ".watches":
case "security_audit_log":
case ".slm-history":
case ".async-search":
case "saml-service-provider":
case "ilm-history":
case "logs":
case "logs-settings":
case "logs-mappings":
Expand All @@ -1438,7 +1440,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 "logstash-index-template":
case "security-index-template":
return true;
Expand Down

0 comments on commit a3cf281

Please sign in to comment.