Browse Source

More migrations of Version for index created version to IndexVersion (#98495)

Simon Cooper 2 years ago
parent
commit
041e94d2b0
19 changed files with 124 additions and 115 deletions
  1. 40 28
      modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java
  2. 15 11
      modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/EdgeNGramTokenizerTests.java
  3. 13 5
      modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java
  4. 6 3
      plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/AnalysisPhoneticFactoryTests.java
  5. 1 1
      server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java
  6. 1 1
      server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java
  7. 5 6
      server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java
  8. 4 2
      server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java
  9. 7 5
      server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java
  10. 5 7
      server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java
  11. 8 9
      server/src/test/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilterTests.java
  12. 1 3
      server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java
  13. 1 2
      server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java
  14. 2 4
      server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java
  15. 4 4
      server/src/test/java/org/elasticsearch/indices/analysis/IncorrectSetupStablePluginsTests.java
  16. 3 3
      server/src/test/java/org/elasticsearch/indices/analysis/StableAnalysisPluginsNoSettingsTests.java
  17. 5 5
      server/src/test/java/org/elasticsearch/indices/analysis/StableAnalysisPluginsWithSettingsTests.java
  18. 3 3
      x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java
  19. 0 13
      x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java

+ 40 - 28
modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/CommonAnalysisPluginTests.java

@@ -9,14 +9,14 @@
 package org.elasticsearch.analysis.common;
 
 import org.apache.lucene.analysis.Tokenizer;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.analysis.TokenizerFactory;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.util.Map;
@@ -30,7 +30,10 @@ public class CommonAnalysisPluginTests extends ESTestCase {
     public void testNGramFilterInCustomAnalyzerDeprecationError() throws IOException {
         final Settings settings = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current())
+            )
             .put("index.analysis.analyzer.custom_analyzer.type", "custom")
             .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard")
             .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram")
@@ -51,7 +54,10 @@ public class CommonAnalysisPluginTests extends ESTestCase {
 
         final Settings settingsPre7 = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_6_0))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_6_0)
+            )
             .put("index.analysis.analyzer.custom_analyzer.type", "custom")
             .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard")
             .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram")
@@ -73,7 +79,10 @@ public class CommonAnalysisPluginTests extends ESTestCase {
     public void testEdgeNGramFilterInCustomAnalyzerDeprecationError() throws IOException {
         final Settings settings = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current())
+            )
             .put("index.analysis.analyzer.custom_analyzer.type", "custom")
             .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard")
             .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram")
@@ -94,7 +103,10 @@ public class CommonAnalysisPluginTests extends ESTestCase {
 
         final Settings settingsPre7 = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_6_0))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_6_0)
+            )
             .put("index.analysis.analyzer.custom_analyzer.type", "custom")
             .put("index.analysis.analyzer.custom_analyzer.tokenizer", "standard")
             .putList("index.analysis.analyzer.custom_analyzer.filter", "my_ngram")
@@ -119,32 +131,32 @@ public class CommonAnalysisPluginTests extends ESTestCase {
         doTestPrebuiltTokenizerDeprecation(
             "nGram",
             "ngram",
-            VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2),
+            IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_5_2),
             false
         );
         doTestPrebuiltTokenizerDeprecation(
             "edgeNGram",
             "edge_ngram",
-            VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2),
+            IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_5_2),
             false
         );
         doTestPrebuiltTokenizerDeprecation(
             "nGram",
             "ngram",
-            VersionUtils.randomVersionBetween(
+            IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_6_0,
-                Version.max(Version.V_7_6_0, VersionUtils.getPreviousVersion(Version.V_8_0_0))
+                IndexVersion.V_7_6_0,
+                IndexVersion.max(IndexVersion.V_7_6_0, IndexVersionUtils.getPreviousVersion(IndexVersion.V_8_0_0))
             ),
             true
         );
         doTestPrebuiltTokenizerDeprecation(
             "edgeNGram",
             "edge_ngram",
-            VersionUtils.randomVersionBetween(
+            IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_6_0,
-                Version.max(Version.V_7_6_0, VersionUtils.getPreviousVersion(Version.V_8_0_0))
+                IndexVersion.V_7_6_0,
+                IndexVersion.max(IndexVersion.V_7_6_0, IndexVersionUtils.getPreviousVersion(IndexVersion.V_8_0_0))
             ),
             true
         );
@@ -153,7 +165,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
             () -> doTestPrebuiltTokenizerDeprecation(
                 "nGram",
                 "ngram",
-                VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT),
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current()),
                 true
             )
         );
@@ -162,7 +174,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
             () -> doTestPrebuiltTokenizerDeprecation(
                 "edgeNGram",
                 "edge_ngram",
-                VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT),
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current()),
                 true
             )
         );
