# Chaos Toolkit tokiproxy driver
[![pypi](https://img.shields.io/pypi/v/sky-chaostoolkit-toxiproxy.svg)](https://pypi.python.org/pypi/sky-chaostoolkit-toxiproxy) [![travis](https://img.shields.io/travis/grubert65/chaostp.svg)](https://travis-ci.org/grubert65/chaostp) [![readthedocs](https://readthedocs.org/projects/chaostp/badge/?version=latest)](https://chaostp.readthedocs.io/en/latest/?badge=latest)
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.
[chaostoolkit]: https://github.com/chaostoolkit/chaostoolkit
```
$ pip install sky-chaostoolkit-toxiproxy
```
## Usage
### Configuration
In your experiment configuration section you can set the toxiproxy server
address if different from localhost:
```json
"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:
```json
"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
```json
{
"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][pep8] code style, add appropriate tests and submit a PR for
review.
[pep8]: https://pycodestyle.readthedocs.io/en/latest/
The Chaos Toolkit projects require all contributors must sign a
[Developer Certificate of Origin][dco] 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.
[dco]: https://github.com/probot/dco#how-it-works
没有合适的资源?快使用搜索试试~ 我知道了~
PyPI 官网下载 | sky-chaostoolkit-toxiproxy-0.1.3.tar.gz
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 2 浏览量
2022-01-16
07:31:23
上传
评论
收藏 17KB GZ 举报
温馨提示
共38个文件
py:11个
rst:10个
txt:4个
资源来自pypi官网。 资源全名:sky-chaostoolkit-toxiproxy-0.1.3.tar.gz
资源推荐
资源详情
资源评论
收起资源包目录
sky-chaostoolkit-toxiproxy-0.1.3.tar.gz (38个子文件)
sky-chaostoolkit-toxiproxy-0.1.3
MANIFEST.in 262B
PKG-INFO 10KB
docs
history.rst 28B
conf.py 5KB
usage.rst 69B
make.bat 769B
installation.rst 1KB
authors.rst 28B
readme.rst 27B
Makefile 608B
index.rst 304B
contributing.rst 33B
AUTHORS.rst 159B
CONTRIBUTING.rst 3KB
tests
test_probes.py 3KB
test_configuration.py 752B
pytest.ini 198B
__init__.py 0B
.pytest_cache
v
cache
lastfailed 759B
nodeids 248B
stepwise 2B
README.md 295B
test_actions.py 5KB
LICENSE 1KB
HISTORY.rst 90B
setup.cfg 501B
setup.py 2KB
chaostp
cli.py 413B
proxy
probes.py 2KB
__init__.py 23B
actions.py 9KB
__init__.py 2KB
sky_chaostoolkit_toxiproxy.egg-info
PKG-INFO 10KB
requires.txt 58B
SOURCES.txt 861B
top_level.txt 8B
dependency_links.txt 1B
README.md 7KB
共 38 条
- 1
资源评论
挣扎的蓝藻
- 粉丝: 13w+
- 资源: 15万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功