[Build] Require reason for usesDefaultDistribution (#124707)

This makes using usesDefaultDistribution in our test setup for explicit by requiring a reason why it's needed.
This is helpful as part of revisiting the need for all those usages in our code base.
This commit is contained in:
Rene Groeschke 2025-03-17 08:25:39 +01:00 committed by GitHub
parent a77bf7f1a6
commit ae569def9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
62 changed files with 80 additions and 71 deletions

View file

@ -47,7 +47,7 @@ plugins.withType(InternalJavaRestTestPlugin) {
tasks.withType(StandaloneRestIntegTestTask).configureEach {
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
classpath = sourceSets.javaRestTest.runtimeClasspath
usesDefaultDistribution()
usesDefaultDistribution("BWC tests require full distribution for now")
}
}

View file

@ -198,6 +198,11 @@ public class RestTestBasePlugin implements Plugin<Project> {
task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure<Void>(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);
@ -212,6 +217,10 @@ public class RestTestBasePlugin implements Plugin<Project> {
return null;
}
private static boolean reasonForUsageProvided(Object[] args) {
return args.length == 1 && args[0] instanceof String && ((String) args[0]).isBlank() == false;
}
});
// Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution

View file

@ -26,7 +26,7 @@ dependencies {
}
tasks.withType(StandaloneRestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
if (buildParams.inFipsJvm){

View file

@ -21,10 +21,10 @@ restResources {
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty 'es.queryable_built_in_roles_enabled', 'false'
}

View file

@ -33,7 +33,7 @@ restResources {
}
tasks.withType(StandaloneRestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
testClusters.configureEach {

View file

@ -111,7 +111,7 @@ tasks.named("dependencyLicenses").configure {
}
tasks.withType(RestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
buildParams.withFipsEnabledOnly(it)
jvmArgs '--add-exports', 'java.security.jgss/sun.security.krb5=ALL-UNNAMED'
}

View file

@ -13,5 +13,5 @@ apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.withType(StandaloneRestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -11,7 +11,7 @@ apply plugin: 'elasticsearch.legacy-yaml-rest-test'
apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}

View file

@ -19,6 +19,6 @@ esplugin {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}

View file

@ -19,6 +19,6 @@ esplugin {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}

View file

@ -15,7 +15,7 @@ dependencies {
}
tasks.withType(StandaloneRestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named("javaRestTest").configure {

View file

@ -42,7 +42,7 @@ public class LocalDistributionResolver implements DistributionResolver {
+ "tasks.named('"
+ taskName
+ "') {\n"
+ " usesDefaultDistribution()\n"
+ " usesDefaultDistribution(\"Reason why default distribution is required\")\n"
+ "}"
);
} else {

View file

@ -7,5 +7,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -55,7 +55,7 @@ if (buildParams.snapshotBuild == false) {
}
tasks.withType(StandaloneRestIntegTestTask).configureEach {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named("yamlRestTest").configure {

View file

@ -31,7 +31,7 @@ def supportedVersion = bwcVersion -> {
buildParams.bwcVersions.withWireCompatible(supportedVersion) { bwcVersion, baseName ->
def yamlRestTest = tasks.register("v${bwcVersion}#yamlRestTest", StandaloneRestIntegTestTask) {
usesDefaultDistribution()
usesDefaultDistribution("BWC tests require full distribution for now")
usesBwcDistribution(bwcVersion)
systemProperty("tests.old_cluster_version", bwcVersion)
testClassesDirs = sourceSets.yamlRestTest.output.classesDirs

View file

@ -25,10 +25,10 @@ artifacts {
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
if (buildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC

View file

@ -5,6 +5,6 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
}

View file

@ -25,14 +25,14 @@ artifacts {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
if (buildParams.inFipsJvm){

View file

@ -12,7 +12,7 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
if (buildParams.inFipsJvm){

View file

@ -3,7 +3,7 @@ apply plugin: 'elasticsearch.internal-java-rest-test'
apply plugin: 'elasticsearch.internal-test-artifact'
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
dependencies {

View file

@ -17,7 +17,7 @@ dependencies {
GradleUtils.extendSourceSet(project, "javaRestTest", "yamlRestTest")
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
restResources {
@ -30,6 +30,6 @@ restResources {
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
}

View file

@ -36,12 +36,12 @@ restResources {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
jvmArgs('--add-opens=java.base/java.nio=ALL-UNNAMED')
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
maxParallelForks = 1
}

View file

@ -20,10 +20,10 @@ artifacts {
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named('yamlRestCompatTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
if (buildParams.inFipsJvm){
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC

View file

@ -15,5 +15,5 @@ restResources {
}
tasks.named("yamlRestTest") {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -5,5 +5,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -398,6 +398,6 @@ tasks.named("thirdPartyAudit").configure {
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -9,5 +9,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -16,5 +16,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -32,7 +32,7 @@ dependencies {
}
tasks.named('yamlRestTest').configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
/**********************************

View file

@ -36,9 +36,9 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named('yamlRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -15,5 +15,5 @@ tasks.named("javaRestTest").configure {
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
buildParams.withFipsEnabledOnly(it)
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -15,5 +15,5 @@ tasks.named("javaRestTest").configure {
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
buildParams.withFipsEnabledOnly(it)
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -8,5 +8,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -39,7 +39,7 @@ if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty("tests.use.fixture", Boolean.toString(useFixture))
systemProperty 'test.s3.bucket', s3Bucket
systemProperty("s3AccessKey", s3AccessKey)

View file

@ -26,7 +26,7 @@ restResources {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
buildParams.withFipsEnabledOnly(it)
jvmArgs '--add-exports', 'java.security.jgss/sun.security.krb5=ALL-UNNAMED'
}

View file

@ -11,7 +11,7 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
restResources {

View file

@ -41,7 +41,7 @@ if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty("tests.use.fixture", Boolean.toString(useFixture))
systemProperty 'test.s3.bucket', s3Bucket
systemProperty("s3AccessKey", s3AccessKey)

View file

@ -15,5 +15,5 @@ restResources {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -8,5 +8,5 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -16,5 +16,5 @@ tasks.named("javaRestTest").configure {
// This test cluster is using a BASIC license and FIPS 140 mode is not supported in BASIC
buildParams.withFipsEnabledOnly(it)
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -17,5 +17,5 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -5,6 +5,6 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
it.onlyIf("snapshot build") { buildParams.snapshotBuild }
}

View file

@ -15,5 +15,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -15,6 +15,6 @@ dependencies {
boolean literalUsername = buildParams.random.nextBoolean()
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty 'test.literalUsername', literalUsername
}

View file

@ -25,5 +25,5 @@ dependencies {
tasks.named("javadoc").configure { enabled = false }
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -23,7 +23,7 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
tasks.named("javadoc").configure { enabled = false }

View file

@ -21,7 +21,7 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
// Test clusters run with security disabled
buildParams.withFipsEnabledOnly(it)
}

View file

@ -9,6 +9,6 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -14,5 +14,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -5,5 +5,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -39,7 +39,7 @@ if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty("tests.use.fixture", Boolean.toString(useFixture))
systemProperty 'test.s3.bucket', s3Bucket
systemProperty("s3AccessKey", s3AccessKey)

View file

@ -31,7 +31,7 @@ dependencies {
// Disable integration test if Fips mode
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
description = "Runs rest tests against an elasticsearch cluster with HDFS."
buildParams.withFipsEnabledOnly(it)
// required for krb5kdc-fixture to work

View file

@ -22,5 +22,5 @@ restResources {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -37,7 +37,7 @@ if (!s3AccessKey && !s3SecretKey && !s3Bucket && !s3BasePath) {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
systemProperty("tests.use.fixture", Boolean.toString(useFixture))
systemProperty 'test.s3.bucket', s3Bucket
systemProperty("s3AccessKey", s3AccessKey)

View file

@ -53,7 +53,7 @@ subprojects {
} else {
apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}
}

View file

@ -8,7 +8,7 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
description = "Runs rest tests against an elasticsearch cluster with Kerberos."
// required for krb5kdc-fixture to work
jvmArgs '--add-exports', 'java.security.jgss/sun.security.krb5=ALL-UNNAMED'

View file

@ -22,7 +22,7 @@ restResources {
}
tasks.named("yamlRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
ArrayList<String> blacklist = [
/* These tests don't work on multi-project yet - we need to go through each of them and make them work */
'^analytics/boxplot/*',

View file

@ -14,7 +14,7 @@ dependencies {
}
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
// test suite uses jks which is not supported in fips mode
buildParams.withFipsEnabledOnly(it)
}

View file

@ -6,5 +6,5 @@
apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.named('javaRestTest') {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -1,5 +1,5 @@
apply plugin: 'elasticsearch.internal-yaml-rest-test'
tasks.named("yamlRestTest") {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -1,5 +1,5 @@
apply plugin: 'elasticsearch.internal-java-rest-test'
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}

View file

@ -9,5 +9,5 @@ dependencies {
}
tasks.named("javaRestTest").configure {
usesDefaultDistribution()
usesDefaultDistribution("to be triaged")
}