diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersPrecommitPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersPrecommitPlugin.java index 5883d2cc5d35f..01c8654a452b9 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersPrecommitPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/LicenseHeadersPrecommitPlugin.java @@ -18,7 +18,6 @@ import org.gradle.api.tasks.TaskProvider; import javax.inject.Inject; -import java.util.stream.Collectors; public class LicenseHeadersPrecommitPlugin extends PrecommitPlugin { @Inject @@ -31,8 +30,7 @@ public TaskProvider createTask(Project project) { return project.getTasks().register("licenseHeaders", LicenseHeadersTask.class, licenseHeadersTask -> { project.getPlugins().withType(JavaBasePlugin.class, javaBasePlugin -> { final SourceSetContainer sourceSets = project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets(); - licenseHeadersTask.getSourceFolders() - .addAll(providerFactory.provider(() -> sourceSets.stream().map(s -> s.getAllJava()).collect(Collectors.toList()))); + sourceSets.configureEach(sourceSet -> { licenseHeadersTask.getSourceFolders().add(sourceSet.getAllJava()); }); }); }); } diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/PrecommitTaskPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/PrecommitTaskPlugin.java index fa8720f3dce28..5d15c6b7557fe 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/PrecommitTaskPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/PrecommitTaskPlugin.java @@ -34,7 +34,7 @@ public void apply(Project project) { ); project.getPluginManager().withPlugin("java-base", p -> { // run compilation as part of precommit - project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().all(sourceSet -> + project.getExtensions().getByType(JavaPluginExtension.class).getSourceSets().configureEach(sourceSet -> precommit.configure(t -> t.dependsOn(sourceSet.getClassesTaskName())) ); // make sure tests run after all precommit tasks diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy index 63bb732d8a11d..00c565dfd18a2 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy @@ -137,12 +137,12 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest { file("licenses/hamcrest-core-1.3.jar.sha1").text = "42a25dc3219429f0e5d060061f71acb49bf010a0" file("licenses/hamcrest-core-LICENSE.txt").text = EXAMPLE_LICENSE file("licenses/hamcrest-core-NOTICE.txt").text = "mock notice" - file("licenses/junit-4.12.jar.sha1").text = "2973d150c0dc1fefe998f834810d68f278ea58ec" + file("licenses/junit-4.13.2.jar.sha1").text = "2973d150c0dc1fefe998f834810d68f278ea58ec" file("licenses/junit-LICENSE.txt").text = EXAMPLE_LICENSE file("licenses/junit-NOTICE.txt").text = "mock notice" buildFile << """ dependencies { - api "junit:junit:4.12" + api "junit:junit:4.13.2" // missing classes in thirdparty audit api 'org.hamcrest:hamcrest-core:1.3' } diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy index 2b3206f13230d..f3700e8ffa238 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/precommit/TestingConventionsPrecommitPluginFuncTest.groovy @@ -32,7 +32,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl "org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase", "org.elasticsearch.test.AbstractMultiClustersTestCase" ) - repository.generateJar('org.junit', 'junit', "4.42", + repository.generateJar('junit', 'junit', "4.42", "org.junit.Assert", "org.junit.Test" ) } @@ -180,7 +180,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl dependencies { yamlRestTestImplementation "org.apache.lucene:tests.util:1.0" - yamlRestTestImplementation "org.junit:junit:4.42" + yamlRestTestImplementation "junit:junit:4.42" } """ @@ -222,7 +222,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl dependencies { ${sourceSetName}Implementation "org.apache.lucene:tests.util:1.0" - ${sourceSetName}Implementation "org.junit:junit:4.42" + ${sourceSetName}Implementation "junit:junit:4.42" } tasks.withType(TestingConventionsCheckTask).configureEach { suffix 'IT' @@ -243,7 +243,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl } when: - def result = gradleRunner("testingConventions").buildAndFail() + def result = gradleRunner(taskName).buildAndFail() then: result.task(taskName).outcome == TaskOutcome.FAILED assertOutputContains(result.getOutput(), """\ @@ -266,7 +266,7 @@ class TestingConventionsPrecommitPluginFuncTest extends AbstractGradleInternalPl dependencies { testImplementation "org.apache.lucene:tests.util:1.0" - testImplementation "org.junit:junit:4.42" + testImplementation "junit:junit:4.42" } """ } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java index 70f6cecb8e725..3b3e5170a983f 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaBasePlugin.java @@ -21,10 +21,12 @@ import org.gradle.api.Plugin; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; +import org.gradle.api.artifacts.ExternalModuleDependency; import org.gradle.api.artifacts.ResolutionStrategy; import org.gradle.api.file.FileCollection; -import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaPluginExtension; +import org.gradle.api.plugins.JvmTestSuitePlugin; +import org.gradle.api.plugins.jvm.JvmTestSuite; import org.gradle.api.provider.Provider; import org.gradle.api.tasks.SourceSet; import org.gradle.api.tasks.SourceSetContainer; @@ -35,6 +37,7 @@ import org.gradle.api.tasks.testing.Test; import org.gradle.jvm.toolchain.JavaLanguageVersion; import org.gradle.jvm.toolchain.JavaToolchainService; +import org.gradle.testing.base.TestingExtension; import java.util.List; import java.util.Map; @@ -61,7 +64,18 @@ public void apply(Project project) { // make sure the global build info plugin is applied to the root project project.getRootProject().getPluginManager().apply(GlobalBuildInfoPlugin.class); buildParams = project.getRootProject().getExtensions().getByType(BuildParameterExtension.class); - project.getPluginManager().apply(JavaBasePlugin.class); + project.getPluginManager().apply(JvmTestSuitePlugin.class); + TestingExtension testing = project.getExtensions().getByType(TestingExtension.class); + testing.getSuites().withType(JvmTestSuite.class).configureEach(suite -> { + if (suite.getName().equals("test") == false) { + // default test task behaves differently in gradle + suite.useJUnit(); + } + ExternalModuleDependency junitDependency = suite.getDependencies() + .module("junit", "junit", VersionProperties.getVersions().get("junit")); + junitDependency.setTransitive(false); + suite.getDependencies().getImplementation().add(junitDependency); + }); // common repositories setup project.getPluginManager().apply(RepositoriesSetupPlugin.class); project.getPluginManager().apply(ElasticsearchTestBasePlugin.class); @@ -99,7 +113,7 @@ public static void configureConfigurations(Project project) { return; } // fail on any conflicting dependency versions - project.getConfigurations().all(configuration -> { + project.getConfigurations().configureEach(configuration -> { if (configuration.getName().endsWith("Fixture")) { // just a self contained test-fixture configuration, likely transitive and hellacious return; @@ -109,17 +123,17 @@ public static void configureConfigurations(Project project) { // disable transitive dependency management SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - sourceSets.all(sourceSet -> disableTransitiveDependenciesForSourceSet(project, sourceSet)); + sourceSets.configureEach(sourceSet -> disableTransitiveDependenciesForSourceSet(project, sourceSet)); } private static void disableTransitiveDependenciesForSourceSet(Project project, SourceSet sourceSet) { + List sourceSetConfigurationNames = List.of( sourceSet.getApiConfigurationName(), sourceSet.getImplementationConfigurationName(), sourceSet.getCompileOnlyConfigurationName(), sourceSet.getRuntimeOnlyConfigurationName() ); - project.getConfigurations() .matching(c -> sourceSetConfigurationNames.contains(c.getName())) .configureEach(GradleUtils::disableTransitiveDependencies); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavadocPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavadocPlugin.java index aca310cbf1e47..b385cbabeb495 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavadocPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavadocPlugin.java @@ -16,7 +16,6 @@ import org.gradle.api.Project; import org.gradle.api.Task; import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.Dependency; import org.gradle.api.artifacts.ProjectDependency; import org.gradle.api.plugins.BasePluginExtension; import org.gradle.api.plugins.JavaPlugin; @@ -25,7 +24,6 @@ import org.gradle.external.javadoc.StandardJavadocDocletOptions; import java.io.File; -import java.util.Comparator; import java.util.List; // Handle javadoc dependencies across projects. Order matters: the linksOffline for @@ -77,12 +75,11 @@ public void execute(Task task) { } private void configureJavadocForConfiguration(Project project, boolean shadow, Configuration configuration) { - configuration.getAllDependencies() - .stream() - .sorted(Comparator.comparing(Dependency::getGroup)) - .filter(d -> d instanceof ProjectDependency) - .map(d -> (ProjectDependency) d) - .forEach(projectDependency -> configureDependency(project, shadow, projectDependency)); + configuration.getAllDependencies().configureEach(dependency -> { + if (dependency instanceof ProjectDependency) { + configureDependency(project, shadow, (ProjectDependency) dependency); + } + }); } private void configureDependency(Project project, boolean shadowed, ProjectDependency dep) { diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestArtifactPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestArtifactPlugin.java index 674effecd8fbd..ba7538a82031c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestArtifactPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalTestArtifactPlugin.java @@ -24,7 +24,7 @@ public class InternalTestArtifactPlugin implements Plugin { public void apply(Project project) { project.getPlugins().apply(InternalTestArtifactBasePlugin.class); InternalTestArtifactExtension testArtifactExtension = project.getExtensions().getByType(InternalTestArtifactExtension.class); - project.getExtensions().getByType(SourceSetContainer.class).all(sourceSet -> { + project.getExtensions().getByType(SourceSetContainer.class).configureEach(sourceSet -> { if (sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME) == false) { testArtifactExtension.registerTestArtifactFromSourceSet(sourceSet); } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java index dc8ea4424ba89..370637f7bea05 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/CheckstylePrecommitPlugin.java @@ -115,7 +115,7 @@ public void execute(Task task) { JavaBasePlugin.class, javaBasePlugin -> project.getExtensions() .getByType(SourceSetContainer.class) - .all( + .configureEach( sourceSet -> project.getTasks() .withType(Checkstyle.class) .named(sourceSet.getTaskName("checkstyle", null)) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsPrecommitPlugin.java index 9df3e9256ff54..853c8906d0a8c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/FilePermissionsPrecommitPlugin.java @@ -16,8 +16,6 @@ import org.gradle.api.provider.ProviderFactory; import org.gradle.api.tasks.TaskProvider; -import java.util.stream.Collectors; - import javax.inject.Inject; public class FilePermissionsPrecommitPlugin extends PrecommitPlugin { @@ -33,18 +31,10 @@ public FilePermissionsPrecommitPlugin(ProviderFactory providerFactory) { @Override public TaskProvider createTask(Project project) { return project.getTasks().register(FILEPERMISSIONS_TASK_NAME, FilePermissionsTask.class, t -> { - t.getSources() - .addAll( - providerFactory.provider( - () -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList()) - ) - ); - t.dependsOn( - GradleUtils.getJavaSourceSets(project) - .stream() - .map(sourceSet -> sourceSet.getProcessResourcesTaskName()) - .collect(Collectors.toList()) - ); + GradleUtils.getJavaSourceSets(project).configureEach(sourceSet -> { + t.getSources().add(sourceSet.getAllSource()); + t.dependsOn(sourceSet.getProcessResourcesTaskName()); + }); }); } } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsPrecommitPlugin.java index b2c62ba9a4628..f1ffa164e8079 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/ForbiddenPatternsPrecommitPlugin.java @@ -16,8 +16,6 @@ import org.gradle.api.provider.ProviderFactory; import org.gradle.api.tasks.TaskProvider; -import java.util.stream.Collectors; - import javax.inject.Inject; public class ForbiddenPatternsPrecommitPlugin extends PrecommitPlugin { @@ -33,18 +31,10 @@ public ForbiddenPatternsPrecommitPlugin(ProviderFactory providerFactory) { @Override public TaskProvider createTask(Project project) { return project.getTasks().register(FORBIDDEN_PATTERNS_TASK_NAME, ForbiddenPatternsTask.class, forbiddenPatternsTask -> { - forbiddenPatternsTask.getSourceFolders() - .addAll( - providerFactory.provider( - () -> GradleUtils.getJavaSourceSets(project).stream().map(s -> s.getAllSource()).collect(Collectors.toList()) - ) - ); - forbiddenPatternsTask.dependsOn( - GradleUtils.getJavaSourceSets(project) - .stream() - .map(sourceSet -> sourceSet.getProcessResourcesTaskName()) - .collect(Collectors.toList()) - ); + GradleUtils.getJavaSourceSets(project).configureEach(sourceSet -> { + forbiddenPatternsTask.getSourceFolders().add(sourceSet.getAllSource()); + forbiddenPatternsTask.dependsOn(sourceSet.getProcessResourcesTaskName()); + }); forbiddenPatternsTask.getRootDir().set(project.getRootDir()); }); } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/JavaModulePrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/JavaModulePrecommitPlugin.java index 8c4c72eaba923..3b0793695453f 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/JavaModulePrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/JavaModulePrecommitPlugin.java @@ -25,12 +25,13 @@ public class JavaModulePrecommitPlugin extends PrecommitPlugin { public TaskProvider createTask(Project project) { TaskProvider task = project.getTasks().register(TASK_NAME, JavaModulePrecommitTask.class); task.configure(t -> { - SourceSet mainSourceSet = GradleUtils.getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME); - t.dependsOn(mainSourceSet.getClassesTaskName()); - t.getSrcDirs().set(project.provider(() -> mainSourceSet.getAllSource().getSrcDirs())); - t.setClasspath(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)); - t.setClassesDirs(mainSourceSet.getOutput().getClassesDirs()); - t.setResourcesDirs(mainSourceSet.getOutput().getResourcesDir()); + GradleUtils.getJavaSourceSets(project).named(SourceSet.MAIN_SOURCE_SET_NAME).configure(sourceSet -> { + t.dependsOn(sourceSet.getClassesTaskName()); + t.getSrcDirs().set(project.provider(() -> sourceSet.getAllSource().getSrcDirs())); + t.setClasspath(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)); + t.setClassesDirs(sourceSet.getOutput().getClassesDirs()); + t.setResourcesDirs(sourceSet.getOutput().getResourcesDir()); + }); }); return task; } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/LoggerUsagePrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/LoggerUsagePrecommitPlugin.java index d3c803a100d4b..8d0a7d58b9cba 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/LoggerUsagePrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/LoggerUsagePrecommitPlugin.java @@ -33,7 +33,7 @@ public TaskProvider createTask(Project project) { sourceSets.matching( sourceSet -> sourceSet.getName().equals(SourceSet.MAIN_SOURCE_SET_NAME) || sourceSet.getName().equals(SourceSet.TEST_SOURCE_SET_NAME) - ).all(sourceSet -> loggerUsage.configure(t -> t.addSourceSet(sourceSet))); + ).configureEach(sourceSet -> loggerUsage.configure(t -> t.addSourceSet(sourceSet))); loggerUsage.configure( t -> t.setClasspath(loggerUsageConfig) diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java index 23435aefb4a3c..fccca33ed6a75 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/precommit/SplitPackagesAuditPrecommitPlugin.java @@ -30,9 +30,11 @@ public TaskProvider createTask(Project project) { task.configure(t -> { t.setProjectBuildDirs(getProjectBuildDirs(project)); t.setClasspath(project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME)); - SourceSet mainSourceSet = GradleUtils.getJavaSourceSets(project).findByName(SourceSet.MAIN_SOURCE_SET_NAME); - t.dependsOn(mainSourceSet.getJava().getSourceDirectories()); - t.getSrcDirs().set(project.provider(() -> mainSourceSet.getAllSource().getSrcDirs())); + GradleUtils.getJavaSourceSets(project).named(SourceSet.MAIN_SOURCE_SET_NAME).configure(sourceSet -> { + t.dependsOn(sourceSet.getJava().getSourceDirectories()); + t.getSrcDirs().set(project.provider(() -> sourceSet.getAllSource().getSrcDirs())); + }); + }); return task; } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/InternalClusterTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/InternalClusterTestPlugin.java index e13c2544ae9cf..24dce655c3ef2 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/InternalClusterTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/InternalClusterTestPlugin.java @@ -11,14 +11,14 @@ import org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin; 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.artifacts.dsl.DependencyCollector; +import org.gradle.api.plugins.JavaPlugin; +import org.gradle.api.plugins.JvmTestSuitePlugin; +import org.gradle.api.plugins.jvm.JvmTestSuite; import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.TaskProvider; -import org.gradle.api.tasks.testing.Test; - -import static org.elasticsearch.gradle.internal.util.ParamsUtils.loadBuildParams; +import org.gradle.testing.base.TestingExtension; public class InternalClusterTestPlugin implements Plugin { @@ -27,19 +27,20 @@ public class InternalClusterTestPlugin implements Plugin { @Override public void apply(Project project) { project.getRootProject().getPlugins().apply(GlobalBuildInfoPlugin.class); - var buildParams = loadBuildParams(project).get(); - - TaskProvider internalClusterTest = GradleUtils.addTestSourceSet(project, SOURCE_SET_NAME); - internalClusterTest.configure(task -> { - // Set GC options to mirror defaults in jvm.options - if (buildParams.getRuntimeJavaVersion().get().compareTo(JavaVersion.VERSION_14) < 0) { - task.jvmArgs("-XX:+UseConcMarkSweepGC", "-XX:CMSInitiatingOccupancyFraction=75", "-XX:+UseCMSInitiatingOccupancyOnly"); - } else { - task.jvmArgs("-XX:+UseG1GC"); - } + project.getPluginManager().apply(JavaPlugin.class); + project.getPluginManager().apply(JvmTestSuitePlugin.class); + TestingExtension testing = project.getExtensions().getByType(TestingExtension.class); + + testing.getSuites().register(SOURCE_SET_NAME, JvmTestSuite.class, suite -> { + suite.useJUnit(); + DependencyCollector implementation = suite.getDependencies().getImplementation(); + implementation.add(suite.getDependencies().project()); + suite.getTargets().configureEach(target -> { target.getTestTask().configure(test -> { test.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); + project.getPluginManager().withPlugin("java", plugin -> { + // 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); + }); } } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java index a2851bfa2ae55..c304b1cff78e5 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/TestWithDependenciesPlugin.java @@ -47,7 +47,7 @@ public void apply(final Project project) { } Configuration testImplementationConfig = project.getConfigurations().getByName("testImplementation"); - testImplementationConfig.getDependencies().all(dep -> { + testImplementationConfig.getDependencies().configureEach(dep -> { if (dep instanceof ProjectDependency && dep.getGroup().contains("plugin")) { addPluginResources(project, ((ProjectDependency) dep)); } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultJavaRestTestSuite.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultJavaRestTestSuite.java new file mode 100644 index 0000000000000..2450750f98500 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultJavaRestTestSuite.java @@ -0,0 +1,26 @@ +/* + * 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.gradle.internal.test.rest; + +import org.gradle.api.artifacts.ConfigurationContainer; +import org.gradle.api.internal.tasks.TaskDependencyFactory; +import org.gradle.api.plugins.jvm.internal.DefaultJvmTestSuite; +import org.gradle.api.tasks.SourceSetContainer; + +public abstract class DefaultJavaRestTestSuite extends DefaultJvmTestSuite implements JavaRestTestSuite { + public DefaultJavaRestTestSuite( + String name, + SourceSetContainer sourceSets, + ConfigurationContainer configurations, + TaskDependencyFactory taskDependencyFactory + ) { + super(name, sourceSets, configurations, taskDependencyFactory); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultYamlRestTestSuite.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultYamlRestTestSuite.java new file mode 100644 index 0000000000000..bb4b0c28fb6bb --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/DefaultYamlRestTestSuite.java @@ -0,0 +1,26 @@ +/* + * 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.gradle.internal.test.rest; + +import org.gradle.api.artifacts.ConfigurationContainer; +import org.gradle.api.internal.tasks.TaskDependencyFactory; +import org.gradle.api.plugins.jvm.internal.DefaultJvmTestSuite; +import org.gradle.api.tasks.SourceSetContainer; + +public abstract class DefaultYamlRestTestSuite extends DefaultJvmTestSuite implements YamlRestTestSuite { + public DefaultYamlRestTestSuite( + String name, + SourceSetContainer sourceSets, + ConfigurationContainer configurations, + TaskDependencyFactory taskDependencyFactory + ) { + super(name, sourceSets, configurations, taskDependencyFactory); + } +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java index 56c9a81a4a900..07382964434f9 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalJavaRestTestPlugin.java @@ -9,16 +9,12 @@ package org.elasticsearch.gradle.internal.test.rest; -import org.elasticsearch.gradle.internal.test.RestIntegTestTask; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskProvider; +import org.gradle.testing.base.TestingExtension; -import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.registerTestTask; import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupJavaRestTestDependenciesDefaults; /** @@ -31,24 +27,24 @@ public class InternalJavaRestTestPlugin implements Plugin { @Override public void apply(Project project) { project.getPluginManager().apply(RestTestBasePlugin.class); + TestingExtension testing = project.getExtensions().getByType(TestingExtension.class); + testing.getSuites().registerBinding(JavaRestTestSuite.class, DefaultJavaRestTestSuite.class); + testing.getSuites().register(SOURCE_SET_NAME, JavaRestTestSuite.class, suite -> { + suite.useJUnit(); + configureJavaRestSources(project, suite.getSources()); + if (project.findProject(":test:test-clusters") != null) { + suite.getDependencies().getImplementation().add(suite.getDependencies().project(":test:test-clusters")); + } + }); - // create source set - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet javaTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - - if (project.findProject(":test:test-clusters") != null) { - project.getDependencies().add(javaTestSourceSet.getImplementationConfigurationName(), project.project(":test:test-clusters")); - } - - // setup the javaRestTest task - TaskProvider testTask = registerTestTask(project, javaTestSourceSet, SOURCE_SET_NAME, RestIntegTestTask.class); - - project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(testTask)); + } + private void configureJavaRestSources(Project project, SourceSet javaTestSourceSet) { // setup dependencies setupJavaRestTestDependenciesDefaults(project, javaTestSourceSet); // setup IDE GradleUtils.setupIdeForTestSourceSet(project, javaTestSourceSet); } + } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java index 049ad7dec3057..bc1cdffe673f4 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/InternalYamlRestTestPlugin.java @@ -9,16 +9,12 @@ package org.elasticsearch.gradle.internal.test.rest; -import org.elasticsearch.gradle.internal.test.RestIntegTestTask; import org.elasticsearch.gradle.util.GradleUtils; import org.gradle.api.Plugin; import org.gradle.api.Project; -import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.tasks.SourceSet; -import org.gradle.api.tasks.SourceSetContainer; -import org.gradle.api.tasks.TaskProvider; +import org.gradle.testing.base.TestingExtension; -import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.registerTestTask; import static org.elasticsearch.gradle.internal.test.rest.RestTestUtil.setupYamlRestTestDependenciesDefaults; /** @@ -32,15 +28,15 @@ public class InternalYamlRestTestPlugin implements Plugin { public void apply(Project project) { project.getPluginManager().apply(RestTestBasePlugin.class); project.getPluginManager().apply(RestResourcesPlugin.class); + TestingExtension testing = project.getExtensions().getByType(TestingExtension.class); + testing.getSuites().registerBinding(YamlRestTestSuite.class, DefaultYamlRestTestSuite.class); + testing.getSuites().register(SOURCE_SET_NAME, YamlRestTestSuite.class, suite -> { + suite.useJUnit(); + configureYamlSourceSet(project, suite.getSources()); + }); + } - // create source set - SourceSetContainer sourceSets = project.getExtensions().getByType(SourceSetContainer.class); - SourceSet yamlTestSourceSet = sourceSets.create(SOURCE_SET_NAME); - - TaskProvider testTask = registerTestTask(project, yamlTestSourceSet, SOURCE_SET_NAME, RestIntegTestTask.class); - - project.getTasks().named(JavaBasePlugin.CHECK_TASK_NAME).configure(check -> check.dependsOn(testTask)); - + private void configureYamlSourceSet(Project project, SourceSet yamlTestSourceSet) { // setup the dependencies setupYamlRestTestDependenciesDefaults(project, yamlTestSourceSet, true); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/JavaRestTestSuite.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/JavaRestTestSuite.java new file mode 100644 index 0000000000000..a434703992de1 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/JavaRestTestSuite.java @@ -0,0 +1,12 @@ +/* + * 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.gradle.internal.test.rest; + +interface JavaRestTestSuite extends RestTestSuite {} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java index 1259d13773ce7..baf4002ebf35d 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java @@ -18,6 +18,7 @@ import org.elasticsearch.gradle.Version; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.distribution.ElasticsearchDistributionTypes; +import org.elasticsearch.gradle.internal.BwcVersions; import org.elasticsearch.gradle.internal.ElasticsearchJavaBasePlugin; import org.elasticsearch.gradle.internal.InternalDistributionDownloadPlugin; import org.elasticsearch.gradle.internal.test.ClusterFeaturesMetadataPlugin; @@ -44,10 +45,14 @@ import org.gradle.api.file.FileCollection; import org.gradle.api.file.FileTree; import org.gradle.api.internal.artifacts.dependencies.ProjectDependencyInternal; +import org.gradle.api.plugins.JavaBasePlugin; +import org.gradle.api.plugins.jvm.JvmTestSuiteTarget; import org.gradle.api.provider.ProviderFactory; import org.gradle.api.tasks.ClasspathNormalizer; import org.gradle.api.tasks.PathSensitivity; +import org.gradle.api.tasks.testing.Test; import org.gradle.api.tasks.util.PatternFilterable; +import org.gradle.testing.base.TestingExtension; import java.util.Collection; import java.util.Iterator; @@ -94,6 +99,7 @@ public RestTestBasePlugin(ProviderFactory providerFactory) { public void apply(Project project) { project.getPluginManager().apply(ElasticsearchJavaBasePlugin.class); project.getPluginManager().apply(InternalDistributionDownloadPlugin.class); + var bwcVersions = loadBuildParams(project).get().getBwcVersions(); // Register integ-test and default distributions @@ -153,104 +159,154 @@ public void apply(Project project) { }); - project.getTasks().withType(StandaloneRestIntegTestTask.class).configureEach(task -> { - SystemPropertyCommandLineArgumentProvider nonInputSystemProperties = task.getExtensions() - .getByType(SystemPropertyCommandLineArgumentProvider.class); - - task.dependsOn(integTestDistro, modulesConfiguration); - registerDistributionInputs(task, integTestDistro); - - // Pass feature metadata on to tests - task.getInputs().files(featureMetadataConfig).withPathSensitivity(PathSensitivity.NONE); - nonInputSystemProperties.systemProperty(TESTS_FEATURES_METADATA_PATH, () -> featureMetadataConfig.getAsPath()); - - // Enable parallel execution for these tests since each test gets its own cluster - task.setMaxParallelForks(task.getProject().getGradle().getStartParameter().getMaxWorkerCount() / 2); - nonInputSystemProperties.systemProperty(TESTS_MAX_PARALLEL_FORKS_SYSPROP, () -> String.valueOf(task.getMaxParallelForks())); - - // Disable test failure reporting since this stuff is now captured in build scans - task.getExtensions().getByType(ErrorReportingTestListener.class).setDumpOutputOnFailure(false); - - // Disable the security manager and syscall filter since the test framework needs to fork processes - task.systemProperty("tests.security.manager", "false"); - task.systemProperty("tests.system_call_filter", "false"); + TestingExtension testing = project.getExtensions().getByType(TestingExtension.class); + testing.getSuites() + .withType(RestTestSuite.class) + .configureEach( + restTestSuite -> restTestSuite.getTargets() + .configureEach((Action) jvmTestSuiteTarget -> jvmTestSuiteTarget.getTestTask().configure(test -> { + configureRegisteredRestTask( + project, + test, + integTestDistro, + modulesConfiguration, + featureMetadataConfig, + bwcVersions, + pluginsConfiguration, + extractedPluginsConfiguration, + defaultDistro, + defaultDistroFeatureMetadataConfig + ); + test.setGroup(JavaBasePlugin.VERIFICATION_GROUP); + test.setDescription("Runs the REST tests against an external cluster"); - // Pass minimum wire compatible version which is used by upgrade tests - task.systemProperty(MINIMUM_WIRE_COMPATIBLE_VERSION_SYSPROP, bwcVersions.getMinimumWireCompatibleVersion()); + })) + ); - // Register plugins and modules as task inputs and pass paths as system properties to tests - var modulePath = project.getObjects().fileCollection().from(modulesConfiguration); - nonInputSystemProperties.systemProperty(TESTS_CLUSTER_MODULES_PATH_SYSPROP, modulePath::getAsPath); - registerConfigurationInputs(task, modulesConfiguration.getName(), modulePath); - var pluginPath = project.getObjects().fileCollection().from(pluginsConfiguration); - nonInputSystemProperties.systemProperty(TESTS_CLUSTER_PLUGINS_PATH_SYSPROP, pluginPath::getAsPath); - registerConfigurationInputs( + project.getTasks().withType(StandaloneRestIntegTestTask.class).configureEach(task -> { + configureRegisteredRestTask( + project, task, - extractedPluginsConfiguration.getName(), - project.getObjects().fileCollection().from(extractedPluginsConfiguration) + integTestDistro, + modulesConfiguration, + featureMetadataConfig, + bwcVersions, + pluginsConfiguration, + extractedPluginsConfiguration, + defaultDistro, + defaultDistroFeatureMetadataConfig ); + }); + } - // Wire up integ-test distribution by default for all test tasks - FileCollection extracted = integTestDistro.getExtracted(); - nonInputSystemProperties.systemProperty(INTEG_TEST_DISTRIBUTION_SYSPROP, () -> extracted.getSingleFile().getPath()); - - // Add `usesDefaultDistribution()` extension method to test tasks to indicate they require the default distro - task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure(task) { - @Override - public Void call(Object... args) { - if (reasonForUsageProvided(args) == false) { - throw new IllegalArgumentException( - "Reason for using `usesDefaultDistribution` required.\nUse usesDefaultDistribution(\"reason why default distro is required here\")." - ); - } - task.dependsOn(defaultDistro); - registerDistributionInputs(task, defaultDistro); + private void configureRegisteredRestTask( + Project project, + Test task, + ElasticsearchDistribution integTestDistro, + Configuration modulesConfiguration, + FileCollection featureMetadataConfig, + BwcVersions bwcVersions, + Configuration pluginsConfiguration, + Configuration extractedPluginsConfiguration, + ElasticsearchDistribution defaultDistro, + FileCollection defaultDistroFeatureMetadataConfig + ) { + SystemPropertyCommandLineArgumentProvider nonInputSystemProperties = task.getExtensions() + .getByType(SystemPropertyCommandLineArgumentProvider.class); + + task.dependsOn(integTestDistro, modulesConfiguration); + registerDistributionInputs(task, integTestDistro); + + // Pass feature metadata on to tests + task.getInputs().files(featureMetadataConfig).withPathSensitivity(PathSensitivity.NONE); + nonInputSystemProperties.systemProperty(TESTS_FEATURES_METADATA_PATH, () -> featureMetadataConfig.getAsPath()); + + // Enable parallel execution for these tests since each test gets its own cluster + task.setMaxParallelForks(task.getProject().getGradle().getStartParameter().getMaxWorkerCount() / 2); + nonInputSystemProperties.systemProperty(TESTS_MAX_PARALLEL_FORKS_SYSPROP, () -> String.valueOf(task.getMaxParallelForks())); + + // Disable test failure reporting since this stuff is now captured in build scans + task.getExtensions().getByType(ErrorReportingTestListener.class).setDumpOutputOnFailure(false); + + // Disable the security manager and syscall filter since the test framework needs to fork processes + task.systemProperty("tests.security.manager", "false"); + task.systemProperty("tests.system_call_filter", "false"); + + // Pass minimum wire compatible version which is used by upgrade tests + task.systemProperty(MINIMUM_WIRE_COMPATIBLE_VERSION_SYSPROP, bwcVersions.getMinimumWireCompatibleVersion()); + + // Register plugins and modules as task inputs and pass paths as system properties to tests + var modulePath = project.getObjects().fileCollection().from(modulesConfiguration); + nonInputSystemProperties.systemProperty(TESTS_CLUSTER_MODULES_PATH_SYSPROP, modulePath::getAsPath); + registerConfigurationInputs(task, modulesConfiguration.getName(), modulePath); + var pluginPath = project.getObjects().fileCollection().from(pluginsConfiguration); + nonInputSystemProperties.systemProperty(TESTS_CLUSTER_PLUGINS_PATH_SYSPROP, pluginPath::getAsPath); + registerConfigurationInputs( + task, + extractedPluginsConfiguration.getName(), + project.getObjects().fileCollection().from(extractedPluginsConfiguration) + ); - nonInputSystemProperties.systemProperty( - DEFAULT_DISTRIBUTION_SYSPROP, - providerFactory.provider(() -> defaultDistro.getExtracted().getSingleFile().getPath()) + // Wire up integ-test distribution by default for all test tasks + FileCollection extracted = integTestDistro.getExtracted(); + nonInputSystemProperties.systemProperty(INTEG_TEST_DISTRIBUTION_SYSPROP, () -> extracted.getSingleFile().getPath()); + + // Add `usesDefaultDistribution()` extension method to test tasks to indicate they require the default distro + task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure(task) { + @Override + public Void call(Object... args) { + if (reasonForUsageProvided(args) == false) { + throw new IllegalArgumentException( + "Reason for using `usesDefaultDistribution` required.\nUse usesDefaultDistribution(\"reason why default distro is required here\")." ); + } + task.dependsOn(defaultDistro); + registerDistributionInputs(task, defaultDistro); - // If we are using the default distribution we need to register all module feature metadata - task.getInputs().files(defaultDistroFeatureMetadataConfig).withPathSensitivity(PathSensitivity.NONE); - nonInputSystemProperties.systemProperty(TESTS_FEATURES_METADATA_PATH, defaultDistroFeatureMetadataConfig::getAsPath); + nonInputSystemProperties.systemProperty( + DEFAULT_DISTRIBUTION_SYSPROP, + providerFactory.provider(() -> defaultDistro.getExtracted().getSingleFile().getPath()) + ); - return null; - } + // If we are using the default distribution we need to register all module feature metadata + task.getInputs().files(defaultDistroFeatureMetadataConfig).withPathSensitivity(PathSensitivity.NONE); + nonInputSystemProperties.systemProperty(TESTS_FEATURES_METADATA_PATH, defaultDistroFeatureMetadataConfig::getAsPath); - private static boolean reasonForUsageProvided(Object[] args) { - return args.length == 1 && args[0] instanceof String && ((String) args[0]).isBlank() == false; - } - }); + return null; + } - // Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution - task.getExtensions().getExtraProperties().set("usesBwcDistribution", new Closure(task) { - @Override - public Void call(Object... args) { - if (args.length != 1 || args[0] instanceof Version == false) { - throw new IllegalArgumentException("Expected exactly one argument of type org.elasticsearch.gradle.Version"); - } + private static boolean reasonForUsageProvided(Object[] args) { + return args.length == 1 && args[0] instanceof String && ((String) args[0]).isBlank() == false; + } + }); - Version version = (Version) args[0]; - boolean isReleased = bwcVersions.unreleasedInfo(version) == null && version.toString().equals("0.0.0") == false; - String versionString = version.toString(); - ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString); + // Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution + task.getExtensions().getExtraProperties().set("usesBwcDistribution", new Closure(task) { + @Override + public Void call(Object... args) { + if (args.length != 1 || args[0] instanceof Version == false) { + throw new IllegalArgumentException("Expected exactly one argument of type org.elasticsearch.gradle.Version"); + } - task.dependsOn(bwcDistro); - registerDistributionInputs(task, bwcDistro); + Version version = (Version) args[0]; + boolean isReleased = bwcVersions.unreleasedInfo(version) == null && version.toString().equals("0.0.0") == false; + String versionString = version.toString(); + ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString); - nonInputSystemProperties.systemProperty( - (isReleased ? BWC_RELEASED_DISTRIBUTION_SYSPROP_PREFIX : BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX) + versionString, - providerFactory.provider(() -> bwcDistro.getExtracted().getSingleFile().getPath()) - ); + task.dependsOn(bwcDistro); + registerDistributionInputs(task, bwcDistro); - if (version.getMajor() > 0 && version.before(bwcVersions.getMinimumWireCompatibleVersion())) { - // If we are upgrade testing older versions we also need to upgrade to 7.last - this.call(bwcVersions.getMinimumWireCompatibleVersion()); - } - return null; + nonInputSystemProperties.systemProperty( + (isReleased ? BWC_RELEASED_DISTRIBUTION_SYSPROP_PREFIX : BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX) + versionString, + providerFactory.provider(() -> bwcDistro.getExtracted().getSingleFile().getPath()) + ); + + if (version.getMajor() > 0 && version.before(bwcVersions.getMinimumWireCompatibleVersion())) { + // If we are upgrade testing older versions we also need to upgrade to 7.last + this.call(bwcVersions.getMinimumWireCompatibleVersion()); } - }); + return null; + } }); } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java new file mode 100644 index 0000000000000..3e6e6b2704968 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java @@ -0,0 +1,14 @@ +/* + * 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.gradle.internal.test.rest; + +import org.gradle.api.plugins.jvm.JvmTestSuite; + +public interface RestTestSuite extends JvmTestSuite {} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java.new b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java.new new file mode 100644 index 0000000000000..e7a960e9f81b2 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestSuite.java.new @@ -0,0 +1,26 @@ +package org.elasticsearch.gradle.internal.test.rest; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import org.gradle.api.plugins.jvm.JvmTestSuite; + +public interface RestTestSuite extends JvmTestSuite { +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java new file mode 100644 index 0000000000000..d5fe7a11fe959 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java @@ -0,0 +1,12 @@ +/* + * 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.gradle.internal.test.rest; + +interface YamlRestTestSuite extends RestTestSuite {} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java.new b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java.new new file mode 100644 index 0000000000000..e11f060701645 --- /dev/null +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/YamlRestTestSuite.java.new @@ -0,0 +1,24 @@ +package org.elasticsearch.gradle.internal.test.rest; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +public interface YamlRestTestSuite extends RestTestSuite { +} diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/testfixtures/TestFixturesDeployPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/testfixtures/TestFixturesDeployPlugin.java index 08484346e6908..6b92f0d90bd4a 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/testfixtures/TestFixturesDeployPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/testfixtures/TestFixturesDeployPlugin.java @@ -42,7 +42,7 @@ private static void registerDeployTaskPerFixture( NamedDomainObjectContainer fixtures, boolean isCi ) { - fixtures.all( + fixtures.configureEach( fixture -> project.getTasks() .register("deploy" + StringUtils.capitalize(fixture.getName()) + "DockerImage", DockerBuildTask.class, task -> { task.getDockerContext().fileValue(fixture.getDockerContext().get()); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java index 8068a8fd9801f..9332f08291dcf 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/util/GradleUtils.java @@ -14,8 +14,7 @@ import org.gradle.api.Task; import org.gradle.api.UnknownTaskException; import org.gradle.api.artifacts.Configuration; -import org.gradle.api.artifacts.ModuleDependency; -import org.gradle.api.artifacts.ProjectDependency; +import org.gradle.api.artifacts.ExternalModuleDependency; import org.gradle.api.plugins.JavaBasePlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.plugins.JavaPluginExtension; @@ -196,11 +195,9 @@ public static boolean isModuleProject(String projectPath) { } public static void disableTransitiveDependencies(Configuration config) { - config.getDependencies().all(dep -> { - if (dep instanceof ModuleDependency - && dep instanceof ProjectDependency == false - && dep.getGroup().startsWith("org.elasticsearch") == false) { - ((ModuleDependency) dep).setTransitive(false); + config.getDependencies().withType(ExternalModuleDependency.class).configureEach(dep -> { + if (dep.getGroup().startsWith("org.elasticsearch") == false) { + dep.setTransitive(false); } }); } diff --git a/build.gradle b/build.gradle index d5fc7ef8ecfb1..f2b66a950132a 100644 --- a/build.gradle +++ b/build.gradle @@ -397,19 +397,6 @@ allprojects { tasks.matching { it.name.equals('integTest') }.configureEach { integTestTask -> integTestTask.mustRunAfter tasks.matching { it.name.equals("test") } } - -/* configurations.matching { it.canBeResolved }.all { Configuration configuration -> - dependencies.matching { it instanceof ProjectDependency }.all { ProjectDependency dep -> - Project upstreamProject = dep.dependencyProject - if (project.path != upstreamProject?.path) { - for (String taskName : ['test', 'integTest']) { - project.tasks.matching { it.name == taskName }.configureEach { task -> - task.shouldRunAfter(upstreamProject.tasks.matching { upStreamTask -> upStreamTask.name == taskName }) - } - } - } - } - }*/ } apply plugin: 'elasticsearch.formatting' diff --git a/modules/build.gradle b/modules/build.gradle index be84095340422..52f012e14e3ad 100644 --- a/modules/build.gradle +++ b/modules/build.gradle @@ -9,7 +9,6 @@ configure(subprojects.findAll { it.parent.path == project.path }) { group = 'org.elasticsearch.plugin' // for modules which publish client jars - // apply plugin: 'elasticsearch.internal-testclusters' apply plugin: 'elasticsearch.internal-es-plugin' apply plugin: 'elasticsearch.internal-test-artifact' diff --git a/modules/repository-s3/build.gradle b/modules/repository-s3/build.gradle index 9f77d2489cb81..232db69143766 100644 --- a/modules/repository-s3/build.gradle +++ b/modules/repository-s3/build.gradle @@ -6,16 +6,15 @@ * your election, the "Elastic License 2.0", the "GNU Affero General Public * License v3.0 only", or the "Server Side Public License, v 1". */ -import org.apache.tools.ant.filters.ReplaceTokens -import org.elasticsearch.gradle.internal.test.InternalClusterTestPlugin +org.elasticsearch.gradle.internal.test.rest.RestTestSuite -apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.internal-cluster-test' +apply plugin: 'elasticsearch.internal-yaml-rest-test' apply plugin: 'elasticsearch.internal-java-rest-test' esplugin { description = 'The S3 repository plugin adds S3 repositories' - classname ='org.elasticsearch.repositories.s3.S3RepositoryPlugin' + classname = 'org.elasticsearch.repositories.s3.S3RepositoryPlugin' } dependencies { @@ -60,32 +59,152 @@ dependencies { testImplementation project(':test:fixtures:s3-fixture') testImplementation "software.amazon.awssdk:endpoints-spi:${versions.awsv2sdk}" +} - internalClusterTestImplementation project(':test:fixtures:aws-fixture-utils') - internalClusterTestImplementation project(':test:fixtures:minio-fixture') - internalClusterTestRuntimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}" - - yamlRestTestImplementation project(':modules:repository-s3') - yamlRestTestImplementation project(':test:fixtures:aws-fixture-utils') - yamlRestTestImplementation project(':test:fixtures:s3-fixture') - yamlRestTestImplementation project(':test:fixtures:testcontainer-utils') - yamlRestTestImplementation project(':test:framework') - yamlRestTestRuntimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}" - - javaRestTestImplementation project(':modules:repository-s3') - javaRestTestImplementation project(':test:fixtures:aws-fixture-utils') - javaRestTestImplementation project(':test:fixtures:aws-sts-fixture') - javaRestTestImplementation project(':test:fixtures:ec2-imds-fixture') - javaRestTestImplementation project(':test:fixtures:minio-fixture') - javaRestTestImplementation project(':test:fixtures:s3-fixture') - javaRestTestImplementation project(':test:fixtures:testcontainer-utils') - javaRestTestImplementation project(':test:framework') - javaRestTestRuntimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}" +tasks.named('check') { + // TODO revisit to be the default in ES + dependsOn tasks.withType(Test) +} + +testing { + suites { + configureEach { + // common configuration for all test suites in this project + dependencies { + implementation project() + implementation project(':test:framework') + } + } + test { + dependencies { + implementation(project(':test:fixtures:s3-fixture')) + implementation "software.amazon.awssdk:endpoints-spi:${versions.awsv2sdk}" + } + } + // test suite defined by InternalJavaRestTestPlugin + internalClusterTest { + dependencies { + implementation project(':test:fixtures:minio-fixture') + implementation project(':test:fixtures:aws-fixture-utils') + runtimeOnly "org.slf4j:slf4j-simple:${versions.slf4j}" + } + targets { + all { + testTask.configure { + // TODO: remove once https://github.com/elastic/elasticsearch/issues/101608 is fixed + systemProperty 'es.insecure_network_trace_enabled', 'true' + } + } + } + } + // test suite for the java rest tests provided by the InternalJavaRestTestPlugin + javaRestTest { + dependencies { + implementation project(':test:fixtures:aws-fixture-utils') + implementation project(':test:fixtures:s3-fixture') + implementation project(':test:fixtures:testcontainer-utils') + implementation project(':test:fixtures:aws-sts-fixture') + implementation project(':test:fixtures:ec2-imds-fixture') + implementation project(':test:fixtures:minio-fixture') + implementation project(':test:fixtures:testcontainer-utils') + implementation "software.amazon.awssdk:s3:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:endpoints-spi:${versions.awsv2sdk}" + } + } + // test suite for the Yaml rest tests provided by the InternalYamlRestTestPlugin + yamlRestTest { + dependencies { + implementation project() + implementation project(':test:fixtures:aws-fixture-utils') + implementation project(':test:fixtures:s3-fixture') + implementation project(':test:fixtures:testcontainer-utils') + } + } + // Add-hoc test suites require to be passed a type. (usually JvmTestSuite) + webIdentityTokenTest(JvmTestSuite) { + dependencies { + implementation project(':server') + implementation "software.amazon.awssdk:auth:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:utils:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}" + + } + targets { + all { + testTask.configure { + systemProperty 'es.allow_insecure_settings', 'true' + } + } + } + } + insecureCredentialsTest(JvmTestSuite) { + dependencies { + implementation "software.amazon.awssdk:auth:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:regions:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:s3:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:utils:${versions.awsv2sdk}" + } + targets { + all { + testTask.configure { + systemProperty 'es.allow_insecure_settings', 'true' + } + } + } + } + s3ThirdPartyTest(JvmTestSuite) { + dependencies { + implementation project(':test:fixtures:minio-fixture') + implementation project(':server') + implementation "software.amazon.awssdk:s3:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:utils:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}" + implementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}" + } + targets { + all { + testTask.configure { + boolean useFixture = false + String s3PermanentAccessKey = System.getenv("amazon_s3_access_key") + String s3PermanentSecretKey = System.getenv("amazon_s3_secret_key") + String s3PermanentBucket = System.getenv("amazon_s3_bucket") + String s3PermanentBasePath = System.getenv("amazon_s3_base_path") + + // If all these variables are missing then we are testing against the MinIO fixture instead, which has the following credentials hard-coded in. + if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3PermanentBasePath) { + useFixture = true + s3PermanentAccessKey = 's3_test_access_key' + s3PermanentSecretKey = 's3_test_secret_key' + s3PermanentBucket = 'bucket' + s3PermanentBasePath = 'base_path' + } + systemProperty("tests.use.fixture", Boolean.toString(useFixture)) + systemProperty 'test.s3.account', s3PermanentAccessKey + systemProperty 'test.s3.key', s3PermanentSecretKey + systemProperty 'test.s3.bucket', s3PermanentBucket + nonInputProperties.systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + buildParams.testSeed + + // test container accesses ~/.testcontainers.properties read + systemProperty "tests.security.manager", "false" + } + } + } + } + } } restResources { restApi { - include '_common', 'cluster', 'nodes', 'snapshot','indices', 'index', 'bulk', 'count' + include '_common', 'cluster', 'nodes', 'snapshot', 'indices', 'index', 'bulk', 'count' } } @@ -121,12 +240,7 @@ tasks.named("dependencyLicenses").configure { } esplugin.bundleSpec.from('config/repository-s3') { - into 'config' -} - -tasks.named("internalClusterTest").configure { - // TODO: remove once https://github.com/elastic/elasticsearch/issues/101608 is fixed - systemProperty 'es.insecure_network_trace_enabled', 'true' + into 'config' } tasks.named("thirdPartyAudit").configure { @@ -189,3 +303,5 @@ tasks.named("thirdPartyAudit").configure { 'software.amazon.eventstream.MessageDecoder' ) } + + diff --git a/modules/repository-s3/qa/build.gradle b/modules/repository-s3/qa/build.gradle deleted file mode 100644 index 1fec1c76430eb..0000000000000 --- a/modules/repository-s3/qa/build.gradle +++ /dev/null @@ -1,6 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ diff --git a/modules/repository-s3/qa/insecure-credentials/build.gradle b/modules/repository-s3/qa/insecure-credentials/build.gradle deleted file mode 100644 index bac3e00f5dadb..0000000000000 --- a/modules/repository-s3/qa/insecure-credentials/build.gradle +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -apply plugin: 'elasticsearch.java' - -dependencies { - testImplementation project(':modules:repository-s3') - testImplementation project(':test:framework') - testImplementation project(':server') - - testImplementation "software.amazon.awssdk:auth:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:regions:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:s3:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:utils:${versions.awsv2sdk}" -} - -tasks.named("test").configure { - systemProperty 'es.allow_insecure_settings', 'true' -} diff --git a/modules/repository-s3/qa/third-party/build.gradle b/modules/repository-s3/qa/third-party/build.gradle deleted file mode 100644 index acf912e6c0136..0000000000000 --- a/modules/repository-s3/qa/third-party/build.gradle +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -apply plugin: 'elasticsearch.java' - -dependencies { - testImplementation project(':modules:repository-s3') - testImplementation project(':test:fixtures:minio-fixture') - testImplementation project(':test:framework') - testImplementation project(':server') - - testImplementation "software.amazon.awssdk:aws-core:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:http-client-spi:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:s3:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:sdk-core:${versions.awsv2sdk}" - testImplementation "software.amazon.awssdk:utils:${versions.awsv2sdk}" -} - -boolean useFixture = false -String s3PermanentAccessKey = System.getenv("amazon_s3_access_key") -String s3PermanentSecretKey = System.getenv("amazon_s3_secret_key") -String s3PermanentBucket = System.getenv("amazon_s3_bucket") -String s3PermanentBasePath = System.getenv("amazon_s3_base_path") - -// If all these variables are missing then we are testing against the MinIO fixture instead, which has the following credentials hard-coded in. - -if (!s3PermanentAccessKey && !s3PermanentSecretKey && !s3PermanentBucket && !s3PermanentBasePath) { - useFixture = true - s3PermanentAccessKey = 's3_test_access_key' - s3PermanentSecretKey = 's3_test_secret_key' - s3PermanentBucket = 'bucket' - s3PermanentBasePath = 'base_path' -} - -tasks.named("test").configure { - systemProperty("tests.use.fixture", Boolean.toString(useFixture)) - systemProperty 'test.s3.account', s3PermanentAccessKey - systemProperty 'test.s3.key', s3PermanentSecretKey - systemProperty 'test.s3.bucket', s3PermanentBucket - nonInputProperties.systemProperty 'test.s3.base', s3PermanentBasePath + "_third_party_tests_" + buildParams.testSeed - - // test container accesses ~/.testcontainers.properties read - systemProperty "tests.security.manager", "false" -} - -tasks.register("s3ThirdPartyTest") { - dependsOn "test" -} diff --git a/modules/repository-s3/qa/web-identity-token/build.gradle b/modules/repository-s3/qa/web-identity-token/build.gradle deleted file mode 100644 index b87c52663d241..0000000000000 --- a/modules/repository-s3/qa/web-identity-token/build.gradle +++ /dev/null @@ -1,20 +0,0 @@ -/* - * 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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -apply plugin: 'elasticsearch.java' - -dependencies { - testImplementation project(':modules:repository-s3') - testImplementation project(':test:framework') - testImplementation project(':server') - testImplementation "software.amazon.awssdk:auth:${versions.awsv2sdk}" - implementation "software.amazon.awssdk:identity-spi:${versions.awsv2sdk}" -} - -tasks.named("test").configure { - environment 'AWS_REGION', 'es-test-region' -} diff --git a/modules/repository-s3/qa/insecure-credentials/src/test/java/org/elasticsearch/repositories/s3/AmazonS3Wrapper.java b/modules/repository-s3/src/insecureCredentialsTest/java/org/elasticsearch/repositories/s3/AmazonS3Wrapper.java similarity index 100% rename from modules/repository-s3/qa/insecure-credentials/src/test/java/org/elasticsearch/repositories/s3/AmazonS3Wrapper.java rename to modules/repository-s3/src/insecureCredentialsTest/java/org/elasticsearch/repositories/s3/AmazonS3Wrapper.java diff --git a/modules/repository-s3/qa/insecure-credentials/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java b/modules/repository-s3/src/insecureCredentialsTest/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java similarity index 100% rename from modules/repository-s3/qa/insecure-credentials/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java rename to modules/repository-s3/src/insecureCredentialsTest/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java diff --git a/modules/repository-s3/src/insecureCredentialsTest/resources/plugin-security.policy b/modules/repository-s3/src/insecureCredentialsTest/resources/plugin-security.policy new file mode 100644 index 0000000000000..4b3e89e3f60e3 --- /dev/null +++ b/modules/repository-s3/src/insecureCredentialsTest/resources/plugin-security.policy @@ -0,0 +1,3 @@ +grant { + permission java.lang.RuntimePermission "accessDeclaredMembers"; +}; diff --git a/modules/repository-s3/qa/third-party/src/test/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java b/modules/repository-s3/src/s3ThirdPartyTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java similarity index 100% rename from modules/repository-s3/qa/third-party/src/test/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java rename to modules/repository-s3/src/s3ThirdPartyTest/java/org/elasticsearch/repositories/s3/S3RepositoryThirdPartyTests.java diff --git a/modules/repository-s3/qa/web-identity-token/src/test/java/org/elasticsearch/repositories/s3/CustomWebIdentityTokenCredentialsProviderTests.java b/modules/repository-s3/src/webIdentityTokenTest/java/org/elasticsearch/repositories/s3/CustomWebIdentityTokenCredentialsProviderTests.java similarity index 100% rename from modules/repository-s3/qa/web-identity-token/src/test/java/org/elasticsearch/repositories/s3/CustomWebIdentityTokenCredentialsProviderTests.java rename to modules/repository-s3/src/webIdentityTokenTest/java/org/elasticsearch/repositories/s3/CustomWebIdentityTokenCredentialsProviderTests.java diff --git a/modules/repository-s3/src/webIdentityTokenTest/resources/plugin-security.policy b/modules/repository-s3/src/webIdentityTokenTest/resources/plugin-security.policy new file mode 100644 index 0000000000000..4b3e89e3f60e3 --- /dev/null +++ b/modules/repository-s3/src/webIdentityTokenTest/resources/plugin-security.policy @@ -0,0 +1,3 @@ +grant { + permission java.lang.RuntimePermission "accessDeclaredMembers"; +}; diff --git a/modules/transport-netty4/build.gradle b/modules/transport-netty4/build.gradle index 145a4405d05f0..ec57272f46ccf 100644 --- a/modules/transport-netty4/build.gradle +++ b/modules/transport-netty4/build.gradle @@ -30,7 +30,7 @@ esplugin { // exclude transitively pulled in version via the esplugin plugin to always build from fresh sources and make jar-hell checks pass configurations { - [testCompileClasspath, testRuntimeClasspath, internalClusterTestCompileClasspath, internalClusterTestRuntimeClasspath].each { + [testCompileClasspath, testRuntimeClasspath].each { it.exclude group: 'org.elasticsearch.plugin', module: 'transport-netty4' } } @@ -237,3 +237,4 @@ tasks.named("thirdPartyAudit").configure { tasks.named('forbiddenApisMain').configure { signaturesFiles += files('forbidden/netty-signatures.txt') } +