From 09dd03e19f8724c3e26bd35c6d0c411449e75562 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Sat, 27 May 2017 15:46:16 -0400 Subject: [PATCH] Verify Lucene version constants The Lucene version constants for 5.4.1 and 5.5.0 are wrong, they are listed as 6.5.0 instead of 6.5.1. This commit fixes these issues, and adds a test to ensure that this does not happen again. Relates #24923 --- .../main/java/org/elasticsearch/Version.java | 4 +- .../upgrades/FullClusterRestartIT.java | 2 +- qa/verify-version-constants/build.gradle | 61 +++++++++++++++++++ .../VerifyVersionConstantsIT.java | 45 ++++++++++++++ settings.gradle | 1 + 5 files changed, 110 insertions(+), 3 deletions(-) create mode 100644 qa/verify-version-constants/build.gradle create mode 100644 qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java diff --git a/core/src/main/java/org/elasticsearch/Version.java b/core/src/main/java/org/elasticsearch/Version.java index a9a63b151a3..c6939756816 100644 --- a/core/src/main/java/org/elasticsearch/Version.java +++ b/core/src/main/java/org/elasticsearch/Version.java @@ -75,9 +75,9 @@ public class Version implements Comparable { public static final int V_5_4_0_ID = 5040099; public static final Version V_5_4_0 = new Version(V_5_4_0_ID, org.apache.lucene.util.Version.LUCENE_6_5_0); public static final int V_5_4_1_ID = 5040199; - public static final Version V_5_4_1 = new Version(V_5_4_1_ID, org.apache.lucene.util.Version.LUCENE_6_5_0); + public static final Version V_5_4_1 = new Version(V_5_4_1_ID, org.apache.lucene.util.Version.LUCENE_6_5_1); public static final int V_5_5_0_ID = 5050099; - public static final Version V_5_5_0 = new Version(V_5_5_0_ID, org.apache.lucene.util.Version.LUCENE_6_5_0); + public static final Version V_5_5_0 = new Version(V_5_5_0_ID, org.apache.lucene.util.Version.LUCENE_6_5_1); public static final int V_6_0_0_alpha1_ID = 6000001; public static final Version V_6_0_0_alpha1 = new Version(V_6_0_0_alpha1_ID, org.apache.lucene.util.Version.LUCENE_7_0_0); diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index 93c544f2658..ae901c308d5 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -224,7 +224,7 @@ public class FullClusterRestartIT extends ESRestTestCase { } else if (bwcLuceneVersion.equals(version)) { numBwcVersion++; } else { - fail("expected version to be one of [" + currentLuceneVersion + "," + bwcLuceneVersion + "] but was" + line); + fail("expected version to be one of [" + currentLuceneVersion + "," + bwcLuceneVersion + "] but was " + line); } } assertNotEquals("expected at least 1 current segment after translog recovery", 0, numCurrentVersion); diff --git a/qa/verify-version-constants/build.gradle b/qa/verify-version-constants/build.gradle new file mode 100644 index 00000000000..d3b0f7f99cf --- /dev/null +++ b/qa/verify-version-constants/build.gradle @@ -0,0 +1,61 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.elasticsearch.gradle.Version +import org.elasticsearch.gradle.test.RestIntegTestTask + +apply plugin: 'elasticsearch.standalone-test' + +// This is a top level task which we will add dependencies to below. +// It is a single task that can be used to backcompat tests against all versions. +task bwcTest { + description = 'Runs backwards compatibility tests.' + group = 'verification' +} + +for (Version version : indexCompatVersions) { + String baseName = "v${version}" + Task oldClusterTest = tasks.create(name: "${baseName}#oldClusterTest", type: RestIntegTestTask) { + mustRunAfter(precommit) + } + configure(extensions.findByName("${baseName}#oldClusterTestCluster")) { + distribution = 'zip' + bwcVersion = version + numBwcNodes = 1 + numNodes = 1 + clusterName = 'verify-version-constants' + if (version.onOrAfter('5.3.0')) { + setting 'http.content_type.required', 'true' + } + } + + Task versionBwcTest = tasks.create(name: "${baseName}#bwcTest") { + dependsOn = [oldClusterTest] + } + + bwcTest.dependsOn(versionBwcTest) +} + +test.enabled = false + +task integTest { + dependsOn = ["v${indexCompatVersions[-1]}#bwcTest"] +} + +check.dependsOn(integTest) diff --git a/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java b/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java new file mode 100644 index 00000000000..97d2d4dcc31 --- /dev/null +++ b/qa/verify-version-constants/src/test/java/org/elasticsearch/qa/verify_version_constants/VerifyVersionConstantsIT.java @@ -0,0 +1,45 @@ +/* + * Licensed to Elasticsearch under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.elasticsearch.qa.verify_version_constants; + +import org.elasticsearch.Version; +import org.elasticsearch.client.Response; +import org.elasticsearch.test.rest.ESRestTestCase; +import org.elasticsearch.test.rest.yaml.ObjectPath; + +import java.io.IOException; +import java.text.ParseException; + +import static org.hamcrest.CoreMatchers.equalTo; + +public class VerifyVersionConstantsIT extends ESRestTestCase { + + public void testLuceneVersionConstant() throws IOException, ParseException { + final Response response = client().performRequest("GET", "/"); + assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); + final ObjectPath objectPath = ObjectPath.createFromResponse(response); + final String elasticsearchVersionString = objectPath.evaluate("version.number").toString(); + final Version elasticsearchVersion = Version.fromString(elasticsearchVersionString); + final String luceneVersionString = objectPath.evaluate("version.lucene_version").toString(); + final org.apache.lucene.util.Version luceneVersion = org.apache.lucene.util.Version.parse(luceneVersionString); + assertThat(luceneVersion, equalTo(elasticsearchVersion.luceneVersion)); + } + +} diff --git a/settings.gradle b/settings.gradle index e12da9f2ebe..9fc33b59f32 100644 --- a/settings.gradle +++ b/settings.gradle @@ -77,6 +77,7 @@ List projects = [ 'qa:smoke-test-reindex-with-all-modules', 'qa:smoke-test-tribe-node', 'qa:vagrant', + 'qa:verify-version-constants', 'qa:wildfly' ]