@@ -171,32 +183,32 @@ public class CommonAnalysisPluginTests extends ESTestCase {
         doTestCustomTokenizerDeprecation(
             "nGram",
             "ngram",
-            VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2),
+            IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_5_2),
             false
         );
         doTestCustomTokenizerDeprecation(
             "edgeNGram",
             "edge_ngram",
-            VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2),
+            IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_5_2),
             false
         );
         doTestCustomTokenizerDeprecation(
             "nGram",
             "ngram",
-            VersionUtils.randomVersionBetween(
+            IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_6_0,
-                Version.max(Version.V_7_6_0, VersionUtils.getPreviousVersion(Version.V_8_0_0))
+                IndexVersion.V_7_6_0,
+                IndexVersion.max(IndexVersion.V_7_6_0, IndexVersionUtils.getPreviousVersion(IndexVersion.V_8_0_0))
             ),
             true
         );
         doTestCustomTokenizerDeprecation(
             "edgeNGram",
             "edge_ngram",
-            VersionUtils.randomVersionBetween(
+            IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_6_0,
-                Version.max(Version.V_7_6_0, VersionUtils.getPreviousVersion(Version.V_8_0_0))
+                IndexVersion.V_7_6_0,
+                IndexVersion.max(IndexVersion.V_7_6_0, IndexVersionUtils.getPreviousVersion(IndexVersion.V_8_0_0))
             ),
             true
         );
@@ -205,7 +217,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
             () -> doTestCustomTokenizerDeprecation(
                 "nGram",
                 "ngram",
-                VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT),
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current()),
                 true
             )
         );
@@ -214,13 +226,13 @@ public class CommonAnalysisPluginTests extends ESTestCase {
             () -> doTestCustomTokenizerDeprecation(
                 "edgeNGram",
                 "edge_ngram",
-                VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT),
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current()),
                 true
             )
         );
     }
 
-    public void doTestPrebuiltTokenizerDeprecation(String deprecatedName, String replacement, Version version, boolean expectWarning)
+    public void doTestPrebuiltTokenizerDeprecation(String deprecatedName, String replacement, IndexVersion version, boolean expectWarning)
         throws IOException {
         final Settings settings = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())
@@ -250,7 +262,7 @@ public class CommonAnalysisPluginTests extends ESTestCase {
         }
     }
 
-    public void doTestCustomTokenizerDeprecation(String deprecatedName, String replacement, Version version, boolean expectWarning)
+    public void doTestCustomTokenizerDeprecation(String deprecatedName, String replacement, IndexVersion version, boolean expectWarning)
         throws IOException {
         final Settings settings = Settings.builder()
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir())

+ 15 - 11
modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/EdgeNGramTokenizerTests.java

@@ -9,7 +9,6 @@
 package org.elasticsearch.analysis.common;
 
 import org.apache.lucene.analysis.Tokenizer;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
@@ -17,13 +16,14 @@ import org.elasticsearch.env.TestEnvironment;
 import org.elasticsearch.index.Index;
 import org.elasticsearch.index.IndexService.IndexCreationContext;
 import org.elasticsearch.index.IndexSettings;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.analysis.IndexAnalyzers;
 import org.elasticsearch.index.analysis.NamedAnalyzer;
 import org.elasticsearch.indices.analysis.AnalysisModule;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTokenStreamTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.io.StringReader;
