pact-provider-verifier 1.22.0 → 1.23.0
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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +2 -1
- data/lib/pact/provider_verifier/app.rb +19 -3
- data/lib/pact/provider_verifier/cli/verify.rb +1 -0
- data/lib/pact/provider_verifier/version.rb +1 -1
- data/lib/pact/wait_until_server_available.rb +24 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17d3324935c8a29bf63d0f6254f4a48c41eba99c9b0af7cdb9d1db0958bc169a
|
4
|
+
data.tar.gz: 9aa32e0862384b929374bfb5eb517cd3aac2285ca17991a6f37c2c612403d28f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdc51f38063e5d4dbbbb89733d5517e51dda440e02b705e03cef9a48b0a8d98d8085afa327791df19dbb445a713afffcb936503273930c6ceb27a75e1a84d572
|
7
|
+
data.tar.gz: a930b5f928f601faa705d2b72c8b6be7130b7030c10e5c348ba06cbc33118ee66995b2c28fa786ad0050b5b2774a2ca97b6f4d5bdf5bb06f4e56b9d24ff29bf8
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -55,7 +55,8 @@ Options:
|
|
55
55
|
-v, [--verbose=VERBOSE] # Verbose output
|
56
56
|
-f, [--format=FORMATTER] # RSpec formatter. Defaults to custom Pact formatter. Other options are json and RspecJunitFormatter (which outputs xml).
|
57
57
|
-o, [--out=FILE] # Write output to a file instead of $stdout.
|
58
|
-
|
58
|
+
[--wait=SECONDS] # The number of seconds to wait for the provider to become available before running the verification
|
59
|
+
# Default: 0
|
59
60
|
Verify pact(s) against a provider. Supports local and networked (http-based) files.
|
60
61
|
```
|
61
62
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'pact/wait_until_server_available'
|
1
2
|
require 'pact/provider_verifier/add_header_middlware'
|
2
3
|
require 'pact/provider_verifier/provider_states/add_provider_states_header'
|
3
4
|
require 'pact/provider_verifier/provider_states/remove_provider_states_header_middleware'
|
@@ -13,6 +14,7 @@ require 'json'
|
|
13
14
|
module Pact
|
14
15
|
module ProviderVerifier
|
15
16
|
class App
|
17
|
+
include Pact::WaitUntilServerAvailable
|
16
18
|
|
17
19
|
PROXY_PACT_HELPER = File.expand_path(File.join(File.dirname(__FILE__), "pact_helper.rb"))
|
18
20
|
|
@@ -29,7 +31,9 @@ module Pact
|
|
29
31
|
def call
|
30
32
|
setup
|
31
33
|
|
32
|
-
|
34
|
+
pact_urls = all_pact_urls
|
35
|
+
wait_until_provider_available
|
36
|
+
exit_statuses = pact_urls.collect do |pact_url|
|
33
37
|
verify_pact pact_url
|
34
38
|
end
|
35
39
|
|
@@ -197,8 +201,20 @@ module Pact
|
|
197
201
|
$stderr.puts "WARN: The --provider-states-url option is deprecated and the URL endpoint can be removed from the application"
|
198
202
|
end
|
199
203
|
end
|
204
|
+
|
205
|
+
def wait_until_provider_available
|
206
|
+
if options.wait && options.wait != 0
|
207
|
+
uri = URI(options.provider_base_url)
|
208
|
+
$stderr.puts "INFO: Waiting for up to #{options.wait} seconds for provider to become available at #{uri.host}:#{uri.port}..."
|
209
|
+
up = wait_until_server_available(uri.host, uri.port, options.wait)
|
210
|
+
if up
|
211
|
+
$stderr.puts "INFO: Provider available, proceeding with verifications"
|
212
|
+
else
|
213
|
+
$stderr.puts "INFO: Waiting for up to #{options.wait} seconds for provider to become available..."
|
214
|
+
$stderr.puts "WARN: Provider does not appear to be up on #{uri.host}:#{uri.port}... proceeding with verifications anyway"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
end
|
200
218
|
end
|
201
219
|
end
|
202
220
|
end
|
203
|
-
|
204
|
-
|
@@ -30,6 +30,7 @@ module Pact
|
|
30
30
|
method_option :out, aliases: "-o", banner: "FILE", desc: "Write output to a file instead of $stdout."
|
31
31
|
method_option :ignore_failures, type: :boolean, default: false, desc: "If specified, process will always exit with exit code 0", hide: true
|
32
32
|
method_option :pact_urls, aliases: "-u", hide: true, :required => false
|
33
|
+
method_option :wait, banner: "SECONDS", required: false, type: :numeric, desc: "The number of seconds to wait for the provider to become available before running the verification", default: 0
|
33
34
|
|
34
35
|
def verify(*pact_urls)
|
35
36
|
validate_verify
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'socket'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module Pact
|
5
|
+
module WaitUntilServerAvailable
|
6
|
+
def self.call(host, port, wait_time = 15)
|
7
|
+
end_time = Time.now + wait_time
|
8
|
+
tries = 0
|
9
|
+
begin
|
10
|
+
sleep 2 if tries != 0
|
11
|
+
Socket.tcp(host, port, connect_timeout: 3) {}
|
12
|
+
true
|
13
|
+
rescue => e
|
14
|
+
tries += 1
|
15
|
+
retry if Time.now < end_time
|
16
|
+
return false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def wait_until_server_available *args
|
21
|
+
WaitUntilServerAvailable.call(*args)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pact-provider-verifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Fellows
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2019-
|
12
|
+
date: 2019-04-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -305,6 +305,7 @@ files:
|
|
305
305
|
- lib/pact/provider_verifier/set_up_provider_state.rb
|
306
306
|
- lib/pact/provider_verifier/underscored_headers_monkeypatch.rb
|
307
307
|
- lib/pact/provider_verifier/version.rb
|
308
|
+
- lib/pact/wait_until_server_available.rb
|
308
309
|
homepage: https://github.com/pact-foundation/pact-provider-verifier
|
309
310
|
licenses:
|
310
311
|
- MIT
|
@@ -324,7 +325,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
324
325
|
- !ruby/object:Gem::Version
|
325
326
|
version: '0'
|
326
327
|
requirements: []
|
327
|
-
rubygems_version: 3.0.
|
328
|
+
rubygems_version: 3.0.3
|
328
329
|
signing_key:
|
329
330
|
specification_version: 4
|
330
331
|
summary: Provides a Pact verification service for use with Pact
|