Skip to main content

Kafka extension for Chaos Toolkit extensions

Project description

Chaos Toolkit Extensions for Kafka

Version License

Build Python versions

This project contains Chaos Toolkit activities to create kafka chaos experiments.

Install

This package requires Python 3.8+

To be used from your experiment, this package must be installed in the Python environment where chaostoolkit already lives.

$ pip install chaostoolkit-kafka

Usage

A typical experiment using this extension would look like this:

{
  "title": "Reboot MSK broker and check the health of a target topic!!",
  "description": "Experiment to ensure that topics should not have offline partitions after a restart",
  "configuration": {
    "aws_profile_name": "aws-profile-msk",
    "boostrap_servers": "msk_bootstrap_servers:9092",
    "aws_region": "aws_region",
    "cluster_arn": "arn_msk_broker",
    "broker_ids": [
      "1"
    ],
    "recovery_time": 120,
    "topic": "kafka-test-offline"
  },
  "steady-state-hypothesis": {
    "title": "After Rebooting the Kafka broker, the topic shouldn't have offline partitions",
    "probes": [
      {
        "name": "Check that Kafka topic doesn't have offline partitions!!",
        "type": "probe",
        "tolerance": true,
        "provider": {
          "type": "python",
          "module": "chaoskafka.probes",
          "func": "topic_has_no_offline_partitions",
          "arguments": {
            "bootstrap_servers": "${boostrap_servers}",
            "topic": "${topic}"
          }
        }
      }
    ]
  },
  "method": [
    {
      "type": "action",
      "name": "Reboot MSK broker",
      "provider": {
        "type": "python",
        "module": "chaosaws.msk.actions",
        "func": "reboot_msk_broker",
        "arguments": {
          "cluster_arn": "${cluster_arn}",
          "broker_ids": "${broker_ids}"
        }
      },
      "pauses": {
        "after": "${recovery_time}"
      }
    }
  ]
}

That's it!

Please explore the code to see existing probes and actions.

Test

To run the tests for the project execute the following:

$ pdm run test

Formatting and Linting

We use ruff to both lint and format this repositories code.

Before raising a Pull Request, we recommend you run formatting against your code with:

$ pdm run format

This will automatically format any code that doesn't adhere to the formatting standards.

As some things are not picked up by the formatting, we also recommend you run:

$ pdm run lint

To ensure that any unused import statements/strings that are too long, etc. are also picked up.

Contribute

If you wish to contribute more functions to this package, you are more than welcome to do so. Please, fork this project, make your changes following the usual PEP 8 code style, sprinkling with tests and submit a PR for review.

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

chaostoolkit_kafka-0.1.0.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

chaostoolkit_kafka-0.1.0-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file chaostoolkit_kafka-0.1.0.tar.gz.

File metadata

  • Download URL: chaostoolkit_kafka-0.1.0.tar.gz
  • Upload date:
  • Size: 16.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for chaostoolkit_kafka-0.1.0.tar.gz
Algorithm Hash digest
SHA256 be699b55485191ff69ceb4e8d6ede5fb7df0e8ea27830360aaa7de44a6e4d421
MD5 5028b208da1aa7aea4bfa62102b3b2dd
BLAKE2b-256 e1e492f6be6cac0868b1bc5269308ade125b0ac456d232d3f26f7f3d9493d304

See more details on using hashes here.

File details

Details for the file chaostoolkit_kafka-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for chaostoolkit_kafka-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b94044497712f9561c31690ff3f48b2a5950f25de95bf52c76ad3af5ff9d523
MD5 af2f0bd4a579876682ca05ec2e3bbd83
BLAKE2b-256 d62b70cb931d791f060eba073b6ebdcd1ceac53dfc0c316ed588682eb1055606

See more details on using hashes here.

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