aranea 0.0.2 → 0.0.3
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/lib/aranea/failure_repository.rb +9 -1
- data/lib/aranea/rack/aranea_middleware.rb +14 -1
- data/lib/aranea/version.rb +1 -1
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '019581a335c3958a31655effdf3af83cb79aa2987b9d79539a19d355b6643023'
|
4
|
+
data.tar.gz: d96ba0a406b2b69898747da9c6d03a91d9ac954fd948d53d5872109d4e4a9f4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5487fd366ef3dd6b4ed5cd0e4af82964e92babae887cb9d9dfdc8f08a200d8a17d7f5fc2e7d39e0b8ec31db7bd06421cb9f739ded22dc784a3de1b48c8a82ea
|
7
|
+
data.tar.gz: 832d65d2819bd27a0fb62256fbdc3eac4a44238a54b8669c184cd48336b362edb767931c780e6677324be2f203851430eea68b9f1cdecc790f54b471370c1ec9
|
@@ -1,5 +1,7 @@
|
|
1
1
|
require 'faraday'
|
2
2
|
require 'active_support/core_ext/numeric/time'
|
3
|
+
require 'json'
|
4
|
+
|
3
5
|
module Aranea
|
4
6
|
|
5
7
|
# TODO: Look into moving whitelisting of consumer hostnames to here and allowing it to be configurable via the consuming application
|
@@ -33,6 +35,8 @@ module Aranea
|
|
33
35
|
def initialize(params)
|
34
36
|
@pattern = Regexp.new(params[:pattern])
|
35
37
|
@response = params[:failure]
|
38
|
+
@response_hash = params[:response_hash] || {}
|
39
|
+
@response_headers_hash = params[:response_headers_hash] || {}
|
36
40
|
end
|
37
41
|
|
38
42
|
def should_fail?(request_env, app)
|
@@ -45,7 +49,11 @@ module Aranea
|
|
45
49
|
elsif @response == 'ssl_error'
|
46
50
|
raise ::Faraday::SSLError, 'Fake failure from Aranea'
|
47
51
|
else
|
48
|
-
::Faraday::Response.new(
|
52
|
+
::Faraday::Response.new(
|
53
|
+
status: @response.to_i,
|
54
|
+
body: @response_hash.to_json,
|
55
|
+
response_headers: @response_headers_hash
|
56
|
+
)
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'aranea/failure_repository'
|
2
2
|
require 'rack'
|
3
|
+
require 'json'
|
3
4
|
|
4
5
|
module Aranea
|
5
6
|
|
@@ -41,6 +42,12 @@ module Aranea
|
|
41
42
|
dependency = options.fetch('dependency') { raise FailureFailure, 'Please provide a dependency to simulate failing' }
|
42
43
|
minutes = options.fetch('minutes') { 5 }
|
43
44
|
failure = options.fetch('failure') { '500' }
|
45
|
+
response = options.fetch('response') { '{}' } # Expect URI encoded
|
46
|
+
headers = options.fetch('headers') { '{}' }
|
47
|
+
|
48
|
+
# These will emit a parsing error if the response/headers URI encoded string is malformed.
|
49
|
+
response_hash = JSON.parse(CGI.unescape(response)).to_hash
|
50
|
+
response_headers_hash = JSON.parse(CGI.unescape(headers)).to_hash
|
44
51
|
|
45
52
|
unless failure =~ /\A((4|5)\d\d|timeout|ssl_error)\Z/i
|
46
53
|
raise FailureFailure, "failure should be a 4xx or 5xx status code, timeout, or ssl_error; got #{failure}"
|
@@ -50,7 +57,13 @@ module Aranea
|
|
50
57
|
raise FailureFailure, "minutes should be an integer from #{ALLOWED_MINUTES.begin} to #{ALLOWED_MINUTES.end}, got #{minutes}"
|
51
58
|
end
|
52
59
|
|
53
|
-
Failure.create(
|
60
|
+
Failure.create(
|
61
|
+
pattern: dependency,
|
62
|
+
minutes: minutes.to_i,
|
63
|
+
failure: failure,
|
64
|
+
response_hash: response_hash,
|
65
|
+
response_headers_hash: response_headers_hash
|
66
|
+
)
|
54
67
|
|
55
68
|
result = "For the next #{minutes} minutes, all requests to urls containing '#{dependency}' will #{failure.downcase}"
|
56
69
|
|
data/lib/aranea/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aranea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Weiner
|
8
8
|
- Matthew Szenher
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
@@ -127,7 +127,7 @@ homepage: https://github.com/mdsol/aranea
|
|
127
127
|
licenses:
|
128
128
|
- MIT
|
129
129
|
metadata: {}
|
130
|
-
post_install_message:
|
130
|
+
post_install_message:
|
131
131
|
rdoc_options: []
|
132
132
|
require_paths:
|
133
133
|
- lib
|
@@ -142,9 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
142
142
|
- !ruby/object:Gem::Version
|
143
143
|
version: 1.3.5
|
144
144
|
requirements: []
|
145
|
-
|
146
|
-
|
147
|
-
signing_key:
|
145
|
+
rubygems_version: 3.2.16
|
146
|
+
signing_key:
|
148
147
|
specification_version: 4
|
149
148
|
summary: Middleware for fault tolerance testing
|
150
149
|
test_files: []
|