-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: lizhou1111 <jianan.li@timeplus.com> Co-authored-by: Jasmine-ge <jasmine.ge@timeplus.io> Co-authored-by: Eddú Meléndez <eddu.melendez@gmail.com>
- Loading branch information
1 parent
e7f8af5
commit 0f9956a
Showing
17 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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> |