SlideShare ist ein Scribd-Unternehmen logo
1 von 39
Downloaden Sie, um offline zu lesen
Testing SMTs?
Testcontainers to the rescue!
Fábio Sequeira | Mafalda Santos
Marionete
2
© 2023 Marionete Limited
• Kafka Connect is a tool for scalability and reliable data transmission between Apache Kafka and other data systems.
• Kafka Connectors are ready-to-use components useful for importing and exporting data between Kafka topics and external
systems (e.g. databases).
Testing SMTs
Kafka Connect & Connectors
Source Connector Sink Connector
Data Source Data Sink
Kafka
3
© 2023 Marionete Limited
• Single Message Transforms (SMTs) are used to transform message values and keys.
• Just like the connectors, there are ready-made and easy-to-use SMTs available.
Testing SMTs
SMTs
Source Connector Sink Connector
Data Source Data Sink
Kafka
SMT SMT
4
© 2023 Marionete Limited
There are plenty of SMTs available but…
Testing SMTs
5
© 2023 Marionete Limited
There are plenty of SMTs available but…
Testing SMTs
Sometimes they are not enough.
6
© 2023 Marionete Limited
We need to build
CUSTOM SMTs!
Testing SMTs
7
© 2023 Marionete Limited
SMTs are relatively easy to build…
Testing SMTs
8
© 2023 Marionete Limited
SMTs are relatively easy to build…
Testing SMTs
9
© 2023 Marionete Limited
Testing SMTs
Unit Tests Limitations
Data Source
Kafka Cluster
Kafka Connect
Connector
Instance
SMTs
Converter
Connect
Record
10
© 2023 Marionete Limited
Testing SMTs
Unit Tests Limitations
Data Source
Kafka Cluster
Kafka Connect
Connector
Instance
SMTs
Converter
Connect
Record
Unit Tests
?
?
?
11
© 2023 Marionete Limited
Testing SMTs
Unit Tests Limitations
• Hard to understand how the Connector reads the value types coming from a DB:
• Often got data in different formats or patterns than we expected
• Different connectors could “read” data differently
12
© 2023 Marionete Limited
Testing SMTs
Unit Tests Limitations
• Hard to understand how the Connector reads the value types coming from a DB:
• Often got data in different formats or patterns than we expected
• Different connectors could “read” data differently
• Certain DB-specific types are very difficult to define in unit tests:
• SQL Server types: Datetime2? Datetimeoffset?
13
© 2023 Marionete Limited
Testing SMTs
Unit Tests Limitations
• Hard to understand how the Connector reads the value types coming from a DB:
• Often got data in different formats or patterns than we expected
• Different connectors could “read” data differently
• Certain DB-specific types are very difficult to define in unit tests:
• SQL Server types: Datetime2? Datetimeoffset?
• Difficult to map/identify specific topic schema fields:
• Protobuf schemas: optional/oneof fields
14
© 2023 Marionete Limited
How to complement the SMTs tests with a more robust and effective test?
Testing SMTs
15
© 2023 Marionete Limited
How to complement the SMTs tests with a more robust and effective test?
Testing SMTs
© 2023 Marionete Limited
Testcontainers
to the rescue!
17
© 2023 Marionete Limited
Testcontainers to the rescue!
Testcontainers
• Set up, configure, and run Docker
containers
• Simplify integration testing
• Available in multiple languages
• (We used Java)
18
© 2023 Marionete Limited
Testcontainers to the rescue!
Containers for SMT Testing
• The Testcontainers library has a module for Kafka
• Example:
KafkaContainer kafka = new KafkaContainer(
DockerImageName.parse("confluentinc/cp-kafka:7.3.2")
)
• There are also modules for various types of databases.
• For our use cases, we used a Container object based on the Testcontainers MS SQL Server module.
• But we needed more than that…
19
© 2023 Marionete Limited
Testcontainers to the rescue!
Custom Testcontainer Library
KafkaContainer SchemaRegistryContainer ConnectContainer MsSqlServerContainer
20
© 2023 Marionete Limited
Testcontainers to the rescue!
SchemaRegistryContainer
public final class SchemaRegistryContainer extends GenericContainer<SchemaRegistryContainer> {
public SchemaRegistryContainer(DockerImageName image) {
super(image);
this.addExposedPorts(8081);
this.withEnv("SCHEMA_REGISTRY_HOST_NAME", this.getHost());
}
public SchemaRegistryContainer withKafka(KafkaContainer kafkaContainer) {
this.withNetwork(kafkaContainer.getNetwork());
this.withEnv(
"SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS",
"PLAINTEXT://" + kafkaContainer.getNetworkAliases().get(0) + ":9092"
);
return this;
}
}
21
© 2023 Marionete Limited
Testcontainers to the rescue!
SchemaRegistryContainer (cont)
public SchemaRegistryContainer setupSchemaRegistryContainer(
KafkaContainer kafkaContainer,
String alias,
String confluentVersion
) {
return new SchemaRegistryContainer(
DockerImageName
.parse("confluentinc/cp-schema-registry:" + confluentVersion))
.withNetworkAliases(alias)
.withKafka(kafkaContainer);
}
22
© 2023 Marionete Limited
Testcontainers to the rescue!
ConnectContainer
public final class ConnectContainer extends GenericContainer<ConnectContainer> {
public ConnectContainer(ImageFromDockerfile image) {
super(image);
this.addExposedPorts(8083);
this.withEnv("CONNECT_GROUP_ID", "testcontainer-connect-group");
this.withEnv("CONNECT_CONFIG_STORAGE_TOPIC", "connect-config");
this.withEnv("CONNECT_OFFSET_STORAGE_TOPIC", "connect-offsets");
this.withEnv("CONNECT_STATUS_STORAGE_TOPIC", "connect-status");
this.withEnv("CONNECT_REST_ADVERTISED_HOST_NAME", this.getHost());
this.withEnv(
"CONNECT_PLUGIN_PATH",
"/usr/share/java, /usr/share/confluent-hub-components/"
);
// ...
}
public ConnectContainer withKafka(KafkaContainer kafka, SchemaRegistryContainer registry) {
this.withNetwork(kafka.getNetwork());
this.withEnv(
"CONNECT_BOOTSTRAP_SERVERS",
"PLAINTEXT://" + kafka.getNetworkAliases().get(0) + ":9092”
);
this.dependsOn(kafka, registry);
return this;
}
}
23
© 2023 Marionete Limited
Testcontainers to the rescue!
ConnectContainer (cont)
public ConnectContainer setupConnectContainer(
KafkaContainer kafkaContainer,
SchemaRegistryContainer registryContainer,
String alias,
String confluentVersion
) {
return new ConnectContainer(
new ImageFromDockerfile().withDockerfileFromBuilder(
dockerfileBuilder -> dockerfileBuilder
.from("confluentinc/cp-kafka-connect:" + confluentVersion)
.run("/bin/bash", "-c", "confluent-hub install --no-prompt confluentinc/kafka-connect-jdbc:10.6.0")
.build()
)
)
.withKafka(kafkaContainer, registryContainer)
.withNetworkAliases(alias);
}
24
© 2023 Marionete Limited
Testcontainers to the rescue!
Custom Library Example Helper Methods
• createTopic() • registerSchema() • installSMT()
• registerConnector()
• runSQLFile()
KafkaContainer SchemaRegistryContainer ConnectContainer MsSqlServerContainer
25
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
26
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Custom SMT
Generate jar
27
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Custom SMT
28
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
Custom SMT
29
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
Custom SMT
30
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Custom SMT
31
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Consumer
Custom SMT
32
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Consumer
test-source-connector
Custom SMT
33
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Consumer
test-source-connector
Custom SMT
{
"name": "test-source-connector",
"config": {
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"tasks.max": "1",
"key.converter":
"org.apache.kafka.connect.storage.StringConverter",
"value.converter": "io.confluent.connect.avro.AvroConverter",
"value.converter.schema.registry.url": "http://schema:8081",
"value.converter.auto.register.schemas": "false",
"topic.prefix": "output-topic",
"connection.url":
"jdbc:sqlserver://mssql:1433;databaseName=TestDB;(...)",
"table.whitelist": "Input_Table",
// ...
"transforms": "myCustomSMT",
"transforms.myCustomSMT.type": "org.example.MyCustomSMT$Value",
"transforms.myCustomSMT.targetFields": "field1,field2"
}
}
34
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Consumer
test-source-connector
Input records
Custom SMT
35
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Source Connectors
KafkaContainer SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer
MsSqlServerContainer
Input table
output-topic
output-topic-value
Consumer
test-source-connector
Input records
Compare retrieved records
with expected records
Custom SMT
36
© 2023 Marionete Limited
Testcontainers to the rescue!
Test Setup – Sink Connectors
KafkaContainer
SchemaRegistryContainer
Installed plugins:
• JDBC connector
• Custom SMT
ConnectContainer MsSqlServerContainer
Output table
input-topic
input-topic-value
Producer
test-sink-connector
Compare retrieved records
with expected records
37
© 2023 Marionete Limited
Thank you!
© 2023 Marionete Limited
Contacts
www.marionete.co.uk
FÁBIO SEQUEIRA
fabiosequeira
MAFALDA SANTOS
mafaldajsantos
solutions@marionete.co.uk
@marionete_io
https://www.linkedin.com/company/marionete
Core Technology
Specialist
Core Technology
Specialist
Testing SMTs? Testcontainers to the Rescue! with Fábio Sequeira & Mafalda Santos

