You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- 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
68
50
69
51
## Installation
70
52
@@ -89,44 +71,44 @@ go get github.com/mefellows/muxy
89
71
90
72
Muxy is typically used in two ways:
91
73
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
95
77
96
78
### 5-minute example
97
79
98
80
1. Install Muxy
99
81
1. Create configuration file `config.yml`:
100
82
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
+
130
112
1. Run Muxy with your config: `muxy proxy --config ./config.yml`
131
113
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.
132
114
@@ -137,10 +119,10 @@ That's it - running Muxy is a matter of configuring one or more [Proxies](#proxi
137
119
1. Create an application
138
120
2. Build in fault tolerence (e.g. using something like [Hystrix](https://github.com/Netflix/Hystrix))
139
121
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!
144
126
145
127
### Notes
146
128
@@ -150,6 +132,7 @@ It is also recommended to run within a container/virtual machine to avoid uninte
150
132
## Proxies and Middlewares
151
133
152
134
### Proxies
135
+
153
136
#### HTTP Proxy
154
137
155
138
Simple HTTP(s) Proxy that starts up on a local IP/Hostname and Port.
@@ -208,8 +191,8 @@ Example configuration snippet:
208
191
proxy:
209
192
- name: tcp_proxy
210
193
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
213
196
proxy_host: 0.0.0.0
214
197
proxy_port: 2000
215
198
nagles_algorithm: true
@@ -232,18 +215,18 @@ Example configuration snippet:
232
215
middleware:
233
216
- name: delay
234
217
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
237
220
238
221
# Specify additional matching rules. Default is to apply delay to all
239
222
# requests on all http proxies.
240
223
# Request matchers are specified as valid regular expressions
241
224
# and must be properly YAML escaped.
242
225
# See https://github.com/mefellows/muxy/issues/11 for behaviour.
243
226
matching_rules:
244
-
- method: 'GET|DELETE'
245
-
path: '^/boo'
246
-
host: 'foo\.com'
227
+
- method: "GET|DELETE"
228
+
path: "^/boo"
229
+
host: 'foo\.com'
247
230
```
248
231
249
232
#### HTTP Tamperer
@@ -257,78 +240,78 @@ middleware:
257
240
- name: http_tamperer
258
241
config:
259
242
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
263
246
headers:
264
-
x_my_request: "foo" # Override request header
247
+
x_my_request: "foo" # Override request header
265
248
content_type: "application/x-www-form-urlencoded"
266
249
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
277
260
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
280
263
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
292
275
293
276
# Specify additional matching rules. Default is to apply delay to all
294
277
# requests on all http proxies.
295
278
# Request matchers are specified as valid regular expressions
296
279
# and must be properly YAML escaped.
297
280
# See https://github.com/mefellows/muxy/issues/11 for behaviour.
298
281
matching_rules:
299
-
- method: 'GET|DELETE'
300
-
path: '^/boo'
301
-
host: 'foo\.com'
282
+
- method: "GET|DELETE"
283
+
path: "^/boo"
284
+
host: 'foo\.com'
302
285
```
303
286
304
287
#### Network Shaper
305
288
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.
307
290
Using the excellent [Comcast](https://github.com/tylertreat/comcast) library, it can shape and interfere with network traffic,
308
291
including bandwidth, latency, packet loss and jitter on specified ports, IPs and protocols.
309
292
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.
311
294
312
295
Example configuration snippet:
313
296
314
297
```yaml
315
298
middleware:
316
-
317
299
- name: network_shape
318
300
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
323
305
- 0.0.0.0
324
-
target_ips6: # Target ipv6 IP addresses
306
+
target_ips6: # Target ipv6 IP addresses
325
307
- "::1/128"
326
-
target_ports: # Target destination ports
308
+
target_ports: # Target destination ports
327
309
- "80"
328
-
target_protos: # Target protocols
310
+
target_protos: # Target protocols
329
311
- "tcp"
330
312
- "udp"
331
313
- "icmp"
314
+
device: "lo" # defaults to eth0
332
315
```
333
316
334
317
#### TCP Tamperer
@@ -341,13 +324,13 @@ the last character of messages or randomise the text over the wire.
341
324
- name: tcp_tamperer
342
325
config:
343
326
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
347
330
response:
348
331
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
351
334
```
352
335
353
336
#### Logger
@@ -360,7 +343,7 @@ Example configuration snippet:
360
343
middleware:
361
344
- name: logger
362
345
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
364
347
```
365
348
366
349
## Configuration Reference
@@ -408,7 +391,7 @@ Take a look at the [HTTP Proxy](protocol/http.go) for a good working example.
408
391
409
392
### Middleware
410
393
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.
412
395
Take a look at the [HTTP Delay](symptom/http_delay.go) for a good working example.
0 commit comments