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.1.tar.gz (16.0 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: chaostoolkit_kafka-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 db462a322427c5b62e019defaa3ff5c50dcd3c94e8d732d21cfdc7d50d209d30
MD5 ef88db216a3667094aaf14c294b03b16
BLAKE2b-256 5588e05e0cc62fa34b41f58445514bc0cabfd7ec47853288137b475245795078

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for chaostoolkit_kafka-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 39db5807dc334542ad3e02966b8f9649828ae0c074e2f22dd287e342e829fa4c
MD5 19c5d927c5c3700ba195665a3d70a55b
BLAKE2b-256 00b310100944a5d4a09f6c1a897084b0bea451c8e8efbe88ed2796ab2a7ce0ad

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