Weitere ähnliche Inhalte

Ähnlich wie Testing SMTs? Testcontainers to the Rescue! with Fábio Sequeira & Mafalda Santos

OpenStack Magnum 2016-08-04
OpenStack Magnum 2016-08-04OpenStack Magnum 2016-08-04
OpenStack Magnum 2016-08-04Adrian Otto
 
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...Flink Forward
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE
 
Real time data pipline with kafka streams
Real time data pipline with kafka streamsReal time data pipline with kafka streams
Real time data pipline with kafka streamsYoni Farin
 
Keep Your Kafka Cloud Costs in Check with Showbacks
Keep Your Kafka Cloud Costs in Check with ShowbacksKeep Your Kafka Cloud Costs in Check with Showbacks
Keep Your Kafka Cloud Costs in Check with ShowbacksHostedbyConfluent
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningGuido Schmutz
 
Kafka Connect & Kafka Streams/KSQL - the ecosystem around Kafka
Kafka Connect & Kafka Streams/KSQL - the ecosystem around KafkaKafka Connect & Kafka Streams/KSQL - the ecosystem around Kafka
Kafka Connect & Kafka Streams/KSQL - the ecosystem around KafkaGuido Schmutz
 
Making Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache MesosMaking Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache MesosJoe Stein
 
