diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java index bfa1bcd34749f..f7e2f3d0d6c30 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionArchiveSetupPlugin.java @@ -76,12 +76,14 @@ private void registerAndConfigureDistributionArchivesExtension(Project project) sub.getArtifacts().add(DEFAULT_CONFIGURATION_NAME, distributionArchive.getArchiveTask()); var extractedConfiguration = sub.getConfigurations().create(EXTRACTED_CONFIGURATION_NAME); extractedConfiguration.setCanBeResolved(false); + extractedConfiguration.setCanBeConsumed(true); extractedConfiguration.getAttributes() .attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); sub.getArtifacts().add(EXTRACTED_CONFIGURATION_NAME, distributionArchive.getExpandedDistTask()); // The "composite" configuration is specifically used for resolving transformed artifacts in an included build var compositeConfiguration = sub.getConfigurations().create(COMPOSITE_CONFIGURATION_NAME); compositeConfiguration.setCanBeResolved(false); + compositeConfiguration.setCanBeConsumed(true); compositeConfiguration.getAttributes() .attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); compositeConfiguration.getAttributes().attribute(Attribute.of("composite", Boolean.class), true); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java index 564bc44ab5d8b..7e3e8bd458c92 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/RestrictedBuildApiService.java @@ -53,8 +53,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":plugins:repository-hdfs"); map.put(LegacyRestTestBasePlugin.class, ":plugins:store-smb"); map.put(LegacyRestTestBasePlugin.class, ":qa:ccs-rolling-upgrade-remote-cluster"); - map.put(LegacyRestTestBasePlugin.class, ":qa:ccs-unavailable-clusters"); - map.put(LegacyRestTestBasePlugin.class, ":qa:logging-config"); map.put(LegacyRestTestBasePlugin.class, ":qa:mixed-cluster"); map.put(LegacyRestTestBasePlugin.class, ":qa:multi-cluster-search"); map.put(LegacyRestTestBasePlugin.class, ":qa:remote-clusters"); @@ -65,7 +63,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-ingest-with-all-dependencies"); map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-plugins"); map.put(LegacyRestTestBasePlugin.class, ":qa:system-indices"); - map.put(LegacyRestTestBasePlugin.class, ":qa:unconfigured-node-name"); map.put(LegacyRestTestBasePlugin.class, ":qa:verify-version-constants"); map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-apm-integration"); map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-delayed-aggs"); @@ -73,7 +70,6 @@ private static ListMultimap, String> createLegacyRestTestBasePluginUsag map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-error-query"); map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-latency-simulating-directory"); map.put(LegacyRestTestBasePlugin.class, ":test:yaml-rest-runner"); - map.put(LegacyRestTestBasePlugin.class, ":distribution:archives:integ-test-zip"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:core"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search"); map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet"); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java index fbcfcb8202104..777a6d931e50e 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java @@ -18,7 +18,7 @@ import org.elasticsearch.gradle.Version; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes; -import org.elasticsearch.gradle.internal.ElasticsearchJavaPlugin; +import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin; import org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin; import org.elasticsearch.gradle.internal.info.BuildParams; import org.elasticsearch.gradle.internal.test.ErrorReportingTestListener; @@ -90,7 +90,7 @@ public RestTestBasePlugin(ProviderFactory providerFactory) { @Override public void apply(Project project) { - project.getPluginManager().apply(ElasticsearchJavaPlugin.class); + project.getPluginManager().apply(ElasticsearchJavaBasePlugin.class); project.getPluginManager().apply(InternalDistributionDownloadPlugin.class); // Register integ-test and default distributions diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java index fe4d7148e18d6..4c7290457e7df 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/DistributionDownloadPlugin.java @@ -89,7 +89,9 @@ public void apply(Project project) { private void setupDistributionContainer(Project project) { distributionsContainer = project.container(ElasticsearchDistribution.class, name -> { var fileConfiguration = project.getConfigurations().create(DISTRO_CONFIG_PREFIX + name); + fileConfiguration.setCanBeConsumed(false); var extractedConfiguration = project.getConfigurations().create(DISTRO_EXTRACTED_CONFIG_PREFIX + name); + extractedConfiguration.setCanBeConsumed(false); extractedConfiguration.getAttributes() .attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, ArtifactTypeDefinition.DIRECTORY_TYPE); var distribution = new ElasticsearchDistribution( diff --git a/distribution/archives/integ-test-zip/build.gradle b/distribution/archives/integ-test-zip/build.gradle index 4a5e0eb0b59b3..6fbb73cf64aad 100644 --- a/distribution/archives/integ-test-zip/build.gradle +++ b/distribution/archives/integ-test-zip/build.gradle @@ -9,7 +9,7 @@ import org.apache.tools.ant.filters.ReplaceTokens -apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' // The integ-test-distribution is published to maven apply plugin: 'elasticsearch.publish' @@ -35,19 +35,3 @@ publishing { } } } - -tasks.named("javaRestTest").configure { - dependsOn "assemble" - /* - * There are two unique things going on here: - * 1. These tests can be run against an external cluster with - * -Dtests.rest.cluster=whatever and -Dtest.cluster=whatever - * 2. *One* of these tests is incompatible with that and should be skipped - * when running against an external cluster. - */ - if (project.providers.systemProperty("tests.rest.cluster").isPresent()) { - nonInputProperties.systemProperty 'tests.logfile', testClusters.named('javaRestTest').map(c -> c.singleNode().serverLog) - } else { - systemProperty 'tests.logfile', '--external--' - } -} diff --git a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java index eea049c433c07..b28f7c020be53 100644 --- a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java +++ b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/CreatedLocationHeaderIT.java @@ -11,6 +11,8 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.Response; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.junit.ClassRule; import java.io.IOException; @@ -23,6 +25,14 @@ */ public class CreatedLocationHeaderIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + public void testCreate() throws IOException { locationTestCase("PUT", "test/_doc/1"); } diff --git a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/JsonLogsFormatAndParseIT.java b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/JsonLogsFormatAndParseIT.java index 47bdf1b425684..aef7a876ffadf 100644 --- a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/JsonLogsFormatAndParseIT.java +++ b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/JsonLogsFormatAndParseIT.java @@ -10,36 +10,36 @@ package org.elasticsearch.test.rest; import org.elasticsearch.common.logging.JsonLogsIntegTestCase; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.LogType; import org.hamcrest.Matcher; +import org.junit.ClassRule; -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.AccessController; -import java.security.PrivilegedAction; +import java.io.InputStream; import static org.hamcrest.Matchers.is; public class JsonLogsFormatAndParseIT extends JsonLogsIntegTestCase { + + private static final String NODE_NAME = "test-node-0"; + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .withNode(localNodeSpecBuilder -> localNodeSpecBuilder.name(NODE_NAME)) + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + @Override protected Matcher nodeNameMatcher() { - return is("integTest-0"); + return is(NODE_NAME); } @Override - protected BufferedReader openReader(Path logFile) { - assumeFalse( - "Skipping test because it is being run against an external cluster.", - logFile.getFileName().toString().equals("--external--") - ); - return AccessController.doPrivileged((PrivilegedAction) () -> { - try { - return Files.newBufferedReader(logFile, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + protected InputStream openLogsStream() { + return cluster.getNodeLog(0, LogType.SERVER_JSON); } } diff --git a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/NodeRestUsageIT.java b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/NodeRestUsageIT.java index 461c23e91ccd2..17bdf2a748bd7 100644 --- a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/NodeRestUsageIT.java +++ b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/NodeRestUsageIT.java @@ -15,6 +15,8 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.builder.SearchSourceBuilder; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.junit.ClassRule; import java.io.IOException; import java.util.Collections; @@ -28,6 +30,14 @@ public class NodeRestUsageIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + @SuppressWarnings("unchecked") public void testWithRestUsage() throws IOException { // First get the current usage figures diff --git a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java index 8732110bb1937..abb92ebad9d52 100644 --- a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java +++ b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/RequestsWithoutContentIT.java @@ -11,6 +11,8 @@ import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.junit.ClassRule; import java.io.IOException; @@ -18,6 +20,14 @@ public class RequestsWithoutContentIT extends ESRestTestCase { + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + public void testIndexMissingBody() throws IOException { ResponseException responseException = expectThrows( ResponseException.class, diff --git a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/WaitForRefreshAndCloseIT.java b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/WaitForRefreshAndCloseIT.java index 285ba29848a2a..37efc2d7f2b43 100644 --- a/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/WaitForRefreshAndCloseIT.java +++ b/distribution/archives/integ-test-zip/src/javaRestTest/java/org/elasticsearch/test/rest/WaitForRefreshAndCloseIT.java @@ -17,8 +17,10 @@ import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.client.ResponseListener; +import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.junit.After; import org.junit.Before; +import org.junit.ClassRule; import java.io.IOException; import java.util.Map; @@ -32,6 +34,15 @@ * Tests that wait for refresh is fired if the index is closed. */ public class WaitForRefreshAndCloseIT extends ESRestTestCase { + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local().build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + @Before public void setupIndex() throws IOException { Request request = new Request("PUT", "/test"); diff --git a/docs/reference/esql/functions/examples/median_absolute_deviation.asciidoc b/docs/reference/esql/functions/examples/median_absolute_deviation.asciidoc index 9084c008e890a..cfd3d0a9159aa 100644 --- a/docs/reference/esql/functions/examples/median_absolute_deviation.asciidoc +++ b/docs/reference/esql/functions/examples/median_absolute_deviation.asciidoc @@ -10,7 +10,7 @@ include::{esql-specs}/median_absolute_deviation.csv-spec[tag=median-absolute-dev |=== include::{esql-specs}/median_absolute_deviation.csv-spec[tag=median-absolute-deviation-result] |=== -The expression can use inline functions. For example, to calculate the the median absolute deviation of the maximum values of a multivalued column, first use `MV_MAX` to get the maximum value per row, and use the result with the `MEDIAN_ABSOLUTE_DEVIATION` function +The expression can use inline functions. For example, to calculate the median absolute deviation of the maximum values of a multivalued column, first use `MV_MAX` to get the maximum value per row, and use the result with the `MEDIAN_ABSOLUTE_DEVIATION` function [source.merge.styled,esql] ---- include::{esql-specs}/median_absolute_deviation.csv-spec[tag=docsStatsMADNestedExpression] diff --git a/docs/reference/landing-page.asciidoc b/docs/reference/landing-page.asciidoc index 1f2145a3aae82..6449a799ffd16 100644 --- a/docs/reference/landing-page.asciidoc +++ b/docs/reference/landing-page.asciidoc @@ -79,6 +79,11 @@

Get to know Elasticsearch

+

+Demos: + Hands-on learning for Search +

+

