MyGit

testcontainers-all-things-kafka/cp-testcontainers

Fork: 12 Star: 47 (更新于 2024-09-04 19:19:20)

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-10-04 22:44:02 tronprotocol/java-tron

2024-10-04 14:22:57 apache/mina-sshd

2024-10-03 23:03:18 Eanya-Tonic/CCTV_Viewer

2024-10-02 13:21:56 apache/dubbo

2024-10-01 06:18:31 testcontainers/testcontainers-java

2024-10-01 04:58:51 dromara/dante-cloud