Skip to content

Add lucene version compatibility tests #121104

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

Merged
merged 6 commits into from
Jan 29, 2025
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
21 changes: 21 additions & 0 deletions .buildkite/pipelines/intake.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,27 @@ steps:
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: "{{matrix.BWC_VERSION}}"
- group: lucene-compat
steps:
- label: "{{matrix.LUCENE_VERSION}} / lucene-compat"
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=$$ES_VERSION -Dtests.bwc.refspec.main=$$ES_COMMIT luceneBwcTest
timeout_in_minutes: 300
matrix:
setup:
LUCENE_VERSION:
- "10.0.0"
ES_VERSION:
- "9.0.0"
ES_COMMIT:
- "b2cc9d9b8f00ee621f93ddca07ea9c671aab1578" # update to match last commit before lucene bump
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we wanna coordinate on this commit hash, or just go with what is here and update it after the Lucene 10.1.0 upgrade has been merged?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tying testing to a specific commit is ok, yet I wonder if it would be possible in the future to tie to index version changes. I think that besides codec changes, we are totally lacking test coverage for index version changes that we make. And a codec change implies an index version change.

Copy link
Contributor Author

@mark-vieira mark-vieira Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have to know what hash to checkout. So if we do based on index version we still have to have some mapping of version -> commit somewhere.

agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: custom-32-98304
buildDirectory: /dev/shm/bk
env:
ES_VERSION: "{{matrix.ES_VERSION}}"
ES_COMMIT: "{{matrix.ES_COMMIT}}"
- label: rest-compat
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints checkRestCompat
timeout_in_minutes: 300
Expand Down
21 changes: 21 additions & 0 deletions .buildkite/pipelines/intake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,27 @@ steps:
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: "{{matrix.BWC_VERSION}}"
- group: lucene-compat
steps:
- label: "{{matrix.LUCENE_VERSION}} / lucene-compat"
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=$$ES_VERSION -Dtests.bwc.refspec.main=$$ES_COMMIT luceneBwcTest
timeout_in_minutes: 300
matrix:
setup:
LUCENE_VERSION:
- "10.0.0"
ES_VERSION:
- "9.0.0"
ES_COMMIT:
- "b2cc9d9b8f00ee621f93ddca07ea9c671aab1578" # update to match last commit before lucene bump
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: custom-32-98304
buildDirectory: /dev/shm/bk
env:
ES_VERSION: "{{matrix.ES_VERSION}}"
ES_COMMIT: "{{matrix.ES_COMMIT}}"
- label: rest-compat
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints checkRestCompat
timeout_in_minutes: 300
Expand Down
21 changes: 21 additions & 0 deletions .buildkite/pipelines/periodic.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,27 @@ steps:
image: family/elasticsearch-ubuntu-2004
machineType: n2-standard-8
buildDirectory: /dev/shm/bk
- group: lucene-compat
steps:
- label: "{{matrix.LUCENE_VERSION}} / lucene-compat"
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=$$ES_VERSION -Dtests.bwc.refspec.main=$$ES_COMMIT luceneBwcTest
timeout_in_minutes: 300
matrix:
setup:
LUCENE_VERSION:
- "10.0.0"
ES_VERSION:
- "9.0.0"
ES_COMMIT:
- "b2cc9d9b8f00ee621f93ddca07ea9c671aab1578" # update to match last commit before lucene bump
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: custom-32-98304
buildDirectory: /dev/shm/bk
env:
ES_VERSION: "{{matrix.ES_VERSION}}"
ES_COMMIT: "{{matrix.ES_COMMIT}}"
- label: Upload Snyk Dependency Graph
command: .ci/scripts/run-gradle.sh uploadSnykDependencyGraph -PsnykTargetReference=$BUILDKITE_BRANCH
env:
Expand Down
21 changes: 21 additions & 0 deletions .buildkite/pipelines/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,27 @@ steps:
image: family/elasticsearch-ubuntu-2004
machineType: n2-standard-8
buildDirectory: /dev/shm/bk
- group: lucene-compat
steps:
- label: "{{matrix.LUCENE_VERSION}} / lucene-compat"
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true -Dorg.elasticsearch.build.cache.push=true -Dignore.tests.seed -Dscan.capture-file-fingerprints -Dtests.bwc.main.version=$$ES_VERSION -Dtests.bwc.refspec.main=$$ES_COMMIT luceneBwcTest
timeout_in_minutes: 300
matrix:
setup:
LUCENE_VERSION:
- "10.0.0"
ES_VERSION:
- "9.0.0"
ES_COMMIT:
- "b2cc9d9b8f00ee621f93ddca07ea9c671aab1578" # update to match last commit before lucene bump
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
machineType: custom-32-98304
buildDirectory: /dev/shm/bk
env:
ES_VERSION: "{{matrix.ES_VERSION}}"
ES_COMMIT: "{{matrix.ES_COMMIT}}"
- label: Upload Snyk Dependency Graph
command: .ci/scripts/run-gradle.sh uploadSnykDependencyGraph -PsnykTargetReference=$BUILDKITE_BRANCH
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ public void apply(Project project) {
fileSystemOperations
);
});

