From 16f840b2f7def16327dd138050b09a373d52dc33 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 14:13:42 +0200 Subject: [PATCH 01/21] Remove version qualifier from Java.version --- ...acyDelimitedPayloadTokenFilterFactory.java | 2 +- .../common/NGramTokenFilterFactory.java | 2 +- .../common/NGramTokenizerFactory.java | 2 +- .../mustache/MultiSearchTemplateResponse.java | 4 +-- .../IcuNormalizerTokenFilterFactory.java | 2 +- .../elasticsearch/upgrades/IndexingIT.java | 2 +- .../elasticsearch/ElasticsearchException.java | 2 +- .../main/java/org/elasticsearch/Version.java | 11 +++--- .../indices/alias/IndicesAliasesRequest.java | 4 +-- .../indices/create/CreateIndexRequest.java | 4 +-- .../mapping/put/PutMappingRequest.java | 4 +-- .../action/delete/DeleteRequest.java | 4 +-- .../elasticsearch/action/get/GetRequest.java | 4 +-- .../action/get/MultiGetRequest.java | 4 +-- .../action/index/IndexRequest.java | 4 +-- .../action/main/MainResponse.java | 4 +-- .../action/search/MultiSearchResponse.java | 4 +-- .../termvectors/TermVectorsRequest.java | 4 +-- .../action/update/UpdateRequest.java | 8 ++--- .../cluster/metadata/MappingMetaData.java | 4 +-- .../metadata/MetaDataCreateIndexService.java | 4 +-- .../elasticsearch/common/lucene/Lucene.java | 8 ++--- .../analysis/ShingleTokenFilterFactory.java | 2 +- .../index/mapper/MapperService.java | 4 +-- .../index/similarity/SimilarityProviders.java | 6 ++-- .../index/similarity/SimilarityService.java | 6 ++-- .../index/translog/Translog.java | 4 +-- .../indices/analysis/AnalysisModule.java | 4 +-- .../org/elasticsearch/script/ScriptStats.java | 4 +-- .../CompositeValuesSourceBuilder.java | 4 +-- .../search/dfs/DfsSearchResult.java | 4 +-- .../search/slice/SliceBuilder.java | 2 +- .../elasticsearch/search/suggest/Suggest.java | 8 ++--- .../completion/context/GeoContextMapping.java | 4 +-- .../search/suggest/term/TermSuggestion.java | 4 +-- .../transport/RemoteConnectionInfo.java | 4 +-- .../ExceptionSerializationTests.java | 2 +- .../java/org/elasticsearch/VersionTests.java | 34 +++++++++---------- .../action/support/IndicesOptionsTests.java | 2 +- .../MetaDataCreateIndexServiceTests.java | 6 ++-- .../discovery/zen/MembershipActionTests.java | 4 +-- .../similarity/SimilarityServiceTests.java | 6 ++-- .../indices/analysis/AnalysisModuleTests.java | 2 +- .../RemoteClusterConnectionTests.java | 2 +- .../test/rest/yaml/section/DoSection.java | 2 +- .../AbstractFullClusterRestartTestCase.java | 2 +- .../xpack/core/ml/job/config/Job.java | 16 ++++----- .../xpack/core/ml/job/config/JobUpdate.java | 4 +-- .../autodetect/state/ModelSnapshot.java | 4 +-- .../exporter/MonitoringTemplateUtils.java | 2 +- .../deprecation/IndexDeprecationChecks.java | 4 +-- .../IndexDeprecationChecksTests.java | 2 +- .../exporter/ClusterAlertsUtil.java | 2 +- .../exporter/http/HttpExporter.java | 2 +- .../xpack/security/Security.java | 2 +- .../authc/esnative/ReservedRealmTests.java | 2 +- .../elasticsearch/upgrades/IndexingIT.java | 2 +- .../TokenBackwardsCompatibilityIT.java | 2 +- 58 files changed, 128 insertions(+), 129 deletions(-) diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java index 69acb411d105f..ae20a5fbf5a86 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/LegacyDelimitedPayloadTokenFilterFactory.java @@ -33,7 +33,7 @@ public class LegacyDelimitedPayloadTokenFilterFactory extends DelimitedPayloadTo LegacyDelimitedPayloadTokenFilterFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) { super(indexSettings, env, name, settings); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException( "[delimited_payload_filter] is not supported for new indices, use [delimited_payload] instead"); } diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java index 8d99ec1d1a15d..72649239a30d7 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenFilterFactory.java @@ -43,7 +43,7 @@ public class NGramTokenFilterFactory extends AbstractTokenFilterFactory { this.maxGram = settings.getAsInt("max_gram", 2); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException( "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" diff --git a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java index b00797428b79a..e811d0fbc4bda 100644 --- a/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java +++ b/modules/analysis-common/src/main/java/org/elasticsearch/analysis/common/NGramTokenizerFactory.java @@ -91,7 +91,7 @@ static CharMatcher parseTokenChars(List characterClasses) { this.maxGram = settings.getAsInt("max_gram", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE); int ngramDiff = maxGram - minGram; if (ngramDiff > maxAllowedNgramDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException( "The difference between max_gram and min_gram in NGram Tokenizer must be less than or equal to: [" + maxAllowedNgramDiff + "] but was [" + ngramDiff + "]. This limit can be set by changing the [" diff --git a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponse.java b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponse.java index 74f3bc743aeb2..70e36ed85a496 100644 --- a/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponse.java +++ b/modules/lang-mustache/src/main/java/org/elasticsearch/script/mustache/MultiSearchTemplateResponse.java @@ -154,7 +154,7 @@ public void readFrom(StreamInput in) throws IOException { for (int i = 0; i < items.length; i++) { items[i] = Item.readItem(in); } - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { tookInMillis = in.readVLong(); } } @@ -166,7 +166,7 @@ public void writeTo(StreamOutput out) throws IOException { for (Item item : items) { item.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { out.writeVLong(tookInMillis); } } diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java index d3e59bf9488eb..1826666de32be 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/analysis/IcuNormalizerTokenFilterFactory.java @@ -63,7 +63,7 @@ static Normalizer2 wrapWithUnicodeSetFilter(final IndexSettings indexSettings, final Normalizer2 normalizer, final Settings settings) { String unicodeSetFilter = settings.get("unicodeSetFilter"); - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { if (unicodeSetFilter != null) { deprecationLogger.deprecated("[unicodeSetFilter] has been deprecated in favor of [unicode_set_filter]"); } else { diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java index 0b186db0f7a9f..eab1136ed1ed0 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java @@ -70,7 +70,7 @@ public void testIndexing() throws IOException { Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion(); assertThat("this branch is not needed if we aren't compatible with 6.0", minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true)); - if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0_alpha1)) { + if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) { XContentBuilder template = jsonBuilder(); template.startObject(); { diff --git a/server/src/main/java/org/elasticsearch/ElasticsearchException.java b/server/src/main/java/org/elasticsearch/ElasticsearchException.java index c009bb3818cc8..80c0ceedfd87f 100644 --- a/server/src/main/java/org/elasticsearch/ElasticsearchException.java +++ b/server/src/main/java/org/elasticsearch/ElasticsearchException.java @@ -1007,7 +1007,7 @@ private enum ElasticsearchExceptionHandle { org.elasticsearch.common.xcontent.UnknownNamedObjectException::new, 148, UNKNOWN_VERSION_ADDED), TOO_MANY_BUCKETS_EXCEPTION(MultiBucketConsumerService.TooManyBucketsException.class, MultiBucketConsumerService.TooManyBucketsException::new, 149, - Version.V_7_0_0_alpha1); + Version.V_7_0_0); final Class exceptionClass; final CheckedFunction constructor; diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index 0f636f76d8ae5..6ebb49e11ed7a 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -109,10 +109,9 @@ public class Version implements Comparable, ToXContentFragment { public static final Version V_6_5_0 = new Version(V_6_5_0_ID, org.apache.lucene.util.Version.LUCENE_7_5_0); public static final int V_6_6_0_ID = 6060099; public static final Version V_6_6_0 = new Version(V_6_6_0_ID, org.apache.lucene.util.Version.LUCENE_7_5_0); - public static final int V_7_0_0_alpha1_ID = 7000001; - public static final Version V_7_0_0_alpha1 = - new Version(V_7_0_0_alpha1_ID, org.apache.lucene.util.Version.LUCENE_8_0_0); - public static final Version CURRENT = V_7_0_0_alpha1; + public static final int V_7_0_0_ID = 7000099; + public static final Version V_7_0_0 = new Version(V_7_0_0_ID, org.apache.lucene.util.Version.LUCENE_8_0_0); + public static final Version CURRENT = V_7_0_0; static { assert CURRENT.luceneVersion.equals(org.apache.lucene.util.Version.LATEST) : "Version must be upgraded to [" @@ -125,8 +124,8 @@ public static Version readVersion(StreamInput in) throws IOException { public static Version fromId(int id) { switch (id) { - case V_7_0_0_alpha1_ID: - return V_7_0_0_alpha1; + case V_7_0_0_ID: + return V_7_0_0; case V_6_6_0_ID: return V_6_6_0; case V_6_5_0_ID: diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java index dfe0a25c6110a..1abb551eba302 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/alias/IndicesAliasesRequest.java @@ -239,7 +239,7 @@ public AliasActions(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_6_4_0)) { writeIndex = in.readOptionalBoolean(); } - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { originalAliases = in.readStringArray(); } } @@ -256,7 +256,7 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().onOrAfter(Version.V_6_4_0)) { out.writeOptionalBoolean(writeIndex); } - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { out.writeStringArray(originalAliases); } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java index fa2a395f2c9e4..1bbce19ee8dec 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/create/CreateIndexRequest.java @@ -460,7 +460,7 @@ public void readFrom(StreamInput in) throws IOException { for (int i = 0; i < aliasesSize; i++) { aliases.add(Alias.read(in)); } - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readBoolean(); // updateAllTypes } waitForActiveShards = ActiveShardCount.readFrom(in); @@ -485,7 +485,7 @@ public void writeTo(StreamOutput out) throws IOException { for (Alias alias : aliases) { alias.writeTo(out); } - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(true); // updateAllTypes } waitForActiveShards.writeTo(out); diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java index a827444acb8c5..926ae175d65ad 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/put/PutMappingRequest.java @@ -297,7 +297,7 @@ public void readFrom(StreamInput in) throws IOException { indicesOptions = IndicesOptions.readIndicesOptions(in); type = in.readOptionalString(); source = in.readString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readBoolean(); // updateAllTypes } concreteIndex = in.readOptionalWriteable(Index::new); @@ -310,7 +310,7 @@ public void writeTo(StreamOutput out) throws IOException { indicesOptions.writeIndicesOptions(out); out.writeOptionalString(type); out.writeString(source); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(true); // updateAllTypes } out.writeOptionalWriteable(concreteIndex); diff --git a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java index 165aa7afd9e2e..2d625025932fa 100644 --- a/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java +++ b/server/src/main/java/org/elasticsearch/action/delete/DeleteRequest.java @@ -188,7 +188,7 @@ public void readFrom(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); // _parent } version = in.readLong(); @@ -201,7 +201,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing()); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); // _parent } out.writeLong(version); diff --git a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java index 090935107a778..87c62611e484a 100644 --- a/server/src/main/java/org/elasticsearch/action/get/GetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/GetRequest.java @@ -245,7 +245,7 @@ public void readFrom(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); } preference = in.readOptionalString(); @@ -264,7 +264,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); } out.writeOptionalString(preference); diff --git a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java index df23bad10bce7..920049867968c 100644 --- a/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java +++ b/server/src/main/java/org/elasticsearch/action/get/MultiGetRequest.java @@ -191,7 +191,7 @@ public void readFrom(StreamInput in) throws IOException { type = in.readOptionalString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); // _parent } storedFields = in.readOptionalStringArray(); @@ -207,7 +207,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); // _parent } out.writeOptionalStringArray(storedFields); diff --git a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java index 8f5fd156018a2..710ae331b99f4 100644 --- a/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java +++ b/server/src/main/java/org/elasticsearch/action/index/IndexRequest.java @@ -514,7 +514,7 @@ public void readFrom(StreamInput in) throws IOException { type = in.readOptionalString(); id = in.readOptionalString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); // _parent } if (in.getVersion().before(Version.V_6_0_0_alpha1)) { @@ -541,7 +541,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString(type); out.writeOptionalString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); // _parent } if (out.getVersion().before(Version.V_6_0_0_alpha1)) { diff --git a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java index 6cae1056a4b7b..d5367cd1bc21b 100644 --- a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java +++ b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java @@ -81,7 +81,7 @@ public void writeTo(StreamOutput out) throws IOException { clusterName.writeTo(out); out.writeString(clusterUuid); Build.writeBuild(build, out); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(true); } } @@ -94,7 +94,7 @@ public void readFrom(StreamInput in) throws IOException { clusterName = new ClusterName(in); clusterUuid = in.readString(); build = Build.readBuild(in); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readBoolean(); } } diff --git a/server/src/main/java/org/elasticsearch/action/search/MultiSearchResponse.java b/server/src/main/java/org/elasticsearch/action/search/MultiSearchResponse.java index f2b1b0d5c6265..ac17ec1e579bc 100644 --- a/server/src/main/java/org/elasticsearch/action/search/MultiSearchResponse.java +++ b/server/src/main/java/org/elasticsearch/action/search/MultiSearchResponse.java @@ -170,7 +170,7 @@ public void readFrom(StreamInput in) throws IOException { for (int i = 0; i < items.length; i++) { items[i] = Item.readItem(in); } - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { tookInMillis = in.readVLong(); } } @@ -182,7 +182,7 @@ public void writeTo(StreamOutput out) throws IOException { for (Item item : items) { item.writeTo(out); } - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { out.writeVLong(tookInMillis); } } diff --git a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java index d6bf911e572c3..4cd02caf91c32 100644 --- a/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/termvectors/TermVectorsRequest.java @@ -502,7 +502,7 @@ public void readFrom(StreamInput in) throws IOException { } routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); // _parent } preference = in.readOptionalString(); @@ -545,7 +545,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeEnum(xContentType); } out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); // _parent } out.writeOptionalString(preference); diff --git a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java index 96816efe5322e..5840ab9411e90 100644 --- a/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java +++ b/server/src/main/java/org/elasticsearch/action/update/UpdateRequest.java @@ -748,7 +748,7 @@ public void readFrom(StreamInput in) throws IOException { type = in.readString(); id = in.readString(); routing = in.readOptionalString(); - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readOptionalString(); // _parent } if (in.readBoolean()) { @@ -760,7 +760,7 @@ public void readFrom(StreamInput in) throws IOException { doc = new IndexRequest(); doc.readFrom(in); } - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { String[] fields = in.readOptionalStringArray(); if (fields != null) { throw new IllegalArgumentException("[fields] is no longer supported"); @@ -785,7 +785,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeString(type); out.writeString(id); out.writeOptionalString(routing); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalString(null); // _parent } @@ -806,7 +806,7 @@ public void writeTo(StreamOutput out) throws IOException { doc.id(id); doc.writeTo(out); } - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeOptionalStringArray(null); } out.writeOptionalWriteable(fetchSourceContext); diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java index 2f4461066ec98..1aa53fca1b31c 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MappingMetaData.java @@ -178,7 +178,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalString("now"); // 5.x default out.writeOptionalBoolean(null); } - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(false); // hasParentField } } @@ -220,7 +220,7 @@ public MappingMetaData(StreamInput in) throws IOException { in.readOptionalString(); // defaultTimestamp in.readOptionalBoolean(); // ignoreMissing } - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { in.readBoolean(); // hasParentField } } diff --git a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java index 08e81eb93319b..9f497edf4e59a 100644 --- a/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java +++ b/server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexService.java @@ -575,7 +575,7 @@ static int getNumberOfShards(final Settings.Builder indexSettingsBuilder) { final int numberOfShards; final Version indexVersionCreated = Version.fromId(Integer.parseInt(indexSettingsBuilder.get(IndexMetaData.SETTING_INDEX_VERSION_CREATED.getKey()))); - if (indexVersionCreated.before(Version.V_7_0_0_alpha1)) { + if (indexVersionCreated.before(Version.V_7_0_0)) { numberOfShards = 5; } else { numberOfShards = 1; @@ -799,7 +799,7 @@ static void prepareResizeIndexSettings( * the less default split operations are supported */ public static int calculateNumRoutingShards(int numShards, Version indexVersionCreated) { - if (indexVersionCreated.onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexVersionCreated.onOrAfter(Version.V_7_0_0)) { // only select this automatically for indices that are created on or after 7.0 this will prevent this new behaviour // until we have a fully upgraded cluster. Additionally it will make integratin testing easier since mixed clusters // will always have the behavior of the min node in the cluster. diff --git a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java index b384e45f56d22..9addc342aa0aa 100644 --- a/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java +++ b/server/src/main/java/org/elasticsearch/common/lucene/Lucene.java @@ -283,7 +283,7 @@ public static boolean exists(IndexSearcher searcher, Query query) throws IOExcep private static TotalHits readTotalHits(StreamInput in) throws IOException { long totalHits = in.readVLong(); TotalHits.Relation totalHitsRelation = TotalHits.Relation.EQUAL_TO; - if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) { totalHitsRelation = in.readEnum(TotalHits.Relation.class); } return new TotalHits(totalHits, totalHitsRelation); @@ -402,7 +402,7 @@ public static ScoreDoc readScoreDoc(StreamInput in) throws IOException { private static void writeTotalHits(StreamOutput out, TotalHits totalHits) throws IOException { out.writeVLong(totalHits.value); - if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) { out.writeEnum(totalHits.relation); } else if (totalHits.value > 0 && totalHits.relation != TotalHits.Relation.EQUAL_TO) { throw new IllegalArgumentException("Cannot serialize approximate total hit counts to nodes that are on a version < 7.0.0"); @@ -608,7 +608,7 @@ public static void writeSortField(StreamOutput out, SortField sortField) throws } private static Number readExplanationValue(StreamInput in) throws IOException { - if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) { final int numberType = in.readByte(); switch (numberType) { case 0: @@ -640,7 +640,7 @@ public static Explanation readExplanation(StreamInput in) throws IOException { } private static void writeExplanationValue(StreamOutput out, Number value) throws IOException { - if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(org.elasticsearch.Version.V_7_0_0)) { if (value instanceof Float) { out.writeByte((byte) 0); out.writeFloat(value.floatValue()); diff --git a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java index 422941acc73e5..50e1844609df5 100644 --- a/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java +++ b/server/src/main/java/org/elasticsearch/index/analysis/ShingleTokenFilterFactory.java @@ -40,7 +40,7 @@ public ShingleTokenFilterFactory(IndexSettings indexSettings, Environment enviro int shingleDiff = maxShingleSize - minShingleSize + (outputUnigrams ? 1 : 0); if (shingleDiff > maxAllowedShingleDiff) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException( "In Shingle TokenFilter the difference between max_shingle_size and min_shingle_size (and +1 if outputting unigrams)" + " must be less than or equal to: [" + maxAllowedShingleDiff + "] but was [" + shingleDiff + "]. This limit" diff --git a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java index 828b5b956f5de..076f6e7ebe030 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/MapperService.java @@ -154,7 +154,7 @@ public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, this.mapperRegistry = mapperRegistry; if (INDEX_MAPPER_DYNAMIC_SETTING.exists(indexSettings.getSettings()) && - indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Setting " + INDEX_MAPPER_DYNAMIC_SETTING.getKey() + " was removed after version 6.0.0"); } @@ -411,7 +411,7 @@ private synchronized Map internalMerge(@Nullable Documen Map results = new LinkedHashMap<>(2); if (defaultMapper != null) { - if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("The [default] mapping cannot be updated on index [" + index().getName() + "]: defaults mappings are not useful anymore now that indices can have at most one type."); } else if (reason == MergeReason.MAPPING_UPDATE) { // only log in case of explicit mapping updates diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java index aba860337f3df..0473c6aeaf551 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityProviders.java @@ -139,7 +139,7 @@ private static BasicModel parseBasicModel(Version indexCreatedVersion, Settings if (model == null) { String replacement = LEGACY_BASIC_MODELS.get(basicModel); if (replacement != null) { - if (indexCreatedVersion.onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexCreatedVersion.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Basic model [" + basicModel + "] isn't supported anymore, " + "please use another model."); } else { @@ -170,7 +170,7 @@ private static AfterEffect parseAfterEffect(Version indexCreatedVersion, Setting if (effect == null) { String replacement = LEGACY_AFTER_EFFECTS.get(afterEffect); if (replacement != null) { - if (indexCreatedVersion.onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexCreatedVersion.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("After effect [" + afterEffect + "] isn't supported anymore, please use another effect."); } else { @@ -261,7 +261,7 @@ static void assertSettingsIsSubsetOf(String type, Version version, Settings sett unknownSettings.removeAll(Arrays.asList(supportedSettings)); unknownSettings.remove("type"); // used to figure out which sim this is if (unknownSettings.isEmpty() == false) { - if (version.onOrAfter(Version.V_7_0_0_alpha1)) { + if (version.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Unknown settings for similarity of type [" + type + "]: " + unknownSettings); } else { deprecationLogger.deprecated("Unknown settings for similarity of type [" + type + "]: " + unknownSettings); diff --git a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java index d7308c424be8e..44956eec35d9b 100644 --- a/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java +++ b/server/src/main/java/org/elasticsearch/index/similarity/SimilarityService.java @@ -59,7 +59,7 @@ public final class SimilarityService extends AbstractIndexComponent { static { Map>> defaults = new HashMap<>(); defaults.put(CLASSIC_SIMILARITY, version -> { - if (version.onOrAfter(Version.V_7_0_0_alpha1)) { + if (version.onOrAfter(Version.V_7_0_0)) { return () -> { throw new IllegalArgumentException("The [classic] similarity may not be used anymore. Please use the [BM25] " + "similarity or build a custom [scripted] similarity instead."); @@ -86,7 +86,7 @@ public final class SimilarityService extends AbstractIndexComponent { Map> builtIn = new HashMap<>(); builtIn.put(CLASSIC_SIMILARITY, (settings, version, script) -> { - if (version.onOrAfter(Version.V_7_0_0_alpha1)) { + if (version.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("The [classic] similarity may not be used anymore. Please use the [BM25] " + "similarity or build a custom [scripted] similarity instead."); } else { @@ -267,7 +267,7 @@ private static void validateScoresDoNotIncreaseWithNorm(Version indexCreatedVers } private static void fail(Version indexCreatedVersion, String message) { - if (indexCreatedVersion.onOrAfter(Version.V_7_0_0_alpha1)) { + if (indexCreatedVersion.onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException(message); } else if (indexCreatedVersion.onOrAfter(Version.V_6_5_0)) { deprecationLogger.deprecated(message); diff --git a/server/src/main/java/org/elasticsearch/index/translog/Translog.java b/server/src/main/java/org/elasticsearch/index/translog/Translog.java index 0b91de81932b4..6baeb53136129 100644 --- a/server/src/main/java/org/elasticsearch/index/translog/Translog.java +++ b/server/src/main/java/org/elasticsearch/index/translog/Translog.java @@ -1200,7 +1200,7 @@ public Source getSource() { } private void write(final StreamOutput out) throws IOException { - final int format = out.getVersion().onOrAfter(Version.V_7_0_0_alpha1) ? SERIALIZATION_FORMAT : FORMAT_6_0; + final int format = out.getVersion().onOrAfter(Version.V_7_0_0) ? SERIALIZATION_FORMAT : FORMAT_6_0; out.writeVInt(format); out.writeString(id); out.writeString(type); @@ -1360,7 +1360,7 @@ public Source getSource() { } private void write(final StreamOutput out) throws IOException { - final int format = out.getVersion().onOrAfter(Version.V_7_0_0_alpha1) ? SERIALIZATION_FORMAT : FORMAT_6_0; + final int format = out.getVersion().onOrAfter(Version.V_7_0_0) ? SERIALIZATION_FORMAT : FORMAT_6_0; out.writeVInt(format); out.writeString(type); out.writeString(id); diff --git a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java index 43c61094ca7e4..2bfde42a3e876 100644 --- a/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java +++ b/server/src/main/java/org/elasticsearch/indices/analysis/AnalysisModule.java @@ -124,7 +124,7 @@ private NamedRegistry> setupTokenFilters(Li tokenFilters.register("standard", new AnalysisProvider() { @Override public TokenFilterFactory get(IndexSettings indexSettings, Environment environment, String name, Settings settings) { - if (indexSettings.getIndexVersionCreated().before(Version.V_7_0_0_alpha1)) { + if (indexSettings.getIndexVersionCreated().before(Version.V_7_0_0)) { deprecationLogger.deprecatedAndMaybeLog("standard_deprecation", "The [standard] token filter name is deprecated and will be removed in a future version."); } else { @@ -182,7 +182,7 @@ static Map setupPreConfiguredTokenFilters(List // Add "standard" for old indices (bwc) preConfiguredTokenFilters.register( "standard", PreConfiguredTokenFilter.singletonWithVersion("standard", true, (reader, version) -> { - if (version.before(Version.V_7_0_0_alpha1)) { + if (version.before(Version.V_7_0_0)) { deprecationLogger.deprecatedAndMaybeLog("standard_deprecation", "The [standard] token filter is deprecated and will be removed in a future version."); } else { diff --git a/server/src/main/java/org/elasticsearch/script/ScriptStats.java b/server/src/main/java/org/elasticsearch/script/ScriptStats.java index abf54e7e3d0a2..06eec72c0e0da 100644 --- a/server/src/main/java/org/elasticsearch/script/ScriptStats.java +++ b/server/src/main/java/org/elasticsearch/script/ScriptStats.java @@ -42,14 +42,14 @@ public ScriptStats(long compilations, long cacheEvictions, long compilationLimit public ScriptStats(StreamInput in) throws IOException { compilations = in.readVLong(); cacheEvictions = in.readVLong(); - compilationLimitTriggered = in.getVersion().onOrAfter(Version.V_7_0_0_alpha1) ? in.readVLong() : 0; + compilationLimitTriggered = in.getVersion().onOrAfter(Version.V_7_0_0) ? in.readVLong() : 0; } @Override public void writeTo(StreamOutput out) throws IOException { out.writeVLong(compilations); out.writeVLong(cacheEvictions); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { out.writeVLong(compilationLimitTriggered); } } diff --git a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java index 32a94f59be5c2..01c592a5e01a7 100644 --- a/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/aggregations/bucket/composite/CompositeValuesSourceBuilder.java @@ -72,7 +72,7 @@ public abstract class CompositeValuesSourceBuilder= 0; out.writeVLong(statistics.maxDoc()); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { // stats are always positive numbers out.writeVLong(statistics.docCount()); out.writeVLong(statistics.sumTotalTermFreq()); @@ -176,7 +176,7 @@ public static ObjectObjectHashMap readFieldStats(S final long docCount; final long sumTotalTermFreq; final long sumDocFreq; - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { // stats are always positive numbers docCount = in.readVLong(); sumTotalTermFreq = in.readVLong(); diff --git a/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java b/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java index 9b11de93bee8a..40e10eb589006 100644 --- a/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/slice/SliceBuilder.java @@ -260,7 +260,7 @@ public Query toFilter(ClusterService clusterService, ShardSearchRequest request, if ("_uid".equals(field)) { // on new indices, the _id acts as a _uid field = IdFieldMapper.NAME; - if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_7_0_0_alpha1)) { + if (context.getIndexSettings().getIndexVersionCreated().onOrAfter(Version.V_7_0_0)) { throw new IllegalArgumentException("Computing slices on the [_uid] field is illegal for 7.x indices, use [_id] instead"); } DEPRECATION_LOG.deprecated("Computing slices on the [_uid] field is deprecated for 6.x indices, use [_id] instead"); diff --git a/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java b/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java index c957b16502724..b2f2a336d3684 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/Suggest.java @@ -93,7 +93,7 @@ public Suggest(List>> suggestions) public Suggest(StreamInput in) throws IOException { // in older versions, Suggestion types were serialized as Streamable - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { final int size = in.readVInt(); suggestions = new ArrayList<>(size); for (int i = 0; i < size; i++) { @@ -161,7 +161,7 @@ public boolean hasScoreDocs() { @Override public void writeTo(StreamOutput out) throws IOException { // in older versions, Suggestion types were serialized as Streamable - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeVInt(suggestions.size()); for (Suggestion command : suggestions) { out.writeVInt(command.getWriteableType()); @@ -279,7 +279,7 @@ public Suggestion(StreamInput in) throws IOException { size = in.readVInt(); // this is a hack to work around slightly different serialization order of earlier versions of TermSuggestion - if (in.getVersion().before(Version.V_7_0_0_alpha1) && this instanceof TermSuggestion) { + if (in.getVersion().before(Version.V_7_0_0) && this instanceof TermSuggestion) { TermSuggestion t = (TermSuggestion) this; t.setSort(SortBy.readFromStream(in)); } @@ -389,7 +389,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeVInt(size); // this is a hack to work around slightly different serialization order in older versions of TermSuggestion - if (out.getVersion().before(Version.V_7_0_0_alpha1) && this instanceof TermSuggestion) { + if (out.getVersion().before(Version.V_7_0_0) && this instanceof TermSuggestion) { TermSuggestion termSuggestion = (TermSuggestion) this; termSuggestion.getSort().writeTo(out); } diff --git a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java index ae9cf6fc8c2f9..b908fadd55845 100644 --- a/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java +++ b/server/src/main/java/org/elasticsearch/search/suggest/completion/context/GeoContextMapping.java @@ -292,7 +292,7 @@ protected void validateReferences(Version indexVersionCreated, Function sortComparator() { public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { sort.writeTo(out); } } diff --git a/server/src/main/java/org/elasticsearch/transport/RemoteConnectionInfo.java b/server/src/main/java/org/elasticsearch/transport/RemoteConnectionInfo.java index 60067e18573ad..c2024e39228aa 100644 --- a/server/src/main/java/org/elasticsearch/transport/RemoteConnectionInfo.java +++ b/server/src/main/java/org/elasticsearch/transport/RemoteConnectionInfo.java @@ -58,7 +58,7 @@ public final class RemoteConnectionInfo implements ToXContentFragment, Writeable public RemoteConnectionInfo(StreamInput input) throws IOException { seedNodes = input.readList(TransportAddress::new); - if (input.getVersion().before(Version.V_7_0_0_alpha1)) { + if (input.getVersion().before(Version.V_7_0_0)) { /* * Versions before 7.0 sent the HTTP addresses of all nodes in the * remote cluster here but it was expensive to fetch and we @@ -79,7 +79,7 @@ public RemoteConnectionInfo(StreamInput input) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeList(seedNodes); - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { /* * Versions before 7.0 sent the HTTP addresses of all nodes in the * remote cluster here but it was expensive to fetch and we diff --git a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java index 62778af8d577c..9e286aa61e5d1 100644 --- a/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java +++ b/server/src/test/java/org/elasticsearch/ExceptionSerializationTests.java @@ -358,7 +358,7 @@ public void testCircuitBreakingException() throws IOException { public void testTooManyBucketsException() throws IOException { MultiBucketConsumerService.TooManyBucketsException ex = serialize(new MultiBucketConsumerService.TooManyBucketsException("Too many buckets", 100), - randomFrom(Version.V_7_0_0_alpha1)); + randomFrom(Version.V_7_0_0)); assertEquals("Too many buckets", ex.getMessage()); assertEquals(100, ex.getMaxBuckets()); } diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index e1a7633e1d0dc..6bf81a7b0360d 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -37,7 +37,7 @@ import java.util.Set; import static org.elasticsearch.Version.V_6_3_0; -import static org.elasticsearch.Version.V_7_0_0_alpha1; +import static org.elasticsearch.Version.V_7_0_0; import static org.elasticsearch.test.VersionUtils.allVersions; import static org.elasticsearch.test.VersionUtils.randomVersion; import static org.hamcrest.CoreMatchers.equalTo; @@ -50,30 +50,30 @@ public class VersionTests extends ESTestCase { public void testVersionComparison() throws Exception { - assertThat(V_6_3_0.before(V_7_0_0_alpha1), is(true)); + assertThat(V_6_3_0.before(V_7_0_0), is(true)); assertThat(V_6_3_0.before(V_6_3_0), is(false)); - assertThat(V_7_0_0_alpha1.before(V_6_3_0), is(false)); + assertThat(V_7_0_0.before(V_6_3_0), is(false)); - assertThat(V_6_3_0.onOrBefore(V_7_0_0_alpha1), is(true)); + assertThat(V_6_3_0.onOrBefore(V_7_0_0), is(true)); assertThat(V_6_3_0.onOrBefore(V_6_3_0), is(true)); - assertThat(V_7_0_0_alpha1.onOrBefore(V_6_3_0), is(false)); + assertThat(V_7_0_0.onOrBefore(V_6_3_0), is(false)); - assertThat(V_6_3_0.after(V_7_0_0_alpha1), is(false)); + assertThat(V_6_3_0.after(V_7_0_0), is(false)); assertThat(V_6_3_0.after(V_6_3_0), is(false)); - assertThat(V_7_0_0_alpha1.after(V_6_3_0), is(true)); + assertThat(V_7_0_0.after(V_6_3_0), is(true)); - assertThat(V_6_3_0.onOrAfter(V_7_0_0_alpha1), is(false)); + assertThat(V_6_3_0.onOrAfter(V_7_0_0), is(false)); assertThat(V_6_3_0.onOrAfter(V_6_3_0), is(true)); - assertThat(V_7_0_0_alpha1.onOrAfter(V_6_3_0), is(true)); + assertThat(V_7_0_0.onOrAfter(V_6_3_0), is(true)); assertTrue(Version.fromString("5.0.0-alpha2").onOrAfter(Version.fromString("5.0.0-alpha1"))); assertTrue(Version.fromString("5.0.0").onOrAfter(Version.fromString("5.0.0-beta2"))); assertTrue(Version.fromString("5.0.0-rc1").onOrAfter(Version.fromString("5.0.0-beta24"))); assertTrue(Version.fromString("5.0.0-alpha24").before(Version.fromString("5.0.0-beta0"))); - assertThat(V_6_3_0, is(lessThan(V_7_0_0_alpha1))); + assertThat(V_6_3_0, is(lessThan(V_7_0_0))); assertThat(V_6_3_0.compareTo(V_6_3_0), is(0)); - assertThat(V_7_0_0_alpha1, is(greaterThan(V_6_3_0))); + assertThat(V_7_0_0, is(greaterThan(V_6_3_0))); } public void testMin() { @@ -182,10 +182,10 @@ public void testMinCompatVersion() { // from 7.0 on we are supporting the latest minor of the previous major... this might fail once we add a new version ie. 5.x is // released since we need to bump the supported minor in Version#minimumCompatibilityVersion() Version lastVersion = Version.V_6_6_0; // TODO: remove this once min compat version is a constant instead of method - assertEquals(lastVersion.major, Version.V_7_0_0_alpha1.minimumCompatibilityVersion().major); + assertEquals(lastVersion.major, Version.V_7_0_0.minimumCompatibilityVersion().major); assertEquals("did you miss to bump the minor in Version#minimumCompatibilityVersion()", - lastVersion.minor, Version.V_7_0_0_alpha1.minimumCompatibilityVersion().minor); - assertEquals(0, Version.V_7_0_0_alpha1.minimumCompatibilityVersion().revision); + lastVersion.minor, Version.V_7_0_0.minimumCompatibilityVersion().minor); + assertEquals(0, Version.V_7_0_0.minimumCompatibilityVersion().revision); } public void testToString() { @@ -340,9 +340,9 @@ public static void assertUnknownVersion(Version version) { public void testIsCompatible() { assertTrue(isCompatible(Version.CURRENT, Version.CURRENT.minimumCompatibilityVersion())); - assertFalse(isCompatible(Version.V_6_5_0, Version.V_7_0_0_alpha1)); - assertTrue(isCompatible(Version.V_6_6_0, Version.V_7_0_0_alpha1)); - assertFalse(isCompatible(Version.fromId(2000099), Version.V_7_0_0_alpha1)); + assertFalse(isCompatible(Version.V_6_5_0, Version.V_7_0_0)); + assertTrue(isCompatible(Version.V_6_6_0, Version.V_7_0_0)); + assertFalse(isCompatible(Version.fromId(2000099), Version.V_7_0_0)); assertFalse(isCompatible(Version.fromId(2000099), Version.V_6_5_0)); assertFalse(isCompatible(Version.fromString("7.0.0"), Version.fromString("8.0.0"))); assertFalse(isCompatible(Version.fromString("7.0.0-alpha1"), Version.fromString("8.0.0"))); diff --git a/server/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java b/server/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java index f564066b4e3df..e27d98a43c4cb 100644 --- a/server/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java +++ b/server/src/test/java/org/elasticsearch/action/support/IndicesOptionsTests.java @@ -51,7 +51,7 @@ public class IndicesOptionsTests extends ESTestCase { public void testSerialization() throws Exception { int iterations = randomIntBetween(5, 20); for (int i = 0; i < iterations; i++) { - Version version = randomVersionBetween(random(), Version.V_7_0_0_alpha1, null); + Version version = randomVersionBetween(random(), Version.V_7_0_0, null); IndicesOptions indicesOptions = IndicesOptions.fromOptions( randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean()); diff --git a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java index aa0f6834b98ec..c8877c138a3c2 100644 --- a/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataCreateIndexServiceTests.java @@ -103,12 +103,12 @@ public void testNumberOfShards() { { final Version versionCreated = VersionUtils.randomVersionBetween( random(), - Version.V_6_0_0_alpha1, VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1)); + Version.V_6_0_0_alpha1, VersionUtils.getPreviousVersion(Version.V_7_0_0)); final Settings.Builder indexSettingsBuilder = Settings.builder().put(SETTING_VERSION_CREATED, versionCreated); assertThat(MetaDataCreateIndexService.IndexCreationTask.getNumberOfShards(indexSettingsBuilder), equalTo(5)); } { - final Version versionCreated = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0_alpha1, Version.CURRENT); + final Version versionCreated = VersionUtils.randomVersionBetween(random(), Version.V_7_0_0, Version.CURRENT); final Settings.Builder indexSettingsBuilder = Settings.builder().put(SETTING_VERSION_CREATED, versionCreated); assertThat(MetaDataCreateIndexService.IndexCreationTask.getNumberOfShards(indexSettingsBuilder), equalTo(1)); } @@ -445,7 +445,7 @@ public void testCalculateNumRoutingShards() { assertEquals(2048, MetaDataCreateIndexService.calculateNumRoutingShards(1024, Version.CURRENT)); assertEquals(4096, MetaDataCreateIndexService.calculateNumRoutingShards(2048, Version.CURRENT)); - Version latestV6 = VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1); + Version latestV6 = VersionUtils.getPreviousVersion(Version.V_7_0_0); int numShards = randomIntBetween(1, 1000); assertEquals(numShards, MetaDataCreateIndexService.calculateNumRoutingShards(numShards, latestV6)); assertEquals(numShards, MetaDataCreateIndexService.calculateNumRoutingShards(numShards, diff --git a/server/src/test/java/org/elasticsearch/discovery/zen/MembershipActionTests.java b/server/src/test/java/org/elasticsearch/discovery/zen/MembershipActionTests.java index 8ebb543da6e4f..11307dd4663c3 100644 --- a/server/src/test/java/org/elasticsearch/discovery/zen/MembershipActionTests.java +++ b/server/src/test/java/org/elasticsearch/discovery/zen/MembershipActionTests.java @@ -77,7 +77,7 @@ public void testPreventJoinClusterWithUnsupportedNodeVersions() { final Version maxNodeVersion = nodes.getMaxNodeVersion(); final Version minNodeVersion = nodes.getMinNodeVersion(); - if (maxNodeVersion.onOrAfter(Version.V_7_0_0_alpha1)) { + if (maxNodeVersion.onOrAfter(Version.V_7_0_0)) { final Version tooLow = getPreviousVersion(maxNodeVersion.minimumCompatibilityVersion()); expectThrows(IllegalStateException.class, () -> { if (randomBoolean()) { @@ -99,7 +99,7 @@ public void testPreventJoinClusterWithUnsupportedNodeVersions() { }); } - if (minNodeVersion.onOrAfter(Version.V_7_0_0_alpha1)) { + if (minNodeVersion.onOrAfter(Version.V_7_0_0)) { Version oldMajor = Version.V_6_4_0.minimumCompatibilityVersion(); expectThrows(IllegalStateException.class, () -> MembershipAction.ensureMajorVersionBarrier(oldMajor, minNodeVersion)); } diff --git a/server/src/test/java/org/elasticsearch/index/similarity/SimilarityServiceTests.java b/server/src/test/java/org/elasticsearch/index/similarity/SimilarityServiceTests.java index 48d1e2b9c9b6c..0eefd737364a5 100644 --- a/server/src/test/java/org/elasticsearch/index/similarity/SimilarityServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/similarity/SimilarityServiceTests.java @@ -84,7 +84,7 @@ public float score(float freq, long norm) { } }; IllegalArgumentException e = expectThrows(IllegalArgumentException.class, - () -> SimilarityService.validateSimilarity(Version.V_7_0_0_alpha1, negativeScoresSim)); + () -> SimilarityService.validateSimilarity(Version.V_7_0_0, negativeScoresSim)); assertThat(e.getMessage(), Matchers.containsString("Similarities should not return negative scores")); Similarity decreasingScoresWithFreqSim = new Similarity() { @@ -107,7 +107,7 @@ public float score(float freq, long norm) { } }; e = expectThrows(IllegalArgumentException.class, - () -> SimilarityService.validateSimilarity(Version.V_7_0_0_alpha1, decreasingScoresWithFreqSim)); + () -> SimilarityService.validateSimilarity(Version.V_7_0_0, decreasingScoresWithFreqSim)); assertThat(e.getMessage(), Matchers.containsString("Similarity scores should not decrease when term frequency increases")); Similarity increasingScoresWithNormSim = new Similarity() { @@ -130,7 +130,7 @@ public float score(float freq, long norm) { } }; e = expectThrows(IllegalArgumentException.class, - () -> SimilarityService.validateSimilarity(Version.V_7_0_0_alpha1, increasingScoresWithNormSim)); + () -> SimilarityService.validateSimilarity(Version.V_7_0_0, increasingScoresWithNormSim)); assertThat(e.getMessage(), Matchers.containsString("Similarity scores should not increase when norm increases")); } diff --git a/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java b/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java index 119a74262bf7a..f3a8847a9b594 100644 --- a/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java +++ b/server/src/test/java/org/elasticsearch/indices/analysis/AnalysisModuleTests.java @@ -260,7 +260,7 @@ public void testStandardFilterBWC() throws IOException { .put("index.analysis.analyzer.my_standard.tokenizer", "standard") .put("index.analysis.analyzer.my_standard.filter", "standard") .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString()) - .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0_alpha1) + .put(IndexMetaData.SETTING_VERSION_CREATED, Version.V_7_0_0) .build(); IndexAnalyzers analyzers = getIndexAnalyzers(settings); IllegalArgumentException exc = expectThrows(IllegalArgumentException.class, () -> diff --git a/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java b/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java index e6f7b449b43f3..d46a8f28d38d3 100644 --- a/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java +++ b/server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java @@ -1019,7 +1019,7 @@ private static RemoteConnectionInfo assertSerialization(RemoteConnectionInfo inf public void testRemoteConnectionInfoBwComp() throws IOException { final Version version = VersionUtils.randomVersionBetween(random(), - Version.V_6_1_0, VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1)); + Version.V_6_1_0, VersionUtils.getPreviousVersion(Version.V_7_0_0)); RemoteConnectionInfo expected = new RemoteConnectionInfo("test_cluster", Collections.singletonList(new TransportAddress(TransportAddress.META_ADDRESS, 1)), 4, 4, new TimeValue(30, TimeUnit.MINUTES), false); diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index dcda4a2a025e8..c0cabc13a8abd 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -293,7 +293,7 @@ void checkWarningHeaders(final List warningHeaders, final Version master if (matches) { final String message = matcher.group(1); // noinspection StatementWithEmptyBody - if (masterVersion.before(Version.V_7_0_0_alpha1) + if (masterVersion.before(Version.V_7_0_0) && message.equals("the default number of shards will change from [5] to [1] in 7.0.0; " + "if you wish to continue using the default of [5] shards, " + "you must manage this on the create index request or with an index template")) { diff --git a/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java b/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java index b61182415eeb4..aff75e242145f 100644 --- a/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/upgrades/AbstractFullClusterRestartTestCase.java @@ -40,7 +40,7 @@ public abstract class AbstractFullClusterRestartTestCase extends ESRestTestCase public void init() throws IOException { assertThat("we don't need this branch if we aren't compatible with 6.0", Version.CURRENT.minimumIndexCompatibilityVersion().onOrBefore(Version.V_6_0_0), equalTo(true)); - if (isRunningAgainstOldCluster() && getOldClusterVersion().before(Version.V_7_0_0_alpha1)) { + if (isRunningAgainstOldCluster() && getOldClusterVersion().before(Version.V_7_0_0)) { XContentBuilder template = jsonBuilder(); template.startObject(); { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java index 5a352ab26657c..673e6f45105d7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/Job.java @@ -197,7 +197,7 @@ public Job(StreamInput in) throws IOException { createTime = new Date(in.readVLong()); finishedTime = in.readBoolean() ? new Date(in.readVLong()) : null; // for removed last_data_time field - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { if (in.readBoolean()) { in.readVLong(); } @@ -218,7 +218,7 @@ public Job(StreamInput in) throws IOException { Map readCustomSettings = in.readMap(); customSettings = readCustomSettings == null ? null : Collections.unmodifiableMap(readCustomSettings); modelSnapshotId = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1) && in.readBoolean()) { + if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) { modelSnapshotMinVersion = Version.readVersion(in); } else { modelSnapshotMinVersion = null; @@ -464,7 +464,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(false); } // for removed last_data_time field - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(false); } if (out.getVersion().onOrAfter(Version.V_6_1_0)) { @@ -480,7 +480,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalLong(resultsRetentionDays); out.writeMap(customSettings); out.writeOptionalString(modelSnapshotId); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { if (modelSnapshotMinVersion != null) { out.writeBoolean(true); Version.writeVersion(modelSnapshotMinVersion, out); @@ -693,7 +693,7 @@ public Builder(StreamInput in) throws IOException { createTime = in.readBoolean() ? new Date(in.readVLong()) : null; finishedTime = in.readBoolean() ? new Date(in.readVLong()) : null; // for removed last_data_time field - if (in.getVersion().before(Version.V_7_0_0_alpha1)) { + if (in.getVersion().before(Version.V_7_0_0)) { if (in.readBoolean()) { in.readVLong(); } @@ -711,7 +711,7 @@ public Builder(StreamInput in) throws IOException { resultsRetentionDays = in.readOptionalLong(); customSettings = in.readMap(); modelSnapshotId = in.readOptionalString(); - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1) && in.readBoolean()) { + if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) { modelSnapshotMinVersion = Version.readVersion(in); } else { modelSnapshotMinVersion = null; @@ -886,7 +886,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(false); } // for removed last_data_time field - if (out.getVersion().before(Version.V_7_0_0_alpha1)) { + if (out.getVersion().before(Version.V_7_0_0)) { out.writeBoolean(false); } if (out.getVersion().onOrAfter(Version.V_6_1_0)) { @@ -902,7 +902,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalLong(resultsRetentionDays); out.writeMap(customSettings); out.writeOptionalString(modelSnapshotId); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { if (modelSnapshotMinVersion != null) { out.writeBoolean(true); Version.writeVersion(modelSnapshotMinVersion, out); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java index cdfd9bad7f1de..067a73e47787d 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/config/JobUpdate.java @@ -141,7 +141,7 @@ public JobUpdate(StreamInput in) throws IOException { } else { jobVersion = null; } - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1) && in.readBoolean()) { + if (in.getVersion().onOrAfter(Version.V_7_0_0) && in.readBoolean()) { modelSnapshotMinVersion = Version.readVersion(in); } else { modelSnapshotMinVersion = null; @@ -183,7 +183,7 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(false); } } - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { if (modelSnapshotMinVersion != null) { out.writeBoolean(true); Version.writeVersion(modelSnapshotMinVersion, out); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java index ad5b9d780e695..e1933ef1a59ef 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/job/process/autodetect/state/ModelSnapshot.java @@ -118,7 +118,7 @@ private ModelSnapshot(String jobId, Version minVersion, Date timestamp, String d public ModelSnapshot(StreamInput in) throws IOException { jobId = in.readString(); - if (in.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { minVersion = Version.readVersion(in); } else { minVersion = Version.CURRENT.minimumCompatibilityVersion(); @@ -137,7 +137,7 @@ public ModelSnapshot(StreamInput in) throws IOException { @Override public void writeTo(StreamOutput out) throws IOException { out.writeString(jobId); - if (out.getVersion().onOrAfter(Version.V_7_0_0_alpha1)) { + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { Version.writeVersion(minVersion, out); } if (timestamp != null) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter/MonitoringTemplateUtils.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter/MonitoringTemplateUtils.java index 96bc59af1ca63..ad67ba723ca51 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter/MonitoringTemplateUtils.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/monitoring/exporter/MonitoringTemplateUtils.java @@ -28,7 +28,7 @@ public final class MonitoringTemplateUtils { *

* It may be possible for this to diverge between templates and pipelines, but for now they're the same. */ - public static final int LAST_UPDATED_VERSION = Version.V_7_0_0_alpha1.id; + public static final int LAST_UPDATED_VERSION = Version.V_7_0_0.id; /** * Current version of templates used in their name to differentiate from breaking changes (separate from product version). diff --git a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java index 177574d89b65c..273fe1dec9d20 100644 --- a/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java +++ b/x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java @@ -145,7 +145,7 @@ static DeprecationIssue baseSimilarityDefinedCheck(IndexMetaData indexMetaData) } static DeprecationIssue delimitedPayloadFilterCheck(IndexMetaData indexMetaData) { - if (indexMetaData.getCreationVersion().before(Version.V_7_0_0_alpha1)) { + if (indexMetaData.getCreationVersion().before(Version.V_7_0_0)) { List issues = new ArrayList<>(); Map filters = indexMetaData.getSettings().getGroups(AnalysisRegistry.INDEX_ANALYSIS_FILTER); for (Map.Entry entry : filters.entrySet()) { @@ -211,4 +211,4 @@ static DeprecationIssue indexSharedFileSystemCheck(IndexMetaData indexMetaData) } return null; } -} \ No newline at end of file +} diff --git a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java index d496eea2f0d13..7203a853846d1 100644 --- a/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java +++ b/x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java @@ -22,7 +22,7 @@ public class IndexDeprecationChecksTests extends ESTestCase { public void testDelimitedPayloadFilterCheck() throws IOException { Settings settings = settings( - VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0_alpha1))) + VersionUtils.randomVersionBetween(random(), Version.V_6_0_0, VersionUtils.getPreviousVersion(Version.V_7_0_0))) .put("index.analysis.filter.my_delimited_payload_filter.type", "delimited_payload_filter") .put("index.analysis.filter.my_delimited_payload_filter.delimiter", "^") .put("index.analysis.filter.my_delimited_payload_filter.encoding", "identity").build(); diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java index 259c3af8839b2..782ecba1c30f9 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/ClusterAlertsUtil.java @@ -56,7 +56,7 @@ public class ClusterAlertsUtil { * The last time that all watches were updated. For now, all watches have been updated in the same version and should all be replaced * together. */ - public static final int LAST_UPDATED_VERSION = Version.V_7_0_0_alpha1.id; + public static final int LAST_UPDATED_VERSION = Version.V_7_0_0.id; /** * An unsorted list of Watch IDs representing resource files for Monitoring Cluster Alerts. diff --git a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java index c7a19635bbbb5..9f13f58065fad 100644 --- a/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java +++ b/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/HttpExporter.java @@ -164,7 +164,7 @@ public class HttpExporter extends Exporter { /** * Minimum supported version of the remote monitoring cluster (same major). */ - public static final Version MIN_SUPPORTED_CLUSTER_VERSION = Version.V_7_0_0_alpha1; + public static final Version MIN_SUPPORTED_CLUSTER_VERSION = Version.V_7_0_0; /** * The {@link RestClient} automatically pools connections and keeps them alive as necessary. diff --git a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java index b0c1acba7e215..076997d297ac2 100644 --- a/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java +++ b/x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java @@ -1032,7 +1032,7 @@ public void accept(DiscoveryNode node, ClusterState state) { static final class ValidateUpgradedSecurityIndex implements BiConsumer { @Override public void accept(DiscoveryNode node, ClusterState state) { - if (state.getNodes().getMinNodeVersion().before(Version.V_7_0_0_alpha1)) { + if (state.getNodes().getMinNodeVersion().before(Version.V_7_0_0)) { IndexMetaData indexMetaData = state.getMetaData().getIndices().get(SECURITY_INDEX_NAME); if (indexMetaData != null && INDEX_FORMAT_SETTING.get(indexMetaData.getSettings()) < INTERNAL_INDEX_FORMAT) { throw new IllegalStateException("Security index is not on the current version [" + INTERNAL_INDEX_FORMAT + "] - " + diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java index 53963f996daf6..070ea855800f7 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/esnative/ReservedRealmTests.java @@ -470,6 +470,6 @@ private void verifyVersionPredicate(String principal, Predicate version assertThat(versionPredicate.test(Version.V_6_3_0), is(true)); break; } - assertThat(versionPredicate.test(Version.V_7_0_0_alpha1), is(true)); + assertThat(versionPredicate.test(Version.V_7_0_0), is(true)); } } diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java index 20e7bf07e0f65..5bd4128701f03 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/IndexingIT.java @@ -55,7 +55,7 @@ public void testIndexing() throws IOException { Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion(); assertThat("this branch is not needed if we aren't compatible with 6.0", minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true)); - if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0_alpha1)) { + if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) { XContentBuilder template = jsonBuilder(); template.startObject(); { diff --git a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java index 6afecfc2f28da..7562589594461 100644 --- a/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java +++ b/x-pack/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/TokenBackwardsCompatibilityIT.java @@ -33,7 +33,7 @@ public void testGeneratingTokenInOldCluster() throws Exception { Version minimumIndexCompatibilityVersion = Version.CURRENT.minimumIndexCompatibilityVersion(); assertThat("this branch is not needed if we aren't compatible with 6.0", minimumIndexCompatibilityVersion.onOrBefore(Version.V_6_0_0), equalTo(true)); - if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0_alpha1)) { + if (minimumIndexCompatibilityVersion.before(Version.V_7_0_0)) { XContentBuilder template = jsonBuilder(); template.startObject(); { From 93b7079db0261ee310d6d01ff5e9b8acaa8bfbd2 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 17:22:38 +0200 Subject: [PATCH 02/21] Set plugin version numeric only --- .../elasticsearch/gradle/doc/DocsTestPlugin.groovy | 11 ++++++----- .../gradle/plugin/PluginPropertiesTask.groovy | 11 +++-------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index 881fce443a792..59df39299bfcb 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -18,6 +18,7 @@ */ package org.elasticsearch.gradle.doc +import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionProperties import org.elasticsearch.gradle.test.RestTestPlugin import org.gradle.api.Project @@ -37,12 +38,12 @@ public class DocsTestPlugin extends RestTestPlugin { // Docs are published separately so no need to assemble project.tasks.assemble.enabled = false Map defaultSubstitutions = [ - /* These match up with the asciidoc syntax for substitutions but - * the values may differ. In particular {version} needs to resolve - * to the version being built for testing but needs to resolve to - * the last released version for docs. */ + /* These match up with the asciidoc syntax for substitutions but + * the values may differ. In particular {version} needs to resolve + * to the version being built for testing but needs to resolve to + * the last released version for docs. */ '\\{version\\}': - VersionProperties.elasticsearch.replace('-SNAPSHOT', ''), + Version.fromString(VersionProperties.elasticsearch).toString(), '\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''), '\\{build_flavor\\}' : project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default', diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy index 633647514ed7d..5bc98cc6ff052 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy @@ -18,6 +18,7 @@ */ package org.elasticsearch.gradle.plugin +import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.VersionProperties import org.gradle.api.InvalidUserDataException import org.gradle.api.Task @@ -66,17 +67,11 @@ class PluginPropertiesTask extends Copy { } Map generateSubstitutions() { - def stringSnap = { version -> - if (version.endsWith("-SNAPSHOT")) { - return version.substring(0, version.length() - 9) - } - return version - } return [ 'name': extension.name, 'description': extension.description, - 'version': stringSnap(extension.version), - 'elasticsearchVersion': stringSnap(VersionProperties.elasticsearch), + 'version': extension.version, + 'elasticsearchVersion': String.valueOf(Version.fromString(VersionProperties.elasticsearch)), 'javaVersion': project.targetCompatibility as String, 'classname': extension.classname, 'extendedPlugins': extension.extendedPlugins.join(','), From 6b7be57faaf674538a16441cdb2a177884422554 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 17:34:07 +0200 Subject: [PATCH 03/21] Fix docs tests --- .../gradle/doc/DocsTestPlugin.groovy | 4 +-- docs/reference/cat/plugins.asciidoc | 36 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index 59df39299bfcb..d450e665f75e1 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -42,8 +42,8 @@ public class DocsTestPlugin extends RestTestPlugin { * the values may differ. In particular {version} needs to resolve * to the version being built for testing but needs to resolve to * the last released version for docs. */ - '\\{version\\}': - Version.fromString(VersionProperties.elasticsearch).toString(), + '\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(), + '\\{plugin_version\\}': VersionProperties.elasticsearch, '\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''), '\\{build_flavor\\}' : project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default', diff --git a/docs/reference/cat/plugins.asciidoc b/docs/reference/cat/plugins.asciidoc index 265a9e270f581..12c11466a3802 100644 --- a/docs/reference/cat/plugins.asciidoc +++ b/docs/reference/cat/plugins.asciidoc @@ -14,24 +14,24 @@ Might look like: ["source","txt",subs="attributes,callouts"] ------------------------------------------------------------------------------ name component version description -U7321H6 analysis-icu {version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. -U7321H6 analysis-kuromoji {version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. -U7321H6 analysis-nori {version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. -U7321H6 analysis-phonetic {version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. -U7321H6 analysis-smartcn {version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. -U7321H6 analysis-stempel {version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. -U7321H6 analysis-ukrainian {version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. -U7321H6 discovery-azure-classic {version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism -U7321H6 discovery-ec2 {version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. -U7321H6 discovery-gce {version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. -U7321H6 ingest-attachment {version} Ingest processor that uses Apache Tika to extract contents -U7321H6 ingest-geoip {version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database -U7321H6 ingest-user-agent {version} Ingest processor that extracts information from a user agent -U7321H6 mapper-annotated-text {version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. -U7321H6 mapper-murmur3 {version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. -U7321H6 mapper-size {version} The Mapper Size plugin allows document to record their uncompressed size at index time. -U7321H6 store-smb {version} The Store SMB plugin adds support for SMB stores. -U7321H6 transport-nio {version} The nio transport. +U7321H6 analysis-icu {plugin_version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. +U7321H6 analysis-kuromoji {plugin_version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. +U7321H6 analysis-nori {plugin_version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. +U7321H6 analysis-phonetic {plugin_version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. +U7321H6 analysis-smartcn {plugin_version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. +U7321H6 analysis-stempel {plugin_version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. +U7321H6 analysis-ukrainian {plugin_version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. +U7321H6 discovery-azure-classic {plugin_version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism +U7321H6 discovery-ec2 {plugin_version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. +U7321H6 discovery-gce {plugin_version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. +U7321H6 ingest-attachment {plugin_version} Ingest processor that uses Apache Tika to extract contents +U7321H6 ingest-geoip {plugin_version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database +U7321H6 ingest-user-agent {plugin_version} Ingest processor that extracts information from a user agent +U7321H6 mapper-annotated-text {plugin_version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. +U7321H6 mapper-murmur3 {plugin_version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. +U7321H6 mapper-size {plugin_version} The Mapper Size plugin allows document to record their uncompressed size at index time. +U7321H6 store-smb {plugin_version} The Store SMB plugin adds support for SMB stores. +U7321H6 transport-nio {plugin_version} The nio transport. ------------------------------------------------------------------------------ // TESTRESPONSE[s/([.()])/\\$1/ s/U7321H6/.+/ _cat] From 541f0cd9f52baa17ea0a6bdca5e86f4db4aafab4 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 19:04:16 +0200 Subject: [PATCH 04/21] Fix rebase --- .../src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index a97989c1167c2..824da05e12ccd 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -699,7 +699,7 @@ class BuildPlugin implements Plugin { // this doFirst is added before the info plugin, therefore it will run // after the doFirst added by the info plugin, and we can override attributes jarTask.manifest.attributes( - 'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch.replace("-SNAPSHOT", ""), + 'X-Compile-Elasticsearch-Version': String.valueOf(Version.fromString(VersionProperties.elasticsearch)), 'X-Compile-Lucene-Version': VersionProperties.lucene, 'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(), 'Build-Date': ZonedDateTime.now(ZoneOffset.UTC), From 5e949a0a49763139f8cd004ab8715b6cceb735c5 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 20:02:59 +0200 Subject: [PATCH 05/21] Fix server tets --- server/src/test/java/org/elasticsearch/VersionTests.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index 6bf81a7b0360d..b44138e00160f 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -344,8 +344,6 @@ public void testIsCompatible() { assertTrue(isCompatible(Version.V_6_6_0, Version.V_7_0_0)); assertFalse(isCompatible(Version.fromId(2000099), Version.V_7_0_0)); assertFalse(isCompatible(Version.fromId(2000099), Version.V_6_5_0)); - assertFalse(isCompatible(Version.fromString("7.0.0"), Version.fromString("8.0.0"))); - assertFalse(isCompatible(Version.fromString("7.0.0-alpha1"), Version.fromString("8.0.0"))); final Version currentMajorVersion = Version.fromId(Version.CURRENT.major * 1000000 + 99); final Version currentOrNextMajorVersion; From ad68da1f763efffdcf3be93012a3c814f72b0dea Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Thu, 1 Nov 2018 21:51:51 +0200 Subject: [PATCH 06/21] fix packaging tests --- qa/vagrant/src/test/resources/packaging/utils/utils.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qa/vagrant/src/test/resources/packaging/utils/utils.bash b/qa/vagrant/src/test/resources/packaging/utils/utils.bash index f5a9f25df16f3..e54e913aea171 100644 --- a/qa/vagrant/src/test/resources/packaging/utils/utils.bash +++ b/qa/vagrant/src/test/resources/packaging/utils/utils.bash @@ -516,7 +516,7 @@ wait_for_elasticsearch_status() { # $1 - expected version check_elasticsearch_version() { local version=$1 - local versionToCheck=$(echo $version | sed -e 's/-SNAPSHOT//') + local versionToCheck=$(echo $version | sed -e 's/-SNAPSHOT//' | sed -e 's/-\(alpha\|beta\|rc\)[0-9]//') run curl -s localhost:9200 [ "$status" -eq 0 ] From fa5d007184c2425e24fdaeb5b0b601613c30727f Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 06:01:16 +0200 Subject: [PATCH 07/21] Fix tets that rely on ID --- x-pack/plugin/core/src/main/resources/monitoring-alerts.json | 2 +- x-pack/plugin/core/src/main/resources/monitoring-beats.json | 2 +- x-pack/plugin/core/src/main/resources/monitoring-es.json | 2 +- x-pack/plugin/core/src/main/resources/monitoring-kibana.json | 2 +- x-pack/plugin/core/src/main/resources/monitoring-logstash.json | 2 +- .../monitoring/watches/elasticsearch_cluster_status.json | 2 +- .../main/resources/monitoring/watches/elasticsearch_nodes.json | 2 +- .../monitoring/watches/elasticsearch_version_mismatch.json | 2 +- .../resources/monitoring/watches/kibana_version_mismatch.json | 2 +- .../resources/monitoring/watches/logstash_version_mismatch.json | 2 +- .../resources/monitoring/watches/xpack_license_expiration.json | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/x-pack/plugin/core/src/main/resources/monitoring-alerts.json b/x-pack/plugin/core/src/main/resources/monitoring-alerts.json index 01186bca77db5..5ab085b453075 100644 --- a/x-pack/plugin/core/src/main/resources/monitoring-alerts.json +++ b/x-pack/plugin/core/src/main/resources/monitoring-alerts.json @@ -1,6 +1,6 @@ { "index_patterns": [ ".monitoring-alerts-${monitoring.template.version}" ], - "version": 7000001, + "version": 7000099, "settings": { "index": { "number_of_shards": 1, diff --git a/x-pack/plugin/core/src/main/resources/monitoring-beats.json b/x-pack/plugin/core/src/main/resources/monitoring-beats.json index 0d8158a2d250f..a5a3bbf79490f 100644 --- a/x-pack/plugin/core/src/main/resources/monitoring-beats.json +++ b/x-pack/plugin/core/src/main/resources/monitoring-beats.json @@ -9,7 +9,7 @@ "index.number_of_replicas": 0, "index.number_of_shards": 1 }, - "version": 7000001, + "version": 7000099, "mappings": { "doc": { "dynamic": false, diff --git a/x-pack/plugin/core/src/main/resources/monitoring-es.json b/x-pack/plugin/core/src/main/resources/monitoring-es.json index bdd16d3b58cc6..259cba34f5dc6 100644 --- a/x-pack/plugin/core/src/main/resources/monitoring-es.json +++ b/x-pack/plugin/core/src/main/resources/monitoring-es.json @@ -1,6 +1,6 @@ { "index_patterns": [ ".monitoring-es-${monitoring.template.version}-*" ], - "version": 7000001, + "version": 7000099, "settings": { "index.number_of_shards": 1, "index.number_of_replicas": 0, diff --git a/x-pack/plugin/core/src/main/resources/monitoring-kibana.json b/x-pack/plugin/core/src/main/resources/monitoring-kibana.json index 51e9f7cdd1906..c220e95e182e3 100644 --- a/x-pack/plugin/core/src/main/resources/monitoring-kibana.json +++ b/x-pack/plugin/core/src/main/resources/monitoring-kibana.json @@ -1,6 +1,6 @@ { "index_patterns": [ ".monitoring-kibana-${monitoring.template.version}-*" ], - "version": 7000001, + "version": 7000099, "settings": { "index.number_of_shards": 1, "index.number_of_replicas": 0, diff --git a/x-pack/plugin/core/src/main/resources/monitoring-logstash.json b/x-pack/plugin/core/src/main/resources/monitoring-logstash.json index cadefd6864dc5..5ae3e9a9eb85a 100644 --- a/x-pack/plugin/core/src/main/resources/monitoring-logstash.json +++ b/x-pack/plugin/core/src/main/resources/monitoring-logstash.json @@ -1,6 +1,6 @@ { "index_patterns": [ ".monitoring-logstash-${monitoring.template.version}-*" ], - "version": 7000001, + "version": 7000099, "settings": { "index.number_of_shards": 1, "index.number_of_replicas": 0, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json index e1f418d5a8d71..1a177a26e7cf2 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_cluster_status.json @@ -7,7 +7,7 @@ "link": "elasticsearch/indices", "severity": 2100, "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json index 5c0cb7f55b4e5..4b45cb38f07d4 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_nodes.json @@ -7,7 +7,7 @@ "link": "elasticsearch/nodes", "severity": 1999, "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json index 051a3a9d40921..7cb494ce8e712 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/elasticsearch_version_mismatch.json @@ -7,7 +7,7 @@ "link": "elasticsearch/nodes", "severity": 1000, "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json index b2acba610e141..7ec176c57897a 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/kibana_version_mismatch.json @@ -7,7 +7,7 @@ "link": "kibana/instances", "severity": 1000, "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json index cf1fdde606c7a..69fc05f7ccee8 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/logstash_version_mismatch.json @@ -7,7 +7,7 @@ "link": "logstash/instances", "severity": 1000, "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, diff --git a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json index 7eb0d59167dbd..e7c05fbcde11b 100644 --- a/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json +++ b/x-pack/plugin/monitoring/src/main/resources/monitoring/watches/xpack_license_expiration.json @@ -8,7 +8,7 @@ "alert_index": ".monitoring-alerts-6", "cluster_uuid": "${monitoring.watch.cluster_uuid}", "type": "monitoring", - "version_created": 7000001, + "version_created": 7000099, "watch": "${monitoring.watch.id}" } }, From 04f62073db8452edee1160110ee6f4785bb238b4 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 07:27:08 +0200 Subject: [PATCH 08/21] fix HLR test --- .../test/java/org/elasticsearch/client/PingAndInfoIT.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java index 3d6b2d6634f93..91a3d49ec2ae7 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java @@ -85,7 +85,10 @@ public void testXPackInfo() throws IOException { assertTrue(ml.available()); assertTrue(ml.enabled()); assertEquals(mainResponse.getVersion().toString(), - ml.nativeCodeInfo().get("version").toString().replace("-SNAPSHOT", "")); + ml.nativeCodeInfo().get("version").toString() + .replace("-SNAPSHOT", "") + .replaceFirst("-(alpha|beta|rc)[0-9]+", "") + ); } public void testXPackInfoEmptyRequest() throws IOException { From dabdd05946d70b0d886f081ca90a21ec1360a8cb Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 09:41:04 +0200 Subject: [PATCH 09/21] Set version in meta-inf to build version --- .../src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy index 824da05e12ccd..f5b6e6462bce2 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/BuildPlugin.groovy @@ -699,7 +699,7 @@ class BuildPlugin implements Plugin { // this doFirst is added before the info plugin, therefore it will run // after the doFirst added by the info plugin, and we can override attributes jarTask.manifest.attributes( - 'X-Compile-Elasticsearch-Version': String.valueOf(Version.fromString(VersionProperties.elasticsearch)), + 'X-Compile-Elasticsearch-Version': VersionProperties.elasticsearch, 'X-Compile-Lucene-Version': VersionProperties.lucene, 'X-Compile-Elasticsearch-Snapshot': VersionProperties.isElasticsearchSnapshot(), 'Build-Date': ZonedDateTime.now(ZoneOffset.UTC), From c67a06731139b72f625b9bc3338fb15cee53120b Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 10:11:43 +0200 Subject: [PATCH 10/21] Fix HLRC tests --- server/src/main/java/org/elasticsearch/Build.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index 9021e2d4c1f66..99b9ab28b522c 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -121,7 +121,10 @@ public static Type fromDisplayName(final String displayName) { final String esPrefix = "elasticsearch-" + Version.CURRENT; final URL url = getElasticsearchCodeSourceLocation(); final String urlStr = url == null ? "" : url.toString(); - if (urlStr.startsWith("file:/") && (urlStr.endsWith(esPrefix + ".jar") || urlStr.endsWith(esPrefix + "-SNAPSHOT.jar"))) { + if (urlStr.startsWith("file:/") && ( + urlStr.endsWith(esPrefix + ".jar") || + urlStr.matches("(.*)" + esPrefix + "(-)?((alpha|beta|rc)[0-9]+)?(-SNAPSHOT)?.jar") + )) { try (JarInputStream jar = new JarInputStream(FileSystemUtils.openFileURLStream(url))) { Manifest manifest = jar.getManifest(); shortHash = manifest.getMainAttributes().getValue("Change"); From 970eff37519959c17e59133f2a4f137d52706259 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 14:09:50 +0200 Subject: [PATCH 11/21] fix wildfly test --- qa/wildfly/build.gradle | 2 +- .../java/org/elasticsearch/wildfly/WildflyIT.java | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 6c6bf5d9b31b9..98111f6393dc2 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -129,7 +129,7 @@ task startWildfly { assert index >= 0 httpPort = Integer.parseInt(line.substring(index + 1)) // set this system property so the test runner knows the port Wildfly is listening for HTTP requests on - integTestRunner.systemProperty("tests.jboss.http.port", httpPort) + integTestRunner.systemProperty("tests.jboss.home", "http://localhost:$httpPort/wildfly-$version/transport") } else if (line.matches('.*Http management interface listening on http://.*:\\d+/management$')) { assert managementPort == 0 final int colonIndex = line.lastIndexOf(":") diff --git a/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java b/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java index 1da713ea9bcd9..b77e6c92cba2c 100644 --- a/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java +++ b/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java @@ -27,10 +27,9 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.TestRuleLimitSysouts; -import org.elasticsearch.Build; -import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterModule; import org.elasticsearch.common.Strings; import org.elasticsearch.common.xcontent.DeprecationHandler; @@ -54,14 +53,16 @@ @TestRuleLimitSysouts.Limit(bytes = 14000) public class WildflyIT extends LuceneTestCase { + Logger logger = Logger.getLogger(WildflyIT.class); + public void testTransportClient() throws URISyntaxException, IOException { try (CloseableHttpClient client = HttpClientBuilder.create().build()) { final String str = String.format( - Locale.ROOT, - "http://localhost:%d/wildfly-%s%s/transport/employees/1", - Integer.parseInt(System.getProperty("tests.jboss.http.port")), - Version.CURRENT, - Build.CURRENT.isSnapshot() ? "-SNAPSHOT" : ""); + Locale.ROOT, + "%s/employees/1", + System.getProperty("tests.jboss.home") + ); + logger.info("Connecting to uri: " + str); final HttpPut put = new HttpPut(new URI(str)); final String body; try (XContentBuilder builder = jsonBuilder()) { From d6abd1aeba91a85a6daf588b4da5a6806753e869 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Fri, 2 Nov 2018 14:19:14 +0200 Subject: [PATCH 12/21] Fix packaging tests for unreleased versions --- .../org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index 0aa57502c39c1..ffd274bbd77f6 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -280,7 +280,8 @@ class VagrantTestPlugin implements Plugin { Task createUpgradeFromFile = project.tasks.create('createUpgradeFromFile', FileContentsTask) { dependsOn copyPackagingArchives file "${archivesDir}/upgrade_from_version" - contents project.extensions.esvagrant.upgradeFromVersion.toString() + contents "${project.extensions.esvagrant.upgradeFromVersion}"+ + "${project.bwcVersions.unreleased.contains(project.extensions.esvagrant.upgradeFromVersion)?"-SNAPSHOT": ""}" } Task createUpgradeIsOssFile = project.tasks.create('createUpgradeIsOssFile', FileContentsTask) { From 1fd508dd85efc0aca90ac9f63a3b337183d9ad49 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Sat, 3 Nov 2018 09:21:58 +0200 Subject: [PATCH 13/21] Fix version parsing sql client Allow for qualifier --- .../java/org/elasticsearch/xpack/sql/cli/VersionTests.java | 2 +- .../main/java/org/elasticsearch/xpack/sql/client/Version.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/VersionTests.java b/x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/VersionTests.java index 5be8bdd4df025..96e3e417531a7 100644 --- a/x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/VersionTests.java +++ b/x-pack/plugin/sql/sql-cli/src/test/java/org/elasticsearch/xpack/sql/cli/VersionTests.java @@ -12,10 +12,10 @@ public class VersionTests extends ESTestCase { public void testVersionIsCurrent() { /* This test will only work properly in gradle because in gradle we run the tests * using the jar. */ - assertEquals(org.elasticsearch.Version.CURRENT.toString(), Version.CURRENT.version); assertNotNull(Version.CURRENT.hash); assertEquals(org.elasticsearch.Version.CURRENT.major, Version.CURRENT.major); assertEquals(org.elasticsearch.Version.CURRENT.minor, Version.CURRENT.minor); + assertEquals(org.elasticsearch.Version.CURRENT.revision, Version.CURRENT.revision); } } diff --git a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java index d7327af6c4e48..57956d1cc219b 100644 --- a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java +++ b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java @@ -38,7 +38,8 @@ public static Version fromString(String version) { static byte[] from(String ver) { String[] parts = ver.split("[.-]"); - if (parts.length == 3 || parts.length == 4) { + // Allow for optional snapshot and qualifier + if (parts.length >= 3 || parts.length < 6) { return new byte[] { Byte.parseByte(parts[0]), Byte.parseByte(parts[1]), Byte.parseByte(parts[2]) }; } else { From b4db6b9af1913ef452ae31069244c6fe57c76fee Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Sun, 4 Nov 2018 10:22:47 +0200 Subject: [PATCH 14/21] Fix cli version tests --- .../java/org/elasticsearch/xpack/sql/jdbc/VersionTests.java | 2 +- .../java/org/elasticsearch/xpack/sql/client/Version.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/VersionTests.java b/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/VersionTests.java index 03986e595442a..0a2d3206468d8 100644 --- a/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/VersionTests.java +++ b/x-pack/plugin/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/VersionTests.java @@ -12,9 +12,9 @@ public class VersionTests extends ESTestCase { public void testVersionIsCurrent() { /* This test will only work properly in gradle because in gradle we run the tests * using the jar. */ - assertEquals(org.elasticsearch.Version.CURRENT.toString(), Version.CURRENT.version); assertNotNull(Version.CURRENT.hash); assertEquals(org.elasticsearch.Version.CURRENT.major, Version.CURRENT.major); assertEquals(org.elasticsearch.Version.CURRENT.minor, Version.CURRENT.minor); + assertEquals(org.elasticsearch.Version.CURRENT.revision, Version.CURRENT.revision); } } diff --git a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java index 57956d1cc219b..3f7134272c9c5 100644 --- a/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java +++ b/x-pack/plugin/sql/sql-client/src/main/java/org/elasticsearch/xpack/sql/client/Version.java @@ -39,11 +39,11 @@ public static Version fromString(String version) { static byte[] from(String ver) { String[] parts = ver.split("[.-]"); // Allow for optional snapshot and qualifier - if (parts.length >= 3 || parts.length < 6) { - return new byte[] { Byte.parseByte(parts[0]), Byte.parseByte(parts[1]), Byte.parseByte(parts[2]) }; + if (parts.length < 3 || parts.length > 5) { + throw new IllegalArgumentException("Invalid version " + ver); } else { - throw new IllegalArgumentException("Invalid version " + ver); + return new byte[] { Byte.parseByte(parts[0]), Byte.parseByte(parts[1]), Byte.parseByte(parts[2]) }; } } From 917131c407d4fc61a18665180dcb7aefca596ff8 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 5 Nov 2018 08:52:01 +0200 Subject: [PATCH 15/21] Introduce a version field to `Build` Now that the version no longer carries information about the qualifier, we still need a way to show the "display version" that does have both qualifier and snapshot. With this change we read it from the jar. A subsequent change will switch to useing it instead of `Version.displayVersion` --- .../main/java/org/elasticsearch/Build.java | 44 ++++++++++++++++--- .../action/main/MainResponse.java | 5 ++- .../java/org/elasticsearch/BuildTests.java | 30 ++++++++++--- .../action/main/MainResponseTests.java | 16 +++++-- 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index 99b9ab28b522c..304c59f644f34 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -114,6 +114,7 @@ public static Type fromDisplayName(final String displayName) { final String shortHash; final String date; final boolean isSnapshot; + final String version; flavor = Flavor.fromDisplayName(System.getProperty("es.distribution.flavor", "unknown")); type = Type.fromDisplayName(System.getProperty("es.distribution.type", "unknown")); @@ -130,6 +131,7 @@ public static Type fromDisplayName(final String displayName) { shortHash = manifest.getMainAttributes().getValue("Change"); date = manifest.getMainAttributes().getValue("Build-Date"); isSnapshot = "true".equals(manifest.getMainAttributes().getValue("X-Compile-Elasticsearch-Snapshot")); + version = manifest.getMainAttributes().getValue("X-Compile-Elasticsearch-Version"); } catch (IOException e) { throw new RuntimeException(e); } @@ -137,6 +139,7 @@ public static Type fromDisplayName(final String displayName) { // not running from the official elasticsearch jar file (unit tests, IDE, uber client jar, shadiness) shortHash = "Unknown"; date = "Unknown"; + version = "Unknown"; final String buildSnapshot = System.getProperty("build.snapshot"); if (buildSnapshot != null) { try { @@ -158,8 +161,12 @@ public static Type fromDisplayName(final String displayName) { throw new IllegalStateException("Error finding the build date. " + "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug."); } + if (version == null) { + throw new IllegalStateException("Error finding the build version. " + + "Stopping Elasticsearch now so it doesn't run in subtly broken ways. This is likely a build bug."); + } - CURRENT = new Build(flavor, type, shortHash, date, isSnapshot); + CURRENT = new Build(flavor, type, shortHash, date, isSnapshot, version); } private final boolean isSnapshot; @@ -178,13 +185,18 @@ static URL getElasticsearchCodeSourceLocation() { private final Type type; private final String shortHash; private final String date; + private final String version; - public Build(final Flavor flavor, final Type type, final String shortHash, final String date, boolean isSnapshot) { + public Build( + final Flavor flavor, final Type type, final String shortHash, final String date, boolean isSnapshot, + String version + ) { this.flavor = flavor; this.type = type; this.shortHash = shortHash; this.date = date; this.isSnapshot = isSnapshot; + this.version = version; } public String shortHash() { @@ -211,7 +223,14 @@ public static Build readBuild(StreamInput in) throws IOException { String hash = in.readString(); String date = in.readString(); boolean snapshot = in.readBoolean(); - return new Build(flavor, type, hash, date, snapshot); + + final String version; + if (in.getVersion().onOrAfter(Version.V_7_0_0)) { + version = in.readString(); + } else { + version = "Unknown"; + } + return new Build(flavor, type, hash, date, snapshot, version); } public static void writeBuild(Build build, StreamOutput out) throws IOException { @@ -224,6 +243,13 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException out.writeString(build.shortHash()); out.writeString(build.date()); out.writeBoolean(build.isSnapshot()); + if (out.getVersion().onOrAfter(Version.V_7_0_0)) { + out.writeString(build.getVersion()); + } + } + + public String getVersion() { + return version; } public Flavor flavor() { @@ -238,9 +264,13 @@ public boolean isSnapshot() { return isSnapshot; } + public boolean isProductionRelease() { + return version.matches("[0-9]+\\.[0-9]+\\.[0-9]+"); + } + @Override public String toString() { - return "[" + flavor.displayName() + "][" + type.displayName + "][" + shortHash + "][" + date + "]"; + return "[" + flavor.displayName() + "][" + type.displayName + "][" + shortHash + "][" + date + "][" + version +"]"; } @Override @@ -268,13 +298,15 @@ public boolean equals(Object o) { if (!shortHash.equals(build.shortHash)) { return false; } + if (version.equals(build.version) == false) { + return false; + } return date.equals(build.date); - } @Override public int hashCode() { - return Objects.hash(flavor, type, isSnapshot, shortHash, date); + return Objects.hash(flavor, type, isSnapshot, shortHash, date, version); } } diff --git a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java index d5367cd1bc21b..012b764bc6e17 100644 --- a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java +++ b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java @@ -112,6 +112,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws .field("build_hash", build.shortHash()) .field("build_date", build.date()) .field("build_snapshot", build.isSnapshot()) + .field("build_version", build.getVersion()) .field("lucene_version", version.luceneVersion.toString()) .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString()) .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString()) @@ -138,7 +139,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws buildType == null ? Build.Type.UNKNOWN : Build.Type.fromDisplayName(buildType), (String) value.get("build_hash"), (String) value.get("build_date"), - (boolean) value.get("build_snapshot")); + (boolean) value.get("build_snapshot"), + (String) value.get("build_version") + ); response.version = Version.fromString((String) value.get("number")); }, (parser, context) -> parser.map(), new ParseField("version")); } diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index c2b0f3acb941d..0d3f4c8b71adc 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -44,29 +44,47 @@ public void testJarMetadata() throws IOException { public void testEqualsAndHashCode() { Build build = Build.CURRENT; - Build another = new Build(build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot()); + Build another = new Build( + build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + ); assertEquals(build, another); assertEquals(build.hashCode(), another.hashCode()); final Set otherFlavors = Arrays.stream(Build.Flavor.values()).filter(f -> !f.equals(build.flavor())).collect(Collectors.toSet()); final Build.Flavor otherFlavor = randomFrom(otherFlavors); - Build differentFlavor = new Build(otherFlavor, build.type(), build.shortHash(), build.date(), build.isSnapshot()); + Build differentFlavor = new Build( + otherFlavor, build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + ); assertNotEquals(build, differentFlavor); final Set otherTypes = Arrays.stream(Build.Type.values()).filter(f -> !f.equals(build.type())).collect(Collectors.toSet()); final Build.Type otherType = randomFrom(otherTypes); - Build differentType = new Build(build.flavor(), otherType, build.shortHash(), build.date(), build.isSnapshot()); + Build differentType = new Build( + build.flavor(), otherType, build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + ); assertNotEquals(build, differentType); - Build differentHash = new Build(build.flavor(), build.type(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot()); + Build differentHash = new Build( + build.flavor(), build.type(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot(), + build.getVersion() + ); assertNotEquals(build, differentHash); - Build differentDate = new Build(build.flavor(), build.type(), build.shortHash(), "1970-01-01", build.isSnapshot()); + Build differentDate = new Build( + build.flavor(), build.type(), build.shortHash(), "1970-01-01", build.isSnapshot(), build.getVersion() + ); assertNotEquals(build, differentDate); - Build differentSnapshot = new Build(build.flavor(), build.type(), build.shortHash(), build.date(), !build.isSnapshot()); + Build differentSnapshot = new Build( + build.flavor(), build.type(), build.shortHash(), build.date(), !build.isSnapshot(), build.getVersion() + ); assertNotEquals(build, differentSnapshot); + + Build differentVersion = new Build( + build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), "7.0.0" + ); + assertNotEquals(build, differentVersion); } } diff --git a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java index b833ed674c018..f2d7af478c484 100644 --- a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java @@ -41,7 +41,10 @@ protected MainResponse createTestInstance() { ClusterName clusterName = new ClusterName(randomAlphaOfLength(10)); String nodeName = randomAlphaOfLength(10); final String date = new Date(randomNonNegativeLong()).toString(); - Build build = new Build(Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean()); + Build build = new Build( + Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, randomAlphaOfLength(8), date, randomBoolean(), + randomAlphaOfLength(12) + ); Version version = VersionUtils.randomVersion(random()); return new MainResponse(nodeName, version, clusterName, clusterUuid , build); } @@ -59,7 +62,10 @@ protected MainResponse doParseInstance(XContentParser parser) { public void testToXContent() throws IOException { String clusterUUID = randomAlphaOfLengthBetween(10, 20); final Build current = Build.CURRENT; - Build build = new Build(current.flavor(), current.type(), current.shortHash(), current.date(), current.isSnapshot()); + Build build = new Build( + current.flavor(), current.type(), current.shortHash(), current.date(), current.isSnapshot(), + current.getVersion() + ); Version version = Version.CURRENT; MainResponse response = new MainResponse("nodeName", version, new ClusterName("clusterName"), clusterUUID, build); XContentBuilder builder = XContentFactory.jsonBuilder(); @@ -75,6 +81,7 @@ public void testToXContent() throws IOException { + "\"build_hash\":\"" + current.shortHash() + "\"," + "\"build_date\":\"" + current.date() + "\"," + "\"build_snapshot\":" + current.isSnapshot() + "," + + "\"build_version\":\"" + current.getVersion() + "\"," + "\"lucene_version\":\"" + version.luceneVersion.toString() + "\"," + "\"minimum_wire_compatibility_version\":\"" + version.minimumCompatibilityVersion().toString() + "\"," + "\"minimum_index_compatibility_version\":\"" + version.minimumIndexCompatibilityVersion().toString() + "\"}," @@ -98,7 +105,10 @@ protected MainResponse mutateInstance(MainResponse mutateInstance) { break; case 2: // toggle the snapshot flag of the original Build parameter - build = new Build(Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, build.shortHash(), build.date(), !build.isSnapshot()); + build = new Build( + Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, build.shortHash(), build.date(), !build.isSnapshot(), + build.getVersion() + ); break; case 3: version = randomValueOtherThan(version, () -> VersionUtils.randomVersion(random())); From 3ce864efde4f818a72e3b85fa61940dfb7d1bdb1 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 5 Nov 2018 11:22:35 +0200 Subject: [PATCH 16/21] Fix doc tests --- .../gradle/doc/DocsTestPlugin.groovy | 2 +- docs/plugins/discovery-azure-classic.asciidoc | 1 + docs/reference/cat/plugins.asciidoc | 36 +++++++++---------- .../setup/install/check-running.asciidoc | 1 + 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index d450e665f75e1..e0917616123aa 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -43,7 +43,7 @@ public class DocsTestPlugin extends RestTestPlugin { * to the version being built for testing but needs to resolve to * the last released version for docs. */ '\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(), - '\\{plugin_version\\}': VersionProperties.elasticsearch, + '\\{build_version\\}': VersionProperties.elasticsearch, '\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''), '\\{build_flavor\\}' : project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default', diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index 1c1925de878aa..d52a4efe4678c 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -377,6 +377,7 @@ This command should give you a JSON result: "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, + "build_version" : "{build_version}", "lucene_version" : "{lucene_version}", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" diff --git a/docs/reference/cat/plugins.asciidoc b/docs/reference/cat/plugins.asciidoc index 12c11466a3802..8efe01d71022e 100644 --- a/docs/reference/cat/plugins.asciidoc +++ b/docs/reference/cat/plugins.asciidoc @@ -14,24 +14,24 @@ Might look like: ["source","txt",subs="attributes,callouts"] ------------------------------------------------------------------------------ name component version description -U7321H6 analysis-icu {plugin_version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. -U7321H6 analysis-kuromoji {plugin_version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. -U7321H6 analysis-nori {plugin_version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. -U7321H6 analysis-phonetic {plugin_version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. -U7321H6 analysis-smartcn {plugin_version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. -U7321H6 analysis-stempel {plugin_version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. -U7321H6 analysis-ukrainian {plugin_version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. -U7321H6 discovery-azure-classic {plugin_version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism -U7321H6 discovery-ec2 {plugin_version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. -U7321H6 discovery-gce {plugin_version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. -U7321H6 ingest-attachment {plugin_version} Ingest processor that uses Apache Tika to extract contents -U7321H6 ingest-geoip {plugin_version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database -U7321H6 ingest-user-agent {plugin_version} Ingest processor that extracts information from a user agent -U7321H6 mapper-annotated-text {plugin_version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. -U7321H6 mapper-murmur3 {plugin_version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. -U7321H6 mapper-size {plugin_version} The Mapper Size plugin allows document to record their uncompressed size at index time. -U7321H6 store-smb {plugin_version} The Store SMB plugin adds support for SMB stores. -U7321H6 transport-nio {plugin_version} The nio transport. +U7321H6 analysis-icu {build_version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. +U7321H6 analysis-kuromoji {build_version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. +U7321H6 analysis-nori {build_version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. +U7321H6 analysis-phonetic {build_version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. +U7321H6 analysis-smartcn {build_version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. +U7321H6 analysis-stempel {build_version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. +U7321H6 analysis-ukrainian {build_version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. +U7321H6 discovery-azure-classic {build_version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism +U7321H6 discovery-ec2 {build_version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. +U7321H6 discovery-gce {build_version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. +U7321H6 ingest-attachment {build_version} Ingest processor that uses Apache Tika to extract contents +U7321H6 ingest-geoip {build_version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database +U7321H6 ingest-user-agent {build_version} Ingest processor that extracts information from a user agent +U7321H6 mapper-annotated-text {build_version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. +U7321H6 mapper-murmur3 {build_version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. +U7321H6 mapper-size {build_version} The Mapper Size plugin allows document to record their uncompressed size at index time. +U7321H6 store-smb {build_version} The Store SMB plugin adds support for SMB stores. +U7321H6 transport-nio {build_version} The nio transport. ------------------------------------------------------------------------------ // TESTRESPONSE[s/([.()])/\\$1/ s/U7321H6/.+/ _cat] diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index 7b95a10158d2f..b5df20fc0564e 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -24,6 +24,7 @@ which should give you a response something like this: "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, + "build_version" : "{build_version}", "lucene_version" : "{lucene_version}", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" From 26be21bc84b13049d08ab92af563007c435e389f Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 5 Nov 2018 15:39:32 +0200 Subject: [PATCH 17/21] Remove `Version.getDisplayName` --- .../plugins/InstallPluginCommand.java | 4 +- .../plugins/InstallPluginCommandTests.java | 46 +++++++++++-------- .../main/java/org/elasticsearch/Version.java | 6 +-- .../action/main/MainResponse.java | 1 + .../bootstrap/Elasticsearch.java | 3 +- .../java/org/elasticsearch/node/Node.java | 11 ++--- .../java/org/elasticsearch/BuildTests.java | 27 +++++++++++ .../java/org/elasticsearch/VersionTests.java | 12 ----- .../bootstrap/ElasticsearchCliTests.java | 3 +- .../org/elasticsearch/node/NodeTests.java | 31 ------------- 10 files changed, 66 insertions(+), 78 deletions(-) diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java index dd19594d29b87..3bd4729048e59 100644 --- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java +++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java @@ -310,11 +310,11 @@ private String getElasticUrl( baseUrl = String.format(Locale.ROOT, "https://artifacts.elastic.co/downloads/elasticsearch-plugins/%s", pluginId); } final String platformUrl = - String.format(Locale.ROOT, "%s/%s-%s-%s.zip", baseUrl, pluginId, platform, Version.displayVersion(version, isSnapshot)); + String.format(Locale.ROOT, "%s/%s-%s-%s.zip", baseUrl, pluginId, platform, Build.CURRENT.getVersion()); if (urlExists(terminal, platformUrl)) { return platformUrl; } - return String.format(Locale.ROOT, "%s/%s-%s.zip", baseUrl, pluginId, Version.displayVersion(version, isSnapshot)); + return String.format(Locale.ROOT, "%s/%s-%s.zip", baseUrl, pluginId, Build.CURRENT.getVersion()); } private String nonReleaseUrl(final String hostname, final Version version, final String stagingHash, final String pluginId) { diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java index ceff354f15fe8..b5906a0e9c00f 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java @@ -936,7 +936,8 @@ public void assertInstallPluginFromUrl( } public void testOfficialPlugin() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false); } @@ -945,7 +946,7 @@ public void testOfficialPluginSnapshot() throws Exception { Locale.ROOT, "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s.zip", Version.CURRENT, - Version.displayVersion(Version.CURRENT, true)); + Build.CURRENT.getVersion()); assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true); } @@ -954,7 +955,7 @@ public void testInstallReleaseBuildOfPluginOnSnapshotBuild() { Locale.ROOT, "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s.zip", Version.CURRENT, - Version.displayVersion(Version.CURRENT, true)); + Build.CURRENT.getVersion()); // attemping to install a release build of a plugin (no staging ID) on a snapshot build should throw a user exception final UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, true)); @@ -965,13 +966,13 @@ public void testInstallReleaseBuildOfPluginOnSnapshotBuild() { public void testOfficialPluginStaging() throws Exception { String url = "https://staging.elastic.co/" + Version.CURRENT + "-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" - + Version.CURRENT + ".zip"; + + Build.CURRENT.getVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", false); } public void testOfficialPlatformPlugin() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Platforms.PLATFORM_NAME + - "-" + Version.CURRENT + ".zip"; + "-" + Build.CURRENT.getVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false); } @@ -981,13 +982,13 @@ public void testOfficialPlatformPluginSnapshot() throws Exception { "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s-%s.zip", Version.CURRENT, Platforms.PLATFORM_NAME, - Version.displayVersion(Version.CURRENT, true)); + Build.CURRENT.getVersion()); assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true); } public void testOfficialPlatformPluginStaging() throws Exception { String url = "https://staging.elastic.co/" + Version.CURRENT + "-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" - + Platforms.PLATFORM_NAME + "-"+ Version.CURRENT + ".zip"; + + Platforms.PLATFORM_NAME + "-"+ Build.CURRENT.getVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", false); } @@ -1009,10 +1010,13 @@ public void testMavenSha1Backcompat() throws Exception { } public void testOfficialShaMissing() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-1"); UserException e = expectThrows(UserException.class, () -> - assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, ".sha1", checksum(digest), null, (b, p) -> null)); + assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, + ".sha1", checksum(digest), null, (b, p) -> null) + ); assertEquals(ExitCodes.IO_ERROR, e.exitCode); assertEquals("Plugin checksum missing: " + url + ".sha512", e.getMessage()); } @@ -1027,7 +1031,8 @@ public void testMavenShaMissing() throws Exception { } public void testInvalidShaFileMissingFilename() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1037,7 +1042,8 @@ public void testInvalidShaFileMissingFilename() throws Exception { } public void testInvalidShaFileMismatchFilename() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion()+ ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1047,7 +1053,7 @@ public void testInvalidShaFileMismatchFilename() throws Exception { null, false, ".sha512", - checksumAndString(digest, " repository-s3-" + Version.CURRENT + ".zip"), + checksumAndString(digest, " repository-s3-" + Build.CURRENT.getVersion() + ".zip"), null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1055,7 +1061,8 @@ public void testInvalidShaFileMismatchFilename() throws Exception { } public void testInvalidShaFileContainingExtraLine() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1065,7 +1072,7 @@ public void testInvalidShaFileContainingExtraLine() throws Exception { null, false, ".sha512", - checksumAndString(digest, " analysis-icu-" + Version.CURRENT + ".zip\nfoobar"), + checksumAndString(digest, " analysis-icu-" + Build.CURRENT.getVersion() + ".zip\nfoobar"), null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1073,7 +1080,8 @@ public void testInvalidShaFileContainingExtraLine() throws Exception { } public void testSha512Mismatch() throws Exception { - String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Version.CURRENT + ".zip"; + String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + + Build.CURRENT.getVersion() + ".zip"; UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( "analysis-icu", @@ -1082,7 +1090,7 @@ public void testSha512Mismatch() throws Exception { null, false, ".sha512", - bytes -> "foobar analysis-icu-" + Version.CURRENT + ".zip", + bytes -> "foobar analysis-icu-" + Build.CURRENT.getVersion() + ".zip", null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1101,7 +1109,8 @@ public void testSha1Mismatch() throws Exception { public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception { final String icu = "analysis-icu"; final String url = - "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + Version.CURRENT + ".zip"; + "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + + Build.CURRENT.getVersion() + ".zip"; final MessageDigest digest = MessageDigest.getInstance("SHA-512"); /* * To setup a situation where the expected public key ID does not match the public key ID used for signing, we generate a new public @@ -1124,7 +1133,8 @@ public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception { public void testFailedSignatureVerification() throws Exception { final String icu = "analysis-icu"; final String url = - "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + Version.CURRENT + ".zip"; + "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + + Build.CURRENT.getVersion() + ".zip"; final MessageDigest digest = MessageDigest.getInstance("SHA-512"); /* * To setup a situation where signature verification fails, we will mutate the input byte array by modifying a single byte to some diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index 6ebb49e11ed7a..d80c01f1ecb43 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -390,7 +390,7 @@ public static void main(String[] args) { final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s/%s/%s, JVM: %s", - Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), + Build.CURRENT.getVersion(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), Build.CURRENT.shortHash(), @@ -424,10 +424,6 @@ public String toString() { return sb.toString(); } - public static String displayVersion(final Version version, final boolean isSnapshot) { - return version + (isSnapshot ? "-SNAPSHOT" : ""); - } - @Override public boolean equals(Object o) { if (this == o) { diff --git a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java index 012b764bc6e17..306e51b08cdac 100644 --- a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java +++ b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java @@ -61,6 +61,7 @@ public Version getVersion() { return version; } + public ClusterName getClusterName() { return clusterName; } diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index 6296b611c15d9..1d331e05ba515 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -24,7 +24,6 @@ import joptsimple.OptionSpecBuilder; import joptsimple.util.PathConverter; import org.elasticsearch.Build; -import org.elasticsearch.Version; import org.elasticsearch.cli.EnvironmentAwareCommand; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.cli.Terminal; @@ -102,7 +101,7 @@ protected void execute(Terminal terminal, OptionSet options, Environment env) th final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s/%s/%s, JVM: %s", - Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), + Build.CURRENT.getVersion(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), Build.CURRENT.shortHash(), diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 6480ef3ffaebc..3f7d8ead39655 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -26,7 +26,6 @@ import org.elasticsearch.Build; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchTimeoutException; -import org.elasticsearch.Version; import org.elasticsearch.action.Action; import org.elasticsearch.action.ActionModule; import org.elasticsearch.action.search.SearchExecutionStatsCollector; @@ -279,7 +278,7 @@ protected Node( final JvmInfo jvmInfo = JvmInfo.jvmInfo(); logger.info( "version[{}], pid[{}], build[{}/{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", - Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()), + Build.CURRENT.getVersion(), jvmInfo.pid(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), @@ -293,7 +292,7 @@ protected Node( Constants.JAVA_VERSION, Constants.JVM_VERSION); logger.info("JVM arguments {}", Arrays.toString(jvmInfo.getInputArguments())); - warnIfPreRelease(Version.CURRENT, Build.CURRENT.isSnapshot(), logger); + warnIfPreRelease(Build.CURRENT, logger); if (logger.isDebugEnabled()) { logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]", @@ -577,11 +576,11 @@ protected Node( } } - static void warnIfPreRelease(final Version version, final boolean isSnapshot, final Logger logger) { - if (!version.isRelease() || isSnapshot) { + static void warnIfPreRelease(final Build build,final Logger logger) { + if (build.isProductionRelease() == false) { logger.warn( "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", - Version.displayVersion(version, isSnapshot)); + Build.CURRENT.getVersion()); } } diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index 0d3f4c8b71adc..c84ed1ca11bab 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -41,6 +41,33 @@ public void testJarMetadata() throws IOException { assertNotNull(Build.CURRENT.shortHash()); } + public void testIsProduction() { + assertTrue(new Build( + Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), + Build.CURRENT.isSnapshot(), randomInt() + "." + randomInt() + "." + randomInt() + ).isProductionRelease()); + + assertFalse(new Build( + Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), + Build.CURRENT.isSnapshot(), "7.0.0-alpha1" + ).isProductionRelease()); + + assertFalse(new Build( + Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), + Build.CURRENT.isSnapshot(), "7.0.0-alpha1-SNAPSHOT" + ).isProductionRelease()); + + assertFalse(new Build( + Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), + Build.CURRENT.isSnapshot(), "7.0.0-SNAPSHOT" + ).isProductionRelease()); + + assertFalse(new Build( + Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), + Build.CURRENT.isSnapshot(), "Unknown" + ).isProductionRelease()); + } + public void testEqualsAndHashCode() { Build build = Build.CURRENT; diff --git a/server/src/test/java/org/elasticsearch/VersionTests.java b/server/src/test/java/org/elasticsearch/VersionTests.java index b44138e00160f..ae7442f9ed614 100644 --- a/server/src/test/java/org/elasticsearch/VersionTests.java +++ b/server/src/test/java/org/elasticsearch/VersionTests.java @@ -411,16 +411,4 @@ public void testUnreleasedVersion() { VersionTests.assertUnknownVersion(VERSION_5_1_0_UNRELEASED); } - public void testDisplayVersion() { - final Version version = randomVersion(random()); - { - final String displayVersion = Version.displayVersion(version, true); - assertThat(displayVersion, equalTo(version.toString() + "-SNAPSHOT")); - } - { - final String displayVersion = Version.displayVersion(version, false); - assertThat(displayVersion, equalTo(version.toString())); - } - } - } diff --git a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java index fa65a7a12a230..e473c1a495319 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java @@ -20,7 +20,6 @@ package org.elasticsearch.bootstrap; import org.elasticsearch.Build; -import org.elasticsearch.Version; import org.elasticsearch.cli.ExitCodes; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.monitor.jvm.JvmInfo; @@ -63,7 +62,7 @@ private void runTestThatVersionIsMutuallyExclusiveToOtherOptions(String... args) private void runTestThatVersionIsReturned(String... args) throws Exception { runTestVersion(ExitCodes.OK, output -> { - assertThat(output, containsString("Version: " + Version.displayVersion(Version.CURRENT, Build.CURRENT.isSnapshot()))); + assertThat(output, containsString("Version: " + Build.CURRENT.getVersion())); final String expectedBuildOutput = String.format( Locale.ROOT, "Build: %s/%s/%s/%s", diff --git a/server/src/test/java/org/elasticsearch/node/NodeTests.java b/server/src/test/java/org/elasticsearch/node/NodeTests.java index ded1010f9e245..288817d5c7708 100644 --- a/server/src/test/java/org/elasticsearch/node/NodeTests.java +++ b/server/src/test/java/org/elasticsearch/node/NodeTests.java @@ -18,9 +18,7 @@ */ package org.elasticsearch.node; -import org.apache.logging.log4j.Logger; import org.apache.lucene.util.LuceneTestCase; -import org.elasticsearch.Version; import org.elasticsearch.bootstrap.BootstrapCheck; import org.elasticsearch.bootstrap.BootstrapContext; import org.elasticsearch.cluster.ClusterName; @@ -40,11 +38,6 @@ import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.reset; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - @LuceneTestCase.SuppressFileSystems(value = "ExtrasFS") public class NodeTests extends ESTestCase { @@ -88,30 +81,6 @@ protected void validateNodeBeforeAcceptingRequests(BootstrapContext context, Bou } } - public void testWarnIfPreRelease() { - final Logger logger = mock(Logger.class); - - final int id = randomIntBetween(1, 9) * 1000000; - final Version releaseVersion = Version.fromId(id + 99); - final Version preReleaseVersion = Version.fromId(id + randomIntBetween(0, 98)); - - Node.warnIfPreRelease(releaseVersion, false, logger); - verifyNoMoreInteractions(logger); - - reset(logger); - Node.warnIfPreRelease(releaseVersion, true, logger); - verify(logger).warn( - "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", releaseVersion + "-SNAPSHOT"); - - reset(logger); - final boolean isSnapshot = randomBoolean(); - Node.warnIfPreRelease(preReleaseVersion, isSnapshot, logger); - verify(logger).warn( - "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", - preReleaseVersion + (isSnapshot ? "-SNAPSHOT" : "")); - - } - public void testNodeAttributes() throws IOException { String attr = randomAlphaOfLength(5); Settings.Builder settings = baseSettings().put(Node.NODE_ATTRIBUTES.getKey() + "test_attr", attr); From 638b846fe0c4cfff9fa85b4fa94b103932b6f1ee Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Mon, 5 Nov 2018 17:55:11 +0200 Subject: [PATCH 18/21] fix isProductionRelease tests --- server/src/test/java/org/elasticsearch/BuildTests.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index c84ed1ca11bab..a5bbb6fe97b0e 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -42,10 +42,11 @@ public void testJarMetadata() throws IOException { } public void testIsProduction() { - assertTrue(new Build( + Build build = new Build( Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), - Build.CURRENT.isSnapshot(), randomInt() + "." + randomInt() + "." + randomInt() - ).isProductionRelease()); + Build.CURRENT.isSnapshot(), Math.abs(randomInt()) + "." + Math.abs(randomInt()) + "." + Math.abs(randomInt()) + ); + assertTrue(build.getVersion(), build.isProductionRelease()); assertFalse(new Build( Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), From 37c5812094e84b352465fc273a4de4d2a0c330ed Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 6 Nov 2018 12:27:09 +0200 Subject: [PATCH 19/21] PR review --- .../gradle/doc/DocsTestPlugin.groovy | 2 +- .../gradle/plugin/PluginPropertiesTask.groovy | 2 +- .../gradle/vagrant/VagrantTestPlugin.groovy | 7 ++-- .../elasticsearch/client/PingAndInfoIT.java | 6 +--- .../plugins/InstallPluginCommand.java | 4 +-- .../plugins/InstallPluginCommandTests.java | 34 +++++++++--------- docs/reference/cat/plugins.asciidoc | 36 +++++++++---------- .../main/java/org/elasticsearch/Build.java | 6 ++-- .../main/java/org/elasticsearch/Version.java | 2 +- .../action/main/MainResponse.java | 2 +- .../bootstrap/Elasticsearch.java | 2 +- .../java/org/elasticsearch/node/Node.java | 4 +-- .../java/org/elasticsearch/BuildTests.java | 14 ++++---- .../action/main/MainResponseTests.java | 6 ++-- .../bootstrap/ElasticsearchCliTests.java | 2 +- 15 files changed, 64 insertions(+), 65 deletions(-) diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy index e0917616123aa..f5ea19fb2ec7f 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/doc/DocsTestPlugin.groovy @@ -43,7 +43,7 @@ public class DocsTestPlugin extends RestTestPlugin { * to the version being built for testing but needs to resolve to * the last released version for docs. */ '\\{version\\}': Version.fromString(VersionProperties.elasticsearch).toString(), - '\\{build_version\\}': VersionProperties.elasticsearch, + '\\{qualified_version\\}': VersionProperties.elasticsearch, '\\{lucene_version\\}' : VersionProperties.lucene.replaceAll('-snapshot-\\w+$', ''), '\\{build_flavor\\}' : project.integTestCluster.distribution.startsWith('oss-') ? 'oss' : 'default', diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy index 5bc98cc6ff052..f0a07515924a0 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginPropertiesTask.groovy @@ -71,7 +71,7 @@ class PluginPropertiesTask extends Copy { 'name': extension.name, 'description': extension.description, 'version': extension.version, - 'elasticsearchVersion': String.valueOf(Version.fromString(VersionProperties.elasticsearch)), + 'elasticsearchVersion': Version.fromString(VersionProperties.elasticsearch).toString(), 'javaVersion': project.targetCompatibility as String, 'classname': extension.classname, 'extendedPlugins': extension.extendedPlugins.join(','), diff --git a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy index ffd274bbd77f6..0be2069b1cd93 100644 --- a/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy +++ b/buildSrc/src/main/groovy/org/elasticsearch/gradle/vagrant/VagrantTestPlugin.groovy @@ -278,10 +278,13 @@ class VagrantTestPlugin implements Plugin { } Task createUpgradeFromFile = project.tasks.create('createUpgradeFromFile', FileContentsTask) { + String version = project.extensions.esvagrant.upgradeFromVersion + if (project.bwcVersions.unreleased.contains(project.extensions.esvagrant.upgradeFromVersion)) { + version += "-SNAPSHOT" + } dependsOn copyPackagingArchives file "${archivesDir}/upgrade_from_version" - contents "${project.extensions.esvagrant.upgradeFromVersion}"+ - "${project.bwcVersions.unreleased.contains(project.extensions.esvagrant.upgradeFromVersion)?"-SNAPSHOT": ""}" + contents version } Task createUpgradeIsOssFile = project.tasks.create('createUpgradeIsOssFile', FileContentsTask) { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java index 91a3d49ec2ae7..ba27bdd3a5bd4 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/PingAndInfoIT.java @@ -84,11 +84,7 @@ public void testXPackInfo() throws IOException { assertNotNull(ml.description()); assertTrue(ml.available()); assertTrue(ml.enabled()); - assertEquals(mainResponse.getVersion().toString(), - ml.nativeCodeInfo().get("version").toString() - .replace("-SNAPSHOT", "") - .replaceFirst("-(alpha|beta|rc)[0-9]+", "") - ); + assertEquals(mainResponse.getBuild().getQualifiedVersion(), ml.nativeCodeInfo().get("version").toString()); } public void testXPackInfoEmptyRequest() throws IOException { diff --git a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java index 3bd4729048e59..70e496ff2f274 100644 --- a/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java +++ b/distribution/tools/plugin-cli/src/main/java/org/elasticsearch/plugins/InstallPluginCommand.java @@ -310,11 +310,11 @@ private String getElasticUrl( baseUrl = String.format(Locale.ROOT, "https://artifacts.elastic.co/downloads/elasticsearch-plugins/%s", pluginId); } final String platformUrl = - String.format(Locale.ROOT, "%s/%s-%s-%s.zip", baseUrl, pluginId, platform, Build.CURRENT.getVersion()); + String.format(Locale.ROOT, "%s/%s-%s-%s.zip", baseUrl, pluginId, platform, Build.CURRENT.getQualifiedVersion()); if (urlExists(terminal, platformUrl)) { return platformUrl; } - return String.format(Locale.ROOT, "%s/%s-%s.zip", baseUrl, pluginId, Build.CURRENT.getVersion()); + return String.format(Locale.ROOT, "%s/%s-%s.zip", baseUrl, pluginId, Build.CURRENT.getQualifiedVersion()); } private String nonReleaseUrl(final String hostname, final Version version, final String stagingHash, final String pluginId) { diff --git a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java index b5906a0e9c00f..c93f39902e533 100644 --- a/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java +++ b/distribution/tools/plugin-cli/src/test/java/org/elasticsearch/plugins/InstallPluginCommandTests.java @@ -937,7 +937,7 @@ public void assertInstallPluginFromUrl( public void testOfficialPlugin() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false); } @@ -946,7 +946,7 @@ public void testOfficialPluginSnapshot() throws Exception { Locale.ROOT, "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s.zip", Version.CURRENT, - Build.CURRENT.getVersion()); + Build.CURRENT.getQualifiedVersion()); assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true); } @@ -955,7 +955,7 @@ public void testInstallReleaseBuildOfPluginOnSnapshotBuild() { Locale.ROOT, "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s.zip", Version.CURRENT, - Build.CURRENT.getVersion()); + Build.CURRENT.getQualifiedVersion()); // attemping to install a release build of a plugin (no staging ID) on a snapshot build should throw a user exception final UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, true)); @@ -966,13 +966,13 @@ public void testInstallReleaseBuildOfPluginOnSnapshotBuild() { public void testOfficialPluginStaging() throws Exception { String url = "https://staging.elastic.co/" + Version.CURRENT + "-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" - + Build.CURRENT.getVersion() + ".zip"; + + Build.CURRENT.getQualifiedVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", false); } public void testOfficialPlatformPlugin() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + Platforms.PLATFORM_NAME + - "-" + Build.CURRENT.getVersion() + ".zip"; + "-" + Build.CURRENT.getQualifiedVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false); } @@ -982,13 +982,13 @@ public void testOfficialPlatformPluginSnapshot() throws Exception { "https://snapshots.elastic.co/%s-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-%s-%s.zip", Version.CURRENT, Platforms.PLATFORM_NAME, - Build.CURRENT.getVersion()); + Build.CURRENT.getQualifiedVersion()); assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", true); } public void testOfficialPlatformPluginStaging() throws Exception { String url = "https://staging.elastic.co/" + Version.CURRENT + "-abc123/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" - + Platforms.PLATFORM_NAME + "-"+ Build.CURRENT.getVersion() + ".zip"; + + Platforms.PLATFORM_NAME + "-"+ Build.CURRENT.getQualifiedVersion() + ".zip"; assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, "abc123", false); } @@ -1011,7 +1011,7 @@ public void testMavenSha1Backcompat() throws Exception { public void testOfficialShaMissing() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-1"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl("analysis-icu", "analysis-icu", url, null, false, @@ -1032,7 +1032,7 @@ public void testMavenShaMissing() throws Exception { public void testInvalidShaFileMissingFilename() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1043,7 +1043,7 @@ public void testInvalidShaFileMissingFilename() throws Exception { public void testInvalidShaFileMismatchFilename() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion()+ ".zip"; + Build.CURRENT.getQualifiedVersion()+ ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1053,7 +1053,7 @@ public void testInvalidShaFileMismatchFilename() throws Exception { null, false, ".sha512", - checksumAndString(digest, " repository-s3-" + Build.CURRENT.getVersion() + ".zip"), + checksumAndString(digest, " repository-s3-" + Build.CURRENT.getQualifiedVersion() + ".zip"), null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1062,7 +1062,7 @@ public void testInvalidShaFileMismatchFilename() throws Exception { public void testInvalidShaFileContainingExtraLine() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; MessageDigest digest = MessageDigest.getInstance("SHA-512"); UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( @@ -1072,7 +1072,7 @@ public void testInvalidShaFileContainingExtraLine() throws Exception { null, false, ".sha512", - checksumAndString(digest, " analysis-icu-" + Build.CURRENT.getVersion() + ".zip\nfoobar"), + checksumAndString(digest, " analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip\nfoobar"), null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1081,7 +1081,7 @@ public void testInvalidShaFileContainingExtraLine() throws Exception { public void testSha512Mismatch() throws Exception { String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/analysis-icu-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; UserException e = expectThrows(UserException.class, () -> assertInstallPluginFromUrl( "analysis-icu", @@ -1090,7 +1090,7 @@ public void testSha512Mismatch() throws Exception { null, false, ".sha512", - bytes -> "foobar analysis-icu-" + Build.CURRENT.getVersion() + ".zip", + bytes -> "foobar analysis-icu-" + Build.CURRENT.getQualifiedVersion() + ".zip", null, (b, p) -> null)); assertEquals(ExitCodes.IO_ERROR, e.exitCode); @@ -1110,7 +1110,7 @@ public void testPublicKeyIdMismatchToExpectedPublicKeyId() throws Exception { final String icu = "analysis-icu"; final String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; final MessageDigest digest = MessageDigest.getInstance("SHA-512"); /* * To setup a situation where the expected public key ID does not match the public key ID used for signing, we generate a new public @@ -1134,7 +1134,7 @@ public void testFailedSignatureVerification() throws Exception { final String icu = "analysis-icu"; final String url = "https://artifacts.elastic.co/downloads/elasticsearch-plugins/analysis-icu/" + icu + "-" + - Build.CURRENT.getVersion() + ".zip"; + Build.CURRENT.getQualifiedVersion() + ".zip"; final MessageDigest digest = MessageDigest.getInstance("SHA-512"); /* * To setup a situation where signature verification fails, we will mutate the input byte array by modifying a single byte to some diff --git a/docs/reference/cat/plugins.asciidoc b/docs/reference/cat/plugins.asciidoc index 8efe01d71022e..23b33dcf07002 100644 --- a/docs/reference/cat/plugins.asciidoc +++ b/docs/reference/cat/plugins.asciidoc @@ -14,24 +14,24 @@ Might look like: ["source","txt",subs="attributes,callouts"] ------------------------------------------------------------------------------ name component version description -U7321H6 analysis-icu {build_version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. -U7321H6 analysis-kuromoji {build_version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. -U7321H6 analysis-nori {build_version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. -U7321H6 analysis-phonetic {build_version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. -U7321H6 analysis-smartcn {build_version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. -U7321H6 analysis-stempel {build_version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. -U7321H6 analysis-ukrainian {build_version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. -U7321H6 discovery-azure-classic {build_version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism -U7321H6 discovery-ec2 {build_version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. -U7321H6 discovery-gce {build_version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. -U7321H6 ingest-attachment {build_version} Ingest processor that uses Apache Tika to extract contents -U7321H6 ingest-geoip {build_version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database -U7321H6 ingest-user-agent {build_version} Ingest processor that extracts information from a user agent -U7321H6 mapper-annotated-text {build_version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. -U7321H6 mapper-murmur3 {build_version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. -U7321H6 mapper-size {build_version} The Mapper Size plugin allows document to record their uncompressed size at index time. -U7321H6 store-smb {build_version} The Store SMB plugin adds support for SMB stores. -U7321H6 transport-nio {build_version} The nio transport. +U7321H6 analysis-icu {qualified_version} The ICU Analysis plugin integrates Lucene ICU module into elasticsearch, adding ICU relates analysis components. +U7321H6 analysis-kuromoji {qualified_version} The Japanese (kuromoji) Analysis plugin integrates Lucene kuromoji analysis module into elasticsearch. +U7321H6 analysis-nori {qualified_version} The Korean (nori) Analysis plugin integrates Lucene nori analysis module into elasticsearch. +U7321H6 analysis-phonetic {qualified_version} The Phonetic Analysis plugin integrates phonetic token filter analysis with elasticsearch. +U7321H6 analysis-smartcn {qualified_version} Smart Chinese Analysis plugin integrates Lucene Smart Chinese analysis module into elasticsearch. +U7321H6 analysis-stempel {qualified_version} The Stempel (Polish) Analysis plugin integrates Lucene stempel (polish) analysis module into elasticsearch. +U7321H6 analysis-ukrainian {qualified_version} The Ukrainian Analysis plugin integrates the Lucene UkrainianMorfologikAnalyzer into elasticsearch. +U7321H6 discovery-azure-classic {qualified_version} The Azure Classic Discovery plugin allows to use Azure Classic API for the unicast discovery mechanism +U7321H6 discovery-ec2 {qualified_version} The EC2 discovery plugin allows to use AWS API for the unicast discovery mechanism. +U7321H6 discovery-gce {qualified_version} The Google Compute Engine (GCE) Discovery plugin allows to use GCE API for the unicast discovery mechanism. +U7321H6 ingest-attachment {qualified_version} Ingest processor that uses Apache Tika to extract contents +U7321H6 ingest-geoip {qualified_version} Ingest processor that uses looksup geo data based on ip adresses using the Maxmind geo database +U7321H6 ingest-user-agent {qualified_version} Ingest processor that extracts information from a user agent +U7321H6 mapper-annotated-text {qualified_version} The Mapper Annotated_text plugin adds support for text fields with markup used to inject annotation tokens into the index. +U7321H6 mapper-murmur3 {qualified_version} The Mapper Murmur3 plugin allows to compute hashes of a field's values at index-time and to store them in the index. +U7321H6 mapper-size {qualified_version} The Mapper Size plugin allows document to record their uncompressed size at index time. +U7321H6 store-smb {qualified_version} The Store SMB plugin adds support for SMB stores. +U7321H6 transport-nio {qualified_version} The nio transport. ------------------------------------------------------------------------------ // TESTRESPONSE[s/([.()])/\\$1/ s/U7321H6/.+/ _cat] diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index 304c59f644f34..1b265fb61c3aa 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -228,7 +228,7 @@ public static Build readBuild(StreamInput in) throws IOException { if (in.getVersion().onOrAfter(Version.V_7_0_0)) { version = in.readString(); } else { - version = "Unknown"; + version = in.getVersion().toString(); } return new Build(flavor, type, hash, date, snapshot, version); } @@ -244,11 +244,11 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException out.writeString(build.date()); out.writeBoolean(build.isSnapshot()); if (out.getVersion().onOrAfter(Version.V_7_0_0)) { - out.writeString(build.getVersion()); + out.writeString(build.getQualifiedVersion()); } } - public String getVersion() { + public String getQualifiedVersion() { return version; } diff --git a/server/src/main/java/org/elasticsearch/Version.java b/server/src/main/java/org/elasticsearch/Version.java index d80c01f1ecb43..f6ef5ccc97a11 100644 --- a/server/src/main/java/org/elasticsearch/Version.java +++ b/server/src/main/java/org/elasticsearch/Version.java @@ -390,7 +390,7 @@ public static void main(String[] args) { final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s/%s/%s, JVM: %s", - Build.CURRENT.getVersion(), + Build.CURRENT.getQualifiedVersion(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), Build.CURRENT.shortHash(), diff --git a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java index 306e51b08cdac..3f8ab6856e846 100644 --- a/server/src/main/java/org/elasticsearch/action/main/MainResponse.java +++ b/server/src/main/java/org/elasticsearch/action/main/MainResponse.java @@ -113,7 +113,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws .field("build_hash", build.shortHash()) .field("build_date", build.date()) .field("build_snapshot", build.isSnapshot()) - .field("build_version", build.getVersion()) + .field("build_version", build.getQualifiedVersion()) .field("lucene_version", version.luceneVersion.toString()) .field("minimum_wire_compatibility_version", version.minimumCompatibilityVersion().toString()) .field("minimum_index_compatibility_version", version.minimumIndexCompatibilityVersion().toString()) diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index 1d331e05ba515..45803b98774a6 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -101,7 +101,7 @@ protected void execute(Terminal terminal, OptionSet options, Environment env) th final String versionOutput = String.format( Locale.ROOT, "Version: %s, Build: %s/%s/%s/%s, JVM: %s", - Build.CURRENT.getVersion(), + Build.CURRENT.getQualifiedVersion(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), Build.CURRENT.shortHash(), diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 3f7d8ead39655..1b82b6b80b8da 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -278,7 +278,7 @@ protected Node( final JvmInfo jvmInfo = JvmInfo.jvmInfo(); logger.info( "version[{}], pid[{}], build[{}/{}/{}/{}], OS[{}/{}/{}], JVM[{}/{}/{}/{}]", - Build.CURRENT.getVersion(), + Build.CURRENT.getQualifiedVersion(), jvmInfo.pid(), Build.CURRENT.flavor().displayName(), Build.CURRENT.type().displayName(), @@ -580,7 +580,7 @@ static void warnIfPreRelease(final Build build,final Logger logger) { if (build.isProductionRelease() == false) { logger.warn( "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", - Build.CURRENT.getVersion()); + Build.CURRENT.getQualifiedVersion()); } } diff --git a/server/src/test/java/org/elasticsearch/BuildTests.java b/server/src/test/java/org/elasticsearch/BuildTests.java index a5bbb6fe97b0e..04119bbc0f07a 100644 --- a/server/src/test/java/org/elasticsearch/BuildTests.java +++ b/server/src/test/java/org/elasticsearch/BuildTests.java @@ -46,7 +46,7 @@ public void testIsProduction() { Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), Build.CURRENT.isSnapshot(), Math.abs(randomInt()) + "." + Math.abs(randomInt()) + "." + Math.abs(randomInt()) ); - assertTrue(build.getVersion(), build.isProductionRelease()); + assertTrue(build.getQualifiedVersion(), build.isProductionRelease()); assertFalse(new Build( Build.CURRENT.flavor(), Build.CURRENT.type(), Build.CURRENT.shortHash(), Build.CURRENT.date(), @@ -73,7 +73,7 @@ public void testEqualsAndHashCode() { Build build = Build.CURRENT; Build another = new Build( - build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + build.flavor(), build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getQualifiedVersion() ); assertEquals(build, another); assertEquals(build.hashCode(), another.hashCode()); @@ -82,7 +82,7 @@ public void testEqualsAndHashCode() { Arrays.stream(Build.Flavor.values()).filter(f -> !f.equals(build.flavor())).collect(Collectors.toSet()); final Build.Flavor otherFlavor = randomFrom(otherFlavors); Build differentFlavor = new Build( - otherFlavor, build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + otherFlavor, build.type(), build.shortHash(), build.date(), build.isSnapshot(), build.getQualifiedVersion() ); assertNotEquals(build, differentFlavor); @@ -90,23 +90,23 @@ public void testEqualsAndHashCode() { Arrays.stream(Build.Type.values()).filter(f -> !f.equals(build.type())).collect(Collectors.toSet()); final Build.Type otherType = randomFrom(otherTypes); Build differentType = new Build( - build.flavor(), otherType, build.shortHash(), build.date(), build.isSnapshot(), build.getVersion() + build.flavor(), otherType, build.shortHash(), build.date(), build.isSnapshot(), build.getQualifiedVersion() ); assertNotEquals(build, differentType); Build differentHash = new Build( build.flavor(), build.type(), randomAlphaOfLengthBetween(3, 10), build.date(), build.isSnapshot(), - build.getVersion() + build.getQualifiedVersion() ); assertNotEquals(build, differentHash); Build differentDate = new Build( - build.flavor(), build.type(), build.shortHash(), "1970-01-01", build.isSnapshot(), build.getVersion() + build.flavor(), build.type(), build.shortHash(), "1970-01-01", build.isSnapshot(), build.getQualifiedVersion() ); assertNotEquals(build, differentDate); Build differentSnapshot = new Build( - build.flavor(), build.type(), build.shortHash(), build.date(), !build.isSnapshot(), build.getVersion() + build.flavor(), build.type(), build.shortHash(), build.date(), !build.isSnapshot(), build.getQualifiedVersion() ); assertNotEquals(build, differentSnapshot); diff --git a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java index f2d7af478c484..2572fad3a5721 100644 --- a/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java +++ b/server/src/test/java/org/elasticsearch/action/main/MainResponseTests.java @@ -64,7 +64,7 @@ public void testToXContent() throws IOException { final Build current = Build.CURRENT; Build build = new Build( current.flavor(), current.type(), current.shortHash(), current.date(), current.isSnapshot(), - current.getVersion() + current.getQualifiedVersion() ); Version version = Version.CURRENT; MainResponse response = new MainResponse("nodeName", version, new ClusterName("clusterName"), clusterUUID, build); @@ -81,7 +81,7 @@ public void testToXContent() throws IOException { + "\"build_hash\":\"" + current.shortHash() + "\"," + "\"build_date\":\"" + current.date() + "\"," + "\"build_snapshot\":" + current.isSnapshot() + "," - + "\"build_version\":\"" + current.getVersion() + "\"," + + "\"build_version\":\"" + current.getQualifiedVersion() + "\"," + "\"lucene_version\":\"" + version.luceneVersion.toString() + "\"," + "\"minimum_wire_compatibility_version\":\"" + version.minimumCompatibilityVersion().toString() + "\"," + "\"minimum_index_compatibility_version\":\"" + version.minimumIndexCompatibilityVersion().toString() + "\"}," @@ -107,7 +107,7 @@ protected MainResponse mutateInstance(MainResponse mutateInstance) { // toggle the snapshot flag of the original Build parameter build = new Build( Build.Flavor.UNKNOWN, Build.Type.UNKNOWN, build.shortHash(), build.date(), !build.isSnapshot(), - build.getVersion() + build.getQualifiedVersion() ); break; case 3: diff --git a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java index e473c1a495319..f59584bb90cc5 100644 --- a/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java +++ b/server/src/test/java/org/elasticsearch/bootstrap/ElasticsearchCliTests.java @@ -62,7 +62,7 @@ private void runTestThatVersionIsMutuallyExclusiveToOtherOptions(String... args) private void runTestThatVersionIsReturned(String... args) throws Exception { runTestVersion(ExitCodes.OK, output -> { - assertThat(output, containsString("Version: " + Build.CURRENT.getVersion())); + assertThat(output, containsString("Version: " + Build.CURRENT.getQualifiedVersion())); final String expectedBuildOutput = String.format( Locale.ROOT, "Build: %s/%s/%s/%s", From b14bb39c0bd88821dd25613cb522de69fa919708 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Tue, 6 Nov 2018 13:07:47 +0200 Subject: [PATCH 20/21] Fix doc tests --- docs/plugins/discovery-azure-classic.asciidoc | 2 +- docs/reference/setup/install/check-running.asciidoc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/plugins/discovery-azure-classic.asciidoc b/docs/plugins/discovery-azure-classic.asciidoc index d52a4efe4678c..5f655cd48d4a7 100644 --- a/docs/plugins/discovery-azure-classic.asciidoc +++ b/docs/plugins/discovery-azure-classic.asciidoc @@ -377,7 +377,7 @@ This command should give you a JSON result: "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, - "build_version" : "{build_version}", + "build_version" : "{qualified_version}", "lucene_version" : "{lucene_version}", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" diff --git a/docs/reference/setup/install/check-running.asciidoc b/docs/reference/setup/install/check-running.asciidoc index b5df20fc0564e..992cc7498fdde 100644 --- a/docs/reference/setup/install/check-running.asciidoc +++ b/docs/reference/setup/install/check-running.asciidoc @@ -24,7 +24,7 @@ which should give you a response something like this: "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, - "build_version" : "{build_version}", + "build_version" : "{qualified_version}", "lucene_version" : "{lucene_version}", "minimum_wire_compatibility_version" : "1.2.3", "minimum_index_compatibility_version" : "1.2.3" From 69559511dc3cfc902fca05592bdead269c447ac6 Mon Sep 17 00:00:00 2001 From: Alpar Torok Date: Wed, 7 Nov 2018 07:36:32 +0200 Subject: [PATCH 21/21] PR review --- qa/wildfly/build.gradle | 2 +- .../java/org/elasticsearch/wildfly/WildflyIT.java | 2 +- server/src/main/java/org/elasticsearch/Build.java | 14 ++++++++++++++ .../elasticsearch/bootstrap/Elasticsearch.java | 15 ++++++++------- .../main/java/org/elasticsearch/node/Node.java | 14 +++++--------- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/qa/wildfly/build.gradle b/qa/wildfly/build.gradle index 98111f6393dc2..c967d4139d48a 100644 --- a/qa/wildfly/build.gradle +++ b/qa/wildfly/build.gradle @@ -129,7 +129,7 @@ task startWildfly { assert index >= 0 httpPort = Integer.parseInt(line.substring(index + 1)) // set this system property so the test runner knows the port Wildfly is listening for HTTP requests on - integTestRunner.systemProperty("tests.jboss.home", "http://localhost:$httpPort/wildfly-$version/transport") + integTestRunner.systemProperty("tests.jboss.root", "http://localhost:$httpPort/wildfly-$version/transport") } else if (line.matches('.*Http management interface listening on http://.*:\\d+/management$')) { assert managementPort == 0 final int colonIndex = line.lastIndexOf(":") diff --git a/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java b/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java index b77e6c92cba2c..9aebffdc4ce3f 100644 --- a/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java +++ b/qa/wildfly/src/test/java/org/elasticsearch/wildfly/WildflyIT.java @@ -60,7 +60,7 @@ public void testTransportClient() throws URISyntaxException, IOException { final String str = String.format( Locale.ROOT, "%s/employees/1", - System.getProperty("tests.jboss.home") + System.getProperty("tests.jboss.root") ); logger.info("Connecting to uri: " + str); final HttpPut put = new HttpPut(new URI(str)); diff --git a/server/src/main/java/org/elasticsearch/Build.java b/server/src/main/java/org/elasticsearch/Build.java index 1b265fb61c3aa..706d5095dee2c 100644 --- a/server/src/main/java/org/elasticsearch/Build.java +++ b/server/src/main/java/org/elasticsearch/Build.java @@ -248,6 +248,15 @@ public static void writeBuild(Build build, StreamOutput out) throws IOException } } + /** + * Get the version as considered at build time + * + * Offers a way to get the fully qualified version as configured by the build. + * This will be the same as {@link Version} for production releases, but may include on of the qualifier ( e.x alpha1 ) + * or -SNAPSHOT for others. + * + * @return the fully qualified build + */ public String getQualifiedVersion() { return version; } @@ -264,6 +273,11 @@ public boolean isSnapshot() { return isSnapshot; } + /** + * Provides information about the intent of the build + * + * @return true if the build is intended for production use + */ public boolean isProductionRelease() { return version.matches("[0-9]+\\.[0-9]+\\.[0-9]+"); } diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index 45803b98774a6..1cf88c6245fa4 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -99,14 +99,15 @@ protected void execute(Terminal terminal, OptionSet options, Environment env) th } if (options.has(versionOption)) { final String versionOutput = String.format( - Locale.ROOT, - "Version: %s, Build: %s/%s/%s/%s, JVM: %s", + Locale.ROOT, + "Version: %s, Build: %s/%s/%s/%s, JVM: %s", Build.CURRENT.getQualifiedVersion(), - Build.CURRENT.flavor().displayName(), - Build.CURRENT.type().displayName(), - Build.CURRENT.shortHash(), - Build.CURRENT.date(), - JvmInfo.jvmInfo().version()); + Build.CURRENT.flavor().displayName(), + Build.CURRENT.type().displayName(), + Build.CURRENT.shortHash(), + Build.CURRENT.date(), + JvmInfo.jvmInfo().version() + ); terminal.println(versionOutput); return; } diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index 1b82b6b80b8da..3546e770c99df 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -292,7 +292,11 @@ protected Node( Constants.JAVA_VERSION, Constants.JVM_VERSION); logger.info("JVM arguments {}", Arrays.toString(jvmInfo.getInputArguments())); - warnIfPreRelease(Build.CURRENT, logger); + if (Build.CURRENT.isProductionRelease() == false) { + logger.warn( + "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", + Build.CURRENT.getQualifiedVersion()); + } if (logger.isDebugEnabled()) { logger.debug("using config [{}], data [{}], logs [{}], plugins [{}]", @@ -576,14 +580,6 @@ protected Node( } } - static void warnIfPreRelease(final Build build,final Logger logger) { - if (build.isProductionRelease() == false) { - logger.warn( - "version [{}] is a pre-release version of Elasticsearch and is not suitable for production", - Build.CURRENT.getQualifiedVersion()); - } - } - protected TransportService newTransportService(Settings settings, Transport transport, ThreadPool threadPool, TransportInterceptor interceptor, Function localNodeFactory,