Skip to content

feat(clickhouse): Add ClickHouse with Http port #10371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

janeklb
Copy link

@janeklb janeklb commented Jun 22, 2025

Motivation

The official ClickHouse java client (https://github.com/ClickHouse/clickhouse-java) offers both JDBC and HTTP interfaces; however, testcontainers-java only offers an option for JDBC clients.

Modifications

  • Add ClickHouseHttpContainer
  • Add ClickHouseHttpContainerTest

Generated by Claude Code based on the following prompt (typo and all!):

Please add an http-based container for ClickHouse. It should live alongside the existing jdbc-based ClickHouse conatiner; however, it should follow the same kind of patterns that other http-based containers apply.

Click to see Claude Code's generated work summary

Summary

I have successfully implemented an HTTP-based ClickHouse container for Testcontainers alongside the existing JDBC-based container. Here's what was created:

Files Created:

  1. ClickHouseHttpContainer.java - The main HTTP-based container class that:
    • Extends GenericContainer instead of JdbcDatabaseContainer
    • Provides HTTP-specific methods like getHttpUrl(), getHttpHostAddress(), etc.
    • Uses the same Docker image and wait strategy as the JDBC version
    • Supports custom credentials and database configuration
    • Exposes both HTTP (8123) and Native (9000) ports for flexibility
  2. ClickHouseHttpContainerTest.java - Comprehensive test suite that includes:
    • Basic HTTP query execution
    • Custom credentials testing
    • URL method validation
    • Table creation and data insertion
    • Health check verification
    • Support for multiple ClickHouse versions

Key Features:

  • HTTP API Access: Provides direct access to ClickHouse's HTTP interface for REST API calls
  • Consistent Interface: Follows the same patterns as other HTTP-based containers in the codebase
  • Full Compatibility: Uses the same Docker images and configuration as the JDBC version
  • Comprehensive Testing: All 6 test scenarios pass, covering various use cases
  • Proper Error Handling: Includes authentication and error response handling
  • Documentation: Well-documented with Javadoc comments

Integration:

The HTTP-based container lives in the same package (org.testcontainers.clickhouse) as the existing JDBC container, allowing users to choose the appropriate approach for their use
case:

  • JDBC Container - For traditional database connections with SQL drivers
  • HTTP Container - For REST API access and direct HTTP query execution

Both containers can coexist and complement each other, providing flexibility for different testing scenarios and development patterns.

@janeklb janeklb requested a review from a team as a code owner June 22, 2025 22:17
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