Skip to main content

Chaos Toolkit tokiproxy driver

pypi travis readthedocs

This module provides actions to configure toxiproxy proxies and toxies.

WARNING: This module exposes actions that have rather strong impacts on your cluster. While Chaos Engineering is all about disrupting and weaknesses, it is important to take the time to fully appreciate what those actions do and how they do it.

Install

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

$ pip install sky-chaostoolkit-toxiproxy

Usage

Configuration

In your experiment configuration section you can set the toxiproxy server address if different from localhost:

  "configuration":{
    "toxiproxy_host": "<defaults to localhost...>",
    "toxiproxy_port": 1234  
  }

If more than one toxiproxy server needs to be addressed, you can set the list using the "toxiproxy" configuration key:

  "configuration":{
      "toxiproxy": [
        {
          "host": "<defaults to localhost>",
          "port": "<defaults to 8474>"
        },
      ]

Exported actions

Adding a toxic

  add_toxic(
    server: Dict = {'host': 'localhost', 'port': 8474}, 
    random_server: bool = False, 
    proxy_name: str = None, 
    toxic_name: str = None, 
    type: str = None, 
    stream: str = 'downstream', 
    toxicity: float = 1.0, 
    attributes: str = None 
  )

Add a toxic to a proxy

The server can be specifically passed as parameter. Alternatively, if the "toxiproxy" configuration section is present, a random server is picked setting the "random_server" parameter to True.

The name of the proxy to add the toxic to can be specified, otherwise a random proxy for the server is picked up

Creating a new proxy

  create_proxy(
    proxy_name, 
    upstream, 
    listen, 
    enabled: bool = True, 
    server: Dict = {'host': 'localhost', 'port': 8474}

Deleting all proxies attached to a server

  delete_all_proxies(
    server: Dict = {'host': 'localhost', 'port': 8474}
  )

Deleting all toxic attached to a proxy

  delete_all_toxics(
    server: Dict = {'host': 'localhost', 'port': 8474}, 
    proxy_name: str = None
  )

Deleting a proxy

  delete_proxy(
    proxy_name: str, 
    server: Dict = {'host': 'localhost', 'port': 8474}
  )

Deleting a toxic

  delete_toxic(
    server: Dict = {'host': 'localhost', 'port': 8474}, 
    proxy_name: str = None, 
    stream: str = 'downstream', 
    type: str = None
  )

Disabling a proxy

  disable_proxy(
    server: Dict = {'host': 'localhost', 'port': 8474}, 
    proxy_name: str = None
  )

Enabling a proxy

  enable_proxy(
    server: Dict = {'host': 'localhost', 'port': 8474}, 
    proxy_name: str = None
  )

Populating a server

  populate(
    proxies, 
    server: Dict = {'host': 'localhost', 'port': 8474}
  )

Resetting all servers

  reset_all()

Enable all proxies and remove all active toxics for all servers

Resetting a server

  reset_server(
    server: Dict = {'host': 'localhost', 'port': 8474}
  )

Enable all proxies and remove all active toxics

Sample experiment

{
  "version": "1.0.0",
  "title": "What happens if a latency is introduced on a proxy for cassandra",
  "description": "We introduce a 400 ms latency on a single cassandra node",
  "tags": ["proxy"],
  "steady-state-hypothesis": {
    "title": "Proxy is found",
    "probes": [
      {
        "type": "probe",
        "name": "proxy-is-found",
        "tolerance": "c1",
        "provider": {
          "type": "python",
          "module": "chaostp.proxy.probes",
          "func": "get_proxy",
          "arguments": {
              "name": "c1"
          }
        }
      }
    ]
  },
  "method": [
    {
      "type": "action",
      "name": "delete_all_toxics",
      "provider": {
          "type": "python",
          "module": "chaostp.proxy.actions",
          "func": "delete_all_toxics",
          "arguments": {
              "proxy_name": "localhost",
              "name": "c1"
          }
      }
    },
    {
      "type": "action",
      "name": "add-a-latency-toxic",
      "provider": {
          "type": "python",
          "module": "chaostp.proxy.actions",
          "func": "add_toxic",
          "arguments": {
              "proxy_name": "c1",
              "toxic_name": "t1",
              "type": "latency",
              "stream": "upstream",
              "toxicity": 0.5,
              "attributes": {"latency": 100}
          }
      },
      "pauses": {
          "before": 10,
          "after": 40
      }
    },
    {
      "type": "action",
      "name": "add-a-bandwidth-degradation-toxic",
      "provider": {
          "type": "python",
          "module": "chaostp.proxy.actions",
          "func": "add_toxic",
          "arguments": {
              "proxy_name": "c1",
              "toxic_name": "bandwidth_degradation_toxic",
              "type": "bandwidth",
              "stream": "upstream",
              "toxicity": 0.5,
              "attributes": {"rate": 400}
          }
      },
      "pauses": {
          "before": 10,
          "after": 40
      }
    },
    {
      "type": "action",
      "name": "delete_all_toxics", "provider": {
          "type": "python",
          "module": "chaostp.proxy.actions",
          "func": "delete_all_toxics",
          "arguments": {
              "name": "c1"
          }
      }
    }
  ],
  "rollbacks": []
}

Please explore the code to see existing probes and actions.

Discovery

You may use the Chaos Toolkit to discover the capabilities of this extension:

$ chaos discover sky-chaostoolkit-toxiproxy  --no-install

Configuration

The module expects a toxiproxy-server running and listening on the default port 8474, there is currently no way to configure another server address.

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, add appropriate tests and submit a PR for review.

The Chaos Toolkit projects require all contributors must sign a Developer Certificate of Origin on each commit they would like to merge into the master branch of the repository. Please, make sure you can abide by the rules of the DCO before submitting a PR.

Metadata

Release files for sky-chaostoolkit-toxiproxy-2 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sky-chaostoolkit-toxiproxy-2 0.1.8
File Size Uploaded
sky-chaostoolkit-toxiproxy-2-0.1.8.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sky-chaostoolkit-toxiproxy-2 0.1.8
File Interpreter ABI Platform
sky_chaostoolkit_toxiproxy_2-0.1.8-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 26.6 kB

Release files / sky-chaostoolkit-toxiproxy-2-0.1.8.tar.gz

Download URL sky-chaostoolkit-toxiproxy-2-0.1.8.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2e50588c2cb5b89b0e2e84988bf29bccdd152bc9687a31f76591058b4d1f3c41
BLAKE2b-256 checksum
How to use checksums
be8457f9caba46b8f3917eefcf6eec0cacd439513a8d8cfa987299c4833c596d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release files / sky_chaostoolkit_toxiproxy_2-0.1.8-py2.py3-none-any.whl

Download URL sky_chaostoolkit_toxiproxy_2-0.1.8-py2.py3-none-any.whl
Size 9.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
09948741f39e9cd0fcb1a7735b5d10e4d1a8ba9900787daf8ef680d74070cf3a
BLAKE2b-256 checksum
How to use checksums
23cdfca4940d228987b4425ce4bdee308fb4ddd85a58807b181fdc7f3cc67d65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

Release history Release notifications | RSS feed

This release

0.1.8 This release

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page