-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated kafka repository to use test containers (#30)
* updated kafka repository to use test containers Signed-off-by: Ayan Sen <[email protected]> * fixed bugs in topic creation for test Signed-off-by: Ayan Sen <[email protected]> --------- Signed-off-by: Ayan Sen <[email protected]>
- Loading branch information
Showing
7 changed files
with
97 additions
and
63 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 |
---|---|---|
@@ -1,19 +1,18 @@ | ||
plugins { | ||
id 'ayansen.playground.kotlin-common-conventions' | ||
id 'com.github.davidmc24.gradle.plugin.avro' version '1.3.0' | ||
id 'com.avast.gradle.docker-compose' version '0.16.8' | ||
} | ||
repositories { | ||
maven { | ||
url 'https://packages.confluent.io/maven/' | ||
} | ||
} | ||
dockerCompose.isRequiredBy(test) | ||
|
||
dependencies { | ||
implementation 'org.apache.kafka:kafka-streams:2.5.0' | ||
implementation 'org.apache.kafka:kafka-clients:2.6.0' | ||
implementation 'io.confluent:kafka-avro-serializer:7.2.1' | ||
implementation 'org.apache.avro:avro:1.10.0' | ||
testImplementation "org.testcontainers:kafka:1.19.3" | ||
testImplementation 'org.apache.kafka:kafka-streams-test-utils:2.6.0' | ||
} |
This file was deleted.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
kafka/src/test/kotlin/ayansen/playground/kafka/SchemaRegistryContainer.kt
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,35 @@ | ||
package ayansen.playground.kafka | ||
|
||
import org.testcontainers.containers.GenericContainer | ||
import org.testcontainers.containers.KafkaContainer | ||
import org.testcontainers.containers.Network | ||
|
||
import org.testcontainers.containers.wait.strategy.Wait | ||
|
||
|
||
class SchemaRegistryContainer : | ||
GenericContainer<SchemaRegistryContainer>("$SCHEMA_REGISTRY_IMAGE:$CONFLUENT_PLATFORM_VERSION") { | ||
companion object { | ||
const val SCHEMA_REGISTRY_IMAGE = "confluentinc/cp-schema-registry" | ||
const val SCHEMA_REGISTRY_PORT = 8081 | ||
const val CONFLUENT_PLATFORM_VERSION = "5.5.1" | ||
} | ||
|
||
lateinit var schemaRegistryUrl: String | ||
|
||
init { | ||
waitingFor(Wait.forHttp("/subjects").forStatusCode(200)) | ||
withExposedPorts(SCHEMA_REGISTRY_PORT) | ||
} | ||
|
||
fun withKafka(kafka: KafkaContainer): SchemaRegistryContainer { | ||
withNetwork(kafka.network) | ||
withEnv("SCHEMA_REGISTRY_HOST_NAME", "schema-registry") | ||
withEnv("SCHEMA_REGISTRY_LISTENERS", "http://0.0.0.0:$SCHEMA_REGISTRY_PORT") | ||
withEnv("SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", "PLAINTEXT://${kafka.networkAliases[0]}:9092") | ||
start() | ||
schemaRegistryUrl = "http://$host:${getMappedPort(SCHEMA_REGISTRY_PORT)}" | ||
return self() | ||
} | ||
|
||
} |
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