Skip to content

Fix empty liveness check ports in the Databend, Timeplus and ClickHouse modules - #12198

Open
suvvvv wants to merge 1 commit into
testcontainers:mainfrom
suvvvv:fix-module-liveness-ports
Open

suvvvv wants to merge 1 commit into
testcontainers:mainfrom
suvvvv:fix-module-liveness-ports

Conversation

@suvvvv

@suvvvv suvvvv commented Dec 1, 2026 •

Copy link
Copy Markdown

DatabendContainer, TimeplusContainer and both ClickHouseContainer classes override getLivenessCheckPortNumbers() with

return new HashSet<>(getMappedPort(HTTP_PORT));

That calls the HashSet(int initialCapacity) constructor, so the method always returns an empty set. It's the same bug #5734 fixed for the MySQL and Db2 modules; these modules were added later with the same line.

For Databend and Timeplus this means the wait strategy doesn't wait. Both use Wait.forHttp(...) without forPort(...), so HttpWaitStrategy takes its port from getLivenessCheckPorts(). When that's empty, it logs "No exposed ports or mapped ports - cannot wait for status" and returns, so start() finishes before the HTTP endpoint is up. ClickHouse uses forPort(HTTP_PORT), so its wait isn't affected, but the method still returned the wrong value.

They now return Collections.singleton(getMappedPort(HTTP_PORT)), so the HTTP port is still the only liveness check port, like before.

Tests

Each module's container test has a new livenessCheckPortIsTheMappedHttpPort test. It overrides getMappedPort instead of starting a container, so it doesn't need Docker, and checks that getLivenessCheckPortNumbers() contains exactly the mapped HTTP port. All four (Databend, Timeplus, clickhouse.ClickHouseContainer and the deprecated containers.ClickHouseContainer) fail on main with [] and pass with this change.

Ran locally: the new tests, plus checkstyleMain checkstyleTest spotlessCheck japicmp for the three modules. I couldn't run the existing container-based tests of these modules locally, because my Docker's image store is read-only right now and pulling images fails, independent of this change. CI should cover those.

Summary by CodeRabbit

  • Bug Fixes
    • Liveness checks now use the mapped HTTP port for ClickHouse, Databend, and Timeplus containers, ensuring checks target the correct port.
  • Tests
    • Added coverage verifying that each container’s liveness check uses its mapped HTTP port.

…se modules

new HashSet<>(getMappedPort(HTTP_PORT)) calls the HashSet(int initialCapacity) constructor, so getLivenessCheckPortNumbers() returned an empty set. Databend and Timeplus use Wait.forHttp(...) without forPort, and HttpWaitStrategy returns right away when there are no liveness check ports, so those containers were reported as started without waiting for the HTTP endpoint. Return the mapped HTTP port instead, as testcontainers#5734 did for MySQL and Db2.
@suvvvv
suvvvv requested a review from a team as a code owner December 1, 2026 16:02
@azure-pipelines

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

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ClickHouse, Databend, and Timeplus now return the mapped HTTP port as a singleton set for liveness checks. Tests use overridden port mappings to verify the returned port.

Changes: Mapped liveness-check ports

Layer / File(s) Summary
Return mapped HTTP ports
modules/clickhouse/src/main/java/.../ClickHouseContainer.java, modules/containers/src/main/java/.../ClickHouseContainer.java, modules/databend/src/main/java/.../DatabendContainer.java, modules/timeplus/src/main/java/.../TimeplusContainer.java
Each container implementation returns its mapped HTTP port in a singleton set.
Verify mapped liveness-check ports
modules/clickhouse/src/test/java/..., modules/databend/src/test/java/..., modules/timeplus/src/test/java/...
Tests override port mapping and assert the expected liveness-check port. The ClickHouse tests cover both container test paths.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: eddumelendez, hantmac, lizhou1111

Merge Risk: Minimal · up to 68be7

This fixes the liveness-check ports so that Databend and Timeplus wait for HTTP readiness again, and ClickHouse now returns the correct port. The change is small, adds unit tests, and no merge-blocking risk remains.

Pre-merge checks: Passed 7

