Skip to content

Commit

Permalink
Merge branch 'main' into carlosdelest/fix-synonyms-number-limit
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Jun 6, 2024
2 parents 294ecf5 + 8619713 commit 4375e1b
Show file tree
Hide file tree
Showing 518 changed files with 9,480 additions and 6,336 deletions.
2 changes: 1 addition & 1 deletion .buildkite/pipelines/intake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ steps:
timeout_in_minutes: 300
matrix:
setup:
BWC_VERSION: ["7.17.22", "8.13.5", "8.14.0", "8.15.0"]
BWC_VERSION: ["7.17.22", "8.14.1", "8.15.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand Down
12 changes: 6 additions & 6 deletions .buildkite/pipelines/periodic-packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ steps:
env:
BWC_VERSION: 8.12.2

- label: "{{matrix.image}} / 8.13.5 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.13.5
- label: "{{matrix.image}} / 8.13.4 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.13.4
timeout_in_minutes: 300
matrix:
setup:
Expand All @@ -543,10 +543,10 @@ steps:
machineType: custom-16-32768
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 8.13.5
BWC_VERSION: 8.13.4

- label: "{{matrix.image}} / 8.14.0 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.14.0
- label: "{{matrix.image}} / 8.14.1 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.14.1
timeout_in_minutes: 300
matrix:
setup:
Expand All @@ -559,7 +559,7 @@ steps:
machineType: custom-16-32768
buildDirectory: /dev/shm/bk
env:
BWC_VERSION: 8.14.0
BWC_VERSION: 8.14.1

- label: "{{matrix.image}} / 8.15.0 / packaging-tests-upgrade"
command: ./.ci/scripts/packaging-test.sh -Dbwc.checkout.align=true destructiveDistroUpgradeTest.v8.15.0
Expand Down
16 changes: 8 additions & 8 deletions .buildkite/pipelines/periodic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,8 @@ steps:
- signal_reason: agent_stop
limit: 3

- label: 8.13.5 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.13.5#bwcTest
- label: 8.13.4 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.13.4#bwcTest
timeout_in_minutes: 300
agents:
provider: gcp
Expand All @@ -601,7 +601,7 @@ steps:
buildDirectory: /dev/shm/bk
preemptible: true
env:
BWC_VERSION: 8.13.5
BWC_VERSION: 8.13.4
retry:
automatic:
- exit_status: "-1"
Expand All @@ -610,8 +610,8 @@ steps:
- signal_reason: agent_stop
limit: 3

- label: 8.14.0 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.14.0#bwcTest
- label: 8.14.1 / bwc
command: .ci/scripts/run-gradle.sh -Dbwc.checkout.align=true v8.14.1#bwcTest
timeout_in_minutes: 300
agents:
provider: gcp
Expand All @@ -620,7 +620,7 @@ steps:
buildDirectory: /dev/shm/bk
preemptible: true
env:
BWC_VERSION: 8.14.0
BWC_VERSION: 8.14.1
retry:
automatic:
- exit_status: "-1"
Expand Down Expand Up @@ -714,7 +714,7 @@ steps:
setup:
ES_RUNTIME_JAVA:
- openjdk17
BWC_VERSION: ["7.17.22", "8.13.5", "8.14.0", "8.15.0"]
BWC_VERSION: ["7.17.22", "8.14.1", "8.15.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand Down Expand Up @@ -762,7 +762,7 @@ steps:
- openjdk21
- openjdk22
- openjdk23
BWC_VERSION: ["7.17.22", "8.13.5", "8.14.0", "8.15.0"]
BWC_VERSION: ["7.17.22", "8.14.1", "8.15.0"]
agents:
provider: gcp
image: family/elasticsearch-ubuntu-2004
Expand Down
4 changes: 2 additions & 2 deletions .ci/bwcVersions
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ BWC_VERSION:
- "8.10.4"
- "8.11.4"
- "8.12.2"
- "8.13.5"
- "8.14.0"
- "8.13.4"
- "8.14.1"
- "8.15.0"
3 changes: 1 addition & 2 deletions .ci/snapshotBwcVersions
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
BWC_VERSION:
- "7.17.22"
- "8.13.5"
- "8.14.0"
- "8.14.1"
- "8.15.0"
3 changes: 0 additions & 3 deletions branches.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
{
"branch": "8.14"
},
{
"branch": "8.13"
},
{
"branch": "7.17"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ tasks.register("bwcTest") {

plugins.withType(ElasticsearchTestBasePlugin) {
tasks.withType(Test).matching { it.name ==~ /v[0-9\.]+#.*/ }.configureEach {
onlyIf("BWC tests enabled") { project.bwc_tests_enabled }
boolean bwcEnabled = project.bwc_tests_enabled
onlyIf("BWC tests enabled") { bwcEnabled }
nonInputProperties.systemProperty 'tests.bwc', 'true'
}
}
Expand All @@ -50,5 +51,5 @@ plugins.withType(InternalJavaRestTestPlugin) {
}
}

tasks.matching { it.name.equals("check") }.configureEach {dependsOn(bwcTestSnapshots) }
tasks.matching { it.name.equals("test") }.configureEach {enabled = false}
tasks.matching { it.name.equals("check") }.configureEach { dependsOn(bwcTestSnapshots) }
tasks.matching { it.name.equals("test") }.configureEach { enabled = false }
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import org.gradle.api.model.ObjectFactory;
import org.gradle.api.provider.Property;
import org.gradle.api.provider.Provider;
import org.gradle.api.provider.ProviderFactory;
import org.gradle.api.provider.ValueSource;
import org.gradle.api.provider.ValueSourceParameters;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.jvm.toolchain.JavaLanguageVersion;
import org.gradle.jvm.toolchain.JavaToolchainService;
Expand All @@ -41,6 +44,7 @@ public class BwcSetupExtension {
private static final Version BUILD_TOOL_MINIMUM_VERSION = Version.fromString("7.14.0");
private final Project project;
private final ObjectFactory objectFactory;
private final ProviderFactory providerFactory;
private final JavaToolchainService toolChainService;
private final Provider<BwcVersions.UnreleasedVersionInfo> unreleasedVersionInfo;

Expand All @@ -49,12 +53,14 @@ public class BwcSetupExtension {
public BwcSetupExtension(
Project project,
ObjectFactory objectFactory,
ProviderFactory providerFactory,
JavaToolchainService toolChainService,
Provider<BwcVersions.UnreleasedVersionInfo> unreleasedVersionInfo,
Provider<File> checkoutDir
) {
this.project = project;
this.objectFactory = objectFactory;
this.providerFactory = providerFactory;
this.toolChainService = toolChainService;
this.unreleasedVersionInfo = unreleasedVersionInfo;
this.checkoutDir = checkoutDir;
Expand All @@ -65,11 +71,26 @@ TaskProvider<LoggedExec> bwcTask(String name, Action<LoggedExec> configuration)
}

TaskProvider<LoggedExec> bwcTask(String name, Action<LoggedExec> configuration, boolean useUniqueUserHome) {
return createRunBwcGradleTask(project, name, configuration, useUniqueUserHome);
return createRunBwcGradleTask(
project,
checkoutDir,
providerFactory,
unreleasedVersionInfo,
objectFactory,
toolChainService,
name,
configuration,
useUniqueUserHome
);
}

private TaskProvider<LoggedExec> createRunBwcGradleTask(
private static TaskProvider<LoggedExec> createRunBwcGradleTask(
Project project,
Provider<File> checkoutDir,
ProviderFactory providerFactory,
Provider<BwcVersions.UnreleasedVersionInfo> unreleasedVersionInfo,
ObjectFactory objectFactory,
JavaToolchainService toolChainService,
String name,
Action<LoggedExec> configAction,
boolean useUniqueUserHome
Expand All @@ -78,10 +99,10 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(
loggedExec.dependsOn("checkoutBwcBranch");
loggedExec.getWorkingDir().set(checkoutDir.get());

loggedExec.getEnvironment().put("JAVA_HOME", unreleasedVersionInfo.zip(checkoutDir, (version, checkoutDir) -> {
String minimumCompilerVersion = readFromFile(new File(checkoutDir, minimumCompilerVersionPath(version.version())));
return getJavaHome(Integer.parseInt(minimumCompilerVersion));
}));
loggedExec.getNonTrackedEnvironment().put("JAVA_HOME", providerFactory.of(JavaHomeValueSource.class, spec -> {
spec.getParameters().getVersion().set(unreleasedVersionInfo.map(it -> it.version()));
spec.getParameters().getCheckoutDir().set(checkoutDir);
}).flatMap(s -> getJavaHome(objectFactory, toolChainService, Integer.parseInt(s))));

if (BuildParams.isCi() && OS.current() != OS.WINDOWS) {
// TODO: Disabled for now until we can figure out why files are getting corrupted
Expand Down Expand Up @@ -137,10 +158,13 @@ private TaskProvider<LoggedExec> createRunBwcGradleTask(
});
}

private String minimumCompilerVersionPath(Version bwcVersion) {
return (bwcVersion.onOrAfter(BUILD_TOOL_MINIMUM_VERSION))
? "build-tools-internal/" + MINIMUM_COMPILER_VERSION_PATH
: "buildSrc/" + MINIMUM_COMPILER_VERSION_PATH;
/** A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
private static Provider<String> getJavaHome(ObjectFactory objectFactory, JavaToolchainService toolChainService, final int version) {
Property<JavaLanguageVersion> value = objectFactory.property(JavaLanguageVersion.class).value(JavaLanguageVersion.of(version));
return toolChainService.launcherFor(javaToolchainSpec -> {
javaToolchainSpec.getLanguageVersion().value(value);
javaToolchainSpec.getVendor().set(JvmVendorSpec.ORACLE);
}).map(launcher -> launcher.getMetadata().getInstallationPath().getAsFile().getAbsolutePath());
}

private static String readFromFile(File file) {
Expand All @@ -151,13 +175,25 @@ private static String readFromFile(File file) {
}
}

/** A convenience method for getting java home for a version of java and requiring that version for the given task to execute */
public String getJavaHome(final int version) {
Property<JavaLanguageVersion> value = objectFactory.property(JavaLanguageVersion.class).value(JavaLanguageVersion.of(version));
return toolChainService.launcherFor(javaToolchainSpec -> {
javaToolchainSpec.getLanguageVersion().value(value);
javaToolchainSpec.getVendor().set(JvmVendorSpec.ORACLE);
}).get().getMetadata().getInstallationPath().getAsFile().getAbsolutePath();
}
public static abstract class JavaHomeValueSource implements ValueSource<String, JavaHomeValueSource.Params> {

private String minimumCompilerVersionPath(Version bwcVersion) {
return (bwcVersion.onOrAfter(BUILD_TOOL_MINIMUM_VERSION))
? "build-tools-internal/" + MINIMUM_COMPILER_VERSION_PATH
: "buildSrc/" + MINIMUM_COMPILER_VERSION_PATH;
}

@Override
public String obtain() {
return readFromFile(
new File(getParameters().getCheckoutDir().get(), minimumCompilerVersionPath(getParameters().getVersion().get()))
);
}

public interface Params extends ValueSourceParameters {
Property<Version> getVersion();

Property<File> getCheckoutDir();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.gradle.api.tasks.testing.Test;

import java.io.File;
import java.util.List;
import java.util.Map;

import static org.elasticsearch.gradle.util.FileUtils.mkdirs;
Expand Down Expand Up @@ -100,6 +101,7 @@ public void execute(Task t) {
"-Xmx" + System.getProperty("tests.heap.size", "512m"),
"-Xms" + System.getProperty("tests.heap.size", "512m"),
"-Djava.security.manager=allow",
"--add-opens=java.base/java.util=ALL-UNNAMED",
// TODO: only open these for mockito when it is modularized
"--add-opens=java.base/java.security.cert=ALL-UNNAMED",
"--add-opens=java.base/java.nio.channels=ALL-UNNAMED",
Expand Down Expand Up @@ -199,5 +201,29 @@ public void execute(Task t) {
}
});
});
configureImmutableCollectionsPatch(project);
}

private void configureImmutableCollectionsPatch(Project project) {
String patchProject = ":test:immutable-collections-patch";
if (project.findProject(patchProject) == null) {
return; // build tests may not have this project, just skip
}
String configurationName = "immutableCollectionsPatch";
FileCollection patchedFileCollection = project.getConfigurations()
.create(configurationName, config -> config.setCanBeConsumed(false));
var deps = project.getDependencies();
deps.add(configurationName, deps.project(Map.of("path", patchProject, "configuration", "patch")));
project.getTasks().withType(Test.class).matching(task -> task.getName().equals("test")).configureEach(test -> {
test.getInputs().files(patchedFileCollection);
test.systemProperty("tests.hackImmutableCollections", "true");
test.getJvmArgumentProviders()
.add(
() -> List.of(
"--patch-module=java.base=" + patchedFileCollection.getSingleFile() + "/java.base",
"--add-opens=java.base/java.util=ALL-UNNAMED"
)
);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,6 @@ public void execute(Task task) {
String remoteRepo = remote.get();
// for testing only we can override the base remote url
String remoteRepoUrl = providerFactory.systemProperty("testRemoteRepo")
.orElse(
providerFactory.provider(
() -> addRemote.getExtensions().getExtraProperties().has("remote")
? addRemote.getExtensions().getExtraProperties().get("remote").toString()
: null
)
)
.getOrElse("https://github.com/" + remoteRepo + "/" + rootProjectName);
spec.commandLine("git", "remote", "add", remoteRepo, remoteRepoUrl);
});
Expand Down Expand Up @@ -213,6 +206,7 @@ private String maybeAlignedRefSpec(Logger logger, String defaultRefSpec) {

private void writeFile(File file, String content) {
try {
file.getParentFile().mkdirs();
Files.writeString(file.toPath(), content, CREATE, TRUNCATE_EXISTING);
} catch (IOException e) {
throw new UncheckedIOException(e);
Expand Down
Loading

0 comments on commit 4375e1b

Please sign in to comment.