Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-ingest-with-all-dependencies");
map.put(LegacyRestTestBasePlugin.class, ":qa:smoke-test-plugins");
map.put(LegacyRestTestBasePlugin.class, ":qa:system-indices");
map.put(LegacyRestTestBasePlugin.class, ":qa:verify-version-constants");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-apm-integration");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-delayed-aggs");
map.put(LegacyRestTestBasePlugin.class, ":test:external-modules:test-die-with-dignity");
Expand Down
27 changes: 27 additions & 0 deletions docs/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.internal.doc.DocSnippetTask
import static org.elasticsearch.gradle.testclusters.TestDistribution.DEFAULT

Expand Down Expand Up @@ -2048,3 +2049,29 @@ setups['setup-snapshots'] = setups['setup-repository'] + '''
setups['atomic_red_regsvr32'].replace('#atomic_red_data#', events)
}
}

tasks.register('verifyDocsLuceneVersion') {
doFirst {
File docsVersionsFile = file('Versions.asciidoc')
List<String> versionLines = docsVersionsFile.readLines('UTF-8')
String docsLuceneVersion = null
for (String line : versionLines) {
if (line.startsWith(':lucene_version:')) {
docsLuceneVersion = line.split()[1]
}
}
if (docsLuceneVersion == null) {
throw new GradleException('Could not find lucene version in docs version file')
}
String expectedLuceneVersion = VersionProperties.lucene
// remove potential -snapshot-{gitrev} suffix
expectedLuceneVersion -= ~/-snapshot-[0-9a-f]+$/
if (docsLuceneVersion != expectedLuceneVersion) {
throw new GradleException("Lucene version in docs [${docsLuceneVersion}] does not match version.properties [${expectedLuceneVersion}]")
}
}
}

tasks.named('check') {
dependsOn 'verifyDocsLuceneVersion'
}
52 changes: 4 additions & 48 deletions qa/verify-version-constants/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,14 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import org.elasticsearch.gradle.VersionProperties
import org.elasticsearch.gradle.internal.info.BuildParams
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-testclusters'
apply plugin: 'elasticsearch.standalone-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.bwc-test'

dependencies {
testImplementation project(':modules:rest-root')
}

buildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName ->
def baseCluster = testClusters.register(baseName) {
version = bwcVersion.toString()
setting 'xpack.security.enabled', 'true'
user username: 'admin', password: 'admin-password', role: 'superuser'
}

tasks.register("${baseName}#integTest", StandaloneRestIntegTestTask) {
useCluster baseCluster
nonInputProperties.systemProperty('tests.rest.cluster', baseCluster.map(c -> c.allHttpSocketURI.join(",")))
nonInputProperties.systemProperty('tests.clustername', "${->baseCluster.get().getName()}")
}

tasks.register(bwcTaskName(bwcVersion)) {
dependsOn "${baseName}#integTest"
tasks.register(bwcTaskName(bwcVersion), StandaloneRestIntegTestTask) {
usesBwcDistribution(bwcVersion)
systemProperty 'tests.cluster_version', bwcVersion
}
}

tasks.register("verifyDocsLuceneVersion") {
doFirst {
File docsVersionsFile = layout.settingsDirectory.file('docs/Versions.asciidoc').asFile
List<String> versionLines = docsVersionsFile.readLines('UTF-8')
String docsLuceneVersion = null
for (String line : versionLines) {
if (line.startsWith(':lucene_version:')) {
docsLuceneVersion = line.split()[1]
}
}
if (docsLuceneVersion == null) {
throw new GradleException('Could not find lucene version in docs version file')
}
String expectedLuceneVersion = VersionProperties.lucene
// remove potential -snapshot-{gitrev} suffix
expectedLuceneVersion -= ~/-snapshot-[0-9a-f]+$/
if (docsLuceneVersion != expectedLuceneVersion) {
throw new GradleException("Lucene version in docs [${docsLuceneVersion}] does not match version.properties [${expectedLuceneVersion}]")
}
}
}

tasks.named("check").configure {
dependsOn "verifyDocsLuceneVersion"
}
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
Expand Up @@ -69,12 +69,14 @@ private static IndexVersion def(int id, Version luceneVersion) {
public static final IndexVersion V_7_15_0 = def(7_15_00_99, Version.LUCENE_8_9_0);
public static final IndexVersion V_7_16_0 = def(7_16_00_99, Version.LUCENE_8_10_1);
public static final IndexVersion V_7_17_0 = def(7_17_00_99, Version.LUCENE_8_11_1);
public static final IndexVersion V_7_17_19 = def(7_17_19_99, Version.LUCENE_8_11_3);
public static final IndexVersion V_8_0_0 = def(8_00_00_99, Version.LUCENE_9_0_0);
public static final IndexVersion V_8_1_0 = def(8_01_00_99, Version.LUCENE_9_0_0);
public static final IndexVersion V_8_2_0 = def(8_02_00_99, Version.LUCENE_9_1_0);
public static final IndexVersion V_8_3_0 = def(8_03_00_99, Version.LUCENE_9_2_0);
public static final IndexVersion V_8_4_0 = def(8_04_00_99, Version.LUCENE_9_3_0);
public static final IndexVersion V_8_5_0 = def(8_05_00_99, Version.LUCENE_9_4_1);
public static final IndexVersion V_8_5_3 = def(8_05_03_99, Version.LUCENE_9_4_2);
public static final IndexVersion V_8_6_0 = def(8_06_00_99, Version.LUCENE_9_4_2);
public static final IndexVersion V_8_7_0 = def(8_07_00_99, Version.LUCENE_9_5_0);
public static final IndexVersion V_8_8_0 = def(8_08_00_99, Version.LUCENE_9_6_0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ public T version(Version version) {
return cast(this);
}

@Override
public T version(String version) {
this.version = Version.fromString(version);
return cast(this);
}

public Version getVersion() {
return inherit(() -> parent.getVersion(), version);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ interface LocalSpecBuilder<T extends LocalSpecBuilder<?>> {
*/
T version(Version version);

/**
* Sets the version of Elasticsearch. Defaults to {@link Version#CURRENT}.
*/
T version(String version);

/**
* Adds a system property to node JVM arguments.
*/
Expand Down