// Also set up the "main" project which is just used for arbitrary overrides. See InternalDistributionDownloadPlugin.
if (System.getProperty("tests.bwc.main.version") != null) {
configureBwcProject(
project.project(":distribution:bwc:main"),
buildParams,
new BwcVersions.UnreleasedVersionInfo(
Version.fromString(System.getProperty("tests.bwc.main.version")),
"main",
":distribution:bwc:main"
),
providerFactory,
objectFactory,
toolChainService,
isCi,
fileSystemOperations
);
}
}

private static void configureBwcProject(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,29 @@ private void registerInternalDistributionResolutions(List<DistributionResolution
}
return null;
}));

// Distribution resolution for "override" versions. This allows for building from source for any version, including the current
// version of existing released versions from a commit form the main branch. This is done by passing certain system properties, ex:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, typo "... form the main branch"

//
// -Dtests.bwc.refspec.main=deadbeef -Dtests.bwc.main.version=9.0.0
//
// The 'test.bwc.main.version' property should map to the version returned by the commit referenced in 'tests.bwc.refspec.main'.
resolutions.add(new DistributionResolution("override", (project, distribution) -> {
String versionProperty = System.getProperty("tests.bwc.main.version");
// We use this phony version as a placeholder for the real version
if (distribution.getVersion().equals("0.0.0")) {
BwcVersions.UnreleasedVersionInfo unreleasedVersionInfo = new BwcVersions.UnreleasedVersionInfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to assert that versionProperty is non-null here? Or maybe it's already implied by the following fromString ?

Version.fromString(versionProperty),
"main",
":distribution:bwc:main"
);
String projectConfig = getProjectConfig(distribution, unreleasedVersionInfo);
return new ProjectBasedDistributionDependency(
(config) -> projectDependency(project.getDependencies(), unreleasedVersionInfo.gradleProjectPath(), projectConfig)
);
}
return null;
}));
}

private boolean isCurrentVersion(ElasticsearchDistribution distribution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public Void call(Object... args) {
}

Version version = (Version) args[0];
boolean isReleased = bwcVersions.unreleasedInfo(version) == null;
boolean isReleased = bwcVersions.unreleasedInfo(version) == null && version.toString().equals("0.0.0") == false;
String versionString = version.toString();
ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;

import javax.inject.Inject;

Expand Down Expand Up @@ -141,8 +143,9 @@ private void registerDistributionDependencies(Project project, ElasticsearchDist

private DistributionDependency resolveDependencyNotation(Project project, ElasticsearchDistribution distro) {
return distributionsResolutionStrategies.stream()
.sorted(Comparator.comparing(DistributionResolution::getPriority).reversed())
.map(r -> r.getResolver().resolve(project, distro))
.filter(d -> d != null)
.filter(Objects::nonNull)
.findFirst()
.orElseGet(() -> DistributionDependency.of(dependencyNotation(distro)));
}
Expand Down
10 changes: 10 additions & 0 deletions distribution/bwc/main/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* 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".
*/

// This project is used only for overriding bwc distributions. See InternalDistributionDownloadPlugin for details.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus;
import org.elasticsearch.upgrades.ParameterizedFullClusterRestartTestCase;
Expand Down Expand Up @@ -54,7 +55,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas

private static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("ingest.geoip.downloader.endpoint", () -> fixture.getAddress(), s -> useFixture)
.setting("xpack.security.enabled", useSecurity ? "true" : "false")
Expand Down
8 changes: 8 additions & 0 deletions qa/full-cluster-restart/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import org.elasticsearch.gradle.Version
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask

apply plugin: 'elasticsearch.internal-java-rest-test'
Expand All @@ -20,6 +21,13 @@ buildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName ->
}
}

