-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Re-enable VerifyVersionConstantsIT #125605
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the "Elastic License | ||
| * 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
| * Public License v 1"; you may not use this file except in compliance with, at | ||
| * your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
| * License v3.0 only", or the "Server Side Public License, v 1". | ||
| */ | ||
|
|
||
| package org.elasticsearch.qa.verify_version_constants; | ||
|
|
||
| import org.elasticsearch.client.Request; | ||
| import org.elasticsearch.client.Response; | ||
| import org.elasticsearch.index.IndexVersion; | ||
| import org.elasticsearch.index.IndexVersions; | ||
| import org.elasticsearch.test.cluster.ElasticsearchCluster; | ||
| import org.elasticsearch.test.cluster.local.distribution.DistributionType; | ||
| import org.elasticsearch.test.rest.ESRestTestCase; | ||
| import org.elasticsearch.test.rest.ObjectPath; | ||
| import org.hamcrest.Matchers; | ||
| import org.junit.ClassRule; | ||
|
|
||
| import java.io.IOException; | ||
| import java.text.ParseException; | ||
| import java.util.Map; | ||
|
|
||
| import static org.hamcrest.CoreMatchers.equalTo; | ||
| import static org.hamcrest.Matchers.notNullValue; | ||
|
|
||
| public class VerifyVersionConstantsIT extends ESRestTestCase { | ||
|
|
||
| @ClassRule | ||
| public static ElasticsearchCluster cluster = ElasticsearchCluster.local() | ||
| .distribution(DistributionType.DEFAULT) | ||
| .version(System.getProperty("tests.cluster_version")) | ||
| .setting("xpack.security.enabled", "false") | ||
| .build(); | ||
|
|
||
| public void testLuceneVersionConstant() throws IOException, ParseException { | ||
| Response response = client().performRequest(new Request("GET", "/")); | ||
| assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); | ||
| ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
|
|
||
| String luceneVersionString = objectPath.evaluate("version.lucene_version").toString(); | ||
| org.apache.lucene.util.Version luceneVersion = org.apache.lucene.util.Version.parse(luceneVersionString); | ||
|
|
||
| IndexVersion indexVersion = getIndexVersion(); | ||
| assertThat(indexVersion.luceneVersion(), equalTo(luceneVersion)); | ||
| } | ||
|
|
||
| private IndexVersion getIndexVersion() throws IOException { | ||
| IndexVersion indexVersion = null; | ||
|
|
||
| Request request = new Request("GET", "_nodes"); | ||
| request.addParameter("filter_path", "nodes.*.index_version,nodes.*.name"); | ||
| Response response = client().performRequest(request); | ||
| ObjectPath objectPath = ObjectPath.createFromResponse(response); | ||
| Map<String, Object> nodeMap = objectPath.evaluate("nodes"); | ||
| for (String id : nodeMap.keySet()) { | ||
| Number ix = objectPath.evaluate("nodes." + id + ".index_version"); | ||
| IndexVersion version; | ||
| if (ix != null) { | ||
| version = IndexVersion.fromId(ix.intValue()); | ||
| } else { | ||
| // it doesn't have index version (pre 8.11) - just infer it from the release version | ||
| version = parseLegacyVersion(System.getProperty("tests.cluster_version")).map(x -> IndexVersion.fromId(x.id())) | ||
| .orElse(IndexVersions.MINIMUM_COMPATIBLE); | ||
| } | ||
|
|
||
| if (indexVersion == null) { | ||
| indexVersion = version; | ||
| } else { | ||
| String name = objectPath.evaluate("nodes." + id + ".name"); | ||
| assertThat("Node " + name + " has a different index version to other nodes", version, Matchers.equalTo(indexVersion)); | ||
| } | ||
| } | ||
|
|
||
| assertThat("Index version could not be read", indexVersion, notNullValue()); | ||
| return indexVersion; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean preserveClusterUponCompletion() { | ||
| /* | ||
| * We don't perform any writes to the cluster so there won't be anything | ||
| * to clean up. Also, our cleanup code is really only compatible with | ||
| * *write* compatible versions but this runs with *index* compatible | ||
| * versions. | ||
| */ | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| protected String getTestRestCluster() { | ||
| return cluster.getHttpAddresses(); | ||
| } | ||
| } |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,11 @@ interface LocalSpecBuilder<T extends LocalSpecBuilder<?>> { | |
| */ | ||
| T version(Version version); | ||
|
|
||
| /** | ||
| * Sets the version of Elasticsearch. Defaults to {@link Version#CURRENT}. | ||
| */ | ||
| T version(String version); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this as a convenience as many of our tests use |
||
|
|
||
| /** | ||
| * Adds a system property to node JVM arguments. | ||
| */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got moved to the
:docsproject since it made much more sense for it to live there.