-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add ClickHouse support #498
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| description = "Testcontainers :: JDBC :: ClickHouse" | ||
|
|
||
| dependencies { | ||
| compile project(':jdbc') | ||
|
|
||
| testCompile 'ru.yandex.clickhouse:clickhouse-jdbc:0.1.36' | ||
| testCompile 'com.zaxxer:HikariCP-java6:2.3.8' | ||
| testCompile 'commons-dbutils:commons-dbutils:1.6' | ||
| } |
70 changes: 70 additions & 0 deletions
70
modules/clickhouse/src/main/java/org/testcontainers/containers/ClickHouseContainer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package org.testcontainers.containers; | ||
|
|
||
| import org.testcontainers.containers.wait.HttpWaitStrategy; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| public class ClickHouseContainer<SELF extends ClickHouseContainer<SELF>> extends JdbcDatabaseContainer<SELF> { | ||
| public static final String NAME = "clickhouse"; | ||
| public static final String IMAGE = "yandex/clickhouse-server"; | ||
| public static final String IMAGE_TAG = "1.1.54310"; | ||
| public static final String JDBC_DRIVER_CLASS_NAME = "ru.yandex.clickhouse.ClickHouseDriver"; | ||
| public static final String JDBC_URL_PREFIX = "jdbc:clickhouse"; | ||
| public static final String TEST_QUERY_STRING = "SELECT 1"; | ||
| public static final Integer HTTP_PORT = 8123; | ||
| public static final Integer NATIVE_PORT = 9000; | ||
|
|
||
| private String databaseName = "default"; | ||
| private String username = "default"; | ||
| private String password = ""; | ||
|
|
||
| public ClickHouseContainer() { | ||
| super(IMAGE + ":" + IMAGE_TAG); | ||
| } | ||
|
|
||
| public ClickHouseContainer(String dockerImageName) { | ||
| super(dockerImageName); | ||
| } | ||
|
|
||
| @Override | ||
| protected void configure() { | ||
| withExposedPorts(HTTP_PORT, NATIVE_PORT); | ||
| waitingFor( | ||
| new HttpWaitStrategy() | ||
| .forStatusCode(200) | ||
| .forResponsePredicate(responseBody -> "Ok.".equals(responseBody)) | ||
| .withStartupTimeout(Duration.ofMinutes(1)) | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| protected Integer getLivenessCheckPort() { | ||
| return getMappedPort(HTTP_PORT); | ||
| } | ||
|
|
||
| @Override | ||
| public String getDriverClassName() { | ||
| return JDBC_DRIVER_CLASS_NAME; | ||
| } | ||
|
|
||
| @Override | ||
| public String getJdbcUrl() { | ||
| return JDBC_URL_PREFIX + "://" + getContainerIpAddress() + ":" + getMappedPort(HTTP_PORT) + "/" + databaseName; | ||
| } | ||
|
|
||
| @Override | ||
| public String getUsername() { | ||
| return username; | ||
| } | ||
|
|
||
| @Override | ||
| public String getPassword() { | ||
| return password; | ||
| } | ||
|
|
||
| @Override | ||
| public String getTestQueryString() { | ||
| return TEST_QUERY_STRING; | ||
| } | ||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
modules/clickhouse/src/main/java/org/testcontainers/containers/ClickHouseProvider.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package org.testcontainers.containers; | ||
|
|
||
| public class ClickHouseProvider extends JdbcDatabaseContainerProvider { | ||
| @Override | ||
| public boolean supports(String databaseType) { | ||
| return databaseType.equals(ClickHouseContainer.NAME); | ||
| } | ||
|
|
||
| @Override | ||
| public JdbcDatabaseContainer newInstance(String tag) { | ||
| return new ClickHouseContainer(ClickHouseContainer.IMAGE + ":" + tag); | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
...n/resources/META-INF/services/org.testcontainers.containers.JdbcDatabaseContainerProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| org.testcontainers.containers.ClickHouseProvider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so happy with adding an additional param to the method if it's only needed by on tested class.
The tests will fail if not set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Method getParameterMetaData not implemented on clickhouse jdbc driver.