diff --git a/dev-tools/tests/gradle-dependency-recovery-contract.sh b/dev-tools/tests/gradle-dependency-recovery-contract.sh index 7971441abb..b213a4424a 100644 --- a/dev-tools/tests/gradle-dependency-recovery-contract.sh +++ b/dev-tools/tests/gradle-dependency-recovery-contract.sh @@ -456,6 +456,87 @@ for mutation in auth wrong-origin wrong-artifact truncated-chain extra-coordinat assert_no_retry done +# The common-test-support failure carries multiple Maven Central JAR chains +# under one test fixtures classpath root, before any fixture compilation. +write_test_fixtures_429_cause() { + cat > "$CASE_DIR/cause.log" <<'LOG' +> Task :buildSrc:compileKotlin FROM-CACHE +FAILURE: Build failed with an exception. +* What went wrong: +Configuration cache state could not be cached: field `classpath` of task `:common-test-support:compileTestFixturesJava` of type `org.gradle.api.tasks.compile.JavaCompile`: error writing value of type 'org.gradle.api.internal.artifacts.configurations.DefaultResolvableConfiguration' +> Could not resolve all files for configuration ':common-test-support:testFixturesCompileClasspath'. + > Could not download spring-grpc-spring-boot-starter-1.0.3.jar (org.springframework.grpc:spring-grpc-spring-boot-starter:1.0.3) + > Could not get resource 'https://repo.maven.apache.org/maven2/org/springframework/grpc/spring-grpc-spring-boot-starter/1.0.3/spring-grpc-spring-boot-starter-1.0.3.jar'. + > Could not GET 'https://repo.maven.apache.org/maven2/org/springframework/grpc/spring-grpc-spring-boot-starter/1.0.3/spring-grpc-spring-boot-starter-1.0.3.jar'. + > Received status code 429 from server: Too Many Requests + > Could not download spring-boot-starter-webflux-4.1.1.jar (org.springframework.boot:spring-boot-starter-webflux:4.1.1) + > Could not get resource 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-webflux/4.1.1/spring-boot-starter-webflux-4.1.1.jar'. + > Could not GET 'https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-webflux/4.1.1/spring-boot-starter-webflux-4.1.1.jar'. + > Received status code 429 from server: Too Many Requests + > Could not download netty-transport-native-epoll-4.2.20.Final-linux-x86_64.jar (io.netty:netty-transport-native-epoll:4.2.20.Final) + > Could not get resource 'https://repo.maven.apache.org/maven2/io/netty/netty-transport-native-epoll/4.2.20.Final/netty-transport-native-epoll-4.2.20.Final-linux-x86_64.jar'. + > Could not GET 'https://repo.maven.apache.org/maven2/io/netty/netty-transport-native-epoll/4.2.20.Final/netty-transport-native-epoll-4.2.20.Final-linux-x86_64.jar'. + > Received status code 429 from server: Too Many Requests + > Could not download guava-33.4.8-jre.jar (com.google.guava:guava:33.4.8-android) + > Could not get resource 'https://repo.maven.apache.org/maven2/com/google/guava/guava/33.4.8-jre/guava-33.4.8-jre.jar'. + > Could not GET 'https://repo.maven.apache.org/maven2/com/google/guava/guava/33.4.8-jre/guava-33.4.8-jre.jar'. + > Received status code 429 from server: Too Many Requests +[Incubating] Problems report is available at: file:///tmp/firemud-gradle/build/reports/problems/problems-report.html +* Try: +> Run with --stacktrace option to get the stack trace. +BUILD FAILED in 4s +LOG +} + +write_test_fixtures_429_wrapper() { + # shellcheck disable=SC2016 + write_wrapper 'if [[ "$call_count" -eq 1 ]]; then cat "$CASE_DIR/cause.log"; exit 1; fi; echo refreshed-test-fixtures; exit 0' +} + +for retry_after in absent 08; do + new_case "test-fixtures-maven-429-$retry_after" + write_test_fixtures_429_cause + if [[ "$retry_after" != absent ]]; then + sed -i "/^[*] Try:/i Retry-After: $retry_after" "$CASE_DIR/cause.log" + fi + write_test_fixtures_429_wrapper + run_case common-test-support 0 + assert_call_count 2 + assert_call 1 "--max-workers=2 -Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 :common-test-support:check -PfullCheck --profile --info --console=plain" + assert_call 2 "--refresh-dependencies --max-workers=2 -Dorg.gradle.jvmargs=-Xmx2500m -Dfile.encoding=UTF-8 :common-test-support:check -PfullCheck --profile --info --console=plain" + if [[ "$retry_after" == absent ]]; then + assert_rate_limit_delay + else + [[ "$(cat "$CASE_DIR/sleeps")" == 8 ]] || fail "fixture HTTP 429 did not honor Retry-After" + fi + assert_output_contains "refreshed-test-fixtures" +done + +for mutation in unknown wrong-module wrong-configuration extra-configuration wrong-type wrong-origin wrong-url wrong-filename \ + truncated-chain mixed-context compile-started test-failure altered-report long-retry-after; do + new_case "test-fixtures-maven-429-$mutation" + write_test_fixtures_429_cause + case "$mutation" in + unknown) sed -i '/^[*] Try:/i > Unknown repository policy failure' "$CASE_DIR/cause.log" ;; + wrong-module) sed -i 's/:common-test-support:testFixturesCompileClasspath/:common-web-support:testFixturesCompileClasspath/' "$CASE_DIR/cause.log" ;; + wrong-configuration) sed -i 's/:testFixturesCompileClasspath/:testCompileClasspath/' "$CASE_DIR/cause.log" ;; + extra-configuration) sed -i "/^[*] Try:/i > Could not resolve all files for configuration ':common-test-support:testCompileClasspath'." "$CASE_DIR/cause.log" ;; + wrong-type) sed -i 's/org\.gradle\.api\.tasks\.compile\.JavaCompile/example.JavaCompile/' "$CASE_DIR/cause.log" ;; + wrong-origin) sed -i '/https:.*webflux/s/repo.maven.apache.org/repository.invalid/' "$CASE_DIR/cause.log" ;; + wrong-url) sed -i '/Could not GET.*webflux/s/webflux-4.1.1.jar/webflux-4.1.0.jar/' "$CASE_DIR/cause.log" ;; + wrong-filename) sed -i '/Could not download.*webflux/s/webflux-4\.1\.1\.jar/webflux-4.1.0.jar/' "$CASE_DIR/cause.log" ;; + truncated-chain) sed -i '/Could not GET.*webflux/d' "$CASE_DIR/cause.log" ;; + mixed-context) sed -i '/^[*] Try:/i Required by:\nproject :unrelated' "$CASE_DIR/cause.log" ;; + compile-started) sed -i '1i > Task :common-test-support:compileTestFixturesJava FAILED' "$CASE_DIR/cause.log" ;; + test-failure) sed -i '1i > Task :common-test-support:test FAILED' "$CASE_DIR/cause.log" ;; + altered-report) sed -i '/^\[Incubating\]/s/$/ (additional failure)/' "$CASE_DIR/cause.log" ;; + long-retry-after) sed -i '/^[*] Try:/i Retry-After: 31' "$CASE_DIR/cause.log" ;; + esac + write_test_fixtures_429_wrapper + run_case common-test-support 1 + assert_no_retry +done + # Mismatched ownership, configuration, or another fatal cause must not retry. for mutation in wrong-module wrong-configuration extra-cause compile-started; do new_case "protobuf-resolution-invalid-$mutation" diff --git a/dev-tools/validation/run-gradle-with-dependency-recovery.sh b/dev-tools/validation/run-gradle-with-dependency-recovery.sh index 2c1ba14b16..dc9b70fa4a 100644 --- a/dev-tools/validation/run-gradle-with-dependency-recovery.sh +++ b/dev-tools/validation/run-gradle-with-dependency-recovery.sh @@ -151,16 +151,16 @@ classify_failure_body() { next } - # A Java annotation processor resolved before compilation can fail at - # the Maven Central JAR download. Require its complete matching chain. - if (processor_download_step) { - if (processor_download_step == 1 && line == "> Could not get resource " quote processor_jar_url quote ".") { - processor_download_step = 2 - } else if (processor_download_step == 2 && line == "> Could not GET " quote processor_jar_url quote ".") { - processor_download_step = 3 - } else if (processor_download_step == 3 && line == "> Received status code 429 from server: Too Many Requests") { - processor_download_step = 0 - processor_downloads++ + # Require each pre-compile Maven Central JAR download to report the + # complete matching 429 chain, not just a coordinate or status line. + if (jar_download_step) { + if (jar_download_step == 1 && line == "> Could not get resource " quote jar_url quote ".") { + jar_download_step = 2 + } else if (jar_download_step == 2 && line == "> Could not GET " quote jar_url quote ".") { + jar_download_step = 3 + } else if (jar_download_step == 3 && line == "> Received status code 429 from server: Too Many Requests") { + jar_download_step = 0 + jar_downloads++ coordinates++ repository_requests += 2 transient++ @@ -169,22 +169,58 @@ classify_failure_body() { } next } - if (wrapped_cache_cause && resolved_configuration == expected_wrapped_configuration && + if ((fixtures_resolver || (wrapped_cache_cause && resolved_configuration == expected_wrapped_configuration)) && line ~ /^> Could not download [[:alnum:]_.-]+\.jar \([[:alnum:]_-]+(\.[[:alnum:]_-]+)*:[[:alnum:]_.-]+:[0-9][[:alnum:]_.-]*\)$/) { artifact_coordinate = line sub(/^.*\(/, "", artifact_coordinate) sub(/\)$/, "", artifact_coordinate) - split(artifact_coordinate, processor, ":") - processor_jar = processor[2] "-" processor[3] ".jar" - if (line != "> Could not download " processor_jar " (" artifact_coordinate ")") { + split(artifact_coordinate, jar_coordinate, ":") + jar_name = line + sub(/^> Could not download /, "", jar_name) + sub(/ .+$/, "", jar_name) + jar_version = jar_coordinate[3] + # Gradle may report the requested Guava Android coordinate while + # the JVM variant resolves its matching JRE artifact and URL. + if (fixtures_resolver && jar_coordinate[1] == "com.google.guava" && + jar_coordinate[2] == "guava" && jar_version ~ /-android$/) { + jre_version = jar_version + sub(/-android$/, "-jre", jre_version) + if (jar_name == "guava-" jre_version ".jar") jar_version = jre_version + } + jar_stem = jar_coordinate[2] "-" jar_version + # Fixture classpaths can resolve platform-specific classifier JARs. + classified_fixture_jar = fixtures_resolver && index(jar_name, jar_stem "-") == 1 && + substr(jar_name, length(jar_stem) + 2) ~ /^[[:alnum:]][[:alnum:]_.-]*\.jar$/ + if ((jar_name != jar_stem ".jar" && !classified_fixture_jar) || + (fixtures_resolver && (jar_coordinate[2] == "." || jar_coordinate[2] == ".."))) { invalid++ } - gsub(/\./, "/", processor[1]) - processor_jar_url = "https://repo.maven.apache.org/maven2/" processor[1] "/" processor[2] "/" processor[3] "/" processor_jar - processor_download_step = 1 + gsub(/\./, "/", jar_coordinate[1]) + jar_url = "https://repo.maven.apache.org/maven2/" jar_coordinate[1] "/" jar_coordinate[2] "/" jar_version "/" jar_name + jar_download_step = 1 next } + if (line == "1 problem was found storing the configuration cache.") { + cache_summary++ + next + } + if (line ~ /^See the complete report at file:.*configuration-cache\//) { + next + } + if (line ~ /^\[Incubating\] Problems report is available at: file:.*\/build\/reports\/problems\/problems-report\.html$/ || + line == ("> If the artifact you are trying to retrieve can be found in the repository but without metadata in " quote "Maven POM" quote " format, you need to adjust the " quote "metadataSources { ... }" quote " of the repository declaration.") || + line == "Deprecated Gradle features were used in this build, making it incompatible with Gradle 10." || + line == "You can use \047--warning-mode all\047 to show the individual deprecation warnings and determine if they come from your own scripts or plugins." || + line ~ /^For more on this, please refer to https:\/\/docs\.gradle\.org\/[0-9]+\.[0-9]+\.[0-9]+\/userguide\/command_line_interface\.html#sec:command_line_warnings in the Gradle documentation\.$/ || + line ~ /^[0-9]+ actionable tasks: [0-9]+ executed, [0-9]+ from cache$/ || + line ~ /^Retry-After: .+$/) { + next + } + # A fixture JAR failure may have only two other cause lines: its typed + # cache wrapper and the matching resolver root. Keep legacy parsing below. + other_cause_lines++ + # buildSrc plugin resolution may wrap a pinned dependency HTTP 429 in # configuration, repository-disablement and parent-POM context. These # lines are admitted only together with that narrow boundary below. @@ -238,10 +274,6 @@ classify_failure_body() { next } - if (line == "1 problem was found storing the configuration cache.") { - cache_summary++ - next - } if (line ~ /^Configuration cache state could not be cached: field `classpath` of `org\.gradle\.process\.internal\.DefaultJavaExecSpec_Decorated` bean found in field `javaExecSpec` of task `:[^`]+:generateJooq` of type `org\.gradle\.api\.tasks\.JavaExec`: error writing value of type \047org\.gradle\.api\.internal\.file\.collections\.DefaultConfigurableFileCollection\047$/) { if (match(line, /task `:[^`]+:generateJooq`/)) { task_reference = substr(line, RSTART, RLENGTH) @@ -292,6 +324,14 @@ classify_failure_body() { wrapped_resolution_causes++ next } + # Test fixture inputs can fail during configuration-cache serialization. + # Only the exact typed wrapper and its same-module resolver admit JARs. + if (line ~ /^Configuration cache state could not be cached: field `classpath` of task `:[[:alnum:]-]+:compileTestFixturesJava` of type `org\.gradle\.api\.tasks\.compile\.JavaCompile`: error writing value of type \047org\.gradle\.api\.internal\.artifacts\.configurations\.DefaultResolvableConfiguration\047$/) { + module = line + sub(/^.* of task `/, "", module) + sub(/:compileTestFixturesJava`.*$/, "", module) + fixtures_configuration = module ":testFixturesCompileClasspath" + } if (line ~ /^Configuration cache state could not be cached: field `classpath` of task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/ || line ~ /^- Task `:[^`]+:compile[A-Za-z0-9]+` of type .*JavaCompile.*: error writing value of type .*DefaultResolvableConfiguration/) { if (match(line, /`:[^`]+:compile[A-Za-z0-9]+`/)) { @@ -306,20 +346,11 @@ classify_failure_body() { cache_cause++ next } - if (line ~ /^See the complete report at file:.*configuration-cache\//) { - next - } - if (line ~ /^\[Incubating\] Problems report is available at: file:.*\/build\/reports\/problems\/problems-report\.html$/ || - line == ("> If the artifact you are trying to retrieve can be found in the repository but without metadata in " quote "Maven POM" quote " format, you need to adjust the " quote "metadataSources { ... }" quote " of the repository declaration.") || - line == "Deprecated Gradle features were used in this build, making it incompatible with Gradle 10." || - line == "You can use \047--warning-mode all\047 to show the individual deprecation warnings and determine if they come from your own scripts or plugins." || - line ~ /^For more on this, please refer to https:\/\/docs\.gradle\.org\/[0-9]+\.[0-9]+\.[0-9]+\/userguide\/command_line_interface\.html#sec:command_line_warnings in the Gradle documentation\.$/ || - line ~ /^[0-9]+ actionable tasks: [0-9]+ executed, [0-9]+ from cache$/) { - next - } - if (line ~ /^> Could not resolve all (artifacts|files) for configuration .+\.$/) { resolver_roots++ + if (fixtures_configuration != "" && line == "> Could not resolve all files for configuration " quote fixtures_configuration quote ".") { + fixtures_resolver = 1 + } if (line ~ /(compileClasspath|testCompileClasspath|integrationTestCompileClasspath|crossServiceTestCompileClasspath)/) { compile_classpath_roots++ } @@ -381,7 +412,6 @@ classify_failure_body() { line ~ /^> Connection (reset|timed out)$/ || line ~ /^> SocketTimeoutException/ || line ~ /^Received status code (429|5[0-9][0-9]) from server/ || - line ~ /^Retry-After: .+$/ || line ~ /^(> )?There are [0-9]+ more failures with identical causes\.$/) { if (line ~ /^Received status code /) { transient++ @@ -403,10 +433,11 @@ classify_failure_body() { invalid++ } END { - if (invalid || processor_download_step || resolver_roots == 0 || coordinates == 0 || - (processor_downloads && - (coordinates != processor_downloads || transient != processor_downloads || - repository_requests != 2 * processor_downloads || searched || repository_urls)) || + if (invalid || jar_download_step || resolver_roots == 0 || coordinates == 0 || + (jar_downloads && + (coordinates != jar_downloads || transient != jar_downloads || + repository_requests != 2 * jar_downloads || searched || repository_urls || + (fixtures_resolver && other_cause_lines != 2))) || ((mavenrepo_disabled || protoc_connect_timeout) && (mavenrepo_disabled != 1 || protoc_connect_timeout != 1 || protoc_coordinates != 1 || protoc_pom_resource != 1 || protoc_pom_get != 1 || @@ -438,7 +469,7 @@ classify_failure_body() { !((transient && repository_requests) || (searched && repository_urls))) { exit 1 } - if (wrapped_resolution_causes) print "before-compile" + if (wrapped_resolution_causes || (fixtures_resolver && jar_downloads)) print "before-compile" exit 0 } ' "$log_path"