← ZIO Kafka docs

KafkaTestUtils

zio.kafka.testkit.KafkaTestUtils

Attributes

Source
KafkaTestUtils.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def consumeWithStrings(clientId: String, groupId: Option[String] = ..., subscription: Subscription)(r: ConsumerRecord[String, String] => URIO[Any, Unit]): RIO[Kafka, Unit]

Consumes a stream of ConsumerRecords for topics that have String keys and String values.

Consumes a stream of ConsumerRecords for topics that have String keys and String values.

For each consumed record, the provided r function will be called.

Attributes

Source
KafkaTestUtils.scala
def consumer(clientId: String, groupId: Option[String] = ..., clientInstanceId: Option[String] = ..., offsetRetrieval: OffsetRetrieval = ..., allowAutoCreateTopics: Boolean = ..., diagnostics: ConsumerDiagnostics = ..., rebalanceSafeCommits: Boolean = ..., maxRebalanceDuration: Duration = ..., commitTimeout: Duration = ..., properties: Map[String, String] = ...): ZLayer[Kafka, Throwable, Consumer]

Consumer layer for use in tests.

Consumer layer for use in tests.

ℹ️ Instead of using a layer, consider using makeConsumer to directly get a consumer.

Attributes

Source
KafkaTestUtils.scala
def consumerSettings(clientId: String, groupId: Option[String] = ..., clientInstanceId: Option[String] = ..., allowAutoCreateTopics: Boolean = ..., offsetRetrieval: OffsetRetrieval = ..., rebalanceSafeCommits: Boolean = ..., maxRebalanceDuration: Duration = ..., maxPollInterval: Duration = ..., max.poll.records: Int = ..., commitTimeout: Duration = ..., diagnostics: ConsumerDiagnostics = ..., properties: Map[String, String] = ...): URIO[Kafka, ConsumerSettings]

Makes ConsumerSettings for use in tests.

Makes ConsumerSettings for use in tests.

Attributes

Source
KafkaTestUtils.scala
def createCustomTopic(topic: String, partitionCount: Int = ...): ZIO[Kafka, Throwable, Unit]

Create a topic.

Create a topic.

Attributes

Source
KafkaTestUtils.scala

Makes a AdminClient for use in tests.

Makes a AdminClient for use in tests.

Attributes

Source
KafkaTestUtils.scala
def makeConsumer(clientId: String, groupId: Option[String] = ..., clientInstanceId: Option[String] = ..., offsetRetrieval: OffsetRetrieval = ..., allowAutoCreateTopics: Boolean = ..., diagnostics: ConsumerDiagnostics = ..., rebalanceSafeCommits: Boolean = ..., maxRebalanceDuration: Duration = ..., commitTimeout: Duration = ..., properties: Map[String, String] = ...): ZIO[Scope & Kafka, Throwable, Consumer]

Makes a Consumer for use in tests.

Makes a Consumer for use in tests.

Attributes

Source
KafkaTestUtils.scala
def makeSaslAdminClient(username: String = ..., password: String = ...): ZIO[Scope & Sasl, Throwable, AdminClient]

Makes a AdminClient for use in tests, using the SASL_PLAINTEXT security protocol.

Makes a AdminClient for use in tests, using the SASL_PLAINTEXT security protocol.

Attributes

Source
KafkaTestUtils.scala

Makes a AdminClient for use in tests, using the SSL security protocol.

Makes a AdminClient for use in tests, using the SSL security protocol.

Attributes

Source
KafkaTestUtils.scala
def makeTransactionalConsumer(clientId: String, groupId: String, clientInstanceId: Option[String] = ..., offsetRetrieval: OffsetRetrieval = ..., allowAutoCreateTopics: Boolean = ..., diagnostics: ConsumerDiagnostics = ..., rebalanceSafeCommits: Boolean = ..., properties: Map[String, String] = ..., rebalanceListener: RebalanceListener = ...): ZIO[Scope & Kafka, Throwable, Consumer]

Makes a transactional Consumer for use in tests.

Makes a transactional Consumer for use in tests.

Attributes

Source
KafkaTestUtils.scala

Makes a TransactionalProducer for use in tests.

Makes a TransactionalProducer for use in tests.

Note: to run multiple tests in parallel, every test needs a different transactional id.

Attributes

Source
KafkaTestUtils.scala
def produceMany(producer: Producer, topic: String, partition: Int, kvs: Iterable[(String, String)]): ZIO[Any, Throwable, Chunk[RecordMetadata]]

Produce many messages to the given partition of a topic.

Produce many messages to the given partition of a topic.

Attributes

Source
KafkaTestUtils.scala
def produceMany(producer: Producer, topic: String, kvs: Iterable[(String, String)]): ZIO[Any, Throwable, Chunk[RecordMetadata]]

Produce many messages to a topic.

Produce many messages to a topic.

Attributes

Source
KafkaTestUtils.scala
def produceOne(producer: Producer, topic: String, key: String, message: String): ZIO[Any, Throwable, RecordMetadata]

Produce a single message to a topic.

Produce a single message to a topic.

Attributes

