Skip to content

Expose MySQL and PostgreSQL protocol ports in ClickHouseContainer - #12001

Open
junho0831 wants to merge 1 commit into
testcontainers:mainfrom
junho0831:feat/3827-clickhouse-mysql-protocol
Open

Expose MySQL and PostgreSQL protocol ports in ClickHouseContainer#12001
junho0831 wants to merge 1 commit into
testcontainers:mainfrom
junho0831:feat/3827-clickhouse-mysql-protocol

Conversation

@junho0831

@junho0831 junho0831 commented Aug 29, 2026

Copy link
Copy Markdown

Description

ClickHouse server provides native compatibility with MySQL (port 9004) and PostgreSQL (port 9005) wire protocols by default. Previously, ClickHouseContainer only exposed the HTTP (8123) and Native (9000) ports, preventing users from connecting via MySQL and PostgreSQL drivers/clients without manual port configuration.

Changes

  • Added MYSQL_PORT = 9004 and POSTGRESQL_PORT = 9005 to ClickHouseContainer and exposed them by default.
  • Added helper methods: getMysqlPort(), getPostgresqlPort(), getHttpPort(), getNativePort(), getMysqlJdbcUrl(), and getPostgresqlJdbcUrl().
  • Updated Javadoc documentation to list the MySQL and PostgreSQL ports.
  • Added tests in ClickHouseContainerTest verifying end-to-end query execution across both MySQL and PostgreSQL protocols.

Fixes #3827

Summary by CodeRabbit

  • New Features

    • Added support for connecting to ClickHouse through MySQL and PostgreSQL protocols.
    • Added access to mapped HTTP, native, MySQL, and PostgreSQL ports.
    • Added JDBC URL helpers for MySQL and PostgreSQL connections.
  • Tests

    • Added coverage confirming both new protocols support JDBC connections and queries.

ClickHouse server provides native compatibility with MySQL (port 9004)
and PostgreSQL (port 9005) wire protocols by default. Previously,
ClickHouseContainer only exposed the HTTP (8123) and Native (9000) ports,
preventing users from connecting via MySQL and PostgreSQL drivers/clients
without manual port configuration.

Expose MYSQL_PORT (9004) and POSTGRESQL_PORT (9005) by default, and
provide helper methods (getMysqlPort(), getPostgresqlPort(),
getMysqlJdbcUrl(), getPostgresqlJdbcUrl()) in ClickHouseContainer.

Fixes testcontainers#3827
@junho0831
junho0831 requested a review from a team as a code owner August 29, 2026 04:45
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 93fa2ab0-3d0d-40e9-81f7-fe55dba056bb

📥 Commits

Reviewing files that changed from the base of the PR and between a4d3a03 and c2daa78.

📒 Files selected for processing (4)
  • modules/clickhouse/build.gradle
  • 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

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


📝 Walkthrough

Walkthrough

Changes

ClickHouse protocol support

Layer / File(s) Summary
Protocol port exposure
modules/clickhouse/src/main/java/org/testcontainers/clickhouse/ClickHouseContainer.java, modules/clickhouse/src/main/java/org/testcontainers/containers/ClickHouseContainer.java
The container defines and exposes MySQL port 9004 and PostgreSQL port 9005 alongside HTTP and native ports.
JDBC URL and port accessors
modules/clickhouse/src/main/java/org/testcontainers/clickhouse/ClickHouseContainer.java
The container provides MySQL and PostgreSQL JDBC URLs and mapped-port accessors for all supported protocols.
Protocol integration validation
modules/clickhouse/build.gradle, modules/clickhouse/src/test/java/org/testcontainers/clickhouse/ClickHouseContainerTest.java
The module adds JDBC test drivers and verifies MySQL and PostgreSQL connections with SELECT 1.

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

Merge Risk: 🔵 Low · up to c2daa

Each ClickHouse container will now expose MySQL and PostgreSQL-compatible endpoints by default, making those protocols easier to use but potentially increasing network exposure when container ports are reachable beyond trusted test environments. The change is mergeable with explicit owner awareness and follow-up to document trusted bindings and credential practices.

Sequence Diagram(s)

sequenceDiagram
  participant ClickHouseContainer
  participant DriverManager
  participant ClickHouseServer
  ClickHouseContainer->>DriverManager: provide protocol JDBC URL
  DriverManager->>ClickHouseServer: connect through MySQL or PostgreSQL protocol
  ClickHouseServer-->>DriverManager: return connection
  DriverManager->>ClickHouseServer: execute SELECT 1
  ClickHouseServer-->>DriverManager: return 1
Loading

Suggested reviewers: eddumelendez, kiview, pioorg

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (1 skipped: 1… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: exposing MySQL and PostgreSQL protocol ports in ClickHouseContainer.
Description check ✅ Passed The description explains the previous limitation, the new ports and helper methods, the end-to-end tests, and the linked issue. It provides the required context for this enhancement.
Linked Issues check ✅ Passed The changes satisfy issue #3827 by adding MySQL and PostgreSQL protocol support, exposing the required ports, providing connection helpers, and adding end-to-end tests.
Out of Scope Changes check ✅ Passed All changes support the stated ClickHouse protocol expansion. The added JDBC test dependencies are required by the new integration tests, and no unrelated code changes are evident.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 3 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

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.

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.

Clickhouse via MySQL protocol

1 participant