From 8bbb1946e17c17cc3610da2a6a1fb21f5de7f3ab Mon Sep 17 00:00:00 2001 From: Nick Knize Date: Wed, 2 Nov 2022 14:39:45 -0500 Subject: [PATCH] [Remove] Version.V_1_ constants (#5021) * [Remove] Version.V_1_ constants Removes all usages of Version.V_1_ version constants along with ancient API logic. Signed-off-by: Nicholas Walter Knize * update changelog Signed-off-by: Nicholas Walter Knize * retain version utils version 1 check Signed-off-by: Nicholas Walter Knize * remove v1 test from mincompat testing Signed-off-by: Nicholas Walter Knize * fix versions and remove bwc test from pluginsInfoTests Signed-off-by: Nicholas Walter Knize * remove unused es warning check Signed-off-by: Nicholas Walter Knize * improve legibility of removed v1 constant Signed-off-by: Nicholas Walter Knize Signed-off-by: Nicholas Walter Knize --- CHANGELOG.md | 1 + .../client/core/MainResponseTests.java | 13 ++--- .../common/EdgeNGramTokenizerTests.java | 2 +- .../common/SynonymsAnalysisTests.java | 6 +-- .../AnalysisPhoneticFactoryTests.java | 2 +- .../src/main/java/org/opensearch/Version.java | 14 ------ .../admin/cluster/node/stats/NodeStats.java | 12 +---- .../admin/indices/stats/CommonStatsFlags.java | 12 ++--- .../action/search/SearchRequest.java | 10 +--- .../coordination/JoinTaskExecutor.java | 31 ------------ .../cluster/health/ClusterStateHealth.java | 11 +---- .../metadata/ComposableIndexTemplate.java | 11 +---- .../index/query/IntervalsSourceProvider.java | 49 +++---------------- .../functionscore/ScoreFunctionBuilder.java | 9 +--- .../org/opensearch/monitor/jvm/JvmStats.java | 11 +---- .../org/opensearch/plugins/PluginInfo.java | 26 +++------- .../CompositeValuesSourceBuilder.java | 9 +--- .../bucket/composite/InternalComposite.java | 12 +---- .../transport/TransportHandshaker.java | 13 ----- .../test/java/org/opensearch/BuildTests.java | 4 +- .../java/org/opensearch/VersionTests.java | 37 +++++++------- .../action/main/MainResponseTests.java | 4 +- .../search/MultiSearchRequestTests.java | 13 ++--- .../action/search/SearchRequestTests.java | 7 +-- .../action/support/IndicesOptionsTests.java | 2 +- .../metadata/AutoExpandReplicasTests.java | 4 +- .../common/lucene/uid/VersionsTests.java | 4 +- .../opensearch/index/IndexSettingsTests.java | 4 +- .../index/mapper/ParametrizedMapperTests.java | 2 +- .../opensearch/plugins/PluginInfoTests.java | 28 ----------- .../transport/InboundDecoderTests.java | 2 +- .../transport/TransportHandshakerTests.java | 5 -- .../org/opensearch/test/VersionUtils.java | 5 +- .../test/rest/OpenSearchRestTestCase.java | 34 +------------ 34 files changed, 87 insertions(+), 322 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d72ffef9c852..702f1bbd62ab7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -134,6 +134,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Remove LegacyESVersion.V_7_8_ and V_7_9_ Constants ([#4855](https://github.com/opensearch-project/OpenSearch/pull/4855)) - Remove LegacyESVersion.V_7_6_ and V_7_7_ Constants ([#4837](https://github.com/opensearch-project/OpenSearch/pull/4837)) - Remove LegacyESVersion.V_7_10_ Constants ([#5018](https://github.com/opensearch-project/OpenSearch/pull/5018)) +- Remove Version.V_1_ Constants ([#5021](https://github.com/opensearch-project/OpenSearch/pull/5021)) ### Fixed - `opensearch-service.bat start` and `opensearch-service.bat manager` failing to run ([#4289](https://github.com/opensearch-project/OpenSearch/pull/4289)) diff --git a/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java b/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java index cd759aa62eaf1..b5985cb419506 100644 --- a/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java +++ b/client/rest-high-level/src/test/java/org/opensearch/client/core/MainResponseTests.java @@ -46,21 +46,16 @@ import static org.hamcrest.Matchers.equalTo; public class MainResponseTests extends AbstractResponseTestCase { + private static String DISTRIBUTION = "opensearch"; + @Override protected org.opensearch.action.main.MainResponse createServerTestInstance(XContentType xContentType) { String clusterUuid = randomAlphaOfLength(10); ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); String nodeName = randomAlphaOfLength(10); final String date = new Date(randomNonNegativeLong()).toString(); - Version version = VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT); - Build build = new Build( - Build.Type.UNKNOWN, - randomAlphaOfLength(8), - date, - randomBoolean(), - version.toString(), - version.before(Version.V_1_0_0) ? null : "opensearch" - ); + Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT); + Build build = new Build(Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString(), DISTRIBUTION); return new org.opensearch.action.main.MainResponse(nodeName, version, clusterName, clusterUuid, build); } diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java index 172d91086f675..ae3ebde99bd98 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/EdgeNGramTokenizerTests.java @@ -83,7 +83,7 @@ public void testPreConfiguredTokenizer() throws IOException { { try ( IndexAnalyzers indexAnalyzers = buildAnalyzers( - VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, VersionUtils.getPreviousVersion(Version.V_3_0_0)), + VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, VersionUtils.getPreviousVersion(Version.V_3_0_0)), "edgeNGram" ) ) { diff --git a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java index c078c7dabc63a..a9d470e3fd544 100644 --- a/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java +++ b/modules/analysis-common/src/test/java/org/opensearch/analysis/common/SynonymsAnalysisTests.java @@ -230,7 +230,7 @@ public void testChainedSynonymFilters() throws IOException { public void testShingleFilters() { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .put("index.analysis.filter.synonyms.type", "synonym") .putList("index.analysis.filter.synonyms.synonyms", "programmer, developer") @@ -289,7 +289,7 @@ public void testPreconfiguredTokenFilters() throws IOException { ); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); @@ -313,7 +313,7 @@ public void testPreconfiguredTokenFilters() throws IOException { public void testDisallowedTokenFilters() throws IOException { Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .putList("common_words", "a", "b") .put("output_unigrams", "true") diff --git a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java index 19bc27f6e616d..62fb6e22b8950 100644 --- a/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java +++ b/plugins/analysis-phonetic/src/test/java/org/opensearch/index/analysis/AnalysisPhoneticFactoryTests.java @@ -64,7 +64,7 @@ public void testDisallowedWithSynonyms() throws IOException { AnalysisPhoneticPlugin plugin = new AnalysisPhoneticPlugin(); Settings settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT)) + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT)) .put("path.home", createTempDir().toString()) .build(); IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", settings); diff --git a/server/src/main/java/org/opensearch/Version.java b/server/src/main/java/org/opensearch/Version.java index 823130cd072c2..b48384e9439ec 100644 --- a/server/src/main/java/org/opensearch/Version.java +++ b/server/src/main/java/org/opensearch/Version.java @@ -75,20 +75,6 @@ public class Version implements Comparable, ToXContentFragment { public static final int V_EMPTY_ID = 0; public static final Version V_EMPTY = new Version(V_EMPTY_ID, org.apache.lucene.util.Version.LATEST); - public static final Version V_1_0_0 = new Version(1000099, org.apache.lucene.util.Version.LUCENE_8_8_2); - public static final Version V_1_1_0 = new Version(1010099, org.apache.lucene.util.Version.LUCENE_8_9_0); - public static final Version V_1_2_0 = new Version(1020099, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_2_1 = new Version(1020199, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_2_2 = new Version(1020299, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_2_3 = new Version(1020399, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_2_4 = new Version(1020499, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_2_5 = new Version(1020599, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_0 = new Version(1030099, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_1 = new Version(1030199, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_2 = new Version(1030299, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_3 = new Version(1030399, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_4 = new Version(1030499, org.apache.lucene.util.Version.LUCENE_8_10_1); - public static final Version V_1_3_5 = new Version(1030599, org.apache.lucene.util.Version.LUCENE_8_10_1); public static final Version V_2_0_0 = new Version(2000099, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version V_2_0_1 = new Version(2000199, org.apache.lucene.util.Version.LUCENE_9_1_0); public static final Version V_2_0_2 = new Version(2000299, org.apache.lucene.util.Version.LUCENE_9_1_0); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java index aa8849934f6ee..a9d406b23ac87 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java @@ -32,7 +32,6 @@ package org.opensearch.action.admin.cluster.node.stats; -import org.opensearch.Version; import org.opensearch.action.support.nodes.BaseNodeResponse; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.node.DiscoveryNodeRole; @@ -141,12 +140,7 @@ public NodeStats(StreamInput in) throws IOException { scriptCacheStats = scriptStats.toScriptCacheStats(); } indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new); - if (in.getVersion().onOrAfter(Version.V_1_2_0)) { - shardIndexingPressureStats = in.readOptionalWriteable(ShardIndexingPressureStats::new); - } else { - shardIndexingPressureStats = null; - } - + shardIndexingPressureStats = in.readOptionalWriteable(ShardIndexingPressureStats::new); } public NodeStats( @@ -319,9 +313,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(ingestStats); out.writeOptionalWriteable(adaptiveSelectionStats); out.writeOptionalWriteable(indexingPressureStats); - if (out.getVersion().onOrAfter(Version.V_1_2_0)) { - out.writeOptionalWriteable(shardIndexingPressureStats); - } + out.writeOptionalWriteable(shardIndexingPressureStats); } @Override diff --git a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java index fd3d6daa9c393..62ebbba500a6a 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/stats/CommonStatsFlags.java @@ -87,10 +87,8 @@ public CommonStatsFlags(StreamInput in) throws IOException { completionDataFields = in.readStringArray(); includeSegmentFileSizes = in.readBoolean(); includeUnloadedSegments = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_1_2_0)) { - includeAllShardIndexingPressureTrackers = in.readBoolean(); - includeOnlyTopIndexingPressureMetrics = in.readBoolean(); - } + includeAllShardIndexingPressureTrackers = in.readBoolean(); + includeOnlyTopIndexingPressureMetrics = in.readBoolean(); } @Override @@ -109,10 +107,8 @@ public void writeTo(StreamOutput out) throws IOException { out.writeStringArrayNullable(completionDataFields); out.writeBoolean(includeSegmentFileSizes); out.writeBoolean(includeUnloadedSegments); - if (out.getVersion().onOrAfter(Version.V_1_2_0)) { - out.writeBoolean(includeAllShardIndexingPressureTrackers); - out.writeBoolean(includeOnlyTopIndexingPressureMetrics); - } + out.writeBoolean(includeAllShardIndexingPressureTrackers); + out.writeBoolean(includeOnlyTopIndexingPressureMetrics); } /** diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequest.java b/server/src/main/java/org/opensearch/action/search/SearchRequest.java index ceb2a150bf352..a3b00801bd6f7 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequest.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequest.java @@ -247,10 +247,7 @@ public SearchRequest(StreamInput in) throws IOException { finalReduce = true; } ccsMinimizeRoundtrips = in.readBoolean(); - - if (in.getVersion().onOrAfter(Version.V_1_1_0)) { - cancelAfterTimeInterval = in.readOptionalTimeValue(); - } + cancelAfterTimeInterval = in.readOptionalTimeValue(); } @Override @@ -278,10 +275,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(finalReduce); } out.writeBoolean(ccsMinimizeRoundtrips); - - if (out.getVersion().onOrAfter(Version.V_1_1_0)) { - out.writeOptionalTimeValue(cancelAfterTimeInterval); - } + out.writeOptionalTimeValue(cancelAfterTimeInterval); } @Override diff --git a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java index 1004663dc875a..4cb6c7b255449 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java @@ -312,37 +312,6 @@ private void refreshDiscoveryNodeVersionAfterUpgrade(DiscoveryNodes currentNodes // this logic is only applicable when OpenSearch node is cluster-manager and is noop for zen discovery node return; } - if (currentNodes.getMinNodeVersion().before(Version.V_1_0_0)) { - Map channelVersions = transportService.getChannelVersion(currentNodes); - for (DiscoveryNode node : currentNodes) { - if (channelVersions.containsKey(node.getId())) { - if (channelVersions.get(node.getId()) != node.getVersion()) { - DiscoveryNode tmpNode = nodesBuilder.get(node.getId()); - nodesBuilder.remove(node.getId()); - nodesBuilder.add( - new DiscoveryNode( - tmpNode.getName(), - tmpNode.getId(), - tmpNode.getEphemeralId(), - tmpNode.getHostName(), - tmpNode.getHostAddress(), - tmpNode.getAddress(), - tmpNode.getAttributes(), - tmpNode.getRoles(), - channelVersions.get(tmpNode.getId()) - ) - ); - logger.info( - "Refreshed the DiscoveryNode version for node {}:{} from {} to {}", - node.getId(), - node.getAddress(), - node.getVersion(), - channelVersions.get(tmpNode.getId()) - ); - } - } - } - } } @Override diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java index 673695e217a5b..981015c7dc7dc 100644 --- a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java +++ b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java @@ -31,7 +31,6 @@ package org.opensearch.cluster.health; -import org.opensearch.Version; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexMetadata; import org.opensearch.cluster.routing.IndexRoutingTable; @@ -154,11 +153,7 @@ public ClusterStateHealth(final StreamInput in) throws IOException { unassignedShards = in.readVInt(); numberOfNodes = in.readVInt(); numberOfDataNodes = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_1_0_0)) { - hasDiscoveredClusterManager = in.readBoolean(); - } else { - hasDiscoveredClusterManager = true; - } + hasDiscoveredClusterManager = in.readBoolean(); status = ClusterHealthStatus.fromValue(in.readByte()); int size = in.readVInt(); indices = new HashMap<>(size); @@ -262,9 +257,7 @@ public void writeTo(final StreamOutput out) throws IOException { out.writeVInt(unassignedShards); out.writeVInt(numberOfNodes); out.writeVInt(numberOfDataNodes); - if (out.getVersion().onOrAfter(Version.V_1_0_0)) { - out.writeBoolean(hasDiscoveredClusterManager); - } + out.writeBoolean(hasDiscoveredClusterManager); out.writeByte(status.value()); out.writeVInt(indices.size()); for (ClusterIndexHealth indexHealth : this) { diff --git a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java index 96ae94f807a04..d350f4deb3077 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/ComposableIndexTemplate.java @@ -32,7 +32,6 @@ package org.opensearch.cluster.metadata; -import org.opensearch.Version; import org.opensearch.cluster.AbstractDiffable; import org.opensearch.cluster.Diff; import org.opensearch.cluster.metadata.DataStream.TimestampField; @@ -312,11 +311,7 @@ public DataStreamTemplate(TimestampField timestampField) { } public DataStreamTemplate(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_1_0_0)) { - this.timestampField = in.readOptionalWriteable(TimestampField::new); - } else { - this.timestampField = DataStreamFieldMapper.Defaults.TIMESTAMP_FIELD; - } + this.timestampField = in.readOptionalWriteable(TimestampField::new); } public TimestampField getTimestampField() { @@ -335,9 +330,7 @@ public Map getDataStreamMappingSnippet() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_1_0_0)) { - out.writeOptionalWriteable(timestampField); - } + out.writeOptionalWriteable(timestampField); } @Override diff --git a/server/src/main/java/org/opensearch/index/query/IntervalsSourceProvider.java b/server/src/main/java/org/opensearch/index/query/IntervalsSourceProvider.java index e1cb0cdff4ebd..131bc3348f4fb 100644 --- a/server/src/main/java/org/opensearch/index/query/IntervalsSourceProvider.java +++ b/server/src/main/java/org/opensearch/index/query/IntervalsSourceProvider.java @@ -41,7 +41,6 @@ import org.apache.lucene.util.BytesRef; import org.apache.lucene.util.automaton.CompiledAutomaton; import org.apache.lucene.util.automaton.RegExp; -import org.opensearch.Version; import org.opensearch.common.ParseField; import org.opensearch.common.ParsingException; import org.opensearch.common.io.stream.NamedWriteable; @@ -154,15 +153,7 @@ public Match(String query, int maxGaps, IntervalMode mode, String analyzer, Inte public Match(StreamInput in) throws IOException { this.query = in.readString(); this.maxGaps = in.readVInt(); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.mode = IntervalMode.readFromStream(in); - } else { - if (in.readBoolean()) { - this.mode = IntervalMode.ORDERED; - } else { - this.mode = IntervalMode.UNORDERED; - } - } + this.mode = IntervalMode.readFromStream(in); this.analyzer = in.readOptionalString(); this.filter = in.readOptionalWriteable(IntervalFilter::new); this.useField = in.readOptionalString(); @@ -222,11 +213,7 @@ public String getWriteableName() { public void writeTo(StreamOutput out) throws IOException { out.writeString(query); out.writeVInt(maxGaps); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - mode.writeTo(out); - } else { - out.writeBoolean(mode == IntervalMode.ORDERED); - } + mode.writeTo(out); out.writeOptionalString(analyzer); out.writeOptionalWriteable(filter); out.writeOptionalString(useField); @@ -442,11 +429,7 @@ public Combine(List subSources, IntervalMode mode, int } public Combine(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.mode = IntervalMode.readFromStream(in); - } else { - this.mode = in.readBoolean() ? IntervalMode.ORDERED : IntervalMode.UNORDERED; - } + this.mode = IntervalMode.readFromStream(in); this.subSources = in.readNamedWriteableList(IntervalsSourceProvider.class); this.maxGaps = in.readInt(); this.filter = in.readOptionalWriteable(IntervalFilter::new); @@ -495,11 +478,7 @@ public String getWriteableName() { @Override public void writeTo(StreamOutput out) throws IOException { - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - mode.writeTo(out); - } else { - out.writeBoolean(mode == IntervalMode.ORDERED); - } + mode.writeTo(out); out.writeNamedWriteableList(subSources); out.writeInt(maxGaps); out.writeOptionalWriteable(filter); @@ -729,11 +708,7 @@ public Regexp(StreamInput in) throws IOException { this.flags = in.readVInt(); this.useField = in.readOptionalString(); this.maxExpansions = in.readOptionalVInt(); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.caseInsensitive = in.readBoolean(); - } else { - this.caseInsensitive = false; - } + this.caseInsensitive = in.readBoolean(); } @Override @@ -803,9 +778,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(flags); out.writeOptionalString(useField); out.writeOptionalVInt(maxExpansions); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - out.writeBoolean(caseInsensitive); - } + out.writeBoolean(caseInsensitive); } @Override @@ -903,11 +876,7 @@ public Wildcard(StreamInput in) throws IOException { this.pattern = in.readString(); this.analyzer = in.readOptionalString(); this.useField = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.maxExpansions = in.readOptionalVInt(); - } else { - this.maxExpansions = null; - } + this.maxExpansions = in.readOptionalVInt(); } @Override @@ -976,9 +945,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(pattern); out.writeOptionalString(analyzer); out.writeOptionalString(useField); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - out.writeOptionalVInt(maxExpansions); - } + out.writeOptionalVInt(maxExpansions); } @Override diff --git a/server/src/main/java/org/opensearch/index/query/functionscore/ScoreFunctionBuilder.java b/server/src/main/java/org/opensearch/index/query/functionscore/ScoreFunctionBuilder.java index 564a4a9de0f19..b2f52c3666643 100644 --- a/server/src/main/java/org/opensearch/index/query/functionscore/ScoreFunctionBuilder.java +++ b/server/src/main/java/org/opensearch/index/query/functionscore/ScoreFunctionBuilder.java @@ -32,7 +32,6 @@ package org.opensearch.index.query.functionscore; -import org.opensearch.Version; import org.opensearch.common.io.stream.NamedWriteable; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; @@ -65,17 +64,13 @@ public ScoreFunctionBuilder() {} */ public ScoreFunctionBuilder(StreamInput in) throws IOException { weight = checkWeight(in.readOptionalFloat()); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - functionName = in.readOptionalString(); - } + functionName = in.readOptionalString(); } @Override public final void writeTo(StreamOutput out) throws IOException { out.writeOptionalFloat(weight); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - out.writeOptionalString(functionName); - } + out.writeOptionalString(functionName); doWriteTo(out); } diff --git a/server/src/main/java/org/opensearch/monitor/jvm/JvmStats.java b/server/src/main/java/org/opensearch/monitor/jvm/JvmStats.java index 172ab8aae4ccd..88242af50a389 100644 --- a/server/src/main/java/org/opensearch/monitor/jvm/JvmStats.java +++ b/server/src/main/java/org/opensearch/monitor/jvm/JvmStats.java @@ -32,7 +32,6 @@ package org.opensearch.monitor.jvm; -import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -554,11 +553,7 @@ public MemoryPool(StreamInput in) throws IOException { max = in.readVLong(); peakUsed = in.readVLong(); peakMax = in.readVLong(); - if (in.getVersion().onOrAfter(Version.V_1_2_0)) { - lastGcStats = new MemoryPoolGcStats(in); - } else { - lastGcStats = new MemoryPoolGcStats(0, 0); - } + lastGcStats = new MemoryPoolGcStats(in); } @Override @@ -568,9 +563,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVLong(max); out.writeVLong(peakUsed); out.writeVLong(peakMax); - if (out.getVersion().onOrAfter(Version.V_1_2_0)) { - lastGcStats.writeTo(out); - } + lastGcStats.writeTo(out); } public String getName() { diff --git a/server/src/main/java/org/opensearch/plugins/PluginInfo.java b/server/src/main/java/org/opensearch/plugins/PluginInfo.java index bcb8e4d6fc97d..5884abc717bd8 100644 --- a/server/src/main/java/org/opensearch/plugins/PluginInfo.java +++ b/server/src/main/java/org/opensearch/plugins/PluginInfo.java @@ -157,13 +157,9 @@ public PluginInfo(final StreamInput in) throws IOException { this.opensearchVersion = Version.readVersion(in); this.javaVersion = in.readString(); this.classname = in.readString(); - if (in.getVersion().onOrAfter(Version.V_1_1_0)) { - customFolderName = in.readString(); - } else { - customFolderName = this.name; - } - extendedPlugins = in.readStringList(); - hasNativeController = in.readBoolean(); + this.customFolderName = in.readString(); + this.extendedPlugins = in.readStringList(); + this.hasNativeController = in.readBoolean(); } @Override @@ -174,12 +170,10 @@ public void writeTo(final StreamOutput out) throws IOException { Version.writeVersion(opensearchVersion, out); out.writeString(javaVersion); out.writeString(classname); - if (out.getVersion().onOrAfter(Version.V_1_1_0)) { - if (customFolderName != null) { - out.writeString(customFolderName); - } else { - out.writeString(name); - } + if (customFolderName != null) { + out.writeString(customFolderName); + } else { + out.writeString(name); } out.writeStringCollection(extendedPlugins); out.writeBoolean(hasNativeController); @@ -234,11 +228,7 @@ public static PluginInfo readFromProperties(final Path path) throws IOException final String customFolderNameValue = propsMap.remove("custom.foldername"); final String customFolderName; - if (opensearchVersion.onOrAfter(Version.V_1_1_0)) { - customFolderName = customFolderNameValue; - } else { - customFolderName = name; - } + customFolderName = customFolderNameValue; final String extendedString = propsMap.remove("extended.plugins"); final List extendedPlugins; diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java index 26015ae04cf76..c3e9b0f6fa0e7 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java @@ -32,7 +32,6 @@ package org.opensearch.search.aggregations.bucket.composite; -import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.io.stream.Writeable; @@ -83,9 +82,7 @@ public CompositeValuesSourceBuilder(StreamInput in) throws IOException { this.userValueTypeHint = ValueType.readFromStream(in); } this.missingBucket = in.readBoolean(); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.missingOrder = MissingOrder.readFromStream(in); - } + this.missingOrder = MissingOrder.readFromStream(in); this.order = SortOrder.readFromStream(in); this.format = in.readOptionalString(); } @@ -105,9 +102,7 @@ public final void writeTo(StreamOutput out) throws IOException { userValueTypeHint.writeTo(out); } out.writeBoolean(missingBucket); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - missingOrder.writeTo(out); - } + missingOrder.writeTo(out); order.writeTo(out); out.writeOptionalString(format); innerWriteTo(out); diff --git a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java index 9b05ba4d14b4e..ceb79ac049567 100644 --- a/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java +++ b/server/src/main/java/org/opensearch/search/aggregations/bucket/composite/InternalComposite.java @@ -33,7 +33,6 @@ package org.opensearch.search.aggregations.bucket.composite; import org.apache.lucene.util.BytesRef; -import org.opensearch.Version; import org.opensearch.common.io.stream.StreamInput; import org.opensearch.common.io.stream.StreamOutput; import org.opensearch.common.xcontent.XContentBuilder; @@ -108,12 +107,7 @@ public InternalComposite(StreamInput in) throws IOException { formats.add(in.readNamedWriteable(DocValueFormat.class)); } this.reverseMuls = in.readIntArray(); - if (in.getVersion().onOrAfter(Version.V_1_3_0)) { - this.missingOrders = in.readArray(MissingOrder::readFromStream, MissingOrder[]::new); - } else { - this.missingOrders = new MissingOrder[reverseMuls.length]; - Arrays.fill(this.missingOrders, MissingOrder.DEFAULT); - } + this.missingOrders = in.readArray(MissingOrder::readFromStream, MissingOrder[]::new); this.buckets = in.readList((input) -> new InternalBucket(input, sourceNames, formats, reverseMuls, missingOrders)); this.afterKey = in.readBoolean() ? new CompositeKey(in) : null; this.earlyTerminated = in.readBoolean(); @@ -127,9 +121,7 @@ protected void doWriteTo(StreamOutput out) throws IOException { out.writeNamedWriteable(format); } out.writeIntArray(reverseMuls); - if (out.getVersion().onOrAfter(Version.V_1_3_0)) { - out.writeArray((output, order) -> order.writeTo(output), missingOrders); - } + out.writeArray((output, order) -> order.writeTo(output), missingOrders); out.writeList(buckets); out.writeBoolean(afterKey != null); if (afterKey != null) { diff --git a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java index e24b4526e42be..2cf3b30bc21de 100644 --- a/server/src/main/java/org/opensearch/transport/TransportHandshaker.java +++ b/server/src/main/java/org/opensearch/transport/TransportHandshaker.java @@ -83,19 +83,6 @@ void sendHandshake(long requestId, DiscoveryNode node, TcpChannel channel, TimeV // we also have no payload on the request but the response will contain the actual version of the node we talk // to as the payload. Version minCompatVersion = version.minimumCompatibilityVersion(); - if (version.onOrAfter(Version.V_1_0_0) && version.before(Version.V_2_0_0)) { - // the minCompatibleVersion for OpenSearch 1.x is sent as 6.7.99 instead of 6.8.0 - // as this helps in (indirectly) identifying the remote node version during handle HandshakeRequest itself - // and then send appropriate version (7.10.2/ OpenSearch 1.x version) in response. - // The advantage of doing this is early identification of remote node version as otherwise - // if OpenSearch node also sends 6.8.0, there is no way to differentiate ES 7.x version from - // OpenSearch version and OpenSearch node will end up sending BC version to both ES & OpenSearch remote node. - // Sending only BC version to ElasticSearch node provide easy deprecation path for this BC version logic - // in OpenSearch 2.0.0. - minCompatVersion = Version.fromId(6079999); - } else if (version.before(Version.V_3_0_0)) { - minCompatVersion = Version.fromId(7099999); - } handshakeRequestSender.sendRequest(node, channel, requestId, minCompatVersion); threadPool.schedule( diff --git a/server/src/test/java/org/opensearch/BuildTests.java b/server/src/test/java/org/opensearch/BuildTests.java index 6e6a91419b762..d99768aa34891 100644 --- a/server/src/test/java/org/opensearch/BuildTests.java +++ b/server/src/test/java/org/opensearch/BuildTests.java @@ -301,9 +301,7 @@ public void testSerializationBWC() throws IOException { final List versions = Version.getDeclaredVersions(Version.class); - final Version post10OpenSearchVersion = randomFrom( - versions.stream().filter(v -> v.onOrAfter(Version.V_1_0_0)).collect(Collectors.toList()) - ); + final Version post10OpenSearchVersion = randomFrom(versions.stream().collect(Collectors.toList())); final WriteableBuild post10OpenSearch = copyWriteable( dockerBuild, writableRegistry(), diff --git a/server/src/test/java/org/opensearch/VersionTests.java b/server/src/test/java/org/opensearch/VersionTests.java index 70bcf343e4c1e..bb5ab4228e264 100644 --- a/server/src/test/java/org/opensearch/VersionTests.java +++ b/server/src/test/java/org/opensearch/VersionTests.java @@ -49,7 +49,7 @@ import java.util.Map; import java.util.Set; -import static org.opensearch.Version.V_1_3_0; +import static org.opensearch.Version.V_2_3_0; import static org.opensearch.Version.MASK; import static org.opensearch.test.VersionUtils.allVersions; import static org.opensearch.test.VersionUtils.randomOpenSearchVersion; @@ -67,31 +67,31 @@ public class VersionTests extends OpenSearchTestCase { public void testVersionComparison() { - Version V_1_1_1 = Version.fromString("1.1.1"); - assertThat(V_1_1_1.before(V_1_3_0), is(true)); - assertThat(V_1_1_1.before(V_1_1_1), is(false)); - assertThat(V_1_3_0.before(V_1_1_1), is(false)); + Version V_2_1_1 = Version.fromString("2.1.1"); + assertThat(V_2_1_1.before(V_2_3_0), is(true)); + assertThat(V_2_1_1.before(V_2_1_1), is(false)); + assertThat(V_2_3_0.before(V_2_1_1), is(false)); - assertThat(V_1_1_1.onOrBefore(V_1_3_0), is(true)); - assertThat(V_1_1_1.onOrBefore(V_1_1_1), is(true)); - assertThat(V_1_3_0.onOrBefore(V_1_1_1), is(false)); + assertThat(V_2_1_1.onOrBefore(V_2_3_0), is(true)); + assertThat(V_2_1_1.onOrBefore(V_2_1_1), is(true)); + assertThat(V_2_3_0.onOrBefore(V_2_1_1), is(false)); - assertThat(V_1_1_1.after(V_1_3_0), is(false)); - assertThat(V_1_1_1.after(V_1_1_1), is(false)); - assertThat(V_1_3_0.after(V_1_1_1), is(true)); + assertThat(V_2_1_1.after(V_2_3_0), is(false)); + assertThat(V_2_1_1.after(V_2_1_1), is(false)); + assertThat(V_2_3_0.after(V_2_1_1), is(true)); - assertThat(V_1_1_1.onOrAfter(V_1_3_0), is(false)); - assertThat(V_1_1_1.onOrAfter(V_1_1_1), is(true)); - assertThat(V_1_3_0.onOrAfter(V_1_1_1), is(true)); + assertThat(V_2_1_1.onOrAfter(V_2_3_0), is(false)); + assertThat(V_2_1_1.onOrAfter(V_2_1_1), is(true)); + assertThat(V_2_3_0.onOrAfter(V_2_1_1), is(true)); assertTrue(Version.fromString("1.0.0-alpha2").onOrAfter(Version.fromString("1.0.0-alpha1"))); assertTrue(Version.fromString("1.0.0").onOrAfter(Version.fromString("1.0.0-beta2"))); assertTrue(Version.fromString("1.0.0-rc1").onOrAfter(Version.fromString("1.0.0-beta24"))); assertTrue(Version.fromString("1.0.0-alpha24").before(Version.fromString("1.0.0-beta0"))); - assertThat(V_1_1_1, is(lessThan(V_1_3_0))); - assertThat(V_1_1_1.compareTo(V_1_1_1), is(0)); - assertThat(V_1_3_0, is(greaterThan(V_1_1_1))); + assertThat(V_2_1_1, is(lessThan(V_2_3_0))); + assertThat(V_2_1_1.compareTo(V_2_1_1), is(0)); + assertThat(V_2_3_0, is(greaterThan(V_2_1_1))); } public void testMin() { @@ -120,7 +120,6 @@ public void testMax() { public void testMinimumIndexCompatibilityVersion() { // note: all Legacy compatibility support will be removed in OpenSearch 3.0 - assertEquals(LegacyESVersion.fromId(6000026), V_1_3_0.minimumIndexCompatibilityVersion()); assertEquals(LegacyESVersion.fromId(7000099), Version.fromId(2000099).minimumIndexCompatibilityVersion()); assertEquals(LegacyESVersion.fromId(7000099), Version.fromId(2010000).minimumIndexCompatibilityVersion()); assertEquals(LegacyESVersion.fromId(7000099), Version.fromId(2000001).minimumIndexCompatibilityVersion()); @@ -181,7 +180,7 @@ public void testVersionNoPresentInSettings() { public void testIndexCreatedVersion() { // an actual index has a IndexMetadata.SETTING_INDEX_UUID - final Version version = Version.V_1_0_0; + final Version version = Version.CURRENT; assertEquals( version, Version.indexCreated( diff --git a/server/src/test/java/org/opensearch/action/main/MainResponseTests.java b/server/src/test/java/org/opensearch/action/main/MainResponseTests.java index b08f08a6d16bf..e2a692d6f7aa6 100644 --- a/server/src/test/java/org/opensearch/action/main/MainResponseTests.java +++ b/server/src/test/java/org/opensearch/action/main/MainResponseTests.java @@ -57,14 +57,14 @@ protected MainResponse createTestInstance() { ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); String nodeName = randomAlphaOfLength(10); final String date = new Date(randomNonNegativeLong()).toString(); - Version version = VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT); + Version version = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT); Build build = new Build( Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), version.toString(), - version.onOrAfter(Version.V_1_0_0) ? randomAlphaOfLength(10) : "" + randomAlphaOfLength(10) ); return new MainResponse(nodeName, version, clusterName, clusterUuid, build); } diff --git a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java index de80ea22071e8..e1953797f5058 100644 --- a/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/MultiSearchRequestTests.java @@ -418,15 +418,10 @@ public void testSerDeWithCancelAfterTimeIntervalParameterAndRandomVersion() thro Version version = VersionUtils.randomVersion(random()); MultiSearchRequest originalRequest = RestMultiSearchAction.parseRequest(restRequest, null, true); MultiSearchRequest deserializedRequest = copyWriteable(originalRequest, writableRegistry(), MultiSearchRequest::new, version); - - if (version.before(Version.V_1_1_0)) { - assertNull(deserializedRequest.requests().get(0).getCancelAfterTimeInterval()); - } else { - assertEquals( - originalRequest.requests().get(0).getCancelAfterTimeInterval(), - deserializedRequest.requests().get(0).getCancelAfterTimeInterval() - ); - } + assertEquals( + originalRequest.requests().get(0).getCancelAfterTimeInterval(), + deserializedRequest.requests().get(0).getCancelAfterTimeInterval() + ); } public void testWritingExpandWildcards() throws IOException { diff --git a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java index 3ffa6d6910548..1779644790c2e 100644 --- a/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java +++ b/server/src/test/java/org/opensearch/action/search/SearchRequestTests.java @@ -110,12 +110,7 @@ public void testRandomVersionSerialization() throws IOException { assertEquals(searchRequest.getLocalClusterAlias(), deserializedRequest.getLocalClusterAlias()); assertEquals(searchRequest.getAbsoluteStartMillis(), deserializedRequest.getAbsoluteStartMillis()); assertEquals(searchRequest.isFinalReduce(), deserializedRequest.isFinalReduce()); - - if (version.onOrAfter(Version.V_1_1_0)) { - assertEquals(searchRequest.getCancelAfterTimeInterval(), deserializedRequest.getCancelAfterTimeInterval()); - } else { - assertNull(deserializedRequest.getCancelAfterTimeInterval()); - } + assertEquals(searchRequest.getCancelAfterTimeInterval(), deserializedRequest.getCancelAfterTimeInterval()); } public void testIllegalArguments() { diff --git a/server/src/test/java/org/opensearch/action/support/IndicesOptionsTests.java b/server/src/test/java/org/opensearch/action/support/IndicesOptionsTests.java index 1f037d2d58e11..a4e201b91cc45 100644 --- a/server/src/test/java/org/opensearch/action/support/IndicesOptionsTests.java +++ b/server/src/test/java/org/opensearch/action/support/IndicesOptionsTests.java @@ -65,7 +65,7 @@ public class IndicesOptionsTests extends OpenSearchTestCase { public void testSerialization() throws Exception { int iterations = randomIntBetween(5, 20); for (int i = 0; i < iterations; i++) { - Version version = randomVersionBetween(random(), Version.V_1_0_0, null); + Version version = randomVersionBetween(random(), Version.V_2_0_0, null); IndicesOptions indicesOptions = IndicesOptions.fromOptions( randomBoolean(), randomBoolean(), diff --git a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java index 9a8ce63098744..4b7eaf0272a91 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java @@ -243,7 +243,7 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { try { List allNodes = new ArrayList<>(); DiscoveryNode oldNode = createNode( - VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.V_1_2_1), + VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.V_2_2_1), DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE ); // local node is the cluster-manager @@ -265,7 +265,7 @@ public void testOnlyAutoExpandAllocationFilteringAfterAllNodesUpgraded() { state = cluster.reroute(state, new ClusterRerouteRequest()); } - DiscoveryNode newNode = createNode(Version.V_1_3_0, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local + DiscoveryNode newNode = createNode(Version.V_2_3_0, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE, DiscoveryNodeRole.DATA_ROLE); // local // node // is // the diff --git a/server/src/test/java/org/opensearch/common/lucene/uid/VersionsTests.java b/server/src/test/java/org/opensearch/common/lucene/uid/VersionsTests.java index 8b22ff56e9abc..d677c1d21d86c 100644 --- a/server/src/test/java/org/opensearch/common/lucene/uid/VersionsTests.java +++ b/server/src/test/java/org/opensearch/common/lucene/uid/VersionsTests.java @@ -216,8 +216,8 @@ public void testCacheFilterReader() throws Exception { public void testLuceneVersionOnUnknownVersions() { // between two known versions, should use the lucene version of the previous version - Version version = Version.fromString("1.1.50"); - assertEquals(VersionUtils.getPreviousVersion(Version.fromString("1.1.3")).luceneVersion, version.luceneVersion); + Version version = Version.fromString("2.1.50"); + assertEquals(VersionUtils.getPreviousVersion(Version.fromString("2.1.3")).luceneVersion, version.luceneVersion); // too old version, major should be the oldest supported lucene version minus 1 version = LegacyESVersion.fromString("5.2.1"); diff --git a/server/src/test/java/org/opensearch/index/IndexSettingsTests.java b/server/src/test/java/org/opensearch/index/IndexSettingsTests.java index de5ef8851ae80..9ea262ab2263d 100644 --- a/server/src/test/java/org/opensearch/index/IndexSettingsTests.java +++ b/server/src/test/java/org/opensearch/index/IndexSettingsTests.java @@ -723,7 +723,7 @@ public void testUpdateSoftDeletesFails() { public void testSoftDeletesDefaultSetting() { // enabled by default on 7.0+ or later { - Version createdVersion = VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT); + Version createdVersion = VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT); Settings settings = Settings.builder().put(IndexMetadata.SETTING_INDEX_VERSION_CREATED.getKey(), createdVersion).build(); assertTrue(IndexSettings.INDEX_SOFT_DELETES_SETTING.get(settings)); } @@ -731,7 +731,7 @@ public void testSoftDeletesDefaultSetting() { public void testIgnoreTranslogRetentionSettingsIfSoftDeletesEnabled() { Settings.Builder settings = Settings.builder() - .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_1_0_0, Version.CURRENT)); + .put(IndexMetadata.SETTING_VERSION_CREATED, VersionUtils.randomVersionBetween(random(), Version.V_2_0_0, Version.CURRENT)); if (randomBoolean()) { settings.put(IndexSettings.INDEX_TRANSLOG_RETENTION_AGE_SETTING.getKey(), randomPositiveTimeValue()); } diff --git a/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java b/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java index 957f3b936a614..f28876b838084 100644 --- a/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java +++ b/server/src/test/java/org/opensearch/index/mapper/ParametrizedMapperTests.java @@ -442,7 +442,7 @@ public void testAnalyzers() { public void testDeprecatedParameters() { // 'index' is declared explicitly, 'store' is not, but is one of the previously always-accepted params String mapping = "{\"type\":\"test_mapper\",\"index\":false,\"store\":true,\"required\":\"value\"}"; - TestMapper mapper = fromMapping(mapping, Version.V_1_0_0); + TestMapper mapper = fromMapping(mapping, Version.V_2_0_0); assertWarnings("Parameter [store] has no effect on type [test_mapper] and will be removed in future"); assertFalse(mapper.index); assertEquals("{\"field\":{\"type\":\"test_mapper\",\"index\":false,\"required\":\"value\"}}", Strings.toString(mapper)); diff --git a/server/src/test/java/org/opensearch/plugins/PluginInfoTests.java b/server/src/test/java/org/opensearch/plugins/PluginInfoTests.java index c81e0d3d4cfea..06295d34e9d97 100644 --- a/server/src/test/java/org/opensearch/plugins/PluginInfoTests.java +++ b/server/src/test/java/org/opensearch/plugins/PluginInfoTests.java @@ -77,34 +77,6 @@ public void testReadFromProperties() throws Exception { assertThat(info.getExtendedPlugins(), empty()); } - public void testReadFromPropertiesWithFolderNameAndVersionBefore() throws Exception { - Path pluginDir = createTempDir().resolve("fake-plugin"); - PluginTestUtil.writePluginProperties( - pluginDir, - "description", - "fake desc", - "name", - "my_plugin", - "version", - "1.0", - "opensearch.version", - Version.V_1_0_0.toString(), - "java.version", - System.getProperty("java.specification.version"), - "classname", - "FakePlugin", - "custom.foldername", - "custom-folder" - ); - PluginInfo info = PluginInfo.readFromProperties(pluginDir); - assertEquals("my_plugin", info.getName()); - assertEquals("fake desc", info.getDescription()); - assertEquals("1.0", info.getVersion()); - assertEquals("FakePlugin", info.getClassname()); - assertEquals("my_plugin", info.getTargetFolderName()); - assertThat(info.getExtendedPlugins(), empty()); - } - public void testReadFromPropertiesWithFolderNameAndVersionAfter() throws Exception { Path pluginDir = createTempDir().resolve("fake-plugin"); PluginTestUtil.writePluginProperties( diff --git a/server/src/test/java/org/opensearch/transport/InboundDecoderTests.java b/server/src/test/java/org/opensearch/transport/InboundDecoderTests.java index 5b7574a11f656..c156a2d1570f8 100644 --- a/server/src/test/java/org/opensearch/transport/InboundDecoderTests.java +++ b/server/src/test/java/org/opensearch/transport/InboundDecoderTests.java @@ -326,7 +326,7 @@ public void testEnsureVersionCompatibility() throws IOException { ise = InboundDecoder.ensureVersionCompatibility(Version.V_2_0_0, version, true); assertNull(ise); - ise = InboundDecoder.ensureVersionCompatibility(Version.V_1_0_0, version, false); + ise = InboundDecoder.ensureVersionCompatibility(VersionUtils.V_1_0_0, version, false); assertEquals( "Received message from unsupported version: [1.0.0] minimal compatible version is: [" + version.minimumCompatibilityVersion() diff --git a/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java b/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java index 9dbfec7bfe106..0a9f1588fc075 100644 --- a/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java +++ b/server/src/test/java/org/opensearch/transport/TransportHandshakerTests.java @@ -189,11 +189,6 @@ public void testHandshakeTimeout() throws IOException { } private Version getMinCompatibilityVersionForHandshakeRequest() { - if (Version.CURRENT.onOrAfter(Version.V_1_0_0) && Version.CURRENT.major == 1) { - return Version.fromId(6079999); - } else if (Version.CURRENT.onOrAfter(Version.V_2_0_0) && Version.CURRENT.major == 2) { - return Version.fromId(7099999); - } return Version.CURRENT.minimumCompatibilityVersion(); } } diff --git a/test/framework/src/main/java/org/opensearch/test/VersionUtils.java b/test/framework/src/main/java/org/opensearch/test/VersionUtils.java index f763d749d70c1..8fb9bc5cd7c1c 100644 --- a/test/framework/src/main/java/org/opensearch/test/VersionUtils.java +++ b/test/framework/src/main/java/org/opensearch/test/VersionUtils.java @@ -49,6 +49,9 @@ /** Utilities for selecting versions in tests */ public class VersionUtils { + // version 1.0 is removed; this is used purely to retain consistent logic for migrations + @Deprecated + public static Version V_1_0_0 = Version.fromId(1000099 ^ Version.MASK); /** * Sort versions that have backwards compatibility guarantees from @@ -104,7 +107,7 @@ static Tuple, List> resolveReleasedVersions(Version curre // remove last minor unless it's the first OpenSearch version. // all Legacy ES versions are released, so we don't exclude any. - if (current.equals(Version.V_1_0_0) == false) { + if (current.equals(V_1_0_0) == false) { List lastMinorLine = stableVersions.get(stableVersions.size() - 1); if (lastMinorLine.get(lastMinorLine.size() - 1) instanceof LegacyESVersion == false) { // if the last minor line is Legacy there are no more staged releases; do nothing diff --git a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java index e82a0c7652004..ec5a617adbde9 100644 --- a/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/rest/OpenSearchRestTestCase.java @@ -537,15 +537,6 @@ protected boolean waitForAllSnapshotsWiped() { private void wipeCluster() throws Exception { - // Clean up SLM policies before trying to wipe snapshots so that no new ones get started by SLM after wiping - if (nodeVersions.first().before(Version.V_1_0_0)) { // SLM was introduced - // in version 7.4 - if (preserveSLMPoliciesUponCompletion() == false) { - // Clean up SLM policies before trying to wipe snapshots so that no new ones get started by SLM after wiping - deleteAllSLMPolicies(); - } - } - SetOnce>>> inProgressSnapshots = new SetOnce<>(); if (waitForAllSnapshotsWiped()) { AtomicReference>>> snapshots = new AtomicReference<>(); @@ -1013,12 +1004,6 @@ private static void updateIndexSettings(String index, Settings settings) throws } protected static void expectSoftDeletesWarning(Request request, String indexName) { - final List esExpectedWarnings = Collections.singletonList( - "Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. " - + "Please do not specify value for setting [index.soft_deletes.enabled] of index [" - + indexName - + "]." - ); final List opensearchExpectedWarnings = Collections.singletonList( "Creating indices with soft-deletes disabled is deprecated and will be removed in future OpenSearch versions. " + "Please do not specify value for setting [index.soft_deletes.enabled] of index [" @@ -1026,23 +1011,8 @@ protected static void expectSoftDeletesWarning(Request request, String indexName + "]." ); final Builder requestOptions = RequestOptions.DEFAULT.toBuilder(); - if (nodeVersions.stream().allMatch(version -> version.before(Version.V_1_0_0))) { - requestOptions.setWarningsHandler(warnings -> warnings.equals(esExpectedWarnings) == false); - request.setOptions(requestOptions); - } else if (nodeVersions.stream().anyMatch(version -> version.before(Version.V_1_0_0))) { - requestOptions.setWarningsHandler(warnings -> warnings.isEmpty() == false && warnings.equals(esExpectedWarnings) == false); - request.setOptions(requestOptions); - } - - if (nodeVersions.stream().allMatch(version -> version.onOrAfter(Version.V_1_0_0))) { - requestOptions.setWarningsHandler(warnings -> warnings.equals(opensearchExpectedWarnings) == false); - request.setOptions(requestOptions); - } else if (nodeVersions.stream().anyMatch(version -> version.onOrAfter(Version.V_1_0_0))) { - requestOptions.setWarningsHandler( - warnings -> warnings.isEmpty() == false && warnings.equals(opensearchExpectedWarnings) == false - ); - request.setOptions(requestOptions); - } + requestOptions.setWarningsHandler(warnings -> warnings.equals(opensearchExpectedWarnings) == false); + request.setOptions(requestOptions); } protected static Map getIndexSettings(String index) throws IOException {