Check name Status Explanation
Title check Passed The title names the three modules and the bug. The PR changes getLivenessCheckPortNumbers() in DatabendContainer, TimeplusContainer and both ClickHouseContainer classes, where the HashSet(int) constru…
Description check Passed The description states the bug, its effect on Databend and Timeplus wait strategies, the fix, the new tests, and the local verification. It also explains the limit on running container-based tests. It…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
New Module Registration Passed The check applies only when the PR adds a new directory under modules/. The reviewed range (refs/coderabbit/pre-merge-check/base..head) changes 8 files, all with status M (modified), in the existing m…
Public Api Compatibility Passed The check fails only if the PR removes, renames, or changes the signature, return type, or visibility of a public or protected class, method, constructor, or field under src/main/java without a deprec…
Tests For Behaviour Changes Passed The PR changes behaviour under src/main/java. It fixes getLivenessCheckPortNumbers() in four container classes. Each one returned new HashSet<>(getMappedPort(HTTP_PORT)), which calls the `HashSe…
Full details: Title check

Explanation

The title names the three modules and the bug. The PR changes getLivenessCheckPortNumbers() in DatabendContainer, TimeplusContainer and both ClickHouseContainer classes, where the HashSet(int) constructor returned an empty set. The title is specific and matches the main change, so it passes.

Full details: Description check

Explanation

The description states the bug, its effect on Databend and Timeplus wait strategies, the fix, the new tests, and the local verification. It also explains the limit on running container-based tests. It does not follow the repository template's checklist sections, but the template is mainly guidance and the required information is present. The description is mostly complete, so it passes.

Full details: New Module Registration

Explanation

The check applies only when the PR adds a new directory under modules/. The reviewed range (refs/coderabbit/pre-merge-check/base..head) changes 8 files, all with status M (modified), in the existing modules/clickhouse, modules/databend, and modules/timeplus directories. No file is added (A) under modules/, so no new module directory is created. The check is inapplicable and passes by its own terms. The PR is by author suvvvv, from fix-module-liveness-ports into main.

Full details: Public Api Compatibility

Explanation

The check fails only if the PR removes, renames, or changes the signature, return type, or visibility of a public or protected class, method, constructor, or field under src/main/java without a deprecated compatibility path. Evidence from the reviewed range (refs/coderabbit/pre-merge-check/base..head): - Changed main-source files are the ClickHouse (two classes), Databend, and Timeplus containers. Each diff changes only the body of getLivenessCheckPortNumbers() and its java.util.HashSet import, which becomes java.util.Collections. - The method declaration public Set&lt;Integer&gt; getLivenessCheckPortNumbers() is unchanged in all four classes. Name, parameters, return type, and visibility stay the same. - No class, constructor, field, or other method is removed or renamed. The import change is not part of the public API. - The other changed files are tests (src/test), which the check does not cover. The PR changes behavior (empty set to singleton) but not the public API surface the check covers. Additive or body-only changes pass. The check is satisfied.

Full details: Tests For Behaviour Changes

Explanation

The PR changes behaviour under src/main/java. It fixes getLivenessCheckPortNumbers() in four container classes. Each one returned new HashSet&lt;&gt;(getMappedPort(HTTP_PORT)), which calls the HashSet(int initialCapacity) constructor and yields an empty set. The PR replaces that with Collections.singleton(getMappedPort(HTTP_PORT)). The changed main files are: - modules/databend/.../DatabendContainer.java - modules/timeplus/.../TimeplusContainer.java - modules/clickhouse/.../clickhouse/ClickHouseContainer.java - modules/clickhouse/.../containers/ClickHouseContainer.java (deprecated) Each changed behaviour has a test under src/test that exercises it: - DatabendContainerTest.livenessCheckPortIsTheMappedHttpPort asserts containsExactly(18000). - TimeplusContainerTest.livenessCheckPortIsTheMappedHttpPort asserts containsExactly(13218). - clickhouse/ClickHouseContainerTest.livenessCheckPortIsTheMappedHttpPort asserts containsExactly(18123). - junit/clickhouse/SimpleClickhouseTest.livenessCheckPortIsTheMappedHttpPort asserts containsExactly(18123). This file imports the deprecated org.testcontainers.containers.ClickHouseContainer, so it covers that class. The new tests override getMappedPort and call getLivenessCheckPortNumbers() directly. They therefore exercise the changed method. The check's exemption for documentation-only, build-only, or pure refactoring changes does not apply, because this is a bug fix. The check passes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a736c02 and 68be7dc.

Files selected for processing: 8

  • modules/clickhouse/src/main/java/org/testcontainers/clickhouse/ClickHouseContainer.java
  • modules/clickhouse/src/main/java/org/testcontainers/containers/ClickHouseContainer.java
  • modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java
  • modules/clickhouse/src/test/java/org/testcontainers/junit/clickhouse/SimpleClickhouseTest.java
  • modules/databend/src/main/java/org/testcontainers/databend/DatabendContainer.java
  • modules/databend/src/test/java/org/testcontainers/databend/DatabendContainerTest.java
  • modules/timeplus/src/main/java/org/testcontainers/timeplus/TimeplusContainer.java
  • modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.java

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant