Skip to content

Commit 72e4787

Browse files
committed
fix(network): upgrade Comcast deps to help resolve #23
1 parent c7e957d commit 72e4787

File tree

7 files changed

+548
-147
lines changed

7 files changed

+548
-147
lines changed

Diff for: README.md

+109-126
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# <img src="https://cloud.githubusercontent.com/assets/53900/26097013/7c930660-3a66-11e7-9b5c-780b0630d5a4.gif" alt="Muxy Logo" style="height: 80px;" height="80px"/>
22

3-
43
Proxy for simulating real-world distributed system failures to improve resilience in your applications.
54

65
[![wercker status](https://app.wercker.com/status/e45703ebafd48632db56f022cc54546b/s "wercker status")](https://app.wercker.com/project/bykey/e45703ebafd48632db56f022cc54546b)
@@ -19,52 +18,35 @@ If you are building a distributed system, Muxy can help you test your resilience
1918
</p>
2019

2120
### Contents
21+
2222
<!-- TOC depthFrom:2 depthTo:4 withLinks:1 updateOnSave:1 orderedList:0 -->
2323

24-
- [Introduction](#introduction)
25-
- [Contents](#contents)
24+
- [Introduction](#introduction) - [Contents](#contents)
2625
- [Features](#features)
27-
- [Installation](#installation)
28-
- [On Mac OSX using Homebrew](#on-mac-osx-using-homebrew)
29-
- [Using Go Get](#using-go-get)
30-
- [Using Muxy](#using-muxy)
31-
- [5-minute example](#5-minute-example)
32-
- [Muxy as part of a test suite](#muxy-as-part-of-a-test-suite)
33-
- [Notes](#notes)
34-
- [Proxies and Middlewares](#proxies-and-middlewares)
35-
- [Proxies](#proxies)
36-
- [HTTP Proxy](#http-proxy)
37-
- [TCP Proxy](#tcp-proxy)
38-
- [Middleware](#middleware)
39-
- [Delay](#delay)
40-
- [HTTP Tamperer](#http-tamperer)
41-
- [Network Shaper](#network-shaper)
42-
- [TCP Tamperer](#tcp-tamperer)
43-
- [Logger](#logger)
26+
- [Installation](#installation) - [On Mac OSX using Homebrew](#on-mac-osx-using-homebrew) - [Using Go Get](#using-go-get)
27+
- [Using Muxy](#using-muxy) - [5-minute example](#5-minute-example) - [Muxy as part of a test suite](#muxy-as-part-of-a-test-suite) - [Notes](#notes)
28+
- [Proxies and Middlewares](#proxies-and-middlewares) - [Proxies](#proxies) - [HTTP Proxy](#http-proxy) - [TCP Proxy](#tcp-proxy) - [Middleware](#middleware) - [Delay](#delay) - [HTTP Tamperer](#http-tamperer) - [Network Shaper](#network-shaper) - [TCP Tamperer](#tcp-tamperer) - [Logger](#logger)
4429
- [Configuration Reference](#configuration-reference)
45-
- [Examples](#examples)
46-
- [Hystrix](#hystrix)
30+
- [Examples](#examples) - [Hystrix](#hystrix)
4731
- [Usage with Docker](#usage-with-docker)
48-
- [Extending Muxy](#extending-muxy)
49-
- [Proxies](#proxies)
50-
- [Middleware](#middleware)
32+
- [Extending Muxy](#extending-muxy) - [Proxies](#proxies) - [Middleware](#middleware)
5133
- [Contributing](#contributing)
5234

5335
<!-- /TOC -->
5436

5537
## Features
5638

57-
* Ability to tamper with network devices at the transport level (Layer 4)
58-
* Ability to tamper with the TCP session layer (Layer 5)
59-
* ...and HTTP requests/responses at the HTTP protocol level (Layer 7)
60-
* Supports custom proxy routing (aka basic reverse proxy)
61-
* Advanced matching rules allow you to target specific requests
62-
* Introduce randomness into symptoms
63-
* Simulate real-world network connectivity problems/partitions for mobile devices, distributed systems etc.
64-
* Ideal for use in CI/Test Suites to test resilience across languages/technologies
65-
* Simple native binary installation with no dependencies
66-
* Extensible and modular architecture
67-
* An official Docker [container](https://github.com/mefellows/docker-muxy) to simplify uses cases such as Docker Compose
39+
- Ability to tamper with network devices at the transport level (Layer 4)
40+
- Ability to tamper with the TCP session layer (Layer 5)
41+
- ...and HTTP requests/responses at the HTTP protocol level (Layer 7)
42+
- Supports custom proxy routing (aka basic reverse proxy)
43+
- Advanced matching rules allow you to target specific requests
44+
- Introduce randomness into symptoms
45+
- Simulate real-world network connectivity problems/partitions for mobile devices, distributed systems etc.
46+
- Ideal for use in CI/Test Suites to test resilience across languages/technologies
47+
- Simple native binary installation with no dependencies
48+
- Extensible and modular architecture
49+
- An official Docker [container](https://github.com/mefellows/docker-muxy) to simplify uses cases such as Docker Compose
6850

6951
## Installation
7052

@@ -89,44 +71,44 @@ go get github.com/mefellows/muxy
8971

9072
Muxy is typically used in two ways:
9173

92-
1. In local development to see how your application responds
93-
under certain conditions
94-
1. In test suites to automate resilience testing
74+
1. In local development to see how your application responds
75+
under certain conditions
76+
1. In test suites to automate resilience testing
9577

9678
### 5-minute example
9779

9880
1. Install Muxy
9981
1. Create configuration file `config.yml`:
10082

101-
```yaml
102-
# Configures a proxy to forward/mess with your requests
103-
# to/from www.onegeek.com.au. This example adds a 5s delay
104-
# to the response.
105-
proxy:
106-
- name: http_proxy
107-
config:
108-
host: 0.0.0.0
109-
port: 8181
110-
proxy_host: www.onegeek.com.au
111-
proxy_port: 80
112-
113-
# Proxy plugins
114-
middleware:
115-
- name: http_tamperer
116-
config:
117-
request:
118-
host: "www.onegeek.com.au"
119-
120-
# Message Delay request/response plugin
121-
- name: delay
122-
config:
123-
request_delay: 1000
124-
response_delay: 500
125-
126-
# Log in/out messages
127-
- name: logger
128-
129-
```
83+
```yaml
84+
# Configures a proxy to forward/mess with your requests
85+
# to/from www.onegeek.com.au. This example adds a 5s delay
86+
# to the response.
87+
proxy:
88+
- name: http_proxy
89+
config:
90+
host: 0.0.0.0
91+
port: 8181
92+
proxy_host: www.onegeek.com.au
93+
proxy_port: 80
94+
95+
# Proxy plugins
96+
middleware:
97+
- name: http_tamperer
98+
config:
99+
request:
100+
host: "www.onegeek.com.au"
101+
102+
# Message Delay request/response plugin
103+
- name: delay
104+
config:
105+
request_delay: 1000
106+
response_delay: 500
107+
108+
# Log in/out messages
109+
- name: logger
110+
```
111+
130112
1. Run Muxy with your config: `muxy proxy --config ./config.yml`
131113
1. Make a request to www.onegeek.com via the proxy: `time curl -v -H"Host: www.onegeek.com.au" http://localhost:8181/`. Compare that with a request direct to the website: `time curl -v www.onegeek.com.au` - it should be approximately 5s faster.
132114

@@ -137,10 +119,10 @@ That's it - running Muxy is a matter of configuring one or more [Proxies](#proxi
137119
1. Create an application
138120
2. Build in fault tolerence (e.g. using something like [Hystrix](https://github.com/Netflix/Hystrix))
139121
3. Create integration tests
140-
1. Run Muxy configuring a *proxy* such as HTTP, and one or more *symptom*s such as network latency, partition or HTTP error
141-
2. Point your app at Muxy
142-
3. Run tests and check if system behaved as expected
143-
4. Profit!
122+
4. Run Muxy configuring a _proxy_ such as HTTP, and one or more *symptom*s such as network latency, partition or HTTP error
123+
5. Point your app at Muxy
124+
6. Run tests and check if system behaved as expected
125+
7. Profit!
144126

145127
### Notes
146128

@@ -150,6 +132,7 @@ It is also recommended to run within a container/virtual machine to avoid uninte
150132
## Proxies and Middlewares
151133

152134
### Proxies
135+
153136
#### HTTP Proxy
154137

155138
Simple HTTP(s) Proxy that starts up on a local IP/Hostname and Port.
@@ -208,8 +191,8 @@ Example configuration snippet:
208191
proxy:
209192
- name: tcp_proxy
210193
config:
211-
host: 0.0.0.0 # Local ip/hostname to bind to and accept connections.
212-
port: 8080 # Local port to bind to
194+
host: 0.0.0.0 # Local ip/hostname to bind to and accept connections.
195+
port: 8080 # Local port to bind to
213196
proxy_host: 0.0.0.0
214197
proxy_port: 2000
215198
nagles_algorithm: true
@@ -232,18 +215,18 @@ Example configuration snippet:
232215
middleware:
233216
- name: delay
234217
config:
235-
request_delay: 1000 # Delay in ms to apply to request to target
236-
response_delay: 500 # Delay in ms to apply to response from target
218+
request_delay: 1000 # Delay in ms to apply to request to target
219+
response_delay: 500 # Delay in ms to apply to response from target
237220
238221
# Specify additional matching rules. Default is to apply delay to all
239222
# requests on all http proxies.
240223
# Request matchers are specified as valid regular expressions
241224
# and must be properly YAML escaped.
242225
# See https://github.com/mefellows/muxy/issues/11 for behaviour.
243226
matching_rules:
244-
- method: 'GET|DELETE'
245-
path: '^/boo'
246-
host: 'foo\.com'
227+
- method: "GET|DELETE"
228+
path: "^/boo"
229+
host: 'foo\.com'
247230
```
248231

249232
#### HTTP Tamperer
@@ -257,78 +240,78 @@ middleware:
257240
- name: http_tamperer
258241
config:
259242
request:
260-
host: "somehost" # Override Host header that's sent to target
261-
path: "/" # Override the request path
262-
method: "GET" # Override request method
243+
host: "somehost" # Override Host header that's sent to target
244+
path: "/" # Override the request path
245+
method: "GET" # Override request method
263246
headers:
264-
x_my_request: "foo" # Override request header
247+
x_my_request: "foo" # Override request header
265248
content_type: "application/x-www-form-urlencoded"
266249
content_length: "5"
267-
cookies: # Custom request cookies
268-
- name: "fooreq"
269-
value: "blahaoeuaoeu"
270-
domain: "localhost"
271-
path: "/foopath"
272-
secure: true
273-
rawexpires: "Sat, 12 Sep 2015 09:19:48 UTC"
274-
maxage: 200
275-
httponly: true
276-
body: "wow, new body!" # Override request body
250+
cookies: # Custom request cookies
251+
- name: "fooreq"
252+
value: "blahaoeuaoeu"
253+
domain: "localhost"
254+
path: "/foopath"
255+
secure: true
256+
rawexpires: "Sat, 12 Sep 2015 09:19:48 UTC"
257+
maxage: 200
258+
httponly: true
259+
body: "wow, new body!" # Override request body
277260
response:
278-
status: 201 # Override HTTP Status code
279-
headers: # Override response headers
261+
status: 201 # Override HTTP Status code
262+
headers: # Override response headers
280263
content_length: "27"
281-
x_foo_bar: "baz"
282-
body: "my new body" # Override response body
283-
cookies: # Custom response cookies
284-
- name: "foo"
285-
value: "blahaoeuaoeu"
286-
domain: "localhost"
287-
path: "/foopath"
288-
secure: true
289-
rawexpires: "Sat, 12 Sep 2015 09:19:48 UTC"
290-
maxage: 200
291-
httponly: true
264+
x_foo_bar: "baz"
265+
body: "my new body" # Override response body
266+
cookies: # Custom response cookies
267+
- name: "foo"
268+
value: "blahaoeuaoeu"
269+
domain: "localhost"
270+
path: "/foopath"
271+
secure: true
272+
rawexpires: "Sat, 12 Sep 2015 09:19:48 UTC"
273+
maxage: 200
274+
httponly: true
292275
293276
# Specify additional matching rules. Default is to apply delay to all
294277
# requests on all http proxies.
295278
# Request matchers are specified as valid regular expressions
296279
# and must be properly YAML escaped.
297280
# See https://github.com/mefellows/muxy/issues/11 for behaviour.
298281
matching_rules:
299-
- method: 'GET|DELETE'
300-
path: '^/boo'
301-
host: 'foo\.com'
282+
- method: "GET|DELETE"
283+
path: "^/boo"
284+
host: 'foo\.com'
302285
```
303286

304287
#### Network Shaper
305288

306-
The network shaper plugin is a Layer 4 tamperer, and requires *root access* to work, as it needs to configure the local firewall and network devices.
289+
The network shaper plugin is a Layer 4 tamperer, and requires _root access_ to work, as it needs to configure the local firewall and network devices.
307290
Using the excellent [Comcast](https://github.com/tylertreat/comcast) library, it can shape and interfere with network traffic,
308291
including bandwidth, latency, packet loss and jitter on specified ports, IPs and protocols.
309292

310-
NOTE: This component only works on MacOSX, FreeBSD, Linux and common *nix flavours.
293+
NOTE: This component only works on MacOSX, FreeBSD, Linux and common \*nix flavours.
311294

312295
Example configuration snippet:
313296

314297
```yaml
315298
middleware:
316-
317299
- name: network_shape
318300
config:
319-
latency: 250 # Latency to add in ms
320-
target_bw: 750 # Bandwidth in kbits/s
321-
packet_loss: 0.5 # Packet loss, as a %
322-
target_ips: # Target ipv4 IP addresses
301+
latency: 250 # Latency to add in ms
302+
target_bw: 750 # Bandwidth in kbits/s
303+
packet_loss: 0.5 # Packet loss, as a %
304+
target_ips: # Target ipv4 IP addresses
323305
- 0.0.0.0
324-
target_ips6: # Target ipv6 IP addresses
306+
target_ips6: # Target ipv6 IP addresses
325307
- "::1/128"
326-
target_ports: # Target destination ports
308+
target_ports: # Target destination ports
327309
- "80"
328-
target_protos: # Target protocols
310+
target_protos: # Target protocols
329311
- "tcp"
330312
- "udp"
331313
- "icmp"
314+
device: "lo" # defaults to eth0
332315
```
333316

334317
#### TCP Tamperer
@@ -341,13 +324,13 @@ the last character of messages or randomise the text over the wire.
341324
- name: tcp_tamperer
342325
config:
343326
request:
344-
body: "wow, new request!" # Override request body
345-
randomize: true # Replaces input message with a random string
346-
truncate: true # Removes last character from the request message
327+
body: "wow, new request!" # Override request body
328+
randomize: true # Replaces input message with a random string
329+
truncate: true # Removes last character from the request message
347330
response:
348331
body: "wow, new response!" # Override response body
349-
randomize: true # Replaces response message with a random string
350-
truncate: true # Removes last character from the response message
332+
randomize: true # Replaces response message with a random string
333+
truncate: true # Removes last character from the response message
351334
```
352335

353336
#### Logger
@@ -360,7 +343,7 @@ Example configuration snippet:
360343
middleware:
361344
- name: logger
362345
config:
363-
hex_output: false # Display output as Hex instead of a string
346+
hex_output: false # Display output as Hex instead of a string
364347
```
365348

366349
## Configuration Reference
@@ -408,7 +391,7 @@ Take a look at the [HTTP Proxy](protocol/http.go) for a good working example.
408391
409392
### Middleware
410393
411-
Middlewares implement the [Middleware](/muxy/middle.go) interface and register themselves via `PluginFactories.register` to be available at runtime.
394+
Middlewares implement the [Middleware](/muxy/middle.go) interface and register themselves via `PluginFactories.register` to be available at runtime.
412395
Take a look at the [HTTP Delay](symptom/http_delay.go) for a good working example.
413396
414397
## Contributing

Diff for: symptom/network_shape.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ func supressOutput(f func()) {
105105
var buf bytes.Buffer
106106
io.Copy(&buf, r)
107107
o := buf.String()
108-
log.Trace(o)
108+
l.Println("[TRACE] output from OS-specific throttler:")
109+
l.Println(o)
109110
outC <- o
110111
}()
111112

112-
// log to TRACE
113-
114113
// back to normal state
115114
w.Close()
116115
os.Stdout = old

Diff for: symptom/throttler/ipfw.go

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// Package throttler is a modified version of https://github.com/tylertreat/comcast/,
2-
// with hard exits removed for use as a library
31
package throttler
42

53
import (

0 commit comments

Comments
 (0)