浏览代码

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
Jason Tedor 8 年之前
父节点
当前提交
09dd03e19f

+ 2 - 2
core/src/main/java/org/elasticsearch/Version.java

@@ -75,9 +75,9 @@ public class Version implements Comparable<Version> {
     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);

+ 1 - 1
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);

+ 61 - 0
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)

+ 45 - 0
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));
+    }
+
+}

+ 1 - 0
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'
 ]