-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Timeplus module #8779
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
Merged
eddumelendez
merged 11 commits into
testcontainers:main
from
lizhou1111:add_timeplus_container
Aug 14, 2024
Merged
Add Timeplus module #8779
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
3be7509
add Timeplus container for test
676bea0
fix comments
22013c0
fix comments 2
f50b0bb
some cleanup
e6cce0f
add template option
00536d1
add doc
6149564
fix comments 3
69a6974
better
Jasmine-ge 858b0ca
fix several problems
Jasmine-ge d341ace
Merge branch 'main' into add_timeplus_container
Jasmine-ge 96169a9
Polish
eddumelendez 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 |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ body: | |
| - Solace | ||
| - Solr | ||
| - TiDB | ||
| - Timeplus | ||
| - ToxiProxy | ||
| - Trino | ||
| - Vault | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ body: | |
| - Solace | ||
| - Solr | ||
| - TiDB | ||
| - Timeplus | ||
| - ToxiProxy | ||
| - Trino | ||
| - Vault | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -60,6 +60,7 @@ body: | |
| - Solace | ||
| - Solr | ||
| - TiDB | ||
| - Timeplus | ||
| - ToxiProxy | ||
| - Trino | ||
| - Vault | ||
|
|
||
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
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
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,24 @@ | ||
| # Timeplus Module | ||
|
|
||
| ## Adding this module to your project dependencies | ||
|
|
||
| Add the following dependency to your `pom.xml`/`build.gradle` file: | ||
|
|
||
| === "Gradle" | ||
| ```groovy | ||
| testImplementation "org.testcontainers:timeplus:{{latest_version}}" | ||
| ``` | ||
|
|
||
| === "Maven" | ||
| ```xml | ||
| <dependency> | ||
| <groupId>org.testcontainers</groupId> | ||
| <artifactId>timeplus</artifactId> | ||
| <version>{{latest_version}}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| !!! hint | ||
| Adding this Testcontainers library JAR will not automatically add a database driver JAR to your project. You should ensure that your project also has a suitable database driver as a dependency. | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| description = "Testcontainers :: JDBC :: Timeplus" | ||
|
|
||
| dependencies { | ||
| api project(':testcontainers') | ||
| api project(':jdbc') | ||
|
|
||
| testImplementation project(':jdbc-test') | ||
| testRuntimeOnly 'com.timeplus:timeplus-native-jdbc:2.0.4' | ||
| testImplementation 'org.assertj:assertj-core:3.26.3' | ||
| } |
125 changes: 125 additions & 0 deletions
125
modules/timeplus/src/main/java/org/testcontainers/timeplus/TimeplusContainer.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,125 @@ | ||
| package org.testcontainers.timeplus; | ||
|
|
||
| import org.testcontainers.containers.JdbcDatabaseContainer; | ||
| import org.testcontainers.containers.wait.strategy.Wait; | ||
| import org.testcontainers.utility.DockerImageName; | ||
|
|
||
| import java.time.Duration; | ||
| import java.util.HashSet; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
| * Testcontainers implementation for Timeplus. | ||
| * <p> | ||
| * Supported image: {@code timeplus/timeplusd} | ||
| * <p> | ||
| * Exposed ports: | ||
| * <ul> | ||
| * <li>Database: 8463</li> | ||
| * <li>HTTP: 3218</li> | ||
| * </ul> | ||
| */ | ||
| public class TimeplusContainer extends JdbcDatabaseContainer<TimeplusContainer> { | ||
|
|
||
| static final String NAME = "timeplus"; | ||
|
|
||
| static final String DOCKER_IMAGE_NAME = "timeplus/timeplusd"; | ||
|
|
||
| private static final DockerImageName TIMEPLUS_IMAGE_NAME = DockerImageName.parse(DOCKER_IMAGE_NAME); | ||
|
|
||
| private static final Integer HTTP_PORT = 3218; | ||
|
|
||
| private static final Integer NATIVE_PORT = 8463; | ||
|
|
||
| private static final String DRIVER_CLASS_NAME = "com.timeplus.jdbc.TimeplusDriver"; | ||
|
|
||
| private static final String JDBC_URL_PREFIX = "jdbc:" + NAME + "://"; | ||
|
|
||
| private static final String TEST_QUERY = "SELECT 1"; | ||
|
|
||
| private String databaseName = "default"; | ||
|
|
||
| private String username = "default"; | ||
|
|
||
| private String password = ""; | ||
|
|
||
| public TimeplusContainer(String dockerImageName) { | ||
| this(DockerImageName.parse(dockerImageName)); | ||
| } | ||
|
|
||
| public TimeplusContainer(final DockerImageName dockerImageName) { | ||
| super(dockerImageName); | ||
| dockerImageName.assertCompatibleWith(TIMEPLUS_IMAGE_NAME); | ||
|
|
||
| addExposedPorts(HTTP_PORT, NATIVE_PORT); | ||
| waitingFor(Wait.forHttp("/timeplusd/v1/ping").forStatusCode(200).withStartupTimeout(Duration.ofMinutes(1))); | ||
| } | ||
|
|
||
| @Override | ||
| protected void configure() { | ||
| withEnv("TIMEPLUS_DB", this.databaseName); | ||
| withEnv("TIMEPLUS_USER", this.username); | ||
| withEnv("TIMEPLUS_PASSWORD", this.password); | ||
| } | ||
|
|
||
| @Override | ||
| public Set<Integer> getLivenessCheckPortNumbers() { | ||
| return new HashSet<>(getMappedPort(HTTP_PORT)); | ||
| } | ||
|
|
||
| @Override | ||
| public String getDriverClassName() { | ||
| return DRIVER_CLASS_NAME; | ||
| } | ||
|
|
||
| @Override | ||
| public String getJdbcUrl() { | ||
| return ( | ||
| JDBC_URL_PREFIX + | ||
| getHost() + | ||
| ":" + | ||
| getMappedPort(NATIVE_PORT) + | ||
| "/" + | ||
| this.databaseName + | ||
| constructUrlParameters("?", "&") | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public String getUsername() { | ||
| return this.username; | ||
| } | ||
|
|
||
| @Override | ||
| public String getPassword() { | ||
| return this.password; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDatabaseName() { | ||
| return this.databaseName; | ||
| } | ||
|
|
||
| @Override | ||
| public String getTestQueryString() { | ||
| return TEST_QUERY; | ||
| } | ||
|
|
||
| @Override | ||
| public TimeplusContainer withUsername(String username) { | ||
| this.username = username; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public TimeplusContainer withPassword(String password) { | ||
| this.password = password; | ||
| return this; | ||
| } | ||
|
|
||
| @Override | ||
| public TimeplusContainer withDatabaseName(String databaseName) { | ||
| this.databaseName = databaseName; | ||
| return this; | ||
| } | ||
| } | ||
32 changes: 32 additions & 0 deletions
32
modules/timeplus/src/main/java/org/testcontainers/timeplus/TimeplusContainerProvider.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,32 @@ | ||
| package org.testcontainers.timeplus; | ||
|
|
||
| import org.testcontainers.containers.JdbcDatabaseContainer; | ||
| import org.testcontainers.containers.JdbcDatabaseContainerProvider; | ||
| import org.testcontainers.utility.DockerImageName; | ||
|
|
||
| /** | ||
| * Factory for Timeplus containers. | ||
| */ | ||
| public class TimeplusContainerProvider extends JdbcDatabaseContainerProvider { | ||
|
|
||
| private static final String DEFAULT_TAG = "2.3.21"; | ||
|
|
||
| @Override | ||
| public boolean supports(String databaseType) { | ||
| return databaseType.equals(TimeplusContainer.NAME); | ||
| } | ||
|
|
||
| @Override | ||
| public JdbcDatabaseContainer newInstance() { | ||
| return newInstance(DEFAULT_TAG); | ||
| } | ||
|
|
||
| @Override | ||
| public JdbcDatabaseContainer newInstance(String tag) { | ||
| if (tag != null) { | ||
| return new TimeplusContainer(DockerImageName.parse(TimeplusContainer.DOCKER_IMAGE_NAME).withTag(tag)); | ||
| } else { | ||
| return newInstance(); | ||
| } | ||
| } | ||
| } |
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.timeplus.TimeplusContainerProvider |
7 changes: 7 additions & 0 deletions
7
modules/timeplus/src/test/java/org/testcontainers/TimeplusImages.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,7 @@ | ||
| package org.testcontainers; | ||
|
|
||
| import org.testcontainers.utility.DockerImageName; | ||
|
|
||
| public interface TimeplusImages { | ||
| DockerImageName TIMEPLUS_IMAGE = DockerImageName.parse("timeplus/timeplusd:2.3.21"); | ||
| } |
19 changes: 19 additions & 0 deletions
19
modules/timeplus/src/test/java/org/testcontainers/junit/timeplus/TimeplusJDBCDriverTest.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,19 @@ | ||
| package org.testcontainers.junit.timeplus; | ||
|
|
||
| import org.junit.runner.RunWith; | ||
| import org.junit.runners.Parameterized; | ||
| import org.testcontainers.jdbc.AbstractJDBCDriverTest; | ||
|
|
||
| import java.util.Arrays; | ||
| import java.util.EnumSet; | ||
|
|
||
| @RunWith(Parameterized.class) | ||
| public class TimeplusJDBCDriverTest extends AbstractJDBCDriverTest { | ||
|
|
||
| @Parameterized.Parameters(name = "{index} - {0}") | ||
| public static Iterable<Object[]> data() { | ||
| return Arrays.asList( | ||
| new Object[][] { { "jdbc:tc:timeplus:2.3.21://hostname", EnumSet.noneOf(Options.class) } } | ||
| ); | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
modules/timeplus/src/test/java/org/testcontainers/timeplus/TimeplusContainerTest.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,46 @@ | ||
| package org.testcontainers.timeplus; | ||
|
|
||
| import org.junit.Test; | ||
| import org.testcontainers.TimeplusImages; | ||
| import org.testcontainers.db.AbstractContainerDatabaseTest; | ||
|
|
||
| import java.sql.ResultSet; | ||
| import java.sql.SQLException; | ||
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| public class TimeplusContainerTest extends AbstractContainerDatabaseTest { | ||
|
|
||
| @Test | ||
| public void testSimple() throws SQLException { | ||
| try (TimeplusContainer timeplus = new TimeplusContainer(TimeplusImages.TIMEPLUS_IMAGE)) { | ||
| timeplus.start(); | ||
|
|
||
| ResultSet resultSet = performQuery(timeplus, "SELECT 1"); | ||
|
|
||
| int resultSetInt = resultSet.getInt(1); | ||
| assertThat(resultSetInt).isEqualTo(1); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void customCredentialsWithUrlParams() throws SQLException { | ||
| try ( | ||
| TimeplusContainer timeplus = new TimeplusContainer(TimeplusImages.TIMEPLUS_IMAGE) | ||
| .withUsername("system") | ||
| .withPassword("sys@t+") | ||
| .withDatabaseName("system") | ||
| .withUrlParam("interactive_delay", "5") | ||
| ) { | ||
| timeplus.start(); | ||
|
|
||
| ResultSet resultSet = performQuery( | ||
| timeplus, | ||
| "SELECT to_int(value) FROM system.settings where name='interactive_delay'" | ||
| ); | ||
|
|
||
| int resultSetInt = resultSet.getInt(1); | ||
| assertThat(resultSetInt).isEqualTo(5); | ||
| } | ||
| } | ||
| } |
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,16 @@ | ||
| <configuration> | ||
|
|
||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
| <!-- encoders are assigned the type | ||
| ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> | ||
| <encoder> | ||
| <pattern>%d{HH:mm:ss.SSS} %-5level %logger - %msg%n</pattern> | ||
| </encoder> | ||
| </appender> | ||
|
|
||
| <root level="INFO"> | ||
| <appender-ref ref="STDOUT"/> | ||
| </root> | ||
|
|
||
| <logger name="org.testcontainers" level="INFO"/> | ||
| </configuration> |
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.
Uh oh!
There was an error while loading. Please reload this page.