Skip to content

Commit

Permalink
Toxi-proxy container network documentation improvements. (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkokar authored Dec 21, 2018
1 parent a8ecad2 commit c1661dd
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
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
}
}

0 comments on commit c1661dd

Please sign in to comment.