New webinar: Architect search apps with Google Cloud diff --git a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IngestGeoIpPlugin.java b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IngestGeoIpPlugin.java index 3107f0bed55e8..a09069dcf438f 100644 --- a/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IngestGeoIpPlugin.java +++ b/modules/ingest-geoip/src/main/java/org/elasticsearch/ingest/geoip/IngestGeoIpPlugin.java @@ -275,7 +275,6 @@ public Collection getSystemIndexDescriptors(Settings sett .build() ) .setOrigin(INGEST_ORIGIN) - .setVersionMetaKey("version") .setPrimaryIndex(DATABASES_INDEX) .setNetNew() .build(); diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java index 4b21db497ead7..ea1c8ade00abe 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java @@ -78,7 +78,6 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase .setType(SystemIndexDescriptor.Type.EXTERNAL_UNMANAGED) .setOrigin(ORIGIN) .setAllowedElasticProductOrigins(Collections.singletonList(ORIGIN)) - .setMinimumNodeVersion(NEEDS_UPGRADE_VERSION) .setPriorSystemIndexDescriptors(Collections.emptyList()) .build(); static final SystemIndexDescriptor INTERNAL_UNMANAGED = SystemIndexDescriptor.builder() @@ -86,7 +85,6 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase .setType(SystemIndexDescriptor.Type.INTERNAL_UNMANAGED) .setOrigin(ORIGIN) .setAllowedElasticProductOrigins(Collections.emptyList()) - .setMinimumNodeVersion(NEEDS_UPGRADE_VERSION) .setPriorSystemIndexDescriptors(Collections.emptyList()) .build(); @@ -98,9 +96,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase .setSettings(createSettings(NEEDS_UPGRADE_INDEX_VERSION, INTERNAL_MANAGED_FLAG_VALUE)) .setMappings(createMapping(true, true)) .setOrigin(ORIGIN) - .setVersionMetaKey(VERSION_META_KEY) .setAllowedElasticProductOrigins(Collections.emptyList()) - .setMinimumNodeVersion(NEEDS_UPGRADE_VERSION) .setPriorSystemIndexDescriptors(Collections.emptyList()) .build(); static final int INTERNAL_UNMANAGED_FLAG_VALUE = 2; @@ -113,9 +109,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase .setSettings(createSettings(NEEDS_UPGRADE_INDEX_VERSION, EXTERNAL_MANAGED_FLAG_VALUE)) .setMappings(createMapping(true, false)) .setOrigin(ORIGIN) - .setVersionMetaKey(VERSION_META_KEY) .setAllowedElasticProductOrigins(Collections.singletonList(ORIGIN)) - .setMinimumNodeVersion(NEEDS_UPGRADE_VERSION) .setPriorSystemIndexDescriptors(Collections.emptyList()) .build(); static final int EXTERNAL_UNMANAGED_FLAG_VALUE = 4; @@ -128,7 +122,6 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase .setType(SystemIndexDescriptor.Type.EXTERNAL_UNMANAGED) .setAllowedElasticProductOrigins(Collections.emptyList()) .setAllowedElasticProductOrigins(Collections.singletonList(ORIGIN)) - .setMinimumNodeVersion(NEEDS_UPGRADE_VERSION) .setPriorSystemIndexDescriptors(Collections.emptyList()) .setAllowsTemplates() .build(); diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java index 4fcd061f421aa..1ee5519593569 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/MultiFeatureMigrationIT.java @@ -10,7 +10,6 @@ package org.elasticsearch.migration; import org.apache.lucene.util.SetOnce; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusAction; import org.elasticsearch.action.admin.cluster.migration.GetFeatureUpgradeStatusRequest; @@ -268,9 +267,7 @@ public void testMultipleFeatureMigration() throws Exception { .setSettings(createSettings(IndexVersions.MINIMUM_COMPATIBLE, 0)) .setMappings(createMapping(true, true)) .setOrigin(ORIGIN) - .setVersionMetaKey(VERSION_META_KEY) .setAllowedElasticProductOrigins(Collections.emptyList()) - .setMinimumNodeVersion(Version.CURRENT.minimumCompatibilityVersion()) .setPriorSystemIndexDescriptors(Collections.emptyList()) .build(); diff --git a/muted-tests.yml b/muted-tests.yml index 68ab8eb37a600..c781a7d30a597 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -1,7 +1,4 @@ tests: -- class: "org.elasticsearch.upgrades.SearchStatesIT" - issue: "https://github.com/elastic/elasticsearch/issues/108991" - method: "testCanMatch" - class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT method: test {yaml=reference/esql/esql-async-query-api/line_17} issue: https://github.com/elastic/elasticsearch/issues/109260 @@ -231,9 +228,6 @@ tests: - class: org.elasticsearch.xpack.restart.MLModelDeploymentFullClusterRestartIT method: testDeploymentSurvivesRestart {cluster=UPGRADED} issue: https://github.com/elastic/elasticsearch/issues/115528 -- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT - method: test {yaml=reference/esql/esql-across-clusters/line_197} - issue: https://github.com/elastic/elasticsearch/issues/115575 - class: org.elasticsearch.oldrepos.OldRepositoryAccessIT method: testOldRepoAccess issue: https://github.com/elastic/elasticsearch/issues/115631 @@ -290,6 +284,9 @@ tests: - class: org.elasticsearch.index.reindex.ReindexNodeShutdownIT method: testReindexWithShutdown issue: https://github.com/elastic/elasticsearch/issues/115996 +- class: org.elasticsearch.search.query.SearchQueryIT + method: testAllDocsQueryString + issue: https://github.com/elastic/elasticsearch/issues/115728 # Examples: # diff --git a/qa/logging-config/build.gradle b/qa/logging-config/build.gradle index 4d65c4384afa1..255a513543c92 100644 --- a/qa/logging-config/build.gradle +++ b/qa/logging-config/build.gradle @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ apply plugin: 'elasticsearch.build' -apply plugin: 'elasticsearch.legacy-java-rest-test' +apply plugin: 'elasticsearch.internal-java-rest-test' dependencies { testImplementation project(":libs:x-content") @@ -15,26 +15,6 @@ dependencies { } -testClusters.all { - setting 'xpack.security.enabled', 'false' -} - -testClusters.matching { it.name == "javaRestTest" }.configureEach { - /** - * Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch - * can successfully startup. - */ - extraConfigFile 'log4j2.properties', file('es-v7-log4j2.properties') -} - -tasks.named("javaRestTest").configure { - nonInputProperties.systemProperty 'tests.logfile', - "${-> testClusters.javaRestTest.singleNode().getServerLog().absolutePath.replaceAll("_server.json", ".log")}" - - nonInputProperties.systemProperty 'tests.jsonLogfile', - "${-> testClusters.javaRestTest.singleNode().getServerLog()}" -} - tasks.named("test").configure { systemProperty 'tests.security.manager', 'false' } diff --git a/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/CustomLoggingConfigIT.java b/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/CustomLoggingConfigIT.java index 765020b9c65e7..085fad8bcdd7f 100644 --- a/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/CustomLoggingConfigIT.java +++ b/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/CustomLoggingConfigIT.java @@ -8,18 +8,19 @@ */ package org.elasticsearch.common.logging; -import org.elasticsearch.core.SuppressForbidden; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.LogType; +import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.test.rest.ESRestTestCase; import org.hamcrest.Matchers; +import org.junit.ClassRule; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.UncheckedIOException; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.List; import static org.hamcrest.Matchers.matchesRegex; @@ -34,53 +35,44 @@ public class CustomLoggingConfigIT extends ESRestTestCase { // [2020-03-20T14:51:59,989][INFO ][o.e.g.GatewayService ] [integTest-0] recovered [0] indices into cluster_state private static final String NODE_STARTED = ".*recovered.*cluster_state.*"; + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .setting("xpack.security.enabled", "false") + .configFile("log4j2.properties", Resource.fromClasspath("es-v7-log4j2.properties")) + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } + public void testSuccessfulStartupWithCustomConfig() throws Exception { assertBusy(() -> { - List lines = readAllLines(getPlaintextLogFile()); + List lines = getPlaintextLog(); assertThat(lines, Matchers.hasItem(matchesRegex(NODE_STARTED))); }); } public void testParseAllV7JsonLines() throws Exception { assertBusy(() -> { - List lines = readAllLines(getJSONLogFile()); + List lines = getJSONLog(); assertThat(lines, Matchers.hasItem(matchesRegex(NODE_STARTED))); }); } - private List readAllLines(Path logFile) { - return AccessController.doPrivileged((PrivilegedAction>) () -> { - try { - return Files.readAllLines(logFile, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new UncheckedIOException(e); - } - }); - } - - @SuppressForbidden(reason = "PathUtils doesn't have permission to read this file") - private Path getJSONLogFile() { - String logFileString = System.getProperty("tests.logfile"); - if (logFileString == null) { - fail( - "tests.logfile must be set to run this test. It is automatically " - + "set by gradle. If you must set it yourself then it should be the absolute path to the " - + "log file." - ); + private List getJSONLog() { + try (InputStream nodeLog = cluster.getNodeLog(0, LogType.SERVER_JSON)) { + return new BufferedReader(new InputStreamReader(nodeLog, StandardCharsets.UTF_8)).lines().toList(); + } catch (IOException e) { + throw new UncheckedIOException(e); } - return Paths.get(logFileString); } - @SuppressForbidden(reason = "PathUtils doesn't have permission to read this file") - private Path getPlaintextLogFile() { - String logFileString = System.getProperty("tests.logfile"); - if (logFileString == null) { - fail( - "tests.logfile must be set to run this test. It is automatically " - + "set by gradle. If you must set it yourself then it should be the absolute path to the " - + "log file." - ); + private List getPlaintextLog() { + try (InputStream nodeLog = cluster.getNodeLog(0, LogType.SERVER)) { + return new BufferedReader(new InputStreamReader(nodeLog, StandardCharsets.UTF_8)).lines().toList(); + } catch (IOException e) { + throw new UncheckedIOException(e); } - return Paths.get(logFileString); } } diff --git a/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/ESJsonLogsConfigIT.java b/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/ESJsonLogsConfigIT.java index d8ff9c88a459f..fa3da02ffbf40 100644 --- a/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/ESJsonLogsConfigIT.java +++ b/qa/logging-config/src/javaRestTest/java/org/elasticsearch/common/logging/ESJsonLogsConfigIT.java @@ -8,49 +8,45 @@ */ package org.elasticsearch.common.logging; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.LogType; +import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.xcontent.ObjectParser; import org.hamcrest.Matcher; +import org.junit.ClassRule; -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.AccessController; -import java.security.PrivilegedAction; +import java.io.InputStream; import static org.hamcrest.Matchers.is; /** * Test to verify ES JSON log format. Used in ES v7. Some users might decide to keep that format. + * Provide a custom log4j configuration where layout is an old style pattern and confirm that Elasticsearch can successfully startup. */ public class ESJsonLogsConfigIT extends JsonLogsIntegTestCase { + + private static final String NODE_NAME = "test-node-0"; + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .setting("xpack.security.enabled", "false") + .withNode(localNodeSpecBuilder -> localNodeSpecBuilder.name(NODE_NAME)) + .configFile("log4j2.properties", Resource.fromClasspath("es-v7-log4j2.properties")) + .build(); + @Override - protected Matcher nodeNameMatcher() { - return is("javaRestTest-0"); + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); } @Override - protected BufferedReader openReader(Path logFile) { - assumeFalse( - "Skipping test because it is being run against an external cluster.", - logFile.getFileName().toString().equals("--external--") - ); - - return AccessController.doPrivileged((PrivilegedAction) () -> { - try { - String temp = Files.readString(logFile); - - return Files.newBufferedReader(logFile, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + protected InputStream openLogsStream() { + return cluster.getNodeLog(0, LogType.SERVER_JSON); } @Override - protected String getLogFileName() { - return System.getProperty("tests.jsonLogfile"); + protected Matcher nodeNameMatcher() { + return is(NODE_NAME); } @Override diff --git a/qa/logging-config/es-v7-log4j2.properties b/qa/logging-config/src/javaRestTest/resources/es-v7-log4j2.properties similarity index 100% rename from qa/logging-config/es-v7-log4j2.properties rename to qa/logging-config/src/javaRestTest/resources/es-v7-log4j2.properties diff --git a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SystemIndexRestIT.java b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SystemIndexRestIT.java index 2e48860e613ee..e37ea125ac070 100644 --- a/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SystemIndexRestIT.java +++ b/qa/smoke-test-http/src/javaRestTest/java/org/elasticsearch/http/SystemIndexRestIT.java @@ -196,7 +196,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setPrimaryIndex(SYSTEM_INDEX_NAME) .setDescription("Test system index") .setOrigin(getClass().getName()) - .setVersionMetaKey("version") .setMappings(builder) .setSettings(SETTINGS) .setType(Type.INTERNAL_MANAGED) diff --git a/qa/system-indices/src/main/java/org/elasticsearch/system/indices/SystemIndicesQA.java b/qa/system-indices/src/main/java/org/elasticsearch/system/indices/SystemIndicesQA.java index 57b0908508bb3..6e15e40efa69a 100644 --- a/qa/system-indices/src/main/java/org/elasticsearch/system/indices/SystemIndicesQA.java +++ b/qa/system-indices/src/main/java/org/elasticsearch/system/indices/SystemIndicesQA.java @@ -77,7 +77,6 @@ public Collection getSystemIndexDescriptors(Settings sett .build() ) .setOrigin(TASKS_ORIGIN) - .setVersionMetaKey("version") .setPrimaryIndex(".net-new-system-index-primary") .build(), SystemIndexDescriptor.builder() @@ -99,7 +98,6 @@ public Collection getSystemIndexDescriptors(Settings sett .build() ) .setOrigin(TASKS_ORIGIN) - .setVersionMetaKey("version") .setPrimaryIndex(".internal-managed-index-primary") .setAliasName(".internal-managed-alias") .build() diff --git a/qa/unconfigured-node-name/build.gradle b/qa/unconfigured-node-name/build.gradle index 07aafd8f5c269..ecc088e5972ef 100644 --- a/qa/unconfigured-node-name/build.gradle +++ b/qa/unconfigured-node-name/build.gradle @@ -7,17 +7,4 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -apply plugin: 'elasticsearch.legacy-java-rest-test' - -testClusters.configureEach { - setting 'xpack.security.enabled', 'false' -} - -testClusters.matching { it.name == "javaRestTest" }.configureEach { - nameCustomization = { null } -} - -tasks.named("javaRestTest").configure { - nonInputProperties.systemProperty 'tests.logfile', - "${-> testClusters.javaRestTest.singleNode().getServerLog()}" -} +apply plugin: 'elasticsearch.internal-java-rest-test' diff --git a/qa/unconfigured-node-name/src/javaRestTest/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java b/qa/unconfigured-node-name/src/javaRestTest/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java index 30804adca88b3..7ceda070adadb 100644 --- a/qa/unconfigured-node-name/src/javaRestTest/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java +++ b/qa/unconfigured-node-name/src/javaRestTest/java/org/elasticsearch/unconfigured_node_name/JsonLogsFormatAndParseIT.java @@ -10,15 +10,12 @@ package org.elasticsearch.unconfigured_node_name; import org.elasticsearch.common.logging.JsonLogsIntegTestCase; +import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.LogType; import org.hamcrest.Matcher; +import org.junit.ClassRule; -import java.io.BufferedReader; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.security.AccessController; -import java.security.PrivilegedAction; +import java.io.InputStream; import static org.hamcrest.Matchers.equalTo; @@ -26,9 +23,24 @@ public class JsonLogsFormatAndParseIT extends JsonLogsIntegTestCase { private static final String OS_NAME = System.getProperty("os.name"); private static final boolean WINDOWS = OS_NAME.startsWith("Windows"); - // These match the values defined in org.elasticsearch.gradle.testclusters.ElasticsearchNode - private static final String COMPUTERNAME = "WindowsComputername"; - private static final String HOSTNAME = "LinuxDarwinHostname"; + private static final String COMPUTERNAME = "WindowsTestComputername"; + private static final String HOSTNAME = "LinuxDarwinTestHostname"; + + @ClassRule + public static ElasticsearchCluster cluster = ElasticsearchCluster.local() + .setting("xpack.security.enabled", "false") + .setting("discovery.type", "single-node") + .withNode( + localNodeSpecBuilder -> localNodeSpecBuilder.withoutName() + .environment("HOSTNAME", HOSTNAME) + .environment("COMPUTERNAME", COMPUTERNAME) + ) + .build(); + + @Override + protected String getTestRestCluster() { + return cluster.getHttpAddresses(); + } @Override protected Matcher nodeNameMatcher() { @@ -39,13 +51,7 @@ protected Matcher nodeNameMatcher() { } @Override - protected BufferedReader openReader(Path logFile) { - return AccessController.doPrivileged((PrivilegedAction) () -> { - try { - return Files.newBufferedReader(logFile, StandardCharsets.UTF_8); - } catch (IOException e) { - throw new RuntimeException(e); - } - }); + protected InputStream openLogsStream() { + return cluster.getNodeLog(0, LogType.SERVER_JSON); } } diff --git a/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java b/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java index 27392fefbf4ca..cf54bc50398c4 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/aliases/NetNewSystemIndexAliasIT.java @@ -89,7 +89,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setPrimaryIndex(SYSTEM_INDEX_NAME) .setDescription("Test system index") .setOrigin(getClass().getName()) - .setVersionMetaKey("version") .setMappings(builder) .setSettings(SETTINGS) .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/TestSystemIndexDescriptor.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/TestSystemIndexDescriptor.java index cc05bb4c82ceb..487bbf7c9a4be 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/TestSystemIndexDescriptor.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/TestSystemIndexDescriptor.java @@ -9,7 +9,6 @@ package org.elasticsearch.indices; -import org.elasticsearch.Build; import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; @@ -51,9 +50,7 @@ public class TestSystemIndexDescriptor extends SystemIndexDescriptor { SETTINGS, INDEX_NAME, 0, - "version", "stack", - null, Type.INTERNAL_MANAGED, List.of(), List.of(), @@ -72,9 +69,7 @@ public class TestSystemIndexDescriptor extends SystemIndexDescriptor { SETTINGS, name, 0, - "version", "stack", - Version.fromString(Build.current().minWireCompatVersion()), Type.INTERNAL_MANAGED, List.of(), List.of(), diff --git a/server/src/main/java/org/elasticsearch/env/BuildVersion.java b/server/src/main/java/org/elasticsearch/env/BuildVersion.java index 5536b06d4d587..7a6b27eab2330 100644 --- a/server/src/main/java/org/elasticsearch/env/BuildVersion.java +++ b/server/src/main/java/org/elasticsearch/env/BuildVersion.java @@ -11,9 +11,13 @@ import org.elasticsearch.Build; import org.elasticsearch.Version; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.Writeable; import org.elasticsearch.internal.BuildExtension; import org.elasticsearch.plugins.ExtensionLoader; +import org.elasticsearch.xcontent.ToXContentFragment; +import java.io.IOException; import java.util.ServiceLoader; /** @@ -31,7 +35,7 @@ * provide versions that accommodate different release models or versioning * schemes.

*/ -public abstract class BuildVersion { +public abstract class BuildVersion implements ToXContentFragment, Writeable { /** * Check whether this version is on or after a minimum threshold. @@ -58,6 +62,11 @@ public abstract class BuildVersion { */ public abstract boolean isFutureVersion(); + /** + * Returns this build version in a form suitable for storing in node metadata + */ + public abstract String toNodeMetadata(); + /** * Create a {@link BuildVersion} from a version ID number. * @@ -72,6 +81,16 @@ public static BuildVersion fromVersionId(int versionId) { return CurrentExtensionHolder.BUILD_EXTENSION.fromVersionId(versionId); } + /** + * Create a {@link BuildVersion} from a version in node metadata + * + * @param version The string stored in node metadata + * @return a version representing a build or release of Elasticsearch + */ + public static BuildVersion fromNodeMetadata(String version) { + return CurrentExtensionHolder.BUILD_EXTENSION.fromNodeMetadata(version); + } + /** * Create a {@link BuildVersion} from a version string. * @@ -82,6 +101,16 @@ public static BuildVersion fromString(String version) { return CurrentExtensionHolder.BUILD_EXTENSION.fromString(version); } + /** + * Read a {@link BuildVersion} from an input stream + * + * @param input The stream to read + * @return a version representing a build or release of Elasticsearch + */ + public static BuildVersion fromStream(StreamInput input) throws IOException { + return CurrentExtensionHolder.BUILD_EXTENSION.fromStream(input); + } + /** * Get the current build version. * @@ -94,9 +123,6 @@ public static BuildVersion current() { return CurrentExtensionHolder.BUILD_EXTENSION.currentBuildVersion(); } - // only exists for NodeMetadata#toXContent - public abstract int id(); - private static class CurrentExtensionHolder { private static final BuildExtension BUILD_EXTENSION = findExtension(); @@ -125,6 +151,10 @@ public BuildVersion fromVersionId(int versionId) { public BuildVersion fromString(String version) { return new DefaultBuildVersion(version); } - } + @Override + public BuildVersion fromStream(StreamInput in) throws IOException { + return new DefaultBuildVersion(in); + } + } } diff --git a/server/src/main/java/org/elasticsearch/env/DefaultBuildVersion.java b/server/src/main/java/org/elasticsearch/env/DefaultBuildVersion.java index 9cf0d60719653..a7e1a4fee341d 100644 --- a/server/src/main/java/org/elasticsearch/env/DefaultBuildVersion.java +++ b/server/src/main/java/org/elasticsearch/env/DefaultBuildVersion.java @@ -10,7 +10,11 @@ package org.elasticsearch.env; import org.elasticsearch.Version; +import org.elasticsearch.common.io.stream.StreamInput; +import org.elasticsearch.common.io.stream.StreamOutput; +import org.elasticsearch.xcontent.XContentBuilder; +import java.io.IOException; import java.util.Objects; /** @@ -28,7 +32,7 @@ final class DefaultBuildVersion extends BuildVersion { public static BuildVersion CURRENT = new DefaultBuildVersion(Version.CURRENT.id()); - private final Version version; + final Version version; DefaultBuildVersion(int versionId) { assert versionId >= 0 : "Release version IDs must be non-negative integers"; @@ -39,6 +43,10 @@ final class DefaultBuildVersion extends BuildVersion { this.version = Version.fromString(Objects.requireNonNull(version)); } + DefaultBuildVersion(StreamInput in) throws IOException { + this(in.readVInt()); + } + @Override public boolean onOrAfterMinimumCompatible() { return Version.CURRENT.minimumCompatibilityVersion().onOrBefore(version); @@ -50,8 +58,18 @@ public boolean isFutureVersion() { } @Override - public int id() { - return version.id(); + public String toNodeMetadata() { + return Integer.toString(version.id()); + } + + @Override + public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + return builder.value(version.id()); + } + + @Override + public void writeTo(StreamOutput out) throws IOException { + out.writeVInt(version.id()); } @Override diff --git a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java index 5b2ee39c1b622..c71a3798be1f7 100644 --- a/server/src/main/java/org/elasticsearch/env/NodeMetadata.java +++ b/server/src/main/java/org/elasticsearch/env/NodeMetadata.java @@ -204,7 +204,7 @@ protected XContentBuilder newXContentBuilder(XContentType type, OutputStream str @Override public void toXContent(XContentBuilder builder, NodeMetadata nodeMetadata) throws IOException { builder.field(NODE_ID_KEY, nodeMetadata.nodeId); - builder.field(NODE_VERSION_KEY, nodeMetadata.nodeVersion.id()); + builder.field(NODE_VERSION_KEY, nodeMetadata.nodeVersion); builder.field(OLDEST_INDEX_VERSION_KEY, nodeMetadata.oldestIndexVersion.id()); } diff --git a/server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java b/server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java index 92b8686700a05..44be3a3812fd1 100644 --- a/server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java +++ b/server/src/main/java/org/elasticsearch/gateway/PersistedClusterStateService.java @@ -364,7 +364,7 @@ public static NodeMetadata nodeMetadata(Path... dataPaths) throws IOException { ); } else if (nodeId == null) { nodeId = thisNodeId; - version = BuildVersion.fromVersionId(Integer.parseInt(userData.get(NODE_VERSION_KEY))); + version = BuildVersion.fromNodeMetadata(userData.get(NODE_VERSION_KEY)); if (userData.containsKey(OLDEST_INDEX_VERSION_KEY)) { oldestIndexVersion = IndexVersion.fromId(Integer.parseInt(userData.get(OLDEST_INDEX_VERSION_KEY))); } else { @@ -395,7 +395,7 @@ public static void overrideVersion(BuildVersion newVersion, Path... dataPaths) t try (IndexWriter indexWriter = createIndexWriter(new NIOFSDirectory(dataPath.resolve(METADATA_DIRECTORY_NAME)), true)) { final Map commitData = new HashMap<>(userData); - commitData.put(NODE_VERSION_KEY, Integer.toString(newVersion.id())); + commitData.put(NODE_VERSION_KEY, newVersion.toNodeMetadata()); commitData.put(OVERRIDDEN_NODE_VERSION_KEY, Boolean.toString(true)); indexWriter.setLiveCommitData(commitData.entrySet()); indexWriter.commit(); @@ -852,7 +852,7 @@ void prepareCommit( final Map commitData = Maps.newMapWithExpectedSize(COMMIT_DATA_SIZE); commitData.put(CURRENT_TERM_KEY, Long.toString(currentTerm)); commitData.put(LAST_ACCEPTED_VERSION_KEY, Long.toString(lastAcceptedVersion)); - commitData.put(NODE_VERSION_KEY, Integer.toString(BuildVersion.current().id())); + commitData.put(NODE_VERSION_KEY, BuildVersion.current().toNodeMetadata()); commitData.put(OLDEST_INDEX_VERSION_KEY, Integer.toString(oldestIndexVersion.id())); commitData.put(NODE_ID_KEY, nodeId); commitData.put(CLUSTER_UUID_KEY, clusterUUID); diff --git a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java index 372e0bbdfecf4..1162734c0dc81 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/SourceFieldMapper.java @@ -242,7 +242,7 @@ public SourceFieldMapper build() { } private Mode resolveSourceMode() { - // If the `index.mapper.source.mode` exists it takes precedence to determine the source mode for `_source` + // If the `index.mapping.source.mode` exists it takes precedence to determine the source mode for `_source` // otherwise the mode is determined according to `_source.mode`. if (INDEX_MAPPER_SOURCE_MODE_SETTING.exists(settings)) { return INDEX_MAPPER_SOURCE_MODE_SETTING.get(settings); @@ -439,6 +439,10 @@ public static boolean isSynthetic(IndexSettings indexSettings) { return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == SourceFieldMapper.Mode.SYNTHETIC; } + public static boolean isStored(IndexSettings indexSettings) { + return INDEX_MAPPER_SOURCE_MODE_SETTING.get(indexSettings.getSettings()) == Mode.STORED; + } + public boolean isDisabled() { return mode == Mode.DISABLED; } diff --git a/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java b/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java index f3456870114f5..8b9610a52cc3d 100644 --- a/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java +++ b/server/src/main/java/org/elasticsearch/indices/SystemIndexDescriptor.java @@ -13,7 +13,6 @@ import org.apache.lucene.util.automaton.CharacterRunAutomaton; import org.apache.lucene.util.automaton.Operations; import org.apache.lucene.util.automaton.RegExp; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.create.AutoCreateAction; import org.elasticsearch.action.admin.indices.create.TransportCreateIndexAction; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -36,7 +35,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.Set; @@ -141,25 +139,12 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable_meta in the index mappings - * that contains the index's mappings' {@link Version}. We need to read and write this field for - * backwards compatibility. - */ - private final String mappingsNodeVersionMetaKey; - /** The version meta key for the integer system index mapping version */ public static final String VERSION_META_KEY = "managed_index_mappings_version"; /** For internally-managed indices, specifies the origin to use when creating or updating the index */ private final String origin; - /** The minimum cluster node version required for this descriptor */ - private final Version minimumNodeVersion; - - /** Legacy mapping version from the descriptor */ - private final Version mappingsNodeVersion; - /** Mapping version from the descriptor */ private final MappingsVersion mappingsVersion; @@ -209,11 +194,8 @@ public class SystemIndexDescriptor implements IndexPatternMatcher, Comparable_meta where a version can be found, which indicates the - * Elasticsearch version when the index was created. * @param origin the client origin to use when creating this index. Internal system indices must not provide an origin, while external * system indices must do so. - * @param minimumNodeVersion the minimum cluster node version required for this descriptor * @param type The {@link Type} of system index * @param allowedElasticProductOrigins A list of allowed origin values that should be allowed access in the case of external system * indices @@ -229,9 +211,7 @@ protected SystemIndexDescriptor( Settings settings, String aliasName, int indexFormat, - String mappingsNodeVersionMetaKey, String origin, - @Deprecated Version minimumNodeVersion, Type type, List allowedElasticProductOrigins, List priorSystemIndexDescriptors, @@ -282,12 +262,10 @@ protected SystemIndexDescriptor( Objects.requireNonNull(settings, "Must supply settings for a managed system index"); Strings.requireNonEmpty(mappings, "Must supply mappings for a managed system index"); Strings.requireNonEmpty(primaryIndex, "Must supply primaryIndex for a managed system index"); - Strings.requireNonEmpty(mappingsNodeVersionMetaKey, "Must supply nodeVersionMetaKey for a managed system index"); Strings.requireNonEmpty(origin, "Must supply origin for a managed system index"); if (settings.getAsInt(IndexMetadata.INDEX_FORMAT_SETTING.getKey(), 0) != indexFormat) { throw new IllegalArgumentException("Descriptor index format does not match index format in managed settings"); } - this.mappingsNodeVersion = bestEffortExtractNodeVersionFromMappings(mappings, mappingsNodeVersionMetaKey); this.mappingsVersion = extractVersionFromMappings(mappings); assert mappingsVersion.version >= 0 : "The mappings version must not be negative"; @@ -295,8 +273,6 @@ protected SystemIndexDescriptor( assert Objects.isNull(settings) : "Unmanaged index descriptors should not have settings"; assert Objects.isNull(mappings) : "Unmanaged index descriptors should not have mappings"; assert Objects.isNull(primaryIndex) : "Unmanaged index descriptors should not have a primary index"; - assert Objects.isNull(mappingsNodeVersionMetaKey) : "Unmanaged index descriptors should not have a version meta key"; - this.mappingsNodeVersion = null; this.mappingsVersion = null; } @@ -310,8 +286,8 @@ protected SystemIndexDescriptor( Objects.requireNonNull(priorSystemIndexDescriptors, "priorSystemIndexDescriptors must not be null"); if (priorSystemIndexDescriptors.isEmpty() == false) { // the rules for prior system index descriptors - // 1. No values with the same minimum node version - // 2. All prior system index descriptors must have a minimumNodeVersion before this one + // 1. No values with the same minimum mappings version + // 2. All prior system index descriptors must have a lower mappings version // 3. Prior system index descriptors may not have other prior system index descriptors // to avoid multiple branches that need followed // 4. Must have same indexPattern, primaryIndex, and alias @@ -383,9 +359,7 @@ protected SystemIndexDescriptor( throw new IllegalArgumentException("System indices must have " + IndexMetadata.SETTING_INDEX_HIDDEN + " set to true."); } this.indexFormat = indexFormat; - this.mappingsNodeVersionMetaKey = mappingsNodeVersionMetaKey; this.origin = origin; - this.minimumNodeVersion = minimumNodeVersion; this.type = type; this.allowedElasticProductOrigins = allowedElasticProductOrigins; this.hasDynamicMappings = this.mappings != null @@ -478,16 +452,6 @@ public int getIndexFormat() { return this.indexFormat; } - public String getMappingsNodeVersionMetaKey() { - assert isAutomaticallyManaged() : "Do not request version meta keys for unmanaged system indices"; - return this.mappingsNodeVersionMetaKey; - } - - public Version getMinimumNodeVersion() { - assert isAutomaticallyManaged() : "Do not request version minimum node version for unmanaged system indices"; - return minimumNodeVersion; - } - public boolean isAutomaticallyManaged() { return type.isManaged(); } @@ -534,18 +498,6 @@ public boolean allowsTemplates() { return allowsTemplates; } - /** - * Use of the mappings {@link Version} should be replaced with the value returned from {@link #getMappingsVersion()} - * @return Elasticsearch version associated with this descriptor's mappings. - */ - @Deprecated - public Version getMappingsNodeVersion() { - if (isAutomaticallyManaged() == false) { - throw new IllegalStateException(this + " is not managed so there are no mappings or version"); - } - return mappingsNodeVersion; - } - public MappingsVersion getMappingsVersion() { if (isAutomaticallyManaged() == false) { throw new IllegalStateException(this + " is not managed so there are no mappings or version"); @@ -554,7 +506,7 @@ public MappingsVersion getMappingsVersion() { } /** - * Gets a standardized message when the node contains a data or master node whose version is less + * Gets a standardized message when the node contains a data or master node whose mappings version is less * than that of the minimum supported version of this descriptor and its prior descriptors. * * @param cause the action being attempted that triggered the check. Used in the error message. @@ -573,55 +525,12 @@ public String getMinimumMappingsVersionMessage(String cause) { ); } - /** - * Gets a standardized message when the node contains a data or master node whose version is less - * than that of the minimum supported version of this descriptor and its prior descriptors. - * - * @param cause the action being attempted that triggered the check. Used in the error message. - * @return the standardized error message - */ - @Deprecated - public String getMinimumNodeVersionMessage(String cause) { - Objects.requireNonNull(cause); - final Version actualMinimumVersion = priorSystemIndexDescriptors.isEmpty() - ? minimumNodeVersion - : priorSystemIndexDescriptors.get(priorSystemIndexDescriptors.size() - 1).minimumNodeVersion; - return String.format( - Locale.ROOT, - "[%s] failed - system index [%s] requires all data and master nodes to be at least version [%s]", - cause, - this.getPrimaryIndex(), - actualMinimumVersion - ); - } - /** * Finds the descriptor that can be used within this cluster, by comparing the supplied minimum - * node version to this descriptor's minimum version and the prior descriptors minimum version. + * mappings version to this descriptor's minimum version and the prior descriptors minimum version. * - * @param version the lower node version in the cluster - * @return null if the lowest node version is lower than the minimum version in this descriptor, - * or the appropriate descriptor if the supplied version is acceptable. - */ - @Deprecated - public SystemIndexDescriptor getDescriptorCompatibleWith(Version version) { - if (minimumNodeVersion.onOrBefore(version)) { - return this; - } - for (SystemIndexDescriptor prior : priorSystemIndexDescriptors) { - if (version.onOrAfter(prior.minimumNodeVersion)) { - return prior; - } - } - return null; - } - - /** - * Finds the descriptor that can be used within this cluster, by comparing the supplied minimum - * node version to this descriptor's minimum version and the prior descriptors minimum version. - * - * @param version the lower node version in the cluster - * @return null if the lowest node version is lower than the minimum version in this descriptor, + * @param version the lower mappings version in the cluster + * @return null if the lowest mappings version is lower than the minimum version in this descriptor, * or the appropriate descriptor if the supplied version is acceptable. */ public SystemIndexDescriptor getDescriptorCompatibleWith(MappingsVersion version) { @@ -637,8 +546,7 @@ public SystemIndexDescriptor getDescriptorCompatibleWith(MappingsVersion version } /** - * @return The names of thread pools that should be used for operations on this - * system index. + * @return The names of thread pools that should be used for operations on this system index. */ public ExecutorNames getThreadPoolNames() { return this.executorNames; @@ -650,7 +558,7 @@ public static Builder builder() { @Override public int compareTo(SystemIndexDescriptor other) { - return minimumNodeVersion.compareTo(other.minimumNodeVersion) * -1; + return mappingsVersion.compareTo(other.mappingsVersion) * -1; } /** @@ -745,9 +653,7 @@ public static class Builder { private Settings settings = null; private String aliasName = null; private int indexFormat = 0; - private String versionMetaKey = null; private String origin = null; - private Version minimumNodeVersion = Version.CURRENT.minimumCompatibilityVersion(); private Type type = Type.INTERNAL_MANAGED; private List allowedElasticProductOrigins = List.of(); private List priorSystemIndexDescriptors = List.of(); @@ -797,11 +703,6 @@ public Builder setIndexFormat(int indexFormat) { return this; } - public Builder setVersionMetaKey(String versionMetaKey) { - this.versionMetaKey = versionMetaKey; - return this; - } - /** * Sometimes a system operation will need to dispatch sub-actions. A product origin string will tell the system which component * generated the sub-action. Internal system indices must not provide an origin, since they are supposed to reject access from @@ -815,11 +716,6 @@ public Builder setOrigin(String origin) { return this; } - public Builder setMinimumNodeVersion(Version version) { - this.minimumNodeVersion = version; - return this; - } - public Builder setType(Type type) { this.type = type; return this; @@ -863,9 +759,7 @@ public SystemIndexDescriptor build() { settings, aliasName, indexFormat, - versionMetaKey, origin, - minimumNodeVersion, type, allowedElasticProductOrigins, priorSystemIndexDescriptors, @@ -962,44 +856,4 @@ private static MappingsVersion extractVersionFromMappings(String mappings) { } return new MappingsVersion(value, Objects.hash(properties)); } - - /** - * An accurate node version is no longer required in system index mappings metadata. - * because the mappings version should be used to determine if an upgrade is required, - * not the node version. However, some parts of the code are still relying on - * mappingsNodeVersion. This method allows sections of the code to stop - * accurately setting node version in their mappings while other sections continue to - * use it. Once all uses of mappingsNodeVersion are removed this method - * can be removed too. - */ - @Deprecated - private static Version bestEffortExtractNodeVersionFromMappings(String mappings, String versionMetaKey) { - try { - return extractNodeVersionFromMappings(mappings, versionMetaKey); - } catch (Exception e) { - return null; - } - } - - @Deprecated - @SuppressWarnings("unchecked") - private static Version extractNodeVersionFromMappings(String mappings, String versionMetaKey) { - final Map mappingsMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), mappings, false); - final Map doc = (Map) mappingsMap.get("_doc"); - final Map meta; - if (doc == null) { - meta = (Map) mappingsMap.get("_meta"); - } else { - meta = (Map) doc.get("_meta"); - } - if (meta == null) { - throw new IllegalStateException("mappings do not have _meta field"); - } - final String value = (String) meta.get(versionMetaKey); - if (value == null) { - throw new IllegalArgumentException("mappings do not have a version in _meta." + versionMetaKey); - } - return Version.fromString(value); - } - } diff --git a/server/src/main/java/org/elasticsearch/internal/BuildExtension.java b/server/src/main/java/org/elasticsearch/internal/BuildExtension.java index 427e186bc40cf..7b4f5a7fadb4c 100644 --- a/server/src/main/java/org/elasticsearch/internal/BuildExtension.java +++ b/server/src/main/java/org/elasticsearch/internal/BuildExtension.java @@ -10,8 +10,11 @@ package org.elasticsearch.internal; import org.elasticsearch.Build; +import org.elasticsearch.common.io.stream.StreamInput; import org.elasticsearch.env.BuildVersion; +import java.io.IOException; + /** * Allows plugging in current build info. */ @@ -39,8 +42,20 @@ default boolean hasReleaseVersioning() { */ BuildVersion fromVersionId(int versionId); + /** + * Returns the {@link BuildVersion} as read from node metadata + */ + default BuildVersion fromNodeMetadata(String version) { + return fromVersionId(Integer.parseInt(version)); + } + /** * Returns the {@link BuildVersion} for a given version string. */ BuildVersion fromString(String version); + + /** + * Reads a {@link BuildVersion} from the given stream + */ + BuildVersion fromStream(StreamInput in) throws IOException; } diff --git a/server/src/main/java/org/elasticsearch/reservedstate/service/ReservedStateVersion.java b/server/src/main/java/org/elasticsearch/reservedstate/service/ReservedStateVersion.java index 116d470755e1c..ed10df2552b6b 100644 --- a/server/src/main/java/org/elasticsearch/reservedstate/service/ReservedStateVersion.java +++ b/server/src/main/java/org/elasticsearch/reservedstate/service/ReservedStateVersion.java @@ -48,12 +48,12 @@ public static ReservedStateVersion parse(XContentParser parser) { } public static ReservedStateVersion readFrom(StreamInput input) throws IOException { - return new ReservedStateVersion(input.readLong(), BuildVersion.fromVersionId(input.readVInt())); + return new ReservedStateVersion(input.readLong(), BuildVersion.fromStream(input)); } @Override public void writeTo(StreamOutput out) throws IOException { - out.writeLong(version()); - out.writeVInt(buildVersion().id()); + out.writeLong(version); + buildVersion.writeTo(out); } } diff --git a/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java b/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java index c760e8043e262..72d0a1330a249 100644 --- a/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java +++ b/server/src/main/java/org/elasticsearch/synonyms/SynonymsManagementAPIService.java @@ -106,7 +106,6 @@ public class SynonymsManagementAPIService { .setIndexFormat(SYNONYMS_INDEX_FORMAT) .setMappings(mappings()) .setSettings(settings()) - .setVersionMetaKey("version") .setOrigin(SYNONYMS_ORIGIN) .build(); diff --git a/server/src/main/java/org/elasticsearch/tasks/TaskResultsService.java b/server/src/main/java/org/elasticsearch/tasks/TaskResultsService.java index 0c9833fad7640..cafad960c168f 100644 --- a/server/src/main/java/org/elasticsearch/tasks/TaskResultsService.java +++ b/server/src/main/java/org/elasticsearch/tasks/TaskResultsService.java @@ -59,7 +59,6 @@ public class TaskResultsService { .setDescription("Task Result Index") .setSettings(getTaskResultIndexSettings()) .setMappings(getTaskResultIndexMappings()) - .setVersionMetaKey(TASK_RESULT_MAPPING_VERSION_META_FIELD) .setOrigin(TASKS_ORIGIN) .build(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java index b40078ca7f1a9..ec5f0b489d6ef 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/alias/get/TransportGetAliasesActionTests.java @@ -277,7 +277,6 @@ public void testNetNewSystemIndicesDontErrorWhenNotRequested() { .setDescription(this.getTestName()) .setMappings("{\"_meta\": {\"version\": \"1.0.0\", \"" + SystemIndexDescriptor.VERSION_META_KEY + "\": 0}}") .setSettings(Settings.EMPTY) - .setVersionMetaKey("version") .setOrigin(this.getTestName()) .setNetNew() .build(); diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java index 7e590dc2cdeec..9f8b4da357ee5 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/create/TransportCreateIndexActionTests.java @@ -104,7 +104,6 @@ public class TransportCreateIndexActionTests extends ESTestCase { } }" """, SystemIndexDescriptor.VERSION_META_KEY)) - .setVersionMetaKey("version") .setOrigin("origin") .build() ) diff --git a/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java b/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java index 834bacd9e6a04..423de4b43088f 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/indices/resolve/ResolveIndexTests.java @@ -525,7 +525,6 @@ private SystemIndices addSystemIndex(Metadata.Builder mdBuilder) { } """, SystemIndexDescriptor.VERSION_META_KEY)) .setPrimaryIndex(".test-net-new-system-1") - .setVersionMetaKey("version") .setOrigin("system") .build() ) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeServiceTests.java index ac9d5021329ab..0dcea706e7f94 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/SystemIndexMetadataUpgradeServiceTests.java @@ -46,7 +46,6 @@ public class SystemIndexMetadataUpgradeServiceTests extends ESTestCase { .setAliasName(SYSTEM_ALIAS_NAME) .setSettings(getSettingsBuilder().build()) .setMappings(MAPPINGS) - .setVersionMetaKey("version") .setOrigin("FAKE_ORIGIN") .build(); diff --git a/server/src/test/java/org/elasticsearch/env/BuildVersionTests.java b/server/src/test/java/org/elasticsearch/env/BuildVersionTests.java index dab0adc2446ce..9fd889426fd2d 100644 --- a/server/src/test/java/org/elasticsearch/env/BuildVersionTests.java +++ b/server/src/test/java/org/elasticsearch/env/BuildVersionTests.java @@ -42,4 +42,8 @@ public void testIsFutureVersion() { assertFalse(afterMinCompat.isFutureVersion()); assertTrue(futureVersion.isFutureVersion()); } + + public static BuildVersion increment(BuildVersion version) { + return BuildVersion.fromVersionId(((DefaultBuildVersion) version).version.id() + 1); + } } diff --git a/server/src/test/java/org/elasticsearch/indices/SystemIndexDescriptorTests.java b/server/src/test/java/org/elasticsearch/indices/SystemIndexDescriptorTests.java index 59d5cf4359bb1..eedd7c2594691 100644 --- a/server/src/test/java/org/elasticsearch/indices/SystemIndexDescriptorTests.java +++ b/server/src/test/java/org/elasticsearch/indices/SystemIndexDescriptorTests.java @@ -10,14 +10,12 @@ package org.elasticsearch.indices; import org.apache.lucene.util.automaton.CharacterRunAutomaton; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentHelper; import org.elasticsearch.indices.SystemIndexDescriptor.Type; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; import org.elasticsearch.xcontent.json.JsonXContent; import java.util.List; @@ -38,7 +36,6 @@ public class SystemIndexDescriptorTests extends ESTestCase { { "_doc": { "_meta": { - "version": "7.4.0", "%s": %d } } @@ -211,7 +208,6 @@ public void testPriorSystemIndexDescriptorValidation() { .setType(Type.INTERNAL_MANAGED) .setSettings(Settings.EMPTY) .setMappings(getVersionedMappings(TEST_MAPPINGS_VERSION + 1)) - .setVersionMetaKey("version") .setOrigin("system") .setPriorSystemIndexDescriptors(List.of(prior)) .build() @@ -272,9 +268,7 @@ public void testGetDescriptorCompatibleWith() { .setType(Type.INTERNAL_MANAGED) .setSettings(Settings.EMPTY) .setMappings(getVersionedMappings(TEST_MAPPINGS_PRIOR_VERSION)) - .setVersionMetaKey("version") .setOrigin("system") - .setMinimumNodeVersion(Version.V_7_0_0) .build(); final SystemIndexDescriptor descriptor = SystemIndexDescriptor.builder() .setIndexPattern(".system*") @@ -284,27 +278,15 @@ public void testGetDescriptorCompatibleWith() { .setType(Type.INTERNAL_MANAGED) .setSettings(Settings.EMPTY) .setMappings(MAPPINGS) - .setVersionMetaKey("version") .setOrigin("system") .setPriorSystemIndexDescriptors(List.of(prior)) .build(); - SystemIndexDescriptor compat = descriptor.getDescriptorCompatibleWith(Version.CURRENT); + SystemIndexDescriptor compat = descriptor.getDescriptorCompatibleWith(descriptor.getMappingsVersion()); assertSame(descriptor, compat); - compat = descriptor.getDescriptorCompatibleWith(descriptor.getMappingsVersion()); - assertSame(descriptor, compat); - - assertNull(descriptor.getDescriptorCompatibleWith(Version.fromString("6.8.0"))); assertNull(descriptor.getDescriptorCompatibleWith(new SystemIndexDescriptor.MappingsVersion(TEST_MAPPINGS_NONEXISTENT_VERSION, 1))); - compat = descriptor.getDescriptorCompatibleWith(Version.CURRENT.minimumCompatibilityVersion()); - assertSame(descriptor, compat); - - Version priorToMin = VersionUtils.getPreviousVersion(descriptor.getMinimumNodeVersion()); - compat = descriptor.getDescriptorCompatibleWith(priorToMin); - assertSame(prior, compat); - SystemIndexDescriptor.MappingsVersion priorToMinMappingsVersion = new SystemIndexDescriptor.MappingsVersion( TEST_MAPPINGS_PRIOR_VERSION, 1 @@ -312,11 +294,6 @@ public void testGetDescriptorCompatibleWith() { compat = descriptor.getDescriptorCompatibleWith(priorToMinMappingsVersion); assertSame(prior, compat); - compat = descriptor.getDescriptorCompatibleWith( - VersionUtils.randomVersionBetween(random(), prior.getMinimumNodeVersion(), priorToMin) - ); - assertSame(prior, compat); - compat = descriptor.getDescriptorCompatibleWith( new SystemIndexDescriptor.MappingsVersion(randomIntBetween(TEST_MAPPINGS_PRIOR_VERSION, TEST_MAPPINGS_VERSION - 1), 1) ); @@ -331,7 +308,6 @@ public void testSystemIndicesMustBeHidden() { .setAliasName(".system") .setType(Type.INTERNAL_MANAGED) .setMappings(MAPPINGS) - .setVersionMetaKey("version") .setOrigin("system"); builder.setSettings(Settings.builder().put(IndexMetadata.SETTING_INDEX_HIDDEN, false).build()); @@ -371,7 +347,6 @@ public void testManagedSystemIndexMustHaveMatchingIndexFormat() { .setMappings(MAPPINGS) .setSettings(Settings.builder().put("index.format", 5).build()) .setIndexFormat(0) - .setVersionMetaKey("version") .setOrigin("system"); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, builder::build); @@ -394,16 +369,7 @@ public void testUnmanagedIndexMappingsVersion() { // test mapping versions can't be negative public void testNegativeMappingsVersion() { int negativeVersion = randomIntBetween(Integer.MIN_VALUE, -1); - String mappings = Strings.format(""" - { - "_doc": { - "_meta": { - "version": "7.4.0", - "%s": %d - } - } - } - """, SystemIndexDescriptor.VERSION_META_KEY, negativeVersion); + String mappings = Strings.format(MAPPINGS_FORMAT_STRING, SystemIndexDescriptor.VERSION_META_KEY, negativeVersion); SystemIndexDescriptor.Builder builder = priorSystemIndexDescriptorBuilder().setMappings(mappings); @@ -429,7 +395,6 @@ public void testHashesIgnoreMappingMetadata() { { "_doc": { "_meta": { - "version": "%s", "%s": %d } }, @@ -441,15 +406,14 @@ public void testHashesIgnoreMappingMetadata() { } """; - String mappings1 = Strings.format(mappingFormatString, "8.9.0", SystemIndexDescriptor.VERSION_META_KEY, randomIntBetween(1, 10)); - String mappings2 = Strings.format(mappingFormatString, "8.10.0", SystemIndexDescriptor.VERSION_META_KEY, randomIntBetween(11, 20)); + String mappings1 = Strings.format(mappingFormatString, SystemIndexDescriptor.VERSION_META_KEY, randomIntBetween(1, 10)); + String mappings2 = Strings.format(mappingFormatString, SystemIndexDescriptor.VERSION_META_KEY, randomIntBetween(11, 20)); SystemIndexDescriptor descriptor1 = priorSystemIndexDescriptorBuilder().setMappings(mappings1).build(); SystemIndexDescriptor descriptor2 = priorSystemIndexDescriptorBuilder().setMappings(mappings2).build(); assertThat(descriptor1.getMappingsVersion().hash(), equalTo(descriptor2.getMappingsVersion().hash())); assertThat(descriptor1.getMappingsVersion().version(), not(equalTo(descriptor2.getMappingsVersion().version()))); - assertThat(descriptor1.getMappingsNodeVersion(), not(equalTo(descriptor2.getMappingsNodeVersion()))); } private SystemIndexDescriptor.Builder priorSystemIndexDescriptorBuilder() { @@ -461,8 +425,6 @@ private SystemIndexDescriptor.Builder priorSystemIndexDescriptorBuilder() { .setType(Type.INTERNAL_MANAGED) .setSettings(Settings.EMPTY) .setMappings(MAPPINGS) - .setVersionMetaKey("version") - .setOrigin("system") - .setMinimumNodeVersion(Version.V_7_0_0); + .setOrigin("system"); } } diff --git a/server/src/test/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceTests.java b/server/src/test/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceTests.java index 14536e76f3c04..795c3782ac47c 100644 --- a/server/src/test/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/indices/SystemIndexMappingUpdateServiceTests.java @@ -74,7 +74,6 @@ public class SystemIndexMappingUpdateServiceTests extends ESTestCase { .setIndexFormat(6) .setSettings(getSettings()) .setMappings(getMappings()) - .setVersionMetaKey("version") .setOrigin("FAKE_ORIGIN") .build(); @@ -103,7 +102,6 @@ public void testManagerSkipsDescriptorsThatAreNotManaged() { .setMappings(getMappings()) .setSettings(getSettings()) .setIndexFormat(6) - .setVersionMetaKey("version") .setOrigin("FAKE_ORIGIN") .build(); @@ -137,7 +135,6 @@ public void testManagerSkipsDescriptorsForIndicesThatDoNotExist() { .setMappings(getMappings()) .setSettings(getSettings()) .setIndexFormat(6) - .setVersionMetaKey("version") .setOrigin("FAKE_ORIGIN") .build(); SystemIndexDescriptor d2 = SystemIndexDescriptor.builder() @@ -146,7 +143,6 @@ public void testManagerSkipsDescriptorsForIndicesThatDoNotExist() { .setMappings(getMappings()) .setSettings(getSettings()) .setIndexFormat(6) - .setVersionMetaKey("version") .setOrigin("FAKE_ORIGIN") .build(); diff --git a/server/src/test/java/org/elasticsearch/indices/SystemIndicesTests.java b/server/src/test/java/org/elasticsearch/indices/SystemIndicesTests.java index 77f3d75015d0d..dfcb1c0f1db9b 100644 --- a/server/src/test/java/org/elasticsearch/indices/SystemIndicesTests.java +++ b/server/src/test/java/org/elasticsearch/indices/SystemIndicesTests.java @@ -263,7 +263,6 @@ public void testMappingsVersions() { SystemIndexDescriptor managed = SystemIndexDescriptor.builder() .setIndexPattern(".managed-*") .setPrimaryIndex(".managed-primary") - .setVersionMetaKey("version") .setOrigin("system") .setSettings(Settings.EMPTY) .setMappings(""" diff --git a/server/src/test/java/org/elasticsearch/reservedstate/service/ReservedClusterStateServiceTests.java b/server/src/test/java/org/elasticsearch/reservedstate/service/ReservedClusterStateServiceTests.java index 5c7dd6cb346b9..efe3566064170 100644 --- a/server/src/test/java/org/elasticsearch/reservedstate/service/ReservedClusterStateServiceTests.java +++ b/server/src/test/java/org/elasticsearch/reservedstate/service/ReservedClusterStateServiceTests.java @@ -26,6 +26,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.core.Releasable; import org.elasticsearch.env.BuildVersion; +import org.elasticsearch.env.BuildVersionTests; import org.elasticsearch.reservedstate.ReservedClusterStateHandler; import org.elasticsearch.reservedstate.TransformState; import org.elasticsearch.reservedstate.action.ReservedClusterSettingsAction; @@ -519,7 +520,7 @@ public void testCheckMetadataVersion() { task = new ReservedStateUpdateTask( "test", - new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, BuildVersion.fromVersionId(BuildVersion.current().id() + 1))), + new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, BuildVersionTests.increment(BuildVersion.current()))), ReservedStateVersionCheck.HIGHER_VERSION_ONLY, Map.of(), List.of(), @@ -529,7 +530,7 @@ public void testCheckMetadataVersion() { assertThat("Cluster state should not be modified", task.execute(state), sameInstance(state)); task = new ReservedStateUpdateTask( "test", - new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, BuildVersion.fromVersionId(BuildVersion.current().id() + 1))), + new ReservedStateChunk(Map.of(), new ReservedStateVersion(124L, BuildVersionTests.increment(BuildVersion.current()))), ReservedStateVersionCheck.HIGHER_OR_SAME_VERSION, Map.of(), List.of(), diff --git a/test/framework/src/main/java/org/elasticsearch/common/logging/JsonLogsIntegTestCase.java b/test/framework/src/main/java/org/elasticsearch/common/logging/JsonLogsIntegTestCase.java index 2643959a559fa..4ba2b983fb9cc 100644 --- a/test/framework/src/main/java/org/elasticsearch/common/logging/JsonLogsIntegTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/common/logging/JsonLogsIntegTestCase.java @@ -9,14 +9,14 @@ package org.elasticsearch.common.logging; -import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.xcontent.ObjectParser; import java.io.BufferedReader; import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.stream.Stream; @@ -50,18 +50,21 @@ public abstract class JsonLogsIntegTestCase extends ESRestTestCase { */ protected abstract org.hamcrest.Matcher nodeNameMatcher(); + private BufferedReader openReader() { + return new BufferedReader(new InputStreamReader(openLogsStream(), StandardCharsets.UTF_8)); + } + /** - * Open the log file. This is delegated to subclasses because the test - * framework doesn't have permission to read from the log file but - * subclasses can grant themselves that permission. + * Reads the logs. + * This is delegated to subclasses because they configure the cluster and have access to the nodes logs InputStream. */ - protected abstract BufferedReader openReader(Path logFile); + protected abstract InputStream openLogsStream(); public void testElementsPresentOnAllLinesOfLog() throws IOException { JsonLogLine firstLine = findFirstLine(); assertNotNull(firstLine); - try (Stream stream = JsonLogsStream.from(openReader(getLogFile()), getParser())) { + try (Stream stream = JsonLogsStream.from(openReader(), getParser())) { stream.limit(LINES_TO_CHECK).forEach(jsonLogLine -> { assertThat(jsonLogLine.getDataset(), is(not(emptyOrNullString()))); assertThat(jsonLogLine.getTimestamp(), is(not(emptyOrNullString()))); @@ -77,13 +80,13 @@ public void testElementsPresentOnAllLinesOfLog() throws IOException { } private JsonLogLine findFirstLine() throws IOException { - try (Stream stream = JsonLogsStream.from(openReader(getLogFile()), getParser())) { + try (Stream stream = JsonLogsStream.from(openReader(), getParser())) { return stream.findFirst().orElseThrow(() -> new AssertionError("no logs at all?!")); } } public void testNodeIdAndClusterIdConsistentOnceAvailable() throws IOException { - try (Stream stream = JsonLogsStream.from(openReader(getLogFile()), getParser())) { + try (Stream stream = JsonLogsStream.from(openReader(), getParser())) { Iterator iterator = stream.iterator(); JsonLogLine firstLine = null; @@ -91,6 +94,7 @@ public void testNodeIdAndClusterIdConsistentOnceAvailable() throws IOException { JsonLogLine jsonLogLine = iterator.next(); if (jsonLogLine.getNodeId() != null) { firstLine = jsonLogLine; + break; } } assertNotNull(firstLine); @@ -106,23 +110,6 @@ public void testNodeIdAndClusterIdConsistentOnceAvailable() throws IOException { } } - @SuppressForbidden(reason = "PathUtils doesn't have permission to read this file") - private Path getLogFile() { - String logFileString = getLogFileName(); - if (logFileString == null) { - fail( - "tests.logfile must be set to run this test. It is automatically " - + "set by gradle. If you must set it yourself then it should be the absolute path to the " - + "log file." - ); - } - return Paths.get(logFileString); - } - - protected String getLogFileName() { - return System.getProperty("tests.logfile"); - } - protected ObjectParser getParser() { return JsonLogLine.ECS_LOG_LINE; } diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java index 6a975a2a08518..ec1bf13bd993b 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java @@ -51,6 +51,7 @@ import java.util.Map; import java.util.Properties; import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; @@ -130,7 +131,7 @@ public Node( this.distributionResolver = distributionResolver; this.spec = spec; this.name = suffix == null ? spec.getName() : spec.getName() + "-" + suffix; - this.workingDir = baseWorkingDir.resolve(name); + this.workingDir = baseWorkingDir.resolve(name != null ? name : UUID.randomUUID().toString()); this.repoDir = baseWorkingDir.resolve("repo"); this.dataDir = workingDir.resolve("data"); this.logsDir = workingDir.resolve("logs"); @@ -386,7 +387,9 @@ private void writeConfiguration() { // Write settings to elasticsearch.yml Map finalSettings = new HashMap<>(); finalSettings.put("cluster.name", spec.getCluster().getName()); - finalSettings.put("node.name", name); + if (name != null) { + finalSettings.put("node.name", name); + } finalSettings.put("path.repo", repoDir.toString()); finalSettings.put("path.data", dataDir.toString()); finalSettings.put("path.logs", logsDir.toString()); diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterSpecBuilder.java index fd49d3ab8c4e4..7f1a384ebb43d 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterSpecBuilder.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterSpecBuilder.java @@ -18,7 +18,9 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Optional; +import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; import java.util.function.Supplier; @@ -141,9 +143,10 @@ protected LocalClusterSpec buildClusterSpec() { if (nodeBuilders.isEmpty()) { // No node-specific configuration so assume a single-node cluster - nodeSpecs = List.of(new DefaultLocalNodeSpecBuilder(this).build(clusterSpec)); + nodeSpecs = List.of(new DefaultLocalNodeSpecBuilder(this).build(clusterSpec, 0)); } else { - nodeSpecs = nodeBuilders.stream().map(node -> node.build(clusterSpec)).toList(); + AtomicInteger nodeIndex = new AtomicInteger(0); + nodeSpecs = nodeBuilders.stream().map(node -> node.build(clusterSpec, nodeIndex.getAndIncrement())).toList(); } clusterSpec.setNodes(nodeSpecs); @@ -154,6 +157,7 @@ protected LocalClusterSpec buildClusterSpec() { public static class DefaultLocalNodeSpecBuilder extends AbstractLocalSpecBuilder implements LocalNodeSpecBuilder { private String name; + private boolean unsetName = false; protected DefaultLocalNodeSpecBuilder(AbstractLocalSpecBuilder parent) { super(parent); @@ -161,15 +165,37 @@ protected DefaultLocalNodeSpecBuilder(AbstractLocalSpecBuilder parent) { @Override public DefaultLocalNodeSpecBuilder name(String name) { - this.name = name; + if (unsetName) { + throw new IllegalStateException("Cannot set name when 'withoutName()` has been used"); + } + this.name = Objects.requireNonNull( + name, + "Name cannot be set to null. Consider using '.withoutName()' method if you need node without explicitly set name" + ); return this; } - private LocalNodeSpec build(LocalClusterSpec cluster) { + @Override + public DefaultLocalNodeSpecBuilder withoutName() { + if (name != null) { + throw new IllegalStateException("Cannot use 'withoutName()', because name has been set for the node"); + } + this.unsetName = true; + return this; + } + + private String resolveName(LocalClusterSpec cluster, int nodeIndex) { + if (unsetName) { + return null; + } + return name == null ? cluster.getName() + "-" + nodeIndex : name; + } + + private LocalNodeSpec build(LocalClusterSpec cluster, int nodeIndex) { return new LocalNodeSpec( cluster, - name, + resolveName(cluster, nodeIndex), Optional.ofNullable(getVersion()).orElse(Version.CURRENT), getSettingsProviders(), getSettings(), diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java index 98e6919f95d0c..67d19895ccc30 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/DefaultSettingsProvider.java @@ -15,9 +15,14 @@ import java.util.HashMap; import java.util.Map; +import java.util.Objects; import java.util.stream.Collectors; public class DefaultSettingsProvider implements SettingsProvider { + + private static final String MULTI_NODE_DISCOVERY_TYPE = "multi-node"; + private static final String DISCOVERY_TYPE_SETTING = "discovery.type"; + @Override public Map get(LocalNodeSpec nodeSpec) { Map settings = new HashMap<>(); @@ -70,18 +75,29 @@ public Map get(LocalNodeSpec nodeSpec) { .stream() .filter(LocalNodeSpec::isMasterEligible) .map(LocalNodeSpec::getName) + .filter(Objects::nonNull) .collect(Collectors.joining(",")); - if (masterEligibleNodes.isEmpty()) { - throw new IllegalStateException( - "Cannot start cluster '" + nodeSpec.getCluster().getName() + "' as it configured with no master-eligible nodes." - ); - } + if (isMultiNodeCluster(nodeSpec.getCluster())) { + if (masterEligibleNodes.isEmpty()) { + throw new IllegalStateException( + "Cannot start multi-node cluster '" + nodeSpec.getCluster().getName() + "' as configured with no master-eligible nodes." + ); + } - settings.put("cluster.initial_master_nodes", "[" + masterEligibleNodes + "]"); - settings.put("discovery.seed_providers", "file"); - settings.put("discovery.seed_hosts", "[]"); + settings.put("cluster.initial_master_nodes", "[" + masterEligibleNodes + "]"); + settings.put("discovery.seed_providers", "file"); + settings.put("discovery.seed_hosts", "[]"); + } return settings; } + + private boolean isMultiNodeCluster(LocalClusterSpec cluster) { + return cluster.getNodes().size() > 1 + || cluster.getNodes() + .getFirst() + .getSetting(DISCOVERY_TYPE_SETTING, MULTI_NODE_DISCOVERY_TYPE) + .equals(MULTI_NODE_DISCOVERY_TYPE); + } } diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java index d89540d25c6cd..02fdb45dffa37 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -155,7 +156,7 @@ public LocalClusterSpec getCluster() { } public String getName() { - return name == null ? cluster.getName() + "-" + cluster.getNodes().indexOf(this) : name; + return name; } public Version getVersion() { @@ -345,7 +346,7 @@ private LocalNodeSpec getFilteredSpec(SettingsProvider filteredProvider, Setting newCluster.setNodes(nodeSpecs); - return nodeSpecs.stream().filter(n -> n.getName().equals(this.getName())).findFirst().get(); + return nodeSpecs.stream().filter(n -> Objects.equals(n.getName(), this.getName())).findFirst().get(); } } } diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java index 7992c34dc153f..b01b50d24f5e7 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalNodeSpecBuilder.java @@ -15,4 +15,9 @@ public interface LocalNodeSpecBuilder extends LocalSpecBuilder indices, Metadata @Override public void snapshotShard(SnapshotShardContext context) { final MapperService mapperService = context.mapperService(); - if (mapperService.documentMapper() != null // if there is no mapping this is null - && mapperService.documentMapper().sourceMapper().isComplete() == false) { + if ((mapperService.documentMapper() != null // if there is no mapping this is null + && mapperService.documentMapper().sourceMapper().isComplete() == false) + || (mapperService.documentMapper() == null && SourceFieldMapper.isStored(mapperService.getIndexSettings()) == false)) { context.onFailure( new IllegalStateException( "Can't snapshot _source only on an index that has incomplete source ie. has _source disabled or filters the source" diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/AsyncTaskIndexService.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/AsyncTaskIndexService.java index e44af60a45e08..fe970bef87145 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/AsyncTaskIndexService.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/async/AsyncTaskIndexService.java @@ -144,7 +144,6 @@ public static SystemIndexDescriptor getSystemIndexDescriptor() { .setPrimaryIndex(XPackPlugin.ASYNC_RESULTS_INDEX) .setMappings(mappings()) .setSettings(settings()) - .setVersionMetaKey("version") .setOrigin(ASYNC_SEARCH_ORIGIN) .build(); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java index 54390365c62af..81d194ce84131 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/snapshots/sourceonly/SourceOnlySnapshotShardTests.java @@ -53,6 +53,7 @@ import org.elasticsearch.index.engine.InternalEngineFactory; import org.elasticsearch.index.fieldvisitor.FieldsVisitor; import org.elasticsearch.index.mapper.SeqNoFieldMapper; +import org.elasticsearch.index.mapper.SourceFieldMapper; import org.elasticsearch.index.mapper.SourceToParse; import org.elasticsearch.index.seqno.RetentionLeaseSyncer; import org.elasticsearch.index.seqno.SeqNoStats; @@ -150,6 +151,55 @@ public void testSourceIncomplete() throws IOException { closeShards(shard); } + public void testSourceIncompleteSyntheticSourceNoDoc() throws IOException { + ShardRouting shardRouting = shardRoutingBuilder( + new ShardId("index", "_na_", 0), + randomAlphaOfLength(10), + true, + ShardRoutingState.INITIALIZING + ).withRecoverySource(RecoverySource.EmptyStoreRecoverySource.INSTANCE).build(); + Settings settings = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0) + .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1) + .put(SourceFieldMapper.INDEX_MAPPER_SOURCE_MODE_SETTING.getKey(), "synthetic") + .build(); + IndexMetadata metadata = IndexMetadata.builder(shardRouting.getIndexName()).settings(settings).primaryTerm(0, primaryTerm).build(); + IndexShard shard = newShard(shardRouting, metadata, null, new InternalEngineFactory()); + recoverShardFromStore(shard); + SnapshotId snapshotId = new SnapshotId("test", "test"); + IndexId indexId = new IndexId(shard.shardId().getIndexName(), shard.shardId().getIndex().getUUID()); + SourceOnlySnapshotRepository repository = new SourceOnlySnapshotRepository(createRepository()); + repository.start(); + try (Engine.IndexCommitRef snapshotRef = shard.acquireLastIndexCommit(true)) { + IndexShardSnapshotStatus indexShardSnapshotStatus = IndexShardSnapshotStatus.newInitializing(new ShardGeneration(-1L)); + final PlainActionFuture future = new PlainActionFuture<>(); + runAsSnapshot( + shard.getThreadPool(), + () -> repository.snapshotShard( + new SnapshotShardContext( + shard.store(), + shard.mapperService(), + snapshotId, + indexId, + new SnapshotIndexCommit(snapshotRef), + null, + indexShardSnapshotStatus, + IndexVersion.current(), + randomMillisUpToYear9999(), + future + ) + ) + ); + IllegalStateException illegalStateException = expectThrows(IllegalStateException.class, future::actionGet); + assertEquals( + "Can't snapshot _source only on an index that has incomplete source ie. has _source disabled or filters the source", + illegalStateException.getMessage() + ); + } + closeShards(shard); + } + public void testIncrementalSnapshot() throws IOException { IndexShard shard = newStartedShard(); for (int i = 0; i < 10; i++) { diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java index 9e26444040b03..3848d785275d4 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/test/TestRestrictedIndices.java @@ -179,8 +179,7 @@ public class TestRestrictedIndices { private static SystemIndexDescriptor.Builder getInitializedDescriptorBuilder(int indexFormat) { return SystemIndexDescriptor.builder() .setMappings(mockMappings()) - .setSettings(Settings.builder().put(IndexMetadata.INDEX_FORMAT_SETTING.getKey(), indexFormat).build()) - .setVersionMetaKey("version"); + .setSettings(Settings.builder().put(IndexMetadata.INDEX_FORMAT_SETTING.getKey(), indexFormat).build()); } private static SystemIndexDescriptor getMainSecurityDescriptor() { diff --git a/x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle b/x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle index 0e6a4bc8357e7..e84adf0c0325d 100644 --- a/x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle +++ b/x-pack/plugin/ent-search/qa/full-cluster-restart/build.gradle @@ -13,7 +13,6 @@ apply plugin: 'elasticsearch.bwc-test' dependencies { - testImplementation project(path: xpackModule('ent-search')) javaRestTestImplementation(testArtifact(project(xpackModule('core')))) javaRestTestImplementation(testArtifact(project(":qa:full-cluster-restart"), "javaRestTest")) } diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/secrets/ConnectorSecretsIndexService.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/secrets/ConnectorSecretsIndexService.java index ba9a3e78281dd..7c26c2975d8ee 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/secrets/ConnectorSecretsIndexService.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/connector/secrets/ConnectorSecretsIndexService.java @@ -70,7 +70,6 @@ public static SystemIndexDescriptor getSystemIndexDescriptor() { .setMappings(request.mappings()) .setSettings(request.settings()) .setAliasName(CONNECTOR_SECRETS_INDEX_NAME) - .setVersionMetaKey("version") .setOrigin(CONNECTORS_ORIGIN) .setType(SystemIndexDescriptor.Type.INTERNAL_MANAGED) .build(); diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexService.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexService.java index 8bf4bbd5716b7..3ce51ae5d832d 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexService.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/rules/QueryRulesIndexService.java @@ -92,7 +92,6 @@ public static SystemIndexDescriptor getSystemIndexDescriptor() { .setSettings(getIndexSettings()) .setAliasName(QUERY_RULES_ALIAS_NAME) .setIndexFormat(QueryRulesIndexMappingVersion.latest().id) - .setVersionMetaKey("version") .setOrigin(ENT_SEARCH_ORIGIN) .setThreadPools(ExecutorNames.DEFAULT_SYSTEM_INDEX_THREAD_POOLS); diff --git a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java index 30d533aeb9ae5..2219a2bebbd25 100644 --- a/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java +++ b/x-pack/plugin/ent-search/src/main/java/org/elasticsearch/xpack/application/search/SearchApplicationIndexService.java @@ -130,7 +130,6 @@ public static SystemIndexDescriptor getSystemIndexDescriptor() { .setMappings(getIndexMappings()) .setSettings(getIndexSettings()) .setAliasName(SEARCH_APPLICATION_ALIAS_NAME) - .setVersionMetaKey("version") .setOrigin(ENT_SEARCH_ORIGIN) .setThreadPools(ExecutorNames.DEFAULT_SYSTEM_INDEX_THREAD_POOLS) .build(); diff --git a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TelemetryIT.java b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TelemetryIT.java index 325e8500295ea..25603acece3cb 100644 --- a/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TelemetryIT.java +++ b/x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/TelemetryIT.java @@ -128,20 +128,22 @@ public static Iterable parameters() { : Collections.emptyMap(), Build.current().isSnapshot() ? Map.ofEntries(Map.entry("MAX", 1)) : Collections.emptyMap(), Build.current().isSnapshot() - ) }, - new Object[] { - new Test( - """ - FROM idx - | EVAL ip = to_ip(host), x = to_string(host), y = to_string(host) - | INLINESTATS max(id) - """, - Build.current().isSnapshot() ? Map.of("FROM", 1, "EVAL", 1, "INLINESTATS", 1, "STATS", 1) : Collections.emptyMap(), - Build.current().isSnapshot() - ? Map.ofEntries(Map.entry("MAX", 1), Map.entry("TO_IP", 1), Map.entry("TO_STRING", 2)) - : Collections.emptyMap(), - Build.current().isSnapshot() ) } + // awaits fix for https://github.com/elastic/elasticsearch/issues/116003 + // , + // new Object[] { + // new Test( + // """ + // FROM idx + // | EVAL ip = to_ip(host), x = to_string(host), y = to_string(host) + // | INLINESTATS max(id) + // """, + // Build.current().isSnapshot() ? Map.of("FROM", 1, "EVAL", 1, "INLINESTATS", 1, "STATS", 1) : Collections.emptyMap(), + // Build.current().isSnapshot() + // ? Map.ofEntries(Map.entry("MAX", 1), Map.entry("TO_IP", 1), Map.entry("TO_STRING", 2)) + // : Collections.emptyMap(), + // Build.current().isSnapshot() + // ) } ); } diff --git a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviation.java b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviation.java index dfcbd6d22abae..42960cafdfd3a 100644 --- a/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviation.java +++ b/x-pack/plugin/esql/src/main/java/org/elasticsearch/xpack/esql/expression/function/aggregate/MedianAbsoluteDeviation.java @@ -58,7 +58,7 @@ public class MedianAbsoluteDeviation extends NumericAggregate implements Surroga examples = { @Example(file = "median_absolute_deviation", tag = "median-absolute-deviation"), @Example( - description = "The expression can use inline functions. For example, to calculate the the " + description = "The expression can use inline functions. For example, to calculate the " + "median absolute deviation of the maximum values of a multivalued column, first " + "use `MV_MAX` to get the maximum value per row, and use the result with the " + "`MEDIAN_ABSOLUTE_DEVIATION` function", diff --git a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java index 40e41cb18bdf8..138a07833e584 100644 --- a/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java +++ b/x-pack/plugin/fleet/src/main/java/org/elasticsearch/xpack/fleet/Fleet.java @@ -77,7 +77,6 @@ public class Fleet extends Plugin implements SystemIndexPlugin { public static final String FLEET_SECRETS_INDEX_NAME = ".fleet-secrets"; private static final int CURRENT_INDEX_VERSION = 7; - private static final String VERSION_KEY = "version"; private static final String MAPPING_VERSION_VARIABLE = "fleet.version"; private static final List ALLOWED_PRODUCTS = List.of("kibana", "fleet"); private static final int FLEET_ACTIONS_MAPPINGS_VERSION = 1; @@ -140,7 +139,6 @@ private static SystemIndexDescriptor fleetActionsSystemIndexDescriptor() { .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-actions-" + CURRENT_INDEX_VERSION) @@ -158,7 +156,6 @@ private static SystemIndexDescriptor fleetAgentsSystemIndexDescriptor() { .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-agents-" + CURRENT_INDEX_VERSION) @@ -179,7 +176,6 @@ private static SystemIndexDescriptor fleetEnrollmentApiKeysSystemIndexDescriptor .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-enrollment-api-keys-" + CURRENT_INDEX_VERSION) @@ -195,7 +191,6 @@ private static SystemIndexDescriptor fleetSecretsSystemIndexDescriptor() { return SystemIndexDescriptor.builder() .setType(Type.INTERNAL_MANAGED) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(FLEET_SECRETS_INDEX_NAME + "-" + CURRENT_INDEX_VERSION) @@ -213,7 +208,6 @@ private static SystemIndexDescriptor fleetPoliciesSystemIndexDescriptor() { .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-policies-" + CURRENT_INDEX_VERSION) @@ -231,7 +225,6 @@ private static SystemIndexDescriptor fleetPoliciesLeaderSystemIndexDescriptor() .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-policies-leader-" + CURRENT_INDEX_VERSION) @@ -249,7 +242,6 @@ private static SystemIndexDescriptor fleetServersSystemIndexDescriptors() { .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-servers-" + CURRENT_INDEX_VERSION) @@ -267,7 +259,6 @@ private static SystemIndexDescriptor fleetArtifactsSystemIndexDescriptors() { .setType(Type.EXTERNAL_MANAGED) .setAllowedElasticProductOrigins(ALLOWED_PRODUCTS) .setOrigin(FLEET_ORIGIN) - .setVersionMetaKey(VERSION_KEY) .setMappings(request.mappings()) .setSettings(request.settings()) .setPrimaryIndex(".fleet-artifacts-" + CURRENT_INDEX_VERSION) diff --git a/x-pack/plugin/inference/qa/inference-service-tests/build.gradle b/x-pack/plugin/inference/qa/inference-service-tests/build.gradle index f87f5cb8377c5..422f498082313 100644 --- a/x-pack/plugin/inference/qa/inference-service-tests/build.gradle +++ b/x-pack/plugin/inference/qa/inference-service-tests/build.gradle @@ -1,7 +1,6 @@ apply plugin: 'elasticsearch.internal-java-rest-test' dependencies { - compileOnly project(':x-pack:plugin:core') javaRestTestImplementation project(path: xpackModule('inference')) clusterPlugins project(':x-pack:plugin:inference:qa:test-service-plugin') } diff --git a/x-pack/plugin/inference/qa/mixed-cluster/build.gradle b/x-pack/plugin/inference/qa/mixed-cluster/build.gradle index 0bc4813f25137..64edb196397a0 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/build.gradle +++ b/x-pack/plugin/inference/qa/mixed-cluster/build.gradle @@ -1,6 +1,5 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionProperties -import org.elasticsearch.gradle.util.GradleUtils import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask @@ -9,8 +8,6 @@ apply plugin: 'elasticsearch.internal-test-artifact-base' apply plugin: 'elasticsearch.bwc-test' dependencies { - testImplementation project(path: ':x-pack:plugin:inference:qa:inference-service-tests') - compileOnly project(':x-pack:plugin:core') javaRestTestImplementation(testArtifact(project(xpackModule('core')))) javaRestTestImplementation project(path: xpackModule('inference')) clusterPlugins project( diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/build.gradle b/x-pack/plugin/inference/qa/rolling-upgrade/build.gradle index e1887567a8516..5d72fc96d98d8 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/build.gradle +++ b/x-pack/plugin/inference/qa/rolling-upgrade/build.gradle @@ -5,8 +5,6 @@ * 2.0. */ -import org.elasticsearch.gradle.Version -import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.internal.info.BuildParams import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask @@ -16,7 +14,6 @@ apply plugin: 'elasticsearch.bwc-test' dependencies { - compileOnly project(':x-pack:plugin:core') javaRestTestImplementation(testArtifact(project(xpackModule('core')))) javaRestTestImplementation project(path: xpackModule('inference')) javaRestTestImplementation(testArtifact(project(":qa:rolling-upgrade"), "javaRestTest")) diff --git a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java index 0450400e5ca8b..3ad1e626481bc 100644 --- a/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java +++ b/x-pack/plugin/inference/src/main/java/org/elasticsearch/xpack/inference/InferencePlugin.java @@ -288,7 +288,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Contains inference service and model configuration") .setMappings(InferenceIndex.mappingsV1()) .setSettings(InferenceIndex.settings()) - .setVersionMetaKey("version") .setOrigin(ClientHelper.INFERENCE_ORIGIN) .build(); @@ -301,7 +300,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Contains inference service and model configuration") .setMappings(InferenceIndex.mappings()) .setSettings(InferenceIndex.settings()) - .setVersionMetaKey("version") .setOrigin(ClientHelper.INFERENCE_ORIGIN) .setPriorSystemIndexDescriptors(List.of(inferenceIndexV1Descriptor)) .build(), @@ -312,7 +310,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Contains inference service secrets") .setMappings(InferenceSecretsIndex.mappings()) .setSettings(InferenceSecretsIndex.settings()) - .setVersionMetaKey("version") .setOrigin(ClientHelper.INFERENCE_ORIGIN) .setNetNew() .build() diff --git a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java index 819f41781a307..15582e2b74768 100644 --- a/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java +++ b/x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java @@ -102,7 +102,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Contains data for Logstash Central Management") .setMappings(getIndexMappings()) .setSettings(getIndexSettings()) - .setVersionMetaKey("logstash-version") .setOrigin(LOGSTASH_MANAGEMENT_ORIGIN) .build() ); diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java index 6d21654f9e161..1feb95661f33a 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java @@ -1980,7 +1980,6 @@ public Collection getSystemIndexDescriptors(Settings unus .setDescription("Contains scheduling and anomaly tracking metadata") .setMappings(MlMetaIndex.mapping()) .setSettings(MlMetaIndex.settings()) - .setVersionMetaKey("version") .setOrigin(ML_ORIGIN) .build(), SystemIndexDescriptor.builder() @@ -1989,7 +1988,6 @@ public Collection getSystemIndexDescriptors(Settings unus .setDescription("Contains ML configuration data") .setMappings(MlConfigIndex.mapping()) .setSettings(MlConfigIndex.settings()) - .setVersionMetaKey("version") .setOrigin(ML_ORIGIN) .build(), getInferenceIndexSystemIndexDescriptor() @@ -2003,7 +2001,6 @@ public static SystemIndexDescriptor getInferenceIndexSystemIndexDescriptor() { .setDescription("Contains ML model configuration and statistics") .setMappings(InferenceIndexConstants.mapping()) .setSettings(InferenceIndexConstants.settings()) - .setVersionMetaKey("version") .setOrigin(ML_ORIGIN) .build(); } diff --git a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java index 5ac8cdb43aa33..eabdf7c9bf46c 100644 --- a/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java +++ b/x-pack/plugin/searchable-snapshots/src/main/java/org/elasticsearch/xpack/searchablesnapshots/SearchableSnapshots.java @@ -397,7 +397,6 @@ public Collection getSystemIndexDescriptors(Settings unus .setMappings(getIndexMappings()) .setSettings(getIndexSettings()) .setOrigin(SEARCHABLE_SNAPSHOTS_ORIGIN) - .setVersionMetaKey("version") .build() ); } diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecuritySystemIndices.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecuritySystemIndices.java index 77c7d19e94a9b..609e6696bcb0f 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecuritySystemIndices.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/support/SecuritySystemIndices.java @@ -143,7 +143,6 @@ private SystemIndexDescriptor getSecurityMainIndexDescriptor() { .setSettings(getMainIndexSettings()) .setAliasName(SECURITY_MAIN_ALIAS) .setIndexFormat(INTERNAL_MAIN_INDEX_FORMAT) - .setVersionMetaKey(SECURITY_VERSION_STRING) .setOrigin(SECURITY_ORIGIN) .setThreadPools(ExecutorNames.CRITICAL_SYSTEM_INDEX_THREAD_POOLS); @@ -695,7 +694,6 @@ private static SystemIndexDescriptor getSecurityTokenIndexDescriptor() { .setSettings(getTokenIndexSettings()) .setAliasName(SECURITY_TOKENS_ALIAS) .setIndexFormat(INTERNAL_TOKENS_INDEX_FORMAT) - .setVersionMetaKey(SECURITY_VERSION_STRING) .setOrigin(SECURITY_ORIGIN) .setThreadPools(ExecutorNames.CRITICAL_SYSTEM_INDEX_THREAD_POOLS) .build(); @@ -879,10 +877,8 @@ private SystemIndexDescriptor getSecurityProfileIndexDescriptor(Settings setting .setSettings(getProfileIndexSettings(settings)) .setAliasName(SECURITY_PROFILE_ALIAS) .setIndexFormat(INTERNAL_PROFILE_INDEX_FORMAT) - .setVersionMetaKey(SECURITY_VERSION_STRING) .setOrigin(SECURITY_PROFILE_ORIGIN) // new origin since 8.3 .setThreadPools(ExecutorNames.CRITICAL_SYSTEM_INDEX_THREAD_POOLS) - .setMinimumNodeVersion(VERSION_SECURITY_PROFILE_ORIGIN) .setPriorSystemIndexDescriptors( List.of( SystemIndexDescriptor.builder() @@ -893,7 +889,6 @@ private SystemIndexDescriptor getSecurityProfileIndexDescriptor(Settings setting .setSettings(getProfileIndexSettings(settings)) .setAliasName(SECURITY_PROFILE_ALIAS) .setIndexFormat(INTERNAL_PROFILE_INDEX_FORMAT) - .setVersionMetaKey(SECURITY_VERSION_STRING) .setOrigin(SECURITY_ORIGIN) .setThreadPools(ExecutorNames.CRITICAL_SYSTEM_INDEX_THREAD_POOLS) .build() diff --git a/x-pack/plugin/transform/qa/common/build.gradle b/x-pack/plugin/transform/qa/common/build.gradle index 28e4068d31c6b..d14ff07e916ab 100644 --- a/x-pack/plugin/transform/qa/common/build.gradle +++ b/x-pack/plugin/transform/qa/common/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'elasticsearch.internal-java-rest-test' +apply plugin: 'elasticsearch.java' dependencies { api project(':libs:x-content') diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformInternalIndex.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformInternalIndex.java index e2f9af2c676ce..14e9292d10fd1 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformInternalIndex.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/persistence/TransformInternalIndex.java @@ -111,7 +111,6 @@ public static SystemIndexDescriptor getSystemIndexDescriptor(Settings transformI .setDescription("Contains Transform configuration data") .setMappings(mappings()) .setSettings(settings(transformInternalIndexAdditionalSettings)) - .setVersionMetaKey("version") .setOrigin(TRANSFORM_ORIGIN) .build(); } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index f6f8d3f336e21..cd965bb677526 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -802,7 +802,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Contains Watch definitions") .setMappings(getWatchesIndexMappings()) .setSettings(getWatchesIndexSettings()) - .setVersionMetaKey("version") .setOrigin(WATCHER_ORIGIN) .setIndexFormat(6) .build(), @@ -812,7 +811,6 @@ public Collection getSystemIndexDescriptors(Settings sett .setDescription("Used to track current and queued Watch execution") .setMappings(getTriggeredWatchesIndexMappings()) .setSettings(getTriggeredWatchesIndexSettings()) - .setVersionMetaKey("version") .setOrigin(WATCHER_ORIGIN) .setIndexFormat(6) .build()