-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
550 additions
and
109 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 |
---|---|---|
|
@@ -10,6 +10,7 @@ jobs: | |
build: | ||
|
||
runs-on: ubuntu-latest | ||
concurrency: sequential | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
### 3.3.0 | ||
General: | ||
* Added support for starting containers on a predefined port | ||
|
||
### 3.2.0 | ||
|
||
#### ClickHouse: | ||
|
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
43 changes: 43 additions & 0 deletions
43
...ip/testcontainers/spring/clickhouse/ClickhouseContainerInitializerWithStaticPortTest.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,43 @@ | ||
package com.infobip.testcontainers.spring.clickhouse; | ||
|
||
import static com.infobip.testcontainers.spring.clickhouse.DataSourceConfig.CLICKHOUSE_URL_PROPERTY_NAME; | ||
import static org.assertj.core.api.BDDAssertions.then; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.jdbc.core.JdbcTemplate; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestConstructor; | ||
|
||
@AllArgsConstructor | ||
@ActiveProfiles("static-port") | ||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(classes = Main.class) | ||
class ClickhouseContainerInitializerWithStaticPortTest { | ||
|
||
Environment environment; | ||
DataSource dataSource; | ||
|
||
@Test | ||
void shouldCreateContainerWithStaticPort() { | ||
//given | ||
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource); | ||
|
||
//when | ||
String result = jdbcTemplate.queryForObject("SELECT 1", String.class); | ||
|
||
//then | ||
then(result).isEqualTo("1"); | ||
} | ||
|
||
@Test | ||
void shouldResolveHostInUrl() { | ||
// then | ||
then(environment.getProperty(CLICKHOUSE_URL_PROPERTY_NAME)).isEqualTo("jdbc:clickhouse://localhost:5001"); | ||
} | ||
|
||
} |
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
8 changes: 8 additions & 0 deletions
8
...khouse-testcontainers-spring-boot-starter/src/test/resources/application-static-port.yaml
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,8 @@ | ||
spring: | ||
datasource: | ||
clickhouse: | ||
jdbc-url: jdbc:clickhouse://<host>:5001 | ||
|
||
testcontainers: | ||
clickhouse: | ||
custom-path: "spring.datasource.clickhouse" |
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
54 changes: 54 additions & 0 deletions
54
.../com/infobip/testcontainers/spring/kafka/KafkaContainerInitializerWithStaticPortTest.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,54 @@ | ||
package com.infobip.testcontainers.spring.kafka; | ||
|
||
import static org.assertj.core.api.BDDAssertions.then; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
import java.time.Duration; | ||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
import lombok.AllArgsConstructor; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.boot.autoconfigure.kafka.KafkaProperties; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.kafka.core.KafkaTemplate; | ||
import org.springframework.kafka.support.SendResult; | ||
import org.springframework.test.context.ActiveProfiles; | ||
import org.springframework.test.context.TestConstructor; | ||
|
||
@AllArgsConstructor | ||
@ActiveProfiles("static-port") | ||
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL) | ||
@SpringBootTest(classes = Main.class) | ||
class KafkaContainerInitializerWithStaticPortTest { | ||
|
||
final static String TOPIC_NAME = "test-topic"; | ||
|
||
private final KafkaTemplate<String, String> kafkaTemplate; | ||
private final Listener listener; | ||
private final KafkaProperties kafkaProperties; | ||
|
||
@Test | ||
void shouldCreateContainer() throws InterruptedException, ExecutionException, TimeoutException { | ||
// given | ||
String givenValue = this.getClass().getName(); | ||
|
||
// when | ||
SendResult<?, ?> actual = kafkaTemplate.send(TOPIC_NAME, "key", givenValue) | ||
.completable() | ||
.get(10, TimeUnit.SECONDS); | ||
|
||
// then | ||
then(actual).isNotNull(); | ||
await().atMost(Duration.ofSeconds(10)) | ||
.untilAsserted(() -> then(listener.getValue()).isEqualTo(givenValue)); | ||
} | ||
|
||
@Test | ||
void shouldResolveHostInUrl() { | ||
// then | ||
then(kafkaProperties.getBootstrapServers()).containsExactly("localhost:5002"); | ||
} | ||
|
||
} |
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
8 changes: 8 additions & 0 deletions
8
...-kafka-testcontainers-spring-boot-starter/src/test/resources/application-static-port.yaml
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,8 @@ | ||
spring: | ||
kafka: | ||
consumer: | ||
groupId: static | ||
autoOffsetReset: earliest | ||
bootstrap-servers: <host>:5002 | ||
|
||
testcontainers.kafka.topics: test-topic:1:1 |
Oops, something went wrong.