Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation and examples for configuring toxiproxy environment. #364

Merged
merged 1 commit into from
Dec 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions system-tests/docker-toxiproxy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Toxiproxy Test Network

This is a small Docker container network with Styx and one Apache httpd origin.
They are connected via Toxiproxy server that can simulate various network error
conditions (aka toxics).

## Installation

Local Toxiproxy installation is not necessary. It is deployed into this container
network from Docker Hub. However you may want to use `toxiproxy-cli` for configuration
management. In that case just install it locally:

On Mac OSX:

```bash
$ brew install toxiproxy
```

## Startup

First, build a development Docker image for Styx:

```bash
$ make docker
```

Ensure the image was built:

```bash
$ docker images |grep styxcore
styxcore latest 9b65640de45b 31 minutes ago 343MB
```

Bootstrap the network:

```bash
$ docker-compose -f system-tests/docker-toxiproxy/docker-compose.yml up
```


## Applying Toxics

### HTTP API

Inspecting configuration:

```bash
$ curl http://localhost:8474/proxies | jq
```

Applying toxics:

```bash
$ curl -v -X POST -H "Content-Type: application/json" -d @system-tests/docker-toxiproxy/toxiproxy/origin-latency.json http://localhost:8474/proxies/httpd-01/toxics
```

Removing toxics:
```bash
$ curl -v -X DELETE http://localhost:8474/proxies/httpd-01/toxics/latency_downstream
```


### Command Line

Inspecting configuration:

```bash
$ toxiproxy-cli list
```

```bash
$ toxiproxy-cli inspect httpd-01
```

Applying toxics:

```bash
$ toxiproxy-cli toxic add -t latency -tox 1 -d -a latency=5000 -a jitter=2000 httpd-01
```

Removing toxics:

```bash
$ toxiproxy-cli toxic r -n latency_downstream httpd-01
```
4 changes: 4 additions & 0 deletions system-tests/docker-toxiproxy/styx-config/origins.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# See origins/origins-default.yaml for explanation of config format
#
# You can modify this configuration in runtime. Styx monitors this file
# and applies any changes straight away.
#
---
- id: "httpd"
path: "/"
Expand Down
9 changes: 9 additions & 0 deletions system-tests/docker-toxiproxy/toxiproxy/origin-latency.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"type": "latency",
"stream": "downstream",
"toxicity": 1.0,
"attributes": {
"latency": 5000,
"jitter": 2000
}
}