tasks.register("luceneBwcTest", StandaloneRestIntegTestTask) {
// We use a phony version here as the real version is provided via `tests.bwc.main.version` system property
usesBwcDistribution(Version.fromString("0.0.0"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha! this is a cute trick. Nice!

systemProperty("tests.old_cluster_version", "0.0.0")
onlyIf("tests.bwc.main.version system property exists") { System.getProperty("tests.bwc.main.version") != null }
}

tasks.withType(Test).configureEach {
// CI doesn't like it when there's multiple clusters running at once
maxParallelForks = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.rest.ObjectPath;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
Expand All @@ -44,7 +45,7 @@ public class FullClusterRestartArchivedSettingsIT extends ParameterizedFullClust

private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("path.repo", () -> repoDirectory.getRoot().getPath())
.setting("xpack.security.enabled", "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.rules.RuleChain;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class FullClusterRestartDownsampleIT extends ParameterizedFullClusterRest

private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("xpack.security.enabled", "false")
.setting("indices.lifecycle.poll_interval", "5s")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.test.rest.ObjectPath;
import org.elasticsearch.xcontent.ToXContent;
Expand Down Expand Up @@ -103,7 +104,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas

private static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("path.repo", () -> repoDirectory.getRoot().getPath())
.setting("xpack.security.enabled", "false")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.elasticsearch.common.time.FormatNames;
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.hamcrest.Matcher;
import org.hamcrest.Matchers;
import org.junit.ClassRule;
Expand All @@ -34,7 +35,7 @@ public class LogsIndexModeFullClusterRestartIT extends ParameterizedFullClusterR
@ClassRule
public static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.module("constant-keyword")
.module("data-streams")
.module("mapper-extras")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@
@TestCaseOrdering(FullClusterRestartTestOrdering.class)
public abstract class ParameterizedFullClusterRestartTestCase extends ESRestTestCase {

private static final Version MINIMUM_WIRE_COMPATIBLE_VERSION = Version.fromString(System.getProperty("tests.minimum.wire.compatible"));
private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
protected static final Version MINIMUM_WIRE_COMPATIBLE_VERSION = Version.fromString(
System.getProperty("tests.minimum.wire.compatible")
);
protected static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version");
private static IndexVersion oldIndexVersion;
private static boolean upgradeFailed = false;
private static boolean upgraded = false;
Expand Down Expand Up @@ -133,7 +135,7 @@ public boolean isRunningAgainstOldCluster() {
}

public static String getOldClusterVersion() {
return OLD_CLUSTER_VERSION;
return System.getProperty("tests.bwc.main.version", OLD_CLUSTER_VERSION);
}

protected static boolean oldClusterHasFeature(String featureId) {
Expand All @@ -152,7 +154,7 @@ public static IndexVersion getOldClusterIndexVersion() {
}

public static Version getOldClusterTestVersion() {
return Version.fromString(OLD_CLUSTER_VERSION);
return Version.fromString(System.getProperty("tests.bwc.main.version", OLD_CLUSTER_VERSION));
}

protected abstract ElasticsearchCluster getUpgradeCluster();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class QueryBuilderBWCIT extends ParameterizedFullClusterRestartTestCase {
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(org.elasticsearch.test.cluster.util.Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("xpack.security.enabled", "false")
.feature(FeatureFlag.FAILURE_STORE_ENABLED)
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ List projects = [
'distribution:bwc:maintenance',
'distribution:bwc:minor',
'distribution:bwc:staged',
'distribution:bwc:main',
'distribution:tools:java-version-checker',
'distribution:tools:cli-launcher',
'distribution:tools:server-cli',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ public DistributionDescriptor resolve(Version version, DistributionType type) {
}

// Snapshot distributions are never release builds and always use the default distribution
return new DefaultDistributionDescriptor(version, true, distributionDir, DistributionType.DEFAULT);
Version realVersion = Version.fromString(System.getProperty("tests.bwc.main.version", version.toString()));
return new DefaultDistributionDescriptor(realVersion, true, distributionDir, DistributionType.DEFAULT);
}

return delegate.resolve(version, type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
@ClassRule
public static final ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(org.elasticsearch.test.cluster.util.Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
.setting("xpack.security.enabled", "false")
.setting("xpack.license.self_generated.type", "trial")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.elasticsearch.test.cluster.ElasticsearchCluster;
import org.elasticsearch.test.cluster.FeatureFlag;
import org.elasticsearch.test.cluster.local.distribution.DistributionType;
import org.elasticsearch.test.cluster.util.Version;
import org.elasticsearch.test.cluster.util.resource.Resource;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas
@ClassRule
public static ElasticsearchCluster cluster = ElasticsearchCluster.local()
.distribution(DistributionType.DEFAULT)
.version(getOldClusterTestVersion())
.version(Version.fromString(OLD_CLUSTER_VERSION))
.nodes(2)
// some tests rely on the translog not being flushed
.setting("indices.memory.shard_inactive_time", "60m")
Expand Down
Loading