Skip to content

Commit

Permalink
add protobuf tests for spring-kafka to make sure that ser/de abstract…
Browse files Browse the repository at this point in the history
…ion works when needed
  • Loading branch information
osoykan committed Nov 28, 2024
1 parent 3f0aa59 commit a6f0386
Show file tree
Hide file tree
Showing 12 changed files with 542 additions and 245 deletions.
2 changes: 1 addition & 1 deletion examples/spring-streams-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies {
implementation(libs.kafka.streams)
implementation(libs.kotlin.reflect)
implementation(libs.google.protobuf.kotlin)
implementation(libs.kafka.streams.registry)
implementation(libs.kafka.streams.protobuf.serde)
}

dependencies {
Expand Down
6 changes: 4 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ mockito = "5.4.0"
quiver = "0.5.12"
akkurate = "0.10.0"
exposed = "0.56.0"
kotlinx-serialization = "1.7.3"

[libraries]
kotlin-stdlib-jdk8 = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
Expand All @@ -61,7 +62,8 @@ kotlinx-slf4j = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-slf4j", ver
kotlinx-knit = { module = "org.jetbrains.kotlinx:kotlinx-knit", version.ref = "knit" }
kotlinx-io-reactor = { module = "io.projectreactor:reactor-core", version.ref = "io-reactor" }
kotlinx-io-reactor-extensions = { module = "io.projectreactor.kotlin:reactor-kotlin-extensions", version.ref = "io-reactor-extensions" }
kotlinx-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm", version = "1.7.3" }
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-jvm", version.ref = "kotlinx-serialization" }
kotlinx-serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "kotlinx-serialization" }

# Arrow
arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" }
Expand All @@ -86,7 +88,7 @@ akkurate-ksp-plugin = { module = "dev.nesk.akkurate:akkurate-ksp-plugin", versio
kafka = { module = "org.apache.kafka:kafka-clients", version.ref = "kafka" }
kafkaKotlin = { module = "io.github.nomisrev:kotlin-kafka", version.ref = "kafka-kotlin" }
kafka-streams = { module = "org.apache.kafka:kafka-streams", version.ref = "kafka" }
kafka-streams-registry = { module = "io.confluent:kafka-streams-protobuf-serde", version.ref = "kafka-streams-registry" }
kafka-streams-protobuf-serde = { module = "io.confluent:kafka-streams-protobuf-serde", version.ref = "kafka-streams-registry" }

# Couchbase
couchbase-kotlin = { module = "com.couchbase.client:kotlin-client", version.ref = "couchbase-kotlin" }
Expand Down
2 changes: 1 addition & 1 deletion lib/stove-testing-e2e/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
api(libs.jackson.kotlin)
api(libs.jackson.arrow)
api(libs.google.gson)
api(libs.kotlinx.serialization)
api(libs.kotlinx.serialization.json)
api(libs.testcontainers) {
version {
require(libs.testcontainers.asProvider().get().version!!)
Expand Down
24 changes: 24 additions & 0 deletions starters/spring/stove-spring-testing-e2e-kafka/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import com.google.protobuf.gradle.id

plugins {
alias(libs.plugins.protobuf)
}

dependencies {
api(projects.lib.stoveTestingE2e)
api(libs.testcontainers.kafka)
Expand All @@ -11,4 +17,22 @@ dependencies {
testImplementation(libs.spring.boot.autoconfigure)
testImplementation(projects.starters.spring.stoveSpringTestingE2e)
testImplementation(libs.logback.classic)
testImplementation(libs.google.protobuf.kotlin)
testImplementation(libs.kafka.streams.protobuf.serde)
}

protobuf {
protoc {
artifact = libs.protoc.get().toString()
}

generateProtoTasks {
all().forEach {
it.descriptorSetOptions.includeSourceInfo = true
it.descriptorSetOptions.includeImports = true
it.builtins { id("kotlin") }
}
}
}


Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,14 @@ data class FallbackTemplateSerde(

@StoveDsl
data class KafkaSystemOptions(

/**
* The registry of the Kafka image. The default value is `DEFAULT_REGISTRY`.
*/
val registry: String = DEFAULT_REGISTRY,

/**
* The ports of the Kafka container. The default value is `DEFAULT_KAFKA_PORTS`.
*/
val ports: List<Int> = DEFAULT_KAFKA_PORTS,

/**
* The serde that is used while publishing the messages. The default value is [StoveSerde.jackson].
* You can also pass ser/de during the publish operation.
Expand All @@ -68,26 +65,22 @@ data class KafkaSystemOptions(
* ```
*/
val serdeForPublish: StoveSerde<Any, *> = StoveSerde.jackson.anyJsonStringSerde(),

/**
* The fallback serde for Kafka. It is used to serialize and deserialize the messages before sending them to Kafka.
* If no [KafkaTemplate] is provided, it will be used to create a new [KafkaTemplate].
* Most of the time you won't need this.
*/
val fallbackSerde: FallbackTemplateSerde = FallbackTemplateSerde(),

/**
* Container options for Kafka.
*/
val containerOptions: KafkaContainerOptions = KafkaContainerOptions(),

/**
* Operations for Kafka. It is used to customize the operations of Kafka.
* The reason why this exists is to provide a way to interact with lower versions of Spring-Kafka dependencies.
* @see KafkaOps
*/
val ops: KafkaOps = KafkaOps(),

/**
* The configuration of the Kafka settings that is exposed to the Application Under Test(AUT).
*/
Expand Down

This file was deleted.

Loading

0 comments on commit a6f0386

Please sign in to comment.