From b67a9e1ec3b2735f9e753a43fa59456a0bcc2ad1 Mon Sep 17 00:00:00 2001 From: Simon Cooper Date: Wed, 23 Aug 2023 10:51:56 +0100 Subject: [PATCH] Move text references to index created version to IndexVersion (#98727) --- .../index/mapper/MapperServiceFactory.java | 4 ++-- .../routing/allocation/AllocationBenchmark.java | 4 ++-- ...ShardsAvailabilityHealthIndicatorBenchmark.java | 4 ++-- .../search/QueryParserHelperBenchmark.java | 4 ++-- .../AbstractFeatureMigrationIntegTest.java | 2 +- .../migration/FeatureMigrationIT.java | 2 +- .../example/CustomAuthorizationEngineTests.java | 4 ++-- .../upgrades/FullClusterRestartIT.java | 5 +++-- .../org/elasticsearch/upgrades/RecoveryIT.java | 11 ++++++----- .../upgrades/SystemIndicesUpgradeIT.java | 7 ++++--- .../upgrades/SystemIndexMigrationInfo.java | 2 +- .../action/bulk/TransportBulkActionTests.java | 2 +- .../metadata/MetadataCreateIndexServiceTests.java | 7 +++---- .../metadata/MetadataDeleteIndexServiceTests.java | 5 ++--- .../metadata/MetadataIndexAliasesServiceTests.java | 4 ++-- .../env/NodeRepurposeCommandTests.java | 4 ++-- .../elasticsearch/index/IndexSettingsTests.java | 5 ++--- .../index/IndexSortSettingsTests.java | 3 +-- .../PersistentTasksClusterServiceTests.java | 6 +++--- .../index/mapper/MapperServiceTestCase.java | 7 ++++--- .../authz/store/ReservedRolesStoreTests.java | 5 +++-- .../xpack/ilm/PolicyStepsRegistryTests.java | 5 ++--- .../security/authz/AuthorizationServiceTests.java | 14 +++++++------- .../security/authz/AuthorizedIndicesTests.java | 12 ++++++------ .../accesscontrol/IndicesPermissionTests.java | 9 ++++----- .../authz/store/CompositeRolesStoreTests.java | 8 +++----- .../DeprecationRoleDescriptorConsumerTests.java | 4 ++-- 27 files changed, 73 insertions(+), 76 deletions(-) diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/index/mapper/MapperServiceFactory.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/index/mapper/MapperServiceFactory.java index 96c99648e356d..aabd1ac3f7a1b 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/index/mapper/MapperServiceFactory.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/index/mapper/MapperServiceFactory.java @@ -10,13 +10,13 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.compress.CompressedXContent; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.analysis.AnalyzerScope; import org.elasticsearch.index.analysis.IndexAnalyzers; import org.elasticsearch.index.analysis.LowercaseNormalizer; @@ -44,7 +44,7 @@ public static MapperService create(String mappings) { Settings settings = Settings.builder() .put("index.number_of_replicas", 0) .put("index.number_of_shards", 1) - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put("index.mapping.total_fields.limit", 10000) .build(); IndexMetadata meta = IndexMetadata.builder("index").settings(settings).build(); diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java index 24ebbb89bf57f..a2f91f771290a 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java @@ -8,7 +8,6 @@ package org.elasticsearch.benchmark.routing.allocation; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -19,6 +18,7 @@ import org.elasticsearch.cluster.routing.ShardRouting; import org.elasticsearch.cluster.routing.allocation.AllocationService; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexVersion; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -128,7 +128,7 @@ public void setUp() throws Exception { for (int i = 1; i <= numIndices; i++) { mb.put( IndexMetadata.builder("test_" + i) - .settings(Settings.builder().put("index.version.created", Version.CURRENT)) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())) .numberOfShards(numShards) .numberOfReplicas(numReplicas) ); diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java index ec903186fc540..30b37c018af01 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/ShardsAvailabilityHealthIndicatorBenchmark.java @@ -8,7 +8,6 @@ package org.elasticsearch.benchmark.routing.allocation; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.metadata.IndexMetadata; @@ -28,6 +27,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.health.HealthIndicatorResult; import org.elasticsearch.health.node.HealthInfo; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.SystemIndices; import org.elasticsearch.tasks.TaskManager; @@ -121,7 +121,7 @@ public void setUp() throws Exception { IndexMetadata indexMetadata = IndexMetadata.builder("test_" + i) .settings( Settings.builder() - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(DataTier.TIER_PREFERENCE_SETTING.getKey(), "data_warm") .put(INDEX_ROUTING_REQUIRE_GROUP_SETTING.getKey() + "data", "warm") ) diff --git a/benchmarks/src/main/java/org/elasticsearch/benchmark/search/QueryParserHelperBenchmark.java b/benchmarks/src/main/java/org/elasticsearch/benchmark/search/QueryParserHelperBenchmark.java index e3990151e1149..6aacf319e6b8b 100644 --- a/benchmarks/src/main/java/org/elasticsearch/benchmark/search/QueryParserHelperBenchmark.java +++ b/benchmarks/src/main/java/org/elasticsearch/benchmark/search/QueryParserHelperBenchmark.java @@ -17,7 +17,6 @@ import org.apache.lucene.store.ByteBuffersDirectory; import org.apache.lucene.store.Directory; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.bytes.BytesArray; @@ -28,6 +27,7 @@ import org.elasticsearch.common.xcontent.LoggingDeprecationHandler; import org.elasticsearch.core.IOUtils; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.mapper.MapperRegistry; import org.elasticsearch.index.mapper.MapperService; @@ -163,7 +163,7 @@ protected final MapperService createMapperService(String mappings) { Settings settings = Settings.builder() .put("index.number_of_replicas", 0) .put("index.number_of_shards", 1) - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .build(); IndexMetadata meta = IndexMetadata.builder("index").settings(settings).build(); IndexSettings indexSettings = new IndexSettings(meta, settings); 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 a8e8e7bc935ee..087cc31c5377b 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java @@ -179,7 +179,7 @@ public void createSystemIndexForDescriptor(SystemIndexDescriptor descriptor) thr // managed createRequest.setSettings( Settings.builder() - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .build() ); diff --git a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java index 4658298477995..14647820e71f6 100644 --- a/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java +++ b/modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/FeatureMigrationIT.java @@ -124,7 +124,7 @@ public void testMigrateInternalManagedSystemIndex() throws Exception { createRequest.setWaitForActiveShards(ActiveShardCount.ALL); createRequest.setSettings( Settings.builder() - .put("index.version.created", NEEDS_UPGRADE_VERSION) + .put(IndexMetadata.SETTING_VERSION_CREATED, NEEDS_UPGRADE_INDEX_VERSION) .put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0) .put("index.hidden", true) // So we don't get a warning .build() diff --git a/plugins/examples/security-authorization-engine/src/test/java/org/elasticsearch/example/CustomAuthorizationEngineTests.java b/plugins/examples/security-authorization-engine/src/test/java/org/elasticsearch/example/CustomAuthorizationEngineTests.java index a56491164f138..4f14771007fa4 100644 --- a/plugins/examples/security-authorization-engine/src/test/java/org/elasticsearch/example/CustomAuthorizationEngineTests.java +++ b/plugins/examples/security-authorization-engine/src/test/java/org/elasticsearch/example/CustomAuthorizationEngineTests.java @@ -8,13 +8,13 @@ package org.elasticsearch.example; -import org.elasticsearch.Version; import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.support.PlainActionFuture; import org.elasticsearch.cluster.metadata.IndexAbstraction; import org.elasticsearch.cluster.metadata.IndexAbstraction.ConcreteIndex; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.xpack.core.security.authc.Authentication; @@ -118,7 +118,7 @@ public void testAuthorizeIndexAction() { CustomAuthorizationEngine engine = new CustomAuthorizationEngine(); Map indicesMap = new HashMap<>(); indicesMap.put("index", new ConcreteIndex(IndexMetadata.builder("index") - .settings(Settings.builder().put("index.version.created", Version.CURRENT)) + .settings(Settings.builder().put("index.version.created", IndexVersion.current())) .numberOfShards(1) .numberOfReplicas(0) .build(), null)); diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index 5ef9a48a200a3..1ee07a08d2f06 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -67,6 +67,7 @@ import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static java.util.stream.Collectors.toList; +import static org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SYSTEM_INDEX_ENFORCEMENT_INDEX_VERSION; import static org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SYSTEM_INDEX_ENFORCEMENT_VERSION; import static org.elasticsearch.cluster.routing.UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING; import static org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY; @@ -1730,8 +1731,8 @@ public void testSystemIndexMetadataIsUpgraded() throws Exception { // If .tasks was created in a 7.x version, it should have an alias on it that we need to make sure got upgraded properly. final String tasksCreatedVersionString = tasksIndex.get("settings.index.version.created"); assertThat(tasksCreatedVersionString, notNullValue()); - final Version tasksCreatedVersion = Version.fromId(Integer.parseInt(tasksCreatedVersionString)); - if (tasksCreatedVersion.before(SYSTEM_INDEX_ENFORCEMENT_VERSION)) { + final IndexVersion tasksCreatedVersion = IndexVersion.fromId(Integer.parseInt(tasksCreatedVersionString)); + if (tasksCreatedVersion.before(SYSTEM_INDEX_ENFORCEMENT_INDEX_VERSION)) { // Verify that the alias survived the upgrade Request getAliasRequest = new Request("GET", "/_alias/test-system-alias"); getAliasRequest.setOptions(expectVersionSpecificWarnings(v -> { diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java index ca072e8c2e973..39700514cd79f 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/RecoveryIT.java @@ -22,6 +22,7 @@ import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.core.Booleans; import org.elasticsearch.index.IndexSettings; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.rest.ObjectPath; import org.hamcrest.Matchers; @@ -427,8 +428,8 @@ public void testRecoveryClosedIndex() throws Exception { closeIndex(indexName); } - final Version indexVersionCreated = indexVersionCreated(indexName); - if (indexVersionCreated.onOrAfter(Version.V_7_2_0)) { + final IndexVersion indexVersionCreated = indexVersionCreated(indexName); + if (indexVersionCreated.onOrAfter(IndexVersion.V_7_2_0)) { // index was created on a version that supports the replication of closed indices, // so we expect the index to be closed and replicated ensureGreen(indexName); @@ -498,7 +499,7 @@ public void testClosedIndexNoopRecovery() throws Exception { closeIndex(indexName); } - if (indexVersionCreated(indexName).onOrAfter(Version.V_7_2_0)) { + if (indexVersionCreated(indexName).onOrAfter(IndexVersion.V_7_2_0)) { // index was created on a version that supports the replication of closed indices, so we expect it to be closed and replicated assertTrue(minimumNodeVersion().onOrAfter(Version.V_7_2_0)); ensureGreen(indexName); @@ -515,13 +516,13 @@ public void testClosedIndexNoopRecovery() throws Exception { /** * Returns the version in which the given index has been created */ - private static Version indexVersionCreated(final String indexName) throws IOException { + private static IndexVersion indexVersionCreated(final String indexName) throws IOException { final Request request = new Request("GET", "/" + indexName + "/_settings"); final String versionCreatedSetting = indexName + ".settings.index.version.created"; request.addParameter("filter_path", versionCreatedSetting); final Response response = client().performRequest(request); - return Version.fromId(Integer.parseInt(ObjectPath.createFromResponse(response).evaluate(versionCreatedSetting))); + return IndexVersion.fromId(Integer.parseInt(ObjectPath.createFromResponse(response).evaluate(versionCreatedSetting))); } /** diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SystemIndicesUpgradeIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SystemIndicesUpgradeIT.java index b53766f70acb3..48c3007bb2674 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SystemIndicesUpgradeIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/SystemIndicesUpgradeIT.java @@ -8,13 +8,14 @@ package org.elasticsearch.upgrades; -import org.elasticsearch.Version; import org.elasticsearch.client.Request; import org.elasticsearch.client.ResponseException; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.XContentTestUtils.JsonMapView; import java.util.Map; +import static org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SYSTEM_INDEX_ENFORCEMENT_INDEX_VERSION; import static org.elasticsearch.cluster.metadata.IndexNameExpressionResolver.SYSTEM_INDEX_ENFORCEMENT_VERSION; import static org.hamcrest.Matchers.hasKey; import static org.hamcrest.Matchers.is; @@ -116,8 +117,8 @@ public void testSystemIndicesUpgrades() throws Exception { // If .tasks was created in a 7.x version, it should have an alias on it that we need to make sure got upgraded properly. final String tasksCreatedVersionString = tasksIndex.get("settings.index.version.created"); assertThat(tasksCreatedVersionString, notNullValue()); - final Version tasksCreatedVersion = Version.fromId(Integer.parseInt(tasksCreatedVersionString)); - if (tasksCreatedVersion.before(SYSTEM_INDEX_ENFORCEMENT_VERSION)) { + final IndexVersion tasksCreatedVersion = IndexVersion.fromId(Integer.parseInt(tasksCreatedVersionString)); + if (tasksCreatedVersion.before(SYSTEM_INDEX_ENFORCEMENT_INDEX_VERSION)) { // Verify that the alias survived the upgrade Request getAliasRequest = new Request("GET", "/_alias/test-system-alias"); getAliasRequest.setOptions(expectVersionSpecificWarnings(v -> { diff --git a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java b/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java index c5d5ac9392a33..752228943f693 100644 --- a/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java +++ b/server/src/main/java/org/elasticsearch/upgrades/SystemIndexMigrationInfo.java @@ -199,7 +199,7 @@ static SystemIndexMigrationInfo build( if (descriptor.isAutomaticallyManaged()) { Settings.Builder settingsBuilder = Settings.builder(); settingsBuilder.put(descriptor.getSettings()); - settingsBuilder.remove("index.version.created"); // Simplifies testing, should never impact real uses. + settingsBuilder.remove(IndexMetadata.SETTING_VERSION_CREATED); // Simplifies testing, should never impact real uses. settings = settingsBuilder.build(); mapping = descriptor.getMappings(); diff --git a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java index 03229e14d724a..76db89c138682 100644 --- a/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java +++ b/server/src/test/java/org/elasticsearch/action/bulk/TransportBulkActionTests.java @@ -282,7 +282,7 @@ public void testProhibitCustomRoutingOnDataStream() throws Exception { public void testOnlySystem() { SortedMap indicesLookup = new TreeMap<>(); - Settings settings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); indicesLookup.put( ".foo", new ConcreteIndex(IndexMetadata.builder(".foo").settings(settings).system(true).numberOfShards(1).numberOfReplicas(0).build()) diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java index d983c6fecd320..8df51a08b5ecf 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java @@ -10,7 +10,6 @@ import org.elasticsearch.ExceptionsHelper; import org.elasticsearch.ResourceAlreadyExistsException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.indices.alias.Alias; import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest; @@ -1088,7 +1087,7 @@ public void testParseMappingsWithTypelessTemplate() throws Exception { public void testBuildIndexMetadata() { IndexMetadata sourceIndexMetadata = IndexMetadata.builder("parent") - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .primaryTerm(0, 3L) @@ -1105,7 +1104,7 @@ public void testBuildIndexMetadata() { public void testGetIndexNumberOfRoutingShardsWithNullSourceIndex() { Settings indexSettings = Settings.builder() - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 3) .build(); int targetRoutingNumberOfShards = getIndexNumberOfRoutingShards(indexSettings, null); @@ -1149,7 +1148,7 @@ public void testGetIndexNumberOfRoutingShardsYieldsSourceNumberOfShards() { Settings indexSettings = Settings.builder().put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 3).build(); IndexMetadata sourceIndexMetadata = IndexMetadata.builder("parent") - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(6) .numberOfReplicas(0) .build(); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java index 71c2c35e1182b..8a3de96f02f91 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataDeleteIndexServiceTests.java @@ -29,7 +29,6 @@ import org.elasticsearch.snapshots.SnapshotInfoTestUtils; import org.elasticsearch.test.ClusterServiceUtils; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; import org.elasticsearch.test.index.IndexVersionUtils; import org.junit.Before; @@ -145,7 +144,7 @@ public void testDeleteIndexWithAnAlias() { String alias = randomAlphaOfLength(5); IndexMetadata idxMetadata = IndexMetadata.builder(index) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .putAlias(AliasMetadata.builder(alias).writeIndex(true).build()) .numberOfShards(1) .numberOfReplicas(1) @@ -234,7 +233,7 @@ public void testDeleteCurrentWriteIndexForDataStream() { private ClusterState clusterState(String index) { IndexMetadata indexMetadata = IndexMetadata.builder(index) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) .build(); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java index 4fcf3f8c53be5..1fbd578cc1bed 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetadataIndexAliasesServiceTests.java @@ -21,7 +21,7 @@ import org.elasticsearch.index.IndexNotFoundException; import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import java.util.ArrayList; import java.util.Arrays; @@ -730,7 +730,7 @@ private ClusterState applyHiddenAliasMix(ClusterState before, Boolean isHidden1, private ClusterState createIndex(ClusterState state, String index) { IndexMetadata indexMetadata = IndexMetadata.builder(index) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) .build(); diff --git a/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandTests.java b/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandTests.java index 13d97b08966d6..e7f935fc43a43 100644 --- a/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandTests.java +++ b/server/src/test/java/org/elasticsearch/env/NodeRepurposeCommandTests.java @@ -10,7 +10,6 @@ import joptsimple.OptionSet; import org.elasticsearch.ElasticsearchException; -import org.elasticsearch.Version; import org.elasticsearch.cli.MockTerminal; import org.elasticsearch.cli.Terminal; import org.elasticsearch.cluster.ClusterName; @@ -25,6 +24,7 @@ import org.elasticsearch.core.CheckedRunnable; import org.elasticsearch.gateway.PersistedClusterStateService; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.hamcrest.Matcher; import org.junit.Before; @@ -240,7 +240,7 @@ private void createIndexDataFiles(Settings settings, int shardCount, boolean wri IndexMetadata.builder(INDEX.getName()) .settings( Settings.builder() - .put("index.version.created", Version.CURRENT) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(IndexMetadata.SETTING_INDEX_UUID, INDEX.getUUID()) ) .numberOfShards(1) diff --git a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java index 942a97f4b640c..b6700f0cf775f 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.index; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.AbstractScopedSettings; import org.elasticsearch.common.settings.IndexScopedSettings; @@ -731,7 +730,7 @@ public void testArchiveBrokenIndexSettings() { settings = IndexScopedSettings.DEFAULT_SCOPED_SETTINGS.archiveUnknownOrInvalidSettings( Settings.builder() - .put("index.version.created", Version.CURRENT.id) // private setting + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) // private setting .put("index.unknown", "foo") .put("index.refresh_interval", "2s") .build(), @@ -743,7 +742,7 @@ public void testArchiveBrokenIndexSettings() { ); assertEquals("foo", settings.get("archived.index.unknown")); - assertEquals(Integer.toString(Version.CURRENT.id), settings.get("index.version.created")); + assertEquals(IndexVersion.current().toString(), settings.get(IndexMetadata.SETTING_VERSION_CREATED)); assertEquals("2s", settings.get("index.refresh_interval")); } diff --git a/server/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java b/server/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java index 6cbfb53c3f584..92e080d85c0c2 100644 --- a/server/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java +++ b/server/src/test/java/org/elasticsearch/index/IndexSortSettingsTests.java @@ -10,7 +10,6 @@ import org.apache.lucene.search.Query; import org.apache.lucene.search.Sort; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.Maps; @@ -162,7 +161,7 @@ public void testSortingAgainstAliases() { public void testSortingAgainstAliasesPre713() { IndexSettings indexSettings = indexSettings( - Settings.builder().put("index.version.created", Version.V_7_12_0).put("index.sort.field", "field").build() + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.V_7_12_0).put("index.sort.field", "field").build() ); MappedFieldType aliased = new KeywordFieldMapper.KeywordFieldType("aliased"); Sort sort = buildIndexSort(indexSettings, Map.of("field", aliased)); diff --git a/server/src/test/java/org/elasticsearch/persistent/PersistentTasksClusterServiceTests.java b/server/src/test/java/org/elasticsearch/persistent/PersistentTasksClusterServiceTests.java index 5c2fafe00dec7..f6a8d3a10aafb 100644 --- a/server/src/test/java/org/elasticsearch/persistent/PersistentTasksClusterServiceTests.java +++ b/server/src/test/java/org/elasticsearch/persistent/PersistentTasksClusterServiceTests.java @@ -37,7 +37,7 @@ import org.elasticsearch.persistent.TestPersistentTasksPlugin.TestPersistentTasksExecutor; import org.elasticsearch.persistent.decider.EnableAssignmentDecider; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.threadpool.TestThreadPool; import org.elasticsearch.threadpool.ThreadPool; import org.junit.After; @@ -968,7 +968,7 @@ private ClusterState insignificantChange(ClusterState clusterState) { } // Just add a random index - that shouldn't change anything IndexMetadata indexMetadata = IndexMetadata.builder(randomAlphaOfLength(10)) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) .build(); @@ -1046,7 +1046,7 @@ private ClusterState initialState() { private void changeRoutingTable(Metadata.Builder metadata, RoutingTable.Builder routingTable) { IndexMetadata indexMetadata = IndexMetadata.builder(randomAlphaOfLength(10)) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1) .build(); diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java index 097c236b8e577..371ea3f35292b 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java @@ -20,7 +20,6 @@ import org.apache.lucene.tests.index.RandomIndexWriter; import org.apache.lucene.util.Accountable; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.cluster.metadata.IndexMetadata; import org.elasticsearch.common.Strings; import org.elasticsearch.common.TriFunction; @@ -101,7 +100,9 @@ */ public abstract class MapperServiceTestCase extends ESTestCase { - protected static final Settings SETTINGS = Settings.builder().put("index.version.created", Version.CURRENT).build(); + protected static final Settings SETTINGS = Settings.builder() + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) + .build(); protected static final ToXContent.Params INCLUDE_DEFAULTS = new ToXContent.MapParams(Map.of("include_defaults", "true")); @@ -230,7 +231,7 @@ protected T compileScript(Script script, ScriptContext context) { } protected static IndexSettings createIndexSettings(IndexVersion version, Settings settings) { - settings = indexSettings(1, 0).put(settings).put("index.version.created", version).build(); + settings = indexSettings(1, 0).put(settings).put(IndexMetadata.SETTING_VERSION_CREATED, version).build(); IndexMetadata meta = IndexMetadata.builder("index").settings(settings).build(); return new IndexSettings(meta, settings); } diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java index dfbcfb6283b48..b30a7f5360f0a 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java @@ -64,6 +64,7 @@ import org.elasticsearch.cluster.metadata.Metadata; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.rest.root.MainAction; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportRequest; @@ -2005,7 +2006,7 @@ public void testRemoteMonitoringCollectorRole() { } private void assertMonitoringOnRestrictedIndices(Role role) { - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -2121,7 +2122,7 @@ public void testSuperuserRole() { assertThat(superuserRole.cluster().check(SuggestProfilesAction.NAME, mock(SuggestProfilesRequest.class), authentication), is(true)); assertThat(superuserRole.cluster().check(ActivateProfileAction.NAME, mock(ActivateProfileRequest.class), authentication), is(true)); - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java index cc1b1f322fd70..ef250f0a42fd6 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/PolicyStepsRegistryTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.ilm; -import org.elasticsearch.Version; import org.elasticsearch.client.internal.Client; import org.elasticsearch.cluster.ClusterName; import org.elasticsearch.cluster.ClusterState; @@ -207,7 +206,7 @@ public void testUpdateFromNothingToSomethingToNothing() throws Exception { IndexMetadata.builder("test") .settings( indexSettings(1, 0).put("index.uuid", "uuid") - .put("index.version.created", Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(LifecycleSettings.LIFECYCLE_NAME, policyName) ) .putCustom(ILM_CUSTOM_METADATA_KEY, lifecycleState.build().asMap()) @@ -373,7 +372,7 @@ public void testUpdatePolicyButNoPhaseChangeIndexStepsDontChange() throws Except IndexMetadata.builder("test") .settings( indexSettings(1, 0).put("index.uuid", "uuid") - .put("index.version.created", Version.CURRENT.id) + .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()) .put(LifecycleSettings.LIFECYCLE_NAME, policyName) ) .putCustom(ILM_CUSTOM_METADATA_KEY, lifecycleState.build().asMap()) diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java index 89a2c3b0802a3..54baec95d713a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizationServiceTests.java @@ -7,7 +7,6 @@ package org.elasticsearch.xpack.security.authz; import org.elasticsearch.ElasticsearchSecurityException; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.CompositeIndicesRequest; import org.elasticsearch.action.DocWriteRequest; @@ -103,6 +102,7 @@ import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.Tuple; import org.elasticsearch.index.IndexNotFoundException; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.index.bulk.stats.BulkOperationListener; import org.elasticsearch.index.shard.IndexShard; import org.elasticsearch.index.shard.ShardId; @@ -1940,7 +1940,7 @@ public void testGrantAllRestrictedUserCannotExecuteOperationAgainstSecurityIndic new IndexMetadata.Builder(INTERNAL_SECURITY_MAIN_INDEX_7).putAlias( new AliasMetadata.Builder(SECURITY_MAIN_ALIAS).build() ) - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -2073,7 +2073,7 @@ public void testMonitoringOperationsAgainstSecurityIndexRequireAllowRestricted() new IndexMetadata.Builder(INTERNAL_SECURITY_MAIN_INDEX_7).putAlias( new AliasMetadata.Builder(SECURITY_MAIN_ALIAS).build() ) - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -2130,7 +2130,7 @@ public void testSuperusersCanExecuteReadOperationAgainstSecurityIndex() { new IndexMetadata.Builder(INTERNAL_SECURITY_MAIN_INDEX_7).putAlias( new AliasMetadata.Builder(SECURITY_MAIN_ALIAS).build() ) - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -2185,7 +2185,7 @@ public void testSuperusersCannotExecuteWriteOperationAgainstSecurityIndex() { new IndexMetadata.Builder(INTERNAL_SECURITY_MAIN_INDEX_7).putAlias( new AliasMetadata.Builder(SECURITY_MAIN_ALIAS).build() ) - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -2261,7 +2261,7 @@ public void testSuperusersCanExecuteReadOperationAgainstSecurityIndexWithWildcar new IndexMetadata.Builder(INTERNAL_SECURITY_MAIN_INDEX_7).putAlias( new AliasMetadata.Builder(SECURITY_MAIN_ALIAS).build() ) - .settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build()) .numberOfShards(1) .numberOfReplicas(0) .build(), @@ -2618,7 +2618,7 @@ private ClusterState mockEmptyMetadata() { private ClusterState mockMetadataWithIndex(String indexName) { final IndexMetadata indexMetadata = new IndexMetadata.Builder(indexName).settings( - Settings.builder().put("index.version.created", Version.CURRENT).build() + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build() ).numberOfShards(1).numberOfReplicas(0).build(); final Metadata metadata = Metadata.builder().put(indexMetadata, true).build(); return mockClusterState(metadata); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java index 23fc46b53f58a..35071628603c2 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/AuthorizedIndicesTests.java @@ -6,7 +6,6 @@ */ package org.elasticsearch.xpack.security.authz; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.resolve.ResolveIndexAction; import org.elasticsearch.action.search.SearchAction; import org.elasticsearch.action.support.PlainActionFuture; @@ -18,6 +17,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.set.Sets; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexVersion; import org.elasticsearch.test.ESTestCase; import org.elasticsearch.transport.TransportRequest; import org.elasticsearch.xpack.core.security.authc.Authentication; @@ -70,7 +70,7 @@ public void testAuthorizedIndicesUserWithSomeRoles() { new IndicesPrivileges[] { IndicesPrivileges.builder().indices("b").privileges("READ").build() }, null ); - Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -152,7 +152,7 @@ public void testSecurityIndicesAreRestrictedForDefaultRole() { .add(IndexPrivilege.ALL, "*") .cluster(Set.of("all"), Set.of()) .build(); - Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -190,7 +190,7 @@ public void testSecurityIndicesAreNotRemovedFromUnrestrictedRole() { .add(FieldPermissions.DEFAULT, null, IndexPrivilege.ALL, true, "*") .cluster(Set.of("all"), Set.of()) .build(); - Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -244,7 +244,7 @@ public void testDataStreamsAreNotIncludedInAuthorizedIndices() { new IndicesPrivileges[] { IndicesPrivileges.builder().indices("b").privileges("READ").build() }, null ); - Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -327,7 +327,7 @@ public void testDataStreamsAreIncludedInAuthorizedIndices() { new IndicesPrivileges[] { IndicesPrivileges.builder().indices("b").privileges("READ").build() }, null ); - Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java index 382c903dd7614..aa89cdad6eb7a 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/IndicesPermissionTests.java @@ -8,7 +8,6 @@ import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.action.admin.indices.mapping.put.AutoPutMappingAction; import org.elasticsearch.action.admin.indices.mapping.put.PutMappingAction; import org.elasticsearch.action.search.SearchAction; @@ -239,7 +238,7 @@ public void testIndicesPrivilegesStreaming() throws IOException { // tests that field permissions are merged correctly when we authorize with several groups and don't crash when an index has no group public void testCorePermissionAuthorize() { - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final Metadata metadata = new Metadata.Builder().put( new IndexMetadata.Builder("a1").settings(indexSettings).numberOfShards(1).numberOfReplicas(0).build(), true @@ -340,7 +339,7 @@ public void testErrorMessageIfIndexPatternIsTooComplex() { } public void testSecurityIndicesPermissions() { - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String internalSecurityIndex = randomFrom( TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_6, TestRestrictedIndices.INTERNAL_SECURITY_MAIN_INDEX_7 @@ -398,7 +397,7 @@ public void testSecurityIndicesPermissions() { } public void testAsyncSearchIndicesPermissions() { - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final String asyncSearchIndex = XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2); final Metadata metadata = new Metadata.Builder().put( new IndexMetadata.Builder(asyncSearchIndex).settings(indexSettings).numberOfShards(1).numberOfReplicas(0).build(), @@ -501,7 +500,7 @@ public void testAuthorizationForBackingIndices() { } public void testAuthorizationForMappingUpdates() { - final Settings indexSettings = Settings.builder().put("index.version.created", Version.CURRENT).build(); + final Settings indexSettings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build(); final Metadata.Builder metadata = new Metadata.Builder().put( new IndexMetadata.Builder("test1").settings(indexSettings).numberOfShards(1).numberOfReplicas(0).build(), true diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java index 8baff0091ef53..dd716b79e1db3 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/CompositeRolesStoreTests.java @@ -11,7 +11,6 @@ import org.apache.logging.log4j.Logger; import org.elasticsearch.ElasticsearchSecurityException; import org.elasticsearch.TransportVersion; -import org.elasticsearch.Version; import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsAction; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsAction; @@ -911,10 +910,9 @@ public void testMergingRolesWithFls() { Metadata metadata = Metadata.builder() .put( - new IndexMetadata.Builder("test").settings(Settings.builder().put("index.version.created", Version.CURRENT).build()) - .numberOfShards(1) - .numberOfReplicas(0) - .build(), + new IndexMetadata.Builder("test").settings( + Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()).build() + ).numberOfShards(1).numberOfReplicas(0).build(), true ) .build(); diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java index 12aa688c3cb2d..ee91b8b65e540 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/store/DeprecationRoleDescriptorConsumerTests.java @@ -18,7 +18,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.concurrent.ThreadContext; import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.VersionUtils; +import org.elasticsearch.test.index.IndexVersionUtils; import org.elasticsearch.threadpool.ThreadPool; import org.elasticsearch.xpack.core.security.authz.RoleDescriptor; import org.junit.Before; @@ -342,7 +342,7 @@ public void testMultipleIndicesSameAlias() throws Exception { private void addIndex(Metadata.Builder metadataBuilder, String index, String... aliases) { final IndexMetadata.Builder indexMetadataBuilder = IndexMetadata.builder(index) - .settings(Settings.builder().put("index.version.created", VersionUtils.randomVersion(random()))) + .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))) .numberOfShards(1) .numberOfReplicas(1); for (final String alias : aliases) {