ACRN Kata Container on ACRN
ACRN Kata Container on ACRNACRN Kata Container on ACRN
ACRN Kata Container on ACRNProject ACRN
 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...Juarez Junior
 
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...Alex Maclinovsky
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikEdgar Espina
 
Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...
 Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S... Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...
Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...HostedbyConfluent
 
Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Steffen Gebert
 
Partner Development Guide for Kafka Connect
Partner Development Guide for Kafka ConnectPartner Development Guide for Kafka Connect
Partner Development Guide for Kafka Connectconfluent
 
OSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacyOSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacySteve Wong
 
Network Design patters with Docker
Network Design patters with DockerNetwork Design patters with Docker
Network Design patters with DockerDaniel Finneran
 
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...Alexey Bokov
 

Ähnlich wie Testing SMTs? Testcontainers to the Rescue! with Fábio Sequeira & Mafalda Santos (20)

OpenStack Magnum 2016-08-04
OpenStack Magnum 2016-08-04OpenStack Magnum 2016-08-04
OpenStack Magnum 2016-08-04
 
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
 
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE PlatformsFIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
 
Real time data pipline with kafka streams
Real time data pipline with kafka streamsReal time data pipline with kafka streams
Real time data pipline with kafka streams
 
Keep Your Kafka Cloud Costs in Check with Showbacks
Keep Your Kafka Cloud Costs in Check with ShowbacksKeep Your Kafka Cloud Costs in Check with Showbacks
Keep Your Kafka Cloud Costs in Check with Showbacks
 
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & PartitioningApache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
Apache Kafka - Event Sourcing, Monitoring, Librdkafka, Scaling & Partitioning
 
