Skip to content

Commit

Permalink
Simplify handling of runtime java for tests clusters (#104232) (#104236)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira committed Jan 10, 2024
1 parent 5a9a863 commit 1665f70
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,6 @@ configure(allprojects) {
}
}
}

project.plugins.withType(RestTestBasePlugin) {
tasks.withType(StandaloneRestIntegTestTask).configureEach {
if (BuildParams.getIsRuntimeJavaHomeSet() == false) {
nonInputProperties.systemProperty("tests.runtime.java", "${-> launcher.map { it.metadata.installationPath.asFile.path }.get()}")
}
}
}

project.plugins.withType(ThirdPartyAuditPrecommitPlugin) {
project.getTasks().withType(ThirdPartyAuditTask.class).configureEach {
if (BuildParams.getIsRuntimeJavaHomeSet() == false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
public class RestTestBasePlugin implements Plugin<Project> {

private static final String TESTS_MAX_PARALLEL_FORKS_SYSPROP = "tests.max.parallel.forks";
private static final String TESTS_RUNTIME_JAVA_SYSPROP = "tests.runtime.java";
private static final String DEFAULT_DISTRIBUTION_SYSPROP = "tests.default.distribution";
private static final String INTEG_TEST_DISTRIBUTION_SYSPROP = "tests.integ-test.distribution";
private static final String BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX = "tests.snapshot.distribution.";
Expand Down Expand Up @@ -189,7 +188,6 @@ public void apply(Project project) {
// Wire up integ-test distribution by default for all test tasks
FileCollection extracted = integTestDistro.getExtracted();
nonInputSystemProperties.systemProperty(INTEG_TEST_DISTRIBUTION_SYSPROP, () -> extracted.getSingleFile().getPath());
nonInputSystemProperties.systemProperty(TESTS_RUNTIME_JAVA_SYSPROP, BuildParams.getRuntimeJavaHome());

// Add `usesDefaultDistribution()` extension method to test tasks to indicate they require the default distro
task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure<Void>(task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void testDieWithDignity() throws Exception {
}

private Process startJcmd(long pid) throws IOException {
final String jcmdPath = PathUtils.get(System.getProperty("tests.runtime.java"), "bin/jcmd").toString();
final String jcmdPath = PathUtils.get(System.getProperty("java.home"), "bin/jcmd").toString();
return new ProcessBuilder().command(jcmdPath, Long.toString(pid), "VM.command_line").redirectErrorStream(true).start();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
public class DefaultEnvironmentProvider implements EnvironmentProvider {
private static final String HOSTNAME_OVERRIDE = "LinuxDarwinHostname";
private static final String COMPUTERNAME_OVERRIDE = "WindowsComputername";
private static final String TESTS_RUNTIME_JAVA_SYSPROP = "tests.runtime.java";

@Override
public Map<String, String> get(LocalNodeSpec nodeSpec) {
Map<String, String> environment = new HashMap<>();

// If we are testing the current version of Elasticsearch, use the configured runtime Java, otherwise use the bundled JDK
if (nodeSpec.getDistributionType() == DistributionType.INTEG_TEST || nodeSpec.getVersion().equals(Version.CURRENT)) {
environment.put("ES_JAVA_HOME", System.getProperty(TESTS_RUNTIME_JAVA_SYSPROP));
environment.put("ES_JAVA_HOME", System.getProperty("java.home"));
}

// Override the system hostname variables for testing
Expand Down

0 comments on commit 1665f70

Please sign in to comment.