Skip to main content

Plugin for testing pubsub, pulsar, and kafka systems with pytest locally and in ci/cd

Project description

Pytest Streaming

Augmenting and simplifying the flow of testing streaming applications including pulsar, google pubsub, kafka, and nats.

semantic-release: python PyPI - Downloads Tests Formatting Typing Docs License

Python Pytest Apache Google Cloud

Documentation

PyTest streaming documentation can be found here.

Description

This PyTest plugin makes it easy to test streaming functionality (unit, integration, test, etc) through seamless and easy to use decorators. The plugin currently supports bootstrapping of resources for the following technologies

  1. Apache Pulsar
  2. Google PubSub
  3. [Coming soon] Kafka
  4. [Coming soon] Nats
  5. [Coming soon] Kinesis

The only setup the user needs to take is to have these running locally (ideally via Docker). Docker compose files are provided for each of these, with formal documentation on how to setup everything easily in CI/CD as well.

 

Quick start

To get started, you should reference the extensive documentation page found here.

For a quick start, you can follow these steps

Install pytest-streaming

pip install pytest-streaming

 

Utilize the decorator for the streaming technology of your choice

If you're using docker compose, adding this for pulsar will get you up and running end to end (docker-compose.yml)

services:
  pulsar:
    image: apachepulsar/pulsar:latest
    container_name: pulsar
    ports: ['6650:6650', '8080:8080']
    environment:
    - PULSAR_STANDALONE_ENABLED=true
    - allowAutoTopicCreation=true
    command: [bin/pulsar, standalone]

Now you can run: docker compose up -d to have pulsar locally bootstrapped.

Lastly, you can simply create test specific topics

class TestPulsarProducer:
    @pytest.mark.pulsar(topics=["test-topic1", "test-topic2"])
    def test_pubsub_marker_topic_creation_base(self) -> None:
        # these pulsar topics are now available and completely clean
        ...

Everything will be created and cleaned up for you by default on every test run. Each decorator has a suite of customizable features. Read the documentation to see other parameters you can use and how you can create topics for global use (integration tests).

 

Adding to your CI/CD

Running this in CI/CD is as simple and ensuring pulsar (or other streaming choice) is running in the network. For the example above, adding this step to your GitHub action will yield all the setup required

- name: run docker-compose
    run: |
    docker compose up -d
    sleep 5s

 

Examples

A suite of examples which are provided and ran within the test suite directly to verify functionality. These can be found under the examples directory at the root level of this project.

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_streaming-1.2.1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_streaming-1.2.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file pytest_streaming-1.2.1.tar.gz.

File metadata

  • Download URL: pytest_streaming-1.2.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for pytest_streaming-1.2.1.tar.gz
Algorithm Hash digest
SHA256 fe907f40582fe361ed33c4e4672765c4d8e6df8094051a2e61475388236ab016
MD5 b8687c0345143dc8241c894789ff8bdf
BLAKE2b-256 b84737ef37f024e76020610c4fee02a4d8ae8378b3cb40f12c31be0632d6fdb6

See more details on using hashes here.

File details

Details for the file pytest_streaming-1.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_streaming-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6e7f2898e25447e0aa5c527b753e10dafc1ab8d8d8cd6ba4ece0cf99d6a7a09d
MD5 0150c01f9f54cd026f6c661b844f569f
BLAKE2b-256 307ea1d6d8aaa0030cc2280bd71a294b54168732421f6560cd1a46c7541b7c74

See more details on using hashes here.

Supported by

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