Source
KafkaTestUtils.scala
def produceOne(producer: Producer, topic: String, partition: Int, key: String, message: String): ZIO[Any, Throwable, RecordMetadata]

Produce a single message to the given partition of a topic.

Produce a single message to the given partition of a topic.

Attributes

Source
KafkaTestUtils.scala
def saslAdminSettings(username: String, password: String): ZIO[Sasl, Nothing, AdminClientSettings]

Makes AdminClientSettings for use in tests, using SASL_PLAINTEXT security protocol.

Makes AdminClientSettings for use in tests, using SASL_PLAINTEXT security protocol.

Attributes

Source
KafkaTestUtils.scala
def scheduledProduce[R](producer: Producer, topic: String, schedule: Schedule[R, Any, Long]): ZStream[R, Throwable, RecordMetadata]

A stream that produces messages to a topic on a schedule for as long as it is running.

A stream that produces messages to a topic on a schedule for as long as it is running.

Attributes

Source
KafkaTestUtils.scala
def transactionalConsumer(clientId: String, groupId: String, clientInstanceId: Option[String] = ..., offsetRetrieval: OffsetRetrieval = ..., allowAutoCreateTopics: Boolean = ..., diagnostics: ConsumerDiagnostics = ..., rebalanceSafeCommits: Boolean = ..., properties: Map[String, String] = ..., rebalanceListener: RebalanceListener = ...): ZLayer[Kafka, Throwable, Consumer]

A transactional Consumer layer for use in tests.

A transactional Consumer layer for use in tests.

ℹ️ Instead of using a layer, consider using KafkaTestUtils.makeTransactionalConsumer to directly get a consumer.

Attributes

Source
KafkaTestUtils.scala
def transactionalConsumerSettings(groupId: String, clientId: String, clientInstanceId: Option[String] = ..., allowAutoCreateTopics: Boolean = ..., offsetRetrieval: OffsetRetrieval = ..., rebalanceSafeCommits: Boolean = ..., diagnostics: ConsumerDiagnostics = ..., properties: Map[String, String] = ...): URIO[Kafka, ConsumerSettings]

Makes ConsumerSettings for a transactional consumer, for use in tests.

Makes ConsumerSettings for a transactional consumer, for use in tests.

Attributes

Source
KafkaTestUtils.scala

TransactionalProducer layer for use in tests.

TransactionalProducer layer for use in tests.

ℹ️ Instead of using a layer, consider using KafkaTestUtils.makeTransactionalProducer to directly get a producer.

Attributes

Source
KafkaTestUtils.scala

Makes TransactionalProducerSettings for use in tests.

Makes TransactionalProducerSettings for use in tests.

Note: to run multiple tests in parallel, each producer needs a different transactional id.

Attributes

Source
KafkaTestUtils.scala

Deprecated methods

Consumer layer for use in tests, requires a ConsumerSettings layer.

Consumer layer for use in tests, requires a ConsumerSettings layer.

"minimal" because, unlike the other functions returning a ZLayer[..., ..., Consumer] of this file, you need to provide the ConsumerSettings layer yourself.

ℹ️ Instead of using a layer, consider using KafkaTestUtils.makeConsumer to directly get a consumer.

Attributes

Deprecated
[Since version 3.0.0] Use Consumer.live instead
Source
KafkaTestUtils.scala

Concrete fields

Makes AdminClientSettings for use in tests.

Makes AdminClientSettings for use in tests.

Attributes

Source
KafkaTestUtils.scala

Acked record are not immediately visible to the consumer, even when the producer uses acks=all. Evaluate this after synchronous producing as a workaround.

Acked record are not immediately visible to the consumer, even when the producer uses acks=all. Evaluate this after synchronous producing as a workaround.

See also KAFKA-19811.

Attributes

Source
KafkaTestUtils.scala

Makes a Producer for use in tests.

Makes a Producer for use in tests.

Attributes

Source
KafkaTestUtils.scala

Producer layer for use in tests.

Producer layer for use in tests.

ℹ️ Instead of using a layer, consider using KafkaTestUtils.makeProducer to directly get a producer.

Attributes

Source
KafkaTestUtils.scala

Makes ProducerSettings for use in tests.

Makes ProducerSettings for use in tests.

Attributes

Source
KafkaTestUtils.scala

Makes AdminClientSettings for use in tests, using SSL security protocol.

Makes AdminClientSettings for use in tests, using SSL security protocol.

Attributes

Source
KafkaTestUtils.scala

TransactionalProducer layer for use in tests.

TransactionalProducer layer for use in tests.

Note: to run multiple tests in parallel, you need to use different transactional ids via transactionalProducer(transactionalId).

ℹ️ Instead of using a layer, consider using KafkaTestUtils.makeTransactionalProducer to directly get a producer.

Attributes

Source
KafkaTestUtils.scala

Makes TransactionalProducerSettings for use in tests.

Makes TransactionalProducerSettings for use in tests.

Note: to run multiple tests in parallel, you need to use different transactional ids via transactionalProducerSettings(transactionalId).

Attributes

Source
KafkaTestUtils.scala