toxiproxy 1.0.2 → 2.0.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 +5 -5
- data/README.md +1 -1
- data/lib/toxiproxy/toxic.rb +2 -1
- data/lib/toxiproxy/version.rb +1 -1
- data/lib/toxiproxy.rb +33 -8
- data/test/toxiproxy_test.rb +22 -8
- metadata +12 -71
- data/.gitignore +0 -4
- data/Gemfile +0 -3
- data/Rakefile +0 -12
- data/bin/start-toxiproxy.sh +0 -17
- data/circle.yml +0 -11
- data/shipit.rubygems.yml +0 -2
- data/toxiproxy.gemspec +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d135ce7e35507ad08017ae28db7f7543f9c0d0a29cd32042c9c61d072bee5eee
|
4
|
+
data.tar.gz: 8db56acdadcac8ac84b5b1be31a235cd7715422ff4cee1a36e3832eb983355f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adee5993b439b3227b67ec4ca28fecdb8c7194d9b640e369df77f60a754d42bf20d758eaa8ca2a11a553451d7bd63654d14b0a03781fcc07751a5f5e947d524b
|
7
|
+
data.tar.gz: 1d69a13027507acc7791ac0904e70b1a02bd6f5bd4bad55e2724b6cc6e0d9f19e0e949c05d49f5ef7313e80193cfe898c3b2950c5124c41277412254b5895144
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# toxiproxy-ruby
|
2
2
|
|
3
|
-
`toxiproxy-ruby`
|
3
|
+
`toxiproxy-ruby` `>= 1.x` is compatible with the Toxiproxy `2.x` series.
|
4
4
|
`toxiproxy-ruby` `0.x` is compatible with the Toxiproxy `1.x` series.
|
5
5
|
|
6
6
|
[Toxiproxy](https://github.com/shopify/toxiproxy) is a proxy to simulate network
|
data/lib/toxiproxy/toxic.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class Toxiproxy
|
2
2
|
class Toxic
|
3
|
-
attr_reader :name, :type, :
|
3
|
+
attr_reader :name, :type, :stream, :proxy
|
4
4
|
attr_accessor :attributes, :toxicity
|
5
5
|
|
6
6
|
def initialize(attrs)
|
@@ -15,6 +15,7 @@ class Toxiproxy
|
|
15
15
|
|
16
16
|
def save
|
17
17
|
request = Net::HTTP::Post.new("/proxies/#{proxy.name}/toxics")
|
18
|
+
request["Content-Type"] = "application/json"
|
18
19
|
|
19
20
|
request.body = as_json
|
20
21
|
|
data/lib/toxiproxy/version.rb
CHANGED
data/lib/toxiproxy.rb
CHANGED
@@ -31,6 +31,8 @@ class Toxiproxy
|
|
31
31
|
# Re-enables all proxies and disables all toxics.
|
32
32
|
def self.reset
|
33
33
|
request = Net::HTTP::Post.new("/reset")
|
34
|
+
request["Content-Type"] = "application/json"
|
35
|
+
|
34
36
|
response = http_request(request)
|
35
37
|
assert_response(response)
|
36
38
|
self
|
@@ -66,6 +68,8 @@ class Toxiproxy
|
|
66
68
|
# Sets the toxiproxy host to use.
|
67
69
|
def self.host=(host)
|
68
70
|
@uri = host.is_a?(::URI) ? host : ::URI.parse(host)
|
71
|
+
reset_http_client!
|
72
|
+
@uri
|
69
73
|
end
|
70
74
|
|
71
75
|
# Convenience method to create a proxy.
|
@@ -96,14 +100,23 @@ class Toxiproxy
|
|
96
100
|
def self.populate(*proxies)
|
97
101
|
proxies = proxies.first if proxies.first.is_a?(Array)
|
98
102
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
103
|
+
request = Net::HTTP::Post.new("/populate")
|
104
|
+
request.body = proxies.to_json
|
105
|
+
request["Content-Type"] = "application/json"
|
106
|
+
|
107
|
+
response = http_request(request)
|
108
|
+
assert_response(response)
|
109
|
+
|
110
|
+
proxies = JSON.parse(response.body).fetch('proxies', []).map do |attrs|
|
111
|
+
self.new({
|
112
|
+
upstream: attrs["upstream"],
|
113
|
+
listen: attrs["listen"],
|
114
|
+
name: attrs["name"],
|
115
|
+
enabled: attrs["enabled"]
|
116
|
+
})
|
117
|
+
end
|
118
|
+
|
119
|
+
ProxyCollection.new(proxies)
|
107
120
|
end
|
108
121
|
|
109
122
|
def self.running?
|
@@ -144,6 +157,7 @@ class Toxiproxy
|
|
144
157
|
# Disables a Toxiproxy. This will drop all active connections and stop the proxy from listening.
|
145
158
|
def disable
|
146
159
|
request = Net::HTTP::Post.new("/proxies/#{name}")
|
160
|
+
request["Content-Type"] = "application/json"
|
147
161
|
|
148
162
|
hash = {enabled: false}
|
149
163
|
request.body = hash.to_json
|
@@ -156,6 +170,7 @@ class Toxiproxy
|
|
156
170
|
# Enables a Toxiproxy. This will cause the proxy to start listening again.
|
157
171
|
def enable
|
158
172
|
request = Net::HTTP::Post.new("/proxies/#{name}")
|
173
|
+
request["Content-Type"] = "application/json"
|
159
174
|
|
160
175
|
hash = {enabled: true}
|
161
176
|
request.body = hash.to_json
|
@@ -170,6 +185,7 @@ class Toxiproxy
|
|
170
185
|
# of this connection.
|
171
186
|
def create
|
172
187
|
request = Net::HTTP::Post.new("/proxies")
|
188
|
+
request["Content-Type"] = "application/json"
|
173
189
|
|
174
190
|
hash = {upstream: upstream, name: name, listen: listen, enabled: enabled}
|
175
191
|
request.body = hash.to_json
|
@@ -209,6 +225,15 @@ class Toxiproxy
|
|
209
225
|
}
|
210
226
|
end
|
211
227
|
|
228
|
+
def self.reset_http_client!
|
229
|
+
if defined? @http
|
230
|
+
@http.finish() if @http && @http.started?
|
231
|
+
@http = nil
|
232
|
+
end
|
233
|
+
|
234
|
+
@http
|
235
|
+
end
|
236
|
+
|
212
237
|
private
|
213
238
|
|
214
239
|
def self.http_request(request)
|
data/test/toxiproxy_test.rb
CHANGED
@@ -358,26 +358,31 @@ class ToxiproxyTest < MiniTest::Unit::TestCase
|
|
358
358
|
end
|
359
359
|
|
360
360
|
def test_populate_creates_proxies_update_upstream
|
361
|
-
|
362
|
-
|
361
|
+
proxy_name = "test_toxiproxy_populate1"
|
362
|
+
proxies_config = [{
|
363
|
+
name: proxy_name,
|
363
364
|
upstream: "localhost:3306",
|
364
365
|
listen: "localhost:22222",
|
365
366
|
},
|
366
367
|
]
|
367
368
|
|
368
|
-
proxies = Toxiproxy.populate(
|
369
|
+
proxies = Toxiproxy.populate(proxies_config)
|
369
370
|
|
370
|
-
|
371
|
-
name:
|
371
|
+
proxies_config = [{
|
372
|
+
name: proxy_name,
|
372
373
|
upstream: "localhost:3307",
|
373
374
|
listen: "localhost:22222",
|
374
375
|
},
|
375
376
|
]
|
376
377
|
|
377
|
-
proxies2 = Toxiproxy.populate(
|
378
|
+
proxies2 = Toxiproxy.populate(proxies_config)
|
379
|
+
|
380
|
+
refute_equal proxies.find(name: proxy_name).first.upstream,
|
381
|
+
proxies2.find(name: proxy_name).first.upstream
|
378
382
|
|
379
|
-
|
380
|
-
|
383
|
+
proxies2.each do |proxy|
|
384
|
+
assert_proxy_available(proxy)
|
385
|
+
end
|
381
386
|
end
|
382
387
|
|
383
388
|
def test_running_helper
|
@@ -448,6 +453,15 @@ class ToxiproxyTest < MiniTest::Unit::TestCase
|
|
448
453
|
end
|
449
454
|
end
|
450
455
|
|
456
|
+
def test_invalidate_cache_http_on_host
|
457
|
+
old_value = Toxiproxy.uri
|
458
|
+
assert_equal 8474, Toxiproxy.http.port
|
459
|
+
Toxiproxy.host = "http://127.0.0.1:8475"
|
460
|
+
assert_equal 8475, Toxiproxy.http.port
|
461
|
+
ensure
|
462
|
+
Toxiproxy.host = old_value
|
463
|
+
end
|
464
|
+
|
451
465
|
private
|
452
466
|
|
453
467
|
def with_webmock_enabled
|
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:
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
@@ -9,90 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: bundler
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: '1.3'
|
21
|
-
type: :development
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: '1.3'
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: minitest
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :development
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: rake
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: webmock
|
58
|
-
requirement: !ruby/object:Gem::Requirement
|
59
|
-
requirements:
|
60
|
-
- - ">="
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
|
-
type: :development
|
64
|
-
prerelease: false
|
65
|
-
version_requirements: !ruby/object:Gem::Requirement
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
12
|
+
date: 2022-03-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
70
14
|
description: A Ruby library for controlling Toxiproxy. Can be used in resiliency testing.
|
71
|
-
email:
|
15
|
+
email: opensource@shopify.com
|
72
16
|
executables: []
|
73
17
|
extensions: []
|
74
18
|
extra_rdoc_files: []
|
75
19
|
files:
|
76
|
-
- ".gitignore"
|
77
|
-
- Gemfile
|
78
20
|
- LICENSE
|
79
21
|
- README.md
|
80
|
-
- Rakefile
|
81
|
-
- bin/start-toxiproxy.sh
|
82
|
-
- circle.yml
|
83
22
|
- lib/toxiproxy.rb
|
84
23
|
- lib/toxiproxy/proxy_collection.rb
|
85
24
|
- lib/toxiproxy/toxic.rb
|
86
25
|
- lib/toxiproxy/toxic_collection.rb
|
87
26
|
- lib/toxiproxy/version.rb
|
88
|
-
- shipit.rubygems.yml
|
89
27
|
- test/test_helper.rb
|
90
28
|
- test/toxiproxy_test.rb
|
91
|
-
- toxiproxy.gemspec
|
92
29
|
homepage: https://github.com/Shopify/toxiproxy
|
93
30
|
licenses:
|
94
31
|
- MIT
|
95
|
-
metadata:
|
32
|
+
metadata:
|
33
|
+
homepage_uri: https://github.com/Shopify/toxiproxy
|
34
|
+
documentation_uri: https://github.com/Shopify/toxiproxy-ruby
|
35
|
+
allowed_push_host: https://rubygems.org
|
96
36
|
post_install_message:
|
97
37
|
rdoc_options: []
|
98
38
|
require_paths:
|
@@ -108,9 +48,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
48
|
- !ruby/object:Gem::Version
|
109
49
|
version: '0'
|
110
50
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.5.2
|
51
|
+
rubygems_version: 3.2.20
|
113
52
|
signing_key:
|
114
53
|
specification_version: 4
|
115
54
|
summary: Ruby library for Toxiproxy
|
116
|
-
test_files:
|
55
|
+
test_files:
|
56
|
+
- test/test_helper.rb
|
57
|
+
- test/toxiproxy_test.rb
|
data/.gitignore
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/start-toxiproxy.sh
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
#!/bin/bash -e
|
2
|
-
|
3
|
-
VERSION='v2.0.0'
|
4
|
-
TOXIPROXY_LOG_DIR=${CIRCLE_ARTIFACTS:-'/tmp'}
|
5
|
-
|
6
|
-
if [[ "$OSTYPE" == "linux"* ]]; then
|
7
|
-
DOWNLOAD_TYPE="linux-amd64"
|
8
|
-
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
9
|
-
DOWNLOAD_TYPE="darwin-amd64"
|
10
|
-
fi
|
11
|
-
|
12
|
-
echo "[dowload toxiproxy for $DOWNLOAD_TYPE]"
|
13
|
-
curl --silent -L https://github.com/Shopify/toxiproxy/releases/download/$VERSION/toxiproxy-server-$DOWNLOAD_TYPE -o ./bin/toxiproxy-server
|
14
|
-
|
15
|
-
echo "[start toxiproxy]"
|
16
|
-
chmod +x ./bin/toxiproxy-server
|
17
|
-
nohup bash -c "./bin/toxiproxy-server > ${TOXIPROXY_LOG_DIR}/toxiproxy.log 2>&1 &"
|
data/circle.yml
DELETED
data/shipit.rubygems.yml
DELETED
data/toxiproxy.gemspec
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.expand_path("../lib/toxiproxy/version", __FILE__)
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "toxiproxy"
|
5
|
-
spec.version = Toxiproxy::VERSION
|
6
|
-
spec.authors = ["Simon Eskildsen", "Jacob Wirth"]
|
7
|
-
spec.email = "simon.eskildsen@shopify.com"
|
8
|
-
spec.summary = "Ruby library for Toxiproxy"
|
9
|
-
spec.description = "A Ruby library for controlling Toxiproxy. Can be used in resiliency testing."
|
10
|
-
spec.homepage = "https://github.com/Shopify/toxiproxy"
|
11
|
-
spec.license = "MIT"
|
12
|
-
|
13
|
-
spec.files = `git ls-files`.split("\n")
|
14
|
-
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
-
spec.require_paths = ["lib"]
|
16
|
-
|
17
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
18
|
-
spec.add_development_dependency "minitest"
|
19
|
-
spec.add_development_dependency "rake"
|
20
|
-
spec.add_development_dependency "webmock"
|
21
|
-
end
|