Skip to content

Commit

Permalink
Merge pull request #101 from Shopify/update-makefile
Browse files Browse the repository at this point in the history
Update Makefile, README and CHANGELOG
  • Loading branch information
xthexder committed Mar 29, 2016
2 parents 6fa6fdd + 1f3fbee commit 1fdac2c
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 91 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
toxiproxy
toxiproxy-server
toxiproxy-cli
cli
toxiproxy.test
testing
Expand Down
14 changes: 10 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
# 2.0.0 (Unreleased)
# 2.0.0rc2 (Unreleased)

* Add CLI (`toxiproxy-cli`) and rename server binary to `toxiproxy-server` #93
* Fix removing a timeout toxic causing API to hang #89
* API and client return toxics as array rather than a map of name to toxic #92
* Fix multiple latency toxics not accumulating #94
* Change default toxic name to `<type>_<stream>` #96
* Nest toxic attributes rather than having a flat structure #98

# 2.0.0rc1 (Unreleased)

* 2.0 RFC: #54 and PR #62
* Change toxic API endpoints to an Add/Update/Remove structure
Expand All @@ -14,8 +23,6 @@
* Make `ChanReader` in the `stream` package interruptible #77
* Define proxy buffer sizes per-toxic (Fixes #72)
* Fix slicer toxic testing race condition #71
* API and client return toxics as array rather than a map of name to toxic #92
* Nest toxic attributes rather than having a flat structure #98

# 1.2.1

Expand All @@ -27,7 +34,6 @@
* Add `Dockerfile`
* Fix latency toxic limiting bandwidth #67
* Add Slicer toxic
* Add CLI

# 1.1.0

Expand Down
35 changes: 19 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
NAME=toxiproxy
SERVER_NAME=toxiproxy-server
CLI_NAME=toxiproxy-cli
VERSION=$(shell cat VERSION)
DEB=pkg/$(NAME)_$(VERSION)_amd64.deb
DEB=pkg/toxiproxy_$(VERSION)_amd64.deb
GODEP_PATH=$(shell pwd)/Godeps/_workspace
ORIGINAL_PATH=$(shell echo $(GOPATH))
COMBINED_GOPATH=$(GODEP_PATH):$(ORIGINAL_PATH)

.PHONY: packages deb test linux darwin windows

build:
GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=git-$(shell git rev-parse --short HEAD)" -o $(NAME) ./cmd
GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=git-$(shell git rev-parse --short HEAD)" -o $(SERVER_NAME) ./cmd
GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=git-$(shell git rev-parse --short HEAD)" -o $(CLI_NAME) ./cli

all: deb linux darwin windows
deb: $(DEB)

darwin: tmp/build/toxiproxy-server-darwin-amd64 tmp/build/toxiproxy-client-darwin-amd64
linux: tmp/build/toxiproxy-server-linux-amd64 tmp/build/toxiproxy-client-linux-amd64
windows: tmp/build/toxiproxy-server-windows-amd64.exe tmp/build/toxiproxy-client-windows-amd64.exe
darwin: tmp/build/$(SERVER_NAME)-darwin-amd64 tmp/build/$(CLI_NAME)-darwin-amd64
linux: tmp/build/$(SERVER_NAME)-linux-amd64 tmp/build/$(CLI_NAME)-linux-amd64
windows: tmp/build/$(SERVER_NAME)-windows-amd64.exe tmp/build/$(CLI_NAME)-windows-amd64.exe

release: all docker

clean:
rm -f tmp/build/*
#rm -f $(NAME)
rm -f $(SERVER_NAME)
rm -f $(CLI_NAME)
rm -f *.deb

test:
GOMAXPROCS=4 GOPATH=$(COMBINED_GOPATH) go test -v -race ./...

tmp/build/toxiproxy-server-linux-amd64:
tmp/build/$(SERVER_NAME)-linux-amd64:
GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd

tmp/build/toxiproxy-server-darwin-amd64:
tmp/build/$(SERVER_NAME)-darwin-amd64:
GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd

tmp/build/toxiproxy-server-windows-amd64.exe:
tmp/build/$(SERVER_NAME)-windows-amd64.exe:
GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd

tmp/build/toxiproxy-client-linux-amd64:
tmp/build/$(CLI_NAME)-linux-amd64:
GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli

tmp/build/toxiproxy-client-darwin-amd64:
tmp/build/$(CLI_NAME)-darwin-amd64:
GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli

tmp/build/toxiproxy-client-windows-amd64.exe:
tmp/build/$(CLI_NAME)-windows-amd64.exe:
GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli

$(DEB): tmp/build/toxiproxy-server-linux-amd64 tmp/build/toxiproxy-client-linux-amd64
$(DEB): tmp/build/$(SERVER_NAME)-linux-amd64 tmp/build/$(CLI_NAME)-linux-amd64
fpm -t deb \
-s dir \
-p tmp/build/ \
Expand All @@ -59,8 +62,8 @@ $(DEB): tmp/build/toxiproxy-server-linux-amd64 tmp/build/toxiproxy-client-linux-
--description "TCP proxy to simulate network and system conditions" \
--url "https://github.com/Shopify/toxiproxy" \
$(word 1,$^)=/usr/bin/toxiproxy \
$(word 1,$^)=/usr/bin/toxiproxy-server \
$(word 2,$^)=/usr/bin/toxiproxy-client \
$(word 1,$^)=/usr/bin/$(SERVER_NAME) \
$(word 2,$^)=/usr/bin/$(CLI_NAME) \
./share/toxiproxy.conf=/etc/init/toxiproxy.conf

docker:
Expand Down
64 changes: 27 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ stopping you from creating a client in any other language (see
1. [Proxy fields](#proxy-fields)
2. [Toxic fields](#toxic-fields)
3. [Endpoints](#endpoints)
4. [Curl example](#curl-example)
7. [FAQ](#frequently-asked-questions)
8. [Development](#development)
7. [CLI example](#cli-example)
8. [FAQ](#frequently-asked-questions)
9. [Development](#development)

## Why yet another chaotic TCP proxy?

Expand Down Expand Up @@ -225,7 +225,7 @@ $ docker run -it shopify/toxiproxy
If you have Go installed, you can build Toxiproxy from source using the make file:
```bash
$ make build
$ ./toxiproxy
$ ./toxiproxy-server
```

#### Upgrading from Toxiproxy 1.x
Expand Down Expand Up @@ -268,10 +268,10 @@ This code needs to run as early in boot as possible, before any code establishes
a connection through Toxiproxy. Please check your client library for
documentation on the population helpers.

Alternatively use the HTTP API directly to create proxies, e.g.:
Alternatively use the CLI to create proxies, e.g.:

```bash
curl -i -d '{"name": "shopify_test_redis_master", "upstream": "localhost:6379", "listen": "localhost:26379"}' localhost:8474/proxies
toxiproxy-cli create shopify_test_redis_master -l localhost:26379 -u localhost:6379
```

We recommend a naming such as the above: `<app>_<env>_<data store>_<shard>`.
Expand Down Expand Up @@ -309,6 +309,12 @@ Toxiproxy[:shopify_test_redis_master].downstream(:latency, latency: 1000).apply
end
```

Or via the CLI:

```bash
toxiproxy-cli toxic add shopify_test_redis_master -t latency -a latency=1000
```

Please consult your respective client library on usage.

### Toxics
Expand Down Expand Up @@ -426,16 +432,17 @@ All endpoints are JSON.
- **POST /reset** - Enable all proxies and remove all active toxics
- **GET /version** - Returns the server version number

### Curl Example
### CLI Example

```bash
$ curl -i -d '{"name": "redis", "upstream": "localhost:6379", "listen": "localhost:26379"}' localhost:8474/proxies
HTTP/1.1 201 Created
Content-Type: application/json
Date: Fri, 18 Mar 2016 01:19:59 GMT
Content-Length: 98

{"name":"redis","listen":"127.0.0.1:26379","upstream":"localhost:6379","enabled":true,"toxics":[]}
$ toxiproxy-cli create redis -l localhost:26379 -u localhost:6379
Created new proxy redis
$ toxiproxy-cli list
Listen Upstream Name Enabled Toxics
======================================================================
127.0.0.1:26379 localhost:6379 redis true None

Hint: inspect toxics with `toxiproxy-client inspect <proxyName>`
```

```bash
Expand All @@ -447,23 +454,8 @@ OK
```

```bash
$ curl -i localhost:8474/proxies
HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 18 Mar 2016 01:20:31 GMT
Content-Length: 108

{"redis":{"name":"redis","listen":"127.0.0.1:26379","upstream":"localhost:6379","enabled":true,"toxics":[]}}
```

```bash
$ curl -i -d '{"type":"latency", "attributes":{"latency":1000}}' localhost:8474/proxies/redis/toxics
HTTP/1.1 200 OK
Content-Type: application/json
Date: Fri, 18 Mar 2016 01:21:08 GMT
Content-Length: 122

{"attributes":{"latency":1000,"jitter":0},"name":"latency_downstream","type":"latency","stream":"downstream","toxicity":1}
$ toxiproxy-cli toxic add redis -t latency -a latency=1000
Added downstream latency toxic 'latency_downstream' on proxy 'redis'
```

```bash
Expand All @@ -477,9 +469,8 @@ $ redis-cli -p 26379
```

```bash
$ curl -i -X DELETE localhost:8474/proxies/redis/toxics/latency_downstream
HTTP/1.1 204 No Content
Date: Fri, 18 Mar 2016 01:21:58 GMT
$ toxiproxy-cli toxic remove redis -n latency_downstream
Removed toxic 'latency_downstream' on proxy 'redis'
```

```bash
Expand All @@ -489,9 +480,8 @@ $ redis-cli -p 26379
```

```bash
$ curl -i -X DELETE localhost:8474/proxies/redis
HTTP/1.1 204 No Content
Date: Fri, 18 Mar 2016 01:22:20 GMT
$ toxiproxy-cli delete redis
Deleted proxy redis
```

```bash
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.0rc1
2.0.0rc2
Loading

0 comments on commit 1fdac2c

Please sign in to comment.