Skip to content

Conversation

@verdie-g
Copy link
Contributor

Since we upgraded to Milvus 2.6, our tests started to randomly fail with [service unavailable: internal: Milvus Proxy is not ready yet. please wait. More info here milvus-io/milvus-sdk-csharp#123.

My understanding is that even though the request to /healthz succeeds, Milvus might not be completely ready yet.

The fix is to imitate exactly what https://github.com/milvus-io/milvus/blob/master/scripts/standalone_embed.sh does.

@netlify
Copy link

netlify bot commented Nov 23, 2025

Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 6bc7cd0
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/692491b26bb1da0008c8eb1e
😎 Deploy Preview https://deploy-preview-1585--testcontainers-dotnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Nov 23, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved health check mechanism for Milvus container initialization to provide more reliable container readiness detection.
  • Tests

    • Updated container configuration tests to align with revised health check setup and removed hardcoded version references for greater flexibility.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Replaced the HTTP wait strategy with a Docker container healthcheck in MilvusBuilder.Init by adding a private Healthcheck singleton and applying it via WithCreateParameterModifier; adjusted wait chaining. Tests updated to stop pinning an explicit Milvus version and assert image name suffix instead. No public API changes.

Changes

Cohort / File(s) Change Summary
Milvus builder healthcheck
src/Testcontainers.Milvus/MilvusBuilder.cs
Replaced the previous UntilHttpRequestIsSucceeded wait with an UntilContainerIsHealthy strategy and added a private sealed Healthcheck class (public static Instance) that configures a CMD-SHELL curl check to http://localhost:<MilvusManagementPort>/healthz (interval=30s, timeout=20s, start_period=90s, retries=3). Applied the healthcheck via WithCreateParameterModifier. No public signatures changed.
Tests — image/version handling
tests/Testcontainers.Milvus.Tests/MilvusContainerTest.cs
Removed the private MilvusVersion constant and related explicit image-setting. Tests now use the default image from MilvusBuilder and assert the resolved image ends with MilvusBuilder.MilvusImage instead of exact equality.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as Test
    participant Builder as MilvusBuilder
    participant Docker as Docker Engine

    Test->>Builder: Create container config
    Builder->>Builder: Configure wait strategy -> UntilContainerIsHealthy
    Builder->>Builder: WithCreateParameterModifier(Healthcheck.Instance)
    Builder->>Docker: Create container (with HEALTHCHECK CMD-SHELL curl ...)
    Docker-->>Docker: Run healthcheck cycles (interval/timeout/retries)
    Docker-->>Test: Report container healthy / unhealthy
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify healthcheck command correctness and proper port interpolation (MilvusManagementPort).
  • Confirm the change from HTTP wait to container health wait preserves intended startup ordering.
  • Review the CreateParameterModifier usage to ensure no unintended side effects on container creation.
  • Check updated tests for robustness across CI environments.

Poem

🐰 I curl the port, I watch the beat,
Docker nods — the check is neat.
Versions loosened, tests align,
Builder hums, the container’s fine.
Hops and carrots, ready to shine! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description covers the problem (random failures after Milvus upgrade), the root cause (incomplete readiness despite successful /healthz), and the solution (mimicking Milvus scripts), but lacks explicit 'Why is it important' and 'How to test' sections from the template.
Title check ✅ Passed The title accurately describes the main change: replacing the HTTP-based wait strategy with a healthcheck-based wait strategy to fix intermittent test failures in Milvus initialization.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9de42 and 6589edd.

📒 Files selected for processing (1)
  • src/Testcontainers.Milvus/MilvusBuilder.cs (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: verdie-g
Repo: testcontainers/testcontainers-dotnet PR: 1569
File: src/Testcontainers.Milvus/MilvusBuilder.cs:67-67
Timestamp: 2025-11-10T09:58:21.688Z
Learning: In Milvus test containers (src/Testcontainers.Milvus/MilvusBuilder.cs), the DEPLOY_MODE=STANDALONE environment variable is a valid and official configuration option used in Milvus standalone deployments, as documented in the official Milvus standalone_embed.sh script.
📚 Learning: 2025-11-10T09:58:21.688Z
Learnt from: verdie-g
Repo: testcontainers/testcontainers-dotnet PR: 1569
File: src/Testcontainers.Milvus/MilvusBuilder.cs:67-67
Timestamp: 2025-11-10T09:58:21.688Z
Learning: In Milvus test containers (src/Testcontainers.Milvus/MilvusBuilder.cs), the DEPLOY_MODE=STANDALONE environment variable is a valid and official configuration option used in Milvus standalone deployments, as documented in the official Milvus standalone_embed.sh script.

Applied to files:

  • src/Testcontainers.Milvus/MilvusBuilder.cs
🧬 Code graph analysis (1)
src/Testcontainers.Milvus/MilvusBuilder.cs (1)
tests/Testcontainers.Tests/Unit/Configurations/TestcontainersWaitStrategyTest.cs (1)
  • Timeout (42-65)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: ci (Testcontainers, ubuntu-24.04)
  • GitHub Check: ci (Testcontainers.Milvus, ubuntu-24.04)
  • GitHub Check: analyze (csharp)
🔇 Additional comments (2)
src/Testcontainers.Milvus/MilvusBuilder.cs (2)

62-63: LGTM! Good reference to the official implementation.

The inline comment clearly documents the source of the healthcheck logic and provides a specific commit reference for future maintainability.


88-88: LGTM! Correct approach to fix the readiness issue.

Switching to UntilContainerIsHealthy() ensures the container waits for Docker's native healthcheck to pass, which is the appropriate solution for the reported issue where /healthz returned success before Milvus was fully ready to serve requests.

@HofmeisterAn
Copy link
Collaborator

I double-checked the image configuration during my lunch break. I'm honestly wondering how this ever worked reliably. It looks like the image never had a health check configured, and that configuration has been needed from the start. I also double-checked the old version (v2.3.10) to see if it includes the API, and it does. Thanks for the PR! I'll merge it later.

@HofmeisterAn HofmeisterAn added the bug Something isn't working label Nov 24, 2025
@verdie-g
Copy link
Contributor Author

@HofmeisterAn I think the UntilHttpRequestIsSucceeded can be removed

@HofmeisterAn
Copy link
Collaborator

HofmeisterAn commented Nov 24, 2025

@verdie-g Thanks for checking it again. I didn't see it in the merge conflict. Now it should be correct.

I thought the module already uses the health check to determine readiness. Switching from the HTTP wait strategy to the health check shouldn't behave any differently since they use the same API 🤔.

@verdie-g
Copy link
Contributor Author

Switching from the HTTP wait strategy to the health check shouldn't behave any differently since they use the same API 🤔.

Well, yes. I'm a bit puzzled by that. If that helps we can just rename that PR "mirror official milvus script" and I'll check if we still get the same error.

@HofmeisterAn
Copy link
Collaborator

I'll check if we still get the same error.

This would be really helpful. From experience with other modules, relying on log messages is reliable. For Milvus, I did not find any log messages that truly indicate readiness. Maybe this is feedback we can provide to the Milvus project to let them know that their health check API is not reliable?

It would be great if you can override the builder's wait strategy and test it:

var milvusContainer = new MilvusBuilder()
    .WithWaitStrategy(Wait.ForUnixContainer().UntilContainerIsHealthy())
    .WithCreateParameterModifier(p =>
    {
        p.Healthcheck = new HealthcheckConfig
        {
            Test = ["CMD-SHELL", $"curl -f http://localhost:{MilvusBuilder.MilvusManagementPort}/healthz"],
            Interval = TimeSpan.FromSeconds(30),
            StartPeriod = 90 * 1_000_000_000L, // 90s
            Timeout = TimeSpan.FromSeconds(20),
            Retries = 3,
        };
    });

@verdie-g
Copy link
Contributor Author

Without this change, I used the "Run Unit Test Until Failure" of my IDE and it failed after 2-3 minutes. With the change applied, I was not able to reproduce the problem after 10 minutes of "Run Unit Test Until Failure".

So I cannot really explain how that helps but it does somehow :D

@HofmeisterAn
Copy link
Collaborator

So I cannot really explain how that helps but it does somehow :D

One thing that has changed is the interval. By default, TC runs the wait strategy check every second. Could you try it again with a 1-second interval? We might want to consider reducing the interval, as 30 seconds might be a bit long.

@verdie-g
Copy link
Contributor Author

I can confirm that it doesn't take 30 seconds to start but more like 3-4 seconds. With the StartPeriod decreased to 1s, I was not able to reproduce the problem either.

@HofmeisterAn HofmeisterAn changed the title fix(Milvus): wait for healthy fix(Milvus): Use healthcheck wait strategy Nov 26, 2025
Copy link
Collaborator

@HofmeisterAn HofmeisterAn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, tests and feedback 👍.

@HofmeisterAn HofmeisterAn merged commit 5e7aad7 into testcontainers:develop Nov 26, 2025
12 checks passed
@verdie-g
Copy link
Contributor Author

@HofmeisterAn any chance we could have a release for this PR? I would like to use it right away in the Milvus client.

@HofmeisterAn
Copy link
Collaborator

@HofmeisterAn any chance we could have a release for this PR? I would like to use it right away in the Milvus client.

No ETA. You can patch the default builder configuration, so the release isn't critical.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants