toxiproxy 1.0.3 → 2.0.2
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 +6 -3
- data/lib/toxiproxy/version.rb +1 -1
- data/lib/toxiproxy.rb +25 -8
- data/test/toxiproxy_test.rb +22 -8
- metadata +14 -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: 98c1cbde340b90f1da3d81bf0119ec97a161ffa3815eb06982dd88d807fcce18
|
4
|
+
data.tar.gz: 3a8e7e33d8add55ba5ab6fd77d1914faae65cefd4df3789c8dd3e2d5cf529b62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d9c8ace67f5371eba624490da0933d9b6e6eeb5162f2963a8fb9ad581e45a8efc4ce243a28a042343abeede16897e37ba0e25674c10cd92a94d52facddf931
|
7
|
+
data.tar.gz: 717ac41a5767aecd2a77df7e355180f30622e0628dbed7c7662a931ef0a3a0280119e1f098f8b1ceb4f30995ea702136588b02b5b4ab82408b2bee0abf0bdbe0
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# toxiproxy-ruby
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/toxiproxy)
|
4
|
+
[](https://github.com/Shopify/toxiproxy-ruby/actions/workflows/test.yml)
|
5
|
+
|
6
|
+
`toxiproxy-ruby` `>= 1.x` is compatible with the Toxiproxy `2.x` series.
|
4
7
|
`toxiproxy-ruby` `0.x` is compatible with the Toxiproxy `1.x` series.
|
5
8
|
|
6
9
|
[Toxiproxy](https://github.com/shopify/toxiproxy) is a proxy to simulate network
|
@@ -9,8 +12,8 @@ ensure your application behaves appropriately under harsh conditions. Before you
|
|
9
12
|
can use the Ruby library, you need to read the [Usage section of the Toxiproxy
|
10
13
|
README](https://github.com/shopify/toxiproxy#usage).
|
11
14
|
|
12
|
-
```
|
13
|
-
gem install toxiproxy
|
15
|
+
```shell
|
16
|
+
$ gem install toxiproxy
|
14
17
|
```
|
15
18
|
|
16
19
|
Make sure the Toxiproxy server is already running.
|
data/lib/toxiproxy/version.rb
CHANGED
data/lib/toxiproxy.rb
CHANGED
@@ -68,6 +68,8 @@ class Toxiproxy
|
|
68
68
|
# Sets the toxiproxy host to use.
|
69
69
|
def self.host=(host)
|
70
70
|
@uri = host.is_a?(::URI) ? host : ::URI.parse(host)
|
71
|
+
reset_http_client!
|
72
|
+
@uri
|
71
73
|
end
|
72
74
|
|
73
75
|
# Convenience method to create a proxy.
|
@@ -98,14 +100,23 @@ class Toxiproxy
|
|
98
100
|
def self.populate(*proxies)
|
99
101
|
proxies = proxies.first if proxies.first.is_a?(Array)
|
100
102
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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)
|
109
120
|
end
|
110
121
|
|
111
122
|
def self.running?
|
@@ -214,6 +225,12 @@ class Toxiproxy
|
|
214
225
|
}
|
215
226
|
end
|
216
227
|
|
228
|
+
@http = nil
|
229
|
+
def self.reset_http_client!
|
230
|
+
@http.finish if @http&.started?
|
231
|
+
@http = nil
|
232
|
+
end
|
233
|
+
|
217
234
|
private
|
218
235
|
|
219
236
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Eskildsen
|
@@ -9,90 +9,32 @@ 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-09-02 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
|
+
source_code_uri: https://github.com/Shopify/toxiproxy-ruby
|
35
|
+
changelog_uri: https://github.com/Shopify/toxiproxy-ruby/blob/master/CHANGELOG.md
|
36
|
+
documentation_uri: https://github.com/Shopify/toxiproxy-ruby
|
37
|
+
allowed_push_host: https://rubygems.org
|
96
38
|
post_install_message:
|
97
39
|
rdoc_options: []
|
98
40
|
require_paths:
|
@@ -108,9 +50,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
50
|
- !ruby/object:Gem::Version
|
109
51
|
version: '0'
|
110
52
|
requirements: []
|
111
|
-
|
112
|
-
rubygems_version: 2.6.14
|
53
|
+
rubygems_version: 3.3.3
|
113
54
|
signing_key:
|
114
55
|
specification_version: 4
|
115
56
|
summary: Ruby library for Toxiproxy
|
116
|
-
test_files:
|
57
|
+
test_files:
|
58
|
+
- test/test_helper.rb
|
59
|
+
- 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.1.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
|