Skip to content

fix(flaky): HttpWaitStrategyTest.testWaitUntilReadyWithTlsAndAllowUnsecure - #12190

Draft
kiview wants to merge 1 commit into
mainfrom
claude/intelligent-fermat-95962u
Draft

kiview wants to merge 1 commit into
mainfrom
claude/intelligent-fermat-95962u

Conversation

@kiview

@kiview kiview commented Nov 30, 2026

Copy link
Copy Markdown
Member

Broken behaviour

HttpWaitStrategyTest.testWaitUntilReadyWithTlsAndAllowUnsecure sometimes fails on main with:

ContainerLaunchException: Container startup failed for image alpine:3.17
  Caused by: RetryCountExceededException: Retry limit hit with exception
    Caused by: ContainerLaunchException: Timed out waiting for URL to be accessible (https://localhost:32890/ should return HTTP 200)
      at HttpWaitStrategy.waitUntilReady(HttpWaitStrategy.java:320)

Failing attempt, then a pass on the Develocity retry in the same job: core (17), run 45899380012 @ 943bfd28. Because of failOnPassedAfterRetry = false, the job still showed green.

Root cause

The container command was apk add nmap-ncat; while true; do ... | ncat -lp 8080 --ssl; done. All of this ran inside the wait strategy's startup window, which AbstractWaitStrategyTest caps at 3 s (WAIT_TIMEOUT_MILLIS):

  1. Network dependence: apk add fetches the APKINDEX and the package from dl-cdn.alpinelinux.org at container start, so a slow mirror alone can use up the 3 s.
  2. CPU-bound key generation: with --ssl and no cert, ncat generates a temporary RSA key every time it starts, which adds more time on a busy shared runner.

None of the other HTTP tests in this class install anything at runtime. They use busybox nc, which is already in the image.

Fix

Test-only change. The test now runs on a small ImageFromDockerfile image built from alpine:3.17, where RUN installs nmap-ncat and openssl and generates a self-signed cert at build time. The container then only starts ncat --ssl --ssl-cert /cert.pem --ssl-key /key.pem, so the 3 s timeout covers just the listener. The test still checks the same behaviour (usingTls().allowInsecure() against a self-signed cert). Image builds happen before waitUntilReady and aren't bounded by the startup timeout.

Verification

  • ./gradlew :testcontainers:checkstyleTest :testcontainers:compileTestJava passes.
  • Formatted with the pinned prettier 2.5.1 and prettier-plugin-java 1.6.1. spotlessApply couldn't find Node in the sandbox where this was prepared.
  • ⚠️ Not run locally. That sandbox's egress policy blocks dl-cdn.alpinelinux.org (403), so neither the old nor the new version of this test can build or run there. testWaitUntilReadyWithTimeoutCausedBySslHandshakeError already does apk add in a Dockerfile and fails there the same way. The other 11 tests in the class passed in 5 of 5 local runs. This PR is a draft until CI confirms the test passes.

Context

Found by the automated weekly flaky-test report for main (2026-11-23 to 2026-11-30): 306 CI jobs and about 15.7k test executions scanned. This was the #1 flake: 1 of 21 executions failed (4.8%) in environments where the class otherwise passes, and about 3.6 s plus a re-run were spent on the retry.


Generated by Claude Code

The test ran `apk add nmap-ncat` as the container command, so the package
download from the Alpine mirror and ncat's ephemeral RSA key generation
both counted against the 3s startup timeout of the wait strategy. A slow
mirror made the HTTPS wait time out.

Build the image (ncat, openssl and a self-signed cert) up front with
ImageFromDockerfile so only the ncat listener starts within the timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015e4ZbWiZDuXFmb6UxExQJo
@coderabbitai

coderabbitai Bot commented Nov 30, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants