-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: Standalone kafka now hosts a grpc endpoint to communicate an…
…d understand the messages
- Loading branch information
Showing
24 changed files
with
575 additions
and
389 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,7 +1,9 @@ | ||
plugins { `kotlin-dsl` } | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
mavenCentral() | ||
google() | ||
gradlePluginPortal() | ||
} |
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 @@ | ||
rootProject.name = "buildSrc" | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
create("libs").from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
|
||
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") |
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 |
---|---|---|
@@ -1,13 +1,58 @@ | ||
plugins { | ||
alias(libs.plugins.wire) | ||
} | ||
|
||
dependencies { | ||
api(projects.lib.stoveTestingE2e) | ||
api(libs.testcontainers.kafka) | ||
implementation(libs.kafka) | ||
implementation(libs.kotlinx.io.reactor.extensions) | ||
implementation(libs.kotlinx.jdk8) | ||
implementation(libs.kotlinx.core) | ||
implementation(libs.kafkaKotlin) | ||
api(projects.lib.stoveTestingE2e) | ||
api(libs.testcontainers.kafka) | ||
implementation(libs.kafka) | ||
implementation(libs.kotlinx.io.reactor.extensions) | ||
implementation(libs.kotlinx.jdk8) | ||
implementation(libs.kotlinx.core) | ||
implementation(libs.kafkaKotlin) | ||
|
||
api(libs.wire.grpc.server) | ||
api(libs.wire.grpc.client) | ||
api(libs.wire.grpc.runtime) | ||
api(libs.io.grpc) | ||
api(libs.io.grpc.protobuf) | ||
api(libs.io.grpc.stub) | ||
api(libs.io.grpc.kotlin) | ||
api(libs.io.grpc.netty) | ||
api(libs.google.protobuf.kotlin) | ||
} | ||
|
||
dependencies { | ||
testImplementation(libs.slf4j.simple) | ||
testImplementation(libs.slf4j.simple) | ||
} | ||
|
||
buildscript { | ||
dependencies { | ||
classpath(libs.wire.grpc.server.generator) | ||
} | ||
} | ||
|
||
wire { | ||
sourcePath("src/main/proto") | ||
kotlin { | ||
rpcRole = "client" | ||
rpcCallStyle = "suspending" | ||
exclusive = false | ||
javaInterop = true | ||
} | ||
kotlin { | ||
custom { | ||
schemaHandlerFactory = com.squareup.wire.kotlin.grpcserver.GrpcServerSchemaHandler.Factory() | ||
options = mapOf( | ||
"singleMethodServices" to "false", | ||
"rpcCallStyle" to "suspending" | ||
) | ||
} | ||
rpcRole = "server" | ||
rpcCallStyle = "suspending" | ||
exclusive = false | ||
singleMethodServices = false | ||
javaInterop = true | ||
includes = listOf("StoveKafkaObserverService") | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/main/kotlin/com/trendyol/stove/testing/e2e/standalone/kafka/KafkaContainerOptions.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,19 @@ | ||
package com.trendyol.stove.testing.e2e.standalone.kafka | ||
|
||
import com.trendyol.stove.testing.e2e.containers.ContainerFn | ||
import com.trendyol.stove.testing.e2e.containers.ContainerOptions | ||
import com.trendyol.stove.testing.e2e.containers.DEFAULT_REGISTRY | ||
import org.testcontainers.containers.KafkaContainer | ||
|
||
data class KafkaContainerOptions( | ||
override val registry: String = DEFAULT_REGISTRY, | ||
override val image: String = "confluentinc/cp-kafka", | ||
override val tag: String = "latest", | ||
val ports: List<Int> = DEFAULT_KAFKA_PORTS, | ||
override val compatibleSubstitute: String? = null, | ||
override val containerFn: ContainerFn<KafkaContainer> = { } | ||
) : ContainerOptions { | ||
companion object { | ||
val DEFAULT_KAFKA_PORTS = listOf(9092, 9093) | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...e2e-kafka/src/main/kotlin/com/trendyol/stove/testing/e2e/standalone/kafka/KafkaContext.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,40 @@ | ||
package com.trendyol.stove.testing.e2e.standalone.kafka | ||
|
||
import arrow.core.getOrElse | ||
import com.trendyol.stove.testing.e2e.containers.withProvidedRegistry | ||
import com.trendyol.stove.testing.e2e.system.* | ||
import com.trendyol.stove.testing.e2e.system.abstractions.SystemNotRegisteredException | ||
import com.trendyol.stove.testing.e2e.system.annotations.StoveDsl | ||
import org.testcontainers.containers.KafkaContainer | ||
|
||
data class KafkaContext( | ||
val container: KafkaContainer, | ||
val options: KafkaSystemOptions | ||
) | ||
|
||
internal fun TestSystem.kafka(): KafkaSystem = getOrNone<KafkaSystem>().getOrElse { | ||
throw SystemNotRegisteredException(KafkaSystem::class) | ||
} | ||
|
||
internal fun TestSystem.withKafka(options: KafkaSystemOptions = KafkaSystemOptions()): TestSystem { | ||
val kafka = withProvidedRegistry( | ||
options.containerOptions.imageWithTag, | ||
options.containerOptions.registry, | ||
options.containerOptions.compatibleSubstitute | ||
) { | ||
KafkaContainer(it) | ||
.withExposedPorts(*options.containerOptions.ports.toTypedArray()) | ||
.apply(options.containerOptions.containerFn) | ||
.withReuse(this.options.keepDependenciesRunning) | ||
} | ||
getOrRegister(KafkaSystem(this, KafkaContext(kafka, options))) | ||
return this | ||
} | ||
|
||
@StoveDsl | ||
suspend fun ValidationDsl.kafka( | ||
validation: @StoveDsl suspend KafkaSystem.() -> Unit | ||
): Unit = validation(this.testSystem.kafka()) | ||
|
||
@StoveDsl | ||
fun WithDsl.kafka(configure: () -> KafkaSystemOptions): TestSystem = this.testSystem.withKafka(configure()) |
7 changes: 7 additions & 0 deletions
7
.../main/kotlin/com/trendyol/stove/testing/e2e/standalone/kafka/KafkaExposedConfiguration.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,7 @@ | ||
package com.trendyol.stove.testing.e2e.standalone.kafka | ||
|
||
import com.trendyol.stove.testing.e2e.system.abstractions.ExposedConfiguration | ||
|
||
data class KafkaExposedConfiguration( | ||
val bootstrapServers: String | ||
) : ExposedConfiguration |
Oops, something went wrong.