Package: chaostoolkit-toxiproxy
Chaos Toolkit Driver for ToxiproxyWelcome to theChaos Toolkitdriver forToxiproxy! This extension allows you to setup toxy proxy probes and methods from chaostoolkit by leveraging the toxyproxyhttp management api.InstallInstall theToxiproxy base clientInstall theToxiproxy CLIDriverThis package requires Python 3.5+To be used from your experiment, this package must be installed in the Python
environment wherechaostoolkitalready lives.$ pip install -U chaostoolkit-toxiproxyUsageConfigurationFirst, run the Toxiproxy base client locally to create alocalhost:8474host on your computer. Thencreate a proxy.Next, to start using the actions and probes all you need to do is add the toxiproxy host with "toxiproxy_host" as the key, and optionally the port with "toxiproxy_port" as the key, to the configuration section in your experiment json. If not provided the port defaults to 8474.Alternatively, if toxiproxy api is accessible using a reverse proxy, you can usetoxiproxy_urlsetting.Example usingtoxiproxy_hostin experiment.json"configuration":{"toxiproxy_host":"10.124.23.183","some_environment_variable":{"type":"environment","key":"ENVIRONMENT_VARIABLE"}},Example usingtoxiproxy_urlin experiment.json"configuration":{"toxiproxy_url":"http://mydomain.com:8080/path-to-toxiproxy-api","some_environment_variable":{"type":"environment","key":"ENVIRONMENT_VARIABLE"}},This extension follows the toxiproxy rules. A proxy is the channel where toxicity can be added. For this reason the extension is broken into proxy management and toxic management.All actions and probes in the extension are of python type and are used like any other python extension.Proxy actionscreate_proxyCreates a proxy to which toxics can be added. In toxiproxy a listen port of value 0 tells the API to assign a random available port. The value where the proxy is listenting will be attached to thechaostoolkit configuration objectas<proxyname>_PORT. Should the creation of the proxy fail, an assertion error is raised stopping all subsequent actions.ArgumentDescriptionRequiredDefaultproxy_namename for the proxyYesNoneupstream_hostip address of the host to send traffic toYesNoneupstream_portport of the application to send traffic toYesNonelisten_hostIP address to bind where toxiproxy listensNo0.0.0.0listen_portport to listen for requests, 0 means pick random valueNo0enabledWhether to start listening or notNoTruemodify_proxyModify the configuration of a given proxy. Useful to change the upstream configiuration. Only arguments supplied result in modification of the proxy.ArgumentDescriptionRequiredDefaultproxy_namename for the proxyYesNonelisten_addresip:port address to modifyNoNoneupstream_addresip:port of the upstreamNoNoneenabledToggle enabled/disabled stateNoNonedisable_proxyDisables the proxy, this is useful to simulate a proxied service being down.ArgumentDescriptionRequiredDefaultproxy_namename for the proxy to disableYesNoneenable_proxyEnables a disabled proxy.ArgumentDescriptionRequiredDefaultproxy_namename for the proxy to enableYesNonedelete_proxyRemoves the proxy from the system.Example usage"method":[{"type":"action","name":"setup_toxiproxy_proxy","provider":{"type":"python","module":"chaostoxi.proxy.actions","func":"create_proxy","arguments":{"proxy_name":"myproxy","listen_port":6666,"upstream_host":"10.28.188.118","upstream_port":6040}},"pauses":{"after":1}}]resetEnable all proxies and remove all active toxics.Example usage:"method":[{"type":"action","name":"reset all proxies","provider":{"type":"python","module":"chaostoxi.proxy.actions","func":"reset"},"pauses":{"after":1}}]Proxy pobesproxy_existReturns True of False if a given proxy exists.ArgumentDescriptionRequiredDefaultproxy_namename for the proxyYesNoneToxic actionsAll actions provided by this extension match the types and attributes oftoxics.create_toxicAllows you to create any of the supported types of toxics with their attributes.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNonetoxic_typeA valid toxic typeYesNonestreamThe direction of the toxic "upstream" or "downstream"NodownstreamtoxicityPercentage of toxiciy 1.0 is 100%, 0.5 is 50% etcNo1.0attributesDictionary of attributes for the type of toxicNoNonecreate_latency_toxicAdd a delay to all data going through the proxy using a downstream with a toxicity of 100%.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNonelatencytime in milliseconds to add for latencyYesNonejittertime in milliseconds to jitterNo0create_bandwith_degradation_toxicLimit the bandwith of a  downstream connection with a toxicity of 100%.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNoneratedesired bandwith rate in KB/sYesNonecreate_slow_connection_close_toxicGenerate as downstream delayed TCP close with a toxicity of 100%.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNonedelaydesired close delay in millisecondsYesNonecreate_slicer_toxicSlices TCP data up into small bits, optionally adding a delay between each sliced "packet" with a toxicity of 100%.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNoneaverage_sizesize in bytes for the average packageYesNonesize_variationvariation in bytes of an average pkg (should be smaller than average_size)YesNonedelaytime in microseconds to delay each packet byYesNonecreate_limiter_toxicCloses connections when transmitted data after the limit, sets it up as a dowsntream, 100% toxicity.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNonebytesnumber of bytes to transmit before connection is closedYesNonedelete_toxicDeletes the a given toxic.ArgumentDescriptionRequiredDefaultfor_proxyname for the proxy to attach the toxyYesNonetoxic_namename for this toxyYesNoneExample usage:"method":[{"type":"action","name":"create_latency_toxic","provider":{"type":"python","module":"toxiproxy.toxic.actions","func":"create_dowsntream_latency_toxic","arguments":{"for_proxy":"edsproxy","toxic_name":"latency_toxic","latency":5000,"jitter":200}},"pauses":{"after":1}}]ContributeIf 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
usualPEP 8code style, sprinkling with tests and submit a PR for
review.The Chaos Toolkit projects require all contributors must sign aDeveloper Certificate of Originon 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.DevelopIf you wish to develop on this project, make sure to install the development
dependencies. But first,create a virtual environmentand then install
those dependencies.$pipinstall-rrequirements-dev.txt-rrequirements.txtThen, point your environment to this directory:$pythonsetup.pydevelopNow, you can edit the files and they will be automatically be seen by your
environment, even when running from thechaoscommand locally.TestTo run the unit tests for the project execute the following:$ pytestTo run the integration tests for the project execute the following:$ tox