toxiproxy 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5162d845ab2d8f5b1e1b9af5bf6254957bf9730
4
- data.tar.gz: 0390171e4205337d2c37987980abeffd3c748735
3
+ metadata.gz: 07ea894e2ec459737f6d98f2673e3049e683c4a6
4
+ data.tar.gz: 5310b2f902eef3c7b468fb1d88df000b287bc943
5
5
  SHA512:
6
- metadata.gz: 6328fbcc0977e717ea1dfc596c9388865d86ad3913ca9f1671cd568418c3acf9c5f297bb45fe7b306065a5f232c4a2bc1bb8cb4aefc64c022e68bf6daedc027f
7
- data.tar.gz: 28e150d00c44ff1cc25cece0c148d52d9e54538750045ed53b944baac01ac44b3a33d0737383d3c297b8d28769ef9f2f58e40862ba28f0e49ec7e89dba864c3c
6
+ metadata.gz: 27251df5e59a5144ed162a220f401b431e5e68ece5376f3b67e1ae4aa0594609d6b8dcb0b8d1724a7a4f736cc73564d37cc9bd0880e05ba638da2b47e308c01f
7
+ data.tar.gz: cd8ad0b67da109706aba5ca9c6a4e70313217379f0db35e5899edd45a3c4cd286d6385f03812efe3f2371b2abdc4a7987601e0e381d235228743838447c1df74
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -82,7 +82,7 @@ Toxiproxy.populate([{
82
82
  })
83
83
  ```
84
84
 
85
- This will create the proxies passed, if they don't already exist, in Toxiproxy.
85
+ This will create the proxies passed, or replace the proxies if they already exist in Toxiproxy.
86
86
  It's recommended to do this early as early in boot as possible, see the
87
87
  [Toxiproxy README](https://github.com/shopify/toxiproxy#Usage). If you have many
88
88
  proxies, we recommend storing the Toxiproxy configs in a configuration file.
@@ -1,6 +1,6 @@
1
1
  #!/bin/bash -e
2
2
 
3
- VERSION='0eef7f44653b07ee0e0f8de1cc64b09a'
3
+ VERSION='21a264cc75549c3ae837b606eb6e17ea'
4
4
 
5
5
  echo "[start toxiproxy]"
6
6
  curl --silent http://shopify-vagrant.s3.amazonaws.com/toxiproxy/toxiproxy-$VERSION -o ./bin/toxiproxy
data/lib/toxiproxy.rb CHANGED
@@ -89,7 +89,12 @@ class Toxiproxy
89
89
  proxies = proxies.first if proxies.first.is_a?(Array)
90
90
 
91
91
  proxies.map { |proxy|
92
- self.create(proxy) unless find_by_name(proxy[:name])
92
+ existing = find_by_name(proxy[:name])
93
+ if existing && (existing.upstream != proxy[:upstream] || existing.listen != proxy[:listen])
94
+ existing.destroy
95
+ existing = false
96
+ end
97
+ self.create(proxy) unless existing
93
98
  }.compact
94
99
  end
95
100
 
@@ -1,3 +1,3 @@
1
1
  class Toxiproxy
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -303,6 +303,53 @@ class ToxiproxyTest < MiniTest::Unit::TestCase
303
303
  end
304
304
  end
305
305
 
306
+ def test_populate_creates_proxies_update_listen
307
+ proxies = [{
308
+ name: "test_toxiproxy_populate1",
309
+ upstream: "localhost:3306",
310
+ listen: "localhost:22222",
311
+ },
312
+ ]
313
+
314
+ proxies = Toxiproxy.populate(proxies)
315
+
316
+ proxies = [{
317
+ name: "test_toxiproxy_populate1",
318
+ upstream: "localhost:3306",
319
+ listen: "localhost:22223",
320
+ },
321
+ ]
322
+
323
+ proxies = Toxiproxy.populate(proxies)
324
+
325
+ proxies.each do |proxy|
326
+ assert_proxy_available(proxy)
327
+ end
328
+ end
329
+
330
+ def test_populate_creates_proxies_update_upstream
331
+ proxies = [{
332
+ name: "test_toxiproxy_populate1",
333
+ upstream: "localhost:3306",
334
+ listen: "localhost:22222",
335
+ },
336
+ ]
337
+
338
+ proxies = Toxiproxy.populate(proxies)
339
+
340
+ proxies = [{
341
+ name: "test_toxiproxy_populate1",
342
+ upstream: "localhost:3307",
343
+ listen: "localhost:22222",
344
+ },
345
+ ]
346
+
347
+ proxies2 = Toxiproxy.populate(proxies)
348
+
349
+ assert_equal proxies.first[:upstream], proxies2.first.upstream
350
+ assert_proxy_available(proxies2.first)
351
+ end
352
+
306
353
  private
307
354
 
308
355
  def 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.1
4
+ version: 0.1.2
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-02-17 00:00:00.000000000 Z
34
+ date: 2015-05-11 00:00:00.000000000 Z
35
35
  dependencies:
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: bundler
metadata.gz.sig CHANGED
Binary file