toxiproxy 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75c5cd8a2dd3d9a8f0b932d7f50e0359c77c0fda
4
- data.tar.gz: a6585a9edf06bc9888943292d8784c8aab61685c
3
+ metadata.gz: a5162d845ab2d8f5b1e1b9af5bf6254957bf9730
4
+ data.tar.gz: 0390171e4205337d2c37987980abeffd3c748735
5
5
  SHA512:
6
- metadata.gz: 11f4d1e556c4f942838e3c7d7484e25ed6defecb77985d4609739f25ec383c51aa07c505f64313fb197cfac96611d8ab97d688f6bb8a09a2169112acdf0e763b
7
- data.tar.gz: 87df2064d0189804a8e84820304a5a9312c767b1337bf3d7941c9ea929bdbaa25de654188ba8cdf9d0a361e0087c86ce5a096c428ec0f1d4b7d073a019f218c6
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://githubcom/shopify/toxiproxy#Usage).
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 with the proxies from `config/toxiproxy.json`:
71
+ To populate Toxiproxy pass the proxy configurations to `Toxiproxy#populate`:
68
72
 
69
73
  ```ruby
70
- Toxiproxy.populate("./config/toxiproxy.json")
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(path)
89
- proxies = JSON.parse(File.read(path), symbolize_names: true)
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.each do |proxy|
93
- proxy.create unless find_by_name(proxy.name)
94
- end
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.
@@ -1,3 +1,3 @@
1
1
  class Toxiproxy
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,3 +1,2 @@
1
- require 'minitest'
2
1
  require 'minitest/autorun'
3
2
  require_relative "../lib/toxiproxy"
@@ -263,8 +263,40 @@ class ToxiproxyTest < MiniTest::Unit::TestCase
263
263
  end
264
264
  end
265
265
 
266
- def test_populate_creates_proxies
267
- proxies = Toxiproxy.populate("./test/fixtures/toxiproxy.json")
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.0
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-01-07 00:00:00.000000000 Z
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
@@ -1,7 +0,0 @@
1
- [
2
- {
3
- "name": "toxiproxy_test_mysql",
4
- "upstream": "localhost:3306",
5
- "listen": "localhost:22222"
6
- }
7
- ]