@@ -31,7 +31,7 @@ import java.util.Collections;
 
 public class EdgeNGramTokenizerTests extends ESTokenStreamTestCase {
 
-    private IndexAnalyzers buildAnalyzers(Version version, String tokenizer) throws IOException {
+    private IndexAnalyzers buildAnalyzers(IndexVersion version, String tokenizer) throws IOException {
         Settings settings = Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()).build();
         Settings indexSettings = Settings.builder()
             .put(IndexMetadata.SETTING_VERSION_CREATED, version)
@@ -49,10 +49,10 @@ public class EdgeNGramTokenizerTests extends ESTokenStreamTestCase {
 
         // Before 7.3 we return ngrams of length 1 only
         {
-            Version version = VersionUtils.randomVersionBetween(
+            IndexVersion version = IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_0_0,
-                VersionUtils.getPreviousVersion(Version.V_7_3_0)
+                IndexVersion.V_7_0_0,
+                IndexVersionUtils.getPreviousVersion(IndexVersion.V_7_3_0)
             );
             try (IndexAnalyzers indexAnalyzers = buildAnalyzers(version, "edge_ngram")) {
                 NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
@@ -63,10 +63,10 @@ public class EdgeNGramTokenizerTests extends ESTokenStreamTestCase {
 
         // Check deprecated name as well
         {
-            Version version = VersionUtils.randomVersionBetween(
+            IndexVersion version = IndexVersionUtils.randomVersionBetween(
                 random(),
-                Version.V_7_0_0,
-                VersionUtils.getPreviousVersion(Version.V_7_3_0)
+                IndexVersion.V_7_0_0,
+                IndexVersionUtils.getPreviousVersion(IndexVersion.V_7_3_0)
             );
             try (IndexAnalyzers indexAnalyzers = buildAnalyzers(version, "edgeNGram")) {
                 NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
@@ -77,7 +77,7 @@ public class EdgeNGramTokenizerTests extends ESTokenStreamTestCase {
 
         // Afterwards, we return ngrams of length 1 and 2, to match the default factory settings
         {
-            try (IndexAnalyzers indexAnalyzers = buildAnalyzers(Version.CURRENT, "edge_ngram")) {
+            try (IndexAnalyzers indexAnalyzers = buildAnalyzers(IndexVersion.current(), "edge_ngram")) {
                 NamedAnalyzer analyzer = indexAnalyzers.get("my_analyzer");
                 assertNotNull(analyzer);
                 assertAnalyzesTo(analyzer, "test", new String[] { "t", "te" });
@@ -88,7 +88,11 @@ public class EdgeNGramTokenizerTests extends ESTokenStreamTestCase {
         {
             try (
                 IndexAnalyzers indexAnalyzers = buildAnalyzers(
-                    VersionUtils.randomVersionBetween(random(), Version.V_7_3_0, VersionUtils.getPreviousVersion(Version.V_8_0_0)),
+                    IndexVersionUtils.randomVersionBetween(
+                        random(),
+                        IndexVersion.V_7_3_0,
+                        IndexVersionUtils.getPreviousVersion(IndexVersion.V_8_0_0)
+                    ),
                     "edgeNGram"
                 )
             ) {

+ 13 - 5
modules/analysis-common/src/test/java/org/elasticsearch/analysis/common/SynonymsAnalysisTests.java

@@ -13,7 +13,6 @@ import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.core.KeywordTokenizer;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.tests.analysis.BaseTokenStreamTestCase;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
@@ -25,7 +24,7 @@ import org.elasticsearch.index.analysis.TokenFilterFactory;
 import org.elasticsearch.index.analysis.TokenizerFactory;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 import org.hamcrest.MatcherAssert;
 
 import java.io.IOException;
@@ -237,7 +236,10 @@ public class SynonymsAnalysisTests extends ESTestCase {
     public void testShingleFilters() {
 
         Settings settings = Settings.builder()
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.current())
+            )
             .put("path.home", createTempDir().toString())
             .put("index.analysis.filter.synonyms.type", "synonym")
             .putList("index.analysis.filter.synonyms.synonyms", "programmer, developer")
@@ -289,7 +291,10 @@ public class SynonymsAnalysisTests extends ESTestCase {
         );
 
         Settings settings = Settings.builder()
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.current())
+            )
             .put("path.home", createTempDir().toString())
             .build();
         IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);
@@ -318,7 +323,10 @@ public class SynonymsAnalysisTests extends ESTestCase {
     public void testDisallowedTokenFilters() throws IOException {
 
         Settings settings = Settings.builder()
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.current())
+            )
             .put("path.home", createTempDir().toString())
             .putList("common_words", "a", "b")
             .put("output_unigrams", "true")

+ 6 - 3
plugins/analysis-phonetic/src/test/java/org/elasticsearch/plugin/analysis/phonetic/AnalysisPhoneticFactoryTests.java

@@ -8,14 +8,14 @@
 
 package org.elasticsearch.plugin.analysis.phonetic;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.index.IndexSettings;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.analysis.TokenFilterFactory;
 import org.elasticsearch.indices.analysis.AnalysisFactoryTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.util.HashMap;
@@ -40,7 +40,10 @@ public class AnalysisPhoneticFactoryTests extends AnalysisFactoryTestCase {
         AnalysisPhoneticPlugin plugin = new AnalysisPhoneticPlugin();
 
         Settings settings = Settings.builder()
-            .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT))
+            .put(
+                IndexMetadata.SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.current())
+            )
             .put("path.home", createTempDir().toString())
             .build();
         IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings);

+ 1 - 1
server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoDistanceIT.java

@@ -56,7 +56,7 @@ public class GeoDistanceIT extends ESIntegTestCase {
         return false;
     }
 
-    private IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random());
+    private final IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random());
 
     private IndexRequestBuilder indexCity(String idx, String name, String... latLons) throws Exception {
         XContentBuilder source = jsonBuilder().startObject().field("city", name);

+ 1 - 1
server/src/internalClusterTest/java/org/elasticsearch/search/aggregations/bucket/GeoHashGridIT.java

@@ -49,7 +49,7 @@ public class GeoHashGridIT extends ESIntegTestCase {
         return false;
     }
 
-    private IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random());
+    private final IndexVersion version = IndexVersionUtils.randomCompatibleVersion(random());
 
     static Map<String, Integer> expectedDocCountsForGeoHash = null;
     static Map<String, Integer> multiValuedExpectedDocCountsForGeoHash = null;

+ 5 - 6
server/src/test/java/org/elasticsearch/cluster/metadata/IndexMetadataTests.java

@@ -8,7 +8,6 @@
 
 package org.elasticsearch.cluster.metadata;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.action.admin.indices.rollover.MaxAgeCondition;
 import org.elasticsearch.action.admin.indices.rollover.MaxDocsCondition;
 import org.elasticsearch.action.admin.indices.rollover.MaxPrimaryShardDocsCondition;
@@ -476,7 +475,7 @@ public class IndexMetadataTests extends ESTestCase {
             final IllegalArgumentException iae = expectThrows(
                 IllegalArgumentException.class,
                 () -> IndexMetadata.builder("index")
-                    .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.V_8_5_0))
+                    .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.V_8_5_0))
                     .numberOfShards(1)
                     .numberOfReplicas(0)
                     .putAlias(AliasMetadata.builder("index").build())
@@ -488,7 +487,7 @@ public class IndexMetadataTests extends ESTestCase {
 
     public void testRepairIndexAndAliasWithSameName() {
         final IndexMetadata indexMetadata = IndexMetadata.builder("index")
-            .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.V_8_5_0))
+            .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.V_8_5_0))
             .numberOfShards(1)
             .numberOfReplicas(0)
             .putAlias(AliasMetadata.builder("index").build())
@@ -502,7 +501,7 @@ public class IndexMetadataTests extends ESTestCase {
             final IndexMetadata indexMetadata = IndexMetadata.builder("index")
                 .settings(
                     Settings.builder()
-                        .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
+                        .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
                         .put(INDEX_STORE_TYPE_SETTING.getKey(), "snapshot")
                         .put(SNAPSHOT_PARTIAL_SETTING.getKey(), true)
                 )
@@ -518,7 +517,7 @@ public class IndexMetadataTests extends ESTestCase {
             final IndexMetadata indexMetadata = IndexMetadata.builder("index")
                 .settings(
                     Settings.builder()
-                        .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
+                        .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current())
                         .put(DataTier.TIER_PREFERENCE, DataTier.DATA_CONTENT)
                         .put(INDEX_STORE_TYPE_SETTING.getKey(), "snapshot")
                         .put(SNAPSHOT_PARTIAL_SETTING.getKey(), true)
@@ -534,7 +533,7 @@ public class IndexMetadataTests extends ESTestCase {
             // regular indices do not receive a tier preference when building the index metadata
             // (we have other ways to make sure they have a tier preference)
             final IndexMetadata indexMetadata = IndexMetadata.builder("index")
-                .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT))
+                .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.current()))
                 .numberOfShards(1)
                 .numberOfReplicas(0)
                 .build(false);

+ 4 - 2
server/src/test/java/org/elasticsearch/cluster/metadata/MetadataCreateIndexServiceTests.java

@@ -57,7 +57,6 @@ import org.elasticsearch.indices.SystemIndices;
 import org.elasticsearch.snapshots.EmptySnapshotsInfoService;
 import org.elasticsearch.test.ClusterServiceUtils;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.gateway.TestGatewayAllocator;
 import org.elasticsearch.test.index.IndexVersionUtils;
 import org.elasticsearch.threadpool.TestThreadPool;
@@ -1265,7 +1264,10 @@ public class MetadataCreateIndexServiceTests extends ESTestCase {
             settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_SIZE_SETTING.getKey(), between(1, 128) + "mb");
         }
         if (randomBoolean()) {
-            settings.put(SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT));
+            settings.put(
+                SETTING_VERSION_CREATED,
+                IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current())
+            );
         }
         request.settings(settings.build());
         IllegalArgumentException error = expectThrows(

+ 7 - 5
server/src/test/java/org/elasticsearch/index/IndexSettingsTests.java

@@ -19,7 +19,6 @@ import org.elasticsearch.common.unit.ByteSizeValue;
 import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.index.translog.Translog;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.index.IndexVersionUtils;
 import org.hamcrest.Matchers;
 
@@ -110,7 +109,7 @@ public class IndexSettingsTests extends ESTestCase {
     }
 
     public void testMergedSettingsArePassed() {
-        Version version = VersionUtils.getPreviousVersion();
+        IndexVersion version = IndexVersionUtils.getPreviousVersion();
         Settings theSettings = Settings.builder()
             .put(IndexMetadata.SETTING_VERSION_CREATED, version)
             .put(IndexMetadata.SETTING_INDEX_UUID, "0xdeadbeef")
@@ -173,7 +172,7 @@ public class IndexSettingsTests extends ESTestCase {
                 newIndexMeta(
                     "index",
                     Settings.builder()
-                        .put(IndexMetadata.SETTING_VERSION_CREATED, version.id())
+                        .put(IndexMetadata.SETTING_VERSION_CREATED, version)
                         .put(IndexMetadata.SETTING_VERSION_COMPATIBILITY, IndexVersion.current())
                         .put("index.test.setting.int", 42)
                         .build()
@@ -185,7 +184,10 @@ public class IndexSettingsTests extends ESTestCase {
         }
 
         // use version number that is unknown
-        metadata = newIndexMeta("index", Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(999999)).build());
+        metadata = newIndexMeta(
+            "index",
+            Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.fromId(999999)).build()
+        );
         settings = new IndexSettings(metadata, Settings.EMPTY);
         assertEquals(IndexVersion.fromId(999999), settings.getIndexVersionCreated());
         assertEquals("_na_", settings.getUUID());
@@ -193,7 +195,7 @@ public class IndexSettingsTests extends ESTestCase {
             newIndexMeta(
                 "index",
                 Settings.builder()
-                    .put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(999999))
+                    .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.fromId(999999))
                     .put("index.test.setting.int", 42)
                     .build()
             )

+ 5 - 7
server/src/test/java/org/elasticsearch/index/analysis/AnalysisRegistryTests.java

@@ -19,7 +19,6 @@ import org.apache.lucene.analysis.standard.StandardAnalyzer;
 import org.apache.lucene.analysis.standard.StandardTokenizer;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.tests.analysis.MockTokenFilter;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
@@ -36,7 +35,6 @@ import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
@@ -107,7 +105,7 @@ public class AnalysisRegistryTests extends ESTestCase {
     }
 
     public void testDefaultAnalyzers() throws IOException {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         Settings settings = Settings.builder()
             .put(IndexMetadata.SETTING_VERSION_CREATED, version)
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
@@ -121,7 +119,7 @@ public class AnalysisRegistryTests extends ESTestCase {
     }
 
     public void testOverrideDefaultAnalyzer() throws IOException {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
         IndexAnalyzers indexAnalyzers = AnalysisRegistry.build(
             IndexCreationContext.CREATE_INDEX,
@@ -138,7 +136,7 @@ public class AnalysisRegistryTests extends ESTestCase {
     }
 
     public void testOverrideDefaultAnalyzerWithoutAnalysisModeAll() throws IOException {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
         IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("index", settings);
         TokenFilterFactory tokenFilter = new AbstractTokenFilterFactory("my_filter", Settings.EMPTY) {
@@ -217,7 +215,7 @@ public class AnalysisRegistryTests extends ESTestCase {
     }
 
     public void testOverrideDefaultSearchAnalyzer() {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
         IndexAnalyzers indexAnalyzers = AnalysisRegistry.build(
             IndexCreationContext.CREATE_INDEX,
@@ -321,7 +319,7 @@ public class AnalysisRegistryTests extends ESTestCase {
     }
 
     public void testNoTypeOrTokenizerErrorMessage() throws IOException {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         Settings settings = Settings.builder()
             .put(IndexMetadata.SETTING_VERSION_CREATED, version)
             .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())

+ 8 - 9
server/src/test/java/org/elasticsearch/index/analysis/PreConfiguredTokenFilterTests.java

@@ -8,15 +8,15 @@
 package org.elasticsearch.index.analysis;
 
 import org.apache.lucene.analysis.TokenFilter;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.env.TestEnvironment;
 import org.elasticsearch.index.IndexSettings;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 
@@ -40,13 +40,13 @@ public class PreConfiguredTokenFilterTests extends ESTestCase {
 
         IndexSettings indexSettings = IndexSettingsModule.newIndexSettings("test", Settings.EMPTY);
 
-        Version version1 = VersionUtils.randomVersion(random());
+        IndexVersion version1 = IndexVersionUtils.randomVersion(random());
         Settings settings1 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version1).build();
         TokenFilterFactory tff_v1_1 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "singleton", settings1);
         TokenFilterFactory tff_v1_2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "singleton", settings1);
         assertSame(tff_v1_1, tff_v1_2);
 
-        Version version2 = randomValueOtherThan(version1, () -> randomFrom(VersionUtils.allVersions()));
+        IndexVersion version2 = randomValueOtherThan(version1, () -> randomFrom(IndexVersionUtils.allReleasedVersions()));
         Settings settings2 = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version2).build();
 
         TokenFilterFactory tff_v2 = pctf.get(indexSettings, TestEnvironment.newEnvironment(emptyNodeSettings), "singleton", settings2);
@@ -65,7 +65,7 @@ public class PreConfiguredTokenFilterTests extends ESTestCase {
             }
         );
 
-        Version version1 = VersionUtils.randomVersion(random());
+        IndexVersion version1 = IndexVersionUtils.randomVersion(random());
         IndexSettings indexSettings1 = IndexSettingsModule.newIndexSettings(
             "test",
             Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version1).build()
@@ -84,7 +84,7 @@ public class PreConfiguredTokenFilterTests extends ESTestCase {
         );
         assertSame(tff_v1_1, tff_v1_2);
 
-        Version version2 = randomValueOtherThan(version1, () -> randomFrom(VersionUtils.allVersions()));
+        IndexVersion version2 = randomValueOtherThan(version1, () -> randomFrom(IndexVersionUtils.allReleasedVersions()));
         IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings(
             "test",
             Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version2).build()
@@ -112,7 +112,7 @@ public class PreConfiguredTokenFilterTests extends ESTestCase {
             }
         );
 
-        Version version1 = Version.CURRENT;
+        IndexVersion version1 = IndexVersion.current();
         IndexSettings indexSettings1 = IndexSettingsModule.newIndexSettings(
             "test",
             Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version1).build()
@@ -132,8 +132,7 @@ public class PreConfiguredTokenFilterTests extends ESTestCase {
         );
         assertSame(tff_v1_1, tff_v1_2);
 
-        byte major = VersionUtils.getFirstVersion().major;
-        Version version2 = Version.fromString(major - 1 + ".0.0");
+        IndexVersion version2 = IndexVersionUtils.getPreviousMajorVersion(IndexVersionUtils.getFirstVersion());
         IndexSettings indexSettings2 = IndexSettingsModule.newIndexSettings(
             "test",
             Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version2).build()

+ 1 - 3
server/src/test/java/org/elasticsearch/index/mapper/vectors/SparseVectorFieldMapperTests.java

@@ -8,7 +8,6 @@
 
 package org.elasticsearch.index.mapper.vectors;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.compress.CompressedXContent;
@@ -23,7 +22,6 @@ import org.elasticsearch.index.mapper.MapperParsingException;
 import org.elasticsearch.index.mapper.MapperService;
 import org.elasticsearch.index.mapper.SourceToParse;
 import org.elasticsearch.test.ESSingleNodeTestCase;
-import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.index.IndexVersionUtils;
 import org.elasticsearch.xcontent.XContentFactory;
 import org.elasticsearch.xcontent.XContentType;
@@ -46,7 +44,7 @@ public class SparseVectorFieldMapperTests extends ESSingleNodeTestCase {
     }
 
     public void testSparseVectorWith8xIndex() throws Exception {
-        Version version = VersionUtils.randomVersionBetween(random(), Version.V_8_0_0, Version.CURRENT);
+        IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_8_0_0, IndexVersion.current());
         Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version).build();
 
         IndexService indexService = createIndex("index", settings);

+ 1 - 2
server/src/test/java/org/elasticsearch/indices/IndicesServiceTests.java

@@ -10,7 +10,6 @@ package org.elasticsearch.indices;
 import org.apache.lucene.search.similarities.BM25Similarity;
 import org.apache.lucene.search.similarities.Similarity;
 import org.apache.lucene.store.AlreadyClosedException;
-import org.elasticsearch.Version;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
 import org.elasticsearch.action.admin.indices.stats.IndexShardStats;
@@ -437,7 +436,7 @@ public class IndicesServiceTests extends ESSingleNodeTestCase {
         // import an index with minor version incremented by one over cluster master version, it should be ignored
         final LocalAllocateDangledIndices dangling = getInstanceFromNode(LocalAllocateDangledIndices.class);
         final Settings idxSettingsLater = Settings.builder()
-            .put(IndexMetadata.SETTING_VERSION_CREATED, Version.fromId(Version.CURRENT.id + 10000))
+            .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersion.fromId(IndexVersion.current().id() + 10000))
             .put(IndexMetadata.SETTING_INDEX_UUID, UUIDs.randomBase64UUID())
             .build();
         final IndexMetadata indexMetadataLater = new IndexMetadata.Builder(indexNameLater).settings(idxSettingsLater)

+ 2 - 4
server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java

@@ -14,7 +14,6 @@ import org.apache.lucene.analysis.hunspell.Dictionary;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.tests.analysis.MockTokenizer;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
@@ -42,7 +41,6 @@ import org.elasticsearch.plugins.AnalysisPlugin;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
 import org.elasticsearch.test.index.IndexVersionUtils;
 import org.elasticsearch.xcontent.XContentType;
 import org.hamcrest.MatcherAssert;
@@ -193,7 +191,7 @@ public class AnalysisModuleTests extends ESTestCase {
         // cacheing bug meant that it was still possible to create indexes using a standard
         // filter until 7.6
         {
-            Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_6_0, Version.CURRENT);
+            IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_6_0, IndexVersion.current());
             final Settings settings = Settings.builder()
                 .put("index.analysis.analyzer.my_standard.tokenizer", "standard")
                 .put("index.analysis.analyzer.my_standard.filter", "standard")
@@ -204,7 +202,7 @@ public class AnalysisModuleTests extends ESTestCase {
             assertThat(exc.getMessage(), equalTo("The [standard] token filter has been removed."));
         }
         {
-            Version version = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.V_7_5_2);
+            IndexVersion version = IndexVersionUtils.randomVersionBetween(random(), IndexVersion.V_7_0_0, IndexVersion.V_7_5_2);
             final Settings settings = Settings.builder()
                 .put("index.analysis.analyzer.my_standard.tokenizer", "standard")
                 .put("index.analysis.analyzer.my_standard.filter", "standard")

+ 4 - 4
server/src/test/java/org/elasticsearch/indices/analysis/IncorrectSetupStablePluginsTests.java

@@ -27,7 +27,7 @@ import org.elasticsearch.plugins.scanners.PluginInfo;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -62,7 +62,7 @@ public class IncorrectSetupStablePluginsTests extends ESTestCase {
                 Settings.builder()
                     .put("index.analysis.analyzer.char_filter_test.tokenizer", "standard")
                     .put("index.analysis.analyzer.char_filter_test.char_filter", "incorrectlyAnnotatedSettings")
-                    .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                    .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                     .build(),
                 Map.of(
                     "incorrectlyAnnotatedSettings",
@@ -89,7 +89,7 @@ public class IncorrectSetupStablePluginsTests extends ESTestCase {
                 Settings.builder()
                     .put("index.analysis.analyzer.char_filter_test.tokenizer", "standard")
                     .put("index.analysis.analyzer.char_filter_test.char_filter", "noInjectCharFilter")
-                    .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                    .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                     .build(),
                 Map.of("noInjectCharFilter", new PluginInfo("noInjectCharFilter", NoInjectCharFilter.class.getName(), classLoader))
             )
@@ -111,7 +111,7 @@ public class IncorrectSetupStablePluginsTests extends ESTestCase {
                 Settings.builder()
                     .put("index.analysis.analyzer.char_filter_test.tokenizer", "standard")
                     .put("index.analysis.analyzer.char_filter_test.char_filter", "multipleConstructors")
-                    .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                    .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                     .build(),
                 Map.of("multipleConstructors", new PluginInfo("multipleConstructors", MultipleConstructors.class.getName(), classLoader))
             )

+ 3 - 3
server/src/test/java/org/elasticsearch/indices/analysis/StableAnalysisPluginsNoSettingsTests.java

@@ -11,13 +11,13 @@ package org.elasticsearch.indices.analysis;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.Tokenizer;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.env.TestEnvironment;
 import org.elasticsearch.index.IndexService.IndexCreationContext;
 import org.elasticsearch.index.IndexSettings;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.analysis.AnalysisRegistry;
 import org.elasticsearch.index.analysis.IndexAnalyzers;
 import org.elasticsearch.indices.analysis.lucene.AppendTokenFilter;
@@ -36,7 +36,7 @@ import org.elasticsearch.plugins.scanners.PluginInfo;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -60,7 +60,7 @@ public class StableAnalysisPluginsNoSettingsTests extends ESTestCase {
     }
 
     public void testStablePlugins() throws IOException {
-        Version version = VersionUtils.randomVersion(random());
+        IndexVersion version = IndexVersionUtils.randomVersion(random());
         IndexAnalyzers analyzers = getIndexAnalyzers(
             Settings.builder()
                 .put("index.analysis.analyzer.char_filter_test.tokenizer", "standard")

+ 5 - 5
server/src/test/java/org/elasticsearch/indices/analysis/StableAnalysisPluginsWithSettingsTests.java

@@ -42,7 +42,7 @@ import org.elasticsearch.plugins.scanners.PluginInfo;
 import org.elasticsearch.plugins.scanners.StablePluginsRegistry;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.test.IndexSettingsModule;
-import org.elasticsearch.test.VersionUtils;
+import org.elasticsearch.test.index.IndexVersionUtils;
 
 import java.io.IOException;
 import java.io.Reader;
@@ -71,7 +71,7 @@ public class StableAnalysisPluginsWithSettingsTests extends ESTestCase {
                 .put("index.analysis.analyzer.char_filter_with_defaults_test.tokenizer", "standard")
                 .put("index.analysis.analyzer.char_filter_with_defaults_test.char_filter", "stableCharFilterFactory")
 
-                .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                 .build()
         );
         assertTokenStreamContents(analyzers.get("char_filter_test").tokenStream("", "t#st"), new String[] { "t3st" });
@@ -87,7 +87,7 @@ public class StableAnalysisPluginsWithSettingsTests extends ESTestCase {
 
                 .put("index.analysis.analyzer.token_filter_test.tokenizer", "standard")
                 .put("index.analysis.analyzer.token_filter_test.filter", "my_token_filter")
-                .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                 .build()
         );
         assertTokenStreamContents(
@@ -108,7 +108,7 @@ public class StableAnalysisPluginsWithSettingsTests extends ESTestCase {
                 .putList("index.analysis.tokenizer.my_tokenizer.tokenizer_list_of_chars", "_", " ")
 
                 .put("index.analysis.analyzer.tokenizer_test.tokenizer", "my_tokenizer")
-                .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                 .build()
         );
         assertTokenStreamContents(analyzers.get("tokenizer_test").tokenStream("", "x_y z"), new String[] { "x", "y", "z" });
@@ -123,7 +123,7 @@ public class StableAnalysisPluginsWithSettingsTests extends ESTestCase {
                 .put("index.analysis.analyzer.analyzer_provider_test.old_char", "#")
                 .put("index.analysis.analyzer.analyzer_provider_test.new_number", 3)
                 .put("index.analysis.analyzer.analyzer_provider_test.analyzerUseTokenListOfChars", true)
-                .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersion(random()))
+                .put(IndexMetadata.SETTING_VERSION_CREATED, IndexVersionUtils.randomVersion(random()))
                 .build()
         );
         assertTokenStreamContents(analyzers.get("analyzer_provider_test").tokenStream("", "1x_y_#z"), new String[] { "y", "3z" });

+ 3 - 3
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java

@@ -7,7 +7,6 @@
 package org.elasticsearch.xpack.ml.job.process.autodetect;
 
 import org.elasticsearch.ElasticsearchException;
-import org.elasticsearch.Version;
 import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.ActionType;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
@@ -28,6 +27,7 @@ import org.elasticsearch.core.CheckedConsumer;
 import org.elasticsearch.core.TimeValue;
 import org.elasticsearch.env.Environment;
 import org.elasticsearch.env.TestEnvironment;
+import org.elasticsearch.index.IndexVersion;
 import org.elasticsearch.index.analysis.AnalysisRegistry;
 import org.elasticsearch.indices.TestIndexNameExpressionResolver;
 import org.elasticsearch.license.XPackLicenseState;
@@ -212,7 +212,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
                                 .put(SETTING_INDEX_HIDDEN, true)
-                                .put(SETTING_VERSION_CREATED, Version.CURRENT)
+                                .put(SETTING_VERSION_CREATED, IndexVersion.current())
                                 .build()
                         )
                         .putAlias(AliasMetadata.builder(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).isHidden(true).build())
@@ -224,7 +224,7 @@ public class AutodetectProcessManagerTests extends ESTestCase {
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
                                 .put(SETTING_INDEX_HIDDEN, true)
-                                .put(SETTING_VERSION_CREATED, Version.CURRENT)
+                                .put(SETTING_VERSION_CREATED, IndexVersion.current())
                                 .build()
                         )
                         .putAlias(AliasMetadata.builder(AnnotationIndex.READ_ALIAS_NAME).isHidden(true).build())

+ 0 - 13
x-pack/plugin/wildcard/src/test/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapperTests.java

@@ -42,7 +42,6 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.automaton.Automaton;
 import org.apache.lucene.util.automaton.ByteRunAutomaton;
 import org.apache.lucene.util.automaton.RegExp;
-import org.elasticsearch.Version;
 import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.common.lucene.search.AutomatonQueries;
 import org.elasticsearch.common.settings.ClusterSettings;
@@ -1142,18 +1141,6 @@ public class WildcardFieldMapperTests extends MapperTestCase {
         iw.addDocument(doc);
     }
 
-    protected IndexSettings createIndexSettings(Version version) {
-        return new IndexSettings(
-            IndexMetadata.builder("_index")
-                .settings(Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, version))
-                .numberOfShards(1)
-                .numberOfReplicas(0)
-                .creationDate(System.currentTimeMillis())
-                .build(),
-            Settings.EMPTY
-        );
-    }
-
     static String randomABString(int minLength) {
         StringBuilder sb = new StringBuilder();
         while (sb.length() < minLength) {