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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b5ec2788f09896553d3c835fdce3a287522742bcff5b3a292c4516f10d512d0
4
- data.tar.gz: 31445bf106e251363fae9573017fa2618601932a2a69a45665775ed8870e9b6d
3
+ metadata.gz: 17d3324935c8a29bf63d0f6254f4a48c41eba99c9b0af7cdb9d1db0958bc169a
4
+ data.tar.gz: 9aa32e0862384b929374bfb5eb517cd3aac2285ca17991a6f37c2c612403d28f
5
5
  SHA512:
6
- metadata.gz: fc2ed1561f3cda81af513e6c48e60b77a556600190feed59ddb1111c23b72ae51499051143584751a7f96c44974f187c855b4d6f9c1bcb273ace33b8898ee6d0
7
- data.tar.gz: 5cc2a20dd2a4e60b749ebcd26567211d629bbaa900c98b91f7cef0e090c28dc64a5e29ea5f0ac49345308a7798660a763fba0287929db210f17d4d831216585d
6
+ metadata.gz: fdc51f38063e5d4dbbbb89733d5517e51dda440e02b705e03cef9a48b0a8d98d8085afa327791df19dbb445a713afffcb936503273930c6ceb27a75e1a84d572
7
+ data.tar.gz: a930b5f928f601faa705d2b72c8b6be7130b7030c10e5c348ba06cbc33118ee66995b2c28fa786ad0050b5b2774a2ca97b6f4d5bdf5bb06f4e56b9d24ff29bf8
@@ -1,3 +1,12 @@
1
+ <a name="v1.23.0-1"></a>
2
+ ### v1.23.0-1 (2019-04-28)
3
+
4
+
5
+ #### Features
6
+
7
+ * allow a wait time to be specified to allow the provider to become available ([cec8d56](/../../commit/cec8d56))
8
+
9
+
1
10
  <a name="v1.22.0-1"></a>
2
11
  ### v1.22.0-1 (2019-02-21)
3
12
 
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
- exit_statuses = all_pact_urls.collect do |pact_url|
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
@@ -1,5 +1,5 @@
1
1
  module Pact
2
2
  module ProviderVerifier
3
- VERSION = "1.22.0"
3
+ VERSION = "1.23.0"
4
4
  end
5
5
  end
@@ -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.22.0
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-03-04 00:00:00.000000000 Z
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.2
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