Skip to content

fix(pulsar): increase wait strategy deadlines to fix random test time…#3600

Draft
ljluestc wants to merge 1 commit into
testcontainers:mainfrom
ljluestc:fix/pulsar-test-timeout-2886
Draft

fix(pulsar): increase wait strategy deadlines to fix random test time…#3600
ljluestc wants to merge 1 commit into
testcontainers:mainfrom
ljluestc:fix/pulsar-test-timeout-2886

Conversation

@ljluestc

Copy link
Copy Markdown

The Pulsar module used WithWaitStrategy which has a default 60s deadline. Pulsar is a heavy Java application that can take longer than 60s to start, especially in CI environments, causing random context deadline exceeded failures.

Changes:

  • Use WithWaitStrategyAndDeadline(2min) for default Run()
  • Use WithWaitStrategyAndDeadline(3min) for WithFunctionsWorker()
  • Use WithWaitStrategyAndDeadline(2min) for WithTransactions()
  • Add explicit WithStartupTimeout(2min) to HTTP wait strategies

Fixes #2886

What does this PR do?

Replaces WithWaitStrategy (which uses a hardcoded 60s deadline) with WithWaitStrategyAndDeadline using longer timeouts throughout the Pulsar module:

  • Run(): 2 minute deadline
  • WithFunctionsWorker(): 3 minute deadline (functions worker adds extra startup time)
  • WithTransactions(): 2 minute deadline

Also adds explicit WithStartupTimeout(2*time.Minute) to the HTTP wait strategies for the admin API and transaction topic endpoint checks.

Why is it important?

Pulsar is a heavy Java application whose startup time can exceed 60 seconds, especially in resource-constrained CI environments. The default 60s deadline causes flaky context deadline exceeded failures, making the test suite unreliable. Increasing timeouts to 2-3 minutes gives Pulsar sufficient time to fully initialize.

Related issues

…outs

The Pulsar module used WithWaitStrategy which has a default 60s deadline.
Pulsar is a heavy Java application that can take longer than 60s to start,
especially in CI environments, causing random context deadline exceeded
failures.

Changes:
- Use WithWaitStrategyAndDeadline(2min) for default Run()
- Use WithWaitStrategyAndDeadline(3min) for WithFunctionsWorker()
- Use WithWaitStrategyAndDeadline(2min) for WithTransactions()
- Add explicit WithStartupTimeout(2min) to HTTP wait strategies

Fixes testcontainers#2886

Co-Authored-By: Oz <oz-agent@warp.dev>
@netlify

netlify Bot commented Mar 21, 2026

Copy link
Copy Markdown

Deploy Preview for testcontainers-go failed.

Name Link
🔨 Latest commit d642284
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/69bed6c21d8f810008f4960f

@coderabbitai

coderabbitai Bot commented Mar 21, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8647679b-53f9-4d36-8aba-930edc3c6b8c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

@mdelapenya

Copy link
Copy Markdown
Member

Good catch — the root cause in #2886 is real and the direction is right. A few things to sort out before this is ready.

Two blocking issues:

  1. WithFunctionsWorkerForLog timeout isn't extended.
    The outer deadline is now 3 min, but ForLog("Function worker service started") still has its own default 60s timeout. If the functions worker takes longer than 60s (which it often does), the inner timeout fires before the outer one. The outer deadline doesn't help here.
    Fix: .WithStartupTimeout(3*time.Minute) on the ForLog strategy.

  2. WithTransactions — outer deadline equals the first strategy's timeout.
    Three strategies run sequentially sharing a 2-minute budget. The first HTTP check alone can take up to 2 min — leaving nothing for the clusters check or port check. On a slow CI box this can still fail.
    Fix: outer deadline should be ≥ sum of the strategies' individual timeouts (≈4–5 min).

One warning:

Run() has the same shape: 2-minute deadline, but sequential worst case is ~3 min (HTTP 2min + port 60s). Works in practice since the port is usually up by the time HTTP responds, but it's worth either bumping the deadline to 3 min or adding a comment explaining the ordering assumption.

Minor:
.WithStartupTimeout(2*time.Minute) on the HTTP strategies is redundant when the outer deadline is also 2 min — each resolves to min(remaining_budget, 2min). One or the other is enough; the project pattern (mssql, milvus, solace) tends to use per-strategy WithStartupTimeout only. Not blocking, just worth cleaning up for clarity.

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.

[Bug]: random pulsar test failures

2 participants