Kafka Connect & Kafka Streams/KSQL - the ecosystem around Kafka
Kafka Connect & Kafka Streams/KSQL - the ecosystem around KafkaKafka Connect & Kafka Streams/KSQL - the ecosystem around Kafka
Kafka Connect & Kafka Streams/KSQL - the ecosystem around Kafka
 
Making Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache MesosMaking Apache Kafka Elastic with Apache Mesos
Making Apache Kafka Elastic with Apache Mesos
 
ACRN Kata Container on ACRN
ACRN Kata Container on ACRNACRN Kata Container on ACRN
ACRN Kata Container on ACRN
 
MaxScale - The Pluggable Router
MaxScale - The Pluggable RouterMaxScale - The Pluggable Router
MaxScale - The Pluggable Router
 
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
TDC Connections 2023 - A High-Speed Data Ingestion Service in Java Using MQTT...
 
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
Three Degrees of Mediation: Challenges and Lessons in building Cloud-agnostic...
 
Apache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip HanikApache Tomcat 7 by Filip Hanik
Apache Tomcat 7 by Filip Hanik
 
Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...
 Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S... Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...
Walking through the Spring Stack for Apache Kafka with Soby Chacko | Kafka S...
 
Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0Monitoring Akka with Kamon 1.0
Monitoring Akka with Kamon 1.0
 
Partner Development Guide for Kafka Connect
Partner Development Guide for Kafka ConnectPartner Development Guide for Kafka Connect
Partner Development Guide for Kafka Connect
 
OSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacyOSS Japan 2019 service mesh bridging Kubernetes and legacy
OSS Japan 2019 service mesh bridging Kubernetes and legacy
 
Network Design patters with Docker
Network Design patters with DockerNetwork Design patters with Docker
Network Design patters with Docker
 
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...
Azure: Docker Container orchestration, PaaS ( Service Farbic ) and High avail...
 
Typesafe spark- Zalando meetup
Typesafe spark- Zalando meetupTypesafe spark- Zalando meetup
Typesafe spark- Zalando meetup
 

Mehr von HostedbyConfluent

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Renaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit LondonRenaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit LondonHostedbyConfluent
 
Evolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at TrendyolEvolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at TrendyolHostedbyConfluent
 
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking TechniquesEnsuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking TechniquesHostedbyConfluent
 
Exactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and KafkaExactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and KafkaHostedbyConfluent
 
Fish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit LondonFish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit LondonHostedbyConfluent
 
Tiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit LondonTiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit LondonHostedbyConfluent
 
Building a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And WhyBuilding a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And WhyHostedbyConfluent
 
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...HostedbyConfluent
 
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...HostedbyConfluent
 
Navigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka ClustersNavigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka ClustersHostedbyConfluent
 
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data PlatformApache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data PlatformHostedbyConfluent
 
Explaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy PubExplaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy PubHostedbyConfluent
 
TL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit LondonTL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit LondonHostedbyConfluent
 
A Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSLA Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSLHostedbyConfluent
 
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing PerformanceMastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing PerformanceHostedbyConfluent
 
Data Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and BeyondData Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and BeyondHostedbyConfluent
 
Code-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink AppsCode-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink AppsHostedbyConfluent
 
Debezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC EcosystemDebezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC EcosystemHostedbyConfluent
 
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local DisksBeyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local DisksHostedbyConfluent
 

Mehr von HostedbyConfluent (20)

Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Renaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit LondonRenaming a Kafka Topic | Kafka Summit London
Renaming a Kafka Topic | Kafka Summit London
 
Evolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at TrendyolEvolution of NRT Data Ingestion Pipeline at Trendyol
Evolution of NRT Data Ingestion Pipeline at Trendyol
 
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking TechniquesEnsuring Kafka Service Resilience: A Dive into Health-Checking Techniques
Ensuring Kafka Service Resilience: A Dive into Health-Checking Techniques
 
Exactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and KafkaExactly-once Stream Processing with Arroyo and Kafka
Exactly-once Stream Processing with Arroyo and Kafka
 
Fish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit LondonFish Plays Pokemon | Kafka Summit London
Fish Plays Pokemon | Kafka Summit London
 
Tiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit LondonTiered Storage 101 | Kafla Summit London
Tiered Storage 101 | Kafla Summit London
 
Building a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And WhyBuilding a Self-Service Stream Processing Portal: How And Why
Building a Self-Service Stream Processing Portal: How And Why
 
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
From the Trenches: Improving Kafka Connect Source Connector Ingestion from 7 ...
 
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
Future with Zero Down-Time: End-to-end Resiliency with Chaos Engineering and ...
 
Navigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka ClustersNavigating Private Network Connectivity Options for Kafka Clusters
Navigating Private Network Connectivity Options for Kafka Clusters
 
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data PlatformApache Flink: Building a Company-wide Self-service Streaming Data Platform
Apache Flink: Building a Company-wide Self-service Streaming Data Platform
 
Explaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy PubExplaining How Real-Time GenAI Works in a Noisy Pub
Explaining How Real-Time GenAI Works in a Noisy Pub
 
TL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit LondonTL;DR Kafka Metrics | Kafka Summit London
TL;DR Kafka Metrics | Kafka Summit London
 
A Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSLA Window Into Your Kafka Streams Tasks | KSL
A Window Into Your Kafka Streams Tasks | KSL
 
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing PerformanceMastering Kafka Producer Configs: A Guide to Optimizing Performance
Mastering Kafka Producer Configs: A Guide to Optimizing Performance
 
Data Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and BeyondData Contracts Management: Schema Registry and Beyond
Data Contracts Management: Schema Registry and Beyond
 
Code-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink AppsCode-First Approach: Crafting Efficient Flink Apps
Code-First Approach: Crafting Efficient Flink Apps
 
Debezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC EcosystemDebezium vs. the World: An Overview of the CDC Ecosystem
Debezium vs. the World: An Overview of the CDC Ecosystem
 
Beyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local DisksBeyond Tiered Storage: Serverless Kafka with No Local Disks
Beyond Tiered Storage: Serverless Kafka with No Local Disks
 

Kürzlich hochgeladen

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 

Kürzlich hochgeladen (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

Testing SMTs? Testcontainers to the Rescue! with Fábio Sequeira & Mafalda Santos

  • 1. Testing SMTs? Testcontainers to the rescue! Fábio Sequeira | Mafalda Santos Marionete
  • 2. 2 © 2023 Marionete Limited • Kafka Connect is a tool for scalability and reliable data transmission between Apache Kafka and other data systems. • Kafka Connectors are ready-to-use components useful for importing and exporting data between Kafka topics and external systems (e.g. databases). Testing SMTs Kafka Connect & Connectors Source Connector Sink Connector Data Source Data Sink Kafka
  • 3. 3 © 2023 Marionete Limited • Single Message Transforms (SMTs) are used to transform message values and keys. • Just like the connectors, there are ready-made and easy-to-use SMTs available. Testing SMTs SMTs Source Connector Sink Connector Data Source Data Sink Kafka SMT SMT
  • 4. 4 © 2023 Marionete Limited There are plenty of SMTs available but… Testing SMTs
  • 5. 5 © 2023 Marionete Limited There are plenty of SMTs available but… Testing SMTs Sometimes they are not enough.
  • 6. 6 © 2023 Marionete Limited We need to build CUSTOM SMTs! Testing SMTs
  • 7. 7 © 2023 Marionete Limited SMTs are relatively easy to build… Testing SMTs
  • 8. 8 © 2023 Marionete Limited SMTs are relatively easy to build… Testing SMTs
  • 9. 9 © 2023 Marionete Limited Testing SMTs Unit Tests Limitations Data Source Kafka Cluster Kafka Connect Connector Instance SMTs Converter Connect Record
  • 10. 10 © 2023 Marionete Limited Testing SMTs Unit Tests Limitations Data Source Kafka Cluster Kafka Connect Connector Instance SMTs Converter Connect Record Unit Tests ? ? ?
  • 11. 11 © 2023 Marionete Limited Testing SMTs Unit Tests Limitations • Hard to understand how the Connector reads the value types coming from a DB: • Often got data in different formats or patterns than we expected • Different connectors could “read” data differently
  • 12. 12 © 2023 Marionete Limited Testing SMTs Unit Tests Limitations • Hard to understand how the Connector reads the value types coming from a DB: • Often got data in different formats or patterns than we expected • Different connectors could “read” data differently • Certain DB-specific types are very difficult to define in unit tests: • SQL Server types: Datetime2? Datetimeoffset?
  • 13. 13 © 2023 Marionete Limited Testing SMTs Unit Tests Limitations • Hard to understand how the Connector reads the value types coming from a DB: • Often got data in different formats or patterns than we expected • Different connectors could “read” data differently • Certain DB-specific types are very difficult to define in unit tests: • SQL Server types: Datetime2? Datetimeoffset? • Difficult to map/identify specific topic schema fields: • Protobuf schemas: optional/oneof fields
  • 14. 14 © 2023 Marionete Limited How to complement the SMTs tests with a more robust and effective test? Testing SMTs
  • 15. 15 © 2023 Marionete Limited How to complement the SMTs tests with a more robust and effective test? Testing SMTs
  • 16. © 2023 Marionete Limited Testcontainers to the rescue!
  • 17. 17 © 2023 Marionete Limited Testcontainers to the rescue! Testcontainers • Set up, configure, and run Docker containers • Simplify integration testing • Available in multiple languages • (We used Java)
  • 18. 18 © 2023 Marionete Limited Testcontainers to the rescue! Containers for SMT Testing • The Testcontainers library has a module for Kafka • Example: KafkaContainer kafka = new KafkaContainer( DockerImageName.parse("confluentinc/cp-kafka:7.3.2") ) • There are also modules for various types of databases. • For our use cases, we used a Container object based on the Testcontainers MS SQL Server module. • But we needed more than that…
  • 19. 19 © 2023 Marionete Limited Testcontainers to the rescue! Custom Testcontainer Library KafkaContainer SchemaRegistryContainer ConnectContainer MsSqlServerContainer
  • 20. 20 © 2023 Marionete Limited Testcontainers to the rescue! SchemaRegistryContainer public final class SchemaRegistryContainer extends GenericContainer<SchemaRegistryContainer> { public SchemaRegistryContainer(DockerImageName image) { super(image); this.addExposedPorts(8081); this.withEnv("SCHEMA_REGISTRY_HOST_NAME", this.getHost()); } public SchemaRegistryContainer withKafka(KafkaContainer kafkaContainer) { this.withNetwork(kafkaContainer.getNetwork()); this.withEnv( "SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS", "PLAINTEXT://" + kafkaContainer.getNetworkAliases().get(0) + ":9092" ); return this; } }
  • 21. 21 © 2023 Marionete Limited Testcontainers to the rescue! SchemaRegistryContainer (cont) public SchemaRegistryContainer setupSchemaRegistryContainer( KafkaContainer kafkaContainer, String alias, String confluentVersion ) { return new SchemaRegistryContainer( DockerImageName .parse("confluentinc/cp-schema-registry:" + confluentVersion)) .withNetworkAliases(alias) .withKafka(kafkaContainer); }
  • 22. 22 © 2023 Marionete Limited Testcontainers to the rescue! ConnectContainer public final class ConnectContainer extends GenericContainer<ConnectContainer> { public ConnectContainer(ImageFromDockerfile image) { super(image); this.addExposedPorts(8083); this.withEnv("CONNECT_GROUP_ID", "testcontainer-connect-group"); this.withEnv("CONNECT_CONFIG_STORAGE_TOPIC", "connect-config"); this.withEnv("CONNECT_OFFSET_STORAGE_TOPIC", "connect-offsets"); this.withEnv("CONNECT_STATUS_STORAGE_TOPIC", "connect-status"); this.withEnv("CONNECT_REST_ADVERTISED_HOST_NAME", this.getHost()); this.withEnv( "CONNECT_PLUGIN_PATH", "/usr/share/java, /usr/share/confluent-hub-components/" ); // ... } public ConnectContainer withKafka(KafkaContainer kafka, SchemaRegistryContainer registry) { this.withNetwork(kafka.getNetwork()); this.withEnv( "CONNECT_BOOTSTRAP_SERVERS", "PLAINTEXT://" + kafka.getNetworkAliases().get(0) + ":9092” ); this.dependsOn(kafka, registry); return this; } }
  • 23. 23 © 2023 Marionete Limited Testcontainers to the rescue! ConnectContainer (cont) public ConnectContainer setupConnectContainer( KafkaContainer kafkaContainer, SchemaRegistryContainer registryContainer, String alias, String confluentVersion ) { return new ConnectContainer( new ImageFromDockerfile().withDockerfileFromBuilder( dockerfileBuilder -> dockerfileBuilder .from("confluentinc/cp-kafka-connect:" + confluentVersion) .run("/bin/bash", "-c", "confluent-hub install --no-prompt confluentinc/kafka-connect-jdbc:10.6.0") .build() ) ) .withKafka(kafkaContainer, registryContainer) .withNetworkAliases(alias); }
  • 24. 24 © 2023 Marionete Limited Testcontainers to the rescue! Custom Library Example Helper Methods • createTopic() • registerSchema() • installSMT() • registerConnector() • runSQLFile() KafkaContainer SchemaRegistryContainer ConnectContainer MsSqlServerContainer
  • 25. 25 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer
  • 26. 26 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Custom SMT Generate jar
  • 27. 27 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Custom SMT
  • 28. 28 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table Custom SMT
  • 29. 29 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic Custom SMT
  • 30. 30 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Custom SMT
  • 31. 31 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Consumer Custom SMT
  • 32. 32 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Consumer test-source-connector Custom SMT
  • 33. 33 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Consumer test-source-connector Custom SMT { "name": "test-source-connector", "config": { "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector", "tasks.max": "1", "key.converter": "org.apache.kafka.connect.storage.StringConverter", "value.converter": "io.confluent.connect.avro.AvroConverter", "value.converter.schema.registry.url": "http://schema:8081", "value.converter.auto.register.schemas": "false", "topic.prefix": "output-topic", "connection.url": "jdbc:sqlserver://mssql:1433;databaseName=TestDB;(...)", "table.whitelist": "Input_Table", // ... "transforms": "myCustomSMT", "transforms.myCustomSMT.type": "org.example.MyCustomSMT$Value", "transforms.myCustomSMT.targetFields": "field1,field2" } }
  • 34. 34 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Consumer test-source-connector Input records Custom SMT
  • 35. 35 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Source Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Input table output-topic output-topic-value Consumer test-source-connector Input records Compare retrieved records with expected records Custom SMT
  • 36. 36 © 2023 Marionete Limited Testcontainers to the rescue! Test Setup – Sink Connectors KafkaContainer SchemaRegistryContainer Installed plugins: • JDBC connector • Custom SMT ConnectContainer MsSqlServerContainer Output table input-topic input-topic-value Producer test-sink-connector Compare retrieved records with expected records
  • 37. 37 © 2023 Marionete Limited Thank you!
  • 38. © 2023 Marionete Limited Contacts www.marionete.co.uk FÁBIO SEQUEIRA fabiosequeira MAFALDA SANTOS mafaldajsantos solutions@marionete.co.uk @marionete_io https://www.linkedin.com/company/marionete Core Technology Specialist Core Technology Specialist