diff --git a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java index 4c2e114a84f92..ff47d5ce94292 100644 --- a/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java +++ b/buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/ElasticsearchNode.java @@ -1213,10 +1213,6 @@ private void createConfiguration() { // Don't wait for state, just start up quickly. This will also allow new and old nodes in the BWC case to become the master baseConfig.put("discovery.initial_state_timeout", "0s"); - // TODO: Remove these once https://github.com/elastic/elasticsearch/issues/46091 is fixed - baseConfig.put("logger.org.elasticsearch.action.support.master", "DEBUG"); - baseConfig.put("logger.org.elasticsearch.cluster.coordination", "DEBUG"); - HashSet overriden = new HashSet<>(baseConfig.keySet()); overriden.retainAll(settings.keySet()); overriden.removeAll(OVERRIDABLE_SETTINGS); diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index fd349c75228c5..6245a25536540 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -602,58 +602,63 @@ private void wipeCluster() throws Exception { * slows down the test because xpack will just recreate * them. */ - try { - Request getTemplatesRequest = new Request("GET", "_index_template"); - getTemplatesRequest.setOptions(allowTypesRemovalWarnings()); - Map composableIndexTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, - EntityUtils.toString(adminClient().performRequest(getTemplatesRequest).getEntity()), false); - List names = ((List) composableIndexTemplates.get("index_templates")).stream() - .map(ct -> (String) ((Map) ct).get("name")) - .filter(name -> isXPackTemplate(name) == false) - .collect(Collectors.toList()); - // Ideally we would want to check the version of the elected master node and - // send the delete request directly to that node. - if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) { - try { - adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names))); - } catch (ResponseException e) { - logger.debug(new ParameterizedMessage("unable to remove multiple composable index template {}", names), e); - } - } else { - for (String name : names) { + // In case of bwc testing, if all nodes are before 7.7.0 then no need to attempt to delete component and composable + // index templates, because these were introduced in 7.7.0: + if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_7_0))) { + try { + Request getTemplatesRequest = new Request("GET", "_index_template"); + getTemplatesRequest.setOptions(allowTypesRemovalWarnings()); + Map composableIndexTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, + EntityUtils.toString(adminClient().performRequest(getTemplatesRequest).getEntity()), false); + List names = ((List) composableIndexTemplates.get("index_templates")).stream() + .map(ct -> (String) ((Map) ct).get("name")) + .filter(name -> isXPackTemplate(name) == false) + .collect(Collectors.toList()); + // Ideally we would want to check the version of the elected master node and + // send the delete request directly to that node. + if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_13_0))) { try { - adminClient().performRequest(new Request("DELETE", "_index_template/" + name)); + adminClient().performRequest(new Request("DELETE", "_index_template/" + String.join(",", names))); } catch (ResponseException e) { - logger.debug(new ParameterizedMessage("unable to remove composable index template {}", name), e); + logger.debug(new ParameterizedMessage("unable to remove multiple composable index template {}", names), e); + } + } else { + for (String name : names) { + try { + adminClient().performRequest(new Request("DELETE", "_index_template/" + name)); + } catch (ResponseException e) { + logger.debug(new ParameterizedMessage("unable to remove composable index template {}", name), e); + } } } + } catch (Exception e) { + logger.debug("ignoring exception removing all composable index templates", e); + // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore } - } catch (Exception e) { - logger.debug("ignoring exception removing all composable index templates", e); - // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore - } - try { - Request compReq = new Request("GET", "_component_template"); - compReq.setOptions(allowTypesRemovalWarnings()); - String componentTemplates = EntityUtils.toString(adminClient().performRequest(compReq).getEntity()); - Map cTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, componentTemplates, false); - List names = ((List) cTemplates.get("component_templates")).stream() - .map(ct -> (String) ((Map) ct).get("name")) - .collect(Collectors.toList()); - for (String componentTemplate : names) { - try { - if (isXPackTemplate(componentTemplate)) { - continue; + try { + Request compReq = new Request("GET", "_component_template"); + compReq.setOptions(allowTypesRemovalWarnings()); + String componentTemplates = EntityUtils.toString(adminClient().performRequest(compReq).getEntity()); + Map cTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, componentTemplates, false); + List names = ((List) cTemplates.get("component_templates")).stream() + .map(ct -> (String) ((Map) ct).get("name")) + .collect(Collectors.toList()); + for (String componentTemplate : names) { + try { + if (isXPackTemplate(componentTemplate)) { + continue; + } + adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate)); + } catch (ResponseException e) { + logger.debug(new ParameterizedMessage("unable to remove component template {}", componentTemplate), e); } - adminClient().performRequest(new Request("DELETE", "_component_template/" + componentTemplate)); - } catch (ResponseException e) { - logger.debug(new ParameterizedMessage("unable to remove component template {}", componentTemplate), e); } + } catch (Exception e) { + logger.debug("ignoring exception removing all component templates", e); + // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore } - } catch (Exception e) { - logger.debug("ignoring exception removing all component templates", e); - // We hit a version of ES that doesn't support index templates v2 yet, so it's safe to ignore } + // Always check for legacy templates: Request getLegacyTemplatesRequest = new Request("GET", "_template"); getLegacyTemplatesRequest.setOptions(allowTypesRemovalWarnings()); Map legacyTemplates = XContentHelper.convertToMap(JsonXContent.jsonXContent, @@ -730,7 +735,7 @@ protected static void wipeAllIndices() throws IOException { protected static void wipeDataStreams() throws IOException { try { - if (hasXPack()) { + if (hasXPack() && nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_7_9_0))) { adminClient().performRequest(new Request("DELETE", "_data_stream/*?expand_wildcards=all")); } } catch (ResponseException e) { @@ -1442,6 +1447,8 @@ protected static boolean isXPackTemplate(String name) { case "synthetics-mappings": case ".snapshot-blob-cache": case ".deprecation-indexing-template": + case "logstash-index-template": + case "security-index-template": return true; default: return false;