toxiproxy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +18 -4
- data/lib/toxiproxy.rb +5 -6
- data/lib/toxiproxy/version.rb +1 -1
- data/test/test_helper.rb +0 -1
- data/test/toxiproxy_test.rb +34 -2
- metadata +2 -3
- metadata.gz.sig +0 -0
- data/test/fixtures/toxiproxy.json +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5162d845ab2d8f5b1e1b9af5bf6254957bf9730
|
4
|
+
data.tar.gz: 0390171e4205337d2c37987980abeffd3c748735
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6328fbcc0977e717ea1dfc596c9388865d86ad3913ca9f1671cd568418c3acf9c5f297bb45fe7b306065a5f232c4a2bc1bb8cb4aefc64c022e68bf6daedc027f
|
7
|
+
data.tar.gz: 28e150d00c44ff1cc25cece0c148d52d9e54538750045ed53b944baac01ac44b3a33d0737383d3c297b8d28769ef9f2f58e40862ba28f0e49ec7e89dba864c3c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
and system conditions. The Ruby API aims to make it simple to write tests that
|
5
5
|
ensure your application behaves appropriately under harsh conditions. Before you
|
6
6
|
can use the Ruby library, you need to read the [Usage section of the Toxiproxy
|
7
|
-
README](https://
|
7
|
+
README](https://github.com/shopify/toxiproxy#usage).
|
8
8
|
|
9
9
|
```
|
10
10
|
gem install toxiproxy
|
@@ -61,14 +61,28 @@ You can apply many toxics to many connections:
|
|
61
61
|
Toxiproxy[/redis/].upstream(:slow_close, delay: 100).downstream(:latency, jitter: 300).apply do
|
62
62
|
# all redises are now slow at responding and closing
|
63
63
|
end
|
64
|
+
```
|
65
|
+
|
66
|
+
See the [Toxiproxy README](https://github.com/shopify/toxiproxy#Toxics) for a
|
67
|
+
list of toxics.
|
64
68
|
|
65
69
|
## Populate
|
66
70
|
|
67
|
-
To populate Toxiproxy
|
71
|
+
To populate Toxiproxy pass the proxy configurations to `Toxiproxy#populate`:
|
68
72
|
|
69
73
|
```ruby
|
70
|
-
Toxiproxy.populate(
|
74
|
+
Toxiproxy.populate([{
|
75
|
+
name: "mysql_master",
|
76
|
+
listen: "localhost:21212",
|
77
|
+
upstream: "localhost:3306",
|
78
|
+
},{
|
79
|
+
name: "mysql_read_only",
|
80
|
+
listen: "localhost:21213",
|
81
|
+
upstream: "localhost:3306",
|
82
|
+
})
|
71
83
|
```
|
72
84
|
|
85
|
+
This will create the proxies passed, if they don't already exist, in Toxiproxy.
|
73
86
|
It's recommended to do this early as early in boot as possible, see the
|
74
|
-
[Toxiproxy README](https://github.com/shopify/toxiproxy#Usage)
|
87
|
+
[Toxiproxy README](https://github.com/shopify/toxiproxy#Usage). If you have many
|
88
|
+
proxies, we recommend storing the Toxiproxy configs in a configuration file.
|
data/lib/toxiproxy.rb
CHANGED
@@ -85,13 +85,12 @@ class Toxiproxy
|
|
85
85
|
find_by_name!(query)
|
86
86
|
end
|
87
87
|
|
88
|
-
def self.populate(
|
89
|
-
proxies =
|
90
|
-
proxies = proxies.map { |proxy| self.new(proxy) }
|
88
|
+
def self.populate(*proxies)
|
89
|
+
proxies = proxies.first if proxies.first.is_a?(Array)
|
91
90
|
|
92
|
-
proxies.
|
93
|
-
|
94
|
-
|
91
|
+
proxies.map { |proxy|
|
92
|
+
self.create(proxy) unless find_by_name(proxy[:name])
|
93
|
+
}.compact
|
95
94
|
end
|
96
95
|
|
97
96
|
# Set an upstream toxic.
|
data/lib/toxiproxy/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
data/test/toxiproxy_test.rb
CHANGED
@@ -263,8 +263,40 @@ class ToxiproxyTest < MiniTest::Unit::TestCase
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
def
|
267
|
-
proxies =
|
266
|
+
def test_populate_creates_proxies_array
|
267
|
+
proxies = [{
|
268
|
+
name: "test_toxiproxy_populate1",
|
269
|
+
upstream: "localhost:3306",
|
270
|
+
listen: "localhost:22222",
|
271
|
+
},
|
272
|
+
{
|
273
|
+
name: "test_toxiproxy_populate2",
|
274
|
+
upstream: "localhost:3306",
|
275
|
+
listen: "localhost:22223",
|
276
|
+
},
|
277
|
+
]
|
278
|
+
|
279
|
+
proxies = Toxiproxy.populate(proxies)
|
280
|
+
|
281
|
+
proxies.each do |proxy|
|
282
|
+
assert_proxy_available(proxy)
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def test_populate_creates_proxies_args
|
287
|
+
proxies = [{
|
288
|
+
name: "test_toxiproxy_populate1",
|
289
|
+
upstream: "localhost:3306",
|
290
|
+
listen: "localhost:22222",
|
291
|
+
},
|
292
|
+
{
|
293
|
+
name: "test_toxiproxy_populate2",
|
294
|
+
upstream: "localhost:3306",
|
295
|
+
listen: "localhost:22223",
|
296
|
+
},
|
297
|
+
]
|
298
|
+
|
299
|
+
proxies = Toxiproxy.populate(*proxies)
|
268
300
|
|
269
301
|
proxies.each do |proxy|
|
270
302
|
assert_proxy_available(proxy)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: toxiproxy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
|
32
32
|
TConQSX2BnZdhIEYW+cKzEC/bLc=
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-
|
34
|
+
date: 2015-02-17 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
@@ -94,7 +94,6 @@ files:
|
|
94
94
|
- lib/toxiproxy/toxic_collection.rb
|
95
95
|
- lib/toxiproxy/version.rb
|
96
96
|
- shipit.rubygems.yml
|
97
|
-
- test/fixtures/toxiproxy.json
|
98
97
|
- test/test_helper.rb
|
99
98
|
- test/toxiproxy_test.rb
|
100
99
|
- toxiproxy.gemspec
|
metadata.gz.sig
CHANGED
Binary file
|