Skip to main content

A plugin to send pytest events to Kafka

Project description


PyTest Kafkavents is a plugin for real time streaming of test result events to a Kafka instance. Events can also be logged for batch replay of events via another utility (in the works).

Steps to use pytest-kafkavents

  1. Clone me (soon to be pip install me)
    git clone

To install for dev

    pip install -e .
  1. Create a Kafka instance on Red Hat OpenShift Streams for Apache Kafka

  2. Download and install the client from the Apache Kafka client website.

SIDENOTE: Pytest-Kafkavent uses the Confluent Python Kafka library

On Fedora...

dnf info python3-confluent-kafka
pip show confluent-kafka
  1. Copy and configure template to your local kafka client bin directory and fill-in info for your instance.

  2. Setup env variables

  1. Create topics (with the client command)
./ --create --topic kafkavent --bootstrap-server --command-config ../config/
./ --create --topic kafkavent-failed --bootstrap-server --command-config ../config/
./ --create --topic kafkavent-infra --bootstrap-server --command-config ../config/
  1. Start one consumer in one window to see pytest-kafkavent messages for all tests
    ./ --bootstrap-server $KV_BOOTSTRAP_SERVER \
    --consumer.config ../config/ --from-beginning --topic kafkavents
  1. Start another consumer in another window to see pytest-kafkavent messages for failed tests only
    ./ --bootstrap-server $KV_BOOTSTRAP_SERVER \
    --consumer.config ../config/ --from-beginning --topic kafkavents-failed
  1. Run the example pytest test scripts
    pytest example_tests/ --junitxml=/tmp/kafkavent.xml --kv-topics my-other-topic
    pytest example_tests/ -q --kv-conf examples/kafka_conf.json \
    --kv-topics kafkavent --kv-topics-failed kafkavent-failed 
  1. Or just pull the container from :-)

TODO: create a container with all of this goodness in it, upload to, and link here

Use the test generator...

pytest example_tests/ --kv-conf examples/kafka_conf.json \
--kv-topics kafkavent --kv-topics-failed kafkavent-failed \
--kv-eventlog=/tmp/kafkavent.log -k test_kafkavents --kv-test 4,1,1,1

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-kafkavents- (20.3 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page