TestKafka

Minimal Kafka 0.8 runner suitable for integration testing.

Adapted from the excellent poseidon's integration tests.

Installation

Add TestKafka to your application's Gemfile:

gem 'test_kafka', '~> 0.1.0'

and bundle:

$ bundle

Usage

require 'test_kafka'

cluster = TestKafka.start('/usr/local/kafka')
# or specify custom a temp directory and kafka/zk ports:
# cluster = TestKafka.start('/usr/local/kafka', '/tmp', 9092, 2181)

# ... interact with Kafka/ZK ...

cluster.with_interruption do
  # broker temporarily stopped in this block
end

# broker is back up

cluster.stop

Requirements

  • Kafka 0.8 or higher