Skip to content

Commit

Permalink
Use production-similar GC settings for internal cluster tests (#73701)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-vieira authored Jun 2, 2021
1 parent 8cba213 commit 7bbd311
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,30 @@

package org.elasticsearch.gradle.internal.test;

import org.elasticsearch.gradle.internal.info.BuildParams;
import org.elasticsearch.gradle.util.GradleUtils;
import org.gradle.api.JavaVersion;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.TaskProvider;
import org.gradle.api.tasks.testing.Test;

public class InternalClusterTestPlugin implements Plugin<Project> {

public static final String SOURCE_SET_NAME = "internalClusterTest";

@Override
public void apply(Project project) {
GradleUtils.addTestSourceSet(project, SOURCE_SET_NAME);
TaskProvider<Test> internalClusterTest = GradleUtils.addTestSourceSet(project, SOURCE_SET_NAME);
internalClusterTest.configure(task -> {
// Set GC options to mirror defaults in jvm.options
if (BuildParams.getRuntimeJavaVersion().compareTo(JavaVersion.VERSION_14) < 0) {
task.jvmArgs("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-XX:+UseCMSInitiatingOccupancyOnly");
} else {
task.jvmArgs("-XX:+UseG1GC");
}
});

// TODO: fix usages of IT tests depending on Tests methods so this extension is not necessary
GradleUtils.extendSourceSet(project, SourceSet.TEST_SOURCE_SET_NAME, SOURCE_SET_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static <T extends BuildService<?>> Provider<T> getBuildService(BuildServi
*
* @return A task provider for the newly created test task
*/
public static TaskProvider<?> addTestSourceSet(Project project, String sourceSetName) {
public static TaskProvider<Test> addTestSourceSet(Project project, String sourceSetName) {
project.getPluginManager().apply(JavaPlugin.class);

// create our test source set and task
Expand Down

0 comments on commit 7bbd311

Please sign in to comment.