pact-foundation/pact-provider-verifier

Publish Results And Tag Provider

sthomas1978 opened this issue · 11 comments

Hi

This is more of a workflow process issue in our CI pipeline and just for me to gain an understanding of how the process works.

When I execute pact-provider-verifier you can specify what consumer tag you would like the provider to be tested against. Is there a way when publishing the results to tag the provider as well?

The above question then leads into my next question

When I want to deploy a either a consumer or a provider I want to be able to use the pactbroker can-i-deploy and just specify a tag and the pacticipant.

This will then return a matrix containing pacticipant is either a provider or a consumer with its counterpart pactificipant for that tag

For example we have

Application A --> Application B --> Application C

CONSUMER   | C.VERSION          | PROVIDER | P.VERSION   | SUCCESS?
-----------|--------------------|----------|-------------|---------
A          | 1                  | B        | 5           | true
B          | 5                  | C        | 6           | true

If perform a pact-broker can-deploy on Application B using tag master, it will bring up the matrix and show it as a consumer and a provider, this is compared to the its counterpart for that tag and if its a success.

Is there a way when publishing the results to tag the provider as well?

It depends which implementation you're using - if there isn't, it needs to be added. Which one are you using?

Hi Beth

At the moment, I am using the pact-broker-client.

  1. Firstly i am using the API to get all latest pacts against a provider for a specified tag
    pacts/provider/PROVIDER/latest/TAG
  2. I iterate over the returned results and call pact-provider-verifier for each apact, which publishes the results and sets the provider version.
  3. I then use pact-broker create-version-tag to tag the provider with my branch

I suppose really I want to tag either a consumer or a provider during its build phase therefore we don't need to have tag functionality in the pact-provider-verifier.

What would be good is if steps 1 & 2 could be combined into the pact-provider-verifier?

When I want to deploy a either a consumer or a provider I want to be able to use the pactbroker can-i-deploy and just specify a tag and the pacticipant.

Think I have already figure out you can use

pact-broker can-i-deploy --broker-base-url <BROKERURL> --pacticipant "<PROVIDER|CONSUMER>" --latest <TAG> --to <DESTINATION> -v

which gives the matrix of what worked.

Can I ask why you're not already using the pact-provider-verifier? You can give it the broker base URL and the list of consumer tags. I think the only thing it's missing is the automatic tagging of the provider version when it publishes the results, but I can expose that easily.

Hi Beth

Apologies I am using the pact-provider-verifier as detailed in step 2

When I said pact-broker-client, I meant the tooling provided generally.

Steps 1 and 2 are already combined in the pact provider verifier. This has only been recently added, so perhaps it was not there when you first looked.

Usage:
  pact-provider-verifier PACT_URL ... -h, --provider-base-url=PROVIDER_BASE_URL

Options:
...
  -n, [--broker-username=BROKER_USERNAME]
        # Pact Broker basic auth username
  -p, [--broker-password=BROKER_PASSWORD]
        # Pact Broker basic auth password
      [--provider=PROVIDER]
      [--consumer-version-tag=TAG]
        # Retrieve the latest pacts with this consumer version tag.
        Used in conjuction with --provider. May be specified multiple times.

Hi Beth

Ahhh, yes I did not see this, this has helped alot. I am now using the following to replace Steps 1 and Steps 2

pact-provider-verifier --pact-broker-base-url http://localhost:1234 --provider-base-url http://localhost:1111 --provider-states-setup-url http://localhost:1111/provider-states --consumer-version-tag <REPO BRANCH> --provider "<PROVIDER NAME>"

Although there seems to be an issue whereby if my branchname has a "/" in it i get the following the error, for example

pact-provider-verifier --pact-broker-base-url http://localhost:1234 --provider-base-url http://localhost:1111 --provider-states-setup-url http://localhost:1111/provider-states --consumer-version-tag feature/pact-integration-test --provider "<PROVIDER NAME>"

error message:

INFO: Fetching pacts for <PROVIDER NAME> from http://localhost:1234 for tags: latest feature/pact-integration-test C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:84:in pact_urls': undefined method collect' for nil:NilClass (NoMethodError) from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:58:in block in tagged_pacts_for_provider' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:56:in collect' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:56:in tagged_pacts_for_provider' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:40:in call' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker/fetch_pacts.rb:33:in call' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-1.36.0/lib/pact/pact_broker.rb:12:in fetch_pact_uris' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:38:in non_pending_pact_uris' from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:31:in pacts_urls_from_broker'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:21:in call'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/aggregate_pact_configs.rb:9:in call'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/app.rb:168:in all_pact_urls'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/app.rb:32:in call'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/app.rb:26:in call'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/cli/verify.rb:36:in verify'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/command.rb:27:in run'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in invoke_command'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor.rb:387:in dispatch'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.0/lib/thor/base.rb:466:in start'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.20.0/lib/pact/provider_verifier/cli/custom_thor.rb:17:in start'
from C:/Program Files (x86)/pact-1.61.0-win32/pact/lib/app/pact-provider-verifier.rb:33:in

'`

Can you raise a specific issue for that in the pact broker client repository please? I'll have a look at it as soon as I can.

Before you do, try wrapping the tag in quotes and see if that helps.

Oh, and please run it with - v and include the debug logs.

Hi Beth.

I have raised the above under pact-foundation/pact_broker-client#44.

Thanks

Are there any open issues here now? I'm closing this, but feel free to open if I've missed something.