Skip to content

feat: Add Testcontainers.ZooKeeper module - #1765

Open
rosian22 wants to merge 3 commits into
testcontainers:developfrom
rosian22:feat/zookeeper-module
Open

rosian22 wants to merge 3 commits into
testcontainers:developfrom
rosian22:feat/zookeeper-module

Conversation

@rosian22

@rosian22 rosian22 commented Sep 10, 2026 •

Copy link
Copy Markdown

What does this PR do?

Adds a new Testcontainers.ZooKeeper module for Apache ZooKeeper, following the existing module pattern (builder / configuration / container, tests, docs).

The builder binds the client port (2181) and the AdminServer port (8080), and waits for readiness by polling the AdminServer's /commands/ruok endpoint until it reports no error. GetConnectionString() returns the host:port pair ZooKeeper clients expect. The image is pinned to zookeeper:3.9.5. Tests cover the connection string format and a real znode create/read round-trip via zkCli.sh.

Why is it important?

Requested in #1560, where maintaining it as a separate module (rather than folding it into the Kafka module) was agreed.

Related issues

How to test this PR

dotnet test tests/Testcontainers.ZooKeeper.Tests (3 tests, verified locally against Docker 27.4).

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for running Apache ZooKeeper containers with configurable images and automatic readiness checks.
    • Added connection-string retrieval for ZooKeeper containers.
    • Added support for ZooKeeper’s client and AdminServer ports.
  • Documentation

    • Added ZooKeeper setup, lifecycle, connection-string, and testing guidance.
  • Tests

    • Added integration coverage for container startup, connection strings, and zNode creation and retrieval.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rosian22
rosian22 requested review from a team and HofmeisterAn as code owners September 10, 2026 20:23
@netlify

netlify Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for testcontainers-dotnet ready!

Name Link
🔨 Latest commit 6bd9480
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-dotnet/deploys/6abc312a2ec109000854f8e7
😎 Deploy Preview https://deploy-preview-1765--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

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 7cbf97de-05c5-45d9-bafe-67edb4c3738f

📥 Commits

Reviewing files that changed from the base of the PR and between 29066bb and 6bd9480.

📒 Files selected for processing (2)
  • Testcontainers.slnx
  • mkdocs.yml
💤 Files with no reviewable changes (1)
  • Testcontainers.slnx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.


Walkthrough

The change adds a ZooKeeper Testcontainers module with image-based container setup, readiness polling, and connection-string retrieval. It also adds integration tests, solution entries, and module documentation.

Changes

ZooKeeper module

Layer / File(s) Summary
Module contract and project wiring
src/Testcontainers.ZooKeeper/..., Testcontainers.slnx
Adds a multi-targeted module project, configuration type, public container API, global usings, and solution entries.
Container construction and readiness
src/Testcontainers.ZooKeeper/ZooKeeperBuilder.cs
Adds image-based constructors, bindings for ports 2181 and 8080, AdminServer readiness polling, configuration cloning and merging, and container construction.
Integration validation and usage
tests/Testcontainers.ZooKeeper.Tests/..., docs/modules/zookeeper.md, mkdocs.yml
Adds a pinned test image, test project and fixtures, connection-string and zNode tests, usage documentation, and documentation navigation.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant ZooKeeperContainerTest
  participant ZooKeeperBuilder
  participant ZooKeeperContainer
  participant ZooKeeperAdminServer
  ZooKeeperContainerTest->>ZooKeeperBuilder: Configure ZooKeeper image
  ZooKeeperBuilder->>ZooKeeperContainer: Build container
  ZooKeeperContainer->>ZooKeeperAdminServer: Poll /commands/ruok on port 8080
  ZooKeeperAdminServer-->>ZooKeeperContainer: Return readiness response
  ZooKeeperContainer-->>ZooKeeperContainerTest: Provide tcp://host:port connection string
Loading

Merge Risk: ⚪ Minimal · up to 6bd94

The change adds ZooKeeper container setup, connection access, tests, and documentation. No actionable merge-blocking issue is established; merge after normal build and integration checks pass.

Architecture Summary

Architecture risk: 🔵 Low · up to 6bd94

The change affects 5 systems.

Changed systems: tests, src, docs, mkdocs.yml, Testcontainers.slnx

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — tests (service) was modified; 7 changed files map to changed impact.
  • observed — src (service) was modified; 6 changed files map to changed impact.
  • observed — docs (service) was modified; 1 changed file maps to changed impact.
  • observed — mkdocs.yml (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in docs/modules/zookeeper.md: Added complete ZooKeeper usage documentation, including NuGet installation, xUnit container startup and disposal guidance, connection establishment, package references, and the dotnet test command.
  • observed — Modified behavior in src/Testcontainers.ZooKeeper/.editorconfig: Added a new .editorconfig file with the root = true directive.
  • observed — Modified behavior in src/Testcontainers.ZooKeeper/Testcontainers.ZooKeeper.csproj: Adds a new project file for the ZooKeeper Testcontainers module, declaring multi-targeted frameworks (net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1), latest language version, a private JetBrains.Annotations package reference, and a project reference to the core Testcontainers project.
  • observed — Modified behavior in src/Testcontainers.ZooKeeper/Usings.cs: Adds a new Usings.cs file declaring ten global using directives for System, Docker.DotNet, DotNet.Testcontainers, and JetBrains.Annotations namespaces.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: adding the Testcontainers.ZooKeeper module.
Description check ✅ Passed The description covers what changed, why the change is important, the related issue, and how to test it. It matches the repository template and provides relevant implementation details.
Linked Issues check ✅ Passed Issue #1560 requests a dedicated Testcontainers.Zookeeper library instead of generic-container setup. The PR adds the Testcontainers.ZooKeeper project, ZooKeeperBuilder, ZooKeeperConfiguration…
Out of Scope Changes check ✅ Passed The reviewed changes stay within the scope of issue #1560. The project files, container implementation, integration tests, Docker test image, and documentation directly support the dedicated ZooKeeper…
Docstring Coverage ✅ Passed Docstring coverage is 91.30% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 23 functions across 7 files. (2 skipped: 2 …
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

A rabbit packs a carrot and a kit,
A ZooKeeper container starts up bit by bit.
Port two-one-eight-one joins the play,
While ruok checks readiness on the way.
A host and mapped port form the string,
And zNodes hold the tests’ new spring.

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

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@rosian22

Copy link
Copy Markdown
Author

Regarding the CodeRabbit slop flag (redundant_comments): the repeated comments it detects are intentionally copied from the repository's existing module template (the configuration-class comments and Given/When/Then test markers appear verbatim in the ClickHouse, KurrentDb and other modules) to keep this module consistent with the established pattern. For transparency: I developed this module with AI assistance, as the commit trailers note. I reviewed the design and code myself and validated the behavior against the real zookeeper:3.9.5 image locally (all tests pass). Happy to adjust any comments the maintainers consider noise.

This branch has not been deployed

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

Labels

enhancement New feature or request module An official Testcontainers module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Enhancement]: add zookeeper container

2 participants