Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure PACT_DESCRIPTION and PACT_PROVIDER_STATE env vars can be passed down to pact verify to allow selected interactions to be run #44

Closed
mefellows opened this issue Aug 12, 2017 · 11 comments
Assignees

Comments

@mefellows
Copy link
Member

This probably belongs in a child repo, I'm just not sure which one, so raising here!

I've removed the ruby specific output from the pact verify command (yay!)

What I would like to add is words to the effect of "to run just one interaction, please rerun the pact verify command with PACT_DESCRIPTION="..." and PACT_PROVIDER_STATE="..." environment variables set.

Can you please update to the ruby standalone version 1.4.0 and verify that the above environment variables are passed through? You should see the text Filtering interactions by...

See pact-foundation/pact-js#84

@mefellows
Copy link
Member Author

mefellows commented Aug 12, 2017

@bethesque from the provider side, how would we determine which provider description/state to tell the user? It's quite a blunt instrument at the moment as we get back only unstructured data from a single call to 'verify'.

I see a few options here:

  1. Have the verifier (and mock service?) send back structured data that the client libraries can use more intelligently (this might be required for other scenarios, such as message/other engine support)
  2. Have the verifier output a generic message as per your suggestion that doesn't
  3. Have a clear message in the unstructured data that can be filtered and used to make this decision
  4. Be quite generic and just tell the user they can do this sort of thing
  5. Something else I can't imagine at this moment in time

@mefellows
Copy link
Member Author

FWIW it's worth, it works for Pact Go:

PACT_DESCRIPTION="yeah" PACT_PROVIDER_STATE="blah" make pact
...
Reading pact at /Users/mfellows/go/src/github.com/pact-foundation/pact-go/examples/e2e/../pacts/billy-bobby.json
Filtering interactions by: {:description=>/yeah/, :provider_state=>/blah/}
No examples found.

0 interactions, 0 failures

@bethesque
Copy link
Member

For each failure in the pact, the ruby code outputs the command to run that individual interaction (you probably just gloss over that as it's not relevant for js/go).

Failed interactions:

bundle exec rake pact:verify:at[./spec/support/test_app_fail.json] PACT_DESCRIPTION="a test request" PACT_PROVIDER_STATE="the weather is cloudy" # A test request given the weather is cloudy
bundle exec rake pact:verify:at[./spec/support/test_app_fail.json] PACT_DESCRIPTION="another test request" PACT_PROVIDER_STATE="" # Another test request
bundle exec rake pact:verify:at[./spec/support/test_app_fail.json] PACT_DESCRIPTION="another test request" PACT_PROVIDER_STATE="a missing provider state" # Another test request given a missing provider state

If the calling code can also set an environment variable called PACT_INTERACTION_RERUN_COMMAND then I can use that to create language specific re-run commands. Otherwise, I can just print the description/state env vars for each interaction, with the text "Please re-run the verify command with the relevant env vars set to run an individual interaction"

@bethesque
Copy link
Member

The value of PACT_INTERACTION_RERUN_COMMAND for ruby is

bundle exec rake pact:verify:at[<PACT_URI>] PACT_DESCRIPTION=\"<PACT_DESCRIPTION>\" PACT_PROVIDER_STATE=\"<PACT_PROVIDER_STATE>\"

I substitute in the relevant description, state and URL.

@mefellows
Copy link
Member Author

Yep, but it doesn't do that anymore right?

PACT_INTERACTION_RERUN_COMMAND seems like a good suggestion. Is that already available?

@bethesque
Copy link
Member

I've already done it.

@mefellows
Copy link
Member Author

I think that was a race condition - I can do that :)

@mefellows
Copy link
Member Author

I've updated the code base to set PACT_INTERACTION_RERUN_COMMAND when running the verification process. Let us know when it's in the upstream package. I'm running it locally against 1.4.2 and it's still wanting to do Ruby stuff.

@bethesque
Copy link
Member

Bother, I thought I had already. Will go and check my releases.

@bethesque
Copy link
Member

bethesque commented Aug 15, 2017

It's working for me with 1.4.2. If I run

PACT_INTERACTION_RERUN_COMMAND="foo" ./pact-provider-verifier -a "1.0.100" --provider-base-url http://localhost:4567 --pact-urls fail.json --provider_states_setup_url http://localhost:4567/provider-state -v

I get:

3 interactions, 2 failures

Failed interactions:

foo # Greeting fail
foo # Provider state success

@bethesque bethesque assigned mefellows and unassigned bethesque Aug 15, 2017
@mefellows
Copy link
Member Author

I worked out why - we use the --json flag and it doesn't seem to come through in there (and for good reason).

I'll update docs and have the code pass it through anyway for future safe-keepings.

mefellows added a commit that referenced this issue May 20, 2018
- Allow PACT_DISABLE_TOOL_VALIDITY_CHECK env var to disable tool check
- Document re-running specific provider tests

Fixes #44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants