MyGit

testcontainers-all-things-kafka/cp-testcontainers

Fork: 13 Star: 49 (更新于 2024-11-22 06:25:25)

license: MIT

Language: Java .

Testcontainers for the Confluent Platform Components

最后发布版本: v0.2.1 ( 2022-04-25 00:16:37)

GitHub网址

CP testcontainers

Testcontainers modules for Confluent Platform components.

Example

The following snippet will start an Apache Kafka and a Schema Registry container on the same network

final var factory = new CPTestContainerFactory();

final KafkaContainer kafka = factory.createKafka();
final SchemaRegistryContainer schemaRegistry = factory.createSchemaRegistry(kafka);
schemaRegistry.start(); //will implicitly start kafka container

The following snippet can then be used to configure a producer to use these:

properties.put("bootstrap.servers",   kafka.getBootstrapServers());
//...
properties.put("schema.registry.url", schemaRegistry.getBaseUrl());

The following snippet starts a single node Kafka Connect cluster with two connectors from Confluent Hub installed:

final var connect = factory.createCustomConnector(
        Set.of(
            "confluentinc/kafka-connect-s3:latest", 
            "confluentinc/kafka-connect-datagen:0.4.0"
        ), kafka);
connect.start();

The following snippet configures a CP-server container and a schema registry container with RBAC enabled:

final var factory = new CPTestContainerFactory(network);
final var ldap = factory.createLdap();

final var confluentServer = factory.createConfluentServer().enableRbac();

final var sr = factory.createSchemaRegistry(confluentServer).enableRbac();
sr.start()

See the intTest source set for examples on how to set up containers.

Supported components

So far the following components are supported:

  • Confluent Server
  • Confluent Schema Registry
  • ksqlDB
  • Kafka Connect
  • Confluent Replicator running on Connect
  • Confluent REST Proxy.

Moreover, we can create KafkaContainer instances which have RBAC and MDS enabled. So far, the following components can be configured to use RBAC:

  • Confluent Server
  • Confluent Schema Registry
  • Kafka Connect (without secret registry)

Packages

Project package are hosted on jitpack for the time being. Add the following to your gradle file:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

dependencies {
    implementation 'com.github.christophschubert:cp-testcontainers:Tag'
}

See the jitpack page of the project for information on how to use the package with mvn or sbt.

Noteworthy demos

  • LocalStackIntTest shows how to setup S3 sink connector with S3 installation based on localstack.

Troubleshooting

No non-overlapping IPv4 addresses

Status 404: {"message":"could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"}

Solution: use docker network prune to delete

最近版本更新:(数据更新于 2024-09-03 10:59:51)

2022-04-25 00:16:37 v0.2.1

2022-04-24 23:27:52 v0.2.0

2021-01-03 22:07:23 v0.1.0

testcontainers-all-things-kafka/cp-testcontainers同语言 Java最近更新仓库

2024-11-21 20:32:01 spring-projects/spring-boot

2024-11-21 09:44:43 Card-Forge/forge

2024-11-19 23:42:52 spring-projects/spring-authorization-server

2024-11-18 21:40:12 4379711/lol-helper

2024-11-16 22:50:41 xuxueli/xxl-job

2024-11-16 19:06:35 Stirling-Tools/Stirling-PDF