mboudreau
2017-05-18 14:23
has joined #general

jose
2017-05-18 16:28
has joined #general

uglyog
2017-05-18 22:36
has joined #general

mboudreau
2017-05-22 02:43
I'm sick today, so I'm spending the time looking at website stuff :slightly_smiling_face:

uglyog
2017-06-01 06:05
who can answer Pact .Net questions?


mboudreau
2017-06-01 08:23
Not me :/

jose
2017-06-01 08:38
Certainly not me

bethskurrie
2018-03-24 03:32
has joined #general

andrewspinks
2018-03-24 09:14
has joined #general

neil
2018-03-24 09:22
has joined #general

matt.fellows
2018-03-24 11:15
has joined #general

matt.fellows
2018-03-24 11:15
:wave:

marko
2018-03-25 21:23
has joined #general

matt.fellows
2018-03-25 21:50
Just confirming - are we thinking of opening this up to the public or is it just for maintainers?

bethskurrie
2018-03-25 21:51
I assumed public

matt.fellows
2018-03-25 21:51
ok cool

matt.fellows
2018-03-25 21:51
I can create a Heroku setup page to make it easy for people to join

mboudreau
2018-03-25 21:54
I was going to do it, but go ahead if you're keen

matt.fellows
2018-03-25 21:56
keen is a strong word

matt.fellows
2018-03-25 21:56
if you have time, go for it :slightly_smiling_face:

mboudreau
2018-03-25 22:29
Will do :)

andrewcfitzgerald
2018-03-26 02:44
has joined #general

andrewcfitzgerald
2018-03-26 02:45
:wave:

matt.fellows
2018-03-26 02:51
:wave:

slack1
2018-03-26 04:08
has joined #general

bethskurrie
2018-03-26 06:08
:wave:

dennis
2018-03-26 08:41
has joined #general

abubics
2018-03-27 00:55
has joined #general

abubics
2018-03-27 00:56
hey guys, what?s going on

bethskurrie
2018-03-27 02:13
There was no party til you arrived @abubics

andrewcfitzgerald
2018-03-27 03:28
`+:party_parrot:`

bethskurrie
2018-03-27 03:29
Oh no! No party parrot!

bethskurrie
2018-03-27 03:29
Maybe you have to pay Slack for the party parrot.

andrewcfitzgerald
2018-03-27 03:31
ha, new slack pricing model: all features are free, emojis and gifs unlocked by microtransactions

bethskurrie
2018-03-27 03:56
I know a social media platform that has a revenue model pretty much exactly that!

abubics
2018-03-27 05:06
:party_parrot::party_parrot::party_parrot: :party_parrot:

bethskurrie
2018-03-27 05:29
Woot!

bethskurrie
2018-03-27 05:29
Thanks @abubics!


matthew.balvanz
2018-03-27 14:06
has joined #general

ragarwal
2018-03-28 00:22
has joined #general

cfmack
2018-03-28 13:12
has joined #general

abubics
2018-03-29 03:57
is there a recommended `pact-jvm-consumer` version for use with Kotlin?

abubics
2018-03-29 03:57
last time I was in Kotlin, I just used groovy :s


abubics
2018-03-29 05:03
turns out, it?s still very difficult (possibly impossible) to get Kotlin to play with Groovy . . . so I guess I?ll have to go with one of the Java ones :cry:

mboudreau
2018-03-29 05:17
I figure we'd need a kotlin specific build based on the JVM one

abubics
2018-03-29 05:27
yeah, chuck it on the list :wink:

mboudreau
2018-03-29 06:50
I'll get it done after the website/SaaS app :stuck_out_tongue:

cfmack
2018-03-29 14:43
Has anyone got the Provider Webhooks in the Pact Broker calling Jenkins 2.X with CSRF enabled? It looks like Jenkins requires two API calls (one to get a valid CSRF token)


bethskurrie
2018-03-29 19:44
@cfmack Ugh! We've had this problem before. My suggestion was to run a little intermediate rack app that did the CSRF call. I could create a little prototype if that would help, but you might prefer to do something in a language you're comfortable with.

bethskurrie
2018-03-29 22:14
added an integration to this channel: https://pact-foundation.slack.com/services/B9YEJPQQK

bethskurrie
2018-04-05 04:28
removed an integration from this channel: https://pact-foundation.slack.com/services/B9YEJPQQK

bethskurrie
2018-04-05 10:07
@cfmack does this two stage call follow a standard process that would be applicable to other http servers, or is it a Jenkins Special? As in, is it a feature that would be popular if we ended up implementing support for it, for other services?

david.j.smith
2018-04-06 08:21
has joined #general

david.j.smith
2018-04-06 08:22
:wave:

bethskurrie
2018-04-06 08:23
Welcome Dave!

david.j.smith
2018-04-06 08:24
Thanks Beth :slightly_smiling_face:

david.j.smith
2018-04-06 08:24
I noticed you've been chatting to our government!

bethskurrie
2018-04-06 08:24
Indeed.

bethskurrie
2018-04-06 08:25
I liked them more than our own :-|

david.j.smith
2018-04-06 08:25
The civil servants are a good bunch - just the folks in charge of them that need a bit of a kicking :wink: One of my contributors works there atm.

bethskurrie
2018-04-06 08:27
They seemed like they'd had a good think about things before we even talked. It was a good chat.

abubics
2018-04-13 03:22
I?m hitting a related (but different) issue to this: https://github.com/DiUS/pact-jvm/issues/213 Is there a fix (or recommended approach), or should I just use a workaround for now? and/or an issue already, and should I raise one, if not? :stuck_out_tongue: The issue is I?m not specifying any headers, but this is coming up by default in the response: ``` "headers": { "Content-Type": "application/json; charset=UTF-8" }, ``` and then failing provider pact verify, because there isn?t a space in `"application/json; charset=UTF-8"`

bethskurrie
2018-04-13 04:06
Blame @uglyog for putting in a default header :stuck_out_tongue:

uglyog
2018-04-13 04:08
The space should not make it fail. That's a defect.

bethskurrie
2018-04-13 04:10
I don't understand why there is a mismatch on a header you didn't specify?

abubics
2018-04-13 04:19
all of the above :innocent:

abubics
2018-04-13 07:44
I?m getting ``` "matchingRules": { "$.body.accounts": { "match": "type", "min": 0 }, ``` in my pact file, and ``` "accounts": [ ] ``` showing in the broker, but my test looks like ``` body(newJsonBody { container -> container.eachLike("accounts", 1) { ... ``` Should I raise an issue? I expected `eachLike(1)` to make 1 occurrence :thinking_face:

abubics
2018-04-13 07:44
(this is with the java8 consumer)

abubics
2018-04-13 07:48
using `minArrayLike` instead fixes it, but then what is the point of `eachLike`?

bethskurrie
2018-04-13 08:15
Or of lfe in general.

cfmack
2018-04-13 16:49
Apologies. Life has been crazy lately. In my experience with Travis and AppVeyor, I do not think they have this same request or quiet frankly support CRSF. Our internal walk around, was to disable CRSF. While that's imperfect, it works for our internal needs

bethskurrie
2018-04-17 09:58
Sounds like a good work around to me :wink:

bethskurrie
2018-05-04 06:25
Did you work out the problem @abubics?

abubics
2018-05-04 08:58
nope, just workarounds

abubics
2018-05-04 08:59
I provide an explicit `Content-Type` in the Pact description (so it?s brittle)

abubics
2018-05-04 08:59
we are unblocked, at least :slightly_smiling_face:

bethskurrie
2018-05-04 09:07
Why is it bad to set the content type?

abubics
2018-05-04 09:09
because it was failing on a whitespace issue, and it is asserting on a field I didn?t even set

abubics
2018-05-04 09:10
no wait

abubics
2018-05-04 09:10
that was the Content-Type

abubics
2018-05-04 09:10
the `eachLike` issue was always a workaround, and I didn?t see why `minArrayLike` did what I wanted, while `eachLike` didn?t

abubics
2018-05-04 09:11
is there meant to be a difference? what is the point, if not?

bethskurrie
2018-05-04 09:11
Hm. Bug Ron about that.

abubics
2018-05-04 09:11
hey, you brought it up :stuck_out_tongue:

abubics
2018-05-04 09:11
I already forgot about it xD hence the mild confusion

abubics
2018-05-04 09:12
which (of the 2 issues) were you asking about? :innocent:

bethskurrie
2018-05-04 09:13
I can't remember. Just in general. Because the last time we chatted, we ended up questioning the reason for living.

bethskurrie
2018-05-04 09:13
Just needed to make sure you hadn't topped yourself because of Ron.

abubics
2018-05-04 09:13
lololol

abubics
2018-05-04 09:14
yeah, I?m unblocked :stuck_out_tongue: no thanks to @uglyog :troll:

bethskurrie
2018-05-04 09:14
What a slacker.

bethskurrie
2018-05-04 09:14
<hides behind laptop>

matt.fellows
2018-05-07 09:04
New member join url: http://slack.pact.io

matt.fellows
2018-05-07 09:04
@matt.fellows pinned a message to this channel.

matthew
2018-05-07 14:38
has joined #general

thomas.heilbronner
2018-05-07 20:50
has joined #general

sgleadow
2018-05-08 00:27
has joined #general

philip.sturman
2018-05-08 06:12
has joined #general

david
2018-05-08 07:45
has joined #general

david
2018-05-08 07:47
hello :wave:

dominic.jones
2018-05-08 08:33
has joined #general

mark.bridgett
2018-05-08 08:40
has joined #general

mark.bridgett
2018-05-08 08:40
Greetings

david.j.smith
2018-05-08 08:42
Hello :wave:

mboudreau
2018-05-08 08:50
:wave:

abubics
2018-05-08 23:59
howdy howdy howdy :wave:

bethskurrie
2018-05-09 03:35
Hi all. Welcome.

sgleadow
2018-05-09 05:07
Pacticipants unite!

sgleadow
2018-05-09 05:10
Can I start asking questions now? Is this instead of Gitter? (I'm not on Pact gitter) We're looking to set up Pact between some mobile apps (Swift/Kotlin) and an aggregation API (Node). My question is about setting up provider state. Our API is stateless, so it looks like we're not so much injecting eg. data into a DB as setting up stubs of downstream calls that reflect the provider state. How do people go about doing that? Spin up a separate stub server where you set up the state, and run your API in a configuration where it points there rather than to real dependencies?

abubics
2018-05-09 05:17
There are several approaches, and it depends how cleanly layered your architecture is

abubics
2018-05-09 05:19
The leanest just gives you confidence that your response entities are the right shape: > just stub the response objects at the endpoint layer

abubics
2018-05-09 05:19
The most integrated means you go through all layers (and potentially hit other complications on the way): > inject data in the DB, or responses at the DB client

abubics
2018-05-09 05:20
and a heap of stuff in-between

abubics
2018-05-09 05:21
As for Pact?s intended philosophical usage . . . I?ll leave that answer to @bethskurrie, @uglyog, and @matt.fellows :slightly_smiling_face:

abubics
2018-05-09 05:21
but if you?re treating Pact as an asynchronous pair of network interface unit tests, the leanest approach gives you value

abubics
2018-05-09 05:23
if you phrase the state and requests as ?given no/some/many? and upon receiving ?a valid/invalid request for blah?, there?s no implied logic to stub, just happy & sad response shapes

uglyog
2018-05-09 05:26
Yes, @sgleadow, it's stub and mock servers all the way down.

uglyog
2018-05-09 05:26
Maybe a turtle or two

uglyog
2018-05-09 05:28
Not sure how you would tie the state to the stub with node, but @matt.fellows would prob be able to help there

bethskurrie
2018-05-09 05:48
One way to do it is to create your own mock implementation class that to can set up response objects on, no "mocking library" necessary. Ideally, you could reuse something in that test that would be an input with your downstream contract tests.

bethskurrie
2018-05-09 05:57
For example, you could stub your `AnimalService#get_alligator(...)` to return `Alligator.new(name: Mary)`, and then use that same object in the pact test for `AnimalService#get_alligator`. eg `given... when... will return... expect(AlligatorService.get_alligator(Mary)).to eq Alligator.new(name: Mary)`

bethskurrie
2018-05-09 05:57
So you can use a shared object as a "contract" too.

bethskurrie
2018-05-09 06:01
Or, you could use the pact that you generated for the AnimalService in your unit tests, to create a stub server using the pact-stub-server. You want to make your request expectations quite relaxed if you do this though, because otherwise it will be quite brittle. Normally, when you use pact in a unit test, you can be quite strict, as you're in full control of the outgoing request.

bethskurrie
2018-05-09 06:12
I've just announced on the gitter channel that it will be closing down, so hopefully we'll have some new pacters soon. Let's try and keep conversations in threads, so it's easier to see which questions have been answered, and which haven't. There are a few really good questions on gitter that didn't get answered recently because of all the noise.

vinod.baradwaj
2018-05-09 06:12
has joined #general

bethskurrie
2018-05-09 06:12
Death to gitter!

bethskurrie
2018-05-09 06:12
Welcome @vinod.baradwaj

vinod.baradwaj
2018-05-09 06:12
thank you :slightly_smiling_face:

ashish.dubey91
2018-05-09 06:13
has joined #general

bethskurrie
2018-05-09 06:14
:wave:

rgshah781988
2018-05-09 06:14
has joined #general

rgshah781988
2018-05-09 06:15
I am facing issue with matchers.

rgshah781988
2018-05-09 06:15
Can any buddy help me ?

bethskurrie
2018-05-09 06:16
shoot

vinod.baradwaj
2018-05-09 06:16
@bethskurrie i tried using hash arguments in mock setup for query parameters and it worked fine... will i be able to use the same approach for an endpoint like this, `/api/tagCollections/{tagCollectionId}/tags/{tagId}` where both tagCollectionId and tagId are dynamic ones

bethskurrie
2018-05-09 06:16
Firstly, which language?

bethskurrie
2018-05-09 06:16
Secondly, I'll move this to a thread. It makes the conversations cleaner.

bethskurrie
2018-05-09 06:16
Ok, @vinod.baradwaj let's continue here.

vinod.baradwaj
2018-05-09 06:17
yeah sure

rgshah781988
2018-05-09 06:17
js

bethskurrie
2018-05-09 06:17
Which language?

vinod.baradwaj
2018-05-09 06:17
JS

bethskurrie
2018-05-09 06:17
Ok, I can probably help you.

bethskurrie
2018-05-09 06:18
You can create a matcher using a regular expression but the nice URL format using {} isn't supported. I'd like it to be. Let's put it in v4.

bethskurrie
2018-05-09 06:18
Or... you could create a JS wrapper method that would turn your {} path into a regexp.

rgshah781988
2018-05-09 06:19
Do we need to create a matchers class?

priyank.shah217
2018-05-09 06:19
has joined #general

bethskurrie
2018-05-09 06:20
@uglyog in the Ruby impl, I made a little util that would allow you to construct a Pact Response body with all the matchers, and then tell it to give you the JSON example for it. I then used that body in the pact test, but also used it in a plain stub for other tests (eg. verifications of upstream pacts). Is this something that could be done with the JVM?

bethskurrie
2018-05-09 06:20
It would be the regular expression class

bethskurrie
2018-05-09 06:20
It's called a `term`

rgshah781988
2018-05-09 06:20
ok

vinod.baradwaj
2018-05-09 06:21
we need to create a method which will use regex to create path instead of these {} args @rgshah781988

bethskurrie
2018-05-09 06:21
When you use a term, you give it a regular expression, and an example.

abubics
2018-05-09 06:21
@abubics pinned a message to this channel.

bethskurrie
2018-05-09 06:22
You could make a `Pact.path("/foo/{id}", {id: 2})` that would build a `Pact.term` with the right regular expression and the expanded path as the example.

bethskurrie
2018-05-09 06:22
Does that make sense?

vinod.baradwaj
2018-05-09 06:27
yeah understood... in case of two arguments(`/foo/{fooId}/action/{actionId}`), will the same approach work ?

vinod.baradwaj
2018-05-09 06:27
would i be able to create Pact.term for this ?

rgshah781988
2018-05-09 06:34
@bethskurrie would i be able to create Pact.term for this ?

sgleadow
2018-05-09 06:50
I think this is a difference in the ruby vs node approaches. The node approach, it's not in the same process, so I can't set mocks in code that get called at runtime (at least not out of the box). I think I'll start with some stubs right at the top, and see if actually running downstream stubs through the entire flow makes sense. (although I'm not 100% sure how I'd set this state in a stateless API)

rgshah781988
2018-05-09 06:51
Response body - i have use :

2018-05-09 06:51
A file was commented on

rgshah781988
2018-05-09 06:53
I am trying same think with pactjs but I am not getting success.

bethskurrie
2018-05-09 07:06
@rgshah781988 ask in the js channel, and tag @matt.fellows or @mboudreau

rgshah781988
2018-05-09 07:12
ok

bethskurrie
2018-05-09 07:13
@sgleadow the provider state set up URL could be on the downstream http mock

bethskurrie
2018-05-09 07:13
I'm writing up a list of options with their various pros and cons. Will post here when finished.

rgshah781988
2018-05-09 07:15
Please share channel link

bethskurrie
2018-05-09 07:41
Absolutely

bethskurrie
2018-05-09 07:41
It's still just a regular expression.

bethskurrie
2018-05-09 07:41
And an example.

bethskurrie
2018-05-09 07:49
If you called something like `Pact.path("/api/tagCollections/{tagCollectionId}/tags/{tagId}", {tagCollectionId: 1, tagId: 2})` it would create a Pact.term with a pattern of `\/api\/tagCollections\/[^/]+\/tags/[^/]+\/` as the regular expression (or similar, don't quote me on the backslashes) and `/api/tagCollections/1/tags/1` as the example.

vinod.baradwaj
2018-05-09 08:27
okay got it.. thanks @bethskurrie :slightly_smiling_face:

rgshah781988
2018-05-09 08:53
:+1:


bethskurrie
2018-05-09 09:21
Here's a start.

bethskurrie
2018-05-09 09:28
@uglyog would you like to add any options or content to the gist? I'll put it in the docs when it's had some more eyes on it.

uglyog
2018-05-09 09:29
I'll have a look tomorrow

bethskurrie
2018-05-09 09:29
ta

uglyog
2018-05-09 09:30
I guess, there are model classes that underpin the pact format

vinod.baradwaj
2018-05-09 13:09
i am not able to start pact-stub-server, tried with the example pact file(https://github.com/pact-foundation/pact-stub-server) i am getting the following error ``` pact-stub-server git:(master) ? docker run -t -p 8080:8080 -v "$(pwd)/pacts/:/app/pacts" pactfoundation/pact-stub-server -p 8080 -d pacts 13:08:16 [WARN] No metadata found in pact file "\"pacts/billy-bobby.json\"", assuming V2 specification 13:08:16 [ERROR] There were errors loading the pact files. 13:08:16 [ERROR] - Failed to load pact from 'pacts' - Failed to parse Pact JSON - expected value at line 1 column 1 ```

rgshah781988
2018-05-09 13:39
How can I get dynamic response from pact files ? I tried using matchers such as like,eachlike I am working on API which has POST call with different payload values. (edited) According response changes.

david.j.smith
2018-05-09 16:18
@rgshah781988 You can't :slightly_smiling_face: Pact testing is done in a *known* state, if you want a different response, you need to define a different request. Essentially you're saying "There are different responses I can get for different requests" but they're all 1 to 1. A common thing to do in unit testing with mocks is to make the same request to, say, `/foo` in every test request but get the mocking framework to supply a different response each time with a before and/or after statement in your test framework. Pact does not do that.

david.j.smith
2018-05-09 16:22
@vinod.baradwaj It's saying that is can't parse your Pact contract files, which it has assumed to be V2 formatted, so the first question is: Do you know you have V2 Pact files? Also, do both of those folders contain Pact files? Are they all the same format? You could try adding the metadata to the files (as a test) to see what happens, I believe it looks like: ``` ...rest of Pact file... "metadata": { "pact-specification": { "version": "2.0.0" } } } ```

vinod.baradwaj
2018-05-09 16:26
@david.j.smith i am trying with the example pact file which is in that repo, the pact file has the metadata which you have given in it.. it was working fine before but now i am not able to start the server with the same pact file.

david.j.smith
2018-05-09 16:41
@vinod.baradwaj It's hard to tell from here but it clear isn't happy with something in that directory. Do you have files in there that aren't Pact files? Can you refresh that file to make sure it hasn't be accidentally changed? Failing that you could send it over for us to look at but if it was working and now it isn't... then something has changed. :slightly_smiling_face:

matt.fellows
2018-05-09 20:44
@rgshah781988 can you please explain what you're trying to do with more details?

brentbarker9
2018-05-09 20:55
has joined #general

uglyog
2018-05-09 21:55
@vinod.baradwaj looks like it can't parse your pact file. You can enable debug logging with `-l debug`

mboudreau
2018-05-09 22:26
please don't repost in several channels

mboudreau
2018-05-09 22:26
use the threads, dave

shekharsp27
2018-05-10 05:27
has joined #general

rgshah781988
2018-05-10 05:38
ok sure

rgshah781988
2018-05-10 05:40
Thanks @david.j.smith

rgshah781988
2018-05-10 05:41
But I have one API call with different payload and response should be dependent on payload. So, what to do? It seems that PACTs doesn't have such feature.

rgshah781988
2018-05-10 05:43
@david.j.smith @vinod.baradwaj But same pact file is working in my computer.

rgshah781988
2018-05-10 05:45
I have one API call with different payload and I am expecting different response as per payload values. Eg : API call is url/assets - POST call. I am providing payload as JSON - {"name":"ravi"} , expected response is name as ravi. Now,API call is url/assets - POST call. I am providing payload as JSON - {"name":"shah"} , expected response is name as shah.

matt.fellows
2018-05-10 05:50
Hopefully that?s an example just to illustrate the point (because you wouldn?t use pact just to test different data values)

matt.fellows
2018-05-10 05:50
BUT? that is entirely possible to do with Pact. What?s the issue you?re running into?

mboudreau
2018-05-10 05:50
@rgshah781988 I've responded to you in a thread in pact-js

rgshah781988
2018-05-10 05:52
I am mocking with pact file via pact stub server. And I need to use pact file.

rgshah781988
2018-05-10 05:52
For test , I can use this as per example . I had posted.

rgshah781988
2018-05-10 05:52
But I need to mock into pact stub server and need to use it.

rgshah781988
2018-05-10 05:53
@vinod.baradwaj Please look into respond also.

rgshah781988
2018-05-10 05:54
pact do same as per my example when I test with consumer.spec.js but I need to mock pact files in pact stub server

matt.fellows
2018-05-10 05:55
ok, so this is the _stubs_, and not the tests themselves right?

rgshah781988
2018-05-10 05:58
Yes,We can write a test for different payload and we will get different responses and according pact interactions will be created

matt.fellows
2018-05-10 05:58
ok cool

matt.fellows
2018-05-10 05:58
so yes, the stub server is not able to do what you?re asking unfortunately

rgshah781988
2018-05-10 05:59
how to do that? I am working on mocking with pact files

matt.fellows
2018-05-10 05:59
See the note at https://docs.pact.io/getting-started/local-api-stubs. We don?t support matching on predicates etc., unless I?m mistaken @uglyog @bethskurrie?

matt.fellows
2018-05-10 05:59
Perhaps there?s a way with headers or something. Typically we use other tools for that job

rgshah781988
2018-05-10 05:59
Yes sure , I am look into link

matt.fellows
2018-05-10 05:59
:thumbsup:

matt.fellows
2018-05-10 06:01
brb

rgshah781988
2018-05-10 06:01
Can you suggest some tool to do such job. I am working on mocking of my each micor services in pact-server at different port.

uglyog
2018-05-10 06:03
The stub server returns responses based on the method + path + query parameters. You can raise an issue to get it to have an option to include the request body as well

rgshah781988
2018-05-10 06:09
Where should I raised issue? @uglyog Please help me




uglyog
2018-05-10 06:21
I'll sort it out for you this weekend, and upgrade it to V3 spec as well

rgshah781988
2018-05-10 06:23
thanks

matt.fellows
2018-05-10 06:28
:thumbsup:

vinod.baradwaj
2018-05-10 06:56
@matt.fellows is there any examples in JS to implement `term` in path ? the endpoint i am trying to mock is like `/api/tagCollections/{tagCollectionId}/tags/{tagId}` which will have dynamic values for both tagCollectionId and tagId.

matt.fellows
2018-05-10 06:58
Maybe not examples, but it?s doable - are you having issues?

bethskurrie
2018-05-10 07:02
It's just the same as a term for any other part of the request.

bethskurrie
2018-05-10 07:02
path : Pact.term(...)

vinod.baradwaj
2018-05-10 07:03
term will expect a matcher and generate right ?

matt.fellows
2018-05-10 07:12
yep

david.j.smith
2018-05-10 08:47
@rgshah781988, I'm 99% sure the Scala stubber does do that. However it's probably more hassle than you'd want to get into.

david.j.smith
2018-05-10 08:49
@mboudreau I'll try but I don't like them very much so often forget :slightly_smiling_face: (Hard to scan for relevant information since it's hidden under threads)

mboudreau
2018-05-10 08:55
the point is to keep details out of the main channels so it's not cluttered

omar
2018-05-10 19:49
has joined #general

kateleighrose
2018-05-10 22:09
has joined #general

rgshah781988
2018-05-11 05:04
I need to create pact file which contain interactions eg : id:1234 is randomly created by other API. Can I provide or pass dynamic number in interactions?

uglyog
2018-05-11 05:08
@rgshah781988 what are you using to create the pact file?

rgshah781988
2018-05-11 05:09
I used Pactjs

uglyog
2018-05-11 05:10
Does it need to be dynamic?

uglyog
2018-05-11 05:10
As long as it is correctly formatted, the actual value should not matter

uglyog
2018-05-11 05:11
You can try use a regex matcher without a example, it might generate a random one

rgshah781988
2018-05-11 05:23
@uglyog: Actually , id:1234 is created by other API. And same ID , i need to used in interactions for next API call

matt.fellows
2018-05-11 06:17
That sounds like a functional test - you don?t want to use pact for functional tests (https://docs.pact.io/best-practices/consumer/contract-tests-vs-functional-tests)

kateleighrose
2018-05-11 14:47
hi, I have kind of a weird use case that I'm hoping to use pact-python for but can't figure out. I have a service in python that calls out to a lambda function via boto3, that lambda is a java app I also have ownership of. I want to write a contract test for the consumer (python service) and provider (java app)

kateleighrose
2018-05-11 14:48
but since the consumer is calling boto and not making a standard HTTP request to an api, I can't use the `with_request` param... unless I'm missing something

matt.fellows
2018-05-11 23:58
interesting

matt.fellows
2018-05-12 00:00
how does the service call lambda via boto - triggering an event or something? Boto is an interface to the AWS SDK, so it must just be triggering the lambda function and therefore it would be an asynchronous interaction

matt.fellows
2018-05-12 00:00
Python doesn?t yet support message pact, but we?ve just introduced it to Pact JS and Pact Go with some success, and will hopefully be rolling it out to Python et. al over the coming months

matt.fellows
2018-05-12 00:01
if you wanted to help contribute, @matthew.balvanz would be the guy to chat with

kateleighrose
2018-05-13 01:31
message sounds like what I need, yeah. good to know it's in the plans

uglyog
2018-05-13 06:41
@rgshah781988 `pactfoundation/pact-stub-server:v0.0.8` has been released with your fix and support for V3 spec pact files

ragarwal
2018-05-14 00:45
Hello, I am using pact-js and jest to write consumer side pact tests. As per https://github.com/pact-foundation/pact-js/blob/master/examples/jest/__tests__/another.spec.js example, we can do `.then(() => provider.verify());` with same it block. When I am doing this for 1 test it works seamlessly. But when I have multiple pact tests, interactions start getting confused and results in test failure. To fix the issue, I end up doing `it('successfully verifies', () => provider.verify());` for each test. Now if I have 2 pact tests, I end up having 4 tests => 2 actual tests and 2 verify `it` block. This is just extra noise, can someone help me with this?

mboudreau
2018-05-14 00:53
I think the problem is that you're returning a promise, but also using the `done` function. You're calling `done` before the actual function is done

mboudreau
2018-05-14 00:53
since it still has to verify

mboudreau
2018-05-14 00:53
just remove the `done`, and it should work

ragarwal
2018-05-14 01:08
describe(?pact tests?, () => { const expectedCreateAgencyResponse = { agencyId: ?A000001?, }; beforeAll(() => { process.env.NAILGUN_API_BASE_URL = ?http://localhost:7080'; return provider.addInteraction(interaction); }); it(?should return an success response with the formatted message?, done => { createAgency(createRequest, response).then(() => { expect(response.send).toHaveBeenCalledWith(expectedCreateAgencyResponse); done(); }); }); it(?successfully verifies?, () => provider.verify()); });

ragarwal
2018-05-14 01:09
This is how I am adding tests as of now

ragarwal
2018-05-14 01:10
Are you suggesting to remove done completely, or calling it in a different way?

mboudreau
2018-05-14 01:10
remove it and put your verify back in the then

ragarwal
2018-05-14 01:15
I will try doing that. Thanks @mboudreau

ragarwal
2018-05-14 01:25
It?s not working without done.

matt.fellows
2018-05-14 01:25
What?s it doing - timing out?

matt.fellows
2018-05-14 01:25
Did you remove the done argument (and not just the `done()`?)

ragarwal
2018-05-14 01:26
yes, I removed the done argument

ragarwal
2018-05-14 01:26
it(?should return an success response with the formatted message?, () => { createAgency(createRequest, response) .then(() => { expect(response.send).toHaveBeenCalledWith(expectedCreateAgencyResponse); }) .then(() => { provider.verify(); }); });

ragarwal
2018-05-14 01:27
Now I am getting this error: console.warn node_modules/bluebird/js/release/debuggability.js:873 Unhandled rejection Error: expect(jest.fn()).toHaveBeenCalledWith(expected) Expected mock function to have been called with: [{?agencyId?: ?A000001"}] But it was not called.

ragarwal
2018-05-14 01:27
I can see this in logs, but entire test suite is saying successful. :flushed:

matt.fellows
2018-05-14 01:27
My recommendation is to have a structure like this ` beforeAll(() => provider.setup()); afterEach(() => provider.verify()); afterAll(() => provider.finalize()); describe ?some big important scenario? it ?does something? it ?does something else? describe ?next big important scenario? ...

matt.fellows
2018-05-14 01:28
It reads a lot better, and is less error prone

matt.fellows
2018-05-14 01:29
Also consider that Jest may run in _parallel_ - if that?s the case, then that could explain the weird issues you?re having.


mboudreau
2018-05-14 01:30
@ragarwal if you're not using `done` you need to return the promise in the test

mboudreau
2018-05-14 01:30
ie. return your `createAgency` function

mboudreau
2018-05-14 01:31
and yeah, paralellization might be an issue with jest

ragarwal
2018-05-14 01:33
I am already passing `runInBand` to solve that issue

mboudreau
2018-05-14 01:34
``` it(?should return an success response with the formatted message?, () => { return createAgency(createRequest, response) .then(() => expect(response.send).toHaveBeenCalledWith(expectedCreateAgencyResponse)) .then(() => provider.verify()); }); ```

matt.fellows
2018-05-14 01:34
``` .then(() => { provider.verify(); }); ``` should be ``` .then(() => { return provider.verify(); }); ``` or just? ``` .then(() => provider.verify()) ```

ragarwal
2018-05-14 01:45
adding return to provider.verify() worked!

mboudreau
2018-05-14 01:45
magic! :stuck_out_tongue:

ragarwal
2018-05-14 01:45
also, as suggested by @matt.fellows, I moved it to afterEach() and now I have it only once in a file, which is more cleaner.

ragarwal
2018-05-14 02:01
with `.then(() => { return provider.verify(); })` my test became flaky. I ran them multiple times and they are randomly passing and failing without any code change.

santoshtrip
2018-05-14 03:24
has joined #general

santoshtrip
2018-05-14 03:26
Has anybody tried out swagger mock validator for contract testing

rgshah781988
2018-05-14 04:52
Thanks

rgshah781988
2018-05-14 04:52
Let me try this out

shekharsp27
2018-05-14 06:41
I have done POC using swagger petstore

rgshah781988
2018-05-14 09:05
can you share a link ?


shekharsp27
2018-05-14 09:45
My POC is on local machine, so please let me know if you still require a POC. Will commit it to repo.

ashish.dubey91
2018-05-14 11:51
hey guys. I have a question. I'm thinking of writing pact based tests and automate execution based on collection of BDD scenarios

ashish.dubey91
2018-05-14 11:52
is it possible that I can do provider verification per behavior basis?

ashish.dubey91
2018-05-14 11:52
if there was some way to tag interactions with steps definitions like in cucumber, that would have helped

ashish.dubey91
2018-05-14 11:52
I haven't seen anything like that in the docs hence I'm asking here

matt.fellows
2018-05-14 12:06
Hmm in theory it is possible, with environment variables

matt.fellows
2018-05-14 12:07
I'm on mobile, but off the top of my head, you can replay specific provider interactions, keyed by the description in the pact

matt.fellows
2018-05-14 12:07
But why?

ashish.dubey91
2018-05-14 15:09
so that I can pick certain provider interactions based on the relative importance. or at some point, I can tell for certain descriptions (BDD scenarios) in my case, if there exists a provider interaction that I can verify

santoshtrip
2018-05-14 16:29
Thanks @shekharsp27

timothy.clifford
2018-05-15 00:08
has joined #general

tjones
2018-05-15 01:04
has joined #general

vinod.baradwaj
2018-05-15 08:46
@matt.fellows term worked fine for endpoint which is `/api/tagCollections/{tagCollectionId}` but when i use the same technique for `/api/tagCollections/{tagCollectionId}/tags/{tagId}` i get `multiple interaction found`

vinod.baradwaj
2018-05-15 08:48
because both the endpoints `/api/tagCollections/{tagCollectionId}/tags/{tagId}` and `/api/tagCollections/{tagCollectionId}/tags` are getting matched

matt.fellows
2018-05-15 08:48
Are you clearing interactions between tests? As a general rule, you should only hit one per test. Or is this for local stubs?

vinod.baradwaj
2018-05-15 08:48
this is for local stubs

bethskurrie
2018-05-15 08:50
Can you give more information @vinod.baradwaj

bethskurrie
2018-05-15 08:50
I'm not sure we have the same understanding of "local stubs".

bethskurrie
2018-05-15 08:51
I think the regular expression you're using needs start and end markers on it.

bethskurrie
2018-05-15 08:51
^ and $

vinod.baradwaj
2018-05-15 08:54
i have not used start and end markers, let me try with that

bethskurrie
2018-05-15 11:11
Needs more Tims!

vinod.baradwaj
2018-05-15 11:52
i have used term like this `path: term({generate: "/api/tagCollections/10197", matcher: "/api/tagCollections/"+'\\d{5}'})`

bethskurrie
2018-05-15 12:04
You'll need to escape the forward slashes correctly. And put a $ at the end.

bethskurrie
2018-05-15 12:05
`\/api`

timothy.clifford
2018-05-15 23:01
I'll see what I can do

timothy.clifford
2018-05-15 23:04
Day 2 at Orica and I've already seen "contract testing" on the wish list

timothy.clifford
2018-05-15 23:04
I automatically started muttering "PACT" over and over

matt.fellows
2018-05-15 23:06
:laughing:

matt.fellows
2018-05-15 23:06
You know who to talk to :slightly_smiling_face:

matt.fellows
2018-05-15 23:07
Try using something like this to test your regexes: http://rubular.com/

timothy.clifford
2018-05-15 23:12
I get a commission now, right?

matt.fellows
2018-05-15 23:12
Sure

matt.fellows
2018-05-15 23:12
You can own 1/20th of a slide deck :slightly_smiling_face:

timothy.clifford
2018-05-15 23:12
YES! I'm in

rgshah781988
2018-05-16 05:21
I have a scenario - When I make a GET API call , response is unknown in my application.

rgshah781988
2018-05-16 05:22
How can I create pact for this kind of GET API call ?

uglyog
2018-05-16 05:23
You'll need to be more specific on what "response is unknown in my application" means

rgshah781988
2018-05-16 05:25
Few job are running automatically and it will have id and response depend on job. When I create a pact file for GET api call then response should be different.

uglyog
2018-05-16 05:26
and the job is specified in the path or as query parameters?

bethskurrie
2018-05-16 06:17
@rgshah781988 please provide some example code (ideally in a git repository), describe your expected outcome, and the actual outcome.

vinod.baradwaj
2018-05-16 06:18
same api end point but with different responses every time when u make request to the same endpoint ? @rgshah781988

rgshah781988
2018-05-16 06:20
@vinod.baradwaj :same api end point but with different responses every time when u make request to the same endpoint - > Yes

rgshah781988
2018-05-16 06:20
We need this case for GET Call. I am not changing end-point data - api/assets

bethskurrie
2018-05-16 06:23
It's perfectly normal to set up the same request and expect different responses for different situations. You need to run each test separately, however. You can't load all the interactions into the mock service at the same time. You'll have to do a set up, 1 interaction, test it, tear down, set up the 2nd interaction, test it, tear down etc.

rgshah781988
2018-05-16 06:24
ok

ashish.dubey91
2018-05-16 06:57
Is it possible to do provider verification programmatically (say, in a python function) for a specific interaction? Sorry if it's too obviously mentioned in the docs. I think this slack group is friendly, and I'm exploiting that fact too much

mboudreau
2018-05-16 07:04
probably ask in the python channel if it's python specific since each language has a different way of doing things

nand.sharma
2018-05-16 07:25
has joined #general

nand.sharma
2018-05-16 07:28
Is there a ways to provide pact broker url to pact stub server ? As per https://github.com/pact-foundation/pact-stub-server documentation , we can provide directory of pact file


bethskurrie
2018-05-16 07:58
No, I don't think the rust implementation supports that. The ruby one does though (if I released it. I only did the code for it the other day. Let me check.)

bethskurrie
2018-05-16 07:59
Oh, I beg your pardon. Just read the docs. Yes!

vinod.baradwaj
2018-05-16 08:44
thanks @matt.fellows @bethskurrie

james.hogarth
2018-05-16 09:21
has joined #general

matt.fellows
2018-05-16 10:55
:+1:

uglyog
2018-05-16 23:38
@nand.sharma directly supporting the pact broker is an excellent idea. Can you raise an issue for that?

gnewitt
2018-05-17 03:28
has joined #general

jaime.jaramillo
2018-05-17 18:24
has joined #general

rollertone
2018-05-19 17:21
has joined #general

minhdoan
2018-05-21 03:13
has joined #general

minhdoan
2018-05-21 08:53
Hi team, i am buidling a Pact record with the response contains:

minhdoan
2018-05-21 08:53
{ "Id": 35345786, "DATA_TYPE": { "EntityTypeName": "STRING", } }


minhdoan
2018-05-21 08:53
{ "Id": 35345786, "DATA_TYPE": null

minhdoan
2018-05-21 08:56
I used the pact-jvm-consumer-junit_2.12:3.5.16 and it seems the or() method, e.g: or("DATA_TYPE", null, PM.nullValue(), PM.stringType()) does not work in this case

minhdoan
2018-05-21 08:56
Could you please help to instruct me how to build it?

minhdoan
2018-05-21 08:56
Many thanks!

abhilash.hanumanth
2018-05-21 09:43
has joined #general

abhilash.hanumanth
2018-05-21 09:45
I am also having similar requirement as @minhdoan

abhilash.hanumanth
2018-05-21 09:45
I have a simple pact record :

abhilash.hanumanth
2018-05-21 09:45
[ { "id":123, "name":"Abhilash" }, { "id":1234, "name":"Hanumanth" } ]

abhilash.hanumanth
2018-05-21 09:45
How do I construct the pactDslJsonBody for the above example body ?

abhilash.hanumanth
2018-05-21 09:49
@uglyog: Can you pls provide a solution for this as I see ``` public PactDslJsonArray array() { throw new UnsupportedOperationException("use the array(String name) form"); } ``` in PactDslJsonBody.java

minhdoan
2018-05-21 09:58
@abhilash.hanumanth for your case

minhdoan
2018-05-21 09:58
body(new PactDslJsonBody() .id("Id") .stringValue("name", "Abhilash") ).toPact();

minhdoan
2018-05-21 09:59
and the pact record:

minhdoan
2018-05-21 09:59
{ "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "name": "Abhilash", "Id": 1234567890 } }

minhdoan
2018-05-21 09:59
Is it satisfied your need?

abhilash.hanumanth
2018-05-21 10:20
Sorry @minhdoan. My bad. I changed my requirement. Please check

abhilash.hanumanth
2018-05-21 10:21
body: ``` [ { "id":123, "name":"Abhilash" }, { "id":1234, "name":"Hanumanth" } ] ```

minhdoan
2018-05-21 10:36
@abhilash.hanumanth

minhdoan
2018-05-21 10:37
.body(new PactDslJsonBody() .array("value") .object() .id("id") .stringValue("name", "Abhilash") .closeObject() .object() .id("id") .stringValue("name", "Hanumanth") .closeObject() .closeArray() ).toPact();

minhdoan
2018-05-21 10:37
and pact record:

minhdoan
2018-05-21 10:37
"body": { "value": [ { "name": "Abhilash", "id": 1234567890 }, { "name": "Hanumanth", "id": 1234567890 } ] }

minhdoan
2018-05-21 10:37
try it

peter.banjo
2018-05-21 10:49
has joined #general

abhilash.hanumanth
2018-05-21 10:52
Hi @minhdoan: If you observe my Json body, i dont have "value". In your solution, "value" is passed to array() which will generate key name as "value" which is not there in my response. And passing parameter is mandatory to .array() method as I said : ``` public PactDslJsonArray array() { throw new UnsupportedOperationException("use the array(String name) form"); } ```

minhdoan
2018-05-21 11:03
@abhilash.hanumanth Could you send your detail API response received from Postman or some thing like that? Because almost the response have format as:

minhdoan
2018-05-21 11:03
{ value: [} } or { "Name": "Value" }

minhdoan
2018-05-21 11:05
I have not seen the format: { [] }

bethskurrie
2018-05-21 11:21
@abhilash.hanumanth @minhdoan would you mind moving your conversation to the #pact-jvm channel please? We like to keep the conversations focussed so that we can ensure everyone gets their issues addressed. Using threads helps with this too. Thanks! Hope you get your problem worked out.

abhilash.hanumanth
2018-05-21 11:22
Sure Beth

scott.osborne1
2018-05-21 21:55
has joined #general

scott.osborne1
2018-05-22 20:27
I noticed that the pact-broker database has a table called config. Can anyone point me to examples for how to set up pact-broker configuration in the database? Or maybe there's a separate slack channel for pact-broker issues.

aphelps
2018-05-22 21:08
has joined #general

avinash.eediga
2018-05-23 05:55
has joined #general

avinash.eediga
2018-05-23 05:58
any one can share a simple example to start with pact

avinash.eediga
2018-05-23 05:58
in js /jvm

avinash.eediga
2018-05-23 05:58
thanks in advance

vinod.baradwaj
2018-05-23 06:08
try this @avinash.eediga `https://github.com/Mikuu/Pact-JVM-Example` this is in jvm

rgshah781988
2018-05-23 06:21
@avinash.eediga Pactjs is little bit easy to understand

rgshah781988
2018-05-23 06:24
Can we have some automation in creating a pact file ? When user provide swagger file with its details. Then automatically pact file created. Is it possible ? We should have such kind of automation script? Which will boost use of pact.

bethskurrie
2018-05-23 06:25
Hi @rgshah781988 it could be written, but it's not going to help you. The value of pact is that the contract is generated by tests that execute the actual calls that your codebase will make in real life. A pact file generated from a swagger document misses the whole point.

rgshah781988
2018-05-23 06:25
Presently, It is difficult to update contract regularly whenever endpoint changes.

rgshah781988
2018-05-23 06:26
Can we have solution over this?

bethskurrie
2018-05-23 06:26
Presently, your contract tests are making you keep your code in sync with the provider changes. If they didn't do that, then there would be no value in them.

rgshah781988
2018-05-23 06:26
Agreed 100%.

bethskurrie
2018-05-23 06:26
I don't understand your question, sorry.

rgshah781988
2018-05-23 06:27
Can we make it automation to update end-point in contract file of pact

rgshah781988
2018-05-23 06:28
A pact file generated from a swagger document misses the whole point. - Can we find solution on this ?

tom
2018-05-23 06:42
has joined #general

tom
2018-05-23 06:45
I know that this isn't bet practice, but I need a matcher that make confirms that at object has been sent up, but the key/values aren't important

tom
2018-05-23 06:45
Does something like that exist?

tom
2018-05-23 06:59
I should add that is the values themselves would be objects

tom
2018-05-23 07:00
so using like({}) doesn't work

tom
2018-05-23 07:00
I should have mention that i am using pact-js

matt.fellows
2018-05-23 10:08
I'm sure this discussion has been had before.

matt.fellows
2018-05-23 10:09
We should get it up on our website so at least the key aspects to the problem and solution space are documented

matt.fellows
2018-05-23 10:10
:grin:

matt.fellows
2018-05-23 10:11
Hmmm. I don't think so, at least not in pact JS that I'm aware of

matt.fellows
2018-05-23 10:13
The keys are not matchable to my knowledge, they must be known in advance

bethskurrie
2018-05-23 10:15
The point of this sort of contract testing is not to *have* a pact file, it's to have two sets of tests (one in the consumer project using a mock provider, and one in the provider project using a "mock consumer") that are linked together so they can't get out of sync - the pact file is the mechanism for doing that. Generating a pact file from a swagger document is pointless, and is like marking your own exam, as I've heard someone once describe it before.

bethskurrie
2018-05-23 10:17
@tom is the expectation for the request body or the response body?

tom
2018-05-23 10:34
request body

tom
2018-05-23 10:34
Long story:

tom
2018-05-23 10:35
We use Redux

bethskurrie
2018-05-23 10:35
Hm. If it was the response body, you'd be fine, but for the request body, you really have to specify everything you're sending. Read up on Postel's Law if you're not familiar with it.

tom
2018-05-23 10:36
Yeah. Read that in the docs

tom
2018-05-23 10:37
and i totally agree .... EXCEPT

bethskurrie
2018-05-23 10:37
Redux puts extra stuff in that you don't care about?

tom
2018-05-23 10:37
we have 'screen capture'

tom
2018-05-23 10:38
we are currently achieving this by sending the entire state up as an additional parameter

tom
2018-05-23 10:38
HORRIBLE, i know

tom
2018-05-23 10:38
but, genius in comparison to how we were doing it

bethskurrie
2018-05-23 10:39
What level are you writing your pact tests at? Are they going through the UI, or just testing the API client class?

tom
2018-05-23 10:39
through the ui

bethskurrie
2018-05-23 10:39
there's your problem.

bethskurrie
2018-05-23 10:40
Ideally, you write pact tests for as little code as possible. Just the client that is responsible for making the API calls.

bethskurrie
2018-05-23 10:40
Then, you're in control of everything that gets passed into that client.

rgshah781988
2018-05-23 10:40
Thanks for update

tom
2018-05-23 10:40
Hmmmm. You are right (as always)

bethskurrie
2018-05-23 10:40
Back door of the consumer to front door of the provider.

bethskurrie
2018-05-23 10:41
Ha! My husband would disagree with you there :stuck_out_tongue:

bethskurrie
2018-05-23 10:41
But I have done this enough to know how to write painful pact tests, and I know that the more code you cover with them, the more painful they are.

tom
2018-05-23 10:41
BUT, it doesn't help with the next point

tom
2018-05-23 10:42
It will fail on the mock server

tom
2018-05-23 10:42
which would suck because i am using that for deving


tom
2018-05-23 10:43
the cheat answer is to change it to pass up a stringified json object

bethskurrie
2018-05-23 10:43
There may be a workaround. Let me have a look and see if some naughty code I once put in there is still there.

tom
2018-05-23 10:43
but i was hoping to not have to do any re work

tom
2018-05-23 10:44
The weird thing is, it works in 4

tom
2018-05-23 10:44
it broke updating to 5

bethskurrie
2018-05-23 10:45
4/5 of what?

bethskurrie
2018-05-23 10:45
Is that a pact-js version?


tom
2018-05-23 10:45
it shouldn't have worked, so 5 didn't break it,

bethskurrie
2018-05-23 10:46
i haven't touched that part of the code for years.

bethskurrie
2018-05-23 10:46
I'm just seeing if the dirty hack I once put in to allow this sort of thing is still there

tom
2018-05-23 10:46
:crossed_fingers:

tom
2018-05-23 10:48
The weird thing is, as I was explaining to Beth) that it worked in 4.

tom
2018-05-23 10:48
It shouldn't have

bethskurrie
2018-05-23 10:48
ok... we have two options. We can hack the ruby code or we can hack the js code.

tom
2018-05-23 10:49
I am WAY more comfortable with JS

bethskurrie
2018-05-23 10:49
In the request that gets sent to the mock service, at the same level as the body, path, headers keys, you can add another key called `options`.


bethskurrie
2018-05-23 10:49
In that hash, if you set `{"allow_unexpected_keys_in_body": true}` then it will allow extra keys in the body

bethskurrie
2018-05-23 10:50
You'll have to override the javascript code that sends the request. Is monkeypatching js a thing?

tom
2018-05-23 10:50
I will make it so

bethskurrie
2018-05-23 10:50
If that doesn't work, there's a built in mechanism for allowing us to monkeypatch the ruby :wink:

bethskurrie
2018-05-23 10:51
I persuaded michel to put it in, despite great protestations.

tom
2018-05-23 10:51
So i need to send that up with every request where I need this attribute?

bethskurrie
2018-05-23 10:51
yes


tom
2018-05-23 10:52
I will have a play around with it and get back to you.

bethskurrie
2018-05-23 10:53
ok. if that fails, I can send you the ruby for the monkeypatch.

tom
2018-05-23 10:54
The other option is to change the request to strings and then just parse it on the server site


tom
2018-05-23 10:54
thanks again

bethskurrie
2018-05-23 10:54
good to know there's a backup plan.

bethskurrie
2018-05-23 10:54
np

tom
2018-05-23 10:55
but it is only after updated to 5 that it started.

tom
2018-05-23 10:55
It is my fault

matt.fellows
2018-05-23 10:58
We might need an option to pass that through @bethskurrie, with a warning when used

gopinathlangote11
2018-05-23 13:29
has joined #general

scott.osborne1
2018-05-23 15:25
I would love to be able to set pact-broker configuration through the database instead of in the http://config.ru file. Can anyone point me to examples for setting up configuration in the database?

scott.osborne1
2018-05-23 15:26
Specifically I want to set "order_versions_by_date = true" and have it persist over restarts and upgrades to the pact-broker docker image.

scott.osborne1
2018-05-23 15:27
I could package my own docker image that uses your image and updates the config file, but the http://config.ru is not consistent between pact-broker-docker images either, so I would prefer to put these kinds of settings in the database.

peter.banjo
2018-05-23 15:41
hi. i'm trying to test a swagger API with Pact using swagger-mock-validator. the tests are failing and I'm not sure where the problem is. my setup is like this ``` // secure.spec.js const interaction = { state: "authenticated request", uponReceiving: "a request for a secure resource", withRequest: { method: "GET", path: "/secure", headers: { Accept: "application/json", Authorization: "Bearer 1234XYz" } }, willRespondWith: { status: 200, headers: { "Content-Type": "application/json" }, body: EXPECTED_BODY } }; ```

peter.banjo
2018-05-23 15:42
``` // swagger.yaml swagger: "2.0" ... securityDefinitions: Bearer: type: apiKey name: Authorization in: header ... /secure: x-swagger-router-controller: secure get: description: Allows only secure requests operationId: secure security: - Bearer: [] responses: "200": description: Success schema: $ref: "#/definitions/SecureResponse" default: description: Error schema: $ref: "#/definitions/UnauthorizedError" ```

peter.banjo
2018-05-23 15:43
is anyone familiar with using swagger and pact?

greg
2018-05-23 15:45
has joined #general

peter.banjo
2018-05-23 15:50
I found the issue... i had multiple definitions in my pact file so `pactfileWriteMode: "overwrite",` solved it

paulswilliams
2018-05-23 19:33
has joined #general

paulswilliams
2018-05-23 19:35
Hi all.

bethskurrie
2018-05-24 04:17
It's not a feature I really advertise! But there are certain situations where it's better than the alternatives.

gopinathlangote11
2018-05-24 05:18
Hello


bethskurrie
2018-05-24 08:37
I haven't gotten around to making an API for the configuration, but here is the sql to set the config you want:

bethskurrie
2018-05-24 08:38
``` insert into config (name, type, value, created_at, updated_at) values ('order_versions_by_date', 'boolean', '1', now(), now()); ```

bethskurrie
2018-05-24 08:40
Any luck @tom?


rgshah781988
2018-05-24 11:54
:+1:

matt.fellows
2018-05-24 12:19
Nice, thanks Beth

scott.osborne1
2018-05-24 15:26
That's great! Thank you! I was putting in "true" in the database and it wasn't working. I'll use your example. Appreciate it!

santoshtrip
2018-05-24 23:12
@shekharsp27 can you please share the whole dependency set to run this

santoshtrip
2018-05-24 23:13
Having tough time with multiple versions causing conflict

eumirg
2018-05-25 05:14
has joined #general

shirren
2018-05-25 05:44
has joined #general

shekharsp27
2018-05-25 11:11
Here is consumer dependency

shekharsp27
2018-05-25 11:12
<dependencies> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.12</artifactId> <version>3.5.13</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-java8_2.12</artifactId> <version>3.5.13</version> <scope>test</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> <dependency> <groupId>com.atlassian.oai</groupId> <artifactId>swagger-request-validator-pact</artifactId> <version>1.3.8</version> </dependency> <!-- https://mvnrepository.com/artifact/io.rest-assured/rest-assured --> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>3.0.7</version> <scope>test</scope> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-parser</artifactId> <version>1.0.34</version> </dependency> </dependencies>

shekharsp27
2018-05-25 11:13
Here is provider dependency <dependencies> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit_2.12</artifactId> <version>3.5.13</version> </dependency> <dependency> <groupId>com.atlassian.oai</groupId> <artifactId>swagger-request-validator-pact</artifactId> <version>1.3.8</version> </dependency> <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <version>3.0.7</version> <scope>test</scope> </dependency> <dependency> <groupId>io.swagger</groupId> <artifactId>swagger-parser</artifactId> <version>1.0.34</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> <version>2.9.4</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> <version>2.9.4</version> </dependency> </dependencies>

dervis4
2018-05-28 09:08
has joined #general

dervis4
2018-05-28 10:22
Hi guys! We (at Norwegian LWA) had some issues with the content-type header when running our tests against a Jetty-server. We have made a improvement in Pact-JVM that makes Pact able to accept content-type header with an optional whitespace character (as pr the W3C-specification). Please see our pull-request here: https://github.com/DiUS/pact-jvm/pull/688. :slightly_smiling_face:

mboudreau
2018-05-28 12:00
thanks for the PR. It's night time for most of the core contributors, but I'm sure it will be looked at soon. Cheers :slightly_smiling_face:

dervis4
2018-05-28 12:15
Thank you @mboudreau (its day time here in Norway)

paulswilliams
2018-05-28 12:34
So I?ve got a reliable consumer + provider test working with contracts held by the broker. However, I now want to add a test for an exception case as well as the positive case. Should I just add a uponReceiving? section to this DSL, and another authClient.login chunk into my existing @Test? As you can only have one test per class using the JUnit integration, should I be using the DSL instead? Using this approach, there seems to be a lot of boilerplate needed :confused: ```public class AuthClientTest { @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("simple-auth-api", "localhost", 8081, this); @Pact(consumer = "simple-web") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> requestHeaders = new HashMap<>(); requestHeaders.put("Accept", "application/json, application/cbor, application/*+json"); Map<String, String> expectedResponseHeaders = new HashMap<>(); expectedResponseHeaders.put("Content-Type", "application/json;charset=UTF-8"); return builder .given("Paul exists with password Secret") .uponReceiving("valid authentication details") .path("/login") .query("username=Paul&password=Secret") .headers(requestHeaders) .method("GET") .willRespondWith() .status(200) .headers(expectedResponseHeaders) .body("{\"id\":123,\"username\":\"paul\",\"firstname\":\"Paul\",\"lastname\":\"Williams\"}") .toPact(); } @Test @PactVerification() public void successfulLogin() { User login = new AuthClient().login("Paul", "Secret"); assertThat(login, is(notNullValue())); assertThat(login.getId(), is(123)); assertThat(login.getUsername(), is("paul")); assertThat(login.getFirstname(), is("Paul")); assertThat(login.getLastname(), is("Williams")); } }```

paulswilliams
2018-05-28 12:37
Although one large test testing multiple interactions would work, it gives many reasons for it to fail?

matt.fellows
2018-05-28 12:38
Personally i would try to keep one test for each single interaction rather than make each test more complex, even if it does involve more verbosity/boilerplate. @uglyog might have some opinions tho

mboudreau
2018-05-28 12:40
one way to reduce boilerplate is to have shared 'util' classes that setup the repetitive things from your DSL definition

paulswilliams
2018-05-28 12:40
The boilerplate I?m referring to is less the DSL, more the assertions. Most of: ```MockProviderConfig config = MockProviderConfig.createDefault(); PactVerificationResult result = runConsumerTest(pact, config, mockServer -> { Map expectedResponse = new HashMap(); expectedResponse.put("hello", "harry"); try { assertEquals(new ProviderClient(mockServer.getUrl()).hello("{\"name\": \"harry\"}"), expectedResponse); } catch (IOException e) { throw new RuntimeException(e); } }); if (result instanceof PactVerificationResult.Error) { throw new RuntimeException(((PactVerificationResult.Error)result).getError()); } assertEquals(PactVerificationResult.Ok.INSTANCE, result);```

paulswilliams
2018-05-28 12:41
Testing one thing per test is generally how I?ve done things for 10 years, just trying to work out how to do that succinctly.

paulswilliams
2018-05-28 13:48
Further, is it possible for mocks to throw exceptions in @State methods? The following code seems to cause the exception to be thrown in the wrong context, and thus my ControllerAdvice doesn?t pick it up and convert to 401. ``` @State("Paul exists with password Secret") public void returnSuccessfulLogin() { when(authService.login("Paul", "Secret")).thenReturn(new User(123, "paul", "Paul", "Williams")); when(authService.login("Paul", "Unconcealed")).thenThrow(new BadCredentialsException()); }```

abhilash.hanumanth
2018-05-28 14:06
Did anyone implement PACT for kakfa message queue consumer and provider ?

matt.fellows
2018-05-28 21:00
It's been done, which language?

abhilash.hanumanth
2018-05-29 05:36
using pact jvm

gaurav
2018-05-29 07:56
has joined #general

gaurav
2018-05-29 07:58
configuration for maven plugin.

gaurav
2018-05-29 07:58
Not able to do `mvn pact:publish`

gaurav
2018-05-29 07:58
with above configuration.

gaurav
2018-05-29 07:59
Is there anything wrong I am doing?

gaurav
2018-05-29 08:00
also how can I publish tag? thanks a lot..

gaurav
2018-05-29 08:01
I get this error: `No plugin found for prefix 'pact' in the current project `.. Its in plugins management..

gaurav
2018-05-29 08:03
I was not able to find documentation related to this.. so if someone knows a link then please share.. thanks

such.su
2018-05-29 09:41
has joined #general

such.su
2018-05-29 10:02
Hi all, I am just investigating pact-python to see if it can be used in my services but I got some questions. Could anyone help: 1. Does pact-python support services based on XML message? 2. Is there any reason that it's not implemented or it will be implemented soon?

bethskurrie
2018-05-29 10:03
It isn't yet, but we've just started discussions with someone who is interested in implemeting it. You can use exact string matching, but it will be quite brittle.

such.su
2018-05-29 11:06
Yeah, exact string matching is quite brittle. Is there a release plan for supporting XML? I am quite interesting in using this awesome Pact.

bethskurrie
2018-05-29 11:07
If you look at the pact-dev mailing list, you'll find the current "plan" such as it is.

bethskurrie
2018-05-29 11:08
Oh, actually, that conversation wasn't on that list. Sorry.

such.su
2018-05-29 11:12
Hmmm, where to look at the pact-dev mailing list?:thinking_face:

bethskurrie
2018-05-29 11:12
Sorry, I realised it wasn't on that mailing list

such.su
2018-05-29 11:15
Got it. I am also interested in that mailing list.

bethskurrie
2018-05-29 11:15
I think you can just join it. We're trying to move conversation to slack however.

such.su
2018-05-29 11:16
Cool, thanks:+1:

aswini.j
2018-05-29 11:52
has joined #general

premmkrishna.shenoy
2018-05-29 12:09
has joined #general

premmkrishna.shenoy
2018-05-29 12:11
Hi I am performing a pact test where the provider response is 'application/javascript' with json as body. My provider test is failing on body while my consumer test are good. Do you support 'application/javascript' content type?

aswini.j
2018-05-29 12:13
Does it support JavaScript content-type? The third party service that my microservice interacts with returns the response with the content-type application/JavaScript;charset=UTF-8. Therefore, pact json has response body as string & matching rules has empty body.

aswini.j
2018-05-29 12:14
Using the following pact dependencies:

aswini.j
2018-05-29 12:15
testIntegrationCompile('au.com.dius:pact-jvm-consumer-junit_2.12:3.5.11') testIntegrationCompile('au.com.dius:pact-jvm-provider-junit_2.12:3.5.11') testIntegrationCompile('au.com.dius:pact-jvm-provider-spring_2.12:3.5.11') testIntegrationCompile('au.com.dius:pact-jvm-consumer-java8_2.12:3.5.11')

dagarwal
2018-05-29 20:27
has joined #general

jeremy.shipman
2018-05-29 21:55
has joined #general

jeremy.shipman
2018-05-29 21:57
Hello PACT?ers. I have a random query string being added inside my jQuery ajax config. Is there a way to specify in an interaction that the mock provider service ignore this?

matt.fellows
2018-05-29 21:58
Does the qs have a pattern you can use to match? If it's a cache buster, you could just add a regex matcher for it

jeremy.shipman
2018-05-29 21:58
Ok - yes it?s like a cache buster. Gets around some Safari bug, I see commented

matt.fellows
2018-05-29 22:00
That would work then

bethskurrie
2018-05-29 22:14
You will unfortunately lose the ability to have your pacts "pre-verified" in the broker if you use random data. Let me know if that makes no sense.

uglyog
2018-05-29 23:29
Try using the full artifact name: `pact-jvm-provider-junit_2.12:publish`

uglyog
2018-05-29 23:30
`application/javascript` should be used for Javascript source files. `application/json` should be used for JSON bodies.

uglyog
2018-05-29 23:32
Unfortunately, JavaScript is not a supported content type.

gaurav
2018-05-30 01:11
my bad! I should be using: `pact-jvm-provider-maven_2.12` (not junit_2.12) thanks a lot. Although I believe there should be another maven plugin like `pact-jvm-consumer-maven_2.12` to publish pacts, as publishing pacts are done at consumer side. Anyways, Is there any documentation for this maven plugin goals? Thanks again!

gaurav
2018-05-30 01:15
This time, I am more looking for "how to tag using this maven plugin".. but would love to explore other options this plugin provides.


jeremy.shipman
2018-05-30 02:15
Here?s my code. Is the `query` part of withRequest correct? I?m still getting ?missing requests? urls spitting out. ``` return { uponReceiving: title || mockjax.url, withRequest: { method: mockjax.type || "GET", path: mockjax.url, query: { r: like({ generate: "163aece11f20.7ff22681c8afd", matcher: ".*" }) } }, willRespondWith: { status: mockjax.status || 200, headers: { "Content-Type": "application/json" }, body: mockjax.responseJSON } }; ``` (I?m reusing mock configuration intended for mockjax options)

jeremy.shipman
2018-05-30 02:23
The documentation here: https://docs.pact.io/implementation-guides/javascript suggests the query field should be in this form: `query: /* '?query=parameters' (string) */,`

jeremy.shipman
2018-05-30 02:23
I?m not sure if this means I can?t use js objects to configure it

gaurav
2018-05-30 02:42
thanks a lot. I could pass tags as -D by defining a maven properties. I have another question however bit unrelated so will put that as new slack message. thanks again!

gaurav
2018-05-30 02:53
Hello all, as a best practice, which is more preferable 1. 'mvn pact:verify' to run provider tests 2. Run test with sure-fire plugin (like we we do for normal unit tests in our case). and why?

mboudreau
2018-05-30 02:55
what works best for you?

gaurav
2018-05-30 02:57
I tried both.. both works fine for current purpose so I am trying to decide which one to use. :slightly_smiling_face:

bethskurrie
2018-05-30 02:57
I would suggest it doesn't matter then!

bethskurrie
2018-05-30 02:58
@uglyog may have an opinion

gaurav
2018-05-30 03:00
thanks.. I will also spend little more time experience the whole flow.. checking which one would fit better with our CI pipeline practically. At this point, from my current understanding: both should work just fine.

gaurav
2018-05-30 03:54
I wonder how I can pass 'tag' from command line when running tests through sure-fire.. l have a profile to run provider tests: providerTests. so `mvn test -PproviderTests` will run my provider tests.. However if I want to run provider tests using pacts with a particular tag: 'head' or 'prod' etc., I am wondering how I could achieve that. any ideas? Thanks a lot.

bethskurrie
2018-05-30 03:55
I believe there is a configuration in the maven task config

bethskurrie
2018-05-30 03:55
Can you find the page for the mvn config?


gaurav
2018-05-30 03:58
but thats when I am using `mvn pact:verify` right?

bethskurrie
2018-05-30 03:58
Scroll down until you read the part about the tags.

gaurav
2018-05-30 04:01
I will have to use `mvn pact:verify` if I want to use tag this way..

bethskurrie
2018-05-30 04:01
:thumbsup:

gaurav
2018-05-30 04:01
If I am using surefire then I am defining tags currently as `@PactBroker(host = ?localhost?, port = "80", tags = {"TEST","DEV"})`

uglyog
2018-05-30 04:02
You will probably have to use Java system properties

gaurav
2018-05-30 04:03
I see.. so if I set system properties `pactbroker.tags` to a tag then it should work..


gaurav
2018-05-30 04:13
great. Awesome. Its working. Thanks a lot.

aswini.j
2018-05-30 05:38
Thank you

gaurav
2018-05-30 07:06
Thinking about a bit, I see a possible gap regarding verifying pact with provider when making changes on consumer side. Don?t know how to fill the gap. Following is the scenario: - I checkout a branch on consumer side: my_branch - I make some changes that might impact pact. - I do: `mvn pact:publish -Dpact.tag=my_branch` - Now I want to validate my pact so lets suppose I checkout provider code and do: `mvn test -PproviderTests -Dpactbroker.tags=my_branch` (assuming pom is setup this way) Tests pass and I am happy. BUT I have run master-version-provider to verify pacts. Current master provider code might be different than current production code. I am still not sure whether if I deploy my changes in production then there won?t be any contract issue. Its possible that my current expectation as consumer is not valid with provider service currently running in production.

gopinathlangote11
2018-05-30 07:13
@gaurav I feel, You verified the pacts against your branch, not against master. Whenever you merge the branch to master I think you need to verify once again.

gaurav
2018-05-30 07:15
I verified a pact: consumer-branch with provider-master.. my question is how do I make sure that my consumer-branch will be fine with provider-prod.

bethskurrie
2018-05-30 07:46
@gaurav you need to use the can-i-deploy tool



gaurav
2018-05-30 07:50
thanks a lot Beth. I will read the documentation and try can-i-deploy tool

gaurav
2018-05-30 08:24
thanks, it is starting to make sense now.. So provider version in pact matrix should ideally be git-sha (or anything that can be used to checkout prod version of provider).. right? consumer version does not need git-sha version etc. if doing proper tagging, but probably better to do that way for sake of uniformity.. I am going to do some experiments to get some practical experience of how it would work. Thanks a lot @bethskurrie I also see a scope of a maven plugin to handle many of these things.. Thanks again!

bethskurrie
2018-05-30 08:26
Yes, you should use a git sha (or a version with the git sha in the metadata) for your version. I need to update all the examples, because currently, they have a semantic version, which is now not recommended. Make sure your broker is sorting by date and not semantic version as well. You'll find that setting in the configuration docs in the Pact Broker wiki.

gaurav
2018-05-30 08:33
yea.. may be in next broker release, we can change name ?Consumer Version? to ?Consumer SCM Identifier/tag..etc.? or something like that..

bethskurrie
2018-05-30 08:35
Yes, i wish I'd called it something different. I didn't realise quite what the API would turn into when I first wrote it.

gaurav
2018-05-30 08:35
being agile :slightly_smiling_face:

bethskurrie
2018-05-30 08:36
indeed

gaurav
2018-05-30 08:39
Also the fact that 'the default value is {project.version}' is bit misguiding now.

uldis.sturms
2018-05-30 13:39
has joined #general

jeremy.shipman
2018-05-30 21:09
I?m currently trying to write our first PACT test from a web-based client using pact-web to the ruby stand alone mock provider. We haven?t reached the point of setting up a broker yet.

jeremy.shipman
2018-05-30 21:10
Can anyone @here comment?

jeremy.shipman
2018-05-30 21:12
I?m getting a list of `Missing requests`, but I can?t make make the list smaller. I?m assuming it?ll get smaller if the mock service provider will have correctly configured interactions - where effectively the `r` query param is ignored.

jeremy.shipman
2018-05-30 21:14
I?ve tried deleting previously generated pacts in case that was interfering.

jeremy.shipman
2018-05-30 21:16
I?ve tried the following formats of query matching ``` query: "?r=163aece11f20.7ff22681c8afd", query: { r: somethingLike("163aece11f20.7ff22681c8afd") }, query: { r: like({ generate: "163aece11f20.7ff22681c8afd", matcher: ".*" }) } ```

mboudreau
2018-05-30 22:23
yeah, looking into it

mboudreau
2018-05-30 22:28
ah, right, 'like' isn't the right one for the query

mboudreau
2018-05-30 22:29
you want to use `term` if you want to use the generate/matcher


seb
2018-05-31 08:16
has joined #general

gaurav
2018-05-31 09:38
getting this strangely.. will put more information in the thread comments.

2018-05-31 09:39
A file was commented on

mboudreau
2018-05-31 09:54
can you post the dsl code you're using for this test?

matt.fellows
2018-05-31 09:57
Is myCategory a Boolean value? That error seems to indicate it got a Boolean, but the wrong calue

matt.fellows
2018-05-31 09:57
Value*

g.r.mccann
2018-05-31 10:37
has joined #general

g.r.mccann
2018-05-31 10:41
Hi

g.r.mccann
2018-05-31 10:43
I was hoping I could pick your brains on a migration from https://www.npmjs.com/package/pact to https://github.com/pact-foundation/pact-node or pact-js

g.r.mccann
2018-05-31 10:44
we have a number of tests using the older version. As of this morning one of its downstream dependencies appears to have dissapeared from npm registry @types/node/-/node-9.4.2.tgz so am looking to upgrade the tests

g.r.mccann
2018-05-31 10:46
the current tests make use of the Matchers (eachLike, somethingLike) which don't seem to present in pact-node. According to the docs they should be in pact-js but upon destructing Matchers I'm getting undefined

g.r.mccann
2018-05-31 10:46
are they in a seperate repo or am I barking up the wrong tree

g.r.mccann
2018-05-31 10:46
any help would be much appreciated

matt.fellows
2018-05-31 10:47
You probably want @pact-foundation/pact

g.r.mccann
2018-05-31 10:47
so thats the one I'm trying now

matt.fellows
2018-05-31 10:47
Those matchers are now in `Matchers`

g.r.mccann
2018-05-31 10:47
const { Pact } = require('@pact-foundation/pact'); const {Matchers} = Pact;

g.r.mccann
2018-05-31 10:48
Matchers seems to be undefined


matt.fellows
2018-05-31 10:50
This example should help

matt.fellows
2018-05-31 10:50
Sorry just jumping in a car

g.r.mccann
2018-05-31 10:59
That's fine thanks for your help, much appreciated

g.r.mccann
2018-05-31 10:59
const { Pact, Matchers } = require('@pact-foundation/pact');

g.r.mccann
2018-05-31 11:00
seems to do the job as opposed to how we had it before.

matt.fellows
2018-05-31 13:19
Great!

gaurav
2018-06-01 00:49
Thanks Matt.. got it right! the test code was sending different value in the request.. I am still wondering why mock server gave back the response, if request body was different..

gaurav
2018-06-01 01:28
I understand now.. request body is PactDslJsonBody so it matches with field and field type.. not with field value.

jeremy.shipman
2018-06-01 02:09
Thanks @mboudreau for your help :wave:

mboudreau
2018-06-01 02:12
np :slightly_smiling_face:

gaurav
2018-06-01 05:33
Getting 500 suddenly with mvn pact:publish -Dpact.tag=myBranch (pom is setup accordingly).. was working fine and suddenly stopeed working. Any log that can help?

uglyog
2018-06-01 05:34
What broker are you using?

gaurav
2018-06-01 05:35
x-pact-broker-version: 2.19.1

bethskurrie
2018-06-01 05:35
Docker container?


gaurav
2018-06-01 05:35
yea its container.. checking troubleshooting page.

gaurav
2018-06-01 05:38
pact-broker restart fixed it.. however I am going to set PACT_BROKER_LOG_LEVEL to DEBUG .. just in case it happens again.. thanks all. :slightly_smiling_face:

bethskurrie
2018-06-01 05:38
np

bethskurrie
2018-06-01 05:39
did you find any logs?

gaurav
2018-06-01 05:43
running broker in mesos using marathon and getting logs is bit tricky (our other applications use logstash so we can check app logs in kibana).. We are working on making it better.. however I am going to put ssh in broker docker image so that I can do ssh and get logs from container.. or for any other troubleshooting

gaurav
2018-06-01 07:40
From Pact Nirvana Document: `To reach Pact Nirvana, the final step is to have a CI build that checks out the code for the production version of your provider, and have it verify the same pacts that the head version does.` In case consumer has new pact tests with new states, this won?t work right? because production version of provider code will be having older version of provider tests, that might not run with head version consumer pacts.

bethskurrie
2018-06-01 07:41
I see you've thought this through ;-)

bethskurrie
2018-06-01 07:42
My thought on this is that you could keep the provider state code in a separate repo

bethskurrie
2018-06-01 07:42
This may be difficult

bethskurrie
2018-06-01 07:42
Too difficult

gaurav
2018-06-01 07:43
I intend to put ?independent deployment? in practice so have to think a bit.. :slightly_smiling_face: will think about how to resolve it in our case..

bethskurrie
2018-06-01 07:44
I think it should be OK if you don't go back further than the earliest version that used pacts.

bethskurrie
2018-06-01 07:44
And I'm not 100% sure that it's necessary.

bethskurrie
2018-06-01 07:45
Ensuring that you deploy consume and provider as often as possible should mean you're never in that situation.

gaurav
2018-06-01 07:53
hmm that seems right.. however just to be on safer side: we have all our microservices always running in pre-prod env (same version as prod). If we will be able to replay pact files against those microservices running in pre-prod, and somehow verify that contracts are fine then it might work. at least for few cases (assuming we are using pre-prod data in consumer tests requests).. For negative tests e.g. 404 etc it won?t work. But we don?t need pacts for negative scenarios.

matt.fellows
2018-06-01 11:38
that sort things out Jeremy?

shekharsp27
2018-06-01 13:11
Hi, I have a question about "pact-provider-verifier-docker", as per the document I have done the setup 1) Following is my API docker file, its a simple spring application FROM openjdk:8-jre-alpine COPY ./target/updated-provider-service-0.0.1-SNAPSHOT.jar /usr/src/animal/ WORKDIR /usr/src/animal EXPOSE 8080 CMD ["java", "-jar", "updated-provider-service-0.0.1-SNAPSHOT.jar"] 2) Following is docker-compose yml file <pre>version: '3' services: animalwebapp: build: ./ ports: - "8000:8080" pactverifier: image: dius/pact-provider-verifier-docker links: - animalwebapp environment: - pact_urls=http://192.168.99.100/pacts/provider/zoo__update_provider/consumer/zoo_update_consumer/latest - provider_base_url=http://192.168.99.100:8000</pre> Issue is : When I execute "docker-compose up", the pact verification task is executing before my application gets up & running(also checked by adding depends_on flag). Please let me know what should be the approach here.

gaurav
2018-06-01 13:28
more a docker related question I think.. but if you add ?depends_on? in docker-compose file preferably with a health check then it should be fine. more: https://docs.docker.com/compose/startup-order/

matt.fellows
2018-06-01 13:42
Yep

vikassd2012
2018-06-02 03:35
has joined #general

vikassd2012
2018-06-02 03:36
Hi All needed some of your help. I am trying to run my first test using Pact on dotnet core and I am getting this error {StatusCode: 500, ReasonPhrase: 'Internal Server Error ' I ran the sample solution here https://github.com/tdshipley/pact-workshop-dotnet-core-v1 and it works as expected. I wrote the sample for my application under test following the example


vikassd2012
2018-06-02 03:38
here is my sample code

vikassd2012
2018-06-02 03:38
public void InstrumentReturnsInformationBySerialNumber() { // Arrange var expectedMessage = "{\"runName\":\"dummyRun\",\"instrumentSerialNumber\":\"ea82e963\",\"instrumentDescription\":\"f2bbec3c\",\"instrumenttype\":\"MiSeq\",\"instrumentSoftwareVersion\":\"1.0.0\",\"instrumentApiKeyUsed\":\"c67f59a6b9794c5fb14a594ab1dfe5eb\"}"; _mockProviderService.Given("there is data") .UponReceiving("A valid GET request for Instrument API with a serial number") .With(new ProviderServiceRequest { Method = HttpVerb.Get, Path = "/v3/instruments", Query = "ea82e963", }) .WillRespondWith(new ProviderServiceResponse { Status = 200, Headers = new Dictionary<string, object> { { "Content-Type", "application/json; charset=utf-8" } }, Body = new { message = expectedMessage } }); // Act var result = InstrumentServiceApiClient.GetInstrumentBySerialNumberUsingInstrumentService("ea82e963", _mockProviderServiceBaseUri).GetAwaiter().GetResult(); Console.WriteLine(result.ToString()); var resultBodyText = result.Content.ReadAsStringAsync().GetAwaiter().GetResult(); // Assert Assert.Contains(expectedMessage, resultBodyText); }

vikassd2012
2018-06-02 03:39
please note if I hit my consumer api itself, consuming the provider api, it works as expected

vikassd2012
2018-06-02 03:59
Found an extra comma in the ProviderServiceRequest, removed that but still the same error.

vikassd2012
2018-06-02 04:49
I found my problem


vikassd2012
2018-06-02 04:51
also I was mucking with mockerserver

vikassd2012
2018-06-02 04:51
MockProviderService = PactBuilder.MockService(MockServerPort, new JsonSerializerSettings());

vikassd2012
2018-06-02 04:51
modified that to MockProviderService = PactBuilder.MockService(MockServerPort);

vikassd2012
2018-06-02 04:51
and now it works

bethskurrie
2018-06-02 04:52
Hello Vikas. Can you ask in the pact net channel, and remember to use threads so we can keep conversations focussed. Thanks!

bethskurrie
2018-06-02 04:53
Putting ``` before and after your code will keep it formatted nicely.

hstene
2018-06-02 05:20
has joined #general

hstene
2018-06-02 05:21
God morning. Migrating to Slack is a great idea! :)

vikassd2012
2018-06-02 05:25
Sure Beth got your points. Didn't use Slave before.

bethskurrie
2018-06-02 08:48
Hi all. We have been alerted to a vulnerability in the Pact Broker webhooks and have released a fix in version 2.19.2. The latest Docker image has been upgraded to this version. If you're unsure of the version of your current installation, you'll find the version number in the X-Pact-Broker-Version header in the API Browser. Please upgrade your instance as soon as possible. If you are using the DiUS hosted version, it has already been updated, and no further action is necessary.

richard.peckett
2018-06-02 11:35
has joined #general

matt.fellows
2018-06-02 12:19
Cross post from the Pact Broker slack, but just note that if you?re using the hosted broker from http://pact.dius.com.au, it is already updated

heymega
2018-06-02 13:05
has joined #general

james.carman
2018-06-02 13:09
has joined #general

james.carman
2018-06-02 13:11
When doing pact verification, I want to spin up my provider locally, download all consumer pacts, and run them against my local instance?

james.carman
2018-06-02 13:13
Does that mean I?m mocking out any downstream services? If so, should these mocks be generating pacts for those downstream services also? Basically, do we have a cascading pact situation going on?

james.carman
2018-06-02 20:09
Is that the right pattern or should I verify against a ?deployed? instance of my provider?

hstene
2018-06-02 21:01
deployed

hstene
2018-06-02 21:03
If you want to mock away downstream services, then you are free to do so. That is what I am recommending in my projects as you want to escape the "integration test hell" that downstream services create.

james.carman
2018-06-02 21:04
@hstene so your recommendation is to do the ?cascading? I?m talking about?

james.carman
2018-06-02 21:04
I like that idea :slightly_smiling_face:

james.carman
2018-06-02 21:05
I mean, if you have to push your provider out to some deployment environment in order to verify the pacts against it, then aren?t you basically doing an ?end-to-end? test (the first end is just one less hop)?

james.carman
2018-06-02 21:06
I?m just trying to understand the best practices here, as I?m somewhat new to this world (and I love the idea)

hstene
2018-06-02 21:06
Who are these downstream services? Is it external APIs or services that you control?

james.carman
2018-06-02 21:06
services I control

james.carman
2018-06-02 21:07
Now, would the pact verification run be a bad time to establish new pacts for the downstream services?

james.carman
2018-06-02 21:08
Or, do I just do regular downstream mocks during the ?verify? run and then during my regular pact establishment run (whatever that is called) I publish my pacts against my downstream service?

james.carman
2018-06-02 21:08
Consider the case of Service A --> Service B --> Service C.

james.carman
2018-06-02 21:08
Service A runs some tests, establishing its ?pact? with Service B

james.carman
2018-06-02 21:09
Now, while I?m verifying Service A?s pact it published against Service B, would I publish my pact for Service C during that verify run?

james.carman
2018-06-02 21:09
Or, would that be a different build and I just use a regular (non-pact) mock of Service C during the verify run for Service B

james.carman
2018-06-02 21:09
I hope I?m making sense. I don?t know all the lingo yet I?m afraid :slightly_smiling_face:

hstene
2018-06-02 21:23
Ok, so in your scenario you have Service A that consumes B, and Service B consumes C. By having created a pact between Service B and Service C, you already have *a trusting relationship* with that provider. You already agree on both input and output data of all endpoints you are using. This trusting relationship is the key to this. When you are creating a new release of your service (Service A) you create a new pact and upload it to the broker. When deploying your new Service you run your integration tests to make sure that your service and Service B are communicating correctly. When Service B is getting a new release, it has to verify all pacts before creating the release. When running pacts, Service B *will not* need to talk to downstream service. Because Service B has a trusting relationship with Service C guaranteed by their pact.

hstene
2018-06-02 21:23
Did that answer your question? :thinking_face: (I am going to bed now, but if you have more questions I will answer them later)

matt.fellows
2018-06-02 22:05
So the recommended approach from the Pact team is the cascading pacts you talk about. The choice can then be how you stub the services in each case. This little gist helps explain the tradeoffs https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0

gaurav
2018-06-03 02:39
I have similar scenario and, for now, I just stub downstream services without pact (hard coded). For contract creation with those downstream services: I have another set of consumer tests. I don?t know whether its the best approach but it keeps things simple (1:1) and works for us fine as we are just using simple 1-2 endpoints of downstream services when running provider tests. The approach of using existing consumer tests to create pact and then create stub is interesting, I will definitely try it and see how it works, in case I have more complex mocking to do.

uglyog
2018-06-03 02:40
It is always best to have the test concentrate on a single integration point at a time

gaurav
2018-06-03 02:41
agree! keeps things simple and we quickly know where the breaking points are. :slightly_smiling_face:

james.carman
2018-06-03 21:53
@matt.fellows Thanks! I will take a look.

james.carman
2018-06-03 21:54
@hstene thank you for your info also. :slightly_smiling_face: I am just now getting back in here. Didn?t see the notification. Sorry

james.carman
2018-06-03 21:55
@gaurav so, you?re saying just do regular mocks while verifying Service B?s pacts? Just tell the WireMock (or whatever) what to do and don?t upload pacts?

gaurav
2018-06-03 23:53
@james.carman thats what I am doing currently. I am not in Pact Foundation Team though.. just a user :slightly_smiling_face:

uglyog
2018-06-03 23:56
You don't have to be in Pact Foundation Team to dispense good advice :smile:

bethskurrie
2018-06-04 00:13
@james.carman make sure that you have something to keep your regular mocks in sync with reality still. That gist Matt sent should give you some ideas how.

james.carman
2018-06-04 01:43
Thanks, guys and gals. This is great stuff. Good community vibe here!

gaurav
2018-06-04 01:47
Thanks. Just wanted him to know that I am not an expert and don?t know ins-outs :slightly_smiling_face:. Also as a user I am kind of new.. used it few months before for short time and now picked up again.. enjoying learning it more and more.

james.carman
2018-06-04 01:48
So, the pact team recommends the cascade method, but multiple community members say to just use regular ole service mocks?

james.carman
2018-06-04 01:50
I?m trying to digest this.

james.carman
2018-06-04 01:51
And to clarify, my ?cascade? terminology means that a service?s verify run yields new pacts for its downstream dependencies.

james.carman
2018-06-04 01:53
Are there perhaps scenarios that might lend themselves better to one approach over the other? Or is this just a general pattern?

james.carman
2018-06-04 01:55
Sorry if my questions are silly and I?m not trying to start a religious war here. Just trying to stand on the shoulders of giants so that I can provide informed guidance to folks at work.

james.carman
2018-06-04 02:01
This is a very interesting debate, though

bethskurrie
2018-06-04 02:36
No, I wouldn't recommend that your verify tests generate pacts for downstream services. That would be quite brittle. But, I do recommend that you ensure that your mocks are kept in sync with reality by using some shared artifact between the plain old mocks and your downstream pact tests. Otherwise, your "chain" has a break in it.

hstene
2018-06-04 05:09
Has there been given any consideration to what happens if a consumer publishes two pacts with conflicting response values from the same endpoint? Like if one field of the response has been renamed. Example: `Consumer v0.0.1 performs POST - /customer` Should return ``` { "status": 200, "headers": { "Content-Type": "application/json;charset=UTF-8" }, "body": { "name": "Roger Antonsen", "id": 0, "ssn": "71039012345" } } ``` Example: `Consumer v0.0.2 performs POST - /customer` Should return ``` { "status": 201, "headers": { "Content-Type": "application/json;charset=UTF-8" }, "body": { "socialSecurityNumber": "31129012345", "name": "Henrik Stene", "id": 0 } } ``` Right now I can never get my provider to verify the pacts as they are conflicting. How would I on the provider side handle this? Can I somehow ignore pacts with older version numbers?

bethskurrie
2018-06-04 05:11
Let's continue this in a thread.

bethskurrie
2018-06-04 05:12
With traditional versioning, you would release a major version with a renamed field. With CDC, you would add the field with the new name, transition all the consumers on to the new field, then, once your contracts showed you that everyone was using the new name, remove the old field.

hstene
2018-06-04 05:13
Ok, so if my consumer suddenly requires the field to be renamed (bad bad consumers) I should just add it?

bethskurrie
2018-06-04 05:13
how would you do it if you didn't have CDC?

hstene
2018-06-04 05:14
Heh, good question. Nothing would happen and all our developers would argue who?s fault it is? :smile:

bethskurrie
2018-06-04 05:14
sounds about right.

bethskurrie
2018-06-04 05:14
:stuck_out_tongue:

bethskurrie
2018-06-04 05:14
I would suggest that if a field needed to be renamed, you'd get together and talk about it first.

bethskurrie
2018-06-04 05:14
and you'd work out the impact

bethskurrie
2018-06-04 05:15
same with cdc.

hstene
2018-06-04 05:15
Yeah, but this is why CDC is such a great idea. It makes changes so apparent and visible!

bethskurrie
2018-06-04 05:15
cdc isn't a license for consumer teams to make up a wish list. it's a concrete artifact that should reflect the agreement that has already been made in person.

bethskurrie
2018-06-04 05:16
consumer teams shouldn't just arbitrarily rename a field.

hstene
2018-06-04 05:16
Unless you want to practice Consumer Driven Development. But that would also be agreed upon first (hopefully)

bethskurrie
2018-06-04 05:16
but if there is business justification for it, it give you a process to migrate everyone.

bethskurrie
2018-06-04 05:17
just because an API is driven by the requirements of a consumer, doesn't mean the consumer team gets to dictate everything :stuck_out_tongue:

bethskurrie
2018-06-04 05:17
"it's not dictator driven contracts" is one of our commonly used lines.

hstene
2018-06-04 05:18
Hah, nice quote! Will definitely use that

bethskurrie
2018-06-04 05:18
In answer to your original question, no there is nothing stopping people putting in conflicting expectations. But at least the conflict is made apparent to all.

hstene
2018-06-04 05:19
How do I remove a single pact from the broker?

bethskurrie
2018-06-04 05:19
http delete request




hstene
2018-06-04 05:20
So there is no ?quick key? in the broker? (Maybe to prevent people from just removing pacts?)

bethskurrie
2018-06-04 05:21
There's no quick key because 99% of the broker development is done by me, and I just don't have enough free time to make a pretty UI.

bethskurrie
2018-06-04 05:21
I figure if you're testing APIs, you can handle a HAL browser.

bethskurrie
2018-06-04 05:22
How's your Ruby? :wink:

bethskurrie
2018-06-04 05:22
(Actually, ideally, it could use a nice react UI)

hstene
2018-06-04 05:23
Hah, No Ruby or Rect on my part I?m afraid. Not yet anyway

hstene
2018-06-04 05:23
Thanks for your input!

bethskurrie
2018-06-04 05:24
Please do read the "Steps to reaching Pact Nirvana" doc (link above). It will answer some of your questions. I see you're doing a talk at NDC. Happy to help out with any questions you have.

hstene
2018-06-04 05:25
Will read it and yes I am. Thank you! :slightly_smiling_face:

shekharsp27
2018-06-04 13:06
Thanks @gaurav, however looks like pact-provider-verifier-docker is not capable of doing matching based on regex

gaurav
2018-06-04 13:07
never tried pact-provider-verifier-docker.. so can?t comment on that :slightly_smiling_face:

richard.peckett
2018-06-04 13:57
@bethskurrie Hi Beth, just following up your email are you saying there is now a .net implementation of PACT which can be used mock AMQP? Cheers

james.carman
2018-06-04 15:49
@bethskurrie so, to follow-up a bit. Do you suggest using the pact mocking system to set up my mocks for my verify run, but just not publish the generated pacts?

james.carman
2018-06-04 20:22
Do we have an updated AWS terraform script for PactBroker or are we focusing on the docker stuff these days?

james.carman
2018-06-04 20:23
I was trying to get it set up in our VPC, but it appears the terraform scripts are out of date a bit

matt.fellows
2018-06-04 21:56
We have a terraform script?

matt.fellows
2018-06-04 21:57
Ah, yes

matt.fellows
2018-06-04 21:57
We don?t maintain that script, it was something a community member created and was willing to share. It may not be up to date

matt.fellows
2018-06-04 21:57
You could look at http://pact.dius.com.au

shekharsp27
2018-06-05 04:26
:+1:

shekharsp27
2018-06-05 05:25
I am exploring "pact-provider-verifier-docker" and I have observed that is not doing matching based on regex. Am I missing something?

bethskurrie
2018-06-05 05:40
I guess you could. There are probably more fully featured http mocking solutions however.

bethskurrie
2018-06-05 05:41
I personally wouldn't use pact as a stub.

bethskurrie
2018-06-05 05:42
No, the underlying ruby code is done, and ready for a dot net dev to wrap the dot net code around it, as the http implementation does.

bethskurrie
2018-06-05 05:44
@shekharsp27 What version of the pact specification are your pacts?

shekharsp27
2018-06-05 06:31
@bethskurrie V3

bethskurrie
2018-06-05 06:31
Sorry, you'll need to use v2 pacts

bethskurrie
2018-06-05 06:32
We haven't implemented v3 matching yet

shekharsp27
2018-06-05 06:32
Ok, Thanks @bethskurrie

bethskurrie
2018-06-05 06:33
Or use the Java verifier


bethskurrie
2018-06-05 06:42
You don't need Ruby

bethskurrie
2018-06-05 06:42
Use the pact-provider-verifier command in that package. It may work with your v3 pacts.

bethskurrie
2018-06-05 06:43
that docker image is WAY out of date.

bethskurrie
2018-06-05 06:43
We should look at retiring it.

bethskurrie
2018-06-05 06:44
@matt.fellows should we make a new version of the verifier in pact-foundation with the nice pact-provider-verifier code?

bethskurrie
2018-06-05 06:44
That one uses the old way that you had to cobble together when I was on mat leave.

matt.fellows
2018-06-05 08:43
I think probably modernise it, people might have it in their build pipelines as docker steps. At the very least, a notice on the repo saying that its out of date

dlucas
2018-06-05 09:32
has joined #general

bethskurrie
2018-06-05 09:42
To make it match the current pact-provider-verifier, we'd need to make breaking changes, which makes me think it would be just easier to deprecate the dius one in favour of a new one in the pact-foundation

matt.fellows
2018-06-05 10:05
good point

richard.peckett
2018-06-05 18:09
this issue is still causing me problems :disappointed:

2018-06-05 22:17
A file, which can't be shown because your team is past the free storage limit, was commented on.

2018-06-06 00:11
A file, which can't be shown because your team is past the free storage limit, was commented on.

bethskurrie
2018-06-06 00:50
I'm surprised more people haven't complained

neil
2018-06-06 00:51
Yeah me too actually.

bethskurrie
2018-06-06 00:51
I don't know of any way to compress the file paths for the gems.

neil
2018-06-06 00:52
I?ll do a bit more investigation, and see what options we have. Path limits in windows is such a PITA!

bethskurrie
2018-06-06 00:52
Docker containers?

bethskurrie
2018-06-06 00:52
Or, same problem?

neil
2018-06-06 00:54
as in linux container running the ruby core?

bethskurrie
2018-06-06 00:56
I'm not sure.

bethskurrie
2018-06-06 00:56
Just throwing random technologies at it and seeing if anything sticks!

neil
2018-06-06 00:57
haha, nah it?s good to think of different options :smile:

neil
2018-06-06 00:57
Is anyone using the rust core? I think that would fix the issue

bethskurrie
2018-06-06 00:57
It would.

bethskurrie
2018-06-06 00:58
@uglyog can tell you. Though, I have had someone roll their eyes when discussing ffi bindings to rust on windows, so it may not be completely straightforward.

neil
2018-06-06 01:12
Yeah like a lot of things trade off one pain for another :stuck_out_tongue:

bethskurrie
2018-06-06 01:12
Sorry, realised we're not in a thread, and are spamming people.

bethskurrie
2018-06-06 01:12
Let's continue this here.

neil
2018-06-06 01:13
Oops :slightly_smiling_face:

bethskurrie
2018-06-06 01:13
If it was just the pact gems, I could try and rearrange the files inside the gems, but the error is coming up for bundler - something I don't control.

bethskurrie
2018-06-06 01:14
@richard.peckett what version of windows are you on?

neil
2018-06-06 01:17
Yeah totally understand, why you can?t change things

uglyog
2018-06-06 01:21
You should drop the ruby core, seems to be causing a lot of issues

uglyog
2018-06-06 01:23
The rust implementation is V3, you just need to work out how to interface to it

neil
2018-06-06 01:32
@uglyog Cool. Sounds like a fun experiment either way. Any docs you could point me to? Also is there any other impl using it yet?

uglyog
2018-06-06 01:32
There is a POC with the Swift implementation, but I don't know where that got to

uglyog
2018-06-06 01:38
A quick google seems that an FFI-based interface will be needed. I also found this: https://github.com/KodrAus/cargo-nuget

neil
2018-06-06 01:43
Nice. Yeah I looked into it a while back and there were a couple of FFI interfaces. The gotcha is making sure we can get .NET core compatibility, which has been quite painful in the past.


gaurav
2018-06-06 06:54
For windows 10 build 1607 onwards, a workaround on user side could be to disable max path using registry key/group policy: https://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29.aspx?f=255&MSPPError=-2147217396#maxpath

richard.peckett
2018-06-06 09:34
thanks for the replies guys @gaurav I'll give that a go in the meantime :thumbsup:

richard.peckett
2018-06-06 09:36
@bethskurrie Windows 10

kossling
2018-06-06 10:03
has joined #general

mboudreau
2018-06-06 10:08
@uglyog wait, the rust core is done?! Since when?


richard.peckett
2018-06-06 11:05
Still get the issue when I enable the long file path feature in windows 10, is there something I need to add the project file in Visual Studio to get this to work? :confused:

gaurav
2018-06-06 11:22
It does need a restart @richard.peckett as per the document. Windows typical :stuck_out_tongue_winking_eye:. Just in case you haven't done so.

richard.peckett
2018-06-06 11:22
Yeah I have done :disappointed: @gaurav

gaurav
2018-06-06 11:24
You can test whether it's actually enabled by trying to create a long path with CMD.

gaurav
2018-06-06 11:25
And it also needs at least build 1607.

richard.peckett
2018-06-06 11:30
build is on

richard.peckett
2018-06-06 11:31
when I run mkdir and enter a long file path I get the error "The filename, directory name, or volume label syntax is incorrect."

richard.peckett
2018-06-06 11:31
:neutral_face:

richard.peckett
2018-06-06 11:32
not sure what's going on

mboudreau
2018-06-06 11:54
@uglyog why didn't say so! that's massive news! I need to implement that in pact-node ASAP

matt.fellows
2018-06-06 12:39
@uglyog does this include provider side verification and the stuff we talked about? IIRC one if the primary reasons I didn't adopt it in Pact Go was that a) we had to generate the pact file (unlike how we work with Ruby) and b) the verifier interface hadn't been agreed on. Now that we have message pact, we can probably use the lessons from there

matt.fellows
2018-06-06 12:41
Don't forget we had a fully working Spike in Go, so it doesn't work! E.g. https://github.com/pact-foundation/pact-go/blob/feature/native/dsl/native/mock_server_darwin.go

james.carman
2018-06-06 15:29
Thank you, @bethskurrie

gbeckmann
2018-06-06 18:57
has joined #general

uglyog
2018-06-07 00:14
@matt.fellows there is a verifier, not no verifier language interface. That will come with the first language to interface to it. Maybe .Net is a good candidate.

matt.fellows
2018-06-07 00:48
I'm not sure what words you need from me to confirm that I've already interfaced to it and am ready :laughing:

kra
2018-06-07 06:41
has joined #general

raffi.schmid
2018-06-07 06:41
has joined #general

dervis4
2018-06-07 08:26
Hi guys, could you please guide me to information regarding what the best strategy for testing providers are? At the Norwegian LWA we test our providers against instances that are already deployed and running in Test-environments, however now I am looking into starting local instances of the providers instead. What is your recommendation?

hstene
2018-06-07 08:27
Hello again, Dervis! :slightly_smiling_face:

mboudreau
2018-06-07 08:54
Recommendation? The consumer of you data structure needs use pact to create a contract, that contract can then be shared with pact-broker to the provider (whatever gives the data), the provider, before it goes out to production, would then test to make sure it's not breaking the contract. After both are satisfied, they're not okay to deploy.

mboudreau
2018-06-07 08:54
that is the very very short version of it

hstene
2018-06-07 09:00
They are _not_ okay to deploy? Or did you mean that they _are_ okay?

dervis4
2018-06-07 09:00
We share Pact using the Pact Broker and also tag our deployed Pacts with Production. However, when Jenkins is building our Providers, it runs the Provider-test (using HttpTarget) against an already running instance in the Test-environment.

dervis4
2018-06-07 09:02
My question was more about - every build will then test against the previous version (sort of). I wanted to understand how this idea work when aiming to use the Pact-matrix.

mboudreau
2018-06-07 09:35
@hstene sorry, autocorrect. Meant to say now.



dervis4
2018-06-07 12:36
Thanks :+1:

richard.peckett
2018-06-07 17:40
Peeps, can someone explain to me how verify works? assuming I've started my provider service using something like: " var providerApi = WebHost.CreateDefaultBuilder(null) .UseStartup<Startup>() .UseUrls("http://localhost:9223") .Build(); await providerApi.StartAsync();" Does verify actual query the test server using the URI specified inside the PACT file it retrieves from the broker?

richard.jones
2018-06-07 22:58
has joined #general

matthew.ceroni
2018-06-07 23:28
has joined #general

matthew.ceroni
2018-06-07 23:32
Updated configuration of pact broker as such. But broker still isn?t ordering based on date. This shows in that newly tagged consumer versions, don?t show latest on the latest version.

bethskurrie
2018-06-07 23:33
the latest release of the pact broker has a more elegant solution to the webhooks vulnerability found recently. You will now be able to configure a whitelist to ensure webhooks can only be execute against "safe" hosts. You can read about how to configure the whitelist [here](https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/webhooks.markdown#webhook-whitelist)

2018-06-07 23:45
A file was commented on

biaofu
2018-06-08 02:23
has joined #general

mmonson
2018-06-08 03:03
has joined #general

peter.odonovan
2018-06-08 03:30
has joined #general

mikey
2018-06-08 03:31
has joined #general

peter.odonovan
2018-06-08 03:31
:wave:

sam.jarrett
2018-06-08 03:32
has joined #general

niek
2018-06-08 07:13
has joined #general

nic
2018-06-08 08:33
has joined #general

richard.peckett
2018-06-08 09:23
@neil cheers Neil :+1::skin-tone-2:

oliver.gramberg
2018-06-08 09:38
has joined #general

bethskurrie
2018-06-08 09:52
Welcome everyone.

mr.matt.r.long
2018-06-08 13:44
has joined #general

gonzalogarcia243
2018-06-08 14:58
has joined #general

snatarajan
2018-06-08 16:38
has joined #general

rlamb
2018-06-08 17:09
has joined #general

matt.fellows
2018-06-09 04:01
:wave:

daniel.delatorrebabi
2018-06-10 10:38
has joined #general

daniel.delatorrebabi
2018-06-10 10:46
Hello guys, I am having some issues when I try to execute gradlew pactVerify from my provider.

daniel.delatorrebabi
2018-06-10 10:48
My jetty server starts correctly but the process gets stuck when it is executing pact:pact-spring-provider:startProvider

daniel.delatorrebabi
2018-06-10 10:49
it seems that it never goes to my pactbroker server to verify the pact

daniel.delatorrebabi
2018-06-10 10:49
any idea about this?

bethskurrie
2018-06-10 11:15
Hi Daniel. Try the pact-jvm channel. I believe there is a way to switch on debug logs for the pact verify, have a look at the docs.

daniel.delatorrebabi
2018-06-10 11:22
Thanks for the answer Beth, I will do

matt
2018-06-11 01:35
has joined #general

bethskurrie
2018-06-11 11:42
Hi I've just released a new version of the Docker Pact Broker image, with environment variables to configure the new webhooks whitelist. Please remember to upgrade to the latest version ASAP if you haven't already to ensure you are not susceptible to the webhooks vulnerability that was found recently. In other news, I've added a heap of new parameters to the webhooks templates that now make it possible to send pact verification status updates to github. Check out the Webhook template library to see how this is done https://github.com/pact-foundation/pact_broker/wiki/Webhook-template-library

mr.matt.r.long
2018-06-11 13:44
Hi is anyone able to confirm if the matchers for header Content-Type values perform a full match including charset value? I'm currently seeing a validation error my my jvm provider for the header matcher `application\\/json` throwing the error `Expected 'application/json; charset=utf-8' to match 'application\\/json'`

mr.matt.r.long
2018-06-11 13:46
Sorry I see the fix for partial matching is included in 3.5.17: https://github.com/DiUS/pact-jvm/commit/f7d73250c3986c812459d9ada3677fbdd14693e3. I'm currently running 3.5.16

vinod.baradwaj
2018-06-12 09:46
Has anyone implemented Pact in their pipeline jobs? I am planning to make use of Pacts as a stub in place of the real provider to perform acceptance tests for my application.. and also as part of the pipeline i need to do the provider verification as well with the pact files to be sure that the contract is not broken. Can anyone provide me a heads up on how to start working on the flow for this pipeline ?



bethskurrie
2018-06-12 10:17
Be aware of the fact that the higher level you use your pact tests for, the more fiddly and higher maintenance they become. Pact is generally best for unit tests, not acceptance tests.


bethskurrie
2018-06-12 10:19
You can re-use the pact that you generate in unit tests to make a stub, but you may have problems with the exact matching https://github.com/pact-foundation/pact-mock_service#stub-service-usage

bethskurrie
2018-06-12 10:20
Generally, the higher level the tests, the more flexible you want your matching.

vinod.baradwaj
2018-06-12 10:25
thanks @bethskurrie for mocking stuff i wont be needing much matchers since i can control the flow of data, and can make sure that the data remains unchanged every time the tests are executed. The reason why i am planning to make use of stubs is to speed up my AT's. if i have to rely on actual provider, it takes me more than 15 mins to bring up the environment.

dominic.jones
2018-06-12 11:51
@vinod.baradwaj we?ve taken the approach you?re talking about and it seems to be working pretty well so far. You definitely have to be careful about the implicit coupling you create between different types of test. We?ve created common fixtures that we draw from to run our pact unit tests (and therefore create the pacts) and to use in our ?acceptance? tests (running against a stub server generated from pacts). That at least makes it clear that there is coupling there, though can still be a bit fiddly

dominic.jones
2018-06-12 11:56
Hello! This is a slightly lazy question, but is it a know problem that publication fails if one tries to publish the verification result for the same pact twice. I am getting a rather gnarly db error being spat out when we publish a verification from our Java provider side tests (using the Junit runner) ``` {"message":"PG::UniqueViolation: ERROR: duplicate key value violates unique constraint \"verifications_pact_version_id_number_index\"\nDETAIL: Key (pact_version_id, number)=(66, 181) already exists.\n","backtrace":["/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:166:in `async_exec'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:166:in `block in execute_query'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/database/logging.rb:49:in `log_connection_yield'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:166:in `execute_query'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:153:in `block in execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:129:in `check_disconnect_errors'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:153:in `execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:514:in `_execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:326:in `block (2 levels) in execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:536:in `check_database_errors'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:326:in `block in execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/database/connecting.rb:301:in `block in synchronize'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/connection_pool/threaded.rb:103:in `hold'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/database/connecting.rb:301:in `synchronize'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:326:in `execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/dataset/actions.rb:1081:in `execute'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/postgres.rb:679:in `fetch_rows'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/dataset/actions.rb:942:in `with_sql_each'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/dataset/actions.rb:950:in `with_sql_first'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/adapters/shared/postgres.rb:1607:in `insert_select'","/home/app/pact_broker/vendor/bundle/ruby/2.2.0/gems/sequel-4.48.0/lib/sequel/model/base.rb:2165:in `_insert_select_raw'" ``` (whole error available on request)

dominic.jones
2018-06-12 12:24
ah, ignore that, I accidentally deployed the old pact-broker (pact_broker)

drhansen
2018-06-12 19:25
has joined #general

tlane
2018-06-12 20:58
has joined #general

bethskurrie
2018-06-12 21:44
I can see you've thought it through @dominic.jones. Glad it's working for you.

bethskurrie
2018-06-12 22:15
@dominic.jones is there anything we could do to make it clearer that that one is deprecated?

bethskurrie
2018-06-12 22:16
There's a message in the UI, and the readme, but obviously it's still possible to install it unintentionally.

abhilash.hanumanth
2018-06-13 01:56
I have an array of strings of variable length which is expected in response body. For example : ```"{ Conditions":[ "conditionA", "conditionB", "conditionC" ] }``` How do I use stringType() or stringMatcher() for generalizing while creating pact using LambdaDsl ? Can someone help me with the above problem ?

bethskurrie
2018-06-13 01:57
@abhilash.hanumanth can you ask in pact-jvm please? It makes it easier to find relevant answers.

bethskurrie
2018-06-13 01:58
Please indicate which documentation you have read already, and if there is something missing, let us know which section you would expect it to be in.


vinod.baradwaj
2018-06-13 04:24
@dominic.jones can you share me flow of your process so that i can understand and get an idea how the flow will be ?

dominic.jones
2018-06-13 05:42
I noticed when I loaded it up and saw the UI message, so that was good. Not sure what else you could do without breaking things for people. Maybe add something to logging? But that could be a big faff

dominic.jones
2018-06-13 05:44
@vinod.baradwaj I can try. What would work best? Maybe if I just try to describe in more detail how our process works? I?m busy just now but should have some time later today (I?m in London)

vinod.baradwaj
2018-06-13 05:59
sure, let me know once you are free :slightly_smiling_face:

dominic.jones
2018-06-13 06:13
What time zone are you :slightly_smiling_face: ?

vinod.baradwaj
2018-06-13 06:13
I am from India, IST

zwttgsmu
2018-06-13 08:02
has joined #general

zwttgsmu
2018-06-13 08:07
Hello everyone!)

bethskurrie
2018-06-13 08:09
:wave:

zwttgsmu
2018-06-13 08:10
I want to make a check that an array can contain strings or null Found solutions for Java: "It would also be required to define whether the matchers should be combined with logical AND (all matchers must match) or OR (at least one matcher must match). AND should be the default, but there are cases where an OR makes sense. { "matchingRules": { "header": { "HEADERY": { "combine": "AND", "matchers": [ {"match": "include", "value": "ValueA"}, {"match": "include", "value": "ValueB"} ] } } } }" How can I do this in .NET?

bethskurrie
2018-06-13 08:10
You can't. That functionality is, I believe, being deprecated in the next version of Pact JVM

bethskurrie
2018-06-13 08:11
Let me find the explanation.


bethskurrie
2018-06-13 08:14
Also, the functionality you're describing is in the Pact Specification version 3, and pact net is only up to version 2.

bethskurrie
2018-06-13 09:00
Hopefully someone in the pact-jvm channel can help. Unfortunately, I haven't written or used it, so I'm out of advice!

zwttgsmu
2018-06-13 10:48
Thank you) one more question)) I check for type integer, but in the logs I see an error: -"param1": Bignum +"param1": Fixnum in Google I found such a description: The problem is that FixNum is a platform-dependent type. Ruby automatically switches from FixNum to BigNum if the number becomes bigger than native integer(which has different length on 32-bit and 64-bit platforms). So if you just want to check whether it's an integer you should use Integer for it. For example: timestamp = Time.now.to_i #bad timestamp.is_a? FixNum timestamp.is_a? BigNum #good timestamp.is_a? Integer how can I test this without error?

bethskurrie
2018-06-13 11:40
Can you recreate the issue using this project, and I'll fix the problem in the underlying code https://github.com/pact-foundation/pact-ruby-standalone-e2e-example

matt
2018-06-13 18:12
i'm wondering if we should disable `@` here and `@` channel for regular users.

matt
2018-06-13 18:12
i think slack provides a configuration option to make those admin only

jsyrinek
2018-06-13 23:12
has joined #general

jsyrinek
2018-06-13 23:14
Should we test third-party API's regularly using our consumer contracts?

bethskurrie
2018-06-13 23:15
Pact is not great for testing third party APIs. It assumes you're able to set up provider states without having to use the API you're actually testing.

matt.fellows
2018-06-13 23:16
Thanks for reminding me, this is done :white_check_mark:

bethskurrie
2018-06-13 23:16
Each interaction is tested in isolation, which is fine when you can manipulate the pre-existing data, but not great if you need to set up the data using an API.

jsyrinek
2018-06-13 23:18
That makes sense, but to be clear, my question is more about ensuring that the third-party continues to provide the data our (consuming) application depends on. I'm not asking if we should hit a real API to verify our application/consumer.

jsyrinek
2018-06-13 23:19
Obviously we don't control the third-party API, but if the third-party ever stops providing the things we need, we would want to know.

bethskurrie
2018-06-13 23:19
Indeed. I'm not sure what tool I'd recommend in this situation. If I was using Ruby, I'd use something like VCR.

bethskurrie
2018-06-13 23:19
I don't know what exists in other languages.

jsyrinek
2018-06-13 23:20
I've used yakbak

jsyrinek
2018-06-13 23:20
which is the Javascript analog of VCR, but I'm not sure how to use that in this situation.

bethskurrie
2018-06-13 23:25
I'd probably have a build that ran the live tests regularly and reported if there was a change in the response.

jsyrinek
2018-06-13 23:26
That's what we're thinking as well. And we're thinking of hitting a real API (maybe with Yakback/VCR to mask over third-party outages) then validating using our consumer contract.

jsyrinek
2018-06-13 23:28
We're having a conversation at the office about when/if we should take this approach. In our case, we have a good working relationship with the third-party, so if the contract ever changes, we have a way to address that. I think if we didn't have a relationship like this, we may not take this approach. For instance, if Twitter was the third-party API, we probably can't stop them from changing what they provide. In that case, we should just build the application in a way that it can handle changes gracefully and/or setup alerts when things break so we can take swift action.

jsyrinek
2018-06-13 23:28
I think this thought process is somewhat explained in the bullet points in the FAQ, but you kind of have to piece ideas together.

jsyrinek
2018-06-13 23:29
It might be a good idea to add two recommendations for working with third-party APIs: one for providers that can/will make changes if requested, and one for providers that would not.

bethskurrie
2018-06-13 23:32
That's a good suggestion.

bethskurrie
2018-06-13 23:33
How do you feel about writing those thoughts down and doing a PR to the FAQ page?

jsyrinek
2018-06-13 23:35
I could take a stab at that

bethskurrie
2018-06-13 23:41
That would be greatly appreciated.

matt
2018-06-14 02:57
thank you :simple_smile: now i won't get randomly pinged by people

matt.fellows
2018-06-14 03:15
:slightly_smiling_face:

jonas.lergell
2018-06-14 07:12
has joined #general

oswald.quek
2018-06-14 09:51
has joined #general

dominic.jones
2018-06-14 09:52
we?ve got a bit confused about versions and tags. We version our pacts using the git sha of the consumer code used to produce it. However, as per your docs, the pacts are ordered according ?semver? of version. Obviously this then leads to arbitrary ordering of pacts in our case. If we then want to retrieve the ?latest? (chronologically speaking) pact for a given tag, we seem to be stuck. There is something in your docs about changing a config flag to change how pacts are ordered, but a) we use your docker image b) I?m not sure if this would solve our problem Any suggestions?


bethskurrie
2018-06-14 09:56
Oh, right, the docker version.

dominic.jones
2018-06-14 09:56
and do I have ?access? to that config if I?m using your docker image?

dominic.jones
2018-06-14 09:56
snap

bethskurrie
2018-06-14 09:56
You know what, I've been meaning to change the default any way.

bethskurrie
2018-06-14 09:56
Hang about.

dominic.jones
2018-06-14 09:56
it?s not configurable via env var I assume?

bethskurrie
2018-06-14 09:57
You can insert a config in the db.

bethskurrie
2018-06-14 09:57
But I'll just change it

dominic.jones
2018-06-14 09:58
wow, thanks!

bethskurrie
2018-06-14 10:13
grab 2.22.0-2 when it's built

bethskurrie
2018-06-14 10:13
you'll need to publish another completely new version after you've upgraded to trigger the reordering

dominic.jones
2018-06-14 10:15
ok, great. Thanks very much

bethskurrie
2018-06-14 10:16
np

dominic.jones
2018-06-14 12:16
it works and everything :simple_smile:

bethskurrie
2018-06-14 21:10
Like a shop bought one!

rcheeniyil
2018-06-14 22:26
has joined #general

rcheeniyil
2018-06-14 22:49
Hi there, I see the following warning on verify step: `WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body']` this happens in all tests where each_like is used for type matching array elements in pact-ruby (gem says version 2.7.6). Is this expected behavior or is there some way to use each_like that does not result in this warning?

bethskurrie
2018-06-14 22:50
I'm really sorry - you can ignore that error. It's a very tricky bit of logic to get rid of it, and I just haven't had the brainspace to fix it.

bethskurrie
2018-06-14 22:50
It's all working fine though.

rcheeniyil
2018-06-14 22:50
ya it has expected behavior the warnings are sort of piling up though

rcheeniyil
2018-06-14 22:51
```WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body']['child_events'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body'] WARN: Ignoring unsupported matching rules {"min"=>1} for path $['body']```

abe
2018-06-15 02:24
has joined #general

omar10594
2018-06-15 02:24
has joined #general

rob.lugton
2018-06-15 02:24
has joined #general

rob-manger
2018-06-15 02:24
has joined #general

rholshausen
2018-06-15 02:24
has joined #general

raul.garcia
2018-06-15 02:24
has joined #general

raghunandanjahagirdar
2018-06-15 02:24
has joined #general

prudhvi
2018-06-15 02:24
has joined #general

pivison
2018-06-15 02:24
has joined #general

phil
2018-06-15 02:24
has joined #general

pfajardo
2018-06-15 02:24
has joined #general

paul.davidson
2018-06-15 02:24
has joined #general

patrick
2018-06-15 02:24
has joined #general

ngbrown
2018-06-15 02:24
has joined #general

sai.dileepjana
2018-06-15 02:24
has joined #general

mzacharska
2018-06-15 02:24
has joined #general

mouser
2018-06-15 02:24
has joined #general

mngau
2018-06-15 02:24
has joined #general

mlk
2018-06-15 02:24
has joined #general

mhargiss
2018-06-15 02:24
has joined #general

mende
2018-06-15 02:25
has joined #general

mellis
2018-06-15 02:25
has joined #general

matthewcanty
2018-06-15 02:25
has joined #general

mattfaries
2018-06-15 02:25
has joined #general

mattcoder
2018-06-15 02:25
has joined #general

abhijeet.daspatnaik
2018-06-15 02:25
has joined #general

matt.canty
2018-06-15 02:25
has joined #general

marcevers
2018-06-15 02:25
has joined #general

rolyat.wilson
2018-06-15 02:25
has joined #general

sdulebskiy
2018-06-15 02:25
has joined #general

m.groeneweg
2018-06-15 02:25
has joined #general

timbailey
2018-06-15 02:25
has joined #general

zac.sims
2018-06-15 02:25
has joined #general

willmadison
2018-06-15 02:25
has joined #general

w.everse
2018-06-15 02:25
has joined #general

vinny
2018-06-15 02:25
has joined #general

vijaynag
2018-06-15 02:25
has joined #general

veganjenny
2018-06-15 02:25
has joined #general

v.lukoyanov
2018-06-15 02:25
has joined #general

trenthornibrook
2018-06-15 02:25
has joined #general

travi
2018-06-15 02:25
has joined #general

tom.vanasch
2018-06-15 02:25
has joined #general

tmok01
2018-06-15 02:25
has joined #general

tmcknight
2018-06-15 02:25
has joined #general

tigris
2018-06-15 02:25
has joined #general

shahzadahmad
2018-06-15 02:25
has joined #general

theresa
2018-06-15 02:25
has joined #general

thadir
2018-06-15 02:25
has joined #general

sumit080
2018-06-15 02:25
has joined #general

sudhapatil3
2018-06-15 02:25
has joined #general

stuparty
2018-06-15 02:25
has joined #general

stein
2018-06-15 02:25
has joined #general

sinclair.calleja
2018-06-15 02:25
has joined #general

siaynoqmage
2018-06-15 02:25
has joined #general

shenahas
2018-06-15 02:25
has joined #general

sheetal
2018-06-15 02:25
has joined #general

shashidesai
2018-06-15 02:25
has joined #general

sharding
2018-06-15 02:25
has joined #general

shamilton
2018-06-15 02:25
has joined #general

m.pleijte
2018-06-15 02:25
has joined #general

zerocooljs
2018-06-15 02:25
has joined #general

lukvermeulen
2018-06-15 02:25
has joined #general

eskimoquinn
2018-06-15 02:25
has joined #general

bangn
2018-06-15 02:25
has joined #general

giuseppe.landolfi575
2018-06-15 02:25
has joined #general

areddy
2018-06-15 02:25
has joined #general

aserafim
2018-06-15 02:25
has joined #general

giuseppe.landolfi
2018-06-15 02:25
has joined #general

lkingsley
2018-06-15 02:25
has joined #general

gareth
2018-06-15 02:25
has joined #general

fpelletier
2018-06-15 02:25
has joined #general

fkoner
2018-06-15 02:25
has joined #general

fitzoh
2018-06-15 02:25
has joined #general

finkingma
2018-06-15 02:25
has joined #general

fergusstrange
2018-06-15 02:25
has joined #general

ecoan
2018-06-15 02:25
has joined #general

harryw
2018-06-15 02:25
has joined #general

dniles
2018-06-15 02:25
has joined #general

divs.kanna
2018-06-15 02:25
has joined #general

d.van.dijk
2018-06-15 02:25
has joined #general

cornelia.zintl
2018-06-15 02:25
has joined #general

cormac
2018-06-15 02:25
has joined #general

coco
2018-06-15 02:25
has joined #general

claire.thomson
2018-06-15 02:25
has joined #general

cass
2018-06-15 02:25
has joined #general

asfan.siddiqui
2018-06-15 02:25
has joined #general

beth
2018-06-15 02:25
has joined #general

berisberis
2018-06-15 02:25
has joined #general

benjamin.l.tse
2018-06-15 02:25
has joined #general

gtondi
2018-06-15 02:25
has joined #general

andycampbell92
2018-06-15 02:25
has joined #general

icapurrofagian
2018-06-15 02:25
has joined #general

kanchana
2018-06-15 02:25
has joined #general

lihongmei
2018-06-15 02:25
has joined #general

liam.fisher
2018-06-15 02:25
has joined #general

acooper106
2018-06-15 02:25
has joined #general

lardcanoe
2018-06-15 02:25
has joined #general

kunwardeep
2018-06-15 02:25
has joined #general

krishnaraj.krishnan
2018-06-15 02:25
has joined #general

kong
2018-06-15 02:25
has joined #general

alexei
2018-06-15 02:25
has joined #general

king-smith
2018-06-15 02:25
has joined #general

kevinkraus
2018-06-15 02:25
has joined #general

kevin.meiresonne
2018-06-15 02:25
has joined #general

j03w
2018-06-15 02:25
has joined #general

ken.westdorp
2018-06-15 02:25
has joined #general

kale.mcnaney
2018-06-15 02:25
has joined #general

kabagchi87
2018-06-15 02:25
has joined #general

james
2018-06-15 02:25
has joined #general

jdbann
2018-06-15 02:25
has joined #general

jeanmarclai
2018-06-15 02:25
has joined #general

jeffutter
2018-06-15 02:25
has joined #general

andrew.nicholson
2018-06-15 02:25
has joined #general

jfeng
2018-06-15 02:25
has joined #general

alok.pandey
2018-06-15 02:25
has joined #general

joel_a
2018-06-15 02:25
has joined #general

jsilver
2018-06-15 02:25
has joined #general

gaurav
2018-06-15 03:42
Does anyone have some experience to share using swagger-request-validator-pact? https://bitbucket.org/atlassian/swagger-request-validator/src/master/swagger-request-validator-pact/ From the looks of it, it looks like quite simpler way of achieving CI of contract tests (in organisations using swagger).

shekharsp27
2018-06-15 05:40
Yeah, it verifies pact contract against Swagger specification and enables contract checking from Consumer side as well. It also provides capabilities to enable checks on Response missing required field,Response has the incorrect type for a field among others thought validations are lenient and can control using properties

gaurav
2018-06-15 05:43
seems like worth giving a try. :slightly_smiling_face:

shekharsp27
2018-06-15 05:52
:+1:

bethskurrie
2018-06-15 06:17
I'll try and get back to it soon.

vk.regs
2018-06-15 08:02
has joined #general

gxsham
2018-06-15 12:03
has joined #general

adamgreen
2018-06-15 13:54
has joined #general

santoshtrip
2018-06-15 17:55
This was something great

santoshtrip
2018-06-15 17:55
@shekharsp27 thanks for sharing this earlier with me

minhdoan
2018-06-16 08:53
Hi team,

minhdoan
2018-06-16 08:54
I face an stuck described in the ticket https://github.com/DiUS/pact-jvm/issues/704

minhdoan
2018-06-16 08:54
Any help is highly appreciated!

minhdoan
2018-06-16 08:54
Many thanks

dsbenghe
2018-06-17 16:26
has joined #general

jonas.lergell
2018-06-18 09:25
Hey, im using the pact broker docker image, getting response code 405 when posting to /webhooks, but /webhooks/provider.... works, does the docker image currently not support creating global webhooks?

bethskurrie
2018-06-18 10:33
Nope. I haven't released that yet.

bethskurrie
2018-06-18 10:34
It's on master, but I have to finish off bit more before it can be released. Try again tomorrow.

bethskurrie
2018-06-18 10:34
The gem itself hasn't been released.

bethskurrie
2018-06-18 11:37
@jonas.lergell I've just released a version of the docker image tagged `edge` with the latest code from the repo (not a released gem). There's a known bug if you try and execute a test request (by POSTing to `/webhooks/UUID/execute`) for global webhooks, or ones that have just a consumer or provider, but they execute correctly during normal operation.

jonas.lergell
2018-06-18 11:47
Awesome! Thx

mats.lundkvist
2018-06-18 11:50
has joined #general

mats.lundkvist
2018-06-18 11:56
Hi, I'm using pact ruby standalone and pact-go to write consumer tests in golang but it looks like the generated json file is wrong ```"metadata": { "pactSpecification": { // this is should be pact-specification right? "version": "3.0.0" } }``` Is this an issue or am I just using it wrong?

bethskurrie
2018-06-18 11:56
Version 3 is not yet supported

bethskurrie
2018-06-18 11:57
Oh, the format of the JSON

bethskurrie
2018-06-18 11:57
No, it's the right format. @uglyog needs to update the jvm impl.

mats.lundkvist
2018-06-18 11:58
ok, so the jvm impl will get an update?

bethskurrie
2018-06-18 11:59
It was supposed to a year ago :-P

mats.lundkvist
2018-06-18 11:59
haha okey, I'll inform the people I work with, thanks for the help :smile:

bethskurrie
2018-06-18 11:59
We ended up with about 3 different formats, and I just made the ruby code read it from all three!

bethskurrie
2018-06-18 12:00
It's an embarrassing shemozle.

matt.fellows
2018-06-18 12:22
Out of interest, which bits are you using pact ruby standalone for?

mats.lundkvist
2018-06-18 12:28
what do you mean?

matt.fellows
2018-06-18 13:07
OH, have you just installed them on the command line as per the instructions? I for some reason had the impression you were explicitly using some of the tools (e.g. manually running provider tests or something)

matt.fellows
2018-06-18 13:07
all good if you?ve just added them to the path :thumbsup:

mats.lundkvist
2018-06-18 13:07
okey good :slightly_smiling_face:

adrian.flucus
2018-06-18 14:45
has joined #general

uglyog
2018-06-18 23:51
Sigh, just checked the JVM code, and I didn't fix it as well as I thought :pensive:

bethskurrie
2018-06-18 23:53
I had the thought last night, I could always fix it in the broker. But that wouldn't help pacts exchanged outside the broker.

uglyog
2018-06-18 23:54
I'm going to change it now, but I have a suspicion that the code will just change itself back

bethskurrie
2018-06-18 23:55
It's obviously got gremlins in it.

vk.regs
2018-06-19 07:00
Hi, A am trying to verify request with null field values on consumer pact tests, but pact Framework return error for such field. How can I process such cases? "description": "A request to get export data", "request": { "method": "patch", "path": "/api/export/data", "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "CState": { "ConceptId": 0, }, "FileName": null } }

2018-06-19 07:05
A file, which can't be shown because your team is past the free storage limit, was commented on.

vk.regs
2018-06-19 07:07
@bethskurrie thanks, It is .net, sorry

matt.fellows
2018-06-19 07:12
np

james.carman
2018-06-19 21:28
When I verify my pact, it prints out the ?returns a response which? part twice. I only specify 1 request

james.carman
2018-06-19 21:32
Would a github link help?


james.carman
2018-06-19 21:38
I am creating a demo ?org? for doing this pact testing.




uglyog
2018-06-19 23:24
Could you raise an issue at the github site for that?

uglyog
2018-06-19 23:48
Oh, there is already an issue raised: https://github.com/DiUS/pact-jvm/issues/706

james.carman
2018-06-20 01:10
It doesn?t really bother me, per se. I was more worried I was doing something wrong. Thanks for the heads-up.

james.carman
2018-06-20 01:30
I?m going to submit a patch for it.

uglyog
2018-06-20 01:35
already fixed it :smile:

james.carman
2018-06-20 01:36
dang it! I wanted to contribute and this one was easy

james.carman
2018-06-20 01:36
oh well

james.carman
2018-06-20 01:37
I would have been done faster, but the wifi here at starbucks is slow and downloading Gradle was taking forever.

james.carman
2018-06-20 01:38
I changed it to: for(i in 0 until runTimes)

james.carman
2018-06-20 01:38
what did you do @uglyog?


james.carman
2018-06-20 01:40
that?d work too

djrimokbp
2018-06-20 07:54
has joined #general

santoshtrip
2018-06-21 01:03
I was trying to convert the project to gradle

santoshtrip
2018-06-21 01:03
But facing some challenges consumer.consumer.SwaggerValidatorPactConsumerTest > testGetOrderWithInvalidResponse FAILED java.lang.NoSuchMethodError: au.com.dius.pact.model.MockProviderConfig.createDefault(Lau/com/dius/pact/model/PactSpecVersion;)Lau/com/dius/pact/model/MockProviderConfig; at au.com.dius.pact.consumer.PactProviderRule.<init>(PactProviderRule.java:51) at au.com.dius.pact.consumer.PactProviderRule.<init>(PactProviderRule.java:110) at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.<init>(ValidatedPactProviderRule.java:33) at consumer.consumer.SwaggerValidatorPactConsumerTest.<init>(SwaggerValidatorPactConsumerTest.java:42) consumer.consumer.SwaggerValidatorPactConsumerTest > testGetOrderWithAdditionalPropertiesInResponse FAILED java.lang.NoSuchMethodError: au.com.dius.pact.model.MockProviderConfig.createDefault(Lau/com/dius/pact/model/PactSpecVersion;)Lau/com/dius/pact/model/MockProviderConfig; at au.com.dius.pact.consumer.PactProviderRule.<init>(PactProviderRule.java:51) at au.com.dius.pact.consumer.PactProviderRule.<init>(PactProviderRule.java:110) at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.<init>(ValidatedPactProviderRule.java:33) at consumer.consumer.SwaggerValidatorPactConsumerTest.<init>(SwaggerValidatorPactConsumerTest.java:42)

santoshtrip
2018-06-21 01:04
at @Rule public ValidatedPactProviderRule provider = new ValidatedPactProviderRule(SWAGGER_JSON_URL, null, PROVIDER_ID, this);

santoshtrip
2018-06-21 01:04
for the consumer tests

santoshtrip
2018-06-21 01:05
@shekharsp27 do you know what could be the potential issue

shekharsp27
2018-06-21 05:51
@santoshtrip Please check your pact version as mentioned in this issue https://github.com/DiUS/pact-jvm/issues/456

shekharsp27
2018-06-21 13:24
Hi, In case there is no change in pact content, is there a automated way to trigger can-i-deploy utility from consumer side or does the consumer team has to trigger the job manually

matt.fellows
2018-06-21 13:31
what are you trying to do?

james.carman
2018-06-21 14:14
I gave a talk about PactBroker at our local Cincinnati Java User Group yesterday and folks seemed really interested. Thanks for all your help while I prepared for the talk, guys (and gals)!

james.carman
2018-06-21 14:15
@matt.fellows are you the same ?Matt? that answers the emails about the hosted PactBroker?

matt.fellows
2018-06-21 21:13
That's awesome! (And yes)

shekharsp27
2018-06-22 05:49
Hi Matt, Thanks for your reply. As mentioned in wiki https://github.com/pact-foundation/pact_broker/wiki/Webhooks#example-cicd-and-webhook-configuration. If the changes in consumer side does not affect the contract( pact content has not changed), so its in pre verified state; in this case how I'll trigger can-i-deploy utility automatically in consumer pip-line or in this case consumer has to trigger this check manually

matt.fellows
2018-06-22 09:23
You might need to give us more context and what you?re trying to do, though. If a new consumer contract is being published, presumably the consumer is the one publishing it, so why do you need something to trigger the `can-i-deploy` utility? It should just be a step in the consumer pipeline. If nothing has changed from a contract point of view, `can-i-deploy` will return true

madhukar.mishra
2018-06-22 09:37
has joined #general

wchuang
2018-06-22 16:30
has joined #general

james.carman
2018-06-22 16:51
@matt.fellows I might want to set up a PB account for my personal email also. Is that something I need to fill out another form for?

0xorial
2018-06-23 11:23
has joined #general

0xorial
2018-06-23 11:36
Hi! I am here following up this: https://github.com/pact-foundation/pact-specification/issues/59#issuecomment-399667103 . From what I understood, pact is going to use shared ruby core approach, which is not something I like - it is slow and difficult to debug (especially since I use debugging as a learning tool). I would prefer to have a clear specifications and implementations for different platforms (v2 specs seems to require only around 1 week of work to implement). Hence I started my own port (https://github.com/0xorial/PactNetCore). Perhaps there is something else I should know?

bethskurrie
2018-06-23 11:37
Hi ironic. The wrapped ruby implementation is going to be replaced by a shared Rust implementation, which will be called via FFI. This means there will only be ONE implementation for all the "business logic" of pact, which can be easily shared to all the other languages.

bethskurrie
2018-06-23 11:38
If you want to contribute to this effort, learning about the Rust implementation and how to make FFI calls would be the best use of your time.

bethskurrie
2018-06-23 11:39
@neil who is the current .net maintainer would be the person to talk to about this, as well as @uglyog who has written the rust implementation.

bethskurrie
2018-06-23 11:39
I know how much work goes into creating a pact implementation, and I do not recommend starting from scratch!

0xorial
2018-06-23 11:40
hm....

bethskurrie
2018-06-23 11:40
We are always keen to have people who want to contribute on the team however!

0xorial
2018-06-23 11:41
I am still quite optimistic about making a new implementation. The one I have now seems to cover a lot of cases already. mostly it doesn't work on some annoying cases like null/empty matching

bethskurrie
2018-06-23 11:41
Which pact-specification version are you targeting?


bethskurrie
2018-06-23 11:42
v2 is quite simple. v3 is where it gets hard. it's why I've only done v2 in the ruby impl :stuck_out_tongue:

0xorial
2018-06-23 11:42
well, the goal is get to v3 - we started the whole thing because we needed to test messages

bethskurrie
2018-06-23 11:42
I've been too busy to pick up the v3 stuff.

0xorial
2018-06-23 11:42
xD damn

bethskurrie
2018-06-23 11:43
message support in .net should be quite simple with the ruby impl

bethskurrie
2018-06-23 11:43
we've already wrapped it in the go and js

0xorial
2018-06-23 11:43
I will think about it... I still dont feel well about including binaries into packages...

bethskurrie
2018-06-23 11:43
unfortunately our .net maintainer has been busy moving state, so he hasn't had a chance to pick it up

bethskurrie
2018-06-23 11:43
none of us like the solution!

bethskurrie
2018-06-23 11:44
but it's been a pragmatic solution to the problem of trying to support so many different languages.

bethskurrie
2018-06-23 11:44
it's quite unusual for a library to have to do that.

0xorial
2018-06-23 11:44
let me have a closer look at v3...

bethskurrie
2018-06-23 11:44
it's a dirty hack, but it's got us a long way. hopefully it can be retired soon.

bethskurrie
2018-06-23 11:45
if message pact is what you're really after, I can explain how to wrap that.

bethskurrie
2018-06-23 11:45
it shouldn't be a big amount of work.

0xorial
2018-06-23 11:46
wait, are you talking about wrapping specifically ruby in the package? because for me it is wrapping binaries in general, be it ruby, rust or js

0xorial
2018-06-23 11:47
well, if we can go with your 'recommended' solution and get it to support messaging, my managers/architects will definitely be happy :slightly_smiling_face:

bethskurrie
2018-06-23 11:47
It has it's problems, but they are fewer than trying to keep 7+ implementations of pact in sync. It's hard enough keeping the java and ruby one compatible.

0xorial
2018-06-23 11:48
hm, isn't it because you don't have a strict spec ?

bethskurrie
2018-06-23 11:48
The spec is not all there is to it.

bethskurrie
2018-06-23 11:49
There is a lot of behaviour in the mock service and the writing of the pacts and the verifications that is not pact of the matching spec.

bethskurrie
2018-06-23 11:49
Matching is the easiest part to enforce.

bethskurrie
2018-06-23 11:50
Yes, we could go through and nut out documentation for every part of pact, but we'd prefer to share the code.

0xorial
2018-06-23 11:51
I see :slightly_smiling_face: well, if you say it should be easy to add messages support to .net wrapper, this sounds like best way to go..

0xorial
2018-06-23 11:52
So far we tried this port (https://github.com/Mattersight/pact-net-messages/) separately for messages but there is no matching at all in it...


0xorial
2018-06-23 11:53
> About time, hey? yes! :grinning:

bethskurrie
2018-06-23 11:54
@matt.fellows is the person who has done the js message impl

bethskurrie
2018-06-23 11:54
If you're comfortable reading javascript, looking at that implementation may help you

0xorial
2018-06-23 11:58
great! I will give a try on Monday :slightly_smiling_face: thanks for all the information!

bethskurrie
2018-06-23 11:58
No worries.

borkke
2018-06-23 13:13
has joined #general

santoshtrip
2018-06-23 22:50
Can someone help me explain the benefits of doing pact validation using swagger request validator vs pact verification by replaying the interaction against a live instance (full blown application)

santoshtrip
2018-06-23 22:50
Trying to weigh both of them

matt.fellows
2018-06-23 23:12
Yes please

matt.fellows
2018-06-23 23:15
@0xorial the reason for using a shared component is so that we can continually push out new features and changes quickly across all implementations.we used Ruby for a number of reasons and has been a good choice IMO. Writing it from scratch will likely take you more than 1 week, and as soon as you need to implement v3 and v4 it gets harder.

matt.fellows
2018-06-23 23:16
We understand Ruby isn't ideal, and that is why we invested in building a proper shared library in Rust


matt.fellows
2018-06-23 23:18
This is the future core engine for all official implementations. If you have the time, we'd love to see you spend it getting that in the current pact net impl rather than create another

matt.fellows
2018-06-23 23:20
Bah, didn't see this thread until I answered similarly in general.

matt.fellows
2018-06-23 23:22
Anywho, adding Rust to .net is not like adding a binary, it's a shared library which is totally different. It would be like importong C Git if you needed to link to that. Trust me, writing this yourself is non trivial. Ron, who has done it several times already and has been involved with pact for years, took a long while to get it into Rust with all of the versions supported

matt.fellows
2018-06-23 23:23
As for pact message and here and now, you could definitely get that working in a couple of days with the current wrapper. I'd be happy to have a Hangouts to describe how it currently works


neil
2018-06-24 10:00
Sorry just saw this. Yeah more than happy to help with getting more support, however as Beth said my free time is very limited at the moment. Ideally we want to move to using the Rust impl, but that is going to take a bit of discovery. The ruby integration at the moment is a stepping stone (hopefully) to something a bit easier to support, debug and maintain

neil
2018-06-24 10:01
We (Pact-Net) originally had a native implementation of the v1 spec, however as we started adding more features it became a real burden to try keep up. That?s why we though moving to a shared core would make sense.

santoshtrip
2018-06-24 19:48
Can we consider contract testing as a replacement for integration testing ?

santoshtrip
2018-06-24 19:49
Whats the advantage of having both rather than one over the other

matt.fellows
2018-06-24 21:56
@santoshtrip to some extent yes you might consider it as replacement for end to end integrated tests, however there are good reasons to have integrated tests in certain circumstances and the answer is "it depends". Things you might consider alongside contract tests are blue green deploys, Canary releases, small batch sizes, continuous delivery, understand as code etc

matt.fellows
2018-06-24 21:56
They all push and pull on the overall test strategy.

matt.fellows
2018-06-24 22:03
One appropriate strategy and my general recommendation is to do the bulk of your integrated test using tools like pact and then supplement your release process with a very small subset of end to end integrated tests - potentially in your blue green env - and that gives you confidence that everything is wired together correctly (i.e. tests your config)

david.j.smith
2018-06-25 09:08
@matt.fellows Do we have a best practice for handling Origin headers in Pact JS? The browser adds the Origin header automatically to an XHR request, so they aren't part of the explicit contract from the consumers perspective. Thoughts?

mboudreau
2018-06-25 09:21
Unless your contract cars about it, don't add it

david.j.smith
2018-06-25 09:28
Well the contract from the consumer side doesn't, and the origin is never explicitly added because it's done by the browser automagically ...but the server requires it. Hence, the origin header will always be sent, but there is no JS code that actually adds the header.

david.j.smith
2018-06-25 09:29
We could add the header explicitly, but that's not technically correct. If you see what I mean.

david.j.smith
2018-06-25 09:29
It's an edge case, but I thought our JS folks must have come across this :slightly_smiling_face:

mboudreau
2018-06-25 09:41
Most people don't care about origin on the backend since it can get spoofed, and no logic should really depend on it

shekharsp27
2018-06-25 10:06
Currently I am trying to incorporate CDC tests in CI pipeline. I have taken following approach 1) I have 4 containers i) Creates pact by executing unit tests & publish pacts to pact-broker ii) Provider application container to run provider application iii) Verify container to verify contract iv) can_i_deploy container to check published results are fine 2) I have created CDC and published those to pact broker, have created webhooks to trigger provider application & verify step (I am checking the application is up and running before executing this step) if there is a content change in pact (by using 'contract_content_changed' for both the steps) and one for when results are published (can_i_deploy) container (by using 'provider_verification_published') 3) This mechanism works well if there is a change in pact content, as webhooks does the job for me 4) However in case there is no change in pact content. I am trying to find-out way, how I can get information that, webhooks from pact broker are not triggered and have to trigger can_i_deploy container by skipping other steps. Please correct me if I am missing something

bethskurrie
2018-06-25 11:18
I would put it in Dave, if it affects behaviour.

bethskurrie
2018-06-25 11:19
If the server requires it.

matt.fellows
2018-06-25 11:35
I would lean towards adding it if you actually have logic on your server side for CORS headers, and not otherwise. In most places as Michel notes it's not really important

matt.fellows
2018-06-25 11:36
It's a good point tho, I think it's not documented anywhere but a related issue on GH

matt.fellows
2018-06-25 11:45
We'll, the whole point of triggering on contract changed means that it only triggers if it changes. You can use that information to your advantage.

matt.fellows
2018-06-25 11:47
My advice is to have one pipeline for your consumer and another for your provider. Each pipeline is simple: build, run tests, publish pacts, can-i-deploy, deploy.

matt.fellows
2018-06-25 11:47
The can-i-deploy step in each pipeline will take care of itself. No need to trigger builds from webhooks.

matt.fellows
2018-06-25 11:48
If a build goes red, it means something went into the mainline before it was added to the provider, or it broke a consumer. Simple

david.j.smith
2018-06-25 12:36
Thanks all :thumbsup:

cfmack
2018-06-25 21:24
Playing with Pact Broker, I think one cannot use both a tag and a consumer version. Can anyone confirm this is true?

matt.fellows
2018-06-25 21:48
What do you mean, Charles?

matt.fellows
2018-06-25 21:49
They are both first class citizens in the broker and they can (and should) definitely be used together. The can-i-deploy tool relies on these to help you make a decision on which bits are deployable at any point in time

santoshtrip
2018-06-26 01:22
Sharing my question again

bethskurrie
2018-06-26 05:14
Hey Charles. A tag belongs to a pacticipant version.

bethskurrie
2018-06-26 05:14
Let me find the docs.


bethskurrie
2018-06-26 05:17
There's also a great doc on versioning in the broker on http://docs.pact.io

shekharsp27
2018-06-26 06:09
@matt.fellows Thank you!!

shilkumarjadhav
2018-06-26 14:54
has joined #general

cfmack
2018-06-26 19:12
That is what I thought. I do not think we can answer the question that is asked on https://github.com/pact-foundation/pact-php/issues/76#issue-328007239 I think this works: GET /pacts/provider/PROVIDER/consumer/CONSUMER/latest/TAG That GET would retrieve the latest version of this consumer-provider pair with the latest version of the consumer that has this tag. My question is a GET like: GET /pacts/provider/PROVIDER/consumer/CONSUMER/version/VERSION/TAG Get me a particular version of this consumer with this tag and this provider. I cannot see the use case where this would apply, as if you know the version of the CONSUMER, what does the tag matter? Perhaps there is some odd use case like a policy verification step that says all pacts must be tagged a certain way ... super weird use case. To revisit the question: GET /pacts/provider/PROVIDER/consumer/CONSUMER/version/VERSION/TAG This does not make sense to be use together based on my understanding of TAGS. Is that correct?

cfmack
2018-06-26 19:44
Thanks, Matt. My question was poorly worded and missing context. It was one of those times where I had been thinking about it for quiet a while in a particular github issue and that did not translate to my Slack question. There's a thread about it with more background.

matt.fellows
2018-06-26 21:29
:slightly_smiling_face:

matt.fellows
2018-06-26 21:31
If your team uses swagger as its format and potentially publishes it to 3rd parties outside of your company (e.g. who won?t use Pact) then it?s a really nice way to guarantee the contract is valid

matt.fellows
2018-06-26 21:32
in addition to that, lots of companies seem to use Swagger internally to document/communicate things, create tooling/stubs, so doing both gives you the benefits of both pact and swagger

spai
2018-06-27 09:26
has joined #general

kuo-tai.hwang
2018-06-27 20:45
has joined #general

bethskurrie
2018-06-27 21:46
Yes @cfmack. You either retrieve a pact by consumer version number, or by latest tag. Not both.

kristine.jetzke
2018-06-27 22:08
has joined #general

kristine.jetzke
2018-06-27 22:21
Hi @mr.matt.r.long I have a question regarding the `can-i-deploy` command. I have a consumer foo in version 1 and two providers bar and baz. The provider bar has two versions, a and b. Both are tagged with the tag `prod`. Version b is the lastest one. Only version a has a successful verification with the consumer. The other provider has one version tagged with prod and it successfully verified the consumer version 1. If I now run ```can-i-deploy -a foo -e 1 --to prod``` I would expect the command to fail because version 1 was not successfully verified against version b of the provider bar (the latest prod). But what happens instead is that the command succeeds and displays only one line in the result, for the other provider, baz. I assume this happens because the matrix contains no row for consumer version 1 and latest provider tag prod. Is that the expected behavior or is it a bug?

bethskurrie
2018-06-27 22:24
Hi @kristine.jetzke. I can help you with this. I need to draw up a diagram to understand it properly though.

kristine.jetzke
2018-06-27 22:25
thanks!

kristine.jetzke
2018-06-27 22:25
I can try to send sreenshots, I need to change names though

kristine.jetzke
2018-06-27 22:28
I'm still using pact broker 2.17.1

bethskurrie
2018-06-27 22:28
I'm just recreating your scenario as a test and seeing what I get. Give me a few minutes.

bethskurrie
2018-06-27 22:32
Did the verification for bar version b fail, or does it not exist?

kristine.jetzke
2018-06-27 22:33
it does not exist

bethskurrie
2018-06-27 22:34
How does it have a version that is tagged with prod in the broker then?

bethskurrie
2018-06-27 22:34
provider versions only get created when a verification is published.

bethskurrie
2018-06-27 22:34
Is there another consumer involved?

kristine.jetzke
2018-06-27 22:38
it's a strange setup. maybe that's the problem. the provider has an old version 0.0.0 (i will use the real ones now, otherwise I get confused.). This was tagged with prod at some point. during our regular provider build job we add new provider versions and tag them with prod once they are deployed to prod. The current prod version is 95.0. We now added a new contract for the consumer and it was verified again against version 0.0.0. 0.0.0 is still tagged with prod, but it's no longer the latest (because 95.0 is the latest)

bethskurrie
2018-06-27 22:38
I think you're using an old version of pact jvm.

bethskurrie
2018-06-27 22:39
You shouldn't have verifications for 0.0.0.

bethskurrie
2018-06-27 22:40
Also, you may have semantic version ordering turned on. Change this to date ordering https://github.com/pact-foundation/pact_broker/wiki/Configuration#ordering-versions-by-date

kristine.jetzke
2018-06-27 22:40
But even if I upgrade now, i still have them in the broker?

bethskurrie
2018-06-27 22:40
Yes, we still have to work out the data issue.

kristine.jetzke
2018-06-27 22:40
I'm already using date ordering

bethskurrie
2018-06-27 22:40
Cool.

kristine.jetzke
2018-06-27 22:42
i'm using 3.5.17 i can try upgrading to 3.5.18

bethskurrie
2018-06-27 22:43
That's a side issue

bethskurrie
2018-06-27 22:43
``` CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? ---------|-----------|----------|-----------|--------- foo | 1 | baz | z | false ```

bethskurrie
2018-06-27 22:43
Is that what you get?

bethskurrie
2018-06-27 22:44
No, it isn't.

kristine.jetzke
2018-06-27 22:44
if i only have one provider, the check fails because it cannot find any pacts

kristine.jetzke
2018-06-27 22:44
but if there is another provider that passes, everything passes

bethskurrie
2018-06-27 22:45
I need to be able to recreate the issue, and I don't think I have yet.

kristine.jetzke
2018-06-27 22:47
i can try setting up some data and a script with the pact commands

kristine.jetzke
2018-06-27 22:47
and file a bug in github, i just wanted to know first if this is expected behavior before doing all that

bethskurrie
2018-06-27 22:48
I'm not sure if your data is just dodgy, or if there is a problem.

kristine.jetzke
2018-06-27 22:48
me neither...

bethskurrie
2018-06-27 22:48
> and it was verified again against version 0.0.0. You definitely need to get rid of these.

bethskurrie
2018-06-27 22:48
These are in there because you're verifying from your local dev machines.

kristine.jetzke
2018-06-27 22:48
ok i can delete the tag and try to recreate the issue.

kristine.jetzke
2018-06-27 22:48
yes

kristine.jetzke
2018-06-27 22:48
and no

kristine.jetzke
2018-06-27 22:48
also because the provider didn't set any version

bethskurrie
2018-06-27 22:48
You should only be verifying from CI. The latest version of pact jvm requires that you explictly turn on verification publishing.

kristine.jetzke
2018-06-27 22:49
in their build job

kristine.jetzke
2018-06-27 22:49
yes i just saw

kristine.jetzke
2018-06-27 22:49
i will change it as well

bethskurrie
2018-06-27 22:49
So you can ensure you're only publishing verifications from "clean" code on your CI.

bethskurrie
2018-06-27 22:49
Yes, delete the prod tag on 0.0.0.

bethskurrie
2018-06-27 22:49
In fact, see if you can delete the version entirely.

kristine.jetzke
2018-06-27 22:50
Ok, I will do it and try to recreate the issue without it. Tomorrow though because it's after midnight where I live. Thanks for your help :slightly_smiling_face:

bethskurrie
2018-06-27 22:51
No worries. I may not be able to help tomorrow, but if you decide it's a bug, raise an issue in the pact_broker project, with all the information needed to recreate the issue, and I'll have a look at it when I can.

bethskurrie
2018-06-27 22:51
Unfortunately, I'm the only person who knows this code.

kristine.jetzke
2018-06-27 22:52
oh no :disappointed:

santoshtrip
2018-06-28 01:40
@Beth do you know if we have a way to publish verification to the pact broker

santoshtrip
2018-06-28 01:40
As in Java command


santoshtrip
2018-06-28 01:41
Mostly from junit classes

matt.fellows
2018-06-28 01:41
JVM has this capability, have you looked at the JVM docs?

santoshtrip
2018-06-28 01:42
Nope

matt.fellows
2018-06-28 01:43
cool, please do and then let us know if you still have questions

kristine.jetzke
2018-06-28 07:50
Hi again, I can't delete the complete version. I get a foreign key violation because there are still verification results. I did delete the prod tag though but it didn't change anything. What is the best way to create an example? Is there a public pact broker somewhere where I can publish the results?

bethskurrie
2018-06-28 07:51
Ah, my bad with the FK.

bethskurrie
2018-06-28 07:51
I may have fixed that in the latest version.

bethskurrie
2018-06-28 07:51
Yes, there is a public broker, I'll get you the creds

bethskurrie
2018-06-28 07:52
Broker user: dXfltyFMgNOFZAxr8io9wJ37iUpY42M Broker password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1


kristine.jetzke
2018-06-28 07:52
I just upgraded the pact broker to 2.23.3

kristine.jetzke
2018-06-28 07:52
thanks

bethskurrie
2018-06-28 07:52
I'll raise an issue for deleting provider versions

kristine.jetzke
2018-06-28 08:00
thanks

kristine.jetzke
2018-06-28 13:07
I have created an example to reproduce the issue. The code is here https://github.com/tinexw/pact-broker-example. The matrix is here: https://test.pact.dius.com.au/matrix/provider/de.tine.bar/consumer/de.tine.foo and here: https://test.pact.dius.com.au/matrix/provider/de.tine.baz/consumer/de.tine.foo The output from the last can-i-deploy command is: ``` bin/pact-broker can-i-deploy -a de.tine.foo -e 3.0.0 --to prod Computer says yes \o/ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? ------------|-----------|-------------|-----------|--------- de.tine.foo | 3.0.0 | de.tine.baz | 20.0.0 | true All verification results are published and successful ``` In the matrix the last version of de.tine.foo is 3.0.0 which was not verified against the latest prod version of de.tine.bar. I think the cause is that I published a new prod version with an already existing version which I probably shouldn't. But I still think that the can-i-deploy command should fail in this case. Maybe someone deploys an older version to prod because they need to do a rollback or they simply misconfigured something.

kristine.jetzke
2018-06-28 13:09
@bethskurrie This is the screenshot from the broker

daniel.kirmse
2018-06-28 16:46
has joined #general

daniel.kirmse
2018-06-28 16:50
Hi, don't where to put this. Can someone tell me a best practice to check multiple consumers against the same contract? Obviously I do have a provider that has to fulfill the contract and I do have several client implementations to comply to the same contract to. I'm done with the first client and got my pact file. How would I use this pact file to develop the other clients (different languages) against this w/o duplicating the interactions for them? Is pact supposed to be used in such a way anyway? Thanks

ssn899
2018-06-28 17:53
has joined #general

matt.fellows
2018-06-28 20:43
@daniel.kirmse each client has its own contract with the provider. It's possible for the clients to evolve over time differently such that they have different needs. Importantly, there are key periods in the application lifecycle where you'll want to make changes to one of them, which is where pact willl help you thru

mboudreau
2018-06-28 22:55
@daniel.kirmse to further matt's point, if you have 2 consumers with the same contract, there's no reason not to use the same code to create the contract between the two consumers :)

bethskurrie
2018-06-29 00:30
@daniel.kirmse here is a FAQ on why you don't use an already generated pact file for another consumer https://docs.pact.io/faq#can-i-generate-my-pact-file-from-something-like-swagger

daniel.kirmse
2018-06-29 06:54
Thanks! I was suspecting this :slightly_smiling_face: I?m fine with this and would support the argument for different contracts too. The code reuse is not possible as the clients are basically a client lib for a remote server (think of proxy pattern) and they are written in python and go and have to have the very same behavior for otherwise I would have introduced an inconsistency. On the other hand having two contracts would enable me to catch up major server changes (new API version) for one client after the other with the ?old? contract still in place for the one client that has to wait (? or never will catch up for it doesn?t need the new API capabilities). Okay, fine, thanks!

davidmichaelkarr
2018-06-29 23:47
has joined #general

davidmichaelkarr
2018-06-30 00:23
I'm pretty new to pacts, but I understand the basic concepts. I see that our organization is using version 3.3.9 of pact-jvm, which is over a year old. Is anyone aware of the version history well enough to say whether there are some particular strong arguments for upgrading to a more recent release?

bethskurrie
2018-06-30 02:36
Yes. The verification publishing has been changed to be off by default, so that verification results are not accidentally published from a dev machine.

bethskurrie
2018-06-30 02:37
This is an important upgrade if you wish to use the pact verification statuses for determining when it is safe to deploy the consumer.


uglyog
2018-06-30 02:39
3.3.9 only supports V2 spec pacts, 3.5.x is full V3

uglyog
2018-06-30 02:40
3.5.x also has JUnit 5, Spring and Java 8 support

davidmichaelkarr
2018-06-30 13:57
can you tell me some important good diffs between v2 and v3 specs?

davidmichaelkarr
2018-06-30 13:59
what does not having java 8 support in 3.3.9 mean exactly? I assume that refers to java 8 features in the pact expression. can you give an example?


slack1409
2018-07-01 08:46
has joined #general

slack1409
2018-07-01 08:53
I saw, that you did merge a Pull Request today https://github.com/DiUS/pact-jvm/pull/721 which I am quite interested in. When do you plan on releasing versoin 3.5.19 which will probably contain the code in this Pull Request? Thx

uglyog
2018-07-01 08:54
Just kicked off the release script. 3.5.19 should be available in maven central in a few hours.

slack1409
2018-07-01 08:55
Great. Thx a lot :slightly_smiling_face:

deshdeepdivakar
2018-07-01 09:35
has joined #general


matthew
2018-07-02 06:07
Need some guidance: I've got an API in Rails that our front end runs pacts against. That API also makes calls out to other APIs that are currently tested with VCR. Any best practices here? The problem we seem to be running into is having the APIs that the API hits be stubbed out when Pact verifies.

can
2018-07-02 09:28
has joined #general


matt.fellows
2018-07-02 10:08
FWIW I usually stub out deps during verify. I find it easier. What's the specific issue you're having?

cve-anton
2018-07-02 10:41
has joined #general

cve-anton
2018-07-02 10:43
Hello guys, I'm going to install (on AWS) Pact for the first time, could you please tell me what platform should I choose?

cfmack
2018-07-02 12:59
I use the docker container provided by Pact Foundation, PostGres PAAS, and EKS

gradzio
2018-07-02 20:53
has joined #general

gradzio
2018-07-02 20:55
hey guys, i am working with pact and i managed to upload my pact file to pact broker (http://pact.dius.com.au) but after that I am not able to upload a new file again. No matter what i get 401 - anyone can help please?

matt.fellows
2018-07-02 21:32
Hi @gradzio there are separate read and write users. Perhaps you're using the read only user account? How did the first contract get in?

elliot.chen7
2018-07-02 21:36
has joined #general

elliot.chen7
2018-07-02 21:56
Hi, I?ve been doing research and I?m struggling to decide how pact fits with grpc calls? I?m using Go in a very new micro service environment. I?m trying to find best practices for integration and/or contract testing. I really like Pacts approach to provider states and was wondering if it was good enough reason to use it. Does anyone have experience with this?

elliot.chen7
2018-07-02 21:56
@matt.fellows suggested I ask here :slightly_smiling_face:

elliot.chen7
2018-07-02 21:59
So far I have been following this approach: https://medium.com/namely-labs/how-we-build-grpc-services-at-namely-52a3ae9e7c35 Each microservice designs it?s .proto defs. They are automatically built and commited in a centralised repo that can been used as a client for other services that communicate with it.

elliot.chen7
2018-07-02 21:59
I?m afraid we?ll lose track of what service communicates with who, etc.

gaurav
2018-07-03 03:14
Hello.. Would `pact-jvm-model:3.5.16` work with both scala version 2.11 and 2.12? Thanks.

gradzio
2018-07-03 07:33
that is right Matt! how could I have missed that? thank you i was using dev account

gradzio
2018-07-03 07:34
it would be nice to get 403 instead of 401 that would lead people into solution

matt.fellows
2018-07-03 09:13
You Probably a good point there

rcheeniyil
2018-07-03 16:11
Hi, Is there support for multipart/form data in Pact Ruby and if so is there any example sitting around? What I've found so far is a post for JVM/JS versions of pact: https://github.com/DiUS/pact-jvm/issues/123

matt.fellows
2018-07-03 21:39
@rcheeniyil same answer for Ruby basically

rcheeniyil
2018-07-03 21:39
do you know if it has to be formatted one line or something weird because I haven't had that working yet

matt.fellows
2018-07-03 21:43
I'm not sure sorry. But as noted in that issue it's possible between JS and JVM (JS uses Ruby under the hood, so that bit is definitely supported)

matt.fellows
2018-07-03 21:44
I would use that example as your starting point

rcheeniyil
2018-07-03 21:49
alrighty ty!

matt.fellows
2018-07-03 21:53
:+1:

ssn899
2018-07-03 22:53
To add onto @elliot.chen7's question, is grpc contract testing in Pact's timeline? If so, has there been any work/progess yet? I would love to contribute to or start the effort.

elliot.chen7
2018-07-03 22:58
Same, I would like to contribute. I'm fairly new to the concept so I just need a little guidance

bethskurrie
2018-07-03 23:01
Hi @rcheeniyil there isn't explicit support, however, it wouldn't be too hard to do it.

bethskurrie
2018-07-03 23:02
What exactly would you want to assert about the file?

bethskurrie
2018-07-03 23:04
As @matt.fellows says, if you can do it in js, you can do it in Ruby, because the js uses the ruby under the covers.

bethskurrie
2018-07-03 23:04
Have you tried doing it as per the example?

matt.fellows
2018-07-03 23:18
Thanks @ssn899 and @elliot.chen7. What language are you using (I know Go is in the mix).

matt.fellows
2018-07-03 23:19
The reason I ask, is that we probably need to do some spikes before we know what it is that we can and more importantly, _should_ do.

ssn899
2018-07-03 23:19
Currently, I am using Pact-JVM.

matt.fellows
2018-07-03 23:19
The latest implementation in Pact JS/Go for message support is protocol/transport agnostic, so in theory could support gRPC. But there are still open questions about the value it provides.

matt.fellows
2018-07-03 23:19
awesome

ssn899
2018-07-03 23:20
But I am pretty flexible

matt.fellows
2018-07-03 23:20
I would think a white paper (in the form of a gist like https://gist.github.com/bethesque/c858e5c15649ae525ef0cc5264b8477c) stating the problem space would be a starting point

matt.fellows
2018-07-03 23:20
we can then collaborate in the open on some technical spikes that might guide implementation

ssn899
2018-07-03 23:21
I can create that

matt.fellows
2018-07-03 23:21
that?d be great!

elliot.chen7
2018-07-03 23:22
@ssn899 let me know how I can help

elliot.chen7
2018-07-03 23:22
@matt.fellows only go for me at the moment

matt.fellows
2018-07-03 23:22
cool, thanks

rcheeniyil
2018-07-03 23:27
not exactly as per example but i've taken generated code from postman and I'm getting a null response for a post I'll take another look at it on thursday and reply here. I'll try to follow the example more thoroughly on my next attempt.

ssn899
2018-07-03 23:29
https://gist.github.com/SnewsButton/91901ac8a0ea63c474ac673457d05e45 here is just a stub for the gist. Feel free to post comments on what exactly needs to be done.

rcheeniyil
2018-07-03 23:30
my `will_respond_with` response assertion is just a json body that worked when I was doing requests with a json body instead of a multipart nothing else is being asserted at this time

rcheeniyil
2018-07-03 23:31
I'll do another round of attempts I just figured I'd ask about it here before throwing too much time at the problem since it doesn't seem to be a common use case

matt.fellows
2018-07-03 23:32
@matt.fellows pinned a message to this channel.

matt.fellows
2018-07-03 23:32
awesome, thanks

matt.fellows
2018-07-04 03:54
I?ve added a couple of thoughts of how we might go about doing it just now (gists don?t get notifications sadly).

liran.tal
2018-07-04 18:56
has joined #general

liran.tal
2018-07-04 18:57
hola amigos! :wink:

liran.tal
2018-07-04 18:57
congrats on your new home

bethskurrie
2018-07-04 22:12
Hi @liran.tal!

bethskurrie
2018-07-04 22:13
Welcome

bethskurrie
2018-07-04 22:13
Much better than gitter

paisrikanth
2018-07-05 02:13
has joined #general

paisrikanth
2018-07-05 02:16
Hey Guys I get this error "Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)" When I try to do pactPublish from build gradle file

paisrikanth
2018-07-05 02:18
plz help

matt.fellows
2018-07-05 02:25
@paisrikanth hello, please try in #pact-jvm and also, you?re going to need to provide more detail (see https://coderanch.com/wiki/659862/Show-Effort)

liran.tal
2018-07-05 05:22
yep!

liran.tal
2018-07-05 05:22
thanks

liran.tal
2018-07-05 05:49
we are refactoring some of our devops and pact patterns flows and I wanted to run a draft plan by you and get some feedback: ``` Consumer ????? PR FLOW: -> Build step -> Run contract tests (we do this as integration tests, I know the docs suggest unit) -> Pact contracts are created -> Pact contracts are pushed to broker (can we push on an existing version? will it override the existing contract of the same version?) -> Identifying the contract with: - Consumer name - Provider name - Version: is the build number - Tag: build -> CI step -> Download the Pact contract from the previous step of the build based on: - Consumer name - Provider name - Version: the build number is passed from the build step to the CI step - Tag: build -> Use the pact contracts to spin up mocked providers using docker pact runner -> Perform Backend E2E tests -> Successful build THEN PR IS MERGED TO MASTER MASTER JOB FLOW BEGINS: -> Build Step ? same as for PR -> CI step ? same as for PR -> If CI succeeds - Increment version for app (tag container image, publish to docker hub, etc) - Publish to Pact Broker with: - Consumer name - Provider name - Version: the app incremented version number - Tag: development NOTES: * We tag the contract as 'development' because the contract may not yet be implemented and we don't want to break the build for the provider. * We accept that tagging it as 'production' (meaning its available on prod) is a manual process that requires clear communication to do so. Provider: -> Build step ? nothing relevant to the contract to be done here -> CI step -> Download the Pact contracts of all of my consumers - Consumer name - Provider name - Version: latest - Tag: production -> Run provider contract tests verification (ensure all contract integrations are not broken) -> Successful verification per contract updates the broker ```

bethskurrie
2018-07-05 05:52
Looks pretty sane. I've got a few questions. What is your version number format?

bethskurrie
2018-07-05 05:53
> can we push on an existing version? will it override the existing contract of the same version? Yes. Yes. Not recommended. Ideally, you should have a unique version number for each pact publication, ideally using or including the git sha if possible. I'll find you a link on this.


bethskurrie
2018-07-05 05:59
For your PRs, you say, the tag is the build - what does that mean?


fergusstrange764
2018-07-05 10:26
has joined #general

zwttgsmu
2018-07-05 14:32
Hello! I run the test on the provider side, the error is displayed: JSON::ParserError: A JSON text must at least contain two octets! as I understood, this is because the response is not in json format Does the pact compare non-json formats? or what is the way to solve this problem?

liran.tal
2018-07-05 20:25
1. we follow semver so our version number format is going to be that. But what I was thinking to use during the build step is that version will be set to the build number: i.e just a simple `159` if that?s the current build number because the published contract to the broker at that point is only used so it can be then downloaded for the CI step and used as a stub with pact runner for the E2E. At that point the contract also doesn?t mean anything. Only when we press the merge button to merge a PR to the master branch then we follow the same testing phase and at that point after CI we do increment version and publish it. so the version being the build number is also because you can have multiple PRs open at the same time. And also the app version doesn?t mean anything, like if I had `v1.1.1-build159` then v1.1.1 doesn?t convey anything because the PR can be open for a week and by that time the version in my `package.json` is obsolete since master is now at `v2.0.0`

liran.tal
2018-07-05 20:27
2. as for ``` can we push on an existing version? will it override the existing contract of the same version? ``` I asked this because it is possible that someone might re-run the PR by actually going to jenkins and restart the build it?s probably an edge case.

liran.tal
2018-07-05 20:31
3. when I publish a contract from the build step to the CI step I tag it as `build` just for semantics, as it doesn?t have any other meaning or purpose (the version number is also the build number so the contract is not really conveying anything important at that point). once `master` successfully finishes CI then we increment a version, set that version in the contract, and tag is as `development` which is semantic again but conveys more meaning at this point.

liran.tal
2018-07-05 20:33
4. will read that article, thanks for sharing! what I really miss is some recipes for devops integration for making CDC happen. there are many deployment and source code versioning strategies (github flow/tbd/etc) where that recipe will change to adapt different workflows.

matt.fellows
2018-07-05 20:53
It can compare non JSON but there are two caveats - the first is that catching rules don't work and it will be comparing by string equality. The second is that you'll need to set the correct content-type so that the framework knows it's media type


bethskurrie
2018-07-06 05:18
@liran.tal I'm working on an idea that will allow "wip" (work in progress) pacts to be verified without actually breaking the provider's build. A "wip" pact would be one with content that has not yet been successfully verified. This means that a consumer could publish a changed pact and get feedback on whether or not it passes, without breaking the provider's build. Once it has successfully been verified, it would be up to the consumer team to promote it to one of the tags that is officially supported by the provider (eg "master", "prod") that _would_ break the providers build.

bethskurrie
2018-07-06 05:19
This also means that any merged branch from the consumer should never block at can-i-deploy, because the pact content should be pre-verified.

vinod.baradwaj
2018-07-06 06:16
@liran.tal we are trying out a similar pipeline in my organisation with pact. Also @dominic.jones has done that

kra
2018-07-06 13:02
Hello Pact community! I just had a lively discussion with a coworker. Since we are using Pact, do we still need another API documentation like Swagger or RESTDocs? The Pact Broker offers pretty good live-documentation of all APIs. Any thoughts/experiences/suggestions on this?

matt
2018-07-06 15:17
I think Pact and Swagger solve different problems, they can even be used together :slightly_smiling_face:

liran.tal
2018-07-06 20:19
@vinod.baradwaj that?s really cool. would be interesting to hear what kind of things you?ve been experimenting with and what challenges you found.

liran.tal
2018-07-06 20:19
@beth yeah, and that brings up another challenge - say I have a consumer and provider contract set in place (tagged production). but then there?s a new API integration between them (i.e: through an API Version header flag) or even a simple new field in the response to support. I can?t just add this interaction to the existing consumer-provider contract that is in production because again, that specific new API is still in development phase of the provider. so I can?t just tag the contract ?development? again to not break providers build because they could be breaking the previous API contract. seems the only way to get around it is via naming the provider differently to get a new contract made just for that.

nick
2018-07-06 22:53
has joined #general

matt.fellows
2018-07-07 01:48
It's a good discussion for this group. Our official position is that they solve different problems and can be used together.

matt.fellows
2018-07-07 01:49
But I'd love to see what other responses you get

gaurav
2018-07-07 03:13
I think Pact Broker is not suitable for documentation purposes at all. Reason is that it shows contract between provider and consumers.. which can be different for different consumers. consumers might need only few fields from provider as response and in that case Pact Broker will only show those few fields as a part of their Pact. Swagger is aimed at documentation and from my opinion, both should be used together. Using Pact with Swagger makes CI integration and pact verification super easy and fast (google swagger-request-validator-pact).

yamad
2018-07-07 09:45
has joined #general

bethskurrie
2018-07-07 11:23
> I think Pact Broker is not suitable for documentation purposes at all. What I'd add to that is that it documents the integration between a particular consumer and provider very well. It doesn't, however, provide _general_ documentation for a provider, which Swagger does very well.

polvara
2018-07-07 11:48
has joined #general

polvara
2018-07-07 11:58
Hello everyone, I'm joining this chat in response to my tweet https://twitter.com/Gpx/status/1015233318848262144?s=19 At my company we're trying to decide if Pact is the right tool for us. I hope someone with more experience than me can help. In a nutshell, we're testing our React application with Selenium using a Django server as a backed. We have huge latency issues due to network calls. We were thinking to replace the server with Pact to speed things up. Is this recommendable? Has someone done something similar before? Thank you

liran.tal
2018-07-07 12:06
Hi @polvara. that can definitely work, although if you are working through some CRUD flows and doing more than just smoke tests then it can be a little bit more work to get things to play together.

gaurav
2018-07-07 14:52
Hello all, I have a question about `ConsumerInfo` class in `pact-jvm-provider_2.12-3.5.19`: `consumerInfo.getPactSource()` gets an instance of `BrokerUrlSource`.. how do I retrieve consumer source from this instance. Sorry I am not really familiar with kotlin. For example: if `consumerInfo.getPactSource().toString()` gives: `BrokerUrlSource(url=http://localhost:52821/pacts/provider/Provider/consumer/Consumer1/version/123, pactBrokerUrl=http://localhost:52821, attributes={}, options={})`, I am interested in `consumerInfo.getSource().someMethod()` that gives `http://localhost:52821/pacts/provider/Provider/consumer/Consumer1/version/123` Thanks a lot.

liran.tal
2018-07-07 15:47
@bethskurrie in https://github.com/pact-foundation/pact_broker/wiki/Pacticipant-version-numbers why is `2.0.0` regarded as a bad example for application version? it is following semver and should be unique for apps.

liran.tal
2018-07-07 17:49
hi all, I?m trying to decide on a good title for a talk I?ll be giving about CDC with Pact, it will mostly intro the subject, show an example, and provide a recipe for teams to adapt in their organisation through devops ci/cd pipelines. ``` 1. Testing Microservices and Staying Alive To Tell The Story 2. Testing Microservices and Staying Alive 3. Testing Microservices and avoiding Integration Hell 4. Contracts Testing for a Microservices Architecture 5. Consumer Driven Contracts testing for SOA 6. <your own suggestion> ``` which do you like most? I?m open to your own suggestions! thanks :wink:

david.j.smith
2018-07-07 18:12
"Life's too short for Dev VM's"? :stuck_out_tongue:

liran.tal
2018-07-07 18:14
:slightly_smiling_face:

ar7ai
2018-07-07 18:25
has joined #general

ar7ai
2018-07-07 18:28
Hello! I use ProviderStateMiddleware. Why is the "private void AddData ()" method executed before the test, is this the correct behavior? (I do according to your example https://github.com/tdshipley/pact-workshop-dotnet-core-v1/blob/master/CompletedSolution/Provider/tests/Middleware/ProviderStateMiddleware.cs)

david.j.smith
2018-07-07 18:32
I'm not familiar with that middleware, but it sounds correct. All provider state setup actions need to run before the tests because their job is to put the provider into a known state before the test executes. For example, if the tests relies on being able to use query params to find document with id 12, then document with id 12 will need to be there in advance!

ar7ai
2018-07-07 18:35
I also think so but so far in this example there is first testing, and only then setting a precondition (adding data)

ar7ai
2018-07-07 18:35
and I do not understand why :disappointed:

ar7ai
2018-07-07 18:37
"Why is the "private void AddData ()" method executed after the test, is this the correct behavior?" sorry, not exactly written

david.j.smith
2018-07-07 18:42
I'm not following you sorry, the code you've sent over isn't a test, and (ok my C# is rusty) I can't see it running a test either. Looks like a ProviderState management class to me?

uglyog
2018-07-07 23:44
try consumerInfo.getPactSource().getUrl()

gaurav
2018-07-08 01:53
hmm I was trying to do.. However just noticed that `getPactSource()` actually returns an object type so need to cast that to `BrokerUrlSource`. So `((BrokerUrlSource)(consumerInfo.getPactSource())).getUrl()` is working! Thanks a lot!

bethskurrie
2018-07-08 02:17
Hi @ar7ai please note the guidelines for raising issues that were sent to you by the greetbot, and ask your question in the relevant channel for your technology. It helps keeps the conversations focussed, and lowers the noise in the general channel.

greetbot
2018-07-08 02:18
has joined #general

paulswilliams
2018-07-08 09:00
Hey all, having run with Pact JVM for a month on our production project, I'm really enjoying it's coverage. As we're around half way through our development phase, we're soon going to need to start thinking about production, api versioning, releasing, branching etc. I've read the matrix page, and wondered if anyone can recommend other supporting documentation / videos etc to best prepare us for go live. If it helps, we're currently developing a single provider, that will be consumed by around 6 consumers, although at this moment, only 1 consumer will be in play. Looking forward to any responses.

bethskurrie
2018-07-08 09:49
1!

bethskurrie
2018-07-08 09:52
Because it doesn't uniquely identify the exact version of your repository that made the contact. You ruin the ability of the matrix to safely allow you to deploy if you can't map your code version to your pact version 1 to 1.

bethskurrie
2018-07-08 09:54
You get some extra benefits by using the sha because you can send verification statuses back to github or gitlab (or equivalent) as commit statuses.

bethskurrie
2018-07-08 09:55
If you must use sem ver, then including the sha as metadata will ensure that your version numbers are unique and can be mapped back to the version of the code that created them.

bethskurrie
2018-07-08 10:06
I think you said you increment the patch version with each build, so you should at least have unique numbers. The reason being able to map back to the sha is if you need to do the last step of the "pact nirvana" document, and you have to check out the production version of the provider to verify it against the new consumer. If you're deploying the provider frequently though, you most likely won't have to do this.

bethskurrie
2018-07-08 10:08
Welcome @paulswilliams this document (though it's still in draft, and pretty ugly, sorry!) should help https://docs.google.com/document/d/e/2PACX-1vRf1kSDccImNipOOm1G-bjcSs-ifbZjf1v54K-dIcq8BLKeFPAAm_bf_p71UKqkRMIx30QWWL-kN8TI/pub

bethskurrie
2018-07-08 10:10
Let me know if you have any further queries after reading this. Because everyone's workflow is different, it's hard to describe exactly how to set things up.

paulswilliams
2018-07-08 10:10
Oh thank you. I will have a good read this afternoon. Thank you for you and everyone?s work on Pact. I had a shaky start, but it?s really starting to show value now.

bethskurrie
2018-07-08 10:11
Good to hear! We know that it's difficult to ramp up.

bethskurrie
2018-07-08 10:11
What did you find most difficult?

steve.cook
2018-07-08 10:15
has joined #general

2018-07-08 10:15
Welcome to the Pact #general channel @steve.cook! Please join the relevant channels for your Pact implementation as well, so you can discuss your issues with the audience who can best help you.

bethskurrie
2018-07-08 10:17
Hi @polvara paxt can definitely help you, but I would caution against writing too many contact tests that go through the full layer. Often you'll end up with an explosion of interactions that you've only added because you're trying to test some element of the UI. We'd generally recommend using Pact to unit test the interactions between the API client (a class in your consumer codebase that is responsible for making the calls to the provider) and the API. You can then use the pact *stub* server to stand up a stub for tests that involve the UI.

paulswilliams
2018-07-08 10:34
Concepts. Thinking I could use Pact to create mocks for acceptance tests, rather than focusing on integration components. Some of the JVM docs using Groovy over Java add unneeded cognitive load. Also, sceptical colleagues who are more confident with end to end tests, but unversioned stored procs in shared database have caused so many issues that they?ve seen the light in embracing decoupling.

bethskurrie
2018-07-08 10:35
Ouch!

bethskurrie
2018-07-08 10:35
Yes, it is a conceptual leap.

paulswilliams
2018-07-08 10:36
Once handling the matrix is understood and battle hardened, I?d hope that we?ll use this approach a lot.

bethskurrie
2018-07-08 10:36
That first one is a really good point. Should we make that clearer somewhere?

paulswilliams
2018-07-08 10:36
I work at a contracting company, the shared db is a customer thing :face_with_head_bandage:

bethskurrie
2018-07-08 10:37
I work for a consulting company - I've also seen things I'd rather forget!

paulswilliams
2018-07-08 10:37
Perhaps. If others feel same pain? I can?t recall a ?what Pact doesn?t do? section which might be useful.

bethskurrie
2018-07-08 10:38
There is a "what is pact not good for" section actually.

paulswilliams
2018-07-08 10:38
Yeah, although these anti-patterns are making us be creative.

bethskurrie
2018-07-08 10:38
In the docs, underneath the "what is it good for" section.

paulswilliams
2018-07-08 10:39
Yeah, i couldn?t recall it, but then I started a couple of months back.

bethskurrie
2018-07-08 10:39
Next time I'm looking at the main section, I'll have a think if there's any way to make that clearer.

bethskurrie
2018-07-08 10:40
I value the impressions of people who have recently read the docs, because those of us who know pact too well are bad at working out what needs improving.

paulswilliams
2018-07-08 10:41
Okay, cheers. I?ll try and add an issue or PR on docs if I get chance. Lots of juggling as you no doubt experience

bethskurrie
2018-07-08 10:42
Constantly!

paulswilliams
2018-07-08 14:41
That tagging / wip content is exactly what I was looking for. I will read it again in depth after pondering this evening. Cheers!

polvara
2018-07-08 19:10
Thanks for the reply. Yes, that?s what we wanted to do, use the stub server when we run our E2E tests. Most of our UI is tested with unit and integrations tests. We use E2E to check the main workflows, we don?t cover edge cases. I guess the main issue from my side is to understand how much can you push Pact before you have an explosion of interactions

polvara
2018-07-08 19:13
Hey, thanks for the reply and thanks for the tweet too :bow: Our slowness is due to the server. We tried to use a static server for one of our E2E tests and the increase in speed is noticeable?we?re talking minutes vs seconds. As I wrote also here https://pact-foundation.slack.com/archives/C5F4KFKR8/p1531077014000029?thread_ts=1530964717.000011&cid=C5F4KFKR8 the thing that confuses me the most is to understand when a smoke test becomes too specific and it will force us to work agains Pact

bethskurrie
2018-07-09 00:23
> We use E2E to check the main workflows, we don?t cover edge cases Yay!

obradford
2018-07-09 07:08
has joined #general

2018-07-09 07:08
Welcome @obradford!

greetbot
2018-07-09 07:12
@greetbot has left the channel

violeta.minkov
2018-07-09 07:28
has joined #general

bethskurrie
2018-07-09 11:14
@liran.tal no, this new interaction should be added by creating a feature branch of the consumer codebase, and publishing the pact with a tag that matches the name of the feature branch. You can then go to the provider team and say, hey, can you support this new pact (give them the name of the tag). Once that new pact is supported, and deployed to production, then you can merge in your feature branch in your consumer and deploy.

bethskurrie
2018-07-09 11:15
As the "pact nirvana" document outlines, you'll find it much easier if you use tag names that map to your branch names in development, and tag names that match your environments when you deploy.

bethskurrie
2018-07-09 11:16
Your provider should verify the "master" and "production" tags if you follow this scheme.

bethskurrie
2018-07-09 11:17
The approach I outline above for adding new features (using a branch and another tag) will allow you to add new interactions without breaking everything.

bethskurrie
2018-07-09 11:18
Does that make sense at all?

bethskurrie
2018-07-09 11:29
Hi `can-i-deploy` users. I've added a `--retry-while-unknown` option to allow your consumer pipeline to wait for the provider to finish running the pact verifications when it is triggered by a webhook (which is triggered by a changed pact). Remember, however, that pacts can be pre-verified on feature branches to avoid blocking your master build. You can read about how to do this in https://docs.google.com/document/d/e/2PACX-1vRf1kSDccImNipOOm1G-bjcSs-ifbZjf1v54K-dIcq8BLKeFPAAm_bf_p71UKqkRMIx30QWWL-kN8TI/pub

jannik.falkner
2018-07-09 13:10
has joined #general

jannik.falkner
2018-07-09 13:15
Hi, can someone explain why injection with `@Autowire` in this example does not work when verifying via the Gradle Pact plugin? https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-spring#using-a-spring-runner-version-357 I need to inject a bean of `RabbitMqBackend` but it says `kotlin.UninitializedPropertyAccessException: lateinit property rabbitMQBackend has not been initialized`


ssn899
2018-07-09 19:37
@matt.fellows there has been some discussion in the gist.

bethskurrie
2018-07-09 23:25
Hi @jannik.falkner. Welcome to the pact slack. You'll get the audience for your question by asking in the pact-jvm channel

bethskurrie
2018-07-10 02:59
Hi all! To help get the word out about new features in Pact, and to help Pact users share their experiences with each other, we're trying out a fancy new blog at http://blog.pact.io I've written the first couple of posts to get us started.

bethskurrie
2018-07-10 03:00
Here's a quick intro to the new retries feature in can-i-deploy http://blog.pact.io/2018/07/10/retries-for-can-i-deploy/

bethskurrie
2018-07-10 03:01
We'll be adding new posts as new features come out, so be sure to add it to your feed reader.

bethskurrie
2018-07-10 03:04
added an integration to this channel: https://pact-foundation.slack.com/services/BBM3NQTMF

bethskurrie
2018-07-10 06:44
@gaurav would you be interested in writing a blog post about your pact/swagger set up and experiences on the new http://blog.pact.io?

bethskurrie
2018-07-10 06:47
Hi @santoshtrip sorry, I'm not sure if you ever got an answer. The swagger validator is better in situations where there are more consumers than the provider team can realistically maintain provider state data for (maybe 10?)

bethskurrie
2018-07-10 06:47
The down side is that you lose a bit of confidence, because you're adding an extra layer of abstraction.

bethskurrie
2018-07-10 06:48
The up side is that you can get very fast feedback, and in some situations, fast feedback is more valuable that waiting for slightly more accurate feedback.

bethskurrie
2018-07-10 06:49
The broker doesn't current support the exchange of swagger documents, but it's something we're planning on adding in the future

bethskurrie
2018-07-10 06:49
@gaurav has had experience with the pact swagger workflow.

bethskurrie
2018-07-10 06:50
Keep in mind that you need to ensure that your swagger document is in sync with your code either by using dredd or by generating the swagger document from the code itself.

bethskurrie
2018-07-10 06:52
What you lose is the ability to verify what a particular resource looks like with various combinations of data - the "provider states" that pact gives you. This may or may not be particularly important for your api, however.

gaurav
2018-07-10 07:47
Thanks @bethskurrie. I would love to do that but my setup for pact/swagger is not complete yet. Swagger-validator was using quite old pact version so I was working on upgrading the version recently in my fork (there were many changes!). Also wanted to take this chance to understand the internals of swagger-validator. I am ready to create a PR but there is a delay because of organisational processes (they need some CLA for corporate contributors so need to involve legals). Anyways, point is that although my quick evaluation looks very promising.. it would take me some time.. may be a month to be at a stage where I can share experiences about both good and pain points in more practical sense. On side notes, I really think that Pact Foundation and Atlassian should work together to have a complete and easier contract testing solution (I don?t see many contributors in that repo).. Also asked the contributor there to request a slack channel here because of increasing interest in swagger-validator here.. and to be updated with latest pact discussions.

bethskurrie
2018-07-10 07:50
Having a channel here is a good idea. You're right, that we haven't collaborated on this. Some of the atlassian teams wrote it to solve their own problems (much like pact was originally written!) and then open sourced it afterwards.

bethskurrie
2018-07-10 07:51
We'd love to have better integration and support in the broker for this flow, but it just hasn't reached the top of the priority list yet.

bethskurrie
2018-07-10 07:53
I saw that one of the atlassian contributors is going to be at a conference I'm attending soon, so I'll try and catch him to talk about this.

gaurav
2018-07-10 07:57
Sounds like a good idea.. As they are already using swagger-validator for longer than anyone else, they will be good candidates to share experiences as well. :slightly_smiling_face: May be convince them to remove CLA thing.. :wink:

alex.bednarczyk
2018-07-10 13:18
has joined #general

rlamb
2018-07-10 16:51
Is anyone using a tool like RDoc or YARD to document provider states?

sjani
2018-07-10 23:30
has joined #general

bsayers
2018-07-11 07:35
has joined #general

bethskurrie
2018-07-11 07:48
I reckon the devs probably don't have much say over a CLA unfortunately.

raido.letterbox
2018-07-11 07:48
has joined #general

bsayers
2018-07-11 08:07
Hi all, are there many users of swagger-mock-validator in here? My team is considering adding OpenApi 3 support to it and am wondering if that is of interest to anyone here.

polvara
2018-07-11 08:27
Hello, all my API calls to Pact are returning status code `222`. Any idea why is that or how to debug the issue?

raido.letterbox
2018-07-11 08:30
Hi all. I am a bit confused about consumer tests concept. Are they meant just to generate PACT json file or to test the request which the consumer sends too?

abubics
2018-07-11 08:57
They just generate the pact file, and help assert that your API client deserialises the stubbed response properly.

abubics
2018-07-11 08:57
A separate process verifies the pact file against the producer :)

uglyog
2018-07-11 09:20
Is that the HTTP status code?

polvara
2018-07-11 09:39
Yes, which is weird because it?s a code that doesn?t exist

uglyog
2018-07-11 09:45
What language are you using? Is this during the consumer test?

raido.letterbox
2018-07-11 09:45
Thanks! I was writing a response to you and understood a few thing by myself :slightly_smiling_face: Just a small question left: if we are verifying that the consumer deserialises the response correctly, does this mean that the consumer tests should be written in the same language as the consumer itself?

polvara
2018-07-11 09:48
Yes, consumer test in node

polvara
2018-07-11 09:49
``` provider.addInteraction({ state: 'admin user exists', uponReceiving: 'a sign in request', withRequest: { method: 'POST', path: '/be-mock/api-login/', body: { username: '', password: 'welcome' }, }, willRespondWith: { status: 200, body: { token: 'eyJ, }, }, }) ```

polvara
2018-07-11 09:49
This is how I define the interaction

uglyog
2018-07-11 09:53
Wow, that is weird. Maybe the logs from the mock server will help

polvara
2018-07-11 09:56
``` I, [2018-07-11T11:54:38.132877 #1529] INFO -- : Received request POST /be-mock/api-login/ D, [2018-07-11T11:54:38.133058 #1529] DEBUG -- : { "path": "/be-mock/api-login/", "query": "", "method": "post", "body": { "username": "", "password": "welcome" }, "headers": { "Content-Length": "61", "Content-Type": "application/json", "Host": "localhost:1234", "Connection": "keep-alive", "Origin": "http://localhost:3000", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36", "Accept": "*/*", "Referer": "http://localhost:3000/login", "Accept-Encoding": "gzip, deflate", "Accept-Language": "en-US,en;q=0.9", "Cookie": "_ga=GA1.1.419063753.1531302868; _gid=GA1.1.551748798.1531302868; _gat=1; mp_7c7a4eab3982d24cf551ff2e97f58b30_mixpanel=%7B%22distinct_id%22%3A%20%2216488c3732012d-01429e40c5e0a-163b6950-13c680-16488c37321858%22%2C%22%24initial_referrer%22%3A%20%22%24direct%22%2C%22%24initial_referring_domain%22%3A%20%22%24direct%22%7D; __stripe_mid=a13be528-1a35-4766-80f6-eda2e807ecf4; __stripe_sid=0d317bf2-c1a8-47b3-b4cb-9938c22928f7", "Version": "HTTP/1.1" } } I, [2018-07-11T11:54:38.135619 #1529] INFO -- : Found matching response for POST /be-mock/api-login/ D, [2018-07-11T11:54:38.135714 #1529] DEBUG -- : { "status": 200, "headers": { }, "body": { "token": "eyJ" } } ```

polvara
2018-07-11 09:56
They look fine

polvara
2018-07-11 09:57
Is it as if the server responds correctly but something changes the response

polvara
2018-07-11 10:04
It?s probably a problem with testcafe because if I query the server with curl it works

hstene
2018-07-11 10:10
I am writing a pact where i care about the content of a string, but not capitalization. So in my pact I want to see if the provider returns the string `'hello'`. The provider does in fact return `'HELLO'` but either way (`'hello'|`HELLO`) is fine by me- How do I represent that in a pact test? I am specifically using pact-jvm

polvara
2018-07-11 10:11
Ok, the problem seems to be this header `'x-hammerhead|fetch|request-credentials: include'`

polvara
2018-07-11 10:11
Any idea why?

can
2018-07-11 10:12
Hi, Henrik! Have you used regular expressions before?

hstene
2018-07-11 10:15
Yes, does pact support regex-types in individual fields? :smile:


hstene
2018-07-11 10:18
Thanks!

bethskurrie
2018-07-11 10:52
Yes

bethskurrie
2018-07-11 10:52
You would use pact to write tests for the client class or classes that make the calls to the API.

bethskurrie
2018-07-11 10:53
Generally unit tests are recommended, to keep the contract focussed.

bethskurrie
2018-07-11 10:53
You are testing that the client class makes the expected http requests, and that it handles the expected responses correctly.

bethskurrie
2018-07-11 10:54
Generally this means deserialising the response into a class that represents the resource.

raido.letterbox
2018-07-11 10:59
Thanks a lot

bethskurrie
2018-07-11 11:02
There have been a few people asking about it recently, so if you do a search, you should find them.

polvara
2018-07-11 11:56
I think it?s a problem in the FE. I contacted testcafe https://github.com/DevExpress/testcafe/issues/1134#issuecomment-404123524 Thanks for the support

matt.fellows
2018-07-11 12:01
@bsayers :point_up:

bsayers
2018-07-11 12:13
@gaurav Our legal team is not negotiable on the CLA. It?s not unusual to need to sign one of these if you want to contribute to open source projects owned by bigger companies, Facebook, Google, Microsoft, Amazon are a few examples of other companies that also require this.

gaurav
2018-07-11 12:44
Sure @bsayers. That was more a light comment. :slightly_smiling_face: may be I am just unhappy with all these legal stuff in general.. but yes, I am sure they are there for reasons!

matt.fellows
2018-07-11 12:58
As per above Been, should we create a channel to discuss the swagger tools you guys have created?

gaurav
2018-07-11 14:08
There is a channel already #swagger-validator

matt
2018-07-11 15:50
I think OpenApi 3 support would be awesome.

santoshtrip
2018-07-11 16:50
@bethskurrie thanks for the detailed explanation. This is what I was looking for.:+1:

santoshtrip
2018-07-11 16:51
Awesome!

bsayers
2018-07-12 00:09
I won?t argue with you there @gaurav, I don?t think highly of the legal overhead either. Unfortunately the choice is open source the way we do today or don?t open source anything!

argos83
2018-07-12 00:46
has joined #general

mikey
2018-07-12 20:43
Hullo! First of all, Pact is *awesome*. Incredible work, ya?ll! We?re about to add Pact for a Javascript consumer. We use Karma to drive our javascript test suite. Which javascript Pact lib would you recommend? I?m thinking https://github.com/pact-foundation/karma-pact but I want to check with the experts who know more about the Pact ecosystem than I :simple_smile:

mikey
2018-07-12 20:46
We use Nodejs for our frontend and I saw pact-node and pact-js too, but I?m not sure how to determine which lib would best meet our needs.

mikey
2018-07-12 20:47
looks like karma-pact uses pact-node?

matt.fellows
2018-07-12 21:05
Hi @mikey! You might want to join us over in #pact-js

matt.fellows
2018-07-12 21:05
short answer is yes, longer answer is avoid Karma where possible

mikey
2018-07-12 21:06
oh right on, thank you! Joining now.

minhdoan
2018-07-13 03:12
Hi team, anyone has experience with request with space(s) in URL, when executing pactVerify the space should encoded to %20, unfortunately the '+'. I am stuck and don't know how to fix https://github.com/DiUS/pact-jvm/issues/693 Could you please help on it? Many thanks in advance!

mboudreau
2018-07-13 03:19
is this for a query string or for the actual URL path?

minhdoan
2018-07-13 03:21
Hi Michel, The actual URL is: /odata/CHAIR?$filter=CREATED_BY/FIRST_NAME eq 'LIMS'&$orderby=Id asc It is the code i wrote in consumer side: .path("/odata/CHAIR") .query("$filter=CREATED_BY/FIRST_NAME eq 'LIMS'&$orderby=Id asc")

minhdoan
2018-07-13 03:21
And the result shown on Broker: { "method": "GET", "path": "/odata/CHAIR", "query": "$filter=CREATED_BY%2F_FIRST_NAME+eq+%27LIMS%27&$orderby=Id+asc" }

mboudreau
2018-07-13 03:25
yep, as it should be. HTTP specification says that all query strings should use `+` for spaces

mboudreau
2018-07-13 03:26
if you've use anything that uses HTTP, it should transform it for you when you add spaces

mboudreau
2018-07-13 03:26
and should still work with pact

minhdoan
2018-07-13 03:27
Do you mean if my provider scheme is HTTP, the pactVerify will encode space to + and sent out the URL

minhdoan
2018-07-13 03:27
If the scheme is HTTPS, it is Ok, right?

mboudreau
2018-07-13 03:28
https will do the same

minhdoan
2018-07-13 03:28
yes, i also try with HTTPS and it not works

minhdoan
2018-07-13 03:28
So please help to instruct me how to overcome it

mboudreau
2018-07-13 03:29
are you just trying to verify, or trying to use the mock?

minhdoan
2018-07-13 03:37
I faced the issue when executing pactVerify against actual provider

minhdoan
2018-07-13 03:38
the mock in consumer side is Okie

minhdoan
2018-07-13 03:38
So the pact records are sucessfully created and published to Broker

bethskurrie
2018-07-13 04:46
As Michel says, `+` is the correct character to use when encoding a space in a query parameter. `%20` is what to use when there is a space in the path.

minhdoan
2018-07-13 04:51
Hi @bethskurrie, Nice to meet you

minhdoan
2018-07-13 04:51
Do you mean the URL: /odata/CHAIR?$filter=CREATED_BY/FIRST_NAME eq 'LIMS'&$orderby=Id asc

minhdoan
2018-07-13 04:52
When executing pactVerify, It would be encoded to: %2Fodata%2FCHAIR%3F%24filter%3DCREATED_BY%2FFIRST_NAME+eq+%27LIMS%27%26%24orderby%3DId+asc

minhdoan
2018-07-13 04:52
and send to actual provider

minhdoan
2018-07-13 04:53
it is a correct behaviour of our pact-jvm, right?

minhdoan
2018-07-13 04:53
So the actual provider should handle the '+', right?

bethskurrie
2018-07-13 04:53
yes

minhdoan
2018-07-13 04:54
Do we have any option to encode space to %20 in the query path as well?

bethskurrie
2018-07-13 04:55
If your HTTP library cannot unencode a + symbol in a query parameter, there is a problem with it.

bethskurrie
2018-07-13 04:56
What library are you using?

minhdoan
2018-07-13 04:58
I think i am using pact-provider-gradle

minhdoan
2018-07-13 04:58
plugins { id 'au.com.dius.pact' version '3.5.9' } group 'ODataPactProvider' version = '1.0.0' // PACTs require SemVer task wrapper(type: Wrapper) { gradleVersion = '4.2' }

bethskurrie
2018-07-13 04:59
I mean, what http library

minhdoan
2018-07-13 05:01
I am unsure Beth, i only know when i execute pactVerify task then the pact library will create a request and send to configured provider service

minhdoan
2018-07-13 05:01
Do we know the info with stacktraceshow option?

bethskurrie
2018-07-13 05:03
Sorry, I have to go.

bethskurrie
2018-07-13 05:03
I could be wrong, but I think you need help with your http framework, rather than pact.

minhdoan
2018-07-13 05:04
Many thanks for your help @bethskurrie and @mboudreau !

mboudreau
2018-07-13 05:04
np

minhdoan
2018-07-13 05:07
Though I am still not clear, in consumer side i used Spring Boot RestTemplate for initialize and send request to mock service

minhdoan
2018-07-13 05:07
No issue in consumer side, pact records created without issue

minhdoan
2018-07-13 05:08
But in provider test, pactVerify fails as demonstrated

mboudreau
2018-07-13 05:08
again, pact isn't the issue, it's the thing that calls the pact specified URL that is

minhdoan
2018-07-13 05:08
So i dont know the issue with http framework you mentioned here is the http framework used in Consumer, Spring Boot, right?

mboudreau
2018-07-13 05:08
since the RFC specification for HTTP calls says that query strings needs to be using `+` and not `%20`

minhdoan
2018-07-13 05:09
Yes, i also see that pact record is Okie

minhdoan
2018-07-13 05:10
But i only need to clarify again that whether our actual provider service must handle the + in the query path?

minhdoan
2018-07-13 05:10
If yes, i must raise a change request to dev team

minhdoan
2018-07-13 05:11
The web serivce must support the + in query option

minhdoan
2018-07-13 05:13
Or the actual issue from the http framework which initialize the request sent to the web service, it should replace the + by %20 before sent???

minhdoan
2018-07-13 05:13
Again, i am really not clear so i must take too long

minhdoan
2018-07-13 05:14
And i thank you so much for your help, very very very much

bethskurrie
2018-07-13 06:08
Yes, your service should accept + as a space delimiter in a query.

bethskurrie
2018-07-13 06:10
> The web serivce must support the + in query option This.

bethskurrie
2018-07-13 06:13
Please see the URL encoding section on https://en.wikipedia.org/wiki/Query_string

minhdoan
2018-07-13 06:54
@bethskurrie It is so cool. Only one more concern to fulfill the change request that whether pact-jvm, pactVerify support any configuration to configure the encoding by ourselves, e.g: replace + by %20 or anything else

bethskurrie
2018-07-13 06:57
There is no configuration option to do that. @uglyog can tell you more about it though.

minhdoan
2018-07-13 08:07
Hi team, i am executing pact provider test, the pact-jvm-provider-gradle library is used. My test suite contains 4 test cases (provider MULTI_USERS_PROVIDER has 4 consumers). My system requires login first so we must add an authorization header to each request as below: pact { // Configure the Pact verification log reports { defaultReports() // adds the standard console output json // report in json format } serviceProviders { MULTI_USERS_PROVIDER { requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first with credential: user:password req.addHeader('Authorization', 'Basic dXNlcjpwYXNzd29yZA==') } protocol = providerScheme host = providerHost port = providerPort path = providerScheme + "://" + providerHost + ":" + providerPort + "/webservice" hasPactsFromPactBroker(pactBrokerScheme + "://" + pactBrokerHost + ":" + pactBrokerPort) } } } But in the test suite, there is one test case must use other user , instead of user:password. So i try to use the stateChange for this one: pact { serviceProviders { MULTI_USERS_PROVIDER { requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first with credential: user:password req.addHeader('Authorization', 'Basic dXNlcjpwYXNzd29yZA==') } hasPactWith('AnotherUser_Consumer') { stateChangeUsesBody = false // defaults to true pactSource = url('http://pact-broker-local-repo.net/provider/MULTI_USERS_PROVIDER/consumer/AnotherUser_Consumer/latest') stateChangeRequestFilter = { req -> // Add an authorization header to each request // another:password req.addHeader('Authorization', 'Basic YW5vdGhlcjpwYXNzd29yZA==') } protocol = providerScheme host = providerHost port = providerPort path = providerScheme + "://" + providerHost + ":" + providerPort + "/webservice" hasPactsFromPactBroker(pactBrokerScheme + "://" + pactBrokerHost + ":" + pactBrokerPort) } } } But it seems the credential is not overwritten for specific test case. Anyone has experience on this stuff? Could you please help?

uglyog
2018-07-13 08:30
I don't think `stateChangeRequestFilter` can take any parameters. You'll have to do it in the `requestFilter`, but you might be able to provide a `requestFilter` for `AnotherUser_Consumer`

liran.tal
2018-07-13 08:31
Because we?re using a trunk based development workflow and we merge integrations even if they aren?t yet ready (we have feature flags and API versioning for this) then the whole process of relying on feature branches and specific branch names is not going to work well for us.

liran.tal
2018-07-13 08:32
:+1:

liran.tal
2018-07-13 08:35
my code version will always be the same as my contract version. when I publish a production contract it is tagged with 2.0.0 which is the consumer version that goes to production. when I tag a new production contract as 2.0.1 that is again the new consumer version as well that is deployed to prod. does that make sense ?

minhdoan
2018-07-13 09:13
@uglyog Thanks so much! But i have a concern that it seems new authentication credential used in AnotherUser_Consumer is also used for the test cases which be executed after it.

minhdoan
2018-07-13 09:13
Do you face that situation?

bethskurrie
2018-07-13 10:39
The version that you supply when you publish *is* the code version (it's the consumer application version). The *pact* version is managed for you by the broker (it's a sha based on the content).

bethskurrie
2018-07-13 10:40
Generally, you tag a version resource with the environment name, or the branch name, rather than a version number, because it generally already has a version number as its identifier.

bethskurrie
2018-07-13 10:41
It would be like tagging version "2.0.0" with a tag "2.0.0".

bethskurrie
2018-07-13 10:42
Are you doing this because you want to verify all your prod versions of a mobile api for backwards compatibility, and that's the easiest way to make the verification configuration do that for you?

bethskurrie
2018-07-13 10:45
Then, how about using the feature tag names?

bethskurrie
2018-07-13 10:46
I've been hoping to find someone with a feature toggle use case.

minhdoan
2018-07-13 12:00
Any solution for each case?

jiinliin
2018-07-15 22:33
has joined #general

bethskurrie
2018-07-15 22:59
@minhdoan if you believe you have found a bug, can you create a github repository with an executable example to demonstrate the issue. This will make any issue easy to identify, and allow us to show that it has been fixed.


minhdoan
2018-07-16 11:30
@bethskurrie I am not sure, i need an option to printout the Authorization for each request to investigate further. Any option ?

minhdoan
2018-07-16 11:30
I have tried with --debug, -i, --info but not info about Authorization.

bethskurrie
2018-07-16 11:31
I'm afraid I don't know much about the JVM implementation. Try asking in the JVM channel. If I was having problems with a library, I'd hook up the debugger and step through the code. Have you tried that?

minhdoan
2018-07-16 11:35
Thanks, Beth! I will try but i am not a developer so i am lack of skill to debug deeply :smile:

bethskurrie
2018-07-16 11:44
Oh, I see. Pact is generally used by developers.

bethskurrie
2018-07-16 11:44
Are you a tester?

minhdoan
2018-07-16 11:53
Hi team, i have a provider with 10 consumers so there are 10 pact records on Broker. And 7 test cases use the default authorization credential, and remaining 3 cases use distinct ones. So i must add requestFilter for each as below code: `'PERMISSION_PROVIDER {` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` //default credential is: superuser:123456` ` req.addHeader('Authorization', 'Basic c3VwZXJ1c2VyOjEyMzQ1Ng==')` ` }` ` protocol = schemeProperty` ` host = hostProperty` ` port = portProperty` ` hasPactsFromPactBroker(brokerScheme + "://" + brokerHost + ":" + brokerPort)` ` // Consumer 1 need the credential: test001:123456` ` hasPactWith('Consumer_1') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_1/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test001:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMToxMjM0NTY=')` ` }` ` }` ` // Consumer 2 need the credential: test002:123456` ` hasPactWith('Consumer_2') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_2/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test002:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMjoxMjM0NTY=')` ` }` ` }` ` ` ` // Consumer 3 need the credential: test003:123456` ` hasPactWith('Consumer_3') {` ` pactSource = url('http://localhost/pacts/provider/PERMISSION_PROVIDER/consumer/Consumer_3/latest')` ` requestFilter = { req ->` ` // Add an authorization header to each request` ` // because of our system needs login first` ` // with cre: test003:123456` ` req.addHeader('Authorization', 'Basic dGVzdDAwMzoxMjM0NTY=')` ` }` ` }` ` }` And i want to ensure that each request will have correct Authorization header info when pactVerify is executed, but i tried with: `gradle pactverify [--info | --debug | -i]` But no option show the Authorization information. Could you please help on it? Many thanks!

minhdoan
2018-07-16 13:04
Yes, i am a tester. We want to apply Pact to our project, replace Integration test

minhdoan
2018-07-16 13:06
And maybe create mock services with Pact

bethskurrie
2018-07-16 19:59
@minhdoan I actually suggested you ask in the #pact-jvm channel. We try to keep the general channel for non language specific discussion.

bethskurrie
2018-07-16 21:15
:+1:

bethskurrie
2018-07-16 21:17
Given that Pact is generally implemented by developers (pact tests on the consumer side are typically unit tests for the provider client classes) I'm interested to know why you've been doing it? Are the developers not interested? Do they think it's a tool for testers?

michael.follmann
2018-07-16 21:36
has joined #general

kaushalye
2018-07-17 01:23
has joined #general

mr.matt.r.long
2018-07-17 12:42
Hi, I've been POC the rollout of Pact within an enterprise organisation, and have had queries regarding how well Pact (specifically the Broker) can scale. I appreciate that the self hosted Broker is scaled according to it's deployment mechanism and infrastructure. However are there any case studies I could refer to? The numbers quoted are 8000 services using the Broker. My suggestion would be to deploy the broker and monitor it and scale as necessary, but I presume that it wouldn't require huge resources

david.j.smith
2018-07-17 16:13
Has anyone seen a problem where pactbroker retrieves the pacts in reverse order i.e. it treats the oldest as latest?

matt.fellows
2018-07-17 21:20
Have you got sort by date added or sort by a versioning scheme enabled?

bethskurrie
2018-07-18 00:42
If you don't have the "order by date" turned on, it will use semantic ordering. If you are using git shas, it currently will accept them, but give you a strange order.

bethskurrie
2018-07-18 00:42
I've changed it to sort by date by default now.

bethskurrie
2018-07-18 00:59
What version of the broker are you using, what are you using for your version numbers, and what version ordering setting are you using?

david.j.smith
2018-07-18 09:53
Now that I?ve been forced to dig into it, I think we?re on a really old version - will see if we can do an upgrade. The problem is on one particular part of the relationships it?s just picking a weird order. It?s ignoring both semantic version and date. But lemme push for an upgrade before we continue - thanks!

david.j.smith
2018-07-18 09:57
Two questions about the versions: 1. Is there somewhere in the UI that gives you the pact broker version? (we may not have it of course if, as I suspect, we have an older version) 2. What is the latest version of pact-broker? I couldn?t see the latest version number on the git readme?s or wiki? Might have just missed it.

bethskurrie
2018-07-18 10:29
It's in the response headers.

bethskurrie
2018-07-18 10:30
If it's not, it's ooooooold man.

bethskurrie
2018-07-18 10:30
You'll find the current version number in the releases page https://github.com/pact-foundation/pact_broker/releases

bethskurrie
2018-07-18 10:30
2.24.0

msc.consults
2018-07-18 13:39
has joined #general

msc.consults
2018-07-18 13:50
Hi everyone, Has anyone looked into creating a pact for non-HTTP protocols for Java? I have this scenario whereby my providers HTTP Endpoint is a Apache Knox Gateway, which is a passthrough API, thus I ideally need to create contracts with the underlying apps (which are not accessible via a HTTP protocol). I've come across this article: https://github.com/pact-foundation/pact-ruby/wiki/Why-Pact-may-not-be-the-best-tool-for-testing-pass-through-APIs - which points to: https://gist.github.com/bethesque/0ee446a9f93db4dd0697, but this is written in Ruby

kra
2018-07-18 19:22
Hei guys I just saw a Tweet saying: "Oh WSDL is called CDC these days. Déjà-vue" What are your arguments against this?

matt.fellows
2018-07-18 20:12
Can you share the link? Seems like a good conversation starter :grinning:


matt.fellows
2018-07-18 20:49
thanks

matt.fellows
2018-07-18 20:50
OK, here goes

matt.fellows
2018-07-18 20:50
1. Is the concept behind WSDL even a bad thing?

matt.fellows
2018-07-18 20:51
2. Maybe, but we learned, and moved forward to REST - where Swagger and OAS has picked things up

matt.fellows
2018-07-18 20:51
3. CDC is an _approach_ and a _concept_ for API design and evolution, WSDL/Swagger etc. is a definition language for implementing it. You can literally _do both_!

matt.fellows
2018-07-18 20:52
4. CDC actually started _during_ the WSDL days _using_ WSDL as the message exchange format (see https://martinfowler.com/articles/consumerDrivenContracts.html)

david.j.smith
2018-07-18 20:54
As it turns out, my plea to upgrade after your security announcement was heeded, and we were already running 2.20.0 :smile: The issue was the sorting config hadn?t been added. Thanks for the help as always :thumbsup:

matt.fellows
2018-07-18 20:55
So it?s a bit confused to equate the two.

matt.fellows
2018-07-18 21:05
@matt.fellows pinned a message to this channel.

bethskurrie
2018-07-19 02:42
My understanding of WSDLs (correct me if I'm wrong) is that all the consumers have to be working on the same version of the document and that if you make an update (add a field) you have to send out the new wsdl to all consumers, even if they don't care about that field. It may be cdc, but it seems to break postel's law in a very annoying way. (disclaimer, I haven't used WSDLs for maybe 10 years, so I may be mis remembering)

bethskurrie
2018-07-19 02:43
Pact JVM supports message pacts. Have a look at the docs.

bethskurrie
2018-07-19 02:45
Generally speaking, the protocol is irrelevant. You should separate your message handling code from your protocol specific code and then you can just test the contract between the message consumer and the message producer "business logic" classes.

bethskurrie
2018-07-19 02:45
No worries.

matt.fellows
2018-07-19 03:20
Yep, that was one of the main issues with it. You had to synchronise deployments or deploy multiple versions (which wasn't very common)

bethskurrie
2018-07-19 21:23
I love it when I open a pact stackover flow issue from my inbox and people have already answered it better than I could! Thanks pact community! https://stackoverflow.com/questions/51386591/how-and-if-test-syntactic-bad-request-validation-with-pact

matt.fellows
2018-07-19 21:24
yep!!

peeter.ulst
2018-07-20 10:48
has joined #general

peeter.ulst
2018-07-20 10:52
Hi, is there anywhere info on the `free` hosted beta service as in how it will fare in the future - for now it's free but when the beta ends then it's not free any more I assume?

bethskurrie
2018-07-20 10:53
Hi @peeter.ulst the free tear will continue to exist. The paid offering will simply add more features.

bethskurrie
2018-07-20 10:53
The free tear will basically be (as it is now) a hosted version of the open source codebase.

peeter.ulst
2018-07-20 10:54
so there will be no functionality loss compared to current beta?

bethskurrie
2018-07-20 10:54
No

bethskurrie
2018-07-20 10:54
The paid tear will have better auth and improved UI, amongst other things.

peeter.ulst
2018-07-20 10:55
and I can tell my company to keep using the beta as it will be seamlessly upgraded to production version and we can continue using it forever?

bethskurrie
2018-07-20 10:56
Indeed.

peeter.ulst
2018-07-20 10:56
:+1: thank you!

bethskurrie
2018-07-20 10:56
It will not lose any functionality while the hosted product exists.

brentbarker9
2018-07-20 18:23
Should a pact fail if there is additional data coming back from a provider test?

suliu
2018-07-20 21:00
has joined #general

uglyog
2018-07-21 00:11
If the data is important, it should be specified in the pact. Anything not in the pact should be ignored.


liran.tal
2018-07-21 00:21
no, it?s all basically app to app api calls, no mobile. but I think we?re aligned on this now. we do trunk based development so the pact version is indeed the consumer version. I don?t tag the contract with a version number, instead I tag it as either ?dev? or ?prod? depending if it should break the provider?s CI (due to the fact that this contract agreed to be on implemented & in prod)

liran.tal
2018-07-21 00:22
I?ll read about the feature tag names though not sure I want to couple to that

bethskurrie
2018-07-21 03:26
Can you outline the problems for me?

bethskurrie
2018-07-21 03:27
So, the provider verifies the "prod" ones in the build, but not the "dev" ones?

liran.tal
2018-07-21 07:47
it verifies both. ?dev? to check for the progress of its implementation and to check whether they can be really moved to ?prod? tags, and ?prod? for whats already in prod and then it will break the build if they fail.

bethskurrie
2018-07-21 08:27
Tell me about your process for introducing changes.

liran.tal
2018-07-21 08:31
my own team is following TBD. So every dev is creating a fork of the repo. Doing changes in their own branches. Opening a PR and when code review and checks are done it gets merged into the upstream repository?s master branch (there aren?t any other branches). once a merge happens to that master branch the server gets deployed.

liran.tal
2018-07-21 08:31
another team which is working on a legacy code base isn?t yet able to benefit from this workflow so even if they merge everything to a ?develop? branch, it doesn?t get deployed until end of iteration.

liran.tal
2018-07-21 08:32
while for them it?s easier to keep a feature branch on the side, for our fast-paced teams I prefer not to.

kaushalye
2018-07-23 04:58
~Hi folks, Im trying to get the pact provider side working with ``` &amp;lt;verificationType&amp;gt;ANNOTATED_METHOD&amp;lt;/verificationType&amp;gt; ``` ref: &lt;https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven&gt; Following the example in the above reference, I defined the .groovy file as follows (ignore the simple return type), which get compiled to .class in the test classpath ``` class VehicleTxnResourcePactTest { @PactVerifyProvider('a processed transaction') String verifyTransaction() { JsonOutput.toJson("some string") } } ``` However I am getting the following complaint ```Verifying a pact between MIRB and IPS - a processed transaction Given transactions are processed No signature of method: au.com.dius.pact.provider.ProviderVerifier.invokeProviderMethod() is applicable for argument types: (java.lang.reflect.Method) values: [public java.lang.String net.nxbos.ips.vehicletxn.resource.VehicleTxnResourcePactTest.verifyTransaction()] Possible solutions: invokeProviderMethod(java.lang.reflect.Method, java.lang.Object)```~

kaushalye
2018-07-23 04:58
Any help is highly appreciated.

kaushalye
2018-07-23 04:58
Side question: What do you expect in the classpath? .class file or a .groovy file ?

kaushalye
2018-07-23 04:59
@matt.fellows / @uglyog :wave: :slightly_smiling_face:

kaushalye
2018-07-23 05:03
and Following is the plugin configuration ``` <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven_2.12</artifactId> <version>3.5.18</version> <configuration> <serviceProviders> <!-- You can define as many as you need, but each must have a unique name --> <serviceProvider> <name>IPS</name> <verificationType>ANNOTATED_METHOD</verificationType> <consumers> <consumer> <name>MIRB</name> <pactFile>/Users/malinda/Code/ips-microservice-vehicle-txn/src/test/resources/pacts/MIRB-IPS.json</pactFile> </consumer> </consumers> </serviceProvider> </serviceProviders> <classpathElements> <classpathElement> target/test-classes </classpathElement> </classpathElements> <pactBrokerUrl/> <configuration> <pact.showStacktrace>true</pact.showStacktrace> </configuration> </configuration> </plugin> ```

uglyog
2018-07-23 05:05
@kaushalye let's move this to the #pact-jvm channel

kaushalye
2018-07-23 05:05
:thumbsup:

matt.fellows
2018-07-23 05:17
Ron is your man I?m afraid - what is _maven_ ? :smile:

matt.fellows
2018-07-23 05:17
j/k but I?ve never done any Pact JVM!

thirumal.net
2018-07-23 05:50
has joined #general

kaushalye
2018-07-23 05:59
I have to use pact JVM *Unfortunately* :smile:

minhdoan
2018-07-23 06:47
I want to build a response with Json format as below: {"value":[ { "attribute": "att1", "url": "/att1" }, { "attribute": "att2", "url": "/att2", "type": "Chemistry" }, { "attribute": "att3", "url": "/att3", "type": "Construction" } ] } I have tried with pact consumer code: .body(new PactDslJsonBody() .minArrayLike("value", 2,2) .object() .stringType("url", "/att1") .stringType("attribute", "att1") .closeObject() .object() .stringType("url", "/att2") .stringType("attribute", "/att2") .stringType("kind", "Chemistry") .closeObject()) But the object() method must have a name: `throw new UnsupportedOperationException("use the object(String name) form");` If using another approach as: .body(new PactDslJsonBody() .array("value") .object() .stringType("url", "/att1") .stringType("attribute", "att1") .closeObject() .object() .stringType("url", "/att2") .stringType("attribute", "/att2") .stringType("kind", "Chemistry") .closeObject()) The format is right, but the actual response body contains more than 3 elements (this is unknown number depends on the test system) in "value" array so verification fails. Could you please help to confirm that the format to build a response as example, whether it is supported in pact V3 or i must wait for the V4? Many thanks and nice day, team! (edited)

matt.fellows
2018-07-23 07:02
Can you please move this to #pact-jvm @minhdoan ?

minhdoan
2018-07-23 07:04
@matt.fellows Is Okie, Matt? But i also want to know that others pact libraries support this format? Please help to clarify!

matt.fellows
2018-07-23 07:08
To my eye it doesn?t look out of the ordinary, and it should be doable

minhdoan
2018-07-23 07:14
@matt.fellows Could you please help on it? Many thanks in advance!

matt.fellows
2018-07-23 07:17
Sorry @minhdoan I?m not across the JVM enough to give you specific advice here. Generally speaking, I would start by paring back your Pact test to just a few elements, and then gradually adding bit-by-bit

minhdoan
2018-07-23 07:18
:+1:

minhdoan
2018-07-23 07:18
Thank Matt for your help!

matt.fellows
2018-07-23 07:19
no worries!

psyrez
2018-07-23 07:26
has joined #general

brentbarker9
2018-07-23 16:36
Ok thank you

jim
2018-07-23 17:58
has joined #general

stan
2018-07-23 22:21
has joined #general

arne.zelasko
2018-07-24 07:00
has joined #general


ng.viet.quynh
2018-07-24 07:38
has joined #general

bethskurrie
2018-07-24 09:30
Welcome to all the newcomers :relaxed:

djrimokbp
2018-07-24 10:23
anyone managed to run pact verifications using MockMvcTarget and a controller having Jersey annotations (Java)?

ng.viet.quynh
2018-07-24 10:32
Hi everyone! And thanks for the warm welcome @bethskurrie :relaxed: Not sure where to put this but I am actually writing my bachelor thesis about contract testing in microservices with Pact and would really really appreciate if someone can share their experience implementing Pact in their own team/project. Since I only have a simple prototype, I would love to hear from you guys who have more seriously and intensively work with Pact. - What have run smoothly and what have been difficult for you? - Did contract testing with Pact become a part of your software development lifecycle? Why or why not? - Do you implement Pact in already developed services or in designing new services? Any opinion would be much appreciated! Many thanks!

bethskurrie
2018-07-24 10:36
@djrimokbp try in the pact-jvm channel.

iain.olliver
2018-07-24 10:45
has joined #general

arunesh.rajak
2018-07-24 14:05
has joined #general

gerrymcgovern
2018-07-24 14:26
has joined #general

mohammed.a
2018-07-24 14:32
has joined #general

bethskurrie
2018-07-25 04:11
Pact users. I need some help with a new Pact feature I'm developing. In the languages you've used, are the terms "wip" or "pending" used? And if so, is there a preference for one or the other? Do they have different implications? The feature I'm trying to describe is "if these pacts fail verification, they won't fail the build". I've used "wip" in the code, but I'm tossing up about the term "pending" instead. I'm not sure which is the most cross-language compatible. Doing a quick google comes up with more results for "pending" than "wip". One reason I went for "wip" was that "pending" implies that it is a failing test, and in this case, it's more that we don't know if they'll pass or fail. Happy to take suggestions if you think you have a more descriptive term.

abubics
2018-07-25 04:17
all the other words that I?d associate with that concept are long :stuck_out_tongue: e.g. incomplete, unfinished, etc

abubics
2018-07-25 04:18
but the associated stigmas for wip are intuitively closer to the right concept than pending for me

timothy.clifford
2018-07-25 04:33
For me it comes down to this: `pending` implies that something is planned, but may not yet have been started/finished; `wip` is something that is currently being worked on, but not yet complete

liran.tal
2018-07-25 06:10
agree with timothy and boris

bethskurrie
2018-07-25 06:46
In ruby, if a test that is marked as `pending` passes, the suite actually fails, so that you are alerted that you need to update your test code. Does this behaviour exist in other languages? (This is _not_ the behaviour that we want for this feature, btw - we want the process to exit with a success code all the time, whether the pact verifications pass or fail.)

bethskurrie
2018-07-25 06:47
/poll "What should I call the 'if these pacts fail verification, they won't fail the build' feature?", "WIP pacts", "Pending pacts", "Other (please suggest below)"

sguisado
2018-07-25 10:54
has joined #general

bethskurrie
2018-07-25 11:57
One things I should add to the above description of the "wip/pending" pacts feature is that once the pact is verified successfully, it ceases to be a wip/pending pact.

can
2018-07-25 11:57
Automagically or by the dev that implements the change?

bethskurrie
2018-07-25 11:58
I'm leaning towards "pending" now, as I think "something that was pending that has now succeed" we kind of assume is now not pending. I'm not sure if the same assumption applies to "wip".

bethskurrie
2018-07-25 11:58
Automagically.

bethskurrie
2018-07-25 11:58
It's then up to the consumer team to decide what to do with that previously pending pact.

niedra91
2018-07-25 11:59
has joined #general


can
2018-07-25 12:03
:pray: Thanks for the reading material!

bethskurrie
2018-07-25 12:04
The suggested process for introducing changes would go: * Provider is configured to verify `master` tagged pacts * Consumer creates git branch, modifies pact tests, publishes pact with tag = git branch * Webhook triggers build of provider * Provider runs verification with `master` and "wip/pending" pact but DOES NOT FAIL if the "wip/pending" pact does not pass * If pact passes, consumer merges in branch, and publishes new pact as `master` * If pact does not pass, people talk.

bethskurrie
2018-07-25 12:07
The "wip/pending" pact verification will be an automatic step in the verification process when retrieving pacts from a broker.

can
2018-07-25 12:11
So I guess on the `If pact passes, consumer merges in branch, and publishes new pact as master` is the step where a WIP pact is converted to a concrete one?

mats.lundkvist
2018-07-25 13:26
Hi, I have an issue with providers test in go with json pact generated in java. My go tests cannot find the state when the json looks like this ```"providerStates": [ { "name": "this is my state" } ]``` which is generated with pact-jvm but when I change to ```"providerState": "this is my state"``` it works. This is the metadata in the json ```"metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.19" } }``` Does anyone have an idea why it is like this?

antonello
2018-07-25 15:46
has joined #general

bethskurrie
2018-07-25 21:46
@mats.lundkvist because go doesn't support v2 pact specification yet.

bethskurrie
2018-07-25 21:47
The consumer will need to write a v2 pact for you.

bethskurrie
2018-07-25 21:47
Exactly @can

anthony.herman
2018-07-25 22:10
has joined #general

bethskurrie
2018-07-26 01:25
I think in the next release of Pact go, you may be able to use the v3 format, but it will ignore any v3 features it can't understand

niedra91
2018-07-26 07:43
Hi everybody! I?m trying to integrate Pact with a SCIM connector for the needs of a project. The development environment is Java + Maven. I checked out the Workshop project which helped me to understand the integration steps. Using this project and the pact-jvm project, I could successfully write a UT for the connector using Pact Mock Server. I described the Pact using Java 8 Lambda. At this point, I wanna go further and: 1/ Incorporate matchers for the Pact 2/ ?Build? the Pact as json data, as it?s done within the workshop project, but from the Java-8 DSL. I don?t need at the moment to automatically export the generated Pact to the provider through the pact broker. 3/ Test the generated pact against the real provider. I?m kind of stucked here. 1/ I looked in the matchers sub-project of pact-jvm, but could find only Scala or Kotlin classes. Are there any matchers for the Java DSL? Where could I find revelant documentation? 2/ I didn?t see any way to build the Pact in java. Is there a sample maven plugin available? Thanks in advance for your support :slightly_smiling_face: *edit*: copied to #general2

uglyog
2018-07-26 08:59
@niedra91 Are you asking how to define a matcher on an attribute in the Java-8 DSL?

niedra91
2018-07-26 09:00
Yes indeed :slightly_smiling_face:

uglyog
2018-07-26 09:01
There are methods in the DSL (like `stringValue` or `stringMatcher`) that will add the appropriate matcher

uglyog
2018-07-26 09:03
Not sure I understand what you mean by "?Build? the Pact as json data". Do you mean generate the pact file?

niedra91
2018-07-26 09:05
yes indeed

niedra91
2018-07-26 09:06
where could I find the documentation for these methods or the package name so that I could browse it directly into my IDE?

niedra91
2018-07-26 09:13
You mean the methods from PactDslRootValue and PactDslJsonRootValue in au.com.dius.pact.consumer.dsl I guess?


uglyog
2018-07-26 09:15
`PactDslJsonBody` would be the one to look at

niedra91
2018-07-26 09:15
:thumbsup:

niedra91
2018-07-26 09:15
Thanks :slightly_smiling_face:

pikestar
2018-07-26 09:25
has joined #general

pikestar
2018-07-26 09:33
Hello, I'm introducing Pact where I work and am starting with creating unit tests on the front end app - a React app. I'm new to front end development and JS. I have followed the guide on install and setup and have a test written however on running 'npm run pactTest', I get the following error:

pikestar
2018-07-26 09:34
my pactSetup.js lives here: /Users/adampike/web-project/packages/app

pikestar
2018-07-26 09:36
my package.json lives in the same directory and the script is:

uglyog
2018-07-26 09:37
is there a `pactSetup.js` file in /Users/adampike/web-project/packages/app/src?

pikestar
2018-07-26 09:37
No. it seems lke the rootDir is wrong and should be up one level

uglyog
2018-07-26 09:38
oh, yeah, maybe try `--setupFiles ../pactSetup.js`

pikestar
2018-07-26 09:38
ok thanks

pikestar
2018-07-26 09:40
yep worked :+1:

pikestar
2018-07-26 09:40
thanks

nicolas.clertan
2018-07-26 15:58
has joined #general

dipjyotimetia
2018-07-27 04:10
has joined #general

kurst03
2018-07-27 04:31
has joined #general

ashish.dubey91
2018-07-27 07:50
Hi guys. I have a question - is there any way to generate an HTTP client out of a pact definition?

bethskurrie
2018-07-27 07:50
No. Can you explain your usecase?

ashish.dubey91
2018-07-27 07:52
so imagine a consumer defines a contract. as part of the contract it defines how it sends the request. This data is also used by pact-verifier I'm guessing when it builds the requests to the provider for verification. What I want is a method by which I can write an HTTP client that sends this request to the provider

bethskurrie
2018-07-27 07:54
Can you explain more about what you're trying to achieve?

ashish.dubey91
2018-07-27 07:56
sure. I have an Android app which defines a contract test for the backend API at a URL /v1/someapi, with some specific headers. Now I want to write some integration tests for this backend API for which I'd have to make the same request with the same headers. I wondered if I could re-use the contract definition to make this easier

bethskurrie
2018-07-27 07:58
You could easily write some code to parse the file and turn the request definitions into a live request, and then execute each request.

bethskurrie
2018-07-27 07:58
I wouldn't recommend it though.

bethskurrie
2018-07-27 07:59
Contract tests have different aims to functional tests.

bethskurrie
2018-07-27 07:59
And you'd be coupling your functional tests to the requests the consumer defines in the pact file.


bethskurrie
2018-07-27 08:01
Please read the above explanation about the difference.

ashish.dubey91
2018-07-27 08:03
that's true I've read this one. This thought started when we were discussing the possibility to start using swagger for documenting APIs and then being able to easily generate clients for those APIs

ashish.dubey91
2018-07-27 08:05
but it also occurred that we've tried out pact and it seems useful for contract testing so we're definitely going to be using it a lot it seems. And since request definition is quite tight in a contract test (which is also what pact docs recommend) it's quite possible to re-use that metadata to generate these API clients

ashish.dubey91
2018-07-27 08:06
functional tests I agree ideally should be decoupled from these contract test definitions

ashish.dubey91
2018-07-27 08:08
but for folks in the team who might want to play with the API for some reason, I thought these could be useful

antonello
2018-07-27 10:39
Hi all! I have a question / some thoughts around verifying responses by type only, using matchers, and wanting to be more strict for particular fields. If I decorate the whole response body with a `like`, can I then override that and make sure a specific field is verified also by value?

bethskurrie
2018-07-27 12:04
You can override it with a regex, just make it match exactly.

antonello
2018-07-27 12:14
Thanks @bethskurrie. So a `term` matcher nested within a `like` matcher will win, is that correct?

niedra91
2018-07-27 17:32
For those who may have been wondering, the PACT was generated for the last UT to be runned inside the ?pacts? directory of my build directory. Although I had two pacts described, one different in each UT, there were not combined. I guess I need to set one unique PACT with various interactions for the whole Test class instead.

bethskurrie
2018-07-27 23:02
Yes

matt
2018-07-28 21:38
> if these pacts fail verification, they won't fail the build may be a bit late to the party, in JUnit this is called `Ignore`

bethskurrie
2018-07-29 21:32
Ta. I'm not sure if I can call the feature "ignore pacts" though!

bethskurrie
2018-07-29 21:32
"ignore failure pacts" is accurate, but a bit clunky.

antonello
2018-07-30 08:32
Thanks!

mark.bridgett
2018-07-30 12:11
Hey there. Anyone know how I can get my Java provider tests to output the full provider response? I'm trying to debug a failed test and would like to see what my service is sending back that is failing. All I have to go on at the moment is this output which doesn't help much : $.some_property -> [{mismatch=Expected List() to have minimum 1, diff=}]

can
2018-07-30 12:13
Hi Mark! I think the folks over at #pact-jvm might be better equipped to help you :slightly_smiling_face:

mark.bridgett
2018-07-30 12:19
Ahh, i'll try there thanks :slightly_smiling_face:

antonello
2018-07-30 14:17
I had the same issue the other day when I was playing with a failure when using an `eachLike` matcher.

oswald.quek
2018-07-30 16:06
hello. in a pact consumer test, is there a way to manually verify a call to a certain endpoint was called x number of times? use case: calling an endpoint on our consumer service (and passing it an auth token in the header) causes it to call another authentication service (the provider). however we're caching the valid tokens on the consumer service so i want to verify that making calling the endpoint multiple times only causes the authentication service to be called once.

can
2018-07-30 16:11
Hmmm. I'm not an expert at this but that doesn't strictly sound like a contract test. Looking forward to what others say!

oswald.quek
2018-07-30 16:19
well there's a contract between the consumer service and the authentication service for sure

matt
2018-07-30 16:21
maybe "Ignore failures"

matt.fellows
2018-07-30 21:34
Yeah, this is better served with traditional unit tests and not worth Pact.

bethskurrie
2018-07-30 22:22
@mats.lundkvist did you get this sorted?

bethskurrie
2018-07-30 22:22
Did you get a chance to read this @can? I'd love any feedback you have.

bethskurrie
2018-07-30 22:27
@liran.tal I came across a use case that demonstrates why you have to be very careful if you put a build number in the version. If you have a webhook that triggers a provider build when the pact changes, you'll end up building a particular SHA of the provider multiple times. If your provider is both a consumer and a provider, you need to make sure that this build publishes its own pacts when it does the verification, otherwise the "latest" version of the provider will have the verification results, but no pacts. This means that when you come to deploy that version `can-i-deploy` will say "NO!".

jarrodlilkendey
2018-07-31 01:53
has joined #general

richard.jones
2018-07-31 05:49
Hi folks, we?re seeing a very strange pact verification failure here in the Java verifer: https://gist.github.com/richard-reece/85d58d296aa8e4806bd59496a39780d1 - so even though our pact is specifying matching by type, I think the verifier is failing because the values don?t match.

bethskurrie
2018-07-31 05:51
That does not look like that Java verifier

bethskurrie
2018-07-31 05:51
It looks like the ruby one, and it only supports v2

bethskurrie
2018-07-31 05:51
If your pact is in v3 format, it won't work.

richard.jones
2018-07-31 05:52
Oh! Sorry, I?m passing on information second-hand from our Java dev here. I?ll clarify with him?

bethskurrie
2018-07-31 05:52
Hm. The matching rules look like v2.

bethskurrie
2018-07-31 05:54
And I take it back - the verifier output has a slight difference to the ruby.

bethskurrie
2018-07-31 05:54
I didn't realise it copied the output so closely.

bethskurrie
2018-07-31 05:55
There might be a bug in the Java type comparison for boolean

richard.jones
2018-07-31 05:55
Ah, righto.

bethskurrie
2018-07-31 05:56
It should be identifying the pact spec version from the file, but there might be a problem with that.

bethskurrie
2018-07-31 05:56
Also, lets move this to a thread.

bethskurrie
2018-07-31 05:57
Can you see any output that says which pact spec version is being used?

richard.jones
2018-07-31 05:58
I?m asking :slightly_smiling_face:

richard.jones
2018-07-31 06:06
I think the Java dev has gone for the day, thanks for trying to help tho.

bethskurrie
2018-07-31 06:15
Can you make sure they're running the latest version tomorrow (I'm not sure what that is)

bethskurrie
2018-07-31 06:15
@uglyog can probably help you more, but he's stuck in a basement with no reception at the moment!

richard.jones
2018-07-31 06:16
ouch for @uglyog :confused:

imran.khan2
2018-07-31 07:16
has joined #general

imran.khan2
2018-07-31 07:17
Hey folks

imran.khan2
2018-07-31 07:18
I was looking for some help with pact usage in the java ecosystem

imran.khan2
2018-07-31 07:19
Is this the right place for those types of questions?

bethskurrie
2018-07-31 07:22
Best place to ask is #pact-jvm @imran.khan2

imran.khan2
2018-07-31 07:23
Thanks @bethskurrie

can
2018-07-31 07:49
From my discussions internally with @antonello, we'd found it to fit the process quite nicely! His feedback would be most valuable, though.

oswald.quek
2018-07-31 08:49
yeah after sleeping on it last night i think so too. thanks.

uglyog
2018-07-31 09:30
Hmm, that doesn?t look right. You?ll need to enable debug logging to see what is going on

antonello
2018-07-31 10:55
Just to make sure I understand correctly: 1) a WIP pact is a pact tagged with a feature branch name that has not yet been successfully verified (ie. either there are no verification results, or the verification failed). 2) any pact that is tagged as `master` will not be considered a WIP pact and the provider pipeline will fail if the verification fails

bethskurrie
2018-07-31 10:55
`master` is just an example name

antonello
2018-07-31 10:56
ok, it will be configurable

antonello
2018-07-31 10:56
because my next question was going to be what if you want to force build failure for more than one branch (for example `master` and `release_candidate_v1.1.1`)

bethskurrie
2018-07-31 10:56
1 is almost correct - it's the "latest" of any tag that is not configured to be verified by the provider.

bethskurrie
2018-07-31 10:57
Usually, the provider has certain tags it chooses to verify - eg `master` and `prod`. WIP pacts are any that are the latest of their tags that aren't in the set of names the provider has chosen to verify.

antonello
2018-07-31 10:57
right, which answers my question above your last message.

bethskurrie
2018-07-31 10:58
Basically we take the list of all the head pacts that have no successful verifications, and remove the pacts that the provider is about to verify.

bethskurrie
2018-07-31 10:59
The one thing I haven't solved yet is what to do with pacts that never get successfully verified, and will never be verified because they are wrong, or the functionality has been decided not to be implemented.

bethskurrie
2018-07-31 11:00
We either need a clean up function, or the ability to remove them from the WIP set when running the verifications.

antonello
2018-07-31 13:08
I went to a meeting and just caught up with the messages now and I?m still a bit confused. I?ll try to give an example.

antonello
2018-07-31 14:08
In the processing of trying to write an example, I was wondering if it may be a useful feature to be able to specify an additional criterion for a webhook based on a list of tags. In other words, make it possible to only trigger a webhook if a pact with a specific tag (or list of tags) has changed.

antonello
2018-07-31 14:23
If that was possible, you could create a specific webhook so that, if a consumer publishes a changed pact from a feature branch (tagging it as `consumer_branch_1`), the pact can be verified by a specific provider branch, which will only verify pacts tagged as `consumer_branch_1`.

oswald.quek
2018-07-31 14:26
so my team ran into a problem recently, and I would like to check if there is a bug with the pact broker, or if our build pipeline is faulty... 1. we have a consumer service and a provider service, both of which have already been deployed to our test, staging and production environments. versions of both services are tagged with "test", "staging" and "production" respectively. 2. we changed the consumer pact to add more interactions and committed to master branch. (API wasn't changed on the provider service). our master build also automatically deploys to the test environment, but this failed because can-i-deploy said we couldn't deploy. makes sense because at this point there is no provider service deployed tagged with "test" that verifies the new consumer pact. 4. this was resolved by re-building the provider service (which A. pulls the new consumer pact from its master branch B. runs the provider tests and tells the pact broker the new pact is verified and C. sets a new version for the provider) and re-deploying (which tags the provider with "test"). the consumer service could then be deployed. 5. for the staging/production environment however, re-deploying the provider service first failed because can-i-deploy blocked the deploy of the provider service. i guess this is expected because for the new version of the provider, there is a new interaction from the consumer side, even though nothing has changed in the provider. note that do we not re-run provider contracts tests on the staging and production deployment builds. so we have a chicken-and-egg scenario - we can't deploy the consumer, because there's no corresponding provider tagged with "staging/production", but we can't deploy the provider, because there's no corresponding consumer tagged with "staging/production". what's the solution and/or what is wrong with my build pipeline? thanks.

nabrosimova
2018-07-31 17:58
has joined #general

nabrosimova
2018-07-31 18:05
Hi, I am trying to figure out how to do file_upload in ruby. Both provider and consumer are written in ruby. I did see pact-jvm examples with scala. But really need examples of how .i can set it up in ruby

nabrosimova
2018-07-31 20:39
@channel

clasalle
2018-07-31 21:24
has joined #general

matt.fellows
2018-07-31 21:49
@nabrosimova I can see you posting in a few channels here. The Ruby channel is probably the most appropriate place for this. That being said have you read through the FAQ, including https://docs.pact.io/faq#how-do-i-test-binary-files-in-responses-such-as-a-download?

matt.fellows
2018-07-31 21:50
In short, testing the actual body is not a recommended practice (but is possible). You can?t use matchers either.

nabrosimova
2018-07-31 21:55
@matt.fellows see I'm trying to upload file with post request which is a bit different problem than download

matt.fellows
2018-07-31 21:55
What?s the problem/difference?

matt.fellows
2018-07-31 21:56
If we take away the actual binary payload, the problems are quite similar. Our advice would be to set the correct path, mime types etc. and test those, ignoring the specific payload contents

nabrosimova
2018-07-31 21:58
well provider has to receive media, and send back it's id and status. the response part is just text but i need media to make the actual api call on the provider side

bethskurrie
2018-07-31 22:06
@antonello I've been expecting someone to ask for that eventually.

bethskurrie
2018-07-31 22:06
I'll put it on the backlog


bethskurrie
2018-07-31 22:11
@oswald.quek I will sit down and work through your scenario as soon as I have a moment.

richard.jones
2018-07-31 22:23
@uglyog the spec version 2 pact should be compatible, yeah?

richard.jones
2018-07-31 22:24
sorry it?s not in that gist (I didn?t want to paste the entire pact, there?s a dozen interactions in it) but the version is declared at the end ?metadata?: { ?pactSpecification?: { ?version?: ?2.0.0" } }

zb582
2018-08-01 02:27
has joined #general

thirumal.net
2018-08-01 06:20
PACT Verifier Issue

thirumal.net
2018-08-01 06:21
i am able to mock using mock service but when i try to verify the mock against the provider, it is throwing error. instead of mocking total service response, i did mock only one item. can you please help me what might be the issue ? Mocking Code : def test_callAPI (self): url = 'http://localhost:1234' expected = {'class': 'HealthCheck'} pact.given ( 'sending a request to url' ). upon_receiving ( 'class name should match with HealthCheck' ). with_request ( 'get', '/' ). will_respond_with ( 200,body=expected) with pact: result = callAPI ( url ) self.assertEqual ( result,expected )' *Mock JSON* : '{ "consumer": { "name": "consumer" }, "provider": { "name": "provider" }, "interactions": [ { "description": "a request for the health check", "providerState": "the health of the system is OK", "request": { "method": "get", "path": "/" }, "response": { "status": 200, "headers": { }, "body": { "class": "HealthCheck" } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }' *Real Service Provider Response* : '{ "class": [ "HealthCheck" ], "properties": { "timestamp": "2018-08-01T00:10:00+0000", "systemName": "Test", "buildInfo": { "buildDate": "2018-07-27T07:38:19+0000", "appVersion": "1111", "revision": "2 ", "branch": "develop" }, "health": "OK", "checks": [] }, "links": [ { "rel": [ "self" ], "href": " check" } ] }' i am trying to check only one item from real service response .getting below Error when running against real provider : *Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8***

timothy.clifford
2018-08-01 06:28
Um, is it because your real service provider is returning `{ class: [ "HealthCheck" ] ...}` instead of `{class: "HealthCheck"}`?

thirumal.net
2018-08-01 06:40
@timothy.clifford -Thanks, Yes , real service is giving class: [ "HealthCheck" ] so i have changed my mock url = 'http://localhost:1234' expected = {'class': ['HealthCheck']} but unfortunately same error is coming

thirumal.net
2018-08-01 06:44
@timothy.clifford - am i doing correct for just checking only item from real service response , even though it gives 3 items ? Thank you in Advance

timothy.clifford
2018-08-01 06:46
try it with both and see what happens? ¯\_(?)_/¯

matt.fellows
2018-08-01 06:48
@thirumal.net you probably want to use Matchers to match array contents: https://github.com/pact-foundation/pact-python#eachlikematcher-minimum1

matt.fellows
2018-08-01 06:48
If you expect exactly 1 element, but get back 3 it will fail. This matcher says ?I want an array to contain _at least one_ of these types of elements?

matt.fellows
2018-08-01 06:49
that being said, almost certainly there is another problem going on. It seems to be related to encoding.

matt.fellows
2018-08-01 06:50
I suggest we move this to #pact-python where you can get python specific help

thirumal.net
2018-08-01 07:06
@matt.fellows -Thanks, i have changed mock code as you mentioned 'def test_callAPI (self): url = 'http://localhost:1234' expected = EachLike({'class': ["HealthCheck"]}, minimum=1) pact.given ( 'the health of the system is OK' ).upon_receiving ( 'a request for the health check' ).with_request ( 'get', '/' ).will_respond_with (200, body=expected ) with pact: result = callAPI ( url ) self.assertEqual ( result, expected )' after doing this code change two things happened 1) mock was generated 2) even though mock creation successfull, there is error showing in mock it self *AssertionError: [{'class': ['HealthCheck']}] != <pact.matchers.EachLike object at 0x07244E90>*

thirumal.net
2018-08-01 07:07
if i execute the pact verifier same below errors are coming

thirumal.net
2018-08-01 07:07
* 1) Verifying a pact between consumer and provider Given the health of the system is OK a request for the health check with GET / returns a response which has status co de 200 Failure/Error: expect(response_status).to eql expected_response_status expected: 200 got: 403 (compared using eql?) 2) Verifying a pact between consumer and provider Given the health of the system is OK a request for the health check with GET / returns a response which has a matchin g body Failure/Error: expect(response_body).to match_term expected_response_body, diff_options Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8 1 interaction, 1 failure *

matt.fellows
2018-08-01 07:14
Please avoid posting all of this to general, at the very least keep it contained to a thread. Let?s move it to Pact Python - it?s not something everyone can help with

thirumal.net
2018-08-01 07:20
Sorry @matt.fellows. sure, Lets move to pactpython .i have asked the same question over there .

oswald.quek
2018-08-01 08:44
@bethskurrie thanks. maybe the solution is to have an option to disable can-i-deploy on a deploy of the provider if we know nothing has changed.

bethskurrie
2018-08-01 09:07
@oswald.quek you say "C. sets a new version for the provider" What are you using for your version number? Do you have a build number in there?

bethskurrie
2018-08-01 09:12
Which tags does your provider verify?

bethskurrie
2018-08-01 09:12
Just so you don't have to wait another day for me to reply, I'll give you a couple of potential problems/fixes.

bethskurrie
2018-08-01 09:14
Your provider should be configured to verify `test`, `staging`, `production` (and `master` if that's what you call your main development branch). Also, your version number should not contain a build number. I'll see if I can work out how to explain this.

bethskurrie
2018-08-01 09:18
If you are changing the provider version with every build, but you aren't verifying the test/staging/production pacts with every build, you won't have a verification result that links those versions of the consumer with the latest provider.

bsayers
2018-08-01 09:27
Feel free to direct me to the right place to ask this if in here is wrong: We recently had an incident that spawned a debate on what is and is not the responsibility of Pact to detect. The incident was caused by a client who set the request content type header to ?application/json? (which by default has an encoding of utf-8) but it then encoded the request body using a different charset (ISO-8859-1). When the consumer side tests using pact were run they passed and recorded a pact file, but at this point the charset of the request body had been changed by pact as it saves the body within a utf-8 encoded json file, so we are not able to detect this issue via the pact file. So with green pact tests we deployed and the production provider rejected the requests with a http 400 response. So my question is should Pact be responsible for failing on the consumer side when the requests content encoding and the request body encoding do not match? Or should Pact be recording the requests more precisely (a much bigger deal as changing the pact format is hard)? What is the philosophy on what Pact should and should not be validating?

bethskurrie
2018-08-01 09:29
That's a tricky one. Ideally, I'd like to say Pact could catch that, but we often have issues with anything that's not UTF-8 encoded.

bethskurrie
2018-08-01 09:30
TBH, I thought application/json had to be UTF-8 encoded.

bethskurrie
2018-08-01 09:30
I'm quite willing to be corrected on that though.

bethskurrie
2018-08-01 09:31
I suspect the answer is, it would be great if it could, but it may be too technically difficult.

bethskurrie
2018-08-01 09:32
I don't think you can mix file encodings, so having a ISO-8859-1 encoded body inside a UTF-8 pact file would seem impossible to me.

bethskurrie
2018-08-01 09:33
Maybe we should detect and warn about that scenario.

bsayers
2018-08-01 09:39
I agree detecting it on the provider side via a pact file is difficult, you?d have to find a way of encoding the file without losing the information. I can imagine options where the encoding that was used is saved separately and the pact replay mechanism knows how to reproduce that encoding during verification. What are your thoughts on detecting this on the consumer side? Should pact attempt to detect bad requests based on basic knowledge of http?

bethskurrie
2018-08-01 09:39
If you can suggest some reasonable logic, I'd be ok with adding it.

bethskurrie
2018-08-01 09:40
Could your scenario have been detected on the consumer side though? If it was a default, rather than an explicit encoding?

bsayers
2018-08-01 09:41
In our case the logic that rejected the request came from a framework rather then provider specific code

bethskurrie
2018-08-01 09:42
We could warn "hey, you're using something that's not utf-8 and that's not normal", but there's nothing apart from convention to make that warning on.

bsayers
2018-08-01 09:42
So some generic sever code looked at the request and decided it was invalid

bsayers
2018-08-01 09:44
That might prevent some incidents, although our experience tells us warnings are ignored more often then not.

bethskurrie
2018-08-01 09:44
I agree.

bethskurrie
2018-08-01 09:45
I would never suggest that contract tests can or should be able to identify every integration issue - I think in this case, if you think it's worth trying to come up with a technical solution, we can raise a card for it, or we can say, the effort required for adding this is not proportional to the risk of not having it.

bsayers
2018-08-01 09:50
Ok so your main concerns are around cost and complexity of implementing such checks

bsayers
2018-08-01 09:51
You are ok with the idea of Pact ensuring requests are valid in terms of http in principal

bsayers
2018-08-01 09:51
Have I got that right?

bethskurrie
2018-08-01 09:51
Yes, I think so. Others may disagree!

bethskurrie
2018-08-01 09:51
In principle, I'd like to see encoding faithfully represented, however, I'm unsure of the effort/reward ratio.

bsayers
2018-08-01 09:53
Hmm I see a difference between capturing the request faithfully vs detecting the request is no good up front and just refusing to record it

bsayers
2018-08-01 09:53
Do you have a preference?

bethskurrie
2018-08-01 09:54
Yes - the second one is much easier!

bethskurrie
2018-08-01 09:54
Seeing as you're the first team who has encountered this issue that we know of, I'd say the effort/number of people affected ratio is much better for the second option.

bethskurrie
2018-08-01 09:57
Gtg, but can chat more later.

matt.fellows
2018-08-01 11:08
hi all, I?d like to announce that I?ll be in the US later this year for re:Invent: - San Francisco: 19th-24th November - Las Vegas: 25th Nov - 1st Dec (re:Invent) The plan is to get to a few meetups in SF and also to run some hands-on workshops. If anybody would like to catch up, attend a workshop or digitally hangout in a local timezone, please DM me - I?d :heart: to chat! (P.S. I?m one of the core contributors and are in constant comms with other core contributors, in case you were thinking ?who the **** is that guy??)

hstene
2018-08-01 11:16
Very cool!

mats.lundkvist
2018-08-01 15:26
@bethskurrie right now we're doing it manually but I'll have a look after my vacation, thank you for the help :)

oswald.quek
2018-08-01 15:37
when I say "C. sets a new version for the provider", I lie! it's just the git commit sha of the latest commit. in this case, it happens there were new commits (non-API related) on the provider side.

oswald.quek
2018-08-01 15:41
actually, i'm not sure why step 4 worked for me. even though i rebuilt the provider here, i'm not sure how can-i-deploy gave it the green light for the provider to be deployed? (we're asking the pact broker whether we can deploy the provider where the tag is "test")

oswald.quek
2018-08-01 15:46
because when i rebuilt the provider (which runs the provider tests), it fetches the consumer pact where tag is "master" and presumably publishes verification where the tag is "master". so I don't know how it got deployed to the test environment, because we're asking can-i-deploy whether we can deploy the provider where the tag is "test"

oswald.quek
2018-08-01 15:47
when you say my provider should be configured to verify `test`, `staging`, `production` and `master` should that be happening in step 4 where I run the provider build?

balthasarbiedermann
2018-08-01 18:28
has joined #general

tushar.gavhane
2018-08-02 04:05
has joined #general

bethskurrie
2018-08-02 07:13
Yes.

bethskurrie
2018-08-02 07:13
That's your problem.

bethskurrie
2018-08-02 07:14
If you only verify master, then there is no verification result between the current test, staging or production consumer versions.

bethskurrie
2018-08-02 07:14
So can I deploy will return false.


oswald.quek
2018-08-02 08:36
yes that makes sense! thanks for all your help.

bethskurrie
2018-08-02 08:37
Np

fatih.kuyucuoglu
2018-08-02 09:35
has joined #general

fatih.kuyucuoglu
2018-08-02 10:06
Hi all, I have a question about the @PactFilter annotation. I need to run a method after a specific state in provider test. In my case the only way to do this is separating the test states in different test classes and using @After annotation for that specific state. Anyway, to get this behaviour, I use the @PactFilter. Everything works fine, but the verification results are not published, I get this message "Skipping publishing of verification results as the interactions have been filtered". Is it possible to publish the verification results of filtered states? If I can not publish the verification results, what is the goal of @PactFilter annotation? Thanks in advance for your support :slightly_smiling_face:

shekharsp27
2018-08-02 10:37
@fatih.kuyucuoglu are you using latest version of pact?

fatih.kuyucuoglu
2018-08-02 10:47
Hi Shekhar i am using the version, which is https://github.com/DiUS/pact-jvm here given as latest. So: Version 3.5.19

uglyog
2018-08-02 10:47
The provider states support a teardown call, which will be invoked afterwards. But it is not implemented for JUnit. Maybe raise an issue for this.

uglyog
2018-08-02 10:58
If the test execution is filtered, the verification results will not be published. This is because the verification status is for the entire pact file.

fatih.kuyucuoglu
2018-08-02 11:05
Hi uglyog thanks for the quick answer. :slightly_smiling_face: Could you give me some clue, starting point, i would like to try to find a solution for that. I will create also an issue.

balthasarbiedermann
2018-08-02 12:30
I'm planning to implement a Kotlin DSL for Pact. My current proposal is in the #pact-jvm channel: https://pact-foundation.slack.com/archives/C9UN99H24/p1533212507000007 *Feedback is very much appreciated*

mark.bridgett
2018-08-02 14:10
Anyone here use the pact-stub-server much?

matt.fellows
2018-08-02 21:10
I use it, what's up?


uglyog
2018-08-02 22:55
It will need to change to support a teardown call afterwards

sethimudit2002
2018-08-03 06:35
has joined #general

fatih.kuyucuoglu
2018-08-03 09:59
Thak you for the answer, i will look at this.

cparrish
2018-08-03 18:42
has joined #general

liran.tal
2018-08-05 18:03
I only put a build number in the version to transfer the pact contract from the unit/integration testing phase to the CI which needs to pull it again from the broker for E2E, when that?s done the contract with the build number as version becomes useless and I tag it as ?development? or ?production? and the consumer?s version which is semver (i.e: 2.1.0). any webhook triggers I will have will only work on the ?development? and ?production? contracts which use actual consumer version, never a build version.

liran.tal
2018-08-05 20:36
where-as the recommended pattern on the consumer side is to create the contracts during unit testing of the consumer?s http client implementation, I wonder what is the recommended approach on doing API testing on the consumer side (think `supertest` or `spring test mvc`) ? anything else beyond just mocking the http client call at that phase ?

dhanarajvallabhuni
2018-08-05 20:54
has joined #general

bethskurrie
2018-08-05 23:10
I think the answer is "whatever works for your situation". I've worked on MS where we didn't mock anything, and other services where we provided mock implementations of certain classes, and others where we used standard mocking frameworks.

david.dyke
2018-08-06 06:30
has joined #general

sgarvey
2018-08-06 11:22
has joined #general

tcanascimento
2018-08-07 14:28
has joined #general

emre.duendar
2018-08-07 14:35
has joined #general

joshua.haney
2018-08-07 15:39
has joined #general

liran.tal
2018-08-07 19:26
to clarify, when I said API testing I referred to integration tests (not e2e test for the server-side). - when you say one option was to not mock anything do you mean you used CDC to make a real request and return stubbed responses? I?m thinking that I can re-use the same mocks that will be used for the unit test in the integration tests.

conallbennett
2018-08-07 22:12
has joined #general

rabih
2018-08-08 09:16
has joined #general

rabih
2018-08-08 09:23
Hello, I am using pact for contract testing for our microservices built in golang. I have added some integration tests in a consumer and added build integration tests to CircleCI. I am using hosted pact broker http://pact.dius.com.au. The issue is that the tests are running without updating the contracts in the broker. Any help regarding this issue or any one have worked with integrating pact with CircleCI :question:

antonello
2018-08-08 09:25
I imagine your code is explicitly publishing your pacts?

rabih
2018-08-08 09:39
after adding the interactions, yes I am publishing pacts with the pact broker settings

antonios.klimis
2018-08-08 09:41
has joined #general

rabih
2018-08-08 10:53
ci config : service-integration: <<: *defaults environment: PACT_BROKER_HOST: ?https://.http://pact.dius.com.au/? PACT_BROKER_USERNAME: ?? PACT_BROKER_PASSWORD: ?? steps: - checkout - setup_remote_docker - run: name: Authenticate with GCR command: | docker login -u _json_key -p ?${}? https://eu.gcr.io - run: name: Create source volume command: | docker create -v ${CIRCLE_WORKING_DIRECTORY} --name source alpine:3.7 /bin/true docker cp ./ source:${CIRCLE_WORKING_DIRECTORY} - run: name: Running integration tests command: CONTAINER_NAME=service-integration make integration - run: name: Copying integration test results command: docker cp service-integration:${CIRCLE_WORKING_DIRECTORY}/test/. ./test - store_test_results: path: ./test destination: test - store_artifacts: path: ./test destination: test

antonello
2018-08-08 12:02
What do your logs say when the tests run?

rabih
2018-08-08 12:22
Consumer: ^@^@Running tests: === RUN TestGetTriggers --- PASS: TestGetTriggers (0.00s) === RUN TestGetTriggerByID --- PASS: TestGetTriggerByID (0.00s) === RUN TestGetTriggerByStatus --- PASS: TestGetTriggerByStatus (0.00s) === RUN Test_pactTriggerControlConsumer_CreateTriggerEvent --- PASS: Test_pactTriggerControlConsumer_CreateTriggerEvent (0.00s) === RUN Test_pactTriggerControlConsumer_TriggerCancelledEvent --- PASS: Test_pactTriggerControlConsumer_TriggerCancelledEvent (0.00s) === RUN Test_pactTriggerControlConsumer_TriggerDeletedEvent --- PASS: Test_pactTriggerControlConsumer_TriggerDeletedEvent (0.00s) === RUN Test_pactTriggerControlConsumer_TriggerErroredEvent --- PASS: Test_pactTriggerControlConsumer_TriggerErroredEvent (0.00s) === RUN Test_pactTriggerControlConsumer_TriggerFailedEvent --- PASS: Test_pactTriggerControlConsumer_TriggerFailedEvent (0.00s) === RUN Test_pactTriggerControlConsumer_TriggerCompletedEvent --- PASS: Test_pactTriggerControlConsumer_TriggerCompletedEvent (0.00s) === RUN TestPactProvider --- PASS: TestPactProvider (0.00s) PASS ok

rabih
2018-08-08 12:23
provider: ^@^@Running tests: === RUN Test_pactTriggerControlProvider_Verify --- PASS: Test_pactTriggerControlProvider_Verify (0.00s) PASS ok

matt.fellows
2018-08-08 12:28
Can you please share your test code? You need to explicitly set the verification to true

matt.fellows
2018-08-08 12:32
When you say "not updating in the broker" what do they mean. Contracts aren't being published from the consumer? Verification status not updating from the provider?

rabih
2018-08-08 12:43
both, contracts are not being updated or published and the verification status not updated

rabih
2018-08-08 12:59
req := types.PublishRequest{ PactURLs: []string{filepath.ToSlash(fmt.Sprintf(?%s/triggerconsumer-controlprovider.json?, pactDir))}, PactBroker: os.Getenv(?PACT_BROKER_HOST?), BrokerUsername: os.Getenv(?PACT_BROKER_USERNAME?), BrokerPassword: os.Getenv(?PACT_BROKER_PASSWORD?), ConsumerVersion: ?1.0.0?, Tags: []string{?latest?}, }

rabih
2018-08-08 12:59
pact.VerifyMessageConsumer(t, message, triggerCompletedHandlerWrapper) p := dsl.Publisher{} err := p.Publish(getRequest())

codypumper
2018-08-08 13:10
has joined #general

liran.tal
2018-08-08 13:10
@rabih on the consumer side, I advise to only do contract testing for unit testing the http client

rabih
2018-08-08 13:13
we are using it also for Message Queue integration testing

liran.tal
2018-08-08 13:17
MQ or HTTP, you probably want to unit test both. do you create the contracts through unit tests or integration tests ?

rabih
2018-08-08 13:20
through integration tests

liran.tal
2018-08-08 13:21
can you share more on how you do integration tests? are you actually hitting some endpoint to trigger the flow?

rabih
2018-08-08 13:22
when testing it without CI it is working, when the CircleCI build runs it is not


liran.tal
2018-08-08 13:26
that doesn?t say much about how you are actually running and what you?re doing in integration tests. the problem is in the terminology - people mean different things when they say integration testing.

liran.tal
2018-08-08 13:27
regardless though, my input for you would be that you might be hitting 2 different providers in a single integration test flow and I noticed that this complicate and couples the flow

smuthaiah
2018-08-08 16:42
has joined #general

mbudde
2018-08-09 08:46
has joined #general

richard.hulm
2018-08-09 09:13
has joined #general

rabih
2018-08-09 15:24
the issue is resolved, by adding pact cli tools in the docker image

rabih
2018-08-09 15:24
however, I am getting this issue now unable to convert consumer test to a valid JSON representation: error creating message: exit status 127 STDERR: /go/lib/ruby/bin/ruby: line 6: /go/lib/ruby/bin.real/ruby: No such file or directory STDOUT:

rabih
2018-08-09 15:27
however, I am getting this issue now unable to convert consumer test to a valid JSON representation: error creating message: exit status 127 STDERR: /go/lib/ruby/bin/ruby: line 6: /go/lib/ruby/bin.real/ruby: No such file or directory STDOUT:

bethskurrie
2018-08-09 21:57
@rabih please ask questions about pact-go in the #pact-go channel.

bethskurrie
2018-08-09 21:59
Also, if you can provide a executable example, you will get better help.

such.su
2018-08-10 07:37
:wave:Does anyone know whether pact-python provides a matcher for matching or ignoring an object key?

bethskurrie
2018-08-10 08:26
In the consumer or provider?

bethskurrie
2018-08-10 08:27
You must specify all keys on the consumer side, and any key you don't specify will be ignored on the provider side.


such.su
2018-08-10 09:25
To be accurate, my question is exactly the same as this one - https://stackoverflow.com/questions/48317108/pact-python-matching-keys-in-response

bethskurrie
2018-08-10 11:49
This is not yet supported in python.

gergia
2018-08-10 17:06
has joined #general

davidmichaelkarr
2018-08-10 18:05
I haven't done much with pact-jvm yet, but I have a question about the json pact file. Our team has a different convention for the name of the pact file, and they've designed this somewhat messy AfterClass method that they want everyone to put in their tests, to rename the file. Is there a cleaner way to do this?

uglyog
2018-08-11 03:18
You can override it in code by extending the Pact model class. There is no configuration for the filename.

gaurav
2018-08-11 11:34
In defining mock for `BigDecimal`, I set type as decimal: `.decimalType("amount", new Decimal(100))`.. but on provider side (I am using mockMvc), it fails with `$.result.parent.0.child.0.amount -> Expected 100 to be a decimal number`. I am pretty sure that on provider side, `amount` in model is `BigDecimal` type. Should I set different type in mock definition? Anything I am doing wrong? Thanks.

gaurav
2018-08-11 13:11
Stacktrace for :point_up:

gaurav
2018-08-11 14:28
Changing to `numberType` worked!

simon.nizov
2018-08-12 09:00
has joined #general

liran.tal
2018-08-12 14:16
is it possible to define multiple responses (meaning they span across multiple requests made) for a single interaction? the purpose is to test API interactions like pagination or continuation tokens

liran.tal
2018-08-12 14:17
admittedly this is probably more of an internal test where I?d just mock the entire request entirely but having them on the same test suite (both mocking the request being made as well as not mocking it and doing an actual request to CDC) feels awkward a bit

liran.tal
2018-08-12 14:18
probably best practice is to mock this internally, let me know if you feel otherwise

antonello
2018-08-12 14:52
@liran.tal IMHO - even if you were able to specify multiple request/responses for one interaction with pact - it wouldn?t be a good idea. I?m not sure if this is what you mean when you say ?mock internally?, but I would simply have separate interaction and use the provider state for each one to make sure that you set up the state in the provider so that it returns what you need in each case.

liran.tal
2018-08-12 15:14
that?s what I?m saying too basically.. it?s more about testing internal handling (the consumer ms) of bulk requests. Not sure though what you meant about the provider state, because basically this is a single test case.

antonello
2018-08-12 15:19
Could you give an actual scenario of what the test is just to make sure I understand unambiguously?

antonello
2018-08-12 15:28
To me it sounds like you want to test a session in a single test.

liran.tal
2018-08-12 15:37
yeah of course. the use-case is where my provider has an API to get a list of items but I can?t request more than 10 in one request, so if I want to request 20 item ids I need to split that to sending 2 requests of 10.

antonello
2018-08-12 15:43
How different is the second request from the first one? I assume both responses will have the same contract.

liran.tal
2018-08-12 15:46
exactly. that?s why I?m saying it?s probably an internal logic test for the consuming microservice

antonello
2018-08-12 15:54
If the two requests are different though, there may be a case for some contract testing. It?s difficult to say without an actual example.

liran.tal
2018-08-12 16:52
while I see that query param arrays are supported through `query: { ids: ['1', '2'] }` which translates to `/someapi?ids=1&ids=2` is it possible to specify a query param array list with the [] notation? i.e: `/someapi?ids[]=1&ids[]=2` ?

bernardo.guerreiro
2018-08-12 19:43
has joined #general

wilkin4
2018-08-12 19:56
has joined #general

david.j.smith
2018-08-12 20:17
Scala-Pact versions `2.2.5` (SBT 0.13.x) and `2.3.2` (SBT 1.x) released. http://io.itv.com/scala-pact/change-log.html

bethskurrie
2018-08-13 00:03
Nice work @david.j.smith

bethskurrie
2018-08-13 00:05
Hm. With which implementation @liran.tal?

bethskurrie
2018-08-13 00:05
Anything that wraps the ruby expects array param names to have square brackets at the end.

lindblad.n
2018-08-13 07:26
has joined #general

liran.tal
2018-08-13 07:59
I?m referring to the javascript/node implementation. maybe @matt.fellows knows more about how to specify an array for the `ids[]=1` type of notation

such.su
2018-08-13 08:30
Got it. Thanks.

matt.fellows
2018-08-13 11:33
Ah, there was an issue with this. I?ll dig it up

liran.tal
2018-08-13 11:35
ahh thanks

liran.tal
2018-08-13 11:35
for now I just hardcoded `query: 'id[]=1'` but would like to find a fix for it which allows me to dynamically compose the query with use of matchers


matt.fellows
2018-08-13 11:36
It might not be obvious, but the `eachLike` matcher works here - it?s an array too!

matt.fellows
2018-08-13 11:36
so something like ``` describe.only("get /dogs using builder pattern", () => { before(() => { const interaction = new Interaction() .given("I have a list of dogs") .uponReceiving("a request for all dogs") .withRequest({ method: "GET", path: "/dogs", headers: { Accept: "application/json", }, query: { param: eachLike("1"), }, }) .willRespondWith({ status: 200, headers: { "Content-Type": "application/json", }, body: EXPECTED_BODY, }); return provider.addInteraction(interaction); }); ``` should work

liran.tal
2018-08-13 11:37
not quite. this will create an expected interaction of query being like `param=1&param=2` which will not be compatible with my request using square brackets: `param[]=1&param[]=2`

liran.tal
2018-08-13 11:37
unless I?m mis-reading that issue (it?s quite long so maybe I missed something)

matt.fellows
2018-08-13 11:41
Hmm, let me doubl check this

matt.fellows
2018-08-13 11:47
you?re right.

matt.fellows
2018-08-13 11:47
so if you want the array notation, you can do this: ``` query: { 'param[]': eachLike("1"), }, ```

liran.tal
2018-08-13 11:56
thanks! I?ll try and will add to my to do list to update the docs and code examples for it

nathanrobert.smith
2018-08-13 12:34
has joined #general

matt.fellows
2018-08-13 13:16
That?d be amazing, thanks!!

amitojduggal
2018-08-13 14:47
has joined #general

antonello
2018-08-13 15:58
Hi all! One of the ?buts? that it?s often brought up when I talk to people about pact is: ?_But how do you make sure that the responses that you expect are up to date? What if you forget to add a field that you?ve recently started consuming?_? My usual answer is ?_There is no guarantee that you won?t forget, but it?s like adding any other type of test. If you forget to write a test for a specific scenario, you won?t be covered for that. It?s a matter of discipline, mixed with code inspections such as code reviews_?. However, I can understand why it may be useful to have some kind of mechanism to help you catch cases in which you forget to update your expected responses. The only way that I can think of, if for example you are lucky/unlucky enough to have some functional tests that mock provider responses, is to use the same responses for those tests and for your consumer pact tests. I am playing in my mind with the above idea and it would be very simple to achieve if your expected pact responses were json objects (which will certainly be if you?re using `pact-js`). However, it gets a little more complicated if you?re using matchers, in which case you would have to perform some kind of _reification_, similarly to what?s done here: https://github.com/pact-foundation/pact-support/blob/master/lib/pact/reification.rb What do people think? Any reason why it may be a bad idea? Finally, should we want to port the reification logic, would you have recommended approaches?

liran.tal
2018-08-13 16:31
I hear you but I think your response to that was well put. Pact doesn't protect you from forgetting and it's not its goal and I'm concerned you might be complicating it too much if you'll try to do it

harris.osserman
2018-08-13 16:54
has joined #general

david.j.smith
2018-08-13 17:04
@antonello To go to the original question: ```"But how do you make sure that the responses that you expect are up to date? What if you forget to add a field that you've recently started consuming?"``` If you?re testing your client code correctly in your consumer tests**, and verifying the pacts against the provider? this should not be possible? (** This might be easier in a statically typed language because you would typically deserialise into a real Type, which is a way of proving that all the fields you expect are indeed there? - perhaps that?s what you meant by reification?)

antonello
2018-08-13 18:35
@david.j.smith That makes complete sense, it?s what the documentation recommends, but, as you say, it?s not easy in JavaScript, if at al possible. You may need to go quite high up the stack to actually have a degree of certainty, which would be impractical and make the tests quite complicated.

can
2018-08-13 18:39
Hey @antonello - As you know, my mission here is to Kotlin everything. Though I haven't used Kt/JS interop, it might make testing JS a little easier?

antonello
2018-08-13 18:41
It is the language of the application code that matters. Unless the front-end teams decide to re-write them or parts of them in kt, it probably won?t help. Typescript has started to be used though, which will help in the long term.

antonello
2018-08-13 18:46
Talking about js consumers, in order to test them you probably end up repeating mocked responses a lot. So having a way of removing the repetition and the pain of having to update responses in multiple places when they change would be something positive, imho. For the same reasons you?d want to use builders in strongly typed languages.

codypumper
2018-08-13 20:31
Our team has been able to use Typescript to define a type, then create an "expected object" of that type (letting the linter check for properties/types). Then, before creating the interaction, we take that expected object, and loop through its properties to apply the matchers and create yet another object which then gets passed to the Pact interaction.

antonello
2018-08-13 21:01
Interesting! Would you be able to provide an example?

abubics
2018-08-14 02:05
The pattern I use (and recommend) is to have a connector that converts the api client model (on-the-wire data model) into a application domain model, and asserting that it has the right shape and types in the Pact test. This lets Pact focus on the transport verification (in `given` and `when`), and the unit test focus on domain verification (the `then` part).

abubics
2018-08-14 02:06
How strict you want to be about types, etc, is up to the application developers. You can use typescript of flowtypes or whatever if you want better safety :slightly_smiling_face: All these concerns should be decoupled

paul.davies
2018-08-14 03:31
has joined #general

paul.davies
2018-08-14 04:18
Hi all, I'm pretty new to Pact and have checked the Stack Overflow but no luck with my problem. I'm having an issue with a Date query parameter which is handled by a DateTime argument resolver at runtime. When debugging my application I can hit the endpoint with this command: GET http://localhost:9090/plan/master/active?from_start_date=2018-08-01T22:00:00.000Z and I can see the date has been correctly interpreted, however when I run my Pact Provider test, which has this in the Pact contract:

2018-08-14 04:18
This message was deleted.

paul.davies
2018-08-14 04:18
~The date comes through as null~

bethskurrie
2018-08-14 04:19
Hi @paul.davies You'll get more focussed help if you ask in the channel for your language.

paul.davies
2018-08-14 04:19
Ah right, thanks. It'll be Java - I'll post there. Cheers!

antonello
2018-08-14 06:04
@matt.fellows What are your thoughts on this?

antonello
2018-08-14 08:06
@david.j.smith By reification in this context, which is what the class in the link does, I mean taking a body with matchers and transform the matchers into a response body without matchers.

simon.nizov
2018-08-14 08:18
Hi! Newcomer here. This project looks incredible so far :smile: I noticed that there is a LOT of useful ?theoretical? information present in the pact-ruby github wiki that I feel should be in the general docs at http://pact.io. For example, took me a while before I found this: https://github.com/pact-foundation/pact-ruby/wiki/Provider-states which was very helpful to understand how provider verification works. I realize this probably happened because the ruby project was the first to be developed. Is there a plan to move this into the general docs? I can help out with the dirty work if someone can guide me on where to put things.

bethskurrie
2018-08-14 08:42
Hi @simon.nizov you're right about the ruby project having the documentation first, but most of it should have been migrated. For example, here are the provider state docs https://docs.pact.io/getting_started/provider_states

bethskurrie
2018-08-14 08:42
If there are things missing, please do let us know so we can move them. Always happy to accept PRs for improving the docs.

simon.nizov
2018-08-14 08:48
Ahh.. weird that I missed that one. I?ll keep an eye out, thanks!

david.j.smith
2018-08-14 09:03
Interesting. I had a similar idea ages ago? thanks for the description!

antonello
2018-08-14 09:09
That is exactly what?s done when a pact file is written. The matchers are stripped out, replaced by an example and matchers sections added to the pact json.

amitojduggal
2018-08-14 11:38
Hello guys, want to know what scheme or workflows everyone is using for the service that is being consumed by the UI interfaces and not by another service. For example, Provider: P Consumer: UI Interface. So the provider tests will be kept in the codebase for "P" but what about the Consumer Test, which service repository should those be kept in? if its an app. Should those be kept as part of android/ios code base?

matt.fellows
2018-08-14 12:24
Tests belong with their code

matt.fellows
2018-08-14 12:26
That's a good starting point unless you have a good train not to

matt.fellows
2018-08-14 12:28
Help is always welcome though, and that website is fully managed in GitHub. If you see small things feel free to send a PR but for big things maybe have a chat in #documentation first

simon.nizov
2018-08-14 12:30
Already did a couple of days ago :wink: https://github.com/pact-foundation/pact.io/pull/58

simon.nizov
2018-08-14 14:52
Is there a way to share matchers between services? Imagine you have domain-specific rules that you?d like to use as matchers across multiple services, written in different languages. For example, the ID of a quote must start with ?Q-?.

codypumper
2018-08-14 14:56
Sure! Our metadata call tests call that responds with our "MetadataRes" type: ```// Metadata for SS35538_35538_29885250, "If the Color Changes" const expectedMetadataObject: MetadataRes = { 'title': 'If the Color Changes', 'category_name': '', 'icc_profile_loc': null, ... } // We want to use Pact to verify the types of the properties on the response let matcherMetadataObject = {} Object.keys(expectedMetadataObject).forEach( (key) => { matcherMetadataObject[key] = Matchers.somethingLike(expectedMetadataObject[key]) })``` Where `expectedMetadataObject` is a sample object of that form. And in this case we're testing the form of the top level properties on the response, so we loop through the values, and add matchers for each one to `matcherMetadataObject`, which is then used in: ``` willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json' }, body: matcherMetadataObject }```

codypumper
2018-08-14 14:58
The `MetadataRes` type is used for this response within our app, so expectations of properties are pretty solid and consistent

codypumper
2018-08-14 14:59
@simon.nizov Something like a shared Regex library could handle that pretty well?

simon.nizov
2018-08-14 15:00
What if the services are written in different languages?

antonello
2018-08-14 15:06
:thumbsup:

antonello
2018-08-14 15:13
@codypumper if you?re applying a `somethingLike` to all properties, why not just decorate the whole object with `like`?

sandeep.seshadri
2018-08-14 15:18
has joined #general

matt.fellows
2018-08-14 22:52
:ok_hand:

dagarwal
2018-08-15 06:42
Hi ,is it possible to create interactions in JS like this ?matchingRules?: { ?$.query.var1[0]?: { ?match?: ?regex?, ?regex?: ?.*? }, ?$.query.var2[0]?: { ?match?: ?regex?, ?regex?: ?.*? },

dagarwal
2018-08-15 06:42
what should i pass in var 2 that my two api calls are successful


dagarwal
2018-08-15 06:43
Is it possible to do by provider states?

abubics
2018-08-15 06:44
If you?re trying to do it in JS, try in #pact-js :slightly_smiling_face: you?ll get better answers

dagarwal
2018-08-15 06:44
Thanks

abubics
2018-08-15 06:44
also, try and post code wrapped in back-ticks, e.g. ```

codypumper
2018-08-15 16:27
Is there a way to pass an object to like()? I see that I can give it a list of properties, and I could iterate through properties similarly, but based on the docs, I can't just `Matchers.like(expectedMetadataObject)` and expect type matching for properties

codypumper
2018-08-15 18:39
Using ".like()" on the object results in: ```"matchingRules": { "$.body": { "match": "type" } }``` in the Pact. I'm assuming this is top level only? As in this would only verify that the body is an _object_ type

codypumper
2018-08-15 19:14
Say you have two different object forms that come back from the same endpoint, but via different IDs. ID1 returns an object with audio metadata, and ID2 returns an object with message metadata. Would the Pact assumption be to match for the combination of all available properties on ID1 object and ID2 object?

codypumper
2018-08-15 19:15
:thinking_face:

codypumper
2018-08-15 19:19
It's ugly, but I was imagining a shared file of regex strings essentially

codypumper
2018-08-15 19:19
¯\_(?)_/¯

antonello
2018-08-15 20:30
That is my understanding. That if you do it on the whole object, all properties will be matched by type. I can?t check the docs now, but I remember @bethskurrie also confirming.

antonello
2018-08-15 21:12
> Note that you can wrap a like around a single value or an object. When wrapped around an object, all values and child object values will be matched according to types, unless overridden by something more specific like a term.


david.dyke
2018-08-15 23:03
I've had a similar situation, the way I've gone about it is to write the unit tests of my consuming application to run through handling both of these scenarios, first it will make a call to ID1 and process that response, then make a call to ID2 and process that one. The Pact mock will provide these differing responses as my tests run. The validation at a provider level will require it to respond differently for ID1 and ID2 with the correct objects, for this you need to use providers states which will be along the lines of "ID1 is an object with audio data" and "ID2 is an object with message data"... the consumer sets these states in the Pact so that the provider knows how to setup its state before running the validation. Thus for validation of the provider, ID1 should return one kind of response and ID2 should return another

davidkgp
2018-08-16 14:37
has joined #general

codypumper
2018-08-16 18:38
Thanks @david.dyke! That makes sense, and I hadn't considered using states

codypumper
2018-08-16 18:42
Thanks for the reference Anto!

leomayleomay
2018-08-16 19:29
has joined #general

leomayleomay
2018-08-16 19:34
I am trying to setup Pact for test like ``` Pact.service_consumer 'Authentication Service Consumer' do has_pact_with 'Authentication Service Provider' do mock_service :authentication_service_provider do port 1234 end end end ``` and got an error saying ``` Failure/Error: mock_service :authentication_service_provider do port 1234 end RuntimeError: Port 1234 is already being used by Authentication Service Provider #<Pact::MockService::App:0x007f874ef487b0> ``` please help to advise what's going wrong here, cheers

matt.fellows
2018-08-16 22:02
Looks like you are starting multiple services on the same port

pburls
2018-08-17 08:33
has joined #general

pburls
2018-08-17 09:02
Hey, I was wondering if anyone has used Pact Contracts and Pact Broker to help capture a "to-be" architecture for a new project? I like the idea of teams using the Pact Broker as a reference to start and then slowly creating and validating contracts with the actual implementations.

rrosa
2018-08-17 09:24
has joined #general

david.j.smith
2018-08-17 09:47
I?ve thought about it. The relationship visualisations - currently amazing to most people - would need to be cleverer. Also the ?problem? with Pacts is that they only show the aspects on a API that a consumer cares about. If it?s a microservice architecture that?s likely fine because they probably care about all of it, but if there?s a monolith in there somewhere your documentation would have holes in it. We do write Pacts in advance of services being built for a) stubbing in leu of a real service and b) a TDD style validation point for the team doing the provider service build. This means we have the relationship in pact broker before it?s ?real?.

pburls
2018-08-17 10:19
True, there would be holes where there are monoliths, but generally there is one team maintaining those. So in terms of them understanding new interactions with other services, it would be fine.

pburls
2018-08-17 10:20
It's good to hear though that creating Pacts in advance isn't a crazy idea.

pburls
2018-08-17 10:22
How are you creating these new Pact Contracts though? Hand cranked or creating some kind of prototype unit test to generate it?

matt.fellows
2018-08-17 10:50
I?ve used it a few times to describe potential designs with other teams (green fields / new items only). Obviously it?s a shallow ?architecture? as it only shows which systems communicate with each other - it doesn?t show types of communication, queues, other systems in context

david.j.smith
2018-08-17 11:52
The scenario for us has typically been: A supplier up stream is going to build us a new API. We discuss the design and when we think we?ve got it, we put together a project that will become our consumer service and just write the Pact tests first. Once generated, the Pact contracts can be sent over to make sure both parties have the same expectations for the new API.

pact-box
2018-08-17 19:53
has joined #general

pact-box
2018-08-17 19:56
I need to spin up an HTTP server for every provider test in Golang (1.0.0-beta). I can do this easily enough using provider states but then how do I tear it down when each test is complete?

pact-box
2018-08-17 21:51
I no longer need an answer but Slack won't let me delete the above message.

matt.fellows
2018-08-17 22:23
All good, it can linger. I don't think you can delete after a certain time

richarddalziel
2018-08-18 21:22
has joined #general

richarddalziel
2018-08-18 21:25
Hey folks - Looking for some help. I'm using PactJS with Karma+Jasmine in my Angular project. I'm essentially following this sort of style - https://github.com/paucls/task_list_ui-angular/blob/feature/pact-consumer-contract-tests/src/app/tasks-list/tasks.client.pact.spec.ts It worked fine when i just had one spec file - but since i've got many services i've started spinning up several of these files. Ever since i've done this i seem to get a lot of incosistent failures on my CI Builds

richarddalziel
2018-08-18 21:26
It's hard to tell - but it seems like the issue relates to specifying "new PactWeb" more than once. But i can't figure out how to maintain it's lifecycle with Karma and Jasmine the correct way and can't find any examples online with more than one spec file

richarddalziel
2018-08-18 21:27
I get a consistent spam of 500s in my terminal for mocked interactions which is fairly annoying. That's possibly a symptom to the issue. I get these even if the tests are passing

uglyog
2018-08-19 02:44
moved to #pact-js

richarddalziel
2018-08-19 09:34
Ah apologies - didn't notice!

pau
2018-08-20 10:52
has joined #general

tonimellodic
2018-08-20 15:05
has joined #general

ted.chung
2018-08-20 20:52
has joined #general

richarddalziel
2018-08-21 07:26
What's the correct way to manage queries based of resource Id when Id is not known? Do you normally just setup seeded defaults with Ids for this or is there a smart way to chain tests together?

abubics
2018-08-21 07:51
"chaining tests" sounds like you're trying to test behaviour :slightly_smiling_face: that's not the intended usage

abubics
2018-08-21 07:52
Each test should encapsulate its own state (using the `given` keyword, usually), and not interact with other tests

richarddalziel
2018-08-21 07:55
It does in my head too (Lead to behaviour) - which is what brings me to the question. There are many "GetById" or children creation tests which base off Id where i care about the contracts too. How should these Ids be handled within the tests?

abubics
2018-08-21 08:39
could you elaborate on that? I'll try and give you a general example in the meantime . . .

abubics
2018-08-21 08:41
Say you have a test that expects an entity with some particular seed data in it, you might just specify a provider state as "a user with some foos and bars", which describes the situation abstractly, but then the consumer and provider know which specific data can be expected to exist

abubics
2018-08-21 08:42
so maybe given *a user with some foos and bars*, you can do a `GET /user/3` for a result of `{"id":"3","foo":["x","y"],"bar":["a","b","c"]}`, or whatever you need to be able to assert on

richarddalziel
2018-08-21 08:44
Here's a series of interactions i'm thinking of in RPC style GetAllClients - returns all clients with required schema. (_Links, _embedded etc) GetClientById (HTTPGET "/client/{Id}") - Returns Client with _Links/Other Props CreateChildForClient (HTTPPOST "client/{Id}") - Returns 201 Created and Whatever Body

abubics
2018-08-21 08:46
Someone else might be better at helping with that kind of scenario . . . I tend to stick to ReST APIs. What I can say, though, is while you stick to requests with no side-effects, you can chain as many as you want and still reason about the system :slightly_smiling_face:

abubics
2018-08-21 08:46
So you can chain many read-only requests before finishing on the thing you care about (which may have side-effects)

abubics
2018-08-21 08:48
But also, if you set your state up well, you don't need to do the first 2 GETs, because you can know which IDs they'll have ahead of time.

abubics
2018-08-21 08:48
and each test can just exercise one endpoint at a time

richarddalziel
2018-08-21 09:51
Apologies - i'm only using RPC terminology for convenience of writing here. I suspect the answer is more about setup my state. The detail that's tricky here is that i use Guids for my Ids. So i can't make any assumptions - i need to feed data returned from one call to the next. Which means the contracts are going to be test-run specific

richarddalziel
2018-08-21 09:59
How do you normally go about setting up your state @abubics?

abubics
2018-08-21 13:36
Maybe we need to step back a little... How much of your provider stack are you trying to verify? If you don't stub/replace at least the data layer, you'll have pretty complicated tests :)

abubics
2018-08-21 13:38
For the example you gave, I'd have at least 3 separate tests: 1. List clients (given some clients, given no clients, etc) 2. Get client details (given a client with known id, given no clients (e.g. returns a 404)) 3. Create a child for a client (given a client with known id, etc)

abubics
2018-08-21 13:39
And in the provider you need to facilitate the states by providing expected data somehow. How you do it depends on the provider platform.

abubics
2018-08-21 13:41
My example implies 3 endpoints, at least 2 provider states, and 5 separate tests (one interaction per test) ^_^

richarddalziel
2018-08-21 14:40
That's pretty much along the lines of the tests i'm thinking - i suspect the sticking point in my head is i'm creating restrictions by not having a representative data seed scenario. I think what i need to do is have a representative data seed scenario which can be used specifically for contract testing with known ids, that sounds like it'll be a cleaner solution than faffing with behaviour style tests.

richarddalziel
2018-08-21 14:41
The only counter in my head here is that this implies the consumers have some prior knowledge as to how the provider seeds data for testing scenarios. I do like the idea of the consumer not really caring how the provider goes about their business, just that they adhere to the specified contract.

richarddalziel
2018-08-21 14:55
Just to touch on your first point - i want to test as much of my provider as the consumer uses. If the consumer cares about hateos links, then i want it in the contract. If it cares about x, y, z properties - i want it in the contract. Same goes for any relevant headers etc

richarddalziel
2018-08-21 14:55
It just so happens in this case i have a consumer which uses the API fairly extensively

thirumal.net
2018-08-21 19:58
can we write pacts if project is written in C++ ? if yes can you please point me to the link for more info

matt.fellows
2018-08-21 21:30
Not to my knowledge sorry!

matt.fellows
2018-08-21 21:32
But you could run the mock service (consumer) and provider externally to your service. E.g. https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh


nmalinip
2018-08-21 23:23
has joined #general

abubics
2018-08-22 00:41
My question about "how much" was more about how far down your provider protocol stack are you trying to test. So, if you have a strongly layered stack, you might have web-framework endpoints at the entry point, a business layer with controllers, entities, gateways, etc, and connectors to talk to databases, etc.

abubics
2018-08-22 00:42
You certainly wouldn't want to test across another network boundary (e.g. database), and I'd suggest even going past the core entity layer isn't so valuable.

abubics
2018-08-22 00:43
You're right that the consumer shouldn't care *how* the provider does things (such as allocate IDs), but at some point, the consumer will cache an ID for a future request. That's the situation you want to represent with the "given" states.

abubics
2018-08-22 00:44
i.e. pretend you already did a request to list all Clients. Now you have some IDs, and you can do either of the other requests.

abubics
2018-08-22 00:46
Pact tests are more for verifying the shape of the data, not the concrete content. Things that are part of the request can be verified as literals in the response. Anything generated in the provider should be flexibly matched (by type and/or regex), so the tests aren't brittle.

abubics
2018-08-22 00:50
And yeah, we basically share fixture expectations across consumers and providers.

richarddalziel
2018-08-22 10:38
It's funny - in any of my diagrams for representing this i never include the full stack (To Database). But my current setup has this! I'll need to dig around a bit for how to setup the Given states/caches and see how i can leverage them! I'll be honest - this is a bit more of a faff than i'd hoped. There is a temptation just to mark my own homework here with unit tests on the API. The additional effort is feeling simpler than the state management for theses tests

bherrera
2018-08-22 17:05
has joined #general

bsolosy
2018-08-22 17:08
has joined #general

jkoropchak
2018-08-22 17:23
has joined #general

thirumal.net
2018-08-22 18:41
@matt.fellows - Thank you for the info, i think same applies to languages like SAP ABAP,SFDC APEX,BW . am i correct ? unable to find any documentation for above languages.just want to re confirm that we can't write native pacts for above programming languages.

tmok01842
2018-08-22 21:46
has joined #general

matt.fellows
2018-08-22 21:49
correct

tmok01
2018-08-22 22:02
hey all - does there exist an equivalent .net version of the can-i-deploy feature (which checks the matrix to determine whether things can be deployed)? (just left this query in the pact-net channel as well)

matt.fellows
2018-08-22 22:07
hmm not sure. It should be on the system somewhere (as the CLI tool will be there). If it?s in a predictable path, you could just invoke it directly (it?s what I do with node, for example)

tmok01
2018-08-22 22:18
'k, thanks Matt

bethskurrie
2018-08-22 22:29
You can use can-i-deploy from the command line in windows @tmok01

thirumal.net
2018-08-22 22:45
Thank you Matt

tmok01
2018-08-22 22:55
Ok - thanks @bethskurrie. I'm just starting out on this stuff.


abubics
2018-08-23 00:58
The shallowest version of contract testing I've done just stubbed responses at the controller layer :slightly_smiling_face: Especially if your DB makes it hard to be deterministic, there are heaps of ways to avoid it. Otherwise you're just building integrated tests with the wrong tools :stuck_out_tongue:

abubics
2018-08-23 01:04
And the highest technical value of contract tests is literally unit tests for the network interface. Unit tests for your API won't keep consumers and providers in sync. That's the main thing Pact aims to solve?letting you know if it's safe (or not) to deploy changes.

richard.jones
2018-08-23 04:56
@bethskurrie I?m struggling to find that pact best practices document you wrote and shared a while back, please hit me with the clue bat? :slightly_smiling_face:

abubics
2018-08-23 05:03
is it the "The steps to reaching Pact Nirvana" doc?

richard.jones
2018-08-23 05:25
I think so!

richard.jones
2018-08-23 05:25
Yep, that got me to it, thanks!

richarddalziel
2018-08-23 06:37
I pretty much agree 100% with what you're saying. I think there still is an element of state that needs to be considered. But it doesn't need to be considered with the full stack behind it. Like what Ids generate not found, which generate bad request and all the other variations (if they matter to the consumer).

abubics
2018-08-23 07:09
Yep, totally. The states are test fixtures that are shared (to some extent).

dev
2018-08-23 07:19
has joined #general

komalahluwalia06
2018-08-23 07:21
has joined #general

scott.jungers
2018-08-23 14:30
has joined #general

dniles
2018-08-23 16:23
Hello - I'm trying to find a way to hook into the rest call during a pact provider verification task in order to get a response body, is this possible? My scenario is that the provider verification creates a resource when it makes a call, and the provider responds with the ID of the newly created resource. I want to be able to get the ID from that response to do clean up in the tear down step of the provider state, but as-is I'm unable to access the response from the verification task's rest call at that point. I'm using the Ruby pact-provider-proxy gem to run the provider verification. Thanks in advance for any insight anyone might have.

thirumal.net
2018-08-23 19:10
@matt.fellows - by chance do you know any future plans to support for C++ ?

matt.fellows
2018-08-23 20:50
No plans that I'm aware of, although we do have a set of static libraries that can be linked in from c, so it's entirely possible without having to write it from scratch


nmalinip
2018-08-23 20:53
versions used in my project are 'au.com.dius:pact-jvm-consumer-java8_2.12:3.5.16' 'au.com.dius:pact-jvm-consumer-junit_2.12:3.5.16'

tmok01
2018-08-23 22:41
Um - did Pact Broker just go down?

bethskurrie
2018-08-23 22:41
Let me check

tmok01
2018-08-23 22:42
seems up again now - but was getting 'service unavailable' on a couple of requests

bethskurrie
2018-08-23 22:42
Test one is up, pm me your broker domain

bethskurrie
2018-08-23 22:45
We're currently working on a new multi tenant architecture, which we should be moving customers to over the next few weeks. It will be much more stable than the existing infrastructure.

amitojduggal
2018-08-24 09:22
Guys, what strategy you use for formatting the PactDslJsonBody code blocks in IntelliJ?

richarddalziel
2018-08-24 11:02
For whatever reason i can't seem to find anything in the docs. Is there much documentation around the usage of states aside from just specifying them in Given/Object based setups? I've only ever seen the text referenced but never what the underlying components that represent the state? Perhaps i'm over complicating the capability - but if i'm not then i don't really understand the purpose of state.

bethskurrie
2018-08-24 11:29
It's up to the provider team to set up the right data so that the actual response matches the expected response.

bethskurrie
2018-08-24 11:29
The simplest example is to set up an object so that you get a 200 instead of a 404.


richarddalziel
2018-08-24 13:34
Ah!!! The first post is what i've been looking for. That makes sense ! So in terms of team culture - the correct behaviours here will to be name states fairly explicitly such that the provider team can react to the failing test by reading the provider State and providing the necessary information

richarddalziel
2018-08-24 13:35
So for example State('the object with the id Guid.Default()' exists)

chaitralikulkarni84
2018-08-24 14:38
has joined #general

krosenbaum
2018-08-24 16:00
has joined #general

ayodaiken
2018-08-24 19:08
has joined #general

thirumal.net
2018-08-24 20:16
@matt.fellows - Thank you very much!

nmalinip
2018-08-24 23:17
Hey guys, is there a way to delete the pacts from pack broker? How do u handle the pacts that will be published with every PR?

matt.fellows
2018-08-24 23:18
Yes there is. Go and check out the pact broker wiki, your answers await..

nmalinip
2018-08-25 00:06
Thanks Matt. But I wanted to know if we delete the individual pacts? The delete api in the doc says that the all the pacts related to that participant will be deleted

matt.fellows
2018-08-25 00:12
You can, everything is a resource so just fire off a delete at it


bethskurrie
2018-08-25 02:42
I've updated to make it super clear.

nmalinip
2018-08-25 05:01
Thanks Beth

abubics
2018-08-27 01:41
This is totally a #pact-jvm question, but here you go :slightly_smiling_face:

abubics
2018-08-27 01:41
``` .willRespondWith().run { headers(contentTypeHeaders) status(200) body(newJsonBody { container -> with(container) { minArrayLike("accounts", 1) { with(it) { stringType("id", "S01-01") stringType("name", "Access Account TestOne") stringMatcher("type", "savings|investment|loan", "savings") numberType("availableBalance", BigDecimal("5.00")) numberType("currentBalance", BigDecimal("5.67")) } } } }.build()) } ```

abubics
2018-08-27 01:41
that's in Kotlin, I don't have a strategy for Java :stuck_out_tongue:

abubics
2018-08-27 01:42
You can go more abstract or more concrete for different levels of brittleness :stuck_out_tongue:

abubics
2018-08-27 01:43
But I try to keep mine pretty vague, and just describe the situation, so things can be added without changing expectations

jarpit
2018-08-27 06:53
has joined #general

minhdoan
2018-08-27 07:07
Hi @bethskurrie and team,

minhdoan
2018-08-27 07:12
I downloaded the Pact standalone executables 1.54.3 and extracted it on my local Windows 10 laptop

minhdoan
2018-08-27 07:14
And i put an directory of pact json files here as well

minhdoan
2018-08-27 07:17
Then i run the command to bring up the server and load the pact files to server

minhdoan
2018-08-27 07:17
```pact-stub-service.bat "D:\pact\bin\pacts"```

minhdoan
2018-08-27 07:17
But the error happens and am not familiar with Ruby to debug it

minhdoan
2018-08-27 07:19
Could you please help on it?

minhdoan
2018-08-27 07:19
Many thanks in advance!

minhdoan
2018-08-27 08:12
As i change the command line to: ```pact-stub-service.bat "D:\pact\pacts\*"```

minhdoan
2018-08-27 08:12
No error but i can not confirm that the Server is up

minhdoan
2018-08-27 08:25
And please help to provide some examples for pact-stub-service usage

matt.fellows
2018-08-27 10:00
It?s like it?s not reading the files from a directory, and is expecting a single file

matt.fellows
2018-08-27 10:01
OK so the stub service doesn?t expect a dir, it expects one or more files as space separated values

matt.fellows
2018-08-27 10:02
`pact-stub-service ~/development/public/pact-js/examples/e2e/pacts/*` works on linux shells, because `*` is automatically expanded into the right shape

matt.fellows
2018-08-27 10:02
so looks like you need to do something more like `pact-stub-service.bat "D:\pact\pacts\PACT_FILE1_HERE" D:\pact\pacts\PACT_FILE2_HERE" ...`

minhdoan
2018-08-27 10:16
@matt.fellows Many thanks! When i add each file's path the server is up

minhdoan
2018-08-27 10:17
But anyway to import all of files on Windows because that way quite weird and quite to handle

matt.fellows
2018-08-27 10:22
It?s probably quite easy in Powershell, I can?t recall the syntax off the top of my head though

matt.fellows
2018-08-27 10:23
If you like, raise a feature request at https://github.com/pact-foundation/pact-mock_service

minhdoan
2018-08-27 10:28
Highly appreciate @matt.fellows I will work on it

matt.fellows
2018-08-27 10:31
:thumbsup:

kimmig.alex
2018-08-27 13:23
has joined #general

rsaccoll
2018-08-27 13:26
has joined #general

richarddalziel
2018-08-27 15:31
It's just where things go round to accessing specific resources by their Id. Vagueness becomes a problem there although i'd very much appreciate it!

richarddalziel
2018-08-27 15:31
Managed to get up and running better with it - cheers for the help folks!

ashish.dubey91
2018-08-27 21:17
getting `/app/pact-stub-server: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory` on running pact stub server docker container https://github.com/pact-foundation/pact-stub-server

matt.fellows
2018-08-27 21:18
Are you running in an Alpine Docker container?

matt.fellows
2018-08-27 21:19
Have you looked at the existing published Docker container

ashish.dubey91
2018-08-27 21:20
I just pulled the latest as mentioned in the README

ashish.dubey91
2018-08-27 21:20
I didn't build my own container

matt.fellows
2018-08-27 21:21
Hmmm

matt.fellows
2018-08-27 21:22
Can you please raise a bug report? I should be able to look later today

ashish.dubey91
2018-08-27 21:22
sure @mr.matt.r.long


matt.fellows
2018-08-27 21:27
Are you also on a Mac? I wonder if something in the host runtime as changed.

matt.fellows
2018-08-27 21:40
Cc @uglyog looks like latest stub server missing static or runtime dep

uglyog
2018-08-27 22:36
@ashish.dubey91 I added TLS support in that release. Use the previous version until I fix the docker image.

uglyog
2018-08-27 22:36
Or you can create your own docker image and add openssl libraries

matt.fellows
2018-08-27 22:39
I can take a look today if you like @uglyog?

matt.fellows
2018-08-27 22:40
Assuming it just needs some ssl libs in the image itself? Or does it need to be compiled into the Rust code?

uglyog
2018-08-27 22:47
No, just add openssl to the image

pavan.tallapragada
2018-08-27 23:10
has joined #general

thirumal.net
2018-08-27 23:42
@thirumal.net - i have spring mvc rest application and it doesn't have any test cases. could you please help us how to write pact unit test cases for provider ? please point us to sample example

mpasumarthy
2018-08-28 00:24
has joined #general

matt.fellows
2018-08-28 01:21
OK just pushed the fix, let me know how you go @ashish.dubey91

bethskurrie
2018-08-28 02:13
What documentation have you looked at already? Where have you searched? What have you googled? Please demonstrate that you have tried to solve the problem yourself.

abubics
2018-08-28 04:27
Pretty sure `cmd` globs files with `*` too :thinking_face:

matt.fellows
2018-08-28 04:28
probably, but I?m not willing to stake my reputation on it :slightly_smiling_face: (or to admit i?ve used CMD before)

shreekanth.6
2018-08-28 09:09
has joined #general

chitl
2018-08-28 12:30
has joined #general

ashish.dubey91
2018-08-28 14:58
thanks man! I'll check

ashish.dubey91
2018-08-28 15:00
I'm noticing an issue in my CI setup with pact involving the hosted pact broker. here is how it is - with pact-jvm and gradle plugin I'm pushing my pacts with the branch name as the tag

ashish.dubey91
2018-08-28 15:00
when I fetch the pacts from this url `/pacts/provider/API/consumer/android/latest/dev` I get the latest pact published from *any* branch rather than specifically `dev` branch always

ashish.dubey91
2018-08-28 15:01
because of this my provider build fails because of unstable contracts pushed in feature branches of the consumer

matt.fellows
2018-08-28 21:05
:+1:

mpasumarthy
2018-08-28 22:17
Hi, I am looking for sample pact project built on spring mvc from provider side. could someone please provide link here

matt.fellows
2018-08-28 22:20
What have you tried so far? A cursory google turns up a bunch of links

mpasumarthy
2018-08-28 22:26
I am actually developing using the steps provided in the below link. https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-spring

tjones
2018-08-29 04:14
So I'm writing some consumer code for an API that I don't control (GitHub's OAuth2.0, for those playing at home). Is there value in writing pact tests for the consumer?

tjones
2018-08-29 04:15
My gut feel is yes - even if there's no provider verification, the tests provide some documentation and some regression protection

bethskurrie
2018-08-29 04:15
:shrug::skin-tone-3:

tjones
2018-08-29 04:15
And, possibly it's possible to use something like the pact/swagger thing to do some pretend verification?

tjones
2018-08-29 04:16
I don't remember seeing this question in the documentation, but it seems worth including

tjones
2018-08-29 04:16
I think there was a stackoverflow question on it a while back

bethskurrie
2018-08-29 04:16
sure, if there's a swagger

matt.fellows
2018-08-29 04:17
I still write pact tests as a consumer for the same reasons. I?ve also previously done some ~nasty~ not-so-nice things to validate them also


tjones
2018-08-29 04:19
What were your not-so-nice things? Validate responses against the live API?

bethskurrie
2018-08-29 04:46
Yeah. I don't like to do that.

bethskurrie
2018-08-29 04:46
Swagger would be better.

matt.fellows
2018-08-29 04:49
Pretty much, except when you start thinking about ?provider states? this gets very hard when you can?t control the endpoint. I?ll say ?proxy? and let your imagination do the rest :slightly_smiling_face:

mpasumarthy
2018-08-29 05:03
~Following the below steps and created a provider for validation. <https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-spring> when I try to test pact with state something like {id} does not scenario i.e. 404 error against get end point which accepts integer path variable like this somepath/{id}, seeing the below exception {"@timestamp":"2018-08-28T21:52:48.114-07:00","app_env":"no","app_name":"no","app_version":"no","thread_name":"main","level":"ERROR","logger_name":"com.aligntech.ids.services.patients.error.ApiResponseExceptionHandler","message":"Exception was handled for web request: ServletWebRequest: uri=/api/somepath/9643628244167;client=127.0.0.1","stack_trace":"org.springframework.web.method.annotation.MethodArgumentTypeMismatchException: Failed to convert value of type 'java.lang.String' to required type 'java.lang.Integer'; nested exception is java.lang.NumberFormatException: For input string: \"9643628244167\"\n\tat org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:131)\n\tat org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124)~

mpasumarthy
2018-08-29 05:04
~not sure this is a valid question or not, but how this mock data id generated "9643628244167"~

mpasumarthy
2018-08-29 05:10
please never mind about my question..

abubics
2018-08-29 05:28
If you're only doing JVM stuff, I'd recommend starting in #pact-jvm, rather than adding noise in #general :slightly_smiling_face:

oliver.levett
2018-08-29 08:36
has joined #general

amit.koparkar
2018-08-29 13:23
has joined #general

shekharsp27
2018-08-29 14:22
Hi, is there any graphical representation for 'The steps to reaching Pact Nirvana' document which will help to understand ideal way to implement pact test in CI/CD

raido.letterbox
2018-08-29 14:45
Hi, I am trying to write consumer tests with pact for dotnet core. After enabling SSL for MockProviderService the test fails with "System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure". I've seen in the documentation that it is recommended to ignore certification validation errors globally due to a selfsigned certificate by adding ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; But unfortunately this didn't help. Can anyone please suggest what else can be done?

mpasumarthy
2018-08-29 16:08
@abubics thanks..I did not know about it..will join in that group. thanks..:)

ypeng1
2018-08-29 16:53
has joined #general

ypeng1
2018-08-29 16:56
Consumer test worked on windows but not on linux, can anyone help with this issue?

matt.fellows
2018-08-29 21:15
Might want to ask this in #pact-jvm

tjones
2018-08-30 01:43
Hi Shekhar - I thought there was one in the documentation at http://pact.io, but I can't see it. I'll look into making one.

shekharsp27
2018-08-30 04:53
Thanks, Tim :+1:

madhukar.mishra
2018-08-30 06:04
Hi, is it possible to represent non-heterogenous arrays in pacts ?

bethskurrie
2018-08-30 06:10
Currently, only if you have a set order

madhukar.mishra
2018-08-30 06:32
Thanks, any docs I could look up to understand what my options are ?

madhukar.mishra
2018-08-30 06:32
here's my problem in more detail if you have time to take a quick look


david.dyke
2018-08-30 06:44
This is a recent document I put together to explain interaction between consumer, provider, swagger hub and a pact broker, work in progress but it's helping people to understand

abubics
2018-08-30 08:22
Try in #pact-net :slightly_smiling_face:

uglyog
2018-08-30 08:32
`call site initialization exception` is probably a result of a serious mismatch with your setup. Can you provide the OS version, Java version, Pact-JVM version etc.

dev
2018-08-30 09:07
Hi, we are currently using pact a little bit to test contracts between services of different teams. The documentation notes that the tests should never break the build of other teams. How do you integrate the execution of the tests in the CI process? Running the consumer tests and publishing the contracts shouldn't be an issue to do it on every master build. But then should the provider test be run? And against which version of the contracts? We had the idea to run the provider tests every night against the current master contracts. If a test is failing the team of the provider should look into the issues and try to figure out how they can work together with the consumer team to fix the issue. What do you think, is this a good way, or do you have better ideas?

raido.letterbox
2018-08-30 09:58
Thank you :slightly_smiling_face:

richard.jones
2018-08-30 23:32
@dev I can?t speak for everyone but we have a separate test plan that just runs the verifier for each provider. The plan is maintained by the team owning the provider. It is triggered automatically by any pact being registered against the provider in the pact broker. The latest plan result is then listed against any PR for the provider (since it?s not the build for the PR it doesn?t prevent any specific PR from being merged, it?s just in your face when you review the PR). All the results are also visible in the pact broker per consumer/provider version pair. The latest verification result is also reflected in our grafana dashboard, which gives us a nice heads up that something needs attention.


abubics
2018-08-31 01:48
Ideally, you should make the provider verify every time a Pact changes

abubics
2018-08-31 01:48
but there are some strategies for how exactly you do that, depending on your architecture, app layout, and component lifecycles

abubics
2018-08-31 01:49
For example, one way is to have matching feature branch names on the consumer and provider, and only verify results for pacts tagged with the branch name.

bethskurrie
2018-08-31 01:55
@uglyog is there anything in v3 that can help with this?


bethskurrie
2018-08-31 02:00
@madhukar.mishra Pact really works best when you are able to control the data on the provider so that the responses look like you expect. If you're having trouble with this, Pact might not be the best tool for you.

l.vetter
2018-08-31 09:16
has joined #general

shekharsp27
2018-08-31 10:02
Thanks David for sharing the image will go through it

romuald.quantin
2018-08-31 10:33
has joined #general

shekharsp27
2018-08-31 14:07
@tjones I have a question, in case if Provider is changing the interface and before deployment observes there are breaking consumers, in this case ideally provider should do versioning for interface(and convey consumer about the interface version for backward compatibility and ask to update consumer as per new interface ) and move ahead with the deployment how this workflow should work could please help me to understand

brice.jaglin
2018-08-31 14:18
has joined #general

abhijitkane
2018-08-31 18:25
has joined #general

ashish.dubey91
2018-09-02 12:56
this is happening when I try to run pact-provider-verifier with `--publish-verification-results=1` ``` Error making request - Errno::EPIPE Broken pipe , attempt 3 of 3 /pact/lib/vendor/ruby/2.2.0/gems/pact-1.33.1/lib/pact/provider/verification_results/publish.rb:99:in `rescue in publish_verification_results': Failed to publish verification results due to: Errno::EPIPE Broken pipe /pact/lib/ruby/lib/ruby/2.2.0/openssl/buffering.rb:326:in `syswrite' (Pact::Provider::VerificationResults::PublicationError) ```

ashish.dubey91
2018-09-02 16:02
I think this was because my provider return a massive response and it was too much for the CLI to post the results to the broker..didn't know it actually sends the entire verification log

oswald.quek
2018-09-03 08:43
The way my project does it is by running the pact against a checked out provider master branch during the consumer CI build

pact-slack
2018-09-03 12:29
has joined #general

pact-slack
2018-09-03 12:43
Hi :wave: My elixir pact library (http://github.com/elitau/pact_elixir), which is wrapping the pact-reference Rust implementation works for simple cases. Now I want to extend it towards the generation of matchers like regexp, type, query params, etc. What is the best way to achieve this? I assume I have to "copy" the DSL of the Ruby implementation in Elixir?!

dev
2018-09-03 15:15
@abubics Thank you, that document really helped a bit.

andyharkinsqa
2018-09-03 15:34
has joined #general

dev
2018-09-03 16:24
We had lately a discussion going on belonging how much of the service should be tested when running pact tests. What do you mock on consumer/provider side? As much as possible or as few as possible?

tom.hombergs
2018-09-03 16:33
has joined #general

richard.jones
2018-09-03 21:55
@dev pact isn?t testing the provider or the consumer, it?s enforcing a contract between them. On the consumer side pact mocking *aids* testing of the consumer code at that interface. Pact verification tests exactly enough of the provider that is needed to verify all pacts are correct. Does that help?

mboudreau
2018-09-03 23:49
@dev As however many contracts makes your team happy and confident in the deployment. It could be only a few (more like a health check) or all of them if you're super keen on 100% coverage :slightly_smiling_face:

richard.jones
2018-09-04 00:20
We have 100% coverage in our consumer unit test suites, and use pact mocking for all external API points (as opposed to more generic mocking for other parts of the code). Using flexible pact mocks (having Like and Term in the requests) makes that a lot easier.

abubics
2018-09-04 00:29
It sounds to me like @dev's question is more about depth (of app layers) rather than breadth (of endpoint, features, error cases, etc) . . . I would argue that Pact tests should go only as deep as the minimum required to get to logic that provides enough branching for errors. It depends on your app architecture. On the *provider* side if you had a clean architecture, with a framework-based endpoint layer, and a domain interface beyond that, that should be deep enough to provide thorough value. On the *consumer* side, with a similar architecture, I'd expect a framework-based API client, and a domain interface before it. Definitely don't need to go higher up the protocol stack to test the contract :slightly_smiling_face:

abubics
2018-09-04 00:30
I've done shallower and deeper, and they felt like suboptimal trade-offs

uglyog
2018-09-04 00:31
That's awesome. I would start by creating a DSL that works best for the language, and then work out how to implement it.

uglyog
2018-09-04 00:32
If we need to change the Rust implementation, I can do that for you.

stephen.muss
2018-09-04 04:57
has joined #general

dev
2018-09-04 06:55
Thanks a lot!

dev
2018-09-04 07:00
And one more question. Does anyone have a reference or experience how I can implement a "many providers and one consumer" scenario? We have a single service that consumes an analytics message which can be send by every other service, how does that work?

ibenardetelevis
2018-09-04 07:05
has joined #general

mboudreau
2018-09-04 07:08
1 consumer can have multiple contracts with each provider, and 1 provider can have multiple contracts with each consumer :slightly_smiling_face:

pact-slack
2018-09-04 07:37
Ok. I'll come back here for feedback once I have something useable.

rhys
2018-09-04 10:30
has joined #general

pact-slack
2018-09-04 21:15
@uglyog Is there a Rust library that I can call to generate all the different matching rules? Or a codebase which I can use as a starting/learning point for generating pact files with matching rules?

joguespermana
2018-09-05 02:55
has joined #general

ashish.dubey91
2018-09-05 07:54
can pact-provider-verifier verify multiple consumer pacts for a given provider? If I supply a URL like - `/pacts/provider/authservice/tag/dev` to the verifier, the verifier doesn't traverse through the list of pacts and verifier

bethskurrie
2018-09-05 08:15
It should

bethskurrie
2018-09-05 08:16
Oh, do you mean, does it use the broker?

bethskurrie
2018-09-05 08:16
Yes, the latest version should

bethskurrie
2018-09-05 08:17
You can give it a broker address and a list of tags.

bethskurrie
2018-09-05 08:17
And the provider name.

ashish.dubey91
2018-09-05 09:14
@beth where can I find the docs for this? I can't see it here https://github.com/pact-foundation/pact-ruby-standalone/releases

bethskurrie
2018-09-05 09:20
Hm. Perhaps I haven't released it yet. I'll check for you tomorrow.

bethskurrie
2018-09-05 09:21
Ping me if I don't get back to you in 24 hours.

ashish.dubey91
2018-09-05 09:23
sure!


ashish.dubey91
2018-09-05 11:22
great. I just tried it got an error: `/Users/ashish/pact157/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.16.1/lib/pact/provider_verifier/aggregate_pact_configs.rb:42:in `wip_pact_uris': undefined method `fetch_wip_pact_uris' for Pact::PactBroker:Module (NoMethodError)`

bethskurrie
2018-09-05 11:23
Oh, bother. That's why I hadn't released it. I was in the middle of a refactor.

bethskurrie
2018-09-05 11:23
I renamed wip to pending.

bethskurrie
2018-09-05 11:23
I'll fix it in the morning for you.

bethskurrie
2018-09-05 11:24
Sorry about that

ashish.dubey91
2018-09-05 11:25
it's fine. fun to use this at the bleeding edge! :smile:

bethskurrie
2018-09-05 11:25
Walking on the wild side

ashish.dubey91
2018-09-05 13:42
I need some discussion around this. I'm guessing this might have happened already sometime - https://gist.github.com/bethesque/0ee446a9f93db4dd0697, but I need some help in this. I have a bunch of services (like API gateway and aggregation layer) which basically get responses from upstream services, and then either send the responses through to the front-end client or simply nest them under different keys I've written some contracts in the front-end client against the gateway, but I'd also like to verify the actual provider (upstream service) against these contracts

perrypercy
2018-09-05 14:15
has joined #general

uglyog
2018-09-05 22:10
Do you mean generate a pact file with all the matching rules, or are you asking about a Rust consumer test DSL?

uglyog
2018-09-05 22:11
Or do you need a function that just generates the JSON format for a particular matching rule?

matt.fellows
2018-09-05 22:27
Hi all, Are you interested in talking with the Pact maintainers at your place of work or getting involved in training events? I will be traveling to San Francisco the week of 19th - 23rd November 2018 to run a series of Pact workshops, brown bags and presentations at local meetup events. We are seeking early expressions of interest to help with planning and designing the most appropriate content, as well as for identifying future workshops in other locations. If this is of interest to you, please complete this short survey https://docs.google.com/forms/d/e/1FAIpQLSeHEq52irOfEr5W3sqMRcpIk9ZvybMqtDfEE3y11WYndcsnwA/viewform?usp=sf_link or DM directly. Thanks!

jake.shelley
2018-09-06 01:13
has joined #general

ashish.dubey91
2018-09-06 04:56
@mr.matt.r.long are you guys open for remote workshops/brown bags too?

matt.fellows
2018-09-06 04:56
yep!

matt.fellows
2018-09-06 04:57
It?s under ?online? in the survey if you were wondering

ashish.dubey91
2018-09-06 04:57
that's great! I'm interested in having one for my team

matt.fellows
2018-09-06 04:57
:thumbsup:

matt.fellows
2018-09-06 04:57
Thanks, I?ll chat with you offline about potential options - thanks for reaching out

ashish.dubey91
2018-09-06 05:06
thanks @mr.matt.r.long let me know when you want to do it. I also filled in the survey

matt.fellows
2018-09-06 05:21
fantastic, thanks!!

pact-slack
2018-09-06 08:02
I want to generate a pact file with all the matching rules. Until now the elixir library generates a really basic JSON which is then used to start the Rust mock server. To be able to use the existing Rust code is a great time and code saver. Now I was wondering if there is a Rust library which I can use to implement the missing functionalities like matching rules JSON generation?

pact-slack
2018-09-06 08:04
I need some kind of guideline which functionalities can be reused from the Rust reference implementation and which I need to implement myself.

dipakpawar231
2018-09-06 11:52
has joined #general

culbluswan123
2018-09-06 15:05
has joined #general

uglyog
2018-09-06 22:48
Ok, I'll put something together for you. Might only happen this weekend :wink:


potsawee
2018-09-07 06:16
has joined #general

pact-slack
2018-09-07 14:12
Super, thx. I'll have a look into it.

bethskurrie
2018-09-09 21:35
I've released the fix for this @ashish.dubey91

bethskurrie
2018-09-09 21:36
Sorry I forgot to mention it earlier

mattgilbert90
2018-09-10 12:45
has joined #general

mattgilbert90
2018-09-10 13:09
I am struggling to understand the basics of Pact and implementing my first test against a service. Our team has 20+ services and we'd like to use Pact to help with our contract testing. The tests all run locally? How does the Provider reach out to a specific environment where a service lives? How does the Consumer know what service to mock?

tom.hombergs
2018-09-10 20:08
@mattgilbert90 I struggled quite a bit, too. The tests run locally, that's the main advantage of contract tests. The consumer does not need access to a service and the service does not need to be called by the real consumer in order to be tested.

tom.hombergs
2018-09-10 20:10
I wrote down my thoughts on consumer driven contract tests in a blog post, maybe it helps :slightly_smiling_face: https://reflectoring.io/7-reasons-for-consumer-driven-contracts/

tom.hombergs
2018-09-10 20:11
there are some tutorials on pact with Java there, too.

mattgilbert90
2018-09-10 20:14
@tom.hombergs funny, i was reading your posts this morning. Does starting out with your first contract test require there to be a good bit of API documentation? We are switching to microservices from Monolith and there is not much documented, and what is documented cannot be trusted. Can I just use my knowledge of the system to get started or is there more?

mattgilbert90
2018-09-10 20:16
The main need for switching is the microservice tests that were developed previously used no framework and are super hard to maintain. Our UI tests also take 13 hours to run :face_vomiting:

matt.fellows
2018-09-10 22:16
I love your work @tom.hombergs, especially the summary table

bethskurrie
2018-09-11 01:29
@tom.hombergs what a stellar post. Recommend everyone read it!

tom.hombergs
2018-09-11 03:03
I'd say you can start with contract tests without an API documentation, because you're creating a contract and that IS a bit of documentation by itself.

glvargas
2018-09-11 14:03
has joined #general

tom.hombergs
2018-09-11 18:58
@bethskurrie thanks :slightly_smiling_face:

tom.hombergs
2018-09-11 19:01
Is it possible to test a consumer against an existing contract with pact-jvm? i.e. load the pact from a pact broker, start up a mock provider using that pact and then verify the consumer against the mock?

ypeng1
2018-09-11 20:22
Anyone know how to set provider version using pact-jvm-provider?

ypeng1
2018-09-11 20:22
Or how to publish test results back to pact broker when tests failed?


gaurav
2018-09-11 23:10
@tom.hombergs My opinion: if I understand correctly, what you want seems certainly doable.. however I personally would recommend against doing that.. A pact is only valid for the consumer that created the pact and that pact should not be used for any other consumer. Reason is that pact might reflect only a subset of response data from provider. If a provider P provides {a,b,c,d}, and a consumer C1 needs only {a,b} then pact(P-C1) will only have {a,b}.. and that pact can?t be used to create a mock server for a consumer C2 that needs {c,d} for example.

uglyog
2018-09-11 23:44
It is possible, you'll just have to use the pact-jvm libraries to do it

ypeng1
2018-09-12 04:57
anyone know how to detect pact contract change or not manually ?


bethskurrie
2018-09-12 07:09
The ruby impl does this too.


bethskurrie
2018-09-12 07:10
If you're using Pact JVM with version 3 rules, you'll need the JVM one though

daniel.kirmse
2018-09-12 09:17
~Das Repo git clone <ssh://d027470@git.wdf.sap.corp:29418/d027470/ase_sudoku_java>~

vishesh92
2018-09-12 09:49
has joined #general

vishesh92
2018-09-12 10:05
Hi I have a python project which uses https://github.com/getsentry/responses for mocking requests in unit tests. There are some parts where the requests are made to multiple providers. I wanted to know what is the best way to do this using pact.

matt.fellows
2018-09-13 00:14
I?m not quite sure what you?re asking @vishesh92. Are you asking if you should replace the responses library with Pact, or how they could be used together?

matt.fellows
2018-09-13 00:16
Looking at that library, if I understand correctly, I would be using them for separate purposes. Pact?s job is to capture the expectations of the request/response between the consumer and all of its providers. Responses would be better placed to do all of the standard unit tests you need to run, mocking out the interface so that you can test with all sorts of conditions - e.g. different data types and all of the local validation scenarios etc. you want to test. That?s not an ideal use case for Pact.

tom.hombergs
2018-09-13 18:19
thanks, I'll look into that!

tom.hombergs
2018-09-13 18:23
@gaurav yeah, you're right of course. But I have a special use case where I explicitly want to piggy-back onto an existing pact (while being concious of all the things you said)

matt.fellows
2018-09-13 22:21
Another gem from Tom on testing message consumer and producers with spring: https://reflectoring.io/cdc-pact-messages/

matt.fellows
2018-09-13 22:21
Relevent for all languages

micheal.ieti
2018-09-13 23:02
has joined #general

kanohen
2018-09-14 11:22
has joined #general

kanohen
2018-09-14 11:23
Hello world!

kanohen
2018-09-14 11:31
So, I have a response that looks like this: Books { "JD HUM": 20£, "ZAC ATEKS": 40£ }, ...... Other fields..e.t.c This book structure could have 1,2, more or no contents. At the moment, I am simply adding those two books e.g.book.object ("Books", book-> book.numberType ("JD HUM", "ZAC ATEKS")); How do I handle a generic case where I just define the structure e.g I need a map that has a key string and value number and I don't care if it has 1, 2 or no entry using pact?

matt.fellows
2018-09-14 11:34
I don't believe you can do this in the current version of pact with dynamic keys across languages (it might be available in pact jvm). it's slated for the next specification. If it was an array, it would be possible

matt.fellows
2018-09-14 11:35
It's hard to tell without context, but any reason it's not an array of books instead of a map?

kanohen
2018-09-14 12:32
Sorry, I was at lunch. An array won't work as we needed to get them by unique keys for quick referencing.

kanohen
2018-09-14 12:47
How would this be possible with an array if I may ask?

matt.fellows
2018-09-14 13:34
At the moment, Pact matches maps on exact keys only (see v4 for proposal to enhance this)

matt.fellows
2018-09-14 13:36
Array matching supports your use case: 1 or more objects with a generic shape. How big is this array, I can't imagine lookups being computationally slow (i.e. no worse than `O(n)`)


shekharsp27
2018-09-14 13:49
Hi, are there any guidelines to determine complexity associated with contract testing with respect to the implementation or which points needs to consider to derive complexity involved in implementing contract testing in general

kanohen
2018-09-14 15:09
The reason I ask is because if there isn't a generic way to define types, am afraid, it becomes complex working with complex request/response json structures on pact

daniel.straus
2018-09-14 19:28
has joined #general

daniel.straus
2018-09-14 19:36
Hi there.

daniel.straus
2018-09-14 19:39
Question about publishing pacts with SBT for Scala. We have our pact broker using basic auth as we have it in our ci build which uses a 3rd party service. But sbt seems to have an issue authing to the pact broken. Is anyone familiar with the pacts and sbt and had experience with this?

daniel.straus
2018-09-14 19:39
Thanks in advance

thirumal.net
2018-09-14 21:38
@matt.fellows can you please help me on below scenario? do we need to call real webservice call code in order to create pact files? if yes, how to create pact files for existing API code ? please let me know if you see any sample code with service call

thirumal.net
2018-09-14 21:40
def test_HappyPath (self): mockurl = 'http://localhost:1234' expected = {body:true} pact.given ( 'Given there is a valid form' ).upon_receiving ( 'fetch all the info ' ).with_request ( 'get', '/',headers={Authorization:'Bearer 58771381-333e-334f-9604-784'} ).will_respond_with(200, body=expected) with pact: result = callAPI ( mockurl ) self.assertEqual(result, expected )

thirumal.net
2018-09-14 21:42
'def callAPI (url): return requests.get ( url ).json()'

thirumal.net
2018-09-14 21:46
my understanding is callAPI is real production web service call ? am i correct ? if yes, do you have any sample code to return requested response from real service. i am kind of stuck in this specific part to complete my POC on pact

matthew.balvanz
2018-09-14 22:14
That side of the Python library shown there is the consumer (aka client) side of the contract. `callAPI` should be replaced with the code that would be making an HTTP request to the web service. Using the `mockurl` then connects with the Pact mock service that can record the interaction as a JSON file. After you have the JSON contract, then you can use the pact-verifier to verify the contract, potentially against a production/staging service.

abubics
2018-09-17 04:34
I would suggest that you could use different data structures for transport vs in-app.

abubics
2018-09-17 04:34
(Your sample payload uses business values for primary keys, which seems risky/brittle, but that's beside my point . . .)

abubics
2018-09-17 04:35
transporting them (over the wire) as an array is a good generic approach, with easy-to-implement data integrity

abubics
2018-09-17 04:36
If you want to translate that into a map for performance reasons, that feels more like an app responsibility (and you can do so after it's received)

abubics
2018-09-17 04:39
Also, can you keep platform-specific questions in their own channels? :innocent: :point_right: #pact-python

shekharsp27
2018-09-17 08:03
Hi, are there any guidelines to determine complexity associated with contract testing with respect to the implementation or which points needs to consider to derive complexity involved in implementing contract testing in general

assaf.katz
2018-09-17 10:50
has joined #general

bethskurrie
2018-09-17 10:51
That's a very broad question @shekharsp27. What do you mean by complexity? Are do you mean in the context of story points?

malheur
2018-09-17 13:12
has joined #general

malheur
2018-09-17 13:17
Hi all, I'm running CDC test on provider's side and facing the problem: https://stackoverflow.com/questions/52359563/pact-provider-tests-broken-pactverificationtesttemplate-preconditionviolation. I wonder whether it's the same issue as here: https://github.com/pact-foundation/pact_broker/issues/209 and what should I do to make the consumer-broker-provider bundle work together. Thanks in advance!

thirumal.net
2018-09-17 20:50
@abubics -Sure, Thanks


matt
2018-09-18 01:19
it looks like the swift bindings are inactive?

matt.fellows
2018-09-18 01:28
No changes doesn't necessarily mean bad things - it might mean they just work really well :ok_hand:

matt.fellows
2018-09-18 01:28
Do you have an issue?

abubics
2018-09-18 01:53
(relative to the complexities of other options is probably an important aspect, too)

bethskurrie
2018-09-18 01:57
Please ask in the #pact-jvm channel @malheur

bethskurrie
2018-09-18 01:59
Compared to standard integration tests, contract testing is more complex to get started, but maintains a similar level of complexity as time goes on and more features are added. Traditional integration tests start with a low level of complexity but become exponentially more complex as time/features increase.

shekharsp27
2018-09-18 08:07
@bethskurrie I mean to say for example in API functional testing to derive complexity, one can consider how many parameters does api need or the API composition, on the similar lines can we decide complexity for contract testing

malheur
2018-09-18 08:08
Thanks!

bethskurrie
2018-09-18 08:13
I'm sorry @shekharsp27, I still don't understand. Can you give me a concrete example?

janneck.wullschleger
2018-09-18 09:35
has joined #general

janneck.wullschleger
2018-09-18 09:41
Hey there! I've got a serious problem with the can-i-deploy command and need some explanation. If I do a can-i-deploy --pacticipant --version, I get the results of all pacts associated with that pacticipant-version. I want to use the stricter can-i-deploy --pacticipant --version --to TAG but this one is not looking for pacts associated with that pacticipant-version and other tagged pacticipants its also failing if there are pacts missing between my pacticipant and other pacticipnat versions with that tag if there are pacts between those services on other tags. If there are pacts on some branch/tag between two services why are they considered to must be existing on other branches/tags? I think I get something wrong here and would appreciate any hints.

bethskurrie
2018-09-18 10:35
Hey @janneck.wullschleger can you make a gist and show each command and its output, and list your questions about each scenario, and I will do my best to answer you.


shekharsp27
2018-09-18 10:53
@bethskurrie I am sorry for being unclear, I'll look for an example and will get back

bethskurrie
2018-09-18 11:15
Hi @janneck.wullschleger thanks for the example.

janneck.wullschleger
2018-09-18 11:17
If you need any further information, please send me a message.

bethskurrie
2018-09-18 11:17
The logic in the command is to make sure that you have a valid contract between all the services.

bethskurrie
2018-09-18 11:18
It knows that you have pacts between the services that are missing a contract, and it is saying that if you want to deploy safely, you need to have one.

bethskurrie
2018-09-18 11:18
That's just the way it works.

bethskurrie
2018-09-18 11:19
It wouldn't be very helpful if it didn't check that.

bethskurrie
2018-09-18 11:23
If you are adding pacts into an existing environment, and you have versions of services deployed that never used pact, you can explicitly list the ones you want to deploy.

bethskurrie
2018-09-18 11:24
I've been meaning to add an --ignore-missing but haven't yet gotten around to it

janneck.wullschleger
2018-09-18 11:24
I do not agree with this. If I introduce a pact between service-a and service-b on a feature-branch. Why shouldn't I be able to deploy a new version of service-b to prod when there is a version of service-a deployed that has no pact(dependency) with service-b?

janneck.wullschleger
2018-09-18 11:27
What would be the normal way to introduce such new pacts?

bethskurrie
2018-09-18 11:34
That is a use case I hadn't considered.

bethskurrie
2018-09-18 11:35
Until your pact is on the main branch, you'll need to explicitly list the pacticipants that you care about in your command.

bethskurrie
2018-09-18 11:36
When you only specifying the one pacticipant, the broker autodiscovers all the other dependences.

bethskurrie
2018-09-18 11:37
In this case, it has autodiscoverd a dependency you wish to ignore for now.

bethskurrie
2018-09-18 11:37
As I haven't implemted the ignore feature, you'll need to explicitly list the dependencies you wish it to consider.

bethskurrie
2018-09-18 11:42
It's late here, so I'm not ignoring you if I don't respond, I'm just sleeping! We can chat more tomorrow if you need to.

janneck.wullschleger
2018-09-18 12:21
Thank your for your explanation. While the ignore-flag isn't implemented I have to work around this. Which api endpoint is the pact-broker-client using to query the table?

janneck.wullschleger
2018-09-18 13:15
I think I've found the correct endpoint and my needed query params to query the pact broker myself. I am a bit confused about the thought process because I am into pact since the end of last year and was sure that I understood the functionality. I'd like to chat with you to check if my understanding is correct or not.

schalkt
2018-09-18 13:23
has joined #general

abubics
2018-09-19 01:48
@shekharsp27 I don't think combinatorial/cyclomatic complexity changes at the level you're describing. The interesting complexity that differs is in test implementation and maintainability.

slack1977
2018-09-19 10:57
has joined #general

svams
2018-09-19 11:26
has joined #general


adam
2018-09-19 12:32
has joined #general

adam
2018-09-19 12:38
Has anyone any secret knowledge on how can I configure both gradle and npm to publish contracts to s3?

adam
2018-09-19 12:39
The general workflow that I understand should be possible, is as follows: the microservices backends define their expectations, that get converted to contracts in a build pipeline, and published to s3. At the same time they too retrieve contracts that they have to fulfill from s3 and run pact verification against them. And any frontend compoments that we have, in JS, they too define their contracts and publish them to s3.

adam
2018-09-19 12:40
Did I get it right?

leon.gaban
2018-09-19 15:12
has joined #general

leon.gaban
2018-09-19 15:13
Hi guys, I?m having a problem with the Javascript implementation of Pact, can anyone help?

leon.gaban
2018-09-19 15:14
My error ``` ? Test suite failed to run /Users/leongaban/projects/trade.io/tradeio-front/src/services/api/liquidityPool/TotalPayout.test.pact.js:2 import { Pact } from '@pact-foundation/pact'; ^ SyntaxError: Unexpected token { ```

leon.gaban
2018-09-19 15:14
This is my pactSetup file: ``` // @ts-ignore import path from 'path'; import { Pact } from '@pact-foundation/pact'; // @ts-ignore global.provider = new Pact({ port: 1234, log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), dir: path.resolve(process.cwd(), 'pacts'), spec: 2, cors: true, pactfileWriteMode: 'update', consumer: 'Exchange', provider: 'LP Service' }); ```

christophe
2018-09-19 16:05
has joined #general

christophe
2018-09-19 16:17
Hello all

christophe
2018-09-19 16:17
Is there specific channel for each Pact implementation?


leon.gaban
2018-09-19 16:20
Yeah that would be a great channel :slightly_smiling_face:

christophe
2018-09-19 17:20
I am using Pact JS mais my question more generic, is it the right place ?

mattgilbert90
2018-09-19 17:25
@christophe use #pact-js

liran.tal
2018-09-19 17:35
@adam I think you got the basics right. what do you mean about npm to publish contracts to s3?

liran.tal
2018-09-19 17:36
@leon.gaban looks like your error is related to transpiling. better take it at #pact-js channel

matt.fellows
2018-09-19 21:31
You'd have to do your own work to publish and fetch from s3. Have you considered using a pact broker? E.g. http://pact.dius.com.au or running your own open source one?

ehughes
2018-09-20 01:43
has joined #general

shekharsp27
2018-09-20 07:19
Ok. makes sense, however still I am struggling to put across my point properly and still working on the example which helps to describe the scenario. :disappointed:

wilson.mahann
2018-09-20 13:53
has joined #general

michael.francoeur
2018-09-20 15:32
has joined #general

jacob.hebert
2018-09-20 16:24
has joined #general

zackary.mccolgan
2018-09-20 17:09
has joined #general

suparna.bhattacharjee
2018-09-21 04:26
has joined #general

esf101
2018-09-21 15:15
has joined #general

drsiino
2018-09-21 17:06
has joined #general

yudinagata
2018-09-24 23:08
has joined #general

tom397
2018-09-25 18:30
has joined #general

tom397
2018-09-25 18:38
Hello! Pact is super cool! Thanks for all the great work. I came here to see if I might be able to get some general opinions on the challenges & worth of trying to integrate pact with a legacy system. Specifically I can see how auth will be challenging (as discussed here https://docs.pact.io/faq#how-do-i-test-oauth-or-other-security-headers). Any general thoughts on the subject of legacy system integration? Or any open source examples of rails projects using a mock auth service?

leon.gaban
2018-09-25 21:38
Hi guys, I?m getting the following errors with Pact JS version ``` console.error node_modules/@pact-foundation/pact/pact.js:110 Pact verification failed! console.error node_modules/@pact-foundation/pact/pact.js:111 Actual interactions do not match expected interactions for mock MockService. Missing requests: GET /frontoffice/api/liquidity-pool/get-total-payout ```

leon.gaban
2018-09-25 21:39
On the missing requests, that API isn?t built yet, does PACT require that endpoint to be hit?

leon.gaban
2018-09-25 21:40
~My test.pact.ts file~

leon.gaban
2018-09-25 21:41
Posting my question in pact-js

uglyog
2018-09-25 22:42
A legacy system is just a system where the original authors are no longer around. If you can write tests for it, you can use Pact. I have used pact to test things like where we replace some function in the legacy system with a call out to a new microservice.

tom397
2018-09-26 03:31
Tremendous. Thanks @uglyog!

christophe
2018-09-26 06:45
Hello all Thanks for the great work. Pact is really cool. I have a question about to manage multiple consumers with one provider. Imagine we already have a pact, published on Pact Broker, betwee a consumer À and a provider. Here comes a new consumer, Consumer B. At the starting point the contract between Consumer B and the Provider is the same as between Consumer A and the Provider. What is the best way to manage this case? Consumers B publish the contract but on the server side we have to implement twice the test? Consumer B download the latest version of the contract between A and the Provider and generate the mock from the Pact file ? Is there a such functionality on the consumer ? I mean replaying the contract from another consumer?

abubics
2018-09-26 06:51
This kinda depends on what pact libraries you're using on the consumer, which is dictated by what language/platform it's written on

abubics
2018-09-26 06:52
For example, there's a unit test style of provider verification that I've never tried, but it seems like it might work how you've described (which sounds horrible).

abubics
2018-09-26 06:52
I usually just manage fixture data through states, and don't do any verification through explicit test code (on the provider side).

eduardo.iriarte-mende
2018-09-26 15:38
has joined #general

viktor.nyblom
2018-09-27 07:46
has joined #general

madu.alikor
2018-09-27 09:14
has joined #general

vikassd2012
2018-09-27 17:43
@bethskurrie I needed help with the seek.automation.stub library, I posted my issue on the git but didn't receive any responses https://github.com/seek-oss/seek.automation.stub/issues/11 so I was hoping you can direct me to the right person?

bethskurrie
2018-09-28 09:12
@vikassd2012 tag Neil Campbell in the #pact-net channel.

testmoodbit
2018-09-28 19:51
has joined #general

moodbit
2018-09-28 19:52
has joined #general

vikassd2012
2018-09-29 05:30
Thanks @bethskurrie for your prompt response

liran.tal
2018-09-30 12:15
I thought of using `http://pact.dius.com.au/register/` for a workshop on pact but due to the non-automatic sign-up and registration process I guess I?ll have to revert to a docker-based solution? ? would be happy to get input

matt.fellows
2018-09-30 21:33
@liran.tal did you register? Haven't seen anything in the past few days, I'm happy to create one for your workshop

shekharsp27
2018-10-01 07:49
Hi, In case of a scenario where there is a dependency in microservice as ( A-> B- > C ), so in case if A sends a request to B to get some data, in that case, B has to request C to fulfill data required by A. So in this scenario to check the contract between A->B I can use the following options 1) I can virtualize service 'C' which can be used while validating the contract 2) Can use contract generated by B -> C to create mock service (service C) 3) Can use Swagger mock Validator tool which will leverage the Swagger file of providers (B and C), so providers can validate consumers' expectations without spinning up themselves. So in addition to the above approach will it be advisable to have one of the following options as well 1) Write a contract test between A->B such that, B doesn't have to get any data from C (write the contract which will cover only response which B can provider on its own without depending on C) and have separate contract between B->C which will make sure C responding in a proper way. 2) Use of provider state, for example, if service B knows what data needs to get from service C which required to send to service A. In that case service B can insert that data directly in its own database or can provide endpoint which service A will use to setup data. Please let me know your thoughts

matt.fellows
2018-10-01 07:51
I would go for option 2, using provider states and stubbing out service C when contract testing A->B

matt.fellows
2018-10-01 07:52
Depending on language, tool etc that might be a stub server, an in memory fake dependency (e.g. spring ) or any number of things


liran.tal
2018-10-01 10:12
oh I didn't, I just noticed that it's not an instant thing from the website. I think for the workshop I'd plan to have many accounts open for each team that joins in. Its not a problem though, I'll just run the broker from the docker image. Thanks!

matt.fellows
2018-10-01 11:32
No worries. If you want a bunch created for the workshop, let me know and I?ll get them created in bulk (I can send you a template).

matt.fellows
2018-10-01 11:32
Also I think there was a conversation _somewhere_ - what?s the workshop details and do you want any help getting it together?

liran.tal
2018-10-01 11:39
I would love to, thanks! I'm still working on the details, story and plan but once I have something more coherent to share I definitely will.

liran.tal
2018-10-01 11:39
That's awesome of you to offer, thanks! :heart:

matt.fellows
2018-10-01 11:40
:thumbsup:

shekharsp27
2018-10-01 12:44
Thanks @matt.fellows

matt.fellows
2018-10-01 12:52
np

suvendu.panja1
2018-10-02 01:43
has joined #general

keynan21
2018-10-02 01:47
has joined #general

keynan21
2018-10-02 01:51
You rang?

nnoble
2018-10-02 02:21
has joined #general

keynan21
2018-10-02 04:47
@tjones you rang?


keynan21
2018-10-02 05:28
affermative

tjones
2018-10-02 05:28
I guess the first question is - is there a reason you're spinning up the mock server in the build script rather than letting the js library do it for you?

tjones
2018-10-02 05:28
that lifecycle is supposed to be abstracted a bit (and I'm hoping we can eventually abstract it more)

keynan21
2018-10-02 05:29
Yes, if I let the lib do it, it explodes looking for ruby

keynan21
2018-10-02 05:29
I strongly believe what you want is a session lifecycle, not a process lifecycle

tjones
2018-10-02 05:30
Could you elaborate a bit?

bethskurrie
2018-10-02 05:31
Huh? @keynan21 something is not right.

bethskurrie
2018-10-02 05:31
The fact that it is ruby under the hood shouldn't matter.

bethskurrie
2018-10-02 05:31
What is the error stack?

keynan21
2018-10-02 05:32
The service simply exists, somewhere, accessible at http://localhost:5236 , now how do you implement the library / service to behave the way you want

keynan21
2018-10-02 05:32
Dear service please give me a session cookie

keynan21
2018-10-02 05:32
.... do many test things

keynan21
2018-10-02 05:33
Thx service, close my session

keynan21
2018-10-02 05:33
whatever is happening on process start / stop is moved to the session create / close

tjones
2018-10-02 05:33
Perhaps. I think ideally all of that should be abstracted to the user

keynan21
2018-10-02 05:34
same lifecycle, with no dependence on where / when / how the process is created

keynan21
2018-10-02 05:34
ideally I don't need to know the internals of tcp to write an http server

keynan21
2018-10-02 05:34
however that is never and will be never the case

tjones
2018-10-02 05:35
Anyway, to fix your issue, this is happening because alpine has `uglibc`instead of `glibc`


keynan21
2018-10-02 05:35
What's important is that new users can get something working quickly and advanced users can customize their usage to their usecase

tjones
2018-10-02 05:36
You can either add the relevant parts to your dockerfile, or use a different base image


tjones
2018-10-02 05:38
So, that will get you able to get the tests working

tjones
2018-10-02 05:38
Beyond that, the suggestion of having a separate service for the mock server is interesting

keynan21
2018-10-02 05:39
Thank you, but I always knew installing the missing dependency would solve the immediate problem. I filed the ticket because I don't want a dependency on ruby or anything else creeping in.

tjones
2018-10-02 05:40
You don't have to depend on Ruby - `pact-node` contains everything it needs.

bethskurrie
2018-10-02 05:40
Eventually you'll have to depend on something @keynan21 - the service isn't built on air :stuck_out_tongue:

tjones
2018-10-02 05:40
It does expect `glibc` though

keynan21
2018-10-02 05:40
okay, I don't want to depend on glibc

bethskurrie
2018-10-02 05:40
What would you prefer to depend on?

keynan21
2018-10-02 05:40
I'm perfectly happy to depend on docker

tjones
2018-10-02 05:41
Why not run the test within docker, then?

keynan21
2018-10-02 05:42
I do

tjones
2018-10-02 05:42
The dockerfile can contain the dependencies

tjones
2018-10-02 05:43
glibc doesn't seem like an unreasonable dependency. Is there some reason you are unable to include it?

keynan21
2018-10-02 05:43
which means I'm now mixing in things to my test environment I'm not necessarily expecting in production

tjones
2018-10-02 05:44
That's standard practice with npm, though - `devDependencies` are available at test time and not available in production.

tjones
2018-10-02 05:46
An alternative if you don't want to have a different container definition in prod would be to have two containers - one for your Pact tests, and one for your other tests

keynan21
2018-10-02 05:46
Best practice is to replicate your prod environment as close as possible.

tjones
2018-10-02 05:46
(Or leave glibc there in production)

keynan21
2018-10-02 05:48
An per the link you gave, adding glibc adds 86MB to a container that currently weighs only 22MB

tjones
2018-10-02 05:48
So, your issue could be resolved by removing the dependency on glibc?

keynan21
2018-10-02 05:50
The specific problem of today? maybe.

bethskurrie
2018-10-02 05:50
@keynan21 I'm afraid that the current method of packaging is the only alternative we have at the moment. We know that it is not ideal, and we have a long term plan to fix it, however, this is an open source project that gets completed in people's free time, and the amount of work to change the current implementation to the new fancy version is significant, and has not yet been picked up.

bethskurrie
2018-10-02 05:50
If you are interested in contributing, we would be very happy to accept your assistance.

keynan21
2018-10-02 05:51
The general problem remains. I want control over what and how process get run, and there seems to be no reason why the library MUST start the process other than it's the status quo

bethskurrie
2018-10-02 05:51
There is a docker image of the mock service

bethskurrie
2018-10-02 05:52
There should be the ability to use an existing mock service in the js library.

keynan21
2018-10-02 05:52
@bethskurrie Yes, those are what I'm trying to use

bethskurrie
2018-10-02 05:52
If there isn't, we can add it.

bethskurrie
2018-10-02 05:52
Please go to the #pact-js channel, and discuss it with @matt.fellows and @mboudreau. Please keep your comments in a thread to avoid spamming people as we have currently been doing.

keynan21
2018-10-02 05:53
@bethskurrie And I appreciate that yall have limited bandwidth. I've no objection to doing the leg work once people are onboard.

keynan21
2018-10-02 05:53
soz, slack noob

bethskurrie
2018-10-02 05:57
In the Ruby implementation, there is a flag called `standalone` when you are setting up the mock service configuration, which tells the code "don't start a mock service, I've already got one running". This needs to be added to pact-js if it doesn't already exist @keynan21

keynan21
2018-10-02 05:59
Thx

matt.fellows
2018-10-02 07:27
As a related aside, multi stage builds https://docs.docker.com/develop/develop-images/multistage-build/#before-multi-stage-builds) and other similar patterns can assist with keeping runtime dependencies to a minimum, whilst allowing for flexibility during build stages

christophe
2018-10-03 14:22
Sorry. I did not see that you answered me.

christophe
2018-10-03 14:22
I am not sure to get you

christophe
2018-10-03 14:36
So imagine, that we have client A in Angular and client B in Java with a server in Java. So the 2 contracts are published on Pact Broker. The server should implement tests to validate the 2 contracts. So my question is how to manage the case where the 2 client contract have common part. Should the server side test every contracts, which could implies to duplicate tests or could we image some common contracts and the client download this part of this contracts to generate the mock ?

holden.mcginnis
2018-10-03 15:43
has joined #general

igalkop
2018-10-04 04:31
has joined #general

contactsai123
2018-10-04 05:33
has joined #general

kashikar.harsh
2018-10-04 07:56
has joined #general

daniel.oades
2018-10-04 13:31
has joined #general

joe.campedelli
2018-10-04 19:22
has joined #general

shawn
2018-10-04 20:15
has joined #general

fraser.crichton.devel
2018-10-04 22:56
has joined #general

chandas.pathre
2018-10-05 07:10
has joined #general

ashish.dubey91
2018-10-05 12:26
hey guys I have some questions around managing provider states across different services - are there best practices around making provider states discoverable in a setting which has multiple teams managing a dozen of micro-services? I have some ideas, I would like to know how others do it

jose.neto
2018-10-05 14:57
has joined #general

rakshit.shukla
2018-10-05 16:06
has joined #general

abubics
2018-10-08 00:56
I think that's definitely a "teams should talk to each other" kinda thing, but I haven't had a particularly complex use case yet.

abubics
2018-10-08 00:57
I'd be interested to see if anyone feels that it's a problem that needs a technical solution :thinking_face:

matt.fellows
2018-10-08 10:58
It?s something we?re looking to add to the broker roadmap - making those states more easily discoverable. If nothing else to avoid simple mistakes where two states exist and differ by spelling or something.

matt.fellows
2018-10-08 10:58
But yes, it?s always a ?talk to the provider? before adding a state they don?t know about

kashikar.harsh
2018-10-08 11:26
hi all

kashikar.harsh
2018-10-08 11:26
Facing an issue with pact verification, getting below error

kashikar.harsh
2018-10-08 11:26
Pact verification failed! Actual interactions do not match expected interactions for mock MockService.

kashikar.harsh
2018-10-08 11:27
I understand this is because the request is executed before the interactions were added

kashikar.harsh
2018-10-08 11:27
however I have added done to my interactions, still getting this error

mboudreau
2018-10-08 11:32
please keep it in the appropriate language channel :slightly_smiling_face:

jesus.medinilla
2018-10-08 12:29
has joined #general

robcossin
2018-10-08 16:14
has joined #general

abubics
2018-10-08 23:17
The "provider states" docs page gives a nice high-level description of how states work, but I think this could also be expanded to some descriptions of approaches to state structure/strategy :thinking_face: and that would lead nicely into state discoverability (or vice versa)

matt.fellows
2018-10-08 23:47
good point

ashish.dubey91
2018-10-09 03:31
yeah something like that would definitely be helpful. conversation between the consumer and provider would def be there for using a provider state while defining a contract but once a provider state has been negotiated it should also be easy for consumers to reference them (to make re-use easy) and also same for teams managing the provider

ashish.dubey91
2018-10-09 03:32
what we're thinking in our team is to have a way to document the provider states that the provider has fixtures for in the code repo of the provider. that's the most basic one. something on the pact-broker would have been great too

abubics
2018-10-09 03:59
Generally, the first pact tests I write are GETs that mostly show the bare state anyway . . . and without an abstract data visualisation, I don't see an easy, consistent way to display the state across multiple tables, or the many kinds of stores (including relational and nosql)

abubics
2018-10-09 04:00
I guess what I'd like to know is: what kinds of issues do you have already? Do your GETs not give enough info, and/or not show relationships between different levels of relational hierarchy? etc

abubics
2018-10-09 04:22
(and do you have any ideas for how to represent the state, since the structures may be very arbitrary?)

ashish.dubey91
2018-10-09 04:27
The GETs in my case give out information, mostly. but it could be contained in headers, query string, or url. There's no standard at the moment. I think there is scope for making provider state inference easier than looking at request specs of the consumers

brian.smith.keith
2018-10-09 18:56
has joined #general

marco.dellolio
2018-10-09 18:56
has joined #general

avi.pardu.nash3
2018-10-10 00:05
has joined #general

arne.zelasko
2018-10-10 08:58
Hi everyone, short question; Is it possible to use spring cloud contract on one service and on the other pact-jvm ?

bethskurrie
2018-10-10 08:59
Which end is which?

bethskurrie
2018-10-10 09:00
Ask in #pact-jvm, or better yet, on the SCC gitter channel. The maintainer is very responsive.

matt.fellows
2018-10-10 11:18
My understanding that yes, you can. On the consumer side, it can generate Pact files that can be sent to the broker, and on the provider side it can fetch from the broker. So if it can do those things, then in theory either side is possible

inbox
2018-10-10 15:40
has joined #general

colin.but
2018-10-10 21:13
has joined #general

liran.tal
2018-10-11 12:37
@matt.fellows follow-ing up on our thread here about query params in brackets support in a matching rule. short reminder: the API endpoint on the provider follows this signature: ``` GET /reviews?movieId[]=1 ``` on the consumer, I?ve set the interaction as follows: ``` withRequest: { method: 'GET', path: `/reviews`, query: { 'movieId[]': Matchers.like('1') } }, ``` when I run the provider testing I get this warning as part of the results of the verifier: ``` WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['query']['movieId'][][0] ``` My provider?s project dependencies are `"@pact-foundation/pact": "^6.0.1"`

liran.tal
2018-10-11 12:41
I updated the interaction on the consumer to be: ``` query: { 'movieId[]': Matchers.like('1') ``` just as in my PR for array brackets example and now the provider verification results shows these warnings: ``` WARN: Ignoring unsupported matching rules {"min"=>1} for path $['query']['movieId'][] WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['query']['movieId'][][*]* ```

louiseavelar
2018-10-11 13:30
has joined #general

louiseavelar
2018-10-11 16:48
Hello Everyone, I am new to pact and the whole concept of contract testing. I was wandering if contract testing replaces completly e2e tests or is just a complementary test. That wasn't clear for me! thanks in advance!

liran.tal
2018-10-11 21:45
@louiseavelar welcome! :wave: I would think of it as not replacing e2e tests but instead of enabling robust and short feedback loop of e2e tests in a rich SOA.

bethskurrie
2018-10-11 21:46
There's a FAQ dedicated to this on http://docs.pact.io @louiseavelar

mboudreau
2018-10-11 23:25
@louiseavelar they do different things. e2e tests is to test your front-end code and routes through your application, while contract testing is to make sure your consumer (front-end app) can consistently call your producer (API) without the contract breaking in production. My personal opinion is that they work really well in unison since in one run, you can do both your e2e and contract testing :slightly_smiling_face:

pact-slack
2018-10-12 12:23
I'm thinking about using Pact for a message/event driven architecture. Now the Pact tool is an implementation of consumer driven contracts (CDC). But in our event driven architecture every application/service (a Bounded Context in DDD) publishes its own events in its own language. Other applications consume these events and translate them into their own language (ACL in DDD) and then act upon them. So there is not really a _consumer driven_ style of development, but more kind of "let's have a look of what happens out there and try to make some sense out of it." I'm not sure on how to use the CDC methodology in this context (and if it is applicable at all) and which Pact based workflow you would suggest? Nonetheless Pact as a tool for decoupled, fast contract testing seems still very useful for event based architectures.

abubics
2018-10-12 13:02
These are a few orthogonal concerns. Contracts are important. If they're brokered messages instead of synchronous calls, that's one point. Both of those are separate from the concern of: which end drives the contract.

ibenardetelevis
2018-10-12 13:07
I?m a bit new to pact and contract testing might be a dummy question but; while writing a contract test for getting an entity `/resource/ID` when I use a random ID in my consumer and generate the pact file, now I need to make sure provider uses the same id to create this entity or is there a way to implement this without an actual value ?

kashikar.harsh
2018-10-12 13:27
@ibenardetelevis have a look at matcher https://github.com/pact-foundation/pact-js#matching

ibenardetelevis
2018-10-12 13:31
@kashikar.harsh thank you for the example, The only part I could not figure is ` path: "/animals/1" ` where I need to match that 1 in the provider side as well right ? because when the Pact File is generated 1 will be embedded in there ?

brian.smith.keith
2018-10-12 14:03
You can use a regex I believe

liran.tal
2018-10-12 15:20
Right. I?d further add that while there definitely is a contract there - there?s a DTO that one service publishes and another service catches - that?s essentially the contract. A provider in your case is definitely clear. A consumer on the other hand could be a bit more odd situation since sometimes the EDA is also about decoupling the ?know? of who your consumers are. I?d say that?s the interesting part of the problem and will also be happy to learn more on this.

pbanka
2018-10-12 17:26
has joined #general

matt.fellows
2018-10-12 21:24
Matchers are for the consumer to convey to the provider that the specific response value isn't important, just the type or structure. The request value has to be able to work on the provider (e.g. resource 1) which is where provider states are useful

liran.tal
2018-10-13 00:07
I take that back. Actually since the consumer is creating the contract then its the consumer that is creating the relationship so the provider doesn?t know of this to begin with, only after-the-fact. To summarize I don?t think working with a message bus adds anything new.

kashikar.harsh
2018-10-13 16:56
@ibenardetelevis I used matcher in expect lik this

kashikar.harsh
2018-10-13 16:56
expect(response).to.eventually.have.property('service_id') .and.match(contractTestConfig.regex.guid)

kashikar.harsh
2018-10-13 16:57
you can define regex and use it to match expected value

matt.fellows
2018-10-14 03:33
This is redundant - pact does this exact test for you anyway.

kashikar.harsh
2018-10-14 03:38
@matt.fellows, thanks can you please share a code snippet on how to do this?

kashikar.harsh
2018-10-14 03:39
somehow the code examples in the link are not enough for new beginners like me

matt.fellows
2018-10-14 21:44
Hi Harsh. What have you read on the subject so I know what level your education is at?

matt.fellows
2018-10-14 21:45
Start with the FAQs and best practices at http://docs.pact.io

abubics
2018-10-14 23:05
The important thing for contract testing is the expectations (i.e. the contract), not the transport (i.e. http, events, messages, function calls, whatever). Message protocols & transports (such as SQS, *MQ, etc) got some Pact implementation support in the last few years :slightly_smiling_face:

abubics
2018-10-14 23:09
One of the intents of consumer-driven (rather than provider-driven) contracts is waste reduction. - There's little value in building endpoints that no one uses. - DDD is obviously important, but that helps shape the data structures, and to a lesser extent their APIs. - To this point, just because it makes sense to CRUD everything, doesn't mean all the endpoint+verbs will be used :slightly_smiling_face: - (And the simple CRUD endpoints probably aren't the interesting ones for regression testing anyway, but I digress)

liran.tal
2018-10-14 23:36
I like the point about waste reduction, will add that to my article!

matt.fellows
2018-10-15 03:29
Sorry Liran, I missed this. Will follow up tonight !

liran.tal
2018-10-15 03:59
Thanks!

bethskurrie
2018-10-15 04:00
You can ignore that @liran.tal

bethskurrie
2018-10-15 04:01
It has no side effects, it's just annoying.

bethskurrie
2018-10-15 04:01
I've been trying to work out how to get rid of it, but it's a bit tricky.

liran.tal
2018-10-15 04:02
Gotcha. No worries. I thought I was landing on some wrong version or doing something wrong on my side. Maybe we should add it on the FAQ or somewhere as a known issue? Possibly even an open issue on GitHub so that if someone searches they no it?s a no-issue thing.

bethskurrie
2018-10-15 04:03
There were a few that were known issues, and I've fixed them like I was playing whack-a-mole, but the error for the query string specifically can be ignored.

bethskurrie
2018-10-15 04:03
I think there is an issue somewhere.

bethskurrie
2018-10-15 04:03
In fact, there are many

liran.tal
2018-10-15 04:05
:slightly_smiling_face:

kashikar.harsh
2018-10-15 06:02
Hi @matt.fellows, I have gone through the entire document and some blogs as well, but couldn't find any e2e example of matchers... Not sure if I have missed anything... Also it may be obvious for many to tweak the given examples to use matcher, but not for me

marco.dellolio
2018-10-15 20:16
hello everybody. I?m implementing `pact-node`. basic on the documentation look like after I spin up the server ``` const provider = pact.createServer({ ...opts }) ``` I can just proceed regularly with ``` return provider.start().then(() => { provider.addInteraction(interaction).then(() => done()) ``` but `Unhandled Promise Rejection: TypeError: provider.addInteraction is not a function` Am I missing something?

matt.fellows
2018-10-15 21:55
I think you want to be using pact js, not pact node directly.

matt.fellows
2018-10-15 21:56
addInteraction is not available on the object of pact node. It just is a library under the hood

matt.fellows
2018-10-15 21:56
Look at the examples in pact js repo

marco.dellolio
2018-10-15 23:07
Ok I wanted to confirm that, at the moment there isn?t a way to use pact is without installing Ruby on the service

matt.fellows
2018-10-15 23:11
You shouldn't have to install it manually or anything.

matt.fellows
2018-10-15 23:11
It should u install it all for you

matt.fellows
2018-10-15 23:12
But yes, Ruby under the hood

mboudreau
2018-10-15 23:12
portable ruby

mboudreau
2018-10-15 23:12
which we have plans to change to a OS specific binary written in rust eventually

matt.fellows
2018-10-15 23:14
As a consumer it is something you shouldn't even know exists. No need for installing Ruby runtime or anything

marco.dellolio
2018-10-15 23:51
Thank you guys! To be more specific, when I start a provider it?s still spawn a Ruby process, that?s what I wanted to avoid

abubics
2018-10-15 23:53
it will always have to spawn at least one process during consumer testing or provider verifying . . . which bit of "ruby process" are you trying to avoid?

marco.dellolio
2018-10-16 00:16
My goal on using pact-node was to spawn a node process for provider. Otherwise in `Pact.js` provider.setup() would start a ruby process

abubics
2018-10-16 01:01
I mean, why do you want to avoid that?

abubics
2018-10-16 01:02
(no judgement, I'm just trying to understand the problem before offering solutions)

heymega
2018-10-16 08:59
Do you think the design choice to use ruby under the hood or indeed rust binary is going to be a hinderance in the long run? It seems every language implementation is using it. I like the idea that the community can help create language specific implementations but it can be quite difficult, or in some cases off putting, if the library isn't 100% native. For instance, in the .NET repo they moved over to the ruby core for v2 and this meant we can no longer use an in-memory server and requires spawning a ruby process. Something that isn't always possible to do given that these might run on build agents in the cloud. I'm guessing there are other restrictions that people have seen in their implementations.

neil
2018-10-16 09:07
Speaking from my experience with moving from v1 to v2, trying to rally some support to build version 2 natively in the community was a real uphill battle. There were people who wanted to help, however nothing eventuated after quite some time of discussions.

neil
2018-10-16 09:11
In the end I made the decision to move to using the ruby core, as the .NET version was trailing so far behind and having matchers was a really nice feature. I also didn?t want to be trailing that far behind next time. The idea is that building some language specific facades is a lot easier, than building the feature multiple times in each supported language.

neil
2018-10-16 09:12
And hopefully it?s a more palatable chunk of work for someone in the community to break off as well

heymega
2018-10-16 09:15
Makes sense when you put it that way Neil. I guess its one of the downsides of OSS. I'm surprised more people aren't prepared to help out given how awesome and useful the library is.

neil
2018-10-16 09:15
Our goal is to keep using this model, however hopefully we can make it feel more native with less trade offs

neil
2018-10-16 09:19
There have been some really awesome contributions, don?t get me wrong. From what I have seen though, I?d guess that a lot of the OSS contributions come from peoples free time (including most of mine now days) and as a society we are just getting busier and busier.

neil
2018-10-16 09:22
Over in #pact-net it may be worth chatting about the issues you are running into with running the pact tests on cloud agents. There may be a solution, that someone knows?

heymega
2018-10-16 09:52
That's a great idea Neil. I'll drop a question on the issues section.

matt.fellows
2018-10-16 10:20
The more languages that we want to have Pact work with exponentially increases time to market for new features and ongoing maintenance. We identified a few years ago that a) more languages were in demand and b) that we couldn't scale to implement new features (and thus compatibility across languages)

matt.fellows
2018-10-16 10:21
We all use pact on our own projects and so dogfood them regularly. There are likely going to be some restrictions as you note, but outsourcing the core logic means we can start to focus efforts elsewhere (e.g. docs, better DX etc)

matt.fellows
2018-10-16 10:22
If there are issues though, we want to know!

pact-slack
2018-10-16 10:54
Thanks for making things clear. You're right, transport mechanism is of lesser importance. So, at the concept level, you still would start to write the contract on the consumer side even though the producer is upstream and technically (because of decoupling) not interested which consumers exist. To bring a DDD based example (assuming team A is upstream): Team A would define their Ubiquotous Language, then team B (which wants to use events from team A) would define a contract (event content) in that language and give it to team A. Thus there would be no waste on team A side and the team would still be able to use its own language for the events.

marco.dellolio
2018-10-16 23:04
~moved to pact.js channel~

abubics
2018-10-17 00:16
From an analysis perspective, you should probably work on your domain language well before starting development :stuck_out_tongue:

abubics
2018-10-17 00:17
but, more seriously, one of the early points highlighted in the docs is that Pact isn't intended to replace conversation

abubics
2018-10-17 00:18
So, it shouldn't matter who is upstream . . . usually the initial consumer/provider pair should work out a domain model that works for their intended use cases, and extension considerations

abubics
2018-10-17 00:18
You can design a model, and an API, and then only implement the bits as you need them :ok_hand:

mboudreau
2018-10-17 00:36
yeah, it all comes down to a single library to rule them all. Currently it's ruby, but we've been making efforts towards a Rust c library implementation that should work in process in most languages. Consistency is key for this because if the implementation is different for each language, it could break contracts making the product useless

alejandro.exequiel.ca
2018-10-17 19:44
has joined #general

pact-slack
2018-10-18 22:24
:grinning::+1:

igit.soeriasaputra
2018-10-19 04:44
has joined #general

privat.sebastian.muel
2018-10-21 09:56
has joined #general

rr.1.riou
2018-10-22 11:02
has joined #general

rr.1.riou
2018-10-22 11:04
Hey guys, nice to meet you! I am looking for an exemple of pact on top of native jest on a create-react-app? If there is some best practice, how is the best way to set it up! thanks in advance! Erwan

abubics
2018-10-22 11:38
Try in #pact-js, but this seems like a thing that's covered in the ToC on http://docs.pact.io :thinking_face:

rr.1.riou
2018-10-22 12:42
Yes i already found exemple, acutally a lot of differents ones. I apply this one (https://github.com/arkency/react-example-pact/blob/master/src/App.test.js) but its seems it creating errors. Probably due to the new architecture version of react release recently. So i was looking for a 'recommanded reference'

abubics
2018-10-22 23:00
Yeah, I wouldn't go with Enzyme for Pact testing. These network interface unit tests should avoid DOM & browser dependencies :slightly_smiling_face:


abubics
2018-10-22 23:24
Some bits of this example are outdated (e.g. `publish.js` is no longer required)

yunxing.wang
2018-10-23 07:44
has joined #general

rr.1.riou
2018-10-23 08:58
Yes i actually clone this test but i can't manage launch it, its very weird : ``` PS C:\Users\eadrien\Desktop\pact-js\examples\jest> cd __tests__ PS C:\Users\eadrien\Desktop\pact-js\examples\jest\__tests__> npm test > jest@1.0.0 test C:\Users\eadrien\Desktop\pact-js\examples\jest > jest __tests__/ --runInBand --setupFiles ./pactSetup.js --setupTestFrameworkScriptFile ./pactTestWrapper.js No tests found In C:\Users\eadrien\Desktop\pact-js\examples\jest 9 files checked. testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 3 matches testPathIgnorePatterns: \\node_modules\\ - 9 matches Pattern: __tests__/ - 0 matches PS C:\Users\eadrien\Desktop\pact-js\examples\jest\__tests__> ```

rr.1.riou
2018-10-23 09:32
i also created an issue on the pact-js since its really doesn't work to install properly


kanohen
2018-10-23 15:19
Hello guys, Please, I have a pact test on my producer. The producer is a Gradle spring project. I have added the pact test to a pact directory in my test folder. When I run ./gradlew test --info, every test in the test folder runs except the pact test. For some reason Gradle isn't aware of that test. However , when I run it locally, without using Gradle, it works fine. Is there some configuration I need to add to my build file to notify Gradle of the pact folder?

gopinathlangote11
2018-10-23 16:31
It depends upon how you gradle test script works.

gopinathlangote11
2018-10-23 16:32
Could you please share the `build.gradle` file along with you test package structure

tom.hombergs
2018-10-23 19:47
I have exactly the same issue

tom.hombergs
2018-10-23 19:48
and no clue how to debug it...any help is appreciated :slightly_smiling_face:

abubics
2018-10-23 21:45
Also, take this to #pact-jvm for more targeted help :)

tarcio.saraiva
2018-10-23 23:09
has joined #general

tarcio.saraiva
2018-10-23 23:10
hello :wave:

tarcio.saraiva
2018-10-23 23:11
unfortunately I come with a problem: seems like pact broker is down?

tarcio.saraiva
2018-10-23 23:11
we are getting a 404 here

bethskurrie
2018-10-23 23:12
@matt.fellows

bethskurrie
2018-10-23 23:13
@kong are you able to check? I'm afk.

tarcio.saraiva
2018-10-23 23:43
sorry disregard my message earlier guys

tarcio.saraiva
2018-10-23 23:49
false alarm - I was given the wrong information; it turns out a pact file was missing - all is well :tada:

kong
2018-10-23 23:50
thanks @tarcio.saraiva .. sorry , just saw this.

kanohen
2018-10-24 08:27
Sorry guys,I didn't get a notification that my message was replied. Hence, my late response. @gopinathlangote11 could you elaborate more on how the Gradle test script could have affected this?

kanohen
2018-10-24 08:28
My test package has the test folder with sun folders. Say sub folders A and B. In A is another subfolder C which contains my pact test. Every tests in folder A and B are hit but folder C is never hit.

kanohen
2018-10-24 08:29
Here is my test class ``` @RunWith(RestPactRunner.class) @Provider("hombrew") @PactBroker(host="pact-broker.europe-west6.prod.cloud", port="80") public class ProviderTest { @TestTarget // has to be public public final MockMvcTarget target = new MockMvcTarget(); private Controller controller = new Controller(someContainer); @Before public void setup() { target.setControllers(modelController); } } ```

nishantv12
2018-10-24 08:47
has joined #general

kanohen
2018-10-24 09:55
My Gradle build: ``` group = '{UNNECESSARY}' buildscript { ext.springVersion = '5.0.6.RELEASE' ext.springBootVersion = '2.0.2.RELEASE' ext.micrometerVersion = '1.0.4' ext.jUnitVersion = '5.1.0' ext.versionpath = 'src/main/resources/version' ext.restAssuredVersion = '3.1.0' repositories { mavenLocal() maven {url = "URL_TO_ARTIFACTORY"} } dependencies { classpath("io.franzbecker:gradle-lombok:1.11") classpath("org.springframework:spring-core:${springVersion}") classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath("org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:1.0.2") } } def getGitHash = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--short', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } def getGitBranch = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD' standardOutput = stdout } return stdout.toString().trim() } def versionString = "0.1.0" apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: "io.franzbecker.gradle-lombok" apply plugin: "application" sourceSets { main.java.srcDir "src/main/java" main.resources.srcDir "src/main/resources" test.java.srcDir "src/test/java" test.resources.srcDir "src/test/resources" integrationTest { java.srcDir file('src/integration-test/java') resources.srcDir file('src/integration-test/resources') } } repositories { mavenLocal() maven {url = "URL_TO_REPO"} } //ignore the class name.. mainClassName = '{application_className}' sourceCompatibility = 1.8 targetCompatibility = 1.8 gradle.projectsEvaluated { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" } } dependencies { // H2O compile files("libs/h2o-genmodel.jar") // Spring compile("org.springframework:spring-core:${springVersion}") compile("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") // uncomment the following to switch from tomcat to jetty as the server // { exclude(module: 'spring-boot-starter-tomcat') } // compile('org.springframework.boot:spring-boot-starter-jetty') compile("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}") testCompile("org.springframework.boot:spring-boot-starter-test:${springBootVersion}") // Metric instrumentation compile("io.micrometer:micrometer-core:${micrometerVersion}") compile("io.micrometer:micrometer-registry-prometheus:${micrometerVersion}") // Logging compile("org.slf4j:slf4j-log4j12:1.8.0-beta2") compile("org.slf4j:jcl-over-slf4j:1.7.12") //Annotation Processor annotationProcessor("org.projectlombok:lombok:1.18.0") // File IO compile("org.yaml:snakeyaml:1.21") // Testing testCompile("com.jayway.jsonpath:json-path:2.2.0") testImplementation("org.junit.jupiter:junit-jupiter-api:${jUnitVersion}") testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${jUnitVersion}") // Contract testing testCompile("au.com.dius:pact-jvm-provider-spring_2.11:3.5.2") testCompile("au.com.dius:pact-jvm-model:3.5.2") integrationTestCompile("commons-collections:commons-collections:3.2.2") integrationTestCompile("io.rest-assured:rest-assured:${restAssuredVersion}") integrationTestCompile("io.rest-assured:json-schema-validator:${restAssuredVersion}") integrationTestCompile sourceSets.main.output integrationTestCompile configurations.testCompile integrationTestCompile sourceSets.test.output integrationTestRuntime configurations.testRuntime } configurations.all { exclude group: "commons-logging", module: 'commons-logging' } test {

kanohen
2018-10-24 09:55
useJUnitPlatform() dependsOn 'cleanTest' } task integrationTest(type: Test) { group = 'Verification' description = 'Integration tests against a running instance.' testClassesDirs = sourceSets.integrationTest.output.classesDirs classpath = sourceSets.integrationTest.runtimeClasspath systemProperties['jar.path'] = jar.archivePath systemProperties['server.host'] = System.properties['server.host'] } task wrapper(type: Wrapper) { gradleVersion = "4.5.1" } task('cleanVersionText') { group = 'Resource Processing' description = "Delete the files holding the version text" doLast { delete("$projectDir/$versionpath/VERSION") delete("$projectDir/$versionpath/GITHASH") delete("$projectDir/$versionpath/GITBRANCH") } } task('versionText') { group = 'Resource Processing' description = "Write the version string, git branch and git hash to three local files in the jar" doLast { mkdir("$projectDir/$versionpath") new File("$projectDir/$versionpath/VERSION").text = versionString new File("$projectDir/$versionpath/GITHASH").text = getGitHash() new File("$projectDir/$versionpath/GITBRANCH").text = getGitBranch() } } versionText.dependsOn(cleanVersionText) clean.dependsOn(cleanVersionText) // we want the build to depend on the version task so that the version/GITHASH file is always up to date processResources.dependsOn(versionText) //tasks.withType(Test) { // reports.html.destination = file("${reporting.baseDir}/${name}") //} task testReport(type: TestReport) { group = 'Verification' description = 'Moves the test reports to a location where they can be found by gocd.' destinationDir = file("$buildDir/reports") // Include the results from the `test` task in all subprojects reportOn subprojects*.test } tasks.withType(Jar) { task -> // Includes War and Ear manifest { attributes('Modelservice-Release-Version': versionString) attributes('Modelservice-Release-Githash': getGitHash()) attributes('Modelservice-Release-Gitbranch': getGitBranch()) } } ```

jeroen.claassens
2018-10-24 13:54
has joined #general

jeroen.claassens
2018-10-24 14:08
Hello, I'm looking for some help. I am tackling the task of upgrading the npm dependencies in my corporation and along with that i want to upgrade the old `pact` v3.0.1 (pact-consume-js-dsl) to the new `@patch-foundation/pact` (pact-js) v7.0.1. Since I cannot find any migration guide between these two packages I figured I'd join this server to get support. Right now I'm facing an issue with Pact Term. In our project we use `Pact Term` (`Patct.Matchers.Term`) however when following what is written here in the docs (https://docs.pact.io/getting_started/matching#regular-expressions) I get the error ``` 'Content-Type': _pact.Pact.term({ ^ TypeError: _pact.Pact.term is not a function ``` This happens in a `beforeEach` block at the `headers` property and we use Pact Terms many times after that too. Section of code:

dagarwal
2018-10-24 14:48
Hello all , do u push pact tests to pact broker only from master branch or from all the branches .Is their a way we can restrict our test only for master branch .I tried with few npm dependencies .It all works fine on my local but I am not able to get branch name on jenkins .Any suggestions ?

alex
2018-10-24 15:36
has joined #general

zhirschtritt
2018-10-24 17:42
has joined #general

matt.fellows
2018-10-24 20:18
@dagarwal the answers to all of your questions are at https://github.com/pact-foundation/pact_broker/wiki and specifcally probabaly https://github.com/pact-foundation/pact_broker/wiki/Using-tags.

matt.fellows
2018-10-24 20:19
Publish all of your pacts, and use tags to separate the important ones (e.g. your `master` code line generated pacts) from WIP ones. On the provider side, you should be able to configure the fetch to only grab the relevant tags.

dagarwal
2018-10-25 08:04
Ok thank you ,will give a look :slightly_smiling_face:

matt.fellows
2018-10-25 09:16
:+1:

michael.ohegarty
2018-10-25 13:50
has joined #general

zdprescott
2018-10-25 18:25
has joined #general

shidhore.ajinkya
2018-10-26 10:14
has joined #general

marco.dellolio
2018-10-28 02:58
Hello! Thank you for the support so far, you guys are amazing. Today question is about JWT. Testing the matching of a signed JWT token it is out of scope for PACT? Should I just the ?three parts? structure for a JWT. What?s your opinion/experience about it?

liran.tal
2018-10-28 08:04
@marco.dellolio heyas can you explain more specifically how is JWT related to your contract tests?

matt.fellows
2018-10-28 08:47
Are you looking to test JWT contract itself, or authenticated APIs that use them?

marco.dellolio
2018-10-28 11:44
Every API request must be authenticated using a signed JWT containing url and parameters in the signature.

matt.fellows
2018-10-28 11:49
ok cool. The problem will be that whatever you put into the consumer contract will (likely) be invalid when it is later verified by the provider (assuming it?s short-lived)

matt.fellows
2018-10-28 11:50
I would on the consumer side, generate the JWT and ensure it?s in the request (you can use matchers to ensure it matches the expected query string)

matt.fellows
2018-10-28 11:51
For the verification, assuming it?s JS, use the `customProviderHeaders` option of the verifier to dynamically overwrite it with a valid token for the test https://github.com/pact-foundation/pact-js/#verification-options

matt.fellows
2018-10-28 11:53
Alternatively, disable the JWT verification code in your Provider, as @tom.hombergs advocates in his recent article: https://reflectoring.io/pact-node-provider/

matt.fellows
2018-10-28 11:54
I personally prefer this option, on the assumption that a) it is easy enough to mock the JWT authorization implementation in the provider, and b) you have sufficient test coverage of that sub-system through other types of testing

matt.fellows
2018-10-28 11:54
@liran.tal you should add all of the articles from @tom.hombergs to your `awesome-contract-testing` repo :slightly_smiling_face:

tom.hombergs
2018-10-28 12:14
:slightly_smiling_face:

liran.tal
2018-10-28 17:02
@matt.fellows will definitely add! Thanks for the mention :slightly_smiling_face:

marco.dellolio
2018-10-28 20:14
Thank you guys, according to this, a testing case ?return 403 {error: ?..} if request if the jwt doesn?t contain the correct signature? can be considered out of scope.

matt.fellows
2018-10-28 20:16
I would still consider testing that case, and another with a slight modification - "no JWT present"

matt.fellows
2018-10-28 20:17
It should be possible to generate an invalid JWT but if not then test not supplying it at all

abubics
2018-10-28 22:08
"Invalid" sounds like too vague a use case. Even if that's the level of detail in the error, there are lots of reasons it could be invalid (e.g. expired, malformed, wrong signature, etc), which are more relevant to the testing context :slightly_smiling_face:

matt.fellows
2018-10-28 23:59
true. From a contract point of view, you probably want to capture the different responses from the system - e.g. `401`, `400` and `403` type errors. They can often be generated by different means, so worth thinking through what you need/want to test, vs what you can test via other means

abubics
2018-10-29 00:09
(and what isn't worth testing, because the library/protocol does it for you)

efoshager
2018-10-29 02:30
has joined #general

shidhore.ajinkya
2018-10-29 13:58
Hi everyone! I have implemented PACT on consumer side and I was able to publish *.json pact file to PactBrocker using following code in dotnet core. var pactPublisher = new PactPublisher("http://johnsoncontrolsinc.pact.dius.com.au", new PactUriOptions("***", "***")); pactPublisher.PublishToBroker($"..\pacts\userservice.api-event.api.json", "1.0.2"); On provider side, when I try to verify the same published Pact, using a unit test case (see below code): IPactVerifier pactVerifier = new PactVerifier(config); pactVerifier .ProviderState($"{_providerUri}/provider-states") .ServiceProvider("Event.API", _providerUri) .HonoursPactWith("UserService.API") .PactUri("http://johnsoncontrolsinc.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2", new PactUriOptions("***", "***")).Verify(); I get below error when I run that unit test. Can someone please help? PactNet.PactFailureException : Pact verification failed. See output for details. If the output is empty please provide a custom config.Outputters (IOutput) for your test framework, as we couldn't write to the console. at PactNet.Core.PactCoreHost`1.Start() in C:\projects\pact-net\PactNet\Core\PactCoreHost.cs:line 139 at Event.Test.EventApiTests.EnsureEventApiHonoursPactWithConsumer() in C:\POC\pact2\Event.Api\Event.Test\EventAPITests.cs:line 55 Error reading file from http://johnsoncontrolsinc.pact.dius.com.au/pacts/provider/Event.API/consumer/UserService.API/version/1.0.2 No connection could be made because the target machine actively refused it. - connect(2) for "http://johnsoncontrolsinc.pact.dius.com.au" port 80 C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `open' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `block in connect' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/timeout.rb:74:in `timeout' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:878:in `connect' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:863:in `do_start' C:/POC/pact2/Event.Api/Event.Test/bin/Debug/netcoreapp2.0/pact-win32/lib/ruby/lib/ruby/2.2.0/net/http.rb:852:in `start'

zhirschtritt
2018-10-29 15:09
Hi all, question regarding best practices: If I have a provider that does some external data-lookups when you hit an endpoint, what?s the best practices for mocking out those requests? For example, if I have a consumer that hit?s a provider endpoint `/gatherAllTheData` and the provider reaches out to a number of other services to synchronously aggregate data.

efoshager
2018-10-29 17:52
Hi All, is there a way to only test against specific elements? As opposed to the whole provider

anfalsiddiqui
2018-10-29 21:14
has joined #general

matt.fellows
2018-10-29 21:23
My guess is that You?re hitting it on `http` (port `80`) but it needs to be `https` (port `443`). My guess is either a) the publisher isn?t actually working or b) it is able to handle the redirect to https but the verifier isn?t

matt.fellows
2018-10-29 21:23
OR you?re inside a proxy environment and not allowed to connect to that host?

matt.fellows
2018-10-29 21:25
The answer is yes, depending on which language/library you use.

matt.fellows
2018-10-29 21:25
e.g. in pact js:



matt.fellows
2018-10-29 23:38
There are a couple of relevant sections there, andn a link to this gist: https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0

hansrd_98
2018-10-30 05:08
has joined #general

romuald.quantin
2018-10-30 13:24
Sorry for the long block of text, I'm happy to take that somewhere else if that's not the right place. I got an issue, not caused by pact itself but more as a conceptual question caused by the way the pact mock service is used. This page does not cover everything: https://github.com/pact-foundation/pact-mock_service/wiki/Using-the-mock-service-with-CORS In case you make a request from a browser, the Origin header will be sent, the pact mock service can just return `Access-Control-Allow-Origin: *` for it to work. However, if you make request with `withCredentials`, chrome for example will not take a wildcard for answer (https://stackoverflow.com/questions/42803394/cors-credentials-mode-is-include). That's why most backend framework instead takes the Origin value and send it back as `Access-Control-Allow-Origin`, for example for it could look like: ``` withRequest: { headers: { 'Origin': 'http://mydomain.com', willRespondWith: { headers: { 'Access-Control-Allow-Origin': 'http://mydomain.com', ``` Unfortunately, doing this will prevent you making request against the pact mock service from let's say, a localhost. The solution could be to add a matcher and with a wildcard: ``` willRespondWith: { headers: { 'Access-Control-Allow-Origin': Pact.Matchers.somethingLike('*'), ``` This will make you able to request from a localhost domain, to the pact mock service, but the only thing you want to make sure is that `'Access-Control-Allow-Origin` contains `http://mydomain.com` so that your app can call your service, and this doesn't do the job. Any thoughts?

zhirschtritt
2018-10-30 14:06
thanks Matt!

shidhore.ajinkya
2018-10-30 18:02
Thanks a lot @matt.fellows you both guresses are accurate :blush: . I need to hit https and also I was in my office's proxy environment. It works great at my home. Do you have any idea how to fix proxy issue in Visual Studio 2017 when I work in my office? I have the proxy server IP with me.

efoshager
2018-10-30 18:15
I'm a bit confused on consumers and providers in pact testing when only one endpoint is being tested. So the consumer generates a pact file based on the provider data being passed. This pact file is then tested against the contract?

efoshager
2018-10-30 21:26
What if the provider endpoint has like 30k lines? Does the consumer expect all 30k lines to be there?

bethskurrie
2018-10-30 21:28
The pact file *is* the contract.

bethskurrie
2018-10-30 21:31
Does the consumer care about every one of those 30k lines?

bethskurrie
2018-10-30 21:32
Can you set up a failing executable example in a repository? It always takes me a while to wrap my head around cors each time I pick it up again!

efoshager
2018-10-30 21:39
Sorry, I meant the pact file is then tested against the provider.

bethskurrie
2018-10-30 21:42
Yes

efoshager
2018-10-30 21:42
It did when I tested it. I added the provider data I wanted passed in the consumer, published, and it failed when I verified because it expected all the info.

bethskurrie
2018-10-30 21:42
Why is it different with only one endpoint?

efoshager
2018-10-30 21:43
I think I'm just confusing myself that both the consumer and provider have two separate endpoints. Thank you for clarifying!

abubics
2018-10-31 01:30
@efoshager ? It might help to clarify some vocabulary (for ease & consistency of communication) . . . - The implementation of the provider endpoint should be irrelevant to the consumer. I assume you mean the response is 30k lines? - Any consumer endpoint is generally implicit in an API client, not usually referred to as a separate concept/entity.

abubics
2018-10-31 01:32
- The pact test doesn't change the interaction of the consumer/provider, it's just more explicit about the sequence of communication.

abubics
2018-10-31 01:33
- The Pact-facilitated part of a contract test cares more about the shape of data than the values in the data. If you're writing tests that care about huge amounts of content (rather than structure), you might be better served with a different kind of test (e.g. unit test, not contract test)..

sylvia.yap
2018-10-31 05:20
has joined #general

matt.fellows
2018-10-31 07:31
It shouldn?t, we follow Postel?s law and only look at the bits we care about. Can you share your tests so we can understand why it?s failing?

matt.fellows
2018-10-31 07:32
Hi @shidhore.ajinkya not sure I?m afraid. You might have to ask Dr. Google :slightly_smiling_face:

bethskurrie
2018-10-31 08:04
If it failed because it expected "all the info" it's because the consumer expected "all the info".

romuald.quantin
2018-10-31 09:16
Hi Beth, setup is hard so that it might take a while, I'll think to the simplest way of showing you that. I keep you posted.


romuald.quantin
2018-10-31 09:27
Thank you, I'll check that. I might still start from scratch as I "might need" the PactJS version to do an xhr request.

paulswilliams
2018-10-31 11:41
So, I've also got a question about best practices, this time in relation to contract vs functional provider tests or possibly microservice / ui responsibility as described at https://docs.pact.io/best_practices/consumer/contract_tests_not_functional_tests The documentation advises contract tests be declarative about password complexity rules thus allowing password complexity rules to change over time with redeployments of the upstream service, without requiring consumer change. This is a great aim; a significant argument for micro-services and embracing different release cadences etc. However, perhaps it's a bad example, or perhaps I'm missing something, but I see a problem over this ambiguity; in this example the consumer also needs to understand the complexity rules to state them to the user either initially, or later if the user attempts to use an unsafe password. The UI needs to describe to users that passwords must be x length, contain this, that, and the other. The only solutions I see are: 1. the client understands at least a specification of the rules and is informed of breakage by server using some kind of status code, so the UI renders appropriate messages back to the user. These status codes would thus need Pact coverage to ensure reliable interoperability. This would break the documentation's advise? 2. the client knows nothing of the rules and if a user attempts an insecure password, the server encapsulates all responsibility of validation including rendering an error message eg error message string back through to the user via the consumer. This follows the documentation's advise and has the advantage of looser coupling between the components, and the ability to add new rules without redeploying the consumer. However, in my view, this would be breaking SRP; the service would be responsible in some part with UI concerns like the formatting of the error message, perhaps i18n etc. I'm wondering, is this just the wrong example to demonstrate non implementation contract tests, or am I missing something?

matt.fellows
2018-10-31 12:02
So I think that?s a good enough example. The password complexity logic will be contained within the API and as you state, you want to avoid breaking the SRP where possible, and you need a way to convey errors to the user. All that the functional test vs contract docs is saying, is that you don?t need to break all of the permutations of the password rules as part of your Pact testing. You?re probably going to have a standard `400` type error for a bad input, and then there should be an error body e.g. ``` { "error": "invalid password", "reason": "doesn't match complexity rule: > 10 chars", "code": 1234 } ```

matt.fellows
2018-10-31 12:03
that is a very contract-testable document, that you can now test without having to do all of the behaviour tests.

matt.fellows
2018-10-31 12:05
The Providers? job is to make sure it enforces the complexity rules, the job of the consumer is to make sure it can render messages. You should be able to design the consumer to gracefully handle new error codes (aka Postel?s Law) so that the system itself isn?t brittle

sarala_01
2018-10-31 12:38
has joined #general

borsuk.artem034
2018-10-31 13:55
has joined #general


romuald.quantin
2018-10-31 14:42
let me know if you have any problem running it

romuald.quantin
2018-10-31 14:42
there are 3 folders that explain the different CORS behavior


romuald.quantin
2018-10-31 14:44
again, just to be clear, this is not a pact-mock-service issue, it behaves in the right manner, it is just not accessible because of CORS issues

romuald.quantin
2018-10-31 14:45
we are not sure how we should approach this

romuald.quantin
2018-10-31 14:45
thanks in advance for any time taken looking at this!

romuald.quantin
2018-10-31 14:45
cheers.

paulswilliams
2018-10-31 14:58
Hey @matt.fellows, I'm not wondered away.. I'm just parsing and thinking. I have a slow brain :wink:

kevin.cormier
2018-10-31 15:02
has joined #general

matt.fellows
2018-10-31 20:12
No worries - I was resting my eyes :zzz: (7am our time now)

efoshager
2018-10-31 21:37
Any idea why I'm getting a 500 error when trying to generate a contract with a POST method? GET methods work fine.

bethskurrie
2018-10-31 21:40
What do the mock service logs say?

bethskurrie
2018-10-31 21:57
Can you raise an issue in one of the repos so I don't loose track of this @romuald.quantin?

romuald.quantin
2018-10-31 22:00
Sure, it is not exactly an issue, but I can summarize this in the pact-node or pact-mock-service repo. Tomorrow, cause that's the end of my day ;) cheers


efoshager
2018-11-01 14:04
node ./node_modules/mocha/bin/mocha ./test/pact/generate_reports/api.js --timeout 10000 Creating Pact Server with options: consumer = ui, cors = false, dir = C:\Projects\ui\pacts, host = 127.0.0.1, log = C:\Projects\ui\logs\pact.log, pactFileWriteMode = overwrite, port = 8993, provider = RegisteredCoupons, spec = 2, ssl = false, sslcert = , sslkey =

efoshager
2018-11-01 14:06
Created 'standalone\win32-1.61.1\bin\pact-mock-service.bat service --consumer 'UI' --pact_dir 'C:\Projects\ui\pacts' --host '127.0.0.1' --log 'C:\Projects\ui\logs\pact.log' --pact-file-write-mode 'overwrite' --port '8993' --provider 'RegisteredCoupons' --pact_specification_version '2'' process with PID: 21988

efoshager
2018-11-01 14:22
I, [2018-11-01T09:07:38.262193 #23576] INFO -- : Registered expected interaction POST /ok/user D, [2018-11-01T09:07:38.262193 #23576] DEBUG -- : { "description": "a request", "providerState": "a ui", "request": { "method": "POST", "path": "/ok/user", "headers": { "Content-Type": "application/json" }, - "body": { - "page": "browse", - "id": "201203164639", - "xpl": [ - "00891038001", - ] - } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "couponDetails": [ { "summary": "3.00$", "expDueDays": -1, } ] } } } I, [2018-11-01T09:07:38.293393 #23576] INFO -- : Received request POST /ok/user D, [2018-11-01T09:07:38.293393 #23576] DEBUG -- : { "path": "/ok/user", "query": "", "method": "post", "headers": { "Accept": "application/json", "User-Agent": "axios/0.15.3", "Host": "localhost:8993", "Connection": "close", "Version": "HTTP/1.1" } } E, [2018-11-01T09:07:38.293393 #23576] ERROR -- : No matching interaction found for POST /ok/user E, [2018-11-01T09:07:38.293393 #23576] ERROR -- : Interaction diffs for that route: E, [2018-11-01T09:07:38.293393 #23576] ERROR -- : Diff with interaction: "a request" given "a ui" Diff -------------------------------------- Key: - is expected + is actual Matching keys and values are not shown { "headers": { - "Content-Type": "application/json" }, - "body": { - "page": "browse", - "id": "201203164639", - "xpl": [ - "00891038001", - ] - } + "body": null } Description of differences -------------------------------------- * Could not find key "Content-Type" (keys present are: Accept, User-Agent, Host, Connection, Version) at $.headers * Expected a Hash but got nil at $.body

efoshager
2018-11-01 15:19
Okay, I figured it out. Had to change my header in my axios request and add charset=utf-8 to my withRequest.

r.chinn
2018-11-01 15:50
has joined #general

r.chinn
2018-11-01 15:53
Hi All, Can anyone point me in the right direction for raising a potential bug?


bethskurrie
2018-11-01 20:33
@r.chinn Find the appropriately repository in the pact-foundation org, and give the steps to reproduce it, the expected behaviour, and the actual behaviour. An executable code example to reproduce the issue is also polite and will help get your issue addressed more quickly.

efoshager
2018-11-01 21:04
I'm having a similar 500 issue from what I posted earlier. This time it is when adding a query to the url

efoshager
2018-11-01 21:05
E,[2018-11-01T14: 45: 29.245780 #30696] ERROR -- : No matching interaction found for GET /api/v2/products/1/(Price + Details)?upc=422504 E,[2018-11-01T14: 45: 29.245780 #30696] ERROR -- : Interaction diffs for that route: E,[2018-11-01T14: 45: 29.245780 #30696] ERROR -- :

bethskurrie
2018-11-01 21:07
Can you see the interaction being set up in the logs?

bethskurrie
2018-11-01 21:07
What is the path and query?

anothonyvong
2018-11-01 21:35
has joined #general

hansrd_98
2018-11-02 01:10
hi folks, I?m experimenting with pact-js (having previously used the ruby version of pact a fair bit), and anm having difficulty getting provider tests to work. So, after running the consumer tests, I can see the pact now in the pact broker, and it looks legit. When running the provider tests, based on the example here: https://github.com/DiUS/pact-workshop-js/blob/master/provider/test/providerPact.spec.js I get this error: ``` TypeError: verifier.verifyProvider is not a function ``` The provider test looks like this: ``` const verifier = require('@pact-foundation/pact').Verifier const chai = require('chai') const chaiAsPromised = require('chai-as-promised') const expect = chai.expect chai.use(chaiAsPromised) describe('Pact Verification', () => { it('should validate the expectations of the mock consumer', function () { this.timeout(10000) let opts = { provider: 'PaymentService', providerBaseUrl: <I have the provider endpoint here> pactBrokerUrl: <Broker url>, pactBrokerUsername: <Broker username>, pactBrokerPassword: <Broker password>, publishVerificationResult: true, providerVersion: '1', } return verifier.verifyProvider(opts) .then(output => { console.log('Pact Verification Complete!') }) }) }) ``` Any ideas what I?m doing wrong?

abubics
2018-11-02 01:19
Hi @hansrd_98 :slightly_smiling_face: you'll get better targeted support in #pact-js

abubics
2018-11-02 01:19
But I think `require('@pact-foundation/pact').Verifier` is a constructor

abubics
2018-11-02 01:20
so you probably want `new Verifier().verifyProvider(...)`

hansrd_98
2018-11-02 01:42
Thanks @abubics . Didn?t realise there?s a dedicated channel for js :slightly_smiling_face: Anyways, got it working fine with the below: `const { Verifier } = require('@pact-foundation/pact');` and inside the `it` block, `await new Verifier().verifyProvider(opts)`

abubics
2018-11-02 01:46
Nice one :ok_hand:

matt.fellows
2018-11-02 03:13
hehe thanks!

kobvel
2018-11-02 08:48
has joined #general

kobvel
2018-11-02 08:50
Guys. Quick question - should we host Pact tests as a separate repository?

jerwinecares
2018-11-02 09:18
has joined #general

bethskurrie
2018-11-02 10:09
I wouldn't. They belong as part of your normal test suite. They would go where the rest of your tests go.

bethskurrie
2018-11-02 10:10
The advantage of contract tests is that they give you immediate feedback. You don't want to slow that down by moving them further away from your code.

jesus.medinilla
2018-11-02 13:07
Hi everyone! Anyone knows how we can install Pact Broker on premise in HA (high availability)? Is there any documentation regarding this topic?

liran.tal
2018-11-02 13:55
@jesus.medinilla I don?t know about high availability but just getting it installed on premise is easy with the docker base image: https://github.com/DiUS/pact_broker-docker what kind of traffic are you expecting that qualifies as a requirement for high availability?

jesus.medinilla
2018-11-02 13:58
Having running two different instances (at least) sharing the load and the data. I don't know if only sharing the database would be enough (plus a load balancer) or more configuration is needed to achieve this

mats.lundkvist
2018-11-02 14:15
hi, I just downloaded the latest pact-ruby-standalone 1.62.2 but when I try to run ```bin/pact-mock-service version``` I get the following error ```bin/pact/lib/ruby/bin/ruby: line 6: bin/pact/lib/ruby/bin.real/ruby: No such file or directory``` but the file exists with read and execute permission for all users. What am I missing?

efoshager
2018-11-02 14:26
I tried adding a specific query parameter and adding it to the path directly, both throw the same error

efoshager
2018-11-02 17:09
Okay, I figured this one out. I used the query parameter and left out the ?. And then hardcoded the query in the expectation

efoshager
2018-11-02 21:21
I have some mock data similar to this. Is there a way to just reference "menu-coupons" and "categories" without specifying everything else in categories?

bethskurrie
2018-11-02 21:31
Are you on alpine linux @mats.lundkvist?

jeffm
2018-11-02 22:36
has joined #general

matt.fellows
2018-11-02 23:22
If not that, check correct architecture too

matt.fellows
2018-11-02 23:23
Why would you want to do that? Are you not interested in the shape of those fields?

bethskurrie
2018-11-03 00:25
Yes, you can just expect an empty hash.

jjlehva
2018-11-03 12:34
has joined #general

jjlehva
2018-11-03 12:55
Hi all! I am trying out Pact for the first time (with node and js). I?ve been testing this with a small microservice system and I ran in to a small problem when I started figuring out how to verify the provider side of things. I got the pact broker running and my consumer tests properly publishes the pacts there :ok_hand: The problem is simply that I?ve got the consumer pacts created for integrations between `Client A` and `Api 1`. Now when I try to verify the pacts for `Api 1` I am left wondering how should I tackle the requests from `Api 1` to `Api 2`, `Api 3` and `Api 4` which happens when the clients requests the endpoint from the `Api 1`. Should I mock those requests from `Api 1` to the other Apis during the provider verification or do I have to really run all the rest of the Apis as well? That would then again lead to running real integrations which is kind of the thing I would like to get rid of? I am just wondering if I?ve got the whole concept of Pact wrong or just missing some details from the documents. Any help would be great! :slightly_smiling_face:

liran.tal
2018-11-03 13:55
@jjlehva congrats on your progress so far! your intuition is correct - API 1 should stub the downstream dependencies. It makes sense that API1 has contracts with API 2, 3 and 4 so you can use the contracts with them as stubs, or just stub them out completely without the contracts.

matt.fellows
2018-11-03 14:28
Your doing great @jjlehva!

matt.fellows
2018-11-03 14:29
There's a section on the http://docs.pact.io I think under provider best practices that talks about exactly this +with a link out to a gist).

joscha.alisch
2018-11-03 16:18
has joined #general

vishesh92
2018-11-05 06:12
https://hub.docker.com/r/pactfoundation/pact-stub-server/tags/ tag v0.1.0 & v0.1.1 were removed recently from docker and our tests started failing because of that and we will have to update the image version at multiple places. Does latest version of the stub server image break or gets breaking changes frequently?

uglyog
2018-11-05 06:13
Versions 0.1.0 and 0.1.1 have a serious defect. Use 0.0.9 or 0.2.0 instead

uglyog
2018-11-05 06:15
Latest is pointing to 0.2.0 now

vishesh92
2018-11-05 06:38
ok. Thanks.

mats.lundkvist
2018-11-05 07:54
I run arch linux. I have an older version that works ```bin/pact-mock-service version 2.8.0``` but I wanted to upgrade for a new project

mats.lundkvist
2018-11-05 08:15
fixed it, I had some issues with my machine. Thanks for your help

dora.daniluc
2018-11-05 12:14
has joined #general

iryna.feuerst
2018-11-05 13:13
has joined #general

efoshager
2018-11-05 15:09
Because then my contract will be extremely long. Would it be best practice to pass all data?

efoshager
2018-11-05 16:27
like 5k lines

jbbarquero
2018-11-05 19:21
has joined #general

guilherme.santos6
2018-11-05 19:36
has joined #general

jbbarquero
2018-11-05 19:38
Hello, this is my first message here

jbbarquero
2018-11-05 19:39
I want to publish pacts to a broker with HTTPS and a certificate issued by a custom CA so I need to provide a truststore

jbbarquero
2018-11-05 19:40
But I don?t find this option in the maven plugin: https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-maven



jbbarquero
2018-11-05 19:47
Is it possible to specify a trustore for publishing pact files into a Pact Broker with HTTPS with certificates issued by a custom CA?

josh.mccure
2018-11-05 23:00
has joined #general

efoshager
2018-11-05 23:02
Actual array is too long and should not contain a Hash at $.items[1] -Why am I getting this error when my contract is specifying a specific array?

uglyog
2018-11-05 23:15
Wow, nobody has needed to do that before. You can publish the pact files with a PUT request to the broker using something like curl and be able to supply certificates.

xcq1.defy
2018-11-06 09:25
has joined #general

a.carpe
2018-11-06 13:16
has joined #general

a.carpe
2018-11-06 13:28
~Hello I?m using the pact-ruby to verify a pact produced by pact-jvm in V3 format~

a.carpe
2018-11-06 13:29
~it fails because the matching rules contain the `combine` key~

a.carpe
2018-11-06 13:30
~``` "$.assignedTimeSlot": { "matchers": [ { "match": "type" } ], "combine": "AND" } ```~

a.carpe
2018-11-06 13:31
and fails with this error: ``` pact-support-1.8.0/lib/pact/matching_rules/v3/merge.rb:124:in `block (2 levels) in log_ignored_rules': undefined method `any?' for "AND":String (NoMethodError) ```


a.carpe
2018-11-06 13:42
made a mess, wanted to post on pact-ruby channel? if anybody can delete these messages it would be great

nigel.hannam
2018-11-06 15:15
has joined #general

aaronmckaynz
2018-11-07 03:44
has joined #general

hima.sanagavarapu
2018-11-07 19:19
has joined #general

nish
2018-11-07 22:35
has joined #general

matt.fellows
2018-11-08 09:07
I think you're probably still interested in the shape of each object in the array, but not all the array items. If so, You could consider array matches to make your tests more succinct but still cover off the contract.

hstene
2018-11-08 11:03
Is the pact-broker down? My team reports that their managed pact-broker is not responding?

alexander.premer
2018-11-08 11:08
has joined #general

hcw99498
2018-11-08 14:33
has joined #general

rnv27647
2018-11-08 15:04
has joined #general

efoshager
2018-11-08 16:07
@hstene it's not down for me

efoshager
2018-11-08 17:30
I see, thank you

zhirschtritt
2018-11-08 17:35
Our team is currently evaluating Pact and we?re not sure it?s the right fit. One scenario: we have known consumers who are expecting our API to provide specified message via POST. First of all, are we the consumers in that case, or is our customer? And second, is this a reasonable use for contract testing? Any thoughts would be appreciated! Thank you :pray:

efoshager
2018-11-08 22:06
Is it possible to verify multiple providers to pact broker from a single file?

efoshager
2018-11-08 22:23
found out a way but not sure if its best practice. i'm adding multiple options and then passing those options through multiple verifiers and not exiting until the last verify

mboudreau
2018-11-08 23:14
I think you might have mistyped that, first consumers = customers?

mboudreau
2018-11-08 23:14
the consumers would be whatever uses the API

mboudreau
2018-11-08 23:14
now, if your company only provides the API for 3rd parties to use, they are the consumers

mboudreau
2018-11-08 23:16
however, this doesn't mean you can't still have pact tests to make sure your APIs follow a contract, the only thing is that you don't have a real life consumer to base it on, which is fine. Contracts don't have to be made from the consumer, you could, if you're keen, just create the contract file by hand, or use the consumer DSL to create one for you which you then use to test your API

mboudreau
2018-11-08 23:18
not really, the whole point is that your provider should be unique in a way, hence the contracts are a many to one, consumer to providers respectively

mboudreau
2018-11-08 23:18
if what you're trying to accomplish is to 'reuse' code or contracts between providers, I'd suggest you do that through code reuse, but not contract reuse

mboudreau
2018-11-08 23:18
does that make sense?

hstene
2018-11-09 07:11
Our broker was on an overloaded worker instance. They moved it and it came back online :slightly_smiling_face:

kevin.cormier
2018-11-09 15:29
Hi All. We are looking at evaluating Pact in the next few weeks. I'm trying to find some guidance on securely running a pact broker in AWS while testing in travis. Does anyone have any recommended reading?

efoshager
2018-11-09 15:55
i don't want to reuse any contracts, just simply verify multiple providers from a single file. i have a single script in my package.json that i want to be executed to verify all 10 providers i'm using from a single file.

zhirschtritt
2018-11-09 16:36
ok, that clears things up. I was having a hard time convincing my team that the customer is the consumer, even though we initiate that particular communication via a POST

efoshager
2018-11-09 18:33
other teams at my work are writing the consumer contracts, multiple teams use my providers, i want to verify all providers from a single file. each provider is unique with its given name.


matt.fellows
2018-11-09 19:46
A simple option is nginx (or another proxy) with auth attached to it, then use Travis secrets to manage creda

matt.fellows
2018-11-09 19:46
Alternatively, you could add rack middleware to the app with your own custom auth

kevin.cormier
2018-11-09 20:41
@mr.matt.r.long Thanks for the info!

jani.jegoroff
2018-11-10 19:50
has joined #general

nihei.dev
2018-11-11 06:56
has joined #general

kamilmarkow
2018-11-11 15:05
has joined #general

liran.tal
2018-11-11 18:04
:wave: I created `awesome-contract-testing` as a repository to help consolidate all kinds of resources for this topic. would be great if you want to contribute: https://github.com/lirantal/awesome-contract-testing I?ll also gladly add you to the repo collaborators to help organize and curate content

silvia.pusterla
2018-11-12 09:14
has joined #general

silvia.pusterla
2018-11-12 09:14
Hi all, My name is Silvia and I?m from Data Natives. Glad to be part of your community! I wanted to let you know about our Data Natives conference that will take place on November 22-23. It focuses on key areas of Artificial Intelligence, Machine Learning, Internet of Things, FinTech, HealthTech and more. Our event aims to bridge the gap between technical innovation and business interests. We?d like to offer your community a 50% discount on tickets using this promo code: DN18LOVESCOMMUNITY. You can also enter the raffle for a free ticket here: https://datanatives.typeform.com/to/aKSIlv Please, find more info about the conference here: http://datanatives.io/ Hope to see you there!

nikolajs.cmihuns
2018-11-13 09:57
has joined #general

jesus.medinilla
2018-11-13 11:39
Hi, I'm trying to execute a provider validation using pact-provider-verifier (pact-1.61.2 , linux 64 version) but I've been unable so far: This is what I'm retrieving: pact-provider-verifier --pact-broker-base-url $PACT_BROKER_URL --provider-base-url http://**** --provider users_http_provider --provider-app-version=0.0.1-SNAPSHOT --publish-verification-results=false INFO: Fetching pacts for users_http_provider from http://***** INFO: Reading pact at http://*****/pacts/provider/users_http_provider/consumer/organizations_http_consumer/version/0.0.6-SNAPSHOT /opt/pact/lib/vendor/ruby/2.2.0/gems/pact-support-1.8.0/lib/pact/matching_rules/v3/merge.rb:119:in `block (2 levels) in log_ignored_rules': undefined method `any?' for "AND":String (NoMethodError). Anyone can help me out with this, please? EDIT: The problem is this line: $stderr.puts "WARN: Ignoring unsupported #{key} #{value} for path #{path}" if value.any? from /ruby/2.2.0/gems/pact-support-1.8.0/lib/pact/matching_rules/v3/merge.rb file. "any?" method on strings is not supported is this ruby version

sandy
2018-11-13 13:02
has joined #general

dimas.kotvan
2018-11-13 18:13
has joined #general

efoshager
2018-11-13 19:22
is something like this possible? i want to very many providers in one file. the above code only executes the first opts1 then finishes. even with proccess.exit taken out, it still executes the first opts1 and finishes

matt.fellows
2018-11-13 19:52
Looks like maybe a bug, are you able to pleae submit a ticket with your pact file so we can repro?

matt.fellows
2018-11-13 19:53
Ideally, a gist or something to reproduce would be great

matt.fellows
2018-11-13 19:55
This is not currently possible but could be easily added. If you could please raise an enhancement request to pact js we can discuss there

matt.fellows
2018-11-13 19:56
You'll have to Manually loop for now.

matt.fellows
2018-11-13 19:56
May I ask more about your use case? It would seem unusual to be doing multiple providers at once

marco.dellolio
2018-11-13 20:41
Hey guys good evening/morning I have 2 question, confirmations really: 1 - There is not system in place to push a pact file when a Provider changes because is not of Pact was designed? 2 - We are not supposed to test consumers against in dev providers (using a specific `sha`)

efoshager
2018-11-13 21:04
its mainly because we're running our provider verification through a pipeline and has been requested to be in one file

tjones
2018-11-14 00:21
@marco.dellolio When the provider changes, you only need to do a new verification. Pact is driven by the consumer. You can think of a pact file as a consumer saying "hey, this is the behaviour I rely on". It's not a full API definition. This is a nice feature, as it means that provider changes that don't affect consumers (eg on API endpoints or data objects that aren't being used yet) don't break any tests

tjones
2018-11-14 00:23
If you have the scenario where a provider changes the API in a way that breaks consumers, verification will fail. This needs to be communicated to the consumers who can then update their api calls and tests (which will generate a new Pact file, which can then pass verification)

tjones
2018-11-14 00:24
If you're developing the API at the same time as using Pact, it's easiest to drive changes from the consumer. However, it is still possible to drive them from the provider.

tjones
2018-11-14 00:24
For your second question, I'm not sure I understand. Could you elaborate a bit?


tjones
2018-11-14 00:28
Hi all - I've had a couple of cases where I've written consumer tests in cases where provider verification is extremely impractical (eg third party providers). I think this is still valuable, as it ensures that you're using whatever client library correctly (it picked up a javascript case where `http://axios.post({options, url})` should have been `http://axios.post(url, options)`, whereas mocking `axios` might have missed it). Are there other advantages? What do people think?

ryan
2018-11-14 22:22
has joined #general

matt.fellows
2018-11-15 06:24
Why does it need to be in one file? How does that affect the pipeline? There's no reason you couldn't loop thru all providers in a single just file and run the verification per provider. Still I'd like to know more about why that's necessary. I can't think if many situations where you want to know all providers need to be verified at once. That seems like you're creating too much coupling. @bethskurrie @uglyog thoughts?

bethskurrie
2018-11-15 06:34
My thoughts are "why does it have to be one file? " too. Can you explain that constraint @efoshager?

matt.fellows
2018-11-15 07:40
I still do it

matt.fellows
2018-11-15 07:42
You still get the following benefits: 1. You still verify your collaborator?s behaviour (as you stated) 2. You get documentation 3. There can still be some ways to verify (but they are scary/hacky/dangerous/all of the above)

jonas.natten
2018-11-15 08:02
has joined #general

liran.tal
2018-11-15 12:30
4. if you use the broker to store the pact then you can also see which 3rd parties are used through-out your services very quickly

liran.tal
2018-11-15 12:30
also, will add all of this insight to my upcoming doc on the subject. great points!

ashwin.bakker_nl
2018-11-15 14:54
has joined #general

acooper106
2018-11-15 20:23
When using tags, our pact provider verification is verify against latest and pervious pacts. For example, we added a dev tag to the pact, then removed the dev tag and added a prod tag, then ran provider verification against the consumer pact with the dev tag and the test still found and ran against the previous pact with the dev tag. Is this the expected behavior? If so is there a way to run the provider verification against the latest pact on the broker?

tjones
2018-11-16 02:58
That'd be awesome @liran.tal!

kanwaldeepbhangu117
2018-11-16 07:37
has joined #general

mats.lundkvist
2018-11-16 08:26
Hi, I'm currently writing a provider test in golang with the pact standalone. But it looks like the pact is tested against values and not the correct matchers (regex and type) that is specified in the pact json. Is there some configuration needed to get regex and type matching to work? Edit: From what I can tell pact go cannot handle pact v3

matt.fellows
2018-11-16 09:33
@mats.lundkvist yes, only Pact JVM supports full pact v3 spec. Go/JS support the message pact portion of v3 and everything else is v2

bethskurrie
2018-11-16 09:33
But v2 supports type matching and regex

matt.fellows
2018-11-16 09:41
If it has the `combine` matcher in it then that won?t work, standard regex/type matching should work as per examples (I think you?ve indicated use of this in the past)

mats.lundkvist
2018-11-16 11:10
Thanks for helping!

nikolajs.cmihuns
2018-11-16 11:21
Question to some ... :slightly_smiling_face: If I want to create pact v3 tests for provider in Scala (but don't want to use Junit libs which we have e.g. pact-jvm-provider-junit) what core modules/libs I can rely on ? As I see I can use something from here - https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider

nikolajs.cmihuns
2018-11-16 11:22
but not sure if V3 is supported here

acooper106
2018-11-16 15:28
@bethskurrie Has anyone experienced this? Or know how to fix this?

ashwin.bakker_nl
2018-11-16 16:29
Anyone have experience with Pact in combination with Spring Cloud Contract? I've made a post on stackoverflow, maybe someone in here knows the answer https://stackoverflow.com/questions/53340847/spring-cloud-contract-pact-broker-json-string-can-not-be-null-or-empty

gregigcool
2018-11-16 19:57
has joined #general

ravbaker
2018-11-17 10:24
has joined #general

uglyog
2018-11-18 21:26
Yes you can, all the libraries support the V3 format but you'll have to write the test support code yourself. There is also a pure scala implementation https://github.com/ITV/scala-pact

uglyog
2018-11-18 21:27
But the pact-jvm-provider library contains the verifier used by the other test support modules.

sandy
2018-11-19 01:28
Hello, you were kind enough to provide us with a hosted pact broker, however I am unsure as to wether seeing a 404 on the base URL is normal. We have tried publishing our javascript pact via the binary, and have not been able to get a successful message. Any thoughts?

mboudreau
2018-11-19 01:37
what's the URL you're using?

sandy
2018-11-19 02:13
Its the one we were sent in the email. `https://liftango.pact.dius.com.au`

bethskurrie
2018-11-19 02:14
Hi Sandy. We recently did a cull of brokers that had no pacts and hadn't been used for over a month.

bethskurrie
2018-11-19 02:15
Is this your first pact?

sandy
2018-11-19 02:17
Ah, yes, we started evaluating a couple of months ago, and got sidetracked, but now were moving forward :slightly_smiling_face:

matt.fellows
2018-11-19 05:01
Your account may be disabled, we'll reenable for you

acooper106
2018-11-19 13:59
Or is there any material that would answer this question?

ashwin.bakker_nl
2018-11-19 14:41
Fixed it. My base class wasn't setup properly. See SO thread for working base class if curious.

ben7091
2018-11-19 16:29
has joined #general

sandy
2018-11-19 21:24
thanks, that would be awesome

matt.fellows
2018-11-20 05:51
Your account should be reactivated, apologies for the delay

nikolajs.cmihuns
2018-11-20 07:02
@uglyog thank you for answering:thumbsup:

nikolajs.cmihuns
2018-11-20 08:11
find it strange that we have AmqpTarget, BaseTarget etc. in pact-jvm-provider-junit lib, not in pact-jvm-provider

nikolajs.cmihuns
2018-11-20 08:12
so comes out that we don't have some general V3 support, only something which is coupled to framework specific things like junit

uglyog
2018-11-20 08:14
That is just historical. The Target classes were written for the JUnit implementation, which is why they are there.

uglyog
2018-11-20 08:17
The V3 support is implemented in the core libraries (matching, models, etc). The verifier in pact-jvm-provider uses the core libraries to do the actual matching. The specific framework libraries use the verifier.

sandy
2018-11-20 11:20
No problem, thanks Matt. I have been able to publish our first consumer pacts! really appreciate it.

sasa.milovic
2018-11-20 15:05
has joined #general

sasa.milovic
2018-11-20 15:19
Hi, I'm not sure if this is the right place to ask for support for a hosted pact broker?

sasa.milovic
2018-11-20 15:20
We've got one at https://asos.pact.dius.com.au, but it's been having issues last week and today again, we seem to be getting "Service Unavailable"

sasa.milovic
2018-11-20 15:22
Also, might be worth mentioning that the join slack link at https://pact.dius.com.au/ takes you to a "there's nothing here yet" heroku landing page :smile:

rjmcguinness
2018-11-20 15:58
has joined #general

uglyog
2018-11-20 21:34
@sasa.milovic we'll look into that for you. The previous slack was decommissioned in favour of the #pact-broker channel

abubics
2018-11-21 03:04
Hey y'all :slightly_smiling_face: We're trying to do some CDC testing for a legacy system (the consumer) written in C++, and not coming up with any good technology fits. Any recommendations?

abubics
2018-11-21 04:09
Looks like we're going to try making a Python test harness, treating the C++ system as a black box. Wish us luck xD

matt.fellows
2018-11-21 05:08
OK, that?s one option

matt.fellows
2018-11-21 05:09
another is to simply use the Pact CLI tools. On the provider side, it?s a cinch. On the consumer side, you might need to orchestrate a few calls to the mock service. Details/breadcrumbs: * How to write a consumer test, without a consumer language / DSL support * https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh * how to write a provider test, without provider language / DSL support * https://github.com/pact-foundation/pact-ruby-standalone/releases

matt.fellows
2018-11-21 05:16
You?re welcome!

abubics
2018-11-21 06:20
The reason for attempting in python is there's a set of company-wide existing test harness codebases (in python), so it might've reduced the learning curve

lloydchang
2018-11-21 08:21
has joined #general

sasa.milovic
2018-11-21 12:58
Thanks!

ian.fessey
2018-11-21 16:22
has joined #general

sandy
2018-11-22 02:24
Hey folks, I have read what I could find about matching, and I have a question. We are using javascript, and I have a case where I want to be able to verify a pact where the value of the key in the object is treated the same way `like()` treats the values. i.e. ```pickingUpRides: { 9: { rideId: 9, passengerSeats: { standard: 1, wheelchair: 0, }, }, }``` so I am asking, can I create a pact response, where I want the key `pickingUpRides` to have a nested object with a key of type 'number' where I don't care about the value, but it must contain at least one nested object? And then to be able to verify the structure under `9` as per normal?

tjones
2018-11-22 02:34
I think JSON requires that keys are strings, so this might be challenging - the default pact matchers work on types

tjones
2018-11-22 02:35
I had a similar situation that we solved using states - the state was something like `a rides record with ID 9 exists`

sandy
2018-11-22 03:05
Yeah, the JSON spec requires a string, this was pulled from the JS... ill take a look at states, as we have decided to just couple the IDs in the interim between consumer/provider

sandy
2018-11-22 03:07
so the key type is not important as far as treating it as any allowed value

tjones
2018-11-22 03:14
for HTTP pacts, pact will verify what was on the wire

tjones
2018-11-22 03:14
(which is probably a string)

tjones
2018-11-22 03:17
As to whether you can use matchers to specify allowed formats for object keys, I'm not sure. Might be a @bethskurrie question

tjones
2018-11-22 03:17
> we have decided to just couple the IDs in the interim between consumer/provider States will let you describe the coupling in a nice way, so that any future provider implementations don't get surprised.

bethskurrie
2018-11-22 03:19
If you're using a non pact-jvm impl, I don't think it will even allow you to use a number as a key.

bethskurrie
2018-11-22 03:19
Let me do a quick experiment with ruby.

bethskurrie
2018-11-22 03:20
``` {9 => 'foo'}.to_json => "{\"9\":\"foo\"}" ```

bethskurrie
2018-11-22 03:20
Numbers are not allowed as keys.

bethskurrie
2018-11-22 03:20
By default, anyway

bethskurrie
2018-11-22 03:20
I really wouldn't recommend it.

sandy
2018-11-22 03:21
Thanks Beth, yes, I mistakenly thought typescripts ability to do this translated to the JSON spec. It doesn't.

sandy
2018-11-22 03:23
So we are planning to just have these tests be aware of the given ids until we can move to a new approach

bethskurrie
2018-11-22 03:23
:thumbsup::skin-tone-3:

acooper106
2018-11-22 04:26
When using tags, our pact provider verification is verify against latest and pervious pacts. For example, we added a dev tag to the pact, then removed the dev tag and added a prod tag, then ran provider verification against the consumer pact with the dev tag and the test still found and ran against the previous pact with the dev tag. Is this the expected behavior? If so is there a way to run the provider verification against the latest pact on the broker?

bethskurrie
2018-11-22 04:26
Don't remove the dev tag.

bethskurrie
2018-11-22 04:27
You say /latest/dev or /latest/prod

bethskurrie
2018-11-22 04:27
You don't typically remove tags

bethskurrie
2018-11-22 04:27
The overall latest is /latest


acooper106
2018-11-22 04:28
Not sure what you mean. I would expect that if the latest pact doesn't have a tag then the verification shouldn't run against it

bethskurrie
2018-11-22 04:29
@acooper106 please read these docs and tell me if you have any further questions

acooper106
2018-11-22 04:30
I would think a pact should have either dev or prod not both. Sure I'll check it out

bethskurrie
2018-11-22 04:30
Think of the tags as a history of its progress

bethskurrie
2018-11-22 04:31
It was at one stage dev, then it became prod

acooper106
2018-11-22 04:31
yes I'm not asking about urls

bethskurrie
2018-11-22 04:32
When you retrieve a pact by tag, you are always retrieving the latest pact with that tag.

acooper106
2018-11-22 04:32
I was talking about the provider verification running against a pact in history

bethskurrie
2018-11-22 04:33
The provider verification retrieves pacts by URL.

bethskurrie
2018-11-22 04:33
If you want to understand how the provider verification selects the pacts to verify, you should understand the URLs.

acooper106
2018-11-22 04:33
I don't have a url in my junit test. I guess that's what I'm looking for a doc on


bethskurrie
2018-11-22 04:34
The junit test will retrieve the latest pact for the tag you give it.

acooper106
2018-11-22 04:37
ok the latest pact on my broker only has prod tag. but the previous version pact has dev. When I run the provider verification it runs against the pact version with the dev tag.

acooper106
2018-11-22 04:38
I would expect it not to run against the previous version because the latest pact on the broker says prod

acooper106
2018-11-22 04:41
I wish there was a way to put the exact url in the test

bethskurrie
2018-11-22 04:41
What is your configuration?

acooper106
2018-11-22 04:41
when doing pact swagger validation the test needs the url of the pact your running against

acooper106
2018-11-22 04:50
I sent you the email with details on exactly what happened. What exact configurations do you need from me

acooper106
2018-11-22 04:56
I just checked the broker again. Currently this provider have 2 pacts with dev tags no prod tags. When I run the provider verification locally 2 pacts come up. and the broker updates the laste verified status. I would expect the test to say there were no pacts with "Prod" tag

bethskurrie
2018-11-22 04:57
That seems reasonable

bethskurrie
2018-11-22 04:58
I haven't used this plugin, but can you look at the documentation and see if there is a verbose option you can put on?

bethskurrie
2018-11-22 04:58
To get a better idea of the tags, can you have a look at the matrix view for this pact?

acooper106
2018-11-22 05:02
I did. the prod tag existed on version 1.0.0

bethskurrie
2018-11-22 05:03
So, there is a prod tag...

acooper106
2018-11-22 05:03
but the latest is only dev

bethskurrie
2018-11-22 05:03
And if you're configuring your test to verify the latest prod, then it will verify that one.

bethskurrie
2018-11-22 05:03
It finds the latest pact with the prod tag.

acooper106
2018-11-22 05:04
~run again latest prod~

bethskurrie
2018-11-22 05:04
It does not find the latest pact, and then see if it has a prod tag on it.

acooper106
2018-11-22 05:05
my latest pact is 1.0.1

bethskurrie
2018-11-22 05:06
If you have configured your test to verify the latest prod, then it should verify 1.0.0

bethskurrie
2018-11-22 05:06
If you have configured your test to verify the latest dev, then it should verify 1.0.1

bethskurrie
2018-11-22 05:07
If you have configured your test to verify the latest (with no tags specified, not recommended) then it will verify 1.0.1

acooper106
2018-11-22 05:07
can this be changed

acooper106
2018-11-22 05:08
the test only has tags no way to specify version

acooper106
2018-11-22 05:08
latest or otherwise

acooper106
2018-11-22 05:08
I would think latest would just be the one showing on the broker

bethskurrie
2018-11-22 05:09
When you specify the tag name, it will verify the latest pact with that tag.

bethskurrie
2018-11-22 05:09
> the test only has tags no way to specify version This is the normal behaviour.

acooper106
2018-11-22 05:09
I wasn't expecting it to go back in history to find prod tag over the latest version published

acooper106
2018-11-22 05:09
o

bethskurrie
2018-11-22 05:09
According to the images you sent me, it was configured with the "prod" tag.

bethskurrie
2018-11-22 05:10
I can see in the screenshot, `tags="PROD"`

bethskurrie
2018-11-22 05:10
That means it will verify the latest pact that has the prod tag.

acooper106
2018-11-22 05:10
yes but the current version on the broker is 1.0.1 DEV

acooper106
2018-11-22 05:11
I was expecting it to only look at that one and say there are no pacts with that tag

bethskurrie
2018-11-22 05:11
So, configure it to verify `tags="DEV"`

bethskurrie
2018-11-22 05:11
But there is a pact with dev and a pact with prod.

bethskurrie
2018-11-22 05:11
Which ever tag name you put in, it will find a pact.

bethskurrie
2018-11-22 05:13
If you put in "foobar" it should raise an error - there are no pacts with tag "foobar".

acooper106
2018-11-22 05:15
I see. I just thought it would check only check the latest version. But I see you've clarified that its expected to look at pervious versions for the tag

acooper106
2018-11-22 05:23
hmm now I think it makes sense because we don't want the provide build to fail when a consumer uploads a new pact with 1.0.1 dev. but I think the broker last veried is a little misleading since it just looks like 1.0.1 dev was varied, when actually it was 1.0.0 PROD that was varied. Maybe last verified should still be yellow.

acooper106
2018-11-22 05:25
why should this update when my tag is prod

fewstera
2018-11-22 09:55
has joined #general

roger.vieira
2018-11-22 12:51
has joined #general

roger.vieira
2018-11-22 13:03
Hi guys I have some doubts trying to use Pact in my projects: ? why I need to call a PactVerificationResult in order to generate the Pact's contract file (the one that is used to publish in Pact Broker)? ? is mandatory to use @Test annotation to call for a method that will generate Pact contract? Is there another way to call for contract generation? Maybe I've misunderstood about Pact application scenarios, but actually is not so clear for me the reason why I need to call a mock server using the contract in order to generate Pact file, imo this seems to be against Pact's purpose, because the main objective of Pact is to not "touch" in third parties' APIs, just test contract between consumers and providers.

roger.vieira
2018-11-22 13:04
(I'm not sure whether this is the right place for my questions)

romuald.quantin
2018-11-22 13:38
General question, we updated our nodejs version which support http2. Is there a correlation between pact and http2? If yes, where can I find more information?

uglyog
2018-11-22 21:02
Pact is a contract *testing* framework. It is designed for writing and executing contract tests. The actual pact file is just an artefact of the test execution on the consumer side.

tadeusz.rychter
2018-11-22 21:17
has joined #general

hans.hofkens
2018-11-22 21:32
has joined #general

paul.mckeown
2018-11-22 21:43
has joined #general

fraser.crichton.devel
2018-11-22 22:05
Hi there, I?m working at an organisation where we are at the early stages of investigating Consumer-Driven Contract Testing and looking at how to achieve this. Many of our API Services are Java Spring Boot applications and our clients are a mixture of React, Ember, mobile applications and service-to-service. Something that we are looking at currently is: https://cloud.spring.io/spring-cloud-contract/single/spring-cloud-contract.html Am just wondering if anyone else using Spring Cloud Contract? Is it mature? Are there any problems people have experienced implementing it? Thanks.

mboudreau
2018-11-22 22:40
What do you mean correlation?

lovesh.jain
2018-11-22 23:01
has joined #general

matt.fellows
2018-11-23 05:46
I haven?t used it personally, but I can say that it is mature and the community around it is very good. Marcin (project Lead) has also made aspects of it compatible with Pact, so there is some interoperability also

matt.fellows
2018-11-23 05:47
Any reason why you?re looking at it instead of Pact?

ots.indrek
2018-11-23 09:41
has joined #general

ots.indrek
2018-11-23 10:24
Hey, I have a question regarding preventing missing verifications https://docs.pact.io/best_practices/pact_nirvana#8-prevent-missing-verifications I have set up tagging when a deployment is made, also webhooks are in place that trigger provider CI jobs. > To reach Pact Nirvana, the final step is to have a CI build that checks out the code for the production version of your provider, and have it verify the same pacts that the head version does. Should the final step be part of the deployment? For example, if `can-i-deploy` reports that a verification is missing, the deployment script will do the verification? Or could this be done when a webhook triggers a provider CI job?

bethskurrie
2018-11-23 10:31
Is the content of the prod and dev pact the same?

bethskurrie
2018-11-23 10:31
The verification belongs to the content, so if they have the same content, they will both be verified

bethskurrie
2018-11-23 10:32
There is a good document on versioning in the broker on http://docs.pact.io

bethskurrie
2018-11-23 10:34
I'm not 100% sure this final step is necessary (and I wrote this document) so I would wait and see if you need it.

bethskurrie
2018-11-23 10:35
One way to do it would be to have a separate job that ran the verifications with the prod codebase that was triggered by a webhook.

ots.indrek
2018-11-23 10:49
Thanks, I'll first start without the final step then and see if I run into a situation where it might be needed

bethskurrie
2018-11-23 11:00
Yes, good plan. If you're deploying your provider regularly, I don't think you'll need it. I think it's mostly relevant if you have long gaps between deployments.

fewstera
2018-11-23 12:13
Any idea why pact-go isn?t working from inside a docker container? ``` 2018/11/23 12:10:38 [DEBUG] pact setup logging 2018/11/23 12:10:38 [DEBUG] pact setup 2018/11/23 12:10:38 [DEBUG] checking CLI compatability 2018/11/23 12:10:38 [INFO] checking pact-provider-verifier within range >= 1.15.0, < 3.0.0 2018/11/23 12:10:38 [DEBUG] running binary pact-provider-verifier 2018/11/23 12:10:40 [DEBUG] checking version for binary pact-provider-verifier version 1.21.0 2018/11/23 12:10:40 [DEBUG] checking if version 1.21.0 within semver range >= 1.15.0, < 3.0.0 2018/11/23 12:10:40 [DEBUG] 1.21.0 satisfies constraints 1.21.0 >= 1.15.0, < 3.0.0 2018/11/23 12:10:40 [INFO] checking pact-broker within range >= 1.16.0, < 2.0.0 2018/11/23 12:10:40 [DEBUG] running binary pact-broker 2018/11/23 12:10:41 [DEBUG] checking version for binary pact-broker version 1.17.0 2018/11/23 12:10:41 [DEBUG] checking if version 1.17.0 within semver range >= 1.16.0, < 2.0.0 2018/11/23 12:10:41 [DEBUG] 1.17.0 satisfies constraints 1.17.0 >= 1.16.0, < 2.0.0 2018/11/23 12:10:41 [INFO] checking pact-mock-service within range >= 2.9.8, < 3.0.0 2018/11/23 12:10:41 [DEBUG] running binary pact-mock-service 2018/11/23 12:10:42 [DEBUG] checking version for binary pact-mock-service version 2.12.0 2018/11/23 12:10:42 [DEBUG] checking if version 2.12.0 within semver range >= 2.9.8, < 3.0.0 2018/11/23 12:10:42 [DEBUG] 2.12.0 satisfies constraints 2.12.0 >= 2.9.8, < 3.0.0 2018/11/23 12:10:42 [DEBUG] setting up a service manager 2018/11/23 12:10:42 [DEBUG] setting up a service manager 2018/11/23 12:10:42 [DEBUG] setting up a service manager 2018/11/23 12:10:42 [DEBUG] pact provider verification 2018/11/23 12:10:42 [DEBUG] client: verifying a provider 2018/11/23 12:10:42 [DEBUG] waiting for port 8000 to become available 2018/11/23 12:10:42 [DEBUG] starting service creation monitor 2018/11/23 12:10:42 [DEBUG] starting service removal monitor 2018/11/23 12:10:42 [DEBUG] starting service creation monitor 2018/11/23 12:10:42 [DEBUG] starting service removal monitor 2018/11/23 12:10:42 [DEBUG] starting service creation monitor 2018/11/23 12:10:42 [DEBUG] starting service removal monitor 2018/11/23 12:10:52 [ERROR] Expected server to start < 10s. Timed out waiting for Provider API to start on port 8000 - are you sure it's running? 2018/11/23 12:10:52 [DEBUG] starting verification service with args: [./replaced-id-pact.json --custom-provider-header X-is-test: true --custom-provider-header X-user-details: {"name": "CDC User", "email":"", "groups": ["journalist", "content-editor"]} --format json --provider-base-url http://app:8000] ``` If I change the provider base url to localhost and run the tests outside of docker with the provider inside of docker it works fine.

fewstera
2018-11-23 12:14
``` func TestProvider(t *testing.T) { c := getConfig() pact := &dsl.Pact{ Consumer: "intel-cms-admin", Provider: "intel-cms-srvice", LogLevel: "DEBUG", } pact.VerifyProvider(t, types.VerifyRequest{ ProviderBaseURL: "http://app:8000", PactURLs: []string{replacedPactJSONFile}, CustomProviderHeaders: []string{ "X-is-test: true", fmt.Sprintf("X-user-details: %s", c.userDetailsJSON), }, }) } ```

fewstera
2018-11-23 12:15
I can curl http://app:8000 from inside the container, so it can see the provider

bernardo.guerreiro
2018-11-23 15:27
You shouldn't be using Pact to test third party API's. You use it to test services you control end to end, consumer/provider pairs. The mock server is replacing your provider API on the consumer side . You need it in order to generate the contract, because when you run your tests, as part of them, your mock server will be called (instead of your real provider), and return the interaction you defined for it. That moment when you've successfully called and received back the interaction you established is when the contract is generated. That contract is the whole point of pact. That then can be used by the real provider to test against the real endpoint.

fewstera
2018-11-23 16:30
^^ seems like a bug with this https://github.com/pact-foundation/pact-go/blob/c2dcd782ab0bb3ee4a6a689ba0c4083f31258628/dsl/client.go#L125 It appears to always assume your address is localhost, I guess it needs a similar function to getPort where it gets the host from the provider base url.

stevejbartholomew
2018-11-23 17:15
has joined #general

kristine.jetzke
2018-11-23 21:04
Hi, just in case someone is interested: I wrote a blog post on writing pact tests in spring boot and one one integrating the tests into Jenkins build pipelines using the pact broker: https://link.medium.com/q3cC0j8w5R and https://link.medium.com/4o0ZIqhx5R

matt.fellows
2018-11-23 23:34
In most cases, the contract doesn't change all that often, so in most cases what's already in prod can be checked with can I deploy.

matt.fellows
2018-11-23 23:35
This is for those edge cases Beth alludes to

matt.fellows
2018-11-23 23:36
Thanks for looking. I'll try to get to these next week. If you haven't already, raise a bug and a PR if you're interested - and we can get it sorted

matt.fellows
2018-11-23 23:39
Thanks, will take a read tonight! So many more strikes coming out now :pray:

jornhansen
2018-11-24 08:14
has joined #general

fewstera
2018-11-24 15:58
I will try raise a PR Monday :slightly_smiling_face: Spent most of Friday afternoon trying to solve a different issue that turned out to be a simple fix in the end :man-facepalming:

fraser.crichton.devel
2018-11-26 04:58
I?m not, but one of the teams I?m working with is and they are interested in exploring Spring Cloud as an alternative as they use Spring for all their services. Many of our other teams may choose plain Pact, so we just want to be sure the Pact Broker and Spring Cloud will play together. Yes, I have to say it seems to over complicate things but we want our teams to feel empowered to choose which tools they use hence trying to find out a bit more so we can help them along. Hope Melbourne is treating you well btw.

matt.fellows
2018-11-26 05:50
Oh - hello!

matt.fellows
2018-11-26 05:50
I replied via mobile but didn?t click - how?s it going?

matt.fellows
2018-11-26 05:51
And yes, totally get the ?pick the right tool for the situation/context/team? - always looking to see if there is something missing / broken that we need to address

matt.fellows
2018-11-26 05:51
How?s it all going? I?m (temporarily) in the states, but will be home in Melbourne next week. Where are you?

matt.fellows
2018-11-26 05:54
:slightly_smiling_face:

matt.fellows
2018-11-26 05:54
no worries, thanks

matt.fellows
2018-11-26 06:36
@kristine.jetzke nice work on the Jenkins example! It?s _pretty_ detailed - and we like that!

kristine.jetzke
2018-11-26 07:46
Thanks :blush:


syed.haq
2018-11-26 12:53
has joined #general

uma.shanker
2018-11-26 16:25
has joined #general

inbox
2018-11-26 16:39
Does the free pact broker expire?

matt.fellows
2018-11-26 16:53
Not for any active accounts, but if you haven't used it for several months and never pushed Tobit, we've probably disabled it

inbox
2018-11-26 20:15
I see. Would it be possible to reenable https://aramark.pact.dius.com.au/ ? or reapply for it? We've been busy with other work and haven't had an opportunity to push to it.

bethskurrie
2018-11-26 21:16
Send us an email to to remind me, and I'll do it at work today @inbox

inbox
2018-11-26 21:16
Thank you!

bethskurrie
2018-11-26 22:09
Done.

fraser.crichton.devel
2018-11-27 03:53
Am back in NZ. Hope you are enjoying the States - might try and get you a trip over this side of the Tasman :wink:

matt.fellows
2018-11-27 06:36
I?m keen! NZ is beautiful

matt.fellows
2018-11-27 06:36
Can we go in winter? :slightly_smiling_face:

shkutov.max
2018-11-27 16:39
has joined #general

fraser.crichton.devel
2018-11-27 20:10
We might be able to get you back in winter :wink:

christian.draeger1
2018-11-27 20:50
has joined #general

rahul.neotech
2018-11-27 21:01
has joined #general

zach.the.hammer
2018-11-27 21:14
has joined #general

zach.the.hammer
2018-11-27 21:24
are python pact people using pact-python or pactman? i'm just starting to play around with pact testing and since pactman supports the v3 spec i'd prefer to use that!

bethskurrie
2018-11-27 21:39
Pactman has v3 support, but pact-python has better broker integration. Depends which is more important to you.

zach.the.hammer
2018-11-27 21:53
anywhere i can read about the better broker integration?

zach.the.hammer
2018-11-27 22:06
to be more clear: is there a breakdown of differences between pactman and pact-python written anywhere?

james.carman
2018-11-27 22:27
Working on automation around pacts and CI/CD. In particular, we are writing Java services. I?m trying to figure out how folks typically rerun pact verification for an already released version of a service?

james.carman
2018-11-27 22:29
I would have previously verified the pacts that existed at release time. Now, suppose a new consumer comes along.

james.carman
2018-11-27 22:29
The pact verification is part of the ?normal build? or do we have a special job that we run dedicated solely to pact verification?

kristine.jetzke
2018-11-27 22:33
We usually have a dedicated job that is triggered by pact webhooks. I actually wrote a blog post about this a couple of weeks ago: https://link.medium.com/T9fZ1bhhcS

james.carman
2018-11-27 22:39
Fantastic! Right now we are using the hosted version, so the web hook won?t be able to reach our Jenkins box. But this is great info

bethskurrie
2018-11-27 22:41
Just make sure the separate job is also triggered by a commit to the provider, as part of your normal pipeline too.

james.carman
2018-11-27 22:43
Do folks typically run verification against an in-process, stubbed-out (the downstream dependencies) instance of the service?

james.carman
2018-11-27 22:43
Or a deployed version?

james.carman
2018-11-27 22:44
I like the idea of the isolation

rahul.neotech
2018-11-28 00:16
Hi :wave: I?m new to using pact and encountering a problem at the moment. Has anyone here used protobufs with pact ruby?

kristine.jetzke
2018-11-28 06:59
We mostly run verification against stubbed-out instances. But for some legacy applications we use the real ones.

stevejbartholomew
2018-11-28 12:22
Hi, I'm new to PACT and Javascript and am trying to run the https://github.com/DiUS/pact-workshop-js (successfully) but trying to switch out certain parameters to test for simple String equivalence (unsuccessfully) and I'm not clear where I'm going wrong

james.carman
2018-11-28 12:34
Are there any good examples of this pattern of running the verify test in isolation?

stevejbartholomew
2018-11-28 12:35
this maybe more to do with novice skills at using Mocha

james.carman
2018-11-28 12:35
By itself I mean

stevejbartholomew
2018-11-28 12:35
but....if anyone's willing to help, I can share code, would be most appreciated

stevejbartholomew
2018-11-28 12:41
specifically, my issue is in issuing the npm run test:pact:consumer command

stevejbartholomew
2018-11-28 12:41
and receiving the error:

stevejbartholomew
2018-11-28 13:09
pls ignore above - i'd overlooked a stack overflow question to which matt has kindly responded

kristine.jetzke
2018-11-28 14:23
I think it depends on your stack. We mostly use spring boot so it?s pretty straightforward with spring boot integration tests.

james.carman
2018-11-28 14:37
That?s what we use. Just trying to see how you set the test up to run by itself. Is it a separate project or is it ?in tree? with the rest of your code.

james.carman
2018-11-28 14:37
I know how to write the test itself

james.carman
2018-11-28 14:38
Just interested in strategies used to isolate it to be run by itself from a git tag

james.carman
2018-11-28 14:38
I hope I?m making sense here.

kristine.jetzke
2018-11-28 15:01
We have it in the same tree as all other code. They are named *ContractIT and we have added a maven profile to run only those

james.carman
2018-11-28 15:01
ok, that?s what I figured. Didn?t know if there was some other maven magic you were using :slightly_smiling_face:

james.carman
2018-11-28 15:02
Thank you so much for your insights, @kristine.jetzke

james.carman
2018-11-28 15:02
are you specifically running that exact test or just running only the failsafe plugin in the other profile?

kristine.jetzke
2018-11-28 15:10
We only run tests that match the *ContractIT pattern (using failsafe). We try to skip as many other steps as possible e.g. we exclude unit tests.

james.carman
2018-11-28 15:12
fantastic. I like it. Care to share your profile configs? :slightly_smiling_face:

james.carman
2018-11-28 15:12
I?m sure I can figure it out, but if you have it handy and it?s something you can share

kristine.jetzke
2018-11-28 15:15
I left the client where I implemented this last Friday so I don?t have access to the production code anymore. I have a small example with the profile: https://github.com/tinexw/cdc-with-pact/blob/master/user-service/pom.xml#L48

kristine.jetzke
2018-11-28 15:15
However, it does not include the surefire exclusion but that should be easily found.


james.carman
2018-11-28 15:16
so, exclude *all* from surefire and include only ContractTestIT in failsafe

james.carman
2018-11-28 15:16
this one looks like you?re only including ContractTest.java in surefire

kristine.jetzke
2018-11-28 15:16
Yes, that?s how we implemented it.

james.carman
2018-11-28 15:17
running them as unit tests, which is fine also

james.carman
2018-11-28 15:17
I don?t really need failsafe

kristine.jetzke
2018-11-28 15:17
Yes, that works too

james.carman
2018-11-28 15:17
Totally fine. I like it

james.carman
2018-11-28 15:17
Thank you again!

james.carman
2018-11-28 15:17
this is pretty slick!

kristine.jetzke
2018-11-28 15:17
good luck :slightly_smiling_face:

james.carman
2018-11-28 15:18
Yeah, now the trick is figuring out how to populate ?the matrix? properly with the right environment tags and what not, but this blog post seems to have that nailed down

james.carman
2018-11-28 15:18
I will soon achieve ?pact nirvana? :slightly_smiling_face:

james.carman
2018-11-28 15:18
I want to beef up my presentation to include this part.

kristine.jetzke
2018-11-28 15:18
Ah sorry. So yes, the example is only using surefire. In the production code we implemented it using failsafe and in the contract tests excluded all unit tests and all integration tests *except* the ContractIT ones.

james.carman
2018-11-28 15:19
I gave a talk going over the general stuff, but this is a really cool extension to that talk

james.carman
2018-11-28 15:19
I think Surefire is just fine.

kristine.jetzke
2018-11-28 15:19
Yeah, and the interesting part :wink:

james.carman
2018-11-28 15:19
exactly!

james.carman
2018-11-28 15:28
I don?t see any reference to it anywhere, but I figured I?d ask. Is the pact broker CLI available via homebrew?

james.carman
2018-11-28 15:28
I did a ```brew search pact``` and only found ?impactor?

matt.fellows
2018-11-28 17:33
@james.carman It?s not, but it?s something we?ve talked about

matt.fellows
2018-11-28 17:33
It would be an obvious thing to do :slightly_smiling_face:

matt.fellows
2018-11-28 17:33
Also Chocolatey/Nuget/whatever it is these days for Windows :slightly_smiling_face:

shirley.ong1
2018-11-28 18:30
has joined #general

bethskurrie
2018-11-28 21:34
When I looked at homebrew, one of the criteria was that the tool wasn't available via another means of installation, so I thought we might be excluded. Also, it had to be submitted by someone who wasn't the maintainer.

bethskurrie
2018-11-28 21:35
This was years ago though.

james.carman
2018-11-28 21:46
oh wow. I guess with the stuff happening with npm it might make sense to have rules like that

richard.jones
2018-11-28 22:08
I would dispute the ?better broker integration? since pactman verifier can be just pointed at a broker with a provider name to pull in all the metadata from the broker for that provider :slightly_smiling_face:

richard.jones
2018-11-28 22:08
Or rather, I?d like to know where pactman is seen to fall short in broker integration :slightly_smiling_face:

bethskurrie
2018-11-28 22:09
Oh, my bad. I didn't think it did this yet.

bethskurrie
2018-11-28 22:09
Does it also publish verifications?

richard.jones
2018-11-28 22:10
Yep!

bethskurrie
2018-11-28 22:10
And verification results from the tests?

richard.jones
2018-11-28 22:11
I?m not sure what that means. Which tests?

bethskurrie
2018-11-28 22:11
The result of each individual test.

bethskurrie
2018-11-28 22:12
That's relatively new to the ruby impl, so you may not have realised it was there.

richard.jones
2018-11-28 22:12
Sorry, which tests? The tests using the mocks?

bethskurrie
2018-11-28 22:12
Sounds like you can ignore my analysis though, zhammer.

richard.jones
2018-11-28 22:12
Ahh. I?ll look up that ruby feature?s documentation.

bethskurrie
2018-11-28 22:13
We're still trying to work out a format for it.

bethskurrie
2018-11-28 22:13
There's an issue somewhere.

bethskurrie
2018-11-28 22:13
At the moment, it can be any arbitrary JSON in the testResults key.

richard.jones
2018-11-28 22:14
I?m still confused about which tests are generating these results. It?s the tests using the pact mocks? So the results of those tests are sent to the pact broker to register against the consumer?

bethskurrie
2018-11-28 22:16
The results of each interaction verification.

bethskurrie
2018-11-28 22:16
They get included in the verification results going back to the broker.

bethskurrie
2018-11-28 22:16
Whether it passed or failed, and the diff.

richard.jones
2018-11-28 22:17
ahhh! righto. that sounds useful, yes! When the format is nailed down more I?ll definitely want to support it :slightly_smiling_face:

bethskurrie
2018-11-28 22:18
I'll find you the issue with the current format, but it doesn't support v2.

bethskurrie
2018-11-28 22:18
If you're interested in coming up with a format that supports v3, even better!

richard.jones
2018-11-28 22:19
\o/

zach.the.hammer
2018-11-28 22:20
@richard.jones are you a / the maintainer of pactman? i'm really interested in experimenting w/ pact testing on some personal projects and will probably use pactman

richard.jones
2018-11-28 22:20
I?m a maintainer, yes. Primary author, but we have a few folks helping maintain it now.

zach.the.hammer
2018-11-28 22:21
would be happy to contribute also if things go well! right now i'm mostly concerned about not having an in-python pact provider verifier like in the ruby package: https://github.com/pact-foundation/pact-ruby/wiki/Provider-states#provider-codebase

richard.jones
2018-11-28 22:23
@zach.the.hammer pactman is the tool we (ReeceTech) use for pact verification, yes. I?m migrating us over to using the mocking in pactman also (no more firing off a separate process to do test mocking!), though the pact-python to pactman migration for our large-ish codebase is tricky due to API conflicts which I?m sorting through.

zach.the.hammer
2018-11-28 22:23
i'm used to testing in `pytest` or `behave` where i can setup fixtures in python within the testing framework. doing this via an additional endpoint seems like a major headache / perhaps not even possible (in a reasonbly non time-consuming way) for things like mocking calls to external services

richard.jones
2018-11-28 22:24
@zach.the.hammer yep, that?s our toolset also

richard.jones
2018-11-28 22:24
and also the same reasoning why I started the pactman project

richard.jones
2018-11-28 22:25
let?s take this convo over to the #pact-python channel tho rather than gum up #general :slightly_smiling_face:

bethskurrie
2018-11-28 22:26
:+1:

zach.the.hammer
2018-11-28 22:27
haha sounds good! at least we were just gumming up this thread

matt.fellows
2018-11-28 22:50
We should create own tap, which doesn?t have these requirements/restrictions

matt.fellows
2018-11-28 22:51
It?s basically a git repository that you run `brew tap ...` on and then can run the install

christian.hope
2018-11-28 23:05
has joined #general

cosmin.mogos
2018-11-29 10:52
has joined #general

cosmin.mogos
2018-11-29 11:49
Hi, I have a question regarding initial PACT sharing. If my understanding is correct the PACT file is generated after the consumer tests successfully run. What mechanism can be used to share PACT files before the consumer tests can be implemented. i.e share the contract before the consumer implements requred functionality, so the discussion can be started with the producer team? more detailed JVM related question https://pact-foundation.slack.com/archives/C9UN99H24/p1543329108034800

ruben.perezg
2018-11-29 14:53
has joined #general

james.carman
2018-11-29 16:55
It seems that the general approach to supporting ?environments? in the pactbroker is to use tags to do so, applying tags like ?prod? to a particular pact file. Am I understanding that correctly?

matt.fellows
2018-11-29 17:04
Yep, that?s the defacto approch!

james.carman
2018-11-29 17:08
Okay, cool. So, we tag it as ?prod? only after a successful deployment to the production environment?

james.carman
2018-11-29 17:08
and perhaps tag it as ?provisional? or something as we?re running it through its paces?

james.carman
2018-11-29 17:09
asking for the production version of the provider verify itself against our ?provisional? tag?

james.carman
2018-11-29 17:09
I really hope this makes sense :slightly_smiling_face:

matt.fellows
2018-11-29 17:31
yep

matt.fellows
2018-11-29 17:33
I normally go with `dev` for what?s currently pushed to master, and `prod` once it is released to prod

matt.fellows
2018-11-29 17:34
and then for branches, you could do a few different things. There are a few posts on the wiki e.g. https://github.com/pact-foundation/pact_broker/wiki/Using-tags

james.carman
2018-11-29 17:37
as far as keeping track of ?what version is in prod? for providers, that would be up to the specific organization to determine how to best do that?

james.carman
2018-11-29 17:38
I suppose that part is really supported (no matter how it?s done) using the webhooks out of the pactbroker.

james.carman
2018-11-29 17:39
meaning, you would tie a webhook to the ?go verify the prod version of service ?foo? against this new consumer pact that just got published?

matt.fellows
2018-11-29 17:40
Probably, yes

matt.fellows
2018-11-29 17:40
But the broker does have a mechanism to query what version of what is where (assuming you tag etc.)

matt.fellows
2018-11-29 17:40
This article might be worth reading too - the effective pact setup guide: https://docs.pact.io/best_practices/pact_nirvana

james.carman
2018-11-29 17:40
if the provider doesn?t have any pacts, then it can?t really be ?tagged?, right?

matt.fellows
2018-11-29 17:40
You can query the broker like this `pact-broker describe-version --pacticipant PACTICIPANT --latest prod` to retrieve the version of the broker tagged `prod`

james.carman
2018-11-29 17:40
or, can we tag a verification also?

james.carman
2018-11-29 17:41
I mean a provider that doesn?t call anyone else

james.carman
2018-11-29 17:41
it wouldn?t be able to be tagged because it didn?t publish any pacts to the broker

matt.fellows
2018-11-29 17:41
exactly

matt.fellows
2018-11-29 17:41
BUT

matt.fellows
2018-11-29 17:42
When a provider performs a verification against a pact, it publishes its version. So when you query a pact by tag, you can retrieve the _latest_ provider that verified it

matt.fellows
2018-11-29 17:42
the command above does this

james.carman
2018-11-29 17:43
yep, but if the production version of the provider has not yet verified this pact (it?s a brand new consumer maybe), then we have no data

james.carman
2018-11-29 17:43
I really hate to be such a bother with all these ?what ifs? questions, man

james.carman
2018-11-29 17:43
I?m just trying to wrap my head around how to fully instrument this stuff

james.carman
2018-11-29 17:44
I am trying to ?RTFM? as much as I can :slightly_smiling_face:

matt.fellows
2018-11-29 17:44
no don?t be sorry, if the manual has it I?ll point to it, if not it maybe needs to be addressed

matt.fellows
2018-11-29 17:45
I don?t think I?m up with the latest on how to deal with the chicken-and-egg problem of new contracts, I?m currently in the states for work. @bethskurrie is on the bleeding edge for that one

james.carman
2018-11-29 17:45
I think we have a gap (at least at my org) where we need to somehow maintain this state of ?what version is deployed in which environment?

james.carman
2018-11-29 17:46
luckily, spring boot provides a nice handy ```/actuator/info``` endpoint which includes our versions, so we can go get it without having to maintain the state in a database I suppose

james.carman
2018-11-29 17:47
loves Spring Boot actuator


zach.the.hammer
2018-11-29 18:12

rahul.neotech
2018-11-29 18:51
Hi :wave: I?m using pact-ruby to write a contract test for our consumer and provider service. Our services communicate via protos and the protos are encoded when sent over the wire. When the protos are encoded, they contain certain characters that are not JSON serializable (pact throws; an error I received looks like this - "\xC8" from ASCII-8BIT to UTF-8). I was able to overcome this by Base64 encoding the request and response - in the pact gem - before it is JSON serialized in the consumer - and then Base64 decoding it in the provider before it is used for verification. I?m wondering if there?s a better solution for what I?m doing. Can someone help?

rahul.neotech
2018-11-29 19:25
cc @beth


rahul.neotech
2018-11-29 23:12
@bethskurrie

bethskurrie
2018-11-29 23:14
Hm. I don't think there is a way to transfer non UTF-8 characters on JSON is there?

bethskurrie
2018-11-29 23:15
Sounds like you're trying to do something that is not possible in JSON, and the pact problem is just a side effect.

bethskurrie
2018-11-29 23:18
Perhaps JSON is not the best transfer format for your situation.

rahul.neotech
2018-11-29 23:49
There might be a way

rahul.neotech
2018-11-29 23:50
Suppose my example string is this `test_string = "\x05\x10\x00\x18\xC8\x068\x04@\x00J\x0ETestAccount"`

rahul.neotech
2018-11-29 23:50
If I try to call `.to_json` on it, it throws with the error message "malformed UTF-8"

bethskurrie
2018-11-29 23:51
You can use other content types than JSON, however, you will lose the ability to use matchers.

rahul.neotech
2018-11-29 23:51
I looked up the following: https://stackoverflow.com/questions/4867883/convert-non-ascii-chars-from-ascii-8bit-to-utf-8 and tried `test_string.force_encoding('UTF-8').to_json` and even that threw an error

bethskurrie
2018-11-29 23:52
I feel that you have a Ruby/API problem first, before you have a pact problem.

rahul.neotech
2018-11-29 23:52
But then I found this: https://stackoverflow.com/questions/18067203/ruby-to-json-issue-with-error-illegal-malformed-utf-8 and tried `test_string.force_encoding("ISO-8859-1").encode("UTF-8").to_json` and it worked

bethskurrie
2018-11-29 23:52
I think you're going to lose information by force encoding the string.

bethskurrie
2018-11-29 23:52
I don't think that's what you want.

rahul.neotech
2018-11-29 23:53
I see... actually its not just the encoding that worked

rahul.neotech
2018-11-29 23:54
I took the encoded protobuf as the `test_string`, ran that above command `force_encoding("ISO-8859-1").encode("UTF-8")` to get an `output_string`, and used the `output_string` to reconstruct the proto

rahul.neotech
2018-11-29 23:54
And it worked as well

rahul.neotech
2018-11-29 23:54
So maybe it works no? :neutral_face:

bethskurrie
2018-11-29 23:55
I don't understand enough about encoding to be able to give you a reliable answer, I'm sorry.

rahul.neotech
2018-11-29 23:56
Okay, no worries, thanks a lot for taking time out to reply to my questions :slightly_smiling_face:

rahul.neotech
2018-11-29 23:59
Oh BTW, what are the other formats I can use instead of JSON even if I lose the ability to use matchers? Is there a link I can look at to learn this?

bethskurrie
2018-11-30 00:12
XML is almost finished, but we lost momentum. Any other format just does plain text matching, but it may not handle non-utf8 chars.

bethskurrie
2018-11-30 00:12
I have a feeling there's a force encode somewhere

bethskurrie
2018-11-30 00:15
If you're comfortable in ruby, you can implement your own matcher for your own format quite easily.


rahul.neotech
2018-11-30 00:22
I was thinking along the same lines :slightly_smiling_face: ... on implementing a custom matcher for the protobufs. I'll take it from here. Thanks a lot for replying to my messages. You were super helpful :100::+1:

bethskurrie
2018-11-30 00:40
no problem

zach.the.hammer
2018-11-30 01:46
@bethskurrie is this the endpoint for publishing pact verification results?

matt.fellows
2018-11-30 01:49
That would be super cool

matt.fellows
2018-11-30 01:49
The question about gRPC and protobufs comes up a lot

matt.fellows
2018-11-30 01:49
I?d love for you to tell us why you think Pact does (or does not) solve a problem for you. We?ll then update our docs accordingly

zach.the.hammer
2018-11-30 02:05
i don?t see how to tag the provider verification

bethskurrie
2018-11-30 02:11
Yes.

bethskurrie
2018-11-30 02:11
You tag a pacticipant version, not a result.

zach.the.hammer
2018-11-30 02:12
> To reach Pact Nirvana, the final step is to have a CI build that checks out the code for the production version of your provider, and have it verify the same pacts that the head version does. If you have followed the recommended strategy of tagging provider versions in the broker on deployment to production, you can use the broker to determine which version of the provider is currently in production. Make sure that the provider application version used when publishing your verification can be reverse engineered to a git reference.

zach.the.hammer
2018-11-30 02:12
>>> To reach Pact Nirvana, the final step is to have a CI build that checks out the code for the production version of your provider, and have it verify the same pacts that the head version does. If you have followed the recommended strategy of tagging provider versions in the broker on deployment to production, you can use the broker to determine which version of the provider is currently in production. Make sure that the provider application version used when publishing your verification can be reverse engineered to a git reference.

zach.the.hammer
2018-11-30 02:12
this confuses me a bit

zach.the.hammer
2018-11-30 02:13
is this ?provider prod? tag done separately via > create-version-tag

zach.the.hammer
2018-11-30 03:42
Agh okay so I have been reading the pact nirvana and pact versioning docs over and over and there is still one thing I can?t understand: https://docs.pact.io/best_practices/pact_nirvana#5-allow-contracts-to-change-without-breaking-your-builds As far as I can tell the recommended workflow is: 1) We have a Consumer and a Provider with some existing pact. 2) Consumer and Provider teams talk. They decide they want a feature for Consumer to be able to get the information about an Alligator from Provider team if the Alligator exists. 3) Consumer service makes a feature branch: `feature-fetch-alligator` 4) Consumer writes a pact in their consumer tests to ?mock? out the desired interaction with the Provider. The pact, in pseudo, looks something like: ``` provider: Provider consumer: Consumer given an alligator named mary exists GET /alligator?name=Mary will respond with status 200 body like { id: 1, name: ?Mary? } ``` 5) Pushing `feature-fetch-alligator` branch to origin triggers the CI feature branch build, which publishes the pact file to the broker with the consumer version {git sha} and the tag feature-fetch-alligator. **Here?s where I?m confused** Assuming an identical pact hasn?t been published and verified by the provider previously, the consumer build fails, as the pact isn?t verified. The provider CI build **doesnt** verify this pact since it?s not tagged `master`. Instead, the provider team locally tests against the `feature-fetch-alligator` pact in their own `feature-provide-alligator` branch in the Provider repo. The feature is built out, and the pact passed locally! `feature-provide-alligator` is merged to master. *what happens now?!?!?!* the tag for the new consumer contract still isn?t `master`! So the Provider still won?t verify the `feature-fetch-alligator`-tagged pact. The Pact *is* supported by the Provider, but it is not verified. Consumer CI never passes, and the branch is never merged. Essentially: provider won?t verify until pact is tagged as master. Consumer can?t merge to / tag as master until provider verifies. What am i missing?

bethskurrie
2018-11-30 03:43
> **Here?s where I?m confused**

bethskurrie
2018-11-30 03:43
You are very observant.

bethskurrie
2018-11-30 03:43
What you're missing is that I have a feature that I have been working on that I haven't fully released and documented.

zach.the.hammer
2018-11-30 03:43
Ah!!!!!!

zach.the.hammer
2018-11-30 03:43
Wow my brain feels a lot better now

bethskurrie
2018-11-30 03:44
I got blocked because I couldn't decide what to call it, and then I started renovations on my house.

bethskurrie
2018-11-30 03:44
Normally, the provider team would just do a manual verification of that new tag - again, because they've talked.

bethskurrie
2018-11-30 03:45
With the new feature, (which may be called WIP pacts or may be called pending pacts) the new pact would be pulled in at the next verification, but *it would not fail the build*.

bethskurrie
2018-11-30 03:45
That way the consumer gets the feedback they need, and the provider doesn't have to change any code.

bethskurrie
2018-11-30 03:45
And their build doesn't break.

zach.the.hammer
2018-11-30 03:45
^ thats what i was thinking!!


bethskurrie
2018-11-30 03:46
Here's my work in progress post about work in progress pacts.

zach.the.hammer
2018-11-30 03:47
Awesome

zach.the.hammer
2018-11-30 03:48
I will let my brain relax a bit and then read this

bethskurrie
2018-11-30 03:49
yeah, it does your head in after a while

bethskurrie
2018-11-30 03:49
even me, and I came up with it!

zach.the.hammer
2018-11-30 03:49
Wait that page is 404ing

bethskurrie
2018-11-30 03:49
Hm, probably beacuse I haven't published it. Let me see if there's a pre-publish link

zach.the.hammer
2018-11-30 03:50
Hah i thought perhaps it was a very meta joke


zach.the.hammer
2018-11-30 03:51
Alright I will read this in a bit. I?ll let you know if any names come to mind for wipacts

bethskurrie
2018-11-30 03:51
Also, if you have a preference for wip/pending, then please let me know! I'm leaning towards "pending" at the moment. Naming things == hard.

zach.the.hammer
2018-11-30 03:51
^ lol i think we?re on the same page

matt.fellows
2018-11-30 05:34
This is what I was referring to this morning :slightly_smiling_face:

dan
2018-11-30 15:51
has joined #general

dan
2018-11-30 16:14
Hello everyone! I'm running the Pact broker with custom authentication. Can `pact-provider-verifier` be configured to use custom headers? I could only find basic http auth in the docs.

matt.fellows
2018-11-30 16:42
It does, run the `help` flag

matt.fellows
2018-11-30 16:42
Or if you could elaborate on what you need in code

popo63301
2018-12-01 16:47
has joined #general

popo63301
2018-12-01 16:58
Hi! Does it work well with GraphQL?


bing.sun
2018-12-02 09:24
has joined #general

zach.the.hammer
2018-12-02 14:52
Is there a tool to check the syntax of a pact file? Specifically for support while working on a pact implementation. Something like `pact-json-validator --spec 3.0.0 --file my_pact_files/Test.pact.json`

bethskurrie
2018-12-02 20:32
There's a JSON schema Somewhere.

bethskurrie
2018-12-02 20:33
Personally, I don't recommend reimplementing the pact matching logic.

bethskurrie
2018-12-02 20:33
Ron has a rust implementation that should allow other languages to call via ffi bindings.

bethskurrie
2018-12-02 20:34
The plan is to move all the languages that are currently using the ruby standalone to use that

bethskurrie
2018-12-02 20:34
Trying to keep multiple implementations in line with each other is quite hard, and slow to roll out new features.

zach.the.hammer
2018-12-02 21:36
Some of this is just building out the implementation to explore pact mechanics

zach.the.hammer
2018-12-02 21:38
I think i saw that rust implementation when looking for v3 implementations

ashish.dubey91
2018-12-03 10:25
hey guys, the public free pact broker has been returning many 5XXs lately. anything wrong there?

bethskurrie
2018-12-03 10:28
We've just moved to some new infrastructure, and we're still ironing out the no downtime deployments.

bethskurrie
2018-12-03 10:28
We hope to have it sorted soon.

ashish.dubey91
2018-12-03 10:28
okay. thanks

gabe
2018-12-03 13:34
has joined #general

gabe
2018-12-03 14:06
Hi there, I'm using the Python Pact library. When sending binary files in the a request payload, I seem to always get back a `"Error ocurred in mock service: Encoding::UndefinedConversionError - \"\\xFF\" from ASCII-8BIT to UTF-8"` error. This does not happen if the payload is a dictionary. Has anyone else ran into this?

gabe
2018-12-03 14:11
Is perhaps the library trying to coerce payloads to strings?

sai.krishna
2018-12-03 14:33
has joined #general

mcon
2018-12-03 17:43
has joined #general

mcon
2018-12-03 22:22
Hi pact folks, I've written a short RFC on the idea of adding protobuf support for pact - it would be great to get people's thoughts on it: in terms of whether such a feature is likely to be accepted, and whether the approach seems reasonable. Thanks, Matt https://github.com/pact-foundation/pact-specification/issues/62

madhukar.mishra
2018-12-04 05:46
ignore if this if of no value: Implementation wise you just use pact to generate stubbed responses which you test your app against, it doesn't add too much complexity in code besides having to define your contract in the dsl of your platform

madhukar.mishra
2018-12-04 05:56
we have the same scenario, we have gone with the 2nd option. So yeah, we've sort of chained contracts.

madhukar.mishra
2018-12-04 06:04
Hi, we're quite close to figuring out how pact will work end to end for all our services. We're now hooking up CIs together with webhooks as prescribed in the docs. I'm having trouble looking at webhook status, they aren't showing up in the webhook status column on the broker homepage, even when they've been triggered. Using the latest image for the broker. *Note*: I'm using global webhooks, (provider, consumer not specified).

madhukar.mishra
2018-12-04 06:05
~I have checked if the webhook actually got triggered.~

bethskurrie
2018-12-04 07:38
Can you raise an issue in the pact broker github repo with the exact steps to reproduce.

bethskurrie
2018-12-04 07:38
Have a look at the logs. It may be a display issue.

madhukar.mishra
2018-12-04 07:43
Will do Beth, thanks. I have a suspicion it's got something to do with global hooks. I'll open the issue as when I have more details.


madhukar.mishra
2018-12-04 07:49
I have enabled `DEBUG` logging but can't seem to get anything useful out of ``` docker-compose logs | grep -i webhook ```

madhukar.mishra
2018-12-04 07:52
This is what broker's section looks like in the compose config ``` broker_app: image: dius/pact-broker links: - postgres # If you remove nginx, enable the following #ports: # - "80:80" environment: PACT_BROKER_DATABASE_USERNAME: postgres PACT_BROKER_DATABASE_PASSWORD: password PACT_BROKER_DATABASE_HOST: postgres PACT_BROKER_DATABASE_NAME: postgres PACT_BROKER_WEBHOOK_SCHEME_WHITELIST: http https PACT_BROKER_WEBHOOK_HOST_WHITELIST: /.*/ PACT_BROKER_LOG_LEVEL: DEBUG ```

madhukar.mishra
2018-12-04 07:53
Not sure if I'm looking in the wrong places.. is there a way to get execution statuses from the API without knowing the execution ID?

madhukar.mishra
2018-12-04 07:59
app logs are in `/var/log/nginx/error.log` in the `broker_app` container only :grinning:

bethskurrie
2018-12-04 08:06
Yes.

bethskurrie
2018-12-04 08:06
Go to the HAL browser

bethskurrie
2018-12-04 08:06
There's a relation that shows you the web hook statues.

madhukar.mishra
2018-12-04 08:08
oh, embarrassing, I must have missed it.

bethskurrie
2018-12-04 08:11
Hm. I beg your pardon.

bethskurrie
2018-12-04 08:12
So, there is a known bug where the global webhooks dont show up in the UI status page.

bethskurrie
2018-12-04 08:12
It would give you a link if it did.

bethskurrie
2018-12-04 08:13
/pacts/provider/PROVIDER/consumer/CONSUMER/webhooks/status

bethskurrie
2018-12-04 08:13
Go to the API browser, and create the link as per that template.

bethskurrie
2018-12-04 08:13
You'll see a list of triggered webhooks, or error logs.

madhukar.mishra
2018-12-04 08:14
^ having touble navigating to this in the browser*

madhukar.mishra
2018-12-04 08:14
sure, thanks

bethskurrie
2018-12-04 08:14
Click on the API browser link

bethskurrie
2018-12-04 08:14
Top right

madhukar.mishra
2018-12-04 08:14
sure, I got it

madhukar.mishra
2018-12-04 08:14
I've been using the HAL browser a lot

madhukar.mishra
2018-12-04 08:16
Thanks again Beth

bethskurrie
2018-12-04 08:16
I'll try and fix that display bug.

bethskurrie
2018-12-04 08:16
That would have made it easier to find the logs.

madhukar.mishra
2018-12-04 08:23
We could help fix the docker setup to log properly if you like. Looking for low hanging fruit to contribute :smile:

bethskurrie
2018-12-04 08:25
I didn't realise it was broken!

bethskurrie
2018-12-04 08:25
But please, do!

bethskurrie
2018-12-04 08:26
App logs should come out in the stout of the docker container. Do they not?

madhukar.mishra
2018-12-04 08:28
Nope


bethskurrie
2018-12-04 08:29
That's... Unusual.

madhukar.mishra
2018-12-04 08:33
getting them out with `docker-compose exec broker_app tail -f /var/log/nginx/error.log`

bethskurrie
2018-12-04 08:34
Please do submit a PR! I'm wondering how it hasn't been picked up yet.

bethskurrie
2018-12-04 08:34
Does it happen when running the docker container without docker compose?

bethskurrie
2018-12-04 08:37
Typically, people just run the docker image in prod. Docker compose is just for messing around with locally.

madhukar.mishra
2018-12-04 08:40
Will try it out and let you know.

bethskurrie
2018-12-04 08:40
Many thanks :-)

james.carman
2018-12-04 15:12
When I run pact_broker locally (using the pact_broker-docker) I get the warning: ``` A security update is available for your version (5.1.11) of Passenger, we strongly recommend upgrading to version 5.3.5. ```

james.carman
2018-12-04 15:35
There seems to be a rather long pause in my verify test after the Spring Boot application is started: ``` 2018-12-04 10:34:14.315 INFO [-,,,] 55404 --- [ main] com.myco.VerifyPactTest : Started VerifyPactTest in 10.281 seconds (JVM running for 11.861) Verifying a pact between sample-hello-client and hello Say Hello 2018-12-04 10:34:25.429 INFO [-,825962565f72090b,825962565f72090b,true] 55404 --- [o-auto-1-exec-1] c.m.provider.RequestLogFilter : BEGIN POST /api/hello ````

james.carman
2018-12-04 15:36
11 seconds pause

james.carman
2018-12-04 15:36
here?s what my test looks like: ``` @RunWith(SpringRestPactRunner.class) @Provider("hello") @IgnoreNoPactsToVerify @PactBroker @EnableAutoConfiguration @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = HelloConfig.class) public class VerifyPactTest { @TestTarget public final Target target = new SpringBootHttpTarget(); } ```

james.carman
2018-12-04 15:56
I think the pause is us downloading the pacts from the broker.

james.carman
2018-12-04 16:01
When I run against the local, Dockerised pact_broker the pause is much shorter

james.carman
2018-12-04 16:02
When I run against the one set up at http://dius.com.au it?s taking much longer. I don?t know that it needs to be terribly fast, but is there any option to speed that up?

james.carman
2018-12-04 16:03
This may not be the proper forum for questions like that. Sorry

andrew.nicholson
2018-12-04 16:24
Does the pact-spec support rules about nested arrays? I.e. if I want to express in my contract that a field is an array of arrays, where both the inner & outer arrays have at least 1 element?

james.carman
2018-12-04 16:37
if you?re using the Java DSL: ``` newJsonBody(o -> o.array("myarray", array-> { array.array(nested-> { }) }) ```

james.carman
2018-12-04 16:37
you can do stuff like that

james.carman
2018-12-04 16:37
so, I would assume it?s allowed

andrew.nicholson
2018-12-04 16:44
hmm...maybe I should try the java8 dsl - I'm using the junit4 dsl, and while I can declare bodies that have nested arrays, I don't seem to be able to declare an outer array minlength 1 combined with declaring that the inner arrays are also minimum length one...

andrew.nicholson
2018-12-04 16:45
also from https://github.com/pact-foundation/pact-specification/tree/version-3#matcher-path-expressions-in-bodies, item 5 is `A star (*) can be used to match all keys of a map or all items of an array (one level only).` -- which makes me think that maybe a matcher matching items in all nested arrays isn't supported by the spec?

james.carman
2018-12-04 16:46
There are some methods like minArrayLike and minMaxArrayLike that makes me think there has to be some sort of ?at least one? or whatever you?re looking for.

james.carman
2018-12-04 16:46
I have not used them, but it?d be interesting to see what they spit out in a pact file when run

james.carman
2018-12-04 16:52
when I added this: ``` .array("array", array -> { array.minArrayLike(1, nested -> { nested.stringType("foo", "bar"); }); })) ```

james.carman
2018-12-04 16:52
I see this in the pact file: ``` "$.array[0]": { "matchers": [ { "match": "type", "min": 1 } ], "combine": "AND" }, "$.array[0][*].foo": { "matchers": [ { "match": "type" } ], "combine": "AND" } ```

james.carman
2018-12-04 16:54
odd syntax, but I suppose it works :slightly_smiling_face: I?ve not tried to upload it to the broker

andrew.nicholson
2018-12-04 16:55
Yeah - I can generate that with the junit one - and that works. What I'm then trying to do is also say that the nested array(s) are an array of strings, minimum length one

james.carman
2018-12-04 16:56
so, instead of it thinking you?re creating an ?object? for each value in the array, you want it to be an array of strings

andrew.nicholson
2018-12-04 16:58
That's a hurdle, as is declaring minimum length rules on both the inner and outer arrays

james.carman
2018-12-04 16:58
gotcha

james.carman
2018-12-04 16:58
I think you?ve already outrun my n00b status :slightly_smiling_face:

james.carman
2018-12-04 16:58
sorry I couldn?t be of more help

andrew.nicholson
2018-12-04 16:58
it could be that I'm veering too far away from 'example-based contracts', and trying to describe a too-generic shape of data

andrew.nicholson
2018-12-04 16:58
nah, it's useful to talk through it -- appreciated the suggestions!

andrew.nicholson
2018-12-04 16:59
plus I'm now trying out the java8 dsl and it's awesome

james.carman
2018-12-04 16:59
I don?t think it?s unreasonable to be able to describe the shape like this, though

james.carman
2018-12-04 16:59
Yeah, I like the java8 dsl

james.carman
2018-12-04 16:59
much more straightforward

yousafn
2018-12-04 19:00
has joined #general

hagglundized
2018-12-04 23:13
has joined #general

borsuk.artem034
2018-12-05 08:30
Hi all, someone know progress about that issue https://github.com/pact-foundation/pact-mock_service/issues/82, or possible workaround how I can get pact file from pact broker to pact-mock_service?

madhukar.mishra
2018-12-05 08:38
for now you can just download the pacts yourself and run pact_stub_server to consume them and provide stubs to dev/test against

madhukar.mishra
2018-12-05 08:40
we do that for running some API tests, and other stuff as well. Let me know if you need details.

matt.fellows
2018-12-05 10:53
You can use the API in the broker to query the pact and easily download them. Should take all of 15 minutes to write a bash script that gets the pact file and starts the stub service with it

borsuk.artem034
2018-12-05 13:45
thanks for answers, you are really help me

matt.fellows
2018-12-05 19:06
:+1:

tim
2018-12-05 20:20
has joined #general

uma.shanker
2018-12-06 07:33
Hey Guys, Facing an issues while implementing pact contract testing using springboot and kotlin , Here is code example I have written but it's not wokring. please help. @Rule var provider: PactProviderRuleMk2 = PactProviderRuleMk2("test_provider", PactDemoApplicationTests()) @RunWith(SpringRunner::class) @SpringBootTest class PactDemoApplicationTests { @Pact(consumer = "test_consumer") fun createFragment(builder: PactDslWithProvider): RequestResponsePact { val headers = HashMap<String, String>() headers["Content-Type"] = "application/json" return builder .given("test state") .uponReceiving("ExampleJavaConsumerPactRuleTest test interaction") .path("/dummies") .method("GET") .willRespondWith() .status(200) .headers(headers) .body("[{" + "\"id\": \"39b2374e-863e-449c-9d7d-b130d5cde957\"," + "\"value\" : \"this is the judge that kept the cat that milked the rooster that tossed the rooster all forlorn that lay in the house that Jack built and this is the house that Jack built\"," + "\"id\": \"dc95d89a-8452-4958-9b84-c20e9108db00\"," + "\"value\" : \"this is the rooster that kept the man that crowed in the morn that married the house that Jack built and this is the cheese all forlorn that waked the farmer that married the judge that married the house that Jack built\"," + "\"id\": \"9a18b039-7408-4c6b-a1f7-7dfffdb5ca98\"," + "\"value\" : \"this is the cat that milked the house that Jack built and this is the maiden all forlorn that kept the house that Jack built\"," + "\"id\": \"e556c8b9-4063-4913-88e2-019ee184aca6\"," + "\"value\" : \"this is the farmer that married the cat that lay in the judge all forlorn that married the house that Jack built and this is the judge with the crumpled horn that chased the house that Jack built\"," + "}]") .toPact() } @Test @PactVerification() fun doTest() { System.setProperty("pact.rootDir","../pacts") val productRestFetcher = DummyEventRestFetcher() productRestFetcher.setBackEndUrl(provider.url) val dummies = productRestFetcher.fetchDummyEvents() Assert.assertNotNull(dummies) print("All dummies: $dummies") }

uma.shanker
2018-12-06 07:34
Saying provider.url not be nill

uma.shanker
2018-12-06 07:34
java.lang.IllegalStateException: provider.url must not be null

matt.fellows
2018-12-06 07:36
Is it nil?

uma.shanker
2018-12-06 07:37
Yes Matt.

uma.shanker
2018-12-06 07:39
Actually I have placed @Rule at the top of the class(outside class definition), When I was placed it inside the PactDemoApplicationTests class it was complaining "Rule must be public"

kristine.jetzke
2018-12-06 08:02
place it inside and make it public.

uma.shanker
2018-12-06 08:41
Thanks Tine. After placing inside class saying org.junit.internal.runners.rules.ValidationError: The @Rule 'provider' must be public.

uma.shanker
2018-12-06 08:42
I think I have to code in Java only Any suggestions?

kristine.jetzke
2018-12-06 08:49
Can?t you make it public? (sorry, I don?t know kotlin, just Java)

uma.shanker
2018-12-06 08:54
Thanks Tine, I was able to run successfully tests are passing now but pact file is not generated

kristine.jetzke
2018-12-06 09:18
Can you remove the `System.setProperty("pact.rootDir","../pacts")` line and check in the default location?

kristine.jetzke
2018-12-06 09:19
target/pacts (or build/pacts if you use Gradle)

uma.shanker
2018-12-06 09:37
yeah got it. thanks after path change it is working. thanks Tine for the help.

kristine.jetzke
2018-12-06 09:38
:slightly_smiling_face:

bethskurrie
2018-12-06 09:39
Just give it the URL @madhukar.mishra

matt.fellows
2018-12-06 09:40
It works now?

bethskurrie
2018-12-06 09:40
Try putting the credentials in the URL.

matt.fellows
2018-12-06 09:40
Ah yeah.

dagarwal
2018-12-06 10:29
Hi All , My api path is : api/test/{id1}/content/{id2}/content . I have added the matchers like this : path: term({ generate: ?/api/test/8061159/content/115578/content?, matcher: ?/api/test/[0-9]+/content/[0-9]+/content? }) When i run the provider verification , it fails with an error as {Id2} does not exist . any idea , how to achieve the same ?

matt.fellows
2018-12-06 19:50
What have you tried so far? Provider states?

sthan
2018-12-06 21:06
has joined #general

sk8390
2018-12-07 09:23
has joined #general

sk8390
2018-12-07 09:25
Hi All,

sk8390
2018-12-07 09:33
I want to verify only few objects inside a Json object and ignore few... for example in a big json structure... {"name":"Senthil", "Details":[{ "address":"{ <IGNORE Details> }",}, {"Salary" : "<Some Integer>"}, "{"Job_Details":["{"JobCode":"<Integer>"},{"Job Desc":"<IGNORE>"},{<IGNORE>}"}]"}"],"{<IGNORE>}"}.... during pact:verify its excatly matching all elements in json and my verfication fails... hence I need to verify only Salary and Job_code and can ignore rest in the JSON... Could you please help me in this?

matt.fellows
2018-12-07 11:17
Simple - don?t include the fields you don?t care about in the consumer test, and they won?t be checked in Provider verification. Also, you probably want to use ?matchers? so that the specific values don?t matter

zach.the.hammer
2018-12-07 22:09
Are pact descriptions between a consumer and provider unique? For example can I have the pacts: ?consumerService?, ?providerService? given ?there are no alligators? upon receiving `'a request for an alligator'` should return a 404 ?consumerService?, ?providerService? given ?there are alligators? upon receiving `'a request for an alligator'` <-- same description string should return a 200

zach.the.hammer
2018-12-07 22:09
?upon receiving? being the description

mboudreau
2018-12-08 00:34
If I remember correctly, every test is unique, so the two requests can be the same or different. It depends on how you coded it. If you're using the same code for that request, they'll be the same

nirpet111
2018-12-08 14:59
has joined #general

ittennull
2018-12-08 16:04
has joined #general

ittennull
2018-12-08 17:32
Hi so, what's your thoughts, plans and timeline on creating new .net core implementation of pact free of ruby stuff? I'm currently working on such a thing and wondering if I should continue

mboudreau
2018-12-09 00:20
it's a valid question. I don't have much visibility on the .net implementation as it's not my area of work, maybe ask in the #pact-net channel.

abubics
2018-12-10 00:48
I guess this would be somewhat assisted/subsumed by the Rust migration, too

mboudreau
2018-12-10 01:08
definitely

s.umair.riaz
2018-12-10 04:37
has joined #general

samuel.verstraete
2018-12-10 08:32
has joined #general

athalytra
2018-12-10 10:59
has joined #general

athalytra
2018-12-10 11:09
Hello to all, just a simple general question: I know that PACT is best to be executed during CI phase and 'can-i-deploy' feature can give the green light to CD phase. But, what is your opinion about exercising PACT tests on an already deployed environment?

ashish.dubey91
2018-12-10 11:30
for some reason from my ubuntu machine I can `dig http://foo.pact.dius.com.au` just fine but when I do `curl http://foo.pact.dius.com.au` I get `Could not resolve host: http://foo.pact.dius.com.au`

ashish.dubey91
2018-12-10 11:30
any DNS changes happened recently?

abubics
2018-12-10 12:49
The second-best time to add tests is now? :upside_down_face:

athalytra
2018-12-10 13:39
Let me provide some details: I'm referring to a test env that is deployed daily. I was thinking to use Contract testing in this stage. Then we can use 'can-i-deploy' feature to give green light to deploy our Staging env...

pcohen
2018-12-10 21:32
has joined #general

abubics
2018-12-10 22:43
That kinda depends on your deploy workflow, but there's nothing stopping you at each promotion.

abubics
2018-12-10 22:44
I wouldn't even deploy to test if contract tests fail, though.

matt.fellows
2018-12-11 04:25
Just created #protobufs if anyone is keen to see how we might make Pact + Protobufs play nicely together. Thanks to @rahul.neotech who has been thinking / spiking on this recently!

madhukar.mishra
2018-12-11 05:41
the issue is just with compose. Haven't had time to see what's wrong yet.

anushree.shenoy
2018-12-11 05:52
has joined #general

saso.madaric
2018-12-11 08:40
has joined #general

joaquin.delgado
2018-12-11 11:52
has joined #general

james.carman
2018-12-11 14:16
So, if one were to want to create a new ```@TestTarget``` implementation, how would one go about that? Are there any docs anywhere?

victor.akinyemi
2018-12-11 15:40
has joined #general

james.carman
2018-12-11 17:29
What is the best practice with respect to running pact tests in Java with Maven? Should we make them integration tests or unit tests?

james.carman
2018-12-11 17:29
Surefire or Failsafe?

james.carman
2018-12-11 17:29
They?ll run fine either way, but is one way considered more ?proper? than the other?

matt.fellows
2018-12-11 19:21
It?s hard to say exactly where they always fit on the pyramid, but generally speaking I group them logically with the ?integration tests? code, even if they are more of a unit test in nature.

matt.fellows
2018-12-11 19:28
There is some commentary on the docs site e.g. https://docs.pact.io/best_practices/consumer#use-pact-for-isolated-unit-tests, but that might not be exactly what you were wanting

james.carman
2018-12-11 20:05
Also, with the hosted pact broker provided by the pact foundation, we get a read-only set of credentials and a read-write set. Within our organization, is there really any reason to ?protect? the read-only creds?

james.carman
2018-12-11 20:05
Meaning, would it be unreasonable to hard-code the configuration in our parent pom.xml file to contain these credentials?

james.carman
2018-12-11 20:08
obviously we wouldn?t want even the read-only stuff to leak out into the world, but if we keep it internal-only it might be okay

uglyog
2018-12-11 21:23
Have a look at the implementation for the HttpTestTarget.

matt.fellows
2018-12-12 01:27
In most organisations, I don?t see why all developers shouldn?t be able to have access to read-only creds. Whether you hard code them in config files is a separate thing :slightly_smiling_face:

felix.dai
2018-12-12 09:48
has joined #general

tghcastro
2018-12-12 12:41
has joined #general

dagarwal
2018-12-12 12:49
@matt.fellows: i have added data by post api call at provider level but it generates with different id everytime .So I am not sure how to get the id?s( of consumer level and provider level) to match

alessio.paciello
2018-12-12 15:25
has joined #general

matt.fellows
2018-12-12 20:49
Use matchers instead of hard coded values

sthan
2018-12-12 22:13
Hi. I?m pretty new to this group. Can someone tell me the best place to post questions about using PACT?

bethskurrie
2018-12-12 22:13
Here. But if your question is technology specific, it's best to ask in the appropriate channel.

sthan
2018-12-12 22:13
I posted a question on stackoverflow, but was wondering if there was a better place.


zach.the.hammer
2018-12-12 22:45
@sthan i would spend some time reading through the documentation on https://docs.pact.io/

bethskurrie
2018-12-12 22:46
Yes, you can use regular expressions. Look at the matchers documentation for pact-jvm.

zach.the.hammer
2018-12-12 22:51
@bethskurrie when i get the chance i'm going to share a little tool i've been using to handle 'wip' pacts

zach.the.hammer
2018-12-12 22:52
basically i have a script with a `--failon` arg where i can pass a set of pact tags to failon

zach.the.hammer
2018-12-12 22:52
and then in CI read from my PR. if there's a line `feature-pacts: zh-feature-a zh-feature-b` those will be added to failon

zach.the.hammer
2018-12-12 22:53
works pretty nicely to specify in a PR what feature tags a provider PR is implementing

bethskurrie
2018-12-12 22:53
sounds good!

raghavendra.chamarthy
2018-12-13 01:09
has joined #general

abubics
2018-12-13 05:43
SO is good, especially for external discoverability :slightly_smiling_face:

abubics
2018-12-13 05:44
In here might be better for more specific questions and help.

abubics
2018-12-13 05:44
And thanks for being very respectful, not just spamming all the channels on join :joy::ok_hand:

dagarwal
2018-12-13 09:57
is it possible to send matchers in api path ?

matt.fellows
2018-12-13 09:57
Yes

dagarwal
2018-12-13 09:59
i tried like this path: term({ generate: ?/api/test/8061159/?, matcher: ?/api/test/[0-9]+/? }),

dagarwal
2018-12-13 10:00
but when i run verification , it fails with error as 8061159 id does not exist .Their is no way i can generate the same id at provider level

matt.fellows
2018-12-13 10:21
The verification process on the provider side still needs a way of knowing how to make the call to the provider, and it uses the value of generate to do so. That id (or another of your choosing) must be present when this test happens. The way to indicate this to the provider is via provider states

dagarwal
2018-12-13 10:24
but that id will never be present

dagarwal
2018-12-13 10:25
as it is generated automatically in db :disappointed:

matt.fellows
2018-12-13 10:25
Can you reset/clear your DB during tests?

matt.fellows
2018-12-13 10:25
Eg. with docker

matt.fellows
2018-12-13 10:25
Or an in memory db

dagarwal
2018-12-13 10:25
yes i will run on jenkins and db will always start fresh

dagarwal
2018-12-13 10:26
but still the id?s are random . if it starts with 1 or so , i can implement easily

matt.fellows
2018-12-13 10:26
So then you should be able to seed the data in a deterministic way, and use a known id in that test

dagarwal
2018-12-13 10:27
thats the thing , id is not known :disappointed:

matt.fellows
2018-12-13 10:27
You can't seed the database with fake data and known IDs?

matt.fellows
2018-12-13 10:28
What kind of database are you using?

dagarwal
2018-12-13 10:28
provider devs are not agreeing to that

dagarwal
2018-12-13 10:28
arango db

dagarwal
2018-12-13 10:29
i will try to fake the data if possible .looks like thats the only solution

matt.fellows
2018-12-13 10:29
So I'm not sure I can help you, apart from to say that the only proper way is via provider states and known IDs

matt.fellows
2018-12-13 10:29
Fake the data?

dagarwal
2018-12-13 10:29
i mean inserting into db

matt.fellows
2018-12-13 10:29
Ah

matt.fellows
2018-12-13 10:30
I don't see why for an automated unit test this is a problem for you provide team. But fundamentally the issue is collaboration and getting them on board

dagarwal
2018-12-13 10:31
Agreed

dagarwal
2018-12-13 10:31
Thanks , i will try the same

matt.fellows
2018-12-13 11:17
:thumbsup:

matt.fellows
2018-12-13 11:17
the hardest part isn?t software - it?s people :0

dagarwal
2018-12-13 11:18
ha ha true, cant agree more .thats what I am facing these days :stuck_out_tongue:

matt.fellows
2018-12-13 11:23
:smile:

rworcest
2018-12-14 01:04
has joined #general

zach.the.hammer
2018-12-16 15:41
i?ve moved my (small personal) project fully to microservices with pact testing! https://github.com/zhammer/morning-cd @bethskurrie: can you share a public repo that uses pact broker badges? i tried to add badges to my readmes but all the badge titles were `pact: `. i couldn?t get custom titles like `front/users pact:`, etc.

andrew.leith
2018-12-16 21:22
has joined #general

coredump
2018-12-17 01:25
has joined #general

ola.jankowska
2018-12-17 10:49
has joined #general

erik.moller
2018-12-17 15:19
has joined #general

davegallant
2018-12-17 17:03
has joined #general

japedersen
2018-12-17 19:03
has joined #general

japedersen
2018-12-17 19:08
Hi, (apologies if this questions has already been answered.) can a service have both consumer and provider tests?

zach.the.hammer
2018-12-17 19:36
yep

yousafn
2018-12-17 19:47
Have looked for a specific channel for the pact-stub-server but haven?t found one. Have raised an issue https://github.com/pact-foundation/pact-stub-server/issues/11 and also added an example repo for my predicament. Hope someone can help!

matt.fellows
2018-12-17 19:51
Absolutely!

kevin.cormier
2018-12-17 20:18
Hi All. I'm wondering if anyone here is using https://pact.dius.com.au/

kevin.cormier
2018-12-17 20:19
We're debating between running our own and using this service and would love to know if people have had any positive or negative experiences with them.

abubics
2018-12-18 00:10
(they have completely isolated lifecycles, however :P)

abubics
2018-12-18 00:11
many people are, and several people aren't

abubics
2018-12-18 00:12
it depends how much you want to look after your own infrastructure & deployment . . . and how that balances against data privacy & SaaS simplicity

ola.jankowska
2018-12-18 11:27
hi i have question, I am using pact broker in the cloud http://pact.dius.com.au where I succesfuly can publish new consumer tests, I also can verify them using java spring boot provider test, and my resutls are generated to json format in target/pact folder, but I still do not know how can I send the results back to broker.

richard.hulm
2018-12-18 11:45
@kevin.cormier We use it quite a lot - we have a few hosted brokers. We do experience occasional errors (lately they've been doing a migration; so had some oddities that should be fixed as a result of moving to more stable infrastructure) But on the whole it's great not having to maintain it ourselves, and the team are always quick to respond which is very useful!

matt.fellows
2018-12-18 12:20
@ola.jankowska there should be a gradle/other property to set that enables publishing the results. What have you tried so far?

godsey.chris
2018-12-18 15:48
has joined #general

zach.the.hammer
2018-12-18 15:50
hey @bethskurrie just bumping on a public repo with several pact badges!

godsey.chris
2018-12-18 16:03
Are there any solutions in place for using my pacts to generate a mock server that i could, say, run a frontend service against in order to do functional testing of my frontend


godsey.chris
2018-12-18 16:20
oh, neat, awesome

godsey.chris
2018-12-18 16:20
thanks

kevin.cormier
2018-12-18 20:32
Thanks a ton for the feedback! We'll consider it!

iamjillsanluis
2018-12-19 04:08
has joined #general

kevin.cormier
2018-12-19 17:09
Hi Boris. Thanks for the info! I was hoping from the responses to get a sense of just how big dius was to help inform those decisions. It sounds like a promising solution for our proof of concept.

abubics
2018-12-20 00:03
For a PoC, I'd just use the SaaS one :slightly_smiling_face: it's not hard to set up a private one (there are docker images, etc), but that's waste if you choose not to continue with Pact :slightly_smiling_face:

abubics
2018-12-20 00:03
I'd also go and ask in #pact-broker for more targeted help

elliot.sel
2018-12-20 22:37
has joined #general

marek.rybakiewicz
2018-12-27 16:16
has joined #general

yousafn
2018-12-28 16:29
Hey, Has there been any more thought on below :- https://docs.pact.io/getting_started/stubs ``` Description: Start a stub service with the given pact file(s). Where multiple matching interactions are found, the interactions will be sorted by response status, and the first one will be returned. This may lead to some non-deterministic behaviour. If you are having problems with this, please raise it on the pact-dev google group, and we can discuss some potential enhancements. Note that only versions 1 and 2 of the pact specification are currently supported. ``` Non-deterministic behaviour is really not good is consumers are using these api stubs to develop against. Pact stub server will just yolo the first response back to the client,, client may assume their request is good, but actually it is garbage (may have no request body, or no headers) This is a real blocker to use being able to implement pact alongside swagger with validation tooling. Currently we are 1) Defining our services in swagger 2) Using swagger-cli to validate that the swagger spec 3) Building pact tests and generating the contracts 4) Using swagger-mock-validator to validate the contracts against the swagger spec 5) Using the pact stub server to run our component integration tests in lieu of a provider In order to avoid deterministic matching, we have put a fall-through route to provide a bad request response if the user enters garbage, however this fails swagger mock validation, and will have further implications at provider verification time

yousafn
2018-12-28 16:31
Also where is the pact-dev google group to get my question raised on there, if that has better traction

guidopio.mariotti10_d
2018-12-29 23:43
has joined #general

uglyog
2018-12-30 22:36
@yousafn this is the best channel for pact discussions. As to the warning about non-determinism it is to make sure that people who are using stubs are aware for the cons of using this strategy. If it is a problem for you, don't use them. Some people will be ok with this if it allows them to get up and running quickly.

uglyog
2018-12-30 22:39
The problem with using validating mock servers is that the requests generally have to be correct, even in the smallest detail, otherwise you get an error response.

bitsapien
2018-12-31 06:08
has joined #general

bitsapien
2018-12-31 06:12
Hey folks! New to PACT, quick question. I'm using `pact-jvm-consumer-junit5` to generate a bunch of pact files. The `pactSpecification` version defaults to `3.0.0`. Is there a way I can set it to v2 ?

tjones
2018-12-31 06:15
I believe it's a parameter to `@PactTestFor`

tjones
2018-12-31 06:17
Try `@PactTestFor( pactVersion = PactSpecVersion.V2 /*...etc */)`

tjones
2018-12-31 06:23
Unless I'm missing something, this workflow seems like it's not consumer driven

tjones
2018-12-31 06:25
As Pact is a consumer-driven testing tool, I think you'll be in for a bad time if you're trying to use mock services to drive consumer development - but I might have radically misunderstood what you're trying to do.

tjones
2018-12-31 06:26
Do your pact files describe your whole API, or just the bits that a particular consumer is expecting?

bitsapien
2018-12-31 06:37
Thanks, that worked.

tjones
2018-12-31 06:37
You're welcome! Happy new year!

bitsapien
2018-12-31 06:37
Happy New Year to you too !!

aruna.muthyala
2018-12-31 06:48
has joined #general

aruna.muthyala
2018-12-31 06:55
Aruna [12:23 PM] HI, I created a clientPactTest class with a mock server with some interactions to my webservice component through stubs, created json file, published it, but got stuck at the Verfication part in the ProciderService. Please answer my queries, regarding the ProviderService for verification: 1) Right now iam running my webservice at command line at localhost port 8080. Then I created a ProviderService with a Pact mentioning the provider url and hostname as localhost and port 8080. So that all my tests hit the webservice which I started at command line. Is this the right approach? 2) Iam a bit confused as at many websites its mentioned that we dont run the actual service for pacts verification and we should create a mock server. So if I create a mock server, do i have re write all the endpoints in my providerservice file, the way it is mentioned in the actual webservice ?

matt.fellows
2018-12-31 10:10
Hi Arun, apologies for the delay. I've answered your SO question

serikch
2018-12-31 14:20
has joined #general

jim.frantzen
2018-12-31 16:15
has joined #general

shekharsp27
2019-01-02 06:10
Hi Aruna, I had a look at your comment on SO question. However, I think you are clubbing more than two services in one pact test. In your case, you have a scenario like (A -> B -> C), so service A will call service B and service B has to make a call to service C to fulfill a request from service A. So in this case you need to stub service C and need to call this service while verifying contract.

shekharsp27
2019-01-02 06:11
Also as you said you are planning to start provider and web service on same port 8080 which is not possible on the same machine. And while verifying contract pact framework will not start provider service automatically

yousafn
2019-01-02 10:42
Hi gents, thanks for the replies. I am not trying to test the whole of the API as a consumer (the provider will take care of functionally testing their API), we have a limited set of consumer expectation tests, and we are running a pact stub server off the back of the generated pact contracts. We noted that with the pact stub server, if we served it specific invalid requests, it would return decide on a match to return, rather than serving a 404. Therefore if in component integration testing, our consumer sends a POST request without a body or without a header, we get served a valid provider response, which gives us a false positive, as the consumer wont fail in component integration but will as we perform e2e. I am on the consumer side, our provider isn?t ready yet and wont be for a while. We have agreed swagger definitions, so have been able to draft up pact contracts to describe our use of the API, and using swagger mock validator tool to ensure that our pact aligns with swagger

yousafn
2019-01-02 10:42
Thanks again for all the work :thumbsup:

yousafn
2019-01-02 23:25
Had some more time to look into this today, I noted there is a pact ruby standalone gem called `pact-mock_service` which contains the bin `pact-stub-service`. I switched over to this implementation and it appears to behave in a more predictable manner as per wiremock, where unmapped routes / requests return a 500 error and a message which shows clearly that this is not a pact contract error response. The issue is was having with `pact-stub-server` (which is the rust implementation) is when sending requests without a json body, or with no content-type header set, it would return the closest match on the end point. The above behaviour may be intended, but wasn't suitable for my needs, it was going to fork it but the ruby `pact-stub-service` solves that issue, and also addresses my other issue raised on your repo @uglyog regarding logging. I am happy to close both if required.


uglyog
2019-01-03 02:54
Great that you found a solution, as the behaviour of the `pact-stub-server` is by design. The pact mock servers are generally strict, so the stub server was created to be more lenient.

aruna.muthyala
2019-01-03 06:34
Hi Shekhar, Let me explain my scenario again. Iam having only one service, which is a Webservice. a) In the ConsumerPact.spec.ts, I created a Pact mock server with some interactions for the above Webservice. And created the pact.json file. b) In PublishPact.ts I published the pact.json file. c) In ProviderPact.ts, I created a Pact object with the location of my pact.json file(broker url) and base_url and port. Its localhost and 8080. And then I verify the pact object with the above options. d) Before I run ProviderPact.ts, I start my webservice manually at commandline at localhost & port 8080. Then I run ProviderPact.ts so it points to my webservice at localhost 8080. My intension is to run the actual websservice so my tests are always in sink with the changes in the webservice. Is this approach right?

surajit.mandal
2019-01-03 07:00
has joined #general

mehdizonjy
2019-01-03 08:40
has joined #general

dagarwal
2019-01-03 12:40
Hello guys , how do you fail the consumer jenkins build when ?can-i-deploy? gives the result as verification failed ? I am adding can i deploy command in the consumer codebase as js file and executing it when build is run

hacosta
2019-01-03 12:58
has joined #general

jdesouza
2019-01-03 12:58
has joined #general

dglaubman
2019-01-03 22:21
has joined #general

mboudreau
2019-01-03 22:26
How is it run? Normally the build would fail if anything but error code 0 is returned

shekharsp27
2019-01-04 05:27
:+1:

dagarwal
2019-01-04 10:19
I am adding can i deploy as a shell command in deploy.js file .When jenkins build is run , that file is executed as node deploy.js

dira.thea
2019-01-05 06:22
has joined #general

thomas.scheuchzer
2019-01-05 10:06
has joined #general

ilya.markevich1991
2019-01-05 16:54
has joined #general

ilya.markevich1991
2019-01-05 17:06
Hi guys. Is there any way to pass some additional info to providerStatesSetupUrl? For now I get only state (which is a string), but I want to pass an object that will be used as provider initial state.

mboudreau
2019-01-05 23:20
Not at this current moment. The idea is that the state string is like a unique identifier between the consumer and the provider. As such, the provider should have its own data for that unique string to setup state.

mboudreau
2019-01-05 23:22
I will agree that this isn't the best experience at the moment and we have talked about potential fixes in the product to be able to attach data to the contract or simply have a better way to manage it on the provider side

ilya.markevich1991
2019-01-06 07:19
Thank you! Yep, I think that would be great to have the feature. It simplifies tests setup a lot

ilya.markevich1991
2019-01-06 07:24
By the way, could you please share available links (maybe github issues or smth else) with discussions about the feature?

mboudreau
2019-01-06 22:23
it was mostly done in person or within the maintainers channel. There's nothing concrete, more of an acknowledgment of the issue

matt.fellows
2019-01-07 00:04
Not sure if this would help your specific situation, but we?re exploring ways to make this a bit richer. See https://github.com/pact-foundation/pact-js/blob/spike/proxy-system/examples/e2e/test/provider.spec.js


lmoore
2019-01-07 04:09
has joined #general

ilya.markevich1991
2019-01-07 10:02
Thank you guys for all your help. Matt, the improvements are really good but doesn?t help me share pre-setup info between consumer and provider. It?s not a big problem for me at the moment, just wanted to know maybe there are some ways to do it. But thank you anyway :slightly_smiling_face:

ilya.markevich1991
2019-01-07 10:06
What I think about is to add field to interaction on consumer side (?providerSetupInfo? for example) and pass the field in ?state? on provider setup.

martin.green
2019-01-07 13:42
has joined #general

ola.jankowska
2019-01-07 14:13
hi, i figured it out, works perfect thanks

charles.prynn
2019-01-07 15:47
has joined #general

cdaly
2019-01-07 18:55
has joined #general

matt.fellows
2019-01-07 20:00
Yes, this is part if the v3 spec but it's not yet supported. We're still working on making that available across the board

matt.fellows
2019-01-07 20:00
:+1:

simon.nizov
2019-01-09 10:14
Hey guys, quick question, should I push the automatically created pact json file to the git repository?

ravbaker
2019-01-09 11:11
no. You shouldn?t. Rather to your pact broker storage.

ravbaker
2019-01-09 11:11
to share it with the provider.

simon.nizov
2019-01-09 16:37
Great, thanks!

mtauraso
2019-01-09 18:26
has joined #general

pravera
2019-01-09 18:30
has joined #general

lauzongrenier.jeremy
2019-01-09 20:26
has joined #general

lauzongrenier.jeremy
2019-01-09 20:44
Hello, I am new to pact and I am very happy I found this gem ! Is it still good practice to set the consumer version to be the commit ID, considering my team is not currently in a continuous deployment cycle, but rather a continuous delivery cycle, and there can be hundreds of commits before tagging the right one to deploy in production environment, say every three weeks or so ? Wouldn't that pollute the pact broker history with useless versioning ? Many thanks ! :smile:

matt.fellows
2019-01-09 21:45
Yep, the broker will handle this just fine. You'll find that over time, most commits aren't changing the actual contract and the broker is smart enough to detect this and manage it effectively

bright.huang
2019-01-10 08:27
has joined #general

pravera
2019-01-10 12:24
Hi guys! Has anyone implemented pact in Travis CI?

jonas.natten
2019-01-10 12:33
I'm doing that in a project

lucas.beier
2019-01-10 12:36
has joined #general

tiago.ferrazmartins
2019-01-10 14:20
has joined #general

tiago.ferrazmartins
2019-01-10 14:25
hi! I have one question. I'm trying to write a match for a array, it can be empty or have at max 5 chars. I cannot use term because it is parsed to array, I cannot use eachlike because the array can be empty and I havent be able to use any other matcher. To ilustrate better, the array can be [], or ['W'] till ['W','W,'W','W','W'].

tiago.ferrazmartins
2019-01-10 14:26
Have anyone dealed with this before?

pravera
2019-01-10 16:54
maybe you need 2 interactions? one for the empty array and another for the max 5 chars?

pravera
2019-01-10 16:55
i'm not sure if it's the best solution

pravera
2019-01-10 16:55
cool! are you following the steps of pact nirvana?

pravera
2019-01-10 18:08
how is that going?

mboudreau
2019-01-10 22:22
that's the correct method. Think each pact interaction like it's own unit test; it's testing one part of the interaction with the provider

abubics
2019-01-10 22:37
If the number of elements in the array is significant, you should have a test for each different state. If it's insignificant, then `eachLike` should be fine :slightly_smiling_face:

leslie.fung.lf
2019-01-11 08:57
has joined #general

tiago.ferrazmartins
2019-01-11 09:42
I have restrictions with this idea. Because matchers increase the flexibility and thus allowing the provider to return different data and still have a valid test.

tiago.ferrazmartins
2019-01-11 09:43
And this solution just takes out all the flexibility I gain with matchers

matt.fellows
2019-01-11 10:28
Did you read the article as to why we recommend this approach?

mboudreau
2019-01-11 11:05
@tiago.ferrazmartins and what are you trying to gain from having a test or an interaction that can provide a whole gamut of different responses? it's like having a unit test that will accept almost any returned result, it's not very useful at finding issues.

tiago.ferrazmartins
2019-01-11 11:08
it is not different from property based testing as long as the result is within the requisites

tiago.ferrazmartins
2019-01-11 11:09
and the function in test is called with a series of valid parameters

tiago.ferrazmartins
2019-01-11 11:13
eachLike does not allow 0, will fail when array is empty. Creating a test for each possible array will only create overhead and contribute little

tiago.ferrazmartins
2019-01-11 11:14
where I could have a matcher and test all possibilities over time and have the same guarantee

tiago.ferrazmartins
2019-01-11 11:14
or almost the same guarantee

mboudreau
2019-01-11 11:17
if you want to do that, sure, but I mean, why test for an array of 0, 1 or multiple? just do a test to make sure it's an array. The matcher is just arrayLike

tiago.ferrazmartins
2019-01-11 11:29
because it is a requirement for it to have maximum of 5 elements, I found this an important requirement to be verified

tiago.ferrazmartins
2019-01-11 11:33
also, the value of the elements is limited, so it also verifiable and part of the contract that just those values are used

tiago.ferrazmartins
2019-01-11 11:34
that's why I find testing only if it is an array is not enough

jonas.natten
2019-01-11 12:16
More or less following the pact nirvana guide. Currently only implemented for interactions between two of our compontents, but it seems to be working flawlessly after initial setup :slightly_smiling_face:

pravera
2019-01-11 19:56
That's great! We're looking forward to implementing it between two services, but still not sure about the steps to follow for our consumer and provider

gbivins4
2019-01-12 00:23
has joined #general

alex291
2019-01-12 15:54
has joined #general

alex291
2019-01-12 15:56
Hi everyone. First of all, thank you for this tool, it'll be awesome in our project. I have an issue I couldn't fix yet, it's about unnamed arrays. The contract I'm writing is like the following:

alex291
2019-01-12 15:56
```[ {object}, {object} ]```

alex291
2019-01-12 15:57
but it only let me create a named one like

alex291
2019-01-12 15:58
```"aName": [{object}, {object2} ]```

alex291
2019-01-12 15:59
I'm using testCompile("au.com.dius:pact-jvm-consumer-junit_2.12:3.6.1")

alex291
2019-01-12 16:00
Can anyone help me?

alex291
2019-01-12 16:00
Thank you :slightly_smiling_face:

mboudreau
2019-01-12 23:51
you mean, the top level json is an array and not an object, right?

mboudreau
2019-01-12 23:52
how are you creating the interaction?

abubics
2019-01-13 09:33
It sounds like you want an `eachLike` with a max of 5?

abubics
2019-01-13 09:33
What part of the system are you testing by checking lists with each different length?

abubics
2019-01-13 09:35
And how are you setting up the provider state?

mat.auburn
2019-01-13 13:51
has joined #general

rjmcguinness
2019-01-14 14:33
Does anyone have experience with automating the generation of consumer pact tests/boilerplate? Or at least streamlining, perhaps with a cli? My current process of copying an old test and replacing things to suit the new one is just a wee bit clunky

pravera
2019-01-14 18:30
When publishing from the CI im having the following error: Failed to publish pact due to error: PactBroker::Client::Error

pravera
2019-01-14 18:30
it's weird cause in the same build that happens for only one pact

pravera
2019-01-14 18:31
there's a pact for another provider that is correctly being published to the broker

pravera
2019-01-14 18:31
anyone has a clue?


matt.fellows
2019-01-14 20:20
that being said, I know of others using other strategies to generate the tests by linking them to _other types of tests_ so that they are still going to be relevant as your code changes

mboudreau
2019-01-14 23:11
@pravera What's the client error specifically? any http errors?

matthew
2019-01-15 06:13
So I upgraded a project from babel 6 to babel 7 and my E2E tests in Nightwatch that use Pacts as mocks no longer work. Any idea how to debug this? The trace from pact-js doesn't really show anything wrong, but every call to `addInteraction` results in a ECONNREFUSED

mboudreau
2019-01-15 06:18
if you revert, does it work again?


matthew
2019-01-15 06:32
but there's also a decent amount of changes when going from 6 to 7

matthew
2019-01-15 06:32
what's weird is that according to the logs it looks like the mock server is starting up


matthew
2019-01-15 06:33
``` [2019-01-15T06:09:01.915Z] INFO: pact-node@6.21.2/2315 on 73281f2e23a6: Creating Pact Server with options: consumer = sojournal-ui, cors = true, dir = /opt/pacts, host = 127.0.0.1, log = /opt/app/logs/pact.log, pactFileWriteMode = overwrite, port = 3001, provider = sojournal-api, spec = 2, ssl = false, sslcert = , sslkey = [2019-01-15T06:09:01.918Z] INFO: pact@7.2.0/2315 on 73281f2e23a6: Setting up Pact with Consumer "sojournal-ui" and Provider "sojournal-api" using mock service on Port: "3001" ```

matthew
2019-01-15 06:33
``` Unable to connect to "http://127.0.0.1:3001/interactions" Caused by: Error: connect ECONNREFUSED 127.0.0.1:3001 at Socket.socketErrorListener (_http_client.js:391:9) at emitErrorNT (internal/streams/destroy.js:82:8) at emitErrorAndCloseNT (internal/streams/destroy.js:50:3) at process._tickCallback (internal/process/next_tick.js:63:19) ```

mboudreau
2019-01-15 06:47
Weird. Do you think Babel is changing the pact js?

matthew
2019-01-15 06:49
my hunch is that something somewhere doesn't like babel 7 or something, but I'm not sure

matthew
2019-01-15 06:49
going to try to do some more diffing in the morning

matthew
2019-01-15 06:49
see if I can nail down exactly which package is breaking

mboudreau
2019-01-15 08:09
Thanks, that would be very helpful. I can't imagine what's causing it

matt.fellows
2019-01-15 08:51
thanks @matthew - hopefully we can get to the bottom of it

matt.fellows
2019-01-15 08:51
haven?t had that combination on a project just yet

rjmcguinness
2019-01-15 09:24
The strategy of linking to other types of tests is interesting to me, as currently have to change both pact tests and unit tests if a contract changes. Could you point me in the direction of an example of this? I have also just abstracted lots of boilerplate code from my pact tests into a helper class which saves on maintenance and adds readability. Even if I cannot link to unit tests, I?m happy with this for the time being.

pravera
2019-01-15 13:33
yes, i'm getting a 500 error @mboudreau

makhov.alex
2019-01-15 13:52
has joined #general

pravera
2019-01-15 16:38
but i'm not getting any description of the error

pravera
2019-01-15 16:38
just that

matthew
2019-01-15 17:02
Yeah too be fair it's a bit complex. Running everything in Docker as well, so an extra layer of wtf. What's interesting is that I reuse the same Pact setup and config and stuff for unit tests and that works, only when I'm setting up for e2e tests in nightwatch.

mary.oconnor
2019-01-15 17:20
has joined #general

pravera
2019-01-15 20:16
I have two pacts to publish but i'm having an error when publishing only one of them (only for a specific Consumer_A/Provider_A). The error is a PactBroker::Client::Error with 500 status code. When running the `bundle exec rake pact:publish`, it tags the version of the app and the branch name, publishes correctly for Consumer_A/Provider_B, and then fails when publishing the next pact. The publishing step shown before the error: `Publishing Consumer_A/Provider_A pact to pact broker at https://pact.URL.com` , and stops there. I tried: - Publishing locally - Changing the content of the pact to the same JSON than the last one published - Publishing only for Consumer_A/Provider_A and not Consumer_A/Provider_B

pravera
2019-01-15 20:38
So pact:publish triggers a PUT to the broker right? Is it possible to check this failing requests?

matt.fellows
2019-01-15 22:50
Hmm not that I can find, but I do recall it coming up in Slack/Github at some point - might be worth searching the channels for it sorry

matt.fellows
2019-01-15 22:51
The boilerplate reduction approach is pretty commmon. Probably so common that we could do something about it

matt.fellows
2019-01-15 22:51
suggestions welcome!

matthew
2019-01-16 03:09
So digging in deeper (trying to go about updating a single package at a time), when going from @pact-foundation/pact 5.9.1 to 7.2.0 I start getting: ``` Pact Binary Error: Could not load existing consumer contract from /opt/pacts/sojournal-ui-sojournal-api.json due to undefined method `gsub' for nil:NilClass. Creating a new file. ```

matthew
2019-01-16 03:09
goes away if I change the write mode from update to overwrite, but not sure if that's a symptom of something else

mboudreau
2019-01-16 04:26
weird

mboudreau
2019-01-16 04:28
@bethskurrie Any idea what this error means?

matt.fellows
2019-01-16 04:33
I have a feeling that `update` is no longer allowed, just `merge` (I know this is contrary to the docs).

matt.fellows
2019-01-16 04:34
The error above looks like some other problem wasn?t caught earlier (i.e. it made assumptions about things working) and failed later on in the piece. It looks like a fairly generic error

matthew
2019-01-16 04:58
I've also figured out that my initial problem wasn't babel, but something with nightwatch

matthew
2019-01-16 04:58
not sure how that's affecting it though

bethskurrie
2019-01-16 04:59
I'd need the full stacktrace

bethskurrie
2019-01-16 04:59
If you can't get that, then can you create a repository with instructions to replicate the issue.

shirishcin
2019-01-16 13:11
has joined #general

rjmcguinness
2019-01-16 16:37
No worries. If this boilerplate reduction proves useful and we are happy with it in our codebase I?ll at least open a pr for an example test helper (using angular/ts/karma/jasmine right now).

shirishcin
2019-01-16 16:51
i am just not able to get started with pact on java intellij

shirishcin
2019-01-16 16:51
is there a simple project which i can use ?

ots.indrek
2019-01-16 17:35
Question regarding `can-i-deploy`. When I do `pact-broker can-i-deploy --pacticipant my-pacticipant --version 5e471db --to prod ...`, the result is the following ``` Computer says no ¯\_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? ---------------|-----------|----------------|-----------|--------- service-a | 55c8086 | my-pacticipant | 5e471db | true service-b | 79f7707 | service-a | 55c8086 | true service-b | 79f7707 | my-pacticipant | 5e471db | true service-c | 380fd66 | my-pacticipant | 5e471db | true service-d | 2c5a9c7 | service-a | 55c8086 | true service-d | 2c5a9c7 | service-c | 380fd66 | true service-d | 2c5a9c7 | my-pacticipant | 5e471db | true service-e | 2a845ca | my-pacticipant | 5e471db | true service-f | 1d8bed8 | service-a | 55c8086 | false service-f | 1d8bed8 | my-pacticipant | 5e471db | true service-g | 70d633a | my-pacticipant | 5e471db | true my-pacticipant | 5e471db | service-a | 55c8086 | true One or more verifications have failed ``` From what I understand, `can-i-deploy` does not allow me to deploy `my-pacticipant` to `prod` because of `service-f | 1d8bed8 | service-a | 55c8086 | false`. I would have expected the output of `can-i-deploy` to only include consumer-provider pairs where `my-pacticipant` is either a consumer or a provider. Instead, I see that the output shows also `service-f` ->`service-a` and other pacticipants that are not related to `my-pacticipant`. Is this an expected behaviour? Perhaps I have fundamentally misunderstood something.

dparkes
2019-01-16 19:20
has joined #general

gopinathlangote11
2019-01-17 11:22
Well. I was also expecting not to see the other mappings than my participant


gopinathlangote11
2019-01-17 11:23
I am not pretty sure about ```-a, --pacticipant=PACTICIPANT # The pacticipant name. Use once for each pacticipant being checked.```

gopinathlangote11
2019-01-17 11:23
What does `Use once for each pacticipant being checked.` means

tomo
2019-01-17 11:34
has joined #general

alessio.paciello
2019-01-17 16:03
did anybody have to provide custom `Converter` to Spring `MockMvcTarget`?

pravera
2019-01-17 21:05
The solution was to restart the pact-broker server

matt.fellows
2019-01-18 02:58
that would be great!

karishnu
2019-01-18 05:28
has joined #general

galvinshane
2019-01-18 11:34
has joined #general

ashish.dubey91
2019-01-20 07:16
hey guys - is there a backlog of things which can be used for newbies to start contributing to pact tools? like `easy pickings` or `first time bugs` or something else

matt.fellows
2019-01-20 07:17
I use tags on pact js and go to indicate which ones are ready and good for New comers.

matt.fellows
2019-01-20 07:17
Can't remember the tag


matt.fellows
2019-01-20 07:31
That's more for general help


matt.fellows
2019-01-20 07:31
This is for more newcomers

ashish.dubey91
2019-01-20 07:31
great

matt.fellows
2019-01-20 07:32
I'm just making dinner, but glad for the reaching out. I'm sure we can do more/better - please let us know how

ashish.dubey91
2019-01-20 07:33
sure thing. since we've been playing with pact for a while, I wondered what are the ways for us to start contributing

chris
2019-01-21 14:36
has joined #general

rosemaryjarnold
2019-01-22 00:44
has joined #general

charles.prynn
2019-01-22 10:40
Hey - does anyone know of an example project using `pact-mock-service-docker` docker image? I can't quite work out how to use it if each instance should be for one consumer/provider and cleared before each test.

matt.fellows
2019-01-22 11:00
Yes it probably should

matt.fellows
2019-01-22 11:02
The provider and consumer are given to the service when started, so it's specific to a consumer/provider pair

charles.prynn
2019-01-22 11:44
@matt.fellows Thanks for the reply. Wonder what the use case is for the docker image.. I'll go back to the starting the instance via PHP.

uma.shanker
2019-01-22 12:21
PACT JVM for Message Queues : Can someone provide guide/reference/sample for simple consumer and provider test over kafka message queue?

ramakrishnan.nagaraja
2019-01-22 18:39
has joined #general

ramakrishnan.nagaraja
2019-01-22 18:44
Hi - just started exploring about using pact broker in .net. While trying to publish the pact to the hosted domain from http://pact.dius.com.au, I am getting "One or more errors occurred. (No such host is known). Socket exception" Any idea why it is? I am using the host as sent in the invite email from Pact. Any help is much appreciated.

ramakrishnan.nagaraja
2019-01-22 19:01
I got this No such host is known fixed. Now getting another error "Failed to publish Pact to the broker with http status NotFound: Not Found".

abubics
2019-01-23 02:50
:point_right: #pact-net

gyula
2019-01-23 12:18
has joined #general

bethskurrie
2019-01-24 04:23
yes.

rabih
2019-01-24 06:39
has any one worked with versioning pact with CI builds and github?

matt.fellows
2019-01-24 06:47
what?s your specific question/challenge?

rabih
2019-01-24 06:58
so on every commit, CI Build process will run. I want to know if it is possible to tag the consumer/provider version with a build number?

matt.fellows
2019-01-24 06:59
yes, of course you can. What problem are you having in doing so?

matt.fellows
2019-01-24 06:59
I would suggest as a start, reading https://github.com/pact-foundation/pact_broker/wiki/Pacticipant-version-numbers (and the other tag related docs there)

matt.fellows
2019-01-24 07:00
?and the effective pact setup guide: https://docs.pact.io/best_practices/pact_nirvana

rabih
2019-01-24 07:00
ok sure, Thank you

matt.fellows
2019-01-24 07:01
you?re welcome

inaki.varebeke
2019-01-24 12:06
has joined #general

jeanlouhallee
2019-01-24 13:45
has joined #general

ravbaker
2019-01-24 14:19
I would not recommend numbering with builds but with commit-sha

vivanov.vasily
2019-01-25 00:37
has joined #general

karishnu
2019-01-25 04:37
Is the Pact file generation and the mock server linked? The code examples imply that a Pact file can be generated only after a mock server is set up. However, why can't it be generated from the transactions alone?

matt.fellows
2019-01-25 04:58
In most of the languages, yes, they are linked

matt.fellows
2019-01-25 05:00
The reason is more to do with the ability to scale pact across languages (we re-use the validation/logic engine within the mock server instead of writing for each version of the specifiction for each language)

matt.fellows
2019-01-25 05:00
In Pact JVM this may noto be th ecase

karishnu
2019-01-25 05:08
So basically the code behind the mock server is responsible for Pact file generation too?

matt.fellows
2019-01-25 05:10
yes

matt.fellows
2019-01-25 05:11
It is more modular than that, but because each language binding has to ?cross the boundary?, as far as pact-js is concerned for example, that is the case

karishnu
2019-01-25 05:23
Thank you!

matt.fellows
2019-01-25 05:23
:thumbsup:

ravbaker
2019-01-25 06:32
Why? To be able later easily submit contract verification results back to Github or similar

norepeat17
2019-01-26 22:23
has joined #general

norepeat17
2019-01-26 22:41
Hi @everyone I have one question while using Pact. Is it right to implement the consumer-driven-test with Pact in the front-end under the situation that APIs are not developed yet?

matt.fellows
2019-01-26 22:49
Yep, that's one of the main use cases

norepeat17
2019-01-26 22:52
Thanks for your prompt reply. The cause that I have such this question is that I got this error while implementing tests with Pact.

matt.fellows
2019-01-26 22:58
Can you elaborate more on what you're currently doing? Obviously if you're trying to connect to the real service if it doesn't exist it won't work. Pact is almost always designed to work on localhost

norepeat17
2019-01-26 23:02
As I mentioned above, this service is not developed yet. But I need to implement the tests only with the format of the request and response. Ah, `Pact is almost always designed to work on localhost` This means I should mock the service on my local, right?

matt.fellows
2019-01-26 23:04
Yes, but that's what pact does. When you setup your tests, pact starts a mock service for you. You should configure your code during test to point at it instead of the real thing

norepeat17
2019-01-26 23:07
I see. Thank you. First, I will have some tests on my side And I will come back to you again.

norepeat17
2019-01-26 23:07
Thank you again!

matt.fellows
2019-01-26 23:10
:+1:

norepeat17
2019-01-26 23:24
Hi, I tried to test with mock service but I received `undefined` as a response.

norepeat17
2019-01-26 23:31
The response of the mock service is not a thing that I expect in the interaction.

matt.fellows
2019-01-26 23:40
Upon receiving is mandatory, also you should include the / in the expected path

matt.fellows
2019-01-26 23:40
Have you seen the examples?

norepeat17
2019-01-26 23:44
Thank you, I am now fixing and trying again.

nikolajs.cmihuns
2019-01-28 13:54
Hi, can some help to write in Java dsl the following json object `{"report": "entries": [], "color": "A"}`

nikolajs.cmihuns
2019-01-28 13:55
entries is array of integers which can have zero records

nikolajs.cmihuns
2019-01-28 14:47
did not write curly braces , so json object is - `"report": {"entries": [],"color": "A"},`

nikolajs.cmihuns
2019-01-28 16:52
entries_zero

nikolajs.cmihuns
2019-01-28 16:52
looks like there is no easy way of creating array of integers

thirumal.net
2019-01-28 18:42
~hi~

thirumal.net
2019-01-28 18:42
Hi All, i have specific question related to local development. When developer will run PACT test on local machine, consumer will publish local changes to pact broker. if many developers are working on the same client version in different branches simultaneously (19.0.0 for e.g.). Are there any possibility to understand that integration was broken by local development or by main release branch changes? * i am trying to understand what is the best way to pubslish the pact file to pact broker ? is it through main branch with CLI process or when ever code changes locally through specific branch?*

antonello
2019-01-28 18:55
@thirumal.net You would want to avoid publishing pacts when running the tests locally. There may be occasional circumstances in which you?d want to do that, but generally speaking it should only been done by your CI pipeline.

thirumal.net
2019-01-28 19:09
@antonello -Thank you for your reply. does that mean, developer knows only whether contract is broken or not once after running the CI pipeline ? i am just thinking what is the harm if we run pact test through locally with different branches since pact broker is smart enough to understand whether there is a change or not in pact file, if there is a change then only it will invoke/give signal to provider side , am i correct ?

james.carman
2019-01-28 19:55
If you upload a pact that?s bad from your local workstation, you could impact the provider?s build status. Also, you don?t have good traceability if you allow upload from a developer?s workstation.

james.carman
2019-01-28 19:55
I would stick with *only* the CI server doing the uploads as @antonello said, because it will be performing a repeatable, traceable build process.

matt.fellows
2019-01-28 21:32
@thirumal.net recommend you read this https://docs.pact.io/best_practices/pact_nirvana

sanyam.satia
2019-01-28 21:56
has joined #general

vicenzo
2019-01-28 22:03
has joined #general

nikolajs.cmihuns
2019-01-29 05:16
cc @uglyog @bethskurrie @matt.fellows

nikolajs.cmihuns
2019-01-29 08:33
if someone will encounter the same problem

nikolajs.cmihuns
2019-01-29 08:34
`.object("report", new PactDslJsonBody() .minArrayLike("entries", 0, PactDslJsonRootValue.integerType(), 0) .stringMatcher("color", "^[-ARG]{1}$", "R") )`

chodera.adam
2019-01-29 09:14
has joined #general

norepeat17
2019-01-29 09:19
Hi, I have some problems to publish pacts. So I've checked this https://github.com/pact-foundation/pact_broker In this example, pact broker is running based on ruby. Is it possible to run pact broker with node.js? If yes, there is any example to reference?

karishnu
2019-01-29 09:50
As far as I know the Pact broker is only written in Ruby and you cannot run it using Node. However, its very easy setting it up using the Docker image and requires little to no coding experience.

norepeat17
2019-01-29 09:52
Thank you @karishnu

norepeat17
2019-01-29 09:52
Could you please send me your samples so I can reference it?

karishnu
2019-01-29 09:54
Samples? This page describes the set up process - https://github.com/pact-foundation/pact_broker#rolling-your-own

norepeat17
2019-01-29 09:57
I decided to not use Docker. But now, I will try Docker and come back to you if I have some problems. Thank you.

matt.fellows
2019-01-29 10:51
hi Mazping, what problems are you actually having? (you alluded to problems, was it just related to hosting the Ruby bit?)

matt.fellows
2019-01-29 10:51
as an aside, we have a hosted version available at http://pact.dius.com.au if you want to reduce the amount of setup and management required to run it

matt.fellows
2019-01-29 10:52
If you need to see examples in node JS publishing to the broker, our repo has examples (see e2e) that demonstrate that feature

norepeat17
2019-01-29 10:59
Sorry for the delay in responding. Thanks a lot for your detailed explanation.

norepeat17
2019-01-29 11:00
I will try on my side and come back to you.

matt.fellows
2019-01-29 11:24
ah, nice one!

matt.fellows
2019-01-29 11:24
Sorry I?m not really across the JVM matching library - and without a heavy IDE it can be hard to see what fits into what in Java :smile:

nikolajs.cmihuns
2019-01-29 11:29
it's ok, missed somehow javadocs, here is the link


nikolajs.cmihuns
2019-01-29 11:30
thanks for the reply anyway :+1:

norepeat17
2019-01-29 14:46
@karishnu@matt.fellows Thanks for your support again. I've ran the pack broker with Docker. Now, I have one question. As you can see through screenshot, the pact verification result is not mentioned. I think it is because I skipped the verification step while implementing pact tests. So I'd like to just confirm the steps that I think for verification. 1. create pactverify.js as the second screenshot. 2. create npm script as `node ./pactverify.js` I should run this script before publish, right?

norepeat17
2019-01-29 15:33
If I think something is wrong, verifying pacts should be done on the provider side?

matt.fellows
2019-01-29 21:27
This is the order: 1) Run consumer tests 2) publish pacts 3) run provider tests (which will publish verification results)

matt.fellows
2019-01-29 21:27
step 1/2 happens in the same consumer?s CI pipeline

matt.fellows
2019-01-29 21:27
Step 3 happens in the provider?s CI pipeline

norepeat17
2019-01-30 07:17
Thank you. I thought something wrong.

melisturgul
2019-01-30 12:43
has joined #general

claudia.cordes.de
2019-01-30 13:17
has joined #general

dagarwal
2019-01-30 14:49
Hello guys , when i add pact matching with term here on path withRequest: { method: ?GET?, path: term({ matcher: ?/api/assets/[0-9]+?, generate: ?/api/assets/10006? }), }, ( I am getting 404 when i try to load the data on UI :disappointed: ) .Without adding matcher it just works fine for me . Any suggestions on what went wrong and how to achieve it ?

thirumal.net
2019-01-30 18:59
@matt.fellows - can you please clarify one question related to step 2 and step3 ? as per my understanding pact broker should invoke provider side build which will run the pact verification step . if provider build is taking lot of time what would be the better way to handle pact verification from provider side . for example one of provider system build runs for 1 hour to build the solution and running the test cases, in this scenario what is the best way to handle pact verification. i recommended invoking provider build from pact broker through web hooks but provider team dismissed my recommendation saying that we are not going to allow provider build to run multiple times in a day for 1 hour

vitaliy.grigoruk
2019-01-30 20:04
has joined #general

matt.fellows
2019-01-30 20:23
looks ok to me Dolly, what do the pact logs say?

matt.fellows
2019-01-30 20:24
The broker doesn?t have to invoke it (via web hooks) but that is a good approach for many.

matt.fellows
2019-01-30 20:26
If the provider build is taking a long time, well that?s a separate problem altogether. That?s quite a long time, and perhaps there is something else that needs to be looked at / addressed. I can?t give you specific advice about your domain/application etc., but one option could be to split the provider into smaller units so things aren?t so slow. In terms of pact, perhaps you can make the webhook only invoke the ?contract? related tests, instead of the entire pipeline?

matt.fellows
2019-01-30 20:26
This way at least you?ll get faster feedback on the contract verification

thirumal.net
2019-01-30 20:30
@matt.fellows -Thank you for clarifcation. i will recommend to run only contract related tests through web hook instead of entire pipeline

matt.fellows
2019-01-30 20:32
It?s worth thinking through the side-effects of that decision - I?m not sure what the pipeline covers, but presumably a lot. If the contract tests pass, this is probably a good indicator that things are working (especially if you have good coverage), but do exercise some caution

thirumal.net
2019-01-30 20:33
Sure, Thank you!!

andreas.flinck
2019-01-30 21:11
has joined #general

mikhail.laptev
2019-01-31 01:57
has joined #general


mboudreau
2019-01-31 05:15
@oswald.quek good job on the blog, would love to get more opinions about what worked and what could be improved in the process :slightly_smiling_face:

matt.fellows
2019-01-31 05:58
yep!

matt.fellows
2019-01-31 05:59
I tweeted yesterday, great news! We had a conference call with the team mid last year. Really great bunch of people and are doing some awesome stuff

mboudreau
2019-01-31 06:05
cool

mboudreau
2019-01-31 06:05
who's "we"? :stuck_out_tongue:

matt.fellows
2019-01-31 06:18
Beth and Ron and I

mboudreau
2019-01-31 06:23
:disappointed:

oswald.quek
2019-01-31 09:39
yes thanks for all your help and guidance @matt.fellows @bethskurrie @uglyog!

oswald.quek
2019-01-31 09:39
i think, and this is just personal opinion, is one of the things that worked for us is bypassing the java dsl completely and writing pacts in their json form


oswald.quek
2019-01-31 09:40
the pact is `publicapi-connector-create-payment.json` which is found at https://github.com/alphagov/pay-publicapi/tree/master/src/test/resources/pacts

oswald.quek
2019-01-31 09:40
java isn't good for dsls in my opinion

mboudreau
2019-01-31 10:22
Yep, understood. We've had a few people tell me something similar. I think we need to improve the experience of creating the contract

vitaliy.grigoruk
2019-01-31 10:57
Hi there. I?m looking for help / suggestion. We?re trying to implement CDCs with pact and got stuck with verification of a contact on providers side. Our contract contains a lot of requests which require auth by different users (different value for Authorization header). Currently, we can only specify 1 header value for all requests. Any suggestions / workarounds? (I?ve seen this issue, which is about the same https://github.com/pact-foundation/pact-js/issues/209)?

vitaliy.grigoruk
2019-01-31 10:57
We?re using pact-js on both consumer and provider sides.

matt.fellows
2019-01-31 11:57
Yep, that issue is in progress and we're looking for feedback. Would love your feedback on it if you're willing to try. It's functional, but not looking to put more quality into it until we get more community validation/involvement


dagarwal
2019-01-31 11:59
@matt.fellows

matt.fellows
2019-01-31 11:59
The crappy workaround I usually implement is a proxy in front of the provider that can override those headers as needed. It's basically what is moving into the frame work

vitaliy.grigoruk
2019-01-31 12:00
thanks for your answer, I?ll try it then and provide my feedback then.

matt.fellows
2019-01-31 20:26
That?d be great. I?d personally like to see this out the door, and if it proves useful i?ll roll it into other languages I maintain (e.g. Go)

ruairitobrien
2019-02-01 03:48
has joined #general

hossam.saraya.ext
2019-02-01 09:25
has joined #general

hossam.saraya.ext
2019-02-01 09:26
Hello guys. Where do we ask technical questions?

matt.fellows
2019-02-01 09:30
Depends on the topic

hossam.saraya.ext
2019-02-01 09:35
I think I found a better channel to ask the questions..lets keep general clean :stuck_out_tongue:

karishnu
2019-02-01 12:36
The provider depends on other services, and if one of those services are down during provider verification, the verification will fail. Does Pact help solve this issue?

vitaliy.grigoruk
2019-02-01 13:39
I?d suggest to run provider verification in development / test / ci environment, where you can mock those services your provider depends on @karishnu

rafael.anachoreta
2019-02-01 13:45
has joined #general

tomw
2019-02-01 15:49
has joined #general

manpreet1107
2019-02-01 16:41
has joined #general

shwetapachori1
2019-02-01 17:49
has joined #general

carolyn0429
2019-02-01 20:20
has joined #general

matt.fellows
2019-02-01 22:01
:wave:

abubics
2019-02-01 23:58
Pact helps more with verifying the contact between implementations of services. To check connectivity between instances of services (i.e. during deployment), you probably want a smoke test :)

matt.fellows
2019-02-02 02:59
Pact is designed to pick up issues prior to deployment, and each component is tested in isolation from others. So in a way, yes, it solves that problem as the dependencies should be stubbed out

karishnu
2019-02-02 07:23
@vitaliy.grigoruk Makes sense! Will give it a try.

hansika
2019-02-03 10:13
has joined #general

doritrieur
2019-02-03 15:11
has joined #general

mark.meninger
2019-02-04 02:26
has joined #general

phodgkinson
2019-02-04 14:05
has joined #general

mehrotrashubhangi
2019-02-04 16:12
has joined #general

julian.jelfs
2019-02-04 17:04
has joined #general

hossam.saraya.ext
2019-02-04 17:14
Why can't we generate pacts from interaction definitions directly? Why do we need a mock server in between the testing layer and the interactions. Is there any other way to do that other than generating the pacts through the mockup server?

james.carman
2019-02-04 17:45
Well, the mock server serves double duty

james.carman
2019-02-04 17:45
you can use it to test your client code too

james.carman
2019-02-04 17:46
I find the approach nice, because I usually end up having to figure out a way to mock out the downstream services myself in order to test my client library I?ll use to talk to it. This way, I get to kill two birds with one stone.

james.carman
2019-02-04 17:46
disclaimer: no *actual* birds were harmed

james.carman
2019-02-04 17:46
@hossam.saraya.ext ^^^^

hossam.saraya.ext
2019-02-04 17:49
Yea I agree..but in some situations one might want to isolate pact's flow from their current testing flow

james.carman
2019-02-04 17:49
I don?t know that anything really dictates that you generate the pact JSON files this way, either. If you can hand-craft them and get them uploaded to the broker, I suppose that?d work also

hossam.saraya.ext
2019-02-04 17:49
yea thats what I had in mind..like implicitly firing http requests against the mock server

james.carman
2019-02-04 17:49
I believe the maven plugin will upload JSON files from any directory you point it at

james.carman
2019-02-04 17:50
I?m a Java guy, but, I suppose the other tooling options would allow the same thing

hossam.saraya.ext
2019-02-04 17:50
ah my question is not about the broker. It's about the part where contracts get generated

james.carman
2019-02-04 17:50
oh, I think I misunderstood

james.carman
2019-02-04 17:51
my apologies

james.carman
2019-02-04 17:51
turns ears back on

hossam.saraya.ext
2019-02-04 17:51
nothing to apologise for

james.carman
2019-02-04 17:51
So, what is it that you want to achieve?

hossam.saraya.ext
2019-02-04 17:51
I want my pact contracts generated without having any unit tests

james.carman
2019-02-04 17:52
generated from what?

hossam.saraya.ext
2019-02-04 17:52
from interactions

hossam.saraya.ext
2019-02-04 17:52
just interaction objects or files

james.carman
2019-02-04 17:52
oh, so more like an api ?specification? in some form

james.carman
2019-02-04 17:52
like OpenAPI or swagger?

hossam.saraya.ext
2019-02-04 17:52
exactly

hossam.saraya.ext
2019-02-04 17:52
no, just the normal interaction form for pact

james.carman
2019-02-04 17:52
or WADL, etc.

james.carman
2019-02-04 17:53
ok, gotcha

hossam.saraya.ext
2019-02-04 17:53
``` { state: 'no conditions', uponReceiving: 'a request to do w/e', withRequest: { method: 'POST', headers: { ... }, path: '...', body: like('str') }, } ```

james.carman
2019-02-04 17:53
I suppose you *can* hand-craft those if you?d like

james.carman
2019-02-04 17:54
but, what would you do with them?

james.carman
2019-02-04 17:54
What do you envision your flow to be?

hossam.saraya.ext
2019-02-04 17:54
1. I would write the interactions manually to describe how the consumer speaks to the provider

james.carman
2019-02-04 17:55
this would be how a *particular* consumer views the world, then?

james.carman
2019-02-04 17:55
how they intend on using said service?

hossam.saraya.ext
2019-02-04 17:56
yea exactly

james.carman
2019-02-04 17:56
ok, go on. Now what happens?

hossam.saraya.ext
2019-02-04 17:57
a consumer is still responsible for documenting its interactions with all providers it speaks to

hossam.saraya.ext
2019-02-04 17:57
2. I use a util from pact that takes these interactions and generate contracts in `pactSpecification` format

james.carman
2019-02-04 17:57
ok, so you want to use the DSL to generate a pact file, but you don?t want to be forced to ?exercise? that pact right this second?

james.carman
2019-02-04 17:58
currently, I believe that if you don?t use one of your interactions, it?ll barf with some error message

james.carman
2019-02-04 17:58
am I understanding you correctly?

hossam.saraya.ext
2019-02-04 17:58
> ok, so you want to use the DSL to generate a pact file, but you don?t want to be forced to ?exercise? that pact right this second? kind of, I don't want to write code for setting up a provider and launching http requests against it

hossam.saraya.ext
2019-02-04 18:01
I think an option would be to write the contracts manually..but that feels wrong

james.carman
2019-02-04 18:11
I think the philosophy (I?m not the expert, so hopefully one of the gurus will correct me if I?m way off base here) is that you really don?t know that your ?pact? is correct or not if you don?t use it (dog-food it) in some way, by testing/exercising your client code against it

james.carman
2019-02-04 18:12
If you don?t use it, you?re really not asserting anything useful from the client side

hossam.saraya.ext
2019-02-04 18:14
that's true

hossam.saraya.ext
2019-02-04 18:15
but when I define the interaction and write a test to assert for the interaction I just hardcoded..that sounds like doing it twice to me. Maybe I am missing something

james.carman
2019-02-04 18:35
that?s a fair point

james.carman
2019-02-04 18:36
I might be too far out over my skis here, so maybe one of the gurus can jump in

james.carman
2019-02-04 18:36
:slightly_smiling_face:

james.carman
2019-02-04 18:36
I agree that sometimes the consumer-driven contract testing can get tedious

james.carman
2019-02-04 18:36
Is there a better way? That?s a fair question to ask (and it?s how innovation happens)

zach.the.hammer
2019-02-04 19:44
hey all! haven't had much time for off-hours developing so haven't been too active here for a bit, but i have a question re: plans for pact i know @bethskurrie mentioned once when talking about the python implementation of pact/request/response matcher logic eventually (ideally) moving to one implementation (i believe in rust) what are thoughts on having a side-effect free endpoint on the pact broker that takes in a request / response and a pact, runs the matcher algorithm, and returns the match document? i think this could be pretty cool (but not perfect). essentially pact libraries could just check their pact broker on what their matcher results are, and not have to worry about implementing that logic in their own language or porting in some tricky way to another languages implementation

zach.the.hammer
2019-02-04 19:45
that request/response service could also live in a shipped docker container that you run locally for testing / CI

matt.fellows
2019-02-04 20:19
So if I understand correctly, rather than verifying locally, you?d have the provider verify by talking directly to the broker which has that capability?

matt.fellows
2019-02-04 20:20
@hossam.saraya.ext @james you kinda of covered it, but here is the docs link that discusses this tension: https://docs.pact.io/faq#can-i-generate-my-pact-file-from-something-like-swagger

abubics
2019-02-05 00:40
In the consumer side of Pact tests, there are 3 potential gains: - declaring the intent of a consumer-side API client - verifying that the API client sends out the correct request - verifying that the API client handles the incoming response correctly

abubics
2019-02-05 00:40
You *don't* really get any value from asserting things in the unit test that Pact already verifies

abubics
2019-02-05 00:41
But you can get value from asserting that, for example, once the JSON came in, it was converted to domain objects properly.

abubics
2019-02-05 00:42
I think there are some code samples that just assert the same things that Pact already checks, and we should fix those, rather than devaluing the process (of exercising our API clients)

hossam.saraya.ext
2019-02-05 00:43
I meant that we already define the interactions as json objects and feed it to the mockserver. Doing that and then testing/asserting for the interactions feels like doing the same thing twice just in a different way

hossam.saraya.ext
2019-02-05 00:46
I think if we have something that generates the contracts directly from the interaction objects we define, it won't defeat pacts purpose if we integrate this as a step in consumer ci pipeline

hossam.saraya.ext
2019-02-05 00:48
you are welcome to correct me..I am just speaking out of my 1-week-old pact experience

hossam.saraya.ext
2019-02-05 01:13
Yea I see where that is coming from! I think the selling point for having pact as a unit test is the luxury to treat it as a real provider and write less stubs/mocks inside your unit tests. Also, if I use pact in unit tests, I would integrate it into the current tests that asserts request body,headers..etc against mocked/stubbed provider client code instead of writing new `<filename>.pact.spec.js`

zach.the.hammer
2019-02-05 01:46
Basically just having an http endpoint to verify against

zach.the.hammer
2019-02-05 01:46
As an easy way to integrate a dedicated ?matcher? in any language


karishnu
2019-02-05 05:24
I had a similar question a while ago too.


matt.fellows
2019-02-05 06:37
One issue I would have with this, is that in mandates the use of a broker - something that is a managed infrastructure. On the one hand, commercially that would be great for business, but on the other, the Pact Broker is currently still an ?optional? part of the ecosystem

abubics
2019-02-05 06:38
@james.carman If you wanted to get some more rationale, my take is hiding in this thread ;D

matt.fellows
2019-02-05 06:38
We have bandied around similar ideas for the broker to enrich the experience, just not for replacing aspects of the core

matt.fellows
2019-02-05 06:38
(and you?re right, rust is the target)

matt.fellows
2019-02-05 06:39
I think I understand what you?re saying

matt.fellows
2019-02-05 06:40
> Doing that and then testing/asserting for the interactions feels like doing the same thing twice just in a different way (edited) Just to be clear, you shouldn?t be asserting that the response was `200` both in Pact and then in the unit test. The Unit test should be _testing the code that calls the API_ - e.g. a `UserService` which may return a `User`. You should have assertions about the `User`, not the JSON response directly.

hossam.saraya.ext
2019-02-05 09:02
Yea that makes sense now. Would be great to have that in FAQ or docs somewhere.

hossam.saraya.ext
2019-02-05 09:16
Is it a good practice to have pact files commited into git repos? Trivial answer is "No" because they are generated during the consumer CI build anyways. I wast just wondering if there is any use case that supports having the pacts managed by git

karishnu
2019-02-05 09:30
Considering that a Pact Broker is used, which also manages different versions of Pact files, I do not see a use case where committing Pact files to git will help in any way

matt.fellows
2019-02-05 09:45
The main use case was to be able to easily and conveniently use the pacts to run a local stubs from. I believe we either will or already do support fetching from the broker

matt.fellows
2019-02-05 09:45
But you can also do this without committing them

hossam.saraya.ext
2019-02-05 10:08
> I believe we either will or already do support fetching from the broker I think we can already do `broker/url/pacts/` to get all pacts

ruban.mahendran
2019-02-05 10:14
has joined #general

matt.fellows
2019-02-05 10:14
Sure, but that's not as easy as passing a flag to the pact-stub-server (https://github.com/pact-foundation/pact-ruby-standalone/releases) to do it for you. But yes, it's all scriptable today, we want to package it up and make that easier

hossam.saraya.ext
2019-02-05 10:19
Does `Pact.verify()` write the pact files even if the verification fails? It's writing pacts for me which is weird as verify should only verify the interactions is being used against mock server? correct or not

bethskurrie
2019-02-05 10:32
It should not write the pact if the mock service verification fails on the consumer side.

keetron
2019-02-05 10:32
has joined #general

bethskurrie
2019-02-05 10:33
I'm not sure at what level the js api works. The pact writing might have been bundled in with the verify method.

bethskurrie
2019-02-05 10:33
Matt should know.

hossam.saraya.ext
2019-02-05 10:34
Yea I removed all `finalize` and `writePact` calls from my tests. Yet, I still have pacts generated for me using only `.verify()`

bethskurrie
2019-02-05 10:35
You'll have to have a look at the source code.

bethskurrie
2019-02-05 10:35
I'm surprised, but I don't maintain the js.

hossam.saraya.ext
2019-02-05 10:35
I did. at a glance, it looks like it doesn't do anything to write the pacts

hossam.saraya.ext
2019-02-05 10:35
``` public verify(): Promise<string> { return this.mockService.verify() .then(() => this.mockService.removeInteractions()) .catch((e: any) => { // Properly format the error /* tslint:disable: no-console */ console.error(""); console.error(clc.red("Pact verification failed!")); console.error(clc.red(e)); /* tslint:enable: */ return this.mockService.removeInteractions().then(() => { throw new Error("Pact verification failed - expected interactions did not match actual."); }) }) } ```

bethskurrie
2019-02-05 10:36
Doesn't look like it's writing to me.

hossam.saraya.ext
2019-02-05 10:36
yea me neither. I suspected that it's jest cache or something..cleared it, but still getting generated pacts O_o

hossam.saraya.ext
2019-02-05 10:36
@matt.fellows any idea?

keetron
2019-02-05 10:37
I am trying to have my pact files written someplace else than `/target/pact`, we will have a pact broker in a few weeks but want to do some POC before that and I cannot find how to do this

bethskurrie
2019-02-05 10:37
Are there automatic hooks created for your test framework?

keetron
2019-02-05 10:37
I am using Java

bethskurrie
2019-02-05 10:37
Ask in #pact-jvm

keetron
2019-02-05 10:38
oh cool, more channels :slightly_smiling_face:


hossam.saraya.ext
2019-02-05 10:39
no, just a single test file being run by `jest <file>`

hossam.saraya.ext
2019-02-05 10:39
nothing fancy

bethskurrie
2019-02-05 10:39
:man-shrugging: Tis a mystery to me.

hossam.saraya.ext
2019-02-05 10:39
You basically set that in the mock server constructor. (Speaking about the JS lib). Hopefully the java library follows the same convention

bethskurrie
2019-02-05 10:40
Nah. Probably goes though 4 levels of factory impls and xml :-P

hossam.saraya.ext
2019-02-05 10:40
Thanks god for js :smile:

hossam.saraya.ext
2019-02-05 10:42
To all my fellow java engineers/devs..stay strong

matt.fellows
2019-02-05 10:58
I'm just at my folks house, will check when I get home (soon)

matt.fellows
2019-02-05 10:58
It's also surprising to me

bethskurrie
2019-02-05 10:59
Can you make a reproducible example repository @hossam.saraya.ext?

hossam.saraya.ext
2019-02-05 11:00
yea will work on that @evening

dipeshlpatel
2019-02-05 11:20
has joined #general

matt.fellows
2019-02-05 11:24
OK had a quick peep. The workflow that causes this behaviour: - Set expectations - fail a unit test (whether or not it actually hits the correct endpoint) - ~verify()~ won?t be called, because the test framework bails In this case, because `verify()` is never called, when the mock service is shutdown, it still writes the pact.

matt.fellows
2019-02-05 11:24
When `verify()` is actually called, if this fails, the pact isn?t written

matt.fellows
2019-02-05 11:25
that being said - is it actually a problem? If your unit tests fail, then subsequent steps (e.g. publishing to a broker) should not run.

hossam.saraya.ext
2019-02-05 11:35
What if my tests pass but the verification fails?

hossam.saraya.ext
2019-02-05 11:36
So, the pacts are written anyways when the mockserver is shutdown?

jlopespereira
2019-02-05 14:09
has joined #general

hossam.saraya.ext
2019-02-05 15:35
> because `verify()` is never called, when the mock service is shutdown, it still writes the pact. So if I want to generate pacts without hitting the server. I just don't call `verify()` and that would make the server generate pacts when it's closed? :thinking_face:

japedersen
2019-02-05 19:23
Hi, is there a way to ignore a specific header param in the pact test, but still generate it into the pact/interaction file?

hossam.saraya.ext
2019-02-05 19:30
Interesting. You mean a request header right?

matt.fellows
2019-02-05 19:42
What's the reasoning behind the need for this?

matt.fellows
2019-02-05 19:43
Something like an auth token?

japedersen
2019-02-05 19:44
yes like an auth token, and in the request header.

hossam.saraya.ext
2019-02-05 19:47
but your tests already include these request headers when testing against the mock server? You just don't want to define it in the interactions? If that's the case, I don't know if it's entirely possible, but if you are worried about having sensitive data specified in the pact file, you can use `like` matchers

japedersen
2019-02-05 20:02
So, this header needs to be in the pact file. However, specifying it in the interaction test will cause a failure.

japedersen
2019-02-05 20:02
~So I'm wondering how to ignore a specific header in the test~

matt.fellows
2019-02-05 20:15
It probably ought to be in the interaction (pact file) - why shouldn't it be there? That being said, auth token are often short lived. You can inject a valid one using custom headers. Which language are you using?

matt.fellows
2019-02-05 20:15
There is a section on the docs site about this

japedersen
2019-02-05 20:20
Javascript.

japedersen
2019-02-05 20:22
So in the test if I specify the header param, then there will be a failure, and wont generate that endpoint into the pact file because it doesn't exist (even tho it does in the api swagger). If I could ignore this in the pact test, then my hope is it gets generated into the pact file.

japedersen
2019-02-05 20:23
Is there a way to work around this and just add this into the pact file?

japedersen
2019-02-05 20:24
Or does the pact manager allow to add a new header after tests run?

matt.fellows
2019-02-05 20:26
No, there is no way to add stuff into the pact after the tests run, unless you do it manually (which is almost always a bad idea)

matt.fellows
2019-02-05 20:31
I'm still confused tho. If in your consumer test you must specify an auth header as the API needs it, why does the provider API fail during verification?

matt.fellows
2019-02-05 20:32
Is it a different endpoint for auth? Or is it a token the provider needs and then passes to an auth svc?

hossam.saraya.ext
2019-02-05 21:33
> However, specifying it in the interaction test will cause a failure. Is this because you don't know the header value in compile time? so you can't hardcode that value in the interaction?

hossam.saraya.ext
2019-02-05 21:33
if I understood you right, then probably this is the reason you can't get your `pact.verify()` to pass

matt.fellows
2019-02-05 21:36
So we?re clear, when we say `pact.verify()` this is in the _consumer_ test, right?

matt.fellows
2019-02-05 21:37
Why would it fail the consumer test?

hossam.saraya.ext
2019-02-05 21:39
:man-shrugging:

hossam.saraya.ext
2019-02-05 21:39
@japedersen would be great if you provide more context

japedersen
2019-02-05 22:25
Hi, apologies. I have solved this.

japedersen
2019-02-05 22:27
I had to fix my jest mocking in all this.

japedersen
2019-02-05 22:30
Adding back the request header, lets my pact tests pass and are being added to the pact file. As desired!

japedersen
2019-02-05 22:30
Sorry for the confusion! @matt.fellows @hossam.saraya.ext

mahyar-1
2019-02-06 08:36
has joined #general

mahyar-1
2019-02-06 08:38
Hi Everyone, Is there anyway to match use path-parameters in pact? I am on jvm and using java


mahyar-1
2019-02-06 13:38
thanks will check it

vitaliy.grigoruk
2019-02-06 14:48
Hey folks, I?ve noticed that pact mockserver doesn?t save multiple providerStates (defined in spec v3) when generating a contract file. I?ve made a small PR to fix it. Coudl somebody take a look? https://github.com/pact-foundation/pact-mock_service/pull/101

dipeshlpatel
2019-02-06 21:01
Hello everyone, I am new to PACT and was wondering if someone can point out if there is any video series which i can follow or attend PACT workshop in London to gain better understanding to implement using JAVA. Referred the link below but i guess step by step docs/video that is what i need ; https://github.com/DiUS/pact-workshop-jvm

matt.fellows
2019-02-06 22:10
Thanks!

matt.fellows
2019-02-06 22:11
Hi Dipesh, there's no video that I'm aware of that gives you a step by step instruction.

matt.fellows
2019-02-06 22:11
We're considering running webinars but not for a little bit

dipeshlpatel
2019-02-07 07:36
Thanks for the reply @matt.fellows It will be great to have a guide to use PACT as I feel that it is a brilliant tool do Contract Testing instead of Integration Testing.

matt.fellows
2019-02-07 08:28
Thanks Dipesh. Have you gone through the workshop?

dipeshlpatel
2019-02-07 08:59
Not yet. I have explore that avenue too but no workshop in London at present

matt.fellows
2019-02-07 08:59
I meant, have you gone through the github workshop?

dipeshlpatel
2019-02-07 09:02
I have gone through the above pact-workshop-jvm but i am unable to find where to start This could be me being an automation test analyst

bart.schotten
2019-02-07 14:18
has joined #general

martin.hock
2019-02-07 14:24
has joined #general

vitaliy.grigoruk
2019-02-07 15:36
any chance to get this merged / released?

hossam.saraya.ext
2019-02-07 20:57
What is the difference between pact-node and pact-js?

matt.fellows
2019-02-07 21:07
Pact JS is the DSL you would use to write your contract tests in. Pact Node is essentially a NodeJS wrapper for the Pact components. In most cases, you shouldn?t have to use it directly, but it is used by Pact JS (and other related components). It?s essentially a dependency

matt.fellows
2019-02-07 21:08
You might want to use it for fine grained control over certain things, or for having a JS interface to tools like `can-i-deploy`

james.carman
2019-02-07 21:42
Would it be possible to move the logic in ?can-I-deploy? to an endpoint on the pactbroker?

matt.fellows
2019-02-07 21:43
It?s certainly possible. Why would you want it there

matt.fellows
2019-02-07 21:43
(not disagreeing, just interested in your perspective)

james.carman
2019-02-07 21:43
So that I don?t need a CLI

matt.fellows
2019-02-07 21:44
:slightly_smiling_face:

james.carman
2019-02-07 21:44
I can easily script web calls into my Jenkins workflows

james.carman
2019-02-07 21:44
I really wasn?t trying to be a smart ass :)

matt.fellows
2019-02-07 21:45
haha I think the bulk of the logic is there anyway

james.carman
2019-02-07 21:45
Sometimes it?s just natural

matt.fellows
2019-02-07 21:45
The CLI probably just orchestrates it. ?The matrix? is what contains the magic

james.carman
2019-02-07 21:45
You get what I mean though, right?

matt.fellows
2019-02-07 21:45
yep

matt.fellows
2019-02-07 21:45
@bethskurrie will be able to tell you more

james.carman
2019-02-07 21:45
Can we move the orchestration behind an endpoint?

james.carman
2019-02-07 21:46
Even if it?s async?

bethskurrie
2019-02-07 21:46
It is.

james.carman
2019-02-07 21:46
All of it?

bethskurrie
2019-02-07 21:47
No, it depends on what your arguments are.

james.carman
2019-02-07 21:47
That?s what I mean

bethskurrie
2019-02-07 21:47
It could be more abstracted.

james.carman
2019-02-07 21:47
Can we move that logic server-side?

bethskurrie
2019-02-07 21:47
Yes

james.carman
2019-02-07 21:48
It does some blocking, right?

bethskurrie
2019-02-07 21:48
The wait?

james.carman
2019-02-07 21:48
Some wait period or something

james.carman
2019-02-07 21:48
Yeah

bethskurrie
2019-02-07 21:48
I wouldn't want to move that into the endpoint

james.carman
2019-02-07 21:48
Right

james.carman
2019-02-07 21:48
Agreed

bethskurrie
2019-02-07 21:48
Not a good use of server cycles.

james.carman
2019-02-07 21:48
Nope

james.carman
2019-02-07 21:48
What is it waiting for?

james.carman
2019-02-07 21:49
Does it trigger notifications for jobs to run?

bethskurrie
2019-02-07 21:49
A result to come back

bethskurrie
2019-02-07 21:49
No


james.carman
2019-02-07 21:50
Ok it?s polling

james.carman
2019-02-07 21:51
Hoping something changes (a job runs) to change a verification result

james.carman
2019-02-07 21:51
Makes sense

james.carman
2019-02-07 21:51
Is that all the logic it?s doing, then?

james.carman
2019-02-07 21:52
The polling?

james.carman
2019-02-07 21:53
If not, can we move whatever else it?s doing server-side?

james.carman
2019-02-07 21:53
And the server just always responds immediately with yes/no?

james.carman
2019-02-07 21:54
And maybe the data that backs up that claim

james.carman
2019-02-07 21:54
Like all the verifications that passed

james.carman
2019-02-07 21:55
I don?t mind helping with a PR (my ruby is dusty). I just wanna make sure it?s not against the vision before I crack open some code

james.carman
2019-02-07 21:57
@bethskurrie did I lose you?

bethskurrie
2019-02-07 21:57
I'm in a tunnel

james.carman
2019-02-07 21:57
I hope you are not driving

james.carman
2019-02-07 21:59
No problem, just let me know. I don?t mind helping out. We are benefiting quite a bit from all the great work you folks have done!

bethskurrie
2019-02-07 21:59
In on a train to work

james.carman
2019-02-07 22:00
:train:

bethskurrie
2019-02-07 22:00
There is a little bit of logic in the cli code, but it's mostly working out what arguments to send to the matrix

bethskurrie
2019-02-07 22:00
Any waiting code would need to be put into your http client.

james.carman
2019-02-07 22:00
Yep

james.carman
2019-02-07 22:00
Agreed

james.carman
2019-02-07 22:01
Provide back the immediate response from the data currently present



james.carman
2019-02-07 22:03
Love the emoticon in the message


james.carman
2019-02-07 22:42
I know the answer involves tags or labels or whatever they?re called, but does anyone have an example of how they?ve managed that stuff in a CD type environment?

james.carman
2019-02-07 22:44
Like, if I want to verify a new version of my provider against all pacts that are currently tagged as ?prod? to make sure it?s safe to push out my updates?

james.carman
2019-02-07 22:45
Can we push tags onto existing, versioned pacts?

bethskurrie
2019-02-07 22:45
yes

bethskurrie
2019-02-07 22:46
that's kind of the point


james.carman
2019-02-07 22:46
And I suppose we?d have to remove the previously tagged prod version

bethskurrie
2019-02-07 22:46
no

james.carman
2019-02-07 22:46
Yeah, I?ve read it

bethskurrie
2019-02-07 22:46
You specify "the latest version tagged prod"

james.carman
2019-02-07 22:46
It?s been a while

bethskurrie
2019-02-07 22:46
it means you don't have to remove previous tags.

james.carman
2019-02-07 22:47
Latest is temporal, not version-based?

bethskurrie
2019-02-07 22:47
technically, it's the latest version with that tag

bethskurrie
2019-02-07 22:47
where the ordering is the order the version was published

james.carman
2019-02-07 22:47
Hmmm

james.carman
2019-02-07 22:48
If I deployed version 1, then 2

james.carman
2019-02-07 22:48
Then I had to rollback because we found an issue

james.carman
2019-02-07 22:48
I redeploy 1

james.carman
2019-02-07 22:48
And re-tag

james.carman
2019-02-07 22:48
Who would be considered ?latest??

james.carman
2019-02-07 22:49
I?m guessing 2, since the pact was published after 1?

james.carman
2019-02-07 22:49
That?s probably unlikely

james.carman
2019-02-07 22:50
But in that case, could we ?untag? 2 as prod?

bethskurrie
2019-02-07 22:51
yes

james.carman
2019-02-07 22:51
Cool

james.carman
2019-02-07 22:52
Most likely, we?d just fix 2 and deploy 2.0.1 or something

bethskurrie
2019-02-07 22:52
Btw, lets move this to a thread in #pact-broker so we're not spamming everyone

james.carman
2019-02-07 22:53
Oh sorry

mboudreau
2019-02-07 23:16
yes, please thread your convo :slightly_smiling_face:

vitaliy.grigoruk
2019-02-08 09:46
@bethskurrie looks like you are maintaining this repo. Could you please take a look at this PR? it is just 2 lines of code

matt.fellows
2019-02-08 09:58
There might have been a reason why it wasn't supported the first time, if it was so easy. I recall discussing it around when we were doing the message pacts

hossam.saraya.ext
2019-02-08 10:30
~http://blog.pact.io/tag/can-i-deploy~ ~Why is this blog post trimmed off? :smile:~ Apparently because I am viewing the tags not the post itself :blush:

bethskurrie
2019-02-08 10:40
I'll have a better look tomorrow, as it's late here now. I don't think v3 writing is actually supported at all from memory. I think it just supports reading v3 pacts. The rule writing format is different for v3 also.

vitaliy.grigoruk
2019-02-08 11:22
oh, well. Didn?t think about rule writing format in v3? :disappointed:

vitaliy.grigoruk
2019-02-08 11:23
I guess I have to specify provider states in 1 string then?

biercoff
2019-02-08 16:23
has joined #general

biercoff
2019-02-08 16:25
Hi guys. Small question. I have a provider that provides a big json payload. And i also have bunch of consumers - each of them is interested in part of this payload. Does every consumer has to specify full provider payload in the contract, or they can specify only structure they are interested ?

james.carman
2019-02-08 16:29
typically a consumer should only deal with the data they?re interested in


biercoff
2019-02-08 16:31
where i find this

biercoff
2019-02-08 16:31
the documentation here http://docs.pact.io/documentation/gotchas.html it says - "Be conservative in what you send - when the mock server in the consumer project compares the actual request with the expected request, the actual request body is not allowed to contain fields that are not defined in the expected request body. We don't want the situation where our real consumer is "leaking" data that we don't know about."

biercoff
2019-02-08 16:31
and i get confused :slightly_smiling_face:

james.carman
2019-02-08 16:55
I got 404

james.carman
2019-02-08 16:55
on the ?gotchas? link

james.carman
2019-02-08 16:56
There?s a huge difference in how you should treat the request vs. the response here.

james.carman
2019-02-08 16:56
As a consumer, you shouldn?t care that the service sends more data than you need

james.carman
2019-02-08 16:56
restated, you shouldn?t care that the response contains more data than you need

biercoff
2019-02-08 17:31
got it thanks

matt.fellows
2019-02-09 02:02
Yep. Optional elements are a separate but related thing. There is an article on http://docs.pact.io about it discussing it in more deptg. In your case, different consumers just need different bits of the payload And they should write pact tests that only include those bits.

matt.fellows
2019-02-09 02:02
I should say it's very common to do what you're asking, if it helps

petro.turovskyy
2019-02-09 18:41
has joined #general

petro.turovskyy
2019-02-09 18:46
Hey guys! I would really appreciate your input on this one: https://github.com/DiUS/pact-jvm/issues/849

ruban72
2019-02-09 19:39
has joined #general

arvindr3
2019-02-11 08:53
has joined #general

javid.ali
2019-02-11 11:21
has joined #general

arvindr3
2019-02-11 11:27
Hi,

arvindr3
2019-02-11 11:28
i m getting the issue while i m running the Pact Workshop - js

arvindr3
2019-02-11 11:29
Error: Error from response: undefined at request.get.query.then.err (D:\Pact\pact-workshop-js-master\consumer\client.js:33:15) at process._tickCallback (internal/process/next_tick.js:68:7)

javid.ali
2019-02-11 11:33
Hi non-techie here, had a quick look at docs but couldn't gather, does Pact interactions use the real API and database of the app or is this mocked out? Sorry for dumb question. Thanks.

matt.fellows
2019-02-11 12:19
Hi Arvind, please ask in the #pact-js channel, and provide all of the details as to what you?re doing, what steps you?ve attempted to resolve them and the results of those attempts.

matt.fellows
2019-02-11 12:20
From the point of view of the _consumer_, the _provider_ is completed mocked out in the test, and the recordings with that mock (it?s still a real API endpoint) become the contract (simplified). When testing the _provider_, Pact assumes the role of the consumer, and sends actual HTTP requests to the real provider - if it needs a DB you may choose to use it or mock it out.

matt.fellows
2019-02-11 12:20
That help?

james.carman
2019-02-11 12:23
I always mock it.

james.carman
2019-02-11 12:23
:)

gopinathlangote11
2019-02-11 12:24
.

gopinathlangote11
2019-02-11 12:24
.

gopinathlangote11
2019-02-11 12:25
sorry mistake

javid.ali
2019-02-11 13:34
Thanks @matt.fellows that makes sense :slightly_smiling_face:

sneha.puskoor
2019-02-11 20:04
has joined #general

brian
2019-02-11 23:10
has joined #general

pilit63
2019-02-12 07:57
has joined #general

pilit63
2019-02-12 07:58
Hi guys! New on the channel

pilit63
2019-02-12 08:04
Im creating a pact verification platform and I found a problem managing versions and where to publish result. The use case is this: in a provider test, I want to publish or not the results of my verification depending on the version of the consumers. These versions can be snapshots or finals, so I want to select only snapshots to be published (the verifications) to work in merge requests. Currently Im using the property "pact.verifier.publishResults" but I need to select whether I publish a verfication of a contract or not dynamically reading consumer version. Is there any option to do this? As PactRunner uses InteractionRunner, I cannot extend it easily..

hossam.saraya.ext
2019-02-12 14:29
How can we match two request with the same METHOD & URL. The difference between requests is that one has 1 more json field than the other

vitaliy.grigoruk
2019-02-12 14:32
there should be different state probably, and different description in this case

hossam.saraya.ext
2019-02-12 14:35
is it ok to have both interactions with request.body set to `Pact.like({...})`

hossam.saraya.ext
2019-02-12 14:35
does that make the matcher match against body type only and disregard the body content?

hossam.saraya.ext
2019-02-12 14:37
in other words.. IS: ``` body: like({ name: 'str' }) ``` equivalent to ``` body: { name: like('str') } ``` ?

jonas.lmk
2019-02-12 14:43
has joined #general

mtissot79
2019-02-13 07:51
has joined #general

sam
2019-02-13 16:10
has joined #general

sam
2019-02-13 16:43
Looking for some advice regarding where to put the consumer pact. We have some webservices, where the webservice team provides its own client library (java). For example, a team provides both application "foo-ws" and "foo-ws-client" library. A different team creates an application "bar" that makes uses of "foo-ws-client" to get data from "foo-ws". Does the consumer pact belong in "foo-ws-client" or "bar"? Should the pact make use of foo-ws-client, or should bar create it's own client to talk to foo-ws?

james.carman
2019-02-13 16:45
I would vote ?bar?.

james.carman
2019-02-13 16:46
because your pact would only specify the data that ?bar? is interested in

james.carman
2019-02-13 16:46
For example, the response type coming from foo-ws-client might have 10 fields in it

james.carman
2019-02-13 16:46
but, bar only cares about 3 of them

james.carman
2019-02-13 16:46
it shouldn?t bother with the other 7 when specifying its pact

james.carman
2019-02-13 16:47
it?ll still use foo-ws-client to talk to foo-ws, but it only does stuff with those 3 fields

sam
2019-02-13 16:50
that makes sense. but if foo-ws makes a breaking changing that breaks foo-ws-client, "bar" would break instead of foo-ws-client

sam
2019-02-13 16:51
that's ok? it's really the client that's broken

james.carman
2019-02-13 16:55
well, if *anything* breaks, that means folks need to start talking :slightly_smiling_face:

james.carman
2019-02-13 16:56
foo-ws is hopefully downloading all pacts declared against it and verifying them as they make changes

james.carman
2019-02-13 16:57
regardless of what client library they use to talk to foo-ws. All clients don?t get the luxury of auto-upgrading to the latest and greatest foo-ws-client

james.carman
2019-02-13 16:57
we have the exact same situation here at work

james.carman
2019-02-13 16:57
we use JAX-RS, though

james.carman
2019-02-13 16:57
so, one team will publish an API jar that has JAX-RS-annotated interfaces in it

james.carman
2019-02-13 16:58
everybody that wants to use it will create a type-safe client proxy object that implements the jaxrs interface from the API jar

sam
2019-02-13 17:03
very good points! thanks for your help

sam
2019-02-13 17:11
That's an interesting way of publishing an API! We use JAX-RS for our webservice implementation too, but I'm curious about the setup you just mentioned. Is there a blog post or something that goes over that particular strategy?

james.carman
2019-02-13 17:15
The trick is separating your JAX-RS annotated stuff out into its own jar

james.carman
2019-02-13 17:15
lemme see if I have an example?


james.carman
2019-02-13 17:16
That?s an example of the pattern

james.carman
2019-02-13 17:16
from my ?jaxxy? library

james.carman
2019-02-13 17:20
we are using CXF to generate the client proxies

james.carman
2019-02-13 17:20
The ?microprofile? API has a new feature that makes this standardized

sam
2019-02-13 17:22
cool, thanks for the info

james.carman
2019-02-13 17:22
you?re welcome

bilgehanl.03
2019-02-14 13:21
has joined #general

igwe.kalu
2019-02-14 15:32
has joined #general

igwe.kalu
2019-02-14 15:38
Hi everyone

igwe.kalu
2019-02-14 15:40
I'm new in this community and I came armed with a question :crossed_swords: :slightly_smiling_face: With reference to this Github issue: https://github.com/pact-foundation/pact-js/issues/268 > Contract testing is about making sure your consumer team and provider team have a shared understanding of what the requests and responses will be in each possible _*scenario*_. > ~ https://docs.pact.io/best_practices/consumer#use-pact-for-contract-testing-not-functional-testing-of-the-provider - How could one possibly test a resource update contract without being sure there's an existing record to update? - In other words, how may the contract regarding a hypothetic product update scenario be tested?

james.carman
2019-02-14 16:25
@igwe.kalu contract testing isn?t functional testing

james.carman
2019-02-14 16:26
just make sure you?re not trying to verify that the service is, behind the scenes, doing the right thing with your data

james.carman
2019-02-14 16:26
with the contract test, you should only really be concerned with the ?shapes? of the responses.

james.carman
2019-02-14 16:26
There can be a bit of a gray area around error scenarios

pkuang
2019-02-14 16:38
has joined #general

jwatanabe
2019-02-14 18:38
has joined #general

igwe.kalu
2019-02-14 18:44
@james.carman thanks for the reminder. Be rest assured that I already have those factors in strict consideration. However, my questions remain open. And I?d very much appreciate an actual answer from any person experienced in the concept

james.carman
2019-02-14 18:45
you?re welcome (I think, although that sounded terribly dismissive)

james.carman
2019-02-14 18:47
@igwe.kalu what exactly are you trying to test and what have you tried so far?

james.carman
2019-02-14 18:48
?functions as expected? sounds a bit ?functional testy?

james.carman
2019-02-14 18:48
and not ?contract testy?

james.carman
2019-02-14 18:53
Perhaps what you?re trying to do is establish some known ?state??


matt.fellows
2019-02-14 23:45
@igwe.kalu > - How could one possibly test a resource update contract without being sure there?s an existing record to update? You?re right, you can?t. But the way you test this in Pact is separated into different pieces 1. The consumer test _does not create the state in advance_ by, for example, first creating the resource. It simply is a test that specifies its expectations - including the state: ?_given_ that resource X exists? (this is the ?state?) then ?when I call `GET` on `/resource/id`? I should get back some response. 2. It is important here that this test is performed in isolation from any other, stateful tests to avoid the functional nature of the test 3. When the provider verifies this piece of code, it is passed the state before the test. In the case above, the state is ?_given_ that resource X exists?. It is the responsibility of the provider to ensure it is in this state before the tests runs. This usually takes the form of seeding/clearing a database The net result is that the consumer tests are clean, simple to understand, and not dependent on the stateful ordering of things, yet the provider can still test interactions that traditionally depended on those things.

matt.fellows
2019-02-14 23:46
Theoretically, if you could spin up multiple provider code bases, you could perform the contract tests _in parallel_. Typically this isn?t needed because they are usually quite fast anyway owing to the fact that you usually stub out any of its dependencies, repeating this pattern all the way down the dependency tree

cocoa
2019-02-15 06:52
has joined #general

cocoa
2019-02-15 06:59
Incidentially, I have a question regarding provider states and this last post. if I have a test for GET on /resources/id and have a provider state "resource X exists" I see two options regarding the "id" part. The id in the request obviously has to match the id of the provider state. 1. predefine a fixed id (e.g. 42) that all "consumers" using that provider state must know and use (requires out of band documentation)

cocoa
2019-02-15 07:00
2. templateable provider state, e.g. "resource X with id {id} exists", which does not exist (as far as I see)

cocoa
2019-02-15 07:01
3. include id in provider state, i.e. "resource X with id 42 exists"

cocoa
2019-02-15 07:01
letting the consumer define ids at will seems crazy :slightly_smiling_face:

cocoa
2019-02-15 07:02
and as a side question: what are the params in pact jvm on the ProviderState meant for? I don't see it being used by the interaction runners at all

cocoa
2019-02-15 07:03
and another related question: what is the best way to avoid provider state explosion in regard to "options" on a resource

cocoa
2019-02-15 07:03
e.g. if I have a resource X that can optionally have option A and B

cocoa
2019-02-15 07:04
I don't want to define provider states for all combinations (without A and without B, with A and without B, ...)

cocoa
2019-02-15 07:05
use three provider states? "resource X exists" + "has option A" + "has option B"?

cocoa
2019-02-15 07:05
this requires a strict ordering of provider state

cocoa
2019-02-15 07:06
"has option A" cannot be done after "resource X exists" because "has option A" requires the existence of "option A"

stein
2019-02-15 08:06
"It is the responsibility of the provider to ensure it is in this state before the tests runs. This usually takes the form of seeding/clearing a database" This is quite an interesting topic and I would be interested to see how different folks manage the provider setup. I have always ran a version of the provider with the entire service/domain layer mocked out - which ensures we aren't testing any behaviour or business logic. I feel having a real database goes too far, but I'd be interested in hearing arguments for it - maybe easier setup. I've taken the mocking approach in both golang and java projects.

james.carman
2019-02-15 12:03
Running your verification using mocks makes this much simpler

james.carman
2019-02-15 12:05
We have state methods that allow you to pass in data to establish state. We don?t store data in a database or anything, but simply train the mocks using the desired state

james.carman
2019-02-15 12:05
The tests are very fast and it?s easy to isolate everything

james.carman
2019-02-15 12:09
@sam the client proxy stuff is being standardized by the microprofile client API: https://github.com/eclipse/microprofile-rest-client

james.carman
2019-02-15 12:10
CXF implements this

matt.fellows
2019-02-15 12:17
You'd still need to know that the state exists, but the ids at least could be made to be dynamic with, say, a callback/hook in the provider tests to fetch known "parameters" for the interaction. @uglyog thoughts?

matt.fellows
2019-02-15 12:17
We are also looking at ways to visualise these available states in the pact broker

matt.fellows
2019-02-15 12:17
To ease with new clients getting started

robin
2019-02-15 13:56
has joined #general

daniel.hegner
2019-02-15 14:36
has joined #general

tom.mortiboy
2019-02-18 05:49
has joined #general

tom.mortiboy
2019-02-18 05:55
Hello all! Just been looking at the hosted pact broker at https://pact.dius.com.au. If you use this service, are contracts and documentation public, or is there auth to keep pacts private?

abubics
2019-02-18 06:07
There is currently basic auth (in the free version), and no anonymous option

abubics
2019-02-18 06:07
Also, hello! Welcome :smile:

tom.mortiboy
2019-02-18 06:07
thanks!

bethskurrie
2019-02-18 06:20
We are at this very moment working on social login.

bethskurrie
2019-02-18 06:21
And API tokens.

ben.smith
2019-02-18 08:07
has joined #general

matt.fellows
2019-02-18 08:50
Ah back travelling again I see Tom. Snow good in Japan? :grinning:

matt.fellows
2019-02-18 08:51
Just so we're clear, acct is private - no one else can see your contracts etc.

rabih
2019-02-18 13:00
Hello, is there a way to hide password from the generated testing debugging log?

matt.fellows
2019-02-18 19:59
what password are you referring to? which language are you using?

vitaliy.grigoruk
2019-02-19 09:37
Hey @bethskurrie @matt.fellows. Considering that V2 doesn?t support multiple provider states (and V3 contract writing is not yet implemented), what would be your suggestion for specifying multiple provider states for pact interactions? In order to run provider verification in our app, we need to set up multiple entities in a DB (e.g. `user with name=TestUser exists`, `company with id=1 exists`, `Survey round for user with id=1 is open`). Defining this state as 1 string is not optimal and will lead to a lot of code duplication on provider?s side (in a state setup code). As a workaround, I?m thinking about encoding JSON object with states into a string using `JSON.stringify` and then decoding it from string to a JSON object via `JSON.parse` on provider verification side. What do you think about such idea?

bethskurrie
2019-02-19 09:38
What languages are you working in?

bethskurrie
2019-02-19 09:38
Pact Ruby actually supports verifying in v3, just not writing in v3.

bethskurrie
2019-02-19 09:39
Hence, pact go, js, net also support verifying in v3.

bethskurrie
2019-02-19 09:39
Not all features are supported yet, but the multiple states and params are supported

bethskurrie
2019-02-19 09:40
It calls the provider state endpoint once for each state.

bethskurrie
2019-02-19 09:42
What is your consumer written in?

vitaliy.grigoruk
2019-02-19 09:43
JS

vitaliy.grigoruk
2019-02-19 09:43
on both sides

bethskurrie
2019-02-19 09:44
Do you really need to specify all 3 things?

bethskurrie
2019-02-19 09:44
I tend to just specify the most important object in the request. In your case, the survey round I would think.

vitaliy.grigoruk
2019-02-19 09:45
well, there a lot of interactions in a contract and some of them depend on different combinations of states

bethskurrie
2019-02-19 09:45
Does this change the way the responses look?

vitaliy.grigoruk
2019-02-19 09:45
yes

vitaliy.grigoruk
2019-02-19 09:46
the endpoints we?re covering with a contract are quite flexible in terms of output (based on query params and provider states)

bethskurrie
2019-02-19 09:47
We really need to support v3. Matt and I are just a bit maxed out at the moment with the commercial pact broker work.

bethskurrie
2019-02-19 09:48
You can try putting all the provider state info in a json string. It'll be yucky, but if it gets you through until we can support it properly, we'll and good

vitaliy.grigoruk
2019-02-19 09:49
Thanks! I?ll be happy to contribute to both Ruby & JS codebases, if some help is needed.

bethskurrie
2019-02-19 09:50
I'd love help.

bethskurrie
2019-02-19 09:50
There's going to be a lot of little things scattered throughout the Ruby library though, it's not straight forward unfortunately.

bethskurrie
2019-02-19 09:52
I'll see if I can find some things that are easy to explain.

ola.jankowska
2019-02-19 09:57
hi I need some help, I have frontend in Angular that is publishing tests to broker and backend in java that is running tests against production environment, the only thing we are missing is adding Authorisation (Bearer Token) header to all requests, we have test user for that, how can we inject this header (end before that get the token because it is valid very short time ) I am using pact-jvm-provider-maven_2.12

matt.fellows
2019-02-19 10:07
look for ?request filters? - that?s probably what you need

matt.fellows
2019-02-19 10:07
But testing against prod?. probably not a great idea

vitaliy.grigoruk
2019-02-19 10:08
:+1:

ola.jankowska
2019-02-19 10:11
why not? we want to be sure we will not brake any contracts when releasing new version

ola.jankowska
2019-02-19 10:12
thanks I found request filters! that is what i Need now I just need to log in :smile:

matt.fellows
2019-02-19 10:13
:slightly_smiling_face:

matt.fellows
2019-02-19 10:13
So, the contract really should be something owned by the provider team and done at build time. Not all contracts will be able to be performed this way - say creating an order or something

matt.fellows
2019-02-19 10:14
Best to have it automated in CI, and have the provider team own the outcome

matt.fellows
2019-02-19 10:14
if it works for you, sure, but the approach will have limits

ola.jankowska
2019-02-19 10:33
I see you can filter tests per environment so we can always split test for P and T


matt.fellows
2019-02-19 10:35
which password though? a password in a test, or for a broker?

bethskurrie
2019-02-19 19:56
@ola.jankowska the recommended way to test contracts is to do it before deploying to production. You can read about it here: https://docs.pact.io/best_practices/pact_nirvana

bethskurrie
2019-02-19 19:57
Testing against a live deployed app rather than against one running in CI can make it slower and more difficult to set up and tear down provider states, and to stub downstream services.

bethskurrie
2019-02-19 19:58
The contract tests would typically be run in the CI pipeline of the provider.

bockus
2019-02-20 02:46
has joined #general

rickard.andersson
2019-02-20 07:01
has joined #general

vitaliy.grigoruk
2019-02-20 08:36
Interesting? Just discovered that I can pass a JSON object to `state` in provider interaction definition and then it is gonna be saved as JSON in a contract json file and then pact verifier reads it and passes a JSON object to /pactStateSetupUrl. So, no need to encode state into a string?

matt.fellows
2019-02-20 09:32
oh wow, magic! (I don?t really like magic, especially if that magic may have been written by me)

matt.fellows
2019-02-20 09:33
I?ll take a look later, hopefully that?s something that?s repeatable across languages and not a ?quirk? for JS only

hossam.saraya.ext
2019-02-20 09:41
Also wanted to add that testing in general against production servers is a bad idea because you don't want to add test data or delete existing data into/from your production data stores if you are not mocking/stubbing

mail
2019-02-20 11:03
has joined #general

oswald.quek
2019-02-20 12:17
:wave: is there a way to tell the pact broker to ignore certain consumers when using the can_i_deploy script (https://github.com/pact-foundation/pact_broker-client/blob/4a27c00e09f4512d539dedbc5c26518e29b8dde5/lib/pact_broker/client/can_i_deploy.rb)?

martin.green
2019-02-21 07:30
Hello, first of all, I love the concept of Pact and CDC?s. Well done! I?m really interested in hearing about peoples implementation of Pact into their company. Most documentation seems to be on tutorials, which is great. But I can?t seem to find much on people?s experiences with using Pact. What are the pain points? How long did it take to implement etc. Much appreciate any info

matt.fellows
2019-02-21 07:45
I'm a maintainer so I'm biased. I'll let the crowd answer and pop in later

vitaliy.grigoruk
2019-02-21 10:19
Hi @martin.green I?m currently implementing Pact in a company I?m working for (at the moment, we have 1 provider and a bunch of consumers). Integrating pact mockserver on the consumer side was quite easy and straightforward. Enabling pact contract verification on provider side took much more time for me, as we need to set up states on our provider side for each request + some of our provider endpoints require auth. While I was implementing provider verification, it turned that I had to refactor all interaction definitions on a consumer side (fix states, make sure that dynamic data is not hardcoded and relevant matchers are used).

lukas.mrtvy
2019-02-21 12:19
has joined #general

lukas.mrtvy
2019-02-21 12:20
Does Pact provide healthcheck or metrics endpoint for Prometheus?

vitaliy.grigoruk
2019-02-21 12:35
I think you need to ask this in #pact-broker @lukas.mrtvy

ramkhi
2019-02-21 14:51
has joined #general

martin.green
2019-02-21 15:08
Thanks very much for the reply @vitaliy.grigoruk

simon.nizov
2019-02-21 16:19
@martin.green What language are your services written in?

martin.green
2019-02-21 16:41
Hey @simon.nizov, the consumers are written in js and the backends are Scala

simon.nizov
2019-02-21 16:43
No tips from me then :)

oswald.quek
2019-02-21 16:44
hello. looking at https://github.com/DiUS/pact-jvm#supported-jdk-and-specification-versions, i take it pact doesn't support java 11 at the moment?

oswald.quek
2019-02-21 16:59
hi @martin.green some pain points i've found are: - the pact consumer js doesn't have the ability to set parameterised states for use with a pact java provider, for e.g. in https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-junit#provider-state-callback-methods `someProviderState(Map<String, Object> providerStateParameters)` - circular dependencies, for example changing a consumer pact without requiring a change of code on the provider side. we documented this in more detail at https://gdstechnology.blog.gov.uk/2019/01/29/lessons-learnt-using-contract-testing-in-gov-uk-pay/ - recently we had an issue where 1) there was a master build of a [provider] project built 2) someone came along and added a brand new consumer service that had a contract with said provider service on a pull request branch. this published the new pact to the pact broker 3) when the provider project was to be deployed to our staging environment, it failed because the "can-i-deploy" (https://github.com/pact-foundation/pact_broker-client/blob/4a27c00e09f4512d539dedbc5c26518e29b8dde5/lib/pact_broker/client/can_i_deploy.rb) check - which is a dynamic check on the pact broker - returned some `incompatible pacts` message as all of a sudden the pact broker had knowledge of this new consumer service so was expecting the new consumer service pact to be in the staging environment, but there was none. at this moment in time we can't get the "can-i-deploy" to ignore certain services. so be very careful when adding new services to the pact broker. - it's generally a bit more painful when updating pacts between services because we always use the "can-i-deploy" function before deploying a service so developers often have to think about the deploy cadence (i.e. what code changes on what services to deploy first)

oswald.quek
2019-02-21 16:59
but all in all the pain is worth it, otherwise we wouldn't be doing it :wink:

yousafn
2019-02-21 18:43
I have written up my first blog post about how we are utilising swagger & pact in our dev flow. Feel free to have a read https://you54f.wordpress.com

matt.fellows
2019-02-21 19:45
Great feedback! FWIW we?ll be addressing the workflow issues soon, I hope. This should make all but the first if not disappear, much easier to deal with

uglyog
2019-02-21 20:51
That is correct. Although some people have indicated they have used some of the libraries with Java 9+, you may have some issues that you?ll have to work around.

mike.key
2019-02-21 22:13
has joined #general

anmalik
2019-02-22 02:42
has joined #general

fil.calcutt
2019-02-22 07:59
has joined #general

martin.green
2019-02-22 09:10
Hey @simon.nizov I'd still be interested to hear any tips or experiences you've had. Regardless of the languages used. :slightly_smiling_face:

oswald.quek
2019-02-22 09:15
awesome!

oswald.quek
2019-02-22 09:22
:+1: we're actually going to try upgrading from Java 8 -> 11 and skip everything in between! will see how we get on.

vitaliy.grigoruk
2019-02-22 09:48
Hi @oswald.quek I?m also using JS on consumer side and to address item #1 from your list I?m just setting `state` field as a JSON array (following the format from pact spec v3: `[{ name: 'statename', params: { foo: 'bar', bar: 'buzz' }}]` which is then also stored as json array in a contract file. But, on a side of provider, I?m also using JS and a custom http endpoint for /pactStateSetupUrl. The payload I get to /pactStateSetupUrl is the same JSON array, I?ve provided in `state` during interaction definition on a provider side?

simon.nizov
2019-02-22 10:24
@martin.green I only just started honestly. A couple of months ago I presented Pact to the dev teams in our company and got a positive response. Since then I've been sort of forcing them to write any new unit tests of our api client classes using pact instead of VCR. This accumulated into a decent amount of interactions spread over 2 pacts between 3 services. Actually our front end team should have been the 3rd pact but they had some troubles integrating pact-js into their react+redux codebase (though they gave up after less than an hour due to more pressing issues). This week I finally published the pacts to our self hosted Pact Broker. The next step is to create an endpoint on each provider to setup the provider state.

wnek.piotr
2019-02-22 11:20
has joined #general

wnek.piotr
2019-02-22 11:25
Hello

wnek.piotr
2019-02-22 11:25
Is there a way to secure somehow pact-broker?

wnek.piotr
2019-02-22 11:26
I wonder, if I can to secure it using LDAP users

supraja.kr
2019-02-22 12:33
has joined #general

vitaliy.grigoruk
2019-02-22 13:16
here is where the fun part starts, @simon.nizov :slightly_smiling_face:

vitaliy.grigoruk
2019-02-22 14:08
Hi everybody. I?m looking for a way to get better test reports on a provider verification side. Currently, https://github.com/pact-foundation/pact-provider-verifier supports only a patched rspec formatter (default option), json and RspecJunitFormatter. We?re using default formatter and when 1 interaction out of 50 fails the output contains all the interactions, which is not very convenient. I?d like to have an option to see only failed interactions. Any suggestions?

m.r.green
2019-02-22 23:31
has joined #general


soap6gal
2019-02-24 11:53
has joined #general

m.r.green
2019-02-25 08:57
Really interesting to see your pipeline @oswald.quek. I assumed git branches would allow us to navigate around the circular dependency issues you mention, perhaps naively.

matt.fellows
2019-02-25 09:01
As a brief aside, whilst you can't _ignore_ certain consumers, you can do the opposite - list the ones you care about

matt.fellows
2019-02-25 09:01
Soon we'll have the ability to ignore the verification result if a new consumer (whilst still verifying it, providing feedback to the consumer). This should make things less disruptive to the provider team

m.r.green
2019-02-25 09:01
@matt.fellows any clue as to the work flow solutions you mention above? I?m doing a presentation to my company about Pact so be great hear any new features

matt.fellows
2019-02-25 09:03
I'll dig up the draft blog article that was to be published, that should give you an indication of what's to come

pravera
2019-02-25 14:31
hi! in our team we?re looking forward to implement pact nirvana


pravera
2019-02-25 14:32
very interesting btw!

pravera
2019-02-25 14:34
In our consumer build, we will need to check if it?s compatible with the production version of our provider. So the question is: as we do with the head versions, do we need to trigger a provider (production) build if the pact changes? So we can pact:verify and fill the matrix row for that Consumer-Provider?

kajan.siva
2019-02-25 14:49
has joined #general

nigel.hannam
2019-02-25 17:17
Hi all. In the pact spec 3 (https://github.com/pact-foundation/pact-specification/tree/version-3), the concept of generators was introduced. The spec document states: ?In some cases, dates and times may need to be relative to the current date and time?, but as far as I can tell, the Date related generators always use today rather than allowing for example today+1 . We have a provider endpoint that must be given a date in the future (i.e. AFTER today), and the generator concept seemed like a suitable way to handle it. Am I missing something in the generators, or is there some other recommended way to handle dates relative to today?

mboudreau
2019-02-25 22:58
Currently, the consumer is the one dictating the contract, hence you wouldn't be able to test your production provider on your consumer locally. We aim to change this behavior in pact to make it a lot more collaborative so that both sides should be testable at all times

mboudreau
2019-02-25 22:59
In your data, how is the date transferred as? a ISO8601 string? a unix timestamp?

abubics
2019-02-26 01:15
> do we need to trigger a provider (production) build if the pact changes? Not a build, but a verify (especially for consumer changes). And there's a webhook to trigger such verify CI processes :slightly_smiling_face:

uglyog
2019-02-26 05:56
The idea was to allow different types of generators, but only ones that generate dates based on the current clock have been implemented. It should not be hard to implement what you need.

nboyd
2019-02-26 09:32
has joined #general

nigel.hannam
2019-02-26 09:39
dates are indeed ISO8601 strings. The other approaches we have considered (but don?t particularly like) are: 1) Using a date that?s a long way in the future 2) Using a TargetRequestFilter on the provider side to override the date in the pact 3) Using a provider state to configure a fixed clock on the provider side (effectively overriding what date is ?today?

nigel.hannam
2019-02-26 09:40
Is it possible for us to add our own generators, or do they need to be provided as part of the pact libraries?

damien.castelltort
2019-02-26 16:36
has joined #general

franckxcode
2019-02-26 16:39
has joined #general

smridula2845
2019-02-26 19:37
has joined #general

smridula2845
2019-02-26 19:52
Hi .. I am a newcomer to the contract testing world and I am noticing an issue with my consumer test run. All my matching rules are ignored and the test fails by trying to match the exact value. Details Posted in the thread.

smridula2845
2019-02-26 19:53
```WARN: Ignoring unsupported matching rules {"$.entitlements"=>{"matchers"=>[{"match"=>"type", "min"=>2}], "combine"=>"AND"}, "$.entitlements[*].entitlementStartDate"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].entitlementEndDate"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].parentFeatureId"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].featureId"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].featureName"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].featureType"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].entitlementType"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].userType"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].meteringType"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].active"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].source"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}, "$.entitlements[*].orderOrigin"=>{"matchers"=>[{"match"=>"type"}], "combine"=>"AND"}} for path ['body']```

smridula2845
2019-02-26 19:53
Json in pact file

smridula2845
2019-02-26 19:53
```"body": { "entitlements": [ { "entitlementEndDate": "string", "meteringType": "string", "parentFeatureId": "string", "featureName": "string", "featureType": "string", "orderOrigin": "string", "active": true, "userType": "string", "source": "string", "entitlementType": "string", "featureId": "string", "entitlementStartDate": "string" }```

smridula2845
2019-02-26 19:56
npm error log

smridula2845
2019-02-26 19:56
```4 verbose stack Error: e2e@1.0.0 test:provider: `mocha test/provider.spec.js` 14 verbose stack Exit status 1 14 verbose stack at EventEmitter.<anonymous> (/Users/sasikum/.nvm/versions/node/v6.10.3/lib/node_modules/npm/lib/utils/lifecycle.js:255:16) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at EventEmitter.emit (events.js:191:7) 14 verbose stack at ChildProcess.<anonymous> (/Users/sasikum/.nvm/versions/node/v6.10.3/lib/node_modules/npm/lib/utils/spawn.js:40:14) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at ChildProcess.emit (events.js:191:7) 14 verbose stack at maybeClose (internal/child_process.js:886:16) 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5) 15 verbose pkgid e2e@1.0.0 16 verbose cwd /Users/ssss/Automation/contract-tests 17 error Darwin 17.7.0 18 error argv "/Users/sss/.nvm/versions/node/v6.10.3/bin/node" "/Users/sss/.nvm/versions/node/v6.10.3/bin/npm" "run" "test:provider" 19 error node v6.10.3 20 error npm v3.10.10 21 error code ELIFECYCLE 22 error e2e@1.0.0 test:provider: `mocha test/provider.spec.js` 22 error Exit status 1 23 error Failed at the e2e@1.0.0 test:provider script 'mocha test/provider.spec.js'. 23 error Make sure you have the latest version of node.js and npm installed. 23 error If you do, this is most likely a problem with the e2e package, 23 error not with npm itself. 23 error Tell the author that this fails on your system: 23 error mocha test/provider.spec.js 23 error You can get information on how to open an issue for this project with: 23 error npm bugs e2e 23 error Or if that isn't available, you can get their info via: 23 error npm owner ls e2e 23 error There is likely additional logging output above. 24 verbose exit [ 1, true ] ```

sthan
2019-02-26 20:23
Hi. I am also new to contract testing and trying to create a POC for our http://ASP.NET WebApi application. I've been following the code example in your PactNet repo. I've been able to create working Consumer tests, but I'm having a bit of trouble creating the Provider test. We have a Global.asax.cs which starts the Provider application like this: public class WebApiApplication : System.Web.HttpApplication { protected void Application_Start() { Common.NetworkingHelper.ConfigHttpTlsLevel(); DependencyConfig.Configure(GlobalConfiguration.Configuration); WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalConfiguration.Configuration.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); GlobalConfiguration.Configuration.Formatters.Add(new System.Net.Http.Formatting.XmlMediaTypeFormatter()); } } But the example code in PactNet uses OWIN Hosting to start the application. I'm not sure how to reconcide the difference. Can you provide some helpful documentation that will help. An example code would also be very useful.

uglyog
2019-02-26 22:28
It was designed to allow generators to be looked up, but the only implementation at the moment uses a hard coded package. This just needs to be extended so you can supply your own. Which implementation are you using?

matt.fellows
2019-02-26 23:47
Thanks @smridula2845, could you please share your code? That will probably help us understand why the matching rules aren?t working

matt.fellows
2019-02-26 23:48
hiya! Might be best asking in the .NET channel. This looks more of support about .NET than Pact itself, but I?m not sure as I?m not familiar with that language

sthan
2019-02-26 23:53
Thanks. didn't realize there was a separate channel.


matt.fellows
2019-02-27 00:01
Js doesn?t support v3 of the pact specification (assume you?re using Pact JVM as the consumer?)

matt.fellows
2019-02-27 00:02
So it doesn?t support the `combine` matchers

mboudreau
2019-02-27 00:03
did you create the JSON by hand?

smridula2845
2019-02-27 00:14
no i didnt create the Json by hand. I wrote consumer side code

smridula2845
2019-02-27 00:15
```@Pact(provider = "lemService",consumer = "portal") public RequestResponsePact createPact(PactDslWithProvider builder) { PactDslJsonBody body = (PactDslJsonBody) new PactDslJsonBody() .minArrayLike("entitlements",2) //.object() // Throws exception .stringType("entitlementStartDate") .stringType("entitlementEndDate") .stringType("parentFeatureId") .stringType("featureId") .stringType("featureName") .stringType("featureType") .stringType("entitlementType") .stringType("userType") .stringType("meteringType") .booleanType("active") .stringType("source") .stringType("orderOrigin") .closeObject() //.closeObject() .closeArray(); return builder .given("valid oxygenId ") .uponReceiving("get entitlement call") .path("/service/lem/v2/admin/aaaaa/entitlements") .method("GET") .matchQuery("includeRelationships", "true") .matchQuery("source","pelican,legacy") .matchQuery("guid","201606300402219") .willRespondWith() .status(200) .body(body) .toPact(); } ````

smridula2845
2019-02-27 00:15
this is the gist of the code i had to create the pact

smridula2845
2019-02-27 00:16
is there an example of JVM V2 pact specification i can use ?

mboudreau
2019-02-27 00:17
isn't your consumer javascript? Why is the DSL written in java?

smridula2845
2019-02-27 00:22
our consumer is java based not JS

smridula2845
2019-02-27 00:24
should we move the provider tests also to Java ?

smridula2845
2019-02-27 00:25
what is the recommendation

matt.fellows
2019-02-27 00:27
is the provider written in java or JS? If it?s written in JS that?s totall yfine

matt.fellows
2019-02-27 00:27
so you have a Java consumer and a JS provider?

matt.fellows
2019-02-27 00:28
You are fine to use the Java DSL for your java consumer, but you need to ensure that Pact JVM is serialising the pacts in v2 specification

smridula2845
2019-02-27 00:28
yes ..

smridula2845
2019-02-27 00:28
How do i serialise to v2 ?


matt.fellows
2019-02-27 00:29
You?ll need to use the 2.4.x version of Pact

smridula2845
2019-02-27 00:30
Thank you. I will change the version and get back .

smridula2845
2019-02-27 00:30
Thank you for spending time !

nigel.hannam
2019-02-27 12:13
Currently using a mixture of pact-js and pact-jvm for consumer side, and pact-jvm (spring) for provider side. If this were to be extended so that we could provide our own generators, would both the consumer and provider side need an implementation? It would add overhead if it needed to be implemented for all types of consumer, and it kinda seems like the consumer side only needs to allow the generator to be specified without necessarily needing to use an implementation of it

sgleadow
2019-02-27 21:47
I saw Pact mentioned in a Nordic APIs article this morning :slightly_smiling_face:, for websockets no less, I haven't tried it in that scenario https://nordicapis.com/functional-contract-testing-a-case-study/

matt.fellows
2019-02-27 22:43
It?s awesome to see this sort of blog, but if I?m honest, I?m not sure the message conveyed in it is very clear. Perhaps it?s a non-native English speaker/writer, but a lot of it didn?t make sense to me, so I?m sure it woudn?t make sense to others. I need to watch the video, i?m guessing the article is a summary of the video which perhaps hasn?t done a great job of distilling the key points.

bethskurrie
2019-02-27 22:44
@oswald.quek I've just been working on the "can't 'deploy the provider because the consumer isn't deployed to the environment' circular issue.

bethskurrie
2019-02-27 22:44
It should be fixed soon.

brendon.flanagan
2019-02-27 23:01
has joined #general

uglyog
2019-02-27 23:15
Pact-js only supports spec V2. Generators are V3. Generators can be applied to both the request and response. If you only care about applying them to the response, then what you have said is correct.

uglyog
2019-02-27 23:16
I'll have some time this weekend, I'll look to add the expression to them in pact-jvm

shekharsp27
2019-02-28 06:26
As per my understanding, the concept of PACT has been used to implement contract testing using 'Erlang'. And there is no use of PACT to implement contract testing. Please correct me if I am missing something here.

matt.fellows
2019-02-28 06:31
you may well be right

matt.fellows
2019-02-28 06:32
Perhaps that?s why it didn?t make sense to me, but I suspect otherwise

brendon.flanagan
2019-02-28 07:20
Hi there, does anyone who knows what Datapower is (IBM gateway devices), if you?ve successfully implemented a solution using Pact ? I?d be interested to know as I?m in the process of understanding pact now and from what I can tell thus far is that it?s currently not possible. Even though datapower runs nodejs under the covers, it?s not the complete implementation and you just can?t go installing node modules onto it and issue node commands. I think I might have a way to achieve this using datapower still but interested to know if anyone else has struck this.

punarjit.singh
2019-02-28 08:38
has joined #general

mboudreau
2019-02-28 09:07
Instead of using the node package, you could always just use the base Ruby binaries instead for all your pact testing

nigel.hannam
2019-02-28 09:10
:+1:

nigel.hannam
2019-02-28 09:11
Do we know if/when pact-js is likely to support V3?

matt.fellows
2019-02-28 10:51
I know of datapower (came across it working at Bank)

matt.fellows
2019-02-28 10:52
are you looking at it from a consumer/provider perspective?

matt.fellows
2019-02-28 10:53
As Michel said, even if you can?t run the unit tests integraated into Datapower, you can still write both consumer and provider tests and execute it remotely (via a ruby CLI toolo)

oswald.quek
2019-02-28 13:34
nice. let me know when there's a new version of the pact broker!

uglyog
2019-02-28 21:09
Depends on when someone implements it, probably in ruby. There is no plan that I?m aware of

me1
2019-02-28 22:50
has joined #general

punarjit.singh
2019-03-01 03:07
Hi there... how are we supposed to pass request parameters in Pact Verifier ? are there any opts or do we need to use requestFilters... ?

bethskurrie
2019-03-01 03:09
Hi @punarjit.singh. Welcome to the pact slack group. Please ask your question in the channel for the relevant language.

punarjit.singh
2019-03-01 03:09
Hi @bethskurrie sure... will join the channels .. thanks

brendon.flanagan
2019-03-01 06:12
Looking at it from a consumer perspective first. Didn?t know about ruby cli toolo so will look into that.


matt.fellows
2019-03-01 06:25
That?s a very crude summary of what the wrapper libraries do

brendon.flanagan
2019-03-01 06:37
Not quite sure how datapower fits in here just yet. The train of thought I am having was a client tool that kicks off the tests under a pact control, the actual client request message goes to the datapower service, that service does xyz and sends to the provider endpoint which would be back to the pact client tool, which will validate against the pact file pulled from the pact broker (local to start off with) send back the pact response all the way back though the datapower service, thus confirming the success or failure against the pact. Note still yet to fully understand what pact does, but I think I?m close. This also means nothing extra has to be deployed with the service on datapower. As we already alias out our endpoints so in a lab environment, the endpoint would be to pact thing and not a real provider which typically doesn?t exist in a lab setup.


matt.fellows
2019-03-01 07:00
TL;DR You only want to test 2 layers at a time in a contract test.

lextiz
2019-03-01 09:15
has joined #general

kristoffer.bakkejord
2019-03-01 13:40
has joined #general

pltran875
2019-03-01 18:28
has joined #general

thirumal.net
2019-03-01 19:14
Hi All, we did poc on pact and it is going to work well in our system but unfortunately my dev teams are not ready to adopt it due to project dead lines ..etc so i am wondering is there any way i can do contract testing with out touching production code base. i know it defeats the purpose of pact if we are not writing unit test cases in production code but i am wondering is there any tool/approach i can use to get the same flavour of contract testing. i am from QA team and did poc on pact and understood the value of it . i would like to use the power of pact broker but dont have access to write unit test cases in production so searching for alternatives which will follow similar pact steps Thanks in advance

matt.fellows
2019-03-01 19:59
Is this for the consumer side, provider side or both?

thirumal.net
2019-03-01 22:39
Hi @matt.fellows - Thank you for looking into query, actually it is for both . i am still pushing hard to implement pact at least from one side(consumer or provider) to show the value of it , but not sure whether i will succeed or not . please guide me if there is any alternative if we implement one side(consumer or provider) vs not implementing both sides

mboudreau
2019-03-02 00:37
It's easy to start on the consumer side as the consumer often already needs a mock of some kind for testing, pact gives the added benefit of generating contracts based on those mocks which can be used to test the producer, but really soonest have to straight away

mboudreau
2019-03-02 00:38
On the producer side, you can do the same thing by creating a contract by hand or with a tool to test what's expected front the consumer

saiarunlak
2019-03-02 13:52
has joined #general

uglyog
2019-03-03 02:41
I've updated to Pact-JVM generators to be loaded from a configured package, so you should be able to add your own. I did not get enough time to add the expressions yet.

ngrigoriev
2019-03-03 20:16
has joined #general

sven
2019-03-03 22:28
has joined #general

nigel.hannam
2019-03-04 09:48
Thanks for looking at this. Unfortunately, without support for the generators in pact-js we can?t use them for our biggest consumer, so we will probably have to stick with one of existing workrounds for now

oswald.quek
2019-03-04 11:18
@uglyog is getting pact to work with Java 11 on your radar for the future? i guess with Java 8 and 9 not being supported many teams will be looking to upgrade

thirumal.net
2019-03-04 18:45
@mboudreau - Thank you for your response. how can i start from consumer side ,you mean to say create the json file(Contract ) from pact libraries or create json file(contract ) from any third party tools ? my scenario is i have swagger/API Blurprint , wondering how can i create contract file out of it so that i can publish the file to pact broker

bhoyt
2019-03-04 18:48
has joined #general


yousafn
2019-03-04 21:16
You don?t need your actual consumer to exist to create a consumer test. You look at your swagger api, define a test ( what you expect to receive which might not be everything the response returns), register this interaction in your mock pact provider. Create the test in your unit test language of choice and run it. It creates a pact contract which you can publish to the broker

yousafn
2019-03-04 21:17
You can then use the tool suggested above to validate the pact contract is valid when compared to the swagger spec

yousafn
2019-03-04 21:19
I am using it to prove the case you are talking about, my provider still isn?t ready 5 months on. I wrote a blog post about it recently using swagger and pact https://you54f.wordpress.com/2019/02/19/protecting-your-api-development-workflows-with-swagger-openapi-pact-io/

thirumal.net
2019-03-04 21:39
@yousafn - Thank you very much for your help on this scenario . i will go through your blog and let you know if i have any questions. Thank you again for your help

yousafn
2019-03-04 23:36
Btw you can?t create pact contracts from a swagger api specification. It lists the operations a service can provide but doesn?t convey the expectations of a consumer, and you can?t infer those automatically. You can still use it as a testing tool even if you aren?t using as part of your development flow, but it offers many dev flow benefits. If only one side implements it, it can still protect you, to can run it against each new release of your dependencies or dependants, and see if the contract still holds water, if not sound the alarm bells. The pact broker still works well in that instance. I will implement the providers tests in my pipeline list against their developed service, the provider for me doesn?t really need to do anything, as long as I have agreed some test cases that have some defined data I can use.

yousafn
2019-03-04 23:37
But api development is much better with collaboration so get them all to feel the pact :heart:

thirumal.net
2019-03-04 23:46
@yousafn - Thank you, Yes, we can't create pact files from swagger specification . initially i was under impression that there might be tool available to convert swagger to pact contract but i don't think we can do that right now. between i like the idea of running one unit test project in isolated environment and generate pact file from expected request/expected response from consumer side . only thing missing here is we are not syncing with production code base and depending on some documentation

mboudreau
2019-03-05 00:02
@thirumal.net you wouldn't want to do that anyways since it would make pact useless if all it does is imitate swagger definitions since it doesn't actually precisely show the interactions between the consumer and the provider

mboudreau
2019-03-05 00:02
however, I feel like there's an opportunity to make it a bit easier to generate the pact contracts from a swagger definition file

brendon.flanagan
2019-03-05 09:51
Been doing some more reading and I'm pretty confident I think I know how I can make this work with Datapower involved to ensure the datapower service is doing what is expected where transformation is invovled, or is not altering what is expected where the service is a proxy. But theres one thing I don't fully understand. So as I understand, the consumer is the one that generates the pact file, which obviously can be shared with the provider, nominally via a pact broker. This is thus the contract. Meaning the provider is free to do what they want with their code, so long as it still passes against the published contract. Now what I don't understand is, if the consumer makes a change to their app, thus a new pact file is generated, with part of that change being what is expected by the provider, means, that once published to the broker, will break the provider. Meaning the consumer has now gone and dictated that the provider has to change ? So to me, the consumer controls the contract outright. Whereas I originally had thought that the consumer would also pull the pact file from the broker to validate against, just like the provider would. Does that sound right ? have I missed something (this being based on what I've read several times over where consumer generates and publishes a pact file to a broker, and where the provider pulls from the broker to validate against) ?

mboudreau
2019-03-05 10:09
That's correct, but only if the provider is testing on the latest contract all the time. The way we recommend you do it is that you tag your contacts based on the environment or the feature your working on, which is then tested based on the tag on the provider side

mboudreau
2019-03-05 10:11
For instance, you should test to make sure whatever you're changing to your provider needs to pass the "production" contract (what's currently deployed), but if you're working on a new feature and the contract is already created from the consumer but hasn't been deployed yet, you can test it based on the same tag

mboudreau
2019-03-05 10:11
Does that make sense?

khaled.hamlaoui
2019-03-05 12:22
has joined #general

thirumal.net
2019-03-05 21:47
@mboudreau -Thank you for your reply but i am still wondering how it is possible to generate pact file from swagger definition so that i can push the same pact file(json) to pact broker ? my assumption is , we can generate pact file from test project with the help of pact library so that it exactly looks like pact flow except calling real production code base . if there is already tool avilable to convert swagger file to pact file then i think no need to create test project to generate pact file . is my assumption correct ? Thank you in advance


matt.fellows
2019-03-05 22:22
this can?t be done

matt.fellows
2019-03-05 22:23
But we are exploring how we integrate swagger into the broker. If that?s of interest to you perhaps we can talk about that

yousafn
2019-03-06 01:13
That sounds like a great idea, as they compliment each other well. My 2p :) I think if you can allow the upload of a swagger api definition registered as a provider, each client that register that they use that api definition. On publish of a swagger file, you can run ?swagger-cli validate? to ensure the swagger is valid. On publish of a client pact contract, it can evaluated against the swagger spec with swagger-mock-validator On new publish of a swagger definition, it could be checked against existing contracts, and mark consumer versions as compatible, or provide a matrix of compatible consumer versions.

matt.fellows
2019-03-06 03:08
Your two cents are? very compatible with our thinking :smile:

asad
2019-03-06 12:23
has joined #general

steve.perkins
2019-03-06 15:46
has joined #general

krzysztof.stepniak
2019-03-07 10:30
has joined #general

stefan.deussen
2019-03-07 12:04
has joined #general

stefan.deussen
2019-03-07 12:22
Hello everybody! I was wondering what the best strategy for writing the tests on the provider side is. Currently we are mocking on the service layer. This makes the tests very robust and easy to write. One the other hand there is no guarantee, that the real implementation is returning the same response as the mock implementation. So what would you recommend? Mocking as much as possible to get small and robust tests or mocking as little as possible to have more confidence on the tests?

keetron
2019-03-07 12:31
mock as much as possible, you are testing the API, not the service behavior

aidamanna
2019-03-07 14:36
has joined #general

phil.a.herbert
2019-03-07 15:57
has joined #general

timepasstimepass1234
2019-03-08 12:33
has joined #general

timepasstimepass1234
2019-03-08 12:45
I am new to Java and to PACT I am getting an error while writing the provider test for an API 0) return BIOS Details returns a response which has a matching body comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain' Verifying a pact between BiosProOnLoad_consumer and BiosProOnLoad_provider Given BIOS OnLoad return BIOS Details MockHttpServletRequest: HTTP Method = GET Request URI = /rest/v1/biospro/onload/component/1234 Parameters = {} Headers = {cid=[2], Accept=[application/json], } Body = <no character encoding set> Session Attrs = {} Async: Async started = true Async result = <200 OK,{"BIOS_Settings": "BIOS_Settings","duration" : 3},{}> Resolved Exception: Type = null ModelAndView: View name = null View = null Model = null FlashMap: Attributes = null MockHttpServletResponse: Status = 200 Error message = null Headers = {} Content type = null Body = Forwarded URL = null Redirected URL = null Cookies = [] [DEBUG] [main 08 Mar 2019 15:53:50] (IndyInterface.java:selectMethod:232) Received response: 200 [DEBUG] [main 08 Mar 2019 15:53:50] (IndyInterface.java:selectMethod:232) Response: [statusCode:200, headers:[:], contentType:application/json; charset=UTF-8, data:] returns a response which has status code 200 (OK) has a matching body (FAILED) Failures: 0) return BIOS Details returns a response which has a matching body comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain'

timepasstimepass1234
2019-03-08 12:48
Can someone help me understand why this may be happening? I have sent the response headers for pact as application/json but it does not show up in pact file..Is that the problem?

timepasstimepass1234
2019-03-08 12:49
Or is it because the response body is null?

hamzahuk
2019-03-09 10:34
has joined #general

timepasstimepass1234
2019-03-10 19:55
My controller call is returning result in DeferredResult format. MockMvcTarget returns the result without waiting for async process. How to async option to pact through PactDslWithProvider builder in java?

matt.fellows
2019-03-10 21:29
The error message is pretty clear there, it was expecting json but didn't get it. Perhaps you could come share more of your code. The headers map looks empty too

matt.fellows
2019-03-10 21:29
Might want to ask in the #pact-jvm channel

thomas.koppensteiner
2019-03-11 14:57
has joined #general

luca.ippolito
2019-03-12 08:27
has joined #general

luca.ippolito
2019-03-12 08:50
Hi there! I've got a question regarding the execution order of provider states, couldn't find anything elsewhere about this. So, let's assume in a contract are the following states configured for a testcase: "providerStates": [ { "name": "service has student", "params": { "id": 1, "firstName": "John", "lastName": "Doe" } }, { "name": "student has grade", "params": { "subject": "Mathematics", "grade": "A" } } ] The expected result by the consumer for this testcase would be "student": { "id": 2, "firstName": "John", "lastName": "Doe", "grades": [ { "subject": "Mathematics", "grade": "A" } ] } When executing this testcase as a provider, I noticed that the execution order of the provider states is reversed, so instead of executing the provider states in this order on the provider side: 1. service has student 2. student has grade The states are getting executed like this: 1. student has grade 2. service has student Can anyone explain me, why the execution order is inverted? Because of that, on the provider side we are implementing something like a "reverse builder pattern" to setup the object that needs to be returned. What would be a better approach on this? I know, a possible answer would be "just use one provider state instead", but I would like to allow multiple consumers to use the same states and they should be able to create their own expected result value, so my key requirement is the usage of multiple paramterized states. Another possible solution would be to tell the consumer that he should invert the order of the provider states on his side, but that does not make that much sense to me. I think, it is more logical to set the provider states like this: .given("service has student", studentParameters).given("student has grade", gradeParameters) instead of setting the states up like this: .given("student has grade", gradeParameters).given("service has student", studentParameters) Thanks in advance for your feedback!

bethskurrie
2019-03-12 09:02
Hi Luca. You'll need to ask in the channel for your language

bethskurrie
2019-03-12 09:03
I would have expected them to be called in the other they were defined.

bethskurrie
2019-03-12 09:03
Petty sure the Ruby impl does, so I'm guessing you have a jvm implementation.

ghandour.jihad
2019-03-12 09:30
has joined #general

mestrez.matthieu
2019-03-12 09:42
has joined #general

luca.ippolito
2019-03-12 09:51
Hi Beth, thanks for your response. I'm using java, so #pact-jvm would be correct than?

matt.fellows
2019-03-12 10:10
yep

matt.fellows
2019-03-12 10:10
Is it always returning it that way, or just often? Might be implement as an unordered type under the hood

bethskurrie
2019-03-12 10:27
That would surprise me.

matt.fellows
2019-03-12 10:36
Indeed, I?m probably going into bug finding mode here

luca.ippolito
2019-03-12 11:56
It looks consistent to me, as far as i can tell. An interaction with the following provider states configured: "providerStates": [ { "name": "stateOrderExample", "params": { "order": "1" } }, { "name": "stateOrderExample", "params": { "order": "2" } }, { "name": "stateOrderExample", "params": { "order": "3" } }, { "name": "stateOrderExample", "params": { "order": "4" } }, { "name": "stateOrderExample", "params": { "order": "5" } } ] While the corresponding method in the provider implementation looks like this: @State("stateOrderExample") public void stateOrderExample(final Map<String, Object> params) { log.debug((String) params.get("order")); } Returns this consistently: 2019-03-12 12:52:57.450 DEBUG traceId= spanId= parentSpanId= reqId= clientId= [c.s.b.d.s.p.ProviderTest] (main) 5 2019-03-12 12:52:57.450 DEBUG traceId= spanId= parentSpanId= reqId= clientId= [c.s.b.d.s.p.ProviderTest] (main) 4 2019-03-12 12:52:57.450 DEBUG traceId= spanId= parentSpanId= reqId= clientId= [c.s.b.d.s.p.ProviderTest] (main) 3 2019-03-12 12:52:57.450 DEBUG traceId= spanId= parentSpanId= reqId= clientId= [c.s.b.d.s.p.ProviderTest] (main) 2 2019-03-12 12:52:57.450 DEBUG traceId= spanId= parentSpanId= reqId= clientId= [c.s.b.d.s.p.ProviderTest] (main) 1 I am using the following dependencies by the way: <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-junit_2.12</artifactId> <version>3.6.2</version> <scope>test</scope> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-spring_2.12</artifactId> <version>3.6.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.swisscom.cdc.pact</groupId> <artifactId>pact-jvm-provider-junit-spring-boot</artifactId> <version>3.6.0-rc.0.0</version> <scope>test</scope> </dependency>

aditya_pradeepkumar
2019-03-12 15:25
has joined #general

lauren.borodajko
2019-03-12 15:41
has joined #general

timepasstimepass1234
2019-03-12 19:20
Hi Matt Thanks for your reply.. My controller looks something like this DeferredResult<ResponseEntity<?>> deferredResult = new DeferredResult<>(deferredResultTimeout); CompletableFuture.supplyAsync(() -> { try { return new ResponseEntity<String>(<some function call>), HttpStatus.OK); } catch (Exception exception) { return restResponseException.parse(exception);} }) .whenCompleteAsync((result, throwable) -> deferredResult.setResult(result)); return deferredResult; This Async call is what is failing the provider test for me... When I remove the async call and make the function call directly in controller Provider test will pass If you look at the response the body we are expecting is in asyncResult at the top..Is there a way to tell provider to assert/verify on asyncResult and not body OR bring the asyncResult into body

arian.maykon
2019-03-13 03:41
has joined #general

msc.consults
2019-03-13 09:31
Hi, I've been looking at writing a contract test that asserts a response when the provider service is unavailable. It ran on the provider side and failed as the service was in-fact up and running. Thinking about this, it doesn't feel like a valid test, as... when the service is unavailable, a `HTTP STATUS 503` is returned, therefore why would I need a contract test for this? I'm deciding to remove this test, however what were your thoughts on this?

matt.fellows
2019-03-13 09:34
I typically don't test 503s, because by definition they tend to be hard to produce in an actively deployed mode

matt.fellows
2019-03-13 09:34
I'm also keen to hear others thoughts

msc.consults
2019-03-13 10:05
I also have another thought *(up for debate)* if a consumer is planning to add restrictions to their service to ensure (let say a bad `POST` request cannot be made to the provider), is there still any value in a contract test being in place that exercises an invalid schema scenario?

abubics
2019-03-13 10:16
You really want to test the intended interactions that your API client exposes, that get marshalled/unmarshalled from/to domain entities. That's the highest value stuff. If you have other expected failures (e.g. re-deleting the same ID accidentally), they're lower value, but worth testing if you have had some real bugs that you want not to regress. Things like 503s may make sense for another kind of testing, not so much contact testing :)

abubics
2019-03-13 10:17
To your question, if you have an API client that doesn't let you send the wrong thing, then I wouldn't worry about forcing unhappy path tests.

oswald.quek
2019-03-13 10:28
hello, am needing some help on the pact broker! some slightly pressing questions. i posted in #pact-broker but didn't get a response. It's a bit of a bottleneck in our deployment pipeline as I think there is too much data in its database. I'm seeing the database used by the pact broker hitting 100% frequently. 1) i'm not sure how to tell which version of the pact broker I have - is there a way to do this? 2) will upgrading to version 2.18.0 help? i see from https://github.com/pact-foundation/pact_broker/blob/master/CHANGELOG.md#v2180-2018-04-05 there is a feature to "add rake task to clean unused data to improve performance". that said v2.18.0 was released 2018/04/05 and that's approximately when the pact broker became a thing in our pipeline 3) is there an endpoint on the pact broker to delete old data?

oswald.quek
2019-03-13 10:34
@bethskurrie?

mboudreau
2019-03-13 11:03
if the pact broker DB is hitting 100%, there must be an issue with that DB. Is it out of storage? Memory? I mean, unless it's getting hit constantly by the broker, I don't see how this is possible

mboudreau
2019-03-13 11:03
and if it is being hit constantly, then are you getting DDoS'ed?

oswald.quek
2019-03-13 11:13
yes i guess we can upgrade the CPU. but we upgraded it just last week and i want to make sure it isn't anything to do with exponential pact verifications between services

oswald.quek
2019-03-13 11:13
no we aren't getting DDoS'ed

oswald.quek
2019-03-13 11:17
it's preferable to delete data. it's inconceivable we are going to have to deploy months-old versions of our services - we don't need those verifications anymore

msc.consults
2019-03-13 11:19
thanks @matt.fellows @abubics for both of your inputs

davidjgmendes
2019-03-13 11:38
has joined #general

mboudreau
2019-03-13 12:00
I mean, it could be. I haven't played around enough with the broker to know what it's doing behind the scene, just trying to think about it from the DB perspective

mboudreau
2019-03-13 12:01
I mean, if you were to go into the admin for the DB, it would become clear easily enough as to why it's hitting 100%

ghandour.jihad
2019-03-13 12:35
Hello Everyone :slightly_smiling_face: I am new to the PACT world and trying to explore it, looking great sofar :slightly_smiling_face:. I am trying to have a pact that expects as a return "body": [ { "firstName": "Emma", "familyName": "Smith" }, { "firstName": "Marc", "familyName": "Johnson" } ] The provider does return this body, but at times Marc would be before Emma. How can I for java ignore the order? https://docs.pact.io/getting_started/matching is Ruby DSL, and can't find the java version. Any help is very appreciated.

alisdaircole
2019-03-13 16:29
has joined #general

yousafn
2019-03-13 16:59
surely the ordering isn?t important if it can change request by request? In that case shouldn?t you just be checking that you get an array of objects with two key/value pairs, of which the value is a string? I assume if the ordering is important (ie you need it alphabetical order) you either get the provider to ensure that the endpoint is deterministic or your consumer takes the response and sorts it before doing something with it

pkuang
2019-03-13 19:41
Hi, does the pact verifier not automatically uncompress responses from the provider if it includes a 'content-encoding: gzip' header?

yousafn
2019-03-13 19:54
Here is our broker at work, there are 4 consumers and 2 providers, over a 30 minute period. it is very similar across a 3 month range.

yousafn
2019-03-13 19:55
It is a postgres instance exclusively for the pact-broker. Is your DB only for the broker?

bethskurrie
2019-03-13 20:45
@oswald.quek I would advise upgrading as there were some major improvements done to optimise the matrix queries.

bethskurrie
2019-03-13 20:45
It may well be responsible for the high usage you're seeing.

bethskurrie
2019-03-13 20:47
There is a clean task, but it is not currently working. The main problem when I was writing it is, knowing which data is safe to clean is dependent on how each company uses their broker (eg tags, verifications etc)

bethskurrie
2019-03-13 20:49
@oswald.quek you can see which version of the broker you have by looking at the response headers - there is an X-Pact-Broker-Version header.

abubics
2019-03-13 21:36
Pact isn't so much for checking specific content, but more for verifying content shape. If there's a material significance to the order, I'd suggest making that more apparent on the interface, or asserting it in unit tests on the provider side :) To ensure the content shape (in a Pact idiomatic way), use `eachLike` :ok_hand:

abubics
2019-03-13 21:37
Also, if you have JVM-specific questions, you can take them to #pact-jvm for better help ^^

mboudreau
2019-03-13 22:20
that's a good question...

matt.fellows
2019-03-13 22:42
I recall this coming up in a discussion somewhere on github (perhaps the pact specification repository) or pact js


ghandour.jihad
2019-03-14 08:37
thanks a lot guys!!!

ghandour.jihad
2019-03-14 11:03
I will continue this thread here, then any other jvm question will send it on the other channel :slightly_smiling_face: I tried to use eachLike, but it looks like it works only for children of a specific parent with name. My object: { "firstName": "Emma", "familyName": "Smith" } Is not the child of anything, so any use of eachLike(name , ...) will result in adding a parent to the object :confused: .willRespondWith() .body(new PactDslJsonBody() .eachLike(2) .stringType("firstName", "Emma") .stringType("familyName", "Smith") it didn't work, and when I use .eachLike("Any name",2) which is a supported form, I will have Any name the parent of my object :confused:

oswald.quek
2019-03-14 13:58
cool thanks. yeah our version is quite recent - 2.27.6. we've managed to resolve our issues by deleting data older than a certain date in the database.

pkuang
2019-03-14 14:47
Thanks, I saw the issue but was hoping support had been implemented since then but I guess not. I can understand the reasoning behind it though.

matt.fellows
2019-03-14 20:47
:+1:

abubics
2019-03-14 23:37
are you using Java or Kotlin? this DSL is very hard for me to read :stuck_out_tongue: I have examples of nicer object blocking with Kotlin in #pact-jvm


abubics
2019-03-14 23:42
Aside from that, I'm not familiar with any `eachLike` or `minArrayLIke` that lets you specify multiple entities with different content.

abubics
2019-03-14 23:43
So, back to my original point, it's not really for verifying content. What is the interaction you're trying to test?

abubics
2019-03-14 23:44
maybe you want `minArrayLike` :slightly_smiling_face:

abubics
2019-03-14 23:44
it's listed with `eachLike` in the docs here: https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-consumer

priyasilverback
2019-03-15 00:47
has joined #general

vitaliy.grigoruk
2019-03-15 08:11
Hi everybody. What is the biggest argument against using pact for browser acceptance tests of a frontend application (in order to replace a real API server with pact mockserver)?

bethskurrie
2019-03-15 08:21
Maintainability of the provider verifications.


vitaliy.grigoruk
2019-03-15 08:34
thanks! But we still need to have some kind of mocking of our API when we run browser tests for our front-ends. Any suggestions?

bethskurrie
2019-03-15 08:36
You can use the pact file to start up a mock server locally.

bethskurrie
2019-03-15 08:36
Stub server rather

bethskurrie
2019-03-15 08:36
It's a pretty dumb stub though.

vitaliy.grigoruk
2019-03-15 08:37
ok, but in this case I need to make sure that my contract still contains all the interactions that I need for my tests to run.

bethskurrie
2019-03-15 08:37
Yes.

bethskurrie
2019-03-15 08:37
It's not ideal.

vitaliy.grigoruk
2019-03-15 08:38
so, it is basically the same as using pact mockserver when running browser test for the frontend, except that I don?t need to explicitly define pact interactions in test cases.

bethskurrie
2019-03-15 08:38
Yes.

vitaliy.grigoruk
2019-03-15 08:38
thanks for your answers!

bethskurrie
2019-03-15 08:39
It helps control the number of interactions, because you'll see more clearly if you start adding duplicate pact unit tests.

bethskurrie
2019-03-15 08:40
It's a bit easier to get carried away with a bajillion slightly different combinations if you're defining your interactions for your UI tests directly.

oswald.quek
2019-03-15 09:45
if anyone's interested, we've had the pact broker for nearly a year now and there were 10 million rows in the view `matrix`

oswald.quek
2019-03-15 09:45
we deleted 7 million rows

bethskurrie
2019-03-15 09:46
Impressive! No wonder your database was struggling!

sergiy
2019-03-15 10:48
has joined #general

james.carman
2019-03-15 10:52
Our fronted developers are using cypress for mocking/stubbing out backend services I believe.

vitaliy.grigoruk
2019-03-15 10:53
well, cypress is not a tool we want to use.

james.carman
2019-03-15 10:54
Fair enough.

james.carman
2019-03-15 10:57
I definitely wouldn?t consider pact to be the right choice for functionality testing browser JS code. You certainly would want to have a pact test.

james.carman
2019-03-15 10:58
There has to be a better stubbing tool, though. I?m not a JS guy, so I don?t know the landscape well, though.

bethskurrie
2019-03-15 10:59
Yeah, I'm in the same boat.

james.carman
2019-03-15 11:01
Cypress is what I?ve heard our folks talk about, but it?s JS, so there have to be a bajillion options.

sergiy
2019-03-15 11:38
:wave: hi all, just a :heavy_plus_sign: to cypress, we've also started to use it in combination with PACT in our project. `@pact-foundation/pact-web` and `@pact-foundation/pact-node` good written JS libraries. For mocking on consumer side, even without cypress, use - `@pact-foundation/pact-node` or for non-Node environments - `@pact-foundation/pact-web`. You can read more here - https://github.com/pact-foundation/pact-js#consumer-side-testing

adb
2019-03-15 12:19
has joined #general

adb
2019-03-15 12:42
Hello ladies and gentlemen. I'm trying to run consumer unit test against pact-mock-service docker image in .NET. So I started container and tried to run consumer tests from https://github.com/tdshipley/pact-workshop-dotnet-core-v1#step-332---completing-your-first-consumer-test. But with no luck: ``` [Test Class Cleanup Failure (tests.ConsumerPactTests)]: PactNet.PactFailureException : {"message":"Error ocurred in mock service: JSON::ParserError - 765: unexpected token at ''","backtrace":["/usr/local/lib/ruby/2.5.0/json/common.rb:156:in `parse'","/usr/local/lib/ruby/2.5.0/json/common.rb:156:in `parse'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/mock_service/request_handlers/pact_post.rb:27:in `respond'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/mock_service/request_handlers/base_request_handler.rb:17:in `call'","/usr/local/bundle/gems/rack-2.0.3/lib/rack/cascade.rb:33:in `block in call'","/usr/local/bundle/gems/rack-2.0.3/lib/rack/cascade.rb:24:in `each'","/usr/local/bundle/gems/rack-2.0.3/lib/rack/cascade.rb:24:in `call'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/consumer/mock_service/cors_origin_header_middleware.rb:11:in `call'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/consumer/mock_service/error_handler.rb:13:in `call'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/mock_service/app.rb:32:in `call'","/usr/local/bundle/gems/pact-mock_service-2.1.0/lib/pact/consumer/mock_service/set_location.rb:14:in `call'","/usr/local/bundle/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service'","/usr/local/bundle/gems/webrick-1.3.1/lib/webrick/httpserver.rb:138:in `service'","/usr/local/bundle/gems/webrick-1.3.1/lib/webrick/httpserver.rb:94:in `run'","/usr/local/bundle/gems/webrick-1.3.1/lib/webrick/server.rb:191:in `block in start_thread'"]} ``` Even most simple tests fails with this ParserError. There is no error when running tests without docker. Any ideas?

8surajsingh9
2019-03-15 12:58
has joined #general

ghandour.jihad
2019-03-15 13:26
it was solved by PactDslJsonArray and value.object().stringType. Thanks in all cases Boris!

pkuang
2019-03-15 17:18
Hi, can someone provide more details on this workflow: https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0 I have consumer -provider chains that I'm having trouble finding a good way to stub out the rest of the chain while ensuring the "stub" is valid. I explored option #2 but came to the same conclusion as the first comment on the gist where this would cause coupling of tests and the necessity of loose matching requests doesn't seem appealing. Is there an example of option #1 that shows how the "linking" that verifies the stub would be implemented?

kapoor84pu
2019-03-16 20:07
has joined #general

simon.nizov
2019-03-17 10:39
Any tips for DRYing up complex provider state setup when using spec V2? Some ideas I had: 1) Using commas in the state description and splitting by comma in the provider state setup. For example the provider state `"User with email X exists, Post with id Y exists"` would be parsed to `["User with email X exists", "Post with id Y exists"]`. 2) Faking a V3 pact by passing JSON inside the string and parsing it. For example passing the following provider state: `"\[\"User with email X exists\", \"Post with id Y exists\"\]"` - very ugly but would make the move to V3 easier in the future. Is it even worth it to do any of this? What?s the current status for supporting V3 in Ruby?

uglyog
2019-03-17 20:32
I would go with option 1.

uglyog
2019-03-17 20:33
Nobody has put their hand up to implement V3 support in ruby, so it will still be a while.

zach.powell
2019-03-18 11:01
has joined #general

vitaliy.grigoruk
2019-03-18 14:19
Hey Simon. I?m using JS implementation (which is a ruby wrapper) and I can pass a JSON array of objects to a provider state in v2. Not sure why, but it works

simon.nizov
2019-03-18 14:31
@vitaliy.grigoruk Interesting.. can you post a code snippet of how it looks?

ghandour.jihad
2019-03-18 15:16
I have a service that starts on a dynamic port. How can I start it, fetch its port, place it in @TestTarget, before @TestTarget is executed? In other words, is there anything cleaner than: @TestTarget public Target target = new HttpTarget(startServiceAndReturnPort()); private Integer startServiceAndReturnPort() { if (!started) { try { // code that starts the service and fetches servicePort } catch (Exception e) { e.printStackTrace(); fail(); } } return servicePort; }

hstene
2019-03-18 15:19
Why can?t you start it on a static port while testing?

ghandour.jihad
2019-03-18 15:20
I run several tests in parallel on the same machine as part of the CI. all the services (many) use dynamic ports so that non conflicts with another

hstene
2019-03-18 15:21
Are you using a framework for running your application? (Like Spring Boot?)


ghandour.jihad
2019-03-18 15:26
Unfortunately I am not using Spring Boot, and I can't for the moment. there is a complex piece of code that needs to be written to start the service. So my workaround was the one in the initial comment. I am checking if there is any kind of @before_everything where I can do things before the @TestTarget PS I checked and @Before_Class is not launched before @TestTarget :confused:

james.carman
2019-03-18 15:27
@ghandour.jihad can you tell your service which port to use?

james.carman
2019-03-18 15:27
From the outside?

james.carman
2019-03-18 15:27
or does it choose a random port internally?

ghandour.jihad
2019-03-18 15:27
No because it will create a race condition. The port I specify before the service starts, might be consumed by another service before my service is started

ghandour.jihad
2019-03-18 15:28
that's why we rely on the OS, by starting on 0 and getting an empty port

james.carman
2019-03-18 15:28
you can find a free port programmatically and hand that to the service rather than letting the OS do so

ghandour.jihad
2019-03-18 15:28
I edited it my reply. Choosing a free port will create a race condition as explained

james.carman
2019-03-18 15:31
what part of your test case starts the service?

hstene
2019-03-18 15:31
Well, why? If you programmatically look for a free port and take it if possible then it should be good?

ghandour.jihad
2019-03-18 15:35
Due to this: 1-You programmatically choose a port X. 2-You ask the service to start on that port X. 3-Service takes 30 seconds to start on that port X. 4-Service starts and the port X appears as busy if during 2 or 3, another service contacts the OS for an empty port, OS might give it X and step 4 will fail because port already in use

ghandour.jihad
2019-03-18 15:37
just to give you a scale, we are talking about thousands of services being started in parallel, and we always recommend using dynamic ports. I think many with such a scale would need a @before_everything or to at least let @before_class run before @TestTarget

james.carman
2019-03-18 21:42
are these thousands of services all downstream dependencies of whatever you?re trying to test?

jmcknight
2019-03-18 23:04
has joined #general

nikbarch
2019-03-19 02:03
has joined #general

nikbarch
2019-03-19 03:07
Hi everyone! Does anyone have a production-like example of pact test suite for python?

marko.justinek
2019-03-19 03:08
has joined #general

luca.ippolito
2019-03-19 06:29
Hey @matt.fellows Any updates on this? I was talking with others about this in the #pact-jvm channel. I was told that i should try to avoid using states that are dependent on each other. What's your opinion on this? Is the order of execution never guaranteed?

ghandour.jihad
2019-03-19 07:23
no no not at all :smile: I am talking about the amount of services being started in parallel and all counting on the OS to handle their port allocation

bethskurrie
2019-03-19 07:43
@uglyog is the author, and is the only one who can give you a definitive answer.

bethskurrie
2019-03-19 07:44
Have you tried in the #pact-python channel @nikbarch?

nikbarch
2019-03-19 10:16
I did. No one answered though

bethskurrie
2019-03-19 10:16
Try @richard.jones

ghandour.jihad
2019-03-19 10:35
Hi @bethskurrie :slightly_smiling_face: what do you think about @before_everything or to at least let @before_class run before @TestTarget ?

onebrianparker
2019-03-19 10:40
has joined #general

bethskurrie
2019-03-19 10:45
@ghandour.jihad I'm not familiar with the jvm implementation, sorry. @uglyog will have to answer your question (sorry to harass you Ron!)

bethskurrie
2019-03-19 10:46
Your use case is quite unusual, to have thousands of tests running in parallel.

bethskurrie
2019-03-19 10:46
Can you explain that more?

bethskurrie
2019-03-19 10:47
Sorry, it's late here, so I can't continue to respond now, but I'll put a reminder to follow up in the morning

uglyog
2019-03-19 11:23
@ghandour.jihad if you use the junit 5 version instead of junit 4 one, you can set the port for the Target.

vitaliy.grigoruk
2019-03-19 14:01
Sorry for a delay, @simon.nizov. Sure I can

vitaliy.grigoruk
2019-03-19 14:03
on a consumer side: ``` const interaction = { state: [ { name: 'session exists', params: { sessionId: 'session_id' } } ], uponReceiving: `a request for session information`, withRequest: { ... }, willRespondWith: { ... } } ```

vitaliy.grigoruk
2019-03-19 14:05
then when contract is generated, I get the following inside it: ``` { "description": "a request for session information", "providerState": [ { "name": "session exists", "params": { "sessionId": "session_id" } } ], "request": { ... }, "response": { ... } } ```

ghandour.jihad
2019-03-19 14:07
@bethskurrie, we have a pool of machines where many developers run their tests in parallel, even one team might be running same test on different branches, that's why dynamic ports are needed @uglyog, interesting. indeed I am not currently using junit 5. Well at least now I know there is a cleaner solution than my workaround. thanks!

vitaliy.grigoruk
2019-03-19 14:08
and on provider side, I?m running NodeJS express app for to handle http calls from pact verifier to /pactStateSetupUrl, which has the following middleware: ``` const express = require('express'); const bodyParser = require('body-const app = express(); app.use(setupUrl, bodyParser.json()); http://app.post(setupUrl, async (req, res) => { /* state handling goes here */ } ```

ots.indrek
2019-03-19 14:34
Found this thread via search. Seems to be an old one. @liran.tal how did you handle the feature toggle/flag use case?

wayofthepie
2019-03-19 20:54
has joined #general

james.carman
2019-03-19 21:35
We solved the port collision problem by using docker containers for our builds.

bethskurrie
2019-03-19 22:06
@adb can you set up a git repository with an executable example that demonstrates the problem, and raise an issue in the pact-mock-service-docker repository please.

bethskurrie
2019-03-19 22:07
Are you sure .net supports use of a standalone mock service, btw?

evan_l00
2019-03-20 00:45
has joined #general

marko.justinek
2019-03-20 02:19
I?m still here, just with my personal account now :slightly_smiling_face: Still keen to help out/support the swift side to the best of my time allowance(s)

matt.fellows
2019-03-20 02:35
:smile:

sdpoling
2019-03-20 02:36
has joined #general

sumanthbharan
2019-03-20 08:37
has joined #general

simon.nizov
2019-03-20 11:53
Hey @vitaliy.grigoruk, thanks for posting. From looking at your code and the pact generated, it seems like you *are* using V3.. https://github.com/pact-foundation/pact-specification/tree/version-3#allow-multiple-provider-states-with-parameters I?m using the ruby implementation and there is no way to pass an array as a state (the `given` method in ruby). If I pass in an array I just get `"providerState": "[\"foo", \"bar\"]"` in the pact file.

vitaliy.grigoruk
2019-03-20 11:54
Well, I?m using v2

vitaliy.grigoruk
2019-03-20 11:54
But I?m using pact-js

simon.nizov
2019-03-20 12:13
In the pact file, `providerState` takes an array (i.e `"providerState": []`) and at the bottom of the file it says `"version": "2.0.0"`? @vitaliy.grigoruk

vitaliy.grigoruk
2019-03-20 13:12
yes, that?s exactly what I have.

simon.nizov
2019-03-20 13:16
Very strange :S @matt.fellows - Isn?t multiple provider states a version 3 feature?

vitaliy.grigoruk
2019-03-20 13:35
it is, but in v3 the fields in contract is called ?poviderStates?, not ?providerState?

vitaliy.grigoruk
2019-03-20 13:36
the fact that it works for me in v2 this way is kind of a ?bug?, which I consider as undocumented feature :slightly_smiling_face:

simon.nizov
2019-03-20 13:38
This has now become my only good reason for leaving ruby in favor of JS :smile:

luca.ippolito
2019-03-20 14:09
Looks like https://docs.pact.io/ is having trouble loading images currently

matt.fellows
2019-03-20 19:31
Looks to be ok now, still having issues @luca.ippolito? We use gitbook for hosting the docs

matt.fellows
2019-03-20 19:32
:laughing:

luca.ippolito
2019-03-21 06:01
@matt.fellows looks better now for me as well :slightly_smiling_face:

a.bokias
2019-03-21 08:17
has joined #general

joseiglesias
2019-03-21 12:46
has joined #general

arunkumarpoonia
2019-03-21 17:07
has joined #general

arunkumarpoonia
2019-03-21 17:11
I am unable to build interaction without given, more details - https://github.com/pact-foundation/pact-php/issues/117

mboudreau
2019-03-21 22:13
please use our stackoverflow to ask questions, issues in github are for code issues: https://stackoverflow.com/questions/tagged/pact#

matt.fellows
2019-03-22 09:03
It looks like a real issue, tho

mboudreau
2019-03-22 09:19
Sorry, assumed that it would work like the other libraries :/

adb
2019-03-22 09:37
Hey, thanks for your reply. I'm not sure about that. It turned out that there is no need to use pact-mock-service image to run tests because .NET implementation uses pact-ruby-standalone. So I run .NET pact tests inside linux container like any other tests, without additional pact-mock-service container. Our devops complicated our life unnecessary :slightly_smiling_face:

upgundecha
2019-03-22 10:05
has joined #general

liran.tal
2019-03-22 19:39
Using something I call a pact manifest

liran.tal
2019-03-22 19:40
@ots.indrek ping me on twitter, I?m happy to share with you an article that I?m actually just about to publish next week on this whole setup


mwroblewski
2019-03-24 13:35
has joined #general

venkata.uday24
2019-03-25 00:07
has joined #general

bethskurrie
2019-03-25 03:00
@oswald.quek @m.r.green the latest version of the broker has the corrected logic to allow you to deploy new providers without requiring the consumer to be deployed.

bethskurrie
2019-03-25 03:00
2.29.0. Please update and let me know how you go.

kataramoonlight
2019-03-25 08:55
has joined #general

dave.carrell
2019-03-25 14:07
has joined #general

lekocrod
2019-03-25 14:32
has joined #general

mmarcottulio
2019-03-25 18:21
has joined #general

vtambourine
2019-03-26 02:45
has joined #general

vtambourine
2019-03-26 02:51
Hi everyone, I'm not sure if this is the right channel for such questions. Please, guide me where should I seek help. I'm wondering about status of this issue ? https://github.com/uglyog/pact-stub-server/issues/19 ? Support for different provider states in pact-stub-service. This feature would be extremely useful in our project, where we actively use pacts. generated from unit tests and pact-mock, to run stub to fuel E2E tests and demo certain features in emulated environment

anliang2314
2019-03-26 03:58
has joined #general

uglyog
2019-03-26 04:09
It was released in version 0.2.2. I've added a comment to the issue.

mateusz.beczek
2019-03-26 07:21
has joined #general

mateusz.beczek
2019-03-26 07:29
hi there, I'm Mateusz and I've got some issues with Pact Broker/Pact Broker clients security - for JVM we need to secure communication between Pact clients and Pact Broker, as I see in sources there is by default "Basic" authentication type, is there an option to use Bearer with token with pact-jvm?

bethskurrie
2019-03-26 08:25
Can you explain why basic auth is any less secure than a bearer token @mateusz.beczek?

bethskurrie
2019-03-26 08:26
Both are sending a value in an http header over a secure channel. I can't see that one is any more or less secure than the other.

bethskurrie
2019-03-26 08:27
Having said that, we are currently adding token auth to the Dius hosted pact broker. It should be released in late April.

mateusz.beczek
2019-03-26 08:37
Hi, issue is that you need to place somewhere user/password (probably plaintext), so that is for us unacceptable

mateusz.beczek
2019-03-26 08:38
we thought that we can us i.e. Keycloak, i.e. call for token and then push pact to Broker

mateusz.beczek
2019-03-26 08:39
we cannot store user/password in repository or whatever because of legal regulations

gopinathlangote11
2019-03-26 09:03
Recently I talked about `confidently-releasing-microservices-with-consumer-driven-contracts`At `Agile India 2019` conference. The slides from the talk are here, (Might help for beginners to understand CDC) https://www.slideshare.net/GopinathLangote/confidently-releasing-microservices-with-consumer-driven-contracts-1

matt.fellows
2019-03-26 09:16
How would you authenticate to keycloak?

matt.fellows
2019-03-26 09:16
Or is that managed at the OS level?

matt.fellows
2019-03-26 09:18
Bearer token would still suffer the same issue. You'd need to call keycloak to get the token and then send. Can you not do the same with the user/pass?

matt.fellows
2019-03-26 09:18
And yes, as Beth mentioned we're adding to the Enterprise offering later next month. If you'd like to discuss feel free to DM one of us and we can chat further

mateusz.beczek
2019-03-26 09:21
With certificate/key stored with sources?

bethskurrie
2019-03-26 09:38
@mateusz.beczek I think what you're getting at is that the bearer token would be a jwt, and hence, able to be validated without any credential stored in the broker itself. It's the fact that the token value would be a jwt that would solve your problem, not the fact that your auth type would be bearer token in itself.

matt.fellows
2019-03-26 09:48
Storing certificate/key with sources is the same as storing a user/pass, is it not?

matt.fellows
2019-03-26 09:48
What I'm saying is no matter which approach you go for, you still have to get a credential (whatever type) before authenticating

vtambourine
2019-03-26 10:16
Thank you, Ronald!

vtambourine
2019-03-26 10:53
Since yesterday I learned that starting from version 0.2.2 _pact-stub-server_ supports declaring provider states, I want to ask what?s your opinion on using stub server for negative testing scenarios. Currently, we are using stub server in E2E tests to mock responses for different edge cases ? for instance, to mock API returning full set of value, part of values, no values, or 4xx error. We have to use special headers (X-Mock-Header) to specify which 2xx response we expect in each particular test case. But that solution doesn?t feel right because of necessity to add test logic in otherwise production code. Instead, would it be possible to launch new instance of stub server with different provider state on each of the ?mocked? test scenarios? What do yo think?

ben.scown
2019-03-26 22:23
has joined #general

paras.vora
2019-03-27 08:29
has joined #general

skirankumars31
2019-03-27 22:50
has joined #general

skirankumars31
2019-03-27 22:58
Im a beginner to pact. We have some mocks for our microservices run with wiremock. Is it possible to keep them in sync with the provider using pact ?

bethskurrie
2019-03-27 23:00
Hi @skirankumars31. Welcome. No, you can't use wiremock with pact, as you need to use the pact mocking framework to generate the contract that is verified with the provider.

skirankumars31
2019-03-27 23:08
Thanks for the reply @bethskurrie. Can pact can help me keep the wiremock services in sync with production service ?

bethskurrie
2019-03-27 23:08
When you say " wiremock services", do you mean, your providers?

bethskurrie
2019-03-27 23:09
Pact will help you keep your dev/prod consumer and provider versions in sync with each other.

skirankumars31
2019-03-27 23:16
We use wiremock to mock all these services in our dev environment, but sometimes they get out of sync with production. So i was wondering if pact could help us run some tests to check if the mocks are not up to date with production

james.carman
2019-03-27 23:21
If you don?t have any state requirements, you may be able to run your pacts against the mocks.

skirankumars31
2019-03-27 23:47
Should i use pact-stub-server or wiremock ?. If i use pact stub server i can be sure that my mocks will be up to date. How can i make sure my wiremock mocks and providers have the same contract ?

yousafn
2019-03-27 23:57
which side are you on? consumer / provider or both? who owns the mocks? If you are the consumer, and you are using wiremock to mock your provider Then you could setup pact consumer tests that describe the behaviour you expect from your wiremock service. You then call the pact broker via pact, and pass it the provider endpoint of your wiremock service and verify it is acting as expected. You would then, in your example run then against your real (non wiremocked) provider to check for drift. However, the real question is the value of your wiremock representations, if they are drifting out of sync with production service. Why is it not being picked up earlier than production? Surely this could be determined much earlier in your workflow. I am currently working in a team where we have pact implemented on our consuming services, they have published contracts to the pact broker. Our provider has given us wiremock representations of their services, and we have validated them against consumer-provider contracts and they are all green now. The hope is that when they finish their first provider service, they will run validate the contracts and again we will see nice green builds. If not, something will have gone amiss, but this would be caught in an integration environment. For protecting production services, we will run the same tests against a staging enviroment (basically pre-prod) which should protect us from having any production incidents due to contractual problems :metal:

yousafn
2019-03-28 00:02
if you guys use swagger, there are some tools to help check drift between swagger & wiremock (https://github.com/telegraph/wiremock-swagger)

skirankumars31
2019-03-28 00:11
Im on the consumer side

uglyog
2019-03-28 04:21
@skirankumars31 pact came about based on consumer tests precisely to keep the mocks in sync. It was designed as a feature. But you can use pact mock servers instead of wiremock. There is nothing to verify the wiremock responses.

uglyog
2019-03-28 04:26
However, you could write provider pact tests against wiremock, assuming you can share the wiremock config.

uglyog
2019-03-28 05:49
Sounds like an ok approach to me

vtambourine
2019-03-28 17:25
Hi everyone! Can someone help me understand ? which pact-stub-service implementation is used in pact-node package? Is it Ruby or Rust?

mboudreau
2019-03-28 22:15
Ruby for the moment

vtambourine
2019-03-29 00:53
Hm? Does it mean, that option to provide regexp for provider state (as in rust cli) is not available yet?

mboudreau
2019-03-29 00:55
It does not

chakra.yadavalli
2019-03-29 01:42
has joined #general

chakra.yadavalli
2019-03-29 01:43
Hi I am looking for information on using pact with grpc proto3

bethskurrie
2019-03-29 03:39
Try the #protobufs channel?

matt.fellows
2019-03-29 10:25
Short answer is that it?s not officially supported? yet. It might be possible, but I?ve not heard of anyone doing it

matt.fellows
2019-03-29 10:25
We?d love support to make it happen

lextiz
2019-03-29 13:24
Hi guys, I have created a Docker image that wraps Pact Ruby CLI (all executables), in case some of you are interested: https://github.com/lextiz/pact-docker.

joseph.s.egan
2019-03-30 18:43
has joined #general

franklin.huynh
2019-04-01 02:59
has joined #general

skirankumars31
2019-04-01 10:43
Hi, Can anyone point me to a example usage of regex matchers in Pact-jvm ?


mboudreau
2019-04-01 11:14
with the dsl, you should be able to do `.stringMatcher("property", "^regex$", "generated value")`


skirankumars31
2019-04-01 12:22
Thanks @mboudreau :slightly_smiling_face:

skirankumars31
2019-04-01 12:38
Can i also have regex on numbers ?

skirankumars31
2019-04-01 12:38
Sorry got that one too

skirankumars31
2019-04-01 12:38
stringMatcher("FNR","\\d{11}","19048634263")

skirankumars31
2019-04-01 12:41
Hi guys, Is it possible to show the pact plugin in Intellij maven panel ?. I have pact plugin in pom.xml but it does not show in intelliJ maven panel

richard.jones
2019-04-01 23:15
Pact V3/V4 question: in pact V3 the ?match? element was replaced with ?matchers? allowing multiple matchers to be specified with a ?combine?, allowing things like ?match the type or a null?. In the V4 spec, the example at the bottom reverts back to the singular ?match? element. Is that indicative of a move away from the multiple matchers model? I note that V4 also includes a reference to ?matcher defintions like or(decimal, nullValue)?, so I?m pretty sure it?s not - just checking :slightly_smiling_face:

richard.jones
2019-04-01 23:27
I?d be interested to know whether anyone?s done anything in the space of multiple matchers. In terms of specifying the rules in our code (Python in this case) we?re thinking that it could be `Any(Like('string'), None)` which would allow the verifier to match a string OR null (the Like could also be an exact value, or a regex `Term()` or whatever). `Any()` would accept 2+ arguments and the concrete value (for mocking) is the first element. I?d also add `All()` at the same time which would generate an AND combiner. The functions could be called `Or` and `And` but I think `Any` and `All` read better.

abubics
2019-04-01 23:32
I think that's a powerful (and relatively complex) feature to provide, but does it give much value? I find (usually) when people start trying to match complex optionals, they really should just have more concrete, explicit test cases :thinking_face:

richard.jones
2019-04-01 23:35
Yeah, it?s a thought. We?ve not jumped yet :slightly_smiling_face:

abubics
2019-04-01 23:38
(I'm not a maintainer, just a frequent user, fwiw)

richard.jones
2019-04-01 23:43
the specific use case we have here derives good benefits from being able to have the representative data set (which includes values and nulls) in the pact, rather than splitting it into two artificial payloads.

uglyog
2019-04-02 01:05
V4 is incomplete, and only a work in progress

pkuang
2019-04-02 01:29
Does Pactjs (or pact in general) have support for request matching MIME types?

richard.jones
2019-04-02 02:52
yep, cool

matt.fellows
2019-04-02 07:03
Search for "optional types" on the pact specification , I believe there is a discussion there on this problem. Also there is a QandA dedicated to it on the pact website. Tldr we explicitly don't currently support it

qatrera
2019-04-02 13:54
has joined #general

pkuang
2019-04-02 15:03
more specifically a application/pdf body

bheemreddy181
2019-04-02 15:07
has joined #general

bheemreddy181
2019-04-02 15:09
Is there a ruby-channel around ?

rjmcguinness
2019-04-02 15:31
#pact-ruby

acooper106
2019-04-02 20:23
Can pact be used for Mobile Applications (Swift and Android)?

acooper106
2019-04-02 20:35
I see this announcement for swift https://docs.pact.io/implementation_guides/swift Please confirm this the recommendation

acooper106
2019-04-02 20:35
And do you have a recommendation for android?

marko.justinek
2019-04-02 21:19
@acooper106 yes, it can be used for Swift consumer side, and Android with JVM and/or Kotlin.

marko.justinek
2019-04-02 21:20
are you looking for something specific? @acooper106

matt.fellows
2019-04-02 21:30
So there's nothing specific to Android, it's just the JVM so you can use pact JVM for that purpose

richard.jones
2019-04-02 21:43
Yep, definitely bleeding edge. I think we might experiment with it and see how it goes? We?ll only be generating/verifying the pacts within pactman space, so having other implementation support it isn?t an issue.

2019-04-03 05:45
@matt.fellows has sent a survey for you!

matt.fellows
2019-04-03 10:12
apologies but I?m going to have to replace the Polly survey with an old-fashioned Google form. There are some restrictions on the Slack integration that weren?t obvious until after the results started coming through. I was hoping that the Slack integration would be more convenient, but not at the $$ it?s asking? Please instead complete the following.

matt.fellows
2019-04-03 10:13
Could we ask you answer a few quick questions on your usage of Pact? Your answers to these really help us understand how we can continue to improve the product. It shouldn?t take more than 1 minute, I promise! https://docs.google.com/forms/d/e/1FAIpQLSeLNdSSTP6eUHeJWnqMiJoD9Trib2Kw-fDarc3SzUM6cB-Bew/viewform?usp=sf_link (only new respondants)

thadir
2019-04-03 10:14
Then you should also set the permisions correct :wink: its now only set to owner organisation

matt.fellows
2019-04-03 10:15
I can?t believe how quick you must have gone to that link!! should be open now, I did both almost at the same time :slightly_smiling_face:

000sps97
2019-04-03 11:55
has joined #general

acooper106
2019-04-03 11:57
@marko.justinek @matt.fellows Thanks for you response. I'm not using it, I will pass along your answers.

laxmi.somni
2019-04-03 14:06
has joined #general

laxmi.somni
2019-04-03 14:07
Hi

laxmi.somni
2019-04-03 14:09
Do we have a good simple easy-to-follow example on PACT- using js? I just need a simple bare-bone example using any 3rd party public API (with clear insturactions to follow) ? Thanks in advane


vinod.baradwaj
2019-04-03 14:13
have u published that article ?

laxmi.somni
2019-04-03 14:19
Cool.

laxmi.somni
2019-04-03 14:19
Thanks a lot

laxmi.somni
2019-04-03 14:20
Its running all fine

laxmi.somni
2019-04-03 14:38
But I need a lighter version of this framework, which I can rewire & use it to create a small working model for our project

laxmi.somni
2019-04-03 14:39
i.e. to propose PACT framework to seniors

simon.nizov
2019-04-03 14:42
:man-shrugging:

simon.nizov
2019-04-03 14:51
Best way IMO is to actually do it yourself on an existing consumer and provider in your company


laxmi.somni
2019-04-03 15:08
sure. let me go through it

simon.nizov
2019-04-03 15:08
More specifically step #3

laxmi.somni
2019-04-03 15:08
Thanks

laxmi.somni
2019-04-03 15:09
I think Step-1 - implementing it on your own API is going to be a big milestone

laxmi.somni
2019-04-03 15:09
I've worked on RestAssured so, I'm sure will be able to work on this as well!:+1:

dagarwal
2019-04-03 18:29
I agree as well, it would be better if you demonstrate on existing services in http://company.it will help your seniors to understand use of pact in a better way

marko.justinek
2019-04-03 22:58
note, if you're using `pact-ruby-standalone` and would like to install it using Homebrew (https://brew.sh) you can use the following tap: ``` brew tap surpher/pact-ruby-standalone brew install pact-ruby-standalone ```

bethskurrie
2019-04-03 23:18
Woot! Thanks @marko.justinek!

bethskurrie
2019-04-03 23:19
You interested in moving it to the pact-foundation org?

marko.justinek
2019-04-03 23:19
sure

bethskurrie
2019-04-03 23:19
Pretty sure you're in the org already

bethskurrie
2019-04-03 23:19
Let me know if I need to add you.

marko.justinek
2019-04-03 23:19
am I?

bethskurrie
2019-04-03 23:20
When I get in front of my laptop I'll check and add you if not.

marko.justinek
2019-04-03 23:20
We'll sort it out np. Maybe over the weekend. Got _things_ to do now

bethskurrie
2019-04-03 23:20
How could anything be more important?! ;-)

marko.justinek
2019-04-03 23:20
Yah, i know ¯\_(?)_/¯

bethskurrie
2019-04-03 23:21
Pact is not the best tool for testing 3rd party APIs.

bethskurrie
2019-04-03 23:21
Let me find the FAQ.


nathan.wilson
2019-04-04 02:49
has joined #general

ghandour.jihad
2019-04-04 07:08
I am really sorry for the following question but well :smile: is there a plan for a c++ version of pact? :eyes:

matt.fellows
2019-04-04 07:25
No worries

matt.fellows
2019-04-04 07:25
Are you planning on creating one?

ghandour.jihad
2019-04-04 07:48
Wasn't planning on creating it, was just checking if there is plan to do it, that way I can use that as a good argument while trying to convince my company to use Pact :slightly_smiling_face:

bethskurrie
2019-04-04 07:49
Shouldn't be too hard to make one with the c bindings from @uglyog's rust impl

ghandour.jihad
2019-04-04 07:52
sounds good thanks!

bethskurrie
2019-04-04 07:53
Sorry, I'm not volunteering - I haven't written any c++ since uni! Just saying it wouldn't be too much work if someone who knew the language was interested. The hard work (the matching logic) is done.

ghandour.jihad
2019-04-04 08:00
oh no worries I got you correctly :slightly_smiling_face: the good news for me is that it is not hard to make since we already have these c bindings, and that is the argument I was looking for.

matt.fellows
2019-04-04 08:11
Hehe

matt.fellows
2019-04-04 08:11
We're definitely happy for it to be created and would support however we can. Let us know if you need help convincing bosses :grinning:

neelofer.tamboli
2019-04-04 10:49
has joined #general

neelofer.tamboli
2019-04-04 11:10
Hi everyone. Can someone help me with fixing this error through the pact broker UI rather than the DB? On the UI everything is looking fine, but our webhook is not getting triggered and we see the following error in logs: ```App 373 output: E, [2019-04-04T10:17:37.341770 #373] ERROR -- : PG::ForeignKeyViolation: ERROR: update or delete on table "pact_publications" violates foreign key constraint "triggered_webhooks_pact_publication_id_fkey" on table "triggered_webhooks" App 373 output: DETAIL: Key (id)=(1172) is still referenced from table "triggered_webhooks".: DELETE FROM "pact_publications" WHERE ("consumer_version_id" = 755) App 373 output: E, [2019-04-04T10:17:37.342049 #373] ERROR -- : PG::ForeignKeyViolation: ERROR: update or delete on table "pact_publications" violates foreign key constraint "triggered_webhooks_pact_publication_id_fkey" on table "triggered_webhooks" App 373 output: DETAIL: Key (id)=(1172) is still referenced from table "triggered_webhooks".```

shutchin
2019-04-04 21:51
has joined #general

matt.fellows
2019-04-04 23:06
Do you know what was done to get it into this state?

matt.fellows
2019-04-04 23:06
Did you do anything manually via the DB?

neelofer.tamboli
2019-04-05 05:53
Nothing via DB. We deleted the webhook and a specific pact version through the `Non-Get` requests from the Browser and then created a new Webhook when this was observed. All this was done for the same Provider and Consumer.

neelofer.tamboli
2019-04-05 05:54
Also when I checked the DB last night, and queried the problematic row, `SELECT FROM "pact_publications" WHERE ("consumer_version_id" = 755)`, there was no record in DB for it.

vaso.giamarelou
2019-04-05 08:46
has joined #general

thadir
2019-04-05 09:54
some cool reading stuff folks


neelofer.tamboli
2019-04-05 10:19
Please ignore my last comment, was looking at the pre-prod data.

neelofer.tamboli
2019-04-05 10:22
The issue is fixed now. The problem was as follows and the fix is also here. To repro: 1. Consumer `C` has two providers, `P1` and `P2`. 2. Pacts and contract content change webhooks are created for both C-P1 and C-P2 combinations. 3. Delete the webhook and latest pact version between `C` and `P1`. 4. Recreate the webhook between `C` and `P1`. 5. Publish a contract with contract change. 6. The webhook is not triggered, the issue we were facing. To fix this: Delete webhooks between `C` and `P1` and between `C` and `P2`. And then do the action required. The webhook then created will be triggered.

k.kaskavelis
2019-04-05 12:17
has joined #general

ghandour.jihad
2019-04-05 15:59
Hello fellow Pacters, I need convincing arguments to help me convince people :slightly_smiling_face: What is your best answer to the below skepticism: If the consumer calls a provider endpoint, using a client interface built by provider team, and places the response in an object built by the provider team, what would be the use of pact? In the consumer test, the consumer team will have to ?re-build? the provider object as a set of .stringType ... body response, just so that the mockedServer returns something that correctly fits in the provider object. Thus the consumer will have to specify all the parts of the response object, which deprives us from the use of Pact, which is specify only what you need. Is pact only for consumers calling providers directly, and parsing the json themselves to fill their own object? (unfortunately that rarely happens in my company :/)

matt.fellows
2019-04-05 21:22
Ho do you _guarantee_ that the client library stays in sync with the provider?

matt.fellows
2019-04-05 21:25
This reminds me of the old days with soap. Yes, we guarantee the client library is compatible with the provider (e.g. it was generated) but it's very brittle because you are coupled to each other. you now have to release all components together (painful) and roll backs aren't gonna be easy

matt.fellows
2019-04-05 21:26
The whole point of contract testing is to enable independent releases of components and continuous delivery. Coupling this way prevents this and scales poorly as you add more teams and components

james.carman
2019-04-06 20:24
We usually keep the service interface as a separate project

james.carman
2019-04-06 20:24
Cuts down on the churn.


matt.fellows
2019-04-06 22:42
Good question if anyone has a moment to answer. I'll look at responding later today when in front of a computer


mo.balghonaim
2019-04-08 00:41
has joined #general

nathan.deamer
2019-04-08 10:51
has joined #general

nathan.deamer
2019-04-08 10:55
Hey, Is anyone able to help with an intermittent 409 conflict from our hosted pact broker? https://github.com/pact-foundation/pact_broker/wiki/Troubleshooting I?ve checked the name and it is unique and not similar from any other names

nathan.deamer
2019-04-08 10:56
I?ve ran a curl script manually from my machine - always fine. But when it runs as part our of circleCI pipeline from an apple build we see 409s.

bethskurrie
2019-04-08 11:03
Are these new consumers or providers?

bethskurrie
2019-04-08 11:04
Do you have the body of the response in your output?

bethskurrie
2019-04-08 11:05
There are a couple of reasons you might get a 409.

bethskurrie
2019-04-08 11:07
Are you sure it's the naming reason?

nathan.deamer
2019-04-08 11:16
Hi Beth, Its an existing consumer and an existing provider - just an update - possibly without any changes other than version number. I don?t have the body of the response, from iOS we only get `HTTP Error 409: Conflict` ```except urllib2.HTTPError as e: print e``` I am not sure if it is the naming reason?. that is the only documentation I could find for why.

nathan.deamer
2019-04-08 11:16
Currently adding more logging :slightly_smiling_face:

bethskurrie
2019-04-08 11:34
The other cause of a conflict is when multiple pact files are merged into one resource using a PATCH request.

bethskurrie
2019-04-08 11:35
Which implementation are you using to publish the files?

nathan.deamer
2019-04-08 12:19
It could be that one?. Our iOS implementation of pact: 1. Starts a mock service . 2. Creates a pact for the next provider 3. Exports the json files etc. 4. Calls flush on the mock service. 5. Repeat for next microservice. Then at the end we use some custom python scripts against the rest apis


bethskurrie
2019-04-08 23:38
@nathan.deamer what are you using to *publish* the pact files to the broker?

bethskurrie
2019-04-08 23:40
Can you copy paste the code for me?

bethskurrie
2019-04-08 23:41
@neelofer.tamboli can you raise an issue for this in the pact_broker repository, with an explanation of how to recreate the issue?

dglaubman600
2019-04-09 04:34
has joined #general


neelofer.tamboli
2019-04-09 07:13
Thank you

maximkugatov
2019-04-09 08:20
has joined #general

nathan.deamer
2019-04-09 09:50
@bethskurrie I think the issue was our side and hopefully got to the bottom of it? iOS was outputting 2 x json files for the same consumer / provider. Would be interesting to know if you have any documentation on iOS and microservices.

bethskurrie
2019-04-09 09:54
What in particular about ios and microservices? I'd try asking in the #pact-swift channel.

jon.pascoe
2019-04-09 11:16
has joined #general

nschmuter
2019-04-09 12:49
has joined #general

bheemreddy181
2019-04-09 18:51
I completely agree with this and Clients are so much to maintain

florian
2019-04-09 20:37
has joined #general

harshal.kulkarni
2019-04-10 00:57
has joined #general

matt.fellows
2019-04-10 00:59
does this resonate with you @ghandour.jihad?

ghandour.jihad
2019-04-10 06:35
it completely resonates :slightly_smiling_face: thanks a lot! that was the argument I needed

matt.fellows
2019-04-10 07:03
OK, let us know how you get on with the team - it will be great feedback for us (and perhaps could move it to the FAQs)

ghandour.jihad
2019-04-10 07:07
sure!

oswald.quek
2019-04-10 09:15
@bethskurrie apologies for only getting back to you now. i'm about to deploy the latest pact-broker soon but will it break the way the pact broker client is used? we currently use it like its done at https://github.com/pact-foundation/pact_broker-client/blob/master/spec/lib/pact_broker/client/can_i_deploy_spec.rb#L25

oswald.quek
2019-04-10 09:16
can we instruct the pact broker to ignore a consumer via the pact broker client?

bethskurrie
2019-04-10 09:17
it won't break any existing commands.

bethskurrie
2019-04-10 09:18
hopefully you shouldn't need to tell it to ignore the consumer

bethskurrie
2019-04-10 09:19
let me know if you have issues

oswald.quek
2019-04-10 09:27
great, thanks. we actually did a work around to get our provider deployed (think it was something to do skipping the pact compatibility check) so it might not be a while till we add a new consumer so we can actually test this.

vinod.baradwaj
2019-04-10 10:00
thanks @liran.tal

gnana_margoschis
2019-04-10 16:26
has joined #general

bhollister
2019-04-10 18:05
has joined #general

bheemreddy181
2019-04-11 13:58
@matt.fellows do you suggest to have own interactor on the consumer side for provider or just open the connection where ever need and close it off ?

matt.fellows
2019-04-11 20:25
Sorry I don't know what that means, can you please elaborate?

bethskurrie
2019-04-12 00:08
Yo. If you're using the pact-ruby-standalone for anything (publishing, verifying) you can now run it via docker using `pactfoundation/pact-cli`. Eg. publishing pacts, can-i-deploy ``` export PACT_BROKER_BASE_URL="https://test.pact.dius.com.au" export PACT_BROKER_USERNAME="dXfltyFMgNOFZAxr8io9wJ37iUpY42M" export PACT_BROKER_PASSWORD="O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1" docker run --rm \ -e PACT_BROKER_BASE_URL \ -e PACT_BROKER_USERNAME \ -e PACT_BROKER_PASSWORD \ pactfoundation/pact-cli:latest \ broker can-i-deploy \ --pacticipant Foo \ --latest ``` Try it now just for funsies!

bethskurrie
2019-04-12 00:09
Btw, if you're using can-i-deploy, it's worth upgrading to the latest version of the broker, because the error explanations when you can't deploy are much more helpful.

bethskurrie
2019-04-12 00:10
I've also fixed the 'provider can't deploy without the consumer' issue.

bheemreddy181
2019-04-12 03:46
Is it a good idea to host a own pact broker or use the one registered on http://dius.com @bethskurrie if you have any documentation for setting it up can you please share the same

bheemreddy181
2019-04-12 03:47
Is there a way to set up Auto upgrades on pact broker

matt.fellows
2019-04-12 03:47
As it stands, the documentation for setting it up is on the github page for the pact broker.

bethskurrie
2019-04-12 03:48
I am part of the team at DiUS that runs the hosted broker. If you're interested in having one, you can sign up at http://pact.dius.com.au. It saves you the hassle of managing your own infrastructure, and we've been working hard on it for the last couple of months to add some new features like social login, and a fancy new UI. They're set to be released at the end of April.

matt.fellows
2019-04-12 03:48
Upgrades would require a backup of the DB, re-deployment to your servers with the latest Ruby code base etc. It should migrate without breaking things, unless of course we release a ?breaking change? (signalled by a major version bump in the semver)

matt.fellows
2019-04-12 03:48
I can recommend the hosted service, but then again, I am one of the maintainers of that product :slightly_smiling_face:

bheemreddy181
2019-04-12 03:49
What I mean most of the Ruby on Rails built api are habituated to use Client gems for communication between consumer and provider

bethskurrie
2019-04-12 03:49
If you're using the docker image, you just upgrade the docker image.

bethskurrie
2019-04-12 03:49
The data will be automatically upgraded for you when you start up the broker again.

bheemreddy181
2019-04-12 03:49
I was asking is it recommended to open a HTTP connection where ever required or have provider specific interactor to communicate?

bethskurrie
2019-04-12 03:50
There is an upgrades section in the documentation where any necessary information for upgrading will be noted.


bethskurrie
2019-04-12 03:51
@bheemreddy181 here is the documentation for setting up your own if you're interested in doing that https://github.com/pact-foundation/pact_broker#for-reals

matt.fellows
2019-04-12 03:52
Oh. I don?t have specific opinions about this, other than the ones shared above. Gems like that can be useful, and if it speeds up your development and you can still guarantee the contract will be satisfied (e.g. as described above), then I?d say go for it

steve
2019-04-12 10:39
has joined #general

slack1949
2019-04-12 12:03
has joined #general

david.edwards
2019-04-12 12:29
has joined #general

m.balghonaim
2019-04-12 13:09
has joined #general

m.balghonaim
2019-04-12 13:30
Hello, I have the following questions: 1) Based on what I understood, a pact's interactions are replayed against the actual server when they're verified for the provider. However, how do I work around the scenario where the interaction has hard-coded data in the query params that might not exist in the future (e.g., querying for a deleted user account)? Is that not a recommended usage of pacts? 2) Why must the consumer unit test the interaction against mock server?

thomas.stock
2019-04-12 13:53
has joined #general

bheemreddy181
2019-04-12 13:53
How about the security concerns and downtime support and all other maintenance?

bheemreddy181
2019-04-12 13:55
@matt.fellows ^

thomas.stock
2019-04-12 14:04
@m.balghonaim I'll try to answer, someone correct me if I'm wrong. 1) you're supposed to set up state on your server specifically for the pact interactions. Otherwise you can never make 2 interactions "I have employees in my company" and "I have no employees in my company" succeed because they are mututually exclusive. Here is a (dirty) example of setting up states for 2 interactions.

thomas.stock
2019-04-12 14:10
2) not sure I fully understand your question, but you're supposed to write a test in your consumer that somehow triggers the API call to the mockserver, which will then return the instructed response. This interaction is then recorded into your pact file. So basically you use pact's mockserver as provider in your unit test. The mockserver records the interactions into a file which your real provider can validate against. The unit test guarantees that the API interaction is actually one that is needed by your consumer. if you refactor the consumer code and delete "api.getEmployees()", you will also remove the unit test for getEmployees(), causing the GET to '/employees/all' to disappear from your pact file, so that the provider knows it must no longer provide/maintain this endpoint.

mo.balghonaim
2019-04-12 17:23
Gotcha, thanks! :bulb:

mo.balghonaim
2019-04-12 17:26
But in this case, wouldn't I be hard-coding responses from the actual provider?

matt.fellows
2019-04-12 22:59
The free tier as it stands today comes with email support and automatic upgrades. See my recent post where we enabled a WAF, we have a number of security measures in place.

bethskurrie
2019-04-12 23:03
@bheemreddy181 as a tool that needs to support CI, we are well aware of the need for the service to be as stable as possible, and this was in the forefront of our minds when we rearchitected the platform recently.

bethskurrie
2019-04-12 23:05
I maintain both the open source and the hosted projects, so the hosted platform always has the latest code.

michaelzaporozhets
2019-04-14 04:54
has joined #general

alexplusm
2019-04-14 14:44
has joined #general

mdsucgang
2019-04-15 01:05
has joined #general

thomas.stock
2019-04-15 10:07
Not really, you are preparing your provider's database to be able to respond to the specific interaction. For example: You prove that there is an endpoint GET /employees/all and that, given 'there are no employees', the endpoint will return an empty array. In order to prove this, you set up a database with an empty employees table. For the next interaction 'given there is an employee called Joan, I can find the employee' you insert an employee called Joan in the database and calling /employees?name=joan endpoint should now return that employee. etc

thomas.stock
2019-04-15 10:09
if you look at my screenshot, you see I'm not hardcoding API responses, I'm just inserting stuff in a database. This proves to me (as provider) that my API is able to return the expected/inserted data.

asite-rshah
2019-04-15 11:21
has joined #general

bheemreddy181
2019-04-15 18:51
1. PACT generally comes into picture for syntax for the API response, not for the semantics( what value will I have the particular field ) of the response. You can handle such cases (/DELETE) with having the Provider States where you can populate or mock the response of the database object or populate the DB and perform cleanup at the end. 2. Consumer interaction against the mock server would help Consumer to talk to real service so that we can reply the same interaction on the provider side - @bethskurrie Can you give you a better answer than me

kyle
2019-04-15 20:54
has joined #general

m.balghonaim
2019-04-16 03:35
That makes sense, thanks Thomas :thumbsup:

handa.manik
2019-04-16 06:31
has joined #general

iruben91
2019-04-16 14:32
has joined #general

ian.mcwilliams
2019-04-16 14:46
has joined #general

gopinathlangote11
2019-04-17 08:55
Who is maintainer from pact foundation here? We at our company want to introduce pact broker in our infrastructure. For the same we have some questionaries to get answer from the pact foundation organisation. please DM me, I will continue discussion there.

bethskurrie
2019-04-17 08:55
Ok

mboudreau
2019-04-17 09:21
@gopinathlangote11 there's a few of us here, just ask.

iruben91
2019-04-17 10:12
Hello everyone. My company is currently replatforming all its existing systems into a microservices architecture hosted with a cloud provider and is considering adopting Pact for contract testing between our services. At this time we're using C# and .NET Core and we don't have Ruby developers, so we would be using Pact-Net. Some questions that have been raised are: - Could Pact be used to test contracts between queues and consumers (i.e. non-HTTPlike AMQP)? I came across this Gist (https://gist.github.com/bethesque/0ee446a9f93db4dd0697) and thread (https://groups.google.com/d/msg/pact-support/4QVTdecls9s/3-cJQh1TUTgJ), but I'm trying to understand whether this would be achievable with the Pact-Net library or if it would need plugging into the underlying Ruby implementation. - Are there any future plans for implementing Protobuf testing in Pact? - Is it possible to use Pact-Net's mock server for additional test cases for component testing within the consumer without including all of them in the Pact. I understand that the mock and stub service used by Pact is accessible for additional uses, but I'm unsure whether it is accessible through the Pact-Net library.

matt.fellows
2019-04-17 10:44
Short answer is yes to all 3. For messaging support there is a caveat as the message provider work is currently in flight for .NET. it looks like there is a working branch close to completion, so you might like to check our the GH issues to follow that work

matt.fellows
2019-04-17 10:44
Also, sounds exciting!

matt.fellows
2019-04-17 10:45
I'll try to answer more a bit later once I've finished with dinner etc :laughing:

murphy.meng
2019-04-17 12:06
has joined #general

murphy.meng
2019-04-17 12:08
Great! People are alive here

murphy.meng
2019-04-17 12:10
@beth Sorry I dropped you an email seeking some help before I get in the slack.

murphy.meng
2019-04-17 12:11
I am attempting to implement v3 spec to pact-python. Who is the best contact there to seek help and discuss?

matt.fellows
2019-04-17 12:19
@matthew.balvanz @jose and @richard.jones (pactman) are worth chatting to

matt.fellows
2019-04-17 12:19
Also #pact-python

neil
2019-04-17 12:38
@iruben91 What @matt.fellows said. Have a look at the `message-pact` branch. You can build a nuget package from that branch if you?d like to use it.

neil
2019-04-17 12:41
For question 3, you can always run another instance of the mock service and just ignore the pact file. Otherwise if you don?t call `.Build()` on the `PactBuilder` the pact file won?t even be written.

iruben91
2019-04-17 13:16
Thank you for your help! So, I understand that AMQP support is nearing completion, and that the mock and stub Pact server can be used separately for other non-contract tests. So, are you saying that the Protobuf support may be being considered for future iterations of Pact?

neil
2019-04-17 13:23
Yeah message support is getting close, we just need to put in some time to cleanup the api and finish things off. I just haven?t had the time lately. Yes it should be, however I?d recommend you run some PoC to see if it works for what your are trying to do. I?m not sure on the status of Protobufs TBH. Check out #protobufs for the conversations.

marc
2019-04-17 13:27
has joined #general

000sps97
2019-04-17 13:45
Hello everyone,

000sps97
2019-04-17 13:48
i am using Pact Provider Verification for verifying pacts using CLI i want to use multiple tags so that i can verify all the pacts containing the tags, like i have 2 pacts, one with tag as "develop" version 1.2 and other with "abcd" version 1.0 i want to run all the interactions in for given two tags at the same time (for checking backward compatibility )

000sps97
2019-04-17 13:49
this the command i am running `./pact-provider-verifier --provider=ApiGatewayProvider --consumer-version-tag=develop --provider=ApiGatewayProvider --consumer-version-tag=abcd --provider-base-url http://localhost:4000 --pact-broker-base-url=http://localhost:9292` it was written in documentation that we can use --consumer-version-tag multiple time

000sps97
2019-04-17 13:52
but its overwriting the tag and searching for only tag abcd instead of both

murphy.meng
2019-04-17 14:11
@matt.fellows pact-mock_service claims it support spec v3, does it support mocking messaging? If yes, any chance I have some examples? If no, how jvm and golang client claim they do asynchronous api? (I did assume all impls relies on pact-mock_service the ruby impl)

nodkane12
2019-04-17 14:22
has joined #general

nodkane12
2019-04-17 14:27
Hi everyone! I'm using Pact for Node.JS and Mocha and I've been using the example provided in the mocha examples section of the Pact-JS repo; I want to validate the pact generated from the local pact server against some external API that is for all intents and purposes a black box. there doesn't seem to be any documentation on how I can go about doing this, (I appreciate this is probably not the right channel, but I'm not sure which one to post this in)

ariel
2019-04-17 15:12
has joined #general

simon.nizov
2019-04-17 16:03
Looking for implementation details regarding tagging pacts when using feature *toggles*, not branches. I?m implementing step 5 of the pact nirvana guide https://docs.pact.io/best_practices/pact_nirvana#5-allow-contracts-to-change-without-breaking-your-builds. Trying to figure out what?s the best way to pass the feature toggles to my CI build which publishes the pact with `pact-broker publish`. Anyone willing to share?

tmok01
2019-04-17 21:41
hey all - quick question for you all. When a consumer publishes a pact to pact-broker which is the same as the last pact it published, is it supposed to require the provider to verify it again? (It looks to me as though it does)

matt.fellows
2019-04-17 22:08
No, if the contract hasn?t changed the previous verification result still applies.

matt.fellows
2019-04-17 22:08
The caveat to this is that if you are generating random values in the contract, the broker will detect this as a change and expect a new verification

matt.fellows
2019-04-17 22:09
Can you please elaborate further by ?mock? in this context?

matt.fellows
2019-04-17 22:10
In short, it supports messaging, but we work at a different layer of abstraction. Rather than implementing the thousands of various messaging protocols, we expect you to separate out the bit that creates the _message_ from the bits that send that message over a wire format. The bit that generates (and on the other side, consumes) the message is the bit we test in Pact

matt.fellows
2019-04-17 22:10
Have you looked at the examples?

matt.fellows
2019-04-17 22:11
Might be worth chatting in #pact-js

matt.fellows
2019-04-17 22:12
It isn?t ideal, but it is doable. There is no reason why you couldn?t just point the provider verification at the external service (rather than a local one). What have you tried so far?

matt.fellows
2019-04-17 22:12
And what issues have you encountered?

mboudreau
2019-04-17 22:15
is this front-end or backend feature toggles?

simon.nizov
2019-04-17 22:35
@mboudreau backend

tmok01
2019-04-17 22:53
Thanks for that Matt. But I seem to have a situation in my pact broker matrix that contradicts that ....

tmok01
2019-04-17 22:55
What would be the process to get some help with this?

mboudreau
2019-04-17 23:25
Right, so you want your feature toggle backend to have a contract with an API? I need more context here :P

ylin
2019-04-18 03:13
has joined #general

matt.fellows
2019-04-18 03:39
Ideally an isolated reproducable test that we can use to identify the cause. There is a test pact broker you can publish to if you need

murphy.meng
2019-04-18 07:04
Yes. @matt.fellows, had gone through all examples (groovy and go impl) but I did not feel myself understood. I don?t see a single example that shows how it actually works with a actually messaging broker. True I know pact does abstraction for messaging recv/produce, but the integration part (make it work with activemq, kafaka) is the bit I am after.

murphy.meng
2019-04-18 07:09
By ?mock? in my question, I mean in a consumer testing for async api, do you expect a real message client (stomp, openwire transport) integrated with pact client, and in the test code, it is the messaging client which sends out the messages __generated__ by pact client? If the answer is yes. I definitely expect the pact mock server should be able to receive the message, read out and parse the body before it generates the pact. However the pact mock server does not have the ability to receive messages (abstraction remember?), then what extra work we need do to help the mock server to consume real messages? I dont see any option to do so in pact-mock_service cli.

murphy.meng
2019-04-18 07:11
(I did not make it clear enough perhaps, when I say mock in my question, I though concept-wise, pact could even mock the message recv/produce with normal http transport, thus it is not actually testing asyn api under the hood)

nodkane12
2019-04-18 07:56
```It isn?t ideal, but it is doable. There is no reason why you couldn?t just point the provider verification at the external service (rather than a local one). What have you tried so far?``` I tried that, I changed the provider verification to the dummy API I am using as a proof of concept, but got an error to the tune of: ``` Pact verification failed! Actual interactions do not match expected interactions for mock MockService. Missing requests: GET /api/v1/employees ```

simon.nizov
2019-04-18 08:02
@mboudreau I want to be able to make changes to my ?main branch? pact, without breaking the consumer build. My understanding is that this should be done by tagging the pact with some kind of indication, ideally derived from a feature toggle.

matt.fellows
2019-04-18 08:08
that?s the consumer side verification.

matt.fellows
2019-04-18 08:08
you definitely can?t point at another API endpoint during consumer verification - you _must_ point at the mock service. On the provider side verification you can do this

nodkane12
2019-04-18 08:17
Ah. There's nothing in the example about how to set up the provider side verification for js & mocha

matt.fellows
2019-04-18 08:24
which example?

matt.fellows
2019-04-18 08:27
the end-to-end example has one



nodkane12
2019-04-18 08:30
Ah, I was looking at the Node.JS Mocha example folder in the Github Repo


matt.fellows
2019-04-18 08:39
Np

matt.fellows
2019-04-18 08:39
Did that help? The framework you use is largely irrelevant

nodkane12
2019-04-18 08:52
In a sense, yes. I'd have liked to use mocha framework in that example, but it looks like that's a no-go.

nodkane12
2019-04-18 08:52
Thanks

matt.fellows
2019-04-18 08:55
It is mocha

matt.fellows
2019-04-18 08:57
What do you mean?

nodkane12
2019-04-18 08:59
I meant the framework example in the repo folder

nodkane12
2019-04-18 08:59
it seemed simpler

matt.fellows
2019-04-18 09:17
Oh ok. Yes the e2e is more fully features to show the capabilities. You won't need them all in most cases

nodkane12
2019-04-18 09:20
Cool, thanks again

matt.fellows
2019-04-18 11:34
Sorry was out at a family thing. Ping me if things aren't clear

murphy.meng
2019-04-18 13:01
@matt.fellows, does it make sense?

murphy.meng
2019-04-18 13:13
Can someone point me to examples of what provider tests SHOULD cover apart from validating the replay of contracts? I thought I read through all documents of pact general, pact go impl, pact python impl and pactman impl, but I did not find answer. For example, provider provides endpoint /user/some_name for GET and the response is json about the user. The consumer testing is apparently about whether the response contains all mandatory fields and if they are in proper format/content and write it to contract. What is left to provider tests? What the provider team should test out of the scope of contracts provided by its client? Why it does not do such testing in normal unit framework, but under pact?

chris.empson
2019-04-18 14:26
has joined #general

simon.nizov
2019-04-18 15:02
https://docs.pact.io/best_practices/consumer#use-pact-for-contract-testing-not-functional-testing-of-the-provider https://docs.pact.io/best_practices/consumer/contract_tests_not_functional_tests These two parts of the docs should answer your questions. Basically Pact provider verification is just an additional layer to your provider tests. You should continue writing functional unit and integration tests for you provider service as you did before.

albertot
2019-04-18 16:31
has joined #general

albertot
2019-04-18 17:15
I'm hoping to find a solution or workaround for my problem. The provider returns something like this: ``` "ratings": [ { "id": 12, "count": 4 "average": 3.75 }, { "id": 37, "count": 1 "average": 4 }, { "id": 143, "count": 0 "average": 0 }, { "id": 574, "count": 6 "average": 4.333333 }, ] ``` My matcher is ``` ratings: eachLike({ id: like(15), count: like(20), average: like(4.5) }) ``` When I validate the provider, I get `Expected a Float (like 4.5) but got a Fixnum (0)`. It looks like this is by design. Any way around it?

murphy.meng
2019-04-18 21:09
Exactly, exactly! These two references are totally on my side, thanks Simon.

murphy.meng
2019-04-18 21:14
I should rephrase my question to be, APART FROM consumer side tests, and scenarios that should be covered by functional testing, what should be covered in provider side testing? (My current confusing is, I can imagine NONE, note in the useful article https://docs.pact.io/best_practices/consumer/contract_tests_not_functional_tests it discussed consumer testing, rather than provider testing)

matt.fellows
2019-04-18 23:25
Hmm I'm not sure actually

matt.fellows
2019-04-18 23:26
As an aside, you don't need to nested `like` in the `eachLike` (superfluous) and this probably should have been asked in the js channel.

matt.fellows
2019-04-18 23:29
I think so. The mock service only talks http at this point and not any of the messaging protocols at this stage (we are experimenting with protobufs atm). For now, you can't use it to mock directly an async service

murphy.meng
2019-04-19 07:28
How consumer tests for asny api are performed then? like jvm and go impl?


matt.fellows
2019-04-19 07:45
And then look at the example tests in those repos (pact js too)

jadedevin13
2019-04-19 09:05
has joined #general

vivek.thangathurai
2019-04-19 11:21
has joined #general

vivek.thangathurai
2019-04-19 11:27
Hello

vivek.thangathurai
2019-04-19 11:29
I want to pass the tags to provider tests with @PactBroker(tags ="${pactbroker.tags}") as a system/environment varaible using gradle.. but even if I pass the variable to the test in gradle it is not being picked up by the provider.. it says `java.lang.RuntimeException: Could not resolve property "pactbroker.tags" in the system properties or environment variables and no default value is supplied`

vivek.thangathurai
2019-04-19 11:31
`systemProperty "pactbroker.tags", System.getProperty("pactbroker.tags")` passing the value to gradle task as -Dpactbroker.tags=latest,1.00

albertot
2019-04-19 13:16
I did ask this in the JS channel, but this is not a JS channel exclusively. I tried your hint of removing the `like`s inside and I still get the same errors. The provider validation fails any time a whole number is returned without a decimal component (that is, `0.0` or `4.0` in this case). I understand failing when I expect an integer and I receive a float. But failing when I expect a float and I receive an integer is an bug in my book (and in math books too). So far we have been impressed with Pact and want to adopt it, but this bug is a show-stopper for us.

albertot
2019-04-19 14:13
:point_up: s/JS channel/JS issue/

matt.fellows
2019-04-20 00:48
Can you please raise an issue? Seems worth investigating

matt.fellows
2019-04-20 00:49
The hint was just to DRY up your code, the outcome is the same (matchers Cascade)

mpglover
2019-04-22 02:11
has joined #general

vitaliy.grigoruk
2019-04-22 12:14
I guess you can do something like ?feature A is enabled? in providerState for interactions affected by a specific toggle

simon.nizov
2019-04-22 12:22
@vitaliy.grigoruk How will that make my provider verification process skip that updated pact?

mvpatel1982
2019-04-22 13:26
has joined #general

albertot
2019-04-22 14:53
Is there a particular repo I should raise this in? After some investigating, this is in the Ruby core. Would `pact-ruby` be the best project?

matt.fellows
2019-04-22 23:28
That would work I think

j
2019-04-23 02:41
has joined #general

mitchell.davis
2019-04-23 06:50
has joined #general

vitaliy.grigoruk
2019-04-23 09:23
it looks like I didn?t understand your question correctly, @simon.nizov.

al
2019-04-24 13:38
has joined #general

gavrie
2019-04-24 14:52
has joined #general

audun.halland
2019-04-24 19:08
has joined #general

audun.halland
2019-04-24 19:34
Hi all. I recently noticed the `pact-reference` Rust project, and got the impression that this will somehow maybe some day act as replacement for `pact-ruby`. Background is that I've been having some problems with `pact-js` and pact spec 3. So this has spawned my curiosity a bit and I'm just wondering how to be of any help contributing to the stabilization of that project. The roadmap states that it's Alpha. I did not find a (public) slack channel devoted to that project.

audun.halland
2019-04-24 19:35
I'm just a big fan of the pact framework, my team and project gets great value out of it, and I'm interested in helping if it's wanted.

matt.fellows
2019-04-24 22:28
Thank you and yes, help is always wanted.

matt.fellows
2019-04-24 22:29
The tldr is that we've been busy with lots of things and whilst this hasn't been forgotten it's probably pushed back in terms of priority

matt.fellows
2019-04-24 22:29
That being said, how can we help you help us? :laughing:

mboudreau
2019-04-25 02:51
@audun.halland ^ What he said. I'm personally committed in getting the rust binary done so we can stop having to spin up another binary in ruby, which is a pain, and then having to manage it all. Problem is time and that so many are already using what we have and we're constantly trying to fix issues and help those get started with Pact

uglyog
2019-04-25 04:32
@audun.halland I wrote the rust library to be a DLL that can be loaded into any language implementation. It is V3 compliant, and has the same features as Pact-JVM. It is ready to be used, but there may need to be some integration work to be done. The best way to help would be to try use it with another language (i.e. JS)

uglyog
2019-04-25 04:33
There is the #pact-rust channel

uglyog
2019-04-25 04:34
The roadmap has not been updated for a long time

audun.halland
2019-04-25 06:00
Thanks, I joined that channel. Can continue discussion there.

audun.halland
2019-04-25 06:12
I'm working with a node.js provider for the first time and then I noticed the problems with pact spec 3 with the ruby verfier CLI. So if pact-ruby is not going to be prioritized in the future, pact-node should probably use rust verifier-CLI/mock-server instead (ASAP?). But the rust DLL didn't appear very stable to me, hence the bug I reported about https pact broker. So two things I can contribute some time to: 1. Fix rust "DLL". 2. Rewrite pact-node to use that instead of ruby

matt.fellows
2019-04-25 08:09
I would suggest pact node stay as is (as it has utility separate to what the dll will provide) and it moves straight into Pact JS. We also don't really need another CLI for pact stuff and want to reduce the number of packages we need to maintain.

matt.fellows
2019-04-25 08:10
There are other gaps in the rust impl which I'll try to draw up later (and share my previous notes on the matter)

s1apped
2019-04-25 09:47
has joined #general

s1apped
2019-04-25 09:58
hello. Maybe you will be able to help. So I setup pact broker with jenkins and can-i-deploy and added webhook

s1apped
2019-04-25 09:58
contract_content_changed

s1apped
2019-04-25 09:58
but unfortunetally

s1apped
2019-04-25 09:59
provider build is being triggered everytime eventhough pact didn't change

bethskurrie
2019-04-25 09:59
Open the pact

bethskurrie
2019-04-25 10:00
In the browser. Click on the "view in api browser" button.

bethskurrie
2019-04-25 10:01
You'll find a relation in the api browser that says something like "diff previous distinct version". Click on the button to follow that relation.

bethskurrie
2019-04-25 10:01
You'll see what's changed.

matt.fellows
2019-04-25 10:03
@s1apped just check that if your consumer code is falling back on the test library (e.g. Pact JVM) to generate values for code, things like dates etc. might change - this will result in a contract changed event

s1apped
2019-04-25 10:04
I checked diff and it doesn't make sense it showed some old differences

s1apped
2019-04-25 10:04
I will investigate further than

s1apped
2019-04-25 10:04
thank you :slightly_smiling_face:

s1apped
2019-04-25 18:33
I made some investigation

s1apped
2019-04-25 18:33
there is no diff

s1apped
2019-04-25 18:34
i cleaned up everything and started from scratch

s1apped
2019-04-25 18:34
the pact file looks ok

s1apped
2019-04-25 18:34
the webhook and build is only triggered when

s1apped
2019-04-25 18:34
there is new commit on consumer side

s1apped
2019-04-25 18:35
when i run consumer build without a change nothing happens

s1apped
2019-04-25 18:35
to be hones I'm out of ideas..

joelbyler
2019-04-25 18:50
has joined #general

1490665859
2019-04-26 03:32
has joined #general

ashish.dubey91
2019-04-26 07:26
what?s the recommended way of doing provider verification when the provider may be aggregating responses from more upstream services (its providers?)?

bethskurrie
2019-04-26 07:27
this one is tricky to be honest

ashish.dubey91
2019-04-26 07:27
1. do you run instances of all the services in an environment and do a verification against them? 2. or run the provider against the mocks of the upstreams?

bethskurrie
2019-04-26 07:28
you can write pacts between the intermediate service and the downstreams and use them to verify the pact with the upstream... BUT it gets quite fiddly

bethskurrie
2019-04-26 07:29
tbh (and I say this as one of the main authors of pact) this is one of the hardest scenarios to use pact in.

ashish.dubey91
2019-04-26 07:29
yeah especially when we end up in a scenario, where we want to verify a pact that a consumer has written and to do that we have to write a pact between all services in the chain

ashish.dubey91
2019-04-26 07:30
I?m trying to figure out if we can ease this somehow for our teams

bethskurrie
2019-04-26 07:36
What languages are you using?

ashish.dubey91
2019-04-26 07:40
python mostly

ashish.dubey91
2019-04-26 07:40
and Java for one consumer

bethskurrie
2019-04-26 08:10
Which python impl?


bethskurrie
2019-04-26 08:52
So, here's one technique I've used, but it would require a little addition to the python code.

bethskurrie
2019-04-26 08:54
In the ruby code, you can create a pact request or response object outside of the dsl that is used to set up the mock. You make a fixture (not sure if the same term is used in python). Then, you use the same fixture to generate the downstream pact, and response to the upstream pact.

bethskurrie
2019-04-26 08:56
You have to "reify" the response object (turn it from the pact object with likes and matchers into a concrete example) to use it, and this bit of functionality isn't available yet in the python lib

ashish.dubey91
2019-04-26 09:01
do you have this as an example somewhere?

bethskurrie
2019-04-26 09:02
No, unfortunately it was for a client years ago.

bethskurrie
2019-04-26 09:02
If I get time, I'll see if I can recreate a simple example.

ashish.dubey91
2019-04-26 09:03
thanks a lot. I can imagine this a little bit, infact we tried something similar, but I want to sure it?s the same thing. I?ll share something from my end as well in a bit

ryan.wicken
2019-04-26 09:10
has joined #general

s1apped
2019-04-26 09:44
@bethskurrie @matt.fellows I created an issue and added some details


bethskurrie
2019-04-26 09:47
@s1apped do you have access to the logs?

bethskurrie
2019-04-26 09:47
If I put in some extra logging so that it indicated what it thought had changed would you be able to get to those logs?

s1apped
2019-04-26 09:47
I think I might be able to get it

s1apped
2019-04-26 09:48
I'm running the pact broker docker

bethskurrie
2019-04-26 09:50
Cool. I'll add the logging and let you know when it's out.

s1apped
2019-04-26 09:51
awesome

s1apped
2019-04-26 09:51
thank you

mokhtar.neifer
2019-04-26 10:32
has joined #general

joelbyler
2019-04-26 14:25
question, is it possible to use a standalone mock server to stand in and develop against?

joelbyler
2019-04-26 14:25
(in addition to running tests against)

yousafn
2019-04-26 14:46
It is, we run it in a docker container and load in a pact file. The container is then uploaded to ecr and run in ecs ( on AWS ) None of our dependencies are ready yet so this is the only way we can test our journies e2e through our ui

bethskurrie
2019-04-27 00:40
Pact peeps of all unit testing frameworks (just normal ones, not pact ones) - if you mark a test as pending, and it passes, does your test fail or pass? Please let me know in this thread.

bethskurrie
2019-04-27 00:40
In rspec, a pending test that passes, fails.

matt.fellows
2019-04-27 01:01
Skipped tests cause a suite to pass in most JS frameworks

matt.fellows
2019-04-27 01:11
What is a pending test that passes, exactly?

bethskurrie
2019-04-27 01:18
In rspec, you mark a test with "pending: true" in the metadata. It still runs, but if it fails, the test overall does not fail - it's like saying, I expect this to fail

kgrabowski
2019-04-27 09:02
has joined #general

joelbyler
2019-04-27 16:03
Ok, is there a good resource for learning how this can be done? The docker / aws part isn?t necessary. Just trying to do this locally for now. Also preferably with ruby.

joelbyler
2019-04-27 16:03
I see some instructions in the wiki for the ruby gem but I?m having trouble following. And it says no interactions match

joelbyler
2019-04-27 17:25
Oh, maybe the pact-mock_service gem?

yousafn
2019-04-27 19:40
Yeah chap, that is what we load into our containers. Pass it a pact file and it will mock the provider. You can use matchers to make the interactions less restrictive :ok_hand:

abubics
2019-04-28 03:52
In most frameworks I've used, pending tests don't get run :thinking_face:

bethskurrie
2019-04-28 03:53
interesting. rspec may be the outlier then.

bethskurrie
2019-04-28 03:53
you use "skip" or xdescribe if you don't want it to run at all.

abubics
2019-04-28 03:57
Ah... In that case, I think most frameworks don't have a distinction between pending and disabled :upside_down_face:

matt.fellows
2019-04-28 04:02
Yeah. It seems unusual, or at least, I?ve not come across it / needed it. I can see why a passing pending test would fail a suite in this case though

biaofu
2019-04-28 06:07
hi guys, in the past a few months, I saw several pots/discussions talked about "should it replaces e2e integration test with contract test?". We have some documents describes this topic, e.g. https://docs.pact.io/faq. I know the consideration to answer this question could be emanative, it depends on lots of uncertain factors, e.g. service environments, risk tolerance, even teams coordination. Some of my points are that both e2e integration tests and contract tests have their own pros & cons, usually, in common situations, I don't think one can or should be "replaced" with another. So, how do you guys personal feel about this question? Would like to hear any opinions from you. :slightly_smiling_face:

bethskurrie
2019-04-28 06:29
They replace a certain class of integration tests (eg the ones you do to make sure that you're using the API right). They don't replace the tests that ensure that the core business logic of your services is working.

bethskurrie
2019-04-28 06:30
Ideally, they should allow you to write fewer integration tests.

biaofu
2019-04-28 06:37
yes, the same opinion with you.

bethskurrie
2019-04-28 06:37
Do we say otherwise in the FAQ? Maybe it needs clarification.

biaofu
2019-04-28 06:43
I?m not so clearly understanding your ?otherwise? here, but we do mentioned the ?core business? in the FAQ, just not as straightforward as we chat here, haha

bethskurrie
2019-04-28 06:47
I'll have another look at the text.

biaofu
2019-04-28 06:48
Another thing people always talks about but never makes it clear is that when we talk about ?integration test?, whose integration tests are we pointing to? The consumer?s integration test or the provider?s integration test?

bethskurrie
2019-04-28 06:49
Either, I guess. Anything when the two systems are both up and running and calling each other.

biaofu
2019-04-28 07:17
let?s say, service A calls C constructing contract ?a2c?, service B calls C constructing contract ?b2c?, and whenever C is called, it will call its own dependence service D, then there is a contract ?c2d?. So, when we talk about ?should contract test for ?a2c? or ?b2c? replace their integration tests??, it?s not quite clear the ?integration test? is pointing to which services, A,B,C,D? Since the contracts ?a2c? and ?b2c? could have totally no overlap at all, then, we say, contract ?a2c? could replace some parts of ?the? integration test, let?s say it integration-test-a2c, the same, we have the integration-test-b2c, due to there is no overlap between these two collections of integration tests, both of them together construct a full collection of service C?s integration tests, which will call service D as well. So, in this cases, if we don?t point out whose integration test we are talking, it could be confusing. My understanding is, to a single service (it could be consumer or provider in different context), contract test is only Consumer concerned but Provider independent, while integration test is only Provider concerned but Consumer independent.

bethskurrie
2019-04-28 07:19
I'm afraid I got lost there!

biaofu
2019-04-28 07:19
I guess you will :sweat_smile:

simon.nizov
2019-04-28 08:20
@ashish.dubey91 @bethskurrie I would love to see those examples as well

joelbyler
2019-04-28 12:19
Thanks for the advice, I?m very new to this but excited to give it a go. Will try it out this week. :yay:

luchillo17
2019-04-28 16:39
has joined #general

luchillo17
2019-04-28 16:45
Hi, i'm trying Pact and i can't grasp yet how to test properly in the backend, say if i have a DB, should i just input the data the contract expects in my DB before the Pact contract verification?

hstene
2019-04-28 16:58
Yes, this is what states are for! :smile:


abubics
2019-04-28 23:56
ideally, stub out the DB, so you have fewer moving parts . . . but second choice is to seed the database :slightly_smiling_face:

abubics
2019-04-28 23:59
Diagrams to help this explanation :ok_hand: ``` A B \ / C | D ```

abubics
2019-04-29 00:01
there are 2 main categories of integrat*ed* tests . . . ones that make sure the real deployed services are talking to each other (smoke tests), and ones that make sure the "core business logic of your services is working", regardless of where they're deployed (integration)

abubics
2019-04-29 00:02
Pact doesn't intend to replace smoke tests, but it can/should mostly replace other integrated tests :slightly_smiling_face:

franklin.huynh
2019-04-29 01:06
Hi, I'm trying to apply can-i-deploy to our service using bitbucket pipeline. A bit of context, as our QA owns a container where we installed all the required packages/tools. In this, QA will easily enable/disable if it fails in the contract test. Our pipeline looks like this ``` branches: master: - parallel: - step: *unit-test - step: *security-test - step: *contract-test - step: *deploy-to-dev - step: *can-i-deploy-staging - step: *deploy-to-staging - step: *tag-staging - step: *can-i-deploy-production - step: *deploy-to-production - step: *tag-production ``` There is a 10 steps limitation in the pipeline that make me think about I should reduce the steps of contract test (there are 5 steps occupied in the above script). My question is do we have any best practise or recommendation to apply can-i-deploy?

biaofu
2019-04-29 02:17
@abubics, your opinion is quite clear, I like that. But I think the point, that to replace ?the other integrated tests which checking the core business logic?, is against to what @bethskurrie mentioned above, and our FAQ also.

biaofu
2019-04-29 02:29
Personally, I agree that Pact shouldn?t focus too much on the ?core business logic?, but only focus on ensuring Provider is responding to its Consumers correctly. To checking the core business logic, it?s the duty of those integration tests, no mater they are integrat*ed* (e2e) or not.

bethskurrie
2019-04-29 02:32
It's the duty of the provider's functional tests to make sure that its doing what it should. One mistake that often gets made is using the consumer as a test harness for the provider.

biaofu
2019-04-29 02:33
Yes, that?s definitely correct!:handshake:

bethskurrie
2019-04-29 02:33
Eg. It's not the consumer's job to make sure that when you do a post to a collection resource, that the new resource is properly created and then available in the collection

luchillo17
2019-04-29 03:35
I'm working with Neo4j, a graph based DB, i want to test with the DB to ensure the graph model is actually constructed correctly so i think i should seed the DB, hopefully it's faster (the DB is supposed to be 100x faster than RDBMS)

abubics
2019-04-29 03:54
yarr . . . contract tests are for the communication interface between systems (i.e. consumer and provider), not for actual business logic testing. That's what functional tests are for :ok_hand:

abubics
2019-04-29 03:56
so, I mean, you can :slightly_smiling_face: no one will stop you :stuck_out_tongue:

abubics
2019-04-29 03:57
but if you need a very large fixture, it's likely that your domain model is wonky

abubics
2019-04-29 03:58
if you want to assert things about content, rather than content shape, the contract is likely not what you're testing :slightly_smiling_face:

myao
2019-04-29 04:14
has joined #general

s1apped
2019-04-29 07:43
and contract didn't change

s1apped
2019-04-29 08:48
@bethskurrie I went through your response on github

s1apped
2019-04-29 08:48
If the pact's consumer version is tagged, then it looks for the latest version with each of the tags, and fires if the content has changed or if there was no previous version with that tag.

s1apped
2019-04-29 08:48
In my case consumer is tagged with branch name, there is a previous version

s1apped
2019-04-29 08:49
but contract didn't change

s1apped
2019-04-29 08:49
so if I understand correctly webhook shouldn't be triggered

andfadeev
2019-04-29 09:57
has joined #general

jonathan.ruckwood
2019-04-29 11:48
has joined #general

luchillo17
2019-04-29 16:10
I do want to test the content shape, but there's data that depends on other data, which is used in the query but not sent back to client, that's why i think i need to seed the DB

luchillo17
2019-04-29 16:11
Hey i know Pact is Consumer Contract Testing, is there a way to make it work as Producer Contract Testing?, like defining the Contracts from the Provider instead of the Consumer?

hstene
2019-04-29 16:41
I am not sure of what you are thinking of here? What is the end goal? What are you trying to test?

bheemreddy181
2019-04-29 17:29
Maybe like Generate a Schema from Provider API and validate each time the schema changes @luchillo17 ?

bheemreddy181
2019-04-29 17:32
@bethskurrie @matt.fellows similar to the above question - I felt like PACT does give a provision of breaking contracts if none of your consumers is using few fields from your API or not bothered if the type is changed? yet all ?

bheemreddy181
2019-04-29 17:33
What if I generated a schema from Provider side once I create my API and validate my API each time I do a change?

luchillo17
2019-04-29 17:39
I want the contract to be generated in the server & the client consumes that contract in their testing

luchillo17
2019-04-29 17:41
I want the server to dictate the shape of the data, generate the contract, upload it to the broker and then use it in the client, possibly even publishing the contract so external API's or third parties can develop with the contracts

bheemreddy181
2019-04-29 18:32
@luchillo17 what if you are changing the contract - that is something which is expected by the consumer then you generate it but the consumer expectations fails and you still want to release it

bheemreddy181
2019-04-29 18:33
the main reason of PACT is to have Integration to happen earlier get the feedback faster on each PR itself if the are changing some expectations of Consumer

bheemreddy181
2019-04-29 18:34
Syntactically - than Semantics of what the value is and how the values is generated

luchillo17
2019-04-29 18:35
I would expect the contract to change only when the API changes, and the Client would adapt to that change, our app is DB heavy so most business logic would go in the Back End

bheemreddy181
2019-04-29 18:37
How does you expect client to adapt the changes untill unless you know what client uses

bheemreddy181
2019-04-29 18:39
which might also lead to having just one version of the API unless needed

luchillo17
2019-04-29 18:40
Let me see if i understand correctly how PACT is supposed to work (as far as i've read): Client defines it's test along with the expected request & response, generating a Contract, then API would load the Contract in it's test and use that to assert the expected request & response If the client changes the expected request/response then the contract changes & the API test could fail, in such case the API is expected to make changes to comply with new contract Somethink like that?

bheemreddy181
2019-04-29 18:41
it is two way not only from the Client ( Consumer ) Side

bheemreddy181
2019-04-29 18:42
even if the providers changes the API - he would know he is breaking a consumers expectations on a particular or set of fields

bheemreddy181
2019-04-29 18:44

pascal.wilbrink
2019-04-29 20:33
has joined #general

pascal.wilbrink
2019-04-29 20:34
Hi all

biaofu
2019-04-30 01:56
hi @luchillo17, if you really want to define the contracts at provider side and use the contracts to test your provider service, then, you are probably duplicating the functional test, not contract test to the provider. Actually, the quintessence of contract test is ?customer driven?, if you can?t manage to achieve that due to some reality reasons, e.g. team communication, network boundary, Pact won?t bring you more benefits than functional tests. Or, another option is, maybe, you can look at Spring Cloud Contract, another implementation of contract test, which create the contracts from provider side.

kevin.meiresonne
2019-04-30 07:57
I'd say "consumer driven" rather than "customer driven"

biaofu
2019-04-30 08:24
yes, consumer driven :sweat_smile:

abubics
2019-04-30 08:27
when you say > data that depends on other data it sounds like you might be testing behaviour through concurrent calls :thinking_face: if that's not what you mean, please explain your use case a bit more :slightly_smiling_face:

bethskurrie
2019-04-30 10:00
Exactly

bethskurrie
2019-04-30 10:02
consumer contracts remove the need to version an API. API versioning is a "work around" because you don't want to break backwards compatibility, and you don't know who is using your API. It's the best technique for a public API. When you know all your consumers, and you know exactly what they're using, you know the impact of changing, and hence, you should be able to avoid versioning the API.

bheemreddy181
2019-04-30 12:28
@bethskurrie ^

bheemreddy181
2019-04-30 13:40
Completely agree :)

bheemreddy181
2019-04-30 13:41
What I meant is documentation driven contract testing

bheemreddy181
2019-04-30 13:41
Where you create a base schema and validate the change against it

bheemreddy181
2019-04-30 13:42
I think this would be again good for public api where you don?t know the consumers

luchillo17
2019-04-30 16:20
Hey @bheemreddy181 I've looked at the document you sent and it makes a lot of sense, i wanted the contract to be defined in the Producer (API) because my back end devs are way more knowledgeable about the business logic, guess i'll have them help the front guys with the tests. thanks.

bheemreddy181
2019-04-30 16:21
Cool - have a great contract testing

qatrera
2019-04-30 16:32
If I understood Contract testing correctly, we shouldn't use this kind of testing to test the business logic but to verify the interfaces of your application

qatrera
2019-04-30 16:32
to test your business logic you have unit/integration tests

luchillo17
2019-04-30 16:50
Yes, i just wanted to have the same guys that know the backend to design the contract for the interfaces

bheemreddy181
2019-04-30 17:18
@qatrera Unit and Functional Tests -- Shift left to decrease the level of Integration tests - The main intention of having PACT is to release micro-services independently

luchillo17
2019-04-30 19:11
Yeah sorry my english isn't the best, let me try with an example, to test 1 of the end points i need to have an user, have data in the DB, the user is related to a set of the data, and the data i need is related to that set, say for example a teacher who has courses and each course for that teacher has students, if i need the students for a teacher i have to go through the course, while ensuring students of other courses are not returned (Btw this is an example, not my actual application)

matt.fellows
2019-04-30 22:07
@luchillo17 we?re looking at how we introduce Swagger/provider-driven testing into our Pact broker offering (http://pactflow.io). Stay tuned :slightly_smiling_face:

evgone
2019-04-30 22:57
has joined #general

bheemreddy181
2019-04-30 23:20
@matt.fellows can you explain that ?

bheemreddy181
2019-04-30 23:21
Swagger or provider driven testing mean generating a schema from provider and keep testing against that each time there is a change ?

stipud
2019-05-01 00:17
has joined #general

biaofu
2019-05-01 02:53
I?m also doubting what the benefits it will bring from the Swagger/Provider-driven testing? Test which service? provider or consumer? If it helps to test the provider, then it would just be a functional (integration, maybe) testing at the provider side, if it helps to test the consumer, then the contract from Swagger could only be used as a stub to a mock service, then consumer can talk to such mock service to do an integration test, is that the purpose? If so, that?s what Spring Cloud Contract exactly doing.

biaofu
2019-05-01 02:53
That is not contract testing, but ?integration testing based on contract?.

matt.fellows
2019-05-01 03:05
I'll explain later, but rest assured we wouldn't suggest it if it wasn't possible to validate both sides of the contract (in this case the OAS spec)

bheemreddy181
2019-05-01 03:44
your inputs on this will be appreciated @bethskurrie - i am still learning so making basics strong

abubics
2019-05-01 04:15
So, in this example, you want to test one API endpoint (provider) that makes 3 db requests, and transforms them into a response?

abubics
2019-05-01 04:16
It's not the contract test's job to ensure data integrity between calls (in the "while ensuring students of other courses are not returned" example)

abubics
2019-05-01 04:16
That's more of a functional or unit test responsibility :slightly_smiling_face:

luchillo17
2019-05-01 18:24
Hmm has Pact some plugin to make it work with Apollo-Client?

uglyog
2019-05-01 23:27
There has been some discussion about whether you need something like Pact for GraphQL. But there is probably no direct support for it.

bethskurrie
2019-05-01 23:55
@luchillo17 re getting your back end and front end teams working together - absolutely! Pact is not meant to be a replacement for good communication between teams. It's meant to help facilitate it. Never stop talking! Tests don't replace talking.

joostvanwollingen
2019-05-02 11:45
has joined #general

luchillo17
2019-05-02 16:00
Thansk guys, this thread is an eye opener for me.

drewbailey5
2019-05-02 17:10
has joined #general

drewbailey5
2019-05-02 17:32
cross posting from #pact-go, Hello! has anyone ever worked with building query params to allow for the rails flavor of arrays in params? `names[]=ENV1&names[]=ENV2`

audun.halland
2019-05-02 18:32
I?ve used it with the client, and I?m able to create contracts with it. Requires no plugin.

audun.halland
2019-05-02 18:36
Although I had to turn off typenames from the query in order to make it work the way I wanted to

matt.fellows
2019-05-03 01:33
:slightly_smiling_face:

detert
2019-05-03 13:13
has joined #general

felipe.faust
2019-05-03 14:43
has joined #general

zach.the.hammer
2019-05-05 01:28
Congrats to @bethskurrie, @matt.fellows and the rest on the pactflow launch! I havent posted here in a while but have been seeing all the pactflow tweets- seems awesome

jonathanparkeremail
2019-05-05 03:39
has joined #general

simon.nizov
2019-05-05 08:53
Do you mean registering an interaction that has these types of query params?

matt.fellows
2019-05-05 10:35
Much thanks @zach.the.hammer - as you?ll have noted, we haven?t announced here properly yet, but it?s coming :slightly_smiling_face:. Appreciate this though!!

zach.the.hammer
2019-05-05 14:29
Ahhh ok. I just have been seeing the tweets

zach.the.hammer
2019-05-05 14:29
Hope i didnt jump the gun

matt.fellows
2019-05-05 20:55
Not at all. I think publicly tweeting about something probably counts for an announcement of sorts :grinning:

s1apped
2019-05-06 07:19
@bethskurrie I run pact broker in debug mode and did some more troubleshooting. I wonder if you can could take a look what I found and if it's not a problem point me to right direction since the log message doesn't make much sense to me unless I'm missing something..

bethskurrie
2019-05-06 07:19
Hi Matthew. I had a quick look at your logs the other day, but haven't had a chance to debug the code.

bethskurrie
2019-05-06 07:20
It does seem like it's doing something unexpected.

s1apped
2019-05-06 07:25
Hi. thanks :slightly_smiling_face: let me know if I could be of any help

simon.nizov
2019-05-06 12:10
Quoting from https://medium.com/@dius_au/closing-the-loop-with-pact-verifications-a7d590ab2f5c > The Pact Broker is smart enough to work out whether the pact content has changed or not, so if a pact is published with the same content as a previous one, it will inherit the same verification results???we call this being ?pre-verified? For some reason my verification results aren?t inherited from previous builds like described. They don?t automatically appear in the matrix on lines of new-but-unchanged pact versions, resulting in ?holes? in the matrix on the provider side. The results appear only after I?ve manually triggered the provider build. I don?t have the webhook enabled yet, is that the issue?

matt.fellows
2019-05-06 12:30
It shouldn?t do. If the contract itself hasn?t changed and has previously been verified, then new consumer versions should also be safe.

matt.fellows
2019-05-06 12:31
There was a thread in pact broker about this issue recently that might be worth having a look at, where @s1apped was running into issues. Might be worth getting across just in case


matt.fellows
2019-05-06 12:58
That?s the issue that was a result, but a lot of conetxt was in the convo

294simon
2019-05-06 13:20
has joined #general

simon.nizov
2019-05-06 13:25
Followed Beth?s suggestion to check `diff-previous-distinct` - didn?t even know this exists. Turns out my consumer?s test suite includes a couple of dynamically generated ID?s in one of the pact interactions, hence the ?change? in the pact. Thanks! :smile:

simon.nizov
2019-05-06 13:25
This is a nice ?gotcha? I think. Is it documented anywhere?

matt.fellows
2019-05-06 13:27
awesome to hear you got to the bottom

matt.fellows
2019-05-06 13:27
Umm, it probably is, but if you didn?t find itt readily I?m sure others wouldn?t have either

christopher.f.almanza
2019-05-06 20:08
has joined #general

christopher.f.almanza
2019-05-06 20:10
Hey guys

christopher.f.almanza
2019-05-06 20:13
Is there any documentation or threads about polymorphic endpoints?

christopher.f.almanza
2019-05-06 20:14
Maybe that's not the correct words. I suppose an example would be better: a `GET /favorites` where you have 2 or 3 different entities that you can favorite


matt.fellows
2019-05-06 21:14
Responded just now. TL;DR - provider states

christopher.f.almanza
2019-05-06 21:15
@matt.fellows Hmm, maybe the example I gave was a bit misleading.

christopher.f.almanza
2019-05-06 21:16
What I meant to say was that both Books and Movies have completely different JSON properties

christopher.f.almanza
2019-05-06 21:16
Would provider states still be the solution? I can think of making provider states like: - `when it returns books` - `when it returns movies`

christopher.f.almanza
2019-05-06 21:17
But can I really trust that when it returns both books and movies, the schema will still be good...

christopher.f.almanza
2019-05-06 21:17
Not sure what to do here

matt.fellows
2019-05-06 21:19
sorry yes, I?ve updated the SO to reflect that

matt.fellows
2019-05-06 21:19
And yes, I believe they would

christopher.f.almanza
2019-05-06 21:20
thank you!

matt.fellows
2019-05-06 21:20
Another alternative (which is possibly more brittle) is that you expect the specific payload response which has one of every example

matt.fellows
2019-05-06 21:21
it means you can?t use a top-level matcher to say _all_ of the objects look like _this_, but instead the response needs to be more exacting. This means you can be sure your code can handle both simultaneously

christopher.f.almanza
2019-05-06 21:21
kind of harcoding the exact response instead of `somethingLike()` ?

matt.fellows
2019-05-06 21:21
exactly

christopher.f.almanza
2019-05-06 21:21
That also makes sense

christopher.f.almanza
2019-05-06 21:21
I'll go for the first approach since it's easier to explain to teammates

matt.fellows
2019-05-06 21:21
you can still use the like matchers at the field level, but in your case you?d need exactly 2 objects in the favourites array (assuming only two types)

matt.fellows
2019-05-06 21:21
i think so

vipin.gaba
2019-05-07 05:25
has joined #general

rune
2019-05-07 07:29
has joined #general

stephane.colson
2019-05-07 09:14
has joined #general

kevin.meiresonne
2019-05-07 12:20
Hi all, Recently I got the following request: "Given we have a UI (Consumer) and an API (Provider), which are deployed/released independently. A new feature in the Consumer requires calling a new endpoint on the API. However, because the release schedules of the Consumer and Provider are vastly different, they want to release the Consumer before the Provider. The Consumer would then check at runtime if its Provider already exposes the new endpoint. Once it does, it would expose the new feature, if not, it would hide it." Although I kind of understand this request, I don't see how we could fit this into the Pact "workflow", that would disallow shipping the Consumer since its contract with the Provider would not be fulfilled (because Provider changes would be released later). Did someone ever come across a similar request?

detert
2019-05-07 12:55
Hi all, what is the best practice to transfer pact files from my `https://github.com/pact-foundation/pact-mock_service` to `https://github.com/pact-foundation/pact_broker`? What I understand that `POST /pact` writes the pact file somewhere in the mock service, but what is the best way to publish that file to the broker?

simon.nizov
2019-05-07 12:56
What language are you using?

detert
2019-05-07 12:57
php currently

detert
2019-05-07 12:57
But a general example with curl or something will help as well

simon.nizov
2019-05-07 12:59
Generally speaking, after running your consumer test suite, a pact json file should be created. You can then use: https://github.com/pact-foundation/pact_broker-client ?to publish that pact file to the broker

simon.nizov
2019-05-07 13:00
In some implementations there are other ways of publishing the pact, not sure about PHP

detert
2019-05-07 13:01
What I do not understand at this point: I run the consumer test with the pact-mock-service. I think that the mock-service should provide the pact file which I have to transfer to the pact broker. Is that correct?

nick.karamaniolas
2019-05-07 13:05
has joined #general

qatrera
2019-05-07 13:08
If the tests run successfully the pact file would be autogenerated locally (I am assuming there is a configuration in the PHP Pact version to set the local path to store the files). After that, you have to share this file with the Pact Broker. I'm not sure about the Pact tooling in PHP but I guess that a `scp` to your Pact Broker server should work

detert
2019-05-07 13:22
Well, I understand the idea. However I have no idea how to retrieve the pact file. The only way I found so far is POST /pact to the pact-mock-service, but that writes the pact file on disk. That does not sound very promising, as I have to grep that file from disk and send it to the pact-broker. Maybe I do miss something important here.

simon.nizov
2019-05-07 13:25
You are going to need to get it from the disk anyway, as part of your CI process.

simon.nizov
2019-05-07 13:25
Regarding the PHP side, you should ask in #pact-php

detert
2019-05-07 13:26
Alright. I hoped that there is a way to fetch the pact file via GET request

detert
2019-05-07 13:26
Thank you very much for your help. Both of you

matt.fellows
2019-05-07 13:40
The pact broker is completely API driven, so you can definitely use curl etc to fetch it



matt.fellows
2019-05-07 13:42
Basically there are a tonne of options and it's fairly trivial work

matt.fellows
2019-05-07 13:44
Hmm will have to think about this. A bit like a feature toggle

detert
2019-05-07 13:45
Well I struggle with the mock service. I am not able to retrieve the pact file nor find it in the docker container

detert
2019-05-07 13:46
the pact-broker is the next step I think

matt.fellows
2019-05-07 13:48
Why are you dealing with the mock service directly? Doesn't php provide an interface over it? It should basically be hidden to you

detert
2019-05-07 13:50
The documentation states "This library contains a wrapper for the Ruby Standalone Mock Service.", that is "https://github.com/pact-foundation/pact-mock_service" and so I started the available docker container "https://github.com/pact-foundation/pact-mock-service-docker". I guess that is as told

matt.fellows
2019-05-07 13:54
Where in the php docs does it say you need to install the mock service yourself? And if so, you shouldn't have to interact with it directly

matt.fellows
2019-05-07 13:55
It is the wrapper for it, that's the whole point! :laughing:

detert
2019-05-07 13:58
Well that might be the mistake. In that case, I do not really understand the section "Start and Stop the Mock Server"

detert
2019-05-07 13:59
But as you write this, maybe I just have to try `$server = new MockServer($config);` and ` $server->start();`

detert
2019-05-07 14:36
Alright that works well. Thank you :slightly_smiling_face:

kevin.meiresonne
2019-05-07 14:48
Yeah, it is pretty much

bheemreddy181
2019-05-07 16:20
Team , Here is the use case - if my consumer is consuming a field as Int and the provider now wants to do the change the UUID type - So can some one help me with the workflow using pact like who should go first ?

detert
2019-05-07 16:38
As far as I understood the documentation: Should the consumer care about the id format at all?

bheemreddy181
2019-05-07 18:16
they should in this particular case

bheemreddy181
2019-05-07 18:20
Given if the consumer is assuming that it is always Integer but provider wants it to change the same to UUID

matt.fellows
2019-05-07 21:58
I would follow the flexible schema strategy. The provider should first add the new field and deploy it (without removing existing field, it should have a ney key) The consumer should then transition to using the new field The provider can then remove the old

matt.fellows
2019-05-07 21:58
Contracts aside, this is how you do it.

matt.fellows
2019-05-07 21:59
Haha np

matt.fellows
2019-05-07 22:00
It all sounded too hard. Perhaps we need a note in there to say the it manages it for you. Or just remove it altogether as it's implementaion detail

ivan.cherkashnev
2019-05-07 23:07
has joined #general

bheemreddy181
2019-05-08 00:17
doesn't consumer start consuming both types and once provider changes to UUID type then modify tests to accept only UUID type ?

matt.fellows
2019-05-08 00:22
Well, once the provider is in production with the new field, the consumer can safely transition straight to the new field - no need for it to consume both. But there may be important context I?m missing here, and if it makes sense to have both then I don?t see an issue with that

bheemreddy181
2019-05-08 02:43
Naming the field would be pain again here

matt.fellows
2019-05-08 02:48
what do you mean? Because you?d like to use the same field name?

bheemreddy181
2019-05-08 03:04
@bethskurrie your thoughts on this ?

biaofu
2019-05-08 03:26
some thoughts from mine: given provider already has the pact test against the contract between that consumer, usually, this kind of contract testing should always runs on some lower environment. Let?s say, provider has multiple environments, env-dev, env-test, env-contract, env-pre-production, env-production, env-dev for provider development, env-test for provider functional test, env-contract for running pact test, env-pre-production for internal share with other consumers, and lastly, env-production for real production. Then, provider could firstly complete their change and functional test in dev and test env, then, deploy to contract env to run pact test, and obviously, failed, then communicate with consumer team about the new change, the two teams need discuss when their change would be deployed together, this is most important, depends on the teams, neither Pact nor any kinds of testing.

biaofu
2019-05-08 03:29
and in real practice, another better way is that provider could have more envs, which contains two different versions of the provider( Int and UUID), then, it?s more easier for provider and consumers to switch their works independently.

bethskurrie
2019-05-08 06:45
Bheem, it depends if you want to take Matt's recommended approach (which I would also recommend) or whether you want to make a breaking change. I'd recommend changing the id field to "uuid" so that you can have both at the same time. Much easier to handle.

bethskurrie
2019-05-08 06:48
If you really want to change the field, you'll need to deploy to prod a version of the consumer that knows how to handle both the int and the string id.

bethskurrie
2019-05-08 07:10
> What if I generated a schema from Provider side once I create my API and validate my API each time I do a change? If you generate a swagger document, you can verify your pact against it using Atlassian swagger validator tool. You can ask about it in the #swagger-validator channel

detert
2019-05-08 07:25
Well. The statement "This library contains a wrapper for the Ruby Standalone Mock Service." confused me, because I assumed that I need to start that service myself. What is missing is a simple example that creates a pact files and publishes that pact file to the broker, however I found a solution for that for the first trial run

stein
2019-05-08 08:04
At sainsburys we do what Matt suggests. We prefer to evolve the schema by adding new fields against versioning (most of the time) which typically involves multiple deployments - for us it's important to provide a backwards compatibility guarantee to consumers - you don't want to be synchronising releases across consumer/provider. It gets a bit trickier when you have mobile app consumers - users might have old versions of the app and you'd need to force upgrade to roll out the old field. We have duplicate fields running in prod and we are fine with that. It just takes some diligence to keep on top of it.

biaofu
2019-05-08 08:20
yes, that?s a good approach

cmcgowan-smyth
2019-05-08 09:07
has joined #general

braddle
2019-05-08 10:08
has joined #general

bheemreddy181
2019-05-08 13:51
Yes @matt.fellows Same field name , sorry i missed your message

noel.yap_slack.pact.i
2019-05-08 16:41
has joined #general

matt.fellows
2019-05-08 22:14
I would recommend against the re-using field approach because of the need to couple deploys between systems that use it. The evolutionary approach is the generally accepted way to do this sort of change. In my experience, changing a field name / definition is rarely an urgent thing that needs to be rushed

james.prescott
2019-05-09 09:09
has joined #general

james.hattersley-dyke
2019-05-09 11:11
has joined #general

mindy.or
2019-05-09 16:44
has joined #general

anton.taranovskyi
2019-05-10 08:15
has joined #general

james.hattersley-dyke
2019-05-10 11:10
Not sure if this has been asked before if someone could point me in the right direction of an answer. Is it possible to do partial response matching in the `willRespondWith: { field1, field3} `. The api actually returns 3 fields, but I'm only interested in 1 and 3... I've had my provider pacts fail because of this... is this possible or do I have to specify the whole response but using `like(...)` for the fields I'm not interested in?

matt.fellows
2019-05-10 11:39
yes it?s been asked and yes you can definitely do that

matt.fellows
2019-05-10 11:39
in fact, that is the _right_ way of writing Pact tests. You should only test and specify the fields you actually use - not all of the possible fields of the Provider


james.hattersley-dyke
2019-05-10 11:44
cool, what's does this have a name? I've read all the docs on flexible matching etc?

james.hattersley-dyke
2019-05-10 11:44
are there any repos with examples of it?

matt.fellows
2019-05-10 11:46
ummm, I?m not sure. You just specify the subset of fields you need in the consumer tests and on the provider side, if there are more fields they are simply ignored

matt.fellows
2019-05-10 11:46
You could fairly easily modify any of the pact js examples to return more fields and they should continue to pass

james.hattersley-dyke
2019-05-10 11:47
ah right, I'll take another look then, I was pretty sure the provider tests failed because it returned more then the consumer was asking for...

matt.fellows
2019-05-10 11:48
if it did, there is either a serious bug in Pact or something else misconfigured

james.carman
2019-05-10 11:48
Maybe it?s a different failure

matt.fellows
2019-05-10 11:49
If you have the pact-js repo about, just add some more fieldss to https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/data/animalData.json and run the tests

james.hattersley-dyke
2019-05-10 11:49
i'll have another look - most likely I'm doing something wrong

james.carman
2019-05-10 11:49
Be sure you?re asserting types , not values

matt.fellows
2019-05-10 11:49
:point_up:

james.hattersley-dyke
2019-05-10 11:49
yeah I will, cheers chaps

james.hattersley-dyke
2019-05-10 11:49
I've only been playing with Pact a week so likely user error :slightly_smiling_face:

james.carman
2019-05-10 11:49
The values provided are for the mocks

james.carman
2019-05-10 11:50
That was confusing to me at first

matt.fellows
2019-05-10 11:52
?user error? is usually ?poor docs? - so now is the time to articulate all of the things we didn?t make clear before it becomes ?normal?

matt.fellows
2019-05-10 11:52
thanks for sharing / asking, many will just move on - this is good feedback

james.hattersley-dyke
2019-05-10 11:53
cool, ok - i'll take another look at my tests and see if I'm doing something wrong

james.hattersley-dyke
2019-05-10 11:53
I'm using a nodeJS consumer calling a Spring Boot provider..

erkan.deveci
2019-05-10 20:43
has joined #general

brwhaley
2019-05-11 01:25
has joined #general

elvis.uagbor
2019-05-11 23:02
has joined #general

s1apped
2019-05-13 07:02
Hi @bethskurrie did you have time to look into this issue?:)

amaano.dev
2019-05-13 09:14
has joined #general

mark.smith
2019-05-13 13:07
has joined #general

phall
2019-05-13 17:19
has joined #general

scott.riley111
2019-05-13 17:33
has joined #general

kristofer.landgren
2019-05-14 07:39
has joined #general

asite-rshah
2019-05-14 09:45
if pact provider side build is failure then how to push latest pact file to pact brocker ?

oswald.quek
2019-05-14 09:48
hello. for our consumer builds I've upgraded the `pact-jvm-consumer-junit_2.12` library to version 3.6.7. This seems to have the effect of not publishing "null" values. for example, we have a pact at https://github.com/alphagov/pay-publicapi/blob/master/src/test/resources/pacts/publicapi-connector-get-payment-with-gateway-transaction-id.json#L63-L64 but what actually now gets published is ```"settlement_summary": {}``` This is :ok_hand: except that the provider tests now fail because our provider endpoint actually returns ``` "settlement_summary": { "capture_submit_time": null, "captured_date": null }``` so the matching fails. however they're actually equivalent. is there a way to relax this matching? from https://docs.pact.io/getting_started/matching/gotchas, it seems the behaviour now doesn't follow Postel's Law: ```Be liberal in what you accept - when verifying a pact in the provider project, the response body and headers may contain fields that were not defined in the expectations, on the assumption that any extra field will be ignored by your consumer. This allows a provider to evolve without breaking existing consumers.```

oswald.quek
2019-05-14 09:54
I suppose I could always fix my provider to never include null values

oswald.quek
2019-05-14 09:56
actually that's what I'll do. no response required!

matt.fellows
2019-05-14 10:11
I'm confused, the pact file should he pushed after a consumer build, not a providers

matt.fellows
2019-05-14 10:12
Can you pls elaborate?

bethskurrie
2019-05-14 10:13
@oswald.quek that change in behaviour sounds like a bug. Can you raise it please?


bethskurrie
2019-05-14 10:41
Thanks.

rafael.anachoreta
2019-05-14 13:44
Hey! I?m interested in opening a new feature request, but I?m not entirely sure how to proceed. This is something that I can see being added to potentially every pact implementation, so I?m not sure where to open an issue for it. Details can be found on this thread: https://pact-foundation.slack.com/archives/C9VBGLUM9/p1549448375093500?thread_ts=1549377207.091900&cid=C9VBGLUM9 Can anyone point me on the right direction? Thanks! :slightly_smiling_face:

christophe.leray
2019-05-14 15:42
has joined #general

blyman
2019-05-14 18:52
has joined #general

tyoder
2019-05-14 19:00
has joined #general

konrad.winkler
2019-05-14 19:16
has joined #general

eran.bergman
2019-05-14 22:05
has joined #general

jhoag
2019-05-14 22:52
has joined #general

bheemreddy181
2019-05-15 03:19
Does Publish_Verification_results when contract is verified should happen only when the verification is triggered from Consumer end - because we run the verification against master of provider ? @matt.fellows

matt.fellows
2019-05-15 03:47
No, verification results are published only on the provider side when the provider tests are run, only when the pacts are fetched from the broker and only when the relevant flag is set to do so

matt.fellows
2019-05-15 03:47
can you elaborate?

bheemreddy181
2019-05-15 03:49
If the pact is verified from the provider PR this will result in ambiguity I feel because the Provider PR will verify the results and the consumer when says can I deploy he will get a true but provider didn?t merge the PR yet

bheemreddy181
2019-05-15 03:54
@matt.fellows ^

matt.fellows
2019-05-15 04:00
Well, that?s where tags come in Bheem

matt.fellows
2019-05-15 04:01
You should set it up so that features aren?t tagged ?master? (or whatever tagging scheme you go with). When you release, you query can I deploy using tags, rather than latest (which could be any branch/feature)


bheemreddy181
2019-05-15 04:02
Page is broken

matt.fellows
2019-05-15 04:03
Ah no, my stupid keyboard (repeats)


the.trav
2019-05-15 04:58
has joined #general

the.trav
2019-05-15 05:00
@matthew.balvanz and Co, thanks for pact-python. I just got it going in less than 10 minutes. It's super fast and I didn't have to change my test framework :thumbsup:

matt.fellows
2019-05-15 05:04
Thanks for the feedback @the.trav!

davidmolinero.com
2019-05-15 08:06
has joined #general

davidmolinero.com
2019-05-15 09:07
Hello, in which languages is V3 PACT specification for async messaging working fully E2E?

bethskurrie
2019-05-15 09:07
js

bethskurrie
2019-05-15 09:07
jvm

bethskurrie
2019-05-15 09:08
ruby consumer

bethskurrie
2019-05-15 09:08
I think that's all

davidmolinero.com
2019-05-15 09:08
even the bit of publishing the verification results back to the broker in js & jvm?

davidmolinero.com
2019-05-15 09:11
I've tried without too much success in ruby using this library https://github.com/reevoo/pact-messages/ but it is using V2 under the covers and I am struggling to get the verifications results published to the covers

bethskurrie
2019-05-15 09:11
it's not the same one

bethskurrie
2019-05-15 09:11
not an official version.

davidmolinero.com
2019-05-15 09:12
yes I know, I became aware of it after doing a spike

bethskurrie
2019-05-15 09:12
in js the verification publishing is the same codepath as the http verificaiton publishing.

bethskurrie
2019-05-15 09:12
so yes, it should work.

bethskurrie
2019-05-15 09:12
@matt.fellows?

davidmolinero.com
2019-05-15 09:13
I also took at the code for the js implementation and I saw some references to directories for fetching the json contracts so I am not sure if it will work with the broker

bethskurrie
2019-05-15 09:13
What languages do you want? The ruby one is actually implemented end to end, however, there isn't a DSL to expose it verification step because nobody uses Ruby anymore

davidmolinero.com
2019-05-15 09:14
we would like to use it with python & ruby at the moment (I know in python it is not supported)

bethskurrie
2019-05-15 09:14
JS message pact definitely works with the broker.

matt.fellows
2019-05-15 09:15
Yep. Pact JS and Pact Go definitely implement the messaging interface. I believe Pact PHP does also

matt.fellows
2019-05-15 09:15
Verifications should work consistently across HTTP or messaging

jon.pascoe
2019-05-15 09:15
I disagree that ?nobody uses ruby anymore? :stuck_out_tongue:

davidmolinero.com
2019-05-15 09:15
most likely we will workaround it using HTTP under the covers for the time being...

davidmolinero.com
2019-05-15 09:16
I'll take a look T the JS implementation then

davidmolinero.com
2019-05-15 09:16
thank you

bethskurrie
2019-05-15 09:16
I use Ruby! But I am assured by all around me that it is effectively COBOL.

davidmolinero.com
2019-05-15 09:17
most of ruby folks are moving to elixir nowadays :slightly_smiling_face:

bethskurrie
2019-05-15 09:18
I have heard that.

heymega
2019-05-15 09:19
I'm just looking at PactFlow and I'm a little confused Is PactFlow just a managed broker? If so, how does it differ from the existing broker we've come to know and love?

matt.fellows
2019-05-15 09:19
Hey @heymega, let?s chat over in #pact-broker if that?s OK?

jon.pascoe
2019-05-15 09:20
Stay strong @bethskurrie - Ruby FTW

heymega
2019-05-15 09:20
Sure!

bethskurrie
2019-05-15 09:20
Well, the broker is written in ruby, and that's not going anywhere.

james.hattersley-dyke
2019-05-15 12:45
if a provider has multiple consumers (I've not got this far yet) but does running `can-i-deploy --pacticipant my-provider` verify all the pacts with all consumers?

matt.fellows
2019-05-15 13:00
by default it will, yes

james.hattersley-dyke
2019-05-15 13:04
brilliant, I've only got 1 consumer and 1 provider right now so wasn't sure.

james.hattersley-dyke
2019-05-15 13:07
What happens then, when the provider team think 'oh these fields might be useful let's add them..' and release a new version of their API with no one consuming it? I'm assuming this _shouldn't_ happen given we're supposed to be following Consumer driven design?

bart.schotten
2019-05-15 13:09
Adding fields should always be allowed

james.carman
2019-05-15 13:10
Yep, new stuff should not impact your existing consumer pacts.

james.carman
2019-05-15 13:11
That?s why it?s very important not to do ?schema? type tests in your consumers and only focus on exactly what you need or care about

james.carman
2019-05-15 13:11
No ?this and only this? type tests.

james.hattersley-dyke
2019-05-15 13:11
right, cool. I'm preparing a demo from a spike I've worked on so swotting up on likely questions...

james.carman
2019-05-15 13:12
I gave a talk a while back and did the same thing. These folks were super helpful!

james.hattersley-dyke
2019-05-15 13:13
would you mind looking over my slides when I'm done - Make sure I'm talking sense?

james.carman
2019-05-15 13:14
Sure. I?m giving a talk at our company today (not on pact in particular), so I?m busy this morning, but I?d be glad to give you a second pair of eyes. Fair warning, I would not consider myself an ?expert? by any means (there are far smarter folks here than me). :slightly_smiling_face:

james.hattersley-dyke
2019-05-15 13:14
so, the api team add a load of new fields to a particular response but no-one is using them, providers build don't generate new contracts, right? It's just a new version of the API and no changes to contracts?

james.carman
2019-05-15 13:14
Providers don?t generate new ?pacts?, is what you mean?

james.hattersley-dyke
2019-05-15 13:15
yeah exactly that

james.carman
2019-05-15 13:15
Providers don?t generate pacts

james.carman
2019-05-15 13:15
Only consumers

james.hattersley-dyke
2019-05-15 13:15
yeah - thought so

james.carman
2019-05-15 13:15
Providers *verify* the pacts generated by the consumers

james.hattersley-dyke
2019-05-15 13:15
yep

james.carman
2019-05-15 13:15
hence the ?consumer-driven? part of it.

james.carman
2019-05-15 13:15
It?s a bit of a mind shift (it was for me)

james.hattersley-dyke
2019-05-15 13:15
there's a lot of moving parts and the docs are great, but yeah... mind shift like you say

james.carman
2019-05-15 13:16
I believe Spring Cloud Contract does take the opposite approach, IIRC

james.carman
2019-05-15 13:16
The provider publishes its contract and consumers test against it.

james.hattersley-dyke
2019-05-15 13:16
what blockers did you guys find to getting this part of the dev process?

james.hattersley-dyke
2019-05-15 13:16
ahh was maybe gonna look at Spring Contracts

james.carman
2019-05-15 13:17
The big roadblock for us was hosting the thing. We aren?t a ruby shop and our ops folks weren?t jazzed about hosting it. Luckily, the fine folks here do have a hosted offering! Problem solved. We?re happily pact brokering now.

james.carman
2019-05-15 13:17
this is not a paid endorsement

james.carman
2019-05-15 13:17
:slightly_smiling_face:

james.carman
2019-05-15 13:17
Just a happy customer

james.hattersley-dyke
2019-05-15 13:17
haha

james.hattersley-dyke
2019-05-15 13:18
I imagine we'll end up going down the broker container route

james.hattersley-dyke
2019-05-15 13:18
although I'll totally push for hosted

james.hattersley-dyke
2019-05-15 13:18
it's so much easier

bethskurrie
2019-05-15 23:48
I do recommend the hosted version (as I'm part of the team that runs it!) but there is a docker container for the OSS version, so you don't need to know Ruby.

james.carman
2019-05-16 00:24
I don?t think it was about knowing it per se, but caring and feeding for a ruby app isn?t something our folks do.

james.carman
2019-05-16 00:27
Our engineers have taken a liking to running the broker on their machines. I find it unnecessary, but they find it comforting I suppose

james.carman
2019-05-16 00:28
Whatever floats their boat

bethskurrie
2019-05-16 00:28
Really? Tell me how that works.

james.carman
2019-05-16 00:28
They just run it so they can see their stuff publish I guess

james.carman
2019-05-16 00:29
:man-shrugging:

bethskurrie
2019-05-16 00:29
I'm confused! But hey, whatever works for them.

james.carman
2019-05-16 00:29
This particular group is writing the consumer and the provider, so I guess they wanted to be able to verify

bethskurrie
2019-05-16 00:29
Oh, I just use the local files when I'm doing that.

bethskurrie
2019-05-16 00:29
No broker required.

bethskurrie
2019-05-16 00:30
But I guess it saves having a completely different task. Can just make the broker location configurable.

james.carman
2019-05-16 00:30
I?m going to create a maven profile that sets up properties for local brokers

james.carman
2019-05-16 00:31
It might be nice for us to share our configuration, in case it helps other people

bethskurrie
2019-05-16 00:31
Surw

bethskurrie
2019-05-16 00:31
Sure, even

james.carman
2019-05-16 00:32
It took me a while to get all the ducks in a row

luchillo17
2019-05-16 01:34
Hey little question, when using create react app, i was looking to the docs and i see they separate the tests for Pact from regular ones, why's that?

tjones
2019-05-16 01:34
Which docs is this?

matt.fellows
2019-05-16 03:42
I have been thinking about the concept of ?sandboxes? (or something similar) for a little bit. Probably not an easy thing to do. Often times people want to test out webhooks, tagging approaches etc. and not impact the main broker. I wonder if what you?re describing above also feeds into this sort of thinking?

matt.fellows
2019-05-16 03:43
i.e. each team member could create a sandbox to muck around in, and potentially even have scoped to their user (or a group of users)

luchillo17
2019-05-16 03:43
Here: https://docs.pact.io/implementation_guides/javascript Specifically the pactTest script which uses a custom regex for the match of test files: ``` { scripts: { ... "pactTest": "export NODE_ENV=pactTest && jest --testRegex \"/*(.test.pact.js)\" --runInBand --setupFiles ./pactSetup.js --setupTestFrameworkScriptFile ./pactTestWrapper.js" } } ```

matt.fellows
2019-05-16 03:53
It?s completely up to you as to where/how you structure your tests. I tend to separate my unit tests from my contract tests from my perf ? etc.

matt.fellows
2019-05-16 03:53
I can?t recall why these were setup that way (I believe this came in via a PR so possibly residue from a project where it came from)

matt.fellows
2019-05-16 03:53
I wouldn?t read into it too much!

david.darrell
2019-05-16 06:04
has joined #general

david.darrell
2019-05-16 06:25
@christophe.leray hi Chris - thanks for invite

vk.regs
2019-05-16 10:44
I am trying to stub some api using pact stub (I use pact file from pact broker by URL). By pact stub cannot match my api URL with stub. Could somebody help.

vk.regs
2019-05-16 10:45
*Error from Pact stub*: 10:39:01 [INFO] comparing to expected Request ( method: GET, path: /api/user/tracking, query: None, headers: Some({"Accept": "text/plain"}), body: Missing ) 10:39:01 [DEBUG] pact_matching: body: '' 10:39:01 [DEBUG] pact_matching: matching_rules: MatchingRules { rules: {"path": Category { name: "path", rules: {"": RuleList { rules: [Regex("(?i)(\\/api\\/user\\/tracking)")], rule_logic: And }} }} } 10:39:01 [DEBUG] pact_matching: generators: Generators { categories: {} } 10:39:01 [DEBUG] pact_matching::matchers: String -> String: comparing '/api/user/tracking' to '/api/user/tracking' using Regex("(?i)(\\/api\\/user\\/tracking)") 10:39:01 [DEBUG] pact_matching: expected content type = 'text/plain', actual content type = 'text/plain' 10:39:01 [DEBUG] pact_matching: --> Mismatches: [PathMismatch { expected: "/api/user/tracking", actual: "/api/user/tracking", mismatch: "\'(?i)(\\/api\\/user\\/tracking)\' is not a valid regular expression - regex parse error:\n (?i)(\\/api\\/user\\/tracking)\n ^^\nerror: unrecognized escape sequence" }] 10:39:01 [WARN] No matching request found, sending 404 Not Found 10:39:01 [INFO] <=== Sending Response ( status: 404, headers: None, body: Missing ) 10:39:01 [DEBUG] pact_stub_server::pact_support: body: '' 10:39:01 [DEBUG] pact_stub_server::pact_support: matching_rules: MatchingRules { rules: {} } 10:39:01 [DEBUG] pact_stub_server::pact_support: generators: Generators { categories: {} } 10:39:01 [DEBUG] hyper::proto::h1::io: flushed 114 bytes 10:39:01 [DEBUG] tokio_reactor: dropping I/O source: 1 *Pact file from pact Broker*: { "consumer": { "name": "SearchHistory" }, "provider": { "name": "Settings" }, "interactions": [{ "description": "Get Tracking Status", "request": { "method": "get", "path": "/api/user/tracking", "headers": { "Accept": "text/plain" }, "matchingRules": { "$.path": { "match": "regex", "regex": "(?i)(\\/api\\/user\\/tracking)" } } }, "response": { "status": 200, "headers": { "Content-Type": "text/plain; charset=utf-8" }, "body": "true", "matchingRules": { "$.body": { "match": "regex", "regex": "(?i)(true)" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }

matt.fellows
2019-05-16 11:01
the error appears to be in those logs

shalygai.a
2019-05-16 11:46
has joined #general

vk.regs
2019-05-16 13:06
As I understand Pact stab cannot parse regex from pact file. Is issue of regexp or pact stab?

matt.fellows
2019-05-16 13:14
What have you tested to see which of those answers is most likely? Looks like maybe the regex is wrong but perhaps it's valid for the code that generated it. What's the consumer language that generated it?

vk.regs
2019-05-16 13:17
C# .net

vk.regs
2019-05-16 13:18
[Fact] public async Task SearchHistoryAndSettingsController_TrackingStatus_ReturnedTrue() { const string path = "/api/user/tracking"; _mockProviderService.UponReceiving("Get Tracking Status") .With(new ProviderServiceRequest { Method = HttpVerb.Get, Path = Match.Regex(path, $"(?i)({path})"), Headers = new Dictionary<string, object> { { "Accept", "text/plain" } }, }) .WillRespondWith(new ProviderServiceResponse { Status = StatusCodes.Status200OK, Headers = new Dictionary<string, object> { { "Content-Type", "text/plain; charset=utf-8" } }, Body = Match.Regex("true", "(?i)(true)") }); var request = new AccessHistoryItemRequest() { Unique = "testUnique" }; await _settingsHelper.AccessHistoryRepository.AddAccessHistory(request).ConfigureAwait(false); } }

vk.regs
2019-05-16 13:18
looks like issue with double \

vk.regs
2019-05-16 13:18
"regex": "(?i)(\\/api\\/user\\/tracking)"

matt.fellows
2019-05-16 13:19
Yeah

matt.fellows
2019-05-16 13:20
Also why bother with that path matcher at all? Is the path dynamic?

vk.regs
2019-05-16 15:20
with need to match path and ignore case

koji
2019-05-16 15:52
has joined #general

edwin.tye
2019-05-16 21:21
has joined #general

mickehl
2019-05-17 08:39
has joined #general

matt.fellows
2019-05-17 09:07
why is your client code sending messages to paths with different cases? This seems unusuall

matt.fellows
2019-05-17 09:08
As in, why do you need a regex at all - does the path the client send ever actually change?

vk.regs
2019-05-17 13:12
This is requirement from dev that we should ignore case because sometimes dev change case for api and test became failed, may be it is not good. Also in some cases we use regex for example for body matching (it will be the same error) - it is usual case.

christopher.f.almanza
2019-05-17 14:04
Are query params mandatory on Pact?

christopher.f.almanza
2019-05-17 14:05
I mean, in order for my endpoint to receive optional query params, do I need to make 2 provider states?

james.hattersley-dyke
2019-05-17 14:46
does the API do different things in response to these params?

christopher.f.almanza
2019-05-17 15:21
functionally speaking, yes. it will sort or limit the results (pagination)

christopher.f.almanza
2019-05-17 15:21
but from the contract perspective, it shouldn't

christopher.f.almanza
2019-05-17 15:21
the json response structure is the same

christopher.f.almanza
2019-05-17 15:21
I'm asking causse the docs doesn't explicitly mentions whether query params can be optional

christopher.f.almanza
2019-05-17 15:22
it just explain why response json props can't (which makes sense)

mboudreau
2019-05-17 23:43
They can be 2 different interactions, one without and one with, to test both scenarios

matt.fellows
2019-05-18 03:05
The general rule we follow here is postel?s law - be conservative in what you send and liberal and what you receive.

matt.fellows
2019-05-18 03:07
In the case of query strings, I can?t recall the specific rule, but if you specify query strings in the actual request, but don?t specify them in the Pact test setup, when the verification happens later on they won?t be sent through. I?m not 100% sure if this will cause a failure in the consumer test though, because you are actually providing more detail than you?ve expected.

matt.fellows
2019-05-18 03:07
But as Michel mentions, you might need to tests. If all of your requests always contain a query string, then you won?t need to test without it

przemek.sech
2019-05-20 00:10
has joined #general

monch1962
2019-05-20 04:05
has joined #general

gordon.barrs
2019-05-20 08:53
has joined #general

vk.regs
2019-05-20 10:12
Looks like it is pact stub issue. Is it possible to fix it?

matt.fellows
2019-05-20 10:36
Just raise an issue on the GitHub repo and somebody will take a look

christopher.f.almanza
2019-05-20 17:46
I can assume a conclusion can be to have a request with the query params, and one without the query params


mboudreau
2019-05-20 23:28
yep, then you test both interactions to make sure they work and are valid :slightly_smiling_face:

sankalan13
2019-05-21 05:16
has joined #general

jinal
2019-05-21 05:33
has joined #general

vadimk0133
2019-05-21 10:21
has joined #general

dimapasko
2019-05-21 14:55
has joined #general

anabalfun
2019-05-22 09:12
has joined #general

martynnevers
2019-05-22 09:34
has joined #general

tylerkron
2019-05-22 18:20
has joined #general

przemek.sech
2019-05-23 06:47
Hi @matt.fellows, This is Przemek from Ansarada. I'm about to purchase a small (5) team plan. Although CC is an acceptable payment method, we (finance) would prefer regular invoicing. Do you provide such a payment method?

matt.fellows
2019-05-23 06:49
Hi @przemek.sech at this stage we can only accept online payments via credit card I?m afraid

matt.fellows
2019-05-23 06:49
We are looking at it down the track - but we don?t have the team to support it just yet

przemek.sech
2019-05-23 06:49
I like `at this stage` :slightly_smiling_face:

przemek.sech
2019-05-23 06:50
When you have such a capability we'd like to change. At this stage CC is ok

matt.fellows
2019-05-23 06:51
no problem, I can?t give you any timelines yet but I can say that we?ve had a few customers ask the same (to be honest, most companies don?t like paying with credit cards as ubiquitous as it is!)

przemek.sech
2019-05-23 06:59
@matt.fellows I need a hand. I cannot create the account as ansarada subdomain is already taken, by our trial

bethskurrie
2019-05-23 07:00
If you sign up with a different domain, I can swap it over for you afterwards.

matt.fellows
2019-05-23 07:02
I?m chatting with him offline Beth, thanks

bethskurrie
2019-05-23 07:03
:+1:

botalov.andrey
2019-05-23 12:08
has joined #general

sebastian.kowalski85
2019-05-23 13:33
has joined #general

miiiiauu
2019-05-24 15:57
has joined #general

florian
2019-05-24 19:47
Hi I am running into problems while trying to build pact-jvm The error message is: No value has been specified for property 'destinationDir'.

florian
2019-05-24 19:47
Sorry here is the full error message:

florian
2019-05-24 19:47
* What went wrong: A problem was found with the configuration of task ':pact-jvm-provider-lein_2.12:compileClojure'. > No value has been specified for property 'destinationDir'.

florian
2019-05-24 19:47
Has anyone faced this before?

uglyog
2019-05-27 03:36
This is an issue after upgrading Gradle. If you try using Gradle 4.10 and JDK 1.8 it will work.

void.alexey
2019-05-27 22:03
has joined #general

wei.feng
2019-05-27 22:43
has joined #general

diandra
2019-05-28 00:15
has joined #general

simone.dicola
2019-05-28 08:32
has joined #general

daniel.tattan.birch
2019-05-28 15:03
has joined #general

pact.io
2019-05-28 16:31
has joined #general


pdunn
2019-05-29 06:15
has joined #general

zaharovrv
2019-05-29 13:16
has joined #general

oswald.quek
2019-05-29 13:40
Hello, are there any jvm examples of asynchronous contract testing (for message queues)?


oswald.quek
2019-05-29 15:51
thanks, will have a look!

ben
2019-05-29 19:04
has joined #general

cocosanti
2019-05-29 21:58
has joined #general

dperez
2019-05-30 01:57
has joined #general

dperez
2019-05-30 04:26
Hi, I'm looking implementations in .Net, so far I found pact-net https://github.com/pact-foundation/pact-net But it looks they are Version 2 compliant, and we are looking to do Contract Test on our messaging infrastructure (Introduced in Version 3) as well our GraphQL endpoints. (All of this in .Net environment) Is somebody dealing with a similar scenario, I will really appreciate any help. I have searched all available source like stackOverFlow tag pact but no luck. Again thanks.

matt.fellows
2019-05-30 04:27
There is a PR on that project to implement message pact. It?s worth jumping on there and seeing how far along it has progressed and how far away it is from mainline

matt.fellows
2019-05-30 04:27
I believe a few people here are using it

matt.fellows
2019-05-30 04:27
jump into #pact-net for more

dperez
2019-05-30 04:27
Thanks a lot @matt.fellows

matt.fellows
2019-05-30 04:27
np

neil
2019-05-30 04:40
@dperez The `message-pact` branch is what you want to look at. You could build a nuget package locally from there and use it if you like.

dperez
2019-05-30 04:41
great help, thanks a lot, will try it

neil
2019-05-30 04:41
The PR is really just a conversation placeholder at the moment.

russell.blandamer
2019-05-30 10:42
has joined #general

pat.vongphrachanh
2019-05-30 13:54
has joined #general

acooper106
2019-05-30 15:56
our pact broker server keeps crashing on its own. Are there any logs that we can check?

laverya
2019-05-30 17:31
has joined #general


bethskurrie
2019-05-30 23:55
There are so many factors when it comes to deploying an application that aren't actually to do with the application itself, that I'm not sure we'll be able to give you any specific advise on what might be the problem.

bethskurrie
2019-05-30 23:58
Pactflow (the hosted Pact Broker) runs in a "highly available architecture", and the fact that it is "highly available" is not much to do with the underlying Ruby application, and mostly to do with the way it is run and deployed (multiple ec2 instances, no downtime deployments, monitoring, auto scaling etc).

bethskurrie
2019-05-31 00:02
What version are you running? There are some versions that have quite intensive data processing before I optimised the "matrix" query. The latest versions do not have this issue.

gopinathlangote11
2019-05-31 08:00
Ok.

matt.fellows
2019-05-31 12:55
@bernardo.guerreiro Thanks for your great post and kind words, these truly mean a lot to us maintainers https://medium.com/dazn-tech/pact-contract-testing-dealing-with-authentication-on-the-provider-51fd46fdaa78 :pray:

matt.fellows
2019-05-31 12:56
And thanks for asking for what you need, without feedback it?s hard to make Pact more awesome!

phall
2019-05-31 13:18
I don?t think :pray: is part of the url :simple_smile:. It?s https://medium.com/dazn-tech/pact-contract-testing-dealing-with-authentication-on-the-provider-51fd46fdaa78, and is a great read. Thanks for sharing!

matt.fellows
2019-05-31 13:23
thx, yes corrected.

matt.fellows
2019-05-31 13:23
my thank you hands ruined it!

acooper106
2019-05-31 13:45
please add Oruganti,Venkata Rao <venkata_oruganti@vanguard.com>; Pickering,Jason <jason_pickering@vanguard.com> to slack channel

acooper106
2019-05-31 13:47
Chigurupati,Vanaja <vanaja_chigurupati@vanguard.com>

acooper106
2019-05-31 13:51
Patel,Rakesh <rakesh_patel@vanguard.com>

yousafn
2019-05-31 14:41
@bernardo.guerreiro great article, thanks for your reply on my issue too, I?ll try out your suggestions. My initial idea to get me over the hump was just overwrite all the headers with the authenticated headers in the request filter as that has access to the body and path.

bernardo.guerreiro
2019-05-31 16:10
No worries Matt! I meant every word, as you guys really are a great community :slightly_smiling_face:

bernardo.guerreiro
2019-05-31 16:59
thanks @yousafn . but the request filter doesn't have access to the states does it? So you wouldn't be able to do for example: if (state === 'authenticated') ADD HEADER; else DO NOTHING.

bernardo.guerreiro
2019-05-31 16:59
meaning you'd only be able to test the happy path, not the 403?

acooper106
2019-05-31 17:03
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-linux]

yousafn
2019-05-31 17:03
I think it does - the req logs are from inside the request filter and the created/creating log comes from inside the state handler. req.path /_pactSetup req.body { consumer: 'consumer-service', state: 'Is authenticated', states: [ 'Is authenticated' ], params: {} } creating AWS signed headers created AWS signed headers req.path /path/that/the/pact/test/is/calling req.body undefined It would be a compromise at being only able to test happy paths. I?m pretty confident that if we don?t send the with headers, the request will fail with a 403. I will try out your blog suggestions when I next get your computer time, as your solution looks much slicker,

yousafn
2019-05-31 17:04
Btw are you at dazn in Leeds?

bernardo.guerreiro
2019-05-31 17:05
oh then if it does, then it's kinda the same. you just defer the state handling to the request filter, in this case haha, and don't send the header when you want a 403

bernardo.guerreiro
2019-05-31 17:05
both would work really !

bernardo.guerreiro
2019-05-31 17:05
nope, I'm in the London branch, although we sync regularly with the other offices. By the way, thanks for all the contributions to the community, you've done some really cool stuff :slightly_smiling_face:

bernardo.guerreiro
2019-05-31 17:06
(join DAZN in Leeds! :P)

yousafn
2019-05-31 17:27
A few of my mates work there, I moved onto a consultancy after Sky and my pals moved over ( rich McIntyre, Costa G and Mo al nuami), I was asked but I wanted to branch out from just testing into a consultancy based role. You never know what the future holds. If you get up to Leeds with work, give me a shout and we can grab a beer!

acooper106
2019-05-31 17:30
docker 2.0.1 or 1.17.2

bernardo.guerreiro
2019-05-31 17:32
Ah yeah! Costa is a blast , we went to a conference in February together :slightly_smiling_face:, and I know Mo too! I know Rich, but haven't really interacted too much with him Sure , sounds good! :slightly_smiling_face:

yousafn
2019-05-31 17:35
Costa is mad Hahahaha, we worked together for about three months before I left Sky. Mo I worked with for about 18 months. Miss them both! I?ll let you know I get on and I?ll be sure to post back my solution

ckaptan
2019-05-31 18:02
has joined #general

acooper106
2019-05-31 18:17
pg 1.1.4

acooper106
2019-05-31 18:18
17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] *************Start Pact Broker Server************* ? 17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] % Total % Received % Xferd Average Speed Time Time Time Current ? 17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] Dload Upload Total Spent Left Speed ? 17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] ? 17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 ? 17:48:48 2019-05-31 13:48:48,059 P4358 [INFO] 100 11 100 11 0 0 1059 0 --:--:-- --:--:-- --:--:-- 1100 ? 17:48:48 2019-05-31 13:48:48,060 P4358 [INFO] /usr/lib64/ruby/gems/2.6.0/gems/sequel-5.20.0/lib/sequel/adapters/postgres.rb:206:in `initialize': PG::ConnectionBad: timeout expired (Sequel::DatabaseConnectionError)

yousafn
2019-06-01 00:56
has anyone had any luck using the `pact-stub-service` which lives with `pact-mock_service`, in getting it to be flexible in matching query parameters? One of my dev?s was attempting this at work and got nowhere, so I started to take a look. I can get `pact-js` to use the matchers properly, but `pact-stub-service` ignores these and leaves me with a rigid mock that will only accept a single query param. I have stuck a full description of my issue here - https://github.com/pact-foundation/pact-mock_service/issues/80#issuecomment-497898603 along with a reproducible example in a repo (see issue comment for link and steps to run)

bethskurrie
2019-06-01 01:07
That shouldn't be the case.

bethskurrie
2019-06-01 01:07
It's the same matching code.

bethskurrie
2019-06-01 01:10
Ah.... yes, I know what you're talking about. It's because the v2 spec doesn't support a query hash in the serialisation.

bethskurrie
2019-06-01 01:10
This has bitten me in a few places.

bethskurrie
2019-06-01 01:10
I'll have a think about what I can do about it.

bethskurrie
2019-06-01 01:11
When v2 was written, the matching info wasn't even included in the pact, because the stub wasn't invented, so we didn't think we'd need it.

yousafn
2019-06-01 01:12
doh :disappointed: our dev did mention about the spec versions. let me try setting the pact version to 3 in the pact provider options and i?ll see what happens. If you can point me in the right direction of the code, I will happily have a stab at a change. No rush on this, the wiremock stuff will get us over the hump for now whilst we have a think

bethskurrie
2019-06-01 01:12
Only the "reified" (concrete) example was stored.

bethskurrie
2019-06-01 01:12
I don't think writing v3 pacts works yet, only reading them. But you can try.

yousafn
2019-06-01 01:17
ahh yeah, just tried it, the only diff in the pact was the version number, ` "version": "3.0.0"` cheers for the answer though, it has saved me chasing my tail! Looking forward to hearing your suggestions and what we can do in the future to support this (if this is indeed a case that pact wants to support)

bethskurrie
2019-06-01 01:17
I want it to work

bethskurrie
2019-06-01 01:18
because using the stub server for larger scale integration tests is one of its purposes

bethskurrie
2019-06-01 01:18
I'll see if I can re-parse the query string back into the hash to apply the matching rules.

yousafn
2019-06-01 01:19
we adore it for that very purpose :heart: Thanks duck, appreciate it. Feel free to leave me some breadcrumbs to work with, and I will have a go (or give it to one of my insanely clever devs and see what he can come up with) as I know you are insanely busy with the pactflow work

bethskurrie
2019-06-01 01:20
we are! I can point you to the code if someone is brave enough to wade in.

yousafn
2019-06-01 01:21
Well I?ve got 3 days off work next week, playing nurse for my wife who is having an op, so I imagine she will be sleeping alot, which means lots of laptop time for me

bethskurrie
2019-06-01 01:21
party time!

bethskurrie
2019-06-01 01:22
I'll put some notes on the issue

yousafn
2019-06-01 01:23
thank you very much mucker, right I should probably hit the sack as it is an ungodly hour here but I will catch up with your notes tomorrow or when you get round to it, again no rush on our side!

matt.fellows
2019-06-01 03:23
thanks for getting involved (and good luck with your wife next week!)

bethskurrie
2019-06-01 03:23
I was wondering how on earth you were chatting to us at this time of your day!

thakkarjinal29
2019-06-01 09:55
has joined #general

thakkarjinal29
2019-06-01 11:27
@bernardo.guerreiro this is indeed a brilliant post, exactly what I was looking for! Only thing is my provider is a django app. I don?t think the `requestFilter` has been implemented in pact-python yet. @matt.fellows is this feature in pipeline for pact-python? Would be so awesome if it is!

matt.fellows
2019-06-01 13:14
I'm not sure if it's in Python yet, but the best way is to get an issue raised on the repo and some votes - community is what drives this stuff

matt.fellows
2019-06-01 13:14
Love that the world is with a small place and little projects like this can bring ppl together!

matt.fellows
2019-06-01 13:15
I'll look into Pact JS to see how we might be able to simplify the workflow

matt.fellows
2019-06-01 13:15
I would still use the state handlers but then setup local state to instruct the request filter how to behave. Otherwise the request filter could get quite large in and if itself

matt.fellows
2019-06-01 13:15
I.e. use them together

yusuke1.sato9.reg
2019-06-03 06:49
has joined #general

sankalan13
2019-06-03 09:20
Hey guys. We have our provider in python django and our consumer in Angular in a separate repo. We are running our provider verifier using the pact ruby standalone. We are having some problem with authentication. Our provider states sets up the user in the backend directly. This can cause 3 cases: 1) We hardcode our passwords and emails and basic auth and use the --custom-headers in provider verifier for each type of tests. (our tests pass but its difficult to scale the hardcoding. This can cause a lot more issues later on) 2) We remove auth altogether and then test the contracts without auth, then test auth separately. (I fairly like this idea, very low effort and easily doable. But it changes the production state of my backend which we should avoid if we can) 3) We write a custom middle ware that generates a random email and password and the related basic auth token and inject the email and password in my provider states setup and the basic auth in my provider verifier. (we need to figure this one out but its interesting and scalable. I think the --custom-middleware flag in pact-ruby standalone would be the place to insert the custom middleware. You have used something as requestFilters to solve this in js. Is there something similar in pact-ruby-standalone? If not, which of the above three would you suggest we use during implementation?

bethskurrie
2019-06-03 09:22
All are perfectly acceptable. I say, which ever one you can all agree on!

bethskurrie
2019-06-03 09:25
The contract testing part is most useful for stuff that is likely to change. The auth is not likely to change, so the benefit of including it is low. And there are generally things you have to test outside a contract anyway, so if you're comfortable in testing that in another place, I don't think it's bad to turn it off for the contract tests

bethskurrie
2019-06-03 09:26
You generally have to modify the provider in some way to do the verifications, like stub a downstream service. The trade-offs are usually worth it.

bethskurrie
2019-06-03 09:29
You could write your own proxy that adds the credentials dynamically by the way. Point the verification at the proxy instead of your real service. Most frameworks have a reverse proxy library that allows you to modify the request on the way through.

bethskurrie
2019-06-03 09:30
Or, your own middleware.

hanumanth.abhilash
2019-06-03 09:54
has joined #general

sankalan13
2019-06-03 10:00
Oh this one is interesting. Will explore this more. Thanks Beth!!

sankalan13
2019-06-03 10:03
Haha thanks Beth, I can see your suggestions have a pattern, the one you like came first. I'm also inclined towards switching off the auth and testing that in another place. :smile:

uri.goldstein
2019-06-03 12:36
has joined #general

uri.goldstein
2019-06-03 12:40
Hello.

uri.goldstein
2019-06-03 12:41
I'm considering Pact for a .net project only the web service are good old fashioned SOAP services. Does PactNet support these, or is it strictly JSON at the moment?

bheemreddy181
2019-06-03 15:12
mock auth to return true you mean on provider ?

matt.fellows
2019-06-03 22:21
Not to my knowledge, but you might be bests checking in #pact-net or on the repo issues.

bethskurrie
2019-06-03 23:13
@ckaptan a delete request with a body is not supported by the ruby implementation. It is a very unusual usecase! @uglyog would it be supported by pact-jvm?

bethskurrie
2019-06-03 23:18
You can do that.

acooper106
2019-06-03 23:20
looks like we were having internal issues before.. Now i'm geting this error when I start the broker. Does this look familiar?

acooper106
2019-06-03 23:20
```22:01:09 2019-06-03 18:01:09,670 [DEBUG] Command 06_start_server_pact_broker output: *************Start Pact Broker Server************* % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 14 100 14 0 0 3 ? 22:01:09 2019-06-03 18:01:09,671 [DEBUG] No services specified ? 22:01:09 2019-06-03 18:01:09,686 [INFO] ConfigSets completed ? 22:01:09 2019-06-03 18:01:09,686 [DEBUG] Not clearing reboot trigger as scheduling support is not available```

bethskurrie
2019-06-03 23:22
Hi @acooper106. Your workmates can join the pact foundation slack channel by going to http://slack.pact.io

acooper106
2019-06-03 23:22
this is the command that I'm running rackup -p 8080 -o $(curl http://169.254.169.254/latest/meta-data/local-ipv4) -D >> pactbroker-service-output.txt

bethskurrie
2019-06-03 23:23
The output that starts `Command 06_start_server_pact_broker output` does not come from the pact broker. It most likely comes from what ever you are using to run the docker container.

bethskurrie
2019-06-03 23:23
``initialize': PG::ConnectionBad: timeout expired (Sequel::DatabaseConnectionError)` This says that your broker cannot connect to the database.

acooper106
2019-06-03 23:25
those are my logs but i'm using the rackup command to start the server

acooper106
2019-06-03 23:25
i fixed the DB connect error

bethskurrie
2019-06-03 23:25
Are you using the docker image?

acooper106
2019-06-03 23:25
yes

bethskurrie
2019-06-03 23:26
you don't need to call rack up then

acooper106
2019-06-03 23:26
docker is installed i believe version 2.0.1

bethskurrie
2019-06-03 23:26
it will start for you automatically

bethskurrie
2019-06-03 23:26
you just run the docker image.

acooper106
2019-06-03 23:26
its doesn't usually start. what command it that to run docker

bethskurrie
2019-06-03 23:27
I'm afraid these are questions you need to ask your ops team.

acooper106
2019-06-03 23:28
i was following the docs to install pact broker

bethskurrie
2019-06-03 23:28
I don't know what architecture, environment or tools you're using to deploy your docker container.

acooper106
2019-06-03 23:28
i believe the last i checked it said to run rackup

acooper106
2019-06-03 23:28
from the example directory

bethskurrie
2019-06-03 23:28
that's if you're running a custom installation

bethskurrie
2019-06-03 23:28
not the docker container.

bethskurrie
2019-06-03 23:28
if you have dius/pact-broker or pactfoundation/pact-broker, you just run the docker container.

acooper106
2019-06-03 23:29
then im not using docker container. I have ruby installed and the i install docker and the pact broker

acooper106
2019-06-03 23:29
do you have doc on this? i believe the doc i was follow said run rackup

bethskurrie
2019-06-03 23:30
Can I suggest that you use the docker container? Running the ruby application directly is something that only experienced ruby developers would be qualified to do. I wouldn't even do it.

bethskurrie
2019-06-03 23:30
No wonder it's crashing!

acooper106
2019-06-03 23:31
i have only seen one doc for the installation


acooper106
2019-06-03 23:31
i'm not sure of any other options

bethskurrie
2019-06-03 23:32
Under "Usage" there is a "container solutions" section https://github.com/pact-foundation/pact_broker#container-solutions

bethskurrie
2019-06-03 23:32
You are trying to "roll your own" which is a technically difficult exercise!

acooper106
2019-06-03 23:33
oo yes i remember now

acooper106
2019-06-03 23:33
we dont have docker in house

acooper106
2019-06-03 23:33
so that why we built it this way

bethskurrie
2019-06-03 23:34
From the line `http://169.254.169.254/latest/meta-data/local-ipv4)` it looks like you're trying to run it on an AWS EC2 instance. Is that the case?

acooper106
2019-06-03 23:37
yes

bethskurrie
2019-06-03 23:43
If you're already using AWS, I would recommend using AWS ECS to run the pactfoundation/pact-broker image. You can find the documentation here https://aws.amazon.com/getting-started/tutorials/deploy-docker-containers/

acooper106
2019-06-03 23:46
ok i will look into this and pass this along to my team.

bethskurrie
2019-06-03 23:46
You will need to ask you own ops people to assist you with the deployment.

acooper106
2019-06-03 23:46
can you speak to our current issuea little more as to why its crashing?

bethskurrie
2019-06-03 23:47
I'm afraid I really don't have enough information to help you.

bethskurrie
2019-06-03 23:47
I can tell you that nobody else has reported these issues, so it is likely to be environment specific.

acooper106
2019-06-03 23:47
ok its hard to identify if its my broker configuration of some other internal issue

acooper106
2019-06-03 23:48
ok what about the most recent one during the start command

bethskurrie
2019-06-03 23:48
If you are running the application directly, without passenger, nginx or puma (which you would get from the docker container), then I'm not surprised it's crashing though. That's not the way to run a production application.

bethskurrie
2019-06-03 23:49
The way you're running it is only suitable for someone playing around with an instance on their local machine - not something that needs to be available 24/7 to support CI.

bethskurrie
2019-06-03 23:50
This is why we've built http://pactflow.io - it takes a lot of engineering to make a service highly available. It's not just to do with the underlying Ruby application.

acooper106
2019-06-03 23:51
ok the doc didn't explain it this way

acooper106
2019-06-03 23:52
to me and our team it seemed like this was an equal option to the docker container

bethskurrie
2019-06-03 23:52
> For production usage, use a web application server like Phusion Passenger or Nginx to serve the Pact Broker application. You'll need to read up on the documentation for these yourself as it is beyond the scope of this documentation. See the wiki for instructions on using a reverse proxy with SSL.


bethskurrie
2019-06-03 23:54
The docs clearly state that you need to use Phusion or similar to run the application in production.

bethskurrie
2019-06-03 23:55
It is beyond the scope of the Pact Broker documentation to explain how to use these. Again, I advise you to contact the ops team at your company.

acooper106
2019-06-03 23:56
like docker container is better but if you dont have it is ok to set it up this way. ok seems like if we dont have docker containers then we can continue this way but we are missing some pieces to make this reliable. ok I'm not sure if we missed that before. Are you sure that this hasn't changed since we first built the broker

bethskurrie
2019-06-03 23:56
No, it has not changed.

acooper106
2019-06-03 23:56
we did consult the ops team when we brought this in and built it on aws

acooper106
2019-06-03 23:57
thats why i'm not sure how we missed it

bethskurrie
2019-06-03 23:57
These instructions are quite old.

acooper106
2019-06-03 23:57
it has been running on aws for a while now and just started seeing major issues

matt.fellows
2019-06-03 23:58
Hi @acooper106, all of the issues you have described are unfortunately outside of our control.

bethskurrie
2019-06-03 23:58
> What version are you running? There are some versions that have quite intensive data processing before I optimised the "matrix" query. The latest versions do not have this issue.

acooper106
2019-06-03 23:59
ok seems like we either need docker container or "Phusion Passenger or Nginx"

bethskurrie
2019-06-03 23:59
I didn't see an answer to this question.

acooper106
2019-06-03 23:59
how to i tell which version of the broker do i have

matt.fellows
2019-06-04 00:00
Running the Pact Broker isn?t a hugely onerous task, but it does take some effort to maintain latest versions, keep it HA etc. I would suggest you have somebody with good operations knowledge look over the design and implementation (if not ownership) to ensure the ongoing stability and performance.

bethskurrie
2019-06-04 00:01
To get the version, go to `/hal-browser/browser.html#` in your broker, and look at the `x-pact-broker-version` response header

acooper106
2019-06-04 00:03
for the last 1-2 years that has been me. I'm technically out of the country now working on getting the broker back up and running

acooper106
2019-06-04 00:03
x-pact-broker-version: 2.32.0

bethskurrie
2019-06-04 00:03
That's the latest version at least.

acooper106
2019-06-04 00:04
i feel like most of our issues are internal tho

acooper106
2019-06-04 00:05
but it felt like we would get updates randomly as well

bethskurrie
2019-06-04 00:05
I'm afraid I have to go. My final advice is to use the pactfoundation/pact-broker image on ECS. The way you are currently running it is not advised, and I'm surprised it's run ok for this long.

acooper106
2019-06-04 00:07
we are using the pactfoundation/pact-broker

acooper106
2019-06-04 00:07
i believe you mean the docker image

bethskurrie
2019-06-04 00:07
ECS is a service for running docker. Yes, use the docker image.

acooper106
2019-06-04 00:08
ok

uglyog
2019-06-04 00:12
Not directly. The mock server will accept it, but any http client libraries may not.

matt.fellows
2019-06-04 00:25
So on a related note - we?ve thought about creating an AWS cloudformation template for this purpose (possibly available via AWS marketplace to make this easier). It would be a bit of effort, but if we created such a thing - would this be something you would consider using instead of rolling your own?

acooper106
2019-06-04 00:26
i have the setup from "rolling my own" in a CF scripts

acooper106
2019-06-04 00:26
its built into our pipeline for maybe 100 teams now

bethskurrie
2019-06-04 00:29
It could just be crashing from the increase in load over time. That's a lot of teams. A single ruby process can only take so much load.

acooper106
2019-06-04 00:30
we have the broker on an aws EC2 instance using the CF templates, auto scaling and load balancer etc. i belive that even at this point i can bring this back up for users but I'll be looking into the aws docker container next. I'm not sure if what you

acooper106
2019-06-04 00:30
now that maybe true

acooper106
2019-06-04 00:30
because it was just happen randomly

acooper106
2019-06-04 00:30
i didn't actually do any analysis on scaling

acooper106
2019-06-04 00:31
but this is autmatically built into everyones build process

bethskurrie
2019-06-04 00:31
Scaling is difficult to do without a lot of fine tuning. Even our ops experts take some time to get it right.

matt.fellows
2019-06-04 00:37
> i have the setup from ?rolling my own? in a CF scripts Sure, but as mentioned, there are lots of little things that make rolling this out a challenge at scale.

matt.fellows
2019-06-04 00:38
To be honest though, if you?ve gotten as far asa 100 teams using it daily, it sounds like you need somebody to actually get their hands dirty to properly help you.

matt.fellows
2019-06-04 00:38
It?s going to be hard (and also very time consuming for us doing this in our spare time) to support your specific needs

acooper106
2019-06-04 00:39
possibly or i just need the aws docker container

matt.fellows
2019-06-04 00:39
:man-shrugging: maybe

acooper106
2019-06-04 00:39
i believe my questions were answered.

matt.fellows
2019-06-04 00:40
excellent!

acooper106
2019-06-04 00:40
thanks for all your help. all of this is good info. and i'll pass it along to my team

acooper106
2019-06-04 00:43
at first i just think they weren't ready for the docker container. but now we have the usage and a strong case for it

neil
2019-06-04 00:57
Hey. Nah no support for SOAP or XML.

richard.jones
2019-06-04 06:37
does anyone know of a stash/bitbucket merge check hook that will check pact verification status (so it?s checked like a build status)?

bethskurrie
2019-06-04 07:09
Can you publish results to a sha like you can with github?

simon.nizov
2019-06-04 08:16
Is there a good practice for provider verification when my provider talks to a 3rd party API (like google maps)? How do I stub that 3rd party API? There?s no pact so `pact-stub-service` isn?t relevant. I tried looking for some kind of standalone VCR stub server but couldn?t find anything worthwhile.

detert
2019-06-04 08:19
If your provider talks to a 3rd party, isn't he a consumer in that case. Wouldn't you use the PactMockService in that case? However if you run the provider verifyAll() tests, maybe you do not want to stub anything ...

simon.nizov
2019-06-04 08:21
No, I mean during the verification stage of a pact between a consumer and a provider, my provider is calling *another service*, which is not under my control, so pact is not an option.

detert
2019-06-04 08:25
Well I know. In that test case he is a provider and a consumer at the same time. And for the consumer part you have to decide if you want to mock/stub the 3rd party or if you use the real API. In my opinion you could could create a pact contract with the 3rd party provider, or you use a simple mock service like http://www.mock-server.com/ or http://wiremock.org/

detert
2019-06-04 08:28
Does that make sense?

simon.nizov
2019-06-04 08:39
Yup, that?s what I was thinking of. Does MockServer have a python client?

simon.nizov
2019-06-04 08:40
WireMock needs Java which is a problem for our use case

alessio.paciello
2019-06-04 08:41
Good morning! Is there a way, in Java, to write verification tests (for the same `consumer-provider` couple) in different test classes? We found no way without using the `@PactFilter` annotation , but doing this we would not fail while a consumer is actually declaring a new interaction


detert
2019-06-04 08:42
mock-server can be configured with json and/or HTTP requests

simon.nizov
2019-06-04 08:44
Yep, but I was hoping to not use pact only for its mocking capability. The Pact docs also suggest that this is not the use case for pact but oh well..

simon.nizov
2019-06-04 08:45
Ideally I would want to use VCR to record my interactions against the 3rd party API. Then in the pact verification I would want some kind tool that can read those VCR recordings and run a stub server with them which my provider would call instead of the real API.

detert
2019-06-04 08:48
Well, I am not using it like that currently (I am really new to this stuff and currently implementing my first consumer / provider tests with ci and all that) However we have way too many 3rd party provider and my idea was to create pact contracts for each of them to be able to run nightly tests for each contract. In that case I would use the pact mock services in cases like yours. However I have no experiences doing that

detert
2019-06-04 11:28
Do you use https://github.com/pact-foundation/pact-mock_service? Maybe you can set --pact-file-write-mode=merge

alessio.paciello
2019-06-04 12:37
Nope I am using the java SpringPactRunner

detert
2019-06-04 13:20
Alright, I have no idea how that works, sorry

ckaptan
2019-06-04 13:40
Thanks, @bethskurrie. I look for more conventional solutions.

bheemreddy181
2019-06-04 13:59
Cool :sunglasses:

dperez
2019-06-04 15:45
hi @neil or @matt.fellows , is there any specific steps I need to follow to build pact-net from a particular branch I cloned?, specifically the message-pact branch. I'm able to build the solution and run the messaging tests and everything works fine inside the solution. Basically I want to build the project to have a nuget package I can include on one of my own projects but not sure how to get it.

gomathi.velayutham
2019-06-04 16:52
has joined #general

rob.clarken
2019-06-04 22:32
has joined #general

richard.jones
2019-06-04 22:42
Ahah! Yes, thanks for the clue!!

richard.jones
2019-06-04 22:43
(now I just need the full commit hash, but I reckon we can solve that)


bethskurrie
2019-06-04 22:45
It was close at one stage, but the person implementing the XML matchers went silent.

richard.jones
2019-06-04 22:47
cool thanks. I also just found https://github.com/pact-foundation/pact_broker/wiki/Pacticipant-version-numbers which I?ll use as a ref to convince folks here to use the full hash as the version

richard.jones
2019-06-04 22:47
it?s not as *readable* though, but we can use tags for that

bethskurrie
2019-06-04 22:48
@detert pact isn't a great fit for 3rd party providers. Unless you can set up the 'provider states` programmatically, it becomes difficult to do the verification step.


bethskurrie
2019-06-04 22:50
@simon.nizov I like the idea of somehow using the VCR recordings to create a mock.

matt.fellows
2019-06-04 23:21
This is one of those cases where you?re talking to the ?dirty outside world?. Depending on those third parties, your level of confidence in the APIs changing could be different (e.g. with AWS I?d have pretty high trust). VCR could be a good option there. But if you have little trust in the system, you may need to continually ensure things work for reals, in which case you have no choice but to actually integrate

yousafn
2019-06-05 00:19
wiremock has a recorder mode and can be used in docker https://github.com/rodolpheche/wiremock-docker but also check out https://github.com/buger/goreplay

yousafn
2019-06-05 00:20
there is a tool that can generate pact files from wiremock mappings but i haven?t got round to trying it out yet


yousafn
2019-06-05 00:23
i tend to run a set of api tests against public api?s and providers i don?t trust (within previous companies where noone talked to each other) on a cron job every hour - found it better to be proactive than reactive

bethskurrie
2019-06-05 00:25
:+1:

neil
2019-06-05 01:12
You can build a nuget package by running the following commands from PowerShell: - Create a release build from VS - `.\Build\Download-Standalone-Core.ps1` If you get a ?The request was aborted: Could not create SSL/TLS secure channel.? error, also run `[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12` - `.\Build\Publish-Release.ps1 -ReleaseVersionNumber "PACTNET_VERSION"` - `.\Build\Publish-StandaloneCore-Releases.ps1 -ReleaseVersionNumber "PACTNET_VERSION"` Replace PACTNET_VERSION with the version number you want. Once all the commands have been run you should see the packages in ./Build dir

neil
2019-06-05 01:13
Alternatively you can use the packages generated from the build https://ci.appveyor.com/project/SEEKJobs/pact-net/builds/22130704/artifacts

neil
2019-06-05 01:13
I do need to merge master back into message-pact, so there will be a new one soon


dperez
2019-06-05 03:07
thanks a lot! @neil you are a life saver

detert
2019-06-05 05:19
@bethskurrie Good point. I missed that

bethskurrie
2019-06-05 05:21
the sweet spot for pact is internal APIs where the consumer teams and provider teams know each other and are collaborating over an API

nick_horne_90
2019-06-05 08:23
has joined #general

elvir.arslanovic
2019-06-05 09:33
has joined #general

taranovskyi.anton
2019-06-05 10:45
has joined #general

nick_horne_90
2019-06-05 14:37
Hi, does anyone know whats happened to the pact-jvm-provider-gradle that used to be here: https://github.com/DiUS/pact-jvm/tree/master/pact-jvm-provider-gradle ?


uglyog
2019-06-05 23:26
Big refactor for version 4.0.x. You can still find the old structure on the v3.6.x branch

perhuman
2019-06-06 02:52
has joined #general

uri.goldstein
2019-06-06 06:52
Thanks @neil and @bethskurrie. I'm thinking of implementing it myself. Can you estimate how much work is involved in getting it done? Will it be in the core Ruby codebase?

bethskurrie
2019-06-06 06:55
Yes, you'll need to do ruby in afraid.

bethskurrie
2019-06-06 06:56
It was super close, and I don't know why it lost momentum.

bethskurrie
2019-06-06 06:56
If you google "pact xml ruby" you should find the repo

bethskurrie
2019-06-06 06:56
In fact, I think there's a channel

bethskurrie
2019-06-06 06:56
#pact-ruby-xml

nick_horne_90
2019-06-06 07:32
Great thanks

uri.goldstein
2019-06-06 07:47
Many thanks @bethskurrie . I don't know Ruby but I want to give it a look. I'll go look for the code and join the channel.


bethskurrie
2019-06-06 07:55
Yes

uri.goldstein
2019-06-06 08:09
Tx :+1:

uri.goldstein
2019-06-06 08:10
Hey, this is you: https://github.com/peer85/pact-xml/commits/master :slightly_smiling_face:

bethskurrie
2019-06-06 08:10
Yes

bethskurrie
2019-06-06 08:11
I did the initial framework to explain how it needed to be written.

bethskurrie
2019-06-06 08:11
But I didn't implement the matching logic.

bethskurrie
2019-06-06 08:11
Not using xml myself!

uri.goldstein
2019-06-06 08:12
Right. Sorry. Got confused.

uri.goldstein
2019-06-06 08:14
Seems like all 3 forks have no commits beyond your initial work.

bethskurrie
2019-06-06 08:14
There's definitely one with work! Have a look at any pr to the original

steveland
2019-06-06 14:20
has joined #general

void.alexey
2019-06-06 16:36
Hi, I am thinking about adding PACT to our company engineering flow. There is no issues when we have «consumer» and «provider». But I also faced use case, that makes me think I am on the wrong way: - assume we have some service API (developed by us); - it will be consumed by another company and it is developed exactly for them to integrate with us (they are the only consumers); - they do not use PACT; - we provide Swagger/Blueprint/etc. Is it OK to implement own generic ?consumer? to write the contract pacts and after that also use it at the same place (code base) to verify ?provider??

russell.blandamer
2019-06-06 17:18
If you are not developing the ?real? consumer, then you have no control over what the it will request from you. Creating a ?fake? consumer in order to perform Pact testing won?t prevent the ?real? consumer from breaking the contract with your provider. IMHO Pact isn?t an appropriate tool in this situation: the whole point is that it?s driven by the consumer.

russell.blandamer
2019-06-06 17:18
Disclaimer: I have been using Pact for like three weeks: I?m not an expert.


antonello
2019-06-06 18:05
You could - in theory - have a pact broker that both you and your client use.

antonello
2019-06-06 18:07
But your client would have to commit to write and maintain consumer tests and publish them to that pact broker.

antonello
2019-06-06 18:08
The standard advice is to not use pact for public APIs, but it you?re building an API for just one client, then it may work out ok for you.

void.alexey
2019-06-06 19:00
My initial goal is: verify and keep up to date API spec we share with client + be able to confirm that changes on provider won?t break current client interactions with us

void.alexey
2019-06-06 19:02
So from these points I came up with idea about using pact + Atlassian tool for swagger spec verification

bethskurrie
2019-06-07 00:43
@void.alexey if your consumer is not actually generating a pact from their own consumer tests, Pact is not going to help you much. In this case, you're best off providing them a swagger document, and then making sure (either by generating the swagger from the code, or via a swagger verification tool like dredd) that your swagger document and provider are in sync.

bethskurrie
2019-06-07 00:43
Peeps - the long awaited "Feature support table" is available here: https://docs.pact.io/feature_support Thanks to @tjones for making me get off my ass and write it.

tjones
2019-06-07 00:45
I love it!

acooper106
2019-06-07 01:21
/usr/lib64/ruby/gems/2.6.0/gems/sequel-5.21.0/lib/sequel/adapters/postgres.rb:206:in `initialize': PG::ConnectionBad: timeout expired (Sequel::DatabaseConnectionError)looks like this has returned. is this issue on my side?i updated the version of ruby https://koshigoe.github.io/ruby/2019/02/06/ruby-2.6.1-bundler-1.17.2.html

bethskurrie
2019-06-07 01:21
Yes, it is an issue on your side. Your ruby process cannot connect to the database.

acooper106
2019-06-07 01:22
hmm ok sometimes its does and sometimes its doesnt

bethskurrie
2019-06-07 01:22
Sounds like you have some kind of intermittent network issue.

acooper106
2019-06-07 01:23
and from that article looks like that combination of bundler and ruby had issues so i upgraded to 2.6.2

bethskurrie
2019-06-07 01:23
Again, you need your own ops people to help you with this.

bethskurrie
2019-06-07 01:23
Again, I recommend you use the docker image.

bethskurrie
2019-06-07 01:23
I have not tested the broker on ruby 2.6

bethskurrie
2019-06-07 01:24
It has been well tested on the version of ruby that is in the docker image.

void.alexey
2019-06-07 04:31
Thank you. Dredd is a good fit, but their golang hooks seems to be not so easy to use, compared to pact provider states :(

dennis.woditsch
2019-06-07 11:12
has joined #general

yousafn
2019-06-07 11:56
That is quality, good work team. There are a few features that I would love to get into pact-js when time allows :slightly_smiling_face:

yousafn
2019-06-07 11:56
Is it worth having the titles of the repo?s as links to the github repos for ease of convenience

bethskurrie
2019-06-07 11:57
I can add links, good idea.

bethskurrie
2019-06-07 11:59
Overall, I found dredd not as flexible as pact, but better than not verifying at all.

sgoodarzy
2019-06-07 21:28
has joined #general

hboddupalli
2019-06-07 21:31
has joined #general

sgoodarzy
2019-06-07 21:34
Hello @everyone I'm very new to pact so I'm gonna say beforehand that I'm sorry if my question is stupid. In the publisher/subscriber communication model , if service A is publishing messages to service B which one is consumer and which one is provider ?

matt.fellows
2019-06-08 02:28
Not stupid! Service B is the consumer. It is the one that consumes the message, so it must be able to handle what is published.

luchillo17
2019-06-08 20:22
Hey guys do you know why pact can't find our provider if we have it running? maybe because it's apollo? the object above are the options passed to the verifier, any idea?

yousafn
2019-06-08 21:42
Maybe try localhost rather than 0.0.0.0

luchillo17
2019-06-08 21:48
@bethskurrie Ok after debugging we found something interesting, we're passing the host url, but as you see in the image, the host url used in the verifier command is not using what we sent it, i think it might be a bug

pact.io
2019-06-08 22:06
the broker stores your pact contracts. the provider is your service under test

yousafn
2019-06-08 22:23
it always reads as that, see my image. The issue is it can?t hit your provider, on 0.0.0.0. Your error states nothing found on port 3001, so it is reading your providerBaseUrl correctly

yousafn
2019-06-08 22:24
my providerBaseUrl in the screenshot is actually `https://petstore.swagger.io`

yousafn
2019-06-08 22:24
but the verifier shows it as `--provider-base-url 'http://localhost:53146'`

yousafn
2019-06-08 22:25
try `localhost:3001` instead of `0.0.0.0:3001`. Can you curl your service on `0.0.0.0` ?

matt.fellows
2019-06-08 22:39
@luchillo17 this is normal, the node process proxies your API to be able to do state handling and request filters

matt.fellows
2019-06-08 22:57
You probably need to or fix your provider got name with `http://`

luchillo17
2019-06-09 00:26
Yep indeed i found out later it was being proxied, and had to split my host config in 2 variables, one for the server and another with `http://localhost` for the other, now it works. Thanks @yousafn @pact.io @matt.fellows

matt.fellows
2019-06-09 00:31
You?re welcome. Could you please raise an issue on pact-js for this? We should probably provide better validation to indicate that problem

luchillo17
2019-06-09 00:36
Sure

luchillo17
2019-06-09 00:41
Hmm i think it should be in pact-node since it's the server side right?

matt.fellows
2019-06-09 00:43
Raise it in Pact JS and we?ll worry about the implementation. Pact Node shouldn?t really be a client facing thing for the most part

matt.fellows
2019-06-09 00:43
But thanks for thinking that way

matt.fellows
2019-06-09 00:43
It might end up in Pact Node

luchillo17
2019-06-09 00:43
I mean i looked through my lock file and pact-js was nowhere to be seen, but ok, i'll raise it there

matt.fellows
2019-06-09 00:45
Oh I see. sure, pact node is fine

matt.fellows
2019-06-09 00:46
hmm really? The fact that your code is going through that proxy (i.e. your host name is changed) tells me you must be using pact js

matt.fellows
2019-06-09 00:47
the dependency will be `@pact-foundation/pact`

luchillo17
2019-06-09 00:47
Yes i'm using that one

matt.fellows
2019-06-09 00:47
that?s pact js

luchillo17
2019-06-09 00:47
In it's dependencies i saw pact-node

luchillo17
2019-06-09 00:47
Ah ok


vetisanvasile
2019-06-10 12:48
has joined #general

vetisanvasile
2019-06-10 13:05
hi

anddreiu
2019-06-10 13:11
has joined #general

matt.fellows
2019-06-10 13:16
:wave:

vetisanvasile
2019-06-10 13:37
I would like to ask if I could post here a question that I posted on stackoverflow but remained without an answered

yousafn
2019-06-10 17:20
@vetisanvasile - ask away, plenty of friendly people here, or post a link to your SO question :call_me_hand:

trent.grover
2019-06-10 19:14
has joined #general

acooper106
2019-06-10 19:15
my team believes that the docker image does not work with our integration of id vault (i'm not sure why they would say that I would have to look into this more). However they would like to continue with the current setup. And are wondering how the container would solve our stability issues and are asking the question below:

acooper106
2019-06-10 19:16
1. Can we ask Beth if we are able to run broker on multiple nodes? Ideally would like to have multiple instances running broker app which points to 1 RDS We only have one node behind the ELB . Does pact support HA where we can have N nodes running connected to the same DB ?

acooper106
2019-06-10 19:17
i believe you mentioned this earlier. that "Pactflow (the hosted Pact Broker) runs in a "highly available architecture", and the fact that it is "highly available" is not much to do with the underlying Ruby application, and mostly to do with the way it is run and deployed (multiple ec2 instances, no downtime deployments, monitoring, auto scaling etc)."

acooper106
2019-06-10 19:17
so does this mean that my current configuration is already leveraging this design out of the box

acooper106
2019-06-10 19:19
or were you saying that if we use the aws ECS container then we would get this HA configuration out of the box

matt.fellows
2019-06-10 21:27
Yes, it can be run on multiple nodes behind a load balancer. It's a stateless design as per modern API design, so no need for sticky sessions etc

matt.fellows
2019-06-10 21:38
If you could reshare your q here, we'll make sure it gets updates if it's answered here

yousafn
2019-06-10 23:21
Hey up, I had an initial stab at this yesterday Hopefully I?m going in the right direction https://github.com/pact-foundation/pact-support/pull/69 Ps. Wife is a-ok after the op!

matt.fellows
2019-06-10 23:23
> Ps. Wife is a-ok after the op! That?s awesome news!

vetisanvasile
2019-06-11 06:09
oky, so a bit of background first Ia have two applications (one - tConsumer that requires some data from wProvider) And I have to set up an automation framework to write the provider part for pact. My automation framework is a standalone maven app (like new Java Project -> maven...so on)

vetisanvasile
2019-06-11 06:09
I need to execute a @State for my provider in order to set up some data


n.chachampis
2019-06-11 06:37
has joined #general

yousafn
2019-06-11 12:19
good post written by the team at atlassian about spec-first API dev, with swagger and pact https://www.atlassian.com/blog/technology/spec-first-api-development

colin.moorehill
2019-06-11 15:43
has joined #general

matt.fellows
2019-06-11 21:05
They?re doing some cool stuff out there. I?ll reach out to James to see if there is anyway we can continue to collaborate. Ben Sayers and Mauri did a great talk a few years back too, and we?ve been in pretty good dialogue since

aniela.cole
2019-06-11 23:04
has joined #general

calvin.mcstein
2019-06-11 23:04
has joined #general

gabrielle.gasse
2019-06-11 23:05
has joined #general

calvin.mcstein
2019-06-11 23:14
:wave: good folks, I have a noobie question. Can pact tests be implemented in a language (ex: pact-js) regardless of whether the application has been (ex: spring boot). I'm evaluating if this can be tool-agnostic and I'm leaning towards a javascript implementation.

bethskurrie
2019-06-11 23:17
You typically need the consumer side to have an implementation in a matching language. The provider side, you can be more agnostic about the language, though it helps to have a matching one because the tooling can be managed with your normal language tools.

bethskurrie
2019-06-11 23:17
You can use pact jvm for a spring boot app.

bethskurrie
2019-06-11 23:18
The consume and provider languages don't need to match.

calvin.mcstein
2019-06-11 23:32
yep, that makes sense. Thanks @bethskurrie

matt.fellows
2019-06-12 01:34
@uglyog are you able to help?

matt.fellows
2019-06-12 01:35
Sorry @vetisanvasile I probably can?t easily help with the maven issue, but I?ll take a quick look

matt.fellows
2019-06-12 01:41
From what I can tell, the `@State` annotation is not supported for the Maven plugin


richard.jones
2019-06-12 02:28
Just reading the ?Effective Pact Setup Guide? under ?Configure pact to be verified when provider changes? AFAICT the provider verification (for a new provider version) will just verify the latest pacts from the consumer. Assuming that there?s a feature branch and a prod pact registered, the provider?s verification will probably only check that feature pact, and not prod. All good for the feature branch - it?s status is updated to reflect potential changes in the provider, yay! You can force the checking of prod pacts by having a separate, explicit prod check (which is probably a good idea so that build can *fail* if the prod pacts fail). All good. Except what if there?s more than one feature branch in flight for a consumer? How do we ensure all *in-flight feature pacts* are checked when the provider changes?

bethskurrie
2019-06-12 02:29
You win all the points for working out what one of the upcoming features is :wink:

bethskurrie
2019-06-12 02:30
At the moment, you need to explictly add the tag of the "work in progress" pacts to your verification. But these will be pulled in automatically very soon as "pending" pacts (ones that don't fail the provider build).

bethskurrie
2019-06-12 02:32
Some teams use matching tag names for the consumer/provider branches. So, consumer publishes 'feat-x' pact, from branch 'feat-x'. Provider has makes a matching branch called 'feat-x'. The default pact verification step dynamically verifies the consumer tag matching the current git branch name, and master.

richard.jones
2019-06-12 02:40
Ahh yep. Honestly, we probably won?t implement proper tagging before pending is implemented :slightly_smiling_face:

bethskurrie
2019-06-12 02:52
You guys!

bethskurrie
2019-06-12 02:52
Well, points for perseverance.

tjones
2019-06-12 02:59
We've solved this in the past by taking "latest" as work-in-progress, and only explicitly tagging prod

bethskurrie
2019-06-12 02:59
That's a simple and reasonable first step.

tjones
2019-06-12 03:00
that strategy might mean that you're not testing all pacts (because the latest might be a feature branch, if you're doing feature branches), but if you do a can-i-deploy before you deploy, it doesn't matter

richard.jones
2019-06-12 03:00
yeah, I?m not sure that solves the problem of having multiple features in flight

richard.jones
2019-06-12 03:01
webhooks only fire on pact content changes too, so another what-if has come up in our discussions. Let?s say this sequence happens: 1. consumer publishes feature pact, broker marks as pending 2. provider verifies pending pacts, result in the feature pact marked not-pending 3. provider makes a change which breaks the pact, but their checks only run against consumer master and pending pacts 4. provider releases to prod 5. consumer can merge and release their feature, and as far as I can tell because there?s no change to their pact, there?s no provider verification and the feature is now broken.

bethskurrie
2019-06-12 03:01
It doesn't really, but at least it stops you deploying anything broken.

bethskurrie
2019-06-12 03:02
> provider verifies pending pacts, result in the feature pact marked not-pending

bethskurrie
2019-06-12 03:02
It depends on which branch of the provider.

tjones
2019-06-12 03:02
^ Exactly. This is what I care about

bethskurrie
2019-06-12 03:02
Are we assuming you're using branches/tags for your provider, or not?

tjones
2019-06-12 03:03
Also, having multiple features in flight is going to cause other problems, not just with Pact. How do you solve those?

richard.jones
2019-06-12 03:03
I?m not entirely sure how provider tagging works yet :sweat_smile:

bethskurrie
2019-06-12 03:03
Let's say no then.

bethskurrie
2019-06-12 03:04
At step 5, the pact changed webhook will fire because you've now merged that content into master.

bethskurrie
2019-06-12 03:04
It will fire because the content has a new tag.

bethskurrie
2019-06-12 03:04
Oh, you're not using tags...

richard.jones
2019-06-12 03:05
oh, the tags are included in the pact contents for contract_content_changed!!

bethskurrie
2019-06-12 03:06
unintentionally, yes. there was a pr that I merged without really considering the impact. The logic is this: for each of the tags that the consumer version has been given, check to see if the content is different from the previous latest version with that tag.

bethskurrie
2019-06-12 03:06
Think of a series of tagged versions forming a 'pseudo branch'.

richard.jones
2019-06-12 03:06
We were reading the webhooks docs to see if that was the case, and concluded that the tags didn?t come into its ?triggered when the content of the contract has changed?

richard.jones
2019-06-12 03:07
If tags trigger a new contract_content_changed then all my (current, lol) problems are solved :slightly_smiling_face:

bethskurrie
2019-06-12 03:07
in your case, it will trigger because you have no tags, and the content is different from the previous latest pact.

richard.jones
2019-06-12 03:08
but in my scenario the content of the pact doesn?t change from the version published in step 1

bethskurrie
2019-06-12 03:08
You don't have "feature" pacts, you only have "latest", because you don't have tags.

bethskurrie
2019-06-12 03:09
the can-deploy check is the thing that stops you deploying a broken integration.

bethskurrie
2019-06-12 03:09
and this is where you really need tagging.

richard.jones
2019-06-12 03:09
This is all assuming that we do implement tagging. So for ?feature pact? I mean ?a pact tagged as feature-x?. My apologies that wasn?t clear.

bethskurrie
2019-06-12 03:09
though, I guess if you have one broker for production, and one for dev, then you might get away with it.

bethskurrie
2019-06-12 03:10
`can-i-deploy --pacticipant Foo --version X` will make sure that version X is compatible with the latest versions of all the other apps that Foo has a pact with.

richard.jones
2019-06-12 03:10
But the sticking point for us was that tag changes (with otherwise identical pact content) didn?t appear to trigger a webhook verification

bethskurrie
2019-06-12 03:11
but you're not using tags?

richard.jones
2019-06-12 03:13
We?re going to be using them, but in order to do so I need to convince people here to use them, which means I need to be able to explain how the workflow changes, and I was just doing that and the person I was explaining it to came up with the what-if that I posted. I couldn?t see how, at step 5, can-i-deploy won?t have an out of date passing verification to work from. The feature pact won?t have been re-verified when the provider merges their breaking change. But if I understand you correctly, the pact *will* be re-verified (even though it?s the same content) because when the consumer merges it, it?s now tagged with a different branch name (?master? instead of ?feature-x?) and that causes the webhook to fire.

bethskurrie
2019-06-12 03:14
yes

richard.jones
2019-06-12 03:14
\o/

richard.jones
2019-06-12 03:14
thank you again

bethskurrie
2019-06-12 03:15
np

richard.jones
2019-06-12 03:19
Lots of communication, and sometimes feature toggles. It doesn?t happen often.


bethskurrie
2019-06-12 03:48
I've just written an article on using can-i-deploy https://github.com/pact-foundation/pact_broker/wiki/can-i-deploy @richard.jones would love your feedback (and anyone else's feedback too). I'll move it to http://docs.pact.io when I've worked out where to put it.

richard.jones
2019-06-12 03:49
oooh! reading it now :slightly_smiling_face:

bethskurrie
2019-06-12 03:52
@tjones you're our resident copywriter, I'd love your feedback too when you have time.

richard.jones
2019-06-12 03:52
that?s a fantastic explanation, thanks Beth!

bethskurrie
2019-06-12 03:52
Does the reason for provider tags make sense now?

richard.jones
2019-06-12 03:55
yep!

bethskurrie
2019-06-12 03:56
win

bethskurrie
2019-06-12 03:57
So the "stage" tags (test, dev, prod) are used for can-i-deploy, while the branch tags (master, feat-x) are used for managing feature development.

bethskurrie
2019-06-12 03:58
I did some work on splitting them out into separate underlying relationships (stage and branch), but I lost momentum on it.

bethskurrie
2019-06-12 03:59
I was thinking of changing the stage tags into "deployment" resources with extra details, and then I just overthought it and ground to a halt!

tjones
2019-06-12 03:59
I think we don't want Pact to be opinionated about how you're doing your branching (if at all)

bethskurrie
2019-06-12 04:00
yeah, that was one of my other thoughts - tags are quite unopinionated.

tjones
2019-06-12 04:00
for example, I prefer not to do feature branches. I think the ideal Pact tagging structure then becomes just "where is this deployed?"

tjones
2019-06-12 04:00
Well, it's nice to have guides for different styles of working

tjones
2019-06-12 04:01
There's an AWS article about how to get git-flow working in their CI/CD products. It starts with a note that is like "full disclosure, we encourage our teams not to work this way. But, if you want to - here's how you can do it"

bethskurrie
2019-06-12 04:01
ha

bethskurrie
2019-06-12 04:19
@richard.jones are you across the "passing the URL of the changed pact to the provider pact verification job using webhook template parameters" technique?

richard.jones
2019-06-12 04:39
I have noted that in our planning, yep. I?m not sure how easy it?ll be to implement in practise across all our teams.

anddreiu
2019-06-12 06:28
Hi @matt.fellows. So there is no way to run a class annotated with @RunWith(PactRunner.class) using mvn pact:verify? In that class we would have @State and some other code which we would like to invoke when verifying the pact (for example, we are altering the request body) in a method annotated with @TargetRequestFilter

matt.fellows
2019-06-12 06:41
It doesn't seem like it. Hopefully when Ron gets a moment he can contribute to the discussion

anddreiu
2019-06-12 06:43
I have also tried to run it with maven surefire plugin, using mvn test command, but this way it's not able to connect to a pact broker using https - not sure how to solve this

anddreiu
2019-06-12 06:45
this is a little bit strange, because using the IDE it is able to connect to the pact broker (I am using the annotation for PactBroker, having also authentication), but when running as maven, it does not

matt.fellows
2019-06-12 06:57
Sure. I'm not a Java dev so hard for me to comment as to why it's the case. If you're running in your ide but not using maven that might be telling. All I'm saying is the docs don't suggest it's possible

poojashukla9219
2019-06-12 07:37
has joined #general

thavamani.raja
2019-06-12 08:41
has joined #general

anddreiu
2019-06-12 10:37
I just want to let you know that I have managed to solve the maven https issue using parameters for trustStore when running the maven command: -Djavax.net.ssl.trustStore=/path/to/file/cacerts -Djavax.net.ssl.trustStorePassword=password

iamtarasshevchenko
2019-06-12 11:21
has joined #general

matt.fellows
2019-06-12 12:02
Right, so you must be using a self-signed certificate somewhere

anddreiu
2019-06-12 12:02
yes, exactly

matt.fellows
2019-06-12 12:03
:thumbsup:

jrubial
2019-06-12 12:27
has joined #general

codrut.gusoi
2019-06-12 12:40
has joined #general

vetisanvasile
2019-06-12 12:50
@matt.fellows I also think that currently there is no way to execute @State from maven plugin. Thanks for the answer

codrut.gusoi
2019-06-12 12:53
:wave: Hello everyobdy. Any chance someone could help me out with writing a message contract test for clojure? I see there is an example here https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit/src/test/clojure/au/com/dius/pact/consumer/example_clojure_consumer_pact_test.clj but that file uses HTTP. What would `config (-> (MockProviderConfig/createDefault))` need to be replaced with for it to work with `MessagePactBuilder`? I see `ConsumerPactRunnerKt` tries to run a mock server.

matt.fellows
2019-06-12 12:58
:+1: sorry :persevere:

thomas.scheuchzer2
2019-06-12 13:17
has joined #general

acooper106
2019-06-12 13:28
I was really asking if its with our current setup or it only configured that way within the container?

enrique
2019-06-12 15:00
has joined #general

detert
2019-06-12 15:17
Which regex would you use, if you describe a field lastName or firstName? Is `.+` too generic?

detert
2019-06-12 15:19
Or would you use `Pact::SomethingLike('John')` for example?

mounikachirasani
2019-06-12 15:38
has joined #general

enrique
2019-06-12 15:42
If any string is a valid `lastName` then I would use exactly that

enrique
2019-06-12 15:43
If you have some validation requirements I would describe them as a regular expression

enrique
2019-06-12 15:43
And I meant validation requirements from the consumer side, the consumer side really cares about the format.

detert
2019-06-12 15:48
Well the consumer does not really care. It might be something like "John Martin" as well

detert
2019-06-12 15:49
Maybe UTF-8 is important. Maybe

codrut.gusoi
2019-06-12 17:05
I got it working by doing: ``` (ns message-consumer.core-test (:require [clojure.test :refer :all] [message-consumer.core :refer :all]) (:import [au.com.dius.pact.consumer MessagePactBuilder] [au.com.dius.pact.consumer.dsl PactDslJsonBody] [au.com.dius.pact.model PactSpecVersion])) (defn process-message "I do cool stuff" [message] (str "Got: " (.toString message))) (deftest clojure-message-consumer-pact-test (let [builder (-> (MessagePactBuilder/consumer "message-consumer") (.hasPactWith "message-provider")) content (-> (new PactDslJsonBody) (.stringValue "Important" "Data")) pact (-> builder (.given "Some condition") (.expectsToReceive "an important message") (.withMetadata {"contentType" "application/json"}) (.withContent content) (.toPact))] (let [interaction (-> pact (.getInteractions) (first)) message-body (-> interaction (.getContents) (.valueAsString))] ;; This is where the fun begins! (let [result (process-message message-body)] (is (= result "Got: {\"Important\":\"Data\"}"))) (.write pact "./pacts/" PactSpecVersion/V3)))) ```

codrut.gusoi
2019-06-12 17:05
Is there a better way?

phall
2019-06-12 20:28
Hi all, we?re developing a micro service architecture, with communication via REST. One area we?re having difficultly with is multiple consumers requiring similar provider states. e.g. Two consumers each want a similar response when a resource exists at a URL. ConsumerOne writes a provider state ?resource exists?, ConsumerTwo writes the same state as ?resource found?. The two consumers do not (and should not) know about each other. Should the provider accept all the various permutations of the same state? Or should there be a shared library, or external process to manage these states?

matt.fellows
2019-06-12 22:11
I?d get them to standardise on the state if possible. Maybe the two consumers don?t know about each other, but the provider should know about its consumers and there should always be a conversation between the consumer/provider before a pact is ?accepted?.

matt.fellows
2019-06-12 22:12
If I was the provider team, I?d ?reject? the pact and tell them to use the other already existent state

matt.fellows
2019-06-12 22:12
We?re working on making the known states available in the Broker (http://pactflow.io) to make this sort of thing easier for consumers to discover

uglyog
2019-06-12 22:56
I've added an additional answer on SO

richard.jones
2019-06-13 00:34
Looks good, thanks!

bethskurrie
2019-06-13 04:18
:pray::skin-tone-3: :pray::skin-tone-3: :pray::skin-tone-3: Hey all! There have been quite a few PRs coming through lately, and I just wanted to thank everyone who has contributed to any of the Pact code or docs. Maintaining and developing on such a large number of codebases and across so many languages (there are 46 repos in pact-foundation alone!) is a big task, and your assistance is greatly appreciated. :pray::skin-tone-3: :pray::skin-tone-3: :pray::skin-tone-3:

bethskurrie
2019-06-13 04:19
Side note, `Pact.like("John")` is shorter.

matt.fellows
2019-06-13 04:27
:point_up: this ++

matt.fellows
2019-06-13 04:27
Thank you. Special call out to @yousafn who I know I?m neglecting in GitHub but know that I _will_ get to your queries/efforts :smile:

detert
2019-06-13 05:52
:smiley::+1:

gerwin.vaatstra
2019-06-13 07:05
has joined #general

yousafn
2019-06-13 08:27
It?s our small way of saying thank you to you all, for doing all this for free, in your spare time. As Beth states, 46 repos, let alone 1 is a mammoth task, alongside your full times jobs, and the release of pact-flow. Don?t worry about getting back to me quickly - you?ve got bigger fish to fry, and we will work around stuff in the day job, but feedback where we can do help improve pact for everyone. Just glad to be able to help out, find it very empowering and it embodies all the good in FOSS. Just make sure you don?t burn yourselves out guys :heart::heart::heart:

yousafn
2019-06-13 08:28
Your NOT neglecting me homie, trust me! You?ve don?t owe us users anything but you give us everything. Much respect

matt.fellows
2019-06-13 11:25
It?s a great feeling, seeing somebody raise an issue for the first time or send a PR.

matt.fellows
2019-06-13 11:25
?OMG somebody is using my _thing_!?

anna.lakstigala
2019-06-13 12:34
has joined #general

neonmd
2019-06-13 15:19
has joined #general

vivek.125
2019-06-13 19:43
has joined #general

vivek.125
2019-06-13 19:43
~hi, how can i get the request reponse logs when running a provider?~

kalinets
2019-06-13 20:01
has joined #general

canomn
2019-06-13 21:05
has joined #general

canomn
2019-06-13 21:19
Hey pact peeps, I'm interested in implementing contract tests at my company, but am a bit unsure of how to get started. Our project consists of two teams, a frontend team, using angular (typescript) and a backend team, using .NET (C#). where do contract tests fit in this situation? what team owns them?

yousafn
2019-06-13 22:15
your consumer will create pacts and publish them to a pact broker. I assume your front-end is calling the backend C# service. your provider (the backend) can then verify that they meet those pacts, and publish the verification results to the broker. Everyone can use can-i-deploy, to find out if they can deploy their services to a particular env. it?s often called consumer driven contract testing, because your consumers provide a contract, as to what they are consuming, from the provider, however in reality, it?s collaborative, the provider should have a vested interest in the contracts, so ownership should be shared, if that makes sense try the pact nirvana guide with steps 1/2, see how you go, and then you can begin to roll it out, as you get buy it. https://docs.pact.io/best_practices/pact_nirvana

yousafn
2019-06-13 22:25
Hah, yes THIS! I built a slack reporter for cypress, as my first open source thing, and someone posted the first issue and I was so happy (even if they had an issue) that the first line of my reply was ``` Hey buddy, thanks for using my plugin! woop woop! ``` I?ve now got 25 odd stars across my few repos and it?s a great feeling. When I?m not playing with computers, I?m tinkering with old cars, and I have written countless guides to help others with engine conversions and the like, so it?s natural to do the same with tech. Wish I had started earlier in my career, but it?s never too late.

matt.fellows
2019-06-14 01:01
start with a consumer contract in your Typescript application for a single API endpoint and a happy scenario (e.g. `GET /users/` should return a list of users and a `200` response). Then publish to a Pact Broker (e.g. hosted at http://pactflow.io or otherwise) and then get your provider team to verify the contract

matt.fellows
2019-06-14 01:02
The contract is owned by the consumer team, but as Yousef says - it?s a collaborative thing. So step 1 is get the two teams talking to each other and agreeing on building the prototype, and measuring the outcomes of the experiment

cjadav
2019-06-14 05:38
has joined #general

anddreiu
2019-06-14 13:34
hi guys. I have added a question on github: https://github.com/DiUS/pact-jvm/issues/893 Did anyone else see this problem? maybe I am doing something wrong and I don't know why the verification reports don't contain all the interactions from my pact file

mui_ume
2019-06-16 11:54
has joined #general

bethskurrie
2019-06-16 22:05
@anddreiu please ask on #pact-jvm

bethskurrie
2019-06-16 22:10
Peeps. We're discussing the issue that some people are having with integers not matching floats/doubles when doing type based matching in pact-js (and other implementations that use the ruby impl under the hood). The ruby implementation has never treated these as equivalent, however, it turns out that the pact-jvm implementation has. Pact specification fail. Anyway, We're discussing adding a flag to make integers/floats match during verification time, and wondering if that should actually be the default behaviour. It would be technically breaking backwards compatibility, but maybe that's ok... thoughts?


matt.fellows
2019-06-16 22:24
I'm leaning towards just making it the default behaviour. Another better option would be to allow the two new matchers on int/floats (i.e. precise matching) and keep the existing matcher as a general "number". No need for flags, but granted it confuses the spec implementation

abubics
2019-06-16 23:27
I would've expected JSON numbers (i.e. decimal) to be the default, and integers only if explicitly specified. But I don't have anything to break right now . . . :sweat_smile:

uglyog
2019-06-16 23:50
Just a note (based on some testing I have done) JSON parsers can return a different type depending on the format of the number. Decimal may not be the default.

bethskurrie
2019-06-16 23:51
ruby has bigdecimal for very large floating point numbers, but float for smaller ones

matt.fellows
2019-06-16 23:57

matt.fellows
2019-06-16 23:58
but I have similar experiences to Ron. For example, in NodeJS a whole number decimal (e.g. 7.0) will be rounded to 7. So even if you wanted a float, you would have to specify something else (which is a bit confusing)

matt.fellows
2019-06-17 00:00
NodeJS floating point information loss

uglyog
2019-06-17 00:00
And different parsers in different languages can do something different.

matt.fellows
2019-06-17 00:00
mmm


uglyog
2019-06-17 00:01
Scala always returned floats, Groovy would return Integer or BigNumber.

matt.fellows
2019-06-17 00:01
> JSON has no standard way to represent complex numbers, so there is no way to test for them in JSON Schema.

giancarlo.dipaolanton
2019-06-17 00:21
has joined #general

abubics
2019-06-17 00:37
A cool* thing I found using Jackson (in Kotlin): JSON numbers could be configured to come through as `Int`/`BigInt` and `Double`/`BigDecimal`, but it would still always throw precision away if the fractional part was all zeroes

mui_ume
2019-06-17 06:00
Hi Do you have any boilerplate project for me to get started on using pact with react native app as the front end client talking to services at the backend

mui_ume
2019-06-17 06:00
I like to use Javascript thanks

matt.fellows
2019-06-17 06:27
Are the existing JS examples not relevant? React native is just JS and react so nothing different

yousafn
2019-06-17 06:50
We use decimaljs at work in JavaScript on our consumer side but send them in strings, so that precision is maintained, ( as it goes through to 2 java rest services and then encoded in a soap message ) - our java services use Jackson

mui_ume
2019-06-17 06:51
Can I have my pact test repo separated from My react native app source code ?

bethskurrie
2019-06-17 06:52
What problem are you trying to get around?

bethskurrie
2019-06-17 06:52
Typically they're in the same codebase as the tests are run along with the other unit tests.

yousafn
2019-06-17 06:52
We had an argument when our provider changed their format in the specs to number, for fields that could contain integers or floats, when we had previously agreed on string, so they changed it back . PayPal use string in their api spec

matt.fellows
2019-06-17 06:54
Yep, it?s a good idea if you don?t want to lose precision over the wire

bethskurrie
2019-06-17 06:54
mm. typically people use strings or integer cents because of the whole precision thing.

bethskurrie
2019-06-17 06:54
sad!

bethskurrie
2019-06-17 06:54
stupid computers.

mui_ume
2019-06-17 06:56
I?m trying to setup the pact test with react native app And I am putting the API call http request and response Those response in Json format

mui_ume
2019-06-17 06:57
Looking at the example I?m quite confused

bethskurrie
2019-06-17 06:57
How does that relate to putting the pact tests in another codebase?

abubics
2019-06-17 06:58
it's the only thing I know is handled pretty well in XML :troll:

abubics
2019-06-17 06:59
Also, integer cents falls down in some finance cases . . . where they have fractional cents, because they like inventing new ways to hurt themselves :upside_down_face:

mui_ume
2019-06-17 07:00
If I use the same codebase Do I create a subfolder called test and put all my spec js file there And do a npm install at the package.json

mui_ume
2019-06-17 07:01
Do you have a simple example how to add a pact test and any npm package to Install ?

matt.fellows
2019-06-17 07:11
What is confusing about the examples on the pact js repository?

matt.fellows
2019-06-17 07:12
they collectively cover a lot of scenarios. I can have them updated if they are confusing

matt.fellows
2019-06-17 07:12
the jest/mocha examples are pretty basic

matt.fellows
2019-06-17 07:12
And yes, I typically have tests within the codebase in a subfolder that groups them together

mui_ume
2019-06-17 07:13
Ok if that is needed I will talk to the developer to add the subfolder there I need to get started and will take a look at the jest /mocha example

yousafn
2019-06-17 07:40
Tests need to be in your root dir with react ( usually src) but can be in any folder. Ideally call your tests .pact.js to seperate from unit tests but you want them in the same codebase so you are testing your codes api clients

yousafn
2019-06-17 07:42
Create react app?s jest config excludes any test files outside of the rootDir by design and cannot be overridden unless you eject from the CRA default ( but then you have to manage all your deps separately ) collaborating with your dev is best, as you want them to treat the pact tests as unit tests and be part of their dev workflow :ok_hand:

mui_ume
2019-06-17 07:44
Thank you Will start working on that

fili.projetto
2019-06-17 10:14
has joined #general

mui_ume
2019-06-17 10:41
Hi, I just have a look at https://github.com/pact-foundation/pact-js. I still do not quite understand how to integrate this into my react native app folder


mui_ume
2019-06-17 10:44
currently the react-native app does not have any jests' __test__ folder

mui_ume
2019-06-17 10:45
is there a simple example, just to see how pact is setup for a react native app? without any irrelevant folder and files?

matt.fellows
2019-06-17 10:46
Not in the pact js repository. We'd happily accept an example if someone is willing to share

mui_ume
2019-06-17 10:46
I also does not quite understand the content of pactSetup.js, I added to my react native app folder, there is alot of syntax error in my VS code, so I don't know what is not needed

matt.fellows
2019-06-17 10:48
Have you written any unit tests for a react native app before?

mui_ume
2019-06-17 10:48
no. I am in QA. I did on end to end testing only. I am familar with appium

mui_ume
2019-06-17 10:49
but now I want to setup pact

matt.fellows
2019-06-17 10:52
Think of Pact as just another unit testing framework. There is nothing specific to react native required to do this testing. My suggestion is to pair with a developer who's written unit tests and get their input on setting it up and then you can write the tests independently

matt.fellows
2019-06-17 10:53
May I ask, is this something you're investigating or has somebody else asked you to do?

mui_ume
2019-06-17 11:06
My own accord I feel the need for pact To complement unit testing and end to end testing As I see it?s benefits that pact will bring to the team

mui_ume
2019-06-17 11:06
I will study jest myself first and see how to go from there

matt.fellows
2019-06-17 11:16
That's awesome!

matt.fellows
2019-06-17 11:18
See if you can get a basic unit test in, and then add in Pact

matt.fellows
2019-06-17 11:18
You might want to jump in #pact-js to get more specific support

mui_ume
2019-06-17 11:34
thanks for directing Matt

phall
2019-06-17 13:26
Fantastic! That sounds like a plan.

drambhia
2019-06-17 15:12
has joined #general

harryzhu2011
2019-06-17 23:58
has joined #general

agarwalatrisha1212
2019-06-18 03:15
has joined #general

arturs.savickis
2019-06-18 03:24
has joined #general

tuan.ho
2019-06-18 03:26
has joined #general

dalsidhu99
2019-06-18 10:50
has joined #general

goncalo
2019-06-18 12:51
has joined #general

christopher.f.almanza
2019-06-18 20:12
Do `@pact-foundation/pact-js` support registering a `GET` interaction that contains a Request body?

bxj231
2019-06-18 21:07
has joined #general

matt.fellows
2019-06-18 21:13
It may, but that is a bit strange (not an RFC standard)

clang1
2019-06-18 22:52
has joined #general

abubics
2019-06-18 23:34
Also, heaps of libraries don't support it, so it has portability issues.

mboudreau
2019-06-18 23:41
@christopher.f.almanza why are you doing such a thing?

mboudreau
2019-06-18 23:41
let me guess, trying to get around a CORS issue? :stuck_out_tongue:

abubics
2019-06-18 23:47
The times I thought I wanted to do that, it was often for a complex query that query params couldn't represent well

abubics
2019-06-18 23:48
but then I changed my resource model (and mental model) to represent searches as resources, so POST made even more sense

david.j.smith
2019-06-18 23:50
Default to doubles, it?s the only accurate thing to do. :slightly_smiling_face: Could add to the spec (who knows maybe we?ll even support it one day!) or have implementation specific matchers to add precision, but it wouldn?t work across language boundaries as there?s no guarantee that, say, Scala and Ruby would have those same ?extra? matchers implemented. Still handy for services talking to each other that are built in the same language. Scala-Pact has a whole different matching approach that none of the others support, and I think Pact-JVM has about a million matchers we don?t have - no problem in general - you just have to be careful interfacing with Pact files coming from other sources and stick to the spec at the boundaries of your estate.

christopher.f.almanza
2019-06-19 14:31
Hey guys! We just had a GET endpoint that expected a body. I know this is non-standard and hacky and just bad design, but I needed to give some solid reason about why it shouldn't be like that. I couldn't find the RFC at that moment Luckily, the backend engineer found the RFC for both `fetch` and `XMLHttpRequest`, where it specified that there should be no body on a GET request body, so the endpoint is now using query params as it should

james.reynolds
2019-06-19 14:44
has joined #general

james.hattersley-dyke
2019-06-19 15:30
Hi, might be a daft question I don't know. But someone on my team was asking if we could make Pact part of our service-template because each service by default exposes a /version and a /health endpoint which returns JSON - I'm think it wouldn't add a great deal of value to contract test these because it'd essentially be the same codebase being consumer and provider. What do people think?

james.carman
2019-06-19 15:38
That doesn?t sound like a big value-add to me. We have the same sort of thing, but it?s provided by the Spring Boot Actuator. We don?t do pacts for it

james.hattersley-dyke
2019-06-19 16:34
yeah I'm thinking it's kinda pointless. The only benefit would be that pact tests are there as a starting point right off the bat.

craig.pothier
2019-06-19 19:15
has joined #general

craig.pothier
2019-06-19 19:50
hello, super new to Pact. I've went through a lot of docs, and post but I am having a difficult time understanding how to use this with Lambda functions. I saw the examples on the pact-js github repo and but cant figure something out. I have 2 microservices. They are both lambda, lets call them lambda 1 and lambda 2. Lambda 1 directly invokes lambda 2 and waits for response from the lambda function. To me its almost like Rest API call with request and response but I cant figure out how to do this with Pact and lambda. Anyone have any ideas around this? I think the pact server mock would not work in this case right?

matt.fellows
2019-06-19 22:21
I?m surprised this hasn?t come up earlier

matt.fellows
2019-06-19 22:21
In short, the ?messaging? feature of Pact doesn?t support request/response style messages

matt.fellows
2019-06-19 22:21
cc: @bethskurrie because we were talking about this the other day

matt.fellows
2019-06-19 22:22
That would be the main benefit I see also. You could do it, but it seems like needless overhead. The other would be that the documentation in the broker (if you?re using one) would make it clear to all that those endpoints exist

matt.fellows
2019-06-19 22:23
Funny that I?ve never really had to do that in the wild, most of my lambda invocations are either a) async (fire and forget) or b) behind an API Gateway

matt.fellows
2019-06-19 22:23
If you would kindly raise a feature request on the Pact JS repository that will help it get the attention it deserves


craig.pothier
2019-06-19 22:44
Can you think of any work arounds for this? Should I create my own AWS lambda mock on the consumer side to do this?

craig.pothier
2019-06-19 22:44
Also, thanks for the response above.

craig.pothier
2019-06-19 22:45
Im also unsure what the point of the consumer mock is. It seems weird to me. Is it much faster than writing the pact file by hand? i know im obviously missing something

matt.fellows
2019-06-19 23:13
So in a normal integration test, you would test that your code is able to send messages and handle the response from the system you?re testing against. This implicitly tests a bunch of things, but importantly you can feel comfortable that _your consumer code_ is able to send messages in the right format, and handle the response properly.

matt.fellows
2019-06-19 23:13
(seems obvious)

matt.fellows
2019-06-19 23:16
But now that we aren?t going to be testing the actual provider service directly, we need a way to do two things: 1. Test that your consumer code is able to send messages in the correct format, and properly handle the response (probably into some internal model) 2. Capture the contract as a side effect of this, so we can share it with the provider If you write the pact file by hand, you can?t guarantee (1). You also can?t be sure that (2) doesn?t drift from reality (because your code isn?t being executed). At this point, you might as well just use a static document (like Swagger/JSON Schema), but you can?t convince yourself that your code (and the providers? code) is compatible with it

craig.pothier
2019-06-19 23:18
gotcha!! makes sense. Thanks a bunch for that. Its helpful for me to understand

matt.fellows
2019-06-19 23:24
I _think_ you might be able to do it by writing two separate message tests: one on the consumer side and one from the provider side. But I can see challenges with that approach. Alternatively, you could create a small wrapper that allows you to write an HTTP-style Pact, but filter out the http stuff

matt.fellows
2019-06-19 23:24
@uglyog how do you do this in Pact JVM?

uglyog
2019-06-19 23:31
Invoke lambda is just an HTTP POST request via the AWS lambda service, so either do it as a regular HTTP request/response, or test it at a higher level (as you mentioned) as two message flows

uglyog
2019-06-19 23:32
Looks like we need to bump up our thinking about synchronous messages

matt.fellows
2019-06-19 23:33
yep

matt.fellows
2019-06-19 23:35
Invoking Lambda in the HTTP Post sense is clever, albeit most libraries abstract away that level of detail so would make the testing obscure and detract from some of the nice abstractions lambda gives you. +1 to req/res messages!

bethskurrie
2019-06-19 23:35
We're just going to have to do something messy with the pact spec version

matt.fellows
2019-06-19 23:35
We have all of the infrastructure in place, we lack :timer_clock:

bethskurrie
2019-06-19 23:35
Technically, it should be easy

matt.fellows
2019-06-19 23:35
mmm

abubics
2019-06-20 00:19
If your consumer uses structured data from the health endpoint for something meaningful (e.g. showing status of upstream services, or whatever) then you should have contract tests :slightly_smiling_face: if not, then it doesn't need to be in the contract

alat
2019-06-20 09:48
has joined #general

craig.pothier
2019-06-20 14:18
@uglyog do you happen to have any examples of how you accomplish executing lambda over http post?

closenet.uk
2019-06-20 14:44
has joined #general

uglyog
2019-06-20 22:24
No, I haven?t done it myself. I was only saying it is possible to do.

oswald.quek
2019-06-21 11:12
For a pact with multiple provider states (https://github.com/pact-foundation/pact-specification/tree/version-3#allow-multiple-provider-states-with-parameters), is it possible to specify the ordering in which they are applied at the provider contract testing side?

kevin.meiresonne
2019-06-21 11:14
What's your use case for requiring this? Your provider should be able to deal with any interaction independently, regardless of the order in which they are executed

bethskurrie
2019-06-21 11:18
If you need to rely on the ordering, then either pact is not the right tool for your use case, or you're not using it the way it's meant to be used.

oswald.quek
2019-06-21 11:19
the use case is that a consumer needs to get a Payment from our system, but some fields won't be populated until some confirmatory action has taken place. so it'd be nice to specify the test cases for *Get Payment from Provider* _Provider states_: 1) a payment exists *Get Payment from Provider with bank reference* _Provider states_: 1) a payment exists 2) the payment has a reference and unique id from bank

oswald.quek
2019-06-21 11:19
there are obvious workarounds but i was just wondering whether it were possible to order states

oswald.quek
2019-06-21 11:20
it'd be nice to reuse the "1) a payment exists"

bethskurrie
2019-06-21 11:20
Each interaction is meant to be executed independently of all the others, so that you don't get into the situation where the success of one interaction depends on the success a previous one.

bethskurrie
2019-06-21 11:20
The provider state should set up everything that's needed before hand

kevin.meiresonne
2019-06-21 11:20
it's up to your provider state to setup all that's needed for that interaction. You could have some helper classes to check if "Payment exists", and just call those in each provider state that needs them

kevin.meiresonne
2019-06-21 11:21
you don't want to end up in a situation where changing/removing one interaction can break other interactions

oswald.quek
2019-06-21 11:23
that's potentially an issue but I then wonder why allow multiple provider states in a pact then

oswald.quek
2019-06-21 11:24
cool that's ok

oswald.quek
2019-06-21 11:24
pact is still the right tool, i just need to use one state to set up everything

kevin.meiresonne
2019-06-21 11:24
well, that's easy: you can have multiple outcomes to a single call. Typically you cover those with multiple states

oswald.quek
2019-06-21 11:24
i was thinking about re-using code for the state setup at the provider end

bethskurrie
2019-06-21 11:24
You can reuse it under the hood.

bethskurrie
2019-06-21 11:25
I always create a "test data builder" that I call out to from the provider state handler code

kevin.meiresonne
2019-06-21 11:26
Indeed, so do we

oswald.quek
2019-06-21 11:26
i don't follow. there is only one response in a pact, never multiple responses.

james.carman
2019-06-21 11:27
@oswald.quek are you verifying your pacts against a live, running system?

oswald.quek
2019-06-21 11:27
no, of course not!

james.carman
2019-06-21 11:27
ok, just making sure :slightly_smiling_face:

oswald.quek
2019-06-21 11:27
:slightly_smiling_face:


james.carman
2019-06-21 11:28
The way I typically handle the data setup is very similar to (and is implemented by) training a mock object.

bethskurrie
2019-06-21 11:28
Damn, I didn't need all that code slack!

james.carman
2019-06-21 11:29
So, you?re saying you want to basically use multiple state setups at the same time (with parameters)?

bethskurrie
2019-06-21 11:29
In v3 you can have multiple provider states.

bethskurrie
2019-06-21 11:30
To help break up the test data set up, and be more specific.

bethskurrie
2019-06-21 11:30
I think Kevin is talking about testing different scenarios by having a different provider state per interaction.

bethskurrie
2019-06-21 11:31
In v3 you can do this.

bethskurrie
2019-06-21 11:32
But it's not fully supported in the ruby impl yet, simply because time.

bethskurrie
2019-06-21 11:32
I think I know someone who could help add it though.

james.carman
2019-06-21 11:33
okay, reading it back now. The main thing is that the ordering is needed.

james.carman
2019-06-21 11:33
?is it possible to specify the ordering in which they are applied?

bethskurrie
2019-06-21 11:33
Oooh!

bethskurrie
2019-06-21 11:34
Right. I misunderstood.

james.carman
2019-06-21 11:34
No, you answered about the ordering. I misunderstood :slightly_smiling_face:

bethskurrie
2019-06-21 11:34
They should be applied in the order in which they were defined. Are they not?

james.carman
2019-06-21 11:34
Or, more likely, didn?t pay attention

james.carman
2019-06-21 11:35
I like the idea of having a larger state setup method and letting it reuse the other bits under the hood, as you suggested.

oswald.quek
2019-06-21 11:35
>To help break up the test data set up, and be more specific I think this was what i was trying to achieve. For example I want to achieve a state of "account with id x exists and a payment with id y exists". At the moment I'd have ``` "providerStates": [ { "name": "account and a payment exists", "params": { "account_id": "x, "payment_id": "y" } } ]``` but I wouldn't be able to separate that out into ```"providerStates": [ { "name": "account exists", "params": { "account_id": "x } }, { "name": "payment exists", "params": { "payment_id": "y" } } ]``` because the payment needs to have an associated account with it

bethskurrie
2019-06-21 11:36
Sorry @oswald.quek I thought you were talking about interaction order, not provider state order.

james.carman
2019-06-21 11:36
@oswald.quek you?re putting this stuff in a database?

oswald.quek
2019-06-21 11:36
oh i just looked at all this just now! :smile:

james.carman
2019-06-21 11:36
hence the referential integrity issues?

bethskurrie
2019-06-21 11:37
@oswald.quek what verifier language are you using?

oswald.quek
2019-06-21 11:37
at the provider side, java

oswald.quek
2019-06-21 11:38
i assumed provider states are applied randomly but now i need to double check

james.carman
2019-06-21 11:38
I would think, since it?s a list, that if it?s not ordered properly, that?s a bug

bethskurrie
2019-06-21 11:38
OK, I totally understand the issue now, and it's something I'd wondered about but hadn't had someone ask about it

bethskurrie
2019-06-21 11:38
We need to be able to pass all the states at once into the provider state handler not one at a time

bethskurrie
2019-06-21 11:39
Is that the issue/solution?

james.carman
2019-06-21 11:39
No, he wants to set up multiple states

oswald.quek
2019-06-21 11:39
yes

james.carman
2019-06-21 11:39
But, the states refer to each other, so they need to be set up in a specific order

james.carman
2019-06-21 11:40
For (what appears to be) referential integrity constraints

james.carman
2019-06-21 11:40
So, the account needs to be in the account table before the payment can be inserted into the payment table with a foreign key to the account table

bethskurrie
2019-06-21 11:40
Yes, but there was one giant provider state setter upper that took the entire list at once, it could decide how to set up the data.

james.carman
2019-06-21 11:40
I believe I have that ordering right :slightly_smiling_face:

james.carman
2019-06-21 11:41
Right, if there was an uber state setter upper, that?d work too

bethskurrie
2019-06-21 11:41
I think the problem is that each state is set up separately, and they lose context.

james.carman
2019-06-21 11:41
you?d just pass in a larger structure of data and it?d know how to do the right thing

bethskurrie
2019-06-21 11:41
Yes.

james.carman
2019-06-21 11:42
@oswald.quek was just hoping to reuse/compose these states from the outside I believe

oswald.quek
2019-06-21 11:42
yup

james.carman
2019-06-21 11:42
Rather than having to work with the provider team to add new state setter upper mechanisms

bethskurrie
2019-06-21 11:42
Perhaps we can have a flag for it, so that you could either do them one at a time (existing behaviour) or have an all in one handler (if toggled on).

bethskurrie
2019-06-21 11:43
Hm. Tricky.

james.carman
2019-06-21 11:43
in this case, the states don?t require data from one another. The account id is fully specified in the pact

oswald.quek
2019-06-21 11:43
it's not that big an issue though :smile: i was just wondering if it were possible.

james.carman
2019-06-21 11:43
I guess the big question is, ?are the state definitions executed in order during verification by the provider??

james.carman
2019-06-21 11:44
Does that sum it up?

bethskurrie
2019-06-21 11:44
Yes

james.carman
2019-06-21 11:44
I don?t think that?s a terrible idea, to support that

bethskurrie
2019-06-21 11:44
They are executed in order of definition

james.carman
2019-06-21 11:44
Yeah, that would be the most intuitive outcome

james.carman
2019-06-21 11:44
So, sounds like you can do what you want, @oswald.quek

oswald.quek
2019-06-21 11:45
yup i can confirm they aren't executed in order of definiton

oswald.quek
2019-06-21 11:45
i've just tested it

james.carman
2019-06-21 11:45
Then that?s a bug

bethskurrie
2019-06-21 11:45
@uglyog?

james.carman
2019-06-21 11:45
I?d ping the #pact-jvm channel

bethskurrie
2019-06-21 11:45
This is news to me. Ruby impl does them in order of definition.

oswald.quek
2019-06-21 11:46
ah :slightly_smiling_face:

oswald.quek
2019-06-21 11:46
i'll raise a github issue too

viktor
2019-06-21 11:46
has joined #general

bethskurrie
2019-06-21 11:46
Sorry, we should stop spamming general. I hadn't realised we'd gone off the thread.

oswald.quek
2019-06-21 11:46
i didn't realise there was a #pact-jvm channel! my bad

james.carman
2019-06-21 11:46
There?s certainly something off, then


james.carman
2019-06-21 11:47
The model for the pact indeed stores them as an ordered list. Perhaps it reads them first into a set or something and converts to a list, which would jumble them

james.carman
2019-06-21 11:47
Likely a very simple fix

bethskurrie
2019-06-21 11:47
:thinking_face:

bethskurrie
2019-06-21 11:47
Ron will know.

james.carman
2019-06-21 11:47
indeed

bethskurrie
2019-06-21 11:50
We used to have a German textbook at school where one of the phrases was "mecki weiss alles".

bethskurrie
2019-06-21 11:50
Ron weiss alles!

rakesh_patel
2019-06-21 13:37
has joined #general

rakesh_patel
2019-06-21 14:28
@bethskurrie I am taking over from Allegra from Vanguard

rakesh_patel
2019-06-21 14:30
Does anyone know of the default log file location for broker? wanted to investigate why our broker app went down

nathan2oo3
2019-06-21 14:55
has joined #general

jemmawells
2019-06-21 15:54
has joined #general

craig.pothier
2019-06-21 16:23
Can someone help me troubleshoot some code?

craig.pothier
2019-06-21 16:24
trying to get verify the results from a lambda invoke to a PACT file

craig.pothier
2019-06-21 16:27
the lambda returns results that I then compare against the generated PACT file. The error is as follows: ``` Actual: {"statusCode":200,"body":{"platform":"test","targetId":"default","version":"4.2.2.3259","upgradeUrl":"http://test.com/test.img","upgradeNow":true}} Diff -------------------------------------- Key: - is expected + is actual Matching keys and values are not shown -{ - "statusCode": 200, - "body": { - "platform": "test", - "targetId": "default", - "version": "4.2.2.3259", - "upgradeUrl": "http://test.com/test.img", - "updateNow": true - } -} +{"statusCode":200,"body":{"platform":"test","targetId":"default","version":"4.2.2.3259","upgradeUrl":"http://test.com/test.img","upgradeNow":true}} Description of differences -------------------------------------- * Expected a Hash (like {"statusCode"=>200, "body"=>{"platform"=>"test", "targetId"=>"default", "version"=>"4.2.2.3259", "upgradeUrl"=>"http://test.com/test.img", "updateNow"=>true}}) but got a String ("{\"statusCode\":200,\"body\":{\"platform\":\"test\",\"targetId\":\"default\",\"version\":\"4.2.2.3259\",\"upgradeUrl\":\"http://test.com/test.img\",\"upgradeNow\":true}}") at $```

craig.pothier
2019-06-21 16:27
I can share the code if it helps too

phall
2019-06-21 17:23
Just from reading the error message, it seems to be expecting an object, but is receiving a string. i.e. the difference between ``` { "statusCode": 200 } ``` and ``` "{ \"statusCode\": 200 }" ``` As to the fix? It?s very much dependent on your code. It may be as easy as parsing the string to JSON, but that?s just speculation.

cristiano
2019-06-21 17:31
has joined #general

craig.pothier
2019-06-21 18:08
yeah, i've been trying to deal with that. Im pasting the code here in case someone sees something that i dont. import { MessageProviderPact} from '@pact-foundation/pact'; import * as path from 'path'; import * as AWS from 'aws-sdk'; const lambda = new AWS.Lambda({ region: 'us-west-1' }); async function calllambda() { const params: any = { FunctionName: 'softwareUpdate-stage-getSoftwareVersion', InvocationType: 'RequestResponse', LogType: 'Tail', Payload: '{ "platform": "test", "groupUuid": "d658c575-b359-41bc-829e-7b00aef6fafd", "serialNumber": "KQ6931091B3B7", "extension": "254266" }' }; try { const response = await lambda.invoke(params).promise(); const responsePayload: string = JSON.stringify(response['Payload']); return JSON.parse(responsePayload); } catch(err) { console.log(err) return err } } describe("Message provider tests", () => { const p = new MessageProviderPact({ messageProviders: { "a request to save an event": () => calllambda() }, logLevel: "warn", provider: "services.softwareUpdate", providerVersion: "1.0.0", consumer: "services.checkin", pactUrls: [path.resolve(process.cwd(), "./src/tests/pacts", "services.checkin-services.softwareupdate.json")], tags: ["latest"], }) describe("send an event", () => { it("sends a valid event", () => { return p.verify() }) }) })```

yousafn
2019-06-21 19:50
You are expecting updateNow but your receiving upgradeNow

craig.pothier
2019-06-21 19:52
wow

craig.pothier
2019-06-21 19:52
haha

craig.pothier
2019-06-21 19:53
thank you!

yousafn
2019-06-21 19:55
Also you may not need return json.parse(responsePayload) and just return the stringified payload. Not sure where in your code, it specifies updateNow, unless that?s in a diff file?

craig.pothier
2019-06-21 19:55
it comes from the PACT file that was generated from the consumer side

yousafn
2019-06-21 19:55
I?ve been testing lambdas, but they are invoked via api gateway

yousafn
2019-06-21 19:55
Ahhh right! Hopefully it?s just that then :raised_hands:

craig.pothier
2019-06-21 19:56
yeah, i wish our application would be invoking them through the API gateway. Current version of PACT doesnt play nicely with lambdas that are invoked in request/response format

yousafn
2019-06-21 19:59
Ahhhh that?s the verifier code, Peter might be correct with regards to the hash/string thing, if you update your pact file to have upgradeNow in it and that doesn?t match then you probably don?t need json.parse and just return the json.stringify, and then work out who is wrong with regards to updateNow/upgradeNow. Best of luck homie

craig.pothier
2019-06-21 20:01
thank you very much

yousafn
2019-06-21 20:02
Any time mate, let us know how you get on :)

dar
2019-06-21 23:45
has joined #general

dar
2019-06-21 23:54
Lack of research: Has anybody succeeded in implementing pact for SOAP Api? Where could I go looking for such?

bethskurrie
2019-06-21 23:54
pact-jvm supports XML matching

bethskurrie
2019-06-21 23:55
no other impls do yet

dar
2019-06-21 23:55
oh :disappointed: Ok, I still can learn things...

dar
2019-06-21 23:57
Thanks!!!

matt.fellows
2019-06-22 03:27
What language are you using?

thakkarjinal29
2019-06-22 12:02
Hello, was wondering if someone could help me with how can to tag a provider. I want to tag my provider with the feature branch it?s been developed on. I checked the `pact-provider-verifier` doc, but I could not find it there. I know that we can make a `PUT` request on the pact-broker and set the tag, but was looking to do this during the verification process. Thanks!

thakkarjinal29
2019-06-22 12:54
Ahh.. missed the `pact-broker create-version-tag`! Got it!

thakkarjinal29
2019-06-22 14:22
I am trying to create webhook via `pact-broker create-webhook` and getting an error saying `require': cannot load such file -- pact/hal/entity (LoadError)` Here?s the entire command ``` pact-broker create-webhook "https://circleci.com/api/v1.1/project/bitbucket/xyz/xyz/tree/JT-AUT-92-pact-poc?circle-token=<token>" -X POST -H Content-Type=application/json -d build_parameters[CIRCLE_JOB]=my_job --consumer con --provider pro --broker-base-url https://x.pact.dius.com.au --broker-token <token> --provider-verification-published -v ```

thakkarjinal29
2019-06-22 14:23
Here?s the complete stacktrace: ``` /Users/jinal/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- pact/hal/entity (LoadError) from /Users/jinal/.rvm/rubies/ruby-2.2.5/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/hal/link.rb:61:in `wrap_response' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/hal/link.rb:49:in `post' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/webhooks/create.rb:41:in `create_webhook_with_consumer_and_provider' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/webhooks/create.rb:30:in `call' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/webhooks/create.rb:17:in `call' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/cli/broker.rb:165:in `create_webhook' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/lib/pact_broker/client/cli/custom_thor.rb:15:in `start' from /Users/jinal/.rvm/gems/ruby-2.2.5/gems/pact_broker-client-1.18.0/bin/pact-broker:4:in `<top (required)>' from /Users/jinal/.rvm/gems/ruby-2.2.5/bin/pact-broker:23:in `load' from /Users/jinal/.rvm/gems/ruby-2.2.5/bin/pact-broker:23:in `<main>' from /Users/jinal/.rvm/gems/ruby-2.2.5/bin/ruby_executable_hooks:15:in `eval' from /Users/jinal/.rvm/gems/ruby-2.2.5/bin/ruby_executable_hooks:15:in `<main>' ```

thakkarjinal29
2019-06-22 14:24
Also (sorry for back to back messages), is there a way to use `Dynamic variable substitution` for webhooks using `pact-broker create-webhook` ?

pact.io
2019-06-22 16:08
I wanna try to implement a new matcher to pact-php. For example the minmax matcher. As far as I understand it is something like ``` "matchingRules": { "body": { "$.values": { "matchers": [{"match": "type", "min": "1", "max": "1"}] }, } } ``` However the json file or the payload send to the ruby mock server seems to have some other format. I don't really understand how that works and what I should do. Do you have an example for the json file and the message that shall be send to POST /interactions?

shefeeque85
2019-06-22 18:53
has joined #general

matt.fellows
2019-06-23 00:03
The Ruby mock service doesn't support this yet I'm afraid

matt.fellows
2019-06-23 00:03
That is a v3 specification matcher, which Ruby does not yet support

luchillo17
2019-06-23 00:48
Hey guys anyone has any idea why my Pact tests fails only in desktop PCs?

mboudreau
2019-06-23 01:15
It's trying to use the Linux binary in windows, that's why. Did someone commit the node_modules folder?

luchillo17
2019-06-23 01:16
No, node modules is ignored by default on project creation, so no. I think most likely is because i'm using WSL.

mboudreau
2019-06-23 01:18
Yep, that's exactly why. Wsl is really crap cause it identifies as Linux, but doesn't work like Linux :/

luchillo17
2019-06-23 01:32
I'm running with powershell & worked like a charm.

luchillo17
2019-06-23 01:32
Thanks, shame i had to install node again.

mboudreau
2019-06-23 02:38
Yeah, I tried getting it working with wsl, but there's nothing in there to say that it's running inside wsl as far as I can tell unless Microsoft changed something. When I first implemented it, wsl just got out

mboudreau
2019-06-23 02:40
I'm not a windows expert myself (Linux guy) but if you can find a variable in wsl that we can use to identify it, that'd be great

pact.io
2019-06-23 07:32
Alright. I understand that. Do you know which of the points mentioned in the below list are worth implementing currently? https://github.com/pact-foundation/pact-php/issues/29#issuecomment-504624662

thakkarjinal29
2019-06-23 12:42
Could someone help with this please?

thakkarjinal29
2019-06-23 12:42
Does anyone have any idea about this one?

jemma.wells
2019-06-23 20:04
has joined #general

abubics
2019-06-23 23:52
You might start getting replies now :slightly_smiling_face: The local time for most of the maintainers is almost 10am now, and your messages were all around midnight over the weekend :stuck_out_tongue:

thakkarjinal29
2019-06-24 05:13
Hehe thanks, will wait :slightly_smiling_face:

mstalmasek
2019-06-24 09:54
has joined #general

sankalan13
2019-06-24 11:50
@bethskurrie @matt.fellows please help. :slightly_smiling_face:

bethskurrie
2019-06-24 11:51
Yes, you just put them in.

bethskurrie
2019-06-24 11:53
There's no trick. You just put `${pactbroker.pactUrl}` or whatever into the body or params where you want it to be substituted.

steve637
2019-06-24 12:09
has joined #general

sankalan13
2019-06-24 14:05
Thanks @bethskurrie will try this out. :slightly_smiling_face: @thakkarjinal29 FYI :slightly_smiling_face:

shefeeque85
2019-06-24 16:25
Hello...Just trying my luck here..Iam doing a poc to implement pact in my project..

shefeeque85
2019-06-24 16:25
I have the following classes:- public class Student { private String id; private String firstName; private String lastName; private int age; } public class DepartmentResponse { private String id; private String name; List<Student> students; } At Consumer side, I have the LamdaDsl as below: @Pact(consumer = "StudentServiceConsumer1") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap(); headers.put("Content-Type", "application/json"); final DslPart actualPactDsl = LambdaDsl.newJsonBody((bodyDsl) -> { bodyDsl .stringType("id", "1") .stringType("name","Dep 1") .array("students",(stud) ->{ stud.object((s1->{ s1.stringType("id","1") .stringType("firstName","John") .stringType("lastName","Smith") .numberType("age",21); })); }); }) .build(); return builder .given("Department 1 exist") .uponReceiving("A request for DepartmentResponse Object with Id 1") .path("/department/1") .method("GET") .willRespondWith() .status(200) .headers(headers) .body(actualPactDsl).toPact(); } So in the pact file generated, I will have only one student record. Now, in the Provider side, with the id as "1", it will give two student records, sample code below:- public DepartmentResponse getDepartmentById(String id){ Student student1 = new Student(); student1.setId("1"); student1.setAge(23); student1.setFirstName("John"); student1.setLastName("Smith"); Student student2 = new Student(); student2.setId("2"); student2.setAge(21); student2.setFirstName("Adam"); student2.setLastName("Zamba"); DepartmentResponse department = new DepartmentResponse(); department.setId(id); department.setName("Dep 1"); department.setStudents(Arrays.asList(student1,student2)); return department; } Now when I run the pact verifier, it fails as it says there are 2 student records in the provider response. java.lang.AssertionError: 0 - $.students -> [{mismatch=Expected a List with 1 elements but received 2 elements, diff= { + "id": "1", "firstName": "John", "lastName": "Smith", - "id": "1", + "age": 23 + }, + { + "id": "2", + "firstName": "Adam", + "lastName": "Zamba", "age": 21}]

shefeeque85
2019-06-24 16:26
So what I need is, if there is a List in the response object, pact verifier should check only for the first instance

shefeeque85
2019-06-24 16:27
either lambda or the old way is fine for me

craig.pothier
2019-06-24 17:31
trying to publish pacts using typescript but Im getting the following error. Anyone have any ideas? Works if I change import state to require and run as js.

matt.fellows
2019-06-24 22:22
I think you need to change the import to `import pact from "@pact-foundation/pact-node"`

chris.maki
2019-06-25 03:12
has joined #general

thakkarjinal29
2019-06-25 05:39
Thanks @bethskurrie and @sankalan13. I did try that but there are 2 issues. 1. One is that `{pactbroker.providerVersionTags}` is returning empty, although I have tagged my provider. 2. I?m getting a `kernel_require.rb:54:in `require?: cannot load such file -- pact/hal/entity (LoadError)` error (Attaching screenshot)

matt.fellows
2019-06-25 06:02
Hmm I think the `401` is the real problem. Looks like the credentials aren?t going through to the broker maybe? Or perhaps it?s an incorrect bearer token

matt.fellows
2019-06-25 06:02
P.S. you exposed your circle CI token. You?ll want to deactivate that

thakkarjinal29
2019-06-25 06:03
Oops! Thanks! :shocked_face_with_exploding_head:

thakkarjinal29
2019-06-25 06:04
Hmm, the bearer token seems to be working for all other commands. But will still check, thanks! Any idea why `{pactbroker.providerVersionTags}` would be empty inspite of tagging the provider version?

matt.fellows
2019-06-25 07:52
Are you missing the `$` in front of that? i.e. `${pactbroker.providerVersionTags}`

bethskurrie
2019-06-25 08:00
@thakkarjinal29 there are a few libraries that incorrectly tag after publishing the pact or results instead of before. What are you using?

bethskurrie
2019-06-25 08:03
Also do you have the latest version of whatever you are using? The token auth support has only been added recently.

bethskurrie
2019-06-25 08:03
I assume you've removed the screenshot, because I can't see it

thakkarjinal29
2019-06-25 08:03
hey @bethskurrie, used `pact-broker create-version-tag`to tag the provider version

thakkarjinal29
2019-06-25 08:08
Hey @matt.fellows, when I use it with *$* in the commandline, it says `${pactbroker.providerVersionTags}: bad substitution`. Hence, was trying without it. However, it works fine from the UI, however even there it returns an empty string.

bethskurrie
2019-06-25 08:08
Ooh, you may be hitting problems with your shell interpolating the dollar sign.

bethskurrie
2019-06-25 08:11
Also, it looks like the token isn't being passed though. I can't see an authentication header being set.

bethskurrie
2019-06-25 08:11
Can you raise an issue in the pact broker client project?

thakkarjinal29
2019-06-25 08:12
Yes this was my next question :slightly_smiling_face: Sure, will do that right away

bethskurrie
2019-06-25 08:14
From memory, when I've created webhooks using this command I've used a file for the webhook json, so it avoids the bash interpolation issue.

thakkarjinal29
2019-06-25 08:14
I am using `pact-broker` utility of pact-ruby-standalone. The version of pact-broker utility is 1.18.0

thakkarjinal29
2019-06-25 08:16
I escaped the *$* and the command works fine. But yes, using a file makes more sense. Thanks, will do that!

matt.fellows
2019-06-25 08:20
Yep. I Verifies the token wasn't coming thru on the train and started investigating

matt.fellows
2019-06-25 08:20
Verified*

thakkarjinal29
2019-06-25 08:23
I am using the pact-ruby-standalone version 1.66.0 and the latest is 1.68.0 however, the `pact_broker-client gem` version in both is `1.18.0`

bethskurrie
2019-06-25 09:14
Ok, I've just put out a fix to the pact broker client in the standalone 1.69.0

bethskurrie
2019-06-25 09:14
the token should work now @thakkarjinal29

thakkarjinal29
2019-06-25 09:22
Wow that was quick! Thanks @bethskurrie @matt.fellows!


detert
2019-06-25 10:15
My pact verification shows this error: What am I doing wrong? * Expected a String matching /\d{1,2}/ (like "11") but got a Fixnum (12) at $.creditCards[0].detail.validToMonth * Expected a String matching /\d{4}/ (like "2019") but got a Fixnum (2020) at $.creditCards[0].detail.validToYear

bethskurrie
2019-06-25 10:18
You're expecting a sting, but getting a number

bethskurrie
2019-06-25 10:18
You can't do a regex on a number btw.

detert
2019-06-25 11:03
Oh, that is a surprise. Can i Match on exactly one or two digots?

bethskurrie
2019-06-25 11:03
Ni

bethskurrie
2019-06-25 11:03
No

bethskurrie
2019-06-25 11:04
Why is that important for a contact?

bethskurrie
2019-06-25 11:04
Oh, I see you have a month and a year.

detert
2019-06-25 11:04
Well I want to ensure that a valid month is returned, but maybe that is not part of the contract?

bethskurrie
2019-06-25 11:05
What might be important is whether it's a two digit year or a 4 digit year. Unfortunately, there's no way to check that, in v2 at least.

bethskurrie
2019-06-25 11:05
V3 might have Min and Max

detert
2019-06-25 11:06
That might be worth a feature request. Where should I write such an issue?

bethskurrie
2019-06-25 11:06
Check if it already exists in v3

bethskurrie
2019-06-25 11:06
In the pact specification repo

detert
2019-06-25 11:08
I don't see it at the first look. Maybe we could extend `{ "match": "integer" }` with `digits` or something like that, or we allow regex for digits as well

bethskurrie
2019-06-25 11:09
Raise an issue for it

detert
2019-06-25 11:09
The Generators are able to provide a specified amount of digits

detert
2019-06-25 11:09
thank you

bethskurrie
2019-06-25 11:10
Or, if you're in control of the schema, you could try changing the date to an ISO date format string.

bethskurrie
2019-06-25 11:10
You can do a regex on that.

bethskurrie
2019-06-25 11:11
Oh, just scrolled up and its a credit card expiry.

bethskurrie
2019-06-25 11:11
I see your issue.

detert
2019-06-25 11:11
I will use like(11) for the beginning. I have to change a lot of stuff else

detert
2019-06-25 11:11
Yes it is

carolyn.biggar
2019-06-25 11:38
has joined #general

alessandrobuggin
2019-06-25 14:08
has joined #general

thakkarjinal29
2019-06-25 15:00
Hey @bethskurrie, I think the 1.69.0 version did not get released, I am unable to use it.

zrkann
2019-06-25 20:49
has joined #general

mail259
2019-06-25 21:27
has joined #general

mail259
2019-06-25 21:32
I'm implementing contract testing in our organization and we are driving it through the provider. As a developer, you often start writing the API first and then use them in the frontend. Similarly, we write the API first and then merge it in master and then define the contract test inside the consumer. When we need to modify something, we take the same approach by making changes in the provider ( N-1 compatible ) and then making those changes in the consumer. I read that pact should be consumer driven but I'm able to understand what's wrong about contract testing by driving it through a provider? What are the cases when this approach can go wrong?

matt.fellows
2019-06-25 22:22
I?ve just re-ran that build - looked like a temporary GitHub API issue. It?s up now at https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.69.0

matt.fellows
2019-06-25 22:32
You can do it from the provider. But (at the moment) Pact makes it a little unnatural due to the workflow assuming it starts from the consumer (for all of the reasons written extensively at https://docs.pact.io).

matt.fellows
2019-06-25 22:32
If you are using the can-i-deploy checks via the Pact Broker on the provider and ensuring backwards compatibility, you still get the usual guarantees of contract testing - i.e. that your consumers and providers are API compatible.

bethskurrie
2019-06-25 22:36
There's no reason why the functionality can't come first @mail259. Pact will just make sure that any changes you make are compatible with your existing consumers.

thakkarjinal29
2019-06-26 04:46
Awesome! Thanks :slightly_smiling_face:

andreas
2019-06-26 11:52
has joined #general

mail259
2019-06-26 13:00
Thanks for the quick response! Given that I'm using can-i-deploy checks, what am I losing out on starting the workflow from the provider ( functionality first )? I'm not sure if it is an anti-pattern and can't get clear information from the pact docs.

matt.fellows
2019-06-26 13:09
You're not losing anything, really

matt.fellows
2019-06-26 13:11
CDC is a philosophical position that advocates better internal microservices design by putting the consumers at the heart of the process. Provider driven APIs tend to think about themselves and less about how they're consumed _</gross generalization>_

matt.fellows
2019-06-26 13:11
If you didn't get that from docs we need to fix something!

mail259
2019-06-26 13:15
That completely makes sense, thanks again!

bethskurrie
2019-06-26 23:47
Peeps. Does anyone here have the scenario where an http message is sent to a service, and an async message is sent back in response?

detert
2019-06-27 06:05
@bethskurrie Maybe. What do you mean with message? We trigger an http request to a search service. That service calls another endpoint when the search is completed

sundaresank
2019-06-27 09:09
has joined #general

whitehorse5353
2019-06-27 16:54
has joined #general

oscar821210
2019-06-28 00:31
has joined #general

doxuantien
2019-06-28 02:25
has joined #general

chris.maki
2019-06-28 05:24
@bethskurrie With POST calls, I?ve implemented services where the provider returns a 201 and populates the LOCATION header so the consumer can check on the progress. Is that similar to what you are trying to do? If not, can you give a little more detail on your service?

bqiu
2019-06-28 20:18
has joined #general

matt.fellows
2019-06-29 04:15
That?s the way I usually see it implemented

matt.fellows
2019-06-29 04:24
/poll ?If we were to run a webinar series, what should we cover?? ?Getting started? ?CD with the Pact Broker? ?Asynchronous service testing? ?Cloud service testing (e.g. lambda)?

matt.fellows
2019-06-29 04:48
Cross posting from #pact-broker Looking to get involved with OSS but don?t know where to start? Here is an easy win :point_right: https://pact-foundation.slack.com/archives/C9VPNUJR2/p1561783533171100

gaurav.singh55
2019-06-30 03:43
has joined #general

nick_horne_90
2019-07-01 08:46
Hi, I am trying to write a Pact-Verifying unit test for the consumer in Java. Should I only have one test per class? I have noticed that if I have multiple tests in the class some of them fail unless I add a sleep before running my client assertions.

nick_horne_90
2019-07-01 08:47
What I have looks like this: ```@RunWith(SpringRunner.class) @SpringBootTest(properties = {}) public class ConsumerPactVerificationTest { @Rule public PactProviderRuleMk2 stubProvider = new PactProviderRuleMk2("customerServiceProvider", "localhost", 8888, this); @Autowired private AddressClient addressClient; @Pact(provider = "test") public RequestResponsePact getAddresses(PactDslWithProvider builder) { return builder .given("a collection of 2 addresses") .uponReceiving("a request to the address collection resource") .path("/addresses/") .method("GET") .willRespondWith() .status(200) .body("...", "application/hal+json") .toPact(); } @Test @PactVerification(fragment = getAddresses public void verifyAddressCollectionPact() { assertThat(addressClient.getAddresses())... } }```

dorons
2019-07-01 09:25
has joined #general

tuan.ho
2019-07-01 09:29
Hi, anyone got experience with dredd test? how is it different from PACT?

tuan.ho
2019-07-01 09:30
there two to me do the same thing which is verifying the API contract

tuan.ho
2019-07-01 09:31
am i correct?

matt.fellows
2019-07-01 09:32
Dreds issues tests against a provider based on a spec (not a contract). It doesn't guarantee that both sides of the contract are in sync. It can be used alongside pact to verify provider functionality/conformity to a spec (to a degree). Pact is a testing framework that implements contract testing (distinct from spec testing) and guarantees both parties to a contract stay in sync

matt.fellows
2019-07-01 09:32
Short answer, no they are different

dorons
2019-07-01 09:34
Hi Can I get some help with pact and protobuf?


bethskurrie
2019-07-01 09:55
Hi @nick_horne_90 best to have this conversation in the #pact-jvm channel

nick_horne_90
2019-07-01 09:59
Thanks @bethskurrie I will ask in there

raffael.stein
2019-07-01 10:54
has joined #general

deepti.kinnerkar
2019-07-01 13:44
has joined #general

deepti.kinnerkar
2019-07-01 13:47
Is there any mechanism to create some data on the Provider via pact Files, before making a GET API Call?


jfnavin
2019-07-01 22:53
has joined #general

uglyog
2019-07-01 23:53
You're HTTP library is probably caching connections. Have a look at https://github.com/DiUS/pact-jvm/issues/342 for more info

nick_horne_90
2019-07-02 15:09
Thanks that does seem to be it. Im using the Spring RestTemplate and it has stored the connection in a connection pool

karlboyle
2019-07-02 15:25
has joined #general

emanuele.ivaldi
2019-07-02 21:18
has joined #general

ur_pact
2019-07-03 15:08
has joined #general

sandhyarani.gabbi
2019-07-03 16:05
has joined #general

morteza.alizadeh
2019-07-04 03:09
has joined #general

johngluckjunk
2019-07-04 05:24
has joined #general

berlinau
2019-07-04 16:48
has joined #general

xyang2008
2019-07-05 05:48
has joined #general

xyang2008
2019-07-05 05:58
Hi

xyang2008
2019-07-05 06:00
Hi, I'am newbie to pact and now learning it by writting some demo. Now the pact contract file was generated successfully as below. { "consumer": { "name": "weather-consumer" }, "provider": { "name": "weather-provider" }, "interactions": [ { "description": "Query weather info by city id.", "providerState": "City id \"101010100\" exists", "request": { "method": "get", "path": "/101010100.html" }, "response": { "status": 200, "headers": { }, "body": { "weatherinfo": { "city": "??", "cityid": "101010100", "temp1": "18?", "temp2": "31?", "weather": "????", "img1": "n1.gif", "img2": "d2.gif", "ptime": "18:00" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }% Next I want to do the provider verification, I run the below cmd: pact-verifier --provider-base-url=http://www.weather.com.cn/data/cityinfo ./pacts/weather-consumer-weather-provider.json I got the failures. INFO: Reading pact at ./pacts/weather-consumer-weather-provider.json Verifying a pact between weather-consumer and weather-provider Given City id "101010100" exists Query weather info by city id. with GET /101010100.html returns a response which WARN: Skipping set up for provider state 'City id "101010100" exists' for consumer 'weather-consumer' as there is no --provider-states-setup-url specified. has status code 200 has a matching body (FAILED - 1) Failures: 1) Verifying a pact between weather-consumer and weather-provider Given City id "101010100" exists Query weather info by city id. with GET /101010100.html returns a response which has a matching body Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example Encoding::UndefinedConversionError: "\xE5" from ASCII-8BIT to UTF-8 1 interaction, 1 failure Failed interactions: PACT_DESCRIPTION='Query weather info by city id.' PACT_PROVIDER_STATE='City id "101010100" exists' /Library/Frameworks/Python.framework/Versions/3.6/bin/pact-verifier --provider-base-url=http://www.weather.com.cn/data/cityinfo ./pacts/weather-consumer-weather-provider.json # Query weather info by city id. given City id "101010100" exists The error "Encoding::UndefinedConversionError:" seems to be a string2json translation error? I'am confused, maybe I used the pact-verifier in a wrong way, am't I?

xyang2008
2019-07-05 06:01
pact-demo ? curl http://www.weather.com.cn/data/cityinfo/101010100.html {"weatherinfo":{"city":"??","cityid":"101010100","temp1":"18?","temp2":"31?","weather":"????","img1":"n1.gif","img2":"d2.gif","ptime":"18:00"}}%

xyang2008
2019-07-05 06:01
I use curl to check the real server response, it returns ok.

bethskurrie
2019-07-05 06:03
You can only use pact for UTF-8 strings

bethskurrie
2019-07-05 06:03
it may be that your encoding env var is set to ASCII

bethskurrie
2019-07-05 06:03
are you running on windows?

xyang2008
2019-07-05 06:03
on macos

bethskurrie
2019-07-05 06:04
hm. should be ok then

xyang2008
2019-07-05 06:04
how to set the encoding? pact-verifier is a bin file

bethskurrie
2019-07-05 06:04
is your response returning non UTF-8 chars?

xyang2008
2019-07-05 06:05
you mean the response from pact-mock server or from the real server?

bethskurrie
2019-07-05 06:05
real server

xyang2008
2019-07-05 06:06
>>> r=requests.get("http://www.weather.com.cn/data/cityinfo/101010100.html") >>> r.encoding 'ISO-8859-1'

xyang2008
2019-07-05 06:06
ISO-8859-1

xyang2008
2019-07-05 06:07
not utf-8

bethskurrie
2019-07-05 06:07
the error is occuring because the response has ascii 8 bit chars in it

bethskurrie
2019-07-05 06:07
that's not going to work.

bethskurrie
2019-07-05 06:07
JSON encoding is UTF-8

xyang2008
2019-07-05 06:08
hmm, because this is a demo, i chose a publick interface, I will try other public API who returns utf-8. Thanks.

bethskurrie
2019-07-05 06:09
@xyang2008 please don't use pact with a public API!

bethskurrie
2019-07-05 06:09
It's really bad for that.

xyang2008
2019-07-05 06:09
I alse check pact-verifier --help, no option to set encoding. this ruby tool could not support set encoding?

bethskurrie
2019-07-05 06:09
the pact files are written in utf-8

bethskurrie
2019-07-05 06:09
i just don't think it would work.

xyang2008
2019-07-05 06:09
Ok, I will test our own API

xyang2008
2019-07-05 06:10
got it


xyang2008
2019-07-05 06:13
emm.. I will read the doc carefully. before I came here, I really read all the doc https://github.com/pact-foundation, it seems the doc is not very clear to a green hand, especially lack of examples. I read the some issues and found the slack... really thanks



xyang2008
2019-07-05 06:14
@bethskurrie thanks for your replies.

xyang2008
2019-07-05 06:15
I just read the readme files:)

bethskurrie
2019-07-05 06:15
ha. yeah, that's not very helpful!

xyang2008
2019-07-05 06:16
Ok, I will read the docs you share with me, thanks.


fun_rajesh
2019-07-05 11:16
has joined #general

fun_rajesh
2019-07-05 12:27
Hi, I received a mail from with a temporoary password. However, when i signed in https://<myusername>.http://pact.dius.com.au , the credentials were not identified.

fun_rajesh
2019-07-05 12:28
May I know how to start using the pact broker hosted in the cloud by Pact team

matt.fellows
2019-07-05 12:32
Hi Rajesh. Drop a line to and we'll get it sorted

kiran.kumar.sukumar
2019-07-05 14:01
has joined #general

fun_rajesh
2019-07-05 14:06
Thanks @matt.fellows I have sent a mail to the support

kiran.kumar.sukumar
2019-07-05 15:20
How do i replace a query parameter sent from the provider ?

kiran.kumar.sukumar
2019-07-05 15:48
Is it possible to modify the query parameter in the pact when running the test from the provider side ?

agarwalatrisha1212
2019-07-06 08:31
hi

agarwalatrisha1212
2019-07-06 08:35
I sorry if it not right channel to post the question, but i am newbie to pact and i wanted to develop the consumer driven test, i have visualisation of how does pact work? but i don?t have hands on . How do i get two dependent api and start with ? A simple example as to start with or pairing with somebody? I just wanted to get the experience of simple test with handson

pact.io
2019-07-06 09:41
Well, if you grep the pact and run all verification step manually that might be possible. However, I think that that is not a good choice as you could break the significance of your test. You could use the provider state to prepare everything as needed


sumit
2019-07-07 05:27
has joined #general

agarwalatrisha1212
2019-07-07 12:26
little

agarwalatrisha1212
2019-07-07 12:26
But i am more open for handson

pact.io
2019-07-07 16:01
@agarwalatrisha1212 you can find implementation guides there

skirankumars31
2019-07-07 16:22
My provider state has no control over the ID that should be used as a query parameter. Its a dynamically generated value

pact.io
2019-07-07 16:57
Why is it random? Are you able to mick the random generator on the consumer side? Every test should be reproducable

agarwalatrisha1212
2019-07-07 18:32
Thank you @pact.io

matt.fellows
2019-07-08 03:59
What language Trisha?

matt.fellows
2019-07-08 03:59
There are a few workshops that are worth doing (linked from docs side as Sebastian mentioned)

florian.nagel
2019-07-08 07:48
has joined #general

asite.mshah
2019-07-08 09:29
has joined #general

asite.mshah
2019-07-08 09:46
One question :- Is it possible to have a different response for the same request on the consumer side? For example call `/api/abc/1` on first call want response `1` and on the second call with the same request want response `2`. Could someone let me know if it supported through pact.

detert
2019-07-08 09:49
Pact tests are isolated. Thus I would say: no. That is not intended However you can set the provider state like "noone called /api/abc/1", "someone called /api/abc/1". Out of curiosity: Why do you have that behaviour? I would not expect that

matt.fellows
2019-07-08 09:51
The main way to achieve it is thru what is known as provider states. The classic example is getting a user - at a minimum, you'll want to test the 200 and the 404 scenarios

florian.nagel
2019-07-08 09:54
Does someone here have a generated pact file for a message queue, so the v3 specification, as a reference point for me? I've found a possible bug and want to compare my pact file. I've already checked multiple online resources, but am not able to build a pact file bc of other errors. So if someone has one laying around I'd appreciate it. I don't want to open an issue before knowing if it really is one. (I haven't found any open issues or stackoverflow questions regarding the possible bug). Any help is appreciated!

florian.nagel
2019-07-08 09:56
As a reference I've tried to compile this https://github.com/DiUS/pact-jvm/blob/v4.x/consumer/pact-jvm-consumer-junit/src/test/java/au/com/dius/pact/consumer/v3/AsyncMessageTest.java project but couldn't get it to produce pacts because of an error I encountered while executing the `build` task in gradle

asite.mshah
2019-07-08 10:08
Thank you for your response. Let me explain the scenario which I am trying to use. Correct me if it is not proper. - We have two services (`a` and `b`) , when we execute acceptance test of service `a` we mock service `b` using `pact-stub-server`. - So there are calls from service a --> b, for which I need to mock. This way we use pact to return a response, without starting actual service.

florian.nagel
2019-07-08 10:31
I think it is a legit bug! I've found a pact file to compare mine to and the `contents:` value under messages looks like a normal formatted JSON. My generated pact file looks like this though: ``` ... "contents": "{\n \"hometeamScore\": 0,\n \"ownerId\": 0,\n \"foreignteamScore\": 0,\n \"matchId\": 0\n}", ... ``` when they should look like this to be recognized correctly by a pact provider test: ``` ... "contents": {"hometeamScore": 0,"ownerId": 0,"foreignteamScore": 0,"matchId": 0}, ... ``` (Omitting some of the contents/pact file bc I don't think it is relevant. Can provide more information if necessary.) Should I ask on stackoverflow and provide more information or is it sufficient to ask this here?

detert
2019-07-08 10:51
Exactly

matt.fellows
2019-07-08 11:04
Let?s give it a quick crack here, and if no-one solves it right away, get it up on SO

matt.fellows
2019-07-08 11:05
At the moment, if you are trying to get pact-stub-server to return different responses from the same request then I think the (current) answer to that question is no

matt.fellows
2019-07-08 11:06
In your tests you can, but not via the stub server (because it needs to know which state to fetch, which is only provided during unit test / framework execution)

asite.mshah
2019-07-08 11:08
Thank you for answer and explaination

matt.fellows
2019-07-08 11:11
We?d like to be able to support that feature, we just haven?t thought of a good way of ?how?

matt.fellows
2019-07-08 11:11
There?s probably an issue for it somewhere, as I recall discussion the potential to augment/amend the pact file with ?predicates? etc.

matt.fellows
2019-07-08 11:12
I usually work around it by not creating two exact requests in a Pact file. In the fictional case above I would have two tests like this: ? `GET /users/1` returns `404` ? `GET /users/2` returns `200`

matt.fellows
2019-07-08 11:12
That way acceptance test mocks work

florian.nagel
2019-07-08 11:13
Alright! I'll send the code used to produce the pact here in a sec @matt.fellows Thanks for your help!

detert
2019-07-08 11:15
I did not understand that Manan needs different response codes. For me it was like, I get a valid 200 response, but the body is different. In the case you have a different provider state. Is the stub-server able to distinguish that?

matt.fellows
2019-07-08 11:15
Well, whether it?s different response codes, bodies etc., the principle is the same

florian.nagel
2019-07-08 11:17
This is the class used to generate the pacts. The first function is the important one. That is `createPactForTippabgabe(MessagePactBuilder builder)`. It is written in Java btw. I've tried it using the old and the new DSL for Java. Both produce the same result. @matt.fellows

matt.fellows
2019-07-08 11:28
I?m not that familiar with the JVM implementation as much, but do you need to call an `.asBody()` on that builder?

florian.nagel
2019-07-08 11:31
I'm not sure what you are referring to. There is nothing coming up when I search for `.asBody()`. I'm sorry if I'm missing something. @matt.fellows

florian.nagel
2019-07-08 11:33
Ah okay. Got what you mean. Trying it out now!

florian.nagel
2019-07-08 11:35
Still the same result unfortunately. Tried to call `.asBody()` on both, the `body` and on `actualPactDsl`, so the error persists no matter which DSL I use. @matt.fellows

matt.fellows
2019-07-08 11:38
bugger, sorry - was really just a guess

matt.fellows
2019-07-08 11:38
@uglyog any ideas?

detert
2019-07-08 11:40
And the stub-server does not support that? Is it possible to spawn it several times and merge the pact files afterwards? I did not implement that yet. But I am going to do so

matt.fellows
2019-07-08 11:41
I?m not sure what you?re asking? The stub server simply reads the pact files for use as a standalone API stub service.

matt.fellows
2019-07-08 11:42
The _mock_ server (thing used in the Pact tests themselves) absolutely _does_ support it

detert
2019-07-08 11:42
My mistake

matt.fellows
2019-07-08 11:42
all good!

florian.nagel
2019-07-08 11:43
I'm using `pact-jvm-consumer-junit5 version: '4.0.0-beta.3'` and `pact-jvm-consumer-java8 version: '4.0.0-beta.3'` by the way. I don't know if that is relevant

florian.nagel
2019-07-08 11:43
No worries! @matt.fellows I appreciate the help nonetheless

asite.mshah
2019-07-08 13:45
@matt.fellows I would suggest the way mockito did to support the different responses might be good option. Sample here https://static.javadoc.io/org.mockito/mockito-core/2.8.9/org/mockito/Mockito.html#10 yeah I have used mocking with different id for a different response, but here id(request) is same.

thamu.gurung
2019-07-08 19:54
has joined #general

thamu.gurung
2019-07-08 19:56
Hi everyone ..

thamu.gurung
2019-07-08 19:58
Looking forward to use Pact js for the contract testing. Can someone pls give me some kind of initial guidelines. Would like to use JavaScript to use Pact

matt.fellows
2019-07-08 22:35
Hi there! That?s great. What have you tried so far and why weren?t they helpful?

matt.fellows
2019-07-08 22:35
this will help us point you in the right direction

matt.fellows
2019-07-08 22:35
also #pact-js

uglyog
2019-07-09 00:13
@florian.nagel both versions are technically correct. The bodies can be encoded in a string (required for non-JSON formats) but for JSON that are inlined to make the file more readable.

uglyog
2019-07-09 00:34
I've confirmed that 4.0.0-beta versions are not inlineing the message contents. You can raise an issue for that.

florian.nagel
2019-07-09 08:14
I'll try to raise an issue for that when I have time for that today. Thank you for the quick reply! @uglyog What would be the next step after raising the issue? Can I help somehow?

thamu.gurung
2019-07-09 08:28
to be honest I haven?t started yet. Wondering if I can pull the example for the JS(https://github.com/pact-foundation/pact-js) and start

thamu.gurung
2019-07-09 08:28
Now I am doing my API testing using the Supertest. But would like to get started with Pact-js

thamu.gurung
2019-07-09 08:29
Would be wonderful if you can suggest me any example repo to clone and get started initially.

beth
2019-07-09 09:37
I believe there are examples in the pact js repo @thamu.gurung

simone.dicola820
2019-07-09 11:51
has joined #general

thamu.gurung
2019-07-09 13:11
would you recommend anything in particular , thanks

antonello
2019-07-09 14:09
I?ve taken the liberty to create this PR to add my current client to the list of companies in the testimonials page https://github.com/pact-foundation/pact.io/pull/89

antonello
2019-07-09 14:11
2 of my clients and old employer are in the list :slightly_smiling_face:

thamu.gurung
2019-07-09 20:08
@beth any suggestion?

matt.fellows
2019-07-09 21:18
I?d start with the simpler mocha unit test, and then once you get that, take a look at the e2e example which covers both consumer/provider and publishing to a broker

beth
2019-07-09 22:07
Thanks @antonello!

antonello
2019-07-09 22:36
My pleasure!

uglyog
2019-07-09 23:20
If you want to try a PR to fix it, it should be a small change

thamu.gurung
2019-07-10 08:43
thanks

budi.injo
2019-07-10 10:14
has joined #general

anders
2019-07-10 12:09
has joined #general

craig.pothier
2019-07-10 17:26
hello, I trying to do a GraphQL interaction. I followed your example and use the exact same queries in the client appolo and pact mock however I am getting this: ```{ "body": { - "query": /query\s*getMeetingsByUUID\(\$uuids:\s*\[UUID\]!\)\s*\{\s*directoryByUUIDsWithFilter\(uuids:\s*\$uuids,\s*filter:\s*MEETING\)\s*\{\s*\.\.\.\s*on\s*Meeting\s*\{\s*displayName\s*UUID,\s*\}\s*\}\s*\}/ + "query": "query getMeetingsByUUID($uuids: [UUID]!) {\n directoryByUUIDsWithFilter(uuids: $uuids, filter: MEETING) {\n ... on Meeting {\n displayName\n UUID\n __typename\n }\n __typename\n }\n}\n" } }``` And I am not getting the returned results I am expecting as it seems pact doesn't see the queries as being the same. Can anyone help me here?

dan.schepers
2019-07-10 22:06
has joined #general

ukamkhan
2019-07-11 01:28
has joined #general

johngluckjunk
2019-07-11 06:09
Hey all, I used pact at my last company. My current company is attempting to figure out why their contract testing implementation isn't getting adoption. (They are using Spring CDC). I have a bunch of questions, but primarily I'm wondering if there are any testimonials from anyone that is using Pact where there are hundreds of microservices, how they were able to get adoption, and whether or not that helped them convince developers to stop writing so many system e2e tests. I have other questions too, but I don't want to overwhelm. Oh, and yes I have seen this - https://medium.com/kreuzwerker-gmbh/consumer-driven-contract-tests-lessons-learned-b4e1ac471d0c. I'm planning on running a POC with pact using the broker. I just don't want to over promise.

matt.fellows
2019-07-11 06:18
Hello!

matt.fellows
2019-07-11 06:18
The GraphQL wrapper provided in the JS implementation is still fairly new, so it?s possible the matching regex that is applied is just? wrong

matt.fellows
2019-07-11 06:20
The wrapper is also just sugar over an HTTP interaction (because GraphQL runs on HTTP)

matt.fellows
2019-07-11 06:20
If you can get it running without the GraphQL interface, we can work out why it?s not working

matt.fellows
2019-07-11 06:20
or, if you can create an example project that replicates and raise an issue, we can look into it

nick_horne_90
2019-07-11 10:35
Hey all, as a consumer, we are modelling some fields (e.g. an Id) as a `String` type but actually the type on the provider is an `integer`. As a result our pact verification is failing but really we wan't to use a string because we don't care on the Id format (just that there is one). Are there any thoughts on this or solutions to get the pact to pass?

simon.nizov
2019-07-11 10:55
You can?t have it both ways. You need to make a decision regarding the contract. If you decide the field should be `String`, then the provider should serialize its response in such a way that fits the contract, regardless of its own internal implementation. On the other hand, if you decide that the provider is the source of truth, then you should change the contract defined by the consumer accordingly.

matt.fellows
2019-07-11 11:30
Following from that. If you ?don?t care? about the format, then `integer` it is

matt.fellows
2019-07-11 11:33
There are a bunch of articles out there, and I can direct you to https://docs.pact.io/testimonialshttps://docs.pact.io/testimonials for companies who are using Pact in one way or another

matt.fellows
2019-07-11 11:33
I have stories, but nothing that has been approved for public release (we are hopeful Sainsbury?s will approve something in this space soon - they are certainly in that size/category)

matt.fellows
2019-07-11 11:36
As a consultant and core Pact developer, there is no ?one way?. But the key things that tend to work: ? Can you identify a problem and ideally a way of measuring it? This usually takes the form of classic CD metrics slow or flakey builds, high test maintenance, long cycle/lead times etc. ? Find a small pocket that you can influence/control and demonstrate a before/after success story. Garner support from key stakeholders in the process, but also be sure to include those pesky ?skeptics? - they become your key change agents when things succeed ? Prove value, iteratively expand from there. If step 1 is 2 services within a team, step 2 should go across team boundaries or knock off a painful integration

matt.fellows
2019-07-11 11:53
Oh, and yes. Generally where there is Pact, e2e tests are reduced. In some cases, completely.

nick_horne_90
2019-07-11 12:13
Thanks for the reply's. I guess as the consumer I just want to say that there is a field called "id" that can be read as a `String` I don't want to make this an integer because on the provider side, its only an integer because of the database implementation (e.g. if that changes I don't really want suffer any consequences as all I care about is that I can read it as a string and its called id).

nick_horne_90
2019-07-11 12:15
With the provider, I can't easily change the API as there will be other clients that do rely on it being an `integer`. Ideally it would have been represented as a `string` from the start on the provider side.

james.hattersley-dyke
2019-07-11 14:05
any advice on how to handle developers changing the provider before the consumer and commenting out the pact verification steps of your build? :rage:

craig.pothier
2019-07-11 15:24
thank you!

joris
2019-07-11 19:55
has joined #general

marko.justinek
2019-07-11 22:44
@james.hattersley-dyke There?s a pretty good write up on how to get the most out of pact -> https://docs.pact.io/best_practices/pact_nirvana Hope it helps If your provider devs decide to not honour the contract and not tell you about it, it might not be (most probably isn?t) personal and just having a friendly chat with them (maybe a few times). Explaining you guys are on the same team to provide a service to end users where you all are responsible for users? success? that might make them think next time (or the 3rd time down the line) to remember to notify you they _need_ to change the provider? That way you can be ready for provider changes by rewriting the implementation and tests, and consequently the contract.

mboudreau
2019-07-11 23:23
@james.hattersley-dyke sounds like you have a cultural problem. Personally, someone disabling tests instead of improving them because it "stops them from doing code" is a flight risk and a cowboy. I'd have a long chat with them and their manager about it in the hopes that they understand that this is detrimental to the business and if they don't change their tune, it might be best to part ways.

abubics
2019-07-12 03:42
put them in charge of maintaining consumer SLAs :upside_down_face:

abubics
2019-07-12 03:45
The practical solution is to make non-breaking changes, deprecate the old interface, then remove it when nothing depends on it, but . . . is there no concern that things are broken in the meantime?

james.hattersley-dyke
2019-07-12 07:23
yeah, it was more of a joke question / rant I guess... Just frustrating when you see lines of code commented out just so 'the build passes' aka my breaking change can get in...

james.hattersley-dyke
2019-07-12 08:25
I'd like to make a suggestion for an improvement in the docs. This was something I missed and was struggling to get my head around. On the Pact Nirvana Guide https://docs.pact.io/best_practices/pact_nirvana#5-allow-contracts-to-change-without-breaking-your-builds sub-bullets 5 & 6 should be in *bold* or have a diagram attached. Especially the part about local verification and then putting the provider code into master first. With the emphasis on it being Consumer driven, I've been struggling with the point of how to get new changes into a provider but having the consumer tagged with a branch name and providers verifying against the latest master from a CI point of view. I feel it's quite an important point but easily missed. Just wanted to say, while the above is a minor minor critique I think Pact is an amazing tool. I'm also loving how helpful you all are on here and the effort you've all have and keep putting in.

matt.fellows
2019-07-12 08:26
Thanks James. Would you care to submit a PR to the docs?

matt.fellows
2019-07-12 08:26
The diagram though, yes, we do need one of those!

james.hattersley-dyke
2019-07-12 08:36
yeah I'll have a crack at getting something down. Just thinking of the best way to describe / visualize it all :slightly_smiling_face:

matt.fellows
2019-07-12 08:37
thanks, that?d be great

matt.fellows
2019-07-12 08:37
my advice: get the text out first and then worry about the diagram. _just_ in case that takes a little longer :slightly_smiling_face:

james.hattersley-dyke
2019-07-12 08:38
:+1:


ninjinsky.coding
2019-07-12 14:02
has joined #general

amber.houle3
2019-07-12 17:10
has joined #general

madhukar.mishra
2019-07-12 17:17
@matt.fellows @bethskurrie can I get my request for pactflow trial approved quickly. Want to use it for the demo if possible

antonello
2019-07-12 18:51
Hi! I have some doubts around how to deal with endpoints protected by cookie based authentication. I have looked at the docs and issues in GitHub but I?m still unclear as what the best approach should be. We have a provider that has some endpoints that are protected by cookie-based authentication. Let?s say that two cookies `cookie_a` and `cookie_b` are required. These cookies are issued by a login endpoint in the provider and are set on the browser via a Set-Cookie directive in the provider response. The consumer sends these cookies in every request but they are not actively added by the consumer as it?s the browser that adds them to every request. How should we treat these cookies from a pact point of view? Should we: a) Not include them at all - after all the consumer does nothing with them and, because the provider is written in Java with Spring, we can mock what we want and handle cases of successful and failed authentication anyway. b) Include the cookies in the request headers of our interactions. If b) is the best answer here, should the cookies have exactly the same names of the real ones? And what about the values, would it be enough for the provider to verify that both cookies are present or should we be able to produce some test cookies (like the real ones) that never expire that the provider will just accept as valid?

matt.fellows
2019-07-12 22:50
There's no approval process anymore, you should have your account already. Hope it goes well, let us know!

madhukar.mishra
2019-07-13 15:41
Talk went well enough, couldn't get the demo prepped on time. Maybe in the next iteration :smiley:

matt.fellows
2019-07-14 01:03
:ok_hand:

matt.fellows
2019-07-14 22:09
It?s an interesting question

matt.fellows
2019-07-14 22:10
if the API Provider requires it to operate, it?s a key part of the contract but equally your ?client _code_? doesn?t know about it. But your _client_ does, however

matt.fellows
2019-07-14 22:11
I think that?s illuminating.

antonello
2019-07-14 22:22
There are different views in the office and I can see merits on both including it and not including them.

antonello
2019-07-14 22:23
Perhaps it would be more important (and sufficient?) to test that the login endpoints actually returns a Set-Cookie response header.

antonello
2019-07-14 22:52
Also, assuming that we were to test that the consumer sends the cookies, would we not want to use some ?real cookies?, with real names and values that the provider can interpret? My gut feeling is that we should, as otherwise you wouldn?t be testing the real contract.

matt.fellows
2019-07-14 23:05
Yep. I think you need to weigh up the pros/cons. From a purely theoretical perspective, I think the answer is ?you should include it?. But taking a more balanced view, I?d say test what gives you value. If the cookie is always going to be implicitly added by the browser (because that?s how browser?s behave) and it?s a scenario unlikely to give your team more (useful) information about how the system behaves, whilst costing you effort in maintaining it. Then maybe it?s not worth it

matt.fellows
2019-07-14 23:05
(sorry for delay, I was on the train on the way in and then was walking to work)

william.ariawan
2019-07-15 00:43
has joined #general

abubics
2019-07-15 01:40
I maintain my first comment :stuck_out_tongue:

matt.fellows
2019-07-15 04:18
Yep, if I did choose to test this I'd use the same cookie names and valid looking values with the auth but mocked our on the provider side (or using request filters if needed to inject the correct value at provider verification time if mocking wasn't an option)

antonello
2019-07-15 06:15
Thank you @matt.fellows! So, if you tested it and you could mock the provider side, you would use valid looking values but not actual valid values. In other words you wouldn?t - for example - generate a valid value with a very long expiration date using the real secret?

bethskurrie
2019-07-15 06:31
@antonello I'm with Matt on this one - be pragmatic.

bethskurrie
2019-07-15 06:31
I like the idea of checking that the login endpoint returns a Set-Cookie header

bethskurrie
2019-07-15 06:33
You can set a header at verification time using the --custom-auth-header option so that you don't have to include any valid values in the pact itself.

bethskurrie
2019-07-15 06:34
If you want to be classy about it, you can use custom middleware that 1. makes sure the cookies with the right name are there and 2. replaces their values with real values.

antonello
2019-07-15 06:40
Thank you both!


antonello
2019-07-15 08:08
Thanks @matt.fellows. The provider is in Java though :slightly_smiling_face: (consumer is js).

matt.fellows
2019-07-15 08:09
Ah no. They're called request filters in the JVM implementation

antonello
2019-07-15 08:11
That?s what I thought. We can mock the authorisation/identification logic in the provider though, so - if we decided not to include the cookies in the pact - I reckon it would just be easier to mock.

matt.fellows
2019-07-15 08:30
Agree. Those filters are for break glass scenarios

antonello
2019-07-15 08:32
I would still quite like the idea of generating a real cookie using the real secret (which in dev is different from production) but with a long expiration date.

rosario.azzaro
2019-07-15 14:44
has joined #general

bethskurrie
2019-07-15 21:58
Try it and see and report back @antonello

antonello
2019-07-15 22:09
Consensus today was to not include the cookies header in the contracts, at least for now.

matt.fellows
2019-07-15 22:32
Thanks for the feedback

matt.fellows
2019-07-15 22:33
If the situation changes let us know

ghandour.jihad
2019-07-16 08:21
Hello @bethskurrie, I am coming back to this answer :slightly_smiling_face: I got 2 questions for you:

ghandour.jihad
2019-07-16 08:21
1- Did anyone work on the c++ during this time? do we have a solution?

ghandour.jihad
2019-07-16 08:22
2- Can you please give me more details on the C++ basics you mentioned above, so that I can try and convince a C++ developer to work on implementing a solution?

bethskurrie
2019-07-16 08:57
@ghandour.jihad Nobody has picked this up that I know of. I'm afraid I haven't done c++ since uni (a long time ago!!), so I won't be any help at all with the technical details.

ghandour.jihad
2019-07-16 09:05
sure no worries! @uglyog, hello :slightly_smiling_face: I am interested in a C++ implementation of PACT. Can you please provide me with more details on how can the c bindings of the rust impl you did be used so that we develop a C++ implementation? (I will forward your answer to C++ developers that might be interested in picking up the work) thanks a lot! :slightly_smiling_face:

nathan2oo3
2019-07-16 09:32
Is there a consensus on the best way to use ldap with pact broker? I see nginx python2 ldap module being recommended by Nginx for ldap authentication and there are docker images out there with the http_auth_ldap module compiled but is there a recommended approach for best results?

uglyog
2019-07-16 13:03
The Rust implementation is a shared library that exports C bindings. Should be very usable from C++.

pavani.polakala
2019-07-16 15:44
has joined #general

pavani.polakala
2019-07-16 16:07
Hi. I'm kind of new to pact contract testing and I want to develop pact for android project. But the pact implementation guide for android looks pretty outdated - https://github.com/DiUS/pact-workshop-android/tree/master/consumer . Do you any other link that helps me setup pact in android env?

abubics
2019-07-17 01:23
I don't know if there are any decent recent examples :slightly_smiling_face: but Pact in Android is the same as any other JVM language consumer, so it really depends more on what testing libraries you're using

tanle.oz
2019-07-17 04:07
has joined #general

elvis.willems
2019-07-17 09:23
has joined #general

sebastian.kempken
2019-07-17 09:31
has joined #general

sabil.beladri
2019-07-17 14:00
has joined #general

jakub.gawryjolek
2019-07-17 16:20
has joined #general

pkuang
2019-07-17 18:43
Is there a way to disable these warnings in the pactjs verifier output: "WARN: Adding header ...", they are polluting our logs which makes it difficult to read the verification results

matt.fellows
2019-07-17 23:25
At the moment I don?t believe so. Could you please raise an issue on the pact JS repo and we?ll get it on our backlog?

denis.ducansel
2019-07-18 09:20
has joined #general

meirosuandreea
2019-07-18 09:56
has joined #general

matt.fellows
2019-07-18 11:13
Haven?t heard of anyone doing this yet, but keen to hear how you go if you do

matektchorek
2019-07-18 17:50
has joined #general

tchorek.mateusz
2019-07-18 17:51
has joined #general

matektchorek
2019-07-18 18:14
Hello. I have running server that allows me to retrieve json when I send get method for an endpoint. I have created in groovy a pact that should test if the json I am sending is correct but unfortunately I constantly have ExpectedButNotReceived exception. if I remove willRespondWith or withAttributes methods everything goes fine but in most of examples there were both of them. What am i doing wrong? Json example: [{"_shoppingmalls":[{"href":"http://localhost:8080/api/shopsData/Shoppingmall/1"}],"id":1,"shopId":1,"shoppingmallId":"1", "isOpen":"true"}] def example = new PactBuilder() example { serviceConsumer "consumer" hasPactWith "producer" port 2356 given('' shopping mall request") uponReceiving(" a shopping mall list") withAttributes(method: 'get', path: '/api/shopsData/Shoppingmall') willRespondWith(status:200,headers: ['Content-Type':'application/json']) withBody([ { _links{ href string() } id integer() shopId integer() shoppingmallId string() isOpen string() } ]) } My exception is: ExpectedButNotReceived(expectedRequests= method: get path: /api/shopsData/Shoppingmall query: [:] headers: [ : ] matchers: MatchingRules(rules= {}) genetrators: Generators(categories={}) body: MISSING])

kevin.monteiro
2019-07-18 22:07
has joined #general

uglyog
2019-07-19 00:36
@matektchorek can you verify that the test code is actually making the request. Debug level logs would help.

matektchorek
2019-07-19 05:19
I can see that incoming data in the intellij's console is the same as in the web browser

matektchorek
2019-07-19 05:20
but asserting service.runTest with PactVerifyProvider.OK.INSTANCE fails

uglyog
2019-07-19 05:21
`ExpectedButNotReceived` means the mock server is not getting the request. Where is it going? Enabling debug logging will show what is happening.

matektchorek
2019-07-19 05:21
You mean pacta server?

matektchorek
2019-07-19 05:22
I have the runnig server at 8080 and pacta running at port 2356

matektchorek
2019-07-19 05:22
i only check that one at 8080

uglyog
2019-07-19 05:22
No, when you run the test, a mock server is created. You need to get your consumer code to make the request to that server.

matektchorek
2019-07-19 05:23
so if I go to the real server instead it does show the good results but tells that mock server is not used

uglyog
2019-07-19 05:23
Port 2356

matektchorek
2019-07-19 05:23
the problem is, when I used mock server

matektchorek
2019-07-19 05:23
it generated random hashed values

uglyog
2019-07-19 05:24
It will generate random values if you don't give example values to the `integer()` and `string()` functions

matektchorek
2019-07-19 05:25
ok, my bad then

matektchorek
2019-07-19 05:25
is it possible then to make pacta tests with the real server running on?

matektchorek
2019-07-19 05:26
just for curosity

matt.fellows
2019-07-19 05:26
`s/pacta/Pact`

matektchorek
2019-07-19 05:39
ye, my bad, i use pacta as substitute for Pact

matektchorek
2019-07-19 05:39
anyway

matt.fellows
2019-07-19 05:39
:smile:

matektchorek
2019-07-19 05:39
I have real jar file running in background

matektchorek
2019-07-19 05:39
and I attempt to use that mocked jar

matektchorek
2019-07-19 05:40
in Pact test, is there a way that Pact tests would treat that jar process as a mocked server?

uglyog
2019-07-19 06:04
No, it doesn't work like that

niickkc2
2019-07-19 23:06
has joined #general

seamusjbellew
2019-07-22 05:34
has joined #general

kapoorvishal23
2019-07-22 10:32
has joined #general

bartek.bulat
2019-07-22 13:18
has joined #general

sdpoling
2019-07-22 15:35
I see there are two git repositories pact-provider-verifier and pact-provider-verifier-docker. Is there any significant difference between them (except the underlying versions of the former are more recent).

luchillo17
2019-07-22 17:44
Second one i'm guessing its the docker image to be able to run Pact in a container

igordezky
2019-07-22 17:53
has joined #general

p0deje
2019-07-23 06:30
has joined #general

yousafn
2019-07-23 09:52
Ola, just me being a mither again. Is there any way to skip provider verification for certain pact interactions?

ramspotla
2019-07-23 10:47
has joined #general

thakkarjinal29
2019-07-23 11:35
Ran into the same issue. Is this resolved? Can you please redirect me to where this issue is raised?

ramspotla
2019-07-23 11:45
Hi There , I am trying to use JVM to set up pact project . Is there any sample project for this


detert
2019-07-23 11:57
The only thing that I can image is using tags

matt.fellows
2019-07-23 11:59
What have you tried so far?

matt.fellows
2019-07-23 12:00
Hmmm you sort of can in some cases. You can spexificy a single interaction to test. But not exclude/fliter

ramspotla
2019-07-23 12:04
I have not tried anything yet . First time at our work plc

ramspotla
2019-07-23 12:05
I?m trying to use pact-jvm-junit5 for consunervtestd

ramspotla
2019-07-23 12:05
Consumer test but Gradle build fails . I did as per your example

ramspotla
2019-07-23 12:07
And also other question I have is : does it support soap/ XML messages

yousafn
2019-07-23 12:08
No worries, for the moment, I will just drop those interactions from the consumer sides code. The provider isn?t going to expose a mechanism to modify the expected response via provider states, and from a consumer perspective, the shape of the response is the same for 3 pact interactions, and I can currently validate one of them so its all good

ramspotla
2019-07-23 12:09
Consumer sends soap message to micro service and micro service receives soap messages from downstream systems & process it sends it back to consumer in soap message

tchorek.mateusz
2019-07-23 13:14
I have an endpoint like: "http://localhost:8080/api/data/nbi/Shop?fields=name,shopId" that allows me to get list of shops with certains fields like name, etc. How can I recreate this string in pact framework? Should I add those parameters in query array in "withAttributes" method? Like: withAttributes(method: 'get', path: /api/data/Shop?fields=", query : [name: "name", shopId : "shopId"] ) ?

mui_ume
2019-07-23 13:20
Hi, I am getting confused with the provider for JVM in this github https://github.com/DiUS/pact-jvm/tree/master/provider

mui_ume
2019-07-23 13:20
do I just choose one only. my project is in java, using maven build and spring boot, junit, which one should I look at?

hvgiitr
2019-07-23 14:20
has joined #general

dherman
2019-07-23 14:36
has joined #general


pact.io
2019-07-23 16:10
According to the docs, soap is possible if I remember it correctly. You should take some time to read the docs. It really helps a lot


ramspotla
2019-07-23 22:04
then I went to I use Java section


ramspotla
2019-07-23 22:06
pact-jvm-consumer-junit5 JUnit 5 support for Pact consumer tests Dependency The library is available on maven central using: group-id = au.com.dius artifact-id = pact-jvm-consumer-junit5 version-id = 4.0.x

ramspotla
2019-07-23 22:08
after adding above dependency in gradle , gradle builld failed

craig.pothier
2019-07-23 22:35
I didn't resolve this unfortunately.

uglyog
2019-07-23 23:03
@ramspotla can you provide more info on how your build failed?

wontae.lee09
2019-07-24 00:30
has joined #general

davmitchell
2019-07-24 00:35
has joined #general

tjones
2019-07-24 01:25
If there are interactions in the consumer pact that you don't expect to work yet, tags are definitely the way to go

matt.fellows
2019-07-24 01:28
But you can?t do that _within_ a contract file, which is a current limitation.

mui_ume
2019-07-24 01:43
thanks my first provider pact looks like this: ```package xx.xxxxxx.platform.service.identitymanager.pact; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import au.com.dius.pact.provider.spring.SpringRestPactRunner; import au.com.dius.pact.provider.spring.target.SpringBootHttpTarget; import org.springframework.boot.test.context.SpringBootTest; import org.junit.runner.RunWith; @RunWith(SpringRestPactRunner.class) @Provider("Platform Services") @PactFolder("pacts") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ProviderPactTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @State("login with valid userId") public void loginTest() { System.out.println("Login Test with valid UserId Verified"); } @State("Start Chat with valid session") public void StartChatTest() { System.out.println("Start chat with valid session Verified"); } @State("logout with valid authToken") public void logoutTest() { System.out.println("logout with valid authToken Verified"); } @State("forgotPassword with valid userId") public void forgotPasswordTest() { System.out.println("forgotPassword with valid userId Verified"); } @State("start Session with valid token") public void startSessionTest() { System.out.println("startSession with valid token Verified"); } } ```

mui_ume
2019-07-24 01:44
I have a pact broker at a url https://pact.shared.frigg.li how do I add to my above code. is it like this: @pactBroker("https://pact.shared.frigg.li")

yousafn
2019-07-24 09:41
Yeah I have a single pact file for each consumer/provider. Some of those interactions are not able to work at the moment, due to the provider state not being able to be addressed in this current phase, so I would ideally like to skip one of those interactions within a pact. I could address it two ways at the moment - either drop the interaction from the pact contract when writing the consumer tests or when I programmatically overwrite a pact prior to verification, to add in AWS signed headers, just remove the interaction from the pact, pre verification. The former is simpler, and is possible now, as we have switched to wiremock for our mock services, rather than using pact mock service, due to some current kwown limitations (which I would like to address and have raised issues/pr?s for :ok_hand: )

antonello
2019-07-24 22:41
Hi! It?s me again! There is something that I have noticed today that is confusing me and some of the teams I?m working with. All our feature branches for consumer and provider have their own pipelines. The consumer?s feature branch pipeline publishes a pact with a tag `feature_branch_a` and the provider?s feature branch pipeline verifies pacts published with tags `master`, `prod` and `feature_branch_a`. So, if the name of the consumer?s and provider?s feature branches match, the pact tagged with `feature_branch_a` gets ?cross-verified?. Today a change was made on a branch of both consumer and provider that involved removing a field from the pact and from the response of the provider. Leaving aside whether this was the right thing to do, when the provider verification ran on the feature branch, it understandably failed because the latest pacts tagged with `master` and `prod` included the field that had been removed from the response of the provider. Now to the bit that I don?t understand. When going to the pact broker matrix and searching for the consumer version that published the pact with tag `feature_branch_a`, it shows that the pact was correctly published. However, it shows that the pact was not verified successfully, even if that pact specifically is compatible with the provider?s feature branch (as demonstrated by running the verification locally agains that tag). I can think of (at least) two possible explanations: a) I don?t understand how the matrix works and it is correct that ?Pact verified? in the matrix is red, or b) when running the provider verification, a failed verification result is uploaded by `pact_jvm` to the broker against the pact with tag `feature_branch` even if the verification tests succeeded when verifying the `feature_branch` tag but failed for `master` and `prod` (which were obviously published by a different consumer version). I hope this is not too convoluted, but it?s sometimes hard to describe these things with enough clarity.

bethskurrie
2019-07-24 22:44
Ok, that's a complicated scenario. Before I delve into it too deeply, have you remembered that the verification belongs to the *content*.

bethskurrie
2019-07-24 22:44
If two different versions of the pact have identical content, then the verification for one also belongs to the other.

antonello
2019-07-24 22:48
Here the content is definitely different as some fields were removed from the pact on the feature branch.

bethskurrie
2019-07-24 22:49
What would help here is if the build URL was published with the results. It's available in the API, but not many clients take advantage of it.

bethskurrie
2019-07-24 22:50
Are you publishing verification results from local machine or CI?

antonello
2019-07-24 22:51
All CI

antonello
2019-07-24 22:51
As we should :)

bethskurrie
2019-07-24 22:51
:thumbsup::skin-tone-3:

bethskurrie
2019-07-24 22:51
You're a pro.

bethskurrie
2019-07-24 22:51
And when you look at the CI results for that branch, they say they're green?

antonello
2019-07-24 22:52
The scenario I?ve described is probably more complicated than it should - but basically it seems that when the provider verification tests run for more than one tag, the latest pact with one of those tags is marked as non verified even the verification failed for a different tag

bethskurrie
2019-07-24 22:53
Sometimes the index can be misleading because it doesn't know which tags are significant, but the matrix should be accurate.

antonello
2019-07-24 22:53
Nope, CI results are red, as expected because feature consumer is compatible with feature provider, but feature provider is not compatible with master consumer.

bethskurrie
2019-07-24 22:53
Esp if you're in the view that shows every version - not the view that rolls up some of the results.

bethskurrie
2019-07-24 22:54
But you'd expect feature_branch_a pact and feature_branch_a verification to be green

bethskurrie
2019-07-24 22:54
Can you find that particular verification result in the CI and see what it says?

bethskurrie
2019-07-24 22:55
When we get verification results into the broker that will also help!

bethskurrie
2019-07-24 22:55
In fact, they may be there, depending which clients you're using. What are you verifying with?

antonello
2019-07-24 22:58
Using `pact-jvm-provider-junit`

antonello
2019-07-24 22:58
>But you?d expect feature_branch_a pact and feature_branch_a verification to be green yes, and that does not seem to be the case.

antonello
2019-07-24 23:01
>Can you find that particular verification result in the CI and see what it says? I can?t see anything being logged with regard to the verification result apart from the two test failures that I expect (for the master and prod tags - well, at least I think it?s for them because it?s 2 out of 3 that failed. Sadly the test runner does not say which tags failed the verification.)

antonello
2019-07-24 23:15
we?re using the `3.6.10` by the way

antonello
2019-07-24 23:21
Time for bed here in :uk:, but I?ll check this again when I wake up in 7 hours. I wonder if @uglyog may have any ideas of whether `pact-jvm-provider-junit` may be behaving incorrectly in this scenario?

uglyog
2019-07-24 23:25
Have a good night! It definitely seems like something is going wrong and we will have to debug a bit further. Version 3.6.10 does publish the verification results, so you will need to dig that out so we can see what is going on.

uglyog
2019-07-24 23:33
Just got a PR to print the tag: > When provider tests are run using the PactBroker, and multiple tags are specified, it can be to figure out which verification was for which tag. > This is slightly annoying especially when verifications fail. This commit prints out the tag if supplied.

antonello
2019-07-24 23:36
That?s great! It?s something we really wanted and I know @alessio.paciello was looking into it but great someone else got there first :blush:

antonello
2019-07-24 23:39
Off the top of your head, do you know if the verification results are published separately for each tag that gets verified?

uglyog
2019-07-24 23:42
It should be, based on the pacts that are fetched. Not sure what happens if two tags fetch the same pact.

gsravikumar
2019-07-25 05:34
has joined #general

gsravikumar
2019-07-25 05:47
Hi , I need input on using PACT for our use case. We are using PACT for our for all our microservice level contract testing. However we have a few jobs (spark jobs) , these jobs consumes data from KAFKA topic.. There are other services which writes into the same KAFKA topic. So two services are not talking to each other via APIs, but use common KAFKA topic. Does PACT supports contract testing for the above scenario ?


gsravikumar
2019-07-25 05:54
Thank you Alex.

matt.fellows
2019-07-25 06:11
Yes, we support testing this sorry if thing. Look for pact message related terms

matt.fellows
2019-07-25 07:02
Sort of thing*

shikha.mishra
2019-07-25 07:44
has joined #general

antonello
2019-07-25 08:12
:+1::skin-tone-2: As you said the next step is probably debugging through it

diegorherrera
2019-07-25 08:20
has joined #general

shikha.mishra
2019-07-25 09:16
Hi everyone, I am quite new to pact and graphql. Has anyone tried mutation in request? Could someone give me some pointers? Thank you:)

manish.kapoor
2019-07-25 10:00
has joined #general

dsu
2019-07-25 10:52
has joined #general

anders
2019-07-25 10:56
Hi Shika. Are you talking about requests to endpoints which mutate persisted data?Our project had some challenges testing this for a while. We solved it by realising that the pact probably should not be verified against an actual live database, but against a mocked database which always contains the expected state (given by the `state` field in the pact interaction), and which doesn't affect any live environment when mutated.

au443479
2019-07-25 13:03
has joined #general

au443479
2019-07-25 13:06
Hi everyone

au443479
2019-07-25 13:07
I want to use to test aws sns notification basically other than res api calls .. is pact a good framework to use for contract testing ?

rajendra.patil
2019-07-25 13:25
has joined #general

matt.fellows
2019-07-25 13:38
yes, you can test SNS notifications

matt.fellows
2019-07-25 13:38
which language?

matt.fellows
2019-07-25 13:38
what have you read/looked at so far?

rajendra.patil
2019-07-25 13:45
Hi Everyone ! I am seeing some wired issue with webhooks talking to slack , I have pivotal cloud foundry instance for my pact broker , when webhook executed it doesn't even go to my https proxy and shows following error.

rajendra.patil
2019-07-25 13:45
Failed to open TCP connection to http://hooks.slack.com:443 (getaddrinfo: Name or service not known)

rajendra.patil
2019-07-25 13:46
after research i learned that it could be caused by rack version! please advice


jgluck
2019-07-25 17:14
has joined #general

christopher.f.almanza
2019-07-25 18:46
Is there any general recommendation for when you have a CD pipeline?

christopher.f.almanza
2019-07-25 18:48
We started off by following the "team communication" motto, which is great. But sometimes we either merge in the wrong order or merge with time in between both consumer and provider

christopher.f.almanza
2019-07-25 18:48
which ends up in a broken build on our integrated environment for some time

christopher.f.almanza
2019-07-25 18:48
is there any process documentation that tackles a similar scenario

ljnoble
2019-07-25 18:58
has joined #general

getsreerag22
2019-07-26 02:28
has joined #general

shikha.mishra
2019-07-26 03:26
Thanks Anders. Yes thats what I was talking about. I will have a look at state field. Thank you:pray:

matektchorek
2019-07-26 12:01
In groovy, how can I add array in withBody parameter? like "array" [ { json: "json" } ] intellij doesnt see array : [ { json: "json" } ]

matektchorek
2019-07-26 12:04
getAt cannot be applied to array

matektchorek
2019-07-26 12:06
ok problem solved

matektchorek
2019-07-26 12:07
array = [ { json: "json" } ] works!

matt.fellows
2019-07-26 12:26
might want to ask this in #pact-jvm


matt.fellows
2019-07-26 12:28
?and read up on provider states

ajeet.tripathi632
2019-07-26 15:57
has joined #general

deshdeepdivakar
2019-07-29 02:37
hi @here I am getting this scalalogging issue when linking the mock server with the interaction. Any help is much appreciated! I am following this https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-junit5

uglyog
2019-07-29 02:48
How are you running your tests? Are you using Scala in your project?

deshdeepdivakar
2019-07-29 02:50
No, we aren't using scala at all. I thought the Pact Junit extension might be using scala

deshdeepdivakar
2019-07-29 02:51
Found this https://github.com/lightbend/scala-logging/issues/68 but not entirely sure what is using scala and how I can exclude it

deshdeepdivakar
2019-07-29 03:09
@uglyog I am running my test as Junit test. Intellij

uglyog
2019-07-29 03:26
There must be some conflict that is bringing in different versions of the Scala logging. You can switch to the latest 4.0.0 beta version. That doesn't depend on Scala.

deshdeepdivakar
2019-07-29 03:28
Sure, let me give it a shot. Thank you for your instant responses appreciate :man-bowing:

deshdeepdivakar
2019-07-29 03:33
This is what i have at the moment - ```classpath 'au.com.dius:pact-jvm-consumer-junit5_2.12:3.6.12' classpath 'au.com.dius:pact-jvm-provider_2.12:3.6.12'```

deshdeepdivakar
2019-07-29 03:36
Now replaced with ```classpath 'au.com.dius:pact-jvm-consumer-junit5:4.0.0-beta.1' classpath 'au.com.dius:pact-jvm-provider-junit5:4.0.0-beta.1'```

annarayanarasagond
2019-07-29 04:09
has joined #general

deshdeepdivakar
2019-07-29 04:51
that worked thanks heaps!!

deshdeepdivakar
2019-07-29 06:48
hi @here just a general/conceptual question? When writing the provider test do I need to startup my provider service locally? I am assuming yes which means in our case I need to proxy a whole bunch of services and DB to have that service up and running. We are monolith from repository perspective but the code is segregated across different projects/folders. Any thought/suggestions are much appreciated as we are currently running a spike for this and really want to adapt it. Cheers!

matt.fellows
2019-07-29 07:00
you assumed correct, you do indeed

matt.fellows
2019-07-29 07:00
My general advice would be to stub out any external collaborators (an anti-social style test)

deshdeepdivakar
2019-07-29 07:07
Thanks @matt.fellows just to understand a bit better what you have suggested. Should I be stubbing everything what my provider needs? Also, a few things - we heavily use rpc/jrpc calls between different api's. I know this might already started to sound intertwined and it is. But we are aiming for leveraging http://Pact.io with all these challenges while we work on separating out those projects in to their own services. Cheers

matt.fellows
2019-07-29 07:09
Correct. But, just know thata when you do that, if you were previously relying on those tests for coverage you might need to add others in the interim to give you confidence that integration is working.

deshdeepdivakar
2019-07-29 07:14
Awesome, thanks appreciate your prompt response. :+1:

florian.nagel
2019-07-29 07:15
I had the same issue on the 3.x version

srikanthyadake
2019-07-29 09:25
has joined #general

lennart.tange
2019-07-29 09:56
has joined #general

lennarttange
2019-07-29 09:56
has joined #general

elineopsommer
2019-07-29 13:55
has joined #general

mohindroo.deepak
2019-07-30 06:10
has joined #general

zhaoxia2
2019-07-30 06:10
has joined #general

deshdeepdivakar
2019-07-30 06:23
hi @here can someone please point me to a good provider (Spring + JUnit 5) example. I am a bit confused as all the current JUnit examples are using Wiremock & I have my service running locally as a gradle task. Do I need to have my consumer mocked when verifying provider :thinking_face: https://github.com/DiUS/pact-jvm/blob/master/provider/pact-jvm-provider-junit5/src/test/java/au/com/dius/pact/provider/junit5/HttpsContractTest.java

deshdeepdivakar
2019-07-30 07:18
Also, ```org.junit.platform.commons.util.PreconditionViolationException: No supporting TestTemplateInvocationContextProvider provided an invocation context``` getting this error as well.

matt.fellows
2019-07-30 07:22
Maybe ask in #pact-jvm

deshdeepdivakar
2019-07-30 07:30
@matt.fellows @uglyog ^ can you please help with the error above ^

matt.fellows
2019-07-30 07:32
Sorry, that means nothing to me :grimacing:

matt.fellows
2019-07-30 07:32
Haven't worked in Java for ages

deshdeepdivakar
2019-07-30 07:34
no worries

deshdeepdivakar
2019-07-30 07:34
Sure

antonello
2019-07-30 07:42
Morning or evening, depending on time zones! I?m posting here rather than in #pact-jvm because, aside from the teamwork implementation, there is a more general point here. We have noticed a problem with pact-jvm-provider-junit. We will probably raise an issue on github, but in the meantime here is a brief explanation. When splitting the verification tests across multiple classes using @PactFilter, if some of the interactions are NOT verified (because they are ?filtered out?), the provider verification tests pass AND a verification result is NOT published to the broker.* While this is ?fine? from a can-i-deploy perspective, it is confusing because, when looking at the broker, it looks as though the provider verifications never ran. Also, one could argue that the provider verification tests should also fail if some interactions are not verified. I am inclined to agree with that. What is the ideal behaviour here? Failing the tests and/or uploading a failed verification results would seem reasonable in principle to me. * A couple of months ago @alessio.paciello pushed a fix to prevent the publication of successful verification results if not all interactions were verified.

antonello
2019-07-30 07:46
P.S. the problem doesn?t manifest itself if you don?t use @PactFilter and if all provider verification tests live in the same class. But it is not a sustainable approach, especially for services that are not that micro.

uglyog
2019-07-30 07:57
The ideal solution would be for the broker to accept the verifications in bits, and only display successful verification when all interactions have a successful result. But it will require work to implement this logic in the broker.

uglyog
2019-07-30 07:58
This is the junit 5 way of saying there were no tests to run. Probably because there were no matching interactions found to verify.

antonello
2019-07-30 08:00
You don?t think that pact-jvm-provider-junit could be changed to have a runner that aggregates the results as @alessio.paciello suggested here? https://github.com/DiUS/pact-jvm/pull/890#issuecomment-499769255

dvallabhuni
2019-07-30 08:05
has joined #general

uglyog
2019-07-30 08:09
I mentioned the ideal solution. Because you can then split the tests over multiple build agents. But that will work for tests that run in a single process. The complexity comes in when do you publish the verification result? You can?t wait for a result for all interactions, because if one doesn?t run.

antonello
2019-07-30 08:15
mmm. you make a very good point.

antonello
2019-07-30 08:20
could it be something that you can switch on and off? if you know you run tests in a single process, you would switch on the ability of failing the test run if not all interactions are verified?

william.robson
2019-07-30 09:34
has joined #general

richard.peckett
2019-07-30 14:48
quick question guys, forgive me if I'm being thicky mc thickson from backwardshire here... If you're defining a contract whereby the consumer is actually sending a POST to a provider is this valid (is the consumer actually a consumer here?) can a consumer be a consumer if it's sending data to the provider and the provider is responding in the 200 range with no content in the body?

phall
2019-07-30 14:53
Yes, the consumer is the ?user? of the service. That would be a valid use case.

thirumal.net
2019-07-30 16:07
Hi All @matt.fellows @yousafn we have implemented pact in some of our projects and it is working good. but stuck in implementing pact for non json services . what is the solution for xml response services form pact recommendation? Thanks in advance

yousafn
2019-07-30 16:09
pretty sure pact-jvm has xml matchers, pact-js doesn?t.

thirumal.net
2019-07-30 16:22
Thank you yousaf for quick response, you mean to say we can implement Pact for web services which will return xml responses from consumer and provider side . could you please guide me for some examples ?

atle.rudshaug
2019-07-30 19:26
has joined #general

kyle.hammond
2019-07-30 20:07
has joined #general

matt.fellows
2019-07-30 21:10
@thirumal.net The Java implementation supports XML (as does the Scala one). I?m not sure/aware of other languages Pact supports that do

matt.fellows
2019-07-30 21:10
so you could, but not if you need to test services that are not either of them

matt.fellows
2019-07-30 21:11
I can see the confusion, but yes, it?s still the correct parlance :slightly_smiling_face:

matt.fellows
2019-07-30 21:11
Presumably, the provider does something more than just respond with a `201` or something - hopefully it actually does something useful :slightly_smiling_face:

kyle.hammond
2019-07-30 21:30
Is it possible to write a PACT with the standard v2 matchers that will match a JSON array where each element of the array matches a regex? My consumer matching code look something like this (using pact-consumer-swift) ``` var expectedBody: [String: Any] = ["object": 123] let regex = Matcher.term(matcher: "(abc|def|ghi)", generate: "abc") expectedBody["available"] = Matcher.eachLike(regex, min: 1) ``` I?m trying to say that the ?available? key should contain an array of at least one element, and each of those elements should match the regex (that is, be one of the three possibilities listed in the regex). Example valid responses would be: `{"object":123, "available": ["abc"]}` or ` {"object":123, "available": ["abc", "ghi"]}` or `{"object":123, "available": ["def", "abc"]}` I can?t seem to figure out if the Pact contract v2 is supposed to support this by looking at the specification.

matt.fellows
2019-07-30 22:00
Hmmm that?s an interesting one. It should, I think. `eachLike(regex(...))` doesn?t work?

shivmohan08
2019-07-30 22:47
has joined #general

abubics
2019-07-30 23:20
The provider-consumer relationship is conceptually close to server-client. One end supplies a service via an interface, and the other end invokes it :)

matt.fellows
2019-07-30 23:21
Also see https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0 (sorry didn?t hit send on this yesterday)

dpm
2019-07-31 06:39
has joined #general

srikanthyadake
2019-07-31 13:22
Hi All, I'm new to pact stuff, can anyone help me with this issue : https://stackoverflow.com/questions/57287320/provider-state-errors

srikanthyadake
2019-07-31 13:24
brief about the issue : when I try to run provider against pact file, I see 'error setting up provider-state'.

chaoscifer
2019-07-31 14:11
has joined #general

chaoscifer
2019-07-31 14:18
Hi! Please, Provider gradle task pactVerify fails with org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(Ljava/lang/Iterable;Lgroovy/lang/Closure;)Ljava/util/List; I'm using pact-jvm with Kotlin and I'm loading the pact file from disk within build.gradle: pact { serviceProviders { providerService { protocol ='http' host = 'localhost' port = 7000 hasPactWith("consumerService") { pactSource = file("$rootDir/resources/pacts/providerService-consumerService.json") } } } } The output of this execution is: Verifying a pact between checkingAccount and fraudService [Using File /Users/cassio.kenji/workspace/fraud-service/target/pacts/checking-account-fraud.json] :pactVerify_fraudService (Thread[Task worker for ':' Thread 3,5,main]) completed. Took 0.011 secs. FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':pactVerify_fraudService'. > org.codehaus.groovy.runtime.DefaultGroovyMethods.collect(Ljava/lang/Iterable;Lgroovy/lang/Closure;)Ljava/util/List; -- Sorry for the lack of information at this moment. I work for a fintech and some data is very sensitive. I already tried a variety of alternatives from github examples and some Pact official documentation and I always come to that error. My pact-jvm versions: classpath("au.com.dius:pact-jvm-provider-gradle_2.12:3.6.1") //pactTests testCompile 'au.com.dius:pact-jvm-provider_2.12:3.6.1' Thanks!

kyle.hammond
2019-07-31 15:39
Indeed `eachLike(regex(?))` does *not* work during pact verification on the provider side. The consumer can code it that way, but I don?t know that the generated PACT is valid. The verification on the server side shows > Error: WARN: Only the first item will be used to match the items in the array at $[?body?][?available?] and stops the verification since it?s an error.

kyle.hammond
2019-07-31 15:42
The spec says, for the ?MinType? matcher > This executes a type based match against the values, that is, they are equal if they are the same type. In addition, if the values represent a collection, the length of the actual value is compared against the minimum. That implies that it is a ?Type? based match, and not a Regex based match for the items in the array. I?m not sure if ?type? based matches are supposed to be replaceable with ?Regex? based matches; that is, if anywhere I can put a type based match I could instead put a Regex based match.

uglyog
2019-07-31 23:02
Try the latest version of pact-jvm. Also check out https://github.com/pactflow/injected-provider-states-example and see if you get the same problem

chaoscifer
2019-08-01 00:12
hi, thanks for you reply! I ended solving this up by updating my gradle wraper to 5.1.1. as I said I work for a fintech and infosec is very restrictive... I have to use an internal repo and some packages are kinda of old. thanks again!

franklin.huynh
2019-08-01 01:36
Hi all I just wanna ask about the idea how to do the below statement without modifying the provider test > Add the ?production? tagged pact to the list of pacts the provider will verify. My current provider script is ``` new PactVerifier(config) .ProviderState($"{PactServiceUri}/provider-states") .ServiceProvider(ProviderName, ProviderUri) .HonoursPactWith(ConsumerName) .PactUri($"PactUtilities.PactBrokerCloud}/pacts/provider/{ProviderName}/consumer/{ConsumerName}/master") .Verify(); ``` Many thanks

franklin.huynh
2019-08-01 05:29
@matt.fellows ^^ any idea

srikanthyadake
2019-08-01 05:31
@matt.fellows any idea? thanks.

antonello
2019-08-01 05:35
Which language is that?

franklin.huynh
2019-08-01 08:12
it's C# @antonello

james.hattersley-dyke
2019-08-01 10:13
Hi, bit of a vauge question. We have an nginx service which calls a downstream REST API using lua. Nginx/lau is the consumer, and the provider is a spring boot app. I noticed there's a generic provider verification tool, is there the consumer equivilant? rather then install node or python etc into the nginx project, I was wondering if there's a generic way to create contracts?

sundakr1
2019-08-01 11:20
has joined #general

marius.maaland
2019-08-01 16:41
has joined #general

marius.maaland
2019-08-01 16:48
Hi all! I'm reading up on, and trying out Pact testing for my company. One question I have is: Can you not run provider tests against deployed APIs, using HTTP*S* ? Our APIs cannot be run locally (locahost, like in all the examples I've seen), but we do deploy to staging before production. I would like to run provider tests against `https://myapi-staging.com/blabla` before deploying to production. Is Pact not intended to be used that way, or am I missing something? When I do run a test like that, the test fails with `read server hello A: unknown protocol`

sedpavel
2019-08-02 12:09
has joined #general

ajitvdpthk
2019-08-02 12:17
has joined #general

matt.fellows
2019-08-03 13:54
You can do it that way, but it will get harder to do as your contracts get more advanced (e.g. setting up states). People so it though and can be a good way to get started with Pact

luis.giraldo10
2019-08-03 18:46
has joined #general

luchillo17
2019-08-03 19:19
Guys question about GraphQL interactions and provider states, i need the same query, different `given` clause & different response, i tried adding this new interaction in the exact test that uses it with the hope that the next request would use the latest defined interaction that matched the request in this test, but it uses the first interaction, how do we use the `providerStates` feature with GraphQL interactions?

luchillo17
2019-08-03 19:24
To clarify the new interaction has the same `withRequest`, `withVariables`, `withQuery` and `withOperation` (as null), things different are the `given`, `uponReceiving` and `willRespondWith`

srikanthyadake
2019-08-04 05:59
Hi all, a question regarding provider state. I need to do a post call which requires http request header from another api. Can I add request header in provider state block?

srikanthyadake
2019-08-04 08:47
I read about this, generateNewHeaders and requestFilters should be added. I am writing in .net and is this implemented in pact-net ? If so, any examples around?

matt.fellows
2019-08-04 22:34
It looks like the suffix `/master` is the tag. So you probably want to also do that for, say, `/production`

matt.fellows
2019-08-04 22:34
(sorry, was traveling second half of last week)

matt.fellows
2019-08-04 22:35
I think so, but you?d need to install Ruby for that CI job

matt.fellows
2019-08-04 22:36
for an example using the mock service in a standalone way (basically, a very crude implementation of what Node/Go/Python/PHP? use) see https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh

franklin.huynh
2019-08-04 23:38
no worry @matt.fellows is that mean I need to update the provider test in order to verify /production tag? Do you have any idea to do it in cicd script? For example, if there is Production tag, it will automatically get the production tag verify?

franklin.huynh
2019-08-04 23:42
I'm trying to make it standard so the owners of the provider test don't need to raise any PR that just to add production tag

franklin.huynh
2019-08-04 23:42
I hope my question is clear

matt.fellows
2019-08-05 02:29
yep

matt.fellows
2019-08-05 02:29
I usually use git tags and/or environment variables to modify behaviour in builds. For example, if on the `master` branch, you might want to verify tags that match `master` and `production` whereas on a branch you might want `feature1` and `production`.

matt.fellows
2019-08-05 02:30
the code you shows above is just going to validate a single tag `master`. You might want it to dynamically iterate over a list of tags that are (possibly) supplied by the build environment

matt.fellows
2019-08-05 02:31
e.g. the build environment might have an environment variable `TAGS=master production` and you split that based on space, and then iterate over it

matt.fellows
2019-08-05 02:31
I don?t know the .NET API all that well, but others let you specify an array of tags to be verified. See if that?s possible, or perhaps raise a feature request if not

franklin.huynh
2019-08-05 03:15
this is exactly what I needed. I'll have a look on that if .net api have it

franklin.huynh
2019-08-05 03:26
at the moment, if I want to verify 2 tags, I need to verify it twice ``` new PactVerifier(config) .ProviderState($"{PactServiceUri}/provider-states") .ServiceProvider(ProviderName, ProviderUri) .HonoursPactWith(ConsumerName) .PactUri($"PactUtilities.PactBrokerCloud}/pacts/provider/{ProviderName}/consumer/{ConsumerName}/master") .Verify(); new PactVerifier(config) .ProviderState($"{PactServiceUri}/provider-states") .ServiceProvider(ProviderName, ProviderUri) .HonoursPactWith(ConsumerName) .PactUri($"PactUtilities.PactBrokerCloud}/pacts/provider/{ProviderName}/consumer/{ConsumerName}/production") .Verify(); ```

franklin.huynh
2019-08-05 03:27
it'll be great if we can pass as an array for to PactUri function

franklin.huynh
2019-08-05 03:27
I checked, it doesn't accept array list

matt.fellows
2019-08-05 04:13
might be worth raising a feature request

franklin.huynh
2019-08-05 04:34
yes, will do

mohindroo.deepak
2019-08-05 06:35
I was trying to set PactDir in consumer side where pact files generated but it always create in d:\pacts directory? Is this a bug? Another issue coming is how provider will get all pact files for specific provider? It can be multiple consumers using one provider?

matt.fellows
2019-08-05 06:48
Can you please ask that question in the related language channel @mohindroo.deepak? That will help get it answered quicker

gs201m
2019-08-05 10:19
has joined #general

matt.fellows
2019-08-05 12:44
Sorry Carlos I didn?t quite follow this question. Are you asking if you can use provider states with GraphQL? The short answer is yes, all that the JS GraphQL interface is is a wrapper over the default one (i.e. you could use that if you needed too)

matt.fellows
2019-08-05 12:44
What issue are you actually facing?

luchillo17
2019-08-05 16:01
To clarify the new interaction has the same `withRequest`, `withVariables`, `withQuery` and `withOperation` (is null), things different are the `given`, `uponReceiving` and `willRespondWith`, but the second request (which is the one that should use the new interaction) is still using the previous one.

matt.fellows
2019-08-05 22:13
Is it two requests in the same test? Or spread across multiple? I don?t believe you can do it twice within the same test

matt.fellows
2019-08-05 22:13
across tests it should work, and if not is a bug. Are you sure the interactions are cleaned in between tests? If you could paste the logs I can t take a look

luchillo17
2019-08-05 22:36
Its in same file, different `it` block.

pbarrientos
2019-08-05 22:46
has joined #general

matt.fellows
2019-08-05 22:48
should work, assuming you call `verify()` in between

luchillo17
2019-08-05 22:57
Hmm? the issue is when we're defining the interacions in the consumer, verify is called in the provider isn't it?

goingkilo
2019-08-05 23:22
has joined #general

matt.fellows
2019-08-05 23:55
In the consumer, you still must call the `verify()` method to ensure that your code did what you said it would


matt.fellows
2019-08-05 23:55
(I generally run this in the `afterEach` type block - after each `it` statement, we should check that your code did what it said it would do - in your case, make a call to the GraphQL mock service)

matt.fellows
2019-08-05 23:55
If you could share your code / logs, I could help more

luis.giraldo10
2019-08-06 00:38
@matt.fellows This is the code (test) and log

franklin.huynh
2019-08-06 00:47
hi @matt.fellows, I raise the feature request and I'd like to work on it. Could you explain to me on how other can use it in CICD? Please leave your comment here


franklin.huynh
2019-08-06 01:38
please ignore the above

sbellew
2019-08-06 02:03
has joined #general

gs201m
2019-08-06 04:36
You can consider running PACT against the deployed API in staging. Only pact generation is part of the unit tests...

thirumal.net
2019-08-06 05:45
Thank you @matt.fellows and @yousafn. we are analyzing pact implementation for xml-rpc service project. i am unable to find out any sample java example for pact xml -rpc projects. please share it if you come across pact implementation for xml-rpc

beth
2019-08-06 09:30
Try asking in the #pact-net channel @srikanthyadake

srikanthyadake
2019-08-06 13:16
cool, I was not aware of the channel. anyway, issue is resolved by using PactVerifierConfig.CustomHeader

srikanthyadake
2019-08-06 13:17
This is resolved now, this happened as there was a issue with pact file.

c.metz
2019-08-06 19:22
has joined #general

c.metz
2019-08-06 19:32
Question: is it possible to define a regex matcher for a plain text body of a multiformdata request? For details see: https://stackoverflow.com/questions/57372629/how-to-define-pact-specification-matching-rule-for-single-string-body. Help would be much appreciated. We got stuck with this. Thanks!

matt.fellows
2019-08-06 21:33
I had a quick look - the test seemed to run as expected as far as the log is cooncerned

matt.fellows
2019-08-06 21:35
That test file you sent me can?t match that log file. The description doesn?t match (log has ?A user? which is not present in the code)

matt.fellows
2019-08-06 23:01
@uglyog any suggestions?

efroese
2019-08-06 23:05
has joined #general

deshdeepdivakar
2019-08-06 23:47
Hi @here anyone tried http://pact.io for `json-rpc` ?

bethskurrie
2019-08-06 23:50
Try asking in the #pact-rust channel. @uglyog will be able to help you.

matt.fellows
2019-08-07 00:09
not me. Any reason why it wouldn?t work with Pact? Looks like JSON req/res so in theory should be OK?

deshdeepdivakar
2019-08-07 03:32
hi @matt.fellows I thought so, but few something i noticed : For a json-rpc header - should be `Content-Type : application/json-rpc` and if you set the ```context.setTarget(new HttpTestTarget``` it seems to override the header with some default values like `Content-Type : application/json`

matt.fellows
2019-08-07 03:37
Oh! Interesting

matt.fellows
2019-08-07 03:37
which language is this?

deshdeepdivakar
2019-08-07 03:54
`Java`

matt.fellows
2019-08-07 05:05
are you setting the correct headers in your request/response setup?

matt.fellows
2019-08-07 05:05
That doesn?t seem right, Pact shouldn?t modify / coerce any headers

deshdeepdivakar
2019-08-07 05:30
```package consumer; import au.com.dius.pact.consumer.MockServer; import au.com.dius.pact.consumer.Pact; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import org.apache.commons.collections4.MapUtils; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Request; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.io.IOException; import java.util.HashMap; import java.util.Map; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.MatcherAssert.assertThat; import static http://org.hamcrest.core.Is.is; //1. Add the Pact consumer test extension to the test class. @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "messageService", port = "8080") public class rpcConsumerTest { private Map<String, String> headers = MapUtils.putAll(new HashMap<>(), new String[] { "Content-Type", "application/json-rpc" }); //2. create a method annotated with @Pact that returns the interactions for the test @Pact(consumer = "ConsumerService", provider = "messageService") public RequestResponsePact getMessage(PactDslWithProvider builder){ return builder .given("default") .uponReceiving("retrieve message") .path("/message") .method("GET") .willRespondWith() .headers(headers) .status(200) .body( new PactDslJsonBody() .integerType("id") .stringType("jsonrpc", "2.0") .stringType("method", "getMessage") .object("params", new PactDslJsonBody() .stringType("text","rpc-pact-demo") )).toPact(); } //3. Link the mock server with the interactions for the test with @PactTestFor @Test @PactTestFor(providerName = "messageService", pactMethod = "getMessage") void verifyGetMessage(MockServer mockServer) throws IOException { HttpResponse httpResponse = Request.Get(mockServer.getUrl() + "/message").execute().returnResponse(); assertThat(httpResponse.getStatusLine().getStatusCode(), is(equalTo(200))); // assertThat(IOUtils.toString(httpResponse.getEntity().getContent()), // is(equalTo("{\"articles\":[{\"variants\":{\"0032\":{\"description\":\"sample description\"}}}]}"))); } } ```

deshdeepdivakar
2019-08-07 05:31
I think I am setting it up right. Sorry, accidentally posted the whole Consumer spec

deshdeepdivakar
2019-08-07 05:31
``` private Map<String, String> headers = MapUtils.putAll(new HashMap<>(), new String[] { "Content-Type", "application/json-rpc" });``` Json rpc GET request body ``` {"id":"1420197679","jsonrpc":"2.0","method":"getMessage","params":{"text":"rpc-pact-demo"}} ```

deshdeepdivakar
2019-08-07 07:11
@matt.fellows ^ your thoughts please?

matt.fellows
2019-08-07 07:13
Sorry, I?m not across the Java DSL so I can?t respond with any authority, but looks ok to me

matt.fellows
2019-08-07 07:15
might be worth chatting in #pact-jvm to see if there are any people with specific advice?

vineethv
2019-08-07 08:09
has joined #general

c.metz
2019-08-07 08:54
I will. Thanks for your suggestion!

gs201m
2019-08-07 09:17
#general

gs201m
2019-08-07 09:21
Guys, I am trying to run PACT tests on a GOLang based MS. It works well in local but on the CI JENKINSX it always throws me error ?pact-mock-service?: executable file not found. Any help is appreciated.

matt.fellows
2019-08-07 09:39
My guess is that the executables are not on the `PATH`

matt.fellows
2019-08-07 09:39
Prove that's not true first and go from thetr

gs201m
2019-08-07 09:43
@matt.fellows how to set the executables in PATH in Jenkins File (using Jenkins X). In windows local I can do it. But on Jenkins kubernetes how can it be done?

matt.fellows
2019-08-07 09:56
:man-shrugging:

matt.fellows
2019-08-07 09:56
Who manages your Jenkins environment?

matt.fellows
2019-08-07 09:56
Its an environment variable. It just needs to be updated to point at where you've installed pact

uglyog
2019-08-07 10:05
Must be a defect if it is overwriting the header

gs201m
2019-08-07 10:06
That?s the challenge. It?s on JENKINSX on kubernetes. We have to mention in the Jenkins File about the instruction to install and point to the same. Which I am doing. Still no luck.

gs201m
2019-08-07 10:32
@matt.fellows is there any specific way to set path in Jenkins X

matt.fellows
2019-08-07 10:36
Im sorry, I don't know anything about Jenkins X

matt.fellows
2019-08-07 10:37
It looks ok, can you check if the binati s are in that directory and iff you can execute any of them?

matt.fellows
2019-08-07 10:38
Binaries*

antstorm
2019-08-07 10:48
has joined #general

deshdeepdivakar
2019-08-07 11:55
hi @uglyog, @matt.fellows sorry it wasn't overwriting the header. I misread that. ```21:44:57.819 [Test worker] DEBUG au.com.dius.pact.core.matchers.Matching - Found a matcher for application/json-rpc -> au.com.dius.pact.core.matchers.JsonBodyMatcher@7af6e144 returns a response which has status code 200 (FAILED) includes headers "Content-Type" with value "application/json-rpc" (OK) has a matching body (FAILED) Failures: 0) Verifying a pact between ConsumerService and messageService - retrieve message returns a response which has status code 200 expected status of 200 but was 400 1) Verifying a pact between ConsumerService and messageService - retrieve message returns a response which has a matching body / -> Expected empty body but received '[B@348a87ce'```

matt.fellows
2019-08-07 12:09
good to know. So it looks like your API is returning stuff when it shouldn?t?

deshdeepdivakar
2019-08-07 12:12
I wrote a basic -`rpc` service returning a string you pass to it & it works as curl request

deshdeepdivakar
2019-08-07 13:12
I don't think it's replaying the interaction as I can't see any request coming through in my provider service

amber.race
2019-08-07 21:45
has joined #general

brent.foley
2019-08-07 22:20
has joined #general

thirumal.net
2019-08-08 05:49
@uglyog Could you Please guide me here

nikolajs.cmihuns
2019-08-08 05:52
Hi, please help me to get understanding in the following problem. Provider has several http API's - 1,2,3,4. Is it somehow possible to verify api calls chain, the correct order in which api's must be called using PACT. The correct order let's say is 1,2,3,4, but not 1,3,2,4. Would provider state feature help here somehow or it's not the case for PACT testing at all ?

matt.fellows
2019-08-08 05:54
What have you read so far about this? Basically, in Pact you always test 1 API at a time. If you need state to do a call, lookup ?provider states?.

matt.fellows
2019-08-08 05:54
http://docs.pact.io has all of these questions answered in one form or another

matt.fellows
2019-08-08 05:54
see FAQ, best practices etc.

uglyog
2019-08-08 05:55
There are no example projects that I know of that use XML. You'll have to look at the XML tests in the Pact-JVM codebase, like this one https://github.com/DiUS/pact-jvm/blob/master/core/matchers/src/test/groovy/au/com/dius/pact/core/matchers/XmlBodyMatcherSpec.groovy or use the JSON examples but replace the bodies and content types with XML

sayboras
2019-08-08 06:56
has joined #general

nikolajs.cmihuns
2019-08-08 07:08
thanks:+1:

gs201m
2019-08-08 07:38
#general guys I am stuck in implementing pact for GO-LANG over Jenkins X. It always complains that it?s not able to find pact-mock-service not found in path. I am explicitly setting the path in Jenkins file through commands. It?s not working out.- Any helps or pointers is much appreciated.

matt.fellows
2019-08-08 07:44
Can you manually execute the binaries to see if they are present? Have you tried enabling debug/verbose on pact go to see if that provides feedback? What have you tried?

matt.fellows
2019-08-08 07:46
The PATH setting looks ok. Have you tried a `which pact-broker` to see if it finds the binary?

gs201m
2019-08-08 11:02
I am using the latest go-pact validation. Getting an error before

matt.fellows
2019-08-08 12:00
Can you run the pact binaries that you've downloaded? Ignoring pact go for a second, let's get the dependencies working first

oswald.quek
2019-08-08 15:06
it'll be something like `@PactBroker(scheme = "https", host = "http://pact.shared.frigg.il")`

gs201m
2019-08-08 18:33
Yes, pact binary is available and is being invoked. However the mock service is still not starting.

anupamknw
2019-08-08 18:43
has joined #general

luchillo17
2019-08-08 19:31
That section is likely to come from another test in the Auth service/store

matt.fellows
2019-08-08 22:09
What happens when you run `/usr/local/git/bin/pact-mock-service` directly? (not through Pact Go)

thirumal.net
2019-08-09 00:08
Thank you @uglyog

uglyog
2019-08-09 00:11
You can also take this opportunity to be the first to create a sample project for it :smile:

thirumal.net
2019-08-09 00:13
sure:) if my poc goes well , will update you back on the same. Thank you again !:+1:

deshdeepdivakar
2019-08-09 05:21
hi @here I am keen to understand the best practices around maintaining Pact's across different versions. For example : Assume, consumer version 1 defines pact for provider version 1 and next iteration we add some non breaking changes to provider version 1 and incremented provider to version 2 - should I'll be updating the consumer 1 pacts?? How would I ensure backward compatibility if I update my pact fro consumer 1? Please, share your experience. Cheers!!

antonello
2019-08-09 06:47
If it?s only the provider that changes, you shouldn?t make any changes to your consumer tests. Simply provider version 2 will have to verify the pact published by consumer version 1.

matt.fellows
2019-08-09 07:11
:point_up:

matt.fellows
2019-08-09 07:11
Exactly what Anto said

matt.fellows
2019-08-09 07:11
so you can keep making changes to the provider until such point that it breaks one of its consumers - Pact will detect this situation

matt.fellows
2019-08-09 07:13
This is the easiest case. It gets more complex when both consumers and providers are constantly making changes. This is where the Pact Broker comes in handy, and can help you identify which components are compatible at any one moment (the can-i-deploy command is the most useful here)

puja.bhattacharya.pb
2019-08-09 18:28
has joined #general

kbakk
2019-08-10 17:01
has joined #general

kbakk643
2019-08-10 17:16
has joined #general

mohindroo.deepak
2019-08-11 07:57
If provider wants to do some breaking and important changes in the code which effects consumer as well then 1) will provider not able to release those changes till consumer not make their changes? Might be consumer need another week to release those changes. 2) logically provider release pipeline should fail. But how will we intimate this breaking change to all consumers across the company?

matt.fellows
2019-08-11 07:59
1) is the answer. If you do release the changes, then you break the consumers. Why would you want to do that?

matt.fellows
2019-08-11 07:59
You initiate the change by talking to the teams

matt.fellows
2019-08-11 08:00
Ideally, you inplement the change using the expand/contract schema approach

matt.fellows
2019-08-11 08:00
Add new field with new behaviours, wait for consumers to transition to it, deprecate old field

bart.schotten
2019-08-11 08:10
I have question about the Pact Specification (maybe there should be a channel for that): why was the decision made to allow matching rules on requests? I can't think of a scenario in which that would be useful and it seems to go against Postel's Law...

mohindroo.deepak
2019-08-11 08:39
Intimation to the consumers about change will be manual or it is automated with some feature? What are the roles of web hooks here?

bethskurrie
2019-08-11 08:46
I personally don't tend to use it, and recommend strict matching where possible, as I only use pact to unit test the client class that is responsible for communicating with the provider. Some people do use it for higher level tests, in which case the more flexible matching is handy. There's also the case where you can use a generated pact to create a stub service for higher level integrated tests, and it's very useful then.

bart.schotten
2019-08-11 08:57
Right, that last case I can imagine.

matt.fellows
2019-08-11 09:33
I mean. You have to speak to your consumers if you're going to decide break stuff. Period. No tool can automate that for you. But Pact has a number of ways of determining if systems are compatible with one another, the most notable is using can-i-deploy with the broker. But the usual flow is that if you break a consumer on the provider side the provider teams build will fail (because if you release bad things will happen) and that's a prompt to go and speak to people (see the theme here?).

matt.fellows
2019-08-11 09:34
Webhooks are useful, and you could use a webhooks on a failed verification to notify consumers. The usual case is for the opposite - to kickoff builds on the provider side for a new contract/changed contract. You could subscribe to the same event to notify the providers of the change

mohindroo.deepak
2019-08-11 18:37
Thanks

richard.jones
2019-08-11 22:14
If I understand your question correctly, matching on requests (allowing variable parameters to match the request params/payload) is very useful to us because it means we can generate a single pact that handles many different unit test data cases, rather than generating new pacts for each case.

richard.jones
2019-08-12 03:13
Is anyone verifying pacts against AWS lambdas?

uglyog
2019-08-12 03:23
Yes, using message pacts.


bart.schotten
2019-08-12 06:30
I personally wouldn't use Pact for unit tests in this way, but it's always interesting to hear how other people approach things.

antonello
2019-08-12 07:47
I imagine that a common, or at least useful, use case for pact is to verify backwards compatibility of api changes against multiple versions of native mobile applications that users may be using. Obviously in this case there can be more than one consumer version in production. @emanuele.ivaldi and I were discussing this and we were thinking that a possible approach may be to tag consumers, when released, with a tag like ?prod-v1.2.0?. This way, you could run provider verification tests against all the ?live? versions, provided that you keep a list of the current live versions somewhere outside of the broker, as you cannot at the moment query the broker for a tag with wildcards. An alternative approach, as the provider is written in Java, would be to be able to tell pact-jvm: ?verify all pacts with a prod tag and not just the latest one tagged ad prod?. This approach would require removing prod tags from the consumer when versions are deprecated and, obviously, a change to pact-jvm. Thoughts?

matt.fellows
2019-08-12 08:05
My first instinct is to support wildcards or regexes to achieve it, with the behaviour of still retrieving the latest for each tag it finds. I suspect they will have unintended consequences but seems the nicest

matt.fellows
2019-08-12 08:06
The answer we usually give is for the provider to know in advance of sacred tags and include that in the list to verify, but it would be nice automate that

antonello
2019-08-12 08:10
Which - as I explained - would require tagging with something more than just `prod` - in other words the tags need to be aware of the version also, which is a bit of a bastardisation of the tags, but kind of harmless.

fernandojsmoreira
2019-08-12 08:12
has joined #general

matt.fellows
2019-08-12 08:22
yes, indeed it is

matt.fellows
2019-08-12 08:22
it?s definitely a workaround, and not a true first class citizen in the system

bethskurrie
2019-08-12 10:21
@antonello I've designed the API so that you can verify *all* pacts with a given tag, not just the latest.

bethskurrie
2019-08-12 10:21
This is to support mobile consumers that have multiple prod versions.

bethskurrie
2019-08-12 10:22
There is a bit of code in the client that needs to be added to support specifying the "all" instead of just "latest", and I just haven't gotten around to putting that in yet.

antonello
2019-08-12 10:22
that?s great @bethskurrie! However, as far as understand it, `pact-jvm` does not support that (yet).

bethskurrie
2019-08-12 10:22
Someone else has asked for it recently, and I need to do it, but I've been using all my Pact energy on Pactflow, and then I come home and I have nothing for the OSS code.

bethskurrie
2019-08-12 10:22
pact-jvm will soon.

antonello
2019-08-12 10:23
sounds great

bethskurrie
2019-08-12 10:23
There's a new API being written for supporting "pending pacts" which will make the broker a lot smarter in what pacts it returns for verification.

antonello
2019-08-12 10:23
in the meantime, we may have to use the workaround.

bethskurrie
2019-08-12 10:23
Again, it's close to done, but I've had little OSS code time recently.

bethskurrie
2019-08-12 10:24
Yes, if you keep a "manifest" of the prod versions, it will achieve the same thing.

bethskurrie
2019-08-12 10:24
I think it would be easier than trying to do wildcard matching.

gaurav13.singh
2019-08-12 13:52
has joined #general

gaurav13.singh
2019-08-12 13:54
Hi, Does pact supports SOAP api calls??

gaurav13.singh
2019-08-12 13:59
basically my microservices make a soap request to downstream system and convert it back to json to serve client

gaurav13.singh
2019-08-12 14:00
so I need to implement pact between my microservice and the downstream system

nathan2oo3
2019-08-12 14:58
Where in pact brokers http://config.ru does the webhook_host_whitelist need to be set? I have tried it in the config loop and outside it below the basic auth variables but still get the error "for security purposes the response details are not logged. Configure webhook host whitelist"

marius.maaland
2019-08-12 15:57
Yeah I am trying to run against staging. The problem is that `pact-go` doesn't seem to like `https` , because it gives me `read server hello A: unknown protocol` when I try it

matt.fellows
2019-08-12 21:08
Is it a self signed certificate?

matt.fellows
2019-08-12 22:22
Search this channel for that very question. Not all languages support XML but Java + Rust does

richard.jones
2019-08-12 23:15
What do you see as ?in this way??

bethskurrie
2019-08-12 23:22
It just goes where the rest of the config goes. Can you copy paste it here? You definitely restarted the server after making the change?

matt.fellows
2019-08-13 11:30
What language are you using?

gijs.van.der.venne
2019-08-13 12:01
has joined #general

gijs.van.der.venne
2019-08-13 12:05
Hi everyone, We started using Pact testing and am running into an issue. Consumers provide pact contracts that we have to adhere to as provider. We get a nice contract from the consumers stating an event that we did not build yet. So our pact-jvm build is now failing. How can i prevent my build to fail in this case?

matt.fellows
2019-08-13 12:06
So my guess is that the consumers are yet to move to production (because their code wouldn?t work). My guess, is that their work is on a feature branch

gijs.van.der.venne
2019-08-13 12:07
Yes it is in a staging branch indeed but now our application build is failing because we use the central staging branches to comsume the contracts

matt.fellows
2019-08-13 12:08
The usual way of dealing with this, is to get your consumers to only tag what?s in production as e.g. `prod` and your provider only cares about validating things that are in, or about to go to, production

matt.fellows
2019-08-13 12:08
(see https://docs.pact.io/best_practices/pact_nirvana for the full workflow you should follow over time)

matt.fellows
2019-08-13 12:09
(you might use multiple tags, but again, that doc above will illuminate that)

matt.fellows
2019-08-13 12:09
If they are tagging the pact as something that needs to be supported by you straight away, but is not valid, you will need to have a conversation with that team telling them that their feature is not yet ready and that they are breaking your build

matt.fellows
2019-08-13 12:10
Their workflow needs to support reality - right now they?ve told you via a Pact publish that it needs to be supported, and Pact is failing because it doesn?t want that to happen. I?d suggest reviewing your tagging strategy, so that features that aren?t going to production yet don?t fail your build

gijs.van.der.venne
2019-08-13 12:10
Thanks a lot of this information

gijs.van.der.venne
2019-08-13 12:11
am starting to read the documentation and the strategy seems very useful indeed am going over to the team to see if they tagged anything :slightly_smiling_face:

matt.fellows
2019-08-13 12:13
:thumbsup:

matt.fellows
2019-08-13 12:14
you?re welcome!

nathan2oo3
2019-08-13 15:02
dc = PactBroker::DockerConfiguration.new(ENV, PactBroker::Configuration.default_configuration) dc.pact_broker_environment_variables.each{ |key, value| $http://logger.info "#{key}=#{value}"} app = PactBroker::App.new do | config | config.logger = $logger config.database_connection = create_database_connection(config.logger) config.database_connection.timezone = :utc config.enable_public_badge_access = true config.enable_badge_resources = true config.webhook_host_whitelist = dc.webhook_host_whitelist config.webhook_http_method_whitelist = dc.webhook_http_method_whitelist config.webhook_scheme_whitelist = dc.webhook_scheme_whitelist #You should set these to appropriate values for your organization config.webhook_host_whitelist = ['http://host.domain.com'] # For security reasons, it is not recommended to alter this list (see below) config.webhook_http_method_whitelist = ['POST'] config.webhook_scheme_whitelist = ['https'] config.base_equality_only_on_content_that_affects_verification_results = dc.base_equality_only_on_content_that_affects_verification_results config.order_versions_by_date = dc.order_versions_by_date config.disable_ssl_verification = dc.disable_ssl_verification end

nathan2oo3
2019-08-13 15:02
Currently how we have it configured. Apologies about the formatting seems mobile app doesn't have code formatting

li.poltorak
2019-08-13 21:51
has joined #general

li.poltorak
2019-08-13 22:10
Hi, I'm working with a couple of other SDETs and QA engineers across teams at my company to test out pact and see if it will work for our needs, we're just putting together a quick proof-of-concept to learn more about the tool. In the particular case I'm testing, the consumer is a python api and the provider is a php (laravel) api. I was wondering, is it required to set up a provider states url for the provider, even if I'm just testing a GET request for a resource I know exists?

matt.fellows
2019-08-13 22:11
Awesome!

matt.fellows
2019-08-13 22:12
Nope, for a lot of cases you can get by with out them. I still like to document the state itself (because it makes for more readible test cases and clarity) but don?t act on the provider state during validation

matt.fellows
2019-08-13 22:12
In many cases, I single (well designed) database fixture on the provider side can take care of most states

matt.fellows
2019-08-13 22:12
e.g. `given user A exists` and `given user B does not exist` is an easy thing to implement

matt.fellows
2019-08-13 22:13
doing `given user A exists` and `given user A does not exists` requires different data to be seeded during verification.

li.poltorak
2019-08-13 22:25
It looks like `.given('user A exists')` or whatever is required, and if there's nothing set up on the provider-side for that, it fails validation (`Could not find provider state "user A exists" for consumer...`). Is there a way to set it up to not require it? Or not expect it in the consumer test?

li.poltorak
2019-08-13 22:25
I'm new to this concept, so forgive me if I'm missing something obvious.

matt.fellows
2019-08-13 22:53
hmmm

matt.fellows
2019-08-13 22:53
that might be a bug on the PHP code - it shouldn?t fail the test if not present, just emit a warning

matt.fellows
2019-08-13 22:54
Are you sure it?s an error and failing the test? If it is, perhaps omit them for now, and raise an issue on the GitHub repo?

li.poltorak
2019-08-13 22:56
Hmmm, ok. I'm using the docker pact verifier to run the verification: https://github.com/DiUS/pact-provider-verifier-docker

li.poltorak
2019-08-13 22:56
Maybe I have something configured wrong there.

li.poltorak
2019-08-13 22:59
```WARN: the following non-mandatory environment variables have not been specified: '["provider_states_url", "provider_states_active_url"]' Reading pact at /tmp/pacts/consumer-provider.json Verifying a pact between Consumer and Provider Given a request for reservation 12345 with GET /v1/reservations/12345 returns a response which has status code 200 (FAILED - 1) has a matching body (FAILED - 2) Failures: 1) Verifying a pact between Consumer and Provider Given a request for reservation 12345 with GET /reservations/12345 returns a response which has status code 200 Got 0 failures and 2 other errors: 1.1) Failure/Error: set_up_provider_state interaction.provider_state, options[:consumer] RuntimeError: Could not find provider state "" for consumer Consumer # /usr/local/bundle/gems/pact-1.14.0/bin/pact:4:in `<top (required)>' # /usr/local/bundle/bin/pact:17:in `load' # /usr/local/bundle/bin/pact:17:in `<main>' 1.2) Failure/Error: tear_down_provider_state interaction.provider_state, options[:consumer] RuntimeError: Could not find provider state "" for consumer Consumer # /usr/local/bundle/gems/pact-1.14.0/bin/pact:4:in `<top (required)>' # /usr/local/bundle/bin/pact:17:in `load' # /usr/local/bundle/bin/pact:17:in `<main>'```

li.poltorak
2019-08-13 23:00
There's the output of the tests.

matt.fellows
2019-08-13 23:00
hmm interesting

matt.fellows
2019-08-13 23:00
in that case, could you please raise a bug there :stuck_out_tongue:

li.poltorak
2019-08-13 23:00
Absolutely, will do!

matt.fellows
2019-08-13 23:00
thank you

matt.fellows
2019-08-13 23:00
presumably it works without the states defined, yes?

li.poltorak
2019-08-13 23:17
I'm not sure how to not define them. If I leave the line out of the consumer test, it fails.

li.poltorak
2019-08-13 23:19
Here's the error: ```self = <pact.pact.Pact object at 0x10bfed080>, scenario = 'a request for reservation 12345' def upon_receiving(self, scenario): """ Define the name of this contract. :param scenario: A unique name for this contract. :type scenario: basestring :rtype: Pact """ > self._interactions[0]['description'] = scenario E IndexError: list index out of range```

matt.fellows
2019-08-13 23:23
Is that the description or the state? The description is definitely mandatory

li.poltorak
2019-08-13 23:25
I'm working off of the example from the pact-python github page (with specifics changed out for our particular test case of course) ```(pact .given('UserA exists and is not an administrator') .upon_receiving('a request for UserA') .with_request('get', '/users/UserA') .will_respond_with(200, body=expected))```

li.poltorak
2019-08-13 23:25
And it seems like whatever I put in the `.given('UserA exists and is not an administrator')` is what fails when I try to run the verification.

li.poltorak
2019-08-13 23:26
But if I try to leave that line out, it will fail in the above manner.

li.poltorak
2019-08-13 23:26
I'm not sure if that's the description or the state.

matt.fellows
2019-08-13 23:26
weird

matt.fellows
2019-08-13 23:26
because https://github.com/pact-foundation/pact-python#verifying-pacts-against-a-service says to do it without provider states (to start with)!

li.poltorak
2019-08-13 23:29
It looks like it fails with a different error (authentication, which I expected) if I run the verification command as shown in that example, using pact-python, from the consumer API's repo, so I imagine it's either a bug or a misconfiguration in the docker verifier I was trying to use from the provider. Running the verification from that python project won't work in the long run, but it's perfectly fine for local testing and can unblock me to keep exploring pact, so that's good! :slightly_smiling_face:

matt.fellows
2019-08-13 23:42
ok perfect

li.poltorak
2019-08-13 23:42
Thank you so much for your help! I really appreciate it.

matt.fellows
2019-08-13 23:42
apologies, sometimes the language implementations have their minor differences

matt.fellows
2019-08-13 23:42
we?ll get it sorted - if you raise the issue typically it?s sorted within a day or two

li.poltorak
2019-08-13 23:43
Thank you!

matt.fellows
2019-08-13 23:43
FYI if you need a quick space to test pact publishing / workflows with e.g. can-i-deploy, you should checkout http://pactflow.io :wink:

matt.fellows
2019-08-13 23:43
if you need more than a few contracts let me know and I can bump up the plan (we?re reviewing the free tier at the moment)

li.poltorak
2019-08-13 23:43
I'll look into it!

bethskurrie
2019-08-14 04:07
Ah, if you're messing with the docker one, you just need to set the right env vars @nathan2oo3

bart.schotten
2019-08-14 06:40
I prefer keeping my (functional) unit tests entirely separate from my contract tests, so I never felt the need to have a single interaction handle multiple test cases.

antonello
2019-08-14 07:47
Is there a piece of documentation that explains which versions of the DSLs are compatible with v3 of the pact specification?

uglyog
2019-08-14 07:49
This is the only docs I know of: https://docs.pact.io/feature_support

antonello
2019-08-14 07:50
Thank @uglyog. I know it existed but could not find it. Still :sleeping:

antonello
2019-08-14 07:52
Is v3 supported in pact-jvm 3.6.x or only in v4?

bethskurrie
2019-08-14 07:52
No pressure, but @tanle.oz may be having a go at v3 for Ruby ;-)

antonello
2019-08-14 07:52
I was reading your recent blog post on provider states @uglyog

uglyog
2019-08-14 08:29
V3 is supported since 3.2+

nikolajs.cmihuns
2019-08-14 09:52
Hi, is there some documentation on how to read error message when pact test fails. E.g I use https://github.com/DiUS/pact-jvm/blob/b370475f0107c16ab498d488fe09c005cff037ad/provider/pact-jvm-provider/src/main/kotlin/au/com/dius/pact/provider/junit/JUnitProviderTestSupport.kt#L24 And output looks to me unreadable. Does pact-jvm have some human readable processor of error output string ?

nikolajs.cmihuns
2019-08-14 10:00
I mean, does one have to manually cast what is in place of Any (mismatches: Map<String, Any>), and act accordingly further

nikolajs.cmihuns
2019-08-14 10:00
Is it the only option available currently ?

matt.fellows
2019-08-14 12:15
V3 in Ruby btw means we get it in JS, Go, python, PHP and . NET

hendrik.diel
2019-08-14 12:29
has joined #general

hendrik.diel
2019-08-14 12:52
Hi, i wonder if there is a planned release date for 4.0.0-beta.5? We are waiting for the fix of issue #908 and #912.

sandro.schifferle
2019-08-14 13:04
has joined #general

richard.jones
2019-08-14 22:42
Interesting! Our pact mocks are just part of our regular test suite mocking. As in, we don?t mock downstreams in any other way other than in exceptional circumstances (like ensuring a 500 response is handled well)

bethskurrie
2019-08-14 22:44
Are you talking about the consumer side or the provider side Richard? I think Bart is talking consumer side.

uglyog
2019-08-14 22:52
I see about getting a release out for you

marius.maaland
2019-08-14 23:50
no I don't believe so

richard.jones
2019-08-15 00:04
I?m talking consumer side, yes.

nikolajs.cmihuns
2019-08-15 06:15
@uglyog

uglyog
2019-08-15 06:18
Are you referring to the actual values which are displayed as `List(Map(code -> 101, order -> 1, timestamp -> 1970-01-01T00:00:11.113Z)`?

nikolajs.cmihuns
2019-08-15 06:22
yes, it is taken from real test if I've got you correct

nikolajs.cmihuns
2019-08-15 06:25
looks like we need additional case for List inside JUnitProviderTestSupport.generateErrorStringFromMismatches

nikolajs.cmihuns
2019-08-15 06:26
I will recheck

uglyog
2019-08-15 06:27
I think the JUnit error output needs to be better presented in general


bart.schotten
2019-08-15 06:55
I try to keep my api client code (the code that I test with Pact) very minimal. The only thing it should do is perform a request to the right path and correctly deserialize the response. All the functional handling around that is done by other code, in which I can then mock the api client, so I don't need Pact (or another http mock service) to test it.

mdilts11
2019-08-15 14:18
has joined #general

itsmanishahere
2019-08-15 14:33
has joined #general

pijush.debnath
2019-08-15 17:54
has joined #general

marius.maaland
2019-08-15 19:07
is pact-go trying to use SSLv2/v3 ? cause that's disabled in my certificate

vinay.luz
2019-08-15 20:24
has joined #general

richard.jones
2019-08-15 22:19
Cool, thanks for the info, and your usage is something I have definitely seen around. FWIW my intent is to ensure that the data going to/from the API call reflects the code using that API, rather than whether I can call the HTTP library correctly.

david862
2019-08-15 22:48
has joined #general

chuck
2019-08-16 18:03
has joined #general

sgriffiths1975
2019-08-19 03:21
has joined #general

archana.rachuri
2019-08-19 23:24
has joined #general

getsreerag22
2019-08-20 05:33
@here Is there anyway I can convert Swagger into Pact????

uglyog
2019-08-20 05:36
Not currently. The problem is that swagger is defined in terms of the API endpoint. I.e. here is an endpoint, it accepts these parameters and here is the list of possible responses. But there is no automatic way to know which request corresponds to which response.


getsreerag22
2019-08-20 05:48
Thank you @bethskurrie

matt.fellows
2019-08-20 05:53
As an aside though, we are working on and thinking about how to marry Pact and Swagger better together at Pactflow. Ping one of us offline if you?d like to be part of this discovery and product development process

vaishnavi.boyidi
2019-08-20 07:38
has joined #general

fil.tmb
2019-08-20 10:58
has joined #general

philusd
2019-08-20 11:46
has joined #general

simon.waterhouse
2019-08-20 14:12
has joined #general

vinoth.raman
2019-08-20 15:26
has joined #general

vinoth.raman
2019-08-20 15:32
Vinoth Raman [4:29 PM] I am trying to setup a pact test for one of the project. unfortunately, I could not PACT dal file created after the successful build.Here is my code

vinoth.raman
2019-08-20 15:32
package com.test; import au.com.dius.pact.consumer.Pact; import au.com.dius.pact.consumer.PactProviderRuleMk2; import au.com.dius.pact.consumer.PactVerification; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.model.RequestResponsePact; import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import java.util.HashMap; import java.util.Map; public class consumertest { @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test_provider", "localhost", 8080, this); @Pact(consumer = "test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json"); return builder.given("test GET").uponReceiving("GET REQUEST").path("/pact").method("GET").willRespondWith().status(200).headers(headers) .body("{\"condition\": true, \"name\": \"tom\"}").given("test POST").uponReceiving("POST REQUEST").method("POST") .headers(headers).body("{\"name\": \"Michael\"}").path("/pact").willRespondWith().status(201).toPact(); } @Test @PactVerification() public void givenGet_whenSendRequest_shouldReturn200WithProperHeaderAndBody() { } }

vinoth.raman
2019-08-20 15:33
Vinoth Raman [4:30 PM] <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd%22> <modelVersion>4.0.0</modelVersion> <groupId>com.test</groupId> <artifactId>test</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer-junit_2.11</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-consumer_2.11</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-model</artifactId> <version>3.5.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.18</version> </plugin> </plugins> </build> </project>

vinoth.raman
2019-08-20 15:33
Could some possibly point me where the issue is please?

mail.colin.smith
2019-08-20 19:20
has joined #general

lgaete.astudillo
2019-08-20 19:30
has joined #general

afrancoh
2019-08-20 19:34
has joined #general

kyle.hammond
2019-08-20 20:43
You have no code in the givenGet_whenSendRequest_shouldReturn200WithProperHeaderAndBody method. In that method you should have your client code connect to the mock server, make the network request, and assert that your code behaves correctly with the expected response.

matt.fellows
2019-08-20 22:04
Could you please ask this on #pact-jvm ?

matzalew
2019-08-21 05:46
has joined #general

ben.minter
2019-08-21 08:26
has joined #general

samuel.hodgkinson
2019-08-21 11:12
has joined #general

matchehot
2019-08-21 17:42
has joined #general

matchehot
2019-08-21 17:49
Hi, has anyone used jvm XmlBodyMatcher to match response body?

matchehot
2019-08-21 17:49
looking for examples

danavery
2019-08-21 22:23
has joined #general

g.maguire85
2019-08-21 23:34
has joined #general

kresimir.kuren
2019-08-22 13:03
has joined #general

david862
2019-08-22 18:06
Hey, I?m curious about pact best practices (and I need to convince my team to use them). Does anyone have any good resources?

marius.maaland
2019-08-22 18:28
There's a section about this in the documentation: https://docs.pact.io/best_practices Is there anything in particular you're curious about?

david862
2019-08-22 18:31
Yeah - I had looked at that pretty thoroughly, but thanks. I?m specifically curious about how much of the consumer to include in the contract test. My team?s assumption is that we should only be including the API call to the provider, and ensuring the right data is returned, but I was under the impression you want to make sure the consumer actually does what you are expecting with the data (more than just deserialization, I mean.)

david862
2019-08-22 18:33
For example we have a service that tells us if a customer is blacklisted, should the pact test include just `service.get('/is-blacklisted?q=john+smith')` or something a bit higher up like a consumer method that calls that endpoint and returns a boolean?

thirumal.net
2019-08-22 21:11
Hi @david862 - i think your team assumption is correct . as a consumer ,we have to make sure provider is returring 200 Ok status and data we need to continue consumer logic. we can still go ahead and verify the data but i think that is not the purpose of contract testing . verifying data should be part of another testing not contract testing . if we have microservice architecture and lot of services are there , it is not ideal to check data instead we have to verify minimum things (200, mandatory attributes from provider) which will make the total CI/CD process quick

nathan2oo3
2019-08-23 09:16
Sorry for the late reply Beth. I noticed in the docs about setting http_proxy environment for executing via an http proxy but other than that is there any other environment variables I need to set? I have already set the PACT_BROKER_LOG_LEVEL: DEBUG in the docker compose file


bethskurrie
2019-08-23 20:45
"PACT_BROKER_WEBHOOK_SCHEME_WHITELIST - a space delimited list (eg. http https). Defaults to https."

bethskurrie
2019-08-24 07:12
I like to include enough of the consumer to ensure that I'm not just testing an HTTP request. I generally have a "XYZClient" class that is responsible for translating between my internal domain and the way the provider represents the data. I like to check that my client does the right translations, serialises the data the right way (though I do tend to keep that serialisation logic in a separate class) and handles the different responses the way I want (eg. 404 might return a null object, a 500 might raise an exception)

bethskurrie
2019-08-24 07:13
I don't tend to include the service layer.

bart.schotten
2019-08-24 10:38
Can a v3 Pact include both messages and (request-response) interactions? This is not entirely clear to me from the spec.

uglyog
2019-08-24 23:34
No, they have to be separate. That?s something we?re planning for the v4 format

bart.schotten
2019-08-25 07:16
v3 isn't final yet is it? :wink: At least, the readme makes it seem like it's still in a "proposal" state, and not everything is covered by testcases.

uglyog
2019-08-25 07:25
V3 was released with Pact-VM over two years ago. It would not be fair to users to change it now

bart.schotten
2019-08-25 09:48
One other small question about the "include" matcher: does the check that the actual value is included in the expected value, or the other way around? And is it only supposed to work with strings?

uglyog
2019-08-25 22:45
Yes, it works on strings and checks that the actual value includes the value associated with the matcher.

jenpresly18.jps
2019-08-26 04:55
has joined #general

bart.schotten
2019-08-26 05:29
Thanks!

r.deboer
2019-08-26 14:37
has joined #general

gcao
2019-08-26 19:31
has joined #general

rikkiprince
2019-08-26 22:50
has joined #general

serge.a.silva
2019-08-27 07:09
has joined #general

serge.a.silva
2019-08-27 07:23
Hey everyone! Following up from this issue https://github.com/pact-foundation/pact-net/issues/197#issuecomment-525138624 as suggested by Beth. Pact-net has been flagged for having a CVE that comes from the version of Ruby that was bundled with it. In the above thread, I mention two CVEs. The first one is a false negative, but the second is correct and it is flagged with maximum severity. We're trying to ramp up my team to use it, but having been flagged means we'll have to look at something else. Beth mentioned there's plans to port pact-net to switch over to the Rust implementation (instead of bundling Ruby in the DLL). I'd like to continue using Pact. What would be the best way to move forward and get green on pact-net? If rewriting part of it to rely on the Rust version, have there been other examples of pact implementations that are based off of the Rust one? Is there a quicker solution? Thanks!

matt.fellows
2019-08-27 07:55
hiya!

matt.fellows
2019-08-27 08:12
OK so we?d love some help on this

matt.fellows
2019-08-27 08:13
Here is an example PoC that Ron put together that implements an MVP pact JS interface build on the rust bindings: https://github.com/uglyog/pact-js-v3-poc

matt.fellows
2019-08-27 08:13
We literally discussed this today

matt.fellows
2019-08-27 08:16
I?ll ping you again a little later to discuss more, just getting to the end of my train journey :slightly_smiling_face:

matt.fellows
2019-08-27 08:16
but sufficed to say - this is moving toward the top of my list for JS/Golang

serge.a.silva
2019-08-27 08:17
Nice, I'll take a look!

serge.a.silva
2019-08-27 08:17
Sure ping me when available, I'd also like to have a rough estimate of how long this will take me!

serge.a.silva
2019-08-27 08:31
Could code under native be reused?

serge.a.silva
2019-08-27 08:44
(I'm not a rust expert :smile:)

matt.fellows
2019-08-27 13:34
Anyone here based in Perth? Beth will be visiting next week... https://www.linkedin.com/posts/bethanyskurrie_activity-6571535304581312512-ElaI

matt.fellows
2019-08-27 13:35
Cc: @neil :point_up:

alvina.putri
2019-08-27 20:30
has joined #general

nathan2oo3
2019-08-27 21:21
Thanks @bethskurrie that helped a lot. One thing though I have tried running your Ruby script for inserting self signed certs but keep getting errors even after installing the dependent gems. Is it possible to manually import the certs into the database?

matt.fellows
2019-08-27 23:15
So the short answer is no, the code there wouldn?t be reusable, because it uses Neon which is a Rust to JS interface. This has benefits (no need for the ugly FFI bindings) but means that we?ll need a small wrapper for each language to achieve it. The alternative is a shared dynamic library, which means we can write it once, but will have some of the downsides of ?crossing the boundary?. It might be a situation that we start with that, and evolve to another interface

matt.fellows
2019-08-27 23:16
@uglyog might have other thoughts, however

serge.a.silva
2019-08-28 00:07
Since I'd like to keep using Pact, I'd prefer the quicker way (of course, in a way that can be improved overtime) :smiley:

uglyog
2019-08-28 00:12
A wrapper in each language over a shared library means that you can create DSLs and tooling that take advantage of the idioms specific to that language. A shared library designed to be used by everyone means the interface becomes the "lowest common denominator", in essence a C interface.

serge.a.silva
2019-08-28 00:18
So a shared library still seems useful?

uglyog
2019-08-28 00:19
There is an existing shared library. The interface still needs some work.

uglyog
2019-08-28 00:21
There is an example of using it with Javascript, Ruby and C here :point_right: https://github.com/pact-foundation/pact-reference

serge.a.silva
2019-08-28 00:21
Oh, which one is it? I'd like to at least plan out the work we'll need to do for a replaced C# version

serge.a.silva
2019-08-28 00:21
Nice :+1:

serge.a.silva
2019-08-28 00:27
Would the current C# dsl/library be a good end result to aim for (ie only change the implementation)? Or is it in your plans to change them too?

uglyog
2019-08-28 00:30
I would try to reuse what is there. That's what I did with the Javascript POC, I took an existing JS test and got it working using the shared library

serge.a.silva
2019-08-28 00:31
Great, I'll do that then.

uglyog
2019-08-28 00:32
If you need any help, let me know. I was planning at looking into the .NET implementation after I'm done with the JS one

serge.a.silva
2019-08-28 00:32
Thanks folks! I'll be sure to come back here with some news :smile: How stable is the Rust implementation btw?

uglyog
2019-08-28 00:32
It's been used by a few people

deshdeepdivakar
2019-08-28 08:27
hi @here can we generate `RequestResponsePact` automatically. So, that I don't have to write the json body myself. I read somewhere using jackson object mapper but not entirely sure. Please share your thoughts. ```package example.consumer import au.com.dius.pact.consumer.dsl.PactDslJsonBody object PactUtil { fun jsonRpcMethodRequest(methodName: String): PactDslJsonBody = PactDslJsonBody() .stringType("id") .stringType("jsonrpc", "2.0") .stringType("method", methodName) fun jsonRpcMethodResponse(): PactDslJsonBody = PactDslJsonBody() .stringType("id") .stringType("jsonrpc", "2.0") }```

evman182
2019-08-28 22:43
has joined #general

matt.fellows
2019-08-28 22:47
I'm not sure if a tool exists, but I suppose it's possible to write one?

matt.fellows
2019-08-28 22:47
As long as you still write the test case around it, it's a viable approach.

matt.fellows
2019-08-28 22:48
In go, we use tags (like an annotation) that dry the tests up in the way you describe

jing.song
2019-08-29 04:04
has joined #general

sarajcarbajal
2019-08-29 09:16
has joined #general

joao
2019-08-29 13:31
has joined #general

christopher.f.almanza
2019-08-29 15:17
People who are experienced with Pact, what do you find useful to put in the `upon receiving` property of a Pact Interaction object:

christopher.f.almanza
2019-08-29 15:18
1. a sentence that describe an operation: `uponReceiving: 'a latest news request'`

christopher.f.almanza
2019-08-29 15:18
2. the actual endpoint: `uponReceiving: 'GET /news'`

christopher.f.almanza
2019-08-29 15:19
please vote with a :thumbsup: emoji, and thank you very much :slightly_smiling_face:

enrique
2019-08-29 15:21
I?d reword a bit, something like `'a request to get the latest news'` or `'a query to get the latest news about the market'` or something similar

christopher.f.almanza
2019-08-29 16:07
Quick question, does matcher `like() / somethingLike()` will match by type also properties that are array of objects? ie: ``` student: somethingLike({ firstName: 'john', courses: [{ name: 'Math', }], }) ``` will the courses `name` be also matched by type?

david862
2019-08-29 17:54
Thanks for the feedback, how would you ensure that a mock return value for the XYZClient class, used in the test for some part of the service layer, stays in sync with the response in the contract test?

davidjgmendes
2019-08-29 18:11
Greetings, I am finding a weird (at least for me) behavior when validating contracts on the provider side using junit. The verifications results are only published whenever they are successful. For example: I forgot to implement a state change on the provider side that was defined on the consumer side. The test failed because i didn't implement it but because the result of that specific pact fragment was not published the matrix said i could deploy. I don't understand this behavior can someone clarify. Thanks in advance

davidjgmendes
2019-08-29 19:02
Is this behavior intended ?

akhteraa
2019-08-29 19:24
has joined #general

uglyog
2019-08-29 22:53
Yes, the matchers cascade

uglyog
2019-08-29 22:54
No, that seems like a defect

kian.leong
2019-08-30 08:08
has joined #general

davidjgmendes
2019-08-30 08:39
I thought so, I can PM u some more detailed information if that would help

uglyog
2019-08-30 09:37
Raise an issue for that, please.

simon.nizov
2019-08-30 09:53
Hi all, I was getting the following error when trying to publish verification results back to the broker: ``` Error returned from verification results publication 400 {"errors"=>{"provider_version"=>["can't be blank", "Version number '' cannot be parsed to a version number. The expected format (unless this configuration has been overridden) is a semantic version. eg. 1.3.0 or 2.0.4.rc1"]}} (Pact::Provider::VerificationResults::PublicationError) ``` Downgrading the `pact` gem version from `1.41.0` to `1.26.0` solved the issue. I?m running the official Dockerized broker version `dius/pact-broker:2.27.6-2`. What is this about? Were there braking changes since that release?

bethskurrie
2019-08-30 09:54
We're up to 2.36

bethskurrie
2019-08-30 09:54
That's a very old version.

bethskurrie
2019-08-30 09:55
The latest Pact Broker versions just order the provider version by date. You don't need a semantic version number

bethskurrie
2019-08-30 09:57
It does also look like your provider version is empty.

simon.nizov
2019-08-30 09:59
I think it's passed to the broker under a different name

simon.nizov
2019-08-30 09:59
Same exact configurations in pact_helper.rb but with the downgraded version works like a charm

bethskurrie
2019-08-30 09:59
It should be "providerApplicationNumber". Pretty sure the publishing code is fine. Just upgrade your broker.

bethskurrie
2019-08-30 10:00
Hm. I'd recommend upgrading to the latest.

simon.nizov
2019-08-30 10:00
Will do. Thanks!

bethskurrie
2019-08-30 10:00
There are performance and other issues with the older versions, including a vulnerability with the webhooks.


davidjgmendes
2019-08-30 10:04
if u need more info say something

apurvjpatel
2019-08-30 13:05
has joined #general

nyarasha
2019-08-30 18:37
has joined #general

priyank.shah217
2019-08-31 11:56
I am new to PACT, Have a question: In my consumer side, i am able to generate pact file with json array (2 entries) with some fields. The json contract uploaded to pact-broker successfully. But while running this file against producer, which basically ingest some random data on those json fields (entries may vary, and data could be any random). due to this eventually my contract test failed. returns a response which has status code 200 (OK) has a matching body (FAILED) So now question is i am more interested into json schema, not in content matching. Is there any way to just focus on those part using pact.

priyank.shah217
2019-08-31 12:03
Do i need to set state from provider side in order to get matched response ? (using directly ingesting data into repository)?

simon.nizov
2019-08-31 12:14
I suggest you have a look here: https://docs.pact.io/getting_started/matching#response-matching On one hand, ?it doesn?t matter what value the provider actually returns during verification, as long as the types match?. On the other, it?s not recommended to use random data for pacts because it will fool the broker into thinking that the pact has changed which will cause some unwanted behavior.

priyank.shah217
2019-08-31 13:30
Thanks @simon.nizov

priyank.shah217
2019-09-01 04:54
I really done my weekend exercise successfully by implementing pact for one of pet project. https://github.com/priyankshah217/ContractTestingExample.git Nice documentation @bethskurrie @uglyog and whole pact team...

simon.nizov
2019-09-01 14:18
@bethskurrie I upgraded our broker to the latest version and still getting the same error :cold_sweat:

simon.nizov
2019-09-01 14:18
Is there an easy way to log the full HTTP request sent to the broker?

serge.a.silva
2019-09-01 21:11
a bit challenging to build pactnet on a mac :slightly_smiling_face:

simon.nizov
2019-09-01 21:29
More on my issue above.. I managed to track down the specific change that is causing my issue. In the release of `v1.27.0` of the Pact gem there is a change in the way the gem calls the broker. `#to_json` is not called on `verification_result` anymore. See here: https://github.com/pact-foundation/pact-ruby/compare/v1.26.0..v1.27.0#diff-2aa19ad532bad3f2050ce3b3aff47b0dL94 The `to_json` method is critical because it translates `provider_application_version` to `providerApplicationVersion`. Not calling it causes the payload sent to the broker to change from what it?s like in `v1.26.0`: `{success:false, providerApplicationVersion": "1.0.0.fake"}` to what it?s like in `v1.27.0`: `{publishable: true, success: false, provider_application_version: "1.0.0.fake", test_results_hash: {?}}` The broker then throws a validation error due to not finding the `providerApplicationVersion` key. As can be seen in the following spec: https://github.com/pact-foundation/pact_broker/blob/master/spec/lib/pact_broker/api/contracts/verification_contract_spec.rb#L74 But if what I?m saying is correct, how is publishing provider verification results working for anyone that is using the latest versions of pact? Am I going crazy here? Any help is welcome!

matt.fellows
2019-09-01 21:43
Thank you! :pray:

milleniumbug
2019-09-02 09:09
has joined #general

milleniumbug
2019-09-02 14:08
I am interested in the efforts of writing a C# wrapper over a Rust library myself. @serge.a.silva is your repository public anywhere?

serge.a.silva
2019-09-02 14:21
I was working on top of pactnet (which is public) but didn't get very far.

milleniumbug
2019-09-02 14:25
Fair enough. I'm gonna do the same approach for now.

serge.a.silva
2019-09-02 14:26
Do create a branch when you get somewhere!

milleniumbug
2019-09-02 14:27
sure

florian.nagel
2019-09-03 07:46
I'm unfortunately based in Germany, but I'd still like to see the talk. Will it be recorded and published online afterwards by any chance?

matt.fellows
2019-09-03 08:02
Beth has given this talk before, I?ll dig up the link?

florian.nagel
2019-09-03 08:02
Ah! Thanks a bunch


matt.fellows
2019-09-03 08:06
It?s not quite the same talk, but the gist is: https://www.youtube.com/watch?v=79GKBYSqMIo&feature=youtu.be

florian.nagel
2019-09-03 08:06
Thanks Matt! Will check it out :smile:

emils.solmanis
2019-09-03 12:56
has joined #general

patryk.skrzymowski
2019-09-03 13:01
has joined #general

thomas.rappos
2019-09-03 23:19
has joined #general

abhishek04002
2019-09-04 01:35
has joined #general

matt400
2019-09-04 03:39
has joined #general

lotsabackscatter
2019-09-04 03:39
has joined #general

simon.nizov
2019-09-04 07:47
@bethskurrie @matt.fellows - I would love your input on this

bethskurrie
2019-09-04 07:51
Hey. Let me have a look.

bethskurrie
2019-09-04 07:58
Yes, you can turn --verbose on @simon.nizov

bethskurrie
2019-09-04 07:59
Ok, so the results I just published look like this: ``` { "providerName": "Pact Broker", "providerApplicationVersion": "0ec26e835373b56410e2b69371e99fa254943e76", "success": false, "verificationDate": "2019-09-04T10:36:21.885+10:00", ```

bethskurrie
2019-09-04 07:59
I'm on version 1.41.0 of pact

bethskurrie
2019-09-04 08:00
If you're on 1.27, then I think there was a bug in that version that has been fixed since.

bethskurrie
2019-09-04 08:02
Which language are you running your verifications in?

simon.nizov
2019-09-04 08:08
Ruby, Pact v1.41.0

simon.nizov
2019-09-04 08:10
Which component is responsible for building that payload?

bethskurrie
2019-09-04 08:10
``` class VerificationResult def initialize publishable, success, provider_application_version, test_results_hash @publishable = publishable @success = success @provider_application_version = provider_application_version @test_results_hash = test_results_hash end def publishable? @publishable end def provider_application_version_set? !!provider_application_version end def to_json(options = {}) { success: success, providerApplicationVersion: provider_application_version, testResults: test_results_hash }.to_json(options) end def to_s "[success: #{success}, providerApplicationVersion: #{provider_application_version}]" end private attr_reader :success, :provider_application_version, :test_results_hash end ```

simon.nizov
2019-09-04 08:11
So where are `providerName` and `verificationDate` coming from in your payload? :S

bethskurrie
2019-09-04 08:12
good question

bethskurrie
2019-09-04 08:13
oh, that's the response

bethskurrie
2019-09-04 08:13
they get added

bethskurrie
2019-09-04 08:13
let me find the request

bethskurrie
2019-09-04 08:14
``` opening connection to localhost:9292... opened <- "POST /pacts/provider/Pact%20Broker/consumer/Pact%20Broker%20Client/pact-version/dd27a7b453e63d32428f48f772eb93cd7e525e7f/verification-results HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json, */*\r\nUser-Agent: Ruby\r\nContent-Type: application/json\r\nAuthorization: [redacted]\r\n" <- "{\"success\":false,\"providerApplicationVersion\":\"0ec26e835373b56410e2b69371e99fa254943e76\",\"testResults\":{\"tests\":[{\"testDescription\":\"has status code 200\",\"testFullDescription\" ```

bethskurrie
2019-09-04 08:14
I just hacked `@verbose = true` in `lib/pact/hal/http_client.rb`

bethskurrie
2019-09-04 08:15
what version of ruby are you using?

simon.nizov
2019-09-04 08:15
2.6.3

bethskurrie
2019-09-04 08:16
hm. I don't have 2.6 on this machine, and I can't install it over hotel wifi to try it unfortunately.

simon.nizov
2019-09-04 08:17
That?s so weird that I?m getting this payload: `{publishable: true, success: false, provider_application_version: "1.0.0.fake", test_results_hash: {?}}` then

simon.nizov
2019-09-04 08:17
who is calling `to_json` on `verification_result`?

bethskurrie
2019-09-04 08:18
I'm not sure myself. I'm just investigating.

simon.nizov
2019-09-04 08:19
:thinking_face:

simon.nizov
2019-09-04 08:19
Which ruby are you using? I?ll install it and try

bethskurrie
2019-09-04 08:19
2.4.5

bethskurrie
2019-09-04 08:20
I've got 2.5.1 though

bethskurrie
2019-09-04 08:26
``` def post(payload = nil, headers = {}) wrap_response(href, @http_client.post(href, payload ? JSON.dump(payload) : nil, headers)) end ```

bethskurrie
2019-09-04 08:26
`lib/pact/hal/link.rb`

bethskurrie
2019-09-04 08:27
I wonder if the behaviour of JSON.dump has changed

bethskurrie
2019-09-04 08:28
I'm surprised I used json dump instead of to_json. Normally, I'd to_json things. I wonder what I was thinking.

bethskurrie
2019-09-04 08:30
In irb with ruby 2.6, run this code and tell me what you get @simon.nizov

bethskurrie
2019-09-04 08:30
``` require 'json' class VerificationResult def initialize publishable, success, provider_application_version, test_results_hash @publishable = publishable @success = success @provider_application_version = provider_application_version @test_results_hash = test_results_hash end def to_json(options = {}) { success: success, providerApplicationVersion: provider_application_version, testResults: test_results_hash }.to_json(options) end private attr_reader :success, :provider_application_version, :test_results_hash end JSON.dump(VerificationResult.new(true, true, "1", {})) ```

simon.nizov
2019-09-04 08:31
one sec, nokogiri is taking forever to install :smile:

simon.nizov
2019-09-04 08:31
(bundling for 2.4.4 that I already have)

bethskurrie
2019-09-04 08:32
ah nokogiri

simon.nizov
2019-09-04 08:34
``` [5] pry(main)> JSON.dump(VerificationResult.new(true, true, "1", {})) => "{\"success\":true,\"providerApplicationVersion\":\"1\",\"testResults\":{}}" ```

bethskurrie
2019-09-04 08:35
that looks fine! I dont' know what's going on.

bethskurrie
2019-09-04 08:36
that's the exact code that should be running.

simon.nizov
2019-09-04 08:36
yeah so weird

bethskurrie
2019-09-04 08:36
In `lib/pact/hal/http_client.rb` set `@verbose = true` and then run the publication.

bethskurrie
2019-09-04 08:37
I need to expose that flag in the api.

simon.nizov
2019-09-04 08:44
``` <- "POST /pacts/provider/Ecommerce%20Server/consumer/Rocky/pact-version/9915c87556e8a24e716f0e38140f9b983219ce01/verification-results HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json, */*\r\nUser-Agent: Ruby\r\nContent-Type: application/json\r\nHost: localhost:9292\r\nContent-Length: 2576\r\n\r\n" <- "{\"publishable\":true,\"success\":false,\"provider_application_version\":\"1.0.0\",\"test_results_hash\":{\"tests\":[{\"testDescription\":\"has status code 201\",\"testFullDescription\":\"Verifying a pact between Rocky and Ecommerce Server A request to start a punchout new session with POST /api/punch_out/sessions.json returns a response which has status code 201\",\"status\":\"failed\",\"interactionProviderState\":null,\"interactionDescription\":\"A request to start a punchout new session\",\"exception\":{\"class\":\"RSpec::Expectations::ExpectationNotMetError\",\"message\":\"\\nexpected: 201\\n got: 400\\n\\n(compared using eql?)\\n\"},\"actualStatus\":400},{\"testDescription\":\"has a matching body\",\"testFullDescription\":\"Verifying a pact between Rocky and Ecommerce Server A request to start a punchout new session with POST /api/punch_out/sessions.json returns a response which has a matching body\",\"status\":\"failed\",\"interactionProviderState\":null,\"interactionDescription\":\"A request to start a punchout new session\",\"exception\":{\"class\":\"RSpec::Expectations::ExpectationNotMetError\",\"message\":\"Actual: {\\\"message\\\":\\\"param is missing or the value is empty: buyer_cookie\\\"}\\n\\nDiff\\n--------------------------------------\\nKey: - is expected \\n + is actual \\nMatching keys and values are not shown\\n\\n-{\\n- \\\"start_page_url\\\": \\\"String\\\"\\n-}\\n+{}\\n\\n\\nDescription of differences\\n--------------------------------------\\n* Could not find key \\\"start_page_url\\\" (keys present are: message) at $\"},\"actualBody\":{\"message\":\"param is missing or the value is empty: buyer_cookie\"},\"differences\":[{\"description\":\"Could not find key \\\"start_page_url\\\" (keys present are: message) at $\"}]},{\"testDescription\":\"\\\"Content-Type\\\" which equals \\\"application/json; charset=utf-8\\\"\",\"testFullDescription\":\"Verifying a pact between Rocky and Ecommerce Server A request to start a punchout new session with POST /api/punch_out/sessions.json returns a response which includes headers \\\"Content-Type\\\" which equals \\\"application/json; charset=utf-8\\\"\",\"status\":\"passed\",\"interactionProviderState\":null,\"interactionDescription\":\"A request to start a punchout new session\",\"actualHeaders\":{\"Content-Type\":\"application/json; charset=utf-8\",\"Cache-Control\":\"no-cache\",\"X-Request-Id\":\"bb2794c8-bad5-4df2-b151-150d107fc24a\",\"X-Runtime\":\"0.341292\",\"Vary\":\"Origin,Accept-Encoding\",\"Content-Length\":\"66\"}}],\"summary\":{\"testCount\":3,\"failureCount\":2},\"metadata\":{\"warning\":\"These test results use a beta format. Do not rely on it, as it will definitely change.\",\"pactVerificationResultsSpecification\":{\"version\":\"1.0.0-beta.1\"}}}}" ```

simon.nizov
2019-09-04 08:45
:cold_sweat:

bethskurrie
2019-09-04 08:45
so confused

bethskurrie
2019-09-04 08:45
so, you used the same ruby to do that little experiment as to run that code?

bethskurrie
2019-09-04 08:46
In `lib/pact/hal/link.rb:47` add a `puts JSON.dump(payload)`

bethskurrie
2019-09-04 08:46
also do a `puts payload.to_json`

bethskurrie
2019-09-04 08:46
see if they're different

bethskurrie
2019-09-04 08:47
also, do you have active record in this project?

bethskurrie
2019-09-04 08:47
or any other JSON libraries?

simon.nizov
2019-09-04 08:49
in debug from within the project JSON.dump doesn?t call to_json

bethskurrie
2019-09-04 08:50
is there a JSON library you're using that might have monkeypatched JSON dump?

simon.nizov
2019-09-04 08:50
I have active record as a dependecy of rails but we use mongoid instead

bethskurrie
2019-09-04 08:50
If you view the source of JSON.dump what do you get?

simon.nizov
2019-09-04 08:50
Maybe `Oj`

simon.nizov
2019-09-04 08:50
let me check

bethskurrie
2019-09-04 08:50
Ah, Oj is a likely candidate.

bethskurrie
2019-09-04 08:51
I've had issues with it before

bethskurrie
2019-09-04 08:51
``` $ JSON.dump From: /Users/bethanyskurrie/.gem/ruby/2.4.5/gems/json-2.2.0/lib/json/common.rb @ line 384: Owner: #<Class:JSON> Visibility: public Number of lines: 20 def dump(obj, anIO = nil, limit = nil) if anIO and limit.nil? anIO = anIO.to_io if anIO.respond_to?(:to_io) unless anIO.respond_to?(:write) limit = anIO anIO = nil end end opts = JSON.dump_default_options opts = opts.merge(:max_nesting => limit) if limit result = generate(obj, opts) if anIO anIO.write result anIO else result end rescue JSON::NestingError raise ArgumentError, "exceed depth limit" end ```

bethskurrie
2019-09-04 08:55
Ok, I've just released 1.41.1 with to_json instead of JSON.dump. Can't think of a good reason why it's JSON.dump, and no tests broke when I changed it.

simon.nizov
2019-09-04 09:05
Yeah it looks like it?s Oj although I?m not sure what exactly is happening

simon.nizov
2019-09-04 09:05
Thanks!!

bethskurrie
2019-09-04 09:06
NP.

milleniumbug
2019-09-04 12:27
I managed to build Rust reference library and wrote some C# P/Invoke bindings here https://github.com/milleniumbug/pact-rust-net However, it seems that the exposed C API from Rust isn't enough to replicate current Ruby-based implementation features - among other things, selecting a specific IP address (e.g. localhost) instead of listening to any, adding and clearing interactions, and so on. Also no C API for pact verifier. How should I approach this? Should I create my own Rust crate that provides a C API for this first?

milleniumbug
2019-09-04 12:58
Or should I send PRs to pact-reference project with additional C API functions? @uglyog

milleniumbug
2019-09-04 13:08
I'm also exploring the idea of using pact-matching library from C#, so it would be possible to use http://ASP.NET Core's TestServer with contract tests. This is, OTOH, is optional for now, since it means partially reimplementing Pact features in C#.

nathan2oo3
2019-09-04 16:31
Hi @bethskurrie I managed to get the certs imported but still it gives us ssl errors when executing the webhooks. Is there a way to verify that the ssl certs have been imported into the database successfully?

guillermo.castro
2019-09-04 18:26
has joined #general

priyank.shah217
2019-09-05 03:32
Have a question, Shall i used pact for CDC if my producer and consumer deployed in AWS lambda?

bethskurrie
2019-09-05 03:38
How are your lambdas operating @priyank.shah217? Are they returning a synchronous response, or are they just accepting and sending messages?

priyank.shah217
2019-09-05 03:52
Its sync APIs

bethskurrie
2019-09-05 03:53
We're working on support for this, but it's not done yet unfortunately.

priyank.shah217
2019-09-05 03:53
I just referred https://github.com/pact-foundation/pact-js/tree/master/examples/serverless but its moreover about async API..can we have something for sync apis also?

bethskurrie
2019-09-05 03:54
We realise it's a great use case for pact.

priyank.shah217
2019-09-05 04:12
:+1:

dvallabhuni206
2019-09-06 01:02
has joined #general

kiranpatel11
2019-09-06 01:31
has joined #general

kiranpatel11
2019-09-06 02:54
has anyone considered pact consumer library for http://force.com apex language? not sure if it is even feasible considering ruby dependency and apex being cloud/interpreted language. (I am not http://force.com/apex guy, but experienced pact user now)

rafael.santos.193
2019-09-06 17:20
has joined #general

thirumal.net
2019-09-06 19:25
@kiranpatel11 - i don't think there is a out of box support for SFDC but i think still you can use below CLI tools to accomplish the same

thirumal.net
2019-09-06 19:25
There is no pact native support to C++/SFDC/SAP but still it is possible to write pacts for C++/SFDC/SAP projects https://github.com/pact-foundation/pact-reference How to write a consumer test, without a consumer language / DSL support https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh how to write a provider test, without provider language / DSL support https://github.com/pact-foundation/pact-ruby-standalone/releases

uglyog
2019-09-06 23:03
If your lambda functions are deployed via API gateway, you can just treat them like a normal HTTP server

uglyog
2019-09-06 23:22
Please send any PRs. I'm also happy to help. We need to work out a good interface.

uglyog
2019-09-06 23:23
I'm going to split the Rust mock server library into a core one and an FFI one which we can expand as you need

serge.a.silva
2019-09-08 06:22
@milleniumbug how?s it going? can I help with anything?

kiranpatel11
2019-09-09 00:10
Thanks for the response, I did looked at the example.sh earlier, but it mentions that interactions to be written by respective pact DSL. Since there is not DSL for SFDC, what's the best way to write. I am considering to keep it along with SFDC codebase and integrating with CI/CD pipeline.

florian.nagel
2019-09-09 08:05
Hello beautiful Pact people, quick question. Have any of you used Pact in an async communicating environment in larger projects? If so, what difficulties did you encounter? And what do you think has to happen to have async CDC testing be as good as sync CDC testing? (@matt.fellows I'll just tag you as well so I don't clutter your mail inbox) Any and all feedback or experiences are welcome! Have a wonderful day.

sahil.goyal2
2019-09-09 12:22
has joined #general

matt.fellows
2019-09-10 02:42
Sorry all if I haven?t returned any messages for a little bit - was away for the past 4 days. Ping me if I?ve ignored you :stuck_out_tongue:

matt.fellows
2019-09-10 02:42
> And what do you think has to happen to have async CDC testing be as good as sync CDC testing? What do you mean by this, sorry?

serge.a.silva
2019-09-10 05:30
Keep in mind, using the Ruby version might get you flagged for a couple of nasty CVEs depending on your SDL/compliance practices.

gigo1980
2019-09-10 08:48
has joined #general

gigo1980
2019-09-10 08:57
Hi, i have seen that the pact broker ui reference to an external project `pactflow`. Will they contribute the ui changes also back to the project?

bethskurrie
2019-09-10 09:04
Hi Enrico. There are no plans to open source the Pactflow UI, as it is part of a commercial product offering.

gigo1980
2019-09-10 09:05
Ok, and will be a onprem solution available in the future ?

kimsia
2019-09-10 09:13
has joined #general

uglyog
2019-09-10 09:40
We are looking into how to offer an on-prem version of Pactflow. At the moment it is tied to a cloud provider?s services, so would need to be decoupled from that.

milleniumbug
2019-09-10 14:46
I'm currently evaluating Pact, and I have a question regarding its use case. My situation is that I have several microservices, each one has its own existing test suite, with the test suite launching the HTTP microservice, and sending it a request, and examining its response. In production, the service calls other services, but in tests, we're using mocks instead. I believe that using Pact mock services instead of regular mocks here will improve coverage across multiple services, since these tests will make each service "cross-check" requests/responses against each other (instead of the service assuming in its own tests what will the other service respond). I am new to contract testing, however, and I'm not sure if this is intended approach, and whether this approach is right (if it's not an anti-pattern)

milleniumbug
2019-09-10 15:02
I am currently trying out this approach on our two services, and it seems to work on consumer side, but provider side is a bit involved, since it involves a single call to `.Verify()` which issues provider state change POST requests, and the requests stored in the pact json, but our existing tests are running xUnit-style arrange-act-assert way. I understand that since the provider has to be aware of what provider states it has to set up, the contract tests could also be done that way, except that pact verifier would have to 1.) read the pact file, to collect all request/response pairs 2.) allow to "emit" a stored request based on the (description, state) pair, and then verify the response 3a.) raise an error in case not all of the requests stored in the pact file would be emitted (which would mean the consumer added a case, and team responsible for provider need to write code to handle that provider state) 3b.) issue requests for the remaining, not "emitted" previously, and see if the provider handles it 4.) send the overall results to the pact broker

milleniumbug
2019-09-10 15:16
@uglyog A separate FFI lib is a great idea. I have a question wrt stability of the lib. Is it fine if I introduce breaking changes in the pull requests?

milleniumbug
2019-09-10 15:19
Asking because I wrote this a few days ago https://github.com/milleniumbug/pact-reference/commit/b48ee725205cfcd1874c5f15a5368509cb7d09a4 while attempting to FFI the lib from C# I was boggled why I get firewall prompts from Windows, and it turned out that by default in PactNet we're listening on localhost, rather than any (so requests never leave the computer they're sent on)

milleniumbug
2019-09-10 15:23
My Rust skills are limited, but I know C# and C++, and I'm comfortable with writing bindings

milleniumbug
2019-09-10 15:36
My plan is: - "ripping away" the Ruby guts from the lib, and replacing anything that calls into the process with stub calls, so I can see where these parts are - compiling all the features that we need to have in order to achieve feature parity with the original Ruby code, in a comprehensive list - evaluate features and see what FFI interface would be most suitable for these - implement the FFI on Rust side (and possibly the features that aren't there yet in Rust code itself) - replace the stub calls with calls to FFI - make existing PactNet test suite pass with the new Rust implementation - extend the PactNet library with my use cases

milleniumbug
2019-09-10 15:46
I'm not sure *where* are the Ruby parts in particular yet, so these parts (point 1 and 2) are where I could use some help Also I don't know yet how to bundle native .dlls in a way that will work in both 32-bit and 64-bit windows - this is a new thing in comparison with the Ruby implementation, which didn't have that requirement (separate processes are launched just fine because there's no shared address space, but a 32-bit process must load a 32-bit library, and 64-bit process must load a 64-bit library)

lwillmeth
2019-09-10 21:03
has joined #general

swu
2019-09-10 21:10
has joined #general

ckotyan
2019-09-10 21:17
has joined #general

matt.fellows
2019-09-10 21:36
What would he the main barrier to not go with a SaaS product here?

matt.fellows
2019-09-10 21:37
Be*

jasonbarr.za
2019-09-11 07:20
has joined #general

german.schnyder
2019-09-11 15:38
has joined #general

athayes.ca
2019-09-11 20:19
has joined #general

anthony.hayes
2019-09-11 20:19
has joined #general

sankarkumar.ponnusamy
2019-09-11 23:39
has joined #general

dan184
2019-09-12 12:29
has joined #general

dan184
2019-09-12 12:38
Hi all, thanks in advance for helping out and providing pact as open source :slightly_smiling_face: I'm trying to get a consumer test running on my linux machine, which I'm pretty sure worked on my mac yesterday, but I keep getting ``` Pact verification failed - expected interactions did not match actual. ``` I can see that Pact is hitting the provider with the right method, path and the right body is being returned. I suspected that headers weren't matching, but I can't see where. 1) Is there any reason this shouldn't work on linux versus mac? can't think of one 2) Any way of debugging how the matching is determined? Loglevel at debug doens't provide any clues - just says missing request

weina.liu
2019-09-12 15:23
has joined #general

weina.liu
2019-09-12 15:28
hello, everyone. we are working on researching tool of gRPC contract testing. does PACT support gRPC?

jainvarz
2019-09-12 17:22
has joined #general

dperez
2019-09-12 17:23
hi @neil hope everything goes good on your end. I was wondering if you could help us merging the latest master into the branch message-pact. Thanks a lot!

neelofer.tamboli
2019-09-12 22:06
Hi Beth. We have a similar situation where two different versions of our web application can be in prod at the same time. How can we ensure any new PRs support both versions? I am still understanding the pact tags. We have a gradle task to verify the pact using `pactTag=production`. How can we verify both production tags every time? We are using a CD workflow so the production tags can change rapidly.

bethskurrie
2019-09-12 22:08
@weina.liu no it doesn't, through we're interested in how it might be added.

bethskurrie
2019-09-12 22:09
@dan184 can you provide an executable example please?

bethskurrie
2019-09-12 22:10
What's else is in the logs in the log file?

bethskurrie
2019-09-12 22:13
@milleniumbug One way to simplify this is to use a "normal" mock to mock downstream calls when you are verifying the upstream pact. Then use a shared artifact in the pact tests for the downstream pact to make sure that you're keeping the two sets of tests in sync.

bethskurrie
2019-09-12 22:14
Or, you could generate the downstream pact first, and then parse the requests/responses from that pact to set up your "normal" mocks in the upstream pact verification.

bethskurrie
2019-09-12 22:16
@neelofer.tamboli we're releasing a new verification api soon that will allow you to say "all pacts with the prod tag" instead of just "the latest Pact with the prod tag". You'll need to remove the prod tag from the versions you no longer wish to verify to make this work.

bethskurrie
2019-09-12 22:17
For now, the easiest way might be to keep track of the version numbers explicitly.

bethskurrie
2019-09-12 22:18
@nathan2oo3 yes, look in the database.

bethskurrie
2019-09-12 22:19
I think there's a way to disable ssl checks entirely.

bethskurrie
2019-09-12 22:20
It may not be exposed via an env var in the docker container though.

bethskurrie
2019-09-12 22:22
Oh yes it is

bethskurrie
2019-09-12 22:22
PACT_BROKER_DISABLE_SSL_VERIFICATION

neelofer.tamboli
2019-09-13 02:11
Thank you. Do you know when it will be out?

p0deje
2019-09-13 03:58
Hey folks, I?m in the process of building a proper ?Pact Nirvana? (https://docs.google.com/document/u/1/d/e/2PACX-1vRf1kSDccImNipOOm1G-bjcSs-ifbZjf1v54K-dIcq8BLKeFPAAm_bf_p71UKqkRMIx30QWWL-kN8TI/pub) for 2 services and things work perfectly fine until I start dealing with _production_ tag verification. After thinking about how to develop services independently, I thought that every Git feature branch of every service (regardless if it?s provider or consumer) needs to be checked against _production_ version of the other service. This seems to be easily done on the provider side, but not on the consumer. On the consumer side, I set up 2 _contract_content_changed_ webhooks: 1. The first webhook triggers the provider verification on provider?s _master_ Git branch (or feature branch). 2. The second webhook triggers the provider verification on provider?s _production_ revision (step #8 of the document). The problem is reporting the results back to the Github? I tried using _contract_published_ webhook, but it only checks the latest version of the provider, so it can?t ensure that consumer is compatible with the provider?s _production_ if the contract is not changed. And when the contract is changed, it doesn?t know about provider version tags, so it reports to Github with any tags at all. And only after verification results are published, they are shown in Github. Has anyone faced similar issue? I?m attaching few screenshots to explain it more.

p0deje
2019-09-13 04:00
This is how it looks when contract_published and the content is not changed. Only _master_ is reported.

p0deje
2019-09-13 04:00
This is how it looks when contract_published and contract content is changed.

p0deje
2019-09-13 04:01
And finally this is how it looks when verification results are published from CI. The first is for master provider. The second is for production provider.

matthias.laug
2019-09-13 05:56
has joined #general

p0deje
2019-09-13 06:42
I guess it worths checking out #protobufs

bethskurrie
2019-09-13 06:48
I'm hoping to release it Thursday week.

bethskurrie
2019-09-13 06:49
I've scheduled a day in!

bethskurrie
2019-09-13 07:16
@p0deje I don't have time to sit down and work through the details of your challenge, but try reading the updated document here: https://docs.pact.io/best_practices/pact_nirvana#d-configure-pact-to-be-verified-when-contract-changes

bethskurrie
2019-09-13 07:17
It might have something that the old doc doesn't explain.

bethskurrie
2019-09-13 07:17
You can pass the tags of the pact in the webhook template.

bethskurrie
2019-09-13 07:18
The other thing to consider is, sometimes putting the full logic of what you want to achieve into the webhook is not possible. In that case, it's best to trigger an intermediate build which can do the logic of which branch to test against which branch.

p0deje
2019-09-13 07:21
Thanks @bethskurrie, I?ll go through the doc you pointed out.

p0deje
2019-09-13 07:22
I know that I can pass the tags in the webhook template, but it seems like Broker is unaware of the tags when contract is changed. Like in https://pact-foundation.slack.com/archives/C5F4KFKR8/p1568347257107500?thread_ts=1568347127.106900&cid=C5F4KFKR8

bethskurrie
2019-09-13 07:29
There was a bug in some of the implementations where the tagging was done after the pact was published, instead of before.

bethskurrie
2019-09-13 07:29
It should have been fixed in all the impls now. Try upgrading.

p0deje
2019-09-13 07:50
I?ll try, thanks. Just to be sure, _contract_published_ webhook only checks latest revision, right? It?s impossible to use to ensure the contract is also verified against provider?s _production_ tag.

bethskurrie
2019-09-13 07:54
Contract published doesn't check anything. It gets triggered each time.

bethskurrie
2019-09-13 07:55
Contract content changed goes through each of the tags that it has, and sees if the previous version with that tag is different

bethskurrie
2019-09-13 07:56
I'm confused as to your problem. The only way to ensure a new contact is verified against the prod version of a provider is to check out that version of the provider and verify the changed pact against it.

p0deje
2019-09-13 07:57
Oh, so if provider has revision that has both _master_ and _production_ tag, contract_content_changed will check both tags?

p0deje
2019-09-13 07:59
I?ll read the guide now again, I?m confused as well :disappointed:

nathan2oo3
2019-09-13 09:37
Great. Thanks Beth I figured it out had to modify your script to pull the script from another location and cat it into the DB. We don't want to have to turn off ssl verification.

robin
2019-09-13 09:38
*edited*

bethskurrie
2019-09-13 09:48
Hi @robin it will help if you ask in the channel for your language. The techniques will vary based on which language you're using.

robin
2019-09-13 09:48
Hi beth, got it, I?ll transfer my message in the appropriate channel

bethskurrie
2019-09-13 09:50
> Oh, so if provider has revision that has both _master_ and _production_ tag, contract_content_changed will check both tags? Yes


lauri.vaeaenaenen
2019-09-13 09:53
has joined #general

p0deje
2019-09-13 11:34
> If your pact is published with tags applied to the consumer version, then you can think of all the pacts that share the same tag name as forming a time ordered ?pseudo branch?. So I?m confused. It will only check consumer version tags, not provider. So if I work in consumer?s feature branch, contract_content_changed will never be triggered for _production_ tag because consumer version doesn?t have it.

bethskurrie
2019-09-13 23:10
Why would it check the provider tags?

bethskurrie
2019-09-13 23:12
The pact doesn't have provider tags.

bethskurrie
2019-09-13 23:13
The contract_content_changed will be triggered for the production tag when you tag the consumer version you just deployed to prod.

bethskurrie
2019-09-13 23:14
It won't get triggered on pact publication, no.

tati.shep
2019-09-15 11:49
has joined #general

kiranpatel11
2019-09-16 07:32
see if this visualization helps...!! happy to be corrected. We are using this model and seems to be good enough. In adition, consumer can publish pact from specific feature branch when provider isn't ready with implemenation yet.

bethskurrie
2019-09-16 08:35
Fantastic diagram @kiranpatel11

admin
2019-09-16 13:17
has joined #general

neelofer.tamboli
2019-09-16 20:49
Cool. Thank you. Please let me know when it is available. I'll be looking at the release notes meanwhile.

simonmeulenbeek
2019-09-17 08:41
has joined #general

gs201m
2019-09-17 12:31
Error throws as HTTP BAD RESPONSE. STatus message says wrong number of arguements. Can someone help?

gs201m
2019-09-17 12:32
#general Guys recently all our pact tests are failing with weird error. We tried to find root cause by just adding response 200 assertion it?s still failing

matt.fellows
2019-09-17 22:32
what have you tried to diagnose? What language are you using? What?s changed?

catrionamcgarvey
2019-09-17 22:32
has joined #general

jfister
2019-09-17 23:00
has joined #general

tjones
2019-09-18 05:15
Could you paste the full error message, please?

tsalvin
2019-09-18 08:14
has joined #general

tsalvin
2019-09-18 08:19
Hi, has anyone used .and/.or with the Lambda DSL object? I'm not sure it's supported like in the non lambda version after checking the docs, but i'd like to check that value is either null or a stringtype https://github.com/DiUS/pact-jvm/tree/master/consumer/pact-jvm-consumer-java8


tsalvin
2019-09-18 08:37
That explains it perfectly, thanks for the response!

tom.mcardle
2019-09-18 10:33
has joined #general

p0deje
2019-09-18 11:05
@kiranpatel11 Thanks for this awesome diagram! May I just clarify one point related to ?Verify Consumer Change?? The consumer publishes the contract with ?master? tag and Pact-Broker will check if contract is changed only for ?master?, ignoring ?prod?. So, is it theoretically possible that contract is _not_ changed for provider?s ?master? but is changed for provider?s ?prod??

vhbsouza
2019-09-18 20:10
has joined #general

vhbsouza
2019-09-18 20:53
@matt.fellows I searched in this channel and couldn't find how to do it (I think is due to the slack 10k message history limit). Do you have a link or something else about it? And I'm using Java.

matt.fellows
2019-09-19 01:51
Java supports XML, but doesn?t have the same richness in the DSL as JSON (see https://github.com/DiUS/pact-jvm/issues/243)

matt.fellows
2019-09-19 01:52
I?m not aware of any public example using it

matt.fellows
2019-09-19 01:52
You need to use the `XmlBodyMatcher`


tritorto
2019-09-19 02:10
has joined #general

wongso_a
2019-09-19 07:14
has joined #general

talshoef
2019-09-19 07:22
has joined #general

dianaszaharia
2019-09-19 10:22
has joined #general

kiranpatel11
2019-09-20 01:36
@p0deje There are two things that can potentially break the working contract 1. Consumer (master) or 2. Provider (master) When consumer publishes new contract, verification should happen against _head_ and _prod_ codebases of the provider. When provider introduces a new change, it verifies the same against the _head_ and _prod_ pacts of the consumer. That way, we can keep the changes from both pacticipants in check by mean of ensuring all combinations !! That's what is famously refferred as Pact Metrics !! I hope it makes sense.

kiranpatel11
2019-09-20 01:37
I assumed the branching strategy to be trunkbaseddevelopment here. As i mentioned earlier, in addition to this you may also use feature branches for early feedback on compatibility, however, they are not expected to be verified always due to WIP implementation.

kiranpatel11
2019-09-20 01:40
@p0deje I think your assumption is incorrect, when consumer publishes new contract, you get a trigger using a webhook. As part of that trigger, you should perform verification against the _head_ and _prod_ version of provider codebase.

kiranpatel11
2019-09-20 01:45
While publishing verification results to pact-broker, we can provider provider version, However, I did not find any documentation on tagging at the same time. is it possible to tag provider upon publishing verification results to pact-broker ?

bethskurrie
2019-09-20 01:46
Yes, that's the way it's meant to happen.

bethskurrie
2019-09-20 01:46
What library are you using?

kiranpatel11
2019-09-20 01:52
pact-jvm

bethskurrie
2019-09-20 01:53
maven or gradle?

kiranpatel11
2019-09-20 01:53
maven

bethskurrie
2019-09-20 01:53
I'd have a look at the code for the maven pact publishing. It may be that the tags are just not exposed in that task yet.

bethskurrie
2019-09-20 01:54
They should be however - if they're not, raise an issue (or even better, I can help you work on a PR, as I know Ron is super busy at the moment).

bethskurrie
2019-09-20 01:54
You can also just call the tagging API directly. It's just a PUT to http://broker/pacticipants/PACTICIPANT/versions/VERSION/tags/TAG.

bethskurrie
2019-09-20 01:55
You need to do the tagging before the verification publication however, so that the right info is present in the webhooks when they get kicked off.

kiranpatel11
2019-09-20 01:57
At the moment, I am explicitly using cli to tag once the verification is performed - success or failed.

bethskurrie
2019-09-20 01:57
if you're relying on the tags in the webhooks, then they won't be present.

bethskurrie
2019-09-20 01:58
Otherwise, you'll be ok.

kiranpatel11
2019-09-20 01:58
I think i will need to rely on the webhooks to retry can-i-deploy on consumer side, its WIP.

kiranpatel11
2019-09-20 02:00
let me check the docs again, if needed I will work on PR

bethskurrie
2019-09-20 02:01
We appreciate everyone's contributions. It's a big job to keep everything going and up to date.

kiranpatel11
2019-09-20 02:06
Sure, btw I am in Melbourne only, hope to catch up with you guys someday.:slightly_smiling_face:

bethskurrie
2019-09-20 02:06
That would be awesome :slightly_smiling_face:

kiranpatel11
2019-09-20 02:26
I found this is flagged as an enhancement https://github.com/DiUS/pact-jvm/issues/823

neelofer.tamboli
2019-09-20 03:47

bethskurrie
2019-09-20 03:48
yes, it will be in there

neelofer.tamboli
2019-09-20 03:57
How do we ensure backward compatibility? What we are doing right now: 1. Create a webhook for Provider which invokes provider Jenkins build when a contract changes. This calls the Jenkins pipeline of the provider, latest master branch. 2. When a contract is changed by consumer, the provider build runs and posts result back to the consumer build. I am not sure I understand how backward compatibility works with this if the master branch of provider has more changes than the provider service deployed on production.

p0deje
2019-09-20 04:43
Right, thanks for clarifying, Kiran

kiranpatel11
2019-09-20 04:48
~<@UHPHAN078> Hope this diagram helps you understand.~



nithinmohan114
2019-09-20 07:42
has joined #general

yuma.higashiyama
2019-09-20 11:58
has joined #general

neelofer.tamboli
2019-09-20 14:14
Perfect, thank you. Exactly what I was looking for.

simonmeulenbeek
2019-09-20 14:46
hey Pact-users, I have a (hopefully) simple question... I'm using pact-jvm-consumer-java8_2.12, and i'm trying to generate pacts on my consumer side. I'm encountering an error where my requests don't get matched with the expected requests, because i'm sending objects with extra key-value pairs. I was under the assumption that creating a expectation will create a sort-of 'minimum viable request', where extra key-value pairs are accepted as long as the expected fields are present

simonmeulenbeek
2019-09-20 14:47
am i wrong in this assumption??

simonmeulenbeek
2019-09-20 14:47
relevant part of my dsl:

simonmeulenbeek
2019-09-20 14:48
` PactDslJsonBody() .stringValue("service_operation", OPERATION_CANCEL_ITEMS) .eachLike("items", 1) .uuid("id") .closeArray()

simonmeulenbeek
2019-09-20 14:48
`PactDslJsonBody() .stringValue("service_operation", OPERATION_CANCEL_ITEMS) .eachLike("items", 1) .uuid("id") .closeArray()`

simonmeulenbeek
2019-09-20 14:48
hmm code tags apparently don't work

simonmeulenbeek
2019-09-20 14:49
the 'eachLike' array holds objects that contain at least an id. When I send objects that also contain other keys it fails with error: " mismatch=Expected a Map with 1 elements but received 2 elements"

simonmeulenbeek
2019-09-20 14:51
I'm probably not using the right arraytype. But tbh it's pretty confusing, there are no docs for the DSL language, and The javadoc isn't that much clearer either

borsuk.artem034
2019-09-20 15:30
Hi, can you share exaple of json?

neelofer.tamboli
2019-09-20 16:53
... but never found a link from anywhere online.

matt.fellows
2019-09-21 02:35
Can you please move this to #pact-jvm ?

uglyog
2019-09-21 03:30
That is true when verifying the provider extra fields will be ignored. But in the consumer test, you are in control of the test so you should be sending the correct attributes to match your expected request.

hoangthaikt07
2019-09-21 08:48
has joined #general

abubics
2019-09-22 23:35
You want to use the triple ` for multi-line code :slightly_smiling_face:

kanaga.chinnappan
2019-09-23 13:19
has joined #general

bart.schotten
2019-09-23 14:12
For a large international company that has to integrate both Java and .NET services I have developed an alternative Pact implementation for .NET that is more compliant with Pact-JVM. It has (at least for our practical purposes) full support for Pact Specification V3, so that includes Message Pacts. From a user perspective it works a bit like a mix of Pact-NET and Pact-JVM (it has a similar DSL). It's not quite a 1.0 version yet, but it's currently already being used in practice, so feel free to check it out: https://github.com/bartschotten/com-pact I want to note that although this goes against the Pact policy of using a common (ruby/rust) core for each implementation, I hope the effort is still appreciated. If nothing else, developing a new implementation from the ground up raised some questions about the details of the Pact Specification that may help to sharpen its definition.

rajendra.sidhu
2019-09-23 16:29
has joined #general

tkimia
2019-09-23 18:31
has joined #general

mpglover
2019-09-24 01:52
As someone who has been toying with a native implementation for Elixir I just want to :+1: your efforts. I agree that it's a good way to ensure the specification is really solid.

uglyog
2019-09-24 02:19
It's not so much a policy as a way to quickly get a language implementation working. Could you announce it in the pact-net channel?

rootuid
2019-09-24 08:58
has joined #general

rootuid
2019-09-24 09:04
https://github.com/pact-foundation/pact-python/ it's a year since the last commit to that repo. Wondering if there is an alternative fork that is progressing ?


rootuid
2019-09-24 09:07
ahh excellent, thanks @294simon

fabio
2019-09-24 09:08
has joined #general


s.roodhorst
2019-09-24 09:46
has joined #general

matt.fellows
2019-09-24 10:28
:wave: hello new friends!

matt.fellows
2019-09-24 10:29
Awesome stuff Bart. Thanks for getting involved!

george.papas
2019-09-24 11:41
has joined #general

tkimia
2019-09-24 14:30
Hey all, I'm looking for info about the state of message based contracts in ruby. It seems like there are a few repos in the pact-foundation https://github.com/pact-foundation/pact-message-ruby that suggest that this is not usable yet.

mohsin
2019-09-24 14:55
has joined #general

mohsin
2019-09-24 15:00
hi, I'm unable to sign into my account. I just registered a few mins back and the email/temp password doesn't work

mohsin
2019-09-24 15:02
could someone please help me @here

mohsin
2019-09-24 15:52
nevermind, I figured it out.

k.sciana
2019-09-24 18:29
has joined #general

erica.kastner
2019-09-24 21:09
has joined #general

george.papas
2019-09-24 23:31
Hello pactarians. Is anyone using pact or contract testing with grpc?

bethskurrie
2019-09-24 23:31
Hi George!

bethskurrie
2019-09-24 23:31
There's a channel for it.

george.papas
2019-09-24 23:31
hey Beth!

bethskurrie
2019-09-24 23:31
No implementation yet, but some discussion.

george.papas
2019-09-24 23:32
protbuf channel ?

george.papas
2019-09-24 23:32
cheers, i?ll take a look

bethskurrie
2019-09-24 23:33
There was another Matt working on an implementation. I'm not sure if our history goes back far enough for me to remember who though!

george.papas
2019-09-24 23:34
got it, looks like I can get back to may 7th

george.papas
2019-09-24 23:34
matt constable?

bethskurrie
2019-09-24 23:34
Could be!

jack
2019-09-25 10:23
has joined #general

fabio.sortino
2019-09-25 12:06
has joined #general

fabio
2019-09-25 12:13
hello i have a question regarding pact.........i have that problem that the pacts generated cannot be replayed against the mock..the consumer is written in pact js...the pact will be generated and also published on the pact broker. when i run pactVerify the contracts will be verified against the original provider this is working..but i am not able to run the tests against the mock..what i am doing wrong???

fabio
2019-09-25 12:13
Request Failed - Connect to 127.0.0.1:8114 [/127.0.0.1] failed: Connection refused: connect

fabio
2019-09-25 12:14
i always get the error connection refused

fabio
2019-09-25 12:18
logfile output

jorge.florian
2019-09-25 13:12
has joined #general

zoeabryant
2019-09-25 15:20
has joined #general

mbieganski.infomatt
2019-09-25 16:24
has joined #general

tritorto
2019-09-26 04:35
Hi Guys, im after a bit of guidance on `best practices` for consumer versioning - I read that using the git-sha is a possibility to use for the consumer version when publishing to the pact broker - I'm wondering if it means that upon a commit to our dev or master branch for example, we would set the consumer version to the git-sha (with the corresponding branch tag) and push that up via our CI/CD- this would happen irrespective of if a pact file change has happened or not?

bethskurrie
2019-09-26 04:37
Correct.

bethskurrie
2019-09-26 04:37
The broker handles the versioning of the pact content for you.

uglyog
2019-09-26 04:38
When you say "replayed against the mock", what do you mean?

bethskurrie
2019-09-26 04:38
You just push it and tell it which consumer version it belongs to, and it will deal with the rest.

tritorto
2019-09-26 04:39
excellent - I think im finally getting my head around versioning and tagging. I suppose we would see our matrix get fairly big over time, is there something we should be doing to manage that maybe?

bethskurrie
2019-09-26 04:39
yes, there is a clean up script.

bethskurrie
2019-09-26 04:39
I've been meaning to add it to the docker container and have it run at a regular interval.


tritorto
2019-09-26 04:40
oh nice - we are using docker for local development but pactflow will be our dev environment, once I finish up my POC and demo it to my team... is this something to handle in Pactflow also?

bethskurrie
2019-09-26 04:41
If you notice your queries taking too long, let us know, and we can clean it up for you.

tritorto
2019-09-26 04:41
yea makes sense! thanks :slightly_smiling_face:

angela.gloyna
2019-09-26 05:54
has joined #general

s1apped
2019-09-26 06:00
Hi I have some problem with junit provider , pactbroker and gradle. I try to set PactBroker properties in gradle like test { systemProperty 'pactbroker.tags', 'test' systemProperty 'pactbroker.host', 'url' systemProperty 'pact.provider.version', 'version' systemProperty 'pact.verifier.publishResults', 'true' I'm getting error : Did not find any pact files for provider This works just fine @PactBroker(host = "url", scheme = "http", tags = {"ests"}). Am I missing something?

bethskurrie
2019-09-26 06:01
@s1apped best to ask in #pact-jvm

s1apped
2019-09-26 06:03
thanks!

liam.williams
2019-09-26 11:11
has joined #general

schmittol
2019-09-27 10:58
has joined #general

peter.lockwood
2019-09-27 13:14
has joined #general

rbhati
2019-09-27 13:44
has joined #general

pkuang
2019-09-30 02:43
Hi, I was wondering if there is any plans for a C++ DSL ?

matt.fellows
2019-09-30 02:48
It?s come up, but no specific plans yet

srinivasan.anusha
2019-09-30 03:09
has joined #general

ckaptan
2019-09-30 13:34
Hello everyone. I am running into the following error when publishing to pact broker `PactBroker::Client::Error - {"error":{"message":"The maximum number of integrations has been added to your account."}}`. Any idea how to resolve this? Thanks.

samuel.hodgkinson
2019-09-30 14:41
Are you using PactFlow? If so, there's a limit of 5 contracts on the free developer instances (https://pactflow.io/pricing/)

alex.thayn
2019-09-30 20:41
has joined #general

me_pact
2019-09-30 20:54
has joined #general

andreas.thurn
2019-10-01 05:30
has joined #general

andreas.thurn
2019-10-01 05:33
We are having the same issue. We are using DiUS hosted pact. We've got 14 integrations so far.

bethskurrie
2019-10-01 05:42
Hi guys. @andreas.thurn you will be one of our beta customers, from before the official "Pactflow" launch, when it was just a hosted version of the OSS codebase.

andreas.thurn
2019-10-01 05:44
That's existing. Does that mean we are falling into the 5 integrations limit or do we have unlimited contracts?

bethskurrie
2019-10-01 05:44
@ckaptan you will be on our Pactflow free developer plan, which has a limited number of integrations (as Sam pointed out, this is noted on the pricing page). This plan is meant to allow developers to do an effective proof of concept to work out if Pactflow is the right product for them, but you will need to choose one of the paid plans if you would like to use Pactflow at scale.

bethskurrie
2019-10-01 05:47
@andreas.thurn your contracts will not be limited, however, if you would like to use some of the fancy new features (webhooks editing and testing UIs, secrets management, SSO, lovely new UI that isn't built with jquery ... :laughing: ) then you'll need to move to one of the paid plans. As one of our beta users though, you would be offered a discounted rate. Feel free to send us an email about it.

bethskurrie
2019-10-01 05:48
Actually, Andreas, I'm confused as to how you're getting limited at 14 contracts. The only limit we have is 5 - all other plans are unlimited.

andreas.thurn
2019-10-01 05:49
I guess that we added 14 contracts before the limit was set in place :thinking_face:

bethskurrie
2019-10-01 05:50
Ah, that would make sense.

nayaksurajr
2019-10-01 05:50
has joined #general

bethskurrie
2019-10-01 05:50
You must have been one of our very first offical Pactflow customers, after we launched.

bethskurrie
2019-10-01 05:50
You get 9 bonus contracts then!

iago.quirino
2019-10-01 09:39
has joined #general

reachbharathan
2019-10-01 09:58
has joined #general

mtimbs91
2019-10-01 12:04
has joined #general

nouri.tawfik
2019-10-01 12:34
has joined #general

phall
2019-10-01 13:23
We (@ckaptan and I are in the same organisation) are on the DiUS-hosted non-pactflow version. Is this a new limit?

phall
2019-10-01 13:24
This has encouraged us to move to Pactflow proper, so I guess it worked :wink:

rbhati
2019-10-01 18:17
@here need a quick help, I'm trying to use pack in one of our contract test and the simple ask is to know how can I set `pact_json_filename` variable, goal is to specify the filename

rbhati
2019-10-01 18:23
@bethskurrie ^^ please help

hande.sagar
2019-10-03 04:15
has joined #general

hande.sagar
2019-10-03 04:26
Hi All , currently I am facing one problem , when trying to publish pact contract for rest provider.

hande.sagar
2019-10-03 04:26
This is the mvn Command we are using in our Jenkin pipeline: MVN cmd: mvn pact:verify -P contract-tests,no-asciidoc -Dpactbroker.host=http://kube-pact -Dpact.verifier.publishResults=true -Dpact.provider.version=fc7194df2b341fbada3c7c2fa0f1ef96abe5f59d -Dpact.tag=feature/FMPSU-236-pact-for-phase-3-4 This is the Error we are getting: 1 @PactVerification then " Verification Failed - No annotated methods were found for interaction 'A GET request to retrieve package with id `04398eb4-0f57-4056-b2ea-aa45bf5c4bfd`.'. You need to provide a method annotated with @PactVerifyProvider("A GET request to retrieve package with id `04398eb4-0f57-4056-b2ea-aa45bf5c4bfd`.") that returns the message contents. " 2. We have added @PactVerifyProvider with method verifyPackage then we got another error ?Verification Failed - Failed to invoke provider method 'verifyPackage'?. If any one has some idea about this issue please revert back to me.

bethskurrie
2019-10-03 04:27
Best to ask on the #pact-jvm channel @hande.sagar

hande.sagar
2019-10-03 04:30
Thanks

bethskurrie
2019-10-03 04:39
@rbhati best to ask on the channel for your language. We have 8+ different implementations and I don't know which one you're talking about.

phillip.goff
2019-10-03 13:16
has joined #general

rootuid
2019-10-03 13:42
Hi @channel, I'm making a requests.get to the pactman mock server but I get a 500 + "received but no interaction registered" back. It appears the mock server is up,returns a 500 and the message as per this code https://github.com/reecetech/pactman/blob/67e17532dc0dff4e41c33cb98cb747670fa6adf2/pactman/mock/mock_server.py#L104 . I don't however know why it's happening :disappointed:

rootuid
2019-10-03 13:43
any advice or code examples much appreciated :slightly_smiling_face:

rootuid
2019-10-03 14:30
more testing: ... talking to the the mock server using any string receives the same response. What defines a registered interaction ?

rootuid
2019-10-03 15:08
my code for reference `import atexit` `from pactman import Consumer, Provider` `import requests` `pact = Consumer('Consumer').has_pact_with(Provider('Provider'), use_mocking_server=True)` `pact.start_mocking()` `print('server on {}'.format(pact.uri))` `atexit.register(pact.stop_mocking)` `def testabc():` ` path = '/test/123')` ` pact.given(` ` 'blah'` ` ).upon_receiving(` ` 'a GET request'` ` ).with_request(` ` method='GET',` ` path='/test/123'` ` ).will_respond_with(200, body={'status': 'FAILED'})` ` response = requests.get(pact.uri+path, "")` ` print(response.status_code)` ` print(response.text)` ` assert (response.status_code == 200)`

rbhati
2019-10-03 17:06
@bethskurrie i'm working on python

dhiral.kaniya
2019-10-03 20:01
has joined #general

dhiral.kaniya
2019-10-03 20:53
Hello everyone, I am new in Pack.

dhiral.kaniya
2019-10-03 20:53
I want to implement pack for my dropwizard application. Can anyone suggest the resource link ?

abubics
2019-10-03 23:29
First, I'd jump in #pact-jvm :slightly_smiling_face:

abubics
2019-10-03 23:31
Then I'd start looking at readmes here: https://github.com/DiUS/pact-jvm

abubics
2019-10-03 23:32
Also, some getting started guides here: https://docs.pact.io/implementation_guides/jvm

bethskurrie
2019-10-04 00:04
@rbhati which python implementation? Pact-python or pactman?

matt.fellows
2019-10-04 02:48
Pact?

ttola
2019-10-04 09:26
has joined #general

joseph.haig
2019-10-04 13:35
has joined #general

joseph.haig
2019-10-04 13:48
I have a question that I suspect may have the answer (a) that is not what Pact is for or (b) that has already been answered ? (and possibly also (c) why would you want to do that?). Sorry if this is the the case. For an API (pact provider, I think is the correct terminology) I would like to have a wrapper library that deals with all the http calls. This wrapper library would then be used by the client application instead of making all the API calls explicitly. I know that I can create the contract between the wrapper library and the API but, in terms of checking the contract during deployment, I want to do this in the client application. Is there a correct way to set this up? Should I (and is it possible to) create a contract between the client application and the wrapper library? I have already done this (some time ago) and the solution I came up with is that the client application copies the contract from the wrapper library and submits that as its own, but this doesn?t feel right.

david862
2019-10-04 16:12
Funnily enough we?ve run into the same issue this week. Agree copying the contract is weird yeah.. :shrug:

dhiral.kaniya
2019-10-04 16:35
Thanks @abubics for update

swaroopshere
2019-10-05 17:59
has joined #general

stewart.henderson
2019-10-05 21:50
has joined #general

sabino_lrs
2019-10-06 03:15
has joined #general

dannybrown2710
2019-10-07 10:24
has joined #general

dannybrown2710
2019-10-07 10:31
Hi , Can anyone help me with setup of pact broker. I dont find sufficient content to setup locally. Also, is there any wrapper available to setup using nodejs? Thanks in advance

matt.fellows
2019-10-07 10:41
Hi Danny. There is no NodeJS wrapper (it's a Ruby app). The wiki itself is pretty clear, the only prerequisite is a working Ruby setup

matt.fellows
2019-10-07 10:42
Alternatively you could use something like Pactflow to save you managing your own

iruben91
2019-10-07 12:50
What opinions are out there about mocking internal code dependencies for Provider tests? In our APIs, we already have component tests that should test the application?s real code behaviour (such as ?return 404 if no entity found?). Our controllers receive the request and send it to a query handler, take the result, and convert it to the response model. In this scenario, could mocking out the application?s query handler and just return what?s expected be enough? Would you see any major flaws in this approach?

jack.middleton
2019-10-07 13:39
has joined #general

tony.ibbs
2019-10-07 14:13
has joined #general

yosevuk
2019-10-07 18:13
has joined #general

yosevuk
2019-10-07 18:18
Hello! I have a question about when to use `pactBrokerUrl` versus `pactUrls` when setting up provider [verification options](https://github.com/pact-foundation/pact-js#verification-options). Are you supposed to use `pactUrls` when you have a provider with more than one consumer pact broker URLs that you want to be able to verify independently?

yosevuk
2019-10-07 18:26
Oh, I should ask this in the pact-broker channel :blush:

vitaliy.grigoruk
2019-10-07 18:28
Hi Yosevu, we have the same setup (1 provider, multiple consumers). In case when provider verification CI job is triggered by a change in provider codebase, we simply verify that all consumer contracts are satisfied (we pass `pactBrokerUrl`, `consumerVersionTag`, `pactBrokerUsername`, `pactBrokerPassword`) In case when provider verification is triggered by pact broker (when contract is changed for a specific consumer), we pass `PACT_URL` of a changed contract to provider?s CI job as a build param and then start provider verification with the following opts: `{ pactUrls: [process.env.PACT_URL], pactBrokerUsername, pactBrokerPassword }`. This allows us to verify only a changed contract. Hope, this answers your question

sabitha_alamaddi
2019-10-07 19:08
has joined #general

sabitha_alamaddi
2019-10-07 19:11
Hi, Does Pact support Spock framework?

yosevuk
2019-10-07 19:43
Hey Vitalii, thanks for sharing! Yes, it looks like we have a similar setup. So, as I understand you verify all the consumer contracts with `pactBrokerUrl` when the provider changes, but only individual consumers when they change the contract with `pactUrls`?

ruben.perezg
2019-10-07 20:10
That's the same approach I've implemented :man-shrugging: I'm not an expert by any means, so take it with a grain of salt... But as far as I understand it, it should be just what these tests would need

abubics
2019-10-07 21:39
Sounds like a #pact-jvm question :) But yes, it's possible to write pact consumer tests using Spock. But how you prefer to run them may change whether you want to.

bethskurrie
2019-10-07 22:12
@yosevuk yes, exactly. You can read about this in the Effective Pact setup guide on http://docs.pact.io


vitaliy.grigoruk
2019-10-08 07:27
yes, @yosevuk

hefnat
2019-10-08 10:03
has joined #general

carolin.wiechert
2019-10-08 11:53
has joined #general

yosevuk
2019-10-08 14:31
Great, thank you both!

pkuang
2019-10-08 15:54
Hi, is there a recommended/supported workflow for a consumer who is also a library that is a dependency of another consumer? eg. Consumer A integrates with Provider X (A -> X) Consumer B pulls in the Consumer A library so by transitivity, B -> X so we need to make sure the current version of A used in B is compatible with Provider X Currently we establish this relationship by having library A publish its pacts with every release and having consumer B source these pacts, overwrite the 'consumer' field to B, and publishes it along with any pacts generated from B. This allows the provider X to verify against all use cases of its API possibly hit by B to ensure B is using a compatible version of the library A As a side note, we only require the provider verify against the latest version of library A but ensure compatibility with older versions of A only if they are actively used by other consumers via the pact merging method above. Our current solution is not scalable since we don't have an automated way for B to detect which of its library deps contains pact integrations and it is even more complex when there is a longer dep chain, eg. For provider X and provider Y, there exists library consumer A -> X and library consumer C -> Y, where consumer B deps on A and A deps on C, so the resulting integrations are C -> Y, A-> X, A -> Y (transitively), B -> X & B -> Y (transitively) Let me know if we're doing something wrong here or if there is some established workflow that supports this. Thanks!

rbhati
2019-10-08 17:17
hi @bethskurrie appreciate your response, I'm on pactman

rbhati
2019-10-08 17:18
I think in last few days i burned all my brain juices to understand how pact works, however now i'm brain dead after I been blocked by pact-verifier

rbhati
2019-10-08 17:22
my test script is ``` import unittest from pactman import Consumer, Provider import requests import atexit pact = Consumer('Joor-UI').has_pact_with(Provider('Atlas'), file_write_mode="overwrite", # pact_dir=, port=8155, use_mocking_server=True) pact.start_mocking() atexit.register(pact.stop_mocking) class AtlasRetailerName(unittest.TestCase): def test_get_retailer_name(self): expected = { "errors": [ { "extensions": { "code": "UNAUTHENTICATED" }, "message": "Context creation failed: Missing auth" } ] } pact.given( 'test_data_setup' ).upon_receiving( 'a request for UserA' ).with_request( 'POST', '/' ) .will_respond_with(400, body=expected) with pact: response = http://requests.post(pact.uri) print(response.json()) ```

rbhati
2019-10-08 17:24
this works with -> ```pact-verifier``` however I want to make a http request for test data setup that returns a json and I must retrieve values out of json to proceed

rbhati
2019-10-08 17:25
#pact-python please help ^^

ckotyan
2019-10-08 17:52
Oops

ckotyan
2019-10-08 17:55
sorry wrong window

dannybrown2710
2019-10-08 18:34
Thanks for your help. Was facing issues with sqlite

matt.fellows
2019-10-09 00:15
:+1:

matt.fellows
2019-10-09 00:15
For a real app you should use Postgres or MySQL

tmok01842
2019-10-09 00:20
Hi all - I've got an error to report. My company has a pact broker account and when people are attempting to view the matrices they're getting 'internal server error'

uglyog
2019-10-09 00:22
Please ask in the #pact-broker channel

tmok01842
2019-10-09 00:23
Ah, ok. Thanks

jovallep
2019-10-09 05:41
has joined #general

olaniyanayobamijr
2019-10-09 06:34
has joined #general

nsshinde27
2019-10-09 10:05
has joined #general

grzegorz.polek
2019-10-09 14:22
has joined #general

catrionamcgarvey
2019-10-09 14:47
Hi - are there any pitfalls if I have a service which is both a provider and a consumer using Pact? specifically if I publish/verify it in the broker with the same name as a consumer and provider respectively?

mauricio.galeas
2019-10-09 15:38
has joined #general

pravera
2019-10-09 17:27
Hi! We?ve worked with many services which are consumer and provider at the same time, and there?s no issue with that. You will have to do the proper consumer/provider configuration and that?s it! They will appear in the pact-broker as different rows for each role.

pravera
2019-10-09 17:30
As you can see, each pact will have the provider and consumer specified in the URL, so in this case, so if the service is consumer and provider, the URL?s are going to be different. `https://broker-base-url/matrix/provider/provider_name/consumer/consumer_name`

matt.fellows
2019-10-09 23:02
The broker should handle this scenario just fine. It?s very common.

bethskurrie
2019-10-10 00:37
Make sure the names match, or you won't be able to use can-i-deploy @catrionamcgarvey

giuseppemath
2019-10-10 01:24
has joined #general

matt.fellows
2019-10-10 01:44
Sorry, I started responding properly to this and then got sidetracked (:baby: ). Thanks Beth

tritorto
2019-10-10 06:17
I?ve done something similar - in that we are using a nuget package of the provide library which contains the ?models? and httpclient (generated via refit) that the client consumes - this of course is all .net packaging, but it seems to work well for us and we use that in the consumer side with type matching to generate the pacts

alexander.schwartz
2019-10-10 07:21
has joined #general

catrionamcgarvey
2019-10-10 09:28
thank you! :slightly_smiling_face:

elain.kelly
2019-10-10 14:50
has joined #general

elaine.kelly
2019-10-10 14:51
has joined #general

harshavardhan.kavuri
2019-10-10 15:25
has joined #general

harshavardhan.chowdar
2019-10-10 15:27
has joined #general

ryan.dens
2019-10-10 16:06
has joined #general

bethskurrie
2019-10-10 20:31
@rbhati you'll need to talk to the pactman author. That's not the same as pact-python

stanko.s.petkovic
2019-10-10 21:32
has joined #general

sai.bolam
2019-10-11 09:43
has joined #general

florian.nagel
2019-10-11 10:27
Hey all! Apart from the multiple language support offered by Pact, what other benefits are there to use Pact in favor of for example Spring Cloud Contract?

p0deje
2019-10-11 10:29
~AFAIK The latter doesn?t support messages (e.g. pub/sub, websocket)~

p0deje
2019-10-11 10:30
AFAIK The latter doesn?t support messages (e.g. pub/sub, websocket)

florian.nagel
2019-10-11 10:50
@p0deje That's what I believed as well. Do you know if they have introduced that recently? As I can recall I didn't see it the first time I was making inquiries about CDC testing.

gabriel.pichot
2019-10-11 10:57
has joined #general


florian.nagel
2019-10-11 11:39
Sorry, I misphrased that. Do you know *when* they introduced that feature? Sorry about the confusion

vsoto26
2019-10-11 13:41
has joined #general

vsoto26
2019-10-11 13:44
Hello! Has anyone used Pact with the Quarkus framework? Is it supported?

p0deje
2019-10-11 14:41
@antonello As far as I understand, Spring Cloud Contract is limited to a particular message protocol that is used by Spring, isn?t it? Pact on the other hand allows to use messages for any kind of asynchronous communication (e.g Kafka, WebSocket).

matt.fellows
2019-10-12 22:52
If it works on the JVM it should, but I don?t know enough about the specifics. I believe it?s JVM binary compatible, so in theory it should right?

mark.chambers
2019-10-13 13:31
has joined #general

florian.nagel
2019-10-13 13:46
The Spring cloud contract documentation does state that it supports integration for various messaging queues like for example Kafka, or RabbitMQ, but don't quote me on this.

florian.nagel
2019-10-14 08:43
@matt.fellows What's your take on this? You are probably more informed on this topic than I am.

darragh.grace
2019-10-14 10:59
has joined #general

venkateshmca2002
2019-10-14 11:03
has joined #general

venkateshmca2002
2019-10-14 11:12
Hi... I am trying out pact JVM. I want to test a resource accepting POST request and expects JSON as payload. I wish to validate the contents of the payload. Is it possible to do it pact. Am i right to expect this out of pact... would appreciate any inputs in this regard. thanks

hstene
2019-10-14 11:56
Yes. Yes, it is. All of this should be documented on http://pact.io and on the pact-jvm github

matt.fellows
2019-10-14 13:48
They are roughly equivalent as stated above. SCC have done a great job, and have also worked hard to get integration with Pact happening via serialising to a pact file (thereby allowing more choice of tools/hybrid Pact/SCC rollouts and also integration with our pact broker. The big differences outside of language specific are tighter integration with the Pact Broker workflows (CI/CD) and the approach to messaging / async. SCC is tighter integrated into Spring libraries and common tools, whereas we decouple ourselves from the various tools and focus more on the payload moving between them

matt.fellows
2019-10-14 13:49
It's been a while since I've looked deep into SCC, there are likely differences in how to do the matching.

florian.nagel
2019-10-14 14:42
Thank you for the input! Appreciate it. It's more or less what I thought, but it's great to have some confirmation. Cheers!

akazantseva2
2019-10-14 16:16
has joined #general

safiyya
2019-10-14 16:47
has joined #general

novyludek
2019-10-14 17:39
has joined #general

kah.goh
2019-10-14 21:44
has joined #general

gaurav.chhabra
2019-10-15 02:24
has joined #general

mateusz.zalewski
2019-10-15 07:41
has joined #general

dannybrown2710
2019-10-15 09:49
Hi Team, I have a doubt, is there any way to categorize pacts for projects in Pact broker(open source)? The UI to show pacts looks over populated and is alphabetically sorted, which doesn't help in categorizing. Thanks in advance.

matt.fellows
2019-10-15 10:22
Unfortunately not, sorry!

colin.bean
2019-10-15 14:08
has joined #general

tjones
2019-10-15 23:57
You could achieve this by prefixing consumer names with projects

neil.syrett
2019-10-16 09:37
has joined #general

akiro
2019-10-16 10:26
has joined #general

akiro
2019-10-16 10:57
Hi Team Could you please help me to clarify next part of documentation https://docs.pact.io/best_practices/provider#only-stub-layers-beneath-where-contents-of-the-request-body-are-extracted How deep is better to stub in three-tier architecture (transport details => business logic => data resources)? I have two options: 1). Stub business logic completely - it will allow me to keep tests simple, but at the same increase possibility of someone forgetting about them during code changes, which would lead to an incorrect contract, because stub would still return old version of the data. 2). Stub only third-party interacted to which we don't access to - for example, we are using a real database without any stubs, but still stub interactions with other microservices (maybe with pact as well). As minus it would make the provider side of contact tests similar to API testing of the microservice. From my perspective first one better reflects the essence of contract testing, but narrowing the scope only to the transport interaction.

florian.nagel
2019-10-16 11:22
For anyone wondering when the feature was introduced. I have asked on their gitter and apparently they have supported messaging queues before Pact did. I neither know why I have missed it nor why it only recently came to my attention. @p0deje Pinging you because you were holding the same belief as I were :sweat_smile:

colin.bean
2019-10-16 14:25
has joined #general

joshwakefield45
2019-10-16 18:09
has joined #general

sliu7
2019-10-17 02:31
has joined #general

phillip.goff
2019-10-17 12:38
@here Noob question - Please can someone help identity what is the 'Dynamic variable substitution' to POST in a webhook the verification status. At the moment I can only see ${pactbroker.githubVerificationStatus} or ${pactbroker.bitbucketVerificationStatus}


phillip.goff
2019-10-17 14:43
I meant Please can someone help identify not identify...

phillip.goff
2019-10-17 16:23
ignore my question above as I have jumped the gun and I am still working my way through the guides https://docs.pact.io/best_practices/pact_nirvana

jennifer.molis
2019-10-17 16:25
has joined #general

okereke.ruth
2019-10-17 20:55
has joined #general

bethskurrie
2019-10-18 04:07
@akiro I tend to use approach 2, unless there are serious complications that would make it unviable. @tjones was telling me the other day that they had some pact tests that all passed, but then the services failed in real life because they'd stubbed out their business logic during pact verification.

bethskurrie
2019-10-18 04:09
Pact people, especially newbies. I'm just having a look at the "was this helpful" results for http://docs.pact.io, and this page rates poorly. I'm not sure why! Does anyone have any opinions? https://docs.pact.io/getting_started/sharing_pacts

abubics
2019-10-18 04:21
It feels like more of a sales page than a helpful information page? Like, it talks about all the benefits (and a tiny bit about the problems it aims to solve), but not much about how to use it, or a workflow, etc

bethskurrie
2019-10-18 04:22
Hm. It is just basically a copy paste of the Pact Broker's readme.

simon.nizov
2019-10-18 10:30
Perhaps an illustration would make the concept clearer?

tkimia
2019-10-18 14:05
I agree with Simon. In my opinion, this page covers too much to be a subpage of the "Getting Started" portion. (You even have a "Getting Started" section on the page itself). Might be good to expand on the basics in this page and move specifics into another page.

travis.anderson
2019-10-18 17:59
has joined #general

me_pact
2019-10-18 19:25
Why does `pact-broker` prefixes the versions with the letter `v`? Very often services are prefixed by the `v` in their version, and when they publish the version to `pact-broker` it's shown as `vv1.2.3` in the frontend. Does it make sense to open a PR to remove this?

bethskurrie
2019-10-18 19:45
OK, I'll have a go at updating it with that on mind. Thanks everyone.

matt.fellows
2019-10-19 00:49
That's interesting. I use the prefix on libs with semantic versions (but not APIs generally). If you can demonstrate the issue it's worth raising, thanks

me_pact
2019-10-19 14:33
For example, this happens with non-semantic versions as well:

me_pact
2019-10-19 14:33
The original tag starts with `4fd...`, but as you can see, the prefix is still there.

slawomir.radzyminski
2019-10-19 19:33
has joined #general

slawomir.radzyminski
2019-10-19 19:34
Hi :slightly_smiling_face: I'm struggling a lot with `State Change Request Failed - ContentType.get(entity) must not be null` errors on pactVerify step. Has anyone experienced this? Some implementation and details in thread :point_down:

slawomir.radzyminski
2019-10-19 19:35
```@Profile("pact") @RestController public class PactController { @RequestMapping(value = "/pactStateChange", method = http://RequestMethod.POST) public void providerState(@RequestBody Map body) { if (body.get("state").equals("No nationality")) { Nationality.setNationality(null); } else { Nationality.setNationality("Japan"); } } }```

slawomir.radzyminski
2019-10-19 19:37
``` project(':example-provider') { apply plugin: 'au.com.dius.pact' jar { version = '1.0.0' } task startProvider(type: SpawnProcessTask, dependsOn: 'assemble') { command "java -Dspring.profiles.active=pact -jar ~/IdeaProjects/Pact-JVM-Example/example-provider/build/libs/example-provider.jar" ready 'Started ContractProvider' } task stopProvider(type: KillProcessTask) { } pact { serviceProviders { ExampleProvider { protocol = 'http' host = 'localhost' port = 8080 path = '/' stateChangeUrl = url('http://localhost:8080/pactStateChange') startProviderTask = startProvider hasPactsFromPactBroker("http://localhost:9292") terminateProviderTask = stopProvider } } }```

slawomir.radzyminski
2019-10-19 19:38
```> Task :example-provider:pactVerify_ExampleProvider FAILED Verifying a pact between Miku and ExampleProvider [from Pact Broker http://localhost:9292/pacts/provider/ExampleProvider/consumer/Miku/version/1.0.0] Given State Change Request Failed - ContentType.get(entity) must not be null Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Verifying a pact between Nanoha and ExampleProvider [from Pact Broker http://localhost:9292/pacts/provider/ExampleProvider/consumer/Nanoha/version/unspecified] Given State Change Request Failed - ContentType.get(entity) must not be null Given No nationality State Change Request Failed - ContentType.get(entity) must not be null Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') Failures: 0) Verifying a pact between Miku and ExampleProvider - Pact JVM example Pact interaction ContentType.get(entity) must not be null 1) Verifying a pact between Nanoha and ExampleProvider - Default nationality ContentType.get(entity) must not be null 2) Verifying a pact between Nanoha and ExampleProvider - No nationality ContentType.get(entity) must not be null```

slawomir.radzyminski
2019-10-19 19:39
Tests pass from IntelliJ

slawomir.radzyminski
2019-10-19 19:40
Spring boot 2.2.0 pact 4.0.1

matt.fellows
2019-10-19 21:05
Looks like just a display thing. Does it affect API calls via CLI or otherwise?

me_pact
2019-10-20 11:43
I wouldn't say so. I checked the pact-broker code, looks like it's rendered with `v` from the Ruby code only, and not persisted with `v` in the database.

matt.fellows
2019-10-20 20:13
:+1:thanks for looking

me_pact
2019-10-20 21:42
Is there a way of getting a specific revision of a published Pact version through the Pact broker API?

bethskurrie
2019-10-20 21:48
Yes


abubics
2019-10-20 22:15
Good idea to move this to #pact-jvm :)

abubics
2019-10-20 22:17
Just going by the error message, it sounds like something is missing a content type, or the content type in a request doesn't match the body?

abubics
2019-10-20 22:20
What content type does your state change endpoint expect?

me_pact
2019-10-20 22:30
Hey Beth! Looks like this will only return the latest Pact version, but I can't specify a revision of the version. This happens in cases where the version of the Pact is overwritten, which is my case.

me_pact
2019-10-20 22:36
I'm building a integration for Concourse CI, and I would like to point to the most specific version of a resource, in this case a Pact contract revision. I can see that they are stored in the database, but I couldn't find a way to get a specific revision through the API.

bethskurrie
2019-10-21 00:09
don't overwrite things :stuck_out_tongue:

bethskurrie
2019-10-21 00:11
If you're overwriting pacts because you're re-publishing them with the same consumer version, you're going to get race conditions, which make can-i-deploy return different results depending on when it gets executed.

bethskurrie
2019-10-21 00:13
There is a form of the pact URL that uses the *pact* version (not the consumer version) that is like a permalink - it will never change.

bethskurrie
2019-10-21 00:14
`/pacts/provider/PROVIDER/consumer/CONSUMER/pact-version/SHA` but there isn't really a great way of getting that URL.

bethskurrie
2019-10-21 00:14
Can you explain the goal you're trying to achieve?

bethskurrie
2019-10-21 00:15
Or maybe, the problem you're facing that you're trying to get around by doing something this unusual?

bethskurrie
2019-10-21 00:22
Hey Pact people. Here at Pactflow, we're doing some research into whether we could use OpenAPI to provide a Pact-like experience for people who can't/don't use Pact (eg. when there are too many consumers to make Pact feasible) @uglyog has written a blog post about our current thinking here: https://blog.pactflow.io/the-curious-case-for-the-provider-driven-contract/ We're trying to get input from as many OpenAPI users as we can, so to that end, I've put together a short survey. We'd really appreciate your input! We're offering a 10% discount on a year of Pactflow as a sign of our appreciation. https://dius.typeform.com/to/Dd66SC

ruben.perezg
2019-10-21 07:06
I was wondering about this, because we use the _approach 1_... Could you help me understand what issues could you make tests pass, but "break" your contract in production?

bethskurrie
2019-10-21 08:36
@tjones can you remember the details of your example?

ppaduch
2019-10-21 10:32
has joined #general

kalpana.k
2019-10-21 11:28
has joined #general

ppaduch
2019-10-21 12:08
Hi All , I am using javascript wrapper. I am struggling with a basic function eachLike for MessagePact. It seems to be a defect: Pact Matchers are not respected in eachLike, any created contract uses only type matching. The basic example from documentation does not work as expected . In the documentation there is an example https://github.com/pact-foundation/pact-js#match-based-on-arrays: pact.eachLike(obj, { min: 3 }) . It?s written that *Where obj can be any javascript object, value or Pact.Match.*. In the attached example *animalBodyExpectation* we use Pact.Match term, however the contract is built according to ?types? not regexp . I would expect that *gender* would be built using regexp matcher.

roi.otero.morales
2019-10-21 12:27
has joined #general

saranyabalaji13
2019-10-21 12:43
has joined #general

akiro
2019-10-21 13:36
@bethskurrie Thanks for the answer, I will rework my POC to use real data. Also as far as I understand as minus of not using stubs I will have to directly specify important fields (like id for getById to check exactly specific record during validation of contract) within a provider state name to use them in consumers.

me_pact
2019-10-21 16:00
I responded in the other thread in #pact-broker. Speaking of the SHA endpoint, why is it exposed if there is no good way of getting the SHA for the Pacts? This might be a be a good way of solving the issue that I have. Edit: Looks like this is exactly what I need, a unique identification for each Pact, so I don't have to rely on the `createdAt` field. I had to dig the SHAs from the DB, as I'm unsure where else can I get them from.

me_pact
2019-10-21 16:51
Looks like this issue https://github.com/pact-foundation/pact_broker/issues/307 is very similar to what the resource does at the moment.

stevi.deter
2019-10-21 17:15
has joined #general

mohsin
2019-10-21 20:11
<ignore>

oliver.nautsch
2019-10-22 08:08
has joined #general

bartlomiej.twarog
2019-10-23 12:49
has joined #general

mateusz.zalewski
2019-10-23 12:52
has joined #general

bethskurrie
2019-10-24 00:09
@me_pact The pact version sha is primarily used to make sure that the verification results are matched up to the right content. (eg. if someone publishes a pact for consumer version 1, the provider verifies, and during verification, the consumer overwrites the pact for consumer version 1 with different content - we have to make sure that the verification results get associated with the right content, regardless of which consumer version is associated with it.)

bethskurrie
2019-10-24 00:10
During verification, the URL usually used to get a pact is the one that gives the latest one for a tag. Having the "permalink" to the exact pact content is not really a "thing".

bethskurrie
2019-10-24 02:56
@ppaduch it should work. Can you make a executable example using a fork of the example directory in the pact-js repository?

erfana.sikder
2019-10-24 03:43
has joined #general

erfana.sikder
2019-10-24 03:46
hey Pact folks, I have a consumer project in clojure - do you have any demo project in clojure or does pact work with clojure?


uglyog
2019-10-24 03:54
There is also a provider module for Leinigen

ryan.dens
2019-10-24 04:07
any good examples of small services created which accept provider states? https://github.com/pact-foundation/pact-provider-verifier#api-with-provider-states

erfana.sikder
2019-10-24 04:08
awesome thanks

monch1962
2019-10-24 07:10
Hi @bethskurrie we looked at doing that NAB a few months back, but there's are few problems and shortcomings: - OpenAPI is inherently provider-side only; it describes what a provider delivers, and has no way of capturing what consumers are consuming - OpenAPI has no concept of providerState, so the best it can do is e.g. generate a random 9-digit string in response to requests. From the consumer side, you typically want to have a capability to generate different responses based on different sets of request data, but OpenAPI doesn't support that - because OpenAPI is provider-only, you lose traceability between what providers provide and what consumers consume. The impact is that there's no automated mechanism to track what the implications are of e.g. the provider removing a field from a JSON response, or changing the structure of the response. This means you now need a separate tool to help you manage these changes through the lifecycle of the provider - following on from the last point, you can't implement a Pact broker-like capability due to that lack of traceability. The best you can do is have sets of consumer-side tests that hit an OpenAPI-defined stub - again from the same point: it becomes difficult to decommission old versions of provider APIs, because there's no mechanism to track (over time) which consumers are using which versions of those APIs

ppaduch
2019-10-24 13:54
Yes, I can. I will do it and let you know, thanks

matt.fellows
2019-10-24 21:32
Hi Ryan, would you mind elaborating a bit further? Which language are you using? Generally speaking, this libarary is only used where we don?t have natural language bindings (e.g. JS, .NET, Python, Ruby, Go, PHP ?)

ryan.dens
2019-10-24 21:56
Hey Matt, I?m looking to setup and teardown various states on the provider from the pact-jvm maven plugin. As I understand it, my consumer pact specifies some state and the jvm maven plugin specifies a stateChangeUrl which accepts a `ProviderState` describing the state to setup or teardown. The service that receives this request is then responsible for setting up and tearing down the state

ryan.dens
2019-10-24 22:00
We?re not looking to modify our Provider to accept special pact json to setup and teardown state, so I?m looking at setting up a separate service which listens for requests at the ?stateChangeUrl? specified in the maven provider plugin and modifies the state of the provider by connecting directly to the DB, rather than using the Provider?s API

ryan.dens
2019-10-24 22:01
Is that the correct approach? If it is, I?m simply looking for a sample project which has been setup to receive messages from the maven provider plugin about setting up and tearing down state in the Provider?s database

ryan.dens
2019-10-24 22:03
@matt.fellows

matt.fellows
2019-10-24 22:42
I?ll double check, I?m not sure from memory.

ryan.dens
2019-10-24 22:43
Thanks! I have something simple working now, but don?t want to deviate too far from the norms. So far I?ve gotten the maven plugin to send a message to the service describing the desired state, but i haven?t gotten it to send a ?teardown? message, which i presume should happpen after verification?

ryan.dens
2019-10-24 22:44
Perhaps a better question for Ron?

matt.fellows
2019-10-24 22:44
ok cool, I was about to suggest the same thing

matt.fellows
2019-10-24 22:44
hmm Teardown, I?m not sure. the Ruby one doesn?t do that from memory, as each state should be self sufficient

ryan.dens
2019-10-24 22:46
Am i misunderstanding the tear_down step here?


ryan.dens
2019-10-24 22:49
my initial thought was to add the data to the DB necessary to verify this pact but that best practices would dictate I should remove the item from the DB after the pact verification

gajjarbee
2019-10-25 01:06
has joined #general

bethskurrie
2019-10-25 02:20
@monch1962 we've been though exactly the same thought process as you. We think we have a technical solution, but we're trying to work out if there is demand for it. Have you read this? https://blog.pactflow.io/the-curious-case-for-the-provider-driven-contract/

bethskurrie
2019-10-25 02:22
> OpenAPI is inherently provider-side only Providers could write OAS, consumers could write pacts, and the two can be verified against each other using the swagger pact verifier that Atlassian open sourced (or even better, inside the broker itself) > OpenAPI has no concept of providerState This would either have to be defined elsewhere (eg as dredd does it) or added to the OAS with custom extensions. > because OpenAPI is provider-only, you lose traceability between what providers provide and what consumers consume Pact/OAS verification would provide this

ryan.dens
2019-10-25 04:16
update: got this working. There?s a config called `stateChangeTeardown` which adds an `action` attribute to the state change server. This config is documented in the gradle plugin readme, but since I was using the maven plugin I had to dig through source to find it

mangesh.sam18
2019-10-25 08:00
has joined #general

rbhati
2019-10-25 19:20
hello @bethskurrie need a quick suggestion, we have a ecosystem where one of our consumer is an ios app and I need help to under how can we write consumer sider unit test using pact which end up generating pact json files

rbhati
2019-10-25 19:20
any pointers will he highly appreciated

ryan.dens
2019-10-25 21:41
Made a simple example here that works with the pact-jvm maven plugin if others ask about this in the future: https://github.com/ryandens/pact-provider-state

bethskurrie
2019-10-25 23:47
@rbhati try #pact-swift


matt.fellows
2019-10-26 01:44
Awesome, thanks @ryan.dens!

agarwalatrisha1212
2019-10-26 12:22
Java

agarwalatrisha1212
2019-10-26 12:23
Could you share me details about workshop @matt.fellows



matt.fellows
2019-10-26 12:24
Take a read through http://docs.pact.io also if you haven?t already

vince.grossi
2019-10-26 19:41
has joined #general

brandontylerwilliams
2019-10-27 20:15
has joined #general

brandontylerwilliams
2019-10-27 20:25
~Hi all!~

tjones
2019-10-28 00:24
Apologies for the slow response - the problem we had was the whole controller was being stubbed. We were testing the translation from the domain objects to the Pact response

tjones
2019-10-28 00:24
This is good practice, because it's not testing the business logic, but if we had put the stub further down (say, beyond the domain layer), we would have discovered that some of the domain objects we tested in the Pact test could never be produced by any code path

tjones
2019-10-28 00:25
(not sure I explained that well, let me know if you'd like more details)

tjones
2019-10-28 00:25
For practical purposes, I think I prefer option 2

tjones
2019-10-28 00:25
but, for a "pure contract test", option 1 is more correct

bethskurrie
2019-10-28 00:26
I take a pragmatic approach, and default to option 2 unless there are performance issues to make it untenable.

tjones
2019-10-28 00:26
Contract testing isn't provider functional testing - but that doesn't mean your contract tests can't naturally include some functional testing.

tjones
2019-10-28 00:27
I would get worried if you started to try to enumerate your provider functional code paths through a contract test

erfana.sikder
2019-10-28 03:53
Hi, my provider depends on multiple microservices to generate a result and same goes with my consumer it depends on multiple microservices to make a request. In this case, should I mock all the dependencies on additional services using any mock framework? If you have any documentation/resource can you please send me the link. Curious to know what is the right approach in this scenario where the microservice u are testing is dependent on others.

bethskurrie
2019-10-28 03:55
This is always a tricky question to answer. It is definitely recommended to mock downstream dependencies, but if you do, you need to ensure that you are sure that the responses you are mocking are valid ones.

bethskurrie
2019-10-28 03:55
To do this, you would then generally add a pact with the downstream service.

bethskurrie
2019-10-28 03:55
How you do this depends on which language you are using.

bethskurrie
2019-10-28 03:55
Which one is it?


bethskurrie
2019-10-28 04:20
You remember what I've written better than I do @matt.fellows :stuck_out_tongue:

erfana.sikder
2019-10-28 04:22
@bethskurrie the provider is Golang and consumer clojure

erfana.sikder
2019-10-28 04:22
@matt.fellows thanks for the link, having a look at it

bethskurrie
2019-10-28 04:23
Unless Matt has done a heap of work since I last checked, go wraps the generic provider verifier that operates at the HTTP level, so you'll need to either stub out your downstream providers within the code, or provide running HTTP stubs.

erfana.sikder
2019-10-28 04:28
I am thinking of spinning up docker with mocked responses from all the dependencies

matt.fellows
2019-10-28 04:33
Any reason you couldn?t just mock the interfaces in memory?

matt.fellows
2019-10-28 04:33
(that works too, btw, but obviously will have tradeoffs on time/setup etc.)

erfana.sikder
2019-10-28 04:52
I can do in memory as well but I thought docker with setup would be more reliable and for the huge amount of dependencies we have

lalin1982
2019-10-28 10:04
has joined #general

prabhuramchennai
2019-10-28 10:44
has joined #general

lalin1982
2019-10-28 10:44
Hi, I am new using Pact and this trying to define good practices within my team. We currently have one microservice that consumes two different providers, we have created two contracts and we have raised doubts whether the name of the contract should be the same for both or should be different. What would be the best way to define it? Regards,

matt.fellows
2019-10-28 10:54
You don't name the contract, you name the consumers and providers

matt.fellows
2019-10-28 10:55
If it's the same consumer or provider being used in different situations, use the same name

matt.fellows
2019-10-28 10:55
What's the actual problem?

lalin1982
2019-10-28 11:34
I have one microservice that manages user accounts, this is my consumer. The microservice calls two APIs, one to recover user activity (activity-provider) and another to manage subscriptions to external services (external-service-provider), then we have two pacts (one for each provider) and we have the doubt whether to define a consumer for each pact or should be the same. Looking for examples in Github we have seen examples of both approaches.

matt.fellows
2019-10-28 11:40
You just have one consumer the ?user accounts? component. You should have two pacts, but the `consumer` property should be the same in both of them

matt.fellows
2019-10-28 11:41
What you just described sounds like a perfectly normal

matt.fellows
2019-10-28 11:41
> we have the doubt whether to define a consumer for each pact or should be the same What does this mean? How are you creating the pacts without defining a consumer in the first place?

matt.fellows
2019-10-28 11:41
Sorry if I?m misunderstanding something

lalin1982
2019-10-28 11:57
We are still defining the pacts and reading documentation. And we had doubts about how to define it. With the answer you have given me you have clarified all my doubts. Many thanks.

matt.fellows
2019-10-28 12:00
ah cool

matt.fellows
2019-10-28 12:00
sorry you were just speaking sense, so hence my confusion - glad you?re here. All the best! :slightly_smiling_face:

prabhuramchennai
2019-10-28 12:39
Hi, there is often question from my teams on who should create the contract. From the principles I understand it should be the consumers but often the consumers will not know all about the services. If the provider is creating and maintaining the services shouldn't they be creating the Contract/Pact for the first time and then maintained by consumers?

kyle.hammond
2019-10-28 19:13
Warning: long post First, the provider and consumer obviously need to communicate prior to the contract being created at all. The two sides need to work out in general what services the provider will handle. Second, generally the provider exists because of the consumer?s need for it. If there were no consumers that needed the service, there?s no need for a provider at all. From that perspective, it makes sense for the consumer to create and maintain the contract. The contract formalizes the consumer?s needs and expectations for that provider. You said ?often the consumers will not know all about the services?. You?re exactly right; each consumer will only know about their part of the contract with the provider. As far as each consumer contract is concerned, that?s all the service has to provide. If as an implementation detail you have two (or more) consumers that have very similar contracts, then by all means share the provider. When developing the provider you can do so in such as way as to satisfy and test both (or multiple) contracts. A contract is not the same as complete documentation of the provider. Contracts are, by design, very specifically between a single consumer and a single provider. In fact, a single contract is often not the complete documentation of a consumer either. The consumer may reach out to multiple providers in order to perform the consumer?s work. In that scenario, multiple contracts are in place both on the consumer and provider sides. Hope that helps to explain why consumer-driven contracts are the way they are.

monch1962
2019-10-28 20:18
I think there's definitely value in using OpenAPI in combination with Pact, even if only because many large companies already have a big investment in OpenAPI that they don't want to lose. If you can position Pact as an addition to, rather than a replacement for, OpenAPI they're far more likely to give Pact a try. With respect to the the idea of adding vendor/custom extensions to OpenAPI, my personal preference would be to make the providerState "object" (? - is that what you'd call it?) more "formal". I've already got code that can parse Pact's requests/response pairs and generate executable test cases and/or stub configs in any language or framework. (Chasing permission to open source it now...) I'd love it if I could take the same approach to parse a generic Pact's providerState, generate the necessary state data and then execute the test - without writing any app-specific code. As a very simple example, if providerState had to be e.g. an array of SQL CREATE or UPDATE statements, I could extract that SQL, execute it against a datastore to load the necessary data to support a test, then run the test. Unfortunately that wouldn't work for anything but SQL databases, but I'd have a self-maintaining test case that could be created and executed directly out of a Pact.

matt.fellows
2019-10-28 20:27
So, the _pact_ contract is generated by the consumer - our tooling basically enforces this. The only way for it not to be the consumer, were if the Provider team wrote your unit tests for you that tested your code. So by definition, it seems unlikely this would happen

matt.fellows
2019-10-28 20:28
Everything Kyle said stands, but also consider that using tools like OAS doesn?t preclude the use of Pact/CDC either. They are complementary technologies

matt.fellows
2019-10-28 20:28
In fact, we are exploring even further how we support OAS as a first class citizen in this contract testing ecosystem

matt.fellows
2019-10-28 20:29
The most important statement that applies to any mode > First, the provider and consumer obviously need to communicate prior to the contract being created at all.

bethskurrie
2019-10-28 21:07
Great answer @kyle.hammond

acooper106
2019-10-28 22:18
is anyone using pact with spring boot app? I'm trying to use it but we are seeing flaky tests. I have 2 tests and one will pass or fail depending on if its ran 1st or 2nd

bethskurrie
2019-10-28 22:23
Is it the provider? Sounds like the provider state data isn't being cleaned properly between interactions.


prabhuramchennai
2019-10-29 08:42
~Nice answers. Thanks. When it's a new service or when there is a change it makes sense. Suppose there is a team with existing services and which wants to adopt contract testing, that's where the difference starts. With a huge list of contracts to be created, consumer expects the provider.. In the tools like Spring cloud contract, we create the contract file first which can be either~

prabhuramchennai
2019-10-29 08:45
Nice answers. Thanks. 1. When it's a new service or when there is a change it makes sense. Suppose there is a team with existing services and which wants to adopt contract testing, that's where the difference starts. With a huge list of contracts to be created, consumer expects the provider.. 2. In the tools like Spring cloud contract, we create the contract file first which can be either be created by a consumer or provider. Eventhough PACT enforces it the PACT.Json could still be created by the provider and consumer can create a test for it later. Overall, what you say absolutely makes sense but since this will be an additional work for existing services, there's is always this confusion of who creates them. If I read you write, you say that even in this situation it must be the consumer who creates the contract..?


prabhuramchennai
2019-10-29 08:49
sounds interesting if the pact file could be generated from a swagger spec. Is this already developed?

bethskurrie
2019-10-29 08:49
No, sorry.

bethskurrie
2019-10-29 08:50
Again, the pact file would not be generated from the swagger document. That defeats the purpose.

bethskurrie
2019-10-29 08:50
The *test code* that generates the pact would be generated from the OAS.

bethskurrie
2019-10-29 08:50
The point of the contract is not to have the contract - it's to keep two sets of tests in sync.

matt.fellows
2019-10-29 09:52
I think there?s something in that. For us, the _contract_ file is an (important) artifact/side-effect, whereas an OAS is a specification that is useful in its own right

monch1962
2019-10-29 20:45
With respect to @kyle.hammond?s excellent response, let me give an different view. Many companies that work in regulated spaces (e.g. banks, wagering companies, some government departments) are creating APIs designed to be consumed by the general public. Realistically, no consumer is going to create and maintain contract tests for a banking API; the bank is going to publish APIs that they're prepared for consumers to use. The bank _could_ also publish a set of contract tests that those consumers could work with when writing code. These providers _could_ also provide a provider-side sandbox environment (either hosted, or downloadable) that supported execution of that set of contract test cases, helping consumers of their APIs to do their thing without having to create stubs. There's nothing inherent in Pact that makes it consumer-driven

adrian.mace
2019-10-30 01:10
has joined #general

sankalan.13
2019-10-30 06:05
has joined #general

sankalan13
2019-10-30 06:20
Hi @bethskurrie The current product I am testing pulls in game data in real time from a third party provider using APIs and we display it in the UI of our product. I will not be able to set up provider states in the code for the third party API provider. I have multiple services running, the gaming service communicates with the third party provider. Will I be able to write Pact tests between a third party provider and my UI consumer? If yes, how will I be able to set up provider states for certain APIs? (given that the APIs to test is only GET APIs) Could I leave my provider state end point to not do anything and verify the API responses with the third party provider in real time?


sankalan13
2019-10-30 08:10
Yep this helps. I will probably still go for Pact on this case instead of using VCR. Thanks Beth!!

acooper106
2019-10-30 15:01
this is actually the consumer side

acooper106
2019-10-30 15:02
Sounds like the solution is to add an @After teardown section. Any examples of this? What am I cleanning up after each test?

kyle.hammond
2019-10-30 19:50
Excellent points @monch1962. I both agree and slightly disagree. An organization may be creating APIs for the general public, but that organization isn?t creating API just to have an API. During API creation, they step into the role of an API consumer to think about what would be useful to expose in their API. They think about how a consumer could interact with the provider, and then document the API and test to that assumed consumer use. Even if they don?t have an explicit consumer-side application/service whose unit tests would drive the pact file creation, they still created their tests and documentation with a consumer mindset. I would love it if any public API would give me some specific tests that I could run from a consumer-side test that verified I was calling the API correctly without having to call the real API. I don?t know of any place that does that; I can set up sandbox or trial accounts with many places but then I would still be calling the real API; error states are particularly hard to test this way. It would be awesome if we could feed some OAS docs into a mock server (or convert OAS to pact first if needed), then have the consumer test against that. This theoretical mock server would verify that the consumer called the API correctly, but wouldn?t verify how much of the API it called (the consumer doesn?t have to hit every API endpoint).

rbhati
2019-10-30 19:59
I'm having a hard time getting this work, almost at the edge of give up

rbhati
2019-10-30 20:00
as soon as i uncomment line#13 `helloProvider = MockService(provider: "Hello Provider", consumer: "Hello Consumer")` test crash during compile time and no error thrown https://github.com/andrewspinks/PactSwiftExample/blob/master/PactSwiftExampleTests/PactSwiftExampleTests.swift

rbhati
2019-10-30 20:01
@matt.fellows and @bethskurrie ^^

rbhati
2019-10-30 20:20
we are on swift 5

rbhati
2019-10-30 20:56
All i'm trying to do is to write a consumer contract test that should end up generating pact json files that i can share with provider for verification

rbhati
2019-10-30 20:57
total block because of this issue, App build success but test fail and no log no message.

rbhati
2019-10-30 20:58
``` import UIKit import XCTest import PactConsumerSwift class PactSwiftExampleTests: XCTestCase { var helloProvider: MockService? // var helloClient: HelloClient? override func setUp() { super.setUp() helloProvider = MockService(provider: "Hello Provider", consumer: "Hello Consumer") // helloClient = HelloClient(baseUrl: helloProvider!.baseUrl) } override func tearDown() { super.tearDown() } func testItSaysHello() { helloProvider!.uponReceiving("a request for hello") .withRequest(method:.GET, path: "/sayHello") .willRespondWith(status: 200, headers: ["Content-Type": "application/json"], body: ["reply": "Hello"]) print("Hello") } ```

rbhati
2019-10-30 20:58
this is all i'm executing

uglyog
2019-10-30 21:25
The http client library used by your consumer app probably is caching the connections. Each test gets a new mock server, so for every second test the connection in the connection pool will be stale. You need to configure the http client to not cache the connections.

archana.rachuri
2019-10-31 01:46
Hey team I?m pretty much new to pact contract testing and I am setting up the framework in my team. I?m using jest to set it up. Apollo client is the consumer and provider is in graphql. Question: I have implemented contract testing using the jest example works well for one provider with global provider variable in pactSetup.js with beforeAll and afterAll setup in pacttestWrapper.js . Now I have same Apollo client with 2 providers. I am able to set up global provider variable for both providers in the pactSetup.js but I?m kinda stuck on how to setup it in a pactTestWrapper.js for two providers ?

matt.fellows
2019-10-31 02:08
You?re now going to have to manage the different pact providers separately. One approach is to create 2 providers in the pact wrapper (e.g. `provider1` and `provider2`) and then in your tests use each provider as required-


archana.rachuri
2019-10-31 02:37
Thanks @matt.fellows I?ve defined it exactly this way but how do I manage it in pactTestWrapper.js ? beforeAll() and afterAll() ? One approach that I figured out now is to use beforeAll().setup and afterAll().finalize in test file instead of a separate wrapper.js file. You think of any other alternative?

kist
2019-10-31 12:37
has joined #general

rbhati
2019-10-31 16:02
``` dyld: Library not loaded: @rpath/BrightFutures.framework/BrightFutures Referenced from: /Users/rajivbhati/Library/Developer/CoreSimulator/Devices/780359F9-BF84-4A2F-8374-FB1025A260A5/data/Containers/Bundle/Application/D55499E3-771A-4F17-BC42-57FA665D34FE/Brand.app/Frameworks/PactConsumerSwift.framework/PactConsumerSwift Reason: no suitable image found. Did find: /Users/rajivbhati/Library/Developer/CoreSimulator/Devices/780359F9-BF84-4A2F-8374-FB1025A260A5/data/Containers/Bundle/Application/D55499E3-771A-4F17-BC42-57FA665D34FE/Brand.app/Frameworks/PactConsumerSwift.framework/Frameworks/BrightFutures.framework/BrightFutures: no matching architecture in universal wrapper ```

ryan.dens
2019-10-31 16:30
:wave: I have a general question about ?pact nirvana?. We?re in the process of trying to figure out our ideal workflow. Right now, our plan is: 1. a provider publishing pacts to a broker on staging deploy (merging PR to master) 2. webhook to trigger a build which verifies and publishes verification results 3. Using `can-i-deploy` in the provider prior to deploying to make sure that there wasn?t a verification failure However, is there an ?ideal way? for the provider to know, prior to merging a PR to master, if a changed contract will break a build?

ryan.dens
2019-10-31 16:33
The only way I can think of is to publish pacts to the broker on a PR as well, with staging and production contracts tagged as such, but not sure if that is ?correct?

rbhati
2019-10-31 18:56
Any help here


matt.fellows
2019-10-31 20:45
I'm not a iOS developer and nothing stands out to me. If you have a build failure you can reporoduce and share on GitHub is suggest raising an issur

tjones
2019-11-01 00:13
Yes, perfect. This is a common question - are there other places in the documentation that we should add this info?

ryan.dens
2019-11-01 00:38
No pact nirvana seems like the one stop shop for this kinda thing, I just skimmed over it the first couple of times

ryan.dens
2019-11-01 00:42
Perhaps it would makes sense to make a comment in the section about versioning?

monch1962
2019-11-01 05:02
Has there been any discussion around adding an optional "tags" field to each interaction e.g. `{..., "tags": ["smoketest", "nondestructive", "performance", ...], ...}` ? It'd be handy to be able to select different subsets of tests from a Pact contract, for different circumstances

bethskurrie
2019-11-01 06:02
It's been briefly mentioned, but we've never had a strong enough reason for it to be added.

bethskurrie
2019-11-01 06:03
Thanks for the feedback Ryan.

douglasortego
2019-11-01 06:08
has joined #general

monch1962
2019-11-01 06:44
Would "please implement this feature" be enough? :grin: Seriously: what sort of justification would be necessary to add it? I'm happy to put something together

bethskurrie
2019-11-01 06:50
The problem is, we've semantically versioned the pact specification.

bethskurrie
2019-11-01 06:51
And Ruby (and hence js, go, php etc that wrap Ruby) are stuck on an old version because Time and Effort.

bethskurrie
2019-11-01 06:52
So, to add it to everything, we'd either have to add it to the semantically versioned specification, or throw in the towel on the sem versioning and just go wild like HTML.

bethskurrie
2019-11-01 06:53
Personally, I'm all for dropping the spec numbers, as they're holding us back, imo, but I'm not sure others share my view.

monch1962
2019-11-01 06:59
Hmm, OK. In the short term, it sounds like I need to think through the implications of adding a custom tags field if I want to implement a test suites capability across my Pact contracts

marius.maaland
2019-11-01 11:51
Is there currently an issue with the Pactflow broker? I'm getting a `503` error when trying to publish a Pact with tags. Publishing without tags works fine. Publishing *with* tags to a locally hosted Pact broker works fine. I am using `pact-go` to publish the Pact This is the error I am getting: ``` 2019/11/01 11:25:18 [ERROR] service: Failed to tag version b04ade69141427904b87b40f4d14f3e8561f2fb5 2019/11/01 11:25:18 [ERROR] service: of TestClient due to error: PactBroker::Client::Error - <html> 2019/11/01 11:25:18 [ERROR] service: <head><title>503 Service Temporarily Unavailable</title></head> 2019/11/01 11:25:18 [ERROR] service: <body bgcolor="white"> 2019/11/01 11:25:18 [ERROR] service: <center><h1>503 Service Temporarily Unavailable</h1></center> 2019/11/01 11:25:18 [ERROR] service: </body> 2019/11/01 11:25:18 [ERROR] service: </html> 2019/11/01 11:25:18 [ERROR] service: } 2019/11/01 11:25:18 [ERROR] service: One or more pacts failed to be published 2019/11/01 11:25:18 [INFO] 2019/11/01 11:25:18 [INFO] Tagging version b04ade69141427904b87b40f4d14f3e8561f2fb5 2019/11/01 11:25:18 [INFO] of TestClient as "PR-8" ```

marius.maaland
2019-11-01 11:52
Another error that might be related: when I click on "View pact" in the Pactflow UI, I get the following error page

ryan.dens
2019-11-01 14:03
Happy to help! Thanks for having great docs :thumbsup:

toby.brown
2019-11-01 14:48
has joined #general

rbhati
2019-11-01 20:39
Hi @matt.fellows & @bethskurrie, I wipe out everything and reinstall from scratch and it seems like things are working, Appreciate your thoughts and help

matt.fellows
2019-11-01 21:24
:+1:

bethskurrie
2019-11-01 21:27
Hi @marius.maaland, sorry for the slow response, we're in Australia, and Pager Duty didn't report anything overnight.

bethskurrie
2019-11-01 21:27
I'll look into it now.

bethskurrie
2019-11-01 22:06
@marius.maaland I can see two 503s in the ELB metrics from Friday 11:22 and 11:25 UTC (you'll have to convert that to your TZ) which from my calculations is about 30 minutes before you reported it on the slack channel.

bethskurrie
2019-11-01 22:11
I can't see any 503s in the application logs, and our semantic monitor hasn't raised a blip. Can you let me know if you're still seeing the issue? It may just be coincidence that it happened to be those tagging requests, as I can see no errors for any other tagging requests.

bethskurrie
2019-11-01 22:12
Also, i'm kind of confused that the tag publishing failed because I was sure it had retries in it. I'll double check.

bethskurrie
2019-11-01 22:14
Hm, it does. ``` Retry.while_error do pact_broker_client.pacticipants.versions.tag pacticipant: pacticipant_name, version: version, tag: tag end ``` I'm assuming you've only copied part of the logs in then.

bethskurrie
2019-11-01 22:19
I got this error report yesterday @marius.maaland - the resource in that URL doesn't exist, and the code needs to gracefully handle the 404.

marius.maaland
2019-11-01 23:15
hmm no that should be all of the pact publishing logs

bethskurrie
2019-11-01 23:30
:thinking_face:

bethskurrie
2019-11-02 04:21
@marius.maaland what was the name of the tag? We're wondering if it was rejected by the WAF.

bethskurrie
2019-11-02 04:26
That would be the main difference between a locally hosted broker and Pactflow.

bethskurrie
2019-11-02 05:27
OK, looks like there is a line feed in the consumer version of the tag request. Not sure if this is causing the problem, but try stripping it out to see.

forestcarlisle
2019-11-02 19:34
has joined #general

erik
2019-11-04 00:16
has joined #general

mangesh.sam18
2019-11-04 06:31

shero86
2019-11-04 09:06
has joined #general

mahadi087
2019-11-04 09:18
has joined #general

marius.maaland
2019-11-04 09:36
But the fact that it does not exists is a little concerning, since it was just published... Maybe there's a connection between this and the `tag` error above

marius.maaland
2019-11-04 09:37
The tag was `PR-8`

bethskurrie
2019-11-04 09:57
The error text at the end says the pact failed to publish.

bethskurrie
2019-11-04 09:58
What happens when you strip the new line out of the consumer version number @marius.maaland?

marius.maaland
2019-11-04 10:01
oh there is a newline? I didn't realize that. Let me check

marius.maaland
2019-11-04 10:02
True, but this error appeared when I deleted the pact, and republished with no tags, which works.

marius.maaland
2019-11-04 10:07
yup that seemed to do the trick!

marius.maaland
2019-11-04 10:17
Does not seem to be the case anymore then tags are working, so maybe it was that after all

lukembarton
2019-11-04 15:35
has joined #general

rbhati
2019-11-04 16:25
Hey @matt.fellows any pointer for : `Error setting up pact: The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.`

alan.nichols
2019-11-04 16:45
has joined #general

rbhati
2019-11-04 18:01
background: After, I got success to make pact example work and not throw exception I move to next step and follow exact same steps in my actual project, and i'm getting this exception, i looked into `pact-mock-service control-start` but unable to find details around how to use https

fbromley
2019-11-04 18:12
has joined #general

rbhati
2019-11-04 19:36
i create a certificate and now i'm getting: ``` pact-mock-service control-start -o --ssl --sslcert=_wildcard.joor.local.pem --sslkey=_wildcard.joor.local-key.pem --host=pact.joor.local --port=5123 /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.1.1/lib/pact/mock_service/server/spawn.rb:21:in `call': ERROR: Port 5123 already in use. (Pact::MockService::Server::Spawn::PortUnavailableError) from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.1.1/lib/pact/mock_service/cli.rb:185:in `start_server' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.1.1/lib/pact/mock_service/cli.rb:123:in `control_start' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /usr/local/Cellar/pact-ruby-standalone/1.69.0/lib/app/pact-mock-service.rb:15:in `<main>' ```

rbhati
2019-11-04 19:37
no matter what port i mentioned I get same error

rbhati
2019-11-04 19:37
i even tried without specifying a port # but still same error

bethskurrie
2019-11-04 19:43
Cool. I've raised an issue in the pact broker client code to handle new lines better.

rbhati
2019-11-04 19:56
a working example of starting server specifying : `certificate , port and host name` will be helpful

rbhati
2019-11-04 20:06
@bethskurrie, @matt.fellows any pointers on above ^^


rbhati
2019-11-04 21:09
Never mind i find the solution, in pace of equal use space :exploding_head: , pact is painful for sure :ghost:

bethskurrie
2019-11-04 21:20
Typically, in a CLI spaces are used for separating the argument from the value. Unfortunately the output of the CLI help command puts equals in. I'm not sure why.

bethskurrie
2019-11-04 21:20
You don't need to use the control server. Just start the service with the service or start command.

bethskurrie
2019-11-04 21:21
The control server is for a flow that isn't used by any libraries at the moment.


bethskurrie
2019-11-04 21:24
Generally, it's much easier to make the ssl configurable, and run the specs without it if you can.

bethskurrie
2019-11-04 21:25
It's not a meaningful part of the contract.

bethskurrie
2019-11-04 21:28
Your question is not very clear @mangesh.sam18. It seems that you are asking for help understanding how pact works. Have you read everything in https://docs.pact.io/getting_started/how_pact_works

bethskurrie
2019-11-04 21:28
If that isn't clear, I'm not sure how better to explain it.

mangesh.sam18
2019-11-05 07:11
@bethskurrie Thanks for your reply. I Will understand the concepts of pact first.

neelofer.tamboli
2019-11-05 08:25
Is there anyway we can check for test coverage from Contract tests? Test coverage in both ways: 1. Lines or % code covered by contract test 2. Number or % of APIs covered by contract test

matt.fellows
2019-11-05 08:27
How do you measure test coverage now? Just use that, Pact just works within whatever test framework you use

matt.fellows
2019-11-05 08:28
As for API test coverage, we can't really know this in advance easily. Short answer is no, but we'd like to help more in this space

neelofer.tamboli
2019-11-05 08:38
Thank you.

matt.fellows
2019-11-05 08:50
Ideas welcome :thinking_face:

bethskurrie
2019-11-05 08:51
What would you compare it to?

lukembarton
2019-11-05 09:32
Is returning a mock from a provider the right way to satisfy a provider test? I'm working on a project where there is a disconnect between the API output and the mock that the provider returns during the pact test. A provider test was failing, but the API was working fine, the issue being that the mock response returned when the provider was under test was out of date and needed updating. Is this a common workflow?

bethskurrie
2019-11-05 09:33
You need a downstream contract, and tie that contract with the mock for the upstream contract.

bethskurrie
2019-11-05 09:34
There's some notes on it somewhere that Matt found recently.


bethskurrie
2019-11-05 09:34
Read the gist it mentions

lukembarton
2019-11-05 09:37
the direction of up and down streams in software talk always make me laugh - you never know which variant you're dealing with

bethskurrie
2019-11-05 09:45
Ha, true!

neelofer.tamboli
2019-11-05 10:01
I was thinking maybe swagger spec if available.

lukembarton
2019-11-05 10:03
ok so we are indeed mocking `CService`. My problem is that the mock doesn't actually look like the kind of thing that `CService` returns. It's 'enforced' through the type system -- the mock is of type `CServiceResponse` but the problem is that `CServiceResponse` type can't adequetly constrain the shape of the response that `CService` returns (which eventually ends up as a `ProviderResponse` and is expected to satisfy the contract with the consumer)

lukembarton
2019-11-05 10:14
(for those curious about the details as to why, it's due to go's `nil` types - an array/slice of strings `[]string` will initialise to `nil` which `json.marshal`s to `null` so you might create a mock of type `CServiceResponse` with `[]string`'s initialised as `nil` which then end up being `json.marshal`ed to `null` -- and the only way to force them into a real empty array/slice of strings`[]string{}` (which will marshal to `[]` as required by the consumer contract) is to pass the object through a function which creates _real_ empty slices, but unfortantely appears to be completely unenforcable through the type system and thus why the mock satisfies the type checker but fails to satisfy the contract that the consumer expects)

matt.fellows
2019-11-05 10:48
What would you want to know by doing that? (FYI we are working/researching a separate swagger process if you're interested in chatting further)

neelofer.tamboli
2019-11-05 10:56
Yes I'd like to discuss further. To ensure teams are following test pyramid and teams themselves know they are testing everything and nothing important is missed or delete unused code.

samuel.hodgkinson
2019-11-05 16:11
Does anyone know which DSLs for pact support V3 spec?

luchillo17
2019-11-05 16:13
Has anyone tried to use Pact with sockets? like for example with http://Socket.io?


greg.pappas
2019-11-05 17:40
has joined #general

crajcan
2019-11-05 19:55
has joined #general

bernardoguerr
2019-11-05 20:20
has joined #general

crajcan
2019-11-05 21:30
Does anyone know of any documentation on how to use the Pact Mock Service Docker container with the "@pact-foundation/pact" consumer library for js? Namely, do I need to replace the call to `provider.setup()` if I already have the dockerized mock service running? `provider.addInteraction()` won't work without it but `provider.setup()` is redundant in this case, right?

matt.fellows
2019-11-05 21:59
It?s complicated but something like that might work. Pact JS is not really designed that way, so you?ll probably need to bend it to make it work. May I ask why you would want to do that?

stevi.deter
2019-11-05 22:04
I would also like to know how to make this work, or how it's recommended to actually work. Trying to get this into our CI/CD pipeline and haven't yet had any luck actually getting our jest consumer tests to work outside the dev laptop.

crajcan
2019-11-05 22:05
Well, locally I was just running the mock server on localhost, and had no problems, but I'm trying to setup the consumer CI tests (on circleci) and was having trouble opening another port on the container my consumer tests were running in. After some googling (new to docker too) it seemed like spinning up another container for the mock server would work nicely, but perhaps I should go back to trying to run both processes on the one container?

matt.fellows
2019-11-05 22:07
Pact has the option to dynamically choose an available port and return that to you in a Promise from `setup()`. You can then configure your client with the correct host/ip combination there. This is the recommended approach (see the e2e example in the readme for how to do this)

matt.fellows
2019-11-05 22:08
So yes, I would do this. If you start the service up externally, you then need to manage versions of the service yourself, the state of the server and so on

matt.fellows
2019-11-05 22:08
ideally, the mock server is hidden from you completely and is implementation detail

crajcan
2019-11-05 22:08
interesting. I'll give it a shot


matt.fellows
2019-11-05 22:22
@stevi.deter it?s not recommended for Pact JS at all. It?s really there for the case you need to run the mock service and don?t have a language DSL to do it. Basically a DIY Pact

matt.fellows
2019-11-05 22:22
You would need to manage the lifecycle of it all

matt.fellows
2019-11-05 22:23
Could you explain why you might want this also?

crajcan
2019-11-05 22:46
@matt.fellows That seems to have worked rather nicely! Thanks for the help.

crajcan
2019-11-05 22:51
Also, I can't speak for Stevi of course, but my original intention was to spin up and tear down a dockerized mock service in every ci run, not to maintain a long-running external instance. After researching how to assign another port on the first container, it seemed a lot of docker users were suggesting just to spin up a second container rather than run two processes in the first. I guess I then assumed that was what the mock service docker image was for. Thanks again for the assistance.

stevi.deter
2019-11-05 22:56
Trying to implement step 4.B of Pact Nirvana, run my Pact tests and publish them to the Pact Broker as part of the build pipeline. Our pipeline is transitioning to Jenkins, so focused on that. It's currently all dockerized - tests are run as part of the Dockerfile build, then trying to actually run the pact tests.

stevi.deter
2019-11-05 22:58
Don't know how much it's complicated by the fact that our testbed service is trying to run its pact tests against three separate providers.

matt.fellows
2019-11-06 00:30
What language are you using? I still don?t see a need to have a separate docker container for this, the language (JS/JVM whatever) should take care of this for you.

matt.fellows
2019-11-06 00:30
I?d suggest keeping it simple for now

sivasateesh9
2019-11-06 04:11
has joined #general

siaynoqmage
2019-11-06 04:45
Hey Pact-ers :slightly_smiling_face: It?s been a while? I resurrected my initiatives around using contract testing and based on one of our APIs I have a few questions :slightly_smiling_face:

siaynoqmage
2019-11-06 04:47
sooo, one of the response fields of a REST API is the ?current date? - how do I write the consumer pact for this? ``` .willRespondWith() .status(200) .headers(headers) .body("{\"date\": ????, \"otherField\": \"XYZ\"}") ```

siaynoqmage
2019-11-06 04:48
(this is mainly because the data contruct is shared and we CAN query data by date or just for ?today?)

siaynoqmage
2019-11-06 04:48
seems to be, ?response? is always static in a pact definition - is that a correct assumption?

tjones
2019-11-06 04:51
No, response is not always static. In general, you want to avoid static responses as much as possible

siaynoqmage
2019-11-06 04:51
so how do I define a Pact in this case?

tjones
2019-11-06 04:51
You'll want to use matchers for whatever framework you are using

tjones
2019-11-06 04:51
The matchers will let you specify what kind of responses you accept

siaynoqmage
2019-11-06 04:52
oh, I thought matchers are for _requests_

tjones
2019-11-06 04:52
is that Pact-JVM? I think there's a date matcher

siaynoqmage
2019-11-06 04:52
coming from ?wiremock? :smile:

tjones
2019-11-06 04:52
Matchers are best used in the response

siaynoqmage
2019-11-06 04:53
OK, where do I find documentation for the available matchers? (I used JVM, but I think Javascript will be used eventually)

tjones
2019-11-06 04:53
The example request you give Pact will be what is sent to your provider during verification

tjones
2019-11-06 04:54
https://docs.pact.io/getting_started/matching <-- this explains the purpose of the matchers

tjones
2019-11-06 04:54
hold on, I'll see if I can get you the JVM / js matcher links

siaynoqmage
2019-11-06 04:55
cool


siaynoqmage
2019-11-06 04:57
ah, I think I found this (or similar) for JVM

siaynoqmage
2019-11-06 04:58
but it seems my scenario here isn?t valid? like I _should_ expect a `date()` to be sent back - but I _should not_ enforce current date in the verification part?

tjones
2019-11-06 04:59
Ideally the pact describes the shape of the data, not the specific content

siaynoqmage
2019-11-06 04:59
hmmm? contractually it doesn?t matter what the date is, right?

tjones
2019-11-06 04:59
Correct

tjones
2019-11-06 04:59
it being todays date is provider functionality, which isn't part of the contract

siaynoqmage
2019-11-06 05:00
so that has to be covered elsewhere (other test phase)?

tjones
2019-11-06 05:00
So your Pact would say "hey, this bit is a date expressed in this format"

siaynoqmage
2019-11-06 05:00
maybe provider internal unit test?

tjones
2019-11-06 05:00
yep, I would do it in a unit test in the provider

siaynoqmage
2019-11-06 05:00
hmmm, that?s actually cool, how contract testing enforces better software design principles :smile: :smile:

tjones
2019-11-06 05:01
if for some reason you really want to cover it with Pact, you could have a provider state that says "Todays date is 1/12/2019", then define specific data in the contract

tjones
2019-11-06 05:01
but that's the kind of test the documentation encourages you not to write - because, as you already said, that kind of test isn't the responsibility of the contract

siaynoqmage
2019-11-06 05:02
I see


siaynoqmage
2019-11-06 05:02
thanks for the quick response :slightly_smiling_face:

tjones
2019-11-06 05:03
You're welcome

tjones
2019-11-06 05:03
there's a documentation page about the kind of data to bake in to the contract, as well

tjones
2019-11-06 05:04
I'm just trying to find it

tjones
2019-11-06 05:05
aha - it's the "Best Practice" section in the matching page I sent earlier:



tjones
2019-11-06 05:06
We're working on improving the documentation, so if there's anything unclear after reading those (or if you already read those links but they didn't help), it's very useful to know

siaynoqmage
2019-11-06 05:11
awesome, thanks a bunch!

greg.pappas489
2019-11-06 06:50
has joined #general

samuel.hodgkinson
2019-11-06 10:34
Nice, thanks anto

vivek.prahlad
2019-11-07 04:22
has joined #general

antonello
2019-11-07 09:17
Are all the dius people on holiday? :slightly_smiling_face:

matt.fellows
2019-11-07 09:18
Should we be? :laughing:

antonello
2019-11-07 09:20
haha. :grin: I have noticed less activity than usual in the last couple of days, but more selfishly @greg.pappas has found and fixed a pact-jvm issue (well, there is a PR) and we were hoping in a release soon.

bethskurrie
2019-11-07 09:22
Cup day.

antonello
2019-11-07 09:22
Right! :slightly_smiling_face:

bethskurrie
2019-11-07 09:22
Long weekend. "The horse race that stops the nation".

antonello
2019-11-07 09:22
So my intuition was right!

bethskurrie
2019-11-07 09:23
It's on the first Tuesday of November, and many people take the Monday off and make it a 4 day weekend.

bethskurrie
2019-11-07 09:23
Yes.

antonello
2019-11-07 09:27
On a different note, there has been an interesting move (one that the client I am working with wanted to get to but didn?t get time to work on it sooner) in the provider verification approach for some of their consumers. Inspired by what http://gov.uk are (or were?) doing, we?re now creating and publishing a jar that contains the provider verification tests and the code necessary to run them, so that the consumer?s pipeline can get immediate feedback on the provider verification.

bethskurrie
2019-11-07 09:28
Well that's clever!

antonello
2019-11-07 09:28
The verification runs for both the head of `master` branch and the version matching what?s in production (plus for a matching feature branch if it exists).

matt.fellows
2019-11-07 09:29
I think right move did something like that

matt.fellows
2019-11-07 09:29
(just doing the bed routine, back a little later but couldn't help myself)

antonello
2019-11-07 09:29
the tag verified is obviously only the one that matches the consumer?s pipeline that is running.

antonello
2019-11-07 09:30
I was there with them when they started using pact and I do remember that it was always the intention!

antonello
2019-11-07 09:30
They created a diagram that explains it much better. I?ll ask if it?s ok to share it.

bethskurrie
2019-11-07 09:30
We should add that as a suggested workflow in the docs.

matt.fellows
2019-11-07 09:42
Ahh ok. Maybe it was just the stubs they shared

matt.fellows
2019-11-07 09:43
I'd need to go back and look at Harry's talk

matt.fellows
2019-11-07 09:46
In case having a public holiday for a horse race wasn't enough, we also get one off for AFL grand final (both Victorian public holidays) :laughing:

matt.fellows
2019-11-07 09:50
But I've also been rather quiet on here. Had baby #2 a few weeks back so have just had a little less time / head space

bethskurrie
2019-11-07 09:51
Sleep

matt.fellows
2019-11-07 09:52
I'm actually about 20 mins away from dead batteries I think. I really shouldn't be so stubborn and still head to gym before work :grimacing:

bethskurrie
2019-11-07 09:53
I can't tell if you mean literal dead batteries or metaphorical ones.

bethskurrie
2019-11-07 09:53
Or, if we're speaking American, literal or literal...

matt.fellows
2019-11-07 09:54
Metaphorical

antonello
2019-11-07 09:54
Congratulations on :baby: #2 Matt!

kv
2019-11-07 11:02
has joined #general

ml
2019-11-07 14:23
has joined #general

luchillo17
2019-11-07 16:03
Is there a way to use Pact with http://Socket.io?

siaynoqmage
2019-11-07 22:33
is that a websocket based framework?

iammrrhodes
2019-11-07 22:36
has joined #general

iammrrhodes
2019-11-07 23:58
Ive a question... when i run my provider tests... and they pass.... my tagging doesn't seem to be saving to the broker.... im not sure what im not doing ...

tjones
2019-11-08 00:23
Yes. You can use a message pact to handle websockets. I've personally not done it, but you might find some inspiration in: https://github.com/pact-foundation/pact-js/tree/master/examples/messages

tjones
2019-11-08 00:24
Which platform? You might need to configure the publication of the verification results

iammrrhodes
2019-11-08 00:35
I'm using JavaScript, with gitlab-ci,

ayip
2019-11-08 02:01
has joined #general

vitaliy.grigoruk
2019-11-08 07:33
provider app versions are not tagged when you publish verification results, @iammrrhodes You need to explicitly create a provider version tag

vitaliy.grigoruk
2019-11-08 07:34
However, it would be nice to have such a feature

cbergstrom
2019-11-08 07:37
has joined #general

ml
2019-11-08 08:03
coincidently at the same problem. Can you point me to the documentation on how to `explicitily create provider version tag`?

vitaliy.grigoruk
2019-11-08 08:07
``` curl -XPUT -H "Content-Type: application/json" \ -u $PACT_BROKER_USERNAME:$PACT_BROKER_PASSWORD \ ${BROKER_URL}/pacticipants/${PARTICIPANT}/versions/${VERSION}/tags/${TAG} ```

vitaliy.grigoruk
2019-11-08 08:08
you can figure it out in HAL API browser.

bethskurrie
2019-11-08 08:59
@iammrrhodes provider tagging should be supported now. Are you using the latest version of pact-js?

bethskurrie
2019-11-08 09:00
@ml which implementation are you using? We need to add this if it's not in there.

bethskurrie
2019-11-08 09:02
Ok, I take it back - I can't see it in the pact-js documentation. Let me raise an issue for it. I'm sorry, I thought it was already there.


iammrrhodes
2019-11-08 09:33
Ok, thank you. I assume for now I need to be using other means.

bethskurrie
2019-11-08 09:33
Yeah, sorry about that.

bethskurrie
2019-11-08 09:33
The way Vitalii described will work.

iammrrhodes
2019-11-08 09:39
I?m assuming the CLI will work too?

bethskurrie
2019-11-08 09:39
Yes.


felipe
2019-11-08 16:46
has joined #general

felipe
2019-11-08 16:47
Hello! Anybody working with pacts and elixir?

rbhati
2019-11-08 20:22
Excellent news i knock this huddle out as well, and I decided to contribute to respective pact readme's based on my learning. Hope that's ok

rbhati
2019-11-08 20:23
@bethskurrie, @matt.fellows next i'm setting up pact broker and I'm using the docker-compose as described in https://github.com/pact-foundation/pact_broker

rbhati
2019-11-08 20:24
wonder if there are any example's that I can refer to know how to stitch the consumer test to push result to pact brocker in swift

jks
2019-11-08 20:59
has joined #general

matt.fellows
2019-11-08 22:20
I would use the CLI tools from https://github.com/pact-foundation/pact-ruby-standalone/ to publish to the broker, or simply use API calls as described at https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts

mpglover
2019-11-09 02:32
I've used the standalone pact broker with it a bit. Also been tentatively messing with building a native elixir library for it but haven't had a lot of time for that recently.

sliu7
2019-11-11 05:53
Hi! I'm trying to implement pact in .NET .. not sure if I've overlooked some basic info, but how can I configure the provider to verify all the contracts associated with it? I'm able to successfully verify it when I specifically mention the consumer name but couldn't figure out how to run it for all contracts. Thanks in advance!

abubics
2019-11-11 06:09
Hi :slightly_smiling_face: Try in #pact-net

bethskurrie
2019-11-11 09:23
@sliu7 it seems that this might not be available in pact-net yet.


felipe
2019-11-11 10:39
I ended up putting the pact verifier cli in a docker image and verifying from there

felipe
2019-11-11 10:39
Against a spinned up instance

jgfarias42
2019-11-11 13:23
has joined #general

acooper106
2019-11-11 13:39
Are there any examples of this?

ismael_rosas_sandoval
2019-11-11 14:43
has joined #general

rrosa171
2019-11-11 16:03
has joined #general

rrosa171
2019-11-11 16:14
Hello, I am having the most confusing Pact issue. I've two tests, locally they pass when run together, fail on their own. On the CI (GitLab) the first one always fails where the second one passes. After debugging them, it seems there is a "SocketTimeout" exception thrown when http client tries to make a GET request.

rrosa171
2019-11-11 16:15
I have run out of ideas, trying to solve it for the last two weeks. The tests were working perfectly fine until I edited some of the code in completely different part of the project.

felipe
2019-11-11 17:39
Sounds like wrong test data setup

rrosa171
2019-11-11 18:05
@felipe What can I do to check my setup?

rrosa171
2019-11-11 18:05
I can't really share the code, it's closed source

felipe
2019-11-11 18:05
It?s an app related thing. You have to check which data is missing

felipe
2019-11-11 18:05
And how your setup differs

felipe
2019-11-11 18:05
That?s what it sounds like

rrosa171
2019-11-11 18:06
I am not sure how to check it, to be perfectly honest,

rbhati
2019-11-11 18:20
Hi @matt.fellows, @bethskurrie Thanks for helping so far i think the last and final mystery pac<t> is webhook in pact Brocker. following are my success steps: 1. Setup pact broker: a. clone `git@github.com:DiUS/pact_broker-docker.git` to local b. run `docker-compose -f docker-compose.yml up` 2. Wrote a consumer side contract test in ios repo 3. Once test execute it post pact json to pact broker using CLI tool 4. Add webhook as : ``` { "consumer": { "name": "Brand App" }, "provider": { "name": "Hyperion" }, "request": { "method": "POST", "url": "https://<user>:<password>@jenkins.server.com/job/contract.test.pact/buildWithParameters", "headers": { "Accept": "application/json" } }, "events": [ { "name": "contract_content_changed" } ] } ``` Problem statement: I made change in consumer side and push new version of pact.json to pactbroker nothing happened Moreover I see no option to execute webhook to check if its really going to work as when a new version of pact push to broker

rbhati
2019-11-11 18:23
And when I click `No run' i get below page and I have no clue what to do next The goal is pretty simple use pact-broker to trigger job if there is change in pact json. Otherwise I have to replace pact broker with git git repository to achieve same goal

rbhati
2019-11-11 18:23
Please help @bethskurrie @matt.fellows ^^

rbhati
2019-11-11 19:51
After I click `http://localhost/webhooks/jwfoN13ZXNR6yaMJoQne6Q/execute` I get below error: ``` { "request": { "headers": { "accept-encoding": "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "accept": "application/json", "user-agent": "Ruby" }, "url": "https://rbhati:11a228678b4ef47c016701a0edc455bce3@jenkins.server.com/job/contract.test.pact/buildWithParameters" }, "message": "For security purposes, the response details are not logged. To enable response logging, configure the webhook_host_whitelist property. See /doc/webhooks#whitelist for more information.", "logs": "[2019-11-11T19:47:43Z] INFO: HTTP/1.1 POST https://user:token@jenkins.server.com/job/contract.test.pact/buildWithParameters\n[2019-11-11T19:47:43Z] INFO: accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\n[2019-11-11T19:47:43Z] INFO: accept: application/json\n[2019-11-11T19:47:43Z] INFO: user-agent: Ruby\n[2019-11-11T19:47:43Z] INFO: null\n[2019-11-11T19:47:43Z] ERROR: Error executing webhook jwfoN13ZXNR6yaMJoQne6Q. For security purposes, the response details are not logged. To enable response logging, configure the webhook_host_whitelist property. See /doc/webhooks#whitelist for more information.\n[2019-11-11T19:47:43Z] INFO: Webhook execution failed\n", "success": false } ```

rbhati
2019-11-11 19:57
i can trigger the same job with same command via postman


rbhati
2019-11-11 20:15
I tried it and I still missing direction

psychopomp3x
2019-11-11 20:27
has joined #general

rbhati
2019-11-11 20:30
i have no idea how to set the `webhook_host_whitelist`, am I supposed to overwrite `pact_brocker-docker/pact_broker/config.ru`

rbhati
2019-11-11 20:30
total lost in setting up webhook again

uglyog
2019-11-11 21:13
The issue above has a comment at the bottom for a fix for their http client. You?ll need to work out which client is being used.

matt.fellows
2019-11-11 21:26
Is there a valid certificate installed on your broker? You don't need to whitelist https URLs

matt.fellows
2019-11-11 21:28
Also, we are based in Australia and so we're all asleep a few hours ago - there is no need to constantly @ us

matt.fellows
2019-11-11 21:29
If the certificate is self signed then you'll need to ensure the certificate authority is properly configured otherwise your broker won't be able to initiate the outbound call

matt.fellows
2019-11-11 21:30
Also check the broker logs on case of anything helpful there

bethskurrie
2019-11-11 21:30
@rbhati The Pact Broker Docker README contains documentation on configuring the webhook whitelist https://github.com/pact-foundation/pact-broker-docker#webhook-whitelists

bethskurrie
2019-11-11 21:30
Please ask your questions in the relevant channel eg. #pact-broker

matt.fellows
2019-11-11 21:32
Which language are you using? Can you ask it in that channel so you get targeted help? Also, consumer or provider test?

bethskurrie
2019-11-11 21:33
There are other people who can help you who may be awake if you ask in the right place.

matt.fellows
2019-11-11 21:33
Either way, my suggestion is to create the simplest version that you can to reproduce the problem, and then sharing with the community here.

rbhati
2019-11-11 21:48
hey Beth are you saying I need to pass environment variable PACT_BROKER_WEBHOOK_SCHEME_WHITELIST as part of docker compose, because that actually where I'm lost how to set this

matt.fellows
2019-11-11 22:33
You?ll need to use an environment variable in your docker-compose setup to do that


sliu7
2019-11-11 22:36
Thanks! :slightly_smiling_face:

bethskurrie
2019-11-11 22:40
Look in the example docker-compose file. You'll see some existing environment variables. Put in the same place.

bethskurrie
2019-11-11 23:03
added an integration to this channel: https://pact-foundation.slack.com/services/BQE9MSRH6

2019-11-11 23:04
Yay! Unlimited knowledge is now at your finger tips! Use the `/gitbook [search query]` command to search through https://docs.pact.io/.

bethskurrie
2019-11-11 23:05
I've turned on the gitbook search plugin ^^. Probably best to try it out under your own user in Direct Messages.

felipe
2019-11-12 04:38
Its not about pact it?s about the software you are testing. You have to know it and check the logs

felipe
2019-11-12 10:05
Hi all! I?m using pact as Json and I wanted to know if it?s possible to transfer properties between interactions in one pact. Does anybody have any idea or experience with that?

bethskurrie
2019-11-12 10:12
Thanks Matt!

ingo.griebsch
2019-11-12 12:02
has joined #general

ingo.griebsch
2019-11-12 12:14
Hi all, we are just investigating PACT and want to use it for our CDC. The first thing we want to understand is if there is a complete documentation about the structure of a pact/interaction and what is necessary/possible to describe. We found https://github.com/pact-foundation/pact-specification and the description of the different versions but at a first glance it looks more like an overview instead of a detailed documentation of every aspect. We also had a look at the JSON schemas but it seems that only v1 and v2 are implemented at the moment. Therefore it would be really nice if someone could give us some hints and/or points us to the places we are currently searching for. :slightly_smiling_face:

roman.g.rodriguez
2019-11-12 12:37
has joined #general

fabio.iglesias
2019-11-12 13:44
has joined #general

bart.schotten
2019-11-12 14:27
No, I don't think that's possible. Interactions are meant to be completely independent.

bart.schotten
2019-11-12 14:30
The JSON schema for V3 is indeed missing, but another way to learn about the details of the specification is to look at the testcases: https://github.com/pact-foundation/pact-specification/tree/version-3/testcases

bart.schotten
2019-11-12 14:31
The question is if you really *need* to know that level of detail though, unless you are creating your own Pact library.

ingo.griebsch
2019-11-12 14:32
Maybe not, we probably first need to understand more how to work with PACT.

ingo.griebsch
2019-11-12 14:33
We are currently doing a API first approach which means that we are sitting together to define the necessary API together. This currently results in several groovy files for Spring Cloud Contract.

ingo.griebsch
2019-11-12 14:33
Now we want to switch to PACT but to keep the process.

ingo.griebsch
2019-11-12 14:33
Therefore we thought if we could write down the PACTs while talking about the API.

ingo.griebsch
2019-11-12 14:35
And that resulted in the question what we need to provide and what are the things we could provide. Spring Cloud Contract is explaining it's DSL in detail therefore you don't need a tool/test/whatever to create a contract. You only need a text-editor.

ingo.griebsch
2019-11-12 14:36
Another nice thing would be to have an editor/tool which allows to 'click together' the PACTs. Like http://editor.swagger.io/ for example. But we did not found any editor until now.

ingo.griebsch
2019-11-12 14:55
@bart.schotten Could I explain myself?

bart.schotten
2019-11-12 14:58
Yeah I think such an editor would not be a bad idea at all. Only problem is that Pact does not really have one DSL. Each library may have a different DSL to generate the contract, as long as the resulting artifact conforms to the spec.

ingo.griebsch
2019-11-12 15:02
But if I would use one of the libraries and put a UI on top I should be fine if I now what the library needs to generate the pacts.

bart.schotten
2019-11-12 15:03
Sure that would be theoretically possible

ingo.griebsch
2019-11-12 15:03
I hope not only theoretically :slightly_smiling_face:

ingo.griebsch
2019-11-12 15:03
But such thing is not available right now, correct?

ingo.griebsch
2019-11-12 15:04
So we still need to find a way how to define the interactions while discussing the cases... :thinking_face:

bart.schotten
2019-11-12 15:06
No as far as I know it's not available now.

fabio.iglesias
2019-11-12 15:55
Hello :slightly_smiling_face: I am learning with @ingo.griebsch about PACT and I was wondering about Pacts structure. Maybe somebody can clarify. Given that a Pact contains several interactions is a Pact sufficient to cover a whole API of a service? Is there any way of organising deeper whithin a Pact its interactions (for example under each endpoint criteria)? Or would it be convenient to use more than one Pact for a given pair of consumer/provider? Thank you in advance!

abubics
2019-11-12 22:58
@ingo.griebsch The workflow for Pact is consumer-driven, and the pact file is a side-effect or output of exercising the API client through running tests. This is why there's no editor for the pact file; it's only an artifact :slightly_smiling_face:

abubics
2019-11-12 23:00
The design is that one pact file should cover all functionality of a consumer-provider pair. As a consumer-driven contract, it should only cover the needs of a consumer, so it may not be exhaustive on API functionality.

dschwartz
2019-11-12 23:46
has joined #general

fabio.iglesias
2019-11-13 09:03
Thank you, this helps me getting a brighter picture of the concept

fabio.iglesias
2019-11-13 09:12
Then I understand that PACT is not suitable for any provider-driven approach, or would it also work from that perspective?

rlabok
2019-11-13 21:37
has joined #general

abubics
2019-11-13 23:33
the base philosophy is to avoid building things that no one is using, but

abubics
2019-11-13 23:34
you can still build the provider first . . . you just have to drive the functionality through a sample consumer, which has dubious value :slightly_smiling_face:

abubics
2019-11-13 23:34
I've done it that way plenty of times, and it does help, but it's still not as good as an irl consumer

neelofer.tamboli
2019-11-14 06:01
Hi. I was wondering if there was any progress or update on this? This is something we are quite interested in.

bethskurrie
2019-11-14 06:03
@neelofer.tamboli which part? We don't have a time frame for the OAS contract testing flow yet, as we're still gauging interest. There's a post on it here: https://blog.pactflow.io/the-curious-case-for-the-provider-driven-contract/

bethskurrie
2019-11-14 06:04
If you're interested, it would be great if you could fill out this survey here: https://dius.typeform.com/to/Dd66SC

bethskurrie
2019-11-14 06:04
There are no plans for any coverage tools at this stage.

neelofer.tamboli
2019-11-14 06:07
Ok, thank you for the update. Will look into it.

m.kwiecien
2019-11-14 09:58
has joined #general

m.kwiecien
2019-11-14 10:48
Hi All. I have problem with *nullValue* in *PactDslJsonBody* (). I get Request mismatch: [BodyMismatch(expected=null, actual=null, *mismatch=Expected null (JsonNull) to be the same type as null (JsonNull)* when I run test so the pact is not created. From logs I see that expected request looks exactly the same as received. I I use *pact-jvm-consumer-junit5* version 4.0.0 and RestTemplate from *spring* org.springframework:spring-web:5.2.0 Anyone had such problem or know how to resolve it?

iamjoemooney
2019-11-14 11:00
has joined #general

bustamcnasty
2019-11-14 15:41
has joined #general

stevi.deter
2019-11-14 15:59
Just to follow up, the e2e example helped me figure out what I was missing and now I can run my consumer verifications and publish results as part of the docker build just like I was hoping! Thanks!

uglyog
2019-11-14 20:50
Please raise an issue for that at the Github project

kiranpatel11
2019-11-14 23:08
How to generate Pact file without writing a test case? I am dealing with multiple monolith consumer systems which are not capable to write pact tests using pact libraries(e.g. SFDC, BPEL engines). We are considering writing the pact separately using one of the supported language(pact-jvm or pact-js) and use it to 1. spin up mock server for consumers. 2. verify provider implementation. Is anyone using PACT in this way successfully? How is the challenge of keeping tests and code in synch addressed ?

rbhati
2019-11-14 23:26
Guys I'm super excited to let you know that I got pact setup, 1. Consumer side write test in swift 2. Push json to Pact Broker 3. Webhook in pact Broker sense change trigger Jenkins Job <-- Broker authentication in Progress 4. Jenkins run provider test [pact verifier] over kubernetes push result back to Broker 5. Broker push notification to CI pipeline - stop/proceed with build . <-- Pending Wonder if you have any enhancement in this setup, what if provider make changes??

bethskurrie
2019-11-14 23:28
Awesome Ray. The pact verification should also be part of the provider's default build. If the provider changes, then the pacts get run as part of the provider's own build.


matt.fellows
2019-11-14 23:52
So http://docs.pact.io has a section on generating Pacts not from test cases. TL;DR you should avoid it-

matt.fellows
2019-11-14 23:53
One option might be to have a tool that can ?capture and replay? what your engines do, and convert those into pact files

matt.fellows
2019-11-14 23:53
but I would think hard before doing this, because it will be hard to use some of the more useful features like matchers and so on, which make the tests way less brittle

kiranpatel11
2019-11-15 00:27
Thanks Matt, I am considering to use PACT DSL to write PACT interactions, but I consider that is not tests, Tests are where we assert the consumer's code output using the mocks defined in pact. Think of it as 2 seperate repo - consumer tests, pact interactions. Thinking of integrating them and keeping in synch using some CI pipeline magic.

kiranpatel11
2019-11-15 00:28
It would be interested to see if anyone else has attempted such scenario and been successful with it

felipe
2019-11-15 05:35
We started with it a month ago like this: - central repo for all pacts where all devs write them in json by hand - provider ci pipeline spins up the application with test data and verifies the pacts with the Ruby cli

matt.fellows
2019-11-15 05:38
> - central repo for all pacts where all devs write them in json by hand Can you explain why you do this? This is almost certainly a bad idea

rbhati
2019-11-15 22:53
hi @bethskurrie I found this http://blog.pact.io/p/d7c9601f-e2ca-4208-b1c0-f02eaf96c3c2/ and wonder if there are any examples you can point to displaying the difference and how to use pending state

kiranpatel11
2019-11-17 23:57
@matt.fellows @bethskurrie Do you guys think it makes sense to generate pact file from something like Karate Tests https://github.com/intuit/karate ?

bethskurrie
2019-11-17 23:57
Yes

bethskurrie
2019-11-18 00:06
As long as they're tests for real consumer code.

bethskurrie
2019-11-18 02:16
Pact Broker users, I'm about to release pagination for the index page (finally!). If you have enough pacts on your index page that you'd appreciate pagination, can you tell me how many pacts you have total, and what default page size you think would be useful.

kiranpatel11
2019-11-18 03:43
I would prefer auto-scolling than pagination, with option of text search filter

kiranpatel11
2019-11-18 03:45
We do have ~250 pacts

bethskurrie
2019-11-18 04:11
It's taken me 6 years to get pagination :stuck_out_tongue:

bethskurrie
2019-11-18 04:12
You make a good point though.

bethskurrie
2019-11-18 04:13
At the moment, the UI is server side rendered, and I do not have the time or energy to re-write it to be client side rendered, hence, pagination was the simplest option.

kiranpatel11
2019-11-18 04:14
I would consider text search filter is more useful than pagination or auto-scrolling

kiranpatel11
2019-11-18 04:14
I believe its relatively easier to impl as well, don't you ?

bethskurrie
2019-11-18 04:15
yes

kiranpatel11
2019-11-18 04:15
may be a candidate for backlog item

bethskurrie
2019-11-18 04:15
I wish there was a "OSS feature prioritisation tool" where you could work out which things were the most important to the most people.

bethskurrie
2019-11-18 04:15
Linked to github issues.

kiranpatel11
2019-11-18 04:17
that's good backlog item for github :wink:

bethskurrie
2019-11-18 04:18
:laughing:

bethskurrie
2019-11-18 04:18
Can you pop the name filter feature in the issues?

bethskurrie
2019-11-18 04:18
Hopefully it won't take me another 6 years...

kiranpatel11
2019-11-18 04:19
sure

felipe
2019-11-18 05:26
@matt.fellows : I know is not the best idea but I decided it for two aspects: We have only one provider so I integrated the pacts in the integration tests. My team is very bad at writing tests and getting motivated about it. So I just gave them the pact spec and told them to write them. What is exactly a bad idea? What would you do different?

bethskurrie
2019-11-18 05:28
@rbhati it's in beta currently. If you're using pact-js you can contact Matt Fellows to be part of the user group that is testing it out.


kiranpatel11
2019-11-18 05:32
@felipe I see two issues with this 1. Writing tests are easy, but keep it maintained is hard, so if teams are not motivated enough they are not going to get a value out of PACT. 2. I would prefer team use PACT DSL instead of writing it from scratch. In the end, you will have to see if your are really detecting compatibility issues through PACT and cutting down on your need of integration tests.

matt.fellows
2019-11-18 05:33
Well said Kiran

felipe
2019-11-18 06:02
You are right. But maybe I explained too less of the context. We have 3 consumers (two frontend and one app) which have no automated tests at all and the the developers are not very experienced with it. I?m introducing automated tests slowly but they are not that good right now. They still complain about the backend team changing structures and not telling them. So in told them they should write the pacts and commit them to a central repo and the backend would take that repo and validate them. That?s the story behind it. Of course I would prefer them to have automated tests for all integrations and be able to generate and publish the pacts from there but they are just not experienced with automated tests and if I tell them to get into it and into pact, it would be the overkill...

felipe
2019-11-18 06:08
So it?s kind of a manual process but I think it will fulfill our need in the short term and later on we will generate the pacts when we have automated tests for the consumers

kiranpatel11
2019-11-18 06:34
@felipe The tests should be used to ensure 1. consumer is using the API correctly 2. provider is behaving as per consumer expectations. You can't do just one of these (by nature), you would still have high probability of integration issues, and that defeats the purpose

kiranpatel11
2019-11-18 06:37
In your case, it seems you are not doing #1, and #2 can be outdated anytime. Another point is - why write pact file from scratch without assertions on consumer side !!

felipe
2019-11-18 08:05
If the consumer devs write the pacts is because the are doing that based on the api they are using. That would cover one in a very unautomated way. And #2 can be outdated anytime yes. This is what we have with the time and experience we can invest in (!!!!)

bethskurrie
2019-11-18 08:10
Well, give it a go and let us know what value you get from it.

felipe
2019-11-18 08:12
That?s the plan. Whenever we start with automated tests we will most probably change it

marco
2019-11-18 08:59
has joined #general

iammrrhodes
2019-11-18 11:31
I've a general versioning question here... on my consumer pipeline, I am tagging the consumer with a git sha... and then on my provider, I am doing the same when verifying the, using the git sha for my provider version.... someone on my team has just ask me ... "should we be publishing the PACT files even if they have not changed on the consumer..." and I'm just reading the docs and looking at examples, and I'm slightly confused now, from what I read in the docs, it says the pact file has a version? but this is hidden?

bernardoguerr
2019-11-18 12:43
The versioning of the pact files is taken care of behind the scenes for you, and you don't need to care about it. You version your applications, and when you publish a pact for a specific application version, it will figure out if it is a new contract or not. So even if you have a CI step to publish on your consumer every time, you don't need to worry about figuring out whether something has changed or not. The Pact Broker will do that for you. Which means the "contract_changed" webhook (triggering a provider build) won't be run unless there was an actual change to the contract

antonello
2019-11-18 13:00
Could it be configurable?

squarism
2019-11-18 19:31
has joined #general

felipe
2019-11-18 20:51
Hi! I ve an elixir provider and want to validate Json pacts v3 against it. Which is the best way? The ruby cli supports only pacts v2 Thanks

rbhati
2019-11-18 21:52
@bethskurrie i need a suggestion, I had pactman_verifier [https://pypi.org/project/pactman/] to verify pact; And I wonder if I can achieve same goal of validating pact [available on pact-broker] via pact-python

bethskurrie
2019-11-18 22:07
@rbhati can you please ask in the relevant channel for the language and stop tagging me for every question? We're happy to help, but we do have limits. Firstly, I am not the maintainer of either of those libraries. Secondly, if the maintainers got tagged for every question, we'd never have time to do any work. We have a community of experienced Pact users who can answer your questions.

bethskurrie
2019-11-18 22:10
Not sure if there's a way yet.

bethskurrie
2019-11-18 22:11
You can verify them, but you won't get any unsupported matching rules.

bethskurrie
2019-11-18 22:12
We do have someone working on v3 support at the moment though.

rbhati
2019-11-18 22:14
got it, thanks for all your help :slightly_smiling_face:

matt.fellows
2019-11-18 22:28
Yep. So short answer: Always publish contract from CI, don?t worry about trying to detect if it has changed You probably want to read this if you haven?t already: https://docs.pact.io/best_practices/pact_nirvana

bethskurrie
2019-11-19 02:27
Yeah, easily. I'll probably add a drop down box for the size next to the pagination control.

bethskurrie
2019-11-19 02:58
@antonello I used your anonymize data set to ensure that the pagination code can handle the "view latest tags" index mode with a lot of data. With pages of 30 rows, your database has 643 pages :laughing:

bethskurrie
2019-11-19 03:03
@rbhati here is an example of the existing workflow compared to the new workflow with pending pacts.

kiranpatel11
2019-11-19 04:00
@bethskurrie Created https://github.com/pact-foundation/pact_broker/issues/318 Let me know if more details needed.

291636938
2019-11-19 06:13
has joined #general

291636938
2019-11-19 06:19
Hi @channel, I using version 3 of pact and is able to generate the pact json file and do the consumer test, but when I turn to run the provider test, it came out error with message "Exception: No tests found matching Method", I use the springboot 2.x , pact 3.6.0, and my demo project is located at https://github.com/wuhuanxing/pact_demo , Ive struggled it for few days, really hope some one can help me , Thank very much!

bethskurrie
2019-11-19 06:28
Thanks for putting together that demo @291636938. Try asking in the #pact-jvm channel.

291636938
2019-11-19 06:30
sorry for putting in the wrong place , thank you for mind~

felipe
2019-11-19 06:31
Hi all! im trying to verify pacts with the gradle plugin but im getting always a 400 bad request from nginx. From postman with https://myurl.com:443/service/path works perfectly. im out of ideas this is my gradle ```plugins { id "java" id "http://au.com.dius.pact" version "4.0.3" } task('getToken') { doLast { } } pact { serviceProviders { wmsBackend { protocol = 'https' host = 'http://myserviceurl.com' port = 443 path = '/' //insecure = true requestFilter = { req -> req.addHeader('Authorization', 'Bearer sometoken') } hasPactsWith('WmsFrontend') { pactFileLocation = file("$rootDir/../pacts/frontend") } hasPactsWith('Plentymarkets') { pactFileLocation = file("$rootDir/../pacts/plentymarkets") } } } reports { defaultReports() // adds the standard console output markdown // report in markdown format json // report in json format } } ```

felipe
2019-11-19 06:35
My pact makes a boring get: ```"request": { "headers": { "Authorization": "Bearer token", "Content-Type": "application/json" }, "method": "GET", "path": "/api/v1/entity/entty2/1", "body": {}```

bethskurrie
2019-11-19 06:36
Best to ask in #pact-jvm @felipe

matt.fellows
2019-11-19 07:03
Get with an empty body as an object

matt.fellows
2019-11-19 07:04
Is that intended?

felipe
2019-11-19 07:45
Will do. Thanks

felipe
2019-11-19 09:50
Hi all! im trying to use matchers but they are being ignored and my body is match to equality. Do you have any idea how to restrict that to the matchers? ```{ "consumer": { "name": "Get Warehouse" }, "provider": { "name": "wms" }, "interactions": [ { "description": "Get Warehouse", "request": { "headers": { "Authorization": "Bearer XXX", "Content-Type": "application/json" }, "method": "GET", "path": "/something/SOMEPATH/warehouses/" }, "response": { "status": 200, "body": { "total_results": 1, "warehouses": [ { "active": true, "city": "Berlin", "country": "Germany", "fax": "56270492786", "id": 1, "line1": "Test Address Line 1", "line2": "Test Address Line2", "name": "Test warehouse", "phone": "56270492786", "state": "Berlin", "tenant_id": 1, "zip_code": "7591538" } ] } }, "matchingRules": { "$.body.total_results": { "match": "type" }, "$.body.warehouses": { "min": 1, "match": "type" }, "$.body.warehouses[*].id": { "match": "type" }, "$.body.warehouses[*].city": { "match": "type" }, "$.body.warehouses[*].country": { "match": "type" }, "$.body.warehouses[*].fax": { "match": "type" }, "$.body.warehouses[*].line1": { "match": "type" }, "$.body.warehouses[*].line2": { "match": "type" }, "$.body.warehouses[*].name": { "match": "type" }, "$.body.warehouses[*].phone": { "match": "type" }, "$.body.warehouses[*].state": { "match": "type" }, "$.body.warehouses[*].tenant_id": { "match": "type" }, "$.body.warehouses[*].zip_code": { "match": "type" } } } ], "metadata": { "pactSpecification": { "version": "4.0.0" }, "pact-jvm": { "version": "4.0.3" } } }```

felipe
2019-11-19 09:50
it says: Failures: 0) Verifying a pact between Get Warehouse and wmsBackend - Get Warehouse returns a response which has a matching body Verifying a pact between Get Warehouse and wmsBackend - Get Warehouse returns a response which has a matching body=BodyComparisonResult(mismatches={$.total_results=[BodyMismatch(expected=1, actual=6, mismatch=Expected 1 but received 6, but im clearly matching it to type

bethskurrie
2019-11-19 09:51
For the verification?

bethskurrie
2019-11-19 09:51
Only JVM supports v4 on provider.

felipe
2019-11-19 09:51
im using JVM

bethskurrie
2019-11-19 09:51
Hm, should work then!

felipe
2019-11-19 09:51
id "http://au.com.dius.pact" version "4.0.3"

bethskurrie
2019-11-19 09:52
If you can create a reproducible code example, you can raise an issue in pact JVM repo.


bethskurrie
2019-11-19 09:53
Also, best to ask questions related to pact JVM in the #pact-jvm channel

felipe
2019-11-19 09:53
the matchers are there to avoid the hard coded data in the response the right? (asking for a friend)

bethskurrie
2019-11-19 09:53
We try to keep the general channel for cross cutting concerns.


bethskurrie
2019-11-19 09:54
The matchers stop the tests being brittle.

felipe
2019-11-19 09:54
cool thanks

bethskurrie
2019-11-19 09:54
We don't generally really care about specifics, just that the shape of the doc matches.

felipe
2019-11-19 09:55
can I add matchers to objects and it would macth everything in there or I have to match every single attribute?

bethskurrie
2019-11-19 10:00
You should just have to put the matcher on the parent, and all children inherit it

felipe
2019-11-19 10:01
in all versions?

bethskurrie
2019-11-19 10:01
Yes

bethskurrie
2019-11-19 10:01
Unless @uglyog has changed anything in v4

ncritah
2019-11-19 10:26
has joined #general

felipe
2019-11-19 11:45
is there any way to combine matchers in json? i want to make null or type

felipe
2019-11-19 11:45
i cannot find anything in the specification

matt.fellows
2019-11-19 11:50
that?s because it?s explicitly not allowed



bart.schotten
2019-11-19 11:56
But I agree that it should definitely not be used in that way

matt.fellows
2019-11-19 12:02
I think @bethskurrie had something to say about this. But yes

ncritah
2019-11-19 14:49
Trying to use pact with Karma and Mocha but without much success. I have updated my karma conf to match the example shown and the rest of my code is as shown below ```*====client.js====* const validate = (host) => { const { url, port } = host; return axios .request({ method: 'GET', baseURL: `${url}:${port}`, url: `/test/111`, headers: { Accept: 'application/json' }, }); }; *====test.js====* describe('Pacting away', () => { let provider; const port = 1331; before(done => { provider = new PactWeb({ consumer: 'KarmaMochaConsumer', provider: 'KarmaMochaProvider', port: port, host: 'http://localhost', }); setTimeout(done, 1000); provider.removeInteractions(); }); after(done => provider.finalize().then(() => done())); describe('', () => { before(done => { provider .addInteraction({ state: 'provider can validate entries', uponReceiving: 'a request to validate 111', withRequest: { method: 'GET', path: '/test/111', headers: { 'Content-Type': 'application/json', }, }, willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json', }, body: { message:"Success" }, }, }) .then(() => { done(); }); }); it('should return 200 for 111', done => { validate({url: 'http://localhost', port: port}).then(response => { expect(response.status).to.equal(200); done(); }, done); }); }); });``` When I run the tests, it hangs after this log > `INFO [pact]: Pact Mock Server running on port: 1331` and when I manually try to access the endpoint in my terminal using curl, I get `{"message":"No interaction found for GET /test/111","interaction_diffs":[]}`

uglyog
2019-11-19 20:50
There is no V4 version (yet). How did that pact file get created?

uglyog
2019-11-19 20:52
The matching rules are in the incorrect format. That file will be treated as a V3 pact file, but the matching rules look like they are in the V2 format.

bethskurrie
2019-11-19 21:28
@ncritah can you ask in the pact-js channel please?

bethskurrie
2019-11-19 21:29
Usually when we see issues like that it's a timing issue with promises and callbacks.

bethskurrie
2019-11-19 21:29
I'm not a js expert though.

bethskurrie
2019-11-19 21:31
That snuck in while I was on mat leave, and it has been regreted @bart.schotten!

bethskurrie
2019-11-19 21:31
@felipe is this one of your handcoded ones?

bethskurrie
2019-11-19 21:32
I think it would be easier to write a fake pact test in Java than hand code it.

ncritah
2019-11-19 21:35
I just found `pact-js` a couple of minutes back and posted there but couldn't delete this

bethskurrie
2019-11-19 21:56
Please don't do it @felipe. If you can't control the data during provider verification, then contract testing isn't the right tool for you.

bethskurrie
2019-11-19 21:56
If you don't know if the element should be there, then leave it out of the expectations.

bethskurrie
2019-11-19 21:57
Thanks for the good answer @bernardoguerr!

bethskurrie
2019-11-19 21:58
@iammrrhodes which bit of the docs is unclear, and what could we do to make it clearer?

iammrrhodes
2019-11-19 22:02
Hey Beth, I'm not sure if I'm just struggling to figure out how the documentation fits to my use case... I'm being told by someone in my organisation how we _should_ be doing it, but I'm then trying to validate their instructions with actual PACT documentation... so I don't think it's a failing of documentation, maybe just my internal contradictions.

iammrrhodes
2019-11-19 22:04
I've spent the evening watching all the things I can find on PACT, but no one seems to go into detail on versioning and environment tags (which is what we're being told to do)

iammrrhodes
2019-11-19 22:04
and thankyou for the responses everyone, I'm very grateful.

bethskurrie
2019-11-19 22:17
There's a good page on it in the docs.

iammrrhodes
2019-11-19 22:17
I've read it several times.

bethskurrie
2019-11-19 22:18
Let us know, or submit a PR, if you can add some clarity.

iammrrhodes
2019-11-19 22:19
I need to get my head around it first, I need to figure out if what I'm being told to do is right or not in my current team...

matt.fellows
2019-11-20 02:33
> what I?m being told to do is right or not in my current team... What are you being told? If it would be useful, we?d be happy to help with any thinking for those who ar esuggesting it

ft1704602
2019-11-20 04:02
has joined #general

ft1704602
2019-11-20 04:18
Hi, I?ve just found out Pact CDC tests. It?s very interesting. I would like to know if my publisher api involves another external public api, is it still appropriate to use pact for testing? The basic flow is: consumer<->publisher<->externalApi.

tjones
2019-11-20 04:20
Yes, you have two choices: 1. you can describe the pact as consumer -> external API (essentially treating the publisher as part of the consumer)

tjones
2019-11-20 04:21
2. You can have two pacts, one from consumer -> publisher, and one from publisher -> externalAPI

tjones
2019-11-20 04:21
I think option 2 is probably best, but it depends on the relationship between the consumer and the publisher

tjones
2019-11-20 04:22
During provider testing for your publisher , you would mock out the externalAPI

tjones
2019-11-20 04:22
(probably by mocking the code that calls it)

ft1704602
2019-11-20 04:24
So every time the consumer modify the pact, I might need to modify the external api mock response ? It seems very bad for maintainability.


bethskurrie
2019-11-20 04:25
If you use type based matching, it shouldn't be.

bethskurrie
2019-11-20 04:26
Compare it to your other option - e2e integration tests.

bethskurrie
2019-11-20 04:28
Remember, you should only really need one or two interactions per endpoint.

tjones
2019-11-20 04:36
You're not mocking the external API responses

tjones
2019-11-20 04:36
you're mocking the code that calls the external API from within the publisher codebase

tjones
2019-11-20 04:37
This is the same pattern as would be used if your publisher (say) wrote to a database

ft1704602
2019-11-20 04:37
for example: the consumer sends 1, the provider uses an external api mock to get external response ?one?, then append 1 to one and return one1. If in the next pact somehow the input becomes 2, i have to modify the mock to return two, right? I want to know this because the external api returns a very complex object, so I don?t want to modify the mock often.

ft1704602
2019-11-20 04:39
@tjones but my publisher api have to interact with external api response to generate the response.

bethskurrie
2019-11-20 04:59
@ft1704602 have a read of this, and the gist that it links to


bernardoguerr
2019-11-20 12:14
Can I ask what exactly do you mean by environment tags? Careful about tagging with environments, I ran into that trap before. To me tagging should be more about differentiating production vs non production, not necessarily tagging with environments like dev, test, etc.

roi.otero.morales
2019-11-21 13:56
Hello everyone! is there a way to not fail `pactPublish` when there is no folder containing pacts? (I want to run pactPublish even if the Repo doesnt have consumers and only providers to have a standarized pipeline) `Execution failed for task ':pactPublish'.` > `http://java.io``.FileNotFoundException: /<somepath>/build/pacts`

vitaliy.grigoruk
2019-11-21 14:26
why don?t you wrap it yourself with a check if files/folder is there?

vitaliy.grigoruk
2019-11-21 14:27
in most of use-cases people would like to be aware if they try to publish pacts that do not exist?

roi.otero.morales
2019-11-21 14:45
Hey, thanks for the answer, I will try to wrap it, the thing is that the pactPublish task comes from the pact puglin, and not from a task defined in my file, so i am having troubles adding the condition to only be run if folder exists. my gradle skills are not the best if you have any suggestion is welcome :smile:


brendan.j.donegan
2019-11-21 16:00
has joined #general

vijay.chinthala
2019-11-21 18:46
has joined #general

vijay.chinthala
2019-11-21 19:03
Hi, I am facing Authorization error while executing pactVerify, the API expect the Authorization Bear token in the header; can someone please help pointing me to some example how to pass the Authorization

vijay.chinthala
2019-11-21 19:07
```10:28:28.630 [DEBUG] [http://au.com.dius.pact.provider.ProviderClient] Response: {statusCode=401, headers={X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], Content-Length=[52], Date=[Thu, 21 Nov 2019 18:28:27 GMT]}, contentType=application/json; charset=UTF-8, data={"message":"Null or Empty Authorization","code":401}}```

pavel.azarau
2019-11-21 19:10
has joined #general

vijay.chinthala
2019-11-21 19:12
@felipe I see you have used Authorization in the header, can you please help with some example code how did you generate the token, I had issues with Authorization while executing pactVerify

vijay.chinthala
2019-11-21 19:12
```10:28:28.630 [DEBUG] [http://au.com.dius.pact.provider.ProviderClient] Response: {statusCode=401, headers={X-Content-Type-Options=[nosniff], X-XSS-Protection=[1; mode=block], Cache-Control=[no-cache, no-store, max-age=0, must-revalidate], Pragma=[no-cache], Expires=[0], Content-Length=[52], Date=[Thu, 21 Nov 2019 18:28:27 GMT]}, contentType=application/json; charset=UTF-8, data={"message":"Null or Empty Authorization","code":401}}```

noel.chin
2019-11-21 19:37
has joined #general


vijay.chinthala
2019-11-21 20:24
Thank you for this information

vijay.chinthala
2019-11-21 20:24
I am using gradle and Junit5, is there an example that I could use in gradle

felipe
2019-11-21 21:08
Remind me tomorrow please

noel.chin
2019-11-21 21:30
Is anyone currently stubbing the response from an external auth api instead of modifying the auth token present in the PACT file?

bethskurrie
2019-11-21 21:53
That's the way I would do it, personally

bethskurrie
2019-11-21 21:54
Much easier. And token is usage is unlikely to get much benefit from contract testing.

bethskurrie
2019-11-21 21:55
It's functionality that's unlikely to change, and will be quickly picked up by higher level tests if it's wrong.

bethskurrie
2019-11-21 21:56
@vijay.chinthala consider if it would be easier to stub out the auth.

bethskurrie
2019-11-21 21:57
It's often something that doesn't benefit much from contract testing, as it's generally pretty stable, doesn't change much, and is often hard to provide valid values when verifying.

bethskurrie
2019-11-21 21:57
It's also something that will get picked up pretty easily and quickly in e2e tests.

bethskurrie
2019-11-21 21:59
Really? What problems did you have with tagging all the envs @bernardoguerr? It's the way I would do it.

vijay.chinthala
2019-11-21 22:04
Thanks Beth

vijay.chinthala
2019-11-21 22:04
I have tried this in my gradle file and it worked..

vijay.chinthala
2019-11-21 22:04
``` hasPactWith('learningService') { pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') // stateChangeUrl = new URI(PACT_BROKER_URL + '/v1/pactstates').toURL() // stateChangeUsesBody = true requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first req.addHeader('Authorization', 'Bearer ' + System.getProperty('PACT_BROKER_TOKEN') ) } }```

vijay.chinthala
2019-11-21 22:06
I have used requestFilter in the gradle script and it worked fine

vijay.chinthala
2019-11-21 22:06
```hasPactWith('learningService') { pactFile = file('build/pacts/learningServiceClient-learningServiceProvider.json') // stateChangeUrl = new URI(PACT_BROKER_URL + '/v1/pactstates').toURL() // stateChangeUsesBody = true requestFilter = { req -> // Add an authorization header to each request // because of our system needs login first req.addHeader('Authorization', 'Bearer ' + System.getProperty('PACT_BROKER_TOKEN') ) }``` }

vijay.chinthala
2019-11-21 22:06
Thanks for your help

bethskurrie
2019-11-21 22:10
That confuses me. Why would the request have the pact broker token added to it?

bethskurrie
2019-11-21 22:10
The replayed request goes to the provider, not the pact broker

vijay.chinthala
2019-11-21 22:19
yes that is correct I have script included in the serviceProviders { } just for testing purpose I am using the local pactFile to test pactVErify

vijay.chinthala
2019-11-21 22:21
and please ignore the naming conversion, it should be named as PACT_SERVICE_PROVIDER_TOKEN

matt.fellows
2019-11-21 22:35
Request filter is probably the way to go

crummynz
2019-11-21 23:36
has joined #general

roi.otero.morales
2019-11-22 09:57
Thanks for your help, finally i end up doing this: ```task pactPublishIfProducedPacts(description: 'Wrapper to only execute the pactPublish task if the repository contains consumers', group: 'Verification') { if (new File("$buildDir/pacts").exists()) { dependsOn pactPublish } }```

roi.otero.morales
2019-11-22 09:57
Not pretty but works?

noel.chin
2019-11-22 13:15
yeah that's what I was thinking as well. Are you using a library like nock to stub the requests?

bernardoguerr
2019-11-22 15:07
@beth: In our case, in the beginning there was a lot of focus on running this on each environment (dev, test, stage, prod). In reality, all we really need, in my opinion, is a distinction between what's in production, and what's in master. Because as far as I understand it, in the end what matters more is what version of code (commit sha) you're testing against, not in which environment (except whether it's in prod or not). Especially if you're testing against local (undeployed) versions of the API's, which I think is ideal. I think environments would only matter if you were testing against deployed versions of the API's. But if you're going for a CI/CD model, then that version of code (commit) should be being promoted through environments, and then in one of those, you would run your Pact tests (even if it was against a deployed version), and then promote it to the next stage. If you're testing it with Pact against each deployed environment, imo you're not really using it just for contract testing, but more like a rather expensive backend system-wide test. Anyway that was the final understanding I've reached of it now. So, TLDR: versioning for identifying *what* piece of code is running, tagging for identifying *where* it is running (*ie prod vs non-prod, potentially branches too)* Do you think that's wrong, Beth?

dschwartz
2019-11-22 16:47
I've read from several sources that CDC testing is not recommended for public apis - what about APIs which have both internal and external consumers - does supporting contracts for internal consumers create difficulty in managing the public API overall?

felipe
2019-11-22 17:44
you have to make sure that you dont have the authorization header in you pacts

felipe
2019-11-22 17:44
that was making trouble with mine

felipe
2019-11-22 17:46
`plugins {` id "java" id "`http://au.com``.dius.pact" version "4.0.3"` } import groovy.json.JsonSlurper def protocolInput = 'https' def hostInput = '`http://some.url.com``'` def portInput = 443 def token = "none" def getToken(username, password, protocol, host, port){ println "generating token" def BODY='{"grant_type": "password","username" : "'+username+'","password" : "'+password+'","scope" : "default"}' def p = ['curl', "-X", "POST", '-H', "Accept: application/json", "-H", "Content-Type:application/json", '--data', BODY, "$protocol://$host:$port/xxx/xxx/auth"].execute() p.waitFor() def json = new JsonSlurper().parseText(p.text) println "got token ${json.access_token}" return json.access_token } task('setup') { doLast { println "#######setup#######" delete fileTree('build/reports') { include '**/*.*' } def protocol = getOrDefault('PROTOCOL', protocolInput) def host = getOrDefault('HOST', hostInput) def port = getOrDefault('PORT', portInput) token = getToken('xxx', 'xxx', protocol, host, port) println "######setup done#####" } } pact { serviceProviders { wmsBackend { protocol = getOrDefault('PROTOCOL', protocolInput) host = getOrDefault('HOST', hostInput) port = getOrDefault('PORT', portInput) path = '/' startProviderTask = setup insecure = true requestFilter = { req -> println req req.addHeader('Authorization', "Bearer $token") } hasPactsWith('WmsFrontend') { pactFileLocation = file("$rootDir/../pacts/frontend") } } } reports { defaultReports() // adds the standard console output markdown // report in markdown format json // report in json format } } def getOrDefault(name, defaultValue){ return project.hasProperty(name) ? project.getProperties().get(name) : defaultValue; }

felipe
2019-11-22 17:46
thats my gradle

justaburneremailforso
2019-11-22 18:43
has joined #general

justaburneremailforso
2019-11-22 18:44
We are starting to use PACT in our team but are running into a strange issue. When we run mvn pact:verify we are getting this error:

justaburneremailforso
2019-11-22 18:46
"Request failed - Connect to localhost:8080 failed: localhost 127.0.0.1 failed: Connection refused connect:"

justaburneremailforso
2019-11-22 18:48
However when we run mvn clean test, the test passes. I don't know why this is happening as we are not using localhost:8080 anywhere in our consumer or provider code or anywhere in our pom. We suspect it's coming from the maven pact provider dependency in the pom but that is a bit of a guess. The application is not a spring boot application either. Any idea where we are going wrong?

bethskurrie
2019-11-22 19:36
@bernardoguerr whatever works for you! Just want to make sure I understand your workflow. So, you re-run the verification step before deploying to each stage? How do you know which version of the pact is in which environment?

uglyog
2019-11-23 00:27
`mvn pact:verify` is for verifying a runner provider. localhost:8080 is the default host and port for that. If you are using unit tests, you don't need to run that.

felipe
2019-11-23 05:12
Hi all! I?m Using the gradle verifier and I would like to know if there is any way to integrate the reports into Jenkins (pipeline). Thanks in advance

justaburneremailforso
2019-11-23 10:49
Is there a way to pass authentication details with a mvn clean install to the broker? We have switched on authentication on our broker so need to pass credentials in order to publish or verify the contracts. So far I haven't found the combination of arguments and pom changes to allow mvn clean test to update the verification status on a broker with authentication turned on.


justaburneremailforso
2019-11-24 23:25
Thanks!

justaburneremailforso
2019-11-24 23:27
Hello all, More of a general question, but what is the normal use case for using mvn pact:verify versus just a mvn clean test? Both will update the broker if configured correctly but I'm not sure why to use one over the other. Our tests are mostly annotated with @State on the provider side but seem to run the consumer side tests.

abubics
2019-11-25 00:18
no, if you have a consumer you're in control of, contract tests can help, and shouldn't cause any conflicts with external consumers :thumbsup:

abubics
2019-11-25 00:19
but it might highlight changes earlier . . . so you might end up wanting to make breaking changes sooner than your external consumers

pradeep.murthy
2019-11-25 07:22
has joined #general

pradeep.murthy
2019-11-25 07:29
Hi, All, we are in the process of using PACT within our projects. We really find PACT to be useful. However we have a general question as to whether the PACT is really being used by others at all in different companies, as the usage stats show as 0 here https://mvnrepository.com/artifact/au.com.dius/pact-jvm-consumer-junit

brendan.j.donegan
2019-11-25 09:46
Hi - I have a particular interaction that I'm a bit unsure how to deal with - basically the provider is returning as part of a the response, an 'dictionary' (slash object) of users, keyed by their ID. The number of users can vary so I want to be able to write the contract in such a way that it doesn't matter how many are returned. This essentially amounts to an object with a variable number of keys. Is there a good way to express this using matchers?

bart.schotten
2019-11-25 14:18
That will just work by default. Extra keys/properties are always allowed. You just need to have one or two keys as an example, which you could set up in the provider state.

john.hamlett
2019-11-25 14:28
has joined #general

ryan.dens
2019-11-25 14:41
For what its worth, my company uses the pact-jvm-consumer-junit, so it seems like those stats aren?t accurate

paul.simms
2019-11-25 16:20
has joined #general

paul.simms
2019-11-25 16:22
Good afternoon, We are implementing PACT consumer driven contract tests which is working well between the back-end services. We have micro-services with the following architecture: web-ui <-> graphQL <-> n * back-end services However there are questions on how to implement this through the graphQL layer. In reality this is a consumer of the back-end services, and a provider to the web-ui. As the consumer, GraphQL doesn't have the domain information for the actual required json that is initiated from the web-ui service. Then the web-ui service doesn't test against the back-end providers (as the graphQL layer is its provider) - and it hasn't got that association / knowledge of the back-end services. Is it that graphQL should create a PACT interaction with each back-end provider containing all its potential values with each service. Then this demonstrates that those interfaces remain compliant. Thus the real request (interaction) from the user (web-ui) has pacts with the GraphQL service (with mocks of the back-end services), so implicitly would work all the way through the stack. Has anyone got advice of how this works across this aggregation layer?

ryan.dens
2019-11-25 16:29
also worth noting that we proxy maven central via our own internal maven repository. I imagine many enterprises which use these tools are in similar situations, so these statistics can?t always be accurate. Makes sense that most ?hobby? projects wouldn?t need consumer driven contract testing

dtobiasalmont09
2019-11-25 17:21
has joined #general

dtobiasalmont09
2019-11-25 17:22
I am working with Pact Node and was trying to find a way to verify the consumer tests without having to publish to the shared broker. Not seeing good examples of this so we can add it to a jenkins pipeline

megha.agrawal
2019-11-25 19:10
has joined #general

vijay.chinthala
2019-11-25 23:38
Thank you Felipe, I got the same idea and except that I got the token generated in the java code and used the same in the pct script

bethskurrie
2019-11-26 01:29
Pact top tip: Ron and I have just come back from a chat with a Pact user (we'll call him "Dave") who ended up pulling out his Pact tests because they were too painful. The reason their Pact tests were painful was that Dave was using them for UI tests. Don't be like Dave! Use Pact to test the "back door" of your consumer, and keep your pact tests fast, maintainable, and easy to debug.


ambergkim
2019-11-26 05:26
has joined #general

vijay.chinthala
2019-11-26 08:38
I have another question what is the best practice to promote the pact tests, let's say I am making changes in the feature branch and I wanted promote to DEV, QA, INT, STG the nPRG

vijay.chinthala
2019-11-26 08:39
can this be managed through tags, or does it required different pact broker environment needed?

bethskurrie
2019-11-26 08:55
Tags

bethskurrie
2019-11-26 08:55
As each version gets promoted through the environments, you tag the application version resource in the broker with the name of the environment.

bethskurrie
2019-11-26 08:56
This is what allows you to use the `can-I-deploy - -to ENV` command

johnny.nilsson83
2019-11-26 09:23
has joined #general

matt.fellows
2019-11-26 09:42
Wow. That page really drills home the point!

bethskurrie
2019-11-26 09:47
@matt.fellows it may be overkill now!

bethskurrie
2019-11-26 09:48
I wanted to put the word "UI" in a top level heading so it was more prominent. But then it's basically 3 points saying the same thing.

bethskurrie
2019-11-26 09:48
I'll try and condence it at some point.

bethskurrie
2019-11-26 09:53
Seamus has found that not many people read the best practices page though.

matt.fellows
2019-11-26 10:03
Yeah. Perhaps we need a bit to remind people who've been here for > x weeks :laughing:

me1352
2019-11-26 12:47
has joined #general

resapu021
2019-11-26 13:41
has joined #general

megha.agrawal
2019-11-26 18:33
Hi I am able to successfully run the provider tests when the pact file is stored locally but getting 401 error when the pact file is store in pact broker. I am using python. Here is the command I am using ```pact-verifier --pact-url="http://your-pact-broker/pacts/provider/PROVIDER/consumer/CONSUMER/latest" --custom-provider-header='Authorization: Bearer mytoken' --provider-base-url="http://localhost:8080"``` Where am I doing wrong?

justaburneremailforso
2019-11-26 19:22
I actually have another question. You said mvn pact verify is for verifying a runner provider. What does that mean? Does it mean it expects to be run against something that is already up and running beforehand? For example does it expect some sort of mocked or real service or something to already be running on localhost:8080 before running mvn pact verify?

prabha_kannusamy2
2019-11-26 19:39
has joined #general

uglyog
2019-11-26 20:56
It?s for when you have the spring boot app running first, and then verify against that

vijay.chinthala
2019-11-26 22:22
returns a response which has status code 200 (OK) has a matching body (OK) Skipping publishing of verification results as it has been disabled (pact.verifier.publishResults is not 'true') BUILD SUCCESSFUL in 31s 8 actionable tasks: 3 executed, 5 up-to-date

vijay.chinthala
2019-11-26 22:22
I am always getting this Skipping publishing of verification results

bethskurrie
2019-11-26 22:23
Well, have you configured it to publish the results?

vijay.chinthala
2019-11-26 22:23
setting this System.setProperty("pact.verifier.publishResults", 'true') but no luck

vijay.chinthala
2019-11-26 22:23
hi Beth, yes

bethskurrie
2019-11-26 22:24
Sorry, I don't know how the pact js api works.

bethskurrie
2019-11-26 22:24
I didn't think it was a system property though

bethskurrie
2019-11-26 22:24
I thought it was a property in the verification configuration.


bethskurrie
2019-11-26 22:27
Best to ask in the pact python channel

bethskurrie
2019-11-26 22:27
The custom auth header is not for the broker though

bethskurrie
2019-11-26 22:27
That's for the provider.

bethskurrie
2019-11-26 22:28
You need to use --broker-token

megha.agrawal
2019-11-26 22:29
ok. Thanks. I will try that

bethskurrie
2019-11-26 22:29
Also, are you using that exact url?

bethskurrie
2019-11-26 22:29
You need to put your own consumer and provider in

megha.agrawal
2019-11-26 22:29
I did

vijay.chinthala
2019-11-26 22:29
I am using gradle and I have set the System property like advised in the forums

vijay.chinthala
2019-11-26 22:29
do I need to use Pact JS?

bethskurrie
2019-11-26 22:30
The verifier should allow you to give it the broker url and the provider name and just give you the pacts automatically.

bethskurrie
2019-11-26 22:30
If it doesn't, I'll raise an issue


bethskurrie
2019-11-26 22:30
Can you remove that preview?

bethskurrie
2019-11-26 22:31
I can't follow the conversation on mobile

megha.agrawal
2019-11-26 22:31
I am getting error when using --broker-token

megha.agrawal
2019-11-26 22:31
Error: no such option: ---broker-token

bethskurrie
2019-11-26 22:31
Oh, you're using pact JVM

vijay.chinthala
2019-11-26 22:31
yes

bethskurrie
2019-11-26 22:31
Ask in the pact JVM channel then.

bethskurrie
2019-11-26 22:31
Also, make sure you're using the latest version.

bethskurrie
2019-11-26 22:32
The provider tag publishing is only available in the latest version.

megha.agrawal
2019-11-26 22:32
```pact-verifier --pact-url="http://your-pact-broker/pacts/provider/PROVIDER/consumer/CONSUMER/latest" --broker-token='mytoken' --provider-base-url="http://localhost:8080"```

megha.agrawal
2019-11-26 22:32
I tried this

bethskurrie
2019-11-26 22:32
OK, its out of date.

bethskurrie
2019-11-26 22:33
I'll raise an issue

megha.agrawal
2019-11-26 22:33
thanks

megha.agrawal
2019-11-26 22:35
How will I know when this issue is fixed?

bethskurrie
2019-11-26 22:35
Follow the issue on github

ben.quinteros
2019-11-26 22:35
has joined #general

bethskurrie
2019-11-26 22:35
i'll post the link in a minute

megha.agrawal
2019-11-26 22:36
thanks


megha.agrawal
2019-11-26 22:44
Thanks Beth.


vijay.chinthala
2019-11-26 22:49
I see

vijay.chinthala
2019-11-26 22:50
I think here I need to access the correct URL of pact from broker and can set the version

vijay.chinthala
2019-11-26 22:50
I could set the version for consumer pactPublish

megha.agrawal
2019-11-26 22:51
:+1:

niciqy
2019-11-27 02:54
has joined #general

niciqy
2019-11-27 02:56
Does anyone has got experience with Pact and graphQL?

johnny.nilsson83
2019-11-27 08:02
Is there any, good, video that describes Pact, how to use it, and how to get started?

artemabezruchko
2019-11-27 08:58
has joined #general


viktor.justo449
2019-11-27 09:46
has joined #general

matt.fellows
2019-11-27 09:54
There's a few listed on the docs site too. It's probably not up to date with the very most recent tho

matt.fellows
2019-11-27 09:55
@hstene did a talk last year at NDC which was quite food

matt.fellows
2019-11-27 09:55
And @bethskurrie did one at YOW in Australia. Both worth a watch

justaburneremailforso
2019-11-27 17:03
Ok, thanks, that clears things up. Is there a way to change the default from localhost:8080 to something else?

timothy.proffitt
2019-11-27 17:05
has joined #general

timothy.proffitt
2019-11-27 17:08
hi @matt.fellows - were those talks recorded and are they available to watch?




matt.fellows
2019-11-27 21:20
:point_up:

matt.fellows
2019-11-27 21:21
you ask and it shall be - @yousafn!

timothy.proffitt
2019-11-27 21:21
thanks @yousafn

lenient315
2019-11-28 03:46
has joined #general

hstene
2019-11-28 06:28
You are too kind, Matt! :slightly_smiling_face:

johnny.nilsson83
2019-11-28 07:47
Hi, Our biggest issue is that the data we test on is consumed. "Accept an offer once, and the offer is gone" type of data. Is there a way to setup mock responses in Pact from some kind of gui outside of the applications making it possible to manually browse a webpage based on the mocked responses from the pact server?

fariasporras
2019-11-28 08:14
has joined #general

fariasporras
2019-11-28 08:18
Hello everyone, I have a question for you. It is possible to load pact files from a HTTPS URL using pact stub server in a docker container? Thanks in advance

fariasporras
2019-11-28 10:46
Hello again, Someone knows, why with pact-stub-server matchingRules it works, but with pact-stub-client marchingRules it doesn't work!

fariasporras
2019-11-28 11:04
WARN: Ignoring unsupported matching rules

matt.fellows
2019-11-28 11:06
Oh, and when I said "food"... I obviously meant burger :laughing:

uglyog
2019-11-28 11:19
pact-stub-client only supports V2 Pact spec, while pact-stub-server supports V3

fariasporras
2019-11-28 11:38
I create the pact-file using unit test and creating rules with PactDslJsonBody. How can i use v2 with PactDslJsonBody or how create a pact with V2 specs through unit test in JAVA?

fariasporras
2019-11-28 11:53
Basically, my problem is that I have to load my pact file with https and ssl. So with pact-stub-server i can't deploy in https with ssl cert and ssl key and I try to use pact-stub-client, but my pact file has V3 Pact specs. Thanks in advance

alexjjseppala
2019-11-28 19:16
has joined #general

uglyog
2019-11-28 21:01
What are you using to create the pact file? If you?re using the pact-jvm DSLs then you can provide the specification version.

uglyog
2019-11-28 21:05
For instance, PactProviderRule constructor takes the spec version as a constructor parameter

uglyog
2019-11-28 21:10
Have you tried with the latest version?

uglyog
2019-11-28 21:12
Are you asking if the is a GUI to setup pact files, are are you asking if you can run a GUI off a pact mock server? You can for the latter case.

bethskurrie
2019-11-28 23:17
Is there any way to make the scheme configurable in dev @fariasporras?

fariasporras
2019-11-29 07:39
I am using JUnit 5, JDK 8, pact-version 3.6.4. on the other hand i am using DslPart and PactDslJsonBody to generate the body with stringMatcher for the matching rules.

johnny.nilsson83
2019-11-29 09:43
I think I am asking both questions. And I recon you have answered both as well, or am I wrong? I'd like a way to prepare a pact-file that is not through testcase-code only, and when that pact-file is done, I'd like to run a GUI off of that

felipe.costa
2019-11-29 13:35
has joined #general

c.talek
2019-11-29 18:08
has joined #general

c.talek
2019-11-29 18:16
Hey there, i'm running through the docs for pact workshop using golang. My OS is windows, I'm using the win32 version of https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.72.2, I have golang installed and am running visual studio code w/all required addons. I was able to get through steps 1-8 no problem. All make/run commands worked. When I get to step 9 (and beyond) which adds authorization, I get this error $ make consumer --- Installing Pact CLI dependencies Sorry, you'll need to install the pact-ruby-standalone manually. make: *** [Makefile:4: install] Error 1 happens also on provider. Any idea on how to fix it? Pact is installed + added to PATH https://github.com/pact-foundation/pact-workshop-go/tree/step9

tenso2006
2019-11-29 21:16
has joined #general

uglyog
2019-11-29 23:39
I haven?t come across any tool like that

matt.fellows
2019-11-30 00:28
I noticed a few issues with the workshop yesterday Talak, I'll take a look today and see if it addresses this. Thanks for raising

lucas.salsaon2
2019-12-01 02:31
has joined #general

punithrajhd
2019-12-02 10:47
has joined #general

wjtlopez
2019-12-02 13:30
has joined #general

wjtlopez
2019-12-02 13:36
Hey guys. I'm playing around with Pact: i've got two consumer tests for the same provider, one is a RequestResponsePact and the other is a MessagePact. Each test is ran in different builds, so whichever occurs second just overwrites the first pact uploaded to my broker. Wondering if there's a way around this, does the broker not support consumer pacts of different types for the same provider? Thanks

bart.schotten
2019-12-02 15:11
No, sadly it does not. The workaround we use it to to append "-events" to the provider name in case of message pacts. That way they will both be stored on the pact broker. I guess you could also choose to differentiate the consumer names.

wjtlopez
2019-12-02 15:40
Thanks @bart.schotten

c.talek
2019-12-02 16:48
Still learning pact, one thing I'm not 100% clear on.. is this a replacement for unit tests? In the workshops at least they provide the same amount of coverage by testing an endpoint using a mocked service.. My assumption is yes they replace unit tests that mock services to test endpoints/states and unit tests themselves are only beneficial for services that do not communicate with other services

andrew.williams439
2019-12-02 17:13
has joined #general

alan.nichols
2019-12-02 17:29
In my case (an iOS app) they've replaced a large number of our unit tests but not all. We still have unit tests for things like malformed json where we want to make sure we're handling things correctly / defensively, but wouldn't ever publish a contract. Not an expert but maybe this helps

c.talek
2019-12-02 19:03
Thanks, thats helpful, hoping to hear other scenarios as well

mohsin
2019-12-02 19:31
Hi, question about adding users to pactflow: It asks me to send an email to to be able to add users to our broker. Am I not allowed to manage my own users?

ryan.dens
2019-12-02 19:36
I found this message useful for understanding how to use pact tests: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1574731798296800. I think these tests can replace unit tests in the consumer code which sends the message or the provider code which de-serializes the message, but that they shouldn?t feed into tests of other parts of the system. Test the ?handshake? and then let the other components of the consumer and provider test the business logic

bethskurrie
2019-12-02 20:42
@mohsin that API is in our backlog, it's just not completed yet. #startuplyf

bethskurrie
2019-12-02 20:44
I think @alan.nichols expressed it well. I tend to use pact tests as unit tests for the "client" class that makes the calls to the provider, but then I tend to have extra tests for things that wouldn't go in the contract, or would be very hard to test in a contract, exactly like Alan does.

bethskurrie
2019-12-02 20:46
eg. if there is some value that could be one of an enumeration of 20 different values, I probably wouldn't test all 20 in the contract. I'd do one or two, and then have a test that shows how my code would behave if it got an unexpected value (eg. would it throw an error, would it ignore it, would it handle it dynamically...)

uglyog
2019-12-02 20:46
@bethskurrie :point_up:

bethskurrie
2019-12-02 20:46
On the provider side, the verification tests behave more like black box, full stack tests, depending on how much you want to stub out.

bethskurrie
2019-12-02 20:47
Sorry @wjtlopez, this is something that we've discussed for ages as needing, but it's not yet supported.

bethskurrie
2019-12-02 20:47
We do intend to support it however.

bethskurrie
2019-12-02 20:48
I'll raise an issue in the Pact Broker so it's in the forefront of my mind.

bethskurrie
2019-12-02 20:48
Actually, now I think about it, there is already an issue.


bethskurrie
2019-12-02 20:50
Is anyone awake at the moment?

wjtlopez
2019-12-02 20:50
Great, thanks. As a side note, not sure you're aware, but if I upload 5 pacts for a http consumer, and then overwrite it with a messaged based pact for the same consumer/provider, the 6th and all the previous ones are overwritten. It's odd that the previous versions are also changed

bethskurrie
2019-12-02 20:50
We're working on some animations for explaining how pact works, and I'd like some feedback on a couple of options that we're working on.

wjtlopez
2019-12-02 20:51
Haven't looked into it but just a curious thing I noticed

mohsin
2019-12-02 20:54
I?m awake. I better be as I?m at work on Pacific Time :slightly_smiling_face:

matt.fellows
2019-12-02 22:43
@mohsin are you on the free plan? There is a 1 user limit on the free plan, but we can get you going on a trial if you?d like to explore. And yes, we have user management on our near-nerm roadmap

bethskurrie
2019-12-02 22:43
Will pm you

kiranpatel11
2019-12-02 23:08
I am in

bethskurrie
2019-12-02 23:08
:thumbsup::skin-tone-3:

mohsin
2019-12-02 23:09
I?m on the paid plan.

marco
2019-12-03 07:09
If you want some more eyes & thoughts, I'm available too :slightly_smiling_face:

vitaliy.grigoruk
2019-12-03 08:54
ping me if you need more :eyes: on it

bethskurrie
2019-12-03 09:22
@mohsin you can check out our roadmap here https://blog.pactflow.io/pactflow-feature-roadmap/

matt.fellows
2019-12-03 09:42
You peeps are so awesome

bethskurrie
2019-12-03 09:46
@megha.agrawal if you're comfortable coding python, I'm sure the maintainer would love a PR for this. It should be a very simple change.

wjtlopez
2019-12-03 10:21
Hello again. I've been spiking out Pact and think i've read most of the documentation but the provider setup remains a little unclear. I understand that it can be configured with the Maven plugin, or we can write specific tests (spring boot style). I would prefer to avoid the plugin approach as I don't want to set up provider states via urls, but with the alternative approach I wonder how others set up their tests so that there's always something that breaks the build if we aren't fulfilling a contract. As soon as you have one specific api test in place, then any other api contract failures will be flagged. But if you don't have a specific api test, how do you set up a catch all type test?

wjtlopez
2019-12-03 10:27
To further clarify my question: when you create a new Provider, which as of yet has no consumers, how do you configure it without the plugin so that when a consumer creates a Pact, the Provider starts failing because it's not fulfilled one of the states required

alan.nichols
2019-12-03 10:44
@bethskurrie this is exactly the approach we have taken ```I probably wouldn't test all 20 in the contract``` We have many calls with enums as Ints. Our contracts only say that we expect anything with type Int. The other unit and Integration tests can cover off specific examples.

christian.johann.eder
2019-12-03 11:03
has joined #general

christian.johann.eder
2019-12-03 12:15
Hi all, I've also been toying with Pact in a project, but ran into 2 issues which led us to implement something custom lightweight Pact-like, instead of using Pact directly. I now wanted to ask if there is any movement in those areas. 1. We're using protobuf serialization. Following the corresponding slack channel clears things up for me regarding the current state of affairs 2. We're not using HTTP, but rather something TCP-ish. Is anyone using Pact with non HTTP Apis?

wjtlopez
2019-12-03 14:45
Can someone please put me out of my misery: can I use the maven plugin to publish verification results without having used it to verify the pacts? I'm verifying pacts with provider side spring boot tests. Now I want to publish that to my broker, but configuring the maven plugin and running publish does nothing. How do I publish verifications to my broker?

ryan.dens
2019-12-03 14:54
Running `pact:publish` with the maven plugin will attempt to publish contracts you?ve created locally (which don?t exist on the provider side) which is why you aren?t see anything happen. The maven plugin also has no way of knowing whether or not your verification was successful. However, you can much more easily publish verification results with the pact-jvm-provider-spring extension that you?re already using to run your verification. Simply set the java system property `pact.provider.version` to the version of the provider that is running the verification (taken from the pact-jvm-provider-spring README https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-spring)

wjtlopez
2019-12-03 15:03
Thanks @ryan.dens I finally found a way to do it: passing through two relevant environment variables to my maven test command

megha.agrawal
2019-12-03 17:05
@bethskurrie I need more info on the change. I?m not sure what change is required ?

bethskurrie
2019-12-03 19:43
The python code calls a CLI under the hood @megha.agrawal. It just needs the --broker-token passed through to it.


bethskurrie
2019-12-03 19:49
That's for verifying pacts. I can't find where the publishing code is.

matt.fellows
2019-12-03 20:28
I can't speak for maven because I haven't used it, but for question number 2 take a look into the docs on tagging. This is how you safely introduce new changes into the system without breaking everything and annoying your provider teams :laughing:

israel.santiago75
2019-12-03 23:46
has joined #general

bheemreddy181
2019-12-04 03:39
I can contribute a bit too

idamasce
2019-12-04 13:46
has joined #general

bernardoguerr
2019-12-04 16:26
Me too! Ping me if still need someone

wjtlopez
2019-12-04 17:06
Does anyone know where I can find what benefit there is in using pactflow over doing it yourself? I can't see much on the website which helps understand why you'd choose to pay for pactflow and I'd like to find out so I can present it at work and let them decide. All I can see is that it has a nicer UI? Thanks

vitaliy.grigoruk
2019-12-04 19:21
Well, you don?t need to operate an additional service + no infra costs

bethskurrie
2019-12-04 19:24
@wjtlopez here's some info on the extras https://pactflow.io/oss/

bethskurrie
2019-12-04 19:26
As time goes on, the number of extra features in Pactflow will increase. Here is our roadmap https://blog.pactflow.io/pactflow-feature-roadmap/

bethskurrie
2019-12-04 19:28
The OSS Pact Broker makes Pact "work", while Pactflow is designed to make Pact work *at scale*.

wjtlopez
2019-12-04 19:32
Thanks @bethskurrie will check it out

bethskurrie
2019-12-04 19:53
Have PMed you @bheemreddy181. Will also PM you @bernardoguerr, thanks

yamuna.rani
2019-12-05 06:34
has joined #general

yamuna.rani
2019-12-05 06:35
Hi Team

yamuna.rani
2019-12-05 06:36
How to change the tenant ID?

matt.fellows
2019-12-05 06:45
Of I could embellish the above, what you get with Pactflow over and above the OSS broker: ? New UX (nicer and easier to use than the server-side rendered templates in OSS) ? Authentication via local user accounts, Github, Google or another OIDC/SAML provider ? Secrets management (i.e. fully encrypted secrets for use in automation etc. that are also redacted from all logs/UI etc.) ? Webhooks management screens ? Detailed verification results displayed in the UI (when a contract breaks a provider build, you can see in the UI what specific components of the interaction failed) ? Audit API (business plans and above) to be able to track changes for security / auditing purposes ? User management with RBAC is coming soon (Q1 next year) In addition to this, you'll be helping to support the growth of the Pact ecosystem through our work on Pactflow. For example, in Q1 next year we'll have v3.0 and XML support in JS/Typescript interface and our Pending Pacts feature is currently in active development.. You can also see a bit more into our roadmap at https://blog.pactflow.io/pactflow-feature-roadmap/

bethskurrie
2019-12-05 06:45
Addressed via PM.

abhilash.giridharan
2019-12-05 07:22
has joined #general

karl
2019-12-05 10:37
has joined #general


wjtlopez
2019-12-05 10:46
Thanks guys that's really helpful. Can I suggest you make it more easy to access in the website? I can't actually see how to navigate to the /oss page. As a user I would have jumped straight to a top level section called 'why choose pactflow'

karl
2019-12-05 10:49
https://github.com/pact-foundation/pact-js/tree/master/examples/messages <- only suggests that pub/sub is supported and not an asynchronous request-response pattern is

adam.ashton
2019-12-05 10:49
has joined #general

karl
2019-12-05 10:52
https://github.com/pact-foundation/pact-js#using-pact-js <-- Using Pact JS Pact supports synchronous request-response style HTTP interactions and asynchronous interactions with JSON-formatted payloads.

karl
2019-12-05 10:53
We can write manual asynchronous request-response tests but that would mean instead of writing one consumer and one provider test, we need to write two consumer and two provider tests

bethskurrie
2019-12-05 11:06
Hi @karl

bethskurrie
2019-12-05 11:10
So, unfortunately what you're describing is the best we've currently got for messages. We had a go at designing "synchronous message pact" but realised that, unlike HTTP, where you can have a generic mock service that works for all languages and http clients (as all http is the same) creating a synchronous message mock would have to be done on a language by language, library by library basis.

bethskurrie
2019-12-05 11:11
We still want to do it, but it's going to be a lot of work.

bethskurrie
2019-12-05 11:11
We'll probably start with synchronous lambdas in js.

bethskurrie
2019-12-05 11:12
What is your messaging tech?

bethskurrie
2019-12-05 11:13
(Sorry, you won't hear much more from me now as it's night time in :flag-au:, but I'll check this thread in the morning)

karl
2019-12-05 11:13
node, ws and we are looking at implementing asyncapi, seems to be supported by some big companies.

karl
2019-12-05 11:13
No worries! :slightly_smiling_face:

bethskurrie
2019-12-05 11:14
Asyncapi is just the documentation format isn't it?

bethskurrie
2019-12-05 11:15
What is the message protocol you're using?

fariasporras
2019-12-05 13:02
Hi, how can i define a matchersRule for a specific integer using specs v2 into a PactDslJsonBody? thanks in advance!

fariasporras
2019-12-05 13:04
I got generate a specs v2 with junit5 using: @PactTestFor( pactVersion = PactSpecVersion.V2 )

fariasporras
2019-12-05 13:05
Now i need to generate a matcher rule for an integer into PactDslJsonBody, because this don't work for specs v2: DslPart dslPart = new PactDslJsonBody() .integerType("age", 14) .stringMatcher("age", "(12)|(14)", String.valueOf(14)) ...

fariasporras
2019-12-05 13:06
Thanks in advance

karl
2019-12-05 15:25
oh sorry. websockets!

c.talek
2019-12-05 15:55
General question as well, has anyone tried integrating pact tests with a monolithic app that is being split apart into microservices? Just looking for written experiences/any headaches.. Said monolith is very API rich however due to it's size, the entire product needs to be installed in order to access said API's.. microservices are being created around it and while contract testing is great to bind microservice to microservice, it's tricky when dealing with the monolith.. only solution I found would be to have an always-online/installed monolith; upgraded frequently & injected to place it in states required for interacting with contract tests, and off we go.. Eventually the entire monolith will be broken out but until that point our tests will need to reflect the state of our product.. which will end up being more integration tests for the monolith and more contract/unit for what we can break out..

fariasporras
2019-12-05 16:26
hi @bethskurrie how pact-stub-server running with HTTPS with docker? thanks in advance!

bethskurrie
2019-12-05 19:07
Try in #pact-jvm @fariasporras

michael.bardouille
2019-12-05 19:50
has joined #general

michael.bardouille
2019-12-05 19:54
We are exploring using contract testing for our services and are currently attempting a proof of concept. However we have reached a stumbling block in our provider test as the service we are validating against requires an auth token in the request payload. If we generate a token and modify the contract the provider test passes. If we don't the tests fails. I was wondering if anyone can point us in the direction of some resources that could help us get around this blocker as we would like to avoid having to generate a valid token for every contract test we potentially look to set up.

ryan.dens
2019-12-05 20:05
It seems the answer is using request filters or provider states per: https://docs.pact.io/faq#how-do-i-test-oauth-or-other-security-headers

bethskurrie
2019-12-06 00:23
@michael.bardouille @ryan.dens I've just thrown this together https://docs.pact.io/best_practices/provider/handling_auth

khoatran
2019-12-06 00:32
has joined #general

khoatran
2019-12-06 00:39
Hi guys/gals, are there examples on how to integrate pact for messages for ruby

matt.fellows
2019-12-06 01:48
It?s a good point. It was actually a deliberate link from OSS web properties / assets, but we should do that too

matt.fellows
2019-12-06 01:48
Thanks

bethskurrie
2019-12-06 02:44
@khoatran I think only one side is done for Ruby, consumer or provider, I can't remember.

bethskurrie
2019-12-06 02:44
Let's have a chat in #pact-ruby

khoatran
2019-12-06 05:27
thanks Beth

jpatron20
2019-12-06 08:48
has joined #general

igalbenardete
2019-12-06 09:43
has joined #general

karl
2019-12-06 11:34
Hi I've got a question regarding async and protocols

karl
2019-12-06 11:35
In contracts tests, should I involve testing the actual connection, websocket in this example. Or should we only be concerned about the messages?

matt.fellows
2019-12-06 11:55
I would not test the websocket specific bit in a Pact test. At least, not as our library stands today. The messages is all we care about and you can (and perhaps should) have separate tests that check your websocket bits work independently of the messages

karl
2019-12-06 12:32
But how would I know that the consumer has the relevant http headers when a connection attempt is established? If the producer requires a JWT token and the consumer doesn't provide one then the two are incompatible?

karl
2019-12-06 12:33
What I wrote above is however supported in the sync version of pact due to pact actually spinning up a mock server with the given header specifications.

karl
2019-12-06 12:35
As far as I see it the async area in pact is only a contract between functions inside both applications. Providers function will give a specific object that the Consumers function can accept. But this doesn't help if the two can't even connect to begin with. Do you understand what I mean?

karl
2019-12-06 12:36
(I'm thinking out loud here, I love pact so far lol)

karl
2019-12-06 12:38
(one connection test should be enough since all of the messages can then use this one connection)

adi.chikara
2019-12-06 15:53
has joined #general

adi.chikara
2019-12-06 19:12
Is there an example of Pact being used for wrapper APIs on top of ERP solutions?

akkoubak
2019-12-06 20:23
has joined #general

akkoubak
2019-12-06 20:30
Hello, I am currently using a .Net implementation of pact. I signed up for a PactFlow broker account that I can publish results to using PowerShell. However, I am unable to connect to my broker to verify Pact, and I am getting a 401: {Error reading file from <https://MyBroker/pacts/provider/MyProvider/consumer/MyConsumer/latest> HTTP request failed: status=401....} I attempted both http and https protocols for .PactUri values. I also fetched my API token in my PactVerifierConfig { CustomHeader = new KeyValuePair<string, string>("Authorization", "Bearer xxxxx")}. Any idea on where to go from here?

akkoubak
2019-12-06 21:08
I have a feeling the issue has to do with CustomHeader

bethskurrie
2019-12-06 23:30
Which pact stub server are you using @fariasporras?

bethskurrie
2019-12-06 23:30
If it's the rust one, I don't know

bethskurrie
2019-12-06 23:32
If it's the one from the pact-cli docker image, then you then these are the options https://github.com/pact-foundation/pact-mock_service/blob/master/README.md#with-ssl

bethskurrie
2019-12-06 23:32
The Ruby one (above) only supports v2 though

keshavpra
2019-12-07 03:33
has joined #general

khoatran
2019-12-08 19:51
Has anyone tried pact to test an AWS step function? We've got service A exposing a lambda function and service B consuming the lambda function through a step function, i.e. function invocation in a config file instead of code.

neil
2019-12-08 23:40
Instead of using a custom header, you can use ```.PactUri("<http://pact-broker/pacts/provider/Something%20Api/consumer/Consumer/latest>", new PactUriOptions("my_bearer_token"))```


matt.fellows
2019-12-09 01:28
Oooh that?s a good question. I think it?s definitely doable, given that it emits JS. I haven?t thought on it hard enough to know if it would be useful, but my gut feeling is yes

matt.fellows
2019-12-09 01:28
@uglyog thoughts?

uglyog
2019-12-09 01:30
Yes, it would be definitely doable. Step functions are great because they get an event as input, and return one as output which is passed into the next step. So JSON in, JSON out, no side effects

uglyog
2019-12-09 01:31
You should be able to use the Message Pact to verify the output with the next input

matt.fellows
2019-12-09 01:31
What do you mean my ?no side effects??

bethskurrie
2019-12-09 01:31
except we don't have synchronous message pact yet!

uglyog
2019-12-09 01:32
As in the output gets passed to the next step, nothing outside step functions effects it

matt.fellows
2019-12-09 01:32
right, yes. Otherwise? pretty useless step functions

matt.fellows
2019-12-09 01:32
like Haskell 1.0

uglyog
2019-12-09 01:32
It's not synchronous, it's a step in a state machine

matt.fellows
2019-12-09 01:33
the output goes to another lambda

uglyog
2019-12-09 01:33
Also, the whole state machine works similar, JSON in and then JSON out

matt.fellows
2019-12-09 01:33
(or the same, but is the input to another scenario)

matt.fellows
2019-12-09 01:33
(that comment was for Beth?s remark)

ivangsa
2019-12-09 10:44
has joined #general

akkoubak
2019-12-09 15:44
@neil thx for the answer, but PactUriOptions in my case takes only takes a minimum of two arguments (for username and password). Severity Code Description Project File Line Suppression State Error CS7036 There is no argument given that corresponds to the required formal parameter 'password' of 'PactUriOptions.PactUriOptions(string, string)' tests C:\Users\AAkkoub\Documents\ManagerMobileAzure\HelloWorld\PactAzureProj\Provider\tests\ProviderApiTests.cs 76 Active

gordo
2019-12-09 22:18
has joined #general

neil
2019-12-10 00:34
@akkoubak If you update to the latest nuget package, you?ll have the additional options

khoatran
2019-12-10 00:44
thanks all for your inputs. Can anyone give some more details. I'm pretty clueless now.

akkoubak
2019-12-10 02:08
@neil It turned out I was using an older version of pactnet. I updated my version, and switched my target framework, and it worked. Thank you for your help!

bethskurrie
2019-12-10 09:51
@khoatran I'm assuming your step functions are written in node?

bethskurrie
2019-12-10 09:53
It sounds to me like you'd need both an input and an output, and at the moment pact-js for messages only allows you to specify the output.

bethskurrie
2019-12-10 09:54
If you look at the pact-js docs, you'll find a section on message pact

bethskurrie
2019-12-10 09:55
The way message pact works is that we ignore the protocol, and just test the payloads

bethskurrie
2019-12-10 09:58
But we'd need the input and the output

bethskurrie
2019-12-10 10:30
Ideally you should be testing the business logic of the function, without actually hitting any AWS specific code.

bethskurrie
2019-12-10 10:30
Without having to deploy.

bethskurrie
2019-12-10 10:31
Disclaimer, I've never written a step function! So I'm talking from theory here.

james.hattersley-dyke
2019-12-10 10:46
Hi all, I've a bit of an annoying problem with our CD set up. I've got everything working using webhooks etc. it's to do with versioning. So in our pipelines, before a Provider is merged to master in git the verification step runs as a unit test and it has one version number say `1.4.1` after the merge it's bumped to `1.4.2` automatically, thus creating a detached unverified version of the provider because the verification step doesn't happen again, and if it did and where to fail, it'd leave built docker images laying around etc. What happens is Consumers come along and their CI pipeline executes `can-i-deploy --a my-consumer --verison consumer-version --to master --latest` or something like that... it's got no way of knowing the provider version has jumped following it's changes and because the verification hasn't happened again i.e the contract hasn't changed, the only way to reverify is manually. Has anyone got any advice on how to handle this, aside from either double tagging the pact with both provider verisons or re-running the verification post merge? It's a bit odd I know, but the versioning of our apps changed to solve one problem we where having, thus creating another!

james.hattersley-dyke
2019-12-10 12:53
I've also thought as well as running `can-i-deploy` on the consumer side I could solve the above by always running a verification on every consumer build. That might cause other problems down the line tho

gaurav.singh55
2019-12-10 13:06
has joined #general

fariasporras
2019-12-10 14:36
yes, i tried with pact-stub-server v0.3.1 --> https://hub.docker.com/r/pactfoundation/pact-stub-server/

fariasporras
2019-12-10 14:38
ok, i tried with pact-stub-server v0.3.1, but i can´t load my contract with https using this -> https://hub.docker.com/r/pactfoundation/pact-stub-server/ Thanks in advance.

prabha_kannusamy2
2019-12-10 15:33
Hi All, I am trying to run pact validation with swagger.yaml file. In swagger file there is a security definition for my api like "security: - apiKey: []". But when i run the pact test it is complaining "[ERROR] GET on path '/api/v1/user-dashboard/user' requires security parameters. None found."

gabrieltnishimura
2019-12-10 16:48
has joined #general

bethskurrie
2019-12-10 19:43
@prabha_kannusamy2 try asking in the #swagger-validator channel

bethskurrie
2019-12-10 19:44
The swagger validator is a tool written by Atlassian employees and open sourced, so the core pact maintainer group can't really help you with it.

bethskurrie
2019-12-10 19:46
That's a tricky one @james.hattersley-dyke

bethskurrie
2019-12-10 19:49
If you're using can I deploy for both consumer and provider anyway, I'd say, rerun the provider verification after merge, but add an `|| true` so that it never fails the build

bethskurrie
2019-12-10 19:50
It will most likely pass if the previous one passed, and if it fails, it will be caught by the can I deploy step.

khoatran
2019-12-10 19:54
thanks Beth. Sorry I didn't get the notification on your reply and thus the late reply

khoatran
2019-12-10 19:54
the step function is written in a cloud formation template, i.e. yaml

bethskurrie
2019-12-10 19:58
The new "pending pacts" feature might help with this.


bethskurrie
2019-12-10 20:00
It's currently being beta tested.

bethskurrie
2019-12-10 20:03
@karl you're right, the current support isn't sufficient. We hope to have better support for websockets in the future, however, it's not on the immediate road map. Sorry!

prabha_kannusamy2
2019-12-10 20:23
Actually it is failing in pact Validation , when trying to see the YAML has security defined for the api as apiKey, but i am not sure how to send it in pactVerification .com.atlassian.oai.validator.pact.ValidatedPactProviderRule$PactValidationError: Validation failed. [ERROR] PUT on path '/api/v1/advisor-dashboard/crmKey/update' requires security parameters. None found. [INFO] PUT on path '/api/v1/advisor-dashboard/crmKey/update' defines a response schema but no response body found. at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.validatePactDef(ValidatedPactProviderRule.java:98) at com.atlassian.oai.validator.pact.ValidatedPactProviderRule.access$000(ValidatedPactProviderRule.java:27)

matt.fellows
2019-12-10 21:02
That still looks to be the use of the atlassian tool. It has its own Pact validation but it's not Pact

uglyog
2019-12-10 22:27
Output is downstream to the next step or thing, not back

bethskurrie
2019-12-10 22:27
But don't you need to give it an input?

uglyog
2019-12-10 22:29
Sigh, let's discuss this with a whiteboard.

bethskurrie
2019-12-10 22:29
Yes teacher :joy:

rbhati
2019-12-10 22:37
hi all & @matt.fellows, @bethskurrie: need directions on following situation: [i'm unable to find designated slack channel for pact-provider-verifier] I'm executing `pact-provider-verifier` with `--verbose` in shell to do pact validation at provider side Problem: How can i get the request/response printed in case of failure. When it fails all i get is below, I have no clue what got sent and what got received. `Failures:`  `1) Verifying a pact between my-consumer and my-provider Given This-is-given request to fetch accounts with POST / returns a response which has status code 200`    `Failure/Error: expect(response_status).to eql expected_response_status` `   `     `expected: 200`        `got: 500` `   `     `(compared using eql?)`  `2) Verifying a pact between my-consumer and my-provider Given This-is-given request to fetch accounts with POST / returns a response which has a matching body`    `Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example` `   `     `Actual: POST body missing. Did you forget use body-parser middleware?` `   `     `Diff`     `--------------------------------------`     `Key: - is expected`          `+ is actual`      `Matching keys and values are not shown`

bethskurrie
2019-12-11 03:21
@rbhati there's a log file

bethskurrie
2019-12-11 03:21
You can tell it where to go in the options.

james.hattersley-dyke
2019-12-11 09:41
Thanks Beth, we went with the reverification on the provider build but not waiting on the outcome as it'll have already passed as you say. Basically nothing changes in the code, just a version gets incremented once it's merged into master.

karl
2019-12-11 11:35
It's ok Beth and thanks for answering, it's nice to know that yous are aware!

bernardoguerr
2019-12-11 15:00
I'm assuming one of the steps of the step function is the invocation of the lambda function, then receiving that input. I think the point at which you would test is not the step function itself, but whatever is the next step in the step function that consumes that message. That is, there should be code that runs against the lambda's output and uses it as input (potentially in another lambda, for example). The step function is just orchestrating it

bernardoguerr
2019-12-11 15:01
do you have the step function diagram, or some architecture diagrams of the services?

bethskurrie
2019-12-11 20:12
I'm guessing it just doesn't support running with https. You could raise an issue requesting it.

theriaultnicolas
2019-12-12 03:10
has joined #general

michael.donkhin
2019-12-12 15:57
has joined #general

sam774
2019-12-12 18:59
has joined #general

sam774
2019-12-12 20:54
Does anyone have any experience running the pact-cli docker image on gitlab? Simple example but if locally I was to run: `docker run --rm pactfoundation/pact-cli help` as a simple example, what we're doing there is passing a command to the container. The entry point for the pact-cli image is running a shell script, which effectively proxies the command you pass into the container. In Gitlab, the operating model is slightly different and you can't specify a command to the image in the same way, and so: ` mypactjob: image: pactfoundation/pact-cli:latest script: - help ` Then this isn't going to work.

travis.anderson
2019-12-12 21:21
Hello everyone, I have a question about how exactly request filters work when testing with OAuth headers? Specifically, on the consumer side of testing does the authentication actually get checked? Or is the whole process on both consumer and provider side essentially stubbed out?

vitaliy.grigoruk
2019-12-12 21:33
Hi Travis. On the consumer side, you can verify that headers are set and that pact mockserver receives requests with necessary headers. Then on provider?s side, when your contract is gonna be verified against a running provider, you?ll need to override auth headers. Pact provides a way to do this for each request verifier checks, but you need to generate valid auth tokens yourself for this.

travis.anderson
2019-12-12 21:55
Hi Vitalii, thanks for getting back to me. So from what I understand, I will need to get those valid auth tokens (probably programmatically by a request to the auth service). On the provider side, override the header with a valid token from that response, and on the consumer side do the same?

bethskurrie
2019-12-12 22:06
I wrote a page about options regarding this the other day!


bethskurrie
2019-12-12 22:08
Hi @sam774

bethskurrie
2019-12-12 22:09
I'm the maintainer of the Pact cli docker image.

bethskurrie
2019-12-12 22:09
I'm not familiar with gitlab, so I don't quite understand the constraint.

bethskurrie
2019-12-12 22:09
Are you saying, you can't pass an argument to the container?

bethskurrie
2019-12-12 22:10
Could you build your own image based on the pact-cli to call the task you're interested in without any args?

travis.anderson
2019-12-12 22:24
Oh awesome! So I guess my question is: is there any authentication that needs to happen on the consumer side tests? Or is that dependednt on how the individual app handles auth?

sam774
2019-12-12 22:31
Hi Beth. That should be possible, I'll give it a try thanks! Will attempt to get a sample repo up tomorrow :grin:

bethskurrie
2019-12-12 22:31
You put in any authentication you want to use on the provider side.

bethskurrie
2019-12-12 22:32
Let me know how you go

bethskurrie
2019-12-12 22:32
It's very hard to give generic advice, because only you know what is covered where in your test suites.

bethskurrie
2019-12-12 22:34
You could put in a hard coded token if you wanted to stub the auth code on the provider to accept a hard coded token.

bethskurrie
2019-12-12 22:35
If you reckon you'll just stub the whole thing, or turn off auth, then there's not much point putting it in the consumer side.

bethskurrie
2019-12-12 22:35
It might lead to a false sense of confidence if it's not actually being used. "oh, it's in the contract, it must be right!"

travis.anderson
2019-12-12 23:31
Oh! I think I understand. So as long as I set up the provider with the proper interactions to produce a 401, I can grab a valid token and override the request on the provider side. I'll give that a shot and see what happens I guess :man-shrugging:

bethskurrie
2019-12-12 23:33
:+1:

pact
2019-12-13 10:10
has joined #general

sam774
2019-12-13 14:21
Hey Beth. Thanks for the pointer. I managed to get this working, thankfully without having to build an additional image. Sample repo at https://gitlab.com/my-pact-experiments/pact-provider My Gitlab job needs to looks like this: > test: > stage: test > image: > name: pactfoundation/pact-cli:0.1.0-1 > entrypoint: [""] > services: > - name: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHORT_SHA} > alias: app > script: > - cd /pact > - | > bundle exec bin/pact verify \ > --provider_base_url http://app:8081 \ > --provider-states-setup-url http://app:8081/provider-states \ > --wait 10 That is running the Java web app built in a previous job as a service (an additional container on the side), and setting pact-cli to be the main image run for this job. I'm overriding the entrypoint to be [""] so that gitlab can start it correctly. Then, in the script section, I can effectively recreate what's done in the pact-cli entrypoint, of cd'ing to the /pact dir and running the verify step :slightly_smiling_face: The bit I've missed out here is that I'm not using Pact broker (another rant for another time). The gitlab runner will actually clone your repo into this docker container, and so it's easy to point at local pact files. Just add: $CI_PROJECT_DIR/<location-of-pact-file>

michael.donkhin
2019-12-15 09:01
Hi all,

michael.donkhin
2019-12-15 09:09
I have a question regarding a strange behavior of Pact Broker: for the can-i-deploy endpoint, I receive a 'falsy' result when the provider tests for the consumer I am currently querying have newer verification results in another branch. The situation is like this: Consumer build in a 'master' branch is trying to check if deployment is possible, using the consumer version and the 'master' tag. A matching provider version verification exists on 'master' tag, but can-id-deploy returns _`"deployable": null`_ result with a message: '_There is no verified pact between version 'xxxxx' of Consumer and the latest version of Provider with tag master (no such version exists)_' This is because there is a newer version of Provider on a feature branch with a changed pact contract. Is it the expected behavior? In this case it's hard to understand why, because it breaks the 'master' branch build each time there is a newer version on a feature branch.

bethskurrie
2019-12-15 09:11
@michael.donkhin turn on the verbose mode and get the URL that the request is making

bethskurrie
2019-12-15 09:11
Paste that into a browser and have a look at the table that gets returned.

bethskurrie
2019-12-15 09:12
The feature branch pact won't affect this result unless you've published it with the same consumer version ID.

bethskurrie
2019-12-15 09:13
Or, with the master tag.

bethskurrie
2019-12-15 09:13
Also, can you provide the actual command you're using to do can I deploy.

michael.donkhin
2019-12-15 09:15
I'm using direct REST call from a Rest client: `http://<my pact broker address>/can-i-deploy?pacticipant=<Consumer>&version=<Consumer Version>&to=master`

bethskurrie
2019-12-15 09:16
Hm. You won't get a table with that query

bethskurrie
2019-12-15 09:16
You'll need to run the cli

michael.donkhin
2019-12-15 09:21
BTW, here is the result I get: `{` `"summary": {` `"deployable": null,` `"reason": "There is no verified pact between version <Consumer Version> of <Consumer> and the latest version of <Provider> with tag master (no such version exists)\nThere is no verified pact between the latest version of <Higher Level Consumer> with tag master (<Higher Level Consumer Version>) and version <Consumer Version> of <Consumer>",` `"success": 0,` `"failed": 0,` `"unknown": 2` `},` `"matrix": [` `{` `"consumer": {` `"name": "<Higher Level Consumer>",` `"version": {` `"number": "<Higher Level Consumer Version>",` `"_links": {` `"self": {` `"href": "http://<pact broker address>/pacticipants/<Higher Level Consumer>/versions/<Higher Level Consumer Version>"` `}` `}` `},` `"_links": {` `"self": {` `"href": "http://<pact broker address>/pacticipants/<Higher Level Consumer>"` `}` `}` `},` `"provider": {` `"name": "<Consumer>",` `"version": null,` `"_links": {` `"self": {` `"href": "http://<pact broker address>/pacticipants/<Consumer>"` `}` `}` `},` `"pact": {` `"createdAt": "2019-12-03T14:52:27+00:00",` `"_links": {` `"self": {` `"href": "http://<pact broker address>/pacts/provider/<Consumer>/consumer/<Higher Level Consumer>/version/<Higher Level Consumer Version>"` `}` `}` `},` `"verificationResult": null` `}` `]` `}`

michael.donkhin
2019-12-15 09:21
One moment, I'll try the CLI

michael.donkhin
2019-12-15 09:31
I get the same result from the CLI

michael.donkhin
2019-12-15 09:35
And here are the conflicting versions of the pact, as I understand:

michael.donkhin
2019-12-15 09:36
The second line is the version of the provider that has a changed contract

bethskurrie
2019-12-15 09:36
I don't see a tag on the provider version

michael.donkhin
2019-12-15 09:37
you are right...

bethskurrie
2019-12-15 09:37
You've got a consumer with a master tag, but that version has not been verified by a version of the provider with a master tag.

bethskurrie
2019-12-15 09:37
What lib are you doing the provider verification with?

bethskurrie
2019-12-15 09:38
Provider tagging has only been recently added to all the libs. You may need to upgrade to the latest Pact version.

michael.donkhin
2019-12-15 09:40
it's pact for .Net, and I all the other providers tagged, this is the only one that isn't

bethskurrie
2019-12-15 09:41
Strange

michael.donkhin
2019-12-15 09:41
probably some bug in the build pipeline

bethskurrie
2019-12-15 09:41
Is it possible that's one an old version?

bethskurrie
2019-12-15 09:41
Hm, but it would blow up if it got args it didn't recognise.

michael.donkhin
2019-12-15 10:05
It's a problem in my configuration, I see that the tagged versions of providers are for those services that are consumers by themselves

michael.donkhin
2019-12-15 10:08
So I have implicit provider tags for consumers, but no tags at all for providers

michael.donkhin
2019-12-15 10:09
Another question, if I may: the verification above will still fail because of the 'upstream' consumer, should the new 'pending pact' feature solve this?

bethskurrie
2019-12-15 19:07
@michael.donkhin the verification will still fail, and you won't be able to deploy, but it won't break the provider's build.

bethskurrie
2019-12-15 19:07
It depends what you mean by "solve".

michael.donkhin
2019-12-16 07:48
Well, I guess we'll need to figure out how exactly we'd like to integrate contract tests in our pipeline...

michael.donkhin
2019-12-16 07:49
Thanks a lot for your help! Appreciate it very much!

bethskurrie
2019-12-16 08:03
You're welcome @michael.donkhin

michael.donkhin
2019-12-16 08:22
Sorry, one more question: is there an API allowing to retrieve the 'reason' for can-i-deploy failure in a structured manner, instead of a text? I mean - the matrix provides information about existing contracts, but not about absent ones, so I would like to somehow filter the reasons based on the matrix and decide which are relevant for me and which are not. For example, if there is an unverified contract with a consumer, but two more 'non-existent' verifications with downstream providers, I would like to evaluate the number of unverified vs. number of non-existent contracts which comprise the overall number of failure reasons.

michael.donkhin
2019-12-16 08:22
Is matrix structure good enough for that?

bethskurrie
2019-12-16 08:49
No. Can you explain what you're trying to achieve?

bethskurrie
2019-12-16 08:53
Actually, yes, I think it is.

bethskurrie
2019-12-16 08:53
In the summary.

bethskurrie
2019-12-16 08:54
Have a look at the json. It has a count for missing, failed, and succeeded.

michael.donkhin
2019-12-16 09:40
Yes, but in the example above, there are two 'unknowns' where one of the is from 'higher level' consumer, while another doesn't exist at all. That's the number which meaning I'd like to understand more when I read the file. Currently I don't see any option except going over the matrix and subtracting the number of 'unknown' verifications in matrix from the overall 'unknowns'. Which still doesn't provide me with a definitive answer what is absent, except by looking at 'reasons'.

bethskurrie
2019-12-16 09:41
You sound like you're trying to do something unusual. What are you trying to achieve?


nerea.tamayo
2019-12-16 10:39
has joined #general

michael.donkhin
2019-12-16 14:27
:slightly_smiling_face: I'm trying to implement my own logic of parsing the results of can-i-deploy call and decide if I can deploy a given service builds based only on its providers' verification outcome, not consumers'.

christian.johann.eder
2019-12-16 15:39
I've got a question regarding these test cases for the V2 specification: https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/request/body/missing%20body.json https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/request/body/missing%20body%20no%20content%20type.json Don't these test cases break Postel's Law? They expect the *requests* to match although the actual requests contain a bofy and the expected request doesn't. Did I get the philosophy wrong?

christian.johann.eder
2019-12-16 15:49
And another one that I'm curious about: https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/response/body/unexpected%20index%20with%20not%20null%20value.json Shouldn't this be allowed (match the expected response) since the actual response is only sending *additional* data back to the consumer that the consumer didnt expect?

greig.baird
2019-12-16 16:51
has joined #general

bheemreddy181
2019-12-16 19:42
Do we have to really set a port for each provider mock server we are creating on the consumer side? Can we handle this internally to pick any port which is available on that environment ?

uglyog
2019-12-16 21:18
That exactly how the robustness principle (aka Postel?s law) works. We ignore the additional fields, being liberal in what we receive.

christian.johann.eder
2019-12-16 21:38
Then why does the test case (in my last link, so the response test case) say match: false? I would expect it to say match:true And: the first two links are links to request test cases.

christian.johann.eder
2019-12-16 21:40
I interpreted the test case files to be read as: this *actual* request (or response, depending on the folder of the test case) *matches* the *expected*

bethskurrie
2019-12-16 22:44
Why is that @michael.donkhin?

bethskurrie
2019-12-16 22:57
@bheemreddy181 it depends which implementation

bethskurrie
2019-12-16 22:57
Best to ask in the relevant channel.

bheemreddy181
2019-12-16 23:05
I did put it in #pact-ruby

michael.donkhin
2019-12-17 09:47
More like management requirements

bethskurrie
2019-12-17 09:48
So, providers are allowed to break consumers, but consumers must work with providers?

michael.donkhin
2019-12-17 09:49
Something like: providers can be moved to the master branch even if they do not implement the consumer requirements yet

bethskurrie
2019-12-17 09:51
Have you read the pending pacts blog post yet?

michael.donkhin
2019-12-17 09:57
Yes, I read it. However, I don't believe the implementation is already done for the .Net version

bethskurrie
2019-12-17 09:57
It can be quite easily if it's not

bethskurrie
2019-12-17 09:57
it's just an upgrade to the latest version of the underlying lib.

michael.donkhin
2019-12-17 09:58
any example of existing implementation? maybe I'll submit a pull request


bethskurrie
2019-12-17 09:58
I'm sure neil would love a PR.

bethskurrie
2019-12-17 09:59
However, I'm not sure if it will fix your workflow, because it won't change the can-i-deploy results, it will just ensure that your provider build can't be broken by unimplemented requirements added by a consumer.

michael.donkhin
2019-12-17 10:22
What I want to achieve is block merging of customers into the master branch until there are matching providers, which requires (as I understand) to run can-i-deploy on feature branches against 'master'. Successful build is a prerequisite for PR in our environment. But this will also block the hybrid consumer-provider services because they will block themselves.

bethskurrie
2019-12-17 10:23
so, you can just provide the explict names.

bethskurrie
2019-12-17 10:23
If you are a consumer, you know your providers.

bethskurrie
2019-12-17 10:24
if you give the names explicitly, it will ignore all the other dependencies.

michael.donkhin
2019-12-17 10:24
do you mean - for can-i-deploy calls?

bethskurrie
2019-12-17 10:24
yes


bethskurrie
2019-12-17 10:24
oh, sorry, not that

michael.donkhin
2019-12-17 10:24
yes


michael.donkhin
2019-12-17 10:26
this one is new for me, let me see

michael.donkhin
2019-12-17 10:27
does it use the can-i-deploy endpoint behind the scenes?

bethskurrie
2019-12-17 10:28
No, it uses the matrix endpoint, which is more complex.

michael.donkhin
2019-12-17 10:28
I ask it because currently I cannot integrate the CLI inside the build

bethskurrie
2019-12-17 10:28
You can call the endpoint directly though - the params are just a bit more complex

michael.donkhin
2019-12-17 10:29
the matrix endpoint?

bethskurrie
2019-12-17 10:29
make the query you want using the CLI, turn on verbose, and then copy the URL that it makes.

michael.donkhin
2019-12-17 10:29
OK, thanks fro your time, I'll check it

bethskurrie
2019-12-17 10:29
Yes, to the matrix endpoint. the can-i-deploy endpoint is a simplified version of the matrix, which only accepts the simplest format (consumer, version, to tag)

bethskurrie
2019-12-17 10:30
I will eventually get round to making the can-i-deploy endpoint support the multiple provider format.

khoatran
2019-12-18 00:58
Hi Bernard, sorry for the late reply. Please find below the step function diagram

khoatran
2019-12-18 00:58
I'm after testing the signature of the 'SendMessage' step

loveshjain88
2019-12-18 01:52
has joined #general

loveshjain88
2019-12-18 01:54
Hi All, I am using Pact JVM and trying to add header for every request when provider verifies it I added @TargetRequestFilter according to https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-junit#modifying-the-requests-before-they-are-sent-version-323245 but it is not getting called?

christian.johann.eder
2019-12-18 09:05
anyone who can explain to me how the test case files are to be interpreted, if not the way I did? And if I did it right, why the test cases seem to neglect Postel's law, or what I am interpreting wrong? @matt.fellows or @bethskurrie (since you seem to also have worked on the spec testcases)?

bethskurrie
2019-12-18 09:05
Hi Christian. Are you writing a new pact implementation?

christian.johann.eder
2019-12-18 09:06
I was rolling my own for a customer project that wasnt using JSON over HTTP, and am trying to make it PACT compliant.

christian.johann.eder
2019-12-18 09:06
So, yes

bethskurrie
2019-12-18 09:07
Interesting. What protocol?

christian.johann.eder
2019-12-18 09:07
We are using protobuf serialized payload over a TCP-ish peer to peer protocol

bethskurrie
2019-12-18 09:08
Have you been part of the protobuf channel conversations?

bethskurrie
2019-12-18 09:09
BTW, the first link, it fails because the actual request has more data in it than it should.

bethskurrie
2019-12-18 09:09
We are strict with what we send out, so unexpected data is not allowed.

christian.johann.eder
2019-12-18 09:09
yes, but those still wont help that project, since its still just related to HTTP APIs (but with protobuf bodies).

bethskurrie
2019-12-18 09:10
The test case is named in a misleading way. It should be "unexpected body".

christian.johann.eder
2019-12-18 09:10
I get the Postels law - what I dont get is why the Request test case I linked states that an *actual* request that contains a body should match an *expected* request without a body. To me, this seems like a violation of said Postels law

bethskurrie
2019-12-18 09:11
It does indeed.

christian.johann.eder
2019-12-18 09:12
As far as i interpret postels law, if a consumer doesnt state that he will send a body in the request (=expected), but then sends a body (=actual), those should NOT match

christian.johann.eder
2019-12-18 09:12
but the test case says "match: true"

bethskurrie
2019-12-18 09:12
Looks like a bug to me

christian.johann.eder
2019-12-18 09:12
Thanks ^^

christian.johann.eder
2019-12-18 09:12
I am not crazy

christian.johann.eder
2019-12-18 09:12
there are several of those test cases

christian.johann.eder
2019-12-18 09:13
also, the other way around: response test cases where an actual array contains more elements than expected. In my opinion, these should match. But the test case says they shoudl not

bethskurrie
2019-12-18 09:13
Probably got copy pasted. @uglyog am I also missing something?

christian.johann.eder
2019-12-18 09:14
I found at least something between 5-8 such test cases, would have to look up for more details

bethskurrie
2019-12-18 09:14
The array thing, they match if there is a matcher used to say, ignore array length.

bethskurrie
2019-12-18 09:14
I don't know how pact JVM passes then.

bethskurrie
2019-12-18 09:15
The first one looks fine to me though.

christian.johann.eder
2019-12-18 09:15
ah - ok, so for arrays (if no matcher is defined for the array length) the length has to be exactly the same, also for responses? I thought we should accept more data than expected here as well, similar to getting more properties than expected on an object.

christian.johann.eder
2019-12-18 09:15
which one do you mean?

bethskurrie
2019-12-18 09:15
It has to have a matcher.

christian.johann.eder
2019-12-18 09:16
k, ok, got the array thing

christian.johann.eder
2019-12-18 09:16
and regaridng the body test cases, do you think this one here is correct? https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/request/body/missing%20body.json

christian.johann.eder
2019-12-18 09:16
If so, please explain

bethskurrie
2019-12-18 09:16
In hindsight, there are things we would do differently, but unfortunately that's the way it made at the time, so they all have to work the same.

bethskurrie
2019-12-18 09:17
The missing body one is weird.

bethskurrie
2019-12-18 09:18
It might have been that that was a quirk of the original Ruby impl, and when the spec was retrofitted to match existing behaviour, that's what came out.

christian.johann.eder
2019-12-18 09:18
If you want to, i can link you all the test case files my implementation fails where I think the test case might be wrong. would that helpß

christian.johann.eder
2019-12-18 09:18
?

bethskurrie
2019-12-18 09:18
The thing is, even if they are wrong, all the impls will also be wrong together.

christian.johann.eder
2019-12-18 09:19
... meaning I would probably have to make my implementation wrong as well if i want to make it compatible :slightly_smiling_face:

bethskurrie
2019-12-18 09:19
You might need to choose between being spec compliant and being "right"

bethskurrie
2019-12-18 09:20
When it was first written, nobody knew it was going to turn into a Thing, so there are inconsistencies.

christian.johann.eder
2019-12-18 09:21
would be great if someone would confirm that indeed those testcases are purposefully "wrong" - or are you already sure on that?

christian.johann.eder
2019-12-18 09:36
But anyway thanks already for your insights!

christian.johann.eder
2019-12-18 09:37
I think I am going to give the users of my library the choice of being Pact compliant (this being the default) and "right"

christian.johann.eder
2019-12-18 16:02
I've got another question regarind this one here: https://github.com/pact-foundation/pact-specification/blob/version-2/testcases/response/body/objects%20in%20array%20type%20matching.json What exactly does a "type match" on an object mean? Does it mean that two objects are structurally the same, i.e. a deep check that they have the same properties with the same types?

paul.simms
2019-12-18 16:39
We are in the same situation. We are currently pushing to add pact tests to the new microservices, and yes it is far harder for us to add into the monolith. We have (almost) managed in a couple of key interfaces, but are handling most of them through other testing from the existing monolith (UI, RestAssured, Unit). Not ideal.

v.melnychuk12
2019-12-18 18:43
has joined #general

uglyog
2019-12-18 21:38
If the examples are wrong, we should fix them

bethskurrie
2019-12-18 22:10
@christian.johann.eder yes. It does a deep match to ensure the keys and types are the same.

rahul.singh2
2019-12-19 06:58
has joined #general

rahul.singh2
2019-12-19 07:00
Hi Guys, I am pretty new to PACT. Can someone please help me to setup PACT on my machine and how to write my first test?

matt.fellows
2019-12-19 07:02
Welcome! what have you tried so far? What language?

matt.fellows
2019-12-19 07:05
(btw it?s just Pact, not PACT. It?s not an acronym)

rahul.singh2
2019-12-19 07:08
I have read so many articles on google regarding Pact but didn't get any article which explains step by step procedure to install and setup the same. Any language would be fine to me, just want to start by installing it :slightly_smiling_face:

rahul.singh2
2019-12-19 07:08
will appreciate your help!



christian.johann.eder
2019-12-19 07:10
@uglyog as far as I understood Beth, the testcases / examples are not wrong as in "different from how Pact works". They are just wrong as in "break Postels Law".

christian.johann.eder
2019-12-19 07:10
@bethskurrie thanks!

rahul.singh2
2019-12-19 07:11
thanks! will go through and will ping for any questions if i will have :slightly_smiling_face:

richard.staehler
2019-12-19 17:36
has joined #general

c.talek
2019-12-19 18:43
Random questions, for teams using pact broker, do your project managers leverage the tool to determine version compatability matrix's ? This assumes you only leverage unit/contract testing and don't consider anything heavier beyond that

c.talek
2019-12-19 18:44
I assume for your runs you basically keep a constant running monolith that gets periodically upgraded to validate your pacts?

uglyog
2019-12-19 22:25
The tests are written with the context of the Pact mock server and verifier. When the mock server is matching a body, it will be strict. When the verifier is matching the response from the provider, it will be less strict. This follows the robustness principle from the perspective of the Pact framework, not in isolation.

antonello
2019-12-19 22:39
Not sure I follow...

matt.fellows
2019-12-20 01:05
Perhaps you?re alluding to the approach where various teams get together as part of an integration cycle and use this sort of matrix to determine which component is in what environment and what?s been tested?

christian.johann.eder
2019-12-20 13:23
Yes - if I understoof correctly, the tests in the "request" folder are written from the perspective of the Pact mock server, and the tests in the "response" folder in the perspective of the verifier - right? Nevertheless, I think that the inconsistencies as discussed with Beth still apply

c.talek
2019-12-20 14:39
Correct :point_up:

wesleythomaswilliams
2019-12-20 14:39
has joined #general

sumeshs572
2019-12-20 21:18
has joined #general

sumeshs572
2019-12-20 21:19
Hi all I am unable to find our pact cradle plugin dependency jar in any repository

matt.fellows
2019-12-21 00:08
Maybe try the #pact-jvm

matt.fellows
2019-12-21 00:08
Can you show the problem? Where are you searching for example

sumeshs572
2019-12-21 01:17
Sure I will let you know the details and also check the issues on pact-Jvm

taisedias
2019-12-22 21:50
has joined #general

ak.bhartiya
2019-12-23 13:19
has joined #general

plessmann
2019-12-23 14:25
has joined #general

vasile.pop
2019-12-23 14:42
has joined #general

ak.bhartiya
2019-12-23 18:29
Hi, i have been stuck with following situation.. Having api(/user) support 2 operation. 1. with post method creates a new user and return status code 200, and Created user id 2. With get method /user/{user-id} return user details How its possible to write contract test for both operation. How can i use user-id created with post method in get method.

matt.fellows
2019-12-23 22:08
@ak.bhartiya Each Pact test runs in isolation from every other test (i.e. it?s stateless in that sense). > How its possible to write contract test for both operation. How can i use user-id created with post method in get method You don?t do it this way in Pact. You simply have 2 tests, one for each scenario (the post and the get). Look up provider states to understand this further.

matt.fellows
2019-12-23 22:08
Just so we?re clear, what you want to cover is a totally normal use case, it?s just that you do it differently with Pact.

shilpa3006
2019-12-24 04:34
has joined #general

kbsachin01
2019-12-24 18:07
has joined #general

bethskurrie
2019-12-24 19:33
Yes, that's right.

sayboras
2019-12-28 00:32
has joined #general

sridevi_akshayapatra2
2019-12-30 01:14
has joined #general

sridevi_akshayapatra2
2019-12-30 02:15
Hi, I have a question regarding the PACT test for PUT method

sridevi_akshayapatra2
2019-12-30 02:15
I have to write a PACT test for PUT request method which has a path param, do I need to add any path param in the JSON file

sridevi_akshayapatra2
2019-12-30 02:16
Its throwing me assertion error saying expected status 200 and actual status 405

matt.fellows
2019-12-30 02:16
You absolutely need to include path params in the contract

sridevi_akshayapatra2
2019-12-30 02:17
Can you please assist me on how to add the path param

matt.fellows
2019-12-30 02:19
What language? And what have you tried?

matt.fellows
2019-12-30 02:19
We are talking about query strings yes?

sridevi_akshayapatra2
2019-12-30 02:21
Its Java and I am using JSON file for the request and response, in the JAVA test file i have used the annotation @PactFolder to include the Json file

sridevi_akshayapatra2
2019-12-30 02:21
In JSON i have added the consumer provider request response etc,

matt.fellows
2019-12-30 02:21
Have a look at the docs and see if there is anything related to query or path params

sridevi_akshayapatra2
2019-12-30 02:23
Do you want me to check here https://docs.pact.io/


matt.fellows
2019-12-30 02:24
You want the docs for Java don't you? It's all on the GitHub repository

sridevi_akshayapatra2
2019-12-30 02:26
Thanks will check

sridevi_akshayapatra2
2019-12-30 03:02
Hi, I am unable to figure out on how to add the path param even after going through the above mentioned link

sridevi_akshayapatra2
2019-12-30 03:02
My JSON has the following code

sridevi_akshayapatra2
2019-12-30 03:03
"request": { "method": "PUT", "path": /test/1234/testing", "headers": { "temp": "111", "Accept": "application/json", "Content-Type": "application/json" },

sridevi_akshayapatra2
2019-12-30 03:03
In the path, 1234 is the path param

sridevi_akshayapatra2
2019-12-30 03:03
how can I use matchPath for this

matt.fellows
2019-12-30 03:06
You might be better off asking this in the #pact-jvm channel

matt.fellows
2019-12-30 03:07
Also, show the code not the json file, and the actual errors you are getting

sridevi_akshayapatra2
2019-12-30 03:09
I can't show the code as it is confidential

matt.fellows
2019-12-30 03:10
Then all I can point you too are docs

matt.fellows
2019-12-30 03:10
How can I help correct if I can't know what you're doing?

matt.fellows
2019-12-30 03:11
Could you try creating an example with the problem that isn't confidential?

sridevi_akshayapatra2
2019-12-30 03:11
anyway the error i am getting is java.lang.AssertionError: 0 - Expected a response type of 'application/json' but the actual type was 'text/plain' 1 - assert expectedStatus == actualStatus | | | 200 | 405 false 2 - Expected a header 'Content-Type' but was missing

sridevi_akshayapatra2
2019-12-30 03:11
sure I can try creating an example

sridevi_akshayapatra2
2019-12-30 03:12
My main question is can we write pact for PUT method also, for me its working fine for POST and DEETE methods

matt.fellows
2019-12-30 03:13
Its the same for all. It's more likely your test case isn't actually making the request you told it to (i.e. a put to the path you registered)

sridevi_akshayapatra2
2019-12-30 03:16
I have 3 endpoints, the only difference is the POST and DELETE endpoints are straight forward but the PUT endpoint has a path param in the URI

matt.fellows
2019-12-30 03:17
Is this consumer or provider side?

matt.fellows
2019-12-30 03:18
If provider side, 405 is method not allowed. So it suggests your provider doesn't allow a PUT on that path (or at all)

sridevi_akshayapatra2
2019-12-30 03:20
Provider side

sridevi_akshayapatra2
2019-12-30 03:22
Its a PUT endpoint

sridevi_akshayapatra2
2019-12-30 03:22
could you please tell me what do you mean by provider doesn't allow a PUT on the path

matt.fellows
2019-12-30 03:28
We'll Pact will make a request to the path you have in that pact file. If your provider doesn't allow a PUT that's the HTTP response code I'd expect to see

matt.fellows
2019-12-30 03:28
Does your provider allow a PUT to that path?

sridevi_akshayapatra2
2019-12-30 03:31
yes it is allowing

sridevi_akshayapatra2
2019-12-30 03:31
our endpoint is consumed by othere services too

matt.fellows
2019-12-30 03:37
Did you delete your previous post? In any case, you need to investigate why your provider is not returning a 200 on that path. It's returning a 405 Without detailed logs and evidence that endpoint is responding to a request with that exact path I'm not sure how much I can help you

sridevi_akshayapatra2
2019-12-30 03:39
I didnt delete any of my posts

sridevi_akshayapatra2
2019-12-30 03:40
Here is the stacktrace I can provide you with

sridevi_akshayapatra2
2019-12-30 03:40
java.lang.AssertionError: 0 - Expected a response type of 'application/json' but the actual type was 'text/plain' 1 - assert expectedStatus == actualStatus | | | 200 | 405 false 2 - Expected a header 'Content-Type' but was missing at au.com.dius.pact.provider.junit.target.BaseTarget.getAssertionError(BaseTarget.java:90) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.java:125) at http://au.com.dius.pact.provider.junit.InteractionRunner$2.evaluate(InteractionRunner.java:236) at http://au.com.dius.pact.provider.junit.RunStateChanges.evaluate(RunStateChanges.java:31) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.java:168) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:123) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:51) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

matt.fellows
2019-12-30 03:46
Thanks. The error is clear to me

sridevi_akshayapatra2
2019-12-30 03:46
Really

matt.fellows
2019-12-30 03:46
Yes

matt.fellows
2019-12-30 03:47
It's what I explained earlier. Maybe try a request to that endpoint not using Pact and see how it responds

matt.fellows
2019-12-30 03:48
Also, can you enable debug logs to see the request/ response

sridevi_akshayapatra2
2019-12-30 03:49
Do you mean direct hitting the endpoint in postman

matt.fellows
2019-12-30 03:51
Yes, That could help.

matt.fellows
2019-12-30 03:51
Ideally from your junit test starting the server in the same way

matt.fellows
2019-12-30 03:52
Something like rest assured or just with a simple HTTP client and long the request+ response

matt.fellows
2019-12-30 03:54
I have to run, but come back with some logs showing the request response and I'm sure someone will be able to help

sridevi_akshayapatra2
2019-12-30 03:56
ok sure....thanks for your help

sridevi_akshayapatra2
2019-12-30 04:12
I am getting 200 as response when i directly run the endpoint and JNUIT is also successful, only failing is while running PACT

sridevi_akshayapatra2
2019-12-30 04:12
If anyone has any solution please let me know...thanks in advance

matt.fellows
2019-12-30 04:25
Can you please show the request / response for the working hand failed examples?

sridevi_akshayapatra2
2019-12-30 13:58
Hello

sridevi_akshayapatra2
2019-12-30 14:53
Request is - { "acc1": ["111"], "acc2": ["222"], "acc3": ["333"], "version": "V10" } Response is - Status Code: 200 Message - Updated Successfully

sridevi_akshayapatra2
2019-12-30 14:53
Is this what you are asking me

matt.fellows
2019-12-31 02:38
I need the full path, method etx

matt.fellows
2019-12-31 02:39
I'd like to compare the request Pact makes to your server and the response, against what you sent to the server and it's response so we can compare

matt.fellows
2019-12-31 02:39
So the full http request and response

knkarthik20
2019-12-31 09:53
has joined #general

anshu1987
2019-12-31 10:22
has joined #general

uwe.regenhardt
2020-01-02 15:02
has joined #general

brent_jackson
2020-01-02 21:31
has joined #general

swaroopshere
2020-01-03 00:32
hello! im wondering if there is support for 'valueFromProviderState' usage in pact-jvm-consumer-java8 library? I am trying to define a json body in a POST request that takes certain string values dynamically

tjones
2020-01-03 00:33
Might be best to ask in #pact-jvm

tjones
2020-01-03 00:33
Oh, I see you already did. Sorry!

swaroopshere
2020-01-03 00:34
thank you for your response Tim, yeah i did post it on that channel, I will further clarify my question there :slightly_smiling_face:

gerrymcgovern
2020-01-03 15:49
Hi Guys ? I am attempting to create some pact tests for a service that consumes messages from a message queue. Would I be correct in thinking that for services like this setting up provider states is not a concern? My thinking is that unlike http services where you have a consumer and a provider, for services that consume messages from a queue you really only need to worry about testing how the services handles the message. Is this correct?

stein
2020-01-03 15:54
I guess if you have a service writing to the queue and another service reading from the queue you essentially have a consumer/provider relationship. So you could take the normal approach and model it that way - that?s what I?ve done in the past for message queues.

iaroslav.liashenko
2020-01-03 16:04
has joined #general

gerrymcgovern
2020-01-03 16:36
my thought was to put the sample messages that correspond to different scenarios I wish to test directly onto the message queue, (not using a service) so that the tests are easier to setup, no dependancy on an actual provider.

marcelo.emmerich
2020-01-03 22:16
has joined #general

marcelo.emmerich
2020-01-03 22:20
Hi Guys, I created a consumer pact for a Vue application, and am now trying to verify it with a MessageProviderPact that locally invokes the handler of a lambda function. When I try to verify the pact, I get the following error: no handler found for message undefined. Is it even possible to have the consumer be a http pact and the provider be a message pact?

stein
2020-01-03 23:27
I guess it?d be easier to setup, but what?s the point of using pact if both the provider and consumer aren?t verified from the same contract?

marcelo.emmerich
2020-01-04 11:49
nevermind, just wired a jasmine http mock around the lambda code and refactored the pact to be a http one and now it works

matt.fellows
2020-01-04 12:22
How does the lambda get invoked - via API gateway or direct (i.e. using the AWS SDK invoke operation)?

matt.fellows
2020-01-04 12:22
If the former, then it should be an HTTP pact. If the latter, a message pact.

matt.fellows
2020-01-04 12:23
You can't mix the two, or rather you probably shouldn't

marcelo.emmerich
2020-01-04 22:20
Thanks @matt.fellows. I actually have both types of lambdas, so I ended up writing http pacts for the api gateway ones and message pacts for the rest.

animesh.sahai08
2020-01-05 11:05
has joined #general

wliao
2020-01-06 00:00
has joined #general

prabhuramchennai
2020-01-06 16:55
There is a team which wants to switch from Spring cloud to PACT. Is there any migration library or project available?

matt.fellows
2020-01-06 21:06
Mmm not that I'm aware of. Why the move out of interest?

matt.fellows
2020-01-06 21:07
Tho being said. You can integrate SCC into the Pact broker which is therefore compatible with Pact. So you could slowly migrate over and technically have one side in SCC and the other in Pact

prabhuramchennai
2020-01-06 21:12
Change, as they more teams with different technologies are coming in...

prabhuramchennai
2020-01-06 21:14
Even if integrated through broker, starting point of SCC is to create the groovy file which creates the stub and Junit... but in PACT a piece of code creates the pact JSON... the approaches being different, what will be the center piece which binds PACT & SCC together? it cannot be contract file of the code which creates them, that's where the problem is.

matt.fellows
2020-01-06 21:55
The consumer team creates the pact file and the provider verifies it. So if the consumer was a SCC project it would publish to the broker and you could perform Pact verification on that (or vice versa). The groovy contract is serialised to JSON in pact format during publishing (I'm not across the details of how SCC does that tho)

matt.fellows
2020-01-06 21:55
So the pact file is the artifact we care about

bethskurrie
2020-01-07 04:11
Pop quiz. Has anyone every wondered why can-i-deploy has "Computer says yes/no" in the output?

matt.fellows
2020-01-07 04:13
I always assumed it was a tribute of sorts to Little Britain

bethskurrie
2020-01-07 04:13
Yes it is. But we have a very international audience, and I wondered how many people had actually heard of Little Britain!

david.wang3
2020-01-07 20:06
has joined #general

david.wang3
2020-01-07 20:08
can somebody show me how to set the tag when pushing a pact to the pact broker?

david.wang3
2020-01-07 20:09
i don?t see a tag parameter in the PUT api


david.wang3
2020-01-07 20:19
i?m using the python pact library by the way

matt.fellows
2020-01-07 21:23
See https://docs.pact.io/pact_broker/advanced_topics/using_tags in our docs (hint: something like PUT to this resource`/pacticipants/Foo/versions/2.3.0/tags/prod` )


david.wang3
2020-01-07 21:32
awesome great thanks!

franklin.huynh
2020-01-07 23:58
Hi team, I have a question regarding to consumer test. Should we include authentication header in the request such as X-Token? I have a feeling we should but would love to hear from you guys opinion.


franklin.huynh
2020-01-08 00:19
perfect. Thanks

matt.fellows
2020-01-08 01:27
Generally the answer is yes, but worth understanding the trade offs

franklin.huynh
2020-01-08 02:29
thanks for your answers. fyi I discussed with our dev and we agree to include them a bit of context > Perhaps handling the auth error cases in the Pact, and then bypass auth for the success cases would be easiest. > I?m specifically thinking about where there are extra auth behaviours than standard Authorization Header/Bearer token > (disclaimer: I forgot to mention these are for cases when they are non-standard - so not just 401/403)

matt.fellows
2020-01-08 02:40
That is reasonable

matt.fellows
2020-01-08 02:41
sometimes it?s too hard to actually do the validation/authentication, but if you can verify that the tokens are present and well formatted, that is good enough (assuming of course that you have a separate way of testing that autha/authz are properly covered)

matt.fellows
2020-01-08 02:42
FWIW the Golang workshop that we have uses this approach (see https://github.com/pact-foundation/pact-workshop-go/blob/master/provider/user_service_test.go#L48-L56 and the corresponding README)

franklin.huynh
2020-01-08 02:49
noted. Thanks for the sharing

kevin.meiresonne
2020-01-08 07:55
Goodmorning, Does anyone know if it's valuable/possible to create contracts using Pact for push notification-style interactions, where the server asynchronously pushes content to connected clients (e.g. SignalR)?

kevin.meiresonne
2020-01-08 08:06
Also, what is the current state of the Pact Specification Version 3.0?

bethskurrie
2020-01-08 08:31
V3 is implemented for JVM and rust. People keep volunteering to do Ruby, but then getting scared off.

bethskurrie
2020-01-08 08:31
You've seen message pact right?

bethskurrie
2020-01-08 08:31
You basically just right the pact for the message and ignore the protocol.

chen1055
2020-01-08 11:15
has joined #general

chen1055
2020-01-08 11:21
Hi guys Im working with `pact-jvm` with maven. Im wondering is it mandatory to start the provider before verifying the provider against the relevant consumer? is there a workaround for this? this is the part of the `pact-jvm-provider-maven` pom i am using: ```<plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.4</version> <executions> <execution> <id>some id</id> <phase>verify</phase> <goals> <goal>verify</goal> </goals> </execution> </executions> <configuration> <? some configs ?> </configuration> </plugin>```

chen1055
2020-01-08 11:25
the issue is that without the plugin pact testing work with the httptarget as localhost, the provider is started when the tests requires it to. but it stops working when the plugin is added to the pom.

wesleythomaswilliams
2020-01-08 12:00
I'm really new to this so take this with a pinch of salt, but my pom looks like: ``` <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.4</version> <configuration> </configuration> </plugin>```

chen1055
2020-01-08 14:35
the thing is i think i need the pact to run on verify since i am populating some configuration based on properties generated by another plugin

kevin.meiresonne
2020-01-08 15:10
yeah


david.wang3
2020-01-08 21:12
can somebody help me with this particular use case. On the provider side, I?m using swagger mock validator to validate the pact files that I?ve downloaded for a particular consumer. This means that I don?t really need to have my provider service up and running and have the pact broker feed it the requests using pact-provider-verifier. How can I send verification results to the pact broker with this method?

bethskurrie
2020-01-08 21:13
You'll need to call the api directly.

david.wang3
2020-01-08 21:14
can u provide the api? I?m using the hal browser on the pact-broker, but I don?t know what the endpoint is

bethskurrie
2020-01-08 21:14
Yup, just finding the docs


david.wang3
2020-01-08 21:16
can u provide an example? what exactly is the endpoint here? Its not clear from the docs

david.wang3
2020-01-08 21:24
i don?t understand what this means? `pb:publish-verification-results` link (`$[?_links?][?pb:publish-verification-results?][?href?]`)

david.wang3
2020-01-08 21:24
is this ruby syntax? I?m not familar with ruby.

matt.fellows
2020-01-08 21:28
Yep, I?d use that as a basis. Message Pact is also supported in JS/Go


david.wang3
2020-01-08 21:29
I?m doing a contract test POC for my company. If upper management can be convinced to roll out contract testing. We could potentially use the pact broker SAS. Any help would be greatly appreciated! :slightly_smiling_face:

david.wang3
2020-01-08 22:07
ok i found some code here

david.wang3
2020-01-08 22:07
describe ?verification_publication_url? do context ?with no metadata? do subject { PactBrokerUrls.verification_publication_url(verification, base_url) } it { http://is_expected.to match_route_in_api(PactBroker::API) } it { http://is_expected.to eq ?http://example.org/pacts/provider/Bar%2FBar/consumer/Foo%2FFoo/pact-version/1234/metadata//verification-results? } end context ?with metadata? do subject { PactBrokerUrls.verification_publication_url(verification, base_url, ?abcd?) } it { http://is_expected.to match_route_in_api(PactBroker::API) } it { http://is_expected.to eq ?http://example.org/pacts/provider/Bar%2FBar/consumer/Foo%2FFoo/pact-version/1234/metadata/abcd/verification-results? } end end

david.wang3
2020-01-08 22:07
what is pact-version? is tha the consumer version? what is metadata abcd?


bethskurrie
2020-01-08 22:58
Don't look at what's in the URL

bethskurrie
2020-01-08 22:58
Just use it

bethskurrie
2020-01-08 23:00
You can't compose it. You have to get the pact, and then look up the verification url from it.

david.wang3
2020-01-08 23:00
yeah? I finally figured it out

david.wang3
2020-01-08 23:00
i was looking at the response from the GET and it had all the links

david.wang3
2020-01-08 23:01
how do I add the tag to the provider version when I publish the verification results

bethskurrie
2020-01-08 23:01
Look at the pact broker wiki. There's a page on using tags.

david.wang3
2020-01-08 23:02
those links basically tell you to use the provider library. It doesn?t tell you how to do it through the rest api

david.wang3
2020-01-08 23:02
When publishing verification results Your Pact provider library will allow you to set the ?provider version tags? that will be set for the relevant provider version when you publish your verification results. The recommended tag value to use is the name of your git branch, if applicable, or `dev`, if not.

bethskurrie
2020-01-08 23:02
In answer to your question about the pact version, it's the pact version :joy: behind the scenes, the broker versions the content for you.

bethskurrie
2020-01-08 23:03
There's a section that explains the urls

bethskurrie
2020-01-08 23:03
Keep going

bethskurrie
2020-01-08 23:04
"As an example, to tag Foo application version b5236e772 as the production version, do a PUT to the resource /pacticipants/Foo/versions/b5236e772/tags/prod. All the pacts and verifications associated with Foo version b5236e772 are now considered to be the production pacts/verifications. The latest production pact for provider Bar can be retrieved from /pacts/provider/Bar/consumer/Foo/latest/prod."

david.wang3
2020-01-08 23:05
so i have to call a sperate tag API after I publish the verficiation results?

bethskurrie
2020-01-08 23:06
Yes

david.wang3
2020-01-08 23:06
oik i thought i could just append the tag to the publish-verification results endpoint

bethskurrie
2020-01-08 23:06
If I was designing the api with the experience I have now, it would be all together. But you live and learn.

bethskurrie
2020-01-08 23:07
"Note that the tag is actually placed on the pacticipant version resource, not the pact itself (conceptually, you are indicating that that particular version of the application is a "prod" version, or a "feature-xyz" version). The URL structures, however, then allow you to retrieve pacts by the tags on their associated versions."

bethskurrie
2020-01-08 23:07
The tag doesn't belong to the verification result. It belongs to the pacticipant version resource.

bethskurrie
2020-01-08 23:08
Give that page a good read. It should make things clear.

david.wang3
2020-01-08 23:12
awesome.. got it working..

david.wang3
2020-01-08 23:12
thanks!

bethskurrie
2020-01-08 23:29
np

akkoubak
2020-01-09 00:13
@matt.fellows I am having trouble creating a PACT for a particular request using the .Net implementation of PACT. More specifically I am attempting to test a GraphQL POST request against a host server on this IP (http://52.188.176.147:4000). When running my dotnet test command, I am getting the following exception: ```System.Exception: 'There was a problem connecting to Provider API - {MYAPI}' - HttpRequestException: Response status code does not indicate success: 500 (Internal Server Error )``` I am able to successfully test my ConsumerAPIClient which contains the following code: ```using Newtonsoft.Json; using RA; using System; using System.Collections.Generic; using http://System.Net; using http://System.Net.Http; using http://System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace Consumer { public static class ConsumerApiClient { static public async Task<HttpResponseMessage> LocationQuery(string baseUri) { using (var client = new HttpClient { BaseAddress = new Uri(baseUri) }) { try { string json = JsonConvert.SerializeObject(new { query = "\n{\n locations {\n displayName\n }\n}" }); var content = new StringContent(json.ToString(), Encoding.UTF8, "application/json"); var response = await client.PostAsync($"{baseUri}", content); response.EnsureSuccessStatusCode(); return response; } catch (Exception ConnectionEx) { throw new Exception("There was a problem connecting to Provider API - LocationQuery.", ConnectionEx); } } } } }``` Here is my consumer test class: ``` using Xunit; using PactNet.Mocks.MockHttpService; using PactNet.Mocks.MockHttpService.Models; using Consumer; using System.Collections.Generic; using PactNet.Matchers; using RA; namespace tests { public class ConsumerPactTests : IClassFixture<ConsumerPactClassFixture> { private IMockProviderService _mockProviderService; private string _mockProviderServiceBaseUri; private int _mockProviderServiceBasePort; public ConsumerPactTests(ConsumerPactClassFixture fixture) { _mockProviderService = fixture.MockProviderService; _mockProviderService.ClearInteractions(); //NOTE: Clears any previously registered interactions before the test is run _mockProviderServiceBaseUri = fixture.MockProviderServiceBaseUri; // _mockProviderServiceBaseUri = "http://52.188.176.147:4000/"; } [Fact] public void LocationQuery() { // Arrange _mockProviderService.Given("There is no data") .UponReceiving("A valid POST request to validate location GraphQL") .With(new ProviderServiceRequest { Method = http://HttpVerb.Post, Path = "", //Query = "", Headers = new Dictionary<string, object> { { "Content-Type", "application/json" } }, Body = new { query = "\n{\n locations {\n displayName\n }\n}" } }) .WillRespondWith(new ProviderServiceResponse { Status = 200, Headers = new Dictionary<string, object> { { "Content-Type", "application/json; charset=utf-8" } }, Body = new { data = (new { locations = Match.MinType(new { displayName = "" }, 2) }) } }); // Act var result = ConsumerApiClient.LocationQuery(_mockProviderServiceBaseUri).GetAwaiter().GetResult(); var resultBodyText = result.Content.ReadAsStringAsync().GetAwaiter().GetResult().ToString(); ; // Assert Assert.Contains("data", resultBodyText); } } }``` I would appreciate your help on this issue.

bethskurrie
2020-01-09 00:58
Try asking in the pact-net channel. Matt isn't a maintainer of that lib.

akkoubak
2020-01-09 01:00
@bethskurrie My bad. I wasn't aware there was a dedicated channel for PactNet. Will post there. Thank you!

muppasaikarthik964
2020-01-09 09:26
has joined #general

bheemreddy181
2020-01-09 15:06
I want to hear some thoughts from folks here - As we are moving more towards contract testing do we completely eliminate Integrations tests from product side some times business or product folks want to see how things will appear for customers and we end up talking to micro services

wesleythomaswilliams
2020-01-09 15:24
Last Nov I joined a new company who had had unit, functional and E2E tests (they call them integration tests, but they're bigger than that). These E2E tests were really problematic for them and they asked me to look at solutions, hence contract testing. We're not ditching our E2E, but I want to reduce the amount as we build up our contract tests. For pure integration tests that literally focus on integrations between two micro-services, I may look to remove them entirely, but if you don't have E2E tests, I'd be tempted to add some at that point. I don't think there's a once size fits all solution for everyone though, but I'm still a firm believer in the testing pyramid.

david.wang3
2020-01-09 17:14
Are there is any sort of guidelines, documentation on how to use PACT with rabbitmq, kafka or any other type of event based messaging with python/java

alan.nichols
2020-01-09 17:29
Still new to this but your contracts will most likely be enforcing the correct type of result, String, Int etc. You will still need integration tests to ensure functionality works end to end or at an integration level.

david.wang3
2020-01-09 17:45
from what i can tell, messaging is supported with pactv3, but the python client only supports v2. can I use the standalone pact clients to support messaging for languages that only support pact v2?

bheemreddy181
2020-01-09 19:11
@alan.nichols I think we can still do functional testing between two services using contract testing but we shouldn?t be checking the boundaries , we should pick stable use cases for testing so

c.talek
2020-01-09 19:41
unit test for test your individual code (ex: junit, rest-assured) contract test your agreements between services (ex: pact) integration test your services working together (ex: postman) e2e test your services in the bigger picture (ex: postman, selenium) it really entirely depends on the foundation of your product and the ecosystem it runs in.. there are ways you can wiggle things around.. like asynchronous testing.. only running a select # of tests when doing commits vs pull requests vs pushing to prod..etc.. then amongst all of this testing for your feature, you'd have other quality gates.. ex: security/performance testing

bethskurrie
2020-01-09 22:26
@david.wang3 sorry, not yet :disappointed:

bethskurrie
2020-01-09 22:26
pactman might support messaging @richard.jones?

david.wang3
2020-01-09 22:56
I looked at pactman, but it only supports python 3 and unfortunately, we are only python 2.7.

bethskurrie
2020-01-09 22:57
Bummer.

bethskurrie
2020-01-09 22:57
So, the underlying ruby library actually supports the messaging part of v3, but not the new matchers.

bethskurrie
2020-01-09 22:57
it just needs someone to write the python wrapper part to support messaging.

david.wang3
2020-01-09 22:58
I was thinking of using this script for v3.


david.wang3
2020-01-09 23:00
but i?m not exactly sure how to get the mock service to send the message back to the test client

bethskurrie
2020-01-09 23:02
yeah, you'll need to have a look at how pact-js does it

bethskurrie
2020-01-09 23:03
which side are you looking at? consumer or provider?

david.wang3
2020-01-09 23:04
i?m looking at the consumer side for now.

david.wang3
2020-01-09 23:22
i looked at this example. and it looks like its retrieving the message from the mock service manually. i don?t think the mock service is actually sending anything to the test client.


david.wang3
2020-01-09 23:24
~i?m not sure what language this is. I think its nodejs, but i?m not familiar with that language either~

bethskurrie
2020-01-09 23:25
Sorry, I dont' have time to explain right now, but it basically makes a proxy to the http mock service.

bethskurrie
2020-01-09 23:25
if you want to make a time for us to discuss it I'm happy to explain it

david.wang3
2020-01-09 23:25
sure.. let me know when u are free? we can discuss


bethskurrie
2020-01-09 23:27
See if that helps.

bethskurrie
2020-01-09 23:27
Looks like you're 5 hours ahead of my timezone.

david.wang3
2020-01-09 23:31
i?m in California. PST

bethskurrie
2020-01-09 23:32
If you still have questions after working through the demo, then let me know and we'll work out a time.

matt.fellows
2020-01-09 23:33
I could walk you through it David, as I?ve done it for both JS and Go.

matt.fellows
2020-01-09 23:33
Have a read of the example above first and then we can chat

david.wang3
2020-01-09 23:34
cool? i go through the demo

david.wang3
2020-01-09 23:34
thx

matt.fellows
2020-01-09 23:34
The sequence diagrams and the link to https://gist.github.com/bethesque/c858e5c15649ae525ef0cc5264b8477c are probably the most insightful bits

david.wang3
2020-01-09 23:35
i gave a walkthrough of pact with my team using the rest api interface and the first thing they asked was if it supported events (rmq, kafka). So I wanted to get a real life implementation of that working for them.

matt.fellows
2020-01-09 23:35
Nice!

matt.fellows
2020-01-09 23:35
what was the general reaction?

bethskurrie
2020-01-09 23:35
It shouldn't be too much code - it's just a bit conceptually tricky to understand because we retrofitted it into our existing HTTP codebase.

david.wang3
2020-01-09 23:36
mixed? some people really liked it, but others were skeptical if it could actually replace/supplement integration tests.

david.wang3
2020-01-09 23:37
i?m personally convinced that contract tests is the way to go.

bethskurrie
2020-01-09 23:37
we should ask some people to write their stories

david.wang3
2020-01-09 23:38
we have all the ITs but they are so flakey and slow.. i hate them

bethskurrie
2020-01-09 23:39
Hey people. Is anyone interested in writing a blog post to feature on http://blog.pact.io talking about how Pact has helped reduce your reliance on integration tests (and hence, sped up your release cycle)?

bethskurrie
2020-01-09 23:39
It would really help new people who are sceptical of whether or not contract testing is a good idea or not.

matt.fellows
2020-01-09 23:40
If I had a $1 for every time I heard that?

david.wang3
2020-01-09 23:40
LOL

bethskurrie
2020-01-09 23:41
We'd have more money than we currently have in the Pact donations account...


bheemreddy181
2020-01-10 09:45
That?s what I mean when I said boundaries

bheemreddy181
2020-01-10 09:45
Contract tests are subset of functional tests

bheemreddy181
2020-01-10 09:46
Picking right use cases is very important for contract testing

bheemreddy181
2020-01-10 09:46
@alan.nichols ^

alan.nichols
2020-01-10 09:49
Agree with that for sure. To me it's a faster, cheaper way to catch some of the issues that functional tests would find, that also has the benefit of being run, monitored and maintained by the relevant team, rather than the client team catching these sort of problems. Very useful for things like apps that are consuming from APIs owned by many different teams.

rikeshgohil
2020-01-10 10:33
has joined #general

pavel.azarau
2020-01-10 22:24
Hey folks, I?ve got a Consumer CI workflow question. Will appreciate if you share how you handle such an issue. Given: we have consumers C1 and C2 and we have provider P1. P1 has contract tests related to C1 and C2. All the tests are configured with the following annotation: ```@PactBroker(host = "${pactbroker.host}", authentication = @PactBrokerAuth(token = "${pactbroker.auth.token}"), tags = "${pactbroker.tag}")``` When we raise a PR for C1 for a feature branch `Branch-1` our C1 CI job publishes contract with a tag Branch-1 and our web hook triggers P1 CI job passing the tag Branch-1 so that it is used to run P1 tests tags = ?${pactbroker.tag} (see provider tests annotation). So all the contract tests of P1 are run. And it?s fine for the tests which are related to C1 as we?ll be able to fetch the latests pacts with the tag Branch-1 (pacts/provider/P1/latest/branch-1). But the tests related to C2 will fail because there are no contracts related to C2 for such a tag/feature branch. One solution would be to use annotation @IgnoreNoPactsToVerify in C2 tests (and C1 tests accordingly). I wonder if there is another way? E.g. to pass the consumer via webhook call (${pactbroker.consumerName}) and then to execute only tests for that consumer? Thanks in advance!

pavel.azarau
2020-01-10 22:25
I?ll appreciate if anybody could point out docs where potential solution is described

bethskurrie
2020-01-11 01:45
Pavel this feature is coming soon, but is not currently supported that I know if in pact JVM

bethskurrie
2020-01-11 01:46
The upcoming feature will allow you to specify a fall back tag if the tag you're trying to get doesn't exist, for exactly this scenario

bethskurrie
2020-01-11 01:48
For builds triggered by webhooks, it's actually best to use the pact URL that you can get from the webhook body, so that you don't run all the verifications.

bethskurrie
2020-01-11 01:48
So you'd have a separate task that is just for webhooks, different from the one you run when your provider changes.


bethskurrie
2020-01-11 01:49
I'm actually not 100% sure if this is possible in Pact-JVM currently, as it's so annotation driven.

bethskurrie
2020-01-11 01:49
If it's not, can you raise it in the pact-jvm repository?

kevinkontcheu
2020-01-12 17:24
has joined #general

kevinkontcheu
2020-01-12 17:47
Hey Guy i'm new to pact and i have some questions. please can someone help me? I want to write the Tests on the consumer side( I habe a GET, a POST, and a PUT). How can i add many request type in the returned bilder??

kevinkontcheu
2020-01-12 17:48
``` @Pact(state = "a collection of 2 addresses", provider = "customerServiceProvider", consumer = "addressClient") public RequestResponsePact createAddressCollectionResourcePact(PactDslWithProvider builder) { return builder .given("a collection of 2 addresses") .uponReceiving("a request to the address collection resource") .path("/addresses/") .method("GET") .willRespondWith() .status(200) .body("...", "application/hal+json") .toPact(); }``` For example if i want to add a POST request here, do i need to just add a new .given .... and juste apply the toPact method at the end ?ß Thanks for the help

uglyog
2020-01-12 20:44
That?s correct. You can chain the interactions by adding another starting with .given

david.wang3
2020-01-12 23:21
question regarding the pact-message gem binary. does this internally spawn a mock-service instance and send the message pact file to mock-service. There?s not a whole lot of documentation on exactly what its doing.

david.wang3
2020-01-12 23:22
i see the the pact-go library uses it to support v3 message format

dlmiddlecote
2020-01-12 23:39
has joined #general

matt.fellows
2020-01-12 23:55
But you almost certainly don?t want to do a `GET` , `PUT` and a `POST` in the same interaction

matt.fellows
2020-01-12 23:55
Look at provider states

bethskurrie
2020-01-13 00:25
Yeah, sorry about that.

bethskurrie
2020-01-13 00:26
So, on the consumer side, there is no mock service.

bethskurrie
2020-01-13 00:27
The mock service is only used when there is a request/response. In the case of message pact, there's only a "response".

bethskurrie
2020-01-13 00:52
Welcome @dlmiddlecote

kevinkontcheu
2020-01-13 03:02
I don't want to have the request in the same interaction but in the same pact file at the end of my test. I also want to define one test for each request (GET, POST and PUT). please can you explain me more? have yoou some examples on how i can realise that? Thanks

uglyog
2020-01-13 03:22
If you use tests with the same provider and consumer names, they will be merged into the same pact file

david.wang3
2020-01-13 06:05
ok thanks.. I?m trying to add message support into pact python

bethskurrie
2020-01-13 06:23
Amazing stuff!

elliottmurray
2020-01-13 07:23
has joined #general

bethskurrie
2020-01-13 08:49
Hi @elliottmurray :wave::skin-tone-3:

pavel.azarau
2020-01-13 17:03
Thanks for the info! And it?s good to know about the upcoming feature. I?ll try to apply the suggested approach with pact URL and will raise the issue in case it?s not supported.

david.wang3
2020-01-13 17:28
is there a way to have pact-message update not overwrite an existing pact file? I have some rest test cases in addition to a message test case that is writing to the same pact json, but when I call pact-message to generate the json, it overwrites the existing pact file

david.wang3
2020-01-13 17:41
same thing with mock-service

david.wang3
2020-01-13 17:41
it deletes the existing pacfile before overwriting

david.wang3
2020-01-13 17:42
I suppose i can have seperate pact files for message and rest

david.wang3
2020-01-13 18:06
also, how does reify work. I ran it on the test_json and it gave me an error


david.wang3
2020-01-13 18:06
pact-message reify test_message.json Traceback (most recent call last): 10: from /usr/local/bin/pact-message:23:in `<main>' 9: from /usr/local/bin/pact-message:23:in `load? 8: from /var/lib/gems/2.5.0/gems/pact-message-0.6.0/bin/pact-message:3:in `<top (required)>' 7: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start? 6: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch? 5: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command? 4: from /var/lib/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run? 3: from /var/lib/gems/2.5.0/gems/pact-message-0.6.0/lib/pact/message/cli.rb:24:in `reify? 2: from /usr/lib/ruby/2.5.0/json/common.rb:335:in `load? 1: from /usr/lib/ruby/2.5.0/json/common.rb:156:in `parse? /usr/lib/ruby/2.5.0/json/common.rb:156:in `parse?: 765: unexpected token at ?test_message.json? (JSON::ParserError)

mokbat
2020-01-13 20:21
has joined #general

pavel.azarau
2020-01-13 21:21
If anybody is interested, I was able to solve my issue by using Maven plugin https://github.com/DiUS/pact-jvm/tree/master/provider/pact-jvm-provider-maven (instead of Junit) as a runner. There are few ways of filtering interactions. In my case `pact.filter.consumers` has worked out.

bethskurrie
2020-01-13 21:22
Did you work out if you could use the pact URL from the webhook to run the verification?

bethskurrie
2020-01-13 21:22
For example, if you've got the verification hardcoded to verify certain tags, and a consumer pushes a new tag, your verification won't run the actually changed pact.

pavel.azarau
2020-01-13 21:28
I haven?t found the way to use URL to a certain pact. It doesn?t mean there is no such a way though :slightly_smiling_face: I?m not sure I?m getting your example. In both cases (annotations or plugin) there is a possibility to parametrize tags. And if you do so, in case of plugin there are certain ways to filter interactions by parameters passed via web hook and in case of annotations the upcoming feature should solve the problem

bethskurrie
2020-01-14 00:06
Just had a chat with Ron and he said there isn't a way to give it just a URL

bethskurrie
2020-01-14 00:06
I'm raising an issue for it, but he's got so many other issues, it's not likely to get picked up any time soon. We'll need a volunteer!

pavel.azarau
2020-01-14 00:10
thanks! well, it?s not that urgent as it seems there is a way to support a workflow described in the best practices by filtering interactions

bethskurrie
2020-01-14 00:10
Can you specify the tag dynamically?

bethskurrie
2020-01-14 00:10
So, if the consumer makes a new tag, you can pick that up?

bethskurrie
2020-01-14 00:12
Btw, would you be able to do a write up the way you've configured this? We often have people asking how to configure the webhook builds in pact-jvm, so it needs some example docs or a blog post badly.

pavel.azarau
2020-01-14 00:29
If I use `pact-jvm-provider-maven` I can specify a tag dynamically if I use only ONE tag. In this case I can use system property ${sometag} and pass it from CI using -Dsometag. And I?m getting the value from web hook because it supports the list of dynamic variables (and among them ${pactbroker.consumerVersionTags} ). So when Consumer publishes new tag web hook is triggered and the tag vaue is passed to Provider pact verification CI job

bethskurrie
2020-01-14 00:29
that makes sense.

bethskurrie
2020-01-14 00:29
Would you write a post about it for http://blog.pact.io?

pavel.azarau
2020-01-14 00:29
I need to finish this thing and then I?ll try to find tome to describe the final solution :slightly_smiling_face:

bethskurrie
2020-01-14 00:30
That would be awesome :slightly_smiling_face:

florian845
2020-01-14 15:49
has joined #general

anupamknw
2020-01-14 19:11
I have very a weird question. Please try to digest. Who generally writes CDC test - QA or Dev? n Why? Or Who should write?

matt.fellows
2020-01-14 19:41
There?s no absolutes. But usually a dev, because the tests live alongside the code (just like unit tests)

matt.fellows
2020-01-15 03:05
From memory, the reify takes a JSON input (not a file name)

bethskurrie
2020-01-15 03:06
correct

bethskurrie
2020-01-15 03:07
> is there a way to have pact-message update not overwrite an existing pact file? It should update the file, that doesn't sound right

bethskurrie
2020-01-15 03:07
in fact, I thought there was an issue because it only ever updated, and you had to clear it manually at the beginning of a test run

bethskurrie
2020-01-15 03:08
The mock service does deliberately delete the file, as it's meant to be started at the start of a test suite, and stopped at the end

bethskurrie
2020-01-15 03:08
if you're stopping and starting multiple mock services for the same file, something is strange

bethskurrie
2020-01-15 03:09
Just checked the code and the pact file write mode for the update is hardcoded to ":update"

bethskurrie
2020-01-15 03:10
Can you provide me an executable example showing me your issue with it overwriting the file @david.wang3

bethskurrie
2020-01-15 03:11
> I suppose i can have seperate pact files for message and rest Oooh, yes, they can't go in the same file.

bethskurrie
2020-01-15 03:11
The spec and the code don't support that.

bethskurrie
2020-01-15 03:11
We may support it in later versions, but we have other higher priorities atm.

simone.cusimano92
2020-01-15 08:11
has joined #general

simone.cusimano92
2020-01-15 08:30
Hi everyone :wave:

alan.nichols
2020-01-15 16:47
Hi everyone. I have a test that is generating a PACT for a PUT request with some values in the body of the request. (iOS app using the ruby standalone server). When I have a look at the PACT that is generated, all that is captured is the method and the path. I'm not sire if I'm doing something wrong.... Any ideas?

shero86
2020-01-15 16:49
Hi , did you check the log file?

alan.nichols
2020-01-15 16:55
Sorry just looked at the test for the 25th time and realised that even though the api call has the values set up, they aren't described in the .withRequest() when we configure the mock server.

alan.nichols
2020-01-15 16:58
I had assumed that the pact mock server would capture the request and add it to the contract, rather than me manually configuring it.

davchung5
2020-01-15 22:40
has joined #general

swaroopshere
2020-01-16 01:05
Hello Pact folks, I wrote the following contract using pact-jvm-consumer-junit5 library, and wrote a consumer side test against it. I think I have written the contract to allow variations in header values as well as variations in request body. ```return builder .given("Initial State") .uponReceiving("first request") .path("/abc/pqd/rest/createObjects") .method("POST") .matchHeader(SSL_CLIENT_SUBJECT_HEADER, SUBJECT_HEADER_VALUE) .matchHeader(CIPHERSUITE_HEADER,CIPHERSUITE_HEADER_VALUE) .matchHeader("Connection",".*") .matchHeader("Host",".*") .matchHeader("User-agent",".*") .matchHeader("Content-length",".*") .headers(requestHeaders) .headerFromProviderState("organization", ORG_ID_EXP,"blah") .body( new PactDslJsonBody() .object("animal") .stringType("animalId") .valueFromProviderState("keyId", KEY_EXP,"animalIdValue") .stringType("animalType") .object("contextParamMap") .stringType("initiationMethod","inbound") .stringType("vendorKey","value2") .stringType("from","1234567890") .stringType("startTime","2019-12-02T17:32:28Z") .stringType("to","8002345678") .closeObject() .closeObject() .array("participants") .object() .numberType("joinedTimestamp") .stringType("app") .numberType("notificationDelay") .valueFromProviderState("subject", D_EXP,"stateValue") .stringType("context") .booleanType("returnResponse") .closeObject() .closeArray() ) .willRespondWith() .status(200) .matchHeader("Content-Type","text/json;charset=UTF-8") .toPact();```

swaroopshere
2020-01-16 01:05
However, I am running into errors while recognizing the request. It appears that there is a body mismatch since the c.d.p.c.m.PlainTextBodyMatcher likely invokes exact matcher? Am I writing the contract to be too specific?

swaroopshere
2020-01-16 01:05
Following are the debug log lines -

swaroopshere
2020-01-16 01:05
```15:36:21.885 [Thread-17 ] DEBUG [-,,] [,] DEBUG c.d.p.c.m.PlainTextBodyMatcher : No regex for '{"animal":{"animalId":"string","keyId":"animalIdValue","contextParamMap":{"initiationMethod":"inbound","vendorCallKey":"value2","from":"1234567890","startTime":"2019-12-02T17:32:28Z","to":"8002345678"},"channelType":"string"},"participants":[{"joinedTimestamp":100,"app":"string","notificationDelay":100,"role":"string","subject":"stateValue","context":"string","returnResponse":true}]}', using equality : DEBUG [-,,] [,] DEBUG a.c.d.p.c.m.RequestMatching : Request mismatch: [BodyMismatch(expected={"animal":{"animalId":"string","keyId":"animalIdValue","contextParamMap":{"initiationMethod":"inbound","vendorCallKey":"value2","from":"1234567890","startTime":"2019-12-02T17:32:28Z","to":"8002345678"},"channelType":"string"},"participants":[{"joinedTimestamp":100,"app":"string","notificationDelay":100,"role":"string","subject":"stateValue","context":"string","returnResponse":true}]}, actual={"animal":{"animalId":"62a5908d-4aed-43c9-9c4a-a827a5538af4","keyId":"animalIdValue","contextParamMap":{"initiationMethod":"inbound","vendorCallKey":"value2","from":"1234567890","startTime":"2019-12-02T17:32:28Z","to":"8002345678"},"channelType":"Phone"},"participants":[{"joinedTimestamp":1579131381380,"app":"PHONE","notificationDelay":10000,"role":"Role","subject":"stateValue","context":"Context","returnResponse":false}]}, using equality but did not match, path=/, diff=null)] :```

swaroopshere
2020-01-16 01:07
#pact-jvm

uglyog
2020-01-16 01:11
You've overridden the Content-Type header with no actual value, you need it to be set to `application/json` so the matcher knows to match it as a JSON body

uglyog
2020-01-16 01:12
Either remove `.matchHeader("Content-length",".*")` or set it to `.matchHeader("Content-length",".*", "application/json")`

swaroopshere
2020-01-16 01:54
thank you @uglyog for your response. I tried both suggestions, removing the matchHeader as well as setting `application/json` in Content-length but running into the same error. I do want to mention that the content-type header in our actual request is set to `text/plain`

swaroopshere
2020-01-16 01:54
i wonder if that makes a difference

uglyog
2020-01-16 01:57
Oh, sorry, my mistake. It should be the Content-Type header. You should not change the Content-Length header, that could cause problems

uglyog
2020-01-16 01:58
Make sure you are not overwriting it

swaroopshere
2020-01-16 02:05
ok I updated the contract with ```.matchHeader("Content-type",".*")``` so it should now accept whatever the client sends (which is `text/plain`) . Now I run into the following error ```Request mismatch: [BodyTypeMismatch(expected=????, actual=text/plain)] : ```

swaroopshere
2020-01-16 02:07
im also ensuring that there are no header overrides

uglyog
2020-01-16 02:08
Don't use match header for the content type, or at least give it a valid value for the third parameter

swaroopshere
2020-01-16 02:27
ok, I now did ` ```.matchHeader("Content-type","text/plain; charset=UTF-8")``` and that got rid of the intermediate header mismatch errors. However, I am back to the BodyMismatch exception from the first post on this thread

uglyog
2020-01-16 02:28
not `text/plain`, `application/json`

swaroopshere
2020-01-16 02:29
if i set `application/json` i run into the headerMismatch Exception unfortunately. The client that we use has been overridden to set the content-type header to `text/plain`

uglyog
2020-01-16 02:30
If you use a plain text header, then the matcher will always think it is plain text and not JSON, and your body will not be matched correctly

uglyog
2020-01-16 02:31
> The client that we use has been overridden to set the content-type header to `text/plain`

uglyog
2020-01-16 02:31
That is a really bad thing to do

swaroopshere
2020-01-16 02:31
i see

swaroopshere
2020-01-16 02:35
while I wait for someone to make that fix in the client, is there a way to override the body processing as `application/json`

swaroopshere
2020-01-16 02:35
without actually setting the Content-type header

uglyog
2020-01-16 02:36
Unfortunately not

swaroopshere
2020-01-16 02:46
Got it. Thank you for all your help @uglyog !! really appreciate it

shanta.kumar
2020-01-16 07:37
has joined #general

wesleythomaswilliams
2020-01-16 13:52
Not sure whether this belongs in #general or #pact-jvm. In testing my provider, I wanted to double check a 404 test I've written is behaving correctly. The pact file interaction uses a query with a junk value for a parameter and expects a 404 back with no body. ```{ "description": "a request to get a thing", "request": { "method": "GET", "path": "/v1/search/find-by-identifier", "query": { "alias": [ "identifier" ], "value": [ "JUNK" ], "caller": [ "<my_consumer_service>" ] } }, "response": { "status": 404 }, "providerStates": [ { "name": "invalid identifier in query params" } ] }``` That seems pretty standard and passes just fine, but as part of figuring this all out, I thought I'd try instructing my provider to actually return a 200 and a body when testing this interaction, just to see what happens. This is what I get when I do: ```Given invalid identifier in query params a request to get a thing returns a response which has status code 404 (FAILED) has a matching body (OK)``` The reporting here seems wrong, so I just wanted to check if this is expected based on how pact works at the moment. The failure on the 404 is correct as the service returns a 200, but the matching body is incorrect as the pact file has no body and the service is now returning one. @uglyog or @bethskurrie is this something you can clear up for me please?

wesleythomaswilliams
2020-01-16 13:55
Our initial thoughts were that the body doesn't actually get checked if the status check fails.

brook
2020-01-16 15:17
has joined #general

david.wang3
2020-01-16 17:26
ok thanks.. i?ve put this on hold temporary, as I?m working on getting my current rest api pact tests integrated with my jenkins server. I?ll come back to in a few weeks as we still need to get event tests working for python

bethskurrie
2020-01-16 21:43
@wesleythomaswilliams if the body is not specified in the pact, then I think it is just not checked - so any body that is returned is considered ok.

bethskurrie
2020-01-16 21:43
It looks like in your pact, you're not specifying anything about the response body. Try specifying an empty string and see what you get.

bethskurrie
2020-01-16 21:45
Oh, that's a pity, someone just asked for it on a github issue. Do you have anything you can share? I might know someone who can pick it up @david.wang3

david.wang3
2020-01-16 22:06
yes I do have some code I can put up

david.wang3
2020-01-16 22:07
its not much but its a start

bethskurrie
2020-01-16 22:07
cool.

david.wang3
2020-01-16 22:07
i?ll try to clean it up a bit and put it tonight my time

bethskurrie
2020-01-16 22:08
cheers

bethskurrie
2020-01-16 22:14
Hi guys, we've been given a free Canny (feature request and prioritisation software) account for Pact. I'm hoping it will help us prioritise feature development better across our many many repositories. If you have a Pact feature request, please create an account and add it to the list, or go and vote on what you can see. Remember to specify which language you're talking about. https://pact.canny.io/

uglyog
2020-01-16 22:25
As @bethskurrie said. Specifying no body in the expectations means you don't care about the body. If you do care, add an appropriate value to the expectation

bethskurrie
2020-01-16 22:55
added an integration to this channel: https://pact-foundation.slack.com/services/BSRMH3JG4

wesleythomaswilliams
2020-01-16 22:56
Thanks both, I'll test with an empty body too, just to make absolutely sure, but it appears to be doing what you're saying. :+1:

2020-01-16 22:57
A new post has been created in *Feature Requests*

tjones
2020-01-16 22:57
I don?t know who this Tim Jones is, but I like his ideas.

tjones
2020-01-16 22:57
Ok, ok. It was me.

2020-01-16 22:59
A new comment has been created in *Feature Requests*

bethskurrie
2020-01-16 23:02
Ha

bethskurrie
2020-01-16 23:03
Not sure if this integration is going to be too noisy for general - if we don't like it, I can make a separate channel for it.

2020-01-16 23:21
A new comment has been created in *Feature Requests*

abubics
2020-01-16 23:38
`has a matching body` still seems a bit misleading :slightly_smiling_face:

fox_rul
2020-01-17 03:09
has joined #general

2020-01-17 04:49
A new post has been created in *Feature Requests*

2020-01-17 06:23
A new comment has been created in *Feature Requests*

2020-01-17 06:26
A new comment has been created in *Feature Requests*

nva
2020-01-17 09:53
has joined #general

2020-01-17 10:27
A post in *Feature Requests* hit *5 votes*

2020-01-17 12:55
A new post has been created in *Feature Requests*

r.roos
2020-01-17 13:08
has joined #general

josue.guerrero
2020-01-17 14:50
has joined #general

josue.guerrero
2020-01-17 15:28
Hello everyone, is there someone who works with microservices, RabbitMQ and Nodejs ?

chen1055
2020-01-19 04:37
Just curious is there a solution for pacts where a node is both a consumer and a provider? Basically there is three nodes, A, B and C. If A is a consumer of B, B is both a consumer of C and provider of A, C is the provider of B. How do I contract test node A using the contract test between node B and C?

bethskurrie
2020-01-19 04:37
@chen1055 let me find the gist I did on this


bethskurrie
2020-01-19 04:39
I personally would use some "shared fixtures" that were used in both the upstream test and downstream tests, to tie the two pacts together.

bethskurrie
2020-01-19 04:39
What language is the consumer/provider app written in?

chen1055
2020-01-19 04:44
Java

chen1055
2020-01-19 04:46
Seems like theres more work when a node is both a consumer and provider. Is there no way to use the same contract tests in node B for node A Contract tests?

bethskurrie
2020-01-19 04:57
Yes, people have done it.

bethskurrie
2020-01-19 04:57
In fact, BankWest wrote some code specifically for that.

bethskurrie
2020-01-19 04:57
I don't think they got to open source it however.

bethskurrie
2020-01-19 04:58
So, in the Ruby code, you can define a body outside of the scope of a 'given when then' and use it for both upstream and downstream tests. I don't know if you can do the same thing with Java or not.

chen1055
2020-01-19 05:00
I never tried. tbh I asked because I'm contract testing node B to node C recently and just realized I don't know how to expand to node A easily.

chen1055
2020-01-19 05:01
But thanks for the gist at least I have some idea and will try them.

matt400
2020-01-19 06:06
We use the same test for consumer and provider in the scenario you describe. Our junit tests will generate consumer contracts (pact mocking) and be a provider state (custom annotation) if the are Node B. I can't confirm if we can release our code as open source at this time.

2020-01-19 16:35
A new comment has been created in *Feature Requests*

bethskurrie
2020-01-19 21:36
You could try #pact-js @josue.guerrero

2020-01-19 22:06
A new comment has been created in *Feature Requests*

2020-01-19 22:19
A new comment has been created in *Feature Requests*

2020-01-19 22:53
A new post has been created in *Feature Requests*

2020-01-19 23:35
A new comment has been created in *Feature Requests*

bethskurrie
2020-01-19 23:57
I think the comments from Canny are getting a bit noisy, so I've made a #feature-requests channel to pipe all the comments to. The new features will still show up in general so that if anyone is interested, they know to jump in to canny to contribute.

ssong
2020-01-20 02:10
has joined #general

ssong
2020-01-20 02:12
Hi All, I have some questions about PACT junit 5 configuration, where should I ask the questions?

bethskurrie
2020-01-20 02:13
#pact-jvm @ssong

ssong
2020-01-20 02:17
Thanks

tjones
2020-01-20 05:06
Discussion question: How do *you* do your app versions so that they?re unique per contract?

chen1055
2020-01-20 09:28
Git commit hash?

2020-01-20 10:24
A post in *Feature Requests* has been marked as *in progress*

g.van.vliet
2020-01-20 14:24
has joined #general

josue.guerrero
2020-01-20 15:27
@bethskurrie thanks for answer Beth. I have another question. We are using different projects for each microservice. I should create a provider and a consumer for each project or depends which microservice is the consumer or the producer

sliu7
2020-01-21 04:10
Hey guys. I've been trying out some of the PactBroker webhooks and was trying to trigger a slack webhook when provider verification fails. When I test out the webhook using the execute endpoint, it works. But it doesn't seem to get triggered when the provider verification is failing in the CI pipeline. For the verification result, the 'Webhooks triggered by the publication of this verification result' is empty. Not sure if I'm missing some other config? Webhook configured: ```{ "description": "POST http://hooks.slack.com", "consumer": { "name": "TestConsumer" }, "provider": { "name": "TestProvider" }, "enabled": true, "request": { "method": "POST", "url": "slackwebhookurl", "headers": { "Content-Type": "application/json" }, "body": { "text": "Test pact verification failed" } }, "events": [ { "name": "provider_verification_failed" } ], "createdAt": "2020-01-20T23:53:23+00:00" }```

bethskurrie
2020-01-21 04:12
```provider_verification_failed``` is a very new feature - it's possible there's a bug in it.

bethskurrie
2020-01-21 04:12
I do remember testing it myself (as well as having automated tests), but there may be a corner case.

bethskurrie
2020-01-21 04:13
There are logs that print out that tell you which webhooks are being triggered for each event. Can you find them?

bethskurrie
2020-01-21 04:13
Also, best to ask these questions in the #pact-broker channel.

sliu7
2020-01-21 04:19
Ah, ok. I'll post it in the relevant channel. Thanks!

vinodkumar.bs57
2020-01-21 08:33
has joined #general

john.hamlett
2020-01-21 15:07
Quick question: So we are using pact in CI. If we run it every build, with a new tag, will the contract need to be revalidated every time even if no change has occurred to the pact file?

matthew.denvir
2020-01-21 15:11
has joined #general

anja.kammer
2020-01-21 15:51
has joined #general


raymond.burrowes
2020-01-21 17:04
has joined #general

john.hamlett
2020-01-21 19:10
Having a tough time convincing a coworker to go to pact, he says that if we have a microservice that is consumed by 10000 other microservices and each has a contract test that pact will have to run 10000 tests suites, is that correct?

brook
2020-01-21 19:13
yes. although the same endpoint can be used to satisfy multiple clients, the verification will still have to be completed for each client, so each contract will have to be tested. (I could be wrong, this is based on my experience)

brook
2020-01-21 19:13
Are these REST or AMQP endpoints?

john.hamlett
2020-01-21 19:15
REST

brook
2020-01-21 19:17
separate question: is this an extreme hypothetical? or realistic architecture consideration?

john.hamlett
2020-01-21 19:18
Hypothetical

john.hamlett
2020-01-21 19:18
His concern is that as the number of consumer increases the number of tests and time does also

brook
2020-01-21 19:18
okay? because my response to extreme hypothetical would be to turn the discussion back to ?why would we have 10K consumers? Is there a better design that we could implement?

john.hamlett
2020-01-21 19:19
Still does not get around the one to one relationship though

brook
2020-01-21 19:19
but to the point, yes? you have 2 tests for each consumer/provider interaction, the consumer contract test and the provider implementation verification.

brook
2020-01-21 19:20
but if you focus _solely_ on contract testing (and avoid sneaking in functional tests) they are very quick to write and run.

brook
2020-01-21 19:22
additionally, you should pick and choose which interactions you want to make contracts for. Although I lean towards contracts for all interactions. You may not need to write contracts for interactions within a domain (for example) and focus only on enterprise interactions (between domains) as a good starting place.

john.hamlett
2020-01-21 19:23
Agreed

brook
2020-01-21 19:26
(my opinion) governance is another ?-ility? that should be considered when designing a system. contract tests reduce risk at the added cost of writing and maintaining these tests. You should consider that when designing your system and it may impact how you partition your services.

erikpatekoski
2020-01-21 19:32
has joined #general

kkumar86
2020-01-21 20:05
has joined #general


wesleythomaswilliams
2020-01-21 20:46
@john.hamlett How would the colleague test them otherwise? I guarantee the other options for testing the integration of that many micro-services would be worse. :slightly_smiling_face:

matt.fellows
2020-01-21 21:11
In case you haven?t seen it, we also have this page that addresses some common questions/concerns (sometimes slightly tongue-in-cheek): https://docs.pact.io/faq/convinceme

bethskurrie
2020-01-21 21:16
@john.hamlett I'm actually on side with your colleague, in that if you had 1000 consumers, you're not really an "internal" api any more, you're a public api, and you would probably be best to use traditional versioning approaches. There's a section on "what is pact not good for" here https://docs.pact.io/getting_started/what_is_pact_good_for

bethskurrie
2020-01-21 21:19
I think he's falling for the slippery slope fallacy though, in thinking that "if contract testing doesn't work for 10000 consumers, we shouldn't use it when we have 3". You use the right tool for the right job, and your testing approach can and should change based on the situation your provider is in.

bethskurrie
2020-01-21 21:21
Thanks @kkumar86 where is the link from?

matt.fellows
2020-01-21 21:28
Actually, I think he?s straw manning to discredit the approach. But logical fallacies / arguments aside, you?re best going back to basics and assessing your testing strategy - and asking the question ?what problems do we have and how might contract testing change our approach?

matt.fellows
2020-01-21 21:30
I assume there is a reason you?re looking into contract testing, so you should be clear on the benefits and drawbacks, and any objectives of a change. Perhaps your colleague is really just a skeptic, and prefers to be really clear in his own mind. I can understand that. This article may also be of use in framing things: https://blog.pactflow.io/why-contract-testing/

matt.fellows
2020-01-21 21:31
As Wes mentioned, if the alternative is lengthy end-to-end tests, then we have a target and measures we can use to improve the situation, compare results etc.

kkumar86
2020-01-21 23:01
@bethskurrie it was hyperlinked on one of the pages .. will find out... but i found this article which i was looking for https://docs.pact.io/best_practices/consumer/contract_tests_not_functional_tests

nerea.tamayo
2020-01-22 08:35
Hi! I'm trying to implement CDC with Pact, and I have a question....For verifying Pact from the provider side, is it necessary that the provider is running?

bethskurrie
2020-01-22 08:36
Depends which language you're using @nerea.tamayo

bethskurrie
2020-01-22 08:37
Different implementations all you to verify at different levels. For example, with the Ruby implementation, you configure a Rack app, but it's not actually running a service on a port.

bethskurrie
2020-01-22 08:37
I believe JVM does a similar thing.

bethskurrie
2020-01-22 08:38
Other languages require that you have a running service, but it's best to use a local one not a deployed one.

bethskurrie
2020-01-22 08:38
Which verifier are you using?

nerea.tamayo
2020-01-22 08:39
At first, thanks a lot for your quick answer.I'm using JVM

nerea.tamayo
2020-01-22 08:40
but the idea is to introduce PACT through all company and we have a lot of different projects, but now I'm piloting the first project using JVM

bethskurrie
2020-01-22 08:40
Ask in the #pact-jvm channel then, someone will know. I'm pretty sure it calls the methods on the server directly without a process running, but you should confirm that.

nerea.tamayo
2020-01-22 08:41
Perfect!!!thanks a lot!!

bethskurrie
2020-01-22 08:41
Pact JVM can be tricky as there a lot of different ways to do things. The channel should help if you get stuck.

jgfarias42
2020-01-22 09:24
has joined #general

ankit992
2020-01-22 09:27
has joined #general

bethskurrie
2020-01-22 09:56
Sorry @josue.guerrero, I don't understand the question

mail259
2020-01-22 16:32
Hi, I am currently seeing all my github verification status to be reported as pending, is this because of the recent pending pact feature?

mail259
2020-01-22 16:32
I?m following the blog post but not entirely sure if the pending pact feature is enabled for me in pact broker: http://blog.pact.io/p/d7c9601f-e2ca-4208-b1c0-f02eaf96c3c2/

mail259
2020-01-22 16:33
Also not able to find any documentation around pending pact here: https://docs.pact.io/getting_started/pending-pacts

david.wang3
2020-01-22 16:57
when creating tags via the rest api, how do I specify multiple tags in the request url?

david.wang3
2020-01-22 16:57
`GET`, `PUT`, `DELETE` Path: `/pacticipants/{pacticipant}/versions/{version}/tags/{tag}`

david.wang3
2020-01-22 17:43
some questions on webhooks

david.wang3
2020-01-22 17:43
are webhooks meant to be created one time or on the fly?

david.wang3
2020-01-22 17:43
also, it seems like I cannot create a webhook for a consumer/provider pair if they don?t exist

david.wang3
2020-01-22 17:44
what i want to do is create a webhook, then publish my pactfiles and then have the webhook trigger my provider verification jenkins job. that doesn?t seem to work properly since I cannot create my webhook before I actually publish my pactfiles so that the pacticipants are created

matt.fellows
2020-01-22 21:27
It?s possible, maybe. It should be something that is opt-in, however in some testing I was doing yesterday it seemed like it was on by default

matt.fellows
2020-01-22 21:27
I need to prove/validate this though

matt.fellows
2020-01-22 21:27
but, it should only be ?pending? if the verification failed on something it hadn?t seen before

bethskurrie
2020-01-23 00:29
Hey @david.wang3

bethskurrie
2020-01-23 00:29
You can pre create the pacticipants to make this work.

bethskurrie
2020-01-23 00:30
Do a post to /pacticipants with a json body containing the name of the application

bethskurrie
2020-01-23 00:31
Typically, webooks get created once manually at the start of an integration, but there is a PR in play at the moment to support upserting a webhook so that the whole thing can be automated.

bethskurrie
2020-01-23 00:31
That way, the whole workflow can be scripted before you start, which sounds like what you want to do.

mail259
2020-01-23 03:21
Thanks for the reply. I?m using branch name as tags, and our pacts have not changed over weeks, though on the new pact broker, most of our statuses are shown as pending.

mail259
2020-01-23 03:23
We only trigger the verification step on contract_changed, though I manually run the verification against the pact on the develop branch to fix any failed verification in past which after completion did put the success tick on the github status. All the commits on develop after that are still in pending stage.

mail259
2020-01-23 03:26
Do you have suggestions on how to fix this? I was looking to revert the pact broker image to < v2.40 but it seems like migrations are causing the problem.

mail259
2020-01-23 03:28
Btw, I wanted to let you know that we all love pact at our company. It has made our move to micro services much easier :heart: Thanks for the support.

bethskurrie
2020-01-23 04:08
When creating a provider, I would create one "contract content changed" webhook, with no consumer specified, so that any consumer that adds a contract will automatically be picked up.

david.wang3
2020-01-23 04:08
thanks beth. actually I found out about the dynamic variables pactbroker.consumerName and pactbroker.providerName which means I c an pass that to my jenkins job.

bethskurrie
2020-01-23 04:08
When creating a consumer, I would create one "verification results published" webhook, with no provider specified, so that any new providers are automatically picked up.

david.wang3
2020-01-23 04:09
one question though

bethskurrie
2020-01-23 04:09
That's a good technique - one global webhook that passes the smarts on to a single jenkins job. This can be good when you're working out whether to trigger certain branches of things.

david.wang3
2020-01-23 04:09
how do I use consumerLabels and providerLabels dynamic variables?

bethskurrie
2020-01-23 04:09
They're not really used.

bethskurrie
2020-01-23 04:10
They're like tags for pacticipants.

david.wang3
2020-01-23 04:10
how do I set it?

bethskurrie
2020-01-23 04:10
I haven't really built any APIs on them yet.

david.wang3
2020-01-23 04:10
ok thats cool

bethskurrie
2020-01-23 04:11
Let me find the docs (if I wrote any)

bethskurrie
2020-01-23 04:12
Can't find any. From memory, it's just PUT /pacticipants/Foo/labels/bar

bethskurrie
2020-01-23 04:14
You can get them back by doing `/pacticipants/label/LABEL`

bethskurrie
2020-01-23 04:15
The plan was to use it for grouping pacticipants into business domains.

david.wang3
2020-01-23 04:17
```body = { "events": [{ "name": "contract_published" }], "request": { "method": "POST", "url": "https://acp-jenkins.arubathena.com/job/acp-qa/job/Multiapp/job/${pactbroker.providerName}/buildWithParameters?provider_branch_name=pact&pact_consumer_name=${pactbroker.consumerName}&pact_provider_name=${pactbroker.providerName}&consumer_tags=${pactbroker.consumerVersionTags}", "username": "xxxxx", "password": "xxxxxx", "headers": { "Accept": "application/json" } } }```

david.wang3
2020-01-23 04:17
i think this works well

david.wang3
2020-01-23 04:17
my jenkins job name is the pactbroker providername and then I pass in the various input parameters

bethskurrie
2020-01-23 04:17
sweet

david.wang3
2020-01-23 04:18
the main thing is the tag

david.wang3
2020-01-23 04:18
the consumer tag dictates what the provider branch would be

bethskurrie
2020-01-23 04:18
I notice that you're not using the pact URL to do the verification.

david.wang3
2020-01-23 04:19
not sure what you mean?

bethskurrie
2020-01-23 04:19
You only need to verify the pact that's changed.

david.wang3
2020-01-23 04:19
oh yeah? this is just for testing

bethskurrie
2020-01-23 04:19
Not all the pacts. The URL of the pact that has changed is one of the parameters.

david.wang3
2020-01-23 04:20
when I commit the code, i?ll change the event type

bethskurrie
2020-01-23 04:20
Having said that, not all the libraries support verifying a pact based on a dynamic URL (eg pact-jvm). There's an outstanding issue for this.

david.wang3
2020-01-23 04:20
contract_content_changed

bethskurrie
2020-01-23 04:21
Sorry, what I mean is, you don't want to run the full verification when only one pact has changed.

bethskurrie
2020-01-23 04:21
You only want to verify the one that has changed.

david.wang3
2020-01-23 04:21
right

david.wang3
2020-01-23 04:21
how do I do that?


bethskurrie
2020-01-23 04:22
The url of the changed pact is one of the parameters.

david.wang3
2020-01-23 04:23
oh i see

david.wang3
2020-01-23 04:23
pas the changed pact url to the jenkins job

bethskurrie
2020-01-23 04:23
yes

david.wang3
2020-01-23 04:23
got it

bethskurrie
2020-01-23 04:24
:thumbsup::skin-tone-3:


bethskurrie
2020-01-23 04:24
If you think that could be clearer, let me know how to improve it.

david.wang3
2020-01-23 04:24
i?m planning on doing a demo to my team tommorrow. hopefully with some real life examples they will be more convinced. and walking them through the entire workflow will be conving

martin.schneider
2020-01-23 05:08
has joined #general

mail259
2020-01-23 14:34
cc @matt.fellows @bethskurrie

ake
2020-01-24 12:26
has joined #general

krdurgesh28
2020-01-24 14:12
has joined #general

dmytro.garanzha
2020-01-25 22:30
has joined #general

david862
2020-01-26 00:16
Does anyone know of an example - for any language - of using the result of a generator (https://github.com/pact-foundation/pact-specification/tree/version-3#introduce-example-generators) within a `path`? I?m trying to understand if that?s even something that can be represented by a v3 pact file.

matt.fellows
2020-01-26 00:19
I think it is possible but haven't used pact JVM before. Is this helpful at all? https://blog.pactflow.io/injecting-values-from-provider-states/

hidalgofdz
2020-01-26 01:06
has joined #general

ian.mcwilliams
2020-01-27 17:22
Does anyone have any advice in implementing Pact in clusters where the individual repos are big monoliths? The stubbing strategy is a highlighted concern; this is discussed in a previous question (https://pact-foundation.slack.com/archives/C5F4KFKR8/p1571223440029200) and in a gist by @bethskurrie (https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0), the challenge in this case is that the amount of stubbing that may be required could be too big a job to ask a team you are trying to work with to implement this type of testing

joseph.haig
2020-01-28 10:15
I have created a new contract with a service and uploaded it to our PACT server. The service provider hasn?t been set up yet, though, so the contract hasn?t been verified. Is it possible in the `pact-broker can-i-deploy` step to exclude this contract as it is causing the pipeline to fail? (We are retrospectively adding PACT to an existing service so it does exist. It is just the PACT that is not yet being verified)

wesleythomaswilliams
2020-01-28 10:23
I had a similar issue last week Joe. Our builds/tests are run by Maven, so I deleted the published pact and disabled publishing on the consumer side. My plan is to enable it once the provider side is ready.

joseph.haig
2020-01-28 10:31
Thanks. I think that is what I will have to do.

sagupta
2020-01-28 10:35
has joined #general

sagupta
2020-01-28 10:47
Hi , I just joined the slack group. May i know if there is a list of channel that i can refer to see which ones to join?

joseph.haig
2020-01-28 10:54
If you click on the word ?Channels? on the left (which will have ?# general? and ?# random? underneath) you are able to search for channels. This will give you a list of channels that match your search.

joseph.haig
2020-01-28 10:55
A slight issue with this (that has just become apparent) is that the team working on the provider want to get the contract from the server.

david862
2020-01-28 15:28
Yeah that?s really interesting, cheers. Looks like it?s definitely possible to use a generator result in a query parameter, but not sure about the path itself, e.g. /object/{generated_id}/. Would be really useful to us but since the spec v3 presents generators as overriding example values, I?m not sure how it could override just part of a path :shrug: We?re using python so we?d probably have to roll our own input/output logic here, but it could be worth it.

nathan.deamer
2020-01-28 16:10
Hey all, I am looking at setting up webhooks to force builds of my providers when contracts are changed.... The URL I have to hit to trigger a build is something like: https://someUrl.com/api/organization/repo?branch=master&access_token=<INSERT ACCESS TOKEN HERE> Can I use the pactflow secrets to store my access token and reference?


g.j.crossfield
2020-01-28 18:24
has joined #general

jana.pacheco
2020-01-28 18:41
has joined #general

bethskurrie
2020-01-28 19:11
@joseph.haig I've been meaning to support something like --allow-missing Foo for this scenario, but it hasn't gotten to the top of the priority list!

bethskurrie
2020-01-28 19:12
In the meantime, you can explicitly list your dependencies instead of using --to prod


bethskurrie
2020-01-28 19:18
@ian.mcwilliams if Pact doesn't make life easier than real integration tests, then maybe you're better sticking with integration tests, is my opinion.

bethskurrie
2020-01-28 19:20
If you're retrofitting pact onto existing code, rather that trying to cover every existing interaction, it might be easier to just start with new and changing interactions.

bethskurrie
2020-01-28 19:26
Some teams do do their verification against a deployed provider - this might be an option for you, even though it's not really the recommended approach, because you'll probably need to set up data in the downstream services in the provider states, and that could get messy.

bethskurrie
2020-01-28 19:27
It's all about trade-offs!

bethskurrie
2020-01-28 19:27
Working out which is the least painful option!

matt.fellows
2020-01-28 21:35
yes and yes :slightly_smiling_face:

bethskurrie
2020-01-29 05:38
@mail259 it's not enabled in the oss code yet, as im making sure we do a couple of trial client implementations before releasing it. I don't want to put the api out there and then have to making breaking changes.

bethskurrie
2020-01-29 05:40
I've only enabled it in http://pactflow.io for the alpha release. If you have one of pact js, pact ruby, pact net or pact go, you can try it out if you have a pactflow account.

bethskurrie
2020-01-29 05:42
@matt.fellows in the first release of the ruby standalone, pending was on by default. The most recent version has it disabled by default with a config to turn it on.

bethskurrie
2020-01-29 05:43
@mail259 when you say, most of your statuses are shown as pending, what do you mean?

bethskurrie
2020-01-29 05:43
Do you mean, the yellow state?

bethskurrie
2020-01-29 05:43
Github pending is not the same as pact pending.

elliottmurray
2020-01-29 05:44
Is there a ?best practices? on how to test integration with pact broker? I have made some changes to python around it?s provider options that now allow it to pull from a broker. But I?m really not sure how to get confidence it really works. It?s as if you need a broker and a provider running at once - have to check my contracts!


tjones
2020-01-29 05:46
Oh, wait, you?re asking how to test a pact implementation? Not how to integrate your provider tests with a broker?

elliottmurray
2020-01-29 05:46
yep!

elliottmurray
2020-01-29 05:46
Should have put in a bit of a Meta alert warning

tjones
2020-01-29 05:46
We don?t have a best practices for that

elliottmurray
2020-01-29 05:46
ok

bethskurrie
2020-01-29 05:46
ha

bethskurrie
2020-01-29 05:47
There are pacts between the pact broker clients and the pact broker


elliottmurray
2020-01-29 05:47
Just I?m spinning up a lot of docker containers to test os calls work

elliottmurray
2020-01-29 05:47
oh really?

bethskurrie
2020-01-29 05:47
yup!

bethskurrie
2020-01-29 05:47
We use pact to test pact.

elliottmurray
2020-01-29 05:47
let me look at e2e again

elliottmurray
2020-01-29 05:47
eating your own dog food?.

tjones
2020-01-29 05:47
yo-dawg.gif

elliottmurray
2020-01-29 05:47
drinking your own champagne?

bethskurrie
2020-01-29 05:48
So, in the pact broker client, I write a pact for the calls, then I use the pact to make a stub that I use for a "top to bottom" test of the CLI.

tjones
2020-01-29 05:48
We get around this in Pact-JS / Pact-Node by using the pact-broker client

tjones
2020-01-29 05:48
which we assume works

bethskurrie
2020-01-29 05:48
oh - yes, if you're in pact-python, then the pact-ruby-standalone has already been tested.

elliottmurray
2020-01-29 05:49
yeah I guess I?m nervous my changes are unit test mocked

elliottmurray
2020-01-29 05:49
but it?s hard to actually validate those initial tests are correct

elliottmurray
2020-01-29 05:49
if that makes sense

elliottmurray
2020-01-29 05:49
so am I calling pact broker client correctly?

tjones
2020-01-29 05:49
in JS land, we don?t validate that call

elliottmurray
2020-01-29 05:50
specifically that multiple consumer tags thing @bethskurrie

tjones
2020-01-29 05:50
This has been the source of bugs in the past

bethskurrie
2020-01-29 05:50
In a few of the projects I have a bash script that I use to test things out e2e against a live broker, but I don't automate a test against it.

elliottmurray
2020-01-29 05:50
thats what I want

tjones
2020-01-29 05:50
There is a test broker with test credentials you can use

elliottmurray
2020-01-29 05:50
Then once I have my tests correct I?m good

elliottmurray
2020-01-29 05:51
or that

tjones
2020-01-29 05:51
but if you do that, your tests rely on it :shrug:

bethskurrie
2020-01-29 05:51
Broker base URL: https://test.pact.dius.com.au username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1

elliottmurray
2020-01-29 05:51
I won?t automate

elliottmurray
2020-01-29 05:51
I just want to validate my unit tests are valid = especially when I?m wrapping unix system calls

elliottmurray
2020-01-29 05:51
thx


tjones
2020-01-29 05:53
Actually, have a look at the integration tests in pact-node

elliottmurray
2020-01-29 05:53
ok thx

tjones
2020-01-29 05:53
The history says I?ve touched it, but it?s a lie. It was just autoformat when I brought in `prettier`

elliottmurray
2020-01-29 05:54
lol

elliottmurray
2020-01-29 05:54
also @bethskurrie when you get a chance let me know what you think about what I?ve done with docker in python. I can help publish to dockerhub if you like too. It?s the only way i could test 2.7 locally

bethskurrie
2020-01-29 05:54
@mail259 if you think there might be a bug calculating the statuses, can you create a document that explains your CI set up, and get me a screenshot of the "index with tags" that has the incorrect status, and a screenshot of the matrix that shows the relevant versions.

elliottmurray
2020-01-29 05:54
I can do all other versions

elliottmurray
2020-01-29 05:55
I can give you a script to actually run it yourself (I?ll add if you like)

bethskurrie
2020-01-29 05:55
I have OSS day tomorrow, so I'll have a good look at it then.

elliottmurray
2020-01-29 05:55
:thumbsup:

bethskurrie
2020-01-29 05:59
The other thing that would help is if you did an export of your database, imported it, ran this script to redact it, and then sent me the file. https://github.com/pact-foundation/pact_broker/blob/master/script/prod/redact-data.sql

bethskurrie
2020-01-29 06:01
I have an OSS day tomorrow, so if you're able to get it to me by then, I can have a look at it. Best to raise an issue in the Pact Broker repository.

bethskurrie
2020-01-29 06:14
If you want to downgrade, you'll need to run migrations to reverse the database changes that got applied between 40 and your version


joseph.haig
2020-01-29 08:57
My command currently looks like this: ```pact-broker can-i-deploy --pacticipant $CONSUMER --version `cat git-version.txt` --pacticipant $PROVIDER --latest prod_env --broker-base-url $PACT_BROKER --broker-username $PACT_USER --broker-password $PACT_PASSWORD``` If I understand correctly, this is in the format to explicitly specify dependencies. However, it is also picking up the new provider, which is not yet ready.

fabio.iglesias
2020-01-29 08:59
Hello, We have a doubt regarding Error cases testing with Pact. In the docs it is stated that "unhappy paths" testing belong in functional tests, not in contract tests. However, in this same docs (https://docs.pact.io/best_practices/consumer/contract_tests_not_functional_tests) I can see that a simple, general error is included in the Pact content `So let's go back to our scenarios and instead choose just one simple example to test the way the _User Service_ reacts to bad input`. We have been trying to include some error response interactions as part of the pact with the utility from @pact-foundation/pact but error cases are never included in the Pact. Is there a way to enable the "unhappy path" inclusion so the BE can also be aware of such logic? Thank you beforehand

sagupta
2020-01-29 09:05
Hello people, i have just started reading about PACT to see if I can implement in my company. We have a microservice architecture in place and also we provide public API (for customers to consume) and also use external API (like Auth0) for authentication. Below are some questions: 1. As PACT is a consumer driven test, I was wondering if it is useful to have contract tests between external API (auth0) and my company as we do not have control over AUth0 and was wondering how would i test in that case.

sagupta
2020-01-29 09:07
2. We would like to have contract tests in place as we have multiple consumer consuming our services and the idea is to have tests fail whenever we as a provider change our contract . Also we want to make sure we do not break consumer and if possible break provider side only (and fix as it is in our control) Just wanted to know from you guys if this makes any sense ?

antonello
2020-01-29 09:26
Hi Fabio, hopefully this will clarify things a little. Unhappy paths, e.g. interactions that don?t lead to a 2XX response from a provider, should be included in the pact if they consumer uses them or relies on them. When the documentation talks about unhappy paths and functional testing it refers to that the fact that it would be ill advised to test for all possible permutations that would lead to a response that is the same from a contract point of view. Let?s say, for example, that a consumer expects a 400 response with a body like this when some fields are invalid ```{ "errors": [ { "field": "username", "error": "an error message" }, { "field": "firstname", "errror": "a different error message" } ] }```

bethskurrie
2020-01-29 09:28
Short answer, no, unfortunately. You'll find it covered here https://docs.pact.io/getting_started/what_is_pact_good_for

bethskurrie
2020-01-29 09:28
That is exactly what Pact is good for :+1:

sagupta
2020-01-29 09:29
ok great

bethskurrie
2020-01-29 09:29
:+1: Anto

bethskurrie
2020-01-29 09:30
You just need one example of an unhappy path, so you know what the shape of the document is.

sagupta
2020-01-29 09:30
ok got it so it works when you have provider and consumer both in your domain and in your control

antonello
2020-01-29 09:31
What you don?t want is to have a different interaction for all possible permutations of errors, but as Beth said, cover one example so that you can verify the shape of the document (+ the http status code).

bethskurrie
2020-01-29 09:31
Ha, I thought you'd gotten distracted. What Anto said ^^

bethskurrie
2020-01-29 09:32
I don't know what that utility class is.

bethskurrie
2020-01-29 09:33
There's nothing special about the error scenarios, you just declare them exactly the same as a normal one.

bethskurrie
2020-01-29 09:33
When I send a request with bad data with (example request) then I expect a 400 response (example response)

bethskurrie
2020-01-29 09:35
Think of it this way - you could mock the validation on the provider side during verification (if your library supported that) to return a 400 response, and it would be a perfectly valid test.

bethskurrie
2020-01-29 09:35
That's what we mean by saying it's not a "functional test".

bethskurrie
2020-01-29 09:37
It's generally just simpler to provide a stable "wrong" request to get the 400 response though.

bethskurrie
2020-01-29 09:37
You're trying to cover the "classes of errors", not every single thing that could lead to each error.

bethskurrie
2020-01-29 09:40
Exactly @sagupta

ian.mcwilliams
2020-01-29 09:40
Thanks for the feedback @bethskurrie!

bethskurrie
2020-01-29 09:41
Which is why internal microservices are the sweet spot for Pact.

bethskurrie
2020-01-29 09:42
That's not supposed to be happening then.

ian.mcwilliams
2020-01-29 09:42
Yes I agree that we must be open minded to the best solution for the problem at hand - currently I'm working with a colleague to list out and examine as many variations as we can think of

bethskurrie
2020-01-29 09:43
The format is correct. If it's picking up the new provider, there's a bug.

ian.mcwilliams
2020-01-29 09:43
I'd considered limiting the number of interactions under test, starting with new/changing interactions sounds like a good way for that to take form

bethskurrie
2020-01-29 09:44
Can you raise an issue in the Pact Broker and let me know the versions of everything (client and broker) and describe the dependencies between your services so I can recreate the data.

ian.mcwilliams
2020-01-29 09:45
The issue is really with removing the unreliability of downstream services when running the provider tests - so would require the provider to stub a call to a third party service for example

bethskurrie
2020-01-29 09:45
Run can I deploy with --verbose turned on, and send me the output, and the returned table.

joseph.haig
2020-01-29 09:45
OK. Is there a way to get verbose (or debugging) output from `pact-broker`?

joseph.haig
2020-01-29 09:45
You read my mind. :slightly_smiling_face:

ian.mcwilliams
2020-01-29 09:46
Which is fine but the provider team are raising a valid question about the amount of stubbing they'd need to maintain, given that their service is large and has a mess of dependencies!

bethskurrie
2020-01-29 09:47
Screenshots of the matrix tables with the relevant lines would help.

bethskurrie
2020-01-29 09:48
Sounds tricky :pensive:

bethskurrie
2020-01-29 09:49
Are you on the latest version of the broker? And the latest client?

bethskurrie
2020-01-29 09:50
I have an oss day tomorrow, so I'll hopefully be able to work it out.

ian.mcwilliams
2020-01-29 09:50
It's a situation we'll find in more than one team here, so finding the right solution should scale across the business - at the same time I'm looking to advocate for splitting services into smaller repos, but as you can imagine that'll be part of the long game :wink:

bethskurrie
2020-01-29 09:50
There's been a lot of change in there recently, trying to optimise the queries.

joseph.haig
2020-01-29 09:51
Our broker (I believe) is hosted at http://arnoldclark.pact.dius.com.au. Is there a way I can find the version from that page? The client is version 1.23.0.

bethskurrie
2020-01-29 09:51
I don't envy you! We've all been there.

bethskurrie
2020-01-29 09:51
Oh, it's the latest then.

bethskurrie
2020-01-29 09:51
You can find the version in the response headers.

ian.mcwilliams
2020-01-29 09:51
It's all in the game! And your advice is, as ever, much appreciated :+1::facepunch:

joseph.haig
2020-01-29 09:51
The pipeline has a `gem install` step so it should always be the latest.

bethskurrie
2020-01-29 09:51
Let us know how you go

joseph.haig
2020-01-29 09:53
2.44.0 - does that sound right for the broker version?

bethskurrie
2020-01-29 09:53
Yes.

bethskurrie
2020-01-29 09:53
Pactflow always has the latest

bethskurrie
2020-01-29 09:54
I put it out before I release the oss version to test it.

bethskurrie
2020-01-29 09:54
Just sent you a PM

ian.mcwilliams
2020-01-29 10:04
Will do @bethskurrie :slightly_smiling_face: I'm supporting @shero86 in this work so either of us will be around here and there I should think

fabio.iglesias
2020-01-29 11:21
Thank you @bethskurrie @antonello :slightly_smiling_face: this makes the issue much more clear to me.

fabio.iglesias
2020-01-29 11:22
I am using https://www.npmjs.com/package/@pact-foundation/pact-web in my consumer. I don't know if it is possible that I missconfigured something thus preventing the error contract cases from being added to the Pact

bernardoguerr
2020-01-29 12:43
One thing you could potentially do, if your external provider publishes a swagger/openapi spec of sorts, is just verify against a published version of that schema, with a tool like this: https://bitbucket.org/atlassian/swagger-mock-validator/src/master/ I actually work for Auth0, funny enough. I believe you can obtain the swagger docs for it from the management API documentation (https://auth0.com/docs/api/management/v2), not sure about the authorization endpoints . But if they are documented, then you can in theory setup a repo that pulls in that schema and validates using that tool, just like a provider repo would. It's not the full pact workflow, but it's something I think could be useful

sagupta
2020-01-29 13:54
Thats good input. I will see if I can use this info Thanks a lot :slightly_smiling_face:

elitusprime
2020-01-29 15:34
has joined #general

brook
2020-01-29 19:55
FWIW. we write pact against controller and mock out the service layer. This can run in memory as unit test. We use a separate ?publish? maven profile which would publish provider verification to the broker.

bethskurrie
2020-01-29 20:04
@fabio.iglesias can you create a little demo of the error interactions not being added please, and raise an issue in the github repository? There may be a bug if that is the case.

mail259
2020-01-29 20:54
https://pact-foundation.slack.com/archives/C5F4KFKR8/p1580276582021100?thread_ts=1579710728.040400&cid=C5F4KFKR8 I meant that 99% of our github statuses in the frontend/consumer repositories are reported as pending. This is updated via webhook on all pacts and the status being sent there is ?Pending?. This started happening when we updated the pact broker version to latest ( probably from v2.30.0 ).

mail259
2020-01-29 20:57
None of our pacts are failing or in pending state in UI. Everything is successfully verified but somehow the value of `${pactbroker.githubVerificationStatus}`is sent as pending and never being updated after that. We trigger our CI job only on pact change, so I assume if the pact has not changed, it should set the status as successful. None of our pacts are changed recently

matt.fellows
2020-01-29 22:55
> @Matt (http://Pactflow.io) in the first release of the ruby standalone, pending was on by default. The most recent version has it disabled by default with a config to turn it on. Thanks Beth. Yes, I had noticed this the other day. In fact, when I set the CLI flag either way it seemed to have no effect. I thought it was something I was doing, and wanted to do more investigation but ran out of time.

matt.fellows
2020-01-29 22:55
If I get to it this afternoon (Pact Go) I?ll confirm

sliu7
2020-01-29 23:14
Hey guys, Does anyone have experience with using Pact with GraphQL - specifically with a federation layer? <multiple independent GraphQL services> --- <GraphQL federation layer> --- <clients> The federation layer isn't the actual provider, but it acts like a gateway which stitches together data from the individual GraphQL services based on the query requested by the clients. Was wondering if Pact could be used in the scenario and if yes, at which layer would we include it? The clients can create the contracts based on the queries they use and the responses they expect to receive, but I'm a bit confused about where and how the verification could take place since the data returned from the query might span across different individual GraphQL services

mramos
2020-01-29 23:49
has joined #general

mramos
2020-01-29 23:58
hello everyone. I have an issue connecting to PactFlow using a nodeJS app. The credentials works fine when I do it manually as well as the token when I do curl command. I got this error in node app: `PactBroker::Client::Error - Authentication` `failed} One or more pacts failed to be published` Below is what in my publish opts: pactBroker: "<url>", pactBrokerUsername: "<username>", pactBrokerPassword: "<password>", pactBrokerToken: "<token>" Can you please advise? thanks.

bethskurrie
2020-01-29 23:59
You don't need a username and password, just the token.

bethskurrie
2020-01-29 23:59
Also, make sure you have the latest version of pact-js, as token support has only recently been added.

mramos
2020-01-30 00:00
oh thanks. I'll try that. cheers!

matt.fellows
2020-01-30 00:24
Sorry for any confusion. I?ve added stronger validation to pact node to error if somebody tries this: https://github.com/pact-foundation/pact-node/compare/chore/token-or-username-but-not-both?expand=1

mramos
2020-01-30 00:31
all good now. thanks a lot.

bethskurrie
2020-01-30 01:05
I'll double check the pending flag is being applied.

bethskurrie
2020-01-30 01:37
@matt.fellows I've fixed this - the broker was defaulting to true when unspecified (from my original plan to make this a no-code change opt-in), and the ruby code was only setting it to true if --enable-pending was set (from my new plan to require explicit opt-in), so it was always coming back with the pending info. Releasing the change now.

matt.fellows
2020-01-30 01:41
aha, makes sense

matt.fellows
2020-01-30 01:41
thanks Beth

mail259
2020-01-30 01:43
@bethskurrie Will that commit fix the issue that I?m seeing as well?

bethskurrie
2020-01-30 01:43
No, completely unrelated.

mail259
2020-01-30 01:43
Ahh okay, thanks

bethskurrie
2020-01-30 01:43
I'm hoping I'll get to your issue this afternoon.

mail259
2020-01-30 01:55
Matrix looks like this

mail259
2020-01-30 01:57
> get me a screenshot of the ?index with tags? that has the incorrect status, Sorry I?m not sure what do you mean by index with tags?

bethskurrie
2020-01-30 01:57
if you go to the index page, you can select "view with tags"

bethskurrie
2020-01-30 02:08
I agree, those pacts sure don't look like they're pending!

bethskurrie
2020-01-30 02:09
Can you raise an issue for me in https://github.com/pact-foundation/pact_broker and describe when your webhooks are firing?

mail259
2020-01-30 02:09
Sure I will do that

bethskurrie
2020-01-30 02:09
Can you tell if they're reporting the wrong status, or if the webhook that should set the status to green is not firing properly?

tjones
2020-01-30 06:02
The short answer is yes, you can use pact for this

tjones
2020-01-30 06:02
The longer answer to ?what layer? depends on your scenario (forgive my lack of GraphQL knowledge)

tjones
2020-01-30 06:02
what is the contract between in your case?

tjones
2020-01-30 06:02
To me, it sounds like it is between the client and the federation layer

tjones
2020-01-30 06:03
but it depends on how easy that is to set up for provider testing, and whether it is appropriate for whatever the federation layer does

tjones
2020-01-30 06:03
generally you don?t want your provider tests to test functionality

tjones
2020-01-30 06:04
is the federation layer doing any translation or mapping?

tjones
2020-01-30 06:04
or is it just joining responses together?

tjones
2020-01-30 06:04
You have A -> B -> C, where C is each individual service

tjones
2020-01-30 06:05
Ignoring the GraphQL angle, this is common with API gateways, too

tjones
2020-01-30 06:05
if your gateway is just passing through, you could simply test the contract between A -> C

tjones
2020-01-30 06:05
if your gateway is changing C?s response (or mutating headers), you might want to contract A-> B and B -> C


tjones
2020-01-30 06:08
I?ve also written consumer-only tests in the past. This ensures that your HTTP APIs are configured to produce the expected request. But without verification, it doesn?t ensure connectivity with the provider

sliu7
2020-01-30 06:16
yeah, it wouldn't be testing any functionality, but more to check where the schema is being adhered to. To the clients, it would be creating contracts with the gateway layer. But I'm just confused as to how the gateway would be able to verify the contracts

sliu7
2020-01-30 06:18
Because the individual services are registered with the gateway, which would stitch together the responses from the individual services based on the query received

sagupta
2020-01-30 14:01
So @tjones do you then think its still worth to have these or not?

fabio.iglesias
2020-01-30 15:38
Hi @bethskurrie , I have finally found my "missconfiguration". I was using the same content in several interactions for the field "uponReceiving". The tests were working fine but at the time of generating the pact only the first of several interactions with identical "uponReceiving" content was being included

fabio.iglesias
2020-01-30 15:39
That made my problem :sweat:

bethskurrie
2020-01-30 20:55
Ah, right!

tjones
2020-01-30 23:02
I personally do think they?re worth writing, but only if you don?t spend a great deal of time doing it. Here?s an example of a consumer-only test: https://github.com/TimothyJones/github-cognito-openid-wrapper/blob/master/src/github.pact.test.js

oscar821210
2020-02-02 20:09
has joined #general

juanma97perez
2020-02-03 11:27
has joined #general

juanma97perez
2020-02-03 11:28
Hello, I have a little dude

juanma97perez
2020-02-03 11:28
I want include headers in my request

juanma97perez
2020-02-03 11:28
``` Map<String, String> headers = new HashMap<>(); headers.put("Authorization", "Bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJiNzkyMDAxNS01NjExLTQ5NWEtYjA2MS0wNmZkNWM5NGJiNTAiLCJuYmYiOjAsImlhdCI6MTU2NTY4MDU5NywiaXNzIjoiaXNzdWVyX2IiLCJhdWQiOiJpYmVyaWFfd2ViIiwic3ViIjoiMjBlYWI1ZjAtMjE0Yy00NDJlLWE3ODktODhmYzdkNzgzZmM4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiaWJlcmlhX3dlYiIsInNlc3Npb25fc3RhdGUiOiJiZDlmZGVjYS0yYTVmLTQ1OTYtYTQ5MC01Zjc2MTUxMDkyOTEiLCJjbGllbnRfc2Vzc2lvbiI6ImJmOWRjOTRhLTcxZjAtNDViNS1iY2M4LTNkNzFiMmNmYzM0YSIsImFsbG93ZWQtb3JpZ2lucyI6W10sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJST0xFX1JFVFJJRVZFX0RFTEFZRURfQkFHX1JFVElSRURfUkVDT1JEIiwiUk9MRV9DUkVBVEVfQ0xBSU0iLCJST0xFX0NMSUVOVF9XRUIiLCJST0xFX09STSIsIlJPTEVfQlBNIiwiUk9MRV9QTVQiLCJST0xFX0FWTSIsIlJPTEVfTE9DIiwiUk9MRV9SRVFVRVNUX0dDX0JBR19DTEFJTSIsIlJPTEVfQ0hFQ0tfUElSU1RBVFVTIiwiUk9MRV9BRFZNIiwiUk9MRV9SRVFVRVNUX1NVUFBPUlRfQ0FMTCIsIlJPTEVfUFJNIiwiUk9MRV9GQVNTIiwiUk9MRV9DVVNUIiwiUk9MRV9QQUNDIiwiUk9MRV9SRVRSSUVWRV9EQU1BR0VEX0JBR19SRVRJUkVEX1JFQ09SRCIsIlJPTEVfQVBJTSIsIlJPTEVfUkVUUklFVkVfREVMQVlFRF9CQUciLCJST0xFX1NFQVRTIiwiUk9MRV9SRVRSSUVWRV9EQU1BR0VEX0JBRyIsIlJPTEVfU1JWIiwiUk9MRV9HRVRfQ0xBSU1fU1RBVFVTIiwiUk9MRV9VU0VSIiwiUk9MRV9FVEVSTkFMIiwiUk9MRV9JTVBFUlNPTkFUSU9OIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJ2aWV3LXByb2ZpbGUiLCJtYW5hZ2UtYWNjb3VudCJdfX0sImVtYWlsIjoic2VydmljZS1hY2NvdW50LWliZXJpYV93ZWJAcGxhY2Vob2xkZXIub3JnIiwibmFtZSI6IiIsInByZWZlcnJlZF91c2VybmFtZSI6InNlcnZpY2UtYWNjb3VudC1pYmVyaWFfd2ViIiwiY2xpZW50QWRkcmVzcyI6IjE3Mi4yMS4yNTUuOCIsImNsaWVudEhvc3QiOiIxNzIuMjEuMjU1LjgiLCJjbGllbnRJZCI6ImliZXJpYV93ZWIifQ.jBPU5jYTx9J_3_STXpF9rXSluYhrqh7gxaZYH2nb-aMulQIKw-ElSG_VeI5WWvcsMwrMDUKS4DtFWMkXkmnMxw"); headers.put("Accept-Language", "es-ES"); return builder.given("get request") .uponReceiving("send get request") .path("/api/v1/locale/supported") .method("GET") .headers(headers) .willRespondWith() .status(200) .body(LambdaDsl.newJsonBody(o -> o .stringType("language", "es") .stringType("country", "ES") ).build()) .toPact(); }```

juanma97perez
2020-02-03 11:28
But, when I run this test I have the next error: java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[PartialMismatch(mismatches=[HeaderMismatch(headerKey=Accept-Language, expected=es-ES, actual=, mismatch=Expected a header 'Accept-Language' but was missing), HeaderMismatch(headerKey=Authorization, expected=Bearer eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJiNzkyMDAxNS01NjExLTQ5NWEtYjA2MS0wNmZkNWM5NGJiNTAiLCJuYmYiOjAsImlhdCI6MTU2NTY4MDU5NywiaXNzIjoiaXNzdWVyX2IiLCJhdWQiOiJpYmVyaWFfd2ViIiwic3ViIjoiMjBlYWI1ZjAtMjE0Yy00NDJlLWE3ODktODhmYzdkNzgzZmM4IiwidHlwIjoiQmVhcmVyIiwiYXpwIjoiaWJlcmlhX3dlYiIsInNlc3Npb25fc3RhdGUiOiJiZDlmZGVjYS0yYTVmLTQ1OTYtYTQ5MC01Zjc2MTUxMDkyOTEiLCJjbGllbnRfc2Vzc2lvbiI6ImJmOWRjOTRhLTcxZjAtNDViNS1iY2M4LTNkNzFiMmNmYzM0YSIsImFsbG93ZWQtb3JpZ2lucyI6W10sInJlYWxtX2FjY2VzcyI6eyJyb2xlcyI6WyJST0xFX1JFVFJJRVZFX0RFTEFZRURfQkFHX1JFVElSRURfUkVDT1JEIiwiUk9MRV9DUkVBVEVfQ0xBSU0iLCJST0xFX0NMSUVOVF9XRUIiLCJST0xFX09STSIsIlJPTEVfQlBNIiwiUk9MRV9QTVQiLCJST0xFX0FWTSIsIlJPTEVfTE9DIiwiUk9MRV9SRVFVRVNUX0dDX0JBR19DTEFJTSIsIlJPTEVfQ0hFQ0tfUElSU1RBVFVTIiwiUk9MRV9BRFZNIiwiUk9MRV9SRVFVRVNUX1NVUFBPUlRfQ0FMTCIsIlJPTEVfUFJNIiwiUk9MRV9GQVNTIiwiUk9MRV9DVVNUIiwiUk9MRV9QQUNDIiwiUk9MRV9SRVRSSUVWRV9EQU1BR0VEX0JBR19SRVRJUkVEX1JFQ09SRCIsIlJPTEVfQVBJTSIsIlJPTEVfUkVUUklFVkVfREVMQVlFRF9CQUciLCJST0xFX1NFQVRTIiwiUk9MRV9SRVRSSUVWRV9EQU1BR0VEX0JBRyIsIlJPTEVfU1JWIiwiUk9MRV9HRVRfQ0xBSU1fU1RBVFVTIiwiUk9MRV9VU0VSIiwiUk9MRV9FVEVSTkFMIiwiUk9MRV9JTVBFUlNPTkFUSU9OIl19LCJyZXNvdXJjZV9hY2Nlc3MiOnsiYWNjb3VudCI6eyJyb2xlcyI6WyJ2aWV3LXByb2ZpbGUiLCJtYW5hZ2UtYWNjb3VudCJdfX0sImVtYWlsIjoic2VydmljZS1hY2NvdW50LWliZXJpYV93ZWJAcGxhY2Vob2xkZXIub3JnIiwibmFtZSI6IiIsInByZWZlcnJlZF91c2VybmFtZSI6InNlcnZpY2UtYWNjb3VudC1pYmVyaWFfd2ViIiwiY2xpZW50QWRkcmVzcyI6IjE3Mi4yMS4yNTUuOCIsImNsaWVudEhvc3QiOiIxNzIuMjEuMjU1LjgiLCJjbGllbnRJZCI6ImliZXJpYV93ZWIifQ.jBPU5jYTx9J_3_STXpF9rXSluYhrqh7gxaZYH2nb-aMulQIKw-ElSG_VeI5WWvcsMwrMDUKS4DtFWMkXkmnMxw, actual=, mismatch=Expected a header 'Authorization' but was missing)])])

matt.fellows
2020-02-03 11:29
whoah, can you maybe format that correctly and also move to the laguage specific channel? (looks like #pact-jvm )

juanma97perez
2020-02-03 11:29
I don't understand, because, I'm only send a headers, not compare

juanma97perez
2020-02-03 11:29
without headers, run perfectly

juanma97perez
2020-02-03 11:29
Okay,

matt.fellows
2020-02-03 11:30
thx

matt.fellows
2020-02-03 11:31
the error looks clear to me though - the header `Accept-Language` is not present in the http request that your code sends

dalves
2020-02-03 15:55
has joined #general

dalves
2020-02-03 15:59
In your documentation, you make the following statement, "Something that could be useful, however, is to generate skeleton Pact test code from a Swagger document. If you're interested in working on this, have a chat to the maintainers on the Pact Slack." I am interested in finding your recommended way of doing this. Can you please help me?

tjones
2020-02-04 05:12
We don?t have a recommended way of autogenerating Pact test code from a Swagger document

tjones
2020-02-04 05:13
it?s challenging because an API spec is not the same as a contract (although they?re related)

tjones
2020-02-04 05:15
A lot would depend on exactly what is written in your spec - probably an ideal tool to convert a spec into a pact skeleton would have several configuration options

ihor.dobrovolskyi
2020-02-04 08:51
has joined #general

juanma97perez
2020-02-04 09:04
Hi

juanma97perez
2020-02-04 09:04
In version 3.6.0 of jvm-consumer-java8_2.11 not recognize PactProviderRuleMk2 and PactVerification

juanma97perez
2020-02-04 09:04
What happens??

matt.fellows
2020-02-04 09:42
Can you please ask in #pact-jvm?

ihor.dobrovolskyi
2020-02-04 09:52
Hello! I want to implement contract testing to my product. We have microsecvices archtecture. But after researching and creating a POC for developers, they told me that they do not want to write a code for pact file generation :slightly_smiling_face: But I cann't find any solutions for that. Can you help me with it please?

matt.fellows
2020-02-04 10:05
If you can find a solution we?d all be very interested. That sounds like Pact v2


simon.nizov
2020-02-04 10:09
@ihor.dobrovolskyi How is the team currently writing unit tests for the API clients in their services?

ihor.dobrovolskyi
2020-02-04 10:12
They are mock routes without startup an app

simon.nizov
2020-02-04 10:15
mock routes?

simon.nizov
2020-02-04 10:15
can you provide an example?

ihor.dobrovolskyi
2020-02-04 10:17
```Then("successfully created") Post(s"/limits/$uuid/deposit", HttpEntity(ContentTypes.`application/json`, LimitRequest(DefaultDuration, TotalDefaultAmount).asJson.printWith(Printer.noSpaces))) .withHeaders(operatorHeader) ~> comp.paymentLimitRoute ~> check { status shouldEqual StatusCodes.OK```

matt.fellows
2020-02-04 10:24
how do you ensure that the consumers of the APIs are in sync? End to end tests?

matt.fellows
2020-02-04 10:24
Sorry if that came across brash, it wasn?t intended.

matt.fellows
2020-02-04 10:25
This article has some tips on getting buy in from your colleagues

matt.fellows
2020-02-04 10:25
if they don?t see/feel the pain, it?s hard to get them acress

matt.fellows
2020-02-04 10:25
Pact is work, but it?s just visible work. Issues/incidents/bug fixing is less visible, but more painful and expensive

matt.fellows
2020-02-04 10:25
you need to make those things visible, and then writng some tests becomes an obvious answer

simon.nizov
2020-02-04 10:28
@ihor.dobrovolskyi If the team is already writing unit tests for the API clients and use mocks to define the expected response from the API, that?s exactly the process needed to create the pact json, just with a slightly different DSL. Unlike your current process however, Pact actually verifies those same expectations against the API makes sure everyone is on the same page.

simon.nizov
2020-02-04 10:29
maybe that?s an argument you can use in favor of pact

matt.fellows
2020-02-04 10:36
nice one Simon

simon.nizov
2020-02-04 10:37
:sunglasses:

joseph.haig
2020-02-04 12:07
I have a pact with a service provider that returns JSON. There is a deprecated field that I, as the client, am going to stop using. If I just remove it from the expected responses will this cause the providers pact verify step to fail until they remove it at their end? Or is the expected response that I specify assumed to be a subset of the actual response?

simon.nizov
2020-02-04 12:13
The verification won?t fail. If the provider responds with extra data that is not included in the pact that?s fine, it will be ignored.

joseph.haig
2020-02-04 12:13
Thanks.

samuel.hodgkinson
2020-02-04 16:41
When the `Feature Support` page (https://docs.pact.io/feature_support) says `Pact specification v3 matchers` are not supported in some languages, but `Verify a pact that uses the Pact specification v3 format` is supported in all of them, does this mean that you can't verify a pact which uses v3 matchers using PactNET for example?

bernardoguerr
2020-02-04 18:10
For anyone interested, I will be giving a workshop on Pact at the European Testing Conference (https://europeantestingconference.eu/2020/topics/#bernardo-guerreiro). I aim to cover some of the more confusing topics like provider states, versioning and tagging, and will try to work from a realistic scenario!

bethskurrie
2020-02-04 19:50
It will read the format @samuel.hodgkinson but it will ignore the matchers it can't understand

bethskurrie
2020-02-04 19:50
Any new matchers introduced in v3

asteffey
2020-02-04 20:21
has joined #general

uglyog
2020-02-04 21:38
It was renamed to just PactProviderRule

abubics
2020-02-04 22:43
It's designed that way so you can make non-breaking changes :ok_hand: otherwise every added/removed field would be breaking :scream:

sagupta
2020-02-05 08:40
Hello, Will this be recorded by any chance to follow later ?

bernardoguerr
2020-02-05 08:41
Hey @sagupta I'm actually not sure, I will post something here if it is.

sagupta
2020-02-05 08:42
cool thanks :slightly_smiling_face:

samuel.hodgkinson
2020-02-05 09:42
Okay, because we got the following error when reading a v3 pact for verification (PactNet): ```/pact-win32/lib/vendor/ruby/2.2.0/gems/pact-support-1.12.0/lib/pact/matching_rules/v3/merge.rb:110:in `[]': no implicit conversion of String into Integer (TypeError)```

samuel.hodgkinson
2020-02-05 09:43
I'm guessing it's best to just not use v3 until all providers we use support it fully

justaburneremailforso
2020-02-05 10:37
Hello, has anyone here tried to use pact with Kafka and Java? I've done a little work with pact and http restful services but nothing with Kafka. With the restful tests, my pacts always returned a RequestResponsePact. Am I correct to think that for Kafka, my pacts should be returning a MessagePact type? Thanks.


wesleythomaswilliams
2020-02-05 10:53
Not yet, but I'll be starting this week or next.

uglyog
2020-02-05 12:01
Message Pacts were developed for that use case. Here is a blog post I wrote about it https://dius.com.au/2017/09/22/contract-testing-serverless-and-asynchronous-applications/

justaburneremailforso
2020-02-06 13:25
Thanks, been reading that. Are there any examples of how to do this in Java?

justaburneremailforso
2020-02-06 13:44
Btw the GitHub links towards the bottom of that blog are broken.

rafael.negron
2020-02-06 15:01
has joined #general

karl
2020-02-06 15:53
Hi guys, quick question. What is the difference between pact-js and pact-node?

karl
2020-02-06 15:53
Why would I use pact-node in a node.js instead of pact-js, are there any advantages?

matt.fellows
2020-02-06 21:12
Pact JS is almost certainly what you want if you?re writing tests

matt.fellows
2020-02-06 21:12
Pact Node is the engine it uses under the hood to do stuff with Pact libraries. It?s mostly implementation detail

matt.fellows
2020-02-06 21:18
I?ve just responded to your issue, thanks for reporting

sagupta
2020-02-07 14:41
@here I do have the same situation. Can anyone provide advice on what @paul.simms mentioned

sagupta
2020-02-07 14:42
@bethskurrie @matt.fellows

sagupta
2020-02-07 14:50
This is my case 1. Shows the entire flow from frontend (forms) till backend micro services 2. Shows what I feel about how I can perform contract testing .The frontend to GraphQL can be done using pact graphql connection and the graphql to backend connection can be contract tested just like normal REST api contract test

kulik.olenka
2020-02-07 20:56
has joined #general


bernardoguerr
2020-02-07 22:23
Here are the slides. But no recording, sorry!

bethskurrie
2020-02-08 09:49
I don't have any graphql experience @sagupta but that seems to make sense.

bethskurrie
2020-02-08 09:50
It should support the v3 format @samuel.hodgkinson. Could you raise an issue with the pact (you can redact the specifics) that caused the error?

matt.fellows
2020-02-09 11:47
I would treat graphql like any other BFF (that?s basically what it is). It isn?t a proxy, it presents a completely new abstraction over existing APIs.

matt.fellows
2020-02-09 11:48
I?ve used Pact with GraphQL before and it certainly wasn?t redundant. Both sides of the GraphQL layer are not resilient to breaking API changes

matt.fellows
2020-02-09 11:48
So aside from it having it?s own format, it?s the same as RESTful HTTP APIs

matt.fellows
2020-02-09 11:49
TL;DR - what you said :slightly_smiling_face:

matt.fellows
2020-02-09 11:49
@paul.simms sorry I missed this when you posted

sagupta
2020-02-09 11:52
So you mean the idea of contract testing frontend and graphql && graphql to backend APIs is the right way ?

matt.fellows
2020-02-09 20:30
Yep!

ahmadw
2020-02-09 20:52
has joined #general

ahmadw
2020-02-10 06:16
Hi, i am new to Pact using java. i am facing few issues regarding testing the contract with deployed service.

ahmadw
2020-02-10 06:18
this is my consumer-pact and i am getting mismatch exception.

ahmadw
2020-02-10 06:18
```package com.pact.actual.maven; import http://au.com.dius.pact.consumer.Pact; import http://au.com.dius.pact.consumer.PactHttpsProviderRuleMk2; import http://au.com.dius.pact.consumer.PactProviderRuleMk2; import http://au.com.dius.pact.consumer.PactVerification; import http://au.com.dius.pact.consumer.dsl.PactDslWithProvider; import http://au.com.dius.pact.model.RequestResponsePact; import org.junit.Rule; import org.junit.Test; import org.springframework.http.*; import org.springframework.web.client.RestTemplate; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; public class PactConsumerDrivenContractUnitTest { @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test-provider", "localhost", 8084, this); @Pact(consumer = "test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json"); return builder .given("test POST") .uponReceiving("POST Request") .path("/") .headers(headers) .method("POST") .body("{\n" + " \"otp\": \"566666\",\n" + " \"mobileNumber\": \"9715088833323\",\n" + " \"user\": \"CARD_DIGI_USER\",\n" + " \"originId\": \"AE\",\n" + " \"serviceId\": \"84\",\n" + " \"channel\": \"mobile\",\n" + " \"minutesToUnblockUser\": \"60\",\n" + " \"totalNumberOfRegenerationAllowed\": \"3\"\n" + "}") .willRespondWith() .status(200) .headers(headers) .body("{\n" + " \"data\": \"succeeded\",\n" + " \"responseStatus\": {\n" + " \"status\": 1,\n" + " \"description\": \"succeeded\"\n" + " }\n" + "}") .toPact(); } @Test @PactVerification() public void givenPost_whenSendRequest_shouldReturn200WithProperHeaderAndBody() { // when ResponseEntity<String> response = new RestTemplate().postForEntity(mockProvider.getUrl() + "/", "{\n" + " \"otp\": \"566666\",\n" + " \"mobileNumber\": \"9715088833333\",\n" + " \"user\": \"CARD_DIGI_USER\",\n" + " \"originId\": \"AE\",\n" + " \"serviceId\": \"84\",\n" + " \"channel\": \"mobile\",\n" + " \"minutesToUnblockUser\": \"60\",\n" + " \"totalNumberOfRegenerationAllowed\": \"3\"\n" + "}",String.class); // then assertThat(response.getStatusCode().value()).isEqualTo(200); assertThat(response.getHeaders() .get("Content-Type") .contains("application/json")) .isTrue(); assertThat(response.getBody()) .contains("{\"data\":\"succeeded\",\"responseStatus\":{\"description\":\"succeeded\",\"status\":1}}"); // and HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); String jsonBody = "{\n" + " \"data\": \"succeeded\",\n" + " \"responseStatus\": {\n" + " \"status\": 1,\n" + " \"description\": \"succeeded\"\n" + " }\n" + "}"; // when ResponseEntity<String> postResponse = new RestTemplate().exchange(mockProvider.getUrl() + "/", http://HttpMethod.POST, new HttpEntity<>(jsonBody, httpHeaders), String.class); // then assertThat(postResponse.getStatusCode().value()).isEqualTo(200); } }```

ahmadw
2020-02-10 06:18
and this is my provider: ```package com.pact.actual.maven; import http://au.com.dius.pact.provider.junit.PactRunner; import http://au.com.dius.pact.provider.junit.Provider; import http://au.com.dius.pact.provider.junit.State; import http://au.com.dius.pact.provider.junit.TargetRequestFilter; import http://au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.HttpTarget; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import com.pact.actual.maven.model.MavenApplication; import org.apache.http.HttpRequest; import org.junit.BeforeClass; import org.junit.runner.RunWith; import org.springframework.boot.SpringApplication; import http://java.io.Console; import java.util.Base64; import org.springframework.web.context.ConfigurableWebApplicationContext; import http://java.io.UnsupportedEncodingException; @RunWith(PactRunner.class) @Provider("test-provider") @PactFolder("target/pacts") public class ProviderEnd { @TestTarget public final Target target = new HttpTarget("https", "http://digital-dev.mashreq.com/api/otp-service/api/v1/otp", 8080,"/generate"); private static ConfigurableWebApplicationContext application; @TargetRequestFilter public void exampleRequestFilter (HttpRequest request) { request.addHeader("Authorization", "Basic T3RwVXNlcjpvdHBAMTIz"); request.addHeader("Content-Type", "application/json"); } private String base64StringOf(String username, String password) { return Base64.getEncoder().encodeToString((username + ":" + password).getBytes()); } @BeforeClass public static void start() { application = (ConfigurableWebApplicationContext) SpringApplication.run(MavenApplication.class); } @State("test POST") public void toPostState() { } }```

ahmadw
2020-02-10 06:19
i am verifying an OTP contract followed by an authorization header. plus it?s a POST service so request body is included as well.

ahmadw
2020-02-10 08:22
Or any deployed service example with java would be beneficial.

bethskurrie
2020-02-10 08:24
Please, firstly, ask in #pact-jvm, and secondly, it's best to create an executable example that someone can clone and run in a docker container if you have a tricky code problem.

bethskurrie
2020-02-10 08:26
Just pasting a big block of code into slack is not the best way of getting help.

ahmadw
2020-02-10 08:26
okay sure, i will do that

matt.fellows
2020-02-10 11:48
So as noted on the SO answer, your API is up but is responding with a `404`. You need to find out why it?s returning a `404` instead of a `200`. Does it need some data setup before the request will work? The pact framework is currently executing the provider test, injecting the header and hitting your endpoint and then getting a response (as mentioned, I actually hit your API and got a 404 also).

matt.fellows
2020-02-10 11:49
If you need to setup data for the test, you may want to modify your `toPostState()` method to add data / state to the system under test

matt.fellows
2020-02-10 11:49
is there a reason why you can?t test it locally?

ahmadw
2020-02-10 11:49
i just check it, it is working

ahmadw
2020-02-10 11:49
i think i am missing request body

ahmadw
2020-02-10 11:50
but i am not able to insert body from consumer, is there any way to publish in pact?

matt.fellows
2020-02-10 11:51
Can you please share your pact file here?

me1015
2020-02-10 11:51
has joined #general

matt.fellows
2020-02-10 11:51
From what I can see, there should be a body in the request

ahmadw
2020-02-10 11:52
i put request body in the pact, but in assertion it is giving me mismatch error.

matt.fellows
2020-02-10 11:55
@ahmadw please share the pact file here (the generated file, not the source test)

matt.fellows
2020-02-10 11:56
let?s keep the chat here, to avoid polluting the general channel

matt.fellows
2020-02-10 11:56
:point_up: let?s carry on this in the thread i tagged you in

ahmadw
2020-02-10 11:56
yeah sure

ahmadw
2020-02-10 11:56
```{ "provider": { "name": "test-provider" }, "consumer": { "name": "test_consumer" }, "interactions": [ { "description": "POST Request", "request": { "method": "POST", "path": "/generate" }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "data": "succeeded", "responseStatus": { "description": "succeeded", "status": 1 } } }, "providerStates": [ { "name": "test POST" } ] } ], "metadata": { "pact-specification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.0" } } }```

ahmadw
2020-02-10 11:57
i want to include request body too that?s why i am having 404 error

ahmadw
2020-02-10 11:57
but not be able to generate in pact file

matt.fellows
2020-02-10 12:02
hmm strange. I?m not super familiar with the Java DSL, but i?m guessing something in the setup is wrong


matt.fellows
2020-02-10 12:02
I think you might want `PactDslJsonBody` instead of the string? But could be wrong about that

ahmadw
2020-02-10 12:05
let me check with this one.

me1015
2020-02-10 12:12
Hey everyone, I have a provider in JS and consumer in Java, working with both (*pact-jvm* and *pact-js*(and mainly *pact-provider-verifier*) I am missing some features that *pact-jvm* has implemented. Did anyone try to write the bindings to Java version rather than the ruby version from JS?

me1015
2020-02-10 12:13
It might be faster than trying to fix the *pact-provider-verifier*

matt.fellows
2020-02-10 12:22
Heya! Not yet, but we are working on integrating to a rust one instead. Much smaller footprint and had all the same features now.

matt.fellows
2020-02-10 12:23
We're still a few months away from that is say

matt.fellows
2020-02-10 12:23
I'd*

me1015
2020-02-10 12:24
That?s amazing, i didn?t check the rust version, but will do in a future. We?re trying to implement Pact now to our workflow and have a few small issues - do you still accept PR?s on the current versions?

samuel.hodgkinson
2020-02-10 17:15
Realised this was an issue with `pact-ruby-standalone` so I've raised the issue there: https://github.com/pact-foundation/pact-ruby-standalone/issues/44

matt.fellows
2020-02-10 19:28
Of course!

ahsan_bhai
2020-02-10 19:39
has joined #general

ahsan_bhai
2020-02-10 19:44
I was reading the Pact docs (btw, really good job at documenting it on the web). I stumbled upon this particular bit: https://docs.pact.io/best_practices/consumer#avoid-using-pact-for-tests-that-involve-the-ui My Question: Is it being advised here that we don't even have UI as a consumer? Or this particular part is saying not use Pact for UI as a provider? We have our UI calling other backend micro-services. In that case, we would want UI to be the consumer and those services to be provider. Is it something we should do?

matt.fellows
2020-02-10 19:52
Yes that's totally fine. A react front end is a typical consumer

matt.fellows
2020-02-10 19:52
What we're saying is that you shouldn't test the API by invoking a web form in and end to end style test

matt.fellows
2020-02-10 19:53
Your code should be modular and have a component that talks to APIs - test that bit. Then you're not coupled to running the test in a browser and not coupled to your UI components

matt.fellows
2020-02-10 19:54
See docs on this page for a visualisation https://docs.pact.io/5-minute-getting-started-guide

ahsan_bhai
2020-02-10 19:54
that makes sense! Thanks for clarifying @matt.fellows

ahsan_bhai
2020-02-10 20:00
Another question: This time about PactBroker: My use case for PactBroker is this: 1. Public read access. So pacts could be verified in local builds 2. Write access only from CI pipelines. I am achieving this currently by enabling authentication in PactBroker and storing credentials as environment variables in Jenkins. These credentials are retrieved in `build.gradle` using the environment variables. Something like this: ``` systemProperty 'pact.broker.username', System.getenv('PACT_BROKER_USERNAME') ?: "fake-user" systemProperty 'pact.broker.password', System.getenv('PACT_BROKER_PASSWORD') ?: "fake-password"```

ahsan_bhai
2020-02-10 20:02
I am currently accessing the pact broker credentials via annotation like this: ```@PactBroker( host = "${pact.broker.host}", port = "${pact.broker.port}", tags = "${pact.consumer.tag}", authentication = @PactBrokerAuth(username = "${pact.broker.username}", password = "${pact.broker.password}")```

ahsan_bhai
2020-02-10 20:05
My question: For some reason we need to have the `pact.broker.username` and `pact.broker.password` always set for the tests to run successfully. If I remove the `?: "fake-user"` and `?: "fake-password"` , the test fails and complains about user name and password not set. Why does it require username and password when it should be able to read the pacts as they are public read access.

antonello
2020-02-10 21:05
Are there any decks from more recent presentations that are not listed here? If I?m not wrong, @bethskurrie and @matt.fellows, you?ve delivered some presentations recently at meet-ups. https://docs.pact.io/getting_started/further_reading

bethskurrie
2020-02-10 21:07
Yes. If you look on slideshare, you'll find some from recent conferences.

matt.fellows
2020-02-10 21:10
Are you setting those properties to the empty string or omitting them completely? Perhaps there's validation on the property value

ahsan_bhai
2020-02-10 21:18
omitting them completely. I think empty strings might work. haven't tested them yet. It looks weird to have those settings set when you have public read. If I don't add the `authentication` attribute in the `@PactBroker` annotation then offcourse it works. But I have a case where I need to publish the results to broker in CI pipelines

matt.fellows
2020-02-10 21:20
I'll double check if I've done some that aren't public and if so publish and let you know. There's been a few targeted brown bags for local companies that we've done and might need cleaning to publish

matt.fellows
2020-02-10 21:21
Sounds like a validation thing. You're telling the annotation to expect credentials but not supplying them.

ahsan_bhai
2020-02-10 21:22
yeah. I guess I'll have to pass either empty string or just fake credentials (like I am doing now) to get around it. I don't want local builds to be able to publish results

matt.fellows
2020-02-10 21:23
Yeah that's normal and should be easy - don't let local builds know the credentials :laughing:

ahsan_bhai
2020-02-10 21:23
also, how do I fail the gradle build if publishing the results fail for some reason? Currently the publishing silently fails but doesn't fail the gradle build.

ahsan_bhai
2020-02-10 21:25
for e.g.: incase of invalid credentials to PactBroker, the log would say 401 Unauthorized. but the build would be successful

ahsan_bhai
2020-02-10 21:26
btw, I am using my own PactBroker instance.

2020-02-10 23:27
A new post has been created in *Feature Requests*

matt.fellows
2020-02-10 23:29
I?m not sure, are you swallowing the exit code or something? That might be best asked in #pact-jvm anyway

cfaisalm
2020-02-11 00:44
has joined #general

ahmadw
2020-02-11 07:02
```package com.pact.actual.maven; import http://au.com.dius.pact.consumer.Pact; import http://au.com.dius.pact.consumer.PactProviderRuleMk2; import http://au.com.dius.pact.consumer.PactVerification; import http://au.com.dius.pact.consumer.dsl.PactDslJsonBody; import http://au.com.dius.pact.consumer.dsl.PactDslWithProvider; import http://au.com.dius.pact.model.RequestResponsePact; import org.junit.Rule; import org.junit.Test; import org.springframework.http.*; import org.springframework.web.client.RestTemplate; import java.util.HashMap; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; public class PactConsumerDrivenContractUnitTest { @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test-provider", "localhost", 8084, this); @Pact(consumer = "test_consumer") public RequestResponsePact createPact(PactDslWithProvider builder) { Map<String, String> headers = new HashMap<String, String>(); headers.put("Content-Type", "application/json"); return builder .given("test POST") .uponReceiving("POST Request") .path("/") .headers(headers) .method("POST") .body(new PactDslJsonBody() .stringValue("otp", "56666") .stringValue("mobileNumber", "9715088833328") .stringValue("user", "CARD_DIGI_USER") .stringValue("originId", "AE") .stringValue("serviceId", "84") .stringValue("channel", "mobile") .stringValue("minutesToUnblockUser", "60") .numberValue("totalNumberOfRegenerationAllowed", 3) ) .willRespondWith() .status(200) .headers(headers) .body(new PactDslJsonBody() .stringValue("data", "succeeded") .object("responseStatus") .numberValue("status", 1) .stringValue("description", "succeeded") .closeObject() ) .toPact(); } @Test @PactVerification("test-provider") public void givenPost_whenSendRequest_shouldReturn200WithProperHeaderAndBody() { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); String jsonBody = "{\"data\":\"succeeded\",\"responseStatus\":{\"description\":\"succeeded\",\"status\":1}}"; // when ResponseEntity<String> postResponse = new RestTemplate().exchange(mockProvider.getUrl() + "/", http://HttpMethod.POST, new HttpEntity<>(jsonBody, httpHeaders), String.class ); //then assertThat(postResponse.getStatusCode().value()).isEqualTo(200); HttpHeaders httpHeader = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); String requestBody = "{\n" + " \"otp\": \"566666\",\n" + " \"mobileNumber\": \"9715088833328\",\n" + " \"user\": \"CARD_DIGI_USER\",\n" + " \"originId\": \"AE\",\n" + " \"serviceId\": \"84\",\n" + " \"channel\": \"mobile\",\n" + " \"minutesToUnblockUser\": \"60\",\n" + " \"totalNumberOfRegenerationAllowed\": \"3\"\n" + "}"; // when ResponseEntity<String> postResponse1 = new RestTemplate().exchange(mockProvider.getUrl() + "/", http://HttpMethod.POST, new HttpEntity<>(requestBody, httpHeader), String.class ); //then assertThat(postResponse1.getStatusCode().value()).isEqualTo(200); } }```

ahmadw
2020-02-11 07:03
java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[PartialMismatch(mismatches=[BodyMismatch(Map(channel -> mobile, minutesToUnblockUser -> 60, otp -> 56666, mobileNumber -> 9715088833328, totalNumberOfRegenerationAllowed -> 3, serviceId -> 84, user -> CARD_DIGI_USER, originId -> AE),Map(data -> succeeded, responseStatus -> Map(description -> succeeded, status -> 1)),Some(Expected a Map with 8 elements but received 2 elements),$,Some({

ahmadw
2020-02-11 07:03
This is the error i am getting, am i doing something wrong in assertions?

paul.white
2020-02-11 09:03
has joined #general

ileshdarji
2020-02-11 11:04
has joined #general

ahmadw
2020-02-11 12:08
```{ "provider": { "name": "test-provider" }, "consumer": { "name": "test_consumer" }, "interactions": [ { "description": "POST Request", "request": { "method": "POST", "path": "/", "headers": { "Content-Type": "application/json" }, "body": { "channel": "mobile", "minutesToUnblockUser": "60", "mobileNumber": "9715088833328", "originId": "AE", "otp": "56666", "serviceId": "84", "totalNumberOfRegenerationAllowed": 3, "user": "CARD_DIGI_USER" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "data": "succeeded", "responseStatus": { "description": "succeeded", "status": 1 } } }, "providerStates": [ { "name": "test POST" } ] } ], "metadata": { "pact-specification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.0" } } }```

ahmadw
2020-02-11 12:09
finally published the pact

matiass0003
2020-02-12 07:07
has joined #general

peter.mcintyre
2020-02-12 11:00
has joined #general

sagupta
2020-02-12 12:12
Hi people, A stupid question may be : What exactly is the need to use provider.verify(). What does it do? Anyway we are writing our tests which has assertions in it so what extra validation does this verify() method is doing? According to PACT JS ? ```validate the interactions you've registered and expected occurred // this will throw an error if it fails telling you what went wrong // This should be performed once per interaction test``` ?

davidmolinero.com
2020-02-12 14:21
Hi Folks, do you have any plans to fix this issue any time soon? `Pact verifier doesn't send DELETE requests with body correctly` https://github.com/pact-foundation/pact-ruby/issues/198

davidmolinero.com
2020-02-12 14:30
or a way to workaround it, I am currently using pact with nodejs

justaburneremailforso
2020-02-12 14:57
Hello, I'm looking at using the MessagePact class to create pact contracts for Kafka. I can get it to create the contract and return a message, however I'm not clear on how to test the message I get back. I can verify it's not null but I think ideally I'd want to verify the structure and/or data types in the message. Is there a way to convert/analyse the returned message? At present my contract just returns a MessagePactBuilder object with a body which is a PactDslJsonBody (is that correct?) and the body just contains a string and integer type. Thanks.

wesleythomaswilliams
2020-02-12 15:18
On the consumer side, you just need to validate that the complete message matches what you've specified e.g. https://github.com/DiUS/pact-jvm/blob/master/consumer/pact-jvm-consumer-junit5/src/test/java/au/com/dius/pact/consumer/junit5/AsyncMessageTest.java ``` PactDslJsonBody body = new PactDslJsonBody(); body.stringValue("testParam1", "value3"); body.stringValue("testParam2", "value4");``` ```assertThat(new String(pact.getMessages().get(0).contentsAsBytes()), is("{\"testParam1\":\"value3\",\"testParam2\":\"value4\"}")); } }``` As we're just interested in creating the contract for the provider and you control what the message looks like.

tomas.sakinis
2020-02-12 15:39
has joined #general

ryan.dens
2020-02-12 15:46
I ran into an interesting situation recently, and curious to hear about thoughts motivation. For context, I was using pact-jvm, but I found a test case which asserts this behavior in the pact-specification. 1. I modified an existing contract to support a new feature I was building, adding changing the expectations of the contract as necessary for the feature. 2. I implemented the feature in the consumer code until it was passing all of our tests. Part of implementing this feature included sending a new HTTP header to our API provider 3. My CI published the contract to our pact broker triggering a build in our provider to verify the changed contract, and the build failed. I looked at provider and consumer code alike and couldn?t figure out what was going wrong. Eventually I looked more closely at the contract that was being produced and noticed this contract was missing the header that I added in my client code in step #2. I added the header to the expectations of my contract and re-ran the test and it still passed. I (incorrectly) assumed this was a bug with pact-jvm, so I went about adding a test case to the pact-jvm-consumer project to reproduce my issue, when I stumbled across a test asserting the behavior that if the consumer sends a header that is not expected, the consumer test should still pass. I tracked the origin of the file to https://github.com/pact-foundation/pact-specification/blob/version-1/testcases/request/headers/unexpected%20header%20found.json This feels ideologically at odds with how I understand consumer driven contracts to work, but I realize that ideologies are often at odds with what people practically need. Have other people run into problems with this?

wayne.cavanagh
2020-02-12 16:35
has joined #general

me1015
2020-02-12 16:41
Nice, will have some in next weeks as we?re onboarding contracts! :slightly_smiling_face:

kyle.hammond
2020-02-12 17:13
During the setup of your test, you register with the mock server what URLs will be hit with what parameters, and what the server?s response will be. When you call `provider.verify()` the code asks the mock server if all of the URLs you registered were actually hit. This helps keep your tests to a minimum of setup and also ensures that your production code is hitting all of the endpoints you expect it to. Here is a more concrete example: 1. You set up the provider to expect URLs /foo and /bar to be hit and provide responses foo_response and bar_response respectively. 2. Your test code only hits /bar, and then asserts the things you want done with bar_response. 3. By looking at the tests you may think you?re testing /foo since you setup for that, but you?re actually not. `provider.verify()` would fail this test because /foo was not hit.

matt.fellows
2020-02-12 19:47
I think you referring to the breaking if postels laws for headers. If it was an attribute in the body it would have failed. I believe there was a good reason, albeit I can't recall at this moment why. Possibly because http clients often add extra headers that can't be controlled and we don't want those in the contract. But that's just a guess

matt.fellows
2020-02-12 19:48
Do continue to poke us if we don't get back to you quickly. Well support however we can

james.elsey
2020-02-12 23:07
has joined #general

ryan.dens
2020-02-12 23:14
> I believe there was a good reason, albeit I can?t recall at this moment why. Possibly because http clients often add extra headers that can?t be controlled and we don?t want those in the contract. But that?s just a guess That actually makes a lot of sense. I think this is not actually as bad as I initially thought. We aren?t capturing our http client header in our contract right now either and I?d rather not so I think that makes sense. Still learning all the concepts around postels law, thanks for the context!

ryan.dens
2020-02-12 23:15
some of our legacy APIs define important behavior defining things in the headers beyond the auth headers, which is a strange use case, so I think this is mostly on us

ryan.dens
2020-02-12 23:15
:thumbsup: thanks Matt!

sagupta
2020-02-13 07:45
Ohh so whenever provider.verify() is called ,then it checks if all the interactions created during setup are met or not

sagupta
2020-02-13 07:46
Is it then useful to call provider.verify() after each test.We could just call it after all tests as well,right ?

divyakiran
2020-02-13 15:09
has joined #general

adrian.deanda
2020-02-13 15:56
has joined #general

spencer.stewart
2020-02-13 16:46
has joined #general

pact501
2020-02-13 23:59
has joined #general

sumeshs572
2020-02-14 21:21
I see in doc how pact work it support HTTP and messages , curious to know is there any chance I can use it for SOAP web services ?

matt.fellows
2020-02-15 11:34
We don?t yet fully support XML matching across the libraries yet, although I believe Pact JVM and Rust have support for XML.

reverse9
2020-02-16 18:44
has joined #general

bethskurrie
2020-02-16 22:17
Just doing some diagrams for an advanced workshop, and thought I'd post them here for some feedback. This one shows the class involved in publishing pacts.

abubics
2020-02-16 22:29
"application that participants" -> "application that participates" :slightly_smiling_face:

bethskurrie
2020-02-16 22:29
ha!

bethskurrie
2020-02-16 22:29
thanks.

bethskurrie
2020-02-16 22:29
though, I just changed the text to `"Consumer" and "Provider" are roles that a pacticipant takes in a pact`

bethskurrie
2020-02-16 22:37
Verification results class diagram

bethskurrie
2020-02-16 22:50
Putting it all together

bethskurrie
2020-02-17 00:50
Tagging over time

baquinteros
2020-02-17 01:20
has joined #general

pvhau93
2020-02-17 02:08
has joined #general

2020-02-17 02:37
A post in *Feature Requests* has been marked as *under review*

2020-02-17 02:37
A new post has been created in *Feature Requests*

bethskurrie
2020-02-17 03:04
So... this diagram is technically a lie. But it's easier to understand than the technically correct ones.

bethskurrie
2020-02-17 03:17
I think this could be considered a business domain model, where as the first ones were class diagrams.

parveenbanu
2020-02-17 05:09
has joined #general

parveenbanu
2020-02-17 05:24
Hi, I got a request from my Lead to setup PACT for JS for our micro services

parveenbanu
2020-02-17 05:24
Can any one help me to do the same

parveenbanu
2020-02-17 05:25
i came all the documents related to that

parveenbanu
2020-02-17 05:25
But still need someone's help to setup it

abubics
2020-02-17 06:02
problem space vs solution space? :thinking_face:

abubics
2020-02-17 06:02
(I can't actually see the lines between the boxes in dark mode :P)

bethskurrie
2020-02-17 07:33
There are lines all over the place!

bethskurrie
2020-02-17 07:33
It is the liniest diagram ever.

bethskurrie
2020-02-17 07:36
@parveenbanu firstly, try the #pact-js channel. Secondly, please let us know what documents you have read. Thirdly, if you start by setting up a test microservice in a public github account, you'll find people will be able to help you much more easily than if you start with a closed source one. There's nothing more painful than someone copy pasting large quantities of code into the slack channel and just saying 'it doesn't work'!!!

matt.fellows
2020-02-17 09:34
There are examples in the pact-js repository, so I?d suggest starting there

matt.fellows
2020-02-17 09:34
there is also a workshop you can do in the repository to teach the concepts, that would be worth doing

matt.fellows
2020-02-17 09:35
Do you have access to the microservices code? Because the tests usually belong side-by-side with the code base

parveenbanu
2020-02-17 11:19
Hi Beth thanks for the link.

parveenbanu
2020-02-17 11:21
Hi Matt. I am from testing Background were i do API Testing with Postman. So management came up with this Contract Testing concept. so we choose PACT for that. I know how API Works and gone throw the 5 minutes guide for PACT and other pages over there.

parveenbanu
2020-02-17 11:22
I need to setup a prototype let it be public GITHUB account. may be once i understand the implementation i go for closed source

parveenbanu
2020-02-17 11:22
can anyone help me to set up that

parveenbanu
2020-02-17 11:23
primary set up would be fine. Later on i can build it up.

jonathan.ho
2020-02-17 13:36
has joined #general

dperez
2020-02-17 15:06
hi, will that workshop be available online later or any way to attend it online? I'm highly interested

koradrop
2020-02-17 15:57
has joined #general

yau.yik.shiung
2020-02-17 16:04
has joined #general

matt.fellows
2020-02-17 19:50
Possibly. We may publish the materials, but I'll make a note of it

matt.fellows
2020-02-17 21:23
Do you know how to write code in Node.JS and using tools like Mocha/Jest?

bethskurrie
2020-02-18 00:39
@parveenbanu typically, Pact tests are written by developers, or testers who are experienced in writing automated tests. See https://docs.pact.io/faq#who-would-typically-implement-pact Is your team lead aware of this?

parveenbanu
2020-02-18 04:21
@bethskurrie: I am from Automation Tester. Nothing is impossible. I can try writting the Code, if someone helps me up. API's are already developed by Developers and they are in JSON Format. Using that i need to develop Consumer and provider. IF anyone teach me to develop one set then i will make it.

parveenbanu
2020-02-18 04:21
@bethskurrie and @matt.fellows Please help me.

parveenbanu
2020-02-18 04:22
My API's are in Swagger.


matt.fellows
2020-02-18 06:53
There are examples in the Pact JS repository, can you use those as a basis? As noted above, the tests need to be written in the same repository as your API consumer (and provider, when you get to that). Forgive us if we don?t have the time to give everyone a personalised tutorial.

sagupta
2020-02-18 14:50
Hello people, So I got these questions from my team while giving a small demo of POC of PACT contract tests. I implemented a small API contract test between a consumer and a provider. I also used PACT broker and showed how can we use versioning and tagging to test consumer and provider. Also showed verification results being published back to PACT broker by provider. Now the questions: 1. Can you run PACT mock server in a docker container which can be used to execute calls and generate pact files. Currently I showed provider.setup() inside a test file and my team wants to know if we can do it more centrally? 2. Does Implementing contract tests means we have to get rid of existing integration tests with Postman? 3. Should PACT files be used for postman collections to execute integration tests? Can someone provide their inputs?Would like to know if they also came across such questions in their organisation.

bheemreddy181
2020-02-18 16:04
few of those will be answered from the thread here https://pact-foundation.slack.com/archives/C5F4KFKR8/p1578582397103600

bheemreddy181
2020-02-18 16:07
why do you want to run pact mock server in docker? pact mock server is pretty much unique for each provider service used in the consumer.

sagupta
2020-02-18 16:10
my team wants to run it inside docker as they feel , running it inside a docker with http server is much more realistic scenario in line with production. Also they would like to have one mock server (lets say pact server) for all consumers which will generate pact files

bheemreddy181
2020-02-18 18:56
your mock server is a provider from what I know you cannot have a single mock server for multiple providers

dperez
2020-02-18 21:36
Thanks @matt.fellows looking forward you are able to publish them

matt.fellows
2020-02-18 21:42
We discussed this yesterday, the current plan will be to publish them, sanitised of any customer specific items. We?ll share on Slack/social/docs.pact.io when the time comes

bethskurrie
2020-02-18 22:13
> IF anyone teach me to develop one set then i will make it. @parveenbanu we can help you with pact related things, but we can't teach you to develop over slack! You'll need to pair with a developer from your own company for this.

bethskurrie
2020-02-18 22:16
> running it inside a docker with http server is much more realistic scenario in line with production Contract testing is not about providing a realistic situation. It's about checking your requests and responses in an isolated environment.

bethskurrie
2020-02-18 22:16
> Also they would like to have one mock server (lets say pact server) for all consumers which will generate pact files

bethskurrie
2020-02-18 22:16
You can't do this.

bethskurrie
2020-02-18 22:16
Each mock service is only for one consumer.


bethskurrie
2020-02-18 22:17
> Can you run PACT mock server in a docker container which can be used to execute calls and generate pact files. Currently I showed provider.setup() inside a test file and my team wants to know if we can do it more centrally?

bethskurrie
2020-02-18 22:18
Yes, you can run the mock service in a docker container, however, it will increase the complexity of your tests, as the test framework is no longer able to manage the lifecycle of your mock service instances.

bethskurrie
2020-02-18 22:18
You would need to write custom code to start and stop each docker container, and you would need one docker container per consumer.


bethskurrie
2020-02-18 22:19
> Does Implementing contract tests means we have to get rid of existing integration tests with Postman?


bethskurrie
2020-02-18 22:20
> Should PACT files be used for postman collections to execute integration tests?

bethskurrie
2020-02-18 22:20
You could do this, for sure.

bethskurrie
2020-02-18 22:21
Would you be getting any extra benefit from it, over your existing tests though?

bethskurrie
2020-02-18 22:22
Using contract tests should mean that the boring "when I send this request, I get this response" kind of tests are already done. Your testers would now be better off spending their time on exploratory manual testing, rather than repeating existing automated tests.

2020-02-18 22:37
A new post has been created in *Feature Requests*

matt.fellows
2020-02-18 22:40
Anyone interested in Swagger + Pact, please discuss/vote on :point_up: and also consider joining #swagger-integration



bethskurrie
2020-02-18 22:43
The introduction of contract testing allows you to reduce your integrated and e2e tests - but how much they reduce them depends heavily on your situation. Some teams skip the integrated and e2e tests altogether, and some teams keep a smaller set that is focussed on the "business value" scenarios rather than the "is this request/response right" kind of scenarios.

bethskurrie
2020-02-19 03:04
I gave one of the first questions some more thought, and have a more detailed answer now.

bethskurrie
2020-02-19 03:04
Q. My team wants to run the application inside docker as they feel that running it inside a docker with http server is much more realistic scenario in line with production. A. Contract testing is not about providing a realistic situation. It's about testing your requests and responses in focussed way, isolating the application under test from causes of failure that are unrelated to the contents of the requests and responses (eg. networking issues, deployment problems, race conditions, downstream service unavailability) The types of tests that are about providing realistic situations are end-to-end tests, smoke tests, canary tests, performance tests etc. Incidentally, these types of tests are really bad at checking request/response correctness because their scope is so broad, it's hard to tell exactly what has gone wrong when something fails.

parveenbanu
2020-02-19 05:01
@bethskurrie Sure Beth. I will develop one set of Consumer JS script with my developer and then will come back to you

parveenbanu
2020-02-19 05:01
Anything else i need to have before starting pact.

bethskurrie
2020-02-19 05:02
I'd recommend reading the docs thoroughly, as they really will help. Even if you don't take everything in, at least you'll have a better idea of where to go when you have issues.

bethskurrie
2020-02-19 05:02
Look at the examples in the pact-js github repository.

parveenbanu
2020-02-19 05:03
The example throwing me error. Tried yesterday.

parveenbanu
2020-02-19 05:03
something like this

parveenbanu
2020-02-19 05:03
npm update check failed ? [0] ? Try running with sudo or get access ? [0] ? sudo chown -R $USER:$(id -gn $USER) C:\Users\parveenbanu\.config

bethskurrie
2020-02-19 05:03
:thinking_face:

bethskurrie
2020-02-19 05:03
Well, that's a good place to start!

bethskurrie
2020-02-19 05:04
I'd put that into stackoverflow

bethskurrie
2020-02-19 05:04
nothing to do with pact.

bethskurrie
2020-02-19 05:04
it's about your local machine and your npm set up.

parveenbanu
2020-02-19 05:04
And saying CI=true is not recognised

parveenbanu
2020-02-19 05:04
consumer@0.1.0 test C:\GIT Samples\pact-workshop-js-master_New\consumer > CI=true react-scripts test 'CI' is not recognized as an internal or external command, operable program or batch file.

parveenbanu
2020-02-19 05:05
Okie

parveenbanu
2020-02-19 05:05
checking on that. and also working on Javascript to call our existing API

parveenbanu
2020-02-19 05:05
once the script is ready i will insert the Pact sets into it..

bethskurrie
2020-02-19 05:05
I'd start with making sure the examples worked properly before trying your own stuff.

parveenbanu
2020-02-19 05:06
and see weather the Contract file is generating or not

parveenbanu
2020-02-19 05:06
Yes

parveenbanu
2020-02-19 05:06
Example should work first

bethskurrie
2020-02-19 05:06
:thumbsup::skin-tone-3:

parveenbanu
2020-02-19 05:06
working on that.

parveenbanu
2020-02-19 05:06
:slightly_smiling_face:

parveenbanu
2020-02-19 05:06
thanks for the support Beth.

parveenbanu
2020-02-19 05:07
I will learn Pact soon:)

parveenbanu
2020-02-19 05:09
:nerd_face:

sagupta
2020-02-19 07:41
This is indeed what was looking for .Thanks Beth and bheem for detailed explanation .Let me mention these points to my team and see what they have to say

bethskurrie
2020-02-19 07:42
:thumbsup::skin-tone-3:

mail961
2020-02-19 07:44
has joined #general

dominik
2020-02-19 07:53
has joined #general

robin.vanwijngaarden_
2020-02-19 12:01
has joined #general

sumeshs572
2020-02-19 15:45
How we can make sure the matching rules are published in pact broker and exists from swagger , current the matching rules are not displayed in pact broker console any where thanks in advance

thomas.shipley
2020-02-19 17:44
has joined #general

matt.fellows
2020-02-19 21:07
what does ?exist from swagger? mean?

matt.fellows
2020-02-19 21:08
The matching rules are always published to the broker, what makes you think they aren?t?

sumeshs572
2020-02-19 21:09
Wanted to double check latest pact published have all matching rules

aorumbayev
2020-02-19 22:56
has joined #general

aorumbayev
2020-02-19 23:43
Greetings to all community members of Pact Foundations! :slightly_smiling_face: Is there a generic language-independent approach for using message pacts (async messages kafka and etc). Example scenario: ? Given 2 microservices implemented in Python and communicating via Kafka I would like to use pact for contract testings -> the pact-python implementation currently doesnt support v3 specs, are there any alternatives ?

bethskurrie
2020-02-20 00:03
I can't remember where the pact python impl was at.

bethskurrie
2020-02-20 00:03
See if someone knows on #pact-python

bethskurrie
2020-02-20 00:04
There's not heaps of work to be done, but it is conceptually tricky to understand how to implement it.

bethskurrie
2020-02-20 00:05
If you use the new UI, then you can expand the matching rules section to see them.

bethskurrie
2020-02-20 00:05
Otherwise you can view it in the Hal browser.

bethskurrie
2020-02-20 00:05
Copy the link of the Pact, click on the "api browser" button on the top right, and the paste the URL into the api location bar.

bethskurrie
2020-02-20 00:08
If you can't see the matching rules link, there aren't any.

sumeshs572
2020-02-20 00:29
New UI option I did not see I will confirm version of pact broker I am using

sumeshs572
2020-02-20 00:29
Thanks for the information :+1:

tausif2909
2020-02-20 04:47
has joined #general

sagupta
2020-02-20 13:57
Hello team, So i have been reading about using Docker to run PACT. And if i understand correctly, I need to use below docker images for tests: 1. Consumer tests : Stub server image (to run the mock server) + Docker CLI image (to add interaction, verify, publish pacts) + Actual consumer API image 2. Provider tests: Just Docker CLI image (verify provider against pact file) + actual provider API image Mock service docker image : Is deprecated now and docker CLI image be used instead. Can someone validate it ? And i would be using the JS implementation of PACT

bernardoguerr
2020-02-20 15:02
For the consumer and provider tests, you can use any Docker image with the appropriate install (in the case of Javascript, it just needs NodeJS). You can then install the dependencies you need to run your tests. For example, you would need to install @pact-foundation/pact, and that should suffice for consumer and provider tests

bernardoguerr
2020-02-20 15:03
You can of course create or use a dedicated docker image that has all these things installed already

matt.fellows
2020-02-20 15:03
I?m confused - didn?t this thread cover off why you should not do that? https://pact-foundation.slack.com/archives/C5F4KFKR8/p1582037442233700

matt.fellows
2020-02-20 15:04
In any case, running Pact in a docker as you described is going to lead you to a path where you basically have to re-build the DSL (e.g. the Pact JS, Pact Python, Pact go? interface) all again

matt.fellows
2020-02-20 15:05
It really is for advanced use cases, and normally where you don?t have a language already implemented to do it. If you are using one of the languages currently supported, you are far better off going down that path

sagupta
2020-02-20 15:05
From the thread , I got to know that running one mock server for all consumers is not an option. However after discussing with beth more , I would like to create one mock service per consumer (will manage its lifecycle myself) and thats why i went ahead to read more on pact docker part

matthew.salt
2020-02-20 15:06
has joined #general

bernardoguerr
2020-02-20 15:07
But why not let the mock service be created at runtime of the tests by the appropriate libraries? Why do you need to spin up the mock server separately yourself? Just wondering.

matthew.salt
2020-02-20 15:08
Hello, I have a question about using pact with junit5. I would like a single consumer test to generate a single .json file with multiple interactions. I want to define the RequestResponsePacts in several ?pact methods? rather than a single chained DSL to male it easier to maintain. Each time I?ve tried though I only get a single interaction in my consumer json file. And tips on how I might be able to achieve this?

sagupta
2020-02-20 15:09
Because we want to also ship it to other projects implemented in different languages while maintaining certain guard rails for pact

matt.fellows
2020-02-20 15:09
Can you elaborate on the guard rails? Perhaps it?s a feature request to the project rather than a bespoke thing you build (it may not be, just keen to understand)

matt.fellows
2020-02-20 15:09
(FYI I have to run - 2am here? but will follow up tomorrow)

wesleythomaswilliams
2020-02-20 15:11
Question about contract tests with messages. When building my pact in the consumer, I initially had: ``` return builder .given("the service creates an update message") .expectsToReceive("a service update") .withContent(body) .toPact();``` Then in my provider test, I had: `@State("the service creates an update message")` , which was where I though I'd be verifying the message. That failed, instructing me that I needed to use `@PactVerifyProvider("a service update")` as the place to verify the message. I've since added `@PactVerifyProvider` and taken out the `.given` from the pact builder in the consumer and the `@state` from the provider and the test is working fine, so I'm trying to work out if there's a case where I might need them for contract testing with messages, as in my rest based contract tests I rely on given and state?

wesleythomaswilliams
2020-02-20 15:11
I'd consider putting this in #pact-jvm

matthew.salt
2020-02-20 15:13
Good point. I?d come through to here on a link. I shall post there!

matthew.salt
2020-02-20 15:13
Thanks

sramakrishnan
2020-02-20 16:14
has joined #general

kyle.hammond
2020-02-20 18:50
Calling it after each test lets you know which test failed. Calling it at the very end of all tests would tell you that some test didn?t call all the things you thought, but you would not know which test was wrong.

bethskurrie
2020-02-21 01:57
@wesleythomaswilliams try in #pact-jvm. The general channel has people from all 10 languages.

bethskurrie
2020-02-21 01:58
Haha, just seen your comment above about asking in the pact-jvm channel :stuck_out_tongue:

matt.fellows
2020-02-21 02:00
:wave: anybody using Pact keen on showcasing their company on our websites (http://pact.io + http://pactflow.io)? We?re in the process of putting together some case studies now. If you are interested, we?ll be happy to pick up as much of the legwork as we can - e.g. interview you or send you a Q&A and then can author the post. DM me if you?re keen!

wesleythomaswilliams
2020-02-21 08:58
@bethskurrie Yeah, I wasn't sure if this was more of a general issue about writing tests for messaging or specific to pact-jvm quirk :grinning:

justaburneremailforso
2020-02-21 09:57
Hello, Am I looking to see if we can use pact where the consumer is receiving data through a Java API (packaged up as a jar file), as opposed to receiving it through a rest endpoint. I'm not sure what would be the correct approach here as it's not http/rest responses we are getting, it's just whatever data the API/jar sends back. I'm guessing our contract won't be RequestResponsePact or MessagePact contracts. Any ideas?

sagupta
2020-02-21 10:01
Based on the discussion with my team. We would like to run the consumer (GraphQL , APIs ) and the pact tests on one container AND pact mock server, mock service on another container.  Advantages that we foresee of this approach are: 1. We can easily maintain the mock server docker container 2. Reduced docker image size of the consumer 3. If any other team (other APIs) would like to run contract tests, all they need to do is to write the contract tests and define the ports for the mock server and use the mock server docker image as described above. This way we can establish guard rails to use PACT in our company. I might miss some context here as I am still exploring pact and may miss some details. I have also understood that we can also use the docker image of the pact implementation (PACT JS for example) to achieve this . So I would try to implement both cases and see what the differences are and what suits as per our company WOW.

uglyog
2020-02-21 10:16
How is the Java API receiving the request?

justaburneremailforso
2020-02-21 10:21
We just add the jar to our project, make a call to it and it returns the data. On the provider side it gets the actual data when requested from the API. The data returned can be a string or possibly a specific object.

matt.fellows
2020-02-21 11:58
Think of Pact as a unit testing framework. The mock server it uses under the hood is implementation detail of the framework, and not some architectural feature you should care about.

matt.fellows
2020-02-21 11:59
Your goal is to test the consumer code that makes a call, it _just so happens_ to make an external call to an API that we?ve mocked out. But you should really conceptually pretend as if this is not happening.

matt.fellows
2020-02-21 11:59
I?m not sure what you mean by ?guard rails? - do you mean this in a security sense?

matt.fellows
2020-02-21 12:00
my advice is keep things simple until you fully understand all of the pieces - Pact has some complexity, and you?ll easily get tangled and get no value from it (or lots of re-inventing the wheel)

matt.fellows
2020-02-21 12:01
Start by using the language bindings and get that humming. Then, if you?re still convinced you should run things in a docker container, you can try that too. I?m not seeing any good reason to do it the way your discussing, but i see a huge amount of work ahead of you. As I said before, this is a path to creating your own Pact interface - so any new enhancements/features we add to the library, you?ll have to re-implement yourself

matt.fellows
2020-02-21 12:03
To address your points: > We can easily maintain the mock server docker container What is so hard about installing an npm/java/xyz package? > Reduced docker image size of the consumer I personally don?t buy into image size very much. Temporary storage and network is cheap, the container should not become a runtime container. > If any other team (other APIs) would like to run contract tests, all they need to do is to write the contract tests and define the ports for the mock server and use the mock server docker image as described above. This way we can establish guard rails to use PACT in our company. You are glossing over the fact that _you_ will need to basically create a wrapper for the mock service (for each language you need), and now you are the vendor - not the community

bernardoguerr
2020-02-21 12:05
As someone who's seen the issues you may get in implementing Pact at large scale, I really second what Matt said. Pact does have complexity, the problem is the complexity in my opinion is not around the things that you're focusing on (the running of the tests). IMO, the hard parts are around other things like getting versioning/tagging right, understanding how to put it in CI/CD, how to trigger builds, how to use it to gateway deployments, etc. Actually running the tests is made trivial, with the mock server being provided for you by the language bindings, and they do provide quite a few language bindings, so it shouldn't be a big deal unless some of the languages in your org are not supported by Pact? So if you really want to show how it works, starting simple is a good idea. Over-engineering is really easy with these things, and nailing the fundamentals of how Contract Testing works with Pact is kind of important, before you start thinking of the implementation details.

sagupta
2020-02-21 12:18
Ok i understand your points both of your points and sense that i might land into implementing lot of complex stuff instead of getting value from contract tests. I will mention these points to my team again and will start with implementing the language bindings first.

paolaagudelo10
2020-02-21 16:32
has joined #general

paolaagudelo10
2020-02-21 18:55
hello people, i am starting to work with pact, want to ask if there is a way to make a test contract fail because of warn messages?

uglyog
2020-02-22 00:56
In that case you don't need contract tests, but it be good if the team that provides the JAR file also provides some tests for you to run in your build

uglyog
2020-02-22 00:58
A contract test fails if it ever gets a response that is not defined in the contract. Your example sounds like a valid response according to a contract. Maybe a different type of test is more suitable.

joeruello
2020-02-23 23:56
has joined #general

joeruello
2020-02-24 00:01
Hi everyone! We're getting started looking at pact this sprint. I was wondering if anyone is running pact on k8s and has a helm chart. I found one on GitHub but it doesn't seem to have a license or be published anywhere so at this stage we'll probally roll our own.


bethskurrie
2020-02-24 00:02
And welcome :wave::skin-tone-3:

joeruello
2020-02-24 00:03
:wave: thanks

greetbot
2020-02-24 00:20
has joined #general

2020-02-24 02:05
A new post has been created in *Feature Requests*

tjones
2020-02-24 02:06
^ Do we want that?

tjones
2020-02-24 02:06
I feel like that?s a feature rather than a problem

tjones
2020-02-24 02:07
I have seen teams complain, though

tjones
2020-02-24 02:07
Oh, this is what pending pacts solves?

bethskurrie
2020-02-24 02:07
Yes

bethskurrie
2020-02-24 02:07
Ask @uglyog if he wants it now :stuck_out_tongue:

bethskurrie
2020-02-24 02:07
(I broke his build the other day)

tjones
2020-02-24 02:07
haha!

tjones
2020-02-24 02:09
We had a project where I annoyed Victoria with this - she was on the task ?make pact verification pass? for some new features, but since it is quicker to implement tests than to fix verifications, the checklist kept growing

tjones
2020-02-24 02:09
feature branches or pending pacts would have avoided that problem

bethskurrie
2020-02-24 02:09
:thumbsup::skin-tone-3:

julian.pittas
2020-02-24 05:00
has joined #general

2020-02-24 05:00
Welcome @julian.pittas! :wave::skin-tone-3: Please check your direct message from our greetbot :smile:

matt.fellows
2020-02-24 06:08
Sorry for the Spam Julian - I think there is some testing going on with our welcome bot :slightly_smiling_face:

matt.fellows
2020-02-24 06:08
and also, hello :slightly_smiling_face:

naamam
2020-02-24 15:23
has joined #general

wesleythomaswilliams
2020-02-24 17:03
@matt.fellows As I get deeper into reading up on tagging and using can-i-deploy (which is all kind of frying my brain a bit). It seems to suggest making use of webhooks to trigger the provider's CI build when a change is detected in a pact published by the consumer service. With that in mind, what happens when the consumer and the provider are owned by different teams or even say a 3rd party. Would you expect a different team to be triggering CI builds for the provider service you own?

bernardoguerr
2020-02-24 17:25
Hey @wesleythomaswilliams! This topic is indeed the more confusing part of Pact. I know the question wasn't for me, but I'll attempt to help answer it, if that's okay :) Regarding 3rd party, Pact is technically not intended for that use case, precisely because you should have ownership of the services in order to be able to do things like triggering builds, as well as be able to communicate with teams, etc. Regarding consumer/provider being owned by different teams, the idea is indeed that a consumer could be able to trigger a provider's CI build. Which I understand may seem like a troubling proposition. Here's a couple of things about that: ? Some people prefer to run the verification as part of the consumer's CI, bypassing the need to trigger a provider CI build. Here's an example of that being done by the UK GOV: https://technology.blog.gov.uk/2019/01/29/lessons-learnt-using-contract-testing-in-gov-uk-pay/ ? The more traditional approach is to use the Webhooks on the Pact Broker to trigger the CI builds. In order to avoid problems with this, what I recommend is having dedicated steps for Pact in the provider's CI. In my opinion, the best way I've seen it done is to have 2 different steps on the provider CI: one for when they are verifying by running their own CI builds, and another step for when it gets triggered by a consumer's Webhook. This may help avoid some of the side effects you may be worried about. Additionally, you have to be really careful about understanding tagging and versioning right, because to have this flow truly working well, you need to be doing it well. In general, it is advised to be working with branches as tags , alongside with filtering on the verification (consumerVersionTag: read more here - https://github.com/pact-foundation/pact-js#verification-options) . This allows you to prevent the consumer from being able to truly break provider's builds, and for consumer and provider to work in parallel

wesleythomaswilliams
2020-02-24 17:29
Thanks Bernado, the 3rd party thing makes sense, but I'm expecting my team to "wig out" a bit over other teams triggering things in our CI. In terms of tagging, using the git sha as a tag seems to be suggested, but I've seen other references to also tagging with environments? So dev, pre-prod, prod. I'm trying to work out if that's overkill or pretty much necessary.

bernardoguerr
2020-02-24 17:42
The git sha is suggested for versioning. Versioning and Tagging are different concepts

bernardoguerr
2020-02-24 17:43
Imo tagging with the environment is not necessary, with the exception of *prod*. The main tags you want to have are, imo: ? feature branches (so you can distinguish between something that's in development or not) ? master ? prod (so you can check for backward compatibility when releasing a new provider/consumer)

bernardoguerr
2020-02-24 17:45
I ran a workshop on this topic recently, here are the slides (and there's a link to a github with multiple branches organised in order, where you can go through the commit history and see the progressive changes): https://www.slideshare.net/BernardoGuerreiro4/get-with-the-pact-gotchas-of-implementing-contract-testing-the-right-way-227294138 It might help, although without the workshop itself, it is of course not as rich a resource

bernardoguerr
2020-02-24 17:45
Hopefully I at least pointed you in the right direction, and of course, Matt and the Pact team will have better info than me to give :slightly_smiling_face:

bethskurrie
2020-02-24 19:11
You said it as well as I could @bernardoguerr!

bethskurrie
2020-02-24 19:13
Here's the docs for the "pact change kicking off the verification" https://docs.pact.io/pact_nirvana#d-configure-pact-to-be-verified-when-contract-changes

bethskurrie
2020-02-24 19:14
As Bernardo says, it's just the verification step, not the entire provider build.

bethskurrie
2020-02-24 19:27
If your team is going to wig out about pact changes triggering builds, they're going to be very upset about the idea that a pact verification failure can break their build as well.

bethskurrie
2020-02-24 19:29
You're either going to have to ensure your consumers strictly follow the recommend process for introducing changes https://docs.pact.io/pact_nirvana#5-allow-contracts-to-change-without-breaking-your-builds

bethskurrie
2020-02-24 19:30
Or, you're going to need to enable the "pending pacts" feature, which is not publicly released just yet.

abrinker
2020-02-24 19:35
has joined #general

bernardoguerr
2020-02-24 19:41
Beth, is that going to be available on the OSS version of Pact too?

djorgensen
2020-02-24 19:42
has joined #general

bethskurrie
2020-02-24 19:48
Here's the (similarly unreleased) blog post about it http://blog.pact.io/p/d7c9601f-e2ca-4208-b1c0-f02eaf96c3c2/

bernardoguerr
2020-02-24 20:13
Awesome, thanks for that! Great feature. One quick question, is the Pact Broker going to have a different colour or info associated when a Pact has failed verification but is in this pending state?


bethskurrie
2020-02-24 20:31
^^ I'd shared this post so many times in draft that I figured I may as well publish this post with a caveat to say it is still in beta.

matt.fellows
2020-02-24 21:33
I believe that's the plan. Or at least some visualisation to indicate that

bethskurrie
2020-02-24 21:34
Nope

bethskurrie
2020-02-24 21:34
Well - I haven't worked out how yet.

bethskurrie
2020-02-24 21:34
The problem is, the pending status is calculated based on the provider tags.

bethskurrie
2020-02-24 21:35
So a pact could be pending for 'master' tag, but not pending for 'feat/x' tag.

bethskurrie
2020-02-24 21:35
So may not be meaningful to show an overall 'pending' status.

bernardoguerr
2020-02-24 21:35
maybe the tags themselves could have colours?

bethskurrie
2020-02-24 21:35
It's the *provider* tag, not the consumer tag.

bethskurrie
2020-02-24 21:36
So, the 'feat/xyz' pact for a consumer may be pending for 'master' provider, but because it got verified on the 'feat/xxx' branch of the provider, it's not pending for that tag.

bethskurrie
2020-02-24 21:36
It needs a table to visualise!

bernardoguerr
2020-02-24 21:37
yeah I see what you mean

bernardoguerr
2020-02-24 21:37
not as straightforward as I had pictured it when I asked :sweat_smile:

bethskurrie
2020-02-24 21:37
At the moment, the broker doesn't know which the "important" tags are for each user. It's a feature we'd like to add though.

bethskurrie
2020-02-24 21:38
Then it would be easier to say, ok, you care about the "master" provider tag, we'll show you the pending status for the master tag.

matt.fellows
2020-02-24 21:39
Yeah I was going to say that. The tag model is super flexible, but the more I think about it the more I think it's the single most confusing thing to people. Starting to wonder if we need a new "promotion" model independent of tags :thinking_face:

matt.fellows
2020-02-24 21:39
Bbl afk

bernardoguerr
2020-02-24 21:40
that's funny you'd use the word flexible, I was just typing something saying that I think some of the confusion comes from how flexible it is

bethskurrie
2020-02-24 21:40
I did start work on a different API for doing "branches" and "deployments", but I overthought it and then backed it out.

bernardoguerr
2020-02-24 21:40
because when you give out examples for it, it's easy to lose sight of which ones are the tags that actually matter

bethskurrie
2020-02-24 21:40
I also wasn't sure about being too prescriptive about how we modelled peoples CI process.

bernardoguerr
2020-02-24 21:41
I think that's a good thing though

bernardoguerr
2020-02-24 21:42
For example when I was at DAZN we had a more obscure one (Drone), and if something was too "standardized", we might've had issues. I think keeping it flexible + good documentation for the most common examples is probably where it's at, imo

bethskurrie
2020-02-24 21:42
To be prescriptive, or flexible?

bernardoguerr
2020-02-24 21:42
Flexible

bernardoguerr
2020-02-24 21:43
but I guess both arguments

bernardoguerr
2020-02-24 21:45
I mean generally when I'm in a company I actually like some prescription, ie standardization, it takes away a lot of the headache. the whole workshop I gave was basically "make a standard for your company with naming conventions, versions, tagging, and apply it". But in this case I guess the onus of being prescriptive probably lies with the company trying to implement it, rather than the Pact team, otherwise you could risk alienating some uses.

bernardoguerr
2020-02-24 21:45
are you finding people generally give you feedback that they'd want it to be more standardized and less flexible ?

bethskurrie
2020-02-24 21:45
people generally don't want to have to think too much!

bethskurrie
2020-02-24 21:46
There's a big cognitive overhead with Pact.

bernardoguerr
2020-02-24 21:47
perhaps the two don't have to be mutually exclusive. you can probably keep the flexibility of the tags and think of some other API to cater to the 90% use-case in a more direct way

bernardoguerr
2020-02-24 21:47
but I guess that's what you were trying to do before :smile:

bethskurrie
2020-02-24 21:48
Yes, there's no reason why we'd have to remove the tag functionality if we also supported explicit branches/stages - except for the potential complication of code and documentation and making people have to choose between options!

bethskurrie
2020-02-24 21:49
It's something I've thought about for a long time, but haven't quite had the conviction to make the changes.

2020-02-24 21:53
A new post has been created in *Feature Requests*

bethskurrie
2020-02-24 21:53
I've added it as a potential feature - let's see what people say about it. https://pact.canny.io/feature-requests/p/support-explicit-branches-and-stages

bernardoguerr
2020-02-24 22:14
That sounds good! The only thing is that probably the people that will understand the value of this feature request are those that already understand the Pact workflow a little bit better. But still better than not knowing anything :smile:

bethskurrie
2020-02-24 22:14
Yes, its target audience is probably people who already understand tags!

jason_willis
2020-02-24 22:36
has joined #general


2020-02-24 23:39
A post in *Feature Requests* has been marked as *planned*

wesleythomaswilliams
2020-02-24 23:51
Thanks for the doc links Beth, I'd been reading them all day and trying to explain them to a team mate, while simultaneously not trying to tie myself in knots. I think my biggest problem is I end up looking for examples of how people have implemented things and that doesn't always make things clearer for me. Today that led me to this: https://kreuzwerker.de/post/integrating-contract-tests-into-build-pipelines-with-pact-broker-and

matt.fellows
2020-02-24 23:58
Ha, funny - I was on a call to them last night :slightly_smiling_face:

matt.fellows
2020-02-24 23:59
Kristine is apparently on maternity leave - but I?d love to meet and thank her one day!

bethskurrie
2020-02-24 23:59
It's very difficult to provide simple answers to how to integrate pact into your pipeline because everyone's pipelines are different.

matt.fellows
2020-02-24 23:59
yeah

bethskurrie
2020-02-25 00:00
You really have to have a good understanding of how tagging/can-i-deploy works so you can work out how to fit it into your own pipeline.

matt.fellows
2020-02-25 00:00
I was doing a talk at another local company recently, and their pipeline was also weird - for example, they had _multiple_ production environments

bethskurrie
2020-02-25 00:00
woah

matt.fellows
2020-02-25 00:00
It?s easy for us to say ?your pipeline is weird, you should change it?. But in most cases, there is so much inertia around pipeline design it?s almost impossible to change (at least in places big enough)

matt.fellows
2020-02-25 00:01
They were a services company - so they would deploy their application to tenant a, tenant b -> tenant x. But not always at the same time

bethskurrie
2020-02-25 00:01
interesting

matt.fellows
2020-02-25 00:02
They also often had to get external certification \ sign-off from their customers before promoting - so you can imagine how the pipelines could get a bit tangled

bernardoguerr
2020-02-25 00:15
Yeah we actually also kind of have the same issue with different tenant environments at Auth0. One of the reasons I said I don't think we were quite ready to implement it here yet

bernardoguerr
2020-02-25 00:15
It's definitely hard maintaining the balance between giving folks too much flexibility at the cost of ease of adoption VS catering to the mass :smile:

matt.fellows
2020-02-25 00:18
Interesting. Thanks for the insights!

2020-02-25 04:44
A new post has been created in *Feature Requests*

milanese.david
2020-02-25 04:48
has joined #general

daniel.paetzold
2020-02-25 08:14
has joined #general

naamam
2020-02-25 08:25
Hi there, I'm new with Pact (using c# language), wanted to know what is the Nuget package for PactDslJsonBody? This stackoverflow is what i'm searching for :https://stackoverflow.com/questions/60207882/is-there-any-way-we-can-only-validate-field-name-not-value-in-pact-json/60221333#60221333 but I don't have the right Nuget package. Can you help me please?

bethskurrie
2020-02-25 08:26
Hi @naamam. Try asking on #pact-net

bethskurrie
2020-02-25 08:27
Also, are you sure that example is .net? It looks more like java to me.

bethskurrie
2020-02-25 08:28
You've read all of this haven't you? https://github.com/pact-foundation/pact-net

matt.fellows
2020-02-25 09:22
Yeah, it?s definitely Java

matt.fellows
2020-02-25 09:23
(and no Nuget package for Pact JVM that I?m aware of!)

2020-02-25 09:25
A new post has been created in *Feature Requests*

dan.garland
2020-02-25 09:43
has joined #general

dan.garland
2020-02-25 10:23
Hi all, Pact user here (Ruby and JS), using in a corporate environment and finding it very useful, thanks to all the contributors! Right now we've got a setup that is approaching Pact Nirvana, and now the CTO has decreed we're all going to be using Kafka, so we're interested in the V3 progress and especially Ruby support. I found this repo which suggested I shoutout to @bethskurrie https://github.com/pact-foundation/pact-message-ruby/. I ought to be able to contribute code if there was enough feedback and direction if that helps. Would be good to know where things stand right now: 1. Can I use Pact tools to test Ruby provider/producer and consumers in a message setting? 2. Will the generated Pacts appear on our Pact Broker? 3. If not, what are the outstanding tasks? Is there a roadmap/issues that can help me understand what to do? 4. How can I contribute?

matt.fellows
2020-02-25 10:33
Hi Dan, thanks so much for the lovely feedback and offer to help - it is genuinely, very much appreciated!

matt.fellows
2020-02-25 10:33
You might also find https://docs.pact.io/feature_support useful

matt.fellows
2020-02-25 10:34
#pact-message-ruby is the channel to discuss adding message support to Ruby. It can?t be a huge effort to add, because it provides the functionality to Pact JS, Pact Go and Pact Python. So it?s probably just cleaning up the interface (i?m glossing over much of the detail I?m sure)

matt.fellows
2020-02-25 10:35
2) Generated pacts don?t currently appear in the OSS pact broker, but do show up in http://pactflow.io (we have a different presentation layer). It?s not a huge amount of work their I wouldn?t imagine

matt.fellows
2020-02-25 10:36
To answer (4) with respect to (2), you could take a look at the advice in this issue: https://github.com/pact-foundation/pact_broker/issues/127

matt.fellows
2020-02-25 10:36
hope that helps!

tomas.sakinis611
2020-02-25 11:00
has joined #general

naamam
2020-02-25 11:03
Yes, the example is java, I'm searching for the equivalent in c#. Can you help? what will be the class handling this?

naamam
2020-02-25 11:04
I want to only verify response fields name and type and not actual values (can changed)

naamam
2020-02-25 11:05
Thank you for your replies. Appreciate it

2020-02-25 14:04
A new post has been created in *Feature Requests*


a.konovalov
2020-02-25 15:50
has joined #general

manos
2020-02-25 16:22
has joined #general

mike.hamer
2020-02-25 23:06
has joined #general

mike.hamer
2020-02-25 23:09
Hello - Does anyone know of any available tutorials or examples of using Pact with Azure Functions?

bethskurrie
2020-02-26 06:28
Continued in #pact-message-ruby

ckkinay
2020-02-26 09:32
has joined #general

nerea.tamayo
2020-02-26 10:35
Hi one quick question about PactFlow, regarding plans?.the plans have different conditions about number of users, number of contract,support??.but what is number of user??I mean, one user is a project or each person?

nerea.tamayo
2020-02-26 10:38
I?m thinking about which plan is better for my company, we have a lot of different teams/projects, so if a user means each person, we need a big number of users, but if a user is each project and all members of the project are able to publish/verify and see the contract we need less users

nerea.tamayo
2020-02-26 10:39
I think user means consumer/provider, but I need to confirm it

matt.fellows
2020-02-26 10:54
Taken from https://pactflow.io/faq/ > We use a ?seat? based model, where you purchase capacity for how many Users you need and assign them as required. > > A user is considered any person or application that requires independent access to the system. For example, if you have two team members Sally and Billy that will be logging into the UI, as well as a separate dedicated CI user for automation, they will each consume one seat for a total of 3. > > Each user gets a read-only and read-write API token that can be used for automation (e.g. for use in CI or local verification testing). Each user is able to rotate these tokens as needed.

matt.fellows
2020-02-26 10:55
The consumer/provider pair is what we refer to as a ?contract? - they are unlimited

matt.fellows
2020-02-26 10:55
basically, our costs scale on the size of your team

nils.thenhausen
2020-02-26 13:08
has joined #general

dave_sharp_
2020-02-26 14:31
has joined #general

2020-02-26 21:45
A new post has been created in *Feature Requests*

2020-02-27 01:24
A new post has been created in *Feature Requests*

2020-02-27 05:25
A new post has been created in *Feature Requests*

2020-02-27 06:36
A post in *Feature Requests* has been marked as *complete*

2020-02-27 06:36
A post in *Feature Requests* has been marked as *closed*

paulg4321
2020-02-27 06:53
has joined #general

christopher.taormina
2020-02-27 18:45
has joined #general

bethskurrie
2020-02-28 01:23
Hey peeps. We've had some really good questions recently that aren't quite "frequently asked" but are good to record for posterity anyway. I've put them here: https://docs.pact.io/faq/question_archive

bethskurrie
2020-02-28 01:24
Feel free to contribute any more you think might be helpful. Slack is great, but because we're on the free plan, we lose good Q&As over time.

matt.fellows
2020-02-28 02:31
Awesome idea, thanks Beth

wesleythomaswilliams
2020-02-28 09:30
Has anyone integrated can-i-deploy into a jenkins/maven pipeline when using Pact Flow? I'm looking at using the docker that hosts it, but not sure on formatting of spinning it up and calling it. Our pipeline uses groovy files, so I have a stage that looks like: ```sh 'docker run --rm pactfoundation/pact-cli:latest ' + 'broker can-i-deploy ' + '-a ' + <service_name> + '-b ' + <broker_url> + '-e ' + <git_commit>``` This is my first time trying to modify a pipeline in this way, so all new to groovy, docker etc. Have been looking at these links for reference: https://hub.docker.com/r/pactfoundation/pact-cli https://kreuzwerker.de/post/integrating-contract-tests-into-build-pipelines-with-pact-broker-and https://pactflow.io/blog/deploying-your-microservices-with-confidence-using-can-i-deploy/ https://docs.pact.io/pact_broker/can_i_deploy

davidmolinero.com
2020-02-28 09:56
Hi, I am using pact-js `@pact-foundation/pact` and I have the following test in the provider side ```it("verifies contracts successfully", async () => { const providerVersionTag = process.env.PROVIDER_VERSION_TAG || ""; const options: VerifierOptions = { consumerVersionTag: process.env.CONSUMER_VERSION_TAG || "HEAD", pactBrokerToken: process.env.PACT_BROKER_TOKEN, pactBrokerUrl: process.env.PACT_BROKER_BASE_URL, provider: PROVIDER, providerBaseUrl: `http://${SERVER_HOST}:${SERVER_PORT}`, providerVersion: gitCommit, providerVersionTag: [gitBranch, providerVersionTag], publishVerificationResult: process.env.PUBLISH_VERIFICATION_RESULTS === "true", stateHandlers: { "order-123": save(order("123") } }; const verificationResult = await new Verifier(options).verifyProvider(); expect(verificationResult).not.toContain("Failures"); });``` The test itself is very poor since I am checking that the output that I am getting from the broker does not contain the ?Failures? string, this used to work well until recently, now the broker is not returning the entire output and it is only returning the following log entry `INFO: Fetching pacts for Provider from https://....http://pact.dius.com.au with the selection criteria: : latest for tag prod` the test is passing but nothing is verified? :sob::sob::sob::sob::sob:

davidmolinero.com
2020-02-28 09:57
Is there a better way to verify the contract, am I missing something?

wesleythomaswilliams
2020-02-28 10:12
Think I've got it

tyler.rasor
2020-02-28 13:00
has joined #general

karl
2020-02-28 13:29
Hey guys I'm confused as to how the pact files are written for consumer tests

karl
2020-02-28 13:30
I run run mocha which runs two tests files, in each of the tests files I create a new MessageConsumerPact, but it only seems to create only one of the pact files for one of the tests?

wesleythomaswilliams
2020-02-28 13:33
@karl If these are tests for a single service, is there a specific reason you have multiple test files and not multiple tests in one file? I've no experience with mocha and I'm using Java, but for any given service, I have multiple tests in one file.

karl
2020-02-28 13:33
Ah I have multiple services!

wesleythomaswilliams
2020-02-28 13:34
@karl and do these multiple services exist in the same git repo (or other src control repo)?

karl
2020-02-28 13:34
For example I have service A and B and C. Service A will be consuming things from B and C, so I've divided the tests into two files, each for consuming their own service.

wesleythomaswilliams
2020-02-28 13:35
@karl Ah gotcha, so you're writing tests for service A which is a consumer of B & C

karl
2020-02-28 13:36
I also need to create a new MessageConsumerPact because it states in there the "consumer" and "provider", it seems like the pact file is being overwritten, but I don't know why because the file name should be different

karl
2020-02-28 13:36
I'm expecting two pact files a-b.json and a-c.json

wesleythomaswilliams
2020-02-28 13:38
In java, our pact definition is headed by `@Pact(provider = "<provider_service>", consumer = "<consumer_service>")` and I believe the name of the pact is taken from those values.

karl
2020-02-28 13:38
Exactly, it's kinda the same in js, I have that at the top of each test also

wesleythomaswilliams
2020-02-28 13:40
@karl I assume in both test files you've set the provider value differently? The other thing we have in Java is the class is headed by `@PactTestFor(providerName = "provider_service", providerType = ProviderType.ASYNCH)` , which may be relevant.

karl
2020-02-28 13:41
exactly!

karl
2020-02-28 13:41
The sync things were easy to impliment but we are doing messages now, so it's slightly more of a headache heh

karl
2020-02-28 13:41
I have pact write mode set to update, so it should'nt be removing anything

wesleythomaswilliams
2020-02-28 13:42
I'll try and see if I can create a dummy second pact file with a fake 2nd provider to see if it works. Might help me work out out why it's not working for you.

karl
2020-02-28 13:46
The weird thing is, if I disable the first test then the second pact file is written

karl
2020-02-28 13:46
so it's as if, there is only one file allowed and that the other is being removed

wesleythomaswilliams
2020-02-28 13:47
Which might well be the case. If I do my test, it should hopefully prove that.

karl
2020-02-28 13:53
Yea i'm curious if you get two files, name of the file is made up of the consumer and provider names

wesleythomaswilliams
2020-02-28 13:59
Ok, tested, I managed to get two files created and the only thing I changed in the dummy second test file, was the provider service names.

karl
2020-02-28 14:51
Ah ok, thank you so much for testing

karl
2020-02-28 14:52
So it must be something in my environment then, like a setting

wesleythomaswilliams
2020-02-28 16:44
Either that or it's a JS specific Pact bug.

premanandc
2020-02-28 19:28
has joined #general

matt.fellows
2020-02-29 00:10
Yes, you should check for a rejected promise.

matt.fellows
2020-02-29 00:10
Does that not work?

matt.fellows
2020-02-29 00:13
Can you please share a redacted test for us? It should work the same as sync

matt.fellows
2020-02-29 02:17
Sorry was, been a while since I've used Jenkins. I recall interpolating environment variables inside shell inside groovy the DSL being a bit messy

matt.fellows
2020-02-29 02:17
Also, perhaps we should consider creating a Jenkins plugin for this? If so, should I raise a feature request?

erickoston
2020-02-29 08:01
has joined #general

davidmolinero.com
2020-02-29 17:52
the promise is not rejected, it is resolved

davidmolinero.com
2020-02-29 17:52
the problem is the output does not contain the full log

davidmolinero.com
2020-02-29 17:53
it just contain the first `INFO` line

matt.fellows
2020-02-29 20:09
Ok so if this is true it's a nasty bug. It should reject the promise and you should not have to do string analysis to determine the output. Can you please raise an issue so I can look into it?

matt.fellows
2020-02-29 20:28
See this PR I just put for Pact JS


matt.fellows
2020-02-29 20:29
```const res = new Verifier(opts).verifyProvider() return expect(res).http://to.eventually.be.rejected``` this test passes, in that the provider verification fails and returns a rejected promise

matt.fellows
2020-02-29 20:29
If you can help reproduce the issue above that?d be great, because it?s a worry if it can happen!

tomas.sakinis611
2020-02-29 20:45
Hi, i'm planning on using pact as a stub-server after I have all interactions in place. This is to speed up e2e tests, and at the same time make them more stable. The problem i'm facing right now is that one service is returning incrementing number in a response (ID for next request payload). App tracks that number, and expects it to increment with every request, otherwise it retries the request indefinitely. Do you have any insight how to handle such case?

uglyog
2020-02-29 23:50
The only mechanism I know of is the V3 generators that could do that, but you would need to use Pact-JVM and create the generator yourself

tomas.sakinis611
2020-03-01 10:12
I'm thinking about creating my own mock server, which would handle that specific case, and then validating pacts against both: mock server and provider service. Might be an overkill though...

davidmolinero.com
2020-03-01 14:16
Ok, I think I know what is going on here, I was using the `expect(verificationResult).not.toContain("Failures");` as a workaround of not getting back a rejected promise (I wasn?t aware of an existing bug)

davidmolinero.com
2020-03-01 14:16
If I understand correctly this PR https://github.com/pact-foundation/pact-js/pull/412/ contains a test that proves that there is a bug (not getting a rejected promise when the contract verification fails)

davidmolinero.com
2020-03-01 14:17
What I don?t understand, is that a few weeks ago, I was getting the entire log output of the verification result and now I am only one single line `INFO: Fetching pacts for Provider from https://....http://pact.dius.com.au with the selection criteria: : latest for tag`

davidmolinero.com
2020-03-01 14:18
This behavior has had to change recently

davidmolinero.com
2020-03-01 16:10
and since this behaviour has changed, the state handlers are not executed

davidmolinero.com
2020-03-01 16:13
I think there are 2 problems: ? There are situations in where a rejected promise should be returned and instead a resolved promise is returned ? Some behaviour has changed and since then the response from the `verifyProvider()` call does not contain the full output and the state handlers are not invoked

davidmolinero.com
2020-03-01 16:42
when I execute `npm run test:e2e-examples` in master branch the tests are not passing, I am getting this output

davidmolinero.com
2020-03-01 16:43
```[2020-03-01T16:40:26.214Z] DEBUG: pact-node@10.0.1/22879 on AdministorsMBP9: INFO: Fetching pacts for Animal Profile Service from https://test.pact.dius.com.au/ for tags: latest prod [2020-03-01T16:40:26.215Z] WARN: pact-node@10.0.1/22879 on AdministorsMBP9: Pact exited with code 1. 1) validates the expectations of Matching Service 0 passing (4s) 1 failing 1) Pact Verification validates the expectations of Matching Service: Error: Error reading file from https://test.pact.dius.com.au/pacts/provider/Animal%20Profile%20Service/consumer/Matching%20Service/version/1.0.1583080814```

matt.fellows
2020-03-01 19:37
Weird. Our builds are all green (look for tags and/or master) https://travis-ci.org/pact-foundation/pact-js/builds and I can't reproduce. There was a change to logging recently but it hasn't affected our builds or output that I can see. If you can help create a repro we'll be in it asap because it looks like everything has stopped for you!

davidmolinero.com
2020-03-01 19:44
I?ll try to create an example to reproduce it, but I am afraid I?ll have to do it outside the `pact-js` repo since the e2e tests that are there are not working for me

davidmolinero.com
2020-03-01 19:44
I won?t have time today, I?ll try to do it tomorrow

elliot.whiley94
2020-03-01 20:44
has joined #general

elliot.whiley94
2020-03-01 21:40
Hello :wave: My company is looking to gain better test coverage across our microservices, and I'm investigating to see whether Pact could be applicable for our use case. I've read through the docs and I'm specifically interested in the use of JavaScript and .NET libraries. It seems appealing as an alternative to maintaining large end-to-end tests which end up hitting multiple services and are brittle to changes. There are some questions I'd like some clarity around, any help/guidance appreciated. Posting in separate messages to make thread responses easier, thanks in advance! :slightly_smiling_face: 1. All calls out to one of our microservices first require an auth token from our auth server. So for example, an API call from consumer A to provider B, first requires a token from auth server C. I can see from the .NET docs an example which includes something similar (https://github.com/pact-foundation/pact-net/blob/master/Samples/EventApi/Consumer.Tests/EventsApiConsumerTests.cs#L106), but don't know how this works in practice. Could someone please go in to more detail about this, e.g. how will provider B verify that this token is valid.

elliot.whiley94
2020-03-01 21:40
2. To add to the above, we would like to test the process of getting an auth token from auth server C (e.g. consumer A calls auth server C to retrieve an auth token). So in this case we don't want to mock out the auth behaviour, how would this work?

elliot.whiley94
2020-03-01 21:40
3. How do Pact tests handle downstream dependencies? e.g. consumer A calls provider B, which calls downstream dependency provider D, which then calls other downstream dependencies provider E and provider F all within the same request. What would this Pact test looks like on both the Client and Server side at a high level?

elliot.whiley94
2020-03-01 21:40
4. We had a postmortem for a particular case where consumer A used a particular client library to call provider B. On shipping a change to B, the client calls from A were now invalid. We would like to pick up changes like these before shipping. I'm not sure if Pact helps here, as the way I see it currently is as follows: on new build of provider B version 2, pact tests are pulled from a broker for consumer A and run against provider B. However the requests replayed against B are just the plain HTTP requests and don't have the surrounding library calling and processing code, so I'm not sure if we would get the full test coverage we are looking for here.

batulrizvi
2020-03-02 01:27
has joined #general

hendrik
2020-03-02 08:12
has joined #general

hendrik
2020-03-02 08:14
Hey folks!

hendrik
2020-03-02 08:16
I'm running a MessageConsumerPact multiple times to produce variations of accepted payload. For some reason I always end up with a single object in `messages` array of the pact. And it's always the last variation I tested. My `pactfileWriteMode` is set to `update`. Is this expected behaviour? If I set the `pactfileWriteMode` to `merge`, then the pact file will be empty. No errors in console.

hendrik
2020-03-02 08:38
Ah, got it. It seems to be based on state. E.g each variation should have different provider state.

matt.fellows
2020-03-02 09:40
Yes, this applies to all Pact tests - you need to have unique keys so that they can be differentiated in the pact file

matt.fellows
2020-03-02 11:29
See https://docs.pact.io/provider/handling_auth. Generally speaking, you don?t want your tests to have to traverse multiple layers

matt.fellows
2020-03-02 11:30
I need to move this page, but the ?Scope of a consumer test? hopefully helps clarify this a bit: https://docs.pact.io/5-minute-getting-started-guide#scope-of-a-consumer-pact-test

matt.fellows
2020-03-02 11:31
You really just want to test the API collaborator in isolation of other antecedents (such as having had a valid bearer token). In your consumer test, just stub out the part of the system that has to fetch this, and on the provider side employ one of the above strategies

matt.fellows
2020-03-02 11:32
See step 7-9 in our JS workshop for an example of how to do this in JS: https://github.com/pact-foundation/pact-workshop-js/blob/step7/LEARNING.md

matt.fellows
2020-03-02 12:09
on my current client, particularly from service to service communication (in Go) we use client libraries and use Pact to protect against exactly this.

matt.fellows
2020-03-02 12:10
The trade off is that cliens aren?t fully abstracted from the HTTP requests, because they will need to know what the req/response over the wire looks like

matt.fellows
2020-03-02 12:10
for us, it?s totall yworth it

matt.fellows
2020-03-02 12:13
It?s a very common thing/question. Each consumer<->provider pair should be tested in isolation. It?s worth looking through http://docs.pact.io because lots of these questions are covered off

matt.fellows
2020-03-02 12:14
I would create a Pact test for the authentication that is _independent_ (i.e. produces a different contract and is not tied to) from the other APIs that also rely on that auth service

matt.fellows
2020-03-02 12:14
have contracts between all of the things that directly communicate, and stub out transitive dependencies


hendrik
2020-03-02 12:30
How am I supposed to verify Asynchronous API pacts? `pact.verifyPacts()` requires `providerBaseUrl` parameter as if I was testing HTTP API. I could also verify pacts while CI is running provider tests, but in that case `tags` property of `MessageProviderPact` is not respected and provider pact is verified against latest consumer pact, even if it doesn't have the correct... say environment tag.

jwojtowicz
2020-03-02 14:05
has joined #general

hendrik
2020-03-02 15:09
Ok, so it seems there are couple of gray areas: first off, `MessageProviderOptions` expects `tags` attribute, which is deprecated and thus is ignored. Secondly, why verification result is positive if it cannot find pact for certain tag? If you don't have anything to verify against, the result should be false IMO.

joel.whalen
2020-03-02 17:17
has joined #general

matt.fellows
2020-03-02 19:50
Can you please raise a bug? I'm look into ASAP

warren.bayek
2020-03-02 20:52
has joined #general

hank.mitsch
2020-03-02 21:42
has joined #general

avinash.eediga533
2020-03-02 23:36
has joined #general

avinash.eediga533
2020-03-02 23:37
Hey guys

avinash.eediga533
2020-03-02 23:38
Could any one please help me in setting up pact dir for in kotlin

matt.fellows
2020-03-02 23:38
#pact-jvm

avinash.eediga533
2020-03-02 23:39
Thanks @matt.fellows

shsamkit.shah
2020-03-03 00:52
has joined #general

shsamkit.shah
2020-03-03 00:58
Hi, I have a question regarding debugging pact-docker. I was able to configure it with docker-compose on my local and now trying to deploy it on company's private-cloud. Due to serveral network restrictions, it's not going as easy as it was on local. The last line of logs I can see is ```[ N 2020-03-03 00:48:30.4729 35/T5 age/Cor/SecurityUpdateChecker.h:519 ]: Security update check: no update found (next check in 24 hours)``` Nothing after that and I don't see the process running in the container either. Any suggestion on checking further/failure logs?

elliot.whiley94
2020-03-03 01:03
Thanks for all your responses @matt.fellows. Could you please clarify what you mean by this particular case? Are you saying you have the consumer client library code also running as part of the provider-side pact tests?

matt.fellows
2020-03-03 01:05
No, I mean the consumer Pact tests use the provided client library

elliot.whiley94
2020-03-03 01:08
Where `provided client library` is some 3rd party library used to make HTTP requests?

shsamkit.shah
2020-03-03 02:18
Nvm, the problem is fixed.

matt.fellows
2020-03-03 02:32
hmm, no they are internal client libraries built by other teams - are you referring to external APIs/clients? Perhaps you could elaborate further?

matt.fellows
2020-03-03 02:32
(sorry had to duck off after that last message)

matt.fellows
2020-03-03 07:06
What was the issue?

matt.fellows
2020-03-03 07:06
I was going to say, that last line (if no exceptions above it) meant that it?s all up and running. So it?s probably a port mapping / network thing

matt.fellows
2020-03-03 07:06
You can also look at http://pactflow.io if you don?t want to run/manage it yourself

deathangel908
2020-03-03 07:46
has joined #general

deathangel908
2020-03-03 07:54
Hello guys, https://stackoverflow.com/questions/60495511/how-to-use-pactjs-with-cypress. It seems like both of these libraries are starting to become very popular lately. What I came to atm is just using cypress task that runs pact http server in the background. But I believe for cypress case there's no need to even listen a port, since cypress has `route` API that allows to intercept/stub/proxy network. To do this we just need to exclude all the related code that requires node api, listening to a port etc. Unfortunately what I found yesterday is that pact is too tightly coupled and also depends on some `ruby` (WOT?) files that are necessity which makes me sad. It would be ideal that pact would run directly in browser purely abstracted from its underlying http-server/node_implementation. What do you think guys? I guess I can collaborate a bit.


bethskurrie
2020-03-03 07:56
Also, we're really keen to get pact and cypress integrated. It's something we've actually been discussing this week.

sergiy
2020-03-03 10:24
Hi there :wave:, we?ve implemented *pact-cypress* integration lib at our company and using it on a regular basis in our test suites. We?ve been talking about it and more here - https://www.youtube.com/watch?v=cs5ebVzG_Q4 at one of the testing meetups organized by SauceLabs. I had a short chat with @matt.fellows about it, and we were thinking about open sourcing our tooling, seems like folks here could be interested?

greg719
2020-03-03 10:40
has joined #general

matt.fellows
2020-03-03 10:50
Loving this thread - thanks for joining Andrew. I?d love to get on a call with you folks to understand this all better. I haven?t used Cypress, so don?t fully appreciate all of its goodness and how Pact might fit in

matt.fellows
2020-03-03 10:50
But, I?d love to.

matt.fellows
2020-03-03 10:50
Would you be up for it?

sergiy
2020-03-03 10:54
hey @matt.fellows, who? Us or Andrew? :slightly_smiling_face: I?m sure we can organise something

deathangel908
2020-03-03 12:02
@sergiy I don't have much time atm, to fully watch the conference, gonna check it later So the lib is not opened atm, I can't check the source code. The most interesting thing I'm curious whether you still run in in `node` env and listen for the port or you fully ported it to browser.

yousafn
2020-03-03 12:10
We use Cypress & Pact heavily, but we generate pact contracts from our code, and load these into a stub server hosted in docker, and run in an ECS cluster

deathangel908
2020-03-03 12:13
Lets move this to #cypress channel

sergiy
2020-03-03 12:27
@deathangel908 yes, it?s not public yet, we need to do some chore work, cause we prefer to release it properly. We have ported it as a cypress plugin

deathangel908
2020-03-03 12:28
anything I can help you with?

sergiy
2020-03-03 12:29
contribute when it?s released :wink: :grinning:

deathangel908
2020-03-03 12:30
ok, cool, any ETA?

sergiy
2020-03-03 12:32
I wish to give you one, but can?t say for sure, we just need to plan some time :man-shrugging: /cc @enrique

enrique
2020-03-03 12:44
I don?t think there will be any problems. Because it started as an internal project we need to change it a bit to make it ready for open source. I think mid 2020 is feasible.

hendrik
2020-03-03 14:31
What's the general practice.... using a single pact per Consumer - Provider or rather a single pact per API endpoint/Async message between Consumer and Provider?

bernardoguerr
2020-03-03 14:43
If pact means single contract file, then yes, the general practice would be a single contract between a consumer-provider pair (afaik)

hendrik
2020-03-03 14:48
I figured. Thanks

oleg.shuliak
2020-03-03 14:51
has joined #general

crajcan
2020-03-03 19:19
Does anyone use the pact_broker-cli on a Heroku web server? I'm thinking of creating a Heroku build-pack for pact_broker-cli so I can run `can-i-deploy` and `create-version-tag` from Heroku's "Release Phase", and I'm wondering if someone has done something similar, or if there is a better way to make the cli available on a Heroku web server.

matt.fellows
2020-03-03 20:42
Haven't seen that before. We have a docker container that has all of our tools on it tho, so that's an option too

matt.fellows
2020-03-03 20:43
The other thing to consider is that (at the moment) you need to separate the message pacts from the http pacts (the provider needs a different name). The pact broker doesn't yet support this

surajkeshri
2020-03-03 21:45
has joined #general

hendrik
2020-03-03 21:49
I actually solved it by passing `consumerVersionTag` instead of `tags` to `MessageProviderPact`. The interface at `options.d.ts` file should be still updated though.

hendrik
2020-03-03 21:53
Not sure if it's worth raising a bug.

hendrik
2020-03-03 21:53
If you think so, I'll do it in the morning

matt.fellows
2020-03-03 21:54
No dramas - i?ve almost completed the changes to support it (it?s just the TS types as you say that disallow it)

hendrik
2020-03-03 22:01
But maybe the part where pact with specific tag is not found needs discussion. It's debatable whether it should report as a success or not, but one should somehow know if provider tests passed since pact is really verified or because there's no pact at all with given tag.

matt.fellows
2020-03-03 22:16
There is a flag to control that behavior, it may not be exposed also. I'll add that to the Todo

tjones
2020-03-03 22:44
Would pact-web help here?

matt.fellows
2020-03-03 22:51
yes quite possibly. I?d like to fully understand/appreciate the nuances - but almost certainly there will need to be a server-side component to make this a reality. OR, we swap out the http engine (e.g. like nock does) and then serialise the results after into a Pact file

matt.fellows
2020-03-03 22:52
It would be ace if we could get the Rust thing working as web assembly, but that still has the dark arts smell about it

osirisnos4a2
2020-03-03 23:48
has joined #general

adam.strickland
2020-03-03 23:56
has joined #general

aserdyuk
2020-03-04 00:04
has joined #general

paulolai
2020-03-04 00:14
has joined #general

hendrik
2020-03-04 08:53
Any guidelines on how to to test custom messaging? Say I'm using Moleculer.js and need to test events exchanged between microservices.

simon.nizov
2020-03-04 09:36
I have a scenario where I have 2 services with 2 pacts between them (not interactions). One pact with service A as the consumer and service B as the provider, and another pact where it?s the other way around - service B is the consumer and service A is the provider. Everything works well except for the matrix page in the broker. When I go to the matrix page of each of the 2 pacts: ```https://mybroker/matrix/provider/A/consumer/B https://mybroker/matrix/provider/B/consumer/A``` In *both* of these cases the matrix table in the UI *always* shows A as the consumer and B as the provider. Along with the relevant version, tag, verification result etc. Has anyone encountered this before? Is this a bug on the broker?s end or am I doing something wrong?

wesleythomaswilliams
2020-03-04 09:48
I've not had to deal with a bidirectional relationship yet, but I will have to quite soon. I'll report in when I do.

matt.fellows
2020-03-04 10:02
What do you mean by custom, sorry? I'm not familiar with molecular

matt.fellows
2020-03-04 10:03
We don't actually support specific protocols (like amqp or stomp or whatever) - just the message exchange.

matt.fellows
2020-03-04 10:04
There was something on this recently. I can't remember the outcome tho but maybe try a quick history search?

simon.nizov
2020-03-04 10:10
@matt.fellows Can you remember any keywords other than ?matrix? that can help find it?

matt.fellows
2020-03-04 10:12
Gah, I tried a few but nothing showing up either. Might be past the history buffer :man-facepalming:

hendrik
2020-03-04 12:25
Ok. Would be cool if you interfaced the whole thing so people could write their own adaptions for various protocols or purposes.

jussi.saurio
2020-03-04 17:16
has joined #general

jagmeet_randhawa
2020-03-04 18:44
has joined #general

bethskurrie
2020-03-04 19:09
@294simon are you on the very latest version of the Pact Broker?

bethskurrie
2020-03-04 19:13
There are definitely test cases for bi directional pacts for can I deploy. I wonder if the rows for the second pact are being truncated by the row limit.

bethskurrie
2020-03-04 19:18
I can't replicate the issue myself.

simon.nizov
2020-03-04 20:44
@bethskurrie is it intentional that both directions are shown in the same matrix?

bethskurrie
2020-03-04 21:44
Yes

bethskurrie
2020-03-04 21:44
You can't deploy just the consumer portion of an application. You deploy it as an application, and it has a role as both a consumer and a provider. The URL that you used to get there is just a convenience for the real query.

bethskurrie
2020-03-04 21:46
You'll notice that the form details don't mention consumer or provider.


bitsurfing
2020-03-04 22:59
has joined #general

alex.yianni
2020-03-05 04:49
has joined #general

simon.nizov
2020-03-05 06:51
Yes that always bothered me :D

simon.nizov
2020-03-05 06:54
It's probably the order+row limit that's the problem then. One direction has thousands of builds/versions more than the other. Is it possible to order by date in the query? The column header only orders what's already on the page.

bethskurrie
2020-03-05 06:55
Pactflow or OSS?

simon.nizov
2020-03-05 06:55
OSS

bethskurrie
2020-03-05 06:55
Yes, but not without a code change.

bethskurrie
2020-03-05 06:56
The best way for you to see results now is to put in the version numbers you care about.

bethskurrie
2020-03-05 06:56
It will be sorting by consumer name, then provider name, then date

bethskurrie
2020-03-05 06:56
You need it to sort by date, the consumer/provider

bethskurrie
2020-03-05 06:58
I can change the code and put out a release, but it'll have to be tomorrow.

simon.nizov
2020-03-05 07:04
That'll be great! No rush :blush:

smilewithvammy
2020-03-05 09:09
has joined #general

davidmolinero.com
2020-03-05 09:26
I can?t reproduce the problem anymore, I am getting the full log now and the state handlers are executed?

davidmolinero.com
2020-03-05 09:26
but this was definitely not working for me over the weekend

matt.fellows
2020-03-05 10:34
:man-shrugging:

matt.fellows
2020-03-05 10:34
weird

matt.fellows
2020-03-05 10:35
sorry I wish I could tell you more. I don?t think we?ve released anything recently that would affect that

tainguyen
2020-03-05 11:21
has joined #general

tainguyen
2020-03-05 11:24
hello

tainguyen
2020-03-05 11:26
I would like to send a POST request, where the request body get value from provider state However I am facing the issue: The request body content is escaped after it is rebuilt by using value injected from provider state https://github.com/DiUS/pact-jvm/issues/1031 Does anyone help me to solve this problem?

tainguyen
2020-03-05 11:26
Thanks alot

matt.fellows
2020-03-05 11:29
#pact-jvm

zshahnan
2020-03-05 12:23
has joined #general

davidmolinero.com
2020-03-05 13:09
thanks anyway, I?ll keep an eye on it

chakravarthi.sara
2020-03-05 15:12
has joined #general

jarmy
2020-03-05 16:33
has joined #general

reemadhiman92
2020-03-05 19:25
has joined #general

2020-03-05 21:52
A new post has been created in *Feature Requests*


bethskurrie
2020-03-05 21:53
Give it a vote if you're keen @hendrik

bethskurrie
2020-03-05 22:17
Peeps who are using the Pact Broker/Pactflow, if you're looking for a high level list of the tasks that need to be done to integrate your CI with a broker, there's a checklist here: https://docs.pact.io/pact_broker/set_up_checklist

hendrik
2020-03-06 07:45
Done

sjdl
2020-03-06 11:07
has joined #general

labardinim
2020-03-06 15:12
has joined #general

phil.brock
2020-03-06 19:17
has joined #general

regi24
2020-03-06 22:06
has joined #general

dashrath.mundkar545
2020-03-07 15:38
has joined #general


dashrath.mundkar545
2020-03-07 15:45
any solution guys? anyone using pact broker behind keycloak proxy?

bethskurrie
2020-03-08 21:58
Only basic auth and bearer tokens are supported @dashrath.mundkar545

abhi358
2020-03-09 01:03
has joined #general

dashrath.mundkar545
2020-03-09 07:41
do I have to include bearer token on pact container as ENV variable?

dashrath.mundkar545
2020-03-09 07:42
if possible could you provide me example??

bethskurrie
2020-03-09 07:49
Sorry, I mean the pact clients only support basic auth and bearer tokens.

bethskurrie
2020-03-09 07:49
The oss pact broker only supports basic auth

bethskurrie
2020-03-09 07:50
The bearer token code was written to support http://pactflow.io

dashrath.mundkar545
2020-03-09 07:50
Okay

dashrath.mundkar545
2020-03-09 07:51
I looks like kaycloak and basic auth is not working together

bethskurrie
2020-03-09 07:51
I don't know how keycloak works for protecting an api unfortunately.

bethskurrie
2020-03-09 07:52
My gut feel is that what you're trying to do is probably not possible.

dashrath.mundkar545
2020-03-09 07:53
Yes

dashrath.mundkar545
2020-03-09 07:54
what I did is that I allowed basic auth on conatiner and I also added keycloak for browser based login? but it gives me 400 error

bethskurrie
2020-03-09 07:54
Pactflow allows you to have different auth for the UI and the API but we've been able to do that only by separating those concerns at the code level.

bethskurrie
2020-03-09 07:54
From the outside, I can't see how it could be done.

dashrath.mundkar545
2020-03-09 08:06
okaz

karl
2020-03-09 10:02
Update from my side! It had to do with the library and how it handled paths, it's not documented very clearly!

karl
2020-03-09 10:02
But now it works hah!

karl
2020-03-09 10:03
So thanks for your help

wesleythomaswilliams
2020-03-09 10:15
:+1:

karl
2020-03-09 10:28
Hey guys! I'm wondering about the pact write mode: Update, Overwrite and Merge. We have it setup so that local devs on their own laptops can publish to the broker with the version x.x.x-dev. I would like for every push to the version to overwrite since it's a dev version. However when I set the provider pact write mode to overwrite, it just keeps adding more x.x.x-dev to the matrix?

karl
2020-03-09 10:30
When publishing the consumer pact file ii overwirtes correctly, but the provider verification publishes new results and does not overwrite old ones. I'm guessing it should overwrite and the "revision" number should increment?

karl
2020-03-09 10:36
Also when publishing the first consumer pact file overwrite doesn't work, just states "No pact files found". I was expecting it to publish if nothing exists and overwrite if there is already one that exists.

dashrath.mundkar545
2020-03-09 10:49
Hi @bethskurrie,

dashrath.mundkar545
2020-03-09 10:50
Where I can get pact broker api token?

karl
2020-03-09 10:50
Also when using TypeScript it states that the different values for the following Type "PactfileWriteMode" are: "overwrite" | "update" | "merge", I use overwrite, when running the consumer test and the message comes up: [2020-03-09T11:07:02.659Z] INFO: pact-node@10.5.0/26881 on karl-Dell-Precision-M3800: Could not find command "overwrite".

karl
2020-03-09 12:20
I'm also wondering if the pact files should be commited to version control?

simon.nizov
2020-03-09 12:30
Nope. The broker is how you should share pacts. Your CI build should generate the pact files (by running the test suite) and publish them to the broker.

karl
2020-03-09 12:40
Ok, that's what I do currently great!

slimak2387
2020-03-09 13:31
has joined #general

vasilisnx
2020-03-09 14:08
has joined #general

dikili
2020-03-09 14:50
has joined #general

nithya.ganesan
2020-03-09 16:59
has joined #general

ahsan_bhai
2020-03-09 17:35
I am looking for some clarification in regards to the recent fix for this issue: https://github.com/DiUS/pact-jvm/issues/768 I've tried to test with `4.0.7` with `@IgnoreNoPactsToVerify` annotation. I get NullPointerException on `PactVerificationContext`. It looks like `context` variable is still set to null when there are no pacts found in pact broker. ```@IgnoreNoPactsToVerify @ExtendWith(SpringExtension.class) @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT ) @Provider("invalid-provider") @PactBroker( host = "${pact.broker.host}", port = "${pact.broker.port}", tags = "${pact.consumer.tag}", authentication = @PactBrokerAuth(username = "${pact.broker.username}", password = "${pact.broker.password}") ) public class ProviderTests { @LocalServerPort private int serverPort; @BeforeEach void setupTestTarget(PactVerificationContext context) { System.out.println(context); // this returns null context.setTarget(new HttpTestTarget("localhost", serverPort, "/")); } }``` Does anyone have any idea how to NOT fail pact provider tests in JUnit5 when pacts cannot be found. I assume `IgnoreNoPactsToVerify` is for that purpose. But it just doesn't seem to work as desired with JUnit5.

bethskurrie
2020-03-09 19:32
These questions are best asked in the #pact-broker channel @karl

bethskurrie
2020-03-09 19:34
The pact file write mode is only for the mock service. It does not relate to the Pact Broker.

bethskurrie
2020-03-09 19:37
It tells the mock service how to deal with existing pact files that are already in the folder.

bethskurrie
2020-03-09 19:37
If you're just starting out, I would leave this as its default value. (ie. don't set it)

bethskurrie
2020-03-09 19:37
Setting it to a custom value is only for advanced use cases.

bethskurrie
2020-03-09 19:39
Having devs publish from their laptops is an unusual approach. What are you trying to achieve?

bethskurrie
2020-03-09 19:40
You can't in the OSS code @dashrath.mundkar545

bethskurrie
2020-03-09 19:40
It's only implemented in http://pactflow.io

bethskurrie
2020-03-09 19:40
The OSS pact broker only supports basic auth

bethskurrie
2020-03-09 19:42
You would need to make your own docker container and use some Rack Middleware that checks for bearer tokens.

bethskurrie
2020-03-09 19:45
Best to ask in the #pact-jvm channel @ahsan_bhai

ahsan_bhai
2020-03-09 19:48
Thank you for your reply @bethskurrie

bethskurrie
2020-03-09 19:49
No data in the pact broker is ever lost unless you delete it explicitly. Publishing a pact with the same consumer version makes a new revision, rather than deleting the existing one. If you change the "group by" selection in the matrix page to "latest by consumer version and provider version" you'll only see the latest revision.

bethskurrie
2020-03-09 19:50
Also, if that's not your default view, you're probably not on the latest broker version, and it's worth updating.

aaron
2020-03-09 21:34
has joined #general

2020-03-10 08:09
A post in *Feature Requests* has been marked as *in progress*

karl
2020-03-10 08:18
Aha I gotcha, ok I'll remove the pactWriteMode completely thanks! Regarding the local dev thing, to increase dev time and reduce wait time on the CI: one little change, commit, push, open up CI UI, wait for build, wait for contract tests to pass or fail = it just takes far too much time from a dev. So I've dedicated a version for devs (x.x.x-dev) so they can make the change, contract test locally(which would push to the broker) and just check the broker immediately to see if their change made the contract test pass, this means they can be confident when pushing to the repo the CI will pass. This was also the reason I was looking into the "overwrite", I was hoping it was the option to overwrite previous verifications, since in the case of x.x.x-dev we don't care about previous versions. We do however care about the x.x.x versions and they are set via the CI. I hope you understand my thought of mind? (I basically want to reduce dev time and reduce the amount of failed builds in the CI due to contract test failings)

bethskurrie
2020-03-10 08:43
I do understand


bethskurrie
2020-03-10 08:48
Typically, we recommend making changes to pacts on a branch of the consumer, and to only merge once the pact has been successfully verified, to avoid blocking master.

bethskurrie
2020-03-10 08:48
Would this not work for you?

dikili
2020-03-10 16:51
~hi i would like my provider test result of pact file be sent to http://pact-broker site~

dikili
2020-03-10 16:52
~how do i manage to do this ?~

dikili
2020-03-10 16:52
~can i use the APIs ?~

dikili
2020-03-10 16:54
~i use pactflow ui~

dikili
2020-03-10 17:19
hi, i have a pact file submitted to pact broker (i use pactflow) via api end point

dikili
2020-03-10 17:23
i need the provider to verify the Pact, in my local it is working fine but this is the provider code, can you advise how i can amend it to get provider test will work and i can see in the pactflow dashboard that it is verified after running it ? var comp= new PactClient(); //this is calling the api endpoint /pacts/provider/provider/consumer/Service_Consumer/latest to retrieve the pact file which works fine var pact= comp.GetPact(); var config = new PactVerifierConfig { Outputters = new List<IOutput> { new XUnitOutput(_output) }, Verbose = true }; // Act + Assert Uri pactFile = new Uri(pact.ResponseUri.ToString()); //test fails in the below code new PactVerifier(config) .ServiceProvider("Service_Consumer", "https://dev-apiendpoint.co.uk/mobile-api/") .HonoursPactWith("pactcontract") .PactUri(pact.ResponseUri.ToString()) .Verify( description: "A request is made", providerState: "A GET request for getting titles is submitted");

dikili
2020-03-10 18:24
@here in the above code i changed PactUri with .PactBroker(pact.ResponseUri.AbsoluteUri) as i use pact broker( pactflow) , but it still fails, can you pls advise me what i am not doing right pls ?

dikili
2020-03-10 18:26
@here with this error: PactNet.PactFailureException: 'Pact verification failed. See output for details. If the output is empty please provide a custom config.Outputters (IOutput) for your test framework, as we couldn't write to the console

dikili
2020-03-10 18:26
@here your support appreciated!

bethskurrie
2020-03-10 19:28
@dikili best to ask in the channel for your language, #pact-net

bethskurrie
2020-03-10 19:28
Also, you need to turn on the publishing.


matt.fellows
2020-03-10 21:42
Also - if you could format your code that would help readability a lot

bethskurrie
2020-03-10 21:47
I've released this in 2.51.0-1 @simon.nizov

vaikar.abhijeet
2020-03-11 04:30
has joined #general

vaikar.abhijeet
2020-03-11 04:43
Hello :man-raising-hand: I'm here to understand some principles and concepts in contract testing in general. Based on all that I have read about contract testing / consumer driven contract testing I have many doubts. Here they are: 1. Is contract testing and consumer driven contract testing different? 2. This page: https://docs.pact.io/consumer/contract_tests_not_functional_tests gives an example that verifies status code of service as part of contract test. Why is status code verification part of contract tests? 3. Is it correct to say that the difference between functional and contract tests is that the scenarios for both can be same but the verifications/checks are different? Functional tests for correctness of the values in the response and contract tests for the correctness of the schema structure? 4. Why do we say contract testing should be about catching bugs in the consumer? If the contract is meant for the provider shouldn't it be bugs in the provider because if the provider breaks the contract the consumer will get affected.

vaikar.abhijeet
2020-03-11 04:55
To give a bit of a background, I am working on setting up a strategy for contract tests for `gRPC based microservices` in my organisation. To do that, I'm getting the foundation of what and how contract testing works.

vaikar.abhijeet
2020-03-11 05:44
Also, 5. I read here: https://martinfowler.com/bliki/ContractTest.html that contract tests are not supposed to be part of regular build pipeline, they can be run once in day. How would that work if a provider's contract is changed and deployed to production and the contract tests don't run as part of the provider's build pipeline?

simon.nizov
2020-03-11 06:28
Awesome, thanks!

abubics
2020-03-11 06:35
1. Consumer-driven contract testing is a specific kind of contract testing. In the Fowler link you added, it's mentioned: > To reduce the chances of unexpected breaks in contracts, it's useful to move to a https://martinfowler.com/articles/consumerDrivenContracts.html approach.

abubics
2020-03-11 06:37
2. HTTP is an application-level protocol, and often status codes are used to indicate operation completion status. If you have a different schema, where, for example, everything returns a status of 200, but potentially errors in the body, this approach may be less relevant.

abubics
2020-03-11 06:39
3. Functional tests usually check the validity of state changes. Contract tests intend to verify interaction effects (and not side-effects). They may have some overlap, as you mentioned :slightly_smiling_face:

abubics
2020-03-11 06:40
4. Contract tests can catch bugs in both the consumer and provider. The classes of test on each side may differ.

abubics
2020-03-11 07:25
5. That post is old, and kinda hints at using functional tests as a proxy for contract tests. The workflow described by pact is more advanced, and designed to be automated, fast, and run in CI on every commit, for both sides of each contract.

s1apped
2020-03-11 09:36
Hi. What is best approach to using @State. Lets say we have provider service A and consumer services B and C. Service A provides details about car e.g color, type, hp, mark Service B only needs mark, color and service C hp and type. So now consumers are responsible for defining @State e.g ```.given("Car exists with details expected by service B") .given("Car exists with details expected by service C")``` and provider responds appropriately. What about common state like throwing message when car is not found. Should be share state between multiple consumers?

joseph.haig
2020-03-11 09:43
Is it possible to remove a version tag using `pact-broker`? I would like to tag a consumer?s contract as (for example) `deploy` so that the provider can use that in the ?pact verify? step. Then, when I tag the contract for production, I?d like to remove `deploy`.

bethskurrie
2020-03-11 09:44
You can just keep adding them.

bethskurrie
2020-03-11 09:45
You typically use the latest for a particular tag anyway.

bethskurrie
2020-03-11 09:46
/... /latest/prod etc

bethskurrie
2020-03-11 09:47
You can send a http delete to the resource url if you really want to, but it's rarely necessary in the normal flow of things.

bethskurrie
2020-03-11 09:47
The only time it's really necessary is if you're rolling back to a previous version in prod. You have to remove the tag from the version you're undeploying.

joseph.haig
2020-03-11 09:48
Hmmm, OK. I know I can have multiple tags but I was thinking of not cluttering, so remove the ?deploy? tag when adding the ?prod? tag. Alternatively, can a ?pact verify? select the latest that doesn?t have a particular tag. We have just discovered (first time the contract changed) that the provider is configured to check against the latest prod. Hence, our (the consumer) pipeline failed the can-i-deploy.

bethskurrie
2020-03-11 09:49
I'm confused

bethskurrie
2020-03-11 09:49
Yes, it should check the latest prod

bethskurrie
2020-03-11 09:49
So you know it's backwards compatible

bethskurrie
2020-03-11 09:49
Otherwise, the provider might deploy to prod and break it.

bethskurrie
2020-03-11 09:50
You typically tag with the branch name and the environment name. The provider would generally verify master and prod.

joseph.haig
2020-03-11 09:51
I?m deploying a new version of the consumer. It publishes a new contract but it is not yet tagged as production, as it hasn?t made it there yet. The provider then runs the ?pact verify? but it takes the latest tagged version, and so ignores the one the consumer has just published.

bethskurrie
2020-03-11 09:51
That means it's compatible with the latest dev version, and backwards compatible with the prod version.

bethskurrie
2020-03-11 09:51
You should tag when you publish

joseph.haig
2020-03-11 09:51
OK, I?m missing that. Thanks.

bethskurrie
2020-03-11 09:52
Let me find you the docs on tagging


dikili
2020-03-11 09:53
Thank you @bethskurrie i did not realise #pact-net channel, thank you for your help, i will revise what you mentioned and if i still can not get it working with the formated latest code i will ask for support at #pact-net

dikili
2020-03-11 09:53
thanks

wesleythomaswilliams
2020-03-11 10:07
I think that's specifically talking about contracts with external services. If you own all the services you're contract testing, integrating it with your pipeline is the way to go. imo.

dikili
2020-03-11 10:21
I also started learning CDCT approach recently, and i really benefited from these questions/answers, i have one more question, in the ideal scenerio in the ci/cd pipeline, should both consumer and provider tests run ? from my understanding running the provider test on the pipeline should suffice before deployment if no change is made ? And also when i look at the provider test verifications can there be more than one test ? it looks like to me all provder does it check the contract and pass parameters of the actual service etc.. and call Verify() method , why is there a notion where it looks like there can be more than one provider test ?

dikili
2020-03-11 10:21
thanks

bethskurrie
2020-03-11 10:33
You can share states. Just make sure the consumers are using type based matching so the exact values don't matter.

bethskurrie
2020-03-11 10:34
Some other Pact implementations allow you to namespace the states by consumer name.

bethskurrie
2020-03-11 10:36
If you're finding the lack of namespacing is a problem, raise an issue in pact-jvm, because we were just talking about it the other day.

bethskurrie
2020-03-11 10:36
I suspect with type based matching, it's not such an issue, because we haven't had many people asking for it over the years.

matt.fellows
2020-03-11 10:48
Yes. That article is misleading, and is probably a bit out of date with regards to tools like Pact

matt.fellows
2020-03-11 10:48
(dated 2011)

matt.fellows
2020-03-11 10:49
Pact (and SCC) contract tests are generally fast, cheap and can be run as often as unit tests - so you should definitely do that as a starting point

matt.fellows
2020-03-11 10:51
> n the ideal scenerio in the ci/cd pipeline, should both consumer and provider tests run ? Not in the same pipeline (at least, not usually). You?re usually not changing them both at the same time, they?re often developed/owned by separate teams. They have separate lifecycles.

matt.fellows
2020-03-11 10:51
Run the respective contract tests for consumer and provider in each of their pipelines

matt.fellows
2020-03-11 10:53
> And also when i look at the provider test verifications can there be more than one test ? it looks like to me all provder does it check the contract and pass parameters of the actual service etc.. and call Verify() method , why is there a notion where it looks like there can be more than one provider test ? I?m not exactly sure what you?re asking. But the ?verify? is just the command to tell Pact to fetch all of the contracts (consumers and their expectations) and then test that every single one of those can be satisfied by the provider - in most project, these could be considered hundreds of tests (many scenarios, checking headers, body, status code etc.)

matt.fellows
2020-03-11 10:53
> Is contract testing and consumer driven contract testing different? Yes. See Andras as per above. But basically, consumer-driven is just a philosophical position that says ?consumers drive the contract design?, and Pact makes that easier to do. Contract testing is simply ensuring that a contract is compatible (on both sides) > This page: https://docs.pact.io/consumer/contract_tests_not_functional_tests gives an example that verifies status code of service as part of contract test. Why is status code verification part of contract tests? Why _wouldn?t_ you think it?s part of the contract? > Is it correct to say that the difference between functional and contract tests is that the scenarios for both can be same but the verifications/checks are different? Functional tests for correctness of the values in the response and contract tests for the correctness of the schema structure? I wouldn?t split it that way, albeit as has been stated there may be overlap. Contract tests are about the messages that go back and forward, and if both sides are able to agree on how they communicate. Functional testing is more about what both sides _do_ in response to those messages - did the email get sent off? Did the user state update? etc. > Why do we say contract testing should be about catching bugs in the consumer? If the contract is meant for the provider shouldn?t it be bugs in the provider because if the provider breaks the contract the consumer will get affected. Contract tests also ensure that the consumer does what it says. All to often, consumers say ?we need all of these things? but don?t validate that their code actually does it. This means that when the provider comes to change, they don?t know what the impact of the change would be. If we ensure the consumer behaves as expected, the contract is exactly what the consumer needs - no more or less. This is good for everyone

dikili
2020-03-11 11:22
Ok, sorry i guess i could not communicate well, What i was trying to say is , if consumer produced one pact file, one provider test to verify it would suffice is this right? what is the scenerio/use case for adding multiple provider tests in one class since Verify command in one test does all the verification of the pact which means many tests , creating multiple provider classes does not make sense, is this right , is it more clear now ? One of [Fact] public void TestProvider() {//do the verify} is sufficient to handle all the verifications, is there a scenerio where i need to add multiple of above TestProvider2() etc... in one project ?

s1apped
2020-03-11 11:42
basically what I found that having 2 consumer calling 1 provider enforeces some naming convenction for @State becasue you can't have 2 exact same @States even in separate consumers. I think that common state for things like errors is ok. I will take a look into namespacing

s1apped
2020-03-11 11:44
With sharing states issue is that consumer dictates what it should be so with sharing it might be a hassle

matt.fellows
2020-03-11 11:51
Oh right, then yes I believe that's the case across all languages. Sorry for any confusion!

adamadiopzongo
2020-03-11 14:48
has joined #general

timo
2020-03-11 15:00
has joined #general

dikili
2020-03-11 15:04
@bethskurrie when you say turning it on now i use this config; var config = new PactVerifierConfig { Outputters = new List<IOutput> { new XUnitOutput(_output) }, ProviderVersion = "1.0.0", PublishVerificationResults = true, CustomHeaders = new Dictionary<string, string> { { "Authorization", "Bearer xxxx" } }, }; is there anything else i need to do for turning it on as far as you aware because i can not see any ? thank you

bethskurrie
2020-03-11 21:25
@dikili I don't know, as I'm not a JVM developer.

bethskurrie
2020-03-11 21:26
Best to ask in the #pact-jvm channel

bethskurrie
2020-03-11 21:27
Or is that Pact Net?

neil
2020-03-11 23:34
Yeah that?s .NET

neil
2020-03-11 23:34
`PublishVerificationResults = true` will publish the result of the verification to the broker

bethskurrie
2020-03-12 00:44
Pact message people. You know how we tell people what scope of each of the consumer and provider to cover in each of the tests (out the back door of the consumer, covering as much of the provider as you need)? How much of the consumer/provider is a good amount when you're testing message pact?

unitsix
2020-03-12 02:41
has joined #general

bethskurrie
2020-03-12 07:13
Good article on hexagonal architecture in the Netflix tech blog mentions they want to use contract testing, and links to http://docs.pact.io https://netflixtechblog.com/ready-for-changes-with-hexagonal-architecture-b315ec967749

matt.fellows
2020-03-12 08:57
Does it support bearer tokens Neil? I didn't see that on the link above

bethskurrie
2020-03-12 09:03
@matt.fellows yes, pact net does.

neil
2020-03-12 09:27
Yeah I think i see the problem. Replied in the thread in #pact-net

matt.fellows
2020-03-12 09:46
In https://www.slideshare.net/mobile/DiUSComputing/serverless-microservices-test-smarter-not-harder I argue for hexagonal architectures and suggest (in pact tests) that you should test the adapter (and not the protocol handler)

matt.fellows
2020-03-12 09:47
If we provided tools for specific message protocols - websockets, kafalka, AMQP etc then I would test both the port and adapter

matt.fellows
2020-03-12 09:47
But really, the same advice as HTTP

bethskurrie
2020-03-12 09:49
I've just been having a conversation on twitter where nobody is able to actually explain the difference between hexagonal and layered architecture, and yet they still insist there is a difference. Tomorrow's job is for you to explain to me what it is!

matt.fellows
2020-03-12 09:52
Ha!

matt.fellows
2020-03-12 09:52
Arguably Hexagonal is a form of layered arch.

bethskurrie
2020-03-12 10:11
As far as I can see, it's just sensible separation of concerns.

matt.fellows
2020-03-12 10:12
I like it because it's simple, easy to explain and easy to implement

bethskurrie
2020-03-12 10:12
Hm. Nobody I've seen has been able to explain it :-P

matt.fellows
2020-03-12 10:14
I'm going to peruse your Twitter timeline now...


simon.nizov
2020-03-12 12:24
Damir, one of the authors of the article, did a talk about this same topic at EuRuKo 2019. https://www.youtube.com/watch?v=YUX2tl3BMpw

jpieree1fchd
2020-03-12 12:38
has joined #general

dikili
2020-03-12 12:50
@here just a quick question, for the published pact files on pactflow, if we want to remove them is it possible to do on the UI ?

engin.marshall
2020-03-12 13:51
has joined #general

wesleythomaswilliams
2020-03-12 14:27
While I've been experimenting with Pact I've deleted quite a few. I usually delete my pacticipant, rather than the pact file, but it can all be done inside the HAL Browser for the API

dikili
2020-03-12 14:36
thanks

dikili
2020-03-12 14:37
@bethskurrie @neil thank you

dikili
2020-03-12 14:38
also i realised you need to provide ProviderVersion as well in order for this to work

sarathojha
2020-03-12 15:31
has joined #general

dikili
2020-03-12 15:39
@here I have a question as a result of interesting behaviour I am getting from pact: I run a consumer test with consumer2 and provider2 and consumer test passes and produces the pact as consumer2-provider2.json PactBuilder .ServiceConsumer("consumer3") .HasPactWith("provider3"); then i change the name and leave everything same to consumer3 and provider3 , the test then fails with error : http://System.IO.FileNotFoundException : Could not find file 'c:\source\contractfile\pacts\consumer3-provider3.json'. and when i look at the folder i do not see that file, and sometimes no files is being created and sometimes what gets created is the previous one which is consumer2-provider2.json ultimately since i expect consumer3-provider3.json test fails, does anyone understand the issue here please ?

wieslaw.mlynarski
2020-03-12 17:13
has joined #general

wieslaw.mlynarski
2020-03-12 17:31
Hey everyone. I noticed an incompatibility while updating between, "au.com.dius:pact-jvm-provider-junit5:4.0.6" "au.com.dius:pact-jvm-provider-junit5:4.0.7" https://github.com/DiUS/pact-jvm/blob/6fd8adbc33fe472cd5e3a1299cfda54c74b6ff15/provider/pact-jvm-provider/src/main/kotlin/au/com/dius/pact/provider/ProviderClient.kt#L297 the issue is that the code changed from "application/json", to "text/plain; charset=ISO-8859-1" which as a result makes the test fail, the application under test does not accept "text/plain". I am checking if I can create a fix for that.

bethskurrie
2020-03-12 19:29
@wieslaw.mlynarski shouldn't you be setting your own content type header anyway?

bethskurrie
2020-03-12 19:29
I would imagine that overrides the default that the JVM code sets.

bethskurrie
2020-03-12 19:30
Please ask in #pact-net @dikili

bethskurrie
2020-03-12 19:32
@dikili you can delete them through the old OSS UI. You'll see a blue toggle button at the top of the screen.

bethskurrie
2020-03-12 19:34
You can delete a single pact on the pact page (click the ...) and you can delete all the pacts for an integration on the index page by clicking on the ... button next to the integration.

matt.fellows
2020-03-12 21:41
The docs mentioned that from what I could see

bethskurrie
2020-03-12 22:11
@tjones once tried to explain it to me...

tjones
2020-03-12 22:55
In my view, they?re largely the same thing in different words

bethskurrie
2020-03-12 23:00
FFS. That's what I've been suspecting all along.

bsigney
2020-03-12 23:02
has joined #general

matt.fellows
2020-03-12 23:35
haha

matt.fellows
2020-03-13 00:03
OK so here?s my take on it (probably controversially): 1. Hexagonical architecture _is_ a type of layered architecture (it just arranges layers a little differently). 2. The aims of both are largely to provide separation of concerns and modularity 3. Both have strong direction dependency - the inner layers of hexagonal should not know about the outer. Each layer only knows about the layer directly beneath 4. Layered architecture is more broad - it?s fractal. For example, you can apply it to a distributed system (e.g. client server) or to a single system (monolithic app) 5. Hexagonal architecture is generally applied to a single application boundary / process. One of it?s stated aims is to increase the testability of applications 6. Hexagonal architecture establishes a common vocabulary that can be used to talk about specific abstractions within code bases - ports, adapters, repositories, services, domain (they are not all original of course) 7. One notable difference is that it separates the idea of ?presentation? to simply ?inputs? and ?outputs?. Presentation is typically at the ?top? of a layered architecture. But that has some consequences, because often times presentation moves in different directions (not just ?inbound? from a user). Having inputs and outputs (an abstraction of presentation if you will) gives increased flexibility and resolves some of the coupling problems a layered architecture may introduce solving that challenge But a lot of the difference is splitting heirs. TL;DR - hexagonal architecture is a specific implementation of a layered architecture

abubics
2020-03-13 02:27
I basically agree . . . clean & hexagonal are pretty much the same thing, and both have directionality embedded in the definition. They're a specific kind of layered arch. There are many other kinds of layered architectures, with different directionality profiles and topologies :slightly_smiling_face:

bethskurrie
2020-03-13 02:29
I'd love an example :wink:

bethskurrie
2020-03-13 02:30
So far I've heard, it's just a different way of conceptualising the same thing, with some different labels.

bethskurrie
2020-03-13 02:31
I want to understand how it would change the way I'd write or structure my code.

bethskurrie
2020-03-13 02:32
for example, the PB has very clearly defined and well separated classes. HTTP handler is separate from body parsing, completely separate from business logic, and everything goes through a repository (even if the respository does return Sequel models rather than POROs).

bethskurrie
2020-03-13 02:33
Is that hexagonal?

bethskurrie
2020-03-13 02:33
Each of those concerns is orthogonal

bethskurrie
2020-03-13 02:33
Unlike some opinionated frameworks where all your routes/requests/validation etc are very tightly coupled

matt.fellows
2020-03-13 02:36
Here is a port (the lambda handler), adapter (the kinesis specific handler), and the business objects (service, repository, domain)

matt.fellows
2020-03-13 02:37
:point_up: very basic/crude example, but hopefully gives you an idea. I?m not sure it really matters that you can say ?that?s a hexagonal architecture? in hindsight - the goal isn?t to be hexagonal, but to be able to do the things you describe.

matt.fellows
2020-03-13 02:38
terminology is probably the main identifier, assuming the other properties exist

abubics
2020-03-13 03:06
The main thing from clean architecture is that the inner layers don't know about the outer layers. Inner is more abstract (domain concerns & modelling), and outer is more concrete (specific protocols, libraries, platforms, etc). Due to the implications of these properties, you should be able to plug different http libraries, or database drivers, for example, without changing any domain code. Likewise, you should be able to swap presentation layers easily (e.g. move from react to svelte, or use the core in Android and some other JVM target). There are some patterns that may be less obvious to inexperienced developers, like how to invert the directionality of some inter-layer interfaces. There are some ways to enforce the architecture, like having layers in their own modules, or banning imports from certain areas.

abubics
2020-03-13 03:12
What often happen in frameworks like Spring, etc, is a top-to-bottom layering, where the domain logic is distributed across several layers. This is canonically not "clean", because the domain concerns aren't modelled separately from platform concerns, and the layers usually know about each other, bidirectionally. You can make Spring clean, but it's tricky because it blends some concerns in some of the layers, and encourages configuration tentacles & annotation leakage.

matt.fellows
2020-03-13 03:12
Indeed

matt.fellows
2020-03-13 03:13
The abstractness is more of an emphasis in hexagonal, and something not really communicated in (traditional) layered architectures

matt.fellows
2020-03-13 03:13
it doesn?t mean you can?t do it, because of course you can

bethskurrie
2020-03-13 03:16
I'm going to blame java

matt.fellows
2020-03-13 03:18
ahmmm also Rails

bethskurrie
2020-03-13 03:19
zactly

bethskurrie
2020-03-13 03:19
however, Rails was invented as a backlash to java frameworks, so I'll still blame java.

matt.fellows
2020-03-13 03:21
lol

tjones
2020-03-13 03:31
I blame OO

bentstuart
2020-03-13 05:25
has joined #general

bentstuart
2020-03-13 05:27
Howdy there. I am wondering if anyone would be able to help me with pact-jvm pact messaging https://github.com/DiUS/pact-jvm/issues/1047

bethskurrie
2020-03-13 05:28
Try #pact-jvm-help @bentstuart


bentstuart
2020-03-13 05:29
Thanks @ben7091

bethskurrie
2020-03-13 05:36
Hey people. Is anyone interested in doing some slack plugin dev to help new users onboard to our slack community? We'd like to make a welcome bot that posts a private message to new users, in the #general channel. The free welcome bot lets you do either a public message (which ends up being noisy for everyone else) or a PM (which nobody ever really notices). There's a template for writing a welcome bot in the Slack docs. It would be a fun little job for someone who has more free time than I do! Let me know if you'd be interested.

bradyzp
2020-03-13 21:36
has joined #general

bheemreddy181
2020-03-13 23:25
I can give a try if you can direct me

sumeshs572
2020-03-16 15:29
@bethskurrie could you please confirm which version of pact broker have this latest UI feature, is u see pactfoundation/pact-broker or dius/pact-broker in dockerhub

matt.fellows
2020-03-17 00:09
Anybody here used Pact with Mulesoft before?

engin.marshall
2020-03-17 09:13
Or with NestJs? :slightly_smiling_face:

tausif2909
2020-03-17 10:52
Hello I am looking for example to update request while running provider verification for below calls `/api/asset/1234` & `/api/assets?assetId=1234` .


tausif2909
2020-03-17 10:56
Can someone share the example to handle such cases in Java (JVM Maven) based framework?

matt.fellows
2020-03-17 10:57
The feature is probably called ?request filters? - try searching that

matt.fellows
2020-03-17 10:57
also check out #pact-jvm-help


tainguyen
2020-03-17 11:03
Is that you're looking for?

tausif2909
2020-03-17 11:10
ok, I tried to use request filters like below but it worked for updating path, not working for query parameters like `/api/assets?assetId=1234`.

tausif2909
2020-03-17 11:11
```@TargetRequestFilter public void updateRequest(HttpRequest request) throws Exception { HttpGet httpGet = (HttpGet) request; URIBuilder builder = new URIBuilder(httpGet.getURI()); builder.setPath(builder.getPath().replaceAll("/api/assets/20000", "/api/assets/" + mediaAssetId) .replaceAll("/api/assets/21000","/api/assets/" + rootGroupAssetId)); System.out.println("Built request is "+request); }```

matt.fellows
2020-03-17 11:12
Check the API docs for URIBuilder - I?m sure it has an API to handle query params

tainguyen
2020-03-17 11:12
U can use queryParameterFromProviderState

tainguyen
2020-03-17 11:13
how about update request body?

tausif2909
2020-03-17 11:15
Yes, But I dont find any example of it


kevin.meiresonne
2020-03-17 12:48
Is there a way to have flexible matching on the response status code? We want to specify in our pact that for a given state, the response can be a 4xx status code We can't use the regex matcher, as that only works on string values, whereas the status code is a numeric

matt.fellows
2020-03-17 12:49
no, it has to be exact (at this moment). I think all libraries are consistent on this

nerea.tamayo
2020-03-17 16:18
Hi!! Do you know if there is somthing for reporting benefits we get using Pact?I mean, I?d like to generate report in order to show the errrors we avoid applying consumer driven contract testing

nerea.tamayo
2020-03-17 16:18
Any ideas?

wieslaw.mlynarski
2020-03-17 16:37
@bethskurrie the Interaction looks something like this ```{ "method": "POST", "path": "/postEndpoint", "body": { .... } }``` In this interaction there is no content type. I am aware it could be set. In this case after upgrading version 4.0.6-> 4.0.y the default content type changed setting it to "text" (before was application/json) causing the service endpoint to return `expected status of 204 but was 415` I posted this PR https://github.com/DiUS/pact-jvm/pull/1046 to try go around this in situation when you know that the payload is a "JSON" document and no header is specified.

kevin.meiresonne
2020-03-17 18:38
If you're using the pact broker maybe you can use the pact broker metrics API It gives you an overview of stats on your pacts and their verifications. e.g. ```... "verificationResults": { "count": 35457, "successCount": 45824, "failureCount": 3522, "distinctCount": 40245, "first": "2017-1-24T11:37:46+00:00", "last": "2020-03-17T16:28:50+00:00" }, ...``` Every failed pact verification is a potential error you avoided. Although this would heavily depend on your workflow, as while developing a new feature/change you could have quite a few failures when pushing code and triggering pact verifications. I guess it depends a bit on what you consider "avoided errors"

matt.fellows
2020-03-17 20:20
Great question Nerea! We'd like to add first class metrics into Pactflow, but feel free to raise a feature request and talk about the things you'd like to see. Failed verifications are one. I would also look at metrics from use of can-i-deploy. On a current client, we wrapped this command and sent data to datadog to measure this

matt.fellows
2020-03-17 20:21
We also have done some preliminary work to measure cycle times - e.g. how long from when a contract started to being deployed to prod

steffen.vulpius
2020-03-17 23:48
has joined #general

steffen.vulpius
2020-03-17 23:53
Hi, I'm going through the pact workshop in Go and am stuck at Step 3. It seems no pact file is written.

matt.fellows
2020-03-18 00:00
can you please post CLI output in #pact-go ?

steffen.vulpius
2020-03-18 00:08
thanks @matt.fellows

networkandcode
2020-03-18 06:01
has joined #general

nerea.tamayo
2020-03-18 09:25
Nice!!thanks a lot, I?m going to spend some time on this in order to suggest some features!!Thanks!!

nerea.tamayo
2020-03-18 09:26
Nice, I?ll have .a look, thanks!!

matt.fellows
2020-03-18 09:36
Awesome - that?d be great, thanks Nerea

bethskurrie
2020-03-18 09:46
I'd be interested to hear your thoughts @nerea.tamayo

bethskurrie
2020-03-18 09:49
One of the great benefits of using pact is that bugs get fixed before code is even committed, but the downside is, that does make it hard to count them!

matt.fellows
2020-03-18 09:50
this is true

matt.fellows
2020-03-18 09:51
I think this is where metrics emitted from CLI tools would help - if we rely on metrics solely from the Broker, then we only get part of the picture.

matt.fellows
2020-03-18 09:51
Instrumenting calls like can-i-deploy, and failed local verifications could be illuminating

bethskurrie
2020-03-18 09:52
We can count deployments that have been prevented due to missing or failed verifications.

bethskurrie
2020-03-18 09:52
Auth would be tricky.

matt.fellows
2020-03-18 09:52
Another option could be to always publish the results (but not treat them as failures in the broker). This way we get fine grained metrics (essentially, the publish flag is just a toggle to say ?metric? or ?real?)

matt.fellows
2020-03-18 09:52
yeah

bethskurrie
2020-03-18 09:53
Devs shouldn't be using write tokens

bethskurrie
2020-03-18 09:53
So it would have to be a special endpoint.

matt.fellows
2020-03-18 09:53
I think our current API access key model needs improvement. The idea of across the board ?read-only? and ?write-only? will have to change with RBAC etc.

matt.fellows
2020-03-18 09:54
For example, you _should_ be able to modify details scoped to your user (e.g. your email address, name, password)

bethskurrie
2020-03-18 09:54
Good point

matt.fellows
2020-03-18 09:54
I know I?m conflating various roadmap items here, but good to have the full picture in view

matt.fellows
2020-03-18 09:55
I think a simpler starting point is to simply have a metrics receiver endpoint, and instrument CLI/frameworks that run locally

matt.fellows
2020-03-18 09:55
P.S. Happy 3 year anniversary!!! :tada:

bethskurrie
2020-03-18 09:56
Yes, that could work.

matt.fellows
2020-03-18 09:58
@kevin.meiresonne keen to hear your thoughts. The metrics endpoint is fairly rudimentary, is it something you actually use?

kevin.meiresonne
2020-03-18 10:09
No, tbh, I just found it by accident yesterday when browsing the API :slightly_smiling_face:

kevin.meiresonne
2020-03-18 10:09
It's rudimentary, but nice to get a global idea on how much we use the pact broker

matt.fellows
2020-03-18 10:10
turns out quite a bit

kevin.meiresonne
2020-03-18 10:11
not sure if there's a way to get metrics on a particular tag? Like "show me all verification metrics on the master branches"

pawarsumit12
2020-03-18 14:06
has joined #general

arho.huttunen
2020-03-18 18:55
has joined #general

bethskurrie
2020-03-18 21:12
No, but that's a good idea @kevin.meiresonne

anoop.nair
2020-03-19 03:37
has joined #general

jks
2020-03-19 13:13
Is '$.foo.item.#text' a valid matcher for ```<foo><item>1</item><item>2</item><item>3</item></foo>``` if we wanted to match text nodes? pact-jvm is throwing an exception: ```http://au.com.dius.pact.core.model.InvalidPathExpression: Expected either a "*" or path identifier in path expression "$.foo.item.#text" at index 11``` I realize this description is for rust https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_matching, but since it's for the pact-specification I was hoping it was same for pact-jvm.

uglyog
2020-03-19 22:00
I initially developed the XML matchers to use `@name` to match an attribute and `#text` to match the combined text nodes, but have since realised that the matchers will be applied to the text contents of a node anyway and so targeting the text explicitly is not needed.

mick.mccarthy
2020-03-19 23:01
has joined #general

jks
2020-03-20 14:09
Thanks. As, I'm looking at XML matching I'm starting to recognize the differences between XML and JSON. Arrays for instance, say I have XML like: `<foo><title>my list</title><item>1</item><item>2</item><footer>my footer</footer></foo>` a JSON would be equivalent to: `{"foo": {"title": "my list", "item": [1,2], "footer": "my footer"}}` For JSON, if I wanted to match each instance of item with a different matcher I believe `$.foo.item[0]` and `$.foo.item[1]` matchers would work. However, I don't believe these matchers would work for the XML case. I haven't tried this yet, so if I'm wrong forgive me. Will that notation work for XML matching or are the brackets just used for matching element attributes?

adadache
2020-03-20 15:02
has joined #general

shero86
2020-03-20 16:34
hi guys, I have a valid contract with generated `Date` for request. So after every running the contract is generating almost the same (except the Date field), and when the contract is publishing, Pact broker assuming that this is a new version of contract. Any suggestions, how I can ignore that Date field for contract versioning? To match versions according to matcher? I tried with `generate` , but it didn?t work for me (using typescript).

matt.fellows
2020-03-20 22:20
Can you not have the date update each time - i.e. in the matcher, provide a hard-coded date as the example but use a regex to allow it to be diffeent? Please share your code in #pact-js and we?ll help you out

uglyog
2020-03-20 22:44
No, those should work. What I have come to realize is that `$.foo.item` should match all the items in XML, while in JSON it won?t.

waquino
2020-03-21 03:52
has joined #general

jks
2020-03-21 15:08
Thanks again. I'll write some tests to get a better understanding for myself.

krosan
2020-03-21 19:28
has joined #general

vaikar.abhijeet
2020-03-22 10:42
Thanks all for such great replies. Really appreciate your efforts to explain :slightly_smiling_face: I'm still quite confused where to draw the line between functional testing and contract testing. _*Question 1:*_ Regarding functional test why are we talking about `side effects` only? Isn't verifying a `side effect` an integration test? _*Question 2:*_ If my feature is to create a user using a `UserService` where the business logic is: ? User's username should be a combination of first name and last name. ? User's default password should be their government identity that they provide. ? Every user should have a unique id. In this case verifying above will be functional tests right? _*Question 3:*_ Let's say my test-case is to verify that a user should get created when I call `createUser/` then the steps that come to my mind are: 1. Call `/userservice/createUser` with request data 2. Verify that response has the *same values* for user data that I passed in the request. Now this becomes a contract test or a functional test? _*Question 4:*_ For consumer driven contract tests *(without using pact)*, how, from your experiences and real implementations you have come across in organisation, was the continuous integration done? Assumptions: ? Organisation uses Github. ? Each microservice has it's own repository. ? Tests are written in their respective repositories. ? One provider service has many consumers. Is it like this? 1. Provider service code repository has it's functional tests *only*. 2. Consumer service code repository has it's functional tests and consumer tests for the provider. 3. Whenever provider service maintainers make any changes in the provider's code, a build pipeline is triggered on Jenkins (for eg). 4. This pipeline somehow knows that the provider has service B,C,D as consumer services. 5. Pipeline starts the provider service instance. 6. Pipeline triggers provider's functional tests. 7. Pipeline pulls the git repositories of services B, C, D and triggers the consumer driven contract tests. Is that how?

ewa
2020-03-22 11:39
has joined #general

vaikar.abhijeet
2020-03-22 12:25
_*Question 5:*_ If there's a service called OrderService which has an endpoint called GetOrders. So there can be some test-cases like: ? Return orders with specified ids, if found. ? Return empty list if offers don't exist for the user. ? orders include a `delivery_instructions` field if delivery instructions were provided for those orders. So above cases will be contract tests / functional tests?

matt.fellows
2020-03-23 03:18
Thanks for the detailed questions - I think you?re on the right path!

matt.fellows
2020-03-23 03:18
1: IMO an integration test is a type of functional test. At some point, you need to test for side effects - e.g. on a User persistance service, if you call the ?create()? function it should do the persistance thing. I don?t think you wanted to write integration tests for each of those scenarios over and above a unit test (we can go on for ages on the subtle diffeneces between unit/integration but that won?t be instructive) 2. Yes 3. > Let?s say my test-case is to verify that a user should get created when I call createUser/ then the steps that come to my mind are: > Call /userservice/createUser with request data > Verify that response has the same values for user data that I passed in the request. The steps you mentioned aren?t sufficient to test the ?and a user got created bit?, it simply looks at the API data itself. It?s actually neither. It?s the provider?s job to test ?createUser/? API and validate the behaviour - and that?s a form of functional test (probably an integration test given the amount of layers it would need to traverse in the API itself) A contract test simply says ?if POST /users {...}? is sent, I should get back a ?200? with ?these headers? and ?this body {...}? _AND_ that my API client is able to handle the response, and convert it into an internal model suitable for use throughout my code base > Verify that response has the same values for user data that I passed in the request. That sounds like the consumer is doing a functional test of the provider. Don?t do that, that?s just bad practice. That?s the provider?s job (see docs for commentary on this) 4. Yes, pretty much. > Pipeline pulls the git repositories of services B, C, D and triggers the consumer driven contract tests. I think a more broader statement is ?Provider pipeline retrieves the contracts for B, C and D and triggers the consumer driven contract tests?. I can?t think of many good cases where you?d want to be pulling down another projects? git repo.

matt.fellows
2020-03-23 03:23
Question 5: 1 + 2 are definitely contract test things, 3 is a grey area. You?re trying to ensure the client code is able to handle that field or not, it?s not about the functional use case. > So above cases will be contract tests / functional tests? I think you?re trying to find a clear line between functional tests and contract tests. Constantly focussing on that is probably not worth doing, because the truth is, _all_ types of testing overlap. What you should focus on is this: 1. Contract tests - try to find ways to break the communication/messages between systems. Get coverage of all of the API calls, and types of requests/responses that map to your usage patterns 2. Functional tests - try to find bugs in functional requirements to actual implementation. For example, a contract test doesn?t care if a user is added to a DB, a functional test might

shero86
2020-03-23 07:06
thank you! :slightly_smiling_face:

grzegorzkrol90
2020-03-23 08:28
has joined #general

aliihlail
2020-03-23 15:36
has joined #general

aliihlail
2020-03-23 15:39
:raising_hand: Roll call! Who else is here?

ankit992
2020-03-23 15:40
I am but should we do that considering it?s a channel with almost 1500 people

matt.fellows
2020-03-23 20:58
Lots of people are Ali - may I ask what you're trying to do?

elliottmurray
2020-03-24 00:34
I?m not here

christian.roepke
2020-03-24 07:45
has joined #general

llin
2020-03-24 18:19
has joined #general

josue.boix
2020-03-24 19:04
has joined #general

mukheem
2020-03-24 19:52
has joined #general

mukheem
2020-03-24 19:53
:raising_hand: Roll call! Who else is here?

mukheem
2020-03-24 20:34
Can someone quickly help me with the difference between PROVIDER_URL and PROVIDER_SETUP_URL

ryan.dens
2020-03-24 21:05
PROVIDER_URL is the base URL that the requests recorded in the pact from the consumer are replayed against. E.g if you had a contract which has a path of `/foo/bar/baz` your pact verification step will replay the request to `$PROVIDER_URL/foo/bar/baz`

ryan.dens
2020-03-24 21:06
`PROVIDER_SETUP_URL` is a way to to tell your provider verification step who to tell about any provider states that might be specified in your pact

ryan.dens
2020-03-24 21:07
here?s a quick run down on provider states: https://docs.pact.io/getting_started/provider_states

matt.fellows
2020-03-24 21:12
@mukheem which language do you use? Best to ask in that channel directly

matt.fellows
2020-03-24 21:12
In many cases now you can get by without this

mukheem
2020-03-24 21:13
yeah @matt.fellows.I should have put that along with my question

mukheem
2020-03-24 21:15
Thanks @ryan.dens and @matt.fellows I am using Python and I really feel very difficult to get the Provider test done. (It's been 2 days I'm working on it yet :|)

mukheem
2020-03-24 21:15
Let me go thru the above document quickly please.

mukheem
2020-03-24 21:48
Hello there !!! Can someone help me with the answers for the below queries please. 1. When we test PACT against Provider, are we gonna play it against a REAL HTTP server or a MOCKED one ? If it is a MOCKED server, then how are we gonna confirm that our PACT is aligned with the latest version ? 2. I found different versions of Provider Testing. I am using PACT in *Python* Language. Per Documentation, I see Django server is being used. But I am not sure if it is the only way to test PACT against Provider. Can someone help with the latest stuff please.

matt.fellows
2020-03-24 21:49
1. Real 2. Django is obviously the server they use in their example, it can be any http server implementation you choose

bethskurrie
2020-03-24 21:49
@mukheem you're the second person to ask about whether the pact is replayed against a mock provider recently. Is there any documentation out there that suggests that it is?

mukheem
2020-03-24 21:56
Not really @bethskurrie. It might be just a mis-interpretation. Because for newbies like me when we go thru the documentation repetitively, first step In the workflow used Mock server so it was flowing in the sub-conscious. That's it



mukheem
2020-03-24 21:59
along with the Github Wiki for Pact- Python

bethskurrie
2020-03-24 21:59
The animation will help. There are links to it from http://docs.pact.io

mukheem
2020-03-24 22:00
Thanks a lot Beth. Let me just check that. It would really help me in getting vivid picture

2020-03-25 04:13
A new post has been created in *Feature Requests*

2020-03-25 05:28
A post in *Feature Requests* has been marked as *in progress*

jwortmann719
2020-03-25 10:50
has joined #general

cesar.lopes
2020-03-25 11:11
has joined #general

cesar.lopes
2020-03-25 11:13
Hello

daljeet.sidhu
2020-03-25 11:33
has joined #general

fimiere
2020-03-25 12:30
has joined #general

ravi.dasari
2020-03-25 21:25
has joined #general

bethskurrie
2020-03-25 22:22
It's only available in Pactflow @sumeshs572, not the open source version.

sumeshs572
2020-03-25 22:23
Oh is it ?

sumeshs572
2020-03-25 22:25
Thanks for confirming it:+1:

aliihlail
2020-03-25 22:51
Hello, is there any recommendations or examples for consumer java code example for asynchronous messages such as RabbitMq

deepakverma
2020-03-26 00:36
has joined #general

deepakverma
2020-03-26 00:46
Hi there getting error while running pact broker with mysql backend ```! Unable to load application: Sequel::DatabaseError: Mysql2::Error: Index column size too large. The maximum column size is 767 bytes. ```

deepakverma
2020-03-26 00:46
Was unable to found anything related in the documentation. is there any recommended parameter to be set of mysql

bethskurrie
2020-03-26 01:23
@deepakverma can you use postgres instead?

bethskurrie
2020-03-26 01:24
Also, best to ask in the #pact-broker channel


deepakverma
2020-03-26 01:25
Hi @bethskurrie thank you. figured out. the collation was wrong as I was using utf8mb4. sure I will ask in that channel.

matt.fellows
2020-03-26 04:43
Yes. That?s the plan

matt.fellows
2020-03-26 04:43
(sorry this was stuck in ?drafts?)

sagupta
2020-03-26 11:58
Hi all, Can someone please tell me what is the format for providing matching in the json sent to the mock service api http://localhost:80/interactions I am providing this JSON and it adds the interactions . Now how can i provide the matching in the request or response properties. { ?request?: { ?method?: ?GET?, ?path?: ?/companies/7xxxx0/roles/7xxxxe? }, ?response?: { ?status?: 200, ?headers?: { ?Content-Type?: ?application/json; charset=utf-8" }, ?body?: { ?name?: ?admin?, ?userId?: ?7xxxxxe? } } }

bernardoguerr
2020-03-26 13:31
The best way would be to generate the interaction from running it with one of the libraries (pact js, etc).

bernardoguerr
2020-03-26 13:31
so you don't have to know the format of the JSON at all

rbenbolton
2020-03-26 15:11
has joined #general

vadim.sacharow
2020-03-26 16:50
has joined #general

bethskurrie
2020-03-26 19:21
Hi Pacters! If you're a QA you is keen to contribute to OSS, I'd love some help with some manual testing. It shouldn't take long. Don't let the devs have all the fun!

rbenbolton
2020-03-26 23:01
Hey everyone, new to this workspace though not new to pact. I just started a new job and pact I think is the main reason I landed it. Working on implementing pact in Go but I?ll be very interested in the #protobufs as my new company heavily uses gRPC.

matt.fellows
2020-03-26 23:04
I thought I recognised the face - hello again!

matt.fellows
2020-03-26 23:05
Amazing that Pact has helped, and thanks for being such an advocate. We?re moving forward and gRPC is now being considered much more closely - we?ll continue the discussion in there

rbenbolton
2020-03-26 23:05
Hey there! You?re probably more familiar with @gbeckmann from Instructure. I was there until just recently, but I?m a big fan hope to be a more active one as well.

matt.fellows
2020-03-26 23:06
I recognise the face as I?m sure we were on a call once, but perhaps you have a familiar face. Yes, Gentry, Matt and Robert L were the main guys

rbenbolton
2020-03-26 23:08
Yep! I didn?t attend as many meetings - I worked in a different product group, but pact was an essential piece to our testing strategy.

sagupta
2020-03-27 00:02
@bernardoguerr true however still have you tried using matching in this json itself or you have an idea on how can i provide it

bernardoguerr
2020-03-27 13:18
Like I said, if you create the interactions programatically, and just make a simple API call to the endpoint you're testing, the JSON contract will be generated. If you don't want to do this always, you can do it just once, and then you will have an idea of what the JSON is supposed to look like. And from then on, you'll know how to do it using the JSON. In essence, it will be something similar to (e.g.): ```"matchingRules": { "$.body": { "min": 1 }, "$.body[*].*": { "match": "type" } }``` which would be included under the appropriate key (in this case the response). Although I don't see why you would do it this more complicated way that requires you to know the much more error prone JSON formatting, as opposed to using a provided API. Remember that there is a lot of different matching options, and they are provided to you through an API (a language binding) for a reason. As far as I know, they haven't documented the underlying JSON structure (although I'm sure you can find it somewhere in the code). Like I said, the easiest way is choosing a language binding and generating the contract from there, even if it's a one time thing. You'll probably waste more time trying to figure out the JSON formatting than just doing it that way

2020-03-29 22:31
A post in *Feature Requests* has been marked as *complete*

kaz.udesh
2020-03-29 23:18
has joined #general

ina.lopez
2020-03-29 23:22
has joined #general

tjones
2020-03-30 00:10
Nice catch!

2020-03-30 05:57
A post in *Feature Requests* has been marked as *closed*

richard.allen
2020-03-30 09:21
has joined #general

godfrey.carnegie
2020-03-30 10:32
has joined #general

davidpihlaja
2020-03-30 19:08
has joined #general

theuiser
2020-03-30 22:32
has joined #general

jinah.adam
2020-03-30 23:21
has joined #general

siddharth.gupta
2020-03-31 12:08
has joined #general

paras.vora1801
2020-04-01 09:08
has joined #general

ina.lopez
2020-04-01 21:14
Has anyone gotten this issue before: _`INFO: pact-node@10.8.0/42995 on ina: Checking if it it possible to deploy`_ _`INFO: pact-node@10.8.0/42995 on ina: Asking broker at http://localhost:80 if it is possible to deploy`_ _`WARN: pact-node@10.8.0/42995 on ina: Pact exited with code 1.`_ _`ERROR: pact-node@10.8.0/42995 on ina:`_ _`can-i-deploy produced non-json output:`_ _`No value provided for required options '--pacticipant'`_ ```./src/test/pact/candeploy.js var pact = require('@pact-foundation/pact-node'); let opts = { retryWhileUnknown: 3, retryInterval: 5, pacticipants: ["a-consumer", "b-provider"], versions: [process.argv[2]], pactBroker: 'http://localhost:80', to: process.argv[3] }; pact.canDeploy(opts).then(function (result) { console.log("success " + result) done() }) .catch(function(error) { console.log("failure " + error) done() });``` ```./package.json "scripts": { "build": "webpack --config webpack.prod.js", "lint": "eslint --ext=.js,.jsx src/", "start": "webpack-dev-server --config webpack.dev.js", "test": "jest", "test:pact": "cross-env CI=true react-scripts test --runInBand --setupFiles ./src/test/pact/setup.js --setupFilesAfterEnv ./src/test/pact/jest-wrapper.js --testMatch \"**/*.test.pact.js\"", "publish:pact": "node ./src/test/pact/publish.js", "candeploy:pact": "node ./src/test/pact/candeploy.js" }, ...``` `~ npm run candeploy:pact -- feature-123 dev`

matt.fellows
2020-04-01 22:18
Hi @inaki.varebeke, the ?pacticipants? property is not actually an arary of strings, but an array of ?selectors?. Nevermind the specifics of what that is just now, but see https://github.com/pact-foundation/pact-node/blob/master/src/can-deploy.spec.ts#L55 for an example input

matt.fellows
2020-04-01 22:24
I?ve just fixed the docs on the `pact-node` website, because they were broken - my apologies

lbraymusso
2020-04-02 05:32
has joined #general

sacharya_pact
2020-04-02 05:36
has joined #general

adadache
2020-04-02 08:25
Is there any way to use the `pact-provider-verifier` with multiple outputs? I want to have a .xml output in RspecJunitFormatter to `/tmp/reports/pactReport`, but also want to keep stdout for CI/CD. The above results in using the `-f` and `-o`, where `-o` disabled stdout.

tjones
2020-04-02 08:26
I don?t believe this is currently supported, but would be a reasonable feature request

bethskurrie
2020-04-02 08:28
Tim is right. It's not currently supported, but it could be.

bethskurrie
2020-04-02 08:28
Raise an issue in the Pact provider verifier repository

bethskurrie
2020-04-02 08:30
@matt.fellows is it called pacticipants?

bethskurrie
2020-04-02 08:32
Could it be renamed pacticipant versions?

matt.fellows
2020-04-02 08:33
Yes and yes. I'll mark that enhancement after feeding time at the zoo is complete

ryanlevell
2020-04-02 12:53
has joined #general

adadache
2020-04-02 14:40
I?ll. In the meantime, I am executing it twice, as I have an option to disable publishing verification results. :confused: :smile: So I can get both output?

christopher.richard
2020-04-02 15:01
has joined #general

christopher.richard
2020-04-02 17:21
:wave: ~Hi everyone/anyone! I'm working on a POC of PACT and have hit my first really blocking snag so far with the pact-verifier CLI in pact-python. Anyone at all familiar with that who might be able to answer some questions?~

christopher.richard
2020-04-02 17:47
Heading to the python channel!

ina.lopez
2020-04-02 23:25
While running Broker and Jenkins in docker container, has anyone come across below error: ```console.error node_modules/jest-jasmine2/build/jasmine/Env.js:290 Error: listen EADDRNOTAVAIL: address not available 172.17.0.1:8099 Error: connect ECONNREFUSED``` Here is my setup.js ```const path = require('path'); const Pact = require('@pact-foundation/pact').Pact; global.port = 8099; global.provider = new Pact({ cors: true, port: global.port, log: path.resolve(process.cwd(), 'pacts/logs', 'pact.log'), loglevel: 'debug', dir: path.resolve(process.cwd(), 'pacts'), spec: 2, pactfileWriteMode: 'update', consumer: 'b-consumer', provider: 'a-provider', host: '172.17.0.1' }); For host, I tired: localhost, 127.0.0.1, 172.17.0.1, 192.168.99.1```

bethskurrie
2020-04-02 23:26
Best to ask in the #pact-broker channel @ina.lopez

matt.fellows
2020-04-02 23:27
that looks like an issue unrelated to the broker

bethskurrie
2020-04-02 23:27
Agreed. I think your docker set up is not right.

matt.fellows
2020-04-02 23:27
You?re setting the port to `8099` and when the test framework starts up, it?s trying to start a service on that port

matt.fellows
2020-04-02 23:27
If the port is not available, you will get that error

matt.fellows
2020-04-02 23:28
It could be unavailable because of a parallel process using the same port, because something didn?t shut down correctly etc.

ina.lopez
2020-04-02 23:28
I did a grep -w '8099/tcp' /etc/services and nothing was using it.

ina.lopez
2020-04-02 23:28
did I forget to mention I tried many ports

matt.fellows
2020-04-02 23:29
My suggestion is to leave host blank, and leave port blank. Pact JS will try to find an available port, and return what port it found in when `setup()` ends

matt.fellows
2020-04-02 23:29
You can then use that to configure your http client

matt.fellows
2020-04-02 23:29
> did I forget to mention I tried many ports maybe! :slightly_smiling_face: (or I missed it)

ina.lopez
2020-04-02 23:30
but I am using this global.port in my actual test

matt.fellows
2020-04-02 23:30
It certainly looks like an issue in your environment though. Perhaps you don?t have permission to bind ports?

matt.fellows
2020-04-02 23:31
so can you not do something like this (pseudo js): ```const provider =new Pact(?) before(() => { provider.setup().then(config => { global.port = config.port }) }) ```

matt.fellows
2020-04-02 23:31
Hardcoding the port is basically never going to be a good thing, because of the chances of port conflicts. If you do run Docker with a private network per container, then you might be OK

ina.lopez
2020-04-02 23:32
let me try. Good advise

ina.lopez
2020-04-02 23:40
Well, with that fix, at least it is not complaining about connection refused :slightly_smiling_face: But it does spin forever...

matt.fellows
2020-04-02 23:40
Did the setup promise return or reject?

matt.fellows
2020-04-02 23:41
ok, ignoring pact for a moment, are you able to start a service within that docker container or a port of your choosing?

matt.fellows
2020-04-02 23:41
e.g. something like `python -m http.server 8099` should do it (python 3)

matt.fellows
2020-04-02 23:41
`python -m SimpleHTTPServer 8099` for Python 2

matt.fellows
2020-04-02 23:42
of course there are other linux tools e.g. `nc -l 8099`

ina.lopez
2020-04-02 23:42
returns `Serving HTTP on 0.0.0.0 port 8099 ..`

matt.fellows
2020-04-02 23:43
have you tried `0.0.0.0` as the listen port for Pact?

matt.fellows
2020-04-02 23:43
maybe you can only bind to public address?

ina.lopez
2020-04-02 23:43
I have not tried 0.0.0.0

matt.fellows
2020-04-02 23:44
it might be Pact trying to check if an ipv6 port is available

ina.lopez
2020-04-02 23:45
perhaps

ina.lopez
2020-04-02 23:53
Oh man, I tried just about everything... I ran out of options. Maybe I should start drinking :slightly_smiling_face: It is 5o'clock here in SF :slightly_smiling_face:

matt.fellows
2020-04-02 23:58
My suburb just lost power. ETA is 6pm (7 hours away). I have 3 workshops today that I'm either attending/running... I might have to join you

matt.fellows
2020-04-02 23:58
Chat later I'm sorry. Heading into first one

ina.lopez
2020-04-03 00:01
ok

mukheem
2020-04-03 06:07
Is it feasible to implement PACT for those Interactions where the request and response are not in JSON but are XMLs ?

matt.fellows
2020-04-03 07:02
In Rust yes, in JS sort of (we just released a beta for testing), and in JVM it?s a sort of also

matt.fellows
2020-04-03 07:02
coming soon, but help wanted is the best answer I can give

mukheem
2020-04-03 07:09
Okay thanks @matt.fellows.

mukheem
2020-04-03 07:10
Help wanted ?? How ca nwe helpyou @matt.fellows

matt.fellows
2020-04-03 07:10
which language - assuming Python?

mukheem
2020-04-03 07:10
Yes, It's Python :slightly_smiling_face:

matt.fellows
2020-04-03 07:10
see https://github.com/pact-foundation/pact-reference/ - that?s where the underlying engine that does it all will have it

matt.fellows
2020-04-03 07:11
Sorry, I also lost power at that moment. Let me know how you go. You might need to hack the `net.js` file to find a combination that works

mukheem
2020-04-03 07:11
Let me check it.

bethskurrie
2020-04-03 07:31
Haha, sneaky work around!

2020-04-03 07:44
A new post has been created in *Feature Requests*

2020-04-03 07:48
A post in *Feature Requests* has been marked as *complete*

2020-04-03 07:48
A post in *Feature Requests* has been marked as *complete*

2020-04-03 07:51
A post in *Feature Requests* has been marked as *in progress*

2020-04-03 07:52
A post in *Feature Requests* has been marked as *in progress*

2020-04-03 07:53
A post in *Feature Requests* has been marked as *in progress*

2020-04-03 07:53
A post in *Feature Requests* has been marked as *complete*

bethskurrie
2020-04-03 07:56
Did you end up using the pact-provider-verifier or pact-js @adadache?

bethskurrie
2020-04-03 07:56
@tjones the way rspec handles mutlile output files is `--format format1 --out out --format format2 --out out2`

bethskurrie
2020-04-03 07:56
How much would pact-js blow up if we tried to support that?

adadache
2020-04-03 08:02
@bethskurrie pact-provider-verifier using cli. :slightly_smiling_face: Actually using pac-cli docker.

adadache
2020-04-03 08:03
The best and only solution I use is the latter? no environment setup (at least any other thank docker)

adadache
2020-04-03 08:03
We are shooting containers in DinD CI/CD pipelines.

adadache
2020-04-03 08:04
Docker in Docker made us invincible with Pact.

bethskurrie
2020-04-03 09:06
cool, I can support multiple outputs very easily then.

s1apped
2020-04-03 12:22
Hi. I have a question about best practice to handle below scenario: Endpoint returns response object with multiple properties and nested objects. Some of the nested objects have different implementation and can return additional properties. What is the best approach when creating contract? Create multiple contracts with state for each of the implementation?

mrudzki
2020-04-03 14:36
has joined #general

bwoodhouse322
2020-04-03 15:23
has joined #general

ina.lopez
2020-04-03 18:49
The problem was the docker image. I downloaded stand-alone Jenkins. I did leave Broker in docker image since it was also configuring PostGRES db for me. Man, I tell you California wine is the best. I found me an amazing Cabernet and after 2 glasses, everything started making sense :)

ina.lopez
2020-04-03 18:51
Is there a way to delete a Webhook created in Pact Broker, without deleting Pacticipant?

cesar.lopes
2020-04-03 19:20
Hello, imagine a scenario were we need to mock two distinct services in the same a test, how should we use pact for that?

ina.lopez
2020-04-03 19:22
found documentation :slightly_smiling_face: DELETE against your webhook URL. i.e. in postman: ```DELETE http://localhost/webhooks/TzQoXESDkN7g-YMOdIX4SQ```

bernardoguerr
2020-04-03 20:24
Good question! The way I've done it is that normally per scenario I test one single integration. If your service depends on more than one, I usually just mock the other service to give the happy path success response with any mocking tool (e.g. nock in JS). This allows me to generate a contract for that single integration, and just test the different variations for that integration. Then I do the same with the other integration. Use Pact Mock Server for the integration I'm trying to test at that time, and use any mocking tool for the other, assuming it gives the happy path response

cesar.lopes
2020-04-03 20:38
ok, that should do it, ty

matt.fellows
2020-04-03 22:15
That?s great to hear!

matt.fellows
2020-04-03 22:16
I was in SF in late 2018 (during the Camp fire :disappointed: ) but did make it to Napa. The wine was lovely, although I?m usually a Shiraz kind of guy :wink:

matt.fellows
2020-04-03 22:24
yep - every resource in Pactflow would work as you might expect.

matt.fellows
2020-04-03 22:24

matt.fellows
2020-04-03 22:25
There is an article for this somewhere on the docs site too

tjones
2020-04-04 05:49
@bethskurrie I don?t think pact-node supports multiple outputs at the moment, but it would be an easy change

cesar.lopes
2020-04-04 12:03
hello, can?t find anything about that

bernardoguerr
2020-04-04 12:38
Btw @matt.fellows it would probably be interesting to make this mocking capability part of the Pact libraries itself. I think it would keep the whole test within the Pact ecosystem, instead of needing another external library. I mean, your mock server already does this, it's just that in this case you just want to create a very simplified interaction that doesn't generate a contract. Either that or some sort of "depends on" concept whereby an interaction may depend on another being there WDYT?

cesar.lopes
2020-04-04 13:52
that would be great

ina.lopez
2020-04-05 01:27
My Pact Broker is on Docker image, accessible on localhost:80. My Jenkins is running independently on my mac, accessible on localhost:8080. I was able to call my Jenkins job using Postman with `Jenkins-Crumb` and `Authorization` headers. Now, I am trying to make Pact Broker webhook call my Jenkins job, but it's throwing error: ``` Error executing webhook fGe8FbvT-IF2IJt35nfZxg Errno::EADDRNOTAVAIL - Failed to open TCP connection to localhost:8080 (Cannot assign requested address - connect(2) for "localhost" port 8080``` Anyone have any idea why this is happening?

bethskurrie
2020-04-05 01:28
Please ask questions related to the pact broker in the #pact-broker channel.

bethskurrie
2020-04-05 01:28
This is a docker issue.

bethskurrie
2020-04-05 01:29
Are you using docker-compose?

ina.lopez
2020-04-05 01:29
yes

bethskurrie
2020-04-05 01:29
You need to give the webhook the service name of the jenkins service

bethskurrie
2020-04-05 01:30
the pact broker is trying to connect to its own localhost

bethskurrie
2020-04-05 01:30
from within the pact broker container, it needs to access the jenkins container via the jenkins container's host name.

bethskurrie
2020-04-05 01:31
you'll need a ```depends_on: - jenkins```

bethskurrie
2020-04-05 01:31
in your definition of your broker

bethskurrie
2020-04-05 01:31
and vice versa, so the the broker can connect to jenkins.

bethskurrie
2020-04-05 01:32
Not sure how it works when each container depends on the other :thinking_face:

ina.lopez
2020-04-05 01:35
I am not sure how to define jenkins in the this file, since jenkins is not part of that container...

ina.lopez
2020-04-05 01:36
I am so new to all of this :neutral_face:

ina.lopez
2020-04-05 02:32
jenkins is not running in a container. I have it running by iteslf on port localhost:8080

matt.fellows
2020-04-05 03:16
OK, so localhost _within_ a container is not the same as localhost _outside_ of a container

matt.fellows
2020-04-05 03:17
i.e. if the host?s localhost is `127.0.0.1` and the docker container is not sharing the same network space (and that is highly likely, and recommended - especially in CI) then `localhost` from within a container is not talking to the same thing

matt.fellows
2020-04-05 03:18
You would need to either a) ensure the same network space is used (e.g. bridged networking mode) or b) pass in to the broker container dynamically, the actual IP address it can be reached on

matt.fellows
2020-04-05 03:19
is this just for local testing? Or your actual CI setup?

bethskurrie
2020-04-05 03:44
@ina.lopez if you'd like to see a working CI/CD set up with a consumer and provider, I've just made a demo here https://github.com/pactflow/example-consumer


bethskurrie
2020-04-05 03:45
Having proper host names makes it a bit simpler.

bethskurrie
2020-04-05 03:46
You can fork the repos, grab a free broker from http://pactflow.io and update the environment variables to point to your own broker.

bethskurrie
2020-04-05 03:47
You'll just need to replace the username and password env vars with PACT_BROKER_TOKEN as the new pactflow accounts use bearer tokens, not basic auth.

mcruzdrake
2020-04-05 16:29
has joined #general

cesar.lopes
2020-04-05 22:24
```Hello, I want to test the same request path with different queries, for example abc-com?a=1&b=2 and hhttp://abc.com?a=3&b=4 abc-com?a=1&b=2 and hhttp://abc.com?a=3&b=4 I can see both contracts on json file, but when I run the tests the second test will use the first contract.```


bethskurrie
2020-04-05 22:27
Which language @cesar.lopes?

cesar.lopes
2020-04-05 22:28
typescript

bethskurrie
2020-04-05 22:28
I mean which pact implementation - sounds like pact-js

cesar.lopes
2020-04-05 22:28
yep

bethskurrie
2020-04-05 22:28
are you testing both interactions at the same time?

bethskurrie
2020-04-05 22:28
ie. are they in separate tests, or the same one?

cesar.lopes
2020-04-05 22:29
same file but in separated describe/interactions

bethskurrie
2020-04-05 22:29
they should be in completely separate contexts then.

bethskurrie
2020-04-05 22:30
when you say, the second uses the first contract, do you mean the response for the second request is the one you defined in the first interaction?

cesar.lopes
2020-04-05 22:30
yes

matt.fellows
2020-04-05 22:31
Can you please share your code setup?

bethskurrie
2020-04-05 22:31
can you give us a working example that demonstrates the issue please? You can fork pact-js and modify one of the examples in the example directory.

cesar.lopes
2020-04-05 22:31
Ok, I?ll ty

cesar.lopes
2020-04-05 22:59
Amazing news, this is a problem on the software not at the testing tool :slightly_smiling_face: so much winning

matt.fellows
2020-04-05 22:59
:slightly_smiling_face:

cesar.lopes
2020-04-05 22:59
ty

matt.fellows
2020-04-05 22:59
np

cesar.lopes
2020-04-05 23:00
should we use pact for unit tests? I questing this because on the most cases we will need to mock function as well?

abubics
2020-04-05 23:42
It's really a unit-testing framework for network boundaries, so *I* would say yes ;)

cesar.lopes
2020-04-05 23:43
:+1:

matt.fellows
2020-04-05 23:43
What Andras said


bethskurrie
2020-04-05 23:43
^^ Got some guides on that @cesar.lopes

matt.fellows
2020-04-05 23:44
You can probably get into splitting heirs about what is/isn?t a unit test, but it?s not very helpful. In the end, we find it best tested alongside other unit tests

cesar.lopes
2020-04-05 23:58
ty all

ric.yik
2020-04-06 06:52
has joined #general

martin.nilsson
2020-04-06 13:09
has joined #general

paras.vora1801
2020-04-06 16:36
Hello, I am trying to write a consumer side test, please see the code below: ```package com.inq.ceapi.contract.test; import http://au.com.dius.pact.consumer.dsl.PactDslJsonBody; import http://au.com.dius.pact.consumer.dsl.PactDslWithProvider; import http://au.com.dius.pact.consumer.junit.PactHttpsProviderRule; import http://au.com.dius.pact.consumer.junit.PactVerification; import http://au.com.dius.pact.core.model.PactSpecVersion; import http://au.com.dius.pact.core.model.RequestResponsePact; import http://au.com.dius.pact.core.model.annotations.Pact; import org.apache.commons.collections.map.HashedMap; import org.apache.http.HttpResponse; import org.apache.http.client.fluent.Request; import org.apache.http.util.EntityUtils; import org.json.JSONException; import org.json.JSONObject; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.junit4.SpringRunner; import static org.junit.Assert.assertThat; import static http://org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.equalTo; import http://java.io.IOException; import java.util.Map; @RunWith(SpringRunner.class) public class ConsumerTests { @Rule public PactHttpsProviderRule auth_server = new PactHttpsProviderRule("auth_server", "localhost", 10443, true, PactSpecVersion.V3, this); static String END_POINT_AUTH = "/oauth-server/oauth/token"; @Pact(consumer = "ceapi", provider = "auth_server") public RequestResponsePact createPactToFetchAuthToken(PactDslWithProvider builder) { Map<String, String> requestHeaders = new HashedMap(); requestHeaders.put("Content-Type", "application/x-www-form-urlencoded; charset=utf-8"); requestHeaders.put( "Authorization","Basic Y2VhcGlDbGllbnRJZDpjZWFwaUNsaWVudFNlY3JldA=="); Map<String, String> responseHeaders = new HashedMap(); responseHeaders.put("Content-Type", "application/json;charset=utf-8"); return builder .given("A valid authorization token is returned") .uponReceiving("A request to fetch the authorization token") .method("POST") .headers(requestHeaders) .path(END_POINT_AUTH) .body(new PactDslJsonBody() .stringType("client_id", "ceapiClientId") .stringType( "grant_type","client_credentials")) .willRespondWith() .status(200) .headers(responseHeaders) .body(new PactDslJsonBody() .stringType("access_token", "access_token") .stringValue("token_type", "Bearer") .integerType("expires_in", 60) .stringType("scope", "read write") .stringType("jti","a5fa8e08-9790-430b-81e3-509e8653656a") .array("sites") .closeArray()) .toPact(); } public JSONObject buildResponseObject(String authServerBaseUrl) throws IOException, JSONException { HttpResponse response = http://Request.Post(authServerBaseUrl + END_POINT_AUTH) .addHeader("Content-Type", "application/json;charset=utf-8") .execute().returnResponse(); assertThat(response.getStatusLine().getStatusCode(), is(equalTo(200))); JSONObject jsonObject = new JSONObject(EntityUtils.toString(response.getEntity())); return jsonObject; } @Test @PactVerification(value = "auth_server", fragment = "createPactToFetchAuthToken") public void getAuthToken() throws IOException, JSONException{ JSONObject responseJson = buildResponseObject(auth_server.getUrl()); } }```

paras.vora1801
2020-04-06 16:36
Somehow, the mock provider server is unable to initiate, `io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Can't assign requested address` `at io.netty.channel.unix.Errors.newIOException(Errors.java:122)` `at io.netty.channel.unix.Socket.bind(Socket.java:287)` `at io.netty.channel.kqueue.AbstractKQueueChannel.doBind(AbstractKQueueChannel.java:688)` `at io.netty.channel.kqueue.KQueueServerSocketChannel.doBind(KQueueServerSocketChannel.java:61)` `at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:558)` `at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1358)` `at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:501)` `at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:486)` `at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1019)` `at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:254)` `at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)` `at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163)` `at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)` `at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)` `at io.netty.channel.kqueue.KQueueEventLoop.run(KQueueEventLoop.java:276)` `at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)` `at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)` `at java.lang.Thread.run(Thread.java:821)` Can anyone help here please?

kyle.hammond
2020-04-06 17:52
Probably the #pact-jvm-help channel would be a better place for this question.

matt.fellows
2020-04-06 22:11
Have you checked to see if the port is already in use? That would be the obvious one

matt.fellows
2020-04-06 22:11
Either that, or you?re unable to start a port (privileges)


tjones
2020-04-07 00:50
I haven?t!

matt.fellows
2020-04-07 00:50
I noticed that Pact JS is included in the microservices template, so that?s pretty cool


tjones
2020-04-07 00:57
Yeah, the sequence diagram there reads like Pact JS

tjones
2020-04-07 00:57
I tried to make a generic sequence diagram while writing the intro docs, but each framework is so different

matt.fellows
2020-04-07 00:59
yeah, that?s the strength and weakness of Pact I think. It can be made to fit into all scenarios, but because of that, it?s less instructive.

matt.fellows
2020-04-07 00:59
Pact JVM has the opposite problem - so many options, it?s hard to get to the right one, even though they pretty much all exist

tjones
2020-04-07 01:01
I mean, Pact JS has opinions about how to structure your code (as in, you?re going to have a bad time if you?re spreading your API calls around rather than abstracting them in a module). I just happen to strongly agree with Pact-JS.

tjones
2020-04-07 01:01
I?ve been thinking we should make a documentation page about that.


tjones
2020-04-07 01:02
It?s less relevant to JVM land, but for some reason JS has a culture of putting the whole API call where you need the data, maybe because it?s usually one line and a callback

tjones
2020-04-07 01:03
I?ve seen things like: ```const someData = await api(endpoints.someWhere, api.headers);```

matt.fellows
2020-04-07 01:15
sorry in a meeting

matt.fellows
2020-04-07 01:15
yes, I see that a lot also

matt.fellows
2020-04-07 01:15
It doesn?t often need to be marshalled/unmarshalled to DTOs and all of that stuff

paras.vora1801
2020-04-07 03:00
@matt.fellows I am unable to use any of the port, tried changing the numbers, no luck.

matt.fellows
2020-04-07 04:04
Just so I?m clear. Are you able to run _anything_ on any port? Independent of Pact, that is

matt.fellows
2020-04-07 04:05
For exampe, if on linux, you could do `nc -l 8080` to check if port `8080` is available. If you can?t run a command like this, you may not be able to open ports. Are you running in Docker? or your machine? What?s the OS? Can you please find a way for us to reproduce the problem?

enash
2020-04-07 05:52
has joined #general

paras.vora1801
2020-04-07 06:20
@matt.fellows Somehow the binding error has been resolved however, I am facing an `500 Internal Server Error` while executing the code: ```return InsecureHttpsRequest.httpsPost(url + encodePath(path)) .addHeader("Content-Type", "application/x-www-form-urlencoded; charset=utf-8") .addHeader("Authorization","Basic Y2VhcGlDbGllbnRJZDpjZWFwaUNsaWVudFNlY3JldA==") /*.bodyForm(new BasicNameValuePair("grant_type", "client_credentials")) .bodyForm(new BasicNameValuePair("client_id", "ceapiClientId"))*/ .bodyForm(new BasicNameValuePair("grant_type", "client_credentials"), new BasicNameValuePair("client_id", "ceapiClientId")) .execute().returnResponse();```


paras.vora1801
2020-04-07 06:22
@matt.fellows It is unable to connect to the provider server

matt.fellows
2020-04-07 06:32
should it be https?

matt.fellows
2020-04-07 06:32
How did you resolve the other problem? That feedback would be nice for others just in case they have the same issue

paras.vora1801
2020-04-07 06:34
Yes, the provider service is hosted under https protocol

matt.fellows
2020-04-07 06:35
the real one, or the mock one Pact JVM is setting up?

paras.vora1801
2020-04-07 06:35
The mock provider server

matt.fellows
2020-04-07 06:35
ok.

matt.fellows
2020-04-07 06:36
Are there any logs suggesting why there is a 500?

paras.vora1801
2020-04-07 06:36
```InsecureHttpsRequest.httpsPost(url + encodePath(path))``` It is throwing 500 status code right at this line.

paras.vora1801
2020-04-07 06:38
`2020-04-07 11:59:05,038 INFO [o.s.t.c.s.DefaultTestContextBootstrapper] - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.inq.ceapi.contract.test.ConsumerTests], using DelegatingSmartContextLoader` `2020-04-07 11:59:05,045 INFO [o.s.t.c.s.AbstractContextLoader] - Could not detect default resource locations for test class [com.inq.ceapi.contract.test.ConsumerTests]: no resource found for suffixes {-context.xml}.` `2020-04-07 11:59:05,045 INFO [o.s.t.c.s.AnnotationConfigContextLoaderUtils] - Could not detect default configuration classes for test class [com.inq.ceapi.contract.test.ConsumerTests]: ConsumerTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.` `2020-04-07 11:59:05,078 INFO [o.s.t.c.s.DefaultTestContextBootstrapper] - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]` `2020-04-07 11:59:05,095 INFO [o.s.t.c.s.DefaultTestContextBootstrapper] - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@ca18cdee, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@becdcaf0, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@833481f9, org.springframework.test.context.support.DirtiesContextTestExecutionListener@502eed96, org.springframework.test.context.transaction.TransactionalTestExecutionListener@75d79da6, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@b4186aa3, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@bea92b05, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@cee9994f, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener@4b7d666, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener@3b6f441e, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener@8cee8a96, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener@996d3600]` `2020-04-07 11:59:05,360 WARN [o.s.b.t.j.DuplicateJsonObjectContextCustomizerFactory$DuplicateJsonObjectContextCustomizer] - __Found multiple occurrences of org.json.JSONObject on the class path:__ jar:file:/Users/paras.vora/.m2/repository/com/vaadin/external/google/android-json/0.0.20131108.vaadin1/android-json-0.0.20131108.vaadin1.jar!/org/json/JSONObject.class_ file:/Users/paras.vora/n_workspace/rt/commons/commons-json/target/classes/org/json/JSONObject.class_ jar:file:/Users/paras.vora/.m2/repository/org/json/json/20160212/json-20160212.jar!/org/json/JSONObject.class__You may wish to exclude one of them to ensure predictable runtime behaviour_` `2020-04-07 11:59:05,364 INFO [o.s.c.s.GenericApplicationContext] - Refreshing org.springframework.context.support.GenericApplicationContext@526afac0: startup date [Tue Apr 07 11:59:05 IST 2020]; root of context hierarchy` `2020-04-07 11:59:05,869 INFO [Application] - No ktor.deployment.watch patterns specified, automatic reload is not active` `2020-04-07 11:59:05,910 INFO [Application] - Responding at https://localhost:10443` `2020-04-07 11:59:06,858 ERROR [Application] - Unhandled: POST - /oauth-server/oauth/token`

ukrainian1991
2020-04-07 08:50
has joined #general

ukrainian1991
2020-04-07 08:53
Hi! Is there a way to use PACT for microservices with gRPC communication? I see that issue for gRPC support is open. Are there any workarounds?

tjones
2020-04-07 08:54
I haven?t used gRPC, but you might get some mileage out of the message pact support, maybe

matt.fellows
2020-04-07 09:24
See also #protobufs

matt.fellows
2020-04-07 09:25
I know they?re not the same, but it?s basically a proxy for that conversation

ukrainian1991
2020-04-07 09:28
Thanks for info

artur.mkr
2020-04-07 14:51
has joined #general

yuniorbv
2020-04-07 15:55
has joined #general

ina.lopez
2020-04-07 22:47
```it is only safe to deploy the consumer if it was verified against the production version of the provider.*``` https://docs.pact.io/provider so, does this mean that when triggered by broker, Provider CI verify: 1. gets the latest provider prod version from broker (PROD_VERSION=pact-broker describe-version...) 2. checks it out from git, git checkout ${PROD_VERSION} 3. runs provider server locally, verifies and publishes results (PACT_PUBLISHED=${pactPublished} PACT_PUBLISH_RESULTS=true run pact tests)

bethskurrie
2020-04-07 22:48
Yes, that is the way you would do it if necessary.

bethskurrie
2020-04-07 22:48
Most people don't seem to have found it necessary though.

bethskurrie
2020-04-07 22:48
I think if the consumer and provider release cycles are close enough that it doesn't really come up very often.

bethskurrie
2020-04-07 22:51
I'll add an example to the provider codebase when I'm working on it next.

matt.fellows
2020-04-08 00:11
to add to this sentiment, I?ve also never fully reached the Pact nirvana either - but I?ve never experienced an issue where I?ve actually needed that scenario. Not saying it?s not required, but in my experience not having done that has never caused issues

matt.fellows
2020-04-08 00:11
If you?ve gotten this far in the process - you?re doing _very well_

bethskurrie
2020-04-08 00:13
I'd try without it for a while, and only add it in if you find it necessary.

ina.lopez
2020-04-08 01:51
```As you have two different builds running the pact verifications (one when the provider changes, one when the contract changes) it is best to use a provider version number that is deterministic (eg. does not include your CI build number) so that a verification from either job is recorded with the same version number. This will help you when it comes to using the can-i-deploy tool``` Am I understanding this right, or Consumer should use `GIT_HASH` and Provider should use something "deterministic"... something developers change, as in *package.json.version* ?

bethskurrie
2020-04-08 01:52
use the git hash unless there's some reason that makes this impossible.

bethskurrie
2020-04-08 01:52
for both consumer and provider

bethskurrie
2020-04-08 01:54
I'll update the docs to clearly state that the git sha is the best option wherever possible.

matt.fellows
2020-04-08 01:57
I usually go with something like `semver-SHA` e.g. `1.0.0-a12xy8en`

bethskurrie
2020-04-08 01:57
This doc is a good explanation of versioning and version numbers https://docs.pact.io/getting_started/versioning_in_the_pact_broker

siddharth.gupta
2020-04-08 07:41
Hi there , I am beginner with Pact , I have been able to run consumer and provider tests provided at https://github.com/pact-foundation/pact-net. But I have question for the experts , when we test the provider APIs which interacts with an external component for example a SQL db , how do we deal with such scenario when running contract tests on local developer machine . As we do not deploy the services instead use self hosted routing .

2020-04-08 11:14
A post in *Feature Requests* has been marked as *complete*


sridhar_murari
2020-04-08 14:29
has joined #general

anguyen0815
2020-04-08 15:37
has joined #general

anguyen0815
2020-04-08 15:52
Good morning guys, I'm using pactflow for the broker and just wondering how to use WIP feature with pending pacts. I know I can do ``` consumerVersionSelector: [{ tag: "prod", all: true }, { tag: "master", latest: true } ],``` to retrieve all prod pacts and the latest master pact. How do I also make it retrieve WIP/pending pacts?

bethskurrie
2020-04-08 21:08
To turn on the pending, you need to set enablePending: true @anguyen0815

bethskurrie
2020-04-08 21:09
The wip pacts is slightly different. I'm not sure if @matt.fellows has added support for that yet.

bethskurrie
2020-04-08 21:09
You need to give it a date.

bethskurrie
2020-04-08 21:10
I've just checked the code, and it's not supported yet. I'll raise an issue for it.

anguyen0815
2020-04-08 21:13
@bethskurrie thanks for your fast response. do you know when it will be available to use? just an estimate would help a lot.

matt.fellows
2020-04-08 21:42
Which language - JS?

matt.fellows
2020-04-08 21:42
Beth I didn?t realise WIP pacts was a thing already, I?ll get that added to JS/Go today

anguyen0815
2020-04-08 21:48
@matt.fellows I'm using JS

matt.fellows
2020-04-08 21:53
cool, thanks

matt.fellows
2020-04-08 21:53
I?ll try and get that added today

anguyen0815
2020-04-08 22:09
you guys are awesome. thank you!

matt.fellows
2020-04-08 22:10
:+1:

bethskurrie
2020-04-08 22:10
I've created a documentation issue and a matching one in pact js.

eric.jones
2020-04-09 12:11
has joined #general

anguyen0815
2020-04-09 16:11
Hi guys, quick question about pact verifier. Our backend is in Elixir so we can't use Ruby. It looks like there are 2 dockers out there that we can use for verifying pacts https://hub.docker.com/r/pactfoundation/pact-cli and https://hub.docker.com/r/dius/pact-provider-verifier-docker. Which one should I use? It looks like the second one is only about verifying pacts and the first one includes everything.

komeershettyvinod
2020-04-09 16:36
has joined #general

kjtester
2020-04-09 16:47
has joined #general

kjtester
2020-04-09 16:49
:wave: I?m here! What?d I miss?

ina.lopez
2020-04-09 23:12
In the example-provider: https://github.com/pactflow/example-provider/blob/master/product/product.pact.test.js _TRAVIS_BRANCH_ is used as a tag. What I am reading in https://docs.pact.io/pact_nirvana makes me think that we should perhaps tag it differently. What is considered *stable tag*? ```In the provider verification configuration, change the pact that is being verified from the latest pact to the latest pact for the stable tag. This will help keep your provider builds green.```

bethskurrie
2020-04-09 23:15
They're not contradictory, but it seems the set up guide does not explain it clearly enough.

bethskurrie
2020-04-09 23:15
Stable just means "master" - but some teams don't use branch based workflows, so I was trying to use a non-workflow specific term.

bethskurrie
2020-04-09 23:16
That's right.

bethskurrie
2020-04-09 23:17
Use the pact cli, because you'll be able to use it for other parts of the workflow (can I deploy, webhook creation etc)

bethskurrie
2020-04-09 23:18
It's Ruby under the hood, but because it just uses http to do the verifications, it doesn't make a difference which language it's in.

anguyen0815
2020-04-09 23:25
thank you for the info!

faisallarai
2020-04-10 00:26
has joined #general

matt.fellows
2020-04-10 11:58
v9.9.3 should be out soon @anguyen0815 which has the WIP feature

anguyen0815
2020-04-10 13:24
that's so awesome. excited to start using it. thanks guys!!

l.dziedziul
2020-04-10 14:07
has joined #general

david.tran
2020-04-10 16:20
has joined #general

rahulpandey8920
2020-04-12 19:22
has joined #general

rahulpandey8920
2020-04-12 22:10
Hello, Is there any standalone way of generating documentation from a pact json file which looks like the one shown in pact broker ?

bethskurrie
2020-04-12 22:11
The code exists in the Ruby gem

bethskurrie
2020-04-12 22:11
I'll see is it's accessible in the standalone

rahulpandey8920
2020-04-12 22:20
Thanks Beth! That would be helpful.

bethskurrie
2020-04-12 22:24
`pact/bin/pact docs --pact-dir ./pacts --doc-dir docs`

rahulpandey8920
2020-04-12 22:45
Thanks! That works. :slightly_smiling_face: I didn't know that the documentation is created in MarkDown format. Somehow I assumed it to be some sort of HTML.

bethskurrie
2020-04-12 22:47
Oh, yes. The html is actually generated from the markdown.

bethskurrie
2020-04-12 22:49
The markdown came first, before we had the pact broker, and then I took the markdown and used a library to turn it in to html.

rahulpandey8920
2020-04-12 22:51
Yeah, that makes sense. I am not using pact broker yet and was just looking to get a better view of the interactions so thought of generating the report.

bethskurrie
2020-04-12 23:08
When it was written, we were checking pacts in to the repository, so the markdown was in there to, and so it rendered as HTML in the browser.

bonnie.malec
2020-04-13 02:23
has joined #general

christopher.richard
2020-04-13 12:21
This is super cool.

rahulpandey8920
2020-04-13 20:21
@bethskurrie is the library that is used to turn the markdown into html an open source library ?

cody
2020-04-13 20:42
has joined #general

rahulpandey8920
2020-04-13 23:07
Hello :wave: I am trying to find any documentation and practices around how does the provider sets up the state. I've come across this statement from https://docs.pact.io/provider/using_provider_states_effectively > _The provider team sets up the relevant provider state by creating one alligator with the name Mary._ Would this mean creating an alligator in the actual database and running the provider with all its external dependencies ?

rahulpandey8920
2020-04-13 23:08
Or we could stub all the external dependencies of the provider when running the contract tests ?

rahulpandey8920
2020-04-13 23:09
Is there any example of a producer implementing the setting up of the state I could refer to ?

uglyog
2020-04-13 23:10
It's up to the provider team to decide what needs to be done. But the intention of the provider states is to put the provider service in the correct state to return the correct response.

uglyog
2020-04-13 23:11
If there is a database, creating records there can work. So can mocking out the database layer

matt.fellows
2020-04-13 23:12
What language are you using @rahulpandey8920?

matt.fellows
2020-04-13 23:12
Each language should have at least an example of doing that, so I?d suggest going to the language docs for that

rahulpandey8920
2020-04-13 23:26
In my case, the provider is a REST API implemented in C# dotnet. So would it mean creating an endpoint which would take the state as a string and put the provider service in that state ?

matt.fellows
2020-04-13 23:26
yep!


rahulpandey8920
2020-04-13 23:32
Thanks @matt.fellows! I can see that the provider has a middleware which helps in setting up the expected state.

matt.fellows
2020-04-13 23:33
Working late btw :P

matt.fellows
2020-04-13 23:34
I was doing the same about the same time last night :raised_hands:

rahulpandey8920
2020-04-13 23:40
Have lost track of days and time these days :smile:

rahulpandey8920
2020-04-13 23:41
Thanks for your help.

matt.fellows
2020-04-13 23:41
:smile:

derekhu
2020-04-14 01:38
has joined #general

derekhu
2020-04-14 04:23
Is there any way to combine the pact with swagger?

aaron590
2020-04-14 05:55
has joined #general



artur.ashyrov
2020-04-14 18:30
has joined #general

2020-04-15 02:32
A post in *Feature Requests* has been marked as *in progress*

2020-04-15 02:32
A new post has been created in *Feature Requests*

2020-04-15 04:17
A post in *Feature Requests* has been marked as *in progress*

2020-04-15 04:18
A post in *Feature Requests* has been marked as *planned*

2020-04-15 04:20
A new post has been created in *Feature Requests*

2020-04-15 04:24
A post in *Feature Requests* has been marked as *planned*

2020-04-15 08:32
A new post has been created in *Feature Requests*

chandanakurumeti27
2020-04-15 12:24
has joined #general

safiyya
2020-04-15 13:25
Hi all, I?m a beginner with Pact. Perhaps a dumb question but what is the advantage of using contract testing & Pact in a Typescript world? If I were to create a shared Typescript library as a ?schema repository? for all our async messages payloads (similar to a schema registry for messages), what is the benefit of introducing Pact in my testing suite?

l.dziedziul
2020-04-15 13:46
A shared Typescript library can lead to synchronized deployments of all your services, which basically turn them into a distributed monolith. Ownership of the schema would be also problematic. Each change in the schema can potentially break non-related services because you aren?t aware of the parts of the schema it was relying on. You can also have a bit different serialization settings in each service result with different date format in json.


james.salamon
2020-04-15 14:33
has joined #general

travis.anderson
2020-04-15 15:11
Hello everyone :wave: I have been auditing my organization's automated testing strategy and developing a comprehensive strategy moving forward. My plan is to have it heavily build around Pact but it leaves a very small gap https://docs.pact.io/consumer/contract_tests_not_functional_tests#does-the-provider-do-the-right-thing-with-the-request. Does anybody have any examples, theoretical or otherwise, about how they covered this small gap in testing? I am in the JavaScript universe so my idea was to utilize supertest or a similar library then reach into the given database to verify the "side effects." Preferably these tests would be run in a deployed environment too.

d.drinfeld
2020-04-15 16:54
has joined #general

d.drinfeld
2020-04-15 16:57
Hi folks, very new to Pact? Not sure if I missed this in documentation, maybe someone can point me to it. Does provider verification have to run on a live instance of the provider, or can it be run at build time? I am particularly interested in Java side of things.

wesleythomaswilliams
2020-04-15 17:04
The way pact works is it's effectively simulating requests from your consumer (based on the pact file contents). So it doesn't matter where or when you're doing verification on the provider because it's being tested in isolation.

wesleythomaswilliams
2020-04-15 17:05
I'm working on the java side too (with spring)

d.drinfeld
2020-04-15 17:07
So when doing provider verification, are you running that on a live instance of the provider? I.e. do you stand up a provider instance and run against that, or run the provider verification during build time, in a form of junit test? Sorry if I sound completely off, still try to wrap my mind around it.

wesleythomaswilliams
2020-04-15 17:08
It's run at build time as a junit test.

d.drinfeld
2020-04-15 17:08
Okay, that makes sense then. In that case you don?t need to stand up the web server or anything like that to run verification. Its run as part of the unit test, where you can respond to the requests with crafted responses for specific use cases. (With DB and and everything else stubbed out)

d.drinfeld
2020-04-15 17:20
Reading through docs, provider verification still seems to run against a live instance? I.e. ``` @TestTarget public final Target target = new HttpTarget(8080);``` So a server is run at localhost, on port `8080` against which the verification is happening? I am understanding this correctly?

wesleythomaswilliams
2020-04-15 17:26
I guess it depends what you mean by live instance. The service has to be able to respond to the calls being simulated by pact, but you'll likely be mocking out any dependencies. Here's an example with java, junit5 and spring (which may just confuse things further for you): ```@Provider("myProvider") @EnableAutoConfiguration @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { myProviderSearchControllerV1.class }, properties = { "server.port=1337" }) @PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}")) public class ProviderPactTest { @LocalServerPort private int port; @MockBean private myProviderWrapperService myProviderWrapperService; @MockBean private ValidationService validationService; @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port, "/")); }```

wesleythomaswilliams
2020-04-15 17:27
I've left out the tests etc, but that may give an idea

d.drinfeld
2020-04-15 17:30
I think I am beginning to understand, thank you Wes.

wesleythomaswilliams
2020-04-15 17:31
No worries, I still get confused by it.

yka
2020-04-15 18:59
has joined #general

matt.fellows
2020-04-15 23:15
So within your question you can still split apart tests: ? Unit ? Integrat_ion_ (not integrat_ed)_ ? End to End (or integrated)

matt.fellows
2020-04-15 23:15
For Unit, that is obvious, you should have some coverage there

matt.fellows
2020-04-15 23:18
Integration is complicated, because it?s a vague term. It?s going to depend a lot on the types of side effects you need to test. If it?s just data states, then that should be fairly easy to do. There are various layers you can test this at also. Two common approaches are: 1. Component level (e.g. persistance layer, routing layer, domain etc.) 2. Black-box (or ?hermetic server?) style, when you mock out 3rd party dependencies (typically other APIs/systems) and run tests from the outside, and assert behaviour 3. Integrated - where you test with real dependencies (this is the old school mentality and is hard to draw a line) I would highly recommend reading this article that goes into a lot more detail https://martinfowler.com/articles/microservice-testing/

matt.fellows
2020-04-15 23:20
So I think Wes has answered it. But I?ll come from a slightly different angle. You want to think about it a bit like a unit test. A good rule is that it should be able to run on your laptop/desktop without an internet connection (so this would generally preclude it being an externally deployed/hosted provider)

matt.fellows
2020-04-15 23:21
You can point verification at a staging/test environment, but you lose some of the value of contract testing, because you won?t get feedback during development that you?re about to break something. Ideally, you never push up a change that breaks a contract at all

travis.anderson
2020-04-15 23:46
Wow, awesome stuff @matt.fellows thank you for the run down! I'll take a look at this and see what kind of strategy I can put together. I appreciate the help!

2020-04-16 00:18
A new post has been created in *Feature Requests*

matt.fellows
2020-04-16 02:25
Next week, @uglyog @beth (http://Pactflow.io) (http://Pactflow.io) and I will be presenting a lunch and learn session at Pactflow?s parent company (DiUS) on ?Lessons learned whilst building a SaaS business?. If you?re interested in hearing a bit about our journey, we?d love for you to join us. We?ll cover a bit about our origins, the challenges of balancing OSS and commercial interests and talk about the mistakes we?ve made along the way. The event starts at 12:30 AEST on Tuesday 21st April: * 22:30 EDT (Monday evening) * 19:30 PDT (Monday evening) * 04:30 CEST (sorry :disappointed: !) Sign up here https://docs.google.com/forms/d/e/1FAIpQLSfBb7UBVoIfW4ioOyiWTG2ha0zhOpsV5Xs_ie3py-znWYdXUw/viewform

tjones
2020-04-16 02:26
Signed up! Is lunch provided?

tjones
2020-04-16 02:26
(I?m kidding, of course)

tjones
2020-04-16 02:26
Well, not about signing up. I definitely did that.

matt.fellows
2020-04-16 02:27
Virtual lunch. We?ll share food emjoi

pbarrientos
2020-04-16 02:27
:broken_heart:

matt.fellows
2020-04-16 02:31
:smile:

mkairys
2020-04-16 08:06
has joined #general

jan.falek
2020-04-16 13:00
has joined #general

d.drinfeld
2020-04-16 13:53
Yep, thats a good point, was thinking about that today? Thanks Matt!

pavel.azarau
2020-04-16 15:50
Hi. Are you going to share a recording?

komeershettyvinod
2020-04-16 17:43
@matt.fellows hey one quick question on a regular unit test, does junit tests also need a local server to run?

safiyya
2020-04-16 18:04
Thanks @l.dziedziul, very helpful.

giuseppe.salvatore
2020-04-16 18:46
has joined #general

giuseppe.salvatore
2020-04-16 18:49
Hi everyone

giuseppe.salvatore
2020-04-16 19:18
I have been interested in the contract testing and started to look at the pact approach. It's quite interesting... so far I managed to write consumer side testing to generate the pact contracts, publish the contracts to a broker and now I was trying to look at the verification options that are there.

giuseppe.salvatore
2020-04-16 19:19
I am using spring boot with maven project for the provider but I am struggling to find a clear example or some documentation.

giuseppe.salvatore
2020-04-16 19:19
can anybody please help me a bit?

matt.fellows
2020-04-16 21:11
Yes!

matt.fellows
2020-04-16 21:12
I think JVM automatically manages this for you but I'm not 100% sure sorry. It probably depends on other things, like which framework you use (e.g. spring boot)

theuiser
2020-04-16 21:48
Hi, all. I?m looking for good examples for a consumer to generate a Pact contract that is only concerned about types and not values. I?m using the pact-jvm-consumer-java8 jar. Having some challenges using Matchers. I?m looking for a JVM equivalent of the *Matchers*.*somethingLike* method in Pact JS

wesleythomaswilliams
2020-04-16 22:24
We use Java 8, Junit 5, Maven and Spring Boot. Does that fit your profile? If so I can help.

giuseppe.salvatore
2020-04-16 22:53
yeah thanks a lot, I guess I can make it fit

giuseppe.salvatore
2020-04-16 22:54
As far as I have seen around you can either user a maven plugin to perform your verification or you can write provider unit tests

uglyog
2020-04-16 22:54
The `LambdaDslJsonArray` class has an `eachLike` method

giuseppe.salvatore
2020-04-16 23:07
but yeah if you can point me to some example that would greatly appreciated

giuseppe.salvatore
2020-04-16 23:11
at the moment I am taking a look here https://github.com/DiUS/pact-jvm/tree/master/provider

abubics
2020-04-16 23:23
Maybe a little hard to find, but there's https://github.com/DiUS/pact-jvm#service-providers with a list of ways to verify, and links to examples

abubics
2020-04-16 23:26
There's also https://github.com/DiUS/pact-workshop-jvm, that has similar `gradle` instructions, if that helps :slightly_smiling_face: I typically use `gradle`, so I'm not sure what kind of state the other examples are in.

abubics
2020-04-16 23:30
(that's all for JVM, of course, but let us know if you're targeting other platforms)

bethskurrie
2020-04-16 23:42
Looking for a dockerized version of the Travis CLI for a Pact workshop and found `lirantal/travis-cli`. Thanks @liran.tal!

matt.fellows
2020-04-16 23:47
Nice!

bethskurrie
2020-04-16 23:56
Reckon you'd have a chance to update the gem? I keep getting "Outdated CLI version, run `gem install travis`"

wesleythomaswilliams
2020-04-17 07:55
@giuseppe.salvatore We went down the provider unit test path.


giuseppe.salvatore
2020-04-17 08:31
Thanks @wesleythomaswilliams @abubics

giuseppe.salvatore
2020-04-17 08:33
I was looking at the two options: with Maven plugin and within provider with Junit4 (I guess the can-i-deploy is a third option to verify the pact on provider side right?)

wesleythomaswilliams
2020-04-17 08:44
can-i-deploy is more for when you integrate your tests into your pipeline so that changes that break a contract don't get into production.

giuseppe.salvatore
2020-04-17 08:45
:+1:

joao.salles
2020-04-17 09:35
has joined #general

matt.fellows
2020-04-17 10:40
Wes you're a machine - first answer at 8:35am local time, and just now at 6:44pm our local time. :pray:

giuseppe.salvatore
2020-04-17 10:52
I keep getting this error: ```[ERROR] Failures: [ERROR] ContractTest.account-service-api - A request for an existing account that has at least one product returns the data 0 - Expected a response type of 'application/json' but the actual type was 'text/plain' 1 - assert expectedStatus == actualStatus | | | 200 | 400 false 2 - Expected a header 'Content-Type' but was missing``` Which makes me think that the real service is not running... but not sure why, it looks like from the test code perspective a @TestTarget is the only thing that goes up ```@RunWith(SpringRestPactRunner.class) @Provider("product-service-api") @PactBroker(host = "http://my-pact.co.uk", port = "443", scheme = "https", consumers = "account-service-api") @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class ContractTest { @TestTarget public final Target target = new SpringBootHttpTarget(); @State("default") public void user1Exists() { // nothing to do, real service is used } }```

wesleythomaswilliams
2020-04-17 11:25
It might not be relevant, but we don't use ```@RunWith(SpringRestPactRunner.class)``` Our annotations ```@Provider("id") @EnableAutoConfiguration @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = { idSearchControllerV1.class }, properties = { "server.port=1337" }) @PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}"))``` And we use ```@LocalServerPort private int port; @BeforeEach void setupTestTarget(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", port, "/")); }``` Is that helpful?

giuseppe.salvatore
2020-04-17 11:27
I think the last bit might be ok for me as I have SpringBootTest.WebEnvironment.RANDOM_PORT but I will give it a go with the @SpringBootTest annotation as it seems like you provided a rich configuration that I might be missing

giuseppe.salvatore
2020-04-17 11:28
> Is that helpful? I did want to say "Every little helps" ...

wesleythomaswilliams
2020-04-17 11:28
My Spring knowledge comes from our devs, so I'm not massively clued up on it. They just tell me it's magic. :wink:

giuseppe.salvatore
2020-04-17 11:30
I am with you 100%. I am finding that my java knowledge since 6 years ago is quite obsolete and instead of knowing the java language now people want to know how you configure your application with tons of bloody annotations

wesleythomaswilliams
2020-04-17 11:30
You're pretty much exactly in the same boat as me :smile:

giuseppe.salvatore
2020-04-17 11:33
I might have found the problem!

giuseppe.salvatore
2020-04-17 11:33
Verifying now :computer:

giuseppe.salvatore
2020-04-17 11:47
The power of black magic!!! So I am going to share this with you because I think it's a good one. Basically the short version is: there were 2 problems with the consumer side pact that didn't match what the provider was exposing 1. the provider wanted a correlationId into the header and 2. it was returning an arrays of products not only one

giuseppe.salvatore
2020-04-17 11:48
but as the consumer in his tests wasn't giving the header param the provider was failing the check with a 400 (bad request)

giuseppe.salvatore
2020-04-17 11:48
(which in fairness is another test I could add)

giuseppe.salvatore
2020-04-17 11:49
I find all of this very nice and although I am new to all of this (I was testing GPU driver stuff in C++ only 8 months ago) I think the progress I am making thanks to community and people like you is amazing

giuseppe.salvatore
2020-04-17 11:50
So thanks everyone for the support, really, really appreciated :pray:

matt.fellows
2020-04-17 13:49
That sounds like good progress to me! You've worked out how the tool works, found a potential bug and had a chat with another team :clap:

anguyen0815
2020-04-17 15:37
Hi guys, I posted this in pact-ruby channel 2 days ago. just trying again here. any suggestion/recommendation is appreciated! ```Hi guys, I have been trying to write consumer tests for a file upload api and it has to do with image/binary files. I couldn't get it to work so far and it looks like the mock service couldn't handle the binary file. I saw that there is this ticket https://github.com/pact-foundation/pact-mock_service/issues/32. Is that issue still applicable? If so, do you guys have any recommendations as far as testing image upload goes?```

darshan
2020-04-17 15:51
has joined #general

paolaagudelo10
2020-04-17 16:27
Hi everyone, someone can help me with this problem? The broker is already up because the test are verified, but when try to publish the verification result to the broker, the result the following message appears pact-linux-x86_64/lib/vendor/ruby/2.2.0/gems/pact-1.49.2/lib/pact/provider/verification_results/publish.rb:103:in `publish_verification_results': Error returned from verification results publication 500 {"error"=>{"message"=>"An error has occurred. The details have been logged with the reference agMzWQbfmU", "reference"=>"agMzWQbfmU"}} (Pact::Provider::VerificationResults::PublicationError) i am using "PactNet.Linux.x64" Version="2.5.3" in a jenkins pipeline

giuseppe.salvatore
2020-04-17 18:27
.

giuseppe.salvatore
2020-04-17 18:27
How do you publish the result?

paolaagudelo10
2020-04-17 18:50
@giuseppe.salvatore the PactNet library contains the publish to broker property

giuseppe.salvatore
2020-04-17 20:09
something like this?

giuseppe.salvatore
2020-04-17 20:10
```var pactPublisher = new PactPublisher("http://test.pact.dius.com.au", new PactUriOptions("username", "password")); pactPublisher.PublishToBroker( "..\\..\\..\\Samples\\EventApi\\Consumer.Tests\\pacts\\event_api_consumer-event_api.json", "1.0.2", new [] { "master" });```

theuiser
2020-04-17 20:18
Thanks, @uglyog. I?ll take a look.

paolaagudelo10
2020-04-17 20:46
@giuseppe.salvatore

paolaagudelo10
2020-04-17 20:49
and that configuration is used in the test like this :

paolaagudelo10
2020-04-17 20:49
IPactVerifier pactVerifier = new PactVerifier(config); pactVerifier .ProviderState($"{uri}/provider-states") .ServiceProvider("provider", ServiceUri) .HonoursPactWith("consumer") .PactUri(URL) .Verify();

marzieh312
2020-04-18 08:17
has joined #general

gunjan.arora
2020-04-18 23:14
has joined #general

jayeshdalal7
2020-04-19 12:25
has joined #general


matt.fellows
2020-04-19 21:19
I think there is an issue on the JS repo also that might have some tips too

bethskurrie
2020-04-19 22:33
@paolaagudelo10 are the details you've pasted the actual details you're getting the error for?

bethskurrie
2020-04-19 22:33
I can't see that error reference in the logs for Pactflow anywhere.

bethskurrie
2020-04-19 22:33
Also, the application doesn't run on http - it's https.

eduardopceleste
2020-04-20 04:15
has joined #general

dsmith
2020-04-20 11:43
has joined #general

dsmith
2020-04-20 11:47
Good Day All, I have just started out using Pact. Working on a Kotlin project . I've created a pact file by creating the consumer test. I am now at the provider end of the solution. I require a custom header to be send when making the request in the Provider Test. Has anyone got this right in Kotlin? I looked at PactVerificationContext and found it only has host, port, path .. no headers.

matt.fellows
2020-04-20 11:48
Are you using gradle?

dsmith
2020-04-20 11:48
```@BeforeEach fun before(context: PactVerificationContext) { context.target = HttpsTestTarget( host = "http://dummy-host.com", port = 443, path = "/dummy-path") }```

dsmith
2020-04-20 11:48
i am yes


chris.spencer
2020-04-20 12:30
has joined #general

dsmith
2020-04-20 13:00
Thank you! I'll give it a shot and let you know

dsmith
2020-04-20 13:17
Schweet! Works like a charm, thanks again :slightly_smiling_face:

paolaagudelo10
2020-04-20 14:02
@bethskurrie yes bet that is the log that I am getting in the Jenkins output

matt.fellows
2020-04-20 14:08
:raised_hands:

bethskurrie
2020-04-20 20:02
First thing change the http to https @paolaagudelo10

bethskurrie
2020-04-20 20:04
Can you send another of the error references and I'll see if I can find it in the logs.

paolaagudelo10
2020-04-20 22:10
@bethskurrie Do you refer that my provider should be with https ? Why? I was looking in the documentation and all the examples have the providerURL with HTTP, however, if you refer to the broker URL I already have them with https .. btw thanks for your helping I really appreciate it

bethskurrie
2020-04-20 22:14
Http or https just depends on how the broker is deployed. You can't use http if it's only running https (which most servers should these days). The examples just assume you know how your broker is running.

bethskurrie
2020-04-20 22:16
@paolaagudelo10 could you try publishing again so I can have a look at the logs?

paolaagudelo10
2020-04-20 22:36
@bethskurrie I have deployed again and now I am not having the problem without any changes :confused:

bethskurrie
2020-04-20 22:55
Well, that's annoying and good at the same time!

duncan.kennedy
2020-04-20 23:09
has joined #general

bethskurrie
2020-04-21 00:13
Hey pact peeps. Ron, Matt and I did Y Combinator's start up school last year. One of the concepts they talked about was "the magic moment", which is the moment that a new user decides "Ah!! this is the thing I've been looking for all my life!! I must have it!!!" I'd be really interested to know from you all, what had you just done with Pact when you had that "aha!" moment? Generating a contract? Running the verifications? Using can-i-deploy? Seeing the verification results in Pactflow? Or, was it more just a moment of understanding rather than an action? Please do share!

ina.lopez
2020-04-21 00:36
I am still waiting for the "aha" moment :slightly_smiling_face: Getting there....

abubics
2020-04-21 00:37
As a somewhat early adopter, and after a couple of years of tedious and flaky integrated test suites (read: torture) just the fundamental concept was enough to convince me :sweat_smile: Using it, and getting all the value quickly just sealed the deal further :ok_hand:

abubics
2020-04-21 00:38
(that's a couple of years of consulting . . . before that I was making mobile games, where there was no testing whatsoever)

bethskurrie
2020-04-21 00:39
If it doesn't happen, let us know what didn't work for you. There are legitimate reasons why it doesn't help in 100% of cases. I've got a half written blog post about it actually.

bethskurrie
2020-04-21 00:40
But I hope it does!

bethskurrie
2020-04-21 00:40
"Honey, I'm just 'testing' my game... yeah... I know, working late sucks..."

ina.lopez
2020-04-21 00:50
When I create a new feature branch and make some changes, I then run contract tests and publish pact to Pact Broker and I continue with my Marry way. (CI build) Meanwhile Pact broker calls Provider and verifies this Pact. How does this later tell me that this feature branch in consumer code is/isn't ready to be merged into master? At the time of master build?


ina.lopez
2020-04-21 00:53
I could be just confusing myself

ryan.dens
2020-04-21 01:50
Magic moment was seeing it catch the same kind of bugs our integration tests did, but early on. It did a lot to build trust :raised_hands:

bethskurrie
2020-04-21 02:39
Using webhooks to send notifications to something like Slack, or to post back a github commit status is the best way @ina.lopez. There's a post on it here: http://blog.pact.io/2018/07/16/publishing-pact-verification-statuses-to-github/

bethskurrie
2020-04-21 02:41
If you're using can-i-deploy, you get the feedback as part of the consumer build too. Here's an example: https://travis-ci.com/github/bethesque/example-consumer/builds/160698464

matt.fellows
2020-04-21 02:42
?Lessons learned building a Saas business? is on now - join here: https://meet.google.com/xns-yoku-oum You can interact with us with live Q&A here: ? http://www.slido.com ? event code: #82934

matt.fellows
2020-04-21 02:42
I can see a bunch of you already - thanks for joining!

tjones
2020-04-21 03:31
Good talk! Thanks! :clap:

matt.fellows
2020-04-21 03:33
Thanks for coming Tim!

ina.lopez
2020-04-21 15:14
Great. This is exactly what I needed. It says I will need at least https://github.com/pact-foundation/pact_broker/releases/tag/v2.47.1 version of Broker. Is there a way to tell the version of Pact Broker through the browser? I don't own that service.

rbenbolton
2020-04-21 16:55
The ?magic moment? for me was when I realized this was the thing we needed to keep providers from breaking dependent services within out product suite as we split out monolithic applications into micro-services. When we added a second application that depended on the first, things were constantly breaking and coordination between the two was terrible. But, plans were to add more apps/services. Once pact was in place, these breaking changes stopped almost completely. Also realizing the power it gave those consumer applications to control the types and parameters around the data they received and place expectations around it.

jon.stevens
2020-04-21 22:07
has joined #general

matt.fellows
2020-04-22 00:56
For those of you who missed the session yesterday, here is the recording: https://www.youtube.com/watch?v=w50VOIRHFcQ&feature=youtu.be Thanks again for those who attended and asked us difficult questions :) If you have any feedback questions, you know where to find us!

s.garcha
2020-04-22 09:59
has joined #general

sbartsa
2020-04-22 11:34
has joined #general

sbartsa
2020-04-22 11:38
For us the aha moment was when we realised we could pass the same test files from the consumer to the provider. We had tons of tests passing which were quite useless since they were testing old implementation, and gave us no actual value.

sbartsa
2020-04-22 11:42
Hello everyone. I am digging into creating a full fledged CI for our contract tests. The problem is to fully automate this procedure we have a problem when we want to publish a new contract from a feature branch and test against the provider on master since, profoundly, it is going to fail. I researched and came across the `pending_contracts` which seems to solve this issue impeccably. Does anyone have any more information on how we can use this functionality? P.S. We are using `pact-jvm` , `maven` and `junit` in our tests. Reached here following this article (http://blog.pact.io/2020/02/24/how-we-have-fixed-the-biggest-problem-with-the-pact-workflow/) Thank you in advance!

matt.fellows
2020-04-22 20:04
Yes, you can head to the HAL browser and look at the response headers. There is a x- header with the version in it

ina.lopez
2020-04-22 20:51
found it :slightly_smiling_face: thank you

corey
2020-04-22 22:40
has joined #general

artur.ashyrov
2020-04-23 05:07
Hello everyone. I have a question on proper way of using Pact for contracts testing. How to properly test contracts when my service consumer A consumes API of service provider B but interacting with B through api gateway? Gateway basically authorizing the request and adds some headers to proxied request. Thanks in advance! PS: to me it seems that authorization should not be a part of contract here but the main problem for me that B will not verify contracts without request headers that are added on gateway(response is just passed as is). Of course i could consider gateway as consumer and producer at the same time - but it sounds like an overkill in my case

bethskurrie
2020-04-23 05:48
If the headers are simple and consistent, I'd add them in a filter when doing the verification step.

bethskurrie
2020-04-23 05:48
It's a tricky one, and comes up a bit

bethskurrie
2020-04-23 05:48
What are the headers that the called code expects?

bethskurrie
2020-04-23 05:49
Can you decouple it from the business logic as middleware?


artur.ashyrov
2020-04-23 05:54
thanks for quick response. Yes i?ve seen this article request flow is something like this: consumer headers: Authorization abcd gateway exchanges this for: X-Customer-Id X-Cusomer-Currency and proxies the request(or rejects it if auth token is expired etc). Which means that X-Customer-* headers are part of provider?s verification(but not the contract from consumer?s side)

artur.ashyrov
2020-04-23 05:56
at the moment - the only way around i see is to implement both consumer/provider states on my front api gateway. but as i mentioned - looks smelly to me(because of tests/contracts duplication)

bethskurrie
2020-04-23 05:56
Yeah, I'd just add them at verification time

bethskurrie
2020-04-23 05:57
It's an internal concern of the deployed provider, if you see the gateway and the app as one system from the outside.

bethskurrie
2020-04-23 05:58
If it's unlikely to change often, or have complex logic, I think it would be OK.

artur.ashyrov
2020-04-23 05:58
ok so i was thinking in right direction you mean? i need to add them(X-Customer-* headers) on verification phase of service B correct?

bethskurrie
2020-04-23 05:58
Yes

artur.ashyrov
2020-04-23 05:59
ok will dig in this direction then. Thank you very much Beth and have a good day :slightly_smiling_face:

bethskurrie
2020-04-23 05:59
You too. Happy quarantine.

bernardoguerr
2020-04-23 09:44
Hey @artur.ashyrov I wrote this article where I solved this problem before. My use case was also a lambda behind API Gateway. https://medium.com/dazn-tech/pact-contract-testing-dealing-with-authentication-on-the-provider-51fd46fdaa78 It might help you

artur.ashyrov
2020-04-23 10:45
will check it out

anja.gruss
2020-04-23 10:46
has joined #general

asher.feil
2020-04-23 19:20
has joined #general

dham
2020-04-23 21:28
has joined #general

dham
2020-04-23 21:30
hello friends!

dham
2020-04-23 21:34
we are having a mysterious issue. we are running pact broker on kubernetes, and it looks like it crashed earlier today (due to an unrelated cluster issue) but now pact-broker is crash looping with this message: ```Connecting to database with config: {:adapter=>"postgres", :user=>"clearcover", :password=>"*****", :host=>"pact-broker.[REDACTED].us-eas ? ? pact-broker ! Unable to load application: Sequel::DatabaseConnectionError: PG::ConnectionBad: expected authentication request from server, but received H ```

dham
2020-04-23 21:35
I am able to connect to the DB via DataGrip

dham
2020-04-23 21:35
also, we have not changed our deployment of pact broker in months, and it was working fine earlier this week

matt.fellows
2020-04-23 23:14
I?m assuming you?ve tried the obvious - restart the app?

bethskurrie
2020-04-23 23:19
"Received H"? Is there part of the message I'm not seeing?

evanrosal
2020-04-24 04:30
has joined #general

mbieganski.infomatt
2020-04-24 12:39
has joined #general

shurik
2020-04-24 14:15
has joined #general

dham
2020-04-24 15:07
we did get it to work eventually. We are running Istio, and when we disabled the Istio sidecar it worked again. We don't know what the issue was exactly but I don't think it was anything to do with Pact broker. Thanks!

fafa029
2020-04-25 05:00
has joined #general

dinh.che
2020-04-27 04:44
has joined #general

thibaud.stevelinck
2020-04-27 09:17
has joined #general

thibaud.stevelinck
2020-04-27 09:34
Hello there! I would like to know if you have a rough idea of when pact-ruby would fully support V3matcher. Kind regards

bethskurrie
2020-04-27 09:34
Sorry, I don't know.

bethskurrie
2020-04-27 09:35
I may have some time in the next few months, depending on pandemic!

thibaud.stevelinck
2020-04-27 09:35
ok thanks

bethskurrie
2020-04-27 09:35
Is there a particular matcher you're after @thibaud.stevelinck?

thibaud.stevelinck
2020-04-27 09:37
Not really at the moment, only investigating as we've planned to use pact.

praneethkumar
2020-04-27 10:30
has joined #general


lukasz.kaniowski
2020-04-28 13:44
has joined #general

lukasz.kaniowski
2020-04-28 14:03
Hello guys and gals, hope everyone is having a nice day! We?ve recently started integrating pact into our workflow and as such I just wanted to say hello to the community :wave:

eleftherios
2020-04-28 15:09
has joined #general

matt.fellows
2020-04-28 21:16
Awesome, thanks for joining us! Let us know how we can help

sen.rudrappa
2020-04-29 08:15
has joined #general

jake.chandrasakera
2020-04-29 16:08
has joined #general

maciej.olko
2020-04-29 17:49
has joined #general

stephen.rhodes
2020-04-29 18:19
has joined #general

stephen.rhodes
2020-04-29 18:19
where would be the best place for me to ask some graphql related questions ?

leonardo.k.magalhaes
2020-04-29 21:22
has joined #general

matt.fellows
2020-04-29 21:36
what language are you using? Probably in that channel, albeit perhaps we should create a GraphQL specific channel

preethighalke
2020-04-30 05:49
has joined #general

stephen.rhodes
2020-04-30 09:20
JavaScript,

stephen.rhodes
2020-04-30 09:25
i was wondering about how flexible the withQuery method is... for example: If i define, ```query { id name }``` in theory.. this creates a contract that will cover a query that queries id, name... so if i do a query somewhere that will just be .. ```query { id }``` ... i am ... in theory, just querying something that has already been covered in a contract. .. I know this very different to how REST works, but as GraphQL is different, should contracts for GraphQL be changed to cover partials ?

jsanchez
2020-04-30 11:45
has joined #general

sonya.chauhan
2020-04-30 15:26
has joined #general

sonya.chauhan
2020-04-30 15:46
Hello all, I have started looking into using Contract testing in our project. We have a frontEnd (react app) and Bff (Graphql .net core) API. FrontEnd which is the consumer, I can use the pact library to generate the contract file.. which then gets publish via pact broker .. so the Api can pick the file and verify it. My biggest problem is that on BFF (API), we have couple of dependencies on other systems. Like Authentication being one, for which we use some other system.. and then to fetch data also we are dependent on some other system. So what's the best practice/way to run the verification of pact file on provider's end ? will it run like a integration test at Providers end ?

malex.y
2020-04-30 20:19
has joined #general

matt.fellows
2020-04-30 22:06
No you should probably stub the other layers. The docs have a section on this somewhere

matt.fellows
2020-04-30 22:07
FAQs I think

bethskurrie
2020-04-30 23:53
These are slides on stubbing in the provider from a workshop I did recently. I need to add them to the docs.


kaypee90
2020-05-01 00:16
has joined #general

preethighalke
2020-05-01 05:46
Hi All, Can you point me to an example Provider Test which works with JUnit4, I'm unable to get my sample test working as it ends up with InitializationError. I'm using pact-jvm-provider version 4.0.10. Many Thanks in advance. Regards


uglyog
2020-05-01 05:52
Just note that that test is unsing ClientDriverRule to create a mock provider. You should use your actual provider.

sonya.chauhan
2020-05-01 09:31
Thanks Beth.. I will read though the doc.

bheemreddy181
2020-05-01 11:57
The slides are really helpful thanks Beth

preethighalke
2020-05-01 11:58
Thank you @uglyog the example helped. I'm able to run my providertest now. Many Thanks.

julie_woodford
2020-05-01 12:05
has joined #general

zibyte
2020-05-01 12:31
has joined #general

dan.h.lee329
2020-05-02 01:53
has joined #general

tyler.morris
2020-05-03 04:00
has joined #general

tyler.morris
2020-05-03 04:02
qq, reading over the docs on https://github.com/pact-foundation/pact-js#provider-api-testing it looks like you should use the providerStatesSetupUrl to have the provider state set on the provider via a put method, but the e2e examples show the use of a stateHandlers property on the verifier options. The typedef for pact shows providerStatesSetupUrl under "DeprecatedVerifierOptions". Is the going forward way for provider state via this stateHandler method and not via the api route?

matt.fellows
2020-05-03 04:04
yes, this is correct

matt.fellows
2020-05-03 04:04
I?ll update the docs now to show that field as deprecated

tyler.morris
2020-05-03 04:06
Oh awesome thanks! Any reason in particular the move away from the url to the methods on the test running side? I know there's more recent stuff related to pact testing support for events and other non api based things

matt.fellows
2020-05-03 04:09
There are a bunch of reasons: 1. Having to standup a separate HTTP endpoint is pretty ugly 2. A lot of people struggle with the concept 3. People who get it, complain that they don?t want to ?change? their provider for the purposes of testing 4. Function mapping is much simpler, hides away this complexity and feels a lot more natural/ergonimic

matt.fellows
2020-05-03 04:09
If you disagree though, i would love to chat/understand further!

tyler.morris
2020-05-03 04:31
Nope, that makes perfect sense. Im in node atm so adding a route conditioned on a process env is easy, but does add code the setup. Thanks again for the info! :slightly_smiling_face:

nqdung.itus
2020-05-03 09:56
has joined #general

srinivasan.sekar1990
2020-05-03 10:41
has joined #general

krishnam.misc
2020-05-03 12:44
has joined #general

krishnam.misc
2020-05-04 05:00
I see few errors like below when _jest_ tests are run. ERROR: The process "23412" not found. [2020-05-04T04:55:16.578Z] ERROR: pact-node@9.0.7/12924 on LTIN114925: Pact Binary Error: C:/ComCast/TestCafe/ContractTesting/pact-js-master/pact-js-master/examples/jest/node_modules/@pact-foundation/pact-node/standalone/win32-1.70.2/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.1.1/lib/pact/mock_service/request_handlers/interaction_post.rb:1:in `require': cannot load such file -- pact/mock_service/request_handlers/base_administration_request_handler (LoadError)

tjones
2020-05-04 05:09
@krishnam.misc Can you try updating to the latest pact-js and see if this still happens?

matt.fellows
2020-05-04 05:22
the issue looks like the well-document windows file path issue

matt.fellows
2020-05-04 05:22
Please try moving your path closer to the root of `c:`

tjones
2020-05-04 05:22
Ah yes, so it is

matt.fellows
2020-05-04 05:23
classic, how the fuck is this still happening, windows issue

tjones
2020-05-04 05:40
I think this is a problem because for some reason I set the default log to `error` in jest-pact

tjones
2020-05-04 05:40
pact-node tests the windows path length and will warn if it is too long

tjones
2020-05-04 05:40
I?ll update jest-pact

krishnam.misc
2020-05-04 05:57
Thanks for all super quick responses!

krishnam.misc
2020-05-04 07:38
So, that apparently is due to the workspace name (lengthy). I see below warning now. 2020-05-04T07:36:53.989Z] INFO: pact@9.2.1/22480 on LTIN114925: Setting up Pact with Consumer "MyConsumer" and Provider "MyProvider" using mock service on Port: "8991" [2020-05-04T07:36:54.060Z] ERROR: pact-node@9.0.7/22480 on LTIN114925: Pact Binary Error: WARN: Ignoring unsupported matching rules {"min"=>1} for path $['query']['catId'][] [2020-05-04T07:36:54.060Z] ERROR: pact-node@9.0.7/22480 on LTIN114925: Pact Binary Error: WARN: Ignoring unsupported matching rules {"match"=>"type"} for path $['query']['catId'][][*]* [2020-05-04T07:36:54.063Z] INFO: pact@9.2.1/22480 on LTIN114925: Pact File Written [2020-05-04T07:36:54.064Z] INFO: pact-node@9.0.7/22480 on LTIN114925: Removing Pact with PID: 7004 PASS __tests__/index.spec.js (5.023s) Test Suites: 3 passed, 3 total Tests: 4 passed, 4 total Snapshots: 0 total Time: 21.312s Ran all test suites matching /__tests__\\/i. [2020-05-04T07:36:55.327Z] INFO: pact-node@9.0.7/22480 on LTIN114925: Deleting Pact Server with options: {"consumer":"MyConsumer","cors":false,"dir":"C:\\ContractTesting\\pact-js-master\\pact-js-master\\examples\\jest\\pacts","host":"127.0.0.1","log":"C:\\ContractTesting\\pact-js-master\\pact-js-master\\examples\\jest\\logs\\mockserver-integration.log","pactFileWriteMode":"update","port":8991,"provider":"MyProvider","spec":2,"ssl":false} PS C:\ContractTesting\pact-js-master\pact-js-master\examples\jest>

abubics
2020-05-04 07:39
Probably good to move this over to #pact-js now :slightly_smiling_face:

krishnam.misc
2020-05-04 07:40
Sure

gromov.yuriy
2020-05-04 08:57
has joined #general

gromov.yuriy
2020-05-04 09:11
Hi. I'm looking for a way to migrate pact-broker data from one instance to another. Is there some standard way to do so or I just have to migrate DB? Is there some ready-baked script for that? Many thanks.

bethskurrie
2020-05-04 09:11
Import and export the db is the easiest way.

bethskurrie
2020-05-04 09:11
Both postgres?

gromov.yuriy
2020-05-04 09:11
Yep same versions

matt.fellows
2020-05-04 09:13
Why are you migrating? Upgrade or something?

bethskurrie
2020-05-04 09:13
pg_dump and pg_restore is the way I do it.

gromov.yuriy
2020-05-04 09:13
I did a dump, restored to another database, run pact-broker on a new database, but it crashed with an error about inconsitency in data

gromov.yuriy
2020-05-04 09:14
We had it in test and developers already have some data in it, now we are migrating it into production and they say that they need that data.

bethskurrie
2020-05-04 09:14
I do it all the time. What's the error?

gromov.yuriy
2020-05-04 09:15
I need to do that one more time, I deleted all the error logs.

gromov.yuriy
2020-05-04 09:17
I guess it is because guys that made that test instanse run database in the default postgres database (postgres), but I need to run it in its own dedicated db (pact-broker), may be an issue in restoring to db with different name

bethskurrie
2020-05-04 09:33
Well, let me know when you have the error. Can't help you much until then!

gromov.yuriy
2020-05-04 10:20
I did it, it works. The issue was that I didn't know much about postgres (simple issue with permissions) :) Sorry for disturbing.

bethskurrie
2020-05-04 10:21
Glad you've got it sorted.

gromov.yuriy
2020-05-04 10:22
Thank you for willing to help.

mykeandreas_pact
2020-05-04 10:23
has joined #general

matt.fellows
2020-05-04 11:11
Ah, makes sense

matt.fellows
2020-05-04 11:11
Always good to know the use cases. Helps us with ensuring pactflow and our OSS tooling stays relevant

mykeandreas_pact
2020-05-04 11:42
I have a questions regarding pact verification on a Provider which is in python. right now we are using pactman-verifier https://github.com/reecetech/pactman#verifying-pacts-against-a-service for pacts verification. This has a disadvantage that is run in a service, so when ever you want to run the tests on your Provider, you have configure the other services, for each state, from the scope of the service in which you are running the tests. The database of the service in which you run the verification with `pactman-verifier` is cleared for each pact. My issue is that i have to manually do some housekeeping to clean or configure other services based on the provider states from within the scope of the service in which I am running the pact verification. Is there a better way to verify the pacts in a microservices architecture ? Can you configure multiple services with the same pact provider state ?

krishnam.misc
2020-05-04 11:49
How do we debug pacts?

matt.fellows
2020-05-04 11:50
Maybe start a new thread elsewhere (e.g. #pact-js) on this. Do you have a specific issue?

krishnam.misc
2020-05-04 11:52
Well, I have an endpoint to test how pact actually works and want to debug the whole flow once so I am comf with the workspace

sidhartha.k.subudhi
2020-05-04 12:05
has joined #general

chandanakurumeti27
2020-05-04 12:33
Hi , I wanted to use `pact-jvm-consumer` dependency to support (testNG @Test annotation )and not `pact-jvm-consumer-junit.2.11` as my consumer code base is using testNG framework. Is there any possibility to use `pact -jvm-comsumer` dependency which can support TestNG. Cannot really use `pact-jvm-consumer-junit.2.11` for my consumer code base, please help me to find the solution here in this case. looking forward to some suggestions. Thanks, Chandana

chandanakurumeti27
2020-05-04 13:13
Can someone please help me understand the difference between `pact-jvm-consumer` and `pact-jvm-consumer-junit` dependencies ?

matt.fellows
2020-05-04 13:31
Please ask in #pact-jvm-help

matt.fellows
2020-05-04 13:32
Out of curiosity, did you receive a welcome message asking to request questions in the appropriate language channel? Just want to check that's working

chandanakurumeti27
2020-05-04 13:36
Yes, i did receive. But thought that general channel is something where i can request for suggestions for general questions. Sorry, will ask my doubts in appropriate channels from now.

rjaladurgam
2020-05-04 18:21
has joined #general

rjaladurgam
2020-05-04 18:22
Could a test file have multiple @Pact and @Test annotations? For example, to test GET, POST and DELETE methods of an API

rjaladurgam
2020-05-04 18:34
How to use the pending pacts feature?

wesleythomaswilliams
2020-05-04 20:27
Yes

john.richards
2020-05-04 21:10
has joined #general

nick.smith3128
2020-05-04 21:46
has joined #general

matt.fellows
2020-05-04 21:48
All good, just checking!

nick.smith3128
2020-05-04 21:49
hi. has anyone seen a really odd `pactfoundation/pact-stub-server` behaviour? My Spring Boot app calls to a service hosted in `pactfoundation/pact-stub-server`, calls which fail every other time (with no response from the server). i.e ```for (int i=0 ; i < 20; i++) { try { accountApiService.getAccount(accountId); http://log.info("XXXXXXX - {} passed", i); } catch (Exception e) { http://log.info("XXXXXXX - {} failed", i); } }``` produces: ```XXXXXXX - 0 failed XXXXXXX - 1 passed XXXXXXX - 2 failed XXXXXXX - 4 passed etc```

matt.fellows
2020-05-04 21:52
No that's... Strange. If you can provide a repro outsiders can use we'd appreciate an issue

john.richards
2020-05-04 21:56
Hello! I am looking to use PACT with this stack: Ruby, SNS, and SQS. I see a lot of simple examples for instance in the ruby workshop for Pact. That use the mock service and a port. How could I do this to emulate messages queues like SQS? Pact.service_consumer "Zoo App" do has_pact_with "Animal Service" do mock_service :animal_service do port 1234 end end end

jlklein
2020-05-04 22:08
has joined #general

jlklein
2020-05-04 22:09
QQ, I have been reading a lot about PACT and one argument is this does not solve UI testing. What is the recommended approach lets say for an angular project?

nick.smith3128
2020-05-04 22:09
ill try to sort out out

bethskurrie
2020-05-04 22:16
Angular can be tricky I believe. Someone wrote a blog on this recently @jlklein https://medium.com/@dany.marques/how-to-set-up-pact-tests-with-angular-jest-ae157f272428

bethskurrie
2020-05-04 22:16
The recommended approach for UI testing is to use the pact generated in the unit tests as a HTTP stub using one of the pact stub server implementations.


2020-05-04 22:47
A new post has been created in *Feature Requests*

bethskurrie
2020-05-04 22:49
I've just thrown together some docs here: https://docs.pact.io/consumer/using_pact_to_support_ui_testing

nick.smith3128
2020-05-04 22:54
whilst making a test rig for this i discovered that it was the dependency `io.github.openfeign:feign-httpclient`

nick.smith3128
2020-05-04 22:55
that was causing this issue

nick.smith3128
2020-05-04 22:55
thanks for your help anyway

matt.fellows
2020-05-04 22:57
:+1:


bethskurrie
2020-05-04 23:03
It looks like Ruby is the consumer, and as you can see, the consumer side DSL is not quite finished.

bethskurrie
2020-05-04 23:03
If you're keen to use it, I can make it happen however.

bethskurrie
2020-05-04 23:05
@mykeandreas_pact yes - you generally stub any downstream services during the verification phase.


mykeandreas_pact
2020-05-04 23:08
But this are services from my provider, which I would like to test along with the pacts, not external services.

bethskurrie
2020-05-04 23:15
I think we have a different understanding of what "service" means in this context.

bethskurrie
2020-05-04 23:15
It is expected that at the start of each provider state set up that your clear all state associated with the previous interaction.

bethskurrie
2020-05-04 23:16
It's much safer to clean up at the start of an interaction than the finish, because you can never be certain of what happened in the test before this point in time.

bethskurrie
2020-05-04 23:17
I always do a "db reset" at the start of each of my provider states.

bethskurrie
2020-05-04 23:18
I just wrote a new page on using Pact to support UI testing here: https://docs.pact.io/consumer/using_pact_to_support_ui_testing

bethskurrie
2020-05-04 23:18
It's a bit light on detail because I don't have time to do too much on it right now, but I've raised a feature request to provide some code examples.

john.richards
2020-05-04 23:21
@bethskurrie@bethskurrie@bethskurrie We would love to use it. I could also help in development if it is open source.

bethskurrie
2020-05-04 23:22
The code is mostly done - I got stuck on the naming :laughing:

john.richards
2020-05-04 23:23
Haha fair enough.

bethskurrie
2020-05-04 23:23
I'll see if I can find where I was up to

bethskurrie
2020-05-04 23:24
Ok, it's because I ended up with a `builder` object in both the consumer and provider contexts that did different things.


bethskurrie
2020-05-04 23:25
On the consumer side, the `builder` (see https://github.com/pact-foundation/pact-message-ruby/blob/master/spec/features/create_message_pact_spec.rb#L11) is the thing that you use to build the interactions.

bethskurrie
2020-05-04 23:26
On the provider side (which is already released) the builder is the thing that creates concrete examples of the messages to be returned to the pact verifier for matching against the pact.

john.richards
2020-05-04 23:26
Awesome!

john.richards
2020-05-04 23:26
Looks good

bethskurrie
2020-05-04 23:27
So, my problem was - I didn't want two things called `builder` but I couldn't think of what to call the consumer `builder`.

bethskurrie
2020-05-04 23:27
So I stopped because nobody was actually asking for the code yet!

bethskurrie
2020-05-04 23:28
Maybe you have some idea.


john.richards
2020-05-04 23:31
Oh yikes. I always pick out-there names. I like ?architect?, ?assembler?, or ?fabricator? haha

bethskurrie
2020-05-04 23:32
ha!

bethskurrie
2020-05-04 23:32
I'm trying to keep it in line with the other implementations.

bethskurrie
2020-05-04 23:33
I don't use message queues very much.

bethskurrie
2020-05-04 23:33
Can you read the specs here and tell me if the DSL makes sense to you? https://github.com/pact-foundation/pact-message-ruby/blob/master/spec/features/create_message_pact_spec.rb

john.richards
2020-05-04 23:36
Yes that is the most basic usage for a message. The DSL looks correct

bethskurrie
2020-05-04 23:39
I'll see if I can get this finished in the next few days. I can't remember where I was up to well enough to describe what would need doing for you to do it.

bethskurrie
2020-05-04 23:40
I'll let you know if there's something you can help out with though :slightly_smiling_face:

john.richards
2020-05-04 23:40
Ok let me know. We are planning to use it for a very big system.

bethskurrie
2020-05-04 23:40
:thumbsup::skin-tone-3:


rjaladurgam
2020-05-05 05:45
@wesleythomaswilliams is there any example you have?

wesleythomaswilliams
2020-05-05 08:25
Is this what you're after @rjaladurgam ```public class myConsumerPactTest { @Pact(provider = "", consumer = "") public RequestResponsePact putCall(PactDslWithProvider builder) throws Exception { return builder .given("") .uponReceiving("") .path("") .query("") .method("PUT") .willRespondWith() .status(201) .body(putResponse) .toPact(); } @Pact(provider = "", consumer = "") public RequestResponsePact getCall(PactDslWithProvider builder) throws Exception { return builder .given("") .uponReceiving("") .path("") .query("") .method("GET") .willRespondWith() .status(200) .body(getResponse) .toPact(); } @Test @PactTestFor(pactMethod = "putCall") void testPut() throws Exception { } @Test @PactTestFor(pactMethod = "getCall") void testGet() throws Exception { } }```

mykeandreas_pact
2020-05-05 08:29
Ok, in my understanding, the provider is the entire BE and the consumer is the mobile app in this case. In the BE there are multiple microservices, the way how pact verifier works, it runs the pact verification in the context of a microservice. If you run it through `pytest` it will create a test database before the tests start and it will clear that database automatically for each test. The issue is that it clears only the database for that microservice, and as there are multiple microservices, I need to manually clear the database for the other ones before each pact test.

mykeandreas_pact
2020-05-05 08:48
Maybe I am missing something here, I?ve looked on the documentation but I can?t see how the Pact verification can be run against the Provider and not against a microservice

bethskurrie
2020-05-05 08:56
I don't feel like we have the same understandings of the terms here. Perhaps you could draw me a diagram and mark the components that have a pact between them.

mykeandreas_pact
2020-05-05 08:56
Ok, I will try to do that later today, thanks for the help

bethskurrie
2020-05-05 08:56
Is your backend an aggregation service?

mykeandreas_pact
2020-05-05 09:07
No, the backend is composed of multiple microservices

mykeandreas_pact
2020-05-05 09:07
each one with its own purpose

bethskurrie
2020-05-05 09:07
you need a pact with each of the microservices separately

bethskurrie
2020-05-05 09:08
You can't have a single pact that covers multiple services

mykeandreas_pact
2020-05-05 09:08
and if you perform a normal http call, you will hit the API endpoint and from there multiple micro services get called and in the end you will get the response

bethskurrie
2020-05-05 09:09
let's go back to the drawing plan.

bethskurrie
2020-05-05 09:09
I'm in australia, so I'll be offline in a couple of hours. If I don't get back to you tonight, I'll respond in the morning.

mykeandreas_pact
2020-05-05 09:10
That is a big time difference

mykeandreas_pact
2020-05-05 09:10
I am in Europe

bethskurrie
2020-05-05 09:10
yeah, it does make it tricky

mykeandreas_pact
2020-05-05 09:11
But this is not urgent, I will try to explain as clear as possible

bethskurrie
2020-05-05 09:11
:thumbsup::skin-tone-3:

mykeandreas_pact
2020-05-05 09:11
Thanks

ajinkya.pande
2020-05-05 09:50
has joined #general

ajinkya.pande
2020-05-05 15:18
Hello , i am new to pact. one question i have should i mock the actual end point for dependent server or the logic in service where endpoints API's accessed?

rjaladurgam
2020-05-05 16:32
Thanks @wesleythomaswilliams. Wasn't sure that multiple pacts and tests could be written in a single java file

wesleythomaswilliams
2020-05-05 16:32
No worries, it's working just fine for me.

rjaladurgam
2020-05-05 16:33
Would it be possible for consumer tests to fail if the provider doesn't have the API yet?

wesleythomaswilliams
2020-05-05 16:38
Both consumer and provider are independent of each other. Their link is the contract that the consumer creates and the provider verifies. So while the provider is dependent on their being a contract to verify, the consumer has no such dependency as it is creating the contract.

rjaladurgam
2020-05-05 16:42
isn't it unsafe if a consumer is pushed to prod without the provider having the correct API. I am trying to see how the consumers to be protected too. Read something about pending pacts feature

rjaladurgam
2020-05-05 16:43
What is the channel for UI tests?

rjaladurgam
2020-05-05 16:43
@bethskurrie Could you please help on why "While we don't recommend you generate pacts from your UI tests, you can use Pact to support your UI testing using one of a few approaches." ?

wesleythomaswilliams
2020-05-05 16:47
```isn't it unsafe if a consumer is pushed to prod without the provider having the correct API. I am trying to see how the consumers to be protected too. Read something about pending pacts feature``` Depends how you define "unsafe". You have less overall validation without the provider side testing, but presumably you have lots of other types of tests validating your consumer outside of contract tests. Many people write services without contract tests and while the risk to quality might be higher, that doesn't stop them going to production. The quality requirements of your business/industry might be higher, I've no idea. Personally, I would put contract tests in place once both the consumer and provider were ready for them, but I don't think that should prevent you writing consumer tests in the meantime. Would love other people's thoughts on that.

wesleythomaswilliams
2020-05-05 16:51
As an example, before I left my last job, we developed microservices for three years and never implemented contract testing.

rjaladurgam
2020-05-05 16:52
My view was to flag errors in the consumer tests if the provider doesn't have the API

wesleythomaswilliams
2020-05-05 16:55
I'm not sure I understand that last message. Can you explain what you mean by "if the provider doesn't have the API"

rjaladurgam
2020-05-05 17:11
Sorry, let me be more clear. I mean if the provider hasn't written the API or API doesn't return the responses expected. How could we show some errors when consumer tests are written

mykeandreas_pact
2020-05-05 18:16
I think I realized what is the issue of our current implementation. Pact-verifier runs inside one of the microservices, lets say Microservice A, we run pact-verifier with pytest to take advantage of the pytest functionality, but this limits the configuration of Microservice B, during pact tests

mykeandreas_pact
2020-05-05 18:16
So now, during pact tests, we reset the DB of Microservice B from within Microservice A

mykeandreas_pact
2020-05-05 18:16
After more investigation I understood that the pact-verifier needs to be outside of the Backend, and just run like a normal app the prerecorded pacts against the Backend API, and pass the provider states before each pact.

nhodaly
2020-05-05 18:39
has joined #general

rjaladurgam
2020-05-05 19:38
Is there any recording of the advanced pact workshop?

jlklein
2020-05-05 21:07
Thanks @bethskurrie. I would love to see some examples on this topic.

wesleythomaswilliams
2020-05-05 21:35
Your test would (and should) have no knowledge of the provider API/service. However, the can-i-deploy tool that Pact provides, which you integrate into your build pipeline, would stop the pipeline if it found no provider. It gives output like: ```Computer says no ¯\_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? ------------------------|-----------|----------------------------|-----------|--------- consumer-service | 35eb3c2 | provider-service | ??? | ??? [There is no verified pact between version 35eb3c2 of consumer-service and the latest version of provider (818cab2)``` @matt.fellows can you have a read of the thread and just make sure I'm advising @rjaladurgam correctly.

matt.fellows
2020-05-05 23:22
Thanks Wes, yes that?s pretty much it

matt.fellows
2020-05-05 23:23
Ramana - your unit tests are your unit tests and have no access to outside systems. Think of Pact as a unit test, it should not have access to the real provider - the whole point of contract testing is to get away from this end-to-end, integrated testing issue

matt.fellows
2020-05-05 23:23
Of course, unit tests can put in assumptions about things that are simply not true - like an endpoint on a provider that doesn?t yet exist

matt.fellows
2020-05-05 23:24
That?s where the `can-i-deploy` check comes in. It says ?hey, I want to deploy consumer A to production, does the provider in production support my expectations??. If the answer is no, you have a failed build

matt.fellows
2020-05-05 23:24
no sorry, we are looking to do more of these publicly soon though


bethskurrie
2020-05-06 01:26
Ok, I'm glad you've worked it out @mykeandreas_pact

bethskurrie
2020-05-06 01:26
That diagram wasn't quite what I was after - I meant a diagram that showed how your HTTP services talked to each other, and which services the pact was between.


sbartsa
2020-05-06 07:52
Hello everyone! Does anyone know any more information about the `pending pacts` and how we can use them? Thank you in advance :slightly_smiling_face:

bethskurrie
2020-05-06 07:52
You need to be using Pactflow at the moment.

matt.fellows
2020-05-06 07:53
I love that people know about pending pacts but don?t - feels so secretive!

bethskurrie
2020-05-06 07:53
And Pact js, go, or net.

bethskurrie
2020-05-06 07:53
Or python

matt.fellows
2020-05-06 07:53
And some select? that

bethskurrie
2020-05-06 07:57
You can see an example consumer pipeline here https://github.com/pactflow/example-consumer @rjaladurgam

bethskurrie
2020-05-06 07:59
You can see how to enable the feature in this step of our CI/CD workshop https://github.com/pactflow/ci-cd-workshop/blob/master/workshop/02_protecting_the_provider.md

2020-05-06 08:02
A new post has been created in *Feature Requests*

sbartsa
2020-05-06 08:02
Perfect. So specifically for jvm distributions we'll have to wait a bit, right?

2020-05-06 08:03
A post in *Feature Requests* has been marked as *in progress*

bethskurrie
2020-05-06 08:04
Yes. Ron is working on it.

matt.fellows
2020-05-06 08:04
I think so. I know work has started but not sure where it?s specifically at

martin.nilsson
2020-05-06 08:05
Hi! I want to start using pact but I can?t really wrap my head around how to approach messages (we use a lot of JMS). With messages it feels like I want the provider/consumer inverted, instead the message-consumer I want to use the service-consumer as the pact-consumer. Does that make sense at all? For example appA sends a message to appB, appB may or may not send a response. Here I want to write my consumer tests in appA

bethskurrie
2020-05-06 08:05
You could achieve a similar outcome if you are using can-i-deploy, by running the verifications in a separate process and ignoring the exit code.

bethskurrie
2020-05-06 08:05
Then rely on can I deploy to make sure you don't deploy any broken code.

bethskurrie
2020-05-06 08:06
Or, you could call the new api directly, and then verify each pact url separately, ignoring the results of the pending ones.

bethskurrie
2020-05-06 08:06
Depends how impatient you are!

2020-05-06 08:07
A new post has been created in *Feature Requests*

2020-05-06 08:08
A post in *Feature Requests* has been marked as *in progress*

sbartsa
2020-05-06 08:08
Ah I see, now I understand the can-i-deploy flow cause my scepticism was that the build will fail due to the broken tests.

sbartsa
2020-05-06 08:08
Thanks a lot! You have been doing an amazing job :slightly_smiling_face:

bethskurrie
2020-05-06 08:09
Did you read the pending pacts blog post? I'm guessing that's where you heard about it?

bethskurrie
2020-05-06 08:09
Thanks Stefanos - it's nice to be appreciated!

bethskurrie
2020-05-06 08:10
I've just made a new feature request in canny. You can follow it to be updated when it's out.

bethskurrie
2020-05-06 08:10
Gtg, dinner in Australia!

sbartsa
2020-05-06 08:11
Yes, this is where I can across pending pacts.

matt.fellows
2020-05-06 08:11
And yes, Beth _has_ been doing an amazing job. Pending and WIP pacts are game changers, we need to market that feature better

sbartsa
2020-05-06 08:11
Regards to my other country :flag-au:

ashish_garg5
2020-05-06 09:33
has joined #general

a.smith
2020-05-07 08:09
has joined #general

morten.hekkvang
2020-05-07 08:42
has joined #general

morten.hekkvang053
2020-05-07 08:45
has joined #general

wesleythomaswilliams
2020-05-07 22:06
@bethskurrie @matt.fellows You may find this interesting. The contact tracing app the NHS in the UK is developing is making use of Pact: https://github.com/nhsx/COVID-19-app-Android-BETA/blob/master/app/src/test/java/uk/nhs/nhsx/sonar/android/app/registration/RegistrationConfirmDevicePactTest.kt

bethskurrie
2020-05-07 22:07
Interesting. Is your one open source? Ours isn't, but people have decompiled it.

matt.fellows
2020-05-07 22:07
I think they were open sourcing it right?

matt.fellows
2020-05-07 22:07
Wow thanks for the share Wes

bethskurrie
2020-05-07 22:08
I haven't heard about any intention to open source it

wesleythomaswilliams
2020-05-07 22:11
Not sure on the open source aspect.


bethskurrie
2020-05-07 22:24
Nice

tjones
2020-05-08 02:28
This is cool! Thank you!

2020-05-08 03:23
A new post has been created in *Feature Requests*

bethskurrie
2020-05-08 03:31
Looking for someone to help create a pact-net e2e example for helping diagnose issues, like we have for the pact-ruby-standalone and pact-js.

2020-05-08 04:40
A new post has been created in *Feature Requests*

2020-05-08 04:41
A new post has been created in *Feature Requests*

2020-05-08 04:42
A post in *Feature Requests* has been marked as *complete*

2020-05-08 04:42
A post in *Feature Requests* has been marked as *complete*

2020-05-08 04:43
A post in *Feature Requests* has been marked as *complete*

tjones
2020-05-08 05:32
Hi everyone! In pact-js land, I?m putting together a common example consumer and provider so that our many JS test framework examples are comparable to each other (currently we have some things covered in some tests, but not others). I?m starting from the Pact-JS workshop example here: https://github.com/pact-foundation/pact-workshop-js What would people want to see in the examples? So far I?ve got: * Success and failure cases * Matching strings / ints and array contents (we get asked about array matching a lot) * Easy broker configuration without too much config (some of the examples use older patterns which require more custom code)

bethskurrie
2020-05-08 05:40
Did you merge my PR for updating the examples?

bethskurrie
2020-05-08 05:40
The publishing code.

bethskurrie
2020-05-08 05:40
Great idea BTW. It just reminded me of the changes I'd made recently.

tjones
2020-05-08 05:42
Yep! Well, Matt did :slightly_smiling_face:

tjones
2020-05-08 05:43
(also, thanks!)

bethskurrie
2020-05-08 05:43
:+1:

tjones
2020-05-08 05:43
I have this long term dream that all the examples will implement the same thing, then we can talk about it everywhere in the docs

tjones
2020-05-08 05:43
I?m probably not the first with this dream

tjones
2020-05-08 05:44
I?m also not planning to do it, at least not all at once.

tjones
2020-05-08 05:44
Starting with pact-js, though

bethskurrie
2020-05-08 05:44
It's good to have dreams

tjones
2020-05-08 05:47
* provider states

tjones
2020-05-08 05:49
John Lennon famously said ?A dream you dream alone is only a dream. A dream you dream together is reality?, Not many people know that the rest of that quote is ?Contract tests help you assert that you?re dreaming the same dream, also I recommend Pact?

bethskurrie
2020-05-08 05:50
HA!

bethskurrie
2020-05-08 05:50
He was stoned at the time...

bethskurrie
2020-05-08 05:51
The recommended tagging and verification set up.

tjones
2020-05-08 05:52
?Eh, what?s that, John?? ?I dunno, check the log files?


tjones
2020-05-08 05:52
Great idea

bethskurrie
2020-05-08 05:54
Now I've got "I dreamed a dream" from Les Mis on my head

matt.fellows
2020-05-08 07:27
Now I have ?a million dreams? from the greatest showman

matt.fellows
2020-05-08 07:27
Oh Hugh

bethskurrie
2020-05-08 08:03
Funny, that's what I said...

priyafa
2020-05-08 13:37
has joined #general

priyafa
2020-05-08 13:45
Hi there, I am a QA engineer. I am just very new to contract testing and read about PACT online today. I am not sure this is the right place to ask. Please redirect me if not. I would like to know whether its right to use PACT in my scenario. I have a rest api to test, which takes data from a third party wcf service , process and gives some result. Can someone please advice ? THanks in advance

pyasi
2020-05-08 13:46
has joined #general

manos
2020-05-08 16:19
Hi everyone! I am a Test Engineer and recently started exploring the Contract way of testing integrations. Having successfully covered server-to-server integrations i am now highly interested in using Pact for Kafka messages integrations in Ruby and Node apps. I am also using a Pact broker. Is there any chance of having a complete implementation for messages in Ruby soon? (including ?honours_pacts_from_pact_broker?) Thank you in advance!

wesleythomaswilliams
2020-05-08 21:55
.

bethskurrie
2020-05-08 23:40
@manos yes, I've recently had someone else asking about this, so it's high on my priority list. You'll see it's in progress on our feature board. https://pact.canny.io/

bethskurrie
2020-05-08 23:41
The consumer support is there for pact-js, and the provider verification support is there for pact-js and pact-ruby. What's missing is the consumer support for pact-ruby, which just has a few things left.

patelaksh412
2020-05-09 06:57
has joined #general

hoagiex
2020-05-09 21:53
has joined #general

xiaoxing.hu
2020-05-11 01:25
has joined #general

lewis.thorley
2020-05-11 09:49
has joined #general

lewis.thorley
2020-05-11 09:59
Just wondered whether anyone has come across or attempted a dart implementation of PACT? My personal drive for this is that I use PACT tests on .net and React projects, but would like to use PACT on flutter projects.

matt.fellows
2020-05-11 10:27
No-one has created one yet - but hey, if you want to get involved we would :heart: to support you

tjones
2020-05-11 10:28
That would be super cool!

elliottmurray
2020-05-11 16:01
The more I?m using Dart the more I like it tbh.

patrick.b.romo
2020-05-11 18:00
has joined #general

wesleythomaswilliams
2020-05-11 21:44
I've got a service that writes messages to a kafka topic and consumes messages from the same kafka topic. Just wondering if that's likely to throw up any issues when I write a consumer and provider test for the service? Also wondering how Pact Flow would represent that in the network diagram.

matt.fellows
2020-05-11 22:49
3 volunteers already! :wink:

abubics
2020-05-11 23:32
I'm working through the Flutter workshops with GDG Sydney atm . . . haven't done much except UI, but I'd be interested to see the progress, and maybe help, too . . . time permitting . . .

bethskurrie
2020-05-12 01:54
I don't even know @wesleythomaswilliams!

bethskurrie
2020-05-12 01:55
About the diagram that is.

bethskurrie
2020-05-12 01:56
I believe it's possible to have a pact with the same consumer and provider - I remember someone doing this once, and there was some issue that I then wrote a test case to cover.


elliottmurray
2020-05-12 06:24
Which covers a lot is ground including basic programming. But has good coverage and plenty of coding. I?m currently doing custom animations and about to move onto firebase

wesleythomaswilliams
2020-05-12 07:56
I'll let you know then. :smile:

bernardoguerr
2020-05-12 10:14
I guess in theory you could always name them differently. Even though it's the same service, you could maybe separate the naming with something that differentiates them. Just a thought!

bethskurrie
2020-05-12 10:49
I wonder what would happen to can-I-deploy!

bethskurrie
2020-05-12 10:50
It'll either work perfectly, or explode in a spiral of meta :exploding_head:

rajeesudh
2020-05-12 16:26
has joined #general

rajeesudh
2020-05-12 17:54
HI All, I am new to this channel, and a QA Engineer... I was wondering If I can create tests using Pact if I just have the endpoints of the API and the json files for the POST ? Do I have to be a developer and have access to the code in order to handle the Provider tests, or can I do it with just the endpoints? I am trying out Pact with .net core btw

kaamilwal
2020-05-12 20:26
has joined #general

matt.fellows
2020-05-12 23:06
Hi! Yes. It?s not designed to be an external API testing tool (e.g. postman). It needs to execute the actual consumer code to generate the contract and ensure it?s always up to date

matt.fellows
2020-05-12 23:07
You could still do it without executing the real client, but you?d run the risk that the test gets out of sync with the actual implementation. But if you wanted to do to just understand the tool, obviously that would be fine. You could then present the case to the developers after showing the value - that?s a pretty standard POC process

hans.brouwer
2020-05-13 08:24
has joined #general

rajeesudh
2020-05-13 09:40
Thanks @matt.fellows, I would like to do that then ..... are you aware of any websites which would give me some on info on doing it this way?

matt.fellows
2020-05-13 10:16
I don't know of any website directly getting you to do it the wrong way, no

matt.fellows
2020-05-13 10:17
Just write a regular pact test based on an example in one of the repositories and adjust to your needs

matt.fellows
2020-05-13 10:17
I'll be honest, you'll need to know how to code or to have access to somebody who can guide you

krishnam.misc
2020-05-13 10:43
Hey @rajeesudh, I can help you there with half cooked stuff. I have managed to generate pact and right now trying to publish a pact. Onc e done, we need to write a Provider test that validates this pact.

francislainy.campos
2020-05-13 10:54
has joined #general

francislainy.campos
2020-05-13 10:57
Hi all, good morning. Could I get some help with this SO question here please? https://stackoverflow.com/questions/61772433/how-to-verify-pact-when-data-returns-items-with-or-without-children-filled-in-o. Many thanks.

bethskurrie
2020-05-13 11:00
I've added a response.

francislainy.campos
2020-05-13 11:17
Thank you. I've just read it now. Unfortunately we don't have access to changing the data removing the skills array for some of the items, but I guess we'll need to live with it, knowing the tests are not checking that part of the response if no other way around that.

francislainy.campos
2020-05-13 11:18
I've marked your SO answer as accepted.

bethskurrie
2020-05-13 11:19
Pact tests work in concert with your overall testing strategy - sometimes it's not possible or convenient to test something with Pact, so you might want to test that particular bit in an integration test (though of course, you'd want to keep those to as few as possible).

rajeesudh
2020-05-13 11:22
That's great @krishnam.misc .......your help would be great

matt.fellows
2020-05-13 12:00
Love the collaboration folks!

simon.nizov
2020-05-13 12:34
Hi all, anyone here using Drone CI and implemented pact webhooks?

krishnam.misc
2020-05-13 13:16
@rajeesudh - javascript

rajeesudh
2020-05-13 13:21
That'scool... could you share some more details , I will decode it to .net :slightly_smiling_face:

bernardoguerr
2020-05-13 13:38
Hi Simon. I've had to do it in a previous company I've worked in. It's a bit of a pain :slightly_smiling_face:

bernardoguerr
2020-05-13 13:40
Happy to help out @simon.nizov, if you have any specific questions

krishnam.misc
2020-05-13 13:51
JS

simon.nizov
2020-05-13 13:53
Hey Bernard, yeah I?m starting to realize it?s not that easy. Did you trigger the builds using Drone?s API? How did you control the steps you wanted to execute?

bernardoguerr
2020-05-13 13:54
I had to build a system to support it. I can kind of show you a diagram of it, sec

bernardoguerr
2020-05-13 14:09
Basically, there are 3 main issues with Drone: 1. There is no webhooks API, so we had to create one ourselves; 2. The API drone exposes, as is, only supports returning the last 50 builds. This is a problem because you want to be able to find the latest build matching something. We happened to already have an internal service that talks directly to the Drone DB to retrieve more than 50 builds; 3. You need to do this in a safe way, as the drone builds could easily have side effects, and you can't have more than one drone file for different purposes. The result was something like this:

bernardoguerr
2020-05-13 14:12
To give you some context: ? The service was the Lambda there (dapact-webhooks); ? We had a manifest.yml file in each repo with some other settings. We added one for pact there. This was one of the checks that the lambda did. If there wasn't a pact: enabled option there , it wouldn't run. The reason for that was because we had to make sure people had adequately prepared their drone pipelines with the appropriate steps; ? We used deployment events (with name pact) to run only the pact tests from the webhook (the regular provider tests were a separate pipeline step from the webhook triggers). This allowed us to only run specific steps (like building, installing, and the pact verification). It did mean that we couldn't have any other steps in the pipeline with generic triggers (meaning that they trigger for any deployment). Thus the need to prepare the pipelines

bernardoguerr
2020-05-13 14:13
(The call to the Github API was to get that manifest file I mentioned. You could of course implement this some other way, instead of a manifest file in each repo, you could keep one in the service you build that lists all the repos that this is enabled in. Or some other way to manage configuration. Up to you - This is basically a safety precaution so people don't go enabling this webhooks Drone flow and mess up other peoples deploys without properly configuring pipelines)

bernardoguerr
2020-05-13 14:18
Also the drone-pe-query is the other internal service we happened to already have, which gives access to more than 50 builds directly from drone's db

simon.nizov
2020-05-13 14:22
Wow! thanks for the great overview @bernardoguerr

simon.nizov
2020-05-13 14:22
Can you tell me more about the ?deployment event: pact? part?

simon.nizov
2020-05-13 14:23
I don?t see a way in drone to make your own manual event ?types?

simon.nizov
2020-05-13 14:23
did you use starlark?

bernardoguerr
2020-05-13 14:24
sorry that might have been misleading

bernardoguerr
2020-05-13 14:25
I believe we used a deployment event to an environment called pact

bernardoguerr
2020-05-13 14:25
we did not use starlark, no

bernardoguerr
2020-05-13 14:25
They were YAML configurations

bernardoguerr
2020-05-13 14:26
Bear in mind this was based on Drone 0.8. Not sure if much has changed with regard to webhooks for Drone 1+, but I don't think so

simon.nizov
2020-05-13 14:27
Well one thing is that now you can paginate and get more than the latest 50 builds :slightly_smiling_face:


bernardoguerr
2020-05-13 14:27
Awesome, so you don't need that intermediate service

bernardoguerr
2020-05-13 14:27
It sounds like all you really need is to build the webhooks service talking to the Drone API. You can even bypass the Github API part like I suggested, if you don't want to deal with that

simon.nizov
2020-05-13 14:28
Yes, I was also thinking about using lambda for that

simon.nizov
2020-05-13 14:30
But I?m still not sure I understand how to skip build steps when triggered through the webhook

bernardoguerr
2020-05-13 14:32
This basically contains details of most of the things you need in this: a function to getAllBuilds. A function to find the latest successful one. a drone token (which we encrypted with KMS) And then use the event *deployment* with *deploy_to* pact (means the drone file would have an environment: pact)

bernardoguerr
2020-05-13 14:32
Well you are not actually "skipping them" . It's just that you configure steps only specifically for the deployment to environment pact, with the things you need to run the pact via a webhook trigger

bernardoguerr
2020-05-13 14:33
so when it makes a deployment to environment pact, it will only run those

bernardoguerr
2020-05-13 14:34
like I said, the only caveat is you have to make sure you don't have generic deployment events (ie ones that run for *every* environment - if you want them, you have to specifically exclude pact on them)

simon.nizov
2020-05-13 14:36
Ah ok! Got it

simon.nizov
2020-05-13 14:36
It?s not documented that you can pass params when triggering a build


bernardoguerr
2020-05-13 14:36
It works :slightly_smiling_face:

bernardoguerr
2020-05-13 14:37
I suggest you play around with the drone API a bit on Postman first, to get a feel for it

simon.nizov
2020-05-13 14:38
Yeah will do. Thanks a lot! :party_parrot:

bernardoguerr
2020-05-13 14:38
One final thing: If you do implement things this way (with deployment and environment = pact), just make sure that your provider also has a regular pact step for running in their own CI. Basically think of verification differently from 2 sources: ? 1 source is the CI of the provider just running normally, like when a provider is running their tests ? the other is from a webhook

bernardoguerr
2020-05-13 14:38
Good luck! :slightly_smiling_face:

krishnam.misc
2020-05-13 14:46
For the overall example to wrok; you need these pieces: Implement Provider Implement Consumer Install pact package from npm Install test runner like Jest Write Consumer test to generate pact json file Execute Consumer test which will generate pact json publish pact file to pact broker Write provider test with pact broker Execute provider test

rajeesudh
2020-05-13 14:49
Thanks @krishnam.misc, I will try and come back if I have any doubts or issues

krishnam.misc
2020-05-13 14:50
yes pls

krishnam.misc
2020-05-13 14:50
will do whatever I could

krishnam.misc
2020-05-13 14:52
About your other Q: pact works on the concept of mocking and gives the flexibility of not having to spin up actual services (prov,cons) to test the contract

rajeesudh
2020-05-13 15:50
does that mean we have to have access to the Modal's (Json rootojects kind of stuffs) ?

bethskurrie
2020-05-14 07:08
Wow. That sounds amazingly complex!

simon.nizov
2020-05-14 07:49
It?s funny because other than this, it?s a really cool and easy tool to use. All our DevOps guys swear by it and say it?s the best CI/CD tool out there :man-shrugging:

aleksmarg
2020-05-14 08:50
has joined #general

szymon.ramczykowski
2020-05-14 08:51
has joined #general

bernardoguerr
2020-05-14 09:09
Yeah that's the same experience I've had. It's really good at what it does, but there are some things it doesn't do. We just happened to need those things :smile:

arindam.datta
2020-05-14 10:33
has joined #general

roshan.lobo
2020-05-14 12:07
has joined #general

ashwin.bakker
2020-05-14 12:16
has joined #general

szymon.ramczykowski
2020-05-14 12:47
Hello and welcome! I am new to PACT testing, and was wondering if it is possible to use it when producer and consumer are in different technologies (i.e. consumer java, producer go).

matt.fellows
2020-05-14 12:48
yep!

matt.fellows
2020-05-14 12:49
Totally one of the main reasons to use Pact - we have language bindings for JS, Java, Go, Ruby, .NET, Python, PHP, Scala, Swift, Rust, R and now C++

matt.fellows
2020-05-14 12:49
I?ve probably missed a language there, but you get the idea

szymon.ramczykowski
2020-05-14 12:58
Thanks Matt. Wondering if there are any tutorials on how to tackle this? Probably we could take producer part for one language, consumer for another. I assume contract would be in a format acceptable for all technologies.

matt.fellows
2020-05-14 13:02
bang on

matt.fellows
2020-05-14 13:02
Start with the consumer. In your case Java


matt.fellows
2020-05-14 13:02
Write your consumer test in whichever variant of build system / test framework

matt.fellows
2020-05-14 13:03
step 2: publish your pact file somewhere (usually a pact broker see https://docs.pact.io/pact_broker about how to run / host your own or use something like http://pactflow.io)

matt.fellows
2020-05-14 13:03
step 3: have your provider _verify_ the contracts


matt.fellows
2020-05-14 13:04
you might also like to do an end-to-end workshop to learn all of the concepts: https://github.com/pact-foundation/pact-workshop-go (all go, but should translate)

szymon.ramczykowski
2020-05-14 15:29
cheers!

krishnam.misc
2020-05-14 15:42
Sorry, was busy with few other things today. Well, you have to generate pact (contract) by mocking the consumer endpoint response

krishnam.misc
2020-05-14 15:42
you shd look into existing example, which is very clear in official website

jacek.okrojek
2020-05-14 21:17
has joined #general

jacek.okrojek
2020-05-14 21:22
Hi all, I am new to Pact but I plan to use, I joined Pact Slack to see what is going on here and get help when I get to problems :slightly_smiling_face:

bethskurrie
2020-05-14 22:00
Welcome @jacek.okrojek

matt.fellows
2020-05-14 23:13
:point_up:

matt.fellows
2020-05-14 23:14
@rajeesudh what have you looked at and tried so far? You?ll find we have examples in the Pact JS repository that cover most cases


matt.fellows
2020-05-14 23:14
:point_up: end-to-end tutorial

mike.geeves
2020-05-14 23:39
has joined #general

mike.geeves
2020-05-15 00:01
Hi :slightly_smiling_face: We are in the process of trying to get a pact poc working with our GitLab CI/CD pipelines, just trying to get my head around a sensible flow. Hoping there might be some useful python examples to share rather than help I'm stuck, but we shall see :joy:

bethskurrie
2020-05-15 00:03
There's a javacript one.


bethskurrie
2020-05-15 00:03
Apart from the actual tests themselves though, most of it is translatable to other languages.

bethskurrie
2020-05-15 00:04
I believe that pact publish is not natively available in pact-python, but you can do it with the docker image, or the pact-ruby-standlone (which requires no ruby).



matt.fellows
2020-05-15 00:05
Also, :clap: for dedication :stuck_out_tongue:

mike.geeves
2020-05-15 00:05
Yeah, using the docker based cli so far

mike.geeves
2020-05-15 00:06
Python seems like a less than idea first language to try with it :D

bethskurrie
2020-05-15 00:06
It's not quite as widely used, but it should be ok.

mike.geeves
2020-05-15 00:07
Thanks, I'll have a look through those as well

mike.geeves
2020-05-15 00:09
Yep, the pact part itself is ok so far, consumer/broker/first part of provider. Looks like it should be really nice if we can persuade everyone else to try it :D

mike.geeves
2020-05-15 00:14
Ohh, sorry also bad wording from me typing on my phone, I meant I'm hoping we might have some examples to share back if successful, python + GitLab less widely used as you say so seems to be less in the way of full examples floating around

bethskurrie
2020-05-15 00:56
I was sure we had a Gitlab webhook trigger in our templates library, but I can't see it https://docs.pact.io/pact_broker/advanced_topics/webhooks/template_lib

matt.fellows
2020-05-15 00:57
hmm yes I recall this too



matt.fellows
2020-05-15 00:57
lol

bethskurrie
2020-05-15 00:57
Need to sync the docs.

matt.fellows
2020-05-15 00:57
But why is the Wiki still alive? That?s going to be a source of confusion and duplication

mike.geeves
2020-05-15 01:46
:thinking_face: currently I'm calling the trigger from the CI itself rather than a webhook back from the broker - that way the consumer build can pause (or fail) waiting for the verification/publish (I need to read many things still, this may be a terrible idea... But that's all once I get past what I even want to do re feature branching/versioning/environments!)

bethskurrie
2020-05-15 02:05
You can use can I deploy to poll for the result.

bethskurrie
2020-05-15 02:06
I would use that instead, because it will be quicker 99% of the time, as with most commits, the pact doesn't change.


bethskurrie
2020-05-15 02:07
The wiki is still alive because it hasn't all been transferred across.

bethskurrie
2020-05-15 02:10
@mike.geeves the ci/cd workshop would be really useful for you to get your head around the flow. You don't need to know JavaScript particularly well to do it.

lbraymusso
2020-05-15 02:56
hey, i'm trying to get a sense for the `pact_mock_service` tool's capability and am curious if there's a way to extend its usage to a more generic service-mocking capability. in other words, would teams that don't yet have interest in using pact for contract testing still be able to use the mock service in order to (temporarily) spin up a dependent service for their local dev environment?

uglyog
2020-05-15 03:10
You can, but you will have to configure it with Pact files. However, the mock server is strict and will only return results if they match what is in the pact files.

uglyog
2020-05-15 03:12
For a more lenient mock server, the https://github.com/pact-foundation/pact-stub-server was created for Android developers to be able to continue prototyping their app without having to create the backend services. You could try that.

lbraymusso
2020-05-15 05:02
got it, that makes sense. and thanks! i'll check `pact-stub-server` out as well :slightly_smiling_face:

tjones
2020-05-15 05:17
How is everyone doing their version numbers for Pact? Are there commonalities, and would automatically picking up versions be something we could generally do? I?m thinking of making a tool (or option) for PactJS which does nice Pact versions for you if you?re using semver on git tags - this is a very common pattern in javascript land, but what about elsewhere?

matt.fellows
2020-05-15 05:18
I generally do `<package version>.<short git sha>`

matt.fellows
2020-05-15 05:18
e.g. `1.6.34-fc0026d`

tjones
2020-05-15 05:19
I do this: `1.2.0-master+1.e03b40b`

tjones
2020-05-15 05:20
(when not on an exact tag, it tells you branch and the number of commits past the full tag)

matt.fellows
2020-05-15 05:20
interesting


tjones
2020-05-15 05:21
Going to write a blog to accompany this one day

tjones
2020-05-15 05:21
The thing that?s nice about this is that it?s possible to reason about how far past the package version you are

bethskurrie
2020-05-15 05:57
I thought the official semver format was to put a plus symbol for anything after the M.m.p?

bethskurrie
2020-05-15 05:57
Rather than a dash.

matt.fellows
2020-05-15 06:00
Yeah that?s not semver, but is it suppposed to be?

matt.fellows
2020-05-15 06:02
Actually I lie, it is valid semver, but it denotes it as a prerelease: https://semver.org/#spec-item-9

bethskurrie
2020-05-15 06:04
From memory, anything after the plus is just metadata, and not considered part of the ordering.

matt.fellows
2020-05-15 06:06
If the tags need to be semver compatible and represent reality (e.g. master is probably not a prerelease) then I?d swap the hyphen and `+` around in Tim?s example

matt.fellows
2020-05-15 06:06
But I?ve never come across anything IRL that?s needed that when it comes to Pact specific stuff. The commit sha usually gets me to where I need to get

bethskurrie
2020-05-15 06:07
"Build metadata MAY be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers MUST comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85."

bethskurrie
2020-05-15 06:07
Basically, anything after the plus is whatever you want.

bethskurrie
2020-05-15 06:08
I like Tim's format, but yes, I'd replace the dash with a plus to make it sem ver compatible.

jacek.okrojek
2020-05-15 07:43
Hi Beth

jacek.okrojek
2020-05-15 07:45
does Pact Foundation/PactFlow support commercialy organizations that would like to introduce CDC Tests

jacek.okrojek
2020-05-15 07:45
?

mike.geeves
2020-05-15 07:51
It's the how this fits e2e in the development flow, e.g. re the can-i-deploy / verifier, I might want to know if the provider and consumer aren't compatible (and so prevent a master merge of a feature branch and deploy to the QA environment), but for the Dev environment it's maybe fine to deploy anyway :thinking_face: Morning again in the UK so I'll start going through the links properly :) Thanks!

matt.fellows
2020-05-15 07:58
Morning!

matt.fellows
2020-05-15 07:58
Well, you can certainly do that using the tools discussed. Definitely worth doing that workshop

bethskurrie
2020-05-15 08:19
If you're using PRs to merge your branches, you can use commit statuses sent via webhooks to make sure your branch is ready to merge.


hans.brouwer
2020-05-15 08:35
Hi, has any one experience with Kafka message CDC testing? I'm trying, though I got stuck. The scalapact library seems only to support HTTP call testing.

wesleythomaswilliams
2020-05-15 08:36
Yes, but using Java.

hans.brouwer
2020-05-15 08:37
If any one has an example while using Scala and Kafka CDC I would be very happy to receive it. @wesleythomaswilliams, if I can have a simple example of your setup it might help me as well.

hans.brouwer
2020-05-15 08:37
In the end, Scala is running java too.

wesleythomaswilliams
2020-05-15 08:38
Sure, let me see if I can whip up a dummy version of what I have with all the business related junk stripped out.

matt.fellows
2020-05-15 08:38
Yep, don't think scalapact supports in. Pact JVM definitely does and kafaka was one of the first use cases I'd u recalls

wesleythomaswilliams
2020-05-15 08:39
Btw, I assume you've seen the example in the pact-jvm repo?

matt.fellows
2020-05-15 08:39
And as always, the community beats me here! :laughing:

hans.brouwer
2020-05-15 08:39
Yeah, I found that one. But didn't get it working

hans.brouwer
2020-05-15 08:40
(yet)

mike.geeves
2020-05-15 08:40
I have a feeling you may have already dealt with a lot in the upcoming WIP functions :thinking_face:

bethskurrie
2020-05-15 08:40
Yes. These are available to pact-python.

bethskurrie
2020-05-15 08:41
Are you using the OSS broker or Pactflow?

mike.geeves
2020-05-15 08:41
OSS


bethskurrie
2020-05-15 08:41
You'll need to turn the feature on in the Broker.

hans.brouwer
2020-05-15 08:41
Especially as the example is using an older version and some of the calls (including their parameter list) are changed. (eg. PactMessageBuilder vs MessagePactBuilder) I was trying to use the 4.0.10 library in combination with Scala 2.13

mike.geeves
2020-05-15 08:41
:+1:

bethskurrie
2020-05-15 08:42
This will also enabled "pending pacts"

mike.geeves
2020-05-15 08:42
Awesome, thanks :)

bethskurrie
2020-05-15 08:43
Something to note is that can-i-deploy is also "can i merge". eg. if you ran `can-i-deploy --to test` from a branch of your consumer, the results would tell you whether or not you were safe to merge, because it would mean that the API was supported in the test environment already.

mike.geeves
2020-05-15 08:43
Also, big thanks, you're very reactive :) I was expecting much quieter!

bethskurrie
2020-05-15 08:44
I just happen to be on my laptop right now!

bethskurrie
2020-05-15 08:44
Usually I'm asleep when anybody needs me (being in Australia!)

matt.fellows
2020-05-15 08:45
If you wanted to spike quickly, just sign up to a dev acct a http://Pactflow.io

mike.geeves
2020-05-15 08:45
Yeah, we've been looking at that. There's a lot to take in :)

mike.geeves
2020-05-15 08:50
I'm picking up from a colleague who started looking at it, she has the broker/consumer/provider all setup, I'm just looking at the what next and stealing the glory! (not really)

bethskurrie
2020-05-15 08:58
Btw, I don't think you mean to have "also send to general" turned on.

bethskurrie
2020-05-15 08:59
All your chats are turning up in the main thread.

mike.geeves
2020-05-15 09:01
Information share? We try to tick it on threads in our slack so other people can find and you don't have to repeat. I spend a lot of time repeating :p happy to not tick, wasn't sure preferred practices on here

bethskurrie
2020-05-15 09:01
We try to keep conversations in threads, so as not to spam people in general.

mike.geeves
2020-05-15 09:02
:+1:

bethskurrie
2020-05-15 09:02
If it's a generally useful comment, we might tick it, but if it's discussing stuff that's only relevant to the people in the conversation, we keep it unchecked.

mike.geeves
2020-05-15 09:03
Apologies for the noise :p

mike.geeves
2020-05-15 09:06
(no offence taken to deleting the noise!) Meanwhile, I'll get back to reading

hans.brouwer
2020-05-15 09:28
@wesleythomaswilliams, thanks! I will have a look!

tjones
2020-05-15 16:04
Off the topic of the main question, but the intention of my script was to match semver correctly - as in, anything that isn?t a release is a pre-release. `master` is printed because it?s not a released version.

tjones
2020-05-15 16:07
Only from the perspective of version preference. It?s defined as dot separated

tjones
2020-05-15 16:07
Yep :slightly_smiling_face:

arindam.datta
2020-05-15 16:37
is there any library in .net for message contract testing for event driven communication between services?

matt.fellows
2020-05-15 22:40
There is a branch that's I think close to merging

matt.fellows
2020-05-15 22:40
I know some people here use it

matt.fellows
2020-05-15 22:41
But not merged in to master yet

raghu.alapati1
2020-05-16 00:07
has joined #general

bethskurrie
2020-05-16 01:33
I'm just going through the "pact nirvana" pages, and updating them. During the initial set up, we don't reference tags at all - the initial pact gets published with no tags, and the initial verification set up just verifies the latest pact. Then in the next step, we add the tags to both sides. Would it make more sense to just set the tags from the beginning? I had done it in two parts so as to introduce as few concepts at the same time as possible, but I wonder if it's just easier to start with the tags already there. I'd love to hear from anyone who has gone through this for the first time recently.

mike.geeves
2020-05-16 07:50
Could you include both and explain the consequences? I mean show the simplest example as well as with tags, then in the later can-i-deploy section you could refer back to the two and what having the -to or not means I agree fewer concepts / flags can be simpler, but generally find it's ok as long as there's at least and explanation of the difference if the optional ones weren't there

bethskurrie
2020-05-16 08:03
I would never set up a pipeline without the tags.

bethskurrie
2020-05-16 08:03
It's not so much that it's optional - it's whether to do it in one hit, or two steps.

mike.geeves
2020-05-16 08:53
What about branch vs env tags?

mike.geeves
2020-05-16 09:18
Imo, if it's completely non-optional, it's confusing to suggest it as an example isn't it?

bethskurrie
2020-05-16 09:32
Yes, that's my quandary.

mike.geeves
2020-05-16 09:46
I find often (general tutorials rather than pact specifically) that it's a bit like science at school, you have the intro to "this is what an atom is like". Then two years later "actually that wasn't quite true we simplified it because it's complicated, it's like this..". Repeat. :joy: "tags aren't strictly needed here, but are useful because x and will be explained in more detail later, for the impatient, <here> ?

matt.fellows
2020-05-16 10:05
I'd say in that Nirvana case, just state how it should be in the end game

matt.fellows
2020-05-16 10:06
Tutorials and other workshops can teach the concepts. I think the Nirvana guide should simply be "this is where you're aiming"

luis.con-garza
2020-05-16 17:44
has joined #general

kameda.sbng
2020-05-17 02:33
has joined #general

mramos
2020-05-17 12:28
Hi, when trying to publish pacts in PactFlow, I got this error: Could not publish pact: Error making request - OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed Can anyone advise please? Thanks.

mike.geeves
2020-05-17 18:47
Just to confirm, that's the hosted PactFlow rather than your own broker with a self signed cert? (I haven't used PactFlow, but for self hosted it looks like there are a couple of steps to use your own cert)

matt.fellows
2020-05-17 23:08
It?s pretty clear that you?re communicating to a server with a self-signed certificate, as Mike says

matt.fellows
2020-05-17 23:42
> To connect to a Pact Broker that uses custom SSL cerificates, set the environment variable `$SSL_CERT_FILE` or `$SSL_CERT_DIR` to a path that contains the appropriate certificate.

upgundecha
2020-05-18 03:57
Hi, I am currently implementing Pact-JVM for a Spring Boot application. I?m new to Spring boot architecture. We have an interaction which requires an auth token. How do we setup a provider verification API which requires an auth?

bethskurrie
2020-05-18 03:58
Read the docs under Verifying Pacts on http://docs.pact.io

bethskurrie
2020-05-18 03:58
There's a page on auth


upgundecha
2020-05-18 04:00
Thanks, I can see reference to Request filter but the link is broken


bethskurrie
2020-05-18 04:01
Have you tried googling it?

upgundecha
2020-05-18 04:01
I did but there is no clear doc or examples that I can refer

upgundecha
2020-05-18 04:01
There are many vanilla examples

upgundecha
2020-05-18 04:02
None talk about handling auth

bethskurrie
2020-05-18 04:02
I mean, the broken page

bethskurrie
2020-05-18 04:02
Did you read the page I just sent?

upgundecha
2020-05-18 04:02
yeah, I did search for broken link on google

bethskurrie
2020-05-18 04:03
Ask on the #pact-jvm-help channel

bethskurrie
2020-05-18 04:03
But also, read the docs page on auth


bethskurrie
2020-05-18 04:03
That link looks identical

upgundecha
2020-05-18 04:04
Anyway thanks

upgundecha
2020-05-18 04:04
Thanks @uglyog

bethskurrie
2020-05-18 04:04
I can't see what's different!

upgundecha
2020-05-18 04:04
@uglyog can we set the request filter for specific endpoints only?

uglyog
2020-05-18 04:05
```tree/master/pact-jvm-provider-gradle tree/master/provider/pact-jvm-provider-gradle```

uglyog
2020-05-18 04:06
The urls will change again when 4.1.0 is released

upgundecha
2020-05-18 04:07
ok

uglyog
2020-05-18 04:07
@upgundecha Pact doesn't deal with endpoints, it deals with providers and consumers. You can either setup different endpoints as different providers, or have your callback filter on the path of the request

abubics
2020-05-18 04:14
@bethskurrie The broken one is missing `provider/` after `master/` :innocent:

bethskurrie
2020-05-18 04:15
Ah, right.

bethskurrie
2020-05-18 04:15
I've put a reminder for me to update it

upgundecha
2020-05-18 04:23
@uglyog can you help me with an example of callback filter on path of the request?

uglyog
2020-05-18 04:28
I don't have any examples like that, but it will be a simple if statement ```if (request.getRequestLine().getMethod() == "/path/needing/auth") {```

upgundecha
2020-05-18 10:10
Thanks so much @uglyog that was super easy. Got the verification running smooth. Really appreciate your help

mike.geeves
2020-05-18 11:44
I'd add, there's not really a "good" reason anymore to not just use something like let's encrypt, which: handles the certificate creation for you, can be setup to auto renew, and doesn't cost anything I've found a lot less headaches with software and so a lot less work overall not having to "work round" self signed certs: https://letsencrypt.org/ Out of scope for pact but worth a look if you haven't tried already

kumarkrish85
2020-05-18 12:14
has joined #general

matt.fellows
2020-05-18 12:24
Let's encrypt is awesome Mike - happy for you to respond to the next ticket raised by someone who works in an enterprise with their own CA :laughing:

preethighalke
2020-05-18 13:11
Hi, I was trying to run the pact-mock-server on Mac V 10.15 which does not have ruby installed. when I execute the command ./pact-mock-service --help start its shows the error : /pact/lib/ruby/bin/ruby: line 6: /pact/lib/ruby/bin.real/ruby: No such file or directory I do not see the ruby folder under "bin.real" $ ls bundle irb puma rake thin bundler nokogiri pumactl redcarpet unicorn gem posix-spawn-benchmark rackup redcloth unicorn_rails am I missing something, I was following the instructions mentioned at https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.84.0. Any inputs will be helpful. Many Thanks.

matt.fellows
2020-05-18 13:33
You don't need Ruby installed, so that should be fine

matt.fellows
2020-05-18 13:34
How have you installed it? Have you just extracted the contents into something like /opt/pact ?

matt.fellows
2020-05-18 13:35
Can you also confirm you've downloaded the Mac specific version?

preethighalke
2020-05-18 13:37
Hi Matt, installed pact-1.84.0-osx.tar.gz version thats the only version provided at the link.

preethighalke
2020-05-18 13:38
I just extracted the contents into a folder and tried executing the command

chris.dopler
2020-05-18 14:11
has joined #general

robert.strauch_slack
2020-05-18 21:24
has joined #general

adam.strickland
2020-05-18 21:25
@bethskurrie I?m interested in using `pact-message-ruby` for a ruby messaging consumer. if i can help in any way, please lmk

bethskurrie
2020-05-18 22:53
We often see this error when people are running it within a docker container that doesn't have certain libraries available @preethighalke

bethskurrie
2020-05-18 22:55
@preethighalke can you raise an issue in the pact-ruby-standalone repo with exactly the commands you used?

bethskurrie
2020-05-18 22:57
@preethighalke are you running it in a bash shell? https://github.com/pact-foundation/pact-js/issues/305

preethighalke
2020-05-19 01:03
Thanks @bethskurrie I'm using the default Mac Os shell provided by its terminal which looks to be bash. will raise an issue. Regards. $ echo $SHELL /bin/bash $ ${SHELL} -version GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) Copyright (C) 2007 Free Software Foundation, Inc.

preethighalke
2020-05-19 01:27

ashish_garg5
2020-05-19 11:52
Hi, I am able to publish the provider version in pact broker using -Dpact.provider.version=0.0.1.

ashish_garg5
2020-05-19 11:53
wanted to know if there is any way so it can automatically read from the pom.xml

wesleythomaswilliams
2020-05-19 12:01
@ashish_garg5 ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.provider.version>${pact.provider.version}</pact.provider.version> </systemPropertyVariables> </configuration> </plugin>``` We use the surefire plugin to set SystemPropertyVariables for our provider tests to use.

ashish_garg5
2020-05-19 12:02
@wesleythomaswilliams - thanks Wesley, let me add this and try

ashish_garg5
2020-05-19 12:12
Its publishing now thanks @wesleythomaswilliams :slightly_smiling_face:

jacek.okrojek
2020-05-19 13:26
Hi @bethskurrie @matt.fellows

jacek.okrojek
2020-05-19 13:27
do you have any recommendations when it comes to hardware for PactBroker ?

rafael.negron
2020-05-19 15:30
Hello Pact! In order for me to call my provider server, I need to be able to provide authorization headers. Is this possible to do via the provider states server? For example: 1. Provider reads Pact file. 2. Provider makes call to `provider-states` server to setup state. 3. `provider-states` server proxies call (with headers) to real server. 4. Results returned to Provider to `Verify` Please let me know if you all have any questions I can help clarify. Thanks!

wesleythomaswilliams
2020-05-19 15:35

sairsule
2020-05-19 15:35
has joined #general

sairsule
2020-05-19 15:44
In what language shall I try Pact? Considering I am comfortable with Java and JavaScript. and I know Python and Go.

elliottmurray
2020-05-19 15:44
If you are just trying to get the concepts stick with what you are comfortable with

elliottmurray
2020-05-19 15:44
But Java and Javascript are 2 of the most popular and best supported

elliottmurray
2020-05-19 15:44
So you won?t go wrong with either of those.

sairsule
2020-05-19 15:44
I am asking in terms of ease of use and community support.

sairsule
2020-05-19 15:45
thanks @elliottmurray

wesleythomaswilliams
2020-05-19 15:45
I would write it in whatever language your consumer/provider are written in.

elliottmurray
2020-05-19 15:45
You could do a consumer in one and a provider in another if you want to really :muscle:

sairsule
2020-05-19 15:45
:slightly_smiling_face:.

sairsule
2020-05-19 15:46
@wesleythomaswilliams, Is it necessary to write in the language that consumer/provider are written in?

sairsule
2020-05-19 15:48
Is it necessary to write in the language that consumer/provider are written in?

sairsule
2020-05-19 15:48
or is it possible to write Pact tests in other languages. (other than what consumer and providers are written into)

sairsule
2020-05-19 15:49
or is it possible to write Pact tests in other languages. (other than what consumer and providers are written into)

wesleythomaswilliams
2020-05-19 15:49
Not sure, but my contract tests live in the same repositories as the consumer/provider service code and this also allows me to take advantage of using actual product code for contract verification and lean on development engineering expertise if I need it.

mike.geeves
2020-05-19 15:49
The language shouldn't matter, the idea is thouse are decoupled so you shouldn't have problems

elliottmurray
2020-05-19 15:49
It is possible for the Provider but not sure I would

elliottmurray
2020-05-19 15:50
Especially in those first 2 you get a lot of support

wesleythomaswilliams
2020-05-19 15:50
It also means I can get development engineers involved in writing and maintaining contract tests easier.

mike.geeves
2020-05-19 15:50
So a consumer in one language can create the pact definition, push up to a broker, and then a provider in another language perform the verification

sairsule
2020-05-19 16:26
Thanks @mike.geeves. Thanks @wesleythomaswilliams. this is really helpful

koen.roevens
2020-05-19 16:38
has joined #general

bethskurrie
2020-05-19 20:52
@rafael.negron no, but you can write your own proxy server


matt.fellows
2020-05-19 22:55
> Is it necessary to write in the language that consumer/provider are written in? In case it?s not clear from above, yes, you should write the tests in the language of the consumer or the provider you?re testing. There are exceptions to this rule, but until you have a full grasp of Pact it?s not worth discussing

matt.fellows
2020-05-19 22:58
:point_up:

rkhemlani1
2020-05-20 03:59
has joined #general

rkhemlani1
2020-05-20 05:01
Hello, Has anyone had any luck with verifying the pact file on the Provider side when provider is an Azure Function App application ? Since Azure Functions don't really have a "startup.cs" associated with them, I am not able to verify the interactions without having to run two instances of the provider app - the actual server instance (in debug mode) and the unit test instance, which is not the right way. Many thanks

tjones
2020-05-20 05:02
I haven?t had any experience with Azure, but with AWS Lambdas you can either use aws localstack (there may be an equivalent), or test against a test deployment

tjones
2020-05-20 05:03
If there are provider states, you?ll usually want to start the provider in a way that exposes the state change endpoints

bethskurrie
2020-05-20 06:05
A neat little trick that @tjones showed me was to make the lambda functions agnostic about how they were being hosted, so the function could be called via a little express api.

bethskurrie
2020-05-20 06:05
I like this technique a lot, as testing the invocation of cloud functions without the cloud can sometimes be tricky, and is, I think, a step backwards for testability.

dattasai.chunduru
2020-05-20 07:24
has joined #general

antonello
2020-05-20 08:06
Is pending pacts still considered in beta?

melgaer
2020-05-20 09:38
has joined #general

melgaer
2020-05-20 09:39
Hey guys. Im stuck with https://github.com/pact-foundation/pact-go/issues/128 Matt mentioned that there could be some workaround. What it could be?

mike.geeves
2020-05-20 10:18
Happy dance! Just demo'd where I'm up to with pact: broker / 2x consumer / 2x provider / CI pipelines -> adding to consumer -> failing verification -> adding to provider -> pass and deploy. And the live demo didn't fail horribly :smile: Positive feedback and understanding even from non-tech upper management and qa. Thanks, you are awesome (@ pact people) :smile: But now I need a nap

thinh.tranquoc
2020-05-20 10:40
has joined #general

dattasai.chunduru
2020-05-20 10:54
Hi All

dattasai.chunduru
2020-05-20 10:55
I am very new to Contract testing and want to know how to start it and undrstand the PACT with Java usage , I am having a bit knowledge in Java as I am a Selenium Automation engineer

wesleythomaswilliams
2020-05-20 10:56
Hi Datta, first thing to know... Junit 4 or 5 (or something else) Are you using Spring? Maven or Gradle (or something else)

wesleythomaswilliams
2020-05-20 10:57
And there's a dedicated channel for the java side of things #pact-jvm-help

matt.fellows
2020-05-20 11:04
FWIW the use of ports+adapters or clean architecture is one way of enabling this. See slide 40 and beyond for a discussion on how I tend to do this: https://www.slideshare.net/DiUSComputing/aws-workshop-trends-and-development-practices-in-serverless-architectures

matt.fellows
2020-05-20 11:05
Awesome to hear!

ashish_garg5
2020-05-20 11:06
Hi All, I want to combine my GET and POST request. return builder .given("create inventory").uponReceiving("a request to save inventory").path("/api/inventory") .body(requestBody).method(RequestMethod.POST.name()).willRespondWith().headers(headers).status(200) .body(responseBody) .toPact(); return builder .given("get inventory").uponReceiving("a request to get inventory").path("/api/inventory").method("GET") .willRespondWith().headers(headers).status(200).body(responseBody) .toPact(); right now i have these 2 in different files if i am combining i am getting error.

matt.fellows
2020-05-20 11:06
Please ask in -> #pact-jvm-help Ashish

ashish_garg5
2020-05-20 11:08
ok sure

matt.fellows
2020-05-20 11:08
Hi Tomasz, apologies, I?ve been sidetracked with other things the past couple of weeks - it is the top of my OSS list

matt.fellows
2020-05-20 11:08
I think I know where the problem is, but it needs refactoring

matt.fellows
2020-05-20 11:08
If I can prove it?s the issue, I will then have a concrete next step

matt.fellows
2020-05-20 11:09
a) refactor current implementation (if it?s not a huge effort) b) implement the rust interface (strategic direction)

melgaer
2020-05-20 11:10
Hi Matt. Good to hear it got in "top of your backlog" now :slightly_smiling_face:.

matt.fellows
2020-05-20 11:11
To be honest, it was already there from an OSS perspective. Unfortunately there are other priorities for day job stuff. I?d say early next week I?ll be able to re-visit

melgaer
2020-05-20 11:12
Its not easy now, when its harder to separate day-work stuff from off-work stuff being whole time in the same place :slightly_smiling_face:.

melgaer
2020-05-20 11:12
Great.

melgaer
2020-05-20 11:13
ETA is what I need for now.

matt.fellows
2020-05-20 11:14
If I don?t get back to you by Tuesday next week, please @ me as a reminder. you have my blessing! I know it must be frustrating

melgaer
2020-05-20 11:16
Its more concerning than frustrating as it disables core banking pact tests.

melgaer
2020-05-20 11:16
I will.

dattasai.chunduru
2020-05-20 12:07
I am using TestNG and Maven

dattasai.chunduru
2020-05-20 12:08
In our Project we have to do Automation by using Junit 5

dattasai.chunduru
2020-05-20 12:08
and Maven for adding dependencies

wesleythomaswilliams
2020-05-20 12:08
Ok cool, any use of Spring?

dattasai.chunduru
2020-05-20 12:08
I think Developers are using SPRING

dattasai.chunduru
2020-05-20 12:10
now as TESTERS we have to do contract Testing by using PACT

wesleythomaswilliams
2020-05-20 12:10
Ok, then it sounds like you're living in the same world as I am with my contract testing. Are you wanting to test REST API or Messaging contracts?

dattasai.chunduru
2020-05-20 12:11
REST API's

dattasai.chunduru
2020-05-20 12:12
I don't know what is Messaging Contracts

dattasai.chunduru
2020-05-20 12:12
:disappointed:

wesleythomaswilliams
2020-05-20 12:13
If you had a consumer and a provider and rather than the consumer hitting a provider REST API with a GET request etc. There's something like Kafka in the middle of the two that the provider posts messages to and the consumer retrieves messages from. Just a different way for microservices to communicate.


wesleythomaswilliams
2020-05-20 12:17
One of the trickiest parts for me was configuring my POM for both my consumer and provider and you'll also want a good understanding of your build pipeline, to work out how to best integrate the contract tests once you've written them.

dattasai.chunduru
2020-05-20 12:20
This GITHUB Project is having any example to get some understanding coz what ever I am trying to google everything is about PACT Tehory :disappointed: and now the client is expecting us start TESTING and none of us have an IDEA on this :disappointed:

wesleythomaswilliams
2020-05-20 12:21
Main thing, don't stress out about it. Pact can be a little complicated to understand initially, but you'll get there. The github projects have examples and there's a workshop which is probably linked from the docs.

dattasai.chunduru
2020-05-20 12:26
Thank you for your Help and immediate responses. I have small query PACT is also like API Testing Like we will send request and will get response . I understood that there will be a MOCK Consumer and it will take the response

wesleythomaswilliams
2020-05-20 12:49
Yeah, the goal with Pact is to allow you to test both your consumer and your provider in isolation. Hopefully the docs will make that clear.

lankala321
2020-05-20 13:57
has joined #general

matt.fellows
2020-05-20 23:09
:raised_hands: Just wanted to get a shout out to @wesleythomaswilliams who has been answering questions like a mad man. Thanks for being so helpful!!

bethskurrie
2020-05-20 23:09
Thanks @wesleythomaswilliams!

wesleythomaswilliams
2020-05-20 23:23
That's very kind! Glad to be able to help.

matt.fellows
2020-05-20 23:39
Data, I also wanted to make sure that as a Tester if you?re writing Pact tests you will need full access to the code you?re testing (whether on the consumer or provider side)

matt.fellows
2020-05-20 23:39
e.g. tools like Postman will work from ?the outside? perspective, but Pact doesn?t work like this

matt.fellows
2020-05-21 00:16
(Also, sorry for calling you Data! I?m going to blame auto-correct, but I think it was just my fingers)

ravi.mijar
2020-05-21 05:01
has joined #general

ashish_garg5
2020-05-21 10:37
Hi All, Wanted to know where are the PACT/Contract files get stored when published to pact broker ? Thanks.

arindam.datta
2020-05-21 10:47
@bethskurrie any plan to merge the message-pact branch of the https://github.com/pact-foundation/pact-net repo in near future? asking you as you are one of the contributors.

bethskurrie
2020-05-21 10:51
Sorry, I don't actually know any .net!

bethskurrie
2020-05-21 10:52
I maintain the underlying Ruby implementation.

bethskurrie
2020-05-21 10:52
You'll need to ask whoever was working on that branch.

arindam.datta
2020-05-21 10:53
ah ok.. thanks!

bethskurrie
2020-05-21 10:53
@ashish_garg5 they get stored in a relational database. Generally postgres, though it does support mysql too.

arindam.datta
2020-05-21 10:54
Hi @neil , hope you can answer this question :arrow_up:

ashish_garg5
2020-05-21 11:01
@bethskurrie Thanks :+1:

matt.fellows
2020-05-21 12:50
Might be worth checking in the actual issue/PR. We could really do with some help getting the PR into the main project

mike.geeves
2020-05-21 15:08
Probably one of those "you shouldn't really need to look", but for info they're in the pact_versions table, for example:

neil
2020-05-21 23:59
The issue is not in merging, that?s the easy part, the branch was never fully finished

neil
2020-05-22 00:00
@arindam.datta Are you interested in helping finish off the branch? https://github.com/pact-foundation/pact-net/blob/message-pact/TODO.txt

hello
2020-05-22 04:40
has joined #general

bethskurrie
2020-05-22 06:00
Is it hexagonal @matt.fellows? :P

preethighalke
2020-05-22 06:00
Hi, how can one verify an interaction which takes query parameters using the pact-mock-service? I have an interaction defined which is GET request with query parameters. I could POST the interaction, but when i try to verify it using curl -H "X-Pact-Mock-Service: true" localhost:1234/interactions/verification it says the interactions do not match, need inputs. Also a reference example with query params would help. Regards

matt.fellows
2020-05-22 06:01
I prefer dodecahedrons

bethskurrie
2020-05-22 06:01
You probably need to set the query parameters separately in the expectation.

bethskurrie
2020-05-22 06:01
don't put them on the end of the path, set {query: '...'}

matt.fellows
2020-05-22 06:01
6 sides is just not enough

matt.fellows
2020-05-22 06:02
Also, may I ask why you are directly interacting with the mock service? What?s your use case?

bethskurrie
2020-05-22 06:02
It looks like you're doing something unusual though - the documentation should explain that.

preethighalke
2020-05-22 06:09
@bethskurrie Thanks for the response, its working fine at my end now.

matt.fellows
2020-05-22 06:10
Preethi - can we ask why you?re using the mock service directly?

preethighalke
2020-05-22 06:11
@matt.fellows Right now we are just exploring on how to use the mock service and if it can be used to mimic instead of using of our actual provider instance.

matt.fellows
2020-05-22 06:15
interesting.

preethighalke
2020-05-22 06:15
we want to see if we can use the Mock service as part of the consumer Functional verification tests which mimics the actual provider interactions instead of actually pointing to the provider instance

matt.fellows
2020-05-22 06:15
Is this for front end end-to-end type testing with tools like Selenium, Cypress?

matt.fellows
2020-05-22 06:16
gotcha

preethighalke
2020-05-22 06:16
its pure backend microservice to microserice for now

matt.fellows
2020-05-22 06:16
Is there a reason why you wouldn?t still write the contract tests first? This way you?re ensuring your client/consumer code works correctly, and then you can use the contracts with the pact stub server (it will take a pact file, and produce a mock server with the interactions from it)


preethighalke
2020-05-22 06:18
right i was planning to explore the stub service next, just wanted to see how the mock service works and the tradeoff's

matt.fellows
2020-05-22 06:23
the mock server is unlikely to be the right tool for the job you?re talking about, because it?s stateful and has other behaviour associated with it you don?t need. The stub service seems much more useful

matt.fellows
2020-05-22 06:24
I?d still suggest writing the Pact tests. This way, any functional tests you use with those contracts (that are then used as the stub source) will be guaranteed to be correct, because you will get the provider to verify it. You could then look to remove any end-to-end tests you have, because Pact has verified the contract

preethighalke
2020-05-22 06:26
I see, sure . Thank you for the valuable suggestions will get back.

rajeesudh
2020-05-22 07:44
HI @matt.fellows, @krishnam.misc ... I am not able to set { "Content-Type", "application/json;charset=utf-8" } in response header ... any idea how this can be set in ConsumerTest, for .WillRespondWith()

ashish_garg5
2020-05-22 07:44
Hi All, Is there any convention for the package where contract test files will reside ?

tjones
2020-05-22 07:45
Do you mean the pact file, or the tests?

bethskurrie
2020-05-22 07:45
They're generally unit tests for the client class.

ashish_garg5
2020-05-22 07:45
i mean tests

ashish_garg5
2020-05-22 07:46
ok thanks @bethskurrie

matt.fellows
2020-05-22 07:48
what have you tried? What language? The examples above definitely show setting headers

rajeesudh
2020-05-22 07:48
HI All, I am using .net core to do Contract testing, I am stuck in an issue where I need to set the Header with Content-Type . WillRespondWith() in the Consumer test, { Status = 200, //con.setRequestProperty("Content-Type", "application/json; charset=utf8") Headers = new Dictionary<string, object> { { "Content-Type", "application/json;charset=utf-8" } },

rajeesudh
2020-05-22 07:48
Errror that I get is

matt.fellows
2020-05-22 07:52
That?s a provider test result, and the provider seems to be sending the header you?re talking about

matt.fellows
2020-05-22 07:52
it?s complaining because the states code is not 200 and the body isn?t matching

rajeesudh
2020-05-22 08:00
Oh ok, let me sort the body and check again , Thanks @matt.fellows

arindam.datta
2020-05-22 08:38
Hi @neil, thanks for your reply. I have some other pressing priorities, so I wouldn't make any false commitment about contribution.

dom.udall
2020-05-22 09:57
has joined #general

rajeesudh
2020-05-22 09:58
Aah, still cant figure out whats going wrong

bethskurrie
2020-05-22 09:59
Can you see the actual response in there?

rajeesudh
2020-05-22 09:59
I am not sure why I am getting different status code, because when I see it in postman, it looks fine

bethskurrie
2020-05-22 10:00
There's been an error. I'd look in your application log

rajeesudh
2020-05-22 10:00
just trying to do a simple test against this api


bethskurrie
2020-05-22 10:02
You can see the exact request being sent in the pact log.

matt.fellows
2020-05-22 10:11
Also please share your pact file

matt.fellows
2020-05-22 10:12
I can hit that endpoint in a browser so I'm guessing you've got the wrong ot fix it something

matt.fellows
2020-05-22 10:12
I also easily produced that same error

rajeesudh
2020-05-22 10:47
Thats the constract

rajeesudh
2020-05-22 10:49
Cant see anything in logs

matt.fellows
2020-05-22 10:52
The path is missing the v2 prefix is my guess. What's your provider setup code look like?

rajeesudh
2020-05-22 10:53
new PactVerifier(config) .ServiceProvider("EmployeeList", "http://dummy.restapiexample.com/api/v1") .HonoursPactWith("Consumer_1") .PactUri(@"C:\POC - Contract testing - Pact\COntractTesting_DummyRestApi\pacts\consumer_1-employeelist.json") .Verify();

rajeesudh
2020-05-22 11:14
@matt.fellows @bethskurrie any idea?

matt.fellows
2020-05-22 11:25
yes. I just tried hittinsg that rest api using curl. It doesn?t work, I would find another solution (e.g. postman echo)

matt.fellows
2020-05-22 11:26
The site is basically spam

matt.fellows
2020-05-22 11:26
http://dummy.restapiexample.com/api/v1/employee/2 but in a browser it works. I think you need an active session. I?m not going to waste my time debugging that, and neither should you :slightly_smiling_face:

rajeesudh
2020-05-22 11:27
Oh ok.... gotcha

rajeesudh
2020-05-22 11:27
Cool, Thanks @matt.fellows

matt.fellows
2020-05-22 12:51
Hi Jacek - just saw your email

matt.fellows
2020-05-22 12:51
Happy to chat, I just replied now

zeldigas
2020-05-22 17:38
has joined #general

nickj21
2020-05-22 18:33
has joined #general


mike.geeves
2020-05-23 12:37
:thinking_face: slightly fluffy question, I'm wondering about the general pact usage. Does anyone know if "most people" use it mostly for positive tests, i.e. the expect some data coming back, or also to verify expected error handling behaviour? We are working on creating a new set of services for a new product and I'm wanting to try and get pact usage in there from the start. Part of it around making sure different services adhere to conventions (vs everything errors slightly differently) I would expect the FE consumers probably wouldn't care about handling all edge cases and so on, and wouldn't want to lose "test coverage" if the consumer "stopped caring"and removed them later I'm thinking maybe the providers need some pseudo consumer that the BE team would own to cover it, ideally with some sort of discovery and scraping endpoints to fill in gaps automatically Just wondering if there are better suggestions / that would be considered an anti pattern / nobody really tries to do that

zeldigas
2020-05-24 09:42
Hello, could anyone comment on the plans regarding this missing matching rule for array element presence - https://github.com/pact-foundation/pact-specification/issues/38 I feel that I there are use cases that that make PACT almost unusable in terms of contract - some hypermedia formats actively use lists (e.g. Siren), so I have no idea how to do assertion on links presence

matt.fellows
2020-05-24 23:22
> I?m thinking maybe the providers need some pseudo consumer that the BE team would own to cover it, ideally with some sort of discovery and scraping endpoints to fill in gaps automatically I?ve seen people do this. It can be useful for a bunch of reasons, but personally you could still write provider-side functional tests that cover all of the consistent behaviour you expect - e.g. error codes, metadata, standards etc.

matt.fellows
2020-05-24 23:24
I think the general sentiment is that we want to support it, but to get it into all languages will take some time

matt.fellows
2020-05-24 23:24
what language do you need it in first?

matt.fellows
2020-05-24 23:24
Perhaps raise it https://pact.canny.io/ and see if others need it too? we?ve found Canny is a great place to help us prioritise features

abubics
2020-05-25 01:14
The usual approach I see is basically as you describe: ? mostly positive tests (because they're the most interesting and varied), ? plus specific unique negative interactions, and then ? a sprinkling of generic negative tests (they should be consistent across all endpoints).

zeldigas
2020-05-25 06:23
I need for Java as the first priority, then C++, python and JS (with no specific order)

zeldigas
2020-05-25 06:24
In general if design question is closed, I'm ready to contribute to JVM part

matt.fellows
2020-05-25 06:26
@uglyog thoughts?

zeldigas
2020-05-25 06:27
Also, maybe strange and somewhat destructive desire, but still - is there any options for custom extensions? Say finalizing naming and semantics of new assertion would take 3 months, but I'd be happy to have it now, maybe in "limited" version. What if I'd put non-standard matching rule to my pact - what are the places that are likely to blow up?

zeldigas
2020-05-25 06:28
e.g. will pact broker be affected and reject my contract or it does not care and I can just make my quick and dirty patches for consumer/provider in langs I'm interested in?

matt.fellows
2020-05-25 06:29
I?d really like to see us have that capability, not just at the matchers level but at the transports and protocols - but that is a bit harder

matt.fellows
2020-05-25 06:29
no, the broker will not be bothered at all by additional stuff in the contract

matt.fellows
2020-05-25 06:29
I?d say it?s worth a spike if you need it!

zeldigas
2020-05-25 06:30
Thanks!

uglyog
2020-05-25 06:30
I don't see why the matchers couldn't be extended, but how do you get them to work in a language neutral way

matt.fellows
2020-05-25 06:32
there are consequences to something like this, but perhaps the `x-` type extension - where anything with a given prefix is denoted as ?external? or ?non-official? type thing. Then there is the whole question of implementation.

matt.fellows
2020-05-25 06:33
The current Ruby process does actually have a way to monkey patch, so in theory it could be done. Ideally, natural hooks are provided to enable that though

matt.fellows
2020-05-25 06:33
(we also expose that monkeypatch option through to JS currently but wouldn?t be hard to add for the others)

zeldigas
2020-05-25 06:35
I'm not sure that it's possible. In fact I have not dig into implementation details of pact consumer/providers libs, but assume that every language have to reimplement all the checks described in standard. there is no some "universal representation" that is traspiled to java, c, js and so on, right?

zeldigas
2020-05-25 06:35
@matt.fellows Thanks for `x-` idea. I'll take a look into it.

matt.fellows
2020-05-25 06:40
> I?m not sure that it?s possible. In fact I have not dig into implementation details of pact consumer/providers libs, but assume that every language have to reimplement all the checks described in standard. there is no some ?universal representation? that is traspiled to java, c, js and so on, right? Funny you should ask that. Ruby was the original, and powers JS/Go/Python/.NET/PHP. So that is one place C++ and new JS use the Rust engine: https://github.com/pact-foundation/pact-reference JVM is its own beast

matt.fellows
2020-05-25 06:40
But yes, there is still work in all of the client libraries

2020-05-25 06:49
A new post has been created in *Feature Requests*


zeldigas
2020-05-25 06:49
done

dattasai.chunduru
2020-05-25 07:53
Oh we need the API Code what they have developed ?

dattasai.chunduru
2020-05-25 07:57
Actually Contract Testing word is completely new for me I don't have any Idea on this. I used POSTMAN Previously where we used to get end point and the Spec Documentation based on that we used to validate. I understood some Basics from PACT that we will test a MICROSERVICE FROM both Client and Consumer Prospective and it need a MOCK Server. I have cloned a GIT HUB Project and tried to replicate it with a dummy API from my LOCALLY Installed J-SON Server

ravbaker
2020-05-25 08:13
I?ve successfully managed handling and tracking async (fire&forget) events between two services written in Ruby in my project. I had to write some extra code to handle it but it works for me quite well. Maybe I could extract some code to a GitHubGist to showcase it. @bethskurrie

matt.fellows
2020-05-25 10:20
Yes, think of it like a unit test. You're going to need to know the code base well and be able to code

francislainy.campos
2020-05-25 11:40
Hi, could I get some help with this error I'm getting here please? https://stackoverflow.com/questions/62001663/exception-in-thread-thread-2-java-lang-nosuchmethoderror-kotlin-io-bytestream. Thank you very much.

zeldigas
2020-05-25 11:47
would be great to see your dependencies to make sure kotlin is in the classpath. what does `mvn dependency:tree` prints?

francislainy.campos
2020-05-25 11:57
Hi, here is the list of plugins and dependencies and the minimum pom where I can reproduce the issue in pasted on the SO question.

mike.geeves
2020-05-25 12:04
Yes, should still have backend tests, seems like a nice way to avoid copy pasted boilerplate code for the same tests, I'm a big fan of writing as little code as possible. I think the "most interesting and varied" is the key part, focus effort on what's likely to be different Thanks for input / confirming :+1: Would that be something useful as a feature I wonder? :thinking_face: Maybe something with tags whereby a set of tests get performed against providers tagged as a certain class? :thinking_face:

francislainy.campos
2020-05-25 16:01
Why would I be getting a Kotlin error on a Java project?

francislainy.campos
2020-05-25 16:27
I've updated the SO question with some further details in case that may be helpful.

uglyog
2020-05-26 00:54
Answered on SO

abubics
2020-05-26 00:57
> Would that be something useful as a feature Which one of the things? :sweat_smile:

ashish_garg5
2020-05-26 05:43
Hi All, How can i pass a json body in my PactDslJsonBody response ? I have created a json file which my consumer is expecting as a response now i want to pass that in my PactDslJsonBody response. // Want to do something like this PactDslJsonBody responseBody = new PactDslJsonBody().object("test.json");

bethskurrie
2020-05-26 05:44
Please ask in #pact-jvm-help

ashish_garg5
2020-05-26 05:44
sure

romuald.quantin
2020-05-26 08:08
Hi, How do I test 2 differents type of structure with an eachLike? ```{ "list": Pact.Matchers.eachLike({ type: 'A', fieldForA: {} }) }``` And: ```{ "list": Pact.Matchers.eachLike({ type: 'B', fieldForB: {} }) }``` I tried to create 2 different interactions, which works, but I'm also verifying mocks, and these mock contains both it is failing on: ```{ list: [ { type: 'A', fieldForA: {} }, { type: 'B', fieldForB: {} } ] }```

francislainy.campos
2020-05-26 08:15
Thank you. I've updated the dependencies and that's what I have now but still same error I'm afraid.

uglyog
2020-05-26 08:19
You still have the older version of the Maven plugin (pact-jvm-provider-maven). The 4.0.10 version does not have the _2.12 in the name.

uglyog
2020-05-26 08:20
```<groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version>```

francislainy.campos
2020-05-26 08:30
Thank you. Yeah, I hadn't changed that because didn't find a _2.12 compatible with 4.0.10 but changed it now and got the same error still.

francislainy.campos
2020-05-26 08:30
This is what I get when run the dependency tree. All the appearances for Kotlin.

romuald.quantin
2020-05-26 08:40
For one or the other interaction I would get some like: ```Could not find key "fieldForB" (keys present are: fieldForA) at...```

bethskurrie
2020-05-26 08:41
Are they in separate tests?

richard.nunes
2020-05-26 08:43
has joined #general

romuald.quantin
2020-05-26 08:44
That's how I started, I created 2 test that doesn't represent the reality, but I can make 2 tests for for each type of object I can receive

romuald.quantin
2020-05-26 08:44
it is when I verify mock that's I'm failing, because our mocks contains both (as the real response can be)

bethskurrie
2020-05-26 08:45
You need to be able to totally control the data on the provider side for pact to work.

bethskurrie
2020-05-26 08:45
Can you make an array with one of each object?

bethskurrie
2020-05-26 08:46
Unfortunately we don't have a matcher yet that allows you to do unordered contains.

bethskurrie
2020-05-26 08:46
But it's only the list.

bethskurrie
2020-05-26 08:46
BTW, you mean pact verification, not mock verification.

romuald.quantin
2020-05-26 08:47
I do mean mock verification

bethskurrie
2020-05-26 08:47
The mock verification happens on the consumer side, after each consumer test.

bethskurrie
2020-05-26 08:47
The pact verification happens on the provider side.

romuald.quantin
2020-05-26 08:47
yeah

romuald.quantin
2020-05-26 08:48
basically I'd like to do something like: ```{ "list": Pact.Matchers.eachLike({ type: 'A', fieldForA: {} }).or({ type: 'B', fieldForB: {} }) }```

tjones
2020-05-26 08:48
You can?t have a matcher that looks for arrays containing mixed objects

bethskurrie
2020-05-26 08:48
I'm confused as to what the issue is if you really mean mock verification.

tjones
2020-05-26 08:49
Usually this happens if you?re trying to test more than one contract test case with a single test

tjones
2020-05-26 08:49
it?s better to write two tests


romuald.quantin
2020-05-26 08:50
so I can receive a response with 2 type of objects, I can create tests to separate them on the client side, and pact verify them separately, on the backend side but then we have integration tests with mocked response, that contains both the type of object in one response We are verifying these mocks by serving then (all this is client side), and replaying the interaction against it

tjones
2020-05-26 08:50
as Beth says, what mock are you verifying? There are a few cases where you might want to do Pact tests of a mock (eg asserting that mocks for front end devs work correctly), but usually trying to verify concrete mocks with Pact suggests there?s a misunderstanding somewhere

romuald.quantin
2020-05-26 08:51
@bethskurrie we did have some long conversation about optionals a few years ago :wink:

tjones
2020-05-26 08:52
So, your contract test should read: In <this server state>, <this request> will result in <this response>

romuald.quantin
2020-05-26 08:53
I'm not sure what the misunderstanding can be, having 2 tests is already a "way around" not representing the reality

romuald.quantin
2020-05-26 08:53
what I'm missing is capabilities with the matchers

bethskurrie
2020-05-26 08:53
OK, you are doing something that is very interesting, but isn't what pact is written to support. I don't know if we can help until we have the more sophisticated array matching.

tjones
2020-05-26 08:53
I would solve this with a server state where the list is: ``` list: [ { type: 'A', fieldForA: like({ /* whatever fieldForA looks like */}) }, { type: 'B', fieldForB: like({ /* whatever fieldForA looks like */}) } ]```

bethskurrie
2020-05-26 08:54
It's not the pact verify that is failing, Tim.

bethskurrie
2020-05-26 08:54
It's a custom verification, I think.

romuald.quantin
2020-05-26 08:54
yes that's correct

tjones
2020-05-26 08:54
Oh, I thought it was trouble writing the contract?

bethskurrie
2020-05-26 08:54
To validate a separate, custom mock.

romuald.quantin
2020-05-26 08:54
we are serving our mocks, re-using the pact interactions to verify they are valid

tjones
2020-05-26 08:54
I?ve had this case, where you want to verify a response that is an array that contains mixed types

romuald.quantin
2020-05-26 08:55
yes exactly

bethskurrie
2020-05-26 08:55
Short story, can't be done yet, sorry.

tjones
2020-05-26 08:55
Right, but your interaction should say that your server is in a particular state.

bethskurrie
2020-05-26 08:55
But it's been requested.

bethskurrie
2020-05-26 08:55
The "server" is a mock.

romuald.quantin
2020-05-26 08:56
that's fine @bethskurrie that's all I wanted to hear I'll try to find other solutions to verify our mocks

tjones
2020-05-26 08:56
If you say this is an array of type A or B, then you can?t be sure that your test is covering both types

bethskurrie
2020-05-26 08:56
Sorry. It's on the to do list.

romuald.quantin
2020-05-26 08:56
is that feature request deep in a backlog or? :slightly_smiling_face:

tjones
2020-05-26 08:56
I think the answer is the same regardless of whether there?s a mock or not

romuald.quantin
2020-05-26 08:56
or not many people are asking for that

romuald.quantin
2020-05-26 08:57
that's true @tjones

bethskurrie
2020-05-26 08:57
There are requests for it, but we have to make a new spec version to add it, and we haven't caught up all the languages to the most recent spec yet.

bethskurrie
2020-05-26 08:57
We need to do that first.

romuald.quantin
2020-05-26 08:57
I see

tjones
2020-05-26 08:57
If the request is: ?I want to match an array that contains A and B?, then I think it?s on the backlog if the request is ?I want to match an array that contains A or B?, then I think it?s explicitly not planned

romuald.quantin
2020-05-26 08:58
yeah that's the first case

tjones
2020-05-26 08:58
Cool :+1:

tjones
2020-05-26 08:58
For now, you have to do this with provider states

romuald.quantin
2020-05-26 08:58
yep, that's what we will do

tjones
2020-05-26 08:59
I?ve had provider states like ?the list contains A then B?

romuald.quantin
2020-05-26 08:59
provider states are fine, we can cover anything, what is missing is more on the matcher side of it

tjones
2020-05-26 09:00
You just have to match in a more concrete way, since the spec doesn?t support mixed types in an array response yet


tjones
2020-05-26 09:02
I think this is the issue if you want to comment, and there?s a feature request you can vote for too, hold on.


tjones
2020-05-26 09:03
^ I think this would serve your needs

tjones
2020-05-26 09:03
We should have a FAQ page for matchers

tjones
2020-05-26 09:03
I?ll make a note

romuald.quantin
2020-05-26 09:06
yes, it seems to be the same problem

romuald.quantin
2020-05-26 09:06
is there a public pact roadmap I can keep my eyes on?

romuald.quantin
2020-05-26 09:08
thanks both for your time and fast answer about that!

bethskurrie
2020-05-26 09:08
canny has a roadmap at the homepage


romuald.quantin
2020-05-26 09:09
thanks @bethskurrie

francislainy.campos
2020-05-26 09:25

zeldigas
2020-05-26 13:44
@romuald.quantin thanks for voting. In case there will be some progress regarding such assertion, I'll post it to #general

dattasai.chunduru
2020-05-26 14:02
Hi

dattasai.chunduru
2020-05-26 14:03
Can I test this dummy API http://dummy.restapiexample.com/api/v1/ by using PACT ?

romuald.quantin
2020-05-26 14:35
no problem, I feel that would be a good addition :wink:

danhitchcock
2020-05-26 15:37
has joined #general

danhitchcock
2020-05-26 15:42
Hi All, I am trying to pass an hard coded (:grimacing:) auth token into my provider tests, I can't currently set my provider state, is there any other way i can pass this value in for those tests?

francislainy.campos
2020-05-26 15:49
How do I check for longs as in `"timestamp": 1589451234126` in PACT with Java, since integer or number type is not available for large numbers please?

tjones
2020-05-26 15:57
You might get a better answer in Pact JVM - but in general you need to be careful with large numbers in JSON -- because javascript only supports 64 bit floating point numbers, treating it as a big integer is risky

tjones
2020-05-26 15:57
Also, that is an unusually high timestamp

tjones
2020-05-26 15:58
Which tests? For the provider tests, you can set arbitrary tokens in the consumer, or are you asking about re-setting the token during verification?

wesleythomaswilliams
2020-05-26 15:59
I assume you can't match with ```.numberType("timestamp", 1589451234126)```

danhitchcock
2020-05-26 15:59
Yes in the provider test, thanks for getting back to me.

tjones
2020-05-26 15:59
If you need to change the provider test, you can use custom middleware implementing `Pact::ProviderVerifier::CustomMiddleware`

tjones
2020-05-26 16:00
(in Ruby)

danhitchcock
2020-05-26 16:00
is there a JS implementation?


tjones
2020-05-26 16:01
kind of. `pact-node` exposes the standalone ruby binaries as binstubs

tjones
2020-05-26 16:03
You can also use the `customProviderHeaders` option to the verifier if you?re calling it from JS

francislainy.campos
2020-05-26 16:03
@tjones. The timestamp length seems fine to me as it's today's date.

tjones
2020-05-26 16:04
That timestamp is unusual, since it?s in milliseconds

francislainy.campos
2020-05-26 16:04
Yes, it's the time a notification is triggered on our system.

danhitchcock
2020-05-26 16:05
Ok, one more thing, is there any way to console.log the req the provider test makes?

francislainy.campos
2020-05-26 16:07
I'll post it on the jvm channel as you suggested.

tjones
2020-05-26 16:09
I?m afraid I?m not familiar with the java implementation, but I guess the maths checks out for millisecond timestamps in json for more years than you or I will need to worry about

tjones
2020-05-26 16:11
in js we defer most of that to the Ruby implementation (at the moment). Try setting verbose mode - `-v` if you?re calling the binary, or `verbose: true` if you?re invoking from JS

tjones
2020-05-26 16:12
I?m about to make a (large!) list of improvements we can make to the logging and error messages in JS - so please let me know how you get on, and what areas you?d like to see improved.

danhitchcock
2020-05-26 16:17
Awesome, thanks for your help Tim

francislainy.campos
2020-05-26 16:18
Removed the sample for the input altogether such as in `.integerType("timestamp")` rather than `.integerType("timestamp", 1589451234126)` and it worked now. Thanks.

tjones
2020-05-26 16:18
You?re very welcome! I?m heading to bed here, but I?ll check back in the morning in case you have further questions.

tjones
2020-05-26 16:22
Awesome! That?s also good practice - in general, it?s best to get Pact to match the shape of the data rather then the value

mike.geeves
2020-05-26 18:40
The "Maybe something with tags whereby a set of tests get performed against providers tagged as a certain class" :slightly_smiling_face:

uglyog
2020-05-26 23:33
Ok, I can see kotlin-stdlib-jdk8:1.2.71 in your dependencies, which is the wrong version. I'll clone your repo and see if I can reproduce it.

uglyog
2020-05-27 00:07
I was able to reproduce it, but I don't understand why it is happening. I can see in the dependency tree: ```au.com.dius:pact-jvm-consumer-junit5:jar:4.0.10 -> au.com.dius:pact-jvm-consumer:jar:4.0.10 -> io.ktor:ktor-server-netty:jar:1.2.6 -> org.jetbrains.kotlin:kotlin-stdlib:jar:1.2.71``` which is the wrong version of the Kotlin standard lib. Checking Maven Central, https://search.maven.org/artifact/io.ktor/ktor-server-netty/1.2.6/jar has the following in it's POM: ``` <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.3.60</version> <scope>compile</scope> </dependency>```

uglyog
2020-05-27 00:11
Also, https://search.maven.org/artifact/au.com.dius/pact-jvm-core-support/4.0.10/jar has ```<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-jdk8</artifactId> <version>1.3.71</version> <scope>runtime</scope> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-reflect</artifactId> <version>1.3.71</version> <scope>runtime</scope> </dependency>``` Looks like there is the same issue with Gson. I was able to fix your project by adding the following to the dependencies: ``` <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.3.72</version> <scope>test</scope> </dependency> <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>2.8.6</version> </dependency>```

abubics
2020-05-27 00:59
I think the most useful starting point is to treat a provider as a cohesive interface of a single bounded context.

abubics
2020-05-27 00:59
If you find a test set getting big, and duplicated between providers, I'd reconsider the scopes of your bounded contexts and modules.

abubics
2020-05-27 01:00
You could probably come up with some custom verification tagging schemes that do what you're suggesting, but it feels more like the domain concerns could be remodelled instead :slightly_smiling_face:

abhinav.sharma
2020-05-27 06:04
has joined #general

francislainy.campos
2020-05-27 08:38
Thanks a lot! Yeah, that worked. Accepted the SO answer now. Appreciate your help. Have a great day. :)

danhitchcock
2020-05-27 09:58
``` Types of property 'logLevel' are incompatible. Type 'string' is not assignable to type '"trace" | "debug" | "info" | "warn" | "error" | "fatal" | undefined'. ``` Upgraded to the latest version and i am getting this error

danhitchcock
2020-05-27 10:49
also i am a bit confused as to why the service i am pointing it at is printing this out to console, as i haven't setup a pactSetup url ``` I, [2020-05-27T11:38:19.680907 #14248] INFO -- request: POST http://localhost:52641/_pactSetup```

tjones
2020-05-27 10:50
For the first try `'info' as logLevel`

danhitchcock
2020-05-27 10:51
ah no same error

tjones
2020-05-27 10:51
The second is looking for the default provider state URL, I believe. You can safely ignore it.

tjones
2020-05-27 10:51
can you share your code?

danhitchcock
2020-05-27 10:52
```import { Verifier } from "@pact-foundation/pact" import path from "path" const port = 5000 const opts = { provider: "Backend", providerBaseUrl: `http://localhost:${port}`, pactUrls: [path.resolve(__dirname, "../pacts/frontend-backend.json")], providerVersion: "1.0.", followRedirects: true, verbose: true, logLevel: "info", customProviderHeaders: ["Authorization: Bearer XXXXXredactedXXXX"], } jest.setTimeout(30000); // Verify that the provider meets all consumer expectations describe('Pact Verification', () => { it("validates the expectations of Matching Service",async() => { console.log("opts " + opts.providerBaseUrl) return await new Verifier(opts).verifyProvider().then((output:any) => { console.log("done "+output) }); }) })```

tjones
2020-05-27 10:58
Apologies, it?s in caps: ```import { LogLevel } from '@pact-foundation/pact/dsl/options'; .... logLevel: "info" as LogLevel,```

tjones
2020-05-27 11:00
I?m not a big typescript user, so if I?ve done something unhelpful with the type system recently, please let me know (also I apologise)

danhitchcock
2020-05-27 11:03
ok debug works :slightly_smiling_face: i am hardly a TS evangelist so you're safe :slightly_smiling_face: . It looks like the tests are failing because i am not authorised, despite passing a valid bearer token, which i tested on postman. Below is the logging for when i replace the token . redacted because :slightly_smiling_face: ``` INFO: Replacing header 'Authorization: Bearer' with 'Authorization: Bearer eyXXXREDACTEDXXX'```

danhitchcock
2020-05-27 11:04
I tried escaping quotes around it but that didn't seem to help

tjones
2020-05-27 11:37
Hm. That looks like the right log output. Are you 100% sure that your postman test used the same token?

danhitchcock
2020-05-27 11:38
checking the logging it seems to be setting the url to not point at localhost:5000 ? ```Starting pact binary 'standalone\win32-1.84.0\pact\bin\pact-provider-verifier.bat', with arguments [/workspace/frontend/pact/pacts/frontend-backend.json --provider-states-setup-url http://localhost:53102/_pactSetup --provider Backend --provider-base-url http://localhost:53102 --provider-app-version 1.0. --verbose true],```

tjones
2020-05-27 11:48
Ah- so, Pact-JS runs its own proxy between the verifier and your provider.

tjones
2020-05-27 11:48
@matt.fellows - can you think of a reason that the proxy would not respect headers that are replaced by the verifier?

matt.fellows
2020-05-27 11:51
Not at all, it should definitely pass them thru

tjones
2020-05-27 11:51
(you should be able to see the request go through the proxy if you set log level to debug)

matt.fellows
2020-05-27 11:51
We could definitely add some trace logging in that part of the code tho

tjones
2020-05-27 11:51
Yeah, I?ve looked through the Ruby and the JS here and I can?t see why the header wouldn?t be correct

tjones
2020-05-27 11:55
@danhitchcock Sometimes middleware rewrites header key case - is your provider particular about the case of `Authorization`?

tjones
2020-05-27 11:56
Thought it would be easier to check the provider before I go through all the layers of middleware here and see if they?re misbehaving

tjones
2020-05-27 12:00
@danhitchcock, can you try using the following option instead? ``` requestFilter: (req, res, next) => { console.log( "Middleware invoked before provider API - injecting Authorization token" ) // e.g. ADD Bearer token req.headers["authorization"] = `Bearer ${token}` next() },```

tjones
2020-05-27 12:01
That will get Pact-JS?s proxy to do the auth header instead of the pact binary

tjones
2020-05-27 12:01
it?s riskier, because the ruby binary will complain if you?re trying to replace a header that doesn?t exist in the Pact file.

tjones
2020-05-27 12:01
(and this approach won?t do that)

tjones
2020-05-27 12:02
even if it doesn?t work, it eliminates the Ruby -> Proxy connection as the source of the problem

tjones
2020-05-27 12:05
Also, it?s weird that the provider verifier doesn?t seem to have the header replacement listed as an argument in your log quote.

dikili
2020-05-27 12:39
Hello, i have a general question, is pactflow the recommended tool as a pact broker or setting this up within the company is a better choice ? Also by uploading pact files somewhere we might be exposing some auth tokens, internal important credentials in the contract thus would it pose a security risk if pactflow is used and pact files published outside ?

danhitchcock
2020-05-27 13:26
Ok tried the code snippet in my options, i can see the log output text, ```[2020-05-27T13:21:58.297Z] DEBUG: pact-node@10.9.4/17356 on beast: Verifying a pact between Frontend and Backend Given 201 is seen a request for a price with the given values with POST /api/v1/campaign returns a response which [2020-05-27T13:21:58.298Z] DEBUG: pact-node@10.9.4/17356 on beast: DEBUG: Setting up provider state '201 is seen' for consumer 'Frontend' using provider state set up URL http://localhost:53688/_pactSetup [2020-05-27T13:21:58.307Z] DEBUG: pact-node@10.9.4/17356 on beast: I, [2020-05-27T14:21:58.306388 #13072] INFO -- request: POST http://localhost:53688/_pactSetup [2020-05-27T13:21:58.307Z] DEBUG: pact-node@10.9.4/17356 on beast: D, [2020-05-27T14:21:58.306388 #13072] DEBUG -- request: User-Agent: "Faraday v0.17.3" Content-Type: "application/json" console.log pact/test/provider.spec.ts:16 Middleware invoked before provider API - injecting Authorization token [2020-05-27T13:21:58.338Z] WARN: pact@9.11.0/17356 on beast: No state handler found for "201 is seen", ignoring [2020-05-27T13:21:58.349Z] DEBUG: pact-node@10.9.4/17356 on beast: I, [2020-05-27T14:21:58.349388 #13072] INFO -- response: Status 200 [2020-05-27T13:21:58.349Z] DEBUG: pact-node@10.9.4/17356 on beast: D, [2020-05-27T14:21:58.349388 #13072] DEBUG -- response: x-powered-by: "Express" content-type: "text/plain; charset=utf-8" content-length: "2" etag: "W/\"2-nOO9QiTIwXgNtWtBJezz8kv3SLc\"" date: "Wed, 27 May 2020 13:21:58 GMT" connection: "close" console.log pact/test/provider.spec.ts:16 Middleware invoked before provider API - injecting Authorization token [2020-05-27T13:21:58.370Z] DEBUG: pact@9.11.0/17356 on beast: Proxing /api/v1/campaign [2020-05-27T13:21:58.396Z] DEBUG: pact-node@10.9.4/17356 on beast: has status code 201 (FAILED - 1)```

bernardoguerr
2020-05-27 14:05
I would say it depends on your bandwith. If you do not have the expertise in-house and need the extra features, go with Pactflow. I think Pactflow right now has an interesting offering, and as a paid customer you are more likely to get support as you need it. As for your second question, you should not need to be passing real authentication tokens in contracts. At most, the contract might represent the shape of the authentication method, but not the actual content. The provider should be responsible for dealing with the authentication when necessary . I wrote an article about it a while ago (https://medium.com/dazn-tech/pact-contract-testing-dealing-with-authentication-on-the-provider-51fd46fdaa78) , and there is useful material on the pact website too (https://docs.pact.io/provider/handling_auth)

tjones
2020-05-27 14:09
Is it definitely failing with an auth failure?

dikili
2020-05-27 14:09
Thank you for the response, but Provider will make the actual call to the API , thus it will need the token and its only source for the token is the pact file itself though no? I thought about encrypting the token via some algorithm and the decrypting for the provider to make the actual call but this would add an overhead i suppose or i am thinking i might be reinventing the wheel somehow ? Not sure if that is the case though

danhitchcock
2020-05-27 14:10
``` Failures: 1) Verifying a pact between Frontend and Backend Given 201 is seen a request for a price with the given values with POST /api/v1/campaign returns a response which has status code 201 Failure/Error: expect(response_status).to eql expected_response_status expected: 201 got: 401 (compared using eql?) 2) Verifying a pact between Frontend and Backend Given 201 is seen a request for a price with the given values with POST /api/v1/campaign returns a response which has a matching body Failure/Error: expect(response_body).to match_term expected_response_body, diff_options, example Actual: {"code":"401","message":"Unauthorized"}``` according to the output

tjones
2020-05-27 14:10
(also your auth token is in that snippet)

tjones
2020-05-27 14:11
wait, no it isn?t. Sorry, tired brain

danhitchcock
2020-05-27 14:12
No worries :slightly_smiling_face: i thought my tired brain couldnt see it

tjones
2020-05-27 14:12
I?m not sure what is happening. I suspect there?s something that?s different between the Pact test and the postman test that you ran to confirm the token is correct.

tjones
2020-05-27 14:12
You could try printing out the whole request in that middleware function

tjones
2020-05-27 14:12
to confirm

tjones
2020-05-27 14:14
(as an aside, it looks like you might not be using provider state correctly - it?s meant to describe the state that the provider is in _before_ the test, but it looks like you might be describing the result of the test. If the provider doesn?t need any config, you don?t need to provide a value in the provider state)

tjones
2020-05-27 14:16
@dikili I think you might be misunderstanding something, although I am not sure what

tjones
2020-05-27 14:18
The usual pattern is to either: 1) use a provider state that sets up an arbitrary token (a state like `"SOME_TOKEN is a valid auth token"`) or 2) Inject a header with a real token during provider verification. The implementation of this depends on the pact framework you are using, and the blog that @bernardoguerr linked illustrates the approach for JS

dikili
2020-05-27 14:21
@tjones my misunderstanding comes under the second question i asked, so what I am trying to get to is, 1. consumer test generated a pact file but end point needs authentication so for the sake of security i can write a consumer test that will just Not require a token in the contract BUT when the provider will verify it will fetch the contract and as it wont see any token in the contract will make a anonymous call to the endpoint thus it will fail, at one point or how provider will substitute different tokens to different endpoints is where I am confused about,if it makes sense ?

tjones
2020-05-27 14:21
(Nice post @bernardoguerr ! One small correction - it?s Pact, not PACT :sunglasses:)


tjones
2020-05-27 14:23
or you can use an approach like the one linked in the blog to rewrite the token during verification

dikili
2020-05-27 14:23
Ok , thank you i will read about this as I am kind of beginning this journey recently

tjones
2020-05-27 14:25
@bernardoguerr how to handle authorisation is a question we get asked a lot, and the end of your blog post is a nice write up. Would you be interested in contributing it to the documentation?

litty.john
2020-05-27 14:29
has joined #general

bernardoguerr
2020-05-27 14:29
Hey @tjones. I've fixed it to say Pact now :slightly_smiling_face: , I think at the time I highlighted it to PACT when I was referring to the team/company. And yes, sure!

litty.john
2020-05-27 14:31
Can someone help in ruby how to add hmac auth in the provider side test

tjones
2020-05-27 14:34
Awesome! The repository is here - https://github.com/pact-foundation/docs.pact.io We?re in the middle of migrating the docs to a better look + feel, but the structure is the same (I?m afraid we haven?t written any instructions for running the new documentation locally yet - but let me know if you need any assistance). Perhaps start with a markdown file under `/docs/faq` (ultimately we?ll probably have a best-practices section and it can go in there)

danhitchcock
2020-05-27 14:40
Not too sure how to see the request thats being sent in the middleware section, tried Json stringifying the req variable. The provider can't be configured so i guess i can remove this, it was there so i could change the auth token for the 401 test.

mike.geeves
2020-05-27 15:37
Totally agree about looking at the overlap, if we have the same tests for the same endpoints it's definitely doing something wrong (I type that as I think of where we have getFarmer, getFarmer2 and getFarmerNew controllers *table flip*) I was thinking more for use cases like "all services with a GET {id} should return a 403 if not found or no permission", vs some return 403 and some return 404, or "all services with GET [all] should also implement GET {id}". Patterns Coding standards rather than domain. I'm having that conversation currently though :slightly_smiling_face: "what is a service", it's very philosophical :joy:

ross.kaffenberger
2020-05-28 01:10
has joined #general

tjones
2020-05-28 01:22
A good guideline that @abubics gave me once is ?test every response that the consumer needs to be able to understand?

tjones
2020-05-28 01:23
this helps you see whether you need to write individual error interactions, or whether you can cover them all with one

tjones
2020-05-28 01:23
does your API client behave differently when it gets 401 vs 403 vs 500 ? (etc)

ross.kaffenberger
2020-05-28 01:29
Hi, new member here. I work at Stitch Fix and we use pact-ruby! I just found this channel via the project README for https://github.com/pact-foundation/pact-message-ruby. We also use messaging quite a bit so I'm interested in possibly introducing this project at work. I'm here to ask about Consumer contract support in pact-message-ruby /cc @bethskurrie

tjones
2020-05-28 01:30
It?s very weird. If you have time, it would be great to get an example repository somewhere that reproduces the problem. The quickest path is usually to fork pact-js and modify one of the examples - either way if you can get an example up on github somewhere, I?ll take a look.

matt.fellows
2020-05-28 01:34
Hey Ross! Welcome

matt.fellows
2020-05-28 01:35
You might be interested in voting for https://pact.canny.io/feature-requests/p/implement-consumer-message-dsl-for-pact-ruby. It?s really not that much work to get it complete, I believe.

ross.kaffenberger
2020-05-28 01:40
Thanks, Matt. Voted!

matt.fellows
2020-05-28 02:04
So I just updated the e2e example in the project as follows (the request filter was already there where an Authorization token was added). I?ve also added a custom provider header `x-header-foo`

matt.fellows
2020-05-28 02:05
I put logging in the providerr service - you can see both headers are being set

preethighalke
2020-05-28 02:14
@matt.fellows tried the stub service it works to suit the needs have few queries though: 1. Does the stub /mock server do an exact maching of the query param values for a given interaction? for eg: My API takes a parameter key=queryvalue now when i test the interaction curl localhost:1234/xyzcontext?key=queryvalue it works but if i give curl localhost:1234/xyzcontext?key=somevalue it fails saying expectation does not match, I was wondering if pact provides a way where i do not want to have hardcoded values for query parameters , request headers etc in the pact and the curl works against the stub/mock server. Also do we have a mechanism to mock authorization header against mock/stub server. any inputs would help.

venkata.poranki
2020-05-28 08:06
has joined #general

godfrey
2020-05-28 09:05
has joined #general

oscarg798
2020-05-28 12:47
has joined #general

oscarg798
2020-05-28 12:48
Hello guys hope you are doing okay, new member arriving with some questions :slightly_smiling_face: Can we specify the provider version for publish task in gradle plugin ?

matt.fellows
2020-05-28 12:56
> _NOTE:_ The pact broker requires a version for all published pacts. The `pactPublish` task will use the version of the gradle project by default. You can override this with the `providerVersion` property. Make sure you have set one otherwise the broker will reject the pact files. from https://github.com/DiUS/pact-jvm/tree/master/provider/gradle#publishing-pact-files-to-a-pact-broker

matt.fellows
2020-05-28 12:56
that answer it?

oscarg798
2020-05-28 13:02
So we have a provider version, but I saw that this can be override but not sure if its just on the provider side, so what I?,m trying to achieve is be able to publish new version of a contract with for example `develop` tag, but avoid this one to be verified by the provider until they are ready

andreas
2020-05-28 20:25
Hi All, We are starting a Pact implementation for a Java/Kotlin client that consumes a (Legacty - No Async Messages) PHP based API. And as I see it, the Java Pact Consumer writes Pact V3 and the Pact for PHP support V2? as I understand it? Should we/Can we - save our pacts in V2 format? Or is there a converter?

uglyog
2020-05-28 23:07
You can save the pacts in V2 format. Also, don't use any of the V3 matchers (numbers, date/times)

uglyog
2020-05-28 23:10
The DSL support libraries have a PactSpecificationVersion parameter. For instance, with JUnit it is supplied on the constructor for PactProviderRule

bethskurrie
2020-05-28 23:35
@andreas the underlying pact engine for php should just ignore the parts of the v3 spec it doesn't understand.

bethskurrie
2020-05-28 23:36
If you find it doesn't, then let me know.

uglyog
2020-05-29 01:42
We have started an RFC process to begin work on a Pact V4 version. The RFC is being tracked on the Github issue https://github.com/pact-foundation/pact-specification/issues/71. We are looking for community feedback on what changes should be made to the Pact file format as well as the behaviour of the matching and verification. Comments are welcome.

jacek.okrojek
2020-05-29 07:05
Hi All, we are planning to introduce Pact Broker to our organization. We are not sure what hardware (CPU, memory) we should use. Can anyone desribe the hardware configuration that he use or give some guidelines?

danhitchcock
2020-05-29 08:02
Cheers @matt.fellows and @tjones that did help resolve my issues with passing a token and using the state tags, tests are now working. Also learnt a few things about the matching and managed to get a full e2e going. It wasn't without some pain so when the dust settles on this project i'll see what i can do about sharing the love on setup :slightly_smiling_face: :wave:

bethskurrie
2020-05-29 08:05
Funnily enough, I was just writing some docs for this for our On Premises offering.

bethskurrie
2020-05-29 08:08
I've just been working on these today, so they're not finished.

bethskurrie
2020-05-29 08:08
https://doc.pact-dev.dius.com.au/docs/on-premises/system-requirements/ This is our staging instance btw, so don't bookmark any of those links. They'll be out at http://docs.pactflow.io next week.

matt.fellows
2020-05-29 08:09
Thanks Daniel - we would _really_ appreciate the surprises / confusing things. Tim and I (core JS maintainers) are planning on catching up soon to talk ergonomics and the new API

matt.fellows
2020-05-29 08:09
I?m thinking we do an open session (e.g. hangouts/twitch/something live) that anybody can join in. Stay tuned in the #pact-js channel

bethskurrie
2020-05-29 08:11
Ron had some estimate for the database so where in slack

bethskurrie
2020-05-29 08:14
Found it. He said one that had been running for quite a while had 650Mb of data.

bethskurrie
2020-05-29 08:15
Give it a couple of GB and I think you'd be more than fine. Not sure you can even provision an AWS instance with that little storage. I think from memory it's 15GB or something?!

mike.geeves
2020-05-29 09:09
We don't have them yet, that's part of the fun :slightly_smiling_face: (we have about 15 years of services of varying quality, varying levels of consistency) It's a chance to try and do things nicely. Agree with the Boris quote, that's absolutely something done badly in the past :smile: I was thinking around the "Principle of least astonishment", they might not need something now, but if they decide they need it later, and then add in the test later, it would be nice if it worked how they expected it because it was the same as everywhere else :slightly_smiling_face: I'm trying to get more QA involvement at the start to work with devs rather than just testing at the end, it's a terrible waste of time when QA picks up edge cases that behave badly/fall over which could have been handled with only a tiny amount of effort at the start vs fix time later Getting a bit deeper than the original thought now :smile:

andreas
2020-05-29 09:59
Thanks! Will just dive into it. Trying to implement Pact and Contract Testing at YouSee (nuuday) - a large danish TV & Films app (distributor).

bethskurrie
2020-05-29 10:02
Let us know how you go. We've just put this out - it might be helpful, if this is your first time. https://docs.pactflow.io/docs/workshops/ci-cd/

jacek.okrojek
2020-05-29 11:55
Thanks Beth, do you have any ideas on HA configuration, is it popular or people have some workarounds for cases then PacktBroker is temporary down?

chandanakurumeti27
2020-05-29 14:01
Hi, Could some one please clarify the below thing! I have consumer test written for specific method (lets say `createuser()`) in my consumer service (`user`) code base, This method `createuser()` is retrieving the data from two different services (`authentication` and `account` services). so as we can see that authentication and account services are two different providers to consumer user service. Now, I want to have two different contracts `1. user<->authentication services` and `2. user <-> account services` . But i have written only one testcase using `@pactverification` against the createuser() method. Is there any possiblility to have two different contracts from only one testcase with `@pactverification` annotation. Please get back to me if anything is unclear here. Looking forward to any reply. Thank you in advance :slightly_smiling_face:

dale.bennett
2020-05-29 14:08
has joined #general

chandanakurumeti27
2020-05-29 14:18
As in figure here https://docs.pact.io/consumer#scope-of-a-consumer-test Collaborators in the my consumer service is communicating with two external services

chandanakurumeti27
2020-05-29 14:18
and i want to have two different contracts when i run test against collaborators unit

bethskurrie
2020-05-29 21:23
Usually you just deploy the image to a docker container management service like fargate, Kubernetes, ecs, and that is sufficient to keep it up 99.99% of the time. That's how we run Pactflow, and we've found it very reliable.

bethskurrie
2020-05-29 21:25
It's not a highly complicated service, so there's not much to go wrong.

bethskurrie
2020-05-29 21:27
We also use a multi az database.

bethskurrie
2020-05-29 21:30
Best to ask in #pact-jvm-help. You definitely can in Ruby, JS etc, by running two mock services at the same time, but I don't know how it works in JVM land.

chandanakurumeti27
2020-05-30 15:31
sure thank you Beth!

wesleythomaswilliams
2020-05-30 16:07
@chandanakurumeti27 I would put tests for each service in separate classes.

chandanakurumeti27
2020-05-30 16:13
Yeah, i tried my best to have it that way, but as i can see it is very difficult to have seperate tests for those two services in my case. so it is not possible to have two contracts from one test case in java?

chandanakurumeti27
2020-05-30 16:23
I found the same kind of issue  https://github.com/DiUS/pact-jvm/issues/117, but couldnt really understand the solution provided here.

chandanakurumeti27
2020-05-30 16:37
I think i found the solution, I have added two provider names in this annoattion @PactVerification({?auth_For_Player?,?account_For_Player?}), started two mock providers at diff ports using @Rule and its working now :slightly_smiling_face:

sairsule
2020-06-01 09:17
Hi, I am testing kafka contracts using Pact. I have a query, there is a section Metadata MessagePact, what is the use of it? I do not use metadata in producer code, still I see "has matching metadata (OK)" message in logs. How can I make sure metadata is also compared?


matt.fellows
2020-06-01 10:16
Might want to check pact JVM GitHub repo and look for any tests that use metadata

dattasai.chunduru
2020-06-01 12:43
Hi All

sjuli.chen
2020-06-01 15:55
has joined #general

uladzimir.sadouski
2020-06-01 20:53
has joined #general

weyert.deboer
2020-06-01 21:55
has joined #general

weyert.deboer
2020-06-01 22:17
Hello

weyert.deboer
2020-06-01 22:18
I am considering use Pact for solving an issue were we keep having a broken API from a third party supplier, thinking of writing both the consumer and provider as it's working now so we can easily track when things break. Only it's not full clear how Pact could assist me with detecting this. As I assume you can't really run it against a test environment?

mike.geeves
2020-06-01 22:25
I'm not sure if this would be a good use case for pact as there then wouldn't be anything you could do about it anyway, aside from then updating your software and creating a new pact Disclaimer: fairly new to pact myself so may not be the best answer From my experience elsewhere, I've covered this with tools such as runscope, where we have tests against 3rd party APIs to check some of our common usage and how long those requests etc take, to then get a slack notification of there is a problem

weyert.deboer
2020-06-01 22:27
Yeah, I have been looking for a nice lecture or tutorial/book about Pact to get a better understanding of it :slightly_smiling_face:

dgaglani
2020-06-02 00:07
has joined #general

dgaglani
2020-06-02 00:10
Hi.. I am using PACT test framework (on Java) .. I am stuck in creating array of interactions in pact programatically.. I know one way is: ```return builder .uponReceiving("a request for something") .path("/hello") .method("GET") .willRespondWith() .status(200) .body("{\"hello\": \"Ada\"}") .uponReceiving("another request for something") .matchPath("/hello/[0-9]+") .method("GET") .willRespondWith() .status(200) .body("{\"hello\": \"Ada\"}") .toPact();```

bethskurrie
2020-06-02 00:10
Best to ask in #pact-jvm-help

dgaglani
2020-06-02 00:11
Thanks!


matt.fellows
2020-06-02 00:20
@bernardoguerr :point_up: another vote for your video series :slightly_smiling_face:

ramfjordm
2020-06-02 07:55
has joined #general

vitor.campos
2020-06-02 12:41
has joined #general

sairsule
2020-06-02 14:15
I created a sample contract test for a messaging service consumer and producer in using spring boot. following pact file is created ```{ "consumer": { "name": "KafkaReceiver" }, "provider": { "name": "MessageProvider" }, "messages": [ { "description": "a test user is created", "metaData": { "topic": "first_topic", "key": "update", "contentType": "application/json" }, "contents": { "name": "Foo", "id": 42 }, "providerStates": [ { "name": "SomeProviderState" } ], "matchingRules": { "body": { "$.id": { "matchers": [ { "match": "number" } ], "combine": "AND" }, "$.name": { "matchers": [ { "match": "type" } ], "combine": "AND" } } } } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "4.0.10" } } }```

sairsule
2020-06-02 14:17
when run java-producer it allows different numeric values for 'id'. Which is fine. But when I wrote producer pact test in GO, it fails when 'id' is not exact match of 42. are matchers different in GO and JVM?

matt.fellows
2020-06-02 14:21
Go doesn't support the v3 matchers yet. You need to serialise the Java pacts with V2

sairsule
2020-06-02 14:27
OK.

sairsule
2020-06-02 14:28
where can I see what languages support what specification?


dominicdemierre
2020-06-02 16:35
has joined #general

sairsule
2020-06-02 16:53
Thank you @mike.geeves

dominicdemierre
2020-06-02 16:56
Hi, sorry if this has been answered already, I couldn't find it. I have tests using the PactNet messaging branch, which is V2. I'm now writing tests w PactJS, and https://github.com/pact-foundation/pact-node/issues/100#issuecomment-635641156 I'm looking at using V3 PactJS. But, I'm concerned about compatibility. I'll need PactNet to consume contracts generated by PactJS, and vice versa. Is this remotely possible (assuming I avoid V3 features?) Thanks very much :^)

sairsule
2020-06-02 17:22
link for "Best practices for pacticipant version numbers " is broken on https://docs.pact.io/pact_nirvana/step_8

shawn.edge
2020-06-02 17:35
has joined #general

shawn.edge
2020-06-02 17:39
Hello! I had a question about Pact and graphql... We're got a debate internally here and I'm hoping you guys might be able to shed some light. graphql is a bit new to me vs. REST api so I apologize if this is obvious. My question is Why would anyone want to use Pact for Graphql?

dom.udall
2020-06-02 17:50
I had the same question a few weeks ago! At the end of the day it's not the technology your using as much as the request you're making and the response you're expecting. Changes to a qraphql API can still break clients that are written with specific queries. http://blog.pact.io/2018/07/24/contract-testing-a-graphql-api/ was one of the posts I found useful

pravera
2020-06-02 17:58
Hi everyone! We have many services in Ruby, Python, JS that have pact tests and are thinking of a way to know which of our endpoints are covered by pacts. Have you thought of a `pact coverage tool`? Will be doing research on how to solve this? Thanks!

shawn.edge
2020-06-02 18:28
One of the arguments was that if the schema doesn't change the API shouldn't break. I thought this was. bit odd.

sairsule
2020-06-02 22:49
I tried this following, It gives error ```Message pacts only support version 3+, cannot write pact specification version V2``` `@Pact(consumer = "KafkaReceiver")`     MessagePact reciveMessagePact(MessagePactBuilder builder) {         PactDslJsonBody body = new PactDslJsonBody();         body.numberType("id", 42L).         stringType("name", "Bar")         .closeObject();         Map<String, Object> metadata = new HashMap();         metadata.put("key1", "value1");         metadata.put("key2", "value2");         MessagePact pact =  builder.given("SomeProviderState")                 .expectsToReceive("a simple test")                 .withMetadata(metadata)                 .withContent(body)                                  .toPact();         pact.write("../pact", PactSpecVersion.V2);                 return pact;     }

matt.fellows
2020-06-02 23:26
Hi Dominic, yes I can see how this would be confusing. If you don?t use the v3 specific matchers (so stick with regex/type matchers) then the matchers generated should still be usable by the v2 .NET implementation

matt.fellows
2020-06-02 23:26
You?ll still suffer the path length issue in .NET though, albeit I think it?s less likely because of the way npm vs nuget will package things


matt.fellows
2020-06-02 23:28
hmmm I thought that might be the case

matt.fellows
2020-06-02 23:28
I think as long as you don?t use v3 matchers it should be OK

matt.fellows
2020-06-02 23:28
but it sounds like that?s not the case

matt.fellows
2020-06-02 23:33
ok so back to your problem. I think if you don?t use the `numberType` matcher it should work

matt.fellows
2020-06-02 23:34
```"matchingRules": { "body": { "$.id": { "matchers": [ { "match": "number" } ], "combine": "AND" }, "$.name": { "matchers": [ { "match": "type" } ], "combine": "AND" } } }``` So with those matching rules, the `type` matcher will be :ok_hand: but not the `number` matcher

matt.fellows
2020-06-02 23:35
Hey! So, we?d love to be able to do it but the only way to know that is to know all of the services in advance - thoughts on how to achieve it?

matt.fellows
2020-06-02 23:35
I?ve thought about creating a proxy that can be installed as middleware into common HTTP frameworks, that could sample requests and send to the pact broker. There, we could build a map of the ecosystem and start to show the coverage

matt.fellows
2020-06-02 23:36
Perhaps as a starting point, an API to register the services and known interactions could suffice and then a UI (or manual API call) to load them in

tjones
2020-06-03 00:01
Would love to hear how you get on with an approach to this! I?ve thought about taking an openapi spec and seeing if all response and request types are covered, but it?s hard to do this in the general case

matt.fellows
2020-06-03 00:03
That?s also a good idea for companies that use them. But doesn?t cover other protocols - protobufs, GraphQL, MQ etc.

matt.fellows
2020-06-03 01:06
fixed

bheemreddy181
2020-06-03 01:34
we did this using codecov https://docs.codecov.io/docs/flags by running them separately in CI along with other unit/functional tests and codecov has great features where they show flag level percentage on github and coverage on their UI

sairsule
2020-06-03 02:35
are you suggesting contract json file manually?

matt.fellows
2020-06-03 02:42
Not at all. Just avoid the v3 matchers like numbertype in your test code


tjones
2020-06-03 04:33
I don?t personally use GraphQL, but I have heard people who do use it say they don?t need contract tests because they have a schema. I don?t think this claim is true. My understanding is that GraphQL doesn?t provide any mechanism for verifying whether a schema change has affected any clients.

tjones
2020-06-03 04:37
Generally, you would want to use Pact if you want to be certain that your client implementations can speak to your provider implementation. I don?t believe the GraphQL tooling provides this capability out of the box- at least, not in an easy to drop in way.

tjones
2020-06-03 04:44
@shawn.edge: I agree that?s an odd argument. How often do you have a schema that will never change? I?ve only seen it where people are afraid to change the schema because they don?t know what will break. With regular HTTP+json, I?ve heard both ?We don?t change our API, so we don?t need contract tests? and ?the same team writes the consumer and the provider, so we don?t need contract tests?. I disagree with both statements - Pact gives you the advantage that you *know* the consumer can speak to the provider. And you *know* whether you?ve made breaking changes to your API (not all schema changes are breaking). Pact gives you confidence that the integration points won?t be a source of failure. Like all testing tools, it?s not necessary, but it is a great way to reduce risk.

ale.paciello
2020-06-03 08:13
has joined #general

shawn.edge
2020-06-03 13:15
@tjones: Thanks! This is exactly what we are discussing and I appreciate your comments!

dominicdemierre
2020-06-03 14:02
Yeah, nuget makes it way easier to get around that issue, since you can just store packages somewhere else. If v2 .NET can still read the Node tests' contracts then that eliminates a major hurdle. Thank you!

irldev
2020-06-03 17:47
has joined #general

hoagiex
2020-06-03 22:09
Philosophical question: How to handle external additions to your contract (e.g. required/remapped headers in an API gateway) which affect what a consumers needs to supply/what a provider secretly requires? My current problem: *layout:* Consumer(s) -> AWS API gateway -> Provider *flow:* ? the consumer is required to provide an X-api-key header, with a value that is specific to that consumer ? the AWS API gateway strips the X-api-key header and adds a new header with human readable identification (in this case: X-client-name), which as mandatory in the provider application *Problems:* 1. The consumer generated pact may only be aware of the requirement for the X-api-key header, not the X-client-name header 2. The provider will test for the presence of the X-client-name header, which will not be in the consumer pact 3. The consumer cannot use an actual/real API key in the pacts ; fixing this with provider states and generators would mean that the API key format used in the example value of the pact, could be invalid resulting is a false positive for the consumer end of the pact (a common problem with provider states & generators) Even if I would ignore problem 3 above, I cannot figure out how I would implement the following: ? provider state: ?api key XXXXXXXXX? will be resolved to the consumer name ?whatever?, which sets up some form of client request interceptor (can this be done?) for the HttpTestTarget class, that does the header remapping Any thoughts?

bethskurrie
2020-06-03 22:12
Tricky. Can you test via a proxy function/service that acts like the gateway?

bethskurrie
2020-06-03 22:12
This comes up a lot.

hoagiex
2020-06-03 22:13
you are a genius? I can just spin up a wiremock in proxy mode

hoagiex
2020-06-03 22:13
It?s so simple and clean? I?m ashamed I didn?t figure it out?

bethskurrie
2020-06-03 22:14
It's not our first time at the rodeo ;-)

phil.endsley
2020-06-04 03:51
has joined #general

thomas.koerner
2020-06-04 06:12
has joined #general

anatoli.sorochinskiy
2020-06-04 08:29
has joined #general

dattasai.chunduru
2020-06-04 10:15
Hi , I have a basic query for doing pact consumer testing we have to stub the API in our machine and then start testing it ?

tjones
2020-06-04 10:46
No. Pact will handle the stubs for you.

tjones
2020-06-04 10:47
A Pact consumer test runs a mock server. The mock server asserts that your consumer sends the request that you promised.


dattasai.chunduru
2020-06-04 12:05
so we have to just pass the JSON data what we need and test it directly that's all ?

philipp.mueller-leven
2020-06-04 12:27
has joined #general

philipp.mueller-leven
2020-06-04 12:31
Hi is there any Problem according with the pact-documentation? Currently https://docs.pact.io/ is not reachable.

matt.fellows
2020-06-04 12:40
Shit!

matt.fellows
2020-06-04 12:40
I'm wondering if Gitbook (where our docs are hosted) is down

dom.udall
2020-06-04 12:42
Yeah it looks like it is, getting a CloudFlare 502


matt.fellows
2020-06-04 12:43
When the status page is hosted on the same system that it's monitoring :laughing:

matt.fellows
2020-06-04 12:44
(either that, or they've lost control of DNS which is worse)

elliottmurray
2020-06-04 12:44
cert error seems to be looking for *.http://gitbooks.io

elliottmurray
2020-06-04 12:44
not gitbook

dom.udall
2020-06-04 12:45
Yeah, also seems to be down.

dom.udall
2020-06-04 12:45
Is https://github.com/pact-foundation/pact.io the content repo for the docs site?

elliottmurray
2020-06-04 12:48
lol


dom.udall
2020-06-04 12:49
@philipp.mueller-leven this may help if you're looking for something while the main site is down

matt.fellows
2020-06-04 12:50
Domain registered, but nobody is home

matt.fellows
2020-06-04 12:51
There are NS records (cloudflare) but no DNS records. So, they could be migrating and just haven?t told anybody

matt.fellows
2020-06-04 12:51
but then.. you would have setup your zone in advance.

dom.udall
2020-06-04 12:52
Sounds about right. NS typos can be quite killer. I'm getting the CloudFlare error page every so often still though..

philipp.mueller-leven
2020-06-04 12:53
@dom.udall Thank You :slightly_smiling_face: maybe this is enough for me :-)

matt.fellows
2020-06-04 12:55
looks like they?ve been with cloudflare at least 2 years, so it would be a hell of a mistake at this point

bernardoguerr
2020-06-04 12:56
There's an update on this on @GitBookStatus on Twitter


dom.udall
2020-06-04 12:58
Status site is back up too

matt.fellows
2020-06-04 12:58
lol was looking at the same thing

matt.fellows
2020-06-04 13:00
I?m reluctant to try their fallback method

matt.fellows
2020-06-04 13:01
> Clients using a custom domain to serve their public content can update their CNAME record to the following host in order to re-establish access to their documentation: > http://hosting-fallback.gitbook-staging.com Decision validated:

dom.udall
2020-06-04 13:02
Do the docs setup allow for something like github pages too? Guessing it'd be quite a bit of custom stuff

matt.fellows
2020-06-04 13:03
We were in the process of moving to docusaurus. Beth did some great work a week or so ago

matt.fellows
2020-06-04 13:03
It?s not that we don?t like Gitbook (their authoring is quite nice actually and has matured a lot) but it?s not the ?open a PR? like environment it used to be. And that doesn?t gel with us. It also has some restrictions on what can go in it, obviously


matt.fellows
2020-06-04 13:05
Ah, the domain is on client hold (https://www.icann.org/resources/pages/epp-status-codes-2014-06-16-en#clientHold). So this could take a bit

matt.fellows
2020-06-04 13:06
I need to run, a bit shit for anyone visiting our site, but hopefully it won?t be for too long

matt.fellows
2020-06-04 13:06
thanks for raising!

matt.fellows
2020-06-04 13:07
If anybody is keen to be a community hero and help migrate our docs to docusaurus, I?m positive Beth would happily share the spike!

dom.udall
2020-06-04 13:09
I can probably spare some time if it's not too challenging :smiley:

antonello
2020-06-04 13:38
guys, you probably have noticed already but it seems that the SSL certificate for http://docs.pact.io has expired

bernardoguerr
2020-06-04 13:40
the problem is on gitbook's side (which pact use to host their docs) .

eduardo.bellis-ext
2020-06-04 14:25
has joined #general

eduardo.bellis-ext
2020-06-04 15:29
Hey everyone! i couldn't find the link to log in to the web portal

eduardo.bellis-ext
2020-06-04 15:29
Could someone please send me? I received the credentials but I can't find it

sawan
2020-06-04 16:27
has joined #general

sadeed.bari
2020-06-04 18:15
has joined #general

sadeed.bari
2020-06-04 20:43
Hi all! Was looking into http://PACT.io vs BDD (behavior driven dev)/Cucumber for an API integration project and just looking to get a general opinion if one is better than the other, or advantages of using both of them together. Is there a lot of overlap in doing both? Seems that way from my initial research. Would really appreciate your thoughts. Thanks!

matt.fellows
2020-06-04 22:29
Hi Eduardo, please dm your email address and we'll resend it

matt.fellows
2020-06-04 22:31
Gitbook suffered an outage last night which messed with their DNS (registrar put them into domain lock)

abubics
2020-06-04 23:54
This is a bit more of a philosophical question & answer, but . . . Pact is really about unit testing the interface over the network boundary, so it is probably not super valuable to go all the way with Cucumber-style "natural language" specs. I still phrase all of my unit tests (including Pact tests) as "given, when, then", so I'm in favour of the BDD concept. I just don't push it all the way up to Gherkin syntax for non-devs.

tjones
2020-06-05 00:25
A pact consumer test has a few parts: 1) Defining the expected request and response 2) Asserting that the expected request was sent (the Pact mock service does this. and if successful it returns the expected response) 3) Asserting that the expected response is marshalled into the right object by your code (you do this in the unit test where you trigger pact)

tjones
2020-06-05 00:25
does that help?

matt.fellows
2020-06-05 07:06
New docs are live: https://docs.pact.io/

matt.fellows
2020-06-05 07:07
Thanks to @bethskurrie for the spike that is now the real docs. We have work todo, but that is the first step to getting back to a more open environment


matt.fellows
2020-06-05 07:07
So it turns out Beth did some good work, so much that it was basically done

matt.fellows
2020-06-05 07:07
BUT

matt.fellows
2020-06-05 07:07
It?s ugly and needs work


alex810
2020-06-05 08:01
has joined #general

thomas.fisher
2020-06-05 08:23
has joined #general

slack.pact.io
2020-06-05 11:39
has joined #general

antonello
2020-06-05 13:17
I am missing the search functionality :slightly_smiling_face:

sawan
2020-06-05 13:43
Hi team, super stoked about using Pact. Looking forward to working with the community

mike.geeves
2020-06-05 15:00
:open_mouth: I had not heard of docusaurus. I feel I may be about to make some possibly not the best informed choices over tooling :thinking_face:

dattasai.chunduru
2020-06-05 15:44
Defining the expected request and response- Hi Tim this is where I need help , let us assume there is a API end point like this http://dummy.restapiexample.com/api/v1/employees and I want to write a PACT Consumer driven test for this

dattasai.chunduru
2020-06-05 15:45
Actually I did POC with an API stubbed in my local machine

dattasai.chunduru
2020-06-05 15:45

dattasai.chunduru
2020-06-05 15:45
I am able to generate PACT file for this end point sucessfully

dattasai.chunduru
2020-06-05 15:46
Can you help me how can I proceed with API end point like this http://dummy.restapiexample.com/api/v1/employees

dattasai.chunduru
2020-06-05 16:36
If it is possible can you connect with me for 5 to 10 minutes I can show what I am trying to do Pleasee

dattasai.chunduru
2020-06-05 17:00
Like in POSTMAN if I hit the endpoint https://jsonplaceholder.typicode.com/posts/1 it will give the response. In pact if I have to get the response for same end point(https://jsonplaceholder.typicode.com/posts/1) how can we do. I understood that a Mock PROVIDER will be created . I am not able to understand how this MOCK provider will be created? coz if we have to get the response first we have to hit the API end point how we can do I am having this query in my mind from past few days and not able to proceed further

dattasai.chunduru
2020-06-05 17:01
I have gone through the PACT docs but not able to get it

steven.knopf
2020-06-05 17:34
has joined #general

antonello
2020-06-05 21:36
I?ve had an interesting debate today on whether to include or not specific values for ids and other properties in provider states.

tjones
2020-06-06 03:34
What was the conclusion?

arindam.datta
2020-06-06 05:15
Conclusion please.

arindam.datta
2020-06-06 05:17
Hi, can anyone please help me with a proven workflow of CI-CD for both Provider and Consumer? Just block diagram would do. I am finding this part pretty complex and hard to decide the flow. I know that probably I am asking for too much. But I found members of pact slack channel so helpful which gave me confidence to ask for such a help. This is the last puzzle I need to solve.

felipe
2020-06-06 06:34
We start a docker compose with our application and run the pacts from the gradle plugin

bethskurrie
2020-06-06 06:34
Answered in the #pact-broker channel.

bethskurrie
2020-06-06 06:35
Welcome @sawan. It's a great bunch of people we've got here.

bethskurrie
2020-06-06 06:36
@antonello it'll be back asap. I had it indexed for the netlify domain, and now it needs to be switched to the http://docs.pact.io domain.

bethskurrie
2020-06-06 06:42
If anyone has some free time in these crazy days, and is good with CSS, I'd love some help making the new Pact docs site look a bit better. IMO, it doesn't look anywhere as good as the old gitbook one (even though it is much better suited to us in other ways). PRs happily accepted! Ping me here if you're interested. Here's the repo: https://github.com/pact-foundation/docs.pact.io

antonello
2020-06-06 06:42
We didn?t get to a conclusion... still trying to get to one. We might reach out for opinions.

bethskurrie
2020-06-06 06:43
@antonello search is back now

antonello
2020-06-06 06:43
:clap::skin-tone-2:

bethskurrie
2020-06-06 06:43
Dude - what are you doing awake?

bethskurrie
2020-06-06 06:43
Oh - it's quarter to 8. That's not so bad.

bethskurrie
2020-06-06 06:44
I thought it was the middle of the night.

antonello
2020-06-06 06:44
:sweat_smile:

bethskurrie
2020-06-06 06:44
Oh crap, I need to get dinner on asap!

bethskurrie
2020-06-06 06:47
My feel is, if you can use matchers to avoid it, do. The more specific, the more brittle.

bethskurrie
2020-06-06 06:48
If you can't think of another way to do it without specific IDs, then do it with specific IDs. It's still better than an integration test. The Beth Pragmatic Approach.

tjones
2020-06-06 08:56
I agree with Beth. Sometimes you have to use specific values (eg, for `/users/someId`, you might have to have the state ?A user with id ?someId? exists?), but most of the time you don?t need to be overly specific, since matchers will let you generalise your test data. Pact is more about verifying the shape of the response in particular server states, rather than the specific response.

antonello
2020-06-06 09:05
This is in line with my thinking. The debate stems from a new use case for us. We have a new provider that has decided to run provider tests against a real data store, albeit a test one, and therefore the ids of the entities need to match, similarly to what @tjones has mentioned.

antonello
2020-06-06 09:11
A different use case is when it comes to our java providers that mock everything under the controller. Whilst ids that are part of the uris don?t need to match as otherwise requests would fail, the situation is different when it comes to query string parameters. If the mocks are set up loosely and you don?t set up them up strictly using the actual values of the query parameters, effectively you?re not testing that part of the contract.

antonello
2020-06-06 09:12
This is unless the query parameters are required by the controller, but in most cases they?re not.

tjones
2020-06-06 09:12
Philosophically, Pact is a consumer-driven contract testing tool. So, if a provider wanted to use a real data store, it?s probably up to them to ensure that the data in the store matches the expectations of the contract. Using matchers appropriately might mean that approach doesn?t hurt you, but I don?t really know.

tjones
2020-06-06 09:14
On your second point, I usually mock the boundaries, since you get a bit of functional testing for free. Just because contract tests are not functional tests doesn?t mean they can?t have functional converage.

antonello
2020-06-06 09:14
Even in the case of query parameters values having to match, I?m not sure if having them or not in the state will make much of a difference, except for making them explicit. You will still end up with some brittleness due to using hardcoded values.

antonello
2020-06-06 09:15
When you say boundaries, are you referring to over the network boundaries or data stores?

tjones
2020-06-06 09:17
I mean mocking at the repository later, which would be whatever contacts the network or the store. Hard to explain without a diagram or shared language. I?m afraid I have to head out - but I can share some examples later

antonello
2020-06-06 09:17
No I get it!

tjones
2020-06-06 09:18
Mocking the module(s) of your service responsible for the boundary, not mocking the other side of the boundary

antonello
2020-06-06 09:19
Thank you! I am thinking that even when mocking repos, mocking them loosely might still lead to non-testing of query parameters.

tjones
2020-06-06 09:20
I think it depends, but yes, you have to be careful.

antonello
2020-06-06 09:21
And if you need/want to be careful, you might end up having to use the values that hardcoded are in the pact

bethskurrie
2020-06-06 09:49
Stubbing business logic seems like it could easily result in false positives. I personally don't do it - how have you found it @antonello? I remember @tjones had a bad experience with it a year or so ago.

antonello
2020-06-06 09:57
Some of our providers are so massive and have so many dependencies that not mocking the business logic would make it very hard to write provider tests. For newer, smaller, leaner services it might make sense to mock deeper.

bethskurrie
2020-06-06 09:57
Yeah, fair enough.

antonello
2020-06-06 09:59
What?s happening though is that the first provider tests were written for the larger, less testable services and since then everyone has been following the same approach even on the newer ones. This conversation has helped me realised that, perhaps, we should push harder to pursue a different approach in each case.

bethskurrie
2020-06-06 10:01
Sounds logical.

antonello
2020-06-06 10:05
Now that means... a lot of tests to re-write....

antonello
2020-06-06 10:06
But at some point you?ll have to mock something, even if it?s clients or repositories. In which case how you set up those mocks will matter in the context of query parameters, unless I?m missing something obvious.

antonello
2020-06-06 10:07
Even just reusing the example scenario here https://docs.pact.io/provider/using_provider_states_effectively

bethskurrie
2020-06-06 10:08
Yup - every time you mock something, you then have to write another test to make sure you've mocked it correctly.

bethskurrie
2020-06-06 10:08
Maybe another Pact test, maybe a manual "contract" test.

antonello
2020-06-06 10:08
If you don?t mock the relevant repo method(s) using the value ?Mary? - you?re not testing the filter

bethskurrie
2020-06-06 10:09
I've got a slide somewhere in one of my decks that has an image of a chain made of links, where each link is a contract. Miss one, and you've lost all your confidence in the strength of the chain.

tjones
2020-06-06 10:09
@bethskurrie We should put something like that chain in the docs

tjones
2020-06-06 10:10
I also think there?s something in the ?not functional tests, but functional coverage?

bethskurrie
2020-06-06 10:10
Which is why by default I tend not to mock stuff inside the service unless there's a good reason for it - because then you really should write another test to validate that mock... and I'm lazy :wink:

bethskurrie
2020-06-06 10:11
Yes, we definitely need to expand the section on "where and how and what to mock"

tjones
2020-06-06 10:11
@antonello I ended up with the current view on mocking because of a case where the contract tests passed, but the provider was incapable of generating one or two of the responses when the real domain layer was called by the controller

bethskurrie
2020-06-06 10:11
There was more in the original ruby docs I think, that got lost in the migration.

bethskurrie
2020-06-06 10:11
I've got material in the Advanced Pact workshop I've been giving recently that needs to go into the guides section.

antonello
2020-06-06 10:19
Does what I?m saying make sense though? Pact interaction is for `GET /appointments?type=massage` Provider test mocks `when(repo).find(filterCriteria).thenReturn(anAppointmentList)` (repo could even be a BLL service) If `filterCriteria` is `any()` , the `type` parameter is ignored. Whilst if `filterCriteria` is set up to specify `type=massage` , then you are truly testing the query parameter side of the contract.

matt.fellows
2020-06-06 11:29
What did you choose?

mike.geeves
2020-06-06 11:36
No choices made, we are just starting to look around. Currently we have a dokuwiki which is..messy and a collection of sphinx docs which I quite like. I'm just wondering if there's something called docusaurus, if there's any point looking elsewhere :thinking_face: :joy:

jaycloudtechie
2020-06-06 18:05
has joined #general

bethskurrie
2020-06-06 21:07
Yes. I'd make it match exactly otherwise you're not actually checking the request is right.

antonello
2020-06-06 22:06
So that involves a bit of hard coding, whether you include the values in the provider state or not.

bethskurrie
2020-06-06 22:07
Yup.

bethskurrie
2020-06-06 22:08
I think it's the lesser of the two evils in this situation.

bethskurrie
2020-06-06 22:10
One day I'll get around to writing that blog post, "every decision you make in IT is about trade-offs" :joy:

antonello
2020-06-06 22:19
:joy:

antonello
2020-06-06 22:21
If only all trade-offs were understood and not just left to chance!! :zany_face:

bethskurrie
2020-06-06 22:30
:100:

tjones
2020-06-07 12:50
@antonello I think tests (in general, not just contract tests) should fail if and only if the interface or the behaviour change. If filterCriteria is `any`, then that statement is not true. I think the best-practice mock would have the expected filter criteria there.

antonello
2020-06-07 13:46
@tjones We?re all on the same page! :-)

antonello
2020-06-07 13:48
Unfortunately a lot of tests have been already written using `any`

raghulraj
2020-06-07 20:32
has joined #general

kalyan.chakri24
2020-06-08 05:01
has joined #general

r.iglesias
2020-06-08 09:33
has joined #general

2020-06-08 10:06
A new post has been created in *Feature Requests*

jinrui01
2020-06-08 12:14
has joined #general

sonney.patel
2020-06-08 12:23
has joined #general

sonney.patel
2020-06-08 12:30
Hi there, I'm getting desperate so i joined this slack channel. Essentially I'm trying to implement pact. I have successfully created a java consumer test and published it to the pact broker. However when i attempt to verify the pact, I seem to be getting statuses of 401 and not 200. I am struggling to workout the source of this discrepancy I created test endpoints from the controller and had no problems making calls to them through a default WebTestClient that i configured in unit test. Has anyone else had an experience like this before? We are using Spring Boot framework

matt.fellows
2020-06-08 12:31
Might want to ask in #pact-jvm-help

sonney.patel
2020-06-08 12:31
cheers man

matt.fellows
2020-06-08 12:32
But, 401 indicates no or invalid authorization / credentials are being passed in verification

sonney.patel
2020-06-08 12:32
I'm trying to work out what authentication it is I am missing and where

matt.fellows
2020-06-08 12:32
how are you authenticating? Bearer token? If the contract has a token in it, it?s probably old

matt.fellows
2020-06-08 12:32
does the provider API need auth?

sonney.patel
2020-06-08 12:32
our consumer talks to the provider through basic authentication

sonney.patel
2020-06-08 12:33
yeah the provider does need basic auth

sonney.patel
2020-06-08 12:34
but im not sure where that is meant to be configured

rafael.espillaque
2020-06-08 12:50
has joined #general

rafael.espillaque
2020-06-08 12:59
Hi, I?m struggling to find an equivalent table to this one https://docs.pact.io/consumer/contract_tests_not_functional_tests#which-test-is-responsible-for-what but focused on asynchronous messages instead of Request/Response. Can anyone help me with that?

christopher.kies
2020-06-08 14:11
has joined #general

v.scherr
2020-06-08 15:12
has joined #general

karol.szymanowski
2020-06-08 15:24
has joined #general

robert.zimmermann
2020-06-08 16:13
has joined #general

arindam.datta
2020-06-08 17:17
Question: Can't a provider be deployed until consumer pact is published? The provider has a verification test, but the consumer CI pipeline hasn't yet published the pact. The provider should get deployed right?

mike.geeves
2020-06-08 17:45
No free time really :) and no CSS skills, but if you need another proof read etc, happy to help

uglyog
2020-06-08 23:01
You have a few options, but a request filter is probably the best option.

matt.fellows
2020-06-08 23:30
Are you asking if it?s safe to deploy a provider if it has no consumers? And further, does Pact allow this case? The answer is ?yes? and ?yes?

bethskurrie
2020-06-08 23:31
How can the provider do a verification of a pact that doesn't exist @arindam.datta?

bethskurrie
2020-06-08 23:38
It's the same principle @rafael.espillaque. Test enough of the code that makes the message to give you confidence that the message that is expected can be created.

bethskurrie
2020-06-08 23:41
On the consumer side, test enough to make sure that you're handling the message correctly. Focus on the idea, "if this message wasn't as expected, would my test expose that?"

tjones
2020-06-09 00:48
That has been my experience too. I think it?s more common to inappropriately use `any` where the boundaries are mocked at a layer where you?d have to have several `when(thing).... when(otherThing)` statements, and people get lazy.

arindam.datta
2020-06-09 05:45
Exactly that's my point. There is no pact yet there (on broker). The provider team has verified a locally communicated pact. So, the provider has the pact verification test in place. CI pipeline tries to get the pact from broker, but doesn't find any and the verification job fails. While there is no pact on broker, hence no verification. Then why fail? P.S: Library "pact-net".

rafael.espillaque
2020-06-09 08:31
thanks that was useful

bethskurrie
2020-06-09 08:32
Good. I was in the process of adding a message section to that page, but didn't get back to finish it.

jeanlucc
2020-06-09 09:35
has joined #general

xuanzhaopeng
2020-06-09 10:31
has joined #general

cristian.schez
2020-06-09 11:17
has joined #general

slack1274
2020-06-09 11:49
has joined #general

wvdbraak
2020-06-09 13:11
has joined #general

tjones
2020-06-10 00:59
This is a good discussion, though - I think the outcomes from it would make a great best-practices page in the docs

tjones
2020-06-10 02:10
How are you specifying the pact from the broker? If there are no pacts for that provider, I don?t think it should be failing

shero86
2020-06-10 09:22
hi all, is there any chance to load all pacts from pact broker to stub server? :slightly_smiling_face: I want to run `pact-stub-server` and load all interactions from pact-broker. Is that possible? thanks

bethskurrie
2020-06-10 09:29
Which implentation @shero86?

shero86
2020-06-10 09:32
any will be glad :slightly_smiling_face: I?m using now command line pact-stub-server , and passing URI to local folder with pacts, and also tried to do the same to interaction from pact broker. It worked, but only for one pair of `ConmsumerA ? ProviderA` . But I want to load the rest pairs of services, if it?s possible @bethskurrie

bethskurrie
2020-06-10 09:33
You can't load all of the pacts into one service at the same time.

shero86
2020-06-10 09:33
got it, so I need to use local folder with pacts, right?

bethskurrie
2020-06-10 09:33
You could write a script to pull them all downs and merge them into one file if you really wanted.

bethskurrie
2020-06-10 09:34
No... It's the same locally. It only allows you to load one pact. You can do it from a local file, or a remote URL.

shero86
2020-06-10 09:35
ah, I see. Thanks for this info, will try to play around to merge all pacts into one file :slightly_smiling_face: thanks!

bethskurrie
2020-06-10 09:36
Though, I could be talking shit. If you're using the rust one, ignore what I'm saying.

bethskurrie
2020-06-10 09:36
I only know about the Ruby one.

shero86
2020-06-10 09:38
:smile: I?m using ruby one, I think. that one from standalone pact.

wesleythomaswilliams
2020-06-10 10:10
@arindam.datta so you've been given a pact file (that has yet to be hosted on a broker) and built a provider test to verify it, which is running in your pipeline and failing because of the missing pact. Did I understand that correctly? If that's the case, disable the provider test until the consumer is publishing the pact to the broker.

arindam.datta
2020-06-10 10:21
Hi @wesleythomaswilliams, yes that's exactly the scenario at my end. From the reply of @tjones , the verification shouldn't have failed when pact is not available. I wanted to verify from experts what is expected fundamentally: Should the provider test be disabled until pact is published to the broker? OR Should the provider test *NOT fail,* since there is no pact and hence nothing to verify and the .Net library 'pact-net' has a bug which is causing it to fail?

bethskurrie
2020-06-10 10:28
Well, it's not normal to hook up a verification until there is actually a pact to verify. So, the first one.

bethskurrie
2020-06-10 10:28
Cool. Do listen to me then.

slack1274
2020-06-10 11:37
hello i am a beginner with pact and am getting the below error. can someone tell me what's going on and what to do next. "java.lang.IllegalStateException: transformedJson [" provider "] must not be null" thank you in advance

matt.fellows
2020-06-10 11:41
Can you please ask in #pact-jvm-help. Also, we may need to see the test code to help diagnose

slack1274
2020-06-10 11:41
tx you, i will that

sjuli.chen
2020-06-10 11:53
Kijk aan, ik zie een aantal testcollegas :joy:

sjuli.chen
2020-06-10 11:54
Dit is Sjuli

sreeharimohan11
2020-06-10 12:29
has joined #general

sreeharimohan11
2020-06-10 12:42
Hey everyone, I understand pacts must be generated from integration tests within the codebase but are there any tools which provide a user interface to essentially create integration tests, which when run, generate the pact file. All integration tests should be centrally available and tagged to specific commit versions of the service themselves. The only difference from traditional integration tests is that they have the actual code abstracted out on a rich UI. This would help teams which have huge codebases and tons of integration tests which have to be altered in order to incorporate Pact.

wesleythomaswilliams
2020-06-10 13:09
Hi @sreeharimohan11, Pacts aren't generated from running integration tests. The tests that generate Pacts are unit tests. In order to write those, you're going to need to write them in code and usually in the same language as the actual service your testing is written in.

sreeharimohan11
2020-06-10 13:19
@wesleythomaswilliams Ideally, unit tests evaluate the internal functions of a service while integration tests evaluate external dependencies and how the service reacts when the external dependency reacts differently. Both tests can be written in the same language as the actual service code. This is why I mentioned pacts being generated using integration tests but yes, they are executed using the unit testing framework

jacek.okrojek
2020-06-10 13:25
Hi, I am looking for someone from Poland who has experience in Pact-Java to help us introduce Pact to our organization, anyone who can share experience will be very helpful

pavel.kirpichyov
2020-06-10 13:30
has joined #general

tjones
2020-06-10 13:39
@sreeharimohan11 I?m not sure I understand what you?re asking for. If you?re asking for a user interface to construct Pact consumer tests, then I don?t think one exists. Most tests follow a fairly straightforward formula: * Describe expected request * Describe expected response * Trigger request within your code <This is where Pact mocks your provider, and returns the expected response if your request was correct> * Assert that response from your code was the unmarshalled object that you expected

tjones
2020-06-10 13:40
^ The DSLs in the different Pact frameworks generally follow this pattern. It would be possible to make a UI that generates test code in different DSLs, but I think most developers would prefer to use the DSL directly.

sreeharimohan11
2020-06-10 14:03
Thanks for the quick response @tjones If the DSLs in the different frameworks follow a similar pattern, will a test code generating UI improve adoption within an organization. Once some code has been generated for say, a module, developer could then invest time in understanding the DSL and modifying the code. Some really 'busy' developers could even continue using the UI to add/edit/remove tests. Another advantage is also the ease with which you could possibly switch from one language to another if all frameworks followed a standard pattern. Does it make sense to create something like this?

matt.fellows
2020-06-10 14:43
https://blog.gitbook.com/tech/post-mortems/06-20-gitbook-domains-blocked-by-registrar for those interested in why our docs went down last week. A good read and a sad indightment on the hypocrisy of Google domains

pact.io971
2020-06-11 01:11
has joined #general

nanil4568
2020-06-11 03:19
has joined #general

tjones
2020-06-11 04:42
My gut is that most developers would prefer to edit the code directly than through a UI- however, if you think it?s useful then you may not be alone. You could put the feature request on https://pact.canny.io/ to see if others would find it useful. Note that Pact isn?t about specifying the entire API, it?s about specifying only the parts the consumer uses. So, switching an existing pact between different languages isn?t a common use case (how often do you replace a consumer with an identical implementation in a different language?).

bradley.smith
2020-06-11 05:14
has joined #general

sreeharimohan11
2020-06-11 07:31
Yes, I agree that advantage was far fetched. To give you some more context on the problem at hand, I manage the productivity team at my workplace and am trying to evaluate the ROI if we move to using consumer driven contract testing. The said ROI now depends on how fast developers can get onto this platform and configuring integration tests via a UI seems a much faster approach than writing those integration tests. What do you think?

tillmannheigel
2020-06-11 13:41
has joined #general

satya.quote_pact
2020-06-11 13:43
has joined #general

satya_srinivas_volla
2020-06-11 17:30
has joined #general

bruce.laird
2020-06-11 17:50
has joined #general

bruce.laird
2020-06-11 17:55
Hi I am trying to get provider tests working in .NET that use auth tokens, I have been trying to follow the example provided here without any luck. https://github.com/pact-foundation/pact-net/blob/master/Samples/EventApi/Provider.Api.Web.Tests/AuthorizationTokenReplacementMiddleware.cs anyone have experience sorting this kind of thing out?

maxurbanija.globant
2020-06-11 19:57
has joined #general

maxurbanija.globant
2020-06-11 20:10
@here Hello! I need some help let's assume I have 3 artifacts. ArtA -> Artb -> ArtC When ArtB downloads the pact that ArtA uploaded to the broker, I need to mock ArtC. Should I pact mock server for that?

max.forasteiro
2020-06-11 20:48
has joined #general

zbintliff
2020-06-11 21:02
has joined #general

tjones
2020-06-11 23:57
As a developer, writing tests using a UI sounds much slower to me. We already have productivity tooling around writing code, and it?s the environment we?re most used to working in. But, I don?t speak for all developers, perhaps your team have a different view.

tjones
2020-06-12 00:01
We?ve put a fair bit of work into making the various pact DSLs easy to use, so writing tests shouldn?t be a burden. If this isn?t the experience of your developers, I?d love to hear about it. Perhaps there are things that can be improved.

matt.fellows
2020-06-12 01:15
Might want to ask in #pact-net

matt.fellows
2020-06-12 01:15
I?d read https://docs.pact.io/provider/readme#stub-calls-to-downstream-systems and the gist associated with it. I think it answers your question

arindam.datta
2020-06-12 06:28
Well, in my opinion (I might be wrong as I am very new to this area), Provider verification test (libraries should implement this) should not fail if there is no pact available yet. This will even more promote the independence of deployment of both Provider and Consumer. And only when the pact is available, the deployment should be driven by the pact agreement between both Provider and Consumer (as already happening as per workflow).

bethskurrie
2020-06-12 07:31
Why hook it up unless there is a pact though? Am I missing something here? Are you building a generic pipeline that's used for all services?

sandhyareddy019
2020-06-12 07:34
has joined #general

rafael.espillaque
2020-06-12 08:40
I can read this in that gist: > A pact is best created using unit tests for the client class. Ideally, you could have a CClient in your B codebase, and you would write your Pact tests using that CClient class. I don?t fully understand it, could anyone expand on that please?

matt.fellows
2020-06-12 10:52
In that Gist, it is assumed that in an `A` -> `B` -> `C` set of interactions that you should stub out `C` when doing a provider verification of `B`. BUT, you should create a pact between `B` and `C`.

matt.fellows
2020-06-12 10:53
so when testing `B`. You either a) mock out of the piece of code (CClient) that talks to C or b) let CClient make an http call, but send it to a mock server

matt.fellows
2020-06-12 10:54
whichever approach you take, the idea is to avoid having real systems talking to real systems to do these test, because that gets us back into integrated, e2e testing which we want to avoid

rafael.espillaque
2020-06-12 10:54
ah! it?s only that? I got confused

rafael.espillaque
2020-06-12 10:54
I get it know, Thanks Matt

kaio.silveira
2020-06-12 10:55
has joined #general

matt.fellows
2020-06-12 10:58
no probs

sairsule
2020-06-12 13:24
In api tests, if provider api is /users{id} and consumer is calling /user/{id} this gets caught by pact test. Similarly in message-contracts if provider is writing to topic:Test1 and consumer is listening on topic:Test2, is it caught by Pact?

sreeharimohan11
2020-06-12 13:50
I'm really grateful to you guys to have put so much effort into DSLs @tjones . Thanks for that. One of my team's responsibilities include ensuring all developer teams are not spending too much time during the integration tests stage. Consumer driven contracts tests are the way ahead but requiring every developer team to write integration tests for all the services they own (we have a total of 400+ microservices) could become time consuming and there could also be a backlash from developers. Providing them with a UI which automatically writes these integration tests would actually prove more faster and easier to get a buy-in from teams. I'm split as of now as I would love to require everyone to use the DSL for each of their languages (you guys cover 100% of the languages we use) but would also not want this effort to slow down our current development.

wesleythomaswilliams
2020-06-12 14:24
Ah, 400+ micrsoservices, now I get why you were so keen to find a quicker/easier solution :smile:

wesleythomaswilliams
2020-06-12 14:25
I guess the trick is to convince them that alternative integration tests would be far far more time consuming to write, run and maintain.

max.forasteiro
2020-06-12 14:26
Hi all, just open a issue (https://github.com/pact-foundation/pact-ruby/issues/215) regarding the message support to ruby :slightly_smiling_face:

sreeharimohan11
2020-06-12 14:28
They actually already have alternate integration tests which are like all integration tests - flaky, unreliable, outdated and borderline disturbing. My team needs to find a way to convert them into pacts without having to write them out again :thinking_face:

kuzhca
2020-06-12 16:52
has joined #general

krisdinesh
2020-06-13 04:09
has joined #general

krisdinesh
2020-06-13 13:26
@here Is there any video tutorial for pact so that beginners like can learn?


antonello
2020-06-13 14:08
Pact?s website, though, is full of good resources, from documentation to tutorials.

krisdinesh
2020-06-13 15:21
:pray:

evanrosal
2020-06-14 13:59
Is anyone familiar with AWS EventBridge and its Schema Registry? If yes, how did you embed contract tests into this.

matt.fellows
2020-06-14 14:00
I?ve looked at it recently, and hopefully a colleague will also - I?m keen to see how it might work together. More broadly, registries like Kafka schema registry and Uber?s protobuf registry are of interest to me and the ecosystem - would be interesting to see how they should all play together

bethskurrie
2020-06-14 23:46
The ones that nobody ever seems to read :laughing: :cry:

psychopomp3x
2020-06-15 01:18
Does anybody have an example azure-pipelines.yml for an azure devops ci/cd pipeline with pact? Trying to figure out how hard a pact proof of concept for my team in that ci/cd system would be.

srikanth.chikkala
2020-06-15 04:01
has joined #general

josh.mccure
2020-06-15 04:18
will `can-i-deploy` look for an env variable so we don't have to pass the key in CI?

bethskurrie
2020-06-15 04:18
yes

bethskurrie
2020-06-15 04:18
All the CLI commands will.

josh.mccure
2020-06-15 04:18
Okay cool - maybe I just missed what it's called sorry

bethskurrie
2020-06-15 04:19
PACT_BROKER_BASE_URL, PACT_BROKER_TOKEN, PACT_BROKER_USERNAME, PACT_BROKER_PASSWORD, PACT_BROKER_PUBLISH_VERIFICATION_RESULTS can each be set via env vars.

josh.mccure
2020-06-15 04:19
Thanks Beth :slightly_smiling_face:

bethskurrie
2020-06-15 04:19
if you run `pact-broker help can-i-deploy` you should see it in the output

bethskurrie
2020-06-15 04:20
```The environment variables PACT_BROKER_BASE_URL, PACT_BROKER_BASE_URL_USERNAME and PACT_BROKER_BASE_URL_PASSWORD may be used instead of their respective command line options.```

a.smith
2020-06-15 05:33
@psychopomp3x what?s your runtime environment? We?re using Pact with Azure Functions. I?d be happy to share our pipeline structure, but there?s a lot of ?noise? for Functions vs. ?signal? for Pact.

sandhyareddy019
2020-06-15 09:39
Hi,how to insert records in object/tab created in developers account in salesforce?

bethskurrie
2020-06-15 09:40
Hi @sandhyarani.gabbi sounds like a question for a Salesforce channel.

bethskurrie
2020-06-15 09:40
How does it relate to Pact?

sandhyareddy019
2020-06-15 09:41
instead of creating providers i want to use salesforce and if any one can help?

bethskurrie
2020-06-15 09:42
Are you sure Pact is the right tool for this problem?


sandhyareddy019
2020-06-15 09:43
ok thank you

psychopomp3x
2020-06-15 14:24
We're using angular UI with .net core http://asp.net webapi microservices using an NServiceBus Esb. They are deployed to on prem services. Hopefully we will be moving to openshift next year.

linda.anthu
2020-06-15 14:46
has joined #general


rafael.espillaque
2020-06-15 16:08
Hi all, I asked a question in SO. I felt it was a better place than slack to provide some context but I?d like your help. https://stackoverflow.com/questions/62392004/any-problems-when-using-pact-for-async-messages-that-are-commands-or-queries-ins thanks a lot!

linda.anthu
2020-06-15 17:02
Hi all, I can test this response body with Matchers? {data: "123", result: [ {"id":"1", "competition": {"name": "teste1", "place": "en"}}, {"id":"2", "sport":{"name":"football", "type": "international"}} ]}

linda.anthu
2020-06-15 17:04
In this case the attribute "result" is an array of objects and each object can be "competition" or "sport" as attribute, it's possible?

psvieira.ti
2020-06-15 19:00
has joined #general

matt.fellows
2020-06-15 22:39
Thanks Ivan D for answering (if you?re in here!)

matt.fellows
2020-06-15 22:40
Also, thanks for asking there Rafa. Because we use the free slack, old answers disappear. SO Q&A live on forever, and are Googleable

michaelphi
2020-06-16 02:36
has joined #general

nicholas.pleschko
2020-06-16 08:50
has joined #general

garry.jeromson
2020-06-16 08:51
has joined #general

nicholas.pleschko
2020-06-16 09:00
Hi guys. We are using the terraform provider for pactflow (https://github.com/pactflow/terraform) to define webhooks. Is there a way to define the webhook consumers (or providers) to be ?ALL? as it is possible in the pactflow UI? We tried just using the string ?ALL? in the `webhook_consumer` name property but that didn?t work.

matt.fellows
2020-06-16 09:01
Thanks I saw the issue. I'll add it tonight

nicholas.pleschko
2020-06-16 09:03
Oh nice thanks!


nicholas.pleschko
2020-06-16 10:58
thanks a lot!

matt.fellows
2020-06-16 10:58
No probs. Let us know how you get on with it!

nicholas.pleschko
2020-06-16 12:23
Hmm ? we are hitting ?unauthorized? errors when running our CICD pipeline. Is there any kind of rate limit on pactflow?

dalton.silveira
2020-06-16 14:35
has joined #general

dattasai.chunduru
2020-06-16 17:37
Hi I am using this docker-compose.yml file for PACTS publish and verify

dattasai.chunduru
2020-06-16 17:39
I have 2 Projects seperately created for two different GET requests( one GET request is for locally stubbed API ) and another one is for externally available API. When I am trying to do PACT verification from Provider side it is valiadting with same Provider Json file again and again

dattasai.chunduru
2020-06-16 17:40
I have created 4 Maven Projects( 2 each seperately for consumer and provider validations). I am able to publish the PACT files successfully but when verifying it is checking for same PACT file in both the cases can anyone please help me on this

dattasai.chunduru
2020-06-16 17:41
Please let me know if you need the code snippets (or) POM.xml's

dattasai.chunduru
2020-06-16 17:42
I am using JAVA

gstorck
2020-06-16 17:51
has joined #general

gstorck
2020-06-16 17:55
Hey guys! I'm using pactflow and doing a poc for my company, but I can't find a way to use wip pacts. The blog post says I'd find help here. Thaanks!

dattasai.chunduru
2020-06-16 18:31
It is always verifying for this Json file

eric.jones
2020-06-16 18:59
Can someone give me clear guidance on Remote mockservers/Providers in the Pact Rule. Are they possible in the JVM (Java) version of Pact? Or do they have to be localhost? If not localhost, which provider class should I use to set the mockserver? I've been getting NW socket and bind errors. Thanks!

phil.endsley
2020-06-16 19:00
I can give it a shot. The error above is saying it can't find anything in Pact Broker for the provider called 'ProviderJson'. I'm not even sure it's verifying anything When you go to pact broker, do you see the pacts for your consumers there? You should see a table with at least one row that lists your consumer name and ProviderJson as the provider.

matt.fellows
2020-06-16 22:01
No rate limits. We'll check the logs and DM you offline with what we see

matt.fellows
2020-06-16 22:01
There is a WAF so if you're hammering us it may detect some form of foul play

naeem95m
2020-06-17 00:34
has joined #general

matt.fellows
2020-06-17 00:57
:wave:

matt.fellows
2020-06-17 00:58
So WIP/Pending pacts are enabled on your account. What language are you using?

matt.fellows
2020-06-17 00:58
Might be worth asking in #pact-jvm-help

matt.fellows
2020-06-17 00:58
May I ask about the use case - why do you want a ?remote? mock server?

matt.fellows
2020-06-17 00:59
I think Phil is on point here

matt.fellows
2020-06-17 01:00
if you?re using a broker, you need to first publish to the broker

matt.fellows
2020-06-17 01:00
the provider tests then pull down related contracts for the given provider

matt.fellows
2020-06-17 01:00
Did you end up completing the Pact JVM workshop?

bethskurrie
2020-06-17 02:22
Hi all. There's been a lot of confusion about the difference between pending pacts and WIP pacts. I'd like to see if I can find a more helpful name for the configuration option "includeWipPactsSince". If you've read the blog posts and have an idea of what they both mean, could you fill in a vote below?

2020-06-17 02:22
@bethskurrie has a poll for you!

nicholas.pleschko
2020-06-17 07:13
Ok cool thanks.

anddreiu
2020-06-17 12:04
Hi. I would like to open a discussion with you guys, maybe there are some of you who were in the same situation with me. Please let me know if I should ask this in a different channel. Currently we are writing PACT tests and we have the following scenario: there are multiple consumers for a single provider. The special thing on our side is the fact that the provider is an old legacy system, a monolith. But we have managed to use Pact, everything is fine with the tests. The particularity is that we have several test environments on the provider side, so we need to run the Provider tests on 30 functional test environments (each owned by a different team) in order to be sure that each team does not affect the consumers integrated with the big provider. All works fine, we can run the tests on all these test environments, but currently we are not publishing the results on Pact Broker for all those runs, just from a single test environment. I didn't try, but I imagine there will be a chaos on Pact Broker if results are published from 30 different runs each day. I would like to ask you how do you see this scenario? Or if there was anybody in this situation how did you handle it? Or if there is something that we can do. Because it would be nice to have all the results published, so that we can have the full pact flow in place. Thanks.

matt.fellows
2020-06-17 12:33
Sounds like you work at a bank :stuck_out_tongue:. Are you just not publishing with impunity for fear of overloading the broker or is it more of a technical thing where you aren?t sure how to to configure each of those functional test environments with tags/versions appropriately?

matt.fellows
2020-06-17 12:33
If the former, I wouldn?t make that a worry. There are ways to reduce the load/volume if it becomes a problem

anddreiu
2020-06-17 12:49
I imagine that there will be lots of lines in the Broker and the consumer won't understand what happens. It may be hard to follow if the provider tests are green on all those environments or if there were problems on some of them

anddreiu
2020-06-17 12:54
In terms of technical things, I was able to configure the provider tests to publish the version in broker, so that I can clearly see the test environment name and the current build version from that one.

matt.fellows
2020-06-17 13:06
Are each of those environments just so teams can build features in parallel on the same monolith? Or is it more about having lots of places to scale testing activities?

matt.fellows
2020-06-17 13:07
I?d also optimise for CI/CD in this case. The matrix would allow you to filter by tag/version to reduce the noise

anddreiu
2020-06-17 13:07
the first version, teams are developing things in parallel

matt.fellows
2020-06-17 13:07
Not having it controlled by pact sounds like a human error waiting to happen (i.e. false positives of ?safe to go?)

anddreiu
2020-06-17 13:08
so each test environment will have a different version

matt.fellows
2020-06-17 13:08
Another approach, although not ideal ,is to treat each team as a separate ?provider?

matt.fellows
2020-06-17 13:08
I?d say tags are probably also a better way to go, because you can encode human readable things into them more easily

anddreiu
2020-06-17 13:09
yeah, I wouldn't split it in more providers, I think it would add more complexity

anddreiu
2020-06-17 13:10
do you have something specific in mind when you say tags? we are not using the tags very well until now. I mean, we just tag prod and master versions

matt.fellows
2020-06-17 13:22
I?d need to think about your case a bit more, because it is a little unusual. Ordinarily, you would use tags like ?feature-a? or ?feature-b? to denote the features being worked on in those projects and what the consumers are currently expecting of them

matt.fellows
2020-06-17 13:22
_as a side note: https://docs.pactflow.io/docs/workshops/ci-cd/ might be useful reading material_

matt.fellows
2020-06-17 13:25
> The golden rule for tagging is: Tag with the branch when you publish pacts/results, tag with the environment when you deploy. from Beth, the other day

anddreiu
2020-06-17 13:25
yep, I'm sure it's unusual and that's why I wanted to open the discussion here. So if you'll have anything else in mind, please ping me with a message or here in the thread. Thanks Matt, much appreciated

matt.fellows
2020-06-17 13:26
No worries. I?ll have a think tomorrow when I?m properly awake and caffeinated :P

anddreiu
2020-06-17 13:26
cool :smile:

phil.endsley
2020-06-17 14:00
@anddreiu I'm pretty sure we're doing the same thing you are, just on a smaller scale (3 teams instead of 30 :slightly_smiling_face: ) Here's what we're doing 1. Tag every pact with the consumer branch. Tag every verification with the provider branch 2. Providers have Pending Pacts enabled 3. Providers will also be using WIP Pacts once it's available (we use Java for our providers. It may already be available for the language you use). 4. Until they're available, our providers verify against latest main branch, latest prod, and latest consumer feature tag. 5. Use can-i-deploy to act as a "can I merge?". This makes sure you're not breaking something when you merge because you don't have the latest changes from the main branch. (This is talked about in the CI/CD Workshop) This setup makes sure that each provider feature branch is compatible with: ? The latest version of your main branch ? The latest version of prod ? The latest version of the consumer feature tag they are developing against I'll second the CI/CD workshop linked above. Great resource that outlines this process.

anddreiu
2020-06-17 14:05
Thanks Phil! I will do the workshop, I'm sure it will help me. So the key thing is tagging. The consumers are now in the middle of the process to use tagging on the consumer side and to rely on can-i-deploy. So maybe after that, we can use these steps. (we are using also Java on the provider side). Thanks again for your notes!

gstorck
2020-06-17 14:39
js on the consumer, java on the provider

brendan.j.donegan
2020-06-17 17:00
Speaking from experience I doubt it should be an issue

zhukeven86
2020-06-17 21:33
has joined #general

aditi.puri
2020-06-18 05:27
has joined #general

nmsuryavanshi
2020-06-18 06:20
has joined #general

dattasai.chunduru
2020-06-18 10:42
@matt.fellows I have gone through and got one working GITHUB example and I condtructed a basic framework accordingly

dattasai.chunduru
2020-06-18 10:44
Actually I am having a GET Request and created 2 different Maven projects for Consumer side and Provider side . In Provider side Verification there is one Class Annotaiton called @PactFolder. I want to make this path as dynamic once. Can you please help me in this.

dattasai.chunduru
2020-06-18 10:45
Currently I have given a Hard-coded path like this

matt.fellows
2020-06-18 11:17
The workshop has examples of how to do this. You would usually use a pact broker and fetch the contracts that way

matt.fellows
2020-06-18 11:17
But you can put dynamic property values in there in whatever java framework you're using eg spring

alexandre.cuva
2020-06-18 12:58
has joined #general

pavann088
2020-06-18 17:20
has joined #general

pavann088
2020-06-18 17:22
Hi. I am new to pact . can any one tell me where to getstarted .

zhukeven86
2020-06-18 17:56
Hi. I'm planning on adding the JVM implementation of Pact (version 4.x) from the Maven Central repository, but I am unsure of which files to use. The files there seem to be fragmented and there does not seem to be a fully packaged version of JVM Pact on there. Any help would be greatly appreciated.

phil.endsley
2020-06-18 18:03
Read the docs if you haven't already. They're excellent. https://docs.pact.io/getting_started/ https://docs.pactflow.io/docs/workshops/ci-cd/ There's also docs for language specific libraries and how to use them.

bernardoguerr
2020-06-18 18:04
Hello! There's a #pact-jvm-help channel , it's probably a better place to ask that question :slightly_smiling_face:

zhukeven86
2020-06-18 18:07
Thanks!

williamfslima
2020-06-18 20:15
has joined #general

matt.fellows
2020-06-18 23:06
What do you by fragmented Keven?

bethskurrie
2020-06-18 23:24
I hadn't realised that the "how does Pact compare to..." page hadn't been migrated from the old ruby docs to the new ones. I've just added the page here https://docs.pact.io/getting_started/comparisons Are there any notable tools that are missing that we should add? I've already asked in the pact-jvm channel to see if someone can write about spring cloud contracts.

jess.c.ho
2020-06-19 02:19
has joined #general

bethskurrie
2020-06-19 03:08
@gstorck pending pacts is implemented, but WIP pacts is not yet.

bethskurrie
2020-06-19 03:09
The issue for the feature is here: https://github.com/DiUS/pact-jvm/issues/1131

tjones
2020-06-19 07:53
This page is excellent, Beth! I reckon we should do one for each language. In JS land, there?s `nock` (and others probably). In jvm at least Wiremock and RestAssured

bethskurrie
2020-06-19 07:53
Good point.

bethskurrie
2020-06-19 07:54
Maybe make headings for each language

bethskurrie
2020-06-19 07:54
would you like to do the nock one?

tjones
2020-06-19 07:54
Also, possibly worth an item on ?Mocking your favourite request framework?? I?ve seen a lot of JS unit tests where they straight up mock `axios` or `request`

bethskurrie
2020-06-19 07:54
good idea

tjones
2020-06-19 07:54
Happy to do the nock one

bethskurrie
2020-06-19 07:55
please!

yangyu823
2020-06-19 14:21
has joined #general

sklein
2020-06-19 19:23
has joined #general

tyler.collins
2020-06-19 21:07
has joined #general

nouri.tawfik
2020-06-20 08:31
Hello folks! The pact wip (pact working in progress) feature is available for . NET? Have a great day


bethskurrie
2020-06-20 08:52
Can you raise an issue asking for it to be implemented please?

nouri.tawfik
2020-06-20 08:55
Thank you @bethskurrie Oky

nouri.tawfik
2020-06-20 09:00
Done

tausif8709
2020-06-20 13:52
has joined #general

tom.shirley
2020-06-21 00:38
has joined #general

jacek.okrojek
2020-06-22 07:26
Hi All!

jacek.okrojek
2020-06-22 07:29
I wonder if enyone tried to adapt Pact for other protocols than XML/JSON over HTTP(s) and try to store contracts for in PactBroker ?

bethskurrie
2020-06-22 07:29
@jacek.okrojek you can store any type of JSON contract in the Pact Broker

bethskurrie
2020-06-22 07:30
> The Pact Broker is an application for sharing for consumer driven contracts and verification results. It is optimised for use with "pacts" (contracts created by the http://docs.pact.io/ framework), but can be used for any type of contract that can be serialized to JSON.


jacek.okrojek
2020-06-22 07:49
Thanks Beth, I wonder if you heard about someone who also created solution that fetchs cotracts from PactBroker and create from them stubs and also create sort of Pact DSL for custom protocol? Do you think it is worth digging into pact for this purpose or it would be easier to create custom solution?

bethskurrie
2020-06-22 07:49
Totally doable.

bethskurrie
2020-06-22 07:50
We're already considering grpc and peotobufs

jacek.okrojek
2020-06-22 07:51
Can you point me to some source that could give me some hints how to start

jacek.okrojek
2020-06-22 07:51
?

matt.fellows
2020-06-22 07:55
#protobufs

matt.fellows
2020-06-22 07:55
Head there Jacek, somebody recently blogged about doing it in Java.

matt.fellows
2020-06-22 07:56
It might be a great starting point for you

jacek.okrojek
2020-06-22 10:44
Thanks!

dattasai.chunduru
2020-06-22 12:18
Hi All I am trying to do a POST request by using PACT

dattasai.chunduru
2020-06-22 12:20
but it is giving me error as

dattasai.chunduru
2020-06-22 12:20
can anyone please help me on this

dattasai.chunduru
2020-06-22 12:41
I am using Java and Maven

phil.endsley
2020-06-22 12:44
There's a #pact-jvm-help channel you can post this too. Also, I think you'll need to provide more of the stack trace. The test is failing, but there should be more details where it actually failed

dattasai.chunduru
2020-06-22 12:47
My end point is like this

dattasai.chunduru
2020-06-22 12:48
actually it is saying it is not able to do POST action

dattasai.chunduru
2020-06-22 12:54
This is the full error I am getting

dattasai.chunduru
2020-06-22 12:54
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 8.793 sec <<< FAILURE! testPact(pact_post.pact_post.PactBaseConsumerTest) Time elapsed: 2.54 sec <<< FAILURE! java.lang.AssertionError: Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET path: /comments query: {} headers: {Accept=[application/json, application/*+json], Connection=[keep-alive], Host=[kubernetes.docker.internal:54925], User-agent=[Java/14.0.1]} matchers: MatchingRules(rules={}) generators: Generators(categories={}) body: EMPTY)]) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.testPact(ConsumerPactTest.java:41) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.springframework.test.context.junit4.statements.RunBeforeTestExecutionCallbacks.evaluate(RunBeforeTestExecutionCallbacks.java:74) at org.springframework.test.context.junit4.statements.RunAfterTestExecutionCallbacks.evaluate(RunAfterTestExecutionCallbacks.java:84) at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75) at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:251) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:564) at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Caused by: org.springframework.web.client.HttpServerErrorException$InternalServerError: 500 Internal Server Error: [{ "error": "Unexpected request : \tmethod: GET\n\tpath: \/comments\n\tquery: {}\n\theaders: {Accept=[application\/json, application\/*+json], Connection=[keep-alive], Host=[kubernetes.docker.internal:54925], User-agent=[Java\/14.0.1]}\n\tmatchers: MatchingRules(rules={})\n\tgenerators: Generators(categories={})\n\tbody: EMPTY" }] at org.springframework.web.client.HttpServerErrorException.create(HttpServerErrorException.java:100) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:172) at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:112) at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63) at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:782) at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:740) at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:674) at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:315) at pact_post.pact_post.ProviderService.getInformation(ProviderService.java:20) at pact_post.pact_post.PactBaseConsumerTest.runTest(PactBaseConsumerTest.java:54) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.lambda$testPact$0(ConsumerPactTest.java:32) at http://au.com.dius.pact.consumer.BaseMockServer.runAndWritePact(MockHttpServer.kt:110) at http://au.com.dius.pact.consumer.ConsumerPactRunnerKt.runConsumerTest(ConsumerPactRunner.kt:13) at http://au.com.dius.pact.consumer.junit.ConsumerPactTest.testPact(ConsumerPactTest.java:31) ... 38 more 2020-06-22 18:21:40.530 INFO 11840 --- [extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' Results : Failed tests: testPact(pact_post.pact_post.PactBaseConsumerTest): Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET(..) Tests run: 1, Failures: 1, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 49.969 s [INFO] Finished at: 2020-06-22T18:21:40+05:30 [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project pact-post: There are test failures. [ERROR] [ERROR] Please refer to C:\Users\dattasai.sukumar\Documents\workspace\pact-post\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

gstorck
2020-06-22 13:02
thaanks~

dattasai.chunduru
2020-06-22 13:20
Actually in POST method also it is reffering for GET method

dattasai.chunduru
2020-06-22 13:20
it is giving me error as it is giving error for me as Failed tests:  testPact(pact_post.pact_post.PactBaseConsumerTest): Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[UnexpectedRequest(request= method: GET(..)

chandanakurumeti27
2020-06-22 13:21
I would like to know how often there would be updates for pactbroker chart? and where can we find the updated versions of the same?

2020-06-22 13:33
A new post has been created in *Feature Requests*

phil.endsley
2020-06-22 13:50
I replied to the thread in the pact-jvm-help channel

nathan.deamer
2020-06-22 15:39
I have a question about webhooks. If I want to use the provider name in the webhook, how can I do that? e.g. https://my_ci_tool.client.com/{provider.name}/build?branch=master

nathan.deamer
2020-06-22 15:39
Maybe its {pactbroker.providerName}

nathan.deamer
2020-06-22 15:42
With the consumer and provider set to all

nathan.deamer
2020-06-22 16:10
This didn't work. I am trying to build a webhook where consumer: ALL provider:ALL Events: Contract published with changes content or tags

wesleythomaswilliams
2020-06-22 16:35
.

uglyog
2020-06-22 23:04
@dattasai.chunduru You have configured the expected interaction to be a POST request, but then your test is not making a POST request, but a GET request. The mock server is doing the correct thing. You told it it must receive a POST, so when it receives any other request it will fail the test.

naeem95m
2020-06-23 06:58
@a.smith I'm also working on a POC for my team to use Pact with NodeJS based Azure Functions. It would be great if you can share a sample pipeline structure. Thanks

2631133172
2020-06-23 07:21
has joined #general

giuseppe.salvatore
2020-06-23 10:57
Hi all! I know this might be a dumb question but potentially there could be use cases for this. So I would need to publish the verification results to pact broker and I know how to do it in the provide CI (using jvm maven junit4 for that) Publishing the results it's just a matter of adding an option to pom or a -Dpact.verifier.publishResults=true on the command line of the maven build

giuseppe.salvatore
2020-06-23 10:57
I am wondering if the results are stored as files and they can be published after the build

bethskurrie
2020-06-23 10:58
No

giuseppe.salvatore
2020-06-23 10:58
more or less like you can publish the pact contract from the consumer side with `mvn pact:publish`

bethskurrie
2020-06-23 10:58
The reason is that most build systems do not proceed to the next step once they hit a failure.

bethskurrie
2020-06-23 10:58
So, we had to do the publishing directly within the proccess.

bethskurrie
2020-06-23 10:58
If you want to get the verification results back again, you'll need to use the API.

giuseppe.salvatore
2020-06-23 10:59
ok thanks Beth, I guess that will do :+1:

bethskurrie
2020-06-23 10:59
what are you trying to do?

giuseppe.salvatore
2020-06-23 11:04
well... it's mainly a workaround that we will need to fix properly. We are running the CI with Jenkins X which provides build packs to run `mvn deploy` To run the verification we had to add a postbuild step and run `mvn deploy --Dpact.verifier.publishResults=true` which is time consuming and not really elegant but works. The proper solution with Jenkins X would be not to use the build pack and write the pipeline ourselves (doable) but I was just wondering if there was another option, like for example publishing the verification in a post build step

giuseppe.salvatore
2020-06-23 11:05
I guess I will have to go the proper way and writing the pipeline, not a big deal, we can do that

bethskurrie
2020-06-23 11:05
No - sorry.

matt.fellows
2020-06-23 11:45
Hmm, that should work Nathan. These are the default variables available

matt.fellows
2020-06-23 11:46
What?s the error you?re getting?

catalin
2020-06-23 15:20
has joined #general

rafael.espillaque
2020-06-23 16:18
Hi, I?m in the process of evaluating Pact for my services which communicate using messages. Some messages are Queries, where a message is the Request and another the Response. Those services will have cycles: Serv.A is the consumer AND the provider of Serv.B (because they read and write request and response messages). I?m a bit concerned that those cycles will complicate the CI pipeline flows. Have you seen this use case in the past? Anyone has something to read in this topic? Thanks a lot again!

chawlapriyanka29
2020-06-23 22:47
has joined #general

tjones
2020-06-23 23:43
@rafael.espillaque I would do something like this:

tjones
2020-06-23 23:56
How you cut the steps into pipelines is up to what makes sense for your CI system and implementation, but generally make sure that you avoid cycles

tjones
2020-06-23 23:57
You also might not want to allow B?s code change to do a deploy of A

bethskurrie
2020-06-23 23:57
The broker supports this usecase. It's been done before.

ravi.mijar
2020-06-24 05:57
Hello Dr. @tjones, is there a way to install pact for nodejs w/o the standalone binary that seems to get installed as a postscript?

tjones
2020-06-24 05:57
Pact-js is backed by the ruby binaries

tjones
2020-06-24 05:58
Why do you need to install them separately?

ravi.mijar
2020-06-24 05:58
restricted windows dev environment where it fails to download the zip file from github

tjones
2020-06-24 05:59
Ok. So you want to install the binaries separately?

tjones
2020-06-24 05:59
I believe this is possible, hold on

ravi.mijar
2020-06-24 05:59
yep


tjones
2020-06-24 06:00
Does this work for you?

ravi.mijar
2020-06-24 06:00
brilliant, let me try..

ravi.mijar
2020-06-24 06:22
yes, that worked. Thanks Dr. Jones.. :slightly_smiling_face:

tjones
2020-06-24 06:31
You?re welcome! Feel free to reach out if you have any further problems.

gerrelatanacio
2020-06-24 07:02
has joined #general

d.duraivelan
2020-06-24 08:57
has joined #general

luca.cervello
2020-06-24 13:11
has joined #general

poffey21
2020-06-24 15:22
has joined #general

poffey21
2020-06-24 15:27
@mike.geeves have you had much luck getting this going? I'd love to learn about your experience thus far - shamelessly I'm with GitLab and looking to see how we can work well with Pact!

hadjaliabir
2020-06-24 15:56
has joined #general

mike.geeves
2020-06-24 16:02
I got the first few bits going quite nicely, but not with the full end to end process, unfortunately distracted with other things. Still more to do around the "can-i-deploy" part for example. It works well having webhooks to do the validation after a new consumer update comes in, to trigger a build on the provider side. I'm happy to share the steps, but I wouldn't say it's following best practices and so on just yet

poffey21
2020-06-24 16:03
For sure! I'm hoping to get an example out on our blog. Any information you have would be great. I'd be happy to send props your way too.

rafael.espillaque
2020-06-24 16:58
@tjones going back to the flow you shared a few messages above, Red?s consumer test would trigger a webhook for Blue build but Blue wasn?t merged into master because Blue consumer tests are still failing. Blue?s master wouldn?t have Red?s provider code. I guess I?d need to manually run Blue?s build using the correct branch, right? I guess webhooks would only trigger builds in master.

rafael.espillaque
2020-06-24 17:15
I guess that?s a question for everybody: Do webhooks always trigger builds on the master branch? I don?t understand how webhooks triggers usually work

phil.endsley
2020-06-24 17:24
I'm going to take a stab at this, because it's only a matter of time before we have the same scenario. As I understand it, you would need to break up feature development in a way that only one part (consumer or provider) is changing at a time for Red or Blue. If you have two applications that are a consumer/provider for each other, you can't make changes to both contracts in parallel and safely merge them. You would have to coordinate the merges. This isn't safe, because now you have to coordinate the releases of Red and Blue. So, I think you would want to: ? Change/update Red's Consumer contract ? Implement provider changes on Blue (without breaking Blue's contract with Red) ? Merge Blue, then merge Red ? Repeat for Blue Doing it that way would let you release Red/Blue individually, because you'll have compatible versions

phil.endsley
2020-06-24 17:26
I would still like to hear from @tjones or someone else

rafael.espillaque
2020-06-24 17:27
I see? it?s like working on the contract of the Request message first and merge everything. And after that, work on the contract of the Response message and merge everything. Is that what you?re saying?

phil.endsley
2020-06-24 17:28
If you make changes to the contract for Blue in a way that makes Red fail verification, And you change the contract for Red in a way that makes Blue fail verification You wouldn't be able to merge those into your main branch, since there wouldn't be any verification against the latest version of main branch against that feature branch (Since they depend on each other)

phil.endsley
2020-06-24 17:29
Yes. So the feature won't be ready to ship until both are done, but this way, you'll have versions that are backwards compatible

rafael.espillaque
2020-06-24 17:31
> since there wouldn?t be any verification against the latest version of main branch against that feature branch (Since they depend on each other) I was thinking that having a verification against a feat-X tag would be enough to be able to merge into master

phil.endsley
2020-06-24 17:34
`provider-red-feat-x` verifies `consumer-blue-feat-x` `provider-blue-feat-x` verifies `consumer-red-feat-x` `provider-red-master` fails verification with `consumer-blue-feat-x` `provider-blue-master` fails verification with `consumer-red-feat-x` If neither `feat-x` tags have verified with master, how would you safely merge one?

phil.endsley
2020-06-24 17:37
I think I had the master one backwards. I edited it

rafael.espillaque
2020-06-24 17:43
I see?

rafael.espillaque
2020-06-24 17:43
I?ll wait for @tjones and @bethskurrie input as well

kristine.jetzke
2020-06-24 20:23
Short answer AFAIK: no

kristine.jetzke
2020-06-24 20:25
I think you can also trigger builds on other branches

kristine.jetzke
2020-06-24 20:32
You can pass https://docs.pact.io/pact_broker/advanced_topics/api_docs/webhooks#dynamic-variable-substitution to the webhook and use them to check out specific branches

kristine.jetzke
2020-06-24 20:42
hm? I realized I misunderstood your question. I was thinking about the consumer not being on master branch. But I guess it is about the provider not being on master branch?

kristine.jetzke
2020-06-24 20:45
If it was about the consumer, it can work like this: ? Consumer develops new feature in branch `feature-a` ? Contract gets tagged with branch name `feature-a` ? Provider CI build is triggered via webhook, webhook payload includes the consumer tag `feature-a` via variable `${pactbroker.consumerVersionTags}` ? Provider build checks that it?s own master fulfills contract from `feature-a` ? Consumer can safely merge to master

kristine.jetzke
2020-06-24 21:01
For the reverse I?m not sure. If the branch names are the same in consumer and provider it could look like this: ? Consumer and provider both create a feature branch `feature-a` ? Consumer published contract from this branch ? Provider CI build gets triggered via webhook, takes value `feature-a` from `${pactbroker.consumerVersionTags}` and checks out own `feature-a` branch ? Verifies that own `feature-a` branch fulfills consumer `feature-a` branch ? Provider merges to master ? Consumer merges to master :thinking_face:

rafael.espillaque
2020-06-24 22:27
that was very helpful. I was interested on both flows

rafael.espillaque
2020-06-24 22:28
thanks a lot

chawlapriyanka29
2020-06-25 00:42
Hey.. I am new to Pact Testing.. I just have a quick question.. So I have 2 swagger files at the provider side against which I can validate my consumer.. So I thought of creating 2 pacts between one consumer and provider.. My question is can I have 2 pact files one can verified against one swagger file and other against the other one

matt.fellows
2020-06-25 00:44
Why do you have 2 swaggers for a single provider? But as far as pact goes, you _could_ create two separate pacts (but you would need to give the provider two names for that to work). But I wouldn?t, it?s logically one provider (assuming it is deployed as a single unit)

matt.fellows
2020-06-25 00:44
Pact also doesn?t verify the swagger, they are orthogonal concerns. So you can keep your swagger files there if that?s something that?s useful to have. But Pact doesn?t care about swagger

chawlapriyanka29
2020-06-25 00:48
So the scenario is I have 2 swagger files one for legacy system and one is the new one.. There are some api calls in my contract tests which are for legacy system and some are for new system.. So in that case I want both my pacts to be verified against those 2 swagger files

matt.fellows
2020-06-25 00:48
Is it one provider or two providers? where a provider is an API that is a single, deployable unit?

chawlapriyanka29
2020-06-25 00:49
There is one provider

matt.fellows
2020-06-25 00:49
> So in that case I want both my pacts to be verified against those 2 swagger files Pact doesn?t care about swagger files, it just cares about the API target itself

matt.fellows
2020-06-25 00:49
ok cool, then I?d create a single pact contract

phil.endsley
2020-06-25 00:50
Two consumers? You mentioned a legacy and new system

chawlapriyanka29
2020-06-25 00:50
2 swagger files at the provider side

matt.fellows
2020-06-25 00:51
Is it just a single consumer application talking to that provider?

chawlapriyanka29
2020-06-25 00:51
For now it is just one.. but there can be many

chawlapriyanka29
2020-06-25 00:52
Is there a way I can have 2 contracts ?

chawlapriyanka29
2020-06-25 00:53
I mean is there a possibility to support multiple pact files for a single consumer

matt.fellows
2020-06-25 00:53
Why would you want to do it, is the question?

matt.fellows
2020-06-25 00:53
A contract is between a single consumer <-> provider pair. Knowing this relationship is what makes all of the CI/CD workflows with the Pact Broker work. For example, answering the question ?is it safe to release consumer A to production?

matt.fellows
2020-06-25 00:54
having multiple contracts complicates this relationship.

chawlapriyanka29
2020-06-25 00:57
Yes I know that..but let's suppose there is API call named getXy() which is for the legacy system and it is in legacy swagger file and there is API call addPY() which is for the newer system and the newer swagger supports it.. what should I do in that case

matt.fellows
2020-06-25 00:57
I?m not understanding how Swagger has anything to do with this. Swagger is just a document that describes how your underlying API works. It isn?t a functional thing you can test.

matt.fellows
2020-06-25 00:58
Pact will test your API, it doesn?t know your swagger document even exists

chawlapriyanka29
2020-06-25 00:59
But what I mean to say is there is legacy system let's suppose v1 for which one swagger file is created and there is another system v2 for which another swagger file is created.. and my contract tests needs to test both

chawlapriyanka29
2020-06-25 00:59
But at provider side.. My code verifies against the swagger file and it's request and response

matt.fellows
2020-06-25 01:00
If indeed the legacy system and new system are _separate providers_ then I would create 2 contracts - `Consumer` -> `Legacy Provider` and `Consumer` -> `New Provider`

chawlapriyanka29
2020-06-25 01:00
I mean the yaml file

chawlapriyanka29
2020-06-25 01:00
What do mean by that ?

abubics
2020-06-25 01:01
It does make conceptual sense to have one pact per pair of bounded contexts, but practically it makes more sense to have one per codebase pair :upside_down_face:

matt.fellows
2020-06-25 01:01
yeah

matt.fellows
2020-06-25 01:02
Priyanka - When your provider team makes a change to the legacy system, will it get deployed with the new api? Or are they deployed separately? i.e. is the Provider an API that supports the legacy and modern API?

matt.fellows
2020-06-25 01:02
Because if it?s all one code base that gets deployed, then i would strongly recommend you have a single contract between the consumer and the provider

matt.fellows
2020-06-25 01:03
I know where you?re coming from, but unless you are actually experiencing issues I think you?re worrying about problems that don?t exist

matt.fellows
2020-06-25 01:03
yes. more specifically, the ?deployable unit?

matt.fellows
2020-06-25 01:06
I realise I never answered this directly. Yes absolutely, a single consumer can have relationships with many providers. But in your case, I think you just have a single provider we?re talking about

bethskurrie
2020-06-25 01:07
This

chawlapriyanka29
2020-06-25 01:11
Matt I can understand your point but it's like 2 pods are running the services each has its own yaml but has the same code base.. So I am bit confused

chawlapriyanka29
2020-06-25 01:16
Does it seem like I should have a 2 providers then..

tjones
2020-06-25 01:17
This is a good discussion! Thanks for the additional input @phil.endsley- here?s some thinking on breaking changes: Generally when making breaking changes between A and B, you?d need a version of one that speaks both versions of the other. Sometimes the design dictates whether that?s the consumer or the provider, and sometimes you get to choose. Ideally, this still holds true for when A and B are both consumers of the other - from a strictly theoretical perspective, it should be possible to view the contracts as independent. This is sort of illustrated in the diagram from yesterday, because a contract change for one service doesn?t affect the other?s contract. With a circular contract between A and B, it?s possible that certain design choices might result in it being impractical to modify both contracts at the same time. I haven?t run in to this, but then I haven?t had much personal experience with circular contracts. My gut feel is that if this is happening, there?s an anti-pattern somewhere

tjones
2020-06-25 01:20
@rafael.espillaque, to your specific question about branches, I?m not sure I fully understand the picture. It sounds like the branching and tagging strategy might not be aligned? Ideally, you wouldn?t need to manually kick off any provider verifications

tjones
2020-06-25 01:22
(but of course, if this works for you, there?s no reason to forbid it. Testing is about risk reduction, and if you?re still getting the risk reduction you need without adding extra risks or overheads, then it?s fine)

abubics
2020-06-25 01:23
It does feel like you might be conflating a few technologies here (e.g. Kubernetes, Swagger, Pact, YAML, etc) that aren't intrinsically related to the problem you're trying to solve. I'd recommend stepping back from the implementation details, and try to talk about it in terms of higher-level concepts and building blocks.

tjones
2020-06-25 01:27
In swagger land, people often talk about the swagger document being a ?contract?. This is a different meaning to the contract as we use it in pact. Here are some of the differences: 1. A swagger document says ?I accept these requests? and ?I can generate these responses?. A Pact contract says ?For this request, I expect this response? 2. A swagger document is only from the provider?s perspective. A Pact contract is between a specific consumer and a specific provider. 3. A swagger document typically describes the whole API. A Pact contract only describes the parts of the API that the specific consumer uses.

tjones
2020-06-25 01:27
There are probably more differences

matt.fellows
2020-06-25 01:32
Indeed

matt.fellows
2020-06-25 01:33
Furthermore, Pact is not just about the contract. The whole purpose of doing this is not to ?generate a contract? but to get confidence that two applications can communicate, and to use that information to release and deploy systems safely.

matt.fellows
2020-06-25 01:33
Generating a contract is really a side-effect of the process - an important one for it to function - but it?s not the _end_ in and of itself

abubics
2020-06-25 01:53
I feel like some of this info must be in the docs :troll: I'm not familiar enough with them to point anyone to the right spots, though :upside_down_face:


bethskurrie
2020-06-25 01:53
> The reason the pact file exists is to ensure the tests in both projects are kept in sync - it is not an end in itself. Manually writing or generating a pact file from something like a Swagger document would be like marking your own exam, and would do nothing to ensure that the code in the consumer and provider are compatibile with each other.

kristine.jetzke
2020-06-25 07:36
:slightly_smiling_face: For the second flow though I?m not sure how ?notification? works e.g. how do you know that you can safely merge.

thomas.rychlik
2020-06-25 07:57
has joined #general

mike.geeves
2020-06-25 10:11
the repos aren't in a sharable state yet - I'm trying to build up a set of a couple of consumers and a couple of providers (and I would need to check what's in there that shouldn't be in terms of did anyone commit in keys etc)

mike.geeves
2020-06-25 10:12
however, gitlab ci

mike.geeves
2020-06-25 10:12
Here's one of the consumers

mike.geeves
2020-06-25 10:13
I'm not sure how much would make Beth, Matt etc angry or sad but .. :smile:

mike.geeves
2020-06-25 10:14
I tried in the consumer part to go through looking for providers to verify against and then make a webhook against the repo after searching to find their name to get the project id via the gitlab API :thinking_face: it's a bit of bash-fu

mike.geeves
2020-06-25 10:15
The provider part is then

mike.geeves
2020-06-25 10:15
with more bash-fu in the pact-verify

mike.geeves
2020-06-25 10:18
we build the docker images as step 1 to then run tests, deployment against that built image rather than just "against the files", so this was partly then going towards what other dependencies need to be spun up - i.e. you have the docker network created for just these containers, the provider will then need (for example) a postgresql container setup and linked in and then provide the state - I didn't get onto progressing that part

mike.geeves
2020-06-25 10:21
Note: this was following something I was playing around with, that definitely isn't best practice - because you can handle the webhooks arguably "better" via the broker itself, BUT: what I was trying to do with this approach is make it more of the gitlab pipeline, I like having the flow of steps going through and it's "valuable" for me to be able to see the consumer build having the waiting patiently for the provider verification step, and then failing or passing that step as part of the consumer build, so you can see within the gitlab pipelines what has happened

mike.geeves
2020-06-25 10:24
For reference, this is using pipeline-trigger from https://gitlab.com/finestructure/pipeline-trigger > Pipeline-trigger allows you to trigger and wait for the results of another GitLab pipeline which worked quite nicely :slightly_smiling_face:

mike.geeves
2020-06-25 10:40
The other way could be useful, if you could get the pact tests into swagger docs We have a lot of very useless swagger (auto generated from spring) files which do technically contain the model etc but since nobody puts in valid request/responses, or at least keeps it up to date it is not helpful (I'm currently playing with FastAPI and pydantic and omg drool)

suma.papanna
2020-06-25 10:52
has joined #general

naeem95m
2020-06-25 11:06
Not able to configure webhook, even though I have followed exact steps in CI/CD workshop. It would be great if anyone can help?

matt.fellows
2020-06-25 11:09
`403` forbidden tells me it?s highly likely you haven?t got the correct API token from Travis configured

naeem95m
2020-06-25 11:12
using this token as secret in pactflow

matt.fellows
2020-06-25 11:13
You could please share the contents of that webhook test dialog?

naeem95m
2020-06-25 11:14
```[2020-06-25T11:14:07Z] DEBUG: Webhook context {"base_url":"https://mnaeem.pact.dius.com.au"} [2020-06-25T11:14:07Z] INFO: HTTP/1.1 POST https://api.travis-ci.com/repo/mnaeem95%2Fexample-provider/requests [2020-06-25T11:14:07Z] INFO: accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3 [2020-06-25T11:14:07Z] INFO: accept: application/json [2020-06-25T11:14:07Z] INFO: user-agent: Ruby [2020-06-25T11:14:07Z] INFO: content-type: application/json [2020-06-25T11:14:07Z] INFO: travis-api-version: 3 [2020-06-25T11:14:07Z] INFO: authorization: [REDACTED] [2020-06-25T11:14:07Z] INFO: host: http://api.travis-ci.com [2020-06-25T11:14:07Z] INFO: content-length: 512 [2020-06-25T11:14:07Z] INFO: {"request":{"message":"Triggered by changed pact for pactflow-example-consumer version cc6b02b+1593080393","branch":"master","merge_mode":"deep_merge_append","config":{"env":{"global":["PACT_URL=https://mnaeem.pact.dius.com.au/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/pact-version/afc6e91b38b47ad457266f7f223b7a2a3c6e0382/metadata/Y29uc3VtZXJfdmVyc2lvbl9udW1iZXI9Y2M2YjAyYiUyQjE1OTMwODAzOTMmY29uc3VtZXJfdmVyc2lvbl90YWdzW109bWFzdGVyJmNvbnN1bWVyX3ZlcnNpb25fdGFnc1tdPXByb2Q="]}}}} [2020-06-25T11:14:07Z] INFO: HTTP/1.1 403 Forbidden [2020-06-25T11:14:07Z] INFO: date: Thu, 25 Jun 2020 11:14:07 GMT [2020-06-25T11:14:07Z] INFO: content-type: text/html;charset=utf-8 [2020-06-25T11:14:07Z] INFO: transfer-encoding: chunked [2020-06-25T11:14:07Z] INFO: connection: keep-alive [2020-06-25T11:14:07Z] INFO: strict-transport-security: max-age=15724800; includeSubDomains [2020-06-25T11:14:07Z] INFO: x-oauth-scopes: [2020-06-25T11:14:07Z] INFO: vary: Accept-Encoding [2020-06-25T11:14:07Z] INFO: x-request-id: 2dafc2cc179f6b7877d6937ada6af10d [2020-06-25T11:14:07Z] INFO: access-control-allow-origin: * [2020-06-25T11:14:07Z] INFO: access-control-allow-credentials: true [2020-06-25T11:14:07Z] INFO: access-control-expose-headers: Content-Type, Cache-Control, Expires, Etag, Last-Modified, X-Request-ID [2020-06-25T11:14:07Z] INFO: access denied [2020-06-25T11:14:07Z] INFO: Webhook execution failed```

matt.fellows
2020-06-25 11:19
looks ok

matt.fellows
2020-06-25 11:20
I just reproduced the issue by mis spelling the token variable in the webhook - so it was blank

matt.fellows
2020-06-25 11:20
can you please show me your webhook configuration screen?

matt.fellows
2020-06-25 11:22
you have basic auth credentials added down the bottom (perhaps your browser auto-filled them?)

matt.fellows
2020-06-25 11:22
please remove them

naeem95m
2020-06-25 11:24
Ohhk, my bad. It's working now.

naeem95m
2020-06-25 11:24
Thanks a lot for the help!

matt.fellows
2020-06-25 11:24
you?re welcome!

matt.fellows
2020-06-25 11:28
I?ve just made a small fix to prevent browsers from doing that. I?ll release that tomorrow

naeem95m
2020-06-25 11:29
Cool

rafael.espillaque
2020-06-25 13:09
I wouldn?t say I?m hitting any anti-patterns. My services are using CQRS and Event Sourcing so for them it?s very common to have a message (no http interactions) that triggers some action (a command message) and then waits for an event message. In that scenario, Service A is the producer of the Command and the consumer of the Event. Service B is the consumer of the Command message and the provider of the Event message. I?m concerned that those circular dependencies will complicate merging and deploying so much that Pact and the Pact broker will stop us to delivery as fast as possible.

matt.fellows
2020-06-25 13:27
I think it's fine, you'll just need to (unfortunately) five different names to the http and message part of that provider (the broker does not yet support a provider being in both roles at once)

rafael.espillaque
2020-06-25 13:29
sorry, I don?t have any http interactions. I just wanted to highlight that we?d use messaging contracts

lmcfadden03
2020-06-25 13:54
has joined #general

tjones
2020-06-25 14:19
I?m keen to better understand the problem you?re facing. Are you asking about a situation where the next version of the service (the version immediately after the merge) is not compatible with both the new and the old versions? You might know this already, but there?s a subtlety in that pact verification works against a contract, not a version. This means you don?t need to over-verify - if the contract that master produces is identical to a previously-verified contract, then verification doesn?t need to be done. See here for more info: https://docs.pact.io/getting_started/versioning_in_the_pact_broker

rafael.espillaque
2020-06-25 14:24
not exactly that, give me a few minutes in order to explain my use case in depth

rafael.espillaque
2020-06-25 14:24
thanks btw!

tjones
2020-06-25 14:31
You?re welcome! Pact should only really block you from deploying software that won?t work in your ecosystem, so if it?s slowing you down in other ways I?m keen to hear about it. We can probably improve something - whether it?s planning new features or just better documentation.

tjones
2020-06-25 14:31
It?s bedtime here in my time zone, but I?ll check back tomorrow.

rafael.espillaque
2020-06-25 14:33
```Service A is interested on some data that Service B exposes. Service B has a QueryHandler method that receives GetDocument messages and returns Document messages. (QueryHandlers are something managed by the framework I use but you can think that there's a Message Broker in the middle of both services.) Service A is the consumer of the Document message and the provider of the GetDocument message. Service B is the consumer of the GetDocument message and the provider of the Document message. Service A and B are in a circular cycle. Service A can't deploy because the contract for Document is not verified. Service B can't deploy because the contract for GetDocument is not verified.```

rafael.espillaque
2020-06-25 14:33
thanks Tim! rest well!

tjones
2020-06-25 14:35
In your scenario, is deploying the same as merging to master?

rafael.espillaque
2020-06-25 14:36
yes, merging would mean deploying to test or stage environment

rafael.espillaque
2020-06-25 14:37
but not really deploying to prod directly

tjones
2020-06-25 14:38
In the feature branch for the producer, are you also verifying against the master pact from the consumer?

rafael.espillaque
2020-06-25 14:40
I haven?t built the pipelines yet, just learning about workflows following the workshop and the pact nirvana. I guess I wouldn?t? isn?t that something related to the new WIP Pact feature?

tjones
2020-06-25 14:43
My gut is that you would want to verify against your consumer?s master and your consumer?s corresponding feature branch, otherwise you?re unlikely to know if it?s safe to merge

rafael.espillaque
2020-06-25 14:44
yeah, makes sense

tjones
2020-06-25 14:46
I might have a different view after sleep, though. It sounds like your CI setup is different to my personal preferences (to be clear, I don?t think it?s a bad setup, it?s just different), so maybe I missed something.

tjones
2020-06-25 14:47
I?ll check in again tomorrow. I think you should be able to design a process that?s fairly painless.

rafael.espillaque
2020-06-25 14:48
I?m open to any CI setup, I?ll let you rest!

rafael.espillaque
2020-06-25 14:49
wtf 12:49 AM and talking with me? go to bed!

tjones
2020-06-25 14:49
I don?t think you need to change it :+1: - in particular, I?d like Pact to not force opinions on CI setup, or at least to be as broadly useful as possible.

ayyamuthutechnical
2020-06-25 16:35
has joined #general

ayyamuthutechnical
2020-06-25 16:38
Hi, My name is Ayyamuthu. Currently working in pact with python for microservices. Happy to be part of this group.


tausif8709
2020-06-25 17:24
Hi Guys, I am doing a POC on pact-python for microservices , could you please advice on the best approach for testing the consumer pacts locally by setting up dummy provider states? Thanks in advance :slightly_smiling_face: Tausif

phil.endsley
2020-06-25 17:26
You may get more targeted help in #pact-python

matt.fellows
2020-06-26 03:08
How?d you go with it?

tjones
2020-06-26 04:01
@rafael.espillaque: I drew this to try to reason about your situation:

tjones
2020-06-26 04:02
This shows the branches for the two codebases, and the theoretical verification status, if you were to run all verifications

tjones
2020-06-26 04:03
I think you could consider it safe to merge anything where all verifications were green

tjones
2020-06-26 04:04
Then, if you rebase Consume GetDocument, you would get:

tjones
2020-06-26 04:05
(repeat until all branches are merged)

tjones
2020-06-26 05:36
Further to Beth?s comments above, there have been many good discussions in here recently- it would be great to capitalise on that momentum along with our documentation drive. If you?d like to contribute, but don?t see any code examples issues for you to pick up in your framework of choice, here are some more ways you can help: 1. Is there anything you?re aware of that you?d like to see covered better in the documentation? 2. Is there anything in the documentation you found hard to find? 3. Is there anything that you?d like to contribute to the documentation? At the moment, the documentation is mostly written by the core team, but we?d love to have more community input - another great place to start could be best practice or cookbook articles, especially from those with more complex or elegant pact use cases

dattasai.chunduru
2020-06-26 06:19
Hi @matt.fellows Thank you :slightly_smiling_face: I have used @PactBroker option and it is working

bethskurrie
2020-06-26 08:26
If you want to embed the verification into your consume pipeline rather than use webhooks, that can work.

bethskurrie
2020-06-26 08:27
You want to run can I deploy before running the verification to make sure you're not doing it unnecessarily.


bethskurrie
2020-06-26 08:28
Scroll down to the section on what to do if you can't use webhooks.

mike.geeves
2020-06-26 08:29
Sad face, I had the brief flurry of activity now about a month ago but haven't had time to progress since :(

mike.geeves
2020-06-26 08:29
I think the can I deploy was the last bit you mentioned to try next :)

rafael.espillaque
2020-06-26 09:23
thanks for that Tim, I think I get it. In summary, carefully splitting code changes into different branches so that interactions can be merged one at a time

naree.song
2020-06-26 10:54
has joined #general

adam.pike.ap
2020-06-26 12:06
has joined #general

adam.pike.ap
2020-06-26 12:14
Hello all, I have a question about how to work with multiple contracts between the same two apps. What's the best practice here? should I name them each after their respective feature / business requirement? If so is there a way that I can still associate them to show that they live in the same 2 apps when viewing the Pact Broker's network diagram?

matt.fellows
2020-06-26 12:20
What do you mean multiple contracts between the same two apps? A contract should be the collection of all interactions between them - i.e. a 1-to-1 mapping

adam.pike.ap
2020-06-26 12:26
Our case is that we have a web app that has multiple http clients, some of those are using axios some are graphql

adam.pike.ap
2020-06-26 12:26
so I thought it best to define a contract per client

adam.pike.ap
2020-06-26 12:28
the site is a very high traffic UK store

adam.pike.ap
2020-06-26 12:38
Perhaps a better questions is - is it possible to have multiple consumer tests contribute to one contract? If so how and how good would this look when viewing the contract in Pact Broker?

naz
2020-06-26 13:05
has joined #general

rafael.espillaque
2020-06-26 13:06
I?d say that?s a very common use case and Pact is designed to handle that. Each client would have its own Contract with its own expectations.

chandanakurumeti27
2020-06-26 13:24
Hi Beth, could you please provide some link in js where there are two different providers for specific consumer and where it generates two diferent pacts from one test.

naz
2020-06-26 14:05
Hi everyone. I'm a tech lead at a fintech in London and currently exploring the idea of using Pact. I've managed to get client tests working but I'm confused as to how providers are tested. How can I set up the db etc in a provider before tests are run? Do I *have* to expose a URL that does the setup when called?

naz
2020-06-26 14:07
I guess a better way to phrase my question is: what's the best practice for setting provider states prior to running tests?

mohammad.hasan
2020-06-26 14:09
has joined #general

antonello
2020-06-26 14:15
It should be a responsibility of the provider to set the state based on the provider state stated in the interaction. Which languages are your providers in?

antonello
2020-06-26 14:16
Also - ideally you wouldn?t use a real database in your provider tests, but mock at a sensible layer, depending on what?s feasible.

zbintliff
2020-06-26 14:17
We use the full DB (postgres) via docker compose an have hooks to where each test runs in a transaction and roles back. It definitely copmlicated things. But to answer your first question. Yes the provider listens to `/setup` . ours is in Go so we take the router and add a new path then have a case statement based on "state" param to setup the DB for the test.

sklein
2020-06-26 14:59
Hello everyone, is there a way to exclude contracts with an unknown success (???) in `can-i-deploy` or prevent them from failing the verification? We'd like to allow consumers the ability to add contracts with providers that have not yet implemented the verification workflow yet. Alternatively, is it just best practice to always have the provider verification pipeline setup before a consumer adds their contracts?

adam.pike.ap
2020-06-26 15:08
That seems logical to me too, but I wanted to keep the contracts from 1 app described as being from 1 app in the Pact Broker network graph too.

adam.pike.ap
2020-06-26 15:10
How can I name those contracts in a way that allows for this?

adam.pike.ap
2020-06-26 15:18
Hi Sean, you can use consumer version and tags to ensure that your provider only runs pipeline against the version that they currently have developed for. Version could be your git hash and tag could be your branch for example. I think there is also an extra 'WIP' feature when you use PactFlow.

sklein
2020-06-26 15:20
Thanks for the reply. We have that working for providers, but right now I have a failed consumer verification because it has a contract against a provider where the contract hasn't been verified (because the provider hasn't implemented the verification workflow yet)

sklein
2020-06-26 15:20
Maybe i'm missing something?

hadjaliabir
2020-06-26 15:27
Hello, i am new to contract testing ! what are the basics i should know to automate my test ?

wesleythomaswilliams
2020-06-26 15:31
It might not be a bad thing for them to appear separate on the network graph as <service>_<type>. I have services that use both REST and Kafka and I wish I could tell which connections on my network graph were which.

naz
2020-06-26 15:34
What's the best way to deal with cookies/auth? We currently pass user cookies in service to service calls so they can perform relevant ACL checks. These can't be mocked because they'd become stale.

naz
2020-06-26 15:36
@antonello Everything is in Python. We'd rather *not* mock the db as we lose confidence our services run as expected

adam.pike.ap
2020-06-26 15:37
I haven't used can-i-deploy yet but the way I read it, is that you will be using the result of a provider verification to ensure you haven't broken the contract. I would guess that in your case, since the contract has not been fulfilled yet but you still want to deploy, there is no need to use can-i-deploy? But this is with the caveat that you are deploying an app that makes requests to a currently non-existent end point. I'm guessing you have it under a feature-toggle?

naz
2020-06-26 15:37
@zbintliff So am I right in understanding that your provider will listen for a `/setup` call and then setup the db? How do you reset it between provider tests?

sklein
2020-06-26 15:38
Well not entirely. I only want any success = false to gate the deploy. I can write some sh to grep for that, but was hoping more for a cli flag.

zbintliff
2020-06-26 15:39
I have hooks to on the db client. So rather than stub and mock we just set it up as transaction and reset before and after. TBH ours is definitely clunky but once it was set up we haven't had to change it in a long time

sklein
2020-06-26 15:39
the endpoint currently exists. we're going through the process of adding contract testing to an existing eco system of many microservices and apis

zbintliff
2020-06-26 15:39
we do tx's so that the we know the exact state and it doesn't impact things

zbintliff
2020-06-26 15:40
we even run queries to reset seq for ids. so that creates give the exact ID we are expecting

adam.pike.ap
2020-06-26 15:40
sounds familiar :slightly_smiling_face:

adam.pike.ap
2020-06-26 15:42
My approach has been to set up the broker and start adding consumer-provider verification pairs before adding to CI with can-i-deploy. Gives the teams a chance to play with it and learn before introducing it to CI.

phil.endsley
2020-06-26 15:57
I haven't done anything with cookies specifically. But the docs have a couple items I've read about https://docs.pact.io/provider/handling_auth https://docs.pact.io/faq/#how-do-i-test-auth-cookies

naz
2020-06-26 16:18
These are fantastic links, thanks. Not sure how I missed them.

phil.endsley
2020-06-26 16:39
If you're just starting out, I would start here: https://docs.pact.io/getting_started/ The ci/cd workshop is also excellent, and walks through setting up a ci/cd pipeline: https://docs.pactflow.io/docs/workshops/ci-cd/

hadjaliabir
2020-06-26 20:08
Thank you for your help :blush:

matt.fellows
2020-06-26 22:14
Provider states and/or request filters usually solve this. What language do you use?

matt.fellows
2020-06-26 22:14
Hmmmm

matt.fellows
2020-06-26 22:16
How would you _always_ know that an unknown success is ok to release? It could be that it's just not had a chance to have a verification (that may well fail) yet

matt.fellows
2020-06-26 22:17
It feels like for those cases you already have prior knowledge they are compatible. I wonder if it's better for us to make it easier to setup pre existing component status than to do this

phil.endsley
2020-06-26 23:08
@matt.fellows I've been thinking about this all day. I think we're going to run into this same issue, since we're going to roll this out by teams, and some some will implement it quicker than others

phil.endsley
2020-06-26 23:11
So here's my half baked idea: add a flag to `can-i-deploy` that acts kind of like pending pacts do for providers. If a consumer has never had any verifications for a provider, it will warn you, but still allow it? It seems like that would cover the teams are migrating. If there has ever been a verification (pass or fail), it would fail

phil.endsley
2020-06-26 23:13
Haven't thought it through all the way...like if it would work for going to multiple stages. It would work fine until the provider goes to dev? But then, that would block the consumer deploying to prod, because the provider is now in dev? Still some things to think about...just wanted to get my thoughts down somewhere before I lost them

phil.endsley
2020-06-26 23:13
Curious how other companies have done this. Aside from not leveraging can-i-deploy until everyone has pacts?

phil.endsley
2020-06-27 00:02
Yeah, I thought about this more. We would just do each pact in a feature branch and let it sit until the provider gets it implemented. Ideally, teams will have some level of communication so they're on the same level with expectations

princiya.marina
2020-06-27 10:08
has joined #general

princiya.marina
2020-06-27 10:13
Hello everyone :wave: I am trying pact-js for the first time. The tests always timeout and never get executed. I also tried running the pact-js-workshop material, same problem, also the same problem when running in a Docker container. Node version: tried both v10 and v12 MacOS Catalina `Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error` I also tried increasing the jest timeout, but doesn't work. ```console.error node_modules/jest-jasmine2/build/jasmine/Env.js:290 TypeError: Cannot read property 'writePact' of undefined``` Does anyone else have similar problems?

matt.fellows
2020-06-27 11:22
Welcome! Have you tried increasing the timeout?

matt.fellows
2020-06-27 11:23
They definitely work. I might add a Travis build to it just to make sure and make it easy fir people to submit bugs

princiya.marina
2020-06-27 11:31
yes, increased the timeout to even 50000. same problem. so not sure what this problem is :disappointed:

matt.fellows
2020-06-27 11:32
Have you tried the troubleshooting steps shown on the pact is readme?

matt.fellows
2020-06-27 11:33
Are you on a work/corporate network? Are there any errors during installation? What do the debug logs say? Share those results in this thread as attachments/code formatted and we'll see if we can track it down

princiya.marina
2020-06-27 11:40
home wifi. on my local machine, I have a Pact Binary error. ```[2020-06-26T05:52:47.414Z] ERROR: pact-node@10.9.5/48869 on fritz.box: Pact Binary Error: /Users/p.s 1/workspace/admin-web/node_modules/@pact-foundation/pact-node/standalone/darwin-1.85.0/pact/lib/ruby/bin/ruby: line 14: 1/workspace/admin-web/node_modules/@pact-foundation/pact-node/standalone/darwin-1.85.0/pact/lib/ruby/lib/ruby/gems/2.2.0: No such file or directory``` There is a space in my `/Users/p.s 1/` and that's why the error `No such file or directory` . So I tried in a Docker container, the above error isn't there, but the following error: ```[2020-06-26T05:44:25.039Z] ERROR: pact-node@10.9.5/28 on 1693f09a7469: (errno=ENOENT, code=ENOENT) -- syscall: spawn standalone/linux-x64-1.85.0/pact/bin/pact-mock-service -- path: standalone/linux-x64-1.85.0/pact/bin/pact-mock-service -- spawnargs: [ "service", "--consumer", "hero-consumer", "--cors", "true", "--pact_dir", "/usr/app/pacts", "--host", "127.0.0.1", "--log", "/usr/app/logs/pact.log", "--pact-file-write-mode", "update", "--port", "8080", "--provider", "hero-provider", "--pact_specification_version", "2" ]```

elliottmurray
2020-06-27 12:40
Python right? We haven?t implemented that yet. It is actually part of the next frequent in working on

ag.robinson
2020-06-27 15:38
has joined #general

tjones
2020-06-29 02:16
Are you waiting for the setup promises to resolve before trying to run the tests?

matt.fellows
2020-06-29 02:19
it may be a problem with your path

matt.fellows
2020-06-29 02:19
I can see a space and full stop in it - could you please try from a directory without? That may be the bug

matt.fellows
2020-06-29 02:19
Looking at the error above, i?m almost certain that?s the issue

tjones
2020-06-29 02:20
Good pickup.

matt.fellows
2020-06-29 02:23
Sorry I didn?t see your note about that in your prompt there Princiya. Can you please share how you ran that in Docker? My guess is that you?ve synced the mac directory into the Docker container, and os-specific packages are not installed.

matt.fellows
2020-06-29 02:23
so it?s trying to execute Mac binaries that won?t work, or it?s trying to execute the native linux binary (as you can see above) which doesn?t exist

matt.fellows
2020-06-29 02:24
Please ensure if you run in docker, that you exclude `node_modules` and do a fresh `npm ci`

princiya.marina
2020-06-29 05:19
ok, i will try this in a bit @matt.fellows :raised_hands:

chandanakurumeti27
2020-06-29 11:28
Hello , someone please give me example on how to start the two providers at the same time at diff port in `JS`, I have them defined like this, const provider = new Pact({ consumer: ?consumer_authentication?, provider: ?p_ authentication?, host: ?localhost?, port:10002, log: path.resolve(process.cwd(), ?logs?, ?pact.log?), dir: path.resolve(process.cwd(), ?pacts?), logLevel: LOG_LEVEL, specification: 2 }); const provider_savedgames = new Pact({ consumer: ?consumer_savedgames?, provider: ?p_savedgames?, host: ?localhost?, port:10001, log: path.resolve(process.cwd(), ?logs?, ?pact.log?), dir: path.resolve(process.cwd(), ?pacts?), logLevel: LOG_LEVEL, specification: 2 });

chandanakurumeti27
2020-06-29 11:29
If there is only one provider , am starting it like

chandanakurumeti27
2020-06-29 11:30
how can i start/setup both providers running at diff ports inside before hook,please help me on this. Any help would be greatly appreciated !

nicholas.pleschko
2020-06-29 11:38
in your config of the providers it seems like you are missing the ?port? property name: ```new Pact({ // ... other properties port: 10002 })```

chandanakurumeti27
2020-06-29 11:39
yeah sorry, i had them in my code, just missed it here while posting

chandanakurumeti27
2020-06-29 11:40
when i had only one provider, i used to start/setup the provider before running the test as below

chandanakurumeti27
2020-06-29 11:41
Now, how do i make two providers start inside before hook

nicholas.pleschko
2020-06-29 11:41
you could try to run the second provider setup in the `then` of the first setup

nicholas.pleschko
2020-06-29 11:42
provider1.setup().then(() => provider2.setup().then(() => done()) )

chandanakurumeti27
2020-06-29 11:42
I tried this, but not working

nicholas.pleschko
2020-06-29 11:42
how is it not working?

nicholas.pleschko
2020-06-29 11:42
error?

chandanakurumeti27
2020-06-29 11:43
yeah , gimme sec

chandanakurumeti27
2020-06-29 11:43
wil share the error

chandanakurumeti27
2020-06-29 11:45
This is my whole code,

shailesh.wadhwa
2020-06-29 11:45
has joined #general

chandanakurumeti27
2020-06-29 11:46
provider and provider_Savedgames are the ones which i shared before here

chandanakurumeti27
2020-06-29 11:47
In the logs, i can see that

nicholas.pleschko
2020-06-29 11:55
is there really nothing in: ```E, [2020-06-29T13:44:16.518714 #23351] ERROR -- : Interaction diffs for that route:``` or did you remove that from the log?

nicholas.pleschko
2020-06-29 11:57
also are your requests pointing to the right host:port?

matt.fellows
2020-06-29 12:10
Still waiting for the actual error. The problem above is clear to me There are a number of problems here 1. You are setting the same log file for different providers, that is likely to cause issues where one is overriding the other 2. You are using different consumer names from the same project. I would advise against this (it?s the same consumer for two different providers) 3. You are doing what looks like a functional test (expecting an auth, and then doing a request to get games). Where possible, I would test these as separate contract tests. This test is quite high level.



chandanakurumeti27
2020-06-29 12:19
i didnt remove any interaction diffs in the logs , just removed some thing inside req and response bodies and some headers but not anything generated by pact framewokr

chandanakurumeti27
2020-06-29 12:20
@matt.fellows, i will try to see any of your points are what am missing ,Thank you so much

chandanakurumeti27
2020-06-29 12:21
Thank you @nicholas.pleschko for your suggestion

shailesh.wadhwa
2020-06-29 12:42
Hello #here Does anyone have the idea on how to modify a *GraphQL variable* during *Provider Verification*? I have a Pact Interaction for GraphQL Mutation which uses a variable. The variable has to be unique each time Mutation is requested to the Provider. From the way of injecting Authorization header, I tried the *requestFilter* in *Verifier opts* but doesn't know if it can be used for this purpose. Can anybody help, please? Thanks in advance

matt.fellows
2020-06-29 12:56
which language?

matt.fellows
2020-06-29 12:57
In theory you could modify any part of the payload during a request filter - you?d probably need something like https://github.com/apollographql/graphql-tag to do it well, or you could hack the string body that GraphQL creates

martin.hentschel
2020-06-29 14:03
has joined #general

shailesh.wadhwa
2020-06-29 14:27
Hello @matt.fellows, Thanks for your response. The Language is *JavaScript.* Actually, from the following implementation of Provider verification: https://github.com/pact-foundation/pact-js/blob/master/examples/graphql/provider.spec.ts and https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/test/provider.spec.js I got the idea of using *requestFilter in opts.* `requestFilter: (req, res, next) => {}` The example in above link, however, focuses on modifying the request Headers. I'm not sure how we can _extract the Query Payload from the Contract_ and then modify it ? or if there is any other *opts* that can update the GraphQL variable in the contract? Thanks again!!

samycici
2020-06-29 15:28
has joined #general

matt.fellows
2020-06-29 22:09
Req is the full request object. You can mutate it however you like - including the body.

matt.fellows
2020-06-29 22:09
It's a standard express JS middleware

jonathan-pact
2020-06-30 06:57
has joined #general

gauravsingh1095
2020-06-30 07:19
has joined #general

gauravsingh1095
2020-06-30 07:21
Hello team

sairsule
2020-06-30 07:27
I asked this once before, but there were no replies.. so asking again.. In api tests, if provider api is /*users*/{id} and consumer is calling /*user*/{id} this gets caught by pact test. Similarly in message-contracts if provider is writing to topic:Test1 and consumer is listening on topic:Test2, is it caught by Pact?

matt.fellows
2020-06-30 07:57
I responded (https://pact-foundation.slack.com/archives/C5F4KFKR8/p1591006567185000). You can do it, but not all languages currently support this. Java does

sairsule
2020-06-30 08:00
Thanks Matt, I missed that reply

matt.fellows
2020-06-30 08:11
no probs!

amaljayaraj07
2020-06-30 08:27
has joined #general

shailesh.wadhwa
2020-06-30 09:42
Thanks @matt.fellows, So, I tried to log the contents of the `req` and can find the `req.body` as follows: ```body: { consumer: 'UI', state: 'Atleast one item exists', states: [ 'Atleast one item exists' ], params: {} },``` I've attached the Pact file -> ui-graphql_api.json and inside that file, I want to modify `interactions.request.body.variables.itemId` However, as I try to modify the `variables` in body, i get the error ```TypeError: Cannot set property &#39;itemId&#39; of undefined<br> &nbsp; &nbsp;at requestFilter``` Appreciate your response.

matt.fellows
2020-06-30 10:39
That request is the state setup coming in to setup a provider state. You should probably ignore that request (look at the path and don't act if it matches the setup path). The following request will have your actual interaction payload

giuseppe.salvatore
2020-06-30 11:14
The updates to the docs are amazing!! Really great work guys

giuseppe.salvatore
2020-06-30 11:15
:+1:

matt.fellows
2020-06-30 11:41
Thanks so much! You can thanks @bethskurrie for this

giuseppe.salvatore
2020-06-30 16:09
Well... then many thanks to @bethskurrie

giuseppe.salvatore
2020-06-30 16:09
Truly impressive

bethskurrie
2020-06-30 20:49
Thanks for the nice words @giuseppe.salvatore.

yrh.harini
2020-06-30 21:31
has joined #general

shailesh.wadhwa
2020-06-30 23:33
Hi @matt.fellows, In the output of `console.log(req)`, from requestFilter option: ```requestFilter: (req, res, next) => { req.headers['Authorization'] = userToken; console.log(req); next(); },``` I can see two `IncomingMessage` -- one with setup path and other with path apparently for my graphQL query Unfortunately, there is no `body` or *interaction payload* in the request. Infact, I see empty query and params: ```params: {}, query: {},``` Am I missing something here? I'm just trying using `req` object first time. Learning how the middleware works for GraphQL. Thanks again for your responses.

hadjaliabir
2020-07-01 15:37
hello everyone ! how can i create a mockprovider on a specific port ? and how can i verify it was created ? i don't get this code !!

hadjaliabir
2020-07-01 15:38
`public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2("test_provider", "localhost", 8080, this);`

giuseppe.salvatore
2020-07-01 17:09
Hey guys... somebody was challenging me regarding the use of PACT vs Spring Cloud Contracts. Would it be fair to say that those reasons are still applicable and valid? ? PACT has our of the box ready to deploy broker ? PACT supports contracts for REST API as well as messaging services ? PACT has native support for multiple languages, also Spring Cloud does but it's only java so say I am a FE developer I would need to user yaml files or DSL to document my contracts ? PACT has an active community and outstanding documentation (unfortunately I don't know about Spring Cloud, I mean the documentation is pretty good as well) ? PACT broker can interact with Spring Cloud Anything else that you think is worth mentioning? I thing it's fairly good list

rafael.espillaque
2020-07-01 17:11
Not very sure about how this would work on SCC but I?d say that Pact allows for more complex automation and verifications (thanks to Pact broker and Webhooks) than SCC.

rafael.espillaque
2020-07-01 17:13
actually I don?t know if SCC even supports checking a consumer/provider with older versions of the contract (in Pact we?d use the broker, not sure if SCC supports that using the stub jars that are pushed to artifactory/nexus)

rafael.espillaque
2020-07-01 17:14
(I believe SCC also supports REST and messaging)

giuseppe.salvatore
2020-07-01 19:02
yeah I can confirm this one is correct

kristine.jetzke
2020-07-01 19:29
The port is `8080` - you can use a different value

kristine.jetzke
2020-07-01 19:31
To https://kreuzwerker.de/post/writing-contract-tests-with-pact-in-spring-boot > The rule was quite confusing for us as well. It does many things and has a weird name. Most importantly it starts a mock server that will return the expected response and writes the Pact JSON file at the end. I think the easiest way to verify that it works is to write a very simple pact test.

kristine.jetzke
2020-07-01 19:32
In case you?re unsure about rules in general, https://github.com/junit-team/junit4/wiki/Rules

kristine.jetzke
2020-07-01 19:33
If you?re not forced to use JUnit4 I would recommend to use JUnit5, it has become easier

kristine.jetzke
2020-07-01 19:36
Hey, thanks for the list. I agree with all your points and also @rafael.espillaque?s point is very important - it?s not just only about ?ready to deploy broker? but the whole workflow around it.

chifamba
2020-07-01 19:37
has joined #general

kristine.jetzke
2020-07-01 19:38
Additionally, SCC is conceptually different. It definitely started as a provider-driven framework. Consumers had to add their contract to the provider?s repo and wait for the provider to publish a jar. ~tbh I didn?t look into it for a while so I?m not sure if that changed somehow or not.~ Edit: It now supports a consumer-driven approach. But it seems very limited, all contracts need to live in a separate repository. See https://cloud.spring.io/spring-cloud-static/spring-cloud-contract/2.2.3.RELEASE/reference/html/using.html#flows-cdc-contracts-external

kristine.jetzke
2020-07-01 19:48
? PACT generates the contracts based on code and automatically verfies the consumer whereas in SCC you need to manually write the contracts in a separate step


hadjaliabir
2020-07-01 20:38
Thank you so much :slightly_smiling_face: ! another question plz !! *given* and *uponReceiving* was explained in your blog , what about *path* are we supposed to add a path to the api real file.json ?

kristine.jetzke
2020-07-01 20:58
The path is the endpoint you are writing the test for e.g. `/users`

hadjaliabir
2020-07-01 21:14
Ah ! okey ! thank you again :slightly_smiling_face:

harsh.x.parekh
2020-07-01 21:35
has joined #general


matt.fellows
2020-07-01 23:24
If the concepts are confusing and you need more assistance in getting going, doing this ~1 hour workshop will be time well spent. By the end of it, all of the core concepts should be much much clearier

matt.fellows
2020-07-01 23:25
You can connect SCC to the pact broker. But you may lose out on some fidelity (in either the Spring contract or the Pact one). You?ll be forced to a ?common denominator? type situation

matt.fellows
2020-07-01 23:27
I think it?s fair to say that Pact and SCC are fairly comparable. As @kristine.jetzke said - and this is absolutely crucial - is that SCC _does not mandate_ that your consumer code actually generate the contract. It can be hand-cranked outside of the code base. This creates a potential for drift. The leads to the other key difference, that Pact has language specific bindings. Unlike SCC where you would need to write it in Groovy if it wasn?t a JVM code base.

matt.fellows
2020-07-01 23:27
I?d say SCC is probably a bit friendlier if you?re embedded in the Spring ecosystem.

matt.fellows
2020-07-01 23:28
I think it?s fair to say that Pact and SCC are fairly comparable in their stated aims at a test framework. Where Pact differentiates is the broker experience, which you could classify as the CI/CD part of the tool. SCC doesn?t have this, you?d need to build all of the workflows yourself

matt.fellows
2020-07-01 23:28
But you can publish/verify from a broker, Marcin (SCC maintainer) has done an excellent job of getting the ecosystems to work together

phil.endsley
2020-07-01 23:40
Seems like an appropriate time to bring up @bethskurrie's request for help with comparing pact to other frameworks (SCC was specifically asked about) https://pact-foundation.slack.com/archives/C9UN99H24/p1592522585096300 Seems like this is the kind of stuff being looked for

bethskurrie
2020-07-01 23:53
@sklein it's been on my todo list to add an -`--ignore Foo` flag to explictly ignore particular pacticipants. In the meantime, what you can do is explicitly list the pacticipants you care about.


2020-07-01 23:57
A new post has been created in *Feature Requests*


matt.fellows
2020-07-02 01:19
It?s worth a blog post or article on our docs site.

matt.fellows
2020-07-02 01:19
I?ll add to my TODO but #help-wanted



bethskurrie
2020-07-02 01:39
Unrelated to above conversation

matt.fellows
2020-07-02 01:46
wow!

christmagri
2020-07-02 06:12
has joined #general

greg.tyler
2020-07-02 09:43
has joined #general

tesnim.rabeh
2020-07-02 14:15
has joined #general



hadjaliabir
2020-07-03 11:13
Hello everyone ! do you have An example of running provider verification using java maven ?

matt.fellows
2020-07-03 11:31
What have you found so far?

hadjaliabir
2020-07-03 12:21
i found many examples using springboot, it was complicated for me !


hadjaliabir
2020-07-03 14:19
Yes exactly !

a.catalucci
2020-07-04 10:28
has joined #general

hadjaliabir
2020-07-04 19:28
well i did it :smile: , still is it possible to load my API to the provider code ?

matt.fellows
2020-07-04 22:39
Sorry I don't understand the question Abir?

hadjaliabir
2020-07-05 09:58
i want to compare my pact with my real API to retrieve id etc..

matt.fellows
2020-07-05 10:48
Thanks but I'm still not understanding your question. How are you validating it now if your not testing against your real provider? And when you say real, do you mean running against a local checked out version of the provider (e.g. a ci build) or production?

matt.fellows
2020-07-05 10:48
It will be helpful for you to share Daniel code so we can understand what you're doing as well as what you've done so far

hadjaliabir
2020-07-05 11:25
https://github.com/eugenp/tutorials/tree/master/libraries-5 -------------- https://github.com/eugenp/tutorials/tree/master/spring-resttemplate ------------------ https://www.baeldung.com/pact-junit-consumer-driven-contracts --------------- i used this project to understand the concept then i retrieved the consumer and provider code only so now i have this : https://github.com/abirbha/pactProject

hadjaliabir
2020-07-05 11:30
Yes exactly ! i mean running against a local checked out version of the provider


matt.fellows
2020-07-05 11:35
There are heaps of provider tests examples you can borrow. See the Pactflow GitHub org also

hadjaliabir
2020-07-05 11:46
Thank you so much !!! am so confused as you can see because am an automation tester and found myself dealing with springboot and Pact for the first time ! thank you again for your help :blush:

matt.fellows
2020-07-05 11:58
Ah ok, you're doing great. Most of the hard work is going to he navigating source code in consumer/provider side, and the specifics of the test frameworks, build tools etc. If you have access to a Dev on the team they'll be able to accelerate things. Pact is just a test tool that you'll need to make work in your specific env. Good luck!

suma.surabhi
2020-07-05 12:10
has joined #general

francesco.bartoli
2020-07-05 17:46
has joined #general

dirkbolte79
2020-07-06 06:43
has joined #general

dirkbolte79
2020-07-06 06:52
Hi - I?m currently using pact in a scenario where the server is returning a JWS with JSON as payload. From what I found so far (e.g. https://stackoverflow.com/questions/44087197/encoded-encrypted-body-before-verifying-a-pact ), there is no built-in support for this. I wonder whether this would be a doable extension to pact and whether you would accept a PR which adds it.

uglyog
2020-07-06 07:07
Depends, is the actual payload in the claims and you just need to encode as JWT on the one side, and decode on the other? Or do you need to verify with the signature as well?

dirkbolte79
2020-07-06 07:09
long term, a signature validation would be nice, but that would probably require to pull in another library which might be ideal. So for the time being, For the time being, checking the actual payload would be more than sufficient

uglyog
2020-07-06 07:18
I think that can be a workable extension

dirkbolte79
2020-07-06 07:18
so would it be ok if I give it a try?

vasile.pop971
2020-07-06 07:43
has joined #general

vasile.pop971
2020-07-06 07:49
Hi there. Is there any way of having some rigid contracts? I have one situation where the contract must be strict, if a new field comes from the provider, the provider test must fail.

abubics
2020-07-06 08:28
It's generally possible, but not really in the spirit Pact. If you do that, then most categories of backwards-compatible change are broken. My main question becomes: what is the deploy sequence if you want to make an API change?

philipp.walser
2020-07-06 09:18
has joined #general

matt.fellows
2020-07-06 09:27
Why would you want that out of interest?

matt.fellows
2020-07-06 09:27
Pact follows Poster's Law on this, so it's not possible with pact as I understand

philipp.walser
2020-07-06 09:51
Hi there. I would be interested in using the new Beta-Features wip-contracts/pending contracts. We played around with Pact a bit for some time and now want to make use of the full feature set in one of our new projects. Of course, we would not need the feature 'right now', but thought when we set everything up from scratch now, why not incoorperate the latest features which sound like we want to have them anyways




bethskurrie
2020-07-06 09:55
These will get you going

vasile.pop971
2020-07-06 09:55
service A has new or updated entities, sends those via Kafka, service B is consuming data from topic, but for reasons out of my hand the deserialization is done to some strict models

bethskurrie
2020-07-06 09:55
Nope, not possible with Pact. You'd need another tool.

bethskurrie
2020-07-06 09:56
Bummer

bethskurrie
2020-07-06 09:56
That's an unfortunate architecture.

vasile.pop971
2020-07-06 09:56
I completely agree

bethskurrie
2020-07-06 09:56
Sounds like the old JVM wsdl parsing

vasile.pop971
2020-07-06 09:56
yeah, and it's Python, should NOT be like this

bethskurrie
2020-07-06 09:58
Filter?

vasile.pop971
2020-07-06 09:59
I'm working on understanding why this is architectured like this

bethskurrie
2020-07-06 10:04
The more stupid something seems, the weirder the back story!

michael
2020-07-06 12:20
has joined #general

sklein
2020-07-06 12:57
Awesome! Thanks @bethskurrie

philipp.walser
2020-07-06 13:58
I completely missed the existence of http://docs.pact.io/wip, I only checked https://docs.pact.io/pending ...so all I am missing is `PACT_BROKER_FEATURES=pacts_for_verification` Thanks for the links!

hadjaliabir
2020-07-06 14:02
Hello ! how can i resolve "failed to invoke pact method "

elliottmurray
2020-07-06 14:20
maybe include more information? And what pact language? Have you checked faq?s etc?

hadjaliabir
2020-07-06 14:25
java/junit/eclipse, i added the jars using build path

elliottmurray
2020-07-06 14:41
#pact-jvm-help

elliottmurray
2020-07-06 14:42
Though I think you would be best getting it running from gradle/mvn and working back from there

giuseppe.salvatore
2020-07-06 17:22
Hi guys, is there a way to specify the content-type in the response section generated in the contract from the consumer side?

giuseppe.salvatore
2020-07-06 17:23
I mean I know how to set it in the request

giuseppe.salvatore
2020-07-06 17:23
not sure how to set it in the response returned by the mock

giuseppe.salvatore
2020-07-06 17:52
sorry dumb question... already found the answer

aliaksandr.valadzko
2020-07-06 21:21
has joined #general

bethskurrie
2020-07-06 23:27
@giuseppe.salvatore did you find it via the new search in http://docs.pact.io?

bethskurrie
2020-07-06 23:27
I'll update the pending page too

abubics
2020-07-07 00:05
The thing is . . . while Pact doesn't support rigid contracts, you can still use it for theoretical non-breaking contract tests, and just let the unit tests break on deserialisation. Until you migrate to an architecture that doesn't require paired deploys, it may still be useful?

giuseppe.salvatore
2020-07-07 08:44
na it was just me being so dumb not being able to remember the code I wrote a couple of months ago.

charu.agarwal
2020-07-07 11:39
has joined #general

jlammers
2020-07-07 13:34
has joined #general

camila.pinto-ext
2020-07-07 14:10
has joined #general

fernando.martin
2020-07-07 14:20
has joined #general

bheemreddy181
2020-07-07 15:46
Can we still use pact for provider driven testing where there is no two way feedback loop in place ? like i push a contract manually to pact broker and use that for verifying my provider side implementation in future

bethskurrie
2020-07-07 20:18
You can push any json resource you like into the broker, but the URL structure is designed for the contract to come from the consumer, not the provider.

chawlapriyanka29
2020-07-08 00:09
In consumer driven contract approach as an when the consumer published a contract which breaks the providers build, I am not aware why the failure has occurred.. Is there a utility to that can help me to provide the exact reason. ?

matt.fellows
2020-07-08 00:15
In Pactflow, we have a UI feature that allows you to see the failures and dig into it: https://pactflow.io/blog/verification-results/

matt.fellows
2020-07-08 00:16
It?s backed by an API, so all of the verification results (if you?re publishing to the broker) are there

matt.fellows
2020-07-08 00:16
but having access to the provider?s build output should be enough to diagnose the problem, usually

chawlapriyanka29
2020-07-08 00:28
Is there a way to implement this using pact-pyton ?

matt.fellows
2020-07-08 00:29
implement publishing verification results?

chawlapriyanka29
2020-07-08 00:33
And while publishing I should set publishverificationResult as True. Right ?

bethskurrie
2020-07-08 01:45
Yes, the interaction level results are published in pact python @chawlapriyanka29

bethskurrie
2020-07-08 01:46
There's no UI to look at them, but you can use the API browser

anilbms75
2020-07-08 12:40
has joined #general

sklein
2020-07-08 14:04
@bethskurrie i changed to explicitly specifying dependencies as suggested. I'm finding though that this isn't actually limiting `can-i-deploy` to only verifying the pact between the two explicitly stated pacticipants (i.e. one expected verification result) but rather it is running the verification against all dependencies for both pacticipants (many verification results). In other words if I specified ```can-i-deploy --pacticipant consumer --version some-version --pacticipant provider --version some-version``` I expect... | consumer | some-version | provider | some-version | true | not ... | consumer | some-version | provider | some-version | true | | some-other-consumer | version | provider | some-version | false |

bheemreddy181
2020-07-08 17:09
Our consumers are from different org and are not in a position to write contracts - we were thinking to publish contracts similar to how consumer publishes it

nirupma.rim
2020-07-08 17:28
has joined #general

bheemreddy181
2020-07-09 02:39
Can we call Contract Tests as `Contractual Functional Tests as Provider Implementation is not mocked mostly`

matt.fellows
2020-07-09 02:40
I mean, it?s a bit of a mouthful :stuck_out_tongue:

matt.fellows
2020-07-09 02:40
What?s the intent behind it?

bheemreddy181
2020-07-09 02:44
Just curious if we can call so - it is hard at times to convince people around if it just a contract tests - as we are validating more than schema at times ( like we get a value back in the response )

abubics
2020-07-09 03:51
That really depends how deep into your provider you go. I wouldn't say that most people leave the "provider implementation not mocked mostly". My preference, for example, is to treat is as a unit test for the network interface, and go just barely to the boundary of domain logic to start stubbing.

bethskurrie
2020-07-09 03:53
It is more than schema validation, because it links the requests to the responses, so you can be sure you understand all the different scenarios.

bethskurrie
2020-07-09 03:55
That being said, you can validate a pact against an OAS doc, which is just schema validation. You then have to make sure the oas doc is 100% accurate however, which may well include a step which is basically like the pact verification.

bethskurrie
2020-07-09 03:56
If you stub too much of your business logic, you can easily end up in the situation where your pact passes, but in real life, it fails, because you stubbed out critical things that make it behave differently. The recommendation is to see if you can not stub, and then just add in the stubs that you absolutely need to get the pact verification to pass reliably.

bethskurrie
2020-07-09 03:58
Yes, it's a functional test in that you're executing real functionality, but it's the response you're looking at, not the side effects, and checking for side effects is a critical part of functional testing.

bethskurrie
2020-07-09 04:00
With contract tests, we're not asking "did you save the new resource correctly?" we're asking "do you return the expected response when I send you a request to create a resource?"

bethskurrie
2020-07-09 04:01
Other tests within the provider test suite should be asking the "did you save the new resource correctly?" question.


tjones
2020-07-09 05:01
I think of it as ?contract tests with functional coverage? - my view is that it?s advantageous for your contract tests to cover some of the business logic in the provider, but that they shouldn?t be viewed as a tests *for* that business logic. It does depend on your provider architecture.

matt.fellows
2020-07-09 05:47
Most importantly, it needs to be a deliberate part of an overall test strategy. If it's more work to maintain pact (or whatever other tool) and tests duplicates what other tests suites do, that's a recipe for developer frustration

matt.fellows
2020-07-09 05:48
As Tim says, sometimes it covers functional stuff as a happy coincidence, but not necessarily as its purpose

tjones
2020-07-09 05:50
I like covering the functional stuff where possible because you?re saying ?does the provider respond with the expected response in at least one scenario?, rather than ?is there code in the provider that could produce the expected response?. Both are valuable tests, though - and as Matt and Boris have both said, it?s essentially down to your values and taste.

matt.fellows
2020-07-09 06:20
yep

matt.fellows
2020-07-09 06:20
FWIW I tend to do the opposite of what @abubics says. I tend to mock at the edges as far as possible. I use the ?hermetic server? approach, where I basically mock any external collaborators (the the possible exception of database, or database like things because Docker usually works quite well there)

tjones
2020-07-09 06:25
> I tend to do the opposite of what @abubics says. I want to take this quote out of context and be like ?me too?, but it would just be sass. I like working with Boris. Even when we don?t do things the same way :joy:

matt.fellows
2020-07-09 06:26
It is certainly a mis-quotable quote

matt.fellows
2020-07-09 06:26
but it also talks to the complexity of doing testing well

matt.fellows
2020-07-09 06:26
there are (probably) no absolutes, other than the rule of ?no absolutes?

bethskurrie
2020-07-09 06:27
I realised I totally misread what @abubics does.

matt.fellows
2020-07-09 06:27
_waits for wrath_

sinanargun48
2020-07-09 12:45
has joined #general

bheemreddy181
2020-07-09 15:21
thankyou all for these insights

rodrigocs
2020-07-09 16:27
has joined #general

mfujiki
2020-07-09 18:52
has joined #general

2020-07-09 22:52
A new post has been created in *Feature Requests*

matt.fellows
2020-07-10 07:46
@dattasai.chunduru please see https://docs.pact.io/docker#docsNav

dattasai.chunduru
2020-07-10 07:47
Hi Can anyone please let me know can we directly execute our PACT Scripts in Docker containers directly or it need any specific setup for doing execution. In our current project we are executing our Automation scripts in docker so we want to execute the pact scripts also in docker

matt.fellows
2020-07-10 07:48
the answer is yes, are you just asking to know if its possible or are you having issues?

dattasai.chunduru
2020-07-10 07:52
I have not yet implemented it . I have to implement I am using Java for Pact scripts

matt.fellows
2020-07-10 07:53
ok. If you?re using Java, then there is nothing specific to Pact to worry about (as per the article linked).

matt.fellows
2020-07-10 07:54
Are you familiar with Docker and Java?

dattasai.chunduru
2020-07-10 07:57
I know little bit of docker as we are using it in our selenium scripts. But in that we are running the yaml file and integration the Selenium GRID with scripts.

dattasai.chunduru
2020-07-10 07:59
My query is like I have a consumer and provider poc scripts all ready and working now I want to execute them in docker container. For this do we have any yaml file to pull the image ? and do we need to do any changes in our consumer or provider side scripts ?

matt.fellows
2020-07-10 08:05
what YAML file are you referring to - a docker-compose.yml or something else?

matt.fellows
2020-07-10 08:05
:point_down: let?s move into a thread

matt.fellows
2020-07-10 08:05
do you use Maven/gradle or something else? I?d be googling ?how to run maven/gradle in docker?

dattasai.chunduru
2020-07-10 08:06
I am using Maven Matt

matt.fellows
2020-07-10 08:32
Cool, then if you already have a working PoC using Maven, there is no reason you shouldn?t be able to run your maven project within docker

hadjaliabir
2020-07-10 10:01
Hello everyone ! Can i generate pact form Swagger documentation ?



jacob.raihle
2020-07-10 11:51
has joined #general

christoffer.lindstrom
2020-07-10 12:26
has joined #general

hadjaliabir
2020-07-10 13:51
thank you :)

dattasai.chunduru
2020-07-10 16:18
Hi All I am deleteing a resource in PACT and in response I will not have content-type/json header . I want to make the header validation as optional. I have not given the headers in response validation. But my Scripts are still failing with error Failed tests: runTest(deleteconsumer.PactBaseConsumerTest): Pact Test function failed with an exception, possibly due to Mismatches(mismatches=[PartialMismatch(mismatches=[HeaderMismatch(headerKey=Content-Type, expected=application/json, actual=, mismatch=Expected a header 'Content-Type' but was missing), BodyTypeMismatch(expected=application/json, actual=text/plain)])])

dattasai.chunduru
2020-07-10 16:19
Please find my Code Snippet

dattasai.chunduru
2020-07-10 16:19
can anyone please help me on how to make the headers validation optional

phil.endsley
2020-07-10 16:23
It looks like you're making the header required when you build the pact The second line of `createPact` method `headers.put("Content-Type", "application/json");` Then in the builder, `.headers(headers)`

dattasai.chunduru
2020-07-10 16:44
I am deleting the record by passing request body

dattasai.chunduru
2020-07-10 16:44
and the request body is of Json type so I have to pass it as headers

phil.endsley
2020-07-10 16:46
It doesn't look like you're passing a body in your test

dattasai.chunduru
2020-07-10 16:51
I am passing data

dattasai.chunduru
2020-07-10 16:51
.body() I am sending data

dattasai.chunduru
2020-07-10 16:51
now im getting error only body mismatch

phil.endsley
2020-07-10 16:53
`.body()` is in `createPact()` , which is just defining the contract. When you're making the REST call in `runTest()`, you're not sending a body. It's just making a DELETE call to the url

dattasai.chunduru
2020-07-10 16:55
can you give me syntax for how to do it

dattasai.chunduru
2020-07-10 16:56
in RESTTEMPLATE I can not pass body right

phil.endsley
2020-07-10 17:02
This is a spring boot question. You can use `restTemplate.exchange` and build a `RequestEntity`

dattasai.chunduru
2020-07-10 17:11
sorry to ask but can you please give me syntax for my example please

dattasai.chunduru
2020-07-10 17:11
I am not able to build it

phil.endsley
2020-07-10 17:13
It should be something like ```RequestEntity<YourEntityObject> requestEntity = new RequestEntity<>(body, HttpMethod.DELETE, uri); restTemplate.exchange(requestEntity, YourResponseType.class);```

dattasai.chunduru
2020-07-10 17:24
This will work for HTTPS Methods also @phil.endsley

phil.endsley
2020-07-10 17:26
Yes, HttpMethod is just the verb (GET, PUT, POST, DELETE, etc...) of the request. The uri is what determines the protocol

chriscrawford80
2020-07-10 17:37
has joined #general

dattasai.chunduru
2020-07-10 17:55
@phil.endsley Thanks a lot phil it is working perfectly

krisdinesh
2020-07-12 13:14
Hello @all - is there a pact workshop repo for dotnet as like java, ruby and js? If yes, kindly share the link.


2020-07-13 02:13
A new post has been created in *Feature Requests*

bethskurrie
2020-07-13 03:22
removed an integration from this channel: https://pact-foundation.slack.com/services/BQE9MSRH6

krisdinesh
2020-07-13 03:49
Thanks a lot @uglyog!!

matt.fellows
2020-07-13 08:36
sorry for the spam. But with the GH issues going on today, note that some of the dependencies (e.g. Pact JS) that depend on github artifacts will be failing. :clap: to companies with caching proxies, :hugging_face: ?s to those without (including, ah, Pactflow)

matt.fellows
2020-07-13 08:37
(intermittently - hit that rebuild button!)

ayyamuthutechnical
2020-07-13 11:09
@bethskurrie, we have developed our services using aws and we will not have the services/provider in our local machine. When we asked developer team they said is tough to setup the services code in local. They are giving only the endpoints for provider. In this case, how to test the provider using pact.

matt.fellows
2020-07-13 11:22
Which language are you using? It shouldn't matter in most cases, pass the URL of the running service (i.e. the deployed one) to the verification process as you would if it was a local service

matt.fellows
2020-07-13 11:22
What have you tried?

ayyamuthutechnical
2020-07-13 11:49
@matt.fellows, i am using javascript for testing the consumer side and python for testing the provider side.


danhitchcock
2020-07-13 13:30
@ayyamuthutechnical You should just be able to change the ``` --provider-base-url``` To point to the provider, and if you've setup the command correctly it should just 'work' however, you might need to authenticate i am guessing? unless this script is running against the publicly facing service. I've just finished an e2e with the same technologies as you (but google instead of AWS) so I may be able to help you out.

greet_bot
2020-07-13 13:54
has joined #general

ayyamuthutechnical
2020-07-13 14:30
@matt.fellows and @danhitchcock, Thanks for the update. Now i got it, i will work and let you know if i face any issues.

jonathan.johnson
2020-07-13 15:36
has joined #general

jonathan.johnson
2020-07-13 15:41
New here, have a container pact/postgres setup question and requesting a reality check,

jonathan.johnson
2020-07-13 15:48
When pact-broker (via a k8s Pod) attempts to start getting error; `Sequel::DatabaseConnectionError: PG::ConnectionBad: FATAL: password authentication failed for user "pactbroker"` Postgres is running as a separate container, however I did not run the setup as described here: https://github.com/pact-foundation/pact-broker-docker/blob/master/POSTGRESQL.md as I was hoping that would auto-magically be done by pact-broker on first connection. Running postgres in K8s and thinking all the steps in the "Running Postgresql via Docker" document need to be done in an initContainer for the postgres Pod.

jonathan.johnson
2020-07-13 16:19
^ No, to answer my own question. It appears the documentation is about steps that are also automatically run at pact-broker startup.

matt.fellows
2020-07-13 23:45
Yes, as long as you setup the correct authentication details/database connection string, it should automatically create all of the things

matt.fellows
2020-07-13 23:45
Everything all sorted now? (also FYI perhaps ask any future q?s in #pact-broker)

chawlapriyanka29
2020-07-14 00:21
So my Pactbroker Webhook for now invokes a Jenkins job. But my requirement is to fetch the Jenkins Job ID so that the consumer can take reference of the Jenkins Job and look at the console output to check the required details. So my question is, is it possible to get the Jenkins Job Id which the Webhook actually triggers ?

matt.fellows
2020-07-14 00:30
Hi Priyanka, you can?t do that at the moment. The webhook is a fire-and-forget type request. Why do you want the consumer to be able to see the results of the webhook? That feels like a recipe for a complicated pipeline

bethskurrie
2020-07-14 00:48
You can look at the webhook logs via the api

bethskurrie
2020-07-14 00:49
But that's a manual process.

bethskurrie
2020-07-14 00:50
@jonathan.johnson typically the permissions required to create the instance of the database are not ones you want to give to your application

bethskurrie
2020-07-14 00:50
The application should have a user that only has permissions to modify tables and views within that particular instance/schema (depending on your terminology)

bethskurrie
2020-07-14 00:51
So, the creation of the database and a user for the app should be done before running the app, by an out of bound person/process.

bethskurrie
2020-07-14 00:52
The table migrations are done automatically by the app on start up however.

mathildecaron94
2020-07-14 02:13
has joined #general

jason
2020-07-14 06:05
has joined #general

aliaksandr.valadzko
2020-07-14 09:48
Hello:slightly_smiling_face: I try to set up Pact Provider tests in java using `@RunWith(PactRunner.class)` To initialize Spring beans I have to use `BeforeClass` section: ``` @BeforeClass public static void contextSetUp() { AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); context.register(PactContext.class); context.refresh(); SomeServiceMockStubs = context.getBean(SomeServiceMockStubs.class); ... }``` Is there a chance to simplify it, and use `Autowired` annotation like it is done in `@RunWith(SpringJUnit4ClassRunner.class)` ? ``` @Autowired protected SomeServiceMockStubs someServiceMockStubs;``` Thanks in advance!

bethskurrie
2020-07-14 09:48
Hi @aliaksandr.valadzko.

bethskurrie
2020-07-14 09:49
Please ask in #pact-jvm

aliaksandr.valadzko
2020-07-14 09:49
Thanks a lot!

matt.fellows
2020-07-14 10:55
June edition of the Pactflow POST is out: https://mailchi.mp/pactflow.io/pactflow-post-july-2020 @tjones and @yousafn - you?re famous(ish)

tjones
2020-07-14 10:57
Is that stats from the blog post?

matt.fellows
2020-07-14 11:00
Early stats from the campaign (i.e. the top clicks for content within the newsletter)

matt.fellows
2020-07-14 11:01
Or put another way, Yousaf?s twitter handle and then jest-pact have the top clicks so far

chris.mitchell
2020-07-14 12:10
has joined #general

jonathan.johnson
2020-07-14 18:40
All set now. It's working fine. I'll have a learning resource in a day or two to share with the community.

jonathan.johnson
2020-07-14 18:47
@bethskurrie Thank you for the helpful feedback. I understand the balance between automating this as much as possible and also the needs for a hardened solution for production. It's working now. Over the last 3 years I have been giving a 90 minute talk on CDC/Pact at NoFluffJust Stuff. We have a conference this week and I'm finishing up the revision for the talk for this Friday. Here is the links to the Katacoda scenario, but it will not be public until late into this evening :slightly_smiling_face: https://katacoda.com/javajon/courses/kubernetes-pipelines/cdc-with-k8s

bnacey
2020-07-14 21:26
has joined #general

uladzislau_danilchyk
2020-07-15 08:11
has joined #general

uladzislau_danilchyk
2020-07-15 08:12
Hi all! Is there any example how to write a contract for a negative scenario with 4xx errors? I faced the issue that HttpClientErrorException is thrown instead.

matt.fellows
2020-07-15 08:31
You probably need to configure your http client not to throw an exception in that case. Pact will send the 4xx if you ask it, so your code needs to be able to handle it

uladzislau_danilchyk
2020-07-15 08:33
Maybe you have an example on how to handle such cases? I didn't found any examples in pact-jvm or workshop repos.


kristine.jetzke
2020-07-15 08:43
it should not be an issue that the exception is thrown

kristine.jetzke
2020-07-15 08:45
for the contract generation - you just need to make sure your test passes

uladzislau_danilchyk
2020-07-15 08:46
@kristine.jetzke I see that ExpectedException is used. But in our case we are not using DSL. We'are using groovy with the following asserts: ```assert pactResult instanceof PactVerificationResult.Ok```

kristine.jetzke
2020-07-15 08:47
The ExpectedException is from Junit - in your testing library there should be something similar to handle the case that you expect an exception to be thrown

uladzislau_danilchyk
2020-07-15 08:49
@kristine.jetzke ok. But I have one more question to your. In our project we need to customize Bad Request response or Unauthorized response. What should we do to match Bad Request response to expected?

uladzislau_danilchyk
2020-07-15 08:50
Did you got my question? We don't need to just get 400 status and that's it. We need to match response schema of Bad Request response to expected.

kristine.jetzke
2020-07-15 08:52
ah you mean the JSON?

uladzislau_danilchyk
2020-07-15 08:53
@kristine.jetzke yep. For the Bad Request response we have custom json response like: `{"code": "2", "message": "Some message about the code."}`

kristine.jetzke
2020-07-15 08:54
do you parse this in your client code?

kristine.jetzke
2020-07-15 08:54
i mean does the method that calls the provider return this kind of error object?

uladzislau_danilchyk
2020-07-15 08:55
@kristine.jetzke I don't know how to validate such case.. No. It just throws an HttpClientException

uladzislau_danilchyk
2020-07-15 08:58
@kristine.jetzke I just thought about such solution: Create custom error handler for Bad Request and convert it into custom exception object instead of using common HttpClientException

kristine.jetzke
2020-07-15 08:59
but does your client really care about the json response? if it does not do anything with it, I would not cover it with a contract

uladzislau_danilchyk
2020-07-15 09:00
@kristine.jetzke I know. But in our case we need to do this and we haven't another options.

kristine.jetzke
2020-07-15 09:01
why do you need to do this?

uladzislau_danilchyk
2020-07-15 09:02
to clarify what was actually wrong: 1. combination of product and category is wrong 2. request params are not valid

kristine.jetzke
2020-07-15 09:17
but in order to do that you do need to parse the provider response, don?t you?

uladzislau_danilchyk
2020-07-15 09:18
@kristine.jetzke Yep. I need to parse. But I thought that there is a solution for such cases or similar to handle negative cases with statuses and responses out-of-the-box in Pact.

kristine.jetzke
2020-07-15 09:20
I still don?t quite get if you need to do the parsing for your application itself or just the contract test. If it is for your application, pact cannot really provide you anything because it is not part of your application. If it is for your application, I would suggest to do the parsing in the client code and transform it into a business object which you can then assert in your unit test.

kristine.jetzke
2020-07-15 09:21
Or a custom exception as you mentioned above using a custom error handler (depends on your general design approach in the application)

uladzislau_danilchyk
2020-07-15 09:22
@kristine.jetzke. Yes. I thought about second choice but still thought that such OOTB functionality exists in Pact to handle negative cases.

uladzislau_danilchyk
2020-07-15 09:22
@kristine.jetzke thanks again!

matt.fellows
2020-07-15 09:57
> @kristine.jetzke. Yes. I thought about second choice but still thought that such OOTB functionality exists in Pact to handle negative cases. Can I ask - what would expect Pact to do in this scenario? I'm wondering if there is a misunderstanding of the tool. Pact's job is to respond as the tests tells it to and then check that your code actually hit the endpoint. All assertions and checks are up totally up to your code. Think of it as a unit test of your client code, that just so happens to produce a contract as a handy side effect

uladzislau_danilchyk
2020-07-15 11:13
@matt.fellows, so I will tell you my case. In our project Bad Request / Unauthorized requests have customized response and are being part of contracts as well. We need to be sure that consumer correctly handles such responses of negative scenarios. It's not being a functional tests, we don't want to do this for every REST endpoint. It uses globally in project and we just need one test per type of such requests (BadRequest/Unauthorized) just to be sure that it handled correctly. Have you got my point?

matt.fellows
2020-07-15 11:26
totally and thanks, that?s quite normal

matt.fellows
2020-07-15 11:27
My question was more what were you expecting Pact to do ?OOTB? for you?

uladzislau_danilchyk
2020-07-15 11:32
@matt.fellows ok. Got it. I'm expecting that it can be approach to write a test case/interaction with negative scenarios where I can put status and expected response and pact will not fail test results with an exception but it will compare expected response and status like in normal/positive interaction. In addition to that I don't need to put custom logic around test to tell junit "You shouldn't fire exception.". I just need to tell junit "Hey. I will use Pact and it can handle bad request, compare responses, and will not fire exception"

uladzislau_danilchyk
2020-07-15 11:47
@matt.fellows what do you think?

yousafn
2020-07-15 17:41
axios and some other clients will throw an error if they encounter a non 2xx/3xx response. If you need to do some matching on the response of the error body, you need to handle that in a catch, and stop your application throwing. Of course if it doesn?t match your conditions, you then throw the caught exception.

yousafn
2020-07-15 17:43
your client code needs updating by the sounds of it, as @matt.fellows has eluded to, you can configure pact to return any kind of response back that you want. Your test runner may also need to be configured differently, for example I have to set out my jest tests for things that will throw exceptions in a test (so its handled) otherwise jest will complain. This then allows me to inspect various things after an error scenario has occurred

yousafn
2020-07-15 17:44
I think understanding how your http client, and your testing framework handles error, so that you orchestrate your tests correctly is your first port of call. If your not a developer and sit on the testing side, look at your existing codebases unit tests, there will be examples of these types of things all over the place

yousafn
2020-07-15 17:45
if there isn?t, you don?t have enough unit test coverage :thumbsup:

bethskurrie
2020-07-15 23:39
Does anyone know how to disable the preview feature for Github links? I find it very annoying to have large slabs of code or markdown appearing in my conversations, especially when they're in a narrow thread. I always remove it when I'm on my desktop, but it can't be removed from a mobile client, and I'm often answering questions and pasting links from my phone. I've looked through all the Slack settings I can find, and can't work out where to disable it.

jonathan.johnson
2020-07-16 03:04
I just completed a free, public Katacoda scenario to help teach Pact. It will soon be in the O'Reilly learning subscription universe as well. I will be teaching with it during a NoFluffJustStuff webinar on Friday. If any expert here can run it and make sure I did not make a misstatement, etc. that would be a huge help. Basically, looking for a reality check. https://katacoda.com/javajon/courses/kubernetes-pipelines/cdc-with-k8s

bethskurrie
2020-07-16 03:05
Awesome stuff @jonathan.johnson!

bethskurrie
2020-07-16 03:05
I'll have a look at it

jonathan.johnson
2020-07-16 03:06
Thanks Beth, Pact is awesome.

bethskurrie
2020-07-16 03:13
I did a quick scroll through the pages and the two things that jump out me are: * Front page, "set up a Pack Broker on Kubernetes" should be "Pact Broker" * Image missing on step 3

bethskurrie
2020-07-16 03:13
You gave me a few chuckles.

bethskurrie
2020-07-16 03:14
(Not related to the typo, I mean, your actual content was humorous, just in case that wasn't clear!)

bethskurrie
2020-07-16 03:16
Can we link to this from http://docs.pact.io?

matt.fellows
2020-07-16 03:18
> write a consumer that defines and published Pact contracts publishes? > verify the consumer Pacts against a producer pacts

jonathan.johnson
2020-07-16 03:19
Linking from http://docs.pact.io would be and honor, yes!

jonathan.johnson
2020-07-16 03:19
I will fix all these great finds now. Thank you!!!

matt.fellows
2020-07-16 03:20
step 4: > Here is one consumer. The Node.js code is independent of the Kubernetes cluster and by running a Pact test is creates a Pact contract running a Pact test _it_ creates a Pact contract

matt.fellows
2020-07-16 03:21
I have to run to a meeting shortly, but so far it?s very good

matt.fellows
2020-07-16 03:21
all of the commands ?just worked? so far

matt.fellows
2020-07-16 03:22
one of the LOLs Beth?

bethskurrie
2020-07-16 03:22
yes. how did you know?

bethskurrie
2020-07-16 03:22
:laughing:

jonathan.johnson
2020-07-16 03:22
@matt.fellows Thank you. I added a link to your recent article.

matt.fellows
2020-07-16 03:23
I saw that - thanks!

matt.fellows
2020-07-16 03:23
Also, I have _not_ come across Marie Drake before. Cool!

jonathan.johnson
2020-07-16 03:23
The un-un publish joke is actually a tip of the hat to Beth as I saw your recent command on JS written in 10 days, what did your expect.

bethskurrie
2020-07-16 03:24
hahaha

jonathan.johnson
2020-07-16 03:24
Yeah, I wanted to call her out. Don't know her, but has good stuff.

bethskurrie
2020-07-16 03:24
The only sticker I have on my laptop says "NOTICE: Employees must wash hands after using Javascript"

jonathan.johnson
2020-07-16 03:26
I agree, I was not happy with the Node experience in this npm node thing. Freaking environment variables - why are they reinventing a wheel.

jonathan.johnson
2020-07-16 03:26
dont get me started.

bethskurrie
2020-07-16 03:26
I'll be honest, the most recent ES6 is just about a proper language. But it does still drive me nuts.

jonathan.johnson
2020-07-16 03:33
If aliens came to our blue marble and audited us for readiness for space travel then they would leave as soon as they saw Javascript. Yup, you need to evolve more, bye.

bethskurrie
2020-07-16 03:33
HA!

g.pou
2020-07-16 04:42
has joined #general

matt.fellows
2020-07-16 08:05
Has anybody used Karate framework before? Care to take a stab at the pros/cons of using something like Karate over Pact?


yousafn
2020-07-16 08:24
I used Karate around 5 years ago and brought it in at a client to perform CDC, we used wiremock to spin up mock providers. Since then Karate has evolved to cover things like load testing / ui testing / mocking and cdc. I found it really easy for non-technical testers as gherkin steps are available for all the API functions but depending on the implementation, it can be badly abstracted which overs little detail on what is sent. `Given I have sent a valid request` but that is the same with any gherkin based implementation, often used to abstract code away from the users (testers) it clouds understanding imo. The maintainer is a bit of a character and tends to have it out with a few other big players in the api testing world but he is awesome, listens to his community and is always smashing out features. I?m not sure what their CDC offering looks like, and if they have a pact broker style portal to view contracts, as that is one of the killer pros in pact. Back when we used in all them years ago, visibility of the contracts to providers was always an issue, and again like our current scenario, full buy in across the teams was a big issue. Maybe the value proposition of the benefits of this testing approach especially in CI/CD wasn?t sold well enough.

matt.fellows
2020-07-16 08:27
Interesting, thanks (and absolutely no surprise you responded to this :stuck_out_tongue: )

matt.fellows
2020-07-16 08:27
Btw your Cypress spike is going to get some love from me. I had a call with Randall (co-founder Cypress) last night. He was keen to play with Pact. My suggestion was that I could put together a PoC showing Cypress and Pactflow working together end-to-end.

matt.fellows
2020-07-16 08:28
I?ve half done that, just needs some tidy up.

matt.fellows
2020-07-16 08:28
:clap:

yousafn
2020-07-16 08:36
Feckin? awesome! I have a good relationship with a few of the Cypress developers over the past couple of years

dineshkr9090
2020-07-16 09:13
has joined #general

dineshkr9090
2020-07-16 09:14
Hi Team,

dineshkr9090
2020-07-16 09:16
Hi Team, Please let me know which version of Java supports Pact framework. I am doing Pact contract testing but getting error like "java.util.function.supplier can not resolved" Thanks, Dinesh Kumar

bethskurrie
2020-07-16 09:17
@dineshkr9090 please ask in #pact-jvm

dineshkr9090
2020-07-16 09:18
ok. Thanks

bethskurrie
2020-07-16 09:18
Also, it will help if you provide an example repository or gist (don't just paste a big slab of code!)

bethskurrie
2020-07-16 09:19
BTW, did you get a message from our greet bot, mentioning the different channels?

a.smith
2020-07-16 10:06
@bethskurrie From my work workspace, it looks like `/github settings` will give you a list of repositories that have rich previews enabled, and the option to disable them.

bethskurrie
2020-07-16 10:08
I did see some mention of that. I don't think we have that plugin though

bethskurrie
2020-07-16 10:08
When I type /github I only get the notifications prompt.

a.smith
2020-07-16 10:41
What about `/github help`? I see a whole bunch of stuff from that, including `/github settings` :thinking_face:

os.shulyak
2020-07-16 14:49
has joined #general

greg719
2020-07-16 18:55
hey, i made a channel in which i talk about your awesome tool pact for angular: https://www.youtube.com/playlist?list=PL1BlcTalLDBcPSvrr4ji0OEYJqO6Bw_9t

greg719
2020-07-16 18:56
any spreading love is appreciated :slightly_smiling_face:

matt.fellows
2020-07-17 03:09
absolutely, great stuff - i?ll watch a bit later today over lunch

matt.fellows
2020-07-17 03:49
How is Pact different to Postman. It?s been asked a few times, so here is a quick post - feedback welcome: https://pactflow.io/blog/how-is-pact-different-than-postman/

maciej.olko
2020-07-17 08:05
Hello, is there a place where one can track progress on support for v3 spec in Pact core?


maciej.olko
2020-07-17 08:58
Thank you! And it was also the thing I was looking for: https://github.com/pact-foundation/pact-python/issues/88

borwoj
2020-07-17 09:37
has joined #general

matthew.thomas
2020-07-17 09:52
has joined #general

shaundavin.se
2020-07-17 10:54
has joined #general

matthew_weisfeld
2020-07-17 13:48
has joined #general

vladg
2020-07-17 20:55
has joined #general

sreeram.thinkal
2020-07-17 21:20
has joined #general

vladg
2020-07-17 21:54
Hi folks. I am a bit confused about Provider States(specifically in PHP). I have a NodeJS consumer service that consumes an http API from a PHP provider service. We have swagger schemas for the PHP API service. I created a pact for simple `/someResource/12345` API using jest-pact DSL in the NodeJS Consumer for both positive and negative(i.e. resource not found) flows, validated it against the swagger api schema and then published the pact to pact broker. Now on to the Provider side(in php): As part of Pact verification, i startup up the Provider API process and then create a php Verifier that is pointed to both the provider API and pact broker. It fetches the corresponding pact from the broker and then try to hit its own `/someResource/12345` endpoint and understandably fails with a 404. I have few questions? 1. Are my expectations that Provider should grab a pact and try to run it against its actual code correct? If so, why does ProviderState config seems to be so limited 2. It seems that some pact implementations(JVM, JS) have a simpler approach to specifying state data than pact-php. Is there any work happening to bring PHP up to the standard of other implementation 3. Does anyone have a good production(ie. working) example of setting up test-only provider state APIs in php ?

bethskurrie
2020-07-17 22:09
Hi @vladg

bethskurrie
2020-07-17 22:09
Best to ask in #pact-php

bethskurrie
2020-07-17 22:09
Did you get a message when you joined from our greet bot mentioning the different channels?

vladg
2020-07-17 22:28
no not yet :slightly_smiling_face:

bethskurrie
2020-07-17 22:28
Hm.

bethskurrie
2020-07-17 22:28
We'll have to check that.

bethskurrie
2020-07-17 22:28
Can you see a message from a greet bot on the side panel?


bethskurrie
2020-07-17 22:29
Did you just join today?

vladg
2020-07-17 22:30
yeah :slightly_smiling_face:

bethskurrie
2020-07-17 22:30
Ok, we'll look into that.

vladg
2020-07-17 22:30
no bots in side panels unfortunately

bethskurrie
2020-07-17 22:31
There is meant to be an ephemeral message that appears to greet you and tell you about the channels. There is also supposed to be a greet bot that leaves a more permanent private message.

bethskurrie
2020-07-17 22:31
@yousafn @matt.fellows ^^

bethskurrie
2020-07-17 22:32
Can you guys have a look when you have a moment?

matt.fellows
2020-07-17 22:32
Will do, thanks

matt.fellows
2020-07-17 22:32
I disabled the greet bot so i can explain that. I'll check the logs for other one

vladg
2020-07-17 22:33
nice Yousaf is here as well ? couldnt get far without his jest-pact-typescript readmes and examples

vladg
2020-07-17 23:07
@bethskurrie my question in there is actually two-fold. one part is PHP specific, but another part is about my understanding of ideal pact flow

vladg
2020-07-17 23:08
ie. providers test pacts against their own live APIs

bethskurrie
2020-07-17 23:08
I'm afraid I'm not a php maintainer so I don't know.

bethskurrie
2020-07-17 23:08
No, providers don't do the tests.

vladg
2020-07-17 23:08
its not php specific

vladg
2020-07-17 23:08
just the conceptual pact flow

bethskurrie
2020-07-17 23:08
Or rather, the API itself doesn't. It's a test harness.

bethskurrie
2020-07-17 23:08
The test harness (aka verifier) fetches the pacts, replays the requests, and compares the actual responses to the expected responses.

vladg
2020-07-17 23:08
once consumer defined a pact and submitted it to the broker


vladg
2020-07-17 23:09
what is provider supposed to do with it? i.e. how do i ensure that if provider changes its API in a way that breaks the contract, that PACT tests will break as well


bethskurrie
2020-07-17 23:10
There are two workflows where the pacts should get verified - one when the pact changes, and one when the provider commits.

bethskurrie
2020-07-17 23:10
Have a read of that page I just sent (and the entire pact set up guide). it should explain what you need to know.

vladg
2020-07-17 23:10
so a simulated consumer tests against live provider api in https://docs.pact.io/how-pact-works#slide-4

vladg
2020-07-17 23:11
this implies that the data that the simulated consumer tests against already exists in the provider

bethskurrie
2020-07-17 23:11
yes.

bethskurrie
2020-07-17 23:11
before the request is replayed, the right data needs to be set up in the provider.

vladg
2020-07-17 23:11
so does that mean that pact itself is coupled to data in the provider

bethskurrie
2020-07-17 23:11
to do this, generally and endpoint is invoked with the name of the provider state, and it's up to that endpoint to set up the right data.

bethskurrie
2020-07-17 23:12
yes, the pact is coupled to the data. it has to be.

bethskurrie
2020-07-17 23:12
you can't expect a 200 if the database is empty.

vladg
2020-07-17 23:12
got it

bethskurrie
2020-07-17 23:12
the provider state for each interaction is set up separately to avoid the situation where failures from one interaction cause failures in a later interaction.

vladg
2020-07-17 23:13
got it

yousafn
2020-07-18 01:08
Welcome @vladg! Glad to hear you have got on well with jest-pact. @tjones also needs props :call_me_hand: he came up with the idea and made the readme extra awesome.

yousaf.nabi
2020-07-18 01:20
has joined #general


charu.agarwal
2020-07-18 21:42
We are using consumer-driven contract testing for our RESTful APIs. We also use Kafka with a schema registry for asynchronous communication between different applications. I am trying to understand how Pact for messaging will help if we are already using schema registry? Will it be overkill?

matt.fellows
2020-07-18 22:12
Schema registry won't pick up the issue until you deploy the app. So at the very least you have a shorter feedback loop if you use Pact

matt.fellows
2020-07-18 22:14
It also won't help you orchestrate a release. Pact maintains a compatibility matrix that you can use for deploys (and rollbacks). This need to builds your own for schema registry

matt.fellows
2020-07-18 22:16
I'll have a watch. I did a talk in Sydney last year and met Sam there. Interested to see her thoughts

vladg
2020-07-18 22:17
Thank you all ? getting started on the consumer side was significantly simpler due to jest-pact readmes and provided examples and shell scripts. Provider side (in my case in php) took some time wrapping my head around. Im doing a POC as part of a HackWeek at work and im hoping to show the value that pact offers in terms of a quality gating factor.

bethskurrie
2020-07-18 22:17
Cool! Thanks @yousafn

bethskurrie
2020-07-18 22:17
To be honest, the provider side is always harder to implement.

bethskurrie
2020-07-18 22:18
There are so many more variables, and it's where the tricky matching takes place.

vladg
2020-07-18 22:18
Makes sense. My hope is that i can easily demonstrate flow where an API change on the provider side will break the build if consumers are relying on it.

bethskurrie
2020-07-18 22:18
There's a CI/CD workshop, if that helps.


bethskurrie
2020-07-18 22:20
It's not php, but it will show you the principles.

vladg
2020-07-18 22:20
Provider States were especially difficult. I wish they were implemented as ?before? callbacks rather than requiring an API to be spun up. I understand where that requirement comes from ? we are wrapping a native executable that has no way to communicate with current runtime other than http. I still wish there was a different way

bethskurrie
2020-07-18 22:20
Funnily enough, @matt.fellows was talking about a solution to this the other day

vladg
2020-07-18 22:20
I ended up avoiding dealing with them entirely by relying on existing data that is currently being used in provider?s integration tests anyway?.

bethskurrie
2020-07-18 22:21
See how far you can get!

vladg
2020-07-18 22:22
I believe Provider State management is implemented differently in pact-js and pact-jvm and that pact-php is a bit behind

bethskurrie
2020-07-18 22:22
Yes, it hasn't been updated for a while I believe.

bethskurrie
2020-07-18 22:23
Trying to keep 11 libraries at parity is a difficult task.

vladg
2020-07-18 22:23
Yeah totally understandable!

matt.fellows
2020-07-18 22:41
You get a great call out too Beth!

matt.fellows
2020-07-18 23:01
Perfect timing - cypress and Pact :heart:

matt.fellows
2020-07-19 10:38
Not sure what happened with that last sentence sorry. But I think you caught my drift

charu.agarwal
2020-07-19 10:42
Thanks Matt for the quick response. We have set schema registry compatiability type to be FULL_TRANSITIVE. We do run our component test in development against real Kafka and schema registry. We keep track of all released schema versions in dev. After deploying in production, we copy the released version of schema to a released folder with a version number. I am not sure what we are missing.

matt.fellows
2020-07-19 10:50
cool

matt.fellows
2020-07-19 10:50
when you say dev, do you mean on your local development machines or elsewhere?

matt.fellows
2020-07-19 10:53
I believe also you need to ensure your test environments exactly match production, not just in the design but also the state - otherwise the history of schema compatibility won?t be there

matt.fellows
2020-07-19 10:53
but again, it?s doable, just not ideal

matt.fellows
2020-07-19 10:54
What Pact will give you over and above your own workflow to ensure the above, is the I want to introduce a breaking/new change into the system, and evolve that safely. That?s what Pact will help you orchestrate

matt.fellows
2020-07-19 10:54
e.g. consumer has a new expectation on the producer

charu.agarwal
2020-07-19 11:23
We can run all our tests locally as well as in our build environment. Both places we use the same Kafka and schema registry. I think I am understanding what you are saying. With schema registry, we are doing provider driven development/testing. Let me try to understand the benefit of schema registry? Is there anything which schema registry gives but Pact doesn't? Schema registry brings the complexity of its own. Pact gives me visibility about each consumer what it needs. I don't have that with schema registry.

matt.fellows
2020-07-19 11:24
I think that?s fair to say

matt.fellows
2020-07-19 11:25
I?m not a Kafka expert, so please do what you think is best of course!

matt.fellows
2020-07-19 11:25
But

matt.fellows
2020-07-19 11:26
I tend to think of the deployment workflows (ultimately, that?s what Pact is for). For example, if you were to rollback a provider (let?s say there is an issue), are you given guarantees that the next provider is compatible with its consumers? i.e. will you know in advance if that rollback will be successful or is it luck?

matt.fellows
2020-07-19 11:27
My understanding is that Kafka schema registry will maintain all versions (deployments). If that data isn?t available to your local dev/test environments you may lose out

alex.mccormick
2020-07-20 02:15
has joined #general

mark.abrahams
2020-07-20 08:38
has joined #general

mark.abrahams
2020-07-20 08:55
Dear Pact friends, I am currently looking at the pact-jvm-server (https://docs.pact.io/implementation_guides/jvm/pact-jvm-server/) for implementing the pact framework with a low code tool. Currently I am able to start the server and register some interactions via the /create endpoint. As mentioned in the documentation you have to define a state and path while doing so. Should I only register one interaction per /create call or can I add multiple? I noticed it works to add multiple interactions to the json however what should be the state filled in in the /create call then since the json contains multiple? And while running the tests how can I set the state the mock server should be in? For example state "user 1 does not exist" should return 404 on GET /user/1 and state "user 1 exists" should return 200 on GET /user/1. Can someone over here tell me how the pact-jvm-server is designed to be used? (register one interaction per /create call or is there some endpoint where I can specify the state the mock server should be in?) Looking forward to your answer!

bethskurrie
2020-07-20 09:30
Hi Mark. The best people to ask are in #pact-jvm

bethskurrie
2020-07-20 09:30
We have so many languages supported that each language has its own channel.

angelo
2020-07-20 09:46
has joined #general

angelo
2020-07-20 09:47
Hi! We're using pact-js (v9.11) for consumer side and pact-php (v5.0) for provider side. Is there a way to have WIP & Pending pacts activated using the php library for the provider side? Ive seen in the github issues that's its yet to be implemented and I wonder if there's a workaround?

bethskurrie
2020-07-20 10:42
There's an open issue to upgrade.

bethskurrie
2020-07-20 10:44
You could try calling the new api directly, and then verifying the pacts individually, ignoring failures for the ones that are marked as pending.

gcoradini
2020-07-20 10:55
has joined #general

mark.abrahams
2020-07-20 11:50
Ok Beth I will give it a try over there. Thanks!

matt.fellows
2020-07-20 12:11
It should be an easy modification. I'd say forking pact php and submitting a PR is likely to be less effort (and also quite rewarding :pray:)

pulgupta
2020-07-20 13:03
has joined #general

pulgupta
2020-07-20 13:09
Hello Everyone! I am currently evaluating Pact to write contract tests for our APIs. Can someone please share some resource highlighting how we can use Pact with Jest and JSDOM? As per the documentation only node is supported with Jest. I can?t use node environment for testing my components. Because of the this I am now planning to create a test consumer for my APIs(just to generate contracts) in java and then use pact-junit runner to generate consumer contracts.


yousafn
2020-07-20 13:16
> The test environment that will be used for testing. The default environment in Jest is a browser-like environment through https://github.com/jsdom/jsdom. If you are building a node service, you can use the `node` option to use a node-like environment instead.

yousafn
2020-07-20 13:18
Is it pact-js that doesn?t work in jsdom? do you need to use pact-web instead?


pulgupta
2020-07-20 15:43
I tried with @pact-foundation/pact and it seems to work in Jest with JSDOM environment.

pulgupta
2020-07-20 15:44
I think I can use it. Somehow pact documentation gives an impression that Pact is only supported in node environment and not in JSDOM

yousafn
2020-07-20 15:51
it does indeed give that impression https://github.com/pact-foundation/pact-js#usage-with-jest maybe the above section could like to pact-web section for users who require jsdom

yousafn
2020-07-20 15:52
out of interest, have you seen jest-pact? https://github.com/pact-foundation/jest-pact

pulgupta
2020-07-20 16:02
not really, I was using @pact-foundation/pact. However I think jest-pact seems promising, will try it out. One more issue which I would like to discuss, Actually, I have a code with jquery.ajax() and I cannot use some random port in the ajax() url. Due to this I have to use a single file for all my tests. As per the documentation if we need to split our tests in separate files we will need to use separate ports for each provider of each test file. Do you have some idea, how can I solve this issue?

yousafn
2020-07-20 16:06
In jest-pact we assign a random port when we instantiate the provider and pass this to our method that utilises the api call internally, and the test is checking the output of the function, whilst the pact provider verification checks that pact got the right request.

yousafn
2020-07-20 16:06
I am not sure if it has made it into pact-js but it is a very useful feature.

pulgupta
2020-07-20 16:11
Yes, That is true, but since jquery?s ajax method only sends request to the same server?s host and port, I had to make even the pact mock server port static. To do this I configured a jest test server port and then use the same port while configuring my pact server. It is a limitation more from the jquery.ajax() method side. With axios I was able to use the pact?s random port feature and it is working perfectly.

yousafn
2020-07-20 16:15
ahh yeah that sucks, I haven?t used ajax much at all, spend most of my time with backend services and dip in and out of ui code mainly react with xhr?s to a backend service

pulgupta
2020-07-20 16:32
yes pact-jvm is nice :-)

tjones
2020-07-20 17:31
@pulgupta could you tell me a bit more about your setup? With jquery, I think you should still be able to specify the URL - can you not pass the full URL to the mock server at test time?

mr.manish22d
2020-07-20 18:55
has joined #general

matt.fellows
2020-07-20 22:34
> I am not sure if it has made it into pact-js but it is a very useful feature. Do you mean does it assign a random port? If so, yes

matt.fellows
2020-07-20 22:36
> Yes, That is true, but since jquery?s ajax method only sends request to the same server?s host and port That?s not true. You can definitely send a CORS request using JQuery

matt.fellows
2020-07-20 22:36
You just need to ensure that the server responds with appropriate CORS headers

matt.fellows
2020-07-20 22:37
And Pact has the `cors: true` option for that

matt.fellows
2020-07-20 22:38
> I think I can use it. Somehow pact documentation gives an impression that Pact is only supported in node environment and not in JSDOM This statement is misleading. JSDom _runs_ on NodeJS

matt.fellows
2020-07-20 22:38
`pact` won?t run in a browser, though, that is what `pact-web` is for

tien.xuan.vo
2020-07-21 01:53
has joined #general

pulgupta
2020-07-21 04:59
thanks @matt.fellows setting the cors option on Pact has made everything work.

matt.fellows
2020-07-21 05:00
Awesome!

ashish_garg5
2020-07-21 06:22
Hi All, ```http://localhost:8500/pacts/provider/provider/consumer/consumer/version/1.0.0``` I am using this broker url to make a put request in python now i want to add pact-broker-username and pact-broker-password as well, how to do that ? Can i pass in this same url or there is any other way. Thanks.

matt.fellows
2020-07-21 06:26
This probably belongs in #pact-broker

matt.fellows
2020-07-21 06:27
the username and password are basic auth credentials, so you need to consult the docs for your Python HTTP client about how to add those

ashish_garg5
2020-07-21 06:27
ok thanks

mr.manish22d
2020-07-21 06:35
Hi Pact friends, I stucked with one issue, need help! Scenario: My API is Post request, which is having one token in body. I want to generate this token in provider state using provider state. In consumer test, I want to use method valuefromProviderState. But I am not getting any approach where I can add above method in my payload string. I am using Java, springboot for pact. If anyone have seen such scenario or I should follow some other approaches, please let me know. Thanks in advance. Regards, Manish

matt.fellows
2020-07-21 06:36
Can you please ask this in #pact-jvm ?

mr.manish22d
2020-07-21 06:37
Sure

angelo
2020-07-21 09:31
I was wondering if the pending/wip pacts can be applied to trunk based development for consumer side and what's the workflow like? Do we use feature flags for the pact tests?

tjones
2020-07-21 09:33
with trunk based, you can tag whatever is deployed. If your pacts are different with feature flags on / off, I would recommend including the flags in the version

tjones
2020-07-21 09:38
If you?re using semver, you could put it in the build information, eg v1.2.3+flagX.flagY

angelo
2020-07-21 09:51
For example you have a pact tagged master in master branch which is green. And you have 2 new features on 2 short lived feature branches: One changes the contract, the other doesnt. Both are then prd and merged to master. One problem with this is it makes the pact go red for both features. So, I'm not quite sure because I version using latest git tag semver + commit hash and tag pacts once they are merged to master (with the branch name master). While the examples I see push and tag contracts on a per branch basis and use can-i-deploy to check if they can merge to master which I do not want to follow because it breaks our trunk based development by waiting for the API counterpart and having dangling branches. Or is this the right approach for a trunk based development? As for feature flagging pact tests, it is something we are considering but may be there's a more elegant solution. Would really love a concrete example to do this right.

tien.xuan.vo
2020-07-21 10:43
Hi all, Is Pact Rust the main implementation of current/future Pact specifications? Does it mean that for example, Pact PHP will replace pact-ruby-standalone to use Pact Rust Standalone (or Rust FFI calls) to implement Pact specification v3 in the future?

matt.fellows
2020-07-21 10:43
Yes!

matt.fellows
2020-07-21 10:43
Why do you ask?

matt.fellows
2020-07-21 10:44
A short lived branch is not trunk based development

matt.fellows
2020-07-21 10:44
It's GitHub flow

tien.xuan.vo
2020-07-21 10:45
I asked because I have plan to learn both contract testing (Pact) & Rust. Maybe it's a good idea to learn Rust to contribute to Rust implementation?

matt.fellows
2020-07-21 10:49
We?re certainly happy to have more contributors

matt.fellows
2020-07-21 10:49
I?d open the chat in #pact-php and we can get the maintainers in on the conversation about how to do it

angelo
2020-07-21 10:56
It can be as long as you use feature flags to differentiate code and have the feature branch commits be squashed to master and wont last for more than a day or two


matt.fellows
2020-07-21 10:59
Maybe I?m a purist, but I cannot see how creating a branch and merging that to master is considered ?trunk based development?. In that flow, all of the usual Pact/Pactflow features work as advertised.

matt.fellows
2020-07-21 10:59
It?s really only when you?re commiting directly to master and using feature toggles alternative Pact approaches are needed

matt.fellows
2020-07-21 10:59
that being said, a colleague has done some work on this - i?ll try and dig it up and share online (somewhere!)

angelo
2020-07-21 11:01
Thanks! That Would really help a lot

angelo
2020-07-21 11:03
Also were doing it like this (short lived feature branches) so we dont use up all our ci build minutes since were a small org with a tight budget

abdul.hussain
2020-07-21 15:28
has joined #general

joel.whalen
2020-07-21 16:49
General philosophical Pact question: How do you all feel about running pact verifications on feature branches that *do not* deploy to a test environment? According to this diagram, we should be doing verification before deploying to an environment. Our feature branches don?t deploy anything, only our shared develop and master branches do. Is it worth the early warning to the developers to have the verification on their feature branches? Or is it too costly in terms of breaking the verification ?too often??

jarmy
2020-07-21 17:00
I?d like some clarification on pact verification in regards to how it fits into CI/CD. I have a consumer contract test (jvm) that publishes a pact as part of its CI and I have a provider verification test (js). Where does the provider verification test run in the CI/CD pipeline? According to https://github.com/pact-foundation/pact-js/#provider-api-testing documentation: _1. Start your local Provider service,_ the provider verification test needs a running API to run against. How would you accomplish this in a CI build where you typically only compile your code, run unit tests and _don?t_ deploy anything? Our typical workflow is to follow up the CI build job with a docker build job and then a docker deploy job. Is it feasible to run the pact verification test _after_ deploying the provider as part of an acceptance test job?

phil.endsley
2020-07-21 17:01
imo, I think it's worth it. It's mentioned in the ci/cd workshop, but you can use `can-i-deploy` as a "can I merge" check. So even if you don't deploy the feature branch itself, you can still leverage the verification results to ensure your branches stay compatible. If you wait until you merge into your main branches, that's too late in the process (imo) to be finding out. We like to keep our develop branches > Or is it too costly in terms of breaking the verification ?too often?? I don't think this really matters in practice, does it? Bad verification results are ok. They just stop you from deploying breaking changes.

phil.endsley
2020-07-21 17:12
> How would you accomplish this in a CI build where you typically only compile your code, run unit tests and _don?t_ deploy anything I guess I'll preface with, there are a lot of different ways to do things, and sometimes you might find yourself constrained by things outside of your control at your company. Our workflow is to run all of our test suites in the CI build. Our provider verifications happen in what I would usually classify as integration tests. In those tests, we spin up our application and the provider verification tests run against those. We also have other applications that require a lot more work than others to start up. For those, we just stand up the parts of the application that affect the pact tests we're running (ex: Maybe just a single rest controller and the service layer that's affected vs the entire application).

joel.whalen
2020-07-21 17:28
ok, thanks for the input. I?ll do it that way then it makes sense

joel.whalen
2020-07-21 17:31
yeah we are spinning up 3 containers to make this work: 1. the application itself 2. a redis container dependency 3. the pact verification test. All of this happens within CICD, and thankfully you *don?t have to mirror your production setup* https://docs.pact.io/faq/question_archive#my-team-wants-to-run-the-application-inside-docker-as-they-feel-that-running-it-inside-a-docker-with-http-server-is-much-more-realistic-scenario-in-line-with-production

krisdinesh
2020-07-21 22:53
@all - looking for pactnet matcher, current doc shows the example in ruby. Could you please share any example on the matcher using pactnet . Thanks in advance!!

matt.fellows
2020-07-22 00:25
:point_up: What Phil said

matt.fellows
2020-07-22 00:26
:point_up: thanks folks!

matt.fellows
2020-07-22 00:26
Yes, ideally you don?t need to deploy the application to run it.

matt.fellows
2020-07-22 00:27
most of our examples show a pact verification running locally (on your dev machine or on CI) where it is started first, and then pact tests use this locally running service

matt.fellows
2020-07-22 00:28
Where possible, I tend stub external dependencies to avoid slow/complex setups. Some people stub all layers except the controller.

matt.fellows
2020-07-22 00:28
Both are OK, as long as you know what coverage/scenarios you?re trading off and have a strategy to get the appropriate level of confidence

jarmy
2020-07-22 00:31
It would sure be easier to run the pact verification tests as part of the CI job. I?ll need to talk to the devs to see how I can stub the external dependencies of this API.

jarmy
2020-07-22 00:35
If run as part of CI, we won?t need any vault tokens to start the acceptance test job if triggered by a webhook created from the consumer tests

matt.fellows
2020-07-22 00:43
ah I see

matt.fellows
2020-07-22 00:43
> I guess I?ll preface with, there are a lot of different ways to do things, and sometimes you might find yourself constrained by things outside of your control at your company. So Phil?s point stands

matt.fellows
2020-07-22 00:44
Ideally, you can stub things out quickly and easily and then it won?t require things like vault tokens etc.

matt.fellows
2020-07-22 00:44
or, are those vault tokens for access to the broker or something?

matt.fellows
2020-07-22 01:35
Extract from the presentation. I hope it?s useful!

bethskurrie
2020-07-22 05:54
@dineshkr9090 there is a channel for each language.

bethskurrie
2020-07-22 05:54
Try asking in #pact-net

bethskurrie
2020-07-22 05:56
Can I also mention how awesome @phil.endsley is?

bethskurrie
2020-07-22 05:57
What Phil said :wink:

ranjanayush03
2020-07-22 06:05
has joined #general

mamtha.3687
2020-07-22 06:07
has joined #general

ranjanayush03
2020-07-22 06:12
Hi all,I am trying to configure pact broker using mysql instead of postgres but I am getting 500 internal server error so can someone please help me with the steps or a document on how to configure this..

ukrainian1991
2020-07-22 08:52
Hi, I faced with a strange ConsumerVersionSelector behaviour (I use latest pact-jvm version and gradle plugin 4.1.6). I have several versions of Consumer mr85 mr86 mr87 and I want to verify Provider against *all* of this versions. According to docs I assigned for all of these versions the same tag "admin-client" and disable option *latest.* Here is the Gladle plugin pactVerify task config ```serviceProviders { iPaaS_CPE { ... fromPactBroker { selectors = [ new ConsumerVersionSelector("admin-client", false)] // specify your tags here. You can leave this out to just use the latest pacts }``` Also, I have tried to do this via Providers tests ```@PactBroker(host="0.0.0.0", port = "9292", consumerVersionSelectors = { @VersionSelector(tag = "admin-client", latest = "false")}) public class PactProviderPaaSTest {``` In both cases, only latest version of Consumer verified against the Provider. Could you point me how to achieve my goal?

ukrainian1991
2020-07-22 08:55
Maybe I misunderstand the meaning of "latest" option from here https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors

abubics
2020-07-22 08:56
I don't have an definite answer, but probably good to move this to #pact-jvm :innocent:

ukrainian1991
2020-07-22 08:57
But it's about a general "consumerVersionSelectors". Is it a jvm specific option?

abubics
2020-07-22 08:58
that annotation is JVM, and I don't know if other implementation have such a feature

abubics
2020-07-22 08:58
I think if you have several live consumers, you need to run `can-i-deploy` once for each version . . . but I don't know if the annotation can provide a similar functionality (only because I haven't used it)

tjones
2020-07-22 09:00
Which version of the broker do you have?

ukrainian1991
2020-07-22 09:01
pact-broker: image: pactfoundation/pact-broker:2.57.0.1

ukrainian1991
2020-07-22 09:04
@abubics I checked can-i-deploy and I cant properly verify exact combination ```-Ppacticipant=PortaBilling -PpacticipantVersion=MR86 --Ppacticipant=iPaaS_CPE -PpacticipantVersion=1.0.1``` For example such parameters says that all is ok) But I definitelly know that 1.0.1 could not be deployed with mr86)

ukrainian1991
2020-07-22 09:05
Maybe I misuse somehow...

abubics
2020-07-22 09:13
I feel like that's pretty close to examples @bethskurrie has given before :thinking_face:

ukrainian1991
2020-07-22 09:20
My case is the following: I need to verify that each commit to Provider side does not break the compatibility with all Consumer versions.

ukrainian1991
2020-07-22 09:33
Maybe it would be better to represent each version as separate Consumer

abubics
2020-07-22 09:40
It's a usage that's come up before, and I think modelling it as a single consumer with multiple versions is the suggested approach. You just can't rely solely on `latest`, because you have multiple live versions, not just a latest :slightly_smiling_face:

rupesh.sawaliya374
2020-07-22 09:50
has joined #general

rupesh.sawaliya374
2020-07-22 09:54
Hi, I trying to use pact-jvm for our web API which returns soap XML as a response. I am looking for examples in which if I can validate XML response against XSD schema. Need suggestion, is it a good idea to use pact for web API's which returns xml response? Please help.

helen
2020-07-22 12:26
has joined #general

uladzislau_danilchyk
2020-07-22 12:40
Hi guys! Can you help? How can I pass custom params into constructor for target pointed with `@TestTarget` ? I need to pass params for that from my properties. Currently I use Spring Context and want to pass params without Spring Boot. Maybe you have some suggestions?

phil.endsley
2020-07-22 12:43
#pact-jvm was the right channel to ask in. Just need to wait for some input :slightly_smiling_face:

uladzislau_danilchyk
2020-07-22 12:43
@phil.endsley already. But haven't answered yet...

phil.endsley
2020-07-22 12:47
Right...just have to be a little more patient

angelo
2020-07-22 13:14
I have confusion about the versioning. Currently I version my pact using a combination of git tags + commit sha and tag it with the branch name (ex. pact-version: 1.0.1+1fjdkolw tag:feature/new1). So, the scenario is when I pr merge this feature branch to master branch, do I publish a new pact in master with its new version + master tag or use the feature branch latest exact pact version and tag (ex. pact-version: 1.0.1+1fjdkolw tag:feature/new1) and just change the tag to master? (ex. pact-version: 1.0.1+1fjdkolw tag:master)

matt.fellows
2020-07-22 14:05
Have you read the docs on versioning and the ideal pact workflow? They should clear that up for you

rupesh.sawaliya374
2020-07-22 14:29
@uglyog and @matt.fellows can you please comment on this?

jarmy
2020-07-22 16:09
The vault tokens are for acceptance test and deployment job permissions

uglyog
2020-07-22 23:01
Pact-JVM doesn't validate against XSD schemas

abubics
2020-07-23 00:12
Pact provides for more business/domain logic reasoning than just an XSD. You can use them together, if you want. Just Pact won't do the XSD bit for you.

matt.fellows
2020-07-23 01:34
I?m probably lacking context to understand why they would be needed to run Pact locally against a localy running provider - does the provider need to talk to other systems and requires secrets to do so? Can you stub out those systems for these pact tests so those aren?t needed?

danhitchcock
2020-07-23 07:54
Hi all, So I've hit a slight roadblock in using the matchers with an array that often has a null value in either the 0 or 1 position. I've tried eachlike(integer(1234)) and that always seems to throw an error because of the null value. ```{ "values": [ { "key": "2020-04-01T00:00:00.000+01:00", "values": [ 14676, null ] } }``` Any ideas on how i match this array, as I am expecting either a null or an integer? My current code for attempting to match this part of the response. ``` values: eachLike({ key: iso8601DateTimeWithMillis("2020-07-01T00:00:00.000+01:00"), values: eachLike(integer(1234)), }),```

uglyog
2020-07-23 07:56
You should use two different tests, one where the value is non-null, and the other were it is null


danhitchcock
2020-07-23 08:15
Ok so maybe i should just say look for an array with something in it. The null value might not be there next week, as this response json is currently hardcoded.

paul.stitt
2020-07-23 08:33
has joined #general

paul.stitt
2020-07-23 08:49
Hi all, I?m interested in trying out the ?pending pacts? beta feature.

hello997
2020-07-23 09:14
has joined #general

sambowenhughes
2020-07-23 09:19
has joined #general

tjones
2020-07-23 09:34
Hi Paul! That?s great! Let us know if you have any questions.

paul.stitt
2020-07-23 09:59
I found some links on the verifications channel, so I?ll see if we can get our broker configured and take it from there.

matt.fellows
2020-07-23 10:08
Which language are you using?

paul.stitt
2020-07-23 12:51
We?re mainly jvm and nodejs.

danhitchcock
2020-07-23 13:00
I am still hacking away trying to make a very basic (it's just an array, don't check the types) statement. It looks like https://github.com/pact-foundation/pact-specification/issues/71 does maybe answer /solve my problem?

krisdinesh
2020-07-23 13:40
Sorry @beth !!

daniele.scillia
2020-07-23 15:05
has joined #general

krisdinesh
2020-07-23 15:24
Exactly this issue is road block to me as well....waiting for V4 and it is a co incident same question I asked yesterday :blush:

danhitchcock
2020-07-23 16:00
In the end i just removed the whole array from the spec, as i couldn't find an acceptable halfway house that followed 'Postels Law' in some way or other.

krisdinesh
2020-07-23 16:03
Yes, I did remove that field in consumer contract as it is not highly required field in validation. Additionally, this field I removed is validated as part of unit test and also in end to test so that it covered in testing

sschectman
2020-07-23 16:18
has joined #general

komeershettyvinod
2020-07-23 18:53
Hi @matt.fellows

komeershettyvinod
2020-07-23 18:53
I have a question

komeershettyvinod
2020-07-23 18:53
I have a very large json body that i need to verify at consumer side

komeershettyvinod
2020-07-23 18:54
i cannot mention the whole json body within withBody {}

komeershettyvinod
2020-07-23 18:54
is there any clean way to do this

komeershettyvinod
2020-07-23 18:54
can you please help me out?

joel.whalen
2020-07-23 18:54
Pact team is on Australian time so there?s usually some delay

komeershettyvinod
2020-07-23 18:56
Hi Joel

komeershettyvinod
2020-07-23 18:56
can you help me out with my problme

joel.whalen
2020-07-23 18:57
No, I?m still quite new to Pact myself. Usually there?s about a day?s worth of time before a question is answered but this slack channel has been very good at answering my questions so far.

komeershettyvinod
2020-07-23 18:59
ok np

jarmy
2020-07-23 22:20
The secrets are only needed for deployments. I?ve just learned that the provider has ~20 dependent services so stubbing them all out would be cost prohibitive. I?ve currently positioned the pact verification test inside the acceptance test suite, which is run against a canary. If the canary fails, the deployment is rolled back. It sounds like Phil?s point still stands.

matt.fellows
2020-07-23 22:36
Cool. Let me know if you have issues with JS

matt.fellows
2020-07-23 22:37
I'm not sure what you mean by it's too big. Can you please ask the the appropriate language channel e.g #pact-js

komeershettyvinod
2020-07-24 03:05
I mean to say its very large , it has lot of fields to verify and having that raw json in test file is not looking clean, is there any way we can store that in json file and verify

matt.fellows
2020-07-24 04:09
what?s stopping you creating a separate file with the body in it, and then requiring that in your test?

matt.fellows
2020-07-24 04:09
I often create a fixtures directory, and have payloads there to reduce the noise in bigger test files

mike.geeves
2020-07-24 06:16
Hi, quick question, I had the ok to share back the Pact examples I was working on, if it would actually be of any use ofc. As a reminder I was creating some hello world examples using GitLab CI/CD to demonstrate multiple consumers and providers, primarily python. Unfortunately due to other priorities, I didn't do the next steps *yet* of making the GitLab pipelines spin up a docker database to then setup states to test against and finish documenting it all (GitLab setup especially) - would any of that be of use, if tidied up and completed a bit more ("that might be helpful if it had...."), I didn't see good example of GitLab pipelines or states apart from very simple hardcoded responses - any strong preference of open source license if sharing to release under?

matt.fellows
2020-07-24 06:16
sounds awesome, and thanks for the offer!

matt.fellows
2020-07-24 06:17
We tend to release under MIT, but that?s because it?s the most liberal and so tends to mean enterprises won?t be afraid to go near it

matt.fellows
2020-07-24 06:18
I think the provider states on the provider side is usually the most complicate concept to grasp, so that?s great if you have examples around that

matt.fellows
2020-07-24 06:18
Nice on the Gitlab webhooks, any lessons we may ?borrow? into the webhook template library

mike.geeves
2020-07-24 06:24
:+1: MIT should be fine, I'll add that in My bash-fu webhooks may or may not have been the best way but it worked for a start I'll add in MIT, tidy up and come back when there's something in a presentable state so may be a little while but I should have more time on it soon :slightly_smiling_face: state stuff looked really interesting, quite a lot to do there though

matt.fellows
2020-07-24 06:24
That?s great, thanks so much for the offer

matt.fellows
2020-07-24 06:25
I?m sure #pact-python will be super happy, and we?ll do our best to promote it around here

matt.fellows
2020-07-24 06:25
@elliottmurray is currently doing a lot of work in this space, he may be interested to see what you come up with to influence any design decisions too

mike.geeves
2020-07-24 06:38
:+1: the current ones were using AWS Chalice as a simple python lambda framework, I'm in the process of trying to now use FastAPI for everything because OMG documentation. Anyway, will tidy, share, and engage more in a bit (might be a week or two)

matt.fellows
2020-07-24 06:49
ha!

komeershettyvinod
2020-07-24 06:55
do we have some example

komeershettyvinod
2020-07-24 06:55
to share

komeershettyvinod
2020-07-24 06:57
I am not sure how to use in conjunction with withbody tag, I see most of the examples having small json which are used withbody tag

vishwa.amit
2020-07-24 07:32
has joined #general

poojashree_gopal
2020-07-24 11:04
has joined #general

komeershettyvinod
2020-07-24 15:08
@matt.fellows is it possible to share some example?

sidhartha.k.subudhi
2020-07-24 16:55
1. I need information for: Can we send an attachment along with certain JSON body in a request if yes how to do that? 2. Can we expect an attachment from a response, if yes, how to do that?

sidhartha.k.subudhi
2020-07-24 16:55
1. Can we send an attachment along with certain JSON body in a request if yes how to do that? 2. Can we expect an attachment from a response, if yes, how to do that?

bzifkin
2020-07-24 18:00
has joined #general

bzifkin
2020-07-24 18:01
Hi everyone I'm a developer for a start up in Chicago, USA

bzifkin
2020-07-24 18:02
im trying to run a POV to get my organization started with pact

bzifkin
2020-07-24 18:02
I am having some trouble getting my pact verify results to publish to my broker though

phil.endsley
2020-07-24 18:08
What language are you using for your providers? There's a channel for each language, and you'll probably get more targeted help there

2020-07-24 18:30
A new post has been created in *Feature Requests*

bzifkin
2020-07-24 18:31
im using java

phil.endsley
2020-07-24 18:38
We can get into the details in #pact-jvm

bzifkin
2020-07-24 18:38
thanks @phil.endsley

bzifkin
2020-07-24 18:38
ill post there

slack1260
2020-07-24 20:55
has joined #general

uglyog
2020-07-25 02:19
You need to be explicit about what you mean by _attachment along with certain JSON body_. What is the attachment and how are you sending it with the JSON body.

vishwa.amit
2020-07-25 18:42
Hi guys, I am new to pact contract testing .. I am trying to understand the pact test from contract side .. where service response is being mocked.. not sure how to mock as the example given in `pact-python` and `pactman` seems to be using the real response ...?

vishwa.amit
2020-07-25 18:42
``` def user(user_name): """Fetch a user object by user_name from the server.""" uri = 'http://localhost:1234/users/' + user_name return requests.get(uri).json()```

vishwa.amit
2020-07-25 18:44
where requests.get() is getting the actual resp from service?

vishwa.amit
2020-07-25 18:48
and in the test we matching against expected results. ```import atexit import unittest from pact import Consumer, Provider pact = Consumer('Consumer').has_pact_with(Provider('Provider')) pact.start_service() atexit.register(pact.stop_service) class GetUserInfoContract(unittest.TestCase): def test_get_user(self): expected = { 'username': 'UserA', 'id': 123, 'groups': ['Editors'] } (pact .given('UserA exists and is not an administrator') .upon_receiving('a request for UserA') .with_request('get', '/users/UserA') .will_respond_with(200, body=expected)) with pact: result = user('UserA') self.assertEqual(result, expected)``` `

vishwa.amit
2020-07-25 18:49
or am I missing something?

matt.fellows
2020-07-25 22:29
You still hit a real server, you just hit the Pact mock server instead of your usual provider

matt.fellows
2020-07-25 22:39
The pact mock server listens and validates everything and then records the contract

elliottmurray
2020-07-26 08:46
@mike.geeves we could do with a Chalice example as well in python. It is on my list but re-jigging the current e2e one at the moment

elliottmurray
2020-07-26 08:48
I suggest reading the docs a bit more first


elliottmurray
2020-07-26 08:49
explains what is going on pretty well (spoiler yes you are making actual http requests) but digest some of the content above.

elliottmurray
2020-07-26 08:49
If you have python specific problems there is #pact-python where we?ll try and answer your questions

mike.geeves
2020-07-26 09:24
@elliottmurray sure, will be happy to shuffle around I was thinking AWS could actually be a nice "starting point" anyway with a free tier. K8s cluster as a starting point to spin up into being a non free starting point once you get past local. Not sure about db though :thinking_face:

elliottmurray
2020-07-26 10:11
Whatever you?re comfortable with - all contributions welcome!

2020-07-26 12:00
A post in *Feature Requests* has been marked as *in progress*

bethskurrie
2020-07-26 22:22
@mike.geeves if you have some Gitlab webhooks that accept parameters, would you be able to submit a PR to this example? https://docs.pact.io/pact_broker/webhooks/template_library#gitlab---trigger-build

bethskurrie
2020-07-26 22:24
Hi @vishwa.amit . It seems like you might not have a good grasp yet of how pact works. Can I recommend watching this https://docs.pact.io/how-pact-works#slide-1

alexei.hmelevski
2020-07-27 00:42
has joined #general

scwang
2020-07-27 01:34
has joined #general

scwang
2020-07-27 01:36
Hi Guys, when I am running target , I always got "Request Failed - Unrecognized SSL message, plaintext connection?" , How I can make a https request ?

bethskurrie
2020-07-27 01:36
Hi @scwang. Can you please read this? https://docs.pact.io/resources/how_to_ask_for_help

scwang
2020-07-27 01:37
thanks

matt.fellows
2020-07-27 01:44
I?d say you?re either sending an `http://foo.bar/resource` to an `https://` running server, or vice versa.

matt.fellows
2020-07-27 01:45
but most of the time you do not need to test SSL with Pact. Because it just doesn?t add any value

francis.lobo
2020-07-27 01:59
has joined #general

bruno
2020-07-27 10:17
has joined #general

umfarooq
2020-07-27 13:28
has joined #general

sidhartha.k.subudhi
2020-07-27 14:09
When I am testing creation of a defect in Jira trough API. I need to send an attachment (a word file or any screenshot). So I need to send the attachment along with the request. How can I do this in PACT?

saulof
2020-07-27 18:39
has joined #general

joaquin
2020-07-27 23:04
has joined #general

matt.fellows
2020-07-28 12:02
For those interested or unaware it?s happening, I?ve release a PoC of integrating Pact with Cypress. Read more over in the #cypress channel

matt.fellows
2020-07-28 12:02
Anyone doing work in that space, we?d love to get your thoughts and feedback if this is something we should pursue further

alexei.hmelevski
2020-07-28 13:30
Hi everyone, sorry if i used the wrong channel. I have a question is it possible to test contract like that. Im writing from the Consumer side for iOS but the question is more generic. More like is it possible? and does it make sense? Any opinion are valuable. Thank you. ```{ // Fixed payload "associatedEntities": [ { // fixed and dynamic payload (can be completely different based on the object) "associatedEntities": [ { //objects with different structures } ] } }```

david025
2020-07-28 15:02
has joined #general

daniel.pritchard
2020-07-28 15:03
has joined #general

guilherme.correa-ext
2020-07-28 19:34
has joined #general

guilherme.correa-ext
2020-07-28 19:39
Hi everyone, i don't know in what channel i should send this message but i and trying to upload 2 contracts for the same provider with version and tag but only one of these 2 contracts have the tags i verify that this is a know issue https://github.com/pact-foundation/pact-js/issues/289 My question is there is any thing i could make on my code to garanty that i will send the two contracts with tags ? or there is any estimate for when this bug will be fixed. Thanks for the help

jan.krejci
2020-07-28 20:09
has joined #general

paul.fairless
2020-07-28 21:44
has joined #general

javier.molina
2020-07-29 08:40
has joined #general

venkat.batchu81
2020-07-29 09:30
has joined #general

marco.dallagiacoma
2020-07-29 09:36
has joined #general

ivan.lombardiborgia
2020-07-29 09:40
has joined #general

matias.waterloo
2020-07-29 12:22
has joined #general

mike.geeves
2020-07-29 12:50
Breathe. FYI, vagueness due to I'm just coming to the end of a pretty intense period (about 12 years :smile:) of going through the crazy journey from sole 3rd party contractor dev to startup founder/first dev to head of tech/dev team, being bought out, "the things that happen when you're bought out" and finally now moving on. pact is on my list of tech I want to spend some time on while I take a little break :slightly_smiling_face: so many conversations the past few years of "if only we had some shared idea of the calls/payloads we wouldn't be in this mess" :joy: so yep, will certainly take a look, I just hope I can still remember how to code well enough :joy: little pause to get myself sorted before I get started on anything though

matt.fellows
2020-07-29 13:01
We?re here for you mate!

matt.fellows
2020-07-29 13:01
and also, congrats (I think?)

mike.geeves
2020-07-29 13:37
Thanks :slightly_smiling_face: I have no clue yet :rolling_on_the_floor_laughing:

amer.mohammed
2020-07-30 12:21
has joined #general

rafael.espillaque
2020-07-30 12:49
hi guys, I have a ?philosophical? question for you, when using Pact for messages. https://stackoverflow.com/questions/63173517/pact-flow-for-event-driven-applications I hope you can help me!

krisdinesh
2020-07-30 14:42
Hello Guys - I have a question on best practice. Kindly suggest your thought here. Running provider test post deploying to an instance is a good practice ? or Running provider test against codebase as soon as coding is completed(localhost)?

rafael.espillaque
2020-07-30 15:44
the best practice is to run them before even merging. Have a look at https://docs.pact.io/pact_nirvana and https://docs.pactflow.io/docs/workshops/ci-cd/

rafael.espillaque
2020-07-30 15:44
sorry, forgot to mention you @krisdinesh

krisdinesh
2020-07-30 16:57
Thanks @rafael.espillaque, so do we need to run the provider test again after we deploy/code merge?

abubics
2020-07-30 23:47
Running them again after deployment won't have any benefit, as long as the deployed things match the tested things.

abubics
2020-07-30 23:48
What you "need" to do depends on how much confidence you're trying to build.

abubics
2020-07-30 23:49
It's common, however, to run tests on merges, because that creates a new, unique set of code. You ideally want to test unique code, right?

krisdinesh
2020-07-30 23:52
In my case, doing provider test after merge has got great benefit to address multiple dev changes and also doing the same after deployment is totally different than localhost testing.

abubics
2020-07-30 23:54
If it gives you confidence, then go ahead :slightly_smiling_face: that's what testing is for. I guess I'd like to know why/how you'll get a different kind of confidence from contract tests in those environments, though.

krisdinesh
2020-07-30 23:56
Awesome

krisdinesh
2020-07-30 23:57
I totally agree with you....I am in process of identifying to best process here to fit....your point makes more sense

abubics
2020-07-31 00:19
I came for Pact, but stayed for the philosophy :troll:

abubics
2020-07-31 00:20
The way I tend to use Pact doesn't go very deep into either side of the network boundary, so re-running those tests after deploy wouldn't give me anything extra. I know many people use it differently, so it's horses for courses :innocent:

abubics
2020-07-31 00:21
It's always interesting to hear about the different setups people have, so if you end up with a new shape that you haven't read about, please share it somehow :party_parrot: People love blog posts and guides that better match their scenarios.

krisdinesh
2020-07-31 00:31
Thanks @abubics for your suggestion which clarified me few things regarding best practice.

sharath.konda
2020-07-31 15:02
has joined #general

ray.bradley
2020-07-31 16:39
has joined #general

francislainy.campos
2020-08-03 02:12
Hi, not sure if I understand the question fully but if you have your contract published to an online broker you should be able to verify against that.

francislainy.campos
2020-08-03 02:13
Owh, I see the rest of the conversation now. It's seem the issue is fixed, right?

bruno.penha
2020-08-03 07:54
has joined #general

bruno.penha
2020-08-03 08:02
Hello @channel: Does anyone already have this issue on not finding a feature file? It's repeating the project name... ```Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.01 sec <<< FAILURE! - in com.compay.project.rs.resources.MyCucumberNoPactITTest initializationError Time elapsed: 0.008 sec <<< ERROR! java.lang.IllegalArgumentException: Not a file or directory: C:\existing_path\<project_name>\<project_name>```

bruno.penha
2020-08-03 08:03
And this feature test exist on C:\existing_path\<project_name> but not in C:\existing_path\<project_name>\<project_name>

antonello
2020-08-03 08:15
It doesn?t look like a Pact problem, Bruno.

bruno.penha
2020-08-03 08:15
But this is blocking me to execute Pact tests

bruno.penha
2020-08-03 08:17
And you are right, seems more like a Cucumber problem than a Pact one...

antonello
2020-08-03 08:18
I appreciate that, but this is not the best place to get help with Cucumber. You might be better off asking on StackOverflow, a Cucumber forum or perhaps in your organisation.


bruno.penha
2020-08-03 08:21
Thanks, anto! I've already looked into Stackoverflow, but I'm not sure which is the appropriate channel for this question... I will browse the channels available :)

matt.fellows
2020-08-03 08:25
If you prove it?s a Pact issue, definitely here is a good place to ask. Ideally, you have an example repository we can look at to help.

matt.fellows
2020-08-03 08:25
I don?t hear cucumber here very often so I?d recommend trying Pact outside of Cucumber and getting that working first, and then integrating the two

matt.fellows
2020-08-03 08:26
otherwise you?re trying too many variables at once

bruno.penha
2020-08-03 08:28
You have a point, I'm looking int that - thanks :slightly_smiling_face:

william.isaksson795
2020-08-03 12:23
has joined #general

jarmy
2020-08-03 16:00
Is there a way to do exclusions when verifying pacts? E.g. to say that ?run all contracts except a, b?

antonello
2020-08-03 16:01
in what language?

jarmy
2020-08-03 16:02
Any language really, but JavaScript in this particular case

antonello
2020-08-03 16:03
the way you?d do it would be dependent on the languge

antonello
2020-08-03 16:03
in pact-jvm, you can, for example, filter by consumer

antonello
2020-08-03 16:03
and interactions

jarmy
2020-08-03 16:07
Is that done via `consumer_version_selectors`?

priyanshu.jain
2020-08-03 17:32
has joined #general

mthirupathi47
2020-08-03 18:02
has joined #general

voloshin1986
2020-08-03 18:25
has joined #general

matt.fellows
2020-08-03 23:37
Not with the flexibility I think you might want (albeit if you?re interested, please help vote on this RFC request: https://github.com/pact-foundation/pact-specification/issues/75#issuecomment-667624532)

matt.fellows
2020-08-03 23:37
You can run selected tests based on the interaction name/state or both: https://github.com/pact-foundation/pact-js#re-run-specific-verification-failures

bethskurrie
2020-08-03 23:42
@jarmy are you talking about excluding certain pacts based on a consumer name, or certain interactions (request/response pairs)? Which language?

matt.fellows
2020-08-03 23:42
He mentioned JS

jarmy
2020-08-03 23:43
Yes, JS. And yes, the capability to exclude certain pacts based on a consumer name.



matt.fellows
2020-08-03 23:46
(The link in Pact JS is broken, looks like an old alias is broken - i?ll fix that now)

bethskurrie
2020-08-03 23:47
The selectors don't currently let you exclude based on a consumer name.

bethskurrie
2020-08-03 23:47
If you're using pending pacts though, failing consumers won't fail your test suite.


jarmy
2020-08-03 23:53
I believe consumer_version_selectors just support inclusion. The team I?m working on bringing Pact to has a pretty aggressive deployment model. Their biggest requirement at the moment is being able to dynamically include/exclude consumers on the fly without having to make code changes. I?ll mention pending pacts to them again to see if it will meet their needs

bethskurrie
2020-08-03 23:53
can you explain that further?

bethskurrie
2020-08-03 23:53
how do you exclude consumers?

bethskurrie
2020-08-03 23:53
what does that mean in terms of what is happening in real life?

jarmy
2020-08-03 23:56
For example, a pact verification breaks because of a bad action (bad pact) by a consumer. The provider team doesn?t want their deployments to be held up while waiting for the pact to be fixed by the consumer

bethskurrie
2020-08-03 23:56
If they're using can-i-deploy, they'd need to use the "manual" version of it, because we don't yet have the option to exclude a pacticipant (though it's on the feature request list) https://docs.pact.io/pact_broker/client_cli/readme#alternate-usage---specifying-dependencies-explicitly

matt.fellows
2020-08-03 23:57
> For example, a pact verification breaks because of a bad action (bad pact) by a consumer. The provider team doesn?t want their deployments to be held up while waiting for the pact to be fixed by the consumer That?s what pending Pacts are for: http://blog.pact.io/2020/02/24/how-we-have-fixed-the-biggest-problem-with-the-pact-workflow/

bethskurrie
2020-08-03 23:57
> The provider team doesn?t want their deployments to be held up while waiting for the pact to be fixed by the consumer Pending pacts will fix this.

jarmy
2020-08-03 23:57
Ah, let me chat with my teammates again

tim.den.dulk
2020-08-04 08:05
has joined #general

jeroen.kropman
2020-08-04 08:09
has joined #general

stephen.attard
2020-08-04 09:54
has joined #general

matt.fellows
2020-08-04 10:34

sschectman
2020-08-04 14:17
Is there a way to establish state in consumer tests ? I am working with an API call that has a foreign key constraint and should work only if the foreign key exists

rafael.espillaque
2020-08-04 14:25
but, isn?t the foreign key in the provider side?

matt.fellows
2020-08-04 23:31
Yep, that?s what provider states are for Shifra

matt.fellows
2020-08-04 23:32
The consumer says ?the provider should be in _<some state>?_ and just before that test is run on the provider, it gets an opportunity to setup for that interaction



francis.lobo
2020-08-05 01:39
Pact newbie here. Does anyone know of any open source projects that use Pact ? I am interested in looking for some real world use cases to see how PACT usage evolves over time in real projects.

matt.fellows
2020-08-05 01:41
Well, it well depend on the language. For example, if you go to the Pact JS repo you can see the ?used by?. I know Pact is used in the IBM cloud tooling

matt.fellows
2020-08-05 01:42
I?m not aware of any high profile OSS projects using it, but would love to hear about them if they exist

francis.lobo
2020-08-05 01:43
sweet! that is exactly what I want. Thanks for pointing out :slightly_smiling_face:

tjones
2020-08-05 02:12
This is an awesome question! Would love to hear what you find out from your investigation, if it's easily summarisable

sklein
2020-08-05 13:20
How have individuals approached provider verification where the provider actually sits behind a proxy/gateway in production that handles redirects/rewrites for the path? In this scenario the consumer generated contract is listing the expected pathing to the proxy, but that path doesn't actually exist in the provider impl.

egor.ostapenko
2020-08-05 13:43
has joined #general

uladzislau_danilchyk
2020-08-05 14:11
@matt.fellows I have found following solution. You can define method with `@PostConstruct` and inside of it create `HttpTarget` instance. Could it be noted in your docs for JVM version of Pact? It would be quite useful.

matt.fellows
2020-08-05 14:22
There may be an article on our docs about this, I can?t quite recall

sklein
2020-08-05 14:23
Perfect, I'll take a read

sklein
2020-08-05 14:23
Thanks!

matt.fellows
2020-08-05 14:25
If it?s _just_ the path mapping it?s doing, then you can do a few things: 1. Run the proxy as part of the tests (or replace it with a suitably simpler/dumb proxy layer) 2. Configure the BaseURL in the consumer tests pact to have the path of the actual provider 3. Configure the provider side pact test to know about this path 4. Manipulate the pact before it hits the provider to re-write the paths. More dangerous, but things like request filters (in JS/JVM/Go) can do that fairly safely). It should be easy enough to put a layer

matt.fellows
2020-08-05 14:25
they all have good/bad bits to them, but it?s going to be better than creating a whole new pact interaction between the proxy as well

sklein
2020-08-05 14:26
I figured 1) might be the answer which, in our case, might be the best approach since we already spin up an nginx proxy in the verification stack to run ssl termination. I was hoping we maybe wouldn't need to carry forward the redirects also, but that's fine

sklein
2020-08-05 14:27
Yes creating pacts with the proxy was not something I wanted to hear :slightly_smiling_face:

ukrainian1991
2020-08-05 16:37
Hi, does pact work with several interactions in single @ Pact method? ```@Pact(provider = "B", consumer = "A") public RequestResponsePact pactForGenerateFullProfile(PactDslWithProvider builder) { return builder .uponReceiving("request correct get_devices_metainfo") .path("/cpe/get_device_metainfo/200") <<<< the first .method("POST") .headers(headers) .body(...) .willRespondWith() .status(200) .headers(headers) .body(...) .uponReceiving("request generate full profile") <<< the second .path("/cpe/generate_profile/200") .method("POST") .headers(headers) .body(...) .willRespondWith() .status(200) .headers(headers) .body(...) .toPact(); }```

phil.endsley
2020-08-05 17:25
I'd try asking in #pact-jvm since this is specific to that library

jbradyj
2020-08-05 21:01
has joined #general

matt.fellows
2020-08-05 22:39
that being said, it?s possibly a use case we could support better. If you had ideas don?t be afraid to raise a feature request

matt.fellows
2020-08-05 22:39
one example could be to allow a configurable ?base path? type thing in the verification process. I think at the moment it only accepts a hostname and the path is ignored. I may be wrong there

matt.fellows
2020-08-05 22:41
but TL;DR yes

2020-08-06 07:08
A new post has been created in *Feature Requests*

ashish_garg5
2020-08-06 09:23
Hi, Is there any specific channel for pact-node ? i am using angular 8 and facing issue while downloading pact dependencies. want to know which version is compatible with Angular 8. Thanks.

matt.fellows
2020-08-06 09:34
There is a channel for that. It's named exactly that

ashish_garg5
2020-08-06 09:36
ok thanks

matt.fellows
2020-08-06 09:36
:+1:

sam.tavakoli
2020-08-06 10:29
has joined #general

sam.tavakoli
2020-08-06 11:02
Hi all, I'm currently trying to understand the pactbroker.pactURL variable substitution and when the structure was changed. We were running pact broker 2.19.2-1 and upgraded it to 2.57.0.0 the url structure of pactURL changed from https://pactbroker.local/pacts/provider/foo/consumer/bar/version/consumer_version_number to https://pactbroker.local/pacts/provider/foo/consumer/bar/pact-version/somehash/metadata/base64data_with_consumer_version_number_etc I'm wondering if this is the commit that changed the behaviour: https://github.com/pact-foundation/pact_broker/commit/426b0b19 Would it be possible to configure the behaviour of this pactURL substitution?

matt.fellows
2020-08-06 11:24
Hi Sam, this might best be asked in the #pact-broker channel

matt.fellows
2020-08-06 11:26
You might also be best mentioning why it?s an issue for you.

hadjaliabir
2020-08-06 12:17
Hello everyone ! can i change the folder (target\pacts) where my pacts are generated ?

rafael.espillaque
2020-08-06 12:43
if using java and junit, you can use the @PactFolder annotation

ranjanayush03
2020-08-06 13:34
Ye s you can do that by setting the rootDir like for example if you want it to be present inside build folder then pact.rootDir =("build/pacts") might work for you include this in your consumer side test cases.

hzhang1
2020-08-06 20:18
has joined #general

jacques.murekezi
2020-08-07 08:24
has joined #general

jacques.murekezi
2020-08-07 08:44
@here I am having trouble setting up my test: I have an Api (.net core), The point of entry is a controller/action. the controller calls the service. In terms of making consumer/Producer is the controller the producer and Service call the consumer?

abubics
2020-08-07 10:20
Probably want to hop over to #pact-net :slightly_smiling_face:

jan.krejci
2020-08-07 18:22
Hi guys, I have a question : Is it a best practice to have the same consumer name if my consumer has two different providers? It is because I can set up a different name for each Pact like that `- @Pact(provider = "AccountBalanceProvider", consumer = "AccountConsumer")`

camila.pinto-ext
2020-08-07 18:25
hi jan!

bzifkin
2020-08-07 18:33
Hey all....my organization does feature branch development. Branch names are guaranteed to be unique. I know that pacticipant version numbers are usually recommended as app version numbers plus a git sha, and tthat branch name is recommended for tagging

bzifkin
2020-08-07 18:34
however if the branch names are guaranteed to be unique would that make them a good choice for pacticipant versions as well?

phil.endsley
2020-08-07 18:38
Don't you have a "main" branch you merge into/release from? Any pacts generated from that would all have the same version, and you should be generating pacts with each build (each time you merge) In addition, any branch that has multiple builds would have multiple pacts generated with a shared version as well.

bzifkin
2020-08-07 18:52
so we utilize a pr system and a portion of our CI/CD pipeline runs then. I was thinking that at that time we would publish/version. Then when we merge to master theres no publishing/verification

bzifkin
2020-08-07 18:53
i see your point about the multiple pacts w/ a shared version though....esp if the consumer expectations get changed in two separate commits to the same branch

bzifkin
2020-08-07 18:57
alright then - i guess we'll use the commit sha to version...i kinda wanted to branch names just cause ive been having a hell of a time getting the commit sha into the version

bzifkin
2020-08-07 19:13
@phil.endsley how does your org get the commit sha to put it in the version number

phil.endsley
2020-08-07 19:22
The way we derive our application versions is over-engineered and complicated. So much so, that we wrote a gradle plugin that does it for us. The commit sha is involved in that process, so we get it for "free" Essentially, the part you care about boils down to running `git rev-parse --short HEAD` Also, your CI server might already provide it and expose that for you? We use Bamboo and it does this out of the box I believe. Would have to dig through your CI's documentation to find out though...

mamtha.3687
2020-08-07 20:08
Have a similar issue. Could use some help if this has been solved @jarmy. We're trying to do pact verify in Jenkins. Unable to get the localhost up for the pactverify to succeed. Getting a connection refused error (obviously because the localhost:8080 isn't running. What I am looking for is, is there a way to run the java springboot app im background in the CI at least until pactVerify runs and then if I can just kill it.

jarmy
2020-08-07 20:18
I might be wrong but I think you?ll want to annotate your verify test class with `SpringBootTest`. You might get better advice in #pact-jvm

bzifkin
2020-08-07 20:35
hmm...we use jenkins to run gradle scripts

bzifkin
2020-08-07 20:36
the issue is that no matter what i do w/ gradle i cant get it to run the command that gets the commit sha

matt.fellows
2020-08-07 22:12
Yes you should keep the same name

victor.mansilla.munoz
2020-08-08 03:49
has joined #general

tjones
2020-08-10 02:48
I usually include the branch name in the version string

tjones
2020-08-10 02:49
Because Pact has some requirements about version numbers, I've been thinking that it might be useful for us to provide gradle plugins (etc) that provide version numbers

steve.mackinnon
2020-08-10 03:10
has joined #general

vit.barabash
2020-08-10 08:05
has joined #general

stanislav.ondac
2020-08-10 10:05
has joined #general

coduo123
2020-08-10 11:12
has joined #general

sam.tavakoli
2020-08-10 13:48
Hi All, According to https://docs.pact.io/pact_broker/#step-2-provider-ci-build it says "The provider has a verification task that is configured with the URL to retrieve the latest pact between itself and the consumer." Why is it latest and not the specific interaction that triggered the content_change webhook? Imagine if there are two PR's on a consumer project which changes interactions with provider. How would Provider be able to distinguish them two if it only looks at latest interaction?

matt.fellows
2020-08-10 13:51
It's a good question! Of course, you can configure all of those things :wink:

matt.fellows
2020-08-10 13:52
Read the effective pact setup guide goes through all of this

matt.fellows
2020-08-10 13:52
The CI/CD workshop is also very good and more detailed when you're ready to implement

sam.tavakoli
2020-08-10 13:53
CI/CD workshop is specific for pactflow if I'm not mistaken? Is this the effective pact setup guide? https://docs.pact.io/pact_nirvana

sam.tavakoli
2020-08-10 13:53
Thanks for the quick response @matt.fellows

sidhartha.k.subudhi
2020-08-10 13:55
Hi,

nkelly
2020-08-10 14:20
has joined #general

bzifkin
2020-08-10 16:22
that would be great, for such a simple things it been pretty difficult to get it to work well

nodirbek
2020-08-10 21:18
has joined #general

matt.fellows
2020-08-10 22:04
It uses Pactflow but the principles are the same

matt.fellows
2020-08-10 22:05
You can achieve the same thing using the OSS broker and the entire workshop is compatible with both

bethskurrie
2020-08-11 06:37
@sam.tavakoli if you configure it correctly, in the "contract changed" workflow, you *are* verifying the one that has changed.

bethskurrie
2020-08-11 06:37
There are two flows - one when the provider changes, and one when the contract changes.

bethskurrie
2020-08-11 06:38
When the contract changes, the Pact Broker triggers the webhook with the URL of the changed pact, which gets passed through to the build.


bethskurrie
2020-08-11 06:41
The docs on the particular page you're on should be updated to make that clearer - they're quite old.

sam.tavakoli
2020-08-11 07:28
Thank you Beth, I did have a deeper read of it and it's more clear now. What wasn't clear in that article was the use of latest without mentioning tags. If I have two PR's where I use their branch name as tag then choosing the latest pact content based on this makes more sense than 'latest interaction'. https://docs.pact.io/getting_started/versioning_in_the_pact_broker This page was hugely helpful in understanding how pact does it also behind the scene

sam.tavakoli
2020-08-11 07:29
That's good to know, cheers!

bethskurrie
2020-08-11 07:37
> What wasn't clear in that article was the use of latest without mentioning tags

bethskurrie
2020-08-11 07:37
Those docs were originally written 6 years ago, and have been incrementally updated - I should just remove them and point to the other ones that I sent to you.

ales.orel
2020-08-11 08:08
has joined #general

jacques.murekezi
2020-08-11 15:54
Hi All, I have this function: ```saveApplication(details: Application): Observable<any> { return http://this.http.post(`http://localhost:5000/Apply`, details); }``` And I am writing a Pact Test for it (API contract testing) and below is the test: ```describe('ApplicationService contract testing', () => { let provider: PactWeb; let applicationService: ApplicationService; beforeAll(function (done) { provider = new PactWeb({ cors: true, host: '127.0.0.1', port: 9776, logLevel: 'error' }); setTimeout(done, 2000); provider.removeInteractions(); }); afterAll(function (done) { provider.finalize().then(function () { done(); }, function (err) { done.fail(err); }); }); beforeEach(() => { TestBed.configureTestingModule({ providers: [ApplicationService], imports: [HttpClientTestingModule] }); applicationService = getTestBed().get(ApplicationService); }); afterEach((done) => { provider.verify().then(done, e => done.fail(e)); }); describe('Save', () => { const _details: Application = { title: 'Mr', firstName: 'Application', lastName: 'applicant', dob: new Date(1977, 10, 10).toString(), gender: 'M' }; beforeAll((done) => { provider.addInteraction({ state: ' a task to save the dashboard application to mongo', uponReceiving: ' a request to post', withRequest: { method: 'POST', headers: { 'Content-Type': 'application/json' }, path: '/Apply', body: _details }, willRespondWith: { status: 201, headers: { 'Content-Type': 'application/json' } } }).then(done, e => done.fail(e)); it('should call the API to Post the application Content', (done) => { const _response: any = {}; applicationService.saveApplication(_details).subscribe(res => { expect(res).toEqual(_response); done(); }, error => { done.fail(error); } ); }); }); }); });``` The test isn't running when id npm run test or ng test, ut the pacts directory is being created. I don't know what is missing from my configs This is what I have in Karma: ``` frameworks: ['jasmine', '@angular-devkit/build-angular','pact'], plugins: [...., require('@pact-foundation/karma-pact')], pact: [{ cors: true, port: 9776, consumer: "ui", provider: "Apply", dir: "pacts/", spec: 2 }], proxies: { '/api/applications/v1/': 'http://localhost:9776/Apply/' },``` Not sure what I am missing. any help?

elliottmurray
2020-08-11 16:28
probably for #pact-js ?

bret.mcclory
2020-08-11 18:39
has joined #general

bret.mcclory
2020-08-11 18:53
Hi there, new user. Trying to test out WIP pacts, hopefully missing something simple here. Uusing http://Pactflow.io and the pact-net client. The broker is stubbornly refusing to return any WIP pacts in the resp. Verbose logging shows I'm getting an empty collection in the /for-verification request, despite including the "includeWipPactsSince" flag. ```"POST /pacts/provider/[REDACTED]/for-verification HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nContent-Type: application/json\r\nAuthorization: [redacted]\r\n" <- "{\"includePendingStatus\":true,\"consumerVersionSelectors\":[{\"tag\":\"master\",\"latest\":true},{\"tag\":\"prod\",\"latest\":true}],\"providerVersionTags\":[\"bret-test\"],\"includeWipPactsSince\":\"2020-07-12\"}" -> "HTTP/1.1 200 OK\r\n" -> "Date: Tue, 11 Aug 2020 18:32:08 GMT\r\n" -> "Content-Type: application/hal+json;charset=utf-8\r\n" -> "Content-Length: 160\r\n" -> "Connection: keep-alive\r\n" -> "Status: 200 OK\r\n" -> "X-Pactflow-Git-Sha: 99df8905\r\n" -> "Vary: Accept\r\n" -> "X-Pact-Broker-Git-Sha: 2c140da0\r\n" -> "X-Request-Id: 59f7ce580157e8d8c8c3e1da811e032e\r\n" -> "X-Pact-Broker-Version: 2.59.1\r\n" -> "X-Frame-Options: SAMEORIGIN\r\n" -> "X-XSS-Protection: 1; mode=block\r\n" -> "X-Content-Type-Options: nosniff\r\n" -> "Referrer-Policy: strict-origin\r\n" -> "Strict-Transport-Security: max-age=31536000 ; includeSubDomains\r\n" -> "\r\n" reading 160 bytes... -> "{\"_embedded\":{\"pacts\":[]},\"_links\":{\"self\":{\"href\":\"https://[REDACTED].http://pactflow.io/pacts/provider/[REDACTED]/for-verification\%22,\%22title\%22:\%22Pacts to be verified\"}}}"``` Looking in Pactflow UI, I see an unverified pact hanging out there for this provider (published an hour ago) with a tag that doesn't match the explicit ("prod" and "master") in the request. I expected this Pact to get returned and verified (in pending mode). Suggestions?

phil.endsley
2020-08-11 19:48
> "providerVersionTags\":[\"bret-test\"] Do you have a provider version that is tagged with `bret-test` already? The tag you send in `providerVersionTags` has to already be existing

briana.mcn
2020-08-11 19:48
has joined #general

bret.mcclory
2020-08-11 19:50
I was wondering about that. No, I don't. I'm doing this entirely via the pact-net client right now, and looking at the verbose logs, it doesn't appear to be making any PUT/tag request (to establish the tagged provider version) before making this request /for-verification. Is that something I'll need to do explicitly out side of the pact-net client?

phil.endsley
2020-08-11 19:56
I'd check in #pact-net for specifics about how to do that with the pact-net client. I've never touched it, so can't help you there... I know the jvm libraries have ways to publish tags. I would be surprised if pact-net does not support that. I think best practice would be that you're tagging the provider (and consumer) versions when you publish verification results and pacts. The WIP pacts get picked up for the "main" branch build once you merge the provider in. I don't think you'll be able to tag a provider version before running the /for-verification request, since that's what pulls in the contracts to verify against. You won't have verification results to publish and tag, because you haven't pulled any down yet.

bret.mcclory
2020-08-11 19:59
I did make an explicit API call just now to establish a provider version with that tag -- PUT /pacticipants/[providername]/versions/[vers]/tags/bret-local -- and the request /for-verifications to include wip pacts still returns nothing. Is there some chicken/egg boostrapping issue here? I.e. does this provider (+version) need to have verified at least one pact before it really exists in the broker? I'm just starting out here, working in non-master branches, so I don't have _any_ published verifications for _any_ consumer versions of this Pact yet.

phil.endsley
2020-08-11 20:15
> /bret-local Not sure which one is right, but the logs you had above had `bret-test`, not `bret-local` The provider verification results have to be published for it to exist in broker to tag. Also, there's also a pretty solid workshop that walks through the whole workflow of pacts, including WIP pacts, if you haven't seen it: https://docs.pactflow.io/docs/workshops/ci-cd/

bret.mcclory
2020-08-11 20:19
I'm still trying to grok your first reply: > Do you have a provider version that is tagged with `bret-test` already? The tag you send in `providerVersionTags` has to already be existing What brings a provider version/tag into existence? Exploring the HAL Browser, I observe that "providers" are created on-the-fly when a new Pact is published, but no versions/tags exist for that provider yet. I assumed that a provider versions would be created on-the-fly when verification results are published during CI builds. On an initial build of a new provider tag (branch), that tag won't exist yet in the Pact broker, so I don't know how it could be "already existing" for purposes of this wip feature. But I'm sure I'm overlooking something fundamental here.

bret.mcclory
2020-08-11 20:19
BTW thanks for helping out, and good catch on the -test / -local diff, I'll double check.

phil.endsley
2020-08-11 20:19
I don't think WIP pacts are great for the feature branch being developed. I think the use case it was trying to solve was fixing the merging workflow for a consumer and provider feature branch. If you're doing feature branch development, ~the~ a happy path where everything "just works" seems to be: ? Develop consumer in feature branch ? Develop provider in feature branch ? Merge provider ? Merge consumer WIP pacts make it easy to go from "merge provider" to "merge consumer". After using starting to use the feature, it doesn't seem like it makes sense to leverage WIP pacts for a provider feature branch. @bethskurrie feel free to correct me

phil.endsley
2020-08-11 20:30
> On an initial build of a new provider tag (branch), that tag won't exist yet in the Pact broker, so I don't know how it could be "already existing" for purposes of this wip feature. But I'm sure I'm overlooking something fundamental here. Yeah, it won't exist yet, so it won't pick up the WIP pacts I think it's worth opening the discussion about this though. This is the third time this has confused people (me being one of the three). I can see both sides though ? If /for-verification returned WIP pacts when the `providerVersionTags` does not exist in broker, that means all your existing pacts (since includeWipPactsSince) will be verified against new feature branches. Which is probably something most people don't want most of the time? Really, you only care about the one consumer feature branch you're implementing functionality for (I'm making assumptions :slightly_smiling_face: ) ? On the other hand, it seems like people expect it to return WIP pacts if the tag doesn't exist yet. But this is kind of strange for feature development if you think about it, because after the first successful verification, it won't pick it up anymore (because it's no longer WIP)

bret.mcclory
2020-08-11 20:31
I think I get what you're saying. > it doesn't seem like it makes sense to leverage WIP pacts for a provider feature branch. So the guidance may be, when dynamically fetching Pacts for verification, as demonstrated in the CI/CD workshop, you should only do `includeWipPactsSince` when provider tag == "master" (or something like that?) I was hoping the WIP feature would give me feedback that I've implemented my provider feature correctly -- i.e. verified the consumer feature Pact -- _before_ I merge it to master.

phil.endsley
2020-08-11 20:32
Yeah. Instead, you need to set up your provider in a way that the consumer version selectors would pick up your consumer feature pact.

phil.endsley
2020-08-11 20:33
As an example, one way would be to name your provider and consumer branches the same, and use that as the tag in a consumer version selector. Set it as an env var in your CI build so it would pick up the consumer feature pact

bret.mcclory
2020-08-11 20:33
Was afraid of that. Per the guidance of the CI/CD workshop, guess that means I either need to tinker with the verification code (and remember to undo changes before merge to master) or ensure that provider/consumer branch names are matching.

phil.endsley
2020-08-11 20:35
We're in the same boat. We can't name our branches the same, because we have unique prefixes to match tickets. I wrote up a feature request to support regex for tags though. It would solve it for us, not sure if it would help you as well. https://pact.canny.io/feature-requests/p/allow-version-selectors-to-specify-tags-with-regex

bret.mcclory
2020-08-11 20:36
I'll have a look. Thanks again for your help!


sschectman
2020-08-12 14:25
Getting this error when verifying a pact with state : Error setting up provider state at http://localhost:54926/_pactSetup

hzhang1
2020-08-12 14:29
hello all, anyone has some code sample for using pact-python against graphql endpoint?

bzifkin
2020-08-12 19:28
Hello all. I asked this question in #pact-jvm but figured id ask here as well. For the provider tests it seems like the entire service has to spin up. Some of our provider services take anywhere from 10-20 minutes to spin up (using docker)

bzifkin
2020-08-12 19:29
one of our goals is to speed things up so this isnt kinda a barrier to entry....how have people handled this in their implementations of pact?

abubics
2020-08-13 00:25
Best to ask in a channel specific to your provider platform (e.g. #pact-jvm, #pact-js, etc)

matt.fellows
2020-08-13 04:19
are you running them on an external platform (e.g. deploying to Kube/ECS/GKE or something)?

matt.fellows
2020-08-13 04:19
Or locally?

matt.fellows
2020-08-13 04:19
(hint: you should do it locally)

matt.fellows
2020-08-13 04:20
yep, please do that and share some code that you?ve written (ideally share the states setup bit at a minimum, and the entire log)

matt.fellows
2020-08-13 04:20
see the debug section in the Pact JS docs

lucasmat.7
2020-08-13 07:36
has joined #general

subash.gururaj
2020-08-13 12:00
has joined #general

amod.shankar
2020-08-13 12:59
has joined #general

bzifkin
2020-08-13 14:33
Yeah running them on an external platform

bzifkin
2020-08-13 14:35
in the case of a consumer merge our jenkins pipeline would kick off provider(s) verification test and that would need to build on the platform wouldnt it?

andrea.spina
2020-08-13 16:14
has joined #general

tom.wilson
2020-08-13 18:13
has joined #general

ziadtawfeek05
2020-08-13 19:34
has joined #general

matt.fellows
2020-08-13 21:24
We would recommend you don't test providers on a deployed environment but rather a locally running provider (e.g. on the CI server itself or locally on dev machines when making changes)

bzifkin
2020-08-13 21:31
sorry i think i may have misunderstood.... it would be running on a CI server, but we would be spinning it up on demand based on the test

bzifkin
2020-08-13 21:31
and the spinning up could take a while if the full docker image is built

iesmite
2020-08-14 00:37
has joined #general

bethskurrie
2020-08-14 00:38
Is there a way you can test the app directly, or does it have to be spun up via docker?

bethskurrie
2020-08-14 00:39
@hzhang1 not that I've seen. There are some js examples, but pact python doesn't have any graphql helpers. You would have to hand code the expectations.

bethskurrie
2020-08-14 00:41
The app that I'm working on at the moment is Pactflow (funnily enough :laughing: ). It gets deployed as a docker image. Pactflow has Pact verification tests that run just after the unit tests. We test the application directly - we don't build it first.

bethskurrie
2020-08-14 00:41
We want the feedback to come as early as possible - waiting for a docker image to be built would slow down the feedback cycle.

bethskurrie
2020-08-14 00:42
Ideally, you want to be able to run the pact tests as early as possible in the release pipeline. Is that possible for you?

matt.fellows
2020-08-14 02:53
And a follow up to this (to help with the ?pact is slower than what we had? argument), what did you do to test things before?

preethighalke
2020-08-14 07:13
Hi, we are trying to publish pact to a pact broker using the maven plugin, but end up with this error intermittently: ```Failed to execute goal [32mau.com.dius:pact-jvm-provider-maven:4.0.10:publish[m [1m(default-cli)[m on project [36mpublisher-pact[m: [1;31mExecution default-cli of goal au.com.dius:pact-jvm-provider-maven:4.0.10:publish failed: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 337 column 3 path $[m ->``` we have this defined in our build: <plugin> <groupId>http://au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>4.0.10</version> <configuration> <pact.showStacktrace>true</pact.showStacktrace> <pactBrokerUrl>${broker.url}</pactBrokerUrl> <projectVersion>${project.version}</projectVersion> <trimSnapshot>true</trimSnapshot> <!-- Defaults to false --> <skipPactPublish>false</skipPactPublish> <!-- Defaults to false --> </configuration> </plugin> Are we missing anything? any reference would help. Regards.

matt.fellows
2020-08-14 07:14
what does your pactfile look like? It seems to be reporting its invalid json

preethighalke
2020-08-14 07:20
the pact jsons that are getting generated using the consumer tests are very much valid, used json validator to validate the generated Json, but the maven plugin fails.

matt.fellows
2020-08-14 07:21
then my next guess is that it?s not able to communicate to the broker and is not getting a valid JSON response

matt.fellows
2020-08-14 07:21
maybe enable debug logs to see what the plugin can see?

preethighalke
2020-08-14 07:25
The connection to broker looks fine as mvn pact:publish works sometimes and when it fails it shows the error mentioned above. we have this enabled <pact.showStacktrace>true</pact.showStacktrace> but we could not see any more debugs

matt.fellows
2020-08-14 07:26
fair enough - that?s about as far as I can go as I don?t know anythting about the Maven setup I?m afraid

preethighalke
2020-08-14 07:33
ok i thought the issue is with the pact maven plugin as it handles the response from the pact broker and i was unable to set the ```JsonReader.setLenient(true)``` for the plugin

os.shulyak
2020-08-14 09:03
Hey there. Got a question regarding Messages testing with PACT for PHP. Is that available now or it?s only for JVM ?


krisdinesh
2020-08-14 13:39
Hello All - I am successfully able to implement PACT for our Client and tones of thanks to all the folks who helped to answer my questions and I would like to call out @matt.fellows for his kind help. This is really a fantastic tool for contract testing for sure. Thank you all :slightly_smiling_face:

ruchika.lakhina
2020-08-14 15:42
has joined #general

bzifkin
2020-08-14 20:41
@matt.fellows sorry its definitely not slower, but its not much of an improvment

bzifkin
2020-08-14 21:05
@bethskurrie so what would happen rn is we would push a feature branch for a consumer, kicking off our jenkins pipeline, after unit tests we would hit the pact broker and tell it to begin any applicable provider verification tests. So the verification tests would be after unit tests but before the integration tests of the consumer itself. I'm just concerned that adding in the call for the provider verification tests will be time consuming b/c the providers need to be spun up

bzifkin
2020-08-14 21:06
I think i maybe missing something here, sorry if this is a silly question

uglyog
2020-08-15 02:42
Does it go through a proxy server?

alexfdz
2020-08-17 06:04
has joined #general

alexfdz
2020-08-17 06:15
Aloha Pact! I?m trying to find good practices around sharing our pacts with internal/external devs in a more friendly way than json. Anyone here doing something like that? Docs autogeneration of some sort? We would love to expose something similar to the pactflow generated docs, but in our own content provider.

alexfdz
2020-08-17 06:19
I found something for https://github.com/pact-foundation/pact-ruby/wiki/Autogenerated-documentationbut it does not seem available in other languages (we are with pact-go)

tjones
2020-08-17 06:33
I haven't done anything like this, but I'm interested. What's the use case?

tjones
2020-08-17 06:35
I tend to think that pact (and also swagger) is for machines to read, not humans. However, sometimes there needs to be supporting information with the contract in order to implement the provider side - especially around provider state. So there are probably some improvements or helpful recommendations we could make in the documentation.

alexfdz
2020-08-17 06:35
We generate the Pact for some consumers (internal) of our API, and they would like a more friendly docs


alexfdz
2020-08-17 06:36
Pactflow?s outcome is probably good enough, but we would like to publish it with our internal API docs

alexfdz
2020-08-17 06:38
thanks @matt.fellows! I guess is a standalone version of https://github.com/pact-foundation/pact-ruby/wiki/Autogenerated-documentation

tjones
2020-08-17 06:41
> We generate the Pact for some consumers (internal) of our API, and they would like a more friendly docs Are your consumers not controlling their own pacts?

tjones
2020-08-17 06:42
If you only have one consumer and one provider, a pact (often) enumerates all the endpoints. However, when there are multiple endpoints, not all pacts will use all endpoints (or all parts of a response). For this reason, it's hard to document or draw an entire picture of what is available in the API from pacts

alexfdz
2020-08-17 06:42
not all of them? We are trying to move them to CDC

alexfdz
2020-08-17 06:43
`pact docs` is probably more than enough!

tjones
2020-08-17 06:43
It is possible to draw a picture of what is used - I remember talking (maybe with @bethskurrie?) a while back about creating something that would take a swagger doc and a pact, and colour the parts of the API that were unused

tjones
2020-08-17 06:44
I didn't build anything on it, but I think it would be a cool tool

tjones
2020-08-17 06:45
I'm keen to hear more about what you're up to - are you saying you have like "example pacts" that you share with your consumers who aren't using CDC yet?

tjones
2020-08-17 06:46
or do you share other consumer's pacts?

matt.fellows
2020-08-17 06:46
The atlassian mock validator could be a starting point to do that btw Tim

tjones
2020-08-17 06:47
Yes, potentially. I was looking at it the other day for another reason

os.shulyak
2020-08-17 08:34
Morning. I?m trying it implement PACT messages in php with this example https://github.com/pact-foundation/pact-php#message-support , but i?ve got the error with using of `ExampleMessageProvider` class, and the error looks like this: ```Error : Class 'MessageProvider\ExampleMessageProvider' not found``` and this is the namespace that i use: ```use MessageProvider\ExampleMessageProvider;``` For now, have no idea how to fix that..

matt248
2020-08-17 08:51
has joined #general

alex.elmekeev
2020-08-17 09:29
has joined #general

matt.fellows
2020-08-17 10:34
Might best ask in #pact-php


tomas.bruhn
2020-08-17 13:32
has joined #general

damianattademo
2020-08-18 01:39
has joined #general

alexfdz
2020-08-18 10:46
@tjones we are trying to use ?example pacts? for endpoints with consumers not CDCing, so we get: ? Integration tests ? Documentation of our API to share with them ? Mocks to share with them ? A way to convince them to create the pacts by themselves

sidhartha.k.subudhi
2020-08-18 14:47
Need help on how to write provider test for POST and DELETE requests. If anybody can give some example it will be great help.

sidhartha.k.subudhi
2020-08-18 14:48
Just need help the functionality of injectAccessToken(HttpRequest request)

vladyslav
2020-08-18 15:08
has joined #general

francislainy.campos
2020-08-18 16:06
```package com.hmhco.crs.v2.pact_tests.consumer; import au.com.dius.pact.consumer.dsl.DslPart; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.consumer.junit5.PactConsumerTestExt; import au.com.dius.pact.consumer.junit5.PactTestFor; import au.com.dius.pact.core.model.RequestResponsePact; import au.com.dius.pact.core.model.annotations.Pact; import io.restassured.RestAssured; import io.restassured.response.Response; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import java.util.HashMap; import java.util.Map; import static com.hmhco.crs.v2.config.Constants.CRS_SERVICE; import static com.hmhco.crs.v2.config.Constants.ED_UI; @ExtendWith(PactConsumerTestExt.class) public class PACTConsumerEdUiCrsTest { Map<String, String> headers = new HashMap<>(); String getRecommendations = "/api/v1/getRecommendations"; @Pact(provider = CRS_SERVICE, consumer = ED_UI) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); DslPart body = new PactDslJsonBody() .object("students") .eachKeyLike("2d6c9d8b-b3d4-4a7c-8e4b-3211e2a1df17") .stringType("refId", "2d6c9d8b-b3d4-4a7c-8e4b-3211e2a1df17") .stringType("lasid", "818-29-6858") .stringType("email", "") .stringType("username", "QAStudent9_92023601_int") .stringType("grade") .object("name") .stringType("firstName", "Nathanael") .stringType("middleName", null) // this may or not be null for some users. Remove it from contract. .stringType("lastName", "Nathanael") .closeObject() .closeObject() .closeObject() .eachLike("skills", 1) .stringType("id", "7810fb5f-a45d-41af-baeb-ac08dd10546b") .stringType("title", "Read Words with Consonant \\\"r\\\" /r/") .stringType("skillRecommendationReason", "Progressing: this student is progressing towards proficiency with the following standards and will benefit from additional instructions and practice.") .array("students") .closeArray() .eachLike("contentRecommendations") .stringType("identifier", "l_479ac4a4-6fc3-4323-9609-ca614c672016_ac54bcae-235c-4d50-a5d8-bca2767dabe7") .decimalType("score", 1.2450236288128311) .array("contentRecommendationReason") .string("The next items in the TOC matching the skill") .closeArray() .closeArray() .closeArray(); return builder .uponReceiving("getRecommendations") .path(getRecommendations) .method("POST") .headers(headers) .body(" { \"discipline\": \"ED18_RLA\", \"programs\": [\"ELA_IR_G1_NA\"], \"sectionId\": \"357e6a22-ea67-458f-8d1a-7e15ec8d4cce\" }") .willRespondWith() .body(body) .toPact(); } @Test @PactTestFor(providerName = CRS_SERVICE, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; Response response = RestAssured .given() .headers(headers) .when() .body(" { \"discipline\": \"ED18_RLA\", \"programs\": [\"ELA_IR_G1_NA\"], \"sectionId\": \"357e6a22-ea67-458f-8d1a-7e15ec8d4cce\" }") .post(getRecommendations); assert (response.getStatusCode() == 200); } }```

francislainy.campos
2020-08-18 16:06
```package com.hmhco.crs.v2.pact_tests.provider; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit5.HttpsTestTarget; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider; import com.hmhco.crs.v2.config.UserType; import com.hmhco.crs.v2.config.Constants; import org.apache.http.HttpRequest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; @Provider(Constants.CRS_SERVICE) /* Uncomment this and comment @PactBroker instead to test locally by pasting a .json file for the contract under the target/pacts folder */ //@PactFolder("target/pacts") @PactBroker(host = Constants.BROKER_PACT_URL, consumers = {Constants.ED_UI}) public class PactProviderEdUiCrsTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", Constants.AUTHORIZATION_TOKEN); context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(Constants.BASE_PACT_CRS_V2_URL, 443, "/")); Constants.getAuthorizationToken(UserType.TEACHER); } @State("getRecommendations") public void sampleState() { } }```

francislainy.campos
2020-08-18 16:08
This is the whole piece of code for both consumer and provider for what we have here on our side for POST example.

francislainy.campos
2020-08-18 16:09
And unless the body for the response for the delete method is consumed by the UI it may not be something you'd have on PACT but rather under a functional test instead.

sidhartha.k.subudhi
2020-08-18 17:46
Here is my code: Consumer: - ```package com.sap.icn.mlp.consumer.petClinic; import au.com.dius.pact.consumer.ConsumerPactBuilder; import au.com.dius.pact.consumer.Pact; import au.com.dius.pact.consumer.PactProviderRuleMk2; import au.com.dius.pact.consumer.PactVerification; import au.com.dius.pact.consumer.dsl.PactDslJsonBody; import au.com.dius.pact.consumer.dsl.PactDslWithProvider; import au.com.dius.pact.model.RequestResponsePact; import com.sap.icn.mlp.Constants; import org.junit.Rule; import org.junit.Test; import static io.restassured.RestAssured.*; public class Post_AddPetType_Consumer { private final String PROVIDER = "petType_provider"; private final String CONSUMER = "petType_consumer"; @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2(PROVIDER, "localhost", 8081, this); @Pact(provider=PROVIDER, consumer=CONSUMER) public RequestResponsePact addPetTypeContract(PactDslWithProvider builder) { return ConsumerPactBuilder .consumer(CONSUMER) .hasPactWith(PROVIDER) .uponReceiving("a POST request to create a pet type.") .path(String.format(Constants.PETTYPE))// POST http://localhost:8081/petclinic/api/pettypes .method("POST") .willRespondWith() .status(201) .matchHeader("Content-Type", "application/json;charset=UTF-8") //; [Cc]harset=UTF-8 .body(new PactDslJsonBody() .integerType("id",7) .stringValue("name", "Reptile")) .toPact(); } @Test @PactVerification(value=PROVIDER, fragment = "addPetTypeContract") public void shouldBeAbleToAddPetType() { given() .baseUri("http://localhost:8081") .header("Content-Type", "application/json;charset=UTF-8") // .header("Accept-Encoding","gzip, deflate, br") .body("{\n" + "\"id\": 8,\n" + "\"name\": \"Hatch1\"\n" + "}") .post("/petclinic/api/pettypes/") .then() .assertThat() .statusCode(201); } }``` Provider: ```package com.sap.icn.mlp.provider.petClinic; import au.com.dius.pact.provider.junit.PactRunner; import au.com.dius.pact.provider.junit.Provider; import au.com.dius.pact.provider.junit.State; import au.com.dius.pact.provider.junit.TargetRequestFilter; import au.com.dius.pact.provider.junit.loader.PactBroker; import au.com.dius.pact.provider.junit.loader.PactFolder; import au.com.dius.pact.provider.junit.target.HttpTarget; import au.com.dius.pact.provider.junit.target.Target; import au.com.dius.pact.provider.junit.target.TestTarget; import com.sap.icn.mlp.Constants; import com.sap.icn.mlp.DataProvider; import com.sap.icn.mlp.enums.AppConfigKeys; import com.sap.icn.mlp.provider.base.BaseCleaProviderTest; import org.apache.http.HttpRequest; import org.apache.http.client.methods.HttpRequestBase; import org.junit.runner.RunWith; import java.io.FileNotFoundException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import static io.restassured.RestAssured.given; @RunWith(PactRunner.class) @Provider("petType_provider") //@PactBroker(host="localhost", port = "9006") @PactFolder("target/pacts") public class Post_AddPetType_Provider extends BaseCleaProviderTest { private final DataProvider dataProvider = new DataProvider(); private final String PET_BASE_URL = dataProvider.getAppConfig(AppConfigKeys.PETCLINIC_BASE_URL).getAsString(); @TestTarget public final Target target = new HttpTarget(new URL(PET_BASE_URL), true); public Post_AddPetType_Provider() throws MalformedURLException, FileNotFoundException { super(); } @TargetRequestFilter public void injectAccessToken(HttpRequest request) throws MalformedURLException, URISyntaxException { // injectAccessToken(request, CLIENT_ID, CLIENT_SECRET, OAUTH_BASE_URL); // request.("access_key", "ff2877fbb3b0eec582cc5e0a435ba1ac"); String uri = ((HttpRequestBase)request).getURI().toString(); //// uri = uri + "/api/pettypes"; // ((HttpRequestBase)request).setURI(new URI(uri)); } @State("Post PetType") public void addPetType() throws MalformedURLException { // String bearerToken = "Bearer " + getBearerToken(CLIENT_ID, CLIENT_SECRET, OAUTH_BASE_URL); given() // .relaxedHTTPSValidation() .baseUri("http://localhost:9966/") // .queryParam("id", ACTIVE_MODEL_ID) .header("Content-Type", "application/json;charset=UTF-8") .body("{\n" + "\"id\": 8,\n" + "\"name\": \"Hatch1\"\n" + "}") .when() .post("petclinic/api/pettypes/") .then() .assertThat() .statusCode(201); } }```

sidhartha.k.subudhi
2020-08-18 17:51
I am getting error in Provider Test: Verifying a pact between petType_consumer and petType_provider a POST request to create a pet type. returns a response which has status code 201 (FAILED) includes headers "Content-Type" with value "application/json;charset=UTF-8" (FAILED) has a matching body (FAILED) Failures: 0) a POST request to create a pet type. returns a response which has status code 201 expected status of 201 but was 400 1) a POST request to create a pet type. returns a response which includes headers "Content-Type" with value "[application/json;charset=UTF-8]" Expected 'text/plain;charset=UTF-8' to match 'application/json;charset=UTF-8' 2) a POST request to create a pet type. returns a response which has a matching body comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain' java.lang.AssertionError: 0 - expected status of 201 but was 400 1 - Expected 'text/plain;charset=UTF-8' to match 'application/json;charset=UTF-8' 2 - Expected a response type of 'application/json' but the actual type was 'text/plain' at au.com.dius.pact.provider.junit.target.BaseTarget.getAssertionError(BaseTarget.kt:71) at au.com.dius.pact.provider.junit.target.HttpTarget.testInteraction(HttpTarget.kt:80) at http://au.com.dius.pact.provider.junit.InteractionRunner$interactionBlock$statement$1.evaluate(InteractionRunner.kt:207) at au.com.dius.pact.provider.junit.InteractionRunner.run(InteractionRunner.kt:148) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:137) at http://au.com.dius.pact.provider.junit.PactRunner.runChild(PactRunner.kt:51) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)

sidhartha.k.subudhi
2020-08-18 17:56
Why the error is coming with error code 400 and 1) a POST request to create a pet type. returns a response which includes headers "Content-Type" with value "[application/json;charset=UTF-8]" Expected 'text/plain;charset=UTF-8' to match 'application/json;charset=UTF-8' 2) a POST request to create a pet type. returns a response which has a matching body comparison -> Expected a response type of 'application/json' but the actual type was 'text/plain'

damianattademo
2020-08-18 19:50
Buenas tardes! Mi nombre es Damián, soy nuevo en el mundo de PACT y me quiero sacar algunas dudas, alguien que hable castellano por aquí? Muchas gracias!

brandon.craig
2020-08-18 21:13
has joined #general

alexfdz
2020-08-18 21:39
Hola Damián, quizá te puedo ayudar

matt.fellows
2020-08-18 21:47
If you're getting a 400 it means your pact contains an invalid request and your provider API is rejecting it. It seems your provider returns a different content type in these situations hence two assertion failures

matt.fellows
2020-08-18 21:47
You need to update the test to match the provider or vice versa

damianattademo
2020-08-18 21:48
hola Alex, gracias! te comento lo que entiendo, a ver si estoy bien rumbeado: El contexto es: en un proyecto de microservicios que aún no existe ni uno: queremos implementar Pact. Los servicios van a ser todos en Golang. Y yo como QA debo implementar Pact en todo el ecosistema. Preguntas: 1. En todos los servicios va a tener que "vivir" una estructura de pact (ya sea consumer o provider)? O es preferible hacer un projecto en el medio de cada projecto? Entiendo que va un pedazo de codigo en el consumer y otro en el provider no? 2. Para evitar que el consumer cambie y rompa el contrato tengo que usar can i deploy, ejecutandolo desde el jenkins que integre al consumidor y pegar contra el broker que yo cree para guardar los contratos, verdad? 3. Para evitar que el Provider cambie y rompa alcanza con correr los specs en el provider contra el contrato del broker, verdad? 4. Si todo el ecosistema donde viven es Golang, conviene que sea golang o puedo ir por js? Muchas gracias!

abubics
2020-08-19 00:25
Hi, Damián, welcome :slightly_smiling_face: Integrating Pact in new services is definitely one of the easiest ways to get started! As a unit-testing-style tool, you will need to be comfortable with programming, app architecture, networking, and maybe containerisation. We get a lot of questions from people who are in QA roles, but with no dev experience, and it's hard to assist them. It sounds like you're comfortable enough, though~* 1. In each side of a consumer or provider, you would have some pact structure that declares and confirms the extent of a contract. If a microservice is both a consumer and a provider, then it will have both parts (one on each end). 2. Yes, that's a good workflow, and matches https://docs.pact.io/pact_nirvana. You don't have to use Jenkins, of course. You also don't have to create your own broker, if you'd rather use http://pactflow.io. 3. Yep, that's perfect :thumbsup: 4. The Pact testing code is implemented (ideally) in the same codebase that you want to test. It should be in the same language (unless you have another way of using your app code directly from tests) to keep things uncomplicated.

damianattademo
2020-08-19 01:17
Thanks Boris! I hope i can do it right, following good practicies would be a good starting point. I really think this tool has a huge potential. Thanks again and have a nice one.

abubics
2020-08-19 01:45
No worries ^^ and thanks for your considerate & though-out line of questioning. There is a lot of content for docs and guides, so always have a search there first. But also feel free to ask questions in here any time :smile: If you're doing everything in Go, I'd recommend hanging out in #pact-go to get the best help.

sidhartha.k.subudhi
2020-08-19 06:35
ok, Thank you. I am looking into the issue. Please let me know if need to send the POST body in PACT... Meaning once I POST the request to add PetType, as a successful response it gives code 201 and the same JSON I send as body of POST - e.g. {     "id": 7,     "name": "Reptile" } This is body of both request and response (in JSON format.) So my PACT is like below: ``` @Rule public PactProviderRuleMk2 mockProvider = new PactProviderRuleMk2(PROVIDER, "localhost", 8081, this); @Pact(provider=PROVIDER, consumer=CONSUMER) public RequestResponsePact addPetTypeContract(PactDslWithProvider builder) { return ConsumerPactBuilder .consumer(CONSUMER) .hasPactWith(PROVIDER) .uponReceiving("a POST request to create a pet type.") .path(String.format("/petclinic/api/pettypes"))// POST http://localhost:8081/petclinic/api/pettypes .method("POST") .willRespondWith() .status(201) .matchHeader("Content-Type", "application/json;charset=UTF-8") //; [Cc]harset=UTF-8 .body(new PactDslJsonBody() .integerType("id",7) .stringValue("name", "Reptile")) .toPact(); }``` Please let me know if I am making any mistake here.


matt.fellows
2020-08-19 12:27
It looks like you aren?t sending a body, just asking to receive one - so I suspect the issue is that you need to add a `.body(?)` after the `.method("POST")` call, before you start declaring the response

matt.fellows
2020-08-19 12:27
right now, there is no post body being sent, probably the cause of the `400`

denitsa.kulezich
2020-08-19 13:13
has joined #general

sidhartha.k.subudhi
2020-08-19 13:19
body is sent in @Test. ```@Test @PactVerification(value=PROVIDER, fragment = "addPetTypeContract") public void shouldBeAbleToAddPetType() { given() .baseUri("http://localhost:8081") .header("Content-Type", "application/json;charset=UTF-8") // .header("Accept-Encoding","gzip, deflate, br") .body("{\n" + "\"id\": 8,\n" + "\"name\": \"Hatch1\"\n" + "}") .post("/petclinic/api/pettypes/") .then() .assertThat() .statusCode(201); }``` Please let me know where I am missing the body. The body is 2 lines only: {     "id": 7,     "name": "Reptile" } Do I need send another body in @PACT? Please send code snippet if I am missing something. I have given the entire Consumer and Provider code in the beginning of this discussion.

matt.fellows
2020-08-19 13:39
See my comment above. You still need to register the expectation in the pact setup as well as send thru the actual body in your test

matt.fellows
2020-08-19 13:39
Currently, you've only specified what should be returned

matt.fellows
2020-08-19 13:40
I can see how that may be confusing, but you need to be explicit about how you're mocking the request in pact

sidhartha.k.subudhi
2020-08-19 13:57
Ok, thanks a lot, it worked now. But again a small question. If the value in the PACT body is not matching it should not give failure. But I get that error though with clear message about the mismatch in value. My understanding is that it should not give error message for mismatch in value. Please clarify. If .body(...) is mandatory after .method(POST), should it not throw an error message in Consumer test itself?

sidhartha.k.subudhi
2020-08-19 13:58
Is there any location where I can get more information and example of different requests for Consumers and Providers. Also need more information about different annotations.

sidhartha.k.subudhi
2020-08-19 14:00
Is there any help for DELETE and PUT?

sidhartha.k.subudhi
2020-08-19 14:15
Please let me know what the following code is meant for in provider test. ```@TargetRequestFilter public void injectAccessToken(HttpRequest request) throws MalformedURLException, URISyntaxException { String uri = ((HttpRequestBase)request).getURI().toString(); }```

alexfdz
2020-08-19 14:44
Philosophical question here: We have a consumer (1)-->(*) providers model were a consumer has multiple providers and all of them must provide the same API contract. Our idea was to declare a unique pact `consumer-generic_provider` , and make sure all providers verify their contract compliance with it. :arrow_down:

alexfdz
2020-08-19 14:45
The problem: We loose the consumer?s `can-I-deploy` feature, as the relation matrix does not know about the providers, only about this fictional `generic_provider`

alexfdz
2020-08-19 14:46
As we would like to avoid the need of create one pact for each provider (`consumer` --> `provider-X` ), the only option we can see is use tags when the providers publish their verification results, so the tag represents each different provider.

alexfdz
2020-08-19 14:47
Does this approach make sense for you? Maybe we should not try to apply CDC in this scenario?

bernardoguerr
2020-08-19 15:47
This is a little bit old (1/2 a year). Accidentally retweeted it haha. Still valid though!

brendan.donegan
2020-08-19 16:13
has joined #general

matt.fellows
2020-08-19 22:57
Lol. Well it got likes :joy:

matt.fellows
2020-08-19 23:47
Can you please elaborate on why all 3 providers are exactly the same?

matt.fellows
2020-08-19 23:48
I?m conscious that this is a form of the XY question, so want to make sure I understand the root of the problem before I provide any advice

2020-08-20 04:02
A post in *Feature Requests* has been marked as *planned*

alexfdz
2020-08-20 05:10
It could be seen as a plug-in model, where you have a container ?consuming? different plug-ins. All these plug-ins must implement a specific contract, so the container knows how to talk to them. The plug-ins are not exactly the same, they offer different features, but they implement the same contract.

matt.fellows
2020-08-20 08:01
> If the value in the PACT body is not matching it should not give failure no it should definitely give a failure - it?s not expected. Why do you think it would it not fail?


matt.fellows
2020-08-20 09:02
What are the issues you're having with PUT?

matt.fellows
2020-08-20 09:03
It's the same process for any request method

matt.fellows
2020-08-20 09:03
I'd run thru the JVM workshop if you haven't already so you've got a good handle on the basics: https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-08-20 09:04
It'll be time well spent I promise!

charliemic
2020-08-20 15:03
has joined #general

charliemic
2020-08-20 15:11
I'm in a scenario where the integration between various components is file-based (downstream components consume files produced by other components) Does anyone know if there's any good tooling for file-based contract testing? I'd love to have some contract tests and something like pact, but haven't been able to find anything suitable

sidhartha.k.subudhi
2020-08-20 16:09
Thanks Matt. I will go through the workshops.

iannsantos8
2020-08-20 18:20
has joined #general

rcrodrigues39
2020-08-20 18:22
has joined #general

luiz.filho
2020-08-20 18:43
has joined #general

2020-08-21 00:21
A new post has been created in *Feature Requests*

2020-08-21 00:21
A post in *Feature Requests* has been marked as *planned*

tjones
2020-08-21 02:01
You might be able to use message pacts for this

tjones
2020-08-21 02:04
Ron wrote a couple of posts about contracts that include S3 - here's a link to part 2: https://dius.com.au/2018/10/01/contract-testing-serverless-and-asynchronous-applications---part-2/ Some ideas in there might help you

rene.bodack
2020-08-21 07:35
has joined #general

charliemic
2020-08-21 07:52
That's the basic principle behind what I'm after yep - thanks for the steer, that's really useful

matt.fellows
2020-08-21 08:14
Good call our Tim. We should document this as like a "recipe" or something.

matt.fellows
2020-08-21 08:14
Reminder set

bheemreddy181
2020-08-21 18:16
I mean latest pact broker image

matt.fellows
2020-08-21 21:14
No, what's the issue?

bheemreddy181
2020-08-21 23:35
When we pulled the latest pact broker image we were not able to publish verification results back after verifying contract

matt.fellows
2020-08-21 23:48
Can you please share thr verbose log showing the problem? It may help us understand what's going on. You may need to upgrade your client libraries to work with it also Please share the versions of things you're using too

bheemreddy181
2020-08-22 01:33
Verbose log was not enabled will share version soon - is there a read me you can refer me to which gems needs to be updated

matt.fellows
2020-08-22 01:56
From this thread I didn't know what you were using. I'm not very familiar with the Ruby lib but I'm surprised if things are not backwards compatible.

matt.fellows
2020-08-22 01:56
If there is a big difference in versions of the broker that you've changed its possible

matt.fellows
2020-08-22 01:56
Hence why it's important to know library and pact broker version (to/from)

ian.letourneau
2020-08-22 14:00
has joined #general

bheemreddy181
2020-08-22 15:47
Pact Broker Upgrade : 2.54.0 -> 2.59.2 And Pact Library Versions as below

nikhilkumar20.1995
2020-08-23 09:33
has joined #general

matt.fellows
2020-08-23 13:54
Thanks Bheem. Can you explain the problem your experiencing? Probably best to get a bug report so we can reproduce the issue

matt.fellows
2020-08-23 13:54
That being said I'm not familiar with the Ruby DSL and others may spot something obvious

bheemreddy181
2020-08-23 23:59
Post verification of contracts - i am not able to publish results back to pact broker from my provider side - My CI fails while publishing results

bheemreddy181
2020-08-23 23:59
the only error i could see is in the CI screenshot i shared above

matt.fellows
2020-08-24 00:01
The newline character problem seems interesting - does the tag or something contain a new line?

alecgerona
2020-08-24 03:07
has joined #general

alecgerona
2020-08-24 03:20
Hi all, really interested in implementing Pact for our microservices architecture testing. I'm currently at the last stages of our POC at our company and am currently stuck at implementing the contract verification. For context, we're using a Django backend as the provider with Gitlab CI. I've implemented the webhook that calls the pipeline but that's where it falls short. I'm using the pact-cli docker image to call the `verify` command that will publish the results to our broker. Now this requires a url to replay the requests to. I was hoping to use Gitlab CI to run the Django app for me then just have verify call it since `pact-python`'s `Verifier` class doesn't appear to have a publish option as of yet and/or I haven't yet seen a guide that can run a local instance of a Django app during a pytest run unlike, say, a Flask app that is shown on the `pact-python` example. Problem is it seems like it's not possible for Gitlab CI to run a standalone server on itself if it's using a docker based runner? Am I overcomplicating things or is there a simple way to do this? I would hate for our POC for Pact to be wasted at this final step. Any help is much appreciated. Thank you! Relevant part for pact verification step on my `.gitlab-ci.yml` file: ```test: image: alecgerona/python-docker:python3.6 services: - postgres:11 - docker:dind stage: test script: - build server here - setsid nohup python manage.py runserver > nohup.out & - make verify_publish # Call pact-cli's verify command with appropriate arguments```

matt.fellows
2020-08-24 03:32
:wave:

matt.fellows
2020-08-24 03:32
Hello, awesome to hear you?re getting started with Pact!

matt.fellows
2020-08-24 03:32
First up, probably want to ask in #pact-python as you?ll likely get more targeted support

alecgerona
2020-08-24 03:32
Got it. Will repost this message there.

matt.fellows
2020-08-24 03:33
> Problem is it seems like it?s not possible for Gitlab CI to run a standalone server on itself if it?s using a docker based runner? Can you please elaborate on this? What is not possible by running in docker? (running docker in docker, for example might be a pain)

robert.strehli
2020-08-24 08:19
has joined #general

alecgerona
2020-08-24 09:23
Has anyone tried to mock any internal methods using the provider states? We have an endpoint that calls an external dependency and it'd be great to be able to mock that instead of having to manually add an environment check to skip it.

antonello
2020-08-24 10:17
What language is the provider written in?

matt.fellows
2020-08-24 10:18
Yes, any reason you can't do it?

matt.fellows
2020-08-24 10:18
Ha, timing

matt.fellows
2020-08-24 10:18
He's using python so it should very much be doable

antonello
2020-08-24 10:18
and advisable!

matt.fellows
2020-08-24 10:19
:point_up:

alecgerona
2020-08-24 10:20
Sorry how is this doable in Python? I'm using the `pact-verifier` with states. Do I mock our internal methods in each call or..?

alecgerona
2020-08-24 10:20
Apologies I don't have any experience in mocking a live running python app before.

parveensultanauk
2020-08-24 11:33
has joined #general

bheemreddy181
2020-08-24 14:42
I don?t think so - i verified them

nsusanward
2020-08-24 16:07
has joined #general

nsusanward
2020-08-24 16:09
Can I use Pact to test a library? We're moving to a microservices framework. Several of the services will import a library that we develop and use it in some of the calls.

elliottmurray
2020-08-24 16:36
Assuming you are making REST calls in the library and you want to import that library into each of the microservices?

elliottmurray
2020-08-24 16:38
Then yes though I think you may lose some of the benefits or have to think through a few more things. For example if MS A and B use it and you update A to a new version, is B now broken? How would you know?

lucaseverain
2020-08-24 17:41
has joined #general

ismail.alam2
2020-08-24 18:19
has joined #general

sudhachilamakuri
2020-08-24 19:35
has joined #general

sudhachilamakuri
2020-08-24 19:49
Hi Guys, I need some help I am at the early stage of implementing Pact, I have scenario where I will get a code from the response of one request and I want to use that code in the request body of next request to get access token in the response , how can I write provider tests , did some one worked this kind of scenario, if yes can you provide some examples pls

sudhachilamakuri
2020-08-24 19:49
I am using Pact Junit5

matt.fellows
2020-08-24 21:11
Whilst you lose some of the benefits, you can certainly still gain this breaking change one of you do it right

matt.fellows
2020-08-24 21:14
I wrote about it here as I used it on a client site quite effectively https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/

alecgerona
2020-08-25 02:04
@matt.fellows@matt.fellows@matt.fellows @elliottmurray?

alecgerona
2020-08-25 02:08
Hmm. Way I'd implement it is to make sure it's gonna be a constant code all throughout. I'd make sure it'll return that constant code via the provider state.

matt.fellows
2020-08-25 02:35
Sorry I can?t speak to Python as I haven?t written any real code in it

alecgerona
2020-08-25 02:35
How is this done with other languages? Do they run the app with environment checks instead?

matt.fellows
2020-08-25 02:35
but presumably somewhere you have a piece of code that is responsible for calling downstream systems. In your provider state route (or perhaps elsewhere in the test setup/context), you should be able to replace that with a fake implementation

alecgerona
2020-08-25 02:36
Do you have an example of that being done with other languages? Examples I see use mocks for this. But that works because they run it in a testing scope.

matt.fellows
2020-08-25 02:37
> How is this done with other languages? Do they run the app with environment checks instead? There is no ?one way? so answering this is very much dependent on many factors


matt.fellows
2020-08-25 02:37
it is run in a test scope though because it?s easy to do

matt.fellows
2020-08-25 02:37
I?m sure without much work you could do the same in Python

alecgerona
2020-08-25 02:40
I would love to run my provider verification in a test scope as well using pact python but as I raised in an earlier issue, it doesn't support publishing and requires a running python app _inside_ the test scope. I've heard @elliottmurray was doing an example for this but haven't seen any yet.

matt.fellows
2020-08-25 02:41
You can still start your application from within a ?test scope?. there are a myriad options to kick off the verification - for example, you could `shell out` to the verification process from within the test

matt.fellows
2020-08-25 02:42

matt.fellows
2020-08-25 02:42
I?m not convinced about why you can?t execute the binaries as per yesterday, because that?s exactly how the python verifier works now

matt.fellows
2020-08-25 02:42
it?s likely something configuration-y that needs sorting, I?m just not familiar enough with the Python ecosystem to fix it

alecgerona
2020-08-25 03:12
Hmm I guess either way I'd need to find a way to mock the actual requests. I see that the example you gave did it by returning a Promise on the handlers.

matt.fellows
2020-08-25 03:13
how would you mock it if you weren?t using Pact?

matt.fellows
2020-08-25 03:13
that?s probably the question to be asking, and then you can work out how to make it work with Pact

matt.fellows
2020-08-25 03:13
(and in this case, we actually want to _stub_ it, not mock it)

alecgerona
2020-08-25 03:15
I'd stub it in the testing scope. Hmm.

matt.fellows
2020-08-25 03:15
so why not do that - start the service, stub the bits you need and then execute the verification from python itself (shelling out, or uplifting pact-python with the extra bits you need?)

alecgerona
2020-08-25 03:17
Lemme try. :crossed_fingers: Thanks for all the help so far.

matt.fellows
2020-08-25 03:17
see https://github.com/pact-foundation/pact-python/blob/master/pact/pact.py#L217-L243 - under the hood, it?s simply executing the binaries I shared

matt.fellows
2020-08-25 03:18
huh, according to https://github.com/pact-foundation/pact-python/blob/master/pact/constants.py the binaries should be in the local dir :thinking_face:

matt.fellows
2020-08-25 03:18
ah lol nevermind, the package install _is_ the local dir according to that. scrap that.

alecgerona
2020-08-25 03:19
Haha I think it'd be easier to just open a PR that would accommodate the publishing.

heytaco
2020-08-25 03:57
has joined #general

heytaco
2020-08-25 03:57
Hi there! My name is HeyTaco!, and you can use me to give people tacos to show your appreciation. My tacos will spread joy through Slack!

matt.fellows
2020-08-25 04:03
So yes, we now have this :point_up:

matt.fellows
2020-08-25 04:03
as a starting point, I?m going to throw some tacos

matt.fellows
2020-08-25 04:04
@phil.endsley loving your work answering and helping out in #pact-jvm :taco:

matt.fellows
2020-08-25 04:04
@elliottmurray thanks for your awesome work both donating to pact-python and migrating to docusaurus v2. Please enjoy this :taco:

matt.fellows
2020-08-25 04:05
@yousafn because I meant to give you tacos a while back for all of the demos, the welcome bot and general awesomeness -> :taco:

matt.fellows
2020-08-25 04:06
@antonello for you and your team contributing to #pact-jvm and getting stuck into meaty issues :taco:

matt.fellows
2020-08-25 04:06
I feel like I?m accepting an academy award ?I have so many people to thank??

bethskurrie
2020-08-25 04:07
I +1 those tacos

matt.fellows
2020-08-25 04:08
Last but not least is @abubics, who has been sharing with us his wisdom, contributing to driving a positive culture and hanging out here for such a long time. :taco:

matt.fellows
2020-08-25 04:09
If you want to +1 properly, send them a `:taco:`

bethskurrie
2020-08-25 04:10
There's a fine line between tacos and spam :stuck_out_tongue:

alecgerona
2020-08-25 04:12
@matt.fellows thanks for all the support. This is the most real-time quality support I've gotten out of any open-source project I've worked with. :taco:

aforeman
2020-08-25 05:01
has joined #general

sathisan
2020-08-25 05:17
has joined #general

sathisan
2020-08-25 05:37
Hi All Maybe someone can help me..if i use the provider verification part with spring mvc, do i need to test against a Running Service ?

sathisan
2020-08-25 05:46
In my contract Test, i am testing that a GET request Returns a string. If i verify with spring mvc, i got an Error " expected a Header 'content-type' but was missing".. can someone explain me this error?

uglyog
2020-08-25 06:02
In your expectations in the test, you have specified the Content-Type header. This means it is a required header, and needs to be included in the request. If it is not required, remove it.

sathisan
2020-08-25 06:05
This is what my consumertest looks like

sathisan
2020-08-25 06:12
Providertest

sathisan
2020-08-25 06:12
Consumertest

sathisan
2020-08-25 06:15
Although I followed what you said, I still get sone errors which I could Not resolve

abubics
2020-08-25 06:18
The combination of ? missing `Content-Type` header, and ? status of 404 sounds like your provider doesn't provide an endpoint to matches your request.

uglyog
2020-08-25 06:18
Your pact file has specified that the response needs to be a JSON response, with a correctly set `Content-Type` header. When the actual request was made, no content type header was returned, so it was assume that it was a text plain response.

abubics
2020-08-25 06:19
@sathisan Also, any reason you're taking photos of your screen, instead of copying & pasting the code in a code block?

sathisan
2020-08-25 06:26
So i need to Start a the Real application to validate my request against a Running service? I thought it is Not necessary if i Work with spring mvc? Since the endpoint in my usecase is an https endpoint, do i need to mock the whole security context in the @state annotation to validate against Provider?

sathisan
2020-08-25 06:29
@abubics i am using my tablet to communicate via slack since slack is Not supported by my laptop

abubics
2020-08-25 06:34
If you're getting a 404, then there's certainly a web server listening on the expected port (probably your service).

sathisan
2020-08-25 06:37
@abubics is this Not the idea that the target defined in the provider should point to the port where my service is listening? In the End, i want to verify against a Running service

sathisan
2020-08-25 06:44
@uglyog thank you for your answer, so if i use PactDSLJsonBody, i already define that my response needs to be a JSON response? Is there an Attribute which I can use to define that my response should be "text/plain"?

matt.fellows
2020-08-25 06:45
@sathisan slack web? Or do you work for one of those places that blocks Slack :grimacing:

sathisan
2020-08-25 06:47
@matt.fellows Yes it is blocked

matt.fellows
2020-08-25 06:47
You can use the spring context to start the app e.g. https://github.com/pactflow/example-provider-springboot

matt.fellows
2020-08-25 06:47
I don?t know spring MVC very well (basically at all), but I assume you can start it as part of the test


matt.fellows
2020-08-25 06:51
there you go

sathisan
2020-08-25 06:55
if i use PactDSLJsonBody, i already define that my response needs to be a JSON response? Is there an Attribute which I can use to define that my response should be "text/plain"?

uglyog
2020-08-25 06:57
Use a string value for the body, instead of PactDSLJsonBody

sathisan
2020-08-25 07:10
Thank you @uglyog

sathisan
2020-08-25 07:13
For Basic understanding: For the provider verification, is it Not necessary that the provider listens to the port where my service is listening?

uglyog
2020-08-25 07:16
Your service is the provider

sathisan
2020-08-25 07:24
I still trying to resolve this issue with status 404 I am using the Concept with mvc, created an instance of my controller and initialized with MVCTarget Since i do Not Set any Ports in this concept, i could Not Think of anything of how to resolve this issue

uglyog
2020-08-25 07:34
From what I can see from your test code, you are setting the controller to the result of calling `MockauthController.getUserInfo()`. You shouldn't so that, you should pass your actual controller class there.

uglyog
2020-08-25 07:34
You're getting the 404 Not Found because MockMVC is not finding a controller to handle the request.


sathisan
2020-08-25 07:43
Target.setRuntimes is actually Calling the mvc container which I initialized before?

sathisan
2020-08-25 07:45
From the official documentation, I still could Not figure what the use Case of the controlleradvice might be? Thank you for your help @uglyog

dan.rh.jones
2020-08-25 11:45
has joined #general

dee_n
2020-08-25 14:56
has joined #general

nsusanward
2020-08-25 15:21
Thank you!

alecgerona
2020-08-25 20:40
Hi I'm having trouble running https://github.com/pact-foundation/pact-ruby-standalone/releases on my docker image. I would like to be able to start a stub server on my Gitlab CI. On local it works great, curl -> tar -> execute. On a docker image it doesn't work. You can see the error log here https://github.com/alecgerona/python-docker/runs/1028444147?check_suite_focus=true#step:5:1512

matt.fellows
2020-08-25 22:10
--help isn't a command

matt.fellows
2020-08-25 22:11
It should just be `help` I think

sathisan
2020-08-25 23:22
Is there a Way to check for type e.g Stringtype if my contenttype is text/plain.... So far i Think the stringtype, integertype etc. can only be checked when used in combination with PactDslJsonbody or PactDslJsonArray?

tjones
2020-08-25 23:22
This might be a question for #pact-jvm

tjones
2020-08-25 23:24
In general, I'm not sure if matchers work in text/plain. If you have a clear type is there some reason you can't use json?

sathisan
2020-08-25 23:36
PactDslRootValue exists, but in the contract the contenttype will be defined as application/json..so I assume any attribute from the DslPart class sets contenttype as application/json

tjones
2020-08-25 23:37
I don't know how the JVM DSL works, sorry. You'll need to ask in #pact-jvm

alecgerona
2020-08-26 03:15
Was just using the `--help` as to see if the executable actually works. But the error is something like the ruby dependency cannot be found even though it's clearly there.

matt.fellows
2020-08-26 05:01
Thanks. Sorry I was on the phone when this happened. I can?t actually see in that repo how you?re installing the binaries - is your repo up to date? (FYI the uglyog stub server is probably the better one to use anyway, which I note you?ve updated to)

matt.fellows
2020-08-26 05:02
FYI it may be one of the glibc or readline type dependencies missing. We can update https://docs.pact.io/docker/ if you find the missing lib it needs

matt.fellows
2020-08-26 05:02
I think your image should have bash, so that shouldn?t be it (unless it?s a bash version compatibility, but we haven?t had a problem with bash 5 before to my knowledge)

alecgerona
2020-08-26 05:03
I'll try to recheck. Was going for this as I would like a docker image that can be executed in a CI environment that has all the pact executables.

matt.fellows
2020-08-26 05:04
kk

matt.fellows
2020-08-26 05:04
I?m guessing it?s going to be a missing lib

alecgerona
2020-08-26 05:06
But yeah you're right I'll be sticking to pact stub server for now. Any tips on how to handle downstream dependencies dynamically? Do I have to pull the dependent pacts everytime?

matt.fellows
2020-08-26 05:07
actually, no, you?ve downloaded the x86 version.

matt.fellows
2020-08-26 05:07
you need to install the 64 bit

alecgerona
2020-08-26 05:07
Ooooh.

matt.fellows
2020-08-26 05:07
:laughing:

matt.fellows
2020-08-26 05:07
yeah

alecgerona
2020-08-26 05:08
Okay lemme try.

alecgerona
2020-08-26 05:08
So thoughts on the downstream dependencies?

alecgerona
2020-08-26 05:08
It's my main use case for the stub server

sathisan
2020-08-26 05:48
Okay Thank you:+1:

matt.fellows
2020-08-26 06:03
Maybe ask it again in #general as a top level question. Keen to hear others? answers

alecgerona
2020-08-26 06:06
When dealing with downstream apis (A calls B which calls C), the ideal solution is to use pact-stub-service to stub B's contract with C. Does this mean the contracts should be pulled everytime for the stub service to use? Or is this checked into version control (especially for external APIs)? If to be pulled manually, is there a command for it already?

alecgerona
2020-08-26 06:06
Done! Thanks again! Will give you another taco. Haha.

bethskurrie
2020-08-26 06:07
I would pull it in live from the broker, personally

bethskurrie
2020-08-26 06:08
depending on which stub service you're using, you can just give it a URL.

alecgerona
2020-08-26 06:08
I'm using pact-stub-server.

bethskurrie
2020-08-26 06:08
There are two :wink:

bethskurrie
2020-08-26 06:08
But you probably mean the rust implementatoin

alecgerona
2020-08-26 06:08
Yes the rust one.

bethskurrie
2020-08-26 06:09
` -u, --url <url>... URL of pact file to verify (can be repeated)

alecgerona
2020-08-26 06:09
Ah I see what you mean. I can just construct the URL based on what the consumer/provider is.

bethskurrie
2020-08-26 06:09
yes

bethskurrie
2020-08-26 06:10
you typically select the latest one for a particular tag

bethskurrie
2020-08-26 06:10
.../latest/prod or .../latest/main

alecgerona
2020-08-26 06:35
@bethskurrie excellent advice as always :taco:

sathisan
2020-08-26 11:34
Hi guys I have one question regarding the provider Test If i verify the contract on the provider Side, what is the difference between verifying against the MockMVC Target and the target which is specified as HttpTarget?

elliottmurray
2020-08-26 11:49
Is this a JVM specific issue? If so #pact-jvm is your best bet

sathisan
2020-08-26 12:32
Okay Thank you:+1:

matt.fellows
2020-08-26 13:09
Also Alec, Pactflow has a hosted stub service available as part of our product. Just in case :wink:

andy.furnival
2020-08-26 16:46
has joined #general

rchong.allan
2020-08-26 19:46
has joined #general


alecgerona
2020-08-27 05:48
See what you did there :smile:

nishtha.kakkar.28
2020-08-27 11:18
has joined #general

sathisan
2020-08-27 16:30
@uglyog thank you, After doing the research, i still could Not figure out the following: As far as I understood, with mockmvc the contract is verified against the weblayer( controller) and with Httptarget the contract is verified against the whole Server with Application context. But in the official documentation, it is stated that pact is testing messages between two Applications at HTTP Level. So if I am testing at Http Level, does it have an impact for my testing if service Layer is mocked or not mocked?

kapilrajput27
2020-08-29 17:06
has joined #general

kapilrajput27
2020-08-30 15:11
Hello all, I am using PactNet and trying to pass a variable value from consumer to the provider-state. MockProviderService .Given($"X exists with id {*Guid.NewGuid()*}") . . . The provider state code looks like this: public ProviderStateMiddleware(RequestDelegate next) { _next = next; _providerStates = new Dictionary<string, Action> { { "X exists with id *??*", CreatXIfNotExists } }; } Is it possible to pass the guid from consumer to the provider side?? Or Am I missing something here, probably the provider states are meant to be controlled by the provider and consumer is just meant to use it as-is :?

imione9
2020-08-30 18:51
has joined #general

matt.fellows
2020-08-30 21:32
Bingo. The last thing you said is how to use them

g.doergeloh
2020-08-31 08:06
has joined #general

kapilrajput27
2020-08-31 15:36
Hi @matt.fellows, Our APIs are not idempotent (if I post again the response would be different) and the ids are auto-generated. So we need a way to provide values with provider state. Do you know of any alternatives?

ryan.dens
2020-08-31 16:20
:wave: Curious, is it recommended to use a contract test to verify a consumer own/managed by your organization works properly with a service external to your organization? The example I?m thinking of is testing the interaction between a backend service (consumer) and an API provider like Hashicorp Vault (a backend service which we don?t build, but are responsible for running/upgrading).

p0deje
2020-08-31 22:23
Hey folks! Does anyone have experience with using Pact for testing federated GraphQL (https://www.apollographql.com/blog/apollo-federation-f260cf525d21/). The idea is that all consumers start talking to a special gateway that is responsible for sending parts of GraphQL query to the services implementing them. This way consumers only need to make a single request and receive response from multiple services. Of course this breaks existing contracts because there is now a new layer in between. However, it?s not possible to perform contract verifications on the gateway itself since it acts as a proxy. I wonder if anyone faced similar issue and what the solution could be?

matt.fellows
2020-08-31 22:27
Answered in #graphql


abubics
2020-09-01 00:08
Pretty sure there's a FAQ about this, but I can't seem to find it . . . My short answer is it has diminished value, but may be better than many other options. It's not the best situation, because you don't get much of a feedback loop (e.g. how do you detect when the provider changes, apart from polling?).

rasih.caglayan
2020-09-01 00:33
has joined #general

jgauthier
2020-09-01 05:36
has joined #general

ryan.dens
2020-09-01 13:22
Thanks for the response! I also looked for something, and I vaguely recall reading something, but couldn?t find it. I agree there?s diminished value. Part of the value of the contract (in my opinion) is that the provider can safely deprecate and remove endpoints. However, I think the feedback loop is still there for external services that are run ?on premise? like the example I gave, Vault. We?re responsible for upgrading the version of Vault we run, so we can re-run contract verification tests then. Contract testing integration with a saas service like Stripe definitely seems like it would have less value.

ryan.dens
2020-09-01 13:25
I did find this: https://docs.pact.io/getting_started/what_is_pact_good_for#what-is-pact-good-for > You (or your team/organisation/partner organisation) control the development of both the consumer and the provider.

gianrubio
2020-09-01 13:48
has joined #general

lmerlin
2020-09-01 13:51
has joined #general

phillip.lo
2020-09-01 16:26
has joined #general

lzyzy1996
2020-09-01 17:08
has joined #general

abagraw3
2020-09-01 21:32
has joined #general

michaelkochub
2020-09-01 21:35
has joined #general

abagraw3
2020-09-01 21:36
Hi All! I'm trying to write a provider test using junit. I've contract files and I want to run them on multiple environment and hence a particular field in request body needs to be modified which is env specific. Is there any way to modify the value of an attribute in request body?

matt.fellows
2020-09-02 00:12
It soundsn like you are matching on specific values, rather than matching on type. Are you using flexible matchers? Can you please share the contract file/test code?

abubics
2020-09-02 00:14
Sounds like you're on the right track :thumbsup:

ashley.graf101
2020-09-02 01:46
has joined #general

alex.radulescu
2020-09-02 07:52
has joined #general

ben.johnson
2020-09-02 11:35
has joined #general

nate.smith
2020-09-02 14:22
has joined #general

carlos.silva
2020-09-02 14:56
has joined #general

sagupta
2020-09-02 18:42
Hi All, I have a question for writing contract tests . So for our API , consumer can send a HTTP POST request with multiple optional fields in the request body based on what functionality consumer want to access from provider. How should we write contract tests in this case? Should we only write contract tests for the the properties which are not optional and always be present in the request and in response?

michaelkochub
2020-09-02 21:29
Hi All! I'm having a bit of trouble figuring out how to inject a value into a provider state from a gradle file. I'm generating a user UUID on the provider side that the consumer should use when making a request. I'm looking at the following bit of documentation https://docs.pact.io/implementation_guides/jvm/provider/gradle/#using-a-closure but an example would be extremely helpful

uglyog
2020-09-02 22:51
You need to return a Map from the closure. The keys need to correspond to the variable used in the expression in the pact file

uglyog
2020-09-02 22:52
I would write different tests for the combinations that are important

ananda-kumar.irudhaya
2020-09-03 07:03
has joined #general

sagupta
2020-09-03 12:21
ok so i should check on the consumer side what fields are important for them and write tests for those. And covering all combinations is not a good practice as well for contract tests

lewis.prescott
2020-09-03 12:45
has joined #general

lewis.prescott
2020-09-03 12:46
:wave: If you are new to Pact and want to learn the basics. Why not checkout my https://www.udemy.com/course/introduction-to-contract-testing-with-pact/?referralCode=90157BA4D133D89E6C0C

jeonghoon
2020-09-03 12:47
has joined #general

sri.prasanna
2020-09-03 12:49
has joined #general

michaelkochub
2020-09-03 13:43
Thank you!

phenchanter
2020-09-03 19:36
has joined #general

phenchanter
2020-09-03 19:42
Hi All, I've stumbled on Pact recently and trying to figure out couple of things. In my case I have quite complex form and depending on some fields values other fields are removed/added and some for some of the fields required state is changed. Is there a way to handle this via Pact? I couldn't find a direct answer in documentation at the moment and if anyone can guide me to somewhere it'll be awesome

matt.fellows
2020-09-03 23:51
So behind the scenes, the form is going to be submitted to an API right? You would normally create a separate Pact tests for the different important pairs of req/responses you?d expect.


olarrmide
2020-09-04 01:56
has joined #general

ravi.mijar
2020-09-04 02:50
Hello folks, I have recently implemented both consumer and provider pact tests using node and typescript. We're not using provider states yet. If we do so, will the provider microservice become state-full in a way? while I understand what the provider states will allow me to test, I'm trying to articulate whether my microservice will end up being termed as statefull ?

matt.fellows
2020-09-04 02:51
no, they will not. At least not in the way that most people refer to ?stateful? services

matt.fellows
2020-09-04 02:52
stateful services usually means that when deployed into a load balanced environment, specific state is stored in each instance of the hosted component (e.g. a users? session), meaning that future requests must hit the same instance for it to work

matt.fellows
2020-09-04 02:52
stateful services is a dumb term, because almost any interesting service has some ?state? - e.g . an Order will be in a ?quote? state, and then maybe ?accepted? and then ?fulfiled? type thing - that?s what we mean by a provider state

matt.fellows
2020-09-04 02:53
or ?user Sally exists?

matt.fellows
2020-09-04 02:53
this is a state, but not in the ?stateful? nomenclature

olarrmide
2020-09-04 04:25
Hi folks, I am implementing the Pact-Mock-Service due to corporate policies that disallow me from running the Pact-JS binaries that are installed via NPM. However, there's an instance of the standalone pact-mock-service that's allowed to run. My project is in Javascript and I wrote my tests using Jest. Right now I'm trying to convert my Javascript tests so I can run them against the standalone mock service. So far, I get that I have to start the mock service then write my interactions which I'll POST to the service. Specifically, I'm following https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh. However, I don't get what exactly I'm supposed to do on line 35 (`curl localhost:1234/foo`). Does anyone have any helpful information to point me in the right direction? I've checked the docs but I couldn't find any answers. Thanks!

matt.fellows
2020-09-04 04:37
have you seen https://github.com/pact-foundation/pact-node#pact-download-location? That should get you around the NPM binary issue

lucaseverain
2020-09-04 14:17
Hello! First, thank you for mantaining this amazing tool! I'm having some issue with JUnit 5: in my consumer I use "pathFromProviderState", and in my provider I create a state that replaces the path correctly, but my TestTemplate is running twice, the first time with the path parameter null, and the second time with the right parameter. Any idea on how to implement this correctly?

olarrmide
2020-09-04 14:40
Thanks for the reply. Yes I have seen the workaround but that helps with installing the packages. The blocker I face is when running my tests. Group policy blocks the ?.bat? scripts within ?node_modules? from running. At the same time there?s a copy of the standalone that?s approved and hosted internally that I can download and run. If there was a way to make my tests run against that instance, I believe my problem will be solved. Alternatively, I?m willing to explore the option I outlined in my original question.

maciej.olko
2020-09-04 14:53
Hello! I am trying to use pending feature with broker we host internally. For some time our verification was failing because of new consumer pacts that aren?t implemented in our API. I?ve run verification with `--enable-pending` flag on and published the result, but the verification is still seen as ?failed?. What should I do to see failing interactions as pending?

marco.dallagiacoma
2020-09-04 15:44
Hello, We're having some trouble trying to verify a contract that uses the `timestamp` matcher. I generated the contract via pact-jvm (i.e., `body.datetime("myDateTime", "yyyy-MM-dd'T'HH:mm:ss.SSSXXX")`) The generated contract includes the following matcher: ```"$.myDateTime": { "matchers": [ { "match": "timestamp", "timestamp": "yyyy-MM-dd'T'HH:mm:ss.SSSXXX" } ], "combine": "AND" },``` while this is the related row in the `contents` section of the contract: ``` "myDateTime": "2000-01-31T14:00:00.000+01:00",``` The problem is that the verifier seems to be matching on the VALUE of the given timestamp instead of just the format. In other words, the verification succeeds only if the provided value is exactly the same as the one set in the `contents` section of the contract. For the example above, this means that it only succeeds if `myDateTime` is `"2000-01-31T14:00:00.000+01:00"`, but it fails e.g., if I change it to `"2000-01-30T14:00:00.000+01:00"` (day changed from 31 to 30). Is this expected? Any ideas on how to match on the format instead of the value? Thanks a lot in advance for your help!

phil.endsley
2020-09-04 18:41
https://docs.pact.io/faq/convinceme#but-our-company-develops-apis-before-consumers-eg-apidocument-driven-design > If you have control over any of them, then Pact could be a good fit - you just won't be driving the design from the consumer (that's OK too). Can someone weigh in on what this means for the development process of pacts? ? Write the API first, then circle back with pacts when the consumer gets around to using it?

phil.endsley
2020-09-04 18:46
Our company writes enterprise software. So we have a lot of teams all writing consumers and providers. We control everything. We're seeing some resistance to defining the contract first. ex: ? Team 1 is responsible for the consumer ? Team 2 is responsible for the provider ? Team 1 needs a new feature, but they're working on a bugfix/something else that has been deemed "more important" ? Team 2 has time to start working on the provider Since we don't have any contract tests in place today, this works out for us. Team 2 implements the new api, and that's ready to go when Team 1 gets around to consume it. How is this supposed to play out with contracts?

lucaseverain
2020-09-04 19:28
It was my mistake, sorry.

matt.fellows
2020-09-04 21:18
Hmm another option is trying out the v3 branch in pact JS. It uses a dynamic library

matt.fellows
2020-09-04 22:18
It doesn't have message support but has some newer matchers and things

matt.fellows
2020-09-04 23:10
The broker will get the failed status, it just won't break the provider build

matt.fellows
2020-09-04 23:11
The pending status is only shown locally

matt.fellows
2020-09-04 23:12
Because the broker doesn't know which tags are important to you it can't display "pending" in the UI, because the pending status is dependent on a few things

matt.fellows
2020-09-04 23:12
We?ve been thinking of be adding a config for something like this in Pactflow at some point because it would clearly be helpful

bethskurrie
2020-09-04 23:18
@phil.endsley I see contracts that are written by the consumer as having multiple purposes. ? requesting new functionality that doesn't exist ? ensuring the consumer is calling the API correctly ? ensuring backwards compatibility

matt.fellows
2020-09-04 23:19
But we haven?t connected it to this use case yet

matt.fellows
2020-09-04 23:19
(for example, `prod` and `master` tags may be the two tags you use to move things through the pipeline)

bethskurrie
2020-09-04 23:19
If the functionality already exists, then the first point is not relevant, but the second and third points are still relevant.

matt.fellows
2020-09-04 23:20
then we can track verifications etc. against these to increase visibility of what?s happening

phil.endsley
2020-09-04 23:22
Yeah, I'm specifically getting pushback about the first point. The others, I'm not so concerned about because we can do those "whenever"

phil.endsley
2020-09-04 23:22
I would prefer we do it the "right" way. Trying to see if there's any suggestions for a "something is better than nothing"

phil.endsley
2020-09-04 23:23
I'm willing to compromise some on process if it means they'll start writing them. My hope is they'll feel test pain and naturally switch to writing from the consumer first

bethskurrie
2020-09-04 23:23
I'm not sure if there is a "right" way.

bethskurrie
2020-09-04 23:24
Your tools need to match your process - modifying your process to match your tools... I'm skeptical of.

bethskurrie
2020-09-04 23:25
I say this as a total CDC fan - but not all APIs are consumer driven.

bethskurrie
2020-09-04 23:25
In this case, I think the benefits of consumer written contracts are mainly in the second and third points, and ensuring that the consumer has a valid mock.

bethskurrie
2020-09-04 23:25
We're actually working on some provider driven contract support in Pactflow at the moment.

bethskurrie
2020-09-04 23:26
Matt's got some posts coming out over the next few days. I'll make sure you get pinged when they come out.

bethskurrie
2020-09-04 23:26
I tell a lie - they're out


phil.endsley
2020-09-04 23:26
That's fair... I guess my opinion was that this would force our APIs to be better thought out, since most of them should be consumer driven (imo). The only reason they aren't is because, we've never done it that way before

bethskurrie
2020-09-04 23:26
There were so many thoughts, it's a 3 part series!

bethskurrie
2020-09-04 23:27
> The only reason they aren't is because, we've never done it that way before Technology is easy, people are hard!

phil.endsley
2020-09-04 23:27
We're interested in provider driven. We have a set of applications that are "core" in that most every other application consumes them

bethskurrie
2020-09-04 23:30
There's a page in the docs on "what is pact not good for" and one of the points is around "when you have an API that just isn't driven by consumers at all".

bethskurrie
2020-09-04 23:31
Hopefully this provider driven approach can help. I'm going get onto it right now! (I'm working Saturdays to help manage the parenting/working juggle :scream: )

phil.endsley
2020-09-05 02:10
> We're actually working on some provider driven contract support in Pactflow at the moment. > Pactflow only? Plans to make it open source at any point?

phil.endsley
2020-09-05 02:14
And back to the main point > I say this as a total CDC fan - but not all APIs are consumer driven. > What, in your mind is the determining factor? A team's process or the APIs functionality/purpose?

uglyog
2020-09-05 03:23
What is doing the verification?

ravi.mijar
2020-09-05 06:01
nicely explained! thanks Matt!

marco.dallagiacoma
2020-09-05 07:26
hi @uglyog, we're using the pact-cli for verification

marco.dallagiacoma
2020-09-05 07:28
We load the pact-cli via docker, running the `verify` command. In case it may be relevant, we're using pact v3 to verify messages

marco.dallagiacoma
2020-09-05 08:20
in case what we're experiencing is not the expected behavior from pact, I can develop and share a minimal example to reproduce it

uglyog
2020-09-05 08:20
pact-cli only supports V2 pact files, so the date/time matchers will not work


marco.dallagiacoma
2020-09-05 08:26
@uglyog I totally missed that, thanks a lot! Also, thank you so much for the tip about the v3 verifier! We'll try it out asap :slightly_smiling_face:

abubics
2020-09-05 11:07
I my experience, provider-driven often just comes from legacy practices and attitudes, usually paired with a "we specify it, you adhere to the spec" vibe. If you can convince the provider that they don't always know what's best, and consumers can help them avoid doing unwanted work, it can be quick to change :innocent:

abubics
2020-09-05 11:08
As usual, all computer problems are people problems :sweat_smile:

maciej.olko
2020-09-05 13:45
Oh, I see. Thank you for clarification!

suresh.tsv
2020-09-06 19:06
has joined #general

suresh.tsv
2020-09-06 21:12
Hi Folks First, I would like to appreciate this amazing tool and people behind it. Coming to the question I have, we are planning to implement CDC in our project and Pact is being considered as primary candidate. Currently I am working on a POC to set up end to end flow with CI/CD integration with GitLab. I have couple of questions related to Authentication/Authorization/security. 1. Consumer - Pact Broker: Consumers here are external partners. I see client side certificates as an option. I am not able to find documentation or info on Web for the options available. Please note that we will hosting the broker in AWS. 2. Pact Broker and Provider: Both components are part of our infrastructure. In this case I understand that we will be generating a GitLab trigger token which will be passed as part of future requests to Provider pipeline. We will be using same token every time. Could you please advise options available in both cases to make the communication more secure. Thanks in advance. Regards Venkat Thota

matt.fellows
2020-09-06 23:48
Thanks for the kind words!

matt.fellows
2020-09-06 23:48
It looks like you?re asking about pact broker security, so perhaps a better channel for that is #pact-broker

matt.fellows
2020-09-06 23:49
But I?ll briefly answer here. The OSS broker doesn?t have any security controls, other than basic auth (which isn?t very appropriate for external use for obvious reasons).

matt.fellows
2020-09-06 23:50
Where did you see that client certificates were supported? I?m sorry to say that is incorrect

matt.fellows
2020-09-06 23:50
You would need to add your own authentication layer for this purpose - if you had an API gateway that might be a good starting point

matt.fellows
2020-09-06 23:51
Alternatively, we have created a commercial version of OSS called Pactflow (see https://pactflow.io/features/) which has a full security model wrapped over the OSS broker. Happy to chat further if it?s something you?re willing to explore. We?re also very interested in the external consumer mode and how we can support that

matt.fellows
2020-09-06 23:56
What language are you using on the provider side Marco?

rafaelg
2020-09-07 06:21
has joined #general

marco.dallagiacoma
2020-09-07 07:03
Hi @matt.fellows, we're using PHP on the provider (sorry for the edit, I misread your question)

marco.dallagiacoma
2020-09-07 07:06
We wanted to use an out-of-process verifier to make the flow more technology-agnostic, since we have multiple providers implemented in different languages (and also since the v3 spec doesn't seem to be supported by most pact libraries yet)

matt.fellows
2020-09-07 07:06
Interesting!

marco.dallagiacoma
2020-09-07 10:05
@uglyog @matt.fellows Sorry to bother you again, but we're a little stuck. The pact-reference verifier does not appear to support messages (for services that communicate via event streams and message queues). Do you know if there is any cli verifier that fully supports the v3 specification? Thanks a lot again

marco.dallagiacoma
2020-09-07 10:24
Hoping it may help, I opened an issue about that https://github.com/pact-foundation/pact-reference/issues/73

matt.fellows
2020-09-07 10:59
There is no CLI support for it because it needs to be able to invoke a function directly (it doesn't act as a specific queue provider such as Kafka). It's a doable thing, but there is design work and thinking to get it going

matt.fellows
2020-09-07 10:59
I think PHP does support messages so that's your best initial path

matt.fellows
2020-09-07 11:01
Alternatively you could call the Ruby pact verifier directly and I think you can get JVM to spit out V2 matchers which should make it work

matt.fellows
2020-09-07 11:02
When I'm in front of a computer next I can go into more detail. There is the pact-message and pact-provider-verifier binaries that work on the consumer and provider sides.

marco.dallagiacoma
2020-09-07 13:25
Hi @matt.fellows, thanks a lot for your reply. I see your point, even though I'm not sure I totally understand the reasoning. Our idea was to expose an API on the provider to return stubbed messages, in order to let the verifier verify the contract. And it appears this is partially supported by the ruby cli (even though it lacks support for some v3 matchers), which is why we thought it would be supported by the new rust cli as well. But in case you think this would not be a sensible way to implement this, I will remove the issue on GitHub and we'll figure out how to do it ourselves, perhaps by wrapping the Java library in a Cli (unless there are better ways to achieve out-of-process verification of messages?). Thanks again, I really appreciate your support

olarrmide
2020-09-07 13:44
I looked at the branch but didn?t see anything that specifically applies. I?d still appreciate some explanation of the example mock-service request.

tjones
2020-09-08 03:05
^ Yep. I've faced similar issues on some clients. For me, I think provider-driven contracts only really make sense when you don't even know who your consumers are (eg, if you're just providing services for people to consume without speaking to you)

matt.fellows
2020-09-08 03:23
So you can download the v3 package this way: https://github.com/pact-foundation/pact-js#pact-js-v3

matt.fellows
2020-09-08 03:23
It doesn?t use `.bat` files, so shouldn?t suffer this issue at all

matt.fellows
2020-09-08 03:24
it loads a dynamic shared library using standard node processes - it?s not executing files like the current version

matt.fellows
2020-09-08 03:24
> I?d still appreciate some explanation of the example mock-service request. Not sure what you mean here sorry?


rarora
2020-09-08 04:33
has joined #general

diana.snyder
2020-09-08 18:31
has joined #general

armorsmith42
2020-09-08 21:36
has joined #general

uglyog
2020-09-08 23:14
If you can provide an endpoint to fetch the messages, we could update the CLI to work. Not sure what other mechanism can work in a general way.

matt.fellows
2020-09-09 00:08
> Our idea was to expose an API on the provider to return stubbed messages, in order to let the verifier verify the contract. > And it appears this is partially supported by the ruby cli (even though it lacks support for some v3 matchers), which is why we thought it would be supported by the new rust cli as well. Yes, that?s exactly how it works. As you say, it just doesn?t parse the v3 matcher format. So if you can serialise v2 format from JVM it should be doable via the CLI


matt.fellows
2020-09-09 00:13
As an FYI, I?ll be needing the Rust stuff to support this in the coming months as I add v3 matching support to Pact Go, and add message support to Pact JS v3 branch. So it will be done, but you can get going with the pact-provider-verifier right now

matt.fellows
2020-09-09 00:13
you should be able to look at the Pact PHP code base for how it does this too (based on the JS/Go implementations)

uglyog
2020-09-09 00:14
I think the point was to use the V3 format to get the date matchers, so serialise v2 format from JVM is not an option.

matt.fellows
2020-09-09 00:50
the date matcher is ultimately just a regex though, so Marco could replace it with a regex and be done with it

uglyog
2020-09-09 01:08
> date matcher is ultimately just a regex though That is so not true, it is semantic in that it parses the dates and understands different days in months, timezones, DST, leap years and leap seconds. I want to see you do that with a regex.

matt.fellows
2020-09-09 01:32
fair enough

matt.fellows
2020-09-09 01:32
I still think for the purposes of this a regex is likely to suffice and get Marco moving

aforeman
2020-09-09 01:56
Hi everyone :wave: I?ve recently joined @bethskurrie  @matt.fellows and @uglyog as the Product Marketing Manager for the commercial version of Pact - https://pactflow.io/. I would love to get in touch with some Pact users to understand how Pact is solving your testing problems. Happy for this to be an informal chat via Slack DMs or a video call at a time that suits you. BTW - I'm also on the hunt for some pin up users to provide testimonials and case studies.... :smile: Looking forward to hearing from you!

armorsmith42
2020-09-09 05:46
@aforeman For me, the value of testing tools, Pact included, is psychological. As I code, I go through the same core loop that I would in a video game: https://youtu.be/mGL5YGcAxEI 1. Understand my goal 2. Gather info 3. Form a hypothesis 4. Test my hypothesis 5. Observe results 6. Interpret data Specs make each step more clear. The stronger & more frequent hits of dopamine keep me motivated. This make me a simultaneously faster and more sure-footed developer.

matt.fellows
2020-09-09 05:49
When I first started to manage people, I realised the dopamine didn?t come in small hits like you do with dev. That was an adjustment!

armorsmith42
2020-09-09 05:58
Speculation: A 1-way pact broker can be a sales & support tool for an API-backed product. When I worked at GoCardless, our salespeople told us that the reference and tutorial docs we wrote helped them close deals by strengthening internal advocates and reducing the total cost of adoption. https://getputpost.co/overhauling-api-docs-with-gocardless-90cc2e656750 This was also Stripe?s early strategy ? I knew their 4th employee Greg. He dropped out of my uni to join them, giving me his dorm room. ??????? Great Docs + Fast tests: More powerful than docs alone.

armorsmith42
2020-09-09 06:14
Imagine if when you are using an API client and keep getting an error ? Why!!??!? frustrating! Imagine a command could make an ?unhappy contract file?. Now you can see your API call side-by-side with the contract ? You can see the diff between them. You could see and fix your bug more quickly. Imagine you could auto-remove the PII and email it to their support team. The API support team could immediately diagnose your confusion ? or see that the bug was on *their* end and API endpoint devs could reproduce and fix the bug in the API route. The Total Cost to Acquire that API-backed product just went down as well as their support cost and dev cost.

armorsmith42
2020-09-09 06:35
Yep! That happens any time you put time lag in the reward feedback loop. Know anybody who found it dramatically harder to focus when they suddenly went from working alongside their team to working remotely? They lost familiar ways to feel aligned with their team. It made it harder for their brain to model rewards ?> weaker and less frequent dopamine hits ?> less well-directed attention. ?????? A friend of mine makes videos on how keep AI systems aligned with humanity?s goals. He explains Reward Modeling well here: https://youtu.be/PYylPRX6z4Q I think the concept is useful for anyone with a deep neural network :brain: between their ears. Automated tests are a written artifact that strengthens a reward model.

matt.fellows
2020-09-09 06:38
Indeed.

matt.fellows
2020-09-09 06:38
> I think the concept is useful for anyone with a deep neural network dang, I was hoping it was going to be helpful for me :wink:

matt.fellows
2020-09-09 06:47
So these ideas are good - what else should we build Andrew!

matt.fellows
2020-09-09 06:47
(just in case, that should not be interpreted as sarcasm)

tjones
2020-09-09 06:47
I really like this

tjones
2020-09-09 06:49
Somewhat related, I'd like the ability to say "I don't like this response" - especially with AWS services - a lot of their APIs return 400 with no context when something is wrong. As a provider OR consumer it would be awesome if consumers could automatically flag "I found this response very unhelpful"

aforeman
2020-09-09 06:59
Getting into the flow @armorsmith42 love it

dabs1234
2020-09-09 07:34
has joined #general

dabs1234
2020-09-09 07:52
Hello All, I am new to PACT and just did a POC with JUnit5 on simple microservice consumer and provider. Now I need to implement it on real springboot microservice which uses oauth2. What is the best way of achieving this? Any sample code would be a great help.

matt.fellows
2020-09-09 07:58
Hello! Might be worth asking in #pact-jvm

matt.fellows
2020-09-09 08:00
howtolearn

2020-09-09 08:00
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-09 08:00
:point_up: have a look here as well, the workshop for Java has an example of how to work with auth

marco.dallagiacoma
2020-09-09 08:25
Thanks a lot @matt.fellows and @uglyog, you've been super helpful and we appreciate that a lot :slightly_smiling_face: We'll try to do as Matt suggests and use the ruby cli until this gets implemented in the rust cli. Again, thank you! :smile:

matt.fellows
2020-09-09 08:36
:slightly_smiling_face:

aftabshk
2020-09-09 09:32
has joined #general

aftabshk
2020-09-09 09:35
Hello All, we are working on a project where we get encrypted responses from providers. We are using pact-jvm-provider-gradle plugin version 4.0.3 for writing the contract tests. Could you please let us know how we can leverage the pact to check the contract after decryption of the response?

hader.araujo
2020-09-09 14:20
has joined #general

jagiles
2020-09-09 16:07
has joined #general

flavio.antunes
2020-09-09 17:22
has joined #general

tony.silva
2020-09-09 17:23
has joined #general

suresh.tsv
2020-09-09 22:57
Thank you very much for your quick response. As suggested, we will explore the options of API gateway and Pactflow. I will reach out to you or team if there are any questions. Regards

crazycabo350
2020-09-10 04:25
has joined #general

daniel.meisen
2020-09-10 06:52
has joined #general

armen.chuljyan
2020-09-10 07:44
has joined #general

aitorarce
2020-09-10 09:56
has joined #general

krisdinesh
2020-09-10 11:12
I am successful implementing Pact for the languages .net and java. Moving further to use in Ruby as well. Here I am having a question, is there a way that I can run provider test using like .exe instead of running like unit test. In the world of ci/cd I feel this could be great option for language agnostic

sagupta
2020-09-10 12:14
Hello , On running the provider side tests, is there a way to get the logs to know what was the actual response from the provider when the interactions are replayed? Currently I only see failure like this ```Failures: 1) Verifying a pact between <consumer> and <provider> Given a saved form with elements a request to publish a form with <> returns a response which has status code 204 Failure/Error: expect(response_status).to eql expected_response_status expected: 204 got: 404 (compared using eql?) # ./bin/pact:15:in `<top (required)>' 4 interactions, 1 failure``` I wanted to know what was the whole response returned from provider? Also currently I am not publishing the results back to pact broker , is there a way to see these response in pact broker as well?


matt.fellows
2020-09-10 12:16
The feedback is displayed in pactflow, not the oss broker I?m afraid

matt.fellows
2020-09-10 12:16
Which language are you using? There should be provider logs somewhere

sagupta
2020-09-10 12:17
ohh, i am using pact-cli provider-verify command to run provider tests

matt.fellows
2020-09-10 12:18
`--verbose` might get you somewhere

matt.fellows
2020-09-10 12:18
I have a feeling it does write a log file somewhere (you might need to do a search in the sub folders)

matt.fellows
2020-09-10 12:18
I can?t recall if there was a flag added recently to control log output

sagupta
2020-09-10 12:20
I find this in the provider-verifier readme ``` -o, [--out=FILE] # Write output to a file instead of $stdout.```

matt.fellows
2020-09-10 12:21
that?s just going to redirect stdout to a file, probably not what you want

sagupta
2020-09-10 12:21
But I guess it is for the failure logs which i posted in the message and not the response from provider

sagupta
2020-09-10 12:21
let me try --verbose

sagupta
2020-09-10 12:27
didnt help , it only added extra logs about connection to pact broker like this and the test logs are the same as before ```opening connection to pact-broker.gp.k8s.<>:443... opened starting SSL for pact-broker.gp.k8s.<>:443... SSL established <- "GET / HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nAuthorization: [redacted]\r\n" -> "HTTP/1.1 200 OK\r\n"```

vittorio.guerriero
2020-09-10 12:28
has joined #general

sagupta
2020-09-10 12:35
I cant find any log file in the subfolder . However I found this as well in readme ``` # Default: 0 [--log-dir=LOG_DIR] # The directory for the pact.log file [--log-level=LOG_LEVEL] # The log level```

sagupta
2020-09-10 12:42
got it . it is indeed :point_up: . once i set the property --log-dir i got a .log file which has all the request and responses

copalco
2020-09-10 12:53
has joined #general

krisdinesh
2020-09-10 13:14
Exactly this is what I am expecting. @matt.fellows I don?t have words to express the way you help community. Without you I would have lost while implementing Pact.

crazycabo350
2020-09-10 13:15
`[ERROR] pactVerificationTestTemplate{PactVerificationContext}[1] Time elapsed: 1.222 s <<< ERROR!` `au.com.dius.pact.core.support.json.JsonException: Invalid Json document (1:3) - expected a string but found unexpected characters '[C@464c18c8'`

crazycabo350
2020-09-10 13:15
Wondering if anyone has an idea of what the error above could represent

crazycabo350
2020-09-10 13:16
The Pact is verified and result uploaded to broker successfully, but error causes test to fail

crazycabo350
2020-09-10 13:22
This is a Spring project using jUnit5

crazycabo350
2020-09-10 13:24
The character string mentioned I could not find in the HAL browser for the broker, so I'm not sure what it's referring to.

antonello
2020-09-10 14:24
It looks like some kind of encoding issue

sidhartha.k.subudhi
2020-09-10 16:18
I was giving a demo to the leadership today. I got a question and could not convince them. Need help in this. Question is, we are defining contract in Consumer test like this: ```.body(new PactDslJsonBody() .integerType("id",7) .stringValue("name", "Tiger"))``` But if there are 50 fields am I going to write one by one like this or there is any way we can feed everything in a file and call that in code?

crazycabo350
2020-09-10 18:24
Define DSL body in another class separate from tests for reusability

crazycabo350
2020-09-10 18:25
Yeah, but how can I troubleshoot it? Where do those characters exist during Pact verification.

michaelkochub
2020-09-10 19:49
Hello! Based on the documentation (https://docs.pact.io/implementation_guides/jvm/provider/gradle/#specifying-the-provider-hostname-at-runtime) you can specify the pact file location at runtime by setting the `pactFile` variable to a closure. This is for configuring a single consumer. Is it possible to do the same thing in the multiple consumer case? Like so: ```hasPactsWith('manyConsumers') { pactFileLocation = { lookupPactFolder() } }``` When I try to do this, Gradle throws a casting exception

antonello
2020-09-10 20:58
Can you tell us nord about your pact?

matt.fellows
2020-09-10 21:35
It's just java code, you could extract those into a fixture file or whatever you find simplest to manage

abubics
2020-09-10 23:48
Also, depending which language you're using, there might be a nicer Pact DSL, or syntactic sugar provided by the actual language.

bethskurrie
2020-09-11 09:01
Pact Broker Maintainer announcement: The Pact Broker API that supports the pending pact, WIP pacts, and consumer version selectors during verification has been officially released in 2.60.1. There are some versions of the pact-ruby-standalone (the underlying shared pact code) that use a beta version of the API that is now no longer supported (the original API used a GET, but the parameters turned out to be too complex, so it was changed to a POST). If you find issues, please upgrade to the latest version of your Pact client library.

bethskurrie
2020-09-11 09:07
Hi @michaelkochub - best to ask in the #pact-jvm channel

alex.elmekeev
2020-09-11 09:09
:wave: is it possible to specify the versions of client libraries we should update to? Do we have updates for all clients libraries to support this change?

bethskurrie
2020-09-11 09:10
Pact JVM will be fine - it never used the GET API.

bethskurrie
2020-09-11 09:10
Which library are you using?

alex.elmekeev
2020-09-11 09:11
we have ruby, jvm, js and python and I've updated our broer to 2.60.1 in order to report https://pact-foundation.slack.com/archives/C9VHVEDE1/p1599756784003800 so now I wonder if I broke something

bethskurrie
2020-09-11 09:28
@alex.elmekeev see the comments on the issue

sidhartha.k.subudhi
2020-09-11 12:03
Can you please give one example for JAVA. a small and simple one is ok to understand.

karasiewicz.business
2020-09-11 14:02
has joined #general

crazycabo350
2020-09-11 14:18
```{ "provider": { "name": "floorplan" }, "consumer": { "name": "payments" }, "interactions": [ { "description": "Request with floorplan ID", "request": { "method": "POST", "path": "/api/v2/floorplans/byFloorplanId", "body": "{[\u00272b1ce421-b80c-4f5b-aef4-b1691d0ff0a2\u0027]}" }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset\u003dutf-8" }, "body": { "id": "e2490de5-5bd3-43d5-b7c4-526e33f71304", "titleLocation": "string", "titleLocationId": 100 }, "matchingRules": { "body": { "$.id": { "matchers": [ { "match": "regex", "regex": "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" } ], "combine": "AND" }, "$.titleLocation": { "matchers": [ { "match": "type" } ], "combine": "AND" }, "$.titleLocationId": { "matchers": [ { "match": "integer" } ], "combine": "AND" } } }, "generators": { "body": { "$.id": { "type": "Uuid" }, "$.titleLocation": { "type": "RandomString", "size": 20 }, "$.titleLocationId": { "type": "RandomInt", "min": 0, "max": 2147483647 } } } } } ], "metadata": { "pactSpecification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.6.15" } } }```

jan.krejci
2020-09-11 16:09
Hi guys. Is it possible somehow you create the provider states before the consumers actually exist within the Pact Broker ?

phillip.lo
2020-09-11 21:07
I was wondering if there are any known limits of how many pacts and number of consumers/providers the broker is able to handle? Are limits purely based on UI usability or is there a limit we should know about?

adrian.golawski
2020-09-12 00:14
has joined #general

matt.fellows
2020-09-12 00:14
How big are we talking? We have customers with hundreds or applications and integrations and tens of thousands of publications etc.

matt.fellows
2020-09-12 00:15
We have a way to clean out old data also if its really a problem, but it's unlikely to surface for a while

bethskurrie
2020-09-12 00:17
There's no offical documentation process for it, but you can write the code and share the documentation in your own way.

bethskurrie
2020-09-12 00:34
@phillip.lo one of the issues people have found with the OSS Pact Broker is that there is no way of grouping or filtering the applications in the dashboard. This is why we've just added teams support in Pactflow. It lets you assign people and applications to teams, and filter the dashboard by team, so you can just see the applications you're responsible for.

bethskurrie
2020-09-12 00:35
We'll be adding more team-centric functionality over the next few months.

phillip.lo
2020-09-12 01:51
Hundreds of apps and tens of thousands of publications is enough scale for what we need. Makes sense about the grouping and filtering from pactflow. Thanks for the info!

abubics
2020-09-12 01:57
https://docs.pact.io/implementation_guides/jvm/consumer/java8/ e.g. ```array.object((o) -> { o.stringValue("foo", "Foo"); # an attribute o.stringValue("bar", "Bar"); # an attribute o.object("tar", (tarObject) -> { # an attribute with a nested object tarObject.stringValue("a", "A"); # attribute of the nested object tarObject.stringValue("b", "B"); # attribute of the nested object }) });```

abubics
2020-09-12 01:58
but if you have a flat set of 50 fields, no DSL is going to help you much :slightly_smiling_face:

abubics
2020-09-12 02:08
If that's the case, it's up to you . . . you can make static fixtures (brittle, and makes matching hard), dynamic fixtures, dynamic fixture helpers . . . they all have different trade-offs, including maintainability and readability. You might also want to consider refactoring the data structures to make them easier to read, understand, and work with for all API consumers :innocent:

armorsmith42
2020-09-13 02:19
Idea 1: Target your marketing at the consumers of APIs who write tests as a way of doing TDD and checking that they understand the API. I naively suspect that the Pay-Per-Click auctions aren?t all that crowded for frustrating API errors. Idea 2: The API-consumer tool that advertises the competitors of your non-customers This CLI helps devs understand and check their assumptions about an API as they work with it. Unless configured otherwise, error responses can link to either A. An API support channel that the API host pays you to include. B. StackOverflow, if you want to leave money on the table. C. A privately-run StackExchange-like forum entry about that API endpoint or error. This page includes discussion of the error and how to use this frustrating API, but also advertisements for competing products. The more frustrating the API, the more ad-exposure its competitors get. Example: If someone is frustrated with the SalesForce ExactTarget API for sending emails, they could google for it and the near-top hits could be: 1. Pact Consumer tool download link. 2. The same Pact API Experience forum link that #1 could give them. It would show an advertisement for Mandrill. So you either A. make money off Mandrill for task-targeted advertizing. B make money from ExactTarget to ?help improve their API usability?

armorsmith42
2020-09-13 02:20
Is it a little bit of a protection racket? Sure, but if I?m right, its a protection racket that would create incentives for better-documented API developer experiences.

armorsmith42
2020-09-13 02:24
It also gives you an audience of devs who start using the consumer tools without needing signoff from anyone but the lead of their particular project.

armorsmith42
2020-09-13 11:27
(Er, maybe thats too convoluted)

me1276
2020-09-14 06:37
has joined #general

rarora
2020-09-14 07:55
Hi Team I am using jdk-11.0.8+10/ and pact version 4.0.4. Whenever i try to publish pacts to broker, my gradle daemon crashes without error in log and hss_err*.pid file is created

rarora
2020-09-14 07:57
Has anybody faced such error before?

uglyog
2020-09-14 07:59
Looks like libjansi is causing an issue. If you upgrade to 4.1.x, it doesn't use jansi anymore

matt.fellows
2020-09-14 08:00
Hello @me1276! How'd the talk go?

me1276
2020-09-14 08:02
Hey @matt.fellows! The talk is later today, it?s not really a talk rather a rundown panel where we review trends in testing, and Contract/Pact is getting a lot of attention :rocket:

matt.fellows
2020-09-14 08:04
Oh cool!

matt.fellows
2020-09-14 08:05
And it sure is. I'm just popping out for a bit but would love to chat and hear how it goes and of course if you need anything we're all here to help!

me1276
2020-09-14 08:06
Sure thing, I?ll share some updates

uglyog
2020-09-14 08:11
@marco.dallagiacoma Rust Pact verifier CLI has been updated to support verifying message pacts.

marco.dallagiacoma
2020-09-14 08:24
@uglyog thanks a lot, you people (and the person who made the PR) rock! :smile:

wesleythomaswilliams
2020-09-14 10:46
General question. My team are about to start integrating with a service which uses Kafka with Avro and a Schema Registry. I've been reading up on it and my immediate thought was that contract testing becomes less important or maybe even redundant when a schema registry is in play. Am I being stupid?

matt.fellows
2020-09-14 12:03
Not being stupid at all!

matt.fellows
2020-09-14 12:04
First, right now at least, you would need to create some form of adapter in your pact tests (similar to the one described in #protobufs ) to deal with Avro, albeit Avro is fairly simple

matt.fellows
2020-09-14 12:04
secondly, the schema registry does give you some guarantees that may alleviate Pact tests

matt.fellows
2020-09-14 12:08
The downsides: 1. You won?t catch integration issues until you deploy into a test environment (so no feedback on dev machine). There are settings as well that configure if it fails on deploy or on ?first contact?. So there may be further delays there also. 2. You have to ensure that your test environment matches the state of production, otherwise the schema version management will get out of sync (i.e. stateful environments) 3. You may not get the full picture in the pact broker of the architecture (or rather, you?ll lose out on the message details) 4. There may be something about the evolution capabilities of Pact that it doesn?t know about (e.g. removing a field that a consumer no longer needs that Pact can facilitate, I?m not sure if that scenario is covered by the schema registry) I?m not an expert though, and possibly

matt.fellows
2020-09-14 12:09
A lot of those tools are more ?backwards compatibility? detectors, but do it at the schema level. A contract encapsulates the conversations, so knows what parts of the schema are/aren?t used

psychopomp3x
2020-09-14 13:15
Lateral question: My team has started down the road of micro-frontends, where a larger application is split into multiple independently deployable applications deployed to different servers, but with facets that allow them to integrate shallowly at runtime. We are finding ourselves with a new need to test that a url is available / stable as those applications may hyperlink to stable and versioned urls in each other. It's not an API, but it is a provider / consumer construct. Is this the sort of thing we could use pact for via an off-label usage? We would essentially need to test that a provider application has a route at a url that accepts certain queryparams.

sklein
2020-09-14 13:17
I am very interested to hear stories/strategies for how others have promoted pact adoption in their organizations (i.e. custom packages, templates, etc). Anyone willing to share experiences and outcomes?

khazhak.vahanyan
2020-09-14 14:54
has joined #general

khazhak.vahanyan
2020-09-14 14:56
Hey there. One question about matching arrays. Is there a way to have anyLike instead of eachLike?

khazhak.vahanyan
2020-09-14 14:58
the problem is, my API has an array which contains elements of different types(I konw it's badly designed). Each element assumes different business logic, so one test case needs one of the elements

khazhak.vahanyan
2020-09-14 15:05
or maybe a functionality of "or". So match like `{ob: likeOr({id: "id but no name"}, {name: "name but no id"})}`


jonathanmorley
2020-09-14 16:58
has joined #general


matt.fellows
2020-09-14 21:07
Which language?

matt.fellows
2020-09-14 21:14
Interesting idea. Are the routes a DAG or can a consumer and provider both link to each other? (I.e. are there cyclic dependencies?)

matt.fellows
2020-09-14 21:14
I think Pact supports it but suspect if there is a lot of it going on it might get messy/confusing

matt.fellows
2020-09-14 22:38
Cc @sayboras @bheemreddy181 @franklin.huynh @antonello

matt.fellows
2020-09-14 22:39
We're also looking for a customer to talk to their experiences using pact at a Rabobank (Netherlands) internal conference. They have a contract testing guild internally and are looking to scale the practice bank wide

matt.fellows
2020-09-14 22:39
I'll be casting the net a little wider so will connect you if I can

bheemreddy181
2020-09-15 03:14
Pact adoption is still in progress at our org and it?s not quite easy to get a buy in directly I am trying to pair with each team and look at new API?s rather than tweaking around the existing ones which already has lot of end to end tests

bheemreddy181
2020-09-15 03:16
And pact adoption is not quite straight forward as writing an end to end test - one team really started seeing value from it and they wanted to do more and another team gave a try and they felt like a overhead because they don?t look at this option as longer term value and they face lot of challenges with existing library comparability

bheemreddy181
2020-09-15 03:18
And this story continues I feel people need more understanding around advantages from this approach

bheemreddy181
2020-09-15 03:19
So I am working on a documentation to make things really easier for people to adopt as we are doing this for the first time we are not quite at there to make it really easy for entire org and the each service has its own challenges for making templates more generic

matt.fellows
2020-09-15 07:16
Thanks for your input Bheem

matt.fellows
2020-09-15 07:18
Looks like things have moved on a little slowly there. As an FYI, we think our work around provider-driven contract testing might be useful to your team - our guess is that the consumers are finding it easier to write the tests, but the provider teams are having a harder time of buying into it. If you?re interested, let me know and we can see if it would be helpful

khazhak.vahanyan
2020-09-15 07:53
JS, Java and swift

khazhak.vahanyan
2020-09-15 07:54
when is the planned release?

matt.fellows
2020-09-15 07:59
JS/Java ~1 month I?d say

matt.fellows
2020-09-15 07:59
Swift is not currently on the near term roadmap, but if you could give that a comment on the canny post that would help

khazhak.vahanyan
2020-09-15 08:00
that's cool. it would probably take more to convince my company to use Pact haha

khazhak.vahanyan
2020-09-15 08:06
A few uncomfortable issues I had while trying the full integration. CLI tool is a bit buggy. Tried the standalone Ruby version on mac, it was pain, as I had to allow permissions for ~20 libs it uses seperately(maybe a brew package would fix this). Error messaging is kinda lacking too. Even with debug mode, I had to guess why some stuff isn't working (1. missed https in front of broker url, it said it succeeded but it didn't, 2. By defualt it searched by tag "dev". For a newbie, it's hard to understand why no contract was being tested).

khazhak.vahanyan
2020-09-15 08:10
Documentation on publishing pacts is also lacking, I think. I persionally think, CLI tool is the best way to publish, as it can be easily integrated with every CI tool out there, so I think docs should state that.

matt.fellows
2020-09-15 08:23
what do you mean by ?allow permissions? for the 20 libs?

matt.fellows
2020-09-15 08:23
do you have a security tool or something picking that up?

matt.fellows
2020-09-15 08:23
it should be an unzip, chmod and go

matt.fellows
2020-09-15 08:23
that protocol thing sounds like a bug though

matt.fellows
2020-09-15 08:24
We agree, but most people say ?why can?t I publish in `<insert my language/framework/build tool here>` (looking at you Maven users)

khazhak.vahanyan
2020-09-15 08:24
Macos Catalina requires manual allowance from "unidentified developers". It's a non issue usually but for some reason pact's cli required for each lib

matt.fellows
2020-09-15 08:24
we recently made some changes on this (to push CLI usage), perhaps we need to do more - thanks!

matt.fellows
2020-09-15 08:25
strange, I?m on catalina and don?t have that issue

matt.fellows
2020-09-15 08:25
That would render any scripting language basically useless!

khazhak.vahanyan
2020-09-15 08:25
I will try to reproduce

abubics
2020-09-15 08:26
idk, if I google "publish pact", https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts/ is the first hit, and it's all CLI instructions (until after the curl section where it says you probably don't need it :P)

khazhak.vahanyan
2020-09-15 08:39
that is correct :smile:

khazhak.vahanyan
2020-09-15 08:45
There it is

khazhak.vahanyan
2020-09-15 08:46
@matt.fellows

bheemreddy181
2020-09-15 10:43
I would like to adopt more Consumer Driven contracts than provider driven for known consumers based services I am fairly confident that we will get there and for services with unknown consumer provider based contract testing makes more sense

lukorovina
2020-09-15 11:20
has joined #general

francislainy.campos
2020-09-15 11:56
Hi, just signed up for pact flow to check it out but am a bit confused on how to publish a contract into it if anyone could guide me on this please? I do Java, so initially assumed I'd need to point my pact plugin on the pom file to url that has been emailed me, but maybe need some more configs? Thanks a lot.

wesleythomaswilliams
2020-09-15 11:57
Happy to help

francislainy.campos
2020-09-15 11:58
Awesome, thanks a million.

francislainy.campos
2020-09-15 11:58
Okay, so trying to publish my contract if you know how to do that please?

wesleythomaswilliams
2020-09-15 11:59
Sure, let me just dig up the details.

francislainy.campos
2020-09-15 11:59
Thank you.

wesleythomaswilliams
2020-09-15 12:01
Ok, so we have a dedicated stage in our pipeline for it. We use Maven & Jenkins. ```/* ******** Pact Publish ******** */ stage("Pact Publish") { // Stage is only executed if the service is a consumer. when { expression { isTestStageRequired() && pipelineParams.pact_publish } } steps { script { currentStage=env.STAGE_NAME try { sh 'docker run -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock ' + env.BUILD_CONTAINER_NAME + ' mvn -B -f pom.xml pact:publish' + ' -Dpact.consumer.version=' + env.GIT_COMMIT + ' -Dpact.tag=' + env.GIT_BRANCH } catch (Exception ex) { echo "Exception in \"Publish Pact File\" stage, see logs for details." throw ex } } } }```

francislainy.campos
2020-09-15 12:02
I'm trying to do the manual publishing so not hooked up to jenkins but directly through a maven command.

wesleythomaswilliams
2020-09-15 12:02
Our pom for consumers contains this: ```<!-- Pact --> <plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <configuration> <projectVersion>${pact.consumer.version}</projectVersion> <pactDirectory>${project.build.directory}/pacts</pactDirectory> <pactBrokerUrl>https://pde.pact.dius.com.au</pactBrokerUrl> <pactBrokerToken>SHHITSASECRET</pactBrokerToken> <pactBrokerAuthenticationScheme>Bearer</pactBrokerAuthenticationScheme> <skipPactPublish>false</skipPactPublish> <tags> <!--suppress UnresolvedMavenProperty --> <tag>${pact.tag}</tag> </tags> </configuration> </plugin>```

francislainy.campos
2020-09-15 12:02
Ah okay, so maybe this line:

francislainy.campos
2020-09-15 12:02
``` <pactBrokerToken>SHHITSASECRET</pactBrokerToken>```

francislainy.campos
2020-09-15 12:03
I'll try that.

francislainy.campos
2020-09-15 12:03
Thank you.

wesleythomaswilliams
2020-09-15 12:03
You can also use username/password

francislainy.campos
2020-09-15 12:03
Really?

wesleythomaswilliams
2020-09-15 12:03
I think so, unless they've removed that (which is possible)

francislainy.campos
2020-09-15 12:04
like <pactUsername>username</pactUsername>

wesleythomaswilliams
2020-09-15 12:04
Yeah, let me check


wesleythomaswilliams
2020-09-15 12:09
Also, I'm using v4.0.4 so some other things may have changed. I notice in the docs the artifactId = maven, whereas mine is pact-jvm-provider-maven

francislainy.campos
2020-09-15 12:11
The pom is rejecting me publishing into the broker whereas it works fine when I point to our own broker url

francislainy.campos
2020-09-15 12:11
I'll see if maybe something else described on the documentation

francislainy.campos
2020-09-15 12:14
```<plugin> <groupId>au.com.dius</groupId> <artifactId>pact-jvm-provider-maven</artifactId> <version>${pact.version}</version> <configuration> <pactDirectory>target/pacts</pactDirectory> <pactBrokerUrl>https://mypflow.pactflow.io/</pactBrokerUrl> <pactBrokerUsername>myusername</pactBrokerUsername> <pactBrokerPassword>mypass$</pactBrokerPassword> <projectVersion>${project.version}</projectVersion> <trimSnapshot>true</trimSnapshot> </configuration> </plugin>```

francislainy.campos
2020-09-15 12:14
This is what I have.

sklein
2020-09-15 12:56
@matt.fellows I'm eagerly awaiting the provider driven contract features you have in store, especially the stuff around openapi spec generated contracts! I know it's on the road map for q3!

psychopomp3x
2020-09-15 13:34
I believe they will be p2p / cyclic for most runtime integrations, which will place a burden on crafting shallow integrations and version stability. For example, there may be a "launchpad" app that provides a user a list of prioritized concerns, and then when they click on a concern, it will switch to a "member" summary app, which may link to a "member contact history" app, and then back to the original "launchpad" app when they complete the workflow. The entry point routes would look something like: http://memberContacts.foo.com/publicStableRoutes/memberSummary/v1 The plan is to make breaking changes immutably via new version numbers, and keep the old one around until all downstream clients are upgraded and tested against the new interfaces. In order to build trust with the consumer apps, we want to have some sort of backwards compatibility test to prove that the v1 isn't broken when v2 is published. We have also toyed with the idea of hosting multiple versioned web components from each of the apps with a similar versioning and bct structure. In that case, it would be something like "http://member.foo.com/publicSmartWidgets/v1/memberDemographics/main.js" They would be loaded at runtime via something like in-browser ES modules or via systemjs. This is similar to how single-spa based apps perform runtime integrations of angular elements / web components.

matt.fellows
2020-09-15 13:37
@francislainy.campos you can?t user username/password for Pactflow. We only support bearer token authentication

matt.fellows
2020-09-15 13:37
your username and password are for access to the UI only

matt.fellows
2020-09-15 13:37
Bearer token is for API Tokens


matt.fellows
2020-09-15 13:38
@wesleythomaswilliams have a :taco: because you?re so helpful.

francislainy.campos
2020-09-15 13:38
Cool, alright. Thanks. I'll try with the token then.

matt.fellows
2020-09-15 13:38
A second :taco: for @wesleythomaswilliams for previously helpfulness

matt.fellows
2020-09-15 13:39
Make sure to get the read/write token, not the read-only one

louisallenfrank
2020-09-15 13:42
has joined #general

matt.fellows
2020-09-15 13:42
You?re now officially on a list, congratulations :stuck_out_tongue:

wesleythomaswilliams
2020-09-15 13:45
Apologies @francislainy.campos I ducked out for lunch. Thanks for the Taco's @matt.fellows

jonathanmorley
2020-09-15 13:45
hey :wave: maybe one for the #pact-js channel but are there any plans to support requiring multiple states in the setup for my consumer test? (maybe this is already possible) i'd like to be able to compose various states together to use in my consumers, to avoid creating further niche states on the provider.

francislainy.campos
2020-09-15 13:47
Cool, yeah. That worked. And no worries Wes, you've been great helping me with this one.

jonathanmorley
2020-09-15 13:47
conceptually looking for something like: ```return provider.addInteraction({ state: ['there is a burger order', 'there is a fries order'], uponReceiving: 'a request for orders', withRequest: { path: '/orders', method: 'GET', }, willRespondWith: { body: eachLike({ id: 1, items: eachLike({ name: 'burger', quantity: 2, value: 100, }), }), status: 200, headers: { 'Content-Type': 'application/json; charset=utf-8', }, }, })```

francislainy.campos
2020-09-15 13:47
I'm now just going to the verification bit.

francislainy.campos
2020-09-15 13:48
And I have this:

francislainy.campos
2020-09-15 13:48
```@Provider(VC) /** Uncomment this and comment @PactBroker instead to test locally by pasting a .json file for the contract under the target/pacts folder */ //@PactFolder("target/pacts") @PactBroker(host = "http://mypact.pactflow.io", consumers = {ED_UI}) public class PactProviderTest { @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", AUTHORIZATION_TOKEN); context.verifyInteraction(); } @BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpsTestTarget(getBasePactEndpoint(), 443, "/")); getAuthorizationToken(UserType.TEACHER); } @State("A request to store/create a Zoom meeting") public void sampleState() { } }```

francislainy.campos
2020-09-15 13:48
But am getting a 401 error.

wesleythomaswilliams
2020-09-15 13:49
So we have: ```@PactBroker( host = "${pact.broker.host}", scheme = "https", port = "443", authentication = @PactBrokerAuth(token = "${pact.broker.token}"))```

francislainy.campos
2020-09-15 13:50
Cool, let me try that. Thank you.

psychopomp3x
2020-09-15 13:52
The exported bits would need to be self-contained except for the dom based public interface. We would not, for example, export any types in this mode of operation.

francislainy.campos
2020-09-15 13:53
Yes, I'm in now but then, sorry, another question.

francislainy.campos
2020-09-15 13:54
It's not finding my pact even though I can see it there on the UI.

francislainy.campos
2020-09-15 13:59
Actually, no, sorry, there was an error on the path and once fixed it did connect and verified the contract but I was expecting to see the results from the ui rather than the local terminal?

wesleythomaswilliams
2020-09-15 14:02
If you publish the verification results, you should see that in the UI

wesleythomaswilliams
2020-09-15 14:02
But the verification alone won't show anything.

francislainy.campos
2020-09-15 14:03
I'm just trying a way to see the stack trace with some better formatting since what is logged on the terminal is hard to read.

wesleythomaswilliams
2020-09-15 14:03
We do this in our pipeline: ```sh 'docker run -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock ' + env.BUILD_CONTAINER_NAME + ' mvn -B -f pom.xml jacoco:prepare-agent jacoco:report test -Pcore-tests' + ' -Dpact.provider.version=' + env.GIT_COMMIT + ' -Dpact.verifier.publishResults=true' + ' -Dpact.provider.tag=' + env.GIT_BRANCH```

wesleythomaswilliams
2020-09-15 14:04
That executes provider tests and publishes the results to Pact Flow

matt.fellows
2020-09-15 14:04
Yes, checkout the v3 version on the readme.

francislainy.campos
2020-09-15 14:04
Okay, so maybe this would be another config on the pom I suppose.

matt.fellows
2020-09-15 14:04
It's beta, but does support that

francislainy.campos
2020-09-15 14:05
Or maybe just to append this to the maven command we use to run it.

wesleythomaswilliams
2020-09-15 14:05
We took the stance that we only want results published as part of the build process, so that Pact Flow isn't full of local build results.

francislainy.campos
2020-09-15 14:05
I'd run it through the ui button on intellij but let me try through the terminal with the maven instead.

jonathanmorley
2020-09-15 14:15
thanks @matt.fellows which bit specifically? The examples seem to 404

francislainy.campos
2020-09-15 14:40
It's working now that I see whether it passed or failed through the flow, but I guess as you're saying it doesn't seem to show much more than that.

francislainy.campos
2020-09-15 14:43
I guess what I need is a better way to debug issues as the terminal is not very friendly with the pact stack trace.

wesleythomaswilliams
2020-09-15 14:44
You might be out of luck there. I think everything I do from a debug perspective is via the terminal.

francislainy.campos
2020-09-15 14:45
~Do you know~

francislainy.campos
2020-09-15 14:45
You see, this is what I mean.

francislainy.campos
2020-09-15 14:46
I was trying to find a way to get the curl that generated that call or pieces of the request that I could put together and maybe check why this is coming up this way.

francislainy.campos
2020-09-15 14:47
There may be something that comes from this bit:

francislainy.campos
2020-09-15 14:47
```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", AUTHORIZATION_TOKEN); context.verifyInteraction(); }```

wesleythomaswilliams
2020-09-15 14:47
Yeah, it's not pretty and does make it challenging at times to debug.

francislainy.campos
2020-09-15 14:47
So was trying to debug the httpRequest class

francislainy.campos
2020-09-15 14:48
Yeah, I'm around 4 to 5 hours now trying to see why my pact is failing I'm afraid.

wesleythomaswilliams
2020-09-15 14:48
As it's referring to the body comparison, I'd be looking at how my contract is defined.

wesleythomaswilliams
2020-09-15 14:48
Can you share it?

francislainy.campos
2020-09-15 14:49
I've removed all fields from my contract so that it has only one key but still getting the same thing. All my others work fine.

francislainy.campos
2020-09-15 14:50
I can clean up a bit here and share, thank you. But yeah, ideally if I knew a way to go inside the request and which payload is coming up.

francislainy.campos
2020-09-15 14:52
Before sharing, I'll delete some more things to see if can debug this way in case can find the solution perhaps.

wesleythomaswilliams
2020-09-15 14:57
FYI our bit of the same code looks like: ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context) { context.verifyInteraction(); }``` We don't add an auth token into the header

francislainy.campos
2020-09-15 14:58
Yeah, we need this bit otherwise we get a 403 here from our side.

francislainy.campos
2020-09-15 14:59
I think the issue we're facing with our calls is to do with date formatting.

francislainy.campos
2020-09-15 15:01
But changed another field now just for debugging purposes and I see this on the terminal.

francislainy.campos
2020-09-15 15:01
But this on Pact flow

francislainy.campos
2020-09-15 15:03
May want to double check with @matt.fellows again on whether there's any way to have the errors showing there please since this would probably be the feature that we'd be in need of the most here from our side to sign up to it I think.

wesleythomaswilliams
2020-09-15 15:05
What does your Pact DSL look like for this contract definition in the consumer test?

francislainy.campos
2020-09-15 15:06
```@ExtendWith(PactConsumerTestExt.class) public class PactConsumerTest { Map<String, String> headers = new HashMap<>(); String storeMeeting = "/vcservice/store/meeting"; DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); String nowAsISO = df.format(new Date()); @Pact(provider = VC, consumer = ED_UI) public RequestResponsePact createPact(PactDslWithProvider builder) { headers.put("Content-Type", "application/json"); headers.put("Accept", "application/json"); DslPart bodyStoreMeetingWithNoParticipants = new PactDslJsonBody() .numberType("id", 3) .stringType("title", "string") .integerType("duration", 0) .stringType("startDateTime", "2020-09-15T11:46:52Z") // .date("startDateTime", "yyyy-MM-dd'T'HH:mm:ss'Z'", new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'").parse(nowAsISO)); return builder .uponReceiving("A request to store/create a Zoom meeting") .path(storeMeeting) .method("POST") .headers(headers) .body( "{\n" + " \"title\":\"My title 2020-09-15T11:46:52Z\",\n" + " \"startDateTime\":\"2020-09-15T11:46:52Z\",\n" + " \"duration\":30,\n" + " \"provider\":\"ZOOM\",\n" + " \"participants\":[]\n" + "}" ) .willRespondWith() .body(bodyStoreMeetingWithNoParticipants) .toPact(); } @Test @PactTestFor(providerName = VC, port = "8080") public void runTest() { //Mock url RestAssured.baseURI = "http://localhost:8080"; RequestSpecification rq = RestAssured .given() .headers(headers) .when(); Response response5 = rq.body( "{\n" + " \"title\":\"My title 2020-09-15T11:46:52Z\",\n" + " \"startDateTime\":\"2020-09-15T11:46:52Z\",\n" + " \"duration\":30,\n" + " \"provider\":\"ZOOM\",\n" + " \"participants\":[]\n" + "}" ).post(storeMeeting); assert (response5.getStatusCode() == 200); } }```

francislainy.campos
2020-09-15 15:07
This is the most current debugging version.

francislainy.campos
2020-09-15 15:07
I'm commenting out and deleting fields but the structure is this one.

wesleythomaswilliams
2020-09-15 15:08
Although I can't see the problem. I'm wondering if you might get more joy switching to using the Pact matchers, so that you're not comparing json or data values directly.

wesleythomaswilliams
2020-09-15 15:09
Sorry I'm looking at the wrong bit

francislainy.campos
2020-09-15 15:09
I'm using the matchers for the body response, json only on the body params.

francislainy.campos
2020-09-15 15:10
No worries.

wesleythomaswilliams
2020-09-15 15:12
I'm confused by this part: ``` return builder .uponReceiving("A request to store/create a Zoom meeting") .path(storeMeeting) .method("POST") .headers(headers) .body( "{\n" + " \"title\":\"My title 2020-09-15T11:46:52Z\",\n" + " \"startDateTime\":\"2020-09-15T11:46:52Z\",\n" + " \"duration\":30,\n" + " \"provider\":\"ZOOM\",\n" + " \"participants\":[]\n" + "}" ) .willRespondWith() .body(bodyStoreMeetingWithNoParticipants) .toPact();``` You have two body entries

francislainy.campos
2020-09-15 15:13
It's a post call which receives a body with params to trigger the request (json fields) but responds with another body (bodyStoreMeeting), which is the DSL with the matchers.

wesleythomaswilliams
2020-09-15 15:15
Does it treat the two body statements differently, so that it knows one are params are one is the actual body of the post request? I've not had to handle a request like this, our params were query based.

francislainy.campos
2020-09-15 15:16
Yes, because one is part of the `uponReceiving` bit

wesleythomaswilliams
2020-09-15 15:16
Also, I notice there's no .status(XYZ), which may be intentional, but something you may want to be checking.

francislainy.campos
2020-09-15 15:16
And the other comes from the `willRespondWith`

wesleythomaswilliams
2020-09-15 15:17
You're teaching me something here, as I had no idea those two things were treated as parents and could each have body as a child.

francislainy.campos
2020-09-15 15:18
Yeah, learned this recently when the need to test this post api came up.

wesleythomaswilliams
2020-09-15 15:18
Our rest testing is all GET, most of the pact work we've done was messaging based.

francislainy.campos
2020-09-15 15:19
Also, about the status you mean the `given` bit that would connect to a `state`

francislainy.campos
2020-09-15 15:19
Or the status code?

francislainy.campos
2020-09-15 15:19
This is being handled on the assert part.

wesleythomaswilliams
2020-09-15 15:20
Ah yeah, I see, we've used .status(200) in the willRespondWith()

wesleythomaswilliams
2020-09-15 15:21
Just checking our matchers to see if there's something obviously different

francislainy.campos
2020-09-15 15:22
No worries, thanks. I can see my issue is on the date type and I'm looking into it now.

francislainy.campos
2020-09-15 15:22
expected="2020-09-15T16:20:39Z", actual="2020-09-15T11:46:52+0000",

wesleythomaswilliams
2020-09-15 15:22
Things we've done differently for date: ```.datetimeExpression("dateCreated", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")```

francislainy.campos
2020-09-15 15:23
My date is dynamic, so need to create it every day and then I parse it.

wesleythomaswilliams
2020-09-15 15:24
Ok, but it should always adhere to a format right and the actual value isn't important

francislainy.campos
2020-09-15 15:25
Yeah, I'm looking into the correct format. I'm sure I'll find it.

francislainy.campos
2020-09-15 15:26
Just this api is different to the other ones we had so not very consistent and then that's why the tests started to fail.

francislainy.campos
2020-09-15 15:26
At least know it now.

wesleythomaswilliams
2020-09-15 15:26
This is the first time I've looked at a pact test in about four months, so it's been useful to get my brain back in the space. :smile:

khazhak.vahanyan
2020-09-15 15:43
hello again. Is there a way to provide a custom "matching rule". I.e. modifying this directly. From the Java/JS APIs ```{ "body": { "$.key": { "matchers": [ { "match": "type" } ], "combine": "AND" } }```

giuseppe.salvatore
2020-09-15 18:37
Hi all

giuseppe.salvatore
2020-09-15 18:37
has anybody ever done contract testing with apigee as a proxy between providers and consumers?

giuseppe.salvatore
2020-09-15 18:37
I am not sure this scenario makes sense

vidya.garimella
2020-09-15 19:45
has joined #general


matt.fellows
2020-09-15 23:52
I?d be keen to hear. In my previous experience with Apigee, you can?t really unit test it, so that makes pact testing very hard already

matt.fellows
2020-09-15 23:53
Hopefully you?re not using all of the nasty transformation/orchestration stuff it can do - and if that?s the case, you could just ignore the proxy really and go straight to the target

matt.fellows
2020-09-15 23:53
what are you trying to achieve by adding a custom matching rule? as in, what would it do?

abubics
2020-09-15 23:54
Just in case it hasn't come up before . . . on the consumer side, the stdout logs are ok for telling you which tests failed, and usually the diff is ok ish . . . but the stacktrace is more of a side effect than an intentional or helpful debugging tool. There is usually a separate log file that has detailed interactions (e.g. requests and responses), but depending on the version, you may need to manually configure an output location before they're findable.


matt.fellows
2020-09-15 23:58
I see the 2 karma examples are 404, I?ll fix that now

bheemreddy181
2020-09-16 01:39
Do you have any documentation which will explain how openapi provider driven contract testing is used in what all use cases ?



bheemreddy181
2020-09-16 02:12
Looks like I need more reading around this probably a better use case where there several unknown consumers and users outside the org ?

young
2020-09-16 02:18
has joined #general

bheemreddy181
2020-09-16 03:14
@matt.fellows if you are doing any workshop for this please do let me know I am very much interested to understand this more

francislainy.campos
2020-09-16 04:05
Thank you. Is this log file autogenerated or do I create it myself under the resources folder? Would you have a sample for it perhaps?


stanleyawang
2020-09-16 06:10
has joined #general

stanleyawang
2020-09-16 06:22
hi all

stanleyawang
2020-09-16 06:22
I was looking through the documentation and I am trying to incorporate can-i-deploy as a tool for deploying to production ...

stanleyawang
2020-09-16 06:24
from the documentation it seems that we are supposed to deploy new provider version to prod that is compatible with current prod consumer version and new consumer version before deploying new consumer version to prod ...

stanleyawang
2020-09-16 06:24
what about a situation where my new provider version is not compatible with the current prod consumer version ?

tjones
2020-09-16 06:25
deploying this would break the consumers in production

tjones
2020-09-16 06:25
This is the kind of situation that `can-i-deploy` is designed to protect against

bethskurrie
2020-09-16 06:26
pact + can-i-deploy is intended to ensure that you are always backwards compatible with every integration every time you deploy.

stanleyawang
2020-09-16 06:27
thanks for the response ... how should i allow for a situation where i have new provider and new consumer that i want to deploy together where they are compatible with each other but either are not compatible with the old versions in prod ..

bethskurrie
2020-09-16 06:28
that's a coupled deployment that we suggest never doing.

bethskurrie
2020-09-16 06:28
a "distributed monolith"

bethskurrie
2020-09-16 06:29
but if you're going to do it, then turn off can-i-deploy

bethskurrie
2020-09-16 06:29
you won't be able to use it

tjones
2020-09-16 06:29
we recommend having at least one side able to speak to both of the other (eg the new consumer can speak to the old provider and the new provider, or vice versa)

stanleyawang
2020-09-16 06:30
ah ok that's a good tip .... ill bear that in mind ... thanks!

tjones
2020-09-16 06:30
but if you can't do this for practical reasons, then as beth says, disable can-i-deploy. It is designed to protect you from deployments where there might be broken contracts (even if only for the few minutes while you're deploying)

stanleyawang
2020-09-16 06:32
ok i guess that means for the first deployment ... it should be done without can-i-deploy... and only incorporate it in subsequent deployments ..

bethskurrie
2020-09-16 06:32
it's not ideal, but it's the only workable solution for your situation.

bethskurrie
2020-09-16 06:32
gotta be pragmatic!

tjones
2020-09-16 06:32
If appropriate, you might be able to treat it as a new consumer and new provider

stanleyawang
2020-09-16 06:33
ok noted thanks!

tjones
2020-09-16 06:33
because you can deploy a new provider without any currently deployed consumers

tjones
2020-09-16 06:35
can-i-deploy says "can I deploy this against what is in prod", and for the first provider deploy of a new provider, nothing will be in prod, so the answer is yes.

tjones
2020-09-16 06:36
this would only be appropriate if your new providers and new consumers were being stood up next to the existing ones

tjones
2020-09-16 06:36
if your situation is that you'll be replacing the old provider with the new one, then it's not appropriate.

tjones
2020-09-16 06:38
Even then, I still like Beth's pragmatic solution. If you know you are safe to live with a broken contract for the time the deploys take to both complete, then just turn it off.

francisco.moreno
2020-09-16 07:50
has joined #general

francisco.moreno
2020-09-16 07:52
Hi all from Spain!

abubics
2020-09-16 08:01
From memory, they come out in a `logs` directory, but I haven't been near pact on the JVM in a while . . .

abubics
2020-09-16 08:08
I can find an example from a JS consumer . . . the logs ended up in `pact/logs`. Perhaps I misremembered, but I was expecting to see logs like this . . .

francislainy.campos
2020-09-16 08:15
Thank you! Your answer and the docs sent by @matt.fellows worked for me. I have this now. :slightly_smiling_face:

francislainy.campos
2020-09-16 08:15
Super happy!

francislainy.campos
2020-09-16 08:16
```@VerificationReports(value = {"markdown"}, reportDir = "target/pacts/myreports")```

francislainy.campos
2020-09-16 08:16
Adding this line on top of my provider class worked did the trick for me.

francislainy.campos
2020-09-16 08:16
Thank you really very much.

matt.fellows
2020-09-16 08:18
That is really nice, I had no idea it existed!!

matt.fellows
2020-09-16 08:18
I?m going to add that to the examples, because it should be ?by default? I reckon!

francislainy.campos
2020-09-16 08:18
:slightly_smiling_face:

francislainy.campos
2020-09-16 08:19
Yeah, I think will save us soooo much time debugging issues. Game changer it feels.

francislainy.campos
2020-09-16 08:19
Great start for the day. :slightly_smiling_face:

matt.fellows
2020-09-16 08:19
I'm so glad to hear that!

matt.fellows
2020-09-16 08:20
Sorry for the pain, we are working on docs but it's a slow burn

francislainy.campos
2020-09-16 08:21
Not at all. You guys have been always great trying and helping through here and I appreciate the great work you've been doing putting this tool together.

francislainy.campos
2020-09-16 08:21
Well done you all.

giuseppe.salvatore
2020-09-16 08:23
Thanks @matt.fellows that helps. To be honest with you I was of the same opinion as there is no easy way to unit test the apigee proxy (which is kind of annoying on its own)

abubics
2020-09-16 08:31
Glad it's working for you now :confetti_ball: and you can get on with the real work~*:bananadance:

khazhak.vahanyan
2020-09-16 09:27
@matt.fellows I was thinking of hacking the anyArray functionality with `OR` combine rule(not sure if it's even possible). Read some of the code of the API, didn't notice any use of OR at the moment

khazhak.vahanyan
2020-09-16 09:35
but to be honest, I am just messing around at this point :smile:, as I like the project

christopher.lampert
2020-09-16 12:22
has joined #general

matt.fellows
2020-09-16 13:25
Give it a go, see what happens

matt.fellows
2020-09-16 13:25
It might work

matt.fellows
2020-09-16 13:26
Albeit, an "or" matcher is something we've discouraged. It was created for a use case but is generally regarded as unsafe

alvaro.gonzalezc
2020-09-16 14:29
has joined #general

jarmy
2020-09-16 22:07
Hi. Where can I find `http://au.com.dius.pact.consumer.junit.exampleclients.ConsumerClient` from the example here? https://docs.pact.io/implementation_guides/jvm/consumer/junit/ I?ve got `au.com.dius.pact.consumer:junit:4.1.7` defined in my build.gradle but I?m not finding the above class

uglyog
2020-09-16 22:46
That is an example consumer client only, it is not exported in any JAR.



achuljyan
2020-09-17 10:47
has joined #general

mmotornyi.consultant
2020-09-17 11:40
has joined #general

mmotornyi.consultant
2020-09-17 11:42
Does anybody have an example of Koltin + Gradle project with contract tests?

mmotornyi.consultant
2020-09-17 11:45
Ok, I'll ask in JVM channel

saurabhapd
2020-09-17 15:20
has joined #general

saurabhapd
2020-09-17 15:26
Hi All, I am lookin to deploy dockerized pact broker with oauth2 support in my own ec2. I have deployed with basic auth, But now I want to do the same with oauth2 bearer token. I am thinking of using aws cognito. Any idea how to implement that?

chaitasi.patel
2020-09-17 23:05
has joined #general

matt.fellows
2020-09-17 23:29
Answered in #pact-broker

ravi.mijar
2020-09-18 00:59
hello General - https://docs.pact.io/documentation/provider_states.html is giving a 404. I landed on it from https://github.com/pact-foundation/pact-provider-verifier -> Features -> provider states.


matt.fellows
2020-09-18 02:28
thanks

sambitkumar.pal
2020-09-18 05:55
has joined #general

stelios.arakliotis
2020-09-18 10:14
has joined #general

thomas.hibbard
2020-09-18 15:30
has joined #general

sambitkumar.pal
2020-09-19 07:20
Can I trigger a webhook in local without using any CI server? In local provider and consumer contract test working fine. Please suggest.


bethskurrie
2020-09-19 07:21
I'm not sure what you mean by "in local"

bethskurrie
2020-09-19 07:22
If you mean, can you make your Jenkins server trigger a webhook in a Pact Broker instance that is running on your local development machine, then the answer is "not unless you really know what you're doing".

bethskurrie
2020-09-19 07:23
You'd need to make sure your broker IP was accessible to the Jenkins machine, and that the pact broker was mounted on port `0.0.0.0` so that is externally accessable.

sambitkumar.pal
2020-09-19 07:23
Ys local means my development machine where I have pack broker and postgress

bethskurrie
2020-09-19 07:23
However, there are generally a bunch of internal firewalls and security software running that make this difficult.

bethskurrie
2020-09-19 07:24
You need to be very specific when you ask questions to get the most helpful answer.

bethskurrie
2020-09-19 07:24
I was able to guess what you meant, but it is not at all clear from your question what you meant.

sambitkumar.pal
2020-09-19 07:25
Is there any way to verify consumer and provider with webhook without using jekin or CI server?

bethskurrie
2020-09-19 07:25
Yes.

bethskurrie
2020-09-19 07:26
it's just more complex

bethskurrie
2020-09-19 07:26
let me see if I can find the docs

sambitkumar.pal
2020-09-19 07:26
Plz let me know ...I am trying the same


bethskurrie
2020-09-19 07:27
You need to run the provider verification tests from within the consumer pipeline.

bethskurrie
2020-09-19 07:29
consumer pact tests -> publish pact -> provider verification tests -> can-i-deploy -> deploy

bethskurrie
2020-09-19 07:30
It sounds like you're doing a proof of concept. You can always use a free Pactflow account for your experiment, as Jenkins should be able to contact the Pactflow host.

sambitkumar.pal
2020-09-19 07:31
Ys. Doing a POC.

sambitkumar.pal
2020-09-19 07:34
But need in my development machine where I have already pact broker

sambitkumar.pal
2020-09-19 07:38
In this case what should be my URL in request?

bethskurrie
2020-09-19 07:39
In which case, and what URL request?

bethskurrie
2020-09-19 07:39
You need to be very specific with your questions to get a helpful answer.

bethskurrie
2020-09-19 07:41
Can I suggest you do the CI/CD workshop? https://docs.pactflow.io/docs/workshops/ci-cd/

sambitkumar.pal
2020-09-19 07:41
The scenario I am discussing here is " Is there any way to verify consumer and provider with webhook without using jekin or CI server"

bethskurrie
2020-09-19 07:42
You can run the tests from your local machine

bethskurrie
2020-09-19 07:42
but you can't do the webhook part

sambitkumar.pal
2020-09-19 07:43
So I trigger a code snippet from library where provider, event, request , body I passed

matt.fellows
2020-09-19 07:43
Sambit maybe if you can explain what you're trying to achieve? You seem to be focussed on webhooks, but if you explain what you're trying to achieve that would help in answering

matt.fellows
2020-09-19 07:44
Howtolearn

2020-09-19 07:44
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-19 07:44
You might find these workshops helpful for learning the full proxess

sambitkumar.pal
2020-09-19 07:44
I need webhook with pact broker

bethskurrie
2020-09-19 07:46
Please go through one of the workshops and come back to us if you have any more questions after that. I recommend getting a free Pactflow (which is a Pact Broker) account and doing the CI/CD workshop.

sambitkumar.pal
2020-09-19 07:46
I already wrote provider and consumer contract test which is working fine and passes showing in pack broker.. Now I want use webhook

bethskurrie
2020-09-19 07:47
In this step of the workshop I mentioned, it explains how to set up a webhook https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/configure-webhook/

bethskurrie
2020-09-19 07:48
In the instructions, Travis is similar to Jenkins

sambitkumar.pal
2020-09-19 07:49
Ok. Let me check the workshops.

sambitkumar.pal
2020-09-19 07:56
One doubt... Can I use webhook in Codefresh ?

sambitkumar.pal
2020-09-19 07:58
As u suggested jenkin, Travis... Can I use pact broker webhook in CodeFresh?

sambitkumar.pal
2020-09-19 08:21
How to configure webhook in Codefresh?

matt.fellows
2020-09-19 08:28
I don't know code fresh that well, you'd have to see if code fresh has an API. If it does then yes

sambitkumar.pal
2020-09-19 08:46
Yes..codefresh has API to integrate other applications

matt.fellows
2020-09-19 08:56
I haven't seen any code fresh examples, you'll have to find an example from another ci and adapt to codefresh's API

sambitkumar.pal
2020-09-20 05:03
How to integrate webhook with codeFresh?

sambitkumar.pal
2020-09-20 05:04
Is there any plugin to add or any other process ?

matt.fellows
2020-09-20 05:07
We already answered this yesterday. There is no plugin or native integration I'm sorry

matt.fellows
2020-09-20 05:08
The webhook is just an http request. find out what http request needs to be sent to codefresh to trigger a build and that's what goes into your webhook

matt.fellows
2020-09-20 05:14
See also howtoask

2020-09-20 05:14
Please see this page for some tips on how to ask for help to get the best response from the community https://docs.pact.io/help/how_to_ask_for_help

bethskurrie
2020-09-20 07:33
I've created an example consumer that uses a "webhookless pipeline". It does this by checking out the provider codebase and running the verifications as part of the provider build. This can be handy if you are unable to use webhooks because of firewalls. https://github.com/pactflow/example-consumer-webhookless

bethskurrie
2020-09-20 07:33
@antonello perhaps you could give us some background on why this flow was preferable for your teams?

amicicristiano
2020-09-20 14:16
has joined #general

bethskurrie
2020-09-20 20:41
Ugh, that was supposed to be "as part of the consumer build" :man-facepalming:

antonello
2020-09-20 20:54
Just seems this. I?ll reply tomorrow :)

christiaan
2020-09-21 08:42
has joined #general

antonello
2020-09-21 11:34
The main driver for us was that we wanted to have a way to get fast feedback and completely prevent a consumer team from breaking the pipelines of the providers by publishing a pact that would lead to provider tests failing. Our approach at the moment is very similar to what @bethskurrie has outlined: ? Consumer publishes pact to the pact broker in its pipeline ? We find that latest `master` and `prod` tagged versions of the providers ? We check if the the new pact is already pre-verified by those versions ? If it?s not pre-verified, we clone the providers and checkout the commit pointing to latest `master` and/or `prod` tagged provider versions. ? We run the required provider tests against the published pact We also do a cross branch verification based on convention, i.e. if there is a provider branch that matches the feature branch of the consumer, we run the provider verification tests for the matching provider branch. We do this both for consumers that are built in GitlabCI (using their multi-project triggers) and in Jenkins. I realise that some of these things could be achieved with a mix of using webhooks and other CI hooks + the new Pending Pacts and WIP Pact functionalities. However, we?ve found the management of webhooks a bit cumbersome. Moreover, being able to see failing provider tests in the consumer?s pipeline has led to an increase in collaboration between consumer and provider developers and a better awareness of how to handle sequencing of merges to master and releases to production. The end game - if we get there - is to let providers publish small test artifacts that consumers can use to run the the provider tests without having to clone, checkout and compile.

christopher.lampert
2020-09-21 11:35
Hi all, I am working on a team who are a provider and we are looking at setting up a webhook to trigger a verification when the content of contracts change. Based on the documentation I know this verification should sit outside the teams usual build pipeline as a task to verify the specific contract. The question I have is, what version of the provider should I be verifying this contract against? The reason I ask is because the we (the provider team) are doing mainline development so sometimes the code in our master branch might be ahead of what is for example in our production environment and therefore verifying against non-production code could lead to giving the consumer team false confidence that their changes are compatible with what is in production with any verifications we do. The documentation (at least from what I can tell) doesnt give any clear guidance as to what version I should be verifying against at this point

antonello
2020-09-21 11:54
Something that I would like to add is around this point you made in the readme, @bethskurrie > The downside of this flow is that it requires the consumer to have access to the provider code, and understand how to execute the tests. In our case, we have addressed this issue by creating a generic script that all providers need to implement. The script invokes `describe-version` and `can-i-deploy` , does the clone and checkout, and runs the require `maven command`. The script takes some environment variables like `CONSUMER_TAGS`, `PROVIDER_TAG` , etc. Now, the beauty is that the core logic is in a shared, published script, so the individual providers just ned to import it and implement a very lightweight wrapper.

matt.fellows
2020-09-21 14:28
I normally run it against the master branch of my code because if you're doing CD it almost always == production. if you're advanced enough and there is a delay, you could run against the prod version also

matt.fellows
2020-09-21 14:30
You want the webhook to give you confidence to merge your consumer code into mainline at which point you'll eventually run a can-i-deploy check to deploy to prod. So whatever the mainline is of the provider is a good start

christopher.lampert
2020-09-21 14:31
Yeah, so there is a delay, which was was my concern but yes production version was my thought process too. Appreciate the guidance, sounds obvious but people like to be sure this is the best practice so wanted to reach out to the community.

christopher.lampert
2020-09-21 14:32
Thanks for getting back to me! :slightly_smiling_face:.

ctelles
2020-09-21 18:59
has joined #general

brian.jin
2020-09-21 19:31
has joined #general

richardwb
2020-09-21 20:06
has joined #general

bethskurrie
2020-09-21 22:08
@christopher.lampert you can read the docs about that situation here: https://docs.pact.io/pact_nirvana/step_8

abubics
2020-09-21 23:55
:taco: for @matt.fellows

abubics
2020-09-21 23:55
and :taco: for @bethskurrie

abubics
2020-09-21 23:56
for just always being there :innocent:

kflo
2020-09-22 01:08
has joined #general

aaron.ramirez
2020-09-22 03:35
has joined #general

antonello
2020-09-22 06:19
@bethskurrie Any reason why in your example you?re only verifying against provider master?

matt.fellows
2020-09-22 07:03
I like the idea of a _contract_ for a build. It?s one of the main reasons why having a consistent interface to executing a CI pipeline is so powerful, and why Docker is so bloody useful

antonello
2020-09-22 07:26
Would a blog post on this be useful? I keep promising myself that I would like to write some blog posts, but then never do... this could be the first one in ages...

matt.fellows
2020-09-22 07:40
I think so

matt.fellows
2020-09-22 07:41
I mean, it would be great

matt.fellows
2020-09-22 07:41
I?ve been thinking of creating a ?recipes? page on our docs for a while, I think this would be a good example recipe

ajayarooon
2020-09-22 07:54
has joined #general

christopher.lampert
2020-09-22 08:50
Thank you both! :smile:

christiaan
2020-09-22 11:58
Hi all, newbie here, still in the grasping the concepts phase. I have a question about "provider states" after reading this page: https://docs.pact.io/implementation_guides/ruby/provider_states/. That page suggests that I should in the "setup phase" on provider side "create a thing here" using a framework of choice and I quote (" # eg. Sequel.sqlite[:somethings].insert(name: "A small something")" Do I understand that it is expected of me to inject data directly in the actual backend where my provider api is connecting to? If this is indeed the case how do I know that this backend is not being "updated/changed" by another test at the same time? Does this not defeat the idea to run tests in isolation? Do I understand correctly that I have to take measures to make sure that the provider pact test currently run is the only one running at the moment against the backend?

2020-09-22 14:19
A new post has been created in *Feature Requests*

jan.krejci
2020-09-22 14:21
Hi guys, I have been struggling to get more and more adopter for using PACT because we really see a cost benefit by using it. However, there is certain scenarios as *External integrations* (Providers) that it ends up to be a challenging because of all considerations described https://docs.pact.io/getting_started/what_is_pact_good_for/#what-is-it-not-good-for . So, my question is more to understand how you guys are solving this issue mostly. Like using VCR, mock server or even using Pact itself.

skarki
2020-09-22 14:48
has joined #general

tyler.mehr
2020-09-22 16:56
has joined #general

tyler.mehr
2020-09-22 18:21
Hello, I'm getting the following error on Windows 10. There doesn't seem to be any other log info for this. I have attempted to fix it by shortening the path, but it did not fix the issue: [2020-09-22T17:03:19.295Z] INFO: pact-node@10.10.1/13152 on <computer_name>:     Creating Pact Server with options:     {"consumer":"MobileApp","cors":false,"dir":"C:\\app_dir\\app_proj\\app\\pacts","host":"localhost","log":"C:\\<app_dir>\\app_proj\\app\\logs\\pact.log","pactFileWriteMode":"overwrite","provider":"AppProvider","spec":2,"ssl":false} [2020-09-22T17:03:19.317Z] INFO: pact-node@10.10.1/13152 on <computer_name>: Publishing Pacts to Broker [2020-09-22T17:03:19.317Z] INFO: pact-node@10.10.1/13152 on <computer_name>: Publishing pacts to broker at: http://localhost:8500 [2020-09-22T17:03:25.263Z] WARN: pact-node@10.10.1/13152 on <computer_name>: Pact exited with code 1. [2020-09-22T17:03:25.264Z] ERROR: pact-node@10.10.1/13152 on <computer_name>:     Could not publish pact:    PactBroker::Client::Error - No pact files found     [2020-09-22T17:03:26.262Z] INFO: pact-node@10.10.1/13152 on <computer_name>: Pact running on port 64710   Error: Couldn't start Pact with PID: 4320      at Timeout._onTimeout (C:\app_dir\app_proj\app\node_modules\q\q.js:1846:21)    at listOnTimeout (internal/timers.js:551:17)    at processTimers (internal/timers.js:494:7) Error: Couldn't start Pact with PID: 4320      at Timeout._onTimeout (C:\app_dir\app_proj\app\node_modules\q\q.js:1846:21)    at listOnTimeout (internal/timers.js:551:17)    at processTimers (internal/timers.js:494:7)

francislainy.campos
2020-09-22 18:22
Hi, I think ideally you'd have control of your data, with your own pact users or something like this so that other tests wouldn't affect the response you're getting. You could also do some clean up wiping out data that you don't need before the pact test is executed.

matt.fellows
2020-09-23 01:47
:wave: looks like you?re using #pact-js ? Maybe jump in there to see

matt.fellows
2020-09-23 01:47
Are you trying to publish a pact or run a consumer test?

matt.fellows
2020-09-23 01:47
Are there files in the pact dir?

aforeman
2020-09-23 05:01
:wave: Hi *Got a spare 15 minutes :watch: to complete a survey about Pact?  If you need a little sweetener :lollipop: read on!* Alicia here, Pactflow?s new Product Marketing Manager :woman-raising-hand: to ask you to complete a max 15 minute survey to share how you use Pact and the difference it has made to how you test and deploy. In return, you can score a *free lifetime upgrade of users and contracts on all Pactflow plans* :ok_hand: I?m also able to disclose that there?s a Pact Community Day in the works  :tada: and that the survey will also capture feedback about what you want to hear and from who! See more about the Pactflow lifetime upgrade and complete the survey here: https://forms.gle/xXmwf4SpAVPTKAtB7  The survey closes midnight Sunday 4 October AEST. Thank you in advance!

florian.nagel
2020-09-23 06:16
The survey had a good flow to it! Good job @aforeman Here's a taco :taco:

aforeman
2020-09-23 06:18
Thanks for the feedback @florian845! Looking forward to reading your responses :smile: I appreciate the taco, thanks :raised_hands:

jeanlucc
2020-09-23 06:22
Personally I run dedicated fixtures for this state, the instance on which tests run is a dedicated docker so there are no other interactions and I run the ?whole? HTTP request in a DB transaction that is rolledback between requests so that tests do not influence each other?s. I borrowed the idea and code for transaction to my integration tests. Since it?s a PHP backend I use the dama doctrine test bundle https://packagist.org/packages/dama/doctrine-test-bundle I?m not sure if what I describe here is a good solution though.

yann.courtel
2020-09-23 07:05
has joined #general

de_breno
2020-09-23 07:52
has joined #general

a.smith
2020-09-23 08:42
Welcome @aforeman! :wave:

alexle
2020-09-23 10:59
has joined #general

matt.fellows
2020-09-23 11:34
@christiaan just in case it?s not clear in the docs, provider states are to deal with the situation where you might normally first perform a series of setup actions in order to actually run your test. Classic example: Getting a user. In an end-to-end integrated test you?d do this: 1. Post to `POST /users {?}` and get a `20x` 2. The run `GET /users/1` and expect a `200` We don?t like these kinds of tests, because the _consumer_ is trying to set things up. But if user 1 already exists and you ran step (1), it would cause a failure in your test run. So now you put a gaurd in to protect that situation. But what if the data doesn?t match? This is the whole mess of integrated tests. Your integrated test suite becomes as complex as your actual app. Pact does it this way: 1. Consumer writes a test, and put?s an annotation against it stating its expectations for the provider to be able to run the test e.g. `where user ID 1 exists` . This is the ?provider state? 2. Consumer writes a test for the `GET /users/1` endpoint with its own local mock data and it should always pass, because it?s a unit test Later on, when the provider test runs: 1. Pact will see the state annotation and pass it to the provider test to say ?please get yourself into a state such that you can respond with user id 1`. This is where you would either a) dynamically setup the state or b) use a pre-canned fixture known to support all states 2. Pact runs the `GET /user/1` against the provider Everyone is happy, because you didn?t need to manage an end-to-end test environment to do it

aforeman
2020-09-23 11:51
Thanks @a.smith :slightly_smiling_face:

adrianojedabenitez
2020-09-23 12:47
has joined #general

begovic.malik
2020-09-23 13:03
has joined #general

joel.whalen
2020-09-23 14:01
some feedback: The definition of ?Before pact? and ?after pact? isn?t very clear. Like we have been working on pact for months now, but haven?t seen a difference in how we work yet due to the whole process taking a long time to implement

sambitkumar.pal
2020-09-23 16:32
Hi, I have triggered webhook which is building the provider contract and build is successful. Pact contract passed but the webhook is going on retrying. When I checked webhook error log, its showing " *Error executing webhook Xw_2o3EfCQ5BSbB4wfs3uQ Net::ReadTimeout -Net : : ReadTimeout with #<TCPSocket:(closed)>* Please let me know on this. It will really helpful if someone help me on this. Thanks in advance.

phillip.lo
2020-09-23 16:39
Hey, not sure if anyone else came across this issue when trying to run the broker locally without docker but I was getting errors trying to install thin ```Building native extensions. This could take a while... ERROR: Error installing thin: ERROR: Failed to build gem native extension.``` Apparently this is a known issue https://github.com/macournoyer/thin/issues/370 This worked ```gem install thin -- --with-cflags="-Wno-error=implicit-function-declaration"``` Not sure if its worth adding to the docs but just thought I'd give people a heads up Edit: realized I should have posted this in the pact-broker channel but I can't delete messages here so I'll just leave it to the pact team to decide what to do :grinning:

phil.endsley
2020-09-23 16:42
The error seems pretty self explanatory. Looks like your webhook is timing out when trying to execute

sambitkumar.pal
2020-09-23 17:29
Ys. That is clear. But that is coming because Failed to open TCP connection to host url.. That I found now. Can you please let me know what should be host URL when pact broker is running through docker compose file. And I am triggering from local system.

phil.endsley
2020-09-23 17:32
Is this a webhook defined in pact broker? Or a webhook in a CI pipeline?

sambitkumar.pal
2020-09-23 17:34
Webhook defined in pact broker

phil.endsley
2020-09-23 17:42
Is the thing your webhook is calling also running on your local machine?

phil.endsley
2020-09-23 17:44
And if so, are you using localhost for the webhook definition? Trying to understand what the actual problem is, since none of those details are provided

sambitkumar.pal
2020-09-23 17:49
Ys locally I have a small rest controller application which will trigger provider build when webhook will trigger. The request URL is working to call that application and provider build successful with respect to the consumer. Contract pass I can see in Last verify column of pact broker. Then webhook status is going on retrying.

phil.endsley
2020-09-23 17:55
Just to re-iterate, this is not a pact issue. This is a common thing to be aware of when using containers. If you reference localhost within a container (which is what you're doing since pact broker is running in a container), that's referring to the container itself. You need to point to your machine's ip address instead if everything is running locally. 127.0.0.1 will _probably_ work (So if your webhook is http://localhost:8080/some/url, try http://127.0.0.1:8080/some/url). If not, I would suggest reading up on docker containers and networking with them, and reaching out to a docker community if you're still looking for help.

sambitkumar.pal
2020-09-23 18:02
If you will see the log I gave its not local host. Its to pass through the docker. And its passing and running the build for provider. But again same URL is failing. My question is , if its allowing in webhook request URL to trigger the build then why after successful build its failing. Plz let know.

christiaan
2020-09-23 18:06
First, thanks all for your clarification and suggestions. This is becoming much clearer now.

sambitkumar.pal
2020-09-23 18:20
My webhook request which is working fine with the given url and making provider build successful . post build webhook is showing same URL as issue.

phil.endsley
2020-09-23 18:29
> If you will see the log I gave its not local host. My mistake...I saw the webhook context base url Your contract_content_changed webhook is using the same url? Is it correctly triggering a build, and the webhook status shows failed?

phil.endsley
2020-09-23 18:39
> My question is , if its allowing in webhook request URL to trigger the build then why after successful build its failing. Sorry, I think there's a slight language barrier :slightly_smiling_face: Your webhook is running, and triggering a build as you would expect, but it shows as failed. Is that correct?

phil.endsley
2020-09-23 19:16
If this is the case, I would guess that the service you're calling in your webhook is taking longer than the timeout

adrianojedabenitez
2020-09-23 19:29
hey guys, thanks a lot in advance :grimacing: Sorry to bother you, but not finding any documentation about this. I have created a POC with gitlab, Java (spring) as provider and a pact-js consumer. I?m triggering a webhook when the contract changes (as per ci/cd workshop) but I?m facing with the next issue. Let?s say backend side has 7 different classes in charge of verification tests. If I configure the webhook to be triggered when, i.e ?dogs? pact changes, considering I?m using junit it makes sense that the webhook call a job that runs `mvn test` command. The issue is, since I already have the pact url, I want to run *only* on the class that contains the ?dogs? states, but mvn clean test will run all the contracts and will fail with the contracts states that don?t match with the pact url. What I?m doing now is parsing the pact url to retrieve the provider name, , i.e dogs_service_provider, I get the dogs name and same to retrieve the consumer. I do something like this `mvn -Dpactbroker.enablePending=true -Dpact.verifier.publishResults=true -Dpact.filter.pacturl=$CONTRACT_URL -Dpact.filter.consumers=$CONSUMER -Pcicdprofile -Dtest=?$CLASS_NAME*ContractVerificationTest? -DfailIfNoTests=false clean test` but is making me noise, is there a better way to handle the scenario described above? this tool looks promising for my company!

antonello
2020-09-23 20:08
Hi Adrian. Just to clarify. Is this one consumer / one provider? What is ?dogs? in this case?

adrianojedabenitez
2020-09-23 20:24
yup, one consumer and one provider, I used dog just as example. The provider name could be dogs_service_provider and the consumer dogs_consumer. I have the pact url but when I run mvn test will run CatsContractTest, RabbitContractTest and so on, I would like to run only DogsContractTest class since that is the class with the states and the pact between dogs_service_provider and dogs_consumer

antonello
2020-09-23 20:27
But you have only one provider and one consumer you said.

adrianojedabenitez
2020-09-23 20:44
no no sorry, I didn?t get it, what I wanted to say is that I want to handle only one provider and one consumer (the provider that was triggered by the web-hook) but on the backend for sure I have multiple providers and all of them are being executed when I call ?mvn test? and that is what I want to avoid

adrianojedabenitez
2020-09-23 20:45
in fact I need to avoid it because I?m getting errors when the others providers are executed

antonello
2020-09-23 20:48
So you have one big Java application with multiple providers. Correct?

adrianojedabenitez
2020-09-23 20:48
exactly!

antonello
2020-09-23 20:49
Do the different providers live inside the same module or different modules?

adrianojedabenitez
2020-09-23 20:50
same module, in fact same folder but each provider has a different business rules.

antonello
2020-09-23 20:51
Are you sure you want different providers? It sounds like it should be one provider. It?s the same service.

adrianojedabenitez
2020-09-23 20:53
do you think is a good practice have only one provider for everything? I spitted in different classes because they handle different business rules and I don?t want to mix it the class will grow a lot

antonello
2020-09-23 20:56
I can?t say without understanding the details, but I think you might be making things difficult for yourself by introducing multiple providers for what seems to be just one service.

adrianojedabenitez
2020-09-23 20:57
I see, but do you have some example link or doc to see how multiple providers should work?

antonello
2020-09-23 20:59
Anyway, that said, imho you have two routes: ? the one you identified already ? use a test filter based on some kind of naming convention

antonello
2020-09-23 21:00
I don?t think you?d find examples, as I don?t think that?s how it?s meant to be used.

adrianojedabenitez
2020-09-23 21:02
I see, thanks a lot for your time! really appreciate it!

antonello
2020-09-23 21:05
My pleasure!

phil.endsley
2020-09-23 21:55
If you need to stick with that structure, maybe custom maven targets (goals? I know maven has its own word for it) that do the filtering for you? Then configure your webhook to call the appropriate target.

mbbush
2020-09-23 22:16
has joined #general

adrianojedabenitez
2020-09-23 22:56
wow! to be honest I haven?t used this before, but will take a look, awesome tip @phil.endsley thanks a lot!!


adrianojedabenitez
2020-09-23 23:01
for some reason I was using https://docs.pact.io/implementation_guides/jvm/provider/junit5spring but will take a look it! :man_dancing:

uglyog
2020-09-23 23:03
Oh, with Junit. Let me check. I think it should still work, but might need an annotation


uglyog
2020-09-23 23:05
I think that will also work with JUnit 5. Let me know if it doesn't

matt.fellows
2020-09-23 23:56
:taco: for @uglyog

matt.fellows
2020-09-23 23:56
:taco: for @phil.endsley

aforeman
2020-09-24 00:24
Good feedback, thanks @joel.whalen - for the purpose of the survey, if you are yet to see changes, you can log the same response to before and after Pact - in the final 'anything else' question at the end of the 'with Pact' section, you can make note of the time to see results. Hope this helps.

wilkinsweiqiangliang
2020-09-24 01:12
has joined #general

wilkinsweiqiangliang
2020-09-24 01:13
Hey guys, does pact work with javascript consumer and java provider? I had experienced body mismatch issue

wilkinsweiqiangliang
2020-09-24 01:17
``` 1.1) BodyMismatch: $.data.0.id BodyMismatch: Type mismatch: Expected Map {"json_class":"Pact::SomethingLike","contents":"da16494a-303a-463c-919a-e29e03a5b1de"} but received String 'c6ef2915-75e8-4570-81be-cb45684eefb6' -{ - "json_class": "Pact::SomethingLike", - "contents": "da16494a-303a-463c-919a-e29e03a5b1de" -} +"c6ef2915-75e8-4570-81be-cb45684eefb6"```

uglyog
2020-09-24 01:26
`"json_class":"Pact::SomethingLike"` means your pact file is not correct. This is an issue with your consumer test.

wilkinsweiqiangliang
2020-09-24 01:27
um? i follow the documentation. let me share my test

uglyog
2020-09-24 01:27
@matt.fellows how does the Ruby matchers get resolved? They shouldn't be in the body

wilkinsweiqiangliang
2020-09-24 01:28
```describe("getting all products", () => { test("products exists", async () => { // set up Pact interactions await provider.addInteraction({ state: 'products exist', uponReceiving: 'get all products', withRequest: { method: 'GET', path: '/v1/products' }, willRespondWith: { status: 200, headers: { 'Content-Type': 'application/vnd.api+json' }, body: { data: eachLike({ id: like("da16494a-303a-463c-919a-e29e03a5b1de"), type: "product", ... }```

wilkinsweiqiangliang
2020-09-24 01:28
```import {Pact, Matchers} from "@pact-foundation/pact"; const { like, eachLike, integer, regex,string, boolean, rfc3339Timestamp } = Matchers```

matt.fellows
2020-09-24 01:28
can you please share the generated pact file?

wilkinsweiqiangliang
2020-09-24 01:28
sure

matt.fellows
2020-09-24 01:29
> @matt.fellows how does the Ruby matchers get resolved? They shouldn?t be in the body Ruby magic?

wilkinsweiqiangliang
2020-09-24 01:31
```{ "consumer": { "name": "TeamView" }, "provider": { "name": "ProductAPI" }, "interactions": [ { "description": "get all products", "providerState": "products exist", "request": { "method": "GET", "path": "/v1/products" }, "response": { "status": 200, "headers": { "Content-Type": "application/vnd.api+json" }, "body": { "data": { "json_class": "Pact::ArrayLike", "contents": { "id": { "json_class": "Pact::SomethingLike", "contents": "da16494a-303a-463c-919a-e29e03a5b1de" }, "type": "product" }, "min": 1 }, "meta": { "totalResourceCount": { "json_class": "Pact::SomethingLike", "contents": 0 } } } } }, { "description": "get all products", "providerState": "no products exist", "request": { "method": "GET", "path": "/v1/products" }, "response": { "status": 200, "headers": { "Content-Type": "application/vnd.api+json" }, "body": { "data": [ ], "meta": { "totalResourceCount": 0 } } } } ], "metadata": { "pactSpecification": { "version": "1.0.0" } } }```

matt.fellows
2020-09-24 01:32
Yeah that?s definitely wrong.

matt.fellows
2020-09-24 01:32
What version of pact are you on?

matt.fellows
2020-09-24 01:32
Looks like the spec is set to `1.0.0` . that?s probably a mistake

matt.fellows
2020-09-24 01:32
We have to use Ruby class-like structures to send to the mock service which generates the pact file. I?ve seen this before, but on very old versions of the library

wilkinsweiqiangliang
2020-09-24 01:32
``` "dependencies": { "@pact-foundation/pact": "^9.12.0",```

matt.fellows
2020-09-24 01:33
ok so that?s fairly new

matt.fellows
2020-09-24 01:33
what does your `Pact(..)` constructor look like?

matt.fellows
2020-09-24 01:33
just check that the specification is set to `2` or just omit it altogether

wilkinsweiqiangliang
2020-09-24 01:33
in java side is 4.1.2 ``` testCompile "au.com.dius.pact.provider:junit5:$pactVersion" testCompile "au.com.dius.pact.provider:spring:$pactVersion" testCompile "au.com.dius.pact.provider:junit5spring:$pactVersion"```

matt.fellows
2020-09-24 01:33
thx

matt.fellows
2020-09-24 01:33
this looks like a JS side issue, JVM is confused by the bad pact

wilkinsweiqiangliang
2020-09-24 01:34
ah from the constructor i set the spec to `1`

wilkinsweiqiangliang
2020-09-24 01:34
```const provider = new Pact({ consumer: 'TeamView', provider: 'ProductAPI', log: path.resolve(process.cwd(), 'logs', 'pact.log'), logLevel: "warn", dir: path.resolve(process.cwd(), 'pacts'), spec: 1 });```

wilkinsweiqiangliang
2020-09-24 01:34
which was 2 before

matt.fellows
2020-09-24 01:34
why did you do that?

wilkinsweiqiangliang
2020-09-24 01:36
i didnt find the definition from pact docs. playing around to see the difference

matt.fellows
2020-09-24 01:36
ah ok. For now, set it back to 2 and see where that gets you.

matt.fellows
2020-09-24 01:37
We may need to deprecate / prevent that from actually being set - because 1 clearly isn?t creating valid pacts (and to be honest, all pact libraries support 2+ anyway)

wilkinsweiqiangliang
2020-09-24 01:38
good to know

uglyog
2020-09-24 01:39
Now you know what version 1 does :smile:

wilkinsweiqiangliang
2020-09-24 01:42
yea now i know. Thanks. pact file looks more promising now.

sambitkumar.pal
2020-09-24 01:47
Sorry. The service is running successful. I mention in the log that its timeout bcz failed to open TCP the URL I passed in webhook. That is confusion. Where same URL hit I'd working and then post success the same URL timeout. Can you please let me know what its trying after provider successful build.

matt.fellows
2020-09-24 01:48
The error looks really clear to me. From the pact broker instance, it cannot open a connection to that host

matt.fellows
2020-09-24 01:49
shell into the docker container, and see if you can run something like a `telnet host.docker.internal 8080`

matt.fellows
2020-09-24 01:49
or even just do `host host.docker.internal`to see if it can resolve the domain

sambitkumar.pal
2020-09-24 01:52
Yes u r correct. But its triggering the build with same URL. How that is happening is a surprise for me.

sambitkumar.pal
2020-09-24 01:54
After provider build successful its showing contract passed and webhook status retrying (again triggering build)

francis.lobo
2020-09-24 01:55
Hello folks, I have a newbie question. I am puling the pact-broker docker image from https://hub.docker.com/r/dius/pact-broker/ looks like it does not have the latest PR. I specifically need this change : https://github.com/pact-foundation/pact_broker/pull/344 Do I need to build my own docker image to get this? or need to wait for someone to update the image on docker hub?

bethskurrie
2020-09-24 01:56
We recommend using the pact-foundation one @francis.lobo

francis.lobo
2020-09-24 01:58
Thanks for the reply @bethskurrie I double checked my configs. I am indeed pulling it from pactfoundation/pact-broker

bethskurrie
2020-09-24 01:58
Note that the base URL does not change where it's actually mounted within the container



bethskurrie
2020-09-24 02:00
But like I said, it won't change where it's mounted within the container. It's used when you mount the container at a particular URL externally.


francis.lobo
2020-09-24 02:10
ah! sorry I mixed up the commit I was looking for. I was looking for a docker image with this commit https://github.com/pact-foundation/pact_broker/commit/ecbac9a688e90b7385f1376b901951c2719baff8 will a `docker pull pactfoundation/pact-broker` get me a container with this change?

bethskurrie
2020-09-24 02:11
nope, I'm about to release it.

bethskurrie
2020-09-24 02:11
give me a minute

francis.lobo
2020-09-24 02:11
awesome thanks for that :thumbsup:

sambitkumar.pal
2020-09-24 02:37
One more update on this .after my webhook trigger the provider build, if build fail then webhook status is coming as success . but if provider build is scuess then webhook status retry where its failing to connect and timeout in log.

matt.fellows
2020-09-24 02:40
the webhook status has nothing to do with the build passing or failing - it is simply ?did the webhook get a success response from the target?. It?s obviously getting a `2xx` status when it triggers a build.

phil.endsley
2020-09-24 02:44
Does the service your webhook calls wait until the build finishes to return the status? If so, how long do your builds take? It still sounds like a timeout issue...but I think this is as far as I can help troubleshoot... If the webhook calls a "start the build and return immediately", I don't have any more suggestions

sambitkumar.pal
2020-09-24 02:47
Ys.. Webhook calls the service and wait until build return status. Build took 01.37 min. If build fails also same time.

matt.fellows
2020-09-24 02:48
ok so that makes sense

matt.fellows
2020-09-24 02:48
when the webhook executed correctly, the build finished in time.

matt.fellows
2020-09-24 02:48
when the webhook failed, the build is still running and maybe it passed

matt.fellows
2020-09-24 02:49
the red build probably didn?t take as long, because it didn?t get all of the way through

matt.fellows
2020-09-24 02:49
I would highly recommend not having the webhook ?wait?. That?s not what they?re for, really

matt.fellows
2020-09-24 02:49
verification results should be sent back to the broker from your build - that?s how you communicate a break in the contract. Not vvia a webhook

phil.endsley
2020-09-24 02:49
Right. The verification results are still published back to the broker, because that happens during the provider build process, and is not dependent on the actual webhook. Which is why you see one succeed and the other fail

matt.fellows
2020-09-24 02:50
good pickup Phil

sambitkumar.pal
2020-09-24 02:50
Fail build and success build nearly same time . that I saw now.

sambitkumar.pal
2020-09-24 02:52
We are sending back status 200

sambitkumar.pal
2020-09-24 02:53
Contract is passing between provider and consumer.

phil.endsley
2020-09-24 02:53
If you're exceeding the read timeout, it doesn't matter what the service sends back. The client will just cut the connection

sambitkumar.pal
2020-09-24 02:54
Anyway to increase the timeout.. Plz let me know

phil.endsley
2020-09-24 02:54
The contract verification results should be published back to pact broker as part of the provider build. It's not publishing the verifications from the webhook, it's doing it from the build. At least, it should be

sambitkumar.pal
2020-09-24 02:56
Ys.. Its send back the verification status due to that contract is pass showing in pact broker.

sambitkumar.pal
2020-09-24 02:58
Can u plz let me know any specific way contract verification need to send back..just a doubt if verification I am sending in wrong way.

phil.endsley
2020-09-24 03:04
I'm pretty sure it depends on what language you're using for your provider. The provider implementation should have documentation on how to do it I'm fairly certain you're doing it right though. If you're running a build, and your contract is updated to show as verified, it's working. That is not happening because of the webhook (directly). The webhook is just making some http call. The response code the webhook gets back will only impact the status of the webhook itself.

phil.endsley
2020-09-24 03:06
Your webhook kicks off a build, which runs a provider build and asynchronously sends that verification result back. Like Matt was saying, ideally, your webhook just invokes a call to start the build and immediately returns. It shouldn't have to wait until the build completes

phil.endsley
2020-09-24 03:06
The build will continue to run, and publish the results on completion

sambitkumar.pal
2020-09-24 03:13
OK.. So as I understood.. Immediately webhook needs a response back..so that it will success ...and it mean time let the provider build run to make the contract pass. There is nothing with build success or failure for webhook. Am I right? Plz correct me if I am wrong.

phil.endsley
2020-09-24 03:13
You got it

sambitkumar.pal
2020-09-24 03:15
Thank u. But please let me know how I will return back immediately to webhook. I am using java code for provider build.

phil.endsley
2020-09-24 03:18
What is the service you're calling now? Did you write it, or is it a build server? Do you just mean the provider is written in java, or you're starting the provider build from a java application?

sambitkumar.pal
2020-09-24 03:20
Ys I wrote a java code to call the build . maven command running to trigger the build. Which I am calling from java code.

sambitkumar.pal
2020-09-24 03:20
Provider is a separate java file for contract verification.

phil.endsley
2020-09-24 03:22
Use an ExecutorService or something similar to start the build in a new thread so it runs asynchronously

sambitkumar.pal
2020-09-24 03:23
Please look into the code I wrote for build.

sambitkumar.pal
2020-09-24 03:24
And its running separately.

sambitkumar.pal
2020-09-24 03:26
So in this class , what need to send back to webhook so that it will success ..plz let me kow

phil.endsley
2020-09-24 03:33
I'm actually heading off to bed, but these are easily searchable problems. Just lookup how to run something asynchronously in java, and do that for what you have. Just return after that, and it will send a 200 back

phil.endsley
2020-09-24 03:33
I don't want to sound too harsh, but after spending a lot of effort helping you, this kind of comes across as you just wanting someone else to do it for you. I think there's enough info here to figure the next part out

sambitkumar.pal
2020-09-24 03:35
Apologies. I will try. Thank you very much .

matt.fellows
2020-09-24 03:35
thanks for your help Phil

matt.fellows
2020-09-24 03:35
I think you?ve got it from here Sambit

matt.fellows
2020-09-24 03:36
also just check if you can?t call your build system directly rather than have a custom API you?re building. Most CI systems have an API you can call

sambitkumar.pal
2020-09-24 03:37
I am doing the POC in local system to call a build via rest controller.

sambitkumar.pal
2020-09-24 03:39
Thank you Phil and Matt.. Appreciate your help on this. I will try to find out something to return to webhook .

wilkinsweiqiangliang
2020-09-24 03:44
Hey guys, and example for testing kafka application? doesnt seems to have one in java repo


matt.fellows
2020-09-24 03:44
see how that goes (there should be a consnumer one there somewhere too)

2020-09-24 05:18
A new post has been created in *Feature Requests*

artur
2020-09-24 05:53
has joined #general

aforeman
2020-09-24 05:58
** BTW - account upgrades will be actioned within one week of survey completion - we will email you once it's done :sunglasses: **

wilkinsweiqiangliang
2020-09-24 06:29
I had check both `java-kafka` and `js-kafka` for consumer part. Doesnt seems to be any pact file that generated by consumer? https://github.com/pactflow/example-consumer-js-kafka

artur
2020-09-24 06:32
Is there a way to create an interaction that only matches when a header DOES NOT exist? in my case I want to have 3 interactions: ? auth header set and correct ? auth header set and incorrect ? auth header not present If I don't mention the auth header for the third interaction I get multiple interactions that match a requests with correct and wrong password. Any ideas?

abubics
2020-09-24 06:54
I think the https://docs.pact.io/faq/#how-do-i-test-oauth-or-other-security-headers is that's a separate layer to the contract interaction testing, and pact isn't a great fit for that . . .

abubics
2020-09-24 06:57
But I would also expect it to be easy to match a request without a header (not explicitly, but still unambiguously).

abubics
2020-09-24 06:57
What language/platform are you using?


artur
2020-09-24 06:59
I'm not using OAuth, simple basic auth

abubics
2020-09-24 07:00
Are you having trouble on the consumer side, or provider side, or both?

artur
2020-09-24 07:00
the client can send any username:password combination (or leave the header empty) and the server replies with 20x or 401, so in the first step I want to test the consumer that it reacts correctly on those responses

abubics
2020-09-24 07:02
On the consumer side, when I write pact interactions, I only have 1 valid matcher at a time, so the request either matches correctly, or finds no match (rather than finding a partial match)

abubics
2020-09-24 07:03
Is your stuff set up in a different way, where multiple interactions can match at once?

artur
2020-09-24 07:04
I have to use karma, and I could not find a way to attach the interactions to the single test because karma seems not to have a way, to have a super-global variable `provider = new Pact.PactWeb()` so I dump all interactions in one file

wilkinsweiqiangliang
2020-09-24 07:08
Hi guys, im writing a pact test with java and kafka. getting error with `Only request/response interactions can be used with an HTTP test target` . Does it mean i used a wrong annotation?

abubics
2020-09-24 07:14
ah, I haven't used karma . . . it's browser testing, right? Sounds tricky :confused: I know there's a https://github.com/pact-foundation/karma-pact lib, but I don't know anything about it either

abubics
2020-09-24 07:14
Sorry I can't be more help in your situation :<

abubics
2020-09-24 07:15
Having fewer interactions defined at once would be my recommended approach, if it's at all possible

christiaan
2020-09-24 07:28
Hi all. Two newbie questions: 1) Can somebody explain me the actual reason/rational about why when you use maven that, after running your unit tests, the producer needs to verify the pact in a seperate step "`mvn pact:verify"` against a running provider? 2 If my producer application already exdcutes junit in the "normal maven verify goal", which is also triggered during e.g mvn clean install, can I then skip this "`mvn pact:verify"` alltogether?

artur
2020-09-24 07:31
maybe I will open a feature request

stelios.arakliotis
2020-09-24 07:56
Hi guys, we are a team of backends(python) and frontends(react). Newbie concept questions : 1. Do we need to create Consumer tests both in python and in javascript in case of microservices connect to each other ? 2. If Pact Provider is written in Python how Consumer tests should be implemented in Javascript requiring access to mock service ?

matt.fellows
2020-09-24 08:02
did you run the test?

matt.fellows
2020-09-24 08:03
ah. OK thanks for raising Artur. Makes sense now

matt.fellows
2020-09-24 08:11
`npm i && make test` will generate a contract

matt.fellows
2020-09-24 08:11
```{ "consumer": { "name": "pactflow-example-consumer-js-kafka" }, "provider": { "name": "pactflow-example-provider-java-kafka" }, "messages": [ { "description": "a product event update", "providerStates": [ ], "contents": { "id": "some-uuid-1234-5678", "type": "Product Range", "name": "Some Product", "version": "v1", "event": "UPDATED" }, "matchingRules": { "body": { "$.id": { "matchers": [ { "match": "type" } ] }, "$.type": { "matchers": [ { "match": "type" } ] }, "$.name": { "matchers": [ { "match": "type" } ] }, "$.version": { "matchers": [ { "match": "type" } ] }, "$.event": { "matchers": [ { "match": "regex", "regex": "^(CREATED|UPDATED|DELETED)$" } ] } } }, "metaData": { "content-type": "application/json", "kafka_topic": "products" } } ], "metadata": { "pactSpecification": { "version": "3.0.0" } } }```

matt.fellows
2020-09-24 08:11
produced that

abubics
2020-09-24 08:15
Not really sure about maven . . . might want to ask in #pact-jvm for more targeted help

jamie
2020-09-24 08:20
has joined #general

abubics
2020-09-24 08:28
1. "Need" is a strong word, but if you have APIs that talk to other APIs, that may indicate a consumer-provider relationship :thumbsup: Nothing fundamentally wrong with that. 2. Consumers and providers certainly don't need to be in the same language. I'm not sure what you mean about "requiring access to mock service", though.

wilkinsweiqiangliang
2020-09-24 09:17
Dont worry about this issue, solved

wilkinsweiqiangliang
2020-09-24 09:20
Seems with `messagePact` , we cannot provide `null` value in the `content` , exception is ```TypeError: Cannot convert undefined or null to object at Function.keys (<anonymous>)``` In consumer test, i define ``` describe("receive a product update", () => { it("accepts a product event", () => { return messagePact .expectsToReceive("a product event update") .withContent({ id: like("da16494a-303a-463c-919a-e29e03a5b1de"), description: null ...```

bethskurrie
2020-09-24 10:04
Peeps! Just want to remind you that there are separate channels for each of the languages. We don't want to be supporting 10+ languages in the one channel! @wilkinsweiqiangliang looks like you want #pact-js ,

artur
2020-09-24 10:22
@matt.fellows I'm trying to restructure my tests. When I have different tests that have similar requests and should have different response, I add an interaction for each test but have to remove all interactions after every test. Is that right? because I cannot "overwrite" an interaction

matt.fellows
2020-09-24 10:53
That?s correct. If you call `verify` after each test runs, that clears out the mock server state. when `finalize` is called, that?s when the actual contract is serialised, including all of the previous interactions that were successfully verified

matt.fellows
2020-09-24 11:00
could you please raise an issue with an example that reproduces the error?

matt.fellows
2020-09-24 11:00
(and the full logs/stack trace etc. as per the issue template)

matt.fellows
2020-09-24 11:01
we?ll get it fixed

artur
2020-09-24 11:19
but if I call `removeInteractions` then `finalize` will not serialize them I guess

matt.fellows
2020-09-24 11:28
that will work too, but I?d suggest you call verify. Verify is what checks that you did what you said you would (i.e. the _mock_ part of the server, it?s not a stub, it?s meant to verify behaviour)

matt.fellows
2020-09-24 11:53
How?d you go Yoni? Keen to hear any insights from the community!

matt.fellows
2020-09-24 12:00
LOL. I thought the idea (and your other one) sounded familiar. I remember not long after I first launched the beta pact broker platform (back in late 2016), what is now Pactflow. I started creating a flurry of ?pie in the sky ideas? on the private GH repo where the initial customised app/platform. This one has a few fun items in it :stuck_out_tongue:

matt.fellows
2020-09-24 12:00
Or put another way - great minds think alike?

matt.fellows
2020-09-24 12:00
Or put another way - developers like to whinge, let?s create a whinge-as-a-service

matt.fellows
2020-09-24 12:01
but i :heart: this idea so much: > Imagine a command could make an ?unhappy contract file?. Now you can see your API call side-by-side with the contract ? You can see the diff between them.

matt.fellows
2020-09-24 12:01
THAT is a very cool idea

matt.fellows
2020-09-24 12:03
It?s also very doable I think. One of the unique parts of Pactflow is that we version all of the things and have all of these interconnections, so we could potentially even say ?actually, this worked for you on version x.y.1 and is incompatible with x.y.2? type thing

matt.fellows
2020-09-24 12:05
retrospective :taco: :taco: for @armorsmith42

matt.fellows
2020-09-24 12:05
?and bed for me :stuck_out_tongue:

jan.krejci
2020-09-24 13:19
Hi guys. Just following up this question. I really appreciate your feedbacks.

phil.endsley
2020-09-24 13:38
> there is certain scenarios as *External integrations* (Providers) By this, do you mean third party APIs you are consuming? For the company I work at, we don't do any kind of contract testing with 3rd party APIs, or even 3rd parties that consume our APIs. We generally get heavy push back if we suggest it, and since we can't control anything from their side, it's not worth the churn on our teams to go back and forth. Instead, we make sure we have testing in place for all the other layers, and mock out the third party stuff with our understanding of how it works. On top of that, we usually test with the third party directly before the feature that interacts with it. We still have bugs come up every now and then, but nothing severe enough that our company has had to consider alternate approaches. I am curious if anyone has success stories. It doesn't seem like a common scenario where I am (even other companies in my area).

sklein
2020-09-24 13:41
Question... Is there a way to force the pact verifier to follow redirects?

armorsmith42
2020-09-24 16:20
> whinge-as-a-service Winging is severely underrated.

armorsmith42
2020-09-24 16:22
This is because the person doing the wingeing is probably next to someone who is also stressed. If they were instead wingeing to someone in problem-diagnosis mode, then the value of their wingeing would connect. There is a time and place for doing everything and for hearing everything. Wingeing does not have the same place for both....not without design https://youtu.be/W4ga_M5Zdn4

jan.krejci
2020-09-24 18:29
Thanks a lot for your answer. It is exactly I what I was asking. Like Pact is not driven to solve this kind of issue, something that might happen is the API producer changes the API after you already validated and tested your features. I don't see any way to prevent it except a good communication. Any thoughts?

kflo
2020-09-24 21:13
so one huge benefit of pact is that it will allow us to not have to maintain environments filled with all of our services for end to end functional testing. but i?m curious what this means for the frontend, more specifically tests which involve flows. i guess these could also be automated using the pact broker, but what about exploratory testing? for example if you run the UI locally and you want to go through some flows manually, what should the frontend be talking to?

kflo
2020-09-24 21:15
i see various articles about functional testing and the UI, but those seem mostly about automated testing

kflo
2020-09-24 21:16
this topic isn?t necessarily related to pact, more about testing practices in relation to contract testing? if anyone has any articles to share it would be appreciated

kflo
2020-09-24 22:39
i guess when i say ?exploratory? i mean any kind of manual testing

bethskurrie
2020-09-24 22:56
@sklein which language? Can you give us some more background on why there's a redirect?

bethskurrie
2020-09-24 22:59
@jan.krejci @phil.endsley this is a big problem for lots of people, and we're actually doing some brainstorming at the moment as to how we could help solve this problem. It would likely involve OAS. @jan.krejci one of the forms of contract testing suggested by the original contract testing thought leaders was to have a stub (that you build yourself using an off the shelf stub tool) and have a test suite that you run against both the stub, and at a regular cadence, against the real provider.

bethskurrie
2020-09-24 22:59
It's an alternative method of ensuring that your stub and the real service behave the same way.


kflo
2020-09-24 23:03
hm, yes i saw this? although it?s still kind of abstract to me without playing around with a stub server? which i should probably do

kflo
2020-09-24 23:03
does the stub server support provider states?

bethskurrie
2020-09-24 23:03
good question.

bethskurrie
2020-09-24 23:03
not yet.

kflo
2020-09-24 23:04
ok, so it?s more of a canned ?i get this request, i give this response? kind of thing?

bethskurrie
2020-09-24 23:04
depends on which impl you're using, but if there are multiple matches for a request, it gives the "most positive"

bethskurrie
2020-09-24 23:04
The ruby one, anyway. I'm not sure on the rust impl.

kflo
2020-09-24 23:04
ok, good to know


bethskurrie
2020-09-24 23:04
It's not a fully featured stub, so you might be best using your pact to seed a proper stub like mountebank.

bethskurrie
2020-09-24 23:05
Ah, create article.

kflo
2020-09-24 23:05
which may help answer some of my questions

kflo
2020-09-24 23:05
i was looking at mountebank as well

bethskurrie
2020-09-24 23:06
If I had all the time in the world, I'd like to write a nice converter to load a pact in automatically.

kflo
2020-09-24 23:06
and i would love to help contribute that as well? depends a little on the timeline we are given at work

matt.fellows
2020-09-25 01:02
mountebank is a good tool, and the predicate matching is something I?d either a) like to bring into the stub server or b) enable a ?is this mountebank stub compatible with this pact contract?. That could give you the flexible stubbing you need for that sort of testing, whilst also giving you the guarantees that what you?re testing is indeed compatible with the provider

matt.fellows
2020-09-25 01:04
There?s a number of tools that can help with it. https://github.com/Netflix/pollyjs is a good one for JS

matt.fellows
2020-09-25 01:06
You could also use a tool like Pact Broker / Pactflow to manage the expectations. I talk about this in point (3) in this article: https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-2/

matt.fellows
2020-09-25 01:07
Replace ?provider? with the external third party, and do what Beth said - periodically test the _real_ provider and use a form of approval-based testing to ensure things don?t drift

2020-09-25 01:37
A post in *Feature Requests* has been marked as *complete*

wilkinsweiqiangliang
2020-09-25 03:43
sure will do thanks

artur
2020-09-25 06:18
Thank you for your great help. I think I got it now. I've creating a new provider in every test file `provider = new Pact.PactWeb()` and interactions that I need in multiple tests I've moved to a helper function, that I can call with the provider as parameter. That system seems to work and enables me to add specific interactions for the tests :bananadance:

sambitkumar.pal
2020-09-25 13:55
Hi, I want to trigger a webhook programtically (java code) instead of directly from pact broker. Any reference/ example available ? Please let me know on this.

sambitkumar.pal
2020-09-25 15:44
Is anybody tried this ? Any suggestions?

raghanag
2020-09-25 18:56
has joined #general

phil.endsley
2020-09-25 19:41
What do you mean by this? Just trigger it artibrarily? Or still based on an event from pactbroker? If you want to invoke the webhook outside of the events from pactbroker, you just call that endpoint directly whenever you want If you want to invoke it based on the event in pactbroker, that's what the webhooks are doing already

collin.johnson
2020-09-25 21:19
has joined #general

sambitkumar.pal
2020-09-25 21:31
Want to invoke the webhook outside of the event from pactbroker. Is the endpoint http://localhost:8500/webhooks/ or anything else? I want to call it whenever any changes in content of consumer , I know the event for this. But how it will call only one time during consumer build ? Suppose 5 consumers are there and I have to prepare 5 requests to hit the endpoint one time. If it is inside the consumer build Pak. Then everytime the build trigger then it will also hit the endpoint. I think in every build of consumer it should not hit. Bcz only one time it should hit endpoint. Am I right in this? Plz let me know.

matt.fellows
2020-09-25 23:36
Why invoke the webhook, you could just call the API the webhook invokes directly

matt.fellows
2020-09-25 23:37
A webhook is designed to trigger based on specific platform events rather than requiring manual intervention. If your code had other logic you can just bypass the webhook altogether

matt.fellows
2020-09-25 23:39
Also, a webhook can already kick off based on the content changes in a contract so you don't need to explicitly call it anyway

matt.fellows
2020-09-25 23:39
Perhaps if you can explain the problem you have and why you think a webhook solves it that would help

sambitkumar.pal
2020-09-26 01:35
Instead of triggering inside pact broker 5 times for 5 consumers, I want to trigger it from my code which will trigger automatically. Webhook is a one time call and then it's retrying for every time to execute after any content change event.

matt.fellows
2020-09-26 01:42
I'm sorry I still don't follow why you want to do it this way and the problem it solves. If you have code to know when to do something (like trigger the webhook) why not just bypass the webhook altogether and perform the trigger from your java code?

matt.fellows
2020-09-26 01:44
It feels like you're trying to solve the wrong problem, which is why I'm asking. The webhooks are designed to decouple applications but it feels like you want to co-ordinate things introducing coupling

sambitkumar.pal
2020-09-26 01:50
Ok. I have 5 consumers and corresponding to those 5 providers as well. So instead of calling 5 times separately from code, I need to make one time call for all 5 consumers? Am I right? Plz correct me.

sambitkumar.pal
2020-09-26 02:00
If any example is available for such API call of webhook from code, please let me know.

viniciusribeirosp
2020-09-27 12:04
has joined #general

wilkinsweiqiangliang
2020-09-28 06:37
Hi team, any example with using pactflow and how it should setup with gradle as provider, and npm as consumer? any example for best practices?

wilkinsweiqiangliang
2020-09-28 06:59
By the way, where i can find this `pactBrokerUsername` ? doesnt seems to appear on the UI.

wilkinsweiqiangliang
2020-09-28 07:39
Other problem is trying to push pact to broker as example however has issue on `NameError`

wilkinsweiqiangliang
2020-09-28 07:40
```consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/broker.rb:59:in `rescue in publish': uninitialized constant PactBroker::Client::Error (NameError)```

wilkinsweiqiangliang
2020-09-28 07:40
```const child_process = require('child_process'); const exec = command => child_process .execSync(command) .toString() .trim() const path = require("path") const { Publisher } = require("@pact-foundation/pact") const branch = exec("git rev-parse --abbrev-ref HEAD") // publish to local docker // const opts = { // pactBroker: 'localhost:9292', // consumerVersion: '1', // pactFilesOrDirs: ['./pacts'], // }; const gitSha = exec("git rev-parse HEAD") const opts = { pactFilesOrDirs: [path.resolve(process.cwd(), "pacts")], pactBroker: "https://test.pact.dius.com.au", pactBrokerUsername: "dXfltyFMgNOFZAxr8io9wJ37iUpY42M", pactBrokerPassword: "O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1", consumerVersion: gitSha, tags: [branch], } new Publisher(opts).publishPacts().then(() => { console.log("Pact contract publishing complete!") console.log("") console.log("Head over to https://test.pact.dius.com.au/ and login with") console.log("=> Username: dXfltyFMgNOFZAxr8io9wJ37iUpY42M") console.log("=> Password: O5AIZWxelWbLvqMd8PkAVycBJh2Psyg1") console.log("to see your published contracts.") }) .catch(e => { console.log("Pact contract publishing failed: ", e) })```

matt.fellows
2020-09-28 07:45
that property is not for pactflow


matt.fellows
2020-09-28 07:45

matt.fellows
2020-09-28 07:46
hmm, that looks like a bug, but the bug is being shown because of an error

matt.fellows
2020-09-28 07:48
what does your console have to say about it? Hopefully there is a stacktrack that explains what it was doing

matt.fellows
2020-09-28 07:48
at the least, set log level to DEBUG and print out what it was trying to do

wilkinsweiqiangliang
2020-09-28 08:39
let me get the debug message and post here

kristine.jetzke
2020-09-28 08:49
Yes. You can skip it then. If you run your contract tests during the regular maven build there?s no need for it. But sometimes you might have cases where you cannot run them as part of the regular build (eg legacy application) and then the verify goal can be used.

noamaanmohdkhan
2020-09-28 15:52
has joined #general

noamaanmohdkhan
2020-09-28 15:55
Hi. I have been trying to find an example code which uses `pathFromProviderState` , `valueFromProviderState` and `queryParameterFromProviderState` . I am working with JVM. And finding it difficult to find a proper documentation in one place or example which can help me understand how it works.

lo.voelsen
2020-09-28 17:02
has joined #general

aforeman
2020-09-28 21:07
Hello *Reminder* score your free lifetime upgrade on Pactflow when you complete our short survey. Submissions closing this weekend. See info and link below :point_down: For those who have already completed, we will be in touch with you today to confirm your account upgrade.  Thanks in advance! :raised_hands:

wilkinsweiqiangliang
2020-09-28 22:36
```yarn run v1.22.5 warning ../../../../../package.json: No license field $ node publish.ts [2020-09-28T22:29:12.217Z] INFO: pact-node@10.10.1/10867 on wilkinsliang: Publishing Pacts to Broker [2020-09-28T22:29:12.217Z] INFO: pact-node@10.10.1/10867 on wilkinsliang: Publishing pacts to broker at: https://test.pact.dius.com.au [2020-09-28T22:29:12.554Z] WARN: pact-node@10.10.1/10867 on wilkinsliang: Pact exited with code 1. [2020-09-28T22:29:12.555Z] ERROR: pact-node@10.10.1/10867 on wilkinsliang: Could not publish pact: /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/broker.rb:59:in `rescue in publish': uninitialized constant PactBroker::Client::Error (NameError) from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/broker.rb:55:in `publish' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/custom_thor.rb:15:in `start' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/app/pact-broker.rb:28:in `<main>' Pact contract publishing failed: Error: /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/broker.rb:59:in `rescue in publish': uninitialized constant PactBroker::Client::Error (NameError) from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/broker.rb:55:in `publish' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/vendor/ruby/2.2.0/gems/pact_broker-client-1.27.0/lib/pact_broker/client/cli/custom_thor.rb:15:in `start' from /home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.86.0/pact/lib/app/pact-broker.rb:28:in `<main>' at ChildProcess.<anonymous> (/home/wilkinsliang/work/lendi/decision-engine-team/e2e-testing/consumer/node_modules/@pact-foundation/pact-node/src/publisher.js:72:40) at Object.onceWrapper (events.js:421:26) at ChildProcess.emit (events.js:326:22) at maybeClose (internal/child_process.js:1051:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5) Done in 0.86s.```

wilkinsweiqiangliang
2020-09-28 22:38
@matt.fellows i saw we are using pact_broker_client `1.27.0` its a bit old from the tags. https://github.com/pact-foundation/pact_broker-client/tags?after=v1.27.26

wilkinsweiqiangliang
2020-09-28 22:39
my consumer node dependency. ``` "dependencies": { "@pact-foundation/pact": "^9.12.0", "axios": "^0.19.0", "faker": "^5.1.0", "kafkajs": "^1.14.0", "uuid": "^8.3.0" },```

bgaundar
2020-09-28 22:43
has joined #general


wilkinsweiqiangliang
2020-09-29 04:15
Hi, i have been trying to find an example how ci/cd will automate the pact verification on both consumer and provider sides. Any resources to help me understand how it should work and setup?

wilkinsweiqiangliang
2020-09-29 04:16
is it a document?

matt.fellows
2020-09-29 04:16
Howtolearn

2020-09-29 04:16
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-29 04:16
CI/cd workshop there

matt.fellows
2020-09-29 04:16
Also look at the effective pact setup guide

wilkinsweiqiangliang
2020-09-29 04:17
okay sure

wilkinsweiqiangliang
2020-09-29 04:17
will do

wilkinsweiqiangliang
2020-09-29 06:10
following the cicd workshop docs and i had found some issue. Would you mind to help?

wilkinsweiqiangliang
2020-09-29 06:11
So im getting 403 when tagging a version to master. ```/home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:84:in `block in tag_versions': Error returned from tagging request 403 (Pact::Provider::VerificationResults::PublicationError)```

wilkinsweiqiangliang
2020-09-29 06:13
The other issue for the docs, is when we generate encrypted token for provider, it doesnt seems to have any `make` task to generate the encrypted token. From the docs, ```The environment variable must be encrypted in the context of the repository to which it will be added, so you can't just reuse the output of the encrypt step from the consumer project.``` I had to manually copy the `make` task `travis_encrypt_pact_broker_token` to generate one for provider.

robbert.van.der.zon
2020-09-29 06:24
has joined #general

matt.fellows
2020-09-29 06:29
Sorry I?m in a meeting for next few hours, but you can just skip all of that and pop your API token directly into your travis ci build


wilkinsweiqiangliang
2020-09-29 06:31
:+1:

matt.fellows
2020-09-29 06:32
awesome

matt.fellows
2020-09-29 06:32
`403` means forbidden, so it could be that you used the read-only token, just double check that

dabs1234
2020-09-29 07:02
Guys I trying to test the api which needs access tocken. Following is the code ```@TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request) { request.addHeader("Authorization", "Bearer " + getClientOAuthToken()); context.verifyInteraction(); System.setProperty("pact.verifier.publishResults", "true"); }``` Getting following 400 error: 1.1) StatusMismatch: expected status of 200 but was 400 1.2) BodyMismatch: $ BodyMismatch: Expected name='name' but was missing { - "name": "name", - "id": 2000 + "timestamp": 1601355640376, + "status": 400, + "error": "Bad Request", + "message": "Missing request header 'Authorization' for method parameter of type String", + "path": "/portal/movie" } What might be wrong here? Any sample with JUnit5 would be a great help.

wilkinsweiqiangliang
2020-09-29 07:06
I had double check my token is the ci token

wilkinsweiqiangliang
2020-09-29 07:06
it pass on the pact verification test on provider but fail on taging

matt.fellows
2020-09-29 07:07
Might be best asking in #pact-jvm


mark.doppelfeld
2020-09-29 07:31
has joined #general

kristine.jetzke
2020-09-29 07:36
Hi everyone :wave: Is anyone planning to participate in https://hacktoberfest.digitalocean.com/ this year? To hack on some pact issues or as a maintainer?

florian.nagel
2020-09-29 07:41
I'm definitely gonna participate :smile: Not sure if I can give much to Pact bc it's quite a big project, but I'm definitely gonna contribute to open source!

matt.fellows
2020-09-29 08:33
We?d love to support this initiative. It would be great to get a show of hands on the above (using the :raised_hand: emoji) so we can gauge interest

matt.fellows
2020-09-29 08:34
Our job as maintainers is to curate and ensure our repositories are tagged/maintained so that we can help people get involvved

wilkinsweiqiangliang
2020-09-29 08:36
still have the issue, do i need any extra permission to do tagging?

wilkinsweiqiangliang
2020-09-29 08:37
@matt.fellows

matt.fellows
2020-09-29 08:38
There are so many ways to help us. Off the top of my head: 1. Help create demos/example projects 2. Update / identify areas we could improve documentation 3. Fix a bug 4. Report a bug 5. Pick up a new feature to contribute to 6. Help uplift a language to v3 (using our new?ish) rust library 7. Help / pair with somebody else 8. ?

matt.fellows
2020-09-29 08:39
Can you please share your log output? Failing on tagging is strange

tjones
2020-09-29 08:40
I'm definitely in!

wilkinsweiqiangliang
2020-09-29 08:41
``` 3 interactions, 0 failures /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:84:in `block in tag_versions': Error returned from tagging request 403 (Pact::Provider::VerificationResults::PublicationError) from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:80:in `each' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:80:in `tag_versions' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:68:in `tag_versions_if_configured' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:34:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish.rb:21:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish_all.rb:22:in `block in call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish_all.rb:19:in `collect' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish_all.rb:19:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/verification_results/publish_all.rb:10:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/rspec/pact_broker_formatter.rb:28:in `close' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:209:in `block in notify' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:208:in `each' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:208:in `notify' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:243:in `close' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:196:in `close_after' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:174:in `finish' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/reporter.rb:76:in `report' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:115:in `run_specs' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:89:in `run' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/rspec-core-3.9.1/lib/rspec/core/runner.rb:71:in `run' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/pact_spec_runner.rb:88:in `run_specs' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/provider/pact_spec_runner.rb:34:in `run' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/cli/run_pact_verification.rb:69:in `run_with_pact_uri_object' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/cli/run_pact_verification.rb:50:in `run_specs' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/cli/run_pact_verification.rb:21:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-1.49.3/lib/pact/cli/run_pact_verification.rb:13:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:169:in `verify_pact' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:43:in `block in call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:42:in `collect' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:42:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/app.rb:34:in `call' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/cli/verify.rb:56:in `verify' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/vendor/ruby/2.2.0/gems/pact-provider-verifier-1.30.1/lib/pact/provider_verifier/cli/custom_thor.rb:17:in `start' from /home/travis/build/wilkinsleung0712/example-provider/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.85.0/pact/lib/app/pact-provider-verifier.rb:33:in `<main>' INFO: Tagging version 9abc843b5c2a91fcb6b0818c4383ba3c49532454 of pactflow-example-provider as "master" at ChildProcess.<anonymous> (node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/src/verifier.ts:265:55)```

matt.fellows
2020-09-29 08:46
That error implies you?re using a *read-only* token

wilkinsweiqiangliang
2020-09-29 08:46
really?

matt.fellows
2020-09-29 08:46
I?ve checked our logs which confirms it, can you please triple check you?re using a read-write token?

wilkinsweiqiangliang
2020-09-29 08:47
no way, check multiple times

wilkinsweiqiangliang
2020-09-29 08:47
unless the copy button from UI doesnt work

wilkinsweiqiangliang
2020-09-29 08:47
haha

wilkinsweiqiangliang
2020-09-29 08:48
this is the one im using

matt.fellows
2020-09-29 08:48
That?s the right one!

matt.fellows
2020-09-29 08:48
you OK if I jump in to take a look?

wilkinsweiqiangliang
2020-09-29 08:49
yes please


mike.geeves
2020-09-29 09:24
Intending to, but I've been intending to take a look at #1 for a little while anyway. Ahem. Been busy :stuck_out_tongue:

bethskurrie
2020-09-29 09:28
Upgrade please @wilkinsweiqiangliang that's been fixed.

bethskurrie
2020-09-29 09:32
I still don't understand why. The webhook will fire automatically when you publish a pact or verification result.

bethskurrie
2020-09-29 09:33
The only reason you'd trigger a webhook manually is to test it.

bethskurrie
2020-09-29 09:34
It's not going to call all 5 consumers/providers at once for you.

bethskurrie
2020-09-29 09:34
For each pact or verification results publication, there is only one consumer and one provider.

kong
2020-09-29 10:21
I?m intending to ? just have to get back to the OSS codebase

matt.fellows
2020-09-29 10:51
Awesome. would people prefer an event format where we find a day/time where us maintainers are hanging out over a 24 hr period (we?re in all the places, so unlikely we?ll be able to line us all up) Or would people prefer us to just have some ?garden paths? available for people to be able to pick up at their own pace I also expect to be told ?both?

florian.nagel
2020-09-29 10:54
For me personally I'd think that the second approach is more convenient as I'm not sure how much time I can spend on Pact in one sitting of 24 hours. Thanks for making this offer! :smile:

mike.geeves
2020-09-29 11:33
Second option for me, although I still have a todo list from before :stuck_out_tongue: Because unreliability :stuck_out_tongue:

phil.endsley
2020-09-29 12:22
Ditto on second option. It's for all of October, and everyone is already super responsive on slack.

sambitkumar.pal
2020-09-29 13:34
Agree. But we need to call webhook manually once. Post which it will automatically. But I want that manual once/1st time to make it programmatically. Not manually.

phil.endsley
2020-09-29 13:52
There's a lot of red flags with the way you're going about implementing this, which is why everyone is trying to ask for more clarification on _why_ you're trying to do this. You said you were working on a proof of concept, so I'm assuming this first time would be for your consumer when you commit a change to modify the consumer pact? If so, the typical workflow would be to have your project setup in source control with a build server. Then, each time you make a commit, your build server would trigger a build. Is that the part you're trying to simulate? If you need to call it manually, for whatever reason, just call the endpoint directly. There's no api in Pact Broker that will fire off a webhook for you. So, if your webhook is setup to call http://localhost:8080, just call that directly instead of trying to make the webhook trigger. Again, if you're doing this for a real setup, you shouldn't have to do this

matt.fellows
2020-09-29 14:05
It's not clear why you need to call the webhook manually at all (and if you do, you don't need to trigger it via Pactflow you can just call it directly as Phil says)

matt.fellows
2020-09-29 14:05
I can't remember if I shared with you already, but I'd look at reading thru (if not doing it yourself) the CI/cd workshop

matt.fellows
2020-09-29 14:05
Howtolearn

2020-09-29 14:05
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-09-29 14:06
:point_up:ci/cd workshop there

matt.fellows
2020-09-29 14:07
Honestly it sounds like you're over complicating things so hopefully once it clicks it will be a lot less complexity to manage and easier to demonstrate the benefits!

ukrainian1991
2020-09-29 14:11
Hi, What is the proper approach if one of the microservices communicates with external 3rd party API? Should I stub it and write separate contracts tests between my microservice and this 3rd party?

ukrainian1991
2020-09-29 14:17
I am a bit messed up with statements here https://docs.pact.io/getting_started/what_is_pact_good_for#what-is-it-not-good-for and my case)


ukrainian1991
2020-09-29 14:43
Thanks!!! I think idea to use OpenApiSpec test for real 3rd party on regular basic is a good easy choice

ukrainian1991
2020-09-29 14:44
...while using stub in other tests with internal microservices


sambitkumar.pal
2020-09-29 15:23
Thanks Phil. You have valid point. I got it. Thank you all.

collin.johnson
2020-09-29 16:49
Hey everyone, I'm very new to pact trying to implement it in an existing project. When implementing pact in my own project I had to set the Cors flag to true to get my consumers pacts to work. It is working now but I'd like to understand what about my app makes it need this, I'm using axios to make the GET request and pact was claiming it only saw an OPTION request (cors preflight) and failed before I set the cors flag to true. Anyone have any insight into where to look to find out more about how this works? I thought maybe it had to do with some detail of how the pact mock server is implemented as other jest mocks don't have this kind of problem, which is why I'm asking here

collin.johnson
2020-09-29 17:11
Upon writing that out I am realizing it's probably something within the surrounding app I need to understand more than pact itself. The project is a dockerized gatsby frontend being served by nginx I didn't set up that part myself so I'm guessing that's where the cause is, and what I need to look into. The jest mocks I used before weren't setting up a mock server like pact is which is why I didn't see the problem before.

phil.endsley
2020-09-29 17:45
> I thought maybe it had to do with some detail of how the pact mock server is implemented as other jest mocks don't have this kind of problem The pact mock server is an actual server that's being started to host what is defined in the contracts. When you run your consumer tests with pact, it's making actual http calls to the mock server, and the mock server then returns what you defined in the contract.

florian.nagel
2020-09-29 20:42
No you didn't :joy: I thought my puns were bad... I stand corrected ^^

matt.fellows
2020-09-29 23:06
:taco: for @joel.whalen for the best pun of the day. Beth will be ~proud~ angry

sreid
2020-09-30 00:08
has joined #general

wilkinsweiqiangliang
2020-09-30 01:04
Hi guys, im working on the ci cd setup and a bit confused. Where does webhook fit in in a normal ci/cd process. ? when consumer publish pact file during build process, and webhook trigger provider verification and failed, would it also fail the consumer builds in ci? ? what is the best practices in ci/cd? Shall the pactverification test be executed in every build?

bethskurrie
2020-09-30 01:07
Have you read the effective pact set up guide?

bethskurrie
2020-09-30 01:07
In this step it describes the workflows https://docs.pact.io/pact_nirvana/step_4

bethskurrie
2020-09-30 01:08
> when consumer publish pact file during build process, and webhook trigger provider verification and failed, would it also fail the consumer builds in ci? you need to use can-i-deploy in the consumer pipeline to find out the verification results

wilkinsweiqiangliang
2020-09-30 01:08
cool i followed the workshop havent reach to this page yet, will read through and see

bethskurrie
2020-09-30 01:08
Heres's the CI/CD workshop, that should make things clear https://docs.pactflow.io/docs/workshops/ci-cd/

bethskurrie
2020-09-30 01:08
I'm in the middle of moving it from Travis CI to Github Actions.

bethskurrie
2020-09-30 01:09
The code works, but the docs still talk about Travis.

bethskurrie
2020-09-30 01:09
> what is the best practices in ci/cd? Shall the pactverification test be executed in every build? Yes, every build.

bethskurrie
2020-09-30 01:09
The consumer generates and publishes a pact with every build. Most of the time it will not change. The provider verifies the pacts every time it runs a build.

bethskurrie
2020-09-30 01:10
When the pact does change, the pact verification build runs on the provider.

wilkinsweiqiangliang
2020-09-30 01:10
and thats by webhook

bethskurrie
2020-09-30 01:10
yes

wilkinsweiqiangliang
2020-09-30 01:11
so i assume everything it start by consumer witting a pact file first, as consumer driven, otherwise without pact file, provider test will fail.

bethskurrie
2020-09-30 01:12
it depends on the Pact implementation for that language as to whether the provider build fails or not when there are no pacts.

wilkinsweiqiangliang
2020-09-30 01:12
thats a good tips

wilkinsweiqiangliang
2020-09-30 01:12
doesnt see it mention anywhere in docs

adrianojedabenitez
2020-09-30 04:40
hello! not sure if this is the correct place to ask, but maybe someone had the same issue as me. Basically, I?m using gitlab and pactflow. I?ve created a webhook to trigger a job in case a contract with my provider changed, following the gitlab webhook template library as per doc. The issue is I need to specify the branch as part of the url ref. But we work with `develop` as develop branch and `master` as stable branch and also with releases branches. The problem is that in case we are adding an intentional breaking contract change the webhook that will be in charge of verify that pact should be able to run in develop but also in master branch depending on the version that the consumer is releasing. how did you guys solve that?

bethskurrie
2020-09-30 04:41
> The issue is I need to specify the branch as part of the url ref The consumer branch or the provider branch?

bethskurrie
2020-09-30 04:41
#pact-broker is the best channel to ask, to keep things focussed.

bethskurrie
2020-09-30 04:44
If you need to do logic on which branch of the provider to do the verification against, I would put that logic into the build itself. eg. have the webhook trigger a build that fetches the info, and decides which branch to verify on.

wilkinsweiqiangliang
2020-09-30 05:42
Hey guys, any example or blog for using pact-broker with aws s3 instead of postgres or sql?

bethskurrie
2020-09-30 05:45
To back the application? Not possible.

bethskurrie
2020-09-30 05:45
It has to be a relational database.

bethskurrie
2020-09-30 05:45
The data is very relational.

bethskurrie
2020-09-30 05:45
Not the contracts themselves, the relationships between the versions - see the matrix page. It's a classic many to many relationship.

wilkinsweiqiangliang
2020-09-30 05:45
anysuggestion for the db instance? sz and performance wise?

bethskurrie
2020-09-30 05:46
You can use the same ones as the Pactflow On-Prem requirements https://docs.pactflow.io/docs/on-premises/system-requirements/

bethskurrie
2020-09-30 05:48
Pactflow On-Prem is the On-Prem version of Pactflow SaaS which is a hardened/improved version of the OSS Pact Broker On-Prem :laughing:

raghanag
2020-09-30 06:00
hi, i am reading https://docs.pact.io/faq/convinceme/ but couldn?t figure out what happens when you have tens of consumers and do you recommend everyone to generate pact files and let the provider run all the pact files at the provider end so that any changes dont break any consumer.

bethskurrie
2020-09-30 06:01
@raghanag you can try it, but you may find it difficult. We're working on a provider driven flow at the moment that will scale better for many consumers.


bethskurrie
2020-09-30 06:03
We're working on a way to allow a provider to define a contract using open api, and run one set of tests to verify that it meets it's contract, then allow consumers to generate their contracts as normal, then verify the consumer contract against the provider contract.

bethskurrie
2020-09-30 06:03
Statically comparing the consumer contracts against the provider contract will scale better than the current method of verifying pacts.

raghanag
2020-09-30 06:06
so you meant going forward it would be just find the delta across provider and consumer pact json files?

bethskurrie
2020-09-30 06:07
it would compare the provider's OAS to the consumers' pacts, and check they were compatible.

raghanag
2020-09-30 06:08
can i safely say that pact is a unit test fwk which provides mock server and generates a json file just like hoverfly which generates json file with its own schema but acts as a MITM proxy which reduces all the cluttering(code changes) you need if you use wiremock, but hoverfly you need to make changes in your browser proxy settings

bethskurrie
2020-09-30 06:09
I've never used hoverfly I'm afraid.

bethskurrie
2020-09-30 06:09
@matt.fellows?

raghanag
2020-09-30 06:09
why provider OAS instead of provider pact

bethskurrie
2020-09-30 06:09
We may end up supporting that as well, but the tool already exists for pact/oas comparison.

bethskurrie
2020-09-30 06:10
So that's where we're starting.

raghanag
2020-09-30 06:10
thanks for answering patiently

bethskurrie
2020-09-30 06:11
no worries. this feature isn't out yet, but it's next on our Pactflow priority list after we get user roles complete

mark.doppelfeld
2020-09-30 07:44
Hi

me1525
2020-09-30 07:57
has joined #general

namhuynhkien
2020-09-30 09:25
has joined #general

adrianojedabenitez
2020-09-30 13:07
thanks for reply Beth! yeah I was asking on the provider branch. I see, I wanted to avoid adding extra logic but that might work. Maybe using the consumer tag to decide which branch to verify on.

adrianojedabenitez
2020-09-30 13:07
thanks!

sklein
2020-09-30 15:10
Any thoughts on how people have effectively shared valid states between consumers and providers? Magic string state matching is starting to feel a bit brittle.

jan.krejci
2020-09-30 19:53
@bethskurrie It's great to know it. I am wondering if the feature request will be released to all open source comunity. https://github.com/pactflow/roadmap/issues/4

abdul.akhter
2020-09-30 21:02
has joined #general

matt.fellows
2020-09-30 22:56
One strategy is to have a standard naming convention for the common states - e.g. mapping to the http status codes

matt.fellows
2020-09-30 22:57
Some teams have a published page which outlines the available states, but according to Beth, that?s an anti-pattern. Each consumer should have its own set of states. Personally, I prefer to have less so it?s a point of contention

matt.fellows
2020-09-30 22:58
I think it could be helpful for the pact broker to show the available states somewhere

matt.fellows
2020-09-30 22:58
Also, the provider driven stuff we?re looking to add should make this problem go away, because the provider doesn?t need to implement the states a consumer defines

abubics
2020-10-01 00:14
Just chipping in with more perspectives . . . I like to have a state per significant situation (which is, of course, an "it depends" answer). What that means will depend on your participants and the domain model, necessarily. But some general ideas for what makes a situation significant are: ? For UI tests, collections with 0, 1, some, many, lots are helpful. ? Similarly for headless/API tests, boundary conditions like pagination limits are interesting (e.g. 0 items, <1 page, >1 page, many pages). ? Design for errors early. ? Design for user roles early. ? Abstract for time-sensitivity early (i.e. inject a "now" provider, so you can mock relative times/dates easily). ? Detail as little as possible in the state name, but have known & shared concrete values backing each state (e.g. "a sprocket exists" tells you that an entity exists (significant) and implies but hides that you know the ID in the URL `/sprocket/12` or whatever).

abubics
2020-10-01 00:18
If you find that you need to specify a lot of things in the state names, it could be because your resources are modelled in a complicated way. The states can be a helpful diagnostic tool to highlight such a situation. In those cases, it's important to remember that a hierarchical set of relationships doesn't have to be exposed directly through your ReST API resources. E.g. if you have 4 levels deep of parent-child relationships, but each level has unique IDs, then don't need to be nested in the URL path.

abubics
2020-10-01 00:21
Relatedly, you don't have to have only one path to access each resource. If it makes sense for your consumer contexts, you could have something like `/parent/{id}/child/{id}/grandchild/{id}` and `/person/{id}` where all of those IDs are unique, and access the same pool of entities. Then navigation metadata become more useful/important, and you may evolve more towards HATEOAS.

matt.fellows
2020-10-01 02:06
@abubics gets a :taco:. You must be hungry after all of that typing

ranjanayush03
2020-10-01 04:20
Hi all , I have a provider API which requires a validation of token to be done so that it can be called because of a proxy app running infront of it , but on the consumer side while generating pacts because we are two separate teams we cannot share the token from provider , and hence the pact which is generated won't have the necessary authorization to hit the API .So , is there a way so that I can modify the headers of the pact file on the provider side..



ranjanayush03
2020-10-01 04:52
Thanks Matt will look into the examples..

wilkinsweiqiangliang
2020-10-01 06:25
Hi guys, i had couple of question. ? how does the providerVersion get inserted in JVM? i can see in js we can insert with `providerVersion Options` ? when using gradle plugin to upload the pact file with versioning, can it be used with `git sha` instead of string? (i.e. the publish config in `pactPublish` gradle task.) ? Does the `pactBroker` support multiple user? and token? like `pactflow` does? im trying to understand what is the main different between pactbroker and pactflow, it seems to be better UI, and secret, multiple user. What about functional wise

bethskurrie
2020-10-01 08:28
The majority of the difference between the Pact Broker and Pactflow is in the user management, security and UI, so far. The feature differentiation will be starting soon, as we begin working on provider driven contract support.

bethskurrie
2020-10-01 08:29
The Pact Broker only supports basic auth, and there's only two sets of credentials - a read write, and a read only.

bethskurrie
2020-10-01 08:30
Best to ask the JVM specific questions in #pact-jvm

bethskurrie
2020-10-01 08:32
Extra :taco: for @abubics

abubics
2020-10-01 08:34
All licenced as MIT and/or CC ;D feel free to steal it and/or publish it

matt.fellows
2020-10-01 11:08
You can see the key feature differences at http://pactflow.io/features


matt.fellows
2020-10-01 11:11
It uses the `pact.provider.version` system property e.g. `System.setProperty("pact.provider.version", "1.0.0-somegitsha")`

matt.fellows
2020-10-01 11:12
example spring boot: https://github.com/pactflow/example-provider-springboot/blob/master/src/test/java/com/example/springboot/ProductsPactTest.java#L34 (probably shouldn?t set that directly in the test, it should live in the gradle file or outside of code)

matt.fellows
2020-10-01 12:52
@bethskurrie :point_up: look what you?ve done

matt.fellows
2020-10-01 13:09
I know @marko.justinek has a v3 compatible Pact Swift he?s raring to get in the hands of mobile devs. Anybody willing to put their hands up to help test and provide early feedback/bug smashing during Hactoberfest?

marko.justinek
2020-10-01 13:43
That would be much appreciated! I can transfer a few of the issues I have on my personal to-do/to-verify/find-alternative list to PactSwift github issues so they could be looked into by anyone willing.

michael_james
2020-10-01 14:33
has joined #general

raghanag
2020-10-01 19:44
Hi @bethskurrie @matt.fellows just a qq, if the provider changes the code and is suddenly breaks lots of consumers, whose responsibility it is to change the code?


michael.miranda
2020-10-01 21:39
has joined #general

wilkinsweiqiangliang
2020-10-01 23:42
Willing to help

wilkinsweiqiangliang
2020-10-01 23:43
Thanks for the answers. Will do more reading on this. :+1:

matt.fellows
2020-10-01 23:47
:raised_hands:

matt.fellows
2020-10-01 23:48
that?d be amazing!

matt.fellows
2020-10-01 23:53
> Hi @bethskurrie @matt.fellows just a qq, if the provider changes the code and is suddenly breaks lots of consumers, whose responsibility it is to change the code? :wave: well? that?s a loaded question!

matt.fellows
2020-10-01 23:54
but, my default answer is the provider. Why are they pushing out breaking changes?

matt.fellows
2020-10-01 23:54
> do you recommend CDC for BFF only https://samnewman.io/patterns/architectural/bff/ you can use Pact for BFFs - are you saying pact is _only_ good for BFFs or if you can use pact to test them?

wilkinsweiqiangliang
2020-10-02 02:08
@matt.fellows Tried setting the env variable and run my test again, doesnt seem to pushing the tag to my broker. Do i need to run gradle/`pact-cli` command to push the version from provider?

wilkinsweiqiangliang
2020-10-02 03:01
nvm, i just got it

robbert.van.der.zon
2020-10-02 07:40
Hi all! I hope this questions isn't asked before too much, but I couldn't find it. I just started using pact for our java microservices and use the cli to upload the contracts, to tag the versions, to run can_i_deploy and to upload verification results. The cli works fine, but when possible, I would like to use the maven (pact-jvm-provider-maven_2.12) plugin so I can just use './mvnw pact:publish' to upload the pact file. This works fine for uploading, but I cannot find if we can use the plugin also for tagging versions and for the can_i_deploy call. Does anyone know if this is possible using the plugin? Or is that only possible with the cli?

lakitna
2020-10-02 07:45
has joined #general

uglyog
2020-10-02 07:51
That's the old version of the maven plugin. The latest one supports can_i_deploy calls

robbert.van.der.zon
2020-10-02 07:58
Thanks for your answer! I am using this version: https://search.maven.org/artifact/au.com.dius/pact-jvm-provider-maven_2.12/3.6.15/jar This seems to be the latest version, but the documentation does not mention the can_i_deploy. Unless I am reading it wrong.

robbert.van.der.zon
2020-10-02 08:04
I see now that I can also use pact-jvm-provider-maven, version 4.0.10, and that has indeed a pact:can_i_deploy. That is not added in the documentation. But tagging a version is not possible? Or is there another way of doing that?

wesleythomaswilliams
2020-10-02 09:24
```-Dpact.provider.tag=```

wesleythomaswilliams
2020-10-02 09:26
Is there more info in here that is useful? https://docs.pact.io/implementation_guides/jvm/provider/maven/

robbert.van.der.zon
2020-10-02 09:58
Perhaps I am not doing it correctly. But for the consumer I am uploading my contracts and give it a tag with the branchname in the build pipeline. But when I have deployed my consumer to production, I tag that version afterwards with the tag 'prd'. (following this: https://docs.pact.io/pact_broker/tags) I do that using the cli with: ```pact-broker create-version-tag ``` As described here: https://docs.pact.io/pact_broker/client_cli/readme

xavier.durairaj
2020-10-02 12:52
has joined #general

seda.urguplu6
2020-10-02 19:44
has joined #general

mateusz.derks
2020-10-03 08:05
has joined #general

hovinen
2020-10-03 15:03
has joined #general

robbert.van.der.zon
2020-10-04 10:49
Hi! I am still trying to get the can_i_deploy working with our workflow, but am still truggling with it. I have the following situation: ? For the consumer I create a git feature branch called ?feature1? and add a new field to an existing contract. We upload this version to pactflow and tag this version with the tag ?feature1?   ? Then I run the master build from the provider. This build is also looking at pending contracts en WIP, so is verifying this contract. This succeeds in this case and marks this as verified. The provider version that verified this contract is marked with ?master?. ? If I manually run the can_i_deploy to master on the consumer build, this is now green (as expected). That means that I could merge my feature branch to master and deploy this to production if I want to. ? However, when in the meantime the master build of the provider has an update and builds again, then this new build is not verifying my ?feature1? contract anymore (because it is not pending anymore). This new build is now marked as ?master?. ? If I run the can_i_deploy on the consumer now, then it is red. This is because the latest ?master? version of the provider has not checked my contract. This also means that I don?t know if I can merge my feature branch to master and deploy to production. Am I doing something wrong, or don't I understand it correctly?

matt.fellows
2020-10-04 23:24
Any mobile devs out there that would be interested in creating an iOS or Android workshop? We have a format that can be followed. It?s about 1 - 2 days? effort based on previous I?ve created an issue for the swift project https://github.com/DiUS/pact-consumer-swift/issues/100 and I?m sure @marko.justinek would be keen to see it created!

tjones
2020-10-05 01:57
I know a couple solid android devs - What's missing from this one? https://github.com/DiUS/pact-workshop-android

matt.fellows
2020-10-05 02:45
It?s just old

matt.fellows
2020-10-05 02:46
Ideally, it be brought in line with the JS workshop (which is the new canonical reference)

2020-10-05 02:57
A post in *Feature Requests* has been marked as *in progress*

m_testslackuser2
2020-10-05 06:05
has joined #general

zelre.stemmet
2020-10-05 06:33
has joined #general

m_greetingsbot3
2020-10-05 06:43
has joined #general

bethskurrie
2020-10-05 07:57
@robbert.van.der.zon I understand your situation. That is a very good question.

bethskurrie
2020-10-05 08:00
I'm going to have to think about how we get around this.

me1276
2020-10-05 08:11
Hey @matt.fellows, I didn?t configure notifications for this workspace so just saw this and configured alerts The event was quite well, it seems that many people are already familiar with PACT and appreciate the idea. That said, not enough tried and implemented it which shows how big is the potential. How do we drive adoption :thinking_face:? My personal thoughts are that there should be a quicker way to start, maybe one-click setup of provider-driven contracts (i.e. OpenAPI validation) and then a way to opt-in for more features with consumer-driven? Buy more influencer in the JS eco-system? Or maybe you are satisfied enough from the growth?:)

robbert.van.der.zon
2020-10-05 08:36
I have created a workaround for myself.  On our provider-master build, after running the normal test, I have created an extra step. In this step, I am creating a list of all tags (using the rest-api of pactflow). Then I run the verification test against all tags (with WIP and pending disabled). This way I know that each master build verifies all latest contract versions. I ignore the test results of this step because I don?t want to fail the build on it.

robbert.van.der.zon
2020-10-05 08:39
I don't really understand why WIP stops verifying a pact with a tag which it has already verified. Is that because of performance?

bethskurrie
2020-10-05 08:40
Because if it didn't stop verifying it at some stage, you'd end up verifying every pact ever in the broker.

bethskurrie
2020-10-05 08:41
maybe that's not a bad thing though :thinking_face:

bethskurrie
2020-10-05 08:42
maybe it should keep verifying them in pending mode until they get deleted :thinking_face:

bethskurrie
2020-10-05 08:43
or they become one of the explicitly supported pacts.

bethskurrie
2020-10-05 08:43
I've just been brainstorming with @antonello

bethskurrie
2020-10-05 08:44
we may have a solution. Are you running your own OSS version of the broker @robbert.van.der.zon or using Pactflow?

robbert.van.der.zon
2020-10-05 08:44
We are using pactflow

bethskurrie
2020-10-05 08:46
Can you PM me your tenant? I might get you to beta test my updated WIP pacts logic when I've thought it though.

robbert.van.der.zon
2020-10-05 08:46
With WIP we can set a date. So all pacts older then that will not be tested anyway. This way you are already avoiding pacts to be tested forever

bethskurrie
2020-10-05 08:47
We don't have to have to continually change that date just to get rid of pacts though.

nazar.khmil
2020-10-05 10:34
has joined #general

xandebianchi
2020-10-05 13:05
has joined #general

dorin.enache
2020-10-05 15:01
has joined #general

ruth
2020-10-05 18:53
has joined #general

phil.endsley
2020-10-05 18:53
@bethskurrie Can you elaborate on what your plan/idea is? I'm curious if this would solve my (and others) issue with having to make a code change to remove selectors for consumer feature branches.

raghanag
2020-10-05 23:14
Hi @matt.fellows in this video they talked about fully automated loop, is it already available now? https://youtu.be/-6x6XBDf9sQ?t=2128

raghanag
2020-10-05 23:49
and also at this https://youtu.be/-6x6XBDf9sQ?t=2175 time, they mentioned about verifying the pact file from consumer and swagger file from provider

bethskurrie
2020-10-05 23:51
> if the provider changes the code and is suddenly breaks lots of consumers, whose responsibility it is to change the code? The provider. There are many alternatives to evolve an API without breaking existing consumers. There is some good advice here https://apisyouwonthate.com/

matt.fellows
2020-10-06 00:57
Anyone keen to contribute an updated version of our Java workshop https://github.com/DiUS/pact-workshop-jvm/issues/20 ? #hacktoberfest

wilkinsweiqiangliang
2020-10-06 00:58
Happy to contribute on this. Would you mind to provide a bit of detail what need to be done?

matt.fellows
2020-10-06 01:13
I?m sorry, that video is almost 5 years old - I can?t remember what ?loop? you?re referring to. But suffice to say, we have verification ?loops? available in Pact. Can you please be more specific?

matt.fellows
2020-10-06 01:14
https://docs.pact.io/pact_nirvana/ and the workshops talk about end-to-end scenarios

matt.fellows
2020-10-06 01:15
So basically, there is a new format of the workshops (https://github.com/pact-foundation/pact-workshop-js and https://github.com/pact-foundation/pact-workshop-go for example) that have been re-designed based on feedback. The JVM workshop uses the original workshop format

matt.fellows
2020-10-06 01:16
What needs to happen is to essentially create a JVM port of the JS/Golang workshops

wilkinsweiqiangliang
2020-10-06 01:16
sure, so jvm port need to be refactor base on the new format i guess

matt.fellows
2020-10-06 01:16
yep!

matt.fellows
2020-10-06 01:16
@uglyog will be able to advise more on the detail when it gets to it (see the comment in the issue above for an example of that), but a spring boot app would be a minimum

matt.fellows
2020-10-06 01:17
The idea is that somebody can run that workshop, and get across all of the key concepts by the end of it - provider states, dealing with authorisation, matching rules etc.

uglyog
2020-10-06 01:19
Prob better to just create a new springboot workshop based off the JS one than upgrade the existing

uglyog
2020-10-06 01:20
As long as make gets removed from it :smile:

wilkinsweiqiangliang
2020-10-06 01:24
oh, those MAKE files. yea, find it a bit hard to read at the beginning

raghanag
2020-10-06 01:32
sorry in that video he is referring to making the verification automatic by comparing the consumer pact file with provider swagger spec which you mentioned in case of provider driven testsing

michael_james
2020-10-06 09:46
@matt.fellows I've been updating the .Net Core one as it's .Net Core 2 not 3.1 which is the LTS version, also fixing some bad habits of not awaiting async code, do I PR to the original workshop?

michael_james
2020-10-06 09:48
I started the PR here: https://github.com/tdshipley/pact-workshop-dotnet-core-v1/pull/16 But believe there will be a few other changes

matt.fellows
2020-10-06 11:56
That?s great, thanks!

matt.fellows
2020-10-06 11:57
Any contribution is fantastic, so this is a great start

matt.fellows
2020-10-06 11:57
Ultimately, it?s tdshipley?s IP. But ideally, we?d love to move it to the pact-foundation so it is more visible etc.

matt.fellows
2020-10-06 11:57
I?ll ask on the repo and see what we can do?


matt.fellows
2020-10-06 11:59
Could be a good #hacktoberfest?

michael_james
2020-10-06 12:43
failing that, i could look at using your new JS example and converting to .net core. But only if tdshipley doesn't want to maintain it

michael_james
2020-10-06 12:45
I'm happy either way as I'm looking at how I can onboard our company and writing internal training for us.

ledinhcuong99
2020-10-06 12:53
has joined #general

matt.fellows
2020-10-06 13:12
they released a tool called Atlassian Mock Validator which can do that check - we?ll be adding similar support into Pactflow shortly too. So, yes :slightly_smiling_face:

matt.fellows
2020-10-06 13:15
Oh, sorry I missed the thing about Hoverfly

matt.fellows
2020-10-06 13:15
Hoverfly is a service virtualisation tool, and Pact is sort of one also. But not as a general purpose one. It has service virtualisation in it, but it?s purpose is about ensuring systems are compatible with one another. Hoverfly does not do that bit, but it is a general purpose SV tool

matt.fellows
2020-10-06 13:20
As described in that issue, we?d appreciate an upgrade to the latest workshop format - it covers all of the key concepts, and is consistent with others we have and will continue to build. That makes it much more helpful when moving between languages to compare/contrast etc.

matt.fellows
2020-10-06 13:21
No pressure either way, but I?m happy to create the repo on Pact Foundation and grant access to you folks to contribute to.

matt.fellows
2020-10-06 13:21
But I get that @thomas.shipley might want to get the Github kudos - so whatever works

matt.fellows
2020-10-06 13:22
haha

matt.fellows
2020-10-06 13:22
is there a make file in the pact JS workshop? hmmm

matt.fellows
2020-10-06 13:22
I don?t think so

matt.fellows
2020-10-06 13:23
the CI/CD workshop (and yes, people like to tell us that :stuck_out_tongue: )

thomas.shipley
2020-10-06 13:28
@matt.fellows happy for you guys to take ownership of it

thomas.shipley
2020-10-06 13:30
I have neglected it a bit I must admit :disappointed: - been on my todo list for a while to spruce up. But could help tidy it under the Pact Foundation banner perhaps?

matt.fellows
2020-10-06 13:33
Don?t feel bad!

matt.fellows
2020-10-06 13:34
It?s a piece of art with 50 stars (I think that?s more than all of our other workshops!)

matt.fellows
2020-10-06 13:34
If you want to transition ownership to pact-foundation, we can start the ball rolling on the upgrade (e.g. the PR from Michael) and then from there, the new format

matt.fellows
2020-10-06 13:34
How does that sound?

thomas.shipley
2020-10-06 13:55
Sounds great :slightly_smiling_face: - happy to transition it :thumbsup:

thomas.shipley
2020-10-06 14:03
@michael_james I can take a look at your PR now

matt.fellows
2020-10-06 14:03
Thanks. I think you need to initiate the transfer. Let us know when it's done and we'll make it happen!

thomas.shipley
2020-10-06 14:08
Looks like I need some permissions to create a public repo on pact-foundation to do the transfer...

thomas.shipley
2020-10-06 14:08
That came up after going through _Transfer Ownership_ in the Danger Zone of my projects repo settings

ruth
2020-10-06 16:00
Hey all! what are the best video resources to learn how to integrate pact and pactbroker into your services?

raghanag
2020-10-06 20:40
thanks @matt.fellows but i do have one question, do you recommend CDC to the consumers who entirely uses SDK?s provided by the providers instead of end points or their own clients. For example if you do then they have to write their own mock providers with their own endpoints in the path like below ```path: '/product/10'``` but provider need not to follow the same endpoint on their end, but the SDK?s they provide will know about all this

raghanag
2020-10-06 21:14
in case if the consumer enters wrong endpoints for their mocking, then the pact file will not be used against provider right? I am trying to understand where this CDC can fit in case of SDK?s instead of own consumer clients

2020-10-06 22:19
A post in *Feature Requests* has been marked as *in progress*

matt.fellows
2020-10-06 22:53
Howtolearn

2020-10-06 22:53
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2020-10-06 22:54
There is at least one video course there

matt.fellows
2020-10-06 22:54
We know, we need more!


matt.fellows
2020-10-06 23:05
There are trade offs

matt.fellows
2020-10-06 23:06
I still write pact tests for them

wilkinsweiqiangliang
2020-10-06 23:07
i had a look, we currently still have MAKE file in `example-provider-java-kafka` repo, and from my understanding it mainly handle the `can-i-deploy` script. Also went through some docs in pactDoc, dont see a way we can handle this by gradle or any other plugin. i think we still need to use MAKE?

matt.fellows
2020-10-06 23:14
They?re the examples - we use Make to keep them all consistent.

matt.fellows
2020-10-06 23:14
Make is absolutely not required

matt.fellows
2020-10-06 23:15
`can-i-deploy` is just a CLI call - you can use a docker image or the standalone tools to use it

wilkinsweiqiangliang
2020-10-06 23:15
how does the jvm use can-i-deploy currently? i would assume there is a config in gradle

matt.fellows
2020-10-06 23:15
it doesn?t, there?s no need to have it any any language - we have a CLI for that purpose


wilkinsweiqiangliang
2020-10-06 23:18
i c, i was confused with gradle build process, i was assuming `can-i-deploy` is embedded in the gradle life-cycle. So it run after gradle build as a cli command

matt.fellows
2020-10-06 23:21
yep, that?s what I?d do

ruth
2020-10-06 23:24
Thank you!

wilkinsweiqiangliang
2020-10-06 23:25
cool, thats good point. What about using list of PARTICIPANT, is it anyway to feed in list of PARTICIPANT in cli command rather than putting them one by one? ``` pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL```

bethskurrie
2020-10-06 23:25
no

matt.fellows
2020-10-06 23:25
What are you trying to achieve?


matt.fellows
2020-10-06 23:26
99% of the time, you just need to put the pacticipant of the service you?re deploying (e.g. the consumer or the provider). It will automatically determine the integrations to check compatibility with

bethskurrie
2020-10-06 23:26
if you have to put in more than 1 pacticipant, you're probably not using the recommended workflow, or you're doing something advanced like checking a mobile consumer where you want to ensure you've verified ALL prod versions, not just the latest.

bethskurrie
2020-10-06 23:27
This is a good doc to read to understand how it works https://docs.pact.io/pact_broker/can_i_deploy

wilkinsweiqiangliang
2020-10-06 23:30
i just thinking it loud atm, what about we had a mono repo that contains a few consumers, instead of verify all of them, i need to workout which one is deploying (maybe all) and generate the corresponding cli command

bethskurrie
2020-10-06 23:31
I'm confused why this is such a thing recently.

bethskurrie
2020-10-06 23:31
Why make microservices if you deploy them all together?

bethskurrie
2020-10-06 23:31
That's just a distributed, coupled monolith.

wilkinsweiqiangliang
2020-10-06 23:31
historical reason lol

matt.fellows
2020-10-06 23:32
it?s very common to deploy serverless architectures (e.g. lambdas) together, for example Beth

bethskurrie
2020-10-06 23:32
the pact is meant to be made on the deployable unit.

bethskurrie
2020-10-06 23:32
so maybe there should just be one pact!

matt.fellows
2020-10-06 23:32
perhaps

matt.fellows
2020-10-06 23:32
But one of the benefits of the broker, is you get this fine grained view

bethskurrie
2020-10-06 23:33
anyway, you would need to either call can-i-deploy once for each of them, or create a selector (--pacticipant A --version X) for each of the sub applications.

wilkinsweiqiangliang
2020-10-06 23:34
cool great. in JVM application we are using, it contains JAVA, lambda, and TS also react in one repo

matt.fellows
2020-10-06 23:34
:exploding_head:

wilkinsweiqiangliang
2020-10-06 23:34
gradle handle the most heavy lifting

matt.fellows
2020-10-06 23:35
you could create a gradle shell task that executes can-i-deploy (or execute the docker image)

bethskurrie
2020-10-06 23:35
so, when you say, can you create a list, then answer is that you can repeat "--pacticipant P --version V" as many times as you like, but you can't say "--pacticipant A B C"

wilkinsweiqiangliang
2020-10-06 23:36
i got the idea now

bethskurrie
2020-10-06 23:36
The CLI docs provide many different examples and should explain it clearly.

matt.fellows
2020-10-06 23:42
FYI can we move this to a new thread if we want to continue it? Just realised we?ve hijacked the hacktober one :grimacing:

bethskurrie
2020-10-07 02:26
@phil.endsley @robbert.van.der.zon @antonello I think I've updated the WIP logic to behave the way we want it to. I've written a bunch of tests to work through all the potential scenarios. This is the one that reflects your usecase @robbert.van.der.zon https://github.com/pact-foundation/pact_broker/blob/2a11c32096/spec/features/wip_pacts_spec.rb#L203

bethskurrie
2020-10-07 02:27
The change I've made to the original logic is that successful verifications that happen when a pact is included as a WIP one do not stop it from being WIP any more. It only stops being WIP for a particular provider tag once it has been *explicitly selected* AND successfully verified.

bethskurrie
2020-10-07 02:28
The outcome of this is that a pact on a feature branch keeps being WIP until it has been merged into master.

bethskurrie
2020-10-07 02:31
One interesting side effect of this change is that if a WIP pact passes verification on master, it is still WIP, BUT it is no longer pending, because I haven't updated the pending logic. I'm not sure if I should or not. Here is the line in the test that shows this behaviour https://github.com/pact-foundation/pact_broker/blob/2a11c32096/spec/features/wip_pacts_spec.rb#L236 It means that a WIP pact *could* now break the provider's build, if it was verified successfully, then a regression was made that caused it to fail. What are everyone's thoughts on this?

bethskurrie
2020-10-07 02:33
@phil.endsley I'm going to start a new thread to discuss your question about changing selectors in the pact broker channel

bethskurrie
2020-10-07 05:41
I've added pages for the recommended configuration for publishing and verifying pacts ? https://docs.pact.io/consumer/recommended_configuration ? https://docs.pact.io/provider/recommended_configuration TODO is to add more details and examples for each language.

bethskurrie
2020-10-07 07:47
Ok, I've given the "pending" issue more thought, and I think it should stay as it is. The consumer may have merged based on the fact that the pact has passed verification, so it shouldn't then go back to being unsuccessful without the provider being alerted to it.

robbert.van.der.zon
2020-10-07 07:54
Seems logical and I think that this would work for me like the way that you described it!

preethighalke
2020-10-07 08:23
Hi, can we order the sequence of the pact interactions in a consumer test? i'm using pact junit/JVM . I see https://github.com/pact-foundation/pact-ruby/issues/48 set as implemented, can you help with the API refernce and usage sample. Thanks & Regards

bethskurrie
2020-10-07 08:23
It's not recommended.

bethskurrie
2020-10-07 08:24
Each interaction should be verified with complete isolation from every other interaction.

preethighalke
2020-10-07 08:24
The verification team is requesting us to send them the interactions in a particular order and i was seeing if there is a possibility

bethskurrie
2020-10-07 08:24
Otherwise we get back into the whole "this test fails because the earlier test didn't work properly" scenario that we have in system integration tests.

bethskurrie
2020-10-07 08:25
The verification team misunderstands how to use pact.

bethskurrie
2020-10-07 08:25
if you cannot use provider states to set up the right data for each interaction, then pact is not a good fit for your situation.



preethighalke
2020-10-07 08:27
I agree but then i was seeing if there is a possibility of setting the order in the consumer test

bethskurrie
2020-10-07 08:27
I can't tell you for pact-jvm, but I strongly strongly recommend against having ordering dependencies.

bethskurrie
2020-10-07 08:28
Get your verification team to chat to us on slack to see if we can help them come up with an alternative solution.

preethighalke
2020-10-07 08:29
i see your point of view sure will try putting across the views

preethighalke
2020-10-07 08:29
many thanks Beth for your quick informative response

bethskurrie
2020-10-07 08:29
you're welcome

preethighalke
2020-10-07 08:29
have a good evening

preethighalke
2020-10-07 08:29
thanks again

bethskurrie
2020-10-07 08:30
when pact is used in ways that it is not designed for, it can make life as bad as when you're using integration tests. I don't want you to get stuck there!

preethighalke
2020-10-07 08:31
i agree somewhere i'm seeing they are driving this to be a semi integration test instead of what it is meant for

bethskurrie
2020-10-07 08:32
best to use a different tool for that, in my opinion

bethskurrie
2020-10-07 08:32
right tool for the right job.


preethighalke
2020-10-07 08:32
agree

bethskurrie
2020-10-07 08:32
good luck!

preethighalke
2020-10-07 08:33
:slightly_smiling_face: thank you

dothetan.040490
2020-10-07 09:14
has joined #general

sklein
2020-10-07 15:01
anybody have a general demo workflow they use to introduce how pact works to others that they'd be willing to share. Just looking for something simple like 1. create the consumer contract 2. implement the provider validation 3. change the consumer contract... etc etc etc

phil.endsley
2020-10-07 18:12
Looks like there was an update to the rules. There's some work needed by maintainers in order for PRs to be officially "counted" towards the event. https://hacktoberfest.digitalocean.com/hacktoberfest-update

tjones
2020-10-07 22:41
Good catch @phil.endsley ! I've added that tag to pact-js and pact-node

matt.fellows
2020-10-07 22:44
awesome, thanks!

marko.justinek
2020-10-07 22:56
The few issues perfect for Hactoberfest in https://github.com/surpher/PactSwift/projects/3 repo have been collated in a Hactoberfest 2020 project :thumbsup:

dagostino.remy
2020-10-07 23:03
has joined #general

matt.fellows
2020-10-07 23:04
Don?t forget to add the `hacktoberfest` topic too Marko!

marko.justinek
2020-10-07 23:07
yep, will do

matt.fellows
2020-10-08 00:09
I have one I do with Pactflow customers Sean, I can?t recall if I did it with you (I think not because you did a lot of homework).

matt.fellows
2020-10-08 00:09
Happy to share the demo deck and example projects I use?

matt.fellows
2020-10-08 00:14
Just dropped you an email with some stuff

matt.fellows
2020-10-08 00:14
It?ll all eventually be made public, just not fully tidied up yet

matt.fellows
2020-10-08 00:15
Happy to chat with the team also if that would be helpful!

abhi.nandan
2020-10-08 06:38
has joined #general

sambitkumar.pal
2020-10-08 09:17
I am running consumer driven contract test using pact broker inside codefresh. Pact broker webhook will execute only when the specified event occurs. So for 1st time when contract published by consumer then webhook will create. But the webhook will not trigger the provider build because the event has not occur (1st time) . Then if we need to again run consumer build to recognise the event. Can you please help me to know how I can execute the webhook http request in 1st time itself when it created.

giuseppe.salvatore
2020-10-08 12:30
Hi everyone, I know this might sound a silly question but is there any way from the broker to get easy to read information about the interactions that failed on the provider? I know you can have that info from the inspector and look into response body but it's kind of complicated to find what you are looking for. Also when you get the diff between expected and actual it is a bit difficult to immediately understand what's wrong... something like this ```"class": "RSpec::Expectations::ExpectationNotMetError", "message": "Actual: {\"code\":\"60\",\"message\":\"Resource not found\"}\n\nDiff\n--------------------------------------\nKey: - is expected \n + is actual \nMatching keys and values are not shown\n\n {\n- \"threeMonthAverages\": {\n- \" ... }\n }\n\nDescription of differences\n--------------------------------------\n* Could not find key \"threeMonthAverages\" (keys present are: code, message) at $\n" ```

matt.fellows
2020-10-08 12:32
Not in the OSS broker, I think there is a feature request for that (somewhere on GH)

giuseppe.salvatore
2020-10-08 12:32
Thanks Matt... good to know


giuseppe.salvatore
2020-10-08 12:33
yeah our next step was to take a look at the Pactflow and see if it fits our needs

przemyslaw.dabrowski
2020-10-08 12:36
has joined #general

giuseppe.salvatore
2020-10-08 12:37
@matt.fellows is the developer plan limited in time or just in features/contracts?

giuseppe.salvatore
2020-10-08 12:47
just signed up

matt.fellows
2020-10-08 13:06
:wave:

matt.fellows
2020-10-08 13:06
just limited in features/contracts

matt.fellows
2020-10-08 13:06
Drop me an email, and I can bump your limits - are you doing a PoC with your team?

giuseppe.salvatore
2020-10-08 13:07
I did already last week and it went so well other teams wanted to hear more

giuseppe.salvatore
2020-10-08 13:08
and managers asked me to evaluate the Pactflow

giuseppe.salvatore
2020-10-08 13:08
is it ok if I let you know a few days before the other demo to bump the limits?

giuseppe.salvatore
2020-10-08 13:08
I don't want to take advantage of the kind offer :wink:

matt.fellows
2020-10-08 13:10
Of course :stuck_out_tongue:

emiliano.righi
2020-10-08 13:25
has joined #general

sklein
2020-10-08 13:31
Champion! Thank you!

emiliano.righi
2020-10-08 13:48
Hi everyone, I am testing a webhook that triggers a jenkins x build. ```{ "consumer": { "name": "api-v2" }, "provider": { "name": "some provider" }, "request": { "method": "POST", "url": "http://jenkins.jx.mydomain.com/job/....../build", "username": "<my username>", "password": "<some-password>", "headers": { "Accept": "application/json" } }, "events": [ { "name": "contract_published" } ] }``` And I get a HTTP 403 ``` "x-you-are-authenticated-as": "anonymous", "x-you-are-in-group-disabled": "JENKINS-39402: use -Dhudson.security.AccessDeniedException2.REPORT_GROUP_HEADERS=true or use /whoAmI to diagnose", "x-required-permission": "hudson.model.Hudson.Read",``` It seems to me the my execution is not sending my credentials since it reports I am authenticating as anonymous. I confirm that my credentials work and I have tested jenkins build with curl successfully. Thanks for the help.

robbert.van.der.zon
2020-10-08 14:58
Hi all! I am a big fan of BDD. We try to create a functional test for each feature we are creating. Our current landscape is that we have 16 microservices working together. All these services are owned by our own team. Besides these 16 microservices, we have some other external services. We currently have an end-to-end test setup that mocks all external services but our own 16 microservices are all connected in these tests. All our BDD functional tests are inside these end-to-end tests. We have a big trust in these tests and have the feeling that we can pretty easy change any microservice, and if the end-to-end tests succeed, we know that we can safely deploy our code. But the more microservices we get, the more difficult it gets to run these tests locally, and the more features we get, the longer it takes to run these tests. We are now looking for a way to reduce the end-to-end tests, and do more contract testing and functional testing within the microservices itself. But I have a hard time trusting that way of testing the same way as I have with the end-to-end tests. Now we have all our functional tests together in one git-repo. This is very clear and organized. Also, from a functional point of view, I don?t care which microservice is responsible for some functionality, I just want something some behavior to be done by the system, and that is what I test. E.g. given some input, we want an order to be created in our SAP system. Our end-to-end test just test that we call SAP with the correct payload to create the order. It doesn?t matter which microservice does that. If we move our functional tests out of our global end-to-end tests, and to the microservices itself, then I am afraid that we lose a good view on it. It gets scattered around. Also, the tests needs to know a bit more about how the microservices work together. I have a hard time to get an idea how to do this, with the same trust as we have right now. I know that having one big set of functional tests will not be able to work as we keep growing. I am trying to look for documentation, books or video?s of how to do BDD (with a lot of functional tests), but with a minimum of end-to-end tests (only for checking the connection between the services) and with contract tests to test the interaction between our microservices and more functional test within the microservices itself. Since you are all doing contract testing, I was hoping that someone can lead me in the right direction.

jarmy
2020-10-08 16:26
I was able to get this to work by using a token. Here?s an example: ```{ "description": "Trigger GraphQL Acceptance Test Job on contract_content_changed event from Pegasus", "provider": { "name": "graphql" }, "consumer": { "name": "pegasus" }, "events": [{ "name": "contract_content_changed" }], "request": { "method": "POST", "url": "https://listeners.jenkins-sb.savagebeast.com/job/listeners-acceptance/job/graphql/job/DEVTOOLS-610-test-pact-broker-webhooks/buildWithParameters?os_authType=basic&environment=shared&graphqlHost=shared.graphql.docker.savagebeast.com", "username": "<USERNAME>", "password": "<TOKEN>", "headers": { "Accept": "application/json" } } }```

emiliano.righi
2020-10-08 16:44
Thanks a lot Jason, I am going to try it.. :slightly_smiling_face:

wilkinsweiqiangliang
2020-10-08 20:15
Hi everyone, im getting ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException at PactJUnit5VerificationProvider.kt:426``` in gradle build while the pact file is available in pactflow. And tried to run in idea, it pass. any suggestion?

phil.endsley
2020-10-08 20:16
I'd ask in the language channel for specific questions #pact-jvm

wilkinsweiqiangliang
2020-10-08 20:29
Thanks @phil.endsley

cariaga.bh
2020-10-08 21:03
has joined #general

wilkinsweiqiangliang
2020-10-08 21:25
The issue is being a mistake of pass the token into the docker container, i think the exception is a bit misleading.

jarmy
2020-10-08 23:22
I had a question about https://docs.pact.io/provider/recommended_configuration/. Specifically, how would one verify a contract they?re developing using `consumerVersionSelectors`? Would we just add a selector to the Pact verification test that matches the tagged branch from the consumer test and then remove that selector before merging? Here?s how we have our selectors currently defined ``` consumerVersionSelectors = [ VersionSelector(tag = "develop"), VersionSelector(tag = "mobile-test"), VersionSelector(tag = "DEVTOOLS-641-integrate-pact-consumer-test"), VersionSelector(tag = "production", latest = false.toString()) ]``` Currently, if I exclude the consumer _branch_ tag, the provider verification fails with ```au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify Provider: pegasus Source: Pact Broker https://pact-broker.docker.savagebeast.com: consumerVersionSelectors=[ConsumerVersionSelector(tag=develop, latest=true), ConsumerVersionSelector(tag=mobile-test, latest=true), ConsumerVersionSelector(tag=production, latest=false)] ``` This puts the provider in a bind since they can?t get a PR build to pass until the consumer merges their branch into develop.

abubics
2020-10-08 23:23
Hey :smile: first of all, it sounds like you have great coverage and rigour, so congratulations! :tada:

abubics
2020-10-08 23:24
I also love BDD as a testing lens & direction. I write my unit tests in that style, for high coverage, and usually have only a light touch on functional end-to-end tests, as a post-deploy smoke test, before re-routing traffic.

abubics
2020-10-08 23:26
My initial advice would be, don't try to replace or get rid of your functional tests in favour of contract tests. They bring great confidence (as you know), but grow combinatorially. Rather, be exhaustive with unit tests (and Pact is basically unit tests for the network interface), and less exhaustive with integrated tests.

campellcl
2020-10-09 00:06
has joined #general

bethskurrie
2020-10-09 05:52
@jarmy does this answer your question https://docs.pact.io/provider/recommended_configuration

bethskurrie
2020-10-09 05:53
I can't see from that config why there are no pacts though

bethskurrie
2020-10-09 05:54
Seems like a bug to me. It should be finding all the other pacts.

bethskurrie
2020-10-09 05:54
Also, if this is a pact-jvm question, best to ask it in #pact-jvm



bethskurrie
2020-10-09 05:59
As the wonderful @abubics says, pack as much as you possibly can into the pact tests (you won't be able to cover everything, but do as much as makes sense) and then start removing e2e tests that are basically just there to make sure the right calls are being made.

bethskurrie
2020-10-09 05:59
keep the ones that are ensuring that the overall business value of your system is being delivered.

mateusz.derks
2020-10-09 06:53
> The outcome of this is that a pact on a feature branch keeps being WIP until it has been merged into master. How is it determined that the feature was merged into main branch? Does it compare content of the pact with the selected tags?

bethskurrie
2020-10-09 06:53
yes

bethskurrie
2020-10-09 07:02
To summarise, "successful verification of a pact version (ie. the content) when it has been explicitly selected for verification causes it to not longer be included as a work in progress pact"

matt.fellows
2020-10-09 08:00
He did mention that page explicitly Beth, so i hope so :joy:

emiliano.righi
2020-10-09 09:43
Sadly same problem. I wonder what I am doing wrong.

elenitsaa043
2020-10-09 10:00
has joined #general

phil.endsley
2020-10-09 10:35
Does the provider have any of the other tags published yet (develop, mobile-test, or production)? Is this the first set of pacts? If so, I think the usual advice given is "do what you need to to get the first set in, since that's an abnormal case". We usually use `@IgnoreNoPactsToVerify` for the first pacts being implemented, then remove it on a later PR If that's not the case, something else is wrong here (likely just config)

adriangabrieloros
2020-10-09 11:05
has joined #general

emiliano.righi
2020-10-09 12:35
I have tried allowing anonymous login in jx and it worked.

jarmy
2020-10-09 15:40
Woot! Nice that you have control over your Jenkins infra.

jarmy
2020-10-09 16:31
This _is_ the first set of pacts and seems to be a chicken and egg problem. I can use Phil?s suggestion on `@IgnoreNoPactsToVerify` to workaround the issue.

jarmy
2020-10-09 16:33
Phil, correct me if I?m wrong but I think you meant to say ?Does the _consumer_ have any of the other tags published yet (develop, mobile-test, or production)??

phil.endsley
2020-10-09 17:39
Yes, thank you. Definitely what I meant :slightly_smiling_face:

jarmy
2020-10-09 17:40
phew. thanks for confirming

robbert.van.der.zon
2020-10-09 19:08
I?ve read (parts) of the ?practical test pyramid? of Fowler before and actually one thing he says has always triggered me: _?The concept of acceptance tests - proving that your features work correctly for the user - is completely orthogonal to your test pyramid?_.  I?ve used that as a confirmation that it?s logical that we do not follow the test-pyramid because when you do BDD, you have so many end-to-end tests (in our case). After re-reading the article again, I see that he also says that functional tests doesn?t have to be at a high level (as end-to-end tests), but when possible you can move them to a lower level (as unit tests or component tests). He is basically giving the same advice as @abubics and @bethskurrie are giving me. I will take that advice and see if we can move some functional tests to the services itself and remove them from the end-to-end test suite. That will however scatter our functional tests (which are now all nice together) to the different microservices. But because that are written in gherkin it?s perhaps more easy to distinct the functional tests from the rest of the tests.  Since we see our functional tests as our functional specification of the application, it would be nice to easily show all these tests somewhere. Since they are not in 1 git repo anymore this way, we can perhaps create an agent that scan?s all repo?s and put all functional tests together on a wiki. Not sure if this is really needed however and how that would look like. Perhaps also a bit overkill, but perhaps also handy. I think I need to give this all a bit more thoughts. Thanks anyway for your responses!

wilkinsweiqiangliang
2020-10-10 04:28
When using spring/junit 5, like springbootTest annotation, and gradle command to run `pactVerify` . Any example? im getting connection refuse on 8080. seems i need to start the app in gradle.

wilkinsweiqiangliang
2020-10-10 04:32
seems like i should be use something similar to this ``` task startTheApp(type: SpawnTask) { commandLine 'java', '-jar', '../test_provider/build/libs/test_provider-all.jar' waitFor 'Ratpack started for http://localhost:5050' } task killTheApp(type: KillTask) { kills startTheApp }```

matt.fellows
2020-10-10 08:46
Might be better of asking in #pact-jvm

sh.ilgam_pact
2020-10-11 16:12
has joined #general

matt.fellows
2020-10-12 00:00
:wave: Happy Monday everyone! I wanted to share some exciting community news. Next week @antonello will be representing Pact at an API testing panel - it is shaping up to be quite in interesting conversation: https://commited.tech/events/api-testing-panel-discussion/ Topics on the agenda: ? The mechanics of API testing ? The differences in approaches of different tools ? The best features of known tools ? QA Processes when using API test automation ? How API Automation should influence Unit&Integration&e2e testing ? The role of Contract Testing Get along to support him, or if (like us) it?s going to overlap with your sleep you can stream it after on Youtube.

matt.fellows
2020-10-12 00:10
In the second announcement, Pierre Vincent (long time pact advocate) will be running a Pact workshop at Testbash Netherlands, including CI/CD integration. If you?d like to get hands-on and gain some wisdom from somebody who?s also a leader in the DevOps field, I?d highly recommend it: https://www.ministryoftesting.com/events/testbash-netherlands-online-2020-workshops-day

aforeman
2020-10-12 00:39
Awesome @antonello!

abubics
2020-10-12 00:56
Sounds like you've got an adventure ahead of you :party_parrot:

bethskurrie
2020-10-12 00:57
@robbert.van.der.zon this is one of the trade-offs that gets made when moving to microservices!

bethskurrie
2020-10-12 00:58
The downside of splitting prod code up is that you then need to either split your test code up too, OR you end up re-coupling your prod code in the test code.

abubics
2020-10-12 00:58
One thing I think you'll find is with the functional tests split across multiple repos, you'll get a more granular picture of things that may be broken at any time, rather than the entire functional spec being partly broken. And just because one part is currently not deploying doesn't mean the spec is broken :sunglasses:

abubics
2020-10-12 01:06
Yeah, good to ask in #pact-jvm . . . but yes, if you don't want to specify the provider side as unit tests, you'll need the app to be running, with a state-change endpoint available.

robbert.van.der.zon
2020-10-12 05:33
@abubics: I am not sure that I understand what you mean.

abubics
2020-10-12 05:35
One part of what I"m saying is: rather than relying on inspecting build artifacts to see which part of the tests is broken, you'll have more granular builds and test sets that break.

abubics
2020-10-12 05:37
The other is: once you're further down the https://docs.pact.io/pact_nirvana/, you'll be able to tell that your components don't work together before you've deployed them.

abubics
2020-10-12 05:39
The goal here is to reduce cycle time, while still maintaining confidence :ok_hand: More granularity means less hunting through test outputs, and more specific tests that require less interpretation.

mcruzdrake
2020-10-12 09:47
This is great! Thanks for sharing :slightly_smiling_face: I will share it to my team

anastasiia.bielik
2020-10-12 11:13
has joined #general

robbert.van.der.zon
2020-10-12 11:13
I understand that you get a quick feedback when each microservice has a good set of contract tests and a set of BDD tests to verify that the functional specification of this microservice are met. But I can also imagine that if you have a system with 30 microservices, each having their own functional specifications (and their corresponding BDD tests), that it will be hard to get the confidence that all these separate functional specifications are drawn up in such a way that the global system specifications will be met for all situations.   For the system as a whole, you only do a smoke test, and trust that all the individual specifications are sufficient. I think that it depends on the kind of system that you are building to see that as a problem or not.

hamzahuk
2020-10-12 11:40
Hey all, I have a question (probably a couple!) and am looking for a little help. I'd like to get a better understanding of the journey of a contract, more so for a CI perspective. I've created a contract on the consumer side, great. I can then relatively easily upload this to our pact broker. Happy days! Its at this point I'm a little unsure about the journey. Pact tests will run on every new build of the app. I would only like to publish a new contract (with a new version) if the contract has changed which would trigger some downstream builds to occur and verify against the new contract. My issue is that I don't always want to publish - in the majority of cases, the contracts will be unchanged. How do I make this decision? Does the pact broker provide a simply compare before publish API? Any such functionality I can add to my publish script (this is all javascript using pact-js). In my head all I need to do is a diff (except the version) on the contracts to determine whether any further downstream work is required. I can see that via the broker I can pull an existing pact and then handball the diff if I need to. Is there a better way to do this? I guess I'm looking for a "isUpdated" check against the existing contract. Anyhow, thank you in advance for any help :)

matt.fellows
2020-10-12 12:36
Just on mobile so I wont be able to provide a detailed response. But, don't fear publishing to the broker, it is clever enough to detect changes in the contract. If the contract hasn't changed the version of the consumer will already be compatible with any provider that has verified it

antonello
2020-10-12 12:37
My recommendation would be to publish every time. The broker knows if the pact has changed between different uploads. It?s important to always upload so that a corresponding pacticipant version is created on the broker for every consumer pipeline, regardless of whether the content of the pact has changed.

matt.fellows
2020-10-12 12:37
Can-i-deploy is the feature that gives you the check

matt.fellows
2020-10-12 12:37
See the effective pact / CI/cd guide on our docs

matt.fellows
2020-10-12 12:38
Also the CI/CD workshop in howtolearn :point_down:

2020-10-12 12:38
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

antonello
2020-10-12 12:39
As @matt.fellows says, can-i-deploy will tell you if the contract you have publish is ?pre-verified?, which means that you can skip the provider verification. If you decide to use webhooks - they can be triggered only when the content of the pact changes.

hamzahuk
2020-10-12 12:51
Ace, don't know why i didn't think of that. @antonello just a quick check, the can-i-deploy hook, when you say content has changed, that excludes the version?

antonello
2020-10-12 12:53
Mixing two things here: `can-i-deploy` is a command exposed by the pact cli, which can tell you whether a specific consumer version is compatible with one or more providers. If the a pact was verified before and the content has not changed, then it would be considered pre-verified. The webhook mechanism is different: it?s a request that the broker can make on your behalf to trigger the provider?s pipeline, which can be conditional on whether the content of the pact has changed.

antonello
2020-10-12 12:54
If with version you meant the pacticipant version, that is excluded yes - it?s only based on a hash of the pact content (the pact file), which doesn?t include the pacticipant version (it?s an external concept to the pact file).

antonello
2020-10-12 12:55
But be mindful that nothing should change in the content of the pact, as in the data needs to be static.

hamzahuk
2020-10-12 13:03
I see - apologies for the confusion - I'm specifically talking about the consumer version sent on a publish: consumerVersion: '1.0.1' < this will be updated per build but that doesn't mean that the contract has changed - so lets say a bug fix triggers the build, the pact test will run and the version on merge will go to 1.0.2 - If the contract should be kept in sync with 1.0.2 then thats fine but I wouldn't want this to trigger a build because the content of the pact hasn't been updated. @matt.fellows that implementation guide looks great, I must of have missed this.

antonello
2020-10-12 13:04
yes, that consumer version has nothing to do with the checks we were talking about.

hamzahuk
2020-10-12 13:04
(also, apologies, I should have spent more time browsing the website :persevere:)

hamzahuk
2020-10-12 13:04
Brill, thanks guys - mega helpful!!

antonello
2020-10-12 13:06
if the content of the pact published by v 1.0.1 was `abcd` and then v 1.0.2 publishes again `abcd` , if your provider had already verified 1.0.1, then 1.0.2 will be considered pre-verified (provided that we?re talking about the same provider version, if the provider version has changed, its own pipeline will have to verify the latest version published by the consumer, which is why it?s important to always publish regardless of whether the pact has changed).

deepika.krishnakumar
2020-10-12 15:03
has joined #general

emiliano.righi
2020-10-12 15:46
It worked changing pact-broker version?

2020-10-12 20:42
A post in *Feature Requests* has been marked as *closed*

anbansal27
2020-10-12 23:02
has joined #general

anbansal27
2020-10-12 23:28
Hi Team, I am currently looking out for a solution to integration test event driven systems using RabbitMq as the messaging platform. Does Pact support it ? If yes, please could you help me with links to some resources ?

matt.fellows
2020-10-13 00:05
Message Pact is the term we use for this. Which language are you using? Not all support it natively at the moment

anbansal27
2020-10-13 00:17
I am using C# with .Net Core

matt.fellows
2020-10-13 00:24
You should ask in #pact-net to get the current state of affairs, I think you may need to use an beta/experimental branch

anbansal27
2020-10-13 00:26
Will do, thanks Matt

olarrmide
2020-10-13 00:47
Hi Folks, anyone have experience successfully running pact-node from a windows mapped network drive? I am able to install the npm packages but starting my tests throws this error: _CMD.EXE was started with the above path as the current directory. UNC paths are not supported. Defaulting to Windows Directory._

bethskurrie
2020-10-13 00:47
There's a challenge. Best to ask in #pact-js

olarrmide
2020-10-13 00:49
Thank you @bethskurrie

bethskurrie
2020-10-13 00:49
:taco: for @antonello for being the person who I think understands the internals of the broker logic almost as well as I do!

abubics
2020-10-13 01:40
Of course this is a valid concern :slightly_smiling_face: It necessitates a shift in perspective and trust, otherwise you'll have to keep thorough integrated tests. During the transition, you'll discover gaps, and need to work out how to fill them to replace that confidence.

bethskurrie
2020-10-13 01:42
The old confidence/agility tradeoff.

abubics
2020-10-13 01:44
To that end, you'll want to de-risk your changes, do them in small chunks while you regain the confidence that you need. Definitely don't try to migrate everything at once :innocent: And actively work out what kinds of confidence you need at each level, and how you can measurably test that.

bethskurrie
2020-10-13 01:47
:taco: for @abubics for always having excellent advice

prabhakar.thippa
2020-10-13 04:58
has joined #general

robbert.van.der.zon
2020-10-13 05:56
We?ll take the advice and won?t migrate all at once. I am actually looking forward to that process and get some more experienced in this. Thanks for your advices!

giadinhluong
2020-10-13 06:24
has joined #general

sagupta
2020-10-13 08:09
Hi folks, I was asked this question by my colleague about the CI CD pipeline with contract tests and looking for answers for it. We have a CI pipeline for provider where we included a job `test-contract` which fetches the latest pact for consumer with the tag `master` . Now as per pact nirvana, I have included a pre-deploy job for can-i-deloy where i am checking if the provider with version xxx can be deployed to master env . Now why do we need a can-i-deploy check when we are already fetching the same contract and verifying it in the `test-contract` job?

bethskurrie
2020-10-13 08:12
Hi @sagupta

bethskurrie
2020-10-13 08:12
"The need for this check increases proportionately with the time that elapses between your pact test execution and your release. If you practice continuous deployment, and you go straight from a test build into a production deployment build, then you can be pretty sure that the version of the other application that is in production probably hasn?t changed in the meantime. If there is a considerable amount of time, however, it is best to do a compatibility check again just before deploying. For example, if you run a pact verification on Monday that verifies the recommended ?master? and ?production? pacts, but you don?t deploy the provider artifact until Friday, the version of the consumer that is now in production may have changed. Alternatively, a pact may have been verified by the ?master? version of the provider, but that version of the provider may not yet have been deployed to production. The consumer cannot be deployed to production until the version of the provider that it depends on is in production (unless it has been specifically written to fail gracefully, which is actually the best approach, but is one that isn?t always followed)."


bethskurrie
2020-10-13 08:13
Another answer is, when you use the "pending" feature (which stops your provider build from breaking when a consumer changes a pact), you need the can-i-deploy check to make sure that you're safe to deploy, because the build won't necessarily fail to tell you so.


sagupta
2020-10-13 08:14
ahh right so what i wrongly assumed is that , we will be running pre-deploy job with all commits which is not the case , it will be run only for master refs

bethskurrie
2020-10-13 08:15
on a branch, can-i-deploy can act as a "can-i-merge", depending on how you configure it. but no, it's not strictly necessary on feature branches.

sagupta
2020-10-13 08:16
ok and indeed we dont do continuous deployment and the consumer version could change during that time so can-i-deploy protects us from that change

bethskurrie
2020-10-13 08:17
:100:

sagupta
2020-10-13 08:17
thanks Beth for this nice explanation

bethskurrie
2020-10-13 08:26
You're welcome

matt.fellows
2020-10-13 08:27
@bethskurrie deserves a :taco:. In fact, many a :taco:

bethskurrie
2020-10-13 08:39
I just got an extremely cantankerous 4 year old through bath and bed time. I deserve more than a taco for that!

florian.nagel
2020-10-13 08:40
@bethskurrie Maybe two tacos? :flushed: :taco: :taco:

pavank
2020-10-13 08:41
has joined #general

bethskurrie
2020-10-13 08:41
And a :wine_glass:

bethskurrie
2020-10-13 08:41
and :chocolate_bar:

sagupta
2020-10-13 08:42
@bethskurrie Thanks for your quick help today . Really appreciate it :taco: :taco:

sagupta
2020-10-13 08:44
tried giving taco to Beth but i posted in the channel and not in this thread :stuck_out_tongue: sorry

bethskurrie
2020-10-13 08:45
haha, appreciated anyway

stephane.meng
2020-10-13 09:06
has joined #general

abirlal.bose
2020-10-13 09:45
has joined #general

michael.west
2020-10-13 14:04
has joined #general

raghanag
2020-10-13 20:26
Sorry to bother you again, if the consumers are using either SDK or direct interaction with provider API?s and if the provider already released the openapi3 or swagger spec, and always supports backward compatibility. Is there any reason to write contract testing, if not can we skip integration testing and replace it with contract testing so that it would be cheap and faster. Other than that my team dont see any value, could you please let me know some strong points on how to convince them.

raghanag
2020-10-13 20:26
@matt.fellows


abubics
2020-10-14 07:09
Where's the link that sent you there?

abubics
2020-10-14 07:10
(i.e. what's the referrer page?)


young
2020-10-14 07:25
thank you

young
2020-10-14 07:25
Pls update it

abubics
2020-10-14 07:28
thanks for the link . . . just need to find someone who knows where to update it :stuck_out_tongue:

young
2020-10-14 07:28
:rolling_on_the_floor_laughing:

young
2020-10-14 07:29
@matt.fellows Can you update the link? Thanks.


abubics
2020-10-14 07:37
if you know where it's meant to point

young
2020-10-14 07:46
Actually I don't know what the new link it is :joy:

abubics
2020-10-14 07:48
oh no :joy:


abubics
2020-10-14 07:53
there are a few different "provider states" pages for each of the build tools, too . . . if you use the on-page search, you might find the one you want

young
2020-10-14 07:54
thank you .

mateusz.mrzyglod
2020-10-14 09:32
has joined #general

cathleen.yuan
2020-10-14 11:16
has joined #general

ramana.jaladurgam
2020-10-14 16:10
has joined #general

alik.berezovsky
2020-10-14 18:38
has joined #general

a.robecke
2020-10-14 19:24
has joined #general

mikahchapman
2020-10-14 21:47
has joined #general

mikahchapman
2020-10-14 21:59
So, I've been working with pact for a while now and it's finally starting to really pick up in our company (yay!). I've been asked a few times about minimizing the number of provider states or sharing a provider state for multiple interactions. I can see some value if you expect the provider to be in the same state, but what's the best practice here? I feel like you want to be fairly specific with the state that you expect the provider to be in, so while sharing states reduces how much you need to maintain on the provider side, it forces the provider state to be more generic (like `entity with id 1 exists`).

hem_kec
2020-10-15 00:44
has joined #general

abubics
2020-10-15 05:42
There are a few paths that people like to take this issue down . . . especially the 2 you've already mentioned. It's definitely an "it depends" problem, because a lof os characteristics affect a desirable outcome.

abubics
2020-10-15 05:43
Personally, I like to keep state descriptions as vague as possible, while maintaining unique significance.

abubics
2020-10-15 05:45
But there are strategies around ? structuring state aspects (i.e. applying orthogonal state pieces from the description), ? making the states parametrically data-driven, ? shared state fixture repos, ? and probably others.

abubics
2020-10-15 05:46
I think there was some v3 or v4 work to provide structured state data, but I haven't used it.

matt.fellows
2020-10-15 08:00
FYI I?ve just scratched together a draft getting started workshop using Katacoda, an in-browser workshop experience. In it, you learn how to create your first contract, publish it to the Pact Broker/Pactflow, verify it on your provider and learn how to gate deployments using the `can-i-deploy` tool. It uses Pact JS but should extrapolate to any language. If you?re new to Pact and/or are willing to share feedback, I would sure love it! Try it out here: https://katacoda.com/mefellows/scenarios/pactflow-getting-started-js

marco.cordeiro
2020-10-15 10:54
has joined #general

giuseppe.salvatore
2020-10-15 13:38
I tried to register for this specific even but it looks like following the subscription link I subscribed to Committed and didn't get any link to the event. Does anyone know how this works?

antonello
2020-10-15 13:44
@giuseppe.salvatore I *think* that the event will be accessible even without registering, but I?m asking

betty.he
2020-10-15 14:32
has joined #general

joel.whalen
2020-10-15 14:48
I was just about to paste this link to my team but got this :disappointed:

sagupta
2020-10-15 14:59
Hello folks, I am using pact cli to verify the provider side. Now i have setup a job in gitlab to fetch the latest contract from consumer xxx with tag master whenever there is a change in provider. Also a provider verification job is triggered from the webhook when a consumer pact is changed , now i am not sure if i need a separate job if build is triggered via webhook ?

seda.urguplu6
2020-10-15 15:09
Hi everyone. I wrote only a basic consumer side test using pact-python. It takes more than 1 minute for start_service() method to run. Also as I see in the pact-mock-service.log, test completed in 4 minutes. Is there a problem with me or is it a normal situation?

brendan.donegan
2020-10-15 16:08
Seeing the same - it appears to be down @matt.fellows

raghanag
2020-10-15 18:10
Hi All, I am using swagger-mock-validator from Atlassian to verify pacts with openapi3 spec, when I use it, I am getting below error. Has anyone used https://bitbucket.org/atlassian/swagger-mock-validator/src. If so could you please let me know how to fix the below issue? ```Error: unknown format "int64" is used in schema at path "#/allOf/1/allOf/0/properties/PrimaryBillingAddressId"```

matt.fellows
2020-10-15 21:10
That is not normal, no

matt.fellows
2020-10-15 21:11
Do you have a virus checker it something blocking things? Could you elaborate more on your setup please?

matt.fellows
2020-10-15 21:11
This channel is for pact support, probably best asking the folks over at atlassian?

matt.fellows
2020-10-15 21:18
It seems to show it getting a number when perhaps it's not defined as a number in the pact / swagger file?

matt.fellows
2020-10-15 21:21
Gah!

raghanag
2020-10-15 21:21
it is defined as int64 in spec file and in pact file it is actually a number ``` "PrimaryBillingAddressId": 3,``` ```"PrimaryBillingAddressId": { "type": "integer", "format": "int64", "readOnly": true, "nullable": true, "x-hints": { "precision": 18 } }```

matt.fellows
2020-10-15 21:22
That's what happen when you push a "minor" edit and run

matt.fellows
2020-10-15 21:22
Sorry all - fixed

matt.fellows
2020-10-15 21:23
What's the pact look like?

matt.fellows
2020-10-15 21:23
Maybe it doesn't recognise any int64 as a valid format?

matt.fellows
2020-10-15 21:24
Upon reflection it does appear that might be it actually

raghanag
2020-10-15 21:26
this is my pact ```{ "consumer": { "name": "fodConsumer" }, "provider": { "name": "crmRestApiProvider" }, "interactions": [ { "description": "a request to get a FodOrder", "providerState": "a FodOrder with ID 300100185754393 exists", "request": { "method": "GET", "path": "/fodOrders/300100185754393" }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "OrderId": 300100185754393, "OrderDate": "2020-10-08", "BasketFlag": "N", "OrderStatus": "DRAFT", "CustomerId": 3, "CurrencyCode": null, "TotalAmount": 0, "ShipToAddressId": 3, "BillToAddressId": 3, "Comments": null, "CreatedBy": "HELPADMIN", "CreationDate": "2020-10-08T20:19:39+00:00", "LastUpdatedBy": "HELPADMIN", "LastUpdateDate": "2020-10-08T20:19:39.283+00:00", "ObjectVersionNumber": 1, "AttachmentEntityName": "fodOrders", "PrimaryBillingAddressId": 3, "CustomerId1": 3, "ObjectVersionNumber1": 1, "PrimaryShippingAddressId": 3, "BillingAddressLine1": "400 Oracle Pkwy", "CustomerAddressId": 3, "ObjectVersionNumber2": 1, "BillingAddressLine2": "2op123", "BillingAddressCity": "Redowood City", "BillingAddressCountry": "US", "BillingAddressPostalCode": "94065", "BillingAddressState": "CA", "ShippingAddressLine1": "400 Oracle Pkwy", "CustomerAddressId1": 3, "ObjectVersionNumber3": 1, "ShippingAddressLine2": "2op123", "ShippingAddressCity": "Redowood City", "ShippingAddressCountry": "US", "ShippingAddressPostalCode": "94065", "ShippingAddressState": "CA", "CustomerFirstName": "Gary", "CustomerLastName": "Jenkins", "OrderNumber": "F300100185754393" }, "matchingRules": { "$.headers.Content-Type": { "match": "regex", "regex": "^application\\/json" }, "$.body": { "match": "type" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }```

bethskurrie
2020-10-16 01:31
@sagupta the recommended approach is to have two different jobs. One for the webhook, that just verifies the changed pact, and one for when the provider does its own build, that verifies the test/prod pacts for every consumer.




bethskurrie
2020-10-16 01:34
The webhook triggered job is likely to fail a lot, because its where the changes are introduced. It's best to keep this out of your main provider pipeline, because you only want the "serious" failures to block your main provider build.

bethskurrie
2020-10-16 01:35
Are you running the test on a Docker image?

bethskurrie
2020-10-16 01:36
Yes. v3 allows you to specify multiple states that are in place at the same time as well.

matt.fellows
2020-10-16 06:08
FYI I?ve moved them to the pact org and have split them into 2 workshops: https://katacoda.com/pact

matt.fellows
2020-10-16 06:09
I?m really liking the platform, and I can see us creating lots of short and sharp workshops for different languages/tools, to teach a specific thing (e.g. publish a contract with Node or Java)

antonello
2020-10-16 08:43
Apparently a Play button will appear on the page just before the event!

tamer
2020-10-16 09:08
has joined #general

giuseppe.salvatore
2020-10-16 10:22
Thanks a lot, will share that info with my team

matt.fellows
2020-10-16 10:29
I?d ask the authors of the tool, sorry

seda.urguplu6
2020-10-16 13:17
I have created an issue about this, shared the files and info. Not testing on docker, I have antivirus software but not sure how to check if it is blocking.

mikahchapman
2020-10-16 14:45
Ooh, that sounds nice. But in general, definitely sounds like sharing states really isn't bad, good practice would be to make sure the state is significant enough to have meaning. So a state like `the server is ready to accept new entities` would be good for multiple interactions that create a new entity.

mikahchapman
2020-10-16 15:29
I think personally, I've gotten into the habit of trying to put too much info into the state description and not letting the rest of the interaction describe itself.

mario.gioiosa
2020-10-16 18:57
has joined #general

matt.fellows
2020-10-17 21:40
Disabling AV is the simplest way to find that out

matt.fellows
2020-10-17 21:40
usually AV software will tell you when it?s messing about though

matt.fellows
2020-10-17 23:52
Is that a question?

abubics
2020-10-18 23:26
Sounds like you're heading in the right direction ^_^

abubics
2020-10-18 23:27
I'd suggest avoiding phrasing like "the server is ready", and stick to domain language. Phrasing the state as domain prerequisites should give you the best flexibility.

ramana.jaladurgam
2020-10-19 03:15
Yes @matt.fellows. I wanted to understand if there is a plan and timeline to upgrade PACT Python to support AMQP based tests. Or any alternatives from the experts that could be suggested.

matt.fellows
2020-10-19 03:22
Did you see my suggestion I linked you to the other day?

ramana.jaladurgam
2020-10-19 05:12
Sorry - i am not sure which link is that


lior.baber
2020-10-19 07:33
has joined #general

lior.baber
2020-10-19 07:38
Hello there mates, I wonder if there is a way to add contract to a running pact-server, the builder (i.e generate a pact and then send it to a running pact-server then use this pact as part of the test)?

2020-10-19 10:44
A new post has been created in *Feature Requests*

matt.fellows
2020-10-19 11:01
do you mean to use it as stubs?


lior.baber
2020-10-19 11:08
yes, I don't have a way to interact with it from outside the docker via api. and have the builder build the contract and send it to the docker container instead of spinning up ephemeral http service

matt.fellows
2020-10-19 11:12
In a language independent way, there is the stub server which accepts a pact file and creates a stub server to use

matt.fellows
2020-10-19 11:12
but i think you want to use it in the usual way (i.e. to generate the contract) as part of a unit test?

matt.fellows
2020-10-19 11:12
If you could please elaborate on your use case/problem that would help. Also probably what language you?re using

matt.fellows
2020-10-19 11:13
It?s not evident why you must use docker in the first instance or why that?s important,

lior.baber
2020-10-19 11:19
I'm using scala, I have an integration test in which the service under test is running in side a docker container as well as its dependent services (i.e the providers) the test send http request to the system-under-test running in the docker container, and wait for the response, because the system is spinning up before the test I can change / reconfigure the stubbed service uri I need to do it beforehand, so if the stubbed service is already up and i can change the contract based on the test I'm currently running, it will be flexible enough for me to use

jeffbdye
2020-10-19 17:10
has joined #general

dmcgill50
2020-10-19 19:15
has joined #general

jace
2020-10-19 19:22
has joined #general

raghanag
2020-10-20 05:57
sure will do

raghanag
2020-10-20 06:08
Hi how do we handle when pact getting verified at provider side, when the pact file has dummy authorization headers and provider expecting real authn tokens?

matt.fellows
2020-10-20 06:08
search authorization on http://docs.pact.io, there?s a page on that somewhere


matt.fellows
2020-10-20 06:10
yep!


sagupta
2020-10-20 09:18
Hello folks , I am trying to setup the consumer pipeline as mentioned in https://docs.pact.io/pact_nirvana/step_4 . However i was wondering once consumer publishes pact to broker and then webhook is triggered , should we go to next job i.e. `can-i-deploy` ? I mean how to wait for the results from the provider build triggered from webhook?

sagupta
2020-10-20 09:19
I was able to setup a separate job in gitlab to only run `test-contract` when pact contract is changed by consumer.

sagupta
2020-10-20 09:19
Thanks for these info . :taco: :taco:

sagupta
2020-10-20 09:20
@bethskurrie Thanks for help :taco: :taco:

antonello
2020-10-20 09:25
if you want to explicitly, you can create a webhook that is triggered when the provider verification is published to the broker.

antonello
2020-10-20 09:25
Or you could introduce other forms of waiting based on the CI tool you?re using

sagupta
2020-10-20 09:27
I am using gitlab and I have configured a webhook to trigger provider build when pact is published/changed, but i am not sure how to handle wait from results of provider. Things not clear to me are: ? after publish job, if i move ahead to can-i-deploy job, it will fail as the pact may not be verified by that time ? How others handle this

antonello
2020-10-20 09:30
Option 1 is definitely possible - and then you might want to retry that job later

antonello
2020-10-20 09:30
I mentioned two other possible ways of doing it - what specifically is not clear?

almaak
2020-10-20 09:35
has joined #general

almaak
2020-10-20 09:41
:wave: Hello, I am trying to set up a pact mock server as a stand-alone service for my REST API. I'm using the service as a docker container and I was wondering how can I initialize the server with a json response and a bearer token? - like, when I make a post request to the server, where should I specify the authentication method and a token? should this be included id the json or should I somehow set the state parameter? POST http://localhost:29999/create?state=NoUsers&path=/accounts'{ "provider": { "name": "Animal_Service"}, ... }' basically, what I want is to setup a response for a path and a static bearer token.

giuseppe.salvatore
2020-10-20 12:14
anybody on this able to see anything from the streaming?

giuseppe.salvatore
2020-10-20 12:14
I got a black streaming from the video window

giuseppe.salvatore
2020-10-20 12:14
no sound as well

mcruzdrake
2020-10-20 12:15
It's also the same for me @giuseppe.salvatore

mcruzdrake
2020-10-20 12:15
Have tried refreshing multiple times

giuseppe.salvatore
2020-10-20 12:15
ok thanks... at least it's not just me

lior.baber
2020-10-20 12:19
@matt.fellows

giuseppe.salvatore
2020-10-20 12:25
@antonello do you have any info?

giuseppe.salvatore
2020-10-20 12:25
ah it's working now

matt.fellows
2020-10-20 12:30
yes, I had issues too. They switched to Youtube now and it?s all good

sagupta
2020-10-20 13:04
I think the option you suggested first (creating a webhook) wont help me here as i would want to wait for the provider pipeline results to move forward for can-i-deploy for consumer

sagupta
2020-10-20 13:05
oK so the option to implement retry once on failure of `can-i-deploy` makes sense

matt.fellows
2020-10-20 13:10
:heart: @giuseppe.salvatore

sagupta
2020-10-20 13:10
You can specify the authentication (bearer token) in the json itself

giuseppe.salvatore
2020-10-20 13:10
kudos to you guys

matt.fellows
2020-10-20 13:10
Sorry I missed this.


matt.fellows
2020-10-20 13:11
but i?m still not sure that?s what you need?

sagupta
2020-10-20 13:11
For example : ```{ "description": "Error Scenario", "request": { "method": "GET", "path": "<pathname>", "headers": { "Authorization": "Bearer xxx" } }, "response": { "status": 404, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "errorCode": "ERROR_NOT_FOUND", "message": "Not found" } } }```

lior.baber
2020-10-20 13:16
no it is not, how can I add a feature request for that? @alik.berezovsky

almaak
2020-10-20 13:48
ok, thank you. so the json is a pact file. correct?

sagupta
2020-10-20 13:49
no this is not pact file, this is the json that you send to your pact mock server

sagupta
2020-10-20 13:49
the auto generated pact file will be pretty similar though

almaak
2020-10-20 13:59
ok, thank you! :slightly_smiling_face:

andra.moraru
2020-10-20 14:13
has joined #general

krisdinesh
2020-10-20 14:18
Guys - I hit through a scenario that I am trying to contract test create new user where I have to pass new user email which should be unique in my post request. If I have use the unique value for every request, I am not sure how can I handle the unique value as part of the contract?

sklein
2020-10-20 14:26
Others definitely chime in here, but I'd expect the business requirement of unique email to be handled by an actual integration test in that service. What I would do contract wise is create two states (email is unique, email is duplicate) on the provider and two tests in the subsequent consumer

sklein
2020-10-20 14:27
then you can add a regex or whatever to check that the payload is indeed an email or just verify its a string

sklein
2020-10-20 14:27
email regex is hard

krisdinesh
2020-10-20 14:41
@sklein - here my scenario is simple post request for creating a user and everytime I need to provide unique email Id. Otherwise it says user exist. How to handle this in contract testing? I can verify as I wanted but the problem exist while posting a request

sklein
2020-10-20 14:52
This would be very much implementation dependent. How does the client generate the unique id? Guid? Some Global Id Service?

antonello
2020-10-20 14:54
@krisdinesh You need to be in control of the data on the provider side (through some kind of mocking, stubbing or using an in memory database).

antonello
2020-10-20 14:55
You definitely should avoid generating a new email every time in your pact, because that would make the content of the pact different for every run, which is a bad pattern.

sklein
2020-10-20 14:55
@antonello this is exactly what I was trying to get at in my original comment.

andra.moraru
2020-10-20 15:00
Hello! I was wondering if anyone here was able to integrate the Pact Mock Server with cucumber tests. At this moment, I create some mocked data using methods annotated with "@Pact" and test the contract with unit test methods annotated with "@PactVerification", but I need to reuse the mocked data also for functional tests built with cucumber. Some links with examples would also be great and I can study further. Thank you

krisdinesh
2020-10-20 16:34
@antonello and @sklein I agree i should have control over the data of provider system but all I am looking here is how can i do that using PACT is my question? In other words, how to test new user creation scenario where it gives 200 ok only when the user details are unique. Please elaborate to this specific scenario to test as part of PACT/Contract Testing. If I use, mock, stubbing or in-memory database it will be more equivalent to unit testing but we are trying to do Contract testing here Please help me here if I am not inline to your thoughts cc: @matt.fellows @uglyog

camila.coder91
2020-10-20 17:06
has joined #general

antonello
2020-10-20 17:49
It depends on what you mean by unit test, but a contract test doesn?t cease to be a contract test if you mock or stub some of your application layers. Actually, it is much preferable than hitting your real database. Ideally you want your provider tests to run without having to hit your deployed application.

antonello
2020-10-20 17:49
Can you mock your data access layer?

antonello
2020-10-20 17:49
If so, that?s what I?d recommend.

krisdinesh
2020-10-20 18:24
makes sense @antonello - I was under the impression that stubs and drivers cant be used in contract testing. I will proceed as suggested but in this case I am not able to distinguish between unit/Component Test VS Contract Test. Thanks for taking time to patiently answer all my questions

antonello
2020-10-20 18:34
Contract Testing is about what you?re testing, which is the contract between two service. You can do contract testing with Pact writing tests that are more like unit tests. In fact, it?s encouraged.


tjones
2020-10-20 21:56
This might be a question for #pact-jvm

wilkinsweiqiangliang
2020-10-21 01:49
Hey guys, a dummy question, for provider to ask can-i-deploy successfully(return YES), it required consumer to public the contract and tag with the specific env tag right? Is there anyway provider can publish first? or it need to wait for you guys to release the `provider-driven` in the future?

matt.fellows
2020-10-21 02:18
I think you can still call `can-i-deploy` even if there are no consumers yet

wilkinsweiqiangliang
2020-10-21 02:19
deploying in progress

wilkinsweiqiangliang
2020-10-21 02:19
will see

wilkinsweiqiangliang
2020-10-21 02:21
```docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest broker can-i-deploy --pacticipant ProductAPI --version=0c842e28bfb5267f45eb970367599582521fe4a9 --tag=staging Computer says no ¯\_(?)_/¯ ```

matt.fellows
2020-10-21 02:21
Yes, just tried the same thing

matt.fellows
2020-10-21 02:21
`No pacts or verifications have been published for version cd3f577+1603246817 of pactflow-example-provider`

wilkinsweiqiangliang
2020-10-21 02:21
so currently, it required consumer to tag, so that webhook can trigger pactVerify and publish result

matt.fellows
2020-10-21 02:21
I wonder if a feature request to say ?allow can-i-deploy? to pass for a pacticipant in a provider role where there are no consumers yet?

wilkinsweiqiangliang
2020-10-21 02:22
before we can ask can-i-deploy


wilkinsweiqiangliang
2020-10-21 02:22
That means its provider driven to me

wilkinsweiqiangliang
2020-10-21 02:22
lol

matt.fellows
2020-10-21 02:33
yes, it reflects the fact that not everyone uses pact only in the consumer driven way

matt.fellows
2020-10-21 02:33
there are many good reasons to support that use case I think, including retrofitting into existing systems

bethskurrie
2020-10-21 05:04
It would be very hard to detect an error situation - how would the tool know if you'd made a mistake and had put in an incorrect version vs the 'there are no results' situation?

bethskurrie
2020-10-21 05:05
it would incorrectly allow you to deploy just because you'd made a mistake in the can-i-deploy call.

bethskurrie
2020-10-21 05:06
if you want to start using can-i-deploy for an application that doesn't actually have any pacts yet, you could check if the pacticipant version resource actually existed in the broker before calling can i deploy.


bethskurrie
2020-10-21 05:08
this is not a philosophical question about who is "driving" the contract so much as a practical consideration of which one is being deployed first.

bethskurrie
2020-10-21 05:08
@wilkinsweiqiangliang tagging in case you don't have notifications turned on for threads.

tjones
2020-10-21 05:11
Ah, I thought the solution to "nothing is deployed yet" was to deploy the provider first - which would be a success, because all deployed consumers (ie, none) are compatible with the provider

tjones
2020-10-21 05:12
Perhaps it should ideally be a big warning, or maybe require an "I'm expecting none" flag?

bethskurrie
2020-10-21 05:12
if you're going to do that, why not just disable can-i-deploy until a consumer is there?

tjones
2020-10-21 05:12
like cloudformation's "allow empty changeset" option

bethskurrie
2020-10-21 05:13
there's no point saying "am i compatible with my contracts' if there are no contracts :laughing:

tjones
2020-10-21 05:13
That also works, but I think it's cleaner/better practice to let it run to success with no consumers

tjones
2020-10-21 05:13
like what if someone else deployed and you didn't know?

tjones
2020-10-21 05:14
I think there's a difference between passing with no contracts and disabling the check entirely

bethskurrie
2020-10-21 05:14
all the command knows is that the version that's being asked for doesn't exist.

bethskurrie
2020-10-21 05:15
if you set it with --ignore-missing-version and left it (because who ever goes back in and changes something that's currently passing) then it would never fail if the version was wrong there after.

tjones
2020-10-21 05:18
What if the behaviour was: Can I deploy ProviderX to TAG: * If no ProviderX is tagged with TAG, allow deployment with zero contracts * Otherwise, if there are zero contracts, fail deployment That might solve most cases. Would it have drawbacks?

bethskurrie
2020-10-21 05:20
:thinking_face:

bethskurrie
2020-10-21 05:21
that might work.

julzelements
2020-10-21 05:25
has joined #general

julzelements
2020-10-21 05:29
Hi folks, I'm a bit worried that this question gets asked a lot but here goes: I'm currently testing a single microservice with a 'black box' approach.

julzelements
2020-10-21 05:31
I've spun up my docker compose with: ? postgres ? a docker image of the scala app in question ? my little node app, which runs my jest tests ? localstack with an sqs que runner

julzelements
2020-10-21 05:32
I'm now in the process of adding mockserver to do the job of another microservice that communicates with the scala app so I can do API testing.

julzelements
2020-10-21 05:33
I'm pretty sure I'm rolling too much of my own stuff at this point, and I should dive in and start looking at how to use http://pact.io in the setup. Am I correct in this assumption? Please ask any more questions, if you feel I've left detail out.

matt.fellows
2020-10-21 05:50
When I was out for my run, I thought it would be fairly easy to wrap the can-i-deploy command with a similar check Tim (on the client side, that is)

matt.fellows
2020-10-21 05:51
My main argument for a behaviour like this would be in places where there is a centralised CI team who create templates for all builds - e.g. in regulated environments, controlling the change process is important, and I?ve had several discussions with teams who do just this. It should also be fairly easy to ?parameterise? to disable can-i-deploy also, which is the obvious counterargument!

wilkinsweiqiangliang
2020-10-21 05:53
There is couple of use case here, and i think its common for cross team deployment. ? When there are no contracts and provider is first time to deploy to an environment, would `can-i-deploy` fail? ? When there is contracts, however, contracts are not being tag with the env tag that provider trying to deploy, would `can-i-deploy` fail?

wilkinsweiqiangliang
2020-10-21 05:53
Thanks for taging @bethskurrie

bethskurrie
2020-10-21 05:54
Open a request on http://pact.canny.io and come up with as clear and well thought out suggestion as you can for how you would want it to work (but still avoid potential accidental deploys)

kapil.mathur
2020-10-21 06:40
has joined #general

yann.courtel
2020-10-21 09:36
Hi everyone. Has anyone tried to know the actual routes a consumer was really consuming? We are looking into being able to see if our interactions in our PACTs are really covering all the routes by a specific consumer. Thank you.

mark.hudson
2020-10-21 10:45
has joined #general

cluu
2020-10-21 17:16
has joined #general

bethskurrie
2020-10-21 21:05
Are you asking if the pact has covered all the routes that the consumer uses, or are you asking if the pact covers all the routes offered by the provider @yann.courtel?


camila.campos
2020-10-21 21:35
has joined #general

matt.fellows
2020-10-21 22:13
My read was covering the _consumer_

matt.fellows
2020-10-21 22:13
> the actual routes a consumer was really consuming

matt.fellows
2020-10-21 22:14
@yann.courtel the question comes up a bit (often in the context of ?how do I know when I have all of the right contracts in place?? as a bit of a target. Whilst we?d like to make tools to simplify this, one option would be to look at your consumer API clients to see what they do, or another option could be to use a recording proxy in a test environment and manually review the requests

abubics
2020-10-22 00:31
Maybe, it's a bit hard to say what your intent is with that setup :slightly_smiling_face: Pact is good for testing a network interface, through a pair of known collaborators (provider and consumer). Your description sounds like you may have several providers and consumers, which might all want separate contracts for their pairings.

yann.courtel
2020-10-22 07:36
Hi Beth, thanks for the info. It's the former as in all routes actually consumed by a microservice. They might consume, say 10% of a provider but at least I want to know if this 10% is covered by a PACT contract in place. It's a very touchy subject here as we have many block from our security. There are two ways I find can be less intrusive but it adds complexity on the development side : 1. Add a layer in all our http calls to be able to record the information we need. The problem is that not all services (consumer) are making http requests the same way. 2. Find a tool that can help auto-generate at build time all http routes by directly parsing the code.

yann.courtel
2020-10-22 07:37
It is quite complicated. Another way that requires a lot of work would be to have our teams maintain a manifest or sitemap file recording all their routes but it sounds too restrictive and counter productive. Thank you for the input. I appreciate.

longlevan
2020-10-22 09:15
has joined #general

justin.garfield
2020-10-22 16:15
has joined #general

guppy0356.nakira
2020-10-23 00:34
has joined #general

matt.fellows
2020-10-23 00:48
Just want to put a general shout out to @antonello who is answering questions like a machine in #pact-jvm, is helping organise and release the Pact JVM library (our most popular/used one), has recently spoken at an API Testing Panel on Pact (https://commited.tech/events/api-testing-panel-discussion/) AND is helping to organise our Pact Meetup in November :taco: :taco::taco: :clap: (also a little reminder - don?t be stingy with those :taco: ?s, which is our kudos currency !)

phil.endsley
2020-10-23 01:42
@antonello is a treasure to the pact community :taco: :taco:

bethskurrie
2020-10-23 05:49
I would personally use a standard code coverage tool and run my pact tests in a separate context to my other tests to get a map of which parts of my consumer are exercised in the pact tests @yann.courtel

bethskurrie
2020-10-23 05:51
In my opinion, it's not so much a question of routes as a question of standard test coverage execution. Eg. imagine you had a client method that makes an http call, and then responds to the different http statuses in different ways (eg. 404 is turned into null, 500 raises an error.) These are actually as much of a concern when you're talking about coverage as the HTTP routes themselves.

tjones
2020-10-23 06:21
Both @antonello and @phil.endsley have been smashing the great answers in the past few months! It's such a pleasure to read a question, then find they've answered it better than I would have :taco: :taco:

thomas.shipley
2020-10-23 09:35
Hey @matt.fellows sorry forgot about this. Looks like I need permission to create a repo in pact foundation before I can transfer it over. Is this something you can help me with?

matt.fellows
2020-10-23 10:04
:wave:

matt.fellows
2020-10-23 10:04
sorry I obviously missed your response

matt.fellows
2020-10-23 10:04
will do this now

matt.fellows
2020-10-23 10:07
OK if you could add me `mefellows` as an admin of that repo, I can transfer to Pact Foundation and then grant you admin to that repo

thomas.shipley
2020-10-23 10:10
No worries - great sent you an invite.

matt.fellows
2020-10-23 10:11
thx, just accepted

matt.fellows
2020-10-23 10:12
I think you need to make me an admin/owner now?

krisdinesh
2020-10-23 11:33
Hello @here - I have scenario like request chaining where api response attribute should be used as request attribute in another api method call. In this case response attribute is dynamic in nature. Hence we are unable to create contract. Please share your thoughts if think it can be addressed

krisdinesh
2020-10-23 11:35
That?s true @antonello has lot of patience in answering questions. Thank you!!

thomas.shipley
2020-10-23 13:10
Transfer of ownership request sent :thumbsup:


matt.fellows
2020-10-24 00:32
:clap: thanks to you both! I?ll take a look at the updates this week

matt.fellows
2020-10-24 00:32
@michael_james :taco: :taco:

matt.fellows
2020-10-24 00:33
@thomas.shipley :taco: :taco:

ercalbwar
2020-10-24 19:24
has joined #general

andrewshtamburg
2020-10-25 13:04
has joined #general

siad.ardroumli
2020-10-25 18:16
has joined #general

srikanthpmailid
2020-10-26 01:02
has joined #general

abubics
2020-10-26 01:03
Pact contracts capture individual interactions, not behavioural sequences. Also, the way versioning & preverification works precludes dynamic request parameters. The usual approach, then, is to use state to avoid dynamism, and design your API client so that it doesn't do conditional things dynamically.

abubics
2020-10-26 01:04
Can you describe your use case more concretely, so someone can help answer you more specifically?

krisdinesh
2020-10-26 02:47
Sure, my 1st scenario is post request for creating a license for a user which gives random id of license and assign the license Id through 2nd post request . This more of request chaining concept

bethskurrie
2020-10-26 06:08
You would do two separate interactions. The first would be to create the license. The second would have a provider state "given that a license with id 123 exists".


krisdinesh
2020-10-26 13:47
Yes @bethskurrie , I am inline with the same but the id 123 can?t be reused so data in the will be invalid after 1st time use

photesthesis_geospiza
2020-10-26 15:10
has joined #general

abubics
2020-10-27 01:47
I think maybe you're not understanding how state setup works. That "provider states" doc pretty clearly describes why test isolation is important, and how state setup can solve your problem. If you can tell us what language/platform your provider is written in, we might be able to give you a concrete example :)

krisdinesh
2020-10-27 01:53
@abubics - we are using dotnet .kindly share the info


jackbwheatley
2020-10-27 21:02
has joined #general

carlosalmeida.xon
2020-10-27 22:06
has joined #general

matt.fellows
2020-10-28 02:39
:tada: I?m excited to announce our first global Pact meetup on the 19th November at 9am (UK/GMT) :tada: Based on your feedback from our recent survey, we will: 1. Demo the use of Pact and some of the latest features 2. Present a case study of using Pact in _Real Life_ :tm: (thanks @antonello!) 3. Have a panel Q&A session where you can ask questions directly of the core team ?and more! Register for the event here: https://go.pactflow.io/nov20meetup, we hope to see you there!

oscar821210
2020-10-28 02:40
Great!!

aforeman
2020-10-28 02:42
Awesome!!

guppy0356.nakira
2020-10-28 02:48
I will join this online meetup from Japan.

pdunn
2020-10-28 04:06
Awesome work guys!!!

evanrosal
2020-10-28 05:31
Has anyone used PACT for aws eventbridge?

a.smith
2020-10-28 06:47
Congratulations all! Great news!

matt.fellows
2020-10-28 07:46
I also forgot to mention. If the timezone is not good for you, we will be recording and uploading to Youtube afterwards. You can still register and there is an option for us to send the video to you once it?s up online

alik.berezovsky
2020-10-28 08:09
????

francislainy.campos
2020-10-28 08:35
Looking forward to it! :slightly_smiling_face:

matt.fellows
2020-10-28 10:27
Do you an adblocker @alik.berezovsky? What browser are you using?

matt.fellows
2020-10-28 10:27
Direct link is https://www.eventbrite.com.au/e/pact-community-meetup-tickets-126772009493 but I've noticed the URL can change so put a branded link over it

nasir.amin
2020-10-28 11:07
has joined #general

jimish.shah.-nd
2020-10-28 11:26
has joined #general

dale.bennett
2020-10-28 11:37
Hi, Wondering if anyone could share some insight into what I might be doing wrong here please. I am using PactNet. I am trying to DELETE a resource. This in theory is simple to execute, but I am receiving a status code 415. What's even weirder is that when I check the application logs my delete request doesn't actually seem reaching the application at all. I am not sure where this status code is coming from, I have double checked the endpoint, the headers I am sending, and I have executed the exact same request manually. When I manually execute this request, I get a 204 as expected, however when I attempt to do this through a provider verification test I get the 415. My pact file looks like this {  "consumer": {    "name": "SpiralSuite"  },  "provider": {    "name": "SchedulingAssistantAPI"  },  "interactions": [    {      "description": "The request to delete is successful",      "providerState": "an optimized case exists",      "request": {        "method": "delete",        "path": "/api/optimize",        "headers": {          "Accept": "application/json; v=1.6"        }      },      "response": {        "status": 204,        "headers": {          "X-Request-ID": "2e3dd4f4-77de-4282-8705-7814d65f4f87"        },        "matchingRules": {          "$.headers.X-Request-ID": {            "match": "type"          }        }      }    }, Other requests in the pact file that point to api/someendpoint work, but none of these are a DELETE. Any idea where I am going wrong please? I have attached a successful request executed manually to the same endpoint. I have also attached the error from the provider test run...

matt.fellows
2020-10-28 11:38
415 is unacceptable/unsupported media type - does your provider actually return `application/json; v=1.6` as the content type from that endpoint?

matt.fellows
2020-10-28 11:40
Also for the future, .NET related questions should go in #pact-net :pray:

dale.bennett
2020-10-28 11:40
Thanks for the quick reply, I believe so. I have attached the manual execution of the same request with a seemingly identical header, I get a 204. Oh sorry I didn't realise that :)

matt.fellows
2020-10-28 11:40
doesn?t look like your DELETE requests receives a body, so the accept header seems redundant

matt.fellows
2020-10-28 11:42
There should be a log file somewhere from Pact that shows the in/out details. That may shed some light

dale.bennett
2020-10-28 11:54
Is that the same as the output from the test? Currently digging but maybe I do not have logs, perhaps I have not configured correctly. Either way my test output shows this: Verifying a pact between SpiralSuite and SchedulingAssistantAPI Given an optimized case exists The request to delete is successful with DELETE /api/optimize returns a response which DEBUG: Setting up provider state 'an optimized case exists' for consumer 'SpiralSuite' using provider state set up URL http://localhost:5002/provider-states I, [2020-10-28T11:50:05.041100 #66320] INFO -- request: POST http://localhost:5002/provider-states D, [2020-10-28T11:50:05.041100 #66320] DEBUG -- request: User-Agent: "Faraday v0.17.3" Content-Type: "application/json" Authorization: "Bearer {_token goes here, I have removed this deliberately_}" I, [2020-10-28T11:50:06.899121 #66320] INFO -- response: Status 200 D, [2020-10-28T11:50:06.900123 #66320] DEBUG -- response: connection: "close" date: "Wed, 28 Oct 2020 11:50:06 GMT" server: "Kestrel" transfer-encoding: "chunked" WARN: Adding header 'Authorization: Bearer {_token goes here, I have removed this deliberately_} to replayed request. This header did not exist in the pact, and hence this test cannot confirm that the request will work in real life. has status code 204 (FAILED - 1) includes headers "X-Request-ID" which is an instance of String

adam_figgins
2020-10-28 14:20
has joined #general

aperdomobo
2020-10-28 15:42
has joined #general

diazguerra2
2020-10-28 16:06
has joined #general

xsamore
2020-10-28 19:52
has joined #general

simon
2020-10-28 20:49
has joined #general

matt.fellows
2020-10-29 00:37
Any mobile devs here keen to try out the latest and greatest Swift lib? https://pact-foundation.slack.com/archives/C9VBGNT4K/p1603931113025100 (x-post from #pact-swift )

ruben.cagnie
2020-10-29 01:24
has joined #general

272939217
2020-10-29 05:33
has joined #general

driloni92
2020-10-29 09:05
has joined #general

pauloavra
2020-10-29 12:33
has joined #general

wilkinsweiqiangliang
2020-10-30 05:19
Hi guys, does our docker pact cli support participant name with spaces? like (?This is a name?) im trying to call but it doesnt work.

bethskurrie
2020-10-30 05:19
It should, if they have double quotes around them.

bethskurrie
2020-10-30 05:19
What is the line you are using?

wilkinsweiqiangliang
2020-10-30 05:20
```docker run --rm -v /Users/wilkinsliang -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:latest broker create-version-tag --pacticipant "Product API" --version 7540-f24a47478c2d840246eb33000864727069cf0703 --tag development```

bethskurrie
2020-10-30 05:22
can you add --verbose and show me the output?

bethskurrie
2020-10-30 05:28
From the description "it doesn't work" I can't tell if it's an issue in the docker -> CLI interface, or the CLI -> HTTP interface.

wilkinsweiqiangliang
2020-10-30 05:28
let me try again

wilkinsweiqiangliang
2020-10-30 05:28
i think issue is not with cli

wilkinsweiqiangliang
2020-10-30 05:28
it might just be my bash script

wilkinsweiqiangliang
2020-10-30 05:30
thanks for confirming the space with naming, i found the issue is on my bash

wilkinsweiqiangliang
2020-10-30 05:30
:taco:

2020-10-30 15:24
A new post has been created in *Feature Requests*

jikogay728
2020-10-30 17:20
has joined #general

raghanag
2020-10-30 22:51
Hi I just have a question why do we need the axios when we already have the mockProvider and pact, isn?t mockProvider is not enough to serve the requests or writing assertions. I understand that axios is like http client but we are including one more library why not pact provide its own http client for the mock service.https://github.com/pact-foundation/pact-js/blob/master/examples/mocha/index.js

matt.fellows
2020-10-30 22:54
That's the client code, which uses Axios to fetch data from the provider

matt.fellows
2020-10-30 22:54
It doesn't know if it's talking to Pact or the real thing

matt.fellows
2020-10-30 22:54
See the howtolearn materials

2020-10-30 22:54
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

raghanag
2020-10-30 22:55
so you meant i can use any http client library i wish not only axios right

matt.fellows
2020-10-30 22:55
Or even start with these quick in browser examples https://docs.pactflow.io/docs/tutorials/

raghanag
2020-10-30 22:57
so mockprovider provides mock server and can you explain this line if you dont mind https://github.com/pact-foundation/pact-js/blob/master/examples/mocha/test/get-dogs.spec.js#L70

matt.fellows
2020-10-30 23:03
On the consumer side, pact mocks out the provider.

matt.fellows
2020-10-30 23:04
The code your looking at is the client code - the thing you want to test

matt.fellows
2020-10-30 23:04
Pact doesn't do anything as a consumer. Your job is to write a unit test of the consumer with Pact

matt.fellows
2020-10-30 23:04
I'd run thru the workshops


matt.fellows
2020-10-30 23:05
It'll really accelerate the learning

raghanag
2020-10-30 23:05
sure

matt.fellows
2020-10-30 23:05
:+1:

blmlcu
2020-10-31 14:51
has joined #general

psychopomp3x
2020-11-02 14:42
Idea: Ability for pact to inform the provider developer that an API is not in use by any consumers. My team is using side-by-side http api versioning and looking for ways to know when it's safe to remove the old versions.

tjones
2020-11-02 14:47
I like this idea! What would it look like? How would you tell pact that the unused api exists?

psychopomp3x
2020-11-02 14:48
Maybe on the test run for a provider, it could declare an informational message? Something like a list of APIS exposed that are not covered by a pact test in the broker.

psychopomp3x
2020-11-02 14:49
I think the provider runner would need to understand how to identify that apis exist from the provider side. Maybe metadata in the code / static analysis? Not sure how to solve it. Sci-fi.

lakitna
2020-11-02 16:51
This would probably combine really well with provider-side things as described here https://github.com/pact-foundation/pact-specification/issues/76

jamescourtoy
2020-11-02 21:04
has joined #general

matt.fellows
2020-11-02 22:42
It?s possible, but probably very framework specific in the current state. i.e. it would probably be fairly easy to discover routes in an ExpressJS app or a spring boot app, but that would involve a lot of plugins to cover all of them. I think the provider driven approach that Sander is referring to is probably going to be easier, because the provider contract is documented in advance - so the ?unused? portion of the api is easier to see. If `P` is the full API documented by the provider (e.g. in an OAS), and `C` is the union of APIs documented by all consumers, then `P - C` is the unused portion that can be decommissioned


matt.fellows
2020-11-03 05:18
The best part is, that she goes on to show how to ?integration? test a smoke alarm, without setting your house on fire :stuck_out_tongue:

telmo.ferreira.costa
2020-11-03 11:32
has joined #general

sergii.kopovskyi
2020-11-03 12:35
has joined #general

silverton.gimenes
2020-11-03 17:58
has joined #general

colber16
2020-11-03 18:34
has joined #general

cvoong
2020-11-03 18:55
has joined #general

cvoong
2020-11-03 19:12
seems like this channel might be the right place to ask this question

phil.endsley
2020-11-03 19:16
Definitely casting a bigger net here, but #pact-net is the best place for language specific questions. Sometimes you might have to just wait a bit, since the core team is based in Australia

brendan.donegan
2020-11-04 11:47
Hi. We?re using the open source Pact broker at the moment and occasionally see `PactBroker::Client::Error - {"error":{"message":"SQLite3::BusyException: database is locked","reference":"WzzADWGTOL","backtrace":` in our CI. Anyone know if this is a known issue?

brendan.donegan
2020-11-04 11:47
We are using pact-node 10.9.2

brendan.donegan
2020-11-04 11:48
The broker version is 2.59.2

antonello
2020-11-04 12:26
this is not going to be super helpful, but using SQLite is not recommended.

brendan.donegan
2020-11-04 12:26
I was thinking that already

antonello
2020-11-04 12:29
My assumption is that it?s struggling with load

antonello
2020-11-04 12:29
and concurrent access

antonello
2020-11-04 12:30
sqlite is only recommended for investigation/spikes

antonello
2020-11-04 12:30
My recomendation would be to switch to Postgres

ukrainian1991
2020-11-04 17:27
Hi, have anyone faced with the task to put credit card expiration date in PACT contract. I know that I could use string matcher, but how about sending card info during provider check. Real provider will decline the expiration date in the past

ukrainian1991
2020-11-04 17:27
```stringMatcher("expiration_year","^\\d{4}\$", "2023")```

ukrainian1991
2020-11-04 17:29
It would send to provider the string 2023 from example, but after 2023 test would have been failing

ukrainian1991
2020-11-04 17:30
Anyway it's not good to hardcode variable (even 2300 year :slightly_smiling_face:)

phil.endsley
2020-11-04 18:14
What languages are you using? I know there's a feature that supports this, but I'm not sure if it's available in every language

ukrainian1991
2020-11-04 18:17
JVM


phil.endsley
2020-11-04 18:26
Your provider can modify/inject a value when setting up the state


ukrainian1991
2020-11-04 18:29
Thanks, seems it's what I am looking for

ukrainian1991
2020-11-04 18:30
need to figure it out

ukrainian1991
2020-11-04 19:05
@phil.endsley Are you using JVM? I am struggled with ```.`object`("accountNumber") .valueFromProviderState("id", "\${accountNumber}", 100) .closeObject()``` valueFromProviderState in body description. I am using Lambda DSL and there is no valueFromProviderState

ukrainian1991
2020-11-04 19:05
seems it's only for ```PactDslJsonBody()```

ukrainian1991
2020-11-04 19:17
Oh, seems I find the way out ```.body(newJsonBody((root)-> { root.object("user", (o) -> { o.getPactDslObject().valueFromProviderState("userId", "${userID}", 6789); <<< o.stringType("email"); o.stringType("firstName"); o.stringType("lastName");```

matt.fellows
2020-11-04 20:35
Ah yes, SQL lite cannot handle multiple simultaneous queries (or something like it anyway). I saw that a lot when testing the terraform provider against it

brendan.donegan
2020-11-04 20:36
okay, good to confirm that

matt.fellows
2020-11-04 20:36
I'd recommend postgres with docker. The example in the repo should work OOTB for testing. For prod obviously you'd probably want to extetnalise that db

uglyog
2020-11-04 22:04
You can also use the date generator, it will generate a value relative to the current system time.

abubics
2020-11-05 03:39
Big tangent . . . are you building or proxying a payment gateway? Dealing with CC info feels like a good way to land yourself in trouble :innocent: especially if it's not 100% necessary

wilkinsweiqiangliang
2020-11-05 03:50
Hi guys #pact-jvm im using gradle plugin `4.1.9` to publish contracts, however, im getting below error. ```> Failed to fetch the root HAL document Caused by: au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path '/' failed with response 'HTTP/1.1 400 Bad Request' at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:301) at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:140) at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:284) at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:140) at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:36) at au.com.dius.pact.core.pactbroker.HalClient.getJson(HalClient.kt:278) at au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:242) at au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:237) at au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:219)```

tjones
2020-11-05 06:12
I do this the other way around - I use the provider state "it is currently July 1st 2020" , or similar

uglyog
2020-11-05 06:24
Your pact broker returned a 400 Bad Request, you'll need to enable debug level logs to see what was wrong.

wilkinsweiqiangliang
2020-11-05 07:40
im using pactflow as my broker

wilkinsweiqiangliang
2020-11-05 07:40
not sure if there is a way to enable it

uglyog
2020-11-05 07:42
With Gradle, you can run it with `-d` to enable debug logs

wilkinsweiqiangliang
2020-11-05 07:52
sure will post the log here

wilkinsweiqiangliang
2020-11-05 08:24
```020-11-05T19:17:21.447+1100 [DEBUG] [jdk.event.security] X509Certificate: Alg:SHA256withRSA, Serial:67f94578587e8ac77deb253325bbc998b560d, Subject:CN=Amazon, OU=Server CA 1B, O=Amazon, C=US, Issuer:CN=Amazon Root CA 1, O=Amazon, C=US, Key type:RSA, Length:2048, Cert Id:-1011578998, Valid from:22/10/15, 11:00 am, Valid until:19/10/25, 11:00 am 2020-11-05T19:17:21.448+1100 [DEBUG] [jdk.event.security] X509Certificate: Alg:SHA256withRSA, Serial:67f944a2a27cdf3fac2ae2b01f908eeb9c4c6, Subject:CN=Amazon Root CA 1, O=Amazon, C=US, Issuer:CN=Starfield Services Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US, Key type:RSA, Length:2048, Cert Id:668791387, Valid from:25/5/15, 10:00 pm, Valid until:31/12/37, 12:00 pm 2020-11-05T19:17:21.448+1100 [DEBUG] [jdk.event.security] X509Certificate: Alg:SHA256withRSA, Serial:a70e4a4c3482b77f, Subject:CN=Starfield Services Root Certificate Authority - G2, O="Starfield Technologies, Inc.", L=Scottsdale, ST=Arizona, C=US, Issuer:OU=Starfield Class 2 Certification Authority, O="Starfield Technologies, Inc.", C=US, Key type:RSA, Length:2048, Cert Id:1766010387, Valid from:2/9/09, 10:00 am, Valid until:29/6/34, 3:39 am 2020-11-05T19:17:21.476+1100 [DEBUG] [jdk.event.security] ValidationChain: -1472444962, -1011578998, -1597878274 2020-11-05T19:17:21.511+1100 [DEBUG] [jdk.event.security] TLSHandshake: http://test.pactflow.io:443, TLSv1.2, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, -1597878274 2020-11-05T19:17:21.511+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] Secure session established 2020-11-05T19:17:21.511+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] negotiated protocol: TLSv1.2 2020-11-05T19:17:21.511+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 2020-11-05T19:17:21.512+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] peer principal: CN=*.http://pact.dius.com.au 2020-11-05T19:17:21.512+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] peer alternative names: [*.http://pact.dius.com.au, *.http://pactflow.io] 2020-11-05T19:17:21.512+1100 [DEBUG] [org.apache.http.conn.ssl.SSLConnectionSocketFactory] issuer principal: CN=Amazon, OU=Server CA 1B, O=Amazon, C=US 2020-11-05T19:17:21.514+1100 [DEBUG] [org.apache.http.impl.conn.DefaultHttpClientConnectionOperator] Connection established 192.168.1.107:41172<->13.54.166.169:443 2020-11-05T19:17:21.514+1100 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Executing request GET / HTTP/1.1 2020-11-05T19:17:21.514+1100 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Proxy auth state: UNCHALLENGED 2020-11-05T19:17:21.532+1100 [DEBUG] [org.apache.http.impl.conn.DefaultManagedHttpClientConnection] http-outgoing-0: Close connection 2020-11-05T19:17:21.533+1100 [DEBUG] [org.apache.http.impl.execchain.MainClientExec] Connection discarded 2020-11-05T19:17:21.533+1100 [DEBUG] [org.apache.http.impl.conn.PoolingHttpClientConnectionManager] Connection released: [id: 0][route: {s}->https://test.pactflow.io:443][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 10] 2020-11-05T19:17:21.534+1100 [ERROR] [au.com.dius.pact.core.pactbroker.HalClient] Failed to fetch the root HAL document```

uladzislau_danilchyk
2020-11-05 08:35
Hi guys! How can I add custom header for specific state on a consumer/provider side? The problem is that after user is authenticated, there is a header JSESSIONID which need to be sent to provider. But in Pact test it absent and my expected and actual request are different. How can I fix that problem? P.s.: I thought that I can modify request in Pact Provider Verification Test for a specific state.

uglyog
2020-11-05 08:41
You can use a request filter to add the header, but you will need to have a way of getting a valid session ID

uglyog
2020-11-05 08:42
Maybe a request before the pact verification test to get the session ID

uladzislau_danilchyk
2020-11-05 08:42
@uglyog but request filter on provider side works for every state. But I need specific request filter for a specific state

uglyog
2020-11-05 08:44
I can't see anything wrong there. Do you go through a proxy server?

uglyog
2020-11-05 08:45
@matt.fellows how would a GET request to the root generate a 400 response?

wilkinsweiqiangliang
2020-11-05 08:52
nope i dont go through the proxy server

matt.fellows
2020-11-05 08:54
I?ll open up the logs now, one moment

ukrainian1991
2020-11-05 08:58
@uglyog yeah, but contract is static, and i can't handle it without provider states. Or Am I missing something? I think that date should be generated in provider state method and this date would be replaced while sending real request to real provider based on stored contract and corresponding variable in this conrtract

matt.fellows
2020-11-05 08:58
just checking, are you using the `test` account or your own?

wilkinsweiqiangliang
2020-11-05 08:59
NOPE

wilkinsweiqiangliang
2020-11-05 08:59
pls use my work account

wilkinsweiqiangliang
2020-11-05 08:59
i replaced for security reason

matt.fellows
2020-11-05 09:00
ah thx

matt.fellows
2020-11-05 09:02
Is there a full trace of the request response? I can?t see it in that log

matt.fellows
2020-11-05 09:02
Could you please send it to me in a DM?

matt.fellows
2020-11-05 09:03
I can see a couple of `400` s during publish

uglyog
2020-11-05 09:05
It's not specific to a state, it is applied to each request

uladzislau_danilchyk
2020-11-05 09:09
@uglyog you talking about current approach how `@TargetRequestFilter` works. But I would like to modify request just for a few interactions. For example, I have 2 pacts: authorized journey and unauthorized. For Authorized journey I want to modify request and add, e.g. header or something else. But for unauthorized journey I don't want to modify request. So I need to have `@TargetRequestFilter` per `@State`. Do you have any ideas?

uladzislau_danilchyk
2020-11-05 09:10
There was similar issue but no results found: https://github.com/pact-foundation/pact-jvm/issues/729

uladzislau_danilchyk
2020-11-05 09:11
@uglyog, in other words: In request filter I need to know about interaction. In this case I can have one filter but may filter out interactions inside.

uglyog
2020-11-05 09:12
There will be no way to know what the current provider state is from the request filter. Maybe raise an issue for it at the Github project

uladzislau_danilchyk
2020-11-05 09:14
@uglyog, i'm seeing that such filter are no longer used in junit 5 and I need to use `PactVerificationInvocationContextProvider` with `@TestTemplate` . Right? But I suggest that this method is called just one time before all pacts are executed.


uglyog
2020-11-05 09:16
You can inject the request into your test method with JUnit 5. No need for the request filter

uladzislau_danilchyk
2020-11-05 09:16
@uglyog what times it can be executed? 1 or per every pact?

uglyog
2020-11-05 09:17
You can also get the current interaction in the same way, so you could get the provider states

uglyog
2020-11-05 09:17
It is passed into the test method as a parameter

uglyog
2020-11-05 09:17
You need to do what you need to before calling the verify

uladzislau_danilchyk
2020-11-05 09:18
@uglyog, ok. but can you have a look on my last question? how much time the method annotated `@TestTemplate` will be executed?

uladzislau_danilchyk
2020-11-05 09:18
`pactVerificationTestTemplate`

uglyog
2020-11-05 09:20
Once for each interaction in the Pact file

uladzislau_danilchyk
2020-11-05 09:21
So the main idea is to filter out states inside this method and for the needed state modify request, yep?

uglyog
2020-11-05 09:22
You can add the interaction as a parameter to the test method. It will have the provider states as a field

uladzislau_danilchyk
2020-11-05 09:22
Do you have an example? I cannot imagine how it looks like.

uglyog
2020-11-05 09:24
No, but pseudo code would be like: ```void testTemplate(PactVerificationContext context, HttpRequest request, Interaction i) { if (i.providerStates[0].description == '...') { // This will add a header to the request request.addHeader("X-Auth-Token", "1234"); } context.verifyInteraction(); }```

uglyog
2020-11-05 09:25
Sorry, the field is `name` not `description`

uladzislau_danilchyk
2020-11-05 09:25
hm.. I just tried to pass HttpRequest into method but it failed with: `No ParameterResolver registered for parameter [http://java.net.http.HttpRequest request] in method` I'm using gradle lib: ``` testImplementation 'au.com.dius:pact-jvm-provider-junit5:4.0.10'```

uglyog
2020-11-05 09:26
Wrong class, it needs to be the Apache Http Client one

uglyog
2020-11-05 09:27
`org.apache.http.HttpRequest`

uladzislau_danilchyk
2020-11-05 09:28
@uglyog, works with Apache lib:)

uladzislau_danilchyk
2020-11-05 09:31
@uglyog, hm.. it's very strange.. Interaction doesn't have any provider states... but in Pact it exists.

uladzislau_danilchyk
2020-11-05 09:32
@uglyog providerStates list is empty

uglyog
2020-11-05 09:32
That is not right

uladzislau_danilchyk
2020-11-05 09:33
@uglyog , but I have another method annotated with `@States("my-state")` and breakpoint was hit there.

uglyog
2020-11-05 09:34
I'll need to investigate that, it should not be empty. It might be a defect

uladzislau_danilchyk
2020-11-05 09:34
@uglyog it would be good.

uladzislau_danilchyk
2020-11-05 09:36
@uglyog but again. Can Pact's team add following functionality: for method annotated with `@State` pass `HttpRequest` to have an ability to modify request along with provider state?


uglyog
2020-11-05 09:37
It is called before the request is created'

uglyog
2020-11-05 09:37
Just checked an example, and the provider state is populated


uladzislau_danilchyk
2020-11-05 09:39
@uglyog currently i'm in breakpoint in method annotated with `@State` and in debug returned back to `PactVerificationStateChangeExtensio#beforeTestExecution()` and it has `providerStates` populated.

uladzislau_danilchyk
2020-11-05 09:39
But inside my method it doesn't: ``` @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) public void pactVerificationTestTemplate(PactVerificationContext context, HttpRequest request, Interaction interaction) { context.verifyInteraction(); }```

uglyog
2020-11-05 09:39
Not that method, the actual test method

uglyog
2020-11-05 09:39
`pactVerificationTestTemplate`

uladzislau_danilchyk
2020-11-05 09:40
@uglyog, sorry. don't understand what you mean

uglyog
2020-11-05 09:41
The interaction will only be passed into the test method (in your example pactVerificationTestTemplate)

uladzislau_danilchyk
2020-11-05 09:42
yep, but it doesn't exist.

uglyog
2020-11-05 09:42
That example link I posted works, I just checked it

uglyog
2020-11-05 09:44
And I reply with

uladzislau_danilchyk
2020-11-05 09:45
its strange..

uglyog
2020-11-05 09:45
Are there more than 1 interaction in the pact file?

uladzislau_danilchyk
2020-11-05 09:46
@uglyog, ohh... I just have a pact with duplicated interaction but second interaction has provider state...) consumer have 'update' instead of 'replace' option


uladzislau_danilchyk
2020-11-05 09:47
and now providerStates is populated)

uladzislau_danilchyk
2020-11-05 09:47
thanks!

uladzislau_danilchyk
2020-11-05 09:48
I just wanted to ask you something more: I saw in examples that provider state method can have a map as a Parameter, but where this map is populated?

uglyog
2020-11-05 09:49
In V3 format pact files, they can have parameters

uladzislau_danilchyk
2020-11-05 09:49
@uglyog , oh, only in V3


uladzislau_danilchyk
2020-11-05 09:49
I'm using pactSpecification.version 2.0.0

uladzislau_danilchyk
2020-11-05 10:03
@uglyog in case of multiple interaction states I cannot filter out current executing provider state for the verification. I need to modify request which depends on current provider state

uladzislau_danilchyk
2020-11-05 10:03
Do you see what I mean?

uglyog
2020-11-05 10:09
Look at the example code I posted, it uses an if statement if it is the correct provider state

uladzislau_danilchyk
2020-11-05 10:10
But in this code you just checking everytime first state `i.providerStates[0].description === '...'`

uglyog
2020-11-05 10:12
That was only an example

ukrainian1991
2020-11-05 11:45
I check the service which proxies payments to real 3rd party gateway? 3rd party would be mocked, but anyway I could not rely on fixed date

reema.dhiman
2020-11-05 13:07
has joined #general

ukrainian1991
2020-11-05 13:55
If I understant correctly I need to use `dateExpression` But can't figure out how to set next year shift

ukrainian1991
2020-11-05 13:56
expression type is string

ukrainian1991
2020-11-05 14:25
It was hard to find)))


ukrainian1991
2020-11-05 14:25
Please add it to docs

ukrainian1991
2020-11-05 14:55
```pactDslObject.dateExpression("expiration_year", "+ 4 years", "yyyy")``` Works like a charm)) Thanks to everyone)

jarmy
2020-11-05 23:26
Hi everyone. What?s the suggested approach for handing non-breaking changes to a provider (e.g. a consumer requests a change to the API generated by the provider). Should the consumer teams add the new feature to their pacts first, as sort of a distributed TDD style workflow, which will give provider a clear idea of what they are expected to deliver? However, wouldn?t that break builds on all other concurrent branches or PRs at the time? How do you synchronize the merging of the updated provider in the consumer team, with the updated implementation in the provider, without build failures? The provider team I?m working with wants to know: > What would be the happy path, where nothing breaks?



jarmy
2020-11-06 00:00
I?m not sure this meets our situation since it seems to infer that the consumer changes the contract. Our situation is as such: 1. The consumer published a pact with a _develop_ tag 2. The pact tagged with _develop_ was verified by the provider 3. The provider changes the API upon a request from the consumer which changes the response body 4. The provider verification build fails with the existing contract

bethskurrie
2020-11-06 00:10
If the consumer is requesting a change, they need to change their contract (typically on a branch)

bethskurrie
2020-11-06 00:11
The consumer branch should not be merged to the main branch until the feature has been implemented on the provider.

bethskurrie
2020-11-06 00:12
I'm a bit confused about something though - you said it was a non-breaking change.

bethskurrie
2020-11-06 00:12
If the consumer has not yet updated their contract, how did the verification task fail?

bethskurrie
2020-11-06 00:13
The CI/CD workshop shows you how to do a flow where all the tests stay green.

jarmy
2020-11-06 00:16
Well, the provider team indicated it?s a non-breaking change. I?m not convinced. If the response from the provider has changed, how can it not be breaking?

bethskurrie
2020-11-06 00:16
it sounds breaking to me.


bethskurrie
2020-11-06 00:17
you can add a field though

bethskurrie
2020-11-06 00:17
that's not a breaking change. You could add more values to an enumerator.

bethskurrie
2020-11-06 00:17
breaking changes would be changing types of used fields, or removing them.

jarmy
2020-11-06 00:18
I believe they changed the response body. It used to have a container with 2 elements but now only has 1

bethskurrie
2020-11-06 00:19
that's a contentious one. It's broken the contract, but not necessarily changed the schema.

jarmy
2020-11-06 00:20
This was the failure message from pact ```1.1) BodyMismatch: $.page.containers BodyMismatch: $.page.containers Expected [BIG OBJECT] to have minimum 2```

bethskurrie
2020-11-06 00:21
In this case, the consumer needs to change their expectations first.

bethskurrie
2020-11-06 00:21
change to "at least one"

jarmy
2020-11-06 00:22
Right, I suspected the contract needed an update. What?s the best process for handling that? Is it simply both the provider and consumer talking?

bethskurrie
2020-11-06 00:23
yes.

bethskurrie
2020-11-06 00:23
there's a slide in every one of my talks that says "CDCs are not a replacement for good communication between teams"

bethskurrie
2020-11-06 00:23
"integration tests weren't either".

jarmy
2020-11-06 00:23
Ha. I?ve seen it mentioned

bethskurrie
2020-11-06 00:24
I do tend to stress it heavily :stuck_out_tongue:

jarmy
2020-11-06 00:24
I?ve got to stress that to the teams that are now using contract testing

bethskurrie
2020-11-06 00:29
> For an sqlite database (only recommended for investigation/spikes, as it will be disposed of with the container unless you mount it from an external file system):

bethskurrie
2020-11-06 00:30
I'll update that to mention the concurrency stuff as well!

bethskurrie
2020-11-06 00:36
@ukrainian1991 all our docs can be modified with a PR. Would you mind adding it while it's fresh in your mind? We always appreciate user contributions.

abubics
2020-11-06 01:33
Fair enough :thumbsup: I would default to leaving all validations like that to the actual source of truth, and then only start taking on that responsibility if it gives UX benefits. Maybe that's what you're doing, or something similar :)

matt.fellows
2020-11-06 01:57
I?ve literally had somebody on a phone call suggest we build an integration into their telephony systems, to automatically ?call the other team? (or book a meeting) if they need to change a contract

matt.fellows
2020-11-06 01:57
They mentioned that ?teams don?t like to talk to each other? and that they saw an opportunity for us to help change it

matt.fellows
2020-11-06 01:58
I placated them as best I could ?Oh, that?s an interesting idea. Let me chat with the team??

matt.fellows
2020-11-06 01:58
it?s not an uncommon sentiment, however

linda.anthu
2020-11-06 15:50
hello :slightly_smiling_face: can anyone help me ? I wanted to update a field on request but I always get timeout :( (edited)  ```[2:28 PM] describe("get football market information", () => { let opts: any; before((done) => { opts = { providerBaseUrl: conf.provider[0].BASE_URL, pactBrokerUrl: conf.pact_broker.URL, provider: conf.provider[0].NAME, publishVerificationResult: true, providerVersion: conf.provider[0].VERSION, requestFilter: (req: any, _res: any, next: any) => { if (req.path.match("/api")) { const chunks: any[] = []; req.on("data", function (chunk: any) { chunks.push(chunk); }); req.on("end", function () { req.body = JSON.parse(Buffer.concat(chunks).toString()); if (req.body.params.filter.marketIds) { req.body.params.filter.marketIds = [marketId]; } next(); }); } else { next(); } }, }; done(); }); it("validates the expectations of Matching Service", (done) => { return new Verifier(opts).verifyProvider() .then(output => { done(); }) .catch((error) => { done(error); }); }); });```

matt.fellows
2020-11-06 21:45
I'm actually not sure it's possible with the current setup. Despite it appearing that way, you can't just change the body as it is a stream. Could you please raise an issue on GH

nish699
2020-11-09 12:28
has joined #general

dikili
2020-11-09 17:18
Hi all @here , I have a generic question for provider verifications...I have a request where although I can verify via postman that api is up and all is fine.. I get an error saying

dikili
2020-11-09 17:18
Expected an Array but got a String ("") at $

dikili
2020-11-09 17:18
and also status came as 308, instead of 200

dikili
2020-11-09 17:19
was the other error item.. Do you know what could be done to resolve it , I cant seem to see/find anything on the code that wd flag anything wrong :disappointed:

dikili
2020-11-09 17:44
I am on VPN and use pactflow as the broker

rforjoe
2020-11-09 20:29
has joined #general

pbobba
2020-11-09 23:03
has joined #general

jun.li
2020-11-09 23:05
has joined #general

matt.fellows
2020-11-10 01:53
:wave:

matt.fellows
2020-11-10 01:54
What language are you using? There are many possibilities here, it would be great to see your code so we can help

matt.fellows
2020-11-10 01:54
See also howtoask

2020-11-10 01:54
Please see this page for some tips on how to ask for help to get the best response from the community https://docs.pact.io/help/how_to_ask_for_help

douweicai
2020-11-10 04:11
has joined #general

christian.huber
2020-11-10 09:20
has joined #general

vuttithatkrongyot
2020-11-10 10:57
has joined #general

dikili
2020-11-10 11:05
@matt.fellows this is c# but does the language even matter, I only get this error when provider runs, consumer test seems to pass.. I attached both cons and prov code below,fyi

dikili
2020-11-10 11:05
`[Fact]`         `public void TestProvider()`         `{`           `//  var comp= new PactClient();`             `string provider = "MobileApi";`             `string consumer = "MobileApp";`            `// var pact = comp.GetPact(provider, consumer);`          `//   var pactUrl = pact.ResponseUri.Host;`             `// Act + Assert`             `var buildNumber = Environment.GetEnvironmentVariable("BUILD_NUMBER");`             `//Assuming build number is only set in the CI environment`             `var config = new PactVerifierConfig`             `{`                 `Outputters = new List<IOutput> //NOTE: We default to using a ConsoleOutput, however xUnit 2 does not capture the console output, so a custom outputter is required.`                 `{`                     `new XUnitOutput(_output)`                 `},`                 `Verbose = true,`                 `PublishVerificationResults = true,`                 `ProviderVersion = "1.0.0"`             `};`             `IPactVerifier pactVerifier = new PactVerifier(config);`             `pactVerifier`                 `.ServiceProvider(provider, "http://endpoint/mobile-api-jobseeker")`                 `.HonoursPactWith(consumer)`                 `.PactBroker("pactflo", new PactUriOptions("token"))`                 `.Verify();`         `}`

dikili
2020-11-10 11:06
consumer:

dikili
2020-11-10 11:07
`public void Suggestions_For_JobTitles()`     `{`         `// Arrange`         `#region Consumer Request`         `_mockProviderService.Given($"I request IT job suggestions")`                            `.UponReceiving($"A GET request for getting job titles for term IT")`                            `.With(new ProviderServiceRequest`                            `{`                                `Method = HttpVerb.Get,`                                `Headers = new Dictionary<string, object>`                                `{`                                    `{ "x-correlation-id", "4f684829-af1c-4f51-abfd-232334420946" },`                                    `{ "x-correlation-source-id", "MOBILE-API-JOBSEEKER" },`                                    `{ "x-device-app-ref", "f1715508-3a20-495d-bbdb-0d2fc45f0733" },`                                    `{ "x-app-version", "4.0.1000" },`                                    `{ "x-os-version", "9.0" }`                                `},`                                `Path = $"/jobs/titles/suggestions/IT"`                            `})`                         `.WillRespondWith(new ProviderServiceResponse`                         `{`                             `Status = 200,`                             `Headers = new Dictionary<string, object>`                             `{`                                 `{ "Content-Type", "application/json; charset=utf-8" }`                             `},`                             `Body = Match.MinType(new { }, 1)`                         `});`         `#endregion`         `var mockClient = new MockClient(_mockProviderServiceBaseUri);`         `// Act`         `var result = mockClient.GetJobTitles("IT");`         `// Assert`         `Assert.NotNull(result);`         `#region Pact Teardown`         `_mockProviderService.VerifyInteractions();`         `#endregion`     `}`

dikili
2020-11-10 11:08
@matt.fellows I attached the codes above , looking forward to help ...thank you !

matt.fellows
2020-11-10 11:08
It matters because it is almost certainly a configuration issue

matt.fellows
2020-11-10 11:09
I?m assuming `.PactBroker("pactflo", new PactUriOptions("token"))` is just you replacing the actual broker and token?

matt.fellows
2020-11-10 11:09
I don?t know .NET all that well, but there must be a way to enable verbose logging so that we can see what the verification process is doing

dikili
2020-11-10 11:09
yes that is true, i did not want to reveal my token and the username that is whuy

dikili
2020-11-10 11:10
I have the logs as well, let me give the logs I have and let me know if you need more logs and i can look for a way to generate it

matt.fellows
2020-11-10 11:10
if you could please enable verbose logging as per the example https://docs.pact.io/implementation_guides/net/readme#2-tell-the-provider-it-needs-to-honour-the-pact and share that

dikili
2020-11-10 11:11
Ok then I will enable this and re-run and share the logs with you


dikili
2020-11-10 11:28
@matt.fellows pls see the logs

dikili
2020-11-10 14:26
@matt.fellows I realised that this output is already with Verbose=true, so wont any further logs

dikili
2020-11-10 14:28
pls note that other interactions in the test suite works fine but one of the tests with failure..

dikili
2020-11-10 14:49
@matt.fellows I managed to sort the above problem out and it seems working for me now, fyi..

dan.iosif
2020-11-10 17:06
has joined #general

wesleythomaswilliams
2020-11-10 19:14
Revisiting our Pact tests to flesh some stuff out and in doing so, found one of my services needs to have provider tests for both rest endpoints and kafka messaging. I've written two separate provider test classes (I'm working in java, but I expect this issue to be universal), one for rest, one for messaging tests. However, when I run the tests in either class, they execute against all consumers, irrespective of the connection type. I'm assuming this is happening because the provider name is the same for both, because it's the same service, it just provides two different communication methods. Is there a sensible way of resolving this beyond giving the provider different names in each test class (e.g. <service_name>-rest and <service_name>-kafka) as that seems a bit hacky and not very elegant (and all consumers will need updating too with the updated provider names).

phil.endsley
2020-11-10 19:24
Probably worth waiting for additional confirmation, but I'm 90% sure having different service names is the only way

matt.fellows
2020-11-10 22:55
Yes, that?s correct unfortunately

matt.fellows
2020-11-10 22:55
see https://github.com/pact-foundation/pact-specification/issues/79 for the upcoming change to allow both formats in the same file

uladzislau_danilchyk
2020-11-11 08:24
Hi all! Is there possibility to check/match response value? Not match by type? (pact-js)

francislainy.campos
2020-11-11 08:36
Hi, if you're using Java instead of using .stringType for example, you would use .stringValue, .booleanValue would replace .booleanType, etc.

uladzislau_danilchyk
2020-11-11 08:40
@francislainy.campos, I'm using pact-js

francislainy.campos
2020-11-11 08:42
Ah, okay. Sorry, not sure if there's an equivalent there for this, as the versions seem to vary a bit between languages. Maybe @uglyog or @matt.fellows would be able to confirm that for you.

uladzislau_danilchyk
2020-11-11 08:47
@uglyog, @matt.fellows what do you think about my case?

matt.fellows
2020-11-11 09:13
Please ask in #pact-js

matt.fellows
2020-11-11 09:14
You can match on value in all languages, just don't use a matcher!

matt.fellows
2020-11-11 09:15
But share your code and we can help

dan.iosif
2020-11-11 09:20
Hey everyone, We've implemented Pact as suggested (Provider and Consumer). When verifying the Provider the verifications are fired at the real service, therefore invoking any processes that are required to correctly fulfil a response. This is having an impact on our system by polluting our data set with the data that's in the Consumer tests. How would you suggest we avoid polluting our data when using Pact?

matt.fellows
2020-11-11 09:21
Don't run it against a live system

matt.fellows
2020-11-11 09:21
That would be the recommendation

matt.fellows
2020-11-11 09:21
You really want the tests to be deterministic and live systems usually don't have this property

matt.fellows
2020-11-11 09:30
The standard approach is to be able to run the system locally (i.e. spinning up the service as a black-box/hermetic server style with external dependencies stubbed) You should be able to run pact on your Dev machines and in a CI pipeline without ever deploying your code

dan.iosif
2020-11-11 09:31
Thank you very much for replying, Matt!

dan.iosif
2020-11-11 09:32
Since we're hitting Lambdas, they're already deployed, but it's a dev environment.

matt.fellows
2020-11-11 09:35
In most cases you can still do this locally

matt.fellows
2020-11-11 09:36
Otherwise you might need a data fixture cleanser, that seeds before the tests and wipes afterwards

matt.fellows
2020-11-11 09:36
Are you using SAM or Serverless framework or something?

matt.fellows
2020-11-11 09:36
Are they HTTP pact or message?

dan.iosif
2020-11-11 09:38
We're using AWS SAM, yeah, and they're HTTP pacts.

matt.fellows
2020-11-11 09:42
which language?

dan.iosif
2020-11-11 09:43
JS. :smile:

matt.fellows
2020-11-11 09:43
It?s on my list to put an example together

matt.fellows
2020-11-11 09:43
perfect, I was hoping you?d say that

dan.iosif
2020-11-11 09:43
:joy:

dan.iosif
2020-11-11 09:43
Haha!

matt.fellows
2020-11-11 09:43
:slightly_smiling_face:

dan.iosif
2020-11-11 09:43
I'll be honest, I'd really appreciate more examples...

matt.fellows
2020-11-11 09:43
pactflowexamples


dan.iosif
2020-11-11 09:44
It's certainly a reflection on myself, but the Pact docs have so much theory I can barely cope. :sweat_smile:

matt.fellows
2020-11-11 09:44
:point_up: We?ve been adding a bunch here. They are linked from http://docs.pact.io also

matt.fellows
2020-11-11 09:44
You may also enjoy pactflowuniversity


dan.iosif
2020-11-11 09:45
Oh, I hadn't seen that before!! I'll take a look and share with the people in my company.

simon.nizov
2020-11-11 14:29
We just deployed our first feature after enabling can-i-deploy and pending+WIP pacts in my company for the first time. It works beautifully! Thanks @pact-team! :tada:

matt.fellows
2020-11-11 23:58
:taco: for @simon.nizov , not just for getting to `can-i-deploy`, but also for being a great contributor in this forum and for his PRs in various repositories over the past few months :clap:

matt.fellows
2020-11-11 23:58
Awesome to see you getting to see the fruits of your labour!

rodrigo.costa20
2020-11-12 00:59
has joined #general

yong.gong188
2020-11-12 09:13
has joined #general

lakitna
2020-11-12 10:04
We just ran into a very interesting one. In my org we have sister orgs. I just got a situation where the sister org wants to get going with Pact as well. Pactflow is setup for the main org right now. The sister org will have internal APIs that the main org doesn't care about, and they will have APIs that directly connect to the main org. I'm not sure how to think about this just yet. What would be the best way to set this up? 1. One broker for the main org and its sister orgs. (single broker) 2. One broker for every org. (multiple brokers) 3. One broker for every orgs internal stuff, and one for the shared stuff (multiple brokers)

anandhadeepak
2020-11-12 13:03
has joined #general

david.dias
2020-11-12 20:04
has joined #general

matt.fellows
2020-11-13 05:49
Interesting. I?d suggest going down the single broker route (1) - unless there are really good reasons to separate them. Are there specific issues you?re expecting to run into?

matt.fellows
2020-11-13 05:50
Once you have two brokers, and you need to ?cross the streams? there is currently no supported way to do that, aside from manually dealing with it (i.e. a consumer/provider may now exist in both - so you?ll have to use the CLI tools in ways they weren?t designed and may miss something)

matt.fellows
2020-11-13 05:50
Are you referring to the OSS one Sander or Pactflow? The Teams and Roles/Permissions in Pactflow will certainly go a way to helping some of this hear

billal.patel
2020-11-13 10:31
has joined #general

lakitna
2020-11-13 14:57
In our case, we're talking about Pactflow. Tough I feel like too early to bind this question to a technical details. The biggest issues that might pop up come from the fact that the sister org have their own independent systems and organisational structure. They often use different standards, have other types of legacy, and some have a different culture when it comes to integration. Having the sister orgs be a part of the same broker might help with aligning some of these things, but it would be a long process. A process we have very little control over from within the main org. If possible I would prefer to not involve upper management, they generally lack the technical background for a quick resolution. All of this makes it as much an organisational question as a technical one.

lakitna
2020-11-13 14:59
Reading this back, this thread got really org specific real quick. I'll discuss this with in the main org as well.

michaelkochub
2020-11-13 17:08
Hello! This question is less technical and more related to best practices. Suppose I need to set up an endpoint that responds to provider state changes. I can create a new, standalone service that will serve the endpoint and respond to requests. This works when the service doesn't need to access beans or other services offered by the application. Is there any advice or guidance related to the case where the endpoint should live inside the provider application (so that it is easy to inject other Spring beans and services into the endpoint)? A canonical example of this might be a provider state that expects a user to exist (which requires a call to `UserService#createUser` for example) Several possibilities include 1) Adding authentication to the endpoint and passing the hard-coded auth key in the provider state params 2) Registering the endpoint only for tests 3) Putting the endpoint behind a feature toggle which is set only set to true by the test configuration

2020-11-13 19:34
A new post has been created in *Feature Requests*

matt.fellows
2020-11-13 21:07
I would add the endpoint only during a test phase (e.g setup in a spring test context). I wouldn't deploy it, but there are occasions where that's difficult to avoid. I would have the endpoint fully locked down if it went to prod and completely inaccessible to the public or other internal systems

mikahchapman
2020-11-13 23:40
So, I know authorization and this page (https://docs.pact.io/provider/handling_auth/) have probably been talked to death, but I'm not really wondering about "how to do authorization with pact". I'm more curious on what people's thoughts are on whether authorization belongs in a contract or not. I'm torn because on the one hand, it seems like it should because the provider will behave differently if that header is present or not. On the other, we're not trying to use Pact to verify that the authorization works on the provider, we're verifying other elements of the interaction (other headers, response shape, etc.), so authorization should just be stubbed to a true state. What are other people's thoughts on this?

bethskurrie
2020-11-13 23:41
If it's a well known standard, I often don't bother putting it in the contract (eg. bearer token, basic auth)

bethskurrie
2020-11-13 23:42
If it's unlikely to change, so there is not much benefit putting it in a contract. If it's a custom thing, then there may be benefits.

mikahchapman
2020-11-13 23:42
That's what we're working with, mostly bearer token. And that's the vibe I was getting from point 1 on that page.

bethskurrie
2020-11-13 23:43
The Pactflow API allows 3 different types of auth (basic auth for the legacy tenants, bearer auth for the new ones, and UI auth via Cognito and JWTs). We just stub out the auth in our internal Pact tests, and use other tests to make sure the auth works.

bethskurrie
2020-11-13 23:43
It simplifies things.

bethskurrie
2020-11-13 23:45
What you can do is stub out the auth by default, but then have a provider state and a specific example for when the auth fails.

uglyog
2020-11-14 02:40
Even using two different apps, the actual one that gets deployed, and a test support one that does not. Some people won't like having test code in the actual app, even if turned off.

louis.oliver
2020-11-16 10:33
has joined #general

ashishkujoy
2020-11-16 15:08
has joined #general

raghanag
2020-11-17 00:12
Has anyone used pact/contract testing when there are message queues like Kafka etc?

matt.fellows
2020-11-17 00:15
yes, what language Naga?

matt.fellows
2020-11-17 00:15
See pactflowexamples for a Java and JS integration


raghanag
2020-11-17 00:17
hi @matt.fellows both js and java.

raghanag
2020-11-17 00:17
we have few microservices which instead of interacting with each other they communicate thru kafka in the middle

matt.fellows
2020-11-17 00:18
cool, well hopefully those examples help. We call this form of testing ?Message Pact?


abubics
2020-11-17 00:19
I know there are some translations of workshops into different programming languages . . . are there translations into different human languages?

tjones
2020-11-17 00:20
We did have a Chinese version at one point, but I don't think it's up to date

matt.fellows
2020-11-17 00:23
yes, somebody translated http://docs.pact.io. But no examples that I know of have been

abubics
2020-11-17 01:03
aha, cool . . . I've seen open source things where people basically set a checklist up of things that need translating/updating, and that's worked into the site (similar to Wikipedia too, I guess?). It is a lot of up-front and maintenance effort, though.

pradeepchoube
2020-11-17 03:49
has joined #general

tjones
2020-11-17 09:24
No, but it should be possible, I think.

tjones
2020-11-17 09:24
Good thinking. We could also use that list for the existing docs, too

meng-lingtao
2020-11-17 14:39
has joined #general

pabvidcal
2020-11-17 15:30
has joined #general

magesh.nagamani
2020-11-18 05:15
has joined #general

lakitna
2020-11-18 12:03
Now that more teams are starting to use Pact in our org, we keep seeing the same reasons why people don't like it at first. The biggest of those has to do with functional tests. Due to the amount of legacy there remains a strong need for functional tests. Some of those are executed on an end-to-end environment, and some in isolation with stubs. It's very easy to include these tests in the Pact, but it's considered bad practice for multiple reasons. The result of this is basically that we have to setup two separate stub servers, for example; Pact and Wiremock. One is there to facilitate the contract tests, the other for functional tests. Setting up two separate systems, that do many of the same things, feels a bit iffy. Because of this, I wondered if we can use the Pact stub server for all stubbing uses without all tests making it into the Pact. Basically an opt-in or an opt-out system on the consumer-side. TL;DR: Can we exclude tests from a Pact?

jstoebel
2020-11-18 13:53
has joined #general

sklein
2020-11-18 14:49
Have you considered just using tags to mark just the tests you want to create the pact? How you do that is language and framework specific but the concept should translate.

sklein
2020-11-18 14:53
Since you mention Wiremock I'm going to assume you're working in a JVM based envrionment so maybe Junit Tags are something to look into https://www.baeldung.com/junit-filtering-tests

sklein
2020-11-18 14:58
Another consideration would be partitioning these tests into separate libraries one for your more typical integration/e2e tests and another for the contract specific tests and then configure only the contract test library to publish to the broker on test run in your ci/cd pipeline

jgfarias42
2020-11-18 16:10
The Pact server works just like the Wiremock server, however it has an additional by product of generating an interaction specification. Why not use only Pact? Tests on the consumer side: Your SUT will be your Client object, the one that makes the remote calls. You then TDD the creation of the Client object: ? Configure the Pact Server for one interaction ? Write something on the @test, run and see it fails ? Write the code on the Client object, run the test and it passes ? Repeat until no more interactions On the provider side: Your SUT will be the Controller object. You then use the consumer contract as a specification and TDD building the controller until the specification is satisfied. What?s the point of these integrated/E2E checks, if the Client and Controller object are on the periphery of the consumer and provider applications?

tjones
2020-11-19 01:21
You could also use Pact as a fake consumer to generate the functional tests you need. That way, you'll have two pacts: Real consumer -> Real provider Functional tests -> Real provider

matt.fellows
2020-11-19 03:57
REMINDER: our community event is on today at 8pm AEDT / 9AM GMT. Join the live stream here: https://youtube.com/watch?v=wkld_wRsTDE Have a question you?d like to ask of the maintainers? Ask here: https://app.sli.do/event/txxh27zr Can?t wait to see you all!

matt.fellows
2020-11-19 08:57
we?re about to kick off. Join us, won?t you?

guppy0356.nakira
2020-11-19 08:59
I forgot about the time difference from Japan... I will join later.

matt.fellows
2020-11-19 10:17
@antonello?s team at Treatwell. Went from 2 deployments a month, to 20 a month, to 45 a week :clap:

brendan.donegan
2020-11-19 10:23
That?s cool. We?re still at stage 2 in that journey, due to relying on a lot of e2e?s still

daniel.sayer89
2020-11-19 10:33
has joined #general

art.ptushkin
2020-11-19 10:34
has joined #general

pact457
2020-11-19 10:36
has joined #general

ajerthan.sivayoganath
2020-11-19 10:38
has joined #general

matt.fellows
2020-11-19 10:55
very cool!

philipchardwick
2020-11-19 11:05
has joined #general

tanzmann
2020-11-19 11:09
has joined #general

tjones
2020-11-19 11:11
This was the coolest bit for me

olivier.quere
2020-11-19 12:10
has joined #general

wilfried.vandenberghe
2020-11-19 12:19
has joined #general

simon.nizov
2020-11-19 13:08
Great event today guys, it was a pleasure to watch! Thank you!

elliottmurray
2020-11-19 14:05
Glad you enjoyed it!

2020-11-19 15:30
A new post has been created in *Feature Requests*

alan.hanafy
2020-11-19 19:28
has joined #general

jarmy
2020-11-19 20:59
One of our provider teams has run into a problem after adding a pact verification job on `contract_content_changed` events: https://docs.pact.io/pact_nirvana/step_4/#e-configure-pact-to-be-verified-when-contract-changes. There was a recent update to the contract to bring it in line with an api change made by the provider. The new pact was verified by the provider in its CI job. There are now branches in the consumer that have drifted behind the contract in the master branch. When a commit is made to these branches, a CI build is initiated, the outdated pact is published and a `contract_content_changed` event is triggered. This causes the pact verification job to fail since it is using an old contract. How do I resolve this issue? Is it recommended to only publish pacts on the `master` branch once a contract has been established?

phil.endsley
2020-11-19 21:07
> Is it recommended to only publish pacts on the `master` branch once a contract has been established? Publish with each commit > How do I resolve this issue? Is there an issue? It sounds like that's what you would want. ? Outdated consumer branches are publishing a contract ? Provider build is triggered to verify ? Verification fails, and publishes the failed verification to pact broker This is what you want, since the contracts are not compatible. Failed verification results are not necessarily bad, it just indicates that version of the provider is not compatible with that version of the consumer, so you can't deploy those together

jarmy
2020-11-19 21:35
Ok, we?re already publishing on each commit. My concern was twofold: ? The provider team was notified via slack about a failure and struggled to understand why ? The pact broker showed ?last verified? as failed for the pact

jarmy
2020-11-19 21:37
Once a pact verification test succeeded, the pact broker became happy again

michael.deutscher
2020-11-19 21:39
has joined #general

phil.endsley
2020-11-19 21:40
Speaking for myself, our practice is to do everything in feature branches. Because of that, the dashboard last verified status is useless for us (I haven't found a use for it yet anyway) because it's almost always for a feature branch

phil.endsley
2020-11-19 21:41
It's the end of the work day for me, and my brain is fried. Would pending pacts work in this scenario? To not fail the provider build?

jarmy
2020-11-19 21:43
We?re already using pending and WIP pacts on the provider, They don?t seem to work in this case

phil.endsley
2020-11-19 21:50
I guess that makes sense if the consumer branches push a commit, but didn't change the contract that's on their branch

jarmy
2020-11-19 21:51
yeah, the contract itself didn?t change but it was tagged with either a different version or branch

gerry.power
2020-11-20 03:31
has joined #general

alex900
2020-11-20 05:08
has joined #general

tomas.panik
2020-11-20 08:28
has joined #general

brendan.donegan
2020-11-20 08:48
@jarmy I assume you already tag your contracts with the branch?

brendan.donegan
2020-11-20 08:53
I see now what you?re saying. My answers would be 1. A details needs to be added to the Slack message saying which branch failed. The provider team should only care about master. 2. Explain to them that Last Verified showed as failed is not something they should care about or look at and explain how to use the search feature in ?The Matrix?

marc.ferland
2020-11-20 14:43
has joined #general

sebastien.crapoulet
2020-11-20 15:24
has joined #general

sebastien.crapoulet
2020-11-20 15:24
Hello :slightly_smiling_face:

adutrillaux
2020-11-20 15:28
has joined #general

he
2020-11-20 15:59
has joined #general

phil.endsley
2020-11-20 16:03
Just got done watching the recording of the event from the other day. Lots of great stuff in there! :clap: I know these things take a lot of effort to coordinate on top of the time commitment. I'm very appreciative of everyone on the panel taking the time out to do this! p.s. Thanks for recording it! I really didn't want to wake up at 3am to watch :smile: A couple follow up questions for it 1. @antonello How did you figure out the number of pacticipants over time? 2. Any chance of making the slides available? Particularly interested in the demo ones from @tjones

antonello
2020-11-20 16:05
Hey @phil.endsley ! Thanks for watching and thanks for your feedback :) We?ll made the slides available very soon and also answer the questions we go on http://sli.do.

antonello
2020-11-20 16:06
To answer your question, I simply queried the broker?s pacticipants table (I was specifically interested in the created_at column)

antonello
2020-11-20 16:07
Hi @sebastien.crapoulet! Welcome! :blush:

ivgeni.slabkovski
2020-11-20 21:52
has joined #general

matt.fellows
2020-11-20 23:40
There is also a `/metrics` endpoint, if you regularly ingested that into your log/analytics tool, you could graph it from there too

matt.fellows
2020-11-20 23:40
and yes, we?ll make all of the content available soon

serhatburakyildirim
2020-11-21 21:57
has joined #general

alnasl
2020-11-22 18:46
has joined #general

ashutosh23802
2020-11-23 06:20
has joined #general

leonty
2020-11-23 10:33
has joined #general

dariusz.piwko
2020-11-23 11:34
has joined #general

uladzislau_danilchyk
2020-11-23 15:08
Hi everyone! I have a question regarding provider verification using junit5. I have a provider verification test as per docs. And I want to verify provider against specific pacts version (consumer version) which are stored in Pact Broker? How to do that? I want to pass consumer version before/during running of provider verification test. But no docs were found related to that. Could anyone help me?

antonello
2020-11-23 15:18
I am not sure if there is other way, but I?ve done is using `pact.filter.pacturl`

antonello
2020-11-23 15:19
Basically setting the property like this `-Dpact.filter.pacturl=http://$BROKER_HOSTNAME:$BROKER_PORT/pacts/provider/$PROVIDER_NAME/consumer/$CONSUMER_NAME/version/$CONSUMER_VERSION`

antonello
2020-11-23 15:33
(I?d recommend you use #pact-jvm for questions on pact-jvm :slightly_smiling_face: )

phil.endsley
2020-11-23 16:08
Hey all, wanted to start a discussion to see how others handle this, and see if maybe there's a way to make this easier. We're in a situation now where we're starting to rollout Pact across our company. Our company is in the middle of basically re-writing a lot of stuff, and we have a lot of microservices. One of the biggest pain points I'm running into is the first set of pacts. ? No pacts exist ? Create and publish pact on a feature branch ? Create provider verification in feature branch ? There's nothing with a develop/master/main tag, so merging the provider first will fail, since there are no pacts to verify ? Merging the consumer without verification is not good So in this situation, we're in a sort of limbo period for the first set. This has come up here a few times before, and I think the prevailing advice is, "It's the first set of pacts, so nothing is using it yet. Just do what you need to do to get the first set in". My issue is that, while this shouldn't come up more than once for a consumer/provider pair, it's coming up a lot now as more and more applications start adding pacts for the first time. Basically, my main complaint is: I've spent the past year convincing everyone to try it out and use it. Now that they are (after a lot of resistance), they come to me with this (known) first scenario, and I have to say something like, "Yeah, it's goofy...but just do it and you won't have to worry about this again". It's just not a great first impression for people that are basically taking my word for how to use it, because this goes against how I've been preaching it should work

praneeth.kumar
2020-11-23 16:18
has joined #general

philipchardwick
2020-11-23 17:00
We've always set it up so the provider ignores the test if theres no pacts to verify (`@IgnoreNoPactsToVerify` if you're using pact-jvm) - which I think makes sense since, if there's no pacts for it fulfill, it can do what it wants. The downside is that someone might configure the wrong tag and never actually verify the pact they expect but that'll be caught as soon as the consumer tries to run can-i-deploy.

phil.endsley
2020-11-23 17:05
We do the same thing (Also pact-jvm). But, it feels like we're adding boilerplate code to cover this unique scenario. Aside from the first one, we would always expect there to be pacts, and would want the build to fail, since it indicates something is misconfigured/wrong. The other issue is jvm specific. For junit5, we have to add null checks in addition to adding `@IgnoreNoPactsToVerify` since the context is null It just feels clunky

brendan.donegan
2020-11-23 18:42
very quick and very minor question - let?s say for a particular interaction we don?t care much what the response code is, or maybe we want it to be 2xx. Is there a way to specify that using Pact?

jarmy
2020-11-23 18:46
I'm now passing `${pactbroker.consumerVersionTags}` into the Jenkins verify job to include in the slack message. I've told the provider team to only pay attention to `main|master|develop` branches


brendan.donegan
2020-11-23 21:19
Ok, cool. Was just fixing a contract that expected 200 back from an endpoint and it was giving 201 (which was wrong cause it wasn?t creating anything), but really most client code is doing something like `if (response.ok) {` or `if (response.status < 400)`

matt.fellows
2020-11-23 22:34
exactly

uglyog
2020-11-23 22:39
If it is a brand new provider, then I just work on master and not bother with a feature branch, because nothing is using it yet so it is safe to deploy. I create the consumer pact in the consumer project, publish that, then get the provider verification passing, deploy that (dark release). Then look to release the consumer to use the new provider.

uglyog
2020-11-23 22:41
If it is adding Pact tests for existing services, then they are already working in production, so I think you can tag with the production tags at the start.

uglyog
2020-11-24 00:14
The problem is the can-i-deploy check in the pipeline. You'll need a way to bypass that as a quality gate until everything is running

mark.white
2020-11-24 09:03
has joined #general

nerea.tamayo
2020-11-24 12:40
Hi all! I'm trying to create webhook in PactFlow for triggering Jenkins pipeline but I don't know how to start.... In PactFlow, clicking on "add webhook", there are some parameters... ? url, is the provider pipeline I want to trigger with in Jenkins? ? About credentials....Which are the credentials I need to use in the PactFLow's webhook? Is the service account I'm using for running the pipeline in Jenkins? Sorry for this type of questions, but I'm lost on this thanks!!!

tjones
2020-11-24 12:41
You may get a faster answer in #pactflow (although it is almost midnight here in Aus, where the pactflow team is)

nerea.tamayo
2020-11-24 12:42
Oh, yes!!!Sorry!!!

nerea.tamayo
2020-11-24 12:42
thanks!

matt.fellows
2020-11-24 13:14
:wave:

matt.fellows
2020-11-24 13:14
Yes that's my understanding. The Jenkins user/pass goes into those form fields

matt.fellows
2020-11-24 13:15
The URL of your provider Jenkins build goes in URL

matt.fellows
2020-11-24 13:16
Jenkins has a ... Funny auth model. So if the test webhook functionality doesn't tell you why it's failing you may need somebody from Jenkins admin side to help diagnose

matt.fellows
2020-11-24 13:16
My recommendation is to first test via curl or something first, and then translate to Pactflow

ufuk.ozcelik
2020-11-24 14:58
has joined #general

stefanos.varsanis
2020-11-24 16:48
has joined #general

lalexander2810
2020-11-24 16:53
has joined #general

brendan.donegan
2020-11-24 17:25
@nerea.tamayo I have quite a bit of experience with this, however it does depend on your Jenkins instance and how it is configured. Do you user a username/password or is there an auth provider like Github?

sivaprasad9
2020-11-24 20:46
has joined #general

matt.fellows
2020-11-24 22:15
Oh cool, @francisco.moreno just posted this! Hopefully it?s helpful (I haven?t reviewed yet myself, but thought best to get it to you quickly) https://www.sngular.com/contract-testing-in-ci-uniting-pact-and-jenkins/

bethskurrie
2020-11-25 02:10
@phil.endsley do you have any proposed changes that you think would help?

bethskurrie
2020-11-25 02:11
Is there a fix for @IgnoreNoPactsToVerify that would help? (Like making a NullContext object?)

bethskurrie
2020-11-25 02:12
I've considered changes to can-i-deploy but can't work out how to tell the difference between "you've misconfigured it" and "we haven't got everything started yet"

phil.endsley
2020-11-25 02:34
Honestly, I've had too much going on with other stuff at work to put any real thought towards it. Wanted to put it out here though to see if there were any thoughts about it though. If I'm remembering correctly, the jvm issue was something about the testing framework itself. Haven't looked too much into it myself, but know it has been discussed in issues raised in pact-jvm repo

phil.endsley
2020-11-25 02:36
Maybe that annotation is the answer, and just need to work out the injection piece. Then remove that in a follow up commit...

bethskurrie
2020-11-25 02:41
I wonder if WIP pacts would fix this.

bethskurrie
2020-11-25 02:42
Automatically bringing in the feature pact to be verified without having to change the config.

bethskurrie
2020-11-25 02:44
that would mean as soon as there was a feature pact, it would be considered WIP, and then there would never be a verification with no pacts.

bethskurrie
2020-11-25 02:55
nope. just did a trial run, and for a particular complicated reason, the feature pact is not considered wip

bethskurrie
2020-11-25 03:50
Ok, @phil.endsley I think I've got a tweak for WIP pacts that will help this situation. Assuming you're on a version of pact-jvm that can use wip pacts.

phil.endsley
2020-11-25 03:50
Yes, were currently using wip pacts

bethskurrie
2020-11-25 03:51
sweet. I have a little http demo client that allows you to simulate a workflow with the broker.

bethskurrie
2020-11-25 03:51
It runs in ruby however, is that something you're ok to try locally, or does it need to be dockerized?

phil.endsley
2020-11-25 03:52
Uhh maybe :grin: Dockerized would be the most convenient, but I'm sure I could get it working

bethskurrie
2020-11-25 03:53
I'll see if I can do it quickly enough.

bethskurrie
2020-11-25 03:53
So, here's the scenario

bethskurrie
2020-11-25 03:53
```td = PactBroker::Test::HttpTestDataBuilder.new('http://localhost:9292', { }) td.delete_integration(consumer: "MyConsumer", provider: "MyProvider") .can_i_deploy(pacticipant: "MyProvider", version: "1", to: "prod") .can_i_deploy(pacticipant: "MyConsumer", version: "1", to: "prod") .publish_pact(consumer: "MyConsumer", consumer_version: "1", provider: "MyProvider", content_id: "111", tag: "feature/a") .can_i_deploy(pacticipant: "MyProvider", version: "1", to: "prod") .get_pacts_for_verification( enable_pending: true, provider_version_tag: "main", include_wip_pacts_since: "2020-01-01", consumer_version_selectors: [{ tag: "main", latest: true }]) .print_pacts_for_verification .verify_pact( index: 0, provider_version_tag: "main", provider_version: "1", success: true ) .print_pacts_for_verification .can_i_deploy(pacticipant: "MyProvider", version: "1", to: "prod") .can_i_deploy(pacticipant: "MyConsumer", version: "1", to: "prod") .deploy_to_prod(pacticipant: "MyProvider", version: "1") .can_i_deploy(pacticipant: "MyConsumer", version: "1", to: "prod") .deploy_to_prod(pacticipant: "MyConsumer", version: "1")```

bethskurrie
2020-11-25 03:54
And here's the output. It makes more sense if you can play around with it locally though.

bethskurrie
2020-11-25 03:54
```============================================================= can-i-deploy MyProvider version 1 to prod: no --- errors: pacticipant: - No pacticipant with name 'MyProvider' found ============================================================= can-i-deploy MyConsumer version 1 to prod: no --- errors: pacticipant: - No pacticipant with name 'MyConsumer' found ============================================================= Creating tag 'feature/a' for MyConsumer version 1 Publishing pact for consumer MyConsumer version 1 and provider MyProvider ============================================================= can-i-deploy MyProvider version 1 to prod: no --- deployable: false reason: No pacts or verifications have been published for version 1 of MyProvider success: 0 failed: 0 unknown: 0 ============================================================= Fetching pacts for verification for MyProvider --- :providerVersionTags: - main :consumerVersionSelectors: - :tag: main :latest: true :includePendingStatus: true :includeWipPactsSince: '2020-01-01' ============================================================= Pacts for verification (1): --- url: http://localhost:9292/pacts/provider/MyProvider/consumer/MyConsumer/pact-version/00b1b6424125436c79369dddaf351313ba811aa8/metadata/d2lwPXRydWU= wip: true pending: true ============================================================= Publishing verification ============================================================= Pacts for verification (1): --- url: http://localhost:9292/pacts/provider/MyProvider/consumer/MyConsumer/pact-version/00b1b6424125436c79369dddaf351313ba811aa8/metadata/d2lwPXRydWU= wip: true pending: true ============================================================= can-i-deploy MyProvider version 1 to prod: yes --- deployable: true reason: There are no missing dependencies success: 0 failed: 0 unknown: 0 ============================================================= can-i-deploy MyConsumer version 1 to prod: no --- deployable: reason: There is no verified pact between version 1 of MyConsumer and the latest version of MyProvider with tag prod (no such version exists) success: 0 failed: 0 unknown: 1 ============================================================= Deploying MyProvider version 1 to prod Creating tag 'prod' for MyProvider version 1 ============================================================= can-i-deploy MyConsumer version 1 to prod: yes --- deployable: true reason: All required verification results are published and successful success: 1 failed: 0 unknown: 0 ============================================================= Deploying MyConsumer version 1 to prod Creating tag 'prod' for MyConsumer version 1 =============================================================```

bethskurrie
2020-11-25 04:05
The tweak I did was to change the WIP pacts logic so that if there were no provider versions published, then all head pacts (the latest pact for each tag) are considered WIP.

bethskurrie
2020-11-25 04:05
This means that if you have WIP on, you always get a pact to verify (if one exists).

bethskurrie
2020-11-25 04:05
Can't do much on the broker side if no pacts exist at all.

bethskurrie
2020-11-25 05:14
Bother. It's not quite right. But it's slightly better.


bethskurrie
2020-11-25 05:15
Do what it says. You'll end up with an error "RuntimeError No pact found to verify at index 0" because there are no pacts to verify.

bethskurrie
2020-11-25 05:15
then kill those containers with `docker-compose -f docker-compose-issue-repro.yml up`

bethskurrie
2020-11-25 05:16
and change RACK_ENV=production to RACK_ENV=development and do it again.

bethskurrie
2020-11-25 05:16
This time, you'll get some pacts to verify the first time, but once it's verified successfully, that publishes a provider version, and that makes the pacts not be considered WIP again.


nerea.tamayo
2020-11-25 07:41
Oh, thanks a lot for the link!! @brendan.donegan I'm able to do the Post using curl from the terminal, but now I'm not able to traduce it in PactFlow. In Jnekins I have user/pasword but I generated a token for my user and it works from the terminal

brendan.donegan
2020-11-25 09:25
@nerea.tamayo if the curl command works, you can use the pact-broker create-webhook command and pass the same options as the cURL command to it

nerea.tamayo
2020-11-25 10:26
I did this i PactFlow

nerea.tamayo
2020-11-25 10:26
and I'm getting this error

nerea.tamayo
2020-11-25 10:26
[2020-11-25T10:21:02Z] DEBUG: Webhook context {"base_url":"https://XXXXX.pact.dius.com.au"} [2020-11-25T10:21:02Z] INFO: HTTP/1.1 POST https://jenkins.tools.XXXXX.com/instanceXX/job/XXXX/job/XXX/job/Pact_Glass_Capi/job/triggered_pact_verification/job/master/build [2020-11-25T10:21:02Z] INFO: accept: */* [2020-11-25T10:21:02Z] INFO: user-agent: Pact Broker v2.68.1 [2020-11-25T10:21:02Z] INFO: authorization: [REDACTED] [2020-11-25T10:21:02Z] INFO: host: http://jenkins.tools.XXXXX.com [2020-11-25T10:21:02Z] INFO: content-length: 0 [2020-11-25T10:21:02Z] INFO: content-type: application/x-www-form-urlencoded [2020-11-25T10:21:02Z] INFO: [2020-11-25T10:21:02Z] INFO: HTTP/1.0 302 Found [2020-11-25T10:21:02Z] INFO: server: BigIP [2020-11-25T10:21:02Z] INFO: content-length: 0 [2020-11-25T10:21:02Z] INFO: location: /my.policy [2020-11-25T10:21:02Z] INFO: set-cookie: LastMRH_Session=ceaec8cc;path=/;secure, MRHSession=Xxxxxxx;path=/;secure, MRHSHint=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/;secure [2020-11-25T10:21:02Z] INFO: connection: close [2020-11-25T10:21:02Z] INFO: [2020-11-25T10:21:02Z] INFO: Webhook execution failed

matt.fellows
2020-11-25 10:28
That looks like an auth proxy has intercepted and is redirecting to an auth challenge. Don't forget Pactflow is running in our cloud. Can you please check the curl works from outside of your network?

nerea.tamayo
2020-11-25 10:42
yes, you're right! from outside of my VPN it doesn`t work

brendan.donegan
2020-11-25 11:28
@nerea.tamayo we are in a similar situation, our Jenkins is inside the network firewall

brendan.donegan
2020-11-25 11:29
It?s an ongoing saga

brendan.donegan
2020-11-25 11:29
Hopefully your IT/Devops team is less bureaucratic than ours

nerea.tamayo
2020-11-25 11:32
hahaha, I think the bureaucratic is there.....

nerea.tamayo
2020-11-25 11:33
So, the solution is whitelisting the PactFlow IP into our Jenkins, right?

nerea.tamayo
2020-11-25 11:33
And after that....It Should work

brendan.donegan
2020-11-25 11:34
It all depends on your network setup. But you need to be able to issue the cURL command successfully while off the VPN

matt.fellows
2020-11-25 11:49
FYI - our public IP addresses can be found at https://pactflow.io/faq/#ip-address-whitelist

nerea.tamayo
2020-11-25 12:55
Thanks @matt.fellows!

scyr
2020-11-25 14:56
has joined #general

timotheus.ruprecht
2020-11-25 22:12
has joined #general

phil.endsley
2020-11-25 22:46
I didn't get time to look at this today, abd won't the rest of this week. Will try to make time early next week to look

bethskurrie
2020-11-25 22:46
np

tjones
2020-11-26 01:00
Friends, I was trialing some Pact swag, but because I am bad at using computers, I ordered an XL shirt instead of an XS. Would someone from the channel like it? I will post it anywhere in the world- the only cost will be that you must agree to tell other developers about how great Pact is when you wear it ;) MacBook power adaptor for scale (sorry I didn?t have a banana).

tjones
2020-11-26 01:02
Fit 61cm wide, 82cm tall

tjones
2020-11-26 01:02
If you?d like it, PM me your mailing address. First in best dressed (literally).

matt.fellows
2020-11-26 02:38
do you come with the shirt Tim?

matt.fellows
2020-11-26 02:38
that would help my decision making

tjones
2020-11-26 02:42
I don't, so you can safely ask for it

matt.fellows
2020-11-26 02:44
do you come with the car

tjones
2020-11-26 03:48
^ for anyone reading this without context, Matt and I know each other well. I also know that: 1) Matt already tells people how awesome Pact is, and 2) this shirt won't fit him either. So, Matt- I'm not sending it to you :stuck_out_tongue:

matt.fellows
2020-11-26 04:10
it?s damn shame, would have mad a nice rag

matt.fellows
2020-11-26 04:10
The blue looks quite nice actually

tjones
2020-11-26 04:19
I'm going to order again, but in my actual size. Want one?

tjones
2020-11-26 04:19
Also with a white logo

rarora
2020-11-26 04:46
Thank you for adding retry mechanism with gradle task canIDeploy. can anyone please share one example how values will be passed in case of gradle? I tried below and it seem to not care about retry. ```./gradlew canIDeploy -Ppacticipant=ProductService -PpacticipantVersion=-Ppact.provider.version -DretryCountWhileUnknown=12 -DretryWhileUnknownInterval=10 -PtoTag=develop --info```

wilkinsweiqiangliang
2020-11-26 06:53
#general Hey guys, does pactflow always trigger the `HEAD` commit? i follow the event template from docs, and find it sometime send `HEAD` commit, sometime send a different commit.

manali.mogre
2020-11-26 11:44
has joined #general

erik.terpstra
2020-11-26 12:08
has joined #general

kjayachandra2000
2020-11-26 20:40
has joined #general

sushil.kumar
2020-11-27 01:45
has joined #general

tjones
2020-11-27 02:56
I would try this question in #pactflow

zhujian
2020-11-27 07:54
has joined #general

h.octavian
2020-11-27 14:08
has joined #general

noel
2020-11-28 23:12
has joined #general

muraalee
2020-11-30 01:56
has joined #general

pooja.sharma
2020-11-30 08:52
has joined #general

mo
2020-11-30 09:24
has joined #general

aliaksandr.valadzko
2020-11-30 15:45
Hey guys I have a question regarding PACT _federation_ or something like this In our company we have huge amount of teams, which develop their own bunch of microservices. At this point we add PACT testing within our team's microservices. However we also want to provide to other teams (our consumers) ability to send PACT contracts to our broker. So my question is, how this situation should be handled - does every team should have its own PACT broker service, or there should be one _Godlike_ PACT broker service which should be shared across teams, or there is some mechanism to connect PACT broker services? Thanks!

aliaksandr.valadzko
2020-11-30 15:50
Sorry, looks like wrong place:slightly_smiling_face: Will move this question to other channel

2020-11-30 18:29
A new post has been created in *Feature Requests*

eric.jones
2020-11-30 20:53
Question, regarding access of test results from within a methods in a Pact Provider test using Pact-JVM: ```Is there any way to access test result status while running our Provider Tests? Is there any sort of construct available to access this information while a Provider test is running on Junit4? I know that there is mention of a PactVerificationContext; but it seems to be limited to Junit5. Looking for some guidance on how to move on this for JVM - is it possible with Junit4 and if not, does the PactVerificationContext have accessibility from within methods in the Provider tests, when using Junit5?```

phil.endsley
2020-11-30 21:14
FYI - There are language specific channels for questions specific to that language. #pact-jvm I don't know the answer. But I am curious what the use case is

david.greene
2020-11-30 21:47
has joined #general

bas
2020-12-01 09:00
has joined #general

ravi.mijar
2020-12-01 11:58
where can I order? :slightly_smiling_face:

wainstead
2020-12-01 14:57
has joined #general

jerobinson
2020-12-01 20:32
has joined #general

sumedhagamage
2020-12-02 03:33
has joined #general

antonello
2020-12-02 09:33
Do we have any resources on how to deal with feature flags and dark releases?

matt.fellows
2020-12-02 10:00
good question, I don?t think so

matt.fellows
2020-12-02 10:00
we should also get some published around pure trunk based dev (as in _no branches_)

antonello
2020-12-02 10:03
We have had some conversations this morning with one of our teams that - unsurprisingly - has experiencing issues and raised concerns.

fealaer
2020-12-02 11:40
has joined #general

antonello
2020-12-02 13:40
I?d love to hear thoughts and current solutions when it comes to managing feature flags

patrick.hendron
2020-12-02 14:44
has joined #general

michaelkochub
2020-12-02 15:43
Question about ensuring consumer contracts remain accurate: since the goal of a consumer contract test is to avoid testing business logic and remain a unit test that encodes the client's expectations for the provider, how do we ensure a consumer contract test doesn't drift? Basically, if someone changes the structure of an API request that the consumer makes to the provider, that developer won't immediately know that the contract test should be updated because the unit test itself still passes. Is there a good way to alert the developer by breaking the unit test somehow? This comes with the caveat that if you start adding more business logic testing into the unit test it becomes more of a functional test.

antonello
2020-12-02 15:49
As a general principle, you should https://docs.pact.io/consumer#ensure-all-calls-to-the-provider-go-through-classes-that-have-been-tested-with-pact. This means that you should write pact tests by exercising the very client classes that make the api requests.

antonello
2020-12-02 15:51
In strongly typed languages, this is a good enough guarantee that you cannot drift to the point that the contracts are inaccurate. What could happen is that you contract might end up using more than needed if you forget to, for example, remove unused fields.

antonello
2020-12-02 15:52
In languages that are not strongly typed, like Javascript, you might want to put other measures in place. See this https://docs.pact.io/consumer#ensure-the-models-you-use-in-other-tests-could-actually-be-created-from-the-responses-you-expect.

antonello
2020-12-02 15:55
@tjones touched on this in the Pact Community Event we held not so long ago. https://www.youtube.com/watch?v=wkld_wRsTDE

phil.endsley
2020-12-02 15:55
I was interpreting the question as how to not break existing pacts by altering the way a consumer makes api calls. ex: I have an existing contract that is verified, but I can change the consumer in a way that changes that contract. Everything on the consumer still passes. Is there a way to alert the developer that you're breaking the contract on the consumer Here's the way I think about it...Pact is _consumer_ driven, so the assumption is the consumer definition will be correct. Because of this, failing unit tests on the consumer side for "breaking a contract" wouldn't be great, because the consumer is one driving the api. You can prevent breaking changes by leveraging `can-i-deploy` as part of the merge checks for commits. If the consumer is deployable, the pact has been verified with the provider, and is safe to merge.

antonello
2020-12-02 15:56
Oh I see, @phil.endsley. I definitely got the wrong end of the stick. I scanned through the question rather than reading it properly.

antonello
2020-12-02 15:59
As I touched on in the talk linked above, where I work we take it even a step further and we execute the provider tests in every single pipeline. Something that you can do asynchronously with webhooks, but at the moment we prefer to do it synchronously.

michaelkochub
2020-12-02 16:53
Thank you for both of your inputs. That sounds like it might be worth clarifying the documentation that provides code samples to link back to what you initially sent me @antonello

michaelkochub
2020-12-02 16:54
For instance, the Groovy code sample for writing a consumer test https://docs.pact.io/implementation_guides/jvm/consumer/groovy#usage uses a basic RESTClient to make the calls, but really it would be better to exercise a client that the business application uses. In this case, then it would be best to add a caveat or a notice to indicate something like `"While this example instantiates a vanilla Groovy RESTClient to make an invocation, the recommended pattern is to test with the same client classes that the application uses"`

michaelkochub
2020-12-02 16:56
However, that's not entirely the case for all the examples. Over in the code sample for using JUnit to write a contract test https://docs.pact.io/implementation_guides/jvm/consumer/junit#usage you use a custom client https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/src/test/java/au/com/dius/pact/consumer/junit/exampleclients/ConsumerClient.java

antonello
2020-12-02 17:36
It might be work creating a PR @michaelkochub :slightly_smiling_face:

lpratt
2020-12-02 18:19
has joined #general

tjones
2020-12-02 21:19
Oh! This is a great catch, @michaelkochub ! Yes, the intention is very much that the actual code that is called by the consumer is what is tested in consumer pact tests

tjones
2020-12-02 22:38
Where the contract is different if the feature flags are different?

tjones
2020-12-02 22:39
I haven't tried this, but could you build that in to pact tags?

antonello
2020-12-02 22:44
Well, there are (at least) 2 cases: 1. An existing interaction changes, for example a new field is required for a new feature. Consumer wants to add it test first, and they put the feature behind feature flag so that they can keep deploying to prod with the feature off. In a continuous deployment world you don?t want to wait for the provider to have implemented the API in order to deploy whatever is in trunk with the flag off.

antonello
2020-12-02 22:45
2. You need a brand new interaction, but this corresponds to a feature behind a flag that will be off until completed.

antonello
2020-12-02 22:46
There is also another interesting case, which is how to deal with feature flags that are enabled or disabled are runtime.

tjones
2020-12-02 22:51
yeah, I think there might be several different approaches depending on how the flags are used- but you're right that it's not obvious how to do it cleanly. With feature flags, I think there are usually some implicit assumptions, like "prod never turns this flag on"- and that's worth observing. The can-i-deploy question becomes something like "can I deploy X with prod, if prod has <these flags>"

tjones
2020-12-02 22:52
That's what made me think that tags might be the right approach, but I'm not certain.

tjones
2020-12-02 22:54
tags are for different cuts of pacticipants that might have different features - it feels like there would be a model where you have a tag that represents a specific feature flag set- and "prod" would be a layer of indirection to the current feature flags, maybe. But, if you've got feature flags in several pacticipants that might become complex quickly.

antonello
2020-12-02 22:55
One dirty trick that perhaps is not that dirty that some teams have started to use to address case 2 (well, also to get ahead or providers adding pact for existing features) is to publish some interactions in a different pact for a provider-temp.

tjones
2020-12-02 22:55
Right, you could view that as an alternative to tagging

tjones
2020-12-02 22:56
I kind of like the idea that you might have two interactions, and do it with provider states: "when the provider has NewFlag not set, I get this 404" "when the provider has NewFlag set, I get this 200"

antonello
2020-12-02 22:58
The problem is that once they end up into your trunk, they?ll both be published and at some point need to be verified or you won?t be able to release. Unless you suddenly have a way of tagging interactions.

tjones
2020-12-02 22:59
Yes (sorry phone rang before I could type up the next part) - then you could use tags to "toggle" the inclusion of the newflag part

matt.fellows
2020-12-03 00:18
FYI Beth has done a bit of thinking about this. It?s currently documented in the advanced workshop: https://docs.pactflow.io/docs/workshops/advanced

matt.fellows
2020-12-03 00:18
(search for ?toggles?)

abubics
2020-12-03 01:15
@antonello?s description is just like a chat we had in #pact-jvm yesterday :thinking_face: Feels like some concerns show up in patterns :party_parrot:

sandragnzalez
2020-12-03 11:04
has joined #general

kristian
2020-12-03 14:34
has joined #general

me1466
2020-12-03 23:42
has joined #general

stephane.meng
2020-12-04 07:23
Sorry if this question is a bit simple, what would be the PACT recommended workflow when both consumer and providers add incompatible changes with each other, e.g: Current production is consumer v1 and provider v1 consumer v2 publishes a new pact, and will become incompatible with provider v1 provider v2 makes the changes, but is incompatible with consumer v1 Both consumer v2 and provider v2 builds will not be green under pact framework from my understanding, is that correct ? In this case, what is the recommended way of deploying both v2s ?

matt.fellows
2020-12-04 07:30
usually you would use an "expand and contract" approach where you add the new fields/changes in addition first and then remove after the consumer(s) no longer needs them. A provider also had the right not to implement a change and give feedback for a bad suggestion (if it's indeed the case)

matt.fellows
2020-12-04 07:31
The scenario you're presenting essentially requires releasing both components at the same time, which is usually a bad idea and is sort of why Pact exists

stephane.meng
2020-12-04 07:37
Thanks for your response, makes sense !

mbieganski.infomatt
2020-12-04 09:55
Hi I have a question about WIP and pending pacts. Given I have below setup for provider ```@PactBroker( consumerVersionSelectors = { @VersionSelector(tag = "master"), @VersionSelector(tag = "dev") }, enablePendingPacts = "true", includeWipPactsSince = "2020-11-20", providerTags = "pact-update-test" )``` and there also feature branch for consumer called "new-feature". Do I understand correctly that provider will run tests against master,dev and new-feature but build will fail only if tests fail for consumerVersionSelectors branches?

mbieganski.infomatt
2020-12-04 10:46
Or still consumer and producer still have to create matching branches?

wenfeng.li
2020-12-04 11:42
has joined #general

phil.endsley
2020-12-04 13:54
Close. There's some subtleties that are easy to gloss over, but can have big impacts. With the above configuration, your provider will always run verification against the latest versions tagged with `master` and `dev`. When you enable pending pacts, that means if a pact is in the pending state, and fails verification, the build will not fail. A pact is pending if it has not been successfully verified by a provider tagged with `providerTags` ("pact-update-test" in your case). Once it has been verified successfully, it is no longer pending. This applies to all pacts that are verified, even if they are specified with version selectors. `includeWipPactsSince` will also pull in any pacts that are "WIP". A WIP pact is the latest pact for its tag that has not been successfully verified by the provider tagged with `providerTags`. The other caveat is that there must be an existing version of the provider tagged with `pact-update-test` to get WIP pacts. So, putting all this together with the following assumptions: ? You have a provider version tagged with `pact-update-test` published to pact broker ? The pact tagged with `new-feature` has not been successfully verified ? The pact tagged with `new-feature` was published after 11-20-2020 Your provider will run verifications against the latest versions of `master`, `dev`, and `new-feature`. If `new-feature` fails verification, the provider build will still pass. Note that it's possible for the latest version of `dev` to also be pending. This can happen if the consumer team accidentally merges a change to Pacts before verifying. In this case, it's possible for verification to fail, but the provider build still passes. This is why it's important to leverage `can-i-deploy` in your pipeline as well.

phil.endsley
2020-12-04 13:58
I think there was also a change recently to determine when a pact is no longer WIP, but I haven't had time to fully wrapped my head around it yet https://pact-foundation.slack.com/archives/C9VPNUJR2/p1606166532472100?thread_ts=1605857445.464000&cid=C9VPNUJR2

mbieganski.infomatt
2020-12-04 14:01
OK so maybe that's my problem right here > The other caveat is that there must be an existing version of the provider tagged with `pact-update-test` to get WIP pacts. I working on my branches so master branches are not yet updated with latest pact but have 2 feature branches 1 for consumer and provider with different names. So I thought that if I run provider locally it will test against master, dev and will pull latest from feature branches. If I understand correctly I have to merge everything to stable branches for it to actually work? I have can-i-deploy and webhooks setup and works really nice (some devs might disagree :smile: ) but having to set branches manually to match is little annoying :wink:

phil.endsley
2020-12-04 14:11
If you're doing feature development in consumer and provider branch at the same time, I would recommend finding a way to include the consumer tag as a version selector. The problem you may run into if you don't, is a successful verification will remove the pending status, so further commits on the provider won't run verification against that tag. We're in the same situation of manually adding branches. Our current workflow is to delete the version selector just prior to merging the provider. Agree it's annoying/tedious. We've brainstormed in this chat about it before, but haven't come up with other strategies. Using matching branch names is another popular solution, but my company's workflow doesn't allow that. I'm open to other ideas if you have any!

phil.endsley
2020-12-04 14:12
So WIP pacts will make it so once you merge the provider branch (without specifying the consumer tag), the wip settings will verify against your consumer branch, and allow you to merge the consumer branch in (Since it will be verified from the dev build)

mbieganski.infomatt
2020-12-04 14:37
I was under the impression while back when there were first rumors about WIP and pending that it will solve the need of creating matching branches. Currently we are adding provider tag as ```systemProperties.put("pactbroker.tags", "dev,master," + branchName);``` so if there is matching consumer branch it will be verified. Of course there separate provider jobs triggered by webhook to test verify contract by url. Reading the link you sent about removing WIP looks I should also add `PACT_BROKER_FEATURES=experimental_webhook_wip`

mbieganski.infomatt
2020-12-04 14:44
I can do something like ```systemProperties.put("pactbroker.consumerversionselectors.tags", "dev,master," + branchName");``` and it should work as previously but then I think I'm missing the point of using WIP or Pending

phil.endsley
2020-12-04 15:07
> I was under the impression while back when there were first rumors about WIP and pending that it will solve the need of creating matching branches. Same. I think I got it from the way it's worded in one of the workshops (https://docs.pactflow.io/docs/workshops/ci-cd/workshop/verifying-feature-pacts lists 3 ways for verifying feature branches), but this hasn't been my experience. What I've found is: Pending - Makes it so consumers can't break provider builds/deployments by merging "bad" contracts WIP - Makes the merging process easier for feature branches

phil.endsley
2020-12-04 15:07
RE: the workshop, it works fine if the provider is running the main branch. But not when you have feature branches for both

mbieganski.infomatt
2020-12-04 15:19
well from my experience with current setup the only way to "break" provider stable branch is to merge failed contract to master and create sort of deadlock but that involves ignoring/not checking broker before merging but yeah it can happen.. I hoped that with WIP and pending provider will always check all consumer latest branches fail tests if something is broken but fail build only when tests failed for stable branch and then we have can I deploy that would stop consumer if it wasn't previously verified by expected tag... From your experience the pactbroker.consumerversionselectors.tags should still contain the provider branch tag which should match consumer?

phil.endsley
2020-12-04 15:20
For provider branch feature development, yes

phil.endsley
2020-12-04 15:21
If you're using pending pacts, you shouldn't get into a bad state on the provider. Verification will fail if the consumer merges a failed contract, but the build should still pass, allowing the provider to continue deployments

mbieganski.infomatt
2020-12-04 15:25
broken dream

mbieganski.infomatt
2020-12-04 15:25
I hoped I will get rid of passing matching branches :stuck_out_tongue:

phil.endsley
2020-12-04 15:26
The only thing I've thought of is to support regex matching. Our branches include the ticket number, which will be unique per project, so we can't have exact matches. If regex matching was supported, we could format ours to match except ticket number and match that way

phil.endsley
2020-12-04 15:28
Still stuck with coordinating names, but it would make it so we don't have to add/remove a selector for every feature branch (For my specific workflow at least :slightly_smiling_face: ) https://pact.canny.io/feature-requests/p/allow-version-selectors-to-specify-tags-with-regex

mbieganski.infomatt
2020-12-04 15:30
maybe that's idea. but you can always have the branch to include both ticket number from provider and consumer.

phil.endsley
2020-12-04 15:33
That's a good idea! I think this is something that would work in theory, but not in practice (again, for my org). Too many non-technical people using the non-pact tools with integrations that would cause confusion

mbieganski.infomatt
2020-12-04 15:34
yeah that's always that small problem :wink: Thanks for help!

cdambo
2020-12-05 11:59
has joined #general

ranjanayush03
2020-12-08 03:40
Hi all we are facing an issue when trying to validate the last login date of the user onto the app , we need to validate only the format of the time and not the actual value and we tried doing that but facing issue like '''[{mismatch=Expected '2020-12-07T11:08:54.800+00:00' to match a timestamp of 'yyyy-MM-dd'T'HH:mm:ssXx': Unable to parse the date 2020-12-07T11:08:54.800+00:00, diff=}]. Can someone please help me with this.

bethskurrie
2020-12-08 03:40
@ranjanayush03 please ask in #pact-jvm

bethskurrie
2020-12-08 03:41
Assuming you're using jvm as the timestamp matchers are in jvm.

ranjanayush03
2020-12-08 03:41
Yeah we are using jvm I asked there but I didn't got any reply

gayatree.eee
2020-12-08 04:50
has joined #general

tjones
2020-12-08 06:34
I don't know much about the JVM pact implementation, but it looks like the timestamp there doesn't match the format that is listed

ranjanayush03
2020-12-08 14:56
Thank you Tim was able to parse it successfully

c.pavan1986
2020-12-09 04:18
has joined #general

william.pritchard
2020-12-09 15:28
has joined #general

parveshchaudhary111
2020-12-09 17:54
has joined #general

nouri.tawfik
2020-12-09 20:16
Hello, Does pact_broker have any endpoint to check online version? Something like http://pact-broker.comm/version? Thanks

phil.endsley
2020-12-09 20:18
Are you looking for an endpoint you can query from some process? If you go to the API browser, you can see the version in the response headers section. `x-pact-broker-version`

nouri.tawfik
2020-12-09 20:22
Thanks Phil, just need to know the installed version manually, so x-pact-broker-version it's OK for me.

eric.jones
2020-12-09 23:29
I want to be able to view and parse individual test method results for reporting purposes outside of pact.

w.sobasik
2020-12-10 10:39
has joined #general

thanuxxxx
2020-12-12 22:41
has joined #general

ian.hamilton
2020-12-13 06:53
has joined #general

colm.j.murphy91
2020-12-13 07:02
has joined #general

victoria.kruczek
2020-12-13 14:13
has joined #general

2020-12-14 05:09
A new post has been created in *Feature Requests*

wuddarwin
2020-12-14 05:23
has joined #general

connor.aird
2020-12-14 15:52
has joined #general

arman.najafian
2020-12-14 15:52
has joined #general

praveen.lakkaraju
2020-12-14 16:12
has joined #general

alejandro.germain
2020-12-14 16:26
has joined #general

wuddarwin
2020-12-14 18:08
Hi folks, Are there any docs or SOPs I can reference if I want to create a new language support for Pact? I'm aware there's a Rust implementation available so it would be great if there are some docs to explain how to interface with it.

matt.fellows
2020-12-14 23:19
Ah, you want to create an Elixir port right?

wuddarwin
2020-12-14 23:21
yeah, or help get the existing one to a more complete state https://github.com/elitau/pact_elixir unless you already have plans of doing so

matt.fellows
2020-12-14 23:22
Oh cool!

wuddarwin
2020-12-14 23:22
regardless, helping with the existing one or not, i'm having a hard time finding docs or SOPs for implementation so would be great to have someone to point me to the right direction

matt.fellows
2020-12-14 23:23
SOP = ?

matt.fellows
2020-12-14 23:23
Solution on a Page?

wuddarwin
2020-12-14 23:23
standard operating procedure

matt.fellows
2020-12-14 23:23
How familiar with Pact are you already?

wuddarwin
2020-12-14 23:24
somewhat, i've read through all the docs on your website and i know what contract testing is.

matt.fellows
2020-12-14 23:24
Have you ever written tests or anything in it?

matt.fellows
2020-12-14 23:25
I only ask because having some experience will make it much easier to build a nice API for your users

uglyog
2020-12-14 23:26
In some of the enterprise circles we been working in, Solution on a Page is abbreviated as SOAP :smile:

matt.fellows
2020-12-14 23:26
yes - I?m used to that. I thought it was perhaps a variation on the abbreviation

wuddarwin
2020-12-14 23:26
no, i haven't written any tests in the context of pact yet. i was going to write the provider tests for go but the consumer of that service is an elixir app so here we are

matt.fellows
2020-12-14 23:26
It makes sense to call it soap - the things are usually pretty slippery

uglyog
2020-12-14 23:27
The big downside of open source software, is that people do it in their spare time. Who wants to work on documentation in their spare time instead of a new fancy feature!

uglyog
2020-12-14 23:27
But we're here to answer any questions. The best thing is to pick a current implementation and use that as a reference.

wuddarwin
2020-12-14 23:28
understandable. how's the documentation on the rust implementation so far? if there's enough docs there, i can just built the docs and read it there. i took a peek but haven't seen much at the moment.

uglyog
2020-12-14 23:30
I haven't written much. The best thing there is to look at the Pact-JS V3 and Pact-C++ or Pact-Go to see how they are intergrated

uglyog
2020-12-14 23:31
Pact-JS one has a native Node module which use the Rust libraries. Pact-C++ and Pact-Go use the FFI bindings

matt.fellows
2020-12-14 23:32
I would go with the Pact C++ one because the go code is still a bit of a mess. At least, the consumer side is

matt.fellows
2020-12-14 23:32
C++ also follows the ?handle? API you created, whereas the go code was initially created pre that interface.

wuddarwin
2020-12-14 23:32
does ruby version also uses FFI? since Elixir syntax is actually somewhat close to ruby, it might be easier for reference. otherwise, i can definitely look at the ones in Go

matt.fellows
2020-12-14 23:32
It?s also in use by real customers

matt.fellows
2020-12-14 23:33
Ruby doesn?t use the Rust engine at all. It _is_ currently the engine used elsewhere by other langs, and we are actively moving to Rust where we can

wuddarwin
2020-12-14 23:33
i see. i'll take a look at the C++ one then

wuddarwin
2020-12-14 23:34
as for guidance, is it best to implement the v1 spec first before moving on to v2 and v3?

matt.fellows
2020-12-14 23:34
We can use the #pact-rust channel also

matt.fellows
2020-12-14 23:35
I would completely ignore the v1 spec, because it?s so old. I?d start with v2 compatibility because all other first class languages support at least v2

wuddarwin
2020-12-14 23:36
i see. thank you.

josh.ellinger
2020-12-15 01:22
has joined #general

nikitsenka
2020-12-15 09:35
has joined #general

hibahawes
2020-12-15 09:53
has joined #general

sarvar
2020-12-15 14:24
has joined #general

bheemreddy181
2020-12-15 21:10
But do you really care about all those 50 fields or you reading everything even if you don't really need them?

bheemreddy181
2020-12-15 21:29
do we have roles and permissions on the open-sourced version as well https://pactflow.io/blog/teams-roles-and-permissions/

bethskurrie
2020-12-15 21:29
No.

lewis.thorley
2020-12-15 23:18
So this is very PoC, but I am in the progress of creating a PACT consumer for Dart. Which I am hoping will be popular among flutter developers. It's pretty rough and ready but I have achieved my first goal of being able to have a server catch the interactions sent by the Dart http client. https://github.com/lemusthelroy/dart-pact-testing

marko.justinek
2020-12-15 23:24
Great work @lewis.thorley!!! We?ll have to open a #pact-dart channel now :tada:

matt.fellows
2020-12-16 01:15
You can see the key differences between Pactflow and OSS pact here: http://pactflow.io/features

suruchipatidar14
2020-12-16 05:35
has joined #general

smatheson
2020-12-16 06:33
has joined #general

olayemifolakemi
2020-12-16 15:23
has joined #general

ania.kovalchuk
2020-12-17 00:09
has joined #general

writetojoshma
2020-12-17 05:52
has joined #general

tjones
2020-12-17 06:48
This is awesome news! Taco for @lewis.thorley!

tjones
2020-12-17 07:17
Er, let's do that properly: :taco: for @lewis.thorley

elliottmurray
2020-12-17 09:09
:taco:

elliottmurray
2020-12-17 09:09
all round!

rejeesh.g
2020-12-17 11:07
has joined #general

lukas.kempec
2020-12-17 12:45
has joined #general

vikas543
2020-12-17 16:28
has joined #general

bpugh
2020-12-17 17:05
has joined #general

kflo
2020-12-19 03:10
just wanted to say i completed a proof of concept of the entire pact workflow with two of our microservices, including the necessary updates to our CI/CD pipelines, and it was overall pretty easy. really loving what this tool provides, i know a lot of hard work went into it so thanks everyone involved! looking forward to getting more involved in the project at some point

kflo
2020-12-19 03:10
at least for now i can be somewhat helpful in #pact-scala-itv :slightly_smiling_face:

jeff.burmood
2020-12-19 17:45
has joined #general

bheemreddy181
2020-12-19 18:58
It?s been a big challenge in general for me to get my principals agree on this approach - they always wanted to write a lot of unit tests and they feel contract tests are always extra effort , I requested for a demo from pact so that lot of their questions are answered. Few teams are really confident as they started writing contract tests - looking forward for 2021 I should on-board this on more teams.

bheemreddy181
2020-12-19 19:00
Few of them always argue that you should treat your services completely independent like how you use google / AWS services and treat internal services in the same way and we should never change any contract once a service is written - I disagree on that but it?s been really hard to convince all

kyle.florence
2020-12-19 19:21
has joined #general

ankurmalik22
2020-12-19 21:14
has joined #general

vsukumaran
2020-12-20 01:56
has joined #general

omer.morad
2020-12-20 08:10
has joined #general

ringo
2020-12-20 10:51
has joined #general

omer.moradd
2020-12-20 18:01
has joined #general

omer.moradd
2020-12-20 18:10
Hi all :) I am new to Pact.js and after some reading, I found it awesome! exactly the thing we were looking for in the company. We work with NestJS a lot, and I thought that creating an NPM Package that brings those two great technologies together will be nice I would love to hear what you guys think of it! NPM: https://www.npmjs.com/package/nestjs-pact Github: http://www.github.com/omermorad/nestjs-pact

abubics
2020-12-20 23:21
I can say, from experience, that a lot of people struggle to comprehend the value of (many kinds of) testing, and many only do it begrudgingly.

abubics
2020-12-20 23:24
And many times I've heard weird excuses for why they don't want to do contract testing, such as ? Both sides of the interface are our own people, so they can just talk to each other. ? We already have end-to-end tests. ? The responses are too big (so it's too hard). ? The responses are too small/simple (so it's unnecessary). and many more.

abubics
2020-12-20 23:24
I hope you can get some traction & understanding :pray:

abubics
2020-12-20 23:26
fwiw, I usually try to highlight the kinds of gaps that people have in their testing strategy, or speed & specificity improvements that could be gained . . . and don't focus on pact, just focus on confidence & consumer-provider drift

abubics
2020-12-20 23:26
(Pact isn't the only tool that can help, but it is many people's preference for its target niche)

2020-12-21 11:17
A new post has been created in *Feature Requests*

souravsen1
2020-12-21 11:28
has joined #general

bheemreddy181
2020-12-21 17:23
Thanks, Boris for sharing your inputs here. helps a lot

andoni.arroyo
2020-12-21 17:51
has joined #general

theovanessen
2020-12-22 10:47
has joined #general

stuart3166
2020-12-22 12:35
has joined #general

winfante
2020-12-22 22:51
has joined #general

bheemreddy181
2020-12-23 01:13
Need some feedback on how the development workflow should look like with new API's - I created a workflow ( flow chart ) as below

bheemreddy181
2020-12-23 02:33
@matt.fellows@matt.fellows@matt.fellows @bethskurrie@bethskurrie@bethskurrie @abubics any feedback will be really helpful

abubics
2020-12-23 03:22
We're all on holidays :) someone might reply if they're free, though

abubics
2020-12-23 03:23
Probably want to be careful how you tag people, too

bheemreddy181
2020-12-23 04:25
Sorry for the tag , happy holidays

lars.bonnes
2020-12-23 13:05
has joined #general

lewis.thorley
2020-12-23 15:08
I like that workflow

claudiond
2020-12-23 21:22
has joined #general

bheemreddy181
2020-12-24 17:33
Need inputs on one of the use case - we want verify the provider when there is a config change on the provider along with a code change ( config change can be done via UI ) where there is not code deployed/ merged any thoughts around this ?

antonello
2020-12-24 17:34
I don?t think I?d merge the consumer if the provider tests are not merged first.

brendan.donegan
2020-12-24 18:04
If it?s possible to make changes which can materially affect the behavior of your software without triggering appropriate tests, then there is a problem with your development workflow

bheemreddy181
2020-12-24 20:22
We are actually giving an ability for business teams to change config without a code change and the config lives in Aurora Postgres database and we provide API?s to modify these config - this is more like removing dependency with SE team and business handle these configs

bheemreddy181
2020-12-24 20:35
if you don?t merge , provider will not be able to look up your contracts as we tag contracts as master on merge

lewis.thorley
2020-12-24 20:47
I agree, I prefer to merge consumer first without provider implemented and this is the practice my company has followed. Particularly when you have separate teams doing FE and BE development.

antonello
2020-12-24 21:27
ultimately, it?s down to what works for you. my philosophy is that master should only point to pacts that are deployable.

matt.fellows
2020-12-25 10:54
What Anto said. Always up to you, but I'm of the "master should always be deployable" view

matt.fellows
2020-12-25 10:56
Merging to master something not deployable ultimately means either a) you have another branch where releases originate or b) you're trapped in an emergency because you have to double handle. I think it just kicks the can down the road.

matt.fellows
2020-12-25 10:57
Trunk based dev is different, especially if using feature toggles etc

matt.fellows
2020-12-25 10:58

eungjun.yi
2020-12-25 14:25
has joined #general

bheemreddy181
2020-12-26 22:24
Does any one use terraform approach for pact broker https://github.com/pactflow/terraform-provider-pact , if so can you help me understand how does this sit in your cicd pipeline

bheemreddy181
2020-12-27 05:45
I see that terraform approach helps us to maintain and add webhooks easily but is the idea to write terraform first and later do implementation on consumer and provider ?

ebanster
2020-12-27 13:18
has joined #general

matt.fellows
2020-12-27 21:01
So obviously the Pact Broker has APIs for almost everything

matt.fellows
2020-12-27 21:03
Terraform is just a Infra as Code version of that

matt.fellows
2020-12-27 21:04
it?s probably not going to be super helpful for the OSS version of Pact Broker, because the resources currently implemented are a Pact itself, and a webhook

matt.fellows
2020-12-27 21:04
Webhooks can drift, so Terraform is useful to correct that - but so is a `PUT` to the webhook endpoint

matt.fellows
2020-12-27 21:04
Over time we?ll expand the resources available of course

matt.fellows
2020-12-27 21:05
Terraform would usually be run as a separate pipeline to your main CI builds (i.e. separate from the actual Pacticipant repositories) and triggered when a new change is made, or somebody wants to bring everything back into centrally configured alignment

bheemreddy181
2020-12-28 00:26
Even with open source pact broker I feel the terraform is helpful it?s been hard for OSS version of pact broker to add webhooks , we have been adding them manually right now which adds a dependency with another who can only view or add or maintain secrets for a NH user for CI

abubics
2020-12-28 07:22
As far as diagrams go, I think it's easy enough to read :slightly_smiling_face: It's missing some consistency/symmetry with PRs and publishing to the broker (PR is only mentioned in the provider side, how/where does the consumer build publish to the broker?). I'd suggest either leaving the source-control details completely out, or making them completely explicit for everyone's sanity :innocent:

onur.baskirt
2020-12-28 10:48
has joined #general

massimo.daros
2020-12-29 13:18
has joined #general

chris.fullinwider
2020-12-29 18:15
has joined #general

piotr.soltysiak
2020-12-30 16:55
has joined #general

adrian.przybyla
2021-01-04 13:41
has joined #general

dcorrales
2021-01-04 22:06
has joined #general

jokubas.lekevicius
2021-01-04 22:10
has joined #general

adrian.przybyla
2021-01-05 09:40
Hey guys, do you have any gist/example/whatever with case where you testing mutation in graphql ? https://github.com/pact-foundation/pact-js/issues/565

tjones
2021-01-05 10:09
Hi Adrian, I'm afraid we don't, but it would be great to extend the graphql example to include one.

tjones
2021-01-05 10:11
(as you point out in the issue, it might require some code changes before we can support mutations. I'm not sure).

tjones
2021-01-05 10:16
I added some extra information on the issue.

adrian.przybyla
2021-01-05 10:55
@tjones thank for response i respond to you on GH

matt195
2021-01-05 16:35
has joined #general

rafael.manzoni
2021-01-05 17:56
has joined #general

thanuxxxx
2021-01-05 19:24
What are the differences between `providerStates` vs `providerState`

animesh2712
2021-01-05 19:29
has joined #general

phil.endsley
2021-01-05 19:57
I think this was just a change between Pact specs. v2 vs v3. One is an array (v3), and one is not (v2)

thanuxxxx
2021-01-05 20:11
:thumbsup:

info
2021-01-06 01:55
has joined #general

pascal.libenzi
2021-01-06 10:57
has joined #general

writetojoshma
2021-01-06 13:54
Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.88.3/pact-1.88.3-win32.ziphttps://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.88.3/pact-1.88.3-win32.zip: Error: Error while installing binary: Error: unable to get local issuer certificate

writetojoshma
2021-01-06 13:54
any help ?

animesh2712
2021-01-06 18:06
Hello All, Could someone help me with an example for sharing Pact file via GitHub URL?

2021-01-06 18:17
A new post has been created in *Feature Requests*

brett
2021-01-06 18:55
has joined #general

josh.rosenfeld
2021-01-06 19:39
has joined #general

matt.fellows
2021-01-06 20:57
Are you behind a network proxy?

matt.fellows
2021-01-06 20:57
Look at the issues in pact node for that

matt.fellows
2021-01-06 20:58
You'll need to set some node settings because network proxies man in the middle requests which confuse HTTPs chains

matt.fellows
2021-01-06 21:49
Why are you wanting to share it this way?

2021-01-07 04:37
A new post has been created in *Feature Requests*

writetojoshma
2021-01-07 06:06
Oh Okay

writetojoshma
2021-01-07 06:32
But this seems to be an intermittent issues

writetojoshma
2021-01-07 06:32
sometimes absolutely no problem installing

writetojoshma
2021-01-07 06:33
and some time it always throws postinstall error

writetojoshma
2021-01-07 06:33
how to resolve this

matt.fellows
2021-01-07 10:52
It sounds like an issue at your end.

matt.fellows
2021-01-07 10:53
Is this inside your company network? Try using a non corporate network and see if the issue persists

writetojoshma
2021-01-07 10:53
Okay Sure

matt.fellows
2021-01-07 10:54
If it does, its likely an issue with your laptop/workstation

matt.fellows
2021-01-07 10:54
Otherwise all of our users would be having the same issue

writetojoshma
2021-01-07 10:54
Error: Error while installing binary: Error: tunneling socket could not be established, cause=getaddrinfo ENOTFOUND <company-name>http://proxy.com

writetojoshma
2021-01-07 10:54
this is the error

writetojoshma
2021-01-07 10:54
its a proxy issue

writetojoshma
2021-01-07 10:54
not all of us getting

writetojoshma
2021-01-07 10:54
so yes its a proxy issue

carlo
2021-01-07 13:24
has joined #general

denis.ducansel
2021-01-07 15:52
Hi, I'm facing a situation where I don't really know if I could reasonably use Pact, and if so, how. Context ? We have provider *P*, and consumer *C*. ? *P* exposes its services to consumers through a *P-api* library . ? *P-api* completely hides communication details (HTTP requests/responses, messaging payloads) to *P* consumers. ? *P*, *C*, and *P-api* are all developed "in-house" ? *P* could have other consumers than *C* Questions Should I use Pact:grin:? ? I'd like to say yes? It's worth knowing whether some version of *C* is compatible with some other version of *P*! ? For this to work, contracts should be published to Pact Broker by *C* How should I use Pact? ? *C* should theorically define and validate the contracts, but *C* does not know at all about communication details ? *P-api* does, but doesn't know about actual consumption of *P* by *C* (which endpoints get called, with which parameters, ?) ? I could imagine having *P-api* produce the contracts by some mean, but this would make overall process more cumbersome, no?   Do any of you know of some good recipe to apply here?   Thanks,     Denis

danny.porrello
2021-01-07 16:48
has joined #general

animesh2712
2021-01-07 17:01
@matt.fellows@matt.fellows@matt.fellows My team don?t want to build infrastructure to share file via pact broker, as no one wants to build and maintain the broker. They are trying to first find out can we use Github way

matt.fellows
2021-01-08 00:23
All of the tooling can communicate to a URL to fetch a pact file, so as long as the file is URL accessible it should be OK

matt.fellows
2021-01-08 00:23
Github will be tough, because it has specific authentication requirements that the system won?t have native support for. So you?ll probably need to build tools to download the pact file from Github first and point to a local file instead

matt.fellows
2021-01-08 00:24
You could also look at using http://pactflow.io whilst you evaluate it

matt.fellows
2021-01-08 00:24
quite honestly, the broker is the best path - you?ll miss out on a lot of key functionality of the approach without it

animesh2712
2021-01-08 03:04
Thank you Matt, for your suggestions! Let me do some POC on it.

dawood.abbas
2021-01-08 07:00
has joined #general

matt.fellows
2021-01-08 10:57
I think at least conceptually, many of the benefits of contract testing still apply to this. Practically things get a little more complicated. One option as you allude to, is that *P-api* could produce the contracts, publishing the version of the library itself. In this model, you would need to publish one version for every consumer of the library for the Pact Broker workflows to work. Then each *C* that uses *P-api* could use the _can-i-deploy_ check passing the version of the *P-api* that they use. Probably time I updated this with more approaches: https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/

michaelkochub
2021-01-08 14:45
Question about provider versioning: is there a best practice for encoding information about the version of the provider app from the consumer contract unit test? Looking through the documentation for https://docs.pact.io/pact_broker/can_i_deploy/ I was really wondering where the information about the provider version comes from, since Pact is consumer-driven. I can think of a number of approaches: 1. In the consumer source code, copy-paste Pact tests into separate packages based on provider version, and then modify those tests as needed 2. In the consumer source code, have a single Pact test that has multiple test cases, each that passes the name the provider and its version to the `provider` setter method in the Pact DSL 3. Within a single test case, use the `fromProviderState` method to inject the version of the provider being tested

michaelkochub
2021-01-08 14:52
As a follow up question, where do the provider versions in the example version matrix in https://docs.pact.io/pact_broker/can_i_deploy/ come from?


tjones
2021-01-08 14:56
In general, it's good to version your software on a per commit basis for pact (and only publish pacts from CI).

phil.endsley
2021-01-08 14:57
> is there a best practice for encoding information about the version of the provider app from the consumer contract unit test? I think best practice is to not. The consumer shouldn't care about what version the provider is, only that the provider satisfies the contract defined by the consumer. Check out the summary. https://docs.pact.io/pact_broker/can_i_deploy/#summary If you use the `--to` argument, you only need the version of the application you're deploying (assuming you're tagging where you deploy to each time. That's what the call to `create-version-tag` is doing in the link)

tjones
2021-01-08 14:58
I've been planning to write a blog post on this topic - since it's nice to be able to reason about what's in a prerelease version. The script I personally use is here: https://gist.github.com/TimothyJones/edf3c5d0e0de582ec34a6daa734d7517

phil.endsley
2021-01-08 14:59
> where do the provider versions in the example version matrix ... come from Any time you publish a pact (from the consumer) or verification results (from the provider), you can provide a version

tjones
2021-01-08 14:59
Oh, yes! Good catch, Phil. In the consumer, you create a pact for a specific version of the consumer, but you only name the provider, you don't specify a version.

tjones
2021-01-08 15:00
Then, you can verify that pact against any version of the provider. Obviously, this might not pass for older versions of the provider.

phil.endsley
2021-01-08 15:05
> Obviously, this might not pass for older versions of the provider I might be starting on a tangent, but one of the points I find myself repeating frequently to new adopters in our organization is that it's not necessarily a bad thing if verifications fail. The point of the matrix is to identify which versions of two applications are compatible with each other. APIs will (probably) continue to evolve and change. The pact matrix is there to prevent breaking changes on deployment, not ensure backwards compatibility forever.

michaelkochub
2021-01-08 15:05
Thank you both for the quick responses. That makes sense, but what about the case where you need to update the Pact but you still want provider verification to succeed against an older version of the provider app because of a business req. Here's an example of what I mean, where the Provider has a capabilities framework that "tells" the Consumer what it can call: ```Assume P is the provider and C is the consumer Assume that C must be compatible with all versions of P and that C uses a capabilities framework to check if an endpoint is supported P 1.0 defines an endpoint /hello P 2.0 defines an endpoint /hello and an endpoint /goodbye P latest defines an endpoint /hello and an endpoint /goodbye the client in C latest looks like GET /hello if P.hasCapability(goodbye) GET /goodbye else use default value what happens is that the same contract is sent to 1.0, 2.0, and latest { GET /hello works GET /goodbye works } which breaks provider verification on P 1.0, even though the app itself works fine but really, in this case (I think) we wanted { P 1.0 GET /hello works P 2.0 GET /hello works GET /goodbye works P 3.0 GET /hello works GET /goodbye works }```

michaelkochub
2021-01-08 15:08
I could see that this resolves to the point made earlier: the consumer effectively "cares" about the provider version, and because of that fact, we're pushed closer to a Pact anti-pattern

phil.endsley
2021-01-08 15:11
My gut reaction is that this: ```if P.hasCapability(goodbye) GET /goodbye else use default value``` Would not be needed if you're using Pacts and can-i-deploy. You're essentially doing a version check from your consumer to make sure the endpoint exists. If using pacts and can-i-deploy, you're effectively guaranteeing that the endpoint will always be there for the consumer (Since the consumer would have a contract for /goodbye, and can-i-deploy would prevent you from deploying a version of P that does not have /goodbye).

tjones
2021-01-08 15:22
I think this is an interesting case. I'm on my way to bed here, but it's possible you could do something with provider states to give the verification you want.

tjones
2021-01-08 15:23
Unless you have some surprising architecture (like old versions of the provider deployed alongside new ones), it does sound like this is a different solution to the problem that Pact solves with can-i-deploy, though.

tjones
2021-01-08 15:28
You can also tag pacts in the broker, so you could maybe do something like have a tag for the different capability settings? That might get messy.

michaelkochub
2021-01-08 15:31
Agreed. It sounds like a capabilities framework doesn't jibe well with Pact concepts because it tries to _replace_ some of those concepts with its own definitions

michaelkochub
2021-01-08 15:32
In our use case though, it's as if our product versions are multiple products, all of which must be compatible with the current consumer

tjones
2021-01-08 15:34
You could potentially consider the different capabilties as different consumers.

michaelkochub
2021-01-08 15:39
I think we'd want to consider the different capabilities as different providers. It doesn't need to necessarily hardcoded to a specific provider version `P v1.0` or `P v2.0` but there would be some labelling that communicates a semantic difference: `P-onlyHello` and `P-laterOn`

tjones
2021-01-08 15:51
Yes, that?s probably better. At that point, the capability endpoint is a kind of service discovery, almost. This is an interesting case!

michaelkochub
2021-01-08 15:53
Yeah exactly, the capability endpoint is a barebones service discovery. In our architecture, it's best to think of multiple versions of the product as separate products in their own right, so using that as a mental model leads us back to the three (or possibly more) options laid out in the initial message.

michaelkochub
2021-01-08 15:54
For using provider states, were you thinking of a provider state callback, where you'd do something like `fromProviderState('version', 'v1.dummy')` and then assert different things based off that. But once you do that it's probably easier to split things off into separate test cases

victoria.kruczek
2021-01-10 14:47
hello, I have a question about provider object properties. Does `__running: false` stand for the fact, that the provider haven?t been properly setup? I can see this values after printing out the `provider` object: ``` Pact { opts: { xxx: xxx }, server: Server { _events: [Object: null prototype] { delete: [Function] }, _eventsCount: 1, _maxListeners: undefined, options: { xxx: 'xxx', }, ---> __running: false, __cliVerb: { xxx: 'xxx' }, __serviceCommand: 'xxx', __argMapping: { xxx: '--xxx', }, [Symbol(kCapture)]: false } }```

cksharma122
2021-01-10 17:19
has joined #general

matt.fellows
2021-01-10 23:30
Hi Victoria, is this question in relation to Pact JS? For future questions, please direct them to #pact-js

matt.fellows
2021-01-10 23:31
This looks like a dump of the consumer side Pact object

matt.fellows
2021-01-10 23:32
But yes, the `__running` property is there to detect when the Pact mock service is started. This can take a few seconds. If it?s not starting as expected, please enable debug logs and share the output along with the issues you?re experiencing

tjones
2021-01-11 02:21
Note that `provider.setup()` returns a promise that you will need to wait for before trying to use it.

caiquedpfc
2021-01-11 04:05
has joined #general

irldev
2021-01-11 18:23
Is there a pact binding for typescript? Or is pactjs the nearest option?

henrik.rudstrom
2021-01-11 18:30
has joined #general

matt.fellows
2021-01-11 23:02
Pact JS _is_ written in typescript, and exports TS bindings

matt.fellows
2021-01-11 23:03
is there something specific you need?

irldev
2021-01-12 07:59
Not really no. I'm about to start implementing it and our code is typescript and from a quick search I didn't see a typescript version available. I can see pactjs and various other flavours to let you write your consumer side and provider side pieces in those languages such as Java, C# etc but didn't see typescript.

matt.fellows
2021-01-12 09:44
Cool, pact JS should do the trick then

eric
2021-01-12 10:23
has joined #general

victoria.kruczek
2021-01-12 12:28
Ok, thank you for you insides :slightly_smiling_face:

henrik.rudstrom
2021-01-12 13:01
Im doing some research on adopting pact in our organization and i have a question regarding best practices: We have a config service that distributes config to almost all our apps, it is accessed via client libraries by 50-100 services. Im wondering what the best practice here is regarding consumer contracts. Likely it will be a massive job to write very similar consumer tests, is it possible/desirable to bake the consumer tests into the client library somehow

fnguyen
2021-01-13 00:39
has joined #general

matt.fellows
2021-01-13 01:55
I posted some thoughts to a similar question just the other day: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1610034769384400

matt.fellows
2021-01-13 01:55
I?m keen on other perspectives of course

henrik.rudstrom
2021-01-13 12:53
So you suggest tagging the version of P-Api with the name of the consuming version (v1.2-<name-of-app>) and validating those in addition to the contract of C?

henrik.rudstrom
2021-01-13 12:57
im just speculating if it would be feasible to add some test-utility functions in P-api that can run as part of the test suite of C. in the most simple case a function takes a pact provider (initilized with the name of C) as argument and runs the whole suite of consumer tests for P-api.

henrik.rudstrom
2021-01-13 12:57
or a more granular approach along those lines?

pollet_22
2021-01-13 16:04
has joined #general

pollet_22
2021-01-13 16:12
Hello Every body , i am pollet a software testing engineer i am trying to implement contract testing in our company between BE and FE and between Apis also so i am in the phase of exploring pact and trying to do CDC between apis first

dshattuck
2021-01-13 20:49
has joined #general

thomas.rosati
2021-01-13 21:58
has joined #general

matt.fellows
2021-01-14 00:05
yep I think it?s doable

matt.fellows
2021-01-14 00:07
They key thing here is that we want to be able to ensure that each _version of_ *C* is able to publish a contract that expresses its needs of *P-api*

matt.fellows
2021-01-14 00:07
Doing that ensures all of the existing broker workflows/tools (e.g. can-i-deploy) will continue to operate

matt.fellows
2021-01-14 00:09
If it?s impossible to know which specific subset of functionality each *C* uses of *P-api* (because they are hidden behind the client lib), then the best you could probably do is just ensure Pact knows the versions of *C* that use the API in its entirety.

matt.fellows
2021-01-14 00:09
This is still useful, but less useful than knowing specifically which APIs and fields are actually in use

rahulsmalpani
2021-01-14 07:56
has joined #general

2021-01-14 07:57
A new post has been created in *Feature Requests*

sacha.camfferman768
2021-01-14 09:42
has joined #general

brandonbeard86
2021-01-14 22:10
has joined #general

geetishnayak
2021-01-15 01:02
has joined #general

stanleyawang
2021-01-15 06:26
hi all, does anybody get intermittent connection refused errors 'connect ECONNREFUSED 127.0.0.1:35183' while using node.js pact on docker?

matt.fellows
2021-01-15 06:28
Mind creating a thread in #pact-js with any logs to show?

stanleyawang
2021-01-15 06:30
ok sure

shettyg
2021-01-15 14:18
has joined #general

shettyg
2021-01-15 14:19
Hi All.I am facing an error while implementing pact provider using Junit

shettyg
2021-01-15 14:20
Receiver class http://au.com.dius.pact.provider.spring.junit5.MockMvcTestTarget does not define or inherit an implementation of the resolved method 'abstract java.util.Map executeInteraction(java.lang.Object, java.lang.Object)' of interface http://au.com.dius.pact.provider.junit5.TestTarget. java.lang.AbstractMethodError: Receiver class http://au.com.dius.pact.provider.spring.junit5.MockMvcTestTarget does not define or inherit an implementation of the resolved method 'abstract java.util.Map executeInteraction(java.lang.Object, java.lang.Object)' of interface http://au.com.dius.pact.provider.junit5.TestTarget.

shettyg
2021-01-15 14:20
Has anyone faced this error before

phil.endsley
2021-01-15 14:22
There's a channel for #pact-jvm specific help. Probably better to move the discussion there

shettyg
2021-01-15 14:22
Sure Thanks

michaelkochub
2021-01-15 14:46
Hello, is there a best practice for breaking up a massive consumer contract unit test? We'd like to do this because we have multiple team members working on adding more test cases and it's harder to parallelize if they're all touching the same file. It's also less maintainable. A few solutions to consider: 1. Split up the consumer unit test into multiple tests, and suffix the provider with the endpoint like `provider-hello_world` 2. Split up the consumer unit test into multiple tests, but stitch the resulting consumer contracts back into one big one before pushing to the broker

natarajang1
2021-01-15 15:29
has joined #general

matt.fellows
2021-01-15 22:50
Hi Michael, which language are you using?

matt.fellows
2021-01-15 22:51
(2) should be supported in most cases

matt.fellows
2021-01-15 22:52
Is it all the same code base though?

michel.neufeglise
2021-01-18 08:55
has joined #general

bart.boersma
2021-01-18 10:48
has joined #general

2021-01-18 14:44
A new post has been created in *Feature Requests*

michaelkochub
2021-01-18 16:06
We are using Java. It's all the same code base. Should that "stitching" behavior be on be default?

matt.fellows
2021-01-19 00:01
I've just asked in #pact-jvm, let's carry on this convo there

monica.wu
2021-01-19 06:25
has joined #general

makobernal
2021-01-19 08:23
has joined #general

jibrail.idris
2021-01-19 10:11
has joined #general

jmvb.registros
2021-01-19 11:01
has joined #general

irldev
2021-01-19 17:16
I was looking at http://pact.net and I'm not totally clear on what this does and what I need to set it to: pactVerifier .ProviderState($"{serviceUri}/provider-states") https://github.com/pact-foundation/pact-net

irldev
2021-01-19 17:16
What are "provider-states" and where are they set?

antonello
2021-01-19 17:59
This explains what provider states are https://docs.pact.io/getting_started/provider_states/

antonello
2021-01-19 17:59
They can be added to an interaction, so set in the consumer tests.

antonello
2021-01-19 18:00
The provider tests then can use these states to do any test data set up (mocks, in memory db, real db, etc.) that?s needed for the tests to pass.

irldev
2021-01-19 18:11
Is there an example of how these can be used in .net? I can see this in the sample but not sure what it's setting pactVerifier .ProviderState($"{serviceUri}/provider-states") https://github.com/pact-foundation/pact-net

matt.fellows
2021-01-19 19:32
Howtoexamples


matt.fellows
2021-01-19 19:32
There is a .NET example there

matt.fellows
2021-01-19 19:33
Also howtolearn has a .NET workshop that might help

2021-01-19 19:33
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

irldev
2021-01-19 19:57
Cheers, thanks

tpham
2021-01-19 22:36
has joined #general

2021-01-19 23:50
A post in *Feature Requests* has been marked as *closed*

vishal.grover
2021-01-20 03:12
has joined #general

priya.saraf
2021-01-20 08:43
has joined #general

fahad.aj.khan
2021-01-20 08:58
has joined #general

nicole.jaenchen
2021-01-20 09:38
has joined #general

vuttithatkrongyot
2021-01-20 11:03
Hi teams, can we add new contract to pact-stub-server without restart it? or even update the specific contract

vuttithatkrongyot
2021-01-20 11:11
my flow is I've contract as JSON file (wrote from scratch) -> I want to add this contract into stub-server without restarting the stub-server

dinakaran.ulaganathan
2021-01-20 13:59
has joined #general

ananda-kumar.irudhaya
2021-01-20 15:51
~hi, Any one have a latest example for pact setup in node..~

ananda-kumar.irudhaya
2021-01-20 16:08
found it

ptsiakos77
2021-01-20 21:55
has joined #general

2021-01-20 23:56
A new post has been created in *Feature Requests*

jibrail.idris
2021-01-21 01:08
Pact is the most frustrating framework that I have ever worked with.

uglyog
2021-01-21 01:11
Then don't use it if it is that bad. There are other ways to test your services, like end-to-end test suites and integration tests. But they tend to be even more frustrating to maintain.

jibrail.idris
2021-01-21 01:14
fascinating way to reply to feedback.

jibrail.idris
2021-01-21 01:16
i didnt say it is bad. It is just frustrating to use. Genuinely frustrating.

marko.justinek
2021-01-21 01:18
What in particular regarding using Pact is frustrating you, @jibrail.idris?

marko.justinek
2021-01-21 01:21
To @uglyog defence, just stating something is off with something without providing context or reason, doesn?t really help anyone. Similar to bug reports that look like ?There?s a bug. Thing doesn?t work. Please look into it.? :sweat_smile: ?Well, I looked into it. Works as designed.? :man-shrugging:

jibrail.idris
2021-01-21 01:22
@uglyog @matt.fellows Yes, apologies for that. I didn't elaborate on the context.

marko.justinek
2021-01-21 01:24
Pact is open source after all (well, most of it). So anyone is welcome to provide ideas and solutions for improvement.

jibrail.idris
2021-01-21 01:34
My working colleagues had great difficulty in setting up simple pact contracts and testing them in JUnit. When things don't work for example, the pact broker doesn't match up with a certain expected response, they are stuck on what to do next. So, what I usually do is step in deep into let's say TestTarget.kt with them and examine how pact plugin uses HttpClient to interact with broker and the actual endpoint to match up. It could be a header missing for example. The missing header example is a classic example. At the consumer side, the contracts are specified in a JSON file and the verified interactions may not work on the provider side. Reason being is that the provider's side spring boot endpoint comes with security such as JWT Token defined in header. All in all, I say kudos to the pact team for crafting an outstanding product. The experience to use it, however, is frustrating. I am not exactly sure what's the point of frustration. The docs are there. My colleagues can spend hours and days at time on figuring out something if we get stuck.

marko.justinek
2021-01-21 01:40
Fair enough. Generated values are always going to be tricky to validate especially if one tries to ?contract everything? in a request/response. Some general pointers on what to test, when and how are written throughout the Pact-land like you wrote.

tjones
2021-01-21 01:41
If you're experiencing this kind of frustration, then I would say that either the team is using it in a way that is causing more trouble than necessary, or we have improvements to make.

tjones
2021-01-21 01:42
If the team are using it in a way that is causing trouble, then probably we need to improve the documentation. Specific feedback on what problems you are experiencing is very helpful, and will lead to improvements.

matt.fellows
2021-01-21 01:42
I?m glad to see this conversation heading on track. We understand things can be frustrating, but also know that it?s an open source tool maintained by a community of dedicated people (often in their own spare time). Insults like this don?t help, and so you are likely to get blunt responses. Let?s keep it on track and within our https://docs.pact.io/contributing/code-of-conduct. Specifically, let?s focus on what can we do to improve.

tjones
2021-01-21 01:50
> When things don't work for example, the pact broker doesn't match up with a certain expected response, they are stuck on what to do next. Do you mean when the response from the provider doesn't match the expectation in the contract? This should be explained in error messages or logs from the verifier. If you're needing to read the pact source to find out what went wrong, I'm curious to know more about how you're using it.

matt.fellows
2021-01-21 01:51
I recall when first using the JUnit provider I didn?t realise I had to look at the test report to see the errors. Once I discovered that, I found it much simpler

tjones
2021-01-21 01:54
> Reason being is that the provider's side spring boot endpoint comes with security such as JWT Token defined in header. There are several approaches that make verification with a security token quite straightforward. There may be springboot examples in the JVM docs, I'm not sure.


jibrail.idris
2021-01-21 01:58
@tjones > Do you mean when the response from the provider doesn't match the expectation in the contract? This should be explained in error messages or logs from the verifier. If you're needing to read the pact source to find out what went wrong, I'm curious to know more about how you're using it. Yes. Let's use this article as an example. https://www.baeldung.com/pact-junit-consumer-driven-contracts In this example, the contract is crafted using the builder. Contract is published and verified. The verification is done simply using `PactProviderRuleMk2` . However, testing the same endpoint at the provider returns mismatch error. For example, a 403 error because JWT could be missing when Pact provider plugin invokes the actual Spring boot endpoint, which comes with the security part as well. I am currently exploring MockMvcTarget and hopefully that makes things simple and doesn't break potential security modules put in place. The console screen spits out the difference and on a cursory glance it is easy to spot the difference. Understanding the difference is another issue. To add from the example above, the engineer working on the consumer part, writing the contract above can publish the to the broker. The engineer working on the provider side verifies the contract and it fails. The consumer engineer said that the contract is fine and tests pass. The provider engineer shows the failed state test. From here, we realise that the pact contract requires the Authorization header with Bearer value to be hardcoded, which flags out security issue with the team because tokens can't be hardcoded.

mhdtouban
2021-01-21 01:58
has joined #general

marko.justinek
2021-01-21 02:11
yeah, you don?t want hardcoded tokens (or secrets of any sorts). Your consumer devs should use matchers instead. Or value generators which some Pact frameworks provide. Is the TL;DR response to the above. But I?m sure someone else will elaborate much better :thumbsup: (I?m counting on it :sweat_smile: )

jibrail.idris
2021-01-21 02:14
Which now then brings to the next question, how do we craft custom headers at the Provider side so that we can include Authorization and other headers, which apparently Pact does not support. https://stackoverflow.com/questions/42765222/how-combine-a-targetrequestfilter-with-runwithparameterized-class

jibrail.idris
2021-01-21 02:15
@marko.justinek Thanks, i will explore matchers.

abubics
2021-01-21 02:21
I'd probably also use the Pact https://docs.pact.io/consumer & https://docs.pact.io/implementation_guides/workshops/ to learn, rather than a more narrowly-targeted tutorial (such as that Baeldung example; I love Baeldung, but they don't always give a full picture).

bheemreddy181
2021-01-21 02:43
@matt.fellows Quick Question : How do we get provider merged first , as provider is always looking for `master` pacts , we don't fail if there are no pact present for provider both on pull request and master ? - then as if we have provider on master now just get the consumer pr triggered again ?

veeraprathap.n
2021-01-21 04:10
has joined #general

tjones
2021-01-21 04:32
Yep. Pact is not a substitute for communication between teams. If there's no communication about the authorisation, then verification would fail. As an aside, my personal preferred auth approach is to have a Provider State like `VALID_TOKEN is a valid auth token`, then mock out the auth provider to turn `VALID_TOKEN` into some mock data. I like it because it is simple, but of course it means you're not properly testing your authorisation. If you want something more principled, you can use an approach like the one documented here: https://docs.pact.io/implementation_guides/jvm/provider/maven#modifying-the-requests-before-they-are-sent

tjones
2021-01-21 04:42
Unless I'm misunderstanding what you're asking I think the answers you are looking for are in the official Pact documentation and examples. If you find areas where we're lacking documentation or features, please feel free to open an issue against the relevant project. If something is unclear, asking here is a good way to get a fast response - and it's good to know where our documentation can be improved. Of course, the very best way to help us improve is to contribute PRs that fix up documentation/otherwise improve the tool. Almost all of Pact has been written in people's spare time, by developers like you and me (although I appreciate that not everyone has the time). I'm not sure how Baeldung works, but I think your observation that the article you linked doesn't handle authorisation would make the seeds for an excellent follow up post explaining how to do it.

tsiakos
2021-01-21 09:24
has joined #general

denitsa.kulezich
2021-01-21 10:13
Hi all, I would like some help with a problem we are currently facing with Pact. We are trying to fit it in a federated api architecture. We implemented several pacts between our federated api (which acts as a consumer) and the source web services on one side and between federated api consumers and the api (which acts as a provider in this case). But we currently face some problems: 1. First is that the federated api is transforming the data from the source web services but doesn?t care about the data, they only care if the schema of the source web services remains the same. 2. Second is that the federated api consumers pact  fails now and then because the source web services deletes their databases. The federated api doesn?t have a db so the consumers can?t rely on the provider states. What we did to avoid these fails is to remove any data from the pact that may change leaving the pact with the bare minimum information. But this means that we can?t actually benefit from the  contract tests

denitsa.kulezich
2021-01-21 10:13
Do you have a case like that? What would be your approach?

tjones
2021-01-21 10:14
Usually you would mock the downstream services during provider verification

tjones
2021-01-21 10:15
(it is usually much easier to do this in code just before the boundary, rather than with actual mock services)

denitsa.kulezich
2021-01-21 10:15
Thanks for the advice, Tim :slightly_smiling_face:

tjones
2021-01-21 10:15
The boundary that you would mock would be the same as the boundary for the code under test in the consumer tests for your federated service

tjones
2021-01-21 10:17
Provider states are the consumers way of saying "I expect this state", but it doesn't care how it is set up- so it doesn't need to be a database. Usually I find it easiest to stub the DB connector layer completely, something like: ```when Db.listSomething is called, then return SomePredeterminedList```

tjones
2021-01-21 10:19
Another approach that people sometimes use is to treat your "provider" as both the federated API and its downstream services. Using pact to drive an integration test, essentially. This feels less clean and easy to reason about to me, but I know that some people have had success with it.

tjones
2021-01-21 10:21
Depending on which pact framework you are using for the verification of the provider, we might have examples of the first approach.

denitsa.kulezich
2021-01-21 10:24
I definitely agree that mocking downstream service is the cleaner way of dealing with our case. I wouldn?t like to create a dependency with the other service when with pact we are actually decoupling them.

denitsa.kulezich
2021-01-21 10:25
As for the framework we are using, it?s pact-js

tjones
2021-01-21 10:36
Ah, perfect. This example has the kind of in-memory mock I am talking about, although because it isn't a real provider, it doesn't actually have the database that it would be mocking https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/test/provider.spec.js Might be useful for some inspiration

tjones
2021-01-21 10:37
https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/repository.js Basically, you just want to mock the layer where you would give business operations to the downstream service

tjones
2021-01-21 10:38
rather than putting a mock that responds to network requests or SQL queries or whatever.

tjones
2021-01-21 10:38
Let us know if you have any further challenges!

denitsa.kulezich
2021-01-21 11:00
thanks a lot Tim, for the help!

tjones
2021-01-21 11:06
No problem

oleg
2021-01-21 13:05
has joined #general

psychopomp3x
2021-01-21 14:37
My team is having a debate about how to interpret the guidance in https://docs.pact.io/5-minute-getting-started-guide/#scope-of-a-consumer-pact-test Some folks are reading it as "only put pact tests on the service api code for calls to services that our dev team don't own", and others are reading it as "pact tests all the service responses. The `collaborator` is just an abstraction in the client code to call service apis". Can somebody more seasoned weigh in? We have an enterprise app with like 40ish microservices if that helps set the scope.

kflo
2021-01-21 16:58
IMO it means ?you should have pact tests for all client requests to services that your company maintains? (e.g. not third party services outside of your control, because you can?t dictate those contracts). so, whenever you have a service which talks to another service that you maintain over HTTP, you should have a pact test in the consuming service for it (and then verification tests in the providing service)

matt.fellows
2021-01-21 21:39
Test all the things for services your org owns or can have verified. In the case for APIs where they won't/can't verify (such as a third party) you could still get some value from the pacts (e.g. they are useful feature specs) but you won't get the full benefit obviously

wesleythomaswilliams
2021-01-21 22:20
:point_up::point_up:and don't forget messaging tests too if you're using Kafka etc. My company has a lot of small teams, some working on a several microservices, some working on one. Our team started by implementing pact between all the microservices we've built, we're now at the point where we're looking to get other teams to do the same and then to have pact tests across the boundaries between our teams.

kflo
2021-01-21 22:21
yes, i am about to figure out how to set up the pact flow for messages (kafka) using scala

kflo
2021-01-21 22:22
:upside_down_face:

2021-01-21 23:36
A new post has been created in *Feature Requests*

tjones
2021-01-22 00:42
I think the dotted line in that diagram is supposed to represent the boundary of your consumer code. So, "external service" would include services owned by the same team.

tjones
2021-01-22 00:42
(I'm not certain that's what it's meant to mean, but that's how I would interpret it)

matt.fellows
2021-01-22 00:53
That?s what I meant it to mean!

matt.fellows
2021-01-22 00:53
How?s the terminology in that diagram - I?ve had mixed feedback. I have thoughts, but if there is more popular language I?d rather update it

matt.fellows
2021-01-22 01:24
@lakitna just released another (awesome) blog post on contract testing: https://lakitna.medium.com/contract-based-testing-5-the-best-approach-e7890c30065 :taco:

bheemreddy181
2021-01-22 01:28
So for everyone on this thread - the reason led me to the above approach was ruby implementation doesn?t allow you run verifications with no pact present - which is a possibility on golang implementation


bheemreddy181
2021-01-22 01:30
i will see if i can send out a feature PR implemented myself

matt.fellows
2021-01-22 01:35
> @matt.fellows Quick Question : How do we get provider merged first , as provider is always looking for `master` pacts , we don?t fail if there  are no pact present for provider both on pull request and master  ? - then as if we have provider on master now just get the consumer pr triggered again ? (edited) Sorry, I didn?t see this yesterday - lots happening

matt.fellows
2021-01-22 01:37
I just found the thread from yesterday it seems you had with Beth. Makes sense

matt.fellows
2021-01-22 01:40
some options in the meantime are to: a) disable pacts for the provider side until there are pacts b) wrap the process with a check to the broker first - basically fetching latest pacts for that provider e.g. `curl <host>/pacts/provider/<ProviderService>/latest/<prod>` and skipping if it comes back with no pacts

tjones
2021-01-22 02:45
I think different frameworks and communities have different languages so there's not really one best or most popular language. Maybe the example could be more concrete? Or less specific about the other code blocks?

tjones
2021-01-22 02:47
For instance, I would say that the coverage of Pact might be better drawn over the interfaces block - which would include both consumers and providers. But that doesn't help if you think about your code as "controllers" -> "services" -> "collaborators"

matt.fellows
2021-01-22 02:57
I?d like to change the examples (again)

matt.fellows
2021-01-22 02:57
The REPL thing sucks, but I don?t have a better browser runnable solution at the moment

matt.fellows
2021-01-22 02:57
I like this, but you can?t embed without paying (and it?s like, not cheap): https://katacoda.com/pact/scenarios/pactflow-getting-started-js

bheemreddy181
2021-01-22 03:43
`disable pacts for the provider side until there are pacts` - i can explore this one for now , lets see how it goes

thomas.powell
2021-01-22 10:18
has joined #general

thomas.powell
2021-01-22 11:48
Hi everyone. We don?t currently use PACT in our org but I?m trying to assess if this would be the right fit for my use case. My team is working on a provider service similar to that shown in the attached diagram labelled ?My Provider Service?. Consumers of our service interact with our translation service only. This API does not hold state as such but does implement request validation of various business rules. The ?Data Warehouse API? contains state. This API is populated through the ingestion of large data files which take ~minutes to ingest. We already have in place a set of e2e tests for our service which populate the Data Warehouse API with a set of canned data. So my questions are these? Is PACT a good fit for this scenario? When working with provider states which of the following scenarios is recommended and why? -        mock out the Data Warehouse API. -        pass information to our Consumers of the canned data used in e2e tests, then run provider tests against a pre-populated system. All the services shown are internal to our organisation and we have relatively good comms channels between teams. Thanks for any help Tom

jibrail.idris
2021-01-22 11:49
@tjones Thank you for the link! That's very helpful! I am wondering if it is possible to create a custom HTTPClient via code and have it injected into the service provider? Let's say in @BeforeAll

stefan.selent
2021-01-23 01:54
has joined #general

jokubas.lekevicius
2021-01-24 21:21
Hi Thomas, I see a place for pact, to test the interactions between your microservices DataWarehouse-TranslationAPI, and between your consumers and the TranslationAPI. And the fact that you have good communication between teams is a nice addition to all this! Regarding the provider states, I'm searching an answer to this question, but to my understanding, you should use mock responses. (if you do this, AND write contracts between your own microservices, you should be set AFAIK) I'm new with PACT so it'd be interesting to hear more opinions

jokubas.lekevicius
2021-01-24 22:27
Hello, I'm writing with a philosophical question to which I can't find a concrete answer in any of the docs or presentations. Tl;dr how much should I couple with the producers data in my contracts. Long version: We've been implementing CBT in our team and it just so happened that we had 3 microservices, 2 consumers, 1 producer. So we separated our work, one writes for consumer A, the second for consumer B. We chipped the contracts away, a few days pass, we submit our PRs and start to celebrate. Until we noticed that we took two different routes on writing the contracts. One developer took a very abstract route for the contract. Some stringType goes in the parameter, some stringType goes in this request field, in this request field we have an Enum, so let's generate a Regex for that. The same for responses, all the fields have very loose constraints, only the type matters in most cases. Add only loose assertions on the consumer side, to see if all the response fields are not null, meaning that our contract represents what our response data types expect. The second developer took a more strict route. Open up the producer application, fire it up with its test database, open you swagger endpoint, see what request payloads return what responses, and write the contracts according to these datapoints, strict on every field. Also do your assertions strictly on the responses, validate every field mapping. These two approaches bring their own pros and cons. The first one is very relaxed, the consumer does not care about the producers test database, only that all the response fields are filled. The consumer doesn't care if the correct request field got mapped to the correct response fields (in a SAVE operation, for example). The second is very good at catching mapping errors, also it helped to catch a certain string generation change (we had an additional question rise from this: imagine you generate an address field from given data, if the format of the string field changes, should the contract break?). The cons are apparent too. We're never sure if our mapping is 100% sure in the first approach. On the second approach, we're really coupled to the producers test data. If something changes in the test db, all contracts should be changed. We're now trying to solve which approach is better, and if chosen, what can be used from the dropped one. I read the docs regarding Postel's Law (here https://docs.pact.io/getting_started/matching) but I can't fully wrap my head around this. For example, if I use Postel's Law and use strict matching on a Save action payload, should I also be strict on the same fields in the response, or should I be loose? Should I be strict on request params in GET?

bethskurrie
2021-01-24 22:34
Good questions @jokubas.lekevicius

bethskurrie
2021-01-24 22:34
Have you read this page? https://docs.pact.io/consumer

jokubas.lekevicius
2021-01-24 22:35
I'm sure I have but I'll look over it Monday morning, I might've missed something crucial :smile: Thanks

bethskurrie
2021-01-24 22:35
I recommend being strict on the consumer side, and as loose as possible (but no looser on the provider side).

bethskurrie
2021-01-24 22:36
On the consumer side, the same person is responsible for the test and the actual requests. You want to make sure your code is sending out exactly what you think it is.

bethskurrie
2021-01-24 22:36
On the provider side, it's best to be as loose as possible - but be strict about things that might cause issues if they changed.

bethskurrie
2021-01-24 22:38
The key to ask on the provider expectations side is "if I made this looser/tighter what bugs would I miss/prevent?"

bethskurrie
2021-01-24 22:39
I would say, both approaches are required, and it's situational as to whether you need to go strict or loose.

bethskurrie
2021-01-24 22:40
That one about the address thing - it seems that if you didn't test with real data, you would miss bugs if the format changed. So it seems a good thing to be strict on.

jokubas.lekevicius
2021-01-24 22:40
Thanks @bethskurrie didn't expect such a swift answer

bethskurrie
2021-01-24 22:41
I just started work and was going through Slack, so it was good timing.

bethskurrie
2021-01-24 22:41
> If something changes in the test db, all contracts should be changed.

bethskurrie
2021-01-24 22:41
That's a situation you want to avoid ^^.

bethskurrie
2021-01-24 22:42
We want changes to cause proportional affects as much as possible. Small change to db -> small change to tests.

bethskurrie
2021-01-24 22:43
So that string generation one - sounds like that field needed someone to think and say "if something about this changes, it would break X, so let's be strict on this one" - but it doesn't mean every field in the response needs strict matching.

bethskurrie
2021-01-24 22:43
Do the strict/loose consideration field by field.

bethskurrie
2021-01-24 23:02
I've taken some of our discussion and put it into that page. Thanks for giving me the impetus to do that!

bethskurrie
2021-01-24 23:05
@lakitna loved your post! https://lakitna.medium.com/contract-based-testing-5-the-best-approach-e7890c30065 An excellent discussion of the trade-offs of various approaches. I am ALL ABOUT highlighting trade-offs rather than saying "this thing is objectively good/bad".

abubics
2021-01-25 00:11
Another little addition to this is: pact isn't trying to replace all your unit tests. For example, if the generated string is an identifier used in a lot of places, maybe the format should be opaque, but it always needs to be valid. Rather than checking the format validity in every interaction, unit tests might cover it better.

bethskurrie
2021-01-25 00:12
On the consumer side? Yes, agreed.

abubics
2021-01-25 00:14
Yarr, there's a lot of maybe (variant of "it depends" :P) . . . working out the best place to do things is one of my more fundamental struggles in computer science :sweat_smile:

bethskurrie
2021-01-25 00:14
And it's something that's so hard to write definitive rules about!

paulo
2021-01-25 11:37
has joined #general

kmckeever
2021-01-25 14:38
has joined #general

robert.land
2021-01-25 19:25
has joined #general

aparnachaudhari
2021-01-25 21:34
has joined #general

gwhill7
2021-01-25 23:23
has joined #general

bheemreddy181
2021-01-26 00:41
Can some one help me understand how the pactflow Hosted Stubs work ?

bheemreddy181
2021-01-26 00:42
more interested on this

tjones
2021-01-26 04:45
You might get a better response in #pactflow , but you may have to wait until tomorrow- it?s a public holiday in Australia today

tjones
2021-01-26 04:46
(I don?t know the answer to your question, sorry)

matt.fellows
2021-01-26 06:03
Hey Bheem, have you read https://pactflow.io/blog/hosted-stubs/?


matt.fellows
2021-01-26 06:04
One thing to note is that you still need to auth as per any Pactflow API

bibinc99
2021-01-26 14:37
has joined #general

luisc.barretog
2021-01-27 00:42
has joined #general

matt.fellows
2021-01-27 00:47
Hi Thomas, sorry for the delay (long weekend here in Australia, where a bunch of the maintainers live)

matt.fellows
2021-01-27 00:47
Jokubas is basically on point

matt.fellows
2021-01-27 00:47
Great question!

matt.fellows
2021-01-27 00:49
There is no absolutely correct answer here. If the canned data and e2e tests are easy to setup and maintain (for this specific scenario) then you could go that route. But generally this is not the case, so the simpler path is to mock out the backend to enable really fast verification in your Translation API. Of course, you would then need a contract (or to use the e2e tests) between your Translation API (now the consumer) and the Data Warehouse API (the provider).

rarora
2021-01-27 07:42
Hi team, i want my provider to only verify "production" tagged contracts of consumer when provider test are run. when provider test are run through webhook, I want provider to verify tests of branch that trigerred it. is there any way to do this conditionally?

matt.fellows
2021-01-27 10:20
Of course. What language are you using? Can you please ask in the language specific channel and tag me?

laxmi.somni508
2021-01-27 10:27
has joined #general

laxmi.somni508
2021-01-27 11:44
Hi Pact Team, Thanks for letting me join. We're in process of embracing PACT in our organisation. Could you please advise how could we get a virtual Brown-bag session by Pact contributor ? As mentioned on the http://pact.io/faq/ webpage. Kindly advise. Thanks

laxmi.somni508
2021-01-27 11:46
Technology stack: *BE* - Scala, Python-Django & few other technologies *FE*- iOS (Swift & XCTest), Android (mixture of Kotlin & Java)


laxmi.somni508
2021-01-27 11:46
great thanks a lot

ryanding16
2021-01-27 20:25
has joined #general

ryanding16
2021-01-27 21:10
We have a situation where one field of a response body could be either one of two values. Let's say they are 'A' or 'B'. So we'd like to use the or matcher. The following is the DSL on the consumer side:

bethskurrie
2021-01-27 21:11
Might be best to ask in the language specific channel @ryanding16

bethskurrie
2021-01-27 21:11
Or is it a general pact theory question?

ryanding16
2021-01-27 21:11
```testkey or('A', equalTo('A'), equalTo('B'))```

ryanding16
2021-01-27 21:13
This generates the following in the contract json file

bethskurrie
2021-01-27 21:13
Can you keep this all in one thread please?

ryanding16
2021-01-27 21:13
``` "matchers": [ { "match": "equality" }, { "match": "equality" } ], "combine": "OR"```

ryanding16
2021-01-27 21:14
Sorry, using this for the first time. Let me try to put everything in one thread. DSL on the consumer side: ```testkey or('AB', equaltTo('A'), equalTo('B'))``` Generated contract json: ``` "matchers": [ { "match": "equality" }, { "match": "equality" } ], "combine": "OR"``` The match does not have any value: "A" or "B" But the following DSL using includeStr ```testkey or('AB', includesStr('A'), includesStr('B'))``` Generates the following contract: ``` "matchers": [ { "match": "include", "value": "A" }, { "match": "include", "value": "B" } ], "combine": "OR"``` Notice the value "A" and "B" for includeStr Could someone help me understand why the values for equalTo are missing in the generated contract?

bethskurrie
2021-01-27 21:44
@ryanding16 the way to put something in a thread is to hover over your first message and then click on the little "talking bubble". It will open up a new section on the side. It's good to do that because it reduces the noise in the thread for all the subscribers.

bethskurrie
2021-01-27 21:45
Ok, I'm replying over here @ryanding16

ryanding16
2021-01-27 21:46
Thanks

bethskurrie
2021-01-27 21:46
There are 10+ pact languages, and they all have different support for the pact specification, so it's best to ask in the channel for your language. General is for "general pact theory stuff" that's applicable to everyone.

bethskurrie
2021-01-27 21:46
Did you get a welcome message with some pointers about the channels?

bethskurrie
2021-01-27 21:47
In answer to your question, which language and version are you using?

ryanding16
2021-01-27 21:47
Should I post this to the pact-jvm channel? We use pact-jvm.

bethskurrie
2021-01-27 21:47
Is that go?

ryanding16
2021-01-27 21:48
We use v3 pact-jvm.

bethskurrie
2021-01-27 21:48
ok, yes, ask in the pact-jvm channel.

ryanding16
2021-01-27 21:48
OK, I'll post there. Thanks.

bethskurrie
2021-01-27 21:48
I think I might be able to answer your question though

bethskurrie
2021-01-27 21:49
for equal to, it just uses the values in the pact.

bethskurrie
2021-01-27 21:49
there is only extra matching data put into the matchers section when the value in the pact is not necessarily the value that should be accepted on the provider side.

bethskurrie
2021-01-27 21:50
in the equality case, it's just saying "the value that the provider returns must be equal to the value that was put into the pact"

ryanding16
2021-01-27 22:17
So how do I specify that the response value is either "A" or "B"? I over simplified the actual problem. The response is not a simple string. The actual problem is the response could either be an empty map or a particular map (either {} or {abc: 123}, for example).

tjones
2021-01-27 23:00
@ryanding16 A common point of confusion is that a contract is not the same as a spec. So, instead of saying "you might reply with A or B", you say "in the state where you would reply with A, the response looks like A", and "in the state where you would reply with B, the response looks like B"

tjones
2021-01-27 23:00
So, generally, write two interactions- one to cover each case\

tjones
2021-01-27 23:02
The reason we do this is because if you say "it could be A or B" you could successfully validate a provider which cannot ever produce B. This is the same reason why our array-like matcher doesn't let you specify an array that could be zero length

rarora
2021-01-28 00:15
we are using java and configuring using gradle

rarora
2021-01-28 00:16
i am sorry, i am not sure which channel is java specific. can you add me to that. i found this channel in documentation

matt.fellows
2021-01-28 00:22
#pact-jvm

matt.fellows
2021-01-28 00:23
I think the answer is using system properties

rarora
2021-01-28 00:23
would that property set conditionally?

matt.fellows
2021-01-28 00:55
what have you looked at so far?

rarora
2021-01-28 00:57
currently for webhook, i get a flag set as true. based on value of that flag i set with `systemProperty "pactbroker.tags"`latest or production. Wanting to know if there is better way

matt.fellows
2021-01-28 00:58
That?s what I would do

rarora
2021-01-28 00:59
Thank you @matt.fellows ++++

matt.fellows
2021-01-28 01:03
:slightly_smiling_face:

kflo
2021-01-28 01:53
re: https://docs.pact.io/pact_nirvana/step_8 ? at what point would this CI job be invoked? or would it be invoked on a schedule?

ryanding16
2021-01-28 13:35
Thanks, Tim for helping. This is our usage scenario, we have an API to pull the execution status of a job. On the provider side, we launch the job as part of the provider state setup. Depending on the execution stage (queued, executing, finished etc.), the response of this pulling request is different. Specifically, one field of the response json is empty before the job is done. After the job is completed, we return a piece of json for that field. Depending on how busy the server is and how fast the execution is, when making the API call, this field could either be empty or has something. That's why we'd like to use the or matcher for these two possible values. It will take efforts to either pause the execution (for the empty value) or wait for the job to finish (for the non-empty value) as part of the provider state setup. Just want to confirm we could not use the or matcher in this situation and we have to do something to control the output as part of the provider state setup.

athurner
2021-01-28 13:55
has joined #general

thomas.powell
2021-01-28 16:20
Thanks for the responses both. TBH the canned data and e2e tests are in place and running so it felt like testing against a primed system would be the way to go. Mocking the internal interface would be quite an overhead and may be brittle with downstream testing. My next question... the data is quite transient in nature and has timestamps in the path. Is it possible to use 'terms' in the path then reroute requests on the provider side to a datetime (path) that exists within my canned data set?

alex.mcnair
2021-01-28 18:35
has joined #general

ryanding16
2021-01-28 21:29
Bump, could someone help confirm if the way we'd like to use the or matcher described above is supported by Pact?

matt.fellows
2021-01-28 23:17
what language do you use? It?s supported in Pact JS (beta) and Pact JVM

mailinglistsspammedme
2021-01-28 23:30
has joined #general

mailinglistsspammedme
2021-01-28 23:38
We are using pact-php and were relying on the default `PactTestListener` to start and stop the mock server (https://github.com/pact-foundation/pact-php#start-and-stop-the-mock-server). We found that because of the way it is configured (and hard coded), that it caused tests to fail for developers when they ran tests locally because it is essentially coded in a way that you have to be running specific test suites for it to start. The documentation says that you can just start the server however you'd like, which works, but the Test Listener also does a bunch of stuff as well: https://github.com/pact-foundation/pact-php/blob/master/src/PhpPact/Consumer/Listener/PactTestListener.php#L96 including uploading everything and verifying the interactions. Without copying and pasting everything how can I replicate the behaviour in the best way possible.

matt.fellows
2021-01-28 23:41
Might be best asked in #pact-php Steve

abubics
2021-01-28 23:51
I will just back @tjones?s point up here, and recommend that you should still have a test for each significant state. You want Pact to help you assert the contract by specifying all the interactions that are important. In the case you're describing, there are at least 3 states that have shapes that you care about (queued, executing, finished, etc), so you should have a interaction for each that is important to distinguish. i.e. ? given the request is queued, when the status is checked, it should have shape A ? given the request is executing, when the status is checked, it should have shape B ? etc If you don't do that, how can you tell that all the shapes you care about are correct in each state? Or inversely, that the states you care about have the fields you need?

mailinglistsspammedme
2021-01-28 23:59
I can try asking there, I saw that but there was no action in 3 months.

matt.fellows
2021-01-29 00:07
Maybe PHP just does the best job of self-documenting on Github :stuck_out_tongue:

tjones
2021-01-29 00:18
Yes, that's a really clear explanation. The point is that if your test allows either shape to pass, you don't *know* that both shapes can be generated. This is an important distinction between a spec and a contract - with a spec, you are defining what kind of shapes are generally possible. With a contract, you are asserting that the right shape is used at the right time. Note that most specs allow completely nonsensical responses to be constructed - so saying "does this match the spec" isn't actually enough to know that your client can understand the response.

abubics
2021-01-29 00:24
> the right shape is used at the right time Stealing this description, I love its conciseness :star-struck:

steven.beaver.retail
2021-01-29 15:34
has joined #general

steven.beaver.retail
2021-01-29 15:42
is http://pactflow.io working today?  Yesterday I was able to push to and pull ... today I am getting 302 errors.  Is anyone else seeing this?

kflo
2021-01-29 16:45
working for me

steven.beaver.retail
2021-01-29 16:52
I am a new user and I signed up for the free plan. Do free plans expire after 1 day?

kflo
2021-01-29 16:59
they do not

kflo
2021-01-29 16:59
i believe they are indefinite, just with restrictions

steven.beaver.retail
2021-01-29 17:17
that's my understanding as well ... I'm not sure what is happening with my account. I emailed about the issue. Thanks for your help

matt.fellows
2021-01-29 21:23
I've responded to your other query in slack.

ekberli.elbrus
2021-01-30 16:33
has joined #general

george.south
2021-02-01 21:12
has joined #general

kflo
2021-02-03 00:22
we are currently using pact for service to service communication, but we additionally also need test coverage for our public API (which is basically composed of an API gateway layer that routes to a bunch of our services). we could of course make a ?fake? consumer and test the public API that way? but i?m wondering if maybe pact isn?t the best tool for that.

kflo
2021-02-03 00:24
i guess my hesitation is because we don?t really have any way of knowing how external consumers will use our API. we can only write tests that cover flows we think they will use.


matt.fellows
2021-02-03 00:26
You?re basically on point

kflo
2021-02-03 00:26
yeah i saw that, although we have control over this public API because it is ours

matt.fellows
2021-02-03 00:26
yep

matt.fellows
2021-02-03 00:26
same kinds of problems though, just in reverse (you can?t / may not be able to control the consumer)

kflo
2021-02-03 00:28
any recommended tools? we already have swagger in our ecosystem for generating documentation so i will look into that

kflo
2021-02-03 00:29
my naive idea is that we can just maintain a manually updated swagger spec, and always run regressions against that prior to deployment. it should fail if the spec is out of sync with the implementation

matt.fellows
2021-02-03 00:41
Tools that come to mind to keep things in sync: ? *OSS Tools:* ? Dredd ? https://github.com/rabobank/openapi-contract-validator-server (via @lakitna - feel free to chime in here!) ? *Services:* ? Optic ? Akira Software The last two look promising, albeit are only in private beta As an aside, we are also planning on creating a tool (see https://github.com/pactflow/roadmap/issues/31) to validate swagger specifications that would work with the rest of the Pact ecosystem. Albeit that would be a few months away for you at best.

twierzchowski
2021-02-03 07:05
has joined #general

yassin.hajaj
2021-02-03 10:35
has joined #general

dany.marques90
2021-02-03 12:48
has joined #general

marcelo
2021-02-03 13:11
has joined #general

sandeeparthur
2021-02-03 19:46
has joined #general

jarmy
2021-02-04 00:33
How exhaustive do you want your contract tests to be? Say I have a provider that has 20 endpoints. Should we expect the consumer to write a contract that exercises all 20 endpoints and their permutations?

bethskurrie
2021-02-04 00:36
My opinion is, do the cost/benefit analysis for your situation. How likely is it that the given fields will change? Are the responses different? Would any of this be covered in any other tests? How good is your error logging?

bethskurrie
2021-02-04 00:37
Eg. when there is a high number of potental values for a field (like an enum) then I might not put every value in a contract test, but I might have my code written to explicitly handle an unknown value.

bethskurrie
2021-02-04 00:38
e.g. follow the laws of interoperation and just pass on things you don't understand, and log them in such a way that the dev team gets notified of the violation.

bethskurrie
2021-02-04 00:38
I'd make sure the main scenarios are covered, but I'm not sure of the benefit of completely exhaustive testing.

jarmy
2021-02-04 00:39
Right. Typically the more exhaustive the tests are the more brittle they become

bethskurrie
2021-02-04 00:39
totally

bethskurrie
2021-02-04 00:40
you have to make sure you're not trying to do "functional" testing at that stage

bethskurrie
2021-02-04 00:40
remember we *mostly* care about shapes, and making sure we understand the possible responses, not necessarily the response to every different variation of data.

jarmy
2021-02-04 00:42
The reason I posted this question is because we have a team that develops acceptance tests that test the swagger api docs for a provider. I imagine there would be some level of duplication with contract tests

bethskurrie
2021-02-04 00:43
yes.

bethskurrie
2021-02-04 00:44
There is overlap in the venn diagram of contract tests and acceptance tests, however, there is a lot in each circle that doesn't overlap

bethskurrie
2021-02-04 00:44
And neither on their own is sufficient.

bethskurrie
2021-02-04 00:45
But both help reduce the need for integration tests, so #winning

jarmy
2021-02-04 00:45
precisely

bethskurrie
2021-02-04 00:45
What tool are you using for verifying your OAS btw?

bethskurrie
2021-02-04 00:46
@matt.fellows and I were discussing this topic this morning actually

jarmy
2021-02-04 00:46
I believe it's RESTApi

bethskurrie
2021-02-04 00:47
I'm having trouble finding it on google. It's a very overloaded term!

bethskurrie
2021-02-04 00:48
Have you seen our Roadmap info on Pact/OAS support? https://github.com/pactflow/roadmap/issues/4

jarmy
2021-02-04 00:48
Correction, it's REST Assured

jarmy
2021-02-04 00:49
I'm following that roadmap issue

bethskurrie
2021-02-04 00:50
Awesome. Is there someone who is working on those tests who I could have a chat with? I'm interested in knowing what sort of artifacts come out of the tool that we could publish to Pactflow.

jarmy
2021-02-04 00:51
Let me see if they'd be willing to share

bethskurrie
2021-02-04 00:51
Thanks!

matt.fellows
2021-02-04 01:27
Hi Steven, just wanted to check-in as I never heard back - everything OK?

bethskurrie
2021-02-04 02:40
People - naming things is hard. What is the noun that means "a specific version of an application running in a specific environment for a period of time that starts when it is deployed, and ends when it is undeployed (ie. when the next version is deployed)". I have a particular word in my head, but when I used it, it was not obvious to another person reading my code what I meant. I want to see what words come to other people's heads without saying the word that I'm thinking of!

bethskurrie
2021-02-04 03:03
For context - at the moment, when an application version is deployed, we tag that version in the broker with the name of the environment. I'm now adding first class support for modelling <name of the thing with the app version/environment/time period> in the Pact Broker, so that when you deploy you would now run `pact-broker name-of-command-to-be-decided --pacticipant Foo ---version 1 --environment production`


tjones
2021-02-04 05:45
I mean, I would just call that `deployment`

tjones
2021-02-04 05:45
Like, the deployed version at 2pm tuesday afternoon was v1.2.3

tjones
2021-02-04 05:46
so, `deployment` or `deployedVersion`

2021-02-04 05:50
A new post has been created in *Feature Requests*

octoberclub
2021-02-04 16:27
has joined #general

kflo
2021-02-04 17:02
optic looks really nice

kflo
2021-02-04 17:03
going to try that one out

slavick
2021-02-04 17:21
has joined #general

imran.settuba
2021-02-04 18:57
has joined #general

matt.fellows
2021-02-04 21:54
Just a general shout out to a few people that I can see have been working furiously on OSS contributions over the past few weeks: @tjones (he?ll be asleep, because I saw him committing/working at almost 2am last night) :taco:

matt.fellows
2021-02-04 21:54
@marko.justinek he?ll probably be on a bike/run/swim right now :taco:

matt.fellows
2021-02-04 21:54
@artur who?s been furiously raising issues, feature requests and contributing across the ecosystem :taco:

bethskurrie
2021-02-04 21:55
I called it a deployment @tjones but then Matt thought I was talking about the deployment process itself, so that made me question the term.

matt.fellows
2021-02-04 21:57
Actually deployment is the perfect term. Sorry I didn?t get back to your other notes Beth

matt.fellows
2021-02-04 21:57
It was the `--end-previous-deployment` that I think threw me off. It seemed to imply a sort of process there

matt.fellows
2021-02-04 21:58
where as simply ?record deployment? is exactly what you talk about here

matt.fellows
2021-02-04 21:59
so perhaps rather than ?end previous deployment?, it?s really a replacement.

matt.fellows
2021-02-04 21:59
i.e. Application A version 1 is deployed to prod. Application A version 2 replaces version 1 in prod

bethskurrie
2021-02-04 21:59
Hm. Kind of. You're replacing IRL, but in terms of the resource model, you're not replacing the object.

matt.fellows
2021-02-04 22:00
But the CLI is not a resource model - that?s the REST guff under the hood

bethskurrie
2021-02-04 22:00
It's putting an end date on the previous latest "thing" resource.

bethskurrie
2021-02-04 22:00
True.

bethskurrie
2021-02-04 22:02
There's a distinction between the language used in the CLI and the terms used in the resource model. But we do want them to harmonise as much as possible.

tjones
2021-02-04 22:02
I think deploymentVersion disambiguates it between the process and what we?re talking about here

bethskurrie
2021-02-04 22:04
`pact-broker record-deployed-version --pacticipant Foo --version --1 --environment prod --replaces-previous`

bethskurrie
2021-02-04 22:04
?

bethskurrie
2021-02-04 22:05
`/environments/prod/deployed-versions/current`

bethskurrie
2021-02-04 22:05
that makes sense.

matt.fellows
2021-02-04 22:05
I think this is still clear. Version is a required flag, so not sure it?s required in the subcommand ```pact-broker record-deployment --pacticipant Foo --version --1 --environment prod --replaces-previous```

bethskurrie
2021-02-04 22:05
`/pacticipants/Foo/deployed-versions/environment/prod/latest`

matt.fellows
2021-02-04 22:06
I think `s/deployed-versions/deployments` is nicer personally

bethskurrie
2021-02-04 22:06
the `--replaces-previous` would actually be on by default because most systems are not mobile consumers, so perhaps we need a flag that says the opposite.

bethskurrie
2021-02-04 22:07
Ok, so the cli could be "record-deployment" but the API could be "deployed-versions"

matt.fellows
2021-02-04 22:07
yep, that would make sense if it matches the resource model clearer

bethskurrie
2021-02-04 22:09
If we're going back to the CLI being "deployment" is "deployment" better in the resource model after all then?

bethskurrie
2021-02-04 22:09
`/pacticipants/Foo/deployments/environment/prod/latest`

bethskurrie
2021-02-04 22:09
`/environments/prod/deployments/current`

bethskurrie
2021-02-04 22:10
I'm leaning towards deployed-versions just because "current deployments" could sound like" the ones that are in process at the moment" where as "current deployed versions" is very clear.

christopher.roberts
2021-02-05 01:02
has joined #general

tjones
2021-02-05 03:10
> most systems are not mobile consumers The other use cases I'm aware of are publishing a client library, or using a progressive web app with a long cache life

matt.fellows
2021-02-05 03:22
yes, good call

tjones
2021-02-05 03:22
I'd like to add @omer.moradd to the list of shoutouts - not only did he create an excellent wrapper for using nest-js together with Pact, but he's brought up several improvements and housekeeping items that will lead to an improved experience for developers all around :taco:

omer.moradd
2021-02-05 06:33
Wow thanks Tim! Happy to be part of Pact!! :blush:

r.darcel
2021-02-05 09:15
has joined #general

kflo
2021-02-05 18:06
first word that comes to mind for me is ?release?

kflo
2021-02-05 18:07
but i guess ?release? implies something changed, when that may not be true? so deployment also works

kflo
2021-02-05 18:10
?deployment? seems like a smaller point in time to me, but it also seems like what you are really tracking is an event and not a ?living? thing

ashish.joshi
2021-02-06 01:07
has joined #general

przemek.sech296
2021-02-08 23:18
has joined #general

matt.fellows
2021-02-09 05:32
This is what a ?day off? looks like for @bethskurrie, @uglyog and @tjones :taco:

tjones
2021-02-09 05:32
What does a day on look like? :thinking_face: :joy: :joy:

vplows
2021-02-09 06:00
has joined #general

ranjanayush03
2021-02-09 06:43
Hello all, I have a new requirement in which I need to implement contract testing for event driven message system in which the provider and the consumer are exchanging messages continuously and based on the messages the ui renders one type or another, they are using hateoas architecture. So suppose if one key changes it's value then there are some changes in the response json structure, so it will be very difficult to write mocks for every such case and in order to generate a pact for that , so is there a way to write a consumer test that has mocks which can cater to all such points based on various matchers or rule that we can provide while creating pact.

ranjanayush03
2021-02-09 06:45
If anyone has implemented contract testing for event driven architecture , it will be very helpful for me if they provide an example or a link to that.

matt.fellows
2021-02-09 10:54
howtoexamples


matt.fellows
2021-02-09 10:55
There is a message queue version here

matt.fellows
2021-02-09 10:55
which language are you using?

matt.fellows
2021-02-09 10:55
(there is also a siren example there, I think, that is a HATEOS/hypermedia api)


ranjanayush03
2021-02-09 11:55
Thanks a lot Matt will look into this

ranjanayush03
2021-02-09 11:56
We are using javascript.

rodney.stromlund
2021-02-09 16:18
has joined #general

nada
2021-02-09 19:00
has joined #general

siddhardhan
2021-02-09 20:21
has joined #general

mamtha.3687
2021-02-10 04:36
Hi, we have a HATEOAS javascript app that integrates with many message providers and has lots of interactions, say 100s of variations for each message "intent" based on various conditions. Few questions: 1. How do we implement contract tests for these? Do you recommend contract tests for messages for this? 2. Since all of the messages mostly have same parent structure, the difference is only within the nested children, is there a way for us to specify rules for the general structure once that can be used for any message as a first rule by default and any additional rules over it? 3. The inner children may not have the same depth for messages. Is there a way to just find if a key called "myKey" exists anywhere within the json (at any level)? Sorry if some or all of these questions are basic. Just trying to help out a team that's struggling with ever changing message structure and really want to leverage contract testing in the best possible way.


abubics
2021-02-10 04:38
Even if it's not the same problem set, the links in that thread might still be helpful :slightly_smiling_face:

mamtha.3687
2021-02-10 04:42
Yes the intent is the same but felt the example shared did not talk about code maintainability and best practices to segregate the interactions when there are way too many. Hence wanted to provide some more background into the issue so someone who has done something similar can assist.

matt.fellows
2021-02-10 06:45
could you perhaps give a few examples to illustrate your point? When some people say ?100s of variations? it can mean different things.

mamtha.3687
2021-02-10 07:25
The app renders UI based on messages it receives. If the intent is to identify user, the message would have validated the given information from home page and find a match and if some additional info is required, a message containing only the missing information fields is sent back and UI for that is rendered accordingly until the app is able to determine if the user is a returning user or a new one. So although the intent is just one, the message structure changes based on the information the user enters. I hope this gives you some idea?

matt.fellows
2021-02-10 07:29
sure, but could you please also share some code snipped examples of the payload?

matt.fellows
2021-02-10 07:32
Ultimately, https://docs.pact.io/consumer still applies: > The rule of thumb for working out what to test or not test is - if I don?t include this scenario, what bug in the consumer or what misunderstanding about how the provider responds might be missed. If the answer is none, don?t include it.

matt.fellows
2021-02-10 07:33
if it?s just values that can change, but have no specific meaning to the user interface (i.e. they are just displayed without having a semantic meaning), then they probably shouldn?t be included

matt.fellows
2021-02-10 07:33
if these are specific hypermedia actions that have a semantic meaning and you need to ensure they exist then they probably should exist

mamtha.3687
2021-02-10 07:42
if these are specific hypermedia actions that have a semantic meaning and you need to ensure they exist then they probably should exist <-- this exactly. There are actions and description body that contains specific validations that need to be applied to the controls. I'll check if the schema can be shared and revert.

matt.fellows
2021-02-10 07:43
thanks

lars.hisken916
2021-02-10 08:08
has joined #general

pauligoe10
2021-02-10 08:19
has joined #general

tusharvarm
2021-02-10 09:38
has joined #general

igorsharf
2021-02-10 10:39
has joined #general

kieran
2021-02-10 17:13
has joined #general

kieran
2021-02-10 17:22
Hey :wave: I am new to pact and currently using pact-python (v 1.3.0) to experiment with a consumer test and the http://packflow.io broker. The docs suggest using a unique string for versioning pacts, i.e a commit SHA, but when I pass anything other than a string in this format 'x.x.x' to the below for example I get the following error. ```pact = Consumer( "example", tag_with_git_branch=True, tags=[prod_tag_flag] ).has_pact_with( Provider("exampleName"), host_name=mock_host, port=mock_port, publish_to_broker=True, broker_base_url=pact_broker_url, broker_token=pact_token, version="1.0.0" <---- ideally this would be dynamic and unique. )``` ```Malformed version number string 9bb9d91 (ArgumentError)``` Am I misunderstanding how I am supposed to pass a version number to the broker? (https://docs.pact.io/getting_started/versioning_in_the_pact_broker/)

kieran
2021-02-10 17:23
I also subsequently get this warning when publishing to the broker: ```A pact for this consumer version is already published. Overwriting. (Note: Overwriting pacts is not recommended as it can lead to race conditions. Best practice is to provide a unique consumer version number for each publication.)```

kieran
2021-02-10 17:24
_(which makes sense if the version number is static on publish)_

poward
2021-02-10 18:17
has joined #general

thirumal.net
2021-02-10 20:51
if you are running in CICD system , i guess you can pass buildnumber

ckhadilkar
2021-02-10 21:16
has joined #general

abubics
2021-02-10 23:03
There's some advice https://docs.pact.io/getting_started/versioning_in_the_pact_broker/, but that sounds kinda like an old thing I've heard of, before people realised that the semver format might not represent enough info . . . might be more to do with that pact-python version :thinking_face:

kieran
2021-02-11 09:15
Thanks @thirumal.net - I am not sure that the build number is unique across PRs in a CICD scenario but I will try use that for now.

kieran
2021-02-11 09:15
I have raised this as an issue against the project -- thanks :thumbsup:

kieran
2021-02-11 18:23
I have figured this out, the structure must follow: ```'1.0.0-' + get_git_revision_short_hash()```

neild
2021-02-11 18:53
has joined #general

painenigowthami
2021-02-11 22:32
has joined #general

matt.fellows
2021-02-11 22:42
I?ve responded to the ticket. It looks like the `version` field on the top level `Consumer` class actually maps to the pact specification version (on the `Pact` class), which is an entirely different thing.

matt.fellows
2021-02-11 22:42
You only need to pass the version when _publishing_

stephenkilbourn
2021-02-11 23:02
has joined #general

tcarlson
2021-02-11 23:05
has joined #general

arindam.datta
2021-02-12 06:22
Hi @bethskurrie, is it recommended to keep the Provider verification step in a separate build pipeline than the normal build pipeline?

bethskurrie
2021-02-12 06:22
Yes.

bethskurrie
2021-02-12 06:22
Let me grab the docs.

arindam.datta
2021-02-12 06:23
Thanks a lot @bethskurrie, the documentation link would be helpful.


arindam.datta
2021-02-12 06:23
:pray:

bethskurrie
2021-02-12 06:23
You have two "modes" of verification. One when the pact changes, and one when the provider changes.

arindam.datta
2021-02-12 06:24
Yes, true..

arindam.datta
2021-02-12 06:24
when pact changes, webhook triggers the verification with specific pact_uri

arindam.datta
2021-02-12 06:26
So, if I understand correctly, the `verification step` which gets triggered when pact changes, is recommended to be in a separate pipeline.

arindam.datta
2021-02-12 06:27
And there will be a `verification step` in the providers normal/default build pipeline too?

bethskurrie
2021-02-12 06:29
yes

bethskurrie
2021-02-12 06:29
That page I sent you describes both flows.

arindam.datta
2021-02-12 06:29
Thanks for the confirmation... clear now. :pray:

knsrividya10
2021-02-12 06:48
has joined #general

r.strauch
2021-02-12 10:15
has joined #general

ztlboy05
2021-02-12 14:57
has joined #general

smith260194
2021-02-12 15:22
has joined #general

greg719
2021-02-12 18:41
We organize Pact related meetup talk, please join :slightly_smiling_face: https://www.meetup.com/Warsaw-Code-Craft-Group/events/276047962/ it will be the first of a series

kflo
2021-02-12 19:58
has anyone made a helm chart for the pact-stub-server before?

kflo
2021-02-12 19:59
we do deployments of our services to local kubernetes for testing, so putting the stub server there would work well for us

dabfleming
2021-02-12 20:34
has joined #general

neild
2021-02-12 21:10
Hi, i?m confused about whether or not to tag the production version of a provider when verifying a consumer contract inside the consumer CI pipeline (webhookless flow). Ex/ say we want to verify the contract in the `feat-a` branch of the consumer against the production version of the provider (tagged `prod`). In the consumer CI pipeline, we would perform the following steps: 1. checkout the production version of the provider using a Docker image 2. Run the verify step inside the consumer CI pipeline 3. Publish the results of the verification from step 2 In step 3, should we publish the results and tag the provider with `prod`? This seems to be the only way to tell the pact-broker that `feat-a` is compatible with `prod`, but it breaks the ?golden tagging rule?, which states to only tag a pacticipant with an environment name on deploy.

ryanlevell
2021-02-13 00:29
> the provider (tagged prod) You said the provider is already tagged prod, so you wouldn?t need to tag it again. The verification results will already show compatibility between consumer feat-a and provider prod.

prasanthp
2021-02-13 00:45
has joined #general

matt.fellows
2021-02-13 00:52
Haven't seen it but good idea!

bethskurrie
2021-02-13 01:02
^^ What @ryanlevell said. That pacticipant version will already be tagged with production, so it doesn't matter if you do it again or not.

bethskurrie
2021-02-13 01:03
@kflo someone has before, just google it.

kflo
2021-02-13 01:06
i saw one for the broker but not the stub server. went ahead and rolled my own for now

kflo
2021-02-13 01:07
i can throw this up on github although it only supports loading pact files from directories right now

bethskurrie
2021-02-13 01:08
sure.

bethskurrie
2021-02-13 01:08
send us the link and we can put it in the docs.

bethskurrie
2021-02-13 01:08
I mis-read your question, and didn't realise it was the stub server you meant.


bethskurrie
2021-02-13 06:14
@neild there is a change coming to the APIs that I'm making that means that I recommend that you put the "prod" tag in there just to be safe.

bethskurrie
2021-02-13 06:15
On a separate note, tag support isn't going away, but we are introducing explicit support for deployments https://github.com/pact-foundation/pact_broker/discussions/384

2021-02-14 20:13
*This polly is closed.* @bethskurrie has a polly for you!

bethskurrie
2021-02-14 21:40
@marko.justinek @animesh2712 you've voted for what I would consider the "feature branch" format. What is the name of the branch that all those features merge into?

marko.justinek
2021-02-14 22:03
`main`

abubics
2021-02-14 22:29
Can't pick multiple :( github changed their default branch name from `master` to `main` a while back, and I'm in multiple repos & git providers :sweat_smile:

bethskurrie
2021-02-14 22:30
Oh, I thought I made it multiple select, but must not have.

bhardwajdiwakar
2021-02-14 22:38
has joined #general

bethskurrie
2021-02-14 22:42
When configuring the verification on the main branch of the provider, does anyone ever have more than one *branch* of the consumer that they include? The reason I'm asking is that I'm adding support for recording the branch name with the version resource in the broker, and I want to make the whole "consumer version selectors" go away by having a `mainDevelopmentBranch` property on the pacticipant. I'm not sure whether to make it a string or an array.

bethskurrie
2021-02-14 23:00
I have plans to make the whole "configuring which pacts to verify" thing much simpler. Would welcome your thoughts on this https://github.com/pact-foundation/pact_broker/discussions/391

abdul.hussain
2021-02-14 23:31
I'm trying to integrate webhooks within my pact workflow so that when a consumer needs to deploy the provider is verified to prevent breaking changes from being deployed, to do this I've got another bitbucket pipeline I can run to verify the provider within the webhook handler, I'm currently trying to substitute the username, password or bitbucket token within the webhook I'm creating within the pact broker with some form of variable, as ideally I wouldn't like to store such credentials within the broker. Is this possible, I can only see the following variables from the documentation https://docs.pact.io/pact_broker/advanced_topics/api_docs/webhooks#dynamic-variable-substitution I also noticed the following statement from the documentation https://docs.pact.io/pact_broker/webhooks/template_library ```If you use Bitbucket and have worked out how to pass parameters into the build, can you please submit a PR to update this example.``` Thoughts?

matt.fellows
2021-02-15 00:26
ahh, so Gitflow has the idea of a release branch (`feat-a`), a main development branch (`develop`) and mainline (`master` or `main`)

matt.fellows
2021-02-15 00:27
I?m just thinking how this may map onto your question

bethskurrie
2021-02-15 00:27
sounds like an array would be safest then.

matt.fellows
2021-02-15 00:28
Personally, I think gitflow is horrible and Github flow is much better, but I know it?s common in enterprises because reasons

bethskurrie
2021-02-15 00:28
it's really "branches you want to verify all the time". but needs a better name!

matt.fellows
2021-02-15 00:29
I still think in gitflow you only really care about a single branch, it?s just that that branch will _change_ depending on where you are in the lifecycle

bethskurrie
2021-02-15 00:30
Well... that could be tricky!

matt.fellows
2021-02-15 00:31
mmm

matt.fellows
2021-02-15 00:32
that?s where falling back to the consumer version selectors probably makes sense

matt.fellows
2021-02-15 00:32
It?s probably safe to say ?we always care about `development` and `main` ? though, and during a release we additionally care about `release-x`

bethskurrie
2021-02-15 00:33
the bigger picture is that we'll be recording and automatically including deployed versions for verification, so anything that's actually in an environment will get picked up that way

bethskurrie
2021-02-15 00:33
so it's mostly "branches that are not currently deployed"

matt.fellows
2021-02-15 02:36
@gradzio is organising a PHP meetup this week on contract testing with Pact https://www.meetup.com/Warsaw-Code-Craft-Group/events/276047962/. Greg - is it worth anybody outside of the PHP community joining? Would you care to share a little more about it?

tjones
2021-02-15 05:52
People who use broker tags - does your tag name also end up in the version?

tjones
2021-02-15 05:52
or, more generally, what do you use as versions for your consumer/provider?

bethskurrie
2021-02-15 05:53
That would imply the branch name is in the version?

tjones
2021-02-15 05:54
Are broker tags always the branch name? (also, yes, this is something I?m thinking about)

bethskurrie
2021-02-15 05:54
they're pretty much always meant to be the branch name or the environment name.

bethskurrie
2021-02-15 05:54
I can't think of a reason for them to be anything else.

tjones
2021-02-15 05:54
Spoiler: I?m working on a module for pact-js which will automatically do versions from git tags

bethskurrie
2021-02-15 05:55
the special Tim format.


tjones
2021-02-15 05:55
But I?m keen to see what other people do so I can support their formats too

bethskurrie
2021-02-15 05:55
I'm not sure what it has to do with pact. it seems just a generally useful thing.

tjones
2021-02-15 05:55
Also the special tim format is just semver with lots of (allowed) metadata

tjones
2021-02-15 05:56
yep! I?m going to release it as a separate module that people can use or not as they like.

bethskurrie
2021-02-15 05:56
sounds like a good plan

tjones
2021-02-15 05:56
In js-land, we can include it in the examples so that modifying the examples results in best-practice rather than hardcoded example versions.

hiteshpatadia
2021-02-15 06:29
has joined #general

antonello
2021-02-15 07:43
We have two ways of doing versioning. In the legacy versioning, the branch would end up in the pact version. In the versioning, it doesn't!

kieran
2021-02-15 09:20
Thanks @matt.fellows I have responded also.

matt.fellows
2021-02-15 11:05
Thanks. It looks like a bug to me

matt.fellows
2021-02-15 11:13
I?ve updated the ticket

matt.fellows
2021-02-15 12:48
ICYMI - the proposal on extending Pact with plugins: https://github.com/pact-foundation/pact-specification/issues/83 (it?s fairly elaborate now - this probably could have been a blog!)

vikrant.sarkaniya
2021-02-15 13:31
has joined #general

neild
2021-02-15 14:12
Got it, thank you all. I was having a hard time wrapping my head around the tagging system, but this clears it up

lemitrou
2021-02-15 14:20
has joined #general

neild
2021-02-15 15:13
Related, I?m basing my consumer CI pipeline on the https://github.com/pactflow/example-consumer-webhookless/blob/master/.github/workflows/build.yml, and I think the `verify` step is missing some pieces. Namely, it doesn?t specify to the provider the newly published pact that needs to be verified. Am I correct or am i missing something here @bethskurrie? ``` Verify: runs-on: ubuntu-latest needs: Test continue-on-error: true steps: - run: docker pull pactfoundation/pact-cli:latest - uses: actions/checkout@v2 - name: Check if verification exists # Taises an error and does not continue if the verification already exists # Because continue-on-error is set to true, this will not fail the overall build however run: "! make check_if_successfull_verification_exists" - uses: actions/checkout@v2 with: repository: pactflow/example-provider - name: Set TRAVIS_BRANCH environment variable run: echo "::set-env name=TRAVIS_COMMIT::$(git rev-parse HEAD)" - uses: actions/setup-node@v2-beta with: node-version: '12' - name: Install run: npm i - name: Verify run: make ci_webhook env: PACT_BROKER_PUBLISH_VERIFICATION_RESULTS: true TRAVIS_BRANCH: master```

matt.fellows
2021-02-15 23:52
I spoke with @uglyog this morning about his ideas to improve the proposal, including better reliability/consistency in plugins and also including how a plugin can also refer to another plugin (the N:M problem). If that doesn?t make the plugin authorship too difficult, or detract from our key objectives, it will genuinely be *awesome.* Stay tuned

helloraj
2021-02-16 08:09
has joined #general

tjones
2021-02-16 11:29
@antonello: I?m keen to hear more details on this - what did the two schemes look like? Why did you change?

wesleythomaswilliams
2021-02-16 15:39
For context on what I've picked our flow is: feature -> develop -> pre-prod -> master (production) Although we're in the process of renaming master to main

jamesmlucas
2021-02-16 19:29
has joined #general

antonello
2021-02-16 19:47
@tjones Our current versioning is: *git-20210127-0818-21accfd6* *I showed it during our pact event.* Nothing particularly odd about the two versioning approaches. We had a different one, based on pom versions and some older apps are still on that.

gabe707
2021-02-16 20:31
has joined #general

wangpei9679
2021-02-16 21:29
has joined #general

geir
2021-02-16 23:03
has joined #general

bheemreddy181
2021-02-16 23:34
Team , How do i check a diff between two pacts ?

abubics
2021-02-16 23:43
@wesleythomaswilliams Is that a gitops kind of thing, like "this branch is deployed to this environment"?

abubics
2021-02-16 23:44
(or more like git-flow?)

matt.fellows
2021-02-17 00:02
Head to the HAL browser for a given Pact, and there is a diff relation on it

matt.fellows
2021-02-17 00:02
you can diff against any version

bheemreddy181
2021-02-17 00:04
Ah got it

bheemreddy181
2021-02-17 00:08
Matt , i got some feedback on the terraforms built around pact broker , i asked my deployment team to join this slack channel to share his feedback. you should see them soon here.

2021-02-17 03:27
A new post has been created in *Feature Requests*

tjones
2021-02-17 03:28
^ This is the kind of thing that could be implemented with the pact file operations tooling I was talking about

tjones
2021-02-17 03:28
I reckon if we had that tooling, all sorts of surprise helpful features would emerge

soruma.net
2021-02-17 05:58
has joined #general

wesleythomaswilliams
2021-02-17 09:19
I wasn't familiar with the git-flow term, but reading up, I believe that kinda fits. When our feature branches are merged into develop, they're deployed into the dev env, likewise, when develop is merged into pre-prod it's deployed to staging and master it's live in production.

therimpact
2021-02-17 12:30
has joined #general

andrzej.igielski
2021-02-17 21:41
has joined #general

andrzej.igielski
2021-02-17 21:45
Hi, I have a general conceptual questions about atomicity of tested interactions and provider states

andrzej.igielski
2021-02-17 21:48
my name is Andrzej and I?m a developer in a team that is contributing to a larger product along with other 5-6 teams. The product we?re developing consists of a number of components that communicate with each other, but are - generally speaking - developed as separate micro-services. We?ve been thinking of using contract testing for a while now, some of our colleagues being passionate advocates of this approach, while others having some doubts (I?m kind of somewhere in between). On clarification in advance: I?m in no way a pact (or contract testing) expert, so my questions are of rather of conceptual nature. I wanted to ask you about 2 points, because I?m still not sure if I?m missing something or whether we?re indeed thinking in different paradigms. These points (both touched upon on this page: https://docs.pact.io/getting_started/provider_states/) are: 1. Isolated testing of single interactions 2. Necessity to provide separate tooling to set internal states of the provider Ad. 1. The way I see it - the contract between consumer and provider is more than just how the provider responds to a given request. The consumer also assumes some behavior of the system over a course of of several calls. This can of course always be reduced down to a series (state, action (request), response + new state) tuples (which is essentially done by the notion of Provider States in `pact`), but this introduces tons of theoretically unrelated test cases / interactions that can be hard to manage and implies some additional capabilities of the provider (more on that in point 2). Wouldn?t it be more natural and understandable to be able to define a contract in form of a series of interactions with some ways on symbolic representation of the provider state on the client side? Ad. 2. I don?t quite understand the necessity to for the provider to additionally provide some means to set its internal state. Every valid provider state can be achieved by (a series of) public API calls, otherwise it?s not a valid provider state. So the only reason to provide additional means to achieve this state is to simplify things for the consumer. This simplification however comes at a cost on the provider side: ? additional effort to develop such means ? risk of these 2 ways (internal and public) to set the state running apart ? deviation from the microservice architecture (the consumer would essentially need to know the internals of the provider?s state to know what to set it to in a given situation); (yes, I know, this is more on the ideological than pragmatic side) Again - wouldn?t it be better to be able to define a contract as a series of interactions (as described in point 1) and achieve (more or less) the same thing? Let me give you some simple example that we were discussing in our team: ? Provider exposes ArtifactService that can register and get / list registered artifacts (corresponds to POST and GET operations in REST API) ? Consumer uses this ArtifactService and wants to make sure that the contract that is assumed by the consumer doesn?t change ? To do it the consumer wants to check that querying for an existing Artifact with ID=1234 yields the response containing attribute ID=1234. This is problematic, however, because the ArtifactService doesn?t allow the consumer to set the ID of the artifact - this ID is generated by the provider. To explicitly check the contract by using fixed ID 1234 the consumer would have to force the provider to go into this state. This could be done using some internal provider API setting the provider to this state, but we?d run into risk of setting it to something that is not a valid state (consumer would have to know all the valid internal states of the provider to not make a mistake). It?s like allowing to use a private method for test purposes. What I was suggesting is to define a contract a sequence of 2 interactions:

andrzej.igielski
2021-02-17 21:48
1. Create artifact by calling POST /artifacts and saving the result of it to some client-side test session (that could be symbolically represented in the contract by some arbitrary handle, e.g. A) 2. use the handle A to define the expectation for the GET call (i.e. check that the response of GET /artifacts/{A.id} contains attribute ID={A.id}) It would allow to test more complex behavior of the system. *Pros*: intuitive definition of test flows reflecting the nature of the provider API *Cons*: not possible to reduce to single interactions Sorry for being that verbose, but this topic has been keeping us occupied for a long time now. I hope you can clarify my doubts to some extent (confirm that what I?m writing makes sense or help me understand what I?m missing). Thanks in advance for your help!

wangpei9679
2021-02-18 00:44
Hi team, one general question, if I write the pact verify test on provider, does it means that I don?t need to write the controller test. since I found the pact verify testing is similar to the controller test which I will also mock the underlying service.

abubics
2021-02-18 00:46
The super-short answer is: ? What you've described might be a conflation with functional tests (stateful, with side-effects). ? The philosophical intent of Pact (and other contract testing tools) is to reduce the scope (collaborators, state, etc) of tests to a unit-level, so test cases & suite sizes don't grow exponentially.

abubics
2021-02-18 00:47
Functional tests are still useful, but replacing bits of them with interaction tests can improve overall test time, and remove flakiness.

abubics
2021-02-18 00:48
It's analogous to replacing bits of end-to-end tests or UI (screen-driver) tests with unit tests. You still want some integrated tests to make sure the units are connected properly, but you don't want only black-box tests, because they take forever to run, especially if they're exhaustive.

abubics
2021-02-18 00:49
You still have to work out how much coverage you want for each level of your testing pyramid :slightly_smiling_face:

abubics
2021-02-18 00:51
Yes and no. ? If I have contract tests, I write less (approaching 0) integrated controller tests (e.g. MockMVC). ? I still have controller unit tests, in cases where there is significant logic.

abubics
2021-02-18 01:29
Discussing this is a little off-topic, but I'd love to hear about your experience with that. I can only imagine issues with having no separation between building artifacts and deploying them :slightly_smiling_face:

matt.fellows
2021-02-18 01:42
> The philosophical intent of Pact (and other contract testing tools) is to reduce the scope (collaborators, state, etc) of tests to a unit-level, so test cases & suite sizes don?t grow exponentially. that statement is a piece of art

matt.fellows
2021-02-18 01:43
Just found this video, it might be helpful for some: https://www.youtube.com/watch?v=arfwmRNTwp0

wangpei9679
2021-02-18 02:53
Hi team, i am not sure if it is an existing bug, When I publish pacts with tag which contains slash `/` , it won?t work. I have to convert it to `%2F` . but when I am using the tag in verify testing, I have to use `/` instead of `%2F` .

tjones
2021-02-18 02:54
This sounds like a bug. Which framework are you using to publish / verify?

wangpei9679
2021-02-18 02:56
I am using `@pact-foundation/pact:9.15.0` pact-js.

mikewagner21
2021-02-18 03:15
has joined #general

abubics
2021-02-18 04:41
steal it for docs :innocent:


andrzej.igielski
2021-02-18 08:08
thanks Boris!

khandelwalbhushan
2021-02-18 08:10
has joined #general

aniket.agarwal
2021-02-18 09:21
has joined #general

arpit.modani
2021-02-18 09:43
has joined #general

byronth
2021-02-18 11:45
has joined #general

sagupta
2021-02-18 14:34
hi team, i have a general question . Should the `can-i-deploy` job be also included in the feature build pipeline or should only be included on master ?

wangpei9679
2021-02-18 19:06
will do,

matt.fellows
2021-02-18 21:07
Yes, you can use it as a can-i-merge check

matt.fellows
2021-02-18 21:07
See the ci/cd workshop in howtolearn

2021-02-18 21:07
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

isa.levine
2021-02-18 23:37
has joined #general

artur
2021-02-19 07:57
I have two providers, an existing system (ownCloud X) and a rewrite (OCIS). The goal is that the rewrite one day is compatible with the existing system. The consumer is supposed to work with both providers Should I have one pact with two versions of the provider or two pacts?

uglyog
2021-02-19 08:35
Is the API the same? If so, then you only need one

artur
2021-02-19 08:36
not yet, OCIS is still under heavy development, but the goal is that the API will be the same one day

uglyog
2021-02-19 08:37
I would use one pact. You will know when the new service is good when the provider test passes

arpit.modani
2021-02-19 09:47
Hi Team !! I am new to Contract testing. I have a question regarding CI/CD integration of PACT. I was going through with below attached chart and as mentioned in Consumers pipeline , producer's pipeline will also get triggered to validate the contract . So It seems total time of consumer pipeline will get increase by producer pipeline time. Is there any other way to integrate it without increasing pipeline running time?

brendan.donegan
2021-02-19 09:49
Do you use pull requests in your development process?

brian.pfretzschner
2021-02-19 10:15
has joined #general

wesleythomaswilliams
2021-02-19 10:45
We're getting to the point where we're going to fully integrate our flow so that consumer builds trigger provider builds and my initial thought on how to handle this would be to pass a build parameter into the provider build that skips everything apart from the pact test and publishing of results to the pact broker. That seems sensible to me, but I'm happy for someone to tell me how crazy that is. :smile:

brendan.donegan
2021-02-19 10:46
depends which CI system you?re using

brendan.donegan
2021-02-19 10:47
we use Jenkins and our model is to have a separate job which runs the Pact tests

brendan.donegan
2021-02-19 10:47
Then you simply call that job from the provider pipeline

brendan.donegan
2021-02-19 10:47
I would assume most other CI systems can use a similar idea

arpit.modani
2021-02-19 16:41
@brendan.donegan We are using here Gitlab. > our model is to have a separate job which runs the Pact tests If Pact test runner would be on separate job then how can we make it part of every deployment process as it would not be part of deployment pipeline .

arpit.modani
2021-02-19 16:44
@wesleythomaswilliams Your idea looks interesting but I have a doubt, still producer pipeline will run those Pact test so this time would be added into consumer pipeline time as we can't get a green pipeline until producer successfully verified the tests.

wesleythomaswilliams
2021-02-19 16:46
If you want to fully integrate pact I don't think there's away around your pipelines taking longer to run. That provider verification is always going to come with a cost in time. It's really just about minimising it I think.

brendan.donegan
2021-02-19 16:47
@arpit.modani as i mentioned already, Jenkins pipelines can call other jobs and use the result

brendan.donegan
2021-02-19 16:48
i don?t know if Gitlab can do that

arpit.modani
2021-02-19 16:49
Yes , I am also thinking in direction to optimise it . Let's say there are multiple producers , we need to trigger pipeline for every producer in parallel.

brendan.donegan
2021-02-19 16:53
your consumer pipeline should never be directly triggering the provider verification

brendan.donegan
2021-02-19 16:53
this should be done by webhooks

brendan.donegan
2021-02-19 16:54
specifically the contract-content-changed webhook

brendan.donegan
2021-02-19 16:54
that will ensure that all appropriate provider verifications get run

wesleythomaswilliams
2021-02-19 16:57
Although there are reasons why you might not be able to use webhooks. Until recently my org had security restrictions that prevented webhooks being used to trigger jenkins builds.

antonello
2021-02-19 16:58
The webhooks approach is one approach. But not the only one.

antonello
2021-02-19 16:58
I have spoken about what we do at Treatwell in my interview during the pact community event last year.

antonello
2021-02-19 17:00
I will dig it out. That said, if you invoke provider builds directly without some kind of middle man, you will end up running provider tests unnecessarily most of the time. The webhook can be set-up to be triggered only when pact content changes, which in most cases would be infrequently.

antonello
2021-02-19 17:01
We don?t use webhooks and we run provider tests in the pipeline of the consumer.

antonello
2021-02-19 17:03
I don?t go in a huge amount of details, but I?ve explained it here: https://youtu.be/wkld_wRsTDE?t=4405

brendan.donegan
2021-02-19 17:14
i will take some time to watch if, but in terms of why you chose to do it that way, was it because you couldn?t trigger the webooks on your internal CI from Pact flow?

antonello
2021-02-19 17:16
No, it was because we wanted the consumers to be fully in control, have the best possible flow and prevent provider failures after merges of feature branches of the consumers. Now some of that stuff is made easier by the pending pacts features, but our approach works well for us.

bheemreddy181
2021-02-19 17:41
this is what we are doing right now

wesleythomaswilliams
2021-02-19 17:45
One thing I am curious about, what is the best way to pause your consumer build pipeline while you wait for the provider verification to occur and the results to be posted by the provider build?

bheemreddy181
2021-02-19 17:46
that is where pending status above comes in , we can also do that with can-i-deploy tool

bheemreddy181
2021-02-19 17:47
pending status is sent using pact broker webhooks

arpit.modani
2021-02-19 17:48
does pact broker communicate with producer and consumers via webhooks here ?

bheemreddy181
2021-02-19 17:48
yes

matt.fellows
2021-02-20 00:11
yeah, can-i-deploy can poll

matt.fellows
2021-02-20 00:11
personally, I don?t like it that way. I like my Consumer build to be separate from my provider build and not have either depend on another build

matt.fellows
2021-02-20 00:11
yes, webhooks can trigger one, but that?s as far as I want it to go

matt.fellows
2021-02-20 00:11
I don?t have my consumer build blocking, waiting on my provider build

matt.fellows
2021-02-20 00:12
see the CI/CD workshop in howtolearn for our ?standard? guidance, taking into account the very interesting discussions here also

2021-02-20 00:12
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2021-02-20 00:13
Consider this case. Consumer A -> Provider B -> Provider C (aka Provider B is also a consumer). How do you set this flow up with the webhooks? Personally, I think it?s a recipe for confusion and build entanglement

arpit.modani
2021-02-20 05:44
@matt.fellows > I don?t have my consumer build blocking, waiting on my provider build But consumer builds result should depend on provider test validations , Right? As if provider fails the validation , consumer pipeline would also be failed / consumer build would not be ready for production deployment. How do you manage this?

matt.fellows
2021-02-20 09:43
Yes that's correct

matt.fellows
2021-02-20 09:44
See the workshop above, it describes the feature pact workflow that most people should use

matt.fellows
2021-02-20 09:44
Also the effective pact setup guide

tjones
2021-02-20 12:08
The question answered by can-i-deploy is ?is this consumer able to communicate with this provider?. Depending on how your deployment ecosystem works, this might be useful to you on feature branches

chitra.adikesavan
2021-02-20 15:50
has joined #general

tjones
2021-02-21 03:26
Interesting question. If you?re planning to have them deployed at the same time, you might need two pacts, or to be super careful with your versioning / pact tags

2021-02-21 04:00
A new post has been created in *Feature Requests*

bheemreddy181
2021-02-21 19:36
why not make consumer build wait until provider build is successful , i don't think it will end up in a circular dependency with this combo ( Consumer A -> Provider B -> Provider C (aka Provider B is also a consumer) ) where consumer A will not run builds for Provider B and Provider C ( aka because of Consumer B ) , there is a possibility that Consumer A wait for Provider B and Provider C and D given it has to satisfy contracts for all and i want to wait before i merge or deploy

matt.fellows
2021-02-22 00:22
Oh, I mean you totally can, but it?s just not necessary. If you have your feature builds setup right, this level of intricacy is unnecessary

matt.fellows
2021-02-22 00:23
this is just my opinion, and as you?ve seen, there are many ways to get there.

ankita.soni
2021-02-22 07:26
has joined #general

jacek.helper
2021-02-22 08:03
has joined #general

sagupta
2021-02-22 14:53
Hey team , I have a question about provider CI workflow when provider needs to make a breaking change i.e. rename an existing property in response . Based on my understanding, The overall process would look like this 1. Consumer creates a feature branch and adds the new expectation from provider (new property name). Consumer pushes this change and publish contract. 2. Contract content changed webhook will trigger provider verification webhook job which will correctly fail as provider has not changed the property name 3. Provider makes changes on feature-branch . Test locally the verification against the feature-branch tag of new feature by consumer. Pushes the change to master . 4. Now master build will verify against the stable version of pact for consumer (which expects old property ) and will fail in this case. Is this expected ? How should we go about this ? When i read the docs , the above scenario is explained by giving example for adding a new property in provider response but not changing the existing property name.

bheemreddy181
2021-02-22 15:23
Ah makes sense

seanw122
2021-02-22 15:36
has joined #general

akennedy
2021-02-22 15:54
has joined #general

esimpson
2021-02-22 16:42
has joined #general

dagrawal
2021-02-22 17:24
has joined #general

venkata.pro
2021-02-22 21:47
has joined #general

matt.fellows
2021-02-22 22:50
if you read the ci/cd workshop in howtolearn, you?ll see the way to verify ?feature pacts? is to use the pending pacts feature

2021-02-22 22:50
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

2021-02-23 00:28
A new post has been created in *Feature Requests*

bethskurrie
2021-02-23 05:16
> but not changing the existing property name. You can only do this in a backwards compatible way by adding the new name in parallel to the old name, deploying that then switching the consumer over to the new name.

vittorio.guerriero
2021-02-23 08:23
Hi, I have a question about the provider verify process. 1. The consumer introduce a new contract and they publish it with a specific tag = 'DEV' 2. The provider listen for new contract published and the verification fails 3. The provider, before honouring the new contract creates a PR to do some refactoring 4 . During the Pull request it will run all the contracts without specifying any tags. this process will fail because there are some contracts that are not satisfied yet 5. The provider will still run `can I deploy` for consumer tag 'PROD' before deploying to avoid breaking any existing contracts Can I use enablePending in order to allow t he provider to continue other work? Is this the correct way to handle contracts that are not compatible yet?

tjones
2021-02-23 08:24
Yes, that?s right

vittorio.guerriero
2021-02-23 08:24
WOW

tjones
2021-02-23 08:24
The use case you?re describing is exactly what enablePending is for

vittorio.guerriero
2021-02-23 08:24
amazing!!!

tjones
2021-02-23 08:24
We think so too!

vittorio.guerriero
2021-02-23 08:44
And, After I've deployed the changes on the provider side shall I run ALL the contract tests (without any tags) with the provider tags = 'prod'? Will enablePending prevent tagging contracts that are not compatibile?

vittorio.guerriero
2021-02-23 08:49
```{ consumerVersionTags: [], pactBrokerUrl: '{url}', pactBrokerToken: process.env.PACT_BROKER_TOKEN, provider: '{providerName}', enablePending: true, providerVersion: process.env.CI_COMMIT_SHA, providerVersionTags: [gitBranch, 'prod'], providerBaseUrl: 'http://localhost:3000/dev', publishVerificationResult: true }```

vittorio.guerriero
2021-02-23 08:50
@tjones I think I need to tag all the contracts with PROD on the Provider side because otherwise the consumer will not be able to run can-i-deploy. The contract is verified but it's not tagged as prod on the provider side yet.

bethskurrie
2021-02-23 08:59
Tagging is completely distinct from the success/failure of the verification results.

vittorio.guerriero
2021-02-23 09:05
Thanks Beth, just to clarify, If I run the verifier with the providerVersionTags = ['prod'] and enablePending: true will the 'pending' contracts/provider matrix contain the prod tag?

bethskurrie
2021-02-23 09:05
ok, now I'm reading your question again.

bethskurrie
2021-02-23 09:06
no

bethskurrie
2021-02-23 09:06
no you should not tag with prod

bethskurrie
2021-02-23 09:06
you only tag with prod when you deploy to prod.

vittorio.guerriero
2021-02-23 09:07
mmmm.. Yes, sorry, I meant to run the verifier with the Provider tagging after is deployed.

bethskurrie
2021-02-23 09:07
that can't be the prod version, because it's not yet deployed

bethskurrie
2021-02-23 09:07
that's unusual. tell me more about your usecase.

vittorio.guerriero
2021-02-23 09:07
Okay, there are not existing contracts.. project is new

bethskurrie
2021-02-23 09:07
btw, once a version is published to the broker and tagged with prod, it's always tagged with prod.

vittorio.guerriero
2021-02-23 09:08
1. The consumer publish a new contract with the tag 'DEV' 2. THe provider listen for the new published contract 3. The proviuder will verify alll the contract (only one) and it will fail

vittorio.guerriero
2021-02-23 09:08
4. The provider decide to honour the new contract

vittorio.guerriero
2021-02-23 09:09
5. The provider open a PR, runs the verification and the consumer contract is verified and passing... no tags here

bethskurrie
2021-02-23 09:09
Why no tags there?

bethskurrie
2021-02-23 09:09
tag with the branch

vittorio.guerriero
2021-02-23 09:09
I am not sure why I need them at this point...

vittorio.guerriero
2021-02-23 09:09
ah yes... good point

vittorio.guerriero
2021-02-23 09:10
I tag the provider with the branch name!

bethskurrie
2021-02-23 09:10
that's the golden rule (though I'm makign that redundant soon, because I'm adding explict branch support).

bethskurrie
2021-02-23 09:10
tag with the branch when you publish, tag with the environment name when you deploy

bethskurrie
2021-02-23 09:10
do those two things, and I think you'll find your way out of your dilemma.

vittorio.guerriero
2021-02-23 09:10
6. The provider check if they can deploy. They can deploy because there are not consumer contracts tagged with 'PROD'

vittorio.guerriero
2021-02-23 09:11
7. After is deployed the provider will tag with 'PROD. My question here is, Do I have to use consumer `consumerVersionTags` or not.. When would you use it?

bethskurrie
2021-02-23 09:12
When you tag the provider version?


bethskurrie
2021-02-23 09:13
Also, have you read the page on tagging? https://docs.pact.io/pact_broker/tags

vittorio.guerriero
2021-02-23 09:14
I will go through the guidelines again. Our current Consumers only tags with PROD after they deployed

vittorio.guerriero
2021-02-23 09:14
thanks.

bethskurrie
2021-02-23 09:14
Only tag with prod when you deploy, not when you verify

bethskurrie
2021-02-23 09:15
The consumerVersionTags are replaced by consumerVersionSelectors. They are used to tell the provider which pacts to verify when you're running the Ci/CD pipeline for the provider.

bethskurrie
2021-02-23 09:15
Here is the docs for how to configure that https://docs.pact.io/provider/recommended_configuration

bethskurrie
2021-02-23 09:15
I do really recommend the workshop. It will make much more sense when you've seen it done.

vittorio.guerriero
2021-02-23 09:17
Thanks!!

vittorio.guerriero
2021-02-23 12:22
Nice, I've also found out about `includeWipPactsSince`

2021-02-23 14:26
A new post has been created in *Feature Requests*

jordan.levin
2021-02-23 19:13
has joined #general

jordan.levin
2021-02-23 19:17
Hi Pact team, I have a question regarding AsyncAPI contract validation. My team is currently using swagger-mock-validator to perform type-diff between the Pact Contract and Swagger OpenAPI specification. This is working great, but our providers/consumers also communicate via asynchronous Kafka messages, which we have written Pact Message contracts (AsyncAPI) for. The problem is that swagger-mock-validator currently only has support for performing the validation on OpenAPI specifications. Ideally we want to be able to perform a simple `diff` between the property types defined in the AsyncAPI specification and the Pact message contract. Has anyone dealt with this problem before or know a good approach to take? I've tried making a contribution to the swagger-mock-validator project but it looks like they rely on third-party NPM libraries to perform the validation. I've also heard that there might be a way to convert the AsyncAPI specification/pact contract to OpenAPI? Has anyone had any experience with this? Any help or advice would be greatly appreciated. Thanks!

tjones
2021-02-24 00:24
I keep planning to write a blog post about this, but there are some subtle but important differences between OpenAPI and a Pact contract. A spec describes the kinds of possible responses (usually much wider than what is actually produced or intended), but doesn?t provide request/response pairs or behaviour. A Pact contract is the other way around - it gives example request response pairs, and some rules around them, but it doesn?t describe all possible responses. For this reason, it?s hard to convert one to the other in a straight forward manner.

tjones
2021-02-24 00:25
I think most teams doing OpenAPI specs are aware of this deficiency, even if not explicitly - because it?s common for an OpenAPI spec to be paired with a Postman collection which does have example request/response pairs. I think a tool to convert between Pact and Postman would be amazing.

tjones
2021-02-24 00:29
As an aside, it sounds like from your question you might be doing swagger validation in place of real provider validation. I wouldn?t recommend this.


tjones
2021-02-24 00:31
(that last link summarises the reasons I would recommend against doing swagger validation in place of provider validation)

tjones
2021-02-24 00:32
Spec-based validation is definitely better than nothing if you?re not able to do contract-based validation, of course. The other day, I was advocating for a `maybe` result from `can-i-deploy` to better describe validations submitted from specs.

tjones
2021-02-24 00:41
If you haven?t read them already @matt.fellows wrote an excellent series of posts about schema testing in the pact ecosystem: https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-1/

francesco.latorre
2021-02-24 05:59
has joined #general

aniket.g2185
2021-02-24 09:13
has joined #general

sundaresank360
2021-02-24 12:12
has joined #general

jhawthor
2021-02-24 15:18
has joined #general

jordan.levin
2021-02-24 15:24
Hi Tim, thank you for your detailed response, for now we are just using schema validation, however I will bring up these good points you made to my team. In the meantime, however I think I didn?t describe my question clearly enough. We are successfully using openAPI schema validation right now, using swagger-mock-validator. Our question is whether or not there are any tools/starting points we could use to implement Async API schema validation against a pact message contract.

chris.r.thomas
2021-02-24 16:54
has joined #general

peter.cook
2021-02-24 17:05
has joined #general

jayeshguru81
2021-02-24 18:34
has joined #general

ben.kirberger
2021-02-24 19:16
has joined #general


matt.fellows
2021-02-24 22:14
We?re currently integrating a similar approach into Pactflow, but AsyncAPI has not yet been looked into. I?m not aware of tools that can do this comparison yet, so it might need to be modified or a custom tool to do it

jordan.levin
2021-02-24 22:14
Hi Matt, yes that is me.

matt.fellows
2021-02-24 22:14
:slightly_smiling_face:

matt.fellows
2021-02-24 22:14
(brb sorry, meeting!)

jordan.levin
2021-02-24 22:19
That was my conclusion as well...I tried modifying swagger-mock-validator, but I ended up having to modify code from the dependencies that it was using and ended up getting stuck with that error in the issue. We also have 2 other engineers working on a custom Golang AsyncAPI validator but it isn?t trivial :sweat_smile:

tjones
2021-02-24 22:20
^ We had the same experience. I wanted to accompany the issue that I raised with a PR, but it?s not a simple problem.

jordan.levin
2021-02-24 22:20
No worries, I apreciate the help! Glad to know that your team has a similar conclusion in this area

m.stephkan
2021-02-25 05:30
has joined #general

stephen.tjasink
2021-02-25 08:23
has joined #general

philipchardwick
2021-02-25 12:42
Hey, has anyone ever created a flow chart explaining how to diagnose why can-i-deploy is failing? I guess it may be that everyone's set up is so different that a singular "way" to investigate wouldn't be appropriate. But seeing how other people tackle it/think about it might help me put it in clearer terms. I think I need something like this to help the engineers get started with pending pacts and the recent changes. When I make my own I'll try make it generic and share it back here if possible.

brendan.donegan
2021-02-25 13:44
shouldn?t it be as simple as inputting the versions/tags into ?the matrix? and finding out what the status of the verification is?

brendan.donegan
2021-02-25 13:45
either ran and passed, ran and failed, or never ran

brendan.donegan
2021-02-25 13:45
or the 4th possibility, the tag or version doesn?t actually exist

irldev
2021-02-25 13:54
Hello, I have a bit of a general/stupid question, apologies in advance. When we create our contract on the consumer side, we have to create tests at the same time otherwise the contract won't generate. My question is why do we need to create tests on the consumer side when creating the contract and what are those consumer tests supposed to be verifying/testing? :blush:

philipchardwick
2021-02-25 13:54
:thumbsup: that's helpful, thanks!

wesleythomaswilliams
2021-02-25 14:25
Sensible question. The example from our tests is in Java, but loosely looks like: ``` @ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "provider", providerType = ProviderType.ASYNCH) public class MyServiceConsumerPactTest { @BeforeEach void beforeEach() throws Exception { #Using the product code, create the message object (DTO) that the contract should adhere to providerMessageStringFromDto = objectMapper.writeValueAsString(providerMessageDto); } //Create the contract @Pact(provider = "provider", consumer = "myservice") public MessagePact providerMessage(MessagePactBuilder builder) { final DslPart body = new PactDslJsonBody() #Create the message body that forms the contract using pact matchers (e.g. stringType etc) .closeObject(); return builder .expectsToReceive("a provider update") .withContent(body) .toPact(); } //Validate the contract @Test @PactTestFor(pactMethod = "providerMessage") public void testProviderMessage(MessagePact pact) throws JSONException { //Get the message component of the contract final String messageFromPact = pact.getMessages().get(0).contentsAsString(); //Assert the message string against a string built from our DTO //Note: the string replace is required to workaround an issue with instant truncation JSONAssert.assertEquals(messageFromPact, providerMessageStringFromDto, false); } }``` So we're using our product code to validate the outline of our contract, thus ensuring that if something changes in the product code on the consumer side, this assertion will fail. Originally we just used json files for the comparison to get us started, but obviously they can easily drift out of sync with the product code, so we're changing that to the design above, which is similar whether we're testing REST or Message Pacts. Hope that makes sense?


francislainy.campos
2021-02-25 15:29
I understand the tests on the contract to validate whether the contract itself was created properly. Whereas the tests on the provider side validate the api request.

ben.kirberger
2021-02-25 15:59
:wave: :wave: :wave: Hey team! I?ve been digging at pact/pactflow documentation and examples, and I?m having trouble determining if contract testing is for our team or not. For our tech stack, we?re a largely nodeJS shop, but we are using Apollo federated GraphQL to drive most of our apis and our UI, in conjunction with Apache Kafka. Mikro-ORM and postgres for our data layer. Wondering if you have any examples for something like this, or if you have any thoughts. Also, the frontend team doesn?t see the value yet, but I really feel like there could be some? Any advice would be much appreciated!

ben.kirberger
2021-02-25 16:16
More details: I was ripping graphQL mutations from our UI via Chrome Dev Tools. My initial thinking there would be that I could write a contract test against the sending of that full payload. But I am more concerned about the provider changing than the consumer. The UI has a boatload of cypress tests and feels confident in our Typescript, Graphql world, we are fairly type safe, and they (the ui team) say they couldn?t break the schema if they wanted to / their payload ?won?t really change?? (in this case, I am on one of the teams that contributes to our GraphQL schemas, and we?re rewriting an API that did this before, so I?m wanting to make sure we?re at parity for the UI and other GQL consumers)

phil.endsley
2021-02-25 16:18
As far as value goes, have you seen the Convince Me page in the docs? https://docs.pact.io/faq/convinceme/ I frequently referenced this when trying to get buy in from my team when first implementing it.

phil.endsley
2021-02-25 16:19
Equally important is giving this a read too: https://docs.pact.io/faq/#what-is-pact-not-good-for

ben.kirberger
2021-02-25 16:45
Thanks Phil, I think I?ve seen both of those, but will give another read in case I missed something. Ultimately, I?m having trouble finding any examples online of contract testing in an Apollo GraphQL / Kafka world.

phil.endsley
2021-02-25 16:47
Oops, I didn't see your initial reply. Didn't realize you were looking for value specifically for those technologies

wesleythomaswilliams
2021-02-25 17:14
We don't do anything with GraphQL or Apollo, but we do use contract testing for all of our microservices that communicate via kafka.

ben.kirberger
2021-02-25 17:45
Cool @wesleythomaswilliams, do you know of any example articles / guides / repos that may help for testing Kafka? I do still seek some advice on the Apollo federation front, if anyone has that, too?

beatrizwaclawek
2021-02-25 20:27
has joined #general

zhoutianli1234
2021-02-25 21:09
has joined #general

matt.fellows
2021-02-25 22:52
There are some kafka examples here: https://docs.pactflow.io/docs/examples

matt.fellows
2021-02-25 22:53
Here is the ?how pact works? for non-http (called message pact): https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact

matt.fellows
2021-02-25 22:54
See also https://github.com/pactflow/roadmap/issues/4. We?d like to extend this model to GraphQL endpoints, especially federated ones which are mostly pass through

matt.fellows
2021-02-25 22:55
but you can do GraphQL with pact. There is also a #graphql channel, there may be some history on doing it with Apollo Federation

ben.kirberger
2021-02-25 23:00
Hmmm, yeah that?s the tricky part. Seems like a many<=>many problem with providers and consumers.

ben.kirberger
2021-02-25 23:01
Lots of apis contributing to the federated endpoint, so I see that as lots of providers?. And consumers, of course.

ben.kirberger
2021-02-25 23:02
Just trying to figure out where / how I would draw my integration lines there, but it seems it might be counterintuitive to try to contract test?

ben.kirberger
2021-02-25 23:03
I will definitely hit up all of those links ? I believe I?d seen the examples already but I will look again in case there was something I missed.

abubics
2021-02-25 23:50
hopefully that's all :pray: easier to diagnose than some other issues that vary per platform/language

abubics
2021-02-25 23:53
Another perspective: the contract is a side-effect (output) of the consumer tests. Writing the Pact description in code somewhere, without exercising it won't prove that the consumer is calling the API as expected. Likewise, not verifying it on the provider won't prove that it handles each interaction correctly..

abubics
2021-02-26 00:14
In case it hasn't come up in any of the docs you've read, a contract that describes interactions (with varying state) can provide more specific reasoning ability than a schema alone. So, depending where you cut the boundaries of a contract test, and how response shapes change in different states, you can get more useful, granular tests.

ben.kirberger
2021-02-26 01:08
I don?t know that I?ve seen it put like that. Excellent explanation, @abubics

abubics
2021-02-26 01:15
There's a whole discussion thread about schema vs contract from yesterday, if you want more detail ^_^ I'll find you the link in a sec

ben.kirberger
2021-02-26 01:16
Ah, thank you!

abubics
2021-02-26 01:17
Not every post in https://pact-foundation.slack.com/archives/C9VBGLUM9/p1614191329060800 may be relevant, but have a skim, see what you get :slightly_smiling_face:

travis.day
2021-02-26 04:06
has joined #general

andrew.cunningham
2021-02-26 11:13
has joined #general

jayeshguru81
2021-02-26 14:52
Sorry for cross posting as this issue may not be necessarily just related `jest-pact`

brianmasschaele
2021-02-27 13:27
has joined #general

pedroefajardo_pactio
2021-02-27 17:18
has joined #general

pedroefajardo_pactio
2021-02-27 17:21
TL;DR - Establishing Pact, creating Consumer Pacts on Providers that already exist. Good morning y?all. Reading the http://Pact.io documentation, it sounds like in an ideal situation the consumer writes the consumer tests using a provider mock. This I understand is because the Consumer is defining what the Provider should implement. The Provider feature does not exist yet. In some cases the providers already exist and that we are tasked to add Pact testing on these. Writing a mock that replies with complex and different payloads depending on all the different APIs and variations of query parameters seems like unnecessary work given the provider already exists. The questions I have is: Is it good process to create Pacts against the live server (running on my machine)? And if so how is it different than creating the consumer Pacts using a mock Provider? How to make the Pact mock talk to the actual provider other than setting the same port? Are there any gotchas I should look for when doing this?

brendan.donegan
2021-02-27 18:02
Hi @pedroefajardo_pactio. I think you?re misunderstanding how Pact works. The purpose of the mock server is nothing to do with the provider existing or not existing at the time. The mock server is used during the consumer tests to receive the requests and return the responses specified, and then record the contract based on this. It?s neither good practice, or even possible to write the consumer tests to run against the real provider.

brendan.donegan
2021-02-27 18:02
Once the contracts are created on the consumer side they can be replayed against the real provider using the providers testing framework to ensure the provider conforms to that contract.

pedroefajardo_pactio
2021-02-27 18:08
I think you are correct, I do not understand how Pact works. :slightly_smiling_face: I think it is better for me to start from my current understanding, step by step. All the tutorials I?ve read/seen show one creating a Pact object, as far as I understand, configured to monitor/intercept a call with the same path to the mock provider that the test makes. Is that ^^^^ correct?

pedroefajardo_pactio
2021-02-27 18:11
I guess the question boils down to: How do I create the Pact files w/o having to mock complex and existing providers. but you?re right, *I do not understand how Pact works.*

pedroefajardo_pactio
2021-02-27 18:19
I know there is a gap in how to implement Pact. I should have started by asking questions and stating my assumptions.

pedroefajardo_pactio
2021-02-27 18:25
I think the Pact object is a mock itself. I don?t know how to link the path used in the Pact mock and the call to a Provider (another mock in all the tutorials I?ve seen). Especially when the provider under test requires specially configured headers.

brendan.donegan
2021-02-27 18:47
It can be helpful to work through an end-to-end example, have you done that yet?

pedroefajardo_pactio
2021-02-27 18:54
I have done. Taking a course through Udemy and also did an exercise from another web site. The exercises all run great, they all use mock providers. I haven?t seen one that explains the relationship between the configuration of the Pact object, path, port, etc. and the call to the mocked provider. Maybe I should go back and read http://Pact.io?s documentation more carefully

pedroefajardo_pactio
2021-02-27 18:57
again, it really is a gap in my understanding. I am trying to close that gap by asking questions. Since I have made some incorrect assumptions now I need to figure out what questions to ask. :slightly_smiling_face:

pedroefajardo_pactio
2021-02-27 19:07
I think this https://github.com/pact-foundation/pact-provider-verifier#api-with-provider-states add some clarity into what my question is: How do I set up state in the provider?

brendan.donegan
2021-02-28 10:10
Just checking you?ve been through this as well? https://pactflow.io/how-pact-works/?utm_source=ossdocs&utm_campaign=getting_started#slide-1, i guess you probably have?

pedroefajardo_pactio
2021-02-28 19:37
looking at it now. thank you


tjones
2021-02-28 22:55
These diagrams also show the parts that are part of pact vs your real code

tjones
2021-02-28 22:56
the reason we use a mock provider is so that you can write your contracts without spinning up the real provider

tjones
2021-02-28 22:56
then later the contract can be verified against the real provider

tjones
2021-02-28 22:57
During verification, the expectations you set in the contract are replayed against the real provider, and pact checks to make sure the real provider behaved like the mock you set up this is a lighter weight way of ensuring that the consumer and provider can speak to each other

tjones
2021-02-28 22:57
Note that each interaction is independent

tjones
2021-02-28 22:57
this is important because it stops the mock from becoming too complex

tjones
2021-02-28 23:00
ie, you would say: ```When a create user request is sent, it looks like X A successful create user response is received, and it looks like Y``` and ```In the state where user X exists When a get user X request is sent, it looks like Z A successful describe user response is sent, and it looks like W``` ^ In this way, your mock is only mocking individual interactions, and doesn?t need to know how the internal system works or persist anything.


pedroefajardo_pactio
2021-02-28 23:41
oh man. lots of info. Will make time to parse. thank you

tjones
2021-02-28 23:45
Welcome! Let us know if you have more questions

bethskurrie
2021-03-01 00:23
People who work on mobile clients and client libraries that have multiple supported versions at a time, your thoughts on this potential new feature would be appreciated https://github.com/pact-foundation/pact_broker/discussions/398

dominic_herrmann
2021-03-01 06:54
has joined #general

thanuxxxx
2021-03-01 19:32
Hi all, I have a general question about running pact tests. 1. We have configured our pipeline to run our unit test, integration tests and cypress tests (if applicable) for every PR we make. 2. If everything goes well, then we merge to master. 3. After that, we deploy master branch to a dev environment 4. latest tagged commit of master will go to prod Where/when should I run my pact tests? ? Can I run during every PR or run during the deploy to a dev env. What is the best practice?

irldev
2021-03-01 19:40
Is there a list of bugs/work to be done for pact? Am thinking about getting involved :)

elliottmurray
2021-03-01 19:41
So most repos have issues including starter ones. What is your background?

irldev
2021-03-01 19:53
Mostly Java test automation but recently started learning typescript and C#

elliottmurray
2021-03-01 19:55
So the first two have strong support but always need more help. I know that pact net needs some love though so that would be most impactful imo

matt.fellows
2021-03-01 21:54
We try to mark the issues as ?good first issue? and ?help wanted?, so a good starting point would be to head to the language repo(s) you want to help out and look for those

matt.fellows
2021-03-01 21:54
As Elliot said, we?re looking for more .NET contributions so if that?s something you?re interested in, that?d be great

ben.kirberger
2021-03-01 23:00
Trying to go back through the CI/CD setup tutorial for the Kafka examples, I am having a problem on the following page: https://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/configure-consumer-and-provider-pipelines It states: > Back to the consumerhttps://docs.pactflow.io/docs/workshops/ci-cd/set-up-ci/configure-consumer-and-provider-pipelines#back-to-the-consumer > :white_check_mark: If you would like to see all your builds go green, you can re-trigger the consumer build by selecting ?More options? > ?Trigger build? > ?Trigger custom build?. However, I am unable to get the consumer to go green. When I build the consumer pipeline in TravisCI the second time (after provider ran and successfully verified the master build), it gives the following in logs: ```Tagged version 526145aa063bc49469221f8edcd8a7374dca7bf8 of pactflow-example-consumer-js-kafka as "master" Publishing pactflow-example-consumer-js-kafka/pactflow-example-provider-java-kafka pact to pact broker at https://funemployed.pactflow.io A pact for this consumer version is already published. Overwriting. (Note: Overwriting pacts is not recommended as it can lead to race conditions. Best practice is to provide a unique consumer version number for each publication. For more information, see https://docs.pact.io/versioning)``` Why does it overwrite? Later in the logs: ```There is no verified pact between version 526145aa063bc49469221f8edcd8a7374dca7bf8 of pactflow-example-consumer-js-kafka and the latest version of pactflow-example-provider-java-kafka with tag prod (no such version exists)``` ?which tells me it?s looking for the Prod tag, but when I look over in pactflow, both consumer and provider only have the tag of ?master?. Did I miss something?

ryanlevell
2021-03-02 01:54
Yes, for every PR (the same time you run unit tests). During deployments you are just checking the verification results of past tests via the Pact Broker CLI ?can-i-deploy? (if you are using a Pact Broker). You do not need to run the tests again for deployments.

matthew.long
2021-03-02 14:08
has joined #general

thanuxxxx
2021-03-02 15:32
But is that okay to publish contracts to broker every time we make PR? isn't it overkill?

ryanlevell
2021-03-02 15:41
No it?s not overkill. Yes, publish every time. The contract may not have changed but the contract version (git sha) has changed. If the contract is the same, the Broker is smart enough to know nothing has changed and will auto-update verification results for all versions in the matrix. Uploading the contract has very little overhead and the Broker expects it each time, so it is not a problem.

ryanlevell
2021-03-02 15:43
Our process is the same way. Our PRs trigger a Jenkins job that then runs the tests/publishes the contract.

thanuxxxx
2021-03-02 15:54
I am working on Jenkins pipeline for Pacts. It really helps me a lot. Thank you

ben.kirberger
2021-03-02 16:30
Update on this: Running `make fake_ci` from the provider kafka repo solved the missing `prod` tag problem. Not sure why it?s failing to do that in actual Travis CI?

tmoncm
2021-03-02 17:17
has joined #general

phoenixcampos01
2021-03-02 21:25
has joined #general

matt.fellows
2021-03-03 00:34
Hi Ben, let me take a look

matt.fellows
2021-03-03 00:35
I?m (happily) surprised you worked out how to get them working together. It is supposed to work that way, but they probably aren?t perfectly document

abdul.hussain
2021-03-03 01:12
I've recently become interested in pact as a contract testing framework for my frontend and backend. My CI process uses bitbucket pipelines. I've read through the docs with my understanding summed up by the following diagram in the docs. Could you guys please validate my understanding within my workflow: 1. Frontend consumer publishes pact. 2. Pact broker handles content_changed webhooks which triggers the backend provider verification through a bitbucket pipeline 3. Frontend consumers runs can I deploy with --retry-while-unknown parameter, on success the front end consumer deploys with a tag and version for the deployment in the pact broker 4. When backend provider pact verification is triggered from the frontend, on failure the consumer can I deploy job fails, on success the consumer deploys. 5. On any amendments to the backend pact backend the contract tests are run against the frontend tags i.e. dev, preprod and prod in the broker, on success can I deploy is run with the new version and provider environment, if this is successful the provider is deployed and a version tag is created for the provider in the broker with the provider environment tag.

abdul.hussain
2021-03-03 01:13
You guys think I'm missing anything?

bethskurrie
2021-03-03 02:38
Yes, that sounds right @abdul.hussain

abdul.hussain
2021-03-03 08:28
cool thanks

hugh.paul.mcgowan
2021-03-03 17:52
has joined #general

laxmi.somni508
2021-03-03 20:04
Dear All, This is a Test Documentation related query. We want to document High level test scenarios for Pact Contract testing in Test Scenario management tool . I could think of following high level scenario per Micro-service: 1. Validate that FE Consumer is able to generate the PACT file successfully & hand it over to Pact broker 2. Validate that BE Provider is able to verify the PACT file 3. Result is being updated on PACT Broker UI Kindly let me know if above is sufficient or there's anything else to cover from testing perspective. Also, it will be a great help if you have any sample Test Scenario / Test Case document for Pact testing documentation, that you could share. Many thanks [P.S::round_pushpin: If I send you a message outside your usual working hours, please do not feel that you need to respond immediately.:pray:]

abubics
2021-03-04 00:19
This workflow sounds fine, but I don't really understand what your situation is . . . you want to verify that the pact bits are actually being run during your CI pipeline?

abubics
2021-03-04 00:20
Little aside: if the contract hasn't changed, I don't think you'll see an update in the Pact broker UI. It doesn't necessarily change in every commit.

laxmi.somni508
2021-03-04 10:17
Yes. That's correct. The PACT broker will highlight only when there's disagreement between Consumer(s) and the Provider.

laxmi.somni508
2021-03-04 10:19
We are thinking to write Test case document (manual) to summarise : ? (A) what PACT tests are actually testing ? (B) To test the PACT set-up itself. In order to ensure that PACT mechanism is working correctly. I think, Its more of test process related documentation work to be documented in central Test cases documentation system, as part of implementing PACT. So please let me know if you have any sample / example of such test cases. Also kindly advise if writing tests on (A) will it be justifiable effort/ too exhaustive? Thanks

normanrs
2021-03-04 11:18
has joined #general

abubics
2021-03-04 12:46
I don't usually write tests to verify other tests . . . and if you're writing documentation to tell people how to check that things are set up properly, there's a risk they'll be stale quickly.

abubics
2021-03-04 12:47
Maybe it'd be easier to ask other clarifying questions like ? when do you expect to run these tests? ? what decisions/actions are you going to take when you get results?

thanuxxxx
2021-03-04 15:19
Hi all, I am referring this doc from http://pact.io https://docs.pact.io/pact_nirvana/step_4/#e-configure-pact-to-be-verified-when-contract-changes I completed A, B, C, and D, and I am confused what this E instructions says, Can anyone give an idea how to proceed with E? ? Consumer is a React project ? Provider is a SpringBoot ```Create a new CI job that performs just the provider pact verification step for a given pact URL. Consult the documentation for your chosen language for the syntax of how to configure this - you can find an example here. The job should accept the URL of the changed pact in the HTTP request parameters or body. You can find a library of webhooks that trigger a build in many popular CI systems here, otherwise you'll need to consult the documentation for your CI application to learn how to pass in parameters to a build```

laxmi.somni508
2021-03-04 15:53
Thanks a lot for your response. ? when do you expect to run these tests? --> We haven't finalised about it, but I guess similar to any other Automated tests run it will be on any major change/ on demand basis / periodically (overnight) ? what decisions/actions are you going to take when you get results? --> Take any corrective action, if contract is shown broken on the dashboard

jayson.bailey
2021-03-04 19:18
has joined #general

matt.fellows
2021-03-04 23:00
> when do you expect to run these tests? --> We haven?t finalised about it, but I guess similar to any other Automated tests run it will be on any major change/ on demand basis / periodically (overnight) I wouldn?t advise that. Pact tests are designed to run like unit tests. They are super fast, so there is really no reason not to do it on every build

matt.fellows
2021-03-04 23:11
> what decisions/actions are you going to take when you get results?  --> Take any corrective action, if contract is shown broken on the dashboard If the contract tests are failing, then the integration is broken. So that represents a real compatibility issue and would block your builds anyway. Documentation to help educate people around this could be helpful, to avoid reputation damage of the tool (i.e. it?s reflecting the state of the system)

abubics
2021-03-04 23:33
Yeah, it kinda sounds like you want to build more tests that do the same thing as Pact. I'd suggest integrating Pact as usual to start with, and see how it feels first :slightly_smiling_face:

ryanlevell
2021-03-05 04:18
If you publish a new contract, you as a consumer, cannot deploy that new version until it has been verified by the provider. You can ask the provider team to run their tests to verify the contract, but that?ll get old fast. Instead, this is saying to create a CI job that executes the provider tests that can be ran anytime to verify a new contract right away. To trigger this job you can use the ?contract published? webhook that will be triggered every time there?s a new contract. Now your consumer app won?t be blocked from deployments by unverified contracts.

2021-03-08 08:44
A new post has been created in *Feature Requests*

ananda-kumar.irudhaya
2021-03-08 15:12
hi team, one question..

laxmi.somni508
2021-03-08 15:39
Thanks both for your responses. @matt.fellows do you have a sample example of such document (perhaps in Excel format). Thanks

thanuxxxx
2021-03-08 16:45
I am just curious about this scenario? ? Assume this is the first time we are doing a Pact tests for a consumer and a provider, and all CI/CD are configured for us. ? we have *working branches* and a *master branch.* ? Our default testing env is called *V1*. After every PR, code will merge with master that will trigger a master build. After that, we deploy master to V1. ? Pact version is *git SHA* and pact tag is *current branch name* 1. We create consumer side tests, and make a PR. So all Pact tests will be verify after unit tests and publish the pact to Pact broker. 2. After PR is merged with master, master will be trigged, that also will verify and publish the pacts after unit tests. 3. After that, we are in deploy to V1 phase where we execute can-i-deploy command. As expected our build will fail because provider side never verified. 4. Now, we create our provider side tests, and it will run and publish the results back to broker after unit tests 5. After PR is merged with master, master build's pact test will be executed and results will be published back to broker 6. We are going to deploy provider to V1, so can-i-deploy command will be execute But we want to deploy provider to V1 if and only if consumer's V1 tag is verified against provider. But consumer never deployed to V1 so that we didn't tag consumer with V1. Is that a valid scenario?

wesleythomaswilliams
2021-03-08 16:49
Question for you... ? We have a service in production, let's call it `MyConsumer` , which has a contract with another service we own `MyProvider` ? We haven't got to the point of using webhooks to automate verification yet, so we manually trigger builds for verification. ? Today, another team in our business wanted to deploy a service, `TheirConsumer`, to consume from `MyProvider` and publishing a pact for us to verify. ? Now `MyProvider` has a `Main` branch and at the time, there was also an outstanding `Feature` branch for a piece of work. ? Both the `Main` and the `Feature` branches had verified the latest version of the contract from `MyConsumer`. ? When `TheirConsumer` published their pact, I ran the `Main` branch of `MyProvider` to verify it and it passed. ? However, when they came to run `can-i-deploy` as part of their deployment, they were prevented, because the contract hadn't been verified against the `Feature` branch version, just the `Main` version. ? Running the `Feature` branch verification fixed the issue, but it feels like they should have been able to deploy without that and that we've done something wrong, but I can't work out what. Any ideas?

thanuxxxx
2021-03-08 16:58
I think you should not verify `TheirConsumer` against your `Feature` branch

thanuxxxx
2021-03-08 17:01
From my understanding, they use `--latest` in their can-i-deploy parameter. That's why it is picking your feature branch. You should tag your main branch , and they will verify your main branch via the tag.

ryanlevell
2021-03-08 18:03
Silly question... our teams are confusing their naming because both ways make sense. Anyone have suggestions? For example, let?s take a test folder called ?consumer?. Does this mean ?my consumer tests? or ?tests for my consumers?. Both make sense IMO so some teams are defining the first way and other teams the second way.

ryanlevell
2021-03-08 18:21
(Sorry I am on mobile, I did not mean to send this to the channel as well) So the current state of you example is: 1. Consumer tagged master 2. Provider tagged master 3. Latest master-master contract has been verified 4. No one is deployed to V1 and therefore no contract is tagged V1. Is that right? As you said, this is the first time so you have to start somewhere. Attempt 1: Start with consumer 1. Deploy consumer to V1 2. Can-I-deploy will fail because no provider is present in V1 and the consumer depends on the provider being present. or else all the calls will fail. Attempt 2: Start with provider 1. Deploy provider to V1 2. Can-I-deploy will pass because the provider has no dependencies and no consumers are present yet. As consumer has no V1 tags can-I-deploy knows that and will allow the provider to deploy successfully. However, once you do deploy a consumer and now there is a consumer tagged V1 it will now enforce that the contract has been verified successfully before allowing new provider deployments.

wesleythomaswilliams
2021-03-08 18:24
If I take a service of ours that is both a consumer and provider as an example, our package structure for the tests is: `java.src.test.pact.consumer` `java.src.test.pact.provider` With the consumer package containing tests that create contracts and the provider package containing tests that verify contracts.

thanuxxxx
2021-03-08 18:52
I didn't know that can-i-deploy will allow a provider if no consumers are present yet. Thank you

ryanlevell
2021-03-08 18:59
Yes, I also define it that way, but one of our teams took the ?provider? package to mean ?tests against our providers? i.e. the consumer side tests. Which isn?t really wrong, just a different way to think about it. Thanks for your feedback!

2021-03-08 23:34
A new post has been created in *Feature Requests*

mjsmcp
2021-03-08 23:46
has joined #general

bethskurrie
2021-03-09 00:45
I've added a page titled "Help! My pact verification tests are failing. What do I do?" https://docs.pact.io/provider/how_to_fix_failing_verification_tests It's very basic now, but I'd like to add more helpful tips as time goes on. I'd also love someone who knows how to do the outlined process for JVM to contribute. Please have a read and add anything you think would be helpful for a person who was completely new to pact.

bethskurrie
2021-03-09 00:46
A :taco: for @ryanlevell for sharing about the "letting the provider deploy first" knowledge.

abubics
2021-03-09 03:32
This is something I haven't come across, because I never model the verification side as tests :thinking_face: is this only an issue when using the JVM provider annotations?

mjsmcp
2021-03-09 15:58
I have a best practices question: Is the intent of the provider verification tests just to test the serialization/routing pieces of the provider (presentation layer) and stub out the domain layer calls? Or should the pact verification run down to the datastores and also test the business logic of the provider?

brendan.donegan
2021-03-09 16:50
my understanding is Pact is only about testing the views, and definitely should *not* test the business logic

brendan.donegan
2021-03-09 16:51
in theory though if your provider is badly designed, you could hide bugs by mocking the datastore

mjsmcp
2021-03-09 17:27
Thanks, that was my understanding as well, but the 5 minute guide seemed to indicate you should go all the way to a stubbed datastore. I'd rather just test the presentation layer with Pact and run application tests against the domain layer.

javier.garcia_cotado
2021-03-09 21:52
has joined #general

matt.fellows
2021-03-10 00:37
so yeah, there are so many variables here, in our docs, it?s just easier to scope it a bit wider and be done with it

matt.fellows
2021-03-10 00:38
otherwise, we need to explain modular architecture, testing practices to ensure all of the various layers are covered and all of this other ?assumed knowledge? just to then say ?test the presentation layer? and ignore the rest.

mjsmcp
2021-03-10 00:49
That makes sense, thanks. Right now I'm working on getting my app server running in a local unit test environment to see if I can do it that way. I'm really trying to avoid running this against a live service.

matt.fellows
2021-03-10 00:55
when you say ?live? do you mean against a deployed environment, or just actually standing it up locally?

matt.fellows
2021-03-10 00:55
It does need to be available over a port (at least, most languages need this)

mjsmcp
2021-03-10 00:56
We're trying to push as much testing as early in the dev cycle as possible, so I'm trying to avoid running the pact verify against a deployed beta stage, for instance. I'd much rather run it locally as part of the build.

matt.fellows
2021-03-10 00:56
oh right

matt.fellows
2021-03-10 00:56
yes, for clarity, we _don?t_ recommend running against a deployed environment. It?s the kind of testing we?re trynig to avoid

matt.fellows
2021-03-10 00:57
what language are you using?

mjsmcp
2021-03-10 00:57
Consumer is a JS/react UI, Provider is Python via Sanic

mjsmcp
2021-03-10 00:57
We might throw golang in the mix in the future, if this poc goes well haha

matt.fellows
2021-03-10 00:58
haha

matt.fellows
2021-03-10 00:58
ok that should be easy

matt.fellows
2021-03-10 00:58
there is an example here if helpful: https://github.com/pactflow/example-provider-python

mjsmcp
2021-03-10 00:58
The fun part: I'm a java dev haha

mjsmcp
2021-03-10 00:58
Awesome, thank you. I'll check that out tomorrow.

matt.fellows
2021-03-10 00:59
haha cool, np

matt.fellows
2021-03-10 00:59
have a good night!

mjsmcp
2021-03-10 01:03
Thanks, you too!

akos.csurai
2021-03-10 13:39
has joined #general

testme2020testme
2021-03-10 14:12
has joined #general

guppy0356.nakira
2021-03-10 14:18
Pact is contract testing, right? I have read some reports. If there are 50+ microservices, it is hard to continue contract testing in the report. I understand pact isn't a silver bullet. What should I do to keep easy developing with pact?

elliottmurray
2021-03-10 14:21
Pact complexity does not grow with size. You have to do more work if you have a higher density of contracts. As in if you have 20 services each with 1 contract you will have less effort than 10 services with an average of 2 contracts

elliottmurray
2021-03-10 14:21
And what report?

guppy0356.nakira
2021-03-10 14:35
Thank you for your respond. I watched this "Testing Microservices with Service virtualization using mountebank (EA Weekend)" in youtube.

elliottmurray
2021-03-10 15:26
pact does not use virtualisation - in fact it is the antithesis of this

elliottmurray
2021-03-10 15:26
So I hope they weren't suggesting this!

mahdi.ali
2021-03-10 15:53
has joined #general

tommy.mirchandani
2021-03-10 17:13
has joined #general

fnguyen
2021-03-10 20:19
Hello. The API I am testing returns some objects but their name is not fixed. The matchers seem to be applied to a named field. Is it possible with pact to verify that my object has at least one object that conforms to a specific format? It is not an array. I could get e.g.: ```blah { m1 { value: 12 }, blue { value: 153 } }``` I want to verify that blah has at least one node with a numeric value. We control the API so we could change it to an array of name/value pairs but I don't think the design should be controlled by the test framework. Thanks

matt.fellows
2021-03-10 20:50
I believe JVM and Rust support this (dynamic keys) but no other language at the current moment

matt.fellows
2021-03-10 20:51
> We control the API so we could change it to an array of name/value pairs but I don?t think the design should be controlled by the test framework. I do understand this concern. It?s hard to comment with the example you gave, but dynamic keys are usually not that friendly to consumers of the API so that might be a better reason to change. Again, stated without context

fnguyen
2021-03-10 22:13
Thanks Matt If I read it right, it's supported through *EachKeyLike* in pact v3 which would be supported in jvm and in rust. The question was for python. It seems we may have a way to force the specific key name for our test so we should be ok without it.

matt.fellows
2021-03-10 23:15
Cool, that?s correct!

thanuxxxx
2021-03-11 01:02
If having a separate Job for provider verification is a best practice, should we run provider verification job first, before the regular build/deploy?

varinderjitkaur13
2021-03-11 01:46
has joined #general


krcl.dev
2021-03-11 05:11
has joined #general

philipchardwick
2021-03-11 15:17
We put our provider verification which runs against main and all other env tags (dev, prod etc.) after our build (our build runs the provider tests by default against main branch as well) and before deploying to dev. This is just to save time, rather than running the verification tests for each env tag before deploying to each env - doing it this way means we need to make sure the pipeline isn't stopped if the pacts fail against prod or staging because any failure will be caught by can i deploy - but doing it this way means you can deploy as far as possible. e.g if pact fails for staging and prod but not dev then we at least want to deploy to dev (this might happen if your latest consumer is only deployed as far as dev)

krishnaraoveera1294
2021-03-11 17:53
has joined #general

2021-03-11 20:54
A new post has been created in *Feature Requests*

2021-03-11 21:05
A post in *Feature Requests* has been marked as *complete*

raghavendra.kalakonda
2021-03-11 23:08
has joined #general

andries.spies
2021-03-12 07:25
has joined #general

kamil.klima
2021-03-12 11:38
has joined #general

bheemreddy181
2021-03-13 00:41
Do we have stubs available on the open source version as well ?


bheemreddy181
2021-03-13 03:03
Is that pact team wanted add or only limited to enterprise version ?

matt.fellows
2021-03-13 03:18
It's not planned for the OSS version if that's what you're asking?

matt.fellows
2021-03-13 03:19
You can of course run stubs locally using pact-stub-server etc

tjones
2021-03-13 03:32
I don?t think it?ll make it to the top of the OSS todo list, as it?s kind of a nice side feature (not related to pact core functionality).

matt.fellows
2021-03-13 03:34
Pretty much

matt.fellows
2021-03-13 03:35
For clarity, the general delineation is features to scale Pact (and more generally, contract testing) in larger organisations goes into Pactflow. Things that improve the DX and Pact direct experience is OSS

matt.fellows
2021-03-13 03:36
So for example, extension via plugins will be an OSS thing

tjones
2021-03-13 03:36
I guess an interested party could add it, but as an OSS maintainer I?d feel a bit weird about replicating premium features from Pactflow - although I?m not involved in Pactflow, I think it?s really good for the ecosystem to have an enterprise who have the time and motivation to contribute to the OSS project. We?d have fewer features in OSS land without Pactflow.

matt.fellows
2021-03-13 03:37
Yep. Occasionally we'll get the line wrong and we may correct later on as we progress the commercial experience. But in the meantime we have to find a way for commercial success AND keep Pact going

matt.fellows
2021-03-13 03:39
I did some analysis last year, and the rate of OSS contributions generally went up, and pact broker significantly, since we launched Pactflow

matt.fellows
2021-03-13 03:39
It's only a single metric, but it's a decent proxy

tjones
2021-03-13 03:39
That?s cool! I definitely perceived it that way, so it?s cool to know that it?s also measurable.

matt.fellows
2021-03-13 03:40
We only spend about 10-15% of Pactflow Dev time on OSS. I'd like to get that to around 30-50 in the next year

matt.fellows
2021-03-13 03:40
To do that, we need more commercial success to hire etc - it's a virtuous loop and has been deliberately created to ensure the interdependence and success of both

tjones
2021-03-13 03:42
I?d like that too :wink:

tjones
2021-03-13 03:42
But seriously, I really appreciate how much does come back into OSS land.

matt.fellows
2021-03-13 03:43
We've spent a LOT of time thinking about how to do this well

matt.fellows
2021-03-13 03:43
It's of course quite hard, but I enjoy it

matt.fellows
2021-03-13 03:43
Side note, if you are interested in more "how to commercialise OSS" check out the podcast open source underdogs. Very good

tjones
2021-03-13 03:43
cool!

matt.fellows
2021-03-13 03:43
(edited)

bheemreddy181
2021-03-13 04:39
I would like to contribute as much as can need some directions :)

bheemreddy181
2021-03-13 04:41
Pact team has done really great job with OSS especially you both ( Beth and Matt ) , hats off :pray::skin-tone-3:

siddharth.gupta
2021-03-13 04:45
Hey folks , My provider returns json as response , i want to validate some of the attributes not all , so how do i set the expectations in the consumer side for mock to return selected attribute and pass the provider tests .

matt.fellows
2021-03-13 04:47
Happy to give some pointers. Pick a language and we'll get you moving (or perhaps docs suggestions is a good start?)

bheemreddy181
2021-03-13 04:51
How can we use pact stub server along with pact broker is that how we use ?

bheemreddy181
2021-03-13 04:52
Your should mock only for needed attributes in your consumer contract tests

siddharth.gupta
2021-03-13 04:53
yes that is what i am doing but provider tests fails as there are extra attributes in actual provider response

bheemreddy181
2021-03-13 04:54
It will not fail unless the provider is not returning your attributes


bheemreddy181
2021-03-13 04:54
Like the body here should only have what you need and the provider should return those values

bheemreddy181
2021-03-13 04:55
Even after that if provider tests are failing then you are doing something wrong

bheemreddy181
2021-03-13 04:56
So my team is writing a mocker service which will act as multiple providers but the mocker service on the fly will also update the response based on the action you do

bheemreddy181
2021-03-13 04:58
So I am trying to see if We can just write contract tests and avoid writing or using this mocker service in replace all I want to use is the stub service

siddharth.gupta
2021-03-13 04:59
currently my boldy is like this

siddharth.gupta
2021-03-13 04:59
Body = new { // new // { entry = new[] { new { fullUrl = Match.Type("https://10.167.167.97:44370/4.0/fhir/Patient/Patient-64851"), resource = new { resourceType = "Patient", id = "Patient-64851", //v = Match.Regex("*","*") } } } // } // resourceType = Match.Regex("Patient", "Patient"), // id = Match.Regex("Patient-64851", "Patient-64851") }

bheemreddy181
2021-03-13 05:00
What is that entry variable ? It is failing on that

bheemreddy181
2021-03-13 05:01
Share your consumer tests

bheemreddy181
2021-03-13 05:01
Like the mock what you wrote

siddharth.gupta
2021-03-13 05:02
//Arrange // var guidRegex = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}"; var PatientIdentifier = "Austin E"; var eventType = "DetailsView"; var eventTimestamp = DateTime.UtcNow; // Describe what mock provider service should return when a specfic request is recieved . _mockProviderService.Given(String.Format("there is patient with name-or-identifier '{0}'", PatientIdentifier)) .UponReceiving(String.Format("a request to retrieve patient with name-or-identifier'{0}'", PatientIdentifier)) .With(new ProviderServiceRequest { Method = HttpVerb.Get, Path = "/4.0/fhir/Patient",//?name-or-identifier=" + PatientIdentifier + "&_format=json&_pretty=true", Headers = new Dictionary<string, object> { { "Authorization", @"Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6IjBFOTk1NjVDMjU3RDhCQzBDNDMwNTI1RTRENDFCMjg4N0U4ODI0RTEiLCJ0eXAiOiJKV1QiLCJ4NXQiOiJEcGxXWENWOWk4REVNRkplVFVHeWlINklKT0UifQ.eyJuYmYiOjE2MTUzNzMyMDAsImV4cCI6MTYxNTM3MzgwMCwiaXNzIjoiaHR0cHM6Ly9wdS1yb21vMThzZjE3LnNpcmUuY29tOjQ0MzMzL3Rva2Vuc2VydmljZSIsImF1ZCI6WyJodHRwczovL3B1LXJvbW8xOHNmMTcuc2lyZS5jb206NDQzMzMvdG9rZW5zZXJ2aWNlL3Jlc291cmNlcyIsIkFSSUEgRkhJUiBSZXNvdXJjZXMiXSwiY2xpZW50X2lkIjoiYWMxOWVlY2EtNWZiYi00NjJjLTlmYTAtZjc5MDNhZDM3OTk2Iiwic2NvcGUiOlsiVmFyaWFuL0FSSUEvRkhJUi9BY2NvdW50L1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0FjdGl2aXR5RGVmaW5pdGlvbi9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9BZHZlcnNlRXZlbnQvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvQWxsZXJneUludG9sZXJhbmNlL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0FsbGVyZ3lJbnRvbGVyYW5jZS9Xcml0ZSIsIlZhcmlhbi9BUklBL0ZISVIvQXBwb2ludG1lbnQvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvQXBwb2ludG1lbnQvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL0Jhc2ljL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0NhcmVQYXRoL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0NoZW1vdGhlcmFweVJlZ2ltZW4vUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvQ2xpbmljYWxJbXByZXNzaW9uL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0NsaW5pY2FsSW1wcmVzc2lvbi9Xcml0ZSIsIlZhcmlhbi9BUklBL0ZISVIvQ29tbXVuaWNhdGlvbi9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9Db21tdW5pY2F0aW9uL1dyaXRlIiwiVmFyaWFuL0FSSUEvRkhJUi9Db25kaXRpb24vUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvQ29uZGl0aW9uL1dyaXRlIiwiVmFyaWFuL0FSSUEvRkhJUi9Db3ZlcmFnZS9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9Db3ZlcmFnZS9Xcml0ZSIsIlZhcmlhbi9BUklBL0ZISVIvRGV2aWNlL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0RpYWdub3N0aWNSZXBvcnQvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvRGlhZ25vc3RpY1JlcG9ydC9Xcml0ZSIsIlZhcmlhbi9BUklBL0ZISVIvRG9jdW1lbnRSZWZlcmVuY2UvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvRG9jdW1lbnRSZWZlcmVuY2UvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL0ZhbWlseU1lbWJlckhpc3RvcnkvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvRmllbGRJbWFnZS9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9GbGFnL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0ZsYWcvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL0dyb3VwL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL0ltbXVuaXphdGlvbi9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9Mb2NhdGlvbi9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9NZWRpY2F0aW9uUmVxdWVzdC9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9NZWRpY2F0aW9uU3RhdGVtZW50L1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL01lZGljYXRpb25TdGF0ZW1lbnQvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL09ic2VydmF0aW9uL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL09yZ2FuaXphdGlvbi9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9QYXRpZW50L1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL1BhdGllbnQvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL1ByYWN0aXRpb25lci9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9QcmFjdGl0aW9uZXIvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL1Byb2NlZHVyZS9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9Qcm9jZWR1cmVSZXF1ZXN0L1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL1Byb2NlZHVyZVJlcXVlc3QvV3JpdGUiLCJWYXJpYW4vQVJJQS9GSElSL1JUUHJlc2NyaXB0aW9uL1JlYWQiLCJWYXJpYW4vQVJJQS9GSElSL1Nsb3QvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvVGFzay9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9UYXNrL1dyaXRlIiwiVmFyaWFuL0FSSUEvRkhJUi9UcmVhdG1lbnRSZWNvcmQvUmVhZCIsIlZhcmlhbi9BUklBL0ZISVIvVHJlYXRtZW50U3VtbWFyeS9SZWFkIiwiVmFyaWFuL0FSSUEvRkhJUi9WYWx1ZVNldC9SZWFkIl19.y4DsSnhwWILP72fUUikgqOxAvr1z_RMTnQrfhMRK93vZabOn533S4D3SNbwogoZJ3iRtwez5Q5zDnfDgOn5cHGb6X_Tlrj2wKFtQIm5RnesQ7QD5ESAYdJuztAaSo88-zJ6_m2AOBvEEgHsZLOEwPjoiRqSadgodrZ0BeWIuU59fVoAssl7mEtd3kJkPJHdg9p9tyfXy0zA7mPxCA1MLnwGcY0S8lC1cfBzPH4IcXwZzdtuLBAkuJz22pptK84H6KIVMuKzjN7CDVrKbuhISWICEtUtZDzVI77VRPR6oDBVOCDuqFt1XGh4l2NBqSXTYgc8-BqOKcPq6Iel7wUWADw" }, { "Accept",@"application/fhir+json"} }, Query = new Dictionary<string, object> { { "name-or-identifier",PatientIdentifier }, { "_format","json" }, { "_pretty","true" } } }) .WillRespondWith(new ProviderServiceResponse { Status = 200, Headers = new Dictionary<string, object> { { "Content-Type", @"application/fhir+json;charset=utf-8"} }, Body = new { // new // { entry = new[] { new { fullUrl = Match.Type("https://10.167.167.97:44370/4.0/fhir/Patient/Patient-64851"), resource = new { resourceType = "Patient", id = "Patient-64851", //v = Match.Regex("*","*") } } } } }) ; ; var consumer = new EventsApiClient(_mockProviderServiceBaseUri); //Act consumer.GetPatientByName(PatientIdentifier); //Assert //Assert.Equal(eventId, result.EventId); //Assert.Equal(eventType, result.EventType); //Assert.Equal(eventTimestamp, result.Timestamp); _mockProviderService.VerifyInteractions();

bheemreddy181
2021-03-13 05:03
Can you share your pact file here

siddharth.gupta
2021-03-13 05:03
sure give me sec

bheemreddy181
2021-03-13 05:05
lol don?t paste your code here hard to read , please push them to a open source git share them here

siddharth.gupta
2021-03-13 05:06
oh ok

bheemreddy181
2021-03-13 05:11
In your second interaction you entry variable is not hash that is the reason why it is failing


siddharth.gupta
2021-03-13 05:15
so test will pass even if there is extra data in actual provider response ?

bheemreddy181
2021-03-13 05:23
Yes

bheemreddy181
2021-03-13 05:25
APIs should be backward compatible as long as they fulfil your need from your consumer point of view they should pass

siddharth.gupta
2021-03-13 05:25
this is actual response from provider

siddharth.gupta
2021-03-13 05:27
can you help with simple body to validate "resourceType": "Patient", "id": "Patient-64851",

siddharth.gupta
2021-03-13 05:47
My Bad , actual response was returning 2 elements in array and i was just validating one

siddharth.gupta
2021-03-13 05:47
now tests is passing

siddharth.gupta
2021-03-13 05:48
thank you very much for your help

matt.fellows
2021-03-13 10:18
:taco: :taco: for @bheemreddy181 - thanks for helping out!!


matt.fellows
2021-03-13 10:19
that can pull contracts from a broker, and load them into a locally running server

matt.fellows
2021-03-13 10:19
The behaviour isn?t going to be as dynamic as something like Mountebank, for instance, but the mocks themselves can be validated

matt.fellows
2021-03-13 10:19
do you guys use OAS to document your APIs? I can?t recall

aniket.g2185
2021-03-13 13:31
May I know the repo where Pact Provider verifier is being re-written in `Rust` ?

aniket.g2185
2021-03-13 13:32
I think I got it, its `pact-reference`

bheemreddy181
2021-03-13 13:44
Can you elaborate what do you mean by document ?

bheemreddy181
2021-03-13 13:45
Ah OpenApi Spec we do for few , how does that help ?

bheemreddy181
2021-03-14 00:58
Isn't pact stub server same as Mountebank ? where you write tests publish them to pact broker but when ever you want those functionalities tested you pull them back into your local using pact stub server ?

matt.fellows
2021-03-14 00:59
Yeah except the pact server does not have any dynamic behaviour

bheemreddy181
2021-03-14 02:40
Dynamic in the sense , can you elaborate ?

matt.fellows
2021-03-14 02:41
Pact will only respond for the exact request/responses as documented in the contract

matt.fellows
2021-03-14 02:41
if you want to do things like predicate matching, you need a more general mocking tool (at the expense of a loss of fidelity in the contract - i.e. it may not represent the reality)


bheemreddy181
2021-03-14 02:42
got that

bheemreddy181
2021-03-14 02:43
Is the cypress integration you are working is using the same pact-stub-server

bheemreddy181
2021-03-14 02:43
Do you have a design documentation around that ?

matt.fellows
2021-03-14 02:46
There are 2 planned approaches for Cypress: 1. Pact contract mode (i.e. pact DSL is used within Cypress) - Loosely based on https://github.com/pactflow/example-consumer-cypress/ (the new cy.intercept will be used instead) 2. Pact capture mode (i.e. we capture a contract based on usage). Will likely still use the intercept feature, but won?t have the ability to capture a full pact contract with matchers. (2) will be used in conjunction with our bi-directional contracts feature in Pactflow (see https://github.com/pactflow/roadmap/issues/4)

bheemreddy181
2021-03-14 02:50
Another Question here : let's say i have a use case where in UI , I create a account in created status , then i do some functionality which changes the status from created to updated status. So i write two mocks for them one in created status response , one in updated status ?

matt.fellows
2021-03-14 02:50
that?s right

matt.fellows
2021-03-14 02:51
Pact stubs aren?t ?smart? mocks with behaviour (personally, I don?t like mocks that do that - because eventually you start rebuilding the actual mocked app! :stuck_out_tongue: )

bheemreddy181
2021-03-14 02:51
So i keep writing all contracts what all i want to test in UI and publish them to pact broker , and i verify all those contracts with my provider service ?

matt.fellows
2021-03-14 02:52
exactly

bheemreddy181
2021-03-14 02:53
makes sense

bheemreddy181
2021-03-14 02:57
So only downside i see is data with these contracts like for product id 10 i keep writing only for product id 10 not for say product 20 or 100 etc

bheemreddy181
2021-03-14 02:57
Do i write regex in my contracts so that i will pull that data ?

bheemreddy181
2021-03-14 02:58
I don't think that would be a case correct ?

matt.fellows
2021-03-14 02:59
can you please elaborate on what you mean?

matt.fellows
2021-03-14 02:59
Are we talking about stub behaviour, or just general contract testing here (for clarity)

bheemreddy181
2021-03-14 03:00
Actually both , lets say a developer wants to test a stub with product id 10 and another developer wants to test with product id 20 so they have to write one contracts for each to get the behavior and store them pact broker ?

bheemreddy181
2021-03-14 03:01
But i think i understand what you are saying , you get what ever you write in your contract tests

bheemreddy181
2021-03-14 03:03
How does regex based mock responses work for UI , they can't correct , we have to write contract tests for exact responses ? like a fully body with exact data in that body with each field what you are looking for ?

matt.fellows
2021-03-14 03:25
Request matching should work for mocks, but yes, responses won't be dynamic

matt.fellows
2021-03-14 03:25
That's kind of the downside to pact stubs

matt.fellows
2021-03-14 03:25
You don't really want to have too many examples because it is forced into a provider to test


matt.fellows
2021-03-14 03:26
(sorry kids just woke, back to work :stuck_out_tongue:)

lswanborough
2021-03-15 00:50
has joined #general

siddharth.gupta
2021-03-15 08:11
* Actual array is too long and should not contain a Hash at $.entry[0].resource.extension[1] * Actual array is too long and should not contain a Hash at $.entry[0].resource.extension[2] * Actual array is too long and should not contain a Hash at $.entry[0].resource.extension[3] * Actual array is too long and should not contain a Hash at $.entry[0].resource.extension[4] * Could not find key "valueCodeableConcept" (keys present are: url, extension) at $.entry[1].resource.extension[0] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[1] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[2] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[3] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[4] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[5] * Actual array is too long and should not contain a Hash at $.entry[1].resource.extension[6]

siddharth.gupta
2021-03-15 08:15
still the issue is if actual response comes back with different number of elements in nested hash(array) , we cannot write a single test for it on consumer side . $.entry[0].resource.extension[0] matches but test fails saying t-- Actual array is too long and should not contain a Hash at $.entry[0].resource.extension[1]....[4]

siddharth.gupta
2021-03-15 08:18
should it be this way , can we not ignore the other elements of hash which we do not wan to validate?

matt.fellows
2021-03-15 10:39
You must not be using a matcher on the top level. Without a matcher, you?re asking Pact to ensure the exact payload you need is there

siddharth.gupta
2021-03-15 10:40
ok , any pointer to examples ?

matt.fellows
2021-03-15 10:42
In most cases, just take a copy of the sample subset of the response you need, and wrap it in a general ?type? matcher (or if it?s an array, the `MinType` matcher). Any additional array elements are tested against the example So for example, if the provider actually returns this: ```{ "resourceType": "Bundle", "id": "60e1070e-f326-486d-a4c8-83efc1516366", "meta": { "lastUpdated": "2021-03-12T13:18:06.762+05:30" }, "type": "searchset", "total": 2, "link": [ { "relation": "self", "url": "https://10.167.167.97:44370/4.0/fhir/Patient?_format=json&_pretty=true&name-or-identifier=Austin%20E%20" } ], "entry": [ { "fullUrl": "https://10.167.167.97:44370/4.0/fhir/Patient/Patient-64851", "resource": { "resourceType": "Patient", "id": "Patient-64851", "meta": { "versionId": "135436046", "lastUpdated": "2008-04-24T13:16:51.060+05:30", "profile": [ "http://varian.com/fhir/v1/StructureDefinition/Patient" ], "tag": [ { "code": "DirectiveStatus", "display": "Not Present" }, { "code": "AllergyStatus", "display": "Not Present" }, { "code": "InfectionStatus", "display": "Not Present" } ] }, "extension": [ { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-status", "valueCodeableConcept": { "coding": [ { "system": "http://varian.com/fhir/CodeSystem/patient-status", "code": "New Patient (NP)" } ] } }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-class", "valueCodeableConcept": { "coding": [ { "system": "http://varian.com/fhir/CodeSystem/patient-class", "code": "Out Patient" } ] } }, { "url": "http://varian.com/fhir/v1/StructureDefinition/recordedOn", "valueDateTime": "2008-04-24T11:51:21+05:30" }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-clinicalTrial", "valueBoolean": false }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-carePlan", "valueReference": { "reference": "CarePath/CarePath-50782", "display": "Added Activities" } } ], "identifier": [ { "use": "usual", "system": "http://varian.com/fhir/identifier/Patient/ARIAID1", "value": "771512730" }, { "system": "http://varian.com/fhir/identifier/Patient/MedOnc-Id", "value": "20580000000000038502" }, { "system": "http://varian.com/fhir/identifier/Patient/RadOnc-Id", "value": "64851" }, { "system": "http://varian.com/fhir/identifier/Patient/patient-uid", "value": "4.7.720.829.87.01.7592.45745.03478294955497" }, { "system": "http://varian.com/fhir/identifier/Patient/SSN", "value": "826403832" }, { "system": "http://varian.com/fhir/identifier/Patient/ARIAID2", "value": "PatientId264851" } ], "active": true, "name": [ { "use": "official", "family": "Doernberg", "given": [ "Austin E" ] } ], "telecom": [ { "system": "phone", "value": "024-988-0858", "use": "home" } ], "gender": "male", "birthDate": "1929-03-10", "address": [ { "id": "145187", "extension": [ { "url": "http://varian.com/fhir/v1/StructureDefinition/address-telephone1", "valueString": "947-157-6980" } ], "use": "home", "type": "both", "line": [ "673 Yofee Lv." ], "city": "CityO145187", "state": "Pa", "postalCode": "73158" } ], "contact": [ { "id": "29324", "extension": [ { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-contact-subrelation", "valueString": "Cousin" }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-contact-isPrimary", "valueBoolean": true } ], "relationship": [ { "coding": [ { "system": "http://terminology.hl7.org/CodeSystem/v2-0131", "code": "C", "display": "Emergency Contact" } ] } ], "name": { "use": "official", "family": "Orvosh", "given": [ "Nicholas" ] }, "telecom": [ { "system": "phone", "value": "093-317-4103", "use": "home" } ] } ], "managingOrganization": { "reference": "Organization/Organization-Prov-1", "display": "UTXG Fayied Iewyed" } }, "search": { "mode": "match" } }, { "fullUrl": "https://10.167.167.97:44370/4.0/fhir/Patient/Patient-12716", "resource": { "resourceType": "Patient", "id": "Patient-12716", "meta": { "versionId": "135311015", "lastUpdated": "2004-05-04T15:03:29.640+05:30", "profile": [ "http://varian.com/fhir/v1/StructureDefinition/Patient" ], "tag": [ { "code": "DirectiveStatus", "display": "Not Present" }, { "code": "AllergyStatus", "display": "Not Present" }, { "code": "InfectionStatus", "display": "Not Present" } ] }, "extension": [ { "url": "http://hl7.org/fhir/us/core/StructureDefinition/us-core-race", "extension": [ { "url": "text", "valueString": "White" }, { "url": "http://varian.com/fhir/v1/StructureDefinition/isPrimary", "valueBoolean": true } ] }, { "url": "http://hl7.org/fhir/StructureDefinition/patient-citizenship", "extension": [ { "url": "code", "valueCodeableConcept": { "coding": [ { "system": "http://varian.com/fhir/CodeSystem/patient-citizenship", "code": "USA", "display": "United States" } ] } } ] }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-status", "valueCodeableConcept": { "coding": [ { "system": "http://varian.com/fhir/CodeSystem/patient-status", "code": "New Patient (NP)" } ] } }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-class", "valueCodeableConcept": { "coding": [ { "system": "http://varian.com/fhir/CodeSystem/patient-class", "code": "Out Patient" } ] } }, { "url": "http://varian.com/fhir/v1/StructureDefinition/recordedOn", "valueDateTime": "2003-12-15T15:41:32+05:30" }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-clinicalTrial", "valueBoolean": false }, { "url": "http://varian.com/fhir/v1/StructureDefinition/patient-carePlan", "valueReference": { "reference": "CarePath/CarePath-10936", "display": "Tmpl10936" } } ], "identifier": [ { "use": "usual", "system": "http://varian.com/fhir/identifier/Patient/ARIAID1", "value": "330307229" }, { "system": "http://varian.com/fhir/identifier/Patient/ARIAID2", "value": "DJB" }, { "system": "http://varian.com/fhir/identifier/Patient/MedOnc-Id", "value": "70190000000000009107" }, { "system": "http://varian.com/fhir/identifier/Patient/RadOnc-Id", "value": "12716" }, { "system": "http://varian.com/fhir/identifier/Patient/patient-uid", "value": "6.1.927.146.99.86.3321.69652.01141691677049" }, { "system": "http://varian.com/fhir/identifier/Patient/SSN", "value": "945875123" } ], "active": true, "name": [ { "use": "official", "family": "Yates", "given": [ "Austin E" ] } ], "telecom": [ { "system": "phone", "value": "172P495-5173", "use": "work" }, { "system": "phone", "value": "844-391-2085", "use": "home" } ], "gender": "female", "birthDate": "1956-01-24", "address": [ { "id": "15799", "use": "home", "type": "both", "line": [ "429 Oeepxoor Vn." ], "city": "CityO15799", "state": "Pa", "postalCode": "21201", "country": "USA" } ], "managingOrganization": { "reference": "Organization/Organization-Prov-1", "display": "UTXG Fayied Iewyed" } }, "search": { "mode": "match" } } ]``` but all you care about is ```{ "resourceType": "Bundle", "id": "60e1070e-f326-486d-a4c8-83efc1516366", "link": [ { "relation": "self", "url": "https://10.167.167.97:44370/4.0/fhir/Patient?_format=json&_pretty=true&name-or-identifier=Austin%20E%20" } ], "entry": [ { "fullUrl": "https://10.167.167.97:44370/4.0/fhir/Patient/Patient-64851", "resource": { "resourceType": "Patient", "id": "Patient-64851", "meta": { "versionId": "135436046", "lastUpdated": "2008-04-24T13:16:51.060+05:30", "profile": [ "http://varian.com/fhir/v1/StructureDefinition/Patient" ], "tag": [ { "code": "DirectiveStatus", "display": "Not Present" } ] }, "active": true }, "search": { "mode": "match" } } ] }```

siddharth.gupta
2021-03-15 10:43
ok , so does it matches the content as well or just the schema ?

matt.fellows
2021-03-15 10:45
if you use `Match.Type` it just looks at the shape

matt.fellows
2021-03-15 10:45
if you don?t use a matcher, you?re asking for exact validation


siddharth.gupta
2021-03-15 11:16
ok , thanks

don.tobias
2021-03-15 19:35
has joined #general

don.tobias
2021-03-15 19:36
I was looking at the documentation and sample apps provided by Pact. is there any examples anywhere that is JVM Provider not using spring boot? I have been searching for hours and cannot find one. I am trying to use this with services where the providers or osgi aetos services.

matt.fellows
2021-03-15 22:40
sorry we don?t have examples for every different framework, spring boot is the most popular so we use that. Is there a particular problem with testing your service?

abubics
2021-03-15 22:42
I've used Pact (on the provider side) with Ktor and Grails (which is Spring-based), and Lift, I think? What are you struggling with?

uglyog
2021-03-15 22:53
There are also lots of example tests in the Pact-JVM repository as well

laxmi.somni508
2021-03-16 11:39
Hello Helpful PACT community members, Could someone tell me (or point to a link), -> when pact tests are triggered , ideally? We're setting up PACT project for first time, & would like to know how CI/CD triggers are set-up by other projects. Many thanks


wesleythomaswilliams
2021-03-16 12:16
Ours run as part of the unit test stage in our jenkins pipeline. If not there, I would run them in a separate stage directly afterwards.

brendan.donegan
2021-03-16 13:34
The only complication is that at least in the JS world, it is advised not to run Pact tests in parallel with each other to avoid conflicts in merging contracts. This means if you want to run your unit tests and your Pact tests together, you won?t be able to run the unit tests in parallel with each other. YMMV per language and framework though, but this is the situation we find ourselves in.

don.tobias
2021-03-16 14:09
I was just having issues getting the test server up with mocks, and being able to get the correct responses. I will look into different frameworks

wesleythomaswilliams
2021-03-16 14:30
Our tests don't run in parallel so we don't hit that problem, but then the unit tests are one of the fastest stages in our pipeline so it's not really an issue. I'd basically separate out the pact tests, into a stage run after the unit tests and run them sequential. I don't imagine that's going to slow you down much unless you've got a lot of pact tests.

sagar.kathuria
2021-03-17 04:25
has joined #general

artur
2021-03-17 06:55
as I understand it I can have "pending pacts" for the case when the client expects some specific behaiviour that is not (yet) implemented in the provider Is it possible to do the same thing on an interactions level? I have one pact with x interactions, all are passing on the consumer, some are not yet passing on the provider (because of a bug in the provider). I want the build NOT to fail if any of the interactions that haven't passed before fail, but when an interaction passed in the past and starts to fail the build also should fail Or would I have to have two pacts for that? One with passing interactions and one with failing ones?

artur
2021-03-17 07:20
just to make it even more complex I have two providers that have different bugs, so some interactions pass on both, some fail on both and some fail on only one of them. My goal is to prevent regressions but not fail CI for tests that we know will fail In other sub-projects we have implemented a "expected-to-fail" system. So basically we have a list of tests that are known to fail but only those are allowed to fail. Additionally if a known-to-fail test start to pass the developer is notified (but that is a bonus). I'm trying to get my head around how that would be possible with pact without writing a wrapper https://dev.to/jankaritech/bdd-on-software-rewrite-6md

shao.sum
2021-03-17 08:35
has joined #general

bheemreddy181
2021-03-17 14:22
typically you are looking for a way to fail at each interaction level , what is benefit of having a failed scenario in production ?

phil.endsley
2021-03-17 21:37
> I want the build NOT to fail if any of the interactions that haven't passed before fail, but when an interaction passed in the past and starts to fail the build also should fail It's been a bit since I've done something with it, but I thought this is what the pending pacts feature does. If a pact has never been verified, the pact is considered pending, and the provider's build will continue passing, even if tests are failing. As soon as a successful verification is published, the pact is no longer pending, and future regressions will fail the build. The caveat here is that can-i-deploy won't return successfully, so Pact won't let you deploy incompatible changes. It just prevents the provider from becoming blocked for a scenario it has never verified it supports

riddhichopra
2021-03-18 01:28
has joined #general

anu.de
2021-03-18 02:28
has joined #general

artur
2021-03-18 03:12
@bheemreddy181 in the simplistic case I want the tests still run for the consumer, they will pass and generate interactions, part of those interactions will fail on the provider. As there are multiple providers there are different ones that will fail on different providers

artur
2021-03-18 03:15
@phil.endsley yes that is also what I understood first, but I could not make it work in the level of an interaction. Is it supposed to work on per-interaction-verification or only on a per-pact-verification? I'm currently trying to work out how to create multiple pacts, pending and not-pending ones https://github.com/owncloud/owncloud-sdk/pull/783/files

matt.fellows
2021-03-18 03:18
kreuzwerker running an online event today: ?Reduce the cost of migrating to a microservices architecture?. I?ll be there, along with @kristine.jetzke and @anja.kammer for Q&A. Please join us if you?d like to learn a bit about how we think about strategies for rebalancing the test pyramid to accommodate a distributed architecture, and of course, how Pact fits in. https://www.linkedin.com/events/pactflowevent-reducecostsofmigr6773279586156470272/

sreyaslj
2021-03-18 04:25
has joined #general

siddharth.gupta
2021-03-18 07:40
one of the provider in my organization do not want to keep track of consumer versions and run prvider test against all versions of consumer and generate compatibility matrix

siddharth.gupta
2021-03-18 07:40
how can we implement this using PactNet

matt.fellows
2021-03-18 08:20
I?ve answered in your #pact-net question

siddharth.gupta
2021-03-18 08:21
ok, thanks let e lookat it

thanuxxxx
2021-03-18 15:10
Question, for consumer side Jenkins CI/CD, I have two stages. 1. Prod 2. Dev Do I have to have two separate Can_I_Deploy , and Create_Tag stages for Prod, and Dev? ``` stage('Can I Deploy to Dev') { } stage ('Can I Deploy to Prod') { } stage ('Tag Dev') { } stage ('Tag Prod') { }``` Something like above?

thanuxxxx
2021-03-18 15:12
I missed that :disappointed: Can I find this on YouTube?

jgfarias42
2021-03-18 18:49
Good to hear these updates in Pact, regarding Plugins and Bi-directional Contracts https://pactflow.io/blog/bi-directional-contracts/ Note: The link on "Our approach to dealing with this, is to https://pactflow.io/blog/bi-directional-contracts/pactflow.io/extending-pact-with-plugins/, and make it available to all as Open Source." results in a 404 - it's malformatted.

matt.fellows
2021-03-18 21:02
Ah, thanks - I?ll fix that now!

matt.fellows
2021-03-18 21:09
1. Can i deploy to dev? 2. Deploy to dev 3. Tag Dev 4. ? 5. can I deploy to prod 6. deploy to prod 7. tag prod

arvind1017
2021-03-18 22:48
has joined #general

sushilvc84
2021-03-19 00:30
has joined #general

sushilvc84
2021-03-19 00:48
Hi Good Morning, My Name is Sushil. We ( My team located out in Singapore & India ) are running a banking application on RM/COBOL and on Linux systems. We have around 40+ interface partners connecting via IBM Websphere MQ and we use COBOL program and a C program to read/write messages on MQ. For some interfaces, we are a consumer and some providers, and for some both. We are planning to adopt contract pact testing for the application and would like to understand the feasibility and compatibility of the COBOL application.  Being a legacy technology, I was thinking, if this can achievable. Appreciate your advice and feedback.  Please do let me know if you would require any further information on the same. Thank you.

matt.fellows
2021-03-19 02:04
So on the provider side (verifying the service works - either an HTTP or a message based one) you could use our CLI tools: https://docs.pact.io/implementation_guides/cli/#pact-cli

bheemreddy181
2021-03-19 02:30
I always hear these concerns from people : ? Our API are stable , we don't have to spend too much time on writing contract tests , rather spend time on fixing production issues ? We don't break contract , did we break any contracts is years , rather than writing contract tests lets educate people around just sticking with unit / functional tests and educate to not to break contracts ? Writing contract tests for existing service slows us down , do we really need to go back write for all existing services ? Writing contract tests really adds very little value , not a lot ? Contract tests can be just unit tests , we don't have to really share feedback on both sides ? Development is slowed why not just keep contract tests in the back in seat for now and get the developments faster in production ? At times contract tests forces us to change a lot of code , like refactoring the interface etc ? We use client libraries - contract tests are not a right fit for us. ? We are really a small company do we need contract testing. ? We have teams which sit outside our org , who can't write contracts - we can't have two different approaches for same api from two different teams. Did anyone hear same concerns ?

matt.fellows
2021-03-19 02:35
I?ve also updated https://docs.pact.io/implementation_guides/other_languages to have a little more detail on how to DIY consumer and provider

matt.fellows
2021-03-19 02:35
it might take a few minutes before the changes are visible

bheemreddy181
2021-03-19 03:03
Do we have recording for this ?

matt.fellows
2021-03-19 03:23
yeah, they are all variant of questions we?ve had (see our https://docs.pact.io/faq/convinceme/ page. It might need updating)

matt.fellows
2021-03-19 03:23
some of those a relevant and worth considering, and some of them are not

matt.fellows
2021-03-19 03:24
> Our API are stable , we don?t have to spend too much time on writing contract tests , rather spend time on fixing production issues For clarity, are you saying they?d rather _fix_ production issues than prevent them? Perhaps it?s just the wording, but that seems?strange

matt.fellows
2021-03-19 03:26
If what the team is saying is essentially _?we don?t have production issues, we haven?t for years, and the current process is not very costly (i.e. lots of effort to coordinate, manage, maintain etc.)?_ Then that is one of the strongest cases to _not_ do contract testing. It?s very hard to justify changing a process that is efficient and works, unless the newer process is much more efficient, or provides some value that you?re not currently getting (value that also must justify the cost of change)

bheemreddy181
2021-03-19 03:28
they means like fix existing issues where the business is being effected rather than going back and writing contract tests for existing API's which don't change that often or our se teams don't break contract we are may matured kind of a case.

uglyog
2021-03-19 03:39
Pact is useful when you need to change an existing API, and you need to know extend of how the changes are going to effect the consumers. If the API is not changing, it is not useful. But then, if there has been no effort invested in Pact, then when do do need to change that API, you have a lot of work to do.

aniket.g2185
2021-03-19 03:43
> At times contract tests forces us to change a lot of code , like refactoring the interface etc This generally happens for good :)

aniket.g2185
2021-03-19 03:47
> We use client libraries - contract tests are not a right fit for us. This generally comes from people who do not fully understand contract tests, the things client lib generally do is make required calls , serialize/deserialize request and responses. Client libs do not verify the response. So even if client lib is used, there is no way to know if contract is being adhered to

aniket.g2185
2021-03-19 03:56
> Development is slowed why not just keep contract tests in the back in seat for now and get the developments faster in production This again comes from people who do not fully understand contract tests, the way you write contract test is no different than unit test, instead of you explicitly mocking the downstream API call and writing your unit tests, just write a pact test instead and you do not need a separate unit test to cover that method which called the downstream API. Contract test is more of Shift left testing and ideally it should be speeding up deployment cycles not slowing them down

aniket.g2185
2021-03-19 04:04
Although I agree to the point that if my services are few years old and APIs have not changed significantly in past few years, I might not want to revisit all services at this stage and start converting tests to PACT tests, but if you are working on building new set of micro-services, contract tests are highly recommended

matt.fellows
2021-03-19 04:11
Largely, the arguments for/against contract tests can be similarly made for the case of a system with/without unit tests

matt.fellows
2021-03-19 04:12
if you never change the code, then unit tests don?t matter

matt.fellows
2021-03-19 04:12
but when you want to change the code, unit tests (or other tests) prevent you from breaking existing functionality. The overhead to add unit tests retrospectively onto a system can be an effort, so you need to judge if the value outweighs the cost

matt.fellows
2021-03-19 04:14
but this is also a crude way to look at things. As Aniket alludes to, perhaps there are areas that _are_ changing a lot - Pact is a great candidate for that, and is a highly valuable thing. What is the cost to the business of an outage? One incident a year sounds small, but that doesn?t say anything about the cost to both the business ($$/reputation/etc.) and the effort to repair the damage What happens when your team grows / changes over time? Will there be knowledge gaps? Do your existing processes hold up or do they rely on key people?

matt.fellows
2021-03-19 04:15
I think it was recorded, but not sure if it?s being published. Stay tuned

aniket.g2185
2021-03-19 04:18
Absolutely, From `efforts` perspective, I think `consumer` teams should look at contract tests just like other unit tests (the only reason these kind of questions come up is because teams see Contract Tests as whole other universe) , and `provider` teams should not be even concerned, as implementing & running contract tests for provider has negligible efforts. Also my personal experience is that in early stages of development contract tests force the teams to engage more and have collaboration if they need to see successful builds at both end, that really helps

matt.fellows
2021-03-19 04:25
One final point on all of this. In my experience, the rational reasons discussed here usually don?t win people over. I don?t know of research that provides evidence for this, so take it with a grain of salt, but this is from both in my experience as somebody trying to convince others to use Pact, and also for other tools that I?ve proposed clients and my team use across my career. In consumer behaviour, it?s been shown that decisions are largely based on *emotion* rather than *reason*. What usually happens is that a buyer is in a headspace to achieve something, solve a problem, whatever. A product can then stir up excitement, something that energises you to take action on it. The rationality comes afterwards, despite our best effort to be ?objective?. For instance, you might draw up a table of pros/cons. Usually, the one you want to win will have more pros than cons, or the weightings for the respective ?pros? will be higher.

matt.fellows
2021-03-19 04:26
So what does this mean for Pact? Well, in the cases where making an argument based on logic/reason isn?t working, you need to *inspire* and *energise*

aniket.g2185
2021-03-19 04:27
well said @matt.fellows :)

matt.fellows
2021-03-19 04:27
One way to do this, is to seize an opportunity that presents <product/tool/process> as the solution

matt.fellows
2021-03-19 04:27
With Pact, the classic example is a production incident.

matt.fellows
2021-03-19 04:28
If it happens, go and get involved, listen, find the people that are most angry/upset/impacted and get them to help you make the case

matt.fellows
2021-03-19 04:28
Product people are good candidates, because they actually know the impact to the business, and often are in positions of power to do something about it (e.g. make room in a backlog/sprint)

aniket.g2185
2021-03-19 04:32
Sometimes I feel that people fail to convince others cos they themselves are not very confident about the whole process/tools and they do not counter question, if we are able to rationally answer the concerns and still someone says No, we should be confident enough to counter question, Why Not? and what are your reasons for that, unless they come up with more sensible reasons about why not

artur
2021-03-19 04:33
I've implemented a solution for my issue I described in https://pact-foundation.slack.com/archives/C5F4KFKR8/p1615964157009300 & https://pact-foundation.slack.com/archives/C5F4KFKR8/p1615965635013500 by splitting the pacts in pending and not pending interactions https://github.com/owncloud/owncloud-sdk/pull/783 but actually I don't like it very much myself. Maybe I misunderstand the whole pending concept I would be super grateful if s.o. would be able to look into the issue and the solution and advise if that is how it supposed to work

matt.fellows
2021-03-19 04:34
The pending flag is at the contract level, I believe

matt.fellows
2021-03-19 04:36
there is a proposal for the interaction level here: https://github.com/pact-foundation/pact-specification/issues/73

artur
2021-03-19 04:38
so for now I need multiple contracts between a consumer and a provider. What I've done for that is to create different "providers" Is that how it supposed to be? In real its one provider with two different implementations (versions) called oc10 and ocis

matt.fellows
2021-03-19 04:42
yeah, I can see why you wouldn?t want to do that in your use case (because now you can?t ensure they?re compatible with each other yet)

matt.fellows
2021-03-19 04:43
But you?re right, Pact isn?t supposed to model a provider this way. They are two different actual providers, so they are separate contracts that track to different implementations.

matt.fellows
2021-03-19 04:44
It?s an interesting use case. If the functionality was meant to be the same, you wouldn?t need this strangeness. But because of the ?bugs? present in each provider, you now have a (deliberately?) divergent API - so the contract needs to capture how it?s supposed to work now (not the ideal / target state)

matt.fellows
2021-03-19 04:44
Otherwise, things like can-i-deploy can?t work

artur
2021-03-19 04:50
yes, for other tests (end-to-end UI & API) we have written a system that we call "expected-to-fail" https://dev.to/jankaritech/bdd-on-software-rewrite-6md basically maitaining a list of tests that don't work yet on a specific version of the provider (mostly on the rewrite of-course) I'm tempted to do the same for the pact tests, but tried to achieve it with pact internal functionalities

matt.fellows
2021-03-19 05:12
Thanks for adding it to the issue, that will help I?m sure

matt.fellows
2021-03-19 05:12
the current pending feature won?t work for your needs, because it?s at the Pact level. Pending is really a feature to prevent breaking the provider, not the consumer

tejakoshti7
2021-03-19 06:26
has joined #general

artur
2021-03-19 07:02
let's see how my coworkers like my hack, otherwise I guess there will be an other wrapper and a list of tests that are expected to fail :disappointed:

simon.nizov
2021-03-19 07:33
How is no one talking about this?? This is huge! Great blog post @matt.fellows, it was a pleasure to read. And thanks to the entire Pact team for continuing to innovate! I?m super excited to see this new future of Pact! :party_parrot:

brendan.donegan
2021-03-19 10:06
Problem is most businesses are completely terrible at assessing and understanding the impact to their revenue outages have

aniket.g2185
2021-03-19 10:08
This is a game changer

matt.fellows
2021-03-19 10:18
indeed!

matt.fellows
2021-03-19 10:19
But that?s not the (main) point. The point is, ?the business? will still be pissed and will have temporary motivation to do something about it, before the next fire starts. That?s the time to capitalise on change

matt.fellows
2021-03-19 10:19
Thanks Simon - I know, right!?

matt.fellows
2021-03-19 10:20
I guess we haven?t shouted it too much yet, but we should. I still don?t think we?ve even fully realised the impact this could have. We?d love for you to help share that message too

matt.fellows
2021-03-19 10:20
Was there anything particular in the post that got you excited? The plugins? The ability to mix and match tools?

aniket.g2185
2021-03-19 10:22
For me , the point that none of consumer or provider dictates the contract but based on their understanding write tests and leave for Pact to match and decide

aniket.g2185
2021-03-19 10:34
Can we deploy full-fledged pactflow on premise? are there any missing features compared to managed version ?

matt.fellows
2021-03-19 10:37
You can

aniket.g2185
2021-03-19 10:37
cool, will try on weekend !

matt.fellows
2021-03-19 10:37
the only difference that we currently only support SAML2.0 connectors for authentication (i.e. you don?t get Google/Github auth)

matt.fellows
2021-03-19 10:38
so Azure AD, Okta, Auth0 etc. should work just fine

aniket.g2185
2021-03-19 10:38
Is it mandatory to have identity provider to try it out? or just recommended

matt.fellows
2021-03-19 10:39
umm no. There is a mode that puts it back into basic auth (which is a bit ugly) but means you can evaluate it

matt.fellows
2021-03-19 10:40
There is also an example SAML provider you can run locally alongside it to see how it works


matt.fellows
2021-03-19 10:42
We?re just re-jigging our licensing model, but we hope in the next few months to be able to make the on-premise container available through e.g. the public docker registry as a container that by default, has the same limits as our free tier (5 contracts, unlimited users).

matt.fellows
2021-03-19 10:42
so then you wouldn?t need to talk to us directly to test things out

matt.fellows
2021-03-19 10:43
but in the meantime, if you?re keen, drop a line to and we can discuss

aniket.g2185
2021-03-19 10:44
Is the current implementation of pactflow also having a restriction of 5 contracts, unlimited users

artur
2021-03-19 10:48
So with that change, if I now have a classic E2E UI test suite I could then "generate" a pact file from it and that way split the consumer and provider tests? At the beginning both sides would use the same recorded pact and over time consumer and provider could add to it.?

matt.fellows
2021-03-19 10:59
It?s more that the consumer can generate a pact from a classic e2e UI test (it could use pact directly, convert any serialised stubs, or simply intercept and write the stubs to a pact file without any matchers). On the provider side (initially, we only support OAS) the provider tests that it is compatible with its OAS and publishes the OAS to Pactflow. During `can-i-deploy` Pactflow will compare the pact file the consumer provided, and the OAS and ensure they are compatible, in much the same way it works today

matt.fellows
2021-03-19 10:59
if the consumer adds something to a contract that isn?t compatible with the OAS, that step will fail. If the OAS removes a field a consumer needs, same thing

matt.fellows
2021-03-19 11:00
> At the beginning both sides would use the same recorded pact and over time consumer and provider could add to it.? That?s something we?ve sort of considered, but don?t have a model for it yet. So, maybe, but we don?t have a path forward for that (yet)

matt.fellows
2021-03-19 11:33
the free tier (our starter plan) does, but there are no contract restrictions on any of our paid plans

matt.fellows
2021-03-19 11:33
is that what you mean?

aniket.g2185
2021-03-19 11:34
No, I meant if I deploy myself on-premise from available docker images, would there still be restrictions

matt.fellows
2021-03-19 11:36
well, the plans work across SaaS and on-premise.

matt.fellows
2021-03-19 11:36
So on-premise free plan (that doesn?t yet exist) would have a 5 contract limit, yes

matt.fellows
2021-03-19 11:36
the on-premise paid plans, no

yannick.adler
2021-03-19 12:44
has joined #general

wesleythomaswilliams
2021-03-19 12:57
@aniket.g2185 As a user of Pact Flow Enterprise I can happily vouch for its awesomeness, but I wasn't responsible for setting it up :smile:

simon.nizov
2021-03-19 19:40
> Was there anything particular in the post that got you excited? The plugins? The ability to mix and match tools? @matt.fellows Mostly the mix and match tools, especially the OAS integration since we?re about to use it in my company, so this couldn?t come at a better time.

aelse
2021-03-19 23:54
has joined #general

eric2323223
2021-03-20 01:35
has joined #general

jordan.r.stewart
2021-03-20 16:07
has joined #general

tmorrison
2021-03-21 21:45
has joined #general

2021-03-21 23:19
A new post has been created in *Feature Requests*

a.chandrasekaran
2021-03-22 00:50
has joined #general

2021-03-22 03:49
A new post has been created in *Feature Requests*

maksym.motornyi
2021-03-22 11:50
has joined #general

gareth.somerville
2021-03-22 12:10
has joined #general

joseph.method
2021-03-22 19:55
has joined #general

dennyg666
2021-03-22 20:54
has joined #general

me1295
2021-03-23 00:15
has joined #general

anchit.99
2021-03-23 09:04
has joined #general

laxmi.somni508
2021-03-23 15:46
Hi guys, Brining your kind attention to below question on Stackoverflow. https://stackoverflow.com/questions/66745685/negative-smoke-tests-defect-seeding-for-validating-pact-implementation Kindly provide answer/opinion if you're stackoverflow enthusiast & have something to add to the thread there. :pray: Thanks in advance.

wola.adedeji
2021-03-23 16:25
has joined #general

kenny.shobowale
2021-03-23 16:38
has joined #general

aniket.g2185
2021-03-24 05:43
General question, If 3-4 Consumers consume the same provider endpoint with not much changes to the contract, they might end up writing somewhat similar interactions. When it runs at provider end, it will be running lot of similar tests over and over again. Now although this makes lot of sense from consumer perspective, is there any easy way to deal with this at Provider end ? This is mainly from PACT 1.0 perspective

tjones
2021-03-24 05:44
Is this a problem?

tjones
2021-03-24 05:44
As in, what are the downsides to running similar / the same test twice?

aniket.g2185
2021-03-24 05:45
not really, was thinking more from the perspective of optimising it

matt.fellows
2021-03-24 05:52
I?ve raised this in the past

matt.fellows
2021-03-24 05:52
the idea of ?compressing? the tests, to reduce duplication

aniket.g2185
2021-03-24 05:52
was there any traction to that?

matt.fellows
2021-03-24 05:53
the main problem is build speed. We did some analysis on Pactflow maybe a year ago. We learned that for most customers it would make basically no difference, and for a few it would make a big difference

matt.fellows
2021-03-24 05:53
I?ll see if I can find the recent public issue about it

tjones
2021-03-24 05:53
cool!

aniket.g2185
2021-03-24 05:56
> for most customers it would make basically no difference, and for a few it would make a big difference You mean the build time would increase if we implemented something to find duplicate/similar contracts or it would decrease due to lesser tests being executed


aniket.g2185
2021-03-24 05:57
Thanks Matt, will go thru this

aniket.g2185
2021-03-24 05:59
BTW is the `bi-directional contracts` with `http://pactflow.io` a WIP or has a running implementation

matt.fellows
2021-03-24 06:05
I?d call it an MVP. It is absolutely usable though, just not documented (yet) because it may change based on our developer program feedback

kristine.jetzke
2021-03-24 07:06
You can find the recording https://vimeo.com/526231279

anbu.pandian
2021-03-24 11:54
has joined #general

rachel.barton
2021-03-24 19:12
has joined #general

thanuxxxx
2021-03-24 20:53
From my understanding, we don't have to `have --try-while-unknown` and `--try-interval` arguments for provider side `can-i-deploy` script right? webhook trigger only work from *consumer side to provider* and there is no webhook for trigger a build to consumer side. Is that statement correct?

brendan.donegan
2021-03-24 21:26
Exactly, because consumers *generate* contracts and providers *verify* them

james522
2021-03-24 22:06
has joined #general

bethskurrie
2021-03-25 01:46
An interesting take on helping consumers stay resilient to changes in the provider. The post is written by a good friend of Pact https://medium.com/pageup-tech/update-on-driving-client-resiliency-how-we-enforced-postels-law-by-violating-postel-s-law-7cd51bf15baa

bethskurrie
2021-03-25 01:48
tl;dr - randomly make changes to the response in a way that shoulnd't break the consumer if they're doing the right thing.

matt.fellows
2021-03-25 01:48
Very cool

bethskurrie
2021-03-25 01:48
eg. ordering changes, null value/missing field etc.

matt.fellows
2021-03-25 01:49
I?m sure I?ve seen this before, but maybe it was Tal?s original post

matt.fellows
2021-03-25 01:50
I recall having a conversation with <insert big customer name here> back when I was a consultant, because they would bump the major API version if a new property was added. I told them this was stupid (I may have even used that word, which is not something I would usually do). I later worked out that this person was very senior, and is now responsible for the Open Banking API specification in Australia

matt.fellows
2021-03-25 01:52
I took away two lessons from that encounter (and overall experience): 1. On your first day on a new client, it might make sense to understand the personnel and dynamics before offering an opinion 2. API design, compatibility, versioning, testing and releasing in big enterprises was flawed

matt.fellows
2021-03-25 01:54
(this person also believed a POST was a PUT, and vice versa. The team I worked in unsurprisingly didn?t agree with this, and did it the way everyone else does, so the API gateway was responsible for the public facing mistake, and converting into the correct method to the actual target API)

matt.fellows
2021-03-25 07:26
In a couple of hours, we have our Pactflow inaugural fortnightly ask-me-anything (AMA) https://meet.google.com/kvm-iwmn-iwq. This, is is an opportunity to ask any questions you might have about contract testing, Pact, Pactflow, new feature requests or just to say hello to some of us on the team. We hope to make this a regular event to help our community and customers with your contract testing journeys, and ensure Pact and Pactflow continues to solve the big problems of today and tomorrow. I hope you and your teams can make it, and look forward to seeing you there! P.S. If you?re based in North America, we?ll be running another one next week - https://mailchi.mp/pactflow.io/pactflow-post-mar!

anne.schuth320
2021-03-25 07:49
has joined #general


james.shirtcliffe
2021-03-25 12:04
has joined #general

serhii.makarenko
2021-03-25 12:55
has joined #general

mahdi.ali
2021-03-25 13:06
Ah late to the game... was this recorded by any chance?

mashabudryte
2021-03-25 14:35
has joined #general

matthew.simon.barnes_
2021-03-25 16:08
has joined #general

matt.fellows
2021-03-26 06:44
sorry not this one. As we grow it and it becomes a thing, we?ll probably start to

matt.fellows
2021-03-26 06:45
yesterday was just a couple of people dropping in, and answering questions 1-on-1.

sushilvc84
2021-03-26 07:20
Hi Matt, I have some very very basic queries, appreciate if you can help to clarify those. Lets say I have 2 application. App-1 & App-2. Both this application uses IBM WebSphere MQ to transfer messages. App-1 generated the message and drop in it's Queue Remote / Ximit Queue and then transfer's the message to App-2 or App-2 pull's the message from App-1 Queue and process it and send's back confirmation message via same MQ. Considering above Scenario, can you please confirm on my below understanding ? App-1 write's the message on it's MessageQueue and hence App-1 becomes the provider and App-2 consumes the message and process it becomes Consumer? I also understand control testing only looks at the messages only and doens't care about the transport protocol here its IBM MQ. In above example, if i want to implement contract testing, - Doesn't both the application should be involved ? Or only the application which want to use contract testing should implement on it's own? - what should be the sequence of steps implementing contract testing? like how the provider should write the message, how exactly Pact standalone executables should be used ?

jose.manzano
2021-03-26 14:27
has joined #general

chris.faulkner
2021-03-26 16:13
has joined #general

bryanw
2021-03-26 18:46
has joined #general

matt.fellows
2021-03-29 00:57
for our friends in North America and the APAC region, your AMA is tomorrow! :mega: Like last week?s session for the UK/EU region, you?re invited to ?drop in? to ask any questions you might have about contract testing, Pact, Pactflow, new feature requests or just to say hello (cameras on!) to @bethskurrie @uglyog and me! We aim to make this a regular event to help our community and customers with your contract testing journeys, and ensure Pact and Pactflow continues to solve the big problems of today and tomorrow. Add to your calendar https://evt.mx/XbDccQs3 (to access the Google Meets link) and we look forward to meeting you

kerem.durak
2021-03-29 08:34
has joined #general

mahdi.ali
2021-03-29 08:35
:+1:

matt.fellows
2021-03-29 08:56
See general, there is one tomorrow morning / Arvo depending on your TZ

mahdi.ali
2021-03-29 10:35
Thanks, I'm in the UK and have no burning questions so will wait for the next UK-EU session :)

matt.fellows
2021-03-29 10:41
Ah ok, if you have any just drop them in that main thread and we'll record and answer tomorrow

dave.clissold
2021-03-29 12:40
has joined #general

matt.fellows
2021-03-29 13:06
Any questions you'd like to ask in advance or if you're unable to make it, please add to here we'll answer them tomorrow https://docs.google.com/forms/u/1/d/1P7pXGKX0mWDqjTnd5zH_-LabTpgDm_OOUu1HJZnzAvE/edit?usp=drivesdk&chromeless=1

thanuxxxx
2021-03-29 15:02
Hey guys, this is what I did so for. > micro-services are SpringBoot (Provider) > Clients are mostly React (Consumer) Due to our CI/CD pipeline complexity I am only running Pact tests for non-prod environments. CI/CD rules : > PR build will runs unit tests + maven failsafe integration tests > Master build runs unit tests + maven failsafe integration tests + *automatic deploy to dev1* *Consumer* For PR branch > `yarn pact:verify` > `yarn pact:publish` For Master branch > `yarn pact:verify` > `yarn pact:publish` > `can-i-deploy --retry-while-unknown 300 --retry-interval 6 --version GIT_COMMIT --to 'dev1'` > `create-version-tag --version GIT_COMMIT -tag 'dev1` *Webhook* ```{ "consumer": { "name": "my-consumer" }, "provider": { "name": "my-provider" }, "request": { "method": "POST", "url": "Master build of provider/buildWithParameters?pactConsumerTags=${pactbroker.consumerVersionTags}", "username": "Username", "password": "Password", "headers": { "Accept": "application/json" } }, "events": [ { "name": "contract_content_changed" } ] }``` provider `parameters { string(name: 'pactConsumerTags', defaultValue: 'master')}` For PR branch *Pcontract-tests is a custom profile which only run pact tests* > `mvn test -Pcontract-tests -Dpact.verifier.publishResults=true -Dpact.provider.version=${GIT_COMMIT} -Dpactbroker.tags='dev1',${params.pactConsumerTags}` For master branch > `mvn test -Pcontract-tests -Dpact.verifier.publishResults=true -Dpact.provider.version=${GIT_COMMIT} -Dpactbroker.tags='dev1',${params.pactConsumerTags}` > `can-i-deploy --version ${GIT_COMMIT} --to 'dev1'` > `create-version-tag --version ${GIT_COMMIT} --tag 'dev1'` Any feedback/suggestions or corrections?

sidhant.bhayana.15
2021-03-29 18:34
has joined #general

matt.fellows
2021-03-29 21:55
:wave: The team will be on air in 5 mins

matt.fellows
2021-03-29 22:06
You can also join the #pactflow-ama channel if you want to chat there

matt.fellows
2021-03-29 23:55
Hi Sushil!

matt.fellows
2021-03-29 23:56
Yes, App-1 is the provider (sometimes referred to as the message _producer)_ and App-2 is the message consumer.

matt.fellows
2021-03-29 23:56
> I also understand control testing only looks at the messages only and doens?t care about the transport protocol here its IBM MQ. :white_check_mark: yep!

matt.fellows
2021-03-29 23:57
> In above example, if i want to implement contract testing, >  - Doesn?t both the application should be involved ? Or only the application which want to use contract testing should implement on it?s own? both sides need to be involved. The consumer generates the contract, containing its expectations. The provider must be able to produce the correct message

matt.fellows
2021-03-29 23:59
Quick animation of how contract testing works in general

matt.fellows
2021-03-29 23:59
How message pact works:

matt.fellows
2021-03-30 00:06
> - what should be the sequence of steps implementing contract testing? like how the provider should write the message, >    how exactly Pact standalone executables should be used ? This is where the consulting piece might come in, it?s not something I can answer quickly here I?m afraid!

matt.fellows
2021-03-30 01:29
:movie_camera: I?ve recently recorded a few talks for virtual conferences, and as part of those recordings, I?ve extracted a few sections to make an introductory series to contract testing - you can see the playlist here: https://youtube.com/playlist?list=PLwy9Bnco-IpfZ72VQ7hce8GicVZs7nm0i Really keen for feedback. If these sorts of things are useful, we?ll record more of them and make them a focus.

aniket.g2185
2021-03-30 05:07
Hey all, I have 2 questions regarding PACT 2.0 using PactFlow ? Are there any tools apart from `dredd` to test provider contracts against Swagger 2.0 or OAS ? Specifically looking for `golang` ? Is there any documentation around how PactFlow actually compares the `pact` generated by consumers and the results from provider test in pactfow ?


bethskurrie
2021-03-30 05:09
We're currently using the Atlassian pact swagger validator to do the pact/oas validation, but will probably migrate to something else when we have proven the concept.


bethskurrie
2021-03-30 05:11
There are some gotchas around additionalProperties which @matt.fellows might have some notes on somewhere

matt.fellows
2021-03-30 05:13
Basically, for now, set them to `false` on any response bodies


matt.fellows
2021-03-30 05:15
For tools, i?d look at https://openapi.tools/

aniket.g2185
2021-03-30 05:26
Thanks @bethskurrie and @matt.fellows, very helpful info

aniket.g2185
2021-03-30 05:29
One question, please let me know if this scenario can be easily tested with Pact 2.0 API behaves differently and gives back different responses depending on the user in the request. The fields in response would vary as per the user status 1. User application is in approved state 2. rejected state 3. in review state Is it possible to define these 3 states for same endpoint in OAS ?

aniket.g2185
2021-03-30 05:42
In Pact 1.0 I can write 3 diff interactions for this to make sure I test all 3 use cases

bethskurrie
2021-03-30 05:43
That is an excellent question

bethskurrie
2021-03-30 05:43
And it gets to the heart of what is different about pact (classic) and pact/oas verifications.

bethskurrie
2021-03-30 05:44
I believe you can define the three different response bodies in the OAS (I'm not an OAS expert) however, there is no way to define provider state or link a specific request to a specific response.

bethskurrie
2021-03-30 05:45
This is what you miss out on when you start comparing static schemas instead of verifying using behavioural tests.

aniket.g2185
2021-03-30 05:45
what I understand is you can define only one response per http code, i.e. for 200 I can define only 1 response

aniket.g2185
2021-03-30 05:46
Although I am still understanding and exploring the whole OAS

bethskurrie
2021-03-30 05:46
I'm not sure about that - I had a feeling in v3 there was an "A or B or C" kind of feature.

bethskurrie
2021-03-30 05:46
@tjones might be able to tell us.


tjones
2021-03-30 05:46
I'll read up, just a moment

tjones
2021-03-30 05:48
ok, with OAS (which is not pact), you can define different response bodies, yes

tjones
2021-03-30 05:48
what you can't do is say "for this request in this state, I expect this response"

tjones
2021-03-30 05:48
which is where Pact comes in

tjones
2021-03-30 05:49
This is one of the reasons I don't think it's appropriate to call an OAS a "contract"

aniket.g2185
2021-03-30 05:49
Can we define multiple responses for the same status code say 200 in OAS ?

tjones
2021-03-30 05:49
When you say Pact 2.0, what do you mean? Most implementations of pact have supported pact spec v2 for a long time


aniket.g2185
2021-03-30 05:50
Sorry I used wrong terminology, I meant bi-directional contracts

tjones
2021-03-30 05:50
You would define the response as one of the three types

tjones
2021-03-30 05:50
bi-directional contracts?

aniket.g2185
2021-03-30 05:51
I mean when I said PACT 2.0 I actually meant bi-directional contracts implementation using pactflow


bethskurrie
2021-03-30 05:51
Tim, that's what we're now calling provider driven contracts - because provider driven contracts wasn't a good name.

tjones
2021-03-30 05:51
This describes how to do exactly what you are asking for with OAS

tjones
2021-03-30 05:52
Ah right, ok.

aniket.g2185
2021-03-30 05:53
Oh so you are suggesting use of `anyOf` and then provide 3 responses ?

tjones
2021-03-30 05:53
That's how you do it in OAS, yes

tjones
2021-03-30 05:53
Remember that an OAS is not a contract

aniket.g2185
2021-03-30 05:53
yeah

aniket.g2185
2021-03-30 05:53
thats where I feel bi-directional contracts fall back to just schema validation

tjones
2021-03-30 05:53
So if you're doing contract "validation" against a spec, then you lose the ability to check the case you're asking about


tjones
2021-03-30 05:54
It's nowhere near as strong as an actual contract test, and in my opinion, only useful in the extreme case where you cannot do consumer driven tests

tjones
2021-03-30 05:56
There are some subtle gotchas with trying to validate your contract against the spec

tjones
2021-03-30 05:56
as matt said above, it's important to be careful with how exactly you are writing your OAS

aniket.g2185
2021-03-30 05:56
> It's nowhere near as strong as an actual contract test true

tjones
2021-03-30 05:56
OAS by default allows fields that you don't descibe

bethskurrie
2021-03-30 05:57
> thats where I feel bi-directional contracts fall back to just schema validation Yup, bi-directional contracts is just schema validation.

tjones
2021-03-30 05:57
which means if your contract says "I require a response with field `X`", but the spec doesn't describe that field, the test will pass

tjones
2021-03-30 05:57
because it would still be schema compliant (by default) to add extra fields

tjones
2021-03-30 05:58
> Yup, bi-directional contracts is just schema validation. I think "schema validation" would be a name worth considering

aniket.g2185
2021-03-30 05:59
thanks all, that kind of clears lot of my doubts

tjones
2021-03-30 06:01
I don't work for pactflow, so I don't have direct input on the feature, but I'm still in favour of adding a "maybe" result to `can-i-deploy`, because I think a schema validation is useful, but not the same as a full pact test/verification cycle.

tjones
2021-03-30 06:01
All testing is risk reduction

bethskurrie
2021-03-30 06:01
Thanks Tim :stuck_out_tongue:

bethskurrie
2021-03-30 06:02
When computers support a "maybe" boolean, it might make it easier :stuck_out_tongue:

tjones
2021-03-30 06:02
it's never necessary to test anything. But it does substantially reduce the risk. And I think schema validation reduces the risk less

tjones
2021-03-30 06:02
(and including it as the same level as a contract validation increases the risk of mistaken deployments)

matt.fellows
2021-03-30 11:04
Sorry to be late to the party here

matt.fellows
2021-03-30 11:05
There is a current limitation in the atlassian tool, that prevents this contract from being used: ```openapi: 3.0.1 info: title: Product API description: Pactflow Product API demo version: 1.0.0 paths: /product/{id}: get: summary: Find product by ID description: Returns a single product operationId: getProductByID parameters: - name: id in: path description: ID of product to get schema: type: string required: true example: "10" responses: "200": description: successful operation content: "application/json": schema: oneOf: - $ref: '#/components/schemas/Product' - $ref: '#/components/schemas/Cat' examples: application/json: value: id: "1234" name: "some product" type: "food" price: 42 components: schemas: Product: type: object required: - id - name - price additionalProperties: false properties: id: type: string type: type: string name: type: string version: type: string price: type: number Cat: type: object required: - name - owner additionalProperties: false properties: name: type: string owner: type: string```

matt.fellows
2021-03-30 11:05
That is to say, a `GET /product/{id}` should be able to return a `Product` or a `Cat`

matt.fellows
2021-03-30 11:06
If you set `additionalProperties` to `false`, but expect either a valid Cat or Product, the verification will fail

matt.fellows
2021-03-30 11:06
if you _don?t_ specify `additionalProperties` at all (or set it to true) it will allow *any body* (and therefore is useless)

matt.fellows
2021-03-30 11:07
This is, fair to say, not an ideal situation to be in

matt.fellows
2021-03-30 11:13
I?m skeptical that this behaviour can?t be fixed, however, because other validation tools explicitly allow that scenario. Otherwise, it would be useless! Within a schema, the challenges of the `additionalProperties` makes sense. But when you?re selecting between schemas, it seems strange that it ?bubbles back up? to the `anyOf` operator. This being said, the Atlassian folks are clever, and this statement from the issue certainly should give us all pause: > I suggest you try and come up with the rules in detail to define what ?not explicitly described in the swagger? means, especially in relation to the additionalProperties and allOf keywords. I think going through that exercise will help you see the hidden complexity behind this feature request. At the very least, I?d like for some of these specific scenarios to be explictly supported in our version of the tool in the end game. Right now, we?re in the ?is this new bi-directional contracts approach something we should invest more in? (as in, look past the current OAS specific issues we?re discussing and assume they get solved - does this workflow and approach make it easier to get started, understand and adopt contract testing??

matt.fellows
2021-03-30 12:46
OK, so I had a shower and was thinking about this. I then thought ?how hard could it be test pact file interactions (examples only) against a third party OAS validator ??


matt.fellows
2021-03-30 12:47
It worked pretty nicely

matt.fellows
2021-03-30 12:49
the main issue, however, is that it?s entirely plausible that the pact example may only use a subset of the response schema of the OAS. At the moment, if that subset doesn?t include _all required_ parameters on the response body, it shouldn?t fail the schema validation. But of course it does, because JSON schema doesn?t know about Postel?s law and that the consumer doesn?t need all the values. This is probably where Atlassian have to do custom JSON schema magic, because it gets complicated when the response schema is anything more than a basic set of parameters (e.g. any use of anyOf, allOf etc.)

matt.fellows
2021-03-30 12:51
It seems like a trivial problem now, but I suspect it may lead to the issues discussed above

aniket.g2185
2021-03-30 13:14
Shower is the best time to think about solutions :smiley:

aniket.g2185
2021-03-30 13:15
.

crhawkins85
2021-03-30 21:02
has joined #general

jarmy
2021-03-30 22:04
Nice job, this provides a nice holistic view into pact. One nit: The playlist ordering is off. Part 3 is in the 2nd spot, part 2 in the 4th.

matt.fellows
2021-03-30 22:07
Thanks! I think a colleague mislabeled them. They appear in the right order, so I'll get that fixed this morning!

matt.fellows
2021-03-30 22:08
Fixed :+1:

pranav.gore
2021-03-31 01:58
has joined #general

pranav.gore
2021-03-31 02:00
Hi All, my provider uses a bunch of services. So, when I run the provider side contract test step: 1. Do I need to spin-up all the dependencies for the provider? 2. How can I set state in dependent services for me to get the right response?


sushilvc84
2021-03-31 02:10
understand, I have call today. Will put consulting topic on the table and see what is being decided. Thanks

anchit.99
2021-03-31 10:56
Hi All! I have been going through the comparisons made with Spring CC over here: https://docs.pact.io/getting_started/comparisons I think there's an important point of difference that's not mentioned over here. Could someone please validate whether this is correct? In SCC, the workflow begins with the provider processing the Contract as part of their build. This generates a stub which is picked up by consumer. In other words, for every release the consumer must wait for the first provider-build generation in order to access those stubs. Contrast this with Pact in which the consumer maintains the mock server code directly. The benefit of this is that whenever a change is needed they can update that code immediately and run their tests against it. The advantage of this is even more prominent when we're consuming from multiple providers (say 4). If there are expected changes from each of them then in order to execute our tests we must wait for all 4 providers to generate their stubs. This can cause a certain amount of waiting time. Does this make sense?

matt.fellows
2021-03-31 11:04
Yeah that?s correct. Pact is a consumer-driven model

matt.fellows
2021-03-31 11:04
I believe you can do it from the consumer in SCC, but you need to write them in either Java or Groovy

matt.fellows
2021-03-31 11:04
(which may be a problem if you?re across tech)

matt.fellows
2021-03-31 11:05
Pact was designed to literally design the Provider from the consumers? perspective, even if it doesn?t yet exist

matt.fellows
2021-03-31 11:09
ok so I just spent an hour mucking about with that spike. I?ve found a way to strip off the `required` from the schemas when verifying the response bodies against the pact expectations. This allows a pact author to only use a subset of the provider response, even if the JSON schema (which is about enforcing provider behaviour) says otherwise

matt.fellows
2021-03-31 11:09
This still requires `additionalProperties` to be set to false, but does allow for dynamic response payloads

matt.fellows
2021-03-31 11:10
It was suggested to us that we should check for `additionalProperties` on the OAS files uploaded to us. If not specified (i.e. the default, which is `true`) we should reject it. That means OAS files _must_ have it explictly set.

2021-03-31 11:13
A new post has been created in *Feature Requests*

anchit.99
2021-03-31 11:13
@matt.fellows Thanks for confirming!

harsha6988
2021-03-31 12:19
has joined #general

anchit.99
2021-03-31 12:27
@matt.fellows I'm seeing another difference between Pact & Spring. Pact supports "provider states". There seems to be no such feature in Spring (https://stackoverflow.com/questions/64909381/spring-cloud-contracts-use-of-provider-state ) I'm mentioning it here in case this is something that you might want to add to the comparison page.

anchit.99
2021-03-31 14:30
@matt.fellows I'm also noticing another point of difference. The Pact library allows writing consumer tests in several languages. The SCC contract seems to be limited based upon their SCC Stub Runner which only supports JUnit and Spock tests (which limits the languages to Java / Groovy). This seems to be a big difference.

anchit.99
2021-03-31 14:31
Added another point of difference.

leixu
2021-03-31 14:42
has joined #general

phil.endsley
2021-03-31 15:08
> The SCC contract seems to be limited based upon their SCC Stub Runner which only supports JUnit and Spock tests (which limits the languages to Java / Groovy). This seems to be a big difference. While I do think Pact is much more user friendly to work with in this regard, SCC does support other languages. You just have to do some additional steps to get it all working. Here's a blog post about it: https://spring.io/blog/2018/02/13/spring-cloud-contract-in-a-polyglot-world

matthew.brown
2021-03-31 15:15
has joined #general

oleksandr.tryshchenko
2021-03-31 19:54
has joined #general

abubics
2021-04-01 04:12
Btw, I would avoid calling "Spring Cloud Contracts" just "Spring". Spring is a web framework that's been around for a long time, Cloud Contracts is a contract-testing facility added more recently.

anchit.99
2021-04-01 06:51
@abubics Agreed. "Spring" doesn't refer to the Cloud Contracts. My bad. I had been abbreviating it to SCC or "Spring CC" and I guess I missed the CC part in the previous message.

abubics
2021-04-01 10:26
All g, no stress

2021-04-01 12:43
A new post has been created in *Feature Requests*

phelantomas
2021-04-01 13:13
has joined #general

leixu
2021-04-01 15:20
hello everyone!

ktogias
2021-04-01 20:04
has joined #general

ktogias
2021-04-01 20:26
Hello. I try to verify my provider with PACT-PHP, but verifier does not seem to take into account the match type (like and eachLike)  matchingRules. Test will succeed only when the actual pact response body is returned. When I change a value eg. 'id': 345 instead of 'id': 123 the provider test fails, although pact file has matchingRules like ```"$.body[*].id": { "match": "type" }``` Am I missing something? Shouldn't the verifier check only for the type of the responce objects?

ktogias
2021-04-01 20:31
My PACT as shown in pact borker HAL Browser is this: https://pastebin.com/05LvhW00

ktogias
2021-04-01 20:32
A provider returning the same objects with different numeric ids fail to validate it with pact php. If all values are exactly the same it validates.

balaji.sivakumar
2021-04-02 05:41
has joined #general

matt.fellows
2021-04-02 22:21
Tried answering in #pact-php

uryadov212
2021-04-05 20:52
has joined #general

soumya.aithal966
2021-04-05 22:45
has joined #general

sheyan.rizfee
2021-04-06 00:55
has joined #general

2021-04-06 04:24
A post in *Feature Requests* has been marked as *in progress*

abubics
2021-04-06 06:11
Just found out that there's a "turing-incomplete contract testing language" called Pact, from Kadena (which is some blockchain tool) . . . just when you thought the keyword search soup couldn't get any murkier :grimacing:

matt.fellows
2021-04-06 06:11
Yep

matt.fellows
2021-04-06 06:11
I've reached out several times telling them it's a bad idea

matt.fellows
2021-04-06 06:11
But nobody has ever responded

matt.fellows
2021-04-06 06:12
I mean seriously, you'd think at least one person wouldn't have googled "pact" and "contract" to see what showed up

abubics
2021-04-06 06:13
Thankfully, they don't seem to maintain anything . . . http://pact.kadena.io gets a 504, and http://pactlang.org has certificate issues

matt.fellows
2021-04-06 06:13
It might be dead now

piotr
2021-04-06 09:24
has joined #general

dmitry.korolev
2021-04-06 11:47
has joined #general

anastasiia.bielik
2021-04-06 12:43
Hello there :wave:, I have a question about pre-verified behaviour. I figured out that the contract is pre-verified for the different provider versions https://share.getcloudapp.com/OAuPL5wj Is it an issue? The broker version is `2.79.1`

abubics
2021-04-06 13:41
If the contract is equivalent (effectively identical) to a previously verified contract, anything associated with it is already proven to be verified :) this is a time-saving optimisation.

abubics
2021-04-06 13:41
Are you seeing something that should be broken? :thinking_face:

antonello
2021-04-06 14:54
@abubics That would be true if: ? consumer changes (new consumer version) ? content of the pact does not change ? provider version hasn?t changed If the provider version changes, there is no way of knowing that the pact is pre-verified.

anastasiia.bielik
2021-04-06 15:42
yeah, my point is that we don?t know if the pact is verified for the updated provider

sravyavadrevu988
2021-04-06 20:40
has joined #general

johnnycareer
2021-04-06 21:34
has joined #general

abubics
2021-04-07 00:51
Yarr, if a provider has changed (in which case it should definitely have a new version number), it can't be pre-verified, but if the contract is the same, the consumer will be pre-verified.

abubics
2021-04-07 00:51
Is that screenshot showing that the provider which was updated 2 hours ago was preverified 3+ hours ago?

abubics
2021-04-07 00:52
(it's a bit hard to tell without the column headers)

anastasiia.bielik
2021-04-07 01:30
Yeap, the consumer (which was not changed) is on the left and the provider (which was changed) on the right https://share.getcloudapp.com/QwuE7jNE

abubics
2021-04-07 01:49
That reads to me like the consumer was updated recently (about 2 hours ago) and pre-verified. Am I missing something?

anastasiia.bielik
2021-04-07 02:49
@abubics oh, that could be the case:thumbsup: I was thinking that the provider with the same version is pre-verified which is wrong. I checked and you are right, the consumer is pre-verified, because it uses the same contract as the previous one, thanks for the explanation!

abubics
2021-04-07 03:34
No problem ^^ if you have any ideas about how it could be clearer (either in the UI or the docs), feel free to start conversations about it!

antonello
2021-04-07 08:42
All makes sense now!

danil.nurgaliev
2021-04-07 12:26
has joined #general

gtsifrikas
2021-04-08 08:53
has joined #general

kanapuramamarnath
2021-04-08 09:18
has joined #general

rodrigo.costa20
2021-04-08 21:05
Hey guys! I'm using pact and I'm on a test where my provider when he performs the request, it has to get data from a 3rd party api... so a way that I found to mock this 3rd party api on provider-side was using wiremock... but I'd like to know... is using wiremock on pact to cases like this a bad practice?

aniket.g2185
2021-04-09 10:40
Is the method calling the downstream API has any business logic? If its just a client wrapper why not mock that method itself rather than downstream API ?

anandhadeepak
2021-04-09 10:57
no, it is the recommended practice. but we have ensure mock replicate the actual behavior. https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0

arnaud.dutrillaux
2021-04-09 10:59
has joined #general

anandhadeepak
2021-04-09 11:09
Hi, a same api being used in two different context, would respond with different values in the response (though the fields and format of the response is same.) Should we cover this as two different interaction and test? if yes, is it not like testing the business functionality?

anandhadeepak
2021-04-09 12:54
This will have implication in the following case too... we are using contract test for backward compatibility validation of our mobile app. If there is a change in api, where only the value of the response have changed. And if the change work for current version of the consumer, but not with the older version. This is will break the backward compatibility of the provider with the older version of mobile app. How will we be able to catch this, if we only consider the structure of the response as part of the contract tests?

tjones
2021-04-09 14:06
I would probably mock in the code if you can, rather than mock the dependency API

2021-04-09 14:07
A new post has been created in *Feature Requests*

tjones
2021-04-09 14:07
if you can mock in the code, you can describe the mock in business rules (eg, `getSomething` returns an instance of `Something`), which is simpler and cleaner than using a mock API

tjones
2021-04-09 14:08
mocking in the code is option 1 in that link

gsinghania
2021-04-09 15:40
has joined #general

souravmohanty35
2021-04-09 16:34
has joined #general

itzdavey
2021-04-09 17:23
has joined #general

itzdavey
2021-04-09 17:39
Hi all! Trying to figure out whether pact is what I'm looking for. I have a backend running in Django Rest Framework, frontend running in react. I want to get us towards CI/CD, but as they run in separate repositories, how do I set up my pipeline? A change to the backend triggers the backend tests, a change to the frontend triggers the frontend tests. As of now we have no E2E tests. (and I'd love to avoid them!) But what about a frontend change that breaks the backend, or vice versa? Such a change would pass it's respective pipeline, right? So I think this is where pact comes in? But it could be just as well that I write a basic E2E test - but this also involves setting up a server on which to run them which introduces other complexities. Am I on the right track?

johnnycareer
2021-04-09 18:28
I believe the key is that you add the ?can-i-deploy? check (which consults the common Pact Broker) to _both_ the Consumer and Provider pipelines. So neither can advance beyond a compatible version.

itzdavey
2021-04-09 18:33
Yeah I don't quite have the mechanics of that nailed down yet but... Something will run on the front end, and leave some json artifacts (Where?) for the backend When backend pipeline runs it will pick up that artifact and use it as test data. (in my case for pytest). Now the pipelines are still configured separately - so I'm not sure whether somehow, the first pipeline should trigger the second.

itzdavey
2021-04-09 18:34
currently using github actions for a very basic set of unit tests in DRF, but we have AWS codepipeline, which can run a different stage of tests

johnnycareer
2021-04-09 19:04
If you use a Pact Broker, it is supposed to take care of the generated (versioned) ?pact? artifacts internally. I believe that is the Broker?s main purpose. Triggering one pipeline off another is a choice you need to make in your context. I imagine that is a more advanced setup. Web hooks apparently help with triggering.

johnnycareer
2021-04-09 19:06
FYI? I have not actually done any of this stuff? just been reading a lot about Pact recently. So it would be good if someone else were to jump in and clarify with actual experience.

itzdavey
2021-04-09 19:17
Yeah this is going to take a bit of doing. :smile:

itzdavey
2021-04-09 19:18
I'm just trying to see if I've got the big picture here.

johnnycareer
2021-04-09 20:47
For big picture, I found this new video playlist very helpful: https://www.youtube.com/playlist?list=PLwy9Bnco-IpfZ72VQ7hce8GicVZs7nm0i

tjones
2021-04-10 06:12
Right, so pact helps you detect breaking changes

tjones
2021-04-10 06:13
In the front end, you write your contract expectations for the backend, and you run a pact test that determines whether your front end will behave correctly if the backend behaves as you have defined in the pact test. This doesn't involve the backend.


tjones
2021-04-10 06:14
At this point, Pact is everything in blue.

tjones
2021-04-10 06:14
Then, if the tests were successful, you publish the Pact (the contract) to the Pact Broker.

tjones
2021-04-10 06:15
The contract says "These are expected request and response pairings that I know the front end can send and receive"

tjones
2021-04-10 06:16
At this point, you would ideally kick off a back end test that will verify the contract

tjones
2021-04-10 06:17
At this point, pact will replay the requests that we know the front end can make against the real provider, and see if the real provider generates the responses you expect

tjones
2021-04-10 06:18
To expand your example: * A change to the front end triggers the front end tests. These might write a new contract. * A change to the back end triggers the back end tests. These will verify any existing contracts. * A change to the contract also triggers the back end tests. These will verify any existing contracts.

tjones
2021-04-10 06:20
> But what about a frontend change that breaks the backend There are two scenarios: 1) The front end no longer matches the defined expectations in the pact tests. This means the pact tests will fail, and a contract won't be generated. 2) The front end implementation and expectations have changed, and they no longer match the implementation of the provider. The pact tests will pass, and a new contract will be generated. This contact won't pass verification, which will let the provider team know they need to update.

tjones
2021-04-10 06:23
> what about a backend change that breaks the frontend? The contract verification will fail in the backend (provider) tests. Pact is consumer-driven ("servers exist to serve"), so we treat the frontend consumer's expectations as the goal. Practically, however, you might want to update the frontends expectations. Pact won't stop you needing to communicate between teams, but it will help you know exactly what has changed and where.

tjones
2021-04-10 06:25
> Such a change would pass it's respective pipeline, right? Not exactly. For the frontend, it depends. For the backend a breaking change won't pass contract verification. There are mechanisms for nicely breaking changes - eg pending pacts, where you say "this is a new feature - it won't break the build until it has passed verification at least once". Pact encourages you to make backwards-compatible breaking changes.

tjones
2021-04-10 06:26
(as in, having a version of either the consumer or the provider that can understand both versions of the protocol)

tjones
2021-04-10 06:27
> But it could be just as well that I write a basic E2E test For me, pact is the e2e test killer. It obviates the need to do heavy e2e tests (although light touch e2e tests are still valuable). Pact answers the question "can these two services talk to each other"

tjones
2021-04-10 06:28
The real magic comes in `can-i-deploy`, which answers the question "can this service communicate with the other services currently in <environment>?"

tjones
2021-04-10 06:28
it lets you gate deployments until they wouldn't be breaking


tjones
2021-04-10 06:30
Pact will give you the value from the e2e test that I think you're implying - but for much much cheaper

tjones
2021-04-10 06:30
It seems complicated at first, but I promise it's actually fairly simple once you've got a handle on it

tjones
2021-04-10 06:31
> how do I set up my pipeline? See this: https://docs.pact.io/pact_nirvana

tjones
2021-04-10 06:33
> Am I on the right track? Yes, mostly :slightly_smiling_face:

itzdavey
2021-04-10 11:33
@tjones you are (literally in this context) the man. Thank you so very much. I'm going to stash your replies away some where. This is gonna sound weird but when I was asking about this type of testing in other slack forums people were acting like I was *crazy*.

itzdavey
2021-04-10 11:33
But I keep seeing all the potential problems with E2E tests, mitigated by only how easy they are to set up (and yet, in some ways, they are not).

matt.fellows
2021-04-10 11:38
May I ask what forums you were asking in?

matt.fellows
2021-04-10 11:38
I'd like to join them if possible to better understand this perspective

matt.fellows
2021-04-10 11:39
As for e2e tests, you might like to read this article by Elliot on the maths behind scaling e2e vs contract tests: https://pactflow.io/blog/proving-e2e-tests-are-a-scam/

itzdavey
2021-04-10 11:43
@matt.fellows Mostly the ministry of test slack is where I hang out. I have asked similar questions in the pythondev slack. I'm exaggerating a little. Pact came up in the discussion, but only from one person who spoke up. I think it took awhile to explain what/why I wanted to test, and there was more of an attitude of "oh if that's what you want then there's this pact thing, but it's probably easier to write an E2E test."

matt.fellows
2021-04-10 11:44
Ah! I need to go back there, thanks for the reminder. It's a good forum

matt.fellows
2021-04-10 11:47
In the playlist that Johnny shared above, there is a video that talks about the replacing e2e part of the story

itzdavey
2021-04-10 11:47
I think a lack of known use cases might be an example. Not enough examples/tutorials floating around out there.

itzdavey
2021-04-10 11:47
cool

abubics
2021-04-12 00:26
Sounds like you're making a breaking business-logic change, not a detectable contract change (it's just a string?) Or is that field an enum value?

matt.fellows
2021-04-12 01:42
I put an answer on SO but we can probably have a more detailed conversation here

matt.fellows
2021-04-12 01:42
I assumed it was an enum also Andras

matt.fellows
2021-04-12 01:42
I also assume it was a theoretical question, but maybe not

abubics
2021-04-12 01:53
lol, got halfway through typing this, then had to run off to meetings :sweat_smile: > Either way, I'd recommend not using the same field for a slightly different purpose (that's the undetectable bit). Usually better the add new field for the new usage, and then remove it later once you know clients (consumers) aren't using it anymore.

anandhadeepak
2021-04-12 05:23
thanks @matt195 . Yes it was an abstracts question, we were validating our coverage and that is when we came up this category of scenarios.

anandhadeepak
2021-04-12 05:26
thanks @abubics . It is a very valid point that you have made, a field should not broadly be used for posting any value. At every point we should use more specific fields and values.


phillip.lo
2021-04-12 21:48
Hi! Just a general question here. Is the thought to always run the pact tests as part of the unit testing cycle even for local development? We were thinking to only run the pact verifications on either PRs or just as part of the CICD process but not necessarily locally unless the dev manually asks for them. The reason being that they would require a connection to the broker if we ran pact tests every time with unit tests and if it was unavailable for whatever reason or they were not connected to the network, they'd need to skip the tests manually.

matt.fellows
2021-04-12 22:30
It depends when you want to catch the problems

matt.fellows
2021-04-12 22:30
Ideally, you catch them on your development machine

matt.fellows
2021-04-12 22:31
is the concern that network connectivity is not always there for developers? Or is your broker actually unreliable?

abubics
2021-04-12 23:59
On the consumer side, you don't need any network to run the Pact tests, I would absolutely recommend keeping them in unit tests for local dev :)

abubics
2021-04-13 00:02
On the provider side, you need to source the contract file(s) from somewhere . . . if you know you're not going to have connectivity, you can download them in advance. That's trickier though.

phillip.lo
2021-04-13 00:15
Yea. More of not wanting to tie local dev to basically require connection to the broker

phillip.lo
2021-04-13 00:15
Which is say only accessible through vpn etc

phillip.lo
2021-04-13 00:16
I saw the annotation to ignore if pacts are unavailable but I wonder if there is a way to only enable during local dev but fail during CI builds for example

tjones
2021-04-13 01:43
I would do that config outside pact- like have an OFF_VPN environment variable that skips the steps that need the VPN.

tjones
2021-04-13 01:43
Presumably you have the same issue with access to source control, etc

tjones
2021-04-13 01:44
With setups with heavy pact usage, it's helpful to have a `test:unit`, `test:pact` and `test:ci`, where the last one runs everything

phillip.lo
2021-04-13 01:45
With the jvm gradle integration is there something built in to the plug-in already or is this something we just custom do

tjones
2021-04-13 02:12
I don't know for JVM, but I would expect that you just create custom lists of tasks like you would for any tests you don't want to always run

tjones
2021-04-13 02:13
maybe have `check` depend on the pact verification, whereas `test` would just run the unit tests. From memory, the gradle standard is `check` for everything, and `test` for some things

tjones
2021-04-13 02:13
(I don't do much work in the JVM)

2021-04-13 05:25
A post in *Feature Requests* has been marked as *complete*

2021-04-13 08:41
A post in *Feature Requests* has been marked as *complete*

2021-04-13 08:44
A post in *Feature Requests* has been marked as *in progress*

2021-04-13 08:48
A post in *Feature Requests* has been marked as *open*

laura.edington
2021-04-13 17:45
has joined #general

johnnycareer
2021-04-13 20:22
Request: Can we turn off Feature Request auto-updates in this channel? They are already available in #feature-requests.

liam.mcdermott
2021-04-13 22:38
has joined #general

matt.fellows
2021-04-13 23:16
Good idea

jacek.helper
2021-04-14 06:52
Hi, could you guys help me with one of possible provider verification scenario? Scenario: New customer require new feature from provider 1. Lets say I have new customer, which need to use existing provider 2. This new customer require new feature from provider, so both need to be deploy at some point 3. My provider in his CI integration verify pacts not just for main line, but also for all my environments 4. When added new feature to provider merge to the main line, my verification failed because provider was not able to find pacts (pact-net failed) with suitable environment tags - customer has not been deploy yet I am not entire sure what would be the best practices in such case. My thoughts are: 1. In theory I can change my code in provider verification to verify only main line for this brand new customer. But this a bit problematic since I have more then two environments and may need to change a code after each deploy. 2. In provider CI i should just fail with main line verification, do all others but handle them just with some info (not break CI), so lack of pact on given environment will not cause provider verification to failed. I don't like this option as well, since I cannot distinguish between lack of pact for given environment and failed verification at least in pact-net client 3. If there is no any other option, what would you say if pact cli or any other pact client could clearly distinguish scenario like missing pact for given environment from failed verification? thanks, JM.

tjones
2021-04-14 06:53
What do you mean?

tjones
2021-04-14 06:53
Oh, sorry, I misread. The answer is yes, we can help. What's your scenario?

jacek.helper
2021-04-14 07:12
Sorry, just press enter too early - dummy me :slightly_smiling_face:. Edit my previous message with scenario details

abubics
2021-04-14 07:41
A few questions/concerns . . . ? Have you read up about pending and WIP pacts? That may solve part of the problem. ? Are your "customers" publishing pact files to your broker? The way you describe "finding pacts" seems like either you have a novel setup, or maybe the vocabulary isn't too familiar :slightly_smiling_face: ? What kind of relationship mapping is there between your consumers and providers? If the consumer teams are external, that may not be a problem, but still check https://docs.pact.io/getting_started/what_is_pact_good_for/.

jacek.helper
2021-04-14 09:13
Hi, thanks for quick response. 1. I think I am quite familiar with pending pact concept and it will helps if I will have a problem with failing verification rather than missing pact for an given environment tag. 2. Yes, I am using PactBroker on premise. Not sure what part was not clear, but maybe that one with provider verification. Lets try to put it in different way: In provider CI integration I am verifying multiple pact versions: for main line and for TEST, QA, PROD. Now with brand new customer only main line have a pacts, so when I try to use provider for a new consumer in the same way like for all other, pact-net client verification failed due to missing pacts for TEST, QA, PROD. Hope it a bit clear now. 3. I am quite familiar with consumer driven contract concept too and I think I fully understand why they are not a good option for public API. That is not my case, all collaborators are under my company control. cheers, JM.

wedlaaa
2021-04-14 13:33
has joined #general

bheemreddy181
2021-04-14 19:13
Have anyone worked with prism ? What are advantages or disadvantages you see with prism over pact ?

wderksen
2021-04-14 22:26
has joined #general

abubics
2021-04-15 02:12
> all collaborators are under my company control This info helps :slightly_smiling_face: I'm still not sure about the customer relationship, but maybe it doesn't matter? > pact-net client verification failed due to missing pacts for TEST, QA, PROD I'm not too sure what this means, but if it's a discrepancy between pact-net and other implementations, you should get better help in #pact-net. If you have a new consumer that only expects some functionality, it shouldn't cause problems. How are you initiating the verification? (Might need to see your actual usage, rather than just abstract explanations) If you're verifying against all envs, how do you test new interactions that aren't ready to be promoted? E.g. if you have a new feature in TEST, but not yet in PROD, wouldn't all your verifications break?

mail_4brad
2021-04-15 02:34
has joined #general

abubics
2021-04-15 03:58
Looks like a mock server, driven by OpenAPI (Swagger) specs, with additional validation. So, same issues that specs have (OpenAPI or otherwise), especially that they don't describe what situations certain kinds of responses are valid in, or what combination of fields is valid.

abubics
2021-04-15 03:58
They're not trying to solve the same problems :slightly_smiling_face:

tjones
2021-04-15 04:14
Good follow up questions! Taco for @abubics :taco: !

jacek.helper
2021-04-15 07:06
Hmm, I don't think we fully understand each other. I have describe this non-abstract example to avoid technical implementation details. Saying that I can provide that, just do not see how it can helps. From my point, there is a difference between brand new customer and a new pact version for existing customer. One more time, my problem isn't that my verification failed, because it is not ready. My problem is that brand new customer has not been deployed yet, so provider cannot retrieved pacts for all environments in its main CI flow, which cause exception in library pact-net, which I am using. >

tjones
2021-04-15 08:00
How are you labelling the pacts for all environments? Typically this is done with a tag, which will be fine because the provider simply won't retrieve pacts without the `prod` tag (or whatever the tag is)

jacek.helper
2021-04-15 08:19
Sorry unexpected meeting. Going back to @abubics questions. I don't think we fully understand each other. I have describe this non-abstract example to avoid technical implementation details.  Saying that I can provide that, just do not see how it can helps. From my point, there is a difference between brand new customer and a new pact version for existing customer.  One more time, my problem isn't  that my verification failed, because it is not ready. My problem is that brand new customer has not been deployed yet, so provider cannot retrieved pacts for all environments in its main CI flow, which cause exception in library pact-net, which I am using. If it is still not clear can I ask you if you have a chance to handle scenario like my, where a brand new customer would like use a provider but also require additional feature do be develop. So they both at some point need to be deploy to all environments. Try to answer some questions: > This info helps :slightly_smiling_face: I'm still not sure about the customer relationship, but maybe it doesn't matter? My bad wording, in this case I should write consumer not customer. Sorry I always mix that two. > I'm not too sure what this means, but if it's a discrepancy between pact-net and other implementations, you should get better help in #pact-net. The only reason, which why I have mention about pact-net client is that, maybe this behavior (throwing error when pact do not exist for given env tag) is only specific to it. > If you're verifying against all envs, how do you test new interactions that aren't ready to be promoted? E.g. if you have a new feature in TEST, but not yet in PROD, wouldn't all your verifications break? If new pact version will be created by already integrated consumer (Scenario: Existing consumer raise query for provider feature e.g. new endpoint) my verification will be fine, since one more time this consumer has already been deployed to PROD and I tagged it in PactBroker. If it is brand new customer, and do not have a chance to be deployed yet to PROD (my original scenario) , my code will unfriendly failed because library will not be able to find latest pact for consumer on PROD.

jacek.helper
2021-04-15 08:21
@tjones Good questions. After deploy to e.g. PROD I use ruby client to add a tag PROD. > the provider simply won't retrieve pacts without the `prod` tag Not sure If i got your point. If my consumer will not have a PROD tag in any version, that is my problem, my scenario. In my provider pact test code for all existing customers, I try to verified pacts not only for main line, but also for all my environments. In a code I do not know if such customer has been deployed to e.g. PROD and has been tagged with PROD label so for each customer I try to verified all environments. Is this clear?

abubics
2021-04-15 08:29
> My bad wording, in this case I should write consumer not customer. Sorry I always mix that two. All good, that clears some things up :thumbsup:

abubics
2021-04-15 08:31
It seems to me that requiring a consumer to be deployed to prod (before you can verify its contract) will cause a deadlock in your verification process. I think this is what you're experiencing.

abubics
2021-04-15 08:32
(Also, happy to bow out if @tjones?s line of questioning is easier to understand :innocent:)

abubics
2021-04-15 08:35
The workflow might be: 1. consumer describes a new feature, published via a feature branch 2. the provider verify fetches all contracts, including this new feature which fails (but may be marked as pending or WIP) 3. the provider team implements changes to fix the contract failure 4. the new provider is deployed 5. now the consumer can be deployed to all envs that the compatible provider exists in

abubics
2021-04-15 08:36
Step 2 (fetching contracts) shouldn't break anything (e.g. throwing exceptions), unless something else is screwy (e.g. pact-net works differently than other platforms, or the way you're explicitly fetching contract sets is more brittle, or something)

matt.fellows
2021-04-15 08:45
Perhaps you could share the error message you're getting?


matt.fellows
2021-04-15 08:53
If you only specify one tag, and no pacts are found, it will probably fail the build

matt.fellows
2021-04-15 08:54
But that's what consumer version selectors help solve. You usually specify multiple tags (e.g. main, test, prod), including an optional fallback tag

jacek.helper
2021-04-15 09:20
@abubics > it seems to me that requiring a consumer to be deployed to prod (before you can verify its contract) will cause a deadlock in your verification process. I think this is what you're experiencing. It is not my assumption at all. Forgot for a moment about my problem, do you understand why I want to verify some customer PROD version in provider? > Step 2 (fetching contracts) shouldn't break anything (e.g. throwing exceptions), unless something else is screwy (e.g. pact-net works differently than other platforms, or the way you're explicitly fetching contract sets is more brittle, or something Before you can verify pacts, under the hood client library will try retrieved pacts. Form my perspective it one action e.g. `verified` Now how client handle scenario when pact are missing for given env tag is a key here.

jacek.helper
2021-04-15 09:21
@matt.fellows thanks a lot. > Also FYI this might be related https://pact.canny.io/feature-requests/p/add-failifnopactsfound-flag-for-verification That is what I am talking about. With exception that my client code throw error in such case, which is the other way around compering to original github problem. But yes this is a key point to understand my scenario. In version of pact-net cleint, which I am using they are no consumer selectors, so for each env verification I have to create separate verification set up: url to PactBroker pact. Maybe that the point. If I understand you correctly if I will use selectors like this: ```var pactVerifier = new PactVerifier(new PactVerifierConfig()) .ProviderState($"providerServiceBaseUri/provider-states") .ServiceProvider("ProviderPacticipantName", "providerServiceBaseUri") .HonoursPactWith("ConsumerPacticipantName") .PactBroker( "http://pact-broker", consumerVersionSelectors: new List<VersionTagSelector> { new VersionTagSelector("master", latest: true), new VersionTagSelector("test", latest: true), new VersionTagSelector("production", latest: true) });``` When there is no production pacts, verification should still pass? If yes, solution to my scenario will be using consumer selectors.

matt.fellows
2021-04-15 10:09
Exactly!

matt.fellows
2021-04-15 10:09
You should only need one verification job

jacek.helper
2021-04-15 10:56
@matt.fellows Reading your answer I think I should ask previous question in different way. I was not asking if I should not failed. I know that in my scenario I shouldn't that why I am asking for help. My question was: If I will use consumer selectors like above one, will pact clients not failed when 'production' pacts are missing? I go through https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ and the only thing about missing pact was part related to `fallbackTag` . Maybe I have missed something, but I could not find info what happen if pact is missing for tag and there is no `fallbackTag` either. >You should only need one verification job In my CI I have one verification job but, because we are still before upgrading PactBroker I cannot use newer client version, which contain consumer selector feature. Instead I have to one by one fire verification for each tag.

jacek.helper
2021-04-15 10:58
However if this feature solve my problem I am happy with such solution and can handle my scenario lets say manually until we will not upgrade PactBroker.

matt.fellows
2021-04-15 11:15
> My question was: If I will use consumer selectors like above one, will pact clients not failed when ?production? pacts are missing? I go through https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors/ and the only thing about missing pact was part related to `fallbackTag` . Maybe I have missed something, but I could not find info what happen if pact is missing  for tag and there is no `fallbackTag` either. If there are no pacts for any of the tags (including the `fallbackTag`), then it will fail. That?s where the issue I linked above comes in (i.e. don?t fail if there are no pacts). In these cases, the simplest option is to disable the pact verification on the provider until the consumer is in place. > > In my CI I have one verification job but, because we are still before upgrading PactBroker I cannot use newer client version, which contain consumer selector feature. Instead I have to one by one fire verification for each tag. As per above, in this case, you?re just going to have to update your build when the consumer is actually in place. It?s a chicken and egg scenario, and unless you?re going to upgrade the broker then you?re stuck

matt.fellows
2021-04-15 11:16
I can?t suggest much else sorry! We?ve built the tools to address your problem, any other fix is likely to be an update to the tools - which is why you?re stuck here in the first place :wink:

matt.fellows
2021-04-15 11:16
Upgrading a broker is usually a short operation, is there a reason why you haven?t done that?

matt.fellows
2021-04-15 11:17
Consumer version selectors has been in the broker for ? I think at least 12 months. So, it?s old

matt.fellows
2021-04-15 11:18
(just checked the source, it?s about 15 months old)

matt.fellows
2021-04-15 11:19
If you?re interested, you could take a look at http://pactflow.io - we host the broker for you, so you don?t have to worry about upgrades, maintenance, patching etc.

jacek.helper
2021-04-15 11:38
@matt.fellows thanks. In terms of upgrade, I will try to speed this up, but it may take a bit longer in a enterprise where I am currently working. Year old software is not unusual thing here. Unfortunately I cannot use http://pactflow.io We have to host all software on our side :disappointed: One more time thanks for your time. Just last suggestion - maybe it will be good to add below info to pact documentation: > If there are no pacts for any of the tags (including the `fallbackTag`), then it will fail. cheers, JM.

matt.fellows
2021-04-15 11:39
Ha, I understand completely (we have an premises version too :wink:, but that won't help speed things up)

matt.fellows
2021-04-15 11:39
You're welcome, and I'll get that updated tomorrow. Thanks for the questions and feedback!

rodrigo.costa20
2021-04-15 12:08
hey guys! I'm using pact-js for a test on consumer-side and the test works well... however, when I try to run the tests on the CI Tool (bamboo), I keep getting this error "Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download ..." and I think this error is probably because the computer where the bamboo runs, is not able to access any external url, so I think when its try to access github, the error is presented. do you guys know what I can do to workaround it? using proxy on CI its not an option in this case

bheemreddy181
2021-04-15 12:16
Makes sense , I felt that bi-directional contract feature from pact has a similar implementation https://github.com/pactflow/example-consumer/blob/master/README-bi-directional.md

goncalosamuel
2021-04-15 15:08
has joined #general

matthew.hall
2021-04-15 17:36
has joined #general

raony
2021-04-15 19:21
has joined #general

bethskurrie
2021-04-15 23:54
Yes, there is a way to point it at a separately downloaded version of the standalone.

bethskurrie
2021-04-15 23:55
I'm not a pact-js person though, so I'm having trouble finding the right keywords in the docs @rodrigocs. Try searching on the #pact-js channel.

bethskurrie
2021-04-15 23:56
@bheemreddy181 the existing schema comparison tools that Pactflow is currently using will have the same problem, yes. That's why it's our plan to write our own OAS verifier that can capture more information about the combinations of fields and requests/responses to make the comparison more valid.

bethskurrie
2021-04-15 23:58
> If there are no pacts for any of the tags (including the `fallbackTag`), then it will fail. @jacek.helper actually, this depends on which language you're using.

bethskurrie
2021-04-15 23:58
The Ruby impl did not fail when there were no pacts, until an option to force it to do so was added recently.

bethskurrie
2021-04-15 23:59
The JVM impl does fail by default, but you can add an annotation to make it not.

bethskurrie
2021-04-15 23:59
I don't know about Rust.


phil.endsley
2021-04-16 01:54
Started a new job a few months ago. We're about to start migrating to microservices (because who isn't these days :laughing: ) pitching pact to the team tomorrow. Hoping they see the benefits I've experienced :crossed_fingers:

bethskurrie
2021-04-16 01:54
I can't think of anyone better to help them learn about/onboard with Pact!

bethskurrie
2021-04-16 01:55
Best of luck!

matt.fellows
2021-04-16 02:30
Yeah, I feel like we actually can?t help you do the pitch.

matt.fellows
2021-04-16 02:30
Also, congrats on the new role!

bheemreddy181
2021-04-16 03:16
Do we always need a OAS verifier if we are generating the OAS documents automatically from the code itself with a set of tests ?

bheemreddy181
2021-04-16 03:17
which all cases do we need a OAS verifier all the time ?

gupta.ratnesh9
2021-04-16 04:48
has joined #general

gupta.ratnesh9
2021-04-16 04:51
I'm new to pact and I just wanted to generate pact file from open API definatation so Can we generate http://pact.io pact file from swagger definition.

gupta.ratnesh9
2021-04-16 04:52
If it is possible then kindly sent me the ref link so that I can learn

tjones
2021-04-16 04:56
No, this isn't possible. The reason is because a contract contains more information than an API spec.

tjones
2021-04-16 04:57
A spec (eg swagger) says "these are the syntactical rules that requests and responses must follow"

tjones
2021-04-16 04:57
A contract (eg Pact) says "here are request and response pairs for various server states"

tjones
2021-04-16 04:59
In this way, a spec is not a contract. So, most people who are using swagger but not Pact also pair their swagger with eg a Postman collection of request/response examples. This pairing of spec + examples is a contract. However, because there isn't a lot of standardisation in that space, there aren't any tools to convert Postman to Pact (yet!)

tjones
2021-04-16 04:59
Also note that a Pact file isn't a description of the whole API surface. It's a description of the parts of the API that your client is actually using.

tjones
2021-04-16 05:00
(for example, even if you're using all endpoints, you might not be using all fields)

tjones
2021-04-16 05:00
it's not a breaking change if you remove an endpoint that no client uses, or remove a field that no client expects.

tjones
2021-04-16 05:03
Once you have a pact file, you can potentially check it against a swagger document to make sure that the request and response pairs also pass the spec. However, this isn't a substitute for proper verification of the contract against the server, as there are some subtle but important differences (for example, by default swagger will allow you to add arbitrary fields, which means your Pact that expects fields that aren't in the spec might still pass).

tjones
2021-04-16 05:05
Let me know if the explanation above needs any clarification

abubics
2021-04-16 05:19
Very concise & pertinent bits in there :3 could almost use this as a pre-canned response (:taco: @tjones)

gupta.ratnesh9
2021-04-16 05:32
Thanks @tjones :+1:

tjones
2021-04-16 05:34
You're welcome! I had the same question when I first started learning pact.


matt.fellows
2021-04-16 05:40
I also really need to write the shorter version of this post (I shall call it ?schemas are not contracts?): https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-1/

matt.fellows
2021-04-16 05:41
Also, what Tim said

greg595au
2021-04-16 10:00
has joined #general

uladzislau_danilchyk
2021-04-16 11:33
Hi everyone! I have a question regarding filtering pacts and their verification results in Pact Broker Matrix (with old UI when filter exists). What is the difference between *`Show latest result for each consumer version/provider version`* and  *`Show latest result for each consumer version/provider`* options?

manel_ben_yahia
2021-04-16 13:59
has joined #general

jacek.helper
2021-04-17 10:16
@bethskurrie thanks. I think this behaviour is quite important and it will be good to add some examples or description to consumer selector examples for each implementation.

maxence
2021-04-17 11:07
has joined #general

kranti.deep
2021-04-17 14:17
has joined #general

aaronw153
2021-04-17 21:42
has joined #general

bheemreddy181
2021-04-19 00:32
@bethskurrie@bethskurrie@bethskurrie ^ ?

bethskurrie
2021-04-19 00:33
That's a good question.

bethskurrie
2021-04-19 00:34
I am planning to add a "auto generated" flag to the OAS publication endpoint, that will negate the need to supply the self verification results document.

bethskurrie
2021-04-19 00:35
With the initial implementation, for can-i-deploy to pass, you need to supply the results of your own verification tests (using something like dredd).

uladzislau_danilchyk
2021-04-19 07:35
Can anyone help me with that?

abubics
2021-04-19 08:29
not sure, but the way it reads to me is "1 provider version" vs "all versions of the provider" maybe?

uladzislau_danilchyk
2021-04-19 08:36
it is shown in old matrix in Pact Broker. But I can't see such filter in newest one

matt.fellows
2021-04-19 09:54
The new UI doesn't have this view yet. It's currently in design, but you can go back to the old view (button at the top)

dwmahieddine
2021-04-19 12:44
has joined #general

bheemreddy181
2021-04-19 13:34
I feel like that is an overhead for people wanted to use pact for bi-directional contracts , why not force everyone to write OAS documents from tests directly

bheemreddy181
2021-04-19 13:34
What are the cases where people have to hand write the OAS documents ?

garrettmichael
2021-04-19 18:34
has joined #general

garrettmichael
2021-04-19 18:56
Hey all, new to Pact / contract testing in general. We're assessing if it's a good fit for our microservices stack and are hung up on a particular scenario. We have two AWS Lambda functions that communicate asynchronously. The first is our 'provider' which publishes a message to an SNS topic, which is subscribed to by an SQS FIFO queue. Our 2nd lambda is the 'consumer' and is invoked by the SQS queue when it receives a message. In this case, the two functions we control have different inputs/outputs due to the baked-in SNS/SQS transformation. How would Pact work in this case - is this even appropriate for a contract test, or would the tests only care about the actual 'body' of these messages somehow? Thanks for any advice!

bethskurrie
2021-04-19 23:23
Hi @garrettmichael this newly added section will probably answer your question https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact

bethskurrie
2021-04-19 23:26
Hey broker users, when you're deploying a service to production and using no-downtime deployments which roll out the new version across your instances, how long is that time when both versions are active? Have you ever seen issues with can-i-deploy because you were midway through a deployment and the broker didn't know about the new version being in prod yet?

matt.fellows
2021-04-20 00:41
+ also an example SNS project with lambdas: https://docs.pactflow.io/docs/examples/aws/sns/consumer/readme/

matt.fellows
2021-04-20 00:41
Sounds like that might be useful :slightly_smiling_face:

abubics
2021-04-20 02:00
usually single-digit minutes, but I haven't gotten to do it recently, so I can't tell you about can-i-deploy :disappointed:

matt.fellows
2021-04-20 02:04
> why not force everyone to write OAS documents from tests directly Not all languages/frameworks have ways to auto-generate swagger files from code

bethskurrie
2021-04-20 02:04
The reason I'm asking is that the current implementation of record-deployment switches over the currently deployed version instantaneously, where as in real life, there are 2 versions running at the same time for a few minutes. I don't think it's a long enough window for it to be a problem, but I am interested to hear from people who do staged rollouts.

matt.fellows
2021-04-20 02:04
And not everyone uses them when they are available

matt.fellows
2021-04-20 02:04
and lastly, a lot of companies already have tests

matt.fellows
2021-04-20 02:04
so primarily, those reasons

matt.fellows
2021-04-20 02:04
Ideally, they are generated from code because this prevents drift

bethskurrie
2021-04-20 02:05
Some companies like to use external tools like swagger hub to author their OAS.

matt.fellows
2021-04-20 02:05
Prism helps with drift

abubics
2021-04-20 02:05
Exactly what I suspected :wink:

bethskurrie
2021-04-20 02:06
I have a plan for how I would implement a "record-deployment-started" and "record-deployment-completed", but I'm 90% sure it's not worth the effort.

bethskurrie
2021-04-20 02:07
I think I'll see how the current implementation goes, and I can add the extra logic if need be.

johnnycareer
2021-04-20 04:16
I am not an expert, but I believe there is a feature related to ?pending? versions (or something).

antonello
2021-04-20 06:35
I haven?t been following in too much detail, but have you considered recording on flipping from blue to green or viceversa rather than on the deployment itself?

bethskurrie
2021-04-20 06:35
yup

bethskurrie
2021-04-20 06:36
I mean, the record-deployment can be called at which ever time the developer wants to

bethskurrie
2021-04-20 06:36
if they want to call it at flip time, or deploy time, it's up to them.

antonello
2021-04-20 06:36
Of course, I was being 7:30-am-silly

bethskurrie
2021-04-20 06:37
I could get very vague with the terminology like "record-version-live" or something, but I think it gets less user friendly like that.

daniel.kalleward
2021-04-20 08:16
has joined #general

scott.riley111
2021-04-20 08:52
Just chiming in on this as we?re currently going through internal investigations into pact - deployments on our larger apps typically take 10-15 minutes, but can take up to 30 minutes depending on the time of the deployment (and sometimes fail and leave a cluster in an inconsistent state)

scott.riley111
2021-04-20 08:53
Only having 1 ?live? version is somewhat of a dealbreaker for us (though I understand that?s what you?re working on now :smile:)

uladzislau_danilchyk
2021-04-20 11:31
Hi everyone! How to understand when contracts will be published even if publish command has run? I know about hashing and determining if something has been changed, but I have a small example which makes me unclear.. 1. Is it clear that pact broker detecting changes in contracts just by hash of content? Or by something else? 2. Lets imagine that I created Pull request and did some changes in contract and then contracts were published. It's ok. But after that I did some changes in my codebase in that PR without changing contracts. Publish command has run but contracts didn't updated in Pact Broker. I think it's correct. 3. But I have created new branch from develop branch and did nothing. Publish command just ran in CI and new contracts are published. But content of them has not changed. How to understand it? In some cases it publishes contracts which are not changed, in some cases - not.

mattias.persson
2021-04-20 12:45
has joined #general

martin.eklund
2021-04-20 12:47
has joined #general

garrettmichael
2021-04-20 16:39
Thank you!

enda.brody
2021-04-20 17:37
has joined #general

enda.brody
2021-04-20 17:42
Hi I am new to Pact, one blocker I am hitting is dealing with API gateway my companies software is like as follows ServiceB-ServiceA- Public Gateway-Web Client I am finding it hard to find a code example that deals with this.

phil.endsley
2021-04-20 17:46
Does the API gateway do anything related to the requests between web client and serviceA? I think the typical usage here would be to ignore it and have contracts like: ServiceB <--> ServiceA ServiceA <--> Web Client


enda.brody
2021-04-20 17:55
Thank you phil for your reply the gateways don't have any logic But are expected by the clients so when we try and run the pact test for ServiceA <--> Web Client without handling the gateway than the test throughs an Error

phil.endsley
2021-04-20 18:01
> But are expected by the clients > Can you elaborate on this a little? In what way are they expected and how are the tests failing?

cristian.moisa
2021-04-20 18:25
has joined #general

brendan.j.donegan
2021-04-20 20:52
@enda.brody thanks for joining :slightly_smiling_face: I think I understand a little now. The API gateway can essentially be bypassed with Pact

brendan.j.donegan
2021-04-20 20:54
Can you elaborate as well which tests are failing? Consumer or Provider?

mail_4brad
2021-04-20 22:47
*Analogy for Pact. And a ?fit? question* Earlier today I was made aware of https://www.youtube.com/watch?v=zI0MGrwqb6w trailer fail when *The Mummy* Tom Cruise film was released for IMAX. Because I?m looking into Pact for the first time I took a look at what the trailer fail could represent as a testing analogy. It treats the interfaces and trailer as abstracts so don?t try to argue about protocols etc. Think of Bob and I as Clients of the trailer. The trailer is a media service Provider, with methods to get the audio and visual elements. Pact wouldn?t have helped the implementors of this trailer because regardless of the Client or https://docs.pact.io/assets/images/consumer-test-coverage-71ca640527716073e40be0b525340500.png used, the functional fault was the same. (The total pool of trailers is analogous to the pool of global web services.) Bob?s viewing of the trailer can be represented by the ?Bob Client Pact Contract?. He happens to prefer YouTube so YouTube is his Collaborators. The contract for Bob Client would have stated that when YouTube (Collaborator) requests the video stream then video would be returned - pass; and that when it requested the audio that audio would be returned - pass. And when I view the trailer on DVD, the DVD playback is the Collaborator. The fact that the audio lacked a musical score is a functional test failure that should have been picked up by the Provider?s own functional tests, back in Universal?s studio. We ignore what the user using YouTube or DVD sees as that?s a functional test for those Clients, not to be covered with Pact, and shouldn?t be specific to The Mummy trailer. This would only work if Universal owned YouTube and all DVD manufacturers, as the Provider team needs to be the author of the Clients also. </End analogy. Critiques welcome> <Fit question> Now assume for a moment that with each copy of the trailer, Universal shipped a DVD player, the old school ones that had a screen and built-in speakers and you could sit anywhere, put in a DVD and it would play. (https://cdn.shopify.com/s/files/1/0352/1016/6412/products/9100_2048x2048.png?v=1594195240) In this case, Bob and I have the same Collaborators. Now Universal only ever need one Client Pact Contract for their Provider, called ?All Clients Pact Contract?. In the real world, our teams here write a small (Java) client project for each microservice. This code is used by each client project and means it can use Java APIs to build and send requests then handle responses. So in effect we have only one client contract, because one set of shared Collaborator code. So if there?s only ever one client contract, is Pact overkill? Let me know if you think we shouldn?t be writing these client projects.

abubics
2021-04-21 00:14
Need to be clear about which side of the contract you're (not) changing, because consumer & provider trigger different processes. I'm pretty sure each consumer publish creates a new record in the db, but if the hash is the same (as any existing contract), it will be pre-verified (won't trigger any provider verification). Not sure if it will trigger verification of provider versions that are newer than the previous latest version of that hash. That's probably a question for @bethskurrie, or it's probably mentioned in the docs.

darccide
2021-04-21 01:35
has joined #general

matt.fellows
2021-04-21 02:13
So, analogy aside here (I?ll need to watch the trailer :stuck_out_tongue: ) Does this article help https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/ ?

matt.fellows
2021-04-21 02:14
> So in effect we have only one client contract, because one set of shared Collaborator code. Can you guarantee at any moment in time, that _every_ consumer uses _exactly_ the same client library that your production system is compatible with?

matt.fellows
2021-04-21 02:15
What I saw in a past life, is that the client library was shipped to consumers, but then deployments had to be synchronised because now the Provider had a false sense of confidence that any changes are going to always be compatible

matt.fellows
2021-04-21 02:15
if you don?t do that, then you need to fallback to practices that prevent backwards incompatible changes or use contract testing approaches to help provide compatible info during deployments

matt.fellows
2021-04-21 02:17
FYI this question will feature in our upcoming https://www.linkedin.com/company/pactflow/events/

matt.fellows
2021-04-21 02:36
Hi all! We have 3 upcoming AMA sessions in EU/UK, APAC and US. We?re going to be taking Q&A from the audience, and will also answer the top few questions on Slack since our last one, including: ? How to test asynchronous services such as Lambda w\ SNS or Kafka? ? Can I generate pact file from Open API specs? ? Where and when do tests run? (unit, CI, against production or dev?) ? How to mock my provider code ? Can I test 3rd party APIs? ? What?s the difference between SCC and Pact? You can join the event :point_right: https://www.linkedin.com/company/pactflow/events/?viewAsMember=true (follow the Pactflow page to be notified of upcoming events)

bheemreddy181
2021-04-21 02:45
```Ideally, they are generated from code because this prevents drift``` i quite didn't get that

mail_4brad
2021-04-21 02:48
? The trailer is missing a musical score and was released in error. You can see it in the first 30s. ? Thanks for the details. I imagine the teams? response will be that the client will maintain backwards compatibility through all releases. But that?s only a soft target, not testable without multi-version testing (and a team that thinks it will always be backwards compatible likely won?t implement version testing). Will have a chat to them.

matt.fellows
2021-04-21 02:48
If the OAS is generated from code, your code shouldn?t be able to drift from the spec. If you write the spec by hand, of course, implementation can drift from the the hand coded OAS file

matt.fellows
2021-04-21 02:49
(I?ve been on phone calls all morning, so can?t listen - but I will!)

matt.fellows
2021-04-21 02:49
re: clients. If you don?t have a problem, it?s hard to demonstrate value

matt.fellows
2021-04-21 02:49
when you say a problem, then you?ll see how Pact / contract testing can add value

mail_4brad
2021-04-21 02:52
I can see the value - it?s figuring whether our setup (including client libraries) solves enough of the same problem

matt.fellows
2021-04-21 02:52
Of course, Pact/contract-tests provides other value as well over and above the exact problem we?re talking about here

matt.fellows
2021-04-21 02:54
client libraries make that a bit more difficult. For example, you don?t get visibility of the exact needs of each client (they may consumer differing subsets of the provider, for example, knowing this is very helpful for evolution of the API itself)

mail_4brad
2021-04-21 03:07
Ok so benefits as I understand it now: 1. Contract verification that Providers are responding correctly to Consumers (as discussed, may be somewhat managed by client libs). 2. Verification of the same as clients are upgraded at different times. 3. Documentation on which client is using what APIs and expectations. 4. The UI which gives graphs of dependent clients And client libs with a backwards-compatible approach meets: 1. Mostly (relying on integration tests between client lib and provider) 2. Not without multi-version testing 3. No 4. No Am I missing any other Pact features that should be in here? Didn?t find a list per se in the docs.

bheemreddy181
2021-04-21 03:28
that is where dredd helps , do you know by any chance which tech stack doesn't have support for generating OAS documents from the code itself ?

laxmi.somni508
2021-04-21 14:02
Hi Helpful members, We've done a small PoC using Pact (1 simple microservice covered through 2 FE consumers & 1 BE Provider) We're trying to prepare a presentation for Management/Business stakeholders (non-Technical) on the PACT implementation. ? What are the key benefits of implementing Pact framework? ? Does anyone have a sample slides /presentation (.ppt etc) , which they used to explain Pact's benefits & little bit of architecture to the wider community (comprising of Devs, non-Devs & Business stakeholders) Thanks in advance. [STAY HOME-STAY SAFE:pray::mask:]

phil.endsley
2021-04-21 14:23
Hi! I've done a couple presentations (no slides I can share, sorry!) In general, I start with this page for slides about the "why we should do this" https://docs.pact.io/faq/convinceme/ I usually either use the pictures from the docs (ex: https://docs.pact.io/getting_started/how_pact_works) or re-create them with concrete examples depending on the audience (Sometimes, it really drives the point home to leadership when you put your product name in the pictures vs ServiceA). You might be able to get some more targeted advice from the maintainers, but they're on Australia time

laxmi.somni508
2021-04-21 14:34
Brilliant. Thanks a lot for your input..:pray: Also will see what maintainers have to add.

laxmi.somni508
2021-04-21 14:36
And one quick question - What kind of bugs PACT normally catches? If I've to explain this to stakeholders (dev/ non-dev) then what can we elaborate?

phil.endsley
2021-04-21 14:43
API compatibility issues. Pact makes sure that an application is providing an API that meets the expectations defined by a consumer of that API. This could be a breaking change to an existing API on the provider, a consumer calling an API that doesn't exist yet, an API returning a response in an unexpected format, etc...

uladzislau_danilchyk
2021-04-21 14:51
@abubics, consumer side I mean

yousafn
2021-04-21 16:35
I?m not usually about that early haha but will deffo try and attend tomorrows UK event!

bethskurrie
2021-04-21 23:55
@scott.riley111 thanks for that input. There will actually a way to model multiple versions in prod at the same time using the code that I've got. It will just be slightly less intuitive with the terminology it uses than start deployment/end deployment.

bethskurrie
2021-04-21 23:56
It will support your usecase.

abubics
2021-04-22 00:33
Something missing from the "convince me" that I often come across is: often organisations don't even know which services/codebases are talking to each other. Pact helps maintain that mapping.

stain.witness
2021-04-22 02:43
has joined #general

uladzislau_danilchyk
2021-04-22 07:58
@bethskurrie, hi! Could you try to explain the last step I described? It would very useful. Thanks

oleksandra.pishcheiko
2021-04-22 08:31
has joined #general

scott.riley111
2021-04-22 08:34
Great :slightly_smiling_face:

akos.csurai.4github
2021-04-22 10:01
has joined #general

christosbouloumpasis
2021-04-22 10:38
has joined #general

temanibeck
2021-04-22 16:04
has joined #general

michael_swiss
2021-04-22 21:04
has joined #general

dawoud.sheraz
2021-04-23 09:34
has joined #general

uladzislau_danilchyk
2021-04-23 10:18
Hi all! @matt.fellows, when it's planned to add filtering of matrix in new Pact Broker like it was in old one?

matt.fellows
2021-04-23 11:34
We?re currently in a UX/DX phase where we?re designing the new interfaces to accommodate bi-directional contracts

matt.fellows
2021-04-23 11:34
This includes a bit of a re-think about some of this stuff

matt.fellows
2021-04-23 11:34
but for now, you know there is a link to the old UI to get the view you?re after right?

matt.fellows
2021-04-23 11:34
Also, we?re trying to encourage Pactflow issues and voting here: https://github.com/pactflow/roadmap. Don?t be afraid to ask by raising a feature request!

adriano.tanoue
2021-04-23 12:01
has joined #general

uladzislau_danilchyk
2021-04-23 13:15
@matt.fellows, thanks. I forgot about "use old UI" feature

uladzislau_danilchyk
2021-04-23 13:22
@matt.fellows, i have no response from Beth. Maybe you can help?

cstepanian
2021-04-23 14:03
has joined #general

uladzislau_danilchyk
2021-04-23 14:06
Hi all! Does anyone have some code examples with "Work in progress" pacts?

chris.faulkner
2021-04-23 15:49
HI all - I am using the matchers with the DSL to define a PACT interaction. I need to model an optional field within an array - how to do this ? The provider verification provides a value in one of the two array elements and verification fails because the way that the DSL expresses the body, it is expected in both. OK so I could remove it entirely from my matcher but how would I then ever know if someone updated the provider project to remove the field entirely which would be part of what I am trying to protect against. The contract really says ?provide this field when it is available? and I?d like the provider to conform to that contract.

phil.endsley
2021-04-23 15:54
Typical advice is to have multiple interactions for the optional fields. One where it's present, and one without. https://docs.pact.io/faq/#why-is-there-no-support-for-specifying-optional-attributes

saurabh.goel
2021-04-24 20:10
has joined #general

matt.fellows
2021-04-24 22:51
Upcoming event: Mobile and Contract Testing https://www.linkedin.com/events/softwaretestinginabudhabi-5-mob6791660658493530112/ Abhi and Devendra Josan will present the topic ?Mobile Application Testing in Agile world?. The agenda is: ? Objectives: Current Challenges & Required Capabilities; ? Types of testing; ? Open-Source Automation tools and their limitations; ? Why to include Cloud-based SAAS tools? ? SAAS based tools on the market; ? How to Identify the right tool to match your requirements; ? Working Demo of mobile app testing using any SAAS-based tools. Abhi Nandan prepared a talk ?Contract testing in Polyglot Microservices?. He will share the experience of working with microservices, that are designed using multiple programming languages. PACT and Pact Broker are used as tools for Contract Testing. Abhi also will show an indicative pipeline orchestration to demonstrate how it can fit into CI/CD pipeline.

cemal.onder
2021-04-25 12:22
has joined #general

matt.fellows
2021-04-26 00:31
This section of the docs explains the ?events? that matter: https://docs.pact.io/pact_broker/webhooks#events


matt.fellows
2021-04-26 00:33
From the docs I just shared: > The broker uses the following logic to determine if a pact has changed: > If the relevant consumer version has any tags, then for each tag, check if the content is different from the previous latest version for that tag. It is ?changed? if any of the checks are true. One side effect of this is that brand new tags will trigger a pact changed event, even if the content is the same as a previous version. > If the relevant consumer version has no tags, then check if the content has changed since the previous latest version.

richard.forjoe
2021-04-26 00:52
has joined #general

ron.aharoni
2021-04-26 11:03
has joined #general

dawoud.sheraz
2021-04-26 12:22
Hello. When using Format().timestamp inside a request body/response with pact-python, I am receiving the following error: ``` TypeError: Object of type datetime is not JSON serializable``` I am using datetime in form `datetime(2020, 10, 10).isoformat()` to generate the pact but it marks it string instead of datetime and I want the checks against timestamp. Any ideas what might be wrong here?

matt.fellows
2021-04-26 12:26
Might be best asked in #pact-python with your code sample to accompany it

matt.fellows
2021-04-26 12:26
sounds like the body is not properly formatted i.e. it can?t be converted to JSON

dawoud.sheraz
2021-04-26 12:40
the error only occurs with Format().timestamp. Unless there is some attribute I have to mention.

andrewmorton
2021-04-26 13:33
has joined #general

aram
2021-04-26 15:24
has joined #general

marcelo.souzameinberg
2021-04-26 21:32
has joined #general

songqing.gu
2021-04-27 01:25
has joined #general

fortiss.anita
2021-04-27 09:34
has joined #general

matt.fellows
2021-04-27 09:48
:wave: Hi all, I wanted to share a post that the co-founders of Pactflow and I recently authored on why we built an open source company, and what Pact means to us. It?s something we?ve wanted to post for a while, but the time never seemed right. Now is as good a time as any! We dive into a couple of touchy subjects in there (e.g. commercial interests vs free software), but we really believe in being transparent and open, and would love to encourage a dialogue so that we continue to shape our values and principles as we move forward as a company. We hope you enjoy it: https://pactflow.io/blog/why-build-an-open-source-company/

tien.xuan.vo
2021-04-27 11:17
Thanks for sharing the story!

keshav.reddy503
2021-04-27 12:06
has joined #general

jeremykeczan
2021-04-27 14:57
has joined #general

yeseniavega411
2021-04-27 15:31
has joined #general

almantusk
2021-04-27 16:56
has joined #general

almantusk
2021-04-27 17:01
I am fresh into contract testing and I still don't see much value of it over functional tests. I do agree, TDD approach, where consumer sets expectations and producer implements them- is neat, but I wouldn't pay this that much effort of adopting a new technology. I don't understand, why in the benefits most people say that you won't be needing to run a db or other services- imo, you will still be doing that for producer end of things. So I am not buying the speed benefit. I mean, you could implement a layer of happy path tests anyways- in any tech or way - how does pact make it any better?

elliottmurray
2021-04-27 17:04
I'll suggest if you're a little unclear on the value of TDD I think you should start there first before Pact. I'd say Pact is an advanced topic and tooling for quite mature teams in terms of test automation.

almantusk
2021-04-27 17:11
I do see value of TDD, but I was asserting whether that's the only benefit

almantusk
2021-04-27 17:19
The thing we are looking for is a lightweight way of picking up breaking changes early on.

elliottmurray
2021-04-27 17:21
That is literally the point of Pact. Well you could also argue as with TDD in terms of also a design tool. But solving regressions introduced because of a change to other services is it's selling point

elliottmurray
2021-04-27 17:22
I accept it can be a mindshift to get started and some learnings but I don't think logically you can get more effective approach than what Contract Testing is trying to solve.

elliottmurray
2021-04-27 17:23
You can argue whether Pact is 'developer friendly' enough (though think we are!)

brendan.j.donegan
2021-04-27 17:47
I think if you don't see the benefit then it's probably not a good idea to try and use Pact for the sake of it

brendan.j.donegan
2021-04-27 17:49
It may be it doesn't suit your particular context, or it may be that it does but you don't have enough insight into the issues to understand how Pact will help. Either way it probably won't work for you

brendan.j.donegan
2021-04-27 17:51
One of the biggest challenges I've found when rolling out Pact in an organization is dealing with cases where teams just don't get it

phil.endsley
2021-04-27 17:53
I'm going to link a few pages within my reply. Apologies ahead of time if you've already read through them. If that's the case, perhaps we could discuss specific points from them, or just do a deeper dive on areas of concern > I still don't see much value of it over functional tests. Contract tests shouldn't replace functional tests. https://docs.pact.io/consumer/contract_tests_not_functional_tests/ > I don't understand, why in the benefits most people say that you won't be needing to run a db or other services- imo, you will still be doing that for producer end of things. Contract tests let you define and assert how two applications communicate with each other. Without contract tests, you would need to start instances of ServiceA and ServiceB, then run tests against them. If you do that, when do you run these tests? Contract tests let you do this in isolation while maintaining the integrity of each application's expectations. Yes, you would still need to start ServiceB to test the producer end of things, but you don't need to start ServiceA when you do that. RE: Running a DB - This is where the lines get a little blurry. On the provider side, you can go as far as you want with standing up services. You could run an embedded db, a real db, mock the db layer (or even higher up). The important takeaway is that for a contract test, that's not in the intended scope of the test. By including it, you're adding more confidence, because the test scope is bigger, but the intended coverage is the communication layers. There's a slide floating around somewhere from the last Pact meetup that does a good job of visualizing the scope of the tests for the consumer and provider. > So I am not buying the speed benefit https://docs.pact.io/faq/convinceme/ (The opening paragraph) ? Pact tests are fast ? You get feedback for breaking/incompatible changes at build time. Since they're relatively light weight, you can run them for each commit on each branch, which speeds up the feedback loop > I mean, you could implement a layer of happy path tests anyways- in any tech or way - how does pact make it any better? It's not about just having happy path tests. The difference is the contract between the two applications is documented and persisted. When the tests are ran, you assert against the contract. You're making sure the APIs are implemented as expected; that the two applications can successfully communicate with each other Like some others have said, it might not suit your needs. The FAQ has a lot of good information that's worth reading over as well. https://docs.pact.io/faq/

phil.endsley
2021-04-27 17:56
One more point I'll make is to paraphrase something @matt.fellows said the other day. If you don't have a problem, it's hard to show the value. If you have a problem, then you can see how Pact adds value

almantusk
2021-04-27 18:21
Thank you for clarifying. My summary. Pact helps: - Do microservices in TDD - Document API communication - Speeds up consumer tests by not requiring a running producer - Detects breaking changes without running the consumer

aforeman
2021-04-27 23:59
Hello! Our next Ask Me Anything (AMA) drop-in session for the *APAC region* is today. Join @uglyog and @matt.fellows (core Pact maintainers and co-founders of Pactflow) from *12:00-12:30pm AEDT* to hear the answers the following top questions from the Pact Slack community: ? What are the best practices for mocking provider dependencies? ? Can I test 3rd party APIs? ? What's the difference between Spring Cloud Contract and Pact? Plus - any questions you may have! Hit attend here to access the Google Meets link https://www.linkedin.com/events/contracttestingamawiththepactfl6788684144894447616/ _And don't forget to follow us Pactflow LinkedIn (https://www.linkedin.com/company/pactflow/events) & Twitter (https://twitter.com/pactflow) to keep up to date with future AMA drop ins_ :raised_hands:

alexandra.huamani
2021-04-28 00:12
has joined #general

abubics
2021-04-28 01:01
Not just microservices, but it's a strong use case :thumbsup:

matt.fellows
2021-04-28 01:08
`s/microservices/distributed systems`

matt.fellows
2021-04-28 01:14
It detects breaking changes from _either_ side of the contract

matt.fellows
2021-04-28 01:14
If the consumer adds something the provider can?t do, it will fail a build. If the provider removes something one of its consumers needs, it fails their build

matt.fellows
2021-04-28 01:15
See video #4 in this playlist for more on how functional tests + contract tests can alleviate a lot of the pain of end-to-end integrated tests: https://www.youtube.com/playlist?list=PLwy9Bnco-IpfZ72VQ7hce8GicVZs7nm0i

tonynguyenit18
2021-04-28 02:12
has joined #general

agrawalneeraj43
2021-04-28 04:37
has joined #general

shixun.liu1023
2021-04-28 04:39
has joined #general

narendra.pathai
2021-04-28 06:21
has joined #general

aforeman
2021-04-28 11:07
Based in the North America and getting FOMO about our 'Ask Me Anything' sessions? Your time is near! Join Pact Core Maintainers & Co-Founders of Pactflow? @matt.fellows and @bethskurrie?on Wed 28 Apr at 3pm PST / 6pm EDT as they discuss the following top questions from the Pact Slack community: ? What is the difference between contract testing and functional testing? ? How can I test optional fields? ? How can I do contract testing when we use API clients/SDKs? Plus any questions you may have! (Add yours in advance in the thread :point_down: ) No need to register, just drop in (link to join the Google Meet is in the event :point_right: https://www.linkedin.com/events/contracttestingamawiththepactfl6788683361243287552/)

itzdavey
2021-04-28 13:52
Just a general statement but I feel like there are two types of people.. People that see Pact and go "Whaaa?" and people that say "Where have you been all my life?"

marcin.grzejszczak
2021-04-28 13:53
has joined #general

flubniewski
2021-04-28 17:01
has joined #general

flubniewski
2021-04-28 18:33
Hey guys, I'd like to ask for little guidance as I'm not sure or I can't wrap my head around one topic. I'd like to introduce Pact or CDC generally speaking in following scenario: Given two services A (consumer) and B (producer), B is service implemented by a set of lambda functions behind AWS API Gateway and A is regular service hosted on server. I'm not sure how I could introduce contract verification in lambda functions (service B - the producer). I was thinking about skipping API Gateway in such contract tests, somehow extracting a generic HTTP handler (because currently it's coupled to some AWS libraries) and running such handler with all mocked dependencies. However it seems cumbersome and I'm not sure if I'm missing something? Do you have any examples for such scenarios? Do you have any other ideas how to do it "by the book"? Thanks a lot for help:)

brendan.j.donegan
2021-04-28 18:43
How do you test changes to the lambda functions? How do you deploy updates?

flubniewski
2021-04-28 19:18
currently there are only unit tests triggered on pipeline

uglyog
2021-04-28 23:45
If the API Gateway is only pass-through, and not modifying anything, then I would not include it.

uglyog
2021-04-28 23:46
What language are you using?

tjones
2021-04-29 02:08
You can also use AWS Localstack in some cases. I've been meaning to set up an example for a while

tjones
2021-04-29 02:12
Another option is to run your verification against a deployed dev or test account.

tjones
2021-04-29 02:13
Running a special handler for verification that mocks the API calls from AWS will work, but you're not testing the actual setup of the server then

tjones
2021-04-29 02:13
it depends on where you want the risks to lie

tonynguyenit18
2021-04-29 02:36
Thanks Fillip. This is interesting and potential case in our design. Would love to follow up this thread and hopefully someone can share an example.

tjones
2021-04-29 03:51
@tonynguyenit18 it's hard to give an example that will work for everyone, because there are a lot of different ways to build a lambda app. Largely, you just need a way to spin up your application so that it can receive HTTP requests (and a way to configure the server states if you are using them). This is the same as any verification step - the difference with lambda is that "spin up your application" might mean deploying it somewhere (or running localstack).

matt.fellows
2021-04-29 07:12
:wave: hello friends! We have an _awesome_ new member of our community - @marcin.grzejszczak. For those of you who don?t recognise that name, he?s the core maintainer of Spring Cloud Contract, another contract testing tool (he?s also responsible and involved in a number of other projects in the Spring ecosystem). I believe there have been a few questions/comments around this recently, so now would be a great time to get some feedback from the _source_ :thread: _Q&A_ :point_down:

matt.fellows
2021-04-29 07:13
@anchit.99 :point_up:

marcin.grzejszczak
2021-04-29 07:13
:blush:

matt.fellows
2021-04-29 07:14
I?ll start us off with a nice and easy one - what do _you_ think is the biggest benefit of contract testing?

matt.fellows
2021-04-29 07:15
(I recognise this is a ?simple? question, but it?s always good to hear a diverse perspective on the topic, and we risk being stuck in our echo chamber here)

marcin.grzejszczak
2021-04-29 07:17
Sure, definitely the fact that one can feel more secure about the stability of their software. IMO without contract tests you can't really ensure that your integration tests are working fine. If you as a consumer are stubbing the producer without verifying that stub - you're basically creating tests that are meaningless. Also what I love about contract testing is that you can use them for API backward compatibility tests

matt.fellows
2021-04-29 07:19
Does contract testing replace end-to-end testing? If not, what do you do to ?cover the gaps??

marcin.grzejszczak
2021-04-29 07:21
It depends :wink: I'm not a fan of end to end testing. I think you describe it in a great way in your documentation. I can imagine in the microservice environment that with proper monitoring and alerting on production you could consider having contract tests instead of end to end tests. That's cause if A passes the contract tests against B and B against C then you can assume that on production you will be able to communicate from A to C. Communicate != it will work from the business perspective

marcin.grzejszczak
2021-04-29 07:21
that's why you have all the unit / integration tests to ensure the business validity of your software

matt.fellows
2021-04-29 07:24
That resonates with me. As far as the pyramid is concerned, I tend to explain it this way. Does this align to how you think about it?

flubniewski
2021-04-29 07:37
hey, thanks for taking part in the discussion :wink: @tjones I'm a little bit worried about running such test against real lambda functions as it would be testing the business logic instead of testing just the contract (?) and it would be a lot more difficult to mock the environment. Was thinking about extracting pure http handlers from lambdas with mocking responses from the services called inside handlers.

flubniewski
2021-04-29 07:39
and running full business tests against live lambda functions on stg would be responsibility of a team that has ownership over service B

flubniewski
2021-04-29 07:39
does it make sense?

tjones
2021-04-29 07:39
So usually your pact tests aren?t tests *for* the business logic, but I think it?s ok (and even good) if they *cover* some of the logic. But, it depends on your setup. If you can?t mock dependencies within your lambda service, it might not work for you

tjones
2021-04-29 07:40
The provider verification (of the lambda) is indeed the responsibility of the team that own the lambda

tjones
2021-04-29 07:41
Ideally you want your provider states to be able to be mocked without having to spin up actual dependencies

tjones
2021-04-29 07:41
Your approach pulling out the http part is a good middle ground, I think

tjones
2021-04-29 07:42
It does run the risk that you?re not testing the actual interface the way it will really be used

matt.fellows
2021-04-29 07:50
I recently did a talk at testing stage, and in the follow up I received this comment about the ?time to value? from contract testing. How do you think about value and what are some of the ways to get there faster?

matt.fellows
2021-04-29 07:51
(no hurries on any of these, but I?m thinking we really should have done this earlier and perhaps should try and do a panel session together one day!)

matt.fellows
2021-04-29 07:51
Do you have the option of using tools like SAM local or Serverless Offline?

matt.fellows
2021-04-29 07:52
Usually these are perfectly good replacements to do HTTP testing of lambda functions locally, albeit it?s a bit more of a black box test (not a bad thing, as Tim points out)

matt.fellows
2021-04-29 07:52
that?s how I usually do it

matt.fellows
2021-04-29 07:52
alternatively, I have a very thin separate ?adapter? layer, that talks HTTP and routes to the lambda function to handle (aka a very basic API gateway)

matt.fellows
2021-04-29 07:53
This means I can test it using standard unit testing tools like Jest/Mocha/Sinon

flubniewski
2021-04-29 08:03
@matt.fellows and how do you mock responses from lambda running locally?

matt.fellows
2021-04-29 09:12
Mock downstream systems, you mean?

matt.fellows
2021-04-29 09:14
1. You can still run these in a dev/test context and stub dependencies that way 2. If more black box, you can use tools like docker to run stub services and environment variables to repoint (e.g. mountebank, Pact stubs, local stack etc)

marcin.grzejszczak
2021-04-29 10:03
re: the time frame - I've noticed that too. Doing contract tests is an organizational problem too

uladzislau_danilchyk
2021-04-29 13:31
@matt.fellows, did I correctly understand that if new version of pacts published (pacts content are not changed) with the same tags, webhook will not be triggered? (changed only version of the consumer)

laxmi.somni508
2021-04-29 14:56
Hi Helpful members, We've done a small PoC using Pact (1 simple microservice covered through 2 FE consumers & 1 BE Provider & http://Pactflow.io as broker) We're having a presentation / gothrough with Management/Business stakeholders (non-Technical) on the PACT implementation and there's a question- ? What actions/steps ideally would be taken if PactBroker shows issue(s) in Contract testing? ? How will we notified if contract is broken?

laxmi.somni508
2021-04-29 14:57
As we're at early stage of implementation, so we haven't defined everything & would like to know from the community. Thanks

parveenbanu
2021-04-29 15:04
Hi Team,

parveenbanu
2021-04-29 15:05
Hi Team, My management is asking like provider driven testing is possible in pact?

parveenbanu
2021-04-29 15:11
any one can help me with this question

phil.endsley
2021-04-29 15:16
> What actions/steps ideally would be taken if PactBroker shows issue(s) in Contract testing? This is a tricky question...I would say: It depends ? First, Failed verification is not necessarily a bad thing. All it represents is that a specific version of a consumer and a specific version of a provider cannot be deployed together. Since APIs evolve, this is ok (depending on the situation). I wouldn't necessarily expect consumer version 35 to be compatible with provider version 1. ? Sometimes, the problem is obvious. If a contract is verified, then fails after a change on the provider side, maybe they accidentally made a breaking change. In this case, they may just need to fix the bug they introduced ? Maybe the consumer published a contract that the provider can't satisfy (for whatever reason) ? Pact is not a replacement for communication. Ultimately, if a contract is failing unexpectedly, I would expect both teams to work together to determine the cause and resolution > How will we notified if contract is broken? In my experience, broken builds or failed deployments. There are also a number of webhooks you can configure for additional notifications if you want (ex: https://docs.pact.io/pact_broker/webhooks/template_library/#slack---post-notification---provider_verification_published)

fnguyen
2021-04-29 18:54
If my service returns Content-type: "text/plain", is there a way to force pact to understand it as json so i can match the individual objects/attributes?

fnguyen
2021-04-29 18:57
@parveenbanu: pact is CDC. CDC is CONSUMER driven contract. Each pact is an agreement between a consumer and a provider. There is one pact per consumer/provider pair. The consumer states what they use in the provider and the provider runs those interactions against its actual service to confirm the service behaves according to the agreement. Not sure how you would turn it around and do it driven by provider.

matt.fellows
2021-04-29 23:05
Pact is inherently consumer driven

matt.fellows
2021-04-29 23:06
Pactflow does now have support for https://pactflow.io/blog/bi-directional-contracts/ from which you can initiate the test from either side.

tjones
2021-04-30 00:26
Contract testing is very much an organisational problem, I agree.

tjones
2021-04-30 00:27
I've noticed a trend towards naming any kind of API testing as "contract testing", which is good (in that people are thinking about it and know it's a bandwagon worth being on), but also bad (in that many of these tests that I see are not what I would call contract tests, because there's only testing on one side).

tjones
2021-04-30 00:28
Also, welcome Marcin! Exciting to have you here!

matt.fellows
2021-04-30 02:00
correct

matt.fellows
2021-04-30 02:00
there?s nothing new to verify

matt.fellows
2021-04-30 02:01
that?s for the ?contract content changed? event

matt.fellows
2021-04-30 02:01
You can use the ?contract published? event which is triggered every time a pact is published, regardless of whether it has changed or not.

abubics
2021-04-30 02:13
Nice summary, @phil.endsley :taco:

parveenbanu
2021-04-30 06:07
Thanks for Sharing the information. I already informed the same to my management. Just double confirming my thoughts with others.

aparnachaudhari
2021-04-30 06:08
Praveen, look at pactflow?s support for bi-directional contract testing

aparnachaudhari
2021-04-30 06:08
That might be something you could leverage for your usecase

parveenbanu
2021-04-30 06:09
can you please help me with some link for the same.?


parveenbanu
2021-04-30 06:11
thanks i will check this

parveenbanu
2021-04-30 06:11
:slightly_smiling_face:. Thanks will check this.

matt.fellows
2021-04-30 06:12
it?s worth understanding why they want provider driven though?

matt.fellows
2021-04-30 06:12
I suspect it might be an XY question

matt.fellows
2021-04-30 06:12
what?s the actual use case or concern with Pact/consumer-driven as it is?

parveenbanu
2021-04-30 06:19
Just they want me to check on this way. Their perception is when go for CDC then it will capture the Provider errors before deployment and in PDC it will capture the consumer error before deployment.

matt.fellows
2021-04-30 06:21
so Pact does both

matt.fellows
2021-04-30 06:22
If the outcome is that you want to prevent releasing breaking changes from either side, you can do that with Pact

matt.fellows
2021-04-30 06:22
It?s _literally_ what it?s designed to do

marcin.grzejszczak
2021-04-30 07:04
thanks :slightly_smiling_face:

aforeman
2021-04-30 07:09
Missed our live 'Ask Me Anything' sessions this month? Lucky for you, we recorded them and have made them available on YouTube. Check out the playlist https://youtube.com/playlist?list=PLwy9Bnco-IpdgdZce-rXeR7EF2_6T8z7S Our team answers the following questions: UK / EU: https://youtu.be/FxrFj7xvQ24 > How to test asynchronous services such as Lambda with SNS or Kafka > What is the boundary of a contract test? > Can I generate a contract test from OAS? > Where and when do tests run? (unit, CI, against production or dev?) North America: https://youtu.be/d6BXvwCoKSQ > What is the difference between contract testing and functional testing and can you do negative testing? > How can I test optional fields? > How can I do contract testing with API clients/SDKS? APAC: https://youtu.be/jARC5TRcn0c > What are the best practices for mocking provider dependencies? > Can I test 3rd party APIs? > What's the difference between Spring Cloud Contract and Pact? --- If your questions haven't been answered here, make sure you hit attend to one of next month's AMAs: https://www.linkedin.com/company/pactflow/events/ OR jump over to #pactflow-ama

wesleythomaswilliams
2021-04-30 09:46
I've been thinking a lot recently about the term consumer driven contracts and in some ways I think it's misunderstood. I tried to explain it to colleagues recently in terms of the way we often work, which is that we've got an existing service that publishes data and we have consumers coming to us periodically to sign up to consume that data. At that point we're starting on our journey together, but the provider very much existed before the consumer. However, it's the consumer which will drive the design of the contract for the data they wish to consume from us. I think the term consumer driven contracts, which is perfectly logical, can be misread by people to think that the consumer must exist before the provider. Of maybe I'm just a babbling fool :smile:

matt.fellows
2021-04-30 10:17
no, not a fool (well, maybe still a fool, but the statements are valid :stuck_out_tongue: )

matt.fellows
2021-04-30 10:18
I think contract testing in general has been co-opted by the industry, and risks being a useless/vague term (unfortunately like many terms in testing!)

matt.fellows
2021-04-30 10:18
The people in the APIs you won?t hate community aren?t overly fond of my strict definition of contract testing, and I?m not overly fond of them referring to a JSON schema as a ?contract?

matt.fellows
2021-04-30 10:19
At the very least, a contract implies an agreement between at least 2 parties

roy_collings
2021-04-30 15:15
has joined #general

matt.fellows
2021-05-03 04:09
A lot of people are _both_ types of people, starting with the ?wtf?

matt.fellows
2021-05-03 04:10
our job is to reduce the time from ?wtf? to ?aha?

prachi_mangesh_edake
2021-05-03 04:43
has joined #general

sams.prashanth
2021-05-03 08:04
has joined #general

philip.m.wood
2021-05-03 12:46
has joined #general

amiller
2021-05-03 15:27
has joined #general

agarwal.akash333
2021-05-03 23:14
has joined #general

anand.ilkal
2021-05-04 08:01
has joined #general

ryanlevell
2021-05-04 14:10
What is the recommendation when using a client to communicate with another service? For example, we have one microservice that also has a client library. So none of the consumers call the API directly, they go through the client that hides all the API details. Where should the Pact be in this case? Should we create pacts against libraries? Libraries are not running services though, so you lose all the deployment checks.

dawoud.sheraz
2021-05-04 14:17
When you say client, do you mean something like Oauth client? If I understand correctly, the client interface is doing all the calls(and there are different methods for separate api calls).

ryanlevell
2021-05-04 14:21
No just like a wrapper around an API, instead of making the API calls directly. You download the client library and make a function call and the client will make the actual API call. For example if you need to make a GET to `/users?userId=1234`, instead of making that call directly you?d instead just use the library code e.g. `client.getUser(1234)`

ryanlevell
2021-05-04 14:23
Maybe SDK is a better term

dawoud.sheraz
2021-05-04 14:23
Since pact is generated with consumer tests, you can write the tests that mock certain level of client library operations(but don?t mock the actual request).

dawoud.sheraz
2021-05-04 14:24
Even though SDK hides the internal details, the documentation usually specifies what url/api is called behind the scenes. But here is the question: Who is maintaining the provider?

ryanlevell
2021-05-04 14:25
SDK and provider are maintained together in this case

dawoud.sheraz
2021-05-04 14:27
Right. In consumer, you can write the consumer tests with some level of mocking for library?s internal operations(if required). I don?t suggest writing a test-only consumer just to create pact. Ideally, write the consumer tests for the module responsible for making the api calls. Not only you are generating the pact, you are also verifying the code you have written against the api response is working as intended.


dawoud.sheraz
2021-05-04 14:29
See this doc for some visual help on what to consumer test.

ryanlevell
2021-05-04 14:30
Funnily enough I just seen above from Alicia?s post that the US session covered this exact question. Maybe I should watch that :slightly_smiling_face:

dawoud.sheraz
2021-05-04 14:30
Nice.

dennis.minard
2021-05-04 16:23
has joined #general

chris.williams
2021-05-04 16:41
has joined #general

chris.williams
2021-05-04 16:42
Hi - does it take a long time to get a password through when signing up for the free trial ?

chris.williams
2021-05-04 16:43
~Haa please ignore, Mimecast marked them all as spam~ :smile:

ssorcnafets
2021-05-04 19:20
has joined #general

matt.fellows
2021-05-04 20:34
Ama is a good idea! Also I updated this based in that AMA: https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/

matt.fellows
2021-05-04 20:35
Any chance you could share the raw email data with me in a DM? We'd love to know why it got marked as spam as we should have all the correct email settings

kowalczuk.jnr
2021-05-04 22:24
has joined #general

jarmy
2021-05-04 22:54
This question has probably been asked before (I couldn't find anything concrete in the FAQ)... why should consumer contract tests reside in the same repository as the service? Some of my colleagues want the contract tests to reside in a separate repo.

matt.fellows
2021-05-04 22:58
The simplest answer is that on the consumer side, they are unit tests, so it just doesn't make sense to have them elsewhere

matt.fellows
2021-05-04 22:58
They are white box tests

matt.fellows
2021-05-04 22:59
"what changes together, stays together" is a nice rule of thumb here - otherwise drift is possible if not guaranteed

matt.fellows
2021-05-04 23:00
On the provider side you could make a case to have them external because they can be done as in a black box fashion (albeit I prefer not to do it this way to ensure I have full control over the test)

jarmy
2021-05-04 23:04
Here's some of the thinking behind my question: ? Wouldn't it be easier to gain acceptance by service owners to maintain the tests if they were in a common repo rather than a service repo? ? Wouldn't it be better to write all the tests in a more commonly used language rather than the underlying language of the service?

matt.fellows
2021-05-04 23:12
> Wouldn?t it be easier to gain acceptance by service owners to maintain the tests if they were in a common repo rather than a service repo? Personally, I think not. That just seems to align with the way traditional enterprises hand off integration testing to another team (usually a dedicated testing team), which is fraught with challenges. Why would that be better than in the service?s actual repo, maintained by the service owners, and the tests are updated with the code when the code updates? It?s also part of ?shift left?. If you want to find a bug at dev time, you need the tests to run when you change your code. If it?s in another location, that makes that harder to do > Wouldn?t it be better to write all the tests in a more commonly used language rather than the underlying language of the service? Possibly. I know some customers who use our https://docs.pact.io/implementation_guides/cli/#provider-verifier and build simple wrappers around it to simplify the provider side. It?s hard to do on the consumer side though, because it needs to check actual behaviour of your code, which (usually) requires access to the code itself, and therefore language neutrality is hard to do But that?s not a reason to not co-locate tests with the service itself. Ultimately, that?s up to the workflow of your team

matt.fellows
2021-05-04 23:13
Are you having challenges using the language specific tools?

matt.fellows
2021-05-04 23:14
(FYI I?ll be offline for the next couple of hours but will come back to this. I?ll also add an FAQ after the discussion to our docs)

jarmy
2021-05-04 23:21
The reasons you outlined are solid and I'm onboard. There's a single team that is putting up resistance to contract testing in general. It seems they don't want to maintain additional tests.

yousafn
2021-05-04 23:46
How does that team mitigate against the risk of failure from contract drift? In their current setup? Do they have a traditional integration test or e2e suite or is the validation done elsewhere and therefore not their job?

yousafn
2021-05-04 23:50
We?ve seen resistance many times to contract testing and the teams resisting don?t have an answer to an alternative. Their cost of change can be seriously impaired by this, not just in monetary terms but also effort and risk. Yes it?s additional effort but it?s at the cheapest place by shifting left, in order to protect those expensive parts to test ( where systems need to come together to talk ) as that could be months of effort

yousafn
2021-05-04 23:53
And imo the best test code I have seen has lived alongside the code it tests, serving as living documentation for not just future you, but future teams.

hugo
2021-05-05 00:48
has joined #general

matt.fellows
2021-05-05 01:52
> It seems they don?t want to maintain additional tests. bingo


matt.fellows
2021-05-05 01:53
TL;DR - take existing tools, and ?upgrade? them into a contract testing workflow. You lose some of the guarantees in favour of a vastly simpler workflow, and in many cases, you don?t need to create new tests (you can re-use the stubs on the consumer side, and whatever functional testing you do on the provider)

matt.fellows
2021-05-05 01:54
If that sounds interesting, have a read of the above, and ping me about your thoughts. It?s something we?re investing more into in Pactflow over the next few months, but the initial feature is already available via API

brendan.j.donegan
2021-05-05 08:11
They're only 'additional' tests if you do it wrong. They should be replacing other kinds of testing you were probably already doing, just worse

brendan.j.donegan
2021-05-05 08:11
On the consumer side they should replace unit tests for the API layer

brendan.j.donegan
2021-05-05 08:12
On the provider side they should replace those silly 'integration' tests that verify your service is returning the 'correct' fields

brendan.j.donegan
2021-05-05 08:12
(except who says they are correct? The team that maintain the service :slightly_smiling_face:)

jadelong
2021-05-05 15:51
has joined #general

itzdavey
2021-05-05 19:27
@matt.fellows Is that what your kanban columns look like? :smile:

alexei.solcanu
2021-05-06 02:01
has joined #general


flubniewski
2021-05-06 07:50
Hey, I wanted to confirm with you guys following scenario - I'd like to run provider verification against big legacy app where it's difficult to stub its services etc., doest it make sense to run such verification against the actual staging app?

flubniewski
2021-05-06 07:50
what's the recommended approach?

flubniewski
2021-05-06 07:56
would it make sense to run such provider tests in some lambda making external calls to provider?

zonkor
2021-05-06 08:08
has joined #general

matt.fellows
2021-05-06 13:25
you can definitely do it, it?s just harder because of things like state (i.e. you?ll not be able to run tests in parallel, catch bugs at dev time, and will need to deal with state)

matt.fellows
2021-05-06 13:26
but if that?s the situation, what can you do!

wesleythomaswilliams
2021-05-06 13:32
Assume you have a REST API with a GET, POST and PUT that as a consumer, you want to create a contract for. Do all those interactions have to be in the same test class or can they be in separate ones, but there still be a single contract that details them all? (asking for a colleague)

matt.fellows
2021-05-06 13:41
In most languages they can definitely be separate, but I recall there maybe being some nuance in how you do it for the JVM.

matt.fellows
2021-05-06 13:42
there are a number of consumer interfaces and my knowledge is hazy. Pretty sure you can though

florian.mautendorfer
2021-05-06 14:04
has joined #general

wesleythomaswilliams
2021-05-06 14:23
Ok my colleague is using python, but finding that if he separates the interactions into individual tests, his pact file is overwritten each time

wesleythomaswilliams
2021-05-06 14:23
Ignore that, he's worked it out :smile:

john.mcnulty
2021-05-06 16:49
has joined #general

matt.fellows
2021-05-06 23:59
Latest version of the Thoughtworks tech radar talks about API expand and contract and contract testing: https://www.thoughtworks.com/radar/techniques?blipid=202104022

bethskurrie
2021-05-06 23:59
We should have an FAQ on that.

bethskurrie
2021-05-06 23:59
Or a page.

bethskurrie
2021-05-07 00:01
Turns out it's in there, but it's not immediately obvious https://docs.pact.io/faq#how-can-i-handle-versioning

abubics
2021-05-07 00:47
hehe yeah, it wouldn't be too well-principled if you couldn't (de)compose them :sweat_smile: if all platforms/bindings don't have options yet, they should eventually :pray:

abubics
2021-05-07 00:49
I think TW has been keen on CDC for a while (they used to maintain Pacto?), so it's not too surprising :party_parrot: nice to be linked to :sunglasses:

uladzislau_danilchyk
2021-05-07 11:22
Thanks @matt.fellows

agarwal.akash333
2021-05-10 00:21
Hello. Is it a questionable practice/even an option to share a pact file between multiple clients of the same backend? For e.g. between an android and an iOS app? This way, only the pact tests would be repeated on both platforms, not the generation of the pacts itself.

matt.fellows
2021-05-10 00:24
yes, it?s a questionable practice

matt.fellows
2021-05-10 00:24
Now you don?t know exactly what fields each uses at what point in time

matt.fellows
2021-05-10 00:25
I may be wrong about this, but in general, I?ve found that usually Android and iOS versions of apps aren?t always at complete feature parity with one another, because of all kinds of reasons (some features are easier/harder to do, team dynamics such as size, hiring, leave etc.) and other market factors

matt.fellows
2021-05-10 00:26
Even if they _are_ at feature parity, there may be different needs each app has. For instance, there may be apple/android specific features which use different APIs/fields (e.g. apple pay)

tjones
2021-05-10 00:27
Remember that a pact test isn't about describing your API, it's about describing the actual calls that the client makes, and testing that it can understand the actual responses. You'll miss this feature if you share the pact

agarwal.akash333
2021-05-10 00:35
I see, thanks for the responses! I quite agree with all of it. We?re still looking to understand if it at least is an option, since our apps at the moment are quite plain. 90% of the stuff happens on the micro-services and the SDKs generally stay on par with each other.

matt.fellows
2021-05-10 02:27
It's that 10% that worries me. Bugs usually happen on areas of the app not well understood, like edge cases

agarwal.akash333
2021-05-10 03:50
IMO that 10% would be something that can be overwritten (still not sure if sharing pacts is possible between clients), without having to duplicate the pact generation for the remaining 90%

matt.fellows
2021-05-10 03:55
Yeah. We don't have any way of reliably doing that, but keen to hear your thoughts

abubics
2021-05-10 04:11
I'm not really sure how you'd share the contract without duplicating the tests for each platform. If you don't generate the contract from exercising your code, how do you know it actually conforms?

matt.fellows
2021-05-10 04:16
I think one of the biggest mistakes people make with Pact, is thinking of it as a means to generate a contract. The contract itself is a means to an end, not the end itself. The tests are what matter, because they represent reality. By way of analogy, it would be like asking if it's ok to reuse the junit tests from your android app on your iOS project because they do the same thing

agarwal.akash333
2021-05-10 04:23
@abubics if you read my message above again: > This way, only the pact tests would be repeated on both platforms, not the generation of the pacts itself.

matt.fellows
2021-05-10 04:24
Are you saying retain the tests, but send the same contract to the provider for verification? Could you pls elaborate?

abubics
2021-05-10 04:42
Yeah, I'm not sure sure what you're trying to optimise out. If the consumers are ever not identical, you want to know which expectations are coming from which. If you wanted to, for example, merge them together, you lose specificity & reasoning ability. If the duplicate interactions are taking a long time to run, that's a separate scenario, with other potential approaches.

abubics
2021-05-10 04:42
Soz, would've sent this earlier, I got a kernel panic while typing lmao

agarwal.akash333
2021-05-10 04:43
Yeah, so you?d: 1. Generate a pact (JSON file) from say, the android client. Write tests. 2. Copy the same pact(s) manually or via broker to another client, say iOS, which has it?s own tests to make sure that client adheres with the pact. Optionally, one may wanna modify a pact to cover the 10% changes using a bunch of identifiers, or add new. *This client will have its own tests too, pretty much the same as for the android client.* 3. Finally, replay both copies of the pact against the providers using the existing flow

abubics
2021-05-10 04:49
Maybe I missed it in my quick read of this thread, but what's the problem you're trying to solve by reducing 2 contracts to 1?

agarwal.akash333
2021-05-10 04:51
Generating an identical contract spec twice for 2 different clients/languages

abubics
2021-05-10 04:56
If you're running the test anyway, the generation is free. How is generating 2 contracts hurting you?

agarwal.akash333
2021-05-10 05:20
How is the generation free? You still have to write/maintain code for generating the pacts across both clients, which get tremendously demanding with changing requirements/large number of simple/complex APIs.

abubics
2021-05-10 05:28
Generation is a side-effect of running the pact tests. Maybe it's not the generation that is hurting you? > which has it?s own tests to make sure that client adheres with the pact What kind of tests are these? If they're not contract tests, how do you know they're not drifting from the other platform's contract?

abubics
2021-05-10 05:29
(I kinda feel like my line of questioning might seem a bit patronising or just missing the point. I'm genuinely trying to understand your situation, but I'm not sure how else to iron out which bits we're not aligning on.)

matt.fellows
2021-05-10 06:12
> Copy the same pact(s) manually or via broker to another client, say iOS, which has it?s own tests to make sure that client adheres with the pact. that?s the bit I?m confused about. How do you do that, without using Pact itself?

agarwal.akash333
2021-05-10 06:25
1. Assuming this is the mock provider: ```@Rule public PactProviderRule provider = new PactProviderRule("ExperimentService", "localhost", 1234, this);``` 2. Assuming you have a pact generator like so: ```@Pact(provider = "ExperimentService", consumer = "ExperimentServiceConsumer") public RequestResponsePact experimentServicePact(PactDslWithProvider builder) throws JSONException { // ... return builder .given("Everything is working fine") .uponReceiving("a request for json data") .path("/api/experiments") .method("GET") .willRespondWith() .status(200) .headers(RESPONSE_HEADERS_FOR_VALIDATION) .body(experimentsPactDslJsonBody) .toPact(); }``` 3. you have a test for that fragment: ```@Test @PactVerification(value = "ExperimentService", fragment = "experimentServicePact") public void validateExperimentServicePact() throws IOException { // actual unit tests that use a HTTPClient to talk to the PactProviderRule }``` Step 2 is what?s super time consuming and ideally, you won?t do on the other client, and instead would replay the requests using the Pact file already generated from Android on iOS and run finally run your assertions against it. The `RequestResponsePact` generated in step 2 is actually never used explicitly when running the tests, so it could be something that?s supplied externally from a JSON IMO.

agarwal.akash333
2021-05-10 06:28
There is a major assumption here and I?m quite confident that this: ```@Test @PactVerification(value = "ExperimentService", fragment = "experimentServicePact")``` doesn?t actually contribute to the pact file(s), simply makes sure that the request and response bodies are indeed what?s expected

tarunmehrotra3
2021-05-10 06:31
has joined #general

abubics
2021-05-10 08:09
Right, if you wanted to do that, you'd still need a way to tell Pact which request it should be expecting, so it can respond with the right stub data. So you'd only lose about half of step 2. Interesting concept, it's not really an intended feature (afaik). You could theoretically hook up a standalone mock server with the existing contract, but you'd have to build replacement code to tell it which interaction you're testing.

scott.riley111
2021-05-10 10:03
Makes sense

scott.riley111
2021-05-10 10:04
Applies to environments with lots of potential versions - you only really care if all ?bad?/incompatible versions are completely gone, not that you might have some good ones

agarwal.akash333
2021-05-10 10:19
Yeah I?m not aware of the internals quite frankly. Glad to have realised however that this isn?t likely something that?s supported as of yet

jbecker
2021-05-10 16:31
has joined #general

james.wettenhall
2021-05-11 04:54
has joined #general

eduardo.marques
2021-05-11 09:19
has joined #general

al8x.romanov
2021-05-11 13:09
has joined #general

ron.aharoni
2021-05-11 14:11
Hey all, Had some use case I wanted to discuss. Recently at my company we extracted a large component from a monolith to its own service. Naturally this component has quite a few external interactions with other services over http. We?d like to start adding coverage to that service, and make use of pact in order to create simple mock servers. Of course, this is just a first step in adoption of the more classical usage of pact in the company. Would be happy to hear if anyone has experience with using pact as a mock server. And another specific question I had, can we ensure a stable port for each mocked service (when using pact cli)?

cc
2021-05-11 14:56
has joined #general

dabfleming
2021-05-11 15:56
Hey, I've been looking at Consumer Version Selectors... I would like to be able to say "Please attempt to verify provider P against `main` (latest) and any unverified contracts (latest) for consumer C" but I don't think there's a way to specify this currently. Is that correct?

jr.jenks
2021-05-11 21:46
has joined #general

matt.fellows
2021-05-11 22:41
Pending pacts should collect the unverified ones

matt.fellows
2021-05-11 22:41
You can use the mock service for that purpose

matt.fellows
2021-05-11 22:42
and yes, the mock service has an option to specify a port, what have you tried so far?

matt.fellows
2021-05-11 22:42
Your use case I would say is fairly standard, unleses I?m missing something

tonynguyenit18
2021-05-11 22:51
@matt.fellows I think it should be `WIP` rather than `Pending` ?

matt.fellows
2021-05-11 23:02
Apologies, you?re right

matt.fellows
2021-05-11 23:02
(you probably want both though)

dabfleming
2021-05-11 23:13
Yeah, this might work for us, thanks.

tonynguyenit18
2021-05-11 23:24
@dabfleming There is one minor issue (at least to me), if you are checkout Consumer and Provider both on feature branch, `WIP` does not support. We discussed here: https://pact-foundation.slack.com/archives/C9VBGLUM9/p1620349213299100

sammomichael
2021-05-12 02:27
has joined #general

tony.foster
2021-05-12 03:44
has joined #general

matt.fellows
2021-05-12 07:40
This is worth sharing here (I hope!) :point_right: https://pact-foundation.slack.com/archives/CKG0YV5EF/p1620805006002700

jan.businsky
2021-05-12 09:10
has joined #general

ron.aharoni
2021-05-12 12:34
I tried using the pact jvm server. it receives a range of ports, and if I understand correctly, it assigns randomly from the range each time a new contract is registered? the command from the docs, `docker run -d -p 8080:8080 -p 20000-20010:20000-20010 uglyog/pact-jvm-server`

matt.fellows
2021-05-12 12:50
ah, does the JVM server take a Pact file?

matt.fellows
2021-05-12 12:50
I may not understand your use case very well. But most of the mock services have a way to control the port. e.g. from JUnit tests you can, and the other CLI tools to



matt.fellows
2021-05-12 12:52
In any case, if you?re doing that, that means you?re probably building your own DSL/implementation. Any reason you can?t use the JUnit or raw interfaces?


ron.aharoni
2021-05-12 13:31
i?ll check it out, it seems this code: ``` RequestResponsePact pact = ConsumerPactBuilder .consumer("Some Consumer") .hasPactWith("Some Provider") .uponReceiving("a request to say Hello") .path("/hello") .method("POST") .body("{\"name\": \"harry\"}") .willRespondWith() .status(200) .body("{\"hello\": \"harry\"}") .toPact(); MockProviderConfig config = MockProviderConfig.createDefault();``` without running the consumer test itself is what i?m looking for and I guess some constructor of MockProviderConfig can receive a port as input

parveenbanu
2021-05-12 14:35
Just need a information. Can we use s3 repo in place of pact broker?

phil.endsley
2021-05-12 14:42
Yes. https://docs.pact.io/getting_started/sharing_pacts/#4-publish-pacts-to-amazon-s3 Not sure what the typical use cases are for not using Pact Broker, but just wanted to add that Pact Broker also provides powerful APIs in addition to just being a contract repository

lreisch
2021-05-12 19:23
has joined #general

bethskurrie
2021-05-12 23:56
@parveenbanu like Phil said, you can use S3 for exchanging contracts, but you can't then use can-i-deploy to make sure your contracts are verified before you deploy, so you won't get very far in building contract testing into your automated CI/CD workflow.


bethskurrie
2021-05-12 23:57
Yeah, this has to be fixed @tonynguyenit18. It's on my list.

tjones
2021-05-13 01:09
If you're asking because you don't want to set up and maintain your own broker, then you might want to check out the hosted broker run by the excellent people over at https://pactflow.io - I don't work for them, but I have used it, and it's very straightforward to set up.

jorge.curima.corp
2021-05-13 01:37
has joined #general

parveenbanu
2021-05-13 04:50
Thanks for all your replies. Will talk to my management with all your valuable inputs.

anh.evizi.test
2021-05-13 05:56
has joined #general

gupta.ratnesh9
2021-05-13 06:38
Hi

gupta.ratnesh9
2021-05-13 06:40
How can we write pact for negative cases like cases that return 4xx and 5xx error code in response

gupta.ratnesh9
2021-05-13 06:41
Like in swagger file have a request with multiple responses

matt.fellows
2021-05-13 07:32
What have you tried so far?

matt.fellows
2021-05-13 07:32
You can specify the status code in your test, including the negative cases you described

matt.fellows
2021-05-13 07:33
The main trick is making sure your API client that makes the call doesn't throw an exception during the test when it gets back a 4xx/5xx (or that you properly catch/expect it)

yka259
2021-05-13 08:22
has joined #general

joshibharat
2021-05-13 11:43
has joined #general

smankala
2021-05-13 20:55
has joined #general

tjones
2021-05-13 23:30
Yes, you can do this with Pact. There are examples in each language in the documentation and associated repositories

martin.pelikan
2021-05-14 06:48
has joined #general

martin.pelikan
2021-05-14 08:19
Hi all, I am working on PoC of Contract testing with http://pact.io and hopefully got some understanding of Pact by reading http://pact.io docs and watching Matts videos. It seems to me the best fit for contract testing is with API Evolution (identify fields that are not used and remove them - even mandatory) and Code first API approach. In our case, we do Contract First and store it into central repo. Each change results into new minor version, all minor versions are backwards compatible. Breaking change results in new major version, on new version path. APIs are accessible via API Gateway. How can I leverage pact to the greatest benefits? From my point of view, with consumer contracts, providers get extra guarantee their change does not break a contract (even though breaking changes should not slip through PRs). Schema testing could help me identify version drift between APIs published by the service itself and on API Gateway. Is there a way for provider contracts? (theoretically - providers contract is entire OAS - all fields could and should be returned in one scenario or another). edit: service is written in Java and data classes are generated from OAS. Thus API Provider is always compatible with published Schema.

joao_glorioso
2021-05-14 08:41
has joined #general

abubics
2021-05-14 10:25
Schema verification can also be helpful, just be careful of the differences (there's some explanation https://docs.pact.io/faq/, search for "schema").

matt.fellows
2021-05-14 10:25
So #1 ?contract first? just means design first, and in your case you?re documenting the interface with an OAS . I have a whole long article about https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-1/ (I need to write the shorter version). TL;DR - you can quite easily not violate an OAS contract (i.e. it remains backwards compatible) but break actual functionality. Contract testing with Pact picks up such cases

abubics
2021-05-14 10:26
When you say "contract-first", where is that contract coming from?

matt.fellows
2021-05-14 10:26
Timing Andras! :slightly_smiling_face:

abubics
2021-05-14 10:26
You have the better links :sunglasses:

matt.fellows
2021-05-14 10:27
That being said Martin, it doesn?t mean it?s not a valid approach, it?s just that you should be aware of the trade-offs

matt.fellows
2021-05-14 10:29
There are other benefits of the consumer driven contract testing model. For one, you get visibility into actual usage of your interface, which is nice, because in many cases you can do away with versioning and all of the shitty side-effects of that (I worked at a bank where there were close to 10 versions of one API, and that was just a pain in the butt to deal with).

matt.fellows
2021-05-14 10:29
Andras? link is useful to explore some of the other benefits of contract testing

matt.fellows
2021-05-14 10:31
That being said, those caveats aside, we are exploring (at Pactflow) the idea of https://pactflow.io/blog/bi-directional-contracts/. That migt better suit your use case (but note it?s a Pactflow only feature)

martin.pelikan
2021-05-14 11:47
@matt.fellows @abubics thanks for replies! Very helpful. Correct me if I am wrong, but Consumer and Provider should generate their pact contracts independently. If OpenAPI spec has abstract class there, Consumer A might use ClassA as a request parameter, Consumer B classB as a request parameter and Provider must has really thorough set of tests to cover for both. That imposes quite a lot of pressure on Provider (which in turn will be good) to have all those cases covered, not only by testing the individual classes but its entire fow. Schema tests are really simple with downsides. This might serve a role to ?check? API Gateway has the latest/agreed version of an API. You are right about multiple API versions - the more. think about role of Pact here, the more I like it. Sadly, to drop API (semantic versioning), all parties would need to implement Contract testing. Which is probably not simple in larger organisations :slightly_smiling_face:.

matt.fellows
2021-05-14 11:54
> Correct me if I am wrong, but Consumer and Provider should generate their pact contracts independently. What do you mean by that - with bi-directional or standard ?Pact? testing? (it is the case for bi-directional though, yes)

matt.fellows
2021-05-14 11:59
> You are right about multiple API versions - the more. think about role of Pact here, the more I like it. Sadly, to drop API (semantic versioning), all parties would need to implement Contract testing. Which is probably not simple in larger organisations yes, that is true. That?s where we see bi-directional contracts being helpful. In many cases, it may be sufficient. But it?s definitely a really nice approach to transition to a full Pact model, because you can more quickly get some level of contract testing achieved. For instance, with bi-directional contracts, you get all of the benefits of the OAS testing you were doing, plus the ability to discover which APIs/fields each consumer is using and the ability to know when a consumer is safe to release a change relating to a new feature.

ashok.jan31
2021-05-14 12:25
has joined #general

martin.pelikan
2021-05-14 12:31
>  Correct me if I am wrong, but Consumer and Provider should generate their pact contracts independently. _What do you mean by that - with bi-directional or standard ?Pact? testing? (it is the case for bi-directional though, yes)_ I meant ?standard? Pact testing - My understanding of ?standard? Pact- Imagine provider has Identity API, using abstract class Identity, implemented by two classes - UserIdentity and OrgIdentity. Provider writes its own set of unit tests, resulting in contracts for both classes. ConsumerA, using only UserIdentity, writes a unit test with Mock (expecting UserIdentity object in some form as a response from Mock server) and ConsumerB does the same for OrgIdentity. Now there should be three contracts and two conversations - ConsumerA(UserIdentity)---Provider and ConsiumerB(OrgIdentity)---Provider. Pact them compares subsets of Consumers A&B against providers contract and providers contract (subset) is compared against OpenAPI Spec as a whole.

matt.fellows
2021-05-14 12:36
> Provider writes its own set of unit tests, resulting in contracts for both classes what do you my by ?contract? here?

martin.pelikan
2021-05-14 12:36
pact contract - generated json file

matt.fellows
2021-05-14 12:36
In Pact, the provider doen?t generate a contract

matt.fellows
2021-05-14 12:36
it _verifies_ one or more consumer contracts

matt.fellows
2021-05-14 12:37
What you?re describing is more the way our bi-directional feature works

matt.fellows
2021-05-14 12:37
The consumers work in the way you describe (both generate a contract). The provider publishes an OAS. We then check that the consumer contracts are a valid subset of the provider OAS file

martin.pelikan
2021-05-14 12:47
Thanks Matt, I got somehow confused by looking Schema-based contract testing site thinking it?s something else. All clear now. I will take deeper look into Pactflow! Bi-directional feature sounds very promising :slightly_smiling_face:.

matt.fellows
2021-05-14 12:48
All good!


matt.fellows
2021-05-14 12:49
For bi-directional, DM me offline if you want to know more and I can share some stuff with you

gusfisha
2021-05-14 19:52
has joined #general

keithgutfreund
2021-05-14 20:13
has joined #general

keithgutfreund
2021-05-14 20:14
Hello, I have a question about billing. If I am on a monthly plan, can I cancel at any time?

matt.fellows
2021-05-14 22:39
Hi Keith, might best to ask Pactflow questions in #pactflow going forward (this is a general slack workspace, we?re working on making all of this a bit clearer).

matt.fellows
2021-05-14 22:39
but yes, monthly plans have no commitment

k.gutfreund
2021-05-15 03:47
has joined #general

keithgutfreund
2021-05-15 03:48
Thank you

bethskurrie
2021-05-15 08:26
Hi pact people. User research question. I'm adding support for allowing failing pacticipants to be ignored eg. ```pact-broker can-i-deploy --pacticipant foo-consumer --version 1 --to prod --ignore baz-provider```

bethskurrie
2021-05-15 08:27
Here is the output when the app can't be deployed because of a failed verification.

bethskurrie
2021-05-15 08:28
Here is the output when the failing pacticipant is ignored with `--ignore baz-provider`

bethskurrie
2021-05-15 08:29
My question is - is it helpful or just distracting to have the ignored text in there. `The verification for the pact between version 1 of foo-consumer and the latest version of baz-provider with tag prod (4) failed [IGNORED]`

bethskurrie
2021-05-15 08:34
Here's a tweaked variation with "Ignoring: " at the start of the sentence instead of the end.

bethskurrie
2021-05-15 08:37
Here's what it looks like without the "Ignoring: ...." message.

matt.fellows
2021-05-15 11:35
The version without the extra text I think is fine. The table view is quite succinct, I don?t think it adds any more useful information. The `[ignored]` in the success column is great.

bethskurrie
2021-05-15 21:00
I was leaning that way myself. But I'd already done the work to calculate the ignored messages, so I wanted to be sure before ditching them! Yet again, a lesson to start with the UI (consumer) first!

bethskurrie
2021-05-15 21:22
One last attempt. Is a shorter "Ignoring.." better or worse than no "Ignoring..." text

bethskurrie
2021-05-15 21:27
Nah, I'll leave it out. Keep it simple.

bethskurrie
2021-05-15 22:18
Thread for feedback on dry-run options -->

bethskurrie
2021-05-15 22:19
Show "dry run" notification at start.

bethskurrie
2021-05-15 22:19
Show "dry run" notification at end.

bethskurrie
2021-05-15 22:19
Show "dry run" notification" at end and uncolor the rest of the text.

bethskurrie
2021-05-15 22:19
Prefix each line with `[dry-run]`

bethskurrie
2021-05-15 22:20
Prefix each line with a yellow `[dry-run]`

tonynguyenit18
2021-05-16 00:53
Do we have this option? Simple pass and fail icon for each

bethskurrie
2021-05-16 04:52
That's a possibility. Right now, I'm focussed on showing the difference between a dry run (where it will always pass) and a normal run (where it will exit with an error if there are failures).

bethskurrie
2021-05-16 20:37
@scott.riley111 exactly

bethskurrie
2021-05-16 22:33
Hands up everyone who has looked at the output of a failed can-i-deploy command and gone "what on earth do I do now?" It currently tells you what is wrong, but it doesn't tell you how to fix it. I want to fix _that_. Take that hand that you raised and click on this link to give me your input: https://github.com/pact-foundation/pact_broker/discussions/431

siegcollado
2021-05-17 05:03
has joined #general

simon.thomas1978
2021-05-17 08:53
has joined #general

simon.thomas1978
2021-05-17 08:58
Hi Not sure if this is the correct place but here goes anyway. Can you define a pact contract between a React client and a dotnet signalr backend? I have been looking at the documentation and it doesnt seem to mention anything on how do this. The only documentation I have come across is the following https://github.com/pact-foundation/pact-js/tree/master/examples/messages for which I dont think its intended for SignalrR implementations. Any help or advice greatly appreciated Regards Simon

abubics
2021-05-17 09:03
Hi Simon :wave: I think you're on the right track. > Furthermore, the web has things like WebSockets which involve bidirectional messaging. > Pact supports these use cases, by abstracting away the protocol and focussing on the messages passing between them. The async messaging feature is probably the closest to what you want :slightly_smiling_face:

gusfisha
2021-05-17 09:34
Hello I am doing research on consumer-driven contract testing in microservice systems for my thesis. Therefore, I?m looking for industrial / production-ready open-source projects that use consumer-driven contract testing. My search results from github were not really satisfactory as they returned mostly examples, toy projects, tutorials. Do you have any suggestions and links? Are you working with a such a (FOSS) project? I would appreciate any tips. Thank you.

simon.thomas1978
2021-05-17 09:39
As part of the PACT Specification Version 3.0 you can test services that communicate via event streams and message queues, which I think includes signalr / websockets. See https://github.com/pact-foundation/pact-specification/tree/version-3 Although PACT JS implements V3 of the specification PACTNET is still on V2, so we can generate the contracts on consumer side (React JS) but I believe we cannot test on the provider side (dotnet Signalr) yet. See https://github.com/pact-foundation/pact-jshttps://github.com/pact-foundation/pact-net There is a project outside of PactNet which implements V3 see https://github.com/Mattersight/pact-net-messages. But this looks as though it hasnt been touched for the last 3 years, so I am a bit apprehensive on using this.

matt.fellows
2021-05-17 09:40
There is a branch of the code that you could look at


matt.fellows
2021-05-17 09:41
All you would need to do essentially is wrap your messages in an HTTP interface so that the CLI can call into them

simon.thomas1978
2021-05-17 10:01
"There is a branch of the code that you could look at" - you mean https://github.com/pact-foundation/pact-net/tree/message-pact-2. This one looks as though it hasn't been actively touched in about a year. The CLI approach looks interesting but would prefer to implement it as unit test as its simpler to manage

keimiokamoto
2021-05-17 10:36
has joined #general

fabian.feary
2021-05-17 11:52
has joined #general

josh.brangwyn
2021-05-17 12:19
has joined #general

matt.fellows
2021-05-17 13:11
Yes it's been in PR state for a while, albeit I'm not sure that means it's not usable.

matt.fellows
2021-05-17 13:12
We're currently working to transition to a new contributor team so hopefully it'll be picked up again soon

matt.fellows
2021-05-17 13:13
The CLI approach might still be best, if not ideal. Happy to give you pointers, unless you're willing to help get the PR up to scratch and merged in?

xiao.liang
2021-05-17 16:41
has joined #general

tomaszjdul
2021-05-17 17:23
has joined #general


matt.fellows
2021-05-18 11:09
@artur works on an OSS project that is incorporating Pact, albeit there are some features lacking to fully support his needs

matt.fellows
2021-05-18 11:09
Do you need OSS only projects?

artur
2021-05-18 11:37
@gusfisha yes, jankari.tech did setup pact tests for owncloud SDK https://github.com/owncloud/owncloud-sdk this is the SDK that is used for the new webUI of owncloud https://github.com/owncloud/web The way the tests are run there is bending a bit what pact is supposed to be used for but I think it gives us valuable feedback and makes some things easier

gusfisha
2021-05-18 11:43
@artur thank you. I?ll have a look. @matt.fellows Any project that is using pact and has its source code accessible would be interesting.

matt.fellows
2021-05-18 12:20
Thanks Artur!

matt.fellows
2021-05-18 12:20
Hartmut - I?m not aware of any, but it?s late here - I might have better ideas in the morning :slightly_smiling_face:

bhattacharyyasom
2021-05-18 14:05
has joined #general

bhattacharyyasom
2021-05-18 14:06
Hello , I have been going through the documentation to put together a webflux provider side test case and am unable to execute it. I am trying to write a provider side contract test using PACT for a Spring web flux application. I am not using the Route functions to functionally create the API. I am using the @RestController annotations in code. Also I do not have any spring webmvc dependency in my application.

samuel.verstraete
2021-05-18 15:52
so we have an integration of pact tests in our .netcore projects. the developers are all running on windows so we added the PactNet.Windows package to the PackageReferences. On the build we are building to the linux target so we would apparently need the PactNet.Linux package but apparently PackageReferences do not support Conditionals based on the runtime... how would you typically advise how to fix this

lalit210784
2021-05-18 17:55
has joined #general

zaxosdimi
2021-05-18 22:14
has joined #general

matt.fellows
2021-05-18 22:44
Might be worth asking in #pact-net

matt.fellows
2021-05-18 22:44
Might be worth asking in #pact-jvm

matt.fellows
2021-05-18 22:44
ah, you have. thx

viktor.trako
2021-05-19 15:45
has joined #general

abdel.akkoub
2021-05-19 17:27
has joined #general

akrala
2021-05-19 21:22
has joined #general

bethskurrie
2021-05-19 22:20
PR to fix the issue Tony mentioned soon to be merged @dabfleming

mazi.fayazfar
2021-05-19 22:23
has joined #general

tjones
2021-05-20 04:44
I really like the `[dry-run]` option

tjones
2021-05-20 04:45
It will be clear even in environments where colours won't display correctly (looking at you, codebuild)

tjones
2021-05-20 04:46
I also think that `Dry run enabled - ignoring any failures` would be best in green

tjones
2021-05-20 04:46
Because it's "passing" the tests

daniel.qu
2021-05-20 18:03
has joined #general

vijay.chawla
2021-05-21 08:37
has joined #general

tim.walter
2021-05-21 09:12
has joined #general

ankit.laddha
2021-05-21 14:03
has joined #general

dimundo
2021-05-21 14:09
has joined #general

include.melaz
2021-05-22 13:15
has joined #general

uddhavchopade
2021-05-23 08:32
has joined #general

bethskurrie
2021-05-24 00:45
Thanks @tjones I was leaning to the `[dry-run]` one myself.

przemek.sech296
2021-05-24 05:45
Hi, I?m starting a new subscription, what is Company URL?

bethskurrie
2021-05-24 05:45
Hi @przemek.sech296. This is the channel for general Pact users. You want the #pactflow channel.

bethskurrie
2021-05-24 05:45
I can tell you that if you don't have a company with a website, just don't fill it in.

przemek.sech296
2021-05-24 05:46
something is blocking the submit button :thinking_face:

bethskurrie
2021-05-24 05:47
Have you filled in your domain?

bethskurrie
2021-05-24 05:47
You get your own subdomain.

tjones
2021-05-24 05:48
(I think it's filled in with `Domain`)

przemek.sech296
2021-05-24 05:48
So the whole form is like this

bethskurrie
2021-05-24 05:49
Do you really want that subdomain?

przemek.sech296
2021-05-24 05:49
I refreshed the page, filled details again and it allowed me to submit

przemek.sech296
2021-05-24 05:50
I do not know what I want @bethskurrie, I?m just starting the tutorial :stuck_out_tongue:

bethskurrie
2021-05-24 05:50
Pretty sure you don't want that domain, but you can always make a new one. It will do for now!

przemek.sech296
2021-05-24 05:51
Possible, but why I do not want that domain?

przemek.sech296
2021-05-24 05:51

bethskurrie
2021-05-24 05:51
Ah! Now I understand.

bethskurrie
2021-05-24 05:52
"domain" is a very overloaded term :laughing:

przemek.sech296
2021-05-24 05:53
Thanks for your time :slightly_smiling_face:

lukasz.wlosek
2021-05-24 08:03
has joined #general

komathy_priya_dhanas
2021-05-24 09:26
has joined #general

laxmi.somni508
2021-05-24 10:48
Hello Folks, Where could I get training material & kickstart examples with explanation, for someone new to Scala/playframework & pact (especially on provider side)? Thanks

matt.fellows
2021-05-24 10:52
mmm maybe #pact-scala-itv?

nh.salah
2021-05-24 11:46
has joined #general

erinc1915
2021-05-24 16:11
has joined #general

nzarate
2021-05-24 18:11
has joined #general

jonathan.arreola
2021-05-24 21:20
has joined #general

jonathan.arreola
2021-05-24 21:22
Hello, learning about pact testing from Joel Whalen over at Zoro US

cesar.consultorjr
2021-05-24 21:39
has joined #general

matt.fellows
2021-05-24 21:41
Welcome!

matt.fellows
2021-05-24 21:41
(and thanks Joel!)

joel.whalen
2021-05-24 21:52
anytime :slightly_smiling_face:

gdfesta
2021-05-25 00:44
has joined #general

utsavk3210
2021-05-25 08:37
has joined #general

daniel.cardinha
2021-05-25 10:06
has joined #general

daniel.cardinha
2021-05-25 10:13
Hello, what is the best channel to pose questions about the basic pact workflow?

matt.fellows
2021-05-25 10:23
Might as well ask here. Worth sharing what docs you?ve looked at specifically that might be confusing or that we need to make more visible. Also if you haven?t yet, worth doing a search in the workspace in case the question has already been asked

daniel.cardinha
2021-05-25 10:24
Thanks, will do

dan.haughey
2021-05-25 14:34
has joined #general

vince.lee
2021-05-25 14:36
has joined #general

gupta.ratnesh9
2021-05-25 15:57
How we can achieve the highlighted point

gupta.ratnesh9
2021-05-25 15:58
If anyone have any implementation reference most welcome

pact544
2021-05-25 16:01
has joined #general

fnguyen
2021-05-25 19:28
Never used but I think in your pact you can specify a provider state. Then you have a provider state middleware that is called by pact to put your service in the state you want before the request is served. For example look at https://docs.pact.io/implementation_guides/net/readme#service-provider

matt.fellows
2021-05-25 20:43
What language?

matt.fellows
2021-05-25 20:43
Most languages have examples in them and we also have a bunch of tutorials

matt.fellows
2021-05-25 20:43
See howtolearn

2021-05-25 20:43
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

shlomi
2021-05-25 22:41
has joined #general

marko.justinek
2021-05-26 00:47
Something like this? https://github.com/surpher/pact-swift-examples/blob/main/Pact-iOS-Example/Pact-iOS-ExampleTests/Pact_iOS_ExampleTests.swift Most of tests hit the same `/api/users/` endpoint, but have different states defined and test the behaviour based on those. Different language implementations have different ways of setting these states, so look at the examples for the framework you?re using.

gupta.ratnesh9
2021-05-26 05:16
Do we have same implementation for java?

marko.justinek
2021-05-26 05:27
I am not sure whether that was a question or a statement. Either way, you will need to look into Pact example projects for Java. I only deal with Swift.

gupta.ratnesh9
2021-05-26 05:30
I was just asking for java implementation but no worry. Thanks for your support:+1: @Marko

gupta.ratnesh9
2021-05-26 05:33
I was asking in terms of java

gupta.ratnesh9
2021-05-26 05:46
Thanks for your support @tjones

tjones
2021-05-26 07:07
Welcome! Let us know if you have any other questions

gupta.ratnesh9
2021-05-26 07:14
Yeah sure

raquel.bautista
2021-05-26 09:38
has joined #general

aubilla
2021-05-26 09:52
has joined #general

vishnuprakash323
2021-05-26 10:46
has joined #general

vishnuprakash323
2021-05-26 11:06
Hi folks, I am new to pact and contract testing. I am checking on using pact for contract testing as well as a mock server. Is it wise to use pact for mocking as well? I could see Local Pact HTTP stub server as part of open source pact and a hosted stub as part of Pactflow. What is the difference between them? Any leads will be helpful. Thanks

greg595au
2021-05-26 11:19
Hi Vishnu. PactFlow is the commercial tool with cloud scaling. They are similar in that we "configure" a stub (a bit like swagger). PactFlow API is cloud based, the http://PAct.io opensource is local to your development or build environment (local or cloud/remote). Let me know if you need more

vishnuprakash323
2021-05-26 11:36
Thank you Greg for the reply. So there is no difference in core features other than how it is deployed and scaled. Is my understanding correct?

greg595au
2021-05-26 11:39
THat is my understanding, yes

vishnuprakash323
2021-05-26 11:39
Thank you very much Greg

vishnuprakash323
2021-05-26 11:39
:slightly_smiling_face:

greg595au
2021-05-26 11:40
just while here.. I am one of the new .NET maintainers... thanks for asking about Pact :slightly_smiling_face:

vishnuprakash323
2021-05-26 11:42
oh nice. happy to know that:thumbsup:

dimundo
2021-05-26 11:45
so, for websocket testing, one must create some proxy ?

rob.caiger
2021-05-26 11:54
has joined #general


matt.fellows
2021-05-26 12:13
There are more differences than just hosting

matt.fellows
2021-05-26 12:15
The main new direction in terms of commercial only features is bi-directional contracts


vishnuprakash323
2021-05-26 12:56
okay. Thankyou @matt.fellows


lio.lunesu
2021-05-26 17:55
has joined #general

nahuel.dallavecchia
2021-05-26 20:24
has joined #general

mathew.baltes
2021-05-26 23:33
has joined #general

stephen.leece
2021-05-26 23:44
has joined #general

matt.fellows
2021-05-27 07:55
@bas is doing a talk on contract testing on June 22 (CET) :point_right: https://pact-foundation.slack.com/archives/C01NKLH8KS4/p1622098563001200

james_fraser
2021-05-27 09:23
has joined #general

mostafa.zaher
2021-05-27 10:13
has joined #general

utsavtiwary10
2021-05-27 10:53
has joined #general

hliulka15
2021-05-27 15:53
has joined #general

jarmy
2021-05-27 18:17
How can you tell which pact-specification a particular pact implementation supports? I ask because we have a contract generated within a javascript project using ``` "@pact-foundation/pact": "^9.11.1", "jest-pact": "^0.5.2"``` But when we try to verify it with a provider using `http://au.com.dius.pact.provider/lein "4.1.20"`, we get the following message: ```% ./lein with-profile pact pact-verify Verifying a pact between :graphql and :sod [from URL https://pact-broker.docker.savagebeast.com] WARNING: Pact file has no interactions```

dimundo
2021-05-27 19:45
by error you have (almost) empty pact file, where version doesn't matters

jarmy
2021-05-27 20:30
I don't think that's the case. If I change the consumer provider pairing to two JVM services, I get a similar response: ```Verifying a pact between :pegasus and :hestia [from URL https://pact-broker.docker.savagebeast.com] WARNING: Pact file has no interactions```

uglyog
2021-05-27 22:57
Have you looked at the Pact file?

jarmy
2021-05-27 23:00
Aha, I just did ``` "metadata": { "pactSpecification": { "version": "2.0.0" }``` Does this mean that pact lein 4.1.20 doesn't support 2.0.0 specification?

jarmy
2021-05-27 23:02
The contract does indeed have `interactions` ```{ "consumer": { "name": "graphql" }, "provider": { "name": "sod" }, "interactions": [ { "description": "POST request for search on demand results", "request": { "method": "POST", "path": "/sod/jsonrpc", "headers": { "Accept": "application/json" }, "body": { "jsonrpc": "2.0", "method": "sod-v3.search", "params": [ "jamiro", [ "AR", "TR" ], { "listenerId": "399" }, 0, 20, false ] } }, ```

uglyog
2021-05-27 23:07
No, it supports all spec versions. Can you raise a github issue for this?

jarmy
2021-05-27 23:08
absolutely

kamoljan
2021-05-28 02:39
has joined #general

artur
2021-05-28 06:21
If I have to test an API that depends on an external API (e.g. a payment gateway) is it advisable to use pact to mock the external API? Do people do that or is pact more only to be used when I have both sides under my own control?

uglyog
2021-05-28 06:22
You can do it, but you will only be able to verify one side

artur
2021-05-28 06:27
yes I will still have to verify that my mock is correct. I could run that against a test-environment, if available (e.g. paypal or dropbox have that) I'm just thinking pact would win against running tests all the time against the vendors test-env because it would be much faster and reliable And pact would win against normal mocking of the requests because at least I could run the contract against the vendors API to ensure my mock is correct

uglyog
2021-05-28 06:33
I used it to a test an integration with Jira, so that the test tooling is the same as for other tests

mathias.duesterhoeft
2021-05-28 08:59
has joined #general

matty_o_connor01
2021-05-28 15:57
has joined #general

matty_o_connor01
2021-05-28 16:07
Hi all. Thanks to the team for creating and maintaining such an interesting product! I've gone through the .net tutorial and hopefully it is something that can add value to my project. I had a couple of basic questions... ? Am I right in thinking that contract tests can (and should?) be added for frontend (e.g. a React app) to backend (e.g. a .net core webapi) API calls? Whilst going through the learning material it _felt_ like PACT was more aimed at backend service to backend service testing but I could be wrong. ? Assuming yes to the question above, if your frontend and backend are in different languages should you model both 'sides' of the contract in their respective PACT implementation languages? E.g. a react front end would use Pact JS for the consumer side and a .net backend would use Pact Net for the provider side. If you are just mocking on the consumer side I guess you could use the provider's language but then you may have to translate type definitions/models for your API calls to a different language. E.g. Your typescript type definition file that you use to model the data you are sending to your backend has to be converted to a POJO/POCO to write your consumer tests. It seems it might be error prone. Many thanks!

brendan.j.donegan
2021-05-28 17:13
Yes to both!

brendan.j.donegan
2021-05-28 17:13
There's no rule that you can't use a different language for Provider verification though

nathaniel.emmons
2021-05-28 18:25
has joined #general

sapoho3257
2021-05-29 16:10
has joined #general

tjones
2021-05-30 13:33
> our typescript type definition file that you use to model the data you are sending to your backend has to be converted to a POJO/POCO to write your consumer tests. It seems it might be error prone. I suspect there might be a misunderstanding here. Pact sends the example requests and responses for you, there is no need to model the types in the same language.

matty_o_connor01
2021-05-30 13:57
Right. It's not enforced but it seems sensible to do so. If I have the following that I want to write a contract test for... ```const basketLine: BasketLineForUpdateDto = {   basketLineId: basketLineId,   quantity: quantity, }; try {   await http://axios.post(     `${env("SHOPPING_BASKET_API")}/api/baskets/${basketId}/basketlines/updateBasketLineQuantity`,     basketLine   );``` `BasketLineForUpdateDto` defines the shape of my data. Replicating this in a different language is something else I have to remember when updating contract tests. If I use a pact language version that has access to the same models that are used by the consumer it would seem to be more robust. Unless I'm misunderstanding something?

matty_o_connor01
2021-05-30 14:05
> Pact sends the example requests and responses for you You still have to define what those requests and responses look like don't you?

andjela.rajic
2021-05-30 20:00
has joined #general

matt.fellows
2021-05-31 00:36
yes

sumitsg004
2021-05-31 05:10
has joined #general

sumitsg004
2021-05-31 05:15
Hi All, I am new to this and just started writing contract tests for APIs in Java. I have run into a rare scenario and I am not able to generate Pactdsljsonbody for my request body API Method - PATCH Request body - _`{"attributes":{"key1":"abc","key2":"xyz"}}`_ Inside "attributes" body, there can be one or more key value pairs. Keys can have any name and not just "key1" and "key2". Their value is of string type. How can I create Pactdsljsonbody, which will accept one or more keys and also keys can have any name?

uglyog
2021-05-31 05:17
What issues are you having?

sumitsg004
2021-05-31 05:19
updated the issue

uglyog
2021-05-31 05:21
Use eachKeyLike to match only the values

sumitsg004
2021-05-31 05:22
Like this - `PactDslJsonBody dsl = *new* PactDslJsonBody();` `dsl.eachKeyLike("attributes");` `*return* dsl;`

uglyog
2021-05-31 05:24
You need to configure it to match the values

sumitsg004
2021-05-31 05:24
Is there a way i can write - request body *must* have "*attributes*", and inside that atleast one key value pair should be there. Basically the object "attributes" should not be null

uglyog
2021-05-31 05:27
`object("attributes").eachKeyLike("key1", PactDslJsonRootValue.stringMatcher("xyx")`

uglyog
2021-05-31 05:28
I don't think there is a way to ensure the attributes is not empty

sumitsg004
2021-05-31 05:36
object("attributes").eachKeyLike("key1", PactDslJsonRootValue.stringMatcher("xyx") when used this - I am getting empty body in the generated pact

uglyog
2021-05-31 05:40
Sorry, `stringType`, `stringMatcher` is for a regex

uglyog
2021-05-31 05:40
```new PactDslJsonBody().object("attributes").eachKeyLike("key1", PactDslJsonRootValue.stringType("xyx")).toString()``` => {"key1":"xyx"}

uglyog
2021-05-31 05:41
You must be doing something else wrong

abubics
2021-05-31 05:41
> Replicating this in a different language is something else I have to remember when updating contract tests. Seems a bit tautological, unless I'm misunderstanding :innocent: If the contract changes, whichever side is now wrong needs to be updated.

abubics
2021-05-31 05:46
> If I use a pact language version that has access to the same models that are used by the consumer it would seem to be more robust. This implies that you might be sharing DTO code across multiple codebases? It's not necessarily a problem, but might give you false confidence that your separate releases are in sync. It's the contract's job (with help of the broker) to let you know when they get out of sync, and being in a different language doesn't hinder that :slightly_smiling_face:

sumitsg004
2021-05-31 05:49
My method - anything I am missing ? `*public* PactDslJsonBody generateDSL()` `{` `PactDslJsonBody dsl = *new* PactDslJsonBody();` `dsl.object("attributes").eachKeyLike("key1", PactDslJsonRootValue._stringType_("xyx")).toString();` `*return* dsl;` `}` This also creating a empty body in the pact

uglyog
2021-05-31 05:50
Remove the toString() call

matt.fellows
2021-05-31 05:50
I took it as trying to make the case for authoring the Pact tests in the same language as the code > If you are just mocking on the consumer side I guess you could use the provider?s language but then you may have to translate type definitions/models for your API calls to a different language. 1. (example) Code is in typescript, and there is a type that contains the definition for let?s say a `User` 2. When you author the pact consumer test, if you have to write the object `{...}` by hand in _another_ language (the ?provider?s language? above), you can?t re-use the type system that your code is using, so could get out of sync

sumitsg004
2021-05-31 05:58
still the same, anything wrong with builder - `*return* builder`         `.uponReceiving("Contact Update")`         `.path("/v1/task/abcdef")`         `.method("PATCH")`         `.headers(headers)`         `.body(generateDSL())`         `.willRespondWith()`         `.status(202)`         `.toPact();`   `}`

sumitsg004
2021-05-31 06:00
Pact generated - `"interactions": [` `{` `"description": "Contact Update",` `"request": {` `"method": "PATCH",` `"path": "/v1/task/abcdef",` `"headers": {` `"Authorization": "Bearer gfgffg",` `"Content-Type": "application/json"` `},` `"body": {` `}` `},` `"response": {` `"status": 202` `}` `}` `]`

sumitsg004
2021-05-31 06:00
body is coming empty in request

abubics
2021-05-31 06:06
oh, right :sweat_smile: yes, I'd totally write each side's Pact bits in their own language

matt.fellows
2021-05-31 06:07
(I could be wrong, that?s just how I read it!)

uglyog
2021-05-31 06:10
What version are you using?

sumitsg004
2021-05-31 06:12
I cloned a github project and started working on it. Sorry to ask basic question but how do i check version ?

uglyog
2021-05-31 06:13
Depends if it is a Gradle or Maven project

uglyog
2021-05-31 06:13
It definitely works

sumitsg004
2021-05-31 06:14
its maven project

uglyog
2021-05-31 06:15
It will be in the dependencies in the Maven POM

sumitsg004
2021-05-31 06:15
`<dependency>`   `<groupId>http://au.com.dius</groupId>`   `<artifactId>pact-jvm-consumer-junit_2.11</artifactId>`   `<version>3.5.23</version>` `</dependency>`

uglyog
2021-05-31 06:21
That won't work, you need a more modern version. That version is from 23-Sep-2018

uglyog
2021-05-31 06:22
```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit</artifactId> <version>4.2.6</version> </dependency>```

uglyog
2021-05-31 06:22
That's the latest, but needs Java 11

sumitsg004
2021-05-31 06:23
I have java 1.8 running

uglyog
2021-05-31 06:23
```<dependency> <groupId>au.com.dius.pact.consumer</groupId> <artifactId>junit</artifactId> <version>4.1.21</version> </dependency>``` for Java 8

uglyog
2021-05-31 06:23
You need to ensure all the pact libraries in the POM have the same version

sumitsg004
2021-05-31 06:25
okay sure, let me check this. will update

dimundo
2021-05-31 06:26
i have some generic question :slightly_smiling_face: 1. pact consumer vs provide works 2. provider announces, that changes in API will follow 3. consumer updates own tests and pact, but build will fail, as pact-related tests are failing, due to new api version is not in place 4. provider updates own api/tests but cant make build/deploy, as pact with new changes will fail how to manage this ( let's say consumer is JS app and provider - scala )?

dimundo
2021-05-31 07:56
for me it looks like option is supporting 2 api versions by server and migrating consumer side to new one

dimundo
2021-05-31 07:56
any other ideas ?

abubics
2021-05-31 08:03
Then general approach is expand+contract - make backwards-compatible changes in the provider (API) and deploy them, then update the consumer (UI), then optionally remove the backwards compat (note: this is a breaking change under semantic release).

matty_o_connor01
2021-05-31 10:06
> When you author the pact consumer test, if you have to write the object `{...}` by hand in _another_ language (the ?provider?s language? above), you can?t re-use the type system that your code is using, so could get out of sync Bingo! Good to know, thanks.

sumitsg004
2021-05-31 11:35
Hey can you please send the pact file which you generated for my request ?

allan.barbosa
2021-05-31 14:08
has joined #general

vinicius.grund
2021-05-31 14:35
has joined #general

2021-06-01 01:10
*This polly is closed.* @bethskurrie has a polly for you!

bethskurrie
2021-06-01 01:14
Peeps! Naming things is hard. Would appreciate input for the above research question. The Pact Broker is getting proper branch support soon, and I need a name for the field that will identify the branch of the application that The Work Gets Done On. The important one. The one that you need to get passing.

bethskurrie
2021-06-01 01:16
Something to keep in mind. Some teams use Git flow, and they have "main/master", "develop" etc. so the "<insert term here> branch" would actually be "develop", not "main".

uglyog
2021-06-01 04:39
I didn't generate a Pact file

sumitsg004
2021-06-01 06:59
this worked - `dsl.object("attributes").eachKeyLike("key1", PactDslJsonRootValue._stringType_("xyx")).toString();` I had not closed the object. silly mistake. Thank you so much for your time and help.

tjones
2021-06-01 07:09
I still think there's something about Pact that isn't clear here, but I can't tell what. Without pact, you have: Consumer, written in (say) Typescript Provider, written in (say) Kotlin They already speak the same "contract" (whether or not it is tested) so you need to keep the types in sync somehow

tjones
2021-06-01 07:10
With pact you have: Consumer, written in (say) Typescript, including consumer tests using the existing Typescript types. These tests generate a Pact file. Provider, written in (say) Kotlin, including provider verification entirely driven by the content in the Pact file

tjones
2021-06-01 07:10
Pact doesn't introduce any need to do anything extra with type systems

tjones
2021-06-01 07:13
I suppose you *could* write the consumer tests using a different language to the consumer, but you'd have trouble getting it to work right I think. The flow is: 1. Consumer test describes the expected request + response (and Pact starts a mock which expects that request and generates that response) 2. Consumer test calls your actual client code that does the actual request (but requests to the mock instead of the real provider) 3. (if your request was right), the mock sends the expected request 4. You check that you unmarshall the response correctly in your client 5. The test passes ^ This gets repeated a bunch, and if all tests pass, a pact file is written

tjones
2021-06-01 07:14
> When you author the pact consumer test, if you have to write the object {...} by hand in another language (the ?provider?s language? above), I think @matt.fellows?s point is - you don't have to do that.

aubilla
2021-06-01 14:09
:wave: I come from reading this greatly written https://docs.pact.io/pact_nirvana/step_5 and I?m finding myself at a sort of a crossroad when dealing with Provider verification. I would like to know if it?s possible to verify providers against Pacts without blocking their deployment. Would this be against Pact?s Consumer first principle?

todd.lemmonds
2021-06-01 15:57
has joined #general

alexander.infante
2021-06-01 15:57
has joined #general

michael.doyle
2021-06-01 15:58
has joined #general

bethskurrie
2021-06-01 19:56
@aubilla without blocking whose development? Consumer or provider?

paulorochag
2021-06-01 20:20
has joined #general

bethskurrie
2021-06-01 23:53
If you mean provider, then pending pacts is designed to help that situation https://docs.pact.io/pending I should update the pact nirvana docs to include that now.

matt.fellows
2021-06-02 01:16
We need your feedback on making the AMA?s most useful. Please vote here if you want to see more of these :point_right: https://pact-foundation.slack.com/archives/C01RPBC2KNG/p1622596291017900

aubilla
2021-06-02 07:22
Yes, I meant Provider. I?m very happy to learn this ?pending pacts? feature exists. Thanks a million @bethskurrie :raised_hands:

dimundo
2021-06-02 14:38
hi! is it correct behaviour, when producer's build fails with error in pact part, this removes `can-I-deploy` for consumer? but until producer's side will not be fixed, consumer side will be blocked for deploys, but actually pact is not broken, as producer is not deployed.

jaspal.gill
2021-06-02 15:23
has joined #general

dimundo
2021-06-02 17:59
ah, i've got it, if this producer breaks pact - it must be new version of pact

dimundo
2021-06-02 17:59
but if someone will forget to bump version - any fixes for that?

wenqiglantz
2021-06-02 18:19
has joined #general

bethskurrie
2021-06-02 21:06
Hi @dimundo I'm not sure what you mean by forgetting to bump the version. Which version? The version that you publish the pact with is the version of the *application* not the version of the pact. The pact versions are tracked automatically by the Pact Broker.


bethskurrie
2021-06-02 21:09
Also, if you do the CI/CD workshop, you'll see how to implement new features, and how pact+can-i-deply ensures that you can never deploy a broken combination of consumer/provider https://docs.pactflow.io/docs/workshops/ci-cd

ch.toimbetov
2021-06-02 21:46
has joined #general

ch.toimbetov
2021-06-02 22:46
Hi! I know that the question about usage of SDK/client libraries has been raised quite a few time here(I?ve also checked Matt?s article about SDKs), but I wanted to clarify benefits of PACT in the scenario. Right now we have a microservice architecture and we have 2 options: 1. start implementing consumer driven tests using PACT 2. add an observability inside SDKs, so we come to know what methods/fields are being used by consume. ? Client library will push metrics which fields are being used(it could be managed through library design). ? Provider will have a dashboard what is being used, so they can plan changes in contract gracefully. ? Verification of expectations are being managed by functional/integration tests on a provider sides and in SDK. ? Based on the metrics there will be similar to can-i-deploy mechanism which blocks provider from introducing a breaking change into a contract Benefits of the second approach: ? No actions required from a consumer ? The metrics reflect real usage of fields, while contract tests may go out of sync I?m curios how does PACT fits if we go with an SDK. If this has already discussed anywhere feel free to point me :upside_down_face:

tjones
2021-06-03 01:55
Somewhat off topic, but I encountered a 421 error for the first time today, which is retryable. Some HTTP status codes are retryable, some aren't. Does anyone know of any libraries that will auto-retry the ones that can be retried?

xyz1kind
2021-06-03 05:03
has joined #general

aftab.shamim2020
2021-06-03 06:02
has joined #general

dimundo
2021-06-03 06:10
i'm trying to make some POC

dimundo
2021-06-03 06:10
and was checking provider against "latest" pact version

dimundo
2021-06-03 06:11
and if i fail pact test, in broker sets it to no-deploy

dimundo
2021-06-03 06:13
will check that workshop

bethskurrie
2021-06-03 06:35
@dimundo the "pending" feature stops consumers being able to break provider builds. You can read about it here: https://docs.pact.io/pending

slu.mendozaharold
2021-06-03 10:33
has joined #general

slu.mendozaharold
2021-06-03 10:38
Not sure if this is already answered but is there a `publish-to-broker` for `pact-python?`

tjones
2021-06-03 10:38
I?m not sure if there is, but you can use the pact binaries for publishing

tjones
2021-06-03 10:39
the language specific bindings for publish are largely a convenience


tjones
2021-06-03 10:40
```pact-broker publish PACT_DIRS_OR_FILES --consumer-app-version=CONSUMER_APP_VERSION --broker-base-url=BROKER_BASE_URL ``` etc

tjones
2021-06-03 10:41
I think pact python is also backed by the ruby-standalone binaries, so you may have the binary already (I have no idea how the python package ecosystem works, sorry)

tjones
2021-06-03 10:43
@dimundo: You have to be careful to make sure that the version changes each time the contract changes. That?s why the versioning best practice recommends using the commit hash as part of the version number, because that way it will always change when your code changes.

slu.mendozaharold
2021-06-03 10:48
yup thanks! I understand. I just have a specific problem that may or may not be resolved by having it in python

matt.fellows
2021-06-03 10:53
(that binary should also be bundled into the python library itself, i.e. it?s already available on your CI etc.)

dimundo
2021-06-03 12:00
@tjones, yeah, already got that

dimundo
2021-06-03 12:00
any hints to version autobumping ? :slightly_smiling_face:

tjones
2021-06-03 12:01
How are you doing your versions?

tjones
2021-06-03 12:01
In js land, we use git tags for releases, using tools like `standard-version`


dimundo
2021-06-03 12:02
for now - i dont , just poking to show pact to the team

dimundo
2021-06-03 12:02
so versions are pretty random in sandbox :slightly_smiling_face:

tjones
2021-06-03 12:02
If you use git tags, then you can get pact friendly versions using this: https://github.com/pact-foundation/absolute-version-js

dimundo
2021-06-03 12:03
and looks like verifying pact against `latest` is very bad idea

tjones
2021-06-03 12:03
I released that under the pact-foundation banner, but I might actually move it out, as it?s a bit opinionated / not actually part of pact

tjones
2021-06-03 12:04
> and looks like verifying pact against latest  is very bad idea It depends. If you want to know if it?s safe to deploy, then you need to know what is in production, so having pact broker tags per environment is helpful

dimundo
2021-06-03 12:04
how do producer knows recent consumer version? any best practices/opinions ?

tjones
2021-06-03 12:04
You don?t need to know the consumer version, you just need to know what tag you want to validate against

tjones
2021-06-03 12:05
to know that, your development lifecycle becomes relevant

tjones
2021-06-03 12:06
Pact is telling you if a consumer + provider are able to talk to each other

tjones
2021-06-03 12:07
usually you want to know: 1) Is the most recent version of everything compatible (as in, if we released both today, would they work?) 2) Is the most recent version of one thing compatible with everything else that is deployed right now?

tjones
2021-06-03 12:08
To make this more concrete, I personally prefer trunk based development, so I would have a `latest` for the head of master, then a tag per environment

tjones
2021-06-03 12:09
then you might want to (eg) have seperate tasks in CI to for the different environments. You could do something like say that a failure to be able to deploy breaks the build, but a failure against latest doesn?t. It depends on your environment

tjones
2021-06-03 12:10
I know that those who use branches like to have separate broker tags per branch

tjones
2021-06-03 12:10
(Beth has some nice patterns for that, I think)

tjones
2021-06-03 12:10
I think we have some docs on it

tjones
2021-06-03 12:11
https://docs.pact.io/pact_nirvana ^ Sections of this might be helpful

dimundo
2021-06-03 12:15
awesome, thank you

dimundo
2021-06-03 12:16
still , having `latest` for trunk could block other guys, if someone will not communicate/predict, that changes are coming :slightly_smiling_face:

dimundo
2021-06-03 12:17
ok, it will be fun at first steps, thank you again :slightly_smiling_face:

tjones
2021-06-03 15:22
The pending pacts feature that Beth linked above ( https://docs.pact.io/pending ) is designed to prevent issues from contracts breaking other teams if you are moving quickly, so that might be helpful. I think it needs you to be using tags other than latest, but don?t quote me on that.

slu.mendozaharold
2021-06-04 06:23
Hi! Is there a way to ensure that before the CI pipeline goes to `pact-can-i-deploy` the Consumer have already been published and verified?

bethskurrie
2021-06-04 06:24
Which pipeline?

bethskurrie
2021-06-04 06:25
I'm guessing you mean the consumer, and I think you might want the --retry-while-unknown options


bethskurrie
2021-06-04 06:25
That will wait for the result to come back for the amount of time that you configure.

slu.mendozaharold
2021-06-04 06:25
Ah, sorry not really a pact-broker question but just want to ask if someone encountered this in their CI pipeline

slu.mendozaharold
2021-06-04 06:26
```stages: - build-test - test - pact-publish - pact-can-i-deploy```


bethskurrie
2021-06-04 06:27
well, it looks like your pact publish comes before your can-i-deploy. if you want it to wait for a verification result, then as I said above, use the --retry-while-unknown options

slu.mendozaharold
2021-06-04 06:27
alright thanks! will do.

artur
2021-06-04 09:07
how do I test how the provider reacts to invalid/badly formatted/dangerous data? let's say I have consumers that have own data sanitation & validation, so when I create a pact, all requests that reach the provider are somehow valid or at least not malicious but I also want to check how the provider reacts on requests that no "good" client would ever send How to do that when using pact? I can think of two possibilities that are both not great: 1. use pact only for requests that a real client sends and expects. For anything else use an other framework. That would result in code duplication, specially in the setup/teardown process. 2. create a specially bad client that would accept and send also bad data. 2.1 a very dump client, that just sends raw data => might make the tests hard to read and write because every detail of the request would have to be given there 2.2 let the client still do encoding, e.g. wrap data from the test into WebDAV request => code duplication between the real clients and the bad-client that only exists to test how the provider reacts on bad input other ideas?

sergio.artero
2021-06-04 10:07
has joined #general

ruben.perezg
2021-06-04 11:26
Hi all :slightly_smiling_face: I have a question, but for that I would need to give you some context. In our company, we have been using Pact for some time, but we want to give it some serious push now. For example, we wanted to use it for the scenarios in which we use API Gateways between our clients and our backends. In our case, the API GW is https://www.krakend.io/, which uses a declarative approach, so no need to write actual code for it to work, just configure it with a JSON file. In that case, we need to check two different things (contracts?) here: 1) The contract/interactions between the consumer and the API exposed by the API GW 2) The contract/interactions between the API GW and the backends it's using for its endpoints (It's important to note that the API contract that exposes the API GW to its consumers is different than the API contract of the backends it is using behind the scenes. It is not just a reverse-proxy) The second point is what I would need some help with. Given that we don't have code at the API GW layer (only a JSON file), we don't see how we could define the fragments and auto-generate the contracts, as we won't have any place to put test code and run it like we would in a "normal" service. Our approach so far has been using the contract generated in the consumer to verify the interactions between the consumer and the API GW, and manually create the contract between the API and the backend it needs to use, and use the `pact-stub-server` and `pact-cli`.That way, we are able to verify the interactions at both levels. So as far as I can tell, that works... but it requires to manually create those contracts, which is not great :slightly_smiling_face: . Do you know if there's a better approach for a scenario like that? I felt like this was a weird use of Pact at first, and that having to manually create contracts was a smell. But I think using Pact for those tests brings much more value than just doing some integration tests with predefined stubs between the API GW and the backends.

tjones
2021-06-04 12:15
This is a super interesting question. My first reaction is "pact isn't really for this use case, you may want another tool", but there might be a different answer that others have

tjones
2021-06-04 12:16
I know that firefox had that giant fuzz tester that generated random html - maybe something like that would be appropriate?

tjones
2021-06-04 12:17
A lot of the pact concepts fall down in negative cases - most of them are for positive "I know the provider can understand X, and I can understand its response, Y"

tjones
2021-06-04 12:18
Good question! Are you able to consider you API GW and provider as one "provider"?

tjones
2021-06-04 12:19
Alternatively, can you consider the client + API GW as one client?

artur
2021-06-04 12:23
the generation of data is one issue, but still you need a tool (could be as simple as sendind curl requests) to test the API. And I think in reality you end up with postman, or if you like me and don't like UIs, with some BDD approach. But if you write tests for your malicious the temptation is very high to use the same framework to write tests for the good requests, and why not? Specially if you have a data drive approach (like with fuzz generated data). And then you have additionally pact tests, that generates test - duplication.

matt.fellows
2021-06-04 13:00
I reckon Conway?s Law will come into play here, but keen to hear the outcome

matt.fellows
2021-06-04 13:00
It?s one of the annoying use cases with Pact, to be honest

matt.fellows
2021-06-04 13:01
How much transformation does it actually do?

matt.fellows
2021-06-04 13:02
If it?s just path routing and auth you can potentially just pretend it doesn?t exist is far as Pact is concerned, and deal with the routing and auth separately (you may want to just exclude auth, for example)

ruben.perezg
2021-06-04 13:07
Those are fast answers :slightly_smiling_face: We are just starting PoCs with Pact at the API GW layer, now that we have started the official rollout of our API GWs

ruben.perezg
2021-06-04 13:08
So far, there are a mix of scenarios: ? Some act almost as a reverse-proxy (with or without authentication). ? Some have aggregations, response manipulations...

ruben.perezg
2021-06-04 13:09
In the first scenario, I guess we could consider that the API GW could be "one" with either the consumer or the provider. But I don't see it for the second scenario

ruben.perezg
2021-06-04 13:14
So, maybe in some scenarios we could take https://docs.pact.io/getting_started/what_is_pact_good_for/#why-pact-may-not-be-the-best-tool-for-testing-pass-through-apis-like-bffs into account, and think if that's a good scenario for pact (reverse-proxy - pass-through APIs)

ruben.perezg
2021-06-04 13:14
But honestly, I see the value in using Pact as I exposed to check both the interactions between the consumer&API Gw, and between the API GW & providers

matt.fellows
2021-06-04 13:20
> Some have aggregations, response manipulations... :see_no_evil:

matt.fellows
2021-06-04 13:27
You can still do Pact, but it will just require a bit more work. I?ve written https://gist.github.com/mefellows/28e613be093b1c18429d before, but it does require some harnessing and automation around. You?ll need a way of stubbing servers etc. too. API gateways are also one of the key use cases for https://docs.pactflow.io/docs/workshops/bi-directional/index#use-cases (BDC). For example, if you had OAS for the endpoints exposed by KrakenD you could write Pacts from the consumer side against the KrakenD schema (no need to replay the Pact tests against the GW, the schema itself is the evidence it needs). You would of course then need to have Pact tests (or BDC tests) between the gateway and the backends for all of the key scenarios to give you the confidence they make the correct calls. One advantage of BDC in particular, is sidestepping the problem of provider states, which is particularly cumbersome for systems that don?t have state, but simply pass it along

tjones
2021-06-04 13:35
We don't have docs for this (yet), but there's also a third scenario, where you see all the things as deployable units from pact's perspective - this is probably more realistic, but also more work - Pact between client and API GW Pact between API GW and provider(s)

tjones
2021-06-04 13:36
I kind of feel that having trouble doing that with Pact is more illustrative of concerns that have bled across boundaries - as in, you'd have problems testing this with any testing tool, not just Pact

matt.fellows
2021-06-04 13:38
yeah, I?m very much of the ilk that API gateways are nothing more than border security, caching, acceleration and routing.

tjones
2021-06-04 13:38
Hmmm. I mean, you could. But, Pact isn't a "this is how the API behaves" tool, it's a "this is how the client wants to communicate" tool

tjones
2021-06-04 13:38
For each client, you cover the examples that the client wants to understand

matt.fellows
2021-06-04 13:38
but I don?t see you winning that argument quickly, especially if it?s already in play

tjones
2021-06-04 13:38
...yes

tjones
2021-06-04 13:38
:joy:

tjones
2021-06-04 13:39
:sob:

matt.fellows
2021-06-04 13:39
So, to do Pact testing all the way

matt.fellows
2021-06-04 13:41
> The second point is what I would need some help with. Given that we don?t have code at the API GW layer (only a JSON file), we don?t see how we could define the fragments and auto-generate the contracts, as we won?t have any place to put test code and run it like we would in a ?normal? service. the answer to this question where the GW is doing the provider test, is to be able to stand up the API gateway in a local environment, stubbing out the downstream systems (you may be able to use Pact for this, but @uglyog has stories he might be able to share on the considerations here). KrakenD is fairly modern and not, say Apigee, so this should be doable albeit cumbersome.

matt.fellows
2021-06-04 13:41
the Pact provider is then going to issue requests at the running gateway

matt.fellows
2021-06-04 13:42
When you treat the GW as a consumer of the downstream systems, you?re going to have to do something similar, except the stubs will be the pact mock service and the client will be an actual client - e.g. an HTTP client that makes the calls

matt.fellows
2021-06-04 13:42
I could see a situation where you cleverly map the provider tests to a consumer test, so that you can bypass some of this, but that may also end up tying yourself in knots

matt.fellows
2021-06-04 13:43
The nginx example above does this, just not with Pact. It was a test to demonstrate the circuit breaker configuration, using dnsmasq to mess with DNS at runtime.

tjones
2021-06-04 13:44
In the case of malicious input, the client doesn't want to send that

tjones
2021-06-04 13:44
I suppose, if you know what the malicious input might be, you could create a hypothetical pact with "malicious actors", which returns 400 / 401/ 403 / 404 (as appropriate)

ruben.perezg
2021-06-04 14:13
I think I have some good reading material here. I will take a deep look at everything you have shared, and I will probably get back to you after the weekend. Thank you very much Matt and Timothy :slightly_smiling_face:

v-gabriel.dantas
2021-06-04 15:26
has joined #general

v-gabriel.dantas
2021-06-04 15:46
hello everyone, this may be a dumb question, but how can I make my provider verified? I already made the deploy from the consumer and the provider, tagged as prod, but I still cant see it in the UI that my provider is verified? Do I have to make any extra step to accomplish this verification? Thanks!

phil.endsley
2021-06-04 16:14
Typically, publishing verification results is a separate step from actually running the verification. It should be outlined in the docs for your provider's language I think

v-gabriel.dantas
2021-06-04 16:17
hum interesting

phil.endsley
2021-06-04 16:18
Typically, it's a separate step, because verifications should be published from your ci pipeline, but not when running verifications locally

phil.endsley
2021-06-04 16:19
If you publish after verifying locally, you can give a false positive that everything is compatible, when you haven't pushed your code yet

v-gabriel.dantas
2021-06-04 16:22
totally make sense?

v-gabriel.dantas
2021-06-04 16:30
Im going to try to integrate with a ci pipeline

v-gabriel.dantas
2021-06-04 16:30
thanks for your help!

phil.endsley
2021-06-04 16:59
Sure. I guess I'll say, it's totally fine to do it locally for a poc. Just best to evaluate all the tradeoffs before doing a real implementation

phil.endsley
2021-06-04 16:59
Even when just getting started

fnguyen
2021-06-04 17:14
when i run the provider test in c#, in the pactVerfierConfig, i set ```PublishVerificationResults = true ``` and it makes the pact marked verified automatically. You need to connect to the broker with a read-write token for the verification to be set.


fnguyen
2021-06-04 17:17
I suppose there are similar feature in your language of choice.

v-gabriel.dantas
2021-06-04 17:26
nice!

leonardo.viana
2021-06-04 18:52
has joined #general

matt.fellows
2021-06-04 23:16
What language Gabriel?

v-gabriel.dantas
2021-06-05 21:49
hey @matt.fellows, I?m using node js

v-gabriel.dantas
2021-06-05 21:50
I tried to do it that way

v-gabriel.dantas
2021-06-05 21:50
but the provider verification wasnt sent to the broker

matt.fellows
2021-06-06 00:05
This is not the standard provider verification and that attributes is not valid for that API call

matt.fellows
2021-06-06 00:05
This is for bi-directional contracts which does not yet have UI support. The results are being sent to the broker, just not in the usual place because it's a different resource


v-gabriel.dantas
2021-06-06 00:06
ah I see, makes sense

v-gabriel.dantas
2021-06-06 00:06
thanks for the tip

matt.fellows
2021-06-06 00:07
So basically, it probably is working you just can't yet see via the UI

matt.fellows
2021-06-06 00:08
May I ask where you started this journey? Did you find the examples and go from there or did you have a demo with Pactflow?

matt.fellows
2021-06-06 00:08
(happy for you to DM me if that's sensitive)

v-gabriel.dantas
2021-06-06 00:09
I?ll DM you, I think its better

abubics
2021-06-07 00:15
I would typically put these kinds of tests in a security unit/integration suite (e.g. MockMvc in Spring, or similar). But it does depend on architecture, and what kinds of consumers & providers you have. e.g. if you have private internal consumers (microservices), that kind of danger has a different profile. And/or if you have public consumers (web UI), other components may intercept the requests before they make it to a provider (WAF, API gateway, etc).

abubics
2021-06-07 00:46
:taco: for @matt.fellows & @tjones - loving the in-depth discussion and philosophy of approaches :3

yashdev963
2021-06-07 06:51
has joined #general

nathaniel.emmons
2021-06-07 15:18
(not sure if this goes here or in #pact-broker sorry).. I?m a little confused about how the ?pending pacts? functionality is supposed to be useful. If the pacts are still recorded as not verified in the broker, then neither the provider nor consumer can deploy if they check the broker. All this does is allow the provider to get through the verification step without a failure. What am i missing?

phil.endsley
2021-06-07 15:27
> If the pacts are still recorded as not verified in the broker, then neither the provider nor consumer can deploy if they check the broker. Kind of, but it's a little more nuanced. The consumer cannot deploy the version that has not been verified. The provider can still deploy non-breaking changes with the existing consumers. It cannot deploy any version that breaks a contract with the currently deployed consumers > All this does is allow the provider to get through the verification step without a failure. Correct. Without pending pacts, a consumer could effectively block a provider's workflow by publishing a contract that is not supported by the provider. If this contract is merged into the main development branch, and providers verify against that tag, the provider's build will be broken until the issue is resolved. By using pending pacts, the provider team can continue to work on non-breaking changes with contracts it has already verified. Using pending pacts will let the provider team shift priorities to a hotfix that needs to go out now. Otherwise, they would have to resolve the contract compatibility issue first.

sammomichael
2021-06-07 16:20
Have a question about GraphQL testing with PACT. Since a single consumer query may hit parts of the graph owned by several different provider teams, what kind of solutions have you attempted to take away some of the complexity and get closer to a 1:1 relationship between provider/consumer instead of 1 to many?

nathaniel.emmons
2021-06-07 17:12
Got it, that makes sense. Thanks very much for that extra nuance. My thinking has been very generic and crude thusfar so this is a big help

phil.endsley
2021-06-07 17:15
np. I think Pact looks pretty straight forward on the surface, but can get pretty complex very quick when learning all the features it offers and how to leverage them effectively.

nathaniel.emmons
2021-06-07 17:17
Yeah, agreed

i.pinzari
2021-06-07 17:27
has joined #general

gurkiratguliani
2021-06-07 19:36
has joined #general

bethskurrie
2021-06-07 23:26
@v-gabriel.dantas the CI/CD workshop will help you get your pipeline working https://docs.pactflow.io/docs/workshops/ci-cd

bethskurrie
2021-06-07 23:26
Assuming you've also seen the CI/CD set up guide here as well: https://docs.pact.io/pact_nirvana

bethskurrie
2021-06-07 23:31
:taco: for @phil.endsley!

matt.fellows
2021-06-08 00:06
:taco: for @phil.endsley indeed!

matt.fellows
2021-06-08 00:06
@bethskurrie FYI this was goinsg to be a topic of a past AMA. We should get Phil to answer it instead of you :slightly_smiling_face:

v-gabriel.dantas
2021-06-08 00:49
cool, Im going to try to integrate with gitlab

wenqiglantz
2021-06-08 03:04
Question related to asynchronous messaging pact consumer, where is a good/recommended place to put topic name in the pact contract? Can I put it within "metaData" under "messages"? Such as in the following sample: ```"messages": [ { "contents": { "userId": "595eed0c-eff5-4278-90ad-b952f18dbae8" }, "description": "valid UserCreatedEvent from provider", "metaData": { "Content-Type": "application/json", "topic": "user_service_topic" }, .....```

uglyog
2021-06-08 03:09
That's what the metadata is for

abubics
2021-06-08 07:08
(I was going to taco Phil, but he already got 2 :joy:)

matt.fellows
2021-06-08 07:18
He deserves at least 2 I reckon

krishna.ramnk
2021-06-08 13:24
has joined #general

krishna.ramnk
2021-06-08 13:39
Hi All

nathaniel.emmons
2021-06-08 14:07
Is :taco: just recognition for providing a helpful answer?

nathaniel.emmons
2021-06-08 14:08
ah, yeah, the plugin just messaged me to explain lol

matt.fellows
2021-06-08 14:17
:smile:

paulorochag
2021-06-09 00:06
Hello everyone, everything good? What configuration should I do to use the pact in the context where the provider will change the return, and the consumer will have to change it to handle the new API return. When both are in agreement, it will be deployed together in production. Note: As the provider is changing the contract it may break the contract with the consumer that is in production. (breaking change) Does anyone have material on?

matt.fellows
2021-06-09 00:30
Use the expand-contract pattern: https://docs.pact.io/faq/#how-can-i-make-a-breaking-change-to-a-provider We recently spoke about this at an AMA: https://docs.pact.io/help/amas/#apac-1 For the CI/CD workflow with Pact, see this: https://docs.pact.io/pact_nirvana/step_5/

sagar.kharab
2021-06-09 00:32
has joined #general

david.vancouvering
2021-06-09 03:36
has joined #general

nuno.pik
2021-06-09 06:58
has joined #general

natashakdykes
2021-06-09 16:06
has joined #general

torbjorn.vatn
2021-06-09 17:30
has joined #general

s.goel
2021-06-10 08:57
has joined #general

kondal.ramidi
2021-06-10 16:13
has joined #general

richard
2021-06-11 00:13
has joined #general

jwcarman
2021-06-11 14:23
has joined #general

jwcarman
2021-06-11 14:24
Hello, everyone! :wave: Long-time Pact fan, just getting back into using it. Wow, the Pactflow UI is really nice. Great work!

hello370
2021-06-11 14:58
has joined #general

matt.fellows
2021-06-12 01:59
Nice to see you again James!

vikrant82
2021-06-12 12:16
has joined #general

daniel.bubenheim
2021-06-14 08:05
has joined #general

joaoproenca
2021-06-14 10:15
has joined #general

joaoproenca
2021-06-14 10:23
Hey everyone from :flag-pt:! I'm a sort of a newcomer, I've known about PACT for years now but only in the last few weeks I've been putting my hands on it to enable contract testing in my teams.

e.pittaluga.b
2021-06-14 16:34
has joined #general

npatil
2021-06-14 17:28
has joined #general

lucas.rolle
2021-06-15 06:48
has joined #general

siddharth.gupta
2021-06-15 06:48
Hi , Is it a good idea to keep 1 Pact file for each code branch of consumer ?

bethskurrie
2021-06-15 06:49
the pact file is automatically generated, and should be published from CI.

bethskurrie
2021-06-15 06:49
it's not generally checked in.

siddharth.gupta
2021-06-15 06:49
i mean on broker

bethskurrie
2021-06-15 06:49
when you publish the pact, you tag it with the name of the branch

matt.fellows
2021-06-15 06:50
You would also use tags to manage versions of the contract, and often these will map to branches


bethskurrie
2021-06-15 06:50
so, yes there is one pact per branch

bethskurrie
2021-06-15 06:50
having said that, explicit branch support is coming out soon

siddharth.gupta
2021-06-15 06:50
ok gr8 thanks

matt.fellows
2021-06-15 07:40
New video from Raquel at Fanduel talking about their experiences with Pact: https://www.ministryoftesting.com/dojo/lessons/consumer-driven-contract-testing-raquel-bautista-garrido > Raquel is a an Engineer working in the quality space, who with over 10 years experience in Software Testing wants to spread the idea of Contract Testing. > > Synopsis > I came across contract testing technique a few years ago in a test conference. Since then, every time I mention it I get a lot of comments like ?What is that about?` `I have never heard of this before`. > > While integration testing in isolation is becoming more requested and common, it raises a big concern between engineers, how do we know we are testing against the right assumptions? This is where contract testing can help us give us the confidence that we are testing the right thing and prove early our services can communicate. > > I will explain my experience in applying this technique, why we chose Pact as the framework to do consumer-driven contract testing, and hopefully give you a better understanding to then know if this is something that you can introduce in your strategy and how. > > Takeaways: > * What is contract testing > * Why do you want to include it in your test strategy > * Pact: a tool for consumer-driven contract testing > * Not a solution for everyone, when and when not to use Pact

lucas.rolle
2021-06-15 08:36
Hey everybody! I'm pretty new to Pact but I've done some research recently. My company wants to evaluate the usage of Pact in one example test case and I want to provide you with some context and my questions regarding the testing scope. System 1: Generates a data object. System 2: Sends the object via AMQP to different consumers. System 3: Consumer for AMQP. Does some internal mapping before sending the information to System 4 via HTTP. System 4: Receives the HTTP request and does some processing. Now I want to use Pact in this setup. System 3 is currently under development and my thoughts are to test the message generated by System 1 as a Provider and System 3 as the consumer and in a second case System 3 as the consumer and System 4 as the provider. What are your thoughts about this? Do you have any comments or recommendations? I hope that I'm on the right track. Best wishes, Lucas

caoilte
2021-06-15 11:36
has joined #general

danielabbitt
2021-06-15 17:12
has joined #general

tom.borglum
2021-06-15 17:29
has joined #general

matt.fellows
2021-06-16 01:50
No reason not to start there. What are your concerns?

matt.fellows
2021-06-16 01:51
Also, what is the relationship of system 1 and 2? how does the object get to system 2 and is that worth starting with?

michael.branders
2021-06-16 06:57
has joined #general

bethskurrie
2021-06-16 07:27
@dimundo please don't use "latest" as a tag!

bethskurrie
2021-06-16 07:27
It will get very confusing!


bethskurrie
2021-06-16 07:28
That page in general is a must read.

tjones
2021-06-16 07:28
Oh! Sorry, I may have confused things.

bethskurrie
2021-06-16 07:28
Tag with the branch name.

bethskurrie
2021-06-16 07:29
Having said that, I'll be releasing proper branch support soon, so it will all be a bit more obvious.

tjones
2021-06-16 07:30
TIL :man-facepalming:

bethskurrie
2021-06-16 07:31
I don't think many of the pact maintainers have read most of the docs I've written :stuck_out_tongue:

bethskurrie
2021-06-16 07:31
But who has the time!

jedlicka
2021-06-16 10:12
has joined #general

jpasse
2021-06-16 13:45
has joined #general

jan.malkiewicz
2021-06-16 14:48
has joined #general

jeen.broekstra
2021-06-17 06:13
has joined #general

minijb225
2021-06-17 06:44
has joined #general

jan.malkiewicz
2021-06-17 07:50
Hi, I'm also pretty new to Pact. I watched a few youtube videos from http://pact.io and studies examples on the http://pact.io page (react and spring-boot). Still I have some questions/considerations to the concept itself and the possible deployment of the solution in my project. Let say i have following micro-services ? B (spring boot app with DB) ? G (go application ) ? F (front-end react app) Service B provides api that is consumed by G and F. Let say also that services B, G and F are developed by separate teams in distinct localisations. 1. Who is the owner of pack tests (which team)? Should it be a dedicated team that takes care of those tests? 2. If i understood it correctly someone who writes the test should have knowledge of product B and G/F, right? 3. Should i write contract unit tests in both G and F and check all the contracts in tests in F? Is this supported, multiple contracts for one producer? 4. If i create service S in future i must extend tests in B so that it will check contracts form S, right? 5. In such case why team B should bother by all the usages of it's API? Producer (B) should not know it's consumers (G, F, S). Which team should add tests in B after service S is created? 6. If i understood the concept right, than tests in B are tightly coupled with tests in G and F by the scenario name, right? So for example if i have endpoint /products/{id} in service B and than i have a usage in contract test in G (/products/123) and in F (/products/456) than in my contract test in F i have to have two test scenarios (123 and 456) and have to assure that in each scenario i load expected data to the dababase, right? 7. If a have multiple usages a the same api call among services G, F, S than is this a good practice to create the same name for tests in G, F, S? In such case can i have single test in B which satisfy all contracts in B? 8. If i understood it correctly, in case of sprint boot application (B) in pact tests do not start the application itself but rather create a mock application which offer endpoints (controllers) that are the same as in standalone application, right? 9. What about the authorization in B? What is the best practice? Should i have in production code a toggle switch which defines that the app is in test mode mode and switch off the autorization? Thank you in advance for answering my questions. I hope i can use pact framework in my project, but without deep understanding i could not make this decision ;)

lucas.rolle
2021-06-17 09:12
Thanks for your reply @matt.fellows System 1 sends the data object as an pdf to system 2, its a bit outdated. System 2 is just a "pass through API", so i wanted to test against system 1 from system 3 perspective

kyle.hammond
2021-06-17 18:51
This is my understanding: G and F should both write the contract generation tests for the parts of the API of B that they use. Both G and F make assumptions about how B works from the outside, and this contract essentially documents all of those assumptions. G and F treat B as a block box; they need to understand the API vended by B and how they use that API but nothing more about B. Both G and F publish their contracts to a pact broker. Team B downloads the contracts for G and F from the pact broker and writes their unit tests for B to verify that they do the right things for the API that G and F are going to use. Using Pact words, team B verifies the contract. As long as B continues to honor the contracts they are free to refactor any code in B, provide more and different APIs, and release updates to B with assurance that they are not going to break G and F. If B wants to change some of the APIs that G or F rely on, then some coordination is needed to update G and F for the upcoming API changes before B can release. This should be done by G and F updating their usage, generating a new contract, then B can take that contract and verify that it is producing the right results for the way G and F intend to use the API. If a new service S is going to also rely on the API from B, then service S should generate it?s own contract with it?s assumptions about the parts of B that it uses. Service S publishes that contract to the pact broker, and service B should pick that up and start verifying that contract as well. The point of the contract tests between consumers/producers is so that each can release on it?s own time frame and know with certainty that they are not breaking the whole system. Pact provides the contract generation mechanism (along with a fake server so the consumers don?t need to hit the actual producer), the pact broker, and the contract verification mechanism (along with a fake client so the producer doesn?t need to have actual consumers during the test).

matt.fellows
2021-06-18 01:09
1. The consumer writes the pact tests and is thus the ?owner?. The provider verifies them, but need not comply with them (i.e. if a consumer wants something the provider can?t/won?t do - it has control) 2. As per (1), but the teams should still talk to each other 3. Yes, that is pretty standard - you can have multiple contracts for a single provider 4. Maybe, it may not need to extend any tests, depending on what S needs. 5. Team B should care about its consumers so that it doesn?t break them, can understand its actual usage, and can safely evolve new features. It can also relieve the need for end-to-end integration tests, which are usually painful for all parties involved 6. There is some coupling, yes. See documentation regarding provider states and data management in alleviating some of these challenges. The scenario names aren?t necessarily a problem, but the specific scenario needs require coordination (e.g. ?product 123 exists?) 7. yes, each consumer should identify what it needs. Just because they overlap at certain points in time doesn?t mean they always will, and won?t always necessarily use exactly the same fields etc. Pact gives you visibility into exact usage 8. In the provider tests, you start the spring boot app up and Pact replays the consumer requests against it. Pact does not mock the provider during this phase of testing. For a _consumer_ test, Pact provides a mock of the _provider_. 9. See the https://docs.pact.io/provider/handling_auth/ regarding dealing with these

jan.malkiewicz
2021-06-18 07:00
Thank you both for the detailed explanation :slightly_smiling_face:

jan.malkiewicz
2021-06-18 07:10
One more question, which team should care about that there is not too much duplication in contracts among the teams (points 3, 4, 6, 7)? How would you setup the teams in practice - maybe a virtual team from each team B, G, F, S which should care about contract tests from both sides?

matt.fellows
2021-06-18 07:19
The provider ultimately owns the service, so should be providing feedback on bad contracts and trying to minimise the work on their side.

jan.malkiewicz
2021-06-18 07:19
Thanks for quick answer.

tomknee1
2021-06-18 08:15
has joined #general

tomknee1
2021-06-18 08:18
Hello all, just joined this slack group, glad to be a part of it. I had one quick question in regards to BDD and contract testing with Pact please. In a team practicing BDD, and turning scenario-oriented Acceptance Criteria into Automated/Executable Specifications, does it make sense to use both a Gherkin communication tool like Cucumber with Pact? Or should contract tests not use the Gherkin layer? Appreciate any thoughts on this. Thanks.

abubics
2021-06-18 09:19
Generally, I'd say don't use gherkin syntax at all :stuck_out_tongue: its intended purpose is usually not fulfilled. But, less cynically, I'd still say don't use gherkin for contract tests, because they're at a lower level, not user-facing features. (Expressing user-value behaviour is where gherkin's meant to shine) I still like other BDD-flavour phrasings, like given-when-then, and use those with Pact.

abubics
2021-06-18 09:20
Of course, you can do whatever you like, it's just extra abstraction layers on top on your test framework. But consider the maintenance effort, and the kinds of expressiveness (different utility to different user groups) you can get from your options.

abubics
2021-06-18 09:23
Pact actually binds in some BDD in its own DSL, where the phrasing is ? given [some provider state] ? upon receiving [some specific kind of request] ? will respond with [some specific response shape]

tomknee1
2021-06-18 12:02
thanks this makes sense

elliottmurray
2021-06-18 14:11
I think Dan North calls this chunking - using the right language for the level of problem you're solving.

tomknee1
2021-06-18 14:13
i guess my thinking is BDD when used right is good for in-sprint automation, but by the sounds of it, contract tests are considered lower level, so the higher level scenarios (that can be written in Gherkin) can help guide development as well as lower level unit tests (where i guess contract tests would fall under more) ?

elliottmurray
2021-06-18 14:17
If you're following the outside in pull approach you would try to automate a scenario in Cucumber and this would lead you in to things like unit tests and Pact tests (so yes) Also I wouldn't use something like Cucumber to do E2E tests on a Microservices architecture - you would bound it's context to maybe some FE system with say stubs.

tomknee1
2021-06-18 14:19
so its for a new role i will be starting soon, consists of microservices but also an Android frontend, so was planning to use Cucumber for the Android FE side and then lead into the lower level tests like pact

tomknee1
2021-06-18 14:19
along with everything else in a BDD approach in terms of user stories etc

elliottmurray
2021-06-18 14:20
this sounds like a solid plan. As Boris pointed out there are some alternatives to using Cucumber you might want to consider depending on the team

tomknee1
2021-06-18 14:23
thanks i guess i need to see what their user stories are like. For example if theres a specific user story but its only concerning microservices and not the frontend/user side of things then that would complicate things I think

tomknee1
2021-06-18 14:25
contract testing is similar to bdd in a way that they are both 'attitudes' taken toward development i guess

achuljyan
2021-06-18 20:43
Hi all, Assuming there are 3 microservices ?A?, ?AB?, ?B?.  ?A? consumes ?AB? while ?AB? consumes ?B. In other words ?AB? is a consumer of ?B? and also it?s a provider for ?A?.   ?A? ->?AB?->?B?.  Thus, the AB service should be tested as a consumer and a provider before deployment. The Pact nirvana document recommends creating separate CI / CD pipelines for both the consumer and the provider. Which means ?AB? service should pass through each of the pipelines. Since both pipelines are configured to deploy to the target environment in case if the contract test passed one but failed another, it can result in the deployment of breaking changes to the target environment. I think, taking this to account, it makes sense to have a single pipeline which runs both types of contract tests in one job one after the other, consumer tests and then provider tests. Also to have a separate pact verifier job which is being triggered by Pact Broker webhook. Are there any recommendations/best practices for setting up a CICD pipeline for "consumer-provider" types services?

matt.fellows
2021-06-18 23:36
The document is describing separate pipelines for consumers _and their providers_ i.e. for different applications

matt.fellows
2021-06-18 23:37
In the case an app is both, you still have one pipeline for the application as you note

matt.fellows
2021-06-18 23:37
A separate provider only build applies

bethskurrie
2021-06-19 01:28
@tomknee1 I'd use pact to generate the contract by creating unit tests for the classes that call out to the other services, and then use the generated contract in a stub for the cucumber tests.

bethskurrie
2021-06-19 01:29
You can either use a pact stub, or parse the pact and use it to set up mocks with more sophisticated mocking tools.

bethskurrie
2021-06-19 01:29
that way your cucumber tests are always using requests/responses that are verified to be compatible with the real service.

bethskurrie
2021-06-19 03:19
I think Matt got distracted, and was going to say "a separate provider build only applies for the provider verification step when a 'changed pact' webhook is fired"

matt.fellows
2021-06-19 03:26
yes, the joys of parenting and answering OSS questions with a mobile :stuck_out_tongue:

armen.chuljyan
2021-06-19 03:54
Thank you Beth and Matt :relaxed:

rockin291
2021-06-19 05:18
has joined #general

rockin291
2021-06-19 05:25
Last I used Pact, I found no way to retrieve verification results for a provider. Let's say I had to test the provider's 2nd last commit in `master` and check if it is compatible with required tags of the consumers, I have to run the test by checking out this particular commit for the provider against the consumer tags. But what if this had already happened when one had pushed that particular commit on the provider repo, by means of its CI pipeline? In this case I was hoping if Pact broker stored this result (similar to how it stores consumer expectations), it would be convenient to just fetch the past verification result than re-running the provider tests as mentioned above. Can this be a useful feature (to store provider verification results on the broker)?

matt.fellows
2021-06-19 05:26
The broker has had this information for years

matt.fellows
2021-06-19 05:26
Can I deploy is the feature that will tell you that

matt.fellows
2021-06-19 05:28
"Can I deploy this version of an application to this environment" uses this information

matt.fellows
2021-06-19 05:29
The verification results aren't directly useful, because the consumer situation may have changed since you last checked


rockin291
2021-06-19 07:11
thanks for the response, though I guess my query was a bit unclear

rockin291
2021-06-19 07:12
I am aware of can-i-deploy results, which are stored per combination of provider and consumer versions / tags.

rockin291
2021-06-19 07:13
What I meant to say is the provider contracts (all endpoints and their contracts) per provider version, can't they be stored on Pact broker also, rather than being calculated repeatedly per commit (where one has to checkout the provider commit and run the service), just because consumer build is new / expectation changed.

matt.fellows
2021-06-19 07:14
All of the verification results are there, they should be accessible by API

matt.fellows
2021-06-19 07:14
You'd need to hit the root resource and navigate to it, I'm on mobile so can't check right now

matt.fellows
2021-06-19 07:15
But I still don't understand how it would be helpful

rockin291
2021-06-19 07:16
Let's say the broker already has the contract json for all provider versions, in that case the broker can do the verification itself, via an API call, rather than the provider pipeline having to run the service to spin up the contracts and then running the verification.

rockin291
2021-06-19 07:17
Only if the provider contract json is missing on the broker, one might have to run the provider pipeline to generate it first and then upload to the broker.

matt.fellows
2021-06-19 07:17
What do you mean by "provider contract JSON". There is no provider contract, is this what you're asking for?

rockin291
2021-06-19 07:18
yeah that's my query on a high level

rockin291
2021-06-19 07:18
broker seems to not store provider contract, all endpoints and their objects in json format for eg

rockin291
2021-06-19 07:19
it could be a useful cache to check consumers against older versions of provider for which build pipeline has already run in the past

rockin291
2021-06-19 07:20
perhaps you can double check the broker APIs when you get access to your system I can wait for you to confirm later

matt.fellows
2021-06-19 07:20
It definitely doesn't store that info.

matt.fellows
2021-06-19 07:20
When you say provider contract, you're referring to the actual responses right?

matt.fellows
2021-06-19 07:21
In any case, I still don't see why can-i-deploy can't be used

rockin291
2021-06-19 07:21
_the actual responses_ I mean not the data within, but only the skeleton of the contract

matt.fellows
2021-06-19 07:21
Yeah

matt.fellows
2021-06-19 07:22
We've discussed this concept before

rockin291
2021-06-19 07:22
so can-i-deploy value is just true or false

matt.fellows
2021-06-19 07:22
What do you want to achieve other than a year/no?

rockin291
2021-06-19 07:22
My request is to store the entire json skeleton of the contract, per provider version, for already run pipelines, which would upload it to the broker.

matt.fellows
2021-06-19 07:22
I guess I'm asking What's the use case?

rockin291
2021-06-19 07:23
the use-case is for consumers to not wait for a build from provider while checking compatibility against an older or stable version of the provider

rockin291
2021-06-19 07:23
so this verification can be lot faster if consumers only have to call an API on the broker

rockin291
2021-06-19 07:23
rather than waiting for the dependent provider pipeline to run, build the service and then do the verification

rockin291
2021-06-19 07:24
let me know if I am able to describe the value-add clearly

matt.fellows
2021-06-19 07:25
Can I deploy can answer that now

rockin291
2021-06-19 07:25
can-i-deploy can only answer for existing combination of consumers and providers, not for the use case I am talking about, let me give an example

rockin291
2021-06-19 07:26
provider version 1.0.0 exists on production let's say

matt.fellows
2021-06-19 07:26
The use case for a provider contract is when a consumer has not been tested against a version of a provider before. Is that what you need?

rockin291
2021-06-19 07:26
and consumer 1.0.0 also is also verified against this provider successfully

rockin291
2021-06-19 07:26
> The use case for a provider contract is when a consumer has not been tested against a version of a provider before yes, that's roughly what I am try to describe

rockin291
2021-06-19 07:27
so consumer 1.0.0 can-i-deploy will be true, as the results already exist

rockin291
2021-06-19 07:27
but now let's say consumer 1.0.1 has been just pushed to git repo

rockin291
2021-06-19 07:27
this new consumer 1.0.1 wants to check compatibility against provider 1.0.0

rockin291
2021-06-19 07:28
that becomes time taking, as provider pipeline has to run again for 1.0.0, as the contracts don't exist on broker

matt.fellows
2021-06-19 07:28
No, that only needs to happen is the consumer's contract changes

matt.fellows
2021-06-19 07:28
But if it does change, yes. And a provider cache could certainly help

rockin291
2021-06-19 07:29
and only after this is verified on the provider, and the results published to broker, can-i-deploy for consumer 1.0.1 against provider 1.0.0 will return true

rockin291
2021-06-19 07:29
> But if it does change, yes. And a provider cache could certainly help

rockin291
2021-06-19 07:29
exactly my point yes :thumbsup:

matt.fellows
2021-06-19 07:30
:wink:

matt.fellows
2021-06-19 07:30
It's clearer now

rockin291
2021-06-19 07:30
we have built such capability in hand written contract verifiers before, long ago when Pact didn't exist

matt.fellows
2021-06-19 07:30
Can you please raise a feature request at http://pact.canny.io referencing this convo and summarising the key value?

rockin291
2021-06-19 07:30
but Pact is so awesome in all its features, so I thought I would request this one additional value add which might help

rockin291
2021-06-19 07:32
> Can you please raise a feature request at http://pact.canny.io referencing this convo and summarising the key value? Sure, I can do that, thanks for your help Matt :raised_hands:

matt.fellows
2021-06-19 07:33
No probs, thanks for the idea!

rockin291
2021-06-19 07:34
Matt, last question: Is *Pact Broker* the right category for the feature request?

matt.fellows
2021-06-19 07:34
:+1:

rockin291
2021-06-19 07:41
Done, here is the feature request post: https://pact.canny.io/feature-requests/p/cache-provider-contract-on-pact-broker PS: Let me know if I have to forward it to any other channels like `feature-requests`

matt.fellows
2021-06-19 07:41
All good. I'll take a look Monday and clean it up

rockin291
2021-06-19 07:41
Thanks Matt Have a good day.

matt.fellows
2021-06-19 07:42
I wouldn't change the consumer experience - it could be a broker only feature

rockin291
2021-06-19 07:42
okay understood

matt.fellows
2021-06-19 07:42
I.e. can-i-deploy would be true in the case the cached result is compatible

rockin291
2021-06-19 07:42
nice, sounds good

matt.fellows
2021-06-19 07:43
FWIW we've done a bit of thinking about provider contracts and a provider driven flow. This may align with that

rockin291
2021-06-19 07:43
nice to know that

rockin291
2021-06-19 07:44
please share if possible any blogs or links related to the provider driven flow idea

matt.fellows
2021-06-19 07:45
It's been several chats in this slack workspace and in some private channels, but if we do it'll show up in the main channels herr

rockin291
2021-06-19 08:01
okay understood :thumbsup:

tomknee1
2021-06-19 09:35
@bethskurrie thanks, so just to clarify for consumer driven contract testing, couple the consumer tests in same language consumer service is implemented in, generate the contract, then use that in a stub on the provider testing side for the cucumber tests?

zainamro1
2021-06-20 17:17
has joined #general

abubics
2021-06-21 01:19
The consumer tests that generate the contract are typically almost indistinguishable from unit tests - same codebase, same language, same execution/workflow context :thumbsup:

bethskurrie
2021-06-21 01:20
No, sorry @tomknee1.

bethskurrie
2021-06-21 01:20
The pact is already the "mock consumer" for provider side tests.

bethskurrie
2021-06-21 01:21
I meant, use the pact to create a stub of the provider for the consumer side cucumber tests.

nferrazzano
2021-06-21 05:23
has joined #general

tomknee1
2021-06-21 08:13
gotcha, thanks

tjones
2021-06-21 09:13
Reading the above it sounds like you might have different commits with the same provider version? I would advise against doing that, because you lose assurance that the code behaves the same


tjones
2021-06-21 09:15
Also, if you release V1 of your consumer, with a contract, verify that against the provider, then release V1.1 which has an identical contract, then it is already considered verified in `can-i-deploy`

matt.fellows
2021-06-21 10:04
We did cover that. The specific scenario I think it helps with is where a consumer needs a new field from the provider that it already supports (by virtue of pact having seen the responses already) but just hasn't been added to a consumer test yet. This would support that flow without needing the whole orchestration rigmarole. Doesn't cover things that haven't been tested of course. It would be nice

matt.fellows
2021-06-21 10:05
There is at least one consideration if we added this (more for Pactflow). Potentially real responses may be sent to the broker, if it was used against live systems (still pretty common)

matt.fellows
2021-06-21 10:05
We'd need to consider privacy/confident data etc a bit more carefully

tomknee1
2021-06-21 10:24
@bethskurrie sorry I have one more question please based on some confusion. In my new role it has an Android frontend with many microservices within an event-driven architecture if its kind of similar to the architecture in the image below, would I want to keep the Cucumber tests 'event consumer-driven' or have it more focused on the 'event producer' side in terms of language and outside in approach? Thanks

lewis.prescott079
2021-06-21 12:55
has joined #general

vlad
2021-06-21 18:23
has joined #general

christopher.doherty
2021-06-21 19:01
has joined #general

thanuxxxx
2021-06-22 01:45
Hi to all, quick question, how to invoke a web-hook if I publish to contract at first time. Right now I am just go to broker and create a web-hook via pb:create. The problem is I have to trigger a provider built manually. Am I doing this in the correct way? :confused:

bethskurrie
2021-06-22 01:46
Sorry, I don't understand the question



thanuxxxx
2021-06-22 02:07
Let's say this is the very fist time I publish a contract to broker, we won't have a web-hook right?

thanuxxxx
2021-06-22 02:10
So how to trigger first provider side verification? I can create a web-hook after very first pact publication

matt.fellows
2021-06-22 03:28
You can setup a webhook for the _provider_ before any new consumer publishes a contract


matt.fellows
2021-06-22 03:29
You don't specify the consumer name in that webhook, which means it will fire for any consumer for that provider

thanuxxxx
2021-06-22 03:34
Awesome!! thanks guys, since I have Jenkins CI/CD I am following this example https://kreuzwerker.de/en/post/integrating-contract-tests-into-build-pipelines-with-pact-broker-and

matt.fellows
2021-06-22 03:34
:+1:

matt.fellows
2021-06-22 03:35
Shout out to @kristine.jetzke :taco:

bethskurrie
2021-06-22 03:35
Taco for @kristine.jetzke!

liorra
2021-06-22 04:17
has joined #general

kristine.jetzke
2021-06-22 07:24
:woman-bowing:

matt.fellows
2021-06-22 07:29
Moar Jenkins, it's a system I haven't used for years but is still popular it seems

matt.fellows
2021-06-22 07:29
Maybe someone will make that Jenkins plugin for you @bethskurrie

2021-06-22 07:29
There is no Jenkins plugin for Pact because a plugin is not needed. Pact tests run as part of the application's unit test suite.

matt.fellows
2021-06-22 07:29
:point_up:what about for publishing and integrating to the broker?

uladzislau_danilchyk
2021-06-22 07:39
Hi everyone! We have some issues with deployed Pact Broker 2.79.0.0. Sometimes it doesn't trigger configured webhook for event contract_content_changed. Not always, but sometimes. Previously we had Pact Broker 1.x and everything was ok. Could anyone help me with that or check it by yourself?

uladzislau_danilchyk
2021-06-22 07:56
Additional question is that there is a "event detected" log by https://github.com/pact-foundation/pact_broker/blob/b0eb53d9e8fbe3445fe788d0d76ca0569d58e5c9/lib/pact_broker/webhooks/event_listener.rb#L51 but no logs are found in log file... Can anyone help me with that as well? Used log level - WARN

stanojevic.boban
2021-06-22 10:20
has joined #general

matt.fellows
2021-06-22 10:40
Probably best for this to go in #pact-broker Danil

matt.fellows
2021-06-22 10:40
A log trace showing the event firings would be nice too

uladzislau_danilchyk
2021-06-22 11:37
@matt.fellows, thank you! Already fixed that issue. Level log just changed to INFO from default one.

uladzislau_danilchyk
2021-06-22 11:37
In that case issue with our CI was faced. Question is invalid.

kristine.jetzke
2021-06-22 12:14
tbh when I wrote the blog post that was also the last time I used Jenkins. But regarding build servers... If you know Jenkins, you can "infer" any build server in my opinion :wink:

miguel.carneiro
2021-06-22 12:51
has joined #general

miguel.carneiro
2021-06-22 14:39
Hi, We are facing an issue in our pipelines when removing a Provider java class, as it stands we should be validating that the consumers are not affected when the provider is deleted or changed. But the pipeline is passing. At the moment, we are creating a branch where we remove Provider classes, expecting the pipeline to fail when tested with all current consumers. To run the pipeline we are using a multiple setep approach, starting with a mvn call with the following mvn arguments ```-Dpactbroker.consumerversionselectors.tags=master -Dpactbroker.providerTags=master -Dpactbroker.host=${PACT_BROKER_HOST} -Dpactbroker.auth.token=${PACT_BROKER_TOKEN} -Dpact.verifier.publishResults=true -Dpact.provider.version=$PACT_PROJECT_VERSION -Dpact.provider.tag=$BITBUCKET_BRANCH``` In the logs we are able to see that we are checking against the consumers, but the following appears > Not all of the 6 were verified. The following were missing: > xxxxCommand > yyyyCommand But it still passes. And a second step where we call can-i-deploy in a docker command ```docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL=https://$PACT_BROKER_HOST -e $PACT_BROKER_TOKEN pactfoundation/pact-cli:latest broker can-i-deploy --broker-base-url $PACT_BROKER_HOST --broker-token $PACT_BROKER_TOKEN --pacticipant ${BITBUCKET_REPO_SLUG} --version $PACT_PROJECT_VERSION --to master --retry-while-unknown 60 --retry-interval 10``` I assume that the first step of the pipeline, the maven call, should fail as the contract will be broken. ? Are we wrongly configuring pact? We have filtering enabled. fyi @rafael.espillaque @william.pritchard

fnguyen
2021-06-22 17:26
If I want to test PUT or DELETE, is there a way to specify multiple queries to test in a specific order or do I have to use a state middleware in my provider ?

phil.endsley
2021-06-22 17:31
What language are you using? Pact has a feature, provider states, that give you a hook to setup any necessary state. Pact tests should not be order dependent

fnguyen
2021-06-22 17:31
My client is in c# (.NET). Not sure about the provider.

fnguyen
2021-06-22 17:32
The pact is created by the client, but the state middleware would be on the provider.

fnguyen
2021-06-22 17:33
I have read about it and was trying to find a way that would not need state endpoint.

phil.endsley
2021-06-22 17:34
Ah. I think that's dependent on the provider's language and implementation

phil.endsley
2021-06-22 17:34
But yes, the client defines the state (in the given clause), and the provider implements whatever state manipulation is needed on its side

srinagasai.krishnasan
2021-06-22 17:35
has joined #general

phil.endsley
2021-06-22 17:35
How that's done is dependent on the pact library for that language I think. If you haven't already, #pact-net would be a good place to ask

fnguyen
2021-06-22 17:37
So the client says *given there is a person with name "bob"* and the provider has an endpoint that takes it and creates the user bob if needed before the test to delete it. We need to make sure this endpoint is disabled before shipping.

matt.fellows
2021-06-23 01:48
> Not all of the 6 were verified. The following were missing: I?ve not seen that before, perhaps it?s a #pact-jvm specific output?

matt.fellows
2021-06-23 01:50
@pact544 @yann.courtel FYI this is reason why mapping provider states to a registered function in the test context is nice. No need to worry about adding middleware that shows up in prod. That being said @fnguyen, assume there is a way to add middleware in your test context/package that won?t be part of the shippable application? Most languages have a way of extending the API that doesn?t require you do it in the source package.

varnit.garg2424
2021-06-23 06:19
has joined #general

varnit.garg2424
2021-06-23 08:05
Hi guys! Newbie here. I have a scala project and planning to start with the basic pact test. Messaging queue is being used between provider and consumer. Can you please advice should I use *scala-pact* or *pact-jvm* ? And can you please point me to any example project for reference? :slightly_smiling_face:

matt.fellows
2021-06-23 08:06
I?m assuming they are scala projects then?

matt.fellows
2021-06-23 08:07
I don?t think scala currently supports message Pact (you should ask in #pact-scala-itv). Pact JVM definitely does.

varnit.garg2424
2021-06-23 08:10
Hey @matt.fellows, thanks for the prompt response! Let me ask in #pact-scala-itv Btw, If I go ahead with pact JVM, would there be any complications or it should work properly?

matt.fellows
2021-06-23 08:11
I mean. It supports message pact so it should work. Just the usual interoperability differences you'd expect between java/scala I suppose

yann.courtel
2021-06-23 08:29
@fnguyen You will need (for now) to create a provider state for each of your instructions you want on the provider side. And yes, even with the data. Meaning you will write "given the customer bob exists". In the next beta version, the 4.0.0, you will be able to chain and put parameters into these, but for now it's the only way. To execute the provider states, you can use a middleware (ProviderStateMiddleware in the samples application of the pact-net source code) or you can also encapsulate pact-net into your own custom lib, read the the provider states from the contract and execute your instructions with no extra middleware (we've done that in our organization). You will need to expose a dictionary of invoking methods to be able to do that.

sams.prashanth
2021-06-23 09:06
Hey @matt.fellows, this page throws 404 in the morning https://docs.pactflow.io/docs/workshops/bi-directional/provider/contracts/pact/#publishing-the-provider-contract--results-to-pactflow and this link redirects to the wrong page as I believe

yann.courtel
2021-06-23 09:11
@fnguyen For your comment "We need to make sure this endpoint is disabled before shipping". This middleware would just be activated in your dependency injection of the provider tests project so it won't be in your API dependency injection component. See here: https://github.com/pact-foundation/pact-net/tree/master/Samples/EventApi/Provider.Api.Web.Tests

matt.fellows
2021-06-23 09:40
I assumed that was possible, Tha ka Yann

matt.fellows
2021-06-23 10:15
hmm is that the link I sent you or did you get there somehow?


matt.fellows
2021-06-23 10:16
Just trying to chase down where to fix, thanks for reporting though

matt.fellows
2021-06-23 10:16
(FYI #documentation might be a good place for this discussion going forward)


sams.prashanth
2021-06-23 10:23
ah okay

miguel.carneiro
2021-06-23 11:21
Thanks @matt.fellows, I?ll raise this in jvm

matt.fellows
2021-06-23 12:35
:+1:

varun.patil
2021-06-23 12:44
has joined #general

rafael.espillaque
2021-06-23 15:46
thanks, Matt. I have a more theoretical question though. If the provider deletes a test for a previously verified pact, would you expect the provider tests to fail, the can-i-deploy step, or nothing to fail? We use the full flow, with pactflow as a broker, pending pacts... in case that matters.

fnguyen
2021-06-23 19:22
Thank you for all the details. I am on the customer side, so I need to generate the pact but I will leave it to someone else to run the test on the provider side and deal with the state.

bethskurrie
2021-06-23 23:24
@tomknee1 sorry, I don't understand the question. Maybe you could give me an example of each? Are you talking about the cucumber tests for the consumer or the provider?

david.vancouvering
2021-06-23 23:39
Hey, all. Does anyone know what flavor of regex is used in the Pact specification? It says regex is supported, but there are many different flavors out there :disappointed:

mselvakumar
2021-06-23 23:54
has joined #general

abubics
2021-06-24 00:45
It's ruby (for legacy reasons)

david.vancouvering
2021-06-24 01:22
OK thanks

abubics
2021-06-24 01:31
https://rubular.com/ is a handy app for testing stuff, if you don't have/want a local ruby install :slightly_smiling_face:

david.vancouvering
2021-06-24 01:32
Ha, thanks, I was in the middle of using that when I saw your Slack message...

srikanth.rachakonda
2021-06-24 02:32
has joined #general

ali.akbar
2021-06-24 06:58
has joined #general

tomknee1
2021-06-24 08:40
@bethskurrie no worries, thats kind of what I'm asking. Based on that image above, when you add event driven architecture it looks like the backend services are the consumers and the frontend apps/services are the event producers. So I guess my question is wouldn't the Cucumber tests be more producer-driven, due to the event producers being the frontend? Or should the Gherkin scenarios be written in a way that makes them sound more consumer driven? If the cucumber tests were producer driven, then would this flip the side of contract testing i cover in the Cucumber tests? Hope that makes sense, sorry, just trying to get a firm understanding of strategy to take :slightly_smiling_face: Thanks

sams.prashanth
2021-06-24 14:08
Is it possible to see the OAS spec uploaded to pactflow in the pactflow interface?

sams.prashanth
2021-06-24 14:09
or is it in the temp memory that we can't see it visually?


matt.fellows
2021-06-24 14:12
UI is currently WIP

matt.fellows
2021-06-24 14:12
API only at the moment

sams.prashanth
2021-06-24 14:13
Oh ok ok. Love to see it soon :slightly_smiling_face:

dawoud.sheraz
2021-06-24 18:11
Hey folks. A question that has been bugging me lately. What?s the effective way to run provider verification(regardless of the language)? There are different examples on the internet that seem to do it via unit tests but never seem to explain the reason why it is done via tests. Since the aim behind verification is making sure the contract is not violated, what would be best way to run the verification? if it is indeed the unit tests, why?

erterpstra
2021-06-24 19:20
has joined #general

abubics
2021-06-25 00:33
Depends what language you're using, but the original workflow was: ? fetch contract ? for each interaction: ? hit the state change endpoint (if required) ? play the request ? assert on the response and only a little bit of tooling around it. This is still the workflow for the gradle plugin, for example. I've only seen the junit bindings that allow provider verifications to happen during the test phase, so I can't comment on other languages/platforms. The workflow is essentially the same, it just provides different lifecycle hooks in a more natural testing idiom.

abubics
2021-06-25 00:34
I'm using `junit5spring` for the first time now, and it's definitely less setup work for me to use the annotations & provide mocking code in my test sourceSet, rather than a custom state change endpoint, and gradle config.

bethskurrie
2021-06-25 01:49
I don't think it matters either way. Write your cucumber tests in which ever way it makes sense to you as the developer to write them.

bethskurrie
2021-06-25 01:50
Just don't use cucumber tests to *generate* the pact (use unit tests instead).

tjones
2021-06-25 04:23
From a javascript perspective, the advantage of doing it in a unit testing context is that it's easier to instrument the application for making state changes (if you do it that way, you don't necessarily need to expose a state change endpoint on your service)

tjones
2021-06-25 04:24
of course, if you're able to expose the state change endpoint (or you're not using provider states), then you don't need to do verification in a unit testing context, and you can use language / framework for pact verification. It's almost personal taste

tjones
2021-06-25 04:26
Another advantage of doing verification in unit tests is that you can use all the standard tools you use with other tests, eg code coverage.

dawoud.sheraz
2021-06-25 05:24
My concern is with Python, to be more specific. Talking about the verification flow, doesn?t the verifier handles the contract fetch and interaction looping internally(Ref: https://github.com/pact-foundation/pact-python/blob/master/examples/e2e/tests/provider/test_provider.py)? Since all is handled internally and we get the response/logs depicting if any interaction failed, I don?t see the reason to do it in unit tests. Furthermore, since the state change endpoint will be needed for complex applications to bring the db into appropriate state, I don?t see how unit tests tooling can overcome that.

matt.fellows
2021-06-25 05:35
We did a couple of AMAs that answer this in more detail: https://docs.pact.io/help/amas/#north-america

matt.fellows
2021-06-25 05:36
See mocking provider dependencies and also the one about unit tests

tjones
2021-06-25 05:37
> I don?t see how unit tests tooling can overcome that. If it doesn't make sense for your usecase, provider design and general ecosystem, then there's no reason to need to use a unit test pattern.

dawoud.sheraz
2021-06-25 05:39
@tjones Right. I have been confused because many examples used the unit test pattern and I thought that was the only way.

tjones
2021-06-25 05:41
FWIW, I used to prefer doing it outside unit tests, and then a discussion with @matt.fellows convinced me that doing it in a unit test framework had enough advantages (eg seeing code coverage, and being able to spin up the provider without extra endpoints). In my view, whatever works for your preferences and environment is fine.

tjones
2021-06-25 05:42
> Furthermore, since the state change endpoint will be needed for complex applications to bring the db into appropriate state, I think this is the main point. Some of the frameworks let you do state change without endpoints. I don't know if Python does.

bethskurrie
2021-06-25 05:43
Anyone used trunk based development with feature toggles rather than feature branches? I'm looking for some feedback on the "tags with feature branches" docs I've just written here: https://docs.pact.io/pact_broker/tags/#using-tags-with-feature-toggles-instead-of-feature-branches

dawoud.sheraz
2021-06-25 05:44
Right, but fetching and replaying the interactions is done internally by the provider(unless I am missing something). With the state change endpoint, it is easier to isolate the db setup per interaction(and pact also suggest to take each interaction independently).

matt.fellows
2021-06-25 05:45
Not every state is a database change, it might also mean stubbing out 3rd party systems. This is much easier with access to unit testing stubbing tools

matt.fellows
2021-06-25 05:46
But as Tim said, whatever works for you

dawoud.sheraz
2021-06-25 05:47
From what I have understood and read so far, we want to test the interaction against the actual provider(with appropriate mocks for the provider dependencies). If I talk about Django/Flask, we would need to run a server with test configuration to replay the interactions. If we mock the server altogether, we can end up changing the way provider behaves(as Matt mentioned in AMA). Again, it depends upon the context and exact use-case.

matt.fellows
2021-06-25 05:52
Ah I mean to talk to you about this!

matt.fellows
2021-06-25 05:52
A customer was asking, I'll DM you a little later

abubics
2021-06-25 05:56
we're using branch and toggles together . . . I'll have a look

abinzahid
2021-06-25 06:12
has joined #general

bethskurrie
2021-06-25 06:20
I'll admit, I use branches and toggles with the pact broker client.

bethskurrie
2021-06-25 06:22
Anything that I want to dog food in Pactflow I feature toggle on master with an env var, so I can do a proper release of the docker image.

bethskurrie
2021-06-25 06:23
But I also use branches when I don't want to potentially screw up master.

abubics
2021-06-25 07:38
ok, I started trying to read it, but it doesn't really fit my use case. So maybe feedback from others who exclusively use toggles would be better :thumbsup: (but hmu if you want me to try again anyway)

abubics
2021-06-25 07:39
(My use case is short (sometimes partial) feature branches, with api features almost never (if ever?) toggled, so everything is always verified, and only bits of the UI are hidden (toggled))

tomknee1
2021-06-25 09:12
ok that clears it up a lot for me, think i was over complicating it. Thanks so much :slightly_smiling_face:

scott.riley111
2021-06-25 10:08
Is there a channel for discussions about using the standalone pact verifier cli? It?s not building with `cargo install pact_verifier_cli` on latest stable rust

tjones
2021-06-25 10:08
I?d say that?d be #pact-rust

tjones
2021-06-25 10:09
There are two standalones, the rust one, and the ruby one. There is a channel for the ruby one (it has been around longer and has more users). Moving forward I don?t know if we?ll need a separate channel

scott.riley111
2021-06-25 12:09
Great, thanks :slightly_smiling_face:

sams.prashanth
2021-06-25 15:13
Hey @matt.fellows, this page is what I see after the verification results got published during cross-contract-verification process. My question is, how does the `properties` section on left side differs from the `response body` on the right side? it's likely the same content - if so, why do we need properties section

dawoud.sheraz
2021-06-25 18:07
by the way, AMAs are very good in providing some nitty gritty details. Nice work on those. :thumbsup:

matt.fellows
2021-06-25 22:29
I'm glad people watch them! We have a few next week, what should we answer?

matt.fellows
2021-06-25 23:37
This is general HAL browser (a web client to follow the hypermedia resources of the server). The left will have just the resource payload, the right hand side also contains HAL structures such as links to other resources etc

matt.fellows
2021-06-25 23:38
It's a convenient UI for the API but long term we'll have proper screens for this obviously


jchandorkar
2021-06-26 09:01
has joined #general

rani.sathya
2021-06-27 04:14
has joined #general

rani.sathya
2021-06-27 04:16
~Hi Team, I havent received the invite code from Pact to change to new password~

matt.fellows
2021-06-27 04:38
Did you find it?

rani.sathya
2021-06-27 05:00
No, was able to login with temporary password

matt.fellows
2021-06-27 05:03
I'm confused, how would you login without receiving the email that has the temp password?

rani.sathya
2021-06-27 06:20
I have received an email with login id and temp password.. But someway when i landed this page, got me confused expecting for verification code.

matt.fellows
2021-06-27 06:50
Have you disabled styles/CSS? That page is definitely not rendered correctly

rani.sathya
2021-06-27 06:59
No I havent made any changes.

matt.fellows
2021-06-27 07:05
I'd you don't mind, could you please send a HAR extract from that page along with the browser / OS you use to ? You should be able to export one from the developer console of your browser.

matt.fellows
2021-06-27 07:06
Thanks for letting us know, that's definitely not expected UI behaviour (and probably explains the confusion)

sams.prashanth
2021-06-27 08:04
Thank you @matt.fellows

cala.dev_pact
2021-06-28 04:07
has joined #general

robert.rap
2021-06-28 06:34
has joined #general

anchit.99
2021-06-28 06:53
I found an HTTP workflow online and modified it so it's now a message queues workflow. Does this workflow look correct for message queues?

v-ratngupta
2021-06-28 07:13
has joined #general

e.hallowell
2021-06-28 13:28
has joined #general

thanuxxxx
2021-06-28 19:06
Do we have an example for slack integration for contract publish and verify events. I have a JSON template ready but how can I integrate that with pact broker? The same way as how we create a web-hook to trigger a provider built?

thanuxxxx
2021-06-28 19:07
I think I should whitelist http://hooks.slack.com isn't it?

tomknee1
2021-06-28 19:08
there is this one from Amazon too for event driven architecture...

aforeman
2021-06-28 22:07
Hello! ICYMI - @bethskurrie and @matt.fellows are live now (for the next ~25 mins) answering any questions you may have about Pact contract testing. Join us here https://www.youtube.com/watch?v=VnOy9Sv9Opo and ask your questions via #pactflow-ama


matt.fellows
2021-06-28 22:23
you shouldn?t need to whitelist it if it?s https by default

thanuxxxx
2021-06-28 22:31
So setting up a slack hook is same as a regular provider built hook right?

matt.fellows
2021-06-28 22:35
I guess so. The events you care about are different though (provider verified is a provider event)

matt.fellows
2021-06-28 23:10
Recording here: https://www.youtube.com/watch?v=VnOy9Sv9Opo *We covered:* * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=140s - How does Pending Pacts work? * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=645s - How does WIP Pacts work? * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=1050s - Understanding webhooks - how they work, the event cycle and debugging them * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=1465s - (audience question) Can users be synced with Google? Can users be part of multiple teams? * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=1500s - (audience question) Should we have multiple brokers (e.g. 1 per project) or is this something the Teams feature addresses? * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=1630s - (audience question) How does Pact work with IoT solutions? * https://www.youtube.com/watch?v=VnOy9Sv9Opo&t=1650s - (audience question) What are the SLAs for Pactflow SaaS? Are there enterprise options?

matt.fellows
2021-06-29 05:28
I think Anchit is wanting to understand how Pact tests it

matt.fellows
2021-06-29 05:28
rather than a general event architecture/overview?

matt.fellows
2021-06-29 05:31
Quick extract from our demo pack (I?ve numbered them to help in case they upload out of order)

anchit.99
2021-06-29 05:37
@matt.fellows Got it. Thanks for confirming the workflow!

mishalalexander20
2021-06-29 07:36
has joined #general

lukemufc125
2021-06-29 07:57
has joined #general

prash471
2021-06-29 09:43
has joined #general

martijn.hagens
2021-06-29 10:12
has joined #general

paul.simms
2021-06-29 10:22
Thanks for the AMA - always very useful. Just a clarification regarding a question I asked (probably not expressed very well) - to ensure I haven't misunderstood, regarding what comes first, consumer or provider. I understand that you can definitely work on generate the consumer's PACT first as you discussed. However, I still believe that this cannot go through the can-i-deploy step until a provider is available to serve the interactions (what I meant to ask). Is that correct? And then thank you for the clarification that there is now the --no-fail-if-no-pacts-found lag that allows providers to be deployed without consumers.

tjones
2021-06-29 11:04
Pact lets you build the consumer knowing that the provider can come along (and be tested) later.

tjones
2021-06-29 11:04
But I think `can-i-deploy` will not let you deploy if you need a provider that hasn?t been verified yet. Which would be correct - you can?t deploy a consumer if there is no provider for it.

tjones
2021-06-29 11:05
I suspect `can-i-deploy` with `--no-fail-if-no-pacts-found` will work for consumers, although someone else can confirm.

dimundo
2021-06-29 11:06
are there any limitations for pactflow broker ?

tjones
2021-06-29 11:06
I think the ?natural? pact workflow is to build the consumer + tests first, then build the provider and verify, then deploy the provider, then deploy the consumer.

tjones
2021-06-29 11:07
Might be a #pactflow question

tjones
2021-06-29 11:07
(there are, of course, many other ways to do it)

paul.simms
2021-06-29 11:11
Yes, I agree that this is a good workflow. The --no-fail-if-no-pacts-found now should allow that (or if the provider is generated before the consumer), and get over the what can be deployed first - which needs to be provider (as I originally meant in the AMA question). Thanks @tjones

matt.fellows
2021-06-29 11:56
A community member recently spoke about contract testing at a meetup in Europe: https://www.linkedin.com/posts/basdijkstra_contract-testing-why-what-how-activity-6815510346388787200-IB_P

tomknee1
2021-06-29 11:57
Nice, will def check this out, Bas' stuff is good on TAU etc

bas
2021-06-29 12:12
s/Vienna/Amsterdam

bas
2021-06-29 12:12
s/Amsterdam/online

matt.fellows
2021-06-29 12:18
a ?global contract testing meetup?? :stuck_out_tongue:

matt.fellows
2021-06-29 12:19
(or should I say, from space?)

bas
2021-06-29 12:20
That sounds a lot better than 'a bunch of people in pajamas listening to some guy rambling on about this contract testing stuff'

sams.prashanth
2021-06-29 13:52
> Publishing the Provider Contract + Results to Pactflow Hey @matt.fellows, do we need to follow any pattern / compatible format on the OpenApi spec validation results? I use `swagger-request-validator-restassured` library for validation - however it doesnt make any output results - wish to get your suggestions to know if there is any format to follow before uploading it to pactflow along with the provider contract. Would be great if you have any sample results somewhere.

sams.prashanth
2021-06-29 13:55
Would love to hear that in near future :slightly_smiling_face:

mikko.s.koskinen
2021-06-29 17:05
has joined #general

matt.fellows
2021-06-29 22:40
No need at the moment. It's an opaque blob so whatever would be useful later on for your own debugging

zhaoyi0113
2021-06-30 02:13
has joined #general

sams.prashanth
2021-06-30 13:02
Makes sense

sams.prashanth
2021-06-30 13:02
Thank you Matt

sgottipati
2021-07-01 06:02
has joined #general

vshankar
2021-07-01 06:06
has joined #general

e.generalov
2021-07-01 07:19
has joined #general

eduards.klavins
2021-07-01 13:44
has joined #general

dimundo
2021-07-01 14:32
any ideas , how to create pacts for ( some ) messages permutations ? ``` "$.mode": { "matchers": [ { "match": "regex", "regex": "^(Live|Maintenance)$" } ] },```

dimundo
2021-07-01 14:32
this will cover both from consumer side

dimundo
2021-07-01 14:33
but how to manage in producer side ?

dimundo
2021-07-01 14:33
( and if there will be _n_ variants ?

felix.gomez
2021-07-01 14:38
has joined #general

thanuxxxx
2021-07-01 15:18
I am not an expert, but I think if you are expecting Live or Maintenance then you probably need two states in provider side

dimundo
2021-07-01 15:19
yes, so 2 tests there

dimundo
2021-07-01 15:19
easy so far

dimundo
2021-07-01 15:19
but maybe there is generator also for provider ?

dimundo
2021-07-01 15:20
as if permutations amount will grow - it will be sad copypaste story

thanuxxxx
2021-07-01 16:00
What do you mean by a generator?

dimundo
2021-07-01 16:01
something like datadriventests


dimundo
2021-07-01 16:45
@matt.fellows is it still ?NO? after 4 years ?

thanuxxxx
2021-07-01 16:51
As the answers suggests, it depends on your scenarios. If you want to tests all of your possible variations then you still need n stages for your n variants.

dimundo
2021-07-01 16:52
n for 1 variable :wink:

dimundo
2021-07-01 16:55
for 2 it will be a bit more and for m variables :see_no_evil:

david.vancouvering
2021-07-01 17:07
Hi, all. I'm piloting Pact here at eBay. We have a service which acts as an orchestrator; all of its state comes from sending requests to other services and getting back responses. So we have nodejs -> orchestrator --> backend domain services In order for me to run provider verification tests against the orchestrator, I have to either mock the backend domain services or run against the real ones in our staging env. The latter seems very counter to what Pact is all about. So if I'm going to mock, it seems correct to mock using Pact, and using the resulting interactions as contract tests against the backend services. I could mock using WireMock or something similar, but now I have no idea whether those mocks are aligned with the reality of what the backend services are actually doing. Have you experience with this? What is your recommended approach? Thanks!

thanuxxxx
2021-07-01 19:24
Hi all, one more question about creating a web-hook via CLI click https://docs.pact.io/pact_broker/client_cli/readme/#create-webhook for docs, so generally, I just need to create a web-hook once. Does it mean that I use CLI tool locally in my machine to create web-hooks? I am not sure I can create a web-hook as part of my build pipeline ( the way I do for `can-i-deploy` and `create-tag`) because that will create web-hook every time when a build is trigged. or Do we have an example where a web-hook is created via CLI?

bbako
2021-07-01 20:51
has joined #general

matt.fellows
2021-07-01 23:36
I wouldn?t test it

matt.fellows
2021-07-01 23:36
It could be expanded on the provider side, but then we?d need a mechanism to expand each test case into _n_ provider states (essentially) to be able to illicit the correct matching response.

matt.fellows
2021-07-01 23:38
See https://docs.pact.io/help/amas/#apac-1. We actually did an AMA on this:

matt.fellows
2021-07-01 23:38
Also https://docs.pact.io/provider/#stub-calls-to-downstream-systems which is mentioned. But the video might be helpful, as @uglyog talks about using Pact for that purpose

matt.fellows
2021-07-01 23:41
I think the webhooks are idempotent, in that you can always create them each time

matt.fellows
2021-07-01 23:42
But you could use something like our Terraform provider


matt.fellows
2021-07-01 23:43
Ideally, you want the webhook as code (infra-as-code) and to have it run in a pipeline. This may be inline to your service, or a separate configuration one. Whatever makes sense

matt.fellows
2021-07-01 23:54
Lastly, I think you might be aware of this approach https://docs.pactflow.io/docs/workshops/bi-directional. Not sure with your specific tech stack if that would be useful, but I believe we discussed this with your team on a call a few months back.

tjones
2021-07-02 02:47
I usually do the mocks in software only - say you have something like a `Controller` that calls a`Service` (which does business logic), then that calls a `Repository` layer (or whatever) that does your downstream callout. In that scenario, I would mock the `Repository` layer very cheaply during a pact test

tjones
2021-07-02 02:47
it's nice because you can then describe your mocks in terms of business logic (because ideally that's the language that the `Repository` layer is implemented in)

dimundo
2021-07-02 05:47
> I wouldn?t test it but then such regexs could be replaced with just a string matcher

dimundo
2021-07-02 05:48
and agree - it is a challenge to be done by producer

phil.armstrong
2021-07-02 06:49
has joined #general

matt.fellows
2021-07-02 07:04
> but then such regexs could be replaced with just a string matcher (edited) that?s fair. But I still like to have it there because it does reflect what the consumer can actually handle (in the case of a semantic field)

gargshubham49
2021-07-02 07:21
has joined #general

gargshubham49
2021-07-02 07:25
Hi all, https://pact.kadena.io/ is down and throwing 504 error. Is that getting tracked?

matt.fellows
2021-07-02 07:26
wrong pact

matt.fellows
2021-07-02 07:27
That?s a ?smart contracts? platform for blockchain, and they stupidly decided to call it Pact. The *real* Pact documentation is http://docs.pact.io

gargshubham49
2021-07-02 07:28
Do we have some interface where we could write pact files? Something like this https://pactlang.org/beginner/online-editor/

matt.fellows
2021-07-02 07:30
you don?t write pact files by hand

matt.fellows
2021-07-02 07:30
you write tests in code, which produce contracts

matt.fellows
2021-07-02 07:30
Think of Pact as a unit testing framework

matt.fellows
2021-07-02 07:30
howtopact

2021-07-02 07:30
See this page for an animation explaining how pact works https://pactflow.io/how-pact-works

matt.fellows
2021-07-02 07:30
howtolearn

2021-07-02 07:30
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2021-07-02 07:30
there?s a few useful resources to get started sir!

gargshubham49
2021-07-02 07:32
I looked into it. So I am creating provider test for my REST APIs, and now I have to write pact file for that. So I thought maybe there is some interface to create pact file easily

matt.fellows
2021-07-02 07:32
you?re missing the point though, the contract is the side-effect, the tests themselves are the artifacts you care about

matt.fellows
2021-07-02 07:33
your ?job? isn?t to create a pact file

matt.fellows
2021-07-02 07:33
It?s to create a good set of tests for your consumer

gargshubham49
2021-07-02 07:34
what if we are not the consumers? then we wont write consumer tests right? or my understanding is not correct?

matt.fellows
2021-07-02 07:34
yep that?s right, the consumers write those tests

matt.fellows
2021-07-02 07:35
You can definitely write a dummy consumer, but I wouldn?t recommend writing a pact file by hand

gargshubham49
2021-07-02 07:35
so consumers are not built yet. we have to create REST APIs and we are writing provider tests for it

matt.fellows
2021-07-02 07:36
So you should still write provider tests (presumably you have other testing tools - e.g. junit, jest and so on) - that you should write unit/functional and other tests for

matt.fellows
2021-07-02 07:36
For a contract test, you could write a dummy consumer that uses all of the endpoins and publish a pact. That?s one way

gargshubham49
2021-07-02 07:37
Is it the only way?

matt.fellows
2021-07-02 07:38
What are you trying to prove?

gargshubham49
2021-07-02 07:40
I was exploring if we have some ui-interface where we could write/autocomplete/generate pact files


matt.fellows
2021-07-02 07:43
I mean, you can do it, but once a real consumer comes along you?ll want to use the real ones

gargshubham49
2021-07-02 08:01
okay Thanks for the info @matt.fellows

marko.justinek
2021-07-02 08:44
Need better tests

phil.armstrong
2021-07-02 12:17
Hi, I have a question about pact-stub-server if that's ok? I can't see a specific channel for it. We're investigating using pact for contract testing, and also utilizing the contracts to provide mocks to our browser tests. I've got everything setup locally in docker. Got an contract for an endpoint setup with 2 different states, the stub-server returns one of them. Is it possible to toggle which one is returned?

dimundo
2021-07-02 13:47
what will happen if contract file will have some `"value":null` ? will it be skipped ?

paulorochag
2021-07-02 21:04
Thank you so much Matt :smile:

uglyog
2021-07-03 01:59
No, it should be validated to always have a `null` value

tjones
2021-07-03 13:03
You should only do this if the client *requires* null for that field (as in, that?s part of the meaning that your test depends on)

tjones
2021-07-03 13:22
Pact is a consumer-driven contract testing framework by philosophy. My personal view is that this makes the most sense- we only have providers *because* of the consumers. You don?t need to provide anything that isn?t consumed. However, although consumer-driven is generally the best approach, it?s not always the best approach (eg, if you don?t know who your consumers are). Recently there have been some efforts to look at provider-driven contracts (notably the efforts using swagger to assist in a provider-driven contract driven by the pactflow people).

sams.prashanth
2021-07-04 06:58
the providerverificationresult (report) as xml/txt file that I uploaded in the pactflow is not in a viewable state. ```REPORT=$(cat ./target/surefire-reports/OpenApiSpecValidationTestReport.xml | base64)```

sams.prashanth
2021-07-04 08:59
tried changing all types of content-type `"contentType": "text/plain",` `"contentType": "text/xml",` `"contentType": "application/xml",`

matt.fellows
2021-07-04 09:02
Where are you expecting to see it Prashanth? Just a reminder we don't have any UI for this just yet, it's only shown via the HAL browser (which is just the API view)

matt.fellows
2021-07-04 09:03
In the future, we expect to display the report in the UI along with the verification details

sams.prashanth
2021-07-04 09:06
I thought we can see the providerverificationresult (report) in the HAL browser

sams.prashanth
2021-07-04 09:07
maybe it's showing only the encoded value

matt.fellows
2021-07-04 09:16
Yeah that's right, it's just showing what is stored essentially in the database

matt.fellows
2021-07-04 09:16
(sorry it's a Sunday here, on my mobile)

sams.prashanth
2021-07-04 09:17
No worries; thank you for responding though :slightly_smiling_face:

matt.fellows
2021-07-04 09:19
You're welcome. Hopefully a better developer experience is not too far away, but the API experience should very much be functional

siddharth.gupta
2021-07-05 04:51
Hey folks ,we are planning to start with Pact Broker to see if we become mature enough to use the SAS version PactFlow ,

siddharth.gupta
2021-07-05 04:52
with Pact Broker should we go with kubernetes or Docker Swarm is good enough

bethskurrie
2021-07-05 04:53
Hi @siddharth.gupta. Try the #pact-broker channel.

bethskurrie
2021-07-05 04:53
(it'll still be me answering, it's just that we like to keep channels focussed one one topic)

siddharth.gupta
2021-07-05 04:53
sure thanks

abubics
2021-07-05 07:48
Should be possible, that's how the contracts are generated (each interaction has to have a unique composite key, not sure which fields make it up, though)

vinnys.lins
2021-07-05 13:49
has joined #general

talank
2021-07-06 03:52
has joined #general

juri.petersen
2021-07-06 07:29
has joined #general

leolvicario
2021-07-06 07:36
has joined #general

swoichhaa
2021-07-06 08:46
has joined #general

ivo.velthoven174
2021-07-06 09:28
has joined #general

fjtdg
2021-07-06 12:16
has joined #general

dmitry.korolev
2021-07-06 15:11
Hey guys, Is it possible to create custom matchers for pact? For example, I would like to specify in my contract that a value should be according to RFC4648.

steve.etherington
2021-07-06 16:44
has joined #general

abubics
2021-07-07 01:01
Should be possible (polymorphism), how you do it will depend on which language you're using. There are new matchers added as versions progress (such as ISO8601 dates), you should be able to follow a similar pattern :party_parrot:

matt.fellows
2021-07-07 01:20
We don?t currently have an extension mechanism that easily works across languages (that?s what our https://github.com/pact-foundation/pact-specification/issues/83 aims to solve).

matt.fellows
2021-07-07 01:20
I think it?s just a base64 matcher you need if I read the other thread correctly?

dmitry.korolev
2021-07-07 05:57
What other thread? :slightly_smiling_face:

dmitry.korolev
2021-07-07 05:58
I was thinking that it would be nice to include in the contract and therefore validate that the format of data complies with RFC4648. I don't think it is possible with regex, at least not fully - you really need to try to decode the value.

matt.fellows
2021-07-07 06:01
It just so happened that somebody else asked this exact question yesterday: https://pact-foundation.slack.com/archives/C9UN99H24/p1625578288331600

dmitry.korolev
2021-07-07 06:01
By the way, any envisioned timeline on the plugin feature? Looking forward to it for native protobuf support :wink:

matt.fellows
2021-07-07 06:01
So when I woke up and saw both, I assumed maybe you were working together

matt.fellows
2021-07-07 06:01
> By the way, any envisioned timeline on the plugin feature? Looking forward to it for native protobuf support Sorry, no timeline yet - but soon :tm:

dmitry.korolev
2021-07-07 06:02
Ah indeed, we are. I was not aware he also contacted you - did not check the other channel. Sorry for the spam!

rosh.mjohn
2021-07-07 07:19
has joined #general

matt.fellows
2021-07-07 07:49
No problem at all!

zhaoyi0113
2021-07-07 10:27
Hi Guys, I see pact supports both `version` and `tag`. what is the different between them? If I put `publishing pact` as part of CI pipeline, should I put `commit id` as version or tag?

dimundo
2021-07-07 10:37
as version

dimundo
2021-07-07 10:38
``` script: - "pact-broker publish ./pacts --broker-base-url $PACT_BROKER_BASE_URL --broker-token $PACT_BROKER_TOKEN --consumer-app-version $VERSION --tag $CI_COMMIT_BRANCH"```

dimundo
2021-07-07 10:39
we ( so far ) doing this ( and branch name as a tag for feature tests )

mahajanalokkumar
2021-07-07 10:41
has joined #general

mahajanalokkumar
2021-07-07 10:45
Hello, Quite new to PACT and contract tests. We have recently started making sure we have contract tests. And one question which popping out in discussion is how we should define the KPI's for it. Does this question makes sense if yes can anyone please let me know what KPI's should be considered for contract tests (PACT). Thanks!

tjones
2021-07-07 10:47
Interesting question. What KPIs do you have for your other tests (eg unit tests)

tjones
2021-07-07 10:47
Pact can be thought of as a cross-service unit test (the unit is the client+server API combination)

matt.fellows
2021-07-07 11:04
What is version in this case Dmitry?

dimundo
2021-07-07 11:05
> VERSION: ?export VERSION=$(date +?%Y%m%d.%H%M%S?).$CI_COMMIT_SHORT_SHA?

dimundo
2021-07-07 11:05
something like `20210707.101858.406f4b1e`


dimundo
2021-07-07 11:06
`0.0.1.` is quite hard to create comparing to date

matt.fellows
2021-07-07 11:07
Having the commit SHA in there is definitely recommended

zhaoyi0113
2021-07-07 11:11
Does `pact` only publish version if the pacts are changed? If I use commit sha as version in the CI, will there be hundreds of commits every month. Will it cause issue on pact broker?

zhaoyi0113
2021-07-07 11:15
Oh, I think this answers my question ```It also has the smaller advantage that it is always safe to republish the same pact contract for the same consumer application version - it will simply be a no-op. You'll see a 200 OK instead of a 201 Created in this situation.```

matt.fellows
2021-07-07 12:00
just publish every time, that?s the standard advice

matt.fellows
2021-07-07 12:00
if the contract doesn?t change, the broker works it all out

zhaoyi0113
2021-07-07 12:07
I just tried and found out that pact broker still adds the version even the pact is no change.

zhaoyi0113
2021-07-07 12:08
the `1.0.0-00001` and `1.0.0-00002` publishes the same pact files but why does the broker shows `1.0.0-00002`?

matt.fellows
2021-07-07 12:08
The version always gets recorded, we need that information - otherwise how would `can-i-deploy` work?

matt.fellows
2021-07-07 12:09
don?t worry about the fact that it?s creating more rows in a database.

matt.fellows
2021-07-07 12:09
Note that the *version of that consumer* is already verified though, because its *underlying contract* has already been verified

zhaoyi0113
2021-07-07 12:12
when the provider verify the pacts, does it verify all the history versions of consumer?

zhaoyi0113
2021-07-07 12:13
In below example, why is the provider `v2.0.1-cb0d80a` verifying the consumer?s old pact?

dimundo
2021-07-07 12:23
0.2.0 wasnt released at that time ( as a guess )

matt.fellows
2021-07-07 12:35
This is a conceptual model

matt.fellows
2021-07-07 12:36
but a practical example, is that v0.1.x of the consumer is currently in `prod` so must be verified by all of its providers, and v0.2.0 is the latest `master` which the provider wants to also test

matt.fellows
2021-07-07 12:37
A good starting strategy, is to always verify the consumers currently in `prod` and the versions of the consumer about to be released (e.g. `main` or `master` or whatever name you have for that)

wesleythomaswilliams
2021-07-07 15:45
Our webhooks are static and created in the Pact Flow UI. We have one per provider build that we need to trigger for Pact verification. We might be doing that entirely wrong, but that's our setup at the moment. The UI is simple to use for creation and unless there's a need to be creating them regularly that I've missed (which Matt's reply suggests I might have), I don't see the benefit of creating them via a CLI.

jyiyng2002
2021-07-07 19:57
has joined #general

splurgeop
2021-07-07 21:48
has joined #general

kapoor.manil
2021-07-07 22:30
has joined #general

matt.fellows
2021-07-07 23:08
that?s totally fine Wes!

pashas.2k3
2021-07-08 03:41
has joined #general

vijayanaggella
2021-07-08 05:25
has joined #general

ananthshenoy03
2021-07-08 05:46
has joined #general

sai5i.islam
2021-07-08 06:40
has joined #general

poorvasgokhale
2021-07-08 09:08
has joined #general

dimundo
2021-07-08 10:10
hi! one more funny question :slightly_smiling_face: there is message pact between `A` and `B` if i will create http pact between `A` and `B` - it will overwrite message one @ broker any options apart from renaming to something like `AMessage` > `BMessage` + `AHTTP`> `BHTTP`

tien.xuan.vo
2021-07-08 10:16
In specification v4 we can merge them in 1 files and publish that file I think. But in v3 we need to put them in separate files and rename them. Not so sure

matt.fellows
2021-07-08 10:36
I don't know of another workaround at the moment I'm sorry. The provider needs a different name

dimundo
2021-07-08 10:37
extra property as a pact type ( as an idea )

dimundo
2021-07-08 10:37
merging them sounds scary to me

dimundo
2021-07-08 10:37
as merging 2 http pacts are okish maybe, but http+messages+whatever comes next - dunno

suresh.thammishetti
2021-07-08 11:08
has joined #general

todd.lemmonds
2021-07-08 19:54
Hello all, Wondering if anyone has used Pactflow/Contract Testing in a Salesforce Development project. Since we don't own Salesforce as the Provider, but do control all of the consumers, would it make sense to use contract testing? Anyone have experience with this?

matt.fellows
2021-07-09 00:18
I suppose the general question is ?can you do contract testing for providers you don?t own??

tjones
2021-07-09 02:51
I usually do. It depends on what your contract is like. If you have a lot of server state, it's hard to verify on a real provider. If you don't, you can verify against the live provider (depending how often you do it)

tjones
2021-07-09 02:51
in the worst case, you're back testing with mocks that you're not sharing

tjones
2021-07-09 02:51
I still like pact in that scenario, because the contract CAN be shared. Even if you're not sharing it right now.

tjones
2021-07-09 02:52
If there's a spec from the provider, you can validate your contract against the spec, but it's not as good as real provider validation (because you don't know what the provider actually does, just that your request/response pairs are at least spec-compliant)

zhaoyi0113
2021-07-09 09:06
Hello, I am checking how to pass access token when publishing pacts but this doc https://docs.pact.io/provider/handling_auth doesn?t provider much examples. Provider needs to check whether a token in the request?s header is valid before processing the request. This token is short live which means it needs to be generated at run time. so it is not possible to put the token as part of `pact`. Is there an example to see how to pass a runtime token in a middleware when provider verifies the pacts?

bethskurrie
2021-07-09 09:06
@zhaoyi0113 you'll need to ask in the channel for the language you're using.

bethskurrie
2021-07-09 09:06
How to do that is very implementation specific.

zhaoyi0113
2021-07-09 09:07
I am using typescript.

bethskurrie
2021-07-09 09:07
Ask in #pact-js

zhaoyi0113
2021-07-09 09:08
Sure thanks.

michael.katende
2021-07-09 10:41
has joined #general

marcin.baranowski953
2021-07-09 10:42
has joined #general

abdul.hussain
2021-07-09 10:45
@michael.katende

matt.fellows
2021-07-09 11:30
*Hey ! How can we improve Pact? Tell us what you _really_ think and get a free upgrade* :free: For those that don? know, I?m one of the Pact maintainers and also one of the co-founders of https://pactflow.io. The last 12 months has seen a lot of change in both Pact and our commercial offering, and we want to make sure those changes are moving the community forward. I?m hoping you can spare a few minutes of your time to tell the team and I how we can improve Pact. Whether you are new to Pact or could qualify as an instructor, use the self-hosted Pact Broker or Pactflow. I just ask one thing....please, be ruthless :smiling_imp: Simply complete the 6 minutes survey and as a thank you, I?d like to offer anyone who is keen to give Pactflow a try, a free upgrade (this applies even if you filled out last years? survey and got the same bonus). :point_right:  *https://www.google.com/url?q=https://dius.typeform.com/to/XSlrZYAB&sa=D&source=editors&ust=1625818568343000&usg=AOvVaw1ZuvvFLZMKA4JnGIWp6DiW* I know your time is valuable and we really appreciate you taking the time to share your honest feedback, so that Pact remains the de-facto contract testing tool :pray: _(P.S. lastly, this is a Pactflow specific initiative, but aggregated anonymised information will be shared back with the maintainers to help improve our community)_

matt.fellows
2021-07-09 11:52
Posting this issue here: https://github.com/pact-foundation/pact-broker-docker/issues/54 Are there any people who love DevSecOps and are interested in getting Pact into the Department of Defence approved docker registry?

greg595au
2021-07-09 12:01
Hey. This is a really good suggestion. If that happens other countries DoD may be atttacted to adopt from there

matt.fellows
2021-07-09 12:44
It looks fairly involved at first glance, but pretty cool to know DoD _want_ to use Pact

dimundo
2021-07-09 16:49
Hi! Pending pacts question :upside_down_face: if one is running tests, which creates bunch of contracts most are not touched, but 1 contract has new feature if that bunch is published with pending=true, which contracts will be pending ? :one: all of them will be pending and need revalidation from producer :two: only changed one will be pending, untouched will remain in previous state :three: some other option

phil.endsley
2021-07-09 16:54
The pending flag is calculated dynamically per pact when the provider fetches them

phil.endsley
2021-07-09 16:55
If the others were previously verified, and didn't change, they will be marked as pre-verified by the broker

dimundo
2021-07-09 16:58
awesome :raised_hands:

dimundo
2021-07-09 17:41
some-why on mobile survey goes 1>2>3>4>5>6>5>6 and cant be finished :disappointed: got survey link from email

dimundo
2021-07-09 18:05
is there possibility to omit `--pacticipant` ? to ask broker such question `pact-broker can-i-deploy --version 20210709.152804.0ed12c12 --broker-base-url....` use-case - to not forget any new pacticipant

dimundo
2021-07-09 18:06
because all pacticipants are in one repo, but in different packages

dimundo
2021-07-09 19:03
and one more pending question is there a possibility to set pending via `pact-broker publish ./pacts?` ? tried to find it some-how, but failed

phil.endsley
2021-07-09 19:10
No, you can't explicitly specify the pending state. Its always a calculated value

dimundo
2021-07-09 19:17
ah, so as it is configured from provider, pact will be shown as pending only on next (breaking) contract update and provider will not be able to satisfy it?

phil.endsley
2021-07-09 19:54
A pact is pending if that version has never been successfully verified for a given provider's tag. It's dynamic, because a Pact could be pending for one tag, but not for another. For example: 1. Consumer changes its pact and publishes a new version 2. The provider has never verified it before. Provider build runs on `main` branch/tag. Verification fails, because the functionality has not been implemented yet. Since that version of the Pact has never been verified against the `main` tag before, it's still pending, and doesn't fail the build 3. Provider creates a new branch and implements the functionality. `feat-x` verifies successfully and publishes the result. The Pact is no longer pending for `feat-x` tag, because it has been verified before. This means a failure now would be a regression, and it would fail the build. 4. `main` is still pending, because `main` has not verified that Pact version yet. So at this point in time, this version of the Pact is pending when verified against `main`, but not pending when verified against `feat-x` 5. Once `feat-x` branch is merged, verification will run, publish result, and no longer be pending

phil.endsley
2021-07-09 19:56
If, however, the consumer publishes a Pact with a new version, but no changed functionality, Broker will know it's the same content, so it will not be pending (assuming it had at least one successful verification previously)

dimundo
2021-07-09 20:00
i understand functionality, but now need to understand, how to turn it on and use :smile: i?ve expected after i?ve added to provider `enablePending = true,` , that something will be changed @ broker somehow but looks like a need to wait ?bad? contract to appear

phil.endsley
2021-07-09 20:03
Ah, yes, once you publish an updated contract, you'll see the new version pulled in when running verification. I'm not familiar with other languages, but I know jvm logs out the message of which pacts are pending, so it's obvious when verification is being ran which are pending and which are not

dimundo
2021-07-09 20:09
ok, so mine assumptions were ok, so i?m just grabbing some :popcorn: and waiting :slightly_smiling_face:

matt.fellows
2021-07-10 00:02
Beth just updated the docs for this yesterday based on workshop feedback


matt.fellows
2021-07-10 00:03
We also did an AMA on it

tjones
2021-07-10 02:07
Yes, I believe you can do this. You have to include at least one pacticipant (otherwise who does the version belong to?), but I believe it should work

matt.fellows
2021-07-10 05:32
Of course! What Tim said, That's the default behaviour and the standard use case

dimundo
2021-07-10 07:09
i hoped, broker is very clever :) but if i include 1 pacticipant, c-i-d checks only its contracts

dimundo
2021-07-10 07:10
idea was - ask only version and broker checks all pacticipants with that version

dimundo
2021-07-10 07:11
one must have very unique versioning, yes

dimundo
2021-07-10 07:12
but in my case i must to include all pacticipants from repo, hoping new one will be added to c-i-d :(

dimundo
2021-07-10 07:13
need to watch them all :+1:

tjones
2021-07-10 09:35
I?m confused. A version belongs to a pacticipant, so how is specifying the pacticipant any different to not specifying it?

dimundo
2021-07-10 10:27
thats the case - all of them must be ferified, as all of them has same version

matt.fellows
2021-07-10 12:00
Can you please explain the use case? I'm not following so I suspect it's because I don't understand how you do things.

matt.fellows
2021-07-10 12:01
I think you're saying "I want to deploy all of my consumers and providers (because they're in the same repo)?"

matt.fellows
2021-07-10 12:02
If that's the case, I'm not sure can-i-deploy makes sense because all of the tests would have to pass, at which point this command isn't very helpful

dimundo
2021-07-10 12:05
check highlighted in yellow pacticipants. i want to be sure, that all of them can be deployed, as all of them are in same repo and create 1 artefact to be deployed

dimundo
2021-07-10 12:05
but now i need to explicitly mention all of them

dimundo
2021-07-10 12:24
yes, monorepo sometimes aint that fun

matt.fellows
2021-07-10 22:00
Do you use any monoroepo tools? Can you just iterate through and call can-i-deploy for each?

matt.fellows
2021-07-10 22:01
But again, if the monoroepo is always deployed together I'm not so sure of the value of that call at all

matt.fellows
2021-07-10 22:02
You might have thought more about it - what do you think it gives?

bedfordwest
2021-07-10 22:21
has joined #general

bedfordwest
2021-07-10 22:25
Hi folks! I'm going to be speaking about consumer driven contract testing using Pact at TestingMind's test automation & digital QA virtual summit in August, and am putting together my presentation now. I would love to use some of the animations or diagrams from the http://docs.pact.io site to help explain the concepts, but unsure if it's ok to do so. Could someone let me know if this is OK or who I should reach out to for permission?

bethskurrie
2021-07-10 22:30
Hi @bedfordwest I think that's fine. Maybe just put a little "image from http://docs.pact.io" at the bottom of the slide?

bethskurrie
2021-07-10 22:31
Good luck with your talk, btw. That's awesome news!

bethskurrie
2021-07-10 22:31
Let us know if you need any support.

bedfordwest
2021-07-10 22:31
Thank you so much! I can do that, definitely! :slightly_smiling_face: I'll be sure to reach out if anything comes up!

bethskurrie
2021-07-10 22:37
Research question for a Pact Broker feature. Does anyone *not* use git? What do you use as an alternative, and what is the equivalent of a "git commit" (sha) in that tool? I'm thinking of adding a new field to the pacticipant version resource for people who want to trigger builds/do commit statuses, but don't use the sha as the version number when publishing pacts/verifications. I need a generic, non-repository specific, but well recognised term. I'm thinking just "commit" might do it, but I don't know what other systems are out there.

matt.fellows
2021-07-10 23:36
We have heaps of stuff from all of our collective ramblings/talks etc so do reach out if you need anything

matt.fellows
2021-07-10 23:37
Is there a link to your talk page? We can help promote it Cc @aforeman

thanuxxxx
2021-07-11 02:37
So how about this approach to create a webhook via CLI ```create-update-pacticipant myprovider create-update-pacticipant myconsumer create-update webhook required arguments --consumer myconsumer --provider myprovider publish contract_to_broker``` @matt.fellows @bethskurrie

matt.fellows
2021-07-11 03:31
I mean, that could definitely work, but in reality its not necessarily to call it every time unless you expect it to drift (i.e. someone to delete it from the UI)

bethskurrie
2021-07-11 03:32
the webhook usually belongs to the provider codebase.

bethskurrie
2021-07-11 03:32
if it's the webhook that triggers the provider build.

matt.fellows
2021-07-11 03:32
But it feels wrong for the pipeline responsible for publishing pact also has that logic in it. In most cases the webhook probably doesn't need to have the consumer in it (i.e. the webhook should belong to the provider)

matt.fellows
2021-07-11 03:33
What Beth said

bethskurrie
2021-07-11 03:33
it would be more like: (consumer pipeline) publish pacts (provider pipeline) create pacticipant create webhook tests verify pacts


thanuxxxx
2021-07-11 03:34
Okay then there is only one pacticipant (provider)

thanuxxxx
2021-07-11 03:35
Okay make sense

thanuxxxx
2021-07-11 03:51
So what is the recommended approach creating a webhook via CLI or HAL Browser?

thanuxxxx
2021-07-11 03:51
or best practice?

abubics
2021-07-11 07:57
I've seen legacy svn and tfs at some places recently, but they're really trying to move off them (if slowly)

abubics
2021-07-11 07:58
No idea how much people use Mercurial anymore . . . I've never seen it in action.

matt.fellows
2021-07-11 11:44
If it were me, if I weren?t using the terraform provider, I?d probably have a script that is checked in and run through CI


matt.fellows
2021-07-11 13:21
I know of a place that still uses CVS

matt.fellows
2021-07-11 13:30
Subversion calls them revisions (just an incremental number)

firstamit
2021-07-11 14:07
has joined #general

bedfordwest
2021-07-11 17:58
Here's a link to the LinkedIn post: https://www.linkedin.com/posts/testingmind-consulting-pvt%2E-ltd%2E_testautomation-qa-summit-activity-6809128771568889856-1UcP That would be great! I'll send a DM to you both with a copy of my first draft of the presentation in case you have any concerns with how I'm using the material or suggestions!

bethskurrie
2021-07-11 21:31
The webhook "create or update" cli command with a known uuid was designed for use in a pipeline, if you don't want to use terraform.

omar554
2021-07-11 21:54
has joined #general

tjones
2021-07-11 23:41
I think each pacticipant ideally is a single deployable. If you have multiple pacticipants that are deployed together, I think they might be better represented as one pacticipant

matt.fellows
2021-07-12 00:54
Sorry, yes, specifically, that script I referred to would call that CLI command

matt.fellows
2021-07-12 00:54
I would follow the usual Infra as Code (IaC) practices here, meaning it should at least be checked into code and ideally run on each run of CI

thanuxxxx
2021-07-12 00:55
Yeah but is it really necessary to create pacticipants and webhook every single CI?

matt.fellows
2021-07-12 00:57
This is more of a DevOps practice question, and not a Pact one

matt.fellows
2021-07-12 00:57
If somebody deletes the webhook via the UI or API, now you don?t have the webhook and have lost visibility

matt.fellows
2021-07-12 00:57
IaC practices ensure that any drift (drift is where the desired state of the system does not match reality) is brought back into line

matt.fellows
2021-07-12 00:58
So with that said, you can use your judgement as to whether it?s necessary - it?s absolutely fine if you don?t run it every time, just know the trade offs

aforeman
2021-07-12 03:19
Hey @dmitry.korolev thanks for the feedback. All the questions are required to be completed before you submit. If you use the skip question (arrow button bottom of the screen) to move through the survey and don't submit an answer for each question, when hitting submit, you'll be pulled back to the questions you didn't answer. Hope this helps :slightly_smiling_face:

aforeman
2021-07-12 03:27
Nice one, @bedfordwest! We'd love to promote this in our next newsletter and on our social media.

dimundo
2021-07-12 05:40
yes, this could be another solution, but you will not understand which part if client is stopping you from deploy

angelo
2021-07-12 06:12
i was scouring through the docs and i'm confused if i turn on pending and wip pacts on feature branches or just turn it on in the main/master branch or both?

erik.terpstra
2021-07-12 06:29
I had the same problem, couldn?t figure out why, so I didn?t finish it.

dimundo
2021-07-12 06:46
everything was answered



bethskurrie
2021-07-12 07:08
I'd try leaving both wip and pending on for all branches to start with, and see how you go.

angelo
2021-07-12 07:23
thanks! i was looking for this

dimundo
2021-07-12 09:50
should one create some hook, notifying, that provider hit ?pending? state ? like if pending changes arent verified by provider, noone notices that, because all pipelines are green. obviously

dimundo
2021-07-12 09:52
or/and could it have pending badge ?

dimundo
2021-07-12 09:53
for now its unknown for fresh pact not verified completely by provider

k.deepupardha
2021-07-12 10:23
has joined #general

lumenofor
2021-07-12 10:46
has joined #general

jayr.motta
2021-07-12 13:57
has joined #general

kyle.florence
2021-07-12 16:40
The consumer build using that pact should fail (against master)

kyle.florence
2021-07-12 16:41
That is how our pipeline is set up

kyle.florence
2021-07-12 16:41
Can't merge consumer until provider verifies and merges first

kyle.florence
2021-07-12 16:41
Can't deploy consumer until verified provider version deploys

dimundo
2021-07-12 16:46
looks like my next task - smoking out can-i-deploy :+1:

david.vancouvering
2021-07-12 18:16
I'm detecting a number of situations where we want to use Pact, except the contract is not standard REST or messages. Examples: ? GRPC ? Server-Sent Events ? Contracts between a consumer and a library In all of these cases there is a ton of value in verifying compatibility before the producer or consumer deploys. Have y'all had any thoughts for allowing someone to provide "plugins" to the overall Pact infrastructure for non-standard protocols/integrations? For example, for SSE, I've built a one-off solution that maps between an SSE response and JSON response so that the pact mock server thinks it's dealing with JSON. I saw somebody did something similar for GRPC. Maybe there is an extensible way to do this?

doug.shattuck
2021-07-12 20:26
has joined #general


matt.fellows
2021-07-12 22:30
> In all of these cases there is a ton of value in verifying compatibility before the producer or consumer deploys. Agree!

david.vancouvering
2021-07-12 22:31
ooh tasty! Let me take a look, thanks

david.vancouvering
2021-07-12 22:31
Is this available now or currently in proposal phase?

david.vancouvering
2021-07-12 22:34
Just saw this response, thanks for the guidance!

matt.fellows
2021-07-12 22:45
just a proposal at this stage.

matt.fellows
2021-07-12 22:46
the current focus is getting Rust (the core engine) into all of the things (happily, good progress happening here). Once that?s in place, and the infrastructure is made available in Rust, it should be a smaller piece of work to add to each language

david.vancouvering
2021-07-12 22:47
OK great. Good to know it's on the roadmap, it definitely would be useful. good luck with the Rustification. Rustifarian Nation.

thanuxxxx
2021-07-13 00:06
So, let's say I merge the code to master and I have dev1, dev2 and prod, when I verify pacts in provider side, do I have to git checkout before I verify?

bethskurrie
2021-07-13 00:07
See if this answers your question @thanuxxxx https://docs.pact.io/pact_nirvana/step_8


thanuxxxx
2021-07-13 01:03
@bethskurrie this is not related to previous question, but let's say consumer and provider decide to remove a field, it is not possible that provider makes that change first ( I mean provider merge that change to master) because provider's feature/branch build will fail because of mismatch pact isn't it? However, if consumer and provider decide to add a field, then provider make the change and merge with master because existing pact tests will pass Is that true? thanks

thanuxxxx
2021-07-13 01:04
Assume in both cases consumer didn't do anything yet

tjones
2021-07-13 01:16
You're welcome! Let us know if there's anything we can make clearer

abubics
2021-07-13 01:49
The expand-and-contract approach means: ? adding a field happens in the provider, then the consumer, and ? removing a field happens in the consumer, then the provider. If you draw the consumer and provider as a dependency graph, it becomes intuitive to follow :slightly_smiling_face:

thanuxxxx
2021-07-13 01:50
Excellent ty

aforeman
2021-07-13 05:34
Thanks @erik.terpstra @dimundo we're looking into it at the moment. I'll let you know when it's sorted.

sorin_balbae
2021-07-13 07:41
has joined #general

akara
2021-07-13 10:34
has joined #general

dawoud.sheraz
2021-07-13 11:44
Hello. A few questions: 1. Relating the question to my post https://pact-foundation.slack.com/archives/C5F4KFKR8/p1624558283271700, how does using unit testing framework remove the need for exposing state setter api-endpoint? Aren?t the interactions supposed to be independent, requiring DB to be in clean and state-relevant state? 2. When adding CI flow in consumer repo, what is the ideal way to add provider verification check job on consumer? As part of unit test job? Or running a different job on PR/branch once the unit tests job has run? 3. What?s the deciding factor if the provider verification checks on consumer should be optional? Is it can-i-deploy i.e. only run the job if output of can-i-deploy is negative?

nathan.derave
2021-07-13 12:28
has joined #general

thanuxxxx
2021-07-13 14:38
What would happen if `create-version-tag` fails for some reason? Does CI/CD pipe-line fail because of this?

dimundo
2021-07-13 15:29
hi! any hints, what could went wrong? `No pacts or verifications have been published for version 25718645e of SomeClient`

dimundo
2021-07-13 15:32
looks like i need publish and then can-i-deploy :facepalm:

akara
2021-07-13 15:44
Hi guys, we are using the pending pacts so that we can publish new consumer pacts without breaking the provider builds. It works fine, we just want to be notified when a new pending pact is added for visibility so that someone doesn't accidentally publish a pending pact which the provider doesn't have any plan to implement. Ideally posting to Slack channel would be great. Is that possible?

poorvasgokhale
2021-07-13 18:26
Hello all, We are trying out contract testing for microservices architecture. We have 4 environments for both provider and conumer. dev, test, uat and prod.. I have following questions from CI and CD perspective. 1. Which environment pipelines should be targeted for running contract test? should they run on all 4 environments? 2. In case of continuous development of consumer (dev environment), which environment of producer should be used for pact verification? 3. In case of continuous development of provider (dev environment), which environment consumer pact should provider use for verification? I could not find any document which talks about this. Can someone help here?

matthew.schaad
2021-07-13 21:29
has joined #general

matthew.schaad
2021-07-13 21:33
Hello Pact friends! I have an idea for a novel (I think) integration with OAS and Pact. I wanted to ask for feedback here, just to rule out that I'm missing something. (Don't worry, I'm not generating my pacts directly from the provider's OAS spec.) Is this the right room for the question?

neenad.jadhavgre
2021-07-13 22:30
has joined #general

matt.fellows
2021-07-14 02:19
Pact tests should, as a general rule, _not_ be run against a real environment. They should run as unit tests with your code

matt.fellows
2021-07-14 02:19
you then use `can-i-deploy` to check whether it?s safe to release a component _into_ one of those environments

matt.fellows
2021-07-14 02:20
If you frame the question as ?should I run my unit tests against dev, test, uat and prod? you?ll see the question doesn?t make sense.

matt.fellows
2021-07-14 02:20
see also https://docs.pact.io/pact_nirvana/ and https://docs.pactflow.io/docs/workshops/ci-cd/ for how to integrate into your pipelines

cristian
2021-07-14 06:18
has joined #general

vuttithatkrongyot
2021-07-14 06:21
Hi all, I'm trying to perform the contract-driven(APIspec-driven) contract testing because I don't want to have bottleneck development on either consumer or provider. Do we have a proper way to do this? I'm using provider verifier for provider side but I have no idea for consumer side. Thanks

matt.fellows
2021-07-14 06:33
Is the implication that you're not a developer? Are you doing consumer driven with Pact or are you using the bidirectional with Pactflow? https://docs.pactflow.io/docs/workshops/bi-directional

matt.fellows
2021-07-14 06:34
(you mentioned API spec)

angelo
2021-07-14 06:37
I have a clarification: according to step 8 in the CI/CD step guide, I have to checkout the prod version. Is this only during the pact consumer contract change (ex. triggering the webhook)? or do I have to do it also in the provider change pipeline (ex. feat branches and main)?

bethskurrie
2021-07-14 06:37
Good question @angelo

bethskurrie
2021-07-14 06:38
it depends how much effort you want to go to!

bethskurrie
2021-07-14 06:39
The answer is, you don't *have* to do this step, but it will allow your consumer to deploy more often if you do.

bethskurrie
2021-07-14 06:40
You only need to do it when the pact changes, not when the provider changes.

bethskurrie
2021-07-14 06:40
I've been working on the design for a feature to make this step easier https://github.com/pact-foundation/pact_broker/discussions/434


angelo
2021-07-14 06:42
^yes I also read this. The examples of the workflow in this were helpful (may be add this to the docs?). Thanks for the clarification!

vuttithatkrongyot
2021-07-14 06:42
Yeah, that's what i'm talking about. So as of now we still not fully support bi-directional in the free version right?

bethskurrie
2021-07-14 06:43
> When adding CI flow in consumer repo, what is the ideal way to add provider verification check job on consumer? As part of unit test job? Or running a different job on PR/branch once the unit tests job has run?

bethskurrie
2021-07-14 06:45
@dawoud.sheraz you can see (a) way of doing it here


bethskurrie
2021-07-14 06:45
I'd recommend doing the CI/CD workshop https://docs.pactflow.io/docs/workshops/ci-cd

bethskurrie
2021-07-14 06:47
> how does using unit testing framework remove the need for exposing state setter api-endpoint When you are using a language agnostic verifier, the only way to provide a generic interface to set up and clear the states is over HTTP, which is why you need the state API endpoint.

bethskurrie
2021-07-14 06:48
When you use a native language verifier, then you don't need to use an HTTP call to clear/set up the state. You can use plain code.

bethskurrie
2021-07-14 06:49
> What?s the deciding factor if the provider verification checks on consumer should be optional? I don't understand this question. Can you rephrase it please?

bethskurrie
2021-07-14 06:50
Are you talking about using can-i-deploy in the webhookless workflow described here? https://docs.pact.io/pact_nirvana/step_4#alternative-webhookless-workflow

dawoud.sheraz
2021-07-14 06:51
> What?s the deciding factor if the provider verification checks on consumer should be optional? > I don?t understand this question. Can you rephrase it please? If the consumer change does not result in contract change, there is no need to trigger provider verification, right? It can be skipped.

bethskurrie
2021-07-14 06:51
the broker does that for you.

bethskurrie
2021-07-14 06:51
You configure a webhook to trigger the verification step.


dawoud.sheraz
2021-07-14 06:52
> When you use a native language verifier, then you don?t need to use an HTTP call to clear/set up the state. You can use plain code. But don?t we want the interactions to be independent? In pact-python, the verifier takes the pact path/pact broker link and returns the verification results. How can we ensure that without api endpoint, the interactions should be independent.

dawoud.sheraz
2021-07-14 06:53
> Have you read this page? https://docs.pact.io/pact_nirvana/step_4 Reading it now.

bethskurrie
2021-07-14 06:53
I think I missed some context from a previous discussion, because that question doesn't make sense to me, sorry.

dimundo
2021-07-14 06:54
Hi One more funny question. ? provider creates test, for message/api , which is not yet in contract from consumer ? publish, merge from branch to trunk, deploy and forget will be pact be green, when consumer after some time will add contract for that part ?

bethskurrie
2021-07-14 06:57
You mean, if you define a provider state, before the consumer starts to use it, so that when the pact is verified the first time, the state is already there?


dimundo
2021-07-14 06:58
provider just created as agreed 100500 endpoints

bethskurrie
2021-07-14 06:58
It's a good idea, yes. If it works as epxected.

dimundo
2021-07-14 06:58
does it work - thats the question :smile:

bethskurrie
2021-07-14 06:59
100500 endpoints/!?!?

dimundo
2021-07-14 06:59
just a random number :slightly_smiling_face: all of them will be used

matt.fellows
2021-07-14 06:59
The bidirectional contracts feature is not supported in the open source version of pact but you can certainly combine other tools to do it

bethskurrie
2021-07-14 07:00
If a single provider has 100500 endpoints, I don't think even pact can help you :stuck_out_tongue:

dimundo
2021-07-14 07:00
proper way - consumer and producer create something in branch

dawoud.sheraz
2021-07-14 07:00
Right, hoping to add some context, when writing consumer tests, we keep each interaction independent with provider state. When doing provider verification, we use provider states(via --provider-states-setup-url) to bring the DB into the right state for a particular interaction. Now, when I was writing code for verification in pact-python, the verifier would take information of provider url, pacts, setup url and return the logs if any interaction failed. I was using provider setup url to setup DB for every state. I was not using unit testing framework at that time. Now, on to my question: ? When running verification, we don?t loop over interactions because verifier is doing that(if that is not the case, I was short on context). How will DB setup per state be achieved without provider setup url? let me know if there are still any confusions and I will be happy to clear them up.

dimundo
2021-07-14 07:00
but sometimes someone could be out of capacity

matt.fellows
2021-07-14 07:00
It is available on the free plan though if that's what you are asking

bethskurrie
2021-07-14 07:00
as long as the consumer's expectations match the provider state you already created, then, yes, it will work.

dimundo
2021-07-14 07:01
but broker ?remembers? new ones from provider if they are not in pact ?

bethskurrie
2021-07-14 07:01
it will mean the consumer can deploy faster, because they don't have to wait for the state to be added.

bethskurrie
2021-07-14 07:01
oooh, no.

bethskurrie
2021-07-14 07:02
no, it will still have to be verified.

dimundo
2021-07-14 07:02
i thought only tests from pact are verified

dimundo
2021-07-14 07:02
ahaa, sad


bethskurrie
2021-07-14 07:03
No, actually, you want something different. What you're asking for can't work, I'm afraid.

dimundo
2021-07-14 07:03
but how provider will know branch/tag to check ?

bethskurrie
2021-07-14 07:03
Have you read about WIP pacts?

dimundo
2021-07-14 07:04
yes, ?canny? sounds good, but there are many questions , than answers :disappointed:

bethskurrie
2021-07-14 07:04
yeah, it's nothing that can/will happen soon. it's just an idea.

dimundo
2021-07-14 07:04
wip is again for ?lagging? provider

bethskurrie
2021-07-14 07:05
@angelo when that new webhook comes out, I'll have to update all the docs to explain it better. :thumbsup::skin-tone-3:

bethskurrie
2021-07-14 07:05
hm... no

bethskurrie
2021-07-14 07:05
it's for getting all the consumer's pacts veriied without the provider having to update their configuration each time a consumer makes a new pact.

dimundo
2021-07-14 07:06
i, meant, it will not help in my case, no?

bethskurrie
2021-07-14 07:07
it will, because it means that when the pact is created, it will be automatically verified, and the provider state you added will be used.

bethskurrie
2021-07-14 07:07
the provider team can add the provider state and "deploy and forget"

dimundo
2021-07-14 07:12
`"WIP pacts" is a feature for consumers, to ensure any new contracts are automatically verified by providers without the provider configuration having to be updated.` so, this sounds like exactly my case

dimundo
2021-07-14 07:13
so, broker is storing somehow all things from provider?

bethskurrie
2021-07-14 07:13
only the verification results.

dimundo
2021-07-14 07:13
but how then new stuff will be ok ?

bethskurrie
2021-07-14 07:14
please read that page thoroughly and let me know if you have questions afterwards.

dimundo
2021-07-14 07:14
will describe the case

dimundo
2021-07-14 07:18
1. there is a contract a. message A is `{key:"value"}` b. contract is verified, all good 2. also provider created and deployed test for c. message B is `{otherKey:{somethingElse}` d. this part is not in a contract from consumer 3. after some time consumer e. creates a branch where i. starts to use message B ii. creates and publishes contract for message B iii. asks can-i-deploy to trunk environment will can-i-deploy succeed ?

bethskurrie
2021-07-14 07:19
Have you read the WIP docs page yet?

dimundo
2021-07-14 07:19
im trying :slightly_smiling_face:

bethskurrie
2021-07-14 07:20
let me know when you're finished, and if your question isn't answered by the docs, I'll help.

dawoud.sheraz
2021-07-14 07:26
Ok, the answer is in https://github.com/pactflow/example-provider/blob/master/src/product/product.pact.test.js. We can get the work done via json too.

dawoud.sheraz
2021-07-14 07:27
One suggestion w.r.t docs: Given a bunch of documents and examples of pact and pactflow, the information becomes hard to find sometimes. Now that you have mentioned some links and code references, the answers were easy to locate.

dimundo
2021-07-14 07:30
actually video helped a lot so, did i?ve got that right ? ? provider creates needed tests and some extra ones, which are not in contract yet, enables WIP, commit, deploy, forget ? when after that some feature branch from consumer is created, verification is done also for that consumer feature branch, if its fine - everyone is happy

bethskurrie
2021-07-14 07:54
Yes.

dimundo
2021-07-14 07:56
epic. but WIP enabling makes sense only for provider trunk branch, yes ?


bethskurrie
2021-07-14 08:00
The guide suggests only to do it on trunk.

bethskurrie
2021-07-14 08:00
There's no harm in having it on all branches, but it would make them run longer.

dimundo
2021-07-14 08:01
exactly

dimundo
2021-07-14 08:01
that you for you patience :heart:

bethskurrie
2021-07-14 08:02
Yes, there's actually so much documentation, it's now hard to find the right information. It's something we were just discussing the other day.

dimundo
2021-07-14 08:02
and :taco: for @bethskurrie sure :smile:

dawoud.sheraz
2021-07-14 08:47
Agree. At first, I thought there was not enough documentation. But given the helpful links and information provided by you and others, it seems there is more than enough documentation. But it is hard to find. Is the an existing open-source process to contribute to documents? I am sure there will be other members/users(myself including) who can help in making documents easier to find and locate.

poorvasgokhale
2021-07-14 09:11
Thank you @matt.fellows and @bethskurrie for response. These are good references. :slightly_smiling_face: Let me be more specific about question. I will continue further discussion on #pact-broker channel.

steve.etherington
2021-07-14 09:17
Does anyone have experience of tool to convert API Blueprint files to swagger v2?

steve.etherington
2021-07-14 09:19
I have tried https://www.apimatic.io/ seems to work but is not free https://github.com/LucyBot-Inc/api-spec-converter Generated invalid swagger for me https://github.com/kminami/apib2swagger Generated invalid swagger for me Are there any other free options?

michal.bernhard
2021-07-14 11:16
has joined #general

richard.jones254
2021-07-14 23:53
has joined #general

richard.jones254
2021-07-14 23:58
Hello again, friends :slightly_smiling_face: I'm back on this thing, and need to get caught up on the latest in pact land, having been in not-pact-land for a couple of years but am trying to get my new organisation into this thing.

matt.fellows
2021-07-15 00:12
Welcome back!

edanielsen
2021-07-15 00:46
has joined #general

aforeman
2021-07-15 01:50
Thanks for your patience, give this one a try https://dius.typeform.com/to/l2bKcIY5 :)

abatan.k
2021-07-15 03:48
has joined #general

tjones
2021-07-15 04:11
Anyone have any experience with Katalon Studio for API testing? https://www.katalon.com/

marko.justinek
2021-07-15 04:13
Great, welcome back! We?ll just need to verify the contract first :troll:

mandeep302755
2021-07-15 04:49
has joined #general


bethskurrie
2021-07-15 04:55
Help would be greatly appreciated!

mahajanrupali22
2021-07-15 05:46
has joined #general

angelo
2021-07-15 11:27
i have a question regarding provider production rollbacks. The situation is: 1. latest master -> deployed to prod -> added prod tag 2. problem with prod that has nothing to do with pact, so decided on a rollback which is still compatible with prod providers 3. a few commits before latest master -> deployed to prod -> readded prod tag i can imagine a problem with verification and can-i-deploy for prod. How do you solve this problem since i cant seem to delete the tag via the pact cli?

angelo
2021-07-15 12:43
^no need to reply I found the docs for this

hylke.de.jong
2021-07-15 12:49
has joined #general

efemgy
2021-07-15 14:27
has joined #general

abatan.k
2021-07-15 16:25
Hey guys :slightly_smiling_face: Pact + PactFlow is my favorite tool for ~integration / e2e~ contract testing of my APIs, but do you have any recommandations for testing externe API ? (Those on which we do not have control) I saw that article https://martinfowler.com/bliki/SelfInitializingFake.html , do you have any other insights ? Best regards, and thx for such a great tool :smile:

crazycabo350
2021-07-15 18:04
Anyone know why this particular exception can be thrown while attempting to verify a consumerPact.13:46:56.023 [main] DEBUG http://au.com.dius.pact.consumer.BaseMockServer - Caught exception in mock server kong.unirest.UnirestException: org.apache.http.NoHttpResponseException: localhost:65257 failed to respond

christopher.doherty
2021-07-15 18:05
this happened to me and the solution was to upgrade my kotlin version

crazycabo350
2021-07-15 18:06
I?m not using that, but using Java 11

christopher.doherty
2021-07-15 18:07
yes but I believe pact-jvm is written in kotlin, all I had to do was add `<kotlin.version>1.5.0</kotlin.version>` in my pom's properties

crazycabo350
2021-07-15 18:13
Wow, why does that work? Please tell me there?s a post somewhere mentioning why? I normally use the jUnit Jupiter libraries and have never seen that error, but one of my organizations projects is using a version of Spring in jUnit 4. I use Unirest to verify the mock response. Where?s the dependency on Kotlin v5?

christopher.doherty
2021-07-15 18:21
I don't think there's a post... took me a few days of debugging myself to figure that one out. I don't think that it specifically needs 1.5.0, that just happened to be the latest kotlin version when I ran into it. I believe the default in my effective pom was ~1.2.7

crazycabo350
2021-07-15 21:28
Does anyone have a link to an open source project combining Pact with SpringBoot with quality references to how providers should mock responses?

kamoljan
2021-07-15 22:15
Is it possible or if anyone in practice tested on TLS version contract between consumer and producer?

matt.fellows
2021-07-15 22:36
Not really worth it IMO

matt.fellows
2021-07-15 22:36
The only time it's useful is when there is some auth or something that only works over TLS that you need to test, or the client won't operate otherwise

matt.fellows
2021-07-15 22:37
Most languages have a way if supporting it if you need

matt.fellows
2021-07-15 23:27
We spoke about stubbing external systems in one of our askmeanything sessions


matt.fellows
2021-07-15 23:27
Might be best asking in #pact-jvm also Brian

abatan.k
2021-07-15 23:29
ok, i guess that is a youtube videos ? I will check out, thx @matt.fellows :wink:

kamoljan
2021-07-16 01:03
true

kamoljan
2021-07-16 01:04
@matt.fellows, thank you for your answer!

abubics
2021-07-16 01:07
Good to ask language/platform-specific questions in their own channels (#pact-jvm in this case) :innocent: just because you'll get better answers :stuck_out_tongue:

abubics
2021-07-16 01:08
But mocking doesn't have a single answer

abubics
2021-07-16 01:09
It depends on your app architecture, and where you like to cut layers off.

abubics
2021-07-16 01:10
The three main approaches I hear about are: ? stub data in the layer just beyond presentation (e.g. the next layer in from API endpoints) - this is my preference,; ? stub the database (or whatever external dependency); and ? seed the database (ditto).

crazycabo350
2021-07-16 02:16
So for a Spring app you would prefer to mock the @Service classes?

crazycabo350
2021-07-16 02:18
I feel like mocking the data layer ends up testing integrations between the service layer, which is no place for contracts.

abubics
2021-07-16 02:58
Not too sure about regular Spring, sorry . . . I only use it for the web layer (endpoint binding).

abubics
2021-07-16 02:59
The only consistent guidance I can give is: don't stub in the endpoints, make sure you go through at least a little bit of domain conversion.

abubics
2021-07-16 02:59
(Sorry it's all "it depends" :sweat_smile: . . . happens a lot in here)

amreenshaik.basha
2021-07-16 04:06
has joined #general

tjones
2021-07-16 07:36
Since contract tests are not functional tests, you don't want to aim to cover the functionality in a contract test. However, I think it is good practice to still have functional coverage (incidentally), since testing is about risk reduction. In my view, the best place to cut for provider state mocks during verification is the last layer that speaks business logic words. In spring, I think that is usually the `@Service` (though I'm not super familiar with Spring)

tjones
2021-07-16 07:38
so, in very-pseudo-code, your mock is something like: ```in state "user with ID=1 exists", then userService.getUser(1) will return: new User(/* ... whatever setup goes in here*/)"```

tjones
2021-07-16 07:39
but not: ```in state "user with ID=1 exists", then the SQL query SELECT * FROM USERS WHERE ID = 1will return .....etc```

tjones
2021-07-16 07:40
This approach is another option to the ones that @abubics mentioned: * Stub the last layer before the database

tjones
2021-07-16 07:41
If you stub before the business logic, you're not testing that your service WILL produce that response when that case is hit. Pact isn't for functional testing, but I think having functional coverage is good.

tjones
2021-07-16 07:42
If you stub the database, then you have to write your mocks in a way that requires intimate knowledge of the database

tjones
2021-07-16 07:43
If you use seeded data in the database, you need intimate knowledge of the database AND you have the problems from integration tests

abubics
2021-07-16 08:38
very nice descriptions, thanks @tjones :ok_hand: :taco:

rhian.van.esch
2021-07-16 12:14
has joined #general

wilco.van.esch
2021-07-16 12:30
has joined #general

karl.morrison
2021-07-16 12:56
has joined #general

timothyjabez
2021-07-16 17:23
has joined #general

matt.fellows
2021-07-17 23:04
Anybody want to chime in on their use of pact in mobile use cases ? https://twitter.com/ubiratanfsoares/status/1416479532584947716?s=19

marko.justinek
2021-07-18 01:08
I?d be interested to know what were the ?various reasons? Julio?s team stopped using it. I?d ask myself, but somehow my twitter account got suspended :man-shrugging: https://twitter.com/juliozynger/status/1416549058865467393

matt.fellows
2021-07-18 02:36
It might have been when Soundcloud reduced their engineering team. Just responded (I can see yours came through too!)

marko.justinek
2021-07-18 03:13
Yeah, got unsuspended :grimacing:

ppdnguyen
2021-07-18 16:23
has joined #general

cgoodison
2021-07-18 23:56
has joined #general

mail_4brad
2021-07-19 00:35
Most of the pact examples I've seen are restful, with ids and method variations, and then a nice chunk of json response. By contrast, a big use case of ours is submitting big json documents and just expected a 200/OK response. I've got a working request now (java) and successfully validating it. But man it's an overhead. So the PoC is done and it's not pretty and doesn't look very maintainable. Am I employing an anti-pattern here? This PoC request json is about 50% of the spec it needs to be to be complete (see originalPdf, attachments, address, emails, are all undefined currently, then other object types need to be supported also) ```DslPart body = new PactDslJsonBody() .nullValue("originalPdf") .array("attachments") .closeArray() .minMaxArrayLike("dbObjects", 1, 2) // min 1 max 2 persons; persons and location types .uuid("uuid") .nullValue("dbPersonId") .stringType("birthDate", "1980-05-21") .nullValue("address") .nullValue("addressType") .nullValue("previousName") .object("currentName") .stringType("firstName") .or("middleNames", "Middle Names", PM.stringType(), PM.nullValue()) .stringType("familyName") .closeObject() .object("gender") .integerType("codeTableId", CT_GENDER) .integerType("codeValue", 2) .or("codeDescription", "Descriptor", PM.stringType(), PM.nullValue()) .closeObject() .object("objectType") .integerType("codeTableId", CT_OTC) .integerType("codeValue", OTC_PERSON) .or("codeDescription", "Descriptor", PM.stringType(), PM.nullValue()) .closeObject() .minArrayLike("emails", 0) .closeArray() .minArrayLike("phones", 1) .stringType("number", PHONE_NUMBER) .stringType("areaCode", String.valueOf(PHONE_AREA_CODE)) .booleanType("primary", PHONE_PRIMARY) .object("countryCode") .integerType("codeTableId", CT_PHONE_COUNTRY) .integerType("codeValue", PHONE_COUNTRY_AU) .nullValue("codeDescription") .closeObject() .object("type") .integerType("codeTableId", CT_PHONE_TYPE) .integerType("codeValue", PHONE_TYPE_HOME) .nullValue("codeDescription") .closeObject() .closeArray() .closeArray() .object("report") .uuid("reportUuid") .stringType("description") .nullValue("location") .stringType("reportId") .uuid("externalReferenceUuid") .date("startDate") .date("endDate") .time("startTime", "HH:mm:ss") .time("endTime", "HH:mm:ss") .nullValue("recordedDate") .nullValue("recordedTime") .stringType("recordingUserId", TEST_USER_STRING) .nullValue("priority") .nullValue("proximity") .object("documentType") .integerType("codeTableId", DOCUMENT_TYPE_CODE_TABLE_ID) .integerType("codeValue", DOCUMENT_TYPE_REFERRAL) .or("codeDescription", "Descriptor", PM.stringType(), PM.nullValue()) .closeObject() .closeObject();``` And as I said, the validation side is minimal: ```builder .uponReceiving("a Referral containing a person") .path("/api/report") .method("POST") .headers(requestHeaders) .body(body) .willRespondWith() .status(200) .body("") .toPact();``` See also https://pact-foundation.slack.com/archives/C9UN99H24/p1620614434335300

bethskurrie
2021-07-19 00:36
@mail_4brad the fact that it's JVM is the reason the example is so long.

bethskurrie
2021-07-19 00:36
In other languages, you can just define maps and it infers the types.

bethskurrie
2021-07-19 00:37
I think it's much more concise in groovy for example.

mail_4brad
2021-07-19 00:38
Ok fair point. I've looked at the groovy, but didn't want to add another dependency. Maybe I can give that some more investigation.

mail_4brad
2021-07-19 00:39
Your comment also tells me that this isn't an unreasonable number of fields to be speccing with pact

bethskurrie
2021-07-19 00:39
no, it looks normal to me

bethskurrie
2021-07-19 00:39
it's annoyingly verbose in java :disappointed:

mail_4brad
2021-07-19 00:39
Yah

bethskurrie
2021-07-19 00:40
Because Java.

mail_4brad
2021-07-19 00:42
I'm just aware as well though, that despite implementation, if I change my model I need to update: the model class; the pact spec (or multiple if I've defined multiple that use it); and any model objects that I'm creating for use in the verification tests. Feels like one of those should be able to be generated

bethskurrie
2021-07-19 00:47
OK, I've just had one of the other devs tell me that there's a new builder api.

bethskurrie
2021-07-19 00:47
That's apparently the old one.

bethskurrie
2021-07-19 00:47
Have a look in the JVM docs


mail_4brad
2021-07-19 00:49
Yeah, I preferred this one and disagreed with the listed benefits of the alternative. Not trying to be contrarian :slightly_smiling_face:

mail_4brad
2021-07-19 00:49
Don't get me wrong, my issue isn't with the verbosity of this builder

mail_4brad
2021-07-19 00:50
It was firstly the number of fields on a request, which differed from all the examples I'd seen (makes sense, they're only examples). And you've answered that one

mail_4brad
2021-07-19 00:51
So now I know you guys still think pact is a good fit for our problem space

bethskurrie
2021-07-19 00:51
still better than having to use just e2e tests, yeah?

mail_4brad
2021-07-19 00:53
I hope so, yeah

mail_4brad
2021-07-19 00:53
And my next point was a discussion around implementation of having to write a spec separate from code. Annotations have dominated for config, ORM mapping, json serialisation etc for a long time now in Java. But I can park that for future

bethskurrie
2021-07-19 00:54
Best to ask in the #pact-jvm channel.

mail_4brad
2021-07-19 00:54
yeah will for that one when I come back to it

mail_4brad
2021-07-19 00:55
Thanks. And cheers for your recent best practices vid, that was really helpful

matt.fellows
2021-07-19 02:00
Annotations might make sense

matt.fellows
2021-07-19 02:00
In Go, you can essentially do that (with struct tags)



matt.fellows
2021-07-19 03:57
Keen to simplify/refine

matt.fellows
2021-07-19 03:57
also thanks to Tim for better verbage

abubics
2021-07-19 08:05
You might also be able to extract some of those chunks into separate methods/functions and make them more composable.

mail_4brad
2021-07-19 08:11
Yes indeed. I like that I can keep adding to the dsl object. Came up with my first generated (capture) solution today so will do some more digging before sanity checking that in the jvm chat

matt.fellows
2021-07-19 10:20
also thanks to Andras (quoted tweet)

sripathi
2021-07-19 12:30
has joined #general

calvin.krist
2021-07-19 15:29
has joined #general

vinay.viswanadha
2021-07-19 15:30
has joined #general

brian.mitchell
2021-07-19 15:37
has joined #general

mike.geeves064
2021-07-19 18:07
has joined #general


mail_4brad
2021-07-20 05:48
Does a pact's *request* need to specify min/max etc for an array, given that the only data used to assess it will be that given as the example in the pact? eg is ```"request": { "body": { "dbObjects": [{ "id": 3 }] } }``` any different to: ```"request": { "body": { "dbObjects": [{ "id": 3 }] }, "matchingRules": { "body": { "$.dbObjects": { "combine": "AND", "matchers": [{ "match": "type", "max": 2, "min": 1 }] } } }``` ? Do the max/min matching rules make _any_ difference in this scenario? If the answer is "no" (like I think the "https://docs.pact.io/consumer#choose-the-right-type-of-matching-for-the-situation" advice is including) then I think that should get some big highlights in the doco.

marko.justinek
2021-07-20 06:15
afaiu, `min` and `max` are used to validate your request (validation of your request has at least one `dbObject`, and max 2). If your request would be made containing `dbObject: [{..}, {..}, {..} ]`, your client test should fail. the `body` in your example is then used by the validator to validate the provider side - ?emulates? a request that contains one object with id: 3.

mail_4brad
2021-07-20 06:28
Ah of course thanks. With my recent focus on request spec generation I lost sight of this. This is the written spec comparison against the consumer tests.

marko.justinek
2021-07-20 06:28
np

dimundo
2021-07-20 07:54
hi! is there matcher `any` ? like field is sometimes is `null` or `integer` yes, `you should control data` , but i want to create test with `eachlike` - response must have n children with mandatory fields despite their values

marko.justinek
2021-07-20 08:03
What language implementation are you using?

dimundo
2021-07-20 08:05
at least JS, maybe scala after some time

marko.justinek
2021-07-20 08:07
@Matt will definitely shed some light on the js implementation. But would the structure/value depend on provider state? If so, perhaps you can test against different provider states, where each responds differently (one with null, or key not provided, and the other expecting an Int value)?

dimundo
2021-07-20 08:10
provider returns n objects, they have different fields, dependent on their states, but some fields must be there ( still, with different types )

marko.justinek
2021-07-20 08:15
I _think_ I understand what you mean, but probably best to ask in #pact-js as different implementations might cater for certain cases.

ben.clare2
2021-07-20 08:16
has joined #general

dimundo
2021-07-20 08:21
2 possible children diff

marko.justinek
2021-07-20 09:01
At least in PactSwift I think I could use two tests for the two different states. One would match against Matcher.Null(), other against http://Matcher.Int(1).

dimundo
2021-07-20 09:02
thats understandable :slightly_smiling_face:

rafael.moral
2021-07-20 11:48
has joined #general

aubilla
2021-07-20 13:42
When running the https://github.com/pact-foundation/pact-stub-server, are the pacts loaded only once? Let?s say I have a folder with 3 pact files, I run the server and then a fourth pact file is added. Is it ?detected? and loaded by the Server?

paulorochag
2021-07-20 14:44
Guys, I created a repository demonstrating how it should be the implementation of webhook, pipeline and contract tests of Provider and Consumer applications in order to achieve what is considered _Pact's Nirvana_. The diagram in README.md can help group members understand the entire architecture of contract testing. It is in Brazilian Portuguese, but google translator can help. Depending on the demand I translate. https://github.com/PauloGoncalvesBH/nirvana-teste-de-contrato

kflo
2021-07-20 20:17
we just ran into an issue with WIP pacts enabled on our main branch. generally the provider build will pick them up and it won?t matter if they fail or not, it won?t block the provider build. however, someone just made a new consumer pact that requires a specific provider state that the provider doesn?t yet support ? and so the provider test is blowing up due to a match statement (this is in scala). i?m wondering if we are doing something wrong, or if there is some way to handle the scenario of a WIP pact requiring a provider state the provider hasn?t implemented yet

kflo
2021-07-20 20:19
pending pacts are also enabled, FYI

kflo
2021-07-20 21:00
related https://github.com/pact-foundation/pact-jvm/issues/1260 ? although we are not using `pact-jvm` for these tests. i know i can ignore missing states, but that seems potentially dangerous

andrii.rakhimov
2021-07-20 23:06
has joined #general

boris.gordon
2021-07-20 23:25
has joined #general

matt.fellows
2021-07-20 23:29
This looks great Paulo, I?ll have to look in more detail later

marko.justinek
2021-07-21 00:00
This is a really good example and having a http://README_en.it would be fantastic. :thumbsup: On a personal note it has been so long since I?ve read Portuguese I?m feeling so very warm and fuzzy inside right now :slightly_smiling_face:

abubics
2021-07-21 01:32
The main steer I would give here is: you want to describe each significant state+interaction. So, if you have the same endpoint with many different states, you probably want to say ? in state 1 the list items are exactly these (with different matchers in each item, if they need different fields present) ? in state 2 [the same concept, but different details] ? etc

abubics
2021-07-21 01:33
I'm working with a similar situation at the moment, we have a large body with about 40 nullable fields, but the entity goes through a bunch of different stages, so we have like 10 different tests with slightly different matchers for each significant state.

abubics
2021-07-21 01:34
Otherwise (if you make it too flexible/generic) you only get the reasoning power of a schema.

dimundo
2021-07-21 06:27
idea is , if i call `/get?object=a` i will get object with properties `x`, if i call `/get?object=b` i will get another object with properties `y`, and if i simply call `/get` i have all objects and all of them must have mandatory fields, but as i said before - they could have different value types

dimundo
2021-07-21 06:39
luckily, from 3rd try i?ve manage to complete this https://pact-foundation.slack.com/archives/CLS16AVEE/p1626849087212600

dimundo
2021-07-21 06:39
answers were the same

abubics
2021-07-21 06:41
I mean, you can do that as well, but you don't need to change the request to get Pact to give you different responses. That's what provider state is for :slightly_smiling_face:

matt.fellows
2021-07-21 06:42
thank you so much Dmitry, really appreciate it!!

poorvasgokhale
2021-07-21 07:12
Hello team, we are using `pact-cli` docker image and trying to publish pact. `docker run --rm pactfoundation/pact-cli:latest publish $HOME/build/pacts -b http://localhost:9293 -a 15` . It gives error that `Specified pact file '/Users/poorva/build/pacts' does not exist. This sometimes indicates one of the arguments has been specified with the wrong name and has been incorrectly identified as a file path.` I cross checked that pact file exists at this location. Am I missing anything?

matt.fellows
2021-07-21 07:13
doesn?t look like you?re volume mounting into docker, so docker can?t see `$HOME/build/pacts`

poorvasgokhale
2021-07-21 07:15
okay. Thanks @matt.fellows

matt.fellows
2021-07-21 07:17
do you know what to do?

matt.fellows
2021-07-21 07:17
something like `-v $HOME/build/pacts:/pacts` , and then the `/pacts` directory in the container has the files

uladzislau_danilchyk
2021-07-21 09:09
@matt.fellows, does it make sense to ignore missing annotated method with state in Scala as well as it was done in pact-jvm requested by me?


matt.fellows
2021-07-21 10:22
Seems logical to me. The whole point of WIP pacts is to not break providers for new pacts from consumers

paulorochag
2021-07-21 12:38
I'll create a README in english today, thanks for the feedback

kyle.florence
2021-07-21 14:49
But from the provider code side, it has no way of knowing if the pact is WIP or not

kflo
2021-07-21 17:05
i guess that if the state is not present then the pact should fail gracefully somehow? i think this will require a change in the implementation library

matt.fellows
2021-07-21 22:30
Have you just cloned yourself? :rolling_on_the_floor_laughing:

matt.fellows
2021-07-21 22:30
When the pacts come back from the broker, they have a flag on them indicating if they're pending or not

tjones
2021-07-22 00:55
Unrelated, but are you writing the pact files yourself? Usually you can treat the actual file as opaque without problems.

tjones
2021-07-22 00:56
(unless you're working on tooling)

mail_4brad
2021-07-22 01:00
I?m using builders typically, if that?s what you mean? Not hand crafting the json. I used the actual file content to help describe the question.

rafael.moral
2021-07-22 07:47
Hello! We are stating to play with pact, integrating it in one of our applications, and we have some doubts about how to start with. In our consumer application, we have integration test for use cases, and we have not unit test. How could be the best way to implement pact testing? IMHO, moving those test to pact could cause instability, because we test so many logics after and before the request. What approach could be better, create unit test for pact to cover infrastructure part or create separated test for it?

abubics
2021-07-22 07:59
How many integration points do your existing integrated tests cross? My general recommended workflow for pushing tests down the pyramid is: automate then narrow. If your integrated tests are already automated, that's a great starting position. If each one only crosses one boundary, that's even better.

abubics
2021-07-22 08:00
Bear in mind, Pact tests are not functional tests, so whatever setup and verification you're doing (in integrated tests) should be independent of any contract testing.

mike.geeves064
2021-07-22 08:31
The info on what it is not good for is worth a read: https://docs.pact.io/getting_started/what_is_pact_good_for/

mike.geeves064
2021-07-22 08:38
[lightweight low use user rather than in depth knowledgeable here :slightly_smiling_face: ] Also video on the faq page about where they fit in with integration etc: https://docs.pact.io/faq/

rafael.moral
2021-07-22 08:38
> How many integration points do your existing integrated tests cross? Too many, we test our use cases input-output, ignoring what is happening inside that ?black box?. I think that we should change our mindset and starting to cover with pact test the part of infrastructure used for communicating with the external API and ignore the rest, isn?t it?

tjones
2021-07-22 11:44
Yes, that's correct. Pact will help you confirm whether or not two services are able to communicate. This obviates the need to do (as much) integration testing. If your primary test approach is integration testing, you can use Pact to cover the integration points. This will help you know what broke if something does break (if you only have integration tests, you don't know whether it was the communication, behaviour or configuration that broke).

tjones
2021-07-22 11:46
My personal approach: * Unit tests for behaviour within a service * Contract tests for communication boundaries * Light touch integration tests (smoke tests) for configuration * Very occasionally black box style integration tests for cross system behaviour testing. I usually try to design those out by being careful about the boundaries of different concerns within the system

tjones
2021-07-22 11:47
All tests are risk reduction. Contract tests reduce the risk that you have two services that can't communicate without you realising. A full pact test setup reduces the risk of deploying those two service versions together.

tjones
2021-07-22 11:48
You can think of pact tests as a unit test for your API boundary (where the "unit" under test is both the client and the server communication code)

tjones
2021-07-22 11:48
:taco: s for @mike.geeves064 and @abubics for excellent answers too!

tjones
2021-07-22 11:50
In the situation where you already have extensive integration testing, Pact can help give you confidence that you have full coverage of a communication boundary (knowing your test coverage in integration tests is ...a challenge)

dimundo
2021-07-22 12:45
funny question :slightly_smiling_face: if pact is just reduced by 1 contract/state, how producer must act ? consumer just not expecting one of the messages anymore


dimundo
2021-07-22 13:13
but after that pipeline + consumer deployment provider must remove obsolete things

francislainy.campos
2021-07-22 13:53
```docker run --rm pactfoundation/pact-cli:latest publish ./target/pacts/ --broker-base-url=http://my-broker.com --consumer-app-version=`git rev-parse HEAD```` Hi, I?m unsure of the path to use here? Tried /target/pacts, target/pacts, ./target/pacts but not of them seem to find my contract

francislainy.campos
2021-07-22 13:56
Thank you.

francislainy.campos
2021-07-22 14:12
PWD does not seem to work either. :disappointed:

tjones
2021-07-22 14:15
> provider must remove obsolete things Why? :slightly_smiling_face:

dimundo
2021-07-22 14:16
kinda dead code, no?

tjones
2021-07-22 14:16
Pact confirms that a given consumer and provider can communicate

tjones
2021-07-22 14:16
If you remove an endpoint from the consumer's need without changing the provider, then Pact is still :+1:

dimundo
2021-07-22 14:16
this is fine

dimundo
2021-07-22 14:17
but clean code also is a nice thing

tjones
2021-07-22 14:17
> kinda dead code, no? I mean, I agree, and would probably remove it. But Pact is a testing utility, not a code cleanliness utility

dimundo
2021-07-22 14:17
The rule of the boy scouts is: ?Always leave the campground cleaner than you found it?.

dimundo
2021-07-22 14:17
but i?ve got idea :slightly_smiling_face:

tjones
2021-07-22 14:18
So, "how *must* the provider act" -> they don't *need* to do anything

tjones
2021-07-22 14:18
but how *should* the provider act - it's kinda up to the team

tjones
2021-07-22 14:19
some teams would be running code coverage tooling during verification. This would tell you that you now have uncovered code.

tjones
2021-07-22 14:19
Good question, though!

dimundo
2021-07-22 14:19
coverage will not show, that api is not in use anymore by other party

dimundo
2021-07-22 14:20
one still need to support it

tjones
2021-07-22 14:20
It should. Coverage will show that those endpoints are not executed during the verification any more.


tjones
2021-07-22 14:20
we should do dead state detection in the verifier DSL :+1:

tjones
2021-07-22 14:21
that would be cool

dimundo
2021-07-22 14:21
not sure how

dimundo
2021-07-22 14:21
check, which handlers weren?t touched by provider tests ?

dimundo
2021-07-22 14:22
not sure if it is an easy task

tjones
2021-07-22 14:23
it would be for the pact-js DSL. I don't think we can do it in the core.

tjones
2021-07-22 14:23
And I'm not sure how you would do it if people are providing their own endpoint for state change

dimundo
2021-07-22 14:23
state change is ok


tjones
2021-07-22 14:25
I put it in here

dimundo
2021-07-22 14:25
dead state is ok

dimundo
2021-07-22 14:26
but dead api? like noone needs ?share to g+? API

dimundo
2021-07-22 14:26
all consumers drops it

dimundo
2021-07-22 14:26
but provider still happy to do so

tjones
2021-07-22 14:26
Code coverage will spot that. Run a coverage tool during verification, then you can see that no consumers are exercising those endpoints.

tjones
2021-07-22 14:27
(or code paths)

francislainy.campos
2021-07-22 15:11
This worked. Had to mount volumes.

francislainy.campos
2021-07-22 15:12
```docker run --rm -w ${PWD} -v ${PWD}:${PWD} pactfoundation/pact-cli:latest publish ${PWD}/target/pacts --broker-base-url=http://pact-broker-hmh.devel.hmheng-qe.brnp.internal --consumer-app-version=`git rev-parse HEAD````

ryn.anderson
2021-07-22 17:41
has joined #general

thanuxxxx
2021-07-22 21:12
So I have a provider build web-hook with `contract_content_changed` *for every PR our consumer team creates triggers provider side build once* and it doesn't trigger any when the PR gets merged to master & I assume that's because of the pre-verified thing. Is that what that event suppose to do?

schakalabbi
2021-07-22 21:29
has joined #general

schakalabbi
2021-07-22 21:33
Hi All, I have just begun to read about pact and probably we will start experimenting this in our team. My questions 1- When I am testing a particular pair of consumer and provider services, In order for the provider to get its response, wouldn?t it stand up/bringup downstream service? 2- And by the time we run tests for every consumer/provider pair haven?t we brought the entire system up just like an integration system would do ?

abubics
2021-07-23 02:27
It's also a per-team consideration for versioning. Removing functionality is a breaking change (even if it breaks nothing because we have a record of "nothing depends on it anymore", which may only be "officially" true)

abubics
2021-07-23 02:34
This is explicitly & intentionally not the approach used in contract testing :slightly_smiling_face: The main workflow is: 1. Run consumer tests against a mock, then 2. Verify that the mock is consistent with reality (against the provider)

abubics
2021-07-23 02:40
Nice round-up, @tjones :taco:

tjones
2021-07-23 03:19
Yes, good point. If pact adoption is not complete, removing something because the consumer(s) using pact weren't using it might not be the right call.

schakalabbi
2021-07-23 03:28
Hey Boris thank you for getting back :slightly_smiling_face:, the doubt I have is, how will the provider be able to respond with actual json response without the downstream services being instantiated (Assuming the provider itself needs to call another provider before it sends any response)

marko.justinek
2021-07-23 03:41
The idea is to test the provider in isolation too. Using fixtures on the _test_ instance of your provider at unit test layer, not the real instance of the provider. The downstream service messages/responses are to be fixtures as well. And those can be (re)used as fixtures for your tests of the consumer part of the same provider. There should be no ?real? requests crossing the border into the next ?actual? module/system.

abubics
2021-07-23 04:05
Yes! The intent is to reduce collaborators as much as possible, making contract test scope close to that of unit tests. There are a few ways to stub state in your provider, but they depend on the internal architecture. My preferred way is to cut just inside the endpoint layer (if my provider is an API), so the use-case transform is still exercised. But you can also stub your direct dependencies inside your provider, or stub/seed the direct dependencies outside the provider.

schakalabbi
2021-07-23 06:01
Hey Marko and Boris thank you for the responses. I am going to try a POC now, that might clarify more :slightly_smiling_face:

schakalabbi
2021-07-23 06:01
Have a great weekend :slightly_smiling_face:

rafael.moral
2021-07-23 06:12
Thank you so much!

abubics
2021-07-23 07:23
np, gl :party_parrot:

consulting
2021-07-23 12:33
has joined #general

sagupta
2021-07-23 13:18
Hello Just wanted to ask people how are they notifying about test failures . Currently i have setup a webhook in pact broker to trigger slack notification on test failure . However i wanted to add some more details to that like ? show only failed test ? we use gitlab so would be nice if we can link the failed pipeline URL also in the slack message has anyone tried it . Or suggest other things?

galante2123
2021-07-23 14:14
has joined #general

dc113604
2021-07-23 14:39
has joined #general

tjones
2021-07-24 07:22
How do you normally show a build failure?

tjones
2021-07-24 07:22
It feels to me like the failure notification is up to the CI system, not necessarily your pact infrastructure

tjones
2021-07-24 07:23
For example, unit test failures don?t normally notify you directly.

sagupta
2021-07-24 07:27
We do not currently notify gitlab build failures to let?s say slack .We are working on implementing it soon though The web hook from pact broker is helpful as it can show consumer,provider or associated pact details .However we wanted to get some more details in it

tjones
2021-07-24 07:41
Makes sense. I?m afraid I don?t know the answer beyond what?s in the webhook documentation

tjones
2021-07-24 07:42
(but someone else probably does)

rarora
2021-07-26 01:31
Hi team I have small basic question that is kind of blocking us. Its similar to https://docs.pact.io/pact_nirvana/step_5 . So, as per our current setup below is happening: 1. Consumer wrote new test in feature branch, this triggers webhook and pact verification fails as new test are not in production yet for provider. 2. We write provider test. When we try to merge feature branch of provider, its configured to verify contract against stable branch of consumer(develop). Since, consumer test are not tagged with develop yet, this fails our build and hence we are unable to merge provider.

rarora
2021-07-26 01:31
anybody with working setup, can you guide me how you make first run successful?

tjones
2021-07-26 01:33
I?m not sure I understand the situation. If your consumer contract is not there in step 2, why was it there in step 1?

rarora
2021-07-26 01:33
its there in both steps but in feature branch, not merged to develop

rarora
2021-07-26 01:34
let me edit question with branch names

tjones
2021-07-26 01:36
ah, I see

tjones
2021-07-26 01:36
This is for a new consumer?


tjones
2021-07-26 01:38
I think there?s a ?succeed if no pacts found? mode for the verifier. Which language framework are you using?


tjones
2021-07-26 01:40
Which verifier are you using?

rarora
2021-07-26 01:41
junit5 one i think

rarora
2021-07-26 01:43
```import au.com.dius.pact.provider.junitsupport.IgnoreNoPactsToVerify;``` let me check if this would work

rarora
2021-07-26 01:44
```compile "gradle.plugin.au.com.dius.pact.provider:gradle:4.1.11"``` we are using this in gradle

abubics
2021-07-26 02:00
Yeah, generally I'd say make CI notify people, then you'll get the best value (full notifications, not only for pact). When our test step fails, the report says which consumer & provider it was (if it was a Pact failure), or whatever else broke (if not). I'm not sure if putting more detail in the notification gives much value, but you can certainly try :slightly_smiling_face:

dsinecos
2021-07-26 04:49
has joined #general

tjones
2021-07-26 04:54
@sagupta: If you do end up building a custom slack bot for the broker's webhooks, it sounds like something that would be great to have under `pact-foundation` on github

tjones
2021-07-26 04:55
According to the docs, it supports `pact.verifier.ignoreNoConsumers=true`, which you could set to allow your first deployment. https://docs.pact.io/implementation_guides/jvm/provider/gradle/#project-properties

rarora
2021-07-26 04:56
thank you!

poorvasgokhale
2021-07-26 04:58
Hello team, we are exploring contract testing for microservices. one of the argument or FAQ I hear a lot is *We have client libraries provided by provider team, then why do we need contract testing?* (Provider team releases client library for ex. Kotlin and Typescript library. Consumer use this library to talk to Provider) Some of the reasons I could think to convince ppl for contract testing are  1. Contract testing gives insight about which fields and APIs are actually being used by consumers. This gives confidence to make changes without breaking functionality and un-necessary version hell. 2. There is always a chance that the consumer are using different versions of client. (I get answers like automated dependabot PRs to consumer repos to make sure consumers upgrade client libraries.) Is there anything else that can be added here to convince about contract testing in case of client libraries?

rarora
2021-07-26 05:01
i have another question, when does broker trigger webhook? we have a scenario where: 1. There is a provider service which was adding production tag through webhook. 2. due to some issues in webhook, this production tag stopped getting added but there is no change in pact. 3. when new commit of feature branch of provider service is pushed, it ran provider test and passed. 4. when consumer checked canIDeploy, it failed saying latest of provider does not have production tag(which is true) but older version still has it and pact is same, why cant it proceed?

rarora
2021-07-26 05:01
it was just feature branch commit

matt.fellows
2021-07-26 05:02
You might also like the video in this AMA https://docs.pact.io/help/amas/#north-america-2

matt.fellows
2021-07-26 05:02
> How can I do contract testing with API clients/SDKS?


matt.fellows
2021-07-26 05:15
What does 1 mean sorry? Why are you tagging on webhook?

matt.fellows
2021-07-26 05:16
You usually would only tag your provider something like `production` when you release to prod, this wouldn?t normally occur via a webhook trigger, but keen to know why

matt.fellows
2021-07-26 05:16
Have you seen this workshop: https://docs.pactflow.io/docs/workshops/ci-cd/ ?

rarora
2021-07-26 05:18
our thought process was, when consumer publishes contract it would trigger webhook which would verify against production version of provider. Once production version of provider runs test, it adds production tag

rarora
2021-07-26 05:18
so, webhook is just a trigger which runs jenkins job and run provider test on production

rarora
2021-07-26 05:19
when we release provider to production, there was no way to tag pact as our ci-cd doesnt allow additional steps

rarora
2021-07-26 05:20
yes i have, add-tag functionality does not work for us

mebenhoeh
2021-07-26 05:20
has joined #general

matt.fellows
2021-07-26 05:24
> when consumer checked canIDeploy, it failed saying latest of provider does not have production tag(which is true) but older version still has it and pact is same, why cant it proceed? how are you calling can-i-deploy?

rarora
2021-07-26 05:24
we have gradle task canIDeploy which is run as part of contract test stage

matt.fellows
2021-07-26 05:24
sure, but what are the arguments to it?

matt.fellows
2021-07-26 05:25
If the current production version satisfies the contract of the consumer that is to be deployed, and the broker has this data, then it should pass. But that depends on the flags you?re passing

matt.fellows
2021-07-26 05:25
> yes i have, add-tag functionality does not work for us why not?

rarora
2021-07-26 05:27
./gradlew canIDeploy -Ppacticipant={service-name} -PtoTag=production

matt.fellows
2021-07-26 05:27
where does version come from?

matt.fellows
2021-07-26 05:27
is it implied by the current project version?+

matt.fellows
2021-07-26 05:28
What does the matrix look like for the version you are trying to release?

rarora
2021-07-26 05:30
```project.ext.pacticipantVersion = "${project.rootProject.ext.COMMIT_HASH}"```

rarora
2021-07-26 05:30
so version is coming from commitHash

rarora
2021-07-26 05:30
```11:35:06 There is no verified pact between version 2322dd2094c601b2de5dedef7b27255ebf7a2f47 of product-service and the latest version of feature-service with tag production (123123123)```

rarora
2021-07-26 05:31
we got this error. so it is checking latest version of feature service

rarora
2021-07-26 05:31
which was a feature branch of feature-service

matt.fellows
2021-07-26 05:33
can you please filter so you can see the `production` versions of feature-service?

matt.fellows
2021-07-26 05:35
when you tag with `production`, if a new provider publishes verification results and tags `production` it becomes the new released thing

matt.fellows
2021-07-26 05:35
In your screenshot, note how none of the feature-service things tagged `production` are blue (current/active). The are all outdated now (shown in grey)

rarora
2021-07-26 05:37
but newer version of provider was feature branch and pact is same, shouldn't it get tags which are still applicable?

matt.fellows
2021-07-26 05:38
think about it this way

matt.fellows
2021-07-26 05:39
whatever is currently in production (feature-service), needs to have satisfied the contract with the version of the consumer (product-service) that you?re deploying. If no verification exists between them, can-i-deploy will fail

matt.fellows
2021-07-26 05:40
Specifically, go to the matrix page and put in the version of the consumer you want to deploy

matt.fellows
2021-07-26 05:40
you should be able to see which versions of the provider its compatible with

matt.fellows
2021-07-26 05:40
it may be the case that what?s in prod is compatible, so that would indicate an error in your tagging logic

rarora
2021-07-26 05:40
i filtered it already as in screenshot above - a992c38

rarora
2021-07-26 05:41
it shows its compatible with feature branch

rarora
2021-07-26 05:43
we know tagging is broken in production, i just wanted to know if pact has not changed, would it retain previous tags or not?

matt.fellows
2021-07-26 05:43
no tag

rarora
2021-07-26 05:44
yes, because it was feature branch jenkins run

rarora
2021-07-26 05:44
we know tagging is broken for production and was working few months before as seen in below screenshot

matt.fellows
2021-07-26 05:44
The tag is actually on the consumer or the provider version

matt.fellows
2021-07-26 05:45
> i filtered it already as in screenshot above - a992c38 that?s the consumer version

matt.fellows
2021-07-26 05:45
now I?m confused about what you?re asking :laughing:

rarora
2021-07-26 05:46
let me start over

rarora
2021-07-26 05:47
feature branch SUPPLY-4979 ran same contract that was few months before and is in production. it added its provider tag.

rarora
2021-07-26 05:47
since this is a feature branch and not deployed to production, it did not add production tag

matt.fellows
2021-07-26 05:48
and for clarity, this is the _consumer_ in this example?

rarora
2021-07-26 05:49
SUPPLY-4979 is provider

rarora
2021-07-26 05:49
feature branch of feature-service(provider)

matt.fellows
2021-07-26 05:49
this commit?

rarora
2021-07-26 05:50
no commit id: f599ac5

rarora
2021-07-26 05:50
first one in below screenshot

matt.fellows
2021-07-26 05:50
ok sorry, I was looking at the other screenshot

rarora
2021-07-26 05:51
when consumer product-service(some other team) ran its build, as part of it, it checked canIDeploy their commitHash version to production for provider feature-service

rarora
2021-07-26 05:52
it got this first entry and said no, due to first entry

rarora
2021-07-26 05:52
```11:35:06 There is no verified pact between version 2322dd2094c601b2de5dedef7b27255ebf7a2f47 of product-service and the latest version of feature-service with tag production (f599ac5)```

matt.fellows
2021-07-26 05:55
so punch that version into the matrix view for the consumer, and see what rows come back

matt.fellows
2021-07-26 05:57
(just an FYI that I have a meeting, but will pop back later)

rarora
2021-07-26 05:57
its similar

rarora
2021-07-26 05:58
no worries

rarora
2021-07-26 05:59
we had errors for two commits : a992c38e3fb4c5f6cb15e3704f846f5d43d1684e and 2322dd2094c601b2de5dedef7b27255ebf7a2f47 and both have same issue, no production tag

matt.fellows
2021-07-26 06:00
exactly!

matt.fellows
2021-07-26 06:00
what are you expecting can-i-deploy to return? They don?t have the tag

rarora
2021-07-26 06:00
yup that i understand. but since pact has not changed, shouldnt it read from older version that has tag

matt.fellows
2021-07-26 06:02
it must have, otherwise it would be pre-verified

rarora
2021-07-26 06:02
means?

rarora
2021-07-26 06:02
if it has, why canIDeploy is saying no? why not read from older version

matt.fellows
2021-07-26 06:03
that matrix will show what Pact thinks is going on

matt.fellows
2021-07-26 06:04
it believes the contracts _are_ different

matt.fellows
2021-07-26 06:04
download the contract between the working and non-compatible ones and compare

poorvasgokhale
2021-07-26 07:29
Most of the usecases for pact are microservices communicating with each other and each microservice is built by different team. Given this context will pact be suited in following case where, ? Application have frontend codebase repo and backend codebase repo. Frontend talking to backend over HTTP. It?s mostly same team building both frontend and backend. Will pact be suited in this case? or is it over engineering in this case. ? If team for frontend and backend are different, does this make situation to introduce pact?

matt.fellows
2021-07-26 07:31
If you deploy the things separately, having contract tests is nice because as you grow/change the system (and people around it) that context gets lost and Pact will decouple your testing

matt.fellows
2021-07-26 07:31
Different teams is certainly one of the main drivers for it though, because it makes assumptions across team boundaries explicit

matt.fellows
2021-07-26 07:32
I think there is still value, for the same reason (and I can?t remember who I?m misquoting here, probably Tim or Andras) that writing unit tests are valuable

abubics
2021-07-26 07:47
> probably Tim or Andras Sounds like something we'd say :joy:

abubics
2021-07-26 07:49
I do think contract tests are still valuable, regardless of whether it's the same team or not, because they can tell you when expectations are broken. Without any kind of automated regression suite, people have to remember (and I think we all know some people who don't always remember).

abubics
2021-07-26 07:50
On top of that, they can help you design better interfaces (e.g. ReST modeling), just like TDD can help you write more testable & reasonable code.

poorvasgokhale
2021-07-26 07:51
yeah makes sense. We are already doing API/Spec first development. I think all these choices will really compliment each other

abubics
2021-07-26 07:53
It's harder to get the interface design benefit if your contracts aren't consumer-driven, but the regression test value is still there (if partial) :thumbsup:

poorvasgokhale
2021-07-26 07:58
I think the flow for us would be 1. consumer driven contracts, 2. finalise provider Spec for provider based on consumer expectations, 3. Generate provider API from Spec. 4. Contract test acting a shield for continuous development of consumer and provider Does this make sense to you?

abubics
2021-07-26 08:00
I'm not sure exactly what you mean by "spec" and "generate", but the rest seems good :)

poorvasgokhale
2021-07-26 08:12
Spec is the openApi specification and we have logic at our end to generate server (interface) and full Client based on openApi specification

mahajanalokkumar
2021-07-26 12:39
@abubics when you say "Verify that the mock is consistent with reality (against the provider)" Can you please let me know if the providers should be mocked or a real one?

matt.fellows
2021-07-26 13:20
Hi folks! So I had this question from a Pactflow prospect recently. I think it has many of the arguments we use for API Gateways (reminder to add to our docs, because it comes up enough to warrant a section on it), but I?m keen for feedback here though. > The big problem that I can see, is that https://www.ibm.com/au-en/cloud/api-connect doesn?t have any way of integrate with Pact and therefore can not contribute to Contract Testing. ?? we could ignore it altogether if the API acts as nothing more than a proxy, but if this isn?t the case i.e is responsible for adding headers, request parameter, manipulating the request body in any way then it will never work, as the contracts will not match. >   > Furthermore, I have concerns about this at a more architectural level. My understanding is that API?s along with giving additional benefits should act as a layer of abstraction and consumers should not require to understand how they work, or what else they communicate with, they are a blackbox. But by enforcing that the contract tests need to be done at microservice level, this means that all consumers of an API must understand how the API works so that they can know what they should actually be writing their contract tests against.

matt.fellows
2021-07-26 13:22
> My understanding is that API?s along with giving additional benefits should act as a layer of abstraction and consumers should not require to understand how they work, or what else they communicate with, they are a blackbox I think the core concern here is about decoupling implementation from the interface which is of course a good thing. The API is the ?UI? of the implementation, which should be allowed to change freely. That doesn?t mean you don?t test it, and it certainly doesn?t imply the consumer shouldn?t understand how to use it. That?s all the Pact is doing - making it clear how a consumer is actually using a given API (from the outside i.e. black box). In Pact, consumers don?t need to know if the implementation of Provider A changes, so long as Provider A keeps the external facing interface the same. If that provider is the gateway which abstract things, then your abstraction is perfectly realised. The gateway sends data to some other place, and now you have a set of tests that ensure that migration happens safely. If it?s the microservice itself, no abstraction is leaked, it just so happens that there is a 1-to-1 mapping.

matt.fellows
2021-07-26 13:25
> But by enforcing that the contract tests need to be done at microservice level, that?s an implementation detail of the testing itself, which is orthogonal to contract-testing as a paradigm. Pact is not prescriptive here. > this means that all consumers of an API must understand how the API works so that they can know what they should actually be writing their contract tests against. As stated above, consumers of an API _should_ understand how an API works given its public interface. I don?t see how you can get around it, because they must be able to in production.

francislainy.campos
2021-07-26 14:00
Hi, is there anything we should do or know about the autogenerated pacts folder as when I run the tests from docker it does not appear there.

francislainy.campos
2021-07-26 14:00
These are the commands we have for building and running the image

francislainy.campos
2021-07-26 14:01
```docker build -f bedrock_tests/Dockerfile -t ed-showcase-pact-container .```

francislainy.campos
2021-07-26 14:01
```docker run --rm -v /dev/shm:/dev/shm --shm-size=4g -v $(pwd)/project ed-showcase-pact-container sh start_tests.sh```

francislainy.campos
2021-07-26 14:01
I?m on Javascript

matt.fellows
2021-07-26 14:13
Do the tests produce a pact file on the volume mounted dir?

matt.fellows
2021-07-26 14:14
If not, they will remain in that container which is deleted after the run

francislainy.campos
2021-07-26 14:22
Thanks Matt. To be honest, I?ve no idea. I don?t really know how to use docker much to check this. I?ll try to google it.

dimundo
2021-07-26 14:42
for sure 1st stage of buil must leave some artifacts ( like /pacts folders ) which must be mounted for next step with docker ( if I guessed properly and you trying to do some cicd pipeline )

dsmileb
2021-07-26 16:06
has joined #general

hazel.wright
2021-07-26 19:04
has joined #general

thanuxxxx
2021-07-26 21:32
What I am doing wrong here, I suppose to execute web-hook for provider side build when `contract content changed,` but it fires every time there is a *new brach created*.

thanuxxxx
2021-07-26 21:35
latests consumer is already verified then what is the point to trigger the provider side build

abubics
2021-07-26 23:49
ah . . . I don't think you can automatically generate a complete API just from a spec (or even a contract), but you can certainly generate the presentation (endpoint) layer :thumbsup:


matt682
2021-07-27 01:32
has joined #general

thanuxxxx
2021-07-27 04:50
So if I remove consumer side initial tag that would solve the problem but what is the recommended approach? Is that okay to trigger provider side built every time a new tag is introduced even though contract content has never changed

anchit.99
2021-07-27 06:30
I have a query on Pact messaging. Let's say that we have 2 services communicating via a Kafka queue. Now AFAIK we have 2 approaches for moving message between two points: 1) Capture the message at service1 with kafka headers, and bring it over to a live service2. We would try to get the live service to read from the pact message but this won't be possible because the live service is designed to read from queues and not contract files. 2) Capture the method before kafka headers are added. Bring it over to the source code for service2 and deserialize the message. Now get the service2 source code to consume the message by triggering it artificially (for ex. using Reflection / Mockito). Are both these points valid? Is this the right approach (pt. #2) towards messaging?

matt.fellows
2021-07-27 07:45
I can?t tell you if that?s a problem, it would probably depend on whether or not there are other undesirable side-effects

matt.fellows
2021-07-27 07:45
but usually this just verifies the contract for the branch and sends back results, so no harm done except for some compute time

matt.fellows
2021-07-27 08:08
In pact it's closer to 2




matt.fellows
2021-07-27 08:11
We have a few examples there also :point_up:

sagupta
2021-07-27 08:41
@tjones alright sure , i along with some colleagues can actually have a look at it. Do you also have some requirements in mind for it?

tjones
2021-07-27 08:47
I don?t. I?m not even sure what?s involved with a GitHub bot- I have seen them done as a small bit of AWS lambda, but that was for an AWS specific trigger, so I don?t know if that?s necessary. Something that is easy for people to set up and use would be ideal. We don?t have a formal process, but usually to bring something in to the pact-foundation GitHub we look for active maintenance from at least two maintainers (and ideally a few people using it, but I think this is a fairly niche use case, so it might not be something that everyone uses). As long as the use case is clearly described in the readme, I think it?s good. In most projects the documentation is generated from the readme, so it?s worth keeping that in mind when working on it

sagupta
2021-07-27 11:09
@abubics about this > When our test step fails, the report says which consumer & provider it was (if it was a Pact failure), or whatever else broke (if not). May i know how are you getting the consumer and provider details in that report which your CI notifies as i think those details can be retrieved from variables if we use pact broker webhook to notify teams (via slack for example). So in short this is what is happening for my team: Gitlab runs pact-test-contract job >> verification results published to pact broker >> webhook (to trigger slack message on failures) runs if test fail >> we get notified in slack ? What is present in this slack message: ? Consumer , provider name ? Complete Test Run URL which is a json which is not nicely formatted so almost not usable ? What is missing in this slack message: ? What was the gitlab job which ran so that in gitlab we can eventually know what was the branch, last commit etc to identify what changed which triggered this test failure

abubics
2021-07-27 13:58
Sorry, I may not have been clear . . . I haven't got notifications at my current engagement, but the failed Gitlab job tells me the consumer and the provider in the test report.

abubics
2021-07-27 13:59
e.g. ```1) Verifying a pact between [redacted consumer] and [redacted provider] - a request to fetch [blah] details by number has a matching body```

vbhardwaj.eminent
2021-07-28 05:15
has joined #general

miguel.panelo
2021-07-28 07:29
has joined #general

otaviio
2021-07-28 07:57
has joined #general

patrice.krakow
2021-07-28 10:00
has joined #general

patrice.krakow
2021-07-28 10:13
Hello :wave: My name is Patrice Krakow, and I am working as an "Architect" for "API Management" and "Service Mesh"; actually, we have "something" that merged these two thingies :wink: I am (super) new to PACT, but the idea of "Consumer Driven Contract Testing" sounds (super) natural in a world in which Consumers are subscribing to API (made by Producers). Today, I see the API solely defined by the Producer, using OpenAPI. In terms of testing, I do see Consumers able to test the API using test data/mock provided by the Producer (usually via OpenAPI extensions), but I have (indeed) never seen Producers able to test a modification of their APIs against the usage from Consumers. Is it where PACT should help? I would be happy to know how I could best continue my exploration of PACT... I already have two quick questions: Q1: Do you guys discuss/collaborate with "OpenAPI Initiative"? Q2: How is the adoption of PACT going? What about support by Postman?

tjones
2021-07-28 10:19
We (I) have a plan to generate postman from pact, as it feels like a natural fit.

tjones
2021-07-28 10:19
My personal feeling is that an open api spec and pact are for different things.

tjones
2021-07-28 10:20
You may be interested in the AMA that @matt.fellows@matt.fellows@matt.fellows and I are doing in 12 hours- have a look in the #pactflow-ama channel for details

tjones
2021-07-28 10:20
And yes, the situation you describe is a natural fit for pact

tjones
2021-07-28 10:21
With openapi, how do you know if your consumer and provider can talk to each other?

tjones
2021-07-28 10:22
Typically people doing openapi without pact pair with a postman collection for the examples.

tjones
2021-07-28 10:22
Apologies for the short answers. I?m on mobile, and can elaborate later

tjones
2021-07-28 10:23
I would say that the adoption of pact is going ?well? in that we have users all over the world, in big and small companies, and a todo list that is large enough to be hard to keep on top of in my free time outside my non-pact job.

tjones
2021-07-28 10:24
It?s also an exciting time to be a pact maintainer- I (anecdotally) think we?ve had more new contributors in the last 12 months than in the last few years.

patrice.krakow
2021-07-28 11:11
Thanks for all your (quick) replies... (1) Happy to hear about the "natural fit" with Postman (2) I agree that OpenAPI and PACT "are for different things", but I looking for the API Management solution that brings them together (via the subscription?) (3) I hope your AMA will be recorded as I will probably be sleeping (CET) (4) Good to hear that the situation I described is a natural fit for PACT (5) We put producer and consumers together via the "subscription mechanism" of our API Management solution (6) I have seen Postman collection provided by the Producers to the Consumers, but I am understanding "Consumer Driven Contract Testing" as being the opposite, the Consumers showing to the Producers how its API is used, is that correct? (7) No problem, many thanks for all your replies (8) Good to hear/read (9) I am looking forward diving more into this subject...

matt.fellows
2021-07-28 12:00
It's definitely being recorded via stream direct to YouTube, we'll link to it in #general tomorrow after it's done

matt.fellows
2021-07-28 12:00
Your timing is very good!

david.simpson
2021-07-28 12:51
has joined #general

e.alderson004
2021-07-28 17:17
has joined #general

matt.fellows
2021-07-28 22:58
FYI recording here: https://lnkd.in/g4Zw59K Really keen for feedback and your thoughts!

poorvasgokhale
2021-07-29 05:32
Hello team, has anyone tried messagePact using kotlin and kotest. Most of the examples I see are in junit. I could get request response pact working in kotlin and kotest. I could write MessagePact using DSL. ```class MessageTestRun() : MessagePactTestRun<Unit> { override fun run(messages: List<Interaction>, context: PactTestExecutionContext?) { messages.forEach { interaction -> ???? //////// what should go here } } }``` I am struggling to understand what should go inside `run` function. Is there any example for consumer side message PACT test in kotlin kotest

poorvasgokhale
2021-07-29 05:42
yeah. I meant presentation layer only

abubics
2021-07-29 05:48
Then I think you're on the right track :party_parrot:

matt.fellows
2021-07-29 06:44
Probably best asked in #pact-jvm

matt.fellows
2021-07-29 06:44
I'm not aware of Kotlin examples, but assume translating from the Java ones should be doable

matt.fellows
2021-07-29 06:44
I don't speak Kotlin so I can't help you directly I'm afraid

jdalessandro
2021-07-29 07:27
has joined #general

poorvasgokhale
2021-07-29 07:31
No worries @matt.fellows. I have posted in #pact-jvm group

anchit.99
2021-07-29 08:02
@matt.fellows I've implemented a POC already but just wanted to make sure about the approach. Thanks for confirming and sharing these links! I'll check them out.

eric.tang1
2021-07-29 16:22
has joined #general

antklim
2021-07-29 22:25
has joined #general

toffer.lim87
2021-07-30 03:51
has joined #general

nathan.derave
2021-07-30 08:11
Hey there ! I have a general question about the verification of pacts hosted on Pactflow and defined with the v2 or v3 specs (depending on the language used. In this case JS for v3 and Python for v2). I just figured out that when using the `pactfoundation/pact-ref-verifier:latest` docker image (the recommended tool, not the legacy one) for verifying v3 specs pacts (generated with JS), no issue, they are well fetched and verify. However, when I want to fetch v2 specs pacts (generated with Python from another side of the stack), the Docker image above is unable to fetch the pacts (they are not found). ```07:46:29 [ERROR] Failed to load pact - Could not load pacts from the pact broker 'https://abcd.pactflow.io/' - NotFound("No pacts were found for this provider") Failures: 1) Failed to load pact - Could not load pacts from the pact broker 'https://abcd.pactflow.io/' - NotFound("No pacts were found for this provider")``` The provider name passed to the CLI seems correct when debugging tho (disclaimer, it uses hyphens `-` and is passed like to the CLI `--provider-name=my-dude-provider` .. Not sure if that could be an issue. Questions then: ? Is that expected ? Should I use v2 tools (like pact-python) for verifying v2 specs pacts. Same for the v3 tools / v3 specs ?

matt.fellows
2021-07-30 08:44
It should definitely work, can you please set logging to verbose and share? (Redacted)

matt.fellows
2021-07-30 08:45
Should tell us why it doesn't find anything

nathan.derave
2021-07-30 09:17
@matt.fellows - Aaaah apologies ! I just figured out the `--consumer-version-selectors` wasn?t covering the tags of that specific Pacts, hence nothing found ! :man-facepalming: Thanks for the confirmation that it should work, I would have inject more complexity if not !

francislainy.campos
2021-07-30 10:33
```docker run --rm -v ${PWD}/pacts:/project/pacts ed-showcase-pact-container``` It?s working now. Removed the shm pieces that were not needed and added /pacts to the run command. Thank you.

aphronio
2021-07-30 13:42
has joined #general

fabio882
2021-08-01 19:31
has joined #general

eddie
2021-08-02 04:08
has joined #general

eddie
2021-08-04 03:26
Where exactly does the line between functional testing and contract testing sit? Let's say I have a calculator service that takes a request ```{ operator: "ADD", operandLeft: 1, operandRight: 1 }``` and responds with ```{ result: 2 }``` would checking `result` == `2` fall under functional testing (and thus be abuse of Pact)? Is all that I can assert is that `result` 1) exists & 2) is a numeric value? Hope this makes sense!

matt.fellows
2021-08-04 03:51
In that case it?s cut and dry for me. Asserting `2` is testing the functionality

matt.fellows
2021-08-04 03:51
If it helps, _there are no clear lines between contract and functional testing_

matt.fellows
2021-08-04 03:51
(see https://docs.pact.io/consumer/contract_tests_not_functional_tests/ and the AMAs for some discussion on this)

matt.fellows
2021-08-04 03:52
It?s generally better to accept some overlap, than try to be overly dogmatic about things. Just like most forms of testing, the seams between different types/layers etc. aren?t usually bright lines.

eddie
2021-08-04 03:58
So for the example above, reading between the lines, the team that maintains the calculator service should have unit / component tests that cover that scenario (rather than handling it as a contract test)? For the team consuming the calculator service, both ```{ result: 3 }``` ```{ result: "two" }``` would represent breaking changes (one contractual, one functional). But either way, we're broken.

matt.fellows
2021-08-04 03:58
exactly

matt.fellows
2021-08-04 03:59
it?s not the Consumer?s job to check that the provider can add two numbers together

marko.justinek
2021-08-04 03:59
but life is cruel so too many times we need to do that too :neutral_face:

marko.justinek
2021-08-04 04:00
I?ll see myself out, bye

matt.fellows
2021-08-04 04:00
:laughing:

eddie
2021-08-04 04:01
If it's a choice between this and E2E tests that involves deploying both components to a staging environment, which way would you go? :thinking_face:

eddie
2021-08-04 04:02
coz we have major major pain with E2E tests. But they're the only way we have currently to verify one of our collaborators hasn't broken something...

marko.justinek
2021-08-04 04:04
I?m on Matt?s side on this one though. But if it is a ?actual? calculator (or whatever you?re dealing with) where only specific values are returned for given state and provided inputs, then verbatim matching might not be too bad of an idea. I mean, in what universe is 2+2 something different to 4? (don?t answer that)

matt.fellows
2021-08-04 04:08
you make a good point

matt.fellows
2021-08-04 04:08
not sure if the example is indicative or actual

matt.fellows
2021-08-04 04:10
> If it?s a choice between this and E2E tests that involves deploying both components to a staging environment, which way would you go? I?d probably err on the Pact side, but you?d be more aware of the potential details/tradeoffs

eddie
2021-08-04 04:10
We're not implementing a cacluclator :wink: - not even an indicative example. Just trying to get some ideas on when boundaries lie. Our problem is that the team imlpementing the service we consume might not write enough tests. We want to ensure behaviour that we depend on doesn't get broken. Something like Pact gives as a way to inject tests.

matt.fellows
2021-08-04 04:11
got it

eddie
2021-08-04 04:11
The only alternative being E2E tests

matt.fellows
2021-08-04 04:11
This video sums up the usual journey most teams go from moving away from E2E tests: https://www.youtube.com/watch?v=3T8J8Pwu3I4&list=PLwy9Bnco-IpfZ72VQ7hce8GicVZs7nm0i&index=4

matt.fellows
2021-08-04 04:11
You might want to run both in parallel whilst you build confidence in a new approach

matt.fellows
2021-08-04 04:12
It?s OK to have functional testing in your Pact tests, but just be wary using it *as* a functional test tool - that?s where you?ll end up creating problems (usually the pain is felt by the provider teams)

eddie
2021-08-04 04:13
> usually the pain is felt by the provider teams How does that pain usually manifest?


eddie
2021-08-04 04:14
Thanks so much :slightly_smiling_face:

matt.fellows
2021-08-04 04:14
basically, if your expectations are too tight/narrow, and you have lots of different scenarios, the provider now has to respond very specifically in each of those scenarios

matt.fellows
2021-08-04 04:15
that increases coupling, makes maintaining tests suites harder etc.


bethskurrie
2021-08-04 04:19
@eddie If you don't trust that the provider has enough functional testing, I'd suggest that you could write your own functional tests that go directly to the provider in the e2e environment, rather than trying to do functional testing through Pact, or through your consumer.

bethskurrie
2021-08-04 04:19
Less chance of bloating your E2E suite and less chance of brittle Pact tests.

eddie
2021-08-04 04:20
Thanks @bethskurrie. That unfortunately doesn't get us away from deploying the (3rd party) provider component to an E2E environment

bethskurrie
2021-08-04 04:20
Yes, indeed.

poorvasgokhale
2021-08-04 04:50
Hello @matt.fellows I am referring to https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/. In case of approach 1 mentioned in article (Write contract test using client SDK), I am assuming following flow. 1. Write consumer side contract test using client sdk. Client sdk will call mock provider provided by pact framework and PACT JSON will be generated. 2. This PACT JSON is shared with provider via PACT broker 3. Provider verifies PACT JSON Is this correct?

p0deje
2021-08-04 19:53
Hey folks! Can somebody clarify why can-i-deploy returns success on a freshly created provider version? Shouldn?t it instead complain saying that there is missing verification for this new version? *First check that the current consumer-provider versions have successful verification* ```$ pact-broker can-i-deploy --pacticipant 'Example API' --version 4.5.7 --to main Computer says yes \o/ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ------------|------------|-------------|-----------|----------|-------- Example App | 5556b81... | Example API | 4.5.7 | true | 1``` *Second check that can-i-deploy fails when provider version doesn?t exist* ```$ pact-broker can-i-deploy --pacticipant 'Example API' --version 4.5.8 --to main Computer says no ¯_(?)_/¯ No pacts or verifications have been published for version 4.5.8 of Example API``` *Now create new version of provider* ```$ pact-broker create-version-tag --pacticipant 'Example API' --version 4.5.8 --tag rc1 --auto-create-version Tagging Example API version 4.5.8 as rc1``` *Finally check if new version can be deployed* ```$ pact-broker can-i-deploy --pacticipant 'Example API' --version 4.5.8 --to main Computer says yes \o/ There are no missing dependencies``` :point_up: I would imagine the last command to fail and say there are missing verification, but it doesn?t. It works however correctly if I pass other pacticipants explicitly instead of using `--to` flag: ```$ pact-broker can-i-deploy --pacticipant 'Example API' --version 4.5.8 --pacticpant "Example App" --version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 Computer says no ¯_(?)_/¯ No pacts or verifications have been published for version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of Example API```

kflo
2021-08-04 20:35
are you using tags? are there any consumers which depend on that provider?

kflo
2021-08-04 20:35
IIRC `--to` only works if you?re tagging your pacts

kflo
2021-08-04 20:36
otherwise the broker won?t know about the pacts it needs to check, for example, in `main`

p0deje
2021-08-04 21:03
> are you using tags? Yes, the consumer is tagged with `main`. The provider is not tagged yet. ```$ pact-broker describe-version --pacticipant 'Example App' NUMBER | TAGS -----------------------------------------|----- 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 | main``` > are there any consumers which depend on that provider? Can you explain what do you mean by ?depends on?? There are verifications between this consumer and provider.

kflo
2021-08-04 21:04
huh. it?s strange that the consumer is tagged with `main` before the provider

kflo
2021-08-04 21:04
it should be the other way around

kflo
2021-08-04 21:06
i guess to fully diagnose the problem, i would need more context about how everything is set up. how pacts are being fetched for verification for example

p0deje
2021-08-04 21:09
> huh. it?s strange that the consumer is tagged with `main` before the provider I guess provider can also be tagged before, but the point here is that we create a new version of provider (e.g. we want to deploy it) and can-i-deploy says it?s good to go. But we haven?t run verifications for this new version yet!

kflo
2021-08-04 21:11
well, i?m guessing you are confusing the pact broker by asking it to verify a provider and specifying a `--to` that the provider is not tagged with? so there would be nothing to verify for that tag

kflo
2021-08-04 21:12
generally for a pact, the consumer would define it first, and then the provider would verify it and deploy first, and then the consumer would deploy

p0deje
2021-08-04 21:17
`--to` checks tags of other parties, doesn?t it? I?m asking the browser if new version 4.5.8 of the provider ?Example API? can be deployed against all applications with latest `main` tag. There is ?Example App? which has `main` tag and also contract with ?Example API?. It should be found by the broker, shouldn?t it?

kflo
2021-08-04 21:17
if you haven?t seen it already this might be useful https://docs.pact.io/pact_broker/can_i_deploy/

kflo
2021-08-04 21:19
well? i?m not sure how `--to` works in the case where the consumer is already in `main` and the provider is not

kflo
2021-08-04 21:19
might have to have someone from the pact team respond to that

kflo
2021-08-04 21:20
it might think since the consumer is already tagged with `main` it?s already been verified

p0deje
2021-08-04 21:20
Yeah, I?ve read the docs and I think it still doesn?t make sense. I feel like this has something to do with https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/matrix/deployment_status_summary.rb#L130-L150 but I cannot really wrap my head around this comment :disappointed:

kflo
2021-08-04 21:21
?the provider does not require the consumer? might be the answer

kflo
2021-08-04 21:22
i can only suggest following the normal consumer-driven flow which i mentioned above, that?s how pact is supposed to be used

p0deje
2021-08-04 21:23
What I don?t understand is why provider doesn?t require consumer. If there is a contract between consumer and provider, deploying provider should check it?s compatible with latest production version of the contract.

kflo
2021-08-04 21:26
what do the pacts look like in the broker? do they show as verified?

p0deje
2021-08-04 21:34
No they actually look weird like the version doesn?t even exist:

p0deje
2021-08-04 21:35
But it exists: ```$ pact-broker describe-version --pacticipant 'Example API' --version 4.5.8 NUMBER | TAGS -------|----- 4.5.8 | rc1```

kflo
2021-08-04 21:35
yeah so the matrix is definitely broken

kflo
2021-08-04 21:36
that?s what `--to` will use

kflo
2021-08-04 21:36
i?m not sure why though

phil.endsley
2021-08-05 01:36
> What I don?t understand is why provider doesn?t require consumer. If there is a contract between consumer and provider, deploying provider should check it?s compatible with latest production version of the contract. Yes, you're correct here. This is what's supposed to happen > `--to` checks tags of other parties, doesn?t it? Yes. `--to` checks to make sure the thing you're trying to deploy has a successful verification with everything it depends on, and everything that depends on it with the tag specified with `--to` > huh. it?s strange that the consumer is tagged with `main` before the provider This will be the case virtually all the time, just not necessarily with passing verification. After the first pact is merged into main, the `main` tag will exist on the consumer. New feature development on the provider will occur, will be ran, before the matching consumer pact is merged. But the `main` tag still exists in that case.

phil.endsley
2021-08-05 01:41
> pact-broker create-version-tag --pacticipant 'Example API' --version 4.5.8 --tag rc1 --auto-create-version This is the part that sticks out as odd to me. Why create a version manually? The recommended practice is to use the commit sha as the pact version, so a new version is created with each commit.

phil.endsley
2021-08-05 01:43
> Shouldn?t it instead complain saying that there is missing verification for this new version? Yes, that's what I would expect, too. Regardless of all the other stuff, this looks like a bug to me as well.

phil.endsley
2021-08-05 01:45
> No pacts or verifications have been published for version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of Example API Is this from the cli output? This message is wrong, right?

phil.endsley
2021-08-05 01:47
I would have expected the same message as "Second check that can-i-deploy fails when provider version doesn't exist": > No pacts or verifications have been published for version 4.5.8 of Example API

phil.endsley
2021-08-05 02:07
> No they actually look weird like the version doesn?t even exist: > @p0deje try selecting show all results instead of just latest

phil.endsley
2021-08-05 02:08
For the matrix view

p0deje
2021-08-05 02:14
> This is the part that sticks out as odd to me. Why create a version manually? The recommended practice is to use the commit sha as the pact version, so a new version is created with each commit. It?s a bit tricky because in our case the provider version is not just SHA of commit, but rather a compound version of itself and additional services it depends. Because of that we often create version manually.

p0deje
2021-08-05 02:16
> Is this from the cli output? This message is wrong, right? You are right, I made a typo in command. The proper output would be this: ```$ pact-broker can-i-deploy --pacticipant "Example API" --version 4.5.8 --pacticipant "Example App" --version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 Computer says no ¯_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ------------|------------|-------------|-----------|----------|-------- Example App | 5556b81... | Example API | ??? | ??? | There is no verified pact between version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of Example App and version 4.5.8 of Example API```

p0deje
2021-08-05 02:17
> @p0deje try selecting show all results instead of just latest Something like this?

phil.endsley
2021-08-05 02:18
Same version as before for Example App, but change the radio button selection to the top one

p0deje
2021-08-05 02:19
This?

p0deje
2021-08-05 02:20
> I would have expected the same message as ?Second check that can-i-deploy fails when provider version doesn?t exist?: Yes, me too. It seems to me `--to main` and `--pacticipant "Example App" --version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30` should give the same result

phil.endsley
2021-08-05 02:21
My guess is the auto-create flag when creating the tag. But, that's just a wild guess without knowing how it works under the hood. I think it's worth raising an issue though

phil.endsley
2021-08-05 02:23
Yeah, if there are no other contracts with those apps, the commands should be the same. I think


phil.endsley
2021-08-05 02:29
Just a quick tangent though: > It?s a bit tricky because in our case the provider version is not just SHA of commit, but rather a compound version of itself and additional services it depends. Because of that we often create version manually. > The pact version is independent of the actual application version. It's really just a unique identifier for a specific state of the code base. It just seems strange to incorporate external factors (like other dependent services) into that

p0deje
2021-08-05 02:42
I can explain in more details what we?re trying to build, but that is a whole longer conversation :slightly_smiling_face:

tjones
2021-08-05 04:14
> . Because of that we often create version manually. This feels like a bit of an anti-pattern - ignoring pact, how would you reason about what version(s) are tested? Ideally, from a given state in your version control system, you can predict what version your software is. You can do this directly from your version control system, but some teams do this with a layer of indirection (eg, a build number that can be mapped to a particular commit)

tjones
2021-08-05 04:16
you might have a "release version" or an "application version" that has a different lifecycle, but for Pact, we want a version that means "a unique identifier for this state in the codebase"

tjones
2021-08-05 04:17
This is helpful for testing, because you can say "this bug existed when the code was in this state"

tjones
2021-08-05 04:22
Side note - I'm not a fan of just using the git hash as your version number, because even though it uniquely identifies a state of the codebase, it's not very human friendly. For this reason, I wrote `absolute-version`, which produces version numbers that work for pact and humans (assuming that you're using semver and tagging releases in your git history - which it sounds like you might not be).


dimundo
2021-08-05 06:19
> There is no verified pact between version 5556b8149bf8bac76bc30f50a8a2dd4c22c85f30 of Example App and version 4.5.8 of Example API this happens when consumer in branch and provider doesnt know about it how to fix ? ? use wip ( i?ve tried, but once and w/o success, need to try once more ) ? use webhook for contract_content_changed, pass consumer branch tag to provider and use as a consumer selector

marvin.kienitz
2021-08-05 07:20
has joined #general

danieljak
2021-08-05 10:09
has joined #general

univ.anirudh
2021-08-05 13:22
has joined #general

danieljak
2021-08-05 13:42
Hi!, I'm new to Pact and I really like the concept of CDC :slightly_smiling_face: . I was wondering if there are best-practices in regards of using Pact inside of a monorepo. I felt like the guide to CI/CD had the assumption that the codebase is split between multiple repositories (for example the webhook for reporting to the provider that the contract changed). I was also wondering if contract testing obsoletes the need for integration tests? If there is a strong unit tests base & strong contract testing base -> is that enough to declare the consumer/provider service as deployable to prod (while also providing continues testing on the prod environment).

kflo
2021-08-05 16:24
@phil.endsley in our workflow, we don?t even allow code to merge into `main` before it?s been verified by the provider, but i understand that maybe other teams have different workflows. the gist is, the provider should deploy first before the consumer

james.perepiczka
2021-08-05 16:29
has joined #general

kflo
2021-08-05 16:54
it does still seem strange to me to allow consumer code to merge before provider code, but i guess as long as you verify before deployment it?s fine

phil.endsley
2021-08-05 17:00
Agreed. Following all best practices, it seems like you shouldn't be able to get into that position

p0deje
2021-08-05 17:51
> This feels like a bit of an anti-pattern - ignoring pact, how would you reason about what version(s) are tested? > > Ideally, from a given state in your version control system, you can predict what version your software is. You can do this directly from your version control system, but some teams do this with a layer of indirection (eg, a build number that can be mapped to a particular commit) @tjones Ok, so we?re building something on top of Pact. We are using GraphQL and Apollo federation and allow consumers to use federated schemas. The consumer make requests to the GraphQL Gateway and it knows which downstream services it needs to query to get actual data, then merge the responses and return 1 huge response back to the consumer. What we have here is in fact multiple contracts (1 between consumer and gateway, N between gateway and downstream services). We?re building a system that allows to automatically generate the latter contracts and properly track verification across different combination of versions of these parties. So in our case, the gateway version is a cumulative version (itself + downstream services). So now when downstream service is deployed, it needs to update not only its own version, but version of Gateway too. This now leads us to the need to create the version manually sometimes.

j3rry.wan9
2021-08-05 21:44
has joined #general

sadikshahidain
2021-08-06 02:14
has joined #general

anchit.99
2021-08-06 06:10
I have a microservices situation like given in this screenshot. I have 3 services that communicate with each other in the following manner: A sends a message to B C sends a message to B B picks up C's message (it acts like a trigger) and immediately picks up A's message B combines both messages and consumes it. In this case, how should pact contracts be implemented for B? If we have an independent A-B and B-C contracts then each of them would require mocking the other message. Is that okay?


anchit.99
2021-08-06 07:12
@bethskurrie Got it! Thanks!

ganginenik
2021-08-06 18:14
has joined #general

eddie
2021-08-08 20:43
Off-topic, but NServiceBus sagas might be interesting for you.

pedroefajardo_pactio
2021-08-09 04:02
Does anyone know if there are any plans to provide tools for writing consumer tests in Elixir?

bethskurrie
2021-08-09 04:03
Not that I know of @pedroefajardo_pactio

bethskurrie
2021-08-09 04:04
We have made a lot of progress with making the rust shared core available for use in other languages in the last few months however, so it should be easier for someone to implement it now (vs a year ago).

pedroefajardo_pactio
2021-08-09 04:04
wow prompt reply. I appreciate it thanks for the info

pedroefajardo_pactio
2021-08-09 04:05
i found a project in GitHub that communicates with the Rust (shared core maybe?) via FFI but it hasn?t been touched in a long time

mpglover
2021-08-09 04:11
I've been looking to find the spare time to resurrect a project that I started to tackle it in an Elixir-native way. But realistically not sure how soon I'll get back to it. Haven't had a need for Pact yet at my current job. And my prototype only partially supported the v1 spec IIRC.

pedroefajardo_pactio
2021-08-09 04:12
is the project in a repo somewhere? This is the closest thing I?ve found https://github.com/elitau/pact_elixir

mpglover
2021-08-09 04:13
I don't know if I published it since I didn't hit anything close to a useful v1 with it.

bethskurrie
2021-08-09 04:13
Any Pact implementation that is going to be supported officially by the pact-foundation maintainers needs to use the shared rust core.

bethskurrie
2021-08-09 04:14
Believe me - you do not want to re-write the entire implementation yourself!

bethskurrie
2021-08-09 04:14
I would imagine using FFI bindings would be well supported in Elixr by now.

pedroefajardo_pactio
2021-08-09 04:14
?In the kingdom of the blind the one-eyed ~man~ person is queen/king? a starting point of any kind is better than nothing

bethskurrie
2021-08-09 04:14
It's a lot of work.

bethskurrie
2021-08-09 04:15
And it would likely be less work to use the FFI bindings to get something started than trying to implement even one of the earlier specification versions of pact.

bethskurrie
2021-08-09 04:15
there are now 4.

pedroefajardo_pactio
2021-08-09 04:15
yeah, i was thinking v3 via FFI bindings

bethskurrie
2021-08-09 04:16
that's a good starting place.

pedroefajardo_pactio
2021-08-09 04:16
newbie at Elixir, have done some sort of FFI like a million years ago using JNI.

bethskurrie
2021-08-09 04:16
you're ahead of me, as I've done none at all :stuck_out_tongue:

mpglover
2021-08-09 04:16
But yeah back when I started something (probably a year+ ago) that old partial Rust-integration project was the only one I saw published as well. So yeah you're probably going to have to roll your own at the moment.

bethskurrie
2021-08-09 04:17
But a bunch of people in the pact-foundation maintainer group have recently, so there will be someone to help you out if you get blocked.

bethskurrie
2021-08-09 04:17
or to get you started.

pedroefajardo_pactio
2021-08-09 04:17
oy vey ok cool I thought i?d start by asking here. Thank you

bethskurrie
2021-08-09 04:18
If you want to get your hands dirty, @matt.fellows can give you some pointers on how to get started

pedroefajardo_pactio
2021-08-09 04:18
awesome. i?ll start a convo with Matt after I talk with my manager thank you again

bethskurrie
2021-08-09 04:18
there might even be docs by this stage

pedroefajardo_pactio
2021-08-09 04:19
oh! THAT would be nice. Ask Matt about them?

bethskurrie
2021-08-09 04:19
yup


matt.fellows
2021-08-09 04:19
Ping us in #pact-rust for getting started pointers

pedroefajardo_pactio
2021-08-09 04:20
thank you Matt

matt.fellows
2021-08-09 04:20
There is also #pact-elixir but has been very quiet

pedroefajardo_pactio
2021-08-09 04:21
I think Beth created the channel today. :slightly_smiling_face:

tjones
2021-08-09 05:50
The easiest place to get started with FFI is the verifier

tjones
2021-08-09 05:50
We have a branch in pact-js that does just that.

tjones
2021-08-09 05:51
One reason it's an easy starting place is that the function that is exposed is essentially the CLI boundary - so you pass arguments to it as you would in the CLI

tjones
2021-08-09 05:51
I'm also happy to help out if you need (I know that Matt has a lot of things on his pact plate)

sams.prashanth
2021-08-09 06:50
As I mentioned in this image, I purposely made the request header value invalid inside the method annotated with @pact; but, on execution, the error is blindly thrown inside the test. Just curious to know, cos, I face similar issue in another test suite. I feel hard to debug where the actual error is. wish to know if there is a better way to trap such issues.

tjones
2021-08-09 06:51
If the mock is throwing a 500 it's because the request was unexpected

tjones
2021-08-09 06:52
The mock server throws a 500 to ensure the test fails

tjones
2021-08-09 06:52
an "unexpected" request means that something about the request did not match the expectation that you set up

tjones
2021-08-09 06:53
> I purposely made the request header value invalid inside the method annotated with `@pact` Yes, this will mean that the request will fail, and the mock will return 500.

tjones
2021-08-09 06:53
You can debug this by looking at the test output, and get further information from the pact logs.

tjones
2021-08-09 06:54
The test output is generally useful - have a look at it, and if you're still unsure why it is failing, post the test output here.

sams.prashanth
2021-08-09 06:55
even if I give an invalid header inside the @test , it returns the same 500. I am kinda skeptical if I need to make changes inside the @pact or inside the @test

tjones
2021-08-09 06:56
As an aside, perhaps you're just using `WebTestClient` as an example here, but you shouldn't use a tool like that with Pact (otherwise you're invoking the pact testing framework with the spring testing framework). Pact is designed to be triggered by your actual code.

tjones
2021-08-09 06:57
What are you trying to achieve? If you're trying to understand pact - then what is happening is Pact is (correctly) complaining that your actual request did not match the request you told Pact to expect.

tjones
2021-08-09 06:58
To fix it, make the expectation and actual request match

tjones
2021-08-09 06:58
`WebTestClient` in this case is standing in for your actual code that would fire the actual request

sams.prashanth
2021-08-09 07:01
For me, both the output look similar - where I have no clue where the mistake could be

sams.prashanth
2021-08-09 07:34
is there a way to see the pact logs in pact-jvm?

tjones
2021-08-09 07:49
That is the assertion output from the spring framework testing tool

tjones
2021-08-09 07:49
I suspect it's throwing before pact-jvm does

tjones
2021-08-09 07:50
I don't know where pact-jvm usually logs, I'm afraid. Try asking in #pact-jvm, but also try triggering your request without the other testing framework (or try expecting a 500), then you can see what it does

tjones
2021-08-09 07:51
I would expect the pact server to log elsewhere in the test output

anchit.99
2021-08-09 10:08
I recently presented a demo/POC on contract testing to a dev team. To get them to try it out. But they said that their E2E automated tests are part of CI (fully automated) and running the whole E2E tests takes between 1-2 hours. So why should they go for this when they're already covering much more in an hour. I told them that the E2E tests are brittle / harder to maintain. And this gives feedback much earlier. Also that sometimes if some other dependent service's build fails then that'll block their testing. But they were pretty confident that that's very rare. Is there something else that I could tell them to get them to try this out? How about: 1. To think of contract tests like smoke tests (because we're not touching functionality which would be taken care of in their E2E tests). Very few, quick, if they break you very likely have a high severity bug. 2. To think of it like their existing integration tests. But instead of using a mocked object they'll get to use a real object. This is good because it was generated from the other microservice (message queue, hence we're recreating the object in the provider's side). AKA if the other service did some breaking changes they would know instantly.

sams.prashanth
2021-08-09 10:27
found this useful link https://github.com/pact-foundation/pact-jvm/blob/master/consumer/junit/README.md#debugging-pact-failures trying it out; btw this process is very easy in pact-js

matt.fellows
2021-08-09 10:34
1-2 hours alone is enough to deter me from e2e tests

matt.fellows
2021-08-09 10:35
That tells me you're probably not doing continuous deployment, which is ok, but is basically unachievable with that duration

matt.fellows
2021-08-09 10:37
I don't believe the e2e tests aren't costly, so I would dig further into that. Any test suite that takes that long has to cover a lot of ground, I bet if you look at the time spent investing in them you could estimate their true cost

matt.fellows
2021-08-09 10:38
Find the people managing those tests, and do some back of envelope time accounting on how much time they spend writing tests, debugging them etc

matt.fellows
2021-08-09 10:38
Also see how often they succeed

matt.fellows
2021-08-09 10:38
And how many production compatibility issue you find

tjones
2021-08-09 11:18
That looks like the right track. And, thank you!

matt.fellows
2021-08-09 12:38
I wonder if we should create our own HTTP status code, so when people google it, ONLY pact results show up that says ?incorrect request to the mock service? :laughing:

pedroefajardo_pactio
2021-08-09 13:02
Thank you TImothy

abubics
2021-08-09 13:22
Ideally, the contract tests would be able to cover the same footprint as the e2e tests in a much shorter time. But they take time to write. Usually, we treat that as an investment, but some people are hard to convince.

tjones
2021-08-09 13:35
That's actually a really good idea

tjones
2021-08-09 13:35
it should actually be a 4xx

tjones
2021-08-09 13:36
since it's a client error not a server error

tjones
2021-08-09 13:36
That's how 429 got in there

tjones
2021-08-09 13:37
Wait, no, I'm thinking of a different one

tjones
2021-08-09 13:38
No, that's the one. Twitter brought in `420 Enhance Your Calm` to say they were throttling a client, and later on 429 was added

tjones
2021-08-09 13:38
I don't think a pact-specific status code is going to be added in general, though

tjones
2021-08-09 13:40
`466` seems free

tjones
2021-08-09 13:41
If we look at 1XX or 3XX we're less likely to get collisions.

tjones
2021-08-09 13:41
1XX is for informational response, so it might be appropriate

tjones
2021-08-09 13:42
I think 3XX is funny - "we direct you back to your tests"

tjones
2021-08-09 13:42
`333 half a pact`?

tjones
2021-08-09 13:42
Anyway, I really like this idea.

tjones
2021-08-09 13:42
500 has always bothered me. What does the pact server do if it has gone wrong?


elliottmurray
2021-08-09 14:25
One approach scales - the other doesn?t

pedroefajardo_pactio
2021-08-09 21:16
@george.south ^^^

pollet_22
2021-08-09 22:15
Hello all :wave:, i am new in pact and i need to give it a try in testing endpoints between each other i prefer to use it in js , can any one help me :pray:


tjones
2021-08-09 23:14
> When they're already covering much more in an hour Do.. they know that a pact test runtime is best measured in seconds (or a couple of minutes at worst)?

abubics
2021-08-10 01:03
Also, hang out in #pact-js :party_parrot:

xiaoyewang
2021-08-10 01:13
has joined #general

xiaoyewang
2021-08-10 01:15
We?re evaluating to adopt Pact in our team, what is the status of the open source version of Pact? Are there any limitations regarding to features, performance?

bethskurrie
2021-08-10 01:15
Hi Zane. All the Pact clients are open source.

bethskurrie
2021-08-10 01:15
The difference is between the OSS Pact Broker and the commercial Pactflow offering.

matt.fellows
2021-08-10 01:16
What do you mean limitations? Relative to something?

bethskurrie
2021-08-10 01:16
This gives you an idea of the differences https://pactflow.io/features/

xiaoyewang
2021-08-10 01:30
We are currently using Cucumber, the BDD approach to do the API testing. It defines the API specification first and using the specification drives the development and testing. The ?Contract based Testing? concept advocates by Pact can somehow achieve a similar result, but also quite different from what I have learned up to now. I was quite confused by the examples listed in the documentation, https://docs.pact.io/consumer/contract_tests_not_functional_tests/ I understand the side effect of a API shouldn?t be included as the API contract. But what?s wrong with the 3 scenarios listed in the bottom section of this doc, they?re not side effects. In our case, the API user relies on our API to return a specific error code regarding to different input parameters. We need to cover all the scenarios in order to guarantee the API can return the right error code. Is this a wrong use case?

bryanw
2021-08-10 01:37
I came across this in the FAQ: "Pact tests run as part of the "isolated" test phase of an application's automated test suite, during (for the consumer side) or immediately after (for the provider side) the application's unit test suite. They should be able to be run on local developer machines _before_ pushing to a CI system." https://docs.pact.io/faq#is-there-a-jenkins-plugin-for-pact While this is true, my desire for a Jenkins plugin is to address the Pactbroker integration points with the CI.  Publishing and "can-i-deploy" are run as part of the Jenkins CI pipeline which requires specific settings (auth for one) not configured in the pom.xml of the clients.   The pull-request test phase handles the "can-i-deploy" question via the maven plugin. A Jenkins plugin would simplify the setup that I am doing per Jenkins jobs on the consumer vs. provider. Both the consumer and provider tests run in isolation and locally, but we do not check the deployability until we're in the CI system as part of a Pull-Request where I pickup and tag the branch/hash of the commit, etc.  We only publish the pact via the CI. There is a considerable configuration overhead that I believe might be simplified with a Jenkins plugin. Maybe this approach is different than the expected audience for the original question?

matt.fellows
2021-08-10 01:41
> While this is true, my desire for a Jenkins plugin is to address the Pactbroker integration points with the CI. Publishing and ?can-i-deploy? are run as part of the Jenkins CI pipeline which requires specific settings (auth for one) not configured in the pom.xml of the clients.  The pull-request test phase handles the ?can-i-deploy? question via the maven plugin. A Jenkins plugin would simplify the setup that I am doing per Jenkins jobs on the consumer vs. provider. I agree with this, at least, I would support the creation of a Jenkins plugin. > There is a considerable configuration overhead that I believe might be simplified with a Jenkins plugin. Authentication is usually a single token (or user/pass for the OSS version) that is made available to the current build. The CLI calls for the CI process can usually be run via a docker container, which feels similar to what a plugin would do anyway

matt.fellows
2021-08-10 01:42
but I appreciate the ergonomics might be different, I haven?t used Jenkins in a while

bryanw
2021-08-10 01:42
We use the maven plugin, not the docker container/CLI -- the latter is not a viable solution in our config.

bethskurrie
2021-08-10 01:43
Are you aware of the maven thingy for can-i-deploy?

bethskurrie
2021-08-10 01:43
(as you can see, I don't use maven)

bethskurrie
2021-08-10 01:43
task?

bryanw
2021-08-10 01:43
Yes, we use the maven plugin "pact:can-i-deploy"

bethskurrie
2021-08-10 01:44
Excuse my ignorance - what does a plugin give you over that?

bryanw
2021-08-10 01:49
It's all of the configuration details wrapped into a single unit -- I'd prefer to have a plugin where I could enter my details: pacticipant, tag, version, username, password and then it would automatically add the necessary tasks to the pipeline for either side of the pact (consumer vs. provider). I'm not sure what all the plugin could drive in this, I assume it should be able to do all that I'm manually configuring. Right now I'm looking to automate this via scripting to be able to modify a job and add the pact specifics. The issue for me is how to scale this and remove myself from the equation.

bethskurrie
2021-08-10 01:50
are you interested in developing it yourself?

bryanw
2021-08-10 01:51
Ha, that's the natural course, eh? It may come to that eventually and maybe can find some helpers. Short term, I'm going to end up scripting it -- perhaps what can follow is a plugin.

bethskurrie
2021-08-10 01:52
None of the core pact maintainers have the space to pick it up at the moment (and nobody uses jenkins) but we'd be happy to support someone who was interested.

bryanw
2021-08-10 01:55
I think that may be the longer term approach. We're pretty deeply integrated with Jenkins so I would take you up on that offer when the time comes.

xiaoyewang
2021-08-10 02:21
@matt.fellows

matt.fellows
2021-08-10 02:25
The last 3 examples are bad, because they are _testing the provider from the consumer?s_ _perspecttive_

matt.fellows
2021-08-10 02:26
The provider should do that

matt.fellows
2021-08-10 02:26
the consumer shouldn?t have assumptions about the provider?s validation rules.

matt.fellows
2021-08-10 02:27
What if the provider later decides the username can have up to 30 characters? They should have the flexibility to change these rules without breaking tests

matt.fellows
2021-08-10 02:28
In fact, the comentary around those examples is pretty clear to me - what?s not clear about it?

matt.fellows
2021-08-10 03:53
in my experience, if they?re not bothered by 1-2 hours of test time, this argument doesn?t usually help

matt.fellows
2021-08-10 03:54
You need to find a pain point, or more importantly, _who_ is experiencing the pain

matt.fellows
2021-08-10 03:54
if the pain is felt disproportionately by one team, they are your friends

matt.fellows
2021-08-10 03:55
Think of it like DevOps. Before that was a thing, the Ops team disproportionately felt the pain of production bugs/stability issues, because they were the ones with the pagers.

matt.fellows
2021-08-10 03:55
No real motivation for the engineering team to fix that problem, because it didn?t impact them day to day

matt.fellows
2021-08-10 03:56
the challenges and incentives need to be aligned, else there is no reason to change.

matt.fellows
2021-08-10 03:57
in lieu of that, the next best motivators are cost (appeal to Managers) and faster time-to-market (Product)

xiaoyewang
2021-08-10 04:37
In my use case, the consumer relies on the provider able to respond with specific error code. You?re more like talking this from the provider?s perspective. Think about what if the provider changed the API make the username only allow 10 characters, then all the consumers would affected, because they?re still assume?s the rules are 20 characters. It is the API producer that is responsible to the API compatibility.

anchit.99
2021-08-10 05:17
@matt.fellows You're right. They're not doing the CD part. I think they're deploying once in 1 or 2 weeks. But they're trying to bring down that time. Great points about digging into the E2E tests! I will try that out! But about E2E tests, I feel they are unavoidable. It's because contract tests wouldn't cover functionality. So AFAIK we cannot avoid those E2E tests even if they take 1-2 hours. If we want to _"push a subset of E2E scenarios further down the pipeline" -_ which sounds like must add those functionality validations but then we don't test functionality as part of contracts. Perhaps can we say that contract testing can start catching bugs initially and it _might_ lead to lesser and lesser dependency upon the E2E tests? That they have to try it out with a few tests and experience this for themselves? @abubics Can contract tests really cover ground like E2E tests? It shouldn't be the case because we're not checking functionality, isn't it? They might exercise that part of the code but we're not validating the content of the results. We're kinda validating the schema. Also, we're checking 2 services together per contract and stubbing out the rest but in E2E tests they would run through the whole services. Perhaps, I could say that they cover the most important parts of the program quickly? AKA, if this fails you've got a serious bug. @tjones Not yet. But that's a very good point. I will bring it up next time. Thank you for suggesting this!

tjones
2021-08-10 05:20
I want to write more about this in the actual documentation sometime, but although pact tests shouldnt aim to test functionality, I think it?s still good practice to cover some functionality in the tests

tjones
2021-08-10 05:21
Particularly on the provider side

tjones
2021-08-10 05:22
One key advantage of pact tests (and contract tests in general) over e2e is that it is much easier to reason about how much test coverage you have over your API implementation. With e2e, how do you know you?re exercising all the communication scenarios?

anchit.99
2021-08-10 06:01
@tjones I see. So we can add a few very selected functionality tests into the mix. I think that that would increase the value. And I get the point about the test coverage as well because unlike E2E tests that are focusing on scenarios, here we can be sure to have at least one test that covers all fields (as Beth had mentioned in one of her videos). Great points! Thank you!

tjones
2021-08-10 06:11
To be clear, I'm not proposing driving functional tests with pact. But, I am saying that just because we're not driving functional tests with pact doesn't mean you can't have some functionality tested, if that makes sense

tjones
2021-08-10 06:12
for example, we don't test all the "create user" -> "invalid username" scenarios with pact. We test all the kinds of invalid username responses. If there are two different responses for "user already exists" and "username isn't formatted appropriately", then we have a pact test for each of those scenarios

tjones
2021-08-10 06:13
but we don't have pact tests for (say) "your username has spaces and it's not allowed to" and "your username is too long", because that's the same shape of response from the contract perspective (even if the content is different)

tjones
2021-08-10 06:15
Having said that, my view is that if the pact test happens to also exercise the "is this username acceptable" part of the business logic, then you get better risk-reduction from the test. Because you're testing "am I able to generate this type of response" and "does the code actually generate that response in at least one scenario"

tjones
2021-08-10 06:16
The reason we don't drive these functional tests with pact is that the pact belongs to the client. It describes what the client is actually sending and actually expecting. If we were driving provider functionality testing from the pact, then the client would need to know how the provider implementation works.

matt.fellows
2021-08-10 06:38
It?s a grey area

matt.fellows
2021-08-10 06:39
Different error codes is definitely a case for Pact

xiaoyewang
2021-08-10 06:41
Ok, got it. It seems that we can still make this as part of the contract.

xiaoyewang
2021-08-10 06:45
We?re using a self developed message queue, it?s based on Kafaka, but the APIs are totally different. Is that still supported by Pact?


tjones
2021-08-10 06:46
Message pacts are a lot more flexible, but they have the downside that you have to implement the connector into the queue yourself

xiaoyewang
2021-08-10 06:46
Got it. Sounds great!

tjones
2021-08-10 06:47
Looks like we don't actually have an easy general intro to the topic in the documentation. We should add that. This is a good starting point: https://dius.com.au/2017/08/22/contract-testing-serverless-and-asynchronous-applications/

tjones
2021-08-10 06:49
So, an HTTP pact test will receive the request with a real http server, and during provider verification it will send the request using a real http client. So your test coverage includes the library you're using to do HTTP for you. This is really nice because it ensures that you're invoking the library correctly.

tjones
2021-08-10 06:50
Message pacts do not do this. They are more focussed on the content matching, and you have to implement to the mock sender / receiver yourself.

matt.fellows
2021-08-10 06:50
Yeah, the main point is to be aware of the tradeoffs

matt.fellows
2021-08-10 06:51
the more interactions (and specifically, more variations on a contract) that you put into the contract, the tighter the fit. The tighter the fit, the more difficult it will be to evolve API without breaking a Pact test. You need to find a balance that works

matt.fellows
2021-08-10 06:52
There is this @tjones https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact But appreciate we could do with more on that

tjones
2021-08-10 06:52
In the pact-js message examples, we usually abstract the send/receive library completely so you don't get the assurance that you're invoking your message libraries correctly. This is not as good as having a proper sender and receiver and spinning up your queues, but it's substantially less implementation effort

tjones
2021-08-10 06:53
for the v4 version of the pact specification, we're looking at bringing in a plugin framework which would enable better mock queues etc across all pact languages.

matt.fellows
2021-08-10 06:53
:point_up:

tjones
2021-08-10 06:55
Ah! Nice, thanks Matt. Maybe we should pull that out- "How Pact works: HTTP contracts" and "How Pact works: Message Queues / Async contracts"

matt.fellows
2021-08-10 06:55
probably not a bad idea, so it?s visibile in the menu

matt.fellows
2021-08-10 06:56
(they are curretnly the two main subsections of that page)

xiaoyewang
2021-08-10 06:56
yeah, the concern for me is whether implementing such sender receiver logic is too much effort for the team, and whether this is really necessary. we haven?t got any issues with the messaging middleware so far in our project. but i?ll give a try first.

tjones
2021-08-10 06:56
(While we're talking about that, the FAQ is now very large, and we could split a lot of that out) Of course, if you have your own custom queue API, then even if we have the plugin framework, you may want your own plugin.

tjones
2021-08-10 06:57
Personally, the errors I have seen in messaging frameworks tend to be content-related rather than framework-use-related, so completely ignoring the framework use during testing has been fine.

tjones
2021-08-10 06:57
(even if I was pretty uncomfortable doing that at first)

tjones
2021-08-10 06:58
You (may) have a fun new concern which is that if your messages live for a while or can be replayed, then your consumer contract has to be with all versions of the provider.

tjones
2021-08-10 07:00
> and whether this is really necessary. I would start without the sender/receiver logic and see if doing content-only gives you the primary benefits you need from pact. My personal experience is it will.

xiaoyewang
2021-08-10 07:00
Sure, i?ll try it.

anchit.99
2021-08-10 07:19
@tjones Yep. I am getting what you mean. Basically we're making a choice on whether we really want to add some particular functionality test and not blindly adding them. I think there was an article somewhere in Pact's docs that mentioned that functionality is to be tested by the provider's own tests and Pact doesn't recommend to add it. But I get that this isn't a hard defined rule and if we really wanted to we could add very very selectively. Thanks for putting the effort to explain further!

varnit.garg2424
2021-08-10 08:28
Hey, we are using kafka queue system between producer and consumer. Been using pact4s and we are done with the test on consumer side by mocking the data. *And running the test successfully generates the pact contract file.* However, now we are totally confused how to mock the data on producer side. Since in case of messaging queue, there is no trigger point. *Can you please advice how should we verify the contract on the provider side?* 1. Should we create a wrapper against the "message generator" object? 2. Do we need a separate mock server on provider side? If yes, then what should it point to?

qingyuliu
2021-08-10 09:27
has joined #general

matt.fellows
2021-08-10 09:32
@varnit.garg2424 see some links in this thread for references

matt.fellows
2021-08-10 09:32
See one thread up for a related discussion :rolling_on_the_floor_laughing:

matt.fellows
2021-08-10 09:32
But closer to (1)

dawoud.sheraz
2021-08-10 09:38
A general question about pact provider verification. Suppose there is a provider with a lot of consumers. Inside the provider, multiple small applications are configured and each consumer is using part/whole of some of the applications of the provider. When running provider verification for such a scenario, should the verification and state setup urls be distributed within each app i.e. if provider A has apps A1, A2, A3, A1 will have only A1 verification related code in it, A2 will contain A2 only and so on?

tjones
2021-08-10 10:58
I think I'm not clear on your setup. Do you have multiple providers too?

tjones
2021-08-10 10:58
I'm not sure what an app is in this context

tjones
2021-08-10 10:59
in general, if you have a lot of consumers, and some of them need similar states, it might be helpful to publish a list of states (or a schema if the states are complex)

tjones
2021-08-10 10:59
For the provider there is only one state setup URL, though.

dawoud.sheraz
2021-08-10 11:00
The architecture of the main application is monolith. It has many plugged-in applications in it. When thinking in terms of provider-consumer context, the plugged-in apps are acting as provider for certain consumers. But all the plugged-in apps are accessible only via monolith?s exposed interfaces.

dhairyapatel071996
2021-08-10 20:06
has joined #general

beem132
2021-08-10 21:21
has joined #general

rfang
2021-08-11 00:49
has joined #general

abubics
2021-08-11 03:22
> @abubics Can contract tests really cover ground like E2E tests? It shouldn't be the case because we're not checking functionality, isn't it? They might exercise that part of the code but we're not validating the content of the results. We're kinda validating the schema. Also, we're checking 2 services together per contract and stubbing out the rest but in E2E tests they would run through the whole services. Perhaps, I could say that they cover the most important parts of the program quickly? AKA, if this fails you've got a serious bug. Mostly covered already (thanks @tjones!), but I'll add a little still . . . > We're kinda validating the schema. Contract tests give us more reasoning power than just a schema, because they encapsulate significant states as well. See https://pactflow.io/blog/schemas-are-not-contracts/ > in E2E tests they would run through the whole services It's still a good idea to run some small amount of integrated tests, to ensure your deployed things can contact each other (i.e. smoke tests post-deploy, pre-traffic). But the contract tests (integrat_ion_, not integrat_ed_) should give you the confidence that specific versions can & do agree on how to communicate. Putting all of this together should move your testing profile towards something that better matches an ideal test pyramid: ? more fast & specific automated tests (unit, contract, etc) ? less slow & broad (& flaky?) automated tests (integrated) ? a small amount of pre-traffic automated sanity (smoke) ? manual tests for exploration Appendix: I really like this list of concerns, the following list of example combinations, and rationales - https://medium.com/@kentbeck_7670/test-desiderata-94150638a4b3

abubics
2021-08-11 03:24
Can the applications be run standalone? (also, do their builds run separately?)

abubics
2021-08-11 03:25
It's often nice to split contracts up by domain context boundaries, rather than deploy topology. Without knowing much more, that's my best hint.

matt.fellows
2021-08-11 03:26
Best part of that post: > I went and re-read https://amzn.to/31u6gE2 and these properties are nowhere to be found, so I guess I shouldn?t have been surprised. Goes back and reads his own book ?shit, I didn?t say the key thing I meant to say!?

tjones
2021-08-11 04:48
Hmm. This feels analogous to clients using subsets of an API, for example you might have two consumers "user frontend" and "admin frontend". Maybe both use the `/oauth/*` endpoints, but then diverge in the other endpoints they use. In that scenario I would have one provider with two (largely) disjoint contracts. Disjoint contracts is fine.

tjones
2021-08-11 04:48
A contract doesn't cover the whole API surface. It only covers the parts of the API that are used by the consumer.

subhashnarla
2021-08-11 07:29
has joined #general

abubics
2021-08-11 08:21
Also true. It depends how the "plugged-in apps" are separated in functionality and/or context. (It could legitimately be one bounded context, with different consumer footprints, but I can't tell from this level of info)

jkdihenkar
2021-08-11 10:43
has joined #general

christian.kampka
2021-08-11 10:51
has joined #general

ashwinparthasarathy30
2021-08-11 11:23
has joined #general

andrew.jensen
2021-08-11 16:18
has joined #general

pedroefajardo_pactio
2021-08-11 16:20
@andrew.jensen ^^^

dawoud.sheraz
2021-08-11 17:42
the applications don?t run standalone. The entry point for the consumers to the underlying apps is via monolith?s exposed interfaces.

dawoud.sheraz
2021-08-11 17:45
To summarize or better put my question: How do we manage the provider verification for sub-apps/plugins in a monolith application where the interfaces of sub-apps are exposed by monolith?

tjones
2021-08-11 22:47
In pact, treat the deployable as the ?pacticipant?. So, in your case I think the monolith is the provider

tjones
2021-08-11 22:49
If the problem is due to config (eg, you don?t know from the monolith version alone what surface it is exposing) have a look at the feature flag guidelines. I think something was published on that recently


vivekkurhe1993
2021-08-12 03:44
has joined #general

matt.fellows
2021-08-12 04:46
Meetup on tonight: https://www.meetup.com/en-AU/Melbourne-CocoaHeads/events/279272441/ @marko.justinek will be talking about consumer driven contract testing with Pact for mobile (iOS)

dawoud.sheraz
2021-08-12 05:10
right, thanks.

dawoud.sheraz
2021-08-12 05:12
Bringing up this conversation, the provider api being consumed has a lot of fields(20 mininum). The values for each field can vary depending upon the state/configuration, affecting the way consumer works. How detailed can we go in such scenarios, in general, when writing consumer tests so that the tests don?t venture into functionality testing? Can we expect a large number of interactions to be recorded for that single api? https://docs.pact.io/consumer/contract_tests_not_functional_tests

aakbar
2021-08-12 06:05
has joined #general

tm.buga
2021-08-12 08:55
has joined #general

yanivhad
2021-08-12 08:58
has joined #general

francois.fernandes
2021-08-12 11:55
has joined #general

xiaoyewang
2021-08-13 02:57
I have an API to create a resource, but same resource can?t be recreated, it?ll throw an error. In the provider verification test, I somehow need a way to check whether this resource has been existing, if it is, I need to delete it, in order to make this pass. Is this a correct way to do this?

bethskurrie
2021-08-13 02:57
@xiaoyewang no, you use provider states to put the application into a known state


bethskurrie
2021-08-13 02:58
you should not ever have anything unknown in the server. the state should be cleaned up entirely between each request that gets verified.

xiaoyewang
2021-08-13 03:06
> Provider states allow you to set up data on the provider by injecting it straight into the data source before the interaction is run sounds like I still need to check the data source whether this resource has been there, if it is, then delete it, but only doing so via the provider state. right?

bethskurrie
2021-08-13 03:13
It's better practice to have a "clean all" function that cleans everything each time.

bethskurrie
2021-08-13 03:13
if you only clean up things that expect to be there, then it's very easy to miss cleaning up things as time goes on and more resources are added.

bethskurrie
2021-08-13 03:14
always run the "clean everything" function at thes tart of the provider state setup

xiaoyewang
2021-08-13 03:14
yeah, but sometimes, the resource is there, not produced by my test. someone else may have created it before I run my test.

bethskurrie
2021-08-13 03:14
so, yes, you could do a "if this thing exists, then delete it" check - just makes sure you do that for everything.

bethskurrie
2021-08-13 03:14
> someone else may have created it before I run my test.

bethskurrie
2021-08-13 03:15
where are you expecting to run this test?

bethskurrie
2021-08-13 03:15
pact verifications are typically done on a local instance, in CI or on a dev machine.

bethskurrie
2021-08-13 03:15
stubbing out any calls to things outside of the provider.

xiaoyewang
2021-08-13 03:15
yeah, I run on local instance, in CI or on a dev machine.

bethskurrie
2021-08-13 03:15
who is the "someone else" that could create the data on your local machine?

xiaoyewang
2021-08-13 03:16
the resource can be created using API directly, not only through test cases.

xiaoyewang
2021-08-13 03:17
or what if the test cases throw exceptions before running to the clean all steps

bethskurrie
2021-08-13 03:18
that's why you always clean before a test, not after

bethskurrie
2021-08-13 03:18
because you don't know what state a previous test let the data in

xiaoyewang
2021-08-13 03:19
yeah


tjones
2021-08-13 10:03
A good guideline is "what are the different kinds of responses your consumer needs to understand"

tjones
2021-08-13 10:04
the boundary between the consumer and the provider is what is under test

dawoud.sheraz
2021-08-13 10:06
Hmmm, so ideally, the rule of thumb would be that if a field/data (or its particular value) is not included in contract, how will consumer behave if it gets an unexpected piece of data?

tjones
2021-08-13 13:37
Contract testing is about confirming that two services can communicate with each other, without needing to do complex and expensive integration tests

tjones
2021-08-13 13:38
it's not really for testing how the consumer behaves if the provider is misbehaving

tjones
2021-08-13 13:38
however, contract testing can detect that the provider is misbehaving, and prevent the deployment of the broken provider.

tjones
2021-08-13 13:39
See the comments here about Postel's law: https://docs.pact.io/getting_started/matching/gotchas/

tjones
2021-08-13 13:40
if your consumer will behave poorly if fields that it doesn't understand are present in the response, then Pact might not be for you.

tjones
2021-08-13 13:41
(although I'm not sure what tool _does_ cover that case)

tjones
2021-08-13 13:43
Another way of answering your original question about testing with a combinatorial explosion of scenarios - you can think of pact as a unit test where the "unit" is the communication code of the consumer and provider together. How would you test that scenario with unit tests?

tjones
2021-08-13 13:44
There are several possible answers, and no single one is "correct", but thinking about it that way might be helpful to you and your team.

dawoud.sheraz
2021-08-13 13:45
(ok, this has increased my confusion) The confusion is that if contract tests don?t help in locating the integration issues, what advantages will it have in replacing complex e2e and integration tests. Isn?t contract testing also ensuring that two services are compatible with each other?

dawoud.sheraz
2021-08-13 13:49
```When writing a test for an interaction, ask yourself what you are trying to cover. Contracts should be about catching: bugs in the consumer misunderstanding from the consumer about end-points or payload breaking changes by the provider on end-points or payload``` (https://docs.pact.io/consumer/contract_tests_not_functional_tests/) How can we locate misunderstanding/breaking changes if we don?t add proper fields(and their possible set of values via matcher) when writing interaction?

tjones
2021-08-13 14:02
I don't think I understand the question, sorry.

tjones
2021-08-13 14:02
You have to add the fields that the consumer needs

tjones
2021-08-13 14:03
I thought you were asking about negative testing, as in how to find out whether the consumer can handle unexpected or corrupt responses

tjones
2021-08-13 14:04
pact isn't really for that. It's for testing whether two systems *can* communicate

dawoud.sheraz
2021-08-13 14:04
Yes, we add the fields that consumer needs. But if the field can have multiple values, ideally, we would have one interaction but use matchers for that field.

tjones
2021-08-13 14:04
Possibly

tjones
2021-08-13 14:04
you might also have multiple interactions

tjones
2021-08-13 14:04
it depends.

tjones
2021-08-13 14:04
Is there an important difference on the consumer side?

tjones
2021-08-13 14:05
for example, does a different value get marshalled into a totally different business object on the client?

tjones
2021-08-13 14:05
if yes, then it's two interactions

tjones
2021-08-13 14:05
If writing a test for `"name": "john smith"`, you probably don't need one for `"name": "jane doe"`

dawoud.sheraz
2021-08-13 14:06
Yes, the behavior can change depending upon the value of field.(e.g. one field is `expiration_date` , which can alter the behavior for a user if attempting an action after expiration date)

tjones
2021-08-13 14:06
A good practice is one interaction per type of request/response

tjones
2021-08-13 14:07
what is under test in pact is the communication boundary

tjones
2021-08-13 14:07
if that behaviour is part of the communication boundary, write an interaction for it

tjones
2021-08-13 14:07
if it isn't, then you'll have a better time if you leave it out

tjones
2021-08-13 14:07
the consumer doesn't know how the provider is implemented or behaves, so it's not a good place for behaviour tests for the provider

tjones
2021-08-13 14:08
for example, consider username validation

tjones
2021-08-13 14:08
a create user request for `"Steve Jenkins"` might return `400` because there's a space in it and you're not allowed spaces

tjones
2021-08-13 14:09
Maybe the payload looks like: ```{ code: "invalidusername", message: "Your username cannot contain spaces" }```

tjones
2021-08-13 14:11
maybe there are other reasons, like say I can't have special characters: ```{ code: "invalidusername", message: "Your username has a '#' in it and that's not allowed" }```

tjones
2021-08-13 14:11
From pact's perspective, these are both probably one interaction - the consumer (probably) turns them both into the same business object. It doesn't care what the message is.

tjones
2021-08-13 14:12
But, maybe there's a different response for "that username is already taken", which returns 409 conflict, and: ```{ code: "usernameunavailable", message: "That username is already taken" }```

tjones
2021-08-13 14:13
whether this is a different interaction from the client's perspective depends.

tjones
2021-08-13 14:13
Does it marshal it to a different object for a different purpose? Or, are all errors handled the same

tjones
2021-08-13 14:14
In this example, the client might not care about the difference

tjones
2021-08-13 14:15
it knows that there are some reasons that usernames might not be accepted, and it knows the server will tell it a message to display

tjones
2021-08-13 14:15
you'll have a better time if the tests for all the different reasons are done on the provider side, not baked into the pact

tjones
2021-08-13 14:16
but, maybe the client *does* care. Maybe it does something different with the confict response, eg it needs that to know that it should show some username suggestions.

tjones
2021-08-13 14:16
In that case, you would use different interactions

tjones
2021-08-13 14:17
A pact is written on the client side, because you're saying "these are the kinds of requests I will send, and the kinds of responses I want to receive"

tjones
2021-08-13 14:17
you're not saying "hey, here are all the scenarios that I know usernames are invalid"

tjones
2021-08-13 14:17
because, ideally, the client doesn't know.

tjones
2021-08-13 14:18
(In part because it's good to keep tests close to the code they're testing)

dawoud.sheraz
2021-08-13 14:18
Thanks for the in-depth explanation. Your point `you'll have a better time if the tests for all the different reasons are done on the provider side` is exactly the reason I posted the question. When writing the code, it felt like the validation was being done in consumer side too. Defining the boundary between contract and functional tests was getting fuzzy.

tjones
2021-08-13 14:18
Yes, that's fair

tjones
2021-08-13 14:19
My view is that it's good to have some functional coverage

tjones
2021-08-13 14:19
(accidental functional coverage)

tjones
2021-08-13 14:19
but not to try to drive the functional tests from the pact

tjones
2021-08-13 14:19
As in, don't go out of your way to avoid testing functionality

tjones
2021-08-13 14:20
your expiry example is a good one

dawoud.sheraz
2021-08-13 14:21
Right, thanks again for helping me clear the context.

tjones
2021-08-13 14:21
there's probably: A request with a valid `expiry_date` -> some type of success A request with an invalid `expiry_date` -> some type of failure

tjones
2021-08-13 14:22
Does this test functionality? Maybe it happens to do that. But the reason the test is there is because the client says: I will send these requests, I need the server to understand I need the server to be able to tell me it failed (possibly including why) I need the server to be able to tell me it succeeded (possibly with more info)

tjones
2021-08-13 14:23
You're welcome! Hopefully I've explained things well enough, please do ask more questions if it's not clear (or it becomes less clear later)

tjones
2021-08-13 14:24
Also, remember there are no contract testing police. If you do drive functional tests with Pact, you won't be in trouble.

tjones
2021-08-13 14:24
We just think it'll make your testing life more difficult.

dawoud.sheraz
2021-08-13 14:54
Haha, yeah. Right again.

johnathan.gilday
2021-08-13 16:40
has joined #general

ben.kaiser
2021-08-13 17:47
has joined #general

dbekman
2021-08-13 20:51
has joined #general

danieljak
2021-08-15 07:52
anyone? :disappointed_relieved:

marko.justinek
2021-08-15 08:18
Hey Daniel. I suppose you didn?t get a response since nobody really is in a similar situation. I would also assume that if it?s a monorepo you might have the complete control over the consumer and provider side and if others are in similar situation, there might not be such a need for Pact (or CDC). Pact really shines when teams working on different systems communicate and work together, but are still not part of the same team/repo.

danieljak
2021-08-15 08:56
Well I'm not sure that it makes sense to me because at my company we have 6 teams working in the same repo and each has their own services. And if you think of places like google/facebook they are also using monorepos and have hundreds of teams, and I think CDC is relevant in these places. Am I missing something? :flushed:

matt.fellows
2021-08-15 09:28
There's been a few threads about this before.


matt.fellows
2021-08-15 09:30
There's no reason you can't do CDC tho if conceptually there are different logical unit managed by separate teams

matt.fellows
2021-08-15 09:31
The repo is now essentially a subfolder in this model

chen
2021-08-15 09:34
has joined #general

dawoud.sheraz
2021-08-16 04:42
Hi. Is there any capability with pact where it is possible to call some function after an interaction? It will be opposite to how the provider states are setup before interaction and can help perform data cleanup so that next interactions can be perform in perfect isolation.

tjones
2021-08-16 04:43
Yes, you have a couple of options. Which language are you using?

dawoud.sheraz
2021-08-16 04:43
python.

tjones
2021-08-16 04:43
In a pinch, you can do your cleanup at the start of each of your state hooks. In pact-js we have an afterEach hook

tjones
2021-08-16 04:43
For python...

dawoud.sheraz
2021-08-16 04:44
We are doing exactly like that, cleaning DB before each interaction. However, this makes it difficult to manage because all the interaction?s cleanup is happening in one place.

tjones
2021-08-16 04:45
Right. For pact-python I'm not sure. In pact spec v3 there are explict setup and teardown hooks for each state

tjones
2021-08-16 04:46
but I think the v3 spec isn't released for python yet. I don't use it myself - you might want to ask in #pact-python

dawoud.sheraz
2021-08-16 04:47
Yes, I haven?t been able to find any related link/ref in pact-python repo. I will post this thread, in case someone else has done something similar in the past.

bethskurrie
2021-08-16 04:54
@dawoud.sheraz what's the issue with "all the clean up being in one place"?

bethskurrie
2021-08-16 04:54
It's much more reliable to clean before than after. You never can tell how the previous test ended.

bethskurrie
2021-08-16 04:55
And when you clean after, you tend to just clean up things you know got created in that test, which can lead to data leaks over time as you add new things in that forget to get cleaned up.

dawoud.sheraz
2021-08-16 04:55
Since each interaction requires different set of data in state setup, ideally, we would want to clean only that data after the interaction. Not all the data in the database(chance to deleting some configuration)

dawoud.sheraz
2021-08-16 04:56
> And when you clean after, you tend to just clean up things you know got created in that test, which can lead to data leaks over time as you add new things in that forget to get cleaned up. So the best way is to cleanup the entire data(configurations excluding) before each interaction?

bethskurrie
2021-08-16 04:56
Yes

bethskurrie
2021-08-16 04:57
I have a function that understands the dependencies between the tables, and iterates over them, truncating all the data in each table

dawoud.sheraz
2021-08-16 04:59
Oh, ok. What I am doing is removing the specific data created in the provider state. But this is being done explicitly. I was hoping there might be way to call that clean-up implicitly. But if the cleanup before interaction is the right idea, the implicit/explicit fight might not be valid much.

bethskurrie
2021-08-16 05:01
If you're testing with a real http server and request, there's no way to auto roll back, as the transaction has to be committed.

dawoud.sheraz
2021-08-16 05:08
Yes, we are doing with real server with test configuration(Django).

dawoud.sheraz
2021-08-16 05:09
Isn?t testing with real server the recommended way?

matt.fellows
2021-08-16 05:57
> In pact spec v3 there are explict setup and teardown hooks for each state This is something not documented in the spec. IMO it?s a missing ?gap? in feature support

matt.fellows
2021-08-16 05:57
it?s one of the reasons I was encouraging a BDD feature spec that each language could implement


danieljak
2021-08-16 08:35
cool sounds good :slightly_smiling_face:

dawoud.sheraz
2021-08-16 10:42
Hello. In terms of authentication in provider verification, how do provider states can help(https://docs.pact.io/provider/handling_auth/#3-set-up-users-with-matching-credentials-using-provider-states)? Only the user creation/permission setup is possible in provider states. How can we add the user in the request itself? Furthermore, if the interactions require different type of users across one pact, how can we cater for such a scenario? Right now, we are using middleware to add user information in the request. But we have less control over the middleware as it intercepts all the requests.


matt.fellows
2021-08-16 10:51
See also the AMAs on this topic

dawoud.sheraz
2021-08-16 10:52
I added ref from the link you provided :slightly_smiling_face:

vuttithatkrongyot
2021-08-16 11:28
Hi team, I would like to ask about matchingRules for pact spec3. I try to write it from scratch and I'm stuck with writing matchingRules for the body like this. The goal is I want to have matchingRules only for the field "id". But I have no idea when the body return as array ;( `"body": [`           `{`             `"id": 1,`             `"title": "New todo 1",`             `"done": false`           `},`           `{`             `"id": 2,`             `"title": "New todo 2",`             `"done": false`           `}`         `],` I tried so many way like this but it not worked. Could you please guide me about this? `"matchingRules": {`           `"body": {`             `"$.[*].id": {`               `"matchers": [`                 `{`                   `"match": "type"`                 `}`               `]`             `}`           `}`         `}`

tjones
2021-08-16 11:31
What are you trying to do? You're not really meant to write a pact file from scratch, since it represents what the consumer is tested to be able to send

tjones
2021-08-16 11:34
It's also considerably easier to write pact files through the DSL

vuttithatkrongyot
2021-08-16 11:34
I try to not using the contract generator from consumer code (some kind of bi-directional contract testing) by writing json contract.

tjones
2021-08-16 11:37
I don't think it will be bidirectional if you are not generating the contract from consumer code

tjones
2021-08-16 11:37
What are you trying to achieve? Pact may not be the right tool for this.

tjones
2021-08-16 11:38
Advantages of the DSL are it's much easier to express the different matcher constraints on your payload, and the Pact file is only written once you have shown that your consumer can send the requests you are expecting it to send

tjones
2021-08-16 11:39
If you do it manually, you'll lose this advantage, and you will find it much more difficult

vuttithatkrongyot
2021-08-16 11:39
I need to achieve contract-driven not consumer-driven because I don't want to have a bottleneck on consumer side.

tjones
2021-08-16 11:39
I don't think Pact is the right tool for that

tjones
2021-08-16 11:39
how are you going to ensure that your consumer implements the contract?

tjones
2021-08-16 11:53
Anyway, I?m afraid I don?t actually know the answer to your question. If you want to know, I would set up one of the DSLs to do it, hit the mock server with something like supertest, and then see what it outputs.

matt.fellows
2021-08-16 12:16
When you say ?bi-directional? do you mean https://docs.pactflow.io/docs/workshops/bi-directional?


tom.willmott
2021-08-16 13:47
has joined #general

dawoud.sheraz
2021-08-16 15:53
To add some more context to the question, the user making the request can have different roles(manager, client etc.) Based upon the user role, the response content can change. Now, in the contract, there are two interactions, one expects request.user to be manager and the other client. With requestFilter(is there an equivalent in pact-python?) approach, we would need special checks based on request contents to add appropriate user to the request.

franklin.lucena89
2021-08-16 16:52
has joined #general

matt.fellows
2021-08-16 22:44
sorry, you did

matt.fellows
2021-08-16 22:45
the provider state would have the context of the authentication - e.g. ?given a call to X with a valid manager? should setup the authentication state for a manager etc.

matt.fellows
2021-08-16 22:46
request filter does not exist in Python, but the infrastructure has recently been added to support messaging, which should make implementing that much easier

matt.fellows
2021-08-16 22:46
I?d suggest a feature request and/or PR to pact-python

dawoud.sheraz
2021-08-17 04:43
right, thanks.

ram.tripathi
2021-08-17 06:33
has joined #general

ricardo.neto
2021-08-17 09:22
has joined #general

andrew.patterson
2021-08-17 14:55
has joined #general

pshah
2021-08-17 15:31
has joined #general

dylanchase26
2021-08-18 04:11
has joined #general

satish.chandra
2021-08-18 05:54
has joined #general

sethimudit2002
2021-08-18 14:36
Hello. We are investigating to use pact tests for inter services messaging and have a spike setup between a consumer and provider with pact broker with webhooks setup for provider. There are situations where we would like to have consumer deployed till prod with new message subscription which is still not done from the provider. We tried pending pacts thinking that should solve it but that helps only provider builds to not fail. Is there a way to let consumer deploy to prod in this case? We have the can-i-deploy on consumer build which fails even though the verification is ?success? meaning it skips the pending pact that is not implemented as yet. P.S. - Consumer and provider are done by same team in this case. We use tags for our main branch and also for our environments. And prefer working on main branch and not feature branches

tjones
2021-08-18 15:03
Ah, this is an interesting edge case. Let me rephrase to see if I have understood: you have a message consumer with no provider (yet), but it?s safe to deploy the message consumer, because it?s not broken- it just won?t receive any messages?

tjones
2021-08-18 15:06
I think it?s hard to tell what the ?right? behaviour for pact should be- I suppose it depends on whether the consumer requires the provider?s messages in order to work, or whether the messages are optional. My gut feel is it sounds like we need a mechanism for this case- maybe a pending pact should allow a message consumer to deploy?

tjones
2021-08-18 15:07
Pragmatically you could just not include the message provider in the can-i-deploy check

sethimudit2002
2021-08-18 15:18
You got it right in understanding. Yes I was hoping pending pact should do it but it only helps the provider and not the consumer which we want in this case. Last resort would be to not have can-i-deploy check but if in someway we can avoid it would be nice. But thanks for the help. I guess an additional configuration that could be set somewhere would be helpful.

poorvasgokhale
2021-08-18 16:26
In this case maybe then Can-i-deploy step can be made optional depending on some flag in consumer pipeline. (Thinking out loud here)

david.vancouvering
2021-08-18 16:50
So let's say our business logic calls another service, rather than calls a database storage layer. Is the best practice to stub the business logic or mock the service? It sounds like, in the spirit of risk reduction, it's preferable to mock the service?

sethimudit2002
2021-08-18 16:55
Yes that is the only thing we could think of for now. @poorvasgokhale thanks

david.vancouvering
2021-08-18 17:44
Hey, all. Great conversations on this channel! It really helped me gel the important distinction between contract tests and integration/functional tests. A QA engineer I have been working with presented me with a scenario where I couldn't tell if this belonged in a contract test and, if not, how you would test it. Let's say an API contract indicates that you are returned a list of widgets. Some are standard and some are specialized. You only get the specialized widgets if you're in the UK. Note that you may or may not get specialized widgets if you are in the UK - you won't get any if there are none currently available. Also, you don't know from the result whether a widget is specialized or not, it just shows up or it doesn't. I suppose you could create a provider state "specialized widget exists" and then run the contract test to make sure it comes back. But I guess my question is - is that part of the contract or is that a functional test? Is the contract "X comes back under Y condition" or is it just "the result set needs to look like this format"?

david.vancouvering
2021-08-18 17:45
Note that the logic to determine if a specialized widget comes back is part of the business logic of the provider, and I've seen mixed messages on whether we should be testing that kind of logic in contract tests...

dimundo
2021-08-18 18:07
its a func test - `if (something) {return another_something}`

david.vancouvering
2021-08-18 18:08
Yea, ok, interesting.

dimundo
2021-08-18 18:08
pact tests would be `UK_something has such format` and `Non_UK_something has such format`

david.vancouvering
2021-08-18 18:09
OK, so you are saying it's the form and shape of the response that is part of the contract, and does the consumer handle that correctly. The fact that A comes back instead of B doesn't matter, if A and B both follow the same format.

david.vancouvering
2021-08-18 18:11
TBH I am quite concerned our engineers, many of whom are junior, are not going to get this subtle distinction. We are going to need to work hard to communicate this clearly, otherwise all sorts of antipatterns will evolve.

dimundo
2021-08-18 18:11
> and does the consumer handle that correctly no, there is no `if` as consumer handles those 2 and made pact for provider to provide such A and B

david.vancouvering
2021-08-18 18:12
sorry, Dmitry, I didn't understand that last part

david.vancouvering
2021-08-18 18:12
But I think your point is, we test format, not logic, in contract tests, is that right?

dimundo
2021-08-18 18:12
> form and shape of the response that is part of the contract, and does the consumer handle that correctly. `does` sounds like a question

david.vancouvering
2021-08-18 18:13
ah ok

kyle.florence
2021-08-18 18:15
@david.vancouvering in case you haven?t read it yet https://docs.pact.io/consumer/contract_tests_not_functional_tests/

david.vancouvering
2021-08-18 18:15
Yes, I've read it but this part was unclear to me. I'll go read it again :slightly_smiling_face:


kyle.florence
2021-08-18 18:17
this is one place where there will be a very small gray area. when i question if something makes sense in a pact test, i?m generally inclined to say ?no? instead of ?yes? and try to cover it somewhere else

dimundo
2021-08-18 18:17
its quite tricky to stop at proper stage to not start doing func tests with pact :smile:

kyle.florence
2021-08-18 18:18
and you are correct David that it is very easy for someone who does not do this questioning to end up with functional pact tests :stuck_out_tongue:

kyle.florence
2021-08-18 18:18
hopefully it will be caught in review

david.vancouvering
2021-08-18 18:22
Thanks all. "Hopefully it will be caught in review" - haha that has an ominous echo to it... :lightning:

david.vancouvering
2021-08-18 18:23
Very interesting SO on your other thread Dmitry. I feel like I have moved from the simplicity of standard physics to the murky world of quantum physics. :disappointed:

dimundo
2021-08-18 18:25
just ask yourself more often - does it really must be tested with contract ?

david.vancouvering
2021-08-18 18:26
So you're saying one should lean towards having fewer contract tests rather than more - one should have a high bar rather than a low bar when adding a contract test

david.vancouvering
2021-08-18 18:27
Doesn't that risk regressions?

dimundo
2021-08-18 18:27
one must build proper testing pyramid

dimundo
2021-08-18 18:27
and test proper things on proper stages

david.vancouvering
2021-08-18 18:28
And I think we're saying functional tests are cheaper/faster than contract tests

kyle.florence
2021-08-18 18:28
yeah, i think these are the same questions you ask with any test you write. ?is this a unit test or an integration test?? ?is this an integration test or a functional test??

kyle.florence
2021-08-18 18:28
functional tests in general are the most expensive/slow tests

kyle.florence
2021-08-18 18:28
but pact is a tool with a specific purpose

david.vancouvering
2021-08-18 18:29
OK terminology: functional test in my mind is testing a component in isolation, like a service or a library. To me those are cheaper than contract tests.

david.vancouvering
2021-08-18 18:30
Whereas e2e test in a staging environment is the most expensive type of test. This is what the team I am working with tends to default towards

dimundo
2021-08-18 18:30
old good pic

david.vancouvering
2021-08-18 18:30
lol

dimundo
2021-08-18 18:30
no ice-cream, please :)

david.vancouvering
2021-08-18 18:31
I would split integration tests into "functional tests" which test a component in isolation and "integration tests" which test a bunch of components, like services, in a shared environment.

kyle.florence
2021-08-18 18:31
functional testing usually means ?testing from outside of the software? (e.g. black box testing)

david.vancouvering
2021-08-18 18:31
I see

kyle.florence
2021-08-18 18:32
we usually use them for things like flows (e.g. selenium functional tests)

kyle.florence
2021-08-18 18:32
i think an e2e test is a type of functional test

kyle.florence
2021-08-18 18:33
and yes e2e tests are the worst :smile:

dimundo
2021-08-18 18:33
and easy to create :smile:

kyle.florence
2021-08-18 18:33
easy to create, a pain to maintain

david.vancouvering
2021-08-18 18:33
Here's the strategy I'm leaning towards in terms of a pyramid: ? Unit tests ? Component tests (e.g. test service with fake/stub/mocked dependencies) ? Contract tests ? Integration tests (in shared environment like staging) So I would prefer to test in a component test over a contract test

dimundo
2021-08-18 18:33
> easy to create, a pain to maintain `we have qa for that, no?`

kyle.florence
2021-08-18 18:34
we don?t like to throw things over the wall to QA at my company :heart:

dimundo
2021-08-18 18:34
( i am a qa :wink: )

kyle.florence
2021-08-18 18:34
i know

kyle.florence
2021-08-18 18:34
:smile:

kyle.florence
2021-08-18 18:35
@david.vancouvering that looks mostly correct to me, although the way we do integration testing it is inside of the application, we don?t need an environment for it

kyle.florence
2021-08-18 18:35
i guess it?s similar to ?component tests? in your model

david.vancouvering
2021-08-18 18:36
ok cool

david.vancouvering
2021-08-18 18:36
At my company the history has been integration tests for pretty much everything, with a separate QE team writing and running these and managing deploys. We are working on slowly shifting the culture to QE being an enabling team that provides tools and best practices, and software devs writing all the tests and being responsible for deploys. Some QE folks may shift to become software devs, and some may choose to be part of the team that provides tools and best practices.

kyle.florence
2021-08-18 18:36
we have unit tests, openapi specification tests, pact tests, integration tests all as pre-deployment automation, and then post-deployment we run functional regression tests

david.vancouvering
2021-08-18 18:37
makes sense

david.vancouvering
2021-08-18 18:38
curious about your openapi spec tests, do you use a tool for that?

kyle.florence
2021-08-18 18:38
yeah, unfortunately we had to write one ourselves. i want to open source it but haven?t had time yet

david.vancouvering
2021-08-18 18:39
OK :eyes:

kyle.florence
2021-08-18 18:39
although this tool does something similar and is worth looking into https://useoptic.com/

kyle.florence
2021-08-18 18:39
eventually i hope to abandon our library and use this one. although our library has some benefits since it is part of our existing stack (scala)

david.vancouvering
2021-08-18 18:40
Optic looks very interesting, thanks!!

kyle.florence
2021-08-18 18:40
it was brand new when i wanted to use it, it has come a long way since then

david.vancouvering
2021-08-18 18:41
"Get the benefits of Contract Tests, without writing and maintaining them." Hm, is it suggesting this can replace Pact tests?

kyle.florence
2021-08-18 18:41
haha. we had to ask ourselves the same questions. i think it is a slightly different use-case

kyle.florence
2021-08-18 18:41
we use it for our public API contracts

kyle.florence
2021-08-18 18:41
but we use pact for all of our internal contracts

david.vancouvering
2021-08-18 18:41
Why that distinction?

kyle.florence
2021-08-18 18:42
because with a pact you control both sides, and with the public contract you only control your side

kyle.florence
2021-08-18 18:42
so that gives you many benefits from pact, like being able to stand up stub servers easily and things like that

david.vancouvering
2021-08-18 18:42
ah i see

kyle.florence
2021-08-18 18:42
it also gives you realistic test data to use in your services (with pact)

david.vancouvering
2021-08-18 18:42
so you use pact to enable consumer develpoment in parallel with provider development, using stubs

kyle.florence
2021-08-18 18:43
the biggest benefit of pact for us is that it allows us to isolate our services completely

david.vancouvering
2021-08-18 18:43
yea makes sense

flynnhandley
2021-08-18 22:30
has joined #general

abubics
2021-08-19 10:08
That's totally up to you. If you want to avoid making extra network hops (which increases isolation & specificity, and reduces flakiness), stub your outgoing API clients (no different than stubbing database clients).

abubics
2021-08-19 10:12
I usually stub things before they get through to the central domain logic. If you cut boundaries in other places, you'll have to make that judgement yourself. It's a trade-off between lots of things, but I like to keep the contract testing limited to platform bindings & a tiny bit of transformation logic (as close to unit tests as possible while still having significant value).

samuel.verstraete
2021-08-19 12:22
we are getting 409's on publishing pacts to http://pact.dius.com.au . is there anyone aware of this?

tm.buga
2021-08-19 13:17
Hi all! I am having hard time understanding the Pact flow. If, for instance, I have two tests - one for the consumer and one for the producer, what would happen, if I run those tests in parallel and producer would start earlier and couldn't verify the contract, as it's not yet present on the Broker/Pactflow?

matt.fellows
2021-08-19 13:22
What?s your account details?

matt.fellows
2021-08-19 13:22
(feel free to DM me if you need)

matt.fellows
2021-08-19 13:29
See https://docs.pact.io/pact_broker/advanced_topics/troubleshooting/#409-when-publishing-a-pact (I have to run, but if it?s not the above, please send any issues to with your account details and actions so we can look)

beem132
2021-08-19 13:45
in the JS example project I believe their full test script goes: consumer tests -> publish -> provider tests. I'm fairly certain in your scenario the result would be that the consumer creates contracts that go unverified, and the provider tests pass no matter what. If you then ran the can-i-deploy script, it would tell you your consumer can't be deployed because it hasn't been verified, I'm not certain what the result would be for the provider.

beem132
2021-08-19 13:48
Hi, I'm writing some event driven contract tests, and I have a question about how to test the provider which is placing an event into a topic to be consumed by the consumer later. Is it expected that the code I test on the provider side would be separate from the part of the code that actually publishes to the event topic? Or is it expected that I mock the publish function and pull the argument from the mock to test the contract shape?

beem132
2021-08-19 13:49
I get that I _could_ do it either way, but just wanted to see if there was any known best practice for this piece.

thomaswtsang
2021-08-19 16:53
has joined #general

chris005
2021-08-19 19:07
has joined #general

chris005
2021-08-19 19:19
Hello : ) I have a general question regarding naming for third party libraries related to pact. Is it OK to use the pact name, e.g. pact-something? We're working on a project which is currently named `pact-testgen`, (it's a python CLI tool, for context). I don't want to imply that the project is owned or maintained by the Pact team. We'd be happy to include some sort of disclaimer to that effect in the README.

matt.fellows
2021-08-19 22:54
Thanks for asking and we don't have any guidelines there, but I'm certainly not concerned by it

matt.fellows
2021-08-19 22:54
What's the tool? Sounds interesting!

matt.fellows
2021-08-19 22:54
The first way


matt.fellows
2021-08-19 23:28
https://docs.pact.io/pact_nirvana explains the key flow

matt.fellows
2021-08-19 23:29
see also the CI/CD workshop in :point_down: (howtolearn)

2021-08-19 23:29
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

srimuralixi
2021-08-20 02:18
has joined #general

manika.goel
2021-08-20 05:38
has joined #general

akanksha.sharma
2021-08-20 06:31
has joined #general

chris005
2021-08-20 13:36
We're trying to make provider testing easier to achieve by leveraging the test isolation provided out of the box by the unittest testing framework, which is part of Python's standard library. So, instead of setting up some endpoint to receive setup instructions from pact-verifier, we generate unit test code directly from a pact file. Once a test file is generated, developers only have to go in and fill in the `setUp` methods for each test class. For a Django project (our first target), each test method is run in a transaction, and rolls the transaction back when the method exits. All the user needs to do is define the state in `setUp`, and the framework takes care of the rest. The project is currently at a sort of working prototype level, and we're still trying to come up with a good name before we publish (and nail down a few issues, of course).

jonah
2021-08-20 14:42
has joined #general

tlzhou
2021-08-20 15:02
has joined #general

ramya.sri
2021-08-23 03:52
has joined #general

joseramonrivera21
2021-08-23 08:49
has joined #general

denny.duttig
2021-08-23 10:10
has joined #general

akansha.saraswat3
2021-08-23 10:50
has joined #general

sushant.soni
2021-08-23 21:10
has joined #general

yousafn
2021-08-24 10:13
My current client has a range of microservices and they have exploded in numbers over a short space of time. Rather than each microservice communicating solely via rest or event based messaging (sns/sqs), it is abstracted by each microservice exposing an SDK, that can be consumed as an npm package. They currently don?t use contract testing, and have little in the way of integration tests, so solely rely on unit tests, and manual regression testing in a deployed environment. It?s the first time I?ve seen the providers API abstracted by an SDK and haven?t had time to think about how to go about this with pact, I have a couple of idea floating around but it?s just fuzz at the minute. Thought I would write something here to get something concrete down and start some discussion :slightly_smiling_face:

tjones
2021-08-24 10:15
I'd be keen to hear more about this!

tjones
2021-08-24 10:16
I've seen swagger docs shared as an "sdk", with the OpenAPI generators used on build

ajaiswal595
2021-08-24 11:00
has joined #general

matt.fellows
2021-08-24 11:06
Hello! Long time no speak

matt.fellows
2021-08-24 11:07
there was a bit of a chat about this recently, i?ll dig up the thread and link

matt.fellows
2021-08-24 11:07
I?ve done work with this situation before, and a little write up on it here: https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/


abatan.k
2021-08-24 12:32
Hello interesting question :slightly_smiling_face: The bridge between teams is brittle. They have unit test, but those are not covering integration between teams. So the teams are doing extra work (manual regression), to try to sync the knowledge between them. Pact is a game changer, because you already know _*before*_ deployment if you brake the expectation of your consumer. In your case it's seems to be verified in production. I think, that pact will improve the pertinence of your sdks. Since they'll evolve with the consumer expectations. Hope it helps :wink:

pd287515778
2021-08-24 12:48
has joined #general

hwebster
2021-08-25 05:30
has joined #general

hoangvo
2021-08-25 05:43
has joined #general

jobjingjo
2021-08-25 06:20
has joined #general

yousafn
2021-08-25 10:14
The client doesn?t currently have swagger for their api?s, it?s all typescript using IOC with inversify. There is a real struggle to understand breaking changes in API?s so they just get updated and are a bit bloated. Agreed @abatan.k! You should come work with us xD I have been using pact for the last 3-4 years known of it for around 5 and been working with cdc for a good few years beforehand. We never managed to successfully leverage pact fully at the last client due to stakeholder resistance from the internal test team. The new client is fully on board! They have CI/CD, teams have full ownership through to prod and there are no release CAB?s so changes go out as soon as tests are green. Biggest problem is the tests that do exist are of limited confidence, often against mocks and the teams don?t know enough about the business critical features that cross service boundaries. They publish packages on PR and master from an SDK, and they have dependabot triggering builds on consuming repositories. I thought about having some tests in place in the pipeline there which would fail if contracts aren?t met, but I would need a way to get feedback, back to the team which caused the breakage. Also not entirely sure how to go about writing pact tests for non http or message based pact, and the validation side of it when its abstracted through SDK?s. Matt - thanks for the blog post links, will have a read!

abatan.k
2021-08-25 13:31
Haha thx for the offer :sweat_smile: , i don't know if you already try to organize a workshop like an https://www.eventstorming.com/ ? I got the chance in my previous experience to work with domain experts really enthusiast about those workshop, and it's a good way to involve everyone in order to share the knowledge :slightly_smiling_face: If you cannot bring everyone, there is also other workshop which requires less people, like https://domainstorytelling.org/ (i have a preference for this one, it's way more "natural" than event storming, for non-tech people :slightly_smiling_face:)

abatan.k
2021-08-25 13:35
Anyway, i hope one day, i could work for a company outside France :sweat_smile: but i prefer the smaller companies, (10-50 people), it's easier to bring everyone on those workshop, and usually, they are more people interested by those practices, and you have less "ego-player" (or you can spot them easily ^^) :sweat_smile:

sagarsitap596
2021-08-25 14:10
has joined #general

sagarsitap596
2021-08-25 14:14
Can we publish contract to somewhere else and not on pact ? and configure provider to read contract from custom location ?

mike.geeves064
2021-08-25 14:37
What is it that you trying to avoid? (I assume by "on pact" you mean a pact-broker?) It would almost certainly be way easier (imo) to just use a broker. I've previously used the docker one: https://github.com/pact-foundation/pact-broker-docker which is straightforward to get going, to run locally or wherever you have docker available [we used locally as well as in our kubernetes cluster on AWS] Alternatively to just try it out you could get a free trial of pactflow: https://pactflow.io/pricing/?utm_source=homepage&utm_content=header and submit them there :slightly_smiling_face:

mike.geeves064
2021-08-25 14:53
Having said that, there is the requirement of a database to store them in, is that the complication? (docker works for there too!) You can specify the files to verify against, there's a --file argument to pact-verifier, just then you need to deal with what to do with them and getting them from your consumers etc

sagarsitap596
2021-08-25 15:21
I want to do poc. So I can't push contract file outside of my org network.

mike.geeves064
2021-08-25 15:37
Fair enough, in which case docker could be a good option? Aside from the functionality, when I did a poc to demo it was good having our local docker pact broker to help explain/demo the consumer and producer relationships that you can see in the broker, you get nice diagrams for example

kyle.fischer
2021-08-25 16:31
has joined #general

datasmithadvtech
2021-08-25 19:43
has joined #general

todor.m.kolev
2021-08-25 19:59
has joined #general

datasmithadvtech
2021-08-25 20:11
How would it be accomplished for java?

matt.fellows
2021-08-25 21:35
For a POC you can always share the file manually to demonstrate the concept, especially if you don't have time to setup a broker

matt.fellows
2021-08-25 21:35
As Mike said, if you want to demo locally just run the docker image

matt.fellows
2021-08-25 23:50
> Also not entirely sure how to go about writing pact tests for non http or message based pact, and the validation side of it when its abstracted through SDK?s. I?ve been wanting to put together a video on this for a while (not the SDK abstracted version of it). But happy to give you pointers!

matt.fellows
2021-08-26 00:34
The latest AMAs are live on our website (and YouTube): https://docs.pact.io/help/amas/ ? July: We were joined by @tjones and discuss the differences between Contract Testing, Schema/Specification Testing and working with OpenAPI specs ? August: We were joined by @kristine.jetzke and @anja.gruss and discussed all things Avro. We?d love feedback on these sessions and if more like them are of interest. It was heaps of fun for us, so if you have a topic you?d like to see discussed in a similar panel format we?d love to hear from you!

tjones
2021-08-26 01:19
I just ran into this: ``` withRequest: { method: 'POST', path: '/item/1', headers, },``` which passed (incorrectly) because I forgot to specify the body of the request. I reckon pact should warn in a case like that - it's valid to have a body-less post, but probably not what you meant.

sushmitha.amin
2021-08-26 04:31
has joined #general

sagarsitap596
2021-08-26 05:42
Thanks Mike, Matt!! yeah docker approach should work for me. Could you please redirect me to your POC if possible?

matt.fellows
2021-08-26 06:58
my POC?

matt.fellows
2021-08-26 06:58
what do you mean, sorry?

matt.fellows
2021-08-26 06:58
I thought you said _you_ were doing a POC, so I was saying for a POC do what you need to do - share the file manually, run the broker locally etc.

matt.fellows
2021-08-26 06:59
but if it?s a POC and the data is not real, what?s the problem with using Pactflow? (thanks Mike for sharing)

mike.geeves064
2021-08-26 08:06
Not sure if Sagar meant my poc that I mentioned? For docker, in the repo linked are some docker-compose examples, which include up a postgresql database, e.g. https://github.com/pact-foundation/pact-broker-docker/blob/master/docker-compose.yml (they have an additional optional step which it mentions of nginx which you may want to add certs for or alternatively just take out to start with) Unfortunately my poc isn't currently in a shareable state, and included a load of extra setup for docker networks and deployment to kubernetes, GitLab webhooks and so on, as part of the CI/CD I was using to demo in our environment If you have the docker compose based broker/database running you should then be able to just push up the consumer pacts you've generated with docker as well to it with something like: > docker run -it --net=pact-broker_default -v $(pwd)/pacts:/pacts --rm pactfoundation/pact-cli broker \ > publish /pacts --consumer-app-version=0.0.1 --tag=first_release --broker-base-url=http://pact-broker_pact-broker_1:9292 (this is using the same "network" the broker docker-compose will have setup with the --net, which is why the broker url is then pact-broker_pact-broker rather than the localhost you would use directly)

sagarsitap596
2021-08-26 09:46
yeah I meant Mike's poc. Sorry for confusion.

sagarsitap596
2021-08-26 10:25
Hi team, I have pact test written in src/test/java/xyzpackage. is there a way we can run pact test under given package using mvn ?

matt.fellows
2021-08-26 10:39
Pact just runs under a unit testing framework, so your questions is probably better framed that way: how to run a specific test in x with maven

matt.fellows
2021-08-26 10:40
Unless you're not using a test framework, in which case I assume you just run the Java class as you would any other

sagarsitap596
2021-08-26 12:18
hey Mike, I am using Junit5. I have other junits written in code. So I thought of running just pact test which are under one package.

sagarsitap596
2021-08-26 12:20
If I run just class in Intelij it runs and test passes. but if I run with mvn '-Dtest=com.xyzpackage.pact.*Test' test , it is giving me 0 - Connect to *localhost:8080 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused).* though my local provider is up

sagarsitap596
2021-08-26 12:28
Ignore, its working now. Setup issue.

shwetastar98
2021-08-26 12:35
has joined #general

contact
2021-08-26 12:44
has joined #general

malena.cadima
2021-08-26 16:07
has joined #general

thanuxxxx
2021-08-27 01:12
Quick question about testing query parameters. I have a URL that has 2 variations 1. resource/id 2. resource/slug&slug=true But they give same response. Do I have to test those two variations?

uglyog
2021-08-27 01:39
What happens if the consumer sends `resource/slug` but does not include the query parameter?

thanuxxxx
2021-08-27 01:40
That would consider as invalid `id` and returns a `404 error response` ( as expected)

louis.ss
2021-08-27 01:42
has joined #general

uglyog
2021-08-27 01:43
Is that not an important thing to define in the contract?

thanuxxxx
2021-08-27 01:43
I have 4 tests ? two tests for happy tests & 2 for sad tests 1. valid id or slug ( `resource/valid_id` and`resource/valid_slug&slug=true` 2. invalid id or slug ( `resource/invalid_id` and `resource/invalid_slug&slug=true`

thanuxxxx
2021-08-27 01:49
ideally when this param is set to true, then id is a slug

uglyog
2021-08-27 01:51
I was more trying to get you to think about what is important in the contract to help you answer your original question

thanuxxxx
2021-08-27 01:54
So in the contact I define, when it is a valid id then there is an expected good response, and when it is not a valid Id then it should be an expected bad response

sagarsitap596
2021-08-27 11:39
```@BeforeEach void before(PactVerificationContext context) { context.setTarget(new HttpTestTarget("localhost", 8080, "/")); }``` instead of localhost how can I provide cname / server domain without port url ? I tried with just domian name, but the lib is appending 8080 by default

matt.fellows
2021-08-27 11:40
Probably best asked in #pact-jvm

matt.fellows
2021-08-27 11:40
But I?m guessing something like: ```context.setTarget(new HttpTestTarget("http://somewebsite.com", 80, "/"));```

matt.fellows
2021-08-27 11:41
or ```context.setTarget(new HttpsTestTarget("http://somewebsite.com", 443, "/"));```


sergio.amorim
2021-08-27 14:40
has joined #general

slin
2021-08-29 23:51
has joined #general

shane.robinson
2021-08-30 00:30
has joined #general

br.maher
2021-08-30 04:35
has joined #general

varnit.garg2424
2021-08-30 09:41
Hey Guys, One quick question: I would like to understand how pact is different from protobuf if two micro-services are connected via kafka. I understand that protobuf helps in validating the schema and supports backward compatibility as well. Let's say if we are already using protobuf, then would there be any significant advantage to consider using pact as well?

tjones
2021-08-30 09:42
Yes. If you are using protobuf, how do you determine that both sides are implementing the same contract?

tjones
2021-08-30 09:43
The pact broker maintains a list of the consumer contracts and the version(s) of the providers that compatible with the contracts.

varnit.garg2424
2021-08-30 10:15
It's like we can have a separate library that would define the proto. Let's say if we update the schema, then just change it in the common lib and use the same version on producer and consumer side

tjones
2021-08-30 12:51
How do you ensure that each deployable object (consumer, producer etc) has the latest version of the lib?

tjones
2021-08-30 12:52
How do you know that the previously deployed version is compatible with the new version?

tjones
2021-08-30 12:52
Pact solves those problems for you through testing

tjones
2021-08-30 12:54
If you're managing a shared library in a way that answers those questions, you probably don't need pact. I'm not super across protobuf, but we occasionally get the same argument in situations where the provider's build also releases a shared http client library. Every time I have personally seen this, the process of "oh, don't worry, we don't forget to update the lib" has not been successful.

tjones
2021-08-30 12:55
> Let's say if we update the schema, then just change it in the common lib and use the same version on producer and consumer side The best use case for this scenario is where the consumer and producer are one atomically deployable unit.

matt.fellows
2021-08-30 13:03
I'll try and answer on more detail tomorrow, but take a look at #protobufs and also the feature requests at http://pact.canny.io

kwongyun
2021-08-30 15:57
has joined #general

0x06065a
2021-08-31 00:02
has joined #general

abubics
2021-08-31 03:42
There's probably the whole https://pactflow.io/blog/schemas-are-not-contracts/ thing, too


matt.thomas
2021-08-31 05:29
has joined #general

bethskurrie
2021-08-31 08:14
Ask in #pact-jvm @datasmithadvtech

abhi.nandan964
2021-08-31 10:19
has joined #general

nathaniel.emmons
2021-08-31 15:06
Question about testing ?message? pacts. Say a provider publishes to an SNS topic which is then fanned out to SQS queues. The consumer listens to an SQS queue. That SNS fanout in the middle is https://docs.aws.amazon.com/sns/latest/dg/sns-sqs-as-subscriber.html by wrapping it in metadata etc. So i need to account for parsing that extra layer in my consumer of course, but in terms of pact testing, i guess that means i need to ?mock? that extra layer of data in my provider verification so that the verification works? It seems like an interesting edge case to have this intermediary transforming the message in the middle in a way which causes the provider more work to match for the sake of verification.. unless i?m missing something?

nathaniel.emmons
2021-08-31 16:38
Put more simply: i?m wondering whether it should be the provider?s responsibility or the consumer?s responsibility to understand and account for the mutation of the message sent by the provider to SNS

shivi.btech08
2021-08-31 21:03
has joined #general

tjones
2021-09-01 00:13
Interesting case!

tjones
2021-09-01 00:14
I think the pragmatic option is to mock it in your provider as you suggest

tjones
2021-09-01 00:16
this is kind of always the case with message pacts at the moment - in an HTTP pact, we actually send the real request, whereas in a message pact, the sending is mocked, and the data shape is the part that's tested.

tjones
2021-09-01 00:17
We're working on plugins for pact, which will mean that in the future you won't need as many mocks

qingyuliu
2021-09-01 02:05
Hi, I have a question about upload pact file to pact broker from the consumer side. Here is how my plugin defined: ```<plugin> <groupId>au.com.dius.pact.provider</groupId> <artifactId>maven</artifactId> <version>${pact-jvm-provider-maven.version}</version> <configuration> <pactBrokerUrl>http://localhost:8085</pactBrokerUrl> </configuration> <executions> <execution> <phase>install</phase> <goals> <goal>publish</goal> </goals> </execution> </executions> </plugin> <properties> <pact-jvm-provider-maven.version>4.1.7</pact-jvm-provider-maven.version> </properties>``` And I got the error: [ERROR] No plugin found for prefix 'pact' in the current project and in the plugin groups [org.mortbay.jetty, com.ebay.raptor.build, org.codehaus.mojo, org.sonatype.maven.plugins, org.apache.maven.plugins], I've tried many different versions of the pact-jvm-provider-maven like 4.1.23, 4.1.11, etc, Can anyone help me solve this problem?

matt.fellows
2021-09-01 02:11
can you please redirect this question to #pact-jvm ?

qingyuliu
2021-09-01 02:12
Sure

kpuengpanich
2021-09-01 07:14
has joined #general

mhmtyuceoz
2021-09-01 07:35
has joined #general

gayatree.eee
2021-09-01 07:38
Is there anyway we can retry publish/verify contract if it fails due to some reason

matt.fellows
2021-09-01 08:42
There are retries built in in many of the tools as I understand, what problem are you seeing and how are you publishing?

gayatree.eee
2021-09-01 10:19
we are using pact cli to invoke publish or verify

matt.fellows
2021-09-01 11:02
What problems agree you getting though?

matt.fellows
2021-09-01 11:03
Pretty sure if you enable verbose you'll see any retry attempts. It won't retry under all conditions though

nathaniel.emmons
2021-09-01 13:05
That all makes sense to me, thanks for your insight

tjones
2021-09-01 14:03
This is an interesting case. I'm not sure I understand it fully, but it sounds like this might be the key: > the gateway version is a cumulative version (itself + downstream services). This makes sense from the perspective of the consumers of the gateway, but I don't think it makes sense for the pact between the gateway and the downstream services

tjones
2021-09-01 14:04
You might benefit from having multiple versions for the gateway - an internal one (that changes when the gateway changes) and one for the consumers (that changes when the downstream services or the gateway change).

tjones
2021-09-01 14:04
Also I'll tag you since I'm nearly a month late replying to this (I only just saw it for some reason): @p0deje

tjones
2021-09-02 04:03
For pending pacts with one branch (say `main`), is there a way to tell the verifier "I'd like to verify the latest `main` pact, and the last one that was successful on `main`"?

volkan.tufekci
2021-09-02 08:47
has joined #general

yassine
2021-09-02 10:59
has joined #general

connor.beck
2021-09-02 13:39
has joined #general

maurits.out
2021-09-02 15:12
has joined #general

kumasaka.tk
2021-09-02 21:24
has joined #general

valeriia.danylenko
2021-09-03 18:26
has joined #general

irmt06
2021-09-04 22:51
has joined #general

wenqiglantz
2021-09-05 00:52
Check out my article on Medium on using Pact for testing event driven pub/sub messaging with Dapr within Spring Boot microservices. https://medium.com/codex/consumer-driven-contract-testing-with-pact-f8a28a8a7c3c

tjones
2021-09-05 06:57
Nice work!

bethskurrie
2021-09-05 07:36
@tjones not currently. What problem would that solve?

tjones
2021-09-06 05:34
Maybe I don't understand this feature

tjones
2021-09-06 05:34
I want it to warn about breaking changes

tjones
2021-09-06 05:35
like "this is a regression", vs "this is a new contract you haven't implemented yet"


tjones
2021-09-06 05:35
if we enable pending pacts, it just won't complain if there's a new contract that fails, right?

bethskurrie
2021-09-06 05:36
there's a state transition diagram and everything.

tjones
2021-09-06 05:36
yes, I've read that, and I still don't understand how I'm supposed to configure it.

bethskurrie
2021-09-06 05:37
enablePending: true

tjones
2021-09-06 05:37
To catch regressions, wouldn't I want to verify the latest non-pending?

tjones
2021-09-06 05:37
As well as the latest pending

bethskurrie
2021-09-06 05:38
Noo....

tjones
2021-09-06 05:38
why not?

bethskurrie
2021-09-06 05:38
are you thinking about wip pacts?

tjones
2021-09-06 05:38
I don't know what that is

bethskurrie
2021-09-06 05:38
pending doesn't change which pacts you're verifying.

tjones
2021-09-06 05:39
right, pending changes whether or not a pact is allowed to fail the build

bethskurrie
2021-09-06 05:39
yes.

bethskurrie
2021-09-06 05:39
well said.

tjones
2021-09-06 05:39
So, for `main`, would I not want to validate: ? main's last pending pact ? main's last non-pending pact ?

bethskurrie
2021-09-06 05:40
no, you just verify the latest main

bethskurrie
2021-09-06 05:40
same as normal.

tjones
2021-09-06 05:40
But I don't want to do that, because I want to catch regressions

bethskurrie
2021-09-06 05:40
enablePending just determines whether or not that failure breaks the build.

tjones
2021-09-06 05:40
Won't I miss things?

bethskurrie
2021-09-06 05:40
we're not connecting here.

tjones
2021-09-06 05:41
Ok. Here's an (I think) unrelated question that might uncover where I'm confused:

tjones
2021-09-06 05:41
> A pact content is considered pending if there has not been a successful verification published by the specified branch of the provider.

bethskurrie
2021-09-06 05:41
you do catch regressions.

tjones
2021-09-06 05:41
With short lived branches, won't all contracts be pending?

bethskurrie
2021-09-06 05:42
that's where WIP pacts comes in.


tjones
2021-09-06 05:42
> you do catch regressions. I don't think I do, because a regression (if covered by the pending pact, which it might not be) won't fail the build.

bethskurrie
2021-09-06 05:42
that will automatically include your feature pacts in the verification process so you don't have to explicitly update teh config.

bethskurrie
2021-09-06 05:42
and they will be included with pending=true so they never fail the build.


tjones
2021-09-06 05:43
I mean feature builds on the provider side

bethskurrie
2021-09-06 05:43
aaah

bethskurrie
2021-09-06 05:44
ok, the logic is actually a little bit more complex

tjones
2021-09-06 05:44
(I don't want to validate any pacts that aren't in `main`)

tjones
2021-09-06 05:44
(so I don't think WIP pacts is for me)

bethskurrie
2021-09-06 05:44
a pact is pending if there is no successful verification from this provider branch AND there was no successful verification from a branch from before this branch was created.


tjones
2021-09-06 05:45
how does the broker know that? Do I have to tell it?

bethskurrie
2021-09-06 05:45
if you only ever verify main, then your'e foricing nyour consumers to break their own builds to get a feature out.

bethskurrie
2021-09-06 05:45
> how does the broker know that? Do I have to tell it? No, it has that data.

tjones
2021-09-06 05:45
It doesn't have my git history

bethskurrie
2021-09-06 05:46
it uses the tags

bethskurrie
2021-09-06 05:46
it assumes at least one of the tags is a branch.

tjones
2021-09-06 05:46
but those don't contain that information. Is it making assumptions about time?

bethskurrie
2021-09-06 05:46
also, branch support is almost done, so it will use that data.

bethskurrie
2021-09-06 05:46
the tags have a date on them.

tjones
2021-09-06 05:47
ok. So it's assuming it hears about the tags/branches in the order that they're created

bethskurrie
2021-09-06 05:47
Ok, as much as I would love to give you the special treatment, at this stage, I'm going to have to say waht I say to everyone, which is "Please do this workshop" https://docs.pactflow.io/docs/workshops/ci-cd

tjones
2021-09-06 05:47
which is going to be wrong sometimes

tjones
2021-09-06 05:47
Our party line can't be "do this workshop"

bethskurrie
2021-09-06 05:47
yes, the tag data is goign to be wrong sometimes. that's why I've written proper branch support.

bethskurrie
2021-09-06 05:47
Yes it bloody is!

bethskurrie
2021-09-06 05:48
I can't sit and take 30 mintues to explain it to everyone who asks or I'd never get any work done!

tjones
2021-09-06 05:48
Well, that's fair

bethskurrie
2021-09-06 05:48
it works. it works enough that people are using it.

bethskurrie
2021-09-06 05:48
and most of them without a personal explanation.

bethskurrie
2021-09-06 05:48
because they do the workshop :stuck_out_tongue:

tjones
2021-09-06 05:49
> and most of them without a personal explanation. Fair. Well, when I understand it, I'll write the summary that I'm looking for.

tjones
2021-09-06 05:50
I still don't think I can catch regressions if I'm using pending

tjones
2021-09-06 05:50
but maybe I don't need to?

tjones
2021-09-06 05:50
when there are deployments, we'll have different tags for those

tjones
2021-09-06 05:52
Anyway, thanks for the personal explanation! I appreciate it :pray:

divyalakshmi.gk
2021-09-07 01:46
has joined #general

constantin.jaeck
2021-09-07 02:24
has joined #general

narendra_uppara
2021-09-07 07:17
has joined #general

nikuplanchiwar
2021-09-07 08:03
has joined #general

sdomeracki
2021-09-07 10:22
has joined #general

gibraltor999
2021-09-07 12:03
has joined #general

norway.martin
2021-09-07 18:38
has joined #general

adamdullenty
2021-09-08 08:23
has joined #general

martin.a.harkins
2021-09-08 12:15
has joined #general

jayeshguru81
2021-09-08 21:55
Hello, In pact test how do I verify if the expected json response body matches for the unordered lists? ```expected_response_json_body = { "message":"Information gathered successfully.", "info":[ {"file_name":"abc.jpg","id":"abc"}, {"file_name":"def.jpg","id":"def"}, {"file_name":"ghi.jpg","id":"ghi"}, {"file_name":"jkl.jpg","id":"jkl"} ] }```

bethskurrie
2021-09-08 22:36
I think later versions of the pact spec allow you to do unordered lists. It depends which library you're using.

bethskurrie
2021-09-08 22:36
The easiest way is to just expect one item!

jayeshguru81
2021-09-08 22:37
yeah thats what I am looking for, I am new to pact

jayeshguru81
2021-09-08 22:37
how do I expect just one item ?

jayeshguru81
2021-09-08 22:37
I thought we have to match whole response body

bethskurrie
2021-09-08 22:38
Which language are you using?

jayeshguru81
2021-09-08 22:38
Consumer - JS Provider - Python




bethskurrie
2021-09-08 22:41
Also, there are 10+ languages that Pact is implemented in. Best to ask questions in the channel for your language. #pact-js and #pact-python

jayeshguru81
2021-09-08 22:42
Thanks Beth I will look into this and see how it fits my usecase

adamdullenty
2021-09-08 23:03
Hey everyone. I'm just working through the pact guide for Ruby at the point where I try to run the rake task to verify against the pact from the consumer project: https://github.com/pact-foundation/pact-ruby#in-the-animal-service-provider-project I'm getting this error: ```RuntimeError: Could not find http://config.ru file at ./config.ru Please configure the service provider app or create a http://config.ru file in the root directory of the project.``` The "producer" in this case is a Ruby lambda function written using Serverless, so it doesn't really make sense to have a `http://config.ru` but I can carry on down this route if there's a known way to get this to work?

bethskurrie
2021-09-08 23:04
Hi @adamdullenty. Best place to ask is in #pact-ruby

adamdullenty
2021-09-08 23:04
Thanks :slightly_smiling_face:

bethskurrie
2021-09-08 23:04
It'll be me there too, but we like to keep the channels focussed.

adamdullenty
2021-09-08 23:04
done!

rocco.smit
2021-09-09 06:20
has joined #general

andrei_mironau
2021-09-09 10:00
has joined #general

febin.sathar
2021-09-09 10:16
has joined #general

jcaromiq
2021-09-09 11:47
has joined #general

aaron590
2021-09-09 15:24
I understand Pact is built for testing contracts that we control both consumer and provider. Is there any guidance for using Pact to stub 3rd party services? I understand there's a second half that we'd have to ensure that the contracts we're using to stub are valid.

mike.geeves064
2021-09-09 17:05
I believe the guidance is generally "don't" :slightly_smiling_face: "When to use Pact | Pact Docs" https://docs.pact.io/getting_started/what_is_pact_good_for/#why-pact-may-not-be-the-best-tool-for-testing-public-apis You can but there are complications to consider when you don't control both sides, so it may or may not be the best solution, as always "it depends"!

aaron590
2021-09-09 17:44
We wouldn't be using it for the actual testing portion. We realize that's not ideal. We'd want to use the stub server functionality and I believe this gets us most of the way, if not all of the way there.

aaron590
2021-09-09 17:45
But we do realize that there's a lot of grey area here

mike.geeves064
2021-09-09 18:18
Indeed! I know what you mean. (disclaimer: far from and expert here so I'm sure others can give more real world guidance :slightly_smiling_face:) Do you know what sort of interactions you will be needing to do? As in if you are just needing to do some GET requests and check out all works together that's going to be a lot simpler than if there are state changes to deal with :thinking_face:

aaron590
2021-09-09 18:21
The plan is to stub entire 3rd party services. GET/PUT/POST/PATCH/DELETE. Overnight run some different tests against these 3rd party services to ensure that our stubs are valid by comparing responses to the defined contract. We want to explore PACT as a part of the core flow because it has most of this functionality built in

kyle.florence
2021-09-09 18:29
i would recommend checking out https://useoptic.com/

kyle.florence
2021-09-09 18:30
but also it sounds like you?re more interested in creating a mock service for the third-party

aaron590
2021-09-09 18:30
We're the consumer though, not the provider. Am I misunderstanding how Optic works?

kyle.florence
2021-09-09 18:31
i see, yeah optic is primarily for the provider side where the consumer is a third-party

kyle.florence
2021-09-09 18:31
we generally just stub our third-party calls in the client layer

kyle.florence
2021-09-09 18:31
or call out to a third party test environment

kyle.florence
2021-09-09 18:32
if the third party provides a spec of some sort (like OpenAPI), there are tools that can be used to generate a stub server from that

aaron590
2021-09-09 18:33
> or call out to a third party test environment We've got services that don't have a test environment and we're having connectivity issues with these environments > we generally just stub our third-party calls in the client layer We're a micro service architecture that we have to do acceptance testing on. This is the level we're interested in. In order to properly test our services we need to make sure we have a reliable connection to a 3rd party service

aaron590
2021-09-09 18:34
> if the third party provides a spec of some sort (like OpenAPI), there are tools that can be used to generate a stub server from that I'm uncertain, but we can dig into that

kyle.florence
2021-09-09 18:36
yeah i guess the solution for stubbing third parties depends a lot on how the third party works and whether or not you want to make actual network calls to something

mike.geeves064
2021-09-09 18:41
A pattern I've used, not specific to pact, if there's a 3rd party service, having a small service acting as a gateway/interface (for example if there are multiple clients using it, avoiding having logic to handle retries, throttling, logging usage and so on) Then you could fully manage the pact contracts with your consumers, although in a way moving the problem (for our use case we were looking at weather data so abstracting out the 3rd party API meant we could swap out the implementation without changing the clients themselves). Tangenting now possibly :)

mike.geeves064
2021-09-09 18:43
So for our testing we would use a dummy implementation that was very fast to verify e2e

kyle.florence
2021-09-09 18:43
we primarily do testing in production against a third party test environment, when we want to ?actually test?

kyle.florence
2021-09-09 18:44
our applications have the concept of a ?usage context? baked into them, though, which is defined by the authentication token used

mike.geeves064
2021-09-09 19:23
Hmm, can't find a link (currently on my phone). I'm not sure about the scenario of running nightly tests, pact is more oriented to running when there are changes on the provider or consumer. That's not to say you couldn't ofc I believe the broker will attempt to use prior evidence of compatibility if there's no change to the pact created by the consumer of behaviour of the broker (that's the bit I can't find in a link to verify if that's actually the case)

kyle.florence
2021-09-09 19:24
i would probably use a different tool rather than pact just for standing up stub servers

mike.geeves064
2021-09-09 19:24
If that's the case, depending on how you're running it, that wouldn't then show if the 3rd party API has since changed :thinking_face:

kyle.florence
2021-09-09 19:24
nope

mike.geeves064
2021-09-09 19:25
(sorry I was continuing the I think it may use cached results rather than a disagreeing with your comment)

mike.geeves064
2021-09-09 19:26
(timing!)

kyle.florence
2021-09-09 19:26
lol

mike.geeves064
2021-09-09 19:27
Wait..re reading it, yes it wouldn't show if you had a mock and their end changed. Should have just kept quiet :D

kyle.florence
2021-09-09 19:28
yeah for that kind of stuff, you mostly just have to trust that the third party isn?t breaking things

kyle.florence
2021-09-09 19:28
but if they do, there are further steps you can take if needed, depending on how they do releases, etc

mike.geeves064
2021-09-09 19:32
Nod. That's where I like the extra point of failure (:open_mouth:) of your own service acting as an interface to work round when they add or remove an s to a field name or a new API version becomes default and breaks things, to be able to update one single place. But that's still going away from the original question :)

kyle.florence
2021-09-09 19:33
yeah that?s an interesting solution, depending on how they break something haha.

mike.geeves064
2021-09-09 19:48
Indeed. The example I'm thinking of, looking at weather data, we had ended up with several consumers pointing to a different API version and or host (USA Vs EU or something), causing ourselves much confusion later because of ever so slightly different values everywhere :sob:

mike.geeves064
2021-09-09 19:49
At doc I was thinking of depending on what pact test/approach running your looking at, it will try to avoid duplicate verification

mike.geeves064
2021-09-09 19:49
Found it


mike.geeves064
2021-09-09 19:51
There we go

mirko.zipris
2021-09-09 20:08
has joined #general

dotelnp
2021-09-10 06:48
has joined #general

sameer.patil
2021-09-10 18:42
has joined #general

b.1.alpha
2021-09-10 19:17
has joined #general

naushad_amin
2021-09-11 23:15
has joined #general

jose_rodriguez
2021-09-13 13:16
has joined #general

kyle_evans
2021-09-13 13:16
has joined #general

rahul.louis
2021-09-13 15:55
has joined #general

a.koka
2021-09-13 17:01
has joined #general

efloresambrosio
2021-09-13 20:09
has joined #general

olle_hallin
2021-09-14 05:50
has joined #general

a.babenko
2021-09-14 14:00
has joined #general

vasavi.balanagu
2021-09-14 16:49
has joined #general

samuel.sjoberg
2021-09-14 21:49
has joined #general

domingo
2021-09-14 23:51
has joined #general



matt.fellows
2021-09-15 01:08
If you are keen to be an early beta tester, please register for our https://github.com/pactflow/roadmap#developer-preview-programs

matt.fellows
2021-09-15 01:09
Quick follow up - you might be interested in this thread also @varnit.garg2424 https://pact-foundation.slack.com/archives/C5F4KFKR8/p1631667982093600?thread_ts=1626113788.476300&cid=C5F4KFKR8

pradeepkumarstudent20
2021-09-15 03:32
has joined #general

anchit.99
2021-09-15 08:45
What is the right answer to "how much maintenance do pact tests need?" or "how many hours per week should I be factoring for pact test maintenance?"

matt.fellows
2021-09-15 08:49
The answer to those sorts of questions is usually several more questions, or a snarky comment like ?How long is a piece of string?? :stuck_out_tongue:

matt.fellows
2021-09-15 08:50
replace ?pact? with ?unit? and see if it changes the way you think about the question

dimundo
2021-09-15 08:58
no tests - no maintenance :all_the_things:

gibraltor999
2021-09-15 11:19
Hi could someone let me know how is pact better or different from wiremocks please?


gibraltor999
2021-09-15 11:29
Yes, doesnt specifically mention about Wiremocks. Just wanted to a couple of points to understand why Pact specifically and not Wiremocks.

matt.fellows
2021-09-15 11:36
Wiremock is an API mocking tool

matt.fellows
2021-09-15 11:37
Pact does mocking, but more importantly those mocks are later verified against the real API

matt.fellows
2021-09-15 11:37
It uses a contract that keeps the two sets of tests in sync

matt.fellows
2021-09-15 11:38
This is why it's called contract testing

matt.fellows
2021-09-15 11:38
So wiremock is an API mocking tool, Pact is an API contract testing tool

gibraltor999
2021-09-15 12:15
Thanks Matt

matt.fellows
2021-09-15 12:19
You can use the ?nock? example from https://docs.pact.io/getting_started/comparisons, as nock does the same thing essentially

matty_o_connor01
2021-09-15 14:54
Hi all, I would like to setup a PACT test for a 400 response from an api call where I want to check the response body for the correct details. The real response from the provider looks something like this.... ```{ "errors": { "password": [ "The Password field is required." ] }, "type": "https://tools.ietf.org/html/rfc7231#section-6.5.1", "title": "One or more validation errors occurred.", "status": 400, "traceId": "|78b76663-404824fd386bdc03." }``` Questions 1. If I mock the response with only the fields I am interested in in my consumer test (e.g. `status` and `errors` ), when PACT does provider verification against the real api is it smart enough to ignore the other fields that are returned? Or does PACT think that is an error with the contract? 2. Depending on the answer to 1. if the provider has some sort of internal mechanism for populating a value in a field, e.g. the guid in the `traceId` above that can't be mocked in the provider when used with PACT, how can I ignore this during provider verification? Many thanks,

bryan
2021-09-15 15:16
has joined #general

matty_o_connor01
2021-09-15 15:29
I've just tried this and it looks like it worked by just specifying the fields I was interested in validating. Questions can be ignored unless some context can be provided to understand why it works this way. Ta,

dboxler
2021-09-15 18:35
has joined #general

matt.fellows
2021-09-15 23:16
I thought there was a better link, but this might help: https://docs.pact.io/getting_started/matching/gotchas/#pact-follows-postels-law

bethskurrie
2021-09-16 03:03
Research for new Pact Broker feature: does anyone use different pact verification configurations on different branches, and what is your reason for doing so?

tjones
2021-09-16 03:40
I don't yet, but I think that maybe I might want different `enablePending` settlings on different branches - for the case where you want to say "ok I'm now working on that feature"

tjones
2021-09-16 03:41
At the moment some frameworks (eg pact JVM in Junit5) represent "pending" pacts as passing in the Junit IntelliJ UI, which is a bit of an annoying development experience - you have to click on each test individually to see what failed

tjones
2021-09-16 03:42
With say 12 interactions, it's just annoying, with hundreds it would be impractical.

keerthisiv
2021-09-16 03:59
has joined #general

adelina.simion
2021-09-16 08:41
has joined #general

akke.luukkonen
2021-09-16 10:29
has joined #general

matt.fellows
2021-09-16 12:12
:wave: Hello! Getting started with Pact or just keen to level up your knowledge in Java or Node.js? You?re in luck! Next week @uglyog and I are hosting two live training workshops next week to help you get up to speed.  During each of the two and a half-hour workshops, we will cover: ? The challenges with end-to-end integrated testing and how contract testing can help ? The basics of contract testing and how it can fit into a general testing strategy ? The core concepts of Pact with a hands-on lab There will be plenty of opportunities for Q&A as we dive into the topics. By the end of the workshop, you should be comfortable writing and verifying Pact tests and have a basic understanding of how you can collaborate using a Pact Broker.  _Note: these training sessions will be most friendly for our users in APAC, Europe, and the UK._  Register yourself and feel free to share with your friends and colleagues https://pactflow.io/upcoming-events/.

alejandro.pena
2021-09-16 13:37
has joined #general

fnguyen
2021-09-16 14:02
I can see how it could be useful to have features (and tests) in dev branch before it's fully stable and not breaking release branch builds

tjones
2021-09-16 14:18
Yes. I think it's a killer feature for people with lots of branches. I also love that you can say "if this has never passed before, I don't expect it to pass now".

j3rry.wan9
2021-09-17 00:40
Will there be future sessions that are more friendly for users in North America?

matt.fellows
2021-09-17 05:26
Yes! We actually ran them last week, and notified via our Pactflow mailing list but thought we'd increase the uptake through this channel

matt.fellows
2021-09-17 05:27
I'll cut up the recordings and share online in the coming weeks

bbleach
2021-09-17 07:30
has joined #general

bbleach
2021-09-17 08:10
Hello all :wave: I've recently been looking into Pact and have a question about the CI integration, as I've hit a bit of a blocker. I'll put the details in a thread so as not spam this chat with a big message, but any help would be greatly appreciated! :pray:

bbleach
2021-09-17 08:11
I have a setup as follows. Note that for now, the sole aim of this is to prevent feature branches being merged into "master" if they are not compatible with the other side in "master" also: ? Pushes to a Provider branch are verifying the consumers in master (enable pending is true, and wip pacts is set also). ? On the consumer side, pushes to a branch trigger a verification against the latest Provider master version, and that verification targets only that consumer version. The pact broker is configured to trigger these verifications on the contract_content_changed event. ? Additionally, to "block" merges into the consumer master version if the verification fails, I have a job that uses `can-i-deploy` to effectively say "is this consumer compatible with the latest provider master version?" Its using `--retry-while-unknown` to cause the consumer pipeline to wait until the verification is available. This is the problem I'm seeing now, possibly caused by using contract_content_changed event (but this seems to be the recommended approach): ? The first consumer push changes the pact and triggers a verification, and this is successful. So in the matrix this consumer version is now verified by the latest 'master' provider. ? Next, a provider branch gets merged into master, and the provider pipeline runs. This causes a verification to happen against the consumer masters. All consumers tagged with 'master' are now verified by the latest 'master' provider. The consumer version from before is now verified by a _previous_ master provider version. ? Finally, an update is made to the consumer branch (not a contract change) and pushed. No verification is triggered because the contract hasn't changed, and the problem is: *the* `can-i-deploy` *step now times out because this consumer version has no verification for the _latest_ provider master.* Does anything jump out at you as being incorrect with the above implementation? This is my first look into Pact so still finding my way a bit.

bbleach
2021-09-17 08:11
I'm thinking that instead of using the contract_content_changed event for the webhook I could switch to contract_published which would mean the consumer pushes always trigger a verification, and that might solve this problem. But it seems a bit wasteful this way so I wanted to check here first what I'm doing wrong :slightly_smiling_face:

bbleach
2021-09-17 08:16
I hope this makes some kind of sense. Its hard to articulate this stuff :sweat_smile:

tjones
2021-09-17 10:51
> the can-i-deploy step now times out because this consumer version has no verification for the latest provider master This shouldn't happen. The pact broker considers unique contracts, not unique versions. So, if you publish a new version of the consumer with an unchanged contract, it is already verified (as long as that contract was previously varied)

tjones
2021-09-17 10:51
I suspect there's something misconfigured somewhere

tjones
2021-09-17 10:52
Are you publishing the pact from the latest consumer build? You still need to publish it even if it hasn't changed, so the broker will know it hasn't changed

bbleach
2021-09-17 11:02
Yes its being published on every build

bbleach
2021-09-17 11:11
This is what I'm seeing in the matrix after the provider branch was merged to master and that subsequent verification takes place against the consumer masters:

bbleach
2021-09-17 11:13
Which I understand to mean that this feature branch will no longer pass the can-i-deploy check against master, because the latest master provider has verified a pact with different contents?

bbleach
2021-09-17 11:23
Currently all provider pipelines (feature branches or master) are verifying the master pacts. Only the verification triggered from a consumer push verifies the given feature pact. I feel like I've missed something here just not sure what it is :thinking_face:

tjones
2021-09-17 15:58
> Which I understand to mean that this feature branch will no longer pass the can-i-deploy check against master, because the latest master provider has verified a pact with different contents? I'm not sure I understand this explanation - multiple consumer pacts are able to be verified by a single provider, so it should be fine. (I'm not too familiar with the pactflow UI for tags, but it looks like that line in the matrix is unrelated to whether you can deploy the provider against master consumer - because it's not the master consumer pact)

tjones
2021-09-17 16:00
What does the matrix say for master consumer vs master provider? If that is green, then perhaps your can-i-deploy check is not set up correctly?

bbleach
2021-09-17 16:00
So perhaps one of the things that I'm doing wrong is that in order to block the merges of the consumer feature branches to master, I'm using `can-i-deploy --to master` after publishing the pact, in the consumer pipeline.

tjones
2021-09-17 16:01
that sounds right to me

bbleach
2021-09-17 16:02
sorry that screen shot is not that useful, but the consumer is on the left and provider on the right. A grey tag here means that a newer version of the provider exists with the master tag, and this I believe is why the can-i-deploy step is timing out

tjones
2021-09-17 16:03
Hmm. Which can-i-deploy is timing out?

tjones
2021-09-17 16:03
the one for that feature branch?

bbleach
2021-09-17 16:03
Yes the feature branch one

bbleach
2021-09-17 16:03
in the consumer

tjones
2021-09-17 16:04
Right. So, possibly the latest provider is not verified against that consumer's pact

tjones
2021-09-17 16:05
if you haven't seen them already, these diagrams might be helpful:


bbleach
2021-09-17 16:08
Yes I think so. I think its because in between the first consumer pipeline run and the second (which triggered no verification), something was merged to the provider master. This triggered a verification but not for the version of the pact in the consumer feature branch. Which means that as you say latest provider is not verified against that consumer's pact. Triggering a verification on pact publish rather than pact change would fix this but doesn't seem right.

bbleach
2021-09-17 16:09
When the provider verifications run (either on master or feature branch), should they run against 'master' pacts, or somehow pick up the feature branches pacts too?

tjones
2021-09-17 16:10
ahhh... maybe it doesn't count as a WIP pact because it has been verified, so it's not picked up?

bbleach
2021-09-17 16:11
yeah it won't be wip because the first consumer run verified it thats right

tjones
2021-09-17 16:12
I think this is the situation:

bbleach
2021-09-17 16:12
yeah thats my understanding too

bbleach
2021-09-17 16:12
just not sure how to resolve it in CI (without changing the verification to happen on pact publish)

tjones
2021-09-17 16:13
Cool. I think with the feature branch approach, maybe you'll want some way of saying "can you verify this because I want to merge it"

bbleach
2021-09-17 16:13
for reference this is the can-i-deploy command I'm using in the consumer pipeline, after the publish ```pact-broker can-i-deploy --pacticipant $PACT_CONSUMER_NAME --version $CI_COMMIT_SHORT_SHA --to master --retry-while-unknown=20 --retry-interval=30 --broker-base-url $PACT_BROKER_URI --broker-token $PACT_BROKER_BEARER_TOKEN"```

tjones
2021-09-17 16:14
> without changing the verification to happen on pact publish Is this so bad? I think it's what I would do if I had a branch strategy like this

bbleach
2021-09-17 16:16
No its not so bad, just will run a lot more jobs as this strategy will be used by lots and lots of micro-services. Plus I just wanted to check as everything in the docs mentions using the pact changed event.

tjones
2021-09-17 16:16
I should turn in here, but I'll check back in the morning. This feels like there will be an easy solution

bbleach
2021-09-17 16:16
No problem. I appreciate all your help and time! :pray:

tjones
2021-09-17 16:18
You're welcome! I'd like to improve the docs with specific recommendations for different branch / CI setups - it's hard because the right setup is different for different styles of deployment / branching / CI. But also there can't be that many combinations of choices out there

tjones
2021-09-17 16:19
A few years ago I think we did a setup with a completely separate verification pipeline - which was triggered on pact publish or on provider build

bbleach
2021-09-17 16:20
No i agree. If I do this on pact publish it will solve the problem for sure. Here I'm only branching from master and the next step would be to gate the deployments with can-i-deploy too. If that works as expected then you could apply the same strategy to a git-flow style setup as well.

tjones
2021-09-17 16:20
That worked fairly well, but we didn't get to the kind of scale that it sounds like you have, so ymmv

bbleach
2021-09-17 16:20
I have moved the verification to a separate pipeline too actually

tjones
2021-09-17 16:20
tbh, I've not tried gating merges with can-i-deploy, but I think it's a great idea

bbleach
2021-09-17 16:20
but scaling is on my mind haha :slightly_smiling_face:

aftab.shamim2020
2021-09-20 06:46
@matt.fellows Hello, can we write contract testing for background kafka service in .net if yes, give me some idea.

matt.fellows
2021-09-20 10:04
This is referred to as message oact. Please ask in #pact-net, support is being added in the latest beta

dimundo
2021-09-20 12:39
hi! i have (n-th) question about tags https://docs.pact.io/pact_broker/tags/#when-verifying-pacts ```const opts = { ..., consumerVersionTags: ['master', 'test','production'], }``` but this will fail build, when production is not compatible with master, no ?

rushideshpandes
2021-09-20 13:11
has joined #general

gemhar
2021-09-20 14:33
has joined #general

jsegall
2021-09-20 21:37
has joined #general

tjones
2021-09-21 01:55
Another pending pacts question - can we say these pacts are pending, but these ones aren't? Eg, if I want incompatibility with `master` to fail the build, but incompatibility with `prod` is ok?

dotelnp
2021-09-21 07:29
Hi Matt. Did this get postponed? Or we're in the wrong link, please help

matt.fellows
2021-09-21 11:26
Hi Richard, there was an issue with the zoom link (the ID in the calendar invite was incorrect)

matt.fellows
2021-09-21 11:27
Did you manage to make it? Very sorry if not, we will be sending out the recording if that's any consolation. I sent an update to all registered attendees after the workshop

dalkire
2021-09-21 13:30
has joined #general

hakan.celebi
2021-09-21 19:43
has joined #general

bethskurrie
2021-09-21 22:42
Can you explain the scenario more Tim?

bethskurrie
2021-09-21 22:42
Feedback on a potential rename of the "pending pacts" feature please https://github.com/pact-foundation/pact_broker/discussions/507

dotelnp
2021-09-22 03:18
No, I didn't get the correct link. Waiting for the recording now.

tjones
2021-09-22 07:04
If we have developers running the pact tests, we want the pact they're woking on to be reported correctly, and it's useful to not have to muck with the config in order to do this

nrobison
2021-09-22 15:39
has joined #general

calise
2021-09-22 17:06
has joined #general

sams.prashanth
2021-09-22 18:21
Do we support wsdl file as a pact in bi-directional approach? (like OpenApi spec)

matt.fellows
2021-09-22 20:39
Not at the moment sorry Prashanth

matt.fellows
2021-09-22 20:40
It's a plausible scenario though

sams.prashanth
2021-09-23 06:43
ah okay @matt.fellows

matt.fellows
2021-09-23 06:45
Let's talk next catch up. It's possibly even more important with WSDL because they are usually more brittle

matt.fellows
2021-09-23 06:45
How big of a portion is it of your systems?

matt.fellows
2021-09-23 06:46
I'd also be keen to know if others have this challenge!

sams.prashanth
2021-09-23 06:48
Got stuck with multiple services in this old model; Over 300 services :disappointed:

sams.prashanth
2021-09-23 06:49
We have multiple systems and those are a part of it

sams.prashanth
2021-09-23 06:51
aha just an update... it's 800+ services


sams.prashanth
2021-09-23 07:16
Nice!

sams.prashanth
2021-09-23 08:06
@matt.fellows apart from OpenApi spec, what other files / formats do we support at the moment?

matt.fellows
2021-09-23 08:16
Just OAS/Swagger at the moment Prashanth

matt.fellows
2021-09-23 08:16
Feedback (like the above) is what we?re going to use to prioritise our roadmap

matt.fellows
2021-09-23 08:16
the current work is about getting the UI designs completed and implemented

matt.fellows
2021-09-23 08:17
that will be a consistent pattern across different contract types

matt.fellows
2021-09-23 08:17
actually, if that?s something you or a key member of the team would like to chat about, @slin would love to chat :slightly_smiling_face:

sams.prashanth
2021-09-23 08:21
Makes sense. And thank you - would be nice to have this feature. Sure, will connect with her as a team on this.

matt.fellows
2021-09-23 08:43
(I?ve also shared with the team, we?ll discuss at the next feature pow wow)

sams.prashanth
2021-09-23 08:45
Thank you Matt!

nareshnavinash
2021-09-23 09:28
has joined #general

radu.simu
2021-09-23 09:38
has joined #general

aterrong
2021-09-23 09:42
has joined #general

nisharaveendran30
2021-09-23 10:34
has joined #general

sujithsukumaranm
2021-09-23 10:36
has joined #general

sureshbabudevaki
2021-09-23 12:01
has joined #general

sujithsukumaranm
2021-09-23 12:19
Thank you for the workshop today. Had these questions. 1. Where should the Contract testing sit in the Tests Pyramid. I mean is it a subset of Integration tests or the other way. 2. I believe Consumers are expected to write their tests against the Pact, right ? Is there any best practice to make the Consumer contribution to tests not mess with each other. 3. What does the Pact broker commercial version offer more compared to open source.

greg.hinsley
2021-09-23 12:29
has joined #general

matt.fellows
2021-09-23 12:38
1. Contract testing is a type of integration testing, I would say


matt.fellows
2021-09-23 12:39
2. > Is there any best practice to make the Consumer contribution to tests not mess with each other. I?m not sure what you mean here. Do you mean if different consumers had different expectations on the provider? In practice, I?ve not really experienced this. If there is a conflicting (or indeed, just a bad request from a consumer) the provider has final say on the matter.

matt.fellows
2021-09-23 12:40
3. You can see the major commercial features/differences here: https://pactflow.io/features

matt.fellows
2021-09-23 12:40
(one new albeit beta feature is bi-directional contracts, which currently allows you to work with OAS, and we?ll be extending to other types over time: https://docs.pactflow.io/docs/workshops/bi-directional)

nyman.robin
2021-09-24 07:07
has joined #general

ricardo.paquito
2021-09-24 10:36
has joined #general

abramenkov.valentin
2021-09-24 12:42
has joined #general

leo.tang
2021-09-24 17:56
has joined #general

jyotiguptaofficial
2021-09-25 13:00
has joined #general

jyotiguptaofficial
2021-09-25 13:06

mattandaey
2021-09-25 20:32
has joined #general

sams.prashanth
2021-09-27 07:50
@matt.fellows In bi-directional approach, when does the cross-contract-verification actually happens? *Scenario:* 1. I push `consumerA` pact to the pactflow for `providerA` (this happens in the consumer-driven approach) 2. Then I push `ProviderA`'s OpenAPI spec to the pactflow > I assume the cross-contract verification process happens immediately after I push the OpenAPI spec to the pactflow - am I right here? or does the verification happens when I hit the can-I-deploy cmd?

matt.fellows
2021-09-27 08:12
It happens during the `can-i-deploy` stage

matt.fellows
2021-09-27 08:13
See step4 on both sides of the contract at https://docs.pactflow.io/docs/workshops/bi-directional/#steps


sams.prashanth
2021-09-27 09:17
Thank you @matt.fellows

sams.prashanth
2021-09-27 10:18
One more use-case that needs clarification *Scenario:* 1. I push 3 interactions(tests) in a `consumerA` pact to the pactflow 2. Then I push `ProviderA`'s OpenAPI spec to the pactflow 3. And I hit `can-i-deploy` cmd 4. Now, there is a failure which is intentional and so I open the verification result link in HAL browser for evaluation - During evaluation, I see that the test got stopped abruptly on finding a failure in the first interaction itself. It is not moving to the next interaction for further validations of the remaining 2 interactions. (It's more like assertion and not verification; but I expect all the remaining interactions to be validated as well)

tjones
2021-09-27 10:19
Hi Prashanth, You don't need to tag maintainers directly here - someone will see your question and get back to you when they can. Also it looks like this is a question better asked in #pactflow

sams.prashanth
2021-09-27 10:20
ah okay @tjones; makes sense. Sorry for that.

tjones
2021-09-27 10:20
No worries :slightly_smiling_face:

sujithsukumaranm
2021-09-27 12:28
Thanks Matt. I will check these.

saurelio58
2021-09-27 12:39
has joined #general

francisco
2021-09-27 18:27
has joined #general

matt.fellows
2021-09-27 21:42
Thanks for raising Prashanth, I'll pass onto the team

matt.fellows
2021-09-27 21:43
This is probably interesting to a broader audience: learn how M1 Finance rolled out Pact in tomorrow's AMA https://pact-foundation.slack.com/archives/C01RPBC2KNG/p1632778200022600

sams.prashanth
2021-09-28 06:33
Thank you @matt.fellows

constantin.jaeck
2021-09-28 07:38
heyho, does pact have a CLA? Couldn't find anything in the contributing.md of (in my case) pact-jvm :slightly_smiling_face:

tjones
2021-09-28 07:55
What does CLA stand for?

tjones
2021-09-28 07:55
(My google search for CLA was .... less than enlightening)



tjones
2021-09-28 07:58
(that surprised me, I thought most of our projects were under the MIT license)

tjones
2021-09-28 07:59
If this is not what you're looking for, how is what you *are* looking for different, and should we get one?

constantin.jaeck
2021-09-28 08:36
yes I mean the first wikipedia link

constantin.jaeck
2021-09-28 08:36
no that's not the license


matt.fellows
2021-09-28 08:49
We talked about it a while back but don't yet have one

matt.fellows
2021-09-28 08:50
Are you concerned about your rights or more just wanting to know the process?

matt.fellows
2021-09-28 08:51
Most are MIT Tim, I can't recall why JVM is not

constantin.jaeck
2021-09-28 09:20
No, so I personally don't care but I'd like to contribute in my work time and my company has a ... big ... legal department

constantin.jaeck
2021-09-28 09:21
and they wanted to know if there is a CLA. If everything is covered by the licence I'm good

matt.fellows
2021-09-28 10:16
Yep it is

jamesatroughton
2021-09-28 10:42
has joined #general


jake.thacker
2021-09-28 22:06
has joined #general

craig.schwarzwald
2021-09-28 22:37
has joined #general

tjones
2021-09-29 03:58
I think we'd be happy to bring one in if not having one was blocking contributors. I like the MIT license because it's permissive and straightforward - from my perspective, anything contributed to pact is already under that license, regardless of where it came from.

tjones
2021-09-29 04:00
There's kind of a downside, which is I personally would be pretty annoyed if someone took all the hard work everyone has put into pact and bundled it behind a closed commercial project (which is technically allowed under the MIT license). I really like the approach that has been taken with Pactflow, which is to value-add, with enterprise grade features (and fairly significant contributions back to the OSS side of the project). If there's something we can do as the pact-foundation to encourage any other commercial operations to be like Pactflow, I think that's a win.

tjones
2021-09-29 04:00
Perhaps that's through a Pact trademark? I'm not sure.

saurelio58
2021-09-29 11:59
Is anyone using Pact & Quarkus? I posted in #pact-jvm a couple days ago and have no responses. Trying here now. https://pact-foundation.slack.com/archives/C9UN99H24/p1632767424240500

owain.hunt
2021-09-29 12:58
has joined #general

matt.fellows
2021-09-29 13:30
@daniel.kalleward was I think, any ideas?


damtsisa
2021-09-30 06:58
has joined #general

morsisdivine
2021-09-30 09:23
has joined #general

artur
2021-09-30 09:37
I had to give a very spontaniuos talk about pact on the owncloud conference. I hope I did not say too much rubbish https://youtu.be/6RWGKRSoOI8?t=1190

tjones
2021-09-30 10:45
This was great! Nice work!

matt.fellows
2021-09-30 13:46
Indeed, I'll pop it on the case studies page tomorrow for others to discover!

patrice.jy.thomas
2021-09-30 15:05
has joined #general

saurelio58
2021-09-30 16:08
@matt.fellows Thanks for the replies. Somehow Slack did not notify me of your posts.

saurelio58
2021-09-30 16:10
I found a link to a working example at https://github.com/skattela/pact-workshop-jvm-quarkus in the post you referenced. The issue is that the example if VERY basic. There is no @State code or @Inject. The @Inject is what is causing my problems as the reference is null. At this time I believe the issue needs to be resolved by Quarkus.

kschendster
2021-09-30 16:46
has joined #general

adam.dubnytskyy
2021-09-30 17:49
has joined #general

stefano.varesi
2021-09-30 17:51
has joined #general

steven.yi
2021-09-30 20:17
has joined #general

matt.fellows
2021-09-30 21:15
Np. Sorry I can't give any more advice. Hope you get to the bottom of it!

calcorbin
2021-09-30 23:09
has joined #general

calcorbin
2021-09-30 23:10
Hi all! I'm learning how to contribute to open source. I've created a small PR that updates documentation if anyone would like to take a look and review here: https://github.com/pact-foundation/docs.pact.io/pull/91

calcorbin
2021-09-30 23:11
This is for Hacktoberfest btw

bethskurrie
2021-09-30 23:12
do you want to tag it for credit?

bethskurrie
2021-09-30 23:12
I can't remember what the tags are

calcorbin
2021-09-30 23:12
Ahhh sure thing!

bethskurrie
2021-09-30 23:13
just googled. looks like I have to do it.

bethskurrie
2021-09-30 23:13
done

calcorbin
2021-09-30 23:13
oh my bad! for some reason I thought you were all were already tagged. didnt mean to create work for you!

calcorbin
2021-09-30 23:13
thank you!!

bethskurrie
2021-09-30 23:14
I meant, the PR needs a label for it ot be accepted, not tag, sorry

bethskurrie
2021-09-30 23:14
either way, it's done

bethskurrie
2021-09-30 23:14
thanks!

calcorbin
2021-09-30 23:14
gotcha, thank you :smile:

bethskurrie
2021-09-30 23:15
are you looking for more things?

calcorbin
2021-09-30 23:17
I am! Every bug I find is already fixed :disappointed:

bethskurrie
2021-09-30 23:17
what are your languages of interest?

matt.fellows
2021-09-30 23:17
> oh my bad! for some reason I thought you were all were already tagged. didnt mean to create work for you! It?s a good reminder. The main projects should have the tags already


calcorbin
2021-09-30 23:18
Javascript, HTML, css, and Python are my preferred, Ruby works too.

bethskurrie
2021-09-30 23:18
it's not a bug, but it's a valuable task.

calcorbin
2021-09-30 23:18
Sweet, I'll dig into it

matt.fellows
2021-09-30 23:18
Documentation is so important for us, so don?t underestimate it

bethskurrie
2021-09-30 23:18
There's no details on that issue, so I can flesh it out if you think you might pick it up.

bethskurrie
2021-09-30 23:19
It would be a manual migration, but there aren't many blog posts.

bethskurrie
2021-09-30 23:19
there may even be an API

calcorbin
2021-09-30 23:20
Gotta feed my toddler and put him to bed. I'll look into the migration once he's asleep. Thank you all!

matt.fellows
2021-09-30 23:20
:point_up: one of us :laughing:

bethskurrie
2021-09-30 23:20
Just had a look, and there are literally 9 public blog posts :laughing:

matt.fellows
2021-09-30 23:21
On the docs, not sure if it is of interested but it might in fact be the current most important thing - if you?re up for trying to create a getting started guide that can have language code toggles so that anybody new to pact can step by step their way through a basic consumer and provider test, and then work through the nirvana guide using the Pact CLI tools (publish pact, record deployments, run can-i-deploy). That would be :sparkles:

calcorbin
2021-09-30 23:22
Cool, I'll look into it. I have some friends looking for PRs as well so I'll let them know.

bethskurrie
2021-09-30 23:22
thanks!

calcorbin
2021-09-30 23:32
@bethskurrie I'll go ahead and pick this up: https://github.com/pact-foundation/docs.pact.io/issues/54 Just going to need some more details about the migration.


tjones
2021-09-30 23:41
(if you want to do some code)

calcorbin
2021-09-30 23:43
oooooo, thats right up my alley

tjones
2021-09-30 23:43
I just put the hacktoberfest label on it, let me know if it needs anything else

calcorbin
2021-09-30 23:43
That should be it

calcorbin
2021-10-01 01:36
@tjones here you go! I took the issue pretty literally, so don't hesitate to let me know if you want any changes. https://github.com/pact-foundation/pact-js/pull/753 Also, if everything looks good- would you mind adding the hackertoberfest label to the PR?

tjones
2021-10-01 01:36
Wow! Amazing

tjones
2021-10-01 01:36
I'll take a look at lunch. Thank you very much!!

osikwemhev
2021-10-01 01:45
has joined #general

dimundo
2021-10-01 06:05
hi! having `Error making request - OpenSSL::SSL::SSLError SSL_connect returned=1 errno=0 state=error: certificate verify failed , attempt 1 of 3` > PACT_BROKER_DISABLE_SSL_VERIFICATION: true > PACT_DISABLE_SSL_VERIFICATION: true doesnt help :disappointed: broker docker version 2.86.0.1



dimundo
2021-10-01 07:26
cc @bethskurrie

matt.fellows
2021-10-01 09:04
The standalone may have this problem because it bundles a ruby runtime that may have an outdated CA

matt.fellows
2021-10-01 09:04
Docker should be fixable because it can use a new runtime

dimundo
2021-10-01 09:05
```pactfoundation/pact-cli:latest``` docker image also needs updates :disappointed:

dimundo
2021-10-01 09:05
everyone waited y2k issues by waterfall, and everyone fixing 30.09 by agile :disappointed:


kentaro
2021-10-01 10:05
has joined #general

vitali.domashkevitsh
2021-10-01 10:08
has joined #general

dimundo
2021-10-01 10:37
should standalone be bumped everywhere ?

seb983
2021-10-01 11:30
has joined #general

philipchardwick
2021-10-01 14:15
I'm getting this too

philipchardwick
2021-10-01 14:15
the pact-cli image worked for us - it's just the standalone which doesn't

dimundo
2021-10-01 14:20
image pact-cli it was updated recently

vannessa.andrade
2021-10-01 14:44
has joined #general

dimundo
2021-10-01 16:06
just fyi - found issue in local network between k8s. at same time ingres and dns were changed, so some combo kicked us

dimundo
2021-10-01 16:06
harold

mickfagan
2021-10-02 10:36
has joined #general

tjones
2021-10-03 13:57
@bethskurrie: These `next steps` bits are *awesome*!!

maxim.matviyuk
2021-10-03 16:48
has joined #general

jonathan.a.stern
2021-10-03 20:38
has joined #general

chris.ramsden
2021-10-04 16:40
has joined #general

brian.fung
2021-10-05 04:57
has joined #general

elekberhacizade
2021-10-05 05:27
has joined #general

bethskurrie
2021-10-05 06:32
Branch docs out - https://docs.pact.io/pact_broker/branches/ Still rolling out support for branches in all the pact clients. Takes a while when there are 10+ languages!

bethskurrie
2021-10-05 06:32
IKR! There will be more steps in there when I get time.

bethskurrie
2021-10-05 06:33
Once you get the webhooks and the verification results, it will start hassling you to record deployments and use can-i-deploy.

scott.riley111
2021-10-05 09:10
Is https://docs.pact.io/pact_broker/branches/#support our best place to track progress?

ankit.wadhwana
2021-10-05 12:23
has joined #general

zhaopeng
2021-10-05 12:24
has joined #general

bjorn.johansson
2021-10-05 13:16
has joined #general

pcting
2021-10-05 18:57
has joined #general

aulia.ahn
2021-10-06 00:01
has joined #general

muralis
2021-10-06 01:21
has joined #general

lakapoor777
2021-10-06 08:47
has joined #general

garry.jeromson973
2021-10-06 09:52
has joined #general

anagha.sulakhe
2021-10-06 16:27
has joined #general

mesut.gunes
2021-10-07 09:03
has joined #general

bethskurrie
2021-10-07 23:49
Does anyone have/know of a publicly accessible letsecrypt server that recently became unaccessible with the latest root certificate expiry?

bethskurrie
2021-10-07 23:49
Just trying to test that the cert upgrade I've made to the pact-ruby-standalone has fixed the issue.

bethskurrie
2021-10-07 23:49
@scott.riley111 yes

scott.riley111
2021-10-08 08:51
:thumbsup: great, thanks

vandana.bhaskersen
2021-10-08 09:58
has joined #general

matt.fellows
2021-10-08 12:05
If there is anybody participating in hacktober that is keen to help, this is a simple but nice https://github.com/pact-foundation/pact-python/issues/270

ad.redouani
2021-10-09 15:11
has joined #general

amulyadoss
2021-10-09 21:09
has joined #general

farshad.falaki
2021-10-10 19:13
has joined #general

jhopkinwilliams
2021-10-12 02:01
has joined #general

josephhaig
2021-10-12 08:52
has joined #general

margarita.lukjanska
2021-10-12 10:12
has joined #general

oak155online
2021-10-12 14:17
has joined #general


bethskurrie
2021-10-13 06:07
Ok, the one time I wanted that link to expand!

bethskurrie
2021-10-13 06:16
Another new blog post - new and improved webhook event :tada: https://docs.pact.io/blog/2021/10/11/contract-requiring-verification-published-webhook-event/ :tada:

filipovic
2021-10-13 06:51
has joined #general

stefan.smith
2021-10-13 09:37
has joined #general

yann.courtel
2021-10-13 12:43
Thanks a lot!

yann.courtel
2021-10-13 12:45
That's awesome @tjones! Permission to use it :)

tjones
2021-10-13 13:27
It's not mine - it's built in to the pact publisher in the ruby binaries

yann.courtel
2021-10-13 13:39
@bethskurrie deserves all the credit then :slightly_smiling_face: good thinking though

v-ratngupta
2021-10-13 15:40
i'm using pact plugin with maven so is there any way to pass authorization token through mvn pact:verify command

v-ratngupta
2021-10-13 15:41
like how can i add authorisation token in request header of each request at the time of verification task

v-ratngupta
2021-10-13 15:43
as like we have in python '--custom-provider-header'

warren
2021-10-13 16:45
has joined #general

michael.stein
2021-10-13 19:02
has joined #general

hwillj
2021-10-14 14:52
has joined #general

fengniy
2021-10-15 02:09
has joined #general

bethskurrie
2021-10-15 04:39
Thanks @yann.courtel. We're trying to take the approach of having the tool guide you through using it effectively. It's a new mindset, and I hope it will make pact a better tool to use as we start rolling ideas like this out across other things.

yann.courtel
2021-10-15 09:13
@bethskurrie That's actually a similar concept we are teaching in our organization with devs, your code *is* your documentation :slightly_smiling_face: here the output guides you from point A to B. Keep up the good work!

mark.dathorne
2021-10-15 09:51
has joined #general

haroldlearning93
2021-10-15 14:49
has joined #general

vsrungar95
2021-10-15 22:14
has joined #general

haroldlearning93
2021-10-16 02:42
is there a way we can check if the local pact-files has no changes(no changes happens when ofcourse we dont update the contract tests) in the Consumer? right now my initial implementation in our gitlab config is to just public pacts but this doesnt make sense when there are no changes in the pacts and this also triggers the webhook on the Provider side

tjones
2021-10-16 02:44
You don't generally need to - because the broker hashes the pact and will realise that it hasn't changed.

tjones
2021-10-16 02:44
You still want to publish the pact even if it hasn't changed, because your version will have changed. So you need to tell the broker the version + contract pairing

haroldlearning93
2021-10-16 03:00
thanks, so it looks fine but Is there a way not to trigger the webhook if nothing changed?

tjones
2021-10-16 03:08
I'm not sure. I'm not too familiar with the webhooks. It sounds like you might be hooking the "contract published" event, but you probably want the "contract content changed" event


jsoto128
2021-10-16 20:45
has joined #general

fiszczu
2021-10-17 17:04
has joined #general

bethskurrie
2021-10-17 21:43
@haroldlearning93 if you don't think you've changed the pact, but the webhook is still triggering, you may have non-deterministic data in your pact

bethskurrie
2021-10-17 21:43
Or, you're applying new tags to the content.

bethskurrie
2021-10-17 21:44
Hey pact users! People find the "pending pacts" feature very confusing, and one of the reasons is that the name doesn't tell you what it does. I'm considering renaming it from "pending pacts" to "smart fail". Would love to hear any thoughts on this (or an even better name suggestion) here https://github.com/pact-foundation/pact_broker/discussions/507

bethskurrie
2021-10-17 22:04
There is a new webhook event which removes unnecessary builds however - you should have a look at this https://docs.pact.io/blog/2021/10/11/contract-requiring-verification-published-webhook-event


haroldlearning93
2021-10-18 00:30
Thanks @bethskurrie I have read above and so does this mean we just need to update from event `contract_content_changed` to `contract_requiring_verification_published` ?


bethskurrie
2021-10-18 00:32
You also need to be doing what the docs say here:

bethskurrie
2021-10-18 00:32
```Use of this webhook requires that: * the provider's main branch is configured * verification results are published with the branch property or you are tagging with the branch name and have automatic branch creation turned on (even if you use trunk based development, and only ever use one branch) * the exact commit of a provider version can be determined from the version number used to publish the verification results (ie. it either is the commit, or contains the commit as per the Pact Broker version number guidelines)```

brocheleau
2021-10-18 03:23
has joined #general

matt.fellows
2021-10-18 03:59
:taco: for both @mike.geeves064 for ~taking the bait~ picking this up, and to @elliottmurray for collaborating Half way into hacktoberfest!

tjones
2021-10-18 06:32
Yes! :taco: for @mike.geeves064 !!

mike.geeves064
2021-10-18 06:36
(I mean it's still not quite finished after getting a bit bigger than intended and I'm only moderately confident the actual changing if variable name was done :grinning:)

andrerc
2021-10-18 22:11
has joined #general

rodolfo.valenzuela
2021-10-19 07:43
has joined #general

v-ratngupta
2021-10-19 08:48
Can I skip a particular provider state at the time of pact verification execution? like in my pact file I have 10 interactions and I want to skip an interaction or a provider state

matt.fellows
2021-10-19 10:18
Hi Ratnesh, yes most likely, but please ask in the relevant language channel (e.g. #pact-jvm ). Thanks!

v-ratngupta
2021-10-19 10:19
okay

vuttithatkrongyot
2021-10-19 19:08
Is there any suggestion for naming convention of Consumer and Provider ? Let say I have Consumer A and Provider X. A using 5 APIs from X and I want one contract file store only one API, so that I can have 5 files separately. Right now i'm using "{consumer-service-name}_{http-method}_{api-path}" to separate each API in pact broker. Is there another suggestion? or I shouldn't separate it? Thanks

matt.fellows
2021-10-19 21:28
Why do you want them in separate files?

kamilyrb
2021-10-19 22:31
has joined #general

vuttithatkrongyot
2021-10-20 06:40
To make it not seems big in just one file. Sometimes one consumer call 8 APIs from one provider and each APIs have around 2-3 interactions so, it will be so big in terms of PactDSL code and Pact Contract file.

matt.fellows
2021-10-20 06:47
the contract file is separate to your tests. There is an exceptional way to upload multiple files to the broker, but it?s definitely not the standard way and I?d advise against it unless you have a good reason to do so (the above is not a good reason to). The tests can be split across multiple files, that is a separate issue to where the interactions go afterwards (which is, a single contract file)

vuttithatkrongyot
2021-10-20 06:58
I see, so in this case I can have multiple tests file with the same consumer and provider name, am I correct?

matt.fellows
2021-10-20 07:01
The answer should be yes, but will depend on your language and other mix of frameworks

matt.fellows
2021-10-20 07:01
best to ask in the language specific channel

marcelo
2021-10-20 14:23
Hey guys :wave: Somebody is facing the next issue? I have everything setup in CI/CD pipelines, using webhooks I run the pacts verifications whenever a pact is changed and then I run Can I deploy command. The problem is that sometimes the pact verification takes longer than expected and the Can I deploy fails

paulorochag
2021-10-20 15:28
use the 'retry-while-unknown' and 'retry-interval' commands to ensure that the contract test run by the webhook has finished. Example (I have to translate this repository to English): https://github.com/PauloGoncalvesBH/nirvana-teste-de-contrato/blob/09a24ca4e177ac9e0c1d9fdc3e789d4abc2009af/.github/workflows/consumer-ci.yml#L38

zhaopeng
2021-10-20 19:17
Hey guys, I maybe got a stupid question, should I upload contract for dev branch? case #1: I have my branch feature/test1 in *consumer*, which will break exist verified contract but it's intend, should I publish this contract? should I merge into master? case #2: I have my branch feature/test2 in *producer*, which will also break exist verified contract but it is intend, should I publish this contract? should I merge into master? case #3: I have branch feature/test3 in *consumer*, it requires new contract from producer? should I publish contract before merge? or I should publish contract after merge into master? case #4: I have branch feature/test4 in *producer*, it add new fields which is not used by any consumer, should I publish contract before merge? or I should publish contract after merge into master? I was confused between "merge" and "can-i-deploy" Thanks in advance

joel.whalen588
2021-10-20 20:27
has joined #general

matt.fellows
2021-10-21 00:10
Hi, these are common questions. I?d take a run through our https://docs.pactflow.io/docs/workshops/ci-cd/ which goes through the typical scenarios and then come back if you have questions. You always publish contracts no matter what branch/feature is being worked on. Features/concepts such as *tags, branches, environments* can be modelled into the system and helps migrate changes into production. You can always deploy changes to a provider that are additive, i.e. new features/fields can always be merged so long as you don?t break any consumers.

garry.jeromson973
2021-10-21 07:58
Question to the floor: has anyone set up pact verification between a consumer and a provider where there?s an API gateway in between? Any tips for strategies? Reasoning: in many cases, an API gateway can potentially modify responses, so it?s a part of the chain that can?t be ignored; however, it doesn?t make much sense to verify directly against the gateway itself as a provider, since it has very limited behaviour. What we?ve been doing up until now is spinning up both the API gateway and the provider during pact verification (using Docker Compose), and pointing the pact mock consumer client at the gateway so that it?s included in the verification process. Curious if anyone has come against the same issue, and what they ended up going with.

matt.fellows
2021-10-21 08:07
Everything you just said has come up before and your thinking sounds reasonable to me

matt.fellows
2021-10-21 08:08
I'd avoid a contract with the gateway directly off though can't avoid it, little value there

matt.fellows
2021-10-21 08:08
We should put up an article about that

zhaopeng
2021-10-21 08:22
great! I will go first with that, thanks @matt.fellows

garry.jeromson973
2021-10-21 08:41
Would be happy to assist with that if it?d help

vasil.vasilev
2021-10-21 08:41
has joined #general

mike.geeves064
2021-10-21 09:04
What's best practice there then? It sounds almost like you would have two layers, of a contract between consumer and GW then between GW and provider, but that does not sound pleasant to work with :open_mouth: little value as you say

garry.jeromson973
2021-10-21 09:21
The contract is really between the consumer and the? shall we call it, _combined provider_ of the API gateway and the backend service

garry.jeromson973
2021-10-21 09:22
(There?s definitely a better way to phrase that)

garry.jeromson973
2021-10-21 09:23
But the main point is that there?s only one contract, rather than two - as you say, two layers of contracts have little value

garry.jeromson973
2021-10-21 09:25
The main source of complication comes from authentication, at least in our experience. We?re using KrakenD as an API gateway, which is essentially a black box for the purposes of the pact verification - there?s no possibility to mock out authentication using provider states, so real authentication has to occur. This means setting up the pact mock client with a valid JWT, which is a bit funky since it touches an external system.

mike.geeves064
2021-10-21 09:26
:open_mouth:

mike.geeves064
2021-10-21 09:27
Yeah, authentication is a pain :grinning:

mike.geeves064
2021-10-21 09:29
Maybe if there's a very specific transformation that could be mocked and injected for tests somehow?

garry.jeromson973
2021-10-21 09:31
Interesting idea! Would involve somehow keeping the tests and API gateway config in sync though, could get juicy

garry.jeromson973
2021-10-21 09:33
But no more juicy than pulling the API gateway image, obtaining a valid JWT, etc.

garry.jeromson973
2021-10-21 09:38
The more I think about, the more I think you may be onto something there: in _theory_ it?d be possible to parse the API gateway config and generate a mock transform that runs in the pact verifier process..

garry.jeromson973
2021-10-21 09:39
complicated

garry.jeromson973
2021-10-21 09:39
Not really a generic solution though

mike.geeves064
2021-10-21 09:45
You could define that as a single contact maybe?

mike.geeves064
2021-10-21 09:46
As in have one place verifying that your gateway "provider" does something expected as a transformation

mike.geeves064
2021-10-21 09:46
And reuse the method as a shared function elsewhere can pull in for tests?

mike.geeves064
2021-10-21 10:16
:thinking_face: I've used dummy services to implement an interface and do some sort of echo back to debug and test against, that worked pretty well

ben.crinion
2021-10-21 11:09
has joined #general

estephania.calvo
2021-10-21 19:27
has joined #general

boris.gordon
2021-10-21 22:23
Not sure if this is a broker question or what but I have a question around how the various tooling decides if a pact has changed. If I use DSL without providing examples, every time the consumer tests are run I can get a different pact file (e.g. we have some enum stringMatchers) for effectively the same contract but if I provide examples for everything the generated pact is stable which makes sense of course. Does the tooling compare the contents of the file or will it ignore the examples and only compare the contract part?

tjones
2021-10-21 22:25
Pact can't know what parts of your payloads are generalisable and what aren't unless you tell it

boris.gordon
2021-10-21 22:26
Cool that?s what I wanted to know. So it will basically git diff the pact file?

boris.gordon
2021-10-21 22:27
I?m wondering how broker reasons about ?there is new contract content?

tjones
2021-10-21 22:27
the generation process should be deterministic though, I don't know why you're seeing a non deterministic build

boris.gordon
2021-10-21 22:28
oh really? even if I don?t provide examples for every property etc.?

tjones
2021-10-21 22:28
The pact broker hashes the contents

tjones
2021-10-21 22:28
I think it's aware of some pact specific things

boris.gordon
2021-10-21 22:28
contents being the pact file basically?

boris.gordon
2021-10-21 22:29
that?s what I assumed

tjones
2021-10-21 22:29
#pact-broker question, probably

boris.gordon
2021-10-21 22:29
Great thanks.

tjones
2021-10-21 22:29
I don't think I understand how you have properties without examples

tjones
2021-10-21 22:29
can you share an example?

boris.gordon
2021-10-21 22:31
jvm dsl for example has example optional: ```.numberType("amount")``` vs. ```.numberType("amount", 1234.56)```

ahmetbcakici
2021-10-21 22:38
has joined #general

matt.fellows
2021-10-22 03:27
Yeah, I would advise against the framework generating examples for you for exactly that reason. You?re spot on Boris

matt.fellows
2021-10-22 03:27
I think that was a feature before the broker added the optimisation to go ?oh, the contract hasn?t changed?

matt.fellows
2021-10-22 03:27
It is a fairly crude diff (it?s a hash of the whole pact file)

matt.fellows
2021-10-22 03:28
(I believe, or at the very least, it doesn?t navigate the tree and ignore values that have generated valuse based on their matchers etc.)

kevin.meiresonne
2021-10-22 07:26
Hi, we are trying to introduce contract testing between a web api (consumer) and an http trigger azure function (provider). However, we are struggling with the provider side. Has anyone got any experience with setting up the provider verification on an http triggered azure function?

matt.fellows
2021-10-22 08:51
Might be worth searching the workspace for azure functions


matt.fellows
2021-10-22 08:52
I?d like to capture the learnings/strategy and pop on the docs site, so anythnig you come up with I?d love to hear about!

abarcadabra
2021-10-22 12:30
has joined #general

harwin1494
2021-10-22 19:04
has joined #general

anindita.ghosh
2021-10-22 23:26
has joined #general

stefan.smith
2021-10-24 17:59
Hi, I'm looking to standardise Pact file publishing and verification in different CI builds spanning Node, Python and PHP repositories. From the docs, it seems using the standalone CLIs might be the best way and would enable access to new features that might not be available in the language-specific wrappers (e.g. branch support). Regarding provider verification, I understand there is a new Rust Provider Verifier CLI and that the Ruby Provider Verifier CLI is considered legacy. What's the best way to retrieve and install the Rust CLI, and easily track newer versions? Relying on the https://github.com/pact-foundation/pact-reference/releases?q=%22Pact+Verifier+CLI%22+NOT+beta means manually tracking and updating the URLs when there's a new release. The https://hub.docker.com/r/pactfoundation/pact-ref-verifier seems to be quite outdated (v0.0.4 vs v0.8.8) but we could easily track `:latest`. Installing via cargo would requires installing `rust` and `cargo` first, then compiling the binary, which takes a little time. Is there any plan to release to OS package repositories like `apt` and `brew`? Regarding publishing Pacts, it seems there is no Rust CLI released yet, although I see there is https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_cli/src/bin/pact-publish.rs. I assume the best thing right now is to keep using the https://hub.docker.com/r/pactfoundation/pact-cli? What's the current recommended practice?

matt.fellows
2021-10-24 22:03
Good question, we could probably clarify that a bit

matt.fellows
2021-10-24 22:05
1. The Ruby CLI is the recommended CLI tool (e.g. for publishing, can-i-deploy etc.) 2. The Rust lib is what gets used in the core of the languages. i.e. the mock server / verifier ultimately are what will be used to do the pact testing (usually via the FFI bindings)

matt.fellows
2021-10-24 22:09
I don?t think the cargo installation is the correct mechanism either. Ideally we provide package specific install targets, but probably a bash script would be a good starting point.

matt.fellows
2021-10-24 22:09
++ we may need to trigger the docker image to build on release of the rust assets

stefan.smith
2021-10-25 06:44
Thanks! I was a bit confused by the advice in https://docs.pact.io/implementation_guides/cli#provider-verifier because it suggests using the Rust Provider Verifier wherever possible, and directly without a wrapper for standardisation across languages in CI. It describes the Ruby Provider Verifier as "legacy" so I assumed there was already an optimal way to install and track the Rust binary.

rajnish.maurya
2021-10-25 06:47
has joined #general

matt.fellows
2021-10-25 07:21
NP. They are separately sectioned as ?CLI? and ?Provider verifier? but I can still see how that could be misconstrued

matt.fellows
2021-10-25 07:22
it does highlight we need some clearer lines though

matt.fellows
2021-10-25 07:22
If you were up for a PR to help with automating the package install, that would be Amazing :sparkles:

stefan.smith
2021-10-25 08:23
:point_up: That may be possible in the medium term. Currently spiking an overall Pact + Pactflow implementation for my org. If we proceed, I can see us looking to optimise pact verification in CI by contributing to the project

stefan.smith
2021-10-25 08:25
On this, I think it's partly because the Ruby Pact Verifier is available in the Pact CLI docker image so there's a historic link that made me think there'd be an equivalent Rust Pact CLI docker image. https://pact-foundation.slack.com/archives/C5F4KFKR8/p1635146508039700?thread_ts=1635098381.037600&cid=C5F4KFKR8

stefan.smith
2021-10-25 08:25
Thanks again for clarifying

matt.fellows
2021-10-25 08:52
Thanks. J think we'll be looking to do a fairly significant documentation overhaul in Q1 2022 but in the meantime will look to make some quick tweaks. Thanks for bringing it attention

alanbos
2021-10-25 10:11
has joined #general

simon.nizov
2021-10-25 10:55
Hi, the latest published Pact CLI docker image seems to be a bit outdated. The `provider-version-branch` option is missing in the `verify` command. This can be easily seen when running `docker run --rm pactfoundation/pact-cli:latest verify --help` . BTW it?s also missing in the the pact-provider-verifier https://github.com/pact-foundation/pact-provider-verifier

kuzmanovid
2021-10-25 13:59
has joined #general

j.malyjasiak
2021-10-25 14:24
has joined #general

rtbhosale17
2021-10-25 14:25
has joined #general

stefano.mantini
2021-10-25 14:31
has joined #general

r.muthukumar136
2021-10-25 14:59
has joined #general

gravis54
2021-10-25 21:46
has joined #general

misha.antipenko
2021-10-25 21:57
has joined #general

adomanski
2021-10-26 10:43
has joined #general

joaoproenca
2021-10-26 11:32
hey folks! I'm working more closely with teams that fall on the consumer side of contract testing. Most of what they own are front-end systems that highly depend on a "large" API from the providers side. The thing is, this API is exposed in a unified way but underneath the different endpoints that can be called there's a gateway and routing rules to redirect each endpoint to the corresponding provider service. Matching API endpoints to the corresponding service is: 1. Not trivial to do "from the outside" (only by looking at the routing rules) 2. Not fixed in time. We predict that while today service X is serving requests done to endpoints A, B and C, in the next couple of months X could be refactored into services X1, X2, etc. Up until now the consumer tests have been "seeing" the provider API as unified, which means that the contracts being produced only have one "provider" (edited)  I could go over all the consumer side tests and map the correct providers to the PACT mock servers; but that will be a challenge both in terms of automated testing effort, making the system capable of dealing with several providers at the same time and also hard to deal with in the future due to item 2. So my idea is to leave the tests still considering the API as just one provider and instead splitting the resulting contract into the interactions that pertain to each "real" provider. This centralized tool that would do this could even draw its rules from the routing info we already have and also would be a centralized focal point where changes would be made when services were refactored like in item 2. so my question is... :slightly_smiling_face: Is this a problem you have seen before? And has anyone dealt with it similarly to what I'm describing?

kriegster108
2021-10-26 14:58
has joined #general

matt.fellows
2021-10-26 23:32
I think @bethskurrie fixed this yesterday, mind checking if that?s working?

simon.nizov
2021-10-27 06:27
@matt.fellows @bethskurrie The option is available now but the version is not marked with the provided branch. Here?s the before and after of changing `provider-version-tag` to `provider-version-branch`:

simon.nizov
2021-10-27 06:33
If `use_first_tag_as_branch` is true, is it supposed to override the value explicitly passed in `provider-version-branch`? I thought it only acts as a fallback in case a branch is not passed.

bethskurrie
2021-10-27 06:40
@simon.nizov It's best to use a hardcoded version number rather than `latest` As of yesterday, latest is up to date again - when docker hub stopped giving people free builds, I moved the build into github actions, and forgot to also push to latest.

bethskurrie
2021-10-27 06:42
If you set a branch and a tag, I'd expect both to be there.

simon.nizov
2021-10-27 06:43
Yep, me too

bethskurrie
2021-10-27 06:43
just trying it locally

bethskurrie
2021-10-27 06:45
I get both

bethskurrie
2021-10-27 06:45
```bundle exec bin/pact-provider-verifier \ --provider "Example API" \ --provider-app-version $(git rev-parse --short HEAD | xargs echo -n) \ --provider-version-branch "main" \ --provider-version-tag "foo" \ --provider-base-url http://localhost:4567 \ --include-wip-pacts-since 2018-01-01 \ --enable-pending \ --no-fail-if-no-pacts-found \ --verbose \ --publish-verification-results```

bethskurrie
2021-10-27 06:46
Can you turn on --verbose please? And send the output in a text attachment.

bethskurrie
2021-10-27 06:47
Can't look at it now, but I'll have a look tomorrow.

simon.nizov
2021-10-27 06:47
My point is that the value in tag overrides the value in branch. Happens to you too

simon.nizov
2021-10-27 06:47
It should be `branch: main` in that screenshot

bethskurrie
2021-10-27 06:47
oh, you're right - I can't read!

bethskurrie
2021-10-27 06:48
Cool - I'll have a look at it tomorrow.

simon.nizov
2021-10-27 06:49
Thanks!

bethskurrie
2021-10-27 06:49
If I take out the tag, I get nothing.

bethskurrie
2021-10-27 06:49
no branch, no tag. So I think it's not sending the branch at all.

simon.nizov
2021-10-27 06:50
Yeah that?s what I was trying to say in my first comment :slightly_smiling_face:

adam.witko
2021-10-27 07:36
has joined #general

alex.macpherson
2021-10-27 08:28
has joined #general

bethskurrie
2021-10-27 09:44
@simon.nizov I've pushed out a fix.

bethskurrie
2021-10-27 09:45
Please update and try now.

bethskurrie
2021-10-27 09:46
You'll note that when you're using the latest verifier, you won't get a duplicate tag/branch when `use_first_tag_as_branch` because it is using the new API that sends the branches/tags/version/pact and everything in one all, so it knows that you've already set the branch.

matt.fellows
2021-10-27 09:47
@bethskurrie deserves a :taco: . I mean, probably more than most, but here's one anyway :rolling_on_the_floor_laughing:

bethskurrie
2021-10-27 09:47
The `use_first_tag_as_branch` is meant for helping people migrate to using branches when their pact clients haven't yet been updated to support branches yet.

bethskurrie
2021-10-27 09:53
I've also updated the tag->branch docs to clarify that it will only use the tag as a branch if there is no branch already set https://docs.pact.io/pact_broker/branches#automatic-branch-creation-from-first-tag

simon.nizov
2021-10-27 10:38
Works! And definitely a well deserved :taco: Thanks!

yurich00
2021-10-27 18:10
has joined #general

lincolnf
2021-10-27 23:30
has joined #general

aakbar
2021-10-28 07:13
Hello everyone. I was using this `--tag-with-git-branch` option in the pact-CLI publish command in github actions and I'm not getting a branch here, instead I'm receiving *`refs/pull/284/merge`* Is there any way to get git branch with the combination of pact-CLI and Github Actions?

lawrencemajmacdonald
2021-10-28 07:33
has joined #general

matt.fellows
2021-10-28 07:37
Mm good q. You'll probably need to use the environment variables

matt.fellows
2021-10-28 07:37
I'll dig up an example


matt.fellows
2021-10-28 07:39
The syntax strips off the first 11 characters which is the `refs/..` guff

aakbar
2021-10-28 08:52
oo, it looks cool. lemme try that.

zsolt.vilagos
2021-10-28 10:00
has joined #general

aakbar
2021-10-28 10:17
So here's the thing. I'm writing these things in my `ci.yml` file: ```env: GIT_REF: ${{ github.ref }}```

aakbar
2021-10-28 10:17
```- name: Publish Pacts run: | gem install pact_broker-client export PACT_BROKER_TOKEN=${{ secrets.PACT_FLOW_ACCESS_TOKEN }} GIT_BRANCH=${GIT_REF:11} make publish_pacts```

aakbar
2021-10-28 10:17
And in my makefile: ```pact-broker publish `find . -type d | grep /pacts` --consumer-app-version=`git rev-parse --short HEAD` --tag ${GIT_BRANCH} --broker-base-url=https://edx.pactflow.io```

aakbar
2021-10-28 10:18
Though I'm still not able to get anything from `${GIT_BRANCH}`

aakbar
2021-10-28 10:18
hence `No value provided for option '--tag'`

aakbar
2021-10-28 12:49
Turns out, I'm getting the same *`refs/pull/284/merge`* from `github.ref` so I used `github.head_ref` instead. Solved my issue. Thanks a lot for the help.

ramesh.dhanasekaran
2021-10-29 02:20
has joined #general

matt.fellows
2021-10-29 02:28
Thanks for raising here!

matt.fellows
2021-10-29 02:29
@garry.jeromson973 did you have anything to add here? @sharath.konda including you also Would be good to collate the various challenges and solutions, and I can move a write up to our docs page

garry.jeromson973
2021-10-29 07:47
@joaoproenca I _think_ this isn?t a million miles away from what I posted here https://pact-foundation.slack.com/archives/C5F4KFKR8/p1634803098005000 , with the root issue being: how can we deal with pacts that involve providers behind a gateway? We?re tending more in the direction of leaving the contracts as they are, but including the gateway in the verification process so that its behaviour is accounted for. Really curious about your idea though, and how you?d go about splitting the contracts. :nerd_face:

joaoproenca
2021-10-29 08:46
hey @garry.jeromson973. From what I understood in your case, I believe that your main issue is that the API gateway changes the requests in some way. In my case, I believe that's not happening :slightly_smiling_face: but the problem is rather splitting the contract because behind the gateway there are different services serving different "parts" of the API. The routing table that defines the gateway uses regular expressions to define how to route requests to the correct services (not sure how standard this is in networking, but using regexps for this kind of thing "kind of" feels scary :stuck_out_tongue: ) and I can use those definitions and regexps to apply to the contract as well, to split the interactions into smaller contracts.

christopher.mcewen
2021-10-29 12:14
has joined #general

catalin.comarnescu
2021-10-29 12:31
has joined #general

kiran.rudrangi
2021-10-29 16:48
has joined #general

danieljak
2021-10-31 15:39
Hey everyone :slightly_smiling_face: Was wondering, I?m setting up a new service, it doesn?t have any contracts yet, But i wanted to include already the infra for it to run verification when it is a provider side. But.. i get an error that says ?No provider with name ?{my service name? found? Is there a way to run the verification tests even though there are no contracts yet?

danieljak
2021-10-31 16:09
Found in the Brokers API that you can do a `POST` request to the `pacticipants` endpoint and add there the provider details, a json body with name, displayName was enough for it

stefan.smith
2021-11-01 13:05
Hi, I'm using the Rust Pact Verifier CLI and have bumped into the lack of support for setting the provider branch when publishing verification results. I see that this is coming based on https://github.com/pact-foundation/pact-reference/issues/151 and https://github.com/pact-foundation/pact-reference/pull/152/files. Any idea when this feature will drop? I see it's absent from the latest beta as well. FYI - I'm aware it's in the Ruby CLI but was following the recommendation to use the native CLI where possible. Thanks!

ahmed_syed
2021-11-01 20:46
has joined #general

ahmed_syed
2021-11-01 20:53
Hi everyone, Glad to join. Is pact good for non-microservices, e.g. i have a Drupal CMS with React Front end, is there an example i can follow? and to write the tests do i need to know nodejs? javascript?

tjones
2021-11-01 20:57
Yes, pact is ideal for microservices. If the react front end is the consumer, then yes, you would write your consumer tests in js. For verification, you can either use the same framework that the back end uses (I think we have PHP bindings, but I haven't used them myself), or you could drive the verification with a different pact framework (eg js or java) if you are more familiar

matt.fellows
2021-11-01 23:27
I think Kamal was asking for *non-*microservices

matt.fellows
2021-11-01 23:27
But the answer might still be the same - microservices is just the common use case

matt.fellows
2021-11-01 23:28
If it speaks REST then the answer is probably (i.e. what Tim said)

matt.fellows
2021-11-01 23:29
I think it?s just waiting on a release. I do recall there being an issue with something in main that couldn?t be released yet

matt.fellows
2021-11-01 23:29
@uglyog is there anything blocking a release?

matt.fellows
2021-11-01 23:30
Also please note Stefan it?s a public holiday here in Melbourne and a bunch of the maintainers who are based here are off for a long weekend

b.1.alpha
2021-11-01 23:52
Hi I am running the tutorial https://katacoda.com/pact/scenarios/pactflow-can-i-deploy-js and getting an error step 4 of 8. '$ npm run publish'

b.1.alpha
2021-11-01 23:53
Where is the best place to discuss something like that?

matt.fellows
2021-11-01 23:54
please raise in #documentation and we can go from there

matt.fellows
2021-11-01 23:57
I just whipped through the workshop and it works :mwah:

somayajulaas
2021-11-02 00:38
has joined #general

john
2021-11-02 03:32
has joined #general

bjorn.johansson
2021-11-02 08:32
I recently started looking into pact. I have set up a simple scenario with a simple integration between a consumer and a provider and that works perfectly. But I?m wondering how one should deal with slightly more complex scenarios? Let?s say I have a consumer that talks to two different services, service A and service B. The role of the consumer is to call service A and B, aggregate the results and apply some business logic to it. Now let?s say I want to write a contract test between the consumer and service A. When verifying the pact on the consumer side I?m gonna mock the response from service A (using pact) and then call the API of the consumer and assert that the response can be dealt with properly. However by invoking the API of the consumer service B will also be invoked. How should I deal with that? These are some of the alternatives I thought of. 1. Mock service B with Wiremock or similar. 2. Try to write the contract test at a lower level so that only the service A interaction is involved. 3. Use pact to mock service B as well What is the recommended approach for these kinds of scenarios?

matt.fellows
2021-11-02 09:23
2 is possible and if not, then 1

matt.fellows
2021-11-02 09:23
See also a few AMAs on that topic: https://docs.pact.io/help/amas/

bjorn.johansson
2021-11-02 10:35
Thanks. So 3 is not desirable right? Because one would like to test the contracts in isolation and not tie the contracts of service A and B together.

rochitsen
2021-11-02 10:49
has joined #general

finta.pl
2021-11-02 14:43
has joined #general

alessandro.borraccino
2021-11-02 17:04
has joined #general

matt.fellows
2021-11-02 20:38
That should have read "2 *if* possible"

matti.anusha
2021-11-03 02:58
has joined #general

bjorn.johansson
2021-11-03 07:28
Ok, so the contract test should be limited to testing the contract and the contract only? So what we would like to verify on the consumer side is that parsing of the response works. Right? Alternative 1 is kinda mixing functional tests with contract tests and if I interpret your response correctly that is not desirable.

matt.fellows
2021-11-03 09:45
Ideally, but if in the course of doing the testing you cover some functional aspects also that's fine, don't beat yourself up about it

matt.fellows
2021-11-03 09:46
We've talked about this in the AMAs too: https://docs.pact.io/help/amas/

ozgurerisir
2021-11-03 10:29
has joined #general

bjorn.johansson
2021-11-03 10:47
Ok, thanks once again. Really appreciate it :slightly_smiling_face:

matt.fellows
2021-11-05 07:08
Hi Brad, anything you can share here? I?m positive others in the community would be keen! cc: @vuttithatkrongyot

dean.miley1
2021-11-05 11:40
has joined #general

dean.miley1
2021-11-05 11:43
Hi Team, I would like to request who would be the right person to approach to talk about having security vulnerabilities addressed in pact-broker?

martha.nolan
2021-11-05 11:50
has joined #general

matt.fellows
2021-11-05 12:03
Answered in the other channel

eniko_kollar
2021-11-05 16:46
has joined #general

ashwin
2021-11-05 17:58
has joined #general

d.philipp
2021-11-08 03:51
has joined #general

mail_4brad
2021-11-08 04:30
@matt.fellows Here?s the thread that resulted: https://pact-foundation.slack.com/archives/C9UN99H24/p1626742572393400 So far it feels like a natural fit. I was pushed by some colleagues to run a compare with SCC as we?re a Spring shop and I?m stalled on that and other distractions so haven?t been able to bed this in yet. I welcome any more thoughts on it.

matt.fellows
2021-11-08 04:53
Oh fantastic, thanks Brad! I might take a copy of this for putting up _somewhere_

hamzah.saleem
2021-11-08 11:22
has joined #general

srividya.ece
2021-11-08 12:17
has joined #general

markus.joschko
2021-11-08 13:13
has joined #general

belugin.v
2021-11-08 17:16
has joined #general

will.griffiths
2021-11-09 05:25
has joined #general

navilooz
2021-11-09 08:48
has joined #general

keith.hirst
2021-11-09 12:13
has joined #general

rbo
2021-11-09 17:47
has joined #general

harshaan.n.khan
2021-11-10 05:38
has joined #general

rbo
2021-11-10 10:05
Hi there, I was wondering whether someone has 'real world' examples of projects using pact?

tjones
2021-11-10 10:05
There are several. What are you looking for?

rbo
2021-11-10 10:06
I'm curious what type of assertions make sense within the verify function in terms of Go

tjones
2021-11-10 10:09
Right, so you would verify that your API call returned the business object that you're expecting

tjones
2021-11-10 10:12
Hmm, it looks like maybe the go examples don't do this

tjones
2021-11-10 10:15
I think the design for go is something like this: ``` var test = func() (err error) { // fire api code that's under test resp, err = yourApiCallHere(paramsIfYouHaveThem) // assert that the resp/err from the call is the business object that you're expecting } // setup interaction pact. AddInteraction()./* ...etc */ if err := pact.Verify(test); err != nil { log.Fatalf("Error on Verify: %v", err) }```

rbo
2021-11-10 10:16
One of the examples from the go-pack-workshop is is shown above in your post Imagine the provider user object provides a field boolean a and boolean b and the consumer's version of that user object has an extra field boolean c which is set to true if the provider's boolean a and boolean b is true. In terms of contract testing and pact it is *not a good idea* to test outcome of the consumer's user object field boolean c because it's not really to do with the contract between the provider and consumer. Have I got that concept correct? Or can that be tested within the verify. I'm not sure if you'd class that as business logic or just the transformation of provider/consumer concepts ``````

tjones
2021-11-10 10:16
For go examples, you might get a better answer asking in #pact-go

rbo
2021-11-10 10:17
Thanks @tjones is my question above better suited for the #pact-go channel too?

tjones
2021-11-10 10:18
Good question. So, in the expectations you set up (in `WillRespondWith` in Go), it's good practice to use matchers, to generalise the response data. For example, if the `name` field is a string, you don't need to the expected response to be tied to a specific string

tjones
2021-11-10 10:18
You might say `dsl.String("Steve")`, to say "this is a string, for example `"Steve"`"

tjones
2021-11-10 10:19
the reason you do this is so that during provider verification, the provider doesn't need to have exactly the same data as is in the consumer test, just the same shape of data

tjones
2021-11-10 10:20
(unless the specific string important for conveying meaning, like say `"type": "UserRecord"` or something)

tjones
2021-11-10 10:20
However, in the test code that you pass to `Verify`, you still want to assert in your consumer test that the response was correctly unmarshalled into whatever business object comes back from your api call

rbo
2021-11-10 10:20
So is the idea that the WillRespondWith is the contract from the provider while the verify function can be used to test how your application responded to the contract perhaps by created it's own version of the object

tjones
2021-11-10 10:21
Yes. In the expectation, we say: "I will send a request that looks like <this request>" "If I do, please send me a response that looks like <this response>"

rbo
2021-11-10 10:22
got it, thank you for your help

tjones
2021-11-10 10:22
A Pact consumer test confirms that you can send the response you claim you will. However, it's up to you to confirm that you can unmarshall the response object correctly.

tjones
2021-11-10 10:22
in some languages, this looks like marking your own exam, if the json unmarsalling is built in and you aren't doing any transformation

tjones
2021-11-10 10:22
but it's still good to do.

tjones
2021-11-10 10:23
Pact interaction: "I will send a request that looks like <this request>" "If I do, please send me a response that looks like <this response>" Your test function: "I fire the code that sends that request" "I check that I understood the response and it was what I was expecting"

rbo
2021-11-10 10:26
So I'm clear on that part, but I'm still unsure in my above example testing boolean c on the consumer user objects is actually testing business logic rather than the contract. I'm finding it hard to draw the line here

tjones
2021-11-10 13:13
I'm not sure I understand the example very well. It sounds like the boolean in your example is unmarshalling logic? If that's the case, I would test it.

tjones
2021-11-10 13:13
Think of Pact as a unit test for your communications boundary - which includes the http call and the marshallers

rbo
2021-11-10 13:29
@tjones Thank you that does answer my question, cheers

esparga
2021-11-10 14:32
has joined #general

thales.areis
2021-11-10 19:33
has joined #general

matt.fellows
2021-11-11 05:24
In case you didn't see, here are a bunch of real world case studies or pact: https://docs.pact.io/blogs_videos_and_articles/#2021

matt.fellows
2021-11-11 05:24
There are some on the http://pactflow.io website also

henk.koopman
2021-11-11 08:56
has joined #general

lena.lindblad
2021-11-11 09:58
has joined #general

radekkoubsky
2021-11-11 16:24
has joined #general

aditya
2021-11-11 17:20
has joined #general

claire
2021-11-11 17:55
has joined #general

bethskurrie
2021-11-11 21:57
Pact Broker Feature Research Question - git uses the word "HEAD" to mean the latest version on a branch. SVN seems to use the same term. Is there a commonly used version control system that does *not* use that term? The reason I ask is that I want to be able to make the contract_requiring_verification_published webhook be able to trigger before we have any versions published from the provider, and to do that, I need a placeholder version number. I think "HEAD" should do it for most systems, but wanted to check if there are any I don't know about.

matt.fellows
2021-11-11 21:59
In terms of tools I?ve seen out in the wild: ? git (most popular) ? svn ? cvs ? Mercurial ? gerrit ? MS Team Foundation VC

joel.whalen588
2021-11-12 01:45
Question - Does Pact support using GraphQL requests instead of REST?

matt.fellows
2021-11-12 02:07
GraphQL is just an abstraction over REST, so yes, you can

matt.fellows
2021-11-12 02:07
In Pact JS we have a GraphQL interface, but it?s a thinly veiled extension to the standard HTTP one

matt.fellows
2021-11-12 02:08
that being said, with the new plugin interface, it would be nice to support GraphQL content-type explicitly

joel.whalen588
2021-11-12 02:13
Thank you for clarifying, it's new tech to me. That would be pretty sweet if that could be added - where can I learn more about plugins for pact? And how much work would this be lol

matt.fellows
2021-11-12 02:14
It?s a _very_ nascent feature, and we haven?t made much noise about it yet

matt.fellows
2021-11-12 02:14
We?d like to get a few official plugins under our belt before doing that so that we can smooth that experience out

matt.fellows
2021-11-12 02:14
you can follow the progress here: https://github.com/pact-foundation/pact-plugins/

joel.whalen588
2021-11-12 02:15
Ah fair enough. I'll keep watching then :slightly_smiling_face:

matt.fellows
2021-11-12 02:15
I?ll DM you some other details too, one moment

matt.fellows
2021-11-12 02:16
In case it?s helpful, the GraphQL interface in PactJS can be found here: https://github.com/pact-foundation/pact-js/blob/master/src/dsl/graphql.ts

matt.fellows
2021-11-12 02:16
all it does is just simplify configuring what the graphql query looks like to the HTTP interface

gentritmm
2021-11-12 08:35
has joined #general

wilson.espina
2021-11-12 09:52
has joined #general

eric2323223
2021-11-12 13:52
Hi @matt.fellows may I know if you provide downloadable executables of https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli?

alejandro.pena
2021-11-12 16:32
wrote by mistake, sorry

mike.geeves064
2021-11-12 16:47
Have a look through the releases, i.e. https://github.com/pact-foundation/pact-reference/releases you should be able to find it there. You may or may not be wanting to use that one, depending on CI approach, language being used etc though.

stefan.smith
2021-11-12 17:41
Hi, I have hit an issue which I think is similar / the same as the scenario described in https://docs.pact.io/pact_nirvana/step_8. I am using Pact flow to coordinate CI exchange of contracts within a GitFlow (feature branching) source control workflow. I am using `--enable-pending` and `--include-wip-pacts-since` when I verify pacts. I am also using `can-i-deploy` and `record deployment`. I have set up a webhook that is triggered on the `contract_requiring_verification_published` event so that Pacts published from consumer feature branches are rapidly verified and results recorded in Pactflow. The scenario I'm unsure about is the follow: ? Consumer publishes a new pact from a feature branch which trigger rapid verification via webhook and records result in pactflow, against the feature branch. ? Provider mainline build runs on a new provider commit, retrieves latest `main`, `staging` and `production` contracts to verify, plus WIP contracts (which includes my consumer feature branch) and they pass. Results are published to pact broker ? Provider mainline build runs on a second new provider commit and this time the WIP contracts do not include my consumer feature branch pact. I _think_ this means there won't be an entry in the Pact matrix for the latest mainline Provider verifying the consumer feature branch pact ? Consumer merges feature branch to mainline. ? Consumer mainline build runs. The pact is published and associated with the mainline branch but the webhook is not triggered because the pact content hasn't changed. Consumer mainline build then runs `can-i-deploy` which fails because the matrix does not contain a result for latest Provider mainline vs current Consumer mainline. On this last point, is this expected behaviour? Ideally, there would be some way for the consumer mainline to force a verification just-in-time if one is missing. Alternatively, is the `--include-wip-pacts-since` feature continued to retrieve passing feature branch Pacts, then there would always be a verification result but then the verification job would accrue more and more pacts to verify over time.

megan.twyver
2021-11-12 18:39
has joined #general

stefan.smith
2021-11-12 20:00
Having done more reading, I came across point 5 of https://docs.pact.io/pact_broker/advanced_topics/wip_pacts/#technical-details. I now realise the WIP pact file will continue to be retrieved even after successful validation. It will only stop being WIP once it is explicitly retrieved using a consumer selector. I have now confirmed this behaviour in our pipeline. This means there should always be a successful result in the matrix that enables the consumer feature branch changes to build and deploy successfully following a merge to mainline. My only outstanding concern is that the number of WIP pacts could grow over time if some branches never get merged to mainline. I guess one could apply a sliding time window by dynamically calculating the wipPactsSince date.

mischa.molhoek
2021-11-14 09:42
has joined #general

stefan.smith
2021-11-14 11:56
Something that might make this clearer for users: currently, when a feature branch WIP pact is retrieved that has already been verified on the `develop` branch of our provider, the DEBUG log says: > This pact is in pending state for this version of <Provider> because a successful verification result for a version of <Provider> from branch 'develop' has not yet been published. This is misleading. In actual fact, a successful verification result _had_ been published from the provider's `develop` branch but the pact was considered WIP because it had not yet been associated with one of the _explicitly_ requested consumer branches or environments (our consumer selector specified `develop`, `staging` and `production`). This is the behaviour described in step 5 of https://docs.pact.io/pact_broker/advanced_topics/wip_pacts/#technical-details. We spent a lot of time trying to figure out what was going on until we discovered this information. If the DEBUG message had explained the true reason for the pact retrieval, we would have arrived at an answer more quickly.

matt.fellows
2021-11-14 22:10
This is a lovely detailed set of messages Stefan!

matt.fellows
2021-11-14 22:10
It sounds like you may have discovered a bug with the notices

69vron
2021-11-15 01:35
has joined #general

tjones
2021-11-15 05:18
What does the Pact verifier do with redirects? Can we make it follow them? I have an API call to endpoint A that will redirect to an endpoint B that returns a different payload. Because it's running in the browser, the consumer code will never see the redirect - from its perspective, endpoint A is returning payload B. So, I want to write a pact that says endpoint A returns a 200 with payload B (which will work from the consumer's perspective), but the provider will actually have a redirect in between (not part of the contract - the consumer doesn't care).

bethskurrie
2021-11-15 05:19
Currently, it would fail.

bethskurrie
2021-11-15 05:19
The Ruby verifier at least does not follow redirects.

bethskurrie
2021-11-15 05:20
You say the consumer doesn't care, but some clients will follow redirects and some don't.

bethskurrie
2021-11-15 05:21
We'd need to add some explicit options and code for the verifier to be able to handle that.

uglyog
2021-11-15 05:25
This is a problem, because if we make it automatically follow redirects, then nobody could have a Pact test with the redirect status codes. In the Pact-JVM I had to add support for this, and it is opt-in.

tjones
2021-11-15 05:36
Yeah. I think neither default works for everyone. The problem is that the front end can't/won't see the redirects

tjones
2021-11-15 05:37
I think for a workaround I could put it in the contract (with two interactions), but it's not a great solution because the contract doesn't actually need the redirect

bethskurrie
2021-11-15 05:37
yeah, it's a tricky one.

tjones
2021-11-15 05:37
@uglyog: Our verifier is pact-jvm. Are you saying we can tell it to follow redirects?

uglyog
2021-11-15 05:40
See ``pact.verifier.enableRedirectHandling`` in https://docs.pact.io/implementation_guides/jvm/provider/gradle/

tjones
2021-11-15 05:41
We're using the JUnit verifier - can we use the same property?

uglyog
2021-11-15 05:45
I think so. It looks like it is in a common class, but i have never tried it.

james.sawle
2021-11-15 08:49
has joined #general

priyank.shah217
2021-11-15 10:46
A general query, does pact supports grpc protobuf also?

priyank.shah217
2021-11-15 10:46
any sample repo would really help


matt.fellows
2021-11-15 11:17
it?s not officially supported yet, but as you?ve just found we?re building a plugin framework for it. You could consider the current implementation an early beta

matt.fellows
2021-11-15 11:27
We?ll be providing updates via the Pactflow https://github.com/pactflow/roadmap#developer-preview-programs


pete.watts
2021-11-15 12:46
has joined #general

malena.cadima
2021-11-15 14:36
Hello everyone. I want to use pact with kubernetes. It is possible? Is there any documentation ?

joel.whalen588
2021-11-15 15:26
I'm not a kubernetes expert by any means, but using the Pact CLI docker image is a good start: https://hub.docker.com/r/pactfoundation/pact-cli It works like any other docker image you'd use in kubernetes. It can handle everything about interacting with the broker: publishing pacts, verifications, and using the can-i-deploy tool.

joshua.badger
2021-11-15 17:10
has joined #general

joshua.badger
2021-11-15 17:14
Hello all! I?ve searched through what I can see and have been unable to find an answer. I see this docker image (https://hub.docker.com/r/pactfoundation/pact-ref-mock-server) and want to use it for an app we are working on, as we have multiple other servers our company controls that this app communicates with. I?m in the beginning stages of setting up Pact on this service, and have it rudimentarily working using the https://hub.docker.com/r/pactfoundation/pact-cli image, but as I understand it that image isn?t set up to run more than one mock server for one consumer/provider pair. I see in its description that it supports multiple mock servers for multiple consumer/provider pairs: > This project provides both a restful web api and command line interface to run pact mock servers. It is a single executable image and is able to manage multiple mock servers. The lifecycle of each mock server can be controlled by the restful web api or through the command line interface. It implements the https://github.com/pact-foundation/pact-specification/tree/version-3. I would much rather have a single container handling this than trying to modify `pact-cli` to have multiple mock servers running. Is there a link somewhere for how to use `pact-ref-mock-server`?

joshua.badger
2021-11-15 17:18
Also, I apologize if I missed the information regarding this.

matt.fellows
2021-11-15 20:33
Are you trying to run the broker on Kube or something else?

matt.fellows
2021-11-15 20:34
Can you please explain your use case a little more? Why are you using the CLI directly instead of using one of the languages?

joshua.badger
2021-11-15 22:39
It?s possible I misunderstood how to get it to work, but using `pact-python` I wasn?t able to get it working. Kept getting errors about not being able to assign an address/port combination. I?ll see if I can reproduce it.

joshua.badger
2021-11-15 23:12
I did in fact misunderstand. Thank you for giving me the right nudge, it?s working now. :slightly_smiling_face: No need for an extra container.

tjones
2021-11-15 23:13
Those containers are useful if you're using pact outside one of the languages where we have DSLs that do all the work for you. Possibly we should make that clearer in the documentation

matt.fellows
2021-11-15 23:43
> I did in fact misunderstand. Thank you for giving me the right nudge, it?s working now. ah, great to hear? What was confusing, perhaps we can improve the docs somewhere

joshua.badger
2021-11-15 23:51
I?m not sure what the issue was; early in my attempts to set up in `pytest` I?d get errors (with ruby tracebacks on occasion) and an error that the address couldn?t be assigned. I will look and see what I ended up doing, and what could have been clearer based on what the existing documentation says.

matt.fellows
2021-11-16 00:18
No worries, thanks. It?s always helpful to update when somebody has fresh eyes :slightly_smiling_face:

joshua.badger
2021-11-16 16:21
I think my issue might have been that I actually started with `pactman` , actually. I?ll still give this some thought, but it might not have been `pact-python`?s documentation that threw me off.

omarsaddaoui
2021-11-17 02:55
has joined #general

eniko_kollar
2021-11-17 10:24
Hi everyone, I was wondering if anyone would be willing to have a quick chat on their experience of using contract testing in a mid-size/large organisation with many microservices! :mechanical_arm: Any input would be greatly appreciated, because we are just trying to start to implement contract testing. :pray:

matt.fellows
2021-11-17 12:32
I guess I?ll count as biased, so i?ll just shared some links to case studies etc.: https://docs.pact.io/blogs_videos_and_articles


eniko_kollar
2021-11-17 12:53
Aww, thank you so much Matt, this is super cool! However, do you think I could get in touch with you or them to ask for a bit more details?

matt.fellows
2021-11-17 13:00
If you drop an email to I can try and do an intro via email, otherwise hopefully somebody will see your call out here also :slightly_smiling_face:

mbyrne
2021-11-17 14:23
has joined #general

matthew.drill
2021-11-18 01:08
has joined #general

james.halsall
2021-11-18 12:02
has joined #general

stefan.smith
2021-11-18 12:39
Hi, I'm using the `pact-provider-verifier` with `--enable-pending`. In addition to suppressing non-zero exit codes when verification of a pending pact fails, I also expected this to suppress non-zero exit codes when provider state setup failed for those same pacts. This doesn't seem to be the case. Is this expected? Ideally, I'd like to avoid a consumer being able to break a provider's mainline build when they define an unsupported provider state.

matt.fellows
2021-11-18 12:56
Sorry, is this the ruby or the rust one (or rather, where did you download it from?)

matt.fellows
2021-11-18 12:56
In either case I think that expectation is fair

stefan.smith
2021-11-18 13:17
It's ruby

stefan.smith
2021-11-18 13:19
Are you saying you think it's a fair expectation but that in reality this _may_ not be the case? That's what I'm seeing - we broke a provider mainline build by pushing an unsupported provider state definition.

stefan.smith
2021-11-18 13:20
Essentially, the /_pactSetup endpoint we call returned a 500 for a pending pact. Would have hoped that would not cause a non-zero exit

matt.fellows
2021-11-18 13:28
I'd also expect it not to fail, that's right

matt.fellows
2021-11-18 13:28
I'll follow up tomorrow

bethskurrie
2021-11-18 21:29
@stefan.smith can you please raise it in the https://github.com/pact-foundation/pact-ruby repository?


chvram
2021-11-19 14:09
has joined #general

akhandalmani.malik
2021-11-19 14:16
has joined #general

malena.cadima
2021-11-19 14:55
my consumer is a library on Docker and my provider is a service on Kubernetes. Is there any documentation about pact+k8?

elias.frykholm
2021-11-19 15:17
has joined #general

eniko_kollar
2021-11-19 15:17
Thanks a ton!

martin.carlin
2021-11-19 15:52
has joined #general

paul.nardone
2021-11-19 16:12
has joined #general

emily
2021-11-19 18:56
has joined #general

pietrucha.bartosz
2021-11-20 13:47
has joined #general

pietrucha.bartosz
2021-11-20 13:48
Hello everyone! I am creating a course about Fullstack Web testing and using PactJS!


pietrucha.bartosz
2021-11-20 13:50
@matt.fellows :wave:

ringo
2021-11-20 21:16
Is there a Github Action available which installs the Pact CLI tools?

matt.fellows
2021-11-20 21:42
Not sure there is, but it's a good idea. Can you please raise a feature request here: http://pact.canny.io?

matt.fellows
2021-11-20 22:08
Excited to see the course! What can we do to help and what are your plans? Happy to review and contribute to key topics that should be covered, and review content and examples for best practices Like like you're going to do it in Node/TS/Angular. I can help with first 2 but not angular as I have no experience there

achuljyan
2021-11-21 07:15
TL;DR How to pass variable from consumer Jenkins pipeline job to triggered verification pipeline job?

tjones
2021-11-21 08:31
This is a *great* idea

mastrobardo
2021-11-21 11:42
has joined #general

mastrobardo
2021-11-21 11:44
Hello, good morning. I'm trying to reset the password in a new generated account, however i dont receive ANY validation code email. The only one i received is when i signed up, but it is expired after 5 minutes

mastrobardo
2021-11-21 11:44
anybody has an hint on how to proceed

matt.fellows
2021-11-21 12:18
Hi Davide, I saw saw your support email. Accounts enter a locked state if not activated within the first 7days. We've unlocked your account now. Also FYI we do have a dedicated channel here for #pactflow

mastrobardo
2021-11-21 12:49
ohh thank you mate!

mastrobardo
2021-11-21 12:51
still no success though. will report to pactflow channel, thank you

matt.fellows
2021-11-21 12:59
I think for this case we'll want to do it offline via email. If you can raise a ticket at we can manage it there. It's late here but I'll check in tomorrow

mastrobardo
2021-11-21 18:25
thx buddy, i just got it trough now. I was probably in some block cycle via IP/repeated attempts

tjones
2021-11-22 04:04
@uglyog: Unfortunately, the JUnit runner doesn't appear to respect this property. Is this an easy fix, or should I open an issue?

uglyog
2021-11-22 04:09
How are you setting that property?

tjones
2021-11-22 04:16
`-Dpact.verifier.enableRedirectHandling=true` as a VM arg

uglyog
2021-11-22 04:19
Hmm, that should do it

fed
2021-11-22 04:20
has joined #general

tjones
2021-11-22 04:23
That's what we thought too. I thought it _might_ be maven weirdness, but it seems like that's not the case

tumunshaily
2021-11-22 07:54
has joined #general

yunfeng.wang
2021-11-22 09:25
has joined #general

connor.aird
2021-11-22 17:44
Hello, I am using the pact-mock-server written in rust to run some mocks during verification. I am mocking a POST endpoint which creates ?something? and I have two scenarios in which only one value in the body of the request will differ - `"Name"`. One of these should return a 200 and create ?something? (i.e. `"Name": "somethingNew"`). In the other scenario ?something? should already exist and hence a 409 should be returned since there was a conflict (i.e. `"Name": "somethingOld"`). Verification is failing currently as only the happy path that returns 200 is appearing in the mock server. Is it possible to have this kind of scenario mocked using a single pact mock server? If so, any ideas what I might be doing wrong?

matt.fellows
2021-11-22 20:40
Can you please share the setup and log messages for when it doesn't work?

james.perepiczka
2021-11-23 08:25
Hi, I wanted guidance on what we should do in the following scenario: We have an endpoint that shows the progress of a running task. If the task is running then it will show an object in the response otherwise it will show an empty collection. What is pact best process for this? The only way I can think it would work is to trigger a task and then call this endpoint and hope the task is not finished by the time the endpoint is run. Similarly we could mock it in a dev environment but we want to validate that each stage from dev to live has a compatible contract so this doesn't seem feasible (especially in live). What approach should I take here?

connor.aird
2021-11-23 09:32
Sure. I have two interactions for the same endpoint `POST /customer`. The only difference is the request body` ```{ "Name": "newName" }``` or ```{ "Name": "existingName" }``` The first body should return a 200 status code and the second a 409. I spin the mock server up as part of a docker-compose file using a customer docker image (with some custom flags), which contains the pact-mock-server. I pass the contract containing both interactions to a single Pact Mock Server, like so. ```pact-mock-server: image: "pact-mock-server:latest" entrypoint: "/entrypoint.sh -psp 3001 -msp 3002 -fn /pacts/consumer-provider.json" volumes: - ./target/pacts:/pacts ports: - 3001:3001``` This is the contract used for the pact-mock-server ```{ "consumer": { "name": "consumer" }, "interactions": [ { "description": "a request to create a customer", "request": { "body": { "Name": "newName" }, "headers": { "Accept": "application/*+json", "Content-Type": "application/json" }, "matchingRules": { "body": { "$.Name": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "method": "POST", "path": "/customer" }, "response": { "body": { "CustomerGuid": "customerGuid" }, "headers": { "Content-Type": "application/json;charset=UTF-8" }, "matchingRules": { "body": { "$.CustomerGuid": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "header": { "Content-Type": { "combine": "AND", "matchers": [ { "match": "regex", "regex": "application/json(;\\s?charset=[\\w\\-]+)?" } ] } } }, "status": 200 } }, { "description": "a request to create a customer", "providerStates": [ { "name": "a customer exists" } ], "request": { "body": { "Name": "oldName" }, "generators": { "body": { "$.Name": { "dataType": "STRING", "expression": "customerName", "type": "ProviderState" } } }, "headers": { "Accept": "application/*+json", "Content-Type": "application/json" }, "matchingRules": { "body": { "$.Name": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "method": "POST", "path": "/customer" }, "response": { "status": 409 } } ], "metadata": { "pact-jvm": { "version": "4.2.4" }, "pactSpecification": { "version": "3.0.0" } }, "provider": { "name": "provider" } }``` I am able to match against the first interaction (Name = newName) but not the second (Name = existingName). I see this log in the `mock_server_mismatches` when trying to match against the second interaction ```[{ "method": "POST", "path": "/customer", "request": { "body": { "Name": "newName" }, "headers": { "Accept": "application/*+json", "Content-Type": "application/json" }, "matchingRules": { "body": { "$.Name": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "method": "POST", "path": "/customer" }, "type": "missing-request" }]```

connor.aird
2021-11-23 09:36
I believe one problem is that the bodies for both interactions, as far as the pact-mock-server is concerned, are identical as we are matching types. Because of this I tried changing from type matching the equality matching on the first interaction and I get the same issue

matt.fellows
2021-11-23 10:28
might be a bug. But also, normally you would test each of these interactions separately (rather than on a single mock server instance)

matt.fellows
2021-11-23 10:28
is there a reason you?re not using one of the language bindings directly?

dawoud.sheraz
2021-11-23 12:42
Cross-posting my thread from #pact-python for better reach https://pact-foundation.slack.com/archives/C9VECUP6E/p1637671332064700

christos.litsas
2021-11-23 13:05
has joined #general

walter.psjr
2021-11-23 17:39
has joined #general

tomknee1
2021-11-23 21:44
Hi there, im pretty new to contract testing but am looking at adopting a consumer driven contract testing approach where i work amongst the teams. My question is regarding sharing of the pact file between teams. I?ve heard u can share it via a pact broker? how does this work exactly if the team providing the consumer uses a different CI than the provider team? Thanks, i guess as a proof of concept ill look at a simpler way to share just to validate the idea etc but need to think more long term too

matt.fellows
2021-11-23 21:45
Think of the pact broker like Git. It?s a repository for contracts

tomknee1
2021-11-23 21:46
ooh i see, so it doesnt matter what CI then

matt.fellows
2021-11-23 21:46
you can push code / pull code from git regardless of your CI tech. Same with Pact Broker

tomknee1
2021-11-23 21:46
ok great :smile:

tomknee1
2021-11-23 21:46
thanks so much

matt.fellows
2021-11-23 21:46

tomknee1
2021-11-23 21:47
thanks, bookmarked and will dig into it tomorrow

matt.fellows
2021-11-23 21:47
It uses Pactflow (a commercial version of the Pact Broker) but shows the workflow, which is the same regardless

tomknee1
2021-11-23 21:47
is there a way to trial a pact broker during proof of concept stage


matt.fellows
2021-11-23 21:48
Pactflow has a free starter plan

matt.fellows
2021-11-23 21:48
the Pact Broker is an open source tool

tomknee1
2021-11-23 21:49
nice, thanks for such quick answers :slightly_smiling_face:

matt.fellows
2021-11-23 21:49
the free starter plan has up to 5 contracts, unlimited users - so should be :ok_hand: for a POC/pilot

tomknee1
2021-11-23 21:49
thats perfect :+1:

abubics
2021-11-24 00:45
With Pact (and presumably other contract testing tools), you don't hit the actual API, and you can specify the current state in the test. So, on the consumer side you might have a few states like ? no tasks in progress ? some tasks in progress with an interaction for each. And then on the provider side, however you're stubbing the responses (depends on your architecture, which layer you cut at, etc), you support those known states.

steveforwork2
2021-11-24 08:47
has joined #general

connor.aird
2021-11-24 10:38
I am using pact-mock-servers as an alternative to mocks such as wiremocks because my understanding was that this was a key use case. In this scenario, a different pact-mock-server for each interaction doesn?t make sense to me. Would you agree? And, in this scenario, we are using the standalone pact verifier to run interactions against a provider which will subsequently call the pact-mock-servers, so language bindings may not make sense?

matt.fellows
2021-11-24 10:56
> And, in this scenario, we are using the standalone pact verifier to run interactions against a provider which will subsequently call the pact-mock-servers, so language bindings may not make sense? this makes no sense to me. Why would you point the pact verifier, against the mock server? The point of the verifier is to check what your consumer is doing (as defined in a consumer test and validated by the mock server) against the actual provider.

matt.fellows
2021-11-24 10:57
if all you did was run the verifier against the mock, you?ve just setup a tautological test that will always pass and tell you nothing useful

matt.fellows
2021-11-24 10:57
> I am using pact-mock-servers as an alternative to mocks such as wiremocks because my understanding was that this was a key use case. In this scenario, a different pact-mock-server for each interaction doesn?t make sense to me. what language are you using? how are you defining the mocks?

connor.aird
2021-11-24 11:13
Sorry I may have described that poorly. I am spinning up an actual instance of a provider. The verifier then plays an interaction defined in one contract against that provider. Following this, the provider will subsequently call my pact-mock-server instance which is mocking out a third service (not consumer or provider). This instance will be spun up using a contract containing the two interactions I have previously mentioned. This contract is different to the one played against the provide and is one in which our provider is a consumer of the third service. ```Verifier ----> Actual Provider ----> pact-mock-server``` All contracts are generated through consumer tests written using the Pact JVM - this maven dependency ```<dependency> <groupId>au.com.dius.pact</groupId> <artifactId>consumer</artifactId> <version>4.2.4</version> <scope>test</scope> </dependency> ```

matt.fellows
2021-11-24 11:42
ok, that does make more sense

matt.fellows
2021-11-24 11:43
so, I wouldn?t be using the *mock* server in your use case, i?d be using the *stub* server

matt.fellows
2021-11-24 11:43
but really, I?d not use the pact tools as a stub there and would tend to want to mock it during my tests (and then have separate pact tests between `Actual Provider ---> Downstream API`

matt.fellows
2021-11-24 11:43
I think @uglyog has a war story about doing what you?re proposing

fredrik.ostling
2021-11-24 11:56
has joined #general

connor.aird
2021-11-24 13:37
Okay I see. I plan to also have the separate pact tests between Actual provider and Downstream API as well. Therefore I will be confident that the pact-mock-servers never get out of date as the downstream API develops. However, if there?s a better approach, I would be interested to hear what that is. This *stub* server, is that something else offered by pact?

jorge.nunez
2021-11-24 14:28
has joined #general

connor.aird
2021-11-24 14:29
After reading around the stub server it seems that it only matches against the method, path and query parameters but I need to match against the body.

tomknee1
2021-11-24 17:13
Hi there, does anyone know if pact contract testing works with Websockets interface etc? thanks

asradhakrishnan
2021-11-24 17:20
has joined #general

matt.fellows
2021-11-24 21:42
You can do it using what we call message pact (howtomessage)

2021-11-24 21:42
See also these examples (e.g. Kafka, AWS SNS)

matt.fellows
2021-11-24 21:42
We don?t support websockets directly, but the idea would be to support it in a first class way via plugins (howtoplugin)


tomknee1
2021-11-25 09:19
thanks but im still a bit confused, are you saying we?d have to make a new plugin or something?

matt.fellows
2021-11-25 09:40
No, you can think of websockets as another type of queue and use message pact to test it

matt.fellows
2021-11-25 09:40
Ideally we could build a specific websocket plugin later on the make it less abstract. But for now you can use message pact to do it.

matt.fellows
2021-11-25 09:40
What language are you using?

tomknee1
2021-11-25 09:40
ok thanks are there any tutorials etc ?

matt.fellows
2021-11-25 09:41
No, otherwise I would have shared a websockets example instead of Kafka one :rolling_on_the_floor_laughing:

tomknee1
2021-11-25 09:42
so the team im on now for Android based app uses kotlin, then the other teams for backend etc all use Go

tomknee1
2021-11-25 09:44
for the proof of concept its probably gona be between different consumers / providers on the Go side of things

connor.aird
2021-11-25 09:48
Hello, I have solved my issue. The custom image I had created containing the pact mock server was handling errors incorrectly. If the pact-mock-server returned an error code as it should (like in the second interaction) the custom image threw an error instead of just returning as it should. By checking the mock servers response for key string such as `request mismatch` I am able to distinguish between an actual mismatch and a valid mocked error code.

matt.fellows
2021-11-25 10:02
Hmm it should match body too I think. I believe it uses the same implementation under the hood, it just doesn't validate (so it may be a moot point)


matt.fellows
2021-11-25 10:04
It's the new v2.x.x branch which is beta but I'd still start there.

matt.fellows
2021-11-25 10:05
It's functional, it's just about ironing out any remaining bugs and getting feedback on the API before we freeze it and release the next major

tomknee1
2021-11-25 10:10
thanks

edouard.lopez
2021-11-25 11:01
has joined #general

maxkitzing
2021-11-25 17:49
has joined #general

bethskurrie
2021-11-25 22:10
The verification step takes place on a local instance, not a deployed one, so hopefully that allows you to put the data in the exact state you need. You may need to stub out parts of your infrastructure to achieve this.


tjones
2021-11-25 22:33
Also, depending on the framework you're using, you might not need to do this -pact-js (for example) brings the CLI tools with it.

matt.fellows
2021-11-25 22:41
Thanks Ringo!

matt.fellows
2021-11-25 22:41
I think he was using Pact Go Tim which needs it on the path

cristian.carrillo
2021-11-26 00:06
has joined #general

christoph.oswald
2021-11-26 09:53
has joined #general

gjourdanweil
2021-11-26 14:39
has joined #general

sean.pike
2021-11-26 14:48
has joined #general

varnit.garg2424
2021-11-27 09:33
Hi, In case of *non http contract* between two services - on the provider side pact tests, should we run the entire producer application to generate to output messages based on mock data? I mean how should we implement the connector to the queue? I'm pretty clear with consumer side flow, but provider side flow is all Greek to me. Any help would be highly appreciated? Do we have any sample project for reference?

matt.fellows
2021-11-27 09:42
Howtomessage



matt.fellows
2021-11-27 09:53
Short answer is no. It's a unit test

varnit.garg2424
2021-11-27 10:05
Thank @matt.fellows. Let me try to dig into it further! :slightly_smiling_face: One confusion is eliminated - that I don't have the run the entire application unlike we do in functional tests

dawoud.sheraz
2021-11-29 05:43
Hello. A curious question; who is responsible for making a decision on feature requests at https://pact.canny.io/? How does open-source contribution works for such requests if someone is interested in doing one?

michael.bannister
2021-11-29 07:43
has joined #general

mike.geeves064
2021-11-29 18:02
Depending on where the changes are for (pact-python, pact-js etc), most have a CONTRIBUTING.md (varying levels of info from project to project) which will hopefully give a starting point. You could also hop into the #pact-python, #pact-js-development etc channels and discuss there if you have a specific request you'd be interested in working on :slightly_smiling_face: I think the suggestion for most (aside from the fork/commit/PR approach) is to talk about it in the appropriate place first to make sure it's not already in progress etc

rjadams96
2021-11-29 18:47
has joined #general

pavithz
2021-11-29 23:51
has joined #general

abubics
2021-11-29 23:52
Just a general admin/visibility question . . . is http://pact.canny.io being used as an overall roadmap, or only for feature requests?

bethskurrie
2021-11-29 23:53
more feature requests

bethskurrie
2021-11-29 23:53
and letting people know what we're working on

abubics
2021-11-30 00:01
coolio, good to know :thumbsup:

bethskurrie
2021-11-30 00:01
it does not get updated as often as it should

matt.fellows
2021-11-30 01:22
We?ve never really solved the problem of a coherent roadmap everybody is working towards. Canny is best way to get feature requests across the ecosystem, github is the best place for the detail. Watch this space though

matt.fellows
2021-11-30 01:24
We?re looking to https://pactflow.io/careers/?gh_jid=5720990002 at Pactflow who will take on some OSS stewardship responsibilities to help drive some of this (amongst other things).

abubics
2021-11-30 02:50
aw man, dream job

tjones
2021-11-30 03:20
Largely, consensus on new project-wide features is reached informally by the core maintainers. It's probably worth us developing a more reasoned or at least formalised approach

tjones
2021-11-30 03:21
if it's a feature that is appropriate to do in one in one of the projects only, then it's down to the maintainers of that repository.

tjones
2021-11-30 03:21
Which feature are you interested in?

tjones
2021-11-30 03:21
(good question, btw)

dawoud.sheraz
2021-11-30 04:46
For now, I am interested in writing a Github action for setting up pact cli tools(https://pact.canny.io/feature-requests/p/github-action-which-installs-pact-cli). This will be universal and would not fall under the territory of any specific client side library.

tjones
2021-11-30 04:55
I think that would definitely be welcome

tjones
2021-11-30 05:02
Since all github runners have bash, this script might be a useful starting point: https://github.com/pact-foundation/pact-js-core/blob/master/script/lib/download-standalone.sh

tjones
2021-11-30 05:03
it's the one that we use in pact-js to download the standalone binaries

dawoud.sheraz
2021-11-30 05:09
Right. But I think we can leverage setup-ruby action(https://github.com/actions/setup-ruby) to setup ruby and simply install cli gem. Although I will have to see how extensible gem install command would be with respect to cli version.

matt.fellows
2021-11-30 05:30
You shouldn?t need to install Ruby, I?d personally start with the standalone as Tim suggested I think

matt.fellows
2021-11-30 05:31
Also, thank you for putting your hand up - in this case, I?d simply comment on the canny feature request indicating you want to pick it up so anybody else interested can see you?re picking it up

dawoud.sheraz
2021-11-30 05:33
:thumbsup:

tjones
2021-11-30 06:04
> simply install cli gem This will mean that you'll support the arches that the standalone doesn't support

matt.fellows
2021-11-30 06:09
that?s true

dawoud.sheraz
2021-11-30 06:10
Can you elaborate on this, please? I have a very less context on ruby, so I can rethink the approach if there are repercussions to installing gem. Thank you

matt.fellows
2021-11-30 06:16
I think Tim is suggesting that you do setup a Ruby runtime and then do a `gem install <artifact>` for each of the following gems: ? `pact-mock_service` ? `pact-message` ? `pact-provider-verifier` ? `pact_broker-client`

tjones
2021-11-30 06:45
I don't know much about Ruby either. But, I do know that the standalone binaries (which the script I linked you to there) don't run on (eg) aarch64

tjones
2021-11-30 06:45
I believe the ruby gems will, assuming ruby runs there

dawoud.sheraz
2021-11-30 06:57
Ah, right. thank you

varnit.garg2424
2021-11-30 10:53
Hi, let's say if we have one provider A and one consumer B and they are connected via kafa queue... Also, we have protobuf in place.. I understand that in case of http requests, pact would provide more advantage.. But in case of kafka messaging, can someone please explain in brief any real time use case in which pact would help considering there is only one consumer to the given provider?

matt.fellows
2021-11-30 11:01
Nothing stopping you - but just? maybe don?t tell Joe/Clency :wink:

mike.geeves064
2021-11-30 11:26
I think it still makes sense even with one consumer to one provider, I'm currently kicking myself for not progressing Pact tests yet where I have messages going to an AWS EventBus. It turns out because of Reasons I had ended up with numbers sometimes being a Decimal, sometimes a float, and sometimes a string for different attributes. And because the payload of the message going to the queue doesn't matter, it's just JSON the isolated tests work just fine..... having fixed them on one part it then broke the other because of no contract :open_mouth:

agittcelik
2021-11-30 18:35
has joined #general

alturil
2021-11-30 20:56
has joined #general

alturil
2021-11-30 21:08
Hi everyone! - Is there a specific channel for the https://registry.terraform.io/providers/pactflow/pact/latest/docs?

matt.fellows
2021-11-30 22:24
no, but we should make one!

mike.geeves064
2021-11-30 23:24
Having a look at how A->B->C tests could work, to try and come up with a sensible example/pattern, starting off on the python side from a thread over here: https://pact-foundation.slack.com/archives/C9VECUP6E/p1637360662056400 I'm having a look over here: https://github.com/pact-foundation/pact-python/pull/276 and am trying to figure out if this is a sensible approach or I'm going off on one :smile: Following the discussion with @joshua.badger I've progressed the idea a little with defining the pair of request/responses: https://github.com/pact-foundation/pact-python/pull/276/commits/fafb3edb52cf589dc1f2f6e752df5e25e3fd4b53#diff-33c99d63050a10d9eb8c4815ddf9e54a721cf44b25894e859c1c99179425efc6 - this is constructing a lookup which is used to handle state requests for the provider tests, and mock the endpoints at C accordingly (over here: https://github.com/pact-foundation/pact-python/blob/fafb3edb52cf589dc1f2f6e752df5e25e3fd4b53/examples/abc/provider_b_hub/tests/pact_provider_b.py#L41 ). The second part of usage is then using that same lookup to loop through and make calls from B->C to ensure that all of the mocked states are actually used to generate Pacts to avoid having essentially invalid mocks being setup due to mistmatches, since everything has to be tested, so looping through like this: https://github.com/pact-foundation/pact-python/blob/fafb3edb52cf589dc1f2f6e752df5e25e3fd4b53/examples/abc/provider_b_hub/tests/provider/test_provider_b_consumer_provider_c_provider.py#L60 Hopefully this is getting the _gist_ of the brief discussion here: https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0 input would be good on if it's a "bad" approach / suggestions of what else to turn it into a useful example. I think it's somewhere between option#1 and option#2. Very much still WIP :thinking_face:

draper.joseph
2021-12-01 06:50
has joined #general

abhay175
2021-12-01 07:35
has joined #general

joelgrimberg
2021-12-01 11:27
has joined #general

reem.alashry
2021-12-01 12:09
has joined #general

beshoy.ibrahim
2021-12-01 12:09
has joined #general

omar.radi
2021-12-01 12:10
has joined #general

mmudassar192
2021-12-01 12:11
has joined #general

eric.seipold
2021-12-01 13:40
has joined #general

tomknee1
2021-12-01 15:12
Hi I'm working on an Android project which is the consumer in this regards, does anyone know if I can write consumer pact tests without MockWebServer and instead use okhttp3 Interceptors? Thanks

apselsevier
2021-12-01 16:48
has joined #general

ali.korayem
2021-12-01 18:55
has joined #general

luiz.filipe.abrahao
2021-12-01 21:04
has joined #general

abubics
2021-12-02 00:52
as in, don't let Pact spin up a mock server? and intercept within a running app? (if so that sounds like a lot of work, and would bind the tests to the android runtime)

tomknee1
2021-12-02 09:23
ah ye if pact itself spins it up then i guess just use that, i was just looking the other day at https://medium.com/ki-labs-engineering/an-easy-way-to-mock-an-api-response-using-retrofit-okhttp-and-interceptor-7968e1f0d050

david.cummings
2021-12-02 14:13
has joined #general

miccagiann
2021-12-02 14:17
has joined #general

abubics
2021-12-03 01:32
Yeah, Pact starts up its own mock server (to set the expected requests & responses in) normally :slightly_smiling_face: For Android consumer testing in CI, I usually write the tests in Kotlin, for the plain-JVM (no Android bindings) API client, so it runs as regular unit tests (i.e. no emulator or robolectric or anything).

abubics
2021-12-03 01:33
That should provide the same facility (at least for contract tests) so you don't need to set any API mocking infrastructure up :ok_hand:

praveen.em
2021-12-03 07:40
has joined #general

tomknee1
2021-12-03 09:24
thanks for the detailed reply will go with that :+1:

ally.parker
2021-12-03 11:18
has joined #general

rishabh.gaur
2021-12-03 11:43
has joined #general

william.wallace
2021-12-03 15:12
has joined #general

batiushkov.nik
2021-12-03 15:48
has joined #general

keith.mcgrath
2021-12-03 18:28
has joined #general

rchandragupthara
2021-12-03 19:32
has joined #general

vinicius.cosmi
2021-12-03 20:01
has joined #general

ichatterjee
2021-12-03 21:27
has joined #general

ben.watts
2021-12-03 23:48
has joined #general

mike.geeves064
2021-12-05 11:43
^ would be good to get some input on the A->B->C approach from a language agnostic pov, I'm less concerned about the python and more does that at least vaguely make sense from a Pact perspective, before it goes in as a PR proclaiming to be best practice (tidying still needed, and I would envisage another PR pulling out the shared broker setup code etc because DRY)

elliottmurray
2021-12-05 12:32
Is this a way of just expressing all the possible consumer tests for B as Provider tests of B for A? Which is even more confusing when I write it! So in this example there are no actual pact tests between B and (C or D) - brackets intentional. They probably exist somewhere else. But you?ve created the corresponding fixtures of C and D to be used by the Provider bit of B in it?s Pact with A? I think this is correct but am worried (coz my head hurts from this!) that it may be more confusing?

mike.geeves064
2021-12-05 12:37
There's quite a long discussion which may help or may confuse! It's not quite the fixture of C/D in A, rather A expecting something from B, which "coincidentally" means C/D behave in a certain way

elliottmurray
2021-12-05 12:39
Isn?t that something we should discourage? It?s a leakage of concerns that means now there is a connection between a change in one of C&D and A? I did read that thread a while ago but didn?t follow all of it!

mike.geeves064
2021-12-05 12:39
On mobile atm, do you think it would help to explain starting from scratch?

elliottmurray
2021-12-05 12:39
I?ll dig out the thread and have another closer read!

mike.geeves064
2021-12-05 12:40
I think the chain of services is a legit use case, it's how to make sure you don't then get a false sense of security saying you have pacts between A and B the B and C but get a mismatch because A never calls B in a way that B can then call C

mike.geeves064
2021-12-05 12:42
But yes, idk if it's a "that's a terrible idea" in which case sharing would be bad There's a gist with I think Beth/Tim/Ron referenced but I may have misunderstood, hopefully not though

tjones
2021-12-05 22:02
The two approaches I'm aware of for A->B->C pacts are: ? Pacts between A->B and B->C ? A pact between A->C If B is a pure passthrough, then the second approach is ideal, otherwise the first approach

matt.fellows
2021-12-05 22:04
If I understood the original conversation, the challenge is ?how do you make sure that there are no gaps between the set of interactions/scenarios captured in A->B and B->C?. i.e. you might have code paths mocked in the A->B provider test that aren?t then included as consumer tests is B->C

mike.geeves064
2021-12-05 22:08
nod, trying to illustrate the second approach, with a request B->C which "gets all" and B does some logic "only return one of them" in reply for the A->B request for a somewhat contrived example and yes to avoiding gaps, as well as mismatches, the suggestion of store them in another object, which I've then iterated over seems to cover it, it feels a little clunky adding another thing in the way like that but I'm not sure how else would be better

mike.geeves064
2021-12-05 22:10
just going A->C and pretending there's no B sounds daaaangerous :open_mouth:

matt.fellows
2021-12-05 22:13
I think that?s only a valid scenario if B is a proxy/gateway (e.g. it?s common to ignore AWS API Gateway as a separate component)

tjones
2021-12-05 22:15
if B is a passthrough, then the contract is between A and a conceptual B, which could be played by B or C

mike.geeves064
2021-12-05 22:16
ah true, I've generally ended up 1 API GW per service but yes I suppose there might be lots

tjones
2021-12-05 22:16
Pact's model doesn't actually handle that too well - it's not easy to express "my contract is for any service that might provide for me"

tjones
2021-12-05 22:17
> ah true, I've generally ended up 1 API GW per service but yes I suppose there might be lots The common case is 1 API gateway -> many services. What is the "provider" in that case?

mike.geeves064
2021-12-05 22:17
nod. for that one I was just going to assume you pretend there's no B really

mike.geeves064
2021-12-05 22:18
I mean 1 API GW -> 1 service for API GW usage in general, rather than Pact specific, I've tended to have them all individual

mike.geeves064
2021-12-05 22:20
does the general concept of some object acting as a lookup to set mocks against (provider tests) but then re-use iterating through for the consumer tests make sense enough then?

tjones
2021-12-05 22:29
I'm not sure I'm following your question, sorry

tjones
2021-12-05 22:33
The problem with pact + API gateways is that there's usually an extra part of the URL: consumer -> `http://host.com/serviceC/foo` provider `http://provider.com/foo` where the API gateway uses the URL to switch the service it speaks to

tjones
2021-12-05 22:34
Usually I've solved this with the baseURL - `http://host.com/serviceC`, but this makes me uncomfortable, because you're not testing the actual URL that is really hit

mike.geeves064
2021-12-05 22:34
forget the API GW part specifically, this is assuming something more complicated

mike.geeves064
2021-12-05 22:34
yeah

tjones
2021-12-05 22:34
well...

tjones
2021-12-05 22:34
what other passthrough designs do you have?

tjones
2021-12-05 22:34
sounds fishy to me.

tjones
2021-12-05 22:34
I like the idea that it's hard to test questionable design :wink:

tjones
2021-12-05 22:35
but I also like the idea that pact doesn't have strong opinions on your designs

mike.geeves064
2021-12-05 22:35
there's a longer explanation when asked initially above a bit, I'm referring to the https://github.com/pact-foundation/pact-python/pull/276/commits/fafb3edb52cf589dc1f2f6e752df5e25e3fd4b53#diff-33c99d63050a10d9eb8c4815ddf9e54a721cf44b25894e859c1c99179425efc6 part where there's an object that contains the lookup of state description from A->B, and what B does to mock then ask, e.g. > "Some orders exist": RequestResponsePair( > provider_name="ProviderDOrders", > request_args=RequestArgs("GET", "https://orders", "/1"), > response_status=200, > response_content_filename="order.json", > method_name="get_order", > method_args={"order_id": 1}, > ), which tries to tie up the handle "Some orders exist" A->B, mocking that the request to https://orders gets the reply order.json..........but then there's a set of tests generated (for each of the keys in the mock) which is calling the get_order request to trigger the consumer request

tjones
2021-12-05 22:35
however, questionable design is hard to test, whether or not you do it with pact

tjones
2021-12-05 22:35
hmmmm

tjones
2021-12-05 22:35
sounds like an integration test to me

mike.geeves064
2021-12-05 22:37
ha, so in terms of concrete designs, I'm lacking :slightly_smiling_face: this is just from someone else asking for ideas and there not being much more in terms of examples than a gist without any impl :slightly_smiling_face:

mike.geeves064
2021-12-05 22:39
at least for https, i will have some more A->B->C use cases myself with message (where I'll have some services receiving from an event bridge and making http calls, others submitting to the event bridge and so on), but first I will need to make sense of that in python, which is a problem for another day :slightly_smiling_face: :thinking_face: maybe A->B->C makes more sense in general with event driven architecture than just usual http

mike.geeves064
2021-12-05 22:41
not sure that counts as integration tests, alternatively there would just be straight pact tests for B->C, but that then leaves potential holes if your expected C "behaviour" that gets mocked for A->B doesn't match up with actual C behaviour, if the tests are totally separate

tjones
2021-12-05 22:43
Yes, that's right

tjones
2021-12-05 22:43
you have this problem with A->B pacts too

tjones
2021-12-05 22:43
I think the solution is the same

tjones
2021-12-05 22:44
Like, I have to ensure that my consumer test assertions use the same data as my regular unit tests

mike.geeves064
2021-12-05 22:44
that's true

tjones
2021-12-05 22:45
The consumer code is like: consumer business code -> consumer API code

tjones
2021-12-05 22:45
A pact test has the test callipers around the API layer in the consumer

tjones
2021-12-05 22:45
and asserts that some particular object comes out of it

tjones
2021-12-05 22:46
you have to use this same object in the consumer business code unit tets

mike.geeves064
2021-12-05 22:46
you do have at least more protection from it though, by pact itself making sure all the consumer expectations are then run against the provider for the provider tests

tjones
2021-12-05 22:47
You *could* do this by configuring pact during each of those unit tests, but I don't think that's a good practice

tjones
2021-12-05 22:48
The contract would either be polluted by lots of repeat examples, or you'd tie the contract data to the unit test data

tjones
2021-12-05 22:48
You'd start having the problems that integration testing has, and then I don't think you'd be getting much advantage from pact

tjones
2021-12-05 22:48
might be interesting to try, but my gut feeling is that you'd have a bad time

mike.geeves064
2021-12-05 22:49
lol

tjones
2021-12-05 22:49
The point of contract testing (at least from my perspective) is to enable you to test elements of the system in isolation

mike.geeves064
2021-12-05 22:49
(I am thinking but my head is slowing down for the night)

tjones
2021-12-05 22:50
I see the argument for "well I want to test the actual system, when it is actually all configured", but also, if you know what the contracts are, you don't need to test that.

tjones
2021-12-05 22:50
or you don't need to test it thoroughly

mike.geeves064
2021-12-05 22:51
if you're testing A->B and B->C they are in isolation? the double usage is only for the B->C where you run against B as provider then B as consumer

tjones
2021-12-05 22:51
at B->C time, A is irrelevant

mike.geeves064
2021-12-05 22:51
yep

tjones
2021-12-05 22:52
This is why I like mocking as close to the repository / upstream layer as possible

mike.geeves064
2021-12-05 22:53
that's what's happening here, A doesn't know anything about C, only what it expects to get back from B

mike.geeves064
2021-12-05 22:54
B just uses the vague awareness A has of the world and what it expects from B so that B can setup appropriate mocks (as in, the description of state)

mike.geeves064
2021-12-05 23:01
I think I'm not quite following the pact ones there

tjones
2021-12-05 23:02
This is where I would mock during pact verification

tjones
2021-12-05 23:02
some people mock the business layer. I think that gives less confidence

mike.geeves064
2021-12-05 23:02
yes, doing the mock there, the mock is purely mocking the http request in this case

mike.geeves064
2021-12-05 23:06
with the example higher up, thats: > "Some orders exist": RequestResponsePair( >         provider_name="ProviderDOrders", >         request_args=RequestArgs("GET", "https://orders", "/1"), >         response_status=200, >         response_content_filename="order.json", >         method_name="get_order", >         method_args={"order_id": 1}, >     ), for pact verification tests of B, the mocked A is going to send "Some orders exist", and then B is going to set a http mock for the https://orders/1 request


tjones
2021-12-05 23:06
the mock isn't doing that at all

tjones
2021-12-05 23:06
the mock is mocking the API client

mike.geeves064
2021-12-05 23:06
(ohhhh, which reminds me, I think the Rust lib always sends teardown state calls, and the option isn't working properly, but I didn't go through it properly yet :thinking_face: )

tjones
2021-12-05 23:07
`getUser("steve") will return new User("Steve", "admin" ....)`

tjones
2021-12-05 23:07
it mocks the API *layer*, not the API

tjones
2021-12-05 23:07
so that you can express your mocks in business logic language, not in API detail

tjones
2021-12-05 23:07
This might make the pact part of the diagram clearer

mike.geeves064
2021-12-05 23:07
wait API client mock isn't the C consumer part of B?

tjones
2021-12-05 23:08
It's the consumer part of B

tjones
2021-12-05 23:08
that consumes C

mike.geeves064
2021-12-05 23:08
yus

tjones
2021-12-05 23:09
The mock example you provided is mocking here:

tjones
2021-12-05 23:10
^ I don't think you should do that

tjones
2021-12-05 23:10
because it makes the provider state harder to write

tjones
2021-12-05 23:11
```given some user "steve" exists get upstream/users/steve <with credentials / headers etc> will return 200 <....JSON details....>```

tjones
2021-12-05 23:12
vs ```given some user "steve" exists repositoryMock.getUser("steve") will return new User("Steve",.... business details)```

tjones
2021-12-05 23:13
^ This one is robust to changes in how the repository works

mike.geeves064
2021-12-05 23:14
I think I will need to re-read that quite a few times :smile:

tjones
2021-12-05 23:15
If your mocks contain details of how the upstream dependency works, then you will need to change them whenever the upstream dependency changes

tjones
2021-12-05 23:15
but you don't care about that at that time

tjones
2021-12-05 23:16
Ideally, you should be able to completely rewrite your service and not change your tests

tjones
2021-12-05 23:16
this means that you (in general) don't want to mock

mike.geeves064
2021-12-05 23:16
nod

tjones
2021-12-05 23:16
but the reason that pact has mocks is so that you can do a unit test across two deployable units

tjones
2021-12-05 23:17
you're doing a unit test for the client on one side and the server on the other

mike.geeves064
2021-12-05 23:17
individual parts make sense, not quite there with how that works as a whole flow though

tjones
2021-12-05 23:17
the risk introduced by this is mitigated by the contract file keeping them in sync

mike.geeves064
2021-12-05 23:19
[just to check, I'm not confusing this by mixing up usage of mocks and stubs am I? calls to C being stubbed for the purposes of the A->B provider tests]

tjones
2021-12-05 23:20
We don't call C at all during B's test as a provider

tjones
2021-12-05 23:20
Or, you could, but in my view you're going to have a bad time

mike.geeves064
2021-12-05 23:20
that bit will need some refactoring/re-thought :thinking_face:

tjones
2021-12-05 23:21
You could think of it like this

tjones
2021-12-05 23:22
The three places you could mock during a provider test are:

mike.geeves064
2021-12-05 23:22
(also apologies, I'm being very slow right now, late!)

mike.geeves064
2021-12-05 23:24
ok, so from your pov where I have say: > class OrderConsumer(object): > def __init__(self, base_uri: str): > self.base_uri = base_uri > > def get_order(self, order_id: int): > url = f"{self.base_uri}/{order_id}" > response = session.get(url) > return response.json() rather than stubbing out the "session.get" http call directly, you'd just replace the whole get_order with a mocked response?

tjones
2021-12-05 23:24
`OrderConsumer` <-- I mock this

mike.geeves064
2021-12-05 23:24
ok or that too :slightly_smiling_face:

tjones
2021-12-05 23:25
in that example, `OrderConsumer` is the API layer for some service that needs orders from somewhere

tjones
2021-12-05 23:26
Note that even though I prefer to mock the API layer, it might be easier to mock at either of the other places, depending on your preferences, design and ecosystem

tjones
2021-12-05 23:26
@abubics and I once mocked the business logic because that's what made sense on that project

mike.geeves064
2021-12-05 23:27
:smile:

mike.geeves064
2021-12-05 23:27
I mean, when the whole controller code is: > @app.get("/orders/{order_id}") > def get_order(order_id: int): > return order_consumer.get_order(order_id=order_id)

tjones
2021-12-05 23:27
why do you have that service?

tjones
2021-12-05 23:27
:stuck_out_tongue:

mike.geeves064
2021-12-05 23:27
it's an example!

mike.geeves064
2021-12-05 23:27
:slightly_smiling_face:

tjones
2021-12-05 23:27
Right, but the question is still valid

tjones
2021-12-05 23:27
say the service is providing auth

tjones
2021-12-05 23:28
the controller might look like that, with the auth provided via middleware

tjones
2021-12-05 23:28
so I mock `order_consumer` during verification of that service

tjones
2021-12-05 23:29
and there's a contract for "when the auth is valid" and one for "when it isn't"

tjones
2021-12-05 23:29
we're now testing the service's part of the contract

tjones
2021-12-05 23:29
but we're not testing (or even knowing anything about) what the service's upstream contracts are

mike.geeves064
2021-12-05 23:30
hmm, am I testing "too much" here on the pact side perhaps? :thinking_face:

tjones
2021-12-05 23:30
we do that separately

tjones
2021-12-05 23:30
I think so

tjones
2021-12-05 23:30
but hey, ymmv

mike.geeves064
2021-12-05 23:30
:smile:

tjones
2021-12-05 23:30
I have to go

mike.geeves064
2021-12-05 23:31
well thank you for the (repeated attempts to give an) explanation!

mike.geeves064
2021-12-05 23:31
I'll be re-reading in the morning and see if I can split that out in a meaningful way, hopefully without it will make sense without further questions :smile:

mike.geeves064
2021-12-05 23:33
it's going to need something similar to try and tie in the extra unit test parts I think, of "make sure an http req is made to x"

mike.geeves064
2021-12-05 23:33
hmm

mike.geeves064
2021-12-05 23:33
will see!

tjones
2021-12-05 23:42
I spoke about matching those up in the talk I did last year, I'll link you later :slightly_smiling_face:

imikhtyuk
2021-12-06 00:36
has joined #general

aforeman
2021-12-06 04:00
*The inaugural Pactflow Contract Testing Report is now live* :raised_hands: Earlier this year, we asked Pactflow customers and users of the self-hosted Pact Broker what they thought about contract testing. We had responses from more than 41 different industries, seven world continents and +100 different organisations. So, we are pleased to share with you the *inaugural Pactflow Contract Testing Report!* Inside you?ll read how others have added contract testing to their test strategy and the outcomes they?ve since experienced, the differences between using Pactflow and the self-hosted Pact Broker plus what you?d like to see us improve and how we?re actioning this to create a better experience for you. Access the report https://pactflow.io/pactflow-contract-testing-report-2021/ :tada: *And it doesn't stop there!* For our final live Ask Me Anything next week, @bethskurrie, @matt.fellows and I will discuss aspects of the report, including the *differences between Pactflow and the self-hosted Pact Broke*r. Add it to your calendar https://www.linkedin.com/events/contracttestingama-comparingpac6869498736658264064 and be sure to post any questions in advance in #pactflow-ama

norrischebl
2021-12-06 05:54
has joined #general

smantini
2021-12-06 09:25
has joined #general

elliottmurray
2021-12-06 09:36
This was a really long thread but I think Tim has advocated in better words what I think we should be doing. Not tying A & C directly via the same Pact? And using Test Driven Design techniques to create the appropriate abstractions so we ca test?

mike.geeves064
2021-12-06 09:48
They're not being tied directly, two separate pacts are being created currently anyway, but there is some mingling of concerns around the second pact with the Producer/Consumer parts

mike.geeves064
2021-12-06 09:49
Going through some other bits first then will be trying to figure out how to restructure, or if not, what else I didn't ask :smile:

gzinger
2021-12-06 11:19
has joined #general


tjones
2021-12-06 12:36
Here's the bit of the talk with (at least the slide) where I talk about this

tjones
2021-12-06 12:37
talking about joining the contract test fixtures with the unit tests

tjones
2021-12-06 12:38
The tl;dr of the above I think is - in a best-practice scenario, your provider verification should not need a pact consumer test to be set up

mahatmafatal
2021-12-06 13:50
has joined #general

jacob.v.gardner
2021-12-06 14:59
has joined #general

glebing2000
2021-12-07 07:28
has joined #general

mike.geeves064
2021-12-07 09:15
I like the example style of just having "Matt is/isn't a valid user to create" rather than "Matt does/doesn't exist" :thinking_face:

tjones
2021-12-07 09:31
I think that's a nice one for illustrating the functional tests vs contract tests

tjones
2021-12-07 09:31
also it's nice that Matt exists

mike.geeves064
2021-12-07 09:31
lol aww

mike.geeves064
2021-12-07 09:31
I *think* from your talk, I'm largely trying to do it like that, using the same responses with/without the like etc to be able to use in various places, but just the one part of ideally just mock the calling function rather than the http req, which is fine because getting python to share the session bit etc was not nice :smile:

mike.geeves064
2021-12-07 09:32
Yeah, it's "obvious" but haven't seen it illustrated elsewhere so far

mike.geeves064
2021-12-07 09:33
There was definitely an "ohhhhhh!" moment :slightly_smiling_face:

tjones
2021-12-07 09:34
Soon you'll be thinking "wait, isn't every type of test just a contract test in disguise?"

tjones
2021-12-07 09:34
(I... started thinking that about 2 years ago and haven't stopped)

mike.geeves064
2021-12-07 09:35
lol

mike.geeves064
2021-12-07 09:36
does that extrapolate a little to "every type of test is just a poorly written contract test in disguise"? :smile:

tjones
2021-12-07 09:36
also yes

mike.geeves064
2021-12-07 09:36
:joy:

mike.geeves064
2021-12-07 09:39
I'm very nearly at a point of adding Pact tests into my stuff, so we'll see how quickly that thought change goes :slightly_smiling_face:

sergio.freire
2021-12-07 09:52
has joined #general

sahoo.skumar
2021-12-07 10:55
has joined #general

srividya.ece
2021-12-07 14:49
Hi All.. A basic question. when to use pact-stub-service? can some one please provide a use case with an example. As from my understanding pact-mock-service are used for consumer unit tests and after performing unit tests against mock provider , pact file will be generated.

srividya.ece
2021-12-07 14:49
But what is the use of Pact stub service?

kingyang728
2021-12-07 15:58
has joined #general

jesseaantebi
2021-12-07 19:36
has joined #general

rsheikh
2021-12-07 22:34
has joined #general

jorgwel
2021-12-08 01:22
has joined #general

rahul.anwekar23
2021-12-08 04:19
has joined #general

rahul.anwekar23
2021-12-08 04:24
Hi, I am working in Telstra and trying test the webhook which should trigger the bamboo build whenever contract gets updated. To do the same, I have created a web hook and trying to test this by running execute api but getting error response . Can someone please help?

rahul.anwekar23
2021-12-08 04:25
Below is my request payload: {   "provider": {     "name": "BusService"   },   "events": [{     "name": "contract_content_changed"   }],   "request": {     "method": "POST",     "url": "https://bamboo.tools.telstra.com/rest/api/latest/queue/ATSP-CON?os_authType=Bearer",     "headers": {        "Authorization":"Bearer <token>",       "Accept": "*/*"           }   } }

matt.fellows
2021-12-08 04:27
What's the error response you're getting?

matt.fellows
2021-12-08 04:28
Is the bamboo server accessible to your Pactflow instance and also does it have a real or self signed certificate?

2021-12-08 04:28
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

rahul.anwekar23
2021-12-08 04:28
{     "request": {         "headers": {             "accept": "*/*",             "user-agent": "Pact Broker v2.83.0",             "authorization": "**********"         },         "url": "/rest/api/latest/queue/ATSP-CON?os_authType=Bearer"     },     "message": "For security purposes, the response details are not logged. To enable response logging, configure the webhook_host_whitelist property. See http://localhost:9292/doc/webhooks#whitelist for more information.",     "logs": "[2021-12-07T15:49:52Z] DEBUG: Webhook context {\"base_url\":\"http://localhost:9292\",\"event_name\":\"test\"}\n[2021-12-07T15:49:52Z] INFO: HTTP/1.1 POST https://bamboo.tools.telstra.com/rest/api/latest/queue/ATSP-CON?os_authType=Bearer\n[2021-12-07T15:49:52Z] INFO: accept: */*\n[2021-12-07T15:49:52Z] INFO: user-agent: Pact Broker v2.83.0\n[2021-12-07T15:49:52Z] INFO: authorization: **********\n[2021-12-07T15:49:52Z] INFO: null\n[2021-12-07T15:49:52Z] ERROR: Error executing webhook 61bEtSp7Tg2FS79AN1817Q. For security purposes, the response details are not logged. To enable response logging, configure the webhook_host_whitelist property. See http://localhost:9292/doc/webhooks#whitelist for more information.\n[2021-12-07T15:49:52Z] INFO: Webhook execution failed\n",     "success": *false*,     "_links": {         "webhook": {             "href": "http://localhost:9292/webhooks/61bEtSp7Tg2FS79AN1817Q"         },         "try-again": {             "title": "Execute the webhook again",             "href": "http://localhost:9292/webhooks/61bEtSp7Tg2FS79AN1817Q/execute"         }     } }

rahul.anwekar23
2021-12-08 04:28
this is the response


matt.fellows
2021-12-08 04:29
So the error is in your broker logs, as per the error message. Have you asked to get those?

rahul.anwekar23
2021-12-08 04:30
Hi @matt.fellows I have already added WEBHOOK_HOST_WHITELIST: 'http://bamboo.tools.telstra.com' in my docker compose

rahul.anwekar23
2021-12-08 04:32
How to check whether bamboo server is accessible or not from my pactflow instance?

abubics
2021-12-08 04:32
You shouldn't have to really care about the stub or mock service unless you have an unusual use case. The framework starts up the bits it needs in regular workflows.

matt.fellows
2021-12-08 04:33
Are you running Pactflow or the pact broker?

matt.fellows
2021-12-08 04:33
I'm assuming you're running the OSS broker

rahul.anwekar23
2021-12-08 04:34
I am running pact broker

rahul.anwekar23
2021-12-08 04:35
running on my localhost:9292

matt.fellows
2021-12-08 04:35
To check if it's accessible, you'll need to ssh onto your broker docker instance and use networking tools

matt.fellows
2021-12-08 04:35
Best you enlist somebody at Telstra who can help you there

rahul.anwekar23
2021-12-08 04:36
okay, thanks..

matt.fellows
2021-12-08 04:38
The reason I say that is your network and configuration is likely to be unique. I'd look out for self signed certificates, inaccessible network paths, invalid credentials or simply an invalid request

rahul.anwekar23
2021-12-08 04:38
I have a question, pact broker is running on my localhost and I connected to VPN. So in that case bamboo should be accessible

matt.fellows
2021-12-08 04:43
Networking is a complex topic, so yes in theory but it depends. You're going to have to use standard networking, Linux and docker debugging tools to confirm all of this, so I'd recommend pairing with somebody who has those skills

matt.fellows
2021-12-08 04:43
This isn't a pact specific issue, I guess is what I'm saying

rahul.anwekar23
2021-12-08 04:46
Is it possible for you if I show you the issus by doing screen share?

matt.fellows
2021-12-08 04:47
Feel free to take a recording and pop it here

matt.fellows
2021-12-08 04:47
Or share the log files

rahul.anwekar23
2021-12-08 04:47
Sure

matt.fellows
2021-12-08 04:52
See also this. You should be able to see why the webhook is failing at debug level in your logs. This is where you should start: Host: If the webhook_host_whitelist contains any entries, the host must match one or more of the entries. By default, it is empty. For security purposes, if the host whitelist is empty, the response details will not be logged to the UI (though they can be seen in the application logs at debug level).

srividya.ece
2021-12-08 07:10
Could you please tell me the difference when to use stub service. Any use case?

abubics
2021-12-08 08:06
I cannot, I haven't used either of them standalone. I think one (or both?) could be used as a stub for testing without contract tests, although it would need to have interactions from a pactfile loaded at the right times.

abubics
2021-12-08 08:07
Why are you asking, though? Are you having trouble with something in particular? Knowing your problem can help people give you better answers :)

matt.fellows
2021-12-08 08:53
How'd you go?

srividya.ece
2021-12-08 10:44
Yes, We have a strange requirement, where request and response will be provided in JSON format(example below), where we need to define all the interaction in the mock server. There are multiple teams(though we are aware these are unit test) who want to perform consumer tests against mock and a pact file should be generated from it and later will be published to provider and verified against actual provider ```{   "request": { "path": "/image/v1", "method": "GET" },   "response": {     "status": 200,     "body": "img_news.jpg",     "headers": {       "Content-Type": "image/jpeg"     }   }```

abubics
2021-12-08 11:56
> perform consumer tests against mock and a pact file should be generated from it and later will be published to provider and verified against actual provider You just described exactly how Pact works :100::ok_hand: except it'd be "published to a broker"

abubics
2021-12-08 11:56
Is the first bit (about the strange requirement & this specific JSON structure) separate to the contract testing workflow?

srividya.ece
2021-12-08 12:10
yes, the first part is a bit separate to how pact works. but,I am not sure how it works.

srividya.ece
2021-12-08 12:22
Also, it's my mistake, I mean will be published to broker.

luanacosta05
2021-12-08 20:34
has joined #general

tjones
2021-12-09 00:24
The pact framework will spin up the pact server for you. The only time you would want to spin them up manually is if you are unable to use the framework (for example if you are not using one of the core supported languages)

tjones
2021-12-09 00:26
If you?re using JS, a JVM language, ruby, Python, C#, Go, Rust or (I think) php, you can use the pact framework to setup the mock servers for you

saurabh.techiee
2021-12-09 09:41
has joined #general

albertcabantog
2021-12-09 10:52
has joined #general

srividya.ece
2021-12-09 10:53
Hi @tjones I want to use JVM (java) but can I setup a standalone server here?

srividya.ece
2021-12-09 12:32
"The pact framework that spin up the *mock server*". Here can I make this *mock server* standalone and can other access this mock server to perform consumer test. This is a strange question, but would like to know if this is possible



tjones
2021-12-09 22:47
Why do you want to do this?


tjones
2021-12-09 22:49
The consumer tests (and therefore the configured mock server) are tied closely to the consumer under test. I think you will have a bad time if you try to share the mock

paul.scholes
2021-12-10 10:21
has joined #general

chris.sloan
2021-12-10 10:48
has joined #general

leon.york
2021-12-10 12:42
has joined #general

kyle.craviotto
2021-12-10 16:40
has joined #general

kyle.craviotto
2021-12-10 17:06
hello all, we are evaluating pactflow within our company and I have a few questions regarding the environment and how it interacts with can-i-deploy. 1. Does the environment have to match exactly between the consumer and provider? 2. Is there any way to make it so they don't match? For example in our org, our environments don't always match, we may have one team that has an environment called Test-A where another team just has Test or even Non-Prod

lorenz.schumann
2021-12-10 18:33
has joined #general

matt.fellows
2021-12-10 21:36
Well if they don't match how would you know if it's safe? From a pact perspective you'll need to match any environments that need to be tested for compatibility

matt.fellows
2021-12-10 21:37
They can be different to the actual environment description which might change over time

kyle.craviotto
2021-12-10 21:40
I see your point, unfortunately we are coming from a place where a consumer might have 3+ test environments but they are all pointing at our one 'test' environment for our provider. I guess in that case we would just make sure that the environment is always 'test' in our non-prod environment. Prod shouldn't be an issue

matt.fellows
2021-12-10 22:04
Mm you could perhaps you could call it with multiple args. I don't have the CLI in front of me but there be provisions for this already

norway.martin
2021-12-10 22:24
You can tag it however you want in Pactflow. As long as you tag them all the same it should work. You can also tag it with multiple environemnts. So you can have both `Test-A` and `Test` .

norway.martin
2021-12-10 22:24
The easier options it to standardize the environments though. It will make other CI/CD processes a lot easier too

kyle.craviotto
2021-12-11 00:33
so you can say --to-environment test-a --to-environment test for example?

luispires.m
2021-12-13 12:32
has joined #general

norway.martin
2021-12-13 15:13
I don't think you can target multiple environments with can-i-deploy. Regarding your questions: 1. Yes. They have to match. That's the whole point of environments. 2. Not sure why your company has teams with different environments names, but you can fix that in Pactflow by just tagging them correctly. For example, if Test-A. Test, and Non-Prod are all test environments, just tag them as `test`. You are not required to use their current names.

fabio.rodrigues
2021-12-13 16:21
has joined #general

kyle.craviotto
2021-12-13 16:33
We are a pretty huge org, so there's a lot of cruft built up over the decades, one thing we are really trying to remove is the idea of having 15+ environments (I'm not kidding)

kyle.craviotto
2021-12-13 16:40
but regardless after reviewing I think it is the correct move to have the environments matching. I think a short term solution may be to 'record-deployment' to all environments that match up with a deployment. For Example: Provider A: is already in test Consumer A: calls Provider endpoint 'test' in environments test-a, test-b, test-c, etc... Consumer A deploys to test-a, test-b unless Provider A - records deployment to test-a, test-b then Consumer A's can-i-deploy check will fail as the environments don't match.

mbailey
2021-12-13 22:17
has joined #general

mbailey
2021-12-14 02:20
I have a general question (and this is #general!) What are the consumer unit test cases for? In other words, at least in the JVM version, I?m defining the Pacts: when I hit this path with X, I should get Y response. Then there are unit tests that essentially say, ?When I hit this path with X, I should get Y response?. Seems like I?m testing my test, as it were. Or are the consumer tests required to run to generate the Pact json?

matt.fellows
2021-12-14 02:22
The best way to think of it is that Pact _is_ a unit testing tool. It just so happens to also produce a contract

mbailey
2021-12-14 02:24
I?ve found cases in unit tests where someone is in essence testing the mock to make sure the mock returns what you told the mock to return. Is this (the consumer unit tests) any different? I?m assuming here that it?s not the unit tests but the pact sections that generate the contract, since they?re not 1-to-1

uglyog
2021-12-14 02:29
The test is meant to test the consumer code. Ie., if we make request X, and should return response Y, then we get the consumer code to make that request, and then check that it has handled the response Y correctly. Then we know that this side of the integration is good.

mbailey
2021-12-14 02:56
I think the disjunct may be that we use Feign - I?m just defining an interface, rather than a service using RestTemplate that may have bugs. So it feels l?m just testing the Pact I defined.

uglyog
2021-12-14 03:00
If your interface is not correct, the mock server may pick that up or the Pact verification should pick that up on the other side

matt.fellows
2021-12-14 03:09
Exactly. There are still assumptions, presumably, to define the interface that Feign will use to generate the HTTP client. These are assumptions are what Pact is designed to formalise into a contract for verification

dkwak
2021-12-14 03:47
has joined #general

matt.fellows
2021-12-14 05:02
> We are a pretty huge org, so there?s a lot of cruft built up over the decades, one thing we are really trying to remove is the idea of having 15+ environments (I?m not kidding) I like to refer to it as sedimentary rock. Because they are old, hard to remove, and buried beneath many other layers (incl. bureaucracy). But you?re not alone friend!

matt.fellows
2021-12-14 05:05
That approach could work Kyle. So long as all of the teams know what it means

matt.fellows
2021-12-14 05:06
I can see the complexity. @bethskurrie might have already predicted this when planning that feature (Beth?s away on leave today/tomorrow)

haoran.lin
2021-12-14 05:27
has joined #general

matt.fellows
2021-12-14 05:32
When looking at tools to help intercept requests in Pact JS (to help identify requests that should have gone to the mock server, but did not) I came across this project, and this very interesting comment (which reflects the Pact philosophy pretty nicely): https://github.com/moll/node-mitm/issues/1#issuecomment-44026236

tom450
2021-12-14 08:06
has joined #general

pajaree.tuampitak
2021-12-14 10:00
has joined #general

nitins333
2021-12-14 10:03
has joined #general

jaakko.tompuri
2021-12-14 13:10
has joined #general

albert.moreno
2021-12-14 17:01
has joined #general

mbailey
2021-12-14 21:23
I see what you?re saying about defining the interface. In our case, the interface is defined on the provider side by defining a `@RequestMapping` interface and exporting that to the consumers to build their Feign clients off of. So there can never be an interface error in a client test. Does that remove the assumptions you?re talking aobut @matt.fellows?

matt.fellows
2021-12-14 22:12
I think it falls into the problem space of client SDKs: https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/

mbailey
2021-12-14 22:46
Haha you?re way ahead of me!

mbailey
2021-12-14 22:57
I think I am still missing something here: Yes, our API changes, and yes, producers can be released at different times than consumers. But 1. If the provider API changes, isn?t it the Pact tests on the provider side that are going to test that? Unless the provider is somehow generating its own contract and sending it to the broker, the fact that it has broken the API for the client will not be caught by the client tests. It?s the contract that?s important, and in the examples that I see, the consumer tests are just testing against the contract in the same file. And 2. If the client implementation actually changed to require a new field, the client tests will not fail unless someone remembers to update the contract, but does not remember to redundantly update the consumer tests. What is a use case using an SDK where a consumer test would catch an actual error? Apologies if it?s in your article and I?m just not seeing it - I?m a bit lost in the SOAP section.

matt.fellows
2021-12-15 00:00
Right, yes that?s true

matt.fellows
2021-12-15 00:00
the art is in generating a contract here for the different use cases

mbailey
2021-12-15 00:07
I?m not sure I get you. Is there a use case where the contract would not successfully detect a breaking change, but the unit test would, due to different granularity?

matt.fellows
2021-12-15 00:19
(sorry, I started responding but had to run to a meeting? gimme 10 :wink: )

mbailey
2021-12-15 00:40
no worries

matt.fellows
2021-12-15 00:47
So there are a few threads on this topic (search for the link shared above for references to those) e.g. https://pact-foundation.slack.com/archives/C5F4KFKR8/p1610034769384400 and https://pact-foundation.slack.com/archives/C5F4KFKR8/p1618958876104600

matt.fellows
2021-12-15 00:48
> I?m not sure I get you. Is there a use case where the contract would not successfully detect a breaking change, but the unit test would, due to different granularity? no, but that?s only part of the benefits of contract testing. 1 benefit, a major one of course, is detecting breaking changes

matt.fellows
2021-12-15 00:49
there are numerous benefits to a provider though, in aiding its ability to evolve over time. If you always assume every consumer uses the entire surface area of a provider, you can never deprecate anything without significant overhead.

matt.fellows
2021-12-15 00:49
If you know exactly which scenarios a consumer is using, down to the field level, Providers have better visibility into how their API is being used and what options they have to change

matt.fellows
2021-12-15 00:49
and then there is of course the CI/CD benefits of decoupling release processes

mbailey
2021-12-15 00:54
I totally agree about benefits for provider testing. The ?entire surface area? issue is what led me to investigate this. There?s a lot of documentation benefit. So I?m sold on contract testing, and consumer-driven contract testing (Spring Cloud Contract does not appear to offer the ability to have breaking provider changes fail out of the box). But all those benefits come from defining the contract. I?m just trying to reduce the startup cost of this - and if the consumer tests are not necessary for the contract testing benefits, that would be a good area to trim. Thanks for the links, I?ll read through them soon.

matt.fellows
2021-12-15 01:29
I think in your case, if you can reliably produce the sets of interactions used by each of the clients (however you do that) then that?s OK/sufficient to generate the contract itself

matt.fellows
2021-12-15 01:30
Where it gets a bit more difficult, is verifying on the provider side. If you auto generate the tests you need to be careful with provider states - because this will become a burden the provider has to live with

matt.fellows
2021-12-15 01:31
> you use pact for your UI tests, you?ll end up with an explosion of redundant interactions that will make the verification process tedious. Remember that pact is for testing the contract used for communication, and not for testing particular UI behaviour or business logic. from https://docs.pact.io/getting_started/testing-scope/#scope-of-a-consumer-pact-test

matt.fellows
2021-12-15 01:31
You may also be interested in a Pactflow feature currently in developer preview called bi-directional contracts: https://docs.pactflow.io/docs/workshops/bi-directional

matt.fellows
2021-12-15 01:32
It?s separate to Pact, and might be a bit more inline with what you need. Auto-generating client contracts, but also comparing those contracts to what the provider produces (initially by comparing to an OAS)

mbailey
2021-12-15 02:06
Thanks, I?ll take a look. Since we already have a pretty mature ecosystem, not starting from scratch, if there?s a way to jumpstart the consumer-side testing, either by recording contracts in some way, or by generating off of classes/schema, it might be an easier sell to our organization.

himanshu
2021-12-15 06:16
has joined #general

diva.pant1
2021-12-15 14:21
has joined #general

diva.pant1
2021-12-15 14:44
Hi everyone, I am new to Pact and contract testing and trying to understand if contracts are better than schemas in terms providing better validations, then how come using schema for provides in the bidirectional flow becomes even better than just using Pact contracts. I mean I understand the approach in terms of scalability and faster execution, but do OpenAPI schemas provide better validation in this case?

diva.pant1
2021-12-15 14:58
I would also like your opinion on schema testing vs contract testing vs bi-directional contract testing. So far that I have read, in my understanding bi-directional contracts trumps other approaches, right?

mike.geeves064
2021-12-15 15:38
Did you find the article on schemas vs Pact? https://pactflow.io/blog/schemas-are-not-contracts/ That might help explain differences

diva.pant1
2021-12-15 16:16
Hi yes I did, I understand the schemas are just the descriptions, whereas contracts are created between two microservice, and we write a code for it. But then what does schema-based contract testing mean. I read an article on schema based contract testing as well. But didn't quite understand. So in the schema based testing approach how are contracts created for example, after we have the OpenAPI specification schema, the contract is formed between whom? If the contract is made, means some coding is done. So coding is done on which side, provider or consumer?

johnreilly100
2021-12-15 16:36
has joined #general

mbailey
2021-12-15 17:51
Matt pointed me to this doc for project status on that https://docs.pactflow.io/docs/workshops/bi-directional

mbailey
2021-12-15 17:53
He suggested sending an email to to request a video about it

mbailey
2021-12-15 17:55
https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-1/ about schema-based testing - it sounds like there are advantages and disadvantages, but I don?t know yet what they?re developing to make this work.

mbailey
2021-12-15 17:55
Finally all my reading is useful to someone!

elliot.weiser
2021-12-15 19:06
has joined #general

tjones
2021-12-15 22:35
> So far that I have read, in my understanding bi-directional contracts trumps other approaches, No, I don't think so. The bi-directional contract approach that Pactflow has is best if it is not possible to do full contract testing (with Pact at both sides)

tjones
2021-12-15 22:36
In the bidirectional approach, you've got a pact mock being validated against a schema, but because of the way the schema works it's very easy to get false confidence

tjones
2021-12-15 22:36
I would view a pass in bi-directional contracts as a "maybe"

tjones
2021-12-15 22:38
I don't think there's a difference between the bi-directional contracts feature from pactflow and the schema-based approach outlined in those posts

matt.fellows
2021-12-15 22:58
what Tim said

matt.fellows
2021-12-15 23:00
bi-directional contracts is a Pactflow feature and can be though of as contract testing using schema comparison (most schema testing doesn?t incorporate the evolution/versioning component that the broker adds). We think it is a much easier workflow to use, at the cost of reduction in guarantees. See also the https://docs.pactflow.io/docs/workshops/bi-directional#trade-offs

mbailey
2021-12-16 00:02
Interesting that you put SCC in the ?*Consumer Driven Contract Testing?* column on that table. I just did a prototype of SCC, and despite it?s home page, it does *not* provide consumer-driven out of the box.

mbailey
2021-12-16 00:03
What is the development timeframe for a workable bi-directional approach?

matt.fellows
2021-12-16 00:10
SCC can be consumer driven, just not by default. Marcin hangs around these traps too, might be able to shed light on it

matt.fellows
2021-12-16 00:11
> What is the development timeframe for a workable bi-directional approach? (edited) the functionality is stable, there is just currently no UI. We are working on that as we speak (literally). It?s likely we?ll have some UI support this side of xmas, and then continuing to roll out UI and expansions on the approach in Q1/Q2 next year

matt.fellows
2021-12-16 00:11
you can see our roadmap here: https://github.com/pactflow/roadmap

sunit
2021-12-16 07:27
has joined #general

diva.pant1
2021-12-16 15:40
How is Pact different fro VCR testing? https://docs.pact.io/faq/convinceme/ I read about it and the difference I found is Pact is consumer-driven approach and VCR is provider-driven approach. But in any case my question is, say in VCR whenever we change something on the provider side, there are many redundant records being created, but in Pact as well with every new version of the product there are many new pacts are being created. How is one beneficial over other?

felipe.simoes
2021-12-16 18:42
has joined #general

ameadewi
2021-12-16 18:48
has joined #general

yousafn
2021-12-16 20:13
I find tools that record/replay interactions give you all the information up front and you have to pare it down to what consumers care about to understand which consumers you will break by changing the providers api. Starting with a minimal example request/response data from your client to test your particular scenario will probably lead to more readable client tests, and I often find tests to be my best living documentation of a system. Looking at VCR docs, quickly you need a real provider first to record the responses? If so do clients have to wait for the provider to exist?

yousafn
2021-12-16 20:15
Also loving your questions whilst you are getting to grasps with CDC, pact and the other tools in the arena! The questions, information and responses are really useful in challenging my own thinking :)


matt.fellows
2021-12-16 20:27
One thing about most of these record and replay tools is that they do just that. They lack assertions, or flexibility in checking the response

matt.fellows
2021-12-16 20:28
With Pact, providers verify the contracts in a unit test setting and have better control over responses for their use cases

matt.fellows
2021-12-16 20:29
With VCR these checks (checking if the provider is compatible,) usually run externally to the provider service by the consumer team

matt.fellows
2021-12-16 20:29
This can make them very brittle

matt.fellows
2021-12-16 20:30
VCR is probably better suited to 3rd party APIs you don't control and can't ask them to run your test suite

mbailey
2021-12-16 21:30
Nice! Thank you

yousafn
2021-12-16 22:02
If I wasn?t on my phone at the time I?d have linked to that page. :+1::skin-tone-4: maybe one for a slack custom response - pact vs x Agreed on being better suited for 3rd party api?s or api discovery. We?ve used goreplay which is similar for a 3rd party ( our main backend provider ) who we?re old skool and didn?t want to subscribe to our cdc mantra for the front end facing micro service suites. But it always meant we were reactive, not proactive.

abubics
2021-12-17 00:50
In a way it's conceptually similar to these desires (from Kent Beck's lovely https://medium.com/@kentbeck_7670/test-desiderata-94150638a4b3): > Behavioral ? tests should be sensitive to changes in the behavior of the code under test. If the behavior changes, the test result should change. > > Structure-insensitive ? tests should not change their result if the structure of the code changes. When you have recorded requests/responses, they don't know which bits are important, which bits should be flexible. So the tests are sensitive to all changes, not just the relevant ones.

matt.fellows
2021-12-17 03:27
The OAS _is_ the contract in schema based testing

matt.fellows
2021-12-17 03:27
you can generate it by hand or auto generate from code (e.g. annotations or bindings). The latter is preferred in some ways, because it means your OAS is unlikely to drift from your code (implementation)

matt.fellows
2021-12-17 03:27
the challenge then becomes not breaking consumers, which is where schema-based contract testing comes in

diva.pant1
2021-12-17 04:16
Thanks!

diva.pant1
2021-12-17 04:16
Thanks!

michael.scheepers
2021-12-17 08:11
has joined #general

yanis.benekaa
2021-12-17 16:05
has joined #general

kamoljan
2021-12-18 01:49
Is anyone using Android (Kotlin) and iOS(Swift) for consumer driven contract testing? If yes can you share any best practices?

matt.fellows
2021-12-18 11:01
might also be interested in joining #pact-swift

matt.fellows
2021-12-18 11:01
I think with mobile, the main thing to remember is that multiple production versions can co-exist, so you want to make sure your provider verifies _all_ versions of a mobile client


matt.fellows
2021-12-18 11:03
Otherwise, the usual principles for consumer tests apply

kamoljan
2021-12-18 11:18
Thank you @matt.fellows!:pray:

akhandalmani.malik
2021-12-19 06:19
Hi Team, I am trying to validate the below contract json with actual provider. But actually *ACTION* array key value pair list data is not in the same *order* from the actual response. Some times "empId": "EMP744" will be at index 1 and "empId": "EMP755", at index 0. I mean *acton* order key value can be change. Any Idea how to ignore list order comparision with respect to order. { "provider":{"name":"my_provider"}, "consumer":{"name":"my_consumer"}, "interactions":[ { "description": "GET REQUEST", "request": {"method": "GET", "path":"path" },"response":{ "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "id": "E200", "name": "xzk", "address": "Asia", *"action":* [ { "empId": "EMP744", "name": "Application Name", "address": "mexico", "desc": "emp744 details", "pin": "453" }, { "empId": "EMP755", "name": "Consolidation Code", "address": "california", "desc": "EMP755 details", "pin": "763" }, { "empId": "EMP766", "name": "Data Source Code", "address": "atlanta", "desc": "emp766 details", "pin": "342" } ] }, "providerStates":[ { "name": "test GET" } ]} }], "metadata":{ "pact-specification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.10" } } }


matt.fellows
2021-12-20 01:24
It?s quite old, but I?m sure the principles are still the same

matt.fellows
2021-12-20 02:43
Take a look at the matching rules. You?re currently trying to do an ?exact match? so if the response is different it will fail.


mike.geeves064
2021-12-20 12:03
Eugh. Not Pact specific I think, but is anyone else having GitHub build issues? I'm having weirdness when it's trying to spin up the Pact Broker docker-compose :disappointed: I wondered if there could be anything with it pointing to latest tags when it wasn't working last night but can't see anything changing and have the typical "works fine locally". The same code retrying builds had a: fail: https://github.com/mikegeeves/pact-python/actions/runs/1599957456/attempts/1 [11 hours ago] fail: https://github.com/mikegeeves/pact-python/actions/runs/1599957456/attempts/2 [30 mins ago] pass: https://github.com/mikegeeves/pact-python/actions/runs/1599957456/attempts/3 [20 mins ago] wtffff. This one weirdly worked for 3 of the python versions but not the 4th: https://github.com/mikegeeves/pact-python/actions/runs/1600297265/attempts/1 [9 hours ago], same 1 hour ago then worked about 30 mins ago: https://github.com/mikegeeves/pact-python/actions/runs/1600297265/attempts/3 :sob:

mike.geeves064
2021-12-20 12:04
There is no /tableflip here, I need one :smile:

dilek
2021-12-20 12:42
has joined #general

diva.pant1
2021-12-20 17:04
Is there a real trade-off between using Pact and OAS. Just OAS is faster, and Pact is reliable?? Contract based testing can be expensive, when we run the tests, just because it gives us confidence is it really a better choice against OAS based contract testing? Can you please point any strong argument against OAS based contract testing

matt.fellows
2021-12-20 20:46
The case against it is laid out here: https://pactflow.io/blog/schemas-are-not-contracts/ (which I think you?ve read)


matt.fellows
2021-12-20 20:47
Pact has stronger guarantees at the usual cost of more tests/complexity

matt.fellows
2021-12-20 20:48
Only you can weigh up the other costs (maintenance, speed of running etc.) based on your own environment.

matt.fellows
2021-12-20 20:49
We (Pactflow) think the bi-directional flow is going to be very useful for a lot of customers in certain situations, especially retrofitting onto existing systems and where there is resistance in using another tool (like Pact).

diva.pant1
2021-12-20 21:12
Okay so we have an existing system, so bi-directional flow is the way to go? And if we decide to go ahead with bi-directional the cost will be comparatively less for bi-directional flows?

tjones
2021-12-20 22:37
No. As I explained last time, using Pact is the approach that gives you the most confidence. However, if you are unable to use pact on the provider side (for example, a provider team who are not interested in using pact), then you can achieve better-than-nothing confidence with the bi-directional flow that Matt describes in his blog posts.

bethskurrie
2021-12-20 22:49
> so you can say --to-environment test-a --to-environment test > for example? No

bethskurrie
2021-12-20 22:51
> but regardless after reviewing I think it is the correct move to have the environments matching. Yes

bethskurrie
2021-12-20 22:55
@kyle.craviotto I think the approach of recording a deployment for each of the conceptual consumer environments could work. You'd need to run can-i-deploy once for each consumer environment though, and then you'd have to work out what to do if one of those failed.

bethskurrie
2021-12-20 22:57
The other approach you could use is using the "application instance" feature of record-deployment for the consumers. With this, you would consider the "Test" environment to be just ONE environment, and you'd give each consumer a different application instance identifier (TestA, TestB). can-i-deploy would just work then, for everyone, just using --to-environment Test.


bethskurrie
2021-12-20 22:57
^^ docs here.

matt.fellows
2021-12-20 23:06
ah, that makes sense

bethskurrie
2021-12-20 23:06
Yes, Beth did think of this :wink:

matt.fellows
2021-12-20 23:11
I?ve been thinking for a while now that our docs almost need a ?use case? type section to help with scanning documentation and mapping use cases to how to do things

bethskurrie
2021-12-20 23:12
Yes, that would be great.

matt.fellows
2021-12-21 00:55
> Okay so we have an existing system, so bi-directional flow is the way to go? And if we decide to go ahead with bi-directional the cost will be comparatively less for bi-directional flows? I?d suggest doing a PoC with both approaches, and then working with the team to assess which approach works best for your situation. In some cases, you may wish to use bi-directional, in other cases Pact and in some cases you may wish to use both approaches. That is to say, it?s not a binary choice


matt.fellows
2021-12-21 06:28
It?s hard to asses the cost from this vantage point without a lot more detail, but assuming you already have sufficient coverage of your consumer and provider, almost certainly the cost of doing bi-directional will be lower than that of Pact. This only takes into account the ?effort? cost of the contract testing bits itself, and not the overall maintenance etc.

sadhana.0203
2021-12-21 07:55
has joined #general

adrian.ernst.lgln
2021-12-21 08:36
has joined #general

dalton.pinto
2021-12-21 09:53
has joined #general

roman.rutkowski.87
2021-12-21 15:42
has joined #general

maxwell.xandeco
2021-12-22 21:43
has joined #general

lixiaoyan68
2021-12-23 06:50
has joined #general

sashaavramchik
2021-12-23 09:07
has joined #general

jamie.manson
2021-12-23 10:51
has joined #general

colin.ansah
2021-12-23 13:21
has joined #general

bruno855
2021-12-23 17:47
has joined #general

appgify
2021-12-23 20:41
has joined #general

jason329
2021-12-23 22:12
has joined #general

shaheen.d2
2021-12-24 07:55
has joined #general

shaheen.d2
2021-12-24 07:57
Hello everyone, As a research analysis I'm looking for open source projects available on github that use Pact or any other type of CDC can anyone give me a hint on where I can find such list?

matt.fellows
2021-12-24 08:01
Welcome! What's the purpose of the research? For use in a commercial setting or something else?

matt.fellows
2021-12-24 08:02
The main OSS project I know of using it is owncloud

matt.fellows
2021-12-24 08:02
I also know IBM have it in their microservice template

shaheen.d2
2021-12-24 08:14
I want to gather lot of contracts and evaluate them in terms of performance, coverage etc.

shaheen.d2
2021-12-24 08:14
Thanks for the answer, can you provide some links please?



laura.koekenberg
2021-12-24 10:32
has joined #general

varnit.garg2424
2021-12-24 12:58
Hello, if I try to verify my pact test against the dummy consumer version(basically the one that doesn't exist), it doesn't fail the pact test even if the contract doesn't match with any of the pact hosted on the broker..Is there any known issue related to that?

varnit.garg2424
2021-12-24 13:03
Build logs shows test is passed which is wierd, if consumer tag is not available then it should fallback to the latest available tag/version and verify the contract... In this case, I don't even see provider version being published to the broker...its just passing the test silently

mike.geeves064
2021-12-24 13:04
Do you mean the Provider Pact tests aren't failing? Do you have successful previous tests against that Consumer? (not the version specifically, some other version for that same Consumer)

varnit.garg2424
2021-12-24 13:06
yes, provider pact tests are not failing if I pass any consumer tag which doesn't exist and expect tests to fail. Since contract uploaded by consumer version doesn't match with what provider is generating. Yes, there are successful previous tests (passed and failed as per the expectations) against that consumer

mike.geeves064
2021-12-24 13:09
Oh Scala, I was going to say maybe try and get the debug logs from the Provider :thinking_face:

varnit.garg2424
2021-12-24 13:29
All the logs are getting uploaded to one server which I can't access at the moment. In general, none of the contracts published on broker expects the messages generated by provider since I tweaked the provider side implementation a bit to ensure that contract should fail.. If I don't pass any tag under consumerSelector or if I pass any valid consumer tag then my provider test is getting failed successfully due to expected issue that provider misses one field that consumer expects in the contract.. It looks like to be an edge case with pact which is not being handled properly. Also to note that I'm using pact4s. Let me try passing fallback tag as well to see if it works then..

craiganthonyrichards
2021-12-25 05:01
has joined #general


tjones
2021-12-28 07:46
Different clients have different behaviours if there are no pacts found. Which pact framework are you using?

mch
2021-12-28 12:54
has joined #general

mch
2021-12-28 13:01
Hi, I'd like to ask what is the consensus regarding whether to keep pact files in git. I looked into examples in pactflow docs and it differs from project to project, e.g. in https://github.com/pactflow/example-consumer its not checked (and in .gitignore) but in https://github.com/pactflow/example-consumer-dotnet it's checked in.

florian.becker_pact-s
2021-12-28 14:49
has joined #general

mike.geeves064
2021-12-28 15:28
I don't think you really want to keep them in git ongoing for normal usage. They will be stored in the broker you use so you don't need to. It's helpful to have them in the examples for people to be able to see how they look, and I've found out helpful when experimenting and making changes to try something, to be able to see what <diff>erence it made

oblique
2021-12-28 18:45
has joined #general

oblique
2021-12-28 18:49
Hello everyone. I?m brand new to Pact, I ran some tutorials I found with google and then the 2 lessons from http://pact.io that were hosted on katacoda. So I?ve got a basic handle on how it works. But I?d love some guidance, just some links, on how to use it in a more real world example. For example, my provider hits a mongodb instance for data, not the hard coded data shown in all the tutorials. How do I get a pact for that?

smalladi
2021-12-28 19:22
has joined #general

jordan.nazemi
2021-12-28 19:24
has joined #general

gbhusari
2021-12-28 21:22
has joined #general

pghosh
2021-12-28 21:23
has joined #general

tjones
2021-12-29 04:08
Think of the pact files as build artefacts - in most cases, you don't want to check them in to source control.

mch
2021-12-29 06:32
ok, thanks for response

carlos.agullo
2021-12-29 08:46
has joined #general

matt.fellows
2021-12-29 11:18
"getting a pact" happens when you write a consumer test, which is independent of the provider implementation. Verifying a provider requires you have the ability to mock your DB or seed it with the data needed for each provider state

matt.fellows
2021-12-29 11:19
The examples often use an in memory db that conform to an interface. Is there a particular problem you're facing?

oblique
2021-12-29 13:48
Thanks for getting back to me. Mocking the DB is the answer I?m looking for, so obvious, I?m not sure why I didn?t see that. The problem we?re facing is a large code base that needs more than unit testing. :- )

cyrus.devnomad
2021-12-29 14:15
has joined #general

dimundo
2021-12-29 17:20
Hi! any option to make this not error ? ```Could not create tag. Version a6c35e1a of zzzz does not exist.``` reasosning - in CI at some stage pacts are tagged, one of theme werent yet created, still tag creatin for this - was :smile: sad story - all rest pact tagging after is skipped :disappointed:

tjones
2021-12-30 06:55
I don't know the answer to your question, but to me this sounds like a build process issue that you would want to fix unrelated to pact - it shouldn't be possible to be trying to tag a non existent version, and also ideally builds are repeatable so once the version was published you could just rerun the build

dimundo
2021-12-30 07:42
there is a build stage for tagging pacts after deploy ```tag-pact-uat1: image: pactfoundation/pact-cli:latest stage : tag-pacts needs: - deploy-uat1 when: on_success script: - "pact-broker create-version-tag --pacticipant aaa --version $CI_COMMIT_SHORT_SHA --broker-base-url $PACT_BROKER_BASE_URL_AIR --broker-username $PACT_BROKER_BASIC_AUTH_USERNAME --broker-password $PACT_BROKER_BASIC_AUTH_PASSWORD --tag uat1" - "pact-broker create-version-tag --pacticipant bbb --version $CI_COMMIT_SHORT_SHA --broker-base-url $PACT_BROKER_BASE_URL_AIR --broker-username $PACT_BROKER_BASIC_AUTH_USERNAME --broker-password $PACT_BROKER_BASIC_AUTH_PASSWORD --tag uat1" - "pact-broker create-version-tag --pacticipant ccc --version $CI_COMMIT_SHORT_SHA --broker-base-url $PACT_BROKER_BASE_URL_AIR --broker-username $PACT_BROKER_BASIC_AUTH_USERNAME --broker-password $PACT_BROKER_BASIC_AUTH_PASSWORD --tag uat1" - "pact-broker create-version-tag --pacticipant ddd --version $CI_COMMIT_SHORT_SHA --broker-base-url $PACT_BROKER_BASE_URL_AIR --broker-username $PACT_BROKER_BASIC_AUTH_USERNAME --broker-password $PACT_BROKER_BASIC_AUTH_PASSWORD --tag uat1"``` new functionality were added and there was idea to add 2 pacts `bbb` and `ccc` their tagging were added, but in same MR only `bbb` pact were created so after merge script fails on `ccc` tag and old `ddd` pact was never tagged after

dimundo
2021-12-30 07:43
yes, its a bad thing - adding something in advance, but this kicked from unforeseen side :)

dimundo
2021-12-30 07:45
i could add `|| exit 0` at every line, but this will look even more scary

tjones
2021-12-30 08:25
> but in same MR only bbb pact were created This feels like a mistake to me. If the pipeline might not generate all the pacts, I don't think it should try to tag them

dimundo
2021-12-30 08:26
this pipeline will generate all but one wasnt developed :D

dimundo
2021-12-30 08:33
still for me this could be a warn, not error

muirandy
2021-12-30 17:57
has joined #general

tjones
2021-12-31 02:38
Hmm. The general philosophy is that we warn for things that might be an error, and error for things that are definitely an error - in this case, trying to tag a version that doesn't exist is definitely a mistake

tjones
2021-12-31 02:39
You can see the guidelines for framework log levels here: https://github.com/pact-foundation/pact-specification#logging-in-a-pact-library

mch
2021-12-31 08:59
Hi, I have a question regarding mainBranch selector for verification. In https://docs.pact.io/blog/2021/10/08/why-we-are-getting-rid-of-tags/#support-for-sensible-defaults-and-simplification-of-pact-selection-when-verifying it's written that one should use "the recommended selectors of `{ mainBranch: true }` and `{ deployedOrReleased: true }"` . I get the part regarding `deployedOrReleased` - I want the provider to be compatible with each deployed version of consumer. However, I'm not 100% sure about `mainBranch` - it looks like it's for cases where the pact has been published but the consumer deployment not yet recorded. Could you please let me know if I'm understanding this correctly? Also, I not sure to what value should I set the `mainBranch`. I have 2 branches: `deploy` == staging env and `master` == prod env. Could you please advise?

mch
2021-12-31 09:44
Also is there any difference between `[{ mainBranch: true }, { deployedOrReleased: true }"]` and `[{ mainBranch: true, deployedOrReleased: true }]` or are they equivalent?

tom450
2021-12-31 14:08
apologies for reviving this thread, was wondering if you have any examples of consumer message pact tests in java or kotlin please ?

matt.fellows
2021-12-31 22:40
Howtoexamples


tomknee1
2022-01-01 00:21
many thanks, happy new year

lewis.prescott079
2022-01-02 07:58
Anyone interested in learning more about Pact, join my workshop https://www.ministryoftesting.com/events/introduction-to-contract-testing-with-pact-v2

mch
2022-01-03 13:52
After some digging I found out that mainBranch should be set to `develop` (https://github.com/pact-foundation/pact_broker/discussions/400#discussioncomment-1007183) which makes sense. Now the only thing that I'd like to know is the purpose of using both `mainBranch` and `deployedOrReleased` selector. Could anyone assist with that?

matt.fellows
2022-01-04 02:10
Because you usually don't want to break what's currently in production `deployedOrReleased` or what's about to go to production `mainBranch`

matt.fellows
2022-01-04 02:11
You don't have to have that configuration, but it's a good starting point

kyle.craviotto
2022-01-04 15:40
thanks, I'll dig into this today. First day back and all from vacation

oblique
2022-01-04 18:52
The answer is in step 7 of https://github.com/pact-foundation/pact-workshop-js/ - pay careful attention to how the state handlers are used in the provider tests.

hocautomation
2022-01-05 09:54
has joined #general

deepakdaga2007
2022-01-05 17:49
has joined #general

tomknee1
2022-01-05 21:19
Hi there, does anyone have any example repositories they can share for setting up open source pact broker with Postgres in a k8s cluster? I'd quite like to compare against what I've come up with, apologies that this is more k8s related than pact itself but just curious to see and compare some yaml files if at all possible please, thanks

tomas.hornak
2022-01-05 23:49
has joined #general

juan.cruz
2022-01-06 02:44
has joined #general

marconota.mac
2022-01-06 10:30
has joined #general

marta.rey-benito
2022-01-06 15:56
has joined #general

fr4ngus
2022-01-06 16:20
has joined #general

huhuang
2022-01-08 05:28
has joined #general

frankfullstack
2022-01-09 20:33
has joined #general

gkrawczyszyn
2022-01-10 06:51
has joined #general

tom.kelly
2022-01-10 15:05
has joined #general

dave.sorenson
2022-01-10 15:51
has joined #general


gianni.araco
2022-01-11 16:13
has joined #general

anu.johar
2022-01-11 20:25
has joined #general

yann.danot
2022-01-12 10:15
has joined #general

adamdullenty
2022-01-12 11:26
Hey guys, a quick question. Does anyone know of a way to generate any kind of API documentation based on a system's Pact contracts?

matt.fellows
2022-01-12 11:52
The CLI tools can produce a type of documentation: https://docs.pact.io/implementation_guides/cli/#pact-cli

matt.fellows
2022-01-12 11:53
the `pact docs` command can do that: ```Commands: pact docs # Generate Pact documentation in markdown pact help [COMMAND] # Describe available commands or one specific command pact verify -h, --pact-helper=PACT_HELPER # Verify a pact```

matt.fellows
2022-01-12 11:54
Also, the Pact broker automatically does that too

matt.fellows
2022-01-12 11:55
example pactflow UI, but the open source broker also has a similar, rudimentary UI

david.vancouvering
2022-01-12 22:37
I can't find the documentation for pact docs - does it exist?

yousafn
2022-01-12 23:04
Hey buddy, Here is an older repo from GitHub with some examples and a few stars https://github.com/javajon/pact-with-kubernetes A quick google found me some helm charts for the oss pact broker. My current client is k8s, we?ve still to setup pact there. It?s been on our radar for a while, so happy to get something in place and compare. Feel free to drop me a private message or continue in the thread!

david.vancouvering
2022-01-12 23:58
Hey, another question. I get why you tag the consumer with its branch when you publish the pact. This allows the provider to pick up the right pact when it's verifying, rather than just using `latest` But I also see recommendations to tag the provider with the branch when it publishes its verification result. Why is that? I don't see any workflow where the provider's branch tag is used. Again, I am aware of the new "deployments" and "branches" concepts, but we can't use them yet because we're using the JVM and Maven integrations, which don't yet support these new concepts. Thanks!


matt.fellows
2022-01-13 00:16
but the docs show above is from running the command `pact help`

hsanghavi
2022-01-13 00:57
has joined #general

tjones
2022-01-13 01:52
I think it's for if you're using a feature-branch based workflow

tjones
2022-01-13 01:53
The reason you'd want the verifications tagged is for when you're asking `can-i-deploy` whether it's safe to deploy

tjones
2022-01-13 01:54
you want to be able to select the thing you're asking about deploying

tjones
2022-01-13 01:54
say you have master deployed to prod, and you want to know if you can deploy the consumer against it, then you need to be able to select the master branch, without any other branches.

david.vancouvering
2022-01-13 01:57
I suppose if you use the branch name for `can-i-deploy` rather than the environment, it makes sense, thanks

david.vancouvering
2022-01-13 01:58
Thanks. Looks like pact docs only works with a pact file rather than a pact in the broker?

matt.fellows
2022-01-13 02:03
ah yes, that?s correct

matt.fellows
2022-01-13 02:03
wouldn?t be hard to automatically fetch them of course and feed into that command

matt.fellows
2022-01-13 02:03
But could probably be added to the `pact` command

david.vancouvering
2022-01-13 02:05
Looks like a really interesting tool, when time allows I'll definitely check it out

tjones
2022-01-13 02:39
I think (although I don't know because I don't do branches this way) the idea is that with branch tags, you can use can-i-deploy to check whether it's safe to merge a branch.

tjones
2022-01-13 02:39
The idea being that (in this style) branches that are named the same are supposed to be pact-compatible

david.vancouvering
2022-01-13 02:40
Yes, makes sense. I'd rather not do things that way but it can be a step towards "Pact Nirvana"

vejeta
2022-01-13 03:19
has joined #general

tjones
2022-01-13 09:05
(I don't do it that way)

chvram
2022-01-13 11:04
hi Un ordered array in JSON not working when are trying to check with /compare with Actual Provider Web service Response, Version Pact we are using is 4.1.2.5. any clue on this?

matt.fellows
2022-01-13 11:19
You might be best asking in the language specific channel - e.g. #pact-jvm Also, consider adding some more detail into your question - at the moment, all we know is that you?re having a problem with unordered arrays.

matt.fellows
2022-01-13 11:19
see howtorepro :point_down: for advice on asking a question that is likely to get a good answer


sweeneyrichard2
2022-01-13 15:43
has joined #general

sweeneyrichard2
2022-01-13 15:48
Has anyone had success with using Pact for Microsoft Dynamics? Or is that not an appropriate use case? We have microservices that interact with Dynamics which would be Pact appropriate, I was just wondering if Pact could / should be used with Dynamics itself.

tomknee1
2022-01-13 20:27
thanks, i have it all working now but no one on the team im currently assigned to knows anything about k8s so its been hard for me to get a review of what im doing, so good to be able to at least compare against something

diva.pant1
2022-01-13 21:47
Hi our company currently uses vcr testing, and we would like to move to pact testing. I am still new to this and trying to understand how to go about it. The general docs doesn't help me at this point. So we have these spec files with vcr tests, since I do not have to start from scratch, so to implement pact testing we to just make changes in the rspecs right?

diva.pant1
2022-01-13 21:49
What all files do I have to make change in? We use circle ci, ruby

tjones
2022-01-14 01:58
This would be best asked in #pact-ruby

tjones
2022-01-14 02:00
The answer to this depends on whether you are able to run provider verification against Dynamics. If I recall correctly, Dynamics has an HTTP API, so there's no reason you couldn't write pact tests for it

tjones
2022-01-14 02:02
personally, I write pact tests even if I'm not planning to run verification. If you just write consumer tests, then you're essentially using Pact as a mock (which has all the disadvantages, like you're marking your own exam and you don't know if the mock matches the real behaviour). However, the advantage of doing it that way is that you can easily upgrade to a full contract test if you ever do get to the situation where you can run the verification.

tjones
2022-01-14 02:03
Oh, sorry - I see you already did. Hopefully someone there can answer

thuvu.se
2022-01-14 05:51
has joined #general

rahul.meher
2022-01-14 09:02
has joined #general

gavin.campbell
2022-01-14 17:31
has joined #general

davideliu
2022-01-14 17:52
has joined #general

matt.fellows
2022-01-15 02:54
the other advantage is you get some extra visibility into what your system is doing

matt.fellows
2022-01-15 02:55
We actually covered this in our first ever AMA (?Can I test 3rd party APIs??): https://docs.pact.io/help/amas/#apac-1

matt.fellows
2022-01-15 02:57
You don?t have to align branches, but it?s relatively common in organisations to have naming conventions for their main branch (e.g. `main` or `master` or `develop` ). You could align feature branch names, but that?s messy. The idea is usually on the provider side, to automatically verify pacts from all consumers? main branches automatically.

matt.fellows
2022-01-15 02:58
I?d say a fairly common starting point would be for providers is to ensure they verify all of their consumers currently deployed to production (e.g. `environment: "prod"` and all of the main branches of their consumers (e.g. `branch: "main"`). This covers breaking prod, and breaking what is about to go to prod

pavlo.sprogis
2022-01-16 17:15
has joined #general

jbrady
2022-01-16 21:54
has joined #general

johnathan
2022-01-17 04:42
has joined #general

dimakos.neoklis
2022-01-17 15:04
has joined #general

gueorgui
2022-01-17 16:43
has joined #general

marcbetts
2022-01-17 22:35
has joined #general

lambat.ishanya
2022-01-18 05:10
has joined #general

sprathi
2022-01-18 13:40
has joined #general

emanuela.ceuta
2022-01-18 16:25
has joined #general

chaugule.sandeep
2022-01-19 05:00
has joined #general

chaugule.sandeep
2022-01-19 05:02
Hello, I have onboarded pactman recently but seems like pact-python is the way to go in future https://docs.pact.io/implementation_guides/python. And In pact-python, I see ruby apps are pre-downloaded with pact-python and since ruby is not supported within our firm. I am not sure whether I can switch to pact-python. Any reason why pactman is in maintenance mode.

tjones
2022-01-19 05:59
I think pactman is not part of the pact-foundation

tjones
2022-01-19 06:31
> I see ruby apps are pre-downloaded with pact-python and since ruby is not supported within our firm. What do you mean by this? You don't need Ruby available in order to run the binaries

matt.fellows
2022-01-19 07:17
The author of pactman also believes having two implementations of the same thing doesn?t make sense, and also doesn?t have the time to maintain it (yet another reason for not having 2 of them)

matt.fellows
2022-01-19 07:17
`pact-python` is the one you should use, probably

chaugule.sandeep
2022-01-19 09:00
Sorry If I wasn't clear. Some of the apps like mock service use Ruby. Since downloading packages is pretty much customized in our firm, I am not sure if they will allow me to pip install pact-python. But I get a direction now that pact-python is the future. Thank you for your quick response

lakitna
2022-01-19 10:38
We're getting 500 responses when uploading OpenAPI Schemas to `{pactflow}/contracts/provider/{pacticipant}/version/{uniqueVersion}`. Did anything change recently, or is this simply an issue on Pactflows end?

matt.fellows
2022-01-19 10:40
No, not that I'm aware. Can you please drop a line to please Sander? We'll look ASAP

lakitna
2022-01-19 10:40
Will do, thanks!

lakitna
2022-01-19 12:10
Just a headsup for those running into the same issue: They have a lead and will follow up on this tomorrow

ajay.kawde
2022-01-19 13:34
has joined #general

chaugule.sandeep
2022-01-19 14:40
Guess I spoked too early, I was able to get the pact-python installed(getting some approvals in place). However I had a query, For provider tests I was loading the interactions using something like def get_interactions(pact_json): pacts = BrokerPact.load_file(pact_json, PyTestResult) return [interaction for interaction in pacts.interactions] Is there an alternative in pact-python for this

liam.chen
2022-01-19 21:19
has joined #general

taylor.phillips01
2022-01-19 21:45
has joined #general

sreid
2022-01-19 23:22
Hello, general question, is Pact able to be used on the new MacBook Pro with ARM64? Asking for a friend :slightly_smiling_face:

marko.justinek
2022-01-19 23:24
Depends which language implementation and version.

uglyog
2022-01-19 23:25
Hey Shaun! It does work. For some of the components we build arm binaries. For others, you need to use the emulation to run it.

sreid
2022-01-19 23:25
We are running using the NPM packages for JS/TS ```"@pact-foundation/pact": "9.16.0", "jest-pact": "^0.9.0",```

uglyog
2022-01-19 23:26
As long as node works, it should be good.

uglyog
2022-01-19 23:32
> for the @greet_bot/pact package the terminal needs to be run in rosetta mode so that the x86_64 version can be installed, as it seems like there isn't an ARM64 version

cgoodison
2022-01-19 23:34
here's a guide on using rosetta mode with node that should help: https://www.jurnalanas.com/node-js-mac-m1/

sreid
2022-01-19 23:36
Thanks @uglyog @cgoodison

cgoodison
2022-01-19 23:37
once rosetta mode is installed and node version for x64 is installed, installing npm packages in that terminal will get you the x64 packages for everything

sreid
2022-01-19 23:37
more details from my friend here ```? yarn yarn install v1.22.17 [1/4] ? Resolving packages... [2/4] ? Fetching packages... error @pact-foundation/pact-node@10.12.2: The CPU architecture "arm64" is incompatible with this module. error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.```

cgoodison
2022-01-19 23:37
yeah, the above will definitely get around that problem

sreid
2022-01-19 23:37
Thanks!

tjones
2022-01-20 00:13
Hello! That shouldn't happen with the latest version

tjones
2022-01-20 00:15
Key points: ? You will need to have rosetta installed ? You *don't* need to run the terminal through rosetta or run the x86 version of node ? The binary is run though rosetta by macos automatically ? We have enabled the install of pact-node on arm64, assuming that rosetta is available (this means it can incorrectly be installed on linux using arm64, but will not work there)

matt.fellows
2022-01-20 00:18
Ah, nice Tim. should we add this to the readme?

tjones
2022-01-20 00:19
pact-node@10.13.0 and above is able to be installed. The first version of `@pact-foundation/pact` to have this is 9.16.1 - but really just upgrade to the latest version (9.17.2)

tjones
2022-01-20 00:19
> Ah, nice Tim. should we add this to the readme? Yes, I think that's a good idea

tjones
2022-01-20 00:20
For mac users, just use the latest version and you won't notice. For users of the same architecture but not on a mac, we definitely need a note in the readme

tjones
2022-01-20 00:20
(because it will install and fail)

sreid
2022-01-20 00:20
thanks!

tjones
2022-01-20 00:22
Questions about Pactflow should go to #pactflow, this channel is for pact.

tjones
2022-01-20 00:24
I'm not sure what you're asking, sorry. If you are asking if you can load pacts from a broker, then yes you can.

sreid
2022-01-20 01:08
Thanks team, PR merged with version update, all good.

chaugule.sandeep
2022-01-20 02:55
Sure. I'll provide some background. I have written my consumer tests and the pact that gets generated is stored locally on say /var/tmp/. Now to run provider tests, I generate a list of interactions as shown as above and run using pytest.param ```def get_interactions(pact_json): pacts = BrokerPact.load_file(pact_json, PyTestResult) return [interaction for interaction in pacts.interactions] pact_interaction = get_interactions(pact_json) @pytest.mark.parameterize('interaction', pact_interaction) def provider_tests(interaction): logic for assertion```

chaugule.sandeep
2022-01-20 02:57
So I am looking for alternative in pact-python as how to get the list of interactions Note: the storing of pacts locally is a temporary solution for now

sandeepa.kv
2022-01-20 06:46
has joined #general

matt.fellows
2022-01-20 07:48
why are you doing it this way and not just using the standard verification interface?


matt.fellows
2022-01-20 07:48
(that fetches from a broker, but the `Verifier` constructor takes arguments to read a pact file directly

matt.fellows
2022-01-20 07:49
I think you?re doing it at too low a level

chaugule.sandeep
2022-01-20 08:08
Thanks Matt. The reason I was doing it like that was because each interaction would act as a test case and it would be easy to capture the # of test cases executed and also for each test case I was able to inject headers. Is there a way I could do this with Verifier class 1. Extract each interaction result 2. How to pass header for request(interaction), because we need Spnego Kerb for auth

chaugule.sandeep
2022-01-20 08:09
Not sure does extract_params allow me to inject headers?

diva.pant1
2022-01-20 13:21
Hi, so while using pact we create two pact_helper.rb files right, one in service_consumers and other in service_providers, right? https://docs.pact.io/implementation_guides/ruby/README And does the directory structure should remain same or can we store these files elsewhere?

shane.dombowsky
2022-01-20 14:08
has joined #general

jlbrown
2022-01-20 15:29
has joined #general

chaugule.sandeep
2022-01-20 17:44
Okay, So i am setting the header in **kwargs to something like headers={"Authorization: Negotiate <token>"} but the moment I set this get 401 response. Any suggestions please?

gabriel.fatori
2022-01-20 18:36
has joined #general

petersonbtah
2022-01-20 20:16
has joined #general

llast
2022-01-20 21:44
has joined #general

chaugule.sandeep
2022-01-21 03:27
Also the console I see its says adding header with but when I take a look at pact.log. I don't see the customer headers i provided ```Sending POST request to path: "/countries" with headers: {"X_PACT_PROVIDER_STATES"=>[{"name"=>"Order ID 123 exists"}]}, see debug logs for body``` I am not sure what is missing here. I am referring to this link https://docs.pact.io/faq/#how-do-i-test-oauth-or-other-security-headers

chaugule.sandeep
2022-01-21 03:43
Okay an update, 401 error is gone now but getting 500 server error with `body : {"message": "an error has occurred"`

matt.fellows
2022-01-21 04:20
It looks you?re setting the provider state URL to your actual service (or something like that). Can you please share your setutp?

matt.fellows
2022-01-21 04:21
the provider state URL is designed to take a provider state setup request, and give your application the opportunity to get into that state. Subsequent requests would go to your actual application

devesh.mishra
2022-01-21 04:26
has joined #general

chaugule.sandeep
2022-01-21 04:40
Yes I am pointing to my actual service. Can't I just ignore the provide state. Unfortunately I cannot share my set-up due to security concerns

devesh.mishra
2022-01-21 04:47
hey everyone, i have created a test case on the consumer side in *Bazel* project i have added the dependencies needed for test case but on running the test no pact file is generated, i think we have to add the corresponding plugin in the *Bazel* project in order to create the pact file after test run, is there any way we can add this plugin in Bazel project? ```<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <pact.rootDir>target/mypacts</pact.rootDir> </systemPropertyVariables> </configuration> ... </plugin>```

tjones
2022-01-21 05:03
> Can't I just ignore the provide state.

tjones
2022-01-21 05:03
No, probably not

tjones
2022-01-21 05:04
The provider state is for allowing you to set up preconditions (such as "user with ID=2 exists")

matt.fellows
2022-01-21 05:04
Might be best asked in #pact-jvm

chaugule.sandeep
2022-01-21 05:04
Not sure if this help but in pactman i was setting provider_state=None and it worked

matt.fellows
2022-01-21 05:06
Maybe try simplifying your setup that doesn't use your private code so you can share with us until it works

matt.fellows
2022-01-21 05:07
Once you get the basics then add back in your code.

devesh.mishra
2022-01-21 05:07
ok

chaugule.sandeep
2022-01-21 05:12
Let me get back with basic set-up on this

matt.fellows
2022-01-21 05:14
FYI It's not just about ignoring provider states (which you probably don't), I think your setup is wrong. If you can just compare your verifier config that would probably be a good start

chaugule.sandeep
2022-01-21 06:06
I am not sure what do you mean by Verifier config `ver = Verifier('DummyService', provider_base_url='http://some-service/qa/dummyservice')` `suc, _ = ver.verify_pacts('pact.json', headers=get_headers())`

chaugule.sandeep
2022-01-21 06:07
This is how I am running, I am not changing anything in Verifier. Note the same thing when i send a Get request it works fine but only for post it end up throwing a 500

tjones
2022-01-21 06:15
`/dummyservice'` <-- you should be verifying against your real service, not a dummy service

tjones
2022-01-21 06:15
> it end up throwing a 500 If the code under test is throwing a 500 during the test ,it is probably failing the test. This might be because pre-conditions have not been met

chaugule.sandeep
2022-01-21 06:18
@tjones: That was just an example of how my verifier class looks like. Yes i am verifying against a real service. And as i mentioned the same set of test cases work fine when i use Pactman

tjones
2022-01-21 06:19
Ok. In order to help more, we probably need to see your test setup

chaugule.sandeep
2022-01-21 06:20
Okay I am working on it. I'll write some basic code for Consumer and provider tests

chaugule.sandeep
2022-01-21 07:36
Here is the sample code i have built https://github.com/sanmechie/pact-pythonissue

chaugule.sandeep
2022-01-21 07:37
Now for demonstration, I have used FastAPI as rest service. When I send the post request it ends up throwing 422 error. Looks like the payload being sent is buggy and when I run the same thing against a dotnet service throws 500

chaugule.sandeep
2022-01-21 07:37
hope this helps

chaugule.sandeep
2022-01-21 07:38
in actual the host is rhel 7

viveksingh.kiit
2022-01-21 09:29
has joined #general

james.demaine
2022-01-21 10:02
has joined #general

chaugule.sandeep
2022-01-21 17:33
So here is the update got it finally working. I had to add in consumer request header= {'Content-type:'application/json'}

chaugule.sandeep
2022-01-21 17:35
The issue was the request wasn't json and hence the it was throwing 500 in case of dotnet service and 422 in case of fastapi service. After adding header in consumer request. it worked Thanks for your support Timothy and Matt

theferryatbuckland
2022-01-21 20:24
has joined #general

theferryatbuckland
2022-01-21 20:29
Hello, I'm new to using Pact and am going through the video tutorial, and from there I'm using the sample Consumer/Provider examples. Running the Consumer api in a Windows 10 environment with VS Code. When running "npm t", the Pact test (create the consumer contract, etc.) is failing with this error FAIL src/api.pact.spec.js ? Test suite failed to run ```**Cannot find module '@pact-foundation/pact/dsl/matchers' from 'api.pact.spec.js'** 1 | import { Pact } from '@pact-foundation/pact'; 2 | import { API } from './api'; > 3 | import { eachLike, like, regex } from '@pact-foundation/pact/dsl/matchers'; | ^ 4 | import { Product } from './product'; 5 | 6 | const mockProvider = new Pact({ at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17) at Object.<anonymous> (src/api.pact.spec.js:3:1)```

theferryatbuckland
2022-01-21 20:30
Is the "matchers" module a separate module I need to add? This is not expecting a running broker server at this point, is it?

matt.fellows
2022-01-21 21:22
Hi, this is probably best asked in #pact-js going forward. But we can carry on here. Which tutorial are you referring to?



theferryatbuckland
2022-01-21 21:44
I cloned the two repos listed under the "Code from Demo" section: https://github.com/pactflow/example-consumer & https://github.com/pactflow/example-provider

theferryatbuckland
2022-01-21 21:45
I had to update (locally, of course) the default url for the consumer's reference to the provider in order for the consumer to work, but the two sample APIs interact just fine.

theferryatbuckland
2022-01-21 21:47
Then I followed the steps for testing in video 3 (https://www.youtube.com/watch?v=6Qd-kq1AzZI&list=PLwy9Bnco-IpfZ72VQ7hce8GicVZs7nm0i&index=3), and when running "npm t" on the Consumer API, that's where it throws the error about missing the "matchers" module.

david.kormushoff
2022-01-22 00:54
has joined #general

tjones
2022-01-22 04:40
That import statement is not correct. It should be ```import { Matchers } from '@pact-foundation/pact';``` Then later if you don't want to use the `Matchers` prefix, you can do: ```const { eachLike, like, regex } = Matchers;```

tjones
2022-01-22 04:43
Importing deeply from a module like that means that you're relying on the internal structure of the module, it's better to import from the public interface.

matt.fellows
2022-01-23 02:31
strange, the versions should be pinned correctly, but perhaps they aren?t

matt.fellows
2022-01-23 02:31
Tim?s right though, i?ll fix the examples

matt.fellows
2022-01-23 02:33
> I had to update (locally, of course) the default url for the consumer?s reference to the provider in order for the consumer to work, but the two sample APIs interact just fine. (edited) hmm sholudn?t have to do that. `npm start` in each repo should ?just work?

matt.fellows
2022-01-23 02:34
(I just updated it)

diva.pant1
2022-01-24 11:13
While creating and verifying pacts do we need two separate pact_helper.rb files to make changes in the file or just one,?

diva.pant1
2022-01-24 12:47
So here are two separate files for service_providers and service_consumers @bethskurrie So I have these files stores as spec/...(in pic 3)

theferryatbuckland
2022-01-24 13:25
@tjones thanks for the guidance, I made that change on my local project and it passed the test. Thanks!

chaugule.sandeep
2022-01-24 13:56
#pact-python: Hi I am facing peculiar issue, after running my consumer tests, says it generates 4 interactions. Now I cannot feed this pact file [having 4 interactions] directly to Verifier class as I need to generate headers with new token for every request made to Provider(Actual service). But the problem as soon as the 1st provider tests get completed successfully, 2nd test onwards, I Am getting 401 error

chaugule.sandeep
2022-01-24 13:56
Any suggestion on this?

jr.jenks
2022-01-24 14:01
What's the appropriate channel to ask questions about our pipeline logic? We're using .NET, JS and Swift but our pipeline questions apply to all.

tjones
2022-01-24 17:01
This channel, ask away

matt.fellows
2022-01-25 00:11
There are some suggestions here you might find helpful: https://docs.pact.io/provider/handling_auth/

matt.fellows
2022-01-25 00:11
(I would usually go with [2])

tom.tantisalidchai
2022-01-25 05:43
has joined #general

theferryatbuckland
2022-01-25 13:45
@matt.fellows, Also, to follow up with your comment about "npm start" should just work. Yes, I think it should, but the Consumer app (again, not the ones located in the various Workshops repos, but the stand alone) was not initialized with the correct URL of the Provider api. Basically, as far as I can tell, on the "api.js" file, the initializing constructor for the API class gets passed a null value for the "url", so I just updated my instance to manually set "http://localhost:8080" when that value is null. So, for instance, without hardcoding the Provider URL, and with the Provider URL running, I can do a GET with the Provider: http://localhost:8080/product/09. However, in the consumer, from the Console I get the error "Cannot read properties of undefined (reading 'endsWith')". Debugging shows me it is because the "url" passed into the API constructor is null. So I just hard coded the || statement to set that url value.

cedric.spengler
2022-01-25 15:08
has joined #general

austin.reifsteck
2022-01-25 15:20
has joined #general

hsd999
2022-01-25 19:06
has joined #general

jr.jenks
2022-01-25 19:06
Question about circular contracts. Say, Service A consumes Service B but Service B consumes Service A. Is it possible to create pipeline logic that allows for that?

hsd999
2022-01-25 19:15
I would like to get your opinion about contract testing. Here is a case: ? Angular client and java back-end micro-services ? API first approach with OpenAPI specs ? Generate API client for Angular and API client for Java for integration units tests - both client will be generated during compilation to run unit tests ? For Angular use json server for test propose with test data So some kind of contract testing we will make in unit testing for Angular and Java and even more we can validate this additionally in CI pipeline. *Question is if we can get additional benefit to go with Pact tool and pure contract testing approach?*

david.vancouvering
2022-01-25 19:26
Hey, have a thought/question. Let's say you are a provider with 5 consumers. 3 consumers use `main` as their trunk branch, and two use `master`. If you run your provider verification with just the tag `master`, you won't verify against the 3 consumers tagged with `main`. Similar problem if you run verification with the tag `main` It seems you need to know the trunk branch names for all your consumers, and you need to verify against _all_ those tags. Am I missing something?

parasonbe
2022-01-25 20:31
has joined #general

parasonbe
2022-01-25 20:33
this might do the trick?

matt.fellows
2022-01-25 22:42
Yes, that?s correct - if using _tags_. When migrating to the _branches and environments_ approach, there is a selector called `mainBranch`. This can be configured individually by each application (`main`, `master` , `develop` or whatever makes sense for them). The provider can then find all pacts for the main branch of consumers without knowing what the name of the main branch is!


matt.fellows
2022-01-25 22:45
There are more things to consider, for one, you won?t know the actual usage of your consumers (because the API clients are generated, you must assume they consume the full interface). This means you can never change a field/endpoint in a backwards incompatible way, even if it?s not being used. Also, you need to ensure that the schema on the provider side is compatible with the client library generated for the consumers (i.e. you need to know a compatability matrix). There are some further points that talk about the differences here: https://pactflow.io/blog/schemas-are-not-contracts/ We also have a feature that works with schemas in pactflow called bi-directional contracts, that solves some additional challenges (including the ones described above). See https://docs.pactflow.io/docs/workshops/bi-directional/

david.vancouvering
2022-01-25 22:48
Nice. Can't wait until Maven/JVM has support for branches and environments. Definitely a great improvement

david.vancouvering
2022-01-25 22:48
Thanks!

matt.fellows
2022-01-25 22:51
I?m just checking now

matt.fellows
2022-01-25 22:51
I seemed to recall Ron picking some of it up recently


matt.fellows
2022-01-25 22:56
I can see some mentions of `mainBranch` in groovy tests, so perhaps some groundwork has been laid down to support it?

david.vancouvering
2022-01-25 22:57
OK. Our breaths are bated

jr.jenks
2022-01-26 00:16
Got a question about event-driven microservices and Pact. A and B are microservices. Suppose A sends a request to B and B sends a response. That means that A will be writing the contract for both the request and response, right? And that logic doesn't change, whether we're talking about synchronous communication (Pact 2.0) or async (Pact 3.0), right? Whether the pattern is HTTP or request/response (or command/response, or query/response, or whatever/response), A will be writing the contract? I ask this because somehow my team has got it into their heads that, in the above scenario, A would write the contract for the request and B would write the contract for the response.

matt.fellows
2022-01-26 00:59
Is it a req/response style async interaction or a fire and forget?

matt.fellows
2022-01-26 00:59
I think the answer is the same regardless (the consumer always defines what it needs)

matt.fellows
2022-01-26 00:59
in the case of async, the consumer is the thing reading from the queue/intermediary (e.g. from kafka). The provider is what publishes to it

matt.fellows
2022-01-26 01:00
req/res style async is only available in v4.0 of the specification

jr.jenks
2022-01-26 02:09
Thanks. We're using PactNet so we're not able to go to Pact v4.0 yet. (Right?)

jr.jenks
2022-01-26 02:11
We will be doing both request/response and fire-and-forget. For fire-and-forget, I assume that the firer is the publisher and the listener is the consumer.

matt.fellows
2022-01-26 02:50
I don?t think Pact Net supports req/res style messages yet, but fire and forget it will

matt.fellows
2022-01-26 02:50
you can test out the new branch, it?s currently being worked on

matt.fellows
2022-01-26 02:50
and yes, the model you have above is correct

alex.diaz
2022-01-26 09:05
has joined #general

alex.diaz
2022-01-26 09:49
Hi, first of all, thank you for all your work on this, it is great! We are starting to implement contract testing in our company and we have some questions: The first question is about how we should update the tests in case the Provider changes. In our case, the Provider is an API with a ML model that returns predictions based on a JSON input. We know that Pact is designed for testing the contract used for communication, and not for testing particular behaviours. Therefore, we have implemented the tests to test the integration between the Consumer and the Provider and we ignore everything related to the model. However, there are some cases where the behaviour of the model affects the API output: ? If the JSON body of the request to the Provider is missing a field called `A` the model will fail to generate the prediction and the API will return `Exception happened in API function: Missing field 'A'`. However, this happens only in a model trained with `dataset 1`, but if we deploy a new version of the service with a model trained with `dataset 2` that does not require the field A, the API will work fine. How should we update the tests when we deploy a new version of the API with a new ML model? Because we would get an error in the verification of the contract already existing in the broker, right? Should we update first the Consumer to publish a new contract before pushing the new version of the Provider? The second question is regarding how you suggest we should keep track of the different contract versions. We have `prod` and `dev` environments but the Provider can be updated in 2 different ways: ? We update the ML model with a different model of a more recent trained model (same case as above). Therefore, if the new model does not require a field anymore the tests need to be updated. ? We update the logic of the API. Therefore the Provider would need to publish a new contract every time the ML model is updated or every time the logic of the API is updated, right? And this also should be done per environment (`prod` or `dev`), right? Is anyone using contract testing for APIs with ML models? If yes can you share any best practices, please? Thank you!

cyrus.devnomad
2022-01-26 10:46
Hi I have a question about managing changes to contracts. In the following workshop, it is explained how the case of adding a new parameter to an API should be managed between consumer and provider: https://docs.pactflow.io/docs/workshops/ci-cd/ However, this case is rather obvious, because the consumer in master is not affected by a new parameter and does not care about it. So, this case is handled as follows: 1.      We create a new feature branch for consumer. 2.      We add a new parameter for the consumer. 3.      We commit our change. 4.      The consumer pipeline fails at can-i-deploy, because it is no longer compatible to provider API. 5.      The webhook is triggered and runs the pact changed verification pipeline and marks the new contract as failed for the new consumer and current provider. 6.      The provider pipeline is not affected by this and can continue to deploy the provider. 7.      We update the provider to include the new parameter added by the consumer in the feature branch. 8.      The provider pipeline can still continue to run successfully because the consumer in master does not care about the new parameter. 9.      We re-run the pipeline for the consumer in feature branch or merge it to master and re-run the pipeline for the consumer in master and end up with new consumer being deployed to production. So far so good. But how the whole process would look like if the consumer in feature branch had changed the name or type of an existing parameter rather than adding a new one. How would the provider had to be updated at step 7 above? Would it have to be updated in a way that it would continue to be compatible to both versions of the consumer (the one in master and the one in feature branch)? I mean providing two parameters one with the name/type of the old consumer and one with the name/type of the new consumer? At least until the consumer version of the feature branch would have been merged to master and then deployed to production or deployed directly to production from the feature-branch?

kskowron
2022-01-26 11:30
has joined #general

jr.jenks
2022-01-26 13:00
When using pending Pacts and the consumer updates a Pact on branch */example-changes*, what cleanup need to be performed if the consumer team decides to delete the branch and no longer wants the changes (before the provider has verified)?

hsd999
2022-01-26 13:42
Thank you for your answer. Right now I understood the differences.

spencerm
2022-01-26 14:33
has joined #general

cristiano.cunha
2022-01-26 14:55
has joined #general

matt.fellows
2022-01-26 20:50
you?re welcome!

abubics
2022-01-26 23:32
Yes, you shouldn't have looping problems. Even if one triggers the other for verification, the loop stops there (they don't cause automatic changes in each other).

nish063
2022-01-27 02:42
has joined #general

ingcmurcia
2022-01-27 04:41
has joined #general

weijian.duan
2022-01-27 08:58
has joined #general

abraham.gonzalez93
2022-01-27 10:39
has joined #general

tjones
2022-01-27 12:26
To your first question, it sounds like provider states are the solution. Have a look here: https://docs.pact.io/getting_started/provider_states/ Basically you would say: ? When the provider has been configured with Model 1 ? This request ? Generates this response -- ? When the provider has been configured with Model 2 ? This request ? Generates this other response

tjones
2022-01-27 12:27
To your second question, generally you want your version to uniquely identify your deployable. If the model can be considered "data", then it's part of the state of the provider, and not part of the deployable unit

tjones
2022-01-27 12:28
If your consumers will break if Model 1 is not present, then maybe it's not "data" and is instead part of the deployable.


tjones
2022-01-27 12:30
> Therefore, if the new model does not require a field anymore the tests need to be updated. For me, I would make this a part of the contract if the client would send the wrong request when the provider's model changes.

tjones
2022-01-27 12:32
Do you use `mocha` for tests in javascript, but want the convenience of `jest-pact`'s `pactWith()` function that does all the pact set up and teardown for you? Now you can! https://www.npmjs.com/package/mocha-pact The API is identical to `jest-pact`, except it's compatible with Mocha instead

tjones
2022-01-27 13:43
GitHub packages is failing sometimes, which is causing intermittent failures for downloads of the pact standalone. This affects pact-js, and any other pact framework that downloads the binaries. Here's the github status page: https://www.githubstatus.com/incidents/29xnrws671f0

akke.luukkonen
2022-01-27 14:31
Kind of related protip for those using Azure DevOps as their pipeline provider. In the November https://docs.microsoft.com/en-us/azure/devops/release-notes/2021/pipelines/sprint-195-update#automatic-retries-for-a-task a `retryCountOnTaskFailure` option was added. It might prevent some intermittent connection failures from failing the whole pipeline. Azure DevOps agents in general don't seem to have the most reliable connections, even to the package feeds hosted in AzDo itself. Or at least we've occasionally seen these types of failures during `yarn install`: ```error An unexpected error occurred: "https://pkgs.dev.azure.com/<organization>/_packaging/<organization>Libraries/npm/registry/ini/-/ini-1.3.8.tgz: Request failed \"503 Service Unavailable\"".```

patrice.krakow
2022-01-27 14:37
Hello World!

patrice.krakow
2022-01-27 14:44
[Newbie question] Following the animations starting at https://pactflow.io/how-pact-works/#slide-1 is it correct to say that the _consumer_ MUST use, within its contract, data that will be later understood by the _Provider_? In other words, for this consumer Pact contract testing to work, you MUST *first* "synchronize" the test data between the _Consumers_ and the _Producer_. If yes, how do you do that? If not, what did I miss?

tjones
2022-01-27 14:47
You don't have to synchronise the data exactly. You can use provider states to tie them together:


tjones
2022-01-27 14:48
You can/should also use matching to mean that you're validating the shape of the data, rather than the exact data:


tjones
2022-01-27 14:49
:taco: for @akke.luukkonen, this is a great tip!

demna
2022-01-27 15:29
has joined #general

mircea.ungureanu
2022-01-27 15:48
has joined #general

cyrus.devnomad
2022-01-27 16:24
Ok, I think I've found the answer to my question. There was a similar question before, which can be found here: https://pact-foundation.slack.com/archives/C9VPNUJR2/p1613577427179400

cyrus.devnomad
2022-01-27 16:38
And again another discussion about the same problem here: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1614005618012700

nikhilwa84
2022-01-27 17:43
has joined #general

bogdanm.rusu
2022-01-27 18:04
has joined #general

matt.fellows
2022-01-27 22:21
I?d look to try out some of the workshops (see howtolearn)

2022-01-27 22:21
Here are a number of useful hands-on labs that teach all of the key concepts https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-01-27 22:21
The workshops go through these core concepts in a guided way

cventcport
2022-01-27 22:29
has joined #general

alex.diaz
2022-01-28 08:50
Thank you so much!

mayuri.khemani
2022-01-28 09:43
has joined #general

patrice.krakow
2022-01-28 10:02
Thanks! I will have a look at those :+1:

sujith.nair2
2022-01-28 12:33
has joined #general

rob
2022-01-28 16:36
has joined #general

joshua.badger
2022-01-28 21:47
Hey, I?m the original poster of the question that Mike is asking about. Reading through the thread has been enlightening, though I wonder if I add a few more specifics into the question if that will change anything you?ve said. We have a number of preexisting systems in different business units that utilize different databases. They come from multiple acquisitions, so there was never a chance to just build them together in the first place. We need them to play nicely together now while we build out unified systems for real. Rather than directly interface with tons of databases, we simply expose endpoints (REST, GraphQL, etc) to allow access to relevant information. I have two systems, A and B, that need information about a given order. That order may be in Business Unit D, E, or F. Rather than recreate the logic in both A and B to gather the information from the correct source, we have implemented Hub C. Hub C takes a given identifier, performs some logic and references its own database, decides which Business Unit to call out to for information (using differently structured calls for each; some are GraphQL, some are REST), and makes the call, performs some transformations on the data to standardize the format it will return, and then returns it. In some cases (but not all!), it will make multiple calls to one C and another call to D, and all in fulfillment of a single request from A or B. A or B then act on the data returned by C, which may or may not behave differently given which BU that information came from. So B is not purely a passthrough. It also needs some refactoring to make some of those Business Logic layers more mockable. (It?s an older system we?re retrofitting with Pact, but we don?t have the resources to refactor everything into a more easily testable system). You suggested that the solution we came up with closely mirrors an integration test in one of your graphics, and you suggested mocking the API layer on the Hub. I guess my concern is that we ARE trying to mirror an integration test, so that we hit all of our test cases we?ve defined, without needing to deploy all the systems (the entire draw of Pact). Coupling the tests guarantees that when Service A has a condition ?Given Order 123 for product XYZ exists?, it sends a request with Order 123's UUID to Hub C and get information back. The test scenario knows Order 123 comes from Service D, but Service A doesn?t know that until it gets its response back from C. With all the above said, we are trying to find a way to codify all the different ways B calls out to fulfill orders to all its consumers so we don?t miss any. That was the other part of the question: how do we make sure we?ve covered what we think we?ve covered? If we couple the tests in this way, we should guarantee that a given version of all services will behave together nicely. Setting up some provider state and mocking the call to the downstream doesn?t guarantee that mocked call represents reality unless that mock is also utilized in a Consumer test. So, all that said: how do I reframe my thinking to the model Pact would suggest I use while not losing out on that coupling?

radovan
2022-01-29 00:20
has joined #general

abubics
2022-01-29 02:48
Without rereading the few threads, I think a few base approaches still apply: ? If you have a proxy, you probably don't need to treat it as a participant. ? If you have something that does more than just proxy (e.g. domain logic, transformation, etc), you probably should treat it as a participant. ? From Pact's perspective, a contract test is only the interaction between 2 participants, no extra behaviour. I would only test combinations A-C, B-C, C-D, C-E, and C-F with Pact. The logic that decides what C wants to talk to is more the domain of unit and functional tests. I would also stub the data to fulfil those tests before the branching point, to increase specificity (so you know which bit is broken when a test fails), but that's a separate philosophical discussion :)

abubics
2022-01-29 02:52
It also sounds like y'all are trying out contact testing in the midst of a large-scale refactor, which seems like it can only make life harder while forming your mental models. Depending on how long that transition is expected to take, I might consider other testing approaches, rather than churning a lot on unfamiliar testing styles :pray: either way, good luck!

tjones
2022-01-29 15:53
> Setting up some provider state and mocking the call to the downstream doesn?t guarantee that mocked call represents reality unless that mock is also utilized in a Consumer test. If you mean using the mock as the expected behaviour when testing the real behaviour of the consumer test, then yes - otherwise, you shouldn't be using a mock at all in a consumer test. In general, yes, mocks run the risk of not testing what your code is actually doing. If you're mocking at any point, you also need a contract test that confirms that the mock behaves the same as the real code. This problem exists any times mocks are used, not just with pact Personally, I try to only mock at the boundaries of the service - which means the mocks always become fixtures to check the expected behaviour during the pact test for that boundary. If you use this style, then it is easy to reason about coverage - you would check to make sure that each mock state has a corresponding contract test to make sure the real boundary code does the same thing. My view is that an integration test would also achieve all of the advantages of a mock that is contracted against, but with many more disadvantages (brittle tests, hard to reason about coverage, expensive run times, complex set up scripts, need to schedule testing, etc). If you disagree with this claim, then there's nothing wrong with doing integration testing. (although you may have a bad time, long term)

matt.fellows
2022-01-29 22:42
This response is poetry

mike.geeves064
2022-01-30 17:32
I think the example looked at was largely doing as Tim described (phew), but still needs the refactor so it's mocking around the whole thing rather than the http request itself. Would be good to then get input following on from there to extend to cover message as that's definitely going to have valid A>B>C flows so it would be nice to improve those examples especially. Only a small amount of time needed to change my bit just not got there

jr.jenks
2022-01-31 13:33
What's the best naming convention for Pending Pact branches, for teams that are doing continuous, straight-from-main-to-production deployment with lots of tiny code changes deployed frequently? For example, here are some options for the same Pact change: /feature/user-name-now-required-for-each-blog-entry /feature/20220131-require-user-name /feature/story-12345/pact-changes /feature/story-12345/20220131-pact-changes I'm assuming: 1. The name needs to make sense to both the consumer and provider teams. 2. I want to include the date (or something) because the same description "require-user-name" might occur in the future and I don't want the labels to get confused. 3. I don't want to include something like the user-story-id because that has no meaning between teams. (Or do I, since it has meaning to the consumer team?) Thoughts?

dennis.woditsch
2022-01-31 13:39
Hey, if been integrating pact in my company since a few weeks. But I have stumbled a cross an issue I haven't found an answer (yet). We successfully publish contracts for each branch using the `http://au.com.dius.pact.provider` maven plugin. Using following configuration ```<configuration> <pactBrokerUrl>${pact.broker.url}</pactBrokerUrl> <pactBrokerToken>${pact.broker.token}</pactBrokerToken> <projectVersion>${project.version}-${git.commit.id.abbrev}</projectVersion> <branchName>${git.branch}</branchName> </configuration>``` This works just fine. But if we re-run our build for any reason again. We run into issues of ```Failed - Request to path 'https://xx.pactflow.io/contracts/publish' failed with response 409 [2022-01-31T09:40:52.425Z] {"notices":[{"type":"error","text":"Cannot change the content of the pact for xxx-service version 0.1.1-SNAPSHOT-da8c216 and provider xxx-provider-service, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number``` What is the suggest way to handle this cases where we re-run builds and the same pact would be published?

mongeyc
2022-01-31 14:03
has joined #general

matt.fellows
2022-01-31 20:52
It seems like the contents of the pact itself is changing between builds, which is causing that message. I believe if you use certain matchers without providing an example this can happen, as Pact JVM will generate examples for you dynamically. You could try reviewing those and ensuring you provide examples for them Also, try a few runs locally to see what is changing. The warning is still valid I might be wrong of course

mike.bernard
2022-01-31 21:14
has joined #general

matt.fellows
2022-01-31 23:10
if you need it to be unique now and the future, then having (3) as part of the name would tick that box

matt.fellows
2022-01-31 23:11
I hadn?t thought too much about the names of the branches being important for the provider, but I tend to use semantic commits and branch names, which aids in readability

matt.fellows
2022-01-31 23:11
do they need to be traceable by the provider?

tjoy
2022-02-01 02:06
has joined #general

max.tilford
2022-02-01 03:17
has joined #general

dennis.woditsch
2022-02-01 07:52
Thanks for the quick response. That might be a good hin to dig deeper into the matchers. I actually wanted to take a easy way first and create non-breaking pacts with hardcoded matchers like that ```@Pact(consumer = "consumer-service") public MessagePact validTitleUpdatedEvent(MessagePactBuilder builder) { return builder .expectsToReceive("valid conference created event") .withContent(LambdaDsl.newJsonBody(lambdaDslJsonBody -> { lambdaDslJsonBody.stringValue("eventName", "ConferenceCreated"); lambdaDslJsonBody.object("payload", lambdaDslObject -> { lambdaDslObject.uuid("conferenceId", UUID.fromString("7205a64a-e495-453a-aff7-a7bc38914fbc")); }); }).build()) .expectsToReceive("valid conference title updated event") .withContent(LambdaDsl.newJsonBody(lambdaDslJsonBody -> { lambdaDslJsonBody.stringValue("eventName", "TitleUpdated"); lambdaDslJsonBody.object("payload", lambdaDslObject -> { lambdaDslObject.uuid("conferenceId", UUID.fromString("7205a64a-e495-453a-aff7-a7bc38914fbc")); lambdaDslObject.stringValue("title", "anyTitle"); lambdaDslObject.numberType("sequenceNumber"); }); }).build()) .toPact(); }``` I have to create some kind of state first as every event needs a `conference created` event. I use this "state-block" on every of my event contract tests

matt.fellows
2022-02-01 08:13
I don?t know the JVM DSL all that well, but i suspect `lambdaDslObject.numberType("sequenceNumber");` is going to generate a random number each time, and therefore a hash of the pact file will be different each time

dennis.woditsch
2022-02-01 08:15
I will check that. Thank you very much

matt.fellows
2022-02-01 08:16
you?re welcome

toanshukumar
2022-02-01 14:15
has joined #general

diva.pant1
2022-02-01 14:34
Hi @matt.fellows could you do Introduction to Pact using Ruby, sometime https://www.youtube.com/watch?v=tTpkLwYOTZo&list=PLwy9Bnco-IpcdSXA4OutjG_lDCCHOXxYL

juanquis419
2022-02-01 15:01
has joined #general

diva.pant1
2022-02-01 19:38
Can the consumer service and the provider service be in the same directory (not repo but directory)?

matt.murray
2022-02-01 19:40
has joined #general

jr.jenks
2022-02-01 19:51
I have no requirement that the branch names be unique now and in the future, but I was wondering if the logic of pending pacts requires that. Let me try asking a similar question. Forget about my requirements and think only about the logic of pending Pacts. Would it be okay to name a pending Pact branch, today, with the name... February branch name: /feature/user-name-now-required ...and then (assuming that the provider verified that pending pact, my consumer merged, the branches were deleted and everyone was happy) to use the same name again 6 months from now? August branch name: /feature/user-name-now-required Will the tagging and stuff get confused in 6 months because I reused the branch name? Or will the fact that they are Pacts with a different hashes be enough to distinguish between February and August?

mike.bernard
2022-02-01 20:57
@matt.fellows @tjones I came across this thread looking for some help. I'm trying to set up a provider test against an AWS API Gateway. The error I'm getting is 415 (Unsupported Media Type) but that may be somewhat of a red herring. Is there a way to pass authentication credentials in the options passed to the Verifier constructor? The APIs in all of our environments require creds and I'm currently not telling the provider how to authenticate. Of course I'd expect a 403 but figured I'd start here. Thanks in advance!

mike.bernard
2022-02-01 21:46
I just came across https://github.com/pact-foundation/pact-js/blob/master/examples/e2e/test/provider.spec.js#L31 which seems like the way to go for auth. I probably shouldn't jump the gun on the 415 error though. Have y'all seen this before? ```Pact::ProviderVerifier::SetUpProviderStateError: Error setting up provider state 'matrix download url' for consumer 'TestApp' at http://localhost:58137/_pactSetup. response status=415 response body= <html lang="en"> <head> <meta charset="utf-8"> <title>Error</title> </head> <body> <pre>UnsupportedMediaTypeError: unsupported charset &quot;UTF-8&quot;<br> &nbsp; &nbsp;at /Users/mikebernard/projects/aws-policy-management/node_modules/body-parser/lib/read.js:83:18<br> &nbsp; &nbsp;at invokeCallback (/Users/mikebernard/projects/aws-policy-management/node_modules/raw-body/index.js:224:16)<br> &nbsp; &nbsp;at processTicksAndRejections (internal/process/task_queues.js:77:11)</pre> </body> </html>```

mike.bernard
2022-02-01 22:04
Running in debug mode ```DEBUG: Setting up provider state 'all is good' for consumer 'TestApp' using provider state set up URL http://localhost:58216/_pactSetup I, [2022-02-01T17:01:00.772962 #63645] INFO -- request: POST http://localhost:58216/_pactSetup D, [2022-02-01T17:01:00.772989 #63645] DEBUG -- request: User-Agent: "Faraday v0.17.4" Content-Type: "application/json" I, [2022-02-01T17:01:00.776446 #63645] INFO -- response: Status 415```

matt.fellows
2022-02-02 00:12
I don?t plan on doing one any time soon. The point of these is not an exhaustive ?how to? in a language, but an overview of the core concepts.

matt.fellows
2022-02-02 00:12
I think the next one would be a ?message pact? demo

matt.fellows
2022-02-02 00:12
However you want to store your code is irrelevant as far as the testing of it goes

matt.fellows
2022-02-02 00:12
Pact makes no assumptions about where the code is stored

matt.fellows
2022-02-02 00:13
> Or will the fact that they are Pacts with a different hashes be enough to distinguish between February and August? bingo!

matt.fellows
2022-02-02 00:13
The broker will uniquely version the underlying contract separate to any tags/consumer versions

matt.fellows
2022-02-02 00:14
this is how if you have a tag `master` and a tag `some-new-feature` , if the underlying contract is the same, you can verify using one of the tags, but all contracts with different tags/consumer versions, but the same hash, will automatically be marked as valid for that provider version.

matt.fellows
2022-02-02 00:15
or more often, if V2 of a consumer doesn?t change the contract and V1 of the consumer is compatible with a given provider, V2 will also be and you don?t need to wait for a verification

matt.fellows
2022-02-02 00:19
hmm, I think that is a red herring. Can you please put it into `trace` level and share those logs?

matt.fellows
2022-02-02 00:19
We run a local proxy during provider verification (which is an express app), and that seems to be responding with the `415`

matt.fellows
2022-02-02 00:23
OK so quick googling, it seems this is likely to happen when the encodings library is not properly loaded into the module runtime. It _may_ be something going on in your Jest setup (see https://stackoverflow.com/a/49211552 and the related/linked issues) It may be that the `iconv` library (or related library) is corrupt/broken (see https://github.com/expressjs/body-parser/issues/52) If you haven?t already, try removing the node_modules and re-installing (I suspect you have though)

frederic.gendebien
2022-02-02 08:54
has joined #general

dougie.robertson
2022-02-02 11:15
has joined #general

mike.bernard
2022-02-02 13:28
Sounds good. I'll dig in this morning and provide more updates. Thanks for the direction!

juan.avendano
2022-02-02 13:36
has joined #general

ananda-kumar.irudhaya
2022-02-02 14:13
@matt.fellows do you have examples for event driven architecture (kafka)?

mike.bernard
2022-02-02 21:15
@matt.fellows thanks so much for the help! I made a ton of progress today and got it working end to end. The issue from above was resolved when I added in the library the first stackoverflow post suggested but then after more digging, I set the Content-Type to application/json when signing the requests using aws4 and that resolved it, allowing me to remove the workaround code.

matt.fellows
2022-02-02 21:16
yes, see :point_down: (howtolearn)

2022-02-02 21:16
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-02-02 21:16
No videos at the moment though

matt.fellows
2022-02-02 21:17
ah, interesting - thanks for letting us know!

matt.fellows
2022-02-02 21:18
I recently point this page up to start capturing common use cases: https://docs.pact.io/recipes/apigateway. If you had any tips examples to share, we?d love a PR to document the learnings

mike.bernard
2022-02-02 21:19
I have another question related to signing the requests. This may not be the best place to ask so if there's a better spot, i'll move. Anyways, I am using the `requestFilter` and `stateHandlers` for each of the APIs i'm testing. The last API call I added is a POST that contains a body. When signing a request that contains a body, you have to include the body because it becomes part of the signature. I have it working by copying in the request body from the consumer app but that seems to circumvent the idea of replaying the requests from the pacts. Is there any way to intercept the body of the request in the request filter so I can add it to the signature?

mike.bernard
2022-02-02 21:19
Perfect! I'll see where I can add some docs and make a PR. Thanks!

matt.fellows
2022-02-02 21:21
I think you?re saying that the request filters don?t currently have access to the body? I think they do, but you can?t modify the body atm as far as I know

mike.bernard
2022-02-02 21:22
I shouldn't have to modify it, but merely grab it so I can add it to the signature. This is what I'm getting when I log out the body in the request filter ```body: {"consumer":"TestApp","state":"create matrix","states":["create matrix"],"params":{}}```

mike.bernard
2022-02-02 21:22
It doesn't have the payload the consumer is sending in.

mike.bernard
2022-02-02 21:23
but it _is_ using the payload when making the request because when I sign the request with that same body, it works. If they were different, the request would fail.

mike.bernard
2022-02-02 21:24
I'm currently doing it statically and rather than making the provider code know about the consumer payloads, I want to retrieve it off the request. Let me know if i'm not making much sense.

matt.fellows
2022-02-02 21:24
hmmm interesting

matt.fellows
2022-02-02 21:24
I think, from memory, the body is actually a stream or a buffer.

matt.fellows
2022-02-02 21:25
I know the current implementation doesn?t let you modify it, because of some detail in the proxy library we use

mike.bernard
2022-02-02 21:26
do you know where I can look to inspect what is on that request object that gets passed in to request filter?

mike.bernard
2022-02-02 21:28
ahh it's an express thing. :thumbsup:

matt.fellows
2022-02-02 21:28
Oh, that?s strange. I thought our request filter didn?t fire for state changes

matt.fellows
2022-02-02 21:29
basically, each test has 2 http interactions - one to setup a pact state change (payload above), the second is the actual test

matt.fellows
2022-02-02 21:29
so the above _is_ the body, just of a request you?re not interested in

mike.bernard
2022-02-02 21:29
got it

matt.fellows
2022-02-02 21:30
looking at the code, the request filter will fire for all requests. This is not what I?d expect as a user, but I might have had good reasons to do it at the time

matt.fellows
2022-02-02 21:30
and yes, the request filter should take a standard express middleware

mike.bernard
2022-02-02 21:31
thankfully the request filter does fire for each state. I was worried about that but she works!! It's necessary because if you have let's say 2 different apis, a GET and a POST, the request to sign needs to contain different info. So we're able to swap out that info within each state handler. :raised_hands:

mike.bernard
2022-02-02 21:32
I took the idea from the `${token}` example in the e2e tests.

mike.bernard
2022-02-02 21:32
anyways, Ill keep digging to try and get at that initial request body to see if I can dynamically pull it to sign the request. I appreciate the help and I'll add some docs with errors and resolutions soon!

matt.fellows
2022-02-02 21:33
Cool, yes, that makes sense

mike.bernard
2022-02-02 22:06
No luck. For some reason that request body is blank, even when I get the proper request logged. I can see the requests to `/_pactSetup` and then the request to the actual API path but even that request's body is empty. Is it common to have to include the consumer's payload in the provider or is this an edge-case I'm after since I'm using aws sig4?

mike.bernard
2022-02-02 22:07
Maybe there's a way for me to fetch the actual pact it's going to validate against? That contains the body and would be reasonable enough to do.

matt.fellows
2022-02-02 22:09
Usually, you wouldn?t send the request to AWS - I tend to use `serverless offline` or `sam local`, which means I can circumvent a lot of this

matt.fellows
2022-02-02 22:09
also, I usually write my code in such a way that I can swap out the gateway if needed. For example, run it behind an express JS app instead of AWS. Most of the time, the gateway is invisible infrastructure to the service itself

matt.fellows
2022-02-02 22:09
but assuming that?s not viable, I know this has been done before

matt.fellows
2022-02-02 22:10
I?ll take a look after some meetings this morning

mike.bernard
2022-02-02 22:19
Sounds good. I'm in EST so may not respond until my tomorrow but thanks for the help again! SAM is probably a viable option but for this POC I was hoping to hit the actual gateway because of a tight timeline. I can investigate sam though, while you're investigating this.

ausachov
2022-02-03 13:15
has joined #general

patrice.krakow
2022-02-03 13:36
@tjones I have read many times the https://docs.pact.io/getting_started/provider_states/ page. At first, it sounds rather logical: _"Provider states allow you to set up data on the provider by injecting it straight into the data source before the interaction is run, so that it can make a response that matches what the consumer expects."_ Indeed, it would be great if the consumer could prepare the provider in a particular state before verifying its customer contract. But, when I am trying to imagine how that could be possible, I have the feeling that it requires a "level of collaboration" between the provider and the consumer which is higher than their actual lack of collaboration that guided me towards the idea of consumer-driven contract testing. So, I have the (wrong?) feeling that consumer-driven contract testing is addressing an issue while making this issue even more problematic, and therefore not solving it at all!? When I read _"The name of the provider state is specified in the given clause of an interaction in the consumer, and then used to *find the block of code to run in the provider to set up the right data*."_, I do not understand how that could work: the consumer is defining the `given` clause and the consumer does (must) *not* know anything about the implementation of the interface called... so how can the provider understand the `given` clause? I am really confused and I am wondering if you could point me to any references/documentation that could help me...

patrice.krakow
2022-02-03 15:07
From https://docs.pact.io/getting_started/terminology, I can also read _"A provider state name is specified when writing the consumer specs, then, when the pact verification is set up in the provider the same name will be used to identify the set up code block that should be run before the request is executed."_ but, I am wondering the kind of (manual human-based?) workflow is needed for the provider (?) to map a specific `given` clause content with a specific "code block" to be run... with a "best-seller" API having hundreds of consumers I do not see that working...

aaron.kibbie
2022-02-03 15:59
has joined #general

patrice.krakow
2022-02-03 16:09
I am also a bit confused between the usage of the words "given" (in https://docs.pact.io/implementation_guides/ruby/provider_states) and "providerState" (in https://github.com/pact-foundation/pact-specification/tree/version-2)... Are they the same thing, or is there a difference?

williangldzn
2022-02-03 20:23
has joined #general

matt.fellows
2022-02-04 05:11
> I am also a bit confused between the usage of the words ?given? (in https://docs.pact.io/implementation_guides/ruby/provider_states) and ?providerState? (in https://github.com/pact-foundation/pact-specification/tree/version-2)... Are they the same thing, or is there a difference? so you are comparing the language interface (i.e. the API you would use in your actual tests) with the format of what gets serialised into the contract file. In most cases, you shouldn?t have to care about what goes into the contract (and therefore, a whole lot about the inner details of the specification)

matt.fellows
2022-02-04 05:12
but to answer your question, yes, `given` will eventually spit out a provider state into the pact file. The attribute it gets serialised to actually depends on the version of the spec, so it?s only really relevant if you?re contributing to the framework at that level.

matt.fellows
2022-02-04 05:18
> I do not understand how that could work: the consumer is defining the `given` clause and the consumer does (must) *not* know anything about the implementation of the interface called... so how can the provider understand the `given` clause? Sort of. The given isn?t an implementation detail of the system (maybe of the test), it?s a statement about the expected state of the system. An example is ?user A exists? or ?there are orders?. This state is going to be the same whether or not the provider is a Ruby service, a dotnet service or some other Rube Goldberg machine. How the provider sets that up is completely up to the provider. It may be injecting data into a database, stubbing a third party API etc. This should happen in the context of a unit test on the provider side, so the system can be tested with fine grained precision. This gives us a number of benefits - e.g. the provider test suite can control its own data, it can be run locally, the tests can run in any order and importantly can be run in a controlled, unit test environment. > I have the feeling that it requires a ?level of collaboration? between the provider and the consumer Yes, ultimately that?s unavoidable if you consider what we?re trying to test here. > which is higher than their actual lack of collaboration that guided me towards the idea of consumer-driven contract testing. So, I have the (wrong?) feeling that consumer-driven contract testing is addressing an issue while making this issue even more problematic, and therefore not solving it at all!? Well, no, I wouldn?t agree with that statement. The alternative is an all-knowing end-to-end suite setup by some other entity, that has to run scenarios and setup data across the entire system. In my experience, this only leads to pain - slow tests, flakey tests, test frameworks that are as complicated as the code they are testing, clogging up testing environments, shared data fixtures, blocking releases etc.

matt.fellows
2022-02-04 05:30
> I am really confused and I am wondering if you could point me to any references/documentation that could help me... I?d suggest just giving it a go is possibly the shortest path to enlightenment from here. It seems like you?ve read a lot about the concepts and are asking fairly well directed questions, so you?re probably in good shape to get more out of them. Running the tutorials/workshops might help clarify them in a much more concrete way.

matt.fellows
2022-02-04 05:34
> but, I am wondering the kind of (manual human-based?) workflow is needed for the provider (?) to map a specific `given` clause content with a specific ?code block? to be run... with a ?best-seller? API having hundreds of consumers I do not see that working... We do have a number of https://docs.pact.io/faq/#what-is-pact-not-good-for for contract testing, which specifically addresses the ?large number of consumers? problem. In that case, you may wish to look into a different approach that Pactflow has called https://docs.pactflow.io/docs/workshops/bi-directional. It is still in developer preview, but essentially it instead opts for a schema comparison test (the consumer contract is compared to a provider spec - such as an OAS). It trades off the extra guarantees something like Pact gives you for a simpler workflow, and removes this specific challenge.

tjones
2022-02-04 06:13
As some of you know already, I've stepped down from maintaining pact-js to focus on other projects (technically last week was my last week as maintainer). The project is in good hands, though! @matt.fellows will still be around to steer the pact-js ship, and I think there might be some more contributions from other familiar faces coming up soon.. It has been several years now since I started maintaining pact-js - so many people to thank - but some specific standouts - @bethskurrie for giving me my first introduction to Pact on a few post-it notes (possibly on the first day we met), @abubics for initially suggesting we use Pact on a project we worked on together, @uglyog for agreeing to spend the time we were supposed to be talking about other things helping me with some pact-jvm issues, @yousafn for taking the initiative to get `jest-pact` out of a git gist and into an npm package with nearly 70,000 weekly downloads, and of course my Pact-JS co-pilot @matt.fellows for being an excellent co-pilot, engineer and friend. The whole team of maintainers have always been friendly and fun to work with through our many many discussions, agreements (and sometimes disagreements). The project is in good hands, and I think the Pact user base will only grow in the next few years - especially now that #pactflow is a thing, making it easier for new and enterprise users to get into Pact. Exciting times! Thanks also to the many Pact users out in the wider community - especially the occasional contributors - shout out to @artur for attention to detail and many many helpful PRs, and @omer.moradd for making things idomatic for Nest-JS users. The community of users and contributors keep the project alive, otherwise it would just be us maintainers. You make it all worth it! Finally, when I took up the Pact-JS reins, it was only possible because of the work of the maintainers + contributors that came before me (Tarcio, Michel, and others). Thank you too, past team! Even though I'm focussing on other projects, I still believe in the value that contract-testing with Pact brings to software development, and I'll keep using it (and probably will occasionally contribute PRs, who knows). I'll still be around on slack, but I'll take a break for a month or two to enjoy the sunshine first :sunglasses: Keep on Pacting, friends. Oh, and please remember to put your framework-specific issues in the right channel :thinking_face::laughing::smiling_face_with_3_hearts:

artur
2022-02-04 07:21
I even don't know what emoji to use a a reply. :rocket: because you brought the project ahead or :disappointed: because you are leaving it? Thank you for working on it and for helping me with random questions. Hope to stay in contact and that your new projects will be equally fun

ricardo.gonzaga
2022-02-04 09:35
has joined #general

patrice.krakow
2022-02-04 10:24
Hello @matt.fellows many thanks for all your answers. Unfortunately, I am more and more thinking that "Consumer-Driven Contract Testing with Pact" might not work in our organization, because of the way the _"Provider State"_ is communicated by the _consumer_ to the _provider_, for the _provider_ to perform the _"Pact verification"_. The _"Provider State"_ is given from the _consumer_ to the _provider_, as a *free English text*. It means that before the _provider_ can perform the _"Pact verification"_, a human being from the _provider_ team needs to read, understand and code the establishment of the "Provider State". It means that the _consumer_ will have to wait for the _provider_ to do something *manually*. This kind of dependency between the consumers and a producer is something we would like to avoid. In addition to that, the understanding by the _producer_ of the expected _"Provider State"_ as expressed by the _consumer_ with a free text sounds quite error-prone.

robin.jacques
2022-02-04 10:51
has joined #general

matt.fellows
2022-02-04 11:04
maybe, we obviously can?t make the decision for you and you?ll have to weigh up the pros/cons. We haven?t come up with a better way to solve the problem in the Pact paradigm in its entirety at this point, but in our experience, this is a lot better than the current standard paradigm of end-to-end tests, which gives practically zero autonomy to the provider?s in how integration tests are performed. As stated earlier, you can skip that whole problem with the *Pactflow* feature I mentioned (bi-directional contract testing). It has slightly less guarantees (I still think quite good) as it is not as strict as pact, but comes with a much simpler conceptual and implementation model. May I ask, something must have drawn you to contract testing with Pact in the first place? What were your motivations, was it interest in a new topic, problems with the current approach? What solutions are you currently investigating?

patrice.krakow
2022-02-04 12:04
1/ I had quick look at "Bi-directional Contracts Guide", but it does not look as good as "Consumer-Driven Contract Testing with Pact" in terms of test coverage. I love the idea of consumers describing in detail (with a lot of request/response pairs) what they expect from their providers. 2/ Within our organization, we (at least, some of us) do recognize the issue with end-to-end testing having applications based on a microservices architecture. We love the idea of testing the different interactions independently. We are struggling with (1) shared test environment, (2) test data, (3) feeding test environment with the right test data at the right moment, (4) ... all the classic issues. The ideal situation would be to give full autonomy to consumers (which is achieved by Consumer-Driven Contract Testing with Pact), as well as not disturbing the providers by consumer tests (the Public API use case). As I see things now, the missing part might be a formal way for the consumer to specify the provider state, so the provider can perform the pact verification in a fully automated way. A (possible) solution might be to ask the provider to develop a specific API to set the provider state, but creating an API to test an API might be the start of an infinite chain as you will need to test the API made for testing an API, and so on ... :grin: In addition to that this new API needed to test the API might be more complex than the API (to be tested). And usually, even if it should probably be the case, we are still not ready to spend more time/effort on testing something than on making something. A good illustration of that technique might be http://mockbank.io which allows you to test an API (the PSD2/Open Banking one) with your own test data that you can set with another "internal" API, or a nice UI using that "internal" API. But, this kind of technique raises another (big) question, should the provider allows you to set the state of its "real" service, or should the provider gives you a simulator of its service. In the case of http://mockbank.io, it is clearly a simulator and I think it must be a simulator: a real banking service should not allow you to set the balance to a certain amount out of nowhere, you MUST have a transaction, the money needs to come from somewhere. So, with a real banking service, it MUST be impossible to set the "Provider State" the way you like for your testing! That's why the provider has to provide a simulator in addition to its real service and keep their behavior aligned. And that is an expensive demand towards providers... To conclude, I think we agree that testing is not an easy/trivial task :wink:

matt.fellows
2022-02-04 12:05
There?s too many things to say about Tim, aside from the obvious contributions to some of the most popular projects in the ecosystem. Dedicated, helpful, friendly, creative, passionate. It might be the last one that defines his time here. It extends from ideas to improve the direction of the project to the day-to-day interactions with the community. Each interaction is always humble, carefully considered and often detailed, but also not patronising - you?ll probably learn something from each response despite the friendly demeanour. See https://pact-foundation.slack.com/archives/C5F4KFKR8/p1643471597396539?thread_ts=1638704614.250900&cid=C5F4KFKR8 piece of poetry for a recent favourite. Whilst I may have introduced conventional commits to Pact, Tim took it to a whole new level. If you?ve ever contributed anything, you may just have found yourself on the nitpicking side of a PR if you didn?t comply. I believe his diary entries may take the same form. I did make a promise to Tim to uphold these standards, and it didn?t take long! (apologies to @patrice.krakow :stuck_out_tongue: ), but a promise is a promise. Maintaining an Open Source project is very rewarding, but it also can be a source of stress, and we all deserve an opportunity for a break, especially given the past 24 months! We?ll miss you Tim, but enjoy your break! The :door: is always open :wave:

matt.fellows
2022-02-04 12:09
> . To conclude, I think we agree that testing is not an easy/trivial task :wink: :rolling_on_the_floor_laughing:

matt.fellows
2022-02-04 12:09
Yes, I can definitely agree to that!

matt.fellows
2022-02-04 12:09
So you?ve summed up the situation well

matt.fellows
2022-02-04 12:10
I don?t disagree that provider states aren?t a challenge, it?s just?we don?t have a better way to give both _isolation_ (the major property that makes pact attractive relative to the status quo) and _correctness_ (the ability to ensure that the concrete examples used are definitely supported by the provider).

matt.fellows
2022-02-04 12:11
In terms of practical ways to address provider states, however

matt.fellows
2022-02-04 12:11
it might sound like the consumer can just put garbage into a state. And they can, but there are also protections in pact to guard against consumers putting in rubbish contracts and breaking their provider (pending pacts).

matt.fellows
2022-02-04 12:12
so one approach is to simply have the provider declare all of the valid states it can be in, advertise them to all of its consumers, and then consumers can only use those states

matt.fellows
2022-02-04 12:12
That?s something we could consider adding to the broker, or somewhere else in the tooling. This could reduce the pain point you?re talking about, to an extent - right?

matt.fellows
2022-02-04 12:12
essentially, it?s a data fixture, but _only_ for a single provider (not the entire system)

matt.fellows
2022-02-04 12:14
One way you could support that in the short term, is simply creating a dummy consumer that supports all of the states the provider can be in, and publish that to the broker. Then you can point all of your consumers to that dummy contract and say ?this is everything we support?. This will work for provider driven flows, where the provider already exists. Where a consumer is adding new features to the provider, that?s naturally going to be a collaborative process anyway, so it?s not a big deal to agree on the name of the provider state.

matt.fellows
2022-02-04 12:14
what do you think?

diva.pant1
2022-02-04 12:36
When we ruck our spec files, the contract is saved in `/spec/pacts`, but we have to create the directory right, and how do we configure that the pacts are stored there?

matt.fellows
2022-02-04 12:40
sounds like a question for #pact-ruby?

patrice.krakow
2022-02-04 12:50
I think I like this approach where _"the provider declares all of the valid states it can be in, advertise them to all of its consumers, and then consumers can only use those states"_. It limits a bit the autonomy of the _consumers_, but it should allow a fully automated _pact verification_ :+1: The success of that technique will depend on the quality and quantity of those predefined _provider states_. However, the _consumers_ might send feedback to the _provider_ to enhance the quality and quantity of those predefined _provider states_. And, in this case, we could "sell" to the _provider_ that working on such feedback should not only benefit the _consumer_ who has sent the feedback, but also all future _consumers_, making this way of working quite scalable with an increasing number of _consumers_. That might actually also work with public APIs :smiley:

matt.fellows
2022-02-04 12:57
I'll revisit this idea next week from a project level proposal, but I think you can implement it now with your own internal policy

matt.fellows
2022-02-04 12:57
Thanks for the chat!

patrice.krakow
2022-02-04 13:05
However, I am not so sure about your _"it?s not a big deal to agree on the name of the provider state"_. The state of a _provider_ can depend on some independent degree-of-freedom, and the number of its possible states, being the permutations of this degree-of-freedom, might grow exponentially. For instance, a provider state might end up being something like: ? Given that Patrice has a bank account with the number BE17631383565421 ? Given that Patrice has a balance above 1000 EUR ? Given that Patrice has made several payments during the last 5 days for a total amount above 2500 EUR ? Given that Patrice is logged on his mobile application with the national access means ? Given that Patrice has a saving account with a balance above 10000 EUR ? ... and so on ... So, I think we still need to explore the practicality of setting predefined provider states... I will let you know. MANY thanks for your help so far :star::star::star::star::star:

diva.pant1
2022-02-04 13:05
okay, posted there

joaomiguel.rocha
2022-02-04 17:40
has joined #general

yousafn
2022-02-04 17:44
This is such amazing news for all the new projects ahead that are going to get so much more Tim time. You?ve been such an inspiration in the community and you will be greatly missed but your impact will be long felt. Your engineering skills are impeccable coupled with your passion, and helpfulness, has made it a pleasure both for maintainers, seasoned pro?s and pact newbies alike. I would agree that Open Source is hugely rewarding, but it can take it?s toll and it is great to maintain a healthy balance but also to take time to get away from it all and have some time enjoying life, with family and friends. That is why many of your contributions for automation, help free up some of our maintainers and contributors to be more efficient with their time and work on what really matters, people and collaboration. Thanks for supporting me through my Javascript adventures, and helping keep my imposter syndrome at bay. Enjoy the sunshine and hopefully catch you out in Aus one day!

matt.fellows
2022-02-04 22:16
:taco: :taco: :taco: for @pact544, who?s kicked off the year with a bunch of major contributions to the #pact-net project. I keep wakin up to an inbox that looks like this :laughing: Not too far away from a proper Nuget release it seems!

pact544
2022-02-07 07:52
What a nuisance that guy is eh? :rolling_on_the_floor_laughing:

jacek.sienniak
2022-02-07 08:45
has joined #general

jamie.weatherby
2022-02-07 15:25
has joined #general

joaobrandao.rodrigues
2022-02-07 16:30
has joined #general

extra
2022-02-07 21:31
has joined #general

austin.reifsteck
2022-02-07 22:39
Hi! :wave: I've been reading through some of the pact docs and I am very interested in the auto-generated docs that are viewable in the Pact Broker. It occurred to me that one way to define an API could be the union of all of its contracts. However, documentation seemed to be on a per-contract basis. Is there any support (current or planned) to view some aggregation of all of a provider's contracts in a format that could be loosely seen as an API spec?

matt.fellows
2022-02-07 22:43
We?ve certainly discussed this before. Might be worth taking a look at http://pact.canny.io to see if the request is there and voting on it

elenatuzel
2022-02-08 08:27
has joined #general

vadim
2022-02-08 09:19
has joined #general

patrice.krakow
2022-02-08 11:27
Hello @matt.fellows just wanted to share my latest thoughts... I think that going for a solution in which _"the provider declares all of the valid states it can be in, advertise them to all of its consumers, and then consumers can only use those states"_ is not a good idea as I think that the best thing about Consumer-Driven Contract Testing is the "Consumer-Driven" part, I would not like to bridle the consumer developers when they define their Pact. In addition to that, the important additional manual work asked to the provider developers for properly setting the "Provider States" defined by the consumer developers, needed before the "Pact Verficication" can take place might be forth it, when compared to the very important additional manual work needed to maintain and prepare "connected test environment(s)" needed to perform valuable end-to-end testing.

anna.khv
2022-02-08 12:19
has joined #general

dhospital
2022-02-08 16:15
has joined #general

mike.bernard
2022-02-08 16:34
Does anyone have any insight on this?

patrice.krakow
2022-02-08 18:08
Hello (again) @matt.fellows I am continuing my exploration of Pact but I found the examples not that easy to understand because of the entangling of Pact with the specific language used to code the consumer tests and the provider service. I just have a high-level understanding of JavaScript and I am not familiar with any of the numerous "stuff" used, e.g. ava, mocha, chai, axios, etc. That's why I have tried to create what would be for me a super simple scenario in order to illustrate/understand a typical _Consumer-Driven Contract Testing_ workflow with _Pact_, see https://github.com/patricekrakow/play-with-pact. In this scenario, I have reached my "critical point" in which the _Pact verification_ does not work because the "test data" invented by the _consumer_ does not match the test/real data used by the _provider_. Following the error message "WARNING: State Change ignored as there is no state change URL provided", I guess there is a way to allow the `pact_verifier_cli` to send the Pact file to the _provider_ so it can set the state according to the _Provider State_. So, I guess I have to implement a specific API endpoint for that on the _provider_, could you point me to the right document/specification to do that (without a library)...

jcabrera
2022-02-08 18:26
has joined #general

david.vancouvering
2022-02-09 00:55
Hey. I was watching the https://www.youtube.com/watch?v=VnOy9Sv9Opo and @bethskurrie said the recommended approach is for the consumer to code against new functionality on a feature branch so it doesn't break the provider. I totally get why this approach solves the problem of not introducing a contract into the main branch until it's ready to go live. However, this pretty much goes against trunk-based development. This is a key practice that has been shown to improve software delivery performance (see the book Accelerate). For reference you can see the https://cloud.google.com/architecture/devops/devops-tech-trunk-based-development as well as https://trunkbaseddevelopment.com/ It's great that pending pacts helps solve this, but I am concerned in general that as you develop tools and features for Pact, you're assuming a workflow that actually isn't best industry practice these days. For example, an important workflow we need to support is to put new changes behind a feature flag. We want to test the new pact that's behind this feature flag without causing the provider to have their build break now that the pact has been verified (which is what would happen with pending pacts). I think we can do this with tags (need to try it) but I'm concerned you're moving away from tags to the concepts of branches, deployments and features. In that world, there is no space for scoping a pact and its verification based on a feature flag. I'd love to hear your thoughts on this. Thanks!

abubics
2022-02-09 01:02
There are a few flavours of trunk-based, the one I see most often is very short-lived feature branches. I think might be the best-practice assumed workflow, or you need compile-time feature flags to not break the trunk.

matt.fellows
2022-02-09 01:03
Yeah, even the guide above has PRs that are attached to a branch (and, if not a branch, something conceptually identical to one)

matt.fellows
2022-02-09 01:03
that being said, you?re on the mark and we are thinking of ways to incorporate feature toggles into this workflow also


david.vancouvering
2022-02-09 01:04
Yea, but those are short-lived branches, like a day. In teams that are really good about delivering functionality in small chunks, an API change could go out in a day. But in other teams/orgs this is not the case, and generally the consumer will want to push out their changes even while the provider is still working on their side.

david.vancouvering
2022-02-09 01:05
Feature toggles is an example; my point is that the recommended workflow for Pact is going against the grain of very short-lived feature branches

matt.fellows
2022-02-09 01:06
I don?t think Pact takes a position on the lifetime of a branch, but perhaps you?re suggesting as a result of having branches as a concept it might _result_ in longer-lived branches as a consequence?

david.vancouvering
2022-02-09 01:06
Long-lived feature branches are really problematic; this is not just theoretically true, I still have scars on my back from teams that have done this

matt.fellows
2022-02-09 01:06
haha yes, most of us have!

david.vancouvering
2022-02-09 01:06
I don't see how you can recommend keeping a new API change on a branch without it becoming a long-lived branch

matt.fellows
2022-02-09 01:07
right, in that case you can definitely toggle (I do think we have some docs on that).

david.vancouvering
2022-02-09 01:07
Oh that's great. I couldn't find any


david.vancouvering
2022-02-09 01:08
Haha thanks. Sometimes search just doesn't work

david.vancouvering
2022-02-09 01:08
But, are tags going away as a thing?

matt.fellows
2022-02-09 01:09
no, I don?t think we?re looking to remove them

matt.fellows
2022-02-09 01:10
I would expect, at some point, a concept like a feature toggle to make its way into the broker so that they can be incorporated into standard workflows as a _first class citizen_ though

david.vancouvering
2022-02-09 01:10
Ok, well that's good. I think I've made my point and I will stand down :slightly_smiling_face: Realizing, reading your docs, that the same git sha is actually different versions of the consumer depending on which set of flags are toggled on or off. :thinking_face:

david.vancouvering
2022-02-09 01:10
Yea I do prefer first-class concepts over a bag of tags

matt.fellows
2022-02-09 01:10
> bag of tags :rolling_on_the_floor_laughing:

matt.fellows
2022-02-09 01:11
On the docs above, it?s possiblre there are better ways that advised. If you come up with them, do let us know - it?ll help with any future feature support and of course, docs

david.vancouvering
2022-02-09 01:12
Yea, it's actually an incredibly common anti-pattern. A developer says "we don't know what the schema is, so we just implemented a table with key column and a value column. It's so nice and flexible!" I go :scream: and explain the problem with what I call a "bag of flags"

matt.fellows
2022-02-09 01:12
Yes, it?s also ?very flexible? - what could be bad about that?!



abubics
2022-02-09 01:18
yeah, "bag of tags" is usually a workaround for "we don't know what we/you want/need yet" :sweat_smile:

ardiel.fuentes
2022-02-09 07:14
has joined #general

patrice.krakow
2022-02-09 08:32
@matt.fellows I have found the `--state-change-url <state-change-url>` option of `pact_verifier_cli` so I will be able to continue my investigation. It still feels a bit "weird" that the _Provider_ may have to update her/his code when receiving a new Pact, and I guess that it is (super) important that the way the _Provider State_ is set is not (too) fake, but reflect the actual behavior of the _Provider_. However, once again, these efforts need to be put in perspective with the work needed to maintain and prepare "connected test environment(s)" in order to perform valuable end-to-end testing.

ruud.von.faber
2022-02-09 09:11
has joined #general

james.perepiczka
2022-02-09 11:02
Hi, I wanted advice on the best approach for using Pact when you require pre-requisite data. For example, I want to test a success response structure for Service A, but in order to trigger that response I would need to hit multiple endpoints on Service B in order to create data to be utilised by Service A to give a success response. What is the approach here? Do you add setup api calls to run before the pact test to generate the required data? or do you do something in the provider like stubbing out a datasource?

matt.fellows
2022-02-09 11:17
Thanks Patrice, sorry I didn?t g et to the bottom of my inbox/slack messages today #inboxZeroFail

matt.fellows
2022-02-09 11:17
glad you?re back on track!

matt.fellows
2022-02-09 11:19
Yes, the equivalent in pact is called ?provider states?

matt.fellows
2022-02-09 11:19
the consumer says ?given *User A exists* A *request to get User a* (at path `/users/a` should return a `200` with a `{..}` etc.?

matt.fellows
2022-02-09 11:20
the provider then is responsible for ensuring ?User A exists? before the tests run. How that happens is language specific, but basically there is a state hook that fires before the specific test is executed and the provider can do what it needs (seed a database, stub a call etc.)

patrice.krakow
2022-02-09 12:55
Hello @matt.fellows I am progressing :wink: I have implemented within the _Provider_ the `POST /` endpoint in order to set the Provider Sate so the Pact verification is successful. I will update https://github.com/patricekrakow/play-with-pact. But I still have an error from the `pact_verifier_cli`: ```play-with-pact>pact_verifier_cli --file consumer.pact.json --url http://localhost --port 3000 --state-change-url http://localhost:3000 12:50:48 [ERROR] Failed to load pact - Failed to load pact 'http://localhost' - Request failed - error sending request for url (http://localhost/): error trying to connect: tcp connect error: No connection could be made because the target machine actively refused it. (os error 10061)``` What is this "load pact" about? Why `http://localhost` is supposed to "load" the Pact file???

agustin.gomes
2022-02-09 13:23
has joined #general

agustin.gomes
2022-02-09 13:26
Hi everyone :wave: happy to be here

thijme.langelaar
2022-02-09 13:29
has joined #general

agustin.gomes
2022-02-09 13:31
My team is looking to introduce Contract test in our CI/CD pipeline. I was looking for the best strategy here to setup the broker as a first step. what yould be your advice? ? Building a Helm chart around the `https://hub.docker.com/r/pactfoundation/pact-broker` docker image? ? Free trial on https://pactflow.io? ? other option? Would appreciate any feedback or input :slightly_smiling_face:

dharmesh.kumar
2022-02-09 13:52
has joined #general

patrice.krakow
2022-02-09 14:03
@matt.fellows FYI, I have just updated https://github.com/patricekrakow/play-with-pact. It would now be nice to eliminate/understand the `Failed to load pact` error... Many thanks in advance for your help :+1:

athaper
2022-02-09 14:14
has joined #general

dennis.woditsch
2022-02-09 15:30
We are currently also using the free trial to establish contract testing and it's sufficient. We will buy a team license after we have an initial setup. We agreed that we do not want to struggle with additional overhead maintaining a pact broker

agustin.gomes
2022-02-09 17:02
Thank you @dennis.woditsch For now I started with the free trial of pactflow, it felt the best way forward for the reasons you mention too

svranyes
2022-02-09 20:16
has joined #general

samuel.whittaker
2022-02-09 23:40
has joined #general

matt.fellows
2022-02-09 23:42
from `pact_verifier_cli`: > -u, --url <url>... URL of pact file to verify (can be repeated) the `--url` is the url of the _pact_ to verify. You can pass in multiple sources, so `--file` is a path to a pact file, `--url` is a path to a pact on a web server somewhere, etc.

matt.fellows
2022-02-09 23:44
I can?t see where you?re setting the flags to verify your _provider_ though. It might be using the defaults, but I?d expect to see `-p` and `-h` in there, as well as the state change URL if you have them

patrice.krakow
2022-02-10 08:30
Oh, I think I have mixed `-u` with `-h` :woozy_face:

patrice.krakow
2022-02-10 09:05
@matt.fellows That was that! Replacing ```pact_verifier_cli --file consumer.pact.json --url http://localhost --port 3000 --state-change-url http://localhost:3000``` by ```pact_verifier_cli --file consumer.pact.json --hostname localhost --port 3000 --state-change-url http://localhost:3000``` fixed it :grinning: Many thanks again for your help/support! I now have all I need for a first try selling _Consumer-Driven Contract Testing with Pact_ to my colleagues :+1:

patrice.krakow
2022-02-10 09:44
@matt.fellows I have updated https://github.com/patricekrakow/play-with-pact. As I explained earlier, I have started my own little "Play with Pact" demo because I was missing an "end-to-end" example of the _Consumer-Driven Contract Testing with Pact_ workflow in which the usage of Pact would not be "entangled" with the usage of a specific language. If it makes sense to you, I would be happy to contribute to a new https://docs.pact.io/implementation_guides/ or maybe update the existing "Other Languages" one, but I feel it more as a "No Language" than an "Other Languages". Before the "Pact JS", "Pact JVM", "Pact Net", ... I see a room for a "Pact" or "Pact Alone" or "Vanilla Pact", ... What do you think? I would like to make sure that such documentation does make sense for you before starting working on it...

david.hvilava
2022-02-10 10:53
has joined #general

cyrus.devnomad
2022-02-10 13:51
Hello I'm trying to implement a pact solution for the multiple dependent microservices scenario A -> B -> C. The most detailed description of the problem and the potential solutions seems to be the following GitHub Gist: https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0#file-index-md What is meant with the following sentence? "Then, in your Pact test for CClient, you can use the same alligator instance as a "link" to tie your stubbing to an artifact that will get verified." Can someone elaborate a bit more on that? "your Pact test": Which pact test is meant here "AB provider test" or "BC consumer test"? "same alligator instance": Is the same subbing instance to be used in both tests? "AB provider test" and "BC consumer test"? Who writes to the shared artifact and who reads from the shared artifact? Thanks

carlos.ferrao
2022-02-10 15:46
has joined #general

rios.martinivan
2022-02-10 20:18
has joined #general

charles.kuo
2022-02-10 21:42
has joined #general

david.vancouvering
2022-02-10 22:25
Starting to learn about pending pacts and work-in-progress pacts. *Pending pacts* - _don't break the build_ for new pacts that have not yet passed verification. *Work in progress pacts* - _run verification_ for the latest pact for any branch which is still pending, and which was not explicitly specified by the provider verification configuration. I was looking at using WIP to manage feature flag variations. But if WIP only runs for pending pacts, how do I make sure that a feature flag pact that _previously passed verification_ will get verified in the future, when the provider changes?

matt.fellows
2022-02-11 02:15
Yep, that would no doubt be helpful to others

matt.fellows
2022-02-11 02:17
I think: 1. A new page under https://docs.pact.io/implementation_guides/other_languages (maybe we just call it ?demonstration? or ?example?? We can iterate on that) 2. The page contains the rationale for when you would do this (which, in my view, is if you can?t use a language specific DSL directly) 3. A cross-referenced link on the ?https://docs.pact.io/recipes? page to this

abubics
2022-02-11 05:01
Generally there's no "provider test". There are just consumer tests and provider verifications.

abubics
2022-02-11 05:02
"your Pact test for CClient" would be the test that exercises CClient, and is verified by C API.

abubics
2022-02-11 05:06
But really, you don't typically need to think about AB and BC at the same time. They have separate lifecycles and workflows and pipelines.

sudhanshu.testing
2022-02-11 05:12
has joined #general

cyrus.devnomad
2022-02-11 08:26
I would like to learn how to implement either of the approaches. The one where I would not look at AB and BC at the same time, which you refer to and the one where I would look at them at the same time. Once I would understand both approaches and how to implement them, I could still choose the more typical solution, you are referring to. But knowing both approaches would give me a bit more feeling of control over the whole thing, which I'm kind of lacking currently :blush: But do I understand it correctly, in the more typical approach you are referring to, I would have to set the "AB provider verification" boundary at B API or B Controller yes? I mean I would have to mock any calls towards the inner parts of B Codebase and set the state of B at B API or B Controller boundary yes?

cyrus.devnomad
2022-02-11 08:59
By the way, how do typical pipelines for B look like? Do my pipelines look valid/typical? B provider pipeline: -         Test CClient -         Test B-API or B-Controller -         Publish BC pact -         Can-i-deploy -         Deploy B verify changed AB pact pipeline: -         Test CClient -         Test B-API or B-Controller

patrice.krakow
2022-02-11 09:15
Great, I will work on that... We should indeed probably iterate on the name - https://martinfowler.com/bliki/TwoHardThings.html :grin: - I will probably start with the (code) name "Pact NoDSL". Regarding the rationale, my main motivation is to provide a "tool" to help the understanding of _Pact_. I see it more as educational material for training than something you would actually use for your project. By the way, the distinction and the relation between Pact and language-specific DSLs was something that takes me some time to grasp and was a source of confusion when I first discovered Pact. I hope that having a "Pact NoDSL" part might be a way to progress more naturally from Pact (alone) to language-specific DSLs. In a "Pact NoDSL", you write separately the "consumer test(s)" and the Pact file, it can then be the right moment to introduce the idea of writing them at the same time, using a DSL.

alessandro.polidori
2022-02-11 15:02
has joined #general

krisakins
2022-02-12 20:19
has joined #general

ian.cervantez
2022-02-13 03:32
has joined #general

abubics
2022-02-13 23:55
There are a bunch of diagrams in the docs (https://docs.pact.io/pact_nirvana/step_4/#consumer-pipeline), about pipelines :slightly_smiling_face: the specifics will always depend on what your situation looks like, but the high level is generally consistent

abubics
2022-02-13 23:56
There's not really an approach where you'd look at AB and BC at the same time. The intent is to isolate those interaction points so you can run things independently (otherwise you end up back in integrated testing land).

abubics
2022-02-13 23:59
As far as stubbing goes, you get to decide where it makes sense to cut. Depending on your internal architecture you may have different options. I prefer to cut just inside the provider, once requests have been parsed, to make sure they make sense. Other people might not have such a clean internal structure, and choose to stub on the outside, e.g. stubbing entire external dependencies.

antonio.gamiz
2022-02-14 06:51
has joined #general

antonio.gamiz
2022-02-14 06:57
Hi! Does anyone know where the documentation for the body of the POST request of the provider setup url parameter is? I get the following body: ```{ "consumer": "Consumer", "state": "User exists and has resources", "states": [ "User exists and has resources" ], "params": {} }```

marko.justinek
2022-02-14 06:58
What Pact implementation are you using?

antonio.gamiz
2022-02-14 07:07
pact python

marko.justinek
2022-02-14 08:15
Tried asking in #pact-python?

antonio.gamiz
2022-02-14 09:26
Oh, I thought that was independent of the implementation, thanks!

matt.fellows
2022-02-14 09:45
Actually in this case you?re right, but most people probably wouldn?t know that - so all is forgiven

matt.fellows
2022-02-14 09:57
I missed this. Your summary of WIP/Pending is how I think about it

matt.fellows
2022-02-14 09:58
Good question on feature flags. @bethskurrie any thoughts?

matt.fellows
2022-02-14 10:01
I don?t actually know where the canonical source is, but this is the Ruby application. I believe it sends both the array format (`states`) and the single `state` property to support both V3 and V2 clients. Params is a v3 thing, and can be passed through from the consumer test.

matt.fellows
2022-02-14 10:02
The properties you see there are the only ones I?d expect to see - the consumer that this test is for, state name itself and any parameters that go with it.

matt.fellows
2022-02-14 10:02
In the case of V2 pacts, I?d only expect that `state` and `consumer` are populated

cyrus.devnomad
2022-02-14 11:23
So if for example in case of A sending 11 to B the valid expected response of B were x,y,z where x & y were independent of C and z were dependent on C, I could basically stub z along x and y yes? And would have the case 11 --> z to be included in the BC-consumer tests or not necessarily?

antonio.gamiz
2022-02-14 14:01
Ohhh, I see, thanks a lot!! :slightly_smiling_face:

zish.gatrad
2022-02-14 16:01
has joined #general

james.troughton
2022-02-14 16:08
has joined #general

david.vancouvering
2022-02-14 17:52
Great, thanks, looking forward to your thoughts @bethskurrie

spencerm
2022-02-14 19:41
Hey, I have a general question about a scenario I?m facing. I have a frontend service that wants to request data from an API. However, this backend must be abstracted from the frontend. I am creating a set of AWS Lambda functions to act as the abstraction layer that the frontend will call. Say one of these endpoints is itemLambda - it will receive a request from the frontend, make a request to one or more of the other backend endpoints and return a json response to the frontend of the requested data. Most of the time, these lambda functions will just directly return the JSON data they receive from the other backend services. I want to set up a pact contract between each lambda and the backend. These lambdas are written in typescript, so realistically they can have any structure of JSON returned to them and, as they just return the JSON, they will not fail. Therefore, does it make sense to introduce some sort of runtime type checking, e.g. zod, to validate that the received json will be interpretable by the frontend? I?m specifically thinking about the consumer pact tests here, in that any json could be provided and they would pass, meaning we have little confidence in the contract. Or is there another way to deal with such a scenario, e.g. contract: backend endpoint <-> lambda <-> frontend

marko.justinek
2022-02-14 20:59
Right, I assumed you were asking how to use your framework to fill in the ?missing? values, sorry.

abubics
2022-02-15 00:18
Yep, that sounds right to me :slightly_smiling_face: The z binding through to C can be tested in a separate runtime/lifecycle, and should be from the perspective of B making a request to C (independent of the AB request). If you break up the coupling that way, it could be any data, not strictly 11->z (which would be a required data coupling if run in the context of the AB request).

manuelam20
2022-02-15 00:41
has joined #general

dchen
2022-02-15 08:03
has joined #general

aristides.suarez
2022-02-15 08:14
has joined #general

marcelino.garcia
2022-02-15 08:22
has joined #general

varnika.singh
2022-02-15 09:11
has joined #general

antonio.gamiz
2022-02-15 13:29
Hi! I?m still quite new to pact and I?m getting this error: `There is no verified pact between version a41c5fa63a9104db55e530f826acb52bfbcfcfdc of Backend and the version of Routes currently deployed to production (no such version exists)` when I run can-i-deploy from my consumer (Backend)

antonio.gamiz
2022-02-15 13:30
these are the last two verifications I have

antonio.gamiz
2022-02-15 13:30
do you know why I?m getting that error?

antonio.gamiz
2022-02-15 13:31
I do not know if those N/A values maybe the problem

antonio.gamiz
2022-02-15 13:33
oh maybe do i need to call record_deployment?

antonio.gamiz
2022-02-15 15:51
it was that, hehe

bernard
2022-02-15 16:22
has joined #general

david.uzumaki
2022-02-15 16:33
has joined #general

abhishekc.jh
2022-02-15 17:21
has joined #general

nuno.frias
2022-02-15 19:28
has joined #general

faran
2022-02-15 22:31
has joined #general

andy
2022-02-16 00:35
has joined #general

fushinoryuu
2022-02-16 01:40
has joined #general

david.vancouvering
2022-02-16 02:22
Hey @bethskurrie checking in - any words of wisdom for us? Thanks!

abdelior
2022-02-16 08:48
has joined #general

abdelior
2022-02-16 08:50
Hi all!

abdelior
2022-02-16 08:51
I wanted to ask if anybody has worked with Pact and Flutter applications as a consumers :slightly_smiling_face:

matt.fellows
2022-02-16 10:05
Maybe check out and see where #pact-dart is at?

abdelior
2022-02-16 10:40
Thanks Matt!

misterjkl
2022-02-16 13:12
has joined #general

brian.azizi
2022-02-16 14:05
has joined #general

richelle.raaphorst
2022-02-16 15:17
has joined #general


guillermo.aguirre
2022-02-17 20:06
has joined #general

matt.fellows
2022-02-18 00:18
This looks to be fixed now. Thanks for letting us know

matt.fellows
2022-02-18 06:03
Happy Friday :wave: In case you missed it, lots happening over at Pactflow HQ. As a sneak preview, if you were ever wondering how to combine contract testing with OpenAPI, this might be for you! https://pact-foundation.slack.com/archives/CLS16AVEE/p1645163512468319

aforeman
2022-02-18 06:04
This is gonna be a game-changer!!

adamslack
2022-02-18 15:55
has joined #general

bernard
2022-02-18 17:14
~Hi everyone, I'm publishing an OAS contract via GitHub Actions, and I'm seeing this error... any idea where I'm going wrong with this...?~ Solved it, environment variable for my URL had double quotes around it. ```error publishing contract + results Error: connect ECONNREFUSED 127.0.0.1:80```

darwin.cahyadi
2022-02-18 18:00
has joined #general

rishi.speets
2022-02-19 14:43
has joined #general

krisakins
2022-02-19 15:54
Sorry if this isn't the right place to pose the question. I'm really interested in contract testing & pact. I'm just trying to get an idea of how widespread the adoption is. I saw on http://pact.io there some big names listed like Atlassian, but can I be pointed to any other well-known microservice-heavy organizations that heavily invest in contract testing? Even if they don't use pact, but perhaps use contract testing to address the integration testing problem at large. Not that big names always matter, but I think demonstrated success can provide confidence. Part of this is me trying to 1) make sure this is the right path for my team, 2) convince my team/manager that we should go forward

matt.fellows
2022-02-19 22:09
Maybe the customer stories / articles here: https://docs.pact.io/blogs_videos_and_articles

matt.fellows
2022-02-19 22:13
Here's a sample of some of our customers at Pactflow (and therefore Pact)

matt.fellows
2022-02-19 22:18
I particularly like the Nubank case study even though it's not Pact. It reads as if they've watched and consumed our material, down to Dora metrics and scaling language.

matt.fellows
2022-02-19 22:19
There are a couple of case studies on https://pactflow.io/ also

krisakins
2022-02-20 00:34
That's perfect, thanks @matt.fellows!!


ybergstrom
2022-02-21 03:24
has joined #general

gyuvaraj10
2022-02-21 08:03
has joined #general

gyuvaraj10
2022-02-21 08:05
I want to create Webhooks with Personal access token of Azure DevOps since the user credentials usage is disabled. I couldn't find any documentation that can help me on this in the pact docs. Please someone suggest

athissen
2022-02-21 08:09
has joined #general

andrefcsousa
2022-02-21 10:19
has joined #general

katharina.pavic
2022-02-21 12:37
has joined #general

ipoe
2022-02-21 14:54
has joined #general

jeroen.vandijk
2022-02-21 16:40
has joined #general

ondikumana
2022-02-21 22:13
has joined #general

nithyag.ganesan
2022-02-22 10:01
has joined #general

ntiwari
2022-02-22 11:48
has joined #general

phil.vint
2022-02-23 11:01
has joined #general

phongthornk
2022-02-23 11:04
has joined #general

phongthornk
2022-02-23 11:10
Hello Pact Team, I really don't know where I can ask for the right channel? However, I try to run workshops which JS and Golang. I've found the same problem with Ruby. So I am not sure how to fix it. Golang: https://github.com/pact-foundation/pact-workshop-go ```<class:CGIHandler>': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError)``` JS: https://github.com/pact-foundation/pact-workshop-js Anyone please help me to fix this :slightly_smiling_face:

matt.fellows
2022-02-23 11:12
hmm I?ve seen this before but I don?t think we ever fully chased it down

matt.fellows
2022-02-23 11:12
I think it might be an environment variable

matt.fellows
2022-02-23 11:12
any chance you could please take a dump of your environment, redact anything important, and share?

matt.fellows
2022-02-23 11:13
Do you also happen to have a ruby installation at all?

phongthornk
2022-02-23 11:23
Pact need to install Ruby, right?

phongthornk
2022-02-23 11:24
I think Pact can run without require Ruby installation

phongthornk
2022-02-23 11:25
However, I try to find a software list to install to make sure I missed something to install. So I just see only workshop and it make me understand to have at all.

matt.fellows
2022-02-23 11:26
You don?t need to install Ruby, no

matt.fellows
2022-02-23 11:26
I was interested if you did, because that could explain the problem

matt.fellows
2022-02-23 11:26
I?m expecting some environment variable or configuration that Ruby is detecting that?s not utf-8 (ascii-8bit).

matt.fellows
2022-02-23 11:26
What?s your OS/arch?

matt.fellows
2022-02-23 11:26
What is your default language and encoding?

phongthornk
2022-02-23 11:26
Linux

phongthornk
2022-02-23 11:28
Not sure for how to check

phongthornk
2022-02-23 11:28
encoding UTF-8

phongthornk
2022-02-23 11:29
I ty with JS workshop first it get the same errors

matt.fellows
2022-02-23 11:30
strange

phongthornk
2022-02-23 11:32
Maybe it is just a warning message. I see the next error about this

phongthornk
2022-02-23 11:33
I still confusing about MOCK_SERVER and PACT_BROKER Is that the same thing?

matt.fellows
2022-02-23 11:33
no

matt.fellows
2022-02-23 11:33
mock server is used locally to mock the provider API

matt.fellows
2022-02-23 11:33
the pact broker is used to share contracts and collaborate

matt.fellows
2022-02-23 11:34
I suspect that?s because the ruby process didn?t start correctly so the golang tests are not able to talk to the mock

phongthornk
2022-02-23 11:34
Mock server that start from pact lib, right?

phongthornk
2022-02-23 11:36
Actually, I will start using pact with PHP but the document is not hard to understand. I will try to do the workshop first.

phongthornk
2022-02-23 11:41
@matt.fellows Could you please let me know if you have any update?

lukasz
2022-02-23 14:55
has joined #general

patrice.krakow
2022-02-23 17:25
Hello All :wave: I am still exploring Pact and I just wanted to share this little demo of "How to use the `--provider-state-header-name` option of the `pact-stub-server` in order to select one specific _provider state_ in case multiple matching _interactions_ are found" | https://github.com/patricekrakow/play-with-pact/blob/main/misc/select-provider-state.md Sometimes, as a _consumer_, you want the API to return a different _response_ for the exact same API _request_ *depending* on the _provider state_. By default, when the `pact-stub-server` received a _request_ for which there are multiple matching _interactions_, it will just select the first one. However, you can specify the _provider state_ you want via a custom HTTP header, I love it :star-struck:

yousafn
2022-02-24 00:06
This is excellent Patrice, thanks for sharing back with us all.

yousafn
2022-02-24 00:08
Can you ```echo $LANG``` on your machine?

yousafn
2022-02-24 00:11
I get `en_GB.UTF-8`

abubics
2022-02-24 00:15
I get `en_AU.UTF-8`, and I've had weird problems in WSL with unsupported locales. Definitely good to check :ok_hand:

phongthornk
2022-02-24 05:44
I get `en_US.UTF-8` @yousafn

phongthornk
2022-02-24 05:46
The problem related to a terminal? I using ZSH not Bash.

phongthornk
2022-02-24 05:49
For more detail ```go test -tags=integration -count=1 http://github.com/pact-foundation/pact-workshop-go/consumer/client -run 'TestClientPact' 2022/02/24 12:46:45 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0 2022/02/24 12:46:45 [INFO] checking pact-provider-verifier within range >= 1.31.0, < 2.0.0 2022/02/24 12:46:45 [INFO] checking pact-broker within range >= 1.22.3 2022/02/24 12:46:46 [ERROR] service: /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:21:in `<class:CGIHandler>': incompatible character encodings: ASCII-8BIT and UTF-8 (Encoding::CompatibilityError) 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:19:in `<module:HTTPServlet>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:17:in `<module:WEBrick>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb:16:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet.rb:13:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet.rb:13:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:16:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpserver.rb:16:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick.rb:225:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick.rb:225:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/ssl.rb:8:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/ssl.rb:8:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/https.rb:11:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/https.rb:11:in `<top (required)>' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:173:in `require' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:173:in `require_common_dependencies' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/pact-mock_service-3.9.0/lib/pact/mock_service/cli.rb:30:in `service' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' 2022/02/24 12:46:46 [ERROR] service: from /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/app/pact-mock-service.rb:15:in `<main>' 2022/02/24 12:46:56 [ERROR] Expected server to start < 10s. Timed out waiting for Mock Server to start on port 41519 - are you sure it's running? --- FAIL: TestClientPact_GetUser (0.00s) --- FAIL: TestClientPact_GetUser/the_user_exists (0.00s) client_pact_test.go:73: Error on Verify: Post "http://localhost:41519/interactions": dial tcp 127.0.0.1:41519: connect: connection refused FAIL Post "http://localhost:41519/pact": dial tcp 127.0.0.1:41519: connect: connection refused FAIL http://github.com/pact-foundation/pact-workshop-go/consumer/client 11.194s FAIL```

matt.fellows
2022-02-24 06:08
No, I use ZSH it?s not the terminal

matt.fellows
2022-02-24 06:10
can you please run `file -ib /home/altelma/projects/Jörmungandr/pact-workshop-go/pact/lib/vendor/ruby/2.2.0/gems/webrick-1.3.1/lib/webrick/httpservlet/cgihandler.rb` ?

matt.fellows
2022-02-24 06:11
I?m wondering if somehow, the files themselves are encoded differently

matt.fellows
2022-02-24 06:12
I think you?re on linux, I believe that?s the right flag to get the encoding

phongthornk
2022-02-24 06:16
I get this `text/x-ruby; charset=us-ascii`

matt.fellows
2022-02-24 06:18
I noticed your file path had extended characters in it. Seems unlikely to be the cause, but if you move it to a dir like `/tmp/foo` do you still have the same issue?

phongthornk
2022-02-24 09:41
@matt.fellows Wow. It works :slightly_smiling_face: Thanks so much

matt.fellows
2022-02-24 11:01
oh really!!

phongthornk
2022-02-24 12:03
Yeah. It is complicated :slightly_smiling_face:. However, I walk through step 11 of the workshop. I try to publish the pact file to https://test.pact.dius.com.au https://test.pact.dius.com.au/pacts/provider/GoUserService2022/consumer/GoAdminService2022/latest I got failed when I run the command `make provider` ```FAIL: TestPactProvider/has_a_matching_body (0.00s) pact.go:629: Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has a matching body pact.go:635: Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has a matching body Actual: null Diff -------------------------------------- Key: - is expected + is actual Matching keys and values are not shown -{ - "firstName": "Sally", - "id": 10, - "lastName": "McSmiley Face??", - "type": "admin", - "username": "sally" -} Description of differences -------------------------------------- * Expected a Hash (like {"firstName"=>"Sally", "id"=>10, "lastName"=>"McSmiley Face??", "type"=>"admin", "username"=>"sally"}) but got nil at $``` I already tested with the local pact file. It works. @matt.fellows Do you have any ideas?

phongthornk
2022-02-24 12:22
In the log file not attach Authorization in header ```# Logfile created on 2022-02-24 19:20:00 +0700 by logger.rb/47272 I, [2022-02-24T19:20:02.367233 #78258] INFO -- : Running example 'Verifying a pact between GoAdminService and GoUserService Given User sally exists A request to login with user 'sally' with GET /user/10 returns a response which has status code 200' I, [2022-02-24T19:20:02.374053 #78258] INFO -- : Sending GET request to path: "/user/10" with headers: {"X_PACT_PROVIDER_STATES"=>[{"name"=>"User sally exists"}]}, see debug logs for body D, [2022-02-24T19:20:02.374120 #78258] DEBUG -- : body : I, [2022-02-24T19:20:02.392009 #78258] INFO -- : Received response with status: 401, headers: {"Content-Length"=>"0", "Content-Type"=>"application/json; charset=utf-8", "Date"=>"Thu, 24 Feb 2022 12:20:02 GMT", "X-Api-Correlation-Id"=>"8c2aa5ba-ea1e-4a39-8dfd-20a333d6f387"}, see debug logs for body D, [2022-02-24T19:20:02.392090 #78258] DEBUG -- : body: ```

matt.fellows
2022-02-24 12:23
It looked like what was published has a different name to what you're verifying (missing 2022cin the application names)

matt.fellows
2022-02-24 12:23
So you're probably verifying a different contract

phongthornk
2022-02-24 15:01
@matt.fellows Oh that's true. I see code to set provider name not using `os.Getenv` Now It works. Thanks so much.

ezequiel.uhrig
2022-02-25 13:46
has joined #general

emin.sahin
2022-02-26 13:53
has joined #general

ihassin
2022-02-27 21:20
has joined #general

yumiihuang
2022-02-28 09:55
has joined #general

yousaf
2022-02-28 11:57
has joined #general

gerry
2022-02-28 12:56
has joined #general

agustina.bosso
2022-02-28 16:04
has joined #general


deactivateduser320370
2022-03-01 11:41
has joined #general

yousafn
2022-03-01 11:47
Hey, thanks for the warm welcome Matt. I am so excited to be here, and to be able to dedicate my full time to Pact and it's incredible community. If you have any questions, thoughts, wishes or just want to vent or chat, feel free to reach out, my door is always open.

luke.bickell
2022-03-01 14:46
has joined #general

james.williams
2022-03-01 16:29
has joined #general

aforeman
2022-03-01 22:13
Welcome @yousafn@yousafn@yousafn ! So pleased to have you join us :pactflow-platypus-slack: :tada:

qluck
2022-03-01 22:15
has joined #general

peter.pinda
2022-03-01 23:37
has joined #general

tjones
2022-03-02 02:14
Great choice!!

yousafn
2022-03-02 11:29
Thanks for all the guidance, advice and helping me become a better engineer@tjones. Looking forward to catching up at some point in the future.

patrice.krakow
2022-03-02 11:38
QUESTION(S): If you would draw the "scope" of respectively "functional testing" (owned by the provider) and "contract testing" (owned by the consumers) as a Venn diagram, (a) would you fully include the "contract testing" circle/set within the "functional testing" circle/set, or (b) would you have a part of the "contract testing" circle/set not included within the "functional testing" circle/set? If you would go with option (b), what would be a representative example of a "contract test" not being as well a good "functional test"? I do have my own answers to these questions - being more "dynamic" than just replying (a) or (b) - but, I am wondering what are your thoughts... P.S. This question has been triggered by the great video _"Best practices for writing consumer tests"_ with @bethskurrie | https://www.youtube.com/watch?v=oPuHb9Rl8Zo&t=1333s

yousafn
2022-03-02 12:23
Great discussion topic @patrice.krakow I think my answer would be it depends on my current client situation and problem they are trying to solve. Without contract testing I would expect to have functional testing at both the provider and consumer side with unit tests and component integration tests. These would use mocks/doubles and could go out of sync from the providing service. We would normally have system integration tests that run through some smoke/sanity tests of core user flows when its deployed into a shared environment. This is where we would see our biggest problems, where regressions were introduced not due to changes in the functional flow, but due to the messaging exchange breaking down due to a schema change in an API. Contract testing plugged that gap, and the way the pacts are generated in the consumer side code, means the pacts are generated as a side effect of the functional testing taking place on the consumer side. (so I would use a unit testing framework such as jest to assert that my client does whatever it should with a valid response, as I assert against the clients output) so getting my functional testing covered, but with the benefit of generating that pact for provider verification, ensuring that when we deploy we don't have a regression because of a schema change. We might still find that a system integration test may still fail but just to application logic and not message schema. On the provider side, the contract verification isn't about functionally testing the providers business logic.

patrice.krakow
2022-03-02 13:32
I was writing my question in the context of https://docs.pact.io/consumer#use-pact-for-contract-testing-not-functional-testing-of-the-provider, avoiding the pitfall of having the consumer testing the provider API. The goal of the consumer is not to discover _bugs in the provider (though this might come up as a by-product)_. So, it is clear that the functional testing of the provider API goes beyond a specific Pact written by a specific customer. So, from a Venn diagram perspective the "provider functional testing scope" is certainly not included in the "consumers contract testing scope". The fact that discovering _bugs in the provider [...] might come up as a by-product_, makes it clear that there is a non-empty intersection between the "consumers contract testing scope" and the "provider functional testing scope". Then, the last question is if the "consumers contract testing scope" is fully included in the "provider functional testing scope", or if there are tests in the "consumers contract testing scope" that are not in the "provider functional testing scope". My answer is *"eventually no"*. Let me explain... The goal of the "provider functional testing" is to _ensure that the provider does the right thing with a request_, coming for *any/all* consumers! So, it's a "no". However, there is a dynamic. When the provider first defines its functional tests, you cannot expect him to cover all possible requests, and the contract tests from the consumers can enrich its functional tests. So, a contract test will be either already included within the "provider functional testing scope", or the provider will extend its functional tests in order to have it eventually included. So, as shown in the diagram below, I would see the "provider functional testing scope" successively expanding with new contract tests to eventually cover the "consumers contract testing scope". Note that, ideally, at each "iteration" the intersection is bigger making the needed expansion smaller/easier and smaller/easier.

dmitry.korolev
2022-03-02 14:02
Hi All :wave: I am curious if somebody dealt with applying contract tests to libraries. I have a provider with quite complex API, and the team who develops this provider also ships the client library that hides the complexity of this interface. They still want to guard this interface with contract tests, which resulted into contracts between the provider and the library. The library of course is not deployable by itself, so they cannot apply can-i-deploy tool to it. Therefore, when consumers that integrate the library are deployed, there is no way to see if some contracts are broken or not. The alternative is of course to implement contracts between services ignoring the library, but then consumers will need to know the details about the API in between the library and the provider, which is currently nicely hidden from them. Any thoughts? :slightly_smiling_face:

pact544
2022-03-02 14:05
Shipping a client library _and_ doing consumer driven contract testing sound like complete opposites to me

2022-03-02 14:41
*This polly is closed.* @lewis.prescott079 has a polly for you!

patrice.krakow
2022-03-02 14:48
Hello @dmitry.korolev. When you wrote _"this interface"_, are you talking about (1) the (network) interface of "Service A" exposed to the "Client library", or (2) the (code) interface of the "Client library" exposed to the "Service B" and "Service C"?

dmitry.korolev
2022-03-02 14:49
Hello Patrice, I meant the network interface exposed by Service A and consumed by Client library.

dmitry.korolev
2022-03-02 14:52
To some extent yes. So, do you think that an old school integration test approach will be more appropriate in this case?

omer.bilgin
2022-03-02 15:51
has joined #general

banolik
2022-03-02 18:35
has joined #general

ancyaziz
2022-03-02 22:26
has joined #general

ancyaziz
2022-03-02 22:35
I am new to Pact Contract Testing. I am using Pact-go and I have a Struct with String[], I need to write a pact:example for this, but I am getting error "`struct field tag `json:"tags" pact:"example="Name::CustomerName","Status::Live""` not compatible with reflect.StructTag.Get: key:"value" pairs not separated by spaces`". JSON value is ```"tags":["Name::CustomerName","Status::Live"]``` Under Struct, this is what I have which is throwing error. `Tags []string `json:"tags" pact:"example="Name::CustomerName","Status::Live""`` can someone tell me the correct format of pact:example for string[]?

timothyg
2022-03-02 23:40
has joined #general

harihararaj.lk
2022-03-03 09:44
has joined #general

matt.fellows
2022-03-03 11:38
I see you?ve asked in Pact Go - I?ll answer there.

matt.fellows
2022-03-03 11:39
I wrote an answer to this question a while back here :https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/

matt.fellows
2022-03-03 11:40
We also answered it in one of our AMAs: https://docs.pact.io/help/amas#north-america-2

matt.fellows
2022-03-03 11:40
> How can I do contract testing with API clients/SDKS?

toyamarinyon
2022-03-03 13:25
has joined #general

david342
2022-03-03 13:26
has joined #general

yesilmenadil
2022-03-03 16:14
has joined #general

dajaman1
2022-03-03 20:30
has joined #general

smalladi
2022-03-03 21:40
I am new to pact contract testing . When i try to build provider service i am facing below error . Could you please help .

smalladi
2022-03-03 21:40
http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://test.pactflow.io/pacts/provider/ProviderPact/for-verification' at app<//au.com>.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:307) at app<//au.com>.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:141) at app<//au.com>.dius.pact.core.pactbroker.HalClient$postJson$3.invoke$lambda-0(HalClient.kt:482) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:202) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:143)

uglyog
2022-03-03 22:02
You need to configure the authentication correctly, that resource requires a username and password

smalladi
2022-03-03 22:08
```pactbroker_host pactbroker_token``` I have these two properties

uglyog
2022-03-03 22:08
Are they correct?

uglyog
2022-03-03 22:09
I think that URL uses a username/password, not a token

smalladi
2022-03-03 22:11
ya they are correct values

smalladi
2022-03-03 22:12
but before i was able to use host, token. I am doing the same for one other application and it is not working

smalladi
2022-03-03 22:21
If i run the pact provider test alone

smalladi
2022-03-03 22:21
No HAL document found at path 'https://brownbag.pactflow.io/pacts/provider/ProviderPact/for-verification' http://au.com.dius.pact.core.pactbroker.NotFoundHalResponse: No HAL document found at path 'https://brownbag.pactflow.io/pacts/provider/ProviderPact/for-verification' at app<//au.com>.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:307)

uglyog
2022-03-03 22:36
The stack trace and logs will have a cause of the error. 99% of the time it is the authentication that is not correct

waqif
2022-03-03 23:32
has joined #general

dmitry.matveev
2022-03-03 23:44
has joined #general

mail_4brad
2022-03-04 02:48
The problem becomes when you have more than one client using the library, because that can lead to clients using different versions of the library. Do you choose to maintain integration tests to ensure coverage for every client version you ever released? (Maybe that is maintainable if breaking changes are minimal). Do you have a strategy for retiring old client versions now?


matt.fellows
2022-03-04 07:37
Just a little news over in Pactflow town :point_up:

david342
2022-03-04 09:58
I'd be very interested in this !

matt.fellows
2022-03-04 10:11
Whilst you?re waiting, @mcruzdrake is running a workshop very soon. Use the promo code MARIEWQF for a nice little incentive:shushing_face: Learn more here :point_right: https://bit.ly/3tffW5a

reuben.tonna
2022-03-04 14:32
has joined #general

negrolyze
2022-03-04 15:34
has joined #general

smalladi
2022-03-04 16:11
```at app//au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:307) at app//au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:141) at app//au.com.dius.pact.core.pactbroker.HalClient$postJson$3.invoke$lambda-0(HalClient.kt:482) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:202) at app//org.apache.hc.client5.http.impl.classic.CloseableHttpClient.execute(CloseableHttpClient.java:143) at app//au.com.dius.pact.core.pactbroker.HalClient$postJson$3.invoke(HalClient.kt:481) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) at app//au.com.dius.pact.core.pactbroker.HalClient.postJson(HalClient.kt:480) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchPactsUsingNewEndpoint$2.invoke(PactBrokerClient.kt:345) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpoint(PactBrokerClient.kt:344) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchPactsUsingNewEndpointTyped(PactBrokerClient.kt:307) at app//au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectors(PactBrokerClient.kt:276) at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:231) at app//au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:118) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider$resolvePactSources$pactSources$1$pacts$1.invoke(PactJUnit5VerificationProvider.kt:83) at app//au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:39) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.resolvePactSources(PactJUnit5VerificationProvider.kt:83) at app//au.com.dius.pact.provider.junit5.PactVerificationInvocationContextProvider.provideTestTemplateInvocationContexts(PactJUnit5VerificationProvider.kt:44) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.lambda$execute$0(TestTemplateTestDescriptor.java:103) at java.base@17.0.1/java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:273) at java.base@17.0.1/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1625) at java.base@17.0.1/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) at java.base@17.0.1/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base@17.0.1/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) at java.base@17.0.1/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) at java.base@17.0.1/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base@17.0.1/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:107) at app//org.junit.jupiter.engine.descriptor.TestTemplateTestDescriptor.execute(TestTemplateTestDescriptor.java:42) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.1/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base@17.0.1/java.util.ArrayList.forEach(ArrayList.java:1511) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at app//org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at app//org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67) at app//org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52) at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at app//org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at app//org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at app//org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79) at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61) at java.base@17.0.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base@17.0.1/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base@17.0.1/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base@17.0.1/java.lang.reflect.Method.invoke(Method.java:568) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94) at jdk.proxy2/jdk.proxy2.$Proxy5.stop(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193) at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100) at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60) at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:133) at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:71) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69) at app//worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)```

smalladi
2022-03-04 16:12
full stack strace, i could not see anything related to credentials

42amehmeto
2022-03-04 19:17
has joined #general

rawatankit90
2022-03-04 22:33
has joined #general

tom.daley
2022-03-07 09:09
has joined #general

leon.brown
2022-03-07 09:26
has joined #general

aurelia.rochat
2022-03-07 10:16
has joined #general

alanbos
2022-03-07 18:29
Having embarked upon looking at consumer-driven contract testing against a GraphQL server, I've come to the point where I need to step back and ask folks here about the appropriate strategies for this compared to testing REST contracts. With a REST provider, contracts tend to be based on quite specific endpoints with focused responses, and (tricks with Accept headers and query parameters aside) there isn't a whole lot of flexibility in what the consumer can expect out of e.g. the response to a GET. This allows provider tests (state change handlers) to be less consumer-focused (ideally completely decoupled from a specific consumer). With GraphQL, the entry points to the graph that a particular consumer app uses may be relatively small in number to choose from, but the number of different navigation paths from that starting query grow exponentially as the graph becomes larger and more connected. So what should such contracts be about? It seems to me that at its simplest the contract could be verifying the schema-correctness of the provider query; schema-correctness is relatively simple to test in most GraphQL servers, but what about the details of the response matching, and how far down the GraphQL server stack should be mocked in the state change handler? Is this an appropriate use of pact? With the chances that any two consumer app's queries being alike _very_ small, it feels like a full-stack state change handler that needs to provide the right returned data shape is going to either become extremely messy to maintain, or will need to do a lot of introspection and mock relatively high up the stack, or there will be effectively one state change handler per consumer contract. If anyone has any opinions or experience on the benefits of different approaches to GraphQL consumer-driven contract testing, I'd be very interested - TIA.

kabhatiya
2022-03-08 00:51
has joined #general

matt.fellows
2022-03-08 06:12
As a start, I put my general thoughts here previously: https://pactflow.io/blog/contract-testing-a-graphql-api/

matt.fellows
2022-03-08 06:17
I don?t have any recent good experiences with large GraphQL rollouts

matt.fellows
2022-03-08 06:17
@sreid might have something to add?

sreid
2022-03-08 08:03
Hey @alanbos, Yep, graphql pacts can be tricky! One of the things we did was to have interactions use a print of the GQL (parsed GraphQL) as the `withQuery` and formatted variables format GQL definition: ```import { gql } from '@apollo/client' export const GQL_QUALIFIED_NAME = gql` mutation mutationName($type: TokenType!, $token: String!) { mutationName(type: $type, token: $token) { transactionId id orderNumber } } ```` Consumer test file ```// These must be static for Pact versioning const exampleRequestToken= '8b06e062-32e3-41b3-b3ae-fbddb637eca0' // generator: generateFakeGuid(), const graphQLResult = { transactionId: '2c8ac019dfbe430d087b1d23', // generator: generateFakeMongoDBId(), id: 'ac1a5c72-73e8-4d36-bd79-6c1fbfcfb27f', // generator: generateFakeGuid(), orderNumber: '320403409' // generator: generateFakeExternalOrderId() } const requestFormat= { token: Matchers.regex({ generate: exampleRequestToken, matcher: Matchers.UUID_V4_FORMAT }), type: REQUEST_TOKEN_TYPE } const resultFormat = { transactionId: Matchers.regex({ generate: graphQLResult.exampleResultId, matcher: '^[0-9a-f]{24}$' }), id: Matchers.regex({ generate: graphQLResult.exampleResultGUID, matcher: Matchers.UUID_V4_FORMAT }), orderNumber: Matchers.regex({ generate: graphQLResult.exampleOrderNumber, matcher: '^[0-9]{9}$' }) } // Define Interaction on client new ApolloGraphQLInteraction() .uponReceiving('internal test name') .given('pact scenario name must be identical in provider and consumer') .withOperation('mutationName') .withQuery(print(GQL_QUALIFIED_NAME)) .withRequest({ path: '/graphql', method: 'POST' }) .withVariables(requestFormat) .willRespondWith({ status: 200, headers: { 'Content-Type': 'application/json; charset=utf-8' }, body: { data: { mutationName: Matchers.like(resultFormat) } } }) ) // Execute interaction on client await expect( client.mutate({ mutation: GQL_QUALIFIED_NAME , variables: { token: exampleRequestToken, type: REQUEST_TOKEN_TYPE } }) ).resolves.toEqual({ data: { mutationName: graphQLResult } })```

matt.fellows
2022-03-08 08:08
Thanks for sharing @sreid :taco:

sreid
2022-03-08 08:22
The other tricky bit we had was getting Pact to understand how to host these queries. We ended up spinning up an Express server to handle the request from Pact on the Provider side our pact server: `note: we didn't resolve getting typedefs dynamically built at test time, so they are manually added here` ```import express from 'express' import { Express } from 'express-serve-static-core' import { ApolloServer, gql } from 'apollo-server-express' import { Server } from 'http' // TODO really needs to use scheama.gql, and not be manually updated const typeDefs = gql` enum TokenType { TOKEN_TYPE_A TOKEN_TYPE_B } ` export default class GraphQLTestServerFactory { apolloServer: ApolloServer expressServer: Express // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types constructor(resolvers) { // Provide resolver functions for your schema fields this.apolloServer = new ApolloServer({ typeDefs, resolvers }) this.expressServer = express() this.apolloServer.applyMiddleware({ app: this.expressServer }) } listen({ port }: { port: number }): Server { return this.expressServer.listen({ port }) } }``` Then jest problems, but it provided enough flexibility to test multiple scenarios Provider Test file: ```let testFactory: GraphQLTestServerFactory const mutationNameMock = jest.fn() beforeAll(() => { jest.setTimeout(30000) // IO is slow sometimes const resolvers = { Mutation: { mutationName: (_, params) => mutationNameMock(params), }, } testFactory = new GraphQLTestServerFactory(resolvers) }) // Test describe('Pact Verification', () => { it('validates charge Paydock with token', async done => { const opts: VerifierOptions = { stateHandlers: { 'pact scenario name must be identical in provider and consumer': async () => { mocked(serviceA.internalFunctionA).mockResolvedValueOnce(valueA) mocked(serviceA.internalFunctionA).mockResolvedValueOnce(valueB) mocked(mutationNameMock).mockImplementationOnce(({ token, type }) => mutationsClass.mutationNameMethod(type, token), ) return Promise.resolve('this worked') }, 'a different pact scenario': async () => { mocked(serviceA.internalFunctionA).mockResolvedValueOnce(valueA) mocked(serviceA.internalFunctionA).mockResolvedValueOnce(valueC) mocked(mutationNameMock).mockImplementationOnce(({ token, type }) => mutationsClass.mutationNameMethod(type, token), ) return Promise.resolve('this worked') }, 'a failing pact scenario': async () => { mocked(serviceA.internalFunctionA).mockResolvedValueOnce(valueA) mocked(serviceA.internalFunctionA).mockResolvedValueOnce(undefined) mocked(mutationNameMock).mockImplementationOnce(({ token, type }) => mutationsClass.mutationNameMethod(type, token), ) return Promise.resolve('this worked') }, }, provider: 'provider-service-name', consumerVersionSelectors: [{ tag: 'master', latest: true }], pactBrokerUrl: process.env.PACT_BROKER_BASE_URL, enablePending: true, includeWipPactsSince: '2020-01-01', providerVersion: process.env.BUILDKITE_COMMIT, providerVersionTags: process.env.BUILDKITE_BRANCH, providerBaseUrl: 'http://localhost:4002', publishVerificationResult: http://process.env.CI === 'true', logLevel: 'info', } const output = await new Verifier(opts).verifyProvider() console.log(output) done() }) })```

sreid
2022-03-08 08:23
It doesn't wrap neatly into jest scenarios, and there may be better approaches, but this hopefully gets you started

varnit.garg2424
2022-03-08 08:48
Hey Guys, I've come across this below question, can you please provide some insights? Bascially, per my understanding there are two ways to create/run pact tests.. 1. create and run the pact tests just like unit tests i.e mock all the input data as we do in traditional unit tests (no need to spin up the dependencies and no need to create the instance of application) 2. spin up the environment, run the instance of the application along with all the dependencies like database etc and then run the pact tests.. I understand that the major usp of pact is that it provides fast feedback and hence #1 should be relevant. However, I would like to hear your thoughts as well.

matt.fellows
2022-03-08 09:15
We've done AMAs on the scope of these tests before: https://docs.pact.io/help#join-an-upcoming-ask-me-anything-ama-session

matt.fellows
2022-03-08 09:16
Are you talking about consumer or provider side here?

matt.fellows
2022-03-08 09:16
Consumer should be closer to a unit test

varnit.garg2424
2022-03-08 09:16
and how about provider side?

matt.fellows
2022-03-08 09:16
Provider usually you would start the application locally and stub out dependencies

varnit.garg2424
2022-03-08 09:19
Oh, but why can't the provider tests be closer to a unit test? what if we just mock the function which returns the end result?

matt.fellows
2022-03-08 09:28
Can you perhaps elaborate on what exactly you're mocking here?

luis.garelli
2022-03-08 09:29
has joined #general

varnit.garg2424
2022-03-08 10:41
Let's suppose in case of event driven architecture, there is one boundary function which takes some input and generate the output which will then be put in to the queue. I'm mocking the input data to that function. I found this on pact official website, then pact tests are two set of unit tests (one set on consumer side and another one on provider side) Having said that, I'm curious to understand what is the need to start the provider application locally?

alanbos
2022-03-08 10:55
Many thanks @sreid - that's very useful in helping to understand just how the provider verification might proceed. I guess my questions about GraphQL-based contract testing are as much about the _what_ and _why_ as the _how_. If you have a growing number of client apps (consumers) all with very specific interactions with a very rich connected graph, then it feels to me that the contracts become extremely specific to the consumer and possibly quite complex to verify; the entry points (supported queries and mutations) may be smaller in number and more analogous to a set of REST entry points - but its the flexibility in specifying the response shape that feels to me where the contract approach struggles. I wonder whether a simpler level of contract that is based on schema validity (i.e. is this GraphQL request schema-valid?) might strike the appropriate balance between affording protection to consumers and not introducing an unbounded set of highly specific contracts to be maintained in the provider.

andrevdrodrigues
2022-03-08 12:50
has joined #general

tobias
2022-03-08 13:11
has joined #general

mutharaju.kk
2022-03-08 14:34
has joined #general

will.robinson
2022-03-08 14:54
has joined #general

bernard
2022-03-08 16:13
Hi :wave: I'm reusing a participant (my consumer) with a colleague who has created a provider. And I'm seeing two integrations in PactFlow. The error I would like to fix is below... ```Computer says no ¯_(?)_/¯ There is no verified pact between version 2eaea58+1646755788 of pactflow-example-consumer and the version of pactflow-example-provider currently deployed to production (no such version exists)``` But I don't want to verify the `pactflow-example-provider` I only want to verify the new integration `pactflow-example-provider-restassured`.

fragonib
2022-03-08 16:22
has joined #general

bernard
2022-03-08 16:33
I was able to resolve this error by deleting my local `pacts/*.json` file.

jason.wang
2022-03-08 19:05
has joined #general

qluck
2022-03-08 20:54
Hi all! I'm trying to find a good way to debug my tests in Intellij. Does anyone have a run configuration or any general tips of how to set this up? Thanks in advance!

sreid
2022-03-08 23:10
@alanbos I guess my advice here has some facets. ? Making a service too generalized in possible use cases may result in something that _by nature_ is hard to develop edge cases for ? Consumers should be able to validate their scenario is supported by the provider ? Consumer driven contract tests give assurances to the consumer that what they expect to happen, will happen, by the design of contract testing ? Consumers should be providing these Pacts to you for their scenario's, especially if they're quite complex ? Graphql has inbuilt schema validation ? Graphql queries define result shapes that could be a subset of data. ? I think this is a limitation around Pact's query and response definitions that they can't be exhaustively tested for each possible combination ? Contracts allow expectations of valid combinations to be set, and new Consumer Contracts can be easily added for new combinations, if the Consumer wanted a guarantee of the interface compatibility. It sounds like contract testing is exactly what you need. If their is a concern that a single provider is possibly doing too much work, it might be time to refactor into smaller responsibility interfaces.

matt.fellows
2022-03-08 23:31
The main point of graphql, as I understand, is that consumers choose what data to return. But the Provider still must be able to return the full dataset. So whilst each consumer may have wildly different shaped queries, it shouldn?t actually change the provider implementation. What you do get however, is complete visibility into the types of queries you need to actually support. Where it might get tricky is dealing with all of the various provider states. There are strategies here, but they are no different to regular HTTP Pact.

matt.fellows
2022-03-08 23:33
so that question is going to be very language specific. Which language - Java?

matt.fellows
2022-03-09 00:09
Thanks for clarifying. So in message Pact, you can definitely get closer to a true unit test.

matt.fellows
2022-03-09 00:10
I asked, because in an HTTP provider test, you usually have several important layers that can be tested - e.g. the controllers, routing etc. and the actual request handlers. Extensive mocking here can be problematic, because the goal is to make sure the provider can both understand and respond correctly.

matt.fellows
2022-03-09 00:10
The answer is ?it depends?, basically. If you have really good coverage across various layers of the system where you have confidence in narrowing the scope of a pact test - all power to you

varnit.garg2424
2022-03-09 00:28
Got it. Thank you for explaining it in detail! :slightly_smiling_face:

sam680
2022-03-09 05:12
has joined #general

annette.reid
2022-03-09 07:43
has joined #general

alanbos
2022-03-09 08:25
Thanks both for your thoughts on this - @matt.fellows when you say "the Provider must still be able to return the full dataset", what would that practically entail in a large highly connected graph - the nature of graphql servers tending to be mostly gateways to their own set of external "providers", this seems to imply mocking all of those backend services in order to ensure that consumer contracts are covered; it would be very complex to introspect the query issued by a particular contract and figure out dynamically what mocks are required, and I feel that writing a dedicated state handler for every contract seems excessive in terms of coupling and brittleness. I'm wondering what all the effort of such mocking actually achieves; in GraphQL the schema is the language of the contract - if my query is schema-valid, what extra assurances does a consumer gain from the provider filling in the response, especially if most of the provider stack exercised by doing so tends to be boilerplate server framework code? The implied contract of a GraphQL server is "if your query is schema-valid, I will respond with data in the shape you ask for". Anyway thank you for taking the time to respond to my existential angst :-) I think my current feeling is that contract testing as a pathway to checking schema validity of the consumer's request seems the most useful approach, but detailed response checking isn't worth the investment of effort.

edouard.lopez
2022-03-09 09:56
Hello, One of our provider send a JSON like ```{ "level": 0, }``` But suddenly, they changed the `level` value to `2` which broke our consumer. Is this something we should verify with a contract test?


alanbos
2022-03-09 10:43
P.S. Had I got my thinking hat on properly, I would have realised that e.g. ApolloServer can be easily run in a mode where all resolvers are mocked without any explicit action. So that means not only can the consumer assert on schema-validity of the request, but also on the expected shape (and more importantly here, the datatypes/values that come back in the leaf nodes of the response tree).

alex1toryanik
2022-03-09 11:08
has joined #general

aleem.riaz
2022-03-09 12:17
has joined #general

mike.geeves064
2022-03-09 12:28
An example of going from something like `{"level": 0}` to `{"level": "OFF"}`where you have a possibly unexpected different type due to a change stringifying an enum would be a valid use case, done that one before :slightly_smiling_face:

josephwoodward
2022-03-09 12:30
has joined #general

josephwoodward
2022-03-09 13:02
Hi, has anyone here experimented with PACT's messaging API? I'm looking at the state providers/handlers but I don't see much about their usage in the messaging API.

matt.fellows
2022-03-09 13:08
They should be exactly the same as the HTTP ones

matt.fellows
2022-03-09 13:08
Which language?

josephwoodward
2022-03-09 13:08
Go

josephwoodward
2022-03-09 13:09
It's probably my lack of understanding of how it works then. My understanding is the support is still early so I didn't now how complete it was.

matt.fellows
2022-03-09 13:10
One sec


matt.fellows
2022-03-09 13:11
Go fully supports messages

matt.fellows
2022-03-09 13:12
The v2.x.x branch does to if you're up for using the next major

josephwoodward
2022-03-09 13:19
Thanks, I've been looking through the docs but couldn't see much mention of how to use the states from the messaging perspective. I'll take a look at the 2.x.x branch.

josephwoodward
2022-03-09 13:20
Perhaps a naive question, but how do the `Params` values get set? (https://github.com/pact-foundation/pact-go/blob/a40972e9597b0112937c5e1af79308f253bfd9c9/dsl/message.go#L56). I see `Given` sets the Name.

sebastianman45
2022-03-09 15:29
has joined #general

sebastianman45
2022-03-09 15:39
Hi guys, good morning :sunglasses::wave:; I'm new to testing with PACT, is there any way to get the response of the calls to the APIs after the provider side verification was done? my code is as follows ```describe("Validate pact of identity", () => { it("Validate pact of identity creation", () => { let opts = { providerBaseUrl: baseUrl.BASE_URL, changeOrigin: true, provider: "Create identity", logLevel: "DEBUG", pactUrls: [ path.resolve( process.cwd(), `./__tests__/contract/pacts/${identity_data.nameConsumerPactFile}-${identity_data.nameProviderPactFile}.json` ), ], requestFilter: async (req, res, next) => { req.headers["authorization"] = "Bearer UQiQPSG-MtD3mNHG0JZT2mqfBh1", next() }, consumerVersionTags: ["QA"], providerVersionTags: ["QA"], publishVerificationResult: false, providerVersion: "1.0.0" } return new Verifier(opts).verifyProvider() .then((res) => { console.log('-------> here I need to get the response <-------', res); }).catch((res) => { console.log('Pact Verification FAIL!: Get identity ', res); }); }) })```

edouard.lopez
2022-03-09 15:42
The type is the same, but the value is inconsistent, it doesn't make sense to have `level: 2` on the first level of the object. IMHO that sound like https://docs.pact.io/consumer/contract_tests_not_functional_tests#does-the-provider-return-the-expected-response So we should enfore the value for this level

qluck
2022-03-09 16:05
@matt.fellows we're using NodeJS

yousafn
2022-03-09 16:51
Hey @sebastianman45, Try setting the `logLevel` to `trace` See this https://github.com/pact-foundation/pact-js/pull/462 for context . Hope that helps :crossed_fingers:

yousafn
2022-03-09 17:35
Ahh that doesn't appear to work, the code is in place in pact-js, but from what I can see pact-js's exported Verifier, calls pact-node, which in turn calls the pact-provider-verifier, which doesn't support the trace method and fails here `pact-node@10.17.1: Created '/Users/saf/dev/pactoss/jest-pact-typescript/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.81/pact/bin/pact-provider-verifier'` https://github.com/pact-foundation/pact-provider-verifier/blob/7d52ff479e9ba982db49b9e120f4c876a515de97/lib/pact/provider_verifier/cli/verify.rb#L118 ```[2022-03-09 17:30:14.098 +0000] WARN (31571 on Yousafs-MacBook-Pro.local): pact-node@10.17.1: Pact exited with code 1. Error: Invalid log level 'trace'. Must be one of: debug, info, warn, error, fatal. at ChildProcess.<anonymous> (/Users/saf/dev/pactoss/jest-pact-typescript/node_modules/@pact-foundation/pact-node/src/verifier.ts:275:58)```

sebastianman45
2022-03-09 17:42
Hi @yousafn ) thanks for answering :sunglasses:, I want to contextualize my need a little more; the API that I am calling generates a guid that I need to capture in order to delete the data it generates (if I don't delete it, it could cause problems later); I don't know if there is any way to capture the response after of the validation of pact to later remove it with a hook :thinking_face:

yousafn
2022-03-09 17:50
Ahh brilliant, thanks for the additional context. I dug a little more into the code https://github.com/pact-foundation/pact-js/commit/efa1e1034f0c58b26fe0cf4e148cdb728f5ae84d#diff-bcf94b082b5b493850358e0d5c89b94a20bf5fac5e6e5261c339688891f16047R131 and it seems if you do set 'debug' now request/response logging will be provided. We are currently capturing them, but not storing them, just outputting to the logs (as `trace` ) which isn't being set, so those refs probably want changing to `debug` as well. It wouldn't be too hard to store the req/responses in an object and return them. Would welcome a PR :sunglasses: otherwise feel free to raise a feature request via the GitHub issues on https://github.com/pact-foundation/pact-js or via our public roadmap https://pact.canny.io/

sebastianman45
2022-03-09 20:20
Thank you so much for you help :raised_hands: @yousafn, I already have created the issue in the repo https://github.com/pact-foundation/pact-js/issues/836

sergio.artero
2022-03-09 20:31
Hi, we are using the dockerized version of PactCLI (*pactfoundation/pact-cli:0.50.0.20*) and we are seeing this error verifying a contract when the provider responds with a `set-cookie` header (I have truncated it for readability purposes) ```pact-cli_1 | Failure/Error: replay_interaction interaction, options[:request_customizer] pact-cli_1 | pact-cli_1 | NoMethodError: pact-cli_1 | undefined method `strip' for nil:NilClass pact-cli_1 | # /usr/lib/ruby/gems/2.7.0/gems/rack-2.2.3/lib/rack/mock.rb:260:in `block in identify_cookie_attributes' ...``` Do you have any clue on how to fix this? Thanks in advance!

victor.lau
2022-03-09 20:46
has joined #general

matt.fellows
2022-03-09 20:52
might be best asking in #pact-js. What?s different about Pact that means you can?t use the usual debugging features?

matt.fellows
2022-03-09 20:53
If you expect level 0 to be the response for a particular shaped request, then you need to ensure the provider always does so, you usually telegraph this via a provider state

matt.fellows
2022-03-09 20:54
if the `0` can be any number, then a `like` matcher is appropriate

matt.fellows
2022-03-09 20:55
They aren?t, at the moment. The type is there because it may be received

matt.fellows
2022-03-09 20:55
I think we could actually support a `GivenWithParams(string, params)` in that API now

diva.pant1
2022-03-09 21:09
Random question, but when we do contract testing, then we create the json files explicitly right. The response that we want, do we write that explicitly in json file before running the Pact test?

qluck
2022-03-09 21:40
I mean I guess I just haven't figured out the correct run configuration. I'll ask in the pact-js channel to see if anyone has a good idea. Thanks!

matt.fellows
2022-03-10 04:43
No, the contract is generated by the act of writing and running pact (unit) tests

matt.fellows
2022-03-10 04:44
Where did you get this idea from? If in our docs, we should clarify as it is not expected that these are manually edited

lewis.prescott079
2022-03-10 09:24
I made a podcast about contract testing for Microservices. The first installment we talk about the challenges of testing including domain boundaries, breaking down monoliths and much more: https://anchor.fm/pactman-consulting

diva.pant1
2022-03-10 09:52
Yes its not mentioned in the docs, but after running my unit test I don't see a json file being generated, so I wonder where I am going wrong

matt.fellows
2022-03-10 11:47
So I?ve just cloned https://github.com/pact-foundation/pact-ruby cd `example/zoo-app` `bundle install` `rake spec` the pacts are generated: ```cat spec/pacts/zoo_app-animal_service.json { "consumer": { "name": "Zoo App" }, "provider": { "name": "Animal Service" }, "interactions": [ { "description": "a request for an alligator", "providerState": "there is an alligator named Mary", "request": { "method": "get", "path": "/alligators/Mary", "headers": { "Accept": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json;charset=utf-8" },....```

matt.fellows
2022-03-10 11:47
what happens if you do the same?

matt.fellows
2022-03-10 11:48
If I then try to verify it: ```? animal-service git:(master) ? rake pact:verify SPEC_OPTS='' /Users/matthewfellows/.rvm/rubies/ruby-2.7.3/bin/ruby -S pact verify --pact-helper /Users/matthewfellows/development/public/pact-ruby/example/animal-service/spec/service_consumers/pact_helper.rb INFO: Reading pact at ../zoo-app/spec/pacts/zoo_app-animal_service.json WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'. Verifying a pact between Zoo App and Animal Service Given there is an alligator named Mary a request for an alligator with GET /alligators/Mary returns a response which has status code 200 has a matching body includes headers "Content-Type" which equals "application/json;charset=utf-8" Given there is not an alligator named Mary a request for an alligator with GET /alligators/Mary returns a response which has status code 404 Given an error occurs retrieving an alligator a request for an alligator with GET /alligators/Mary returns a response which has status code 500 has a matching body includes headers "Content-Type" which equals "application/json;charset=utf-8" 3 interactions, 0 failures ? animal-service git:(master) ? rm ../zoo-app/spec/pacts/zoo_app-animal_service.json ? animal-service git:(master) ? rake pact:verify SPEC_OPTS='' /Users/matthewfellows/.rvm/rubies/ruby-2.7.3/bin/ruby -S pact verify --pact-helper /Users/matthewfellows/development/public/pact-ruby/example/animal-service/spec/service_consumers/pact_helper.rb Error reading file from ../zoo-app/spec/pacts/zoo_app-animal_service.json No such file or directory @ rb_sysopen - ../zoo-app/spec/pacts/zoo_app-animal_service.json /Users/matthewfellows/.rvm/gems/ruby-2.7.3/gems/pact-support-1.17.0/lib/pact/consumer_contract/pact_file.rb:53:in `read' /Users/matthewfellows/.rvm/gems/ruby-2.7.3/gems/pact-support-1.17.0/lib/pact/consumer_contract/pact_file.rb:53:in `get_local' /Users/matthewfellows/.rvm/gems/ruby-2.7.3/gems/pact-support-1.17.0/lib/pact/consumer_contract/pact_file.rb:43:in `render_pact' /Users/matthewfellows/.rvm/gems/ruby-2.7.3/gems/pact-support-1.17.0/lib/pact/consumer_contract/pact_file.rb:24:in `read' /Users/matthewfellows/development/public/pact-ruby/lib/pact/provider/pact_source.rb:17:in `pact_json' /Users/matthewfellows/development/public/pact-ruby/lib/pact/provider/pact_spec_runner.rb:124:in `collect'```

matt.fellows
2022-03-10 11:50
Given that these projects work, I would 1. Check if they work for you 2. If the do, find out what?s different about your setup 3. Create a reproducable example that somebody can run to help guide you (see howtorepro for more on that) I?m guessing that perhaps Ruby is not a language you use very often? (I don?t use it/know it well) If that?s the case, i?d strongly suggest you pair with somebody that does.


bernard
2022-03-10 12:20
:wave: @matt.fellows should we expect the consumer to be deployable if the provider has not implemented the business logic for an endpoint which has been declared in an OAS document?

matt.fellows
2022-03-10 12:32
No. Is this in the bi-directional contract testing flow?

matt.fellows
2022-03-10 12:32
I?d expect to either a) not publish the OAS to Pactflow, or publish the OAS to Pactflow but b) fail the provider test (and send that failure notice to Pactflow)

matt.fellows
2022-03-10 12:33
b) would result in a compatible contract, but because the provider self-verification is failing, the `can-i-deploy` check would fail, because the provider doesn?t implement the OAS (so it?s not trustworthy)

matt.fellows
2022-03-10 12:34
or put another way - would you want to deploy the consumer if the business logic of the provider wasn?t there, but the provider code was compatible with the spec?

matt.fellows
2022-03-10 12:34
(I wouldn?t)

bernard
2022-03-10 12:46
Hi @matt.fellows yes it's bi-directional

bernard
2022-03-10 12:47
We've updated the OAS (by adding a new endpoint) and published it to PactFlow.

bernard
2022-03-10 12:48
But the provider didn't have a test and implementation of that endpoint.

bernard
2022-03-10 12:48
But the consumer was able to publish and it was compatible after writing an interaction and consumer test.

bernard
2022-03-10 12:50
How can we b) fail the provider test (and send that failure notice to Pactflow)?

bernard
2022-03-10 13:00
What can I do to not be able to deploy my consumer if the provider hasn't implemented the endpoint, but the provider has published an OAS which makes my consumer compatible?

bernard
2022-03-10 13:20
I can see in PactFlow that... Your Provider Contract Is Not Compatible With The Provider Codebase. And I don't want to the consumer to be able to deploy. What would I have to do differently to make that happen?

yousafn
2022-03-10 13:52
Awesome! Have got this on Lewis! :headphones: Congrats on getting started!

diva.pant1
2022-03-10 14:08
When I run rake spec I get error

diva.pant1
2022-03-10 14:57
rake pact:verify gives error

bernard
2022-03-10 15:50
:here: Is anyone available to have a chat about a Consumer Pact being deployable when the implementation for a Provider endpoint hasn't been implemented?

kenneth.krause
2022-03-10 16:41
has joined #general

yousafn
2022-03-10 17:55
Hi Bernard, Checks would be required on the provider sides ci workflow when using BDC, prior to uploading the OAS spec to Pactflow, these would ensure that an OAS published, is honourable by the provider codebase. The onus here, is on the providing team to ensure they have checks in place. You have the ability to upload your provider OAS specs on branches, and mark them as deployed when they reach a particular environment, which allows your provider to develop breaking features on a branch, and get validation feedback via can-i-deploy as to whether that contract would honour the consumers needs.

yousafn
2022-03-10 17:57
> What can I do to not be able to deploy my consumer if the provider hasn't implemented the endpoint, but the provider has published an OAS which makes my consumer compatible? provider verifies OAS spec against providing service prior to uploading pactflow contract. You are able to upload a result along with the provider verification which would give you feedback via the pactflow UI, that the provider codebase is not compatible with its OAS spec. Hope that helps @bernard

bernard
2022-03-10 17:58
Thanks @yousafn I'll look into that

caiquedpfc
2022-03-10 20:11
I?m also getting the same problem

matt.fellows
2022-03-10 21:00

matt.fellows
2022-03-10 21:00
Are you saying the consumer is passing `can-i-deploy` in this case?

matt.fellows
2022-03-10 22:13
You might be best prefixing them with `bundle exec ?`

matt.fellows
2022-03-10 22:13
I can?t say for sure, but looks like you?re using Ruby 3 there - maybe it?s not supported? (I?m not sure)

matt.fellows
2022-03-10 22:13
have you tried 2.x.x?

sergio.artero
2022-03-10 22:24
@matt.fellows do you mind to confirm this is the proper channel to ask for this type of support?

matt.fellows
2022-03-10 22:25
Might be best raising an issue on github itself with the specific details that?s causing the issue

sergio.artero
2022-03-10 22:29
Great, I opened https://github.com/pact-foundation/pact-ruby-cli/issues/43 a few days ago and thought it would be easier if I moved the conversation here. Reopened. Thanks for the prompt response.

bergner
2022-03-11 06:19
has joined #general

gotax80534
2022-03-11 06:55
has joined #general

diva.pant1
2022-03-11 08:21
Yes using ruby 3.1.0

josephwoodward
2022-03-11 09:37
@matt.fellows Would you be happy for me to create a PR to add support for `GivenWithParams`?

matt.fellows
2022-03-11 09:48
Sure thing! Alternatively you could look at using the beta which is going to be the next major release. I think the API is close enough to stable

mathias
2022-03-11 10:17
has joined #general

jtcsek
2022-03-11 13:02
has joined #general

bernard
2022-03-11 15:52
@matt.fellows yes the Consumer was passing `can-i-deploy`.

bernard
2022-03-11 16:05
Hi @matt.fellows and @yousafn firstly thanks for getting back to me. I think your feedback has resolved our issues. We were missing a step in the Provider workflow where the OAS has to be verified against the local API. Before running tests and attempting to publish.

yousafn
2022-03-11 16:20
Fabulous, pleased to help @bernard

joachim005
2022-03-14 08:16
has joined #general

alexstout009
2022-03-14 14:32
has joined #general

paul.richards
2022-03-14 14:38
has joined #general

akif.tahir
2022-03-14 15:00
has joined #general

lramos
2022-03-14 16:29
has joined #general

michael036
2022-03-14 18:31
has joined #general

lauren.coggin
2022-03-14 19:27
has joined #general

mkanika1811
2022-03-15 09:22
has joined #general

patrice.krakow
2022-03-15 09:46
Hello @bernard I am in for a chat :wink: When you wrote "Consumer Pact being deployable", strictly speaking, you do not deploy a Pact, right? You (only) deploy the "Consumer", correct? In a (nice) API-first approach, the Provider can indeed define/document an API endpoint (i.e. an interface) and even share it, *before* finishing (even starting) the implementation. Based on that definition/documentation, a Consumer could indeed start developing and testing, writing/generating a Pact file. Then, the critical part in your scenario is the _*Pact Verification*_. The Pact verification MUST (but you are asking for a SHOULD) done against the Provider implementation, that you don't have. Still, you could "analyze" the Pact and marked it as verified, but you CAN NOT change your mind afterward, once you say yes to a particular Pact file, you say *yes forever!* So, if you said "yes", then your implementation *MUST* follow the Pact file, that's the risk you have been taken by verifying without actually verifying. P.S. You can, of course, still change your mind, but then it MUST be the implementation of the "next version" of the API endpoint, you cannot change an existing version, even if the implementation was actually not "existing" :grin:

ian.pringle
2022-03-15 11:02
has joined #general

karl.wagner
2022-03-15 12:25
has joined #general

phongthornk
2022-03-15 18:26
Hello Folk, Is it possible to write a test on the 404 response? Test always fails, but pact file still genearte.

lewis.prescott079
2022-03-15 19:08
Yes in your test you can assert the expected response code. As long as the Pact verify and finalize is called this should work fine. The test shouldn't fail. As you are expecting a 404 response

lewis.prescott079
2022-03-15 19:11
Feel free to share a code example

matt.fellows
2022-03-15 23:59
Usually, the issue is that your HTTP client throws an exception when you receive a 4xx or 5xx response. So Pact is returning the expected status code, but your test throws an error. Whatever language you use, you will need to make sure you catch that exception first

matt.fellows
2022-03-15 23:59
if you have example code we could advise more

matt.fellows
2022-03-15 23:59
Best to ask that in the language specific channel though e.g. #pact-js

phongthornk
2022-03-16 03:21
@lewis.prescott079 @matt.fellows OK, Thanks for you both. I will check my code and let you know again. I think it make sense.

phongthornk
2022-03-16 03:27
Next question, I try to publish pact file to Pactflow but got 409 responses like this ```Client error: `PUT PATH_OF_PACT resulted in a `409 Conflict` response: This is the first time a pact has been published for "SsoUserService". The name "SsoUserService" is very similar to the (truncated...)```

matt.fellows
2022-03-16 03:29
this is a general pact broker thing. As you can see, you have published a contract where the names of two systems are very close to each other, and is likely to result in confusion. Double check to make sure!

matt.fellows
2022-03-16 03:29
docs are your friend (search 409 and you?ll get this article): https://docs.pact.io/pact_broker/advanced_topics/troubleshooting#409-when-publishing-a-pact

phongthornk
2022-03-16 03:38
Ahh, thanks. Let me check

chaitasi.patel988
2022-03-16 04:04
has joined #general

athaper
2022-03-16 05:38
Hey guys I had a question , pact is used to test the integration between 2 services or integration between UI and a service but is there any use case where we can use it to test one single API ? keeping the consumer and producer as the same API and testing different endpoints of that API , does it make sense or possible somehow ?

matt.fellows
2022-03-16 05:39
What exactly would you want Pact to do that other tools couldn?t do here?

matt.fellows
2022-03-16 05:40
e.g. a functional testing tool

athaper
2022-03-16 05:42
Yea like instead of testing the integration between 2 services could we test the different endpoints of a single service by keeping the consumer/producer as the same ? Currently what I?m aware of is pact is only or can only be used to test the integration between 2 services

matt.fellows
2022-03-16 06:18
> test the different endpoints of a single service by keeping the consumer/producer as the same ? I?m not sure what that would look like? If you only have a provider and no consumers, you could write a dummy client that exercises all of the endpoints and create a pact from it

athaper
2022-03-16 06:50
> you could write a dummy client that exercises all of the endpoints and create a pact from it yep that?s what I?m thinking but writing the code that exercises all of the endpoints in our service and the code that verifies the pact in the same service as well . will that be possible or if the pact can be used like this can it serve as an alternative for functional testing of a service ?

matt.fellows
2022-03-16 06:54
you can definitely run pact in that way, yes

matt.fellows
2022-03-16 06:54
I wouldn?t see it?s an alternative to functional testing in a general sense, but yes, in that context it would be possible to exercise it in ways that would be more maintainable and extend beyond a purely contract testing tool

athaper
2022-03-16 06:59
that clears my doubt , thank you Matt :raised_hands:

phongthornk
2022-03-16 08:23
I was already checking the code no exception in my test code. Not sure can I share the code here? or should go to share on #pact-php?

lewis.prescott079
2022-03-16 08:24
Yes share over there. I'm not too good with php myself

phongthornk
2022-03-16 08:28
One more question, If it throws an exception like this. How can I handle the expectation? Do Pact have any expectation support throw an exception?

lewis.prescott079
2022-03-16 08:31
You can handle exceptions in your tests usually https://backendtea.com/post/phpunit-exception-test/

alanbos
2022-03-16 09:07
`arrayContaining(X1, ..., Xi, ..., Xn)` as I understand it means "match if and only if the returned array contains at least one instance of each `Xi`" , and allows _other non-matching elements to appear in the returned array_. Is there a variant of this which says, _every_ element of the returned array *must* match either `X1` ... or `Xi` ... or `Xn`?

jose.iglesias
2022-03-16 09:23
has joined #general

phongthornk
2022-03-16 09:46
@lewis.prescott079 Thank you. I understand the problem now :slightly_smiling_face:

phongthornk
2022-03-16 09:47
clear

diva.pant1
2022-03-16 09:50
Can we use Pact testing for DSL?

matt.fellows
2022-03-16 10:08
No, because that is the "optional attributes" problem in disguise


phongthornk
2022-03-16 10:10
I see the new feature of Pact as a "https://pactflow.io/bi-directional-contract-testing/". I really need to know what is different between an old and a new feature.

matt.fellows
2022-03-16 10:11
For clarity, this is not a Pact feature. It's a Pactflow feature


alanbos
2022-03-16 10:15
Interesting - so as an example I ask for e.g. a list of contacts for a Person; I'm expecting either phone or email contacts so I want to assert that the returned list doesn't contain anything I can't handle (e.g. a fax contact). If the provider is enhanced to start returning fax contacts too, it doesn't feel like my contract will protect me against that breaking change.

matt.fellows
2022-03-16 10:19
It?s more the inverse that Pact is designed to protect in this case. The case you?re referring to is probably best left to the standard array matching, and the scenarios can be separated by provider states to ensure only each type of contact is tested

matt.fellows
2022-03-16 10:19
Pact does assume Postel?s law here ?be liberal with what you accept?

alegab0710
2022-03-16 10:20
has joined #general

matt.fellows
2022-03-16 10:20
i.e. if extra data comes back, you should ignore it. but this is probably an edge case of that principle

matt.fellows
2022-03-16 10:20
You can of course also test that specific scenario without Pact quite easily

alanbos
2022-03-16 10:44
Thanks Matt - I'm not sure the provider state approach would fly here since the consumer would by definition only be directing the provider to return types it knows about.

alanbos
2022-03-16 10:47
But I understand your argument, I think in the case of GraphQL queries the Postel approach would be to request something like: ``` contacts { __typename: always lets us know what this is ... on PhoneContact { ... } ... on EmailContact { ... }``` and if the provider always returns one of each type it supports arrayContaining will not fail.

bernard
2022-03-16 11:57
Hi @patrice.krakow thanks for getting back to me. That's right I only deploy the Consumer. In our API-first approach we would like the Consumer to be aware that an endpoint has not been implemented. We came to the resolution that the Provider's API should be verified by a tool like *https://dredd.org/en/latest/index.html* before allowing a pact to be published.

bernard
2022-03-16 11:58
Hi :wave: if my Provider is tagging an environment, why can't I see it when I run `broker list-environments`?

alegab0710
2022-03-16 12:25
Hi everyone! :wave:. Me and my collegue are doing an internship at a large regional IT-organisation and have been asked to work on a proof-of-concept project to see if Pact could be something that they could implement in their organisation for integration testing and deploy testing etc. Their system is a large system built on many jvm based components built with Maven and running with Mule. It uses AMQ message queues and they want us to test the functionality for testing their components both in pipeline and for integration with other components. I find it rather difficult to find good literature on Pact in these type of enviorments and mainly just for one provider - consumer testing with HTTP. D you guys have any tips or links for me to study and checkout for this purpoise? Thanks :smiley:

serghei.pogodin
2022-03-16 12:31
has joined #general

matt.fellows
2022-03-16 12:51
how are you tagging an environment? (just to confirm what we?re talking about here)

matt.fellows
2022-03-16 12:51
do you mean `pact-broker record-deployment` (which would record that an application has been deployed to an environment)

matt.fellows
2022-03-16 12:52
or do you mean via `--provider-version-tag` (or another provider tag)

matt.fellows
2022-03-16 12:52
if the latter, they aren?t environments - they are tags

matt.fellows
2022-03-16 12:52
tags != environments

matt.fellows
2022-03-16 12:57
I don?t think we have good async/message pact tutorials, you?re right


matt.fellows
2022-03-16 12:58
There are a number of examples here: https://docs.pactflow.io/docs/examples/




jeremy.vincent
2022-03-16 14:29
has joined #general

alegab0710
2022-03-16 15:47
Thank you @matt.fellows för the links! I will check these out!

1.g10squad
2022-03-16 16:01
has joined #general

patrice.krakow
2022-03-16 16:06
In our setup, we have a way to address the question of the implementation of an API endpoint... In our (home-made) API Management solution, we make a radical distinction between the API endpoints, being solely the interfaces, and their implementations. The API (endpoints) definitions are captured within OpenAPI documents, the implementations are classic "pieces of software", and we have the explicit link between the two being the _*authorization to implement*._ Most of the API Management solutions have a workflow for the _authorization to consume_, usually called _subscriptions_, we have an additional similar mechanism for the _authorization to implement_. A service/component/piece-of-software MUST have the _authorization to implement_ one or multiple API endpoints. This _authorization to implement_ is materialized by a signed JSON Web Token which is sent at run-time to our _"API Endpoint Discovery"_. In this manner, a running instance of a service/component/piece-of-software declares at run-time that it is implementing a particular set of API endpoints. That knowledge is used by the consumers who do not know in advance the physical address (internal DNS) of the service/component/piece-of-software implementing the API endpoint they want to call, but they query at run-time the _"API Endpoint Discovery"_. In your scenario, our _"API Endpoint Discovery"_ would also be able to answer the question: "Is there already a running instance implementing the API endpoint that is used by this (new) consumer I would like to deploy?" I don't know what kind of environment you have and if you could consider this kind of "architecture", but I would be happy to describe further what we have done and what we plan to do if it could help :wink:

alistair.c.kung
2022-03-16 18:44
has joined #general

adam.howard
2022-03-17 02:05
has joined #general

johnathan
2022-03-17 02:30
Welcome to the team @yousafn :raised_hands:

jonatan.jaworski
2022-03-17 02:32
has joined #general

lewis.greenway-jones
2022-03-17 08:52
has joined #general

pierre.gerard
2022-03-17 11:59
has joined #general

phongthornk
2022-03-17 13:56
Hello, I had a question. Pact standalone can run on alpine or not? I try to run it from pact-php server not start properly. when I try to run manually I got this error ```/var/www/vendor/pact-foundation/pact-php/pact/lib/ruby/bin/ruby: line 6: /var/www/vendor/pact-foundation/pact-php/pact/lib/ruby/bin.real/ruby: No such file or directory```

yousafn
2022-03-17 15:29
HI @phongthornk, Check out our official docs on the subject https://docs.pact.io/docker#alpine-linux and let us know how you get on. These examples below are a bit older but images I have previously built and used Here is an older one I did for node (https://github.com/YOU54F/pact-standalone-docker-slim/issues/11) and one I did for ruby alpine (https://github.com/YOU54F/pact-standalone-docker-slim/blob/master/ruby_base/Dockerfile)

pierre.gerard
2022-03-17 15:57
Hello All :pactflow-platypus-slack: ! I'm pretty new with pact and I'm looking for french speaking users to "build" a french pact community :slightly_smiling_face:

viswanathan.sarma
2022-03-17 22:39
has joined #general

phongthornk
2022-03-18 03:41
Thanks @yousafn Let me try and let you know :slightly_smiling_face:

phongthornk
2022-03-18 03:54
It works. Thank you so much @yousafn

phongthornk
2022-03-18 06:19
Hello, Does the Pact support testing with multiple Providers? Example like below: ```Frontend Service ====> Auth Service Frontend Service ====> User Service Frontend Service ====> Order Service``` All of the example services run together in the same environment. Is it possible to configure this?

matt.fellows
2022-03-18 06:21
yes

matt.fellows
2022-03-18 06:22
You just need to have a different provider name for each separate integration point

matt.fellows
2022-03-18 06:22
it will create 1 contract file per consumer <==> provider combination

matt.fellows
2022-03-18 06:22
each contract can have 1 or more _interactions_ in it

phongthornk
2022-03-18 06:23
Make sense. Thanks @matt.fellows

yousafn
2022-03-18 11:14
no problem @phongthornk, could you confirm the official docs image worked for you?

yousafn
2022-03-18 11:47
Hey Pierre, :pactflow-platypus-slack: This is very exciting, thanks for reposting this to general! I like the idea of regional Pact communities, especially under a think globally, act locally mantra. I'd love to think about how we could support you and others in getting this off the ground!

madhulika.mitra
2022-03-18 15:56
has joined #general

madhulika.mitra
2022-03-18 16:06
Hi Team. I need to add a request signature to my request before testing from provider side. While i was able to add couple of headers using CustomHeaders, how do i get the entire request so i can add signature and send it In java - @TargetRequestFilter is being used.. do we have something for c#?

matt.fellows
2022-03-18 21:50
Might be best asking in the #pact-net channel

phongthornk
2022-03-19 23:47
@yousafn I do not use the image. I just add the 3 line from your link https://docs.pact.io/docker#alpine-linux ``` && wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub \ && wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk \ && apk add glibc-2.29-r0.apk``` It works with this way

rupam.saha
2022-03-21 09:26
has joined #general

christian.jeppesen
2022-03-21 10:10
has joined #general

anand.kannan
2022-03-21 10:10
has joined #general

mikhail.yartsev
2022-03-21 10:10
has joined #general

phongthornk
2022-03-21 10:47
Hello @matt.fellows, I was trying to do the same as you mentioned before. But no option to set provider name in #pact-php

matt.fellows
2022-03-21 10:57
https://github.com/pact-foundation/pact-php#basic-consumer-usage `$config->setProvider(...)` sets the provider name

matt.fellows
2022-03-21 10:58
The provider is set on the *pact* configuration, not set on the *interaction*

phongthornk
2022-03-21 11:46
I follow with the way of phpunit.xml ===> see this from the pact-php `Keep in mind that both the test suite and the arguments array must be the same value.`

phongthornk
2022-03-21 11:47
As you mention in the code. I need to start the mock server manually and set the configuration depending on a test case, right? So I need some example for PHP

phongthornk
2022-03-21 11:48
However, start Mockserver by manually got slow response on test not sure why

phongthornk
2022-03-21 11:52
See this file https://github.com/pact-foundation/pact-php/blob/master/src/PhpPact/Consumer/Listener/PactTestListener.php If I need to start Mockserver manually, I will customize it to send pact files to Pactflow. Look like #pact-php support only config from env

matt.fellows
2022-03-21 12:12
Ah sorry I'm not familiar enough with Pact PHP to advise. But it must be possible, it's a very standard scenario.

matt.fellows
2022-03-21 12:12
Might need to raise an issue on the repo to get visibility for the maintainers

david.vancouvering
2022-03-21 16:16
Hey. This is becoming a real issue for us. Are there plans to address this?

bblechman
2022-03-21 16:36
has joined #general

bernard
2022-03-21 16:58
Hi, i'm running tests using Jest. ```beforeAll(() => mockProvider.setup()); afterEach(() => mockProvider.verify()); afterAll(() => mockProvider.finalize());``` And I'm seeing this error. The Jest tests are run inside a docker container. ```[2022-03-21 16:53:42.071 +0000] INFO (19 on b0e28777c48a): pact-node@10.17.2: Creating Pact Server with options: {"timeout":30000,"consumer":"studio-frontend-consumer","cors":false,"dir":"/app/pacts","host":"127.0.0.1","log":"/app/logs/pact.log","logLevel":"INFO","pactfileWriteMode":"overwrite","provider":"pactflow-example-provider-restassured","spec":2,"ssl":false,"pactFileWriteMode":"overwrite"} [2022-03-21 16:53:42.135 +0000] ERROR (19 on b0e28777c48a): pact-node@10.17.2: Pact Binary Error: /app/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.88.83/pact/lib/ruby/bin/ruby: line 6: /app/node_modules/@pact-foundation/pact-node/standalone/linux-x64-1.88.83/pact/lib/ruby/bin.real/ruby: No such file or directory [2022-03-21 16:53:42.135 +0000] WARN (19 on b0e28777c48a): pact-node@10.17.2: Pact exited with code 127. [2022-03-21 16:53:42.136 +0000] INFO (19 on b0e28777c48a): pact-node@10.17.2: Removing Pact process with PID: 47``` My previous error led me to install `bash` in the container. Any help??

matt.fellows
2022-03-21 19:35
Best to ask these specific questions in #pact-js going forward

matt.fellows
2022-03-21 19:35
assuming you?ve taken a look at the notes for docker: http://docs.pact.io/docker


phongthornk
2022-03-22 03:15
Yes, you're right. As I try to see issues on #pact-php I see many things hard to be complete on PHP to connect to Ruby. Firstly, I see the default Listener of the package no has any option to config per integration. I need to customize by myself. Sorry for bothering you @matt.fellows.

phongthornk
2022-03-22 03:16
However, thanks so much to support me :slightly_smiling_face:

phongthornk
2022-03-22 03:16
What's the language you hand on?

matt.fellows
2022-03-22 03:21
I help maintain JS and Golang

matt.fellows
2022-03-22 03:21
And other general things across the community

jeffrey2011998
2022-03-22 09:22
has joined #general

jeffrey2011998
2022-03-22 09:24
:wave: Hi everyone!

bernard
2022-03-22 09:31
Yes @matt.fellows, after reading those docs, I managed to fix it.

xavier.arque
2022-03-22 11:33
has joined #general

aubrey
2022-03-22 14:32
has joined #general

balazs
2022-03-22 15:51
has joined #general

seasharp37
2022-03-22 22:17
has joined #general

matt.fellows
2022-03-23 03:03
Hi David, I?ll raise it with the Pactflow team tomorrow for discussion

matt.fellows
2022-03-23 03:09
I?ve been thinking about this, and am not sure WIP pacts is the best approach. I was thinking one approach could be to treat each consumer+toggle as a separate contract and use the `record-deployment` feature to explictly select consumers deployed to an environment - in this case, that would represent a specific toggle

matt.fellows
2022-03-23 03:09
But that is bad for other reasons - for one, there will be a lot of applications making it hard to reason about

matt.fellows
2022-03-23 03:09
I think toggles might need to be supported as a first class concept

matt.fellows
2022-03-23 03:09
they might be another way though

david.vancouvering
2022-03-23 03:15
So you would treat each variation of a consumer as a different consumer? I guess it's a workaround but ideally I'd like the Pact model to reflect the domain, which is that the same consumer can have multiple variations. One form of variation is over time, which is represented as versions. The other is over space, represented as feature toggled/configured variations (it may not be just toggles, it could be experiments or customers choosing different features, which I see a lot in the enterprise space). It seems like actually both variations over time and variations over space are both _versions_. It means that you can actually have multiple versions _deployed_ simultaneously as well as _released_ simultaneously

david.vancouvering
2022-03-23 03:17
If you allow for multiple versions to be deployed to the same environment simultaneously via `record-deployment` and then have the verifications take that into account just as with releases, we'd have what we want

matt.fellows
2022-03-23 03:40
Yes, that is true and a good point

matt.fellows
2022-03-23 03:41
This might model more onto the `release` concept, originally conceived to support mobile use case (i.e. you can have multiple versions of an application released to market at any point at time)

david.vancouvering
2022-03-23 03:42
You might argue that the distinction between release and deploy starts getting a little fuzzy or even non-existent. Sorry, that's a tough thing to say when you put so much work into it.

matt.fellows
2022-03-23 03:42
yes

david.vancouvering
2022-03-23 03:43
We're still using tags because the JVM doesn't support deployments and releases. Based on my statement that feature toggles are different versions of the same consumer that can be deployed on the same environment at the same time, here's what I think could work. But I'm not sure if the current Pact libraries support this... ? When version a pacticipant, the version identifier includes the feature toggle name as well as the git hash ? When we verify a provider, we have to verify all versions of that provider with the same git hash (e.g. all active toggles) and publish each one as a separate verification ? When we run consumer tests, we have to run for all versions of the provider with the same git hash and publish each one separately. Assuming the test passes, we publish the pact and tag with the branch name. ? When we deploy a pacticipant to an environment, we tag _all versions that have the same git hash_, regardless of the feature toggle ? When we run can-i-deploy for a pacticipant to a given environment, we need to check _all_ versions tagged with that environment, not just the latest (not sure if we can do this. I don't see an `--all` option)

matt.fellows
2022-03-23 03:43
_actually, the language I used consulting was that a ?deployment? was when the code was shipped to an environment, and it was ?released? when made available to a customer (i.e. just a step)_

david.vancouvering
2022-03-23 03:44
I often say you deploy code and you release features (when you turn the toggle on)

david.vancouvering
2022-03-23 03:44
Which calls out that even if a version of an application supports a toggle, it's not released to an environment until the toggle is turned on

david.vancouvering
2022-03-23 03:45
You might even say that really `can-i-deploy` should be `can-i-release`

david.vancouvering
2022-03-23 03:45
And runs not when the code is deployed but when the toggle is getting turned on

david.vancouvering
2022-03-23 03:46
If you don't use feature toggles, then those two concepts happen simultaneously, but they are still separate concepts

david.vancouvering
2022-03-23 03:46
And of course, once a toggle is on, then every deploy has to continue to support that toggle's contract

matt.fellows
2022-03-23 03:47
yeah. I guess the challenge here is that the terms/language needs to work across concepts that have subtle variations (branches, toggles, ?). So it might be hard to put that genie back into the bottle.

david.vancouvering
2022-03-23 03:49
Yea, you discover your domain as you implement it, and of course things also evolve, but now you're stuck with a model that doesn't correctly represent the domain. That can create a mismatch that is hard to work with. It's a bummer.

david.vancouvering
2022-03-23 03:50
I can imagine first defining best practices working with what you've got, and then maybe building tooling that is backward-compatible with the existing system but better aligns with the domain. Not saying that's easy, just spitballing here

david.vancouvering
2022-03-23 03:52
For example I described a possible approach using tags above. I believe it needs more refinement, but let's say I get it working. I can imagine building scripts that layer over the Pact API that do what I want for feature toggles so each team doesn't have to handle all the tricky details. That's sort of what I meant.

matt.fellows
2022-03-23 03:53
BTW we?ll be picking up the feature branch/environments etc. work in the Pactflow backlog soon to drive implementation across the ecosystem. We kicked off some planning late last week for that. Just thinking out loud, I wonder if this would be a better approach than WIP for you. As you describe above, you simply tag all variations of your feature variations (versions) with a tag. On the provider side, you can take advantage of the `latest` https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors set to `false`. This would have the effect of always verifying _all_ versions with that tag. You would need to remove the tag from the version afterwards once undeployed, which is the messy bit. I think releases is probably going to be the better tool once you can take advantage of it. From that page: ? `latest`: true. Used in conjuction with the `tag` property. If a `tag` is specified, and `latest` is `true`, then the latest pact for each of the consumers with that tag will be returned. If a `tag` is specified and the latest flag is _not_ set to `true`, _all_ the pacts with the specified tag will be returned. (This might seem a bit weird, but it?s done this way to match the syntax used for the matrix query params. See https://docs.pact.io/selectors).

matt.fellows
2022-03-23 03:54
(I have to duck off to a meeting, but have popped a reminder in my calendar to discuss with the team tomorrow)

david.vancouvering
2022-03-23 03:54
ok duck away, talk more

david.vancouvering
2022-03-23 03:55
I was thinking something like what you describe. But, I don't want to tag an environment with a toggle until it's enabled. So I'd want to automate applying tags when I roll out toggles. Will play around with this and share what I learn when I learn it

saritacutinha
2022-03-23 07:09
has joined #general

rachelb
2022-03-23 10:16
has joined #general

shaheen
2022-03-23 23:11
has joined #general

shaheen
2022-03-24 00:16
Hi everyone, I have maybe a crazy question. I would like to overhaul our current integration testing system. Lets just say it is a publishing type system but interacts with http like System1 -> System 2 -> System 3 (system 1 takes input and publishes to system2), and some other external actor interacts with system 3 and we want to make sure those interactions are correct and the propagation from system 1 got to system 3. Right now its black box where we interact with system 1, wait a while, and then test and make sure system 3 responds with correct results. In my ideal world, we have scenario 1, it interacts with system1, knows what outputs system 1 should have when it interacts, and that is one test. We then take the exact output of that test and use it to test system 2 and so on. Right now when I look at bidirectional testing, it feels like it just makes sure the interfaces conform, but does not fully replace knowing if the output system 1 created is causing the right results in system 2. Is Pact maybe not the right tool for what I am trying to achieve (replace our end 2 end testing with service level tests) but trust that all the interactions that system1 generate cause the correct interactions in system2. Not sure if this is far too much info to get help on as well but looking for any guidance!

abubics
2022-03-24 00:35
Sounds like you're talking about 2 different kinds of testing, and they both have value in different ways. I don't think you can get same kind of confidence from only one, and you should keep both separate: ? Contract testing (consumer-driven) is still great value, and should give you high confidence in the individual interfaces. ? Functional (across several boundaries) will give you the final sanity check, making sure that expected state translates through all the layers. This doesn't need to be so exhaustive, if you have the foundational confidence from the other tests. I'd stay away from bi-directional, unless you need it as a starting point to reduce implementation time, but it will slow you down in different ways.

shaheen
2022-03-24 00:51
Ya, I agree, I feel like I am trying to make our functional tests better and I was seeing if pact could help. However, obviously its designed for contract level testing here. Thanks for feedback.

abubics
2022-03-24 01:09
Sounds like a good direction :slightly_smiling_face: The goal isn't to replace everything with contract tests, it's to reduce the overhead of testing by doing the right kinds of testing in each place.

david.vancouvering
2022-03-24 01:14
By the way, the eBay team is looking for guidance on how to work with feature toggles, so I am going to write something up. I realized, I should just write it up for PactFlow docs, and then point the eBay folks there. So expect another PR in the next few days :slightly_smiling_face:. I know it would be better to get one done at a time, but there is a lot of pull for feature toggle guidance... My guidance will be using tags, rather than deploys and releases, since we can't use those yet. Is that OK?

sentyaev
2022-03-24 12:36
has joined #general

altan.demirkiran
2022-03-24 14:06
has joined #general

jonathan.fortunati
2022-03-24 21:53
has joined #general

simon.dicola
2022-03-25 10:25
has joined #general

simon.dicola
2022-03-25 10:26
:wave: Hi everyone!

mrooschuz
2022-03-25 14:52
has joined #general

ashok.pathak
2022-03-25 15:17
has joined #general

rdanthuluri
2022-03-27 03:28
has joined #general

cudi.unal
2022-03-28 11:25
has joined #general

ashraf.anwar.iw
2022-03-28 13:12
has joined #general

b.costa
2022-03-28 13:15
has joined #general

mark.hopper
2022-03-28 14:53
has joined #general

ashraf.anwar
2022-03-28 15:08
has joined #general

damianruizdev
2022-03-28 18:44
has joined #general

damianruizdev
2022-03-28 18:47
Hey everyone, our company is currently trying to integrate Pact into our nx monorepo and we keep running into errors when trying to run the tests. Was curious if anyone has ever integrated Pact into an nx monorepo that uses angular, jest, and cypress. The initial error we're running into is jest and cypress types clashing when running the Pact test. Our monorepo is configured to support both jest/cypress and we have jest tests in other libs that run fine so not sure what about Pact is causing this behavior.

gibraltor999
2022-03-28 18:59
Hello, In one of our projects (React, NodeJS tech stack) we are using BFF (backend for front end, which in our case is Consumer) to speak to domain services (provider). Any tips on how can I write consumer driven tests for BFF queries?

yousafn
2022-03-28 19:31
Hey @gibraltor999, We often advise against traditional Pact contract testing for BFF's. see https://docs.pact.io/getting_started/what_is_pact_good_for#why-pact-may-not-be-the-best-tool-for-testing-pass-through-apis-like-bffs We think our new feature Bi-directional contract testing over at Pactflow might be more suitable for these pass-through layer use-cases, @matt.fellows wrote a blog here https://pactflow.io/blog/bi-directional-contracts/ and we discuss some of the use cases for BDCT https://docs.pactflow.io/docs/bi-directional-contract-testing#use-cases which although doesn't explicitly call out BFF's. might help provide some food for thought

yousafn
2022-03-28 19:32
Hi @damianruizdev, I would recommend posting in your language specific channel #pact-js for best visibility by those in the JS ecosystem :thumbsup:

matt.fellows
2022-03-28 21:53
I wouldn?t say it?s not applicable to BFFs, but depending on how much of a pass through it is, it might not be ideal. If the BFF has actual logic and is not just a proxy, CDC should be OK

david.vancouvering
2022-03-29 02:16
Making good progress on this doc. One area where I feel my understanding is a bit fuzzy is what happens when you publish a new version of a pact and kick off a webhook to run provider verification. I get how you can indicate which pact version needs to be verified. But how do you know what provider version to use when running the verification. We clearly don't want to run verification for *all* provider versions. So which ones are we supposed to run verification for? Let's say we deploy a provider to staging, preprod and prod. Should we find out what version is active for each of those environments, check out that version, and run verification? Now let's add feature toggles onto this. Now staging, preprod and prod will have *multiple* provider versions. So instead of running three tests we run six or nine or twelve or... Am I missing something? Thanks!

david.vancouvering
2022-03-29 02:40
I published an initial draft of a doc PR for feature toggles. Feedback much appreciated! Still need to figure out the provider workflow, so that's a `TODO` but wanted your feedback on the rest. https://github.com/pact-foundation/docs.pact.io/pull/133/

matthew.churcher
2022-03-29 08:48
has joined #general

gibraltor999
2022-03-29 11:16
Our BFF is acting like a proxy.. just gets the response from domain service and wrapping it into its own response model..

matt.fellows
2022-03-29 11:17
hmm that?s tricky. Can?t just ignore it, because the shapes are different

matthew.churcher
2022-03-29 13:43
oops wrong room

ben.brugman
2022-03-29 14:32
has joined #general

matthew.churcher
2022-03-29 15:00
I'm having trouble with the bi-direction coding kata.. `Step5 - npm run deploy` > `No environment found with name 'production'. Available options: <none found>`

yousafn
2022-03-29 15:23
Hi @matthew.churcher, Have you just created a Pactflow broker, or have you had one a while? You can create environments via the Pactflow UI https://docs.pactflow.io/docs/user-interface/settings/environments/ I saw a similar issue with an Broker instance I have owned for many years now, when I first came to run the workshops. noted https://github.com/pactflow/example-consumer/issues/31 in an issue.

matthew.churcher
2022-03-29 16:03
I don't appear to be able to create environments via the ui or api.. may be that's the problem :thinking_face: API returns environment already exists but they don't ... :scream_cat:

matthew.churcher
2022-03-29 16:07
i think it's permissions, i signed in using sso and ended up with fewer rights

hassan.shaikley
2022-03-29 16:14
has joined #general

matt.fellows
2022-03-30 07:05
Sounds like it Matthew. I'll make a note to update the docs for minimum role/permissions

oakkub.1995
2022-03-30 07:10
has joined #general

oakkub.1995
2022-03-30 10:26
Hello, I?m thinking of implementing pact tests on mobile platform both Android and iOS with the same provider. Because the pact files from both platform will look the same or similar, whenever pact files are published or updated, I want the provider to verify the pact files for the specific platform only, For example, If pact files are published from iOS, then the provider should only verify pact files from iOS only. I?m thinking of using different `tag` for both platform for example `master_android` or `master_ios` to differentiate which pact file belong to which platform and I can send the tag via the webhook to the provider. For the provider CI scenario, which will run all pact files, I would have to specify tags for both platform as well `master_android` and `master_ios` I?m not sure if `tag` is ideal for this scenario or not, as I understand they are use for segregate the environment like `master`, `feature_a` for example. Any suggestions on this topic? Thank you! :bow:

matthew.churcher
2022-03-30 14:55
Thanks, I did successfully complete the workshop. I left a couple of snags in github but overall the tutorial was very good.

hiqbal
2022-03-30 15:16
has joined #general

sstenhouse
2022-03-30 15:16
has joined #general

bmeyres
2022-03-30 17:37
has joined #general

alejandro.velez
2022-03-30 18:42
has joined #general

eddie
2022-03-30 19:23
On the _consumer_ side, will pact tell you about a missing test? Eg if you're already have a test for `GET /foo` returning a 200 OK, but the Open API spec on the provider side indicates that `GET /foo` can also return a 400 status code (and no corresponding test exists on the client side) will pact somehow notify you?

brendan.j.donegan
2022-03-30 19:31
~Not if you're using the traditional approach~ Sorry, misunderstood the question. You're asking about bi-directional contracts, right?

eddie
2022-03-30 19:35
I'm not sure what I'm asking about, I'm new to pact :nerd_face:

eddie
2022-03-30 19:37
If bi-directional contracts might help me, please let me know

brendan.j.donegan
2022-03-30 19:38
Bi-directional contracts would be where the provider uploads an OAS spec as it's side of the contract

brendan.j.donegan
2022-03-30 19:39
Traditionally the consumer defines the contract and the providers job is just to verify that it's met

eddie
2022-03-30 19:42
How does the consumer verify the providers contract? What if it doesn't use all endpoints of the provider?

brendan.j.donegan
2022-03-30 20:03
By creating its own version of the contract based on what it uses and then the broker verifies do these match

justin
2022-03-30 20:07
has joined #general

eddie
2022-03-30 23:36
I've had a bit of a read up on BDCT - Let's say the consumer only has a single test for `GET /foo` and in that test, the provider is assumed to respond with a `200` with the body 'x'. The consumer uploads the contract based on that single scenario. The provider uploads it's OAS which says that `GET /foo` can respond in two ways: ? With `200` and body 'x' ? With `400` and body 'y' *Will the the https://docs.pactflow.io/docs/bi-directional-contract-testing/compatibility-checks#contract-incompatibility-messages (run by PactFlow) alert us in this case?* What if the response bodies are compatible but only the status codes differ? As the development team maintaining the _consumer_, in this scenario we want to be told "Hey! You need to handle the case where the provider gives you a 400 back as well!". *NB*: This illustrates (what in my eyes is) a major shortcoming of the regular (CDCT) contract testing: ? As the team developing the consumer, you need to remember to look at the OAS for the provider and make sure you _exhaustively_ handle the status codes + respond body shapes it could return ? If the provider is updated to return new status codes / response bodies, that is a breaking change for the consumer. *Yet the consumer will have no way of knowing about it & the team developing the provider won't know that they are potentially breaking things for their consumers!* :warning: @brendan.j.donegan what are your thoughts on this?


leo.adriano1994
2022-03-31 00:00
has joined #general

matt.fellows
2022-03-31 01:14
Awesome, thanks!

bethskurrie
2022-03-31 03:40
Well thought out @patrice.krakow

bethskurrie
2022-03-31 03:43
@david.vancouvering sorry, I've only just seen this thread and it looks like Matt has answered a lot of you questions. What is still outstanding that I can help with?

bethskurrie
2022-03-31 03:44
> But how do you know what provider version to use when running the verification. We clearly don't want to run verification for *all* provider versions. So which ones are we supposed to run verification for? if you use the new webhook, it chooses the versions for you.

david.vancouvering
2022-03-31 03:44
The new webhook - do tell? I wasn't aware of a new webhook

bethskurrie
2022-03-31 03:44
it verifies against the main branch and all currently deployed/released versions.


bethskurrie
2022-03-31 03:44
well "new" last year

bethskurrie
2022-03-31 03:45
> Should we find out what version is active for each of those environments, check out that version, and run verification? yes, it does exactly that

bethskurrie
2022-03-31 03:45
de-duplicated

david.vancouvering
2022-03-31 03:45
Well, the challenge is not finding which pacts to verify against. The challenge is you have to actually build, start up and run different versions of the provider, one for each version that is deployed or released

bethskurrie
2022-03-31 03:45
yup

bethskurrie
2022-03-31 03:45
it kicks off a build for each one

david.vancouvering
2022-03-31 03:45
Ah...

bethskurrie
2022-03-31 03:46
with the git sha of each provider.

david.vancouvering
2022-03-31 03:46
I have to run, my son is ready to watch TV with me, but I'll take a look thanks!

bethskurrie
2022-03-31 03:46
:thumbsup::skin-tone-3:

bethskurrie
2022-03-31 03:46
there are still some improvments to be made to that workflow, but it's a big incremement to what we had before.

hitesh.patadia
2022-03-31 04:27
has joined #general

matt.cockayne
2022-03-31 11:02
has joined #general

jimmy
2022-03-31 15:39
has joined #general

bret.mcclory538
2022-04-01 01:10
has joined #general

michael.d
2022-04-01 04:40
has joined #general

yash.deole
2022-04-01 07:07
has joined #general

alan.alie
2022-04-01 08:10
has joined #general

ricardo.cruz
2022-04-01 11:54
has joined #general

thomas.fisher
2022-04-01 12:21
Hi, someone at my org would like to join this Slack community - how can I invite them?

lauren.corderoy
2022-04-01 12:24
has joined #general

jiayao.xu
2022-04-01 12:24
has joined #general

thomas.fisher
2022-04-01 12:24
sorted :thumbsup:

shiva.velde0413
2022-04-01 14:44
has joined #general

shiva.velde0413
2022-04-01 14:47
:wave: Hi everyone!

shiva.velde0413
2022-04-01 14:52
do we have any blog/tutorial that teaches us on contract testing with PACT MQ?

shiva.velde0413
2022-04-01 14:52
please suggest me if any leads

brendan.j.donegan
2022-04-01 19:53
My 2 cents on this - it's really up the consumer to *tell* the provider what it cares about, regardless of CDCT or BDCT being used. So if the consumer has code that cares about a 400 being returned then it should have a test for that scenario

matt.fellows
2022-04-01 22:07
Search message pact in the docs

matt.fellows
2022-04-01 22:08
Also see examples in howtolearn

2022-04-01 22:08
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-04-01 22:08
We also have an AMA on it (see docs site for those)

matt.fellows
2022-04-01 22:08

eddie
2022-04-01 22:36
Thanks Brendan. I'm not sure I agree however - while I get that contract testing isn't a replacement for out-of-band communications between implementing teams, assuming the possible 400 response is something the provider team have recently added to their API, the consumer team "don't know what they don't know" - they don't know there *is* a 400 status code that they should be interested in. What I'm getting at here is this is a case where we're *reliant* on that out of band communication happening.

npc1222
2022-04-04 04:37
has joined #general

npc1222
2022-04-04 04:39
Hi everyone, just a question is this possible to generate open api based on pact contract? If so, could someone share me a link to find how does it work?

matt.fellows
2022-04-04 04:40
Hi Allen, I believe there might be converters somewhere

matt.fellows
2022-04-04 04:40
what are you trying to do?

npc1222
2022-04-04 04:43
Yep. I try to use pact to generate open api and then generate types for client side such as TS? Does this make sense? Please let me know if this is too crazy idea

matt.fellows
2022-04-04 04:46
No this doesn?t make sense at all to me, sorry :slightly_smiling_face:

matt.fellows
2022-04-04 04:47
The workflow would be: 1. Client generates pact file (which requires a working API client) 2. Convert Pact to an OAS 3. Generate API Client from OAS you can see how this is nonsensical

npc1222
2022-04-04 04:49
cos i know 3 is absolutely doable

npc1222
2022-04-04 04:51
but I try to avoid to manually create both OAS and pact testing file. I feel like somehow they?re kind of duplication. My understanding is that OAS is abstract and pact testing file is more like a concrete example of OAS.

matt.fellows
2022-04-04 04:51
yes, but if you already have a pact file, then you already have a working client. So why do 2 and 3 if you already have one?

npc1222
2022-04-04 04:54
Right. If you notice, API Client is manually typed as well without 2 and 3. But I hope I can get an auto-generated API Client.

matt.fellows
2022-04-04 04:56
So it?s up to you if you want to have a typed API client generated from an OAS

matt.fellows
2022-04-04 04:56
you might like to read https://pactflow.io/blog/schemas-are-not-contracts/ for the downsides of this approach, from a contract testing perspective

npc1222
2022-04-04 04:57
will do. Many thanks

npc1222
2022-04-04 05:02
Hi @matt.fellows, By looking at this, what do you mean by `pack + open api` ? just wondering where i can find more details?


matt.fellows
2022-04-04 07:17
Yes, the core idea is identical. We wrap up that idea (and currently, even some of their tooling) into a unified workflow. so you can do it with Pact or future contract types (e.g. protobufs, graphql etc.)

arthur
2022-04-04 14:28
has joined #general

agastiya.mohammad
2022-04-05 01:19
has joined #general

paul.stapleton
2022-04-05 07:33
has joined #general

iurisoares1012
2022-04-05 09:53
has joined #general

gocool9996
2022-04-05 10:04
has joined #general

npc1222
2022-04-05 13:47
nice work

simrat.sidhu
2022-04-05 16:07
has joined #general

gabriel.brazao
2022-04-05 17:42
has joined #general

jhonataok01
2022-04-05 17:43
has joined #general

gabriel.brazao
2022-04-05 17:47
Hello everyone, my team is currently working on PoC to evaluate the usage of the PactFlow in our APIs. We have a lot of questions that the documentation itself its not very clear how to implement. How can we find some support for this tool?

yousafn
2022-04-05 17:53
Hey @gabriel.brazao, Is there anywhere in particular you have got stuck. We have several code demos in multiple languages - https://docs.pactflow.io/docs/examples and the Pactflow university where you can see the core principles in actions https://docs.pactflow.io/docs/tutorials Most of the language implementation repositories have their own examples as well. If you are struggling with a particular question, feel free to get your team-mates to sign up here and ask any questions and I am sure the community will be able to help. If there are particular areas, that we can improve the documentation, we would be open to feedback and change :thumbsup:


gabriel.brazao
2022-04-05 17:58
@jhonataok01 @ricardo.cruz

andre.mariano
2022-04-05 19:10
has joined #general

alex.zuliqiaer
2022-04-05 20:31
has joined #general

lflores
2022-04-05 20:33
has joined #general

keoma4
2022-04-05 21:17
has joined #general

david.vancouvering
2022-04-05 21:30
Hey, all. One of the complaints I am hearing from teams looking at Pact is the amount of work it takes to both create and maintain all the interaction specifications that are included in writing the consumer tests, as well as the work to create and maintain the mocks used by the provider verification tests. We had one team who just didn't have the time to fix the contract tests due to failures when the contract changes, and instead just stopped running the contract tests. I'm curious, have others encountered this challenge? How have you addressed this? Thanks!

erick.belf
2022-04-05 21:46
has joined #general

erick.belf
2022-04-05 21:50
:wave: Hi everyone! I have a question about how pact would work with SDKs, I have a couple of routes that call different services, and I would like to mock somehow these services instead of calling the real server in order to make my provider pass the verification, is there a particular channel where I can use to ask this question or I can put it here so we can discuss it in depth?


erick.belf
2022-04-05 22:13
Perfect! i will have a look at it, thanks!

matt.fellows
2022-04-05 22:47
Hello everyone :wave: Today, Beth, Ron and I have some exciting news to share with you. Pactflow has been acquired by https://smartbear.com/, a leading provider of software development and quality tools. We will join their API Developer Platform, helping to solve the complex challenges of testing microservices and API integrations that companies are facing as they accelerate cloud-native application development and digital initiatives. We care so much for OSS and are so pleased that SmartBear has a strong and https://smartbear.com/product/free/?as proven through the support and scale of https://cucumber.io/ and https://swagger.io/. Through our partnership, we will be able to take contract testing to new heights and help deliver key milestones in Pact?s OSS roadmap. We wanted to take the opportunity to thank you for your dedication and support. Pactflow is not just a SaaS product built by our immediate team but a community of individuals who?ve brought us to this point today. We?ve shared many milestones together and we look forward to sharing many more. Read more on our https://pactflow.io/blog/pactflow-joins-the-smartbear-family/.

aforeman
2022-04-05 22:50
So exciting! :bananadance:

abubics
2022-04-05 23:23
I tend to take an aggressive stance on that attitude, I rarely see the point in good faith . . . like, people are saying they're too busy to make sure their software works properly? From a more constructive perspective, I'd want to know where they get their confidence from :slightly_smiling_face: Are there other tests that cover things enough that they don't see the contracts as high-value? Or are there few tests, and things have been manually tested in a rush? Or something else? Also, where is the time pressure coming from? E.g. if the devs had more time would they be happy to write the tests, or is it just an excuse to avoid (perceived) boring/unproductive work?

abubics
2022-04-05 23:24
If the refactoring burden is genuinely huge, I also wonder if the balance of coverage is wrong. Conversely, if there are many many edge cases to cover, the tests are surely necessary, because people won't remember to manually test them all.

abubics
2022-04-05 23:25
Also interested in which team(s) didn't want to maintain stuff: consumer-side or provider-side (or the same team is doing both sides?)?

przemek.sech296
2022-04-06 03:37
Congrats on joining forces with SmartBear :clap:

michaele
2022-04-06 03:40
has joined #general

bethskurrie
2022-04-06 06:04
Andras makes good points (as always). We do hear that provider state maintenance is one of the biggest challenges, and it's one of the reasons we recently released a feature called bi-directional contract testing which does help mitigate the provider state issue https://pactflow.io/blog/introducing-bi-directional-contract-testing/

brendan.j.donegan
2022-04-06 07:25
Oh congrats! Any plan to share any info on how this will impact plans going forward?

matt.fellows
2022-04-06 07:39
We?ll definitely continue to be as open as we can about roadmaps etc.

matt.fellows
2022-04-06 07:39
At this stage, nothing has changed regarding vision and immediate priorities (as far as the Pactflow team goes, that is)

matt.fellows
2022-04-06 07:41
On the OSS roadmap, we?re still: 1. Working on the plugin framework (core is :white_check_mark: ) and releasing gRPC/Protobufs 2. Supporting branches/releases/environments in key languages 3. Getting v3 and the rust core into the key languages See the Pactflow focus/roadmap here: https://github.com/pactflow/roadmap

francislainy.campos
2022-04-06 08:08
That?s awesome news, Matt. Congratulations. :clap::slightly_smiling_face:

guillaume.camus
2022-04-06 12:47
has joined #general

guillaume.camus
2022-04-06 12:48
:wave: Welcome!

alejandro.pena
2022-04-06 13:24
Congratulations! That?s a huge and exciting step :slightly_smiling_face:

danielglazer123
2022-04-06 19:06
has joined #general

ashish.goyal
2022-04-06 23:14
has joined #general

dawoud.sheraz
2022-04-07 04:56
Congratulations. This initiative truly have come a long way, with many more achievements to be done on this new journey. Kudos to the team.

pennellbeth
2022-04-07 08:04
has joined #general

giuseppe.salvatore
2022-04-07 08:05
Hi guys... trying to join this: Webinar: Using Cypress and Postman for Contract Testing

giuseppe.salvatore
2022-04-07 08:06
Looks like it's a zoom meeting but it's not started yet, according to the invite you should have started 5 mins ago. (9:00AM GMT)

giuseppe.salvatore
2022-04-07 08:06
has anyone got any updates?

giuseppe.salvatore
2022-04-07 08:07
ok just managed to join... :tada::tada::tada::tada:

aforeman
2022-04-07 08:31
Hey @giuseppe.salvatore - please excuse the late start!

aforeman
2022-04-07 08:31
Glad to have you join us :slightly_smiling_face:

dominic.gara
2022-04-07 08:57
has joined #general

ivan.cheung
2022-04-07 08:58
has joined #general

omrieyal
2022-04-07 08:58
has joined #general

drakulavich
2022-04-07 08:58
has joined #general

drakulavich
2022-04-07 09:00
:wave: Hi everyone!

jonoar22
2022-04-07 09:06
has joined #general

josh.king
2022-04-07 09:06
has joined #general

giuseppe.salvatore
2022-04-07 09:27
No worries at all :+1:

pitas01_lope
2022-04-07 09:35
has joined #general

rarestomos
2022-04-07 09:40
has joined #general

shuba.paripoornam
2022-04-07 09:59
has joined #general

shivam.kumar
2022-04-07 11:00
has joined #general

will.robinson
2022-04-07 13:25
In our pactflow broker we are having an issue where we cannot scroll through anything - has anyone else experienced this?

dgupta2
2022-04-07 13:26
has joined #general

matt.fellows
2022-04-07 13:27
I can take a quick look now if you like?

matt.fellows
2022-04-07 13:28
Can you please try temporarily disabling your banner?

will.robinson
2022-04-07 13:28
Are you free to jump on a call for 5 mins?https://meet.google.com/vbr-yeqz-rtd

abraham.gonzalez93
2022-04-07 15:13
Hi, quick question here. I am currently using the pact-broker in my company but we are facing a problem. Each time that we are implementing a new API, we are including the verification test (python) before the pacts are uploaded so the provider doesn?t exist in the broker yet, so the ruby verifier is failing because it?s receiving a 404 from the broker, is there any argument in the verifier to skip the error when the provider does not exists?

yousafn
2022-04-07 17:14
Hey all, Would just love to give a MASSIVE shoutout to @david.vancouvering, who submitted an incredible 4 substantial PR's for our docs site bringing our guide to Pact Nirvana up to date. You can view it https://docs.pact.io/pact_nirvana We would appreciate any comments, feedback or even better submissions, after all it's your tool, we are just the custodians. Why not head over to our #documentation channel, where you can find out more about the contributions that made this happen, and some more for review Thank you so much @david.vancouvering :thank_you: :pactflow-platypus-slack: :pray::yellow_heart:

david.vancouvering
2022-04-07 17:49
Thanks. In my case it's maintaining the expectations defined in the consumer tests that is a huge burden. And as I have been thinking about this more, if you have a huge contract that is difficult to maintain, the underlying problem is actually that the API (and likely the underlying service) is poorly designed - a big surface area indicates a service that has poor cohesion and likely high coupling. I am now asking myself, how much time do I want to spend easing the burden of you having to work with such an API, when the right way to solve this problem is to refactor the API and/or the service.

david.vancouvering
2022-04-07 17:50
That said, it is a lot of boilerplate work to define your expected interactions in the consumer tests. I am working on a tool that can listen to live traffic, record the interactions, and then generate a starting set of expected interactions code. You can then go in and tweak the code, rather than having to write it all by hand. Does that sound useful/interesting?

david.vancouvering
2022-04-07 17:51
The bi-directional contracts are great for provider state. We need something for the consumer tests

david.vancouvering
2022-04-07 17:54
This code could also be used to publish an initial contract that is likely way too strict and brittle, and then over time could be made more reasonable as you address unnecessary failures in the contract (like an exact match failing that does not need to be an exact match)

david.vancouvering
2022-04-07 17:55
This could also bootstrap some stubs for you - you publish this as an initial contract, and now your UI tests and/or your verification tests could use these stubs when interacting with downstream dependencies.

david.vancouvering
2022-04-07 17:55
These are all just ideas, would love your thoughts

david.vancouvering
2022-04-07 17:56
@abubics I wasn't sure what you meant by this can you explain? What is "balance of coverage" in this context? > If the refactoring burden is genuinely huge, I also wonder if the balance of coverage is wrong.

matt.fellows
2022-04-07 21:17
:taco: for @david.vancouvering

david.vancouvering
2022-04-07 21:39
Yum, tacos

bethskurrie
2022-04-07 22:20
> And as I have been thinking about this more, if you have a huge contract that is difficult to maintain, the underlying problem is actually that the API (and likely the underlying service) is poorly designed - a big surface area indicates a service that has poor cohesion and likely high coupling. That is such a valid point. When tests are hard it's sending you a message that using it is likely also hard.

bethskurrie
2022-04-07 22:22
> This code could also be used to publish an initial contract that is likely way too strict and brittle, Yes, it's very easy to make overly specific pacts. I rant about this at great length in some of my "how to do the consumer side" materials. eg. https://docs.pact.io/consumer#only-make-assertions-about-things-that-will-affect-the-consumer-if-they-change https://docs.pact.io/consumer#choose-the-right-type-of-matching-for-the-situation and the video in https://docs.pact.io/consumer#watch-a-video-writing-good-consumer-tests

bethskurrie
2022-04-07 22:26
> I am working on a tool that can listen to live traffic, record the interactions, and then generate a starting set of expected interactions code. You can then go in and tweak the code, rather than having to write it all by hand. > > Does that sound useful/interesting? Yes - we've long talked about being able to generate pact tests from a set of interactions, but we've always had too many other things to do first. The key is that we want to generate test code, not the contract itself. I'm not 100% certain how much "wheat" will come out of such a generation, and how much "chaff" though. It's absolutely worth the experiment though, and would be such a big help introducing contract testing to large existing systems if it ended up working as we'd hope.

david.vancouvering
2022-04-07 22:48
Thanks, Beth. I am working on an experiment. I was doing it in Python using https://github.com/joshuasv/jinja2 as a templating language to create templates for various target languages. If you feel another language would be a better fit, let me know. I have just gotten started so no great loss if I go to another language (although I don't know Rust so that could take me some time to pick up). I am using WireMock as v1, but that is generally limited to environments where you can configure your client to send http to Wiremock. Setting up Wiremock to be an HTTPS person-in-the-middle is tricky. You generally need to use an actual HTTP/HTTPS proxy recorder. I know this could be of general use to the community, so if there is a process you like to use to make sure it gets visibility, input and maybe cross-contribution, please let me know how I might do that. On my side I need to see what eBay requires of me before I contribute work to open source.

pankajarora512
2022-04-07 22:50
has joined #general

aruncontacts
2022-04-07 22:54
has joined #general

bethskurrie
2022-04-07 23:01
Sounds great!

david.vancouvering
2022-04-07 23:01
:thumbsup:

david.vancouvering
2022-04-07 23:01
Python ok?

bethskurrie
2022-04-07 23:02
Yeah, I reckon.

david.vancouvering
2022-04-07 23:02
k

bethskurrie
2022-04-07 23:03
We don't have any formal process yet, but getting some shape around how to contribute pact related tools is something that is right in the job description for @yousafn.

david.vancouvering
2022-04-07 23:04
OK. I'll work on it in my internal repo for now, and will coordinate with @yousafn

bethskurrie
2022-04-07 23:04
I reckon, get a POC going, see how you find it, then if you think it's worth keeping on going, write up something and/or present to an audience who might like to be involved with contributing or testing, and then see where we go from there.

bethskurrie
2022-04-07 23:05
If we reckon it's a goer, we can work out a plan to make it an "official pact foundation" resource.

david.vancouvering
2022-04-07 23:06
ok sounds good. BTW, the only place I've heard "I reckon" is from farmers in the American West and now, apparently, Auzzies :slightly_smiling_face:

bethskurrie
2022-04-07 23:06
HA!

bethskurrie
2022-04-07 23:06
it is very american isn't it.

david.vancouvering
2022-04-07 23:06
Yes ma'am, I reckon it is

bethskurrie
2022-04-07 23:06
I don't think anyone would think it out of place in australian slang though. we've picked up so much from the US.

bethskurrie
2022-04-07 23:07
except when I hear it in my head in a US accent, it's more like "ah reahcahn"

bethskurrie
2022-04-07 23:07
in australia it's more "oi reckn"

david.vancouvering
2022-04-07 23:08
Ah I see, I thought maybe it had a shared ancestor from English that went to both American and Australia. But I guess it could have just come from movies

david.vancouvering
2022-04-07 23:08
Nope, here it's also "reckn"

bethskurrie
2022-04-07 23:25
Australia has so much american content, we're very familiar with any lingo that makes it to a screen. Not so much the other way though! Apparently we can be quite hard to understand :laughing:

bethskurrie
2022-04-07 23:26
Yousaf is just being introduced to our Australian passion for abbreviating things and whacking an "o" on the end. eg. arvo (afternoon)

mira.kim
2022-04-07 23:59
has joined #general

abubics
2022-04-08 01:33
Not sure how relevant it is anymore, but re: > I wasn't sure what you meant by this can you explain? What is "balance of coverage" in this context? >> If the refactoring burden is genuinely huge, I also wonder if the balance of coverage is wrong. You've both kinda covered it with "contract that is likely way too strict and brittle" and "Yes, it's very easy to make overly specific pacts". Sometimes people push too much stuff into Pact (so some testing should move to other areas of the pyramid), or have too many specific interactions that could be generalised a bit.

david.vancouvering
2022-04-08 02:07
Got it thanks

alphonse.bendt
2022-04-08 11:44
has joined #general

wim.dupont
2022-04-08 11:49
has joined #general

wilsonmar
2022-04-08 13:41
has joined #general

henit.laxmicant
2022-04-08 14:19
has joined #general

yousafn
2022-04-08 15:29
How do everyone, I recently did my first ever podcast with our good friend and community champion @lewis.prescott079 , it's just been released and you can check it out https://www.pactman.co.uk/contract-testing-podcast :headphones: He has also been busy putting pen to paper, and has published a new https://www.pactman.co.uk/post/end-to-end-testing-in-microservices-with-api-contracts post :pencil: In other news, we have just published some videos and material on how you can use different testing tools such as Cypress, Postman and more can play nice with Pact. You can check out the details in this https://pact-foundation.slack.com/archives/CLS16AVEE/p1649421874037749 Enjoy happy deployments on a Friday, because you are all contract testing whizz's and have an awesome weekend!:the_horns:

mateustalles
2022-04-08 17:35
has joined #general

lewis.prescott079
2022-04-09 07:19
Thanks @yousafn

artur
2022-04-11 07:38
I'm working with pending pacts. I have two provider-versions one where the pact is pending and one where its not. But as soon the pact is verifies with one provider the running the tests on the other does allow it to stay "pending" Does the pending state not filter by provider-versions?

nathan.deamer
2022-04-11 09:17
Has anyone used CircleCI with can-i-deploy for short lived branched? As per: https://docs.pact.io/pact_nirvana/step_6#add-can-i-deploy-to-consumer-pr-pipeline I need to pass in the pact url for the contract that has changed (or I could use the consumerVersionSelector?)

bioflash1
2022-04-11 09:21
has joined #general

bioflash1
2022-04-11 09:57
Hello everyone! We currently have the problem that we have different providers test classes (for on one contract) located in different modules and therefore in different jvm's when running the tests. Therefore the provider sdk has no way of knowing when all interactions of the contract were validated and therefore never ends up publishing to the pact broker. Is there any existing solution to go about this?

matt.fellows
2022-04-11 10:32
I?d suggest asking this in #pact-jvm

bioflash1
2022-04-11 10:52
thx Matt, I repost it there :slightly_smiling_face:

stambolaolya
2022-04-11 13:20
has joined #general

tomknee1
2022-04-11 13:34
Hi there, Im just reading up on https://docs.pact.io/pact_nirvana/step_5 and am a little confused, where it says ``` Configure your consumer build to run the Pact tests and publish its pact to the Broker as part of its main build (consult the documentation for your chosen language). Consumer Pact tests typically run after the unit tests, and before deploying to a test environment.``` If I have unit tests and pact tests etc running on every PR build, on different feature or task branches (e.g. `feature/PACT-101-do-something-cool`), should I publish it to pact broker as part of this PR build, using commit sha and branch (e.g. HEAD), or do I only do it on PR approval, at which point the feature branch merges into `develop` branch? (we follow git flow consumer side)

matt.fellows
2022-04-11 13:35
every build

tomknee1
2022-04-11 13:35
ok thats what I currently do

tomknee1
2022-04-11 13:36
I guess the tag name in this sense will always be `HEAD` then along with the git sha

matt.fellows
2022-04-11 13:39
the tag would probably be `master` or `main`

matt.fellows
2022-04-11 13:39
HEAD is a ref, not a tag

tomknee1
2022-04-11 13:39
eh ok im confused again sorry, I thought I read we use branch and git sha instead of the legacy tagging?

tomknee1
2022-04-11 13:40
so I run the pact tests and publish task every PR build, which runs on different feature branches

tomknee1
2022-04-11 13:40
once PR is approved its merged into `develop` branch

tomknee1
2022-04-11 13:40
which then triggers a build again on `develop` branch

matt.fellows
2022-04-11 13:40
ha yes well you said `tag` so I gave you the equivalent

matt.fellows
2022-04-11 13:41
Yes, you?re on the right track

matt.fellows
2022-04-11 13:41
the CI/CD workshop I think explains it better, but that?s just the way I digest content (howtolearn)

2022-04-11 13:41
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

tomknee1
2022-04-11 13:42
thanks will have a look

nathan.deamer
2022-04-11 13:42
```curl -X POST 'https://circleci.com/api/v2/project/<vcs-slug>/<org>/<repo>/pipeline' \ -H 'circle-token: *******' -H 'Content-Type: application/json' --data-raw '{ "parameters": { "pact-consumer-name": "${pactbroker.consumerName}", "pact-consumer-version-number": "${pactbroker.consumerVersionNumber}", "pact-consumer-version-tags": "${pactbroker.consumerVersionTags}", "pact-consumer-version-branch": "${pactbroker.consumerVersionBranch}", "pact-url": "${pactbroker.pactUrl}" } }'```

souravmalhotra007
2022-04-11 15:56
has joined #general

akshay.nm92
2022-04-11 17:48
has joined #general

luxfactaest
2022-04-11 18:25
has joined #general

cameron.allan
2022-04-12 00:15
has joined #general

abubics
2022-04-12 00:29
Nice one @lewis.prescott079 :taco:

kendrickbong1996
2022-04-12 04:12
has joined #general

kendrickbong1996
2022-04-12 04:18
Hi all, its good to be here. I have just signed up for pactflow but i have not got the login credentials. I have received both the domain email and the welcome to pactflow email. But nothing on the credentials. Can i please get some assistance with that? Thanks! Please pm me so i can give you my domain details.

timothy.osm
2022-04-12 05:16
has joined #general

matt.fellows
2022-04-12 06:12
Have you signed up before Kendrick? If so, you?ll be able to use your existing user/password with your new account (users are global on the platform)

matt.fellows
2022-04-12 06:12
(FYI next time best to ask Pactflow specific questions in #pactflow)

kendrickbong1996
2022-04-12 06:13
Ok thanks Matt, but while youre here. No i have not signed up before.

matt.fellows
2022-04-12 06:14
Could you please check your spam?

kendrickbong1996
2022-04-12 06:14
I have tried resetting the password as well, but no email came through. No nothing in the spam folder either

matt.fellows
2022-04-12 06:15
I?ve just unlocked your user, could you please try a reset now?

kendrickbong1996
2022-04-12 06:18
Excellent. I'm in. Thanks again Matt. Looking forward to implementing this product.

matt.fellows
2022-04-12 06:20
Great, I?ll look in to see why you might not have received that email. It?s sent from AWS, so it?s strange the first one didn?t arrive but your password reset did (also AWS). :man-shrugging:

pact270
2022-04-12 08:53
has joined #general

oytun
2022-04-12 13:12
has joined #general

oytun
2022-04-12 13:28
Hi Everyone :wave: I have a question. I added all process (webhooks included). Contract creating, publishing, triggering webhooks and verifying (included provider pipeline and webhooks triggered) are running perfectly. But i couln't pass can-i-deploy stage. What am i missing? I'm using this command for can-i-deploy stage by the way. Can anyone help please? ```pact-broker can-i-deploy --pacticipant $APP_NAME --version $CI_COMMIT_SHORT_SHA --branch=$CI_COMMIT_BRANCH --to-environment $ENVIRONMENT --retry-while-unknown=12 --retry-interval=10 --verbose```

fabio.rodrigues
2022-04-12 13:33
what is the output of the command?

oytun
2022-04-12 13:46
On provider side: `There is no verified pact between the version of ShipmentAPI currently deployed to dev (75e21c4a) and version 33cf4ee4 of AddressAPI` On consumer side: `There is no verified pact between version f5e7fb28 of ShipmentAPI and the version of AddressAPI currently deployed to dev (no such version exists)`

matt.fellows
2022-04-12 13:48
So for that to pass: all providers deployed to `$ENVIRONMENT` must have verified the contract associated with `$APP_NAME` version `$CI_COMMIT_SHORT_SHA` and the provider must also have a matching branch `$CI_COMMIT_BRANCH`

yousafn
2022-04-12 13:49
Has your provider been deployed to dev, and recorded a deployment to signify? https://docs.pact.io/pact_broker/recording_deployments_and_releases

matt.fellows
2022-04-12 13:50
My guess, is that your provider is not verifying the pact for version `f5e7fb28` of your consumer

matt.fellows
2022-04-12 13:51
It could be that your webhook is not verifying the correct pact

alessandrovermeulen
2022-04-12 14:00
has joined #general

alessandrovermeulen
2022-04-12 14:02
Hi all, we have a custom test harness that I would like to embed the pact verification in. We have our own custom http client already configured, so I would like to be able to use the verification on a slightly different level. What would be the best way to plug in the verification of pacts with responses? (On the JVM)

matt.fellows
2022-04-12 14:18
Best to ask in #pact-jvm mate!

oytun
2022-04-12 14:49
Interesting. I just disable can-i-deploy part once on the pipeline, after time i enable again and now passed all steps. Why we need to record env for new providers before can-i-deploy?

lucka
2022-04-12 15:25
has joined #general

damon_walker
2022-04-12 15:26
has joined #general

lucka
2022-04-12 16:30
Hi guys, we are currently POC'ing PACT for our organization and have a conceptual question. Let's say we have a consumer, Checkout API and a provider, availability API. I as a consumer know, that the availability API is calling another Shipping API synchronously in order to deliver a meaningful response. Now the consumer and provider have aligned verbally that, if the Shipping 3rd party dependency is facing timeout or downtime, we as a consumer still expect a valid response. Now we as a small team that is building the POC ask ourselves, is this a test case we should portray as a PACT or not. E.g. with JVM syntax, I could write: ```.given("product with stock availability") .given("transport API being down") .uponReceiving("A request on /product-availability endpoint") .willRespondWith() .status(200) .body(aValidResponseBodyUsingLikeEverywhere())``` One part of our group says this is a valid test case, because we've made our verbal contract "On outage of your Transport API dependency we still expect a valid response from you" explicit now. On the other hand the second part of our POC group says, this is an implementation detail and we should not even know, that the provider is using a "transport api" to do its job. Are there any best practices on such an example?

yousafn
2022-04-12 16:43
Interesting, my initial gut feel is that I would want to know that my consumer receives a valid response, when something goes wrong in the provider side (being agnostic of exactly what implementation detail) so you want a consumer product with stock, but your provider isn't healthy (because own x reasons). What should the consumer get when a downstream service is unavailable? A cached item? A valid response body? what is a valid response body? it could be that you expect an error, and your client handles that error. You might agree a timeout with your provider to say that if their downstream doesn't respond in 20 seconds, they return a response. We have done that at a previous client, as the api gateway window was 29 seconds and downstreams (multiple) could take much longer, or not respond. so after 25 seconds our provider would return a REFER response (it was a loan decision platform). Polling would then take place outside of that, to query the provider to retrieve a response returned from the downstream for their initial request. Sometimes this would result in the call having failed, due to a client issue (bad data in their submission) or a server side error, where-ever it was.

justin
2022-04-12 18:15
My opinion: If you don't expect the response in that case to be any different (no headers to indicate it's using cached data, body is the same) then it feels like an implementation detail you could test within the provider itself. But if your stated contract includes telling the consumer there's something going on and they may have to behave differently, it makes much more sense to have as a pact test so the consumer can validate the differences.

anusha_matti
2022-04-12 18:24
has joined #general

lucka
2022-04-12 18:27
In case the provider faces timeout to transport api, the provider is falling back to a simpler logic and responds us ?fallback: true? next to their regular same response body. We could validate that, and we could validate that we ?only? expect 200 OK to explicitly make clear to the provider that we have a contract (200 OK with same response than usual). Because in case one day they would break that contract and respond 5xx without speaking to their consumers first, at least for checkout this is then a big problem (effectively a downtime).

pact270
2022-04-12 18:36
Hi. Apologies if this should be in `pact-jvm`. I've had a PR accepted and merged into the `master` branch of the `pact-jvm` project. We're currently using the 4.1.x line of Pact libraries and really need the change from the PR. I was wondering how we can get the PR merged into the 4.1.x branch? Will this happen as part of a standard process, if so, then when, or should I raise another PR to merge it into 4.1.x?

matt.fellows
2022-04-12 21:13
If it?s easily added to the 4.1.x line I?m sure the maintainers would love a PR into that also. I believe there are some technical differences to accommodate different JVM/library?s for compatibility (this is my simplified understanding)

matt.fellows
2022-04-12 21:26
If the contract changes based on availability of downstream systems, I think it?s perfectly OK to capture that in the contract. The inclusion of the name of the downstream system/systems is something for discussion for the reasons highlighted (does this link an implementation details). Is it possible for that to be generalised such as `.given("a downstream system is unavailable")`

matt.fellows
2022-04-12 21:26
?

albert.pincevic
2022-04-12 21:48
has joined #general

uglyog
2022-04-12 23:02
If you can provide the details of the PR, we can either merge it to the branch, or you can create a new PR with the commits, but against the 4.1.x branch

matt.fellows
2022-04-12 23:26
because you?re asking the question ?can I deploy APP_NAME to environment ENVIRONMENT?. If the provider is not in ?ENVIRONMENT? then it is not safe to deploy APP_NAME to it

matt.fellows
2022-04-12 23:26
recording a deployment lets Pactflow know the provider is there, and so can-i-deploy will be aware of this and succeed

tomknee1
2022-04-13 10:37
Hey sorry have a couple more questions around this

tomknee1
2022-04-13 10:37
im just looking at this in regards to my consumer app's PR validation pipeline...

tomknee1
2022-04-13 10:38
but the docs seem to suggest using branches and record deployment/release instead of tags, so ive gone with that newer approach

tomknee1
2022-04-13 10:39
for my PR builds (before its merged into develop branch (staging)), do i need to apply a "tag" there, or do i need to "record a deployment" ? or do i do neither as its not really deployed to an environment until the PR is merged into develop/staging ?

marcello.rigan335
2022-04-13 12:07
has joined #general

matt.fellows
2022-04-13 12:30
What do people think about the idea of applying contract testing to externally standardised APIs such as OIDC? On the one hand, a standard is a standard and so in theory, there is no need for additional use cases to be documented - that?s the purpose of the standard. Additional scrutiny via contract testing could be an additional maintenance burden for little value. On the other, contract tests could still illuminate gaps in implementation and the usual value of contract test (consumer coverage, documentation of usage, prevent breaking changes etc.) _(context: we have a customer who is wanting to do it on an implementation of an OIDC system and is wondering about the benefits of such an endeavour)_

matt.fellows
2022-04-13 12:30
Is there a use case in here where certain APIs within OIDC aren?t actually called and knowing what is used might be helpful?

matt.fellows
2022-04-13 12:32
How could contract testing help with the customisable bits, such fields (e.g. in a JWT) or the discovery endpoint? For example, the supported https://swagger.io/docs/specification/authentication/openid-connect-discovery/

koel.misra
2022-04-13 13:31
has joined #general

johnmichael.bullen
2022-04-13 15:04
has joined #general

wng
2022-04-13 17:54
has joined #general

connor.mcneil
2022-04-13 19:45
has joined #general

henrry.salinas
2022-04-13 20:10
has joined #general

mike.key
2022-04-14 02:40
So?.is the concept here ultimately a ?do I have the right configuration? type test? When I think of OIDC?I think there are a bunch of libs that do this for me?most of them from IdP?s?.so what exactly are we testing here?

matt.fellows
2022-04-14 02:58
Yes, I'm trying to find _good_ reasons to do CDC here. I think config could be tested differently. The claims and grant types available is a bit blurry and could be argued is just config

mike.key
2022-04-14 03:00
Based on how I understand CDC?optional things are not part of the contract ya? And all non-standard claims are optional with OIDC/OAuth2/JWT

matt.fellows
2022-04-14 03:01
Well it depends. Usually optional things can be tested, just as a separate example (test)

matt.fellows
2022-04-14 03:02
If those non standard claims are important they should be tested, but is CDC the best way? I'm not so sure

mike.key
2022-04-14 03:07
I see what you mean?.IMO they should be tested as part of the service functionality?I can see the gray area?but to me thats dipping into functionality?but I could be convinced otherwise so I definitely get the question

matt.fellows
2022-04-14 03:38
I?m trying to convince myself, with the default position that CDC probably isn?t going to be super appropriate

matt.fellows
2022-04-14 03:38
(BDCT might be a better fit, though)

mike.key
2022-04-14 03:40
I think I agree with how you feel. I am interested in what others think though, I tend to stick to ?purist? when it comes to such things :slightly_smiling_face:

abubics
2022-04-14 04:33
If it's a way to checklist that you're implementing all the OIDC things properly, it could be useful. I don't know if it's better than any existing approaches.

danielflieger
2022-04-14 06:37
has joined #general

matt.fellows
2022-04-14 07:00
Yeah I'm feeling the same way folks. Thanks for the input!

pact270
2022-04-14 07:22
PR https://github.com/pact-foundation/pact-jvm/pull/1534 raised. Once it's merged when will a new version of the 4.1.x libraries become available? Is that something I can help with?

matt.fellows
2022-04-14 07:23
Thabks for that! Only a maintainer can release. Just an FYI that it's a long weekend here in Australia so may not get looked at until mid next week

pact270
2022-04-14 07:24
No worries, long weekend here in the UK too :slightly_smiling_face:

tomknee1
2022-04-14 09:51
bit confused here :confused:

matt.fellows
2022-04-14 10:12
Keep using branches and releases. I know this doc is being actively worked on with some great input from community as we transition from tags. Avoid tags if you're on the newer approach. You don't record a deployment before a PR is merged, unless of course you do deploy before merge.

tomknee1
2022-04-14 10:13
awesome im on the right track then :slightly_smiling_face:

tomknee1
2022-04-14 10:13
thanks for confirming

matt.fellows
2022-04-14 10:13
:+1:

elyas.najafizada
2022-04-14 11:01
has joined #general

tasaki
2022-04-14 14:46
has joined #general

edouard.lopez
2022-04-15 12:19
Hello, do you have resources on Message Queue (RabbitMQ) to share?

matt.fellows
2022-04-15 12:49
The how pact works section talks about message pact, the feature you need

matt.fellows
2022-04-15 12:49
Howtolearn

2022-04-15 12:50
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-04-15 12:50
:point_up:see if samples here. We have Kafka and AWS SNS which hopefully helps

jithinjacob2011
2022-04-18 02:43
has joined #general

bkapadia
2022-04-18 17:25
has joined #general

lewiscowles
2022-04-18 19:10
has joined #general

lucka
2022-04-19 15:11
Hello together, as we successfully made it to the point to reach "Platinum Pact Nirvana" last week (we have a webhook now that triggers the providers' cicd when the consumer changes a PACT), I am starting to learn a bit more about the "Pending Pacts" feature. In the beginning of reading the docs and watching the AMA video I was a bit confused of the feature. Because the objectives of Platinum and Pending Pacts seem to be mutually contradictory to me then, as Platinum is about "Prevent a consumer to merge his PR if his changed PACT is incompatible with the provider". The purpose of Pending Pacts I understood now is in my words: "Do not break the CICD of the provider, if a consumer changed a PACT that the provider is not supporting (yet)". So I was asking myself, "The problem that Pending Pacts solves shouldn't exist with Platinum? At no point in time there could be a PACT on the main branch the provider does not support, because its the job of the consumer to only merge his potentially uncompatible PACT changes to main as soon as the provider supports it.. So what am I not getting right about this? I am confused." :slightly_smiling_face: The more I read about it the more clearer it gets. Also, because I was seeing this "hint" in the Pending Pacts article: > ideally, this should have been done in a feature branch, but for the sake of this example, we'll assume best practice advice was not followed. > https://docs.pact.io/pact_broker/advanced_topics/pending_pacts So the way I understand it _now_ must be this: Pending Pacts was made for the rare cases in which consumers accidentally or forcefully merge/push their changed PACT even though the PR pipeline wouldn't let them, isn't it? So either bei Administrator's force-merge of a PR even though the PR's quality gate failed, or by directly pushing to the main branch to hotfix something, etc. If in these cases they would at the same time change a PACT that the provider is not supporting, they would fail the providers cicd. Did I get this right?

lucka
2022-04-19 15:24
Hey Matt, thanks for replying. I think that sounds reasonable and is actually a great idea.

florent
2022-04-19 16:02
has joined #general

david.vancouvering
2022-04-19 16:26
Hey. I am thinking maybe no - but can you get stubs out of a bidirectional contract published by the provider as an OpenAPI spec? Or does it have to be a Pact contract that drives stubs?

yousafn
2022-04-19 17:35
Hey, Not at the moment, it was queried recently in this conversation https://pact-foundation.slack.com/archives/C9VBGLUM9/p1649673717552369?thread_ts=1649413944.193749&cid=C9VBGLUM9 over in pact-js with a suggestion that swagger-codegen has a stub server that could be useful

david.vancouvering
2022-04-19 18:31
ok thanks!

testingterrasoft
2022-04-19 19:19
has joined #general

olivia.c
2022-04-19 23:27
has joined #general

matt.fellows
2022-04-20 06:33
Yes that's one scenario. It's also to support providers automatically verifying new consumer pacts (via WIP pacts) without breaking their build. Also, there are situations where the exact guidelines in nirvana aren't suitable, so having pending also simplifies those use cases

ysuei.ygui
2022-04-20 20:42
has joined #general

ysuei.ygui
2022-04-20 20:43
:wave: Hi everyone! I am new to pact

ysuei.ygui
2022-04-20 20:44
Was going thru the doc, and was wondering if we can use pact to test pagination?

abubics
2022-04-21 02:18
You sure could :slightly_smiling_face: using states like "several pages of results" with interactions like "fetching the first page", "fetching the last page", etc, is a common approach. I'd be careful of over-specifying the interactions, though, because they may all look the same, and only differ in query params.

ysuei.ygui
2022-04-21 02:21
ah .. thanks for the idea. Greatly appreciated it

yousafn
2022-04-21 08:17
:wave: Morning everyone, This oldie but goodie came back to my attention yesterday and it's made me think, what other programming language oddities are you aware of, that increase that cognitive load and complexity when you are developing. https://www.destroyallsoftware.com/talks/wat

mike.geeves064
2022-04-21 08:31
Not directly, but it brings back similar memories of a MySQL -> PostgreSQL swapout, similar to when you add in typing and find half your code shouldn't actually work but coincidentally some blatantly broken logic and unexpected casting happens to resolve to the thing you need :joy:

2022-04-21 08:53
This message was deleted.

yousafn
2022-04-21 09:50
Hi Nuno. is this sentence correct? > For an asynchronous interaction I would consider a synchronous interaction when the provider sends a message that is syntactically incorrect (e.g. with missing mandatory fields) or with wrong data, causing the consumer to reject it.

nuno.frias
2022-04-21 09:51
Nope it is not. Sorry

nuno.frias
2022-04-21 09:51
Fixing it now

yousafn
2022-04-21 09:51
thanks buddy

nuno.frias
2022-04-21 09:52
Can't edit the message ... annoying

yousafn
2022-04-21 09:52
Neither can I, if you repost, I can delete the original :thumbsup:

nuno.frias
2022-04-21 09:54
Hello all I am struggling to think of an example of an ?unhappy path? for an asynchronous interaction. Let me clarify: On a synchronous interaction I would consider an unhappy path to be something like when the consumer sends a request to the provider and gets a 400 response back. The consumer test then asserts that the consumer handled the 400 response correctly (e.g. correct exception is thrown). For an asynchronous interaction I would consider an unhappy path to be something like when the provider sends a message that is syntactically incorrect (e.g. with missing mandatory fields) or with wrong data, causing the consumer to reject it. The problem is I can?t force the provider to send a message that is syntactically wrong (as the server code enforces the syntax), that leaves me with trying to send a message with wrong data. In this case should I build a scenario for each wrong data combination that can be sent (this is functional testing), or should I just pick one or two examples of wrong data and build tests for it?

nuno.frias
2022-04-21 09:54
Reposted

yousafn
2022-04-21 09:55
we might need to look at our slack settings for allow OP's to the edited. Thanks @nuno.frias

nuno.frias
2022-04-21 09:56
No problem. Apologies for that I should double check my questions on a public forum :disappointed:

yousafn
2022-04-21 09:57
dude, It's okay, I make mistakes all the time!

yousafn
2022-04-21 10:18
> I can?t force the provider to send a message that is syntactically wrong (as the server code enforces the syntax), that leaves me with trying to send a message with wrong data. Are you trying to cover a case on your consumer side, where it handles the errors returned from your provider, in the case of bad data? If you can't force your provider to send a message that in syntactically wrong because the code enforces it, would you expect that scenario to happen in production, and therefore worthy of testing? What is the particular use case here, is your client posting a message to a queue and expecting to do something at some point later with the provider response. Where is the providers response being posted too? There is always a little overlap and I wouldn't be concerned but you wouldn't want to cover all the edge cases. If the shape of the error message is always the same, then you can just test that one case. If in specific error cases, you do some different work in your client, based on a specific response, then I would want a contract to cover that.

yousafn
2022-04-21 10:20
My experience with async has been posting messages to SQS and various lambdas listening to them and performing actions (such as generating a file and saving it in a bucket, based on a ref or payload provided in the message). The only responses the client would get, would be that from SQS as to whether they had published the message correctly or not.

yousafn
2022-04-21 10:23
I would have lots of provider tests (not Pact tests) that ensure that my provider returns nice error messages, when things go bork. We would consider the difference between retryable errors and non-retryable errors. a valid client payload (to the queue) but garbage to the provider (non existent id for example) wouldn't be retried and chucked straight on a DLQ. If the db connection was down we would allow the SQS retry mechanism to kick in, and dump in on the DLQ after x redrives

nuno.frias
2022-04-21 10:32
> Are you trying to cover a case on your consumer side, where it handles the errors returned from your provider, in the case of bad data? Correct. In this particular case the provider communicates with the consumer via kafka. Essentially when an upstream event occurs the provider writes an event to a kafka topic, which the consumer reads, does additional processing and then responds to another consumer further downstream. This interaction is started by the provider. I take it from your answer that I should handle the majority of unhappy paths (messages with wrong data) on the component tests, and pick a few relevant cases for Pact -- even that makes the tests overlap a bit. That makes sense to me.

yousafn
2022-04-21 10:39
Have you ever seen this site? It is really good to quickly make diagrams to represent your domain, I find it quite useful as visual references are easier to relate to than text. https://www.websequencediagrams.com I?ll have a think on your particular problem, first thing that stands out is there are three parties here, one is acting as a pass through with transformation. Not sure if it?s different in Async land but I know that causes pain in provider verification with regular consumer driven contract testing and we have suggested a slightly different pattern. I?ll find the docs. https://docs.pact.io/getting_started/what_is_pact_good_for#why-pact-may-not-be-the-best-tool-for-testing-pass-through-apis-like-bffs This may or may not be applicable to your use case so take it with a pinch of salt

nuno.frias
2022-04-21 10:48
In my case it is not a pass through API the individual micro services do implement a fair bit of logic which controls whether they interact with the other services dowstream and the content of that interaction.

abubics
2022-04-21 10:53
A lot of async things end up being pairs of sync things: instead of getting an immediate response for final success (or failure), you get first an immediate response of acceptance, and then later a separate call back for final success (or failure). If it can truly be modelled in that way, then it's multiple interactions, simple :slightly_smiling_face:

abubics
2022-04-21 10:53
If not, then a diagram would help a lot. It's hard to visualise which bits you want to cover in just words.

abubics
2022-04-21 10:54
Generally, things like malformed messages (e.g. bad syntax) aren't part of the contract, they're at a more fundamental layer (e.g. web framework rejects malformed requests, even if you control the error response shape).

abubics
2022-04-21 10:56
But things that can be invalidated with domain logic (i.e. contract things), can't often be invalidated with only shape or syntax checks, without refactoring your transaction models. That's exactly what contract tests aim to solve, across network boundaries.

nuno.frias
2022-04-21 10:57
The whole system I am testing contains many microservices, typically any two pairs of services interact in the following manner: ? service A sends an HTTP request to service B ? service B responds with a 200 if the request is valid ? service B does additional processing and may send a request to a service C ? service B writes an event to a Kafka topic when it gets the response from service C ? service A reads the event from the topic

nuno.frias
2022-04-21 10:58
Indeed there are multiple interactions involved @abubics

nuno.frias
2022-04-21 11:00
My question was more generic, I wasn't targeting a particular interaction.

abubics
2022-04-21 11:01
sounds like you want ? A->B http ? B->C http ? B->A message

abubics
2022-04-21 11:01
and you might have multiple states and/or interactions for each, including unhappy paths if they're warranted :slightly_smiling_face:

nuno.frias
2022-04-21 11:02
my question was precisely whether or not I should cover the unhappy paths in Pact.

abubics
2022-04-21 11:02
it's valid to have cyclical relationships, but you have to be more careful with them, because they can be hard to change

abubics
2022-04-21 11:02
how much you want to cover unhappy paths is usually determined by how much confidence they'll give you

abubics
2022-04-21 11:03
> There is always a little overlap and I wouldn't be concerned but you wouldn't want to cover all the edge cases. If the shape of the error message is always the same, then you can just test that one case. > > If in specific error cases, you do some different work in your client, based on a specific response, then I would want a contract to cover that. That pretty much covers the general advice :ok_hand:

abubics
2022-04-21 11:04
But, for example, if you have a complex multi-step transaction model, and there are significantly different errors possible in different transitions, then you probably do want coverage of them.

abubics
2022-04-21 11:04
That coverage might be better placed in unit tests, especially if the error shapes don't change.

abubics
2022-04-21 11:06
Generally, I have centralised error handling at the gate where messages are marshalled through the data layer into domain-meaningful models, so I tend to only need one sad path in contracts, for each category of error. The branching for how the errors are handled can be done internally, outside of the contract.

abubics
2022-04-21 11:07
(I think I got there in the end, sorry for the other tangents :sweat_smile:)

nuno.frias
2022-04-21 11:07
That makes a lot of sense

nuno.frias
2022-04-21 11:08
Thank you very much.

abubics
2022-04-21 11:10
np ^_^ conveniently, I think the async bit might be a red herring

nuno.frias
2022-04-21 11:19
On the synchronous interactions the provider responses have pretty much the same format, the only thing that varies is the message, and in some rare cases the status code.

nuno.frias
2022-04-21 11:20
But on the async interactions there are is a larger number of variations that cause the consumer to reject the message

nuno.frias
2022-04-21 11:20
So I was debating whether I should handle the unhappy paths on the component tests alone.

nuno.frias
2022-04-21 11:26
But your response shed some light > I have centralised error handling at the gate where messages are marshalled through the data layer into domain-meaningful models, so I tend to only need one sad path in contracts, for each category of error. The branching for how the errors are handled can be done internally, outside of the contract. Essentially I only need a Pact test to exercise the bit of the client code that rejects the message and I can test the various error cases on the component tests / other unit tests.

abubics
2022-04-21 11:33
in that case, the state for the message consumer might be like "a transaction is in progress" or "a transaction is in <blah> state", but either way, the response is probably a pithy "ok", and the actual error handling happens inside the app, as you suggest :thumbsup:

matt.fellows
2022-04-21 13:00
Hi Nuno - you can actually edit posts, you just can?t edit it after 30 mins from posting.

matt.fellows
2022-04-21 13:01
This is a slack default we can change, but frankly, if you need to change your mind after 30 mins it?s probably best to just post an update on what you thought/wanted to say

giuseppe.torchia
2022-04-22 08:25
has joined #general

thadamski
2022-04-22 14:00
has joined #general

edouard.lopez
2022-04-22 14:50
Using *https://github.com/pact-foundation/pact-stub-server* is there a request I can do to list the endpoints exposed or do I need to manually find them via the broker/contract files?

druiz
2022-04-22 15:02
has joined #general

tord.brokvist
2022-04-22 15:08
has joined #general

lucka
2022-04-22 15:28
Hi, I am wrapping my head around the Diamond Pact Nirvana step, in specific i am trying to set the "main" tag after my PR is merged to the main branch. But since a "merge" to the main branch creates a new commit I am having the problem, that I cannot call the broker to tag this version with "main", because the PACT version that got published to the broker is the head commit sha of the feature branch. There is technically with github actions no problem to simply add the tag to the correct version (git sha of the feature branch), but this is a bit dirty I think, as this git commit is not going to be the one that is deployed to prod, but the merge commit does. Has anyone had this problem too?

lucka
2022-04-22 15:34
What I could do of course is to run the PACT publish step again, then the version is overwritten, but I suppose this is adding a bit of instability to my cicd then, because it could fail and in this case nobody would recognize unless this failure doesn't stop the deploy pipeline. Maybe this is the solution of it? I just thought its advisable to not run the entire build + pact publish step "again". The way its currently solved in the screenshot is that the "main" tag was attached to eeda852, the PR's head commit. This diverges with the actual GIT main branch now and leads to confusion so I think it cannot stay like this.

lucka
2022-04-22 15:35
I'd appreciate to know how others managed to work this out

tord.brokvist
2022-04-22 15:43
Hello :slightly_smiling_face: I want to find some logical relation between the interface specification (OpenAPI) of the service provider and the consumer tests. To do this I need your support to #1 get a better idea about how strictly one should define the API of the service provider and #2 to what level of detail one should specify the service consumer test cases. #1 How strict should I define my inparameters in my OpenAPI for the service provider? Let's assume I go for a very strict approach meaning ? specifying what in-parmeter is optional/mandatory ? specifying all odd formatted in-parameters like customer ID [A-Z][A-Z][A-Z]\-\d\d\d (since it makes my provider logics simpler to implement) ? I might even add restrictions like optional in param C must always be provided if optional param B is provided #2 Your recommendation for level of detail for consumer tests are "Only make assertions about things that will affect the consumer if they change" In that chapter you exemplify to avoid the test case that verifies that "the customer ID is expected to be in the format `[A-Z][A-Z][A-Z]\-\d\d\d`" I hope this is meant for an out-parameter? By this I hope you understand the scope of my thoughts and I would really appreciate som your general thoughts on this theme.

gnanasekar69
2022-04-22 17:23
has joined #general

himanshu.1046
2022-04-24 18:25
has joined #general

lewiscowles
2022-04-24 23:11
:wave: I signed up for a personal free account in addition to my work account. password reset doesn't work.

matt.fellows
2022-04-25 00:11
Hi Lewis, can you please send a request to and we can reset it for you?

matt.fellows
2022-04-25 00:11
How long ago?

himanshu.1046
2022-04-25 04:23
Hello folks, I wanted to have provider setup for pact-python? any refrences to that and what default port it uses? wanted to understand and setup that?

matt.fellows
2022-04-25 04:40
Check out the examples in the git repo.

matt.fellows
2022-04-25 04:40
Also examples here: howtoexamples


matt.fellows
2022-04-25 04:41
Also, best asking in #pact-python

pact270
2022-04-25 06:24
Thanks for getting this merged and released.

lewiscowles
2022-04-25 07:27
Saturay, but I'll send the email.

lewiscowles
2022-04-25 07:28
It was a case that I'd started typing and only pressed send yesterday evening upon realising I had not

chris196
2022-04-25 09:51
has joined #general

manu.vereecken
2022-04-25 11:06
has joined #general

matt.fellows
2022-04-25 11:15
Should still work. You can't reset a password if you hadn't logged in the first time tho.

matt.fellows
2022-04-25 11:15
We'll get it sorted

matt.fellows
2022-04-25 11:16
Just unlocked your user now. Can you please try resetting your password again now?

maltechristian.neuman
2022-04-25 11:52
has joined #general

lewiscowles
2022-04-25 13:39
Ah that must have been it. I will store this one in my password manager. I Think I signed up at work, but it looks like my work login overwrote it.

lewiscowles
2022-04-25 13:47
Stored and hopefully not an issue again. I am mostly going to use this to explore things we can do that are different to how we use at work, as I think it feels a bit of a mess. People are injecting ruby binaries and modifying controllers in their projects to integrate pactflow. It feels quite intrusive for what it's sending to the pactflow broker.

prashanth.ramadass
2022-04-25 14:04
has joined #general

wng
2022-04-25 14:33
Hi! We had a few questions regarding the new bi-directional contract feature of Pactflow (and I suppose Pact in general). 1. To our understanding, Pact is great for direct service to service contract enforcement, but what happens when you add an API gateway into the equation where a service needs to go through the gateway before reaching the microservice? Ideally the gateway would not contain much, if any business logic and mostly functions as a passthrough for api calls in our system. The https://docs.pactflow.io/docs/bi-directional-contract-testing/#use-cases says it simplifies things, but how is unclear. 2. The documentation https://docs.pact.io/getting_started/what_is_pact_good_for#why-pact-may-not-be-the-best-tool-for-testing-pass-through-apis-like-bffs recommends not using Pact for a BFF pattern. However, it's unclear if this documentation is meant to apply just to consumer driven contract testing or if it also applies to the bi-directional contracts as well. Could you clarify that as well? In a nutshell, this is the problem we're trying to understand in the following diagram. If using the bi-directional contract feature, where should Pact live (if at all)? ? (2) only? ? It's clear the microservice is the provider, but who is the consumer? Technically the client, but with the gateway proxying/transforming data potentially, does the consumer contract live here? ? (1) + (2)? ? Given the uncertainties of (2) alone, does it make sense the chain the contracts? Probably not, but wanted to validate this. ? (3) only? ? For contract testing purposes, act as if the gateway doesn't exist and just have the contract between the true consumer/provider? ? (4) We have something wrong with our contract testing approach entirely and if so, what should be the approach.

yousafn
2022-04-25 15:31
I was pondering the same question today, when chatting to a friend. re: point 2 - this https://docs.pact.io/getting_started/what_is_pact_good_for#why-pact-may-not-be-the-best-tool-for-testing-pass-through-apis-like-bffs about Pact _not_ for BFF/API Gateway patterns, relates to the traditional Pact consumer driven contract model, where the provider verification interacts directly with a provider codebase. I think a few people have been wondering about how the traditional CDCT (consumer driven) and BDCT (bi directional) contract testing approaches would work together. If the api gateway was purely non transformational, I would probably use BDCT between 1/2 and use a flavour of a non HTTP CDCT verification at point 3 > What you really need is a "non-HTTP" pact between your consumer and the downstream system. Check out this https://gist.github.com/bethesque/0ee446a9f93db4dd0697 for an example of how to use the Pact contract generation and matching code to test non-HTTP communications. I don't have good examples of that in use, bar the linked gist. I love where this train of thought is going, and I also :heart_eyes: the fact you made a diagram! I really want to showcase some ways Pact (both BDCT and CDCT) can work or not work with API gateways/BFF's and module federation

wng
2022-04-25 15:38
Thanks for quick response and yes, that helps clarify a lot of things! We figured we can't be the only ones using an API gateway, so more documentation for BDCT and CDCT with gateways in the future would be great!

yousafn
2022-04-25 15:40
Hope to hear more real world experiences and share them, so keen to hear what our community has to say :slightly_smiling_face: We used them extensively in a previous project, some as transformational, some pass through, all to access on prem systems, but never got round to properly covering them with Pact because we had far bigger testing challenges in the org

wng
2022-04-25 17:58
This is perhaps more of a Pactflow question then, but if we did (1) and (2) above, that would make the api gateway the consumer and provider (as it should be). Would a pact broker visual the network diagram for the full sequence between the client, gateway and microservice? Or would it just show as two separate contracts where it'll be client to gateway and then gateway to microservice? Or alternatively if we chose to just implement (2), how simple would it be to rename the "consumer" [api gateway]?

janarthanan.rajendras
2022-04-25 22:35
has joined #general

matt.fellows
2022-04-25 23:08
If the gateway was basically pass-through, I?d simply add a single contract (3). Sometimes the gateway adds or validates headers that don?t pass downstream. In this case, i?d still do the above, and test this in other ways (usually, this is such a core part of the API it will be caught in several other places if not fully tested via CT anyway). If the gateway starts to change the paths / routes, you could go either way. If the gateway did things like orchestrate/choreograph and stitch multiple APIs together, then you need to treat them as separate tests. BDCT can make some of these situations simpler, primarily because they can be tested in a black-box way unlike with Pact which requires you to write unit tests, which can often be quite cumbersome depending on the API gateway technology. For example, Axway/Apigee/Layer7 and the like are basically not unit testable, which makes Pact hard to use. But BDCT can side step some of these technical barriers because you have more ways to test it at arms length.

shreyas.gowda
2022-04-26 02:14
has joined #general

abubics
2022-04-26 02:42
Every build (i.e. every commit) should have passing tests (including contract tests) before deploying. There's an optimisation in the broker to pre-verify a new contract version if the content is the same as an existing contract, so you don't really have to worry about verification performance.

abubics
2022-04-26 02:43
You don't want to use the branch version, because there might be legitimate differences once it's merged.

marxjo
2022-04-26 07:09
has joined #general

andrew.fraser
2022-04-26 07:19
has joined #general

lei.shi
2022-04-26 07:46
has joined #general

akash.sharma5253
2022-04-26 11:50
has joined #general

yousafn
2022-04-26 13:26
Hey hey, Open question. are you involved in open source projects? would you like to be, but don?t know where to start? Feel free to join me in a :thread: , if you have a cool package/project, feel free to share. I?ve found so many awesome pact repos and packages sprouted over the years, and plan on collating a list to put on the website, but yeah just curious to hear what others are up to!

rafael.anachoreta
2022-04-26 15:43
I?m also really curious to hear your thoughts on this. I just went through @matt.fellows?s video on BDCT and was hoping to hear more about how to handle the case where a gateway stitches multiple APIs together. What we have done to solve this problem is split our CDCT into two: one between the consumer and the gateway and another between the gateway itself and the provider. This has worked but has been challenging to maintain (the setup is a lot more complex than I?m making it out to be). Is this something Pactflow supports already? And if not is it in your roadmap? How would you solve this challenge?

matt.fellows
2022-04-27 07:18
What technology is your gateway Rafael?

matt.fellows
2022-04-27 07:18
and how does it stitch it all together - configuration? Code? (something else?)

kannan.jai
2022-04-27 07:49
has joined #general

c.giannakopoulos
2022-04-27 10:47
has joined #general

sebastian.spiess
2022-04-27 11:43
has joined #general

rafael.anachoreta
2022-04-27 11:54
It is a NodeJS GraphGL Gateway built on top of Apollo that combines schemas from multiples services into a federated schema. Is that the information you were after, @matt.fellows?

matt.fellows
2022-04-27 11:55
Yes, thanks

matt.fellows
2022-04-27 13:06
OK, so I just did an export of the slack workspace public channel data, and it?s now up at http://docs.pact.io/slack

matt.fellows
2022-04-27 13:08
Checkout the #graphql channel and also this archive of a discussion about federation: https://docs.pact.io/slack/graphql.html#1599007978.023800

matt.fellows
2022-04-27 13:08
Keen on your thoughts

matt.fellows
2022-04-27 13:09
but, to be clear, whilst we would love to, we don?t have any concrete ideas/plans to make GraphQL better in this specific sense. Feedback and feature requests (http://pact.canny.io) would help of course

rafael.anachoreta
2022-04-27 13:11
Ha! I work for the same company, so we are talking about the same setup there :slightly_smiling_face: I couldn?t find this discussion as I was limited to the history slack provided, but thanks for sharing. I?ll go through the messages and get back to you in a bit

matt.fellows
2022-04-27 13:13
LOL

matt.fellows
2022-04-27 13:13
OK, well that?s funny. Hopefully we?ll be able to upgrade the workspace to Pro soon (SmartBear have indicated they might do this), so would mean I wouldn?t need to keep running the export to the site.

rafael.anachoreta
2022-04-27 13:29
What I can say is that the approach we are using works, but it is more time consuming than when you only have to worry about a single consumer <-> provider pair. It also can misbehave when we have multiple concurrent deployments happening at the same time, as it becomes tricky to set on an exact gateway version to verify against.

rafael.anachoreta
2022-04-27 13:33
I don?t exactly know how Pact could make this flow more seamless either :disappointed:

matt.fellows
2022-04-27 13:46
I think it could possibly be solved by BDCT: 1. Consumer - write contract tests (whether using Pact or not), potentially usinsg a GraphQL plugin when the plugin framework is available 2. Gateway - Apollo federation presents a unified graphql schema and uploads to Pactflow (again, would need GraphQL BDCT support - this should be doable though) 3. API Providers - I?d need to know a bit more about how federation works, but potentially Pact works OK here already, if they are HTTP clients?

oury.diallo
2022-04-27 13:46
has joined #general

yousafn
2022-04-27 13:46
:wave: We now having voting buttons in the footer of every page on our documentation site https://docs.pact.io/ If you find a page useful, or just plain confusing, please drop us a vote. We are keen to make the documentation on point, over time and this will hopefully give the open source maintainers visibility into where some of the common pain points are and give us a good base line for improvements, or even measuring if new pages are making the required impact. Also don't forget as the whole site is open source, you also have the option to `Edit this page` and you can help curate and shape our content, like a big beautiful contract testing wiki.

rafael.anachoreta
2022-04-27 14:00
Re #3, yes, they are HTTP clients in our case. How would the Gateway in this case be able to validate requests though? It would need the providers, right?

matt.fellows
2022-04-27 14:17
In BDCT we only look at the schemas. If the graphql schema is sound we can compare to the consumer contract and be confident they are compatible. This assumes of course there are good ways to test the graphql schema + federation setup

jean.paiva42
2022-04-27 18:58
has joined #general

christoffer.vig
2022-04-28 06:09
has joined #general

kannan.jai
2022-04-28 12:50
Hello, team. Afternoon. I have a quick question, to trigger Provider Verification as part of consumer pipeline, can we simply use Jenkins build job trigger instead of using Webhooks? Are there any drawbacks in this approach? Please advise. Thanks. Something like this - ```stage ('Provider Verification') { steps { build job: 'providerVerificationPipeline' }```

matt.fellows
2022-04-28 12:54
You can. The webhookless flow uses this pattern: https://docs.pact.io/pact_nirvana/step_6#alternative-webhookless-workflow

andrea.sangiorgio
2022-04-28 13:01
has joined #general

kannan.jai
2022-04-28 13:03
Thanks, will have a look.

jason.mcinerney
2022-04-28 19:14
has joined #general

psnyder
2022-04-28 19:22
has joined #general

dominique.cote
2022-04-29 01:17
has joined #general

laura.walsh
2022-04-29 13:40
has joined #general

david.vancouvering
2022-04-29 16:14
We'd love to move away from tags to branches and environments, but can't because we use the JVM libraries and Maven plugin, which don't support them. When can we expect that to get resolved? Feels like we're going further and further afield from the main road

ashish.goyal
2022-04-29 18:50
Hello Team- I recently started on BDCT. We have our API spec which internally refers to different schemas. I am working on resolving those references so that i can publish an API contract to pact broker. In your experience what tools have worked best for you.. From my end, i have tried using openapi_parser library written in python. It generates a Specification object after resolving all references from my yaml file, however i am not able to find how to convert this specification back to yaml/json so that it can be published to pact broker

mailtoadnan.ahmed
2022-04-30 08:56
has joined #general

prasanna.mallisetty
2022-04-30 12:11
has joined #general

yousafn
2022-04-30 19:42
Unless you have a specific business case to do some based on that 400 class of error, on the client side, why would they care?

yousafn
2022-04-30 19:45
Liking the discussion though and welcome to Pact! Always good to newcomers thoughts because you might see it in a completely different light

uglyog
2022-05-02 00:27
These are on our product roadmap. Some of us (at Pactflow) have been involved in the acquisition by Smartbear, so have not had much time to work on things like that. Going forward, Smartbear is going to be supporting all the Pact frameworks, so this work will be picked up again.

david.vancouvering
2022-05-02 02:31
Ok thanks

marcelo.jaeggi
2022-05-02 16:26
has joined #general

laura.walsh
2022-05-02 22:27
Hi there! My team set up Pact a few months ago but could use some clarity / guidance on our setup (which we have likely not configured quite right). My team's service is a lambda function that is the consumer of an SQS queue that is written to by a Ruby gem, which is called by another microservice. The Ruby gem is not just a passthrough service, as it takes some of the parameters of the provider's request and puts them into the body of the SQS message while it attaches some of the others as messageAttributes to the SQS message. We initially set up message Pact tests between the Ruby gem and our consumer, since it is the gem that creates and sends the payload that we need to confirm matches with our consumer microservice?s message handler code. We realized though that this does nothing to guarantee that the greater flow between our provider microservice and our consumer microservice (the flow which we really do want to safeguard in production using pact) is actually unbroken. Our team owns the consumer microservice and the client gem and we make sure that any changes that go live on the consumer microservice are immediately supported by an update to the Ruby gem to match. However, the provider microservice is in control of upgrading the Ruby gem to newer versions and if it is using an old version of the gem, the message put onto the queue by that old version of the client gem will fail to be processed by the new, live version of the consumer microservice. We are trying to reason about what makes the most sense for us given our architecture here. Is there a very different way we should be setting up our Pact integration to meet our contract testing goal of ensuring that the provider and consumer microservices (via the Ruby gem) are always in sync with each other in production? Thank you so much for your time!

eddie
2022-05-02 23:58
> Unless you have a specific business case to do some based on that 400 class of error Well that's *one* good reason, but another reason is that if there's a new shape of 400 response, there's a possibility that you were previously making requests that could be now invalid.

jaswanth.ooty
2022-05-03 00:26
has joined #general

james.weng
2022-05-03 05:13
has joined #general

jochen.kraushaar
2022-05-03 09:16
has joined #general

anurag.soni1984
2022-05-03 10:58
has joined #general

stephen.taylor
2022-05-03 14:26
has joined #general

conrad
2022-05-03 18:41
has joined #general

jithinjacob2011
2022-05-04 04:59
Are there any workshops/training available in the office for PactJs Training or is it available only for partners at the moment.

matt.fellows
2022-05-04 06:18
Hi Jithin, I assume this question is directed at Pactflow and not the general community given your comment re: partners?

jithinjacob2011
2022-05-04 06:19
Yes

matt.fellows
2022-05-04 06:19
We can certainly connect you with one of our local Partners - I think DiUS would be a good fit given where you?re based. If you could please drop a line to we could look to connect you via email. I?d like to get a bit more of an understanding of your needs and budget though. Want to DM me with details?

jithinjacob2011
2022-05-04 06:21
Yea sure. I will email the details.We are in a proof of concept phase. As this is something new I thought of taking a basic training

qamarlonalmeida
2022-05-05 05:24
has joined #general

ben.pilgrim
2022-05-05 10:19
has joined #general

lredpath
2022-05-05 11:21
has joined #general

alex834
2022-05-05 11:26
has joined #general

damianruizdev
2022-05-05 13:10
Hey guys, I'm trying to sign up for the Pact Broker but the button is remaining disabled after filling out all the fields?

yousafn
2022-05-05 14:11
Hi @damianruizdev, Does your pact broker already exist? https://avidxchange.pactflow.io/ if you try and enter a different name for the `Requested subdomain for your broker` and then switch it back to avidxchange, it should fire a request and show a message to say its already taken. It looks like there should be a form validation shown, when the form is first rendered and pre-filled with the company name, from the previous part of the flow

yousafn
2022-05-05 14:12
I think you will need to request an invite from the account owner, or reset your credentials, if you are the account owner. https://avidxchange.pactflow.io/

damianruizdev
2022-05-05 14:20
Yup, notification popped up after removing the subdomain and adding it back in. Thanks Yousaf!

nachogonzalez
2022-05-05 15:51
has joined #general

kannan.jai
2022-05-05 16:57
Hi Team, afternoon. I am getting an error while publishing a pact - [ERROR] PUT JSON request failed with status HTTP/1.1 429 Too Many Requests Failed. Looking for any inputs to troubleshoot. Thanks.

yousafn
2022-05-05 17:30
Fab, and no problem buddy, will see if we can get that sorted to avoid confusion for further users, thanks for letting us know.

matt.fellows
2022-05-05 17:45
Is this to a self hosted pact broker or Pactflow?

matt.fellows
2022-05-05 17:46
The error seems obvious, are you sending too many requests?

matt.fellows
2022-05-05 17:48
Might be an on blur event so doesn't pick up default fields

mounaouar
2022-05-05 18:00
has joined #general

kannan.jai
2022-05-05 18:26
I am using Pactflow. I have a consumer which has 3 providers. I am able to generate pact and publish for one provider but while doing the same for the other two providers comes back with this message.

mounaouar
2022-05-05 19:01
Hello everyone, I have a question: Is there a way to allow new consumer contrats to be deployed using can-i-deploy even if there is no provider code to support it at the exact time of deployement? The reason I'm asking is that I want to prevent merge hell, i.e. consomer code waiting in separate branch waiting for the provider code to be developped.

kannan.jai
2022-05-05 19:11
Fixed it, seems like there were some old pacts / interactions in Pactflow which I had to delete.

kannan.jai
2022-05-05 19:11
Interesting but...

matt.fellows
2022-05-06 02:11
Are you on the free tier? Are you at your free tier limits of number of integrationts?

matt.fellows
2022-05-06 02:12
That could explain a 429 I think. On the free tier, you only get 5 integrations by default. So if you had extra pacts with different integration details (provider/consumer) that would try and create more integrations, and potentially exceed the limit

matt.fellows
2022-05-06 02:57
There is a ?dry run? option and options to ignore specific pacticipants in the result.

matt.fellows
2022-05-06 02:58
run `pact-broker help can-i-deploy` to see the available options

matt.fellows
2022-05-06 02:58
`can-i-deploy` is designed to prevent this situation, because it is inherently unsafe (how can you deploy a consumer if the provider is not there? Clearly, the consumer won?t work)

matt.fellows
2022-05-06 02:59
If you know this is the case in advance, the best thing to do is just _not_ call can-i-deploy. If *you* have the information in advance to know you want to skip can-i-deploy, just skip it

richard.jones254
2022-05-06 04:02
Has anyone hooked up the broker webhook to trigger verification in CircleCI? Am looking for clues please :slightly_smiling_face:

bethskurrie
2022-05-06 04:02
Hey @richard.jones254!


richard.jones254
2022-05-06 04:03
OMG @bethskurrie thanks :slightly_smiling_face:

bethskurrie
2022-05-06 04:03
it doesn't look like that example passes in properties though

richard.jones254
2022-05-06 04:03
It?s a good starting point tho

bethskurrie
2022-05-06 04:03
if you work out how to do that, could you update the example?

joanna.schloss
2022-05-06 04:45
has joined #general

frank.kilcommins
2022-05-06 04:46
has joined #general

douglas.clark
2022-05-06 04:46
has joined #general

danielflieger
2022-05-06 06:30
Hey there! I was wondering if it is possible to use the ?pending pacts? feature & ?can I deploy? at the same time when using ?Platinum? or ?Diamand? in pact nirvana? As it seems that ?can I deploy? needs a successful verification on provider side first before it can be deployed. In my example I want to introduce a new ?State? on consumer side which has not be implemented on provider side. So I was wondering if I can deploy without having the new state in the provider. Thanks!


bethskurrie
2022-05-06 06:32
if you want to add a new provider state, but keep the consumer deployable, you generally make the change on the branch of the consumer, then implement it in the provider, then merge in the consumer branch

danielflieger
2022-05-06 06:40
Thank you for the blazing fast feedback. I?ll gone a have look into the workshop. I may missed something in the concept then.

bethskurrie
2022-05-06 06:41
using pending will stop the provider breaking, and the provider will still be able to deploy against the existing consumer in prod, but you won't be able to deploy the consumer version with the new provider state until the provider implements it and deploys that version.

danielflieger
2022-05-06 06:50
Ok. But when the consumer with his new state is in a feature branch which has not been merged yet what?s the reason to have ?pending pacts? anyway then? As I understood the provider tries to verify itself against main/master. Where the new state does not exist at this point in time.

bethskurrie
2022-05-06 06:51
if you follow the process perfectly, then you don't need to enable pending pacts. but nobody every follows a process 100% of the time!

lucka
2022-05-06 06:51
Hi Beth, we implemented Platinum by example of the awesome CI/CD workshop. While we are trying it out on a daily basis, we more and more see that Platinum is going to tightly couple a consumer and his provider. Given Convey's law and having a working model with high concurrent development process on big company initiatives, this in practice usually means that a consumer may be faster in developing a new feature than a provider can actually implement it (assuming consumer and provider have aligned on a new API spec first). This would put the consumer in a position to ask the provider to implement his new/changed PACT for him to unblock his PR pipeline. For this reason we have the necessity to still be able to work independently. We solve this usually by utilizing feature toggles, so that the consumer can deploy his work already even to production, regardless of whether the provider implemented the feature already or not. This comes with the drawback of loosing security from a test perspective though. We too think, that the platinum step is actually worth having, but when we roll out or POC solution on company level I think this is going to be a problem, hence we are now starting with a first POC approach to not use Platinum but rely on pending-pacts first to unblock the consumer from merging his PR.


aaron.m.williams24
2022-05-06 07:50
has joined #general

yousafn
2022-05-06 08:09
That's a great link Beth. Here is an example I've used which has the props set https://github.com/YOU54F/template-jest-pact-typescript/blob/master/src/pact/webhooks/circle_ci_job_trigger.json Might help? Wonder if the 1.1 api is still available as I know they moved to a 2.0 api and things got deprecated ( I have a slack reporter that publishes to slack but broke recently )

joanna.janiec
2022-05-06 08:14
has joined #general

nicholas.simons
2022-05-06 11:02
has joined #general

matias.cardenas
2022-05-06 13:44
has joined #general

yousafn
2022-05-06 22:54
Hi @laura.walsh, so sorry this has missed my radar! This sounds like a really interesting use case. One of co-founders, @bethskurrie is a Ruby :female_mage:. Also top marks for the diagram and really well structured and laid out question. Shining example of how to ask a great question in a community setting :ok_hand: A great question, deserves a great reply, but it's _super_ late here, so I will wrap my head around this over the weekend and get back to you.

akash.srivastava.1911
2022-05-08 09:38
has joined #general

mounaouar
2022-05-08 15:27
Thank you Matt, that answers my question!

kannan.jai
2022-05-08 21:18
Ah OK, this is the plan I can see we are on - Plan:Starter Plan Users:unlimited seats Contracts:30

bernard
2022-05-09 10:57
:wave: feature question/request from one of our engineers: Could Pact generate TypeScript bindings automatically?

matt.fellows
2022-05-09 10:57
From a pact file or something else?

matt.fellows
2022-05-09 10:58
If you had a pact file presumably you could easily convert that to TS types

matt.fellows
2022-05-09 10:58
But if you have created a pact file you already have a client so I'm not sure how useful that would be?

yousafn
2022-05-09 11:07
I have seen a package attempting it the other way round https://github.com/HLTech/pact-gen-ts > This project aims to create a package that can generate pact files only from TypeScript definitions (without the necessity of writing separated tests with using https://github.com/pact-foundation/pact-js package). but haven't used this yet, so cannot comment on its usefulness. On Pact -> TS Bindings, how do you mean? We use TS interfaces for say a Product interface and we use those interfaces in the pact interaction builder, so we get intellisense typing.

yousafn
2022-05-09 11:09
> But if you have created a pact file you already have a client so I'm not sure how useful that would be? Yep the Pact file would come after the interaction with the client, so it's a bit of a weird trip, you need to build up your req/res in the pact interaction, and make it in your client code, so you should have an interface. You can generate types/clients from your providers spec (oas) with tools I've seen in the wild

gustavs.slutins
2022-05-09 11:51
has joined #general

yhiamdan
2022-05-09 13:51
has joined #general

thomas.cederholm
2022-05-09 14:48
has joined #general

rakesh.arrepu
2022-05-09 15:22
has joined #general

yousafn
2022-05-09 16:22
Good communities are places where people :heart: to be. I'm committed to making our Pact community, the go to place for all things contract-testing but also for people to get to know each, connect, meet, share experiences and become life-long friends. So I looking to the OSS space, and have been introduced to https://orbit.love/ What is Orbit and why am I investigating it? As a Developer Advocate / Community Shepherd, I know that we have a huge amount of GitHub repositories and hold a huge amount of weight on our shoulders, to ensure that people can use Pact day-in day-out to protect their deployments. It's a hard job to keep track of. I'd love track our GitHub repo usage, health, and cross-correlate with Slack, so we can reach the right people quicker, and ultimately save leaving you hanging. I'd also love to build some tooling myself, but why reinvent the wheel, there is already plenty of stuff to do in Pact land! So why Orbit? I'll let them explain in their own words https://orbit.love/blog/why-orbit-is-better-than-funnel-for-developer-relations The picture added, came from their open-source https://github.com/orbit-love/orbit-model Additionally, I am looking at taking our evergreen Slack which is stored here :point_right: https://docs.pact.io/slack and https://github.com/pact-foundation/docs.pact.io#slack-history and making it look a bit prettier. A little teaser here :point_right::skin-tone-2: https://pact-slack.vercel.app/ In order to facilitate this, I will need to ? Remove 2 Slack integrations ? 1 to allow Orbit to be added ? 1 to allow for Pact Slack Archiver to be added ? Add Orbit to each public channel :memo: - Both integrations will read publicly available data, but will NOT be provided permissions to read private channels or DM's. We respect open-ness of conversation, as it is in the spirit of both Pact's core mission, and open-source, but we equally respect the right to privacy. :chart_with_upwards_trend: - For visibility, we will publish the results in our regular community updates that will happening in the future, alongside what is happening in the Pact foundation and the wider-community.

yousafn
2022-05-09 16:43
Hey @laura.walsh, have you seen this post out of interest? https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/ Matt pointed me to it when I asked about using SDK's. I think it seems correct that you have a pact between the client gem and consumer microservice. Do you have anything between your provider microservice and the client gem to tie the versions up? do you call can-i-deploy when deploying the provider microservice? you could call it asking if you could deploy between the gem and the consumer, providing the version of the pact relating to the gem, that is going to be used in the provider microservice build you wish to deploy

yousafn
2022-05-09 16:44
Would love to see a sample demo app, and this sounds like a super cool showcase, and I would be happy to help on it

mike.geeves064
2022-05-09 17:06
Orbit looks interesting, sounds like it makes sense from a quick skim through :slightly_smiling_face:

yousafn
2022-05-09 17:30
@mike.geeves064 :taco: testing the taco :slightly_smiling_face:

abhinavsharma333
2022-05-09 17:44
has joined #general

orbit
2022-05-09 17:49
has joined #general

matt.fellows
2022-05-09 21:18
Orbit does look great. I love their writing. I think the taco experiment was ?not that successful. I like the idea but it was never for something like this. If we needed to remove an integration to create some room, that would be :white_check_mark: with me.

mike.geeves064
2022-05-09 21:43
(think that was an unrelated "what's plugged into Pact/Slack, and does it still work" :slightly_smiling_face:)

yousafn
2022-05-09 21:45
We had simple poll, and polly, because two is better. It made me chuckle. Yo dawg, we herd you like pollin' Or keep polling, polling, polling. :musical_note: They are both gone now. :fire: We can have a round-table and work out what we want.

mike.geeves064
2022-05-09 21:46
wait what? you just removed one?

mike.geeves064
2022-05-09 21:46
both even

mike.geeves064
2022-05-09 21:46
without a poll to ask first? :joy:

yousafn
2022-05-09 21:47
51% of the people I didn't ask said yes

yousafn
2022-05-09 21:49
I don't think anyone will miss it for a few days. If anyone reading this needs a snap election, just holla and we shall bring one of them right back!

eric.barrow
2022-05-10 03:50
has joined #general

abubics
2022-05-10 05:50
I guess it might make more sense from a BDC perspective, but there are probably other tools for that already :thinking_face:

danielflieger
2022-05-10 06:58
Hey there! We are currently writing a POC for pact to test the tool in-house. We already have written a provider & consumer with jvm which support pact specification V4. Now we startet to write a consumer with pactJs which only support pact specification V2. So we were wondering if it could cause problems when consumer write pacts in different specification versions or is this something which handles the broker/pactflow by itself? Thanks.

matt.fellows
2022-05-10 07:00
Good question Daniel.

matt.fellows
2022-05-10 07:00
Basically, it?s the provider that?s the lowest common denominator

danielflieger
2022-05-10 07:04
Thank you for the fast feedback.

matt.fellows
2022-05-10 07:05
Sorry, didn?t finish (just joined a meeting :stuck_out_tongue: )

matt.fellows
2022-05-10 07:05
So, the spec version matters most to the _provider_

matt.fellows
2022-05-10 07:06
so if a consumer publishes a contract in V3 or V3 but the provider only supports up to V2, it won?t work

matt.fellows
2022-05-10 07:06
You can still specify the version to serialise in the consumer too. So if you are using Pact JVM which _can_ produce V4 pacts, you can still set the consumer tests to generate a V2 pact

danielflieger
2022-05-10 07:13
Are downwards compatible? So when the consumerA writes pacts in V4 & consumerB writes them in V2. Can the provider support both versions or should all parties use V2 then?

matt.fellows
2022-05-10 07:18
Yes, it can verify V4 and below in that example

matt.fellows
2022-05-10 07:19
so the consumers don?t need to be compatible with the same version

jyiyng2002
2022-05-10 08:24
newbie question: any QA / test enginner using pact. just wondering if this is tool for developer unit test or can be an good api test tool for QA as well.

rakesh.arrepu
2022-05-10 09:26
Could not able to view the link as below: https://docs.pactflow.io/docs/getting-started/#configuring-your-api-token Is there any change in the link? If yes, can you share me the new link?

yousafn
2022-05-10 09:31
Many thousands of QA / test engineers are using Pact, I was one of them before I joined Pactflow. Pact on the consumer side is traditionally used in component integration tests, alongside a assertion library such as Jest, mocha, chai in JavaScript and others in different languages. It is used for testing HTTP and message based clients, however you would use your code under test to issue your calls to your provider, rather than use Pact directly to issue your api request. You can use generate Pact contract files from the consumer side with Pact directly in various languages, or with one of our tool adapters. Is there some particular scenarios and approaches you are considering? What tools do you currently use?

yousafn
2022-05-10 09:33
Hey dude https://docs.pactflow.io/#configuring-your-api-token You can get to it via the homepage http://docs.pactflow.io Where did you grab the link from?

matt.fellows
2022-05-10 09:34
Looks like we have a broken link, I'll look later

yousafn
2022-05-10 09:34
Also there is a search box in the top right which can help

rakesh.arrepu
2022-05-10 09:37
Thank you for response. I will check in search

oprisor.cata24
2022-05-10 09:42
has joined #general

jonathan.rice
2022-05-10 10:50
has joined #general

carolyn.biggar
2022-05-10 14:08
Language support - SoftwareAG WebMethods Hello, my team provides APIs internally and relies on pact to manage change. We have a new internal consumer, an ESB team using SoftwareAG WebMethods . It's a long shot (!), but has anyone implemented consumer side pact testing in SoftwareAG WebMethods?

yousafn
2022-05-10 14:23
Hi @carolyn.biggar, Would be interested to hear from others here as well. Could you provide any background context on what SoftwareAG WebMethods are? ? any links? ? Do they support any open specification such as openAPI? Could you provide some detail on your current Pact setup at all? Cool to hear you are already using it for protecting your internally provided API's (sounds like a perfect use case)

yousafn
2022-05-10 14:25
Ron has been busy working on the pact-plugin framework https://github.com/pact-foundation/pact-plugins which might be interesting for different weird edge case languages https://github.com/pact-foundation/pact-plugins#background > Further, being able to add custom contract testing behaviour for bespoke use cases would be helpful in situations where we can't justify the effort to build into the framework itself (custom protocols in banking such as AS2805 come to mind).

yousafn
2022-05-10 14:26
That being said, if something is popular enough, we might see to make first class support with a more idiomatic interface

vijayasaratha.v
2022-05-10 14:28
has joined #general

carolyn.biggar
2022-05-10 14:34
:grimacing: I actually know very little about SoftwareAG WebMethods, (this looks like their https://www.softwareag.com/en_corporate/platform/integration-apis.html). It's used by another team internal to our company who manage integrations, mostly between legacy applications. I know it's a propriety "integration framework" and they use a test engine called https://www.cloudgensys.com/products-and-services/cloudgen-products/cate/ , but afraid I don't know much beyond that (sorry, not helping myself here am I!). From the chat we've had it sounds like opportunities to use open source / third party libraries may be limited. They will be calling our graphql api over http, from an http client provided (?) by WebMethods My team's way of working currently relies on all our consumers having pact tests, so we're trying to find a way that this new consuming team could manage that within their existing skillset. My team is kotlin and our existing consumers are all jvm, js or swift , so it's a bit of a leap.

carolyn.biggar
2022-05-10 14:35
(Thanks, taking a look at the plugins links :eyes: )

yousafn
2022-05-10 14:40
no worries and it is ok, to not know, so don't ever be afraid to ask :muscle: > (sorry, not helping myself here am I! What you have provided is incredibly helpful > My team's way of working currently relies on all our consumers having pact tests, so we're trying to find a way that this new consuming team could manage that within their existing skillset. Nice, proper decent way of working that! > My team is kotlin and our existing consumers are all jvm, js or swift , so it's a bit of a leap. I am polyglotting all over the place at the minute, so a bit of a leap of faith is all good. We will be there for you :raised_hands:

yousafn
2022-05-10 14:42
On the pact-plugins, and being a Java head, you can check out our hot of the press latest dev preview of the pact-plugins https://pact-foundation.slack.com/archives/CEQBDD5U4/p1652055827960579

yousafn
2022-05-10 14:42
Gives you a practical idea of how the plugins might work, I am half way through the examples, keep getting distracted

dimundo
2022-05-10 15:20
hi! `pending pact` s again :slightly_smiling_face: from https://docs.pact.io/pact_broker/advanced_topics/pending_pacts > 1. Consumer publishes a new pact with tag `main` that has a new unsupported interaction in it. what if i want to amend existing interaction (like enrich message with 1 more field) ? c-i-d in this case says, that pact is failed. do I do/understand something wrong ? so in this case i need 2 interactions ? 1 for old message, 1 for enriched?

radhika.madala
2022-05-10 18:10
has joined #general

oscar.lopez
2022-05-10 20:39
has joined #general

matt.fellows
2022-05-10 21:59
That would be a new pact for pending purposes

matt.fellows
2022-05-10 22:01
We're a little way from plugins being GA, but depending on what your primary language is (webmethids is Java or something else?) It could be the obvious answer soon

johnathan.pestano
2022-05-11 00:43
has joined #general

frank.kilcommins
2022-05-11 08:32
:wave: Hi everyone! I'm Frank and I'm an API Tech Evangelist at SmartBear. Delighted to join the community here and learn! Hopefully I can contribute positively back over time :raised_hands:

matt.fellows
2022-05-11 08:36
Welcome!

bethskurrie
2022-05-11 08:54
Hi @frank.kilcommins!

milda.abromaviciute
2022-05-11 12:47
has joined #general

fabio.rodrigues
2022-05-11 13:03
Hey there

matiasleandronunez
2022-05-11 13:22
has joined #general

croudet
2022-05-11 14:07
has joined #general

alex.bonstrom
2022-05-11 16:19
has joined #general

cody.sims
2022-05-11 16:45
has joined #general

harii.ravii
2022-05-11 22:02
has joined #general

harii.ravii
2022-05-11 22:10
Hi everyone! I?m new to PACT. I would like to know does PACT will work on Database contracts?

matt.fellows
2022-05-11 23:19
If you mean SQL queries or something, then I think the answer is probably no

matt.fellows
2022-05-11 23:19
can you elaborate a bit more on what you want to achieve exactly?

josh.kilazoglou
2022-05-12 04:17
has joined #general

poojakunder1997
2022-05-12 07:25
has joined #general

pekka.kiviniemi
2022-05-12 10:46
has joined #general

sophie.bosse2
2022-05-12 12:45
has joined #general

dimitris.schizas
2022-05-12 16:04
has joined #general

j.shankarnath
2022-05-12 16:37
has joined #general

yesh.veera
2022-05-12 17:35
has joined #general

fabio.been
2022-05-12 18:04
has joined #general

aliboztemir
2022-05-12 19:47
has joined #general

jordan.nazemi
2022-05-12 20:25
Hi, I had a few general question that came up during a conversation regarding our future implementation of bi-directional Pact testing to our pipeline I was wondering if I could get some input on: ? *When doing the API testing of a Provider whats the best way to deal with it further downstream providers?* For example, we have a cart-service that calls a promo-service when finalizing an order. If were setting up a contract where cart-service is the provider being tested using a Dredd implementation (like the workshop on bi-directional) would we want to mock the promo-service using a hook while running the API test? Should it instead still interact with a live version of the promo-service? If we do mock them, how we best ensure the mocked responses are accurate to the actual promo-service? ? *When using bi-directional in a pipeline whats a common method of removing the test-data generated during the API testing step?* Would you use, say, an afterAll hook set up in Dredd to clear the test data that was generated or should we mock those external database calls? Apologies if these are somewhat simplistic. I have some theories already but the development team requested I reach out to you guys for input.

matt.fellows
2022-05-13 03:24
> *When doing the API testing of a Provider whats the best way to deal with it further downstream providers?* For example, we have a cart-service that calls a promo-service when finalizing an order. If were setting up a contract where cart-service is the provider being tested using a Dredd implementation (like the workshop on bi-directional) would we want to mock the promo-service using a hook while running the API test? Should it instead still interact with a live version of the promo-service? If we do mock them, how we best ensure the mocked responses are accurate to the actual promo-service? WRT the contract test itself, it doesn?t really matter with BDC. The goal here is to ensure your provider is compatible with its OAS. This being said, I?d tend to want to run this is a unit-test like environment, and stub the downstream dependencies.

matt.fellows
2022-05-13 03:25
> *When using bi-directional in a pipeline whats a common method of removing the test-data generated during the API testing step?* Would you use, say, an afterAll hook set up in Dredd to clear the test data that was generated or should we mock those external database calls? I think there might be an assumption here is that you run this against a live environment. You can do this, but the answer is ?whatever you normally would do for a functional test of this environment?. I would, again, usually tend to want to do this in a controlled unit test-like environment, where this isn?t a problem

dimundo
2022-05-13 04:54
but question was more - if i as a consumer altering existing interaction - should it became pending or failing ?

matt.fellows
2022-05-13 05:28
It?s a new pact version, in that it has new requirements in it. It will be pending as far as the provider is concerned (subject to the usual pending calculations)

matt.fellows
2022-05-13 05:29
if the provider can?t support it (pending enabled or otherwise) the consumer?s `can-i-deploy` will still fail

dimundo
2022-05-13 05:37
> has a new unsupported interaction in it. then this doesn?t counts as new :slightly_smiling_face:

matt.fellows
2022-05-13 05:38
what do you mean, sorry?

dimundo
2022-05-13 05:44
```hi! pending pact s again from docs Consumer publishes a new pact with tag main that has a new unsupported interaction in it.``` some wording could be updated in docs

dimundo
2022-05-13 05:46
as it could be read as `only new interactions could be pending`

matt.fellows
2022-05-13 05:49
No, the pending status is at the _pact_ level, not the _interaction_ level.

matt.fellows
2022-05-13 05:50
If the contents of the pact changes at all, it is a new _pact_ (version) and if pending is enabled on the provider side, will be treating as a pending pact

dimundo
2022-05-13 05:50
thats clear :slightly_smiling_face:

luis.garcia
2022-05-13 09:06
has joined #general

nuno.frias
2022-05-13 09:34
Hello. We have two teams, one working on the consumer another on the provider. The provider team is finished with the provider and would like to verify the Pact, however the consumer is not yet in a state where the Pact test can be run to generate the Pact -- the consumer API is not generating the request. What is the best way to generate the Pact? (The only way I can think of is to mock the consumer request) Thank you

yousafn
2022-05-13 09:42
You _could_ replace the consumer request and make one directly (but this gives very limited confidence in your client code), however I am not sure what you are trying to achieve in terms of confidence. Are you looking to validate your provider meets its defined specification (not the consumers Pact contract). Or are you looking to test out the Provider verification pipeline? How incomplete is your consumer code? Do you have at least the API client part of it, that will call the provider service (which would be mocked in the consumer Pact test)

yousafn
2022-05-13 09:44
Personally I would invest the initial effort in attempting to get the Pact contract generated in the correct manner in your unit testing code, rather than working on anything else superfluous, but that depends on. your aims :slightly_smiling_face:

nuno.frias
2022-05-13 10:26
I am indeed trying to verify the provider meets the specification -- when the consumer is ready it will meed the same specification. I was trying to see if there was some manner in which I could generate a Pact without having to mock the consumer request -- but my suspicion was that there wasn't one. I agree with your suggestion to invest time to complete the consumer API, rather than mock the consumer, I'll forward it down to the consumer team.

yousafn
2022-05-13 10:54
Hey man, so here is a way you could generate a pact from a client, that is just a library for making requests. Here I use super test as the client. I should make not of this in my docs that this would be replaced by your client code under test https://github.com/YOU54F/template-jest-pact-typescript/blob/master/src/pact/client/json.pacttest.ts

nuno.frias
2022-05-13 12:45
Thank you. We are using Java, but I understand the approach. I am going to present it to the consumer team so they can decide whether to create a pact based on a mock request, or just build the client API.

bernard
2022-05-13 13:50
:wave: Hi I'm gathering company information for a vendor comparison at the company I work at. It would be a great help if I could get answers to the following points: ? *Company mission:* ? *Base:* Global (HQ PLACE, COUNTRY) ? *Capabilities:* ? *Customers / Awards / Scale (global)*

matt.fellows
2022-05-13 14:00
This is a general Pact channel, are you asking about Pactflow?

matt.fellows
2022-05-13 14:03
Could you please drop us a line at with some details about your role, company and the info above and I'll get somebody to respond?

andreas.wiig
2022-05-13 14:18
has joined #general

ocalderin14
2022-05-13 15:20
has joined #general


yousafn
2022-05-13 15:36
Hey do you want to raise an issue on the repo with some information please? https://github.com/pactflow/example-provider-springboot/issues I've just kicked off a build now :point_right: https://github.com/pactflow/example-provider-springboot/actions/runs/2320407061

b.1.alpha
2022-05-13 15:44
done


yousafn
2022-05-13 16:05
replied, has your colleague updated his token correctly

ocalderin14
2022-05-13 16:29
Hi team, was the type timestamp removed from PactDslJsonArray?

ocalderin14
2022-05-13 16:30
I'm trying to use this type with pact-jvm and I can't find it

jyoti.yennam
2022-05-13 17:28
has joined #general

yousafn
2022-05-13 18:12
Let's face it, Contract testing is hard. The Pact foundation has led the field in trying to help ease the world of integration testing hell built on the contributions of many. Community content is rife, blogs, workshops, tutorials, videos. If you are out there, I want to celebrate what you are doing. Let me know!

yousafn
2022-05-13 18:26
?Need inspiration? :thinking_face:? ?See some community videos and articles listed here :point_right::skin-tone-4:https://docs.pact.io/blogs_videos_and_articles :bulb:?

b.1.alpha
2022-05-13 18:58
Okay day 2 we swapped to personal pactflow repos, doing work independantly, using node instead of the example-provider-springboot and then we ran into another problem with my colleague where windows is broken https://github.com/pact-foundation/pact-js/issues/237

b.1.alpha
2022-05-13 19:01
We had him do the registry edit fix but that didnt work. So Monday what should we do. Examples dont work for Win11

b.1.alpha
2022-05-13 19:03
These are suppose to be my pact champions, so its an impressionable time, some extra support would be appreciated.

rberger
2022-05-13 21:06
has joined #general

uglyog
2022-05-14 08:00
use datetime instead

jsb0545
2022-05-15 18:55
has joined #general

matt.fellows
2022-05-16 01:20
The simplest quick fix is to move the project closer to the root drive (e.g. `c:/` )

matt.fellows
2022-05-16 01:21
Alternatively, the V3 package has dropped the Ruby core (the source of the issue) but is currently in beta: https://github.com/pact-foundation/pact-js/#pact-js-v3. The interface is stable enough, so you should be OK to use it. The last remaining feature is supporting message pact, which is not too far away.

leon.luu2
2022-05-16 06:43
has joined #general

samikshaphulzele
2022-05-16 09:53
has joined #general

thomas.cederholm
2022-05-16 19:16
I have one consumer, and one provider and between these I have two different APIs (it is a mono-repo that builds two different versions of an application, but for the sake of trying to keep it simple, lets just say there are two separate APIs, and both are to be tested before the "split" occurs). I have an IT (integration test) in which I want to test these; and I started out on the consumer side, having two `@Pact` methods, and two `@PactTestFor` methods. Each such method sends its own request with its json payload. Both tests have equal provider, and equal consumer identifier. I tried to separate them by using different strings for the "given" statement in each test. That seemed to work, until the provider test ran. So, I tried two different tests on the Provider to, one where I filter out the "first given", and another where I filter the "second given", but the tests fail since not all interactions get recorded.

shiva.idc
2022-05-17 00:33
has joined #general

rholshausen
2022-05-17 00:37
The best way would be to change two different consumer IDs, maybe put a suffix depending on the API

thomas.cederholm
2022-05-17 05:16
Thank you, I will try that!

thomas.cederholm
2022-05-17 06:00
@rholshausen Do I need to think about something on the provider side of this? It would receive pacts for both consumers, right..?

rholshausen
2022-05-17 06:09
Yes, that is fine. Both will be verified

thomas.cederholm
2022-05-17 06:10
What if I have two tests in provider.. do I need a filter of some kind?

thomas.cederholm
2022-05-17 06:10
or.. do I need two providers then as well?

thomas.cederholm
2022-05-17 06:11
Maybe that is just the easiest way.. I thought it would be nice to have a smaller "matrix" but maybe that is not that important

rholshausen
2022-05-17 06:19
No, the provider test can test both pact files

rholshausen
2022-05-17 06:19
You only need one provider test

thomas.cederholm
2022-05-17 06:19
Thank you!

ocalderin14
2022-05-17 09:08
Hi @uglyog, should I use datetime with any other parameter? because it is not working for me

thomas.cederholm
2022-05-17 09:21
@rholshausen I still cant get my head around this... I now have: Consumer: "consumer1" -> "provider1" (one junit test for api 1) "consumer1" -> "provider2" (one junit test for api 2) Provider: provider1 junit test that should test consumer1 (api1), breaks because: ```Did not find a test class method annotated with @State("api2") for Interaction "[name for api2 interaction]" with Consumer "consumer1"``` provider2 junit test that should test consumer1 (api2), breaks because: ```Did not find a test class method annotated with @State("api1") for Interaction "[name for api1 interaction]" with Consumer "consumer1"```

thomas.cederholm
2022-05-17 09:21
Do I need tags or something to filter more?

thomas.cederholm
2022-05-17 09:22
I cannot have one single provider, since the provider uses either api1 OR api2 when it is running.

thomas.cederholm
2022-05-17 09:22
and the Pact test starts the application, starts testcontainers etc, and we try to process the request from Pact to verify it works.

ocalderin14
2022-05-17 09:23
this is what I'm doing ```.body(PactDslJsonArray.arrayMinLike(1) .stringType("transactionHash") .stringType("originWallet") .stringType("destinationWallet") .decimalType("amount", 1.0) .datetime("creationDate") .stringType("method") .stringType("status") .decimalType("fee") ).toPact();```

ocalderin14
2022-05-17 09:24
my consumer tests are passing but the when I'm running my provider tests I'm receiving this error

ocalderin14
2022-05-17 09:24
1.1) body: $.0.creationDate Expected 1652738400000 to match a datetime of 'yyyy-MM-dd'T'HH:mm:ss': Unable to parse the date: 1652738400000

ben.pilgrim
2022-05-17 10:07
Do you need to annotate pacts with tags as well as branches to be able to use pendingPacts?

matt.fellows
2022-05-17 10:20
No, you can use tags OR branches (or both)

ben.pilgrim
2022-05-17 10:22
So I can set the providerTags parameter in the Java jUnit 5 verification to the branch name? (Happy to post this in #pact-jvm if that?s more appropriate)

matt.fellows
2022-05-17 10:24
hmm best asked in pact jvm

matt.fellows
2022-05-17 10:24
I don?t know if JVM supports branches yet off the top of my head

matt.fellows
2022-05-17 10:24
(I can take a look later)

ben.pilgrim
2022-05-17 11:26
Looks like the support is mixed

matt.fellows
2022-05-17 11:29
OK, so the main Java API does not yet support branches, but you can do it with JSON in the relevant system property: https://github.com/pact-foundation/pact-jvm/pull/1471

matt.fellows
2022-05-17 11:29
(basically, that bypasses the usual validation and just passes JSON straight to the broker)

joseph.joyce
2022-05-17 12:15
has joined #general

vasanth.s
2022-05-17 13:36
has joined #general

sri.kasturi
2022-05-17 14:21
has joined #general

lewiscowles
2022-05-17 20:31
Is anyone from the internal team around to talk about https://pact-foundation.slack.com/archives/C9WTB2JDV/p1652787536711159 it looks like the issue this attempts to resolve has been present for some time.

harii.ravii
2022-05-17 21:40
Sorry for the late reply. I got it ..basically looking for SQL..

carlosh.carmo2
2022-05-17 22:43
has joined #general

matt.fellows
2022-05-18 00:50
I don?t fully understand what you want to test with contract testing here? But I?d suggest contract testing is not going to be the best tool for the job here.

gchursov
2022-05-18 09:43
has joined #general

berk.safranbolulu
2022-05-18 10:18
has joined #general

bernard
2022-05-18 11:11
Thanks @matt.fellows I've sent a few emails.

david.uzumaki
2022-05-18 11:34
I only just realised that `--pacticipant` is spelt as ?pact? and not `participant` in the cli tool nice pun haha

larshoogma
2022-05-18 11:34
has joined #general

anja.gruss
2022-05-18 12:02
anyone encounter "Error parsing json" when uploading the OAS to the broker? happens both for yml and json file, the file is created by springdoc-openapi and generates a 3.0.1 openapi version file which seems valid to my ide


matt.fellows
2022-05-18 12:12
@bethskurrie did this years ago, and has never heard the end of it :rolling_on_the_floor_laughing:

malvika0810
2022-05-18 12:17
has joined #general

nishant.shah
2022-05-18 13:38
has joined #general


karl
2022-05-19 08:59
Hey guys, I have a question. In contract testing, is is possible to use Consumer-Driven-Contract-Testing to test towards a 3rd party API which one does not control (for example a Google Service API)? If so, how would one go about doing this?

yousafn
2022-05-19 09:34
Hey, You can, but it is not advised https://docs.pact.io/getting_started/what_is_pact_good_for#what-is-it-not-good-for You run the verifier as standalone https://docs.pact.io/implementation_guides/cli#provider-verifier We introduced Bi-Directional as a way of providing static schema based testing and eliminate some of the verification pains, for situations users were using traditional CDCT, or wished to, for a workflow that wasn't quite suited. With BDCT, the key difference is that a Provider uploads its own provider contract advertising its full capability which is statically compared to the expectations in the consumer contract - the consumer contract is never replayed against the provider code base. This creates a much https://docs.pactflow.io/docs/bi-directional-contract-testing#comparison-to-pact and decoupled workflow. See the https://docs.pactflow.io/docs/bi-directional-contract-testing#trade-offs for more. With CDCT, you need to write and maintain a separate set of (Pact) tests that are responsible for ensuring systems are compatible. The tests on the consumer side produce a consumer contract containing the example scenarios which must be supported for the consumer to work, which are then replayed against an _actual running provider_ in a record and replay style interaction. If the Provider responds correctly, the contract is valid. https://docs.pact.io/getting_started/provider_states are used to setup the test conditions for assertions on the Provider side, see here for the https://docs.pact.io/getting_started/testing-scope#scope-of-a-provider-pact-test

karl
2022-05-19 09:55
Thanks!

matt.fellows
2022-05-19 10:05
Yeah. I think we did an AMA on this a while ago too (or at least it was a question).

matt.fellows
2022-05-19 10:05
Search AMA in the http://docs.pact.io website for that

vorashil.farzaliyev
2022-05-19 10:59
has joined #general

matt.fellows
2022-05-19 11:07
Whilst not a Pact specific feature, we do have a workflow similar to described in Pactflow: https://docs.pactflow.io/docs/bi-directional-contract-testing. Upload OAS as a provider contract (ideally verified to be valid, but in the case of a 3rd party you?ll just have to trust they have tested their API), generate a consumer contract and Pactflow will ensure they stay compatible.

vorashil.farzaliyev
2022-05-19 11:09
Hi all. Apologies, if it?s not the right channel, but I have been trying to publish our contracts to PactFlow. The following command works and publishes the contracts from my local machine but it fails with the following error from the CI. Can you please suggest what could be the issue? Command: ```docker run --rm \ -w "${PWD}" \ -v "${PWD}:${PWD}" \ -e PACT_BROKER_BASE_URL \ pactfoundation/pact-cli:latest \ broker publish "${PWD}/build/pacts" \ --consumer-app-version "$PACT_VERSION" \ --branch "$GIT_BRANCH" \ --broker-base-url "$PACT_BROKER_BASE_URL" \ --broker-token "$PACTFLOW_TOKEN" \``` Error on CI: ```Specified pact file '/godata/pipelines/currency-conversion-library/currency-conversion-library/build/pacts' does not exist. This sometimes indicates one of the arguments has been specified with the wrong name and has been incorrectly identified as a file path.``` I can provide more logs if needed. Currently I have checked everything I could think of, including whether the environmental variables are set or the pacts folder has a json file in it. The only difference between my local machine and GoCD pipeline is the docker version. (My machine runs v20, while GoCD runs v19). Can you please suggest what else I can try to check here? Or is there any other way of publishing pacts from CI/CD other than this docker image

yousafn
2022-05-19 11:34
Is there pacts in the folder you are targeting on the machine before mounting in the imagine? Can you output or see build artefacts, or can you ssh into your building machine and run the command and inspect the container. I think you would need to remove the rm command to avoid killing the container to inspect and pull any files with docker cp

bernard
2022-05-19 13:04
:clap: :clap: :clap: Congratulations on the sale to SmartBear :clap: :clap: :clap:

jlcrazzy
2022-05-19 13:38
has joined #general

galveznairon
2022-05-19 13:40
has joined #general

vorashil.farzaliyev
2022-05-19 13:51
Yes, there are pacts in the targeted folder. Not sure if the attached volumes takes them too. There is no reason for the volume to ignore that file as it works just fine locally. Unfortunately, I cannot ssh into the machine running these as it?s a disposable agent in CI/CD. Think each agent runs in a container, and this problem might be caused by running docker command in docker container

vorashil.farzaliyev
2022-05-19 13:51
But there is not other option I can think of, other than installing the pact cli on each build, which is not ideal I think

yousafn
2022-05-19 14:21
The CLI is available standalone or you can publish manually via an API call https://docs.pact.io/pact_broker/client_cli which may help, if you are in Dockerception (DockerInDocker)

vorashil.farzaliyev
2022-05-19 14:27
I couldn?t find docs for publishing manually via API. Is it supposed to be on this page?

yousafn
2022-05-19 14:32
https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts#publishing I just searched publishing pacts, this is the first result. The exact bit you'd be looking for is referenced in this section https://docs.pact.io/pact_broker/publishing_and_retrieving_pacts#publish-using-http-requests We've always advocated for use of the cli tools directly over the apis, but there is duplication, repitition and omissions across the docs that we are looking to address to make a cohesive experience. However in defence of the documentation, the search functionality is pretty good and is quicker than waiting for a slack reply. All feedback welcome :)

vorashil.farzaliyev
2022-05-19 14:36
Yeah, apologies. I have been frustrated by this last couple days, so probably my first instinct should have been google search. :slightly_smiling_face: Which eventually led me to https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/doc/views/index/publish-contracts.markdown anyways, but was hoping maybe you have some better sources available. Thanks again for the support

yousafn
2022-05-19 14:55
Sorry, I meant a search in the top right of https://docs.pact.iohttps://docs.pact.ioas we pull in all the readmes from the repos and display them on the site so it's one of the best ways to search across the docs. Google is a bit of a Wild West sometimes. Can appreciate the frustrations, so no need to apologise my friend

yousafn
2022-05-19 14:57
I can point you to examples in code of calling the api directly via bash, albeit not for that endpoint but it may help. This is for a provider contract publish https://github.com/pactflow/example-bi-directional-provider-restassured/blob/master/scripts/publish.sh

harii.ravii
2022-05-19 20:05
Matt, Ignore my previous question. I went through pact documentation and got pact is only used for contracts. I have one more question..I want to publish the contract to the pact broker and my contract has timestamp data. Please let me know is it possible to change the time stamp data when the producer consumes the pact contract from the broker.

sunny.cheung
2022-05-19 20:43
has joined #general

matt.fellows
2022-05-20 00:36
the answer is ?it depends?. In some languages you can


matt.fellows
2022-05-20 00:37
There are also things called ?request filters? that can let you modify the request body too

harii.ravii
2022-05-20 01:21
Thanks Matt. This helps

matt.fellows
2022-05-20 04:23
So i?m very inclined to trust the error. One thing you can do, is add `--verbose` to the command to see if it gives you any additional insights

matt.fellows
2022-05-20 04:23
If you can please print out (prior to running the docker command) the value of `${PWD}` so we see what the mapping is

matt.fellows
2022-05-20 04:24
I?d also like to see an `ls -la` on `/godata/pipelines/currency-conversion-library/currency-conversion-library/build/pacts`

matt.fellows
2022-05-20 04:25
in my experience, these types of errors tend to be small pipeline problems that?n aren?t visible - e.g. maybe the pact test itself is failing and is not producing the file or something else is cleaning up between steps.

chantalnitz
2022-05-20 07:22
has joined #general

bethskurrie
2022-05-20 07:47
Thanks @bernard! The last 3 years have been intense but rewarding, and we're looking forward to what's going to happen over the next few.

robert
2022-05-20 08:47
has joined #general

kannan.jai
2022-05-20 09:04
Hello Team, question - Consider I have a pact interaction between ConsumerA version is 3.24.0 and tagged DEV and ProviderA version 1.9.0 and tagged DEV (this is the pact from the deployed code to DEV env). Now, there is a PR which is created against ConsumerA which runs consumer contract tests and publishes pact - tagged with the branch name as lets say PR-2 and version as commit ID, the same PR job will also trigger provider verification for ProviderA against this pact (passing the consumer tag as PR-2). Everything goes well and the code gets merged, now we have two pact interaction as shown below. Now I want to deploy this merged code (ConsumerA) to DEV, so I run "$ pact-broker can-i-deploy --pacticipant ConsumerA --version gitcommit --to DEV" to check which would pass and the code is deployed to DEV. Question: How would I now update the last verified pact interaction to reflect the version of the actual service (which would be lets say 3.25.0)?

baris.kucuk.atilim
2022-05-20 09:47
has joined #general

rajnavakoti
2022-05-20 12:42
has joined #general

jbecker
2022-05-20 17:17
Hey! General pact question (I think). I wrote this little consumer contract test and it seems to be working, and when I go to verify it in the provider it still seems to work, but when I intentionally "break" the provider and have it return `has_bugs: True` the pact still verifies successfully. I'm not sure exactly what I did wrong, but I'm assuming there's a way to have a contract depend on _specific_ values for some contract tests, yes?

jbecker
2022-05-20 17:31
So I circled `body=Like(expected)` here because I wasn't sure if that was my fix or not. That's what I'm experimenting with now. If that's all it was, I'll feel silly, but I'll probably still leave this post for posterity.

jbecker
2022-05-20 18:13
Yeah, looks like that did the trick :thumbsup:

berk.safranbolulu
2022-05-20 20:26
Hello, I?m little bit confused about *Lexical Scope vs Lexical Environment in JavaScript.* In this following code: ```function doSomething() { var age = 7; // Some more code }``` What are the lexical scope and lexical environment of `age` variable? Are they same? As far as I know, Lexical Scope is the place that is defined any variable, function, or expression. What?s the difference from Lexical Environment? With this Lexical Scope knowledge, we are able to know which scope can access to age variable, and age variable can access which scope as well. Am I right? What do you think?

mlund
2022-05-20 21:04
has joined #general

pavi.dealwis
2022-05-21 03:28
has joined #general

tjones
2022-05-21 04:32
Yes, `Like` means "like this type". So, it will accept any boolean.

tjones
2022-05-21 04:33
This question is off topic for this slack space, which is for questions about pact.

tjones
2022-05-21 04:34
For the answer to your question, this blog post looks like a reasonable summary (I didn't read it closely)


berk.safranbolulu
2022-05-21 08:44
Thank you @tjones :thumbsup:

endika2
2022-05-21 10:52
has joined #general

6eo2ge
2022-05-22 13:17
has joined #general

eugene.baranovsky
2022-05-22 23:25
has joined #general

rarora
2022-05-23 03:03
Hi Team I need to configure webhook on provider in gitlab. Gitlab supports data only in form of form variables. How can I configure webhook to send form data? I tried following ```curl --location --request POST 'https://pact-broker.rcue102.viatorsystems.com/webhooks/consumer/event-service' \ --header 'Content-Type: application/json' \ --data-raw '{ "consumer": { "name": "event-service" }, "provider": { "name": "product-service" }, "request": { "method": "POST", "url": "https://gitlab.dev.tripadvisor.com/api/v4/projects/{id}/trigger/pipeline", "headers": { "Accept": "multipart/form-data" }, "body": { "token": "TOKEN", "ref": "develop", "PIPELINE_LIBRARIES": "contract_verification,no_common", "PACT_CONSUMER_TAG": "${pactbroker.consumerVersionTags}" } }, "events": [ { "name": "contract_content_changed" } ] } '```

rarora
2022-05-23 03:03
curl i need to call is: ```curl --request POST \ --form token=TOKEN \ --form ref=develop \ --form "variables[PIPELINE_LIBRARIES]=contract_verification,no_common" \ "https://gitlab.dev.tripadvisor.com/api/v4/projects/${PROJECT_ID}/trigger/pipeline"```

harris
2022-05-23 03:04
has joined #general

matt.fellows
2022-05-23 03:07
Multipart values presumably would go in the body as key/value pairs

matt.fellows
2022-05-23 03:07
i.e. it?s not JSON

rarora
2022-05-23 03:08
yes so above curl should be correct?

rarora
2022-05-23 03:08
but gitlab is not receiving form data

matt.fellows
2022-05-23 03:11
from the curl or the webhook?

rarora
2022-05-23 03:12
from the webhook

matt.fellows
2022-05-23 03:12
right

matt.fellows
2022-05-23 03:12
the webhook is posting JSON, not form values


rarora
2022-05-23 03:14
do you have any example how i can pass key value pairs?

rarora
2022-05-23 03:15
i thought i sent key value pair in body

rarora
2022-05-23 03:16
can you format this request, how you think it might work ```"request": { "method": "POST", "url": "https://gitlab.dev.tripadvisor.com/api/v4/projects/{id}/trigger/pipeline", "headers": { "Accept": "multipart/form-data" }, "body": { "token": "TOKEN", "ref": "develop", "PIPELINE_LIBRARIES": "contract_verification,no_common", "PACT_CONSUMER_TAG": "${pactbroker.consumerVersionTags}" } },```

matt.fellows
2022-05-23 03:17
that?s json

matt.fellows
2022-05-23 03:17
body: ?key=value&key2=val2??

matt.fellows
2022-05-23 03:17
I?ll leave it with you to experiment from there.

rarora
2022-05-23 03:18
i tried it as above thinking it might work as query param

rarora
2022-05-23 03:18
it did not work either

rarora
2022-05-23 03:18
let me paste curl i tried

rarora
2022-05-23 03:19
```curl --location --request POST 'https://pact-broker.rcue102.viatorsystems.com/webhooks/consumer/event-service' \ --header 'Content-Type: application/json' \ --data-raw '{ "consumer": { "name": "event-service" }, "provider": { "name": "product-service" }, "request": { "method": "POST", "url": "https://gitlab.dev.tripadvisor.com/api/v4/projects/p1/trigger/pipeline?token=TOKEN&ref=develop&PACT_CONSUMER_TAG=${pactbroker.consumerVersionTags}&PIPELINE_LIBRARIES=contract_verification,no_common", "headers": { "Accept": "multipart/form-data" } }, "events": [ { "name": "contract_content_changed" } ] } '```

rarora
2022-05-23 03:22
is the above request similar to what you thought?

matt.fellows
2022-05-23 03:23
no, the key value pairs need to be on the `body`

matt.fellows
2022-05-23 03:23
it might be worth you googling how multipart forms are sent over HTTP. I think it will help you construct the webhook

rarora
2022-05-23 03:23
checking

rarora
2022-05-23 03:24
i did check before asking, most of them are suggesting curl, or sending as data but will try to check more

matt.fellows
2022-05-23 03:26
sure but curl is a specific tool, the broker doesn?t use curl to send these requests

abhiattipra
2022-05-23 06:04
has joined #general

max.bruns
2022-05-23 07:13
has joined #general

hello560
2022-05-23 12:23
has joined #general

hello560
2022-05-23 12:36
Hello, just starting to mess about with contract testing, and I have an issue where a consumer has published a contract tagged with a feature branch name. When I try to verify said contract from the provider (no webhook flow set up yet), I can't seem get any verification of said feature branch to take place. I've tried using `--include-wip-pacts-since` with a date well into the past but nothing. Am I totally misunderstanding how this is supposed to work?

yousafn
2022-05-23 12:45
:wave: Could you please provide ? which client language and version ? which tags/branches/command are you using to publish ? which provider language and version ? which filters are you using to pull down ? which pact file specification version



hello560
2022-05-23 12:58
I'll do my best to provide the information you asked for, I've put in some placeholders. Client language: PHP, version: 7.1.1 Branch being published: `dev-3808` Command being used to publish contract: `docker run --rm pactfoundation/pact-cli:latest publish ./pact --consumer-app-version 11.16.116-80952e64 --branch dev-3808 --broker-base-url <broker base URL here>` (the above runs fine, shows up in the UI with the correct values) Provider language: Go, although I'm using `pact-provider-verifier` , version http://1.36.at at the moment Verification command: `pact-provider-verifier --broker-base-url=<broker base url here> --provider-base-url=http://localhost:8000 --provider=<provider name here> --enable-pending --include-wip-pacts-since=2022-05-01 --provider-app-version=1.1.6 --provider-version-branch=master --consumer-version-selector='{"tag":"master","latest":true}'` Pact file specification version: 2 (the above only verifies `master` for its consumer while I would've hoped it'd verify the `dev-3808` branch mentioned earlier)

yousafn
2022-05-23 13:07
I think you want to use branch in your `consumerVersionSelector` for co-ordinated development `--consumer-version-selector='{ "branch": "<branch>", "fallbackBranch": "master" }'` I don?t _think_ you can use `tag` or `latest`, as you aren?t _tagging_ in your consumer, you are using `branches` which is excellent :angel: > `tag`: the tag name(s) of the consumer versions to get the pacts for. _This field is still supported but it is recommended to use the `branch` in preference now._ > > `latest`: true. Used in conjuction with the `tag` property. If a `tag` is specified, and `latest` is `true`, then the latest pact for each of the consumers with that tag will be returned. If a `tag` is specified and the latest flag is _not_ set to `true`, _all_ the pacts with the specified tag will be returned. (This might seem a bit weird, but it?s done this way to match the syntax used for the matrix query params. See https://docs.pact.io/selectors). I may be totally wrong tho, so happy to be corrected :slightly_smiling_face:

hello560
2022-05-23 13:11
> `--consumer-version-selector='{ "branch": "<branch>", "fallbackBranch": "master" }'` I thought the point of WIP pacts was to not have to manually specify what consumer feature branches to verify. Am I incorrect in thinking that?

hello560
2022-05-23 13:13
Just to be clear: I'm trying to verify a feature branch contract from the provider _master_. Which might very well be the wrong way of going about things, I'm still very new to all this.

yousafn
2022-05-23 13:24
I?m not 100% clear on pending pact vs work in progress pacts, especially with the move from tags -> branches at the moment, so I will do some reading, get some clarity and get back to you. just for my own clarity, have you got a verified pact between your consumer and provider on the master branches, and these are deployed to an environment? you now are introducing a change on a consumer branch, which you are trying to verify against the providers master build. Which version of the broker are you using? Pactflow or OSS 2.60.0+ Thanks for the questions though, you are in the right place and welcome to the contract testing journey

hello560
2022-05-23 13:25
> just for clarity, have you got a verified pact between your consumer and provider on the master branches, and these are deployed to an environment? Yes > you now are introducing a change on a consumer branch, which you are trying to verify against the providers master build. Correct > Which version of the broker are you using? Pactflow or OSS 2.60.0+ Pactflow

hello560
2022-05-23 13:30
The help is appreciated, by the way :slightly_smiling_face: Contract testing seems like a potential cure for a lot of problems I've had over the years.

jbecker
2022-05-23 14:05
Anyone have any suggestions for dynamically running pact provider verifications whenever can-i-deploy says that they don't yet exist?

yousafn
2022-05-23 14:10
So I?ve just tested this out, Using this on the consumer side (publishing with branch) ? https://github.com/pactflow/example-consumer/blob/3fb6acb42274a29e0f17d3913cf567aa37a73b1d/Makefile#L40 ? Updating to use `--branch` ? `@"${PACT_CLI}" publish ${PWD}/pacts --consumer-app-version ${GIT_COMMIT} --branch ${GIT_BRANCH}` leads to not finding anything on the provider side, when specifying `tag` not `branch`. ? https://github.com/pactflow/example-provider/blob/master/src/product/product.pact.test.js#L34 ? `consumerVersionSelectors: [{ tag: 'master', latest: true }, { deployed: true } ]` If both the consumer and provider use `tag` everything matches up, or if they both use `branch` they match up. If I then publish a failing consumer pact on a branch, it won?t be validated until I enable the https://docs.pact.io/pact_broker/advanced_topics/wip_pacts ``` enablePending: true, includeWipPactsSince: "2022-05-01",``` https://github.com/pactflow/example-provider/blob/master/src/product/product.pact.test.js#L36-L37

hello560
2022-05-23 14:19
So, after enabling `includeWipPactsSince`, that feature branch contract gets verified for you? How odd, I can't see anything you've suggested that is different to what I've done, and yet, it does not work for me :disappointed:

yousafn
2022-05-23 14:20
I can see you are publishing with `--branch` but verifying with `tag`

yousafn
2022-05-23 14:21
*Before* publish contract: `docker run --rm pactfoundation/pact-cli:latest publish ./pact --consumer-app-version 11.16.116-80952e64 --branch dev-3808 --broker-base-url <broker base URL here>` Verification command: `pact-provider-verifier --broker-base-url=<broker base url here> --provider-base-url=http://localhost:8000 --provider=<provider name here> --enable-pending --include-wip-pacts-since=2022-05-01 --provider-app-version=1.1.6 --provider-version-branch=master --consumer-version-selector='{"tag":"master","latest":true}'` *After* using only `branch` publish contract: `docker run --rm pactfoundation/pact-cli:latest publish ./pact --consumer-app-version 11.16.116-80952e64 --branch dev-3808 --broker-base-url <broker base URL here>` Verification command: `pact-provider-verifier --broker-base-url=<broker base url here> --provider-base-url=http://localhost:8000 --provider=<provider name here> --enable-pending --include-wip-pacts-since=2022-05-01 --provider-app-version=1.1.6 --provider-version-branch=master --consumer-version-selector='{"branch":"master","latest":true}'` using only `tag` publish contract: `docker run --rm pactfoundation/pact-cli:latest publish ./pact --consumer-app-version 11.16.116-80952e64 --tag dev-3808 --broker-base-url <broker base URL here>` Verification command: `pact-provider-verifier --broker-base-url=<broker base url here> --provider-base-url=http://localhost:8000 --provider=<provider name here> --enable-pending --include-wip-pacts-since=2022-05-01 --provider-app-version=1.1.6 --provider-version-branch=master --consumer-version-selector='{"tag":"master","latest":true}'`

hello560
2022-05-23 14:25
I tried it with `branch` in both places just now, too, there is no difference for me. > DEBUG: The pact at <pact url here> is being verified because the pact content belongs to the consumer version matching the following criterion: > * latest version from branch 'master' (<latest version in master here>) Is the only output regarding branches I get for that consumer.

hello560
2022-05-23 14:27
But since it works for you I imagine I've messed something up, unfortunately I have no clue what that'd be.

christoph.oswald
2022-05-23 14:27
Hi, I am having a conceptional question. I am trying to setup a contract between two services. A (consumer) and B(provider). To secure the communication a header is injected by a running side-container, so A actually does not know about this security header. Service B however needs this header to verify the user etc, and it is always checked before handling the requests. Where would I place setting up this header? As part of the consumer-contract? Even though the application A does not really know about it or on the provider side? At the moment I would implement a state "user exists" or "user is authenticated" in the consumer pact and try to setup this header somehow in the provider. Is this the way to go?

yousafn
2022-05-23 14:33
:thinking_face: hmm yeah not entirely sure there buddy. I?ve just taken the two canonical examples https://github.com/pactflow/example-consumer https://github.com/pactflow/example-provider (this is JS but we do have a Go version https://docs.pactflow.io/docs/examples/golang/provider/) This is the output after switching on the WIP feature, otherwise it wouldn?t find the branch. If you could create a sample GH repo, we could take a look at some point, or if you want to start with those two repos and have a go, you can just fork them, set your env vars and run `make fake_ci` to easily run it from your machine and cross compare. ```{ "_embedded": { "pacts": [ { "shortDescription": "latest from branch master", "verificationProperties": { "pending": false, "notices": [ { "when": "before_verification", "text": "The pact at https://saf.pactflow.io/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/pact-version/4a6c2017e4f913c5b18ee0b526eae842567bf489 is being verified because the pact content belongs to the consumer version matching the following criterion:\n * latest version from branch 'master' (ac94418+1653314421)" }, { "when": "before_verification", "text": "This pact has previously been successfully verified by a version of pactflow-example-provider with tag 'master'. If this verification fails, it will fail the build. Read more at https://docs.pact.io/go/pending" } ] }, "_links": { "self": { "href": "https://saf.pactflow.io/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/pact-version/4a6c2017e4f913c5b18ee0b526eae842567bf489/metadata/c1tdW2JdPW1hc3RlciZzW11bbF09dHJ1ZSZzW11bY3ZdPTM5JnA9ZmFsc2U", "name": "Pact between pactflow-example-consumer (ac94418+1653314421) and pactflow-example-provider" } } }, { "shortDescription": "latest from branch wip_pact", "verificationProperties": { "pending": true, "wip": true, "notices": [ { "when": "before_verification", "text": "The pact at https://saf.pactflow.io/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/pact-version/b4d89ebc01885acfd726f527182ca47f8abc712c/metadata/d2lwPXRydWU is being verified because it is a 'work in progress' pact (ie. it is the pact for the latest version of pactflow-example-consumer from branch 'wip_pact' and is still in pending state). Read more at https://docs.pact.io/go/wip" }, { "when": "before_verification", "text": "This pact is in pending state for this version of pactflow-example-provider because a successful verification result for a version of pactflow-example-provider with tag 'master' has not yet been published. If this verification fails, it will not cause the overall build to fail. Read more at https://docs.pact.io/go/pending" }, { "when": "after_verification:success_true_published_false", "text": "This pact is still in pending state for any version of pactflow-example-provider with tag 'master' as the successful verification results with this tag have not yet been published." }, { "when": "after_verification:success_false_published_false", "text": "This pact is still in pending state for any version of pactflow-example-provider with tag 'master' as a successful verification result with this tag has not yet been published" }, { "when": "after_verification:success_true_published_true", "text": "This pact is no longer in pending state for any version of pactflow-example-provider with tag 'master', as a successful verification result with this tag has been published. If a verification for a version of pactflow-example-provider with this tag fails in the future, it will fail the build. Read more at https://docs.pact.io/go/pending" }, { "when": "after_verification:success_false_published_true", "text": "This pact is still in pending state for any version of pactflow-example-provider with tag 'master' as a successful verification result with this tag has not yet been published" } ] }, "_links": { "self": { "href": "https://saf.pactflow.io/pacts/provider/pactflow-example-provider/consumer/pactflow-example-consumer/pact-version/b4d89ebc01885acfd726f527182ca47f8abc712c/metadata/dz10cnVl", "name": "Pact between pactflow-example-consumer (520ecb6+1653314859) and pactflow-example-provider" } } } ] }, "_links": { "self": { "href": "https://saf.pactflow.io/pacts/provider/pactflow-example-provider/for-verification", "title": "Pacts to be verified" } } }```

venky.hodigere
2022-05-23 14:54
has joined #general

prerit.jain
2022-05-23 16:27
has joined #general

evan
2022-05-23 16:48
has joined #general

manuel.porto
2022-05-23 17:56
has joined #general

matt.fellows
2022-05-23 23:04
If the consumer doesn?t know about it, it doesn?t belong in the consumer side

matt.fellows
2022-05-23 23:04
it sounds like a provider implementation detail, so should be part of the provider verification

matt.fellows
2022-05-23 23:05
Presumably, the side container must get some context from the consumer. Provider states could potential be part of the solution


bethskurrie
2022-05-24 00:04
You can simulate workflows using this so you don't have to actually write and verify the pacts. it's much quicker https://github.com/pact-foundation/pact_broker/blob/master/ISSUES.md

bethskurrie
2022-05-24 00:05
I thought I'd made the branches and tags play together nicely for WIP and pending, but it's possible that I've missed something.

bethskurrie
2022-05-24 00:05
definitely use branches if you have the option.

bethskurrie
2022-05-24 00:10
I've made a script that you can play around with here https://github.com/pact-foundation/pact_broker/blob/master/script/data/wip.rb

bethskurrie
2022-05-24 06:26
@jbecker the new webhook is designed to do exactly that


bethskurrie
2022-05-24 06:27
If you can't use webhooks, then there is an alternative "webhookless flow" documented here https://docs.pact.io/pact_nirvana/step_6#alternative-webhookless-workflow

bethskurrie
2022-05-24 06:31
There is a `verification-required` command in the CLI that is designed for this. I need to remove the feature toggle on it, but you can use it now https://github.com/pact-foundation/pact_broker-client/blob/master/lib/pact_broker/client/cli/matrix_commands.rb#L42

abhishek.lamba
2022-05-24 09:25
has joined #general

stefan.friese
2022-05-24 09:32
has joined #general

bharath.shetty
2022-05-24 09:33
has joined #general

jbecker
2022-05-24 13:13
Sorry, I'm still pretty new to pact and I don't know anything about these webhooks. ~Is there an introductory explanation to them somewhere? It sound like this is a feature on the pact broker?~ NVM, just found https://docs.pact.io/pact_broker/webhooks#introduction :slightly_smiling_face:

jbecker
2022-05-24 13:14
Also in your article on this new webhook event, you write: > The triggered provider build must then check out the specified version of the provider codebase, [...] but I was thinking it might make sense to use a docker image for each provider service, but based on this, it sounds like that may not be supported?

rivanitskiy
2022-05-24 14:23
has joined #general

jbecker
2022-05-24 15:54
Does anyone know if there is a way using the https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli to wait or retry on the state change endpoints until the provider service is done starting up? I have tried setting an explicit `--request-timeout` value, but it's still failing, so I think the way my server must work is that while it's still setting up, it's returning 500s instead of hanging

marti92
2022-05-24 21:40
has joined #general

bethskurrie
2022-05-24 22:21
You can do whatever you like in the build, as long as you can get the right version of the provider code in the docker image.

bethskurrie
2022-05-24 22:22
if you're building on the fly, you can checkout the code then build it. if you're pulling from a docker repository, make sure your pre-built image is tagged with the git sha.

yousafn
2022-05-24 23:13
This :point_up: is excellent Beth :clap:

rholshausen
2022-05-24 23:27
No, there is nothing like that. Raise an issue for it at the Github repo https://github.com/pact-foundation/pact-reference

yasarenver
2022-05-25 05:22
has joined #general

brian.quinn
2022-05-25 08:53
has joined #general

akke.luukkonen
2022-05-25 10:40
Great idea in general!

jarekrzdbk
2022-05-25 12:45
has joined #general

jbecker
2022-05-25 13:31
Okay, I went ahead and created a github issue describing what I was trying to do and the work-around I ended up having to do: https://github.com/pact-foundation/pact-reference/issues/197

jbecker
2022-05-25 13:31
Thanks for the attention! :slightly_smiling_face:

shaun.mendham
2022-05-25 16:32
has joined #general

plourded
2022-05-25 19:43
has joined #general

plourded
2022-05-25 19:53
Hello everyone! I have a service that is a consumer and a provider for a least two of others of my services. I was able to make deployment on my develop environment while writing the contracts, but now that everything is working on that environment, I?m not able to deploy to my production environment since can-i-deploy would not let me, :disappointed: computer say no. Am I doing something very wrong? I search everywhere to find a answer to this question but didn?t got luck :(

matt.fellows
2022-05-26 01:42
Hi Dominic. To help answer that question, we?ll at least need to see the output of the command so we can understand the can-i-deploy output

matt.fellows
2022-05-26 01:42
are you saying there is a cyclical dependency (i.e. there are two contracts A -> B and B -> A)?

emirhan.emmez
2022-05-26 06:31
has joined #general

plourded
2022-05-26 14:06
yes!

plourded
2022-05-26 14:08
Trying to deploy on Service A (provisioning-service) : ```Computer says no ¯_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ---------------------|-----------|-----------------|-----------|----------|-------- provisioning-service | 1.0.126 | devices-gateway | ??? | ??? | ``` Trying to deploy service B (devices-gateway): ```Computer says no ¯_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ----------------|-----------|----------------------|-----------|----------|-------- devices-gateway | 1.0.90 | provisioning-service | ??? | ??? | There is no verified pact between version 1.0.90 of devices-gateway and the version of provisioning-service currently deployed to staging (no such version exists)```

plourded
2022-05-26 14:15
temporary, to allow me to deploy on my new environment (staging), I set the can-i-deploy to dry-run in my pipeline and manually made the deployment after that...

yasir27uk
2022-05-26 17:56
has joined #general

lcs2019022
2022-05-27 05:27
has joined #general

lcs2019022
2022-05-27 05:33
Hi everyone, I am setting up this repository https://github.com/pactflow/example-consumer locally on my machine. I have created the PACT_BROKER_TOKEN and PACT_BROKER_BASE_URL, DOCKER, and MAKE but while running the command make fake_ci this error is showing up. Can anyone help me with this issue? 'CI' is not recognized as an internal or external command, operable program or batch file. make: *** [fake_ci] Error 1

tjones
2022-05-27 05:38
This sounds like a windows error. What shell are you running? I don't know if this is the problem, but does it work if you try from `bash`?

tjones
2022-05-27 05:39
It looks like `SHELL=/bin/bash` (or similar) might be helpful https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html

lcs2019022
2022-05-27 06:00
Yes solved, thanks!

tjones
2022-05-27 06:14
@matt.fellows I think you can put the `SHELL=/bin/bash` line in the makefile, solving this for everyone, maybe

lcs2019022
2022-05-27 06:56
I am running the command, and another error is showing up is of Docker. I am new to Docker. Can you help on this. \n========== STAGE: publish pacts ==========\n docker: Error response from daemon: invalid mode: /Pact/example-consumer. See 'docker run --help'. make[1]: *** [publish_pacts] Error 125


tjones
2022-05-27 07:42
Try changing: ```PACT_CLI="docker run --rm -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"``` to ```PACT_CLI="docker run --rm -v "/$(PWD):$(PWD)" -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"``` ...maybe. I don't have a windows machine to test on

tjones
2022-05-27 07:46
oh, actually, does your path have spaces in it? It might be enough to just quote those variables

kannan.jai
2022-05-27 07:50
Hello, have anyone tried passing the port number for the mock server as a command line argument when running consumer tests? Tried it but failing, may be I am missing something. Any thoughts? Thanks. ```@PactTestFor(providerName = "test-provider", port = "${pact.server.port}")```

tjones
2022-05-27 07:57
What error are you getting? IT looks like this question would be best asked in #pact-jvm

kannan.jai
2022-05-27 07:57
We would be setting the same port in one of our config yml file hence we would like to either set it via command line or read and pass it to our yml config similar to using @AutoConfigureWiremockPort which exposes the port via ${wiremock.server.port}

kannan.jai
2022-05-27 07:58
It is Java error, java.lang.NumberFormatException: For input string: "${pact.server.port}". I

matt.fellows
2022-05-27 08:02
The examples aren?t very windows friendly are they.

matt.fellows
2022-05-27 08:03
Glad running it with bash helped though.

matt.fellows
2022-05-27 08:06
Where are you running these docker commands - from which shell environment? I think it needs to be run in something like git shell?

matt.fellows
2022-05-27 08:06
I?m going to see if we can get a windows build running next week, so at least we have a working example to show Windows users

wieslaw.bondyra
2022-05-27 08:09
has joined #general

lcs2019022
2022-05-27 09:57
@matt.fellows running in git shell only

lcs2019022
2022-05-27 09:59
But same error is coming from local and it is not pushing the contract to pactflow. It's working fine from github build workflow.

matt.fellows
2022-05-27 10:00
Thanks. By any chance are there spaces in the project path?

lcs2019022
2022-05-27 10:09
No

lcs2019022
2022-05-27 10:09
```PACT_CLI="docker run --rm -v "/$(PWD):$(PWD)" -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli"``` Tried this as well

lcs2019022
2022-05-27 10:11
But the same error is coming

matt.fellows
2022-05-27 10:41
So the `${PWD}:${PWD}` part of that command says ?mount the current directory into the container, at the same path?. See if you can replace the `PWD` with the correct folder path for the source (i.e. your machine) and target (the container).

hello560
2022-05-27 11:01
Hiya, sorry for taking so long getting back to you. Somehow my issues disappeared the day after I initially wrote here, and frustratingly, I have no idea why. Started seeing expected behavior with WIP pacts being considered and all that.

plourded
2022-05-27 13:08
@matt.fellows We have an event driven architecture where service are highly decoupled, I?m not sure I should use contract for events in my case? or I?m doing something wrong?

rafaelcebulla
2022-05-27 15:20
has joined #general

orbit.mjs
2022-05-27 17:45
has joined #general

msparks
2022-05-27 19:56
has joined #general

matt.fellows
2022-05-28 00:56
No I don?t think that should matter

matt.fellows
2022-05-28 10:30
The can-i-deploy tool supports bi-directional dependencies between applications, however, as you are introducing pact into an existing relationship where there are already versions deployed, you will need to disable can-i-deploy to get the first pair of contracts out into production. Make sure both sides are actually passing before you do this. Or, you can choose one direction to start with (deleting the pacts for the other direction if you have already published them), get that deployed, then add in the pacts for the other direction. Thereafter, you will need to ensure you only ever make changes in one direction of the relationship at a time, otherwise can-i-deploy will very correctly stop you from deploying. If you have changes in both directions that each depend on the other, you will be in the situation where you must deploy both applications at the same time, at which stage you would probably be better off if both services were part of a single application. Bi-directional dependencies tend to cause a lot of issues in both testing and deployments!

plourded
2022-05-29 00:43
Thanks a lot for your response!

matt.fellows
2022-05-29 01:04
You're welcome!

ebanster
2022-05-29 11:22
Hi @matt.fellows@matt.fellows@matt.fellows@Matt (http://pactflow.io / pact-js / pact-go)@Matt (http://pactflow.io / pact-js / pact-go) and team, Ive asked this via twitter but is it viable to use contract testing if our app has heaps of integration with third-party services like zendesk, salesforce, etc. If yes, whats the best way to do it? For context, we don?t have automated integration and api tests yet.

matt.fellows
2022-05-29 22:28
Hi!

matt.fellows
2022-05-29 22:36
For 3rd party tests, because they won?t be able verify your contracts, Pact style tests will only add a little value (see our AMA on the subject: https://docs.pact.io/help/amas#join-an-upcoming-ask-me-anything-ama-session) For 3rd party tests, there are a couple of options; 1. If they are untrusted, you could use record/replay style tests, but this gets hard because you need to be able to handle state. Essentially, you?d be building an approval based workflow, where tests are run on a regular basis and any failed tests need to be manually reviewed/approved. This will require more upkeep, but might be helpful in situations where the 3rd party is unreliable 2. You could use a static style check, where you compare your consumer usage to a defined spec given from the provider. This type of testing assumes the 3rd party is likely to be competent (as would be the case with Zendesk). You might find that https://docs.pactflow.io/docs/bi-directional-contract-testing/ could work for you, in this case (note it?s not an OSS feature)

ebanster
2022-05-29 23:11
Thanks matt for the detailed explanation. I will explore it further and check out the links you have provideex

nuno.frias
2022-05-30 14:13
Hello all I am having trouble understanding the benefits of handling provider asynchronous tests as unit tests instead of treating them as component level tests like the the synchronous provider tests. Let me elaborate: For the provider sync tests I am currently spinning up a docker container with the provider service and I set the provider state by writing records to a database and by simulating HTTP interactions and Kafka interactions with other downstream services. For provider async tests I can just as easily set the state by writing records to the database and simulate downstream interactions with the other services. And when it comes to verifying the message all I need to do is pull the message from the topic (I am using Kafka) and pass it on to Pact. I already have tooling in place to spin up the provider as a docker container for the synchronous tests so it is straight forward to use it for the asynchronous tests ? and in my case the same provider has both asynchronous and synchronous interactions sometimes with the same consumer.

falvarez
2022-05-30 14:17
has joined #general

tjones
2022-05-30 14:32
I think the primary benefit is that you don't have to spin up the provider in a container with all of its machinery. If this is not a cost for you, your way sounds fine

nuno.frias
2022-05-30 14:33
Thank you :raised_hands:

tjones
2022-05-30 14:34
There's a side point here, though - it sounds like you might be writing directly to your database during setup - I don't think this is a good idea, as it ties your database implementation into your tests

tjones
2022-05-30 14:34
I personally usually mock that whole layer with something that fulfils the same interface

nuno.frias
2022-05-30 14:35
Do you do that even for asynchronous tests ?

tjones
2022-05-30 14:35
like, say my database access comes through a class with the signature `getUser(id)`, which returns a `User` or throws `NotFound`, then I would mock that class


tjones
2022-05-30 14:35
The reason writing to the DB as part of the test setup can be painful is - what if you change your DB format?

tjones
2022-05-30 14:35
then you have to update the test

tjones
2022-05-30 14:36
but the test isn't about that format

tjones
2022-05-30 14:36
knowing the format is incidental

tjones
2022-05-30 14:36
this is one of the reasons that a unit test setup can be superior - you might (quite reasonably) say "well, I want to test with my real database"

tjones
2022-05-30 14:37
so, we could initialise an empty database, and then in the unit test setup we could call the `saveUser(someUser)` method on the DB access class (for example)

tjones
2022-05-30 14:38
I like the rule that a test will fail if - and only if - the interface or the behaviour change

tjones
2022-05-30 14:38
I don't think the data in the database is part of the interface

tjones
2022-05-30 14:39
Your test will still work if it knows the database structure, I'm just flagging that I think it will be harder to maintain

nuno.frias
2022-05-30 14:47
The database structure is not likely to change (in fact it is more likely the interface will change at this stage of development). I though the purpose of spinning up the entire provider as part of the provider verification was to ensure you are actually verifying a real provider message (or response in case of sync).

tjones
2022-05-30 22:17
Yes, that's right. The idea is that it's always the real code - but a consumer test can do that without spinning up the whole thing. However, the current implementation of message pacts doesn't include the sending and receiving of messages, which is why spinning up the whole thing isn't the norm. You could, but you may need to build a small test runner to fire the messages

ruslan.ponomarev
2022-05-31 06:28
has joined #general

danielflieger
2022-05-31 07:13
Hey there! I having a question regarding the interesting new contract testing called Bi-directional contract testing. In the given examples the provider verifies the api spec using e.g. rest assured or postman. Is it right that when the provider autogenerates the api spec from code than the provider can just publish the api spec to pactflow without any further?SELF-VERIFICATION TEST RESULT??

alexander.maiburg
2022-05-31 07:31
has joined #general

matt.fellows
2022-05-31 08:59
Hello! For clarity, this is a #pactflow specific feature (so in the future we should keep the conversation there)

matt.fellows
2022-05-31 09:00
But yes, in that case for the purposes of contract testing, you need not do any additional validation. You should obviously still have other functional tests etc.

aherbst
2022-05-31 17:31
has joined #general

jbecker
2022-05-31 18:23
Hey! Can anyone tell me if there is a way using the pact-broker CLI to retrieve information about providers and consumers given a pacticipant?

jbecker
2022-05-31 19:39
Another question: I'm using the v3 pact_verifier_cli (the one written in Rust) and it wants me to specify a https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors, but I'm trying to get this to work with my `contract_requiring_verification_published` webhook, which will trigger on our feature branch build (so before it has been merged/tagged or deployed to any environment) so I just want to point at a specific consumer version when I run the verification. Is there a way to do that with the consumer version selector? Or is there some other way I'm not seeing?

jbecker
2022-05-31 19:41
I don't want to simply rely on "latest" because we may have 2 developers who each publish feature branches at the same time, so one of them might never be considered the latest

jbecker
2022-05-31 19:45
Do I maybe just want to pass the `${pactbroker.pactUrl}` to my webhook and just use the `--file` option to point directly to it?

matt.fellows
2022-05-31 22:25
It might not be the file option, there should be one to specify a URL to the exact pact that's not the broker base URL

matt.fellows
2022-05-31 22:27
What information do you need? If not the CLI the API will have it. Issue a request to `/`and then follow the HAL relations to the different resources

vipul.pachauri
2022-06-01 08:02
has joined #general

komal.sharma1
2022-06-01 08:02
has joined #general

matt.fellows
2022-06-01 09:26
:point_right: Use Pactflow?s BDCT feature, OAS or SwaggerHub? Would love to chat with you! :swagger: :pactflow: https://pact-foundation.slack.com/archives/CLS16AVEE/p1654075535026179

nuno.frias
2022-06-01 10:15
As part of the provider test I fetch the messages from the kafka topic and send them to Pact.

chris169
2022-06-01 11:53
has joined #general

jbecker
2022-06-01 14:18
Oh, you are right, I see that now. Thank you

jbecker
2022-06-01 14:22
I was going to try and use the pact broker to get the providers associated with a given pacticipant, and the provider versions of those providers which are associated with a given environment, so I could programmatically kick off those verifications. I thought it might be easier to do that than to figure out how to set up a `contract_requiring_verification_published` webhook, at least for my first pass on the solution, but after messing with it for a bit, I figured the webhook wouldn't be that hard to set up so I'm just going to end up going with that after all.

jbecker
2022-06-01 14:22
Good tip about the HAL API though, I'll keep that in mind if I need to query the pact broker in the future

jbecker
2022-06-01 19:01
does anyone know if there is an issue with the pact-broker cli's `create-or-update-webhook` "data" option? I'm trying to create a webhook for our jenkins job which verifies contracts and I'm getting a very confusing response from the cli. I am using it like: ```pact-broker create-or-update-webhook \ "http://$JENKINS_BASE_URL/job/Pact%20Verify%20Provider/buildWithParameters" \ --uuid="$PROVIDER_VERIFICATION_WEBHOOK_UUID" \ --request=POST \ --broker-base-url="$PACT_BROKER_URL" \ --data="project=\${pactbroker.providerName}" \ --data="version=\${pactbroker.providerVersionNumber}" \ --data="pactfile_url=\${pactbroker.pactUrl}" \ --user="$USERNAME:$PASSWORD" \ --description='Automatically trigger pact verification on contract change.' \ --contract-requiring-verification-published``` but the response I'm getting is: ```ERROR: "pact-broker create_or_update_webhook" was called with arguments ["http://jenkins-base-url.com/job/Pact%20Verify%20Provider/buildWithParameters", "version=${pactbroker.providerVersionNumber}", "pactfile_url=${pactbroker.pactUrl}"] Usage: "pact-broker create-or-update-webhook URL --uuid=UUID -X, --request=METHOD -b, --broker-base-url=BROKER_BASE_URL"``` as though after the URL the only options it sees are the data options and it's skipping everything else

m.shi
2022-06-01 19:07
has joined #general

jbecker
2022-06-01 19:39
So, some more info, I tried following the instructions in the description for the `pact-broker create-or-update-webhook` command, where it suggested I write a curl command and then change it from `curl` to `pact-broker create-or-update-webhook` and I did, this worked to kick off my jenkins job: ```curl \ "http://$JENKINS_BASE_URL/job/Pact%20Verify%20Provider/buildWithParameters" \ -X POST \ -u "$USERNAME:$PASSWORD" \ -d project=\${pactbroker.providerName} \ -d version=\${pactbroker.providerVersionNumber} \ -d pactfile_url=\${pactbroker.pactUrl}``` but when I change it to this: ```pact-broker create-or-update-webhook \ "http://$JENKINS_BASE_URL/job/Pact%20Verify%20Provider/buildWithParameters" \ -X POST \ -u "$USERNAME:$PASSWORD" \ -d project=\${pactbroker.providerName} \ -d version=\${pactbroker.providerVersionNumber} \ -d pactfile_url=\${pactbroker.pactUrl} \ --contract-requiring-verification-published \ --broker-base-url "$PACT_BROKER_URL" \ --description 'Automatically trigger pact verification on contract change.' \ --uuid "$PROVIDER_VERIFICATION_WEBHOOK_UUID" ``` I get the exact same error: ```ERROR: "pact-broker create_or_update_webhook" was called with arguments ["http://jenkins-base-url/job/Pact%20Verify%20Provider/buildWithParameters", "version=${pactbroker.providerVersionNumber}", "pactfile_url=${pactbroker.pactUrl}"] Usage: "pact-broker create-or-update-webhook URL --uuid=UUID -X, --request=METHOD -b, --broker-base-url=BROKER_BASE_URL"``` Very perplexing :confused:

matt.fellows
2022-06-01 22:00
I don?t think `-d` is a repeated flag for the `create-or-update-webhook` command

asa.anudeep4
2022-06-02 04:33
has joined #general

diede
2022-06-02 10:01
has joined #general

akke.luukkonen
2022-06-02 12:42
Not sure if this is Rust specific, but curious if someone else has seen the following warning when using the `pact_verifier_cli`: `[WARN] Received a ServerHelloDone handshake message while expecting [CertificateRequest]` I'm currently switching from using the Ruby CLI verifier to the Rust one in our CI pipelines by using the https://hub.docker.com/r/pactfoundation/pact-ref-verifierDocker image. However, something currently triggers that warning to appear at the start of each verification. From my understanding it's caused by https://github.com/rustls/rustls/issues/1012 introduced in 0.20.3 of Rustls, which was fixed in 0.20.5. However, the latest Docker image for pact_verifier_cli is of 0.9.10 which is still using 0.20.4 (https://github.com/pact-foundation/pact-reference/blob/55c65b36a1eda2e83294f63b5ecbe18e655f6cc8/rust/Cargo.lock#L2144 from time of release), while it seems that the master branch of the https://github.com/pact-foundation/pact-reference is using 0.20.6 of Rustls. Curious if anyone else has noticed the same thing since I didn't find anything in the workspace via searching messages. I noticed also that the Cargo.toml for the verifier was already bumped to 0.9.11 in this https://github.com/pact-foundation/pact-reference/commit/e1f4d4d957e973b2f974f37f394f51ba3d2e0bc5 during April, but apparently no release itself was made or is it still being tested (this 0.9.11 release is still using the 0.20.4 version of rustls, so it probably won't fix this issue even if released).

akke.luukkonen
2022-06-02 12:44
Not a big thing in general. I can say to people to ignore the warning for the time being as well. But I was just trying to figure out if it's something on my end that I could try to fix.

jbecker
2022-06-02 13:01
Okay, that's a good tip. It is for curl, so I assumed it would translate

mateusz.zaborowski
2022-06-02 17:54
has joined #general

matt.fellows
2022-06-02 22:51
How?d you go?

rholshausen
2022-06-02 23:23
Let me check, there may be a missing update to the docker images

jbecker
2022-06-03 12:42
Still prototyping my whole pipeline, so I just created the webhook via a curl post and side-stepped this issue for now (my original intention was to create it via the cli app using the create-or-update-webhook command in source control so if anyone edits it there and checks it in, it automatically updates in the pact-broker, but that's a stretch-goal now)

jbecker
2022-06-03 12:42
Thanks for following up though! :slightly_smiling_face:

rchord23
2022-06-05 19:30
has joined #general

divya.parameswaran
2022-06-05 20:16
has joined #general

alexey.shchukin
2022-06-06 11:46
has joined #general

tomknee1
2022-06-06 18:38
Hello, hoping someone can help me with `record-deployment` and `record-release` please... When I `record-deployment` into an environment, should the `--version` be the same git commit sha for each environment I deploy to? Reason I ask is because I had a command like this ```docker run pactfoundation/pact-cli:latest pact-broker record-release --pacticipant DojoPayConsumerApp \ --version $BITRISE_GIT_COMMIT \ --environment production \ --broker-base-url $PACT_BROKER_BASE_URL \ --broker-username $PACT_BROKER_BASIC_AUTH_USERNAME \ --broker-password $PACT_BROKER_BASIC_AUTH_PASSWORD``` in CI for deployments and releases, where the `$BITRISE_GIT_COMMIT` version would be different for each deployment. On the `record-release` I was getting failures as it could not find the version it was looking up, would love some clarification on this please, thanks :slightly_smiling_face:

jbecker
2022-06-06 19:03
I'm also a bit of a pact newbie, but I think you should be re-using the same version for every environment. When you cut a release of your service in git (whether you use tags or release branches), there should be one commit sha representing the release-tagged commit or the latest commit on the release branch. In either case, that is the commit sha you want to use as your version in pact because that value won't change as you deploy your service to different environments.

jbecker
2022-06-06 19:05
Maybe you can clarify why your `$BITRISE_GIT_COMMIT` was different for each environment? Because that seems non-typical.

tomknee1
2022-06-06 19:11
Thanks, this is what I?m thinking I need to switch to and where I made a mistake. `$BITRISE_GIT_COMMIT` was different for each environment probably based on our git flow and how Bitrise works. That env var is provided by Bitrise and auto grabs the commit sha. When I make a PR, that will be one commit sha, when the job is triggered to merge that into develop branch, that?s another commit sha etc etc. I?m guessing what I need to do is make sha consistent across all record deployments and releases, but would love some confirmation, if maybe @matt.fellows knows please?

jbecker
2022-06-06 19:16
Oh, your commit sha is always going to be different between your PR branch and your develop branch, because when you merge, the merge commit itself will be your latest commit, and that will have a different sha. What I did in this situation was to simply (on the consumer side) re-generate and publish the contract after merging, and (on the provider side) re-run the verification after merging so that the latest commit sha is included and verified in the pact broker

tomknee1
2022-06-06 19:17
right but then on that pr merge i do one `record-deployment` then later down the line might do other `record-deployments` to other environments, should the sha be the same for all those `record-deployments`?

jbecker
2022-06-06 19:19
I'd guess that when you call `record-deployment` you should always use the actual commit sha that you deployed, or else the `can-i-deploy` feature won't really work as intended.

jbecker
2022-06-06 19:20
So if they're actually different, then they all need to be uploaded to the pact broker and verified. And if they're not actually different, find out why bitrise seems to think they are. :man-shrugging:

tomknee1
2022-06-06 19:20
hm, so the main issue I have is by the time I get to `record-release` its trying to use a git sha version it cannot find, e.g. another different sha

tomknee1
2022-06-06 19:21
all my deployments have different shas / versions

jbecker
2022-06-06 19:21
Right, the error you're getting looks like the pact broker has never seen that sha before

jbecker
2022-06-06 19:21
So you just need to make sure it has seen that sha before you call `record-deployment`

tomknee1
2022-06-06 19:22
correct, so im wondering does it need to be the latest version / sha from a specific tag/environment for `record-release`?

tomknee1
2022-06-06 19:22
i guess via curl or something?

jbecker
2022-06-06 19:22
if your pacticipant is a consumer, make sure you upload its contract file with that sha as a version number before you call `record-release`

tomknee1
2022-06-06 19:22
yep i do :+1:

tomknee1
2022-06-06 19:23
ah sorry i do for deployments

tomknee1
2022-06-06 19:23
release process is a bit weird/different

jbecker
2022-06-06 19:23
and if your pacticipant is a provider, make sure you verify it with that same sha

tomknee1
2022-06-06 19:24
Im on consumer side, I?m thinking for `record-release` I probably need to grab the sha/version for the latest consumer version with the `preproduction` tag/environment (which is the last environment before `production`

jbecker
2022-06-06 19:24
so to address your question specifically: > does it need to be the latest version / sha from a specific tag/environment I'd say no, it doesn't need to be the latest, but it sounds like it _does_ need to be a version that the pact broker has seen before

jbecker
2022-06-06 19:25
No, I don't think you want to do that

jbecker
2022-06-06 19:25
Like I was saying before, I think it's important to make sure that you are using the actual git sha of the commit you're deploying

jbecker
2022-06-06 19:26
don't make try to calculate or make assumptions about your git sha, just use the actual one your deploy tool is providing you, or else `can-i-deploy` may not work correctly

tomknee1
2022-06-06 19:27
hm i get what ur saying, i will dig into whats going on some more and come back on this issue, thanks

jbecker
2022-06-06 19:29
Maybe the real pact folk can give you more ideas too. As I said, I'm just a newbie myself. But I think they are all on European time, so you probably won't hear back from them for a bit. Hopefully I could help get you unblocked in the meantime :slightly_smiling_face:

tomknee1
2022-06-06 19:41
im uk based, think they are on australian time

jbecker
2022-06-06 19:41
Ah, that sounds right

tomknee1
2022-06-06 19:46
alright ive spotted the issue. in our job that records the release (`trigger_master`) we dont run any unit tests etc thus the `pactPublish` never happens so it cant find it :upside_down_face:

tomknee1
2022-06-06 19:46
thanks for your help and talking it through

afang
2022-06-06 22:17
has joined #general

matt.fellows
2022-06-06 23:03
:taco: for @jbecker - thanks for your help!

pratish.mp
2022-06-07 00:58
has joined #general

tjones
2022-06-07 01:00
How mature is the protobuf support? I can't seem to find much documentation on it - but the top results searching http://docs.pact.io are in changelogs, so maybe the functionality is there?

rholshausen
2022-06-07 01:03
Still beta. Follow in the #protobufs channel

tjones
2022-06-07 01:04
Thank you!

tjones
2022-06-07 03:29
@tomknee1 This is one of the reasons it's a good idea to have completely repeatable version numbers for a given commit - that way it doesn't matter if the contract isn't published as part of your release, because the pre-release pipelines have already done it

tomknee1
2022-06-07 08:58
@tjones thanks, i guess this was partly a question i had, do i run pact tests and `pactPublish` in my release pipeline and the just auto grab the commit sha for that? Or do i instead grab the commit sha from my pre-release pipeline and use that when recording a release in my release pipeline?

tjones
2022-06-07 08:58
Why are they different?

tjones
2022-06-07 09:01
Also, a subtlety that I didn't realise at first- the pact *file* is what is verified- so if you publish a new ?version?, but the same contract (which has previously been verified), then it will immediately be verified

tjones
2022-06-07 09:02
This means that if your pre-release and release pipelines have different versions, you can still use the workflow you describe

tomknee1
2022-06-07 09:02
they are different because they are different jobs `trigger_master_pr` and `trigger_master`

tjones
2022-06-07 09:02
Also, this whole situation was the motivation behind this:


tjones
2022-06-07 09:03
(Why is the job affecting your version number? :thinking_face: )

tjones
2022-06-07 09:04
If you have repeatable builds, then all you need is the version control system to decide what version you have

tomknee1
2022-06-07 09:04
(i use commit sha, it auto grabbed from bitrise ci, so it changes for each job i think)

tjones
2022-06-07 09:04
Commit sha will be the same unless your jobs are committing stuff

tomknee1
2022-06-07 10:09
so we use git flow rather than trunk based dev on consumer side, so when we trigger a pr merge into a release branch or something, the sha changes

jbecker
2022-06-07 13:25
Yeah, that bit makes sense, the merge commit itself is a commit and will have a new sha, so I think you just need to be uploading the contract or running the verification *more often*. In my pipeline, since we're doing trunk-based development, we upload the new contract file for *both* the PR branch *and* the master branch. In your case since you're doing gitflow, you'll want to upload a new contract file even more often than that. Essentially any branch that will have unique commits on it, including: ? Your feature branches ? Your develop branch (because of the merge commits) ? Your release branches (probably, though in theory you might not, since creating a branch doesn't create a new commit sha, in practice you will generally need to merge bug fixes into your release branch, and as mentioned above, merge commits create a unique sha) ? Your master branch (again because of merge commits, but it would also probably be useful to tag these pacts with the master version numbers) ? Your hotfix branches (like feature branches, you probably want to verify contracts before you allow merges, but since it's a hotfix, you may want to build in a way to override for emergencies)

tomknee1
2022-06-07 16:32
thanks, we actually do seem to use unique commits this often, except for this specific case where we merge into master after a release is published

tomknee1
2022-06-07 16:33
that helps too on provider side though as they use trunk based dev so will need to help with that once i have all this consumer side correct :slightly_smiling_face:

rarora
2022-06-08 00:01
Hi Team, Our team at tripadvisor landed into unique issue: 1. Feature branch published pact(not new, existing pacts) 2. It triggered webhook and ran provider verification build. 3. Due to some intermittent issue(that I am checking), build failed. 4. Verification result was copied to all other consumer feature branches and canIDeploy check for all consumer feature branches started failing. 5. There was panic situation all around as all builds are failing and nobody changed pact. How it was resolved: I published new feature branch which triggered webhook and got consumer test verified. What i want to ask is : 1. What should be best way to resolve such situation? 2. When is webhook triggered, since its not new pact 3. Was the above behaviour expected or Does pact pipeline setup needs improvement?

dasarih
2022-06-08 00:20
has joined #general

matt.fellows
2022-06-08 00:24
First up, here are some tips for debugging webhooks: https://docs.pact.io/pact_broker/webhooks/debugging_webhooks. If using Pactflow, we have screens to see the webhook executions also

tjones
2022-06-08 00:24
The verification result for a feature published pact shouldn't be applied to all consumers, so I think something is not set up right

rarora
2022-06-08 00:25
> The verification result for a feature published pact shouldn?t be applied to all consumers, so I think something is not set up right even if contract is same?

rarora
2022-06-08 00:25
I verified when contract is different, it is not applied

matt.fellows
2022-06-08 00:26
The verification result is tied to the *provider version.* Because multiple provider versions can verify a contract

matt.fellows
2022-06-08 00:26
so my guess, is that your can-i-deploy setup is incorrect e.g. you?re using `latest` rather than a tag or deployed environment

matt.fellows
2022-06-08 00:26
what does your can-i-deploy command look like?

rarora
2022-06-08 00:29
its gradle task where i setup these variables: ```project.ext.pacticipantVersion = "${project.rootProject.ext.COMMIT_HASH}" project.ext.pacticipant = "${project.parent.name}" project.ext.toTag = "production"``` so essentially it is, feature branch checks it has production tag for provider(This tag is added by webhook build which runs provider contract test on develop version of provider)

matt.fellows
2022-06-08 00:29
so If I understood, you?re adding the tag `production` on the develop version of the provider during verification?

rarora
2022-06-08 00:30
yes, as for our case develop branch go to production

matt.fellows
2022-06-08 00:30
so then you?re getting the expected failure. Now all consumers can?t deploy to `production` because you just told it that the provider doesn?t satisfy the contract

matt.fellows
2022-06-08 00:30
but in any case, you really shouldn?t add the tag `production` until the provider _is_ in production

matt.fellows
2022-06-08 00:31
unless there is a very short window from when code lands in `develop` and is deployed to `production`

matt.fellows
2022-06-08 00:31
The CI/CD guide explains this: https://docs.pact.io/pact_nirvana as well as the CI/CD workshop (see below howtolearn)

2022-06-08 00:31
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

rarora
2022-06-08 00:32
> so then you?re getting the expected failure. Now all consumers can?t deploy to `production` because you just told it that the provider doesn?t satisfy the contract yes, I understand that. Since it happened due to intermittent issue(not actual error), What should be best way to resolve it? rerun?

matt.fellows
2022-06-08 00:32
yes, i?d just re-run the provider build

rarora
2022-06-08 00:32
> unless there is a very short window from when code lands in `develop` and is deployed to `production` yes its 1-1.5 hour for us. We are working on ways to improve it

matt.fellows
2022-06-08 00:33
So that?s definitely a reason to structure your tags differently to avoid this situation.

rarora
2022-06-08 00:33
> yes, i?d just re-run the provider build With above you mean webhook build that can add production tag?

matt.fellows
2022-06-08 00:34
webhooks don?t add tags, builds add tags

matt.fellows
2022-06-08 00:34
I would re-run whatever build is failing that?s causing the issues. Ideally, find out why it failed and make it more resilient also

rarora
2022-06-08 00:34
yup i mean webhook triggered build(we have different setup for both, these build just run provider contract test)

matt.fellows
2022-06-08 00:34
nice, that?s what they should do :slightly_smiling_face:

rarora
2022-06-08 00:35
> I would re-run whatever build is failing that?s causing the issues. Ideally, find out why it failed and make it more resilient also yes, I kind of did that.

matt.fellows
2022-06-08 00:35
but your tagging is iffy, i?d recommend not tagging dev builds `production` because that will prevent consumers deployinsg to prod if your dev builds of provider fail, even though production is not affected

rarora
2022-06-08 00:42
For our provider pipeline, whatever is merged to develop goes to production(There is separate pipeline that runs after merge to develop which takes ~1 hour). We want things to fail if develop build is failing. Provider ci-cd pipeline verifies against release-version of consumer. Develop is kind of master for us

rarora
2022-06-08 00:43
Currently we dont have way to tag after depolying to production, so we tag it after merge

rarora
2022-06-08 00:44
My issue/concern was in form: All feature branch checks for production tag from latest provider verification. Should we have additional variable for this?

benjamhawk
2022-06-08 02:37
has joined #general

tjones
2022-06-08 08:04
> Currently we dont have way to tag after depolying to production, What do you do if your deploy fails? Then your tags will be inaccurate, and you may have problems

tjones
2022-06-08 08:05
Usually you would do the `record-deployment` step at the end of your deploy script - is this not possible?

marcello.rigan335
2022-06-08 08:14
Hey, i have an android and an iOS consumer that have the same provider and use the same Endpoint with literally no differences in response or request. The Provider Test would be identical besides the consumer annotation change. Is there a way where i can avoid that much code duplication and can have multiple consumers in 1 Test?

tomknee1
2022-06-08 08:47
Hello again, myself (consumer side) and someone I'm working with on the provider side were wondering about the gold stage of reaching pact nirvana. If provider verification is run on every PR branch, how does it work in later stages when we start using `can-i-deploy` because doesn't that then also need an environment associated with it? but we don't record a deployment until its merged into main (provider side use trunk based dev), thanks or i guess we can see if its safe to deploy a feature branch / PR into a deployed environment (eg merge into main)?

matt.fellows
2022-06-08 10:27
is it ever possible that they might call different endpoints or at different moments in time consume different parts of the API?

matt.fellows
2022-06-08 10:28
Do you already have good unit test coverage of your API clients in these apps?

matt.fellows
2022-06-08 10:28
If the answers to these questions (and others like it) are ?no?, then I suppose you could.

matt.fellows
2022-06-08 10:28
But if you think of Pact first as a unit testing framework for your API client, it might seem a little silly to skip that part

sclaros
2022-06-08 13:07
has joined #general

daniel.tjondro
2022-06-08 15:25
has joined #general

slacksync
2022-06-08 17:21
has joined #general

sandro
2022-06-08 18:26
has joined #general

hazem
2022-06-08 23:14
has joined #general

2022-06-09 13:59
This message was deleted.

jbecker
2022-06-09 14:19
Looks like there is a channel for #pactflow specific questions. You might want to cross-post there, you might get more responses.

yousafn
2022-06-09 14:23
Yo, as @jbecker as stated, #pactflow is the best channel for pactflow specific features. however the best way to publish provider contracts currently is with our CLI tools! Here are some hot of the press instructions Using docker https://github.com/pact-foundation/pact_broker-client#docker ```docker run --rm -v /${PWD}:/${PWD} -w ${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_TOKEN pactfoundation/pact-cli:0.50.0.28 pactflow publish-provider-contract \ oas/swagger.yml \ --provider "pactflow-example-bi-directional-provider-postman" \ --provider-app-version 3a0994c \ --branch test-pactflow-command \ --content-type application/yaml \ --verification-exit-code=0 \ --verification-results newman/newman-run-report-2022-06-09-14-18-33-406-0.json \ --verification-results-content-type text/plain\ --verifier postman``` if using pact-ruby-standalone https://github.com/pact-foundation/pact_broker-client#standalone-executable and follow this https://pact-foundation.slack.com/archives/C9WTB2JDV/p1654783459462829?thread_ts=1654778378.898589&cid=C9WTB2JDV for cross-platform install ```./pact/bin/pactflow publish-provider-contract \ oas/swagger.yml \ --provider "pactflow-example-bi-directional-provider-postman" \ --provider-app-version 3a0994c \ --branch test-pactflow-command \ --content-type application/yaml \ --verification-exit-code=0 \ --verification-results newman/newman-run-report-2022-06-09-14-03-30-715-0.json \ --verification-results-content-type text/plain\ --verifier postman``` if using pact-broker_client https://github.com/pact-foundation/pact_broker-client#ruby ```pactflow publish-provider-contract \ oas/swagger.yml \ --provider "pactflow-example-bi-directional-provider-postman" \ --provider-app-version 3a0994c \ --branch test-pactflow-command \ --content-type application/yaml \ --verification-exit-code=0 \ --verification-results newman/newman-run-report-2022-06-09-14-03-30-715-0.json \ --verification-results-content-type text/plain\ --verifier postman``` Happy to take a look at the issue with your js example, probably later today

leonardo.lanni
2022-06-09 14:51
has joined #general

jcamilovasquezm
2022-06-10 02:47
has joined #general

markrkell
2022-06-10 08:13
has joined #general

eva-maria.schaller
2022-06-10 08:24
has joined #general

edouard.lopez
2022-06-10 10:34
We have a consumer that added new contracts with consulting its provider, and that broke their pipeline. I know that communication is paramount with Pact and you encourage CDCT, but how do you tackle the case where the provider is already verifying contracts from other consumers? Does the provider need to handle all the states declared by its consumers? Is there a way to tell the consumer is experimenting?

matt.fellows
2022-06-10 10:34
Yes, Pending pacts (and also branches / tags)

matt.fellows
2022-06-10 10:35
I'd highly recommend reading the co/cd setup guide (howtolearn)

2022-06-10 10:35
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

jbecker
2022-06-10 12:39
If it helps, I can tell you that the way I've been handling it is that the consumer feature branch which creates the contract must verify the contract before it can be merged into the master branch of that consumer, and the provider feature branches only have to verify against the master branch of its consumer. This way you can't merge a new contract if you haven't proven it works at least once already, and the provider will only be trying to verify pacts that have been proven to work at least once already.

edouard.lopez
2022-06-10 14:01
Thanks, I believe that what we need to do next! When you say: > consumer feature branch which creates the contract *must verify the contract* before it can be merged into the master branch of that consumer I tend to only use "_verifiaction"_ to talk about the provider to avoid confusion, so I reckon you mean consumer test pass and generate the pact file, right?

jbecker
2022-06-10 14:07
No, actually! I mean that as part of the consumer's feature branch pipeline which must pass before it can be merged to master, it remotely triggers a provider verification job (using the https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event webhook) and then runs the can-i-deploy script to ask of the current version of the consumer is compatible with the master version of the provider.

jbecker
2022-06-10 14:08
This means that _both_ the consumer _and_ the provider have to agree on a change to the contract before it can be merged to master

yousafn
2022-06-10 14:34
Happy Friday Everyone :ralph-wave: Pact Foundation's Slack Emoji Game is officially on :fire-8-bit: courtesy of your Devo :avocato: with :nine: :zero: :zero: ??% :moar: a. it contains language specific :rust: / :java: / :nodejs: / :gopher: b. _it's a silly thing, but_ i. what randoms can you find? :think_bread: ii. what's your favourite emoji? :bobbytables: iii. can we break :slack: on a :friday-2361: by having the most reacted :thread: to ever? :elmo_shrug:

michel.kaporin
2022-06-10 14:43
has joined #general

pooja.sharma4099
2022-06-11 08:39
has joined #general

srinivas.vaddi
2022-06-11 16:31
has joined #general

igor.sharfman
2022-06-12 11:25
has joined #general

chituru.chinwah
2022-06-13 08:48
has joined #general

cchinwah1
2022-06-13 09:45
has joined #general

edouard.lopez
2022-06-13 13:16
Do you have an example of config to share?

jbecker
2022-06-13 13:20
I suppose I can share some of our pipeline

jbecker
2022-06-13 13:21
We use Jenkins, so this is all written in Jenkinsfile groovy

edouard.lopez
2022-06-13 13:23
Jenkinsfile will bring back some memory :older_man: But you do target master branch using your pipeline? I thought it was a pact config

jbecker
2022-06-13 13:26
Skipping right to the pact-related stuff, the first relevant stage runs the unit tests: ``` stage("RUN UNIT TESTS") { steps { script { sh "$POETRY run pytest tests --cov=${job.sourceName}" IS_PACT_CONSUMER = library.exists('./tests/*.json') IS_PACT_PROVIDER = library.exists('./tests/pact_provider') } } }``` We have a library method which is just calling a shell script to check for the existence of a file or directory and convert it to a boolean. Since the `Pact` fixture in pytest automatically produces a pact json file for each provider this service consumes when it's done, we can check if this is a consumer if it has any pact files, and we're using a convention that if this service is a provider, it has its provider state setup logic in `./tests/pact_provider` so we can check for the existence of that directory to see if this is a provider (it can also be both or neither, since this is a general-use pipeline script)

jbecker
2022-06-13 13:29
``` stage("UPLOAD PACT FILE") { when { expression { return IS_PACT_CONSUMER } } steps { script { sh "docker run --network host -v \$(pwd)/tests:/tests " + "pactfoundation/pact-cli broker publish " + "/tests/ " + "--broker-base-url=\"${PACT_BROKER_URL}\" " + "--consumer-app-version=\"${job.abbrevCommitHash}\" " } } }``` Next, if the current project is a consumer, it uploads the pact file using the pact CLI (it's running it through the published docker container so we don't have to worry about installing it on our jenkins agents). We're creating our pact contract files into the `tests` directory, so we pass that directory into this script and it is smart enough to find all the pact json files. It uploads them to our broker (at `PACT_BROKER_URL`) and tags the contracts with the consumer version provided by `job.abbrevCommitHash`.

jbecker
2022-06-13 13:33
The next thing that happens is actually not part of the Jenkinsfile, but rather is a webhook in our pact broker which triggers automatically when it detects a new pact contract which requires verification: ```{ "uuid": "a0beeef6-b69e-421a-8033-d9212c274426", "description": "Automatically trigger pact verification on contract change.", "enabled": true, "request": { "method": "POST", "url": "http://<jenkins-url>.com/job/Pact%20Verify%20Provider/buildWithParameters", "headers": { "Content-Type": "application/json" }, "body": { "project": "${pactbroker.providerName}", "version": "${pactbroker.providerVersionNumber}", "pactfile_url": "${pactbroker.pactUrl}" }, "username": "**********", "password": "**********" }, "events": [{ "name": "contract_requiring_verification_published" }], "createdAt": "2022-06-01T20:32:58+00:00" }``` This webhook is configured to call another jenkins job, passing it the name of the provider that needs to be verified, the version of that provider that needs to be verified (the git commit hash) and the URL of the pactfile that it needs to verify.

jbecker
2022-06-13 13:37
The jenkins job that it calls checks out the matching project and git hash, starts the service, and then runs the pact verification via the v3 CLI docker image: ``` stage("VERIFY") { steps { script { cmd = "docker run " + "--network host pactfoundation/pact-ref-verifier " + "--broker-url \"${PACT_BROKER_URL}\" " + "--provider-name \"${project}\" " + "--provider-version ${version} " + "--publish " + "--hostname \"localhost\" " + "--port \"$PROVIDER_PORT\" " + "--state-change-url \"http://localhost:$PROVIDER_PORT/_pact/provider_states\" " if (pactfile_url != "false") { cmd += "--url \"${pactfile_url}\" " } else { cmd += "--consumer-version-selectors \"{ 'environment': '${environment}' }\" " } sh cmd } } }``` (the "else" clause in there is because this job can alternatively be supplied with an environment name instead of a pact url, and it will verify the provider against all pacts tagged with that environment)

jbecker
2022-06-13 13:40
Looking back at the project jenkinsfile, the next thing that it does is check if the current project is a pact provider, and if it is, it triggers that same verification jenkins job, but with the environment "master" instead of a pact file url: ``` stage ("VERIFY CONTRACTS") { when { expression { return IS_PACT_PROVIDER } } steps{ script { echo 'Verify pacts where self is provider...' build job: "Pact Verify Provider", parameters: [ string(name: 'project', value: job.projectName), string(name: 'version', value: job.abbrevCommitHash), string(name: 'environment', value: 'master') ], wait: true } } }``` We are treating "master" like an environment since we are on a trunk-based development model and simply want to verify all new changes against the head of master before we allow them to merge.

jbecker
2022-06-13 13:42
Next, as long as the current project is a pact provider or a pact consumer (or both) it will run the can-i-deploy script against the master "environment", blocking the rest of the build if the contracts were not verified: ``` stage("CHECK PACT VERIFICATIONS") { when { expression { return IS_PACT_PROVIDER || IS_PACT_CONSUMER } } steps { script { sh "docker run --network host pactfoundation/pact-cli broker " + "can-i-deploy " + "--broker-base-url=\"${PACT_BROKER_URL}\" " + "--retry-while-unknown=30 " + "--retry-interval=10 " + "--pacticipant=\"${job.projectName}\" " + "--version=\"${job.abbrevCommitHash}\" " + "--to-environment=master " } } }```

jbecker
2022-06-13 13:44
And then finally, assuming this was all successful, we check if the current branch is master, and if it is, we tag it in the pact broker as such (along with also tagging it with the sem ver tag, for easy readability in the pact broker matrix): ``` stage("TAG PACT BROKER") { when { branch 'master' expression { return IS_PACT_PROVIDER || IS_PACT_CONSUMER } } steps { script { sh "docker run --network host pactfoundation/pact-cli broker " + "create-version-tag " + "--broker-base-url=\"${PACT_BROKER_URL}\" " + "--pacticipant=\"${job.projectName}\" " + "--version=\"${job.abbrevCommitHash}\" " + "--tag=\"${job.publishedVersion}\" " sh "docker run --network host pactfoundation/pact-cli broker " + "record-deployment " + "--broker-base-url=\"${PACT_BROKER_URL}\" " + "--pacticipant=\"${job.projectName}\" " + "--version=\"${job.abbrevCommitHash}\" " + "--environment=\"master\" " } } }```

jbecker
2022-06-13 13:44
Does that help clear things up a bit?

julian.alvarezv
2022-06-13 17:10
has joined #general

madu.alikor
2022-06-13 21:09
Anyone got an example of using Pact with Typescript/Javascript aws SAM lambda SQS consumer?

tjones
2022-06-13 23:57
I think there are examples in the pact-js repo for SQS

akke.luukkonen
2022-06-14 14:01
I wasn't able yet to replicate this issue to actually report it with repro steps, but just for my sanity I'd already like to confirm that something like this probably shouldn't happen (first image). The verification result is marked as failed even though all the interactions (just one here) have succeeded, which seems quite odd to me. However, in the same run where that verification result was published, there was one other *unrelated* contract that did fail (on purpose). I'm guessing the failure from this contract propagated somehow to this other contract, but I'm not yet sure how since I was unable to reproduce this with some pseudo-pacticipants. A follow-up question here actually is that when you run the `pact_verifier_cli` (Rust) using `--url`, should it also select additional contracts using the default consumer version selection rules? In the second picture the first contract was the one passed with `--url` but I didn't expect the verifications to run with what I'm guessing is the rule `latest: true` (or whatever is the default?) in addition to it.

akke.luukkonen
2022-06-14 14:03
I noticed this because `can-i-deploy` started reporting failures for the contract in the first image, even though I was quite sure all of the interactions should succeed.

akke.luukkonen
2022-06-14 14:04
I'll try to continue reproducing this situation with some pseudo-contracts tomorrow if I have time from team ceremonies, but I'm curious if this situation should at all be possible so that you have a failed verification with all interactions being successful :thinking_face:

akke.luukkonen
2022-06-14 14:13
For reference, the full command for the verification was ```docker run -e PACT_BROKER_TOKEN pactfoundation/pact-ref-verifier:0.9.11 --provider-name An...-Backend --provider-version 3746... --hostname ... --port 443 --transport https --state-change-url ... --enable-pending --publish --broker-url https://xxx.pactflow.io --url https://xxx.pactflow.io/pacts/provider/An...-Backend/consumer/An...-UI/version/ba5d... --request-timeout 60000```

malukenho.dev
2022-06-14 14:33
has joined #general

vikki.read
2022-06-14 18:58
has joined #general

omer.khalil
2022-06-14 19:33
has joined #general

rxiao
2022-06-15 04:29
has joined #general

matt.fellows
2022-06-15 06:07
There _should_ be notices, explaining why certain pacts were collected and verified

matt.fellows
2022-06-15 06:07
if the pacts are different, I?d expect the verifications for each pact to be separately submitted. This could be a bug

matt.fellows
2022-06-15 06:07
@uglyog any thoughts?

matt.fellows
2022-06-15 06:07
We?ll ideally need a way to repro this to fix it, if it is of course

akke.luukkonen
2022-06-15 06:11
> There _should_ be notices, explaining why certain pacts were collected and verified At least to my eyes if you run without specifying any `--consumer-version-selectors` manually, by default it doesn't report why it chose the ones it did. When giving `--url` the one specified by it always gets run first, but by default I assume it selects the rest with `latest: true` for all related consumers without any other mentions. If you do give the `--consumer-version-selectors` argument, then indeed it reports nicely why it chose the specific ones. (I already changed in my pipeline to run it with `--consumer-version-selectors "[ { \"mainBranch\": true }, { \"deployed\": true } ]"` to be safe). > I?d expect the verifications for each pact to be separately submitted Yeah, I was expecting that there might be some weird condition where this might get violated based on what I saw. > We?ll ideally need a way to repro this to fix it, if it is of course I attempted to do a quick repro with some pseudo-pacticipants but I was unable to get it to work at least so far. I'll try to continue later if I have time.

matt.fellows
2022-06-15 06:13
Could you please try with verbose? That should should show us what options went across

akke.luukkonen
2022-06-15 06:15
The original situation is not available anymore since there have been additional contracts published after it. So I'll have to try to get the repro version up first.

matt.fellows
2022-06-15 06:19
Ok cool, thank you

james.demaine373
2022-06-15 10:22
has joined #general

dmoll
2022-06-15 21:10
has joined #general

rholshausen
2022-06-16 04:27
This is going to be hard to replicate. Ideally, you shouldn't use the `--url` option if you are using the `--broker-url` one. You should select all the pacts via the consumer version selectors.

kurt3402
2022-06-16 04:29
has joined #general

kyo.tang
2022-06-16 06:03
has joined #general

dawoud.sheraz
2022-06-16 09:38
Hello. Is pact a good option for generating Data contracts for a yet-to-be-developed API? For context, the contract will be used both by the consumers to develop the pipeline for using the API and by the provider to have clear understanding of the work at hand.

prasadsolanki
2022-06-16 10:58
has joined #general

mairtin.conneely
2022-06-16 12:02
has joined #general

laura.kennedy
2022-06-16 14:32
has joined #general

mike.geeves064
2022-06-16 22:08
In case you didn't come across it, there's one in a separate repo: https://github.com/pactflow/example-consumer-js-sns on the Pactflow side

abubics
2022-06-17 01:07
Not sure if "data contracts" is a specific thing I haven't heard of, but . . . Pact is consumer-driven, so it's usually a great fit if you don't yet know what the API should do :ok_hand:

gaurav.bajpai
2022-06-17 03:41
has joined #general

gaurav.bajpai
2022-06-17 03:52
Hi Guys, I need some general guidance to implement pact test in my project, i have a bunch of micro services written using spring boot in a product, currently there are unit tests and a lot of E2E tests responsible for testing all functionality, I am trying to use pact and possibly reduce the amount of E2E tests after that. I am confused over the scope of provider side verification tests, whether I should just mock everything beyond controller layer and send a mock response back to verify consumer pact (this approach wouldn't help me in reducing E2E tests) Or run the provider service and mock the outgoing calls and database calls so that all the provider side code gets tested as part of pact verification process (This approach has a bunch of challenges to mock all outgoing interaction points).

abubics
2022-06-17 04:20
howdy :slightly_smiling_face: you've basically described the two general provider verification approaches :ok_hand:

abubics
2022-06-17 04:20
I would stub a little further in, past the controller layer

salmanjamali
2022-06-17 06:49
has joined #general

jbecker
2022-06-17 12:35
The approach my team is taking is to mock-out all microservices that the provider service depends on in order to test it in isolation, but we are also spinning up a test instance of its database (via a simple docker container) rather than actually mocking it out, since our microservices generally own their own databases

alansimonalie
2022-06-17 12:57
has joined #general

ben.a.hubbard
2022-06-17 13:47
has joined #general

mike.geeves064
2022-06-18 11:04
[oh no, sorry I just spotted you said SQS not SNS!]

tjones
2022-06-18 11:16
The pattern is the same though, so an SNS example should be a good starting point

mike.geeves064
2022-06-18 11:28
nod

lafriakh.rachid
2022-06-18 14:24
has joined #general

lafriakh.rachid
2022-06-18 14:30
Hello Everyone, I'm trying to implement Pact for my lambda and my use case is as follows: I have a lambda with an SQS setup so I have one Consumer which is my lambda and I have multiple Providers (Producers) who can put data into the SQS and then to my consumer (lambda). When I try to implement this scenario I can't find a way to have a setup with one Consumer and multiple providers. Is this scenario possible to implement in Pact?

mike.geeves064
2022-06-18 17:24
I haven't done with SQS specifically (I'm using EventBridge), but it's working ok for me having multiple providers - just create a separate MessageConsumer for each Provider you're expecting a message from

mike.geeves064
2022-06-18 17:25
In my case, the type of message and structure is different for each provider so it makes sense to identify them separately anyway (vs these providers all create identical messages)

lafriakh.rachid
2022-06-18 18:12
But having multiple consumers would be a bit strange. Because you actually have one consumer for all your providers. Of course, having multiple consumers would make it possible but I think it's having some drawbacks. Ex: In Pacflow you will not be able to see the big picture in the graphs because we are creating Provider-Consumer for each state we want to verify.

matt.fellows
2022-06-19 20:56
I think Mike is talking about the test class - you need to create a pact for each provider. Logically you can have one consumer and multiple providers

matt.fellows
2022-06-19 20:56
What language are you using?


matt.fellows
2022-06-19 20:59
Ultimately you just need to consider what tool/approach gets you the coverage you need

mike.geeves064
2022-06-19 21:14
Yep, apologies for that not being very clear. In my example, I have a consumer "ig-watcher" which listens for events from multiple providers [e.g. here "ig-analysis" and "ig-tracker"], so there's then a test file for each, where each declares the pact between consumer and provider, e.g. *test_pact_analysis_consumer.py* ```CONSUMER_NAME = "ig-watcher" PROVIDER_NAME = "ig-analysis" @pytest.fixture(scope="session") def pact(consumer_version): pact = MessageConsumer(CONSUMER_NAME, tag_with_git_branch=True, version=consumer_version).has_pact_with( Provider(PROVIDER_NAME), pact_dir=PACT_DIR, publish_to_broker=True, broker_base_url=PACT_BROKER_URL, broker_username=PACT_BROKER_USERNAME, broker_password=PACT_BROKER_PASSWORD, ) yield pact ...followed by pact tests using pact, between provider ig-analysis -> consumer ig-watcher``` then the same but for the other providers involved *test_pact_tracker_consumer.py* ```CONSUMER_NAME = "ig-watcher" PROVIDER_NAME = "ig-tracker" @pytest.fixture(scope="session") def pact(consumer_version): pact = MessageConsumer(CONSUMER_NAME, tag_with_git_branch=True, version=consumer_version).has_pact_with( Provider(PROVIDER_NAME), pact_dir=PACT_DIR, publish_to_broker=True, broker_base_url=PACT_BROKER_URL, broker_username=PACT_BROKER_USERNAME, broker_password=PACT_BROKER_PASSWORD, ) yield pact ...followed by pact tests using pact, between provider ig-tracker -> consumer ig-watcher``` When the "pact" object [can't think of the correct terminology right now] finishes/finalises/closes etc it will submit the appropriate pact for that pair. ...then another "pact" will do the same for the other pairs. My graph in the broker does look quite horrible since multiple consumers can receive and consume the same message [bridge vs queue] but that's another problem :sweat_smile:

courtney.lum
2022-06-20 04:02
has joined #general

brocheleau
2022-06-20 08:42
@gaurav.bajpai We just went through this process and found the mocking to become so extensive (for a larger GraphQL API) that we pivoted to using SQLite in our pipeline with some seeding scripts to replace the DB mocks (similar to @jbecker above). Its now been 4 months and I think the overall developer experience has improved.

markrkell
2022-06-20 09:00
Hello :wave: Sorry if this has already been asked. I've just got a question around verifying contracts by provider that were published by branches on the consumer so get tagged with the branch name. We have found that we're having to update our provider verification code (consumerVersionTags) each time to reference the branch where the contract that was published from. I've read https://docs.pact.io/provider/recommended_configuration page in the pact documentation and it suggests using the using the git branch name in ConsumerVersionSelectors and ensure the git branch for both the provider and the consumer are the same when the contract gets published and verified. We have tried this and it appears to work but means we'd need to remember to do this every time going forward. This https://docs.pact.io/provider/recommended_configuration also mentions _dynamically determining the tags of the feature branch_ which sounds like a much better option. Has anyone done this and got some examples or other suggestions?

matt.fellows
2022-06-20 09:26
The CI/CD workshop (howtolearn) shows how to address this

2022-06-20 09:26
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-06-20 09:26
:point_up:

markrkell
2022-06-20 09:37
Thanks for the links Matt but is there anything more specific that covers verifying contracts on branches?

lafriakh.rachid
2022-06-20 09:39
Hi Matt, Hi Mike Thank you for your response. @matt.fellows I'm using JS in the consumer and Kotlin in the provider. @mike.geeves064 Thank you mike for your examples. Now I understand it better. Thank you guys

woojos
2022-06-20 09:58
has joined #general

abdou.ahzab
2022-06-20 10:08
has joined #general

matt.fellows
2022-06-20 10:57
are you using ?tags? or ?branches? and ?releases??

matt.fellows
2022-06-20 11:02
There are two main ways: 1. webhooks - whenever a consumer publishes a new pact (from any branch) you can trigger a build to verify it: https://docs.pact.io/pact_nirvana/step_5#d-configure-pact-to-be-verified-when-provider-changes 2. pending pacts - https://docs.pact.io/pact_broker/advanced_topics/pending_pacts

markrkell
2022-06-20 12:14
We have been using tags but have recently read about branches, we're already using the webhook to trigger the verification but unless we change the consumer tag on the provider to point to the branch it never verifies the contract published from branch

markrkell
2022-06-20 12:14
Thanks I'll have a read of pending pacts

dstekanov.tech
2022-06-20 15:28
has joined #general

rohit.thadhani
2022-06-21 04:39
has joined #general

jvieira
2022-06-21 22:28
has joined #general

harris
2022-06-22 00:09
Hello, quick question about monolith contract testing pipeline strategies: so we have monolith app (provider) with multiple consumers, what is the best strategy for blocking release(we do continues delivery) from provider? monolith(provider) got lots of responsibilities and all of subsystems are dependent on monolith, so when 1 consumer contract fail, should we block entire monolith release? until fix the contract? I know it is sounds same as monolith / micro services release issues, but I am looking for some similar real example for specifically contract testing, thanks

abubics
2022-06-22 01:26
I mean, if it's going to break stuff, you should probably block the entire release, right? Otherwise you're deploying breakages.

abubics
2022-06-22 01:26
Strategies to mitigate that somewhat extreme stance might include feature flags, versioned APIs, etc

abubics
2022-06-22 01:28
The perspective should probably be that Pact (or any kind of testing) is just highlighting existing problems that weren't being caught before. Dealing with those problems isn't the job of the testing tools, it's more based around culture, practices, discipline, communication, etc :innocent:

harris
2022-06-22 03:05
I agree 100% Boris, yeap we are about to expand the contract testing, but little concerned that if we make soft fail(current one) the contract step, no one really care about lol ok I will throw some rocks to the organisation :slightly_smiling_face: thanks

abubics
2022-06-22 05:55
Good luck! I hope you can get traction with a simple reasoning approach :pray:

nuno.frias
2022-06-22 12:14
Hello, I am a bit confused by this apparent issue that i am encountering. Tbh I am not sure if it is an actual issue or if I am not doing things correctly. Anyway here is what is happening: I have a consumer that interacts with a provider using both HTTP and Kafka. I have two consumer tests for each, each creating its own pact file. I am publishing the Pact files to http://pactflow.io using the Pact cli tool (`pact-broker publish`), but when I go to the http://pactflow.io UI I can only see the HTTP interaction. However when I retrieve the latest pact for the provider I get a JSON file that contains both interactions and messages -- I used curl to retrieve the JSON. I also built a provider test but only for the HTTP interaction (using `HTTPVerifier`), what I am also seeing is that when I run the provider test it is attempting to verify the Kafka message. Has anyone experienced a similar situation?

nuno.frias
2022-06-22 12:47
This is the relevant bit of the response I get when I retrieve the latest pact for the provider. ```curl -i -H "Authorization: Bearer $BEARER_TOKEN" https://<my-company>.http://pactflow.io/pacts/provider/<my-provider>/consumer/<my-consumer>/version/<my-version>```

nuno.frias
2022-06-22 12:57
Just a clarification the provider test is both verifying the HTTP interaction and the Message interaction. The message Message interaction obviously fails.

matt.fellows
2022-06-22 12:57
You need to have different names for providers of different types. That's resolved in the latest spec but I think you're using Go and we haven't added v4 support yet (it's quite new)

nuno.frias
2022-06-22 12:59
Indeed I am using Go. Thank you

nuno.frias
2022-06-22 12:59
That makes sense.

nuno.frias
2022-06-22 13:00
Any idea when v4 will be supported in GO?

matt.fellows
2022-06-22 13:02
Over the next few months it will gradually roll out, likely on a beta branch initially and then merged into mainline

qingyuliu
2022-06-22 15:23
Hi team, I have a question about message level contract testing. In message level test, will the provider write the message into an existing kafka topic? Or just create the object to match the consumer defined Pact?

marcus.james
2022-06-22 15:28
has joined #general

jonas.pena
2022-06-22 15:50
has joined #general

abudi.hijazi.01
2022-06-22 16:44
has joined #general

nuno.frias
2022-06-22 17:16
Thank you :+1:

vaddisrinivas170497
2022-06-22 18:57
has joined #general

bethskurrie
2022-06-23 01:17
Sorrynotsorry for posting a job in the general channel, but please excuse us this once - I think you?ll agree it?s a pretty special moment for the Pactflow team. Did I mention we?re excited?

bethskurrie
2022-06-23 01:17
It will just create the object.

bethskurrie
2022-06-23 01:18
The queue technology is ignored. It means you need to decouple your business logic from your message sending logic, but this is generally a good practice anyway.

adam.anderson
2022-06-23 03:46
has joined #general

yegorisa
2022-06-23 03:47
has joined #general

swapnil.jagdale
2022-06-23 05:19
has joined #general

mark.mcmurray
2022-06-23 08:33
has joined #general

jacek.maciag
2022-06-23 09:15
has joined #general

vaddisrinivas170497
2022-06-23 16:18
hi lil new here, I have created a pact using the junit5 library. How can I publish it to local pact broker? is there a way to do that without using the cli?

matt.fellows
2022-06-23 22:27
why can?t you use the CLI?


madhulika.mitra
2022-06-24 09:26
Hi - Pact Gurus :slightly_smiling_face: Is there a limit of interactions(tests) in pactflow. I tried with 1247 interactions and the test timed out .

sandor.arpa
2022-06-24 09:30
has joined #general

sandor.arpa
2022-06-24 09:31
:wave: Hi everyone!

sandor.arpa
2022-06-24 09:33
Could you, please point me to the right channel? I've got an issue with NumberTypeMatcher where the matcher does not recognise a negative number as Integer :thinking_face: Details in :thread:

sandor.arpa
2022-06-24 09:36
The generated pact looks like this: ```$.event_details.net_amount=MatchingRuleGroup(rules=[NumberTypeMatcher(numberType=INTEGER)]``` The error I get: ```BodyMismatch(expected=-8000, actual=-8000, mismatch=Expected -8000 (JsonPrimitive) to be an integer``` I'm on version 3

sandor.arpa
2022-06-24 09:36
Any help would be highly appreciated

sandor.arpa
2022-06-24 09:36
(Yes, tried to search the documentation first)

matt.fellows
2022-06-24 09:54
That's a lot of interactions! If the test is timing out it's not Pactflow. Pactflow is just the storage or the contract, the execution happens locally. What test framework are you using?

madhulika.mitra
2022-06-24 09:54
I am trying to do a bidirectional test...so all execution is on pactflow I thought :confused:

matt.fellows
2022-06-24 09:55
Aha! Ok then yes this does you're right

matt.fellows
2022-06-24 09:57
Please send a support ticket to with the details of what's failing so we can investigate. Ideally please share the contract you've uploaded on both sides

matt.fellows
2022-06-24 09:59
Can you please share the actual contract file and also the actual response from the provider?

matt.fellows
2022-06-24 09:59
One hypothesis is that it's a stringified number

matt.fellows
2022-06-24 10:00
I think you're using #pact-jvm ? Might have luck in that channel

sandor.arpa
2022-06-24 10:01
Ok, thank you! I'll try my luck in pact-jvm

mwilso29
2022-06-24 11:19
has joined #general

renaud.meurisse
2022-06-24 12:47
has joined #general

rk8085858
2022-06-26 08:12
has joined #general

alex.savage
2022-06-27 08:26
has joined #general

simon.selvadurai
2022-06-27 08:28
has joined #general

yasir.khan
2022-06-27 11:21
has joined #general

willem.basson
2022-06-27 11:25
has joined #general

edward.francis
2022-06-27 11:32
has joined #general

laura.cabantous
2022-06-27 11:35
has joined #general

ruslan.charuh
2022-06-27 12:18
has joined #general

yousafn
2022-06-27 12:29
Happy Monday everybody :ralph-wave: and welcome to our new joiners

ruslan.charuh
2022-06-27 12:31
:wave: Hi everyone!

pramod-arjun.bhalerao
2022-06-27 12:54
has joined #general

pramod-arjun.bhalerao
2022-06-27 12:55
:wave: Hi everyone!

ssomepalli
2022-06-27 14:30
has joined #general

owen.oclee.old
2022-06-27 16:13
has joined #general

oherescu
2022-06-27 19:21
has joined #general

nathan.tejuco
2022-06-28 03:50
has joined #general

jun.ito
2022-06-28 07:47
has joined #general

daniel.shamaeli
2022-06-28 09:01
has joined #general

michael.oloyede
2022-06-28 09:55
has joined #general

lucas.azzola
2022-06-29 04:18
has joined #general

jens.suhr
2022-06-29 09:25
has joined #general

mike.geeves064
2022-06-29 10:32
:thinking_face: I'm looking at Pact message (in python specifically) and would like to get rid of the "...as there is no --provider-states-setup-url specified" warning and possibly add usage of states in somewhere. From a quick grep of "provider.states.setup.url" across pact-foundation and pactflow repos I can't find any examples (thought it was worth a try!) - it's used in "normal" http style Pact where the provider is spun up and the additional states endpoint can be spliced in somewhere, but I'm not sure how a nice pattern for message would look? Given the handler mapping approach for each of the provider states to implement, maybe it isn't actually necessary as this can be done via the defined handler itself? TLDR: does anyone have examples using provider states for message?

thammarith.likittheer
2022-06-29 10:46
has joined #general

mike.geeves064
2022-06-29 11:01
[for python, could do something lightweight with https://docs.python.org/3/library/http.server.html as per Beth's example https://stackoverflow.com/questions/47539344/pact-how-to-set-up-provider-states ...but I'm not sure that's how message is intended :thinking_face: ]

matt.fellows
2022-06-29 11:38
so the idea of provider states is definitely still applicable to messaging, albeit because in the case of messages the description is the unique key, you can often just use the description that also includes the state. I prefer not to do that though personally. But really, it?s exactly the same concept as HTTP. *maintainer detail???.* The way we handle this in several of the ?client? languages (not the canonical Rust, Java or Ruby) is that each language spins up an HTTP server transparently to the user, and registers user provided ?state handler? functions with that server, and then gives that server URL to the verifier. When the state request comes in, the framework discovers the function to call, and delegates to the user provided function to ?setup? the state. This way, it looks just like a regular function to the test author, but actually they are effectively implementing an HTTP handler.

mike.geeves064
2022-06-29 14:01
:thinking_face:

mike.geeves064
2022-06-29 14:02
I may be asking the wrong question

mike.geeves064
2022-06-29 14:04
So, I'm aware of the sneaky http implementation approach, and have gone through chunks of the pact-python implementation, it doesn't seem to provide a way to hook in with the http server to give those states, hence I was assuming maybe the expectation is to spin up something outside

mike.geeves064
2022-06-29 14:10
I should probably checkout some of the other implementations, could be something isn't complete on the python side

mike.geeves064
2022-06-29 14:21
Looking at example-provider-js-sns to give you some js rather than my python, you have: ``` const opts = { ...baseOpts, ...(process.env.PACT_URL ? pactChangedOpts : fetchPactsDynamicallyOpts), messageProviders: { "a product event update": () => createEvent(new Product("42", "food", "pizza"), "UPDATED"), }, }; const p = new MessageProviderPact(opts);```

andrevpuc
2022-06-29 14:24
has joined #general

mike.geeves064
2022-06-29 14:29
~So in this case, would you say if some actual state was required, instead of createEvent you would map to e.g. createEventWithState which 'did some stuff' to setup the state, and then made the call to createEvent, returning the payload~ (I think I am confusing myself wrt the hexagonal architecture approach - in this case the 'state' has already happened and as a result of the 'state' existing, the attributes for Product are provided) the handler is responsible for 'setting' any state based on the description, and also returning the appropriate payload for the message? -> in which case the provider-states-setup-url is no longer relevant and python shouldn't be WARN'ing that it's missing -> so possibly it would make sense to add an additional endpoint which does nothing, and send that to the verifier as a default provider-sates-setup-url as the warning isn't relevant?

mike.geeves064
2022-06-29 14:29
`make test` is failing for me on that example so I can't actually see how that one is expected to behave :thinking_face:

mike.geeves064
2022-06-29 14:34
"you can often just use the description that also includes the state. I prefer not to do that though personally." could you elaborate on that a little please? :slightly_smiling_face: as in do you mean having e.g. "A product exists with id 3" and then in your handler scraping out the 3 to create a Product? [and you prefer to not do that] ..or something else?

mylesjj
2022-06-29 16:26
has joined #general

matt.fellows
2022-06-30 01:08
Let?s say you are testing an `Order` updated use case, which has these scenarios: 1. Order has new shipping information 2. Order has a new delivery note 3. ? You could write the consumer tests for these in two ways: *1. The use case + scenario is all in a single description:* ?An order is updated with new shipping information? ?An order is updated with a new delivery note? ?An order is updated with ?? *2. The use case + scenario is separated by different provider states* use case: ?An order update event? scenario 1: ?with new shipping information? scenario 2: ?with a new delivery note? scenario 3: ??? I think 2 is more readable, but does rely on the state handlers instead of a single function that handles the whole thing

matt.fellows
2022-06-30 01:09
> -> in which case the provider-states-setup-url is no longer relevant and python shouldn?t be WARN?ing that it?s missing I agree that we should not have this warning though if there are no states to be setup. It?s not a useful warning - that could be fixed in the Ruby core I think (i.e. don?t warn if there are no states and that URL is not set)

matt.fellows
2022-06-30 01:09
cc @bethskurrie

bethskurrie
2022-06-30 01:37
sure, thanks.

bethskurrie
2022-06-30 01:38
is it python that is warning or ruby?

mike.geeves064
2022-06-30 02:02
It's coming from ruby I believe, `set_up_provider_state.rb` / `set_up_provider_state_spec.rb` I'll see if I can find other language examples to see what they do, in case it's a non-issue down to the way the python implementation sets things up > *The use case + scenario is separated by different provider states* Do you know of any other examples demonstrating that approach for message? Don't worry about looking if not, (I'll have a look through in the morning) I haven't been able to see so far how that's intended to hook in :thinking_face: Only approach 1 with the single description as it's basically a map of description to handler

matt.fellows
2022-06-30 02:03
Not any public ones I don?t think, but conceptually I?m not sure why it?s different than HTTP? Aside from the fact that message implementations tend to be at the function level, rather than at an HTTP API level (spanning a whole live system)

mike.geeves064
2022-06-30 02:04
possibly I've just completely missed something here :smile:

matt.fellows
2022-06-30 02:05
I think you?re right, in that most examples I?ve seen don?t actually make use of states for messages, but the infrastructure is there to support it.

matt.fellows
2022-06-30 02:06
and if it helps, it doesn?t look like a thing unique to python

mike.geeves064
2022-06-30 02:06
consumer side has something like ```( pact.given("A document deleted successfully") .expects_to_receive("Description with broker") .with_content(expected_event) .with_metadata({"Content-Type": "application/json"}) )``` provider side has something like ```def test_verify_success(): provider = MessageProvider( message_providers={ "A document created successfully": document_created_handler, "A document deleted successfully": document_deleted_handler, }, provider="ContentProvider", consumer="DetectContentLambda", pact_dir="pacts", ) with provider: provider.verify()```

mike.geeves064
2022-06-30 02:07
so you can match the "A document deleted successfully" but all the happens is the document_deleted_handler method is called

mike.geeves064
2022-06-30 02:08
the setting up of states is then just doing ```def _setup_states(self): message_handlers = {} for key, handler in self.message_providers.items(): message_handlers[f'{key}'] = handler() resp = http://requests.post(f'{self._proxy_url()}/setup', verify=False, json={"messageHandlers": message_handlers}) assert resp.status_code == 201, resp.text return message_handlers``` so calling that handler, and passing whatever it generates as a key -> payload

matt.fellows
2022-06-30 02:09
wait, that?s the exact opposite that I would expect: ```( pact.given("A document deleted successfully") <--------- this is the state .expects_to_receive("Description with broker") <--------- this is the actual scenario, that should map to a handler .with_content(expected_event) .with_metadata({"Content-Type": "application/json"}) )```

matt.fellows
2022-06-30 02:11
```def test_verify_success(): provider = MessageProvider( message_providers={ "A document created successfully": document_created_handler, <--- scenario handler, not a state "A document deleted successfully": document_deleted_handler, }, state_handlers={ "A document deleted successfully": some_func, <---- in an ideal world, we want something like this }, provider="ContentProvider", consumer="DetectContentLambda", pact_dir="pacts", ) with provider: provider.verify()```

mike.geeves064
2022-06-30 02:14
only message_providers on the python side as far as I can see

matt.fellows
2022-06-30 02:17
so does it provide an option to provide a states setup URL?

mike.geeves064
2022-06-30 02:18
not visibly, but it gets passed through to the verifier

mike.geeves064
2022-06-30 02:18
:thinking_face:

mike.geeves064
2022-06-30 02:18
I can see stateHandlers and messageProviders in pact-js, but then examples e.g. example-provider-js-sns only make use of messageProviders

matt.fellows
2022-06-30 02:20
I?m sure there are plenty of options we don?t use in all of the examples

matt.fellows
2022-06-30 02:20
we often get the feedback ?do you have an example with feature x? and ?your examples are too complicated? (because they use all things)

matt.fellows
2022-06-30 02:20
can?t win that one!

mike.geeves064
2022-06-30 02:20
:smile:

mike.geeves064
2022-06-30 02:20
for sure

matt.fellows
2022-06-30 02:21
I?m sure there is a lesson in there somewhere

matt.fellows
2022-06-30 02:21
also, are you pairing with Yousaf or something? Why are you both awake!

mike.geeves064
2022-06-30 02:21
this isn't causing me a particular problem atm btw, so maybe something to come back to slightly more structured :thinking_face:

mike.geeves064
2022-06-30 02:21
lol

mike.geeves064
2022-06-30 02:22
I've been doing the usual going in circles a bit looking at trying to improve some of the examples and hitting the...but...different examples...things not working...head hurt :smile:

mike.geeves064
2022-06-30 02:22
it is getting a bit early yes

matt.fellows
2022-06-30 02:23
> I?ve been doing the usual going in circles a bit looking at trying to improve some of the examples and hitting the...but...different examples...things not working...head hurt Python or beyond?

mike.geeves064
2022-06-30 02:24
yes

mike.geeves064
2022-06-30 02:25
:smile:

mike.geeves064
2022-06-30 02:28
started adding one of Tim's message examples which was a bit more useful over to python but then tangenting into a bottomless rabbit hole of thinking how an uber example repo could work :thinking_face:

mike.geeves064
2022-06-30 02:29
as per the, _"do you have an example with feature x? and ?your examples are too complicated?_ :slightly_smiling_face:

mike.geeves064
2022-06-30 02:29
I think for now I'll head for sleep and maybe the implications of "wait, that?s the exact opposite that I would expect" will make more sense in the morning :joy:

qingyuliu
2022-06-30 09:35
Hi team, I'm wondering what is the difference between Kafka schema registry and pact message level contract testing. Is there any article about Pact message level contract?

oliviawalsh1
2022-06-30 09:49
has joined #general

mylesjj
2022-06-30 12:34
I'm still looking! An example azure-pipelines.yml for an azure devops ci/cd pipeline would be most useful. All the examples I can find are for Jenkins etc.

hiepluong2205
2022-07-01 06:40
has joined #general

yousafn
2022-07-01 10:45
You are amazing Mike and we really appreciate you! Thanks for this, I knew it was going to be a rollercoaster, just wasn't sure how much :sweat_smile:

mike.geeves064
2022-07-01 10:46
:relaxed:

mike.geeves064
2022-07-01 10:47
There is still also the possibility I've completely misunderstood and gone off on one, but if that's the case it is still a good place to try and help with docs to understand!

mike.geeves064
2022-07-01 10:48
Hadn't even heard of provider state injected :thinking_face: which may or may not have any relevance here

yousafn
2022-07-01 10:51
Aye I was about to say exactly that, whatever comes out of this though, will benefit others and help clear some of the confusion! As if you and me are confused, then I would imagine others are as well.

matt.fellows
2022-07-01 10:56
I think one thing we could do to save everyone?s confusion, is to have a clear set of features that are used as a ?this is what a full implementation looks like?. https://docs.pact.io/roadmap/feature_support is a start, but it?s mostly only useful for maintainers that know what each of those things means, and means almost nothing to a brand new user.

matt.fellows
2022-07-01 10:56
It also of course can and does drift from reality (which I think you proposed some solutions to, Mike)

mike.geeves064
2022-07-01 10:57
Yeah having a few chats with Yousaf about that, I have a cunning plan :grinning:

mike.geeves064
2022-07-01 10:57
I wouldn't agree about meaning nothing to a user though, if it's presented right

mike.geeves064
2022-07-01 10:58
Oh wait specific link rather than the concept nvm :grinning:

mike.geeves064
2022-07-01 10:59
I'd like to have something like that auto generated and testable with a whole load of dark magic :grinning:

matt.fellows
2022-07-01 10:59
yes! I think it could mean a lot, but right now unless you know what `Injecting values from provider state callbacks` it?s only useful for the basic/obvious features.

matt.fellows
2022-07-01 11:00
There?s no one place that says ?here are all of our features and how to use them?, with code snippets etc. and also blank spaces so it?s obvious ?oh, Python doesn?t support that. Maybe I can add it??

mike.geeves064
2022-07-01 11:07
That's what I'm working on :slightly_smiling_face:

mike.geeves064
2022-07-01 11:08
I think it would be really useful but need to see what the barrier to entry could look like etc

mike.geeves064
2022-07-01 11:09
Going a bit ot here but definitely worth carrying on the discussion!

saleh.elnagar
2022-07-01 13:20
has joined #general

mike.geeves064
2022-07-02 10:04
hm, I'm still not quite getting my head around message_provider and state_handler would work in a nice demonstratable flow :thinking_face: it makes sense to me for normal HTTP where the consumer is pulling from the provider, but where the provider is pushing to the consumer I'm finding it harder to "explain" maybe if the given/state is effectively adding to a queue/buffer object [i.e. add a payload onto a stack or something [that you can setup nicely in a test, similar to let's pretend there's a user database by setting up a dict in other examples] and then the handler is responsible for handling whatever is in the queue and pushing it out but that does seem like extra complexity without an understandable value :thinking_face: vs the slightly muddy just doing in one hit where the description/given is doing everything going to try and go through some of this with @yousafn next week, not sure if it makes sense to look at progressing the feature list examples idea and do this as one of them [later], or try and make sense of message by itself first anyway :thinking_face:

animesh.kumar
2022-07-03 16:54
has joined #general

omri.benyair
2022-07-04 03:14
has joined #general

abudi.hijazi.01
2022-07-04 10:38
Does anyone know how to generate a pact file through GH actions. I've written a yml script that runs the consumer tests to generate the pacts. The tests are passing, and it's saying pact files generated, but there's no files in my repo, does anyone know how to access the generated file? This is the script output ``` API Pact test [2022-07-04 10:29:28.863 +0000] INFO (2056 on fv-az459-64): pact@9.17.3: Setting up Pact with Consumer "consumerv1.0.0" and Provider "provider" using mock service on Port: "1234" ? ID 12 exists [2022-07-04 10:29:28.889 +0000] INFO (2056 on fv-az459-64): pact@9.17.3: Pact File Written [2022-07-04 10:29:28.890 +0000] INFO (2056 on fv-az459-64): pact-node@10.17.4: Removing Pact process with PID: 2067 [2022-07-04 10:29:28.892 +0000] INFO (2056 on fv-az459-64): pact-node@10.17.4: Deleting Pact Server with options: {"timeout":30000,"consumer":"consumerv1.0.0","cors":false,"dir":"/home/runner/work/consumerpoc/consumerpoc/pacts","host":"127.0.0.1","log":"/home/runner/work/consumerpoc/consumerpoc/logs/pact.log","logLevel":"INFO","pactfileWriteMode":"overwrite","provider":"provider","spec":2,"ssl":false,"port":1234,"pactFileWriteMode":"overwrite"} 1 passing (572ms)```

matt.fellows
2022-07-04 10:40
There are lots of examples that run on GitHub actions. In fact, probably all of the official ones do and definitely the Pact JS ones that this looks to be using

matt.fellows
2022-07-04 10:41
Why do you need the generated file? You would normally publish it to a pact broker (or a service like Pactflow).

abudi.hijazi.01
2022-07-04 10:42
How am I supposed to push the file without the file

matt.fellows
2022-07-04 10:42
The file should already be on the GitHub servers you should be publishing from

matt.fellows
2022-07-04 10:43
What makes you believe the file isn't there?

matt.fellows
2022-07-04 10:45
All of these examples build and publish from GH: https://docs.pactflow.io/docs/examples

abudi.hijazi.01
2022-07-04 10:46
Usually when it's ran locally, the file appears in the pacts/ dir

abudi.hijazi.01
2022-07-04 10:47
Obviously this can't be added to your GH repo just like that

mike.geeves064
2022-07-04 10:47
Do you mean it isn't being commited to the repo by the GH action? [I'm not sure you'd want that anyway]

abudi.hijazi.01
2022-07-04 10:48
No I don't want that, I want to push it to my broker

matt.fellows
2022-07-04 10:48
So the file should be in the same relative path that it is locally, just on the remote GH file system.

abudi.hijazi.01
2022-07-04 10:49
riiiiiggght, makes sense, let me try now

mike.geeves064
2022-07-04 10:51
Hang on, do you actually "need" that file? [vs your Pact tests submitting]

mike.geeves064
2022-07-04 10:52
[not sure which of those examples show a broker configured]

abudi.hijazi.01
2022-07-04 10:52
I need to push the file to my pact broker, I don't "need" it, as in to open it or look at it

abudi.hijazi.01
2022-07-04 10:53
basically I need to know where it's located

mike.geeves064
2022-07-04 10:53
ok

mike.geeves064
2022-07-04 10:53
you don't need to know where it is as such, that part can be handled "automatically"


abudi.hijazi.01
2022-07-04 10:54
Im not using pactflow as my broker, so I have to manually push it

matt.fellows
2022-07-04 10:54
If you see the log output you shared above, the exact path is logged in the output

matt.fellows
2022-07-04 10:54
But you should use a relative path

mike.geeves064
2022-07-04 10:55
I might be misunderstanding something here, apologies if so https://github.com/pact-foundation/pact-workshop-js/#publish-contracts-from-consumer

mike.geeves064
2022-07-04 10:55
You don't need to be using PactFlow as the broker, it is the same if you are hosting your own OSS Pact Broker

chriswilliamsef
2022-07-04 13:11
has joined #general

chriswilliamsef
2022-07-04 13:24
Hi I?m hoping I could get some help with this - we?re setting up the first bidirectional test, and validation has failed because of ? we?ll we ?re not sure! The error looks more like an implementation error than something defined in our contract or openapi spec

chriswilliamsef
2022-07-04 13:26
OpenAPI3 spec file for the provider, and consumer contract generated via Montebank as per https://github.com/pactflow/example-bi-directional-consumer-mountebank

rioka68
2022-07-04 13:32
has joined #general

heinenm
2022-07-04 14:01
has joined #general

chriswilliamsef
2022-07-04 16:02
Ohh, I worked out what the above error was caused by - it was the way that the results from the Mountebank mocker where being turned into a contract - so fixed it and opened a PR - https://github.com/pactflow/example-bi-directional-consumer-mountebank/pull/6

matt.fellows
2022-07-04 23:22
Ah, thanks for that

matt.fellows
2022-07-04 23:23
It wasn?t intended to be a general solution to Mountebank. I?m interested as to why it only started failing now? :thinking_face:

matt.fellows
2022-07-04 23:23
in any case, much appreciated

abubics
2022-07-05 01:47
Also, it doesn't need to be committed in your repo, it just needs to be available in the build step runtime.

omri.eyal
2022-07-05 06:22
has joined #general

vikki.read
2022-07-05 10:22
Hi there! I was wondering if anyone is using bi-directional contract testing with multiple providers sharing a single contract? I'll thread some context :thread:

vikki.read
2022-07-05 10:22
I'm working with some code that uses a protocol as an abstraction, to make it easy for consuming code to call the same endpoints on different API providers. I'd like to formalise the protocol as an OpenAPI spec, and contract testing could be helpful to help us understand/keep track of how they're used within our system. I implemented this naively but you end up with `consumer*provider` contracts very quickly, and as it's a protocol we'd like a single provider contract, but with many provider implementations. I've got some ideas on how to make this work but thought I would check in here, in case anyone else is doing this, or it doesn't make sense and I'm misunderstanding something!

shen-yu
2022-07-05 15:35
has joined #general

ben.foster
2022-07-05 15:42
has joined #general

maarten.gryp
2022-07-05 16:20
has joined #general

hazem
2022-07-05 22:07
:wave: we just started to evaluate pactflow and i'm able to trigger webhook events to bitbucket thanks to the https://docs.pact.io/pact_broker/webhooks/template_library. question. are there any resource guides available to trigger aws codebuild? does anyone have any experience triggering from pactflow to codebuild?

matt.fellows
2022-07-05 23:15
I didn?t realise people use code build? :troll:

matt.fellows
2022-07-05 23:15
If you don?t hear anything back, we?d love to get another update to that template library for the next person !

hazem
2022-07-05 23:18
most definitely - we're halfway between bitbucket and codebuild (moving towards cb) as our build tool.

harris
2022-07-06 03:35
Hello question regarding `--provider-states-setup-url` , if somehow, we cannot create a seperate endpoint for provider state url, what is the alternative way? we can use real endpoint in `before` block to arrange test data then run tests? I would like to know how others are doing :slightly_smiling_face:

mike.geeves064
2022-07-06 06:55
Could you elaborate on the _cannot create a separate endpoint_ to help understand the situation :slightly_smiling_face:

megha.t
2022-07-06 06:56
has joined #general

ravindra.dhaka
2022-07-06 07:08
has joined #general

mrigendra.ranjan
2022-07-06 07:08
has joined #general

deepak.bhoria
2022-07-06 07:11
has joined #general

cjenkins
2022-07-06 07:17
has joined #general

gustavo.chain
2022-07-06 08:04
has joined #general

tobias.friedrich
2022-07-06 08:31
has joined #general

ganesh.panchagnula-no
2022-07-06 11:50
has joined #general

morten.gejl
2022-07-06 13:02
has joined #general

varunthaper
2022-07-06 15:17
has joined #general

jwheatley
2022-07-06 17:12
has joined #general

jwheatley
2022-07-06 17:32
Hey Everyone, I am a QA at my company and new to Pact. Our company uses a microservice environment. Apparently, they tried to implement Pact in the past and it didn't catch on. I wanted to research a bit more to see if anything has changed. Here were some of the concerns that someone listed out for me from my company and I was hoping someone could help me understand if they are valid concerns still: ? its consumer-oriented design being inconvenient to work with ? Having services written in ruby, python, javascript and golang adds additional complexity. I believe there are pact libraries available for all of those languages, but I don't know anything about the non-ruby ones. ? It's not well-suited to APIs where we don't control both ends of the implementation, e.g. APIs we provide to clients

jbecker
2022-07-06 17:47
I'm an SDET building my company's pact implementation from scratch, and so far my experience with it has been: ? The consumer-oriented design is very convenient to work with, because pact effectively produces a contract automatically from the way I use mocks anyways in my consumer unit tests, and this ensures my contract only specifies the things my consumer actually cares about, leaving the provider full leeway in modifying things that are not yet in use. (I was aware of this criticism myself before getting into Pact and I don't really understand it other than maybe people who didn't understand the best-practices behind consumer-oriented contract testing were just doing it wrong.) ? Pact, in my experience so far, seems very language independent. There are lots of neat libraries for different languages for building up the contract automatically in your consumer, but I've found that outside of that, I've been using the CLI tools for everything else: for uploading and verifying pacts. ? This is true, it is not designed for APIs where you don't control both ends, but my company (as many likely do) uses a reverse-proxy front-end with all our public apis. By writing consumer contract tests into this, we can effectively test our public apis, since our reverse-proxy service does very little logic and passes-through public requests to the back-end services.

jwheatley
2022-07-06 18:00
Thank you, thank you! the more im researching, the more I like it, but it's very difficult to convince people who are hesitant to try something new! I need to really look at their concerns (as you are helping me to do) to figure out if they are valid or just knee jerk reactions

jbecker
2022-07-06 18:15
I think one of the tricks to helping people understand the consumer-oriented nature of it is that most people have this impression that that means you make a change to the consumer, and it changes the contract, and then the next time you try and build the provider it breaks because of a mistake the consumer made. This is what I mean about people doing it wrong though. Ideally, if you're following something like gitflow, you make all your changes in branches, test those branches, and only if the tests pass can you merge them. Well, by the same philosophy, you block merges to both consumers _and_ providers if _either_ breaks the contract between them. So even though the consumer defines the contract, it still has to verify the contract against the provider's master branch before it can be merged to the consumer's master branch, so you can be sure you won't break the provider.

noor.hashem
2022-07-06 20:23
has joined #general

jwheatley
2022-07-06 21:15
thank you for explaining this, i do think this is actually a misconception amongst my teammates!

harris
2022-07-06 22:29
yeap, it is little bit funny situation, I try to adopt contract tests in organisation, people want to see real example, but I dont have enough knowledge/skill set to create endpoint in provider side.

harris
2022-07-06 22:31
so if there is some alternative way, it would be good. when provider app is PHP, is it okay to create `--provider-states-setup-url` in JS and whenever request come to that url, just inject data through real(provider) api?

harris
2022-07-06 22:32
for example, ?when user id123? requird POST({user:123}) like this?

harris
2022-07-06 22:33
so contract -> state setup url->request to provider? not sure

tjones
2022-07-07 00:44
:taco: for @jbecker! Very well explained. A couple of pieces of personal opinion: Many many many teams do provider-driven development, which just seems mad to me. If you didn't have the consumer, you wouldn't need the provider. So why is the provider specifying the contract? It doesn't know what the consumer needs, only the consumer does. My personal opinion is that developing this way costs everyone time, and leads to unnecessary frustration and friction between teams - even ignoring contract testing, I don't think developing this way makes sense. > It's not well-suited to APIs where we don't control both ends of the implementation, e.g. APIs we provide to clients The general case is if you can't know who the consumers are, consumer-driven contract testing is not a good fit. Pact can work if you don't _control_ the implementation, but still know who they are (and can ask them to send you a pact file). It does depend, though- if you're also providing an API client library to your customers, then you can contract test that library. @jbecker?s point about breaking changes being a common point of confusion is spot on. Using Pact will mean you need to think about when you should ask compatibility questions (do I want to fail the master build if the master consumer is not compatible? Often, no). I don't personally use gitflow (and I try to avoid branches, depending on the team), but you can still use pact very effectively with gitflow, github-flow or trunk based - you just need to be clear about when and what you expect to be compatible. Something that may have changed since you last looked at it is that the broker has better support for telling pact which contracts you expect to fail the build. Have a look at pending-pacts and work-in-progress pacts here https://docs.pact.io/pact_broker/advanced_topics/pending_pacts > ruby, python, javascript and golang These are all languages that pact supports :sunglasses: . They share the same core, so anything you can do in one will work in the others.

abubics
2022-07-07 00:47
Also, if everyone is in a provider-first workflow, BDCT was added to make the transition away from that mentality easier. But if you can start with consumer-driven, that'd be even better :ok_hand:

abubics
2022-07-07 00:51
(to be clear, BDCT doesn't provide the same confidence, and if people are looking for an easy way to avoid doing things properly, I'd avoid mentioning it at all)

tjones
2022-07-07 00:51
Teams who are doing provider-first development almost always have mocks. The question I would have is "how are you checking that your mocks work like the real thing?" - Pact makes that check very easy.

matt.fellows
2022-07-07 03:50
What a great thread - thanks all for your answers!

harris
2022-07-07 05:59
Hello , quick question for provider state set up, I have tried to send request to deployed test server(provider) for testing v3 beta but it throw an error(Response for preflight has invalid HTTP status code 405) https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request is the pact framework use a headless browser to send request? lol

tjones
2022-07-07 06:00
It should only generate preflight if the consumer told it to. Is cors set to true in your consumer test?

tjones
2022-07-07 06:01
Can you share the actual error you're getting? Is this from the state setup or the actual endpoint?

harris
2022-07-07 06:06
is the CORS set from consumer define in interaction header? ``` headers: { "Content-Type": "application/json; charset=utf-8" },``` if so, no we dont

harris
2022-07-07 06:07
it is from state setup, we had some ssl issue with local provider docker, so we just want to try out V3 beta to test env(staging) to point out it works as expected or not lol

tjones
2022-07-07 06:08
No. That looks like it's pact-js - if so, cors is set on the `Pact` object when you create it.

tjones
2022-07-07 06:09
I'm not sure how it is set in the beta. If you're not setting it at all, this is definitely a bug.

harris
2022-07-07 06:10
I am using `jest-pact` so it does magic for me? lol I did not set anything yet

harris
2022-07-07 06:10
maybe I will try to change `jest-pact` version to point out beta

tjones
2022-07-07 06:19
jest-pact doesn't set cors by default

tjones
2022-07-07 06:19
you won't be able to use it with the beta, though. There is a beta release of that, too

harris
2022-07-07 06:21
https://github.com/pact-foundation/jest-pact/blob/pact-js-v3/README.md yeap I found that, I will try and get back to you lol but if jest-pact doesnt set CORS, hum ?.. I can downgrade to V2 and try same step to confirm

tjones
2022-07-07 06:22
Can you share the actual error you're getting - It sounds like it might be a bug in the rust core.

tjones
2022-07-07 06:22
ideally the whole log, please

harris
2022-07-07 06:22
yeap I need to go out now, for pick up :slightly_smiling_face: I will get back to you later ! thanks

matt.fellows
2022-07-07 06:41
I?d be interested to understand _why_ you need CORS pre flights at all for your Pact test. This should be running in a Node process (V3 doesn?t support non-node environments to my knowledge) so there is no need for CORS

matt.fellows
2022-07-07 06:41
What HTTP client are you using?

tjones
2022-07-07 06:53
Also, you're not using jest-pact at the provider side, right? It is only for consumer tests.

dormeiri
2022-07-07 09:41
has joined #general

andreaschung1
2022-07-07 12:28
has joined #general

jwheatley
2022-07-07 18:00
You all are really helping me understand benefits. Another coworker has expressed concerns saying ```I believe my main concern with Pact was that you're not getting end-to-end tests, cause the frontend is still left out. In our solution, that's still a pretty big chunk that's not getting tested and while you can say that the interfaces between services work okay (and you can probably even contract test the interface the frontend uses), the code in the frontend itself doesn't get verified. In addition, I see an overlap between Pact tests and controller/requests specs/test. For a good amount of APIs, we're already verifying their behaviour based on the input -> output, so I'm wondering what Pact offers here in addition.```

jwheatley
2022-07-07 18:00
(we are using cypress to test the services separately)

jbecker
2022-07-07 18:30
contract tests are not meant to replace end to end tests, but end to end tests are slower and less reliable than lower level tests. This is why the classic image of the test pyramid is so important. If you're not familiar with it, it looks like this:

jbecker
2022-07-07 18:36
The metaphor is somewhat literal, in that you can't effectively perform e2e testing without a solid foundation of integration and unit tests. An e2e test is run late in the software development life cycle and touches everything, so if something fails, debugging can be difficult because there are many possible points of failure. The same is not true of Unit and Integration tests though, so if you have a very solid foundation of unit and integration tests before you run your e2e tests, you at least know that the logic itself is sound and the failure must have something to do with the much smaller untested code, like your service's configurations.

jwheatley
2022-07-07 19:08
Yea, I'm going to explain that this would not replace the cypress tests ive written. I thought they understood that but maybe i need to clarify. I totally agree and understand what you are saying @jbecker thanks for giving me better language to explain it!

jwheatley
2022-07-07 19:13
What would you say about the overlap between controller/requests specs tests and contract tests?

jwheatley
2022-07-07 19:14
has that been something you all have coordinated on your teams?

jbecker
2022-07-07 19:18
I'm not exactly sure what they mean by that, I suppose it depends on how they get the specs they're testing. That's what pact does, is it uses the pact broker to communicate a spec as defined in the consumer back to the provider for verification, so you can asynchronously verify that your specs are always accurate. If your team already has another system for doing the same thing, then maybe you don't need pact after all, but I don't really know enough to say

jwheatley
2022-07-07 19:59
i dont believe we do, but i need to get clarify on what our specs are currently doing

jwheatley
2022-07-07 21:33
It's looking like our specs are run against a mock. im thinking that there might be some misconceptions about how pact works...

parvatshiva
2022-07-07 22:05
has joined #general

harris
2022-07-07 22:18
```console.error Error: Error: Response for preflight has invalid HTTP status code 405 at Object.dispatchError (/app/app/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:63:19) at EventEmitter.<anonymous> (/app/app/node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18) at EventEmitter.emit (node:events:549:35) at Request.<anonymous> (/app/app/node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:370:16) at Request.emit (node:events:537:28) at Request._processResponse (/app/app/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:228:12) at ClientRequest.<anonymous> (/app/app/node_modules/jsdom/lib/jsdom/living/helpers/http-request.js:101:12) at Object.onceWrapper (node:events:652:26) at ClientRequest.emit (node:events:537:28) at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:642:27) undefined at VirtualConsole.<anonymous> (../node_modules/jsdom/lib/jsdom/virtual-console.js:29:45) at Object.dispatchError (../node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:66:53) at EventEmitter.<anonymous> (../node_modules/jsdom/lib/jsdom/living/xhr/XMLHttpRequest-impl.js:655:18) at Request.<anonymous> (../node_modules/jsdom/lib/jsdom/living/xhr/xhr-utils.js:370:16) [2022-07-07T06:47:35Z ERROR pact_verifier] Provider state change for 'A new object will be created' has failed - MismatchResult::Error("Invalid status code: 500", Some("217f8b60aad7530b2fd3dc48dd723abba5fe8674"))```

harris
2022-07-07 22:18
This is the error I got not sure it helps lol

harris
2022-07-07 22:19
```"interactions": [ { "description": "a deleteObject request", "providerStates": [ { "name": "A new object will be created" } ], "request": { "body": { "query": "\n mutation DeleteObjectMutation($id: Int!) {\n deleteObject(id: $id) {\n id\n }\n }\n", "variables": { "id": 1 } }, "generators": { "body": { "$.variables.id": { "expression": "${objectId}", "type": "ProviderState" } } }, "headers": { "Content-Type": "application/json" }, "matchingRules": { "body": { "$.variables.id": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "method": "POST", "path": "/api/v2/graphql" }, "response": { "body": { "data": { "deleteObject": { "id": 1 } } }, "headers": { "Content-Type": "application/json" }, "matchingRules": { "body": { "$.data.deleteObject.id": { "combine": "AND", "matchers": [ { "match": "type" } ] } }, "header": {} }, "status": 200 } } ]```

harris
2022-07-07 22:19
contract

harris
2022-07-07 22:20
```stateHandlers: { 'A new object will be created': { setup: async () => { const objectId = await createObject() return { objectId } } } } const createObject = async (): Promise<number> => { const body = { query: "use mutation to create an object", variables: {} } try { const res = await http://client.post("/api/v2/graphql", body) return res.data.id } catch (e) { console.log(e) throw e } }```

harris
2022-07-07 22:20
provide state

tjones
2022-07-07 22:20
That looks like it's not coming from Pact. How is your state change implemented? It looks like the state change is failing

tjones
2022-07-07 22:21
That call in the state change is what is failing


harris
2022-07-07 22:22
yeap we tried to use exist provider side call to create

harris
2022-07-07 22:22
send api request to create test data

tjones
2022-07-07 22:23
Well, that API request is sending a preflight that the server is rejecting

harris
2022-07-07 22:25
ok good to know thanks Timothy, let me try api request without any pact connection :slightly_smiling_face:

tjones
2022-07-07 23:24
> we're already verifying their behaviour based on the input -> output, so I'm wondering what Pact offers here in addition. Are you also verifying that the input you're testing the controller with is what your client actually sends?

tjones
2022-07-07 23:25
I think it was Matt's point originally - but if you're not verifying that the request that your client sends is the thing you're testing the controller with too, then you're just marking your own exam.

tjones
2022-07-08 01:34
To me, this is the real value of Pact. It is important to test: ? Your client sends what you think it does ? Your provider will send the responses that you think it will ? Your client can understand the responses you think it will get ? Your provider can understand the requests that you think it can This is what you're testing if you do controller/request spec tests . Pact makes it really easy to tie all those things together, so you get: ? Your client sends what you think it does ? Your provider will generate the responses that you think it does ? Your client can understand the responses that the provider actually sends ? Your provider can understand the requests that that the client actually sends This is an important difference - especially if multiple people are writing the tests. It's super important to tie the mocks together, otherwise you're just marking your own exam. Pact makes that super easy. In addition, Pact gives you knowledge of what is deployed where, so you can say: ? Is it safe to deploy this version of the consumer to prod? ^ That's the killer feature. Do you need Pact to achieve all this value? No. Is Pact the easiest way to achieve all of that value? In my view - absolutely. I don't think there's any other tool that gives you all of those features without you having to build extra infrastructure.

tjones
2022-07-08 01:36
> It's looking like our specs are run against a mock. This is very common. Pact is still a mock - but the difference is that that mock is sharable with the provider, so you check that your mocks are correct. Your team might find the diagrams on this page helpful: https://docs.pact.io/getting_started/how_pact_works

abubics
2022-07-08 02:15
Further to @jbecker?s pyramid point, and the Pact footprint confusion, here's a picture I prepared earlier :yay: sometimes the visual helps a bunch more than just trying to explain with words. Here, Pact is just the blue boxes. The purple would be Cypress in your case, and ideally not pushing past that network boundary, to keep them fast and less flaky. The better the low-level coverage is, the less exhaustive the end-to-end tests need to be.

harris
2022-07-08 03:33
Hello Timothy, I have tested without pact (direct request to test server) it works as expected lol this is provider side option ```export const createOptions = (providerName: string)=> { return { provider: providerName, providerBaseUrl: `${providerBaseUrl}`, pactBrokerUrl: `${pactBrokerUrl}`, pactBrokerToken: `${pactBrokerToken}`,, consumerVersionSelectors:[{tag:'provider-status', latest: true}], providerVersionTags: ['provider-status'], providerVersion: 'provider-status', enablePending: true, validateSSL: false, disableSslVerification: true, stateHandlers: { 'A new link will be created': { setup: async () => { const linkId = await createLinkInMonolith() return { linkId } }, teardown: async () => { } } } } }``` we did not set ```providerStatesSetupUrl:``` we got `stateHandlers` to send post request(axios) to server

harris
2022-07-08 03:33
just pure request using Axios without pact I can send request to server and resoponse as expected lol

jwheatley
2022-07-08 03:35
@tjones and @abubics you have really helped me feel more confident that I am on the right path towards doing what our team needs. I think the misconceptions about Pact have really held us back. I wish I had a bit more technical knowledge to actually implement it myself :stuck_out_tongue_winking_eye:. Have you all found it hard to coordinate cross team collaboration when certain teams own an endpoint?

abubics
2022-07-08 03:39
One of the important things to remember is Pact is just a tool. It can help prompt & drive conversations, because it highlights things that aren't working, and gaps that might've just been assumptions otherwise.

abubics
2022-07-08 03:39
Cross-team collaboration needs to start with buy-in on problems & solutions, so I think you're going in the right direction, trying to get people on the same page :ok_hand:

abubics
2022-07-08 03:41
In places I've used Pact, mostly the bounded contexts were narrow enough that there wasn't ownership contention within a single codebase/API/product. If you find that people don't want to own their code & quality & functionality, that's a bigger problem (which Pact or any other testing tools could highlight).

abubics
2022-07-08 03:42
Most of the push-back I've gotten has been before the buy-in happened.

jwheatley
2022-07-08 03:42
This is a good point. Yea, I think this phase of teaching people how it actually works is probably really critical. I'm not so technically savvy and pretty new to my company so I'm treading lightly!

abubics
2022-07-08 03:43
Pushing/forcing people to use a tool like this, begrudgingly, has always ended up in needing to promote the ownership and buy-in with now-annoyed people.

jwheatley
2022-07-08 03:43
Yea, this is really good to bring up. Even if a manager forces everyone to do it, people being disgruntled to do something they don't understand or believe in will not work out well in the long run.

abubics
2022-07-08 03:45
I find it's easiest to build in with empowered teams - when they already drive their own backlogs, support their own prod issues, etc. If the organisational culture is more siloed, or blamey, or has deferred responsibility (e.g. testing team, secops gatekeeping, etc), it's harder for people to want to own things.

jwheatley
2022-07-08 03:47
I'm getting the sense that our leadership is really open and supportive. I get good vibes all around from teams, so I'm hopeful :crossed_fingers:

abubics
2022-07-08 03:47
Amazing if you have top-down support :sparkling_heart:

abubics
2022-07-08 03:55
Also, if you can start small bottom-up (like if one team is keen to try it out), rather than trying to convince everyone together, that can help both shake out any teething issues small-scale, and then set a good example for others to follow :rocket:

jwheatley
2022-07-08 03:56
yes, my team is very open to trying it (minus one person..this is the person i want to convince :slightly_smiling_face: )

tjones
2022-07-08 04:03
> just pure request using Axios Yes, this is to be expected. The problem is in the `http://client.post()` call - so the question isn't "what happens if I don't use pact and implement a client myself?", the question is what happens when I do: ``` const body = { query: "use mutation to create an object", variables: {} } try { const res = await http://client.post("/api/v2/graphql", body) return res.data.id } catch (e) { console.log(e) throw e }``` without pact. (I can say confidently that it will fail - pact is not the problem here)

tjones
2022-07-08 04:04
Specifically, the errors you're getting are from an xhr library, which Pact doesn't use. So Pact is definitely not the source of the problem.

harris
2022-07-08 04:07
yeap without pact, it works lol ```const axios = require('axios').default const client = axios.create({ baseURL: "my url", timeout: 10000, headers: { "Authorization": `Bearer token`, "Content-Type": "application/json" } }) const body = { query: "mutation", variables: { accountId: 0000 } } async function main() { try { const res = await http://client.post("/api/v2/graphql", body) console.log(res.data.data.addLink.id) } catch (e) { console.log(e) throw e } } main()``` maybe I did not set `providerStatesSetupUrl:` is that the issue?

tjones
2022-07-08 04:10
I think the issue is that code will finish before the client call is made.

tjones
2022-07-08 04:10
also you're sending a different request

harris
2022-07-08 04:11
> different request sorry what do you mean?

tjones
2022-07-08 04:12
The body in your working example is different from the body in your failing example.

tjones
2022-07-08 04:13
I'm afraid I can't help you debug your code. But I can answer your pact question: > maybe I did not set providerStatesSetupUrl: is that the issue? No. You set either one of `stateHandlers` or `providerStateSetupUrl`, not both.

harris
2022-07-08 04:13
ahhh failing example(old shared one) was I modified it for sharing, the axios one (the latest shared one) and failed one are same :slightly_smiling_face:

harris
2022-07-08 04:13
I tested same request with pact, without pact!

harris
2022-07-08 04:14
> code will finish before the client call is made any tip to everything aligned?

tjones
2022-07-08 04:14
Well, the failure isn't coming from pact.

jonathan.dowling
2022-07-08 11:37
has joined #general

alex423
2022-07-08 13:59
has joined #general

jwheatley
2022-07-08 16:00
Just curious....do you also test against a live env in addition to using Pact? Currently, our Cypress tests are in the staging pipeline. A few devs want to also point these tests to a live env

jbecker
2022-07-08 16:07
In my company's case, we use Data Dog synthetic tests in prod environments, and we have simple e2e smoke suite and health suites which we run after each deploy to any environment to check the deploy was successful. The trick is keeping any sort of e2e testing or full-environment testing to a minimum though, because of how slow and expensive they are.

jbecker
2022-07-08 16:08
As a good rule of thumb, if an e2e test ever fails, you should ask yourself why you didn't catch it in a lower level test.

francis.williams
2022-07-08 19:52
has joined #general

dmitry.sarkisov
2022-07-08 20:07
has joined #general

neokree
2022-07-09 10:50
has joined #general

neokree
2022-07-09 10:58
Hello everyone! I asked about the development of a Flutter library on Twitter some days ago.. Matt can you please DM me so we can continue our conversation? Thanks

matt.fellows
2022-07-10 14:43
Check out #pact-dart

lynn.alhaimy
2022-07-10 18:20
has joined #general

matt.fellows
2022-07-10 21:23
I wouldn't point pact tests at a live server. You can do it, but managing provider states might be painful

jwheatley
2022-07-10 23:52
@matt.fellows ah yes, i wasn't thinking of pointing pact tests to a live env. I was asking whether people do pact AND also run e2e tests against a live env. A few devs on my team are pushing for running e2e against a live env and it was something I was told not really to do (or do VERY sparingly).

harris
2022-07-11 02:04
Hello Timothy, I got it :slightly_smiling_face: it was all becuz of jest config setup lol ```testEnvironment: "jest-environment-jsdom-sixteen",``` this one causes issue, now all fixed and working as expected :slightly_smiling_face:

harris
2022-07-11 02:04
thanks for your Advice ! cheers

abubics
2022-07-11 02:28
I tend to only run smoke-level tests in prod (ensuring connectivity), and have prod-shaped non-prod (e.g. staging).

abubics
2022-07-11 02:28
As an aside, if your Cypress tests don't cross the network boundary, you could run them anywhere safely ;D

jwheatley
2022-07-11 02:36
It?s more just that the live envs get so messy that the tests end up being flakey from changing data etc

abubics
2022-07-11 02:37
yeah, unless you have something like a test account in prod that is relatively isolated from real data, it's not really reasonable to expect that in prod

abubics
2022-07-11 02:38
and building something like that is significant dev & maintenance overhead

jwheatley
2022-07-11 02:38
Yeaaaa that?s what our infra dev was telling me!

guillermo.aguirre
2022-07-11 04:59
Hello everyone

guillermo.aguirre
2022-07-11 04:59
I'm having an issue running a producer test

guillermo.aguirre
2022-07-11 04:59
When I run it, I get dependency errors that I cannot mock

guillermo.aguirre
2022-07-11 04:59
Does the Producer test run the entire app?

rarora
2022-07-11 05:08
Hi team I am facing a basic issue: 1. There are two consumers say *pact-consumer* and *pact-consumer-b* for same provider 2. When *pact-consumer* publishes new contract with tag T1, webhook triggers build for provider 3. When provider build runs, it verifies successfully contract between *pact-consumer* and *provider* with tag T1 but fails for *pact-consumer-b* and provider with tag T1(as expected) Below screenshot shows provider annotation where pactConsumerTag value is T1 sent by webhook as explained in thread

rarora
2022-07-11 05:09
webhook configuration: ```{ "uuid": "uuid", "description": "POST http://gitlab.dev.tripadvisor.com", "consumer": { "name": "pact-consumer" }, "provider": { "name": "pact-provider" }, "enabled": true, "request": { "method": "POST", "url": "https://gitlab.dev.tripadvisor.com/api/v4/projects/<id>/trigger/pipeline", "headers": { "Accept": "multipart/form-data" }, "body": "token=<TOKEN>&ref=develop&variables[PACT_CONSUMER_TAG]=${pactbroker.consumerVersionTags}&variables[PIPELINE_LIBRARIES]=contract_verification,no_common" }, "events": [ { "name": "contract_content_changed" } ], "createdAt": "2022-06-07T01:32:01+00:00", ```

rarora
2022-07-11 05:10
please suggest how should i update config so that provider runs T1 tagged test for particular consumer and not for all consumers

rarora
2022-07-11 05:11
not for now

eirikval
2022-07-11 15:08
has joined #general

alex423
2022-07-11 15:27
Hello, Is there a way to test a consumer contract (as bi-directional contract) with a provider without publishing it to the broker ?

jbecker
2022-07-11 15:35
Yeah! The pact verifier cli has an option to pass it a contract file to verify

jbecker
2022-07-11 15:36
Which pact verifier cli are you using? (I am pretty sure they both have this option, the ruby one and the rust one)

alex423
2022-07-11 15:36
nodejs

alex423
2022-07-11 15:37
but it seems the pact verifier cli is written with ruby

jbecker
2022-07-11 15:37
This is the one I'm using and it has a `-f` option for passing a pact file:


alex423
2022-07-11 15:38
thanks :slightly_smiling_face:

jbecker
2022-07-11 15:40
Hmm, actually, I'm not sure if the ruby implementation of the pact verifier cli has this option. I'm not seeing it here: https://github.com/pact-foundation/pact-provider-verifier#usage So looks like you'll want to try out the rust implementation (the first one I linked)

alex423
2022-07-11 19:07
`--file` and `--dir` options are ignored when the env variable `PACT_BROKER_BASE_URL` is defined :confused:

alex423
2022-07-11 19:09
also this tool verify pact files against a running provider. is it possible to verify it with the provider pact submitted on the pact broker instead ?

jbecker
2022-07-11 19:51
yes, you don't need the pact broker if you're passing the contract file

alex423
2022-07-11 19:52
yes, but it requires a running provider, is there a way to verify a consumer contract using the provider contract instead of a running provider ?

jbecker
2022-07-11 19:54
I think you're a little confused, the contract is written by the *consumer* and verified against a running instance of the *provider*. I'm not sure exactly what you mean by "provider contract" but the provider doesn't produce a contract

alex423
2022-07-11 19:56
on my ci flow the provider publish an OAS on the pact broker. I wanna know this is possible to verify if a consumer contract is compatible with my provider oas

alex423
2022-07-11 19:57
(i'm trying to use bi-directional contracts)

jbecker
2022-07-11 19:58
I've never heard of bi-directional contracts in pact. I thought it only supported consumer-driven contracts


matt.fellows
2022-07-12 03:32
> Is there a way to test a consumer contract (as bi-directional contract) with a provider without publishing it to the broker ? Are you asking if there is a way to confirm locally if a change on the provider/consumer will break things, rather than finding out using `can-i-deploy` later in the pipeline? If so, not yet, but it?s on the https://github.com/pactflow/roadmap/projects/1 (see can-i-deploy local)

matt.fellows
2022-07-12 03:32
@jbecker this is a Pactflow specific feature, and not something part of Pact OSS

matt.fellows
2022-07-12 03:36
It?s entirely up to how you run your provider to verify it

matt.fellows
2022-07-12 03:36
But usually yes, with stubbed out external dependencies

matt.fellows
2022-07-12 03:37
Pact can?t fix your dependency errors.

matt.fellows
2022-07-12 03:37
> When I run it, I get dependency errors that I cannot mock Pact is designed for situations where you have granular control over your code. Can you elaborate on this problem a touch?

rarora
2022-07-12 04:41
@matt.fellows can you please suggest

alex423
2022-07-12 04:49
I'm asking if I could run `can-i-deploy` command with a local contract instead of publishing it to the pact broker. My ci/cd workflow is basically `pact-broker publish` `pact-broker can-i-deploy` `pact-broker record-deployment` and I would want to just run `can-i-deploy` locally (with uncommited local changes for example) to make sure my code is fine and only publish validated contracts

sahil.jain
2022-07-12 10:21
has joined #general

jonathan.dowling
2022-07-12 11:29
I have an issue running the pact-protobuf-plugin binary inside a Docker container. I'm using pactflow/pact-protobuf-plugin v0.1.7. When running Pact tests, the tests fail. I tracked this to the plug-in binary failing to start due to *"Cannot assign requested address"*. ```# /root/.pact/plugins/protobuf-0.1.7/pact-protobuf-plugin Error: Os { code: 99, kind: AddrNotAvailable, message: "Cannot assign requested address" }``` This happens on the maven:3-openjdk-17-slim (and other maven images) and also on ubuntu:latest. I think there is an issue with the plug-in attempting to bind `::1`, an IPv6 address, which is not supported in containers by default. Is there a workaround for getting the pact-protobuf-plugin binary to listen on a different localhost address? I need to be able to run Pact tests inside a container as part of a build pipeline.

rholshausen
2022-07-12 13:08
I'll have a look at what is happening. It should try an IP4 address if the IP6 one failes.

sahil.jain
2022-07-12 13:10
Hello Everyone. I am bit new to Contract testing and recently started exploring it for consumer driven contract testing in Android App. The use case I am trying to solve is to generate pact file while i am running my UI Tests in Android app. My Android app makes multiple API requests to our backend server which i have currently mocked the responses through "Wiremock" framework. The next step i want to do is to record all the interactions made by the app and create a pact file so as i can validate it against my reack backend server. In order to do so i have integrated "Wiremock Pact Generator" developed by Atlassian team : https://bitbucket.org/atlassian/wiremock-pact-generator/src/master/ but i am facing crash while running my UI tests. ```com.github.tomakehurst.wiremock.servlet.WireMockHandlerDispatchingServlet.service(WireMockHandlerDispatchingServlet.java:108) at javax.servlet.http.HttpServlet.service(HttpServlet.java:790) at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:812) at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:587) at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1127) at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515) at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1061) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.servlets.gzip.GzipHandler.handle(GzipHandler.java:479) at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:110) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97) at org.eclipse.jetty.server.Server.handle(Server.java:499) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:311) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:258) at org.eclipse.jetty.io.AbstractConnection$2.run(AbstractConnection.java:544) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:635) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:555) at java.lang.Thread.run(Thread.java:784) Caused by: java.nio.file.NoSuchFileException: target/pacts/the-consumer-the-provider-febea806-232d-4527-bacb-d501e5048f78-pact.json at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214) at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434) at java.nio.file.Files.newOutputStream(Files.java:216) at java.nio.file.Files.write(Files.java:3292) at com.atlassian.ta.wiremockpactgenerator.pactgenerator.LocalFileSystem.saveFile(LocalFileSystem.java:14) at com.atlassian.ta.wiremockpactgenerator.pactgenerator.PactSaver.saveFile(PactSaver.java:39) ... 24 more``` Can someone please help why its not able to save pact file? or i am doing something wrong here. Thanks in Advance.


kyriacos.elia
2022-07-12 15:43
has joined #general

fabricio.mendes.ti
2022-07-12 16:33
has joined #general

cameron.allan853
2022-07-12 23:18
has joined #general

matt.fellows
2022-07-13 02:57
Also Check your host entries. If localhost is defined for both ipvr and 6 but your network stack doesn't support it that may also be a problem. Or you could always use 127.0.0.1 instead of localhost

matt.fellows
2022-07-13 02:57
I don't know android, but if you're running a UI test do you have access to the filesystem?

matt.fellows
2022-07-13 02:58
If not, that could explain it

matt.fellows
2022-07-13 03:05
Yep that's exactly the feature we're building. Not ready yet but on the near term horizon as per that roadmap

jeroen.lamain
2022-07-13 08:49
has joined #general

jonathan.dowling
2022-07-13 08:52
@matt.fellows This happens in standard Docker containers. You can reproduce it quickly with this: ```docker run --rm -it ubuntu:latest bash apt-get update && apt-get install -y wget wget --quiet https://github.com/pactflow/pact-protobuf-plugin/releases/download/v-0.1.7/install-plugin.sh bash install-plugin.sh ~/.pact/plugins/protobuf-0.1.7/pact-protobuf-plugin```

programmingwithbangal
2022-07-13 12:48
has joined #general

rohitkeshwani07
2022-07-13 13:28
has joined #general

alex423
2022-07-13 13:45
ok thanks :slightly_smiling_face:

rholshausen
2022-07-13 15:22
I think I added a command line parameter to force IP4 addresses just for docker images.

rholshausen
2022-07-13 15:43
Ah, no, I thought about adding that parameter. I'll raise a ticket for this on our backlog.

gjvengelen
2022-07-13 18:18
has joined #general

jbecker
2022-07-13 19:40
What's the best way to roll out a new pacticipant? I've started building our automation around our pact broker, and I've reached the point where our pipeline will fail pull-request builds if `can-i-deploy` for the given service to deploy to `master` fails... But now I've discovered that when build a new pact provider, it fails `can-i-deploy` because it doesn't exist yet as a pacticipant, and when I add new contract tests to a service, it fails because the contract can't yet be verified, so I'm in a bit of a dependency loop. *Is the only way out of this dependency loop to do a one-time suspension of my checks to get my provider merged?* Am I maybe doing something wrong? (To be clear, currently my script currently checks to see if the pact provider logic has been implemented in the service and if it has, it runs verifications and then the `can-i-deplay`. It doesn't run any pact stuff if it doesn't see the pact provider logic or a pact file in the service)

jbecker
2022-07-13 19:55
Actually, as I write this, it occurs to me that maybe the solution lies in just checking if a given service is a pacticipant in the pact broker. Is there an easy way to check that for a given service name?

tjones
2022-07-14 01:38
You should always be able to deploy a provider that has no consumers

matt.fellows
2022-07-14 03:13
You can definitely check if your provider exists - `:host/pacticipants/:name/` will give you the resource of the application if it exists

matt.fellows
2022-07-14 03:15
Tim is right, however with the caveat that can-i-deploy will fail if the application you?re querying doesn?t exist. To create the application, you don?t need a contract - the simplest option is to simply create the application in advance: `curl -X POST <host>/pacticipants -d {"name": "some provider"}`

lorenz.ammon
2022-07-14 08:52
has joined #general

remigijus.mazulis
2022-07-14 08:53
has joined #general

marcello.rigan335
2022-07-14 11:28
Hey there, im trying to test Kafka messages with Pact. We are using Avro to send the messages, but i can't find any documentation for that. Help would be appreciated. Thank you.

matt.fellows
2022-07-14 11:41
We don't currently support Avro

matt.fellows
2022-07-14 11:42
You could try an approach like this where you serialise to/from json https://medium.com/@ivangsa/consumer-driven-contract-testing-for-grpc-pact-io-d60155d21c4c

marcello.rigan335
2022-07-14 11:43
ok thanks. i'll take a look.

matt.fellows
2022-07-14 11:56
Or if you really were up for it, you could build a plugin. What language do you use?

marcello.rigan335
2022-07-14 11:56
The project where im trying to implement the tests is using kotlin

matt.fellows
2022-07-14 12:03
@uglyog is the content type plugin something Marcello could look to copy from Protobufs or CSV?

marcello.rigan335
2022-07-14 12:24
Is avro support something which is planned? And if yes, do you have a rough time estimation when we can expect it?

matt.fellows
2022-07-14 12:49
It's on our backlog but not yet prioritised or sized

matt.fellows
2022-07-14 12:50
See http://pact.canny.io it should be there if you'd like to vote on it

seanruffatti
2022-07-14 14:40
has joined #general

hazem
2022-07-14 17:47
:wave: , i tried to search the documentation for more info about environments, but i couldnt find anything to help describe the option `--no-production` for the cli `pact-broker create-environment` , documented https://docs.pact.io/pact_broker/client_cli/readme#environments. is this option purely informational when creating an environment, or is it used somewhere like provider verification?

jbecker
2022-07-14 20:15
Perfect, thank you

jbecker
2022-07-14 20:18
I'm just changing my verifier job so if you pass it a provider name, the first thing it does is check if that provider already exists, and if it doesn't, it creates it (unless you also passed it a pactfile url, which it interprets as an error, because, honestly I'm not even sure how that would happen, but it was probably a mistake)

tjones
2022-07-15 05:14
This is a great question! I don't know the answer, but I did notice that that document links to itself for more information: > The "test" and "production" environments will have been seeded for you. You can check the existing environments by running pact-broker list-environments. See https://docs.pact.io/pact_broker/client_cli/readme#environments for more information.

tjones
2022-07-15 05:14
(which leads back to the same doc)

nico.neirinck
2022-07-15 06:10
has joined #general

marcello.rigan335
2022-07-15 10:16
Anyone familiar with that error "ERROR pact@9.18.1: error making http request: axios_1.default is not a function"

dormeiri
2022-07-15 12:59
Hi :wave: , we are thinking of adding Pact to our tests. We have one concern about running the provider's verification. Currently, we are running our services locally in isolation by binding the application interfaces to mocks using IoC. Now, if we want to start using Pact we will have two mock systems, one for tests, and one for an isolated local run. I want to be able to configure and run the Pact mock server locally when running the application. --or-- Use the existing mocked implementations to configure the expected interactions in the tests. Is that possible? Do you have any idea on how to do that correctly? I opened a discussion in GitHub with more details: https://github.com/pact-foundation/pact-js/discussions/887 What do you think about this concern? How do you run your app locally in isolation?

bethskurrie
2022-07-15 14:18
Best to ask in the channel that?s relevant for your language.

bethskurrie
2022-07-15 14:18
We have 10+ pact languages here to support.

bethskurrie
2022-07-15 14:18
It?s just whether or not the environment is a production environment.

bethskurrie
2022-07-15 14:19
At the moment, it?s not used anywhere, but I could see that it might be useful information at some stage, so I included it from the start.

bethskurrie
2022-07-15 14:22
Does this help? `Whether or not this environment is a production environment. This is currently informational only.`

bethskurrie
2022-07-15 14:32
it should just work? so it sounds like something got messed up

bethskurrie
2022-07-15 14:33

jbecker
2022-07-15 14:33
I think it's just as Matt says: I think it's just can-i-deploy pointing out that my pacticipant doesn't exist in the pact broker yet

jbecker
2022-07-15 14:34
I just need to improve my pipeline a bit to add the provider as a pacticipant when it's new

bethskurrie
2022-07-15 14:34
Please do not tag the maintainers.


jbecker
2022-07-15 14:35
I reference that pact_nirvana page often, it's very helpful, haha :thumbsup:

bethskurrie
2022-07-15 14:35
The triggered provider build should only verify the changed pact at the URL that is passed through via the webhook.

bethskurrie
2022-07-15 14:35
If you do this workshop, it will explain that all https://docs.pactflow.io/docs/workshops/ci-cd

k.bangarusamy
2022-07-15 14:36
has joined #general

bethskurrie
2022-07-15 14:36
There is a way to pass in the specific URL of the pact, not the consumer name/tags.

bethskurrie
2022-07-15 14:37
Please look at the docs for your pact testing framework.

bethskurrie
2022-07-15 14:37
Also, it?s best to ask questions in the channel for your specific language (eg #pact-jvm)

bethskurrie
2022-07-15 14:38
Great to hear.

bethskurrie
2022-07-15 14:39
Usually, the consumer adds the pacts for the provider first, and that creates the provider.

jbecker
2022-07-15 14:40
That makes sense, but since the provider should be able to be developed independently if no consumer depends on it, I wanted to create a path in our pipeline for that as well

bethskurrie
2022-07-15 14:40
Cool. Yeah, that page I sent will cover your scenario.

k.bangarusamy
2022-07-15 14:41
Hi Folks, I joint pack to understand for implementing project just share me any guidance which is useful thanks on advance.

jbecker
2022-07-15 14:43
Oh I hadn't thought of just adding _every_ service-version to the pact broker even without contracts, but that's real smart. Thanks for the tip!


k.bangarusamy
2022-07-15 14:52
Thanks

jbecker
2022-07-15 14:53
No problem! There is a lot of really good advice on this page, it's a really good read

k.bangarusamy
2022-07-15 14:53
Is this opensource, just planning to get estimate for this tools

jbecker
2022-07-15 14:55
The pact libraries and cli tools are free open-source, but pactflow is a paid-for service. You can build everything yourself with the pact tools (which is the direction me and my team are going) or you can pay for pactflow and get a lot of that infrastructure pre-built for you

matt.fellows
2022-07-15 15:40
I?d also recommend the following resources (howtolearn)

2022-07-15 15:40
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-07-15 15:41
Looks like a Pact JS issue. That?s worrying though, axios was a recent addition to the stack replacing another lib

matt.fellows
2022-07-15 15:41
if you could please share a repro issue in the #pact-js channel that would help

harinder.kaur
2022-07-15 17:19
has joined #general

jbecker
2022-07-15 19:18
```docker run --network host pactfoundation/pact-cli broker can-i-deploy --retry-while-unknown=60 --retry-interval=10 --pacticipant=test-service --version=430ff0f --to-environment=master Computer says no ¯_(?)_/¯ No pacts or verifications have been published for version 430ff0f of test-service``` Bummer... I thought if a provider had no pacts, it should be safe to deploy? Do I need to specify some other option?

hazem
2022-07-16 00:15
yep, definitely more clear there. i looked in the cli doc first, so :thumbsup: from me. fwiw, i was partly wondering if i could use it with `can-i-deploy` as a way to check many environments containing `production = true`

mahidasp
2022-07-16 17:30
has joined #general

juan.aa.espiritu
2022-07-17 08:39
has joined #general

dormeiri
2022-07-17 16:24
Any thoughts?

rarora
2022-07-17 23:57
sure thanks, let me have a look

abubics
2022-07-18 00:28
There's a lot to unpack here. The example looks like a consumer-side scenario, but your explanation talks about provider verification :thinking_face:

abubics
2022-07-18 00:29
Since V3 or V4, you can include state with parameters in the consumer side of the tests, so if you want to use those to set up your provider state (values for test doubles), you can :slightly_smiling_face:

tjones
2022-07-18 00:49
I don't think I understand your question, sorry.

tjones
2022-07-18 00:50
What is an isolated local run if not for tests?

tjones
2022-07-18 00:50
What is IoC?

tjones
2022-07-18 00:50
What do you mean by configuring the expectations with mocks? That definitely doesn't sound right

tjones
2022-07-18 00:51
The diagrams here might help understand how pact works: https://docs.pact.io/getting_started/how_pact_works

tjones
2022-07-18 00:52
you set up the interactions manually, as expectations.

tjones
2022-07-18 00:52
The answer to your question - whether it is possible to run a pact mock server without a test - is yes. But, I think there's a misunderstanding here about what pact is for

abubics
2022-07-18 00:54
I had to look at the sample code to work out the inversion of control specifics, it's just a DI framework binding.

tjones
2022-07-18 00:58
Oh right. I think I understand the question - you're saying that you have a pact verification for your service's endpoints, and your service makes some downstream service calls, which you would usually mock during testing. But, if you *also* test those downstream service calls with pact, then you're thinking "maybe we can just reuse what we set up for pact instead of manually maintaining mocks"?

tjones
2022-07-18 00:59
You could do this I suppose. I agree with you that it's a lot of mucking around. I don't really think of pact as a mock service (it happens to be backed by one, but the real killer feature is the ability to record and share the contract)

tjones
2022-07-18 01:00
An advantage of using mocks like your example (which is what I would do) is that they are very fast - all your unit tests don't hit the network boundary

tjones
2022-07-18 01:01
You still want to tie your mock together with your pact expectation, of course

tjones
2022-07-18 01:02
I spoke about this a bit last year, let me get you a link


tjones
2022-07-18 01:04
This is the slide - although that section of the talk starts earlier.

tjones
2022-07-18 01:04
I configure the mocks with the pact expectations, not the other way around

tjones
2022-07-18 01:06
I don't think of this as double-mocking - the pact test is around the client in your code - asserting that the innards of `getOrder(id: string): Promise<Order>;` work correctly and return what you expect.

tjones
2022-07-18 01:07
Pact mocks the network part, and what is under test is everything inside `getOrder`

tjones
2022-07-18 01:07
Now, for your unit tests, you know you can safely mock everything inside `getOrder`

tjones
2022-07-18 01:09
For maximum safety, you can use the pact expected return as the mock data that is returned by mock `getOrder`

dormeiri
2022-07-18 06:55
Thanks @tjones! That was really insightful, few thoughts... Seems like I better understand now the benefits of adding Pact, it can validate that my mock classes mimics the provider correctly. Which improves the confidence on my unit tests, it also gives us coverage on the live concrete implementation. As you said in the slide, there is some overlap between functional tests and contract tests, which is good because it validates that isolated run and production run works the same. Just need to find the balance. This is stronger than traditional integration tests where your mocks and live implementations are separated. To maintain this overlap correctly, I need that one of these will happen: 1) Mocks will use Pact 2) Pact will use mocks 3) Pact and mocks will use another component that maintains mocked data. I feel like option 2 suites us best. If we will also implement a state handler, we need it to dynamically mutate our mocks from outside. Our mocked classes already has this possibility and it really fits our needs.

tjones
2022-07-18 06:56
Option 2 might be easiest at first, but you may have a bad time long term. The reason for this is that to get the best use from pact, you'll want to use matchers

tjones
2022-07-18 06:56
For example, your contract for a user might look like: ```{ "firstName": "Dor" }```

tjones
2022-07-18 06:57
But maybe that's not the exact mock data that is on the provider. And, in the contract test, you don't really care exactly what the string returned from the provider is, just that it really was a string

tjones
2022-07-18 06:57
so, you then use matchers: ```{ "firstName": like("Dor") }```

tjones
2022-07-18 06:58
This means your consumer contract test can expect an explicit string, and your provider verification will pass as long as the provider returns any string (eg `{"firstName": "Tim"}`)

dormeiri
2022-07-18 06:59
Hmmm interesting, haven't thought about the matchers, but if I pass `like(mock.getOrder)` it will have similar result? It doesnt give us flexibility of using the matcher

dormeiri
2022-07-18 07:00
So it seems like option 3 is the best, but it requires more to maintain

thomas.loudon
2022-07-18 11:05
has joined #general

david.hayden
2022-07-18 11:12
has joined #general

gibraltor999
2022-07-18 13:01
A quick question for the experts 1. If we already have schema and integration tests in our CI pipelines and are tested as a part of each PR to master, do I still benefit from using Pact? 2. We are following the following approach: Acceptance Criterias created by BA-> Team refines the story -> Squad teams pick up the story fort implementation(please bear that the contracts are not ready here, before our domian services needs to call the third psrty vendor?s APIs) -> Implementation completed (domain services end points created after understanding how the third party vendors apis behave)-> Swagger docs are created-> QEs create their integrations tests and schema tests and are ready to merged into the main PR-> PR is now raised against master -> all checks are made before it gets deployed to master.. Same happens at the consumer side as well.. Can somebody let me know if we would still benefit out of Pact and if yes how? Highly appreciate your thoughts on it. Thanks

mike.geeves064
2022-07-18 13:07
1. You can benefit when making changes to the "interface", i.e. when you are wanting to add or change the producer/consumer. I'm currently adding into some existing services to capture how they currently worked, before then going onto make a few hefty structure changes and it's been helpful so far picking out when my integration tests were all fine but e.g. one end had a timestamp with a T while the other had a space. By themselves they worked fine, together they did not

hakan.b.jansson
2022-07-18 14:04
has joined #general

matt.fellows
2022-07-18 14:10
> integration tests can you please elaborate what you mean by this? The definition has widely ranging meanings, so it?s important to make this clear

gibraltor999
2022-07-18 14:13
integration tests - testing the integration between my domain services & third party vendors and when I hit my application endpoint it actually hits the third party api endpoint and gets the real time response and not mock data.

matt.fellows
2022-07-18 15:04
Well, only the usual benefits of speed, reliability, visibility, precision etc.. If you test all of the scenarios you need against the real thing, then Pact tests are just going give you faster feedback loops, but no more guarantees than testing against the real thing.

matt.fellows
2022-07-18 15:09
If those tests aren?t causing you pain, then you might find it harder to make the case to your team. They are usually harder to coordinate, take longer to run and get harder to manage as they grow. If this works for your team though then it?s up to you if you want the extra visibility and earlier feedback on problems

jakehowden
2022-07-18 15:54
has joined #general

noor.hashem
2022-07-18 19:59
Hi all, quick question, I am trying to use the can-I-deploy command, and I am getting authentication failed. Is there anything I have only installed pact-foundation/pact, is there something else I need to install to get it to work?

noor.hashem
2022-07-18 20:09
Got it!

abubics
2022-07-19 00:31
You should definitely think about flexible matchers :slightly_smiling_face: they're what gets Pact to the sweet spot of "flexible like schemas" but with "the reasoning power of unit tests".

abubics
2022-07-19 00:33
`like(mock.getOrder)` will probably get you close to schema-level flexibility & reasoning. It doesn't let you specify which parts of the payload are important in value vs shape/type.

tjones
2022-07-19 02:17
The primary downside of `like(wholePayload)` is that you will only match on the json types of everything. If your payloads are simple then you can totally get away with it. However, it won't work for all payloads, so you might miss things: Cases where this won't work include: ? where the client only understands specific values where you need an enum (say `userType` which could be `"admin"` or `"member"` - this is an important part of the contract, because you want to be sure that the backend doesn't return `"someOtherType"` or maybe "ADMIN" if your client is case sensitive) . ? If you have any arrays, it will tie the backend to providing exactly that structure ? Same thing you have any objects used as maps

tjones
2022-07-19 02:26
Vs integration tests: Pact gives you deployment safety that most people aren't getting with integration tests. With integration tests, when you're about to deploy something, you need to run an integration test against exactly the versions it's about to deploy against. This is expensive in time and resources (and very hard to do without a test environment that needs booking exclusively for you). It's .... possible, but most of the time it's so much work that people aren't doing it, or aren't doing it strictly. Even if you are, the test setup time is so long that it substantially increases the friction for small fixes Vs Schema tests: Schema tests tell you whether something matches the grammar of the request/response contract. A best-practice Pact test will tell you whether something matches the semantics of the contract. This is substantially more valuable. Pact is by-example, so you're actually testing whether your provider can really understand the requests that your consumer is really sending. Also, depending on your contract design some things can't be expressed (or are difficult to express so people take shortcuts) in schema tests. For example, when you have dependent properties: ```{ "type": "foo" "fooField": {....} } and { "type": "bar" "barField": {....} }``` typically this is expressed in schema as: ```{ type: "bar" | "foo" barField: Optional<BarField> fooField: Optional<FooField> }``` which means the following two examples are schema-compliant, but probably wrong: ```{ type: "bar" } and { type: "bar" fooField: { ... } }```

hakan.b.jansson
2022-07-19 05:20
Hi, I just wanted to flag for a potential problem in the workshop, unless I did something wrong.I ran through the workshop https://github.com/pact-foundation/pact-workshop-jvm-spring yesterday, and I experienced errors about authentication already in ~step 5. So, "Yay - green" was not the case. But after step 10, all was ok again.

alanbos
2022-07-19 07:57
I've been using Pact (pact-js) for GraphQL contracts between client apps and Apollo GraphQL servers, by using pact-js on the client side and server verification tests that allow pact to check the GraphQL response meets contract expectations. Now I'm looking at moving to Apollo Federation, and trying to figure out whether pact could still be used in this context. In a federated architecture there is an single API Gateway sitting in front of multiple subgraphs, responsible for composing the schemas from those subgraphs into one unified supergraph that is consumed by client applications. Each subgraph is a separately versioned deployable component (as is the gateway itself), but from the client perspective the behaviour of the GraphQL server is the _same_ as in the non-federated case. In the non-federated case, the GraphQL server is a single versioned (consumer) pacticipant in this case. In the federated case however, the gateway itself is a relatively thin component whose source version rarely changes, and each subgraph is more like a non-federated server with its own version history. When a contract between a client and the gateway is verified, this is in effect saying that _N_ (where _N_ is the number of subgraphs) "sub-contracts" between the client and each subgraph are verified i.e. can-i-deploy for the client depends on the versions of all the subgraphs used to service the query. As client requests will typically span multiple subgraphs, defining contracts between clients and subgraphs isn't the right approach; the contract should be between the client and the supergraph. It feels like this would be quite a technical challenge - from the client perspective there is one contract, but from the provider perspective there are multiple contracts because each provider (subgraph) has a role to play in servicing the query. There isn't a single deployable versioned component that can take the role of the provider here because the gateway itself isn't changing when the subgraphs change, unless one invents some pseudo-deployable supergraph pacticipant whose version depends in some way on the versions of all contributing subgraphs but is never really deployed, just recorded in the pact broker as such. I'd be interested in any thoughts on this; it feels quite complex to manage and use, but maybe I have missed something.

tjones
2022-07-19 09:00
I feel like this design is going to cause complexity whether or not you use pact... but

tjones
2022-07-19 09:01
Pact versions assume a single "deployable". What you could do is front multiple versions as one deployable

tjones
2022-07-19 09:01
do verification of the gateway at version X, with A, B, C beyond it, and treat that all as one provider "version"

tjones
2022-07-19 09:02
it'll work, and you'll get the contract safety, but now you will have some of the disadvantages of integration tests

alanbos
2022-07-19 09:05
Thanks @tjones - yes it feels like having a pseudo-provider that is versioned as a logical aggregation of gateway + subgraphs is the inevitable conclusion; I'm just not sure the effort and cognitive complexity for developers is repaid by the benefit, which is a shame as GraphQL pacts against a single monolithic server are super-easy to do.

tjones
2022-07-19 09:14
A good thought experiment you can try to help unpack this is - how would I be sure it's safe to deploy without pact?

tjones
2022-07-19 09:15
if you find that it's hard to reason about what is deployed where, and what you should test against, then you'll find a challenge with or without pact - and the design might need some re-thinking

alanbos
2022-07-19 09:18
I think in this case there is some overlap between the checks and balances around deployment provided by Apollo Managed Federation and that provided by a CDC solution; its a matter of trying to figure out what each solution brings that the other doesn't.

tjones
2022-07-19 09:20
I don't know if it would help, but you could also trivially publish the contract repeatedly - so each backend service would see the same contract

alanbos
2022-07-19 09:21
I don't think it would in this case alas; each backend subgraph would in general not be able to handle the contract, because the GraphQL request would contain elements that the subgraph knew nothing about.

alanbos
2022-07-19 09:23
.. but thanks for your advice; I think its confirmed for me what would _need_ to be done. The only question now is the cost/benefit analysis, so I'll plug away at that for a while.

tjones
2022-07-19 09:23
You can also consider a contract between the client and the gateway, and then between the gateway and each provider. But I think that will make you do work that GraphQL Federation is supposed to do

tjones
2022-07-19 09:24
Let us know if you come up with a good solution!

alanbos
2022-07-19 09:25
Yes exactly - I'd have to figure out the federated server query plan and use that to drive gateway-subgraph contracts, but it feels like the wrong bit of the flow for me to be testing to be honest. Will do!

dormeiri
2022-07-19 09:42
Thanks! So I can take the mock result `mock.getOrder(id)` and translate it to a Pact response body more precisely according to the test, something like this: ```const order = mock.getOrder(id); const expectedResponseBody: Order = { id, name: like(order.name), // ... } ``` So my pact tests can use my mocks, with the flexibility of using matchers. Right now, this seems the easiest way to manage the mocks in our services. WDYT?

chrstnklb
2022-07-19 10:58
has joined #general

tjones
2022-07-19 11:24
Yes, exactly.

tjones
2022-07-19 11:25
Once you have that object with matchers, you can use the stripMatchers function to get back the raw object if you need- then you can import it in your other mocks

tjones
2022-07-19 11:25
(It may not be called stripMatchers, I'm not at my computer)

dormeiri
2022-07-19 11:26
Thank you! @tjones

bethskurrie
2022-07-19 14:42
tell me more about that usecase @hazem

bethskurrie
2022-07-19 14:42
Would it just be something you?d do once off to check the status of something, or in a CI/CD pipeline?

bethskurrie
2022-07-19 14:43
If you?re not publishing any pacts or verifications, you need to make the pacticipant version explicitly using ```pact-broker create-or-update-version --pacticipant ${APPLICATION_NAME} --version ${GIT_SHA} --branch ${GIT_BRANCH}```

bethskurrie
2022-07-19 14:43
It knows about the pacticipant, but not the version.

jbecker
2022-07-19 14:46
Oh, I have to publish the version for the provider too, so it can see that it exists and knows that there is no consumer to connect it to?

jbecker
2022-07-19 14:47
Sorry if you said this already, but do I have to do it as two separate commands, or will `create-or-update-version` also create the pacticipant if it doesn't exist?

jbecker
2022-07-19 14:52
From that pact_nirvana page you linked above, it looks like the one command may be enough, but I may be mis-reading it

matt.fellows
2022-07-19 14:53
yep, it should do both

yousafn
2022-07-19 15:21
Spot on @tjones - will get that on the site either in the FAQ https://docs.pact.io/faq or under Pact concepts https://docs.pact.io/getting_started/conceptual_overview will check messaging on here too https://docs.pact.io/faq/convinceme

noor.hashem
2022-07-19 18:02
Hi all, my team and I are looking into what is the best way to split the creation of contracts between consumers and providers, let me elaborate. We have a monorepo for the consumer (front-end) and several different provider services, do we create one pact file for each controller or for each endpoint? There are countless ways to go about creating contracts between the providers and the consumer but I'd like to hear what everyone else thinks about this?

jbecker
2022-07-19 18:07
I think the way Pact works is to create a contract file for each version of each consumer -> provider pair (versioned based on the consumer's version number so that it can verify it against an arbitrary version of the provider to check if those two versions of those services work together)

matt.fellows
2022-07-19 18:23
The simplest pathway is to create contracts between independently deployable units

matt.fellows
2022-07-19 18:24
Controllers is probably not the right abstraction

matt.fellows
2022-07-19 18:24
(just about to hop on a plane, sorry for quick response)

andrew.favaloro
2022-07-19 19:36
has joined #general

tarun.gulati1988
2022-07-19 19:41
has joined #general

boweixu
2022-07-19 20:39
has joined #general

hazem
2022-07-19 23:56
so we have a canonical environment pipeline for our micro service deployment: `dev-> stg -> prd` using the pact broker, i created the three envs. two with the field `production=true` , eg stg and prd. dev has the field `production=false` . this was due to me not knowing this flag was purely informational. after merge to main, we were thinking our AWS codepipeline as such: ```#dev can-i-deploy --environment=dev --dry-run deploy record-deployment --environment=dev #stg can-i-deploy --environment=stg deploy record-deployment --environment=stg #prod can-i-deploy --environment=stg deploy record-deployment --environment=stg``` in our pr pipeline, we wanted to verify can-i-deploy would work for all of our production env: ```test can-i-deploy --environment=stg can-i-deploy --environment=prd``` then it crossed my mind that the `--production --no-production` flags i came across during the create-environment might have special meaning. so i asked in this thread. :) basically i was curious if i could do this instead: ```test can-i-deploy --to-production-environments```

juanalvarezarquillos
2022-07-20 05:46
has joined #general

jkaur
2022-07-20 06:32
has joined #general

jkaur
2022-07-20 06:48
Hi everyone , My use case is that my consumer is an API service i.e. it exposes Rest API Endpoints , however the provider internally it calls is a gRPC service. Moreover its more like a passthrough service for Provider APIs So the consumer <-> provider are integrated via gRPC. I read that the gRPC support is not there yet. So does that mean there is no way to go ahead contract testing this use case with Pact ? Any help is appreciated , thanks

steve.heasman
2022-07-20 09:08
has joined #general

tjones
2022-07-20 09:09
You can use pact for the rest clients right out of the gate. I believe there is some support for protobuf contracts, see #protobufs for the current state

je.alvinez
2022-07-20 11:17
has joined #general

jkaur
2022-07-20 12:23
Thanks @tjones, I will check out there!

noor.hashem
2022-07-20 14:48
I am still a little unclear about this, what do you mean by independently deployable units in this case? How could I group contracts per controller or per API version?

matkruse
2022-07-20 14:53
has joined #general

2billy
2022-07-20 16:56
has joined #general

tjones
2022-07-21 04:30
an independently deployable unit is the thing that is versioned in your version control. If you run a deployment, what is deployed?

tjones
2022-07-21 04:30
If you have two controllers in the same service, they are deployed together , as a unit

tjones
2022-07-21 04:30
if you have two different services deployed separately, they are different units

christopher.forbes
2022-07-21 09:27
has joined #general

noor.hashem
2022-07-21 12:30
Hi everyone, what is pact/pactflows capabilities when it comes to slack, jira, and testRail integrations, I thought I read somewhere that they are able to provide slack messages with webhooks?

matt.fellows
2022-07-21 12:31
Yes at the moment, webhooks are the primary means of connecting Pact Broker/Pactflow to other systems


noor.hashem
2022-07-21 12:36
I see, but are these features for pactflow or pact as well? For example if I use the open source pactbroker can I also integrate slack messaging and jenkins etc? Or is this only on pactflow

jbecker
2022-07-21 12:59
Yes, I use the open source pact broker and I've been using the webhooks :slightly_smiling_face:

noor.hashem
2022-07-21 13:02
Oh I see, that's great then!

noor.hashem
2022-07-21 13:03
Another question I had was about feature flag support, does pact or pactflow have any accommodations for this?

sandy.oberoi
2022-07-21 18:57
has joined #general

adelamarre
2022-07-21 19:37
has joined #general

david.vancouvering
2022-07-21 20:06
Hey. I repeatedly have people saying what they really want is to write isolated functional tests and then feel confident that the mocks they are using are correct. The way many people are solving this is by doing a record/playback approach, where they run their tests in staging on a weekly basis, record the results, and use these as their mocks. But I thought it would be great to say "use Pact to define your mocks, run your functional tests, and then use the Pact mocks to verify your provider." But in the docs you recommend *not* doing this for reasons I don't fully understand - something about the mocks defining a contract that is too constrictive and which breaks even when the contract has not broken. Can you explain more? I am very tempted to start using Pact as the mocks for functional tests, but not if this is just a non-starter use of Pact. Thanks!

matt.fellows
2022-07-21 22:12
Nothing first class, it's something we'll need to think about soon as it grows in popularity. If you search the docs we have some advice about how to use it with Pact tho

matt.fellows
2022-07-21 22:59
yes, webhooks are available to all however Pactflow does have a few additional benefits. e.g. we have a secrets feature that means any credentials used in the webhooks are properly secured, but that may not be a concern. We also have webhooks editing and execution view.

matt.fellows
2022-07-22 02:19
Great question. The main issue is that Pact is not a general purpose mocking tool, so often times the mocks aren?t extensive enough to be used in functional tests. A good example is boundary testing - you might want to test a UI that accepts a user?s name with many combinations of short, long and unicode characters. From a contract POV, this is not useful additional information to encode and enforce a provider test for, but if you did it, it could make provider verification more cumbersome.

matt.fellows
2022-07-22 02:21
You can absolutely use the pact stubs in these environments (including the hosted stubs that Pactflow offers). However, there are some limitations to be aware of - such as the lack of provider states to differentiate between different response codes / bodies for a given request. e.g. you might have two tests that cover a `GET /users/1234`, one that returns a `200 {?}` and another that returns a `404` . In this case, the stubs won?t be able to differentiate. This can be mitigated by not having overlapping requests, but is worth noting

matt.fellows
2022-07-22 02:22
In the case of BDCT, the situation changes because we _don?t_ replay all the examples against a provider, so you can create more extensive mocks and that doesn?t create any additional burden on the provider. As long as the mocks are compatible with the provider contracts (OAS) you?re good to go. Mock with impunity! :wink:

david.vancouvering
2022-07-22 02:45
Makes sense, thanks!

husamhindustani
2022-07-22 06:52
has joined #general

noor.hashem
2022-07-22 11:59
Hey all! How do you guys go about organizing pacts in pactflow? Is there a way to group pacts per API version or per team atc?

akke.luukkonen
2022-07-22 12:13
You can create teams there and then filter the contracts by projects related to a team

matt.fellows
2022-07-22 12:14
You can group the applications by team

matt.fellows
2022-07-22 12:14
Ha, beat me to it :rolling_on_the_floor_laughing:

akke.luukkonen
2022-07-22 12:14
Fastest keyboard in the west :sheriff: :cool_cowboy:

abudi.hijazi.01
2022-07-22 13:43
I see the words participant and consumer being thrown around interchangeably, is there a difference between them or are they the same thing?

wilco.van.esch
2022-07-22 13:47
A participant/pacticipant can be a consumer or a provider. https://docs.pact.io/pact_broker/advanced_topics/pacticipant

noor.hashem
2022-07-22 13:55
Okay perfect, thanks both!

jbecker
2022-07-22 19:49
It looks like publishing a new contract does not trigger the `contract requiring verification published` event/webhook. Is this intended behavior?: ``` Events detected: contract_published, contract_content_changed (first time untagged pact published) No enabled webhooks found for the detected events```

matt.fellows
2022-07-23 00:54
A pacticipant (application) _can be a_ consumer, a provider or both (role)

harley
2022-07-23 02:15
has joined #general

japlavaren
2022-07-25 09:21
has joined #general

alasdair.ryan
2022-07-25 10:45
has joined #general

hui.supat
2022-07-25 13:22
has joined #general

balaramvineethvenugop
2022-07-25 17:06
has joined #general

alan.still
2022-07-25 18:18
has joined #general

yshkedi
2022-07-25 21:16
has joined #general

apapia
2022-07-26 02:27
has joined #general

apapia
2022-07-26 02:31
Hi Pact community. Looking for some advice on how to integrate Pact into runtime and/or deployment checks. We run our microservices architecture on Kubernetes using FluxCD2 to provide a GitOps deployment model.

apapia
2022-07-26 02:32
We have pretty good coverage with Pact contract tests but these only run as part of our CI. There is no CD pipeline anymore. We simply update the declared state in git and Flux will apply the state in the K8s clusters.

apapia
2022-07-26 02:34
I am looking for advice on how to implement the can-i-deploy checks in this model. Our infrastructure team thinks we should use helm pre-install hooks for deployment checks or readiness probes for runtime checks, but doesn't want to put our Pact Broker in the critical path.

apapia
2022-07-26 02:36
We have multiple production environments, so we need to track each of our deployments and rollbacks in the pact broker and then run can-i-deploy prior to deployment or before becoming ready.

tjones
2022-07-26 02:36
>> We simply update the declared state in git and Flux will apply the state in the K8s clusters. :open_mouth: Ignoring pact, isn't this risky?


tjones
2022-07-26 02:37
Oh, well, carry on then :sweat_smile:

tjones
2022-07-26 02:37
Does whatever repo you're declaring state in have CI? Can you do `can-i-deploy` there?

apapia
2022-07-26 02:38
Currently, the proposal is to implement a version API on each of our microservices and have each service track its required dependency versions and do a runtime or deploy time check to make sure dependency versions are satisfied in the environment. But this is totally sidestepping Pact for dependency management. :open_mouth:

apapia
2022-07-26 02:39
Anyone, I'm wondering if anyone else has implemented something for "GitOps" that might satisfy our infra team.

tjones
2022-07-26 02:39
Can we keep this in a thread, please? Some maintainers/contributors have notifications set for new messages

tjones
2022-07-26 02:40
One challenge with Pact is that it kind of needs your deployment process to be able to be reasoned about

tjones
2022-07-26 02:40
I would ask your infra team how they expect to solve all these problems

tjones
2022-07-26 02:41
This proposed process sounds... scary

apapia
2022-07-26 02:41
Sure sorry.

apapia
2022-07-26 02:42
Yeah agreed. I need to come up with a counter proposal so we don't end up in dependency hell and just use Pact to test compatibility.

apapia
2022-07-26 02:44
My thoughts are: 1. Add a check on the PR to update the git state - this could be a Jenkins job or GitHub Action that inspects the change to the declared state and makes the appropriate can-i-deploy check. Not sure if it would make sense to track deployments this way but maybe a GitHub Action could be used for this as well. 2. Pay for pactflow so that they don't have to worry about maintaining the pact broker and it being a SPOF in the deploy process. We already have other SaaS products in the path like GitHub.

tjones
2022-07-26 02:45
You can probably present it as a win for the infra team - "hey, we're already doing these contract checks with our CI, you could get deployment safety for free if you integrate it into your deploy pipeline"

tjones
2022-07-26 02:46
yes, #1 feels like a sensible change. You might run into problems though: PR1 updates some consumer version , it's checked compatible with the current provider in prod at PR time PR2 updates some provider version, it's checked compatible with the current consumer in prod at PR time both PRs get merged, and something breaks because the versions in PR1 and PR2 are not compatible.

tjones
2022-07-26 02:47
Ideally you are doing the check right before you deploy.

tjones
2022-07-26 02:48
> 2. Pay for pactflow so that they don't have to worry about maintaining the pact broker and it being a SPOF in the deploy process. We already have other SaaS products in the path like GitHub. I don't work for pactflow, but I'd still heartily endorse this as an option to simplify things.

tjones
2022-07-26 02:50
> I need to come up with a counter proposal What I would do is look at the things that pact solves, and then ask how those issues are solved with the current proposal (they're probably not, but if they are, then you can compare eng effort etc). If you have history of your past deployments when you had CD, you might be able to motivate your case with statistics on how often the contracts break

tjones
2022-07-26 02:53
> Not sure if it would make sense to track deployments this way but maybe a GitHub Action could be used for this as well. A github action for can-i-deploy is a *great* idea, and if you build this it would be totally worth open-sourcing (I reckon @yousafn would agree)

apapia
2022-07-26 02:56
thanks for the feedback!

tjones
2022-07-26 03:02
You're very welcome! Let us know how you go

yousafn
2022-07-26 09:47
Hey hey, Heard my :batman: call! We do have a can-i-deploy https://github.com/pactflow/actions/tree/main/can-i-deploy Github Action for the Pactflow broker, so it uses a `PACT_BROKER_TOKEN` rather than a `PACT_BROKER_USERNAME`/`PACT_BROKER_PASSWORD`, it would be easy to tweak for the OSS broker.

rziembicki
2022-07-26 10:47
has joined #general

dpal
2022-07-26 10:58
has joined #general

dgrace
2022-07-26 11:02
has joined #general

dgowdappa
2022-07-26 11:02
has joined #general

apapia
2022-07-26 13:23
Thanks @yousafn. Do you also recommend recording deployments and releases with GitHub Actions?

yousafn
2022-07-26 13:58
Hey it is up to you buddy, Our CLI tools are available in a variety of formats, although the linked page is your bi-directional contracts, a Pactflow only feature, the toolset is the same. https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas#installation You can pick whichever is most suitable for your workflow, the GH Actions, is simply a wrapper around the CLI tools, and may be an additional layer of abstraction too far (the CLI tool itself is super versatile) :thumbsup:

sascha_pactflow
2022-07-26 20:29
has joined #general

hunsolitude
2022-07-26 22:34
has joined #general

maksym_odanets
2022-07-27 08:07
has joined #general

andrew.january
2022-07-27 09:03
has joined #general

davidf
2022-07-27 09:17
has joined #general

gibraltor999
2022-07-27 17:07
@tjones Thanks for your detailed response. I am running my integration tests at CI level , well before CD. In my CI, a docker build agent will spin up and I am creating an environment to have all the domain services up and running and connected to different third party vendors and hence I am able to run the tests before it gets deployed. Thats helping me to identify issues even before it gets deployed. AT the same time , you are also right--->setting up this environment in the build agent might take few minutes , and will eventually add up to the whole CI execution time. If possible can you give me an example of difference between grammar vs semantics testing of a contract. I want to understand what my current schema tests lack?


matt.fellows
2022-07-27 22:37
This talks about some of the differences and considerations

tjones
2022-07-27 23:35
The example in my post above is the main one I like to illustrate this problem. Another problem is that the schema can't tell you what's valid- eg a delete for a resource gives a different response if the response doesn't exist. This information is implied in a schema, or encoded in comments. A good contract test will include this information directly.

gibraltor999
2022-07-28 08:49
One thing I had to say.. Pact has awesome *DOCUMENTATION*. It looks like they are very particular for the users to actually use it, documentation is not one-sided, it also talks about down-sides of Pact and how we can overcome them. KUDOS to the TEAM for a fantastic *DOCUMENTATION*. :clap-all:

ankit.mittal
2022-07-28 10:00
has joined #general

vishal.kukreja
2022-07-28 10:22
has joined #general

hazem
2022-07-28 18:45
@bethskurrie in case you didnt see. :grin:

robert.henzel
2022-07-28 19:50
has joined #general

jbecker
2022-07-28 21:00
Hey, something came up recently and I'm not sure what the correct "pacty" way to handle it is: I have a POST rest endpoint I'd like to test which takes an object and creates it in the database. One of the properties on this object must be the ID for an inner object that must exist already in the database, so in my state setup function inside my provider I'm creating the inner object. The problem is that the object is always created by the database with a random UUID, and a database constraint prevents me from creating the object with a known ID. So how do I write my contract such that the object being posted is using the ID of the inner object in its own properties if it's randomly generated? I see that I _can_ use matchers in the POST body in the contract, but if I don't actually know the real ID of the inner object that was created during the setup, I'm going to get a 400 error when I try and post my new object because it's not matching on a valid row of the inner object in the provider's database, so the matcher doesn't actually help me in this instance. Thanks!

bethskurrie
2022-07-28 21:36
Thanks! That makes sense.

tjones
2022-07-29 00:54
You can do this with provider state, where the provider state setup returns the value you need

matt.fellows
2022-07-29 01:21
What language are you using @jbecker?

adam.witko
2022-07-29 08:29
Hey hey :wave: . I have a question about ?dev? environments when pacticipants are deployed to it by N feature branches. We have a setup where each branch is deployed in to a shared ?dev? environment but it itself is physically separate than any other ?instances? of that consumer/provider already in that environment. So Provider A on `feature/123` and Provider A on `feature/234` will have different versions but they?ll represent two distinct instances. This leads me to think about using `record-release` so the other versions are not marked as undeployed (as `record-deployment` will do for you). Our upper environments all have 1 instance of each pacticipant so a normal `record-deployment` workflow will suffice. Is using `record-release` the best for this setup over `record-deployment` with the `--application-instance` to a ?dev? environment like this? If you know of anywhere in the docs or working examples you could share that would be amazing :heart: .

adrianminnock123
2022-07-29 08:53
has joined #general

gibraltor999
2022-07-29 09:22
@tjones I am using https://ajv.js.org/json-schema.html to do my schema testing. I am using an http client to call my endpoint with -verb, headers, payload, and matching the response with the schema.. And I am doing this for variety of combinations (e.g what req will give back different response codes/response body). So am I wrong in assuming that I am also checking the HTTP level semantics using AJV?

matt.fellows
2022-07-29 10:24
It's been a while since I looked at AJV in detail. My understanding is that v doesn't know about HTTP semantics like paths, verbs etc.

matt.fellows
2022-07-29 10:25
How do you map the open API paths and verbs to the right schemas (This is out of genuine interest)

matt.fellows
2022-07-29 10:26
I'm also keen to know if you capture any consumer examples and test those too (e.g. a form of contract testing)

adam.witko
2022-07-29 10:53
Adding to this. These pacticipants in the ?dev? environment are not long lived. When the feature branch is merged to main or deleted, the pacticipant is removed from the environment. This has led me to think about the pros/cons of can-i-deploy and record-deployment/alternative to this environment. Is it better to simplify the pact broker usage for this ?dev? environment and change it to verify in the build/PR pipeline to run can-i-deploy to the next higher environment, e.g. staging/qa?

tjones
2022-07-29 11:15
Interesting. Would you be comfortable sharing an example from your tests?

massimiliano.devivo
2022-07-29 12:12
has joined #general

jbecker
2022-07-29 13:19
For this interaction the consumer is TypeScript and the provider is Python

jbecker
2022-07-29 13:19
The database the provider is using under-the-hood is postgres

jbecker
2022-07-29 13:21
and like I said, the data I'm trying to insert into the fake database as part of my provider state setup has a constraint on that ID field so I can't set it, it gets set automatically when the row is created

tjones
2022-07-29 13:24
The provider state provided variables are perfect for this. Once the row is created in your state hook, you read the ID field and return it in the response from the state hook. This needs spec version 3, which means you?ll need to upgrade to pact-js v10

tjones
2022-07-29 13:24
The method you need on the consumer side is called something like ?fromProviderState?

jbecker
2022-07-29 13:27
Oh I had no idea you could return state from the state setup hook. What does that look like? Can you point me to an example somewhere?

jbecker
2022-07-29 13:28
You're right though, that does sound like exactly what I want

tjones
2022-07-29 14:12
personally, in that scenario I would just not use can-i-deploy - it's ok to deploy broken stuff to dev

adam.witko
2022-07-29 14:13
That?s what I?ve started to make changes towards. Deploying to the env but not can-i-deploy/record-deploy but doing a can-i-deploy post ?deploy to dev? on the next environment along (QA)

tjones
2022-07-29 14:13
or, I would do can-i-deploy only on the master deployment (assuming that your dev deploys don't clobber each other)

tjones
2022-07-29 14:15
I guess my question is - why are you deploying feature branches at all? My guess is that the answer is something like "well, the devs sometimes want to manually test something they're working on" - and in that case, having deployments gated by contract tests would be very annoying.

tjones
2022-07-29 14:16
(I'm not a fan of the "I want to deploy this to test it during development" style, but I haven't found a way to communicate this to people who want to do that)

tjones
2022-07-29 14:17
And, to your actual question - yes, I think record release is ideal. It's for situations where you might have multiple versions of something all live in the same environment (eg, mobile clients or public library clients)

tjones
2022-07-29 14:19
It's a new feature for pact-js, only just out of beta thanks to the hard work of Matt and team

adam.witko
2022-07-29 14:20
Yeah the reasons for the deployment per feature branch is exactly that, for manual/exploratory testing. As we migrate to having the CI/CD contract testing set up in our pipelines the reliance on such deployed consumers/providers should start to reduce. Thanks for your thoughts @tjones

jbecker
2022-07-29 14:21
Oh wait, so if my provider is in Python then I won't be able to do this?

tjones
2022-07-29 14:21
See the ?provider state injected variables? section here: https://github.com/pact-foundation/pact-js/blob/master/docs/matching.md

tjones
2022-07-29 14:22
Oh, sorry, I thought you said typescript

jbecker
2022-07-29 14:22
The consumer is typescript

tjones
2022-07-29 14:22
Yes, you start this on the consumer

tjones
2022-07-29 14:22
You put it in the contract as ?this thing is set by the provider?

tjones
2022-07-29 14:22
*by the provider state

tjones
2022-07-29 14:24
I don't know if pact-python supports this yet (it will if it supports v3 of the pact spec), but you don't need to do provider verification the same language as the provider

jbecker
2022-07-29 14:26
How would I create the state setup router in my FastAPI service _without_ using Python?

tjones
2022-07-29 14:29
you can use a state change endpoint (in python), but drive the test with some other pact-supported language

tjones
2022-07-29 14:29
you would need to have something scripted that starts the provider with this state change endpoint available

hareesh.dj
2022-07-30 12:01
has joined #general

heera
2022-07-31 08:00
has joined #general

adam.redlisiak
2022-08-01 10:18
has joined #general

altan.demirkiran846
2022-08-01 14:38
has joined #general

nick080
2022-08-01 14:44
has joined #general

ali.ustek
2022-08-01 15:09
has joined #general

dimundo
2022-08-01 19:31
hi! is there some way to check `can-i-deploy` against all version , having tag `live` and deployed within n months? like am i `compatible with all versions deployed to live within 3 months?`

dimundo
2022-08-01 19:33
having deployments once a month one can imagine `live1`, `live2` and `live3` for 3 last months version, what to do if deployment arent regular - could happen once a year or each 25 minutes ?

momarquez
2022-08-01 19:37
has joined #general

adam.anderson
2022-08-01 22:07
Hello, any recommendations on using Pact for server to server communications involving files. Examples SFTP file transfers, S3 pre-signed URL file downloads, SWIFT files. I see the file handling as more of functional testing and not contract based. But we have encountered some microservices moving large amounts of JSON via files experience an occasional breaking change.

matt.fellows
2022-08-01 22:39
You can definitely do it. I don?t know if we have any public examples, but if it?s about moving JSON files about you could consider the use of Message Pact for that purpose

matt.fellows
2022-08-01 22:42
This is a very old post that shows that with DynamoDB, but it works just as well with file transfers: https://dius-au.medium.com/contract-testing-serverless-and-asynchronous-applications-part-2-76b5576c789e

matt.fellows
2022-08-01 22:47
Yes! That?s exactly what the `deployed`, `released` and `deployedOrReleased` https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors are for.

matt.fellows
2022-08-01 22:47
If you?re not using deployment/releases yet, you can still use tags. e.g. you might tag things that are in production as `prod`

matt.fellows
2022-08-01 22:48
you would then apply the selector `{"tag": "prod", "latest": "false"}` to fetch all contracts with the `prod` tag. This does mean you need to remove the `prod` tag from the undeployed version

john
2022-08-02 04:12
Just a quick question is pact written in ruby but been refactored to rust via the ffi?

matt.fellows
2022-08-02 04:21
The initial implementation was Ruby, and a number of languages to assist with getting it up and going, bundled Ruby into them as the ?shared core?. This worked great, but as Ruby is not easily distributed there were some challenges. There is a program of work to migrate to Rust. See also https://docs.pact.io/history and https://github.com/pact-foundation/pact-specification/issues/83

matt.fellows
2022-08-02 04:21
why do you ask?

john
2022-08-02 07:06
ah i saw some ffi in the pacts for rust and some rust like error messages and i was curious if it was refactoring i9t or building it fromt he ground up

matt.fellows
2022-08-02 07:07
Are you a Rustacian? :stuck_out_tongue:

john
2022-08-02 10:16
i think i mentioned it previously, but i dabble quite a bit outside of work with Rust. Mainly games development and some stuff like that. Though i have been dabbling in writing rust and importing it as python functions etc. My current project ive been dabbling quite a biit with Warp and will get around to maybe writing some contract tests in rust. My next project will be to get some games into the browser with web assembly

dimundo
2022-08-02 11:00
`latest false` will check all of them ? what if one needs that only last 3months of service is supported ?

rubemfsv15
2022-08-02 20:13
has joined #general

tjones
2022-08-03 01:00
^ This sounds awesome, John!

rene.klatt
2022-08-03 06:13
has joined #general

imayat
2022-08-03 09:42
has joined #general

mark.shand
2022-08-03 10:15
has joined #general

gunjan.titiya
2022-08-03 11:51
has joined #general

gibraltor999
2022-08-03 12:12
@matt.fellows @tjones AJV doesn?t have to know the paths and semantics, we write our tests using an http client(superagent in our case) to hit an endpoint with respective verbs, headers, endpoint , query params, etc etc?and capture the response and then validate them against the schemas we generated through a script( this script basically takes the response which we think is ok once the endpoint is implemented, and then convert it into a schema). 2. Not only we verify the schema but we also check response code, values within the response(e.g, the currency type should be £ and not $)- this way we also test E2E integration and contract test in one single scenario. Dont need two tests for it. 2. We write tests to check all possible scenarios - negative tests, and simulate different scenarios which sends different response code. I am very keen to run past an example with both of you and really wanted to understand and also give some insights to you on how I am doing my contract and integration testing ? I went through the complete documentation of Pact and BDCT , but just have few things which would be good for all of us to discuss and get a different perspective.. Any time slot you both are comfortable and I can run past the things in less than 10 minutes - which covers my Ci-CD process, Contract and Integration testing (all happening before even the code gets deployed ? basically how I implemented Pacts?s ?CAN-I-DEPLOY?..

chaitanya.guttula
2022-08-03 12:43
has joined #general

deb.kimnach
2022-08-03 12:48
has joined #general

abudi.hijazi.01
2022-08-03 14:55
I've encountered a CI/CD design blocker that I can't seem to get around: I was planning to create a pact on every commit, use the commit sha as the consumer version, and the branch committed in, as the consumer branch. I was planning to use github statuses to report whether a commit is compatible with the API, where, once the provider publishes the test result, a webhook will be triggered to change the consumer commit status in accordance with the test result. Now this causes this issue to arise: If a branch commit produces the same pact as the previous commit, how do we get the status of the new commit to be the same as the previous one, without having the provider test every single pact that is published? 'Branch Commit' meaning a commit with the branch set as _XYZ_ on Pactflow. We are assuming we are committing on the same branch in these scenarios. I initially thought, that you could set a webhook on pactflow to be triggered when a duplicate pact is published, but that's not an option in the webhooks. So basically I have no idea how to get around this issue.

kyle.hammond
2022-08-03 17:05
Not sure if this helps or not, but if you commit the pact file itself you could trigger your workflows only when the pact file changes. This would have problems with your version numbering scheme though because getting the hash of the commit that created the pact is one thing, then committing the pact file itself would have a different hash.

adam.anderson
2022-08-03 21:40
Thanks Matt! Very helpful

tjones
2022-08-03 23:17
If the contract is identical to one previously verified, then the broker knows that it doesn't need re-verification

tjones
2022-08-03 23:18
you can then use can-i-deploy as your github status check

tjones
2022-08-03 23:32
Idea: prod pact. A bit of middleware that will log if you're about to send a request or a response that doesn't match any pact interaction

kaiquan.shi
2022-08-04 03:38
has joined #general

matt.fellows
2022-08-04 06:53
Haha it's on the backlog! Runtime violations is what we've been calling it internally, but it can go further. E.g. Missing interactions could show up in the broker as test cases that need coverage, frequency/importance of certain interactions etc. Lots of ways to get the data too. Middleware, log files, eBPF etc.

matt.fellows
2022-08-04 06:54
I'll consider this a form of validation of the idea :rolling_on_the_floor_laughing:

tjones
2022-08-04 06:54
You'd need to use matchers on the request in order to get some of the features there

tjones
2022-08-04 06:55
but it's a small cost

tjones
2022-08-04 06:55
it would be super easy if there was a system of recursive matchers :thinking_face: :sunglasses:

matt.fellows
2022-08-04 06:56
Problems for future us to worry about. Don't let implementation get in the way of fun ideas :wink:

aalexandrumihai
2022-08-04 10:15
has joined #general

pollet_22
2022-08-04 12:25
Can any one help me to design which parts i should do a contract test with Now we have microservices , FrontEnd which is a mobile apps and web and there are also an api gateway which handles requests between microservices and FE for which parts i should add my contract test in to get best test coverage ?

alex.makdessi
2022-08-04 13:03
has joined #general

yousafn
2022-08-04 13:08
Hey, Have you got a diagram of your setup. What existing test coverage do you have? There will be contracts between integration points between two applications. I would generally start with the high value endpoints, one that are subject to change frequently, or those which is they did change, would cause significant detriment. Each of the applications should have a distinct unit test suite, where I would assume developers are performing component integration with mock representations of their dependencies. It is these mocks that are subject to drift from the real implementation, and that is what you will be using contract testing for, to provide that feedback prior to implementing and deploying both sides.

matt.fellows
2022-08-04 13:37
This is a draft, but might be helpful: https://docs.pact.io/recipes/apigateway

ynechaieva
2022-08-04 14:11
has joined #general

dineshh.wot2021
2022-08-05 10:17
has joined #general

fernandapontual5
2022-08-05 11:34
has joined #general

sridhar140895
2022-08-05 11:58
has joined #general

glenn
2022-08-06 18:13
has joined #general

sandy.mechie
2022-08-07 21:46
has joined #general

prapurna.manda3
2022-08-08 07:38
has joined #general

laura.cabantous
2022-08-08 10:42
Hi there, I'm trying to run a test scenario where a parameter is passed in an invalid format (and it should throw a 400), but it fails with the error message `with 30000 ms timeout for Pact`. I've tried to increase the timeout (quite significantly but it still fails with the same message). Is there any way to check why it times out? It seems due to a promise that doesn't resolve... Also it seems to be specifically when looking to get the provider to respond with status 400 :thinking_face:

matt.fellows
2022-08-08 11:16
Might be best asking in #pact-js. If you could please share the code snipped of the test that fails and any terminal output/logs that would help too

matt.fellows
2022-08-08 11:17
My guess is that your HTTP client is throwing and the test isn?t catching it (that is, it?s not a Pact problem, it just happens to be a Pact test that is showing you the problem)

laura.cabantous
2022-08-08 11:19
sure, will do!

jaroslavburi
2022-08-08 14:44
has joined #general

manumahendran
2022-08-08 16:14
has joined #general

lmendonca
2022-08-08 22:18
has joined #general

jbrauchler
2022-08-08 22:44
has joined #general

cristideacc
2022-08-09 09:05
has joined #general

gueorgui
2022-08-09 10:48
Hi folks, We (my team) have a react consumer and a ruby provider, and we?re doing work refactoring one of the endpoints on the provider, by removing unused attributes from the returned JSON in order to improve performance. I want to write a test that would validate that after changes to the provider, the relevant component on the consumer can still render correctly. My idea so far is like this: 1. Update contract test on consumer to match what I expect the backend to return 2. Update my component?s unit test on the consumer to ensure the component will render correctly with the updated backend data 3. Once everything validates, make changes to the backend. Does this sound correct? If so, is there a smart way of not having to maintain two sample API responses on the consumer side (one for the contract test, one for the component?s unit test?) In other words, is there some best practice to reuse data setup for a contract test in a component?s unit tests?

matt.fellows
2022-08-09 11:39
You could use the data from the Pact tests in your component tests, so you don?t have separate mocks that could drift

matt.fellows
2022-08-09 11:40
In the 9.x.x version `extractPayload` in the matchers package lets you do this (it removes any matching rules and gives you the raw JSON.

gueorgui
2022-08-09 12:44
Oh that?s very nice, I didn?t know about `extractPayload`. Thanks Matt!

matt.fellows
2022-08-09 13:50
We need to port this to 10.x.x. let me know how you go and if this helps

alison.stuart.contrac
2022-08-09 20:41
has joined #general

jean.paiva42
2022-08-10 19:03
Hey everyone, quick question: I am using the `pact-provider-verifier` and I installed it through `gem`. On my use case I needed to use a header called `response-format` (all lower case)but it seems like when pact-provider-verifier does the request it changes the header and capitalizes it to `Resonse-Format` , is there a way to prevent this from happening and being able to use the header all lower case?

matt.fellows
2022-08-10 21:56
It might be worth searching this question across the pact foundation GH organisation. I believe it's come up before and I think the answer is no. The header names are standardised.

matt.fellows
2022-08-10 21:57
I believe header keys should be case insensitive as far as the RFC is concerned

matt.fellows
2022-08-10 21:59
The behaviour is built into the framework that pact ruby uses. There is a rust verifier which may not do that


tischnerd
2022-08-11 06:49
has joined #general

tischnerd
2022-08-11 07:28
Hi there :wave: I have a quick design question regarding the `fromProviderState` mechanism. Its not language specific, but I'll use the JVM examples. A frequent situation, also shown in the docs, would be that a consumer is asking for a specific situation: ```builder.given("product with ID 10 exists") .uponReceiving("get product with ID 10") .method("GET") .path("/product/10") ...``` In this example the consumer had to came up with an ID that might exist for a product. (And the provider will then have to adhere to that, making product 10 available). Would this also be a valid application for `fromProviderState` to let the provider decide on the ID of an existing product? (All examples I found in the docs only relate to autogenerated IDs that can not really be picked by the consumer without making life hard for the provider. And they are also mostly focused on using `fromProviderState` for the response part, i.e. after `willRespondWith()`.) I.e. should we write this code instead as ```builder.given("a product exists") .uponReceiving("get that product") .method("GET") .pathFromProviderState("/product/\${id}", "/product/10") ...``` with a provider having a state like ```@State("a product exists") fun createProduct(params: Map<String, String>): Map<String, Any> { val product = ... // maybe create that product in the DB or something return mapOf("id" to product.id) }``` Thanks in advance and cheers :thumbsup:

tischnerd
2022-08-11 07:33
Additionally, would that also be applicable for a product that does **not exist**? Such as ```builder.given("a product exists") .uponReceiving("get a product that does not exist") .method("GET") .path("/product/\${unknownId}", "/product/999") ...``` with a state like ```@State("a product exists") fun createProduct(params: Map<String, String>): Map<String, Any> { val product = ... // maybe create that product in the DB or something return mapOf( "id" to product.id, "unknownId" to 50 ) }```

uglyog
2022-08-11 07:48
Yes, this was exactly what that was for

tischnerd
2022-08-11 08:32
awesome, thanks for clarification :thumbsupparrot:

tischnerd
2022-08-11 08:32
(for visibility: @lucka (colleague of mine))

lucka
2022-08-11 08:38
Good to know

k.bangarusamy
2022-08-11 10:44
Hi @matt.fellows will you just give me some high level description for pact and pactflow - usecase etc

k.bangarusamy
2022-08-11 10:44
We are highly recommending with client so need to include on the slides

matt.fellows
2022-08-11 10:50
That's great to hear!

matt.fellows
2022-08-11 10:50
If you have an email I have a nice a PDF/preso that could be helpful.

k.bangarusamy
2022-08-11 10:50

matt.fellows
2022-08-11 10:51
I'm confused about what additional info you might need that's not already on http://Pactflow.io, http://Pactflow.io/features or docs http://pact.io What's missing?

k.bangarusamy
2022-08-11 10:53
got it, I thought to get some overview from your side. Document has detailed infomation

matt.fellows
2022-08-11 10:54
I just sent you an email now, hope that helps!

k.bangarusamy
2022-08-11 10:56
Thanks Mill Will check it

gueorgui
2022-08-11 11:12
`extractPayload` has made my life much easier overall. We were going to upgrade to 10.x but if not having `extractPayload` available seems like a solid reason to hold back. Is there any alternatives in 10.x?

matt.fellows
2022-08-11 11:49
It?s a pretty simple little function. It just recurses the object and removes any Matchers.

gueorgui
2022-08-11 11:49
Ah fair! I?ll take a look at the code and roll my own then

matt.fellows
2022-08-11 11:51
9.x.x `extractPayload` function: https://github.com/pact-foundation/pact-js/blob/c0f3d37b3a1f1843d4e92182b388bfe23d95e5c8/src/dsl/matchers.ts#L290-L309 It just needs one here (10.x.x): https://github.com/pact-foundation/pact-js/blob/master/src/v3/matchers.ts If you?re up for writing that, it would be ace. Please also call the new function `reify` and type alias it as `extractPayload` (or maybe we don?t bother keeping both, and add it to the upgrade guide?) Reify is the term used in other parts of the project and it has been pointed out we should make that consistent

joel.wochele
2022-08-11 12:53
has joined #general

gueorgui
2022-08-11 13:09
Working on it :slightly_smiling_face:

gueorgui
2022-08-11 13:09
Never seen this syntax before: ```export function isMatcher(x: AnyTemplate): x is Matcher<AnyTemplate> { return x != null && (x as Matcher<AnyTemplate>).getValue !== undefined; }``` what is this `x is Matcher<AnyTemplate>` ?

gueorgui
2022-08-11 13:16
Oh it?s a type predicate. TIL

tischnerd
2022-08-12 08:46
I have a follow-up question on `fromProviderState` design. Where do I ideally draw the line when to use it for argument details that the consumer simply does not care about. Lets say the pact is testing a `hello world` response and the API also requires a somewhat unrelated header that the consumer is supposed to send, maybe `X-Locale: de`. Now, for the test and pact this argument does not matter, any valid country-code would suffice, `fr` for example. Should the pact on consumer side now explicitly demand `de`, using `headers("X-Locale", "de")` or let the provider decide on this with `headerFromProviderState("X-Locale", "${anyValidLocale}", "de")`? This question goes even further. Lets say we have to send a complex DTO body, but for the particular pact only one value in it actually matters. Should the rest of the DTO be given by the provider state or should the consumer just specify the full DTO, even though majority of it _doesnt matter_? Essentially, I am looking for ways to signal to the provider that something was not picked due to any particular reason, but could be _anything_. So that the provider clearly knows which part of the contract is actually important to the consumer.

matt.fellows
2022-08-12 11:20
as a starting point, I think this principle still stands, and the one directly beneath https://docs.pact.io/consumer#only-make-assertions-about-things-that-will-affect-the-consumer-if-they-change

matt.fellows
2022-08-12 11:20
> Lets say the pact is testing a `hello world` response and the API also requires a somewhat unrelated header that the consumer is supposed to send, maybe `X-Locale: de`. Now, for the test and pact this argument does not matter, any valid country-code would suffice, `fr` for example If varying the value isn?t important from a contract point of view, I wouldn?t complicate the tests further

matt.fellows
2022-08-12 11:21
`fromProviderState` does involve some extra setup by the provider, and I tend to have golden data sets on the provider side when I verify them, so the consumers can just use known IDs etc. But of course YMMV

matt.fellows
2022-08-12 11:22
> This question goes even further. Lets say we have to send a complex DTO body, but for the particular pact only one value in it actually matters can you please elaborate on this? Are you saying the JSON that you send doesn?t matter (or just a subset of that) or only a subset of the response matters?

tischnerd
2022-08-12 11:28
the thing is, from a consumer POV some values of a *request* are actually important to be the way they are. and others could be anything that fits. for example, lets say the request has to send a positive value in the body ```"value": 5``` now, the consumer pact could be something like _"when sending a positive value, you respond with 200"_ who is supposed to decide on a value here? the consumer? the provider? and if the consumer picks one, how to signal that they could also have picked 10 or 20, i.e. that they do not really care? for a response, i would just use a lose regex matcher, but afaik for the request part the consumer is supposed to be as strict as possible, no?

tischnerd
2022-08-12 11:32
an actual case from practice could be this here: https://i.imgur.com/YfLroLz.png thats the body of a request. right now, fully specified without any regex or similar. all that matters for this particular pact however is that the date is in the past and not in the future. so the date here just acts as an example. the consumer wants to signal the provider that, for this pact, `anyDateFromPast` would have worked - how to do that?

tischnerd
2022-08-12 11:34
i could use `valueFromProviderState` to let the provider pick one. but it doesnt feel like the right tool for the job

matt.fellows
2022-08-12 11:36
> now, the consumer pact could be something like _?when sending a positive value, you respond with 200?_ > who is supposed to decide on a value here? the consumer? the provider? I would default to the consumer, unless there is a good reason. > for a response, i would just use a lose regex matcher, but afaik for the request part the consumer is supposed to be as strict as possible, no? (edited) Yes, ideally you don?t have matchers on the request unless you really need to (the matchers are only checked on the consumer test, not on the provider side - in case that wasn?t clear). I wouldn?t get too hung up on some of these things though. Occasionally that will border on a functional test, but that?s OK, the lines aren?t always clear and bright. See also https://docs.pact.io/consumer/contract_tests_not_functional_tests. If it is important that the ?positive number? or ?date in the past? scenario is checked, then it should be covered (and specified from the consumer). > i could use `valueFromProviderState` to let the provider pick one. but it doesnt feel like the right tool for the job I would tend to use this function sparingly, and only give more work to the provider if necessary.

michel.kaporin
2022-08-12 11:58
Hi there! I have a question on how Pact / bi-directional contract testing can be beneficial when developing APIs where providers generate new specs when introducing breaking changes and consumers consume it via an HTTP query parameter? E.g. REST API have a form of `GET /path/to/resource?version=2021-09-21` with the parameter targeting a specific date of the API specification. In other words, when new API breaking changes get published, API provider creates completely new OpenAPI specification that consumers have to switch to if they want to target the latest version. The old versions are being supported until a certain deprecation date. You can read more https://github.com/snyk/sweater-comb/blob/main/docs/principles/version.md#api-versioning, if you need a more detailed explanation. How would the consumer and provider contract testing flow look like in such scenario?

tischnerd
2022-08-12 12:01
makes sense. gonna find the sweetspot then, thank you for the input :thumbsup:

matt.fellows
2022-08-12 12:08
I?m keen for other thoughts on this too!

evert.vanloo
2022-08-12 12:16
has joined #general

jors.matthys
2022-08-12 13:27
has joined #general

ricardo.maury
2022-08-12 18:34
has joined #general

prateekm33
2022-08-15 00:46
has joined #general

prateekm33
2022-08-15 01:20
hello! wanted to repost my question in #pact-js here as well. having some issues configuring my consumer tests. any advice would be greatly appreciated! https://pact-foundation.slack.com/archives/C9VBGLUM9/p1660526266380169

ahmed.fahmy
2022-08-15 09:10
has joined #general

tpaktopsp
2022-08-15 18:47
has joined #general

prateekm33
2022-08-15 19:30
curious what ya?ll think about needing or not needing contract tests when the provider is graphql. seems like the graphql schema can be a good enough proxy for a stand-in contract test. just want to make sure we use contract testing in the correct places

matt.fellows
2022-08-15 20:49
See https://pactflow.io/blog/contract-testing-a-graphql-api/ and let me know what you think. TL;DR - GraphQL doesn?t give you protections on its own, you still need a way to ensure the schema doesn?t change in a breaking way

tjones
2022-08-16 00:03
How do you check compatibility between any two versions of the schema? How do you reason about what you can and can't deploy?

tjones
2022-08-16 00:33
GraphQL doesn't solve those problems, it just makes it less work to implement the transport of data

cyrus.devnomad
2022-08-16 06:24
*Hi* *In the following articles "contract testing using json schema" is explained from a theoretical point of view:* *https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-1/* *https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-2/* *https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-3/* *If I'm not mistaken Bi-Directional contract testing is a kind of contract testing using json schemas. In the articles above it is mentioned that one of the advantages of this type of testing is the possibility to test the provider as blackbox.* *For example in the dotnet Bi-Directional contract testing workshop ( https://github.com/pactflow/example-bi-directional-provider-dotnet ) the schemathesis tool is used to verify the provider API in a blackbox manner as follows (in this case the provider is running on the docker host on port 9000 and the tool access it from within the docker container to test it):* *docker run --net="host" schemathesis/schemathesis:stable run --stateful=links --checks all http://host.docker.internal:9000/swagger/v1/swagger.json > report.txt* *Of course it has advantages to be able to test a provider in this blackbox manner but what if most of your microservices have external dependencies? Can you use this approach then?* *In the workshop mentioned above you have to send both to Pactflow server, the swagger.json file (which is generated during the build phase in the workshop) and the report.txt file which contains evidence that the provider API was tested (by that blackbox test mentioned above).* *The problem is what if you can?t easily get your provider with lots of external dependencies running in the pipeline. In that case the generation of that provider API test evidence gets quite difficult. You would have to have access to the code to make sure that your external dependencies are mocked away during the blackbox test. But being forced to have access to your code while you want to perform blackbox tests kind of defeats the advantage of blackbox testing.* *I have tested the Pactflow workflow to see whether the system could work without the need to publish the provider API verification evidence and by only publishing the swagger.json.* *It turns out that the consumer?s can-i-deploy is happy with provider?s swagger.json being published alone and can be deployed without the provider having its API test evidence published. But the provider?s can-i-deploy does not allow it to be deployed as long as its API test evidence is not published.* *Of course this all makes perfect sense.* *But what if you really want to take advantage of blackbox testing but you can?t get your provider with lots of external dependencies up and running in the pipeline. What if you are mostly interested in the compatibility between your consumers and providers and not so much about testing your providers themselves.* *Is there a way to work with swagger.json alone and leave out the provider API test evidence (represented by report.txt in the workshop example above)?*

julian.schmidt
2022-08-16 09:03
has joined #general

jack340
2022-08-16 09:11
has joined #general

g.varga
2022-08-16 11:55
has joined #general

matt.fellows
2022-08-16 12:06
So the TL;DR is ?yes?, you can definitely omit the report (I think the field may need something, even just text that says ?we tested this, trust me because I?m a developer?.

matt.fellows
2022-08-16 12:07
But. > But what if you really want to take advantage of blackbox testing but you can?t get your provider with lots of external dependencies up and running in the pipeline. What if you are mostly interested in the compatibility between your consumers and providers and not so much about testing your providers themselves. The question implies that the provider _implements_ the spec to a degree you have a level of confidence that is the case. If you do have that confidence, this should be fine. But the question then is, how are you getting that confidence? It sounds like testing it is already difficult - do you test it by hand? Autogenerate the OAS? Something else? That?s the evidence you should upload to Pactflow.

matt.fellows
2022-08-16 12:08
If you don?t have confidence the provider is compatible with the OAS, then you?re leaving yourself open to production issues.

cyrus.devnomad
2022-08-16 12:25
Well in the workshop I mentioned above we have the following two steps: 2. Generate the dll for the project, this is the binary file that would be deployed to an environment. This step generates the Swagger doc for the project, which will be uploaded to Pactflow. Run the following command in the terminal on the root of the project: make publish_dll 3. Use Schemathesis to verify that the API endpoints match the generated Swagger doc by running the verify_swagger target. This will generate a a Schemathesis report documenting the compatibility of the endpoints with the Swagger doc make verify_swagger I imagined that the step number 2 automatically generates the swagger.json from the API. In that case I imagined that the confidence that the API matches the swagger.json would be quite strong. If thats indeed the case, would the step 3 be really necessary? Is is about having the HTTP communication really tested? Or am I missing something here!

matt.fellows
2022-08-16 13:03
There is always the chance 2 isn?t a perfect representation of things. Particularly with respect to the behaviour where discriminators such as `anyOf`, `oneOf` etc. are concerned. So (3) is usually a good thing to balance that out

matt.fellows
2022-08-16 13:04
There is of course also the possibility of bugs or e.g. an unimplemented controller that still generates a resource in an OAS - that could give you a false sense of confidence

matt.fellows
2022-08-16 13:05
But to answer your question, if schemathesis gives you the confidence of correctness, and you generate your OAS from working code that should probably be enough. You can upload whatever you want as the report - ultimately, it?ll be future you (or a consumer) that reads that report if things break. so making it useful/readible is probably in your best interest anyway

cyrus.devnomad
2022-08-16 13:11
Thank you for your explanation and clarification, that makes a lot more sense now.

lnthai2002
2022-08-16 15:02
has joined #general

lnthai2002
2022-08-16 15:21
Hello, I am new to pact so when experimenting with versioning, I see that when I run a provider validation, it seems to only validate against the latest pact found in the broker. Is this the expected behavior? In this matrix, there are 2 versions of the consumer (different content of pact files), but 3 versions of the provider. There is no verification result of the *green* version of the provider against the *blue* version of the consumer. However, when i run can-i-deploy on the *green* version of the provider supplying the *blue* version of the consumer as pacticipant, I get a failure, is it right?

sarunas.kavaliauskas
2022-08-16 19:15
has joined #general

hazem
2022-08-16 19:24
Question about webhooks for consumer/provider pipelines. TLDR: in thread :slightly_smiling_face:

hazem
2022-08-16 19:24
We're following https://docs.pact.io/pact_nirvana/step_6 and have implemented a consumer PR pipeline with two webhooks: ? Webhook 1 - Trigger provider verification for event `contract_requiring_verification_published` ? Webhook 2 - Update Consumer's PR build status for the commit with the verification results using event `provider verification published` Another sequence diagram documented https://docs.pact.io/pact_broker/webhooks#example-cicd-and-webhook-configuration. This all works great! However, the intent of webhook 2 is really meant for consumer PR builds and I noticed an undesired side-effect. In the case of Provider CI's, a provider feature branch failed verification due to a breaking change on the provider branch. This was great and awesome it was detected on the provider CI and PR. However, webhook 2 fired as a result of the published verification from the provider feature branch against the consumer main branch. Ultimately this updated consumer's main branch commit with a failed build status and alerted the consuming team via their own slack notification. Ultimately we decided it was a false alarm. Do others experience the same? Considering webhook 2 is meant purely for consumer's CI, it would be nice for webhooks to have conditions.

matt.fellows
2022-08-17 02:11
The answer lies in how you use https://docs.pact.io/selectors in your verification, and the flags you pass to can-i-deploy

matt.fellows
2022-08-17 02:16
Great question, thanks for taking the time to explain it in detail

ben.a.hubbard
2022-08-17 09:33
Are there any metrics that can be pulled (or visualised over time) from the open-source pact broker or pactflow. Like, the pass rate of integrations or number of integrations over time? (Not necessarily these but just in general)

matt.fellows
2022-08-17 09:36
Good question. May I ask why

matt.fellows
2022-08-17 09:37
(I'd love to know more for some use cases in PF I'm exploring)

matt.fellows
2022-08-17 09:39
But if you hit the /metrics endpoint there is data there you could pull daily into e.g. splunk/sumo and visualise

sushant.soni
2022-08-17 09:49
Can a provider application upgrade to Pact V3 independently of the consumers? is it backward compatible?

ben.a.hubbard
2022-08-17 09:52
Thanks, that looks pretty good! Was just for a high level view of trends and progress of adding new integrations etc

ben.a.hubbard
2022-08-17 09:54
But would also be good if we were given enough info to try and catch bad habits early. Like if there are problem providers (for bi-directional etc) who just keep trying to publish breaking changes. So we could investigate why and if they aren't following api evolution from the start (or something similar). If they constantly run into contract verification failures when trying to deploy it could slow down development as they need to go back to redesign/implement/test etc

ben.a.hubbard
2022-08-17 09:58
I guess that would need finer detail than existing metrics as it's currently all grouped under "verificationResults", if you could pull them by team or by pacticipant that could be interesting

ben.a.hubbard
2022-08-17 10:00
Also if you could distinguish integrations by type (CDCT or BDCT)

matt.fellows
2022-08-17 10:01
Yes that should work

matt.fellows
2022-08-17 10:01
JS?

tbansal
2022-08-17 10:30
has joined #general

sushant.soni
2022-08-17 13:28
provider - js consumer - js, jvm, swift

dekkofilms
2022-08-17 21:14
has joined #general

prateekm33
2022-08-17 22:41
so looks like we already have tooling in place in our automated pipelines to handle disallowing breaking schema changes. i think that addresses the concerns above

tjones
2022-08-17 23:33
Does your tooling test that each side understands the same semantics? Most of the time this is the issue with graphql

tjones
2022-08-17 23:36
> seems like the graphql schema can be a good enough proxy My experience is that people assume they don't need contract tests because of graphql tooling, and then they have issues in prod because the tooling couldn't detect the issues.

tjones
2022-08-17 23:42
Of course, you can use what you like. You don't even need to test at all, as tests are only risk reduction. However, doing contract testing (whether or not you use pact) is more than just "is this change a breaking change to the schema". For example, just because an update is backwards compatible it doesn't mean that a non-updated provider is compatible with an updated consumer.

tjones
2022-08-17 23:44
Can you tell me more about your setup? If there is tooling that provides proper deployment confidence for GraphQL, I'm very keen to hear about it.

matt.fellows
2022-08-18 01:23
Awesome, thanks for sharing

matt.fellows
2022-08-18 01:25
Yes we've been thinking about a lot of these at various levels (e.g. at the account, team, integration and app level)

matt.fellows
2022-08-18 01:26
Trying to work out what exactly will be helpful in providing actionable feedback. E.g. as you say, if there are broken integrations can we infer if that's a problem, or if it's because the feature is in development (i.e. TDD for APIs).

matt.fellows
2022-08-18 01:27
Broken webhooks might be useful for admins to keep up maintenance Particularly interested in who is interested in seeing the data and who might end up being on the receiving end of any insights (.e.g Devs, testers, management etc) and why it's important they get it. We do get asked a bit about reporting, but ideally we don't just share vanity metrics that look good but aren't actually very useful. I think seeing trendline activity is helpful, because you can get a sense if teams are increasing, maintaining or decreasing their investment in the tool

matt.fellows
2022-08-18 01:31
I'll share some more thoughts when I get back to my desk

bethskurrie
2022-08-18 07:18
See this guide for the best practice https://docs.pact.io/provider/recommended_configuration

bethskurrie
2022-08-18 07:20
It?s worth updating your quick link to this page now @matt.fellows


nirajlalr
2022-08-18 09:46
has joined #general

sushant.soni
2022-08-18 10:49
our api responses are usually very big and when running provider verification for multiple consumers we have large logs even with `error` logLevel. How to make it manageable and to be able to debug from those? maybe a flag to not show the actual responses but just the error and differences. or any other tips?

bethskurrie
2022-08-18 10:50
which language+version?

sushant.soni
2022-08-18 10:51
pact-js `@pact-foundation/pact": "^9.16.4`

bethskurrie
2022-08-18 10:51
I?ll need someone to let me know if that?s a ruby backed one or a rust backed one.

bethskurrie
2022-08-18 10:51
@matt.fellows will know.

jon669
2022-08-18 11:14
has joined #general

matt.fellows
2022-08-18 11:31
Ruby

gibraltor999
2022-08-18 15:58
quick question: I have this pact file with the contents. This file is in my local machine path: `/Users/srentala/Desktop/Pact/pacts` ```{ "consumer": { "name": "test-consumer" }, "provider": { "name": "test-provider" }, "interactions": [ { "description": "a request to get the machine IP", "providerState": "a endpoint to get IP", "request": { "method": "GET", "path": "/product" }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=utf-8" }, "body": { "ip": "81.96.249.131" }, "matchingRules": { "$.headers.Content-Type": { "match": "regex", "regex": "^application\\/json" }, "$.body": { "match": "type" } } } } ], "metadata": { "pactSpecification": { "version": "2.0.0" } } }``` I am running the following command to create a mock server using Pact : `pact-mock-service --consumer test-consumer --provider test-provider --port 1234 --pact-dir=/Users/srentala/Desktop/Pact/pacts` but on hitting the endpoint from Postman, it gives following ?no interactions found? . What am I missing here?

yousafn
2022-08-18 17:13
The pact-mock-service is documented here https://github.com/pact-foundation/pact-mock_service#mock-service-usage The option you are specifying is where the pact mock service will write generated pacts. ``` -d, [--pact-dir=PACT_DIR] # Directory to which the pacts will be written``` If you are trying to load a pact file, to generate as a stub, you can use https://github.com/pact-foundation/pact-mock_service#stub-service-usage

yousafn
2022-08-18 17:14
Here is an example of a usage of the pact-mock-service https://github.com/pact-foundation/pact-mock_service/blob/master/script/example.sh You would need to load your interactions in via HTTP requests

alejandro.velez
2022-08-18 19:20
Hello! We are beginning to incorporate `record-deployment` as part of our CI/CD process. If a provider version (git sha) was never required to verify a pact should we still use `record-deployment` when deploying that version of the provider? We are only using consumer driven contract testing, and leverage the `contract_requiring_verification_published` event so the consumer in some cases never triggers a provider build because the content is the same. Should we be leveraging `create-or-update-version` first in this case?

michael.birchmeier
2022-08-18 19:27
has joined #general

yousafn
2022-08-18 20:14
Hey hey, If I understand the contract for the latest provider version you want to deploy is pre verified because the contract between its consumers hasn?t changed. If so I would record the deployment of the sha associated with your provider build you are going to deploy. The verifications will still be valid and you are know in your pact broker exactly which provider version is deployed in production

alejandro.velez
2022-08-18 20:17
yes exactly Yousaf. We thought that would be ok, but we received an error ? something like -> `<Pacticipant> version <git sha> not found` when running `record-deployment`

yousafn
2022-08-18 20:18
Interesting, did the provider build run it?s own pact verification against the deployed consumers and publish a result?

yousafn
2022-08-18 20:19
With the version that you want to record?

yousafn
2022-08-18 20:20
I am assuming you have two provider verification tasks, one as part of the providers regular build and one triggered by the webhook you described which would use a pactUrl rather than the consumerVersionSelectors?

alejandro.velez
2022-08-18 20:23
no it did not. we only have one provider build by itself to verify a specific pact when a consumer published a pact that requires verification. Do you think we need to add the additional provider build?

yousafn
2022-08-18 20:30
Yes, if you consumer contracts do not change, but your provider build changes it's response schema or endpoints, you would not know that it was not compatible with its consumers

alejandro.velez
2022-08-18 20:31
ok that makes sense! thank you!

yousafn
2022-08-18 20:32
This recommended step refers to the one you already have in place https://docs.pact.io/pact_nirvana/step_6#add-a-new-provider-verification-job Your verification pipeline during a regular provider CI run would look similar to https://docs.pact.io/pact_nirvana/step_4#provider-pipeline although we advise recording environments over tags now, it is on my backlog to update the guide

yousafn
2022-08-18 20:33
My pleasure @alejandro.velez let us know how you get on, and if you want a platform to talk about your setup and how it's helping out your organisation, I would be happy to help. Good luck on the road to Pact Nirvana :rockon:

jwang
2022-08-18 21:07
has joined #general

msiyaj1
2022-08-18 22:03
has joined #general

matt.fellows
2022-08-18 22:12
yes, you want the stub server

matt.fellows
2022-08-18 22:12
You should probably also use the new recommended one here: https://docs.pact.io/implementation_guides/cli

ben.hansen
2022-08-19 00:44
has joined #general

marko.justinek
2022-08-19 02:37
PactSwift supports v3.

matt.fellows
2022-08-19 02:42
The verifier supports up to v4 Sushant, so you should be good no matter which client you use

sushant.soni
2022-08-19 08:22
Hey :wave: Any solution/advise for me here on the problem?

lottie.kett
2022-08-19 12:08
has joined #general

bethskurrie
2022-08-19 12:55
There's no way to turn off the noise, but do you know how to run just one test at a time?

bethskurrie
2022-08-19 12:56
You run the test with the PACT_DESCRIPTION and PACT_PROVIDER_STATE env cars set.

sushant.soni
2022-08-19 14:05
Hello Team, What is the general notion while setting up provider states? For example - "A user John Doe with bank account exists", here should we actually create a user and link a bank account? Or is it possible to mock this behaviour?

paul.lynn
2022-08-19 14:18
has joined #general

matt.fellows
2022-08-19 14:54
Either is fine. If it's a db state you could seed the data. If it's a service layer you can mock it out. The important thing is the system is setup to receive and respond to the request and the key layers that are responsible for sending back the shape of the data are tested

matt.fellows
2022-08-19 14:55
Some choose to mock from the controller down. Some choose to test all the way to the boundary. Neither is right or wrong, but is contest dependent. I'd say start with mocking the data layer if that's convenient tho, as you'll get some additional functional test coverage as a nice side effect

tjones
2022-08-19 15:12
I strongly prefer mocking the repository layer in your provider. The rationale is: ? If you mock at the controller layer, you get no functional coverage. Pact is not about functional testing, but if you mock at the controller layer, all you know is that your provider can possibly marshal that response, not that it will. ? If you create the data directly in the DB, you have to express the state in terms of DB data, which means that you then need a contract test between the provider state data and the actual data that is saved in the DB ? If you create the data in the DB by calling endpoints / service methods in your provider, then it?s hard to know what went wrong when the tests fail ? If you mock the repository layer in your service, you can express the provider state in terms of business logic - eg `A user John Doe with bank account exists -> when { userRepo.get('John Doe') } willReturn johnUserData`

duynguyenptithcm
2022-08-20 07:22
has joined #general

duynguyenptithcm
2022-08-20 08:03
Hi all, I'm newbie. Please, reference me some course or document about pact to contract testing...thank you

tjones
2022-08-20 09:22
Certainly. You can find what you?re looking for here: https://docs.pact.io

matt.fellows
2022-08-20 09:48
Howtolearn

2022-08-20 09:48
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

matt.fellows
2022-08-20 09:48
How about these?

duynguyenptithcm
2022-08-20 12:02
thank you all, how to implement pact with java?

matt.fellows
2022-08-20 13:20
With all due respect, did you read any of those links? One of them literally has 2 workshops for Java

matt.fellows
2022-08-20 13:21
The Pactflow page has an in browser tutorial in java and there are numerous examples there also in Java

matt.fellows
2022-08-20 13:21
Howtoexamples


gaudenz.halter
2022-08-22 07:52
has joined #general

lottie.kett
2022-08-22 10:07
Hi all, Could you please clarify how can I fix Network Error on the http://localhost:3000/error? When I run 'npm start' in the cloned 'example-consumer' repo, I receive the error I repeat as on the video https://www.youtube.com/watch?v=6Qd-kq1AzZI

matt.fellows
2022-08-22 10:10
:wave: You need to run the `example-provider` if you want to run the app. But you don?t need that if you just want to run the pact tests


lottie.kett
2022-08-22 10:14
Thanks

harold.robson
2022-08-22 13:07
has joined #general

bentzion.schochet
2022-08-22 13:27
has joined #general

mat.delong
2022-08-22 14:03
has joined #general

sushant.soni
2022-08-22 15:12
Thanks for the answer both. That makes sense. But I'm trying to figure out how it would work with shared environments. For example - for unit tests the mocking is easy as it is being done in isolation. But with a shared environment (staging), other users would be affected if we mock our responses to particular http requests. :thinking_face: Or is my understanding still incorrect here? :disappointed:

jean.paiva42
2022-08-22 16:49
Sorry for the VERY LATE reply here, but you were right Matt, we should adjust it on ourside, which we did. Thanks again for the reply!

gibraltor999
2022-08-22 16:53
Thanks @yousafn and @matt.fellows

matt.fellows
2022-08-22 22:03
The answer is you don?t use a shared environment

matt.fellows
2022-08-22 22:04
> For example - for unit tests the mocking is easy as it is being done in isolation. exactly - this is why it?s preferable!

matt.fellows
2022-08-22 22:04
> But with a shared environment (staging), other users would be affected if we mock our responses to particular http requests. exactly - it?s one of the reasons it is _not_ preferable to do it this way!

lottie.kett
2022-08-23 09:02
Hi all, Could you please help me how to fix this error? I have executed 'npm run test' in the 'example-provider repo'. But I have error at the Pact Verification ? validates the expectations of ProductService. Please see the screenshot attached. The error is ' Must provide the pactUrls argument if no pactBrokerUrl provided'. I have thus pactBrokerUrl mentioned at PACT_BROKER_BASE_URL: https://zlata.pactflow.io in .github/workflows/ -build.yml -verify_changed_pact.yml

matt.fellows
2022-08-23 09:05
Looks pretty clear to me. How do you know the environment variable is properly set?

lottie.kett
2022-08-23 09:09
Hi @matt.fellows, I have entered echo %PACT_BROKER_BASE_URL% in terminal and the value wasn't returted. Could you please clarify, if I should paste this value in all the files mentioned in the error or there is another way?

matt.fellows
2022-08-23 09:14
Sorry off the top of my head I can't remember how to export an environment variable in all windows shells.

matt.fellows
2022-08-23 09:15
But that seems to be the issue, you'll need to properly set the URL and token. You can out them straight into the verifier opts (see the available types in your IDE or look at the docs on what ones are there)

lottie.kett
2022-08-23 09:16
Thanks, Matt :slightly_smiling_face:

gibraltor999
2022-08-23 10:30
@yousafn @matt.fellows I have successfully created a mock service as explained in the documentation. However I was wondering if we have a way to just create pacts directly from the interactions?s json(without actual doing registering of pacts, hitting the endpoint etc etc..) ? I have interactions with me ? all I want is to generate pacts using a single command? Can we do that?

volker.wengert
2022-08-23 10:59
has joined #general

matt.fellows
2022-08-23 11:20
What are you trying to do? Can you just create a pact file in advance and send to a stub server?

alejandro.velez
2022-08-23 13:32
Hello! quick question, is there a way to debug why the `contract_requiring_verification_published` event was detected when publishing a pact? the pact content is not changing and I believe we are populating all the required fields. I also see this message beside it `(pact content is the same as previous versions with tags and no new tags were applied)`

yousafn
2022-08-23 13:54
Hey hey, Do you have an existing verification against your mainBranch Taken from https://docs.pact.io/blog/2021/10/11/contract-requiring-verification-published-webhook-event#post-content > It will be triggered if a pact is published with content that does not have a verification result from the main branch of the provider, or any of the deployed or released versions of the provider. Full usage details https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event It is worth paying attention to the `Use of this webhook requires that:` section just to ensure you have the necessary pre-requisites in place

gibraltor999
2022-08-23 13:54
So If I have an agreed interactions.json file, can I not create pact out of it directly?


yousafn
2022-08-23 13:55
No, as the Pact framework seeks to assure strong guarantees in the generated pact consumer contract file, that the client actually issued those requests, prior to serialising into a pact file. What is your particular use case?

yousafn
2022-08-23 13:56
You could transform your interactions file into a pact file, and validate the output against the v2 schema https://bitbucket.org/atlassian/pact-json-schema/src/master/schemas/v2/schema.json to ensure you are generating a valid pact 2.0.0 specification file

sushant.soni
2022-08-23 14:57
Perfect, thank you so much. This clears up a lot :slightly_smiling_face:

alejandro.velez
2022-08-23 15:29
ah I see I will try that! thanks Yousaf!

lnthai2002
2022-08-23 17:20
thank you guys

alejandro.velez
2022-08-23 17:25
after recording a verification against the main branch now I only see `contract_published` thanks again!

yousafn
2022-08-23 17:28
Nice one @alejandro.velez :raised_hands: - Thanks for letting us know

rubemfsv15
2022-08-23 17:44
Hello! I saw in the pact docs FAQ a topic about points with Swagger, and it said to contact one of the maintainers if you are interested in doing something like generate a Skeleton Pact test code from a Swagger document. Do you already have something thought about this? Who can I contact about it?

sathish.sundararajan
2022-08-23 19:32
has joined #general

pedroefajardo_pactio
2022-08-23 21:15
Hello All, I have some questions. I am working on setting contract tests for a GraphQL service (provider) using Pact. The provider is a Ruby on Rails app, the consumer is JavaScript. The JS version of Pact was wrappers for creating GraphQL interactions but the Ruby version does not. 1. For the provider (Ruby) do I create state handlers that return the correct GraphQL. where the objects are loaded from say a file or 2. Do I have to: ? Have the actual provider running; and ? Have to seed the DB with the data elements the tests need Item 2 above being more complicated I am guessing the answer is implement the provider verification as in item 1 above, is that correct?

yousafn
2022-08-23 21:44
Hey @rubemfsv15 , Welcome! Very cool idea, it?s been on want list for many a moon. First off I?d start with some terminology. OpenAPI, is formerly known as Swagger, with Swagger now referring to tools used to interact with Open API Documents/Specs referring to the document in yaml or Json. I?m curious but unsure of the intristic value, in the real world. I know that swagger-codegen will allow for generation of both servers and client sdk?s. The client sdk?s actually having at least stub tests in place for a unit testing framework. It isn?t too much uplift to scaffold a basic pact test, in which the consumer could then record their expectations when they decide what they want to consumer on a particular providers endpoint, or remove anything they don?t wish to consume. I wonder how many people use the codegens, and how well they help over time as a service evolves, and you have had to augment the initial generated client code. Both myself and @tjones have discussed vscode snippets for each of the pact languages so it if easy to create the boilerplate for an interaction in any given language. I hacked out how we could incorporate consumer expectations into an openAPI spec and generate consumer contract files ( pacts ) off the back of it. These could be replaced by the real expectation in the future, when the consumer code is created. I think @matt.fellows would also be interested in this conversation. Love to hear your thoughts and what you?ve got up to so far, if anything :)

tjones
2022-08-23 22:52
When I started with pact, this is something that I wanted. However, it?s worth pointing out that: ? the point of pact is not to describe the whole api, but to describe only the parts that the consumer is using. So, if you did pact-from-swagger, it would probably describe too much and you would lose some of the advantages of pact. There would be some use cases for people who create the swagger for exactly one client, but over time as the api changes think it would produce unnecessary maintenance of dead code ? A disadvantage of swagger is that it doesn?t have clear mapping between requests and responses (and there are a few other challenges generating examples from swagger), so I?m not sure how this would work. Of course, just because I can?t see how it would work doesn?t mean it doesn?t work

bethskurrie
2022-08-24 00:53
I meant your quick link matt.

bethskurrie
2022-08-24 00:53
Selectors are used in multiple places.

matt.fellows
2022-08-24 01:50
Sorry, what?s the quick link?

bethskurrie
2022-08-24 01:50
Your slack short help shortcuts

bethskurrie
2022-08-24 01:51
maybe you didn?t have one for the selectors.

bethskurrie
2022-08-24 01:52
yeah, that wasn?t what I meant. ```commit 3206c823c6446665ebd27df4cea722e7d6a4a9ef Author: Matt Fellows <matt.fellows@onegeek.com.au> Date: Thu Aug 18 17:41:23 2022 +1000 chore: update redirect for /selectors```

matt.fellows
2022-08-24 01:52
Yep :100:. The main use case and supporting argument for this is to reduce boilerplate code and really nothing else. The risk runs the other way of course (now you might over specify requests etc. and the above context may get lost, which is something that needs careful consideration - documentation will not solve that problem)

bethskurrie
2022-08-24 01:53
I meant, instead of sending people to /selectors for this topic, send them to https://docs.pact.io/provider/recommended_configuration

matt.fellows
2022-08-24 01:55
Doesn?t look like we have one. If you do want to add/create them, you can just go here: https://pact-foundation.slack.com/customize/slackbot

matt.fellows
2022-08-24 02:01
If you did (1), how would you be confident your GraphQL provider actually works?

matt.fellows
2022-08-24 02:01
The point of provider verification isn?t to make Pact tests pass, but to ensure your provider actually works

matt.fellows
2022-08-24 02:01
(so the answer is 2)

patrick.lu
2022-08-24 02:12
has joined #general

pedroefajardo_pactio
2022-08-24 02:26
> The point of provider verification isn?t to make Pact tests pass, but to ensure your provider actually works Exactly! and thank you for replying. After saying the approach should be (1.) got me thinking what?s the point of having hard-coded responses? What if the schema changes and developers fail to update the hard-coded responses? Then will you please explain what?s the use of state handlers (provider states)? Do the state handlers query the db for the data that was seeded just for the tests? How do we link a state handler for say ?state 1? with the query that returns the values in the db for ?state 1??


krishna.cv
2022-08-24 04:38
has joined #general

pedroefajardo_pactio
2022-08-24 04:50
i have also have read https://docs.pact.io/implementation_guides/ruby/provider_states and https://docs.pact.io/getting_started/provider_states#:~:text=Provider%20states%20allow%20you%20to,matches%20what%20the%20consumer%20expects and https://github.com/pact-foundation/pact-provider-verifier#api-with-provider-states it is finally coming into focus! (I think) The expected provider state will be passed to the provider via the/from the Pact file that the consumer created. The endpoint to create the data, tries to create the data and return an error if it doesn?t recognize the state or even if it recognizes it but the ?shape? of the request does not match the current schema in the db of what Pact is passing.

matt.fellows
2022-08-24 05:24
It needn?t be writing to a DB, but that?s an option for sure


matt.fellows
2022-08-24 05:25
The idea is that your consumer can signal to your provider somehow that it needs to be in a given state, for a test to work. Just like the `given` in your TDD tests, just at an API testing level. The given represents some arbitrary, abstract state. How you get into that state is up to your provider (implementation detail)

ravishankar.emc
2022-08-24 06:00
has joined #general

alan.zhu
2022-08-24 08:54
has joined #general

pedroefajardo_pactio
2022-08-24 13:58
this is great info. thank you

nabil.bourenane
2022-08-24 14:19
has joined #general

alan.zhu
2022-08-25 02:07
Hi, team:wave: we are using pact contract test and many of our consumers are developed by Perl, is there any official support on Perl language?

matt.fellows
2022-08-25 02:18
:scream:

matt.fellows
2022-08-25 02:18
I mean, no we don?t sorry


alan.zhu
2022-08-25 02:47
Thanks for reply, that really help, I saw the example by https://github.com/pact-foundation/pact-mock_service/blob/master/script/consumer-interaction.json and I have a question: Is there a way to generate looser match rules by something like DSL in this solution ?

matt.fellows
2022-08-25 04:03
Sorry this isn?t ideal, but you can. When you send requests to the mock service to setup the interaction, values that need matching rules can be given specific JSON objects that contain the matching rule definitions. See https://github.com/pact-foundation/pact-js/blob/9.x.x/src/dsl/matchers.ts for the matching rules available (and how to serialise them) properly

tjones
2022-08-25 04:42
What you could maybe do is write your tests in one of the supported languages (eg JS), and then have a call out to a perl script that just invokes the relevant bit of your client code

tjones
2022-08-25 04:42
whether that is a good idea or not depends on the rest of your ecosystem

ami.ta
2022-08-25 06:05
has joined #general

ami.ta
2022-08-25 06:07
Hi.. the 5 min tutorial defined in https://docs.pact.io/5-minute-getting-started-guide. hangs on the ?Repl Waking up? ? phase Who can help ?

matt.fellows
2022-08-25 06:17
hmmm I?ve found they can be unreliable. I know ad blockers / firewall can also interfere if you have those

matt.fellows
2022-08-25 06:18
We have some killercoda tutorials here that are similar: https://docs.pactflow.io/docs/tutorials/

me1001
2022-08-25 07:24
has joined #general

me1001
2022-08-25 07:30
Hi. I managed to convince my team to give http://Pact.io a shot. We have a GraphQL provider, and multiple consumers, but focusing on a single one right now. We are working using git flow - feature branches, develop branch that we merge FB to, and then master branch for production-ready code. We have introduced can-i-deploy on develop/master branches, that checks against current environment (`staging` for develop branch, and `production` for master branch). We have noticed a potential obstacle: ? have a query `User{fullname}`, ? lets assume we want to change that query to return firstName, lastName our initial thought was: ? lets change the provider to return `{firstName, lastName, fullName}` ? then we are able to make changes in the consumer, and deploy to `staging` ? then we are able to remove the redundant & unused `fullName` from the provider, and deploy to `staging` that would work okay for develop branch, but then if code gets merged to `master`, we wouldn't be able to deploy provider (as the currently deployed `production` consumer still _requires_ `fullName` to be passed) and in such case, we are unsure how to proceed.

me1001
2022-08-25 07:32
Consulting a friend led to another idea: feature toggles. We would be able to pass a consumer version to the backend and because of that, backend could select which implementation should be used. However, that seems like a commitment on backend team's side to always ensure every query is supported when breaking changes occur. And I don't think we like that idea.

me1001
2022-08-25 07:32
So how do we deal with existing interaction changes?

me1001
2022-08-25 07:34
(just to be clear: the first post's idea would work if we DIDN'T remove redundant attribute in the `develop` branch. Then, we would still be able to push to master and deploy code to production. However, i'm worried about cases where developers _will_ forget that this `fullName` is still required on the currently-deployed production consumer, and thus it will lead to git chaos because we would have to revert some just merged commits in order to get back to a point where the redundant attribute is not yet removed, deploy, and then remove.)

tjones
2022-08-25 07:42
Are you failing the build on a failed verification, or on a failed can-i-deploy?

tjones
2022-08-25 07:43
Pact prevents you deploying a breaking combination of consumer and provider

tjones
2022-08-25 07:44
so, you need to have a path to deployment that is never breaking - for a "breaking change" this means deploying either a consumer that can speak to both providers, or a provider that can speak to both consumers.

tjones
2022-08-25 07:45
it's worth noting that, whatever your branching strategy, pact just exposes this problem. You would have the same problem without pact, it just wouldn't block deployment.

me1001
2022-08-25 07:52
Yes, correct. This is not a pact problem, but more of a "let's make sure what is live, never breaks" :slightly_smiling_face:

me1001
2022-08-25 07:52
I'm just trying to find an optimal solution to this. We would be failing on a failed verification on the provider side, and also can-i-deploy on consumer side.

tjones
2022-08-25 07:54
You might find it helpful to not fail if verification fails, but to fail only during can-i-deploy

me1001
2022-08-25 07:54
Yeah, we have enabled pending contracts in feature branches.

me1001
2022-08-25 07:55
But overall I guess the real question is: how do you develop without ever breaking the path to deployment? How do we ensure developers do not forget of the production installments, and the fact that they can't just change interactions?

me1001
2022-08-25 07:56
I guess just backend has to be ready to serve both ways? Or we should create new queries (that reflect new interactions) on the consumers side?

nidzgorskiadrian
2022-08-25 08:05
has joined #general

thomas.shipley
2022-08-25 09:41
*Free Hands-on Training Tonight (6:30 pm BST) - Pact Consumer Driven Contract Testing* Hi Testers :wave: - this evening Grace Tree and I will be hosting the DevOps Playground Meetup in Manchester, UK and Online. After a short consumer-driven contract testing talk, we will be diving right into a hands-on lab. There is no need to install anything locally; it is set up and ready to go in the cloud :cloud:. You will get a terminal; a hosted Visual Studio Code editor, and guidance on using Pact through a pre-designed scenario. If you fancy it, here is the link to sign up: https://www.meetup.com/devopsplayground/events/287778275/

alan.zhu
2022-08-25 09:50
Thanks, that make sense. Do we have a plan to implement pact features in Perl ?

matt.fellows
2022-08-25 09:52
What tool are you looking to run for the workshop?

thomas.shipley
2022-08-25 10:08
The one and only Pact .NET! With the pact broker. It is very loosely based on the workshop I wrote years ago now. Mixed in with the latest one published by yourselves. https://github.com/DevOpsPlayground/Hands-on-With-PactNET Grace has done the bulk of the work (and I great job) I am presenting at the start really/helping. https://bit.ly/2QcXY08 - I just need to get the slides in the brand format... a task for today!

matt.fellows
2022-08-25 10:09
Nice! What's the environment you're providing for the participants to run it?

thomas.shipley
2022-08-25 10:30
I am not directly involved with the ops bit. But the high level is a series of docker containers hosted on a cloud platform. There is a web-based front door in which attendees put in their name they get their own unique env with all the docker images prebuilt and ready to go. As a result, they get auto-generated credentials and a browser-based shell and browser-based Visual Studio Code instance with all the code and directory structures setup. The two are linked to each other. Use the terminal to run commands and the VS Code tab to make code changes. At the end of the session the instances are torn down.

matt.fellows
2022-08-25 10:34
Sounds great, hope it goes well - I wish you?d let us know earlier, we?d no doubt have given you a bit of a shout elsewhere. If it is something you do again, please do reach out so we can spread the word

matt.fellows
2022-08-25 10:34
Also those cloud labs sound nice - I?d be interested to seeing if that is something we could replicate for our community at large?

thomas.shipley
2022-08-25 10:46
Ah yeah sorry - our marketing team have been on the ball... but I haven't!

thomas.shipley
2022-08-25 10:46
Yeah, we could potentially do something together - maybe a co-branded thing. I can ask around internally if you like?

yousafn
2022-08-25 11:18
Hey @thomas.shipley this sounds great. I am actually based in Leeds, and spent my early career in Manchester so still know loads of people in the tech scene there. If you are running events in the future, let me know and we can shout about it in our socials :thumbsup: Will stick out a call to arms today

dealandi
2022-08-25 11:50
has joined #general

jreynolds
2022-08-25 12:44
has joined #general

jreynolds
2022-08-25 12:51
Dang! this sounds slick as all get out! And it's my birthday! Which also means I probably won't attend this evening but Dev Ops Playground looks really cool. Sorry to miss it!

josh.steffensmeier
2022-08-25 13:18
has joined #general

thomas.shipley
2022-08-25 13:40
Appreciate it @yousafn :slightly_smiling_face: - many things delayed me from putting the word out. I shall let you know next time! And if you ever fancied doing something with DevOps Playground I am sure we could work something out :thumbsup: Thanks, @jreynolds - lots of effort is put in by the team. All the kit has been shipped down from London to run online. I just do the easy bit and talk for 20 mins :wink:

prateekm33
2022-08-25 14:41
hi! sorry for the late turnaround on this. we?re looking at https://www.graphql-inspector.com/

tjones
2022-08-25 14:54
Thanks! I?ll take a look

abubics
2022-08-26 00:37
I think the only option is to keep the compatibility window open on both sides, until it's safe to remove the old functionality. https://docs.pact.io/faq#how-can-i-make-a-breaking-change-to-a-provider Hopefully the lead time to release isn't too long, so it's not a hassle to support both versions.

abubics
2022-08-26 00:37
It's also customary to check can-i-deploy for both the feature branch and the main branch in CI, pre-merge

abubics
2022-08-26 00:37
if main is ahead of prod, then check against prod, too

mhtkandpal10
2022-08-26 11:29
has joined #general

yousafn
2022-08-26 13:31
Happy Friday everyone :woo: The August edition of the Pact Open Source Update is out now https://docs.pact.io/blog/2022/08/24/pact-open-source-update-august-2022 We are focusing on Pact-JS v3 and the people that made it happen, thank you so much and have an amazing weekend :sunglasses:! https://user-images.githubusercontent.com/53900/180370118-f11c61f3-4ae0-496f-98fa-052fdfad409e.gif

dwalleck
2022-08-26 20:51
has joined #general

lijinze01
2022-08-26 22:20
has joined #general

mhaller
2022-08-27 00:19
has joined #general

mvliannoi
2022-08-29 03:41
has joined #general

duynguyenptithcm
2022-08-29 04:49
How to test graphql ?

duynguyenptithcm
2022-08-29 04:49
Which libraries is best?


tjones
2022-08-29 04:54
I quite like the central library in Christchurch. They have very comfortable chairs.

tjones
2022-08-29 05:45
In general, though, you want to use the library that matches the language and framework that your client is written in

duynguyenptithcm
2022-08-29 05:50
Thank you

haobei.ma
2022-08-29 06:06
has joined #general

tjones
2022-08-29 07:28
You're welcome. In general, it's much better to ask specific questions rather than general questions - otherwise you'll give the impression that you haven't read the documentation. If you have read the documentation and are still confused, it's good to let us know what you read. That way the documentation can be improved.

maram.elsayed
2022-08-29 08:52
has joined #general

siddharth.gupta
2022-08-29 09:16
Hi , I have an array in response . The structure of array elements is different from one another . Not able to write expected body match of consumer test and it is giving error " No best type found for implicitly typed array " : Following is the response [2:45 PM] "extension": [ { "url": "http://xyz.com/fhir/v1/StructureDefinition/schedulable", "valueBoolean": true }, { "url": "http://xyz.com/fhir/v1/StructureDefinition/serviceOrganization", "valueReference": { "reference": "Organization/Organization-Dept-1", "display": "myDepartment" } } ] [2:46 PM] How do i verify an array having different structure of elements

matt.fellows
2022-08-29 10:05
For anyone responding, see the original post and subsequent responses here: https://pact-foundation.slack.com/archives/C9UTHV2AD/p1661764550843779

helloitsdave
2022-08-29 14:51
has joined #general

mberkowitz
2022-08-29 16:16
has joined #general

lnthai2002
2022-08-29 18:42
Hello, if my provider has 2 endpoints (*/products* and */statistic*) and i have 2 consumers 1/*online-store* that uses the */products* end point, 2/*analytic-service* that uses */statistic* end point can both consumer pact tests have the same provider name? Would the pact files generated by the consumer tests get combined when uploaded to pact broker or one will replace the other?

matt.bremer
2022-08-29 20:10
has joined #general

matt.fellows
2022-08-29 21:32
Yea you should use the same provider name. The pacts aren't combined as we need to track each consumer and provider separately, but this is how it's supposed to work

lnthai2002
2022-08-29 21:50
thank you for confirming

tjones
2022-08-30 00:00
We should make a documentation page that explains this. It's kiiind of inferred on the versioning in the pact broker page here https://docs.pact.io/getting_started/versioning_in_the_pact_broker , but it would be good to have a diagram that just talks about consumer / provider names and their relationship to pact

lennart.querter
2022-08-30 09:24
has joined #general

apapia
2022-08-30 14:25
Does anyone have experience performing can-i-deploy checks and recording deployments using Kubernetes / Helm? I wondering if it makes sense to use Helm hooks for these steps. Has anyone had success with that?

thanuxxxx
2022-08-30 14:54
Regarding to the `pactbroker.providerBranch` or tag I still need some clarification. When I do this in Jenkins, what is the value I should assign to that variable? `GIT_BRANCH` or `GIT_MAIN_BRANCH.` From my understanding, the reason we are setting a value here because only that provider branch is eligible for pending pact feature. Is that right?

veaceslav.gaidarji
2022-08-30 15:29
has joined #general

sharonw
2022-08-30 15:29
has joined #general

grace.quek
2022-08-30 15:32
has joined #general

s.kadium1
2022-08-30 16:12
has joined #general

s.kadium1
2022-08-30 16:15
Hi, I'm facing the below issue while publishing the pact json : ```Publishing 'ppe-service-bus-issue-compilation-ppe-service-ent-issue-compilation.json' ... FAILED! 409 Conflict - {"error":"Cannot change the content of the pact for ppe-service-bus-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning"}``` I'm not sure why it is failing and the same json file is getting verified when the run the provider from my local machine pointing to the json file. Any idea?

s.kadium1
2022-08-30 17:04
I have tried to invoke the endpoint that publishes the contract with a similar body mentioned below and got a response: ```{ "pacticipantName": "Foo", "pacticipantVersionNumber": "dc5eb529230038a4673b8c971395bd2922d8b240", "branch": "main", "tags": ["main"], "buildUrl": "https://ci/builds/1234", "contracts": [ { "consumerName": "Foo", "providerName": "Bar", "specification": "pact", "contentType": "application/json", "content": "<base64 encoded JSON pact>" } ] }``` Response: ```{ "notices": [ { "type": "error", "text": "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning" }, { "type": "info", "text": "" } ], "errors": { "contracts": [ "Cannot change the content of the pact for ppe-service-ent-issue-compilation version 1.0.0 and provider ppe-service-ent-issue-compilation, as race conditions will cause unreliable results for can-i-deploy. Each pact must be published with a unique consumer version number. For more information see https://docs.pact.io/go/versioning" ] } }``` I dont see any difference in the content that is causing this issue

matt.fellows
2022-08-30 22:01
The error in the output is quite clear. You need to use a unique version each time you publish a pact

matt.fellows
2022-08-30 22:01
Otherwise you can invalidate previous results

matt.fellows
2022-08-30 22:22
see also https://docs.pact.io/pact_broker/advanced_topics/troubleshooting#409-when-publishing-a-pact. Also, please avoid cross posting unless there is a reason the community would benefit from it. A lot of the maintainers are based in different timezones, and will help you if/when they can.

sumanta.roy
2022-08-31 01:33
has joined #general

shuying.lin
2022-08-31 05:45
has joined #general

victor.lopez
2022-08-31 10:08
has joined #general

nfinley
2022-08-31 15:52
has joined #general

hartror
2022-09-01 06:26
has joined #general

uralsmh
2022-09-01 10:37
has joined #general

uralsmh
2022-09-01 10:38
Hi, Can we use pact for integration tests with mocking rather using mock-server ?

matt.fellows
2022-09-01 11:24
With Pact, you must use the mock server. It?s an important part of how the framework captures the contract.

matt.fellows
2022-09-01 11:24
If you want a slightly more decoupled approach, you can consider something like our BDCT approach: https://docs.pactflow.io/docs/bi-directional-contract-testing There are differences in the value/guarantees they provide, the link above discusses some of these trade offs.

krystof.sykora
2022-09-01 12:34
has joined #general

matt.fellows
2022-09-01 13:18
:arrow_up: *Level up your testing game with Full Stack Testing Academy* Are you hunting for contract testing training materials for you and your team? Our friend @pietrucha.bartosz ? the founder of Fullstack Testing Academy ? covers this in his course, including launching a new Pactflow module. The course starts on *October 6th, 2022.* Our Developer :avocado: @yousafn has personally completed the course and has given it the :thumbsup:. It covers all you need to know about full-stack web application testing and automation. We think it will be helpful for many teams in improving their test quality, knowing how and when to employ test automation at what level, and using tools in their appropriate context. From unit, integration, E2E tests, and automation to CI/CD and contract testing, everything is in one place. @pietrucha.bartosz is generously providing our community with a ?50 discount. Use the code `PACT_FLOW_50` to secure your spot. Sign up :point_right: <https://pactflow.us4.list-manage.com/track/click?u=d975bc32fd84ad3580ed4777e&id=1581d47252&e=f3a6913421 |here>. The course will teach you: ? the good practices of unit, integration, and e2e testing and learn how to implement them in front-end and back-end ? How to test the architecture from different perspectives like dependencies and abstraction layers ? The importance of setting up different quality gates in the project securing its long-term success ? How to establish an automation mindset to free your time to do the ?real work? and monitor quality metrics provided by different tools The course is delivered via 1-2 hours of dense video content, with assignments after each module to put into practice what you learned. In includes lifetime access to on-demand video lessons, as well as ten weeks of support on Slack and via Zoom. If you have any questions, I?m sure @pietrucha.bartosz will be happy to to field them.

pietrucha.bartosz
2022-09-01 14:15
Thanks for the heads-up @matt.fellows :wave::skin-tone-3: Feel free to join the 10-week journey :tada:

lesa
2022-09-01 14:34
has joined #general

gunesmes
2022-09-01 15:31
has joined #general

uralsmh
2022-09-01 15:55
@matt.fellows actually i am looking for some alternatives for mock-server

rubemfsv15
2022-09-01 18:45
Thank you all for the contribution, it was enlightening. I'm maturing the idea, and when I have something more concrete I'll get back in touch!

matt.fellows
2022-09-01 23:12
What's your goal?

uralsmh
2022-09-02 09:19
Remove the dependencies and mock the response

matt.fellows
2022-09-02 09:21
That's what Pact does.

matt.fellows
2022-09-02 09:22
If you want to use your own mocks, that's where bidirectional comes in. You can use your own locking tools and convert to a consumer contract

uralsmh
2022-09-02 09:25
I never used Pact but is it ok to do this with Pact as well, right ?

uralsmh
2022-09-02 09:25
Cause its not a contract testing to be honest its more integration test

matt.fellows
2022-09-02 09:26
No, you must use the mocker server with pact to generate a contract. Once you've done that we can provide a stub server you can use to remove dependencies

matt.fellows
2022-09-02 09:26
It's not a general purpose mocking tool

uralsmh
2022-09-02 09:26
So should I use mock-server in any case ?

matt.fellows
2022-09-02 09:30
Just so I'm clear, what exactly are you proposing

uralsmh
2022-09-02 09:30
Mocking response and isolate service from other dependencies

matt.fellows
2022-09-02 09:30
Ok. Will you be using one of the pact languages?

uralsmh
2022-09-02 09:31
You mean smth like pact-js ?

matt.fellows
2022-09-02 09:38
Yeah

uralsmh
2022-09-02 09:38
yeap..

uralsmh
2022-09-02 09:39
When I check this documentation seems mock server is possible but I guess I need to use stub server as well https://github.com/pact-foundation/pact-js

uralsmh
2022-09-02 09:39
So the things confused me do I still need to use mock-server(https://www.mock-server.com/) or can I achive samething with pact

mvliannoi
2022-09-02 09:47
Hello! I have three questions about the global Pact conception. 1. Please, tell me, should I separate pact files demands on provider features? For example, I have an API for the Task Manager application and implemented API by feature architecture on the C# language. Such as TaskCrud (CRUD operations on tasks), TaskFilter (filtering tasks) etc. And SPA React application, where I write contact tests. So my question is, should I have a single pact file (e.g. `task-api-consumer-task-api-provider.json`) for checking responses to all features from the provider side or better split generating pact files depending on provider features (e.g. `task-api-consumer-task-api-provider-crud.json` and `task-api-consumer-task-api-provider-filter.json`) and after that writing two verification test methods on the provider side for each coming pact files? 2. Where should I save the pact file path? Is reading from a configuration file (such as launchSettings.json) for a test project better than C# constant? 3. If a consumer has many providers, which algorithm is better to use if I need to publish one pact file to a specific provider? Depend on the pact file prefix, or save the pact file in a particular folder during generation on the consumer side on passing tests? Thanks, Maksym

matt.fellows
2022-09-02 09:48
Once you've created a pact you can use the stub server a bit like http://mock-server.com. but it's not a general purpose mocking tool, so you'll need to see how far it gets you

matt.fellows
2022-09-02 09:49
Remember it's goal is creating contracts, and ensuring your mocks don't drift from reality

uralsmh
2022-09-02 10:02
Is delays, erroneous situations etc possible with Pact?

matt.fellows
2022-09-02 10:19
I've responded in #pact-net

matt.fellows
2022-09-02 10:20
No non functional tests like delays, but 4xx and 5xx yes

alanwallaceross
2022-09-02 16:27
has joined #general

wdridi1
2022-09-02 18:59
has joined #general

daviseago
2022-09-03 02:16
has joined #general

daviseago
2022-09-03 02:22
:wave: Hi everyone! I?m quite interested in contract test. Our system has two parts: one is on cloud, the other is on edge. They communicate via MQTT (over websocket). How can this be contract tested? Will pact help in this case?

tjones
2022-09-03 06:56
Yes, you can use message pacts for this. It's not quite as end-to-end as an http pact, but it still brings a substantial improvement to deployment confidence.


daviseago
2022-09-03 11:20
Thanks Timothy!

mvliannoi
2022-09-05 22:14
Hello! I feel a bit confused about using provider states. Even after reading https://docs.pact.io/provider/using_provider_states_effectively, seeing examples of test applications on the web and trying to find https://pact-foundation.slack.com/archives/C5F4KFKR8/p1660921939235489?thread_ts=1660917914810099&cid=C5F4KFKR8 about that - even after that, it is tough to consolidate naming and describe a little algorithm of his naming. So, as I can see, if we are mocking the repository layer (or even the business service layer that is directly referenced to the repository layer) - we should set a human-readable provider state. For example, for Task Manager API and test `GET` and `POST` methods, we should name the provider states as `Task with existing ID is available` and `Task with the correct body is created`. But, how should we call the provider state of checking _unauthorized_ scenarios or _bad requests_ (with invalid request body)? And which name of the provider state is better in the point of view of Pact best practices, the first one or `post-task-success` and `get-task-success`?

abubics
2022-09-06 00:59
I would definitely tend towards human readable, and describe a state that the provider can represent before a request is made. ? "Task with existing ID is available" sounds ok, although "existing ID" is hard for me to understand, but it might be very meaningful for your domain. ? "Task with the correct body is created" sounds more like an outcome or action, rather than a declarative state. If you take it from a ReST perspective, it might be easier to think about. You want to say "my provider is in this state, so when my consumer asks it to perform an action, my intended outcome will be achieved". The same state could be useful for several actions. A `POST` may only need a parent resource to exist beforehand, so that's all you need to specify. The same state may work for a `GET` or `DELETE` of the parent, too.

abubics
2022-09-06 01:08
For an unauthorised scenario, it should be enough to say "there are no users", or "there are no sessions", or "an unauthorised user". However you want to phrase the concept (that the provider can represent) that means any incoming request will be rejected.

abubics
2022-09-06 01:08
For bad requests, you don't even need a provider state. The request should be rejected at the front door (e.g. controller layer) before any domain logic is even applied.

abubics
2022-09-06 01:10
Or, if the bad request is invalid for domain reasons, rather than structural reasons, then it'll be something like a joining resource is missing, or something isn't in the right state (e.g. a date is too early/late, or a transaction is in the wrong phase, etc).

tjones
2022-09-06 01:47
Also, you probably don't need bad requests in your pact. Pact tests are consumer driven - which means they cover the interactions that the consumer will actually send.

tjones
2022-09-06 01:48
You might need unauthorised scenarios because an authentication token might expire, and so your consumer will want to handle this - but unless your consumer is expected to sometimes send bad requests, you don't need this in your pact

hsanghavi538
2022-09-06 02:33
has joined #general

mvliannoi
2022-09-06 06:43
It seems a bit more challenging than I imagined. So, I created a diagram of your answers. Can you please check if it is correct? Also, I want to ask, should we provide a separate state when we cannot find the object by id? @matt.fellows Matt, please, can I ask you for an additional answer to this question?

matt.fellows
2022-09-06 06:45
I agree with the comments from Andras and Tim

mvliannoi
2022-09-06 06:48
Thanks, Matt!

abubics
2022-09-06 06:51
I'd be interested to know what kind of invalid input you expect your API client to produce. That might remove a third of your cases, which can also be caught be Pact.

matt.fellows
2022-09-06 06:52
One thing to consider is whether or not you want to test all of the authorization errors per endpoint, or just a representative sample on a key endpoint (usually, auth is universally applied so I?d tend to only run these once, and not across the entire set of API endpoints)

abubics
2022-09-06 06:53
Also, it would be surprising if all the endpoints handle auth by themselves, so the general "unauthorised" contract should be the same test, regardless of endpoint. Depends on your auth model, but I usually don't duplicate it for every endpoint/verb combination.

abubics
2022-09-06 06:54
great minds? :stuck_out_tongue:

matt.fellows
2022-09-06 06:55
If your client code is designed so that you can?t send a bad request, that might be hard to test properly. You can still of course have a scenario somewhere that can deal in a generic `4xx` or `5xx` error (auth errors probably warrants a separate error handling to validation or system outages). That can probably be done outside of Pact though, because it might be hard to produce a `5xx` on the provider side

abubics
2022-09-06 06:56
The "bad request" response should still be handled, but probably in provider-level (functional?) tests, rather than contract tests. I.e. you want it to respond appropriately if a new consumer makes bad requests (e.g. `curl`)

mvliannoi
2022-09-06 06:59
Authorization sets on an entire controller, so I cannot imagine how we can test it once. Only if check it for GET method, and delete from every endpoint, for example

mvliannoi
2022-09-06 06:59
For example, for tasks/{id} - if id is string-value, we cannot accept null and should return bad request with validation errors object

abubics
2022-09-06 07:03
Can your consumer actually send a request like that, though? An ID like that usually (at least, in my code) comes from the provider, and is sent back without modification (optionally parsed into a strong type, too).

abubics
2022-09-06 07:04
What kind of auth do you have per controller? Is it, like, granular claims per endpoint, or something?

tjones
2022-09-06 07:05
Pact is not about testing that your API behaves as specified, it's about testing that your API behaves as the client actually uses it

abubics
2022-09-06 07:06
oh yeah, that might be the missing piece :pray:

tjones
2022-09-06 07:08
So you don't need to cover cases that your client doesn't send

tjones
2022-09-06 07:09
If you want to cover something other than what the client sends, then you might want a different tool for that, or you could use pact with a fake consumer

mvliannoi
2022-09-06 07:18
So, is that conclusion correct? ? We should cover only each case that client sends to our provider; ? Check unauthorized responses only once per endpoint (e.g. for GET method); ? Give names to provider states as generic as we can, but complete them as human-readable as possible; ? Cover with Pact case for bad request, where expect a validation error object from a provider - is okay

tjones
2022-09-06 07:28
> We should cover only each case that client sends to our provider; Yes, and all response types (eg both 404 and 200 for `GET /some/item`) > Check unauthorized responses only once per endpoint (e.g. for GET method); Yes, usually - generally you need one response type per client behaviour. For example, if your client treats all 401s the same, then you don't need tests for invalid token vs expired token, etc. But, if the server responds with a reason that prompts the user differently (ie, if the client relies on a specific field value eg `reason: "expired_token"` to switch some behaviour), then you'll want a test for each response > Give names to provider states as generic as we can, but complete them as human-readable as possible; Yes > Cover with Pact case for bad request, where expect a validation error object from a provider - is okay Yes. Examples might include `username: " "`, which maybe the user can enter, might return `400: {reason: "Your username must not contain spaces" }`, or maybe `username: "bob"` -> `{reason: "Your username is too short" }` In a case like that, if the behaviour is "show the reason to the user", then you don't need to test each reason that the provider might reject a username, you just check that the response is `400 { reason: <string> }`

tjones
2022-09-06 07:29
> Give names to provider states as generic as we can, but complete them as human-readable as possible; To add to this, keeping the pact states consistent across multiple consumers for the same provider can be annoying - but pact is not a substitute for team to team communication (I'm afraid :sweat_smile:)

tjones
2022-09-06 07:34
If you want to read more on the last point about functional tests vs contract tests, this page is pretty helpful: https://docs.pact.io/consumer/contract_tests_not_functional_tests

mvliannoi
2022-09-06 07:41
Great, everything is understood but requires a lot of practice. Thank you very much @tjones @abubics @matt.fellows!

tjones
2022-09-06 07:42
Awesome! Feel free to ask more questions when/if you have them

thibaut.bodart
2022-09-06 10:41
has joined #general

bastien.decroix
2022-09-06 11:45
has joined #general

pabcagi
2022-09-06 12:28
has joined #general

patrickbadley
2022-09-06 13:25
has joined #general

james.grubb
2022-09-06 19:19
has joined #general

snehasingh291506
2022-09-06 19:42
has joined #general

snehasingh291506
2022-09-06 19:46
Hello! I wanted some clarification because I'm a bit confused. I have read in the doc that Pact supports several languages, but I just want to make sure that I can write the provider-side verification in goLang and use typescript for the consumer-side.

senchu.pampoorickal
2022-09-06 20:15
has joined #general

matt.fellows
2022-09-06 22:56
Yes, assuming the consumer is a typescript app and the provider is a Golang one

nagasrinivas.thota
2022-09-07 06:56
has joined #general

mahinsyeda99
2022-09-07 09:40
has joined #general

sashaavramchik
2022-09-07 13:19
Hi there! Could someone explain me what's the point of using 'Environment' in pactflow? I thought it's replacement for tags but seems like I'm wrong

snehasingh291506
2022-09-07 13:28
Getting the below error while running pact test in the consumer side... i might be doing something really stupid but just can't figure out what... ```'use strict' process.env.REACT_APP_ENGINE_SERVICE_URL = 'http://localhost:8992' import { expect } from 'chai' import path from 'path' import { Pact } from '@pact-foundation/pact' import { fetchACEFields } from '../api/index' describe('fetch ACE fields', () => { const port = 8992 const objectType = 'dummy' const provider = new Pact({ port: port, log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), dir: path.resolve(process.cwd(), 'pacts'), spec: 2, consumer: 'webapp', provider: 'engine-service', pactfileWriteMode: 'merge', }) const expectedBody = { status: true, data: [{ fullName: 'dummy' }] } before(() => provider.setup()) after(() => provider.finalize()) afterEach(() => provider.verify()) describe('request to fetch fields', () => { before(done => { const interaction = { state: 'fetch ace fields', uponReceiving: 'a request to get all ace fields', withRequest: { method: 'GET' as const, path: `/ace-fields?object_type=${objectType}`, headers: { Accept: 'application/json', }, }, willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json', }, body: expectedBody, }, } provider.addInteraction(interaction).then(() => { done() }) }) it('verify it returns the correct response', async () => { const res = await fetchACEFields(objectType) expect(res).equal(expectedBody) }) }) }) Error: ReferenceError: navigator is not defined at Object.<anonymous> (/Users/snehasingh/Documents/webapp/node_modules/flags/node_modules/supports-color/browser.js:3:58) at Module._compile (internal/modules/cjs/loader.js:1068:30) at Module._extensions..js (internal/modules/cjs/loader.js:1097:10) at Object.require.extensions.<computed> [as .js] (/Users/snehasingh/Documents/webapp/node_modules/ts-node/src/index.ts:1445:43) ```

matt.fellows
2022-09-07 13:34
It looks like something needs a web runtime but you're running in a node environment?

snehasingh291506
2022-09-07 13:49
Okay, so I believe that my tsconfig.json file may be to blame since I'm attempting to run a front-end test with backend configuration. That could be it?? @matt.fellows

lisnychyis
2022-09-07 14:00
has joined #general

marek.czerwinski
2022-09-07 16:07
has joined #general

matt.fellows
2022-09-08 00:59
could be

matt.fellows
2022-09-08 01:00
It doesn?t look like a Pact issue though. Remove all of the pact bits and see if you get the same issue - then you?ll know

xiaofeng02111
2022-09-08 03:20
has joined #general

alan.zhu
2022-09-08 04:15
Hi team I try to do timestamp check in LambdaDSL?is there a proper way to do accurate timestamp check in LambdaDSL?For now I only do a looser type check? ```.object("updatedAt", updatedAt -> updatedAt .integerType("epochSeconds",1661307606)```

uglyog
2022-09-08 04:27
If it's an integer value, there is not much else you can do

matt.fellows
2022-09-08 04:49
Hi all! :wave: Next week I?ll be speaking at API Days in Melbourne, on the challenges of testing modern, multi-protocol microservices at scale. The talk is titled: ?Schemas are not contracts! Why contract testing matters in the age of gRPC, Kafka and GraphQL? I have 10 free in-person tickets to give away for the conference (worth about $800 AUD). If you are keen in attending, use the promo code IKNOWMATTFELLOWS , https://www.apidays.global/australia?utm_source=IKNOWMATTFELLOWS&utm_campaign=SC (and drop me a DM). No strings attached, please feel free to share to anyone who might benefit from a great conference. You can also register for free online access Hope to see you there :slightly_smiling_face:

abubics
2022-09-08 05:38
`IKNOWMATTFELLOWS` namedrop for free tix lol :joy:

jayvdb
2022-09-08 06:22
has joined #general

snehasingh291506
2022-09-08 07:36
Any idea what is causing this: ```'use strict' process.env.REACT_APP_ENGINE_SERVICE_URL = 'http://localhost:8992' import path from 'path' import { Pact } from '@pact-foundation/pact' import { fetchACEFields } from '../api/index' const port = 8992 const objectType = 'dummy' const provider = new Pact({ port: port, log: path.resolve(process.cwd(), 'logs', 'mockserver-integration.log'), dir: path.resolve(process.cwd(), 'pacts'), spec: 2, consumer: 'webapp', provider: 'engine-service', pactfileWriteMode: 'merge', }) describe('fetch ACE fields', () => { const expectedBody = { status: true, data: [{ fullName: 'dummy' }] } beforeAll(async () => { await provider.setup(); }); describe('request to fetch ACE fields', () => { beforeAll(async () => { await provider.addInteraction({ state: 'fetch ace fields', uponReceiving: 'a request to get all ace fields', withRequest: { method: 'GET', path: `/ace-fields?object_type=${objectType}`, headers: { Accept: 'application/json', }, }, willRespondWith: { status: 200, headers: { 'Content-Type': 'application/json', }, body: expectedBody, }, }); }); test('verify it returns the correct response', async () => { const res = await fetchACEFields(objectType) expect(res).toBe(expectedBody) }) }) })```

matt.fellows
2022-09-08 08:10
It looks like a CORS problem. I?d suggest running this in a node environment, or usinsg the `cors` flag (also this looks to be a JS question, could you please add future JS questions in #pact-js?)

matt.fellows
2022-09-08 08:13
I did see a recent cors issue in the Pact JS repo, so it might be related.

yousafn
2022-09-08 12:04
:wave: Hey all, hope you are doing well. I?ve just created a new Slack channel called #blogs where you can post, or see links to Pact/Pactflow and Contract testing related posts. If you have any posts you want to share, feel free to pop them in. If you post about contract testing, let me know. I think I would like to build up an RSS feed for contract testing related posts, similar to https://www.ministryoftesting.com/feeds/blogs Also thank you to @anja.gruss for the first post to go live in #blogs, why not hope over and check it out

snehasingh291506
2022-09-08 12:10
when i run it in node env i get navigator not defined error..

vvarunbajpai1988
2022-09-08 12:13
has joined #general

tjones
2022-09-08 12:26
What is your client using to send http requests?

tjones
2022-09-08 12:27
From the error, it looks like you're using xmlhttprequest objects (which is pretty unusual these days). For the best experience with pact, you'll want to run it in a node environment. To use xmlhttprequest in node, you'll want a shim like this: https://www.npmjs.com/package/xmlhttprequest

tjones
2022-09-08 12:28
(disclaimer: I have never used that library, I just found it now)

snehasingh291506
2022-09-08 12:48
we are using axios

tjones
2022-09-08 12:54
Axios will work in node, so that's not the problem. Something is using the navigator API, which doesn't exist outside the browser. It's not pact and it won't be axios

zakir
2022-09-08 12:55
has joined #general

tjones
2022-09-08 12:55
I would guess it is something in your code

gregory.hanson
2022-09-08 12:56
has joined #general

matt.fellows
2022-09-08 13:23
Are you running tests in Jasmine perhaps? I think axios will attempt to use the xmlhttprequest interface if not in a node environment

tjones
2022-09-08 14:03
The problem is that outside node, it's failing as expected - and inside node, it's failing with `navigator not defined`

ashishmerani
2022-09-08 21:54
has joined #general

ramesh.ambastha
2022-09-09 11:06
has joined #general

nickm
2022-09-12 17:15
has joined #general

uzma_khan
2022-09-12 18:13
has joined #general

danielflieger
2022-09-13 06:57
Hey community, thanks in advance for the support! Let?s assume a consumer application triggers a post call to a provider. Within the request of that call comes a request body in a json format. I wonder if the consumer should structure that request body with matchers just like he does with response body, or should he put a json-object for any reason? My suggestion is to use matcher for request body just like with the response body, but I?m not what?s best practice here. Thanks!

matt.fellows
2022-09-13 06:58
Usually you wouldn't, because the matchers on the request are only used in the consumer test

matt.fellows
2022-09-13 06:58
And hopefully it's a unit test, so you should be able to control the conditions and this be very specific

matt.fellows
2022-09-13 06:58
In some cases it's warranted but as a general rule I'd avoid it

matt.fellows
2022-09-13 06:59
The matchers aren't used outside of that scope so there's no additional benefits of them being there

danielflieger
2022-09-13 07:01
Thank you very much.

tjones
2022-09-13 07:08
Matt is completely correct. I'd add - the point of the matchers is just to relax the reliance on exact test data when verifying the provider. If you use any matchers at all, you are saying "I believe this test covers all messages that pass the matchers for this example"

stefan.tertan
2022-09-13 15:28
has joined #general

lnthai2002
2022-09-13 21:29
Hello, i wanna use the pactfoundation/pact-cli docker image to run my bash script to record deployment to pact broker as the last step of my CI/CD pipeline. Since we have quite a number of services deployed, my bash script need to loop over the deployed services and run "pact-broker record-deployment" for each. However, i soon realized that this docker image does not have bash and when i build a custom image from this image with bash installed, i got "NoMethodError - undefined method `request_uri' for #<URI::Generic ?>" when calling pact-broker. I suspect the ruby env is missing something when running from bash. Do you have a docker image built with bash instead of sh? if not, how do i fix this undefined method error?

tjones
2022-09-13 22:11
I don't know the answer to your questions, but I'm pretty sure that the CLI docker image will have bash, as I think the CLI needs it to run. Someone else can confirm

lnthai2002
2022-09-13 22:33
Thanks for the quick reply. As far as i can tell, the pact-cli image only has sh, not a fully functional bash so associated array is not supported. Anyway, i found the issue with my script on my customized image.

matt.fellows
2022-09-13 22:37
does the host that runs the image have bash? Why not just call the CLI docker multiple times?

lnthai2002
2022-09-13 22:50
my script is run in a kubernetes job as part of a helm chart that get installed after the deployment is done. I prefer to install this post deployment helm chart once to record all the services that have been deployed instead of installing this chart multiple time each for one service that was deployed.

mvliannoi
2022-09-14 01:59
Hello, guys! Could we continue our discussion about provider states with ideas from my colleagues? My colleagues propose to introduce the one _God state_ that sounds like ?`default`? and introduce something another; only if we need to change the response to the client from mocked domain service (repository layer). In ?_standard_? conditions, will we behave in the following situation: ? Verifying for HTTP 401 Unauthorized status code - will be done on the layer of Authorization middleware (C# language). So if the client does not send the Authorization header in his request - we regard that as ?`an unauthorised user`? scenario and respond with HTTP 401. So, the provider doesn't have any mocks of domain services in that case (or even if it has, for us, it doesn't matter), and we don't see sense in introducing another provider state. ? Verifying for HTTP 400 Bad Request - will be very similar to the first one, but in that case, a client should pass the Authorization header on his request, and we _automatically_ assign it to this user admin role. And if given other body doesn't meet controller / DTO validation - we expected this response from the provider. And even in this case, execution doesn't execute to mocked domain services - so we can say that it doesn't matter what is mocked on this layer during that verification on the provider side. ? Verifying for HTTP 200/201 Success/Created - but in this case, it is the most complicated because the main idea from my colleagues is if it a just positive case and we don't have any specific response to the client - mock all domain services that are using for verification on the provider side to himself all methods in positive cases. So, in conclusion, I need your help to answer the two main questions: Is that correct from the point of view of Pact conception and in theory, is that implementable on .NET with Moq library (will we not use only the last mock for each domain services, as I write before - because that will be a lot, for each domain service for all himself methods to mock positive scenarios)? Thanks

abubics
2022-09-14 02:29
I don't know much about the .NET ecosystem, so some of those questions might be better placed in #pact-net :sweat_smile:

abubics
2022-09-14 02:30
There are a few considerations I'd like to mention, but if your approach works for you, then I don't see why you shouldn't use it :slightly_smiling_face:

abubics
2022-09-14 02:31
401 isn't just for missing the header, but also for authenticated users trying to access resources that they don't have authorisation for. If that's not a use case for you, then that's fine.

abubics
2022-09-14 02:33
> _automatically_ assign it to this user admin role Might be fine, but if you have other roles you want to test, then consider being more explicit about it. Newer Pact versions support multiple states, and metadata in states, so you don't have to make unwieldy states.

abubics
2022-09-14 02:34
I prefer to make combinations of more granular states, to increase specificity of tests, and reduce the chance of accidental/coincidental passes.

mvliannoi
2022-09-14 02:57
Thank you, Andras! I understand; so, if that is correct from the point of view of global conception - it should be implemented just like that

abubics
2022-09-14 02:59
As very general advice, yes :slightly_smiling_face: I would just try it, and see what problems you end up with. Nothing is really perfect on the first attempt :innocent:

tjones
2022-09-14 04:24
Remember that Pact is not about describing the whole API, but just the parts your client needs. Usually you don't need to test 400 bad request, unless the client is expected to receive and understand that (eg some designs with validation might be done this way)

mvliannoi
2022-09-14 04:31
Yes, that's already clear to me after our previous discussion. Thank you, Timothy

tjones
2022-09-14 04:37
Ah, sorry. I didn't check which discussion was above :sweat_smile:

tjones
2022-09-14 05:12
FWIW: Yes, I usually end up with a default state, or several default states (one per use case). Something like "user with ID 10 exists who has task 1 open and task 2 closed". This isn't so much "best practice" as it doesn't provide any value other than convenience. However, it is definitely convenient.

tjones
2022-09-14 05:12
I believe pact specification version 3 allows multiple states, which might obviate the convenience provided by a default state.

tjones
2022-09-14 05:15
I'm not sure I fully understand what you're saying with the 400 example and the auto-assign an admin role. Are you saying that in the contract you have eg `Authorization: Bearer SOME_TOKEN` and you auto-assign permissions to `SOME_TOKEN`, so that they can access the endpoint? That sounds fine to me.

tjones
2022-09-14 05:17
That's a good example for the several defaults pattern - I would have `default authorized` where `SOME_TOKEN` is considered valid, and `default unathorized` where `SOME_TOKEN` is considered invalid.

tjones
2022-09-14 05:18
This would then cover @abubics?s example of an invalid token being provided. This is almost always a use case, as tokens almost always have an expiry date.

mvliannoi
2022-09-14 05:39
Andras has also written about newer Pact versions and multiple provider states. So that is definitely what I need to figure out. But, if we are talking about the default provider state, I mean the provider state with the name exactly `default`, not `"user with ID exists who has task 1 open and task 2 closed"`. Just `default`, without a shortcut or, better, an alias for getting a specific user. But, if we rethink that process, the default aligns only for fetching all users or getting one by id, so a provider state with a name default isn't enough. Instead, we should inject a new provider state with a different name (maybe as `"user with ID exists who has task 1 open and task 2 closed"`). If moved back to Authorization, so in our contact tests, we implemented him by adding additional middleware https://github.com/DiUS/pact-workshop-dotnet-core-v3/blob/master/Provider/tests/TestStartup.cs#L22, such like ```services.AddAuthentication(AuthenticationHandler.Schema) .AddScheme<AuthenticationSchemeOptions, AuthenticationHandler>(AuthenticationHandler.Schema, _ => { });``` and ```public sealed class AuthenticationHandler : AuthenticationHandler<AuthenticationSchemeOptions> { public const string Schema = "Test"; public AuthenticationHandler(IOptionsMonitor<AuthenticationSchemeOptions> options, ILoggerFactory logger, UrlEncoder encoder, ISystemClock clock) : base(options, logger, encoder, clock) { } protected override Task<AuthenticateResult> HandleAuthenticateAsync() { AuthenticateResult result; var authorizationHeader = Context.Request.Headers.Authorization; if (string.IsNullOrWhiteSpace(authorizationHeader)) { result = AuthenticateResult.Fail( new UnauthorizedAccessException("To access API, you must provide a Bearer token.")); return Task.FromResult(result); } var claims = new[] { new Claim(ClaimTypes.Name, "Test user"), new Claim(ClaimTypes.Role, "admin") }; var identity = new ClaimsIdentity(claims, Schema); var principal = new ClaimsPrincipal(identity); var ticket = new AuthenticationTicket(principal, Schema); result = AuthenticateResult.Success(ticket); return Task.FromResult(result); } }```

mvliannoi
2022-09-14 05:40
Nowadays, seem like that workshop is deprecated :sads:

tjones
2022-09-14 05:41
For me, I don't like the name `default` as it is ambiguous - I would confuse it with "the state that a blank provider would start in". But the concept of "this state actually covers most of the situations I want to test" is pretty helpful.

mvliannoi
2022-09-14 05:45
Agree. We should think about a name that says, "we mocked all domain services for all positive scenarios, that's also compatibly to test all 401 unauthorized and 400 bad request requests"

tjones
2022-09-14 05:45
This is where the granular states really help. With one state, you would go: ```state: "user with ID=10 exists who has task 1 open and task 2 closed" GET /users/10 returns {/* user 10 */}``` and ```state: "user with ID=10 exists who has task 1 open and task 2 closed" GET /users/10/tasks returns [{/* id=1, open */}, {/* id=2, closed */}]``` with granular states, you could say: ```state: ["user with ID=10 exists"] GET /users/10 returns {/* user 10 */}``` and ```state: ["user with ID=10 exists", "user 10 has task ID 1, which is open", "user 10 has task ID 2 which is closed"] GET /users/10/tasks returns [{/* id=1, open */}, {/* id=2, closed */}]``` this has clear advantages when you want to add new concepts (eg, "task 2 has comments from user 12")

tjones
2022-09-14 05:46
I would say what the state is, not what it is for

tjones
2022-09-14 05:47
eg `SOME_TOKEN is an invalid admin auth token` not `SOME_TOKEN returns 401`

mvliannoi
2022-09-14 05:49
Granular states look fantastic and don't confuse like just `default`

mvliannoi
2022-09-14 05:54
Regarding authorization, to verify the 401 status code in our contact tests, we should skip the header, so it's tempting to get something common state for that. But should we react on _provocation_ or make a separate state that sounds like `SOME_TOKEN is an invalid admin auth token`?

mvliannoi
2022-09-14 05:56
The same goes for a situation when we don't need to mock anything on the provider side (e.g. for bad request testing). How should we do that?

tjones
2022-09-14 06:04
I usually just don't provide any provider state in that case. What you're saying then is "it doesn't matter what state the provider is in, I expect request X to respond with Y"

tjones
2022-09-14 06:04
Apologies, I don't think I understood your 401 question

mvliannoi
2022-09-14 06:15
> I usually just don't provide any provider state in that case I am a bit surprised. Is that possible? > Apologies, I don't think I understood your 401 question Sorry, my guilt is related to the general difficulty of our enterprise system. It seems like we can just don't provide any provider state in that case, also if it's possible

tjones
2022-09-14 06:18
> Is that possible? Yep. The point of provider states is to set up some precondition. If you don't have any preconditions, you don't need to use them. If you prefer, a related pattern is to use empty states - like "there are no users", which you implement to do nothing during setup or teardown. This is a neat way to use the states as documentation.

mvliannoi
2022-09-14 06:24
Great, I understand. Can you also help me define the provider state for testing entity creation (POST method)? Something like `"user with ID=10 does not exist"` is a good one? Whereas, for other methods (GET, PUT and DELETE), we can adapt your granular states example

tjones
2022-09-14 06:33
> "user with ID=10 does not exist" This is exactly what I do.

tjones
2022-09-14 06:35
Note that Pact might run requests in any order, so the "no states" case should always be empty. Typically you do this by either: ? Implementing teardown for each state ? Implementing a blank state that resets the server

mvliannoi
2022-09-14 06:43
Sorry, I don't understand you completely. What does it mean to teardown for each state? As I understand, for the state that is representing no-state or, in other words, nothing preparing / mocking on the provider side - such as the "there are no users" state we should do nothing before pact verification of that test case. So, what does it mean to do a teardown or reset the server on such states? Can you please explain more?

tjones
2022-09-14 06:46
Apologies, I wasn't clear. Pact might verify the interactions in any order. So, if you have interactions with no state, you need to make sure that the interactions that _do_ have state are torn down. Eg: ```start server with mock repos that are empty "user 10 exists" setup - mock user repo layer so that user 10 exists teardown - replace mocked user repo layer with empty mock```

tjones
2022-09-14 06:47
alternatively, you can do: ```"user 10 exists" setup - mock user repo layer so that user 10 exists "there are no users" setup - mock user repo layer so that it is empty```

mvliannoi
2022-09-14 06:53
Perfect, everything is clear!

mvliannoi
2022-09-14 06:54
Thank you very much, Timothy! For giving me a ton of helpful information and allocating more than three of your hours :slightly_smiling_face:

konitzert
2022-09-14 07:11
has joined #general

tjones
2022-09-14 07:21
You're welcome!

matt.fellows
2022-09-14 12:09
interesting. Must you use associative arrays or could you achieve this using other ash primitives? I don?t expect us to want to add Bash to the image any time soon

matt.fellows
2022-09-14 12:10
It?s probably not out of the question, but would require some consideration (e.g. it would be a breaking change if others depended on it)

lnthai2002
2022-09-14 13:24
I am also looking for alternative to bash script, i noticed the pact-broker command is a ruby script. Perhaps i could write a ruby script that read the environment variables passed in to the docker container and then call the record-deployment function directly. However, my knowledge of ruby is limited, i would appreciate very much if you can point me how to call the record-deployment.

daniel.puiu
2022-09-14 13:43
has joined #general

edouard.lopez
2022-09-15 08:55
We are starting to explore gRPC as a replacement of HTTP REST in my company, some developers argues that contract testing isn't necessary anymore. What value does pact bring in such situation?

tjones
2022-09-15 09:23
Schemas are not contract tests

tjones
2022-09-15 09:26
I?ll let someone else take this one though

tjones
2022-09-15 09:26
Really the question is: why do they think it wouldn't bring value?

matt.fellows
2022-09-15 10:23
You should watch my talk on this, I literally spoke on it yesterday at API Days in Melbourne :laughing:



matt.fellows
2022-09-15 10:25
We do have a gRPC and Protobufs plugin (see #protobufs if you?re interested, but it is still in beta support as we iron things out) which should help. It doesn?t currently cover the forwards compatibility case where a provider adds a new required field. But we have some ideas on how to address that too

edouard.lopez
2022-09-15 12:06
@matt.fellows Thanks for the links. What' the title of your conf? seems it's not published yet

matt.fellows
2022-09-15 12:34
Yep should be up the next few days I hope. I'll publish when it is. It's "schemas are not contracts: why contract testing matters in the age of gRPC, Kafka and Graphql"


l.heluszko
2022-09-15 13:12
has joined #general

edouard.lopez
2022-09-15 16:00
I think you have a typo in the article:

alecat88
2022-09-16 10:25
has joined #general

matt.fellows
2022-09-16 11:45
Ah thanks, I'll look next week when back!

chris.armbrester
2022-09-16 11:45
has joined #general

zohaibse011
2022-09-16 13:28
has joined #general

nvenkataraman
2022-09-16 17:17
has joined #general

zach.davis
2022-09-16 20:18
has joined #general

jorbraken
2022-09-16 20:29
has joined #general

paulorochag
2022-09-16 20:50
Hello everyone, I translated the material to english, enjoy: https://github.com/PauloGoncalvesBH/contract-test-nirvana

paulorochag
2022-09-16 20:51
People, I created a repository demonstrating how it should be the implementation of webhook, pipeline and contract tests of Provider and Consumer applications in order to achieve what is considered Pact's Nirvana. The diagram in README.md can help group members understand the entire architecture of contract testing. https://github.com/PauloGoncalvesBH/contract-test-nirvana

zach.davis
2022-09-16 21:50
Hi, I must be missing something obvious and I'm guessing this has been asked and answered already, but I couldn't find anything specific which answers the following scenario. Using a git feature branch workflow and following the https://docs.pact.io/provider/recommended_configuration on the pact documentation: ``` consumer_version_selectors [ { main_branch: true }, { matching_branch: true }, { deployed_or_released: true } ] enable_pending true include_wip_pacts_since provider_branch == "main" ? "2020-01-01" : nil``` How is the following flow supposed to work? 1. feature B branch created from main branch 2. feature A branch created from main branch 3. feature A builds new API for consumer, satisfies new consumer pact 4. new consumer pact and feature A branch merged back to main 5. main branch verifies new pact, removes pending status 6. feature B runs through CI with the above consumer selectors We are seeing that on step 6, this now fails verification since the new pact was verified on main branch. This branch doesn't have the new api/provider state, so fails the pact. Is this expected?

paul.ologeh
2022-09-16 23:25
has joined #general

tien.xuan.vo
2022-09-19 01:55
Where is the doc for matchers formats located? I think I can't find it. I'm looking for something like this: ? v2: `"name": { "contents": "rover", "json_class": "Pact::SomethingLike" }, "type": { "data": { "generate": "bulldog", "matcher": { "json_class": "Regexp", "o": 0, "s": "bulldog|sheepdog" } }`https://docs.pact.io/slack/pact-message-ruby.html#1522380995.000036 ? v3: `{ value: 123, 'pact:matcher:type': 'type'}`https://github.com/pact-foundation/pact-js/blob/master/src/dsl/matchers.ts I think the `matchers` in https://github.com/pact-foundation/pact-specification/tree/version-2 and https://github.com/pact-foundation/pact-specification/tree/version-3 is something else different, not related, right? I can't find it here too https://docs.pact.io/getting_started/matching

uglyog
2022-09-19 02:06
Are you asking about the general format of matchers, or the specific fields for a given matcher? A lot is documentation at https://github.com/pact-foundation/pact-specification/tree/version-3, but I don't think the V2 format was properly documented

uglyog
2022-09-19 02:07
The V2 format you posted above is a Ruby specific encoding of Ruby classes to JSON

uglyog
2022-09-19 02:11
The V3 example is the integration JSON used between language implementations using Pact FFI

uglyog
2022-09-19 02:13
I don't think we have formally documented that format, but it is the same as what the V3 spec documents with the exception the type of the matcher is encoded in the `pact:matcher:type` attribute.

abubics
2022-09-19 02:39
From a more fundamental level, though, unless you're writing an implementation of a Pact lib, it should be fine for the JSON format to be opaque. Is that what you're doing? :thinking_face:

tien.xuan.vo
2022-09-19 02:46
Yes, I'm working on updating pact-php. I'm looking for doc that help me update this code https://github.com/pact-foundation/pact-php/blob/master/src/PhpPact/Consumer/Matcher/Matcher.php to this code https://github.com/pact-foundation/pact-js/blob/master/src/dsl/matchers.ts I can blindly follow pact-js. A doc about `pact:matcher:type` would be nice to have for me.

abubics
2022-09-19 02:46
ah ok, that makes sense, then :sunglasses:

uglyog
2022-09-19 03:06
Yeah, I need to document that format, it came out of the implementation of moving Pact-JS over to the FFI libs. Anyone else using the FFI libs will need to know how to construct those.

purushothamv02
2022-09-19 14:19
has joined #general

lcruz
2022-09-19 23:05
has joined #general

tjones
2022-09-20 05:34
> A doc about pact:matcher:type would be nice to have for me. I would *love* the documentation for this (and the overall pact file format in general). It would be great for building tooling that compares pact files, for instance

tjones
2022-09-20 05:35
For example, you could determine if your contract is a subset of another consumers contract

tjones
2022-09-20 05:36
provider teams could use this (along with their own pact tests) to provide provider contracts that you could verify consumer side: ? Provider writes pact using a mock client, and verifies it ? Consumer writes pact using their real client, and compares their outputted pact file to the verified pact. If it is a subset of the verified pact, you're good

sweiba
2022-09-20 07:26
has joined #general

adam910
2022-09-20 12:32
has joined #general

adam910
2022-09-20 12:44
Hi, I am trying to implement Pact as contract testing for our company. Currently I do not understand following: ? I have got working test on consumer service and verify on provider service ? when consumer service is built and `can-i-deploy` passes new contract is published to pact broker (this is in build pipeline) ? this publishes contract e.g. `consumer 1.0 & provider 1.0` ? when I deploy `consumer 1.1` this will publish contract `consumer 1.1 & provider 1.0` ? when I deploy `consumer 1.2` this will publish contract `consumer 1.2 & provider 1.0` now my question is if I deploy `provider 1.1` how do I publish new contract between consumer and provider? I guess in this case if we follow the above example if `provider 1.1` is deployed then contract between `consumer 1.2 & provider 1.1` should be published? how do I publish this new contract new consumer builds? or am I missing something?

owen.oclee.old
2022-09-20 13:59
Hi, is anyone using Pact to mock out and verify the responses from a document store like ElasticSearch? I have a use case where I?d like to avoid needing to have a running instance of ES when running automated tests locally, but still have the opportunity to verify the expectations are valid, and it seems like Pact might be good for this. Curious to know if this would be feasible and if anyone else has done this before?

p.pommerencke
2022-09-20 14:00
has joined #general

dekkofilms
2022-09-20 20:05
is it possible to watch a recording of this talk? @matt.fellows

anhtvuong
2022-09-21 01:39
has joined #general

abubics
2022-09-21 02:02
You don't get a new contract in that case, the new version of the provider just needs to verify against the same contract :party_parrot:

abubics
2022-09-21 02:03
It gets more fiddly if you need to also verify old contracts, but that's facilitated with version selectors.


abubics
2022-09-21 02:09
The rest of the answer is probably best in the form of some extra questions . . . ? Are you using an ElasticSearch client library? If so, you should probably just stub that. ? If you used Pact, would you also be running verifications against ES? ? ES has an https://www.elastic.co/guide/en/cloud/current/ec-openapi-specification.html, so could you get by with a generator for stubs?

timothee.ville
2022-09-21 08:09
has joined #general

matt.fellows
2022-09-21 11:15
I?d like to clarify the use of language here Adam, as it?s important: > when consumer service is built and can-i-deploy passes new contract is published to pact broker (this is in build pipeline) > this publishes contract e.g. consumer 1.0 & provider 1.0 Publishing should happen _before_ running `can-i-deploy` and deployment of code. You should publish on every build, and use https://docs.pact.io/pact_broker/branches and https://docs.pact.io/pact_broker/recording_deployments_and_releases to document what you are working on, and when you have deployed. You then use https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors on the provider side, to verify the appropriate contracts. > when I deploy consumer 1.1 this will publish contract consumer 1.1 & provider 1.0 See above. If you deploy a consumer 1.1 that should use the `record-deployment` command. This can only happen _after_ publishing of a contract > when I deploy consumer 1.2 this will publish contract consumer 1.2 & provider 1.0 as per above. > now my question is if I deploy provider 1.1 how do I publish new contract between consumer and provider? > I guess in this case if we follow the above example if provider 1.1 is deployed then contract between consumer 1.2 & provider 1.1 should be published? how do I publish this new contract new consumer builds? or am I missing something? No, you don?t. The contract is published from the consumer always. The provider verifies the contracts. If there is a new version, you just push the code and let it verify any existing contracts. I?d recommend https://docs.pact.io/pact_nirvana and the https://docs.pact.io/implementation_guides/workshops#pact-workshops---from-0-to-pact-in-2-hours

matt.fellows
2022-09-21 11:18
The videos don?t look like they?re https://www.youtube.com/c/apidays. I?ll let y?all know when they are :slightly_smiling_face:

dekkofilms
2022-09-21 11:39
Awesome, thanks for keeping us posted! Would very much enjoy to hear your talk specifically and learn more :slightly_smiling_face:

tymoschuk.jane
2022-09-21 12:38
has joined #general

tony.nguyen
2022-09-21 13:41
has joined #general

sashi.kandru
2022-09-21 13:45
has joined #general

khaled.bali
2022-09-21 18:01
has joined #general

m.mertens
2022-09-21 18:41
has joined #general

mforsman
2022-09-22 09:13
has joined #general

shivendra.singh1
2022-09-22 10:04
has joined #general

vaibhav.tiwari
2022-09-22 10:04
has joined #general

akshaythakur2905
2022-09-22 10:06
has joined #general

sukriti.kumari
2022-09-22 10:07
has joined #general

p.kowalska
2022-09-22 10:35
has joined #general

mazin.inaad
2022-09-22 13:21
has joined #general

mazin.inaad
2022-09-22 13:34
Hi all, I am looking into implementing contract testing within a new project. The thing is: we are developing our api's using a contract first approach. And the contracts themselves are part of a separate git repo. I'm looking for any documentation or examples of such projects so that we can determine how we could implement contract testing on this project. If anyone has any tips, please let me know :slightly_smiling_face:

tjones
2022-09-22 16:05
What?s in your contract files?

tjones
2022-09-22 16:05
I would say Pact *is* contact-first. As in, the consumer defines the contract

varnit.garg2424
2022-09-23 08:32
Hello! I need some advise. Let?s say there are two services A and B connected using http and protobuf A -> *monolithic* legacy service which is written in `Ruby` (*Consumer*) B -> *microservice* which is written in `GoLang` (*Producer*) Do I need to use `pact-ruby` and `pact-go` on consumer and producer side respectively? Is there anything in addition I should before introducing the pact contract tests?

matt.fellows
2022-09-23 08:37
If you mean OAS, it's an orthogonal concept to pact. You can use them in parallel but you can't use them to drive pact tests.

matt.fellows
2022-09-23 08:41
One option is to combine Pact (to prevent breaking changes and help safely evolve the ecosystem) and/or use tools like Pactflows bidirectional contract testing (supports OAS) or the https://www.npmjs.com/package/@pactflow/swagger-mock-validator tool to prevent for OAS from drifting from actual usage

megha.t
2022-09-23 09:13
Hi All, What are the best practices for provider versioning? Is it possible to make the versioning dynamic? I went through the docs that recommend appending the commit sha to the version but how do you decide whether it should be v1 or v2 dynamically or does the developer need to update the Provider version on each change to the provider? ref-https://docs.pact.io/getting_started/versioning_in_the_pact_broker Any help will be appreciated!

matt.fellows
2022-09-23 09:15
The version can be really whatever you want, but it definitely needs to be automated. Every single time you change the provider, the version should change. Hence why we recommend the SHA. It also needs to be able to be reproduced (e.g. when you run other commands). The version of the provider must therefore be stable

megha.t
2022-09-23 09:20
Thanks for the speedy response @matt.fellows So I am a bit unclear ...At present, when I verify a contract from the provider end, I manually enter the provider version, update it when it is a major change in the api. (Sample go code for the same) I was thinking of making this version dynamic but how to identify if the change is a major update eg:api update or a minor patch. FYI I am a newbie to pact ```_, err := pact.VerifyProvider( s.T(), types.VerifyRequest{ ProviderBaseURL: providerBaseURL, PactURLs: []string{"http://pactbroker-gamma.comp-tech.net:9292/pacts/provider/agent_template/consumer/gemini/latest"}, CustomProviderHeaders: []string{customHeader}, PublishVerificationResults: true, ProviderVersion: "1.0.0", BrokerUsername: brokerUsername, BrokerPassword: brokerPassword, }, )```

matt.fellows
2022-09-23 09:30
OK cool. This versioning is unrelated to Pact. It?s the version of your code. Some teams like to use versions like `x.y.z` (semver) but this is no use in Pact, because each version could map to different commits - some of which may or may not be compatible with other things. If you?re confused about what to put here, don?t overthink it - just put your git sha in there

matt.fellows
2022-09-23 09:30
At the top the TL;DR is what I?d follow: > To avoid race conditions, the application (pacticipant) version number that is used to publish pacts and verification results should either _be_ or _contain_ the commit (ie. the git SHA or equivalent for your version control system).

mastahfreak
2022-09-23 09:47
has joined #general


tjones
2022-09-23 11:26
^ I wrote this tool to solve this problem nicely

kellie.persson
2022-09-23 17:50
has joined #general

tjones
2022-09-25 14:12
I think your question is missing a verb, but it?s also a bit too general to help without more context

tjones
2022-09-25 14:13
you?ll have a better time with pact-ruby and pact-go on each side, but you don?t technically _need_ to

tjones
2022-09-25 14:14
Also it might depend on what you want to do with protobuf. The protobuf plugin isn?t release ready, I think

tjones
2022-09-25 14:15
#protobufs might have what you need

tomknee1
2022-09-25 18:43
Hello, quick question regarding `recording deployments and releases` on the provider side. When we deploy the provider to an environment (e.g. `staging`), it is deployed to multiple `staging` k8s clusters. Should something like `application instances` be considered for deployment of the provider app into each cluster when recording deployment in the pact broker? We were looking at doing the `record-deployment/release` command on provider side as a helm post-install job, but then the command I guess would be run for deployment to every cluster, but I imagine we maybe only need the command called once for the deployment to `staging` environment, rather than for each `staging` cluster ? Would really appreciate any tips on correct approach here. We were looking at this helm post-install hook approach as this better ensures that deployment (to a cluster etc) was actually successful before we run the `record-deployment` command

tjones
2022-09-25 23:10
As I understand it, application instances is more appropriate for things like mobile app releases, where a new deployment doesn?t mean an undeployment of the previous release

tjones
2022-09-25 23:12
It?s hard to know without more information about your setup, but you could consider each staging cluster as its own environment, or you might want to consider deploying to all of them as one deployment (if deployments to individual clusters never happen)

tjones
2022-09-25 23:14
if you have staging-consumer-1 and staging-consumer-2, but they both can connect to staging-provider, then application instances is probably the best approach. But this design sounds like you?d have a bad time with deployment confidence, whether or not you use pact.

matt.fellows
2022-09-26 00:01
Is each k8s cluster serving a different logical environment, or are they all logically the same environment but topologically different (e.g. to support HA)?

matt.fellows
2022-09-26 00:01
If the latter, then `record-deployment` to `staging` is probably all you need. If they are separate environments, you should call `record-deployment` to each logically different environment


tomknee1
2022-09-26 08:28
Thanks, they are logically the same environment, just different regions etc in case one goes down

tjones
2022-09-26 08:29
Can you treat deploying to all clusters as one atomic deploy?

matt.fellows
2022-09-26 11:36
That's what I'd do. If they happen relatively quickly I wouldn't be concerned. If the roll out takes enough time that you could reasonably be worried another deployment attempt could happen during the rollout, then you could record releases to each cluster and then unrecord the previous version release after cutover to each cluster is complete.

tomknee1
2022-09-26 11:38
thanks both, they happen pretty much at the same time and relatively quickly too, i'll look into treating it as one atomic deploy as that also matches our understanding of "environments" on consumer side too :+1:

matt.fellows
2022-09-26 11:48
:+1:

kbon
2022-09-26 13:58
has joined #general

tanyaryzhova93
2022-09-26 18:53
has joined #general

matt.fellows
2022-09-27 01:25
OK looked at the logs - definitely a bug (or at least, currently unsupported). See https://github.com/pact-foundation/pact-reference/issues/220 If you can avoid a context path for now that would work around it, otherwise you?ll have to wait for a fix here until it?s supported

varnit.garg2424
2022-09-27 03:12
Hi @tjones Thanks for the response! Sorry for the typo in my question. Actually my question is pretty genetic and I?m confused since there are so many pact plugins available like pact-jvm, ruby, go etc `you'll have a better time with pact-ruby and pact-go on each side, but you don't technically _need_ to` Can you please explain it a bit? Would it be possible to write the pact tests without using pact-ruby since consumer service is written in pretty old version of Ruby ? Also, would contract tests be ideal to have between a monolithic and microservice ?

tjones
2022-09-27 07:02
> Would it be possible to write the pact tests without using pact-ruby since consumer service is written in pretty old version of Ruby ? Apologies, I probably led you a bit astray. It's technically possible, but you'll be much better off using the native framework for your language(s), as then you can easily (eg) call client code, etc.

tjones
2022-09-27 07:02
> Also, would contract tests be ideal to have between a monolithic and microservice ? Yes. Contract tests are useful any time you have a consumer (client) and a provider (server) that are deployed separately.

varnit.garg2424
2022-09-27 08:00
It helps! Thanks a ton. I?ll start on it and will get back in case of any questions:)

tjones
2022-09-27 08:03
Glad to help!

tomknee1
2022-09-27 08:57
did u mean to send this to a different thread?

mvliannoi
2022-09-27 10:12
Hello! Can anyone please tell me if anybody has experience sending requests with Content-Type `"application/octet-stream"` (_pact-js library_) and verification on the provider side with C# language (_pact-net library_)? Because of many of my attempts, the response is 200 on the provider side, but when I try to test HTTP 400 Bad Request, I cannot find a suitable `withRequest` body for that test. ``` test("...", async () => { const badRequestData = { error: { code: "validationError", message: "Validation error(s) has occurred", details: [], }, }; const badRequestResponse = somethingLike({ error: { code: like(badRequestData.error.code), message: like(badRequestData.error.message), details: like(badRequestData.error.details), }, }); const status = 400; await provider.addInteraction({ state: "...", uponReceiving: "...", withRequest: { method, headers, path, body: "\u0000" }, willRespondWith: { status, body: badRequestResponse }, }); expect.assertions(3); try { await testService.sendContent(mailboxId, content); } catch (e) { checkIfHttpError(e, status); expect((e as AxiosError).response?.data).toStrictEqual(badRequestData); } });``` ```[ApiController] [Route("test")] public class TestController : ControllerBase { private readonly ITestService _testService; public TestController(ITestService testService) { _testService = testService; } [HttpPost("...")] [Authorize(...)] [Produces("application/json")] [Consumes("application/octet-stream")] [ProducesResponseType(type: typeof(TestResponse), StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [ProducesResponseType(StatusCodes.Status401Unauthorized)] [ProducesResponseType(StatusCodes.Status500InternalServerError)] public async Task<TestResponse> HandleAsync(string id, [FromQuery(Name = "fileName")] string? fileName) { if (Request.ContentLength == 0) { throw new InvalidArgumentException("Request body should not be empty"); } var messageId = await _testService.HandleAsync(id: id.ToLower().Trim(), fileName, Request.Body); return new TestResponse(messageId); } }```

anand.krishnan
2022-09-27 10:45
has joined #general

matt.fellows
2022-09-27 11:00
:microphone: Last week I spoke at API Days in Melbourne, about how https://pactflow.io/blog/schemas-are-not-contracts/ and how contract testing is still relevant in the age of gRPC, Kafka and GraphQL! The talk is live here :point_right: https://www.youtube.com/watch?v=ICwB_H1nyW4&list=PLmEaqnTJ40OodNzyBYYedoKLZsR9I-nXA&index=27 Part theory, part rant, part signalling what?s to come with Pact - I hope you enjoy and let me know what you think :eyes:


varnit.garg2424
2022-09-27 11:12
Hello, I?ve recently joined a new project and currently *we don?t have anything to test the integration between two services*. We are planning to *introduce the contract testing*, however, I?m curious to know if we add contract tests, do we still need to create another layer in the test pyramid to carry out the functional integration testing? Or is it possible to tweak our contract tests in such a way that just one layer of *contract tests can help with functional testing as well?* (I understand that it will make the tests unnecessary complicated, but just checking about the feasibility of covering functional testing as part of pact testing layer). I would like to know your opinion on this :slightly_smiling_face:

matt.fellows
2022-09-27 11:14
I absolutely did, very sorry! Not sure?how I did this :man-shrugging:

tomknee1
2022-09-27 11:15
no worries :smile:

matt.fellows
2022-09-27 11:15
What?s the issue with the `400` use case?

matt.fellows
2022-09-27 11:16
Best to keep the functional tests separate. You get a lot of functional test for free as part of pact testing, but you won?t be able to easily test side effects and that will be hard to do with Pact in a way that?s not brittle

tjones
2022-09-27 11:23
I agree with Matt. The way most people write contract tests, there will naturally be some functional _coverage_, but it is incidental / a consequence of the contract test- because some of the functional code happens to be exercised during the test. The primary reason that we don?t recommend functional testing with contract tests is that (especially in consumer driven contract testing) the consumer doesn?t know or define all the provider?s behaviour. Consider username validation- there might be many rules, but the consumer doesn?t necessarily know them.

tjones
2022-09-27 11:24
In that example, the contract test can say ?here is how I expect you to tell me that the username is not valid?, rather than ?here are all the scenarios that the username will not be valid?

estelle.margoutin
2022-09-27 12:00
has joined #general

mvliannoi
2022-09-27 18:34
Sorry for the long time to answer. The issue is more related to the Axios library. It would be great if you, Matt, could help me deal with that. Because for now, it is a real blocking issue for our team. The main problem is sending an empty object with the type ArrayBuffer in the body and "application/octet-stream" as a content type request in the contract test - to get a validation error from the provider. To get such a response from the .NET part - the request content length should be zero. But all of my attempts to send, such as ArrayBuffer(0), don't represent Request with zero content type on the provider side, and as a result - API is trying to do some domain logic with this data returns 200 as well

hazem
2022-09-27 20:46
question about matching arrays. i have a pact that i'd also like to reuse as a stub for testing the consumer ui. my goal is to generate a realistic response that i can reuse as a stub for a ui integration test and also a minimalistic pact definition for the provider to verify, eg atLeastOneLike. is there a matching option that would generate something to support this? pseudo specification ``` { picklists: atLeastOneLike([ {id: 1, name: 'She/Her'}, {id: 2, name: 'He/Him'}, {id: 3, name: 'They/Them'}, {id: 4, name: 'Other'}, ]) }``` so that the generated stub response for the consumer definition is: ``` { picklists: [ {id: 1, name: 'She/Her'}, {id: 2, name: 'He/Him'}, {id: 3, name: 'They/Them'}, {id: 4, name: 'Other'}, ] }``` and the generated matcher for the provider is: ``` "matchingRules": { "body": { "$": { "combine": "AND", "matchers": [ { "match": "type" } ] }, "$.picklists": { "combine": "AND", "matchers": [ { "match": "type", "min": 1 } ] } },```

tjones
2022-09-27 21:19
Pact doesn?t support ?or? on purpose- see the FAQ

matt.fellows
2022-09-28 01:06
No problems. I?m not sure I can give you an answer without detailed exploration on ArrayBuffers. Could you just omit the binary content altogether?

matt.fellows
2022-09-28 01:07
Personally, I don?t think this is a useful test case for Pact though - it feels more of a functional test of the provider. You?re trying to force a `400` on the provider by given them garbage and by knowledge of why it?s causing a `400`. The main thing is that the consumer _can_ handle a `400` . The consumer test should not encode detailed knowledge of how the provider works like this, as it might lead to brittle tests if the provider changes its validation.

mvliannoi
2022-09-28 01:17
Maybe, but it is a part of our actual business logic case, which calls for sending empty files from consumers. Omit from binary content we cannot do because it must be in the protocol of our system. Most possible that I should manually find which is request body sending in UI during that case and pass them in our contract test

matt.fellows
2022-09-28 01:32
I think Hazem is asking about the pact to store all different examples in it that would still comply with the matching rules. The way it works now is you provide a single example e.g. ``` { picklists: eachLike({id: 1, name: 'She/Her'}, 4) }``` and then if you used it as a stub, you?d get back ```[ {id: 1, name: 'She/Her'}, {id: 1, name: 'She/Her'}, {id: 1, name: 'She/Her'}, {id: 1, name: 'She/Her'} ]```

mvliannoi
2022-09-28 02:00
Yeah, it seems we send `ArrayBuffer(0)` to test empty file sending on our UI. But, Pact convert `withRequest` `body` to null if that body is `{}` or `ArrayBuffer(0)` ``` [2022-09-28 01:54:13.419 +0000] ERROR (26056 on ...): pact@9.18.1: error making http request: Request failed with status code 500 FAIL .../__tests__/TestingService.contract.test.ts (5.606 s) ? Console console.error at node_modules/@pact-foundation/src/httpPact.ts:151:17 console.error Pact verification failed! at node_modules/@pact-foundation/src/httpPact.ts:152:17 console.error Actual interactions do not match expected interactions for mock MockService. Incorrect requests: POST /.../004b90d2 (request body did not match) Diff with interaction: "a bad post content request" given "..." Diff -------------------------------------- Key: - is expected + is actual Matching keys and values are not shown { - "body": { - } + "body": null } Description of differences -------------------------------------- * Expected a Hash but got nil at $.body See C:/.../.../.../pact/logs/...-mockserver-interaction-port-9001.log for details. at node_modules/@pact-foundation/src/httpPact.ts:153:17``` ``` await provider.addInteraction({ state: "...", uponReceiving: "a bad post content request", withRequest: { method, headers, path, body: /* new ArrayBuffer(0) or {} */ }, willRespondWith: { status, body: badRequestResponse }, }); expect.assertions(3); try { await keyService.sendContent(mailboxId, new ArrayBuffer(0));```

matt.fellows
2022-09-28 02:17
Well, what is an empty array buffer? It?s 0 bytes of data

matt.fellows
2022-09-28 02:18
JSON has no concept of an array buffer, so it needs to be converted into something expressible in JSON. A 0 byte object is _nothing_

mvliannoi
2022-09-28 02:20
You're right; I didn't even think about that

mvliannoi
2022-09-28 02:25
So, can we conclude that it is a colossal corner case that cannot be tested with contract tests due to JSON limitation for working with binaries, only if our team agrees to do that with functional tests on the provider (API) side?

matt.fellows
2022-09-28 02:45
Yeah, I think the main confidence you want to get here, is that your consumer can handle a `400` . You could do that with provider states, and be agnostic to _how_ the `400` happened (but it?s a bit clunky for the provider). You should definitely functionally test the provider for its validation use cases, but these belong in the provider code base

mvliannoi
2022-09-28 02:55
I understand. Thank you very much, Matt! :slightly_smiling_face:

matt.fellows
2022-09-28 03:02
You?re welcome!

tjones
2022-09-28 03:09
Right. I think it would be good to extend to: ```eachLike(itemDescriptionWithMatchers, exampleArray?)``` So that you could say: ```eachLike( {id: number(), name: string()}, [ {id: 1, name: 'She/Her'}, {id: 2, name: 'He/Him'}, {id: 3, name: 'They/Them'}, {id: 4, name: 'Other'}, ] )```

tjones
2022-09-28 03:12
Although, if this: > i have a pact that i'd also like to reuse as a stub for testing the consumer ui. is the use case, I think that sounds unnecessarily complex. I think it would be better to stub the business object that you assert on in your pact test. For example, if your pact test looks something like: ```pact.addInteraction(/* whatever */) it("returns the correct object", () => { const businessObject = myApi.getWhatever() expect(businessObject).toEqual(expectedBusinessObject) })``` Then you can use `expectedBusinessObject` in stubs, stubbing out `myApi` completely :raised_hands:

matt.fellows
2022-09-28 03:55
Yep, that would be nice. I think the use case is not for the direct pact unit test, but re-using the generated pact file from the stub server later on in UI tests (e.g. cypress). It?s nice to use the pact file for those, because now you?re certain the APIs you?re faking in your UI tests are valid scenarios the provider supports.

matt.fellows
2022-09-28 03:56
Pact has its limitations for those scenarios, but if you can get by with them it?s a real boon

tjones
2022-09-28 04:41
Yes, we are on the same page about the use case. I think a mock (that you assert using pact) is a better fit than a stub api in that case

tjones
2022-09-28 04:41
It?s the same thing we do in a provider test

criss.trifan
2022-09-28 05:36
has joined #general

dimundo
2022-09-28 11:35
hi! compatibility is verified against latest versions with tag is there a mechanism, to verify against ? latest n versions with tag ? or ? versions having tag within last n months

matt.fellows
2022-09-28 11:46
What?s your use case Dmitry?

matt.fellows
2022-09-28 11:46
Recording releases is probably the best way of managing this. You `release` a version of a consumer and a provider can verify all released versions. When a version is no longer relevant, you un-release it

matt.fellows
2022-09-28 11:47
I?d be concerned about ?last n? or time based, because it is not very specific and could result in more tests running that aren?t relevant, or false positives because we?ve overnight stopped caring about an important version

dimundo
2022-09-28 12:07
we have ios bundle - bunch of JS statics our client gets bundles from all suppliers and makes big app sends to Appstore all this hassle is very time consuming and could last months so how can we track, that bundle we shipped some time ago is compatible

dimundo
2022-09-28 12:08
last n is more scary

dimundo
2022-09-28 12:08
so, lets assume - we must support our stuff for 1/2 year

dimundo
2022-09-28 12:08
with just checkin `live` its not enough

dimundo
2022-09-28 12:09
> When a version is no longer relevant, you un-release it looks like i need google something :slightly_smiling_face:

dimundo
2022-09-28 12:10
looks like this ? > record-undeployment --pacticipant my-retired-service --environment test

dimundo
2022-09-28 12:11
> ```record-support-ended --pacticipant foo-mobile-app --version 6897aa95e --environment production``` >

dimundo
2022-09-28 12:11
much wow

dimundo
2022-09-28 12:13
still this is some manual thing

dimundo
2022-09-28 12:17
like after some time i need to find that `--version 6897aa95e`

dimundo
2022-09-28 12:27
or then there is a need in some webhook/api, which would fetch something and un-release based on something

noor.hashem
2022-09-28 13:07
Hi! I was wondering if it was possible with pact to have the consumer tests run against a live provider instead of just the static contract?

yousafn
2022-09-28 13:24
Hey, Bi-directional contract testing is a consumer pact file compared against a static contract (OAS file is currently the only supported) Consumer driven contract testing with Pact, is performed against a locally running provider https://docs.pact.io/provider This wouldn't be your live provider, as you would get the feedback as to breaking changes post deployment which is too late. There is a case where you may want monitoring on your endpoints post deployment, to ensure they work but that is beyond the scope of a contract test, (more a health check / smoke test / canary test ), although I think there is a use case, where a consumer contract file could be used as the input for a live verification. I would consider this FAQ question around 3rd party systems https://docs.pact.io/faq#why-pact-may-not-be-the-best-tool-for-public-testing-apis as the caveats are the same for testing against a live provider

vipatel
2022-09-28 15:29
has joined #general

olaoluphilip
2022-09-28 15:51
has joined #general

hazem
2022-09-28 16:38
yes - your earlier discussion above is what i was looking for, eg ```eachLike(itemDescriptionWithMatchers, exampleArray?)``` apologies, i may have used _stub_ a little too loosely here. :grin: i was referring to the feature in `pactfoundation/pact-stub-server` where we can start a local stub-server running our pact definitions. so in this case, i was hoping to define a pact basically as suggested in the eachLike example.

vieira.jluiz
2022-09-28 17:20
has joined #general

shuo.yang.2006
2022-09-28 19:48
has joined #general

shuo.yang.2006
2022-09-28 19:53
Hi Pacters, We are moving from monolithic app to the micro-service, and I felt end-2-end testing is not sustainable. I just got to know this open source project. However, though I understand what pact wanted to enable us (doing away with the dependence toward e2e testing yet maintaining the peace of mind of releasing), I did not fully understand how can a provider team?s code commit and trigger consumers? contract testing

shuo.yang.2006
2022-09-28 20:00
Imagine a provider service lives in a repo http://GitHub.com/sean/provider.git (hypothetical), it provides an api of 1+1=2; and now, as the owner of this api, I wanted to change it to 1*1=1 (which breaks the contracts, but I did not know) I?d like to get help to understand how pact can help me to know I am checking in something that is impacting my consumers.

yousafn
2022-09-28 20:31
I'd advise checking out our learning material howtolearn

2022-09-28 20:32
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

yousafn
2022-09-28 20:34
Welcome! Good move, both on breaking up the monolith, and knowing that e2e testing isn't scalable in the traditional way. I've popped a link in your other ask with regards to some resources that can help you understand how Pact can aid you as a provider, in understanding how your consumers interact with your API :+1:

yousafn
2022-09-28 20:35
There is a short in browser tutorial that will help showcase Pact and its breaking change detection in action :+1:

shuo.yang.2006
2022-09-28 21:14
Thanks @yousafn@yousafn@yousafn for sharing the pointers. I did watch the 40 mins videos (4 videos of ~10mins) However, I still did not fully understand how the provider repo?s PR or commit can trigger the consumers? contract verification (which is implied in this slide https://docs.pactflow.io/resources/pactflow-demo-pack_2020.pdf)

yousafn
2022-09-28 21:21
Webhooks are used to trigger builds (provider builds when the consumer contract has changed) https://docs.pact.io/pact_broker/webhooks This is the latest webhook event for that purpose https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event In regular provider builds, the provider will verify pacts by a set of defined consumer version selectors, to ensure it is compatible - some of our recommended setups are mentioned https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#recommended https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors Hope this helps a bit

matt.fellows
2022-09-29 00:35
> Imagine a provider service lives in a repo http://GitHub.com/sean/provider.git (hypothetical), it provides an api of 1+1=2; and now, as the owner of this api, I wanted to change it to 1*1=1 (which breaks the contracts, but I did not know) is this a functional change, or an API interface change? That matters, because Pact isn?t a functional testing tool

matt.fellows
2022-09-29 00:35
i.e. it doesn?t check for side effects


shuo.yang.2006
2022-09-29 00:39
I felt it?s contract testing (we want to make sure the contract is what we want to facilitate among teams)

matt.fellows
2022-09-29 00:43
can you be more explicit with your hypothetical example though? is `1+1=2` the body of the code, or the API?

matt.fellows
2022-09-29 00:44
> I did not fully understand how can a provider team?s code commit and trigger consumers? contract testing it doesn?t, it goes the other way around. The consumer publishes a consumer contract (their needs) and that is checked against the provider - the triggering goes this way.

matt.fellows
2022-09-29 00:45
If you need it the other way around and have a provider contract (as an OAS), Pactflow has https://docs.pactflow.io/docs/bi-directional-contract-testing which might be helpful. Or there are OSS tools that can compare the OAS to a pact file and you can create your own workflows around those tools

tjones
2022-09-29 00:53
Yes, that's my understanding of what you're wanting to do with the stub server. My recommendation is to use the test fixtures from your contract test (rather than the contract) to do the stubbing, as it will be simpler, with less moving parts but similar strengths and weaknesses. But, the approach of the stub server is fine too

nirmalcbaral
2022-09-29 15:27
has joined #general

hazem
2022-09-29 15:51
i see your point, however in our case we want to specifically use a stub server to host the api responses as this level of integration testing seems to meet the needs/desires from two separate front-end component teams. is the request above easily doable? ```eachLike(itemDescriptionWithMatchers, exampleArray?)``` we're using pact-js and this would be a great enhancement for our usage there.

ruppel.julian
2022-09-29 20:03
has joined #general

alipala.ist
2022-09-29 20:28
has joined #general

tjones
2022-09-29 23:59
No, I don't believe this is currently supported. @uglyog - can you confirm? You can report this as a feature request against pact-js in this repo: https://github.com/pact-foundation/pact-js

educationextended
2022-09-30 04:59
has joined #general

alan.zhu
2022-09-30 09:31
Hey team I try to find some GraphQL solutions on Pact but find https://docs.pact.io/recipes/graphql, any reference on it ?

matt.fellows
2022-09-30 11:21
There's a GraphQL example in the Pact JS and Pact Go docs.

ross.butler
2022-09-30 11:22
has joined #general

koen.jans
2022-09-30 15:06
has joined #general

hazem
2022-09-30 15:50
thanks for the feedback, i went ahead and logged the https://github.com/pact-foundation/pact-js/issues/955 request since i've already dug around in the code.

lnthai2002
2022-09-30 16:46
Hello, Let say I have 3 applications A, B and C calling each other like this A->B->C within the same API. I understand that the provider test is to check if the provider B implementation complies with the pact generated by the consumer A and since we ae testing implementation, we need the B running with its implementation. However the provider B is also a consumer of provider C. Does it mean the provider test of B also need C running with its implementation?

matt.fellows
2022-10-01 06:48
You should stub C out when you run the B provider test, and then write a separate set of tests for B->C

ksawery.karwacki
2022-10-01 13:12
has joined #general

jesper.nilsson
2022-10-01 13:59
has joined #general

mansillamarcelo90
2022-10-02 22:06
has joined #general

yulia.tekin.86
2022-10-02 22:55
has joined #general

rachel.anderson
2022-10-02 23:39
has joined #general

ashok.pathak
2022-10-03 10:25
Hi Guys, a simple question If consumer contract contains properties not defined in provider contract for this pactflow doesn't throw any error. I want to understand if validation should be there in pactflow for such scenario or not ?

matt.fellows
2022-10-03 10:32
Can you please share an example of what you mean? The answer to this question is complicated, but the general answer is that it should fail if the consumer needs properties that don?t exist (if it sends properties that don?t exist, that?s not an issue)

ashok.pathak
2022-10-03 10:41
Sure, suppose actual data model contains properties A,B,C but as of now only A,B properties have been published in provider contract but consumer sends all A,B,C properties then I am expecting validation error for C as this does not exists for consumer

matt.fellows
2022-10-03 11:52
Sending an additional value is always safe for a provider. It would just ignore the field it doesn?t know about

tomknee1
2022-10-03 13:38
Hello, I just made a sample webhook in my local CLI like this example ```pact-broker create-webhook https://api.github.com/repos/ORG/REPO/dispatches \ > --header=Authorization Bearer $PAT \ > --request=POST \ > --consumer=ConsumerApp \ > --provider=ProviderService \ > --contract-requiring-verification-published``` In my output I got `Webhook "POST http://api.github.com" created` but no UUID, this is using the ruby `pact-cli`... When I try via docker run, I get the same output without any UUID, can anyone help please or know why?

tomknee1
2022-10-03 13:51
ah it looks like i see it in the json response when i go to `/webhooks`

tomknee1
2022-10-03 21:24
Hello, one more question regarding creating webhook with pact broker please, docs say that ?data flag accepts file or string, but when I give a json file path (absolute) it doesn?t work, but passing the json contents as a string does work, is there something I?m missing when trying to use file instead of string? It?s like it reads the file path as a string

jason.stahl
2022-10-03 22:19
has joined #general

sreeragsa
2022-10-04 03:03
has joined #general

ashok.pathak
2022-10-04 06:58
Indeed, incase of actual API I do agree but incase of contract situation is different. In my situation API is already implemented and now we are creating the provider contract which doesn't contain all the properties as this is a very complex single API which is being consumed by lot of calling applications. Now schema varies according to the calling applications so this happens that not all properties are present in the provider contract. So in current situation we are not able to find the gaps as well which doesn't give consumers also the confidence to rely on PactFlow tool as this doesn't identify the gap in this context.

matt.fellows
2022-10-04 07:10
Can you please share the consumer and provider contract?

matt.fellows
2022-10-04 07:10
I'm not sure I understand what you're asking, so seeing an example might help

mazin.inaad
2022-10-04 12:11
Hi, thanks for the responses, sorry for my late reply. I was away for a week. We define our contracts ourselves and use OpenApi to generate the endpoints and DTO's. So I am guessing that there is not much added value to use pactflow.

tara.costin
2022-10-04 14:45
has joined #general



tjones
2022-10-04 21:04
An OpenApi spec isn?t really a contract. It doesn?t define behaviour, and it typically allows lots of requests or responses that wouldn?t actually be acceptable

tjones
2022-10-04 21:05
You don?t *need* contract testing, but without it you will need to be ultra careful about how you test and deploy. How do you know for sure that there are no breaking changes when you update the schema? How do you know that the changes are backwards compatible etc?

matt.fellows
2022-10-04 21:34
How do you know the version of your SDK matches the version of the provider contract that generated the SDK? This was the big problem with SOAP - we generated SDKs from the WSDL, but that just now meant we had to deploy clients and servers at the same time, because the implementation detail was hidden away

yousafn
2022-10-05 13:09
Hey everyone and happy Wednesday. I have a double treat lined up for you. For the past few years, SmartBear has fielded responses from thousands of API practitioners to map out the current state of the industry. From this data, we are able to identify major industry trends and share them back to you and the community in one comprehensive report, you can take a look at the https://smartbear.com/state-of-software-quality/api/ here. We would love your help to make this year's survey our best yet, and because your time is so valuable, by completing the survey (~15 minutes), you will be given an opportunity to direct a donation, given by SmartBear, to your choice of one of the following charities: Make a Wish, http://AnitaB.org, or Clearloop. Helping us with this report will hugely benefit Pact and Pactflow, in shaping our Roadmap for the future (Multi-Protocol Support need in the market === More time spent working on the Pact Plugin ecosystem) , whilst listening to the very heart of what keeps us doing what we are doing - You! Whilst the state of software quality will look forward to the future, we want to show you what we've been up to from product enhancements and future roadmap, news, events, and industry insights in September. You can find it in our Pactflow POST, the attached PDF for perusal at your leisure. That's all for now, but tune in later in the month when the Pactflow Open Source POST will be going out, telling you about all the awesome contributions that have been occurring across the Pact foundation!

oscar.barbamanzano
2022-10-05 14:18
has joined #general

noor.hashem
2022-10-05 18:13
RESOLVED: ~Hey! How can I input my credit card to pactflow so that I can upgrade to payed version?~

varnit.garg2424
2022-10-06 07:09
Hey, Do we have any example on how to define the tests on consumer side if REST API consumes protobuf instead of json?

matt.fellows
2022-10-06 07:35
Not yet. Might be worth joining the #protobufs channel and we can discuss. The protobuf plugin is quite new, and is not yet supported across the full ecosystem.


varnit.garg2424
2022-10-06 07:51
I see the workaround strategy seems to be a bit complicated, I?ll probably take it as last resort. In general, even though the protobuf plugin is pretty much new, does it work for other users? Let me also start a discussion in #protobufs channel :slightly_smiling_face:

mazin.inaad
2022-10-06 08:31
Hahah ok, Thanks for the links. I will dive into them :smile:

yanov.alexander
2022-10-06 08:39
has joined #general

bxbivc
2022-10-06 10:05
has joined #general

curtis.scott
2022-10-06 11:27
has joined #general

riley.lee
2022-10-06 11:30
has joined #general

oliver.smyth
2022-10-06 11:34
has joined #general

kevin.campos
2022-10-06 11:35
has joined #general

pstrnad
2022-10-06 12:04
has joined #general

rachelxelizabethh
2022-10-06 13:20
has joined #general

pratish
2022-10-06 21:08
has joined #general

ilia
2022-10-06 22:18
has joined #general

edudelta
2022-10-07 15:57
has joined #general

olsen.lee.r
2022-10-07 18:29
has joined #general

johndunning
2022-10-08 18:05
has joined #general

kentooooo.1230
2022-10-09 17:49
has joined #general

gpapadakis84
2022-10-10 12:32
has joined #general

daftpunkapi
2022-10-11 09:22
has joined #general

matteo.demasi
2022-10-11 12:08
has joined #general

matteo.demasi
2022-10-11 12:12
Hello guys, i'm working to a PoC with Pact for a company. Any of you with some experience in Event Driven Testing with Pact? Thank you :slightly_smiling_face:

raul.romitan.ext
2022-10-11 12:17
has joined #general

dominikdieter.krichba
2022-10-11 13:23
has joined #general

ulrich.keil
2022-10-11 13:26
has joined #general

mitchell.l.cooper
2022-10-11 13:45
has joined #general

torsten.wiederkehr
2022-10-11 14:24
has joined #general

phillip.lo
2022-10-11 16:21
Hey, I have question about recommendations on handling secret key rotations. We have webhooks set up to call CI jobs as recommended to do verifications when contracts change. However, this is currently making the call using an API key that gets rotated every once in a while. What do people do in these situations? Its not feasible to go and update each webhook every time the key changes so I'm curious what the recommendation is from Pact.


matt.fellows
2022-10-11 21:59
We currently don?t have any vault integration, so I think automation is the key here (pun not intended :wink: )

matt.fellows
2022-10-11 21:59
the only suggestion I have would be to setup automation to create the webhooks in the first place (can be done via our CLI tools)

matt.fellows
2022-10-11 22:00
And when the secret changes, have the automation update the webhooks with the new secret

phillip.lo
2022-10-11 22:00
ok got it.

phillip.lo
2022-10-11 22:01
is there any existing ticket or planned work for handling this directly from the broker itself?

phillip.lo
2022-10-11 22:01
im wondering if there is a way to do bulk updates if the webhook info was stored in a different way

matt.fellows
2022-10-11 22:09
> is there any existing ticket or planned work for handling this directly from the broker itself? not that I?m aware - what is the actual ask - vault integration?

mikey214
2022-10-11 22:32
has joined #general

phillip.lo
2022-10-11 23:45
vault integration and/or just brainstorming ideas of a way to do updates to multiple webhooks at once without creating an outside automation process that would need to iterate through every webhook to update

matt.fellows
2022-10-12 00:17
In Pactflow, we have secrets. These secrets could be updated, so any webhooks that use them would automatically use the new secret

matt.fellows
2022-10-12 00:17
We have considered vault integration for Pactflow, but it?s lower on the roadmap priority right now

matt.fellows
2022-10-12 00:17
If you do have suggestions (for the OSS broker) please do share at -> http://pact.canny.io

xi.luo
2022-10-12 05:11
has joined #general

kim.crowe
2022-10-12 10:15
has joined #general

stefan.tertan
2022-10-13 09:50
accidentally made a request to install a Slack app in this workspace instead of the one it was meant for...ignore that (http://incident.io)

matt.fellows
2022-10-13 09:53
No probs thanks for letting me know - just cancelled it now. Happens all the time !

suganyamuthukumar03
2022-10-13 11:01
has joined #general

francis.bonneau
2022-10-13 18:30
has joined #general

naf
2022-10-14 10:55
has joined #general

werner.lauterfeld
2022-10-14 11:09
has joined #general

jharms
2022-10-14 15:04
has joined #general

daniel.cronin
2022-10-14 16:15
has joined #general

txomin.sirera
2022-10-14 18:57
has joined #general

jr
2022-10-15 20:48
has joined #general

sasankdts
2022-10-16 08:48
has joined #general

wil.pannell
2022-10-16 16:56
has joined #general

matteo.demasi
2022-10-17 07:44
Hi @matt.fellows, thank you very much! I actually saw this, but it's pretty high level. I would like to know if it could be possible to upload in this case only the JSON. For example, in event driven, i want to publish the contract to pactflow without any test, so basically just the JSON file. Anything about this? Using just the eventdriven JSON, doesn't work ofc

sirisha.kunaparaju
2022-10-17 11:01
has joined #general

gardeepti
2022-10-17 11:02
has joined #general

vedant3620
2022-10-17 11:08
has joined #general

priyanka.bbit
2022-10-17 11:11
has joined #general

nvourlakis
2022-10-17 11:21
has joined #general

alan.zhu
2022-10-17 12:40
Hey http://team.In consumer driven contract test. I was curious to understand what is the benefit of me a consumer testing the producer, instead of the producer making sure they keep their API contract and have test in place to validate that each new release does not brake their API as they agreed to provide it to their consumers?

oliwia.koch
2022-10-17 13:51
has joined #general

bluediamondpc
2022-10-17 14:18
has joined #general

nicholas.difelice
2022-10-17 15:16
has joined #general

remington.otoole
2022-10-17 15:20
has joined #general

matt.lucido
2022-10-17 15:23
has joined #general

molly.mccarthy
2022-10-17 15:28
has joined #general

matt.fellows
2022-10-18 01:26
Your job is not to _test_ the producer - I think this is a common misconception. It?s a side effect, but not the key goal. Your job is to test the _client_ and make your requirements clear to the producer, so that they can evolve their API without breaking any of its consumers. Testing an API interface and its functionality is a necessary pre-condition, but is often not sufficient to prevent breaking changes (see Hyrum?s law). I think this FAQ helps clarify some of the other key benefits though. https://docs.pact.io/faq/convinceme#but-i-already-have-a-local-mock-server-eg-vcr-mockserver

matt.fellows
2022-10-18 01:30
Are you asking if we support AsyncAPI? We currently only support OAS providers for BDCT at the moment.

slack1211
2022-10-18 07:24
has joined #general

mekala.kalyan
2022-10-18 12:49
has joined #general

jpullifrone
2022-10-18 17:05
has joined #general

jorge.bo
2022-10-18 18:42
has joined #general

orhun
2022-10-18 19:42
has joined #general

phillip.lo
2022-10-18 20:09
Got a question about pacticipant names. I know that there is a built in check to make sure that you dont have similar/duplicate pacticipant names. However, we are running into a situation where we've deleted the "integration" between two services from the broker ui however the broker is still giving us the error of a pacticipant name being too similar. I wanted to know if this is expected behavior and if we have to go in an manually delete the pacticipant in addition to deleting the pact integration itself? I'm curious what the reasoning behind checking against pacticipant names that dont have any current integrations are.

matt.fellows
2022-10-18 20:17
Yes you will need to delete the pacticipant if you've only deleted the pacts. It's perfectly valid to pre create applications before the contracts are there, and the warning is still useful. It could still be confusing to people

phillip.lo
2022-10-18 20:19
Ah. What is the benefit of pre-creating applications? So you can set up a webhook?

matt.fellows
2022-10-18 23:04
that?s one example, yes

matt.fellows
2022-10-18 23:04
A lot of teams like the idea of IaC, and setting properties on the app (e.g. the github URL)

matt.fellows
2022-10-18 23:05
in Pactflow, it could be to assign it to a team so that users will have the right permissions to work with it

matt.fellows
2022-10-18 23:05
there are many

phillip.lo
2022-10-18 23:05
ok, I can see that for pactflow.

soap6gal
2022-10-19 08:11
Hello,

soap6gal
2022-10-19 08:13
I'd like to pass in dynamic path to PathFolder. Does anyone have any workaround?

kwo.ding
2022-10-19 08:24
has joined #general

matt.fellows
2022-10-19 08:41
What language? Best asking in the language specific channel

soap6gal
2022-10-19 09:51
Posted in #pact-jvm thanks!

ankit.jain
2022-10-19 10:41
has joined #general

edeandre
2022-10-19 12:09
has joined #general

stanlisaus
2022-10-19 12:11
has joined #general

nerea.tamayo
2022-10-19 13:01
Hey team! Do you know if there is any channel for applying pact for Tibco/SAP ?? The case is an integration between a java application with SAP system through Tibco (xml stream). The idea is applying Pact on both sides between SAP - Tibco and Tibco - java system. Do you know if tehre is any channel for this type of technologies?

noor.hashem
2022-10-19 16:11
Hi all, if I remember correctly a few weeks back I saw messages about a pact course coming out soon? Has this course come out yet?

nikolaasrondon
2022-10-19 17:29
has joined #general

matt.fellows
2022-10-19 20:41
I'm not aware of a new pact course. We already have a few here (howtolearn)

2022-10-19 20:42
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

fquijada
2022-10-19 21:25
has joined #general

tjones
2022-10-19 22:34
I?ve not heard of anyone doing this. I believe pact jvm supports xml

aforeman
2022-10-20 00:34
Hey @noor.hashem you might be asking about the Fullstack Testing Academy course? I believe the latest cohort commenced last week. @pietrucha.bartosz is the brains behind it - do you have any other dates upcoming?

lnthai2002
2022-10-20 02:12
Hello, we are using jacoco to calculate codecoverage at test phase. For our unit tests, it is working correctly, however i dont know if pact test can be count toward code coverage given that consumer test is basically a unit test and our provider test is running with junit 5 although they run in verify phase. Has anyone tried reporting pact test coverage with jacoco?

matt.fellows
2022-10-20 02:50
Might be best asking in #pact-jvm

matt.fellows
2022-10-20 02:50
What's the actual issue though? My understanding is that it simply instruments code run paths

matt.fellows
2022-10-20 02:51
That should be agnostic to pact or any other testing

tjones
2022-10-20 03:39
Yes, there should be no issues.

tjones
2022-10-20 03:39
You would just run your unit tests like normal, and then look at the coverage

kkalan
2022-10-20 03:52
has joined #general

pietrucha.bartosz
2022-10-20 06:55
@noor.hashem hi! are you asking about http://fullstack-testing.com ?

nerea.tamayo
2022-10-20 08:00
Oh nice!!thanks a lot!We will try it!!

dyptorden
2022-10-20 10:24
has joined #general

olawale.akande
2022-10-20 11:52
has joined #general

olawale92.tech
2022-10-20 11:56
has joined #general

noor.hashem
2022-10-20 12:57
Hi, Yes I was asking about http://fullstack-testing.com thank you both! :pray:

calen.pennington
2022-10-20 13:43
has joined #general

muhammud.naseeruddin
2022-10-20 16:04
has joined #general

xuw
2022-10-20 16:38
has joined #general

xuw
2022-10-20 16:41
Hi everyone, had a pretty simple question, how does http://pact.io determine which tests need to pass in order to generate the pact? I haven?t figure this out for scala-pact.

matt.johnson
2022-10-20 17:25
has joined #general

xuw
2022-10-20 19:53
To add more detail, currently we are setting up our contract tests in the same repository as all of our tests for our microservice. My understanding is that we cannot avoid running all of our tests versus just the contract ones. Am I misunderstanding this?

tjones
2022-10-20 20:40
Pact has lifecycle hooks that are called at the end of each pact test. It uses those

matt.fellows
2022-10-20 20:40
I don't know scala pact very well,. But I suspect this is more of a question about the test runner than Pact.

matt.fellows
2022-10-20 20:41
Pact shouldn't know or care about other testing

tjones
2022-10-20 20:41
You don?t *have* to run all your unit tests to generate a pact file. You could just run the pact ones

xuw
2022-10-20 20:44
Yeah, I think I?m running into problems with choosing which unit tests to run to generate a pact file if that makes sense? The documentation on scala-pact just seems to use sbt pactTest but this will run all tests. Is there an argument/parameter I need to set


xuw
2022-10-21 00:31
I am using the scala-pact library

matt.fellows
2022-10-21 10:51
Recommended watching from an industry superstar: https://youtu.be/QFCHSEHgqFE (Especially the ~13min mark :wink:)

bhavyashree.r
2022-10-22 06:10
has joined #general

bhavyashree.r
2022-10-22 06:16
Hi Everyone, am new to Pact .. Is it possible to run Provider side verification by directly pointing it to stage or prod URL instead of running service locally.

abubics
2022-10-22 06:29
Short answer: no. That's not really how it's intended to work. Long answer: yes, but you'll still need to be able to change the state in your provider. If you want to set extra infrastructure up to facilitate it, you definitely could. But that feels wasteful and flaky, or at least builds in a lot of latent coupling.

mosesgwenne
2022-10-24 06:10
has joined #general

mosesgwenne
2022-10-24 07:12
Hi @channel, I?m new to Pact and in need of your guidance. I have a running api test harness locally on port 3000. I set my providerBaseUrl to this server but when I run the test I see that provider is listening to a different port. Could someone pls point what I?m missing? ```return new Verifier({ providerBaseUrl: "http://localhost:3000", // <- location of your running provider pactUrls: [ path.resolve( process.cwd(), "./pacts/sampleConsumer-sampleProvider.json" ), ], })``` ```[2022-10-24 06:22:28.693 +0000] TRACE (33504 on xxxxxxx): pact@10.1.4: Verifying pacts with: {"providerStatesSetupUrl":"http://localhost:64042/_pactSetup","provider":"sampleProvider","providerBaseUrl":"http://localhost:64042","pactUrls":["C:\\Users\\gwenne\\Desktop\\Workspace\\pact-sample-test\\pacts\\sampleConsumer-sampleProvider.json"],"logLevel":"TRACE","validateSSL":true,"changeOrigin":false}``` I am receiving failed test but I am not provided with a detailed error. ```[2022-10-24 06:22:29.452 +0000] ERROR (33504 on xxxxxxx): pact-core@13.10.0: Verification unsuccessful [2022-10-24 06:22:29.452 +0000] TRACE (33504 on xxxxxxx): pact@10.1.4: Verification failed(Verfication failed), closing server Pact verification failed :( Error: Verfication failed at C:\Users\d832076\Desktop\Workspace\pact-sample-test\node_modules\@pact-foundation\pact-core\src\verifier\nativeVerifier.ts:50:20```

matt.fellows
2022-10-24 07:21
FYI going forward, best asking in the language specific channel (e.g. #pact-js in this case)

matt.fellows
2022-10-24 07:21
The port in there is a port to a local proxy in Pact JS, nothing to be concerned about. You should be able to see the incoming/outgoing at `trace` level

matt.fellows
2022-10-24 07:22
There should be other logs that explain what is happening, can you please share here?

mosesgwenne
2022-10-24 07:27
thanks for responding, Matt. this is the log returned. ```[2022-10-24 06:22:28.605 +0000] INFO (33504 on xxxxxxxxxx): pact@10.1.4: Verifying provider [2022-10-24 06:22:28.615 +0000] TRACE (33504 on xxxxxxxxxx): pact@10.1.4: Setting up state proxy with path: /_pactSetup [2022-10-24 06:22:28.690 +0000] TRACE (33504 on xxxxxxxxxx): pact@10.1.4: proxy created, waiting for startup [2022-10-24 06:22:28.691 +0000] TRACE (33504 on xxxxxxxxxx): pact@10.1.4: Proxy is ready at :: [2022-10-24 06:22:28.693 +0000] TRACE (33504 on xxxxxxxxxx): pact@10.1.4: Verifying pacts with: {"providerStatesSetupUrl":"http://localhost:64042/_pactSetup","provider":"sampleProvider","providerBaseUrl":"http://localhost:64042","pactUrls":["C:\\Users\\gwenne\\Desktop\\Workspace\\pact-sample-test\\pacts\\sampleConsumer-sampleProvider.json"],"logLevel":"TRACE","validateSSL":true,"changeOrigin":false} [2022-10-24 06:22:28.693 +0000] INFO (33504 on xxxxxxxxxx): pact-core@13.10.0: Verifying Pacts. [2022-10-24 06:22:28.694 +0000] INFO (33504 on xxxxxxxxxx): pact-core@13.10.0: Verifying Pact Files [2022-10-24 06:22:28.696 +0000] TRACE (33504 on xxxxxxxxxx): pact-core@13.10.0: Initiliasing ffi for the first time [2022-10-24 06:22:28.696 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: Initalising native core at log level 'TRACE' [2022-10-24 06:22:28.707 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierSetFilterInfo' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:28.708 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierSetPublishOptions' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:28.709 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierSetConsumerFilters' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:28.710 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierSetFailIfNoPactsFound' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:28.711 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierAddCustomHeader' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:28.712 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: checking source type of given pactUrl: C:\Users\gwenne\Desktop\Workspace\pact-sample-test\pacts\sampleConsumer-sampleProvider.json [2022-10-24 06:22:28.720 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: adding C:\Users\gwenne\Desktop\Workspace\pact-sample-test\pacts\sampleConsumer-sampleProvider.json as File source [2022-10-24 06:22:28.721 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: the optional ffi function 'pactffiVerifierBrokerSourceWithSelectors' was not executed as it had non-fatal validation errors: [2022-10-24 06:22:29.452 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: shutting down verifier with handle 0 [2022-10-24 06:22:29.452 +0000] DEBUG (33504 on xxxxxxxxxx): pact-core@13.10.0: response from verifier: null, 1 [2022-10-24 06:22:29.452 +0000] ERROR (33504 on xxxxxxxxxx): pact-core@13.10.0: Verification unsuccessful [2022-10-24 06:22:29.452 +0000] TRACE (33504 on xxxxxxxxxx): pact@10.1.4: Verification failed(Verfication failed), closing server Pact verification failed :( Error: Verfication failed at C:\Users\gwenne\Desktop\Workspace\pact-sample-test\node_modules\@pact-foundation\pact-core\src\verifier\nativeVerifier.ts:50:20```

dyptorden
2022-10-24 09:47
Hi guys. Having the pact broker deployed via-docker compose, can I create somehow the webhooks automatically when I bring the infrastructure up (by running the docker compose?)

matt.fellows
2022-10-24 09:58
You could run the CLI commands (there is a `create-or-update` one for webhooks) or the terraform.

matt.fellows
2022-10-24 09:59
I?ve never _really_ heard of people actually using docker compose in production - what are you using it for? Can you elaborate what you?re trying to do here - IaC?

matt.fellows
2022-10-24 09:59
There is also a terraform provider, that is probably better suited in that mode

mosesgwenne
2022-10-24 10:06
```'pactffi*' was not executed as it had non-fatal validation errors:``` I don?t understand what these logs mean

dyptorden
2022-10-24 10:16
Thanks for the answer @matt.fellows. I am working on a POC. What I achieved so far is to create and publish a contract in the broker from a consumer (via a Jenkins Job) and also to get results published from the broker (different Jenkins job). As I am working on understanding the webhooks, this question came to my mind... If I need to recreate the broker at some point, can I also have the webhooks automatically created at the same time? I went for the docker way as most of our infrastructure is build on dockers and I am familiar with that approach.

matt.fellows
2022-10-24 10:21
they should probably be `trace` logs actually. I?ll make a bug for that

matt.fellows
2022-10-24 10:21
(they aren?t intended for you, is what that means)

matt.fellows
2022-10-24 10:22
That?s unfortunately not very helpful. If you could please provide your test setup or even a repro, that would be really helpful

glenn
2022-10-24 11:08
Can Pact be used with Financial Information eXchange (FIX) protocol connections?

matt.fellows
2022-10-24 11:12
Pact is usually standard agnostic. Is it just a REST API?

glenn
2022-10-24 11:14
No. I think it?s directly over TCP, e.g. at an equivalent layer to HTTP.

matt.fellows
2022-10-24 11:19
You could look to create a new plugin for it

matt.fellows
2022-10-24 11:20
We haven't published docs yet but could point you in the right direction?

glenn
2022-10-24 11:20
Yes please. It may not be me who does it but would be useful to be able to point the way.

glenn
2022-10-24 11:24
I suspect it?s the same situation for Redis. *RESP (REdis Serialization Protocol)*

lnthai2002
2022-10-24 13:50
my bad, the test result actually reported by jacoco, however since i am using Feign to call provider, there is no implementation code, only an interface class thus jacoco did not see any code get covered when running consumer test. On the provider side, it does report controller, and some services classes get tested, however, due to my jacoco merge config, the result was not merged to the report generated at test phase. I still need to adjust my jacoco config.

xuw
2022-10-24 14:20
Hi! Was looking into overriding the pactTest default command to only run tests with a certain tag. Is there any examples on how to do this?

james.perepiczka
2022-10-24 15:15
Hi, I had a question around approach. We have a service (Service A) that sends a message to another service (Service B) via Kafka. Service B packages up the request and then forwards onto another service (Service C). Service A and Service C have a relationship in that the data that gets send from Service A is only read by Service C and an action is performed based upon the contents of that message. My question is whether we ignore Service B and say there is a *contract between A & C* (where the intent of an action is understood) or I say there is a *contract between A&B and then B&C* (because the message is generated by one and received by another) or whether there is a *contract between A&B and A&C.* What would be the suggested approach in this instance? The concern is that because there is a relationship between what is sent by Service A and what is processed by Service C that the importance of the message content would be lost as Service B does not care or know about what it sends to Service C (If I was to adopt the traditional direct service to service approach)

j.watkins12
2022-10-24 21:13
has joined #general

mosesgwenne
2022-10-24 23:10
I have a running api test harness on localhost:3000. My provider test script is

tjones
2022-10-25 00:32
The request / response logging is actually at `debug` level, or at least it used to be

matt.fellows
2022-10-25 01:04
Tricky. It sounds a bit like the https://docs.pact.io/recipes/apigateway use case. You might be able to extrapolate the guidance from that here

matt.fellows
2022-10-25 01:05
Does the structure of the message from A matter to service B? Or does it blindly find it and carry it to Service C? Does it transform the message at all?

matt.fellows
2022-10-25 01:06
If it doesn?t modify things, in that case, you might choose to ignore B altogether (ensuring you have appropriate coverage to ensure that if service B goes out of commission, the scenarios are appropriately tested)

tjones
2022-10-25 01:12
Yep. This sounds like a jacoco problem rather than a pact problem

tony.odonnell
2022-10-25 07:56
has joined #general

martin.schlegel
2022-10-25 11:24
has joined #general

stefan.zivkovic
2022-10-25 12:35
has joined #general

alexander.friesen
2022-10-25 14:07
has joined #general

mspector
2022-10-25 14:45
has joined #general

thomas.peyregne
2022-10-25 14:53
has joined #general

james.perepiczka
2022-10-25 15:47
> Does the structure of the message from A matter to service B? Or does it blindly find it and carry it to Service C? Does it transform the message at all? (edited) Not really, it just takes the payload and puts a Cloud events wrapper around it and decides where to route it to

tomknee1
2022-10-25 15:57
Hello, im trying to pinpoint an issue and wondering if anyone might have any ideas please... we've created a webhook for `contract-requiring-verification-published` but when we `pact-broker test-webhook` the `pactbroker.providerVersionBranch` and `pactbroker.providerVersionNumber` is the very latest HEAD rather than the version on `main` branch. The provider (as well as consumer) correctly has `mainBranch` property set etc, any ideas please?

jsirju
2022-10-25 20:22
has joined #general

matt.fellows
2022-10-25 22:10
Is it possible that version does require a verification and that version is deployed to an environment?

a.emmanuelmendoza
2022-10-25 23:42
has joined #general

tomknee1
2022-10-26 07:41
The provider version is not deployed to an environment, it?s the latest PR branch before it?s merged to main

matt.fellows
2022-10-26 08:26
I?m not super familiar with the details of the webhook itself and the test feature. I?m currently wondering if during the ?test? it just grabs the latest version, instead of what would happen in ?real life?

matt.fellows
2022-10-26 08:27
Have you tried just enabling it and publishing a new contract, to see if does indeed trigger correctly with real data?

tomknee1
2022-10-26 08:47
Hm thanks, we are about to merge the PR on provider side and then tests the webhook with the GHA repository_dispatch workflow properly

tomknee1
2022-10-26 08:47
so yeah we think it might actually be fine and going to test it more e2e shortly :slightly_smiling_face:

matt.fellows
2022-10-26 09:04
:panic_button:

emma.colleran
2022-10-26 13:05
has joined #general

aaron.swerlein
2022-10-26 15:10
has joined #general

jeronimo
2022-10-26 17:50
has joined #general

anhtvuong
2022-10-26 19:00
I have similar issue with @PactVerifyProvider(CONSUMER_INTERFACE) String verifyMessageForInterface() that somehow reduces curremt jacoco ratio. I'm looking at jacoco pom.xml configuration to exclude PactVerificationTest.class in provider and no luck yet. Just wonder if somebody knew the solution.

lnthai2002
2022-10-26 19:38
I named my provider tests as *.PPT so that they are not pickup by surefire. Then i make a profile to run only provider tests and generate jacoco report for them. Here is my profile: <profile> <id>provider-pact-test</id> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M4</version> <executions> <execution> <id>default-test</id> <phase>test</phase> <goals> <goal>test</goal> </goals> <configuration> <!-- Donot run any normal unit test --> <excludes> <exclude>**/Test*.java</exclude> <exclude>**/*Test.java</exclude> <exclude>**/*Tests.java</exclude> <exclude>**/*TestCase.java</exclude> </excludes> </configuration> </execution> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>test</goal> </goals> <configuration> <excludes> <exclude>**/Test*</exclude> <exclude>**/*Test</exclude> <exclude>**/*Tests</exclude> <exclude>**/*TestCase</exclude> </excludes> <includes> <include>**/*PPT</include> </includes> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.6</version> <executions> <execution> <id>pre-integration-test</id> <phase>pre-integration-test</phase> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${project.build.directory}/jacoco-output/provider-pact-test.exec</destFile> <propertyName>surefireArgLine</propertyName> </configuration> </execution> <execution> <id>post-integration-test</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${project.build.directory}/jacoco-output/provider-pact-test.exec</dataFile> <outputDirectory>${project.build.directory}/jacoco-provider-pact-test-coverage-report</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build> </profile>

lnthai2002
2022-10-26 19:44
by pasting it here i just realized, i can just put skipTest in the test phase instead of excluding :smile: *Test.

matthew.beattie
2022-10-26 20:14
has joined #general

anhtvuong
2022-10-26 20:33
Thanks to @lnthai2002 for sharing. I realized the suggestion from @matt.fellows therefore I added my non-UT standalone provider PactVerifyProvider to an existing UT which helps. My actual issue is surefire version 3.0.0-M4 which can see my pact tests but not other existing UT which reduces CC ratio to 0.0.

lnthai2002
2022-10-26 21:11
i am running build on CI/CD and i have 4 different jobs which runs 4 different kinds of test: unit tests, db integration tests, pact consumer tests and pact provider tests. Each job compiles and runs the tests in a separated docker container. Thus I have to use a different profile (the one I shared is for provider test) for each job to run only one kind of test. At the end of each job, there is one .exec file generated so I gather them and the compiled classes and run the jacoco:merge (in a different job). I have 3 profiles (integration, consumer-pact-test and provider-pact-test) that are similar to the one i shared, the default is the unit test that i configure in the build section: <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>3.0.0-M4</version> <configuration> <argLine>${surefireArgLine}</argLine> <redirectTestOutputToFile>true</redirectTestOutputToFile> <reportsDirectory>${project.build.directory}/test-reports</reportsDirectory> </configuration> </plugin> <!-- Code Coverage report generation --> <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> <version>0.8.6</version> <executions> <execution> <id>pre-unit-test</id> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${project.build.directory}/jacoco-output/unit-test.exec</destFile> <propertyName>surefireArgLine</propertyName> </configuration> </execution> <execution> <id>post-unit-test</id> <phase>test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${project.build.directory}/jacoco-output/unit-test.exec</dataFile> <outputDirectory>${project.build.directory}/jacoco-unit-test-coverage-report</outputDirectory> </configuration> </execution> <execution> <id>pre-integration-test</id> <phase>pre-integration-test</phase> <goals> <goal>prepare-agent</goal> </goals> <configuration> <destFile>${project.build.directory}/jacoco-output/integration-test.exec</destFile> <propertyName>surefireArgLine</propertyName> </configuration> </execution> <execution> <id>post-integration-test</id> <phase>post-integration-test</phase> <goals> <goal>report</goal> </goals> <configuration> <dataFile>${project.build.directory}/jacoco-output/integration-test.exec</dataFile> <outputDirectory>${project.build.directory}/jacoco-integration-test-coverage-report</outputDirectory> </configuration> </execution> <execution> <id>merge-all-test-coverage</id> <goals> <goal>merge</goal> </goals> <configuration> <fileSets> <fileSet> <directory>${project.build.directory}/jacoco-output/</directory> <includes> <include>*.exec</include> </includes> </fileSet> </fileSets> <destFile>${project.build.directory}/jacoco-merged.exec</destFile> </configuration> </execution> </executions> </plugin>

lnthai2002
2022-10-26 21:12
hope it helps

harrison.le
2022-10-26 21:47
has joined #general

amandasstecz
2022-10-26 21:57
has joined #general

christianoliver.table
2022-10-27 06:15
has joined #general

zehra.lichtenberg
2022-10-27 08:08
has joined #general

dawoud.sheraz
2022-10-27 09:42
Hello there, how are you doing? A general question; Is consumer driven contract testing similar to API Testing? What are similarities and differences as a whole? I was recently talking about Pact with someone and they said that the contract testing is just API testing. I have explored some answers on Google but hoping to get better answers from here. Thanks

yousafn
2022-10-27 10:27
Hey buddy, welcome I would recommend reading this home page and two respective pages which should answer your questions or provide further discussion points https://docs.pact.io https://docs.pact.io/getting_started/comparisons https://docs.pact.io/consumer/contract_tests_not_functional_tests

vzviaruha
2022-10-27 11:29
has joined #general

yousafn
2022-10-27 11:32
Welcome to the October Pact Open Source update! I?ve got some great things to share this month ? As always, we have a focus on our community heroes, this time we have @paulorochag, https://twitter.com/holly_cummins, @edeandre & @liran.tal https://docs.pact.io/blog/2022/10/25/pact-open-source-update-october-2022 Plus a sneak peak of our upcoming Pact Plugin Framework launch which you can sign up to here https://docs.pact.io/events/plugins-framework-launch This the culmination of several years of work, and we believe it's going to be a game changer for organisations who love contract testing but can't apply it to various aspects of their organisation because a particular technology isn't supported. Plugins will enable you to extend the capabilities of Pact, without having to make changes to the Pact framework itself. For example, you could create a plugin to handle the Avro or GraphQL content types, or create a websockets transport. You can even test out gRPC with one of our first plugins, we would love you to try it out. Also whilst I have you, you can checkout the state of API quality 2021 here https://smartbear.com/state-of-software-quality/api/ and participate in our 2022 survey, it will take around 15 mins and as a thank you, SmartBear will make a donation to a charity for each survey completed! https://www.surveymonkey.com/r/QF2C6M7 Whichever way you want to get involved, don't hesitate to reach out! Thanks all <3 - Saf

michael.laird
2022-10-27 13:38
has joined #general

pedropho18
2022-10-27 21:33
has joined #general

juancesarvillalba
2022-10-27 21:43
has joined #general

angad.singh
2022-10-28 11:07
has joined #general

xuw
2022-10-28 13:57
Hi Had a question on this page: https://docs.pact.io/getting_started/matching Are the `Pact::SomethingLike` functions, for example `Pact.like(73)`, available in all versions of the pact specification? I haven?t been able to find an example for scala-pact, but I know that it only supports up to v2



oroceo.ian
2022-10-28 20:04
has joined #general

benjamin
2022-10-28 21:09
has joined #general

emailpankaj.agarwal
2022-10-29 13:26
has joined #general

pavithz
2022-10-30 22:52
Hello Team, I have a generic question w.r.t pact consumer. Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ? We are starting the contract testing newly in our org and our stakeholders are interested to use the live service at the first place to generate the contract (as we have 1000+ micro services already up in production) and for those existing ones - preferring to use live rather than mock at the consumer end. Really looking forward for your response !

krishnakanth219
2022-10-30 22:59
has joined #general

matt.fellows
2022-10-30 23:50
> Hello Team, I have a generic question w.r.t pact consumer. Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ? Pact doesn?t no. It?s best thinking of Pact as a unit testing tool. Whilst you could definitely use a record/replay style tool to capture the requests, what you will lose out on is what fields in the response the consumer actually uses - this is an important part of the contract test. Usually, you only use a subset of them. Assuming you need the full suite, means that it will be harder for the provider to evolve. But, you might like to try it as a starting point, and then manually pare the tests back

matt.fellows
2022-10-30 23:51
If Pact is a bit of a hurdle to jump, you could look at https://pactflow.io/bi-directional-contract-testing/ (BDCT) to start with and then transition to Pact as you mature. BDCT is more schema based and might be an option to consider if you want to scale the tests more quickly.

pavithz
2022-10-31 00:51
Thanks Matt for the quick response. Yes that makes sense as the purpose of contract testing!

tjones
2022-10-31 00:52
> Does pact support letting the consumer to generate the pact json file by hitting the real provider service instead of hitting the provider using pact mock server ? The point of pact is that you _don't_ have to do this, but you get the same value as if you had.

joshua.mclatchie
2022-10-31 02:21
has joined #general

pavithz
2022-10-31 03:23
Also have a follow up question. Hope pact supports running against the provider real service at the provider end (I mean without mocking the data layer) and running against the real service running say on dev common environment ?

matt.fellows
2022-10-31 03:39
Yes, you run against a real service. But it's best practice to do it in a unit test-like environment

matt.fellows
2022-10-31 03:39
This allows you to exert very specific control over how the tests run, and importantly, stub out external systems to make them reliable

pavithz
2022-10-31 04:18
Cool ! Thanks Matt


pavithz
2022-10-31 04:51
Yes have read it through and did spike based on pact jvm and mocks on both consumer provider ends. While trying to implement for POC we had this requirements from stakeholders. We explored and couldn?t find any examples at consuming end hitting real service. Hence this post for :100: % confirmation from pact community :blush:

tjones
2022-10-31 05:57
Awesome, makes sense. The people asking the question might be interested in that page too.

jayeshguru81
2022-10-31 12:11
Hello Team, Need help with Pact matching for response body. I have a big response body json of 2000 lines where we have array of templates object. I just want to match 1 object out of 100 templates. I am getting error with failure in matching when I tried this ```asset_classifier_pact.given( "mpid and brand catalog id to retrieve templates" ).upon_receiving("return all templates for mpid").with_request( method="GET", path=api_path, query=req_query_param, headers=req_headers, ).will_respond_with( status=200, body={ "templates_are_approved_for_auto_select": None, "templates": EachLike( { "id": 1, "asset_id": "<any-uuid>", "factory_source_id": 1, "factory_id": "1", "is_manual_selection": False, "status_id": 3, "associations": [ { "association_id": 1, "association_source": 1, "imagery_template_id": 1, "id": 1, } ], "manufacturer_part_id": 1, "class_id": 1, "bounding_box": { "minimum_width": 34.0, "minimum_height": 35.0, "minimum_depth": 1.0, "maximum_width": 40.0, "maximum_height": 40.0, "maximum_depth": 3.0, }, "gs_type_name": "WallMirrorLargeRound", "optimized_for_automation": "No", } ), }, )```

jayeshguru81
2022-10-31 12:11
templates is an array of templates

jayeshguru81
2022-10-31 12:12
I want to just match 1 template

tomknee1
2022-10-31 13:25
Hello :wave: I am trying to do a `pact-broker describe-version` command for a latest pacticipant in environment `prod`, but am having trouble as it looks like you can only use a `--tag` in the command, but we instead use branches and environments so when i do something like ```pact-broker describe-version -a ProviderService --l prod``` I get `Pacticipant version not found` any ideas please?? :pray:

jason.taylor2
2022-10-31 13:55
has joined #general

kedar.ghate
2022-10-31 14:02
has joined #general

tomknee1
2022-10-31 14:18
Context: We want to `record-support-ended` for previous release on provider side when we `record-release` for new version, but getting the previous image tag (previous provider version in prod) is proving difficult due to our setup. Is it possible we could just do `record-deployment` for prod environment here instead as that would auto `undeploy` the previous version? would that work ok once we get to the next steps of `can-i-deploy` etc ??

tony.nguyen
2022-10-31 15:43
Hi, has anyone seen this issue when contract publishing in pact CLI using pactflow version 1.21.0? ```Exception: ArgumentError: comparison of Integer with nil failed```

yousafn
2022-10-31 17:06
that is a very old version from 2017 https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.21.0 is that the correct version, and can you provide reproduction steps, the pacts you are publishing, and command executing

tony.nguyen
2022-10-31 17:10
We are using the paid Pactflow version of 1.21.0 with the Pact CLI docker with the latest tag.

yousafn
2022-10-31 17:33
Ok thanks for that, If you can add more detail, it would be helpful :+1: https://docs.pact.io/help/how_to_ask_for_help#4-ask-a-good-question

yousafn
2022-10-31 17:40
Just tested cross platform against ubuntu/windows/macos (although in GH there are no docker available in macos/windows) so that is using on those platforms the standalone binary https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.91.0 and the latest pact broker ruby gem. could you try dropping back a docker tag, and check if that solves it https://hub.docker.com/r/pactfoundation/pact-cli/tags publishing provider contracts https://github.com/pactflow/example-bi-directional-provider-postman/actions/runs/3363396234/jobs/5576478237 publishing consumer contracts https://github.com/pactflow/example-bi-directional-consumer-cypress/actions/runs/3363395811/jobs/5576479432 (failures are due to can-i-deploy not having a registered provider :+1:)

tony.nguyen
2022-10-31 18:13
dropping pactflow back to 1.20.0 worked for us. Was there any major changes in 1.21.0? https://docs.pactflow.io/docs/on-premises/releases/1.21.0

jwheatley
2022-10-31 18:17
General question here after feedback from my dev team. We have a proof of concept implemented with Pact right now in our CI pipeline across 2 teams. One complaint I am hearing is that since Pact does not test data changes, only changes to the endpoint structure, we aren't really catching anything important. We usually do not encounter changes to our endpoint structure. What are peoples' thoughts on this critique?

tony.nguyen
2022-10-31 18:36
@yousafn is the publication of the above pacts against the 1.21.0 Pactflow?

yousafn
2022-10-31 19:40
It's against the SaaS version not the onprem Changelog for the Broker changes are part of the OSS Broker, so all the commits are visible https://github.com/pact-foundation/pact_broker/blob/master/CHANGELOG.md I would raise a support message at , someone may raise the issue against the open source broker, if they can recreate it

yousafn
2022-10-31 19:45
What do you mean by data change? do you have an example scenario that isn't passing? If you remove a field from a provider, that a consumer relies on, or change the fields type, it would fail verification. depending on your type of matchers setup on the response. if the data change, isn't due to structure, but due to actual identifiers (you require a book with a specific id to exist) you would use provider states for the provider to setup the required state prior to running the test in a decoupled fashion. Otherwise the alternative in an integrated environment is setting up external state which could be affected outside of your test (which is bad)

yousafn
2022-10-31 19:48
It isn't a replacement for other types of testing, but rather compliments it and provides quicker feedback and enhanced visibility, some teams may decide they want to use alternative methods, they may have really good channels of communications, endpoints and payload structures don't change often, or systems aren't that critical. Systems that don't change now, will invariably change in the future, either intentionally or accidentally. Having safety blankets helps :slightly_smiling_face: people in teams move on, people come in with new ideas.

jwheatley
2022-10-31 19:54
Thanks for responding, @yousafn! Things we see change are changes in business logic, like...someone changes what types of data an endpoint can accept...but didn't realize that impacts another team. For example, changes like having data in a certain state, like 'finalized,' that causes issues downstream.

yousafn
2022-10-31 19:55
oh interesting question, I haven't tried if `record-deployment` also unmarks `released` versions. You could try in the Broker UI and filter by environment and pacticipant name in the matrix view. It should be listed in the matrix, as to which version is in the environment :slightly_smiling_face:

jwheatley
2022-10-31 19:56
we use cypress to test our individual services, but need to mock out the downstream services in the CI pipeline. We still then have this issue where business logic changes are causing uncaught bugs.

yousafn
2022-10-31 19:56
I don't think its available via the CLI but should be available via the Broker API, you can view the HAL client in the broker UI to check all the link relations for particular pacts, and make auth calls. The Aus team should be able to help out later when they are up :slightly_smiling_face:

yousafn
2022-10-31 20:00
where are you testing with Pact? through Cypress, or at a unit test level directly with Pact? You can restrict values by enums, with a regex matcher. if the data needs to be different for a particular state `finalized` vs `pending` then you can setup tests for that, but only if they are because of specific client logic, otherwise you can just have one test. You don't want to be looking to functionally cover all cases for the provider.

tomknee1
2022-10-31 20:23
thanks, so I?m looking at parsing this previous version in a CI job that records provider release in prod, ideally in something like a bash script step in our CI workflow or similar so I can then `record-support-ended` for it. Currently we only have access to `.Values.image.tag` and not the previous one unless we do some refactoring. Our consumer side is fine as we support all releases basically forever. Provider service is backend though and we only ever support one version at a time, whatever the latest release in prod is. Was thinking a potential easy solution/workaround is if we just `record-deployment` to prod for provider instead of `record-release` , then the previous version will get automatically undeployed by Pact and it saves us the hassle of figuring out how to retrieve and parse the previous image tag/provider version in prod, unless like u mention there is a relatively easy way via Broker API or similar.

tomknee1
2022-10-31 20:57
looking at HAL browser now struggling a bit to see how i can easily get latest provider version on branch `main` and environment `prod` :thinking_face:

yousafn
2022-10-31 21:04
You could run a local provider verification with consumer version selectors set to released, and the providers name, set publish results to false and it will pull back the versions matching that selector, might be quicker than navigating the APi

tomknee1
2022-10-31 21:05
hmm, is the only difference between `record-release` and `record-deployment` that `record-release` doesnt automatically unrelease previous version? Are there any other differences that might affect `can-i-deploy` for example?

yousafn
2022-10-31 21:06
is your provider using `record-release` although it only ever has one live?

tomknee1
2022-10-31 21:07
yes

yousafn
2022-10-31 21:07
if you run `can-i-deploy` for consumer, it should list the all provider application versions deployed or released in the environment

tomknee1
2022-10-31 21:07
and were thinking of changing it to record-deployment

yousafn
2022-10-31 21:07
so there should only be one provider version returned, if only one is released

yousafn
2022-10-31 21:08
I believe they are separate, as there are seperate consumer version selectors, deployed, released, and deployedOrReleased. Sounds like you want `record-deployment` on provider for sure and `record-release` on consumer side if the consumers are indefinitely supported :slightly_smiling_face:

tomknee1
2022-10-31 21:09
right, i guess the issue I?m actually having is i added a `contract_requiring_verification_published` webhook and when it kicks off the provider side verification, its verifying against versions I don?t need to due to not doing `record-support-ended` on previous provider releases to prod

tomknee1
2022-10-31 21:10
ah yeah ok great, thats what i was thinking, if i can leave `record-release` on consumer side which we have already and then change to `record-deployment` on provider side that might work

yousafn
2022-10-31 21:13
contract_requiring_verification_published webhook should trigger once for each build (head of main branch) and any deployed or released versions. and provide a seperate SHA for the provider to checkout, and the pact url that has changed. you can add into the webhook template, the provider version number, so when the webhook is kicked off, you have the data of the version number, but can i deploy consumer into env, will list back the version number of the provider that is recorded in prod (as a release) If you want a way to cross over, once you find out the version number of the current prod that was marked as released, you can mark that application version as deployed. unrecord the release, and then you are happy to move on forward.

tomknee1
2022-10-31 21:17
> If you want a way to cross over, once you find out the version number of the current prod that was marked as released, you can mark that application version as deployed. > > unrecord the release, and then you are happy to move on forward. sorry im a bit confused, i still need to record the provider version in prod as a release, and then mark it as deployed? i cant just do `record-deployment` in prod for provider release?

yousafn
2022-10-31 21:18
I would need to test it out, but I don't believe. 1. recording a deployment, will do anything to the released version

yousafn
2022-10-31 21:19
so if you do record-deployment you will have a released version as well. (which I assume you want to unrecord) but you don't want to do it before you have a provider version `deployed` to production, You can test it out easily with a fresh pact broker on your local machine you get yourself in the same state :+1:

tomknee1
2022-10-31 21:21
i guess im wondering why i need a release too then, cant i just simply only do `record-deployment` for prod provider?

yousafn
2022-10-31 21:22
Only because you said you have already recorded a release for the provider but you don't know the version number

tomknee1
2022-10-31 21:22
i know the current version, just not the previous

yousafn
2022-10-31 21:22
if you have never marked a provider version as deployed or released, then there is no issue, or nothing to test. What is your current state on both sides exactly

tomknee1
2022-10-31 21:22
as when we `record-release` we would want to stop supporting previous

tomknee1
2022-10-31 21:23
earlier i manually unsupported older releases when cleaning things up

yousafn
2022-10-31 21:23
record-deployment will undeploy deployed versions only, not released versions is my assumption

tomknee1
2022-10-31 21:24
ooh i see so id need to move current recorded release to recorded deployment

tomknee1
2022-10-31 21:24
but then going forwards, simply `record-deployment` should suffice ?

yousafn
2022-10-31 21:25
yes if you only have one current recorded release for the provider. to get parity now, I would record-deployment of provider, with the current released application version. then you can unrecord-release and just stick with record-deployment on the provider side, to support only 1 live application version in an environment

tomknee1
2022-10-31 21:25
thank you so much that makes sense now :smile:

yousafn
2022-10-31 21:27
consumer side will want every version that goes into an environment marking with record-release. :+1: sounds good matey! Good luck. You should test out my assumptions before you proceed if you want to be doubley sure. Quick broker you can spin up here to test :slightly_smiling_face: https://github.com/pact-foundation/pact-broker-docker/blob/master/docker-compose.yml

tomknee1
2022-11-01 17:32
Hello, anyone possibly have any ideas why I occasionally get this error in CI doing a Docker run command for publishing pacts? (In thread as on phone so can?t format properly)

tomknee1
2022-11-01 17:33
Status: Downloaded newer image for pactfoundation/pact-cli:latest /usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'JleHAiOjQ3NjMwNTkyMDAsImlzcyI6ImxvbmctbGl2ZWQtand0LXNpZ25lci1zZXJ2aWNlLWFjY291bnQiLCJuYmYiOjE2MDk0NTkyMDAsInN1YiI6IjQxMTAwMDM3In0.TEXRtG4YB3WeYeINiIU-ycdAV-0AlHGG3o5T9EZoxDig4QgkSA0leahQatiTONedX5X13DyZ-jyoiFu_aqe4a-NA6DUTGaj_LGt_6YFUBgTP2DjWdND-8sXsW6wu32w4STcY7LFvrIiliXe1iIeMKoE1D7gSvS533yUcCaeSdNpjwKYHH5iPFTAJjE1Sd-yh9s-wjphiv-NXdxCOGomN-xWpnQPPgZRaXKhH34GrGgnfiLhTos1Et1v_d2zXckOePEFiunYaoZKe_lnowIb7g7waseF2hmRQUy--XeoQq_g0lmkk-EkCpmFEMOJlVBODWtm4mbjc4qUNnT2frbeNsg" (JSON::ParserError) }, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "matchingRules": { "$.body.token": { "match": "regex", "regex": "^[A-Za-z0-9\\\\-_=]+\\\\.[A-Za-z0-9\\\\-_=]+\\\\.?[A-Za-z0-9\\\\-_=]*$" }, "$.headers.Content-Type": { "match": "regex", "regex": "application/json(;\\\\s?charset=[\\\\w\\\\-]+)?" } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.5" }, "pactSpecification": { "version": "2.0.0" } }, "provider": { "name": "OtacProviderService" } } ' from /usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/pact_file.rb:20:in `consumer_name' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/publish_pacts.rb:145:in `consumer_names' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/publish_pacts.rb:60:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/publish_pacts.rb:33:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/publish_pacts.rb:15:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/cli/pact_commands.rb:66:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/cli/pact_commands.rb:29:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.65.0/bin/pact-broker:10:in `<top (required)>' from /usr/bin/pact-broker:25:in `load' from /usr/bin/pact-broker:25:in `<main>' |

daviseago
2022-11-02 05:57
Hi, does pact test helps only when both consumer and provider use it? what if I want to test my system?s contract with 3rd party system, but the other side doesn?t use pact?

abubics
2022-11-02 06:01
There's a whole FAQ about that :wink: https://docs.pact.io/getting_started/what_is_pact_good_for#what-is-it-not-good-for But, short answer, yes (that doesn't give you the best value).

daviseago
2022-11-02 06:07
I see. Thanks. Then I?ll reconsider using it internally where both sides are under our control.

matt.fellows
2022-11-02 06:58
I think we have an AMA on that: https://docs.pact.io/help/amas

matt.fellows
2022-11-02 06:58
yep:

tjones
2022-11-02 07:17
I usually still write a pact test even if I'm not going to verify the contract. However, when you do that, pact is no better than any other mocking tool (and you get very little confidence out of the test, since you are marking your own exam). The reason I do it is so that I have the pact file in case I ever _can_ verify it.

usama.mumtaz
2022-11-02 09:45
has joined #general

tomknee1
2022-11-02 11:02
Hello, we have successfully added the `contract_requiring_verification_published` webhook, but I am now wondering if we need to add a webhook to trigger consumer build when provider verification is published or not, I see it in the diagram but its not clear if I actually need it or not, as once I add `can-i-deploy` I can use the `--retry-while-unknown` parameter? Or am I missing something obvious here? Thanks

matt.fellows
2022-11-02 11:06
WOOT!

matt.fellows
2022-11-02 11:06
I?d hold off adding that webhook until you have a need, personally

tomknee1
2022-11-02 11:06
ok thanks so i guess i should do `can-i-deploy` as next step in my pact journey then?

tomknee1
2022-11-02 11:07
what is normally the need for that webhook?

matt.fellows
2022-11-02 11:44
> what is normally the need for that webhook? (edited) There are probably some use cases that are now no longer required because of newer functionality (e.g. pending, wip etc.). In most cases, there shouldn?t be any ?gaps? with what?s described in the Nirvana guide/workshop

tomknee1
2022-11-02 11:47
ok thanks :slightly_smiling_face:

jayeshguru81
2022-11-02 13:27
Bumping this

gsouza
2022-11-02 14:29
has joined #general

gsouza
2022-11-02 14:32
:wave: Hi everyone! I'm using http://pact.io to create an poc in my company and ai have have follow the steps and here is the output after run the test: ```[2022-11-02 14:26:59.845 +0000] ERROR (23344 on Ghsouza): pact-core@13.11.0: !!!!!!!!! PACT CRASHED !!!!!!!!! The pact consumer core returned false at 'withResponseBody'. This should only happen if the core methods were invoked out of order This is almost certainly a bug in pact-js-core. It would be great if you could open a bug report at: https://github.com/pact-foundation/pact-js-core/issues so that we can fix it. There is additional debugging information above. If you open a bug report,``` is there anything that i can do it to avoid this message?!

tomknee1
2022-11-02 15:42
Hello again, one last question on `can-i-deploy` please? We have one consumer app `Foo` that consumes let?s say 2 different providers We have all our provider verification tests etc in place for only one of those providers. For the other provider, those verification tests have not been added yet and we only have the consumer side expectations/tests done. This thus fails in `can-i-deploy` step because one of the providers hasnt got any verification tests/results, and we are using the same consumer name pacticipant `Foo` in all cases, as its all the same single consumer app. I can see a way around this would be to use different consumer pacticipant names for our contracts between provider `A` and our contracts between provider `B`, but is this the correct approach? Shouldn?t we just have one consumer pacticipant? But then what do we do in the situation where we are still waiting on provider tests to be added for a provider? Thanks.

yousafn
2022-11-02 16:14
Hey, I would raise an issue on the repo suggested in the link, and provide some repro steps as the message is indicating something is wrong. It may be erroneous but it is worth checking out. Are your pacts being generated correctly?

yousafn
2022-11-02 16:15
Hey buddy. I would create a minimal reproducible example on GitHub so it?s easy for a volunteer to pick up the codebase and see if they can provide an answer by experimentation, as a source of being able to help assist them, to assist you :the_horns::skin-tone-4:


jayeshguru81
2022-11-02 16:19
ok got it thanks will tty to do

yousafn
2022-11-02 16:26
Running cid with retry is good. You publish your pact, if it needs verification, an event is emitted and a webhook kicks off the provider build for a contract requiring validation ( by pact url ) this reports a successful verification Consumer can I deploy will return a result after the provider has performed their verifications based on the builds The retry mechanism is nice here as the consumer can deploy straight after all the necessary verifications are complete. The diagrams and flow on the path to nirvana need updating at the moment to reflect the new ci/cd workshop. I think there will be less steps, and as it will no longer be using tags, both for environments and branches, and uses the new webhook which ensures changed pacts are verified on the latest of the main branch, and any deployed or released versions There are alternative means. The consumer for whatever reason may mechanisms and purposes for webhooks. A provider verification successful result, you may want to report back in a GitHub pull request status check, or trigger the consumers build to run. If you can provide a diagram of your pipeline setup we can help advise on or discuss a suitable workflow.

tomknee1
2022-11-02 16:54
Yep thanks the retry mechanism in can-I-deploy works well but have another question now that I posted separately :)

gsouza
2022-11-02 16:57
Will do, thanks @yousafn

tjones
2022-11-02 21:07
There's a good second reason that is worth calling out - I already know how to use pact. So if I _just_ use it for mocking without verification, I don't have to learn a tool that is explicitly for that

tjones
2022-11-02 22:44
As a workaround, you can ask can-i-deploy about the specific consumer and provider, rather than the environment

tjones
2022-11-02 22:45
That way you don't have to use different consumer names, but you do have to remember to change it back when the other provider has tests

tomknee1
2022-11-02 23:32
Sorry do u have an example please?

tjones
2022-11-02 23:32
I don?t, but I think you can give can-I-deploy the consumer and provider names (it allows you to specify multiple)

tomknee1
2022-11-02 23:34
Hmm I?ll check the docs again in the morning but I?m currently unsure how I could provide two pacticipants in one command

tjones
2022-11-02 23:34
just specify twice

tjones
2022-11-02 23:34
it supports repeat parameters

tomknee1
2022-11-02 23:35
Right but I wouldn?t want to check can I deploy for provider from consumer pipeline ?

tjones
2022-11-02 23:35
`pact-broker can-i-deploy --pacticipant Foo --pacticipant Bar`

tomknee1
2022-11-02 23:35
Bit confused now

tjones
2022-11-02 23:36
Yes, usually you wouldn?t. This is a workaround for the problem of wanting to exclude the provider that has no tests

tomknee1
2022-11-02 23:36
Hm thanks so u would recommend this over different consumer participant names ?

tjones
2022-11-02 23:36
From the docs: > Can I deploy the latest version of Foo with tag ?master? and the latest version of Bar with tag ?master? together? ```$ pact-broker can-i-deploy --pacticipant Foo --latest master \ --pacticipant Bar --latest master```


tjones
2022-11-02 23:37
> different consumer participant names ? This will live for a long time

tjones
2022-11-02 23:37
it will be hard to undo

tjones
2022-11-02 23:37
changing the can-I-deploy check will be easy

tomknee1
2022-11-02 23:38
That makes sense ye

tomknee1
2022-11-02 23:38
Thanks

tjones
2022-11-02 23:39
you?re welcome! Let us know how you go

tomknee1
2022-11-02 23:41
Ah wait using ?latest is for the legacy tagging way, I don?t use tags would I have to now for this workaround?

tjones
2022-11-02 23:42
I think it works with other methods


zhangjingqiang
2022-11-02 23:49
has joined #general

bmorton
2022-11-02 23:58
has joined #general

matt.fellows
2022-11-03 01:52
The fact your tests are passing leads me to think there is an issue with your setup. It shouldn?t be possible for your expectations to pass, but that specific explosion to happen. So there is at least two bugs - one with Pact and one in your tests

andrew.brindle
2022-11-03 10:44
has joined #general

gsouza
2022-11-03 14:08
just to be sure, how can i check this: *`pacts being generated correctly`* *tks!*

vladislav.ledniov
2022-11-03 14:13
has joined #general

jonathan
2022-11-03 16:43
has joined #general

jwheatley
2022-11-03 18:33
We are testing Pact at the unit test level directly with Pact. Is testing client logic like this recommended for Pact?

jwheatley
2022-11-03 18:35
Do folks commonly do this sort of thing with Pact?


ldicesaro.scvsoft
2022-11-03 20:55
has joined #general

jwheatley
2022-11-03 20:57
@ldicesaro.scvsoft is the dev from my team. I invited him to the thread :slightly_smiling_face:

ldicesaro.scvsoft
2022-11-03 20:58
Thanks Jane, hey Yousaf! I'll read the thread.

ldicesaro.scvsoft
2022-11-03 21:21
I have a question, Yousaf. Pact will validate only the communication between the services. (I mean endpoints). So if we want to emulate an E2E we need work together with the unit tests. Pact for communication and unit tests for functionality, right?

ldicesaro.scvsoft
2022-11-03 21:31
Technical questions: ? We are using the `webmock` gem (see https://docs.pact.io/getting_started/comparisons#how-does-pact-differ-from-webmock) in our unit tests (ruby specs). If we want a client (consumer side) to be validated with Pact we should make a copy of that client to point it to the Pact mock service. What is the best practice here? Should we make a copy, or should we replace `webmock` for that client? ? When we define specs on the Consumer side, and we want to generate a pact file, we need to define the request body/response body/headers and finally, execute the code. That's fine. The thing is that we need to code trivial expectations (https://docs.pact.io/implementation_guides/ruby/readme#4-write-a-failing-spec-for-the-animal-service-client) too. I understand the expectation on functional tests. But in these cases, there is no a complex logic in the middle, we are testing the Pact tool itself. What is the purpose to create expectations of something we defined a few lines above? I await your responses. Thanks

matt.fellows
2022-11-03 22:18
When the tests run, it should write a pact file to a folder somewhere (usually `./pacts`

matt.fellows
2022-11-03 22:18
I?d like to see your code if we can, so we can help diagnose

gsouza
2022-11-04 00:30
@matt.fellows can i share the repo and also a video overview ?

carlosmarange
2022-11-04 06:09
has joined #general

stevet
2022-11-04 06:31
has joined #general

seikyo.cho
2022-11-04 08:58
has joined #general

poornimakrishnarajan
2022-11-04 13:56
has joined #general

jwheatley
2022-11-04 16:18
@yousafn does this seem like something you have knowledge about?

ldicesaro.scvsoft
2022-11-04 16:51
Should we post it in a new thread maybe? :thinking_face:

tanyaryzhova93
2022-11-04 18:38
Hello, could you please tell me if Pact can be used for non-HTTP protocols? Can it be used in AWS, for example for eventhubs? If you have a documentation, please share :pray:

jwheatley
2022-11-04 19:13
i think so :slightly_smiling_face:

ldicesaro.scvsoft
2022-11-04 20:55
I'm new in this group, I mean I'm not an expert but maybe you should read this Pact documentation about https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact

tanyaryzhova93
2022-11-04 21:47
Nice, thanks a lot! I missed this one :+1:

ldicesaro.scvsoft
2022-11-04 22:23
Hey people. I have a few questions. Please, let me know if I should post them on a specific channel. Thanks :thread:

ldicesaro.scvsoft
2022-11-04 22:23
We are working with Ruby on Rails. We implemented Pact until thehttps://docs.pact.io/pact_nirvana/step_5. The questions are: ? We are using the https://github.com/bblimke/webmock gem (see https://docs.pact.io/getting_started/comparisons#how-does-pact-differ-from-webmock) in our unit tests. We chose an existing HTTP client (on the consumer side) to be validated with Pact. We made a copy of that client to point it to the Pact mock service, and we could successfully generate the Pact file and validate the provider. The pro is that we didn't change the existing code, and the con is that we need to maintain two mock definitions: one for Pact and one for webmock. What is the best practice here? Should we replace every HTTP client occurrence? ? When we want to generate a Pact file, we need to define the request body/response body/headers, create a spec, and finally to execute the code. That's fine. The thing is that we need to code trivial expectations (https://docs.pact.io/implementation_guides/ruby/readme#4-write-a-failing-spec-for-the-animal-service-client) too. I understand the expectation on functional tests. But in these cases, there is no complex logic in the middle. We are testing the Pact tool itself. What is the purpose creating expectations of something we defined a few lines above?

michalkras
2022-11-05 01:05
has joined #general

abubics
2022-11-06 23:37
Since you're on Rails, you might be interested in #pact-ruby, but these questions are more general philosophy, so here makes sense :thumbsup:

abubics
2022-11-06 23:38
When you say "make a copy of that client", do you just mean "instantiate it with different parameters"? Because that's exactly how it's intended, so it sounds like you're on track.

abubics
2022-11-06 23:41
You can use whatever tools you like together, the maintenance burden is a tradeoff to consider. Pact has done helpers for stripping matchers out of its mocks, in case you want to use those to reduce duplication. I think there's also a stub server (which I haven't used), if you're thinking of replacing wiremock completely.

abubics
2022-11-06 23:43
When you say "should we replace every HTTP client occurrence", I'm a bit confused. If you have an API client that encapsulates all the interactions, you shouldn't need to be replacing anything :thinking_face:

abubics
2022-11-06 23:48
On the "coding trivial expectations" part, if you're just writing things that are exactly represented by the Pact response, you don't need to add any assertions in your unit testing framework. The rest of the answer depends on how much logic you want to test around the edges. For example, on the consumer side, I parse the responses into domain classes, so there's a validation translation that happens, and I usually want to assert that the JSON is correctly converted.

ldicesaro.scvsoft
2022-11-06 23:57
Thanks for your answers, Boris. I'll think about this and ask again if there are any more questions.

abubics
2022-11-07 00:05
np, good luck :party_parrot: reach out any time :sunglasses:

maria.botnari
2022-11-07 12:07
has joined #general

tomasz.sosnowski
2022-11-07 13:52
has joined #general

bpadhalni
2022-11-07 15:26
has joined #general

jonathan
2022-11-07 16:38
Hi all - I'm investigating using Pact on a project and have read through all the docs, but could use help better understanding what sort of test cases to use pact for. A few questions: - Is contract testing mainly about catching breaking structural API changes? If it goes beyond that, how do you determine where to draw the line between functional tests? - If there are several ways we can populate an update (PUT) request which lead to different values in the response, would we want to test several of those, or just one overall test for an update? - We have some large requests that encompass several smaller components. Do we want to have tests that cover the entire large object in addition to tests for the smaller components?

tjones
2022-11-07 18:04
> Is contract testing mainly about catching breaking structural API changes? It depends. I would say contract testing is about confirming whether two systems are able to communicate - in some system designs, this will mainly be about catching breaking structural API changes. > would we want to test several of those, or just one overall test for an update? Test each communication scenario - each time you would be exercising a different meaning or a different code path, add a test for that. Think of it as contract-by-example. > large requests that encompass several smaller components. I don't think I understand this question. Could you elaborate on what you mean by component?

tjones
2022-11-07 18:09
> how do you determine where to draw the line between functional tests? The reason we don't recommend functional tests driven by pact is because the pact is defined at the consumer side, but you would be testing the functionality of the provider. The consumer doesn't (necessarily) know what the functionality of the provider is. Consider a "create this user" request - the provider will know what the valid username rules are (eg, you're not allowed that character, or this user already exists). The consumer will want to be able to understand several different types of response (say "that user was created", "that username isn't valid" and "that username is taken"). You'd want to have a test for each type of response that you care about, but it's not convenient to have a test for each scenario that might create that response - because if you did you would tightly couple the consumer's tests to the provider behaviour.

tjones
2022-11-07 18:09
I would recommend not using pact to drive functional tests, but I also wouldn't _avoid_ functional coverage. As in, it's ok if a pact test happens to exercise some functional code.

tjones
2022-11-07 18:12
> Is contract testing mainly about catching breaking structural API changes? There's another subtlety that might be worth pointing out there- because Pact is consumer-driven, you're not describing the whole API surface, or even necessarily the whole response payload. You're describing the parts of the API or payload that you're actually using. Removing a part of the payload that no consumer is using wouldn't be a breaking contract change, even if it might be a breaking structural change.

tjones
2022-11-07 18:17
The responsibility of contract testing is to test the communication boundary. You can think of it as a unit test that covers the "unit" made of the API code in both services For functional tests, those are more the responsibility of the unit tests on the provider side.

jonathan
2022-11-07 18:49
Thanks for the responses! > Test each communication scenario - each time you would be exercising a different meaning or a different code path, add a test for that. Think of it as contract-by-example. Hmm, that sounds a bit like functional testing to me. Maybe a bit more about my situation would be helpful. My domain involves managing clustered "deployments" of services. We have one request/resource representing a deployment that you can update in different ways, which somewhat represents different use cases. For example, updating a deployment's version causes it to be upgraded. Upgrading a deployment's node count causes it to be scaled out. These are different use cases, but are accomplished via the same "update deployment" request/API. Would it be appropriate to contract test each of these since the structure of the request is the same, and only the contents of the requests and responses differ?

jonathan
2022-11-07 18:54
Somewhat related to the above, when we write a contract test, what is it exactly that we're trying to exercise? Is it the serialization/deserialization logic that ensures compatibility between requests and responses, along with validation of a request? Or are we trying to test all the ways that different values in some request can lead to different values in a response? The former seems more related to the API contracts and the latter seems more related to functionality.

tjones
2022-11-07 18:58
Ah, I see what you're asking. I would say that the contract test covers the serialisers and the API calling / receiving code. In the case of multiple different responses but with similar structure, it can be helpful to add a case for different responses - for example, say you could have a response that is: ```{ "status": "deployed"}``` and ```{ "status": "updating"}``` then it's useful to explicitly cover those: "given some service exists, then a request to update that service, responds with the status: updating"

tjones
2022-11-07 18:59
For me, the difference here is that the contract test is saying "I understand `{ "status": "updating" }` to mean that the service is updating", but you're not actually checking whether it is

tjones
2022-11-07 19:00
Having explicit tests for this, over: ```{ "status": <any string> }``` means that you would catch a case where say the provider responds with `UPDATING` and the client doesn't understand it

jonathan
2022-11-07 19:15
Thanks. Another example that might help clarify things for me, say I have a request that looks like this: ```{ "applicationCount": 3, "applicationConfig": ... }``` and leads to a response like this: ```{ "applications": [ { "endpoint": ... "credentials": ... }, { "endpoint": ... "credentials": ... }, { "endpoint": ... "credentials": ... }, ] }``` I imagine it would make sense to assert that _some_ value for applicationCount and applicationConfig leads to the appropriate response, but not necessarily that various different values do. Does that seem right?

tjones
2022-11-07 19:23
Yes, that?s right. To determine where I stop enumerating scenarios like that, I would think about what risk the test is reducing, if that makes sense?

tjones
2022-11-07 19:23
So you might want to ensure that the different kinds of config can be specified

jonathan
2022-11-07 19:26
Thanks, yea, there are use cases we certainly want to test, I'm just trying to figure out how we draw the line between making something an end-to-end or integration test vs a contract test. For example, the difference between an "upgrade" vs an "upscale" use case for us is just changing one field vs another in the same request document. How that impacts the API response is minimal, but how that impacts the rest of our system is big.

jonathan
2022-11-07 19:27
In that case, maybe we'd want a contract test, but we'd still want some other forms of testing to make sure that what happens afterwards is functionally correct.

tjones
2022-11-07 19:27
Right, yes. Contract testing is about understanding - can service A understand service B. This is important because it?s cheaper to test that with a contract test than an integration test, and that can give you deployment confidence

tjones
2022-11-07 19:27
100%, yes

jonathan
2022-11-07 19:28
Cool, yea so is it fair to say that contract tests can replace e2e or integration tests to the extent that they're asserting API compatibilities, but that asserting correct functionality is still needed separately?

tjones
2022-11-07 19:28
To get the same confidence with an integration test you would need to deploy exactly the same version of all of your dependencies as you have in prod. For most ecosystems this is not practical

tjones
2022-11-07 19:28
Yes, exactly

tjones
2022-11-07 19:29
It is possible to almost completely replace e2e tests this way- as then your functional tests can be within each service

tjones
2022-11-07 19:30
I usually then just do light touch e2e to confirm that the configuration and combination of services is correct (eg urls and so on)

jonathan
2022-11-07 19:31
Re: one of the other questions above: > Do we want to have tests that cover the entire large object in addition to tests for the smaller components? > I don't think I understand this question. Could you elaborate on what you mean by component? Sure, for example, say we have a "create deployment" request that has a few different sections in it: ```{ "databaseConfig": { "nodeCount": 3, "nodeSize": "4G", "partitions": 24 }, "proxyConfig": { "nodeCount": 3, "nodeSize": "4G", "loadBalancing": true } }``` Would we want to create separate test cases to assert that the `databaseConfig` or `proxyConfig` are individually valid, or a single test case for the entire request?

jonathan
2022-11-07 19:32
The challenge is that our API might require both of those sections in the request.

tjones
2022-11-07 19:33
Ah, I understand. To answer that it might depend a bit on how many combinations you have. I had a similar case with a document description that had several different possible section types in arbitrary combinations- so I had contract tests for each type of section, and then one ?here?s an example complex doc?

tjones
2022-11-07 19:34
Right, for ?I require these to be together? it?s good to have an example with them together

matt.fellows
2022-11-07 22:48
I think @tjones deserves a whole meal, and not just a :taco: for this thread! :clap:

jonathan
2022-11-07 23:09
Yes, thanks Timothy!

tjones
2022-11-08 00:17
You're so welcome! Let us know how you go

jonathan
2022-11-08 04:36
Should a consumer test assert that the contents of a response correspond to the contents of a request?

jeroen.vandijk
2022-11-08 08:57
I appreciate your effort in all your thoughtful answers @jonathan (this one, and many others) I've learned a lot from them!

ajay.chinnam
2022-11-08 10:08
has joined #general

sprengo
2022-11-08 10:57
has joined #general

james.ferguson
2022-11-08 12:33
has joined #general

james.ferguson
2022-11-08 12:36
Hi team, I am setting up pactflow for our business and it seems that we've merged two accounts into one. Depending on who's screen you look at (all admins in the same org) we get different information about our subscription, billing, etc. Can you please provide support to ensure we're all on the same 'instance' of pact? Thanks

matt.fellows
2022-11-08 12:38
Hi James, just FYI this is best asked in #pactflow

matt.fellows
2022-11-08 12:38
but for now, your best bet is to drop a ticket to so the team can look into your case and fix it

james.ferguson
2022-11-08 12:38
Ok, thanks Matt

matt.fellows
2022-11-08 12:39
it _sounds_ like you might be logged into different URLs?

james.ferguson
2022-11-08 12:39
Same URLs...

james.ferguson
2022-11-08 12:44
Same Org, both logging in with Google Auth. Everything is the same except our subscription & billing :hmm:

matt.fellows
2022-11-08 12:50
I?ll DM you

gururaghavendrar98
2022-11-08 13:04
has joined #general

gsouza
2022-11-08 18:41
@matt.fellows here is the link for the repo that i said earlier: ? https://github.com/Ghsouza1/poc-contract-testing ? also some loom videos that i did: ? https://www.loom.com/share/1f35a2e0471940b493b21fb1c4ff6d7b ? https://www.loom.com/share/57a22f37cbf14c87b6dac1c010ca67fa let me know if you need something or even better schedule some huddle, tks!

tjones
2022-11-08 18:51
> Should a consumer test assert that the contents of a response correspond to the contents of a request? I'm not 100% on what you're asking here - I think there are two interpretations, so I'll answer both: If you're asking about what to put in the contract (whether to be specific `"status": "deployed"`, or general with a matcher `"status": any string`), then it depends. If it's part of the expectation of the consumer, then yes. For example, if you say "I'd like to change the status of this object to 'deployed'" and the resulting object is returned in the response, then yes, it should be in the contract. Another yes scenario might be where the consumer relies on it being a specific value (eg, if you're switching display logic on `deployed` vs `not-deployed` or something). If you're just displaying it, then no, it doesn't matter. A good guide for "should I use a matcher here" is to realise that using a matcher isn't a description of the response schema, it's a promise that all responses that pass the matcher are covered by the test that you've written.

tjones
2022-11-08 18:54
If you're asking whether you should assert in your test that the response you asked for was returned, then yes, you should do this. The reason is because you're testing that your unmarshaller is built correctly. In some languages (eg js) this is usually a no-brainer, because you often just unmarshall the payload into an object with `JSON.parse()`. But, the test is "does the response I am expecting unmarshall into the business object I am expecting", which is worth including in your test for completeness even if that's a 1:1 mapping.

jonathan
2022-11-08 18:57
Thanks - yea I noticed some of the example consumer tests basically just assert that a response deserializes successfully, but others assert the contents of the response either using a matcher or an exact match. Here's an example consumer test where an exact match is being performed: https://github.com/pact-foundation/pact-go/blob/master/examples/messages/consumer/message_pact_consumer_test.go#L36 It sounds like that kind of thing is ok if the value being exactly matched is meaningful for the test.

tjones
2022-11-08 18:59
That?s right. The matchers really are a convenience thing for the provider team (so they don?t have to have identical test data)

tjones
2022-11-08 18:59
This is especially useful on eg, get requests

jonathan
2022-11-08 19:00
The downside of that test above is that the provider team has to ensure that the StateHandler they use for that test populates "name": "Baz" in the provided object?

tjones
2022-11-08 19:00
Like ?get a user has a username field, which I promise I will understand if it is a string?

tjones
2022-11-08 19:01
Right! That example is a great one. That should (in best practice) be a matcher, not a specific string

jonathan
2022-11-08 19:28
(Starting a new thread since this is a somewhat different topic) - I have a messaging use case where a service consumes a message and emits one or more messages in response, which are in turn consumer by other services. I can use pact to assert that the consumed message is as expected, but I'd also like to assert that the emitted messages are as expected, based on the consumed message, similar to how pact works with Http request/response tests. Here's a diagram to illustrate what I mean. The labels on the left indicate how each service emits messages that are derived from the message it consumes. But really, this is similar to a request/response flow, which the labels on the right illustrate. I'd like to be able to verify this type of situation by asserting the incoming messages (requests) and the emitted messages (responses) for each service. Any thoughts on this? Is there a way to accomplish this?


matt.fellows
2022-11-08 21:00
Thanks!

steven
2022-11-08 23:09
has joined #general

alan.barr
2022-11-09 03:14
has joined #general

bas
2022-11-09 12:43
I'm working with a client on their contract testing implementation, and we're currently doing CDCT with Pact. I could use some views on how and where to make the consumer and provider test steps part of the respective pipelines. Services deploy to a DEV environment multiple times a day through a PR build process. At some point, a release candidate is put together for deployment into a QA environment. Not every PR leads to a new artefact version, hell, most of them don't (i.e., the version in the pom.xml), and I'm not even entirely sure that every RC does (but I'm checking that at the moment). I would love to see both consumer contract generation and publishing tests, as well as provider verification tests, run as often as possible, i.e., on every PR build, no matter what the change is. The earlier we can catch integration issues, the better.. However, I'm not sure if it is possible to publish changes to a contract without an artefact version bump? If that's not possible, I think we need to start having a serious talk with the various dev teams to get their versioning in order.. I'd love to hear some experiences from others about the frequency with which they run their contract tests, what that brought them and what things they had to keep in mind. How much do you really shift to the left with your contract tests?

wojciech.bachur
2022-11-09 13:55
has joined #general

arek92
2022-11-09 13:58
has joined #general

dariusz.duleba
2022-11-09 14:00
has joined #general

tjones
2022-11-09 18:51
Pact doesn't do this, but I think it should. You might be able to put something together that does it by wrapping the message pact interfaces, but it would be custom. I'm working on an alternative framework that will support this (and ideally be pact-compatible), but it's not ready for use yet.

tjones
2022-11-09 18:55
This versioning problem is actually exactly the use case that I wrote https://github.com/absolute-version/absolute-version-js to solve - it allows you to get between-release version numbers that are both human readable and correct. (some teams just use the git sha, but I found that less nice because they're not really human readable)

tjones
2022-11-09 18:55
It currently works off git tags, but it would be easy to extend it to read pom.xml, especially if that would be useful to you.

tjones
2022-11-09 18:57
What I usually do is: ? Generate version numbers with absolute-version ? Every commit is contract tested ? Every commit is deployed to dev ? Every release is tagged and deployed to <other environments>, assuming that the can-i-deploy passes

jonathan
2022-11-09 19:12
Interesting, can you ping me when there's something to share? Either here or .

jonathan
2022-11-09 19:14
As I thought more about this, I think it's fair to want to test this type of use case, but I'm not sure if a contract test is the appropriate place to do it. Because when service A sends a message to service B, it's true that service B emits a "response", but that response flows down to service C rather than back up to service A. So who/where would the assertion of that response live?

tjones
2022-11-09 19:16
It depends. There's an analogy to DB requests, like an http request to get a resource might. result in a request to a DB. You'd have a contract where you say: http request -> http response and you could have another contract where you say DB request -> DB response (for example - we don't actually have DB contract tests). You wouldn't want: http request -> DB request

tjones
2022-11-09 19:16
But, you might have a different case, where eg a translation layer for messages - where you might say: some message -> http request

tjones
2022-11-09 19:17
For me, this comes back to the contract test is for "can these two services talk to each other"

jonathan
2022-11-09 19:18
Yea that's a good point, though I did read in the guidelines that the DB example gets into the realm of functional testing, where shouldn't care about whether a DB is involved. That makes sense to me.

tjones
2022-11-09 19:18
I think the general case that you're hitting here is: some request -> some response But sometimes that's asynchronous

jonathan
2022-11-09 19:19
Yea, it's asynchronous, and the "response" flows down to another service rather than back to the originator of the first message (which makes it more of a reaction than a response).

tjones
2022-11-09 19:19
So, the contract of "can my http client talk to the http server" doesn't include "did the http server make the right DB call"

tjones
2022-11-09 19:20
Similarly, "can Service A understand the message it gets" won't include "did it send a message to Service B", for _most_ cases

tjones
2022-11-09 19:21
Translation layers are a really good counterexample here - like: ```Client -> BFF -> Backend request``` where say the BFF does passthrough, or a slight payload refactor

tjones
2022-11-09 19:22
In that case "did I send the right request further down" is actually part of the contract, I think

tjones
2022-11-09 19:23
"Can the client and the BFF understand each other" can't really be answered by the BFF - it depends on whether the BFF and the backend can understand each other

tjones
2022-11-09 19:23
pact doesn't handle this especially comfortably at the moment

jonathan
2022-11-09 19:24
The catch is that we don't want Service A to know anything about what Service B might emit. But we do want to assert that Service B emits something appropriate when it consumes a message from Service A.

jonathan
2022-11-09 19:25
Which is why I wasn't sure if that particular assertion should be part of a contract test. Maybe it's just a unit test inside Service B.

jonathan
2022-11-09 19:27
So a unit test would assert that an input results in some outputs as expected, and contract tests would assert that those outputs are compatible with the next service(s) down the line.

tjones
2022-11-09 19:28
> But we do want to assert that Service B emits something appropriate when it consumes a message from Service A. Right! I wouldn't do this with the contract test from service A, unless it's part of the communication with service A

jonathan
2022-11-09 19:28
...we just wouldn't be able to contract test anything across more than 2 services at a time.

tjones
2022-11-09 19:28
like, it's probably an expectation of service A (eg, hey service B, please save this in your storage)

tjones
2022-11-09 19:30
In most cases, I would do: ? Contract test on Service A with the message it receives, confirming that it unmarshals into the expected business object ? Unit test in Service A that confirms that the expected business object would be processed into a request for Service B (probably I mock the service B message sending client completely at this point) ? Contract test in Service A that covers the code that was mocked in the previous step

tjones
2022-11-09 19:31
Not sure how clear that description is, sorry :confused:

jonathan
2022-11-09 19:32
Yea that makes sense.

tjones
2022-11-09 19:34
> So a unit test would assert that an input results in some outputs as expected, and contract tests would assert that those outputs are compatible with the next service(s) down the line. Yes. You could equivalently say that a contract test asserts that an input (the call to the client code & the actual request on the wire) produces the expected output (returned business object from unmarshalling the actual response on the wire). That is, a contract test is a unit test that crosses service boundaries.

matt.fellows
2022-11-09 23:13
> However, I?m not sure if it is possible to publish changes to a contract without an artefact version bump? If that?s not possible, I think we need to start having a serious talk with the various dev teams to get their versioning in order.. :laughing:

matt.fellows
2022-11-09 23:14
Using the git commit SHA as the contract version is definitely the easiest first step, but Tim?s absolute version utility is a big improvement.

matt.fellows
2022-11-09 23:16
The issue here is the usual POM versioning strategy is semver or ?this is the thing we are working on and then will release? version vs what Pact needs - which is a unique identifier per code change (which is why the git SHA is a good default).

matt.fellows
2022-11-09 23:19
> I?d love to hear some experiences from others about the frequency with which they run their contract tests, what that brought them and what things they had to keep in mind. How much do you really shift to the left with your contract tests? it should really be every single build, and also run on dev machines prior to commit. In the case of the provider, it should be tested against a locally running version of the software with external dependencies stubbed out (i.e. a so called ?hermetic server?) (image taken from https://docs.pact.io/getting_started/testing-scope)

matt.fellows
2022-11-09 23:21
In some organisations, the provider API is run on technology stacks that can?t be run locally for various reasons (e.g. vintage technology like IBM WebSphere or large runtimes that are just not practical). In those instances, you?ll need to run the Pact tests against a test environment - this is a bit harder to manage and provide general advice for, but the general rule would be ?as often as you can? :)

bas
2022-11-10 07:45
Thanks @matt.fellows and @tjones, really appreciate your input. Running the tests (both consumer and provider parts) locally isn't the issue, we're doing that already (yay for Spring and mocking external dependencies). The versioning is the biggest challenge here. I'll bring that input back to the teams. Thanks again!

matt.fellows
2022-11-10 09:44
Ah perfect! then you've already solved the hard technical problems, this should be the easy bit (famous last words)

bas
2022-11-10 12:35
Yeah, because convincing others to change their ways of working has always been the easy part of consulting :wink: I'll keep you posted.

matt.fellows
2022-11-10 14:00
*Your favourite contract testing solution is now Pact with more power* :zap:*?* We?ve been tempting you for some time... and now we officially launch the Pact Plugin Framework - the missing piece to help you add contract testing to _all_ your applications. If you?ve been held up applying contract testing to a specific use case ? protocols like Protobufs, GraphQL, transports such as gRPC, Websockets and MQTT, Event Driven Architectures and data pipelines or emerging standards such as AsyncAPI and CloudEvent ? consider the blockers abolished! Developers can now build plugins for their custom needs, whether they open source the plugin or keep it closed source for in house only usage. Members of this channel will know this is a substantial innovation. By having a single generic interface, the Plugin Framework side steps the problems of requiring the input of core maintainers to support a new feature and its constituent concepts that must be built into each client language. *What to get started?* ? :computer: Join the launch webinar with @yousafn and me on Wed 30 Nov & Thurs 1 Dec (https://docs.pact.io/events/plugins-framework-launch) ? :books: Get stuck into https://docs.pact.io/blog/2022/11/11/pact-plugin-framework-launch

tjones
2022-11-10 17:57
My original plan was to have absolute-version available natively for the JVM too - so if you would find it useful, but don't want a node tool, let me know what the needs are and I'm happy to build it (it's not a substantial amount of work)

jayeshguru81
2022-11-10 17:58
Is session recorded and sent on channel or to the only people attending?

gsouza
2022-11-10 18:55
would you know what is the reason for that error message below: ```Test failed for the following reasons: Mock server failed with the following mismatches: 0) The following request was expected but not received:```

tjones
2022-11-10 18:59
It means you told pact to expect that request, but it didn't receive it.

tjones
2022-11-10 19:00
Usually one of: 1) You're not sending that request 2) You are sending that request, but not to Pact

gsouza
2022-11-10 19:01
got it, i did exactly the same as https://docs.pact.io/implementation_guides/javascript/docs/consumer but using my own endpoint! is there any link or steps to check those points that you said?

tjones
2022-11-10 19:02
I'm not sure what you're asking. Check that you're sending that request, and check that you're sending it to the pact mock server

gsouza
2022-11-10 19:03
just asking how to check if i'm sending the request and also sending to pact

tjones
2022-11-10 19:04
Read your code, and if it looks right, then run it through a debugger

cgodsey
2022-11-10 19:45
has joined #general

aforeman
2022-11-10 22:44
Hey @jayeshguru81 we will record the webinars and share with registered attendees :slightly_smiling_face: so please register for either session.

bas
2022-11-11 12:08
Thanks @tjones for the offer, I really appreciate it. You're right in that I prefer not to introduce a NodeJS tool (or rather, the runtime itself), but I'm going to try and let them use commit hashes first to make them feel the pain of that, hopefully that'll lead to them doing better on their versioning :slightly_smiling_face:

bas
2022-11-11 12:09
I might ask you again about this at some point, though!

tomknee1
2022-11-11 22:13
really awesome stuff :slightly_smiling_face:

saweniger
2022-11-14 17:29
has joined #general

matt.fellows
2022-11-15 07:50
Interesting in seeing a plugin get created, or perhaps want to contribute? Here is a https://pact.canny.io/feature-requests?category=plugins&sort=top of some of the most popular protocols/transports we see come up often in our chats with users - please vote :white_check_mark:

miguel.roldan
2022-11-15 11:06
has joined #general

robin.lungwitz
2022-11-15 13:32
has joined #general

laith
2022-11-15 16:15
has joined #general

elluru.kri.mohan
2022-11-15 18:14
has joined #general

rmartine
2022-11-15 20:35
has joined #general

sameena9010
2022-11-16 06:49
has joined #general

leon.luu2
2022-11-16 16:32
Hi! I wonder if it is possible for the provider in bi-directional testing to publish the openapi spec without any provider test?

yousafn
2022-11-16 16:43
hey, yes you can, just upload the api def as the test result file, or just use a text file with any text in. as the `verification-results` the results of the provider self verficiation of compliance with the api spec, is defined by the `verification-exit-code` or `verification-success` / `no-verification-success` once uploaded, it is compared to any registered consumers pact file

leon.luu2
2022-11-16 16:51
I manage to upload but got failed error as "Your Provider Contract Is Not Compatible With The Provider Codebase" as provider verification result. How can it be pass?

leon.luu2
2022-11-16 16:57
nvm, it was the flag verification-success which controlls it, I understand it now. Thanks!

ryanthomas840310
2022-11-16 20:52
has joined #general

mike.hideaki
2022-11-16 21:48
has joined #general


vwaters
2022-11-16 22:31
has joined #general

ryanthomas840310
2022-11-16 23:33
Hi. I have a question about the pact broker can-i-deploy behavior. It's a fairly easy use case to work around and I'm not sure if this is specific to the pactflow broker I was using or if the behavior is the same in the open source pact broker. When testing a proof-of-concept bi-directional contract testing setup I found that the `can-i-deploy --to-environment <environmentname>` behavior for the api provider is somewhat unexpected when no environment deploys/releases have happened to the environment yet. In this scenario I would expect that the `can-i-deploy` behavior would not select any pacts for verification because none are in that environment. Instead I found that the behavior was selecting all of the pacts. i.e. 1. Consumer creates first test and uploads pact contract .json (version abcdef1) [from local machine] 2. Provider uploads open api schema (version xzy1) [from local machine] 3. Looking at the pactflow UI we see there are inconsistencies and fix them. 4. Consumer uploads pact contract .json (version abcdef2) [from local machine] 5. Setup proof-of-concept CICD for consumer 5a. Consumer CICD uploads pact contract version (abcdef3) 5b. Consumer CICD calls `can-i-deploy --to-environment production` and gets a 'No' response because no api deployment to production has been recorded. ^ This is the behavior I would expect 6. Setup proof-of-concept CICD for provider 6a. Provider CICD uploads open api schema version (xyz2) 6b. Provider CICD calls `can-i-deploy --to-environment production` and gets a 'No' response. The response shows all 3 consumer contracts (abcdef1, abcdef2, abcdef3) despite none of them being in production. And because abcdef1 is not valid is returns a no. ^ I would expect this to select none of the contracts in scenarios where no consumer version has been deployed to production yet.

matt.fellows
2022-11-17 03:17
Awesome work @jaswanth.ooty!

matt.fellows
2022-11-17 03:20
> 6b. Provider CICD calls `can-i-deploy --to-environment production` and gets a ?No? response. this behaviour is unexpected to me also. Are you able to share a view of what Pactflow sees (e.g. screen grab from UI matrix page for the provider) so we can understand why? Also, there is a can i deploy page in Pactflow. A screengrab of a populated version of that screen would be helpful too (if not for you, for us to help understand) P.S. this is also a #pactflow specific feature, might best ask there next time.

bas
2022-11-17 09:59
Hey @matt.fellows coming back to this, how can I easily add the commit hash to the contract version number? It looks like that's the way to go for now.. But I can't find how to in the docs. Also, can you confirm that the hash performed to see if a contract has been updated in the broker does not include the version number? I.e., the contract isn't actually seen as 'new' unless some expectation changes?

bas
2022-11-17 10:12
Keep in mind we're using the `pact-jvm-provider-maven` plugin to publish consumer contracts

tjones
2022-11-17 10:16
The version number isn?t in the contract file, so it?s not considered for the hash

tjones
2022-11-17 10:17
I don?t know the answer to the other part of your question though, sorry

bas
2022-11-17 10:17
Ah I think I got it... `<projectVersion>${project.version}-${git.shorthash}</projectVersion>`

tjones
2022-11-17 10:18
That? looks like maven, yes :sweat_smile:


bas
2022-11-17 10:18
Thanks @tjones!

tjones
2022-11-17 10:18
Welcome!

bas
2022-11-17 10:19
Now to test if it actually works but for that I need to wait until the ops people provide me with a working broker :slightly_smiling_face:

tjones
2022-11-17 10:19
The contract hash in the broker is a straight up hash of the contract file. The broker is actually pact agnostic- you could use it for any other file

bas
2022-11-17 10:19
Oh that's nice to know!

tjones
2022-11-17 10:20
I can recommend pactflow for that in good conscience, because I don?t work for them. But my experience is that it is definitely easier than maintaining your own.

tjones
2022-11-17 10:20
(Of course, your situation may be different)

bas
2022-11-17 10:24
I'd be 100% in favour of Pactflow, too, I recommended my client using that but for reasons we're going the OSS route for now

bas
2022-11-17 10:24
(long story)

bas
2022-11-17 10:59
Hmm.. `${git.shorthash}`isn't resolved so that is appended to the contract version literally.. Not exactly what I was looking for!

bas
2022-11-17 10:59
Is that a plugin thing?

bas
2022-11-17 11:04
I've found this but the shortcodes are different: https://github.com/git-commit-id/git-commit-id-maven-plugin

bas
2022-11-17 13:38
@matt.fellows do you happen to know how I can get Pact to recognize that `${git.shorthash}` shortcode as seen here (under Publishing Pact files to a Pact broker)?

yousafn
2022-11-17 18:27
A lot happens in 10 years. We?ve seen it all here at Pact, from the proliferation of micro services, to ever increasing protocols like Protobufs, GraphQL, transports such as gRPC, Websockets and MQTT, EventDrivenArchitectures and data pipelines or emerging standards such as OpenAPI, AsyncAPI and CloudEvents. As we launch our Pact Plugin Framework bringing you new possibilities to the Pact eco-system, I?d like to invite you to try an interactive history lesson of Pact, from past, to present and beyond! http://docs.pact.io/blog/2022/11/17/pact-facts-a-history-lesson

juergen.unfried
2022-11-17 20:43
has joined #general

matt.fellows
2022-11-18 03:37
I have no idea sorry Bas, but I reckon @uglyog might. Ron, any ideas? That being said, I like to encourage use of the Pact CLI if you can: https://docs.pact.io/implementation_guides/cli#pact-broker-cli Maven is?.not fun

uglyog
2022-11-18 03:46
Just reading the comments. I think either Maven doesn't replace the expression if the system property is not defined, or it does not support expressions in that form. The best thing to do would be pass it on the command line (i.e. add `-Dpact.projectVersion=...`)

uglyog
2022-11-18 03:47
Oh, I see your issue. You've copied the example. That assumes something is setting `git.shorthash` system property. That is not the default Maven behaviour (Maven knows nothing about Git)

uglyog
2022-11-18 03:48
Try adding `-Dgit.shorthash=...` to your command line (replacing the `...` with the actual Git SHA, of course)

matt.fellows
2022-11-18 04:01
Ah! That makes sense! Thanks Ron. So basically, define outside of maven however you wish (Bash, Powershell, scripts) and pass as a system property. Does Maven support environment variables in the same places as system props?

uglyog
2022-11-18 04:03
> Does Maven support environment variables in the same places as system props? Please refer any Maven questions to the Maven people

tjones
2022-11-18 05:24
https://github.com/git-commit-id/git-commit-id-maven-plugin <-- you can use this to get `git describe` output, which is very similar to what absolute-version does (the main difference is that absolute-version is semver compatible)

bas
2022-11-18 08:05
Cheers folks! I thought it maybe was a feature I didn't know of. Looks like I'll have to take a closer look at that plugin (or see how to pass it through the CLI). I'd like to stick to Maven (yes, I said that) because so much is managed through Maven in this org I'm working with, probably easier to educate people that way.

nicholas.simons
2022-11-18 10:29
Good morning! The pact nirvana doc set (which is great, by the way!) describes how to use the broker in CI/CD pipelines. I'm wondering: are the tests designed to be run locally also (alongside unit tests)? I see value in running the consumer-side tests, as they can fail if they can't generate a pact. But to run the provider-side tests, the machine on which I'm running the tests needs to be connected to a network over which pacts can be pulled from the broker. Is the preference not to run provider-side tests locally, or to fall back to reading pacts out of a folder, or to ensure everyone has access to the broker?

bas
2022-11-18 10:46
Hey @nicholas.simons, I'd definitely prefer using a broker, that's (in my opinion) the only fail-safe way to make sure you always have the latest contracts and versions. By all means run your provider-side tests locally, too (I think that's a great idea) but you'll need that network connection to the broker (running either 'in the cloud' or somewhere within your company network)

bas
2022-11-18 10:47
Let's put it this way: is there another way to make sure, without human intervention, that you have the latest contracts in your local pact folder?

nicholas.simons
2022-11-18 11:00
Hi, As you imply, there is no way to ensure I have the latest pacts in my local folder: a system of caching pacts into a folder so that locally I'm at least testing against a relatively new pact seems complicated and of little value because as soon as I push code to my CI tool, the pipeline would run and test against a pact from the broker anyway. If it's convenient enough for the devs on my team, I'll go with fetching from the broker locally; the second-best option looks like disabling the provider test locally, and only running after pushing code to the CI tool (or on a webhook trigger). Thanks for your reply!

jose.anastacio
2022-11-18 13:34
has joined #general

shawn305
2022-11-18 13:42
has joined #general

tronghuy
2022-11-19 01:38
has joined #general

tjones
2022-11-19 05:21
> I'd like to stick to Maven (yes, I said that) You don't have to explain yourself to us :wink:

matt.fellows
2022-11-21 07:02
> Cheers folks! I thought it maybe was a feature I didn?t know of. Looks like I?ll have to take a closer look at that plugin (or see how to pass it through the CLI). I?d like to stick to Maven (yes, I said that) because so much is managed through Maven in this org I?m working with, probably easier to educate people that way. No judgement :grimacing:

glauco.carvalho
2022-11-21 15:47
has joined #general

soner.ay
2022-11-21 16:57
has joined #general

gsouza
2022-11-21 18:52
@tjones how can i run through a debugger?

flafla.mattos
2022-11-22 19:10
has joined #general

jordan.nazemi
2022-11-22 20:10
In the situation where we have an API provider and an API consumer, are there any recommendations for which tool to use to generate pact files? Most of the workshops seems to be focused on a web app consumer. While we could theoretically just use Cypress to do the API testing and use the cypress-pact adapter to generate the pact file I'm just curious what others have used in the past with success.

matt.fellows
2022-11-22 20:32
Normally you?d just use Pact. The Cypress pact adapter is really only best suited when using Pactflow?s BDCT workflow, because it doesn?t use matchers etc. So it will result in brittle tests if you use Pact to verify them. Does this help or did I misunderstand the question?

jordan.nazemi
2022-11-22 20:39
Nope that answers it! I did forget to specify were specifically using the bi-directional testing model, which is why I suggested the Cypress-pact adapter as one of our tooling solutions.

jordan.nazemi
2022-11-22 20:40
With that in mind, is Pact still preferable to use over Cypress for BDCT? Do any workshops exist for using bi-directional between APIs providers/consumers?



chrisjburnscg
2022-11-22 22:11
has joined #general

matt.fellows
2022-11-22 22:15
> With that in mind, is Pact still preferable to use over Cypress for BDCT? The answer is always ?it depends?. BDCT is faster/easier, Pact has better guarantees

jordan.nazemi
2022-11-23 14:53
Ill take a look at these, thanks!

imer.muhovic
2022-11-24 08:57
has joined #general

mohitsoni
2022-11-24 10:19
has joined #general

celia
2022-11-24 14:32
has joined #general

alan.zhu
2022-11-25 02:31
Hey team I have one question, probably silly, about how to do a contain check in the response array in Pact. below is a sample, if I want to check id 995 in sections seems I have to check the whole exact array or use some thing like regular expressions, is there an easier way to check this?(if sections is a object I can just check id 955 and leave other object I don't want to check) ```{"sections": [ ... { "facilities": [ { "id": 433, "key": "Swimming Pool (2019 format)", "name": "Swimming Pool" } ], "id": 999, "key": "Top Facilities", "name": "Top facilities" }, { "facilities": [], "id": 995, "key": "Meals", "name": "Price for meals" }, { "facilities": [], "id": 997, "key": "Languages Spoken", "name": "Languages spoken" } ... ] }```

aaron.m.williams24
2022-11-25 03:32
Have you checked the arrayContaining function? That may help you if I'm not mistaken!

matt.fellows
2022-11-25 03:52
:dizzy_face:

matt.fellows
2022-11-25 03:53
Can you please explain what you want to test Alan? I?m not sure I understand the question. Do you want to check that an object in the list of arrays exists, that has the id `995`? Or do you want to check that each object in the list has an `id`?

matt.fellows
2022-11-25 03:53
(or something else)

alan.zhu
2022-11-25 04:14
Sure, first thanks Aaron's suggestion. arrayContaining could be helpful in this scenario but I didn't find this function in pact-python which I'm using now:disappointed_relieved:. The sections is an array and may contain hundreds of different objects. I want to check some of specific objects returned with correct name, key and facilities(exp?sections should contain object with id 995 with name "Price for meals", key "Meals" ...) I found it tough to describe my expect because pact will strictly check each index of object in an array and regular expressions(Term) seems much complex for this case

harald.bittermann
2022-11-25 10:01
has joined #general

harald.bittermann
2022-11-25 10:19
Hey Team, I read that pact is not the tool for testing proxies. Now we are currently checking out if pact would work nicely to contract test our microservices and I think we have a special case here. Eager to know your opinion. We have 4 services. Let's call them Consumer, Proxy, MasterProvider and DetailProvider. Proxy is, as the name suggests, a proxy and simply forwards all calls to masterprovider. Proxy does not know (much) about the requests it forwards. But it knows a bit. E.g. it knows that there has to be an auth header, if present it will be checked, if not the request will be rejected. But more importantly, it knows about a query parameter "detail". If set to true the response of masterprovider will be parsed. Again we do not care about how this response looks in detail we are only looking for one defined attribute in the json that contains an ID which will then be used to invoke DetailProvider. The results of this call will be embedded in the original response of Master within a metadata section. Our problem here is: ? How can our client be sure that the his request will be understood by Masterservice ? But without Proxy having any more knowledge about requests that he already has The strange situation here is that proxy is not the owner of the api, but howere he does have logic. Is this an example about "what not to test with pact". How would you make sure (with or without pact) that client test fails when MasterProvider changes its API

matt.fellows
2022-11-25 10:35
yeah, arrayContaining is unfortunately not supported in Python yet

matt.fellows
2022-11-25 10:35
The idea is usually to use provider states, and to limit the responses from the provider for that state, so that you don?t have to do these checks. But that is sometimes easier said than done

matt.fellows
2022-11-25 10:36
i.e. the state might be `given a facility with meals exists` and then when the provider verification happens, this state reduces the responses from the endpoint to the shapes expected

ad
2022-11-25 13:23
has joined #general

sree
2022-11-25 14:22
has joined #general

mwilso29
2022-11-25 14:42
Hi All, When I'm running `pact-broker create-webhook` in the pipeline I don't seem to get a UUID in response. Do you know how I can obtain it?

ad
2022-11-26 12:18
Hello. Is pact-php still supported? I waiting since March 2022 of a reply to an issue... https://github.com/pact-foundation/pact-php/issues/234

tomknee1
2022-11-27 14:04
hello, does anyone please know if it is possible via api or cli etc to get the latest version of a pacticipant within a given environment? (using environments rather than the legacy tagging way)

tomknee1
2022-11-27 14:09
hello, sorry to revive this thread but this has proven to be a bigger problem for us? as we use environments and not the legacy tagging, i don?t know a way that we can get the specific provider pacticipant versions within a given environment, and using `--to` or `--to-environment` still checks against all provider services (even ones not ready for can-i-deploy) the only command ive gotten working as a temp workaround, but is still less than ideal is ```pact-broker can-i-deploy --pacticipant ConsumerApp \ --version "$GIT_COMMIT" \ --pacticipant ProviderService \ --branch main``` which checks against the latest version on that `main` branch but not the versions in the environments. I don?t really want to have to refactor and add in legacy tagging just to be able to get the specific versions within environments either. Any ideas here please? :pray:

soumya.aithal
2022-11-27 17:15
has joined #general

sumitsg004
2022-11-27 18:39
Hello , I am starting with Contract test for my project. Is there any documentation on best practices and do's and don'ts that I can follow? If I can get any doc link or in general best practices to follow would be big help. Thanks


nathan.pine
2022-11-28 09:19
has joined #general

sumitsg004
2022-11-28 09:36
thanks :+1:, went through couple of them. This would be good to start

sanmicad
2022-11-28 12:20
has joined #general


yousafn
2022-11-28 14:17
Hey Anton, Pact-PHP is community supported, but the main author has been very busy for the last couple of years, so it gets occasional maintainence. Looking at your issue, appreciate the snippets you have provided, it might be worth seeing if you can fork the repository and create a test case that demonstrates the issue, to help aid others in their investigations. You may also be interested in reviewing the PR for the migration to the rust core, as help from the community in reviewing and testing that, would be advantageous as your issue could be caused by the ruby core used in pact-php

tomknee1
2022-11-28 14:23
To follow up on this, I have decided to go the route of creating a version tag right after we record deployment/release, this allows us to then do something like `pact-broker describe-version -a ProviderService -l $TAG -o json | jq '.number'` to get the needed provider version number, something i cant do without the legacy tagging currently, would be good if we could get provider version based on the new `environment` instead (maybe a feature request for future :slightly_smiling_face: )

tjones
2022-11-28 14:33
I would put feature requests here https://pact.canny.io/feature-requests or directly in #general to ensure that a maintainer sees it. Maybe ask in #pact-broker, too, if you haven?t already

tomknee1
2022-11-28 14:34
thanks will add it to canny :slightly_smiling_face:

ad
2022-11-28 14:42
Hey Yousaf, thank you for your reply. Do you know when should the Rust version would be released?

alan.zhu
2022-11-29 06:22
Hey team I have another question, about the execution orders of different states in Pact during verification. I met this scenario: saving the object by POST first, and then reading back the values from the appropriate GET request. I just ordered them with 'save' first then 'query'.It seems works in Pact But I still want a double check with you guys: are the use cases executed in strict accordance with the order in the pact?

matt.fellows
2022-11-29 06:27
No, you should not rely upon execution ordering

matt.fellows
2022-11-29 06:28
I?m sure it?s documented on http://docs.pact.io, but a quick search doesn?t show it

matt.fellows
2022-11-29 06:28
probably under best practices


sumitsg004
2022-11-29 06:44
Hello Team, I have a doubt regarding Provider state. As a consumer I want certain specific value to be returned from provider. Say I am consuming a field "RuleId" and I want provider to return "Rule-123". As a provider - I am supposed to hit the real running service and match the response with pact response. But to achieve my scenario, should I use Provider state and mock the response to return "Rule-123" ? Similarly for error scenarios - should I create mock response for each error scenario ? I might be wrong here, but I am confused like if I mock any response, then I am not validating real response but mock response. Kindly help to understand how provider side should be setup to achieve these scenarios mentioned above

tjones
2022-11-29 08:20
You should use provider states to mock something deeper in your service (like the data / repository layer), so that your response is really what your provider will return

tjones
2022-11-29 08:22
> But to achieve my scenario, should I use Provider state and mock the response to return ?Rule-123? ? This is partly what the matchers are for. You might have a request for a rule with `ruleId: "Rule-123"`. You could alleviate the requirement on mock data with: ```{ ruleId: "Rule-123", title: Matchers.string("Rule title") }``` This says the `ruleId` must be `Rule-123`, but you?ll accept any string for the title during verification.

tjones
2022-11-29 08:24
Basically you use the matchers to say ?I promise you anything that passes this matcher is covered by this test case?.


marcin.nawrocki
2022-11-29 09:25
has joined #general

sumitsg004
2022-11-29 09:29
Thanks Timothy for response. "You should use provider states to mock something deeper in your service (like the data / repository layer)" - Can you elaborate a bit on this one? If say "Rule-123" is coming from DB, I should insert that data beforehand in the DB and clear it after the test ? Or I can use Mokito and based on condition reply with appropriate response?

ringo
2022-11-29 11:58
Quick question: where can I download the standalone pact mock server (for Intel MacOS) mentioned in https://docs.pact.io/implementation_guides/rust/pact_mock_server_cli?


tjones
2022-11-29 13:34
It?s definitely easier to use the language specific DSLs though (unless there isn?t one for your language)

ringo
2022-11-29 13:34
I `start` the main mock server. After that, I `create` a new mock server from a pact file. The debug output of the main server shows this: ```13:29:03 [DEBUG] (18) pact_mock_server_cli::server: Starting mock server with id 49c8834c-661f-4b65-94ce-03d9384bb330 13:29:03 [DEBUG] (18) pact_mock_server::mock_server: Started mock server on 0.0.0.0:51714 13:29:03 [DEBUG] (18) pact_mock_server_cli::server: mock server started on port 51714 13:29:03 [DEBUG] (18) pact_mock_server_cli::server: Result of starting mock server: Ok(true) 13:29:03 [DEBUG] (4) pact_mock_server_cli::server: Result of thread: Ok(true)``` When I run `./pact_mock_server_cli list` after that, the `list` call hangs. This is the only debug info shown on the main server: ```13:29:30 [DEBUG] (11) hyper::proto::h1::io: parsed 3 headers 13:29:30 [DEBUG] (11) hyper::proto::h1::conn: incoming body is empty 13:29:30 [DEBUG] (11) pact_mock_server_cli::server: main_resource -> resource_exists 13:29:30 [DEBUG] (11) pact_mock_server_cli::server: main_resource -> render_response``` Am I doing something wrong? Any known issues with this?

tjones
2022-11-29 13:36
I don?t know - in most use cases, you don?t need to interact directly with the mock server like this. What are you trying to do?

tjones
2022-11-29 13:37
I agree with your steps, though - the docs suggest that what you?re doing is right.

ringo
2022-11-29 13:37
@tjones I understand, but I?m not using the mock server for the typical contract test setup. I?m using it to reproduce a bug in an existing CLI tool. The mock server substitutes a service we don?t have access to. Our customer provided what their setup returned, so I?m mimicking the CLI tool connecting to the service, returning the content as is.

ringo
2022-11-29 13:37
@tjones see the other thread on what I?m trying to do.

tjones
2022-11-29 13:38
Interesting!

tjones
2022-11-29 13:38
I assume it doesn?t work without the `list` command? What happens if you just start the server, and then try to use it?

tjones
2022-11-29 13:39
Have you tried not doing `start`?

tjones
2022-11-29 13:40
Ah, wait, that won?t help, according to the docs.

ringo
2022-11-29 13:40
The `list` command was already to debug the fact that my created mock server wasn?t responding at all.

tjones
2022-11-29 13:41
Yeah, I thought that might be the case.

tjones
2022-11-29 13:42
If your pact file is spec V2 or lower (or can be generated as such), you could try the Ruby mock server


tjones
2022-11-29 13:43
Otherwise you might have to wait for a rust core maintainer to come online (probably best to open an issue https://github.com/pact-foundation/pact-reference/issues)

tjones
2022-11-29 13:44
The team is in Australia, so they?re probably asleep now

ringo
2022-11-29 13:45
Thanks for the suggestion, but I?m going to stop investigating this way for now. I already have to debug our customer problem. Not going to debug the pact tooling on top of that. No offence.

tjones
2022-11-29 13:45
That?s very reasonable.

tjones
2022-11-29 13:46
The Ruby CLI has been around for a long time, so it?s likely to work for you - but it doesn?t support the more recent Pact spec versions.

tjones
2022-11-29 13:47
Are you able to share the pact file? I?d be happy to make the issue from there.

tjones
2022-11-29 13:48
understand if this is not possible, of course

yousafn
2022-11-29 13:48
If I read this correctly you are using the pact tooling, in your tool for your customer. I think it is completely reasonable that you raise debug steps for us to follow up. We don't expect you to debug it, but if you are asking for help here, and we are openly providing it, it would be kind to share a repro back

yousafn
2022-11-29 13:49
That way volunteers help is going back into helping the community if that makes sense :slightly_smiling_face:

ringo
2022-11-29 13:50
This is a small handwritten pact file, which I want to return the `body` when a `GET` is done on the given `path`: ```{ "provider": { "name": "PulumiService" }, "consumer": { "name": "PulumiCLI" }, "interactions": [ { "description": "History request", "request": { "method": "GET", "path": "/api/stacks/redacted_customer_name/redacted_project_name/dev/updates?output-type=service&pageSize=1&page=28", "headers": { "Content-Type": "application/json" }, "body": {}, "matchingRules": {} }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": {"updates":[{"info":{"kind":"import","startTime":1669315256,"message":"","environment":{},"config":{},"result":"succeeded","endTime":1669315256,"version":139,"resourceChanges":{"create":0,"delete":0,"same":58,"update":0}},"updateID":"3b1f14e2-bc4e-4b5a-8875-2a56c5fd0217","version":139,"latestVersion":139,"requestedBy":{"name":"","githubLogin":"redacted-user","avatarUrl":"https://avatars.githubusercontent.com"}}], "itemsPerPage":10,"total":139}, "matchingRules": { } } } ], "metadata": { "pact-specification": { "version": "3.0.0" }, "pact-jvm": { "version": "3.5.6" } } }```

ringo
2022-11-29 13:50
I only redacted some customer and user info.

tjones
2022-11-29 13:51
Awesome, thanks. It being hand-written is a good bit of info - I don?t know if much validation is done, as it expects the Pacts to be generated by Pact.

ringo
2022-11-29 13:53
@yousafn fair point. I?m only under time pressure to follow up on this Pact based setup. Need to find another way to get to the bottom of my customer issue first.

tjones
2022-11-29 13:53
Although at a glance it looks ok

tjones
2022-11-29 13:53
I appreciate that you?re a few layers deep, and not excited to debug the tool you?re using to debug a different thing. Thanks for the pact file!

yousafn
2022-11-29 13:53
No rush @ringo :yellow_heart: in your own time, we are here all the time :sweat_smile: Hope you get a happy customer in the end

yousafn
2022-11-29 13:55
> I appreciate that you?re a few layers deep, and not excited to debug the tool you?re using to debug a different thing. Thanks for the pact file! Can totally appreciate those frustrations budd. that is my everyday life - yak shaving :party-yak: :razor:

ringo
2022-11-29 13:55
FYI: I?m mocking our Pulumi Service REST API here: https://www.pulumi.com/docs/reference/service-rest-api/


yousafn
2022-11-29 13:58
Oh very cool, your companies name came up recently in conversation, I can't remember with whom, as something to checkout. I'm definitely interested in helping you get to the bottom of it eventually and learning a bit more about Pulumi on my journey. Your docs look fabulous

ringo
2022-11-29 13:58
I know. Matt contacted me recently.

yousafn
2022-11-29 14:01
Ah I see you are using Pact-JVM. AFAIK, the pact-jvm doesn't use the Rust reference implementation and has its own core. (or this pact was created with pact-jvm)?

tjones
2022-11-29 14:05
I don?t think your Pact file is the problem - I experience the same issue with a different pact file written by Pact-JS

tjones
2022-11-29 14:05
You aren?t using any V3 features, though - so you could just change the spec version and use the ruby standalone

tjones
2022-11-29 14:07
You would want the `pact-stub-service` binary

tjones
2022-11-29 14:10
Ah, your hand written pact file isn?t right - the query string should be separate to the `path`

tjones
2022-11-29 14:14
```{ "provider": { "name": "PulumiService" }, "consumer": { "name": "PulumiCLI" }, "interactions": [ { "description": "History request", "request": { "method": "GET", "path": "/api/stacks/redacted_customer_name/redacted_project_name/dev/updates", "query": "output-type=service&pageSize=1&page=28", "headers": { "Content-Type": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "body": { "updates": [ { "info": { "kind": "import", "startTime": 1669315256, "message": "", "environment": {}, "config": {}, "result": "succeeded", "endTime": 1669315256, "version": 139, "resourceChanges": { "create": 0, "delete": 0, "same": 58, "update": 0 } }, "updateID": "3b1f14e2-bc4e-4b5a-8875-2a56c5fd0217", "version": 139, "latestVersion": 139, "requestedBy": { "name": "", "githubLogin": "redacted-user", "avatarUrl": "https://avatars.githubusercontent.com" } } ], "itemsPerPage": 10, "total": 139 } } } ], "metadata": { "pact-specification": { "version": "2.0.0" }, "hand-written": { "version": "na" } } }```

tjones
2022-11-29 14:14
@ringo Here is a working pact file


tjones
2022-11-29 14:15
```pact-stub-service example.json```

tjones
2022-11-29 14:18
Then ```export PORT= <whatever was in the output of pact-stub-service> curl -H "Content-Type: application/json" "http://localhost:${PORT}/api/stacks/redacted_customer_name/redacted_project_name/dev/updates?output-type=service&pageSize=1&page=28"```

tjones
2022-11-29 14:19
Side point - I don?t think a GET request should have a Content-Type, but since that?s in the linked docs, I left it as is. I did remove the empty body from the Pact, as that wasn?t in the docs.

tjones
2022-11-29 14:20
Anyway, there?s a solution if you want to use pact tooling for this :raised_hands:

yousafn
2022-11-29 15:32
Hey, that hinges on this PR being reviewed and accepted. We do not currently have maintainer capacity (there is a single maintainer - original author, who has a busy day job), so bar me learning PHP on the fly (I've given a bit of a review), and those collaborators having the time, or energy to revisit the answer is, it depends. You could either ? Help review the PR ? Help test the PR ? Help finish up the PR ? Help raise awareness to other PHP Developers who would like the feature set to get involved either in the PR or getting involved in regular maintenance, contributions and reviews

ringo
2022-11-29 16:42
@tjones sorry I was silent until now, but I had a few customer calls. Will see if I can get it working. Thanks for your help already! :pray:

sergewar
2022-11-30 08:54
has joined #general

diego
2022-11-30 09:50
has joined #general

surya.sidharthan
2022-11-30 11:13
has joined #general

nicolas.chara
2022-11-30 13:16
has joined #general

sumitsg004
2022-11-30 13:21
Hi Team, I need some advise on writing contract test for negative (error) scenarios Is it necessary to contract test 5XX error responses ? or only 4XX should be done ? Any guidelines on this? 500 error response would be difficult to setup on provider side, is there a way to achieve that ? or should be mocked on provider side?

yousafn
2022-11-30 13:55
Always ask does my client care about this type of request I am encoding into a pact file, in your test. If your consumer code makes no distinguish between a 4xx/5xx or just bails on a non 2xx you would probably only want to test for a generic error. If you care a specific response code in your client code, then you can encode it. Otherwise you can just test that your api client doesn?t explode for consumers when it does get a 500, in your regular unit tests. It would maybe be nice if you could choose to exclude pacts from being serialised but still run selective tests, so you could do that functional testing of your consumer using pact as your mock, but without serialising all those cases into the pact and functionally testing the provider

yousafn
2022-11-30 13:58
howdy everyone! We are live in a few hours, come and join us, if you haven?t already signed up and check out some of coolest news in almost a decade of Pact :electric_plug:

sumitsg004
2022-11-30 14:16
okay. How about response header validation? I am new to Pact and contract test so please pardon my basic questions.

yousafn
2022-11-30 14:38
I would start with reading our pact docs and going through the cicd course and the pact workshop which is available in a few languages. It teaches about basic Pact concepts and moves onto matchers and authorisation

sumitsg004
2022-11-30 17:40
sure thanks

daniel
2022-11-30 18:30
has joined #general

denis
2022-11-30 22:07
has joined #general

dbarne24
2022-12-01 11:35
has joined #general

min.zaw.mra
2022-12-01 11:36
has joined #general

kevin.lau
2022-12-01 11:41
has joined #general

bojanmarjanovic1980
2022-12-01 13:09
has joined #general

ivona.sovic
2022-12-01 13:13
has joined #general

orbit
2022-12-01 15:45
has joined #general

david.dudley
2022-12-01 19:55
has joined #general

brian.coan
2022-12-01 20:22
has joined #general

j3rry.wan9
2022-12-01 21:22
Unfortunately I missed this webinar, is there a recording that can be shared?

shuying.lin
2022-12-01 21:34
:busts_in_silhouette: *Pact Open Source Community Annual Survey - 2022* :busts_in_silhouette: :blob-wave: Hello here, https://forms.office.com/r/ccxYTMxhJm is now open! The purpose of this survey is a pulse check on the community. In order to serve you best way, we'd like to understand how you use Pact and engage in our ecosystem. The data collected in this survey is anonymous. We intend to use the data to better serve you and to promote the Pact community. This survey has been compiled by @yousafn and myself. If you have any questions regarding the survey, feel free to send a direct message to us or leave your comments. We're looking forward to hearing your experience with Pact Open Source projects and the community. Cheers!

matt.fellows
2022-12-01 23:16
We?ll be sharing it through various channels next week, stay tuned :slightly_smiling_face:

manishmitraba
2022-12-02 02:16
has joined #general

lepdiana01
2022-12-02 03:53
has joined #general

dimundo
2022-12-02 08:03
hi! we are moving to `deployedOrReleased` and i want to clarify some stuff ? `record-deployment` will do same as getting latest from env tag ? like only latest matters in pact verification ? `record-release` - all marked matters in verifications until `record-support-ended` made for version ?

bethskurrie
2022-12-02 08:06
Yes

arpan.agr
2022-12-02 08:06
has joined #general

dimundo
2022-12-02 08:06
yay, thank you :slightly_smiling_face:

arpan.agr
2022-12-02 08:08
Hi Team, do you have any plan to integrate AsyncAPI format for pact based testing. The latest I could get was that the plugin framework has been released through which one can write their own plugin and make it open source in case they want to.

matt.fellows
2022-12-02 10:09
There are no plans to integrate Pact with AsyncAPI at this moment. AsyncAPI is a description format, just like OpenAPI which Pact doesn?t support either. See also https://docs.pact.io/faq#can-i-generate-my-pact-file-from-something-like-swagger. How would you see Pact + AsyncAPI working together? We are looking at integrating to AsyncAPI for Pactflow?s bi-directional contract testing feature, similar to what we have done with OAS if that?s what you?re asking https://github.com/pactflow/roadmap/projects/1?

arpan.agr
2022-12-02 12:25
Yes, my question was pretty similar to "Can I generate my pact file from something like Swagger". As a team I want to maintain the async api schema at a central place and then want to generate pact file against it. I know the limitation would be either random generated values or generating values from example given in the specification. And yes, the other part you mentioned for bi directional testing would also be helpful

goksel00
2022-12-02 17:41
has joined #general

rmartine
2022-12-02 19:17
Very informative webinar, thank you!

aibosun900614
2022-12-04 02:18
has joined #general

tomknee1
2022-12-04 14:32
Hello, does anyone know (or have examples) if its possible to have consumer tests generate pacts without using a `mockServer` and instead using something like `MockK` ? I have tried but get `PactMismatchesException` saying the request was not received

tomknee1
2022-12-04 16:50
I was looking at this example https://technology.lastminute.com/contract-testing-asynchronous-messaging-pact-junit-mockk/ but I cant get it working without using `mockServer`

matt.fellows
2022-12-04 22:31
As a general rule, you need to hit the Pact mock server. Otherwise it complains it can?t be use that your code did what it said and can?t serialise a reliable contract. Not sure how the lastminute folks are using it, maybe they are just mocking out other parts of the method call? Also the lastminute example is a message based example, which doesn?t have a mock server in the same way the HTTP one does

tjones
2022-12-05 02:43
Why would you want to do this?

tjones
2022-12-05 02:46
> `PactMismatchesException` This means the mock server did not receive the request ?. which isn?t surprising. The pact mock server is the thing that checks that your request looks like you said it would. It looks like the lastminute example is mocking out the repository layer of the service during pact verification - which is normal.

matt.fellows
2022-12-05 02:55
Yeah I think so too

matt.fellows
2022-12-05 02:55
What a lot of people want is a mocking experience like `MockK` but with the benefits of contract testing.

matt.fellows
2022-12-05 02:56
I understand that want, but we don?t have an ergonomic way of doing that right now.

tjones
2022-12-05 02:56
What does MockK do that Pact doesn?t?

tjones
2022-12-05 02:57
I guess I?m saying ? I don?t understand the want :sweat_smile:

matt.fellows
2022-12-05 02:58
For one, they don?t require the actual network call to be made.

matt.fellows
2022-12-05 02:58
That _could_ be done of course

tjones
2022-12-05 02:58
Oh, right - but, that doesn?t make sense

tjones
2022-12-05 02:59
> That could be done of course :thinking_face: ?but then you lose the advantage of Pact, which is to check that you *actually* are sending the thing.

tjones
2022-12-05 02:59
(or that you actually receive it)

matt.fellows
2022-12-05 03:00
> Oh, right - but, that doesn?t make sense Yes. Sort of. Obviously, the code should execute. In the sense that it needs to actually go through the whole network cycle is a separate thing. e.g. `nock` mocks the network layer and can do it in a way that?s pretty safe. The related thing is that you don?t need to configure your API client to point at the mock server, because the runtime can intercept it etc.

tjones
2022-12-05 03:00
if you mocked the API of some underlying system (eg a popular HTTP client or whatever), then you?re back in mock land, and the answer stops being ?yes, these two systems can communicate properly? and starts becoming ?maaaaybe these two systems can communicate?

matt.fellows
2022-12-05 03:01
yes, it?s mostly a trade off of those guarantees, against ergonomics and speed

tjones
2022-12-05 03:01
I don?t really see it being less ergonomic

tjones
2022-12-05 03:01
I think it would be more ergonomic to write bad tests, which is not ideal

tjones
2022-12-05 03:02
At the moment, yes, you have to be able to inject your API client?s configuration

tjones
2022-12-05 03:02
but that just encourages good practice

matt.fellows
2022-12-05 03:04
Agree. I?m keen to hear from our actual customer (Thomas - sorry mate :laughing: ), but the complaint that Pact tests are wordy and non-intuitive comes up _a lot_.

tomknee1
2022-12-05 08:31
Thanks guys, interesting discussion. Yeah, I?ve only got it to work with `mockServer` for now, which is ok for our needs.

tomknee1
2022-12-05 08:31
But the existing unit tests all just use `MockK` instead so thought it would?ve been nice if I can simply use `MockK` and still get the consumer expectations generated

tjones
2022-12-05 08:32
I don?t think I understand the need

tomknee1
2022-12-05 08:32
but using mockServer isnt too bad

tjones
2022-12-05 08:32
for example, you wouldn?t say ?these methods return strings, but the other tests are all using numerical assertions, so I was hoping we could use numerical assertions here too?

tjones
2022-12-05 08:33
MockK and Pact are for testing different things

tomknee1
2022-12-05 08:33
so it was more a question of using the two together instead of pact and mockServer

tjones
2022-12-05 08:33
(Unless I am missing something, which is quite possible)

tomknee1
2022-12-05 08:33
where u can mock the response without sending the network call to a mock server

tjones
2022-12-05 08:33
As I understand it - MockK would let you assert on object method calls

tjones
2022-12-05 08:34
whereas Pact lets you assert on actual http calls


tjones
2022-12-05 08:34
right, but then you wouldn?t be testing the network calls?

tjones
2022-12-05 08:35
Usually what I do is use (something like) mockK to test the API invocation, and Pact to test the actual API

tjones
2022-12-05 08:35
that is, say there?s some method like: `api.getUser(userId)`

tjones
2022-12-05 08:36
I would do something like: ```val testUser = User(...some details here..) api.getUser(1) <-- mock this to return testUser```

tjones
2022-12-05 08:36
^ I would do this for all the unit tests

tjones
2022-12-05 08:37
then, in a Pact test, I would test that (when not mocked) `api.getUser(1)` fires the request that I am expecting, and I would confirm that the object that I get back is indeed the same as `testUser`

tomknee1
2022-12-05 08:38
thanks that makes sense, thats actually what we currently do for our unit tests and pact tests

tomknee1
2022-12-05 08:38
so i guess ill keep it that way

tjones
2022-12-05 08:38
In this way, you can think of Pact as kind of a unit test for the API code

tjones
2022-12-05 08:38
Where the ?unit? is the pair of the client code and the network server code.

tjones
2022-12-05 08:39
Ok, that?s good. We?re on the same page. What I?m confused about (and interested to understand ) is how it would be easier if you could write the pact tests with mocks

tjones
2022-12-05 08:39
what would that look like?

tomknee1
2022-12-05 08:41
So right now I have a separate pact test class to the unit test class mainly due to using slightly different things like mockServer etc

tomknee1
2022-12-05 08:41
if it used `MockK` as we already have very similar unit tests, I would group it more with that

tjones
2022-12-05 08:42
As an example, could you write up a pact test in the way that you?d like to use it? Like, just assume the API/DSL you want actually existed - I think that would be helpful for me to see what you?re getting at

tomknee1
2022-12-05 08:42
sure can do later and will share here

tjones
2022-12-05 08:42
> So right now I have a separate pact test class to the unit test class mainly due to using slightly different things like mockServer etc This sounds normal to me

tjones
2022-12-05 08:43
One nice way we could improve pact is to reduce the repetition - at the moment, there?s often a repeated request when there are several possible responses to an API call (there?s usually at least two for every call - one for success, and one for failure)

tjones
2022-12-05 08:44
You can reduce some of that pain with nested tests, but I don?t know how well that would work with the JVM ecosystem

tomknee1
2022-12-05 08:45
yeah we?re not a fan of nested tests really in JVM as it can get messy real quick

tjones
2022-12-05 08:45
https://gist.github.com/TimothyJones/d138bf765509d41e0ce8a4bfb777a31d You might be interested in this (although it is largely obsolete now, and also about Pact-JS) - it has some of the things we were thinking about when we made Jest-Pact to improve the boilerplate on the JS side

tjones
2022-12-05 08:46
I agree. Every time I have tried it I?ve felt ?this seems worse, but now I?m not keen to change it back?

tjones
2022-12-05 08:48
Is the pain the DSL, the test time, or both?

tomknee1
2022-12-05 08:49
the dsl and test time arent too bad to be fair, its more having to setup the retrofit interface to use the mockServer etc

tomknee1
2022-12-05 08:49
id say its more a want than a need though to be honest

tomknee1
2022-12-05 08:49
like everything is fine as it is now

tjones
2022-12-05 08:50
Gotcha. That?s good news :sweat_smile:

tomknee1
2022-12-05 08:50
i kinda just saw that lastminute article and was like how?

tomknee1
2022-12-05 08:50
:smile:

tjones
2022-12-05 08:51
I?d be keen to see the hypothetical DSL if you get a chance though. In the worst case, it would generate an interesting discussion, and that?s a great worst-case

tjones
2022-12-05 08:51
haha! Yeah. I think it?s a bit confusing. I think as Matt said, they?re doing: Pact verification -> Their service -> some mocks

tomknee1
2022-12-05 08:51
sure will try to send something tonight, just woken up here in UK

tjones
2022-12-05 08:51
but it?s confusing because in Pact Message, the ?consumer test? is more like a verification

tjones
2022-12-05 08:52
No rush at all

tomknee1
2022-12-05 08:52
i see that kinda makes sense

mayank.mahajan04
2022-12-05 10:51
has joined #general

mailtoshinu
2022-12-06 07:42
has joined #general

sameena9010
2022-12-06 11:23
Hi, I would need to automate the grpc, events like kafka. Can someone point to me the right docs through which i can get started. Few open questions i have 1. Is it only through plugins ? 2. Is there any language limitation (looking mostly to use it with C#) ?

matt.fellows
2022-12-06 11:38
Best to join #pact-plugins my friend!

yousafn
2022-12-06 12:19
Happy Tuesday everyone, from wherever you are in the world. We would love your responses on this, as we want to make sure Pact is working for you. We are a small but passionate team in the open source, and we serve so many awesome people, it would be great to collect that real world feedback. Maybe you are an advocate of Pact? We can help raise your profile, and give you a soapbox. Maybe you are just plain confused or stuck? It?s okay, we were all there at some point. Help us make the journey frictionless for future users. After all, making quality software shouldn?t be that difficult, right?

dyptorden
2022-12-06 13:24
hi guys, trying to follow the example from the https://hub.docker.com/r/pactfoundation/pact-cli I get the following err: ```docker run --rm -w ${PWD} -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest publish ${PWD}/example/pacts --consumer-app-version fake-git-sha-for-demo-$(date +%s) --tag-with-git-branch fatal: detected dubious ownership in repository at '/home/myuser/workspace/pact-ruby-cli' To add an exception for this directory, call: git config --global --add safe.directory /home/myuser/workspace/pact-ruby-cli PactBroker::Client::Error - Command `git rev-parse --abbrev-ref HEAD` didn't return anything that could be identified as the current branch.``` ---------- running ```git config --global --add safe.directory /home/myuser/workspace/pact-ruby-cli``` doesn't fix the err ---------- running ```git rev-parse --abbrev-ref HEAD``` returns `master`

dyptorden
2022-12-06 13:24
any ideeas pretty please?

yousafn
2022-12-06 13:28
you probably aren't loading a git repo, try removing `--tag-with-git-branch` into the volume mount in docker.

yousafn
2022-12-06 13:30
is `${PWD}` your directory with a `.git` folder in it? `-v ${PWD}:${PWD}`

dyptorden
2022-12-06 13:31
removing the --tag-with-git-branch made it work

yousafn
2022-12-06 13:31
did you clone the pact-ruby-cli repo?

dyptorden
2022-12-06 13:31
yes

yousafn
2022-12-06 13:31
and cd into it,

dyptorden
2022-12-06 13:31
just cloned it and ran the command

yousafn
2022-12-06 13:32
checking now buddy :slightly_smiling_face: on my mac

dyptorden
2022-12-06 13:32
yes, cd-ed in it and ran it

dyptorden
2022-12-06 13:33
```myuser@myuser-laptop:~/workspace/pact-ruby-cli(master)$ pwd /home/myuser/workspace/pact-ruby-cli```

yousafn
2022-12-06 13:36
Hmm so that worked for me, the only thing that I changed was to use the PACT_BROKER_TOKEN, rather than username and password as using a Pactflow broker

dyptorden
2022-12-06 13:36
I am using pact broker (stored on a company machine) and using user\pass

yousafn
2022-12-06 13:37
do you have the latest version of the cli? `docker pull pactfoundation/pact-cli:latest` user/pass shouldn't make a diff at all

dyptorden
2022-12-06 13:38
hah - that did the trick

yousafn
2022-12-06 13:38
I saw the issue as part of our GitHub actions runs https://github.com/pact-foundation/pact-ruby-cli/pull/79 and put a change out for this

dyptorden
2022-12-06 13:38
grabbed the latest and ran it

yousafn
2022-12-06 13:39
Sweet, my fix above sorted it then, I was worried I had caused it :sweat_smile:

dyptorden
2022-12-06 13:40
thanks so much for the help Yousaf

dyptorden
2022-12-06 13:40
I would dare to go for a second question then... close to the case above

dyptorden
2022-12-06 13:41
running the same command but for a local project (that is the pact POC) to publish in the broker, throws a timeout after ~2 min

dyptorden
2022-12-06 13:41
```bundler: failed to load command: /pact/bin/pact (/pact/bin/pact) /usr/lib/ruby/3.0.0/net/http.rb:987:in `initialize': execution expired (Net::OpenTimeout) from /usr/lib/ruby/3.0.0/net/http.rb:987:in `open' from /usr/lib/ruby/3.0.0/net/http.rb:987:in `block in connect' from /usr/lib/ruby/3.0.0/timeout.rb:107:in `timeout' from /usr/lib/ruby/3.0.0/net/http.rb:985:in `connect' from /usr/lib/ruby/3.0.0/net/http.rb:970:in `do_start' from /usr/lib/ruby/3.0.0/net/http.rb:959:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:79:in `block in perform_request' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:93:in `until_truthy_or_max_times' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:64:in `perform_request' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:35:in `post' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/link.rb:57:in `post' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:61:in `block in publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:60:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:33:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:15:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:66:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:29:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start' from /pact/lib/pact/cli.rb:71:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /pact/bin/pact:15:in `<top (required)>' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `load' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `kernel_load' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:23:in `run' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:483:in `exec' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:31:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:25:in `start' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/exe/bundle:48:in `block in <top (required)>' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/exe/bundle:36:in `<top (required)>' from /usr/bin/bundle:25:in `load' from /usr/bin/bundle:25:in `<main>'```

yousafn
2022-12-06 13:44
Could be any number of reasons, including your broker setup, I would probably try and create a minimal reproducible example or a set of reproduction steps including commands run, and where you pacts are located, and run in.


yousafn
2022-12-06 13:45
Did the first command publish Okay to your broker?

yousafn
2022-12-06 13:45
just your own pacts in your project aren't?

dyptorden
2022-12-06 13:45
the one in the recently cloned project that you provide as example worked well

dyptorden
2022-12-06 13:45
my pacts won't go in my broker using the CLI

yousafn
2022-12-06 13:45
that pact is baked into the image, you will need to ensure the path to the pacts directory is correct in the volume mount

yousafn
2022-12-06 13:46
if you can't publish to your broker with either the issue is with your connection to the broker

yousafn
2022-12-06 13:46
if the issue is just with publishing from your own project, you probably haven't loaded a volume with the pacts in, and provided a path for the pacts directory/file

dyptorden
2022-12-06 13:47
connectivity shouldn't be an issue as `docker run --rm -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME=pactuser -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest pact-broker can-i-deploy --pacticipant ......` works well

dyptorden
2022-12-06 13:48
thanks for the hint, I will play a bit with the paths

dyptorden
2022-12-06 16:38
@yousafn hoping to not become too annoying... I tried to go down to the safest case, which was to publish the same contract (that was successfully published to your broker) to our broker (by replacing the 3 params - url\user\pass). Essentially I ran the exact same command again. The result is the same error. Any suggestion on what else can I check pretty please? running the `can-i-deploy` works fine against the same broker.

dyptorden
2022-12-06 16:39
In terms of logs, nothing is recorded in pact-broker container's logs

dyptorden
2022-12-06 16:59
P.S.: sh-ing in the local pactfoundation/pact-cli:latest container (that is stopped after running the publish command), I see that the pact is successfully copied inside - found it under `/home/myuser/workspace/pact-ruby-cli # cat example/pacts/pact.json` so the problem is somhow... sending it from the cli to the broker

dyptorden
2022-12-06 17:22
one difference between the brokers is that yours is https while ours is http - should it matter?

yousafn
2022-12-06 20:55
The file is pre loaded into the docker image anyway. You can use the pact cli tool directory by downloading it as a standalone, or installing it as a ruby gem and that might save you some issues. It isn?t clear if you?ve ever published a pact to your broker. ( nor how your broker is set up ) You can spin up a pact broker with docker composer easily to test. I would strongly advise making a concise list of steps and ideally a reproducible example or share as much code as you can. It is very difficult to hypothesise at what the problem may be. You may wish to raise it in a GitHub issue if it is easier to format. If I am getting the gist, the example pact in the repo will load into your broker, your own pact won?t? Have you check the contents of your pact to see if it is valid. Can you share it. Is your broker on the latest version, if not can you share which version.

yousafn
2022-12-06 20:58
https://docs.pactflow.io/docs/bi-directional-contract-testing/contracts/oas#installation Although this is from the Pactflow docs it offers the various ways you can download and use the CLI tools. Just in case using docker is adding an extra layer of complexity here

dyptorden
2022-12-06 21:26
? pact broker is dockerized and is started with a docker compose. ? pact broker is the latest version (docker pull pactfoundation/pact-broker:latest) ? it also has a contract that is published with a mvn test command in the consumer from the already existing project - so publishing works, but not with the CLI.

dyptorden
2022-12-06 21:32
"Have you check the contents of your pact to see if it is valid." I tried to publish in our broker the same contract that I published in your broker, without changing it (it's the pact.json that's present in the `pact-ruby-cli` project that I cloned a bit earlier) . The only change I did was to replace the following variables ? export PACT_BROKER_BASE_URL=... ? export PACT_BROKER_USERNAME=... ? export PACT_BROKER_PASSWORD=... with the values that point to our broker. When I run the publish command, I get the error. If I set the variables PACT_BROKER_BASE_URL etc. back to your broker's values, the command will be successful again and the contract will be published in your broker

dyptorden
2022-12-06 21:44
So the issue I need to fix, is to publish your contract to our broker, by using the docker run. Fixing this will also fix the publishing of our contracts as the error is the same. The only thing I can change is basically the docker-compose file. Would it help if I share it?

youri.thielen
2022-12-07 07:52
has joined #general

youri.thielen
2022-12-07 08:09
Hi all, question: we have a monilitihic API (documented in open api) that we use internally and is available to our customers. We don't have a microservices architecture and don't plan to. What advantages does bi-directional testing bring over say testing with Postman only?

cpopovici
2022-12-07 09:02
has joined #general

matt.fellows
2022-12-07 10:18
have you tried adding the `--verbose` flag to the command? That should print out additional HTTP level logs, so we can see what is trying to be sent and to where

matt.fellows
2022-12-07 10:22
bi-directional is a #pactflow feature (so best to ask specific Pactflow product features over there) I?m going to answer from the perspective of contract testing in general though. The short answer is that Postman doesn?t take into consideration what a consumer actually does with it, and so we can?t use that information to evolve the API safely in ways that traditionally are backwards incompatible. For instance, if we know all of the consumers of the API don?t use a particular endpoint, or even a particular header or field, we should be safe to remove them without resorting to cumbersome API versioning. You should still do functional testing (we can further discuss if postman is the best tool for that job), that is a necessary condition of a well tested API.

dyptorden
2022-12-07 10:42
thanks for answering @matt.fellows. After adding the `--verbose` I do get some extra info:

dyptorden
2022-12-07 10:42
```................. from /usr/bin/bundle:25:in `<main>' opening connection to 10.34.133.12:9292... opened <- "GET /? HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nAuthorization: [redacted]\r\n" -> "HTTP/1.1 200 OK\r\n" -> "Vary: Accept\r\n" -> "Content-Type: application/hal+json;charset=utf-8\r\n" -> "Date: Wed, 07 Dec 2022 10:33:42 GMT\r\n" -> "Server: Webmachine-Ruby/1.6.0 Rack/1.3\r\n" -> "X-Pact-Broker-Version: 2.105.0\r\n" -> "X-Content-Type-Options: nosniff\r\n" -> "Content-Length: 4384\r\n" -> "\r\n" reading 4384 bytes... -> "{\"_links\":{\"self\":{\"href\":\"http://10.33.132.13:9292\",\"title\":\"Index\",\"templated\":false},\"pb:publish-pact\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}\",\"title\":\"Publish a pact\",\"templated\":true},\"pb:publish-contracts\":{\"href\":\"http://10.33.132.13:9292/contracts/publish\",\"title\":\"Publish contracts\",\"templated\":false},\"pb:latest-pact-versions\":{\"href\":\"http://10.33.132.13:9292/pacts/latest\",\"title\":\"Latest pact versions\",\"templated\":false},\"pb:tagged-pact-versions\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}\",\"title\":\"All versions of a pact for a given consumer, provider and consumer version tag\",\"templated\":false},\"pb:pacticipants\":{\"href\":\"http://10.33.132.13:9292/pacticipants\",\"title\":\"Pacticipants\",\"templated\":false},\"pb:pacticipant\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}\",\"title\":\"Fetch pacticipant by name\",\"templated\":true},\"pb:latest-provider-pacts\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/latest\",\"title\":\"Latest pacts by provider\",\"templated\":true},\"pb:latest-provider-pacts-with-tag\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/latest/{tag}\",\"title\":\"Latest pacts for provider with the specified tag\",\"templated\":true},\"pb:provider-pacts-with-tag\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/tag/{tag}\",\"title\":\"All pact versions for the provider with the specified consumer version tag\",\"templated\":true},\"pb:provider-pacts\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}\",\"title\":\"All pact versions for the specified provider\",\"templated\":true},\"pb:latest-version\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}/latest-version\",\"title\":\"Latest pacticipant version\",\"templated\":true},\"pb:latest-tagged-version\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}/latest-version/{tag}\",\"title\":\"Latest pacticipant version with the specified tag\",\"templated\":true},\"pb:webhooks\":{\"href\":\"http://10.33.132.13:9292/webhooks\",\"title\":\"Webhooks\",\"templated\":false},\"pb:webhook\":{\"href\":\"http://10.33.132.13:9292/webhooks/{uuid}\",\"title\":\"Webhook\",\"templated\":true},\"pb:integrations\":{\"href\":\"http://10.33.132.13:9292/integrations\",\"title\":\"Integrations\",\"templated\":false},\"pb:pacticipant-version-tag\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}/versions/{version}/tags" -> "/{tag}\",\"title\":\"Get, create or delete a tag for a pacticipant version\",\"templated\":true},\"pb:pacticipant-branch-version\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}/branches/{branch}/versions/{version}\",\"title\":\"Get or add/create a pacticipant version for a branch\",\"templated\":true},\"pb:pacticipant-version\":{\"href\":\"http://10.33.132.13:9292/pacticipants/{pacticipant}/versions/{version}\",\"title\":\"Get, create or delete a pacticipant version\",\"templated\":true},\"pb:metrics\":{\"href\":\"http://10.33.132.13:9292/metrics\",\"title\":\"Get Pact Broker metrics\"},\"pb:can-i-deploy-pacticipant-version-to-tag\":{\"href\":\"http://10.33.132.13:9292/can-i-deploy?pacticipant={pacticipant}&version={version}&to={tag}\",\"title\":\"Determine if an application version can be safely deployed to an environment identified by the given tag\",\"templated\":true},\"pb:can-i-deploy-pacticipant-version-to-environment\":{\"href\":\"http://10.33.132.13:9292/can-i-deploy?pacticipant={pacticipant}&version={version}&environment={environment}\",\"title\":\"Determine if an application version can be safely deployed to an environment\",\"templated\":true},\"pb:provider-pacts-for-verification\":{\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/for-verification\",\"title\":\"Pact versions to be verified for the specified provider\",\"templated\":true},\"beta:provider-pacts-for-verification\":{\"name\":\"beta\",\"href\":\"http://10.33.132.13:9292/pacts/provider/{provider}/for-verification\",\"title\":\"DEPRECATED - please use pb:provider-pacts-for-verification\",\"templated\":true},\"curies\":[{\"name\":\"pb\",\"href\":\"http://10.33.132.13:9292/doc/{rel}?context=index\",\"templated\":true},{\"name\":\"beta\",\"href\":\"http://10.33.132.13:9292/doc/{rel}?context=index\",\"templated\":true}],\"pb:environments\":{\"title\":\"Environments\",\"href\":\"http://10.33.132.13:9292/environments\",\"templated\":false},\"pb:environment\":{\"title\":\"Environment\",\"href\":\"http://10.33.132.13:9292/environments/{uuid}\",\"templated\":true}}}" read 4384 bytes Conn keep-alive opening connection to 10.33.132.13:9292...```

matt.fellows
2022-12-07 10:56
The IP address in the second request looks different.

matt.fellows
2022-12-07 10:57
Note the 2nd octet

dyptorden
2022-12-07 10:58
typo - merged the new part to some of the previous one

dyptorden
2022-12-07 10:58
wanted it to make sense :slightly_smiling_face:

dyptorden
2022-12-07 10:58
I played a bit with the ec2

dyptorden
2022-12-07 10:59
```docker run --rm -w ${PWD} -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest publish ${PWD}/example/pacts --consumer-app-version fake-git-sha-for-demo-$(date +%s) --tag-with-git-branch --verbose bundler: failed to load command: /pact/bin/pact (/pact/bin/pact) /usr/lib/ruby/3.0.0/net/http.rb:987:in `initialize': execution expired (Net::OpenTimeout) from /usr/lib/ruby/3.0.0/net/http.rb:987:in `open' from /usr/lib/ruby/3.0.0/net/http.rb:987:in `block in connect' from /usr/lib/ruby/3.0.0/timeout.rb:107:in `timeout' from /usr/lib/ruby/3.0.0/net/http.rb:985:in `connect' from /usr/lib/ruby/3.0.0/net/http.rb:970:in `do_start' from /usr/lib/ruby/3.0.0/net/http.rb:959:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:79:in `block in perform_request' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:93:in `until_truthy_or_max_times' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:64:in `perform_request' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/http_client.rb:35:in `post' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/hal/link.rb:57:in `post' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:61:in `block in publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:60:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:33:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:15:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:66:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:29:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start' from /pact/lib/pact/cli.rb:71:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /pact/bin/pact:15:in `<top (required)>' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `load' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:58:in `kernel_load' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli/exec.rb:23:in `run' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:483:in `exec' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:31:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/cli.rb:25:in `start' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/exe/bundle:48:in `block in <top (required)>' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors' from /usr/lib/ruby/gems/3.0.0/gems/bundler-2.3.13/exe/bundle:36:in `<top (required)>' from /usr/bin/bundle:25:in `load' from /usr/bin/bundle:25:in `<main>' opening connection to 10.34.133.12:9292... opened <- "GET /? HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nAuthorization: [redacted]\r\n" -> "HTTP/1.1 200 OK\r\n" -> "Vary: Accept\r\n" -> "Content-Type: application/hal+json;charset=utf-8\r\n" -> "Date: Wed, 07 Dec 2022 10:33:42 GMT\r\n" -> "Server: Webmachine-Ruby/1.6.0 Rack/1.3\r\n" -> "X-Pact-Broker-Version: 2.105.0\r\n" -> "X-Content-Type-Options: nosniff\r\n" -> "Content-Length: 4384\r\n" -> "\r\n" reading 4384 bytes... -> "{\"_links\":{\"self\":{\"href\":\"http://10.34.133.12:9292\",\"title\":\"Index\",\"templated\":false},\"pb:publish-pact\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}\",\"title\":\"Publish a pact\",\"templated\":true},\"pb:publish-contracts\":{\"href\":\"http://10.34.133.12:9292/contracts/publish\",\"title\":\"Publish contracts\",\"templated\":false},\"pb:latest-pact-versions\":{\"href\":\"http://10.34.133.12:9292/pacts/latest\",\"title\":\"Latest pact versions\",\"templated\":false},\"pb:tagged-pact-versions\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}\",\"title\":\"All versions of a pact for a given consumer, provider and consumer version tag\",\"templated\":false},\"pb:pacticipants\":{\"href\":\"http://10.34.133.12:9292/pacticipants\",\"title\":\"Pacticipants\",\"templated\":false},\"pb:pacticipant\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}\",\"title\":\"Fetch pacticipant by name\",\"templated\":true},\"pb:latest-provider-pacts\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/latest\",\"title\":\"Latest pacts by provider\",\"templated\":true},\"pb:latest-provider-pacts-with-tag\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/latest/{tag}\",\"title\":\"Latest pacts for provider with the specified tag\",\"templated\":true},\"pb:provider-pacts-with-tag\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/tag/{tag}\",\"title\":\"All pact versions for the provider with the specified consumer version tag\",\"templated\":true},\"pb:provider-pacts\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}\",\"title\":\"All pact versions for the specified provider\",\"templated\":true},\"pb:latest-version\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}/latest-version\",\"title\":\"Latest pacticipant version\",\"templated\":true},\"pb:latest-tagged-version\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}/latest-version/{tag}\",\"title\":\"Latest pacticipant version with the specified tag\",\"templated\":true},\"pb:webhooks\":{\"href\":\"http://10.34.133.12:9292/webhooks\",\"title\":\"Webhooks\",\"templated\":false},\"pb:webhook\":{\"href\":\"http://10.34.133.12:9292/webhooks/{uuid}\",\"title\":\"Webhook\",\"templated\":true},\"pb:integrations\":{\"href\":\"http://10.34.133.12:9292/integrations\",\"title\":\"Integrations\",\"templated\":false},\"pb:pacticipant-version-tag\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}/versions/{version}/tags" -> "/{tag}\",\"title\":\"Get, create or delete a tag for a pacticipant version\",\"templated\":true},\"pb:pacticipant-branch-version\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}/branches/{branch}/versions/{version}\",\"title\":\"Get or add/create a pacticipant version for a branch\",\"templated\":true},\"pb:pacticipant-version\":{\"href\":\"http://10.34.133.12:9292/pacticipants/{pacticipant}/versions/{version}\",\"title\":\"Get, create or delete a pacticipant version\",\"templated\":true},\"pb:metrics\":{\"href\":\"http://10.34.133.12:9292/metrics\",\"title\":\"Get Pact Broker metrics\"},\"pb:can-i-deploy-pacticipant-version-to-tag\":{\"href\":\"http://10.34.133.12:9292/can-i-deploy?pacticipant={pacticipant}&version={version}&to={tag}\",\"title\":\"Determine if an application version can be safely deployed to an environment identified by the given tag\",\"templated\":true},\"pb:can-i-deploy-pacticipant-version-to-environment\":{\"href\":\"http://10.34.133.12:9292/can-i-deploy?pacticipant={pacticipant}&version={version}&environment={environment}\",\"title\":\"Determine if an application version can be safely deployed to an environment\",\"templated\":true},\"pb:provider-pacts-for-verification\":{\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/for-verification\",\"title\":\"Pact versions to be verified for the specified provider\",\"templated\":true},\"beta:provider-pacts-for-verification\":{\"name\":\"beta\",\"href\":\"http://10.34.133.12:9292/pacts/provider/{provider}/for-verification\",\"title\":\"DEPRECATED - please use pb:provider-pacts-for-verification\",\"templated\":true},\"curies\":[{\"name\":\"pb\",\"href\":\"http://10.34.133.12:9292/doc/{rel}?context=index\",\"templated\":true},{\"name\":\"beta\",\"href\":\"http://10.34.133.12:9292/doc/{rel}?context=index\",\"templated\":true}],\"pb:environments\":{\"title\":\"Environments\",\"href\":\"http://10.34.133.12:9292/environments\",\"templated\":false},\"pb:environment\":{\"title\":\"Environment\",\"href\":\"http://10.34.133.12:9292/environments/{uuid}\",\"templated\":true}}}" read 4384 bytes Conn keep-alive opening connection to 10.34.133.12:9292...```

dyptorden
2022-12-07 10:59
this is the complete current log

matt.fellows
2022-12-07 11:01
Interesting. What do the server logs say?

matt.fellows
2022-12-07 11:01
It's weird the first request goes through but not the subsequent

dyptorden
2022-12-07 11:02
I need to check with someone who has rights... will be back as soon as I have the server logs

hendrik916
2022-12-07 12:07
has joined #general

dimundo
2022-12-07 12:16
hi! we are moving to `deployedOrReleased` and i want to clarify one more stuff ? we deploy FE app( lets say twice a week ) , which has some support time and is marked as released ? we deploy BE ( lets say twice a week ) both FE and BE parts could be consumers and providers current BE has `deployedOrReleased` selectors, so it verifies all FE in the wiled -thats ok :slightly_smiling_face: at which point / how FE part ( marked as released , lets say 2 months ago ) will be verified against upcoming BE part ?

matcheckep
2022-12-07 13:55
has joined #general

youri.thielen
2022-12-07 14:50
Hi Matt, Thanks for you answer! Gotcha. So using Pact (non bi-directional) isn't very useful for an API that has (in our case many) consumers that don't use Pact. In our situation the consumers of our API are our customers (we're a SaaS company). Will look into bi-directional contract testing and will move to #pactflow, we have an open api description for our API. Cheers

dyptorden
2022-12-07 17:03
Hi @matt.fellows Nothing gets populated in the logs when I run the command. I checked `docker logs -f pact-broker` and also looked at EC2's system log.

dyptorden
2022-12-07 17:04
Interesting fact is that I deployed locally the same pact-broker, by using the same docker-compose, and it works. But not when the broker is in AWS...

dyptorden
2022-12-07 17:05
Knowing that the first request goes through, can you please tell me how can I trace the exact URI and Port at which the second request is being done?

wesley.nutley
2022-12-07 19:48
has joined #general

tjones
2022-12-08 00:00
Pact is also very useful for the case where you publish client libraries

dagmara.krent
2022-12-08 10:19
has joined #general

dyptorden
2022-12-08 10:38
Managed to check the requests @matt.fellows by running Wireshark on the docker0 interface, and saw that the 2nd request is sent from the same ip (obviously) but on a different port. I think that our Firewall has some protection so it's definitely not a broker issue - even more, the publish command works from a different EC2

komathypriya
2022-12-08 11:35
has joined #general

youri.thielen
2022-12-08 11:43
(newbie alert) When a consumer needs a new endpoint or some new fields, this should be in close collaboration with the provider right? So before the consumer testing is done, or at least before uploading the contracts. When the provider agrees and implements the contract it can document the new fields/endpoints in for example an open api document. It just that the open api document is not the starting point. Still trying to wrap my head around the whole CDC concept :)

matt.fellows
2022-12-08 11:56
So yes, Pact isn?t a replacement for a conversation

matt.fellows
2022-12-08 11:58
but also, it can _facilitate_ a good conversation. There is nothing wrong with a consumer creating a branch, putting in what is essentially a request for a change (hey, what if we ?added this new field? or ?changed the resource to this shape? etc.) and then publishing it. That?s what the https://docs.pact.io/pact_broker/branches (selector) feature is for - to be able to delineate between a wip idea and the mainline. Now there is a first class way to communicate that intent, and for the provider team to go ?yeah, it looks good and we?ve now implemented the change (because the pact is now green :white_check_mark: ?

neethu.santhosh
2022-12-08 14:22
has joined #general

janga.nagamallika
2022-12-08 17:49
has joined #general

jampala_1988
2022-12-08 23:47
has joined #general

krishnaraj.pk
2022-12-09 05:35
has joined #general

rajavadootha04
2022-12-09 07:56
has joined #general

rajavadootha04
2022-12-09 08:09
#pact-jvm We are facing issues with multipart file upload contract testing. Getting 'Missing start boundary'. Do we have multipart support at consumer side? We are trying with both pact versions 3.0.0 and 4.0.0, both results same error. If someone has encountered same issue, please provide us the remedy.

matt.fellows
2022-12-09 09:50
Did you mean to ask in #pact-jvm?

rajavadootha04
2022-12-09 10:14
Yes

tomaszrdzak
2022-12-09 11:54
has joined #general

yousafn
2022-12-09 13:03
Hey hey and happy Friday everybody :ralph-wave: I am pleased to point you in the direction of our launch webinar for Pact Plugins, which is now live on YouTube. :tv: https://www.youtube.com/watch?v=XA0yKOv5DjE&ab_channel=PactFoundation If this has whet your appetite, you can sign up for our Build a ~Bear~ Plugin Workshop on the 13/14th December :point_right: https://docs.pact.io/events/plugins-framework-workshop

dyptorden
2022-12-10 23:45
Hi @yousafn, @matt.fellows. I tried to publish with the mechanism you provided here: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1670360300858079?thread_ts=1670333074.636179&cid=C5F4KFKR8 So after downloading the latest version from here: https://github.com/pact-foundation/pact-ruby-standalone/releases I could publish the contract by running: `~/Downloads/pact-1.91.0-linux-x86_64/pact/bin/pact-broker publish /home/user/workspace/pact-ruby-cli/example/pacts/ -b http://10.34.133.12:9292 -u myPactUser -p 'myPassword' -a fake-git-sha-for-demo-$(date +%s) -g -v` Any chance you can make the docker command work as well? - as it will be quite hard to get all the members in all the teams to download the standalone plus keeping it updated to the latest version whenever a new version comes out. To have all in one place, the docker command that fails (for which only the first request goes through): `docker run -w ${PWD} -v ${PWD}:${PWD} -e PACT_BROKER_BASE_URL -e PACT_BROKER_USERNAME -e PACT_BROKER_PASSWORD pactfoundation/pact-cli:latest publish ${PWD}/example/pacts/ --consumer-app-version fake-git-sha-for-demo-$(date +%s) --tag-with-git-branch --verbose` Thank you,

matt.fellows
2022-12-11 23:53
It should be executing the same code (i.e. what is in Docker is the same code, packaged as a Docker container)

matt.fellows
2022-12-11 23:53
My guess is that there is some networking configuration / combination using Docker causing the issue

maxime.raverdy
2022-12-12 09:22
has joined #general


matt.fellows
2022-12-12 12:21
When the FE makes a new change it will publish a new contract. At this point can I deploy will fail until the provider has implemented and deployed the change. If the FE makes a change that doesn't modify the contract it's preverifed and can I deploy will pass.

matt.fellows
2022-12-12 12:22
It's the same as tags, am I missing something?

dimundo
2022-12-12 12:42
when MR is being merged its being tested against deployed and released versions ? provider is compliant with all version ? consumer updates or not pact

dimundo
2022-12-12 12:43
if half year old FE provider will be not ok with current BE - BE consumer will be not allowed to be merged/deployed - this will be detected on c-i-d stage

dimundo
2022-12-12 12:45
if half year old FE consumer will be not ok with current BE - BE provider tests will fail on tests stage ( as `deployedOrReleased` selector is there )

dimundo
2022-12-12 12:45
am i correct ?

dimundo
2022-12-12 12:46
looks like i finally managed to formulate this :smile:

sambhavi.chinnu
2022-12-13 04:11
has joined #general

david.turner
2022-12-13 09:01
has joined #general

yousafn
2022-12-13 13:11
Hey all! Hope to see some of you later in our build a Pact plug-in workshop https://docs.pact.io/events/plugins-framework-workshop Where you will create, publish and utilise your own plug-in in a pact test

mateusz.dudek03
2022-12-13 14:10
has joined #general

mateusz.dudek
2022-12-13 14:22
has joined #general

dmitrij.bogomyakov
2022-12-13 16:09
has joined #general

victor.lau841
2022-12-13 16:30
has joined #general

yousafn
2022-12-13 21:05
Hello, we are live! Give us a shout if you can't get in, or have any issues.

matt.fellows
2022-12-14 09:59
Hello! The Europe Plugins Workshop is starting now :point_right: https://docs.pact.io/events/plugins-framework-workshop Join @yousafn and I if you want to get your hands dirty writing your very first plugin :electric_plug:

guillaume.camus
2022-12-14 11:38
Hi folks, I don?t know if that can be interesting for some of you. I wrote a little command line to generate interactive diagrams of relations between ms. Here you can find the repo: https://github.com/ManoManoTech/pact-graph-network and some screenshots.

roblesjm
2022-12-14 11:40
has joined #general

ahmidat
2022-12-14 12:44
has joined #general

yousafn
2022-12-14 14:13
Nice one @guillaume.camus, this looks awesome! How many services in that graph? Will drop a couple of PR changes back for convenience stuff for mac users. I downloaded to `~/.pact/cli` and have that in my path :ok_hand: The path in the readme doesn't exist for macos users. Does it support broker creds? If you want to, it would be great to add on here https://docs.pact.io/community_repos maybe under a new utilities section? Also if you wanted to talk about it, or write a blog on it about why you built it, we can help give you a platform :slightly_smiling_face:

guillaume.camus
2022-12-14 14:17
Thank you, there are 82 services in this example. Authentication is not taken into account, but it?s a good idea, I will add it.

yousafn
2022-12-14 14:26
Nice :chefkiss:

yousafn
2022-12-14 14:27
I'm keen to run it against our demo pact broker!

sergey.ledniov
2022-12-14 16:46
has joined #general

yousafn
2022-12-14 19:36
Pact needs you. Yes, you! I promise I won?t take long and you can get back to dreaming about Xmas puds. We don?t sleep here at Pact and are always thinking about our community. We?ve launched an annual survey with the hope to get input from you, big or small. Any contribution is valuable. If you have contributed to any Pact Open Source projects or have engaged with Pact social media and Slack, we'd love to hear your thoughts and experiences! https://forms.office.com/r/ccxYTMxhJm Also if you are itching to do some more advent of code all year round, we?ve got some interesting projects in the pipeline you can sink you teeth into! More to come soon!

mike.geeves064
2022-12-14 19:51
I think you have heard all my responses before :joy: but I have filled in! Probably I will be needing to take the rest of the year off from any dev at all if I do manage to complete this year AoC :thinking_face:

abhimanu.sehgal
2022-12-14 20:40
has joined #general

yousafn
2022-12-14 22:55
Thank you Mr! Much appreciated. I've not attempted AoC this year, been on my own little journey in the underbelly of Pact in December. Might have a go when I break up for crimbles. I know I gave up last year on day 6 I think. I was like, this is too much like work, but not the fun bit of work.

mike.geeves064
2022-12-14 22:56
Yeah, I was trying Rust last year and it felt like far too much googling and brute forcing answers :joy: this year I have docs and tests :open_mouth: ..but python

hforhirenpatel
2022-12-15 02:13
has joined #general

enrique.decoss
2022-12-15 02:25
has joined #general

kirankishore4
2022-12-15 06:12
has joined #general

dimundo
2022-12-15 09:27
hello :slightly_smiling_face: more questions about record/release :slightly_smiling_face: https://docs.pact.io/pact_broker/recording_deployments_and_releases#recording-support-ended-for-a-release ```Recording support ended for a release When a released application is deemed to be no longer supported, call pact-broker record-support-ended. This will stop all pacts for this version being returned for verification by its providers, and remove it from consideration when checking if an integrated application is safe to deploy.``` does this mean, that this version also will be considered as not deployed ? use case - we have 3 components ? all 3 were deployed ( deployedOrReleased returns all 3 ) ? 1 was marked as released ( deployedOrReleased returns all 3(+1 but still 3 ) ) ? released component was marked as record-support-ended will deployedOrReleased still return all 3 components ?

dimundo
2022-12-15 09:31
this part of docs is a bit confusing ```and remove it from consideration when checking if an integrated application is safe to deploy.```

antonello
2022-12-15 10:16
Hello all! I?ve done a quick search on http://docs.pact.io and on here and couldn?t find anything relevant. I know there were conversations in the past around supporting *feature flags*. What are the current recommendations?

yousafn
2022-12-15 10:44
Hey hey @david.vancouvering wrote a little first pass at a guide on it earlier in the year https://docs.pact.io/getting_started/feature_toggles We still have some open questions but thought we would get it out there

yousafn
2022-12-15 10:45
Would love to get some feedback from the field from users both still on tags, or those who have moved to branches and/or environments

antonello
2022-12-15 10:45
I was searching for flags and didn?t think about searching for toggles!

yousafn
2022-12-15 10:45
Fancy a PR? so we can get feature flags on the page for indexing?

yousafn
2022-12-15 10:46
also `npx -y pactman` will let you search from your terminal and print out links to pages (if we've got the right search words in there) If you are extra lazy like me!

alvaro.navarroiborra
2022-12-15 10:47
has joined #general

leelavathi.sundaram
2022-12-15 10:55
has joined #general

yousafn
2022-12-15 11:02
Also I wonder if rather than being theoritcal it would be good to show/lead by example. We could built out a set of scenarioes based say on the existing pact product api scenario which is across multiple languages. A flapplication (feature flag application) and actually show it in practise. We have a couple of scenarioes that show the introduction of a visibility field to hide products, could we show that being used to control the client passing the param in the req and expecting that additional data in the resp (if the client side feature flag is on) Would we need scenarioes to cover how the feature flags are retrieved in the consumer or backend application (hard coded, dynamic at startup, dynamic as read by some external config/feature provider)

yousafn
2022-12-15 11:05
released and deployed are two separate concepts I believe. ? Unrecording a release wont unrecord deployments. ? recording a deployment will undeploy all deployed application This is why we recommend using `deployedOrReleased` selector for most use cases in provider verifications so the provider doesn't need to know in advance which style the consumer is using

yousafn
2022-12-15 11:07
And hey dude, thanks for all the brilliant questions. Are you capturing these anywhere? There is probably value in the moment as having an FAQ page with Dmitry atm :sweat_smile: and then feeding that into our docs. Would you be interested in chatting to one of our UX team members to see how we could have makes this docs journey less confusing for you? cc: @shuying.lin

paula.muldoon
2022-12-15 11:40
has joined #general

paula.muldoon
2022-12-15 11:44
:wave: (couldn't find an intro channel so posting hello here) - I'm Paula, lead engineer at Zopa Bank (UK), using Kotlin/Kafka and TS on the FE. Looking into Pact to provide contract testing for our microservices as well as our BFFs and excited to chat more!

yousafn
2022-12-15 12:02
Hey hey, Welcome to the party! Always good to have faces from the UK, I am lonely up in Leeds as the rest of my core Pactflow team are over in Aus! I'm new to Kotlin (it's next of my little list of polyglotting for my own advent of code) new to Kafka too, largely, getting across it soon as part of our Pact Plugin roll out. We would love to hear about your journey as your onboard through our docs and repos/examples, and exploring ideas around BFF's and good testing practises. We had a chat from the creator of module federation, at a client that were looking at rolling our micro front-ends in a mix of both restful/monolith and eda based arch https://scriptedalchemy.medium.com/when-should-you-leverage-module-federation-and-how-2998b132c840 And good shout on the intro channel, most shout in here and we have our widest audience, so this is as good as any :slightly_smiling_face: The welcome bot is here https://github.com/pact-foundation/pact-event-bot/blob/1d8000ef2b0b80e292e468fde25fe7e1705a6779/src/slackEvent.ts#L52 It is shockingly bad, looking back at it :joy: big fat one line string. but if you wanted to help update the content pulled it out here so it is easy to grok. https://gist.github.com/YOU54F/aebc97ef8eb09ce0d4c6d33a3190a672 to say, hey, why not introduce yourself in general. That content is a little stale. we are at over 4.5k users now, and I wrote that before I joined the Pact/Pactflow team It might be that we aren't using that one any more, and you've got a completely different message :sweat_smile:

paula.muldoon
2022-12-15 12:12
Woohoo, :gb: ! Yea I'm really hoping we can use Pact with Kafka cuz microservices testing...ouch

matt.fellows
2022-12-15 12:19
Welcome!

dimundo
2022-12-15 12:38
we almost ready in migration to deployedOrReleased

dimundo
2022-12-15 12:38
and thats why questions appear

dimundo
2022-12-15 12:39
> ? recording a deployment will undeploy all deployed application thats understandable ( making something like ?latest? )

dimundo
2022-12-15 12:39
> ? Unrecording a release wont unrecord deployments. this would be nice to add to docs because it a little bit contradicts with > ```and remove it from consideration when checking if an integrated application is safe to deploy.``` >

dimundo
2022-12-15 12:40
( prolly both notes )

sam774
2022-12-15 12:52
Ran a presentation today at work (Tesco Bank) on Pactflow, it went down a treat! We have lots of integration challenges in our environment and I may have just persuaded the higher ups that we can give this a shot.

sam774
2022-12-15 12:52
Welcome! Another UK bod here (I'm in Newcastle). There's also @wesleythomaswilliams :grinning:

yousafn
2022-12-15 13:46
Saweeeeeet!

yousafn
2022-12-15 13:47
is the slide deck generic enough or worth sharing? just thinking if you found the magic sauce that worked to help get it to click with the higher uppers, that might be good to share

yousafn
2022-12-15 13:48
we have a few champion decks we provide, but I know most practitioners probably have some kind of deck from their own talks / experiences

sam774
2022-12-15 13:50
Take a look at https://sh1989.gitlab.io/talks/consumer-driven-contract-testing Tried to keep it somewhat code light and high level, I only had 20m

yousafn
2022-12-15 13:50
How would people feel about pact-uk / pact-austrailia / pact-<location> style rooms. I would love to meet more Pact advocates, champions in the UK (especially anyone in Leeds), in person and it might be great to help people find communities local to them.

sam774
2022-12-15 13:54
Sounds fun!

paula.muldoon
2022-12-15 14:05
Woo! I'm in Cambridge

yousafn
2022-12-15 14:08
Excellent slide deck dude. Nice 101 level :clap:

yousafn
2022-12-15 14:08
Quality snippets too

yousafn
2022-12-15 14:08
and emojis and occasional lawl pic

yousafn
2022-12-15 14:10
I would maybe have e2e - challenges then the landscape (microservice death star) but other than that, love it Feel free to add an entry on this page if you'd like https://docs.pact.io/blogs_videos_and_articles

yousafn
2022-12-15 14:14
also quotes from testing legends :chefkiss:

sam774
2022-12-15 15:28
We definitely need a Pact UK meetup then lol

yousafn
2022-12-15 17:57
Happy for you to provide any updates to the docs, any of the pages have an edit this link at the bottom. We get a good few updates that way. You can think of it as your own contract-testing wikipedia :slightly_smiling_face:

yousafn
2022-12-15 18:01
We'd want to quickly test it out first before adding to the docs, or get Beth to confirm. I'll have get a chance tomorrow, I've gotta get my head down and box off a couple of tasks today. ty Dmitry

david.vancouvering
2022-12-15 18:55
Wow, I forgot about that doc. :slightly_smiling_face: It's currently under the "getting started" section which doesn't seem right. This seems like a pretty advanced topic. And yes, "feature flag" is probably a better term, sorry about that.

james.sun
2022-12-15 22:42
has joined #general

dominic.matabilas
2022-12-15 22:42
has joined #general

matt.fellows
2022-12-16 01:33
Great idea Yousaf!

matt.fellows
2022-12-16 01:41
If you can make that happen, we?ll definitely find a way to financially sponsor you if needed (e.g. food, drinks, venue). Would love to see this happen

matt.fellows
2022-12-16 01:41
Could do a Tesco vs Sainsburys contract testing talk :stuck_out_tongue:

bethskurrie
2022-12-16 02:48
@dimundo why was the same version marked as deployed and released?

bethskurrie
2022-12-16 02:49
Deployments and Releases are separate domain concepts, and doing something to a deployment does nothing to a release, and vice versa.

bethskurrie
2022-12-16 02:51
Deployments and releases model real life actions - when you deploy an application, the previous version that was in that environment is automatically undeployed IRL and in the Pact Broker. When you do a library/app release, it doesn?t stop any previous releases being available IRL, so we don?t update any previous releases in the Pact Broker.

bethskurrie
2022-12-16 03:04
I?ve updated the docs in the ?differences between deployments and releases?


bethskurrie
2022-12-16 03:05
I?m confused about which bits contradict each other @dimundo

bethskurrie
2022-12-16 03:06
?Deployed versions? and ?released versions? are very similar, but are modelled slightly differently in the Pact Broker. The difference between `record-deployment` and `record-release` is that ? `record-deployment` is used to model the real life scenario where a deployment causes the previous version of an application to be replaced by a new version. It is used for APIs and consumer applications that are deployed to known instances. When called, it automatically marks the previously deployed version as undeployed. ? `record-release` models the real life scenario where the release of a new version of an artifact does not cause the previously released versions of the artifact to become unavailable. It is used for mobile applications and libraries that are made publicly available via an application store or repository. When called, it does NOT change the status of any previously released version. ?Deployed versions? and ?released versions? are different resource types in the Pact Broker, and an application version may be both deployed and released. For example, a mobile phone application version may be recorded as deployed to a mobile device for automated testing in a test environment, and then recorded as released to an app store in a production environment. Deployments and release lifecycles are completely independent of each other. Ending support for a release will not cause a currently deployed version to be marked as undeployed, and marking a version as undeployed will not end support for a release.

bethskurrie
2022-12-16 03:06
how?s that?

bethskurrie
2022-12-16 03:07
> use case - we have 3 components > ? all 3 were deployed ( deployedOrReleased returns all 3 ) > ? 1 was marked as released ( deployedOrReleased returns all 3(+1 but still 3 ) ) > ? released component was marked as record-support-ended > will deployedOrReleased still return all 3 components ? (edited) Yes, all 3 will still be returned.

bethskurrie
2022-12-16 03:08
@dimundo btw, I don?t hang out in the general channel because there?s too much going on. If you have pact broker questions, best to ask in the #pact-broker channel

bethskurrie
2022-12-16 03:09
`fatal: detected dubious ownership in repository at '/home/myuser/workspace/pact-ruby-cli'` perceptive tool :laughing:

bethskurrie
2022-12-16 03:22
Please raise an issue in the pact-ruby-cli repo if you?re still having the issue @dyptorden

bethskurrie
2022-12-16 03:23
Just read @yousafn?s wrap up of 2022. What an amazing community. I?m so proud to be a part of it. https://docs.pact.io/blog/2022/11/17/pact-2022-end-of-year-wrapup

dimundo
2022-12-16 07:53
> why was the same version marked as deployed and released? yes > I?m confused about which bits contradict each other ```call pact-broker record-support-ended. This will stop all pacts for this version being returned for verification by its providers``` it sounds like `call record-support-ended ... version is removed from verifications`

dimundo
2022-12-16 07:56
adding this > Ending support for a release will not cause a currently deployed version to be marked as undeployed, and marking a version as undeployed will not end support for a release. makes everything clear

dimundo
2022-12-16 07:56
:taco: @bethskurrie and thank you :slightly_smiling_face:

paula.muldoon
2022-12-16 09:33
I am so there for this

sam774
2022-12-16 09:34
The big supermarket bank smackdown

sam774
2022-12-16 09:35
I have a session with our principal test engineer next week to go through what running a contract test workflow actually looks like, so I'm really hoping I can finally get some traction here

paula.muldoon
2022-12-16 09:36
We're close to going down the rabbit hole (again) of "just build api tests that you can run anywhere" oh wait that requires 10 JVM microservices, guess we can only run on UAT post-merge Guess we'll just ignore the output of those tests #NotOnMyWatch #HopePactCanHelp

dyptorden
2022-12-16 10:46
Thank you @bethskurrie . I will.

matt.fellows
2022-12-16 11:15
Not if we can help it! I've heard that story just a few too many times

matt.fellows
2022-12-16 11:16
It was both a lovely read (so Yousaf!) and a great reminder of the work that goes on behind the scenes, and the various contributions across the ecosystem. Thank you all, it really is a pleasure!

paula.muldoon
2022-12-16 12:19
Question about best practices for picking up changes to pactfile. Context: 2 microservices, called `PotatoConsumer` and `PotatoProducer` :ireland: :potato: with separate everything - pipelines, repos, deployable artifacts. Owned by a full-stack team that communicates well. `PotatoConsumer` updates the Pactfile (for `$reasons`). The update would cause a failure in `PotatoProducer` because it no longer upholds this contract. HOWEVER, because the pipelines etc are all separate, the failure in `PotatoProducer` doesn't get picked up until the next time someone touches it, six weeks after `PotatoConsumer`'s deployment to production (let's assume it fails in a subtle and unnoticed way). What's the best way to avoid this without ending up with pipelines doing super weird things to each other?

jaswanth.ooty
2022-12-16 12:27
Hi @paula.muldoon :wave::skin-tone-2: We currently have a setup, where this contract change would trigger a new build that would run the provider pact verification tests in the provider side (via a webhook configured in the pact broker) We?ve set it up in a way that if this build fails, it notifies the producer team via slack.

jaswanth.ooty
2022-12-16 12:29
Our setup is quite close to the platinum level. https://docs.pact.io/pact_nirvana/step_6

jaswanth.ooty
2022-12-16 12:30
Hope that helps. Please let me know if I?ve misinterpreted your question. Happy to chat more if needed :+1:

paula.muldoon
2022-12-16 13:30
thanks @jaswanth.ooty! If the build fails, does it block anything on the consumer side?

yousafn
2022-12-16 13:46
The consumer when they post their pact, if it has never been verified by the provider, will trigger a contact content changed and contract requiring verification published event. A provider build ( seperate from their usual build ) will be triggered to check out the code for all deployed/released versions of the provider and the head of the main branch to check comparability. Consumer would fail can I deploy, or can poll for a specified time to wait for the providers build to run. If the provider doesn?t have a sep build that it triggered by the contract changing, they can pick up the changes during their regular CI run by using Include WIP pacts Enable pending pacts. Wip pacts would allow the contracts published but not verified to be picked up by the providers ru. Enable pending on provider side would stop the consumers change a) failing the providers build so they can still deploy b ) block consumer until the provider has deployed a compatible change. I would expect consumer to back out change from main and then co ordinate on the change as a feature, that would allow consumers builds to continue for changes unrelated to that feature

yousafn
2022-12-16 13:49
Our ci/cd workshop covers these techniques and application of them Lesson 3 on here https://docs.pact.io/university It uses pactflow as the broker but you can switch out for an open source broker, the webhook commands will be slightly different https://github.com/YOU54F/path-to-pact-nirvana/blob/9831d9d18bc52b61f1608721601669493f86394e/Step_12_AddWebhookForProviderCIWhenConsumerChanges/Makefile#L24 As you can store secrets in Pactflow, so you create a token first that is parameterised in the webhook

yousafn
2022-12-16 13:51
Hey @jaswanth.ooty great answer. Curious has your team moved from tags for representing branches and environments, to branches/environments https://docs.pact.io/blog/2021/07/04/why-we-are-getting-rid-of-tags And are you using the new webhook event https://docs.pact.io/blog/2021/10/11/contract-requiring-verification-published-webhook-event

yousafn
2022-12-16 13:51
Loving the spud scenario :raised_hands:

paula.muldoon
2022-12-16 14:04
ooh thanks @yousafn that's really interesting!

tlemmonds
2022-12-16 19:55
has joined #general

jaswanth.ooty
2022-12-16 22:14
Hi @yousafn :wave::skin-tone-2: thanks for that ultra clear explanation :raised_hands::skin-tone-2: 1. Yup we?ve moved away from tags and use the branches instead :+1::skin-tone-2: 2. We are still perfecting our webhook setup. Since we don?t have dev or staging branches. We only have feature and main (Trunk based branching). We?ve been running through different scenarios to see how best we can set it up. Have you seen any approaches for trunk based branching before ? Would love to hear from you and the community.

dyptorden
2022-12-18 23:54
@matt.fellows should I understand that the issue is in our network or ...?

dyptorden
2022-12-18 23:57
@bethskurrie, at the moment, the only issue I am facing is the one in the next Thread: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1670715914357109?thread_ts=1670333074.636179&cid=C5F4KFKR8

matt.fellows
2022-12-18 23:57
Yes, it certainly appears that way.

dyptorden
2022-12-19 00:10
thanks Matt.

matt.fellows
2022-12-19 02:24
Sorry, I wish I could help you more!

matt.fellows
2022-12-19 02:25
My suggestion from here is to try and create a simple HA setup (sans VPN etc.) and see if the client works there, and then layer in the other networking components until it stops working. Then at least we?ll have a target to debug

samuel.woodbridge
2022-12-19 09:44
has joined #general

tjones
2022-12-19 13:22
I think @elliottmurray (of at least Pact Python fame) might be in Cambridge too

tjones
2022-12-19 13:23
(I was born in Cambridge, but I live in Australia now, so it?s unlikely I can make a meetup)

tjones
2022-12-19 13:23
Love this

tjones
2022-12-19 13:25
> HOWEVER, because the pipelines etc are all separate, the failure in PotatoProducer doesn?t get picked up until the next time someone touches it, six weeks after PotatoConsumer?s deployment to production (let?s assume it fails in a subtle and unnoticed way). This shouldn?t be possible.

tjones
2022-12-19 13:25
The `can-i-deploy` check for `PotatoConsumer` will fail because the contract has never been verified

tjones
2022-12-19 13:25
so it shouldn?t be possible to deploy something that?s broken

tjones
2022-12-19 13:26
(at least, broken in this way)

mwojcik
2022-12-19 13:43
has joined #general

robinsmit
2022-12-19 15:08
has joined #general

edouard.lopez
2022-12-19 15:58
Do you have recommendation when a code base is both consumer *and* provider? Do you create 2 distinguished tasks? How do you identify provider/consumer test to run? One of our team created 2 task: `testContractConsumer` and `testContractProvider` then used tag annotation ```# build.gradle.kts useJUnitPlatform { includeTags("consumer") }``` And in the test file `@Tag("provider")` or `@Tag("consumer")`

elliottmurray
2022-12-19 16:08
I can confirm he is still in Cambridge! Available for meetups. There was a virtual python one last year on pact I attended actually!

paula.muldoon
2022-12-19 16:12
ooh @elliottmurray where in Cam?? I'm in Girton

elliottmurray
2022-12-19 16:13
Mill road/romsey town way

elliottmurray
2022-12-19 16:13
Girton is very nice

paula.muldoon
2022-12-19 16:20
yea we moved up here a couple years ago to get more space. Mill Rd is fun though! Plus you have Hot Numbers...

elliottmurray
2022-12-19 16:22
Haha. Yes had brunch there just Saturday!

jungjae.lim
2022-12-19 16:24
has joined #general

tjones
2022-12-19 20:00
I used to live in Histon(!)

tjones
2022-12-19 21:13
Yes, I think two different tasks is the way to go

tjones
2022-12-19 21:13
As you need to publish the pact before you start the verification

tjones
2022-12-19 21:14
(well, you don?t _need_ to, since you could point at the local pact that you had just generated, too- but I think it?s the least fiddly to have all the tasks that you would if they were separate services)

tjones
2022-12-19 21:15
I have a service which is its own consumer, and for that I treat it as if it had the ?consumer tests? and the ?provider tests?, just as it would if they were separate. This way, if I add other consumers, or pull one of them out to a separate service, then it?s safe

antonello
2022-12-20 15:04
Hello! Can I just double check that if a pacticipant supports both HTTP and message protocols, that you?d need to use two different pacticipant names?

yousafn
2022-12-20 15:28
Hey @antonello, Believe v4 Pact specification will allow for an integration (consumer/provider application pair) to share multiple interaction types via this RFC https://github.com/pact-foundation/pact-specification/issues/79 so it would be beneficial for client libraries to upgrade to get all the latest and greatest features. This will probably be a community effort rather than on any individual as there is quite an estate to cover, some of which isn't under the Pact foundations direct control. I've got it on my radar for next year's plan of attack :slightly_smiling_face:

yousafn
2022-12-20 15:30
We could do with some documentation on the site regarding those caveats probably ? message pact testing section ? https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact ? pact specification section ? https://docs.pact.io/implementation_guides/pact_specification#migration-guides

yousafn
2022-12-20 15:30
Other than that there are just a few pointers to the naming convention required is a few GH issues in diff repos.

tjones
2022-12-21 02:03
Yes, currently that?s the case.

sam774
2022-12-21 14:31
Good news! Last week's contract testing talk went down very well at work amongst the engineering practice. In the new year we are going to run a proof of concept. A lot of the services we use are SOAP, what does Pact have to say about contract testing SOAP?

sam774
2022-12-21 14:32
To some extent I could see it working similarly to bi-directional contract testing, in that the contract must be a subset of the WSDL. But I'm not sure how much benefit you get from this in the same way you do with HTTP. Keen to be wrong on this tho

saurwein
2022-12-21 14:48
has joined #general

ssharma
2022-12-21 15:17
has joined #general

alejandro.depablos
2022-12-21 18:56
has joined #general

abubics
2022-12-21 22:37
WSDLs have the same kinds of issues as OAS, or other schema specs: less reasoning power (aka: https://pactflow.io/blog/schemas-are-not-contracts/)


abubics
2022-12-21 22:39
WSDLs do have a small benefit in that you can generate code that will always (un)marshall correctly, but you can't guarantee that everything that is expressed is valid.

abubics
2022-12-21 22:41
(e.g. If there are many optional properties/children in am entity, the spec doesn't tell you which combinations are valid) - of course you can design around this, but that burden is on engineers, SOAP doesn't help you.

tomas.cerkasas
2022-12-21 23:14
has joined #general

matt.fellows
2022-12-22 02:01
> To some extent I could see it working similarly to bi-directional contract testing, in that the contract must be a subset of the WSDL. But I?m not sure how much benefit you get from this in the same way you do with HTTP. Keen to be wrong on this tho Yeah. We do have this on our list for BDCT, but I?m not yet convinced we?ll actually be able to solve the problem. In my experience, and some of the examples I?ve seen, the schemas are so full of ?optional? elements, that almost any XML document would match. Which, obviously, wouldn?t be too helpful :laughing:. But that may not be a reason to not do it for those that have useful schemas. I think schematron could also play a part here, which alleviates many of the problems XSD had (in practice, not theory). So the way BDCT works with OAS now, whilst suffers from a variant of the same problem, is nowhere near as bad.

matt.fellows
2022-12-22 02:02
> WSDLs do have a small benefit in that you can generate code that will always (un)marshall correctly, but you can?t guarantee that everything that is expressed is valid. I think one of the reason why schemas tended to be so abstract with XSD, is that the way the clients/servers were built in that generation were not fault tolerant, so if you had a client that didn?t have exactly the same schema as the server, everything went :boom:

matt.fellows
2022-12-22 02:02
so a solution (to that problem) is to make the schema weaker

matt.fellows
2022-12-22 02:03
RESTful services have learned from that mistake, and generally speaking everyone accepts that we don?t need to be so tightly coupled. So I?ve never seen an OAS that is anywhere near as bad as those XSDs.

priyanka.soni
2022-12-22 08:24
has joined #general

zijian.wang1
2022-12-22 10:51
has joined #general

anyi.huang
2022-12-22 11:02
has joined #general

arpan.agr
2022-12-23 05:45
Is there pact support for erlang

matt.fellows
2022-12-23 07:27
No, but let us know if you're up for building an Erlang client!

matt.fellows
2022-12-23 07:28
I should also add, you can test soap with pact languages that support XML (java and JS I think are the only ones currently)

stepik02
2022-12-23 10:36
has joined #general

prajwalg
2022-12-25 14:28
has joined #general

raksha.baskaran
2022-12-27 06:01
has joined #general

venkatesh.madas
2022-12-27 06:36
has joined #general

anthony.bennett
2022-12-27 20:15
has joined #general

livinglogic.nl
2022-12-28 10:50
has joined #general

vittorio.guerriero
2022-12-28 16:34
:wave: , Hello! Question about pact cli `can-i-deploy` Is it possible to specify the version of a Pacticipant through the environment? Basically we would like to do this ```pact-broker can-i-deploy --pacticipant AConsumer --version ${gitHash} --pacticipant AProvider --environment prod``` This should only check for the Provider version with the environment prod. We are currently using pact-node and I couldn?t find a way to do this

vittorio.guerriero
2022-12-28 16:36
We would like this functionality because we trigger the verification process synchronously only for the `can-i-deploy` that fails.

vittorio.guerriero
2022-12-28 16:37
This is the version I am using ```"@pact-foundation/pact-node": "10.17.2",```

vittorio.guerriero
2022-12-28 16:41
Just to clarify that we cannot use `--to-environment` because this would include all the Providers in this instance. We would like to specify a single pacticipant with another single pacticipant. Let me know which other info you need!

tjones
2022-12-28 21:03
Can you use `pact-core` instead of pact-node? It?s the core that backs pact-js@10 and above

tjones
2022-12-28 22:02
> Just to clarify that we cannot use --to-environment because this would include all the Providers in this instance. We would like to specify a single pacticipant with another single pacticipant. What is the reason that this is a problem? The use-case for `--to-environment` is to see if it is safe to deploy the application (ie, including all of its dependencies)

livinglogic.nl
2022-12-29 00:53
I'm working on a tool that includes PACT support and I'm trying to make it fit as good as possible. I understand testing for an optional attribute does not make sense as another consumer might want it to be there. However, if I describe a scenario (by giving provider states) where the returned array should be empty, can we not verify that? After reading documentation and doing some testing, I come to these conclusions: 1. A scenario where the array contains at least one item is verifiable. 2. A scenario where the array contains max=1 item is verifiable. 3. A scenario where the array contains max=0 is **not** verifiable (I can specify an empty array, but PACT would still allow a non-empty array). A real world example of scenario 3 would be: _Given a provider state of items with only state 'declined' searching for items with state 'accepted' would result in an empty array_ I could theoretically have 3 interactions: - Interaction 1: tests items in the array - Interaction 2: tests for array length == 1 under specific circumstances - Interaction 3: tests for array length == 0 under specific circumstances It therefore seems arbitrary to allow `max=1` but not `max=0`.

livinglogic.nl
2022-12-29 00:58
Can anyone shine some light on the above? By the way a big fan of Pact, and I will be able to continue without max=0 but I would like to gain some more understanding, thanks!

tjones
2022-12-29 01:38
> 3. A scenario where the array contains max=0 is *not* verifiable (I can specify an empty array, but PACT would still allow a non-empty array). No, it won?t. If you?re experiencing this, it?s a bug.

tjones
2022-12-29 01:39
Sometimes, people get confused by the `eachLike` matcher in the empty array case. When the array is empty, you don?t need a matcher, you just specify an empty array.

tjones
2022-12-29 01:40
A key point is that the matcher isn?t for ?here are the possible responses that the server might make? it?s for ?everything that passes this matcher is covered by this particular test?

tjones
2022-12-29 01:43
So, yes, you?re right that you usually need at least: ? Some items in the array of a particular shape ? No items in the array Depending on the meaning in the response, you might also need things like: ? Exactly one item ? Exactly these items in this order (you don?t need `eachLike` for this) ? Array that includes these specific items in any order etc

tjones
2022-12-29 01:43
What?s your tool? I?m also working on something that will be pact-compatible, we could compare notes

tjones
2022-12-29 01:45
I?m guessing a bit, but another key point that might be relevant is: In normal pact usage, a pact file can only be written if we _know_ that the consumer works with what the pact file describes. This is important, as it?s what gives you deployment confidence when the verification of a pact file passes. Sometimes we find people who want to write pact files manually (or automatically from a spec), and this is usually a reduction in deployment confidence.

tjones
2022-12-29 01:47
> I?m also working on something that will be pact-compatible, we could compare notes One of the things I?d like to do is to review the pact-jvm source code (where the pact matchers are all described clearly) and write up how each one behaves. I want to do this so that I can read pact files correctly - it?s not at the top of my todo list yet, but if this is the kind of thing your tool will also need, it definitely would be worth comparing notes.

tjones
2022-12-29 01:53
> It therefore seems arbitrary to allow max=1 but not max=0. I believe the reason for this choice is that it?s normally something people want to be able to specify when there?s a misuse or misunderstanding - so preventing it brings them to the help pages or FAQ instead of writing a broken test by mistake. The framework could treat `max=0` as `[]`, but think about how it would work if Pact didn?t exist, and instead a coworker was describing the response to you: ?Ok, I need exactly zero items, each of which matches this template? ?.you?d be like ?wait, what? What do you mean??. It would be better to have your coworker say: ?Ok, I need an empty array? ?Got it? And that?s why instead of `eachLike(item, {max: 0})`, you should say `[]`

tjones
2022-12-29 01:54
Also, very small point, but it?s Pact not PACT :heart:

tjones
2022-12-29 01:54
(for your documentation)

livinglogic.nl
2022-12-29 05:23
Thanks for explaining all of this! Let's say I want to match on type at the root: ```{ id: 1, text: 'hello world', items: [], }``` So id would be a number, text would be a string and items would be an array. Now if I want items to be zero-length in some scenario, I cannot have the `{ match:'type' }` on root, because it will then force items to be an any-length array. So in this scenario, I would have to be specific about matching `id` to be a `number` and `text` to be a `string` because I can't use `{ max:0 }` as a matcher on `$.todos` Is this correct?

livinglogic.nl
2022-12-29 05:32
Documenting the various matchers would be very helpful I think! I see you referring to the jvm as the source of truth. At some point I thought the pact_verifier_cli would be the reference implementation to look at?

livinglogic.nl
2022-12-29 05:42
I do see quite some interesting documentation on https://docs.pact.io/implementation_guides/rust/pact_matching too bad it is a bit hidden (Rust is not my main language)

tjones
2022-12-29 06:52
> Is this correct? No. You can cancel the match and go back to exact for `items` (I forget what it?s called in the pact file format, but there?s a ?match this exactly?), or you could do match of `"type"` on both the `id` and the `text` instead of on the root.

vittorio.guerriero
2022-12-29 07:26
Morning here! :sunrise: ! Thank you for your answer > Can you use `pact-core` instead of pact-node? It?s the core that backs pact-js@10 and above I can certainly do! I was using pact-node because I was simply running the commands from a shell rather than creating a javascript script. Is there a specific reason why is recommended over pact-node? > We would like to specify a single pacticipant with another single pacticipant. Basically, we are following an approach without webhook at Cazoo, As part of the consumer pipeline we ? run the tests ? publish the pacts ? run can-i-deploy -> this is the one that I would like to change ? run the verification only if the previous can-i-deploy failed ? ?. This gives us the advantage that we have an immediate response from the Provider if the verification failed or succeeded. The need of using can-i-deploy with a single Consumer and Provider is to control which verifications we want to trigger. Example ConsumerA is consuming different APIs from 2 different Provider. ProviderA and ProviderB. ConsumerA make a change to the pact that is compatible with ProviderB and it does not affect ProviderA ConsumerA will publish the pacts ConsumerA will run can-i-deploy, it will fail for ProviderB but it will succeed for ProviderA ConsumerA will run the verification on the ProviderB but not the ProviderA

vittorio.guerriero
2022-12-29 07:26
@antonello FYI

antonello
2022-12-29 08:09
Just to clarify further, we?re implanting a webhook-less flow and Beth pointed me to https://github.com/pact-foundation/pact_broker-client/blob/master/lib/pact_broker/client/cli/matrix_commands.rb#L44 but we?ve been unable to use the command successfully.

tjones
2022-12-29 09:04
> Is there a specific reason why is recommended over pact-node? Yes, the latest version of the binaries are in pact-core. Pact-node was renamed `pact-core` to reduce confusion (it was a core package without a convenient DSL that sometimes people mistook for the package to use if you were doing server side node). 9.x depends on pact-node, while 10.x uses pact-core.

tjones
2022-12-29 09:19
I?m not sure I fully understand the workflow you describe, but I have only had time to skim read it so far (I?ll be able to check back later). My first impression is that the situation you describe doesn?t need to be able to drop providers from the query. But perhaps I am missing something

tjones
2022-12-29 09:21
> At some point I thought the pact_verifier_cli would be the reference implementation to look at? My understanding is that they?re the same behaviour. When I was asking Ron if the matchers were documented anywhere, he said they weren?t documented in the spec, but pointed me at this: https://github.com/pact-foundation/pact-jvm/blob/master/core/matchers/src/main/kotlin/au/com/dius/pact/core/matchers/MatcherExecutor.kt#L142

tjones
2022-12-29 09:22
Out of interest, what are you building?

tjones
2022-12-29 10:32
Ok, I think I understand your use case. Are you saying that you want to use can-i-deploy to determine which providers are failing (if any) and then immediately run their verification steps? If yes, what I would do is use the json output from can-i-deploy (there?s a flag for it), parse it, and use that output. This is better than running individual can-i-deploys because it means that you can use the environment selectors and won?t miss any providers.

tjones
2022-12-29 10:35
I?ve never tried running the provider verification in the same build - it feels like it might be more trouble than its worth, but also if this works for you I can?t see anything wrong with it. I?d be keen to hear how you get on

tjones
2022-12-29 10:38
Without webhooks, I usually just go: Consumer build: ? build / test ? publish pact Consumer deploy (triggered after build) ? can-i-deploy ? deploy Provider build ? build / test ? verify pact(s) ? publish results Provider deploy (triggered after build) ? can-i-deploy ? deploy This has the disadvantage that sometimes changes need to wait for the other thing to be triggered by changes (costing unnecessary waiting time). Sometimes I have kicked them off manually (costing time and mucking about), or had the provider build trigger after the consumer build (costing unnecessary builds, and additional complexity).

tjones
2022-12-29 10:39
If you do them all in the same CI session, then the wrong project might fail the build, which could be annoying

antonello
2022-12-29 11:01
@tjones I?ve implemented the workflow Vittorio is talking about before - I talked about it in the first community event we ran 2 years ago.

tjones
2022-12-29 11:05
Oh! Haha! I thought I recognised the name. Forgive me, I?m very tired :sweat_smile:

tjones
2022-12-29 11:06
I remember being impressed by your talk


tjones
2022-12-29 11:09
At 1:17:49 it looks like you also used the json output of can-i-deploy, too

tjones
2022-12-29 11:10
Could you say more about what?s not working this time?

tjones
2022-12-29 11:15
Following https://docs.pact.io/pact_broker/can_i_deploy, I think this: ```pact-broker can-i-deploy --pacticipant AConsumer --version ${gitHash} --pacticipant AProvider --environment prod``` should have `--to-environment` not `--environment`, yes?

tjones
2022-12-29 11:17
The docs also say: > If you declare two (or more) application versions as well as a --to ENVIRONMENT, then the Pact Broker will work out what integrations your declared applications will have in that environment when determining if it safe to deploy. So, I think you?d need a version for `AProvider` (even if it is just `--latest`)

tjones
2022-12-29 11:21
Hmm. Maybe this doesn?t actually do what you want. I think it is asking if it?s safe to deploy all of those things to production, not selecting the versions of those things in production.

tjones
2022-12-29 11:31
Maybe you can use `--ignore`?

antonello
2022-12-29 11:36
I had to parse the response if I?m not wrong. But @bethskurrie has implemented a more straightforward command. And we were using tags.

pawel.szczerbicki
2022-12-29 13:22
has joined #general

anandhiemail
2022-12-29 17:37
has joined #general

arika.goyal
2022-12-30 12:18
has joined #general

livinglogic.nl
2022-12-31 08:47
Hi Timothy, I'm working on a TypeScript HTTP client with a focus on integration testing, what about you?

m.marquez
2022-12-31 16:05
has joined #general

tjones
2023-01-01 12:37
I?m working on another contract testing tool which will solve some of the pain points I have with Pact - but ideally I want to be as Pact compatible as possible

guoxin.rick33
2023-01-03 08:45
has joined #general

will
2023-01-03 09:59
has joined #general

mario.pires
2023-01-03 11:42
has joined #general

vtft1988
2023-01-03 16:38
has joined #general

matt.thompson
2023-01-04 10:54
has joined #general

rytis.lisauskas
2023-01-04 14:20
has joined #general

morin.td
2023-01-04 16:54
has joined #general

afernandez
2023-01-04 22:22
has joined #general

vkaramoff
2023-01-05 10:00
has joined #general

vika.karman
2023-01-05 10:32
has joined #general

nickzakirov
2023-01-05 15:01
has joined #general

nickzakirov
2023-01-05 15:06
HI guys! Reading about Pact and thinking about using it. I have a simple usecase (I think). I want to write a test that sends http to external service, record the request-response in pact json format, then replace the external service in the test with pact-mock-server. I think it must be one of the simplest uses but I can't figure how to register the request-response in pact format. Is there a way to launch pact-proxy-server that would forward my requests and record them against responses?

nickzakirov
2023-01-05 15:14
I can certainly create my own but would not want to reinvent the wheel

tjones
2023-01-05 15:22
afaik, Pact doesn?t do this, at least not easily. Matt and I were discussing this kind of feature a while back - it would be an awesome way to kickstart your tests (you could even just run the app for a while in some kind of ?watch mode?, and generate a test skeleton)

tjones
2023-01-05 15:23
One subtlety that you might miss if you?re new to Pact is that a key part of a pact test is confirming that the response object correctly unmarshalls into whatever business object your API client returns. In some languages (eg JS), this is usually the same as the json object - but not always. This part would be hard to automate.

tjones
2023-01-05 15:24
If I were going to do this, I would write something that watched the response, and then autogenerated the pact test in whatever DSL I wanted.

mwilso29
2023-01-05 15:33
Hi All. I've managed to create a consumer pipeline that creates the contract, publishes the contract to the broker, calls a webhook for the provider pipeline to be ran and the can-i-deploy step checking the broker status. However the webhook succeeds when it gets a 201 and moves on to the can-i-deploy job before the provider has chance to run its pipeline and upload a potential new contract to the broker. What would be the best approach here? Is there a way to wait for the provider pipeline to run before the can-i-deploy check is ran? Thanks

nickzakirov
2023-01-05 15:34
Hmm, I don't understand the confirming part. I write in Rust and what I want really is to make my tests fast - so replace the external service with a mock service. Since I know how to interpret the response from external service and deserialize it into my types I should be able to do the same with pact responses too. Pact has a mock server as far as I understand that would spit reponses based on its json configuration and those responses would be identical to external service. Or I get it wrong?


tjones
2023-01-05 15:49
A successful pact test says: ?This consumer will make this request, and can understand this response, if the provider sends it?

tjones
2023-01-05 15:49
Without asserting on the resulting object from your API code, you can?t be sure that the response is correctly understood

tjones
2023-01-05 15:50
(For comparison, a successful provider verification- ie, the other side of the pact test - says ?this provider can understand that request, and will generate a response that the consumer understands?

tjones
2023-01-05 15:52
Usually in pact you write the expectations first- so you would write down what your consumer expects to receive from the provider in your pact test. Then you later verify that expectation

tjones
2023-01-05 15:53
It would be possible to seed that process by observing real traffic, but I think it?s rare to already have those tests ready to be watched.

tjones
2023-01-05 15:56
There are a few other subtleties too - in a Pact test, you ideally don?t describe the whole payload, just the parts your consumer needs. This is advantageous because it?s not a breaking change to rename or remove a field/endpoint that no-one is using. You wouldn?t have this advantage with recorded traffic- although not having it won?t matter in a lot of cases.

tjones
2023-01-05 15:56
You?re right that a Pact test will be much faster than an integration test. This is one of the major advantages, I think.

tjones
2023-01-05 15:57
There?s a retry-while-unknown flag for can-i-deploy, which would make the pipeline wait until it got a clear answer from the broker. This might work for you (I forget what the flag is called, but it?s in the docs / CLI usage).

tjones
2023-01-05 15:58
> Pact has a mock server as far as I understand that would spit reponses based on its json configuration Ohh, are you asking how to configure the mock service yourself? I probably wouldn?t do this.

tjones
2023-01-05 15:58
It?s likely to be more trouble than it?s worth, I think.

tjones
2023-01-05 16:00
I don?t think the mock setup json is documented.

tjones
2023-01-05 16:00
If you wanted to try this, you?d have to look at the Rust source to see how they?re read, or something like pact-js, which has the matchers laid out in a fairly readable way.

nickzakirov
2023-01-05 16:01
I just want to use the library functions


nickzakirov
2023-01-05 16:01
create server

nickzakirov
2023-01-05 16:01
start server

nickzakirov
2023-01-05 16:02
Providing the pact file to the server

nickzakirov
2023-01-05 16:02
The pact file ideally I want it to be autogenerated by running "pact proxy server"

tjones
2023-01-05 16:02
I?m not personally familiar with the rust API, sorry

nickzakirov
2023-01-05 16:02
that doesn't exist yet unfortunately as I understand

nickzakirov
2023-01-05 16:03
Thank you very much for taking time and writing replies

nickzakirov
2023-01-05 16:03
Much appreciated!

tjones
2023-01-05 16:03
hmm. The pact file shouldn?t exist yet, in that design.

nickzakirov
2023-01-05 16:03
It doesn't exist in the beginning

tjones
2023-01-05 16:03
If you have a pact file, it means you definitely can send those requests and understand those responses

nickzakirov
2023-01-05 16:03
But I would like to autogenerate it

tjones
2023-01-05 16:03
Yes, it should be autogenerated.

dyptorden
2023-01-05 16:04
try a retry mechanism to poll the broker, such as : ? --retry-while-unknown=60 ? --retry-interval=10 (tuned with the values that you need)

nickzakirov
2023-01-05 16:04
But how can I autogenerate it?

tjones
2023-01-05 16:05
usually the consumer tests generate it.


tjones
2023-01-05 16:06
The mock server has a `write_pact_file` function

tjones
2023-01-05 16:07
which will do it - although I think you have to check to make sure that all the tests pass before calling it, otherwise you?ll write a pact file that might not be true

tjones
2023-01-05 16:11
Anyway, it sounds like an interesting project. I?d be keen to hear if you get anything working like this

tjones
2023-01-05 16:11
I?d recommend starting with the user-facing DSLs first, though.

tjones
2023-01-05 16:12
that will give you a feel for how it usually works, which will help inform any automation

mwilso29
2023-01-05 16:23
Perfect thanks guys

varnit.garg2424
2023-01-06 08:26
Hey guys, I?m running into a basic issue while running provider side tests in the CI I?m using pact-go and using pact-ruby-standalone in my local machine. However, while running the tests in ci, it returns - `exec: "pact-provider-verifier": executable file not found in $PATH` Do I need to run `pactfoundation/pact-cli:latest` as part of my application container before running the pact test?

mtissot79
2023-01-06 09:31
Hi Pact team We are about to migrate our internal framework which is based on spring (boot 2.7.7, spring 5.x) to spring boot 3. Spring boot 3 comes with Spring 6, java 17 (minimum) and migration of javax ee8 to jakarta ee9. Spring recommands to look at any third party libraries for the usage of javax ee8. We are using Pact junit5spring that comes with spring 5 and javax ee8. Could you please tell me if you plan to upgrade to spring 6 and support jakarta 9 ? Have a nice day

matt.fellows
2023-01-06 12:17
No, you need the CLO tools installed on your CI also

matt.fellows
2023-01-06 12:18
Pact won't use the docker variant as part of its test run

varnit.garg2424
2023-01-06 12:19
Thanks Matt for the response I?m a bit lost, do we have any example? :) We are using GitHub actions

yousafn
2023-01-06 12:29
Hey got an example I made for another member recently https://github.com/YOU54F/go-pact-test

yousafn
2023-01-06 12:49
Hey @mtissot79, This would be best cross posted in #pact-jvm Our JVM expert is based in Aus so you may get a reply overnight

yousafn
2023-01-06 12:50
:ralph-wave: How do every one! Hope you had a lovely chilled out break with family, loved ones and friends, and are having a brilliant start to the year. I am back in action from today, after a lovely break away, so will be catching up on various slack threads, GitHub messages, pull requests, issues. Feel free to give me a nudge. Good to be back in the land of :pact-open-link:

nam.nguyen
2023-01-07 04:00
has joined #general

dale.wells
2023-01-08 15:18
has joined #general

matt.fellows
2023-01-09 01:10
You need to install the CLI dependencies for Pact Go 1.x.x to work. In the Pact Go project, we use a make target to do this ? https://github.com/pact-foundation/pact-go/blob/master/Makefile#L32 (installs into the relative `pact` folder) ? We also add that `pact` folder to the `PATH` environment variable during the build so that it is available to the runtime: https://github.com/pact-foundation/pact-go/blob/master/make/config.mk#L1 If you?re using 2.x.x, you don?t need to install these for the tests to run (i.e. Pact go won?t use them), but you probably want them installed anyway to publish pact files etc.


manohar.adepu
2023-01-09 02:58
has joined #general

hsyogesh12
2023-01-09 05:54
has joined #general

anandhiemail
2023-01-09 06:14
Hi Team, I am a QE engineer and I would like to introduce Contract testing to our team. In our service which I have taken for writing a POC using Pact, we make thrift RPC calls to other services. How can I write a Pact contract test for Thrift calls? I request you to guide me on this.

matt.fellows
2023-01-09 06:29
Hi Anandhi! We don?t currently support Thrift. You could create a plugin for it (see https://docs.pact.io/plugins) however the plugin framework is still in its infancy - what language do your teams use to write the Thrift calls?

sowmya.bhg
2023-01-09 10:32
has joined #general

matt.fellows
2023-01-09 11:25
Thanks for answering in detail - as always - Tim! I did very much take time afk during the ?break? over xmas (I say break because I?m moving homes, so I?d much rather have ?wasted? my 2 weeks on the computer here :stuck_out_tongue: ) Sounds like a fun project Rinke. Let us know how we can support you!

ivan.mikhalka
2023-01-09 13:20
has joined #general

klaudijus.rulys
2023-01-09 13:32
has joined #general

boer.k
2023-01-09 15:10
has joined #general

dyptorden
2023-01-09 15:44
hi @matt.fellows and Happy New Year. I did the same implementation on a *public* AWS network and it works. It will only NOT work in a *private* one. *`But`*: it works if the docker command (same command / same docker version / same VPN etc.) runs from a Mac. Tested on 3 Ubuntu's in different corners of the world, and on 3 Macs also in different countries. So from Ubuntu 20.04.5 LTS it *doesn't work* but from macOS Monterey v 12.6. it *works*. Could it be something specific to Ubuntu ?

anandhiemail
2023-01-09 15:55
HI Matt, Thank you very much for your response. Our teams use Scala and Typescript to write the Thrift calls.

chris.aguirre11
2023-01-09 16:45
has joined #general

chris.aguirre11
2023-01-09 16:54
Hi, I am a Developer who also would like to introduce contract testing to my team/company. I am not able to successfully install pact via NPM on an Amazon Ec2 instance with CentOS Linux 7. I get many errors related to 'g++' not found (gyp errors), and even after installing a c++ compiler, still have errors related to it. On the other hand, on a physical MAC laptop I have no issues at all installing Pact via NPM. Anyone here ever installed PACT on a bare bones Linux machine and got it working?

nicolas.barbey
2023-01-09 17:06
has joined #general

anandhiemail
2023-01-09 19:21
We have a library that generates Typescript from Thrift IDL files. Our framework calls that library internally, not directly. In that case, if I use the same Thrift calls in my Pact tests, it should work?

simon.petty
2023-01-09 21:11
has joined #general

edisonjen13
2023-01-09 22:25
has joined #general

matt.fellows
2023-01-09 22:26
Best to ask this kind of question in #pact-js channel next time Chris. But for now, under ?Instructions > Requirements? section, there is a link to https://github.com/nodejs/node-gyp#installation which discusses the dependencies required for this. To do any development on Mac OSX, you would had to install the XCode build chain, which covers those needs. Depending on your linux distribution, by default you may not have these

vika.karman
2023-01-10 08:53
Hello! I've got a general question regarding provider verification step. What happens when you run it? Is a test request gets generated from the pulled pact and goes through the providers handlers? We have argues in the team regarding whether it is the same when you run provider verification tests and when you generate provider's spec, push it to pactflow and let it to compare the consumer's and provider's pacts.

abubics
2023-01-10 11:48
Sounds like there might be some confusion between consumer-driven and bi-directional?

abubics
2023-01-10 11:49
Fwiw, I have only done consumer-driven. In that flow, the consumer tests generate a contract, it goes to the broker, which triggers provider verification. There's no provider pact.

vika.karman
2023-01-10 11:52
right...some people of my team think it is more easy to just generate a pact for provider and let broker to compare pacts. But I am not quite sure this will be the same as if we run provider verification. So this is what I am asking - if during provider verification we do more than just pulled consumer pact and provider specification comparison

abubics
2023-01-10 11:54
Yes, there's a significant difference. The consumer-driven flow gives more reasoning power. There's a nice article about it here: https://www.google.com/amp/s/pactflow.io/blog/schemas-are-not-contracts/amp/

abubics
2023-01-10 11:55
Basically, schemas can only tell you that the consumer and provider might not be incompatible.

vika.karman
2023-01-10 11:55
thank you! will read this!

abubics
2023-01-10 11:55
Np, I hope you can win your people over :pray:

vika.karman
2023-01-10 11:55
me too :)))

tjones
2023-01-10 13:29
> it is more easy to just generate a pact for provider and let broker to compare pacts. Definitely not.

tjones
2023-01-10 13:30
The point of pact is to be sure that two services can communicate with each other. With a spec-driven approach, the best you can get is ?they?re not definitely incompatible?

tjones
2023-01-10 13:33
Sometimes people who have graphql or grpc specs as part of their development flow say they don?t need contract testing. I think this is a bit like saying ?all our endpoints use json, so we don?t need contract testing?. Just because (for example) grpc ensures that the payload is receivable by consumers with older versions of the spec doesn?t mean that it will have the intended meaning.

tjones
2023-01-10 13:34
As far as I know, there is no ?provider pact? written by any pact framework at the moment. Pactflow?s BDC approach is based on a swagger spec, which isn?t a Pact.

vika.karman
2023-01-10 13:34
right

vika.karman
2023-01-10 13:34
just spec

tjones
2023-01-10 13:35
When a pact file is written, you are guaranteeing that you can send that request, and promising that you will understand that response (for each req/resp pair in the pact)

tjones
2023-01-10 13:35
this is important, because it?s not a specification that describes the design. It?s a list of examples that definitely work.

vika.karman
2023-01-10 13:36
and how exactly verification on provider side is made? is a request generated from the pact and "send" through the provider's handler?

tjones
2023-01-10 13:38
Yes, that?s right. You can think of it as replaying the requests, and seeing if the responses match what the consumer will understand (that?s not quite what happens, but the subtleties don?t actually matter in practice).

tjones
2023-01-10 13:39
The pact test which writes the file says: ?I definitely send this request, and I have checked that I can understand this response? When you do provider verification you are saying: ?I am checking that I can understand this request, and I definitely send that response?

vika.karman
2023-01-10 13:40
got this!

vika.karman
2023-01-10 13:40
Thank you Timothy! you gave me needed confidence

tjones
2023-01-10 13:41
You?re welcome! Let us know if there?s anything else we can help with.

tjones
2023-01-10 13:42
You?re welcome to invite the team in here and we can answer their questions directly, too.

vika.karman
2023-01-10 13:50
I will! thanks!

anandhiemail
2023-01-10 20:12
Hi Team, I am a QE and have just started learning about Pact and looking for possibilities to introduce it to our team. Do we have to write Pact tests close to the dev code only? Can we write contract tests in a different repo (other than dev repo) using Pact/Cypress? Would it still serve the purpose?

matt.fellows
2023-01-11 00:50
If you want to use the Pact framework on both the consumer and provider side, you really need the tests to be part of the code that is being tested (think of them as unit tests)

matt.fellows
2023-01-11 00:51
You could use tools like Cypress to generate pact files, but I wouldn?t currently recommend using that with Pact on the provider side

matt.fellows
2023-01-11 00:53
We do have a feature (in Pactflow only, so take note of that) that allows you to generate contracts from tools like Cypress and compare to an OAS file (see https://docs.pactflow.io/docs/bi-directional-contract-testing for what it is, the tradeoffs etc.) There are a number of example projects (https://docs.pactflow.io/docs/examples/) and blog articles (http://pactflow.io/blog) that go through both types of testing

anandhiemail
2023-01-11 00:55
Thank you Matt for the guidance. I will go through the docs and links provided.

siddharth.gupta
2023-01-11 09:20
HI , We have a two software components A & B. Communication is unidirectional from A to B . B is the consumer or lets say it subscribes\registers with A and A sends data to B on certain events on database . How can we implement Consumer driven Contrat testing in this case .I guess similar would be the case for software components which registers on a message bus

tjones
2023-01-11 09:30
Yes. B is the consumer here

tjones
2023-01-11 09:30
This would be what is called a ?message pact?

tjones
2023-01-11 09:31
I?m on mobile right now, but have a look for that in the documentation and you should be able to find some useful information. What you describe is a common use case for message pacts

antonello
2023-01-11 11:07
Solved. Here is the command we needed: ```pact-broker can-i-deploy --pacticipant=a_consumer --version=consumer_version --pacticipant=a_provider --latest --in_environment=Prod -b=broker_url -k=a_token```


matt.fellows
2023-01-11 11:25
I think this AMA we talk a bit about message pact strategies (for AWS SNS/Kafka, but we discuss the general principles): https://docs.pact.io/help/amas#ukeu

artem.z
2023-01-11 13:18
has joined #general

vika.karman
2023-01-11 13:18
@artem.z fyi

jrede
2023-01-11 17:57
has joined #general

artem.z
2023-01-11 18:15
Hi Team! thank you so much for your detailed explanation! happy to be talking to someone who actually make this work. So am i right that you?re saying that BCDC should only be used as a compromise when let?s say the ?provider team? doesn?t want to put too much effort? :wink: Thanks for sharing the post - however i was under the impression that the idea of it is to prompt people to use the commercial pactflow solution which is supposed to help with most of listed concerns (which we already do!) - in conclusion it suggests to learn _how you can make schemas work with contract testing_ Speaking of the specifics: my original idea was to implement it in a way described in pactflow https://docs.pactflow.io/docs/bi-directional-contract-testing/provider or https://docs.pactflow.io/docs/workshops/bi-directional/step3 (provider schema created -> provider schema validated against the provider implementation in a ?https://pactflow.io/blog/contract-testing-using-json-schemas-and-open-api-part-2/? style -> validation results and schema uploaded to broker -> broker validates consumer pact against provider schema). With such an approach it doesn?t seem to me that the concerns listed in the post are real, lemme try to go through them: 1 - not sure we faced any issues with that; if we use .yml schema the broker seems to understand it in a way we want. or am i misunderstanding what that means? 2 - totally valid! but is this fully solved with CDCT? for instance could we test with 5xx error from provider when it?s not caused by the inputs from consumer? 3 - looks like supposed to be solved by ?provider vefification step? from the workshop 4 - same (?provider vefification step? ) 5 - same (?provider vefification step? ) 7 and 8 apparently are supposed to handled by pactflow 9 - not sure is this could be a problem with OAS yaml schema ? In general, i understand what you mean when you say that the interactions generated by _consumer_ and ?replayed? against prodiver are more ?real?, i have same ?feeling?; but the tradeoff seems to be fair considering much easier implementation especially with multiple consumers Is there something i am missing? would really appreciate any pointers :wink: thank you guys and have a great day!

abubics
2023-01-11 23:57
Bi-directional is also a helpful stepping stone when adding testing to a large, established ecosystem. If you're starting from scratch, there's pretty much no compelling reason to avoid consumer-driven :innocent:

tjones
2023-01-12 03:42
I?m a bit unclear on what points you?re replying to with the numbers

vanitha.annamalai
2023-01-12 05:27
has joined #general

antonello
2023-01-12 07:46
Any thoughts on https://github.com/pact-foundation/pact_broker/issues/588? It should be a simple change but I?m not sure if it would be formally correct to have the provider version in the response. However it would save us from having to use the api to get the id for the environment and then get the latest prod version for the provider from the list of ?latest?.

artem.z
2023-01-12 08:10
ok seems everyone here is leaning to consumer driven approach then we shall try it, thanks again guys for your help! @tjones oh sorry i was replying to the problems listed and numbered in the https://pactflow.io/blog/schemas-are-not-contracts/ Boris shared above in the thread :sweat_smile:

jessy.li
2023-01-12 17:29
has joined #general

lcruz
2023-01-12 19:08
hi all -- I'm trying to find the talk / it might've been a podcast or video that made a specific reference to "collaborative" testing. I'm sure this is probably referenced across multiple talks but I can't seem to pinpoint which one it was :sweat_smile:

aronlmin
2023-01-13 02:13
has joined #general

tjones
2023-01-13 15:18
I?ve not heard of collaborative testing

buckley
2023-01-13 20:01
has joined #general

nickzakirov
2023-01-16 04:34
Ok so I did this repo to solve this problem https://github.com/NikZak/pact-proxy-rs

sashizen
2023-01-16 09:09
has joined #general

matt.fellows
2023-01-16 11:20
looking at this, are you not better off re-using existing record/replay tools, instead focussing on writing a converter to/from the common formats?

matt.fellows
2023-01-16 11:21
e.g. VCR -> Pact, Nock -> Pact, Polly -> Pact etc.?

matt.fellows
2023-01-16 11:21
that way, you don?t have to re-invent the record/replay bit?

matt.fellows
2023-01-16 11:22
Also I do think you need to be careful - in this way, you?ll miss out on the benefits of matchers and provider states, two very powerful aspects of Pact, without which will likely make your tests very brittle

matt.fellows
2023-01-16 11:22
?and of course, the unit testing bit Tim mentioned

matt.fellows
2023-01-16 11:22
I like to think of Pact as a unit testing tool for your API client, which also happens to do contract testing. If you think of it this way, you?ll be less focussed on generating a contract (and all that goes with that), and more about the test itself

nickzakirov
2023-01-16 11:36
Hi Matt. Thanks a lot for looking at this and chiming in. It is very possible that I still don't understand all of the strenghts of pact. To me the important part here was to make my tests effortlessly fast. I just replace the target url with this proxy server and then it records pacts and matches to this pacts in the next call. First run takes seconds, second run microseconds which is what I need. After some research and asking around I did not find anything like that. I am happy to add back all the missing features one by one if it is required. Or use something standard. (but it should not be that I write the whole request/expected response inside the test like everywhere proposed, that already exists in multiple versions) Would be great if you give some more detailed feedback. Possibly as issues on github. I believe that converters are needed if you want to connect to the web to get the info first time. And I had to rewrite some of the functionality of pact_mock_server to make matching faster (before it was taking >90% of program time) and to be able to interpret a modified url localhost:port/https/<url you actually need in the web without the scheme>

nickzakirov
2023-01-16 11:43
as for existing record/replay. Initially it was my intention but found nothing suitable in rust

nickzakirov
2023-01-16 11:44
I thought of using non rust stuff with test-containers. but it has own drawbacks too

nickzakirov
2023-01-16 11:54
Imagine I have a connector to the exchange that sends orders, reads market data, etc. I have to test it. I can not change the client, I would lose functionality interpreting incoming data. So i can not use some vcr client or whatever client. All I can "dependency inject" is the url and it's for the server to take all the work from here

nickzakirov
2023-01-16 11:55
so no other changes on the client side are allowed. could not find a solution for that

paula.muldoon
2023-01-16 14:00
Happy new year! We are doing team programming tomorrow and trying out this demo. This all makes sense - thanks (didn't know the contract has to be verified) and `can-i-deploy` looks just the ticket.

richardmccann
2023-01-16 15:37
has joined #general

yousafn
2023-01-16 17:03
Happy new year! Awesome sounds like fun, have a good day tomorrow :rocket: Feel free to reach out on here or send your teammates here is they have any other questions :slightly_smiling_face:

tjones
2023-01-17 03:48
> . (but it should not be that I write the whole request/expected response inside the test like everywhere proposed, that already exists in multiple versions) I think ? you need this, right? How would you avoid writing it out? Or, would it be better to automatically translate whatever expectation you already have into Pact?

nickzakirov
2023-01-17 04:05
well I do avoid writing it out. Just look at the example in the readme. I don't write out the expectation. I write whatever I receive as expectation into a pact and then use it as expectation when test is launched second time. I guess I fail to explain my use case.

eugene.malihins
2023-01-17 11:08
has joined #general

yusufjamalazam
2023-01-17 12:24
has joined #general

yusufjamalazam
2023-01-17 12:29
Hello I have a general question. I publish a pact with my consumer that has changes, it runs the webhook and trigger a workflow in the provider verification step. The consumer build however on can-i-deploy says there is no verification for this pact. Do I have to wait for the broker to return the verified pact as part of my ci.?

jbosca
2023-01-17 13:10
has joined #general

yousafn
2023-01-17 13:31
Yes, you can ask can I deploy to retry/poll whilst it waits for the provider verification that is triggered to return its result

yusufjamalazam
2023-01-17 13:49
is this done by passing --retry-interval or --retry-while-unknown flags to the can-i-deploy?


richardmccann
2023-01-17 15:11
Hi, I have a question about implementing Pact. I have been investigating Pact as a POC for a multi team project where the Consumer and Provider teams will be separate. I have created the POC following the best practice for CI/CD as described in the Pact documentation. There is one thing that I think will be a blocker for us to implement Pact and contract tests which is that the necessity of the Consumer code creating (or updating) the the contract first means that this work done by the Consumer team is left in limbo - it cannot be merged into the main branch and must be shelved until the Provider team 'get around' to fulfilling the contract. Under our definition of done this leaves that piece of work incomplete, and dependent on another team before it can be completed. We have tried to remove dependencies like this between teams as the teams are not always at liberty to drop what they are currently working on and so it may be some time before the provider work is done, leaving the Consumer code going stale on a branch. For reference the current process would be that the Provider team would develop the interaction first, test and merge to main, completing their story. The Consumer team could then implement the usage of the feature with no dependency on the Provider team. I would be interested to hear if others have faced this and how they have addressed it or what would the recommended approach be?

tjones
2023-01-17 15:32
> Under our definition of done this leaves that piece of work incomplete, and dependent on another team before it can be completed. How would you solve this problem without Pact?

tjones
2023-01-17 15:34
> For reference the current process would be that the Provider team would develop the interaction first, test and merge to main, completing their story. The Consumer team could then implement the usage of the feature with no dependency on the Provider team. Er. For equivalence, wouldn?t you say that the provider team can?t complete their story without the consumer team doing theirs?

tjones
2023-01-17 15:34
I mean, what happens when (inevitably) it turns out that the provider team made a mistake or the consumer team need more information in a response than they realised?

tjones
2023-01-17 15:35
I?m suspicious of a definition of done that lets one team mark a bit of work as done before the other team have validated that it works for them.

tjones
2023-01-17 15:36
> what would the recommended approach be? Pact is, by nature, consumer driven. This is definitely the recommended approach. The server exists to, well, serve. So, the ideal design process is to have the consumer tell it what they need.

tjones
2023-01-17 15:38
Where I?ve been forced to do something from the provider side first, my experience is that the overall implementation time (to get end-to-end working) is longer, less likely to be a well-designed API, and requires more rework

tjones
2023-01-17 15:38
A related question that might be worth raising is - if your teams are this dependent on each other, why are they separate teams?

tjones
2023-01-17 15:41
If you?re just trying to make sure that teams are not blocked, what I have found successful (and facilitated by Pact) is: 1) Consumer team writes the Pact 2) Provider team adds the verification to their backlog 3) Consumer team proceeds with mock responses (not even hitting any API) safely, since the mock responses can be exactly what the expected response was in the Pact 4) At some point, the provider team finish the verification, and you can use the real endpoint. This works really well for APIs that aren?t complex, or are a lot of read-only requests. Your milage may vary.

tjones
2023-01-17 15:43
> Under our definition of done What is this definition of done? I?m concerned that a consumer team wouldn?t be done without the provider team?s work, but the provider team can be done without the work of the consumer team. If either one of the teams haven?t done their bit, then presumably value is not ready to be delivered to users?

tjones
2023-01-17 15:46
Really, it seems to me that there?s a process problem that is unrelated to Pact. > this work done by the Consumer team is left in limbo - it cannot be merged into the main branch and must be shelved until the Provider team ?get around? to fulfilling the contract. This is true in your usual approach too, yes? It?s just not exposed, because the consumer team don?t even start the implementation while they?re waiting for the Provider team to ?get around? to building the endpoints.

komathypriya
2023-01-17 17:32
Hi Team, we are planning to use PACT for API Testing. Wanted to know is there a license involved in using PACTbrokers and Pact io? If so where can i look at that. If not, if Pact being a Open source how the PACTs are secured when its published in PACT io?

komathypriya
2023-01-17 17:34
PACT been recently acquired by Smartbear. Smart bear has a tool called Ready API, whats the difference being both API testing tools. We are opting for PACT, so trying to understand the benefits of PACT over Ready API.

komathypriya
2023-01-17 17:35
Can anyone help me on my decision ques

komathypriya
2023-01-17 17:35
questions

nickm
2023-01-17 17:49
Hi all, I?m having an issue and need some perspective/guidance. We are introducing a new provider service, and we have built the pipeline in to run the provider verification. We run our verification against `{"deployedOrReleased": true}` as we deploy to staging upon merge to main (assuming tests pass). Since we don?t have the provider in place yet, there?s no consumer test deployed against it. Unfortunately, running a `can-i-deploy` check fails with ```Computer says no ¯_(?)_/¯ No pacts or verifications have been published for version XXX of XXX``` To me, this shouldn?t be a failure. Am I missing something?

nickm
2023-01-17 18:02
I should note that pacts _have_ been published on non-main branches as a part of PR testing

dyptorden
2023-01-17 19:48
afaik, you only need to pay if you want to go with Pactflow. Otherwise it will be free (if you stick with Pact Broker)

kriegster108
2023-01-17 21:18
Hello quick question, our organization is using RDF(Turlte)/JSONLD for response types from our APIs vs just a standard static json response, is this type of testing possible with pactflow?

hehecx
2023-01-17 22:16
has joined #general

abubics
2023-01-17 23:24
> leaving the Consumer code going stale on a branch Feature toggles are usually used to address this, so the work can be "done" while not finally exercised, and not go stale on an old branch. I think Pact either has support for feature toggles now, or it's being worked on.

abubics
2023-01-17 23:25
Apart from that, I agree with Tim that this isn't really a Pact problem, but it might be highlighting other issues :slightly_smiling_face:

matt.fellows
2023-01-17 23:38
Pact Broker is open source (MIT Licensed) as is Pact (primarily MIT licensed)

matt.fellows
2023-01-17 23:39
Pactflow is a commercial offering (free for up to 5 integrations)

tjones
2023-01-17 23:39
No it hasn?t. Pact is open source. Pact is not Pactflow (who have been bought by smartbear)

matt.fellows
2023-01-17 23:39
Pactflow is a superset of the Pact Broker, with additional features

matt.fellows
2023-01-17 23:39
`s/PACT/Pact`

matt.fellows
2023-01-17 23:40
Pact is a contract testing tool, ReadyAPI is a functional/security/performance tool

matt.fellows
2023-01-17 23:40
you can use both at the same time, if you want.

tjones
2023-01-17 23:43
A key difference is that Pact offers no hosting - you have to host the broker yourself (there?s a docker image to make this straightforward). I think of Pactflow as a paid hosted broker with extra features (and a team of experts for support). I don?t work for Pactflow though, so that might not be the most accurate summary

jawaharsurapaneni
2023-01-18 00:36
has joined #general

kerrypmckeever
2023-01-18 02:12
has joined #general

matt.fellows
2023-01-18 06:56
Pretty much, i?m not sure Marketing would approve of that message though :laughing:

tjones
2023-01-18 08:19
I think ?with extra features? is definitely underselling it

paul
2023-01-18 16:56
has joined #general

jean.paiva42
2023-01-18 18:41
Hey everyone, is it possible to use pact-verifier to verify async communication (messages)? Should it work as long I return the response through an endpoint? I am just asking because it seems like sync pact use an array of interactions, and for async, it seems like we use `messages` . Would I be able to use it in a scenario like this?

hazem
2023-01-18 22:02
Hey all, I haven't quite found a nice pattern to define consumer pacts when the provider schema with proto3 type `oneof`? Curious if anyone has any matching examples for the following ```message FooResponse { string description = 1; repeated Field fields = 2; } message Field { string id = 1 oneof field_data { TextField textInput = 6; ChoiceField choiceInput = 7; } } ``` example json to match on ```{ "description": "foo", "fields": [ { "id": "123", "textInput": {} }, { "id": "123", "choice": {} } ] }```

uglyog
2023-01-18 22:05
What problem are you getting?

hazem
2023-01-18 22:05
Currently I've been writing two pacts for this using min=1 for the fields array and matching it contains each type possible type of object, in this case two different permutations. It feels like I'm not using the tool set right. Any suggestions would be greatly appreciated

hazem
2023-01-18 22:07
In my example above, there are only two choices, but in reality I have more than that. And the best I've come up with is using minLike matcher for a template for each type of possible choice.

hazem
2023-01-18 22:08
Otherwise, if I define one, then it's possible the other choices will break and I wont know.

uglyog
2023-01-18 22:15
That is the recommended way to use with Pact, have a test for each permutation, and you can control it with provider states.

hazem
2023-01-18 22:16
ok, so i am doing it right then.


basma.eldesouky
2023-01-19 10:24
has joined #general

alex.strizhak
2023-01-19 13:12
has joined #general

laura.porpiglia
2023-01-19 13:56
has joined #general

chimein.1234
2023-01-19 16:13
has joined #general

john295
2023-01-19 23:12
has joined #general

dominik.lukac.96
2023-01-20 10:33
has joined #general

david342
2023-01-20 15:07
Afternoon , I have set up a PactFlow integration with my SwagerHub, I have the correct URL and Token and have assigned a PactFlow Applications (which appeared in the relevant drop down - I assigned my consumer here - is this correct ? ) and created the integration. When I check "Check Compatibility" I see 'Compatible' but when I click "view compatibility result' I see "_This API does not yet have any consumer contracts_". Why is this , I have a contract in PactFlow which is assigned in the integration , would anyone know how to fix this error ? I think I have misunderstood the PactFlow application , could someone define that for me and how topush it to PactFlow . Thanks

yousafn
2023-01-20 16:03
Hello best asking in the PactFlow channel. You need to select the provider name in the integration option page in SwaggerHub

yousafn
2023-01-20 16:04
The provider name is used to get any associated consumer contracts. :ok_hand::skin-tone-5:have asked for us to clarify the wording there :facepunch::skin-tone-5:

david342
2023-01-20 16:04
OK Thanks . That would be the provider contract uploaded to PactFlow or the provider in the pact between the consumer and provider ?

yousafn
2023-01-20 16:07
The consumer contract in PactFlow has a provider name associated with it, that associates a provider with a consumer. Once you?ve uploaded a consumer contract it should show at least two applications in the integrations list in SHUB. Your consumer and provider

david342
2023-01-20 16:09
OK I have done that but still see the error , I must be doing something incorrectly. I'm afraid the documentation isn't clear for me. But thanks for your help

yousafn
2023-01-20 16:12
Can you show a screenshot of your pactflow main page and SwaggerHub PactFlow integration options? I can have a quick squiz to see if it?s correct

yousafn
2023-01-20 16:17
There are some other caveats, you haven?t followed from the docs. You need to upload your consumer contract with a branch property set

david342
2023-01-20 16:18
My provider name is GeoProvider

yousafn
2023-01-20 16:19
It uses the branch and recording deployments feature to ascertain which contracts to verify. You need the consumer publishing to a main branch ( main/master ) or whatever you set ( it is configurable in the broker )

david342
2023-01-20 16:21
Apologise how would I edit the branch in PactFlow I do not see that option ? I published the consumer contract via a gitHub action and do not see a option to set the branch there either.

david342
2023-01-20 16:29
OK I see your repo https://github.com/pactflow/example-consumer , I'll use that as a basis to publish my contract it seems to set a branch in the workflow. I appreciate your help thanks for your time . Have a good weekend

yousafn
2023-01-20 16:33
you would pass in the `--branch` property in the CLI call. This action does it https://github.com/pactflow/actions/tree/main/publish-pact-files https://github.com/pactflow/actions/blob/ffdabd8bf795ec7c769a977d82002e3e9add759f/publish-pact-files/publishPactfiles.sh#L15-L34 it gets the branch via the command `git rev-parse --abbrev-ref HEAD` and passes it into the CLI in the `--branch` call. The Pact CI/CD workshop introduces the concepts of branches and environments if it may be helpful https://docs.pactflow.io/docs/workshops/ci-cd/ Good luck chap and thanks for trying out the feature

luca.narbone
2023-01-20 16:39
has joined #general

jean.paiva42
2023-01-20 20:05
God bless you sir, as always :awesome-smiley:

bram.hautekiet
2023-01-22 22:32
has joined #general

benjamin.hess
2023-01-23 23:55
has joined #general

steve.jefferies
2023-01-24 09:47
has joined #general

nuno.frias
2023-01-24 10:44
Hi all, I have a contract that checks whether the `Authorization` header in the response matches a jwt regex. However when the provider test runs, it seems to be overriding the regex match and doing an exact match. Is there a different behaviour for the `Authorization` header ?

matt.fellows
2023-01-24 11:23
There's currently a bug in that exact feature


nuno.frias
2023-01-24 12:00
Thank you :+1:

aoife.drury
2023-01-24 14:36
has joined #general

yousafn
2023-01-24 20:23
Hey, Some material around the acquisition and what it means for Pact. https://docs.pact.io/blog/2022/04/06/pactflow-joins-smartbear and PactFlow?s sentiment towards open source and the positioning of Pact https://pactflow.io/blog/why-build-an-open-source-company/ TL;DR - We want it to be accessible to as many people as possible, but we also understand that larger enterprise customers who make the world work, also want the additional features and support that commercial tools such as PactFlow and ReadyAPI provide. SmartBear for example also SoapUI, the open source alternative to ReadyAPI. There is a plethora of documentation supporting these tools, on both of their own sites, and in others own words. Happy to answer any specific questions :+1:

perger1984
2023-01-24 21:04
has joined #general

ajaytaneja
2023-01-25 13:18
has joined #general

yousafn
2023-01-25 13:58
Happy Wednesday everyone! As Pact nears 10 years old (in April!), we are thinking about a birthday party/event to help celebrate it in style, and it wouldn't be a party without you all. We are currently thinking of ideas, so if we have any party-planners in the house, or any ideas, feel free to give me a shout. To kick it off, I'm really keen to try and get some local meetup's arranged globally, we have so many little Pact communities in far-reaching places, so ill start off with a couple of questions. ? Where are you from in the world? ? Would you be keen to attend, help organise or organise a local event? we aren't necessarily looking for Pact experts, anyone with an interest in Pact would be welcome ( I didn't say anyone as I can imagine AirBnB style internet party take-overs where 500 ravers turn up :sweat_smile: )

petr.sebek
2023-01-25 14:20
has joined #general

john295
2023-01-25 14:28
I am in San Diego and interested in attending

jaswanth.ooty
2023-01-25 14:47
Would be keen to participate in something at the birthplace of pact? ie. the DiUS Melbourne office! I?m sure they?d be accomodating :raised_hands::skin-tone-2:

sean.mccann
2023-01-25 15:25
has joined #general

tjones
2023-01-26 08:11
I don?t think that?s the birthplace of pact, but I?d attend a Melbourne party all the time

tjones
2023-01-26 08:11
I meant, ?all the same?. But I?m leaving the typo as I like what it implies about parties

jaswanth.ooty
2023-01-26 08:13
Haha! I could be totally wrong. I just took a stab in the dark :joy: But also, keen to know a bit more of the history. I know Yousaf wrote a blog about it. Time to head there :blush:

tjones
2023-01-26 08:15
I think Pact was born at REA, but someone who was there would be better to say for sure. The history is in one of the readmes somewhere. Of course, DiUS put a lot of effort in. That?s where I picked it up

tjones
2023-01-26 08:15
The history of pact would be a good topic for the 10 year birthday party



nirob726
2023-01-26 12:25
has joined #general

giuseppe.aina
2023-01-26 17:45
has joined #general

tanyaryzhova93
2023-01-26 18:26
Hi All! I have a question regarding provider verification. I would like to achieve the following: ? Webhook triggers the provider verification when a contract was changed and published from the consumer *merge request*. The provider should take the contract published from the *consumer?s merge request or the latest published contract.* ? When provider opens a merge request then the verification should happen for the contract which was published from the *consumer?s main branch*. I created a webhook in PactFlow and it triggers the verification anytime when the contract is changed/published. However, I can?t come up with the idea how to achieve the described scenarios above. I was thinking to provide a `--consumer-version-tags="main"` for provider verification job but then the first scenario won?t work, the provider will always take the contract with `main` tag which is assigned after merge to the main branch. Also, I can create two verification jobs for provider, one will be triggered by webhook only, another one will run when merge request is opened from provider. But it doesn?t look great. Do you have any ideas how I can achieve my desired result described above? Maybe I can play with tags somehow or pass something to my webhook? Please advice :slightly_smiling_face:

tanyaryzhova93
2023-01-26 18:47
I have the following webhook in PactFlow

tanyaryzhova93
2023-01-26 18:48
and the job in gitLab for the verification ```verify contracts: stage: validate image: name: pactfoundation/pact-ref-verifier:latest script: - >- /usr/local/bin/pact_verifier_cli --hostname="app" --broker-url="$PACT_BROKER_BASE_URL" --token="$PACT_BROKER_TOKEN" --loglevel="info" --provider-branch="$CI_COMMIT_REF_SLUG" --provider-version="$CI_COMMIT_SHA" --provider-tags="$CI_COMMIT_REF_NAME" --consumer-version-tags="main" --provider-name="dummy-microservice-provider" --publish rules: - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE == "push" - if: $CI_MERGE_REQUEST_ID - if: $CI_PIPELINE_SOURCE == "trigger"```

tanyaryzhova93
2023-01-26 19:11
in other words, I?d like to take the `latest` published contract version when a webhook triggers the verification. And I?d like to take the contract published from `main` branch only in other cases.

boris.pogrebitskiy
2023-01-26 23:00
has joined #general

matt.fellows
2023-01-26 23:30
Have you run through this workshop? https://docs.pactflow.io/docs/workshops/ci-cd

matt.fellows
2023-01-26 23:31
For (1), the webhook that fi res passes the contract that requires verification and triggers the build job

matt.fellows
2023-01-26 23:31
For (2) you should use the appropriate selectors that verifies the main branch

tanyaryzhova93
2023-01-26 23:36
No, I didn?t went through the workshop. I?ll have a look. What do you mean saying ?the appropriate selectors?? Like `--consumer-version-tags`?

rafael.luiz-cavalcant
2023-01-27 00:00
has joined #general

tanyaryzhova93
2023-01-27 00:44
ok, I had a look. And I changed my webhook and tried to use `--consumer-version-selectors="{\"mainBranch\": true}"` . 1. I provided the link to the latest contract. See screenshot. It works just fine and the latest published contract is taken until I provided selectors

tanyaryzhova93
2023-01-27 00:46
2. I added selectors such as `--consumer-version-selectors="{\"mainBranch\": true}"` for my gitLab verification job. But now contracts posted from the main branch are taken only by webhook despite the fact that I specifically provided the url to the latest published contract in webhook.

tanyaryzhova93
2023-01-27 00:50
Do you have any thoughts how I can handle it? Probably I need to say that I trigger the same gitLab verification job with webhook too, so have only one verification job

tanyaryzhova93
2023-01-27 00:51
my webhook

tanyaryzhova93
2023-01-27 02:35
I checked your repo https://github.com/pactflow/example-provider/blob/master/.github/workflows/contract_requiring_verification_published.yml Do I understand correctly that you created a separate job for webhook? It looks like I need to create one more job too specifically for webhook

abubics
2023-01-27 05:25
Melbourne and DiUS here :) always happy to host Meetups at our office, or other places (I'm also a GDG & RHoK organiser)

mwilso29
2023-01-27 12:41
Hi guys Im getting a 401 when trying to publish an openapi spec from the provider side using `pactflow publish-provider-contract` using pact_broker-client-1.66.1 locally. I know the broker-base-url and broker-token are fine as I can publish the consumer contract just fine. Any ideas?

mwilso29
2023-01-27 12:42
The open api spec is in json format is this an issue?

yousafn
2023-01-27 12:58
the parser should accept json from previous testing. Could you provide the command and OpenAPI spec by chance, and I can try and upload on my side I assume you haven't hit your integration limit? Is there any other messages in your logs?

yousafn
2023-01-27 13:00
yes, you should have two provider verification tasks, one for provider changes (which uses consumer version selectors) and one for webhook triggered builds by PACT_URL, these if you are using branchs/recording deployments rather than tags, will also provide a commit sha, so the webhook based verifications will take place against the latest on your configured main branch, and any released or deployed versions

tanyaryzhova93
2023-01-27 13:01
Thank you! I implemented two jobs and now it works as I wanted.

yousafn
2023-01-27 13:01
superb, top work @tanyaryzhova93

zkocsihorvath
2023-01-27 13:47
has joined #general

tjones
2023-01-27 14:17
#pactflow please

mwilso29
2023-01-27 14:29
I'm using a template openapi just to prove the functionality

mwilso29
2023-01-27 14:30
I have now started using the docker image cmd and made some progress. I am now receiving a 400 error `{"errors":{"contentType":["contentType is missing"]}}`

jorgen.x.andersson
2023-01-27 14:56
has joined #general

eugene.malihins
2023-01-27 16:36
try this ```pactflow publish-provider-contract \ schema.json \ --provider "name" \ --provider-app-version 1.0.0 \ --branch main \ --content-type application/json \ --verification-results=success.json \ --verification-results-content-type=json \ --verification-success \ --verifier=postman \ --broker-base-url=$PACT_BROKER_BASE_URL \ --broker-token=$PACT_BROKER_TOKEN```

shawn305
2023-01-27 19:08
Hi all. I've been working extensively with Pact, MSW, and the rust implementation of pact mock server to run Jest tests against our generated pact files. I've looked at the msw adapter and I'm hoping to get some understanding on two things: 1. Doesn't generating pact files from UI test interactions violate Pact's warnings against writing contracts based on UI test cases? 2. Pact provides an API for clearly identifying exact values vs. types of values that may change via matchers - I would expect generated test cases to either be too exact or too loose. Can we really generate quality contracts this way? I guess I'm trying to understand if we're losing significant value by using this adapter. I'm interested in the efficiency of it, though. Any insights are appreciated!

tjones
2023-01-28 01:15
What adapter?

tjones
2023-01-28 01:16
Anyway, generally: > Doesn?t generating pact files from UI test interactions violate Pact?s warnings against writing contracts based on UI test cases? Yes, try not to do this

tjones
2023-01-28 01:18
What is under test in a Pact test is the API layer. You _could_ drive that test from the UI layer, but I would expect it to be a pain to maintain and set up.

tjones
2023-01-28 01:19
It?s much better to put the test ?callipers? of Pact around what is actually under test - ie, the API client

tjones
2023-01-28 02:26
> generated test cases to either be too exact or too loose. A subtlety that you might not have thought of is that the generic matchers aren?t for describing the schema, they?re for making it easier to write tests. They?re a convenience, so you don?t have to have the same exact test data on both sides. If you say `{ name: like("Steve")}`, you?re saying ?this particular test case covers all possible responses where the name field is a string?

tjones
2023-01-28 02:28
Not ?the name field could be any string?

tjones
2023-01-28 02:29
(well, you are saying that too, but that?s not the main point)

tjones
2023-01-28 02:29
This is why there aren?t optional matchers for ?it could be this type or that type?

mlapis
2023-01-29 10:56
has joined #general

tim.malseed
2023-01-30 04:52
has joined #general

mwilso29
2023-01-30 08:37
Thanks @eugene.malihins was resolved in the pactflow channel

yshkedi
2023-01-30 08:39
Hi all, and thanks for helping in advance. In the company that I working for, contract tests were added, it understood why we need it and the value. We have a use case that was talked in our company and we would like to hear the opinion here from the pact?s experts, to understand what better to do. *Use case:* A msg contract was added. There is a service, that is kind of monolit, the service also send msg (by queue) and the same service consume this queue (maybe other instance). *Question:* Should we create a contract test for this use case? From one side: it more sensible that contract should be between 2 services. From the other side: this is a big service and we still want to verify that nothing break. Would like to hear your opinon. @aram FYI

matt.corby-eaglen
2023-01-30 11:47
has joined #general

matt.fellows
2023-01-30 12:09
It might be worth asking a few other questions: 1. What other protections do you have in place for this if you didn?t use Pact? 2. What?s the harm in trying it? One issue you will probably run into is deadlocks in builds where a consumer is waiting for a provider (itself) or vice versa.

yshkedi
2023-01-30 12:13
thanks for your comment. 1 - tests inside the serivce 2 - it will work, but from design aspect, if it is true. Regarding the ppossible issuee, it is know, should sepeprate the level of the consumer and provider test (will not be in parallel)

ulises.cervino
2023-01-30 12:38
has joined #general

m.gruehn
2023-01-30 13:04
has joined #general

shawn305
2023-01-30 13:23
@tjones thanks for the response here! Replying to a couple of your comments: 1. The adapter I'm referring to is `pact-msw-adapter`: https://github.com/pactflow/pact-msw-adapter. MSW (mock service worker) is used here to capture requests and generate pact files on the fly without any actual pact test authoring by the engineer. Which, if this is truly a viable approach to contract testing, may be a game changer. Pretty much no one is using it, but it's official from Pact. So I'm at least intrigued. 2. I did not realize `"Steve"` and `Matchers.like("Steve")` produce identical output in the pact file, wow. Good point on the role of matchers, that is indeed subtle. One of the biggest challenges for contract testing is the paradigm shift, I'm still wrapping my head around that. So maybe using the adapter is a fine approach, and it's up to us to target tests specifically against the API layer. The thing that stands out to me, though, is the experience based feedback from Pact folks is that using UI tests with Pact should be avoided because the written tests are brittle and maintaining them is overly cumbersome while providing limited value. The adapter arguably changes this - we're not writing tests, pact files are just generated based on the tests, so they may maintain themselves to an extent. I still don't have a lot of real world experience with Pact yet, so wanted to see if this rang true at all for folks who do.

tjones
2023-01-30 13:58
> but it?s official from Pact From Pactflow. A different thing

tjones
2023-01-30 13:59
Pactflow != Pact

tjones
2023-01-30 13:59
But, thanks for the link, I?ll take a look

tjones
2023-01-30 14:01
> The adapter arguably changes this - we?re not writing tests, pact files are just generated based on the tests, so they may maintain themselves to an extent. Hmmm? At first glance, I would say that it feels like it would have the same drawbacks long term, but be much faster to get going. Provider states would be the hard part

tjones
2023-01-30 14:02
In http testing (which you?re probably doing if you?re using this mock service worker thing) you?ll have situations where the same request would generate different responses in different provider states

tjones
2023-01-30 14:05
> and it?s up to us to target tests specifically against the API layer You?re 100% right about this. This, I think, is the main part of your question - if, in your situation, it?s possible to write UI tests that target the API layer, then you?ll be ok. If not (as is usually the case, at least long term), then you might be in for a bad time

ulises.cervino
2023-01-30 14:28
hi all, I have a question about consumer tests: does it make sense, in general, for a consumer to write a test that expresses something like "when I fetch an entity with ID 1, e.g. GET /entity/1, I expect a response entity in json, and the field id in there should also have the value 1"?

ulises.cervino
2023-01-30 14:29
you can check via regexes that the string in field "id" is exactly "1", but that doesn't work with provider states (or at least I couldn't figure out how to make it work) since the pact has the hardcoded string "1", and not as an example

martin.ineichen
2023-01-30 15:07
has joined #general

ch.pascucci
2023-01-30 15:22
has joined #general

grace.tree
2023-01-30 16:03
has joined #general

ulises.cervino
2023-01-30 19:39
another question: how do you folk agree on naming? not just participants' names, but provider states, variable names, etc.?

ulises.cervino
2023-01-30 19:39
we're in a situation in which we have several teams writing consumer tests, while others are writing provider tests, and right now the solution to that is to "hop on a zoom call" but that's ad-hoc a best

pryan
2023-01-30 21:25
has joined #general

andy.jenness
2023-01-30 21:29
has joined #general

abubics
2023-01-31 01:26
This depends how you handle provider states inside your provider. Different language bindings have slightly different options. Depending where you provide the test content for your states (e.g. db stub, domain layer stub, etc), you'll have different options for how those values can be injected, and how static/dynamic you want those states to be.

abubics
2023-01-31 01:26
The original way of declaring interactions doesn't have dynamic path matching, because you need concrete examples to test against. I think that option might be there now, but I don't really use it.

abubics
2023-01-31 01:28
Contracts are definitely not a replacement for conversations :slightly_smiling_face: (as it says https://docs.pact.io/faq#who-would-typically-implement-pact)

abubics
2023-01-31 01:29
it might be a good idea to come up with a naming scheme, and document it somewhere, so you don't have to have to have the discussion from first principles every time

lijinze01
2023-01-31 02:36
Guys, why my webhook is always Not Run??? I changed the contract, and I can also manually kick off wehook, how come my webhook status is always Not Run? And it is not automatically triggered either. Anyone can give me some clue? Thanks in advance.

dyptorden
2023-01-31 07:52
what event are you using for the webhook @lijinze01?

ulises.cervino
2023-01-31 07:57
right, not trying to prevent conversations :slightly_smiling_face:

ulises.cervino
2023-01-31 07:57
but I'm thinking that agreeing on strings for everything, and hoping that they still match 6 months later is a bit brittle

ulises.cervino
2023-01-31 07:57
and sadly, in my experience, documentation rots faster than software

ulises.cervino
2023-01-31 07:58
just trying to formalise and add more visibility to these agreements

ulises.cervino
2023-01-31 08:00
in pact-jvm you can specify that a path depends on a provider state (value) like an ID for instance, and that's fine, it makes the provider more flexible in the presence of auto-gen IDs, however what I couldn't quite pin down is the following: the consumer says "when I get entity with ID 1 I will confirm that the response has the same ID", but also keep this ID variable so that the provider is not forced to have an entity with ID 1 created when providing the state

ulises.cervino
2023-01-31 09:46
if you're interested I have a proposal; in fact I'd love to run it by you folk

abubics
2023-01-31 09:50
Right. There are a couple of separate things going on. ? The consumer and provider don't talk to each other at the same time. ? Depending where you cut your provider for stubbing, you may or may not need to "have an entity with ID 1 created when providing the state". You don't need to actually persist anything unless you want to, you can just pretend you have a real entity (in-memory), with whatever values your state describes, and return it (across the network boundary). ? Not sure if this is what you're implying, but Pact doesn't do behaviour. Each interaction should be agnostic of all others.

abubics
2023-01-31 09:51
To describe an interaction with an ID in the GET (request), which is also returned in the body (response), you just need a matcher in the body (response expectation) with the same ID (by value, not by type). I think that's a canon example in the docs.

abubics
2023-01-31 09:51
(The example with alligators, maybe?)

abubics
2023-01-31 09:53
If you've got some sample code, a concrete explanation might be easier :slightly_smiling_face: I don't know what language/platform you're using, though.

ulises.cervino
2023-01-31 09:53
right, seen that, perhaps I didn't write my tests correctly, for instance in my consumer (pact-jvm) I have call like `pathFromProvider("/entity/${id}", "/entity/1")`

ulises.cervino
2023-01-31 09:54
and then in the expectations part I have something like `body.stringMatcher("id", "1")` (using lambdadsl)

ulises.cervino
2023-01-31 09:54
that's fine on the consumer side of things

ulises.cervino
2023-01-31 09:55
but then it all crumbles on the provider side of things, because I'd expect to be able to return a map like `"id" -> 100` and have the pact be verified no problem

ulises.cervino
2023-01-31 09:55
the value of the ID is immaterial, the check here is "when I get entity with ID N, I expect a field "id":"N" in the response"

abubics
2023-01-31 09:56
I'll need to look up the docs, but you don't want to match on the String type (then it could be anything, including random unicode). You want a String value matcher. It might be `body.stringValue` or `body.string`.

ulises.cervino
2023-01-31 09:56
and the reason I was thinking about this sort of test is because I could easily introduce a bug in my provider whereby I change the ID of the returned entity, and this is important on the side of consumers because this ID is shared state across consumers (it's a shopping-cart ID if it helps)

ulises.cervino
2023-01-31 09:56
I tried with `stringValue`, but then there was no matchers in the pact.json, which was a bit confusing

ulises.cervino
2023-01-31 09:56
but perhaps that's it

abubics
2023-01-31 09:57
yes, without matchers, it will match on the literal value :+1:

abubics
2023-01-31 09:58
I don't work for Pact, but I think everyone is always keen for improvement ideas ^_^

abubics
2023-01-31 09:59
I think the reason there's no formal guidance around it, from the Pact side, is that there are so many different ways people like to do things, and there's not a one-size-fits-all solution. All of the ways I've seen people add structure to state names encodes significant abstraction that's not rarely warranted for all other users.

abubics
2023-01-31 10:00
That said, there's a bit more structure added in more recent versions, with support for lists of state names, and additional maps for metadata. This seems to get people a lot further down the path.

ulises.cervino
2023-01-31 10:00
even on the provider side of things?

abubics
2023-01-31 10:01
Yep, the way the contract describes matching has to work the same on both sides, otherwise it's not reliable. If it doesn't, that's probably a bug.

abubics
2023-01-31 10:02
But also, the contract file isn't really intended for human consumption, so the DSL written there may not be intuitive. The tests should describe the expectations in a more digestible way.

yousafn
2023-01-31 11:06
Would love to hear your ideas @ulises.cervino! I think I would like to see the ability to easily see provider states in use at a glance for a provider, and which consumers are using any given state description. This would allow me to strike up the right conversations, if someone isn't using the right string on the consumer side, or to help authors find existing states to use. The consumers often may not have access to the provider codebase explicitly so can only traverse other contracts.

ulises.cervino
2023-01-31 11:12
I'll play with it a bit more and report back, thanks for your help

ulises.cervino
2023-01-31 11:13
the tl;dr for what I had in mind is to have a broken openapi spec describing (enums) consumer/provider names, provider states, and variable names

ulises.cervino
2023-01-31 11:14
possibly one of the biggest benefits there is code generation + IDE autocompletion for discovery of these things

ulises.cervino
2023-01-31 11:14
what I've seen at work is that many people write both consumer and provider tests, and so they can have a central class (in Java for instance) with enums for these

ulises.cervino
2023-01-31 11:14
but that's in a single repository, single team, etc. It's easy.

ulises.cervino
2023-01-31 11:15
we (my team) are in a position where consumer tests will be written by other teams, in 2+ languages, and we need to coordinate and communicate names, states, variable names, with everybody

ulises.cervino
2023-01-31 11:15
so I'm planning on writing this spec and distribute it + give instructions for code generation

jcarlos.anast
2023-01-31 12:24
has joined #general

leonardo.saragiotto
2023-01-31 12:32
has joined #general

lijinze01
2023-01-31 21:33
@dyptorden I am using contract_requiring_verification_published, but not sure why, webhook always not getting triggered, so frustrating lol

lijinze01
2023-01-31 21:36
Actually thanks for your reminder:) I just changed it to contract_published, it works

matt.fellows
2023-02-01 04:38
Just thinking for better possibilities here, because these seem brittle and look like workarounds (which may be of course acceptable in the short term)

matt.fellows
2023-02-01 04:41
*What if* all of the provider states and any associated parameters/data could be enumerated within the Pact Broker (probably attached to a provider-role pacticipant), and then annotated from within the Pact Broker with what their purpose is? e.g. a form of ?data dictionary?

matt.fellows
2023-02-01 04:43
I?m not sure I follow the OAS argument, how would IDE code completion help here? Also, why you would need the consumer/provider names in an OAS given you can see them in the Pact Broker already? What additional value to you get from it being in the OAS? I?m guessing you may want a way to control what names can be used or control who can create them?

matt.fellows
2023-02-01 04:51
This adapter (and others like it - e.g. wiremock, cypress) are really not designed to work with Pact (the tool) but to produce a pact file (contract). The pact file is an interoperable format that can be used in other contexts - in this case, it?s really designed for use with the Pactflow BDCT feature: https://docs.pactflow.io/docs/workshops/bi-directional-contract-testing. Doing so whilst still verifying pacts using the Pact tool still has the potential for several drawbacks as per other articles. In particular (and as mentioned), matching rules, provider states and the proliferation of tests are still causes for concern. I?m going to have a standard warning/note added to these adapters Github readme?s to make this much clearer.

matt.fellows
2023-02-01 04:52
It might be possible to add https://github.com/pactflow/pact-cypress-adapter/pull/19 and https://github.com/pactflow/pact-cypress-adapter/pull/22 which alleviate part of this, but that will also have its own set of tradeoffs.

dyptorden
2023-02-01 06:50
you are welcome Jay :wink:

ulises.cervino
2023-02-01 08:12
a central registry is the general concept, however not every consumer/provider is _initially_ integrated with the broker, so using the broker as a central repository of names/state-names/variable-names is a fine idea, but might not work all the time

ulises.cervino
2023-02-01 08:13
regarding IDE completion, OAS is only the source of truth, each participant would have to generate code (the models -- which would be nothing but enums) before they can get their IDE to auto-complete things

ulises.cervino
2023-02-01 08:14
further benefits of distributing OAS as an artefact is versioning, auto-upgrades (via automated jobs or bots like renovate https://github.com/renovatebot/renovate)

bhavyashree.r
2023-02-01 08:52
Hi.. Is it possible to host pact broker centrally without using pactflow ? If yes can someone please help me with the steps .

matt.fellows
2023-02-01 09:09
Or course. We provide a ruby app and docker container. See here for broker docs: https://docs.pact.io/pact_broker Hosting concerns generally outside the scope of this forum though - there are plenty of better places for that.

dyptorden
2023-02-01 09:16
@bhavyashree.r we keep our pact broker in an EC2, so yes it can be done. Initially we started it along with a postgres using a docker compose. Later, the posgres was moved out of ec2 in an Aurora RDS, so I can confirm that you have plenty of flexibility to host either the broker or the postgres wherever you need

matt.fellows
2023-02-01 10:05
If it wasn't firing before but is now, maybe it didn't need to fire in the first place? I.e. it didn't require verification?

ulises.cervino
2023-02-01 10:26
ok, I gave it a go and it didn't so what I was hoping it would do

ulises.cervino
2023-02-01 10:27
let me try to sanitise the code a bit before sharing

ulises.cervino
2023-02-01 10:30
```Consumer: --------- @Pact(consumer = "C", provider = "P") RequestResponsePact getExistingLiveBasket(PactDslWithProvider builder) { return builder.given("a LIVE basket exists") .uponReceiving("retrieve LIVE basket") .headers(REQUEST_HEADERS) .method("GET") .pathFromProviderState("/${basketId}", "/" + existingBasketId) .willRespondWith() .status(200) .headers(RESPONSE_HEADERS) .body(LambdaDsl.newJsonBody( body -> body.stringValue("basketId", existingBasketId.toString()) .stringMatcher("status", "LIVE")) .build()) .toPact(); } @Test @PactTestFor(pactMethod = "getExistingLiveBasket", pactVersion = PactSpecVersion.V3) void createBasket_whenServiceIsRunningFine(MockServer server) throws JsonProcessingException { ResponseBasket responseBasket = RestAssured.given() .headers(REQUEST_HEADERS) .when() .get(String.format("%s/%s", server.getUrl(), existingBasketId)) .then() .statusCode(200) .extract() .as(ResponseBasket.class); assertEquals(existingBasketId, responseBasket.getBasketId()); assertEquals(ResponseBasket.StatusEnum.LIVE, responseBasket.getStatus()); }```

ulises.cervino
2023-02-01 10:31
that's the consumer test (using pact-jvm junit5 + resassured)

ulises.cervino
2023-02-01 10:31
regardless of language, I'm hoping it's self-explanatory

ulises.cervino
2023-02-01 10:31
on the provider side of things I got: ``` @State("a LIVE basket exists") Map liveBasketExists(Map _ignored_params) { Map<String, Object> state = new HashMap<>(); InternalBasket internalBasket = repository.createBasket(TestSupport.Repository.basketWithDefaults()).orElseThrow(); // the key in this state-map corresponds to the variable in the expression in the consumer test, i.e. in the // example consumer test we have a call like .pathFromProviderState("/${basketId}", ...) state.put("basketId", internalBasket.getBasketId()); return state; }```

ulises.cervino
2023-02-01 10:32
which in principle should do what we want (create a basket and then provide its ID back for the pact to be verified)

ulises.cervino
2023-02-01 10:32
however the pact has an expected request which uses the ID generated by the consumer

gsouza
2023-02-01 15:17
Hey there! Do we have a documentation about how to setup pact at github actions?!

barry.irvine
2023-02-01 15:52
has joined #general

yousafn
2023-02-01 16:03
Hey Hey, How do you mean? To run the Pact CLI tools? To run a consumer or provider test?

gsouza
2023-02-01 16:09
I mean, run at CI/CD tools Run a consumer and provider test

gsouza
2023-02-01 16:10
I fund CI/CD setup Guide

yousafn
2023-02-01 16:11
You can download the pact ruby standalone here, which you can extract and then in any CI system https://github.com/pact-foundation/pact-ruby-standalone examples here https://github.com/YOU54F/pact-cli-action https://github.com/pactflow/actions all these examples run on GitHub actions https://docs.pactflow.io/docs/examples although they are for PactFlow, it is easy to substitute for a Pact Open Source broker, by using `USERNAME` / `PASSWORD` over `TOKEN`

yousafn
2023-02-01 16:13
https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event I would check the list of pre-reqs > Use of this webhook requires that: > ? the provider's https://docs.pact.io/pact_broker/branches#pacticipant-main-branch-property is configured > ? verification results are https://docs.pact.io/pact_broker/branches#configuring-the-branch-when-publishing-verification-results or you are https://docs.pact.io/pact_broker/branches#automatic-branch-creation-from-first-tag (even if you use trunk based development, and only ever use one branch) > ? the exact commit of a provider version can be determined from the version number used to publish the verification results (ie. it either _is_ the commit, or _contains_ the commit as per the Pact Broker https://docs.pact.io/getting_started/versioning_in_the_pact_broker#guidelines) > ? any deployments and releases are recorded using the `record-deployment`https://docs.pact.io/pact_broker/recording_deployments_and_releases`record-release`https://docs.pact.io/pact_broker/recording_deployments_and_releases.

gsouza
2023-02-01 16:15
I'll take a look, thanks!

gsouza
2023-02-01 16:29
@yousafn and about this link https://docs.pact.io/pact_nirvana ?!

yousafn
2023-02-01 16:37
what is the question?

gsouza
2023-02-01 16:42
I mean, is this a valid doc to follow?!

dyptorden
2023-02-01 16:43
hi guys - is there a way to separate the publishing of the provider results back to the broker from the actual run of the provider tests? (somehow similar to running consumer tests and publishing them in the broker)

yousafn
2023-02-01 16:44
it is yes :+1:

yousafn
2023-02-01 16:45
You can publish verification results to the broker if you wanted to https://docs.pact.io/provider#publish-verification-results-to-the-pact-broker

dyptorden
2023-02-01 17:00
Yousaf, how I have it now is that I have the `pact.verifier.publishResults` property set to `true` in the surefire, so the results get published. What I intend to do is to have 2 separate stages: 1. run tests 2. publish the results

yousafn
2023-02-01 17:20
sounds plausible, I've not tried it myself. may be worth spinning up the scenario on a local broker to test :slightly_smiling_face:

marcin.slowiak.007
2023-02-01 18:28
has joined #general

eddie
2023-02-01 22:47
For pact verifier (provider) implementations, what is the expected behaviour if a given interaction is missing the `providerState` key? Should the verifier still make a call to the provider-states endpoint or should it skip doing that and go directly to making the request defined by the interaction? See https://pact-foundation.slack.com/archives/C9UTHV2AD/p1675291386716379 in #pact-net.

hoon.jung
2023-02-01 23:53
has joined #general

matt.fellows
2023-02-02 01:23
> when I get entity with ID 1 I will confirm that the response has the same ID I?m not sure this is an important thing to capture in a contract test. This smells more like a functional test to me

matt.fellows
2023-02-02 01:26
I must be missing something sorry, i?m still confused about the relationship of the OAS -> consumer/provider names, states, variables etc. Could you perhaps show me what the OAS would contain to solve this problem?

andhika.hasiholan06
2023-02-02 03:51
has joined #general

abubics
2023-02-02 04:30
I've definitely done this before, even if it smells that way, there's no technical limitation in the Pact spec. This code is over 5 years old, and while JS, does the same thing: ``` describe('can get a specific experiment', () => { // given: beforeEach(() => provider.addInteraction({ state: 'a view and two samplers with experiments', uponReceiving: 'request to show experiment 0 in sampler 1 in view 0', withRequest: { method: 'GET', path: '/view/0/sampler/1/experiment/0', headers: headers.request }, willRespondWith: { status: 200, headers: headers.response, body: { name: like('Some experiment'), id: '0', metrics: eachLike({ type: 'event', name: 'view' }, { min: 1 }), variants: eachLike({ name: 'jim', data: '' }, { min: 2 }), state: like('unscheduled') } } }) ); // when: it('', () => client.experiment .get(0, 1, 0) // then: .then(body => { expect(body).to.eql({ name: 'Some experiment', id: '0', metrics: [{ type: 'event', name: 'view' }], variants: [{ name: 'jim', data: '' }, { name: 'jim', data: '' }], state: 'unscheduled' }); }) .catch(fail)); });```

abubics
2023-02-02 04:32
That interaction comes out like this in the pactfile: ``` { "description": "request to show experiment 0 in sampler 1 in view 0", "providerState": "a view and two samplers with experiments", "request": { "method": "GET", "path": "/view/0/sampler/1/experiment/0", "headers": { "Accept": "application/json" } }, "response": { "status": 200, "headers": { "Content-Type": "application/json" }, "body": { "name": { "json_class": "Pact::SomethingLike", "contents": "Some experiment" }, "id": "0", "metrics": { "json_class": "Pact::ArrayLike", "contents": { "type": "event", "name": "view" }, "min": 1 }, "variants": { "json_class": "Pact::ArrayLike", "contents": { "name": "jim", "data": "" }, "min": 2 }, "state": { "json_class": "Pact::SomethingLike", "contents": "unscheduled" } } } },```

abubics
2023-02-02 04:32
So there might be something broken in the Java DSL, or the wrong DSL part is being used. I'm not too sure what the right DSL method is in Java, though.

abubics
2023-02-02 04:37
Ooh, I found one: ``` "gets an existing biller" { val pact = builder .given("a cached biller list") .uponReceiving("a request for biller details").run { headers(authHeaders) method(GET) path("/bpaybiller/24208") } .willRespondWith().run { headers(contentTypeHeaders) status(200) body(LambdaDsl.newJsonBody { with(it) { stringValue("code", "24208") stringType("name", "SOUTH EAST WATER") stringType("longName", "SOUTH EAST WATER CORPORATION") } }.build()) } .toPact() verify(pact) { fetchBiller( GetBillerDetailsRequest(code = "24208") ) shouldBe Response.Success( BpayBiller( code = "24208", shortName = "SOUTH EAST WATER", longName = "SOUTH EAST WATER CORPORATION" ) ) } }``` This one is also over 5 years old, and while Kotlin, is using the same Java8 Lambda DSL, I think.

abubics
2023-02-02 04:37
So, `body.stringValue("code", "24208")` worked for me all the way back then. If it's not working now, there might be a bug.

matt.fellows
2023-02-02 07:17
I?d be very surprised if you couldn?t do that in Java

ulises.cervino
2023-02-02 08:53
when I use `body.stringValue(...)` nothing comes out in the pact file, furthermore we're using `pathFromProviderState`. You maybe have a point about a check like "has the same ID as the path I queried" being a non-quite-a-contract-test thing. We can certainly add other sorts of tests that cover this scenario, however I got curious and I suspect many/most our consumers will come up with that question.

ulises.cervino
2023-02-02 08:54
yes, of course, let me give you an example. Say we have consumer `C` and provider `P`. In pact-jvm you annotate tests with `@Consumer("C")` and `@Provider("P")` on both ends. Further, in the consumer you write stuff like `.given("an expected state for the provider to be in")` and in the provider tests you also add `@State("an expected state for the provider to be in")` and so on.

ulises.cervino
2023-02-02 08:55
now imagine the team of the consumer saying "you know, "C" is a bad name for our consumer, it should be "VeryCoolConsumerC" instead!" the team agrees and change their tests

ulises.cervino
2023-02-02 08:55
now only older pacts (for consumer "C") are being verified by the provider, and not the new ones

ulises.cervino
2023-02-02 08:56
of course this can be solved by a "quick zoom call", which I find brittle (I can share stories about OAS and quick zoom calls -- tl;dr don't trust people, trust code)

ulises.cervino
2023-02-02 08:57
my proposal: have an OAS with stuff in it such as ```components: schemas: Consumer: description: Service consumer enum: - basket-storage - basket-checkout - flight```

ulises.cervino
2023-02-02 08:59
from that you can generate code, in Java you'd end up with an enum `Consumer`, with instances such as `BASKET_STORAGE` (you get something similar for JavaScript too)

ulises.cervino
2023-02-02 08:59
so, what's the point? now if you depend on the OAS (and you generate the code) in your project, with the help of your IDE you can discover participant names, provider states (there'd be a section in the OAS for provider states), and more.

ulises.cervino
2023-02-02 09:00
say someone changes their consumer name from `C` to `VeryCoolConsumer` , when a new version of the OAS is published (and people should always auto-upgrade) now you'd get compilation errors

ulises.cervino
2023-02-02 09:00
so this raises the visibility of an actual issue (newer pacts aren't being verified)

ulises.cervino
2023-02-02 09:01
guess how many pipelines I've seen where people allow the verify-job to fail because it couldn't find a contract or something similar? (too many, and this is of course an issue in and of itself eh)

abubics
2023-02-02 09:03
If `stringValue` doesn't make changes in the Pactfile, it's a bug. It'd be great if you could raise a bug on Github :)

jhordies
2023-02-02 09:59
has joined #general

matt.fellows
2023-02-02 10:08
It feels like you?re just moving the problem around - yes sure the OAS has code gen, but now you: 1. Need to update all of the places you use Pact to be aware of the OAS / schema 2. Need a way to manage the OAS so that you always have the latest version 3. Need a way to version the OAS reliably 4. ? without those things the risk of having out of date information anyway. The pact broker already has this information, there must be another way! (please don?t not do this if you think it will work for you of course! But I?m trying to take your requirement and extrapolate it to a general solution that might benefit others)

ulises.cervino
2023-02-02 10:16
yes, great observations, we have 1-3 sorted out, but the out-of-sync issue is still there

ulises.cervino
2023-02-02 10:31
cool, I'll try to triple-confirm I'm not talking out of my bum and then raise an issue if necessary, but thanks for double-checking my expectations

ulises.cervino
2023-02-02 10:32
sorry, was in a meeting and that's why I was a bit terse: while the info is in the broker, a participant might move on from what's in there (name changes, state-name changes, and even things like variable names in expressions which aren't in the broker -- they're in the pact alone)

ulises.cervino
2023-02-02 10:33
the point of the shared registry (in OAS form in my head right now) is to raise visibility for when there's change, and to add discoverability. This sort of mechanism also doesn't really rely on a broker, so in principle you could use this + S3 buckets for sharing pacts (I know you lose a lot of functionality if you do this though)

amanda.santos
2023-02-02 14:19
has joined #general

keith.w
2023-02-02 15:57
has joined #general

gazal.gafoor
2023-02-03 00:13
has joined #general

ulises.cervino
2023-02-03 08:48
ok, did a bit more digging. I didn't look into `stringValue`, but I did look into `valueFromProviderState` which is the way of telling the provider, via the contract: this field will have a value that you need to fill in.

wesleythomaswilliams
2023-02-03 11:06
Great to see more UK folks here. A bit lttp to comment on the thread. Interesting @sam774 that you have a principal test engineer, that role doesn't even exist in Sainsbury's. It's a bit of a free for all on how we test and what we use to test, with little to no technical guidance.

sam774
2023-02-03 11:07
It's a new role for us too I believe, as we've started to bring test within the engineering fold. Mind you Greg's doing a fantastic job in the role

sam774
2023-02-03 11:35
Thanks both, very useful. Yeah, I also see with SOAP services that we use there are tons of optional elements, which means the utility of applying any form of rigour to them is very limited. I've had some success with snapshot testing on the client side using Jest, so we can capture the SOAP we are sending and check it isn't unintentionally drifting. That says nothing about the validity of the SOAP request against the schema so we have to trust there. It's at least a step forward though

dyptorden
2023-02-03 11:38
hi guys I try to disable the telemetry by setting the `PACT_DO_NOT_TRACK` to *true* (similar to the way I am setting the `pact.verifier.publishResults` to *true* which *works*). Unfortunately, I still get at build the message: ```Please note: we are tracking events anonymously to gather important usage statistics like JVM version and operating system. To disable tracking, set the 'pact_do_not_track' system property or environment variable to 'true'.``` which makes me believe it is not working. Is there another way of writing the `PACT_DO_NOT_TRACK` (e.g. with dots)? The Surefire looks like: ```<systemProperties> <property> <name>pact.verifier.publishResults</name> <value>true</value> </property> <property> <name>PACT_DO_NOT_TRACK</name> <value>true</value> </property> </systemProperties>``` Thanks,


dyptorden
2023-02-03 12:30
thank you @yousafn. It worked

dyptorden
2023-02-03 12:31
can you please update the https://docs.pact.io/telemetry page by adding the variable with low case?

dyptorden
2023-02-03 12:31
it only shows the caps one

yousafn
2023-02-03 12:31
you can edit the page at the bottom, there is a little pencil :+1: ty

yousafn
2023-02-03 12:32
good catch :+1:

dyptorden
2023-02-03 12:32
oki, will do

dyptorden
2023-02-03 12:32
last thing: I wanted to disable the telemetry because it was causing an err in our CI\CD

dyptorden
2023-02-03 12:33
```2023-02-03 12:13:40.891 WARN --- [ Thread-4] au.com.dius.pact.core.support.Metrics : Please note: we are tracking events anonymously to gather important usage statistics like JVM version and operating system. To disable tracking, set the 'pact_do_not_track' system property or environment variable to 'true'. Error: Exception in thread "Thread-4" java.lang.NoSuchMethodError: org.apache.commons.codec.digest.DigestUtils.<init>(Ljava/security/MessageDigest;)V at au.com.dius.pact.core.support.Metrics.hostnameHash(Metrics.kt:150) at au.com.dius.pact.core.support.Metrics.access$hostnameHash(Metrics.kt:74) at au.com.dius.pact.core.support.Metrics$sendMetrics$1.run(Metrics.kt:104) at java.lang.Thread.run(Thread.java:750)```

dyptorden
2023-02-03 12:33
```Build org.apache.commons.codec.digest.DigestUtils.<init>(Ljava/security/MessageDigest;)V```

dyptorden
2023-02-03 12:34
dunno if it was a conflict with smth that we have, but the first thing to do was to remove it completely.

yousafn
2023-02-03 12:35
Was this in Pact-JVM? Would you mind raising an issue on GitHub, when you get some time (no rush). This is less than ideal, and glad you have a workaround. Ideally the metrics would work, without fail, or if they do fail, fail gracefully and allow the Pact framework to work as expected!

yousafn
2023-02-03 12:35
thanks for reporting as always @dyptorden

dyptorden
2023-02-03 12:37
strangely, it does work despite throwing this err. The build completes as green and it moves to the next stage (Can-I-Deploy)

yousafn
2023-02-03 12:41
have you got an `if: always()` or any special conditions in your workflow?

dyptorden
2023-02-03 12:47
not at all

yousafn
2023-02-03 12:53
nice resurrection :slightly_smiling_face: also stoked to see lots of UK faces - We are keen to get everyone together this year somehow on topic, I moved into a principal test engineer role around 2016, and have seen a trend away from Software engineer in test -> test engineer -> principle test engineer/architect. I quite liked the term quality coach/engineer, which is loose enough to kind of fit the ever fluid role that I think a-lot of us play, and didn't silo under the test banner


ulises.cervino
2023-02-03 14:06
I sort of take it back, this is what we have in the pact now: ``` "matchingRules": { "body": { "$.basketId": { "combine": "AND", "matchers": [ { "match": "type" } ] },``` which I'm unsure is the right thing

ulises.cervino
2023-02-03 14:06
this comes out from a lambda-dsl call like ``` body.valueFromProviderState( "basketId", "basketId", existingBasketId.toString())```

ulises.cervino
2023-02-03 14:06
(if I leave out the `toString` bit then it's `null` all the way through)

ulises.cervino
2023-02-03 14:06
back to the drawing board

eschroeder
2023-02-03 17:15
has joined #general

marunachalam1
2023-02-04 02:16
has joined #general

matt.fellows
2023-02-06 00:04
@uglyog might be able to provide some pointers on the DSL. I think it should also write to a `generators` section

uglyog
2023-02-06 00:20
If you use `pathFromProviderState` for the path, and then `valueFromProviderState` in the body, with both using the same expression, then there will be two generator entries added to the Pact file that will replace the values with the result from the provider state callback.

loc.daot
2023-02-06 07:37
has joined #general

ulises.cervino
2023-02-06 08:28
yes, that's exactly what's happening. One thing though is that if I use `${varName}` in the path, and then `varName` in the value, it doesn't do what I was expecting it to do (in my provider state I return a map containing `varName -> actualValue`). My expectation, after reading the docs for `valueFromProviderState` was that if you just specify a name like `varName` in the expression parameter, it'd use that as key, but that didn't quite work for me. Having them both use `${varName}` works just fine though, which is nice.

ulises.cervino
2023-02-06 08:29
another gotcha was that if I do `valueFromProvider('name', '$varName', uuidObject)` then the generator is of type `RAW` (which is fine in principle) however the matchers try to match with `null`, if instead I provide `uuidObject.toString()` then the generator is of type `String` (good stuff) and then the values need to match

ulises.cervino
2023-02-06 08:30
I'm probably just not reading the docs properly

ondrej.hajek
2023-02-06 09:45
has joined #general

ondrej.hajek
2023-02-06 10:53
Hello, I have a question about webhooks, hope this is the best channel. I have successfully setup https://docs.pact.io/pact_nirvana/step_6 level of Pact, but I struggle with one thing, that I don?t fully understand. I am using webhook triggered by `contract requiring verification published` which works nicely, except for one important scenario: 1. I make a pull request to my consumer, which changes the contract 2. My consumer pact tests pass and publish new pact to the broker 3. The provider verification job gets triggered, by the webhook 4. My can-i-deploy job correctly waits for the verification results and shows that I can?t deploy :no-sign: So far so good? but now I go to fix my provider according to the new contract and when I am done, the updated provider is merged, I want to go back to the PR for consumer and just restart the build and get Yes:yes-sign: from can-I-deploy. This doesn?t work though, because the webhook is not triggered again. I understand, why it?s not triggered and I think I can solve it by using the `contract published` event, but I don?t think that?s the best approach, is it? What am I missing? Thanks for any suggestions?

shravan.baira
2023-02-06 11:16
has joined #general

cameron.doyle
2023-02-06 11:17
has joined #general

ckarlborg45
2023-02-06 11:29
has joined #general

itzhak
2023-02-06 11:56
has joined #general

prashant.singh
2023-02-06 14:05
has joined #general

georgina.sallery
2023-02-06 15:18
has joined #general

prashant.singh
2023-02-06 16:03
Hi Pact Team, I want to use webhook, triggered by "Contract published with changed content or tags" and push data to *Microsoft Teams.* Do we have any documentation/example around it? Thanks in advance

guptadaksh56
2023-02-06 20:40
has joined #general

matt.fellows
2023-02-06 20:59
I don?t think we do, but if you come up with an example we?d love a PR to our docs :pray:

matt.fellows
2023-02-06 21:00
If you can?t fire a webhook directly at Teams, you might need to use as strategy like sending the message to an intermediary (e.g. AWS Lambda) and calling from there



uglyog
2023-02-06 22:12
> another gotcha was that if I do valueFromProvider('name', '$varName', uuidObject) then the generator is of type RAW (which is fine in principle) however the matchers try to match with null, if instead I provide uuidObject.toString() then the generator is of type String (good stuff) and then the values need to match That sounds like a bug, `uuidObject` some type of object?

abubics
2023-02-06 22:31
Yeah, if it's a UUID class object, it wouldn't be a JSON type (e.g. String) automatically. I don't know if the lib does coercion like that.

tjones
2023-02-06 23:02
I?ve done this before with Teams, but not for Pact. The teams documentation you?ll want to start with is here: https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook?tabs=javascript

tjones
2023-02-06 23:03
You may need an administrator to create the webhook

brendanmbliss
2023-02-06 23:14
has joined #general

helloyuanyuan
2023-02-07 02:25
has joined #general

ulises.cervino
2023-02-07 07:59
it's a `UUID` class, yes. I don't mind raw (doing `Object` sort of equals) but I do mind it being checked against `null`

ulises.cervino
2023-02-07 08:00
for now `toString` is a workaround though

geetika.joshi
2023-02-07 10:25
has joined #general

erik.haartmans
2023-02-07 10:31
has joined #general

rawisankarn
2023-02-07 12:59
has joined #general

hiep.duong
2023-02-07 13:10
has joined #general

michael.branders484
2023-02-07 14:08
has joined #general

anda.rozenfelde
2023-02-07 14:33
has joined #general

vietanhtran.dev
2023-02-08 04:44
has joined #general

geetika.joshi
2023-02-08 06:16
Hi Pact Team, i am using pact framework and facing a scenario where the response body of the api changes. How can I handle this ? I am using java

tjones
2023-02-08 06:50
Have a look at the documentation on provider states

goyal.himanshu
2023-02-08 08:23
has joined #general

geetika.joshi
2023-02-08 09:04
Thank you are you talking about this link https://docs.pact.io/?


jeroenlamain
2023-02-08 11:57
has joined #general

jeroenlamain
2023-02-08 12:02
Hi, is installing the pact broker (open source) using a prefix path supported or recommended? I have deployed the broker on aws using a name like http://blbla.aws.com/pact-broker. I can log in and do api calls. However, i have multiple problems using client libries. (1) the jvm @provider annotation does not support a path (I think) (2) using the pact-js libraries I could publish the consumer contract but could not verify as the native verifier could not download the consumer contract. Has anyone deployed the pact broker using a prefix path?

pallavi.bose
2023-02-08 13:19
has joined #general

pallavi.bose
2023-02-08 13:21
Hi Pact Team, I'm too new to pact. For my .Net application I'm trying to connect to pact broker from Provider test. I keep getting SSL error. Is there anyways I can disable SSL verification?

adi.d
2023-02-08 16:25
has joined #general

oriane.rodriguez
2023-02-08 16:59
has joined #general

wesleythomaswilliams
2023-02-08 17:01
Quality Coach has a nice ring to it. I definitely feel like we'd benefit from someone in a role like that.

matt.fellows
2023-02-08 21:20
Which version of .NET?

matt.fellows
2023-02-08 21:21
You should be able to use all the normal strategies of loading certificates into the system keyword for the latest (4.x.x), and 3.x.x you can use the standard openssl environment vars

matt.fellows
2023-02-08 21:22
I believe we don't currently support it but there is a feature request to do so


matt.fellows
2023-02-08 21:23
perhaps you could elaborate a bit more on your use case, as it is currently not clear the scenario you are trying to solve for

tdickman
2023-02-08 21:36
has joined #general

george.croucamp
2023-02-09 05:14
has joined #general

gcroucamp
2023-02-09 05:15
has joined #general

tonis.ojandu
2023-02-09 09:46
has joined #general

justyna
2023-02-09 10:03
has joined #general

jeroenlamain
2023-02-09 10:24
thanks, we'll install a pact broker without prefix

tomer.ghelber
2023-02-09 12:24
has joined #general

tommy.chen
2023-02-10 00:39
has joined #general

kerrypmckeever
2023-02-10 21:54
Hey there! Say I have the following scenario: I have a contract test between `Service A (consumer)` and `Service B (provider)`. However, in this particular test, and for the particular endpoint we're exercising, `Service B (provider)` makes an additional call to its own provider, `Service C` . My question is: Has anyone encountered this and worked out a solution where you can still run the contract test with `Service B (provider)` running in isolation, without the need for `Service C` to be running concurrently?

matt.fellows
2023-02-10 22:40
Yes this is totally normal. You should stub C in your provider B verification, and have pact tests between B and C


kerrypmckeever
2023-02-10 22:45
That was the direction we were already going, so it's awesome having validation that we're following the right path. :slightly_smiling_face: Thanks, Matt!

sayler.b
2023-02-11 03:46
has joined #general

rm.bozhko
2023-02-12 16:27
has joined #general

moid.abdul
2023-02-13 00:16
has joined #general

greg.tyler
2023-02-13 08:57
Hi folks, apologies for the #general post but I wasn?t sure which channel this best fit into. I?m trying to sort out Pact verification inside our Jenkins build. We?re using the Ruby (legacy) verifier and need to output as a JUnit file (hence legacy verifier, since the new native binary doesn?t seem to support JUnit). So I have `--format RspecJunitFormatter --out /output/junit.xml`. When I do a verification against multiple consumers, I would hope this would create a single JUnit file of the combined results, but it seems to overwrite the file for each consumer, meaning in the end I only get the last-run consumer?s results. If any other consumers fail, I lose their JUnit output and can?t tell where the failure occurred. This results in failed pipelines without knowing what the error was. Is it possible to either combine multiple consumer-runs into a single JUnit file? Or to output to a dir (`--out-dir /output`) or multiple files (`--out /outout/junit-{consumer}.xml`)?

sugi
2023-02-13 09:59
has joined #general

sgeethu21
2023-02-13 11:01
has joined #general

kp1289
2023-02-13 11:59
has joined #general

rahul.jalagadugu
2023-02-13 15:37
has joined #general

omatuzenko.hse
2023-02-13 18:14
has joined #general

tyler.fleurant
2023-02-13 21:56
has joined #general

matt.fellows
2023-02-13 23:06
Hmmm might be a @bethskurrie question gfor the Ruby one. Would you mind please creating a feature request for the latest verifier here: https://github.com/pact-foundation/pact-reference/issues

bethskurrie
2023-02-13 23:26
> it seems to overwrite the file for each consumer, meaning in the end I only get the last-run consumer?s results that?s a pain. Can you raise an issue in https://github.com/pact-foundation/pact-provider-verifier please

dyptorden
2023-02-14 08:55
good morning! can someone please confirm whether the States are case sensitive or not? My pact file contains the following pieces of info: ```"providerStates" -> "name": "My services are up" "interactions" -> "description": "Get Customer information Request",``` But in the PactBroker the following string is displayed: ```Get Customer information Request given my services are up```

dyptorden
2023-02-14 08:56
so the `interactions` respect the sensitivity but not the `states`

matt.fellows
2023-02-14 08:59
Hmm, good question. I?m pretty sure they are case sensitive.

matt.fellows
2023-02-14 08:59
@bethskurrie @uglyog?

uglyog
2023-02-14 09:07
Yes, case sensitive

geetika.joshi
2023-02-14 09:49
Hi @matt.fellows I am working on pact contract test framework ,where we are doing comparison based verification of the api response we received and what was expected. The expected/correct response body is stored in a metadata. So for all API's which we need to perform pact testing on, it is needed that we have a maintain a database, where we store api details and the response body. Now in some scenarios ,some api's response change in runtime so always it will differ from the response stored in the database, and error like : 0 - $ -> [{mismatch=Expected a Map with at least 6 elements but received 2 elements, diff={ - "children": [ - { - "code": "100", - "id": "100", - "title": "DimOneTest" - }, - { - "code": "102", - "id": "102", - "title": "Test SCD Action1" - }.............

geetika.joshi
2023-02-14 09:50
I need to know how can i handle this kind of scenarios

swilkinson
2023-02-14 09:59
has joined #general

matt.fellows
2023-02-14 10:01
It looks like you are expecting exact values, which is why your tests are failing when different data comes back. Pact has the concept of https://docs.pact.io/getting_started/matching which resolves this issue. In Java, you can see them here: https://docs.pact.io/implementation_guides/jvm/consumer I would read this section of our docs: https://docs.pact.io/consumer, specifically this section: https://docs.pact.io/consumer#choose-the-right-type-of-matching-for-the-situation

matt.fellows
2023-02-14 10:02
thx

geetika.joshi
2023-02-14 10:02
Ok Matt tysm i will try this approach

matt.fellows
2023-02-14 11:23
Worth doing the workshops too if you?re new to Pact (howtolearn)

2023-02-14 11:23
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

dyptorden
2023-02-14 11:29
@uglyog if it is case sensitive, then it means there's a bug in the UI (as the state is displayed with lower case only)?

matt.fellows
2023-02-14 11:31
I think so, because people are likely to copy/paste it

matt.fellows
2023-02-14 11:31
Mind raising a bug? Is this in Pactflow or the OSS Pact Broker?

dyptorden
2023-02-14 11:38
Pact Broker

brooks
2023-02-14 18:41
has joined #general

carlos.lopez
2023-02-14 19:20
has joined #general

sam.mirzaee
2023-02-15 02:35
has joined #general

geetika.joshi
2023-02-15 07:07
from where can i participate? is it on youtube?

tjones
2023-02-15 07:07
It?s on the link that Matt posted above

geetika.joshi
2023-02-15 07:08
ok tysm

kam.sobon
2023-02-15 11:26
has joined #general

mail391
2023-02-15 14:59
has joined #general

constantin.jaeck
2023-02-15 16:09
Hey, I was wondering if you think it's a good idea to write e2e with e.g. cucumber-js and use pact in the background to 'mock' the services I'm communicating with. So basically I have my e2e, use the `.feature` files to control the 'given' behaviour of pact with the 'given' of cucumber - and in the end I call 'writePact' to get my output The cucumber would execute selenium/puppeteer UI actions :slightly_smiling_face:

bethskurrie
2023-02-15 21:08
The pact broker un-capitalises the state so the sentence makes sense.

bethskurrie
2023-02-15 21:08
It is deliberate

jmoreno
2023-02-15 21:27
has joined #general

matt.fellows
2023-02-15 23:24
You could do it, the concern would be the granularity you are testing. Unit tests have the ability to go more granular to test all of the scenarios you need. If you?re doing this at the e2e level, you may not be able to get that level of specificity, and therefore only cover some of the cases. Or, you end up writing too many e2es

matt.fellows
2023-02-15 23:26
I guess the verification test output should have the correct case, so developers could copy correctly from there

tjones
2023-02-16 00:48
Yeah, my gut is this would be a pain to maintain. But, I?d be interested to hear how it goes if you try it

marcio.duarte
2023-02-16 03:38
has joined #general

constantin.jaeck
2023-02-16 14:19
I think due to the 'advertisement' pact is doing with 'cut e2e in smaller pieces' this would be exactly the use case, but I remember the docs also used to contain a warning exactly against hat. From a testing strategy I usually try to only do unit tests for edge-cases that are hard to test from an e2e perspective. Too many unit tests make the code rigid and therefore refactoring hard

constantin.jaeck
2023-02-16 15:02
Right now I'm only building this for an application that's in the supporting domain, which currently only covers 2 interactions with one endpoint - but depending on my learnings I'd roll it out to different parts of our product

bryen.vieira
2023-02-16 16:34
has joined #general

bryen.vieira
2023-02-16 16:54
Hey all, good evening! I was wondering what the recommended approach would be when using Pactflow between Android/iOS apps and the services they communicate with (and if this is even recommended at all, as it seems quite difficult to find articles/docs on this). Integration tests can ensure that software modules which depend on each other correctly work together, and Pact tests are not supposed to be end-to-end integration tests, sp we shouldn't be writing tests in a `given we make a request to this endpoint with these query params, we expect this EXACT response` sort of style, right? Please feel free to correct me if I'm wrong on any of these assumptions, and thanks in advance! :hugging_face:

bryen.vieira
2023-02-16 16:54
To give an example of what I mean, say we have an endpoint `/user` which takes an `email` query parameter, our Pact test should just have a regex to ensure that the email is valid (standard email regex, perhaps a check on the domain for the email, etc.) and then ensure that the response contains the fields we would expect to see for the `user` object of the response, using things like `StringMatcher`s to ensure that a `username` has no special characters in it, etc. because the Android/iOS apps won't accept that, hence breaking the contract we expect. The Pact shouldn't do things like create a hardcoded case where, for example, the `email` query parameter is `` and `willRespondWith` responds with a `user` object that has no address field in it, if I've understood correctly?

bryen.vieira
2023-02-16 16:55
TL;DR: I suppose the question here is how generic/specific should the Pacts (and the tests we write by using them) be?

kerrypmckeever
2023-02-16 21:17
Hey there! I am trying to get my team up to Diamond level, but there is something I'm unclear on. Say I have a new provider and a new consumer, and these two exist in a monorepo. If I am setting up the pipeline for both and adding the `can-i-deploy` and `record-deployment` for both, then it seems I will come to a stalemate since the pipeline changes would exist for both in the same commit, nothing is merged into the target branch, so there's nothing to verify `can-i-deploy` against. I assume I can do this across multiple PRs where I configure the `consumer test`, `provider test`, `provider verification webhook`, and `record-deployment`, let it deploy to my target branch, then configure `can-i-deploy`? Or is there a preferred method of managing this in a monorepo?

ryan319
2023-02-16 22:50
has joined #general

matt.fellows
2023-02-17 06:33
> I think due to the ?advertisement? pact is doing with ?cut e2e in smaller pieces? this would be exactly the use case, but I remember the docs also used to contain a warning exactly against hat. the main way we do that is to improve the ?base? of the pyramid - more tests, reliability etc. lower down gives you more specificity, speed etc. Most orgs have unwieldy e2e tests, because they try to do too much with them. By adding contract testing at the base, you can usually reduce your e2e at the top. Often to the point you don?t need them at all

matt.fellows
2023-02-17 06:34
This YT video is a good way of describing our objective: https://www.youtube.com/watch?v=QFCHSEHgqFE

zhig.ivan
2023-02-17 08:56
has joined #general

yerken.tussupbekov
2023-02-17 11:40
has joined #general

iamchughmayank
2023-02-17 18:30
has joined #general

matt.fellows
2023-02-18 03:22
The reason there isn't much content is that there is nothing unique to the mobile use case.

matt.fellows
2023-02-18 03:22
I believe there was an article that was recently released on mobile tho, let me find it

matt.fellows
2023-02-18 03:23
I'd start here tho: https://docs.pact.io/consumer I think that should answer your base questions


jake.kline
2023-02-18 04:11
has joined #general

culudamar
2023-02-20 08:12
has joined #general

gawaine.ogilvie
2023-02-20 17:01
has joined #general

yousafn
2023-02-20 22:12
It?s Pact's 10th birthday today We are proud to be the most loved and adopted multi-protocol and language contract testing tool. it?s made possible by all of our open source contributors and users! Thank you. We look forward to celebrating with you this year, both in person and as part of virtual events. For now, please take a step back in time with this interactive history of Pact, from your very own Developer Advocate and Community Shepherd! https://docs.pact.io/blog/2022/11/17/pact-facts-a-history-lesson

greg.tyler
2023-02-21 10:18
Sorry this has taken me so long, I ended up moving into something else entirely. Bugs now created :slightly_smiling_face: ? https://github.com/pact-foundation/pact-reference/issues/257 ? https://github.com/pact-foundation/pact-provider-verifier/issues/94

matt.fellows
2023-02-21 11:04
No worries - thanks for that!

tjones
2023-02-21 14:36
You might also be interested in https://stackoverflow.com/a/48000704/790070 I wrote a while back that talks about end-to-end tests and pact

james414
2023-02-22 10:00
has joined #general

nbolam
2023-02-22 20:26
has joined #general

lambent21
2023-02-23 13:35
has joined #general

pach
2023-02-23 17:34
has joined #general

richard.ruiter
2023-02-24 06:43
has joined #general

geetika.joshi
2023-02-24 07:19
Hi Pact Team, i need to use matchers for contract verification. so do i need to include matchers in json file? i am unable to understand where to place the matcher statements like some regular expression etc. i am using java.

matt.fellows
2023-02-24 09:28
What have you tried so far?

matt.fellows
2023-02-24 09:29
I?d start by searching ?matchers? in the docs: http://docs.pact.io We also have numerous examples, tutorials and workshops. (howtolearn)

2023-02-24 09:29
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

geetika.joshi
2023-02-24 09:35
where do we have to write the regular expressions for matchers?

matt.fellows
2023-02-24 09:56
In your test

spalle
2023-02-24 10:54
has joined #general

alex637
2023-02-24 14:32
has joined #general

egrep
2023-02-25 17:32
has joined #general

ykamali
2023-02-26 05:10
has joined #general

kripa.kurian
2023-02-27 04:35
has joined #general

jordan.brooks
2023-02-27 09:46
has joined #general

courtel.yann
2023-02-27 10:47
has joined #general

nathan.hickson
2023-02-27 13:07
has joined #general

mark.simpson
2023-02-27 13:08
has joined #general

nathan.deamer
2023-02-27 14:35
Hi Matt, Just popping on to say this is great. Bryen works with Barry (who wrote that article) and me at Go City :slightly_smiling_face:

masykur.sn
2023-02-27 15:21
has joined #general

makifkus
2023-02-28 03:51
has joined #general

jacob.waller
2023-02-28 21:08
has joined #general

dipak8959
2023-02-28 21:18
has joined #general

sanketh.shanbhag
2023-03-01 03:57
has joined #general

adam.cox
2023-03-01 12:34
has joined #general

adam.cox
2023-03-01 12:37
Hi Pact Team, We are just starting a project using the pact-cplusplus consumer library. I was looking at the async contract testing but I can?t seem to see the methods in the library. Has this been implemented? Thanks

dyptorden
2023-03-01 14:03
Hi everyone - just wondering if anyone used Pact for SIP protocol testing.

steve.short
2023-03-01 15:14
has joined #general

yousafn
2023-03-01 16:49
hiya, doesn't look like it but the implementation calls the ffi methods exposed by pact reference so following the framework of other languages it could be added in. We would happily accept PR's or be able to advise on how you could bring across the relevant FFI methods to support messaging

yousafn
2023-03-01 16:49
Hey dude, what is SIP protocol testing, for the uneducated (like me)

kgrady
2023-03-01 18:58
has joined #general

dyptorden
2023-03-01 20:13
SIP is a protocol used in the telecom industry. It allows pairing the caller and the callee after a series of handshakes between intermediary proxies. Quite similar to HTTP in terms of concepts... it has a header...status codes etc.

matt.fellows
2023-03-01 23:47
I think the answer here is no, as we only support HTTP as a protocol, or are protocol agnostic (sync/async messaging). I think this would need to be implemented as a plugin, if I understand correctly


tjones
2023-03-02 03:13
Contract testing is a really good fit for SIP, although as Matt says, Pact doesn?t directly support it

dyptorden
2023-03-02 07:50
@tjones thanks! Do you also refer to the use of the Plugins or another way? And did you try it?

adam.cox
2023-03-02 09:20
Excellent, thanks for clarifying. I?ll discuss with the team about getting some PRs in place

pratima.patil
2023-03-02 11:13
has joined #general

matt.fellows
2023-03-02 12:17
I think he?s just saying that contract testing (concept) is a valid strategy for SIP, without regard to specific implementation

matt.fellows
2023-03-02 12:17
If you want to do it with Pact, you would need to write a plugin that knew how to communicate the SIP protocol

shilpa199350
2023-03-02 12:40
has joined #general

syamphaneendrak
2023-03-02 16:21
has joined #general

neeraj.sharma
2023-03-02 16:33
has joined #general

dominik.chmielarz
2023-03-02 16:55
has joined #general

xchen
2023-03-02 18:59
has joined #general

fdawson
2023-03-03 08:15
has joined #general

cyrus.devnomad
2023-03-03 11:20
Hi I have a pact consumer unit test that very often and somewhat randomly thows the error "Unable to start mock server". The corresponding error trace would look like this: ```Error Message: System.InvalidOperationException : Unable to start mock server Stack Trace: at PactNet.Drivers.HttpPactDriver.CreateMockServer(String host, Nullable`1 port, Boolean tls) at PactNet.PactBuilder.StartMockServer() at PactNet.PactBuilder.VerifyAsync(Func`2 interact) at MyConsumer.PactConsumer.MyConsumerPactTest.GetUsersByValidParam() in /pact/MyConsumer.PactConsumer/MyConsumerPactTest.cs:line 93 at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)``` I'm not sure whether the source of this error is in http://Pact.NET library or in deeper non .NET pact libraries involved. I have asked this question also in http://Pact.NET forum with a test project to reproduce the problem: https://pact-foundation.slack.com/archives/C9UTHV2AD/p1676368784117769

yousafn
2023-03-03 11:37
Happy Friday everyone! :ralph-wave: Hear from @matt.fellows as to how Pact is evolving alongside the ever shifting world of API development, empowering our users to contract test existing and emergent protocols and transports. Essential to those operating in multi-protocol landscapes. https://nordicapis.com/plugging-into-the-future-of-api-contract-testing-with-pact/

tom.meldrum
2023-03-03 13:02
has joined #general

adam.cox
2023-03-03 15:05
Hello again, Please could someone confirm the following for me? 1. Synchronous message testing is only present in the Pact v4 spec? 2. Pact verifier does not support websockets as a transport by default? We would need to create a plugin for this? Thanks in advance

dawoud.sheraz
2023-03-03 15:59
Hello. Not sure if this sharing is allowed, let me know if not. I will be speaking at Python Web Conf 2023 (March 13- 17), talk titled ?Why you should contract test your Microservices?. This talk will cover the need for contract testing and how pact can help in that (https://2023.pythonwebconf.com/presentations/why-you-should-contract-test-your-microservices). Even though it has been a while since I worked with Pact and Contract testing, my exposure to Pact and the wonders it can bring in integration testing has greatly expanded my technical expertise. I have given a few trainings and provided mentoring to folks within my organization on contract testing already. Really excited for this. https://www.linkedin.com/posts/syed-muhammad-dawoud-sheraz-ali_python-web-conference-2023-activity-7030572405756469248-NkAQ?utm_source=share&utm_medium=member_desktop

dragos.neagu
2023-03-03 16:44
has joined #general

tjones
2023-03-04 02:02
> Not sure if this sharing is allowed, Absolutely! This is exactly the right place. All the best for the talk!

yousafn
2023-03-04 12:40
:wave: hey @dawoud.sheraz ! this sounds awesome! thanks for sharing, we always seen loads going on in the community but normally after the fact so if we can help amplify your content we are all for it, as it?s mutually beneficial for us and our users :yellow_heart: we have pages for upcoming events, talks etc so you can list it there if you wish to make a pr say listed under upcoming community events? https://docs.pact.io/events we are also after increasing our Python maintainer base and contributors with moving to the rust core as one of this years goals. we would super appreciate a call out for extra hands from Pythonistas whilst your there ( if it?s not too much of an ask! )

dawoud.sheraz
2023-03-04 16:26
I would love to both add this under upcoming event and also add a call out for Pact & Pact-python support during the talk.

facundo.g
2023-03-06 12:13
has joined #general

yousafn
2023-03-06 14:30
We've added it now as an upcoming event https://docs.pact.io/events#upcoming-community-events Best of luck with the talk Syed!

michael.bryson
2023-03-06 14:59
has joined #general

dawoud.sheraz
2023-03-06 15:26
Thank you.

kingsley
2023-03-06 22:47
has joined #general

jacob.waller
2023-03-07 03:16
Seems like a hilariously catchable bug with a tool like pact:

tjones
2023-03-07 03:27
Yep. So many outages are avoidable this way

tjones
2023-03-07 03:28
?oh, we don?t need contract tests, because all our clients are built from the schema? ?so you?ve never had an outage after a deployment because of API incompatibility?? ????

matt.fellows
2023-03-07 03:44
:eyes:


matt.fellows
2023-03-07 03:52
Awesome news Syed and thanks for doing this! As others have stated, this is definitely the right place. Let us know if we can support you (over and above what Yousaf has done above :point_up: )

marckpuiu
2023-03-07 15:58
has joined #general

yousafn
2023-03-08 12:33
It's those type of outages that make Pact a far easier sell in your organisation, it is quite difficult to sell the benefits to a business who's bottom line hasn't been affected by an integration outage making it to prod.

tjones
2023-03-08 12:36
Did someone reply to him recommending Pact / Pactflow?

tjones
2023-03-08 12:36
Because someone should

yousafn
2023-03-08 12:36
It was hard to resist

yousafn
2023-03-08 12:38
Hey all, The PactFlow team is conducting research on contract testing within an event-driven architecture context. We'd love to hear from you about your event driven architecture testing strategy in your workplace and how contract testing fits in your event driven projects. More specifically, we are looking at integrating tightly with AsyncAPI, to bring you all the great benefits of Pact alongside the benefits that specification-driven workflows can provide. By getting involved, you can help be in the driving seat and shape the future of contract testing We?ve got multiple ways you can get involved, - An easy to fill https://forms.office.com/r/51FGni44fn (open until 27th March) - Schedule a https://calendly.com/shuying-lin/event-driven-architecture-pactflow?month=2023-03with PactFlow team - Join our https://github.com/pactflow/roadmap#developer-preview-programs - Vote or comment on our Public Roadmap https://github.com/pactflow/roadmap/issues/57 We appreciate your time and input! - Shuying & Yousaf from the PactFlow team!

tjones
2023-03-08 12:40
So um?. what is AsyncApi?

tjones
2023-03-08 12:40
I mean, I?m googling it right now. But this is the first time I?m hearing of it

yousafn
2023-03-08 12:41
Herro dude! It's a specification format for documenting message based services, similar to OpenAPI for REST

tjones
2023-03-08 12:41
> All powered by the AsyncAPI specification, the *industry standard* for defining asynchronous APIs. Emphasis theirs. Colour me suspicious.

yousafn
2023-03-08 12:45
I haven't dug too far into their raison d'etre, but seems similar to the Swagger/OpenAPI. Machine readable specs, which can be leveraged by multiple tools, for multiple purposes We utilised it as a previous organisation in order to help document both their existing RESTful services with OpenAPI and the emergent event-based services that had been built, with AsyncAPI (which people felt familiar with due to exposure to Swagger/OpenAPI). We then built a centralised store where we could search across them, as the real business value spanned multiple services and it was hard to get a decent view across it

tjones
2023-03-08 12:47
Yeah. Looking at the docs it seems a bit sparse, but clearly a good fit for people who like OpenAPI - you don?t have to learn much more, and your existing pipelines / generators etc wouldn?t have to change much

tjones
2023-03-08 12:47
like you could keep going using the same process

tjones
2023-03-08 12:47
even if the tools change

yousafn
2023-03-08 12:48
For those also not sure on what AsyncAPI is, you can check out their link here. https://www.asyncapi.com/ It's part of the Linux Foundation, as is the OpenAPI spec, so it is in decent hands. Industry standard (marketing speak) - it's definitely got a foodhold in the spec market but I don't think enough people are using it. (It's also free and open-source which is why I quite like it) - especially when thinking about building out demos showcasing hexagonal arch where you can show the business logic unaffected by using different transport mechanisms

yousafn
2023-03-08 12:48
They get FREE pro slack too :cry: ! which I am bare jelly about

tjones
2023-03-08 12:48
> Message validation in runtime I reckon pact could do this. It would be excellent to have a drop in gateway / shadow proxy that would detect request / response pairs that aren?t covered by the pact

yousafn
2023-03-08 12:49
I really like the way msw does that, and totally agree

yousafn
2023-03-08 12:50
proxys all reqs and tells you if calls were made without a mock handler

yousafn
2023-03-08 12:51
this caught my eye in the past too https://github.com/bochaco/pact-mock-reactive it gave me many grand ideas

tjones
2023-03-08 12:54
Ah yeah! I thought about building that for Case - it?s something that a lot of mobile developers would like

jacob.waller
2023-03-08 14:34
I'm using a screenshot of that tweet in a company presentation to recommend pact

duncan3142
2023-03-08 19:42
has joined #general

william.stewart
2023-03-08 20:25
has joined #general

matt.fellows
2023-03-09 01:26
> Colour me suspicious. (edited) It?s definitely good marketing on their part, but given a bunch of industry titans have backed it it?s all but going to be. I think https://cloudevents.io/ is probably one competing version, but not really. If you can remember back to the early days of REST, there was WADL, RAML, blueprint and Swagger. Swagger one out for various reasons, and then was donated to the linux foundation. The fact AsyncAPI has been backed by pretty much all the likely suspects means there is unlikely to be a _viable_ alternative. The real question is - will it get _used_? According to public data sources (notably SmartBear and Postman?s annual API surveys), the number of respondents who use it is 12-13%. I think there are reasons to be very skeptical of that number. For example, the actual usage of AsyncAPI in SwaggerHub is much smaller than that. Postman doesn?t yet support it in their IDE yet as far as I can see, but others like Stoplight do. That will no doubt drive some level of adoption. I?m (and the team) are mostly interested in that last question, how message pact provides value to teams today and what we could do to improve that

trc229
2023-03-09 01:34
has joined #general

zaira.zafar
2023-03-09 10:41
has joined #general

dominik.goltermann
2023-03-09 15:31
has joined #general

sharathkonda
2023-03-09 15:37
has joined #general

allen.ayala
2023-03-09 16:33
has joined #general

slawomir.pawluk
2023-03-09 18:22
has joined #general

casavelha
2023-03-09 19:49
has joined #general

nikita.gupta
2023-03-09 22:21
has joined #general

pjayakumar
2023-03-10 02:21
has joined #general

josh.marlow
2023-03-10 15:10
has joined #general

patilb
2023-03-11 17:02
has joined #general

renan.santos
2023-03-11 18:46
has joined #general

keren.eckshtein
2023-03-12 08:57
has joined #general

sr
2023-03-12 11:58
has joined #general

gokuldot
2023-03-12 17:30
has joined #general

ldgaribello
2023-03-13 06:23
has joined #general

lidan.liu
2023-03-13 10:45
has joined #general

vipin.kumar
2023-03-13 12:29
has joined #general

vipin.kumar
2023-03-13 12:40
Hello Pact Team, How can I test My graphql queries with latest pact library for node? I browse through the documentation and I found that for graphql ecamples are either outdated or not documented well. Can someone please point me to a latest example ?

bknapik
2023-03-13 17:13
has joined #general

bknapik
2023-03-13 17:34
Hello Pact Team, I was wondering if there is any guidance on how to measure contract test coverage? I have stakeholder buy-in on contract testing, however we need a way to measure that contracts are covered and what are not. Our concern comes from the fact the can-i-deploy tool is only as good as the data we give to the pact broker. if we are missing contracts, can-i-deploy will misrepesent that the safety of the deployment. Long term we would like to block PRs if they are missing pacts for new endpoints/consumers. (I apologize if this is the wrong channel for this question, please direct me to the correct one if needed.)

ravi0894
2023-03-13 17:38
has joined #general

anji.boddupally
2023-03-13 20:37
has joined #general

tjones
2023-03-13 22:39
I?m not sure what you?re asking for exactly- this post seems to imply a few different meanings of ?contracts?. But, one of the advantages of contract testing is that it _only_ covers what you?re using. So, if you have an endpoint that isn?t used, it?s not covered by the tests (because you could make arbitrary changes to it without consequences)

tjones
2023-03-13 22:40
On the client side, you can get some of the same advantage by tying the test fixtures that you use for your Pact tests to your other tests - so that your contract must be covering exactly what your functional tests cover

bknapik
2023-03-13 22:49
Sorry for the confusion. We know that these endpoints are being used however, they do not have existing pact tests. We have 2 scenarios we are looking to address: 1.) we are rolling out contract testing using Pact. How can we measure what endpoints/producers/consumers are missing tests with Pact. We have 60+ microservices, so onboarding pact is quite an effort. 2.) A developer added a new endpoint/producer/consumer and they forgot to add a pact test for it. Is there any approach/tooling to help us with these scenarios?

tjones
2023-03-13 22:52
I?m not aware of any tooling, although it would be possible to build something that looked at schemas and gave an answer. I think the reason that general purpose tooling doesn?t exist is because Pact isn?t supposed to cover the whole API surface, it?s supposed to cover the parts that your consumer actually needs. Removing a field from a response isn?t a breaking change if your consumer isn?t expecting that field.

tjones
2023-03-13 22:52
> 2.) A developer added a new endpoint/producer/consumer and they forgot to add a pact test for it. How would you solve this for other test types like e2e or unit tests? This doesn?t feel like a problem that should be solved with tooling

tjones
2023-03-13 22:54
> 1.) we are rolling out contract testing using Pact. How can we measure what endpoints/producers/consumers are missing tests with Pact. We have 60+ microservices, so onboarding pact is quite an effort. I think this is a _great_ question

tjones
2023-03-13 22:55
The answer probably depends a lot on what your existing ecosystem is. Do you have schemas for those APIs?

tjones
2023-03-13 22:59
btw - for forgetting to add a test, I think consistency of patterns is important. If your test fixtures are tied to the Pact tests, then people will see the pact stuff when they try to mock the API for the unit tests.

tjones
2023-03-13 23:00
Also, I would expect unit test coverage tools to have full coverage of some parts of the client code. For example, this code should have full coverage during a pact test: ```const api = (baseurl: string): Api => { const server = makeAxiosConnector(baseurl); return { getAllProducts: () => server.authedGet<string[]>('/products'), getProduct: (id) => server.authedGet(`/products/${id}`), getUser: (id: string) => server.authedGet<User>(`/users/${id}`).catch((e) => { if (e.code === API_NOT_FOUND) { throw new UserNotFoundConsumerError(`Unable to find user '${id}'`); } throw e; }), .... }; };```

tjones
2023-03-13 23:01
It?s tricky though, because not all API client code will be 100% covered during a pact test. For example, your API client might handle unexpected error scenarios that the server never produces

tjones
2023-03-13 23:02
(eg, if the client has code for ?what do I do if the sever doesn?t conform to the contract? it?s hard to put that in the contract)

voon.wong
2023-03-14 01:34
has joined #general

matt.fellows
2023-03-14 05:29
Thanks Tim. Yes, the answer to that question is hard. The usual API coverage tools are the best starting point. I would recommend you run pact tests separate from the rest of your tests - you can then at least scope the coverage to your API client packages and know what was covered was from the pact tests and not your other testing types, and assess from there (automated-ly or otherwise)

gigamac
2023-03-14 08:09
has joined #general

ivstam
2023-03-14 08:43
has joined #general

tomknee1
2023-03-14 12:34
Hello, I have a token eg ```"eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJhZy1zdGFnaW5nLW1vYmlsZUBhcHBzcG90LmdzZXJ2aWNlYWNjb3VudC5jb20iLCJhdWQiOiJodHRwczov" + "L2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImV4cCI6MTY0NjMxNjU5NywiaWF0Ij" + "oxNjQ2MzEyOTk2LCJzdWIiOiJhZy1zdGFnaW5nLW1vYmlsZUBhcHBzcG90LmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ1aWQiOiI0MTEwMDAzNyJ9.MLpkCQI5bOSmdJuneQdwChEYvXhkaig" + "d4ouPOn5f2Rw"``` that needs to match my jwt regex of `private val jwtRegex = "^[A-Za-z0-9-_=]+\\.[A-Za-z0-9-_=]+\\.?[A-Za-z0-9-_.+/=]*\$"` most of the time in CI this is fine during pactPublish, but occasionally I get this annoying json parser error like below... ```/usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImV4cCI6MTY0NjMxNjU5NywiaWF0IjoxNjQ2MzEyOTk2LCJzdWIiOiJhZy1zdGFnaW5nLW1vYmlsZUBhcHBzcG90LmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ1aWQiOiI0MTEwMDAzNyJ9.MLpkCQI5bOSmdJuneQdwChEYvXhkaigd4ouPOn5f2Rw" (JSON::ParserError) }, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "matchingRules": { "$.body.token": { "match": "regex", "regex": "^[A-Za-z0-9-_=]+\\\\.[A-Za-z0-9-_=]+\\\\.?[A-Za-z0-9-_.+/=]*$" } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.5" }, "pactSpecification": { "version": "2.0.0" } }, "provider": { "name": "OtacProviderService" } } '``` it doesn't happen 100% and I've tried countless things to fix it with my variable and my regex etc but it still pops up every so often, can anyone please give some guidance here :pray: ? im using kotlin so pact-jvm, apologies if wrong channel and then pact cli docker image

tomknee1
2023-03-14 12:36
It seems similar to another similar issue I had a while back around the escaped slash ending up being `\\\\` every so often when parsed :confused:

bknapik
2023-03-14 13:06
Thanks for your replies; they are appreciated. In our case we use SonarCloud quality gates to require 80%+ unit test coverage. If the developer does not meet that standard their PR is blocked from being checked in using Azure DevOps quality gates. It is how we control our unit testing standards. For E2E tracking, we use Zephyr Squad with Jira where each ticket would have their E2E tests tracked. I do agree on running pact tests seperately.

melikesezin
2023-03-14 14:17
has joined #general

adam.cox
2023-03-14 14:51
Hi Pact, We are trying to develop a plugin in rust that enables support WebSockets. Unfortunately it doesn?t look like the example plugins start up a new server so I am struggling a bit. The `start_mock_server` function on the Plugin trait does not have a mutable reference to the Plugin struct and so I can?t store a reference to the server. Is there some guidance I can get on how to implement this properly?

adam.cox
2023-03-14 14:52
Or are we expected to run the Mock Server as a separate process entirely?

tomknee1
2023-03-14 16:12
For now I will try using a raw string literal instead for the regex but possibly an issue on the pact cli side?

gopishankar.haridas
2023-03-14 16:42
has joined #general

rajasekaran.parthiban
2023-03-14 20:13
has joined #general

matt.fellows
2023-03-14 20:36
Is the issue on publish or something else?

matt.fellows
2023-03-14 20:36
Are you using PactFlow or a self-hosted broker? (I ask, because it might be tripping a WAF rule or something)

uglyog
2023-03-14 22:19
Hi Adam, you can have a look at the gRPC plugin, it provides a gRPC mock server. See https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/server.rs#L568

uglyog
2023-03-14 22:21
It stores the data for the running mock server in a global variable using the lazy_static crate. See https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/mock_server.rs#L49

sbanerjee
2023-03-15 02:46
has joined #general

tomknee1
2023-03-15 08:58
this is on pact publish specifically

tomknee1
2023-03-15 08:58
We are using self hosted pact broker in GKE using GCP Managed Cert and Ingress etc

tomknee1
2023-03-15 09:00
```+ docker run -v /bitrise/src/pacts:/pacts pactfoundation/pact-cli:0.51.0.0 pact-broker publish /pacts --consumer-app-version 6d3721fa3c71f3e431d1af8265b6bff368b5ac2a --branch task/VIS-3411-instrumented-tests-announce-tx-journey-update --broker-base-url https://pact-broker.tools.ld.payments.dojo.dev --broker-username [REDACTED] --broker-[REDACTED] '[REDACTED]' Unable to find image 'pactfoundation/pact-cli:0.51.0.0' locally 0.51.0.0: Pulling from pactfoundation/pact-cli 9621f1afde84: Pulling fs layer 8302e5003f61: Pulling fs layer 9bd515237796: Pulling fs layer a9c2f95dc8b8: Pulling fs layer d659e923d195: Pulling fs layer 0496e58000ed: Pulling fs layer 3ae718baa03f: Pulling fs layer 8a6f32654e19: Pulling fs layer 1e4a0858513a: Pulling fs layer bbf55dfda7e7: Pulling fs layer d31bd4799644: Pulling fs layer 75e247ce101c: Pulling fs layer f73e386bc3e7: Pulling fs layer d659e923d195: Waiting 6ae2a9f86af1: Pulling fs layer 1e4a0858513a: Waiting 0496e58000ed: Waiting 3ae718baa03f: Waiting bbf55dfda7e7: Waiting d31bd4799644: Waiting 8a6f32654e19: Waiting 6ae2a9f86af1: Waiting a9c2f95dc8b8: Waiting f73e386bc3e7: Waiting 8302e5003f61: Verifying Checksum 8302e5003f61: Download complete 9bd515237796: Verifying Checksum 9bd515237796: Download complete 9621f1afde84: Download complete d659e923d195: Verifying Checksum d659e923d195: Download complete 0496e58000ed: Verifying Checksum 0496e58000ed: Download complete 3ae718baa03f: Verifying Checksum 3ae718baa03f: Download complete 8a6f32654e19: Verifying Checksum 8a6f32654e19: Download complete 9621f1afde84: Pull complete 1e4a0858513a: Verifying Checksum 1e4a0858513a: Download complete a9c2f95dc8b8: Verifying Checksum a9c2f95dc8b8: Download complete 8302e5003f61: Pull complete d31bd4799644: Verifying Checksum d31bd4799644: Download complete 75e247ce101c: Verifying Checksum 75e247ce101c: Download complete 6ae2a9f86af1: Verifying Checksum 6ae2a9f86af1: Download complete 9bd515237796: Pull complete bbf55dfda7e7: Verifying Checksum bbf55dfda7e7: Download complete f73e386bc3e7: Verifying Checksum f73e386bc3e7: Download complete a9c2f95dc8b8: Pull complete d659e923d195: Pull complete 0496e58000ed: Pull complete 3ae718baa03f: Pull complete 8a6f32654e19: Pull complete 1e4a0858513a: Pull complete bbf55dfda7e7: Pull complete d31bd4799644: Pull complete 75e247ce101c: Pull complete f73e386bc3e7: Pull complete 6ae2a9f86af1: Pull complete Digest: sha256:b7d9facf2566cbe23c404fa2baaf3b7bb7c417788ad9f83d765fa72cea1a9754 Status: Downloaded newer image for pactfoundation/pact-cli:0.51.0.0 /usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse': 859: unexpected token at 'nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsImV4cCI6MTY0NjMxNjU5NywiaWF0IjoxNjQ2MzEyOTk2LCJzdWIiOiJhZy1zdGFnaW5nLW1vYmlsZUBhcHBzcG90LmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ1aWQiOiI0MTEwMDAzNyJ9.MLpkCQI5bOSmdJuneQdwChEYvXhkaigd4ouPOn5f2Rw" (JSON::ParserError) }, "headers": { "Content-Type": "application/json; charset=UTF-8" }, "matchingRules": { "$.body.token": { "match": "regex", "regex": "^[A-Za-z0-9-_=]+\\\\.[A-Za-z0-9-_=]+\\\\.?[A-Za-z0-9-_.+/=]*$" } }, "status": 200 } } ], "metadata": { "pact-jvm": { "version": "4.3.5" }, "pactSpecification": { "version": "2.0.0" } }, "provider": { "name": "OtacProviderService" } } ' from /usr/lib/ruby/gems/3.0.0/gems/json-2.6.2/lib/json/common.rb:216:in `parse' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/pact_file.rb:28:in `pact_hash' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/pact_file.rb:20:in `consumer_name' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/rake-13.0.6/lib/rake/file_list.rb:70:in `collect' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:145:in `consumer_names' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:60:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:33:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/publish_pacts.rb:15:in `call' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:66:in `publish_pacts' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/pact_commands.rb:29:in `publish' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch' from /usr/lib/ruby/gems/3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/lib/pact_broker/client/cli/custom_thor.rb:23:in `start' from /usr/lib/ruby/gems/3.0.0/gems/pact_broker-client-1.66.0/bin/pact-broker:10:in `<top (required)>' from /usr/bin/pact-broker:25:in `load' from /usr/bin/pact-broker:25:in `<main>'```

tomknee1
2023-03-15 09:06
```apiVersion: http://networking.k8s.io/v1 kind: Ingress metadata: name: {{ include "pactbroker.fullname" . }} namespace: {{ .Values.namespace }} annotations: http://external-dns.alpha.kubernetes.io/hostname: {{ .Values.cloudEndpoints.hostName | quote }} http://kubernetes.io/ingress.allow-http: "true" # allow-http and use frontendConfig to redirect to https http://kubernetes.io/ingress.class: "gce" http://networking.gke.io/managed-certificates: {{ include "pactbroker.fullname" . }} http://networking.gke.io/v1beta1.FrontendConfig: "frontendconfig-ssl-modern-tls12" spec: rules: - host: {{ .Values.cloudEndpoints.hostName | quote }} http: paths: - path: /* pathType: ImplementationSpecific backend: service: name: pact-broker-service port: number: 80 --- apiVersion: http://networking.gke.io/v1beta1 kind: FrontendConfig metadata: name: frontend-config-redirect-to-https spec: redirectToHttps: enabled: true responseCodeName: "MOVED_PERMANENTLY_DEFAULT" --- apiVersion: http://networking.gke.io/v1beta1 kind: FrontendConfig metadata: name: frontendconfig-ssl-modern-tls12 spec: sslPolicy: ssl-policy-modern-tls12 redirectToHttps: enabled: true responseCodeName: "MOVED_PERMANENTLY_DEFAULT"```

adam.cox
2023-03-15 10:00
Thank you! I have been looking at the protobuf plugin in pact-plugins/plugins but it is in Kotlin and I was having a hard time reading it and working our how it could apply to our rust version. This is excellent. Much appreciated. I?ll take a look and see how I can apply this to our own code

matt.fellows
2023-03-15 10:16
Thanks! Have you been able to confirm if the file is indeed invalid JSON? That would help us get to the bottom of it - sounds like perhaps an invalid JSON document is being serialised by your consumer client library (as I think you hinted at)

tomknee1
2023-03-15 10:17
I mean it passes 90% of the time in CI and this issue pops up occasionally, the contracts haven't changed between them

tomknee1
2023-03-15 10:17
and when it works I correctly see the output that it was preverified etc

matt.fellows
2023-03-15 10:46
:thinking_face: so strange!

tomknee1
2023-03-15 11:22
I recently merged a potential fix by using raw string literals in kotlin instead of relying on `\\` for escaped slashes, so will monitor CI over the next week or so and see if the issue still happens or not

kurt_schriefer
2023-03-15 13:21
has joined #general

andreas530
2023-03-15 22:32
has joined #general

santiago.rendong
2023-03-15 23:21
has joined #general

christine.awofeso
2023-03-16 09:58
has joined #general

konstantin.manna
2023-03-16 15:04
has joined #general

emgarcia
2023-03-16 15:44
has joined #general

john.goodwin
2023-03-16 15:51
has joined #general

tomasz.kowalczyk
2023-03-16 15:51
has joined #general

samir.ferreira
2023-03-16 16:27
has joined #general

raess.simon
2023-03-16 23:02
has joined #general

anshu.ranjan1002
2023-03-17 21:59
has joined #general

mptinternational
2023-03-18 18:12
has joined #general

16728365
2023-03-19 14:30
has joined #general

brick777
2023-03-19 21:47
has joined #general

siddharth.gupta
2023-03-20 08:19
Hi Matt , Is there any certification or course after completing which i can become a certified Pact trainer. I am looking to step up my Pact learning further and become a professional trainer.

mark.ingram
2023-03-20 11:31
has joined #general

jo.laing
2023-03-20 17:06
has joined #general

erich.buri
2023-03-20 22:07
has joined #general

matt.fellows
2023-03-20 22:24
Hi! We don?t currently have any certification program, for either users or trainers. We have previously worked with our PactFlow global partners to train and endorse them, but there is nothing official with regards to a certified ?professional trainer?

matt.fellows
2023-03-20 22:25
I?d be interested to know if others think this is a worthwhile initiative cc: @lewis.prescott @yousafn

matt.fellows
2023-03-20 22:27
Awesome stuff Adam! Do join the #pact-plugins channel if you haven?t already, and if the time is right we can create a #websockets channel for this.

matt.fellows
2023-03-20 22:27
Let us know how we can best support you :fist:

kgrady
2023-03-20 23:22
Hi Pact, I?m in the process of upgrading an angular app from spec version 2 to version 3 using the migration https://github.com/pact-foundation/pact-js/blob/master/docs/migrations/9-10.md. Now that mockProvider (PactV3) no longer has access to mockService, where can I access the baseUrl? The migration docs claim: ```the mockService property on the Pact class is no longer an actual MockService, but supports the baseUrl property for compatibility.``` But I am seeing an error that mockService is not a known property of PactV3. What are my options here?

abubics
2023-03-21 03:23
my 2c ? People working with Pact typically need to be embedded in dev teams, doing dev work. Getting a range of experiences across different architectures is a big part of the foundational value you want to end up with. ? The software industry has a history of dubious certification (especially around agile, but also tech), with several pitfalls (payment vs knowledge, faction politicking, secondary economy, transparency, expectation management, etc). ? It's not an inherently bad idea, but it would need a lot of care to make sure it starts & stays valuable & relevant.

siddharth.gupta
2023-03-21 03:30
I get many queries from a lot of companies for training on Pact . Which means many companies want to adapt to Pact but they are lacking skills and want to get trained . From a trainer perspective I would want to ensure that I have to deliver a comprehensive coverage of pact features and best practices . A well structured certification course will allow us not only to confidently impart proper training but it will also act as boon for marketing of the product

abubics
2023-03-21 03:34
I don't disagree with any of that :+1: it's just not simple/obvious how to approach it :sweat_smile:

abubics
2023-03-21 03:35
Anyway, it won't be up to me, just highlighting some pitfalls :innocent:

xiaorong.ruby
2023-03-21 09:34
has joined #general

markcox20
2023-03-21 10:08
has joined #general

adam.cox
2023-03-21 13:26
Hi @matt.fellows - I have just posted our next hurdle over in the #pact-plugins channel. Something is not quite working but we are struggling to work out whats going on

oloruntobi.ayilara
2023-03-21 14:01
has joined #general

pankaj_kumar39
2023-03-21 14:18
has joined #general

ravi_shankar_lakkims
2023-03-21 14:18
has joined #general

sathish.nilla
2023-03-21 14:19
has joined #general

sikandar_kumar.singh
2023-03-21 14:19
has joined #general

yousafn
2023-03-21 17:34
It's available within the `executeTest` scope as shown in the linked docs so this ``` const api = new API(provider.mockService.baseUrl); // make request to Pact mock server const product = await api.getAllProducts(); expect(product).toStrictEqual([ {"id": "09", "name": "Gem Visa", "type": "CREDIT_CARD"} ]);``` would become this ``` await provider.executeTest(async (mockService) => { const api = new API(mockService.url); // make request to Pact mock server const product = await api.getAllProducts(); expect(product).toStrictEqual([ {"id": "09", "name": "Gem Visa", "type": "CREDIT_CARD"} ]); })```

benjamin.earle
2023-03-21 19:23
has joined #general

benjamin.earle
2023-03-21 19:41
Hi everyone! I'm not sure if this is the channel to ask this question, but here we go. I'm trying to use providers states to create an entity and then test the contract of a `get` endpoint for that entity. I need to create it first so that the endpoint doesn't return a 404. I have created a provider state setup function in my API, that creates this entity and returns a dictionary with the relevant value for the generator. I am using the docker pact-cli for verifying the provider, and it is calling that endpoint correctly. My issue is that it is not modifying the pact to use the returned id instead of the example specified in the pact. Here's an example of my code: ```// Consumer in JavaScript provider .given("an existing experiment") .uponReceiving("a request to get the experiment") .withRequest({ method: "GET", path: fromProviderState("/v3/experiments/${uuid}", `/v3/experiments/${exampleUuid}`), }) .willRespondWith({ status: 200, body: { resource: like({ uuid: fromProviderState("${uuid}, exampleUuid) })}, }));``` ```# Provider state setup endpoint (Python & FastApi) @router.get(/pact/setup) def pact_setup(): experiment = create_experiment() return { "uuid": experiment.uuid }``` The setup function is being called by the docker verifier, returning the uuid of the created experiment, but the provider verification is still executing a get request to the `exampleUuid`. Is there anything I'm missing?

benjamin.earle
2023-03-21 20:05
Here?s the generated pact from the js code

tjones
2023-03-21 22:38
Can you show us the verifier configuration?

tjones
2023-03-21 22:39
Are you sure the setup function is being called?

matt.fellows
2023-03-21 22:48
Python doesn?t support verifying V3 pacts, and doesn?t understand the ?from provider state? feature

tjones
2023-03-21 22:49
ah, of course

sanjaysingh99in
2023-03-22 00:57
has joined #general

benjamin.earle
2023-03-22 01:35
Oooh. I see. I'm not using pact-python though. Verification is being done through the pact https://hub.docker.com/r/pactfoundation/pact-cli. Doesn't that support provider injection? It is calling the setup function correctly (requests are logged properly). It's just not injecting the return value on the contract.

matt.fellows
2023-03-22 03:01
Aha!

matt.fellows
2023-03-22 03:01
ok so the answer is yes but no

matt.fellows
2023-03-22 03:02
You actually want https://docs.pact.io/implementation_guides/cli#native-binary-new (the newer verifier). The docker one still uses Ruby. I think we ought to consider getting the new verifier into that image. I?ll raise an issue

matt.fellows
2023-03-22 03:05
Created https://github.com/pact-foundation/pact-ruby-cli/issues/95 to track this issue, but it might get moved about.

benjamin.earle
2023-03-22 03:17
Well, that explains a lot :sweat_smile:. I knew it used the ruby version, but I didn't know it doesn't support provider state injection. Thank you for the help and support!

matt.fellows
2023-03-22 03:17
No worries, it?s confusing. I?m sorry about that

matt.fellows
2023-03-22 03:18
It should be fairly straightforward to swap to the rust version. There might be a docker container for that if it?s your preferred pathway, i?ll take a look. But I do wonder if we should have all of the tools in one place

rafalmaciak
2023-03-22 08:03
has joined #general

markcox20
2023-03-22 09:21
Hi, apologies for cross-posting from #pact-ruby-standalone, but just in case that channel isn?t monitored.

jyothy18
2023-03-22 09:23
has joined #general

haiyang.huang
2023-03-22 10:30
has joined #general

denispegan4
2023-03-22 13:14
has joined #general

erich.buri
2023-03-22 14:30
Hi @kgrady I had the same problem. I added an Interceptor to the TestBed-Environment: ```@Injectable() export class DynamicUrlTestInterceptor implements HttpInterceptor { constructor(private urlResolver: () => string | undefined) {} intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { const urlToPrepend = this.urlResolver(); if (urlToPrepend) { request = request.clone({ url: urlToPrepend + request.url, }); } return next.handle(request); } }``` Add it to your Test-Env: ```{ provide: HTTP_INTERCEPTORS, useValue: new DynamicUrlTestInterceptor(() => mockServerUrl), multi: true, },``` In my test-case: ```const angebotIntegrationService = TestBed.inject(AngebotIntegrationService); await providerV3.executeTest(async (mockServer) => { mockServerUrl = mockServer.url; // activate DynamicUrlTestInterceptor const response = await firstValueFrom( angebotIntegrationService.createAngebotNeugeschaeftRsvUnternehmen( angeboteErstellenNeugeschaeftRsvUnternehmen, captchaToken ) );```

erich.buri
2023-03-22 14:38
Need to add this to your test as well: ```let mockServerUrl: string | undefined = undefined;``` Basically, I set the `mockServerUrl = mockServer.url;` in `executeTest()` , for any subsequent Http-Request, the Interceptor will be called, which will in turn call the `urlResolver` callback to get the current-value to use at that moment, and change the url accordingly.

erich.buri
2023-03-22 14:38
let me know if you found a better solution

benjamin.earle
2023-03-22 14:50
That would be great! I ended up making my verifier in JS, but it would be nice to have a cli ready to use.

kgrady
2023-03-22 20:50
@erich.buri With your solution, where is `mockServerUrl` being passed? If I assign it within `executeTest()` it has no place to go and is just an unused variable

kgrady
2023-03-22 20:57
@yousafn The API that I am testing does not take a URL as a parameter when instantiating like in `const api = new API(mockService.url);` but takes an `HttpService` and `HttpConfigService` which have been added as providers in a `beforeEach()` . If that is the case, can I simply leave the API instantiation out of the `executeTest()` method? I still need access to a mockUrl for the provider `ConfigService`?s `useValue`

kgrady
2023-03-22 20:59
Here?s a look at my `beforeEach` untouched. Error is on `mockProvider.mockService` which no longer exists: ``` beforeEach(async () => { const app = await Test.createTestingModule({ imports: [ConfigModule, HttpModule], providers: [ TenantService, HttpConfigService, { provide: 'MOCK_ENV', useValue: false, }, { provide: ConfigService, useValue: { get: jest.fn((key: string) => { if (key === 'TENANT_BASE_URL') { return mockProvider.mockService.baseUrl; } }), }, }, ], }).compile(); service = app.get<TenantService>(TenantService); });```

tranghetti
2023-03-22 21:15
has joined #general

amruta_mandavilli
2023-03-23 06:23
has joined #general

shubhamshriram.shinde
2023-03-23 06:34
has joined #general

juliemarierosok
2023-03-23 08:20
has joined #general

colin.aygalinc
2023-03-23 09:23
has joined #general

erich.buri
2023-03-23 09:37
I don't know `HttpService` - we're using `HttpClient` . But looking at your setup, you would have to return the actual value here: ```{ provide: ConfigService, useValue: { get: jest.fn((key: string) => { if (key === 'TENANT_BASE_URL') { return mockProvider.mockService.baseUrl; } }), },``` Except that you use a variable like `mockServerUrl` in my case (instead of `mockProvider.mockService.baseUrl` ) mockServerUrl will then be set inside `executeTest()`

me1685
2023-03-23 10:53
has joined #general

erich.buri
2023-03-23 11:14
Hi, I think there is a serious issue with `eachKeyLike()` and it might have to do with the fix here: https://github.com/pact-foundation/pact-reference/issues/216 Please see my comment here https://github.com/pact-foundation/pact-reference/issues/216#issuecomment-1480976176 and the added note below: https://github.com/pact-foundation/pact-reference/issues/216#issuecomment-1480996968 I ran the same on Windows and Mac as I wasn't sure if it is related to my machine. But I got the same result. This is a simplified version to show the issue. I have a more complex data-structure I want to test and the resulting `matchingRules` I got were looking very strange: Example: ```"$.angebote.*.*.*[*].*[*].*.*.*": { "combine": "AND", "matchers": [ { "match": "type", "min": 1 }, { "match": "type" }, { "match": "integer" } ] },``` How could anything satisfy that.

gregpovorozniuk
2023-03-23 11:32
has joined #general

yousafn
2023-03-23 14:32
:blobwave: Hey everyone, hope you are doing well today! The latest Pact blog is out. So sit back, relax, and join me for some contract testing in the wild. Hear from community experts and some of the latest initiatives in the Pact ecosystem. You can read it https://docs.pact.io/blog/2023/03/21/pact-open-source-update-mar-2023!

mpalla553
2023-03-23 14:51
has joined #general

sumit.singh
2023-03-23 18:03
has joined #general

kgrady
2023-03-23 18:08
So now I?ve got: ``` provide: ConfigService, useValue: { get: jest.fn((key: string) => { if (key === 'TENANT_BASE_URL') { return new DynamicUrlTestInterceptor(() => mockServerUrl); } }), },``` after implementing the DynamicUrlTestInterceptor. I assign the mockServerUrl in `executeTest()` but then the mockServerUrl isn?t referenced after it is assigned so it seems useless: ``` await mockProvider.executeTest(async mockServer => { mockServerUrl = mockServer.url; const tenant = await lastValueFrom(service.createTenant(requestHeaders, reqBody)); expect(tenant).toStrictEqual(camelCaseObjectKeys(responseBody)); });``` The test result in a connection error I assume is caused by the Url not working properly: ``` + "code": "ECONNREFUSED", + "data": undefined, + "message": "connect ECONNREFUSED ::1:80", + "status": undefined, + "statusText": undefined,```

quinton.miller
2023-03-23 19:18
has joined #general

sushant.soni
2023-03-24 11:05
Hello, So one of the questions I have received is. ```can contract tests ensure the understanding of what is an optional parameter and what is not between provider and consumer (and how)```

tjones
2023-03-24 11:23
Yes, but I think this not really the right question

hurdledatrade
2023-03-24 11:24
has joined #general

tjones
2023-03-24 11:24
Understanding what parameters are optional / not optional is kind of an implementation detail. It?s _one_ solution to ?how do I know if these two services can communicate??

tjones
2023-03-24 11:25
Contract testing side steps the question of optional / not optional by providing clear examples.

tjones
2023-03-24 11:25
If, in the examples, there are any times the client fails to provide the optional parameter, the contract verification will fail.

srijan.c
2023-03-24 15:26
has joined #general

praveen.gangasani
2023-03-26 13:19
has joined #general

yzxu
2023-03-27 07:27
has joined #general

1248124408
2023-03-27 08:59
has joined #general

daniel.redelberger
2023-03-27 09:07
has joined #general

erich.buri
2023-03-27 09:30
This is not what I suggested: ``` provide: ConfigService, useValue: { get: jest.fn((key: string) => { if (key === 'TENANT_BASE_URL') { return new DynamicUrlTestInterceptor(() => mockServerUrl); } }), },```

erich.buri
2023-03-27 09:35
You're ConfigService returning an Interceptor does not make sense. ``` { provide: ConfigService, useValue: { get: jest.fn((key: string) => { if (key === 'TENANT_BASE_URL') { return mockProvider.mockService.baseUrl; } }), },``` Did you try to return the variable mockServerUrl here? You need to show me your Service-Code or find out at what time in the Lifecycle of your service it will call configService.get('TENANT_BASE_URL'). Anyway, if your Service eventually uses Angular HttpClient, you can just add this. ```{ provide: HTTP_INTERCEPTORS, useValue: new DynamicUrlTestInterceptor(() => mockServerUrl), multi: true, },``` Replace `() => mockServerUrl` with `() => { console.log('Will now use url: ', mockServerUrl); return mockServerUrl }` and you will see in your log at what time the Url actually gets used.

mohammed.a.ezzedine
2023-03-27 15:25
has joined #general

mohammed.a.ezzedine
2023-03-27 16:01
Hello, I've been using PACT for HTTP contracts, and it's great. I have some questions regarding its usage with message contracts: - I've noticed that the documentation does not provide a full scenario example of how to write and validate a contract for message target as it does for HTTP ones, does this have any implication on the future development targeted for the message contracts, or is it just not mature enough? - When verifying HTTP contracts, PACT tests the contracts against the controller at the exposed port by the provider. However, for the message contracts, it is as simple as manually building the message object and returning it in a method, which does not really tests the correctness of the provider, since it can be returning a different object than the one being used in reality. Are there any future plans or vision to change this?

yousafn
2023-03-27 17:11
we have a few examples in different languages, which are you looking for? you are correct that message pact is agnostic of the protocol and concentrates on on the message handling, probably of a message processor in your code, if it?s suitably split from the transport layer. we are aware that this is a halfway house and have since introduced the pact plug-in framework to allow for users to construct their own plugins to handle custom matching rules say for different content types, or protocols/transport layers, pact protobuf plug-in being the first allowing for contract testing of proto/grpc messages.

kiran.malsetty
2023-03-27 17:20
has joined #general

kgrady
2023-03-27 18:22
> Did you try to return the variable mockServerUrl here? Yes I had the same error results > Anyway, if your Service eventually uses Angular HttpClient, you can just add this. I?m getting a type mismatch error: ```Type 'InjectionToken<HttpInterceptor[]>' is not assignable to type 'InjectionToken'. Type 'InjectionToken<HttpInterceptor[]>' is missing the following properties from type 'Abstract<any>': prototype, apply, call, bind, and 5 more.``` our main app module is using HttpClient but HttpConfigService is not. The HttpConfigService just determines if we are using local path for dummy data or not, for example: ```constructor(@Inject(MOCK_ENV) private mockEnv: boolean, private configService: ConfigService) {} private baseUrl = this.configService.get('TENANT_BASE_URL'); private tenantUrl = `${this.baseUrl}/tenant`; public getTenant(): string { const config: httpConfig = { path: this.tenantUrl, localPath: '/get-tenant.json', }; return this.getPath(config); }``` which is where configService.get(?TENANT_BASE_URL) is being called

mohammed.a.ezzedine
2023-03-27 18:45
Thanks for the reply! I am using pact with Spring framework in java. Yes, I came across some examples, but finding an example with the same consumer/provider dependencies was quite a hassle, but I figured it out in the end. Thanks for letting me know about the plugin-in framework. I was intending to give it a look anyway. I hope it suits my use case.

rchild
2023-03-27 18:46
has joined #general

asoni
2023-03-27 20:23
has joined #general

yu.xie
2023-03-28 00:08
has joined #general

gamer.fikri
2023-03-28 04:46
has joined #general

gamer.fikri
2023-03-28 04:53
So, I came here from https://docs.pact.io/faq/convinceme .. I am still yet not convinced, because of our current workflow is 180deg different on what pact offer that is Consumer-Driven. But "I have control over the consumer", this mostly internal apps afterall. so 1. Will consumer now dictate the provider endpoint and response ? 2. Then each of my consumer now will write basically some 80% identical tests because most of them require the same response from the same endpoint ?

tjones
2023-03-28 05:04
You don?t have to have the consumer design the provider endpoints. Consumer driven design is different to consumer driven testing.

tjones
2023-03-28 05:04
Consumer driven testing exists because that way you?re testing the parts the consumer is ACTUALLY using, and not anything else

tjones
2023-03-28 05:05
(Side point: Consumer driven design is less common than provider driven design, but I don?t think there?s a good reason for this. After all, who is the provider _for_? Surely it should provide what the consumer needs, not provide what it thinks the consumer needs)

tjones
2023-03-28 05:07
> Then each of my consumer now will write basically some 80% identical tests because most of them require the same response from the same endpoint ? Do they really require the same response? Usually different consumers want different parts of the response from the same endpoint. Without Pact, testing this will still have some duplication. It might indicate that there?s a client library that?s worth splitting out or something.

gamer.fikri
2023-03-28 05:09
> You don?t have to have the consumer design the provider endpoints. Consumer driven design is different to consumer driven testing. Oh, so I could use pact to verify the interaction *after* the spec is laid out ?, so is this an acceptable flow ? 1. provider design first, output via openapi spec 2. consumer view the spec, write the test for their expected response 3. provider then write their own side of pact

gamer.fikri
2023-03-28 05:09
> Without Pact, testing this will still have some duplication. It might indicate that there?s a client library that?s worth splitting out or something. Hmm, I agree

tjones
2023-03-28 05:11
Yes, except that you might be confused, depending on what you meant by step 3 - the provider _doesn?t_ write a pact file, they write a test that verifies the consumer(s) pacts.

tjones
2023-03-28 05:12
A subtlety here is that the openapi spec and the contract file have different purposes. The spec describes the grammar of the requests and responses (useful for implementers), while the contract describes several example request/response pairs in different server states (useful for testing).

gamer.fikri
2023-03-28 05:12
> they write a test that verifies the consumer(s) pacts. Oh sorry, yes I mean this

tjones
2023-03-28 05:13
You can?t actually take an openapi spec and generate a pact file, and you also can?t take a pact file and generate an openapi spec - even though at first glance it feels like you should be able to.

gamer.fikri
2023-03-28 05:13
So what I meant is that consumer can have some guidelines to write the pact, and not burden them with designing the api

tjones
2023-03-28 05:13
They?re different.

tjones
2023-03-28 05:13
Yes, that?s right

tjones
2023-03-28 05:13
A consumer driven testing approach doesn?t force you in to a consumer driven design.

tjones
2023-03-28 05:14
(I personally believe the best practice would be consumer driven design, but a lot of teams don?t want to work that way, for various reasons)

gamer.fikri
2023-03-28 05:14
> A consumer driven testing approach doesn?t force you in to a consumer driven design. This is maybe what I miss when I read how the pact works

tjones
2023-03-28 05:14
Right, yeah

gamer.fikri
2023-03-28 05:14
I think its more clearer now

gamer.fikri
2023-03-28 05:15
Thanks a lot

tjones
2023-03-28 05:15
You?re welcome! By the way, I?m working on another tool which lets you write the contract at either end, if you want to do server driven contracts. It?s not at a stable release yet, but you can follow the progress here https://case.contract-testing.io/docs/intro

tjones
2023-03-28 05:19
I would also say that: > because of our current workflow is 180deg different on what pact offer that is Consumer-Driven. This is definitely the most common way to design APIs at the moment, and I?ve worked with teams who are thinking and working this way to successfully use Pact without changing the way they work.

shaun.carmody
2023-03-28 13:23
has joined #general

christianschiepe
2023-03-28 13:50
has joined #general

christianschiepe
2023-03-28 13:53
Hi there. I try to convince my Team, but the argument is still: We use yaml files and an API generator, so what is the real advantage of Pact? For sure, prevent breaking changes! I know that YAML Files still dont prevent Integration Bugs from happening, but what bugs exactly are meant here?

yousafn
2023-03-28 14:02
Yo, An OpenAPI and a client SDK based off it, will tie your consumer and provider in lockstep, and you would have to work with the assumption that every endpoint and every field without an object is used by a consumer, which usually doesn't reflect reality. This lack of visibility into consumers exact use cases, and the data they depend on, means more friction on a provider side when making changes to an api. Do you make everything backwards compatible, what about a breaking change, do you start versioning? Consumer driven contract testing and Pact provides actionable insight on both sides of the fence. All of that is not withstanding that Pact utilised with the Pact Broker allows you to create a matrix of your codebases at point in times (you deploy a point in time instance of your application) and want to know if its compatible with an dependants in an environment at any one time. That can help prevent breaking changes in communication making their way into higher level environments and forcing that conversation around design and intent of the services earlier in the SDLC (which is arguably much cheaper)

aberman
2023-03-28 19:24
has joined #general


tjones
2023-03-28 22:32
Yes, contract testing can still provide value in this scenario. A well-written contract testing approach will: ? Track which versions are compatible with each other ? Protect against deployments that are broken due to communication issues ? Protect against breaking semantic changes (eg Admin vs ADMIN for a field that accepts strings) If your communication code is autogenerated, then you still need a way to track which versions are compatible with each other. You also need a way to track and prevent breaking changes - most schema based approaches do this with manual rigour. Manual rigour is effective, but fallible. All schema approaches are syntactic rather than semantic - for example, gRPC prevents syntactic breaking changes by ensuring that all fields have default values. However, this is a bit like saying ?all our endpoints use json, so we can?t send incompatible responses?. Just because the payload can be parsed by the consumer doesn?t mean it has meaning to the consumer. Technically, you never need any testing, as all tests are just risk reduction. Schema-based approaches provide some safety over manual implementations, so depending on your needs, the risks might be acceptable. The questions are whether you want to live with the risk of deploying breaking API changes, and whether you are successfully avoiding breaking API changes with your current approaches.

tjones
2023-03-28 22:48
My personal experience is - teams who think they don?t need contract testing because they generate everything from a schema also have really really good on-call practices. They got good at on-call because of all the outages. I prefer not to have the outages.

tjones
2023-03-28 22:49
(your milage may vary - there might be a way to use auto-generated APIs for deployment confidence, but I haven?t yet seen it)

ilia
2023-03-28 23:55
:wave: Hi all, apologies if this seems spammy, we just need your help to spread the word :slightly_smiling_face:

0xoscario
2023-03-29 03:38
has joined #general

yousafn
2023-03-29 19:57
This is _such_ a cool opportunity, to get paid to play in open source and drive both feature sets for our commercial and open source users. If you are on the fence, why not have a chat with @ilia and see where it ends up :slightly_smiling_face:

paddyhendy94
2023-03-30 12:48
has joined #general

haroldrobson11
2023-03-30 13:16
has joined #general

xchen
2023-03-30 15:20
Hi All. I have a question on the pact broker config. Everything works fine if I have this annotation used on the provider verification test class. @PactBroker(scheme = "https", host = "company.test.stp.hmlr.zone", port = "443"). But if I changed it to @PactBroker and add config on my build.gradle. ```pact { broker { pactBrokerUrl = 'https://company.test.stp.hmlr.zone/' }``` the pact broker won't be found. Not sure why it does not work. Please help. Thank you.

jfbosca
2023-03-30 15:26
has joined #general

uglyog
2023-03-30 22:04
`@PactBroker` annotation does not work with the config in the Gradle build file, that is only used by the Gradle plugin. You can use system properties with that annotation. Refer to https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit#using-java-system-properties but also take note of https://github.com/pact-foundation/pact-jvm/tree/master/provider/junit5#important-note-jvm-system-properties-needs-to-be-set-on-the-test-jvm-if-your-build-is-running-with-gradle-or-maven

constantin.jaeck
2023-03-31 09:34
OK so I got it running and it's actually very nice. Basically I'm doing black-box texting in BDD style where Cucumber + Puppeteer do some click testing, and in the end it spawn some pact files which I upload to our broker. But there is something I find inconvinient with the pact-js api. In the past I remember it was possible to start a pact server and add interactions - in the end verify them. Now the api adds a pact and then every verification spawns a new server. Here I neede to hack my way around it and collect the requests with nock and forward them to the pact server. Is there a way to use the old approach?

tjones
2023-03-31 09:37
I?m on mobile, so short response- but can you collect the requests you want to mock and send them all at once?

tjones
2023-03-31 09:37
Also - sounds cool! Do you have a link we can check out?

constantin.jaeck
2023-03-31 09:38
sadly I've built this for a company internal thing - If I find the time I can create a public example on my private sheet

tjones
2023-03-31 09:39
It sounds like it would be generally useful - maybe your company might want to open source it (I know this isn?t always easy or practical, of course)

tjones
2023-03-31 09:39
A good argument would be future proofing- if you have a custom use of an open source tool, but keep it private, it might not stay compatible

constantin.jaeck
2023-03-31 09:42
I wouldn't consider this one an open source tool - It would be more of a collection of configurations / experient :slightly_smiling_face: - Maybe I find the time on the weekend to recreate it as an pet-shop example

ulises.cervino
2023-03-31 13:24
is anybody doing contract testing against graphql endpoints?

ulises.cervino
2023-03-31 13:25
it's all http with funky protocol inside, sure, but I'm curious about things like provider states (IDs, etc.)

ulises.cervino
2023-03-31 13:26
google does return a few hits (mostly blogs posts with a simple request/response pair that are fairly static), so I'm still wondering

tjones
2023-04-01 06:49
Yes. Pact-js has a wrapper to help

tjones
2023-04-01 06:50
Why would this be different with graphql?

daominhdam
2023-04-01 10:04
has joined #general

edudelta
2023-04-03 08:40
Hi all! Sorry, has contract testing to be made at same language of solution side?

matt.fellows
2023-04-03 08:46
I think you're asking if you create a contract in JS does it need to also be verified in JS? The answer to that question is no, they can be different. They in general should match the language of the code you are testing. E.g. if you have a react JS consumer, the tests should also be JS

jordan.r.stewart
2023-04-03 08:58
I've just noticed that our consumer contracts are being committed to version control. This seems like a bad idea -- when someone deletes or renames a contract, since the change is _merged_ to the contract file, we never get rid of the old contract. I took a look through the docs and can't find anything about this one way or the other (I might have missed something though!) so I just wanted to ask here before I remove them from version control, to make sure I'm not doing something silly . . .

xchen
2023-04-03 09:56
Thanks. @uglyog Now I set system properties for pact broker. It works fine. However, the provider's branch name does not show anymore on the pact broker UI. I have these config on build.gradle. ```serviceProviders { fromPactBroker { withSelectors { branch('poc-contract-testing') } } }``` Please give some suggestions. Many thanks.

edudelta
2023-04-03 09:59
Thank you. But imagine you have Consumer in JS and Provider in .NET. Can I build contract testing only with Java, for instance? (both sides)

edudelta
2023-04-03 10:09
I'm asking because as understood I could raise the consumer by some script with everything needed (docker, mocks) to perform tests written in any language.

matt.fellows
2023-04-03 10:30
Yep, usually no need to check them in I'd you have a broker. It can be helpful in some cases (e.g. if used as stubs)

matt.fellows
2023-04-03 10:30
But most people won't need to

jordan.r.stewart
2023-04-03 10:30
:+1: great, thanks :smile:

matt.fellows
2023-04-03 10:31
It's not recommended. Pact should be thought of as a unit testing tool and used in that context

matt.fellows
2023-04-03 10:31
It's strictly not, but that mindset is what I'd recommend as a good starting point to get the scoping right

yousafn
2023-04-03 11:04
testing closest to the code, in the language the code is written in, will provide the shortest feedback loops and provide stronger guarantees that the mock expectations match reality, and are updated when the code under test is updated. Teams who don't will probably find overlap, your dev team will probably have component integration tests, where they are mocking code.

edudelta
2023-04-03 12:00
Indeed. I wonder if QA guys could go ahead with contract testing, but changing with one language to another is not easy. DEV need to help.

matt.fellows
2023-04-03 12:01
Pact is really a tool for Developers, or at least those that have access to the code base. I?ve never really seen it work well when done outside of the code base. It starts off looking ok, but then it becomes a maintenance issue as the system is evolved

edudelta
2023-04-03 12:01
In this way I saw Spring has modularized contrac testing solution. That could fit any language build in Java only.

matt.fellows
2023-04-03 12:04
Yes, but I?m not convinced you won?t run into the same problems listed above. It?s not a technology problem, it?s a people/organisation problem. When other teams write tests for other people?s code, the maintenance cost/pain is much higher. That?s not to say it?s not valuable, but usually the problem we?re trying to solve here is half created by that problem (the other half is the rest of the pain points associated with E2E tests). You might be interested in something like PactFlow?s https://pactflow.io/bi-directional-contract-testing/ which is a lot more decoupled and alleviates many of these pain points, at the cost of being a bit less strict in terms of guarantees (see https://docs.pactflow.io/docs/bi-directional-contract-testing/#trade-offs)

yousafn
2023-04-03 12:09
It would be more advisable for QA teams to look at the overlap of testing currently being performed, and the endpoints which are subject to change / fail often in integration tests, and work with the developers to advise about the value of contract testing, and utilise that in their codebases, as part of their unit testing strategy. This way you can avoid communication style errors pre deployment, leaving your integration tests to look at the useful business value normally spread out over multiple microservices, safe in the knowledge that each individual service can communicate with its dependants

edudelta
2023-04-03 12:09
One problem that appears is about who should test and this is already covered by many researches and, ok devs covering unit. helping with integration but not about e2e. I'm looking for pushing automation crew to contract tests. at some point I can but some limitations.

matt.fellows
2023-04-03 12:10
> I?m looking for pushing automation crew to contract tests what do you mean by this?

edudelta
2023-04-03 12:11
I'm looking for automation crew that write e2e tests to write contract testing as well.

edudelta
2023-04-03 12:12
so far I got it, by myself. right now I'm wondering limitations.

joseph.gately
2023-04-03 14:14
has joined #general

tjones
2023-04-03 15:08
Pact could probably call out to git and warn if this has happened. Not everyone uses git, but most do, and it would be a nice warning for those who are.

kgrady
2023-04-03 16:28
@erich.buri I haven?t been able to figure out how to implement the interceptor due to this type issue. Let me know if you have any input, thank you!

uglyog
2023-04-03 22:46
Use `pact.provider.branch` to set the branch

matt.fellows
2023-04-04 07:16
> I?m looking for automation crew that write e2e tests to write contract testing as well. gotcha. As stated above, I would highly discourage doing the above. If you?re going to write Pact tests, the developers of the feature should write them. SDET?s are also acceptable if they are appropriately embedded, but again, these tests should be written along with the code being written e.g. TDD

bram.harmsen
2023-04-04 07:20
has joined #general

ulises.cervino
2023-04-04 07:36
it's not, I was wondering about libs that make it nicer than hand-crafted json :slightly_smiling_face:

ulises.cervino
2023-04-04 07:37
cool, the docs seem to suggest that V3 is not yet supported, is this correct?


tjones
2023-04-04 07:37
Ah yeah. Pact-js has a wrapper, but it?s not very first class

tjones
2023-04-04 07:41
I don?t know, sorry.

xchen
2023-04-04 09:04
Thanks.

edudelta
2023-04-04 09:59
Yes, we have access to the solution, but must of QAs are Java only. this is why I raised this thread. Thank you!

sarah.al-hawi
2023-04-04 10:55
has joined #general

andrei.enache
2023-04-04 10:55
has joined #general

sohaib.zahid
2023-04-04 10:55
has joined #general

behrouz.pooladrak
2023-04-04 10:55
has joined #general

amarpal.amrith
2023-04-04 10:57
has joined #general

laszlo.bogardi
2023-04-04 10:57
has joined #general

erich.buri
2023-04-04 11:37
@kgrady The Interceptor is here: https://pact-foundation.slack.com/archives/C5F4KFKR8/p1679495404915779?thread_ts=1679354578.320799&cid=C5F4KFKR8 Add it like this ```let mockServerUrl = undefined; beforeEach(async () => { mockServerUrl = undefined; const app = await Test.createTestingModule({ imports: [ConfigModule, HttpModule], providers: [ TenantService, HttpConfigService, { provide: 'MOCK_ENV', useValue: false, }, { provide: HTTP_INTERCEPTORS, useValue: new DynamicUrlTestInterceptor(() => mockServerUrl), multi: true, }, ...``` In your test: ``` await mockProvider.executeTest(async mockServer => { mockServerUrl = mockServer.url; const tenant = await lastValueFrom(service.createTenant(requestHeaders, reqBody)); expect(tenant).toStrictEqual(camelCaseObjectKeys(responseBody)); });``` There's nothing I can add to that. The Injection-Token HTTP_INTERCEPTORS and the Base-Class HttpInterceptor are from Angular itself. Maybe add a console.log()-Statement in the intercept()-Method of the DynamicUrlTestInterceptor to better understand what happens and to verify that the actual request comes through there.

caroline.thom
2023-04-04 13:20
has joined #general

jeremy.chao
2023-04-04 14:49
has joined #general

bmdk83
2023-04-04 15:51
has joined #general

maithree.uppunda
2023-04-05 07:50
has joined #general

sivamkumar80
2023-04-05 13:34
has joined #general

vanja.ilic
2023-04-05 14:24
has joined #general

proydimonoff
2023-04-05 14:30
has joined #general

proy
2023-04-05 14:33
has joined #general

kevin.moylan
2023-04-05 16:13
has joined #general

vijaykumar.patel
2023-04-06 06:36
has joined #general

ankit.kumar
2023-04-06 10:55
has joined #general

joye.arbuckle
2023-04-06 14:24
has joined #general

buckley
2023-04-06 18:46
~Hello, I was attempting to debug a contract between two of my services in order to replicate a build issue I was having at the time and one of the steps to do so was to delete the PACTs between them. Now when I run my consumer contract tests, it seems to be using a version of the contract which is supposed to have either been updated or deleted despite the UI showing that this contract does not exist. Does anyone know what's going on with that and how to resolve it?~ (resolved see reply)

buckley
2023-04-06 18:54
This has been resolved. The person who updated the contract (me) failed to fully update it and the error was because the interaction wasn't set up correctly.

allison.stone
2023-04-06 19:36
has joined #general

mayank
2023-04-06 22:11
has joined #general

ganesh.walunj
2023-04-07 06:05
has joined #general

jan.krolikowski
2023-04-07 14:39
has joined #general

mragni.majhwar
2023-04-07 17:51
has joined #general

gonzalo.granizo
2023-04-11 10:13
has joined #general

gonzalo.granizo
2023-04-11 10:24
Hi all! Im having an issue with pact integration that i wasn't having before, suddenly this error appeared and configuration on provider test seems correct so i don't know why its not getting the pact from pactflow `http://au.com.dius.pact.provider.junitsupport.loader.NoPactsFoundException: No Pact files were found to verify` `Provider: pss-paymentMethod-api` `Source: Pact Broker https://adidascdc.pactflow.io`

matt.fellows
2023-04-11 10:30
What selectors are you using?

gonzalo.granizo
2023-04-11 10:34
what do you mean by selectors? :sweat_smile:


matt.fellows
2023-04-11 10:46
Can you please share your provider code setup? That will help

matt.fellows
2023-04-11 10:46
(selectors TL;DR - they tell the broker which pacts to find and verify)

gonzalo.granizo
2023-04-11 10:55
this used to find the pact ```@State("get allowed payment methods")```

gonzalo.granizo
2023-04-11 10:57
and for pactbroker im only using this ```pactbroker: url: https://adidascdc.pactflow.io auth: token: ${PACT_AUTH_TOKEN:w6thoBsoU05quJd_sLJNLw}```

matt.fellows
2023-04-11 11:00
> this used to find the pact > ```@State("get allowed payment methods")``` This is just the state annotation.

matt.fellows
2023-04-11 11:01
can you please share the wider java class?

gonzalo.granizo
2023-04-11 11:09
```package com.adidas.pays.orchestration.service.rest.pact; import static org.mockito.ArgumentMatchers.any; import au.com.dius.pact.provider.junit5.PactVerificationContext; import au.com.dius.pact.provider.junitsupport.Provider; import au.com.dius.pact.provider.junitsupport.State; import au.com.dius.pact.provider.junitsupport.loader.PactBroker; import au.com.dius.pact.provider.spring.junit5.PactVerificationSpringProvider; import au.com.dius.pact.provider.spring.junit5.WebTestClientTarget; import lombok.SneakyThrows; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.TestTemplate; import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.web.reactive.server.WebTestClient; import org.springframework.util.ResourceUtils; import org.springframework.validation.beanvalidation.SpringValidatorAdapter; import reactor.core.publisher.Mono; import com.adidas.pays.orchestration.service.dto.response.checkout.regular.AllowedPaymentMethodsResponse; import com.adidas.pays.orchestration.service.rest.PaymentOrderController; @Provider("pss-paymentMethod-api") @PactBroker class PaymentOrderControllerVerifyPactTest extends AbstractVerifyPactTest { @Autowired PaymentOrderController paymentOrderController; @Override @BeforeEach protected void beforeEach(PactVerificationContext context) { super.beforeEach(context); client = WebTestClient.bindToController(paymentOrderController) .controllerAdvice(exceptionAdvice) .validator(new SpringValidatorAdapter(validator)) .build(); context.setTarget(new WebTestClientTarget(client)); } @TestTemplate @ExtendWith(PactVerificationSpringProvider.class) void verifyPact(PactVerificationContext context) { context.verifyInteraction(); } @State("get allowed payment methods") void getAllowedPaymentMethods() { Mockito.when(allowedPaymentMethodsService.allowedPaymentMethods(any())) .thenReturn(buildAllowedPaymentMethods()); } @SneakyThrows private Mono<AllowedPaymentMethodsResponse> buildAllowedPaymentMethods() { return Mono.just(objectMapper.readValue( ResourceUtils.getFile("classpath:pacts/allowed-payment-methods-response.json"), AllowedPaymentMethodsResponse.class)); } }```

matt.fellows
2023-04-11 11:24
hmm

matt.fellows
2023-04-11 11:24
looks like you?re using the default selectors - that?s probably OK but not ideal

matt.fellows
2023-04-11 11:27
ignoring that for now, could you please set the log levels to debug, and share the output here? (please redact any important info)


theburningmonk
2023-04-11 11:29
has joined #general

helenarodcal
2023-04-11 11:31
has joined #general

gonzalo.granizo
2023-04-11 11:37
2023-04-11 13:34:18.758 DEBUG [orchestration-service, ] 80318 --- [ main] h.i.i.PoolingHttpClientConnectionManager : ep-0000000003 connection released [route: {s}->https://adidascdc.pactflow.io:443][total available: 1; route allocated: 1 of 5; total allocated: 1 of 25]

gonzalo.granizo
2023-04-11 11:38
could this mean that there's 1 pact available?

gonzalo.granizo
2023-04-11 11:39
i also tried putting tag @IgnoreNoPactsToVerify and i get this: `java.lang.NullPointerException: Cannot invoke "http://au.com.dius.pact.provider.junit5.PactVerificationContext.setTarget(http://au.com.dius.pact.provider.junit5.TestTarget)" because "context" is null`

matt.fellows
2023-04-11 11:44
mmm, not sure about that last exception sorry - that might be a question for #pact-jvm

matt.fellows
2023-04-11 11:44
as for the logs, that doesn?t seem like a problem - any chance you could get the entire test run log?

gonzalo.granizo
2023-04-11 11:50
this is the full log

matt.fellows
2023-04-11 11:57
thanks, but i?ve just deleted it, as you didn?t redact the token

matt.fellows
2023-04-11 11:57
(I have a copy locally, but please be careful going forward)

matt.fellows
2023-04-11 12:01
Are you sure that?s the right log? I?m seeing a request for `pss-api` in the logs

gonzalo.granizo
2023-04-11 12:03
thanks for your help Matt! we created a new pact in pactflow with a tag and now specifying the tag in the provider its working :slightly_smiling_face:

enver.yasar
2023-04-11 13:39
has joined #general

christian.ledgard
2023-04-11 13:49
has joined #general

ddongre
2023-04-11 15:09
has joined #general

prajapati.pravesh
2023-04-12 02:55
has joined #general

edwin.raju
2023-04-12 08:13
has joined #general

john.hennigan
2023-04-12 08:16
has joined #general

donald.robertson
2023-04-12 10:42
has joined #general

tam.norris
2023-04-12 10:46
has joined #general

gopijaganathan7
2023-04-13 07:27
has joined #general

varnit.garg2424
2023-04-13 09:55
Hello, I would like your opinion about this use case: We have a provider service that exposes one POST endpoint, let?s say `/makePayment` That endpoint takes in two input parameters i.e, _payment_token_ and _customer_id_ Whenever consumer service hits that endpoint, provider internally calls a third party service(external vendor) to make the payment based on payment token and customer id. And returns the response accordingly. The catch is that each payment_token can be used only once. And 3rd party service doesn?t provide a dummy/static token, and there exists a way to call an endpoint in 3rd party staging env to generate the token. My point is that while generating the contract tests in consumer side, we don?t know have payment_token. So, how should I approach this problem? One way I could think is to mock 3rd party service in provider side and carry out the tests. However, if I would like to avoid mocking and want to call staging env of 3rd party service from provider service, then is it feasible to carry out contract testing?

lewis.prescott079
2023-04-13 10:32
I've just released the latest episode of my podcast. A conversation on OpenAPI specifications: https://www.pactman.co.uk/contract-testing-podcast/episode/1bbcff5c/openapi-specification-with-tobias-muller

matt.fellows
2023-04-13 10:39
You shouldn't rely on the presence of live systems for contract tests, that introduces a level of non determinism. That is, stubbing is the preferred approach here. If you must do so, consider an approach (perhaps using provider states) to dynamically replace the token at verification time

varnit.garg2424
2023-04-13 10:42
Thanks for the response, @matt.fellows If we go with live system - Is it possible to override the data in input request using provider state?

varnit.garg2424
2023-04-13 10:46
Actually, it makes sense to stub out the dependencies! Will proceed that way. Thanks! :slightly_smiling_face:

lukaszmalek90
2023-04-13 11:40
has joined #general

yousafn
2023-04-13 11:52
Awesome, looking forward to giving this a listen buddy. We will share it on our networks too

tjones
2023-04-13 12:43
Yep, usually you would do this with a provider state - like ?`DUMMY_TOKEN` is a valid authentication token? and stub out the dependencies

tjones
2023-04-13 12:43
(you can then also write contract tests for the dependencies, if you want :raised_hands:)

nickwilliamsqa
2023-04-13 16:15
has joined #general

2023-04-13 17:01
This message was deleted.

nickwilliamsqa
2023-04-13 17:02
Example of inheritance & references in the spec: ```"Parent": { "description": "Parent schema", "type": "object", "required": ["id", "activities"], "properties": { "id": { "type": "integer", "example": 3, "enum": [3, 4, 5, 6, 7, 8, 9, 16], "nullable": false }, "activities": { "type": "array", "nullable": false, "minimum": 1, "items": { "type": "string", "example": "6AA2A3B9-66BD-447C-90C8-A350F60D592B" } } } }, "Child": { "description": "", "allOf": [{ "$ref": "#/components/schemas/Parent" }], "type": "object", "properties": { "id": { "type": "integer", "enum": [3] }, "activities": { "type": "array", "items": { "type": "string", "enum": [ "value", "another value" ] } } } }``` Example of keyword & circular references: ```"properties": { "project_type": { "type": "object", "nullable": true, "oneOf": [{ "$ref": "#/components/schemas/Category" }] } } .... "schemas": { "Category": { "type": "object", "required": ["short_name"], "properties": { "short_name": { "type": "string", "nullable": false, "example": "test" }, "child": { "nullable": true, "allOf": [{ "$ref": "#/components/schemas/Category" }] } } } }```

tjones
2023-04-13 17:05
This is a pactflow feature, you probably want to put it in #pactflow

guozhangliew
2023-04-14 02:03
has joined #general

praboo.p
2023-04-14 07:17
has joined #general

florenciaaldana.rodri
2023-04-14 08:10
has joined #general

yousafn
2023-04-14 11:08
Anyone using webhookless workflows out in the wild?

yousafn
2023-04-14 11:46
Was a great listen Tobias is lovely, his parting comments made me chuckle :slightly_smiling_face:

tjones
2023-04-14 13:08
I have never used the webhooks. AMA

yousafn
2023-04-14 13:09
1. Why are you awake night :owl: :sweat_smile: (jk - pot calling the kettle black) 2. When a consumer contract changes, assuming you are using a regular CDCT flow, where you use Pact to verify your provider, how are you triggering the provider build to return verification results

yousafn
2023-04-14 13:10
oh 11pm that isn't too bad - timezones shifting everywhere at the moment

yousafn
2023-04-14 13:11
Does anyone, or have you used providers on a cron or something similar to pick up contracts requiring verification (via include work in progress pacts) or similar?

pact544
2023-04-14 14:54
I've used webhookless before with Teamcity where the provider has a snapshot and artifact dependency on the consumer, so each time a new consumer version is built the provider automatically runs verification also

taher.kapasi
2023-04-14 15:53
has joined #general

michael385
2023-04-14 16:40
has joined #general

jean.paiva42
2023-04-14 20:26
hey peeps, I was able to use the pact-provider-verifier for a while now, but this week I had to go through a DELETE endpoint and I notice that things on the provider side froze and I couldn?t see any result. Did anyone see this issue before and know how can I avoid it? This DELETE request has a body on it. I read a little on the matter and I saw this open issue: https://github.com/pact-foundation/pact-js/issues/484 Considering that I am using the agnostic implementation of the provider, is there anything I could do?

tjones
2023-04-14 23:50
If all services are under active development, you don?t need to trigger verification, you can just wait for a new build to happen. If your contract isn?t changing, you don?t need to trigger verification either. If the contract is changing, but the provider isn?t under active development (unlikely, but does happen), other options I have used: ? you can tie the builds together (I think this was also teamcity, but I don?t remember). This wouldn?t scale well to hundreds of services ? Manual build kickoff (doesn?t scale well at all) ? Schedule the verification to run every X minutes (kind of a hack) Most of the time I?ve been working in the situation where active development is happening in both services, so it?s not really a problem to not use the webhooks. Clearly the webhooks would be better than all of the above, as you?d be able to do immediate deploy checks or whatever. But most of the time I don?t think you need them

tjones
2023-04-14 23:55
the key point is - you only need to kick off the provider verification if: ? you are changing the contract, and ? you want to try to deploy immediately You only need to do this with a webhook if the provider is not under active development. If the provider is not under active development, and is not compatible with the contract, the deploy check will fail anyway. So, the only case that matters is if the provider is _already_ compatible with the new contract - say the development finished before the pact was published. I try to use contract tests in a TDD way, so usually the consumer team have published the contract before the provider team does the work. Which means we?d get no benefit from the webhooks. Which in turn means I have never got around to figuring out how they work - the benefit isn?t worth the investment. If I already knew how the webhooks worked, I?d use them every time, probably. I imagine they?re not difficult to set up.

tjones
2023-04-14 23:57
This webhookless strategy has the advantage that it encourages consumer-driven API development, I suppose.

tjones
2023-04-15 00:01
Yes, you can change the consumer to not send a delete with a body. HTTP doesn?t support this.

tjones
2023-04-15 00:02
certain clients _might_ support it, and certain servers _might_ understand it. But you can?t be sure.

tjones
2023-04-15 00:02
And the http rfc says they don?t have to support it.

matt.fellows
2023-04-15 01:47
Yep, it's all very vague when you send a body on a DELETE or a GET. Best avoiding it I've actually seen a case before where a consumer sends a body but the provider ignores it. It's worth checking, because then you know the body is redundant and you can just do what is explicitly supported by the RFC (and frankly, what is standard practice)

darrenoc3
2023-04-15 03:46
has joined #general

guozhangliew
2023-04-17 00:18
Hi my CI is having the following error when I am using the `pactfoundation/pact-cli:latest` docker image ```/usr/lib/ruby/gems/3.1.0/gems/pact_broker-client-1.66.1/lib/pact_broker/client/hal/http_client.rb:49:in `create_request': undefined method `request_uri' for #<URI::Generic //pact.dev.stackjourney.xyz/contracts/publish> (NoMethodError) request = Net::HTTP.const_get(http_method).new(uri.request_uri) ^^^^^^^^^^^^``` I have searched through all issues in the pact foundation github space this is the docker command I used ```docker run -t -i --rm --init --volume .. --env PACT_BROKER_BASE_URL --env PACT_BROKER_USERNAME --env PACT_BROKER_PASSWORD --env GIT_BRANCH=gz/FEAT-69/brokerclient/1 pactfoundation/pact-cli:latest /bin/sh -e -c $'pact-broker help\npact-broker publish backend/pacts --tag-with-git-branch'```

matt.fellows
2023-04-17 00:28
> ```//pact.dev.stackjourney.xyz/contracts/publish``` > my guess is the URL is ill-formatted

guozhangliew
2023-04-17 00:29
does it need https in front of it? I defined my base url this way `PACT_BROKER_BASE_URL=https://pact.dev.stackjourney.xyz`

matt.fellows
2023-04-17 01:25
Yep, it does

matt.fellows
2023-04-17 01:25
I?d suggest adding the `--verbose` flag to your command. My guess is that the arguments being passed aren?t quite what you were wanting

guozhangliew
2023-04-17 02:25
looks like my broker didnt defined https infront of the url but its working now thanks!

ones.ardo
2023-04-17 07:58
has joined #general

deeptiagrawal
2023-04-17 23:31
has joined #general

madhukar.koratagere
2023-04-18 06:24
has joined #general

mahesh.damavarapu
2023-04-18 06:26
has joined #general

haroldrobson11
2023-04-18 09:48
Hi I noticed on my API the pact verifier is making two sets of requests to run one test: ```2023-04-18 10:44:07 "POST /_pact/provider_states HTTP/1.1" 200 4 "-" "Faraday v1.10.3" 2023-04-18 10:44:07 [INFO] base.py(270): POST http://elasticsearch:9200/battery.notification*/_search [status:200 request:0.024s] 2023-04-18 10:44:07 "GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 HTTP/1.1" 200 309 "-" "-" 2023-04-18 10:44:28 "POST /_pact/provider_states HTTP/1.1" 200 47 "-" "Faraday v1.10.3" 2023-04-18 10:44:30 [INFO] base.py(270): POST http://elasticsearch:9200/battery.notification*/_search [status:200 request:0.047s] 2023-04-18 10:44:30 "GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 HTTP/1.1" 200 309 "-" "-"``` My provider states endpoint is set to return after a 20 second delay to give my app time to be ready but it seems that the verifier is using the result from the first request before the app was ready, and the test is failing because there is no data available yet. test output for the above log: ```Verifying a pact between fleet and battery-api Given Fleet has a list of notifications a request for notifications with GET /battery-notifications?limit=100&offset=0&id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 returns a response which has status code 200 has a matching body includes headers "Content-Type" which equals "application/json" 1 interaction, 0 failures WARN: Ignoring unsupported combine AND for path $['vehicle_id'][0] WARN: Ignoring unsupported combine AND for path $``` It shows 1 interaction but two are always happening behind the scenes. I can see all my test data is duplicated twice in the local instance of the app. It shows no failure locally because my app is now full of this data but in CI where it is a fresh instance, it always fails with: ```Matching keys and values are not shown 791 { 792 - "notifications": [ 793 - { 794 - "id": "e2490de5-5bd3-43d5-b7c4-526e33f71304", ... 806 - }, 807 + "notifications": [, 808 +``` Can anybody advise me please?

matt.fellows
2023-04-18 09:58
Can you please share the pact file that is being replayed here? Also, please set the logs to debug/verbose and share (redacting any private info)

matt.fellows
2023-04-18 09:59
Please share the full log output, I appreciate you?re trying to be succinct/helpful, but the long form logs will be most helpful I think here

haroldrobson11
2023-04-18 10:26
OK the verbose log in CI actually shows ```Failures: ... 3) Verifying a pact between fleet and battery-api Given Fleet has a list of notifications a request for notifications with GET /battery-notifications?limit=100&offset=0&vehicle_id=36baa499-ce79-4c03-96e3-93a90fb7f1d9 returns a response which includes headers "Content-Type" which equals "application/json" Failure/Error: set_up_provider_states interaction.provider_states, options[:consumer] Pact::ProviderVerifier::SetUpProviderStateError: Error setting up provider state 'Fleet has a list of notifications' for consumer 'fleet' at http://localhost:8000/_pact/provider_states. response status=500 response body={"message": "Internal Server Error"} # ./bin/pact:15:in `<top (required)>' 1 interaction, 1 failure``` That's interesting, I don't get an internal server error in the local Verbose log It's not a Pact issue then it's something to do with my environment.

haroldrobson11
2023-04-18 10:31
Though I would still be curious why it seems to make duplicate requests when running locally

haroldrobson11
2023-04-18 10:32
the verbose log shows two runs but no clear reason why and in the ordinary log that all gets rolled up into one result

haroldrobson11
2023-04-18 10:36
It seems to be running some other version of this pact

matt.fellows
2023-04-18 11:07
ah!

matt.fellows
2023-04-18 11:07
> docker run --net=host -e VERBOSE=?true? -e PACT_DO_NOT_TRACK=?true? pactfoundation/pact-cli:latest verify ?https://pact.dev.somedomain/pacts/provider/battery-api/consumer/fleet/version/a97efee-QE-74-batterycontracts+a97efee.SNAPSHOT.runner-5ybevqbc-project-456-concurrent-3? --pact-broker-base-url=https://pact.dev.somedomain/ --provider-base-url=http://localhost:8000 --provider-states-setup-url=http://localhost:8000/_pact/provider_states --provider=battery-api You?re providing the broker information to _dynamically_ discover pacts, _and_ you?re passing in the specific URL

matt.fellows
2023-04-18 11:08
So it?s discovering two pacts, one dynamically: > The pact at https://pact.dev.somedomain/pacts/provider/battery-api/consumer/fleet/pact-version/912bb33eea2af5694ce93c3c7b5517c4be3e7ad9 is being verified because the pact content belongs to the consumer version matching the following criterion: > * latest version of fleet from the main branch ?develop? (1b87217-featuremoving-status-embedded+1b87217.SNAPSHOT.runner-5ybevqbc-project-456-concurrent-2) and > INFO: Reading pact at https://pact.dev.somedomain/pacts/provider/battery-api/consumer/fleet/version/a97efee-QE-74-batterycontracts+a97efee.SNAPSHOT.runner-5ybevqbc-project-456-concurrent-3 The one you _explicitly_ asked for

matt.fellows
2023-04-18 11:08
If you want to dynamically discover pacts, don?t pass the Pact URL explicitly (and you should pass in additional selectors). If you only want to verify a specific URL, don?t provide the pact broker details

haroldrobson11
2023-04-18 12:07
Ah, thank you Matt that's really helpful. I think in my implementation it makes sense to validate only the explicitly named pact because this is supposed to run in the context of a webhook from the broker to GitLab done at the time the pact changes. So in my mind, a new Pact is generated on the consumer pipeline, and that is the one I want validated, I don't really care about any other version. Does that make sense or am I doing it wrong? How do I stop it retrieving the pacts automatically? I still want the verification results to be published so I would need to provide the broker details for that wouldn't I?

haroldrobson11
2023-04-18 12:14
Maybe it would be easiest to remove the explicitly named Pact if the automatically retrieved one will always be the latest, which it should be. Though I don't necessarily want the latest, I want the one that relates to a specific upstream branch of the consumer build. So I think I am right to pass in the Pact uRL

yousafn
2023-04-18 12:26
How do all! Have you written a post about Pact, created an open source Pact repo or seen any interesting articles lately? If so, let us know :slightly_smiling_face:

haroldrobson11
2023-04-18 12:29
The command in CI is currently ```docker run --net=host -e VERBOSE='true' -e PACT_BROKER_BASE_URL=https://pact.dev.somedomain/ -e PACT_DO_NOT_TRACK=true pactfoundation/pact-cli:latest verify "$PACT_URL" --provider-base-url=http://localhost:8000 --provider-states-setup-url=http://localhost:8000/_pact/provider_states --provider-version=$CI_COMMIT_SHA --publish```

paul.caplan
2023-04-18 14:52
has joined #general

haroldrobson11
2023-04-18 16:49
I am having an issue with publishing verification results because the tag and version don't exist on the broker yet: ```<- "PUT /pacticipants/battery-api/versions/8d80c2b631939740976bcbf27f05049b86a16dcc/tags/ HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: application/hal+json\r\nUser-Agent: Ruby\r\nContent-Type: application/json\r\nHost: http://pact.dev.ieu.intelematics.club\r\nContent-Length: 0\r\n\r\n" <- "" -> "HTTP/1.1 404 Not Found\r\n"``` Can't it create these dynamically?


matt.fellows
2023-04-19 02:03
It should create the tag on the version dynamically. That?s what I _think_ that `PUT` is doing. But the URL looks suspect. It has a 0 length content (i.e. no body) so I?d expect the tag to be the last segment in the URL, but it?s missing. My guess is that you haven?t populated the tag value correctly

matt.fellows
2023-04-19 02:04
Can you please add `--verbose` or `DEBUG` level logs, and share the redacted output? My guess is the command is invoked incorrectly

matt.fellows
2023-04-19 02:06
this is AWESOME Yousaf! The yaks that had to be shaved to get this going is :chefkiss:

matt.fellows
2023-04-19 02:20
> How do I stop it retrieving the pacts automatically? I still want the verification results to be published so I would need to provide the broker details for that wouldn?t I? the verification results will be published as long as you set the flag for it. Because the URL is a PactBroker URL, it will have the HAL relations in the response, and the verifier will use that URL to publish results.

matt.fellows
2023-04-19 02:21
To stop it using the dynamic lookup, just drop off the `--pact-broker-base-url` arg

matt.fellows
2023-04-19 02:22
> Maybe it would be easiest to remove the explicitly named Pact if the automatically retrieved one will always be the latest, which it should be. Though I don?t necessarily want the latest, I want the one that relates to a specific upstream branch of the consumer build. So I think I am right to pass in the Pact uRL (edited) that?s right. You?re doing the right thing, but you just _don?t_ want to dynamically retrieve pacts for the webhook (and the reverse for regular builds)


cars2991
2023-04-19 02:42
has joined #general

vaidas.sieber
2023-04-19 06:42
has joined #general

jonathandelaros
2023-04-19 07:40
has joined #general

priyaranjanmudliar
2023-04-19 09:05
has joined #general

priyaranjanmudliar
2023-04-19 09:11
:wave: Hi everyone!

priyaranjanmudliar
2023-04-19 09:19
My team in the organization works in erlang and we have taken an initiative towards using Pact as a contract testing tool for http communication as well as message based communication between services (which can be erlang based or non erlang based). I along with the help of some other folks in my team has done PoC for this as well, and now we want to create a library ?Pact-erlang? so that other erlang folks in the community can use this as well !! And for that I would need help from you guys :smiley:

tjones
2023-04-19 09:29
What kind of help do you need?

priyaranjanmudliar
2023-04-19 09:38
Hey @tjones, thanks for asking. Firstly, the PoC i have done is on my local machine which is mac, and during consumer side testing (which also will write the pact after all unit tests are complete), i start up the pact-mock-provider service via erlang as part of my unit test initialization and before my unit tests are executed, it should be up and running. I faced issues permission issues when executing the pact-mock-service binary via erlang. I had to manually allow these binaries in system-preferences, and only then i was able to start up the pact-mock-provider. Can you tell me a better way to handle this ?

tjones
2023-04-19 09:39
I?m not actually a maintainer any more, but I can give some pointers.

tjones
2023-04-19 09:39
Which library are you using?

tjones
2023-04-19 09:40
It sounds like you might be using the Ruby service, which is to be deprecated


priyaranjanmudliar
2023-04-19 09:40
https://github.com/pact-foundation/pact-mock_service I am using this as the mock-provider

tjones
2023-04-19 09:41
Right, yeah. I would recommend using the Rust implementation, as it has more features

tjones
2023-04-19 09:42
It exposes a C API which you can probably link against. This is what pact-js and pact-net do.

tjones
2023-04-19 09:42
And pact-go too, I think

priyaranjanmudliar
2023-04-19 09:42
ohh i see, so you are saying I should use FFIs ?

tjones
2023-04-19 09:43
That?s the pattern, yeah

tjones
2023-04-19 09:43
I think there?s a guide somewhere

tjones
2023-04-19 09:44
Hm, I can?t find the guide

tjones
2023-04-19 09:45
If an example would help, here?s how pact-js does the verification: https://github.com/pact-foundation/pact-js-core/blob/master/src/verifier/nativeVerifier.ts


tjones
2023-04-19 09:46
You?ll also need the ability to create matchers. I don?t believe these are documented, but a good resource for them is pact-js?s matcher code. Let me get you a link


priyaranjanmudliar
2023-04-19 09:50
I have some experience of js, let me go through this implementation then

tjones
2023-04-19 09:51
> I had to manually allow these binaries in system-preferences, and only then i was able to start up the pact-mock-provider. In short, I think you can avoid this by incorporating Pact into your erlang package (module? I don?t know what erlang calls them) instead of invoking a separate binary

tjones
2023-04-19 09:51
The Rust core will do its own spin up and teardown of the server, so you won?t need to muck about in your test harness

tjones
2023-04-19 09:52
I was involved in some (but not all) of the conversion of pact-js to the Rust core, so I should be able to answer some (but not all) of your questions

tjones
2023-04-19 09:52
(if you have them)

priyaranjanmudliar
2023-04-19 09:53
I see, thanks a lot, much appreciated. I guess my first step should be looking the js implementation and take inspiration from there

priyaranjanmudliar
2023-04-19 09:54
as it uses FFIs , which also supports message pacts

tjones
2023-04-19 09:54
I?m also working on an alternative contract testing framework, that is philosophically compatible with Pact (and definitely compatible with the Pact broker). I?m currently working on the cross-language boundary, which isn?t ready for consumption yet. But, it?s designed to be easier to create wrappers for

tjones
2023-04-19 09:54
I would start with Pact, though, as it?s ready today

tjones
2023-04-19 09:55
(and has a well established community)

tjones
2023-04-19 09:56
You can follow it here if you?re interested: https://case.contract-testing.io/docs/intro

tjones
2023-04-19 09:57
it works today in JS, but it?s very beta.

ajaydiwakar.ka
2023-04-19 10:11
has joined #general

meghaagr
2023-04-19 10:13
has joined #general

alanbos
2023-04-19 11:01
Hi - I'm looking for some advice on using pact for contracts between a _library_ and a provider; specifically whether the following approach makes sense. Suppose I've created some library components that contain in-built REST calls to a provider pacticipant. These components would then be used in multiple apps. I want to write consumer pact tests for the library itself and publish the results to the broker, which would then record the contract in the usual way. Then I assume verifying pacts in the provider would work as usual, its just more contracts tagged with a different consumer (the library). Assuming I now have an app _X_ that uses this library _L_. Normally (the non-library case) when I check whether I can deploy a component _X_ to a given environment _E_ I would use `absolute-version` to get the version _V_ of _X_ and then do something like this: ```./pact-broker can-i-deploy --to-environment=E --pacticipant=X --version=V``` However, if my consumer contracts that _X_ relies on are inside the library _L_, I assume the equivalent check would be (assuming _L_ is at versions _Lv_, and that _X_ doesn't have any consumer contracts of its own): ```./pact-broker can-i-deploy --to-environment=E --pacticipant=L --version=Lv``` To make this work, my deployment script for _X_ needs to know the "pact identity" of the library _L_ (which is not a big deal), but also needs to know the the "pact version" of _L_. Typically I have used "git version" for pact versions (i.e. something based on the branch+tag+commits_since_tag) as that unambiguously defines the code state of the pacticipant. In that setup, my deployment script just uses `npx absolute-version` to compute _V_. In the case of a library being the pacticipant, that technique isn't going to work (since the script in running in a git repo for _X_, not _L_). This would mean that _L_ would need a different pact versioning approach that didn't rely on git state (e.g. a maven version or an node package version of the library component itself). Such versions must change if the contracts change in any way; in the git versioning approach above this happens automatically, but in the maven/package versioning approach I must increment the version when I make contract-changing modifications to the library. And then ensure that new version is incorporated into my deploy script for _X_. Does that sound like the right approach, or are there better ways to approach this? tia

haroldrobson11
2023-04-19 12:33
Ah yes, the root cause was because I passed in --provider-version-tag="$CI_BRANCH" instead of --provider-version-tag="$CI_COMMIT_BRANCH"

tjones
2023-04-19 12:43
The important question here is ?is it safe to deploy service X?, - to answer that question whether or not you?re using a library is kind of a side point. What you _could_ do is distribute the Pact with the library, and then publish that artefact from the library on each consumer build - so that the library?s Pact would be associated with the consumer version. I?m not sure if you?d have to rewrite the part of the Pact file that says what the consumer name is (or whether that?s rewritten during upload).

tjones
2023-04-19 12:46
One issue with using the Pact of the library is that you?re not actually testing what the consumer is actually using - you?re now testing what the consumer _might_ use. You could avoid this by writing contract tests in each consumer (regardless of whether or not it?s using a library), but I think that?s a bit clumsy and kind of defeats the purpose of using a library in the first place.

tjones
2023-04-19 12:47
Alternatively - if you know the version of the library at the time of trying to deploy service X, you could use the https://docs.pact.io/pact_broker/recording_deployments_and_releases#recording-releases part of can-i-deploy - which is unlike `deployment` in that you can have multiple releases of that application out in one environment.

tjones
2023-04-19 12:49
It?s intended for things like mobile consumers, where you have multiple versions live at once. However, you might have to build a bit of machinery to count the number of applications using each specific version, so that you know when to `record-support-ended`

alanbos
2023-04-19 12:53
Many thanks @tjones for your thoughts; I did consider the contract test in each consumer approach but as you point out it kind of defeats the purpose of having a library and seems very brittle. I like the idea of including the pact with the library, so that each consumer can appropriate the contracts therein and claim them as its own. I'll dig into that approach a little more.

tjones
2023-04-19 12:55
You?re welcome! Let us know how you go

hcummins
2023-04-19 12:58
has joined #general

tjones
2023-04-19 12:59
Also, thanks for using `absolute-version`! Maybe I can ask you a couple questions if you don?t mind - 1) In semver, the prerelease information (between the `-` and the `+`) is supposed to define an order - to this end, I?m thinking I should move the commits since release to be after the branch name. It?s not an exact ordering, because two copies of the same branch might have the same number of (different) commits. This would of course be a breaking change. Do you think it?s an improvement? 2) I?m thinking of replacing the `SNAPSHOT` string with `DIRTY` so that it better reflects the purpose. What do you think? 3) Would a strict mode where it would fail if there was no tags found be useful to you?

michael.dasilva
2023-04-19 13:13
has joined #general

matt.fellows
2023-04-19 13:14
Hey @hcummins, I wondered at what point you might join us after all the awesome presentations - welcome!

hcummins
2023-04-19 13:15
Thanks!

matt.fellows
2023-04-19 13:15
oh it has a logo - awesome Tim!

alanbos
2023-04-19 13:16
I've not got a strong opinion on (2) or (3), assuming in the latter case the default behaviour is the same as it is now. On (1) I might be misunderstanding what you're saying; in e.g. `2.2.0-develop+2.97baa48` isn't the commits since release (`2`) already after the branch name (`develop`)? That said, from my own perspective I don't think the current format is an issue for the way we are operating with pact, so I would be wary of any changes that broke existing behaviours. On the subject of `absolute-version`, the thing I struggled with was the impact of tagging a release in git on version numbers; e.g. with the above example adding a no-change release tag of `2.2.1` to the `develop` branch means that the versions `2.2.0-develop+2.97baa48` and `2.2.1-develop` are "identical" in contract terms but it took a bit of thinking through to deal with that explicitly in build/deploy scripts.

matt.fellows
2023-04-19 13:17
Thanks for those tips Tim. @priyaranjanmudliar - we are about to kickoff some work around maintainer experience. The key artifacts to emerge from this will be a guide for maintainers, and a BDD suite to use as a basis to test your implementation. In lieu of that, your best bet is to follow a previous implementation (as Tim has suggested) and jump in #libpact_ffi-users - we can help. There are a few others on this journey, such as @tien.xuan.vo working on PHP. We?re here to help, it might be a little bumpy given the lack of good maintainer docs. But you?re not the first to do it

tjones
2023-04-19 13:31
for 1 - yes, it is after, but _technically_ it should be `2.0.0-develop.2+97baa48`, because the prerelease part is supposed to define an ordering, but the build metadata after `+` doesn?t. I do agree, though. I don?t like the idea of mucking with the format too much. > the impact of tagging a release in git on version numbers Ah yeah. That?s something I?ve been meaning to call out in the documentation. It?s absolute in that each version number identifies (in a human readable way) one specific unique place in the repository history. But one specific unique place in the history might have more than one absolute-version.

tjones
2023-04-19 13:31
That subtlety wasn?t obvious to me when I wrote it, either :laughing:

tjones
2023-04-19 13:35
> are ?identical? in contract terms but it took a bit of thinking through to deal with that explicitly in build/deploy scripts. There?s a neat Broker subtlety too - if you upload identical contracts, it doesn?t need to re-verify them. But you?re right in that if you go: ? Publish contract ? Bump version ? Can-i-deploy Then the broker will say it doesn?t know that version :confused:

alanbos
2023-04-19 13:38
Yeah let's just say it has been a "learning experience" dealing with the fallout from tagging release versions :slightly_smiling_face: On the other point, if I understand correctly that the format difference is just between using `.` and `+` in the version string at that point, I would avoid breaking it if it doesn't need fixing. Or, add a new optional switch to `absolute-version` which can force the new format if there are important justifications for it?

tjones
2023-04-19 13:42
I?m keen to avoid increasing the API surface to support lots of options (I?m even nervous about a `--strict` option). The use case for the `.` to `+` change is if anyone is using the between-release versions to (slightly inaccurately) programatically reason about which version is more recent. One advantage of leaving it like it is is that people won?t be encouraged to do that :joy: Thanks for the chat. I reckon I?ll leave it as-is.

tjones
2023-04-19 13:42
I?ll make a note to fix up the documentation, though

ivana.lazic
2023-04-19 14:04
has joined #general

vakong13
2023-04-19 16:15
has joined #general

cars2991
2023-04-19 18:36
Is the can I deploy tool available with the OSS version?

matt.fellows
2023-04-19 21:16
Yep!

ravinder.kadiyan
2023-04-20 09:56
has joined #general

yousafn
2023-04-20 11:12
woop woop! pact erlang sound very cool! no overly familiar with erlang but you might want to take a look at https://github.com/elitau/pact_elixir

yousafn
2023-04-20 11:14
i haven?t used it or studied the code so your mileage might vary. we?ve had a fair few over the last couple of weeks asking about the ffi implementation, details on how to use it as a consumer and some reference documentation. the code for me has always been the best source of truth, but appreciate its hard if you don?t know where to look. i?m going to look at setting up an bit of an intro / workshop and tutorial, can i assume that you would be interested? cc: @adam.cox i think you asked about this re pact-cplus-plus

adam.cox
2023-04-20 13:05
@yousafn yes a few people in my team have been using the ffi in C++ to create sync message pacts. intro / workshop and tutorial with some reference documentation would be much appreciated on our side I think. We have managed to put something together by reading the source code but it has been a bit trial and error

alfredo.castro
2023-04-20 13:27
has joined #general

matt.fellows
2023-04-20 13:57
Let?s make it happen. Great idea Yousaf

priyaranjanmudliar
2023-04-20 13:59
I would be very much interested in this if it happens !!

priyaranjanmudliar
2023-04-20 14:01
But before that I would want to go through the JS implementation myself, so that i have context before any such session

priyaranjanmudliar
2023-04-20 14:04
@yousafn Any intro/workshop/tutorial for the ffi implementation would be much appreciated

yousafn
2023-04-20 15:35
solid, will see what we can rustle up. i?ll be sure to cover from the ground up, so you can come in relatively fresh, and we can build it up over a few sessions

yousafn
2023-04-20 15:37
i?m out at the moment but will put together some initial pointers on a docs page which shows where the reference code ( the pact ffi library lives ), which platforms we aim to support, how we can test it and which implementations currently use it, and where exactly in the code is it done. it will help us identify gaps between implementations, and hopefully feed into the cores design decisions as anything emergent arises

yousafn
2023-04-20 15:43
some architecture details on the ffi https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_ffi/ARCHITECTURE.md examples of loading the shared library in various languages https://github.com/YOU54F/hello_ffi the install.md has instructions on how to run on various platforms some raw examples in python and php which call the ffi methods directly https://github.com/pact-foundation/pact-reference/pull/269/files these are normally wrapped in a dsl which is idiomatic for the client language, but ultimately should expose the same feature set across all the client libs. there are some blurred lines as some functionality a ) needs to reside in the client libs to handle talking to the ffi and the user as an intermediary b ) some func is in the client only, and not exposed in the core, which can lead to apparent feature disparity between languages.

lluis.casals
2023-04-20 17:07
has joined #general

paul.caplan
2023-04-20 18:07
Prove me wrong: Pact (or any form of consumer-driven contract testing) provides little to no value for testing GraphQL APIs. According to https://docs.pact.io/faq/convinceme, ?OpenAPI can be used as a contract testing framework in a similar way to Pact?. I would make the argument that the same applies for GraphQL. In both cases, the APIs have a schema with strongly typed definition of field names, types, etc. Testing guidelines on https://docs.pact.io/consumer recommend loose matching (field names and data types only). The example on https://pactflow.io/blog/contract-testing-a-graphql-api/ follows this approach. Assuming I have a way to ensure that there are *no breaking changes* to the provider?s schema (e.g. by static analysis), *what value at all is this contract test providing?* Again, please prove me wrong. My organization has all the problems that contract testing purports to solve. I want to make a case for adopting it. But so far I am disappointingly unable to. If I were to follow recommended practices, it would require a LOT of development overhead to implement consumer driven contract tests that provide little to no value given the existence of a strongly typed API with prevention of breaking changes already in place. The *only* case I can see right now for consumer driven contract tests providing value is if we can use them in place of functional / integration tests for our front end layer. Right now these are heavily reliant on VCR cassettes but are not providing value because the cassettes are brittle and not frequently re-recorded. If we could use contracts in place as the mocking layer, that would ensure that the mocking layer of the consumer integration tests is in sync with the actual APIs. However, that approach is *strongly discouraged* in https://docs.pact.io/consumer, especially in the video on that page; to quote presenter: ?the teams that have done it have really regretted it?.

darrenoc3
2023-04-20 21:33
Is there a way to ensure that when a consumer's behaviour is modified, the pact gets updated? We are introducing contract testing, but I'm worried about the case where a developer changes the consumer's real interactions with the provider but forgets to update the contract. So the functionality could be broken, but the contract test would still pass. I haven't seen this risk mentioned anywhere, so maybe I'm missing something

cars2991
2023-04-20 21:44
Pact broker? I think isnt it the purpose of pact broker to manage contracts?

bas
2023-04-20 21:49
That?s why you need tests that verify the implementation of your consumer AND drive the generation of your contracts. It?s still not 100% fool-proof but at least you?d be consciously working on / thinking about the expectations you?ve got about provider behaviour.

darrenoc3
2023-04-20 21:59
@bas I agree, but just having functional tests doesn't ensure that when the functional test is modified in a way that makes it incompatible with the provider, the contract test is also modified. They can fall out of sync if the developer isn't aware of, or forgets the need to also modify the contract test. This can obviously have disastrous consequences as the pact broker would release a version of the consumer thats incompatible with the provider. Right?

matt.fellows
2023-04-20 22:59
@myao might have something to add, do I recall you testing a graphql service recently-ish?

matt.fellows
2023-04-20 23:00
The other point to make is that static analysis is a from of schema testing, and schemas are not contracts https://pactflow.io/blog/schemas-are-not-contracts/amp/


dprawatya
2023-04-21 01:11
has joined #general

mbutt
2023-04-21 01:11
has joined #general

bas
2023-04-21 04:46
You?re right, that?s exactly why I said it wasn?t fool-proof :) Even with contract testing, there are no guarantees. We might get even closer when there would be some kind of mutation-testing-for-contract-tests kind of thing but that doesn?t exist as far as I know.. And even then that probably wouldn?t prevent all the failures

priyaranjanmudliar
2023-04-21 06:26
I think that?s why in functional tests/ unit tests, we should mock things as less as possible and actually execute the function/method that calls the api during the test execution. But yeah again, it can?t be forced and not fool proof

matt.fellows
2023-04-21 07:58
> We might get even closer when there would be some kind of mutation-testing-for-contract-tests kind of thing but that doesn?t exist as far as I know Oh, I like the sound of that!

matt.fellows
2023-04-21 08:01
The other approach I?d like to explore is instrumentation, to discover discrepancies between tests (expected behaviour) and actual (possibly expected, maybe unexpected behaviour)

matt.fellows
2023-04-21 08:01
Another approach to ensure consistency, is to re-use the same test data fixtures in your contract tests and other layers of tests. This way, you can reduce potential drift

matt.fellows
2023-04-21 08:02
the other rule of thumb of course, is to have a corresponding contract test wherever you stub/mock out your service layer in other forms of testing

tjones
2023-04-21 08:17
> Prove me wrong: Pact (or any form of consumer-driven contract testing) provides little to no value for testing GraphQL APIs. Why?

tjones
2023-04-21 08:18
We?ve written and spoken about this lots.

tjones
2023-04-21 08:18
If you don?t find it compelling, don?t use it.


tjones
2023-04-21 08:19
tl;dr: Yes, contract tests provide value on top of graphql. No, you don?t have to use it.

tjones
2023-04-21 08:20
> Assuming I have a way to ensure that there are no breaking changes to the provider?s schema (e.g. by static analysis) As far as I know, there are no static analysis tools that can do this.

tjones
2023-04-21 08:21
If you think there are, I suspect that you don?t understand the value of a contract test - which goes beyond the schema.

tjones
2023-04-21 08:21
From my link above: > for example, gRPC prevents syntactic breaking changes by ensuring that all fields have default values. However, this is a bit like saying ?all our endpoints use json, so we can?t send incompatible responses?. Just because the payload can be parsed by the consumer doesn?t mean it has meaning to the consumer.

tjones
2023-04-21 08:26
Perhaps I?m misinterpreting the tone you meant to convey in your question, but no one is telling you you need to use contract testing. If you don?t like it or don?t see why it?s valuable: 1) There are a lot of resources that explain why contract testing will help you. 2) You don?t have to use it. I don?t have to prove anything to you.

tjones
2023-04-21 08:27
Really, it comes down to - contract testing will let you confidently deploy your API on a friday from the pub. If you have an alternative implementation that gives you the same confidence, that?s fine too. If your alternative suits you and your team better, you should use it.

myao
2023-04-21 08:41
We used GraphQL and graphql-codegen to generate the ts-code via the remote schema (we targeted staging API). We've hooked it with husky and found it saved us time to generate code we need in our desired format before we push the changes. Well that is just the GraphQL part, it doesn't provide enough confidence running things on the CI environment as the integrations can still break in any environment when there's a breaking change on the provider side, which are not reflected immediately when we generated the code via the deployed version on staging (which is old). And it happened a few times when the app grows, it got worse. Pactflow came to help with the additional step to check the above before any deployment happens on every environment - what @tjones said, yes you can deploy on Friday with the beer.

darrenoc3
2023-04-21 12:00
Thanks Matt, very helpful. Another approach I had in mind was to try and combine the consumer functional tests with the consumer contract test. Tell me if this sounds crazy or not: ? Modify functional test to replace Mockito mock of provider with Pact mockServer instead ? Annotate functional test with @PactTestFor Is there any merit to this approach, or is it infeasible or otherwise a bad idea to mix contract and functional testing in this way? I guess it's similar to your idea of sharing test fixtures between the two, but trying to go one step further to ensure they're in-step. I'm still new to contract testing, so there may be obvious reasons this can't work that I'm not seeing yet

marcia.meira
2023-04-21 12:43
has joined #general

raubreysmith
2023-04-21 12:46
has joined #general

haroldrobson11
2023-04-21 13:44
Hi, if I use the contract_requiring_verification_published webhook lets say I have the following scenario: 1. consumer contract asks for fields that dont yet exist in provider 2. contract is published 3. webhook verifies it 4. verification fails 5. when we run the consumer pipeline again, the contract has not changed, so it will never be verified again ? 6. provider implements the new field how does the contract get re verified for the new provider version? I'm sorry if this is a stupid question. I don't want the webhook to simply trigger every time a contract is published whether it changes or not because that would be excessive. I guess I am wrong about step 5, it should be verified again when a new version of the provider is built, but if I don't see this behaviour, what has gone wrong?

paul.caplan
2023-04-21 14:05
The schema vs contract articles are exactly the explanations I was looking for, thank you!! I was not trying to make a case against Pact, I was trying to understand whether & why it provides value in my case. Sorry if tone did not properly convey that.

ksenia.vasileva
2023-04-21 15:02
has joined #general

jack.amico
2023-04-21 15:48
has joined #general

tanyaryzhova93
2023-04-21 16:18
Hi Team! Could you please let me know if `--state-change-url` of the https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli accepts several urls? For example, if there are two provider states endpoints as `/app_one/pact/provider_states` and `/app_two/pact/provider_states`

cheng.ngai
2023-04-22 00:55
has joined #general

matt.fellows
2023-04-22 01:15
It does not. How would the verifier know to send the request to one or the other URL?

matt.fellows
2023-04-22 01:15
What's the use case?

tanyaryzhova93
2023-04-22 01:19
The case is that our microservice talks to two services which live in monolith. And I added provider states. endpoint for each mono app because it will be easy when we start tearing apart the monolith.

tanyaryzhova93
2023-04-22 01:19
and of course I would like to add the verification with monolith to the ci/cd pipeline

matt.fellows
2023-04-22 01:20
That's what a regular provider build is for. You would setup the selectors to verify the usual pacts. If the pact in question is a feature branch, you would use WIP pacts to pull in new contracts to check

matt.fellows
2023-04-22 01:20
See the cicd workshop in howtolearn

2023-04-22 01:20
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

tanyaryzhova93
2023-04-22 01:20
and I was wondering if I can put these two verifications (microservice <> mono 1 & microservice <> mono 2) to one ci/cd job

tanyaryzhova93
2023-04-22 01:24
of course I can do something like: ```script: - >- pact-verifier --broker-url="$PACTFLOW_URL" --token="$TOKEN" --provider-name="monolith" ----state-change-url=http://mono_app_one/pact/provider_states --publish - >- pact-verifier --broker-url="$PACTFLOW_URL" --token="$TOKEN" --provider-name="monolith" ----state-change-url=http://mono_app_two/pact/provider_states --publish``` but it doesn?t look nice and it will grow..:neutral_face:

tanyaryzhova93
2023-04-22 01:27
but now I think I can use `matrix` in gitLab, and will be something like: ```parallel: matrix: - PATH: [mono_app_one, mono_app_two] script: - >- pact-verifier --broker-url="$PACTFLOW_URL" --token="$TOKEN" --provider-name="monolith" ----state-change-url=http://${PATH}/pact/provider_states --publish ``` maybe it will work. If it works, it will create 2 parallel jobs with different provider states endpoints

matt.fellows
2023-04-22 01:33
Are you testing against a live microservice connected to the monolith?

tanyaryzhova93
2023-04-22 01:34
yes, monolith provides data to microservice

matt.fellows
2023-04-22 01:36
You should stub that out in your pact test and then have separate pact tests from each of your microservices to each monoloth

matt.fellows
2023-04-22 01:36
You shouldn't do pact testing against a live environment ideally, especially one with live dependencies

tanyaryzhova93
2023-04-22 01:40
> You should stub that out in your pact test and then have separate pact tests from each of your microservices to each monoloth yes, it?s implemented like this. I am wondering if I can put different provider states endpoints into one ci/cd job. I?ll try implement it with matrix, let?s see if it works

matt.fellows
2023-04-22 02:31
Sweet, glad it helped! I did a presentation on a related topic last year albeit in the end I didn't call out graphql


tjones
2023-04-22 03:41
I?m with Matt in that this doesn?t sound like the appropriate approach to this problem- but if you are really faced with it, I would put a prefix on the state string, and do the separation inside the controller for the state change endpoint

aforeman
2023-04-24 00:48
*Based in Melbourne* :flag-au:*? Join upcoming in person event with the Pact/PactFlow crew at DiUS on Thurs 4 May at 4:30pm.* Expert speakers will discuss the benefits of automated testing and deployment strategies, including CI/CD practices to build the confidence to execute. Plus, there will be beer, pizza and swag to be won and a bunch of your Aussie-based Pact/PactFlow team will be there too (@ilia@matt.fellows! :point_right:https://smartbear.com/lp/events/smartbear-dius-event/ :point_left:

aditya.kashyap
2023-04-24 05:13
has joined #general

iustina.gavrila
2023-04-24 09:15
has joined #general

juliemarierosok
2023-04-24 13:29
Hi, I already wrote in the pact-jvm channel, but I guess it's also a general question, so I'm trying here as well. I am looking for a way to specify that we expect either attribute A to be present, OR attribute B. Is there a way to specify this with pact? I have tried with the combine : "OR", but I suspect this is rather for specifying multiple rules for one attribute... Would appreciate any help!

haroldrobson11
2023-04-24 13:31
Thanks, do you know how the ```${pactbroker.providerVersionBranch}``` var is set? I am using this one for the verification that happens when the Pact file changes. The version of the provider in UAT would be on the develop branch and the version in prod would be on the master branch but how can my Pact broker know this?

haroldrobson11
2023-04-24 13:39
I saw this but I am not sure this is what I want because the verify step is where I want to find the branch not set it ```pact-provider-verifier \ --provider "Example API" \ --provider-app-version $GIT_COMMIT \ --provider-version-branch ```

haroldrobson11
2023-04-24 13:52
I believe this is what I needed ```docker run --net=host -e VERBOSE='true' -e PACT_DO_NOT_TRACK=true pactfoundation/pact-cli:latest pact-broker create-or-update-pacticipant --broker-base-url=https://pact.dev.ieu.intelematics.club/ --name=battery-api --main-branch=master```

yousafn
2023-04-24 14:12
use provider states to assert each state, if you had an or, your provider may only ever provide you one of the values and pass the verification successfully, never returning the or'd value in real life

yousafn
2023-04-24 14:37
> Is there a way to ensure that when a consumer's behaviour is modified, the pact gets updated? > We are introducing contract testing, but I'm worried about the case where a developer changes the consumer's real interactions with the provider but forgets to update the contract. Automation can't replace good engineering practises, nor good review practises. It is possible to suffer from consumer drift, whereby the consumer drift drifts in some way from the underlying code, usually this isn't the case as they are an output of your unit test, but it all too easy to encode in extra fields into the contract which aren't relevant for a particular consumer test. By avoiding abstraction layers, and testing closest to the collaborating code, you can make it easier to detect these discrepancies. As Matt said, these contracts can then be reused in other areas of your testing, knowing that they are a good source of truth, although not infallible. Still better than no mocking (you can test in insolation) and better than full mocking (you share some idea of your expectations with others) Depending on your ecosystem and team make-up, teams can share factories/fixtures https://docs.pact.io/consumer#in-dynamic-languages-ensure-the-models-you-use-in-other-tests-could-actually-be-created-from-the-responses-you-expect we used similar approaches in typescript, through shared types and a test data service

juliemarierosok
2023-04-24 14:37
Thanks for the suggestion. The idea would be that I define the message twice (once with attribute B set, and once with attribute A), and provide two different provider states (with the .given method of the builder? This also would work with asynchronous messages?

yousafn
2023-04-24 14:39
> but I'm worried about the case where a developer changes the consumer's real interactions with the provider but forgets to update the contract. The contract is generated as part of a unit test run, therefore if the underlying behaviour of the consumer changes, and the outward behaviour of the SUT changes, there would need to be changes in the developers tests for it to pass, or they would need to update the data in the pact expectations, in order to setup their mock provider in the correct state. if they can change the underlying behaviour of their code, without changing the expectations in their test, they probably aren't testing their actual code.

yousafn
2023-04-24 14:45
> We might get even closer when there would be some kind of mutation-testing-for-contract-tests kind of thing but that doesn?t exist as far as I know I like the idea of being able to use a pact mock provider, on the consumer side, to act as my http mock and test cases that I wouldn't necessarily want to share with a provider, maybe a flag, write to pact. Or here is my happy request, send some garbage and see how my collaborater code behaves On the provider side, as a pact verification provides a good amount of test coverage of the SUT, it could be nice to create a contract to functionally test your provider (with a use case that could represent how your consumers could use the api) utilising pact to act as the mock consumer. That could serve as documentation for potential consumers, and there could be analysis done to see divergence from real consumers, and the providers own view of a consumer, which may highlight new emergent use cases that the providing team didn't expect (and now want to cater for)

darrenoc3
2023-04-24 15:53
@yousafn I really appreciate you engaging with my question in so much detail, I think you've helped me identify a fundamental misunderstanding I may have about where Pact sits in the test pyramid. My testing for my service `Foo` currently looks like: 1. Functional tests for `Foo`: verify that when my application runs, it takes an input and makes the expected API calls to two downstream services (one we control called `Bar`, and another that is a public cloud API) 2. Consumer test for `Foo`: invokes the `BarClient` of `Foo` directly to generate the contract using provided example requests 3. Provider test for `Bar`: verifies the contract from step 2 2 isn't really a test in this setup, it's more of a scaffold for generating the contract so that it can be used for 3. I think what you're saying is that 1 and 2 should be combined right? I.e. Pact annotations should be added to the existing functional tests, rather than writing new tests purely for the sake of generating the Pact as I've done.


tjones
2023-04-24 17:01
You write two examples - one with the field, and one without. The reason for this is that a test which allows optional fields would still pass even if the field was never present. You wouldn?t be sure that your provider could ever generate that missing field.

vandana.aveva
2023-04-24 18:24
has joined #general

vandana.aveva
2023-04-24 18:26
Hi, I'm trying PactFlow on my local machine. But I'm not able publish my contract. The publish command: npm run pact:publish, throws error '.' is not recognized as an internal or external command

matt.fellows
2023-04-24 22:39
See this article for more howtooptional


matt.fellows
2023-04-24 22:40
Can you please provide a little more info? It sounds like the way you're invoking the command on windows is wrong

lucas
2023-04-25 00:01
has joined #general

vandana.aveva
2023-04-25 01:22
So I tried opening the solution in vs code. And I ran the command in the terminal of vs code.

yousafn
2023-04-25 10:31
Please provide as much detail as you can https://docs.pact.io/help/how_to_ask_for_help for alternative ways of publishing, you can use our pact-cli tools https://docs.pact.io/pact_broker/client_cli/readme

szydlakus
2023-04-25 11:19
has joined #general

sarah.hutchins
2023-04-25 12:48
has joined #general

kristoffer
2023-04-25 13:31
has joined #general

jack.drake
2023-04-25 15:40
has joined #general

vandana.aveva
2023-04-25 15:52
I've cloned the git hub repo for 5-minute guide on my local. I've created a pactflow broker using the plug and play broker option provided in that guide. I'm running these steps in the terminal of visual studio code: 1. npm run test:consumer (it worked great) 2. npm run pact:publish This throws an error '.' is not recognized as an internal or external command I hope this helps. Let me know if any other information is needed.

mathivanan.kailasam
2023-04-25 16:15
has joined #general

seb983
2023-04-25 17:16
At a talk I gave last week, someone asked a question which I didn?t feel confident to answer: ?How would you handle a situation where the consumer, C, called service P1 and then passed the results onto service P2? C only cares about the result of the call to P2.? I can see how to contract test P1, but I?m not sure how to contract test the transitive nature of the relationship. I?d appreciate any perspective you might have.

yousafn
2023-04-25 17:21
You can use the docker image https://docs.pact.io/pact_broker/client_cli/readme#publish or via the pact ruby standalone https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.92.0 which offers a windows executable or use git bash, which provides the ability to understand linux commands https://gitforwindows.org/

hornc
2023-04-25 18:00
has joined #general

hulia.suliman
2023-04-25 18:07
has joined #general

tjones
2023-04-26 03:48
You?d typically do this with two interactions: C -> P1 C -> P2 You would make sure the expectations you?re setting up for P1 and P2 match

juliemarierosok
2023-04-26 09:35
Hi again everyone. I asked a question a couple of days ago, and I am almost done implementing the tests with different provider states as suggested by you! However, if I could get some more support I would be very thankful. I am currently adding datetime validation for my pact, but for some reason pact seems to add 2 hours to the example I provide: ```root.datetime("lastModifiedDate", DATETIME_FORMAT, DateUtil.toInstantFromDatetime("2022-06-27T12:30:10.767Z"))``` JSON output from this is 2022-06-27T14:30:10.767Z. Can someone explain to me how I can fix this?

mwilso29
2023-04-26 10:36
Hi all, random question. When the webhook exists in both consumer and provider pipeline, how do you prevent an infinite loop of calling the webhook when the other pipeline is ran? one method I thought of was using a separate branch that does not include the webhook on the 'called' pipeline. However if its calling a separate branch it will be generating a contract that is not on master which may be old and not current. What is the best practice for this scenario?

tjones
2023-04-26 10:42
Why would there be an infinite loop? Consumer publishes a contract (triggering provider verification) Provider verification runs ?. triggering nothing

tjones
2023-04-26 10:43
Or, if you want to trigger can-i-deploy, it would look like: Consumer publishes a contract (triggering provider verification) Provider verification runs ?. triggering verification published Consumer deploy runs, triggering nothing

mwilso29
2023-04-26 10:44
So the webhook to call the consumer should not be on the provider? What if you implement a change on the provider side? Would you look to compare what is uploaded to the broker for the consumer contract?


tjones
2023-04-26 10:45
If you implement a change on the provider side, you already have the consumer contract

tjones
2023-04-26 10:45
you don?t need a new contract


tjones
2023-04-26 10:45
The diagrams here might help

mwilso29
2023-04-26 10:45
Ok that makes sense

tjones
2023-04-26 10:46
When the provider runs the verification, it asks the broker what the relevant contract(s) are

tjones
2023-04-26 10:46
(I think maybe the webhooks get told which specific contract to pull - I don?t actually know, I?ve never used them)

mwilso29
2023-04-26 10:47
Yeah that makes sense thanks

tjones
2023-04-26 10:48
You?re welcome. I?d like to diagram this better, but it?s kinda hard to find a diagram that works for all the different CI practices that people already have

mwilso29
2023-04-26 10:51
The most common use case for webhooks is to trigger a provider build every time a pact changes, and to trigger a consumer build every time a verification is published. So here it mentions triggering the consumer build from a verification being published i.e. the provider has changed. So should the webhook only exist from one perspective and not both?

yousafn
2023-04-26 10:51
you use webhooks to trigger provider verification tasks based on pact url, when a consumer contract changes

tjones
2023-04-26 10:52
They?re different webhooks. Because the contract is written by the consumer, you might want to kick off the provider build (to verify the consumer?s contract). At this point you probably can?t deploy (if the contract is new). When the contract is verified, you might want to kick off the consumer deploy.

yousafn
2023-04-26 10:52
you run a verification task based on consumer version selectors when the provider changes (or doesn't change, just on commit) - this pulls back any contracts matching the selectors, we recommed deployedOrReleased true and matchingBranch true

yousafn
2023-04-26 10:53
> trigger a consumer build every time a verification is published. you could trigger a consumer can-i-deploy after a verification, return a status check to github, or slack

yousafn
2023-04-26 10:53
provider verification result wouldn't trigger another consumer build of publishing pacts (even if it did, it would then be verified by the provider, so a new webhook wouldn't be triggered)

yousafn
2023-04-26 10:55
> When the webhook exists in both consumer and provider pipeline The same webhook wont exist in both (as a trigger) , consumer event triggers a webhook, which in turn triggers the provider verification. if you are talking about different webhooks you should be more specific in your question :)

yousafn
2023-04-26 10:56
> (I think maybe the webhooks get told which specific contract to pull - I don?t actually know, I?ve never used them) They do, they provide a pact url of the pact to be verified, if you use the new contract_requireing_verification_published event/webhook, then the provider side also gets a webhook fired for any deployed or released versions of the provider plus the head of the main branch. previously webhook `contract_content_changed` would only trigger against the head of master


tjones
2023-04-26 10:59
> and to trigger a consumer build every time a verification is published. ^ I think this is misleading. It should say ?trigger a potential consumer deploy every time?.? I see why you thought there was a circular dependency :grimacing:

markus.nakhlah
2023-04-26 13:44
has joined #general

jean-francois.renaud
2023-04-26 21:09
has joined #general

jakazzy
2023-04-27 06:16
has joined #general

rahulpandey8920
2023-04-27 10:14
Hello! Has anyone tried contract testing between micro frontends ?

matt.fellows
2023-04-27 11:42
OK I read this whole thread, and was confused - but this exact point is the problem! I personally don?t like that framing, and wouldn?t recommend it myself. I personally wouldn?t trigger any consumer build related actions from webhooks. I think you?re better off publishing verification events to tools like Github for status checks to unblock PRs to say the consumer build is ?mergeable? or ?deployable?


matt.fellows
2023-04-27 11:55
A similar question was asked here before: https://github.com/pact-foundation/pact-js/discussions/1075

matt.fellows
2023-04-27 11:56
Hello!

matt.fellows
2023-04-27 11:57
Looks like a JVM question so might be best asking in #pact-jvm. What?s the DATETIME_FORMAT? Is it possible that?s playing a part here? Strange!

alfredo.castro
2023-04-27 15:22
Hello, is there any documentation that explains Pact in the context of a BFF or an application that is a consumer and a provider at the same time?.

matt.fellows
2023-04-27 22:56
It?s because https://github.com/pact-foundation/pact-5-minute-getting-started-guide/blob/919519a5faafd49adb37cfcb2b9618f82ce50dbb/package.json#L20 uses a shell script, and needs a bash-like environment and git installed. Hopefully Yousaf?s suggestion help

matt.fellows
2023-04-27 22:56
There is really nothing to be explained. The BFF Is a provider for a consumer and it is a consumer of other apps. It should verify any consumers, and publish pacts for any of its providers. Is there something in particular that you?re concerned/want to know about?

matt.fellows
2023-04-27 23:03
> var is set? I am using this one for the verification that happens when the Pact file changes. The version of the provider in UAT would be on the develop branch and the version in prod would be on the master branch but how can my Pact broker know this? It knows this, because you use your provider should be https://docs.pact.io/pact_broker/recording_deployments_and_releases to the environments it is deployed to

matt.fellows
2023-04-27 23:03
The webhook event knows this, and triggers builds for each of the deployed versions of your app, and also the main branch.


lewis.prescott079
2023-04-28 07:09
Next episode has just dropped! Graphql and Web3. https://www.pactman.co.uk/contract-testing-podcast

matt.fellows
2023-04-28 07:11
If only you posted this an hour ago, I would have listened at the gym :stuck_out_tongue: Great to see the series kicking off again Lewis

tjones
2023-04-28 07:35
Thanks for sharing! I?ll definitely check it out

matt.fellows
2023-04-28 07:46
I reckon Lewis would love to have you on the podcast btw, maybe worth talking about Case and "team contract testing"?

tjones
2023-04-28 07:47
Definitely keen, would be a great thing to do once I?ve got a first release going

juliemarierosok
2023-04-28 10:08
Hi Matt. DATETIME_FORMAT is "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", I don't think this is relevant though. The DateUtil method toInstantFromDatetime is delivering this date in this format, in UTC. However Pact is somehow using the local time, instead of UTC. I was able to get it to work now by setting my system time to UTC with the runtime argument -Duser.timezone="UTC". I would however prefer if I could tell Pact which timezone to use. Is this possible? Edit: Also posted in #pact-jvm

matt.fellows
2023-04-28 11:34
Thanks!

matt.fellows
2023-04-28 11:35
The core maintainer of JVM is on PTO at the moment, so might be worth a follow up Tuesday next week once he?s landed back here.

matt.fellows
2023-04-28 11:35
That?s an interesting insight though, perhaps it?s something Pact can?t control and is a Java system thing. Not sure

juliemarierosok
2023-04-28 12:26
Alright, would be happy to get some more insights as well. I'll wait and see if some more answers come next week then :)

alfredo.castro
2023-04-28 13:08
Hello Matt!, I just wanted to be sure until this point I just followed examples with a single consumer and provider. If I added a bff in the middle then, the consumer will have it's pact with the BFF and the BFF will have it's own pact with the provider? Apart from that, is there any consideration that I should have for implementing Pact in my Pipeline in the context of 3 participants? (Consumer, BFF, Provider)

srinivas.nali
2023-04-28 14:27
has joined #general

dmitriy.tarasevich
2023-04-28 16:00
has joined #general

jigish.mehta
2023-04-28 16:00
has joined #general

juan.felix
2023-04-28 16:01
has joined #general

himesj
2023-04-28 17:25
has joined #general

itsforbabu
2023-04-29 14:25
has joined #general

tea.trader168
2023-04-30 02:04
has joined #general

matt.fellows
2023-04-30 23:31
That?s right!

lori.maurais
2023-05-01 15:27
has joined #general

damola.thompson
2023-05-02 07:26
has joined #general

ivan.v.kurlovich
2023-05-02 13:01
has joined #general

ckulkarni
2023-05-02 14:22
has joined #general

aurel.pintea
2023-05-02 14:55
has joined #general

ariveros142
2023-05-02 20:03
has joined #general

cody.jenkins
2023-05-03 04:48
has joined #general

ashish.tilara
2023-05-03 06:08
has joined #general

alfred.brose00
2023-05-03 08:17
has joined #general

dibya.dhar
2023-05-03 09:04
has joined #general

ronnie.kilsbo
2023-05-03 09:28
has joined #general

caitriona.gallagher
2023-05-03 15:18
has joined #general

majhwar.mragni
2023-05-03 17:03
has joined #general

michael.fenstermaker
2023-05-03 20:56
has joined #general

man.tse
2023-05-03 20:58
has joined #general

tristan
2023-05-04 03:27
has joined #general

haiyang.huang
2023-05-04 09:23
Hi everyone, quick question, does pact consumer/provider version have a character limit?

michal.kopriva
2023-05-04 11:03
has joined #general

hulia.suliman
2023-05-04 17:33
Hi, pact-foundation team, I recently joined the community and need some :blob_help: I see in the https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v2.0.0 that breaking changes are mentioned for naming conventions and I can confirm that the old consumer tests that used to work with previous versions, are not passing any more with the latest version 2.0.0. 1. I would like to understand why the naming conventions change impacts the test execution 2. there is a way to specify the version for the https://github.com/pact-foundation/homebrew-pact-ruby-standalone install command line? currently, the latest version is pulled. there is any other solution/suggestion to fix this? :thankyou:

yousafn
2023-05-04 17:45
Hey @hulia.suliman Please can you raise the exact errors you are seeing, as an issue on the pact-ruby-standalone repository, There is a link to a pull request on the release notes, that show the extent of the changes (major bump in ruby runtime from 2.4 -> 3.2 ) and the build system that packages it, hence the major version bump

yousafn
2023-05-04 17:47
2. there is a way to specify the version for the https://github.com/pact-foundation/homebrew-pact-ruby-standalone install command line? currently, the latest version is pulled. there is any other solution/suggestion to fix this? no there isn't it is a limitation with homebrew, you need to have different versions formulas and install different versions something like https://github.com/isen-ng/homebrew-dotnet-sdk-versions obviously that isn't helpful to you now if you check the previous releases, release notes, you will see instructions on how to install that fixed version :+1:

yousafn
2023-05-04 17:54
assuming your are on osx ```export PACKAGE_VERSION=1.92.0 curl -LO https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v$PACKAGE_VERSION/pact-$PACKAGE_VERSION-osx.tar.gz tar xzf pact-$PACKAGE_VERSION-osx.tar.gz cd pact/bin ./pact-mock-service --help start```

hulia.suliman
2023-05-04 18:00
@yousafn thank you, we will try to figure it out, and come back if needed.

yousafn
2023-05-04 18:04
If you could just try and let us know by raising an issue, with at least the operating system, how you are using it, which tests are failing and what error messages you are seeing, that would be helpful, we have CI runs across several architectures at the moment that are saying it is working. I helped participate in the upgrade from 2.4 from 3.2 of Ruby and have an open pul l request on the build system that supports it, so it would be beneficial to share, so we can fix forward. For homebrew you could fork the repo, and revert the latest change installing it on any machine with ```brew tap yourgithubname/pact-ruby-standalone brew install pact-ruby-standalone``` You might need to ```brew untap pact-foundation/pact-ruby-standalone```

hulia.suliman
2023-05-04 18:22
now, we have encountered another issue with v1.91.0 - it is not working on the new m1 mac. are u aware of a possible issue?

yousafn
2023-05-04 18:22
yes you need rosetta on an non m1 mac for versions less than 2.0.0

yousafn
2023-05-04 18:24
OSX ARM (M1/M2) Machines will require Rosetta tools, as the Ruby binaries as currently built for x86_64. If you don't already have it installed, you can use the following command ```sudo softwareupdate --install-rosetta --agree-to-license```

yousafn
2023-05-04 18:24
it was in the readme for homebrew prior to having this PR merged https://github.com/pact-foundation/homebrew-pact-ruby-standalone/pull/92/files

yousafn
2023-05-04 18:24
hope that helps for the time being :slightly_smiling_face:

yousafn
2023-05-04 18:26
could I ask how you are using the standalone in your tests? traditionally it would be used by client libraries, and anyone using the standalone tools have usually transitioned over to the rust based tools verifier https://docs.pact.io/implementation_guides/cli#native-binary-new mock server https://docs.pact.io/implementation_guides/rust/pact_mock_server_cli

hulia.suliman
2023-05-04 18:37
I know, I am from crowdstrike, and we use the pact-go and as far as I can see, there is no stable version that implements the rust core

yousafn
2023-05-04 18:38
pact-go hasn't been updated to use the latest version


yousafn
2023-05-04 18:38
it's pinned to use less than 2.0.0

yousafn
2023-05-04 18:39
why or how have you installed that version?

yousafn
2023-05-04 18:39
in your pact-go tests? I'm not super familiar with v1 pact-go and how it downloads the right package, but that gives me more to go on :slightly_smiling_face:

hulia.suliman
2023-05-04 18:40
it was installed by a peer on his local machine

hulia.suliman
2023-05-04 18:40
it is not used in the ci pipeline

yousafn
2023-05-04 18:40
ok so there is no issue

yousafn
2023-05-04 18:41
pact-go hasn't been updated to use the latest binaries

hulia.suliman
2023-05-04 18:41
yes

hulia.suliman
2023-05-04 18:41
thank you for your support

yousafn
2023-05-04 18:42
If your colleagues wishes to support the new binary packages in pact-go, they are welcome to raise an issue and/or pull request :+1: and pleasure

yousafn
2023-05-04 18:47
Ahhh I see the issue for end users they are told to install the latest version via our install script which will pull the latest 2.0.0 version https://github.com/pact-foundation/pact-go#installation-on-nix Going to test this out now

james.jenks
2023-05-04 19:09
has joined #general

yousafn
2023-05-04 19:12
working okay for me with latest of pact-go, pulling down the repo. Looks like it just shells out to the standalone tools on the path, so you should be able to run the tools outside of pact-go just on the path. It would be good to tell us what the error the user is seeing, that was with a fresh brew install of the standalone on an arm64 (m1) mac

hulia.suliman
2023-05-04 19:27
did u have rosetta installed on this m1 mac?

yousafn
2023-05-04 19:47
Yes, Is this the issue your user is seeing https://github.com/pactflow/example-consumer-golang/actions/runs/4886667716/jobs/8722304524#step:4:43 ```2023/05/04 19:44:25 [INFO] checking pact-mock-service within range >= 3.5.0, < 4.0.0 2023/05/04 19:44:25 [INFO] checking pact-provider-verifier within range >= 1.31.0, < 2.0.0 2023/05/04 19:44:25 [INFO] checking pact-broker within range >= 1.22.3 2023/05/04 19:44:26 [INFO] mock WARN: Please note: we are tracking events anonymously to gather important usage statistics like Pact-Ruby version and operating system. To disable tracking, set the 'PACT_DO_NOT_TRACK' environment variable to 'true'. 2023/05/04 19:44:26 [INFO] INFO WEBrick 1.8.1 2023/05/04 19:44:26 [INFO] INFO ruby 3.2.2 (2023-03-30) [x86_64-linux] 2023/05/04 19:44:26 [INFO] INFO WEBrick::HTTPServer#start: pid=3796 port=41789 2023/05/04 19:44:26 [INFO] INFO: Writing pact before shutting down 2023/05/04 19:44:26 [INFO] 2023/05/04 19:44:26 [INFO] Writing pact for pactflow-example-provider-golang to /home/runner/work/example-consumer-golang/example-consumer-golang/pacts/pactflow-example-consumer-golang-pactflow-example-provider-golang.json 2023/05/04 19:44:26 [INFO] ERROR ThreadError: can't be called from trap context\n\t/home/runner/work/example-consumer-golang/example-consumer-golang/pact/lib/ruby/lib/ruby/3.2.0/timeout.rb:184:in `synchronize' 2023/05/04 19:44:26 [INFO] INFO going to shutdown ... 2023/05/04 19:44:27 [INFO] INFO WEBrick::HTTPServer#start done. --- PASS: TestConsumer (1.95s) PASS ok http://github.com/pactflow/example-consumer-golang 1.958s``` The tests pass but it fails to write the pact file, It looks be a change in ruby behaviour in 3.1+ https://github.com/rapid7/metasploit-framework/issues/17593 which is causing this issue, I can recreate that above issue on my mac. It isn't clear if that is the issue you are seeing as you haven't provided the error message, but that is a good start for me


hulia.suliman
2023-05-04 19:52
I fw your messages to our slack channel I will let u know tomorrow about the results, now it is already late for me thank you again for your help :hugging_face:

hulia.suliman
2023-05-04 20:03
ok, so, the consumer tests pass, but he is not able to publish the contract to local broker ```2023/05/04 13:28:49 [ERROR] service: Could not load existing consumer contract from /...../pacts/xxxxxx.json due to undefined method `key?' for nil:NilClass. Creating a new file.```

abdurrahman.muratt
2023-05-04 20:50
has joined #general

hulia.suliman
2023-05-04 20:53
sorry, there was an invalid command executed? it may be ok now :smile:

svetoldo444ka
2023-05-05 15:35
has joined #general

priyaranjanmudliar
2023-05-06 10:59
Thanks a lot for all the pointers @yousafn, after going through this pr https://github.com/pact-foundation/pact-reference/pull/269/files i think i understood how i would implement something like this in erlang. Its a great resource for the ffi library usage. Now the only part i think i would need to understand is how i will introduce the cbinding thing in erlang.

priyaranjanmudliar
2023-05-07 05:23
Hi, I am getting this error when i try to load the libpact_ffi.so in erlang vm that i got from pact_ffi release page: ```"No driver init in dynamic library"``` I have tried multiple ways to load the pact ffi shared library but getting errors similar to the above one, any help would be appreciated. Thanks in advance!

uglyog
2023-05-07 23:12
a quick Google turns up: https://stackoverflow.com/questions/54371108/error-opening-c-shared-library-as-erlang-port-driver > From the documentation https://erlang.org/doc/man/erl_ddll.html, `erl_dll:load_driver` is to load a linked in driver. Linked driver's are libraries built with a specific set of interfaces...which I guess the shared library would not have implemented. > One option is to create a NIF's using the shared library and call the NIF's from erlang. The NIF's just need to wrap the functions you would like to use from the shared library

matt.fellows
2023-05-08 00:50
mind sharing how you?re setting up / loading the library?

matt.fellows
2023-05-08 00:51
ah, let?s avoid the cross post and continue here :point_right: https://pact-foundation.slack.com/archives/C02BXLDJ7JR/p1683440950514139

arjun.gowda
2023-05-08 17:07
has joined #general

valencianaad
2023-05-09 15:04
has joined #general

marlon.jimenez
2023-05-09 17:53
has joined #general

erollins
2023-05-09 18:49
has joined #general

marcos.aruj
2023-05-09 23:39
has joined #general

meritxell.rodriguez
2023-05-10 06:33
has joined #general

jaswanth.ooty
2023-05-10 07:13
Hey team :wave: I'm almost certain that the answer is no, but wanted to triple check before I share with my team. *When you write consumer side tests, is it possible to specify multiple provider states in the given block ?* For example, how would you go about creating a given block for a scenario that required --> given _"a product with ID 10 exists"_ & _"a user with ID 5 exists"_ ? Any help appreciated. Ta!

matt.fellows
2023-05-10 07:45
well you?re cause for minor uncertainty is valid - because _you can_.


matt.fellows
2023-05-10 07:46
In the Pact Spec V3, you can have multiple provider states (that may optionally also contain parameters)

jaswanth.ooty
2023-05-10 08:17
Thanks Matt! I knew that my research wasn?t sufficient. Appreciate the timely help :raised_hands::skin-tone-2: :pray::skin-tone-2:

yana.kliuch
2023-05-10 08:58
has joined #general

james.brown
2023-05-10 14:01
has joined #general

mark.bursnall
2023-05-10 14:01
has joined #general

alexandru.simion
2023-05-10 14:01
has joined #general

giulio.giovannini
2023-05-10 14:01
has joined #general

alexandru.simion
2023-05-10 14:03
Hi everybody - nice to meet you! :slightly_smiling_face: when we use the _pactBuilder to mock a service, on which endpoint do we create the server? and is that configurable? (host + port)? Thanks!

razvan.grigorescu
2023-05-10 14:04
has joined #general

alexandru.simion
2023-05-10 14:05
2. when writing contract tests - do you recommend using the actual deployed service (always running) or starting up the service on the spot?

alexandru.simion
2023-05-10 15:30
I think this should solve it: _pactBuilder = _pact.WithHttpInteractions(port: 8081) Please let me know if there is other method / any other documentation

henry.rutman
2023-05-10 18:28
has joined #general

simondemartini
2023-05-10 19:53
has joined #general

simondemartini
2023-05-10 20:08
Hey all :wave: I have some questions about migrating from tags to native environments/branches with pact-broker, since https://docs.pact.io/pact_nirvana/step_7: On a PR branch, the https://docs.pact.io/pact_broker/recording_deployments_and_releases recommend running `can-i-deploy` against all environments on the main branch, which makes sense to me, but: 1. From that PR branch CI pipeline, do we also need to run `can-i-deploy` against a main branch to catch any merged-but-not-deployed changes? 2. Is it still recommended to setup a webhook to trigger a provider verifications with native environments/branches? Since that doesn't sound like it recommends actually deploying those services changes from that

tjones
2023-05-10 22:31
You probably want to ask this in the channel for your language

tjones
2023-05-10 22:32
For the test (where you define the contract) you don?t spin up anything For verification (where you check the contract written earlier) usually you spin it up locally

abubics
2023-05-10 23:43
1. I think that's a good idea, but not necessary for "can I deploy" reasons.

abubics
2023-05-10 23:45
2. I'm not quite sure what that means, maybe someone else will know the answer :sweat_smile:

matt.fellows
2023-05-11 05:38

matt.fellows
2023-05-11 05:39
also, sorry that the Nirvana guide hasn?t been updated with environments/branches. We had an excellent PR last year from a community member, and now we need to do something at least as good with environments/branches

alexandru.simion
2023-05-11 07:11
ok, thanks

alexandru.simion
2023-05-11 07:11
great, thanks! :slightly_smiling_face:

stefan.kemp
2023-05-11 07:42
has joined #general

tam.norris
2023-05-11 11:14
Hi. I am just looking at the provider-example https://github.com/pactflow/example-provider/blob/master/src/product/product.providerChange.pact.test.js. This might be a stupid question but I just want to confirm is this just using a dummy (mock) provider? In a real provider contract test would this be making calls to an actual api?

yousafn
2023-05-11 12:04
it makes calls to the real provider api, which is started up as part of the test


supersmile2009
2023-05-11 12:06
has joined #general

tam.norris
2023-05-11 12:24
ok, thanks Yousaf. I think I was thrown by the stateHandlers function. I thought it was returning dummy responses.

simondemartini
2023-05-11 17:17
Ah thank you! And yeah the nirvana guide is still pretty excellent

simondemartini
2023-05-11 17:19
For #1 is that just using `can-i-deploy --branch <main|master> ...` without any `--to` or `--to-environment`? Or should I continue using tags to tag the main branch and use `can-i-deploy --to myMainBranchTag`?

lknaresh2
2023-05-11 18:20
has joined #general

tjones
2023-05-12 01:24
So many :taco: s for @yousafn for this incredible investigation and diagrams of the Pact ecosystem: https://github.com/pact-foundation/devrel/issues/10

siddharth12345
2023-05-12 09:47
has joined #general

siddharth.shetty
2023-05-12 09:51
has joined #general

siddharth.shetty
2023-05-12 10:17
Hi, I am currently using the C++ FFI to generate PACT contracts for some synchronous interactions and trying to understand why I am seeing multiple entries in the contract for identical request-responses. Have posted example interactions below ```auto syncInteraction1 = pactffi_new_sync_message_interaction( pact, "Interaction"); pactffi_given( syncInteraction1, "Given" ); pactffi_upon_receiving( syncInteraction1, "Upon receiving" ); pactffi_with_body( syncInteraction1, InteractionPart::InteractionPart_Request, "application/json", R"({"jsonrpc":"2.0","id":{"value":3,"pact:matcher:type":"type"}}); pactffi_with_body( syncInteraction3, InteractionPart::InteractionPart_Response, "application/json", R"#({"jsonrpc":"2.0","id":{"value":3,"pact:matcher:type":"type"}})#"); auto syncInteraction2 = pactffi_new_sync_message_interaction( pact, "Interaction"); pactffi_given( syncInteraction2, "Given" ); pactffi_upon_receiving( syncInteraction2, "Upon receiving" ); pactffi_with_body( syncInteraction2, InteractionPart::InteractionPart_Request, "application/json", R"({"jsonrpc":"2.0","id":{"value":4,"pact:matcher:type":"type"}}); pactffi_with_body( syncInteraction2, InteractionPart::InteractionPart_Response, "application/json", R"#({"jsonrpc":"2.0","id":{"value":4,"pact:matcher:type":"type"}})#");``` The above 2 interactions are the same except that the id field(in the request/response) has different values but is matched by type. So, I was expecting this to generate only 1 entry in the contract for both interactions which the provider can verify. But in the contract, there are 2 entries. I suppose this is because there are 2 unique keys generated for each of the 2 interactions? Any ideas how we can get around this so we can have only 1 entry in the contract for such duplicated interactions when using the C++ FFI to write PACT consumer tests would be much appreciated.

yousafn
2023-05-12 10:30
why do you need only 1 entry? I imagine you want a state handler with a param, and that param being the id used in the test (if you really need to fix for the provided id) so you would have two interactions, given there are two states, one where there is a product with id 3, and one where there is a product with id 4

yousafn
2023-05-12 10:31
Also Pact not PACT :slightly_smiling_face:

yousafn
2023-05-12 10:31
Thanks for sharing the code snippet, could you confirm which client library? (link to the codebase?) is it this? https://github.com/pact-foundation/pact-cplusplus


yousafn
2023-05-12 10:39
The CI/CD workshop has been updated https://docs.pactflow.io/docs/workshops/ci-cd/ to use our current best practise with branches / recording-deployments so might be useful

yousafn
2023-05-12 10:41
> For #1 is that just using `can-i-deploy --branch <main|master> ...` without any `--to` or `--to-environment`? Believe so ```Usage: pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL Options: [--branch=BRANCH] # The branch of the version for which you want to check the verification results``` > Or should I continue using tags to tag the main branch and use `can-i-deploy --to myMainBranchTag`? You could use tags, but ideally you have that main/master branch, set as a `mainBranch` in the pact broker (this is configurable per application) You want environments here ```Usage: pact-broker can-i-deploy -a, --pacticipant=PACTICIPANT -b, --broker-base-url=BROKER_BASE_URL Options: [--to-environment=ENVIRONMENT] # The environment into which the pacticipant(s) are to be deployed``` some background for a can-i-merge https://pact.canny.io/feature-requests/p/add-can-i-merge-functionality

yousafn
2023-05-12 10:42
We've actually got that as an open PR to add into the tool https://github.com/pact-foundation/pact_broker-client/pull/117

siddharth.shetty
2023-05-12 10:43
@yousafn We need 1 entry because both the interactions(response/request pair) is the same to the provider who is verifying the contract. We were hoping the provider would not be replayed the same request multiple times with different ID`s. So my question was more along the lines that if Pact is creating the key from the interactions, should it not be ignoring the fact that we are looking to match the ID by value type only and not the actual value itself? Which means the generated key should be the same for both interactions? Also we are not using the pact-cplusplus library, we are using the following C++ https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.4 because we need v4 contracts as we have written our own websocket plugin.

yousafn
2023-05-12 10:49
> We were hoping the provider would not be replayed the same request multiple times with different ID`s. I don't understand why you have two tests, that cover the same scenario, with the same description and state. these tests don't seem different, if they are different, they should be named as such. It might be scope creep into functional testing, it just seems an odd case. Anyway that aside, maybe it should dedupe in this instance, but the interaction key that the pact core adds, might be stopping that. I would raise this in the pact-reference repo I think as a question. Ahhh SkyComcast and the WS Plugin I presume? @adam.cox mentioned engineers were using the FFI directly

yousafn
2023-05-12 10:50
There is also `pactffi_given_with_param` for using a given state, with parameters ```/** * Adds a provider state to the Interaction with a parameter key and value. Returns false if the interaction or Pact can't be * modified (i.e. the mock server for it has already started) * * * `description` - The provider state description. It needs to be unique. * * `name` - Parameter name. * * `value` - Parameter value. */ bool pactffi_given_with_param(InteractionHandle interaction, const char *description, const char *name, const char *value);```

yousafn
2023-05-12 10:51
The notes state for `pactffi_given` that the `description` must be unique ```/** * Adds a provider state to the Interaction. Returns false if the interaction or Pact can't be * modified (i.e. the mock server for it has already started) * * * `description` - The provider state description. It needs to be unique. */ bool pactffi_given(InteractionHandle interaction, const char *description);```

yousafn
2023-05-12 10:52
If they should be unique, I wonder if Pact should clobber one of them and warn the user

yousafn
2023-05-12 10:53
It's plausible that its an incorrect use of the library, I would check out one of the implemented versions of a client library (pact-net, pact-js-core, pact-go@v2 etc that use the FFI, to determine what they do)

siddharth.shetty
2023-05-12 10:57
> I don't understand why you have two tests, that cover the same scenario, with the same description and state. So we have multiple unit tests for testing a single API/Method for ensuring code coverage for every statement/condition in the method. Which means the websocket request would be called multiple times with different ID`s depending on the state of the object under test.

siddharth.shetty
2023-05-12 10:58
> Ahhh SkyComcast and the WS Plugin I presume? @adam.cox mentioned engineers were using the FFI directly Yes thats right :slightly_smiling_face:

yousafn
2023-05-12 11:00
ok so you want the full coverage on the consumer side, using the pact ffi to facilitate the unit testing, but only want to selectively verify some of them in the provider, as otherwise there is duplication

siddharth.shetty
2023-05-12 11:01
```The notes state for pactffi_given that the description must be unique``` I tried this as well, but dont think it matters in what we are trying to acheive here. I mean having a unique description for each interaction will not create the 1 entry in the contract right?

yousafn
2023-05-12 11:02
1. Pact tradtionally is used in a unit testing framework and you would use Pact for capturing cases that have semantic meaning to a consumer, and you might use another mocking tool for testing all the code paths. There is duplication here and I think there could be value is marking a test as not to encode a contract file, as you just want to use Pacts powerful mock server functionality to replace any other types of mocks 2. You could filter by description or something on the verifier side, so despite several contracts being created you only pick specific interactions to verify

yousafn
2023-05-12 11:04
I remember there being an issue about it tracking, going to do some digging :slightly_smiling_face:

siddharth.shetty
2023-05-12 11:04
> ok so you want the full coverage on the consumer side, using the pact ffi to facilitate the unit testing, but only want to selectively verify some of them in the provider, as otherwise there is duplication Yes we are writing unit tests which use the pact framework to standup a mock websocket server and respond to requests as the tests progress. Which is why there might be multiple requests which are similar except they differ in ID value`s. So the provider does not have to verify redundant requests which differ only in ID`s.

adam.cox
2023-05-12 11:28
It would be possible to argue that the function under test is doing too much and should be broken up into smaller functions which could be unit tested separately and we would avoid this issue. However this is the state of the code we are trying to test at the moment and we have the following two scenarios: Scenario 1 uses Request A, B and C Scenario 2 use Request D, E, F, G and C The request and response payloads have an id field in them to correlate a request with a response. This id is incremental in the order in which they are sent. As scenario 2 uses request C in position 5 instead of position 3 we end up with a "duplicate" interaction for request C.

yousafn
2023-05-12 11:28
I can't find the issue at the moment, but the simple answer, is Pact is a contract testing, not unit testing framework, therefore you wouldn't expect to cover these types of duplicate cases. Quickest way would be to give a unique description and verify by that description, or exclude certain interactions from being uploaded (you might need to manually remove)

yousafn
2023-05-12 11:30
But worth raising as a discussion point somewhere :slightly_smiling_face: as there are additional use cases out there, and maybe it makes sense to cover them

yousafn
2023-05-12 11:30
Thanks for the additional context Adam, that seems like a wild ride for a Friday afternoon :smile:

adam.cox
2023-05-12 11:31
Haha, every day is a wild ride at the moment :wink:

yousafn
2023-05-12 11:33
I found this issue whilst hunting, I love the idea of api fuzzing, so if I could do it with Pact, but agree with Ron, it blurs the lines ? https://github.com/pact-foundation/pact-jvm/issues/432 and contract testing already is a confusing topic (suppose its highly overloaded as a term)

adam.cox
2023-05-12 11:34
We really do want contracts for requests A-G so I think for now if the provider has to verify request C twice then that might be the current state we have to accept. > If they should be unique, I wonder if Pact should clobber one of them and warn the user This would solve our current use case I think. Might cause issues for other people elsewhere but if it should be unique then there should be only one

yousafn
2023-05-12 11:40
Yeah I think that is something that should be addressed in the core, I'll raise something to track to find out what the correct behaviour should be then (if there isn't one already) I note the ffi exposes this function to filter verifications, there isn't an exclude filter (I don't think), but you can include by consumer name ```void pactffi_verifier_set_filter_info(VerifierHandle *handle, const char *filter_description, const char *filter_state, unsigned char filter_no_state);``` It would probably be easy to add an exclude filter method into the codebase, which would allow your verification runs just to exclude certain states or descriptions (unit test / xyz)

adam.cox
2023-05-12 11:51
For the verification side we are using the Pact Standalone Verifier which I think does expose filtering options

lukemstorey
2023-05-12 13:52
has joined #general

simondemartini
2023-05-12 16:24
Ahhh thank you! That's super helpful. So if I'm reading that right, it sounds like if my PR just checks a real `can-i-deploy` to all deployed environments, I don't really need the mainBranch check?

yousafn
2023-05-12 16:25
I believe that is the `TL;DR` of my ramblings :sweat_smile:

simondemartini
2023-05-12 16:25
Not ramblings at all :sweat_smile: Ok cool I think we can just go all in on that approach here

yousafn
2023-05-12 16:28
If you use the new webhook checks, when a consumer published a contract that requires verification, it checks against deployed, released and the head of your main branch, so those results all exist in the broker to be queried. If you provider wasn't compatible with deployed or released of consumers, it would fail verification and wouldn't get to can i deploy consumer side, they would still be valid to deploy if they were compatible with deployed or released, but not with provider HEAD of their main branch (and provider would have been stopped from deploying this anyway)


simondemartini
2023-05-12 16:30
Ok thank you! And yeah I was looking at that too, I think the part I was missing was just documention for the whole "big picture" workflow of the new stuff -- I think your updated Nirvana guide will help with that a lot

tjones
2023-05-13 00:32
I confess I?m not following completely, but can?t you inject the ID with provider state?

rana
2023-05-13 20:56
has joined #general

anatoliy.ganzyuk
2023-05-14 20:15
has joined #general

minhajsid
2023-05-15 10:18
has joined #general

minhajsid
2023-05-15 10:23
Hi .. Do we have any case studies or POCs done to integrate PACT with Azure CD pipeline?

matt.fellows
2023-05-15 12:44
There shouldn?t be anything difficult/controversial about it


artur.ashyrov984
2023-05-15 16:01
has joined #general

jerson.zuniga
2023-05-15 20:25
has joined #general

sekumar
2023-05-15 21:05
has joined #general

jzunigacoayla
2023-05-15 21:41
has joined #general

matthieu.saleta
2023-05-16 09:31
has joined #general

yousafn
2023-05-16 09:56
:ralph-wave: How do everyone, happy Tuesday!

carls.stfleur
2023-05-16 12:20
has joined #general

dale
2023-05-16 16:01
has joined #general

curb1968
2023-05-17 03:41
has joined #general

curb1968
2023-05-17 03:46
Is https://github.com/pact-foundation/pact-cplusplus still supported? I attempted to install per the README.md, but I'm apparently not downloading the conanfile.txt. _conan remote list_ _conancenter: https://center.conan.io [Verify SSL: True, Enabled: True]_ _*pact-foundation: https://pactfoundation.jfrog.io/artifactory/api/conan/pactfoundation-conan [Verify SSL: True, Enabled: True]*_ _conan install . --build missing_ _*ERROR: Conanfile not found at /home/harveys/pact/conanfile.txt*_

uglyog
2023-05-17 04:16
It should still work, but has not been updated in quite a while. The conan recipes are not hosted anywhere, so you will have to use the ones checked into the repository.

aforeman
2023-05-17 08:30
*Get contract testing certified!* :every_days_a_school_day: The team at SmartBear have created a three-part introduction to contract testing course for developers who are new to contract testing (and their teams) to learn the basics, covering: 1. *Introduction to contract testing* :cool-dog: - _what is it, why it is needed (vs over-reliance on E2E tests)_ 2. *Introduction to Pact* :pact-logo-white: - _what it is, how it works, how to get started and automate_ 3. *Introduction to PactFlow* :pactflow: - _compare Pact OSS vs PactFlow, benefits of PactFlow - exclusive features such as directional contract testing and more for enterprises_ They are short, bite-sized and accessible courses with exam questions so you?ll finish up with a contract testing certification - all from the team that created Pact and PactFlow! To take the courses, simply sign up here https://smartbear.com/academy/pactflow

robert.turner
2023-05-17 12:26
has joined #general

tjones
2023-05-18 01:33
Awesome!

curb1968
2023-05-18 04:04
Ok, I pulled down the git repo and attempted to install the dependencies via the commands in the README.md. This is what I see from the conan install ../conanfile.txt --build missing: *ERROR: Version conflict: cpprestsdk/2.10.15->boost/1.80.0, None->boost/1.72.0.*

curb1968
2023-05-18 04:04
the conanfile.txt is as follows:

curb1968
2023-05-18 04:05
[requires] gtest/1.10.0 boost/1.72.0 cpprestsdk/2.10.15 pact_ffi/0.0.0@pact/beta nlohmann_json/3.7.3 [generators] cmake

uglyog
2023-05-18 04:06
Try updating boost to 1.80.0

curb1968
2023-05-18 04:06
ERROR: Version conflict: websocketpp/0.8.2->boost/1.81.0, None->boost/1.80.0.

uglyog
2023-05-18 04:07
_Whack a dependency mole ..._

curb1968
2023-05-18 04:21
I hate to say this but it appears as cpprestsdk is the culprit (creates a dependency on websocketpp), I think the codebase is no longer usable. The cpprestsdk website states it's no longer supported (hasn't been updated in 3 years). As such, unless I'm missing something the only solution I can think of is to replace cpprestsdk with an alternative (i.e. libcurl?).

curb1968
2023-05-18 04:23
Is there an alternative to using pact with c++?

curb1968
2023-05-18 04:23
we're locked into that language for a variety of reasons.

uglyog
2023-05-18 04:24
If you have a way of invoking your C++ code, you could use another language that can call it. I.e., using FFI on the consumer side, and use the verifier CLI on the provider side

uglyog
2023-05-18 04:26
You can also try using libcurl instead of cpprestsdk, it would be good to get some fresh eyes over that code base

nada
2023-05-18 07:42
Hi? does someone has implementation example of consumer test with Vitest? Thank you

jsanthakumar
2023-05-18 09:47
has joined #general

rmodrego
2023-05-18 09:47
has joined #general

clm.whyte
2023-05-18 09:48
has joined #general

fdonald
2023-05-18 09:52
has joined #general

mgarcia
2023-05-18 09:53
has joined #general

yousafn
2023-05-18 10:06
we don?t have one in code but there was some discussion about it here https://github.com/pact-foundation/pact-js/issues/965#issuecomment-1348185596

lsantarelli
2023-05-18 10:25
has joined #general

tjones
2023-05-18 11:26
Yep. There should be no reason that the jest examples don?t work for you. Vitest isn?t fully compatible with Jest- but only in the way that?s mentioned in that thread. I opened an issue with them and sent a PR that fixes that problem. They have, of course, ignored it. Anyway, give it a go, and post in #pact-js if you have any problems

bdocherty
2023-05-18 11:56
has joined #general

srikanth_vemuri
2023-05-18 12:08
has joined #general

perera.x.roshni
2023-05-18 12:16
has joined #general

mohitkrishna.s.s12
2023-05-18 13:23
has joined #general

dwayne.sykes
2023-05-18 16:23
has joined #general

yousafn
2023-05-18 19:40
:goodnews: Good news everybody! *TL;DR* > You can now get multi-platform images by appending `-multi` to your `pact-cli`<https://hub.docker.com/r/pactfoundation/pact-cli > | Docker tag> Original tag remains a vanilla `amd64` image. :chefkiss: *ARM64* ```?docker run --rm --platform=linux/arm64 -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm' Unable to find image 'pactfoundation/pact-cli:latest-multi' locally latest-multi: Pulling from pactfoundation/pact-cli Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65 Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi Linux aarch64``` *AMD64* ```?docker run --rm --platform=linux/amd64 -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm' Unable to find image 'pactfoundation/pact-cli:latest-multi' locally latest-multi: Pulling from pactfoundation/pact-cli Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65 Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi Linux x86_64``` *ARM* ```? docker run --rm --platform=linux/arm -it pactfoundation/pact-cli:latest-multi /bin/sh -c 'uname -sm' Unable to find image 'pactfoundation/pact-cli:latest-multi' locally latest-multi: Pulling from pactfoundation/pact-cli Digest: sha256:d0f8f7d47796cc33c5c47ef328bb1ba42685d4c7005dece026ea8363f9d3ce65 Status: Downloaded newer image for pactfoundation/pact-cli:latest-multi Linux armv7l```

tjones
2023-05-18 23:04
Very cool!!

yousafn
2023-05-18 23:06
I am not going to lie, I was banging my head on the table as to why I kept getting an amd64 image, and _forgot_ I had re-enabled my shell workaround to fix the platform to `linux/amd64`

kancharla.g
2023-05-19 03:31
has joined #general

joseantonionmfilho
2023-05-19 17:46
has joined #general

anenada
2023-05-20 08:06
has joined #general

anenada
2023-05-20 08:08
Hi all. I am using http://pactflow.io as a broker. I am uploading OAS as the provider-contract. When writing consumer-pacts, is it possible to validate those consumer-pacts locally, before actually uploading those to http://pactflow.io?

tjones
2023-05-20 11:08
I?m not sure what you?re asking exactly, but this sounds like a #pactflow question, not a pact question.

tjones
2023-05-20 11:11
If by ?consumer pacts? you mean regular consumer driven pact, the workflow is: 1) Define the examples for the consumer tests 2) Run the consumer tests (where the provider is mocked by Pact) 3) If successful, a pact file will be written Then you upload that to a broker, to be verified by the provider later

tjones
2023-05-20 11:12
If you meant anything else, you?ll want to ask in #pactflow as I think it?s not a pact question.

rabrosimov
2023-05-20 20:11
has joined #general

priyaranjanmudliar
2023-05-21 05:59
Hi all Created the lib pact-erlang for erlang/elixir(very basic but works), thanks to everyone who helped https://github.com/silverblaze404/pact-erlang

matt.fellows
2023-05-21 09:05
Thanks for sharing! I wonder if we should pop another entry for ?Erlang? (and Elixir? Can an Elixir project use it?) under ?Other Languages? here https://docs.pact.io/implementation_guides/other_languages We could link to your repository as a ?community supported? one.

priyaranjanmudliar
2023-05-21 09:17
@matt.fellows Oh yes! that would be great, and yes it does support elixir as well due to its interoperability with erlang, the installation is similar as well

matt.fellows
2023-05-21 09:18
nice, will follow up tomorrow then

priyaranjanmudliar
2023-05-21 09:21
Also, I know the pact matchers module is not yet there, will add it incrementally as I get time for it

tjones
2023-05-21 14:55
This is awesome!

tjones
2023-05-21 14:55
Thanks for all your hard work!

arm.arturpetrosyan
2023-05-22 10:37
has joined #general

yousafn
2023-05-22 11:34
Awesome, :taco: for @priyaranjanmudliar! > Also, I know the pact matchers module is not yet there, will add it incrementally as I get time for it This is ideal when you are starting a library out and don't have consumers, no need to get everything in straight way. I would suggest some `DEVELOPING.md` style docs to help others, help build out the library with you :slightly_smiling_face: Nice work, we've love to shout about it in this months open source blog if you'd like?

adra_verma
2023-05-22 12:11
has joined #general

p.keshav.chainani
2023-05-22 12:13
has joined #general

divya.s.parappanavar
2023-05-22 12:13
has joined #general

priyaranjanmudliar
2023-05-22 12:14
thanks @yousafn !! Why not, would love the library to be featured in the blog :grin: as for the suggestion sure, I will add the developing guide as well.

n.duran
2023-05-22 14:38
has joined #general

garry.wilson
2023-05-23 12:28
has joined #general

verevad
2023-05-23 13:04
has joined #general

jon.arambarri
2023-05-24 07:34
has joined #general

yonatany
2023-05-24 08:14
has joined #general

scoplin
2023-05-24 20:02
has joined #general


adam.cox
2023-05-25 08:16
It was my pleasure

yousafn
2023-05-25 13:07
:ralph-wave: Yo yo, The Pact Open Source Blog - May 2023 edition is now live, Check it out https://docs.pact.io/blog/2023/05/25/pact-open-source-update-may-2023


yousafn
2023-05-25 13:11
Yes! Thank you so much for this Adam, in marking the first post in our dedicated community corner section. It was announced in our latest post https://docs.pact.io/blog/2023/05/25/pact-open-source-update-may-2023#community-corner---adam-cox For any others reading, who wish to add your own, please free free, its all of our platform, an online contract testing wikipedia if you will :slightly_smiling_face:

aemanuelson
2023-05-25 23:41
has joined #general

sreenivas.chaitanya
2023-05-26 08:29
has joined #general

sreenivas.chaitanya
2023-05-26 08:32
Hi All, iam a new user to pact , iam using pact with message queues , iam trying to follow the dog example on the github

sreenivas.chaitanya
2023-05-26 08:32
iam getting error in node js

sreenivas.chaitanya
2023-05-26 08:34
this is my handler ```export type LogIds = { session_id: string, client_id: string, persistent_session_id: string, client_session_id: string, request_id: string, }; export function auditApiHandler(logIds: LogIds): void { if (!logIds.client_id || !logIds.client_session_id || !logIds.persistent_session_id || !logIds.request_id || !logIds.session_id ) { throw new Error('Missing fields in the Audit Message '); } return; }```

sreenivas.chaitanya
2023-05-26 08:34
in my spec class iam getting error on synchronousbody handler

sreenivas.chaitanya
2023-05-26 08:34
```verify(synchronousBodyHandler(auditApiHandler)); - error TS2345: Argument of type '(logIds: LogIds) => void' is not assignable to parameter of type '(body: AnyJson | Buffer) => void'. Types of parameters 'logIds' and 'body' are incompatible. Type 'AnyJson | Buffer' is not assignable to type 'LogIds'. Type 'null' is not assignable to type 'LogIds'. 39 .verify(synchronousBodyHandler(auditApiHandler));```

tigrandza
2023-05-26 08:46
has joined #general

tle
2023-05-26 09:56
has joined #general

adam699
2023-05-26 13:35
has joined #general

tjones
2023-05-27 06:25
If you update to the latest version of pact-js, this should go away

mariusz.kapczynski
2023-05-29 12:10
has joined #general

kazimierz.zarychta
2023-05-29 12:10
has joined #general

pierre.zeidan
2023-05-30 13:10
has joined #general

shkothari
2023-05-30 14:55
has joined #general

bwang
2023-05-30 16:55
has joined #general

dev.talha.akbar
2023-05-31 09:45
has joined #general

yousafn
2023-05-31 11:20
Happy Wednesday everyone :slightly_smiling_face:

msiles
2023-05-31 13:50
has joined #general

msiles
2023-05-31 13:54
GM guys, is there a project structure standard / template we should follow for contract testing? a git example would be great :slightly_smiling_face: Thanks

tjones
2023-05-31 14:18
There are git examples in each pact-supporting language?s repository

tjones
2023-05-31 14:18
which language are you using?

tjones
2023-05-31 14:18
Also, generally, there?s no need to do anything special for Pact, structurally

tjones
2023-05-31 14:19
It?s good to clear out the contract file directory before the test run

msiles
2023-05-31 14:19
js, I was checking one example from the Test Automation University repo


tjones
2023-05-31 14:19
there are many examples here

msiles
2023-05-31 14:20
thanks @tjones, I?ll take a look

tjones
2023-05-31 14:20
Pactflow also have some examples I believe, if you look on their github and filter by `example`, you?ll find many

msiles
2023-05-31 14:22
thanks, I was using this one as a guide but I?ll take a look at the other examples https://github.com/rafaelaazevedo/tau-pact-nodejs-course

tjones
2023-05-31 14:25
Cool. That?s an outdated version, but the concepts haven?t changed much

tjones
2023-05-31 14:25
the latest version supports much better provider state setup

msiles
2023-05-31 14:33
good to know, Thanks @tjones

eli.thorkelson
2023-05-31 18:14
has joined #general

dimundo
2023-06-01 10:23
hi! i have some tricky question :slightly_smiling_face: lets imagine we have 2-week sprints ? on monday FE as a consumer waits for BE as a provider to be deployed on dev env ( everything is fine ) ? on tuesday BE deploys, FE is unblocked -> FE deploys ( still everything is fine ) ? on wednesday BE as a consumer waits for FE as a provider to be deployed on dev env ( everything is fine ) ? on thursday FE deploys, BE is unblocked -> BE deploys ( still everything is fine ) ? on friday we have a release to be deployed on pre-prod environment but got a deadlock :hide-the-pain-harold: ? BE as a consumer waits for FE ? FE as a consumer waits for BE how to deal with such deadlocks ?

tjones
2023-06-01 13:12
This might be a dumb question, but why is your sprint cadence relevant?

tjones
2023-06-01 13:17
Also, I don?t think I understand the scenario, sorry

tjones
2023-06-01 13:20
Oh, is the scenario that you have two interdependent services: A -> B B -> A they?re deployed fine to a dev environment, but now you want to promote them both to pre-prod (for the first time), and you can?t because they?re interdependent?

tjones
2023-06-01 13:20
So, my question would be - is it possible to deploy one without the other?

tjones
2023-06-01 13:21
For example, with HTTP endpoints, you can deploy a provider without a consumer

tjones
2023-06-01 13:21
But with say SQS messages, you can deploy either end safely without the other (as long as the queue exists, which Pact doesn?t assert)

tjones
2023-06-01 13:22
This exposes a hole in Pact?s reasoning. Pact assumes that providers can deploy without the consumer, which isn?t always true. It also assumes that consumers can?t deploy without the provider - which also isn?t always true

tjones
2023-06-01 13:24
If your scenario wouldn?t be fixed by the ability to tell Pact which end can deploy with the other end missing, then I think you have a real deadlock - and Pact is just exposing it.

tjones
2023-06-01 13:25
For example, if you have two services which are both HTTP clients and servers, with A -> B, and B -> A ,it?s not possible to deploy one without the other without (at least a moment of) broken state.

tjones
2023-06-01 13:26
That deadlock exists in the process, regardless of whether or not Pact is stopping you.

dimundo
2023-06-01 13:31
only thing - make can-i-deploy be not fullstopper

dimundo
2023-06-01 13:31
but this is scary and make all contract testing useless :disappointed:

dimundo
2023-06-01 13:32
A and B are just FrontEnd and Backend

dimundo
2023-06-01 13:33
and while there is no continuous deployment - this happens

tjones
2023-06-01 13:33
Right, but how is your backend a consumer of the frontend?

dimundo
2023-06-01 13:33
we have ws messages contracts

dimundo
2023-06-01 13:34
so communication is in both directions

dimundo
2023-06-01 13:35
but those could be 2 http services as well ( as we have bunch of microservices )

tjones
2023-06-01 13:35
Right

tjones
2023-06-01 13:36
So, I think this _is_ the scenario for which you?d need to be able to tell Pact that it?s ok to deploy one without the other

tjones
2023-06-01 13:36
because a WS server that is a consumer is safe to deploy with no clients

tjones
2023-06-01 13:37
However, if your situation is: A and B are already in preprod, but this is a breaking change, then Pact is correctly stopping you from deploying

tjones
2023-06-01 13:37
without Pact, a deploy would induce a broken state


tjones
2023-06-01 13:46
I created this ticket that you can vote for if you like (I also would like this feature, but for a different reason - I have an alternative tool that uses the broker, where a regular HTTP client might be the provider - since it provides requests)

yousafn
2023-06-01 14:07
We have a range of examples here https://docs.pact.io/implementation_guides/workshops#examples As stated by Tim, the repo is using a 9.x version of pact and hasn't had any of the dependencies touched in a while, but there isn't much code so shouldn't be hard to update. I would note that it is publishing with `tags` where we prefer publishing with `branches` and deploying to `environments` - Tags previously were used for both, but now we have first class concepts. https://github.com/rafaelaazevedo/tau-pact-nodejs-course/blob/233d856433ff75bea904d1ceb43f747f53e51b4e/__tests__/helpers/publish.js#L9 We would also recommend use of the Pact CLI tools rather than the pact's JS api wrapper for the standalone client.

yousafn
2023-06-01 14:09
Tim's real point, it is always best to look at the projects source code and supporting site for examples, although I do note we do reference that site in our courses section, so it would be both apt and correct for the author to update and for us to help nudge them to do so.

yousafn
2023-06-01 14:10
Whilst external examples are brilliant and we love community users sharing them, I would be mindful of the date stamps of commits and the package versions, comparing them against the latest released versions. Even some of our own aren't always up to date, it is a large estate to manage. We would love support in helping update any, so I am sure a pull request against that course, with an update to the latest version of pact, axios, jest and the like wouldn't go amiss :+1:

yousafn
2023-06-01 14:13
note if you have an existing project, and you are introducing contract testing, I wouldn't worry too much about following other example structures personally and just look to get a test working, within the unit testing framework that exists, where one is mocking out a provider.

dimundo
2023-06-01 14:20
> However, if your situation is: A and B are already in preprod, but this is a breaking change, then Pact is correctly stopping you from deploying this could be not a breaking change

dimundo
2023-06-01 14:20
just 1 _new_ message/endpoint on _each_ side simultaneously

dimundo
2023-06-01 14:20
and - tadaa

dimundo
2023-06-01 14:22
so need some rule, which can handle such "big bang"

tjones
2023-06-01 14:28
This is a break, right?

tjones
2023-06-01 14:29
Because if you can produce a message that can?t be consumed, then it?s not safe to deploy

tjones
2023-06-01 14:29
and if both sides do that at once, it?s not safe to deploy

tjones
2023-06-01 14:37
I think websockets might be a bit complex, in terms of safety :thinking_face:

tjones
2023-06-01 14:37
What do you think?

tjones
2023-06-01 14:37
I?m not super familiar with them

dimundo
2023-06-01 17:55
No, it isn?t break

dimundo
2023-06-01 17:56
Just 2 features

dimundo
2023-06-01 17:57
If they are deployed 1 by 1 ( theoretically in any order) everything is fine

dimundo
2023-06-01 17:57
But at once

dimundo
2023-06-01 18:07
Exact example :all_the_things:

tjones
2023-06-01 22:10
yes, that?s what I?m saying - Pact is just telling you that it?s not safe to do that

tjones
2023-06-01 22:11
if you didn?t have Pact, this deployment strategy would let you deploy, but it would be broken for at least a time during that deploy

abubics
2023-06-02 01:56
Sounds like the current best solution (which Pact is only indirectly surfacing) is to deploy more granularly.

bas
2023-06-02 05:16
Cross-posting here from talks-and-conferences after a hint from Matt.

matt.fellows
2023-06-02 06:05
Any Canadian :flag-ca: ?s aboot - Bas comes highly recommended, not just for contract testing but testing practices more generally.

dimundo
2023-06-02 06:08
its not possible with release pace

dimundo
2023-06-02 06:10
only hack/workaround i found - if pairs A->B and B->A are green I tag one of pacticipants as deployed, then c-i-d says yes

dimundo
2023-06-02 06:10
pact cli helps a lot :smile:

abubics
2023-06-02 06:10
if you have feature toggles, you can still deploy one at a time

abubics
2023-06-02 06:11
I can see how you would get tied up if you're delivering that fast, and not releasing often.

tjones
2023-06-02 06:11
Right, yeah. But that hack still results in a broken state momentarily

dimundo
2023-06-02 06:12
it shouldnt

dimundo
2023-06-02 06:12
if both pairs are green - why should it fail ?

abubics
2023-06-02 06:12
Breakage will occur in the window where one is deployed and the other isn't.

tjones
2023-06-02 06:12
Why not? If A(v2) depends on B(v2), and B(v2) isn't deployed, it's not safe.

tjones
2023-06-02 06:12
You have a deadlock, regardless of what you do with Pact

dimundo
2023-06-02 06:12
ah, yes, but for now deploys are with downtimes

abubics
2023-06-02 06:13
If you're already comfortable with downtime, then this stops being a problem.

abubics
2023-06-02 06:14
And I'd say can-i-deploy has reduced value for you, too

dimundo
2023-06-02 06:14
but it will go away soon :pepe_naruto:

tjones
2023-06-02 06:14
When it goes away, I think you'll have a problem here too.

tjones
2023-06-02 06:14
What you could do, though I haven't thought about this and it might make you nervous when you go to prod, is to make a deploy queue

dimundo
2023-06-02 06:15
c-i-d has value, as apart from prod version, we have some other long-living version in the wild - apps, and a backward compatibility is very needed

tjones
2023-06-02 06:15
where each thing you deployed to dev is put in a queue of deploys

tjones
2023-06-02 06:15
I guess from your original question that you're deploying once per sprint

tjones
2023-06-02 06:15
which I'm not wild about, but I see why you might want to do it

dimundo
2023-06-02 06:15
once per sprint but queue will not help

tjones
2023-06-02 06:16
(side note: I have used the sprint number as a version number before - this works nicely if you don't need semver)

dimundo
2023-06-02 06:16
as again there in queue 2 parts are waiting for each other and we are deploying whole trunks

tjones
2023-06-02 06:16
I think the queue would help - because it would just queue the safe path that went to dev

abubics
2023-06-02 06:18
It would do a batch of smaller deploys at once :sunglasses: which has some other problems, probably

abubics
2023-06-02 06:18
Well, the deploys are the same size, but the size of change per deploy is small maybe

tjones
2023-06-02 06:19
Here's your scenario with queues: ? on monday FE(1) as a consumer waits for BE(1) as a provider to be deployed on dev env ( everything is fine ) ? on tuesday BE(1) deploys, FE is unblocked -> FE(1) deploys ( still everything is fine ) ? on wednesday BE(2) as a consumer waits for FE(2) as a provider to be deployed on dev env ( everything is fine ) ? on thursday FE(2) deploys, BE is unblocked -> BE(2) deploys ( still everything is fine ) ? on friday we have a release to be deployed on pre-prod environment but got a deadlock :hide-the-pain-harold: The FE queue contains: FE1, FE2 The BE queue contains BE1, BE2 Queue run: deploy FE1 (no). Deploy BE1 (yes), deploy FE1 (yes), deploy BE2 (no), deploy FE2 (yes), deploy BE2 (yes)

tjones
2023-06-02 06:19
I think this is probably not a _good_ solution, as maybe you never want to deploy FE1 / BE1 to prod

tjones
2023-06-02 06:20
ooh! You could shorten it by going "deploy latest possible deployable"

tjones
2023-06-02 06:21
Which can-i-deploy doesn't have natively, but you could built it on top of pretty easily

tjones
2023-06-02 06:21
`what-can-i-deploy` - tells you the latest non-deployed version that is compatible with <environment>

tjones
2023-06-02 06:22
(doesn't exist, but you could build it with a few API calls)

tjones
2023-06-02 06:23
This is so cool! Go @bas :taco:

dimundo
2023-06-02 07:29
thing is on friday we deploy FEnn and BEmm versions , which contains (FE1..FEn) and (BE1..BEm) versions

dimundo
2023-06-02 07:30
and we cant get some granular pieces from them

jegadeesan.ponnusamy8
2023-06-02 16:19
has joined #general

siyuanshen1993
2023-06-03 10:36
has joined #general

pawar.s
2023-06-05 05:15
has joined #general

pawar.s
2023-06-05 05:21
Hi Guys, I have question on pact validation. Want to create multiple pact files for *PACT - Error contract validation* by using single pact class. So, is it possible to create multiple pact files by using single class?

tjones
2023-06-05 05:31
I'm not sure what you mean, but this doesn't sound like a general pact question. You probably will want to ask (with more details) in the channel for whatever language you're using.

tjones
2023-06-05 05:32
What is "error contract validation" ?

tjones
2023-06-05 05:32
Why do you want multiple pact files from one class?

matt.fellows
2023-06-05 05:51
> *PACT - Error contract validation* Yes, what is this? It sounds like maybe it?s a requirement or task you?ve been assigned?

pawar.s
2023-06-05 06:00
Hi Timothy ,here the error contract validation means suppose 1.there is contract signed between consumer and provider (for data type and attribute values) 2. I need to do the pact verification by giving all the mandatory values(for data type and attribute values) as positive scenario(200) 3. and again I need to do the pact verification between same counsumer and provider by missing some mandatory values(for data type and attribute values) as negative scenario(400) so i am currently able to do the verification for statement 2nd and 3rd by using seperate pact class. but i don't want diffrent classes for pact file creation. i want this verification for positive and negative under the single class. Why do you want multiple pact files from one class? for positive and negative validations as mentioned above

matt.fellows
2023-06-05 06:03
Please try and keep the conversation to a thread Saraswati. If you?re new to Slack, you can see and respond to the thread when you hover over a message (there are two ways to do it - see attached)

matt.fellows
2023-06-05 06:04
What?s stopping you from putting them in the same class now? Is this a Java class? If so, please ask in #pact-jvm

pawar.s
2023-06-05 06:28
yes it is Java class. Ok I will ask this in #pact-jvm

tanyaryzhova93
2023-06-05 20:02
Hi team, I have a question about `can-i-deploy` tool. I have the following situation: Provider (P) has long and slow pipeline, consumer (C) has small and quick pipeline. P1 deployed to staging. C1 deployed to staging too. Pact between C1 and P1 was verified successfully. Provider pushed some changes to the `main` branch with v2 and the pipeline is running. Meanwhile, consumer pushed changes too (*pact wasn?t changed*) and triggers verification on the provider side against the provider?s `main` branch with v2, in the end verification passed. Consumer is ready to deploy (provider?s pipeline with v2 still running), however `can-i-deploy` tool fails, because it can?t find verification record between P1 and C2. P1 is the latest deployed version of our provider on staging. Should `can-i-deploy` fail in the case when pact wasn?t changed and provider v2 hasn?t beed deployed yet?

tanyaryzhova93
2023-06-05 20:04
According to https://docs.pact.io/getting_started/versioning_in_the_pact_broker#consumer-application-versions can-i-deploy should pass since the pact didn?t change and the previous verification was ok ```This happens when two or more application versions publish the same Pact contract. Duplicate detection is done by hashing the pact file. Note that application versions publishing the same pact contract don't need to be consecutive. Allowing multiple consumer versions to point to one pact contract file has the major advantage that verifications don't need to be repeated when contracts haven't changed. In the diagram above, a provider that has been verified against consumer version 0.0.0 is automatically considered to have been verified against consumer version 0.0.1. This is particularly useful when working on feature branches.```

rohitkrishnan
2023-06-05 20:37
has joined #general

matt.fellows
2023-06-05 23:15
> triggers verification on the provider side against the provider?s `main` branch with v2, in the end verification passed. why did it trigger a verification? If you?re using the the ?contract requiring verification published? https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event then it wouldn?t trigger if it didn?t require verification. This implies it would. It?s worth checking to see if there are any changes between the versions in your consumer contract. This can occasionally happen if you use dynamic matchers without specifying examples (the framework will insert random values in that case) which will invalidate the pre-verification status

tanyaryzhova93
2023-06-05 23:50
> why did it trigger a verification? I don?t use pact webhooks. I trigger provider verification every time when merge request is opened or changes pushed to the `main` branch in a consumer, and I trigger it as a downstream pipeline. I am thinking maybe I should trigger it only when changes introduced in pacts :thinking_face:

tanyaryzhova93
2023-06-05 23:53
> It?s worth checking to see if there are any changes between the versions in your consumer contract. This can occasionally happen if you use dynamic matchers without specifying examples (the framework will insert random values in that case) which will invalidate the pre-verification status If there is no changes between contracts, should `can-i-deploy` fail in my case? (I?m sure there are no changes, but I?ll double check)

matt.fellows
2023-06-06 00:33
> I am thinking maybe I should trigger it only when changes introduced in pacts ah - you should use webhooks if you can! They are clever enough to do it for you :slightly_smiling_face:

matt.fellows
2023-06-06 00:35
> If there is no changes between contracts, should `can-i-deploy` fail in my case? (I?m sure there are no changes, but I?ll double check) without knowing the flags you are giving to the CLI it?s hard to say, but in general if a contract hasn?t changed between consumer versions for the _same provider version_ then it should be pre-verified and not fail.

tanyaryzhova93
2023-06-06 00:45
> if a contract hasn?t changed between consumer versions for the _same provider version_ I use commit sha as a version for both consumer and provider. I have C1 and P1 verified and deployed. Then I have C2 and P1 where contract is the same as between C1 and P1, so contract should be pre-verified and can-i-deploy should pass, is it correct?

tanyaryzhova93
2023-06-06 00:47
I have the following flags: can-i-deploy: ``` script: - >- pact-broker can-i-deploy --pacticipant="my-service" --version="$CI_COMMIT_SHA" --to-environment="$ENVIRONMENT" --broker-base-url="$PACT_FLOW_BASE_URL" --broker-token="$PACT_FLOW_KEY" --verbose``` verification: ```script: - >- pact-verifier --hostname="app" --broker-url="$PACT_FLOW_BASE_URL" --token="$PACT_FLOW_KEY" --loglevel="info" --provider-branch="$CI_COMMIT_REF_SLUG" --provider-version="$CI_COMMIT_SHA" --provider-tags="$CI_COMMIT_REF_NAME" --provider-name="dummy-microservice-provider" --filter-consumer="$CONSUMER_NAME" --publish```

matt.fellows
2023-06-06 00:56
I?d take a look at this article: https://docs.pact.io/pact_broker/advanced_topics/see_changes_pact#most-recent-change See if you can find the difference between the two pacts

tanyaryzhova93
2023-06-06 01:03
Does this article apply for PactFlow? And there is no `pb:diff-previous-distinct` endpoint in the HAL browser for me, maybe something changed?

matt.fellows
2023-06-06 01:30
it should (it?s a superset of the Pact Broker)

matt.fellows
2023-06-06 01:33
helpful?

tanyaryzhova93
2023-06-06 01:38
Wow! :star-struck: Thank you very much for the video! Yes, it was helpful! And it returned a lot of changes for my contract :face_with_spiral_eyes: I am super surprised. But it?s good point for investigations!

matt.fellows
2023-06-06 03:57
awesome, glad it helped :slightly_smiling_face:

payal.chainani
2023-06-06 06:32
has joined #general

payal.chainani
2023-06-06 06:35
Hi Team, could anyone please share the latest PactFlow .Net Workshop Project link here.

tjones
2023-06-06 06:41
Are you just looking for the one in the github?

tjones
2023-06-06 06:41
You can search on github for that

tjones
2023-06-06 06:42
See also howtolearn

2023-06-06 06:42
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

divya.parappanavar
2023-06-06 07:23
has joined #general

mrudula.patil
2023-06-06 08:19
has joined #general

asjad.baig.ind
2023-06-06 11:12
has joined #general

rajat.chouhan
2023-06-06 12:16
has joined #general

david.stothers
2023-06-07 07:25
has joined #general

rafaela.azevedosouza
2023-06-07 08:52
has joined #general

yousafn
2023-06-07 10:10
Morning!

newmolti
2023-06-07 10:14
has joined #general

danut.turta
2023-06-07 11:35
has joined #general

dev664
2023-06-07 11:53
has joined #general

tjones
2023-06-07 13:47
Hi Dr Nick!

david.blanco
2023-06-07 18:08
has joined #general

jonathan.fisher
2023-06-07 19:30
has joined #general

dev.pactslack
2023-06-07 20:17
has joined #general

dan.nichols52
2023-06-08 04:30
has joined #general

dimundo
2023-06-08 05:58
hi! following case ? release was made 2 weeks ago ? provider(s) were changed ? can-i-deploy of current release says, there is no verified pact for consumers is there easy way to verify current consumers and old providers ? I workarounded that by re-running old pipelines , where providers tests were

tjones
2023-06-08 06:22
Usually I would verify all current pacts in each provider build. Are you not doing that?

tjones
2023-06-08 06:23
Or am I misunderstanding the case?

dimundo
2023-06-08 06:35
but provider was changed

dimundo
2023-06-08 06:36
so only new one ( aka current ) is checked on each build

tjones
2023-06-08 06:49
Oh I see, so you're asking about: ? New consumer pact trying to deploy ? Current deployment has old consumer ? Old consumer has never seen the new consumer ?


dimundo
2023-06-08 07:21
? Old *provider* has never seen the new consumer to be precise

tjones
2023-06-08 07:21
I believe webhooks are supposed to be used for that case - https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event triggers for: ? the latest version from the provider's main branch ? any version currently deployed to an environment

dimundo
2023-06-08 07:23
yeh, also thought about webhooks, but how do i tell ci, which branch is needed ?

tjones
2023-06-08 07:24
I don't know, I'm afraid. I've never used the webhooks

dimundo
2023-06-08 07:25
as a human i understand, that i need to rerun release version branch

tjones
2023-06-08 07:25
What I do is verify the current contract, and any deployed contracts, on each build. This doesn't solve your case though

dimundo
2023-06-08 07:25
thats what we do as well

dimundo
2023-06-08 07:25
+ 7 days of WIP

s.lohmeier
2023-06-08 08:08
has joined #general

yousafn
2023-06-08 13:15
Hey @hulia.suliman, Just to let you know I am about to release a new version of https://github.com/pact-foundation/homebrew-pact-ruby-standalone/pull/94 if you have any issues, you?ll be able to stick with the v1.x branch with the following command `brew install pact-ruby-standalone@1`

radek.stolarczyk
2023-06-08 13:32
has joined #general

zeeshankhan0330
2023-06-08 16:36
has joined #general

marek
2023-06-09 07:57
has joined #general

marek
2023-06-09 09:03
happy Friday everyone! We?re very excited to set up Pact tests in our company. We have already everything in a place but we?re still unsure with this functional vs contract tests thing. I?m looking for an advise if we should have just one or multiple interactions for an endpoint. The endpoint GET `/profile` expects a query parameter `code` and returns a user profile object. User can be in one of three statuses: `new`, `lead`, and `user`. When it?s `new` , the profile must have `emailAddress` property. If it?s `lead` or `user` there must be also `phoneNumber` and `username` properties present in the response. There are also optional fields like `firstName` that might be null or a string. Now, the questions are: 1. Should we have only one interaction for all the user statuses or an interaction for each status separately (wouldn?t it be testing a business logic?) 2. Should we have a separate interaction for the optional properties to be given (not null)? I hope that?s a good place for such questions, Best regards

michael.lawrence
2023-06-09 09:57
has joined #general

abubics
2023-06-12 03:07
Good philosophical question, and, in the end, not actually a Pact question :) You can go either way on all the aspects you've mentioned, but you'll be trading-off specificity.

abubics
2023-06-12 03:10
Personally, I'd have a state for each combo, so if something breaks, I know exactly which bit isn't working. That'll require anywhere from 2 to 6 states for the happy paths. That granularity is a problem for some people, but I prefer to have many small detangled bits to maintain.

mssachin
2023-06-12 08:06
has joined #general

andy.frith
2023-06-12 12:31
has joined #general

ajay_886
2023-06-12 22:38
has joined #general

ajay_886
2023-06-12 22:42
Hi :wave:. A Pact newbie here. Could someone point me to any reference articles/blogs regarding recommended Pact workflows for teams doing trunk based development and use of feature toggles?

tjones
2023-06-12 23:11
I haven?t read this, but I searched for ?pact and feature toggles? and this is the first result: https://docs.pact.io/getting_started/feature_toggles

ajay_886
2023-06-12 23:13
Hi Timothy, thanks for responding. I did have a read through that article before posting on this channel. It did assume a feature branch strategy being in place.

ajay_886
2023-06-12 23:18
https://kreuzwerker.de/en/post/integrating-contract-tests-into-build-pipelines-with-pact-broker-and is a more elaborate one and had some useful tips for trunk based workflow. I was hoping if the community is aware of more such ones.

steven.wang06
2023-06-13 05:06
has joined #general

steven.wang06
2023-06-13 05:29
Hi, I'm new to Pact. Is it possible to get the contract files( e.g. swagger files from provider side ) in pact-broker ?

matt.fellows
2023-06-13 06:25
This is a #pactflow question, let?s bring the conversation over there?

tjones
2023-06-13 06:25
I think this might be a Pactflow question, as Pact (the open source broker) doesn't support swagger. Try #pactflow

tjones
2023-06-13 06:25
Haha! Hi Matt!

matt.fellows
2023-06-13 06:25
jinx

steven.wang06
2023-06-13 06:26
Thanks

navanesyan
2023-06-13 07:05
has joined #general

zhaopeng
2023-06-13 08:39
Hey team, may I ask did anyone use http://Pact.io in Provider-driven way, means Provider generate contract, then consumer always verify, does this approach make sense? or maybe overengineering comparing with schema validation? Thanks in advance

tjones
2023-06-13 08:47
Kinda. Pact doesn?t support this directly. In Pact, a consumer is a synonym for client (which is not strictly true - it _provides_ http requests, and _consumes_ http responses). Some of the assumptions change if you were able to write a Pact test for a provider - for example, it?s not breaking if a consumer never calls an endpoint that is available.

tjones
2023-06-13 08:47
The point of consumer-driven testing is that you only test what you need

tjones
2023-06-13 08:47
so, in most http APIs, driving that from the server side doesn?t have that property

tjones
2023-06-13 08:48
since, most http APIs provide a few different services. Mostly (but not always) they are dependencies of the clients - they are servers, but also they only exist to provide for the clients

tjones
2023-06-13 08:49
in some cases, it might make sense to consider the client as a provider for the service - for example, in remote logging, or other situations where you don?t care too much what the response codes are.

tjones
2023-06-13 08:50
I have built a contract testing tool which lets you do client or server-driven contracts. You can find that here: https://case.contract-testing.io/

tjones
2023-06-13 08:50
it?s compatible with the pact broker

tjones
2023-06-13 08:50
(but not compatible with Pact files)

tjones
2023-06-13 08:51
A contract in this case is a series of request / response examples

zhaopeng
2023-06-13 08:51
Thanks a lot for swift and detailed reply!

tjones
2023-06-13 08:51
There are some bullet points here on why it?s not the same as schema tests: https://case.contract-testing.io/docs/Alternatives/contract-testing-vs-schema

tjones
2023-06-13 08:52
In general, I think it?s best practice to define the tests from the client, as that way you only cover what you actually need

tjones
2023-06-13 08:53
If you define from the provider, you have to guess / unnecessarily cover parts you don?t actually need

zhaopeng
2023-06-13 08:53
in some cases of SDLC, we maybe have API-First driven approach, it means producers manage the schema creation, and build up the "contract"

zhaopeng
2023-06-13 08:54
in another hands, Consumer may don't fully understand/predict the usage properly

zhaopeng
2023-06-13 08:54
maybe I'm wrong? feel very free to correct me

tjones
2023-06-13 08:54
> we maybe have API-First driven approach, This is very common. I also think it?s an industry wide anti-pattern (for the same reason - do you have a shop where the shopkeeper decides what the customers want? No, it would be better to ask the customers first, then buy those things)

tjones
2023-06-13 08:55
> manage the schema creation, and build up the ?contract? I wouldn?t call this a contract, at least from the perspective of contract testing

tjones
2023-06-13 08:55
A contract is a series of examples

tjones
2023-06-13 08:56
Anyway, it?s true that a lot of teams do their API definitions at the server side.

tjones
2023-06-13 08:56
I think the testing tools should support this - even though I don?t think it?s the right way to do it

tjones
2023-06-13 08:56
(with contract tests, you could develop your services in a TDD way - where the consumer just writes tests for the calls it wants to make - this is a very efficient way to develop - but again, I realise most teams wouldn?t want to do that)

tjones
2023-06-13 08:57
So, I built that ContractCase project I linked above. I?m afraid it only works at the moment if both sides are in javascript (or typescript), but support for other languages is under development

zhaopeng
2023-06-13 08:59
> I realise most teams wouldn?t want to do that) That's correct, in a big scale projects, the challenge is not technical, but the communication between consumers and providers. In terms of `ContractCase` , will it support Provider-driven contract test? if yes, may I ask what's the difference between Schema validation(imagine we ensure all API changes detect break schema changes) and `ContractCase`

tjones
2023-06-13 09:02
It already does

tjones
2023-06-13 09:02
but it?s very much in beta

tjones
2023-06-13 09:02
> (imagine we ensure all API changes detect break schema changes) I am imagining this and wondering how you do it

tjones
2023-06-13 09:03
Every team I have heard say that they ensure this can?t happen has at least a few outages per year because of broken contracts

tjones
2023-06-13 09:04
Schema validation misses whole classes of errors. We?ve written about this a lot

tjones
2023-06-13 09:04
I?m just running out the door, but I can leave you a more detailed reply tomorrow

tjones
2023-06-13 09:05
Matt wrote a blog post about it, let me link you


tjones
2023-06-13 09:06
Schemas catch syntax errors - you know the parser won?t break, but will the message have any meaning to the other side? Who knows.

zhaopeng
2023-06-13 09:08
in terms of GRPC https://buf.build/docs/about/, the tool potentially can verify and block the break schema changes. ```Forwards and backwards compatibility is not enforced: While forwards and backwards compatibility is a promise of Protobuf, actually maintaining backwards-compatible Protobuf APIs isn't widely practiced, and is hard to enforce.```

tjones
2023-06-13 09:12
Consider: ```message UserTypeResponse { string userType = 1; }``` If a provider is updated to emit `"User"`, `"Admin"` and `"Moderator"`, but the consumer expects `"User"` and `"Admin"` that is a breaking communication change, but not a breaking protobuf change. Any automated tooling aimed at detecting breaking changes in protobuf will not see this

tjones
2023-06-13 09:12
Similarly, if the consumer expects `user` `moderator` and `admin`

tjones
2023-06-13 09:14
?but that?s a bad protobuf, and you shouldn?t use it like that? Sure, I agree. But, people will. I prefer an automated tool that will catch this

zhaopeng
2023-06-13 09:19
imagine above case, consume only can handle `user` , `admin` , but not `moderator` , in this case, we maybe just miss a unit test/integration test to cover `else` status to check if there is a unknown type. but however if producer decided only to emit `admin` and `moderator` , but remove `user` , schema validation is passed, and it won't impact the consumer's functionality, but maybe a feature is gone completely. in this case, more or less, Contract test seems is protecting the "data" between the consumer and producer.

tjones
2023-06-13 09:20
In that example, yes. I would say that generally it is testing the communication between them.

tjones
2023-06-13 09:21
It?s not a breaking change to remove an endpoint no one is using

tjones
2023-06-13 09:21
Or a field no one is relying on

tjones
2023-06-13 09:22
> schema validation is passed, and it won?t impact the consumer?s functionality, but maybe a feature is gone completely. You can?t tell whether it will or won?t impact the consumer?s functionality from the schema alone

tjones
2023-06-13 09:22
That?s the advantage of the contract test. The contract includes ?this is the response I need?

tjones
2023-06-13 09:22
I really do have to go. Feel free to leave questions and I (or someone else) will answer them later

zhaopeng
2023-06-13 09:28
Thanks a lot @tjones!

matt.fellows
2023-06-13 11:13
One way I have thought making this flow work, would be for a provider to generate and ship the pact tests (or perhaps even just a pact file) with the SDK or client. The client would then need to produce a pact file that is equivalent or a subset of the given pact (assuming it?s not necessarily easy to re-use the tests themselves). If this were true, you?d have better confidence there are no compatibility issues.

james_fraser
2023-06-13 11:19
Hey folks :wave: one of our teams has a project making use of bi-directional contract testing using the Pact-Cypress adapter They?re trying to parallelise their Cypress suite to reduce runtime, which means that they end up with several build steps that each generate a consumer contract file Is there a way to publish these individually or do we need to add an additional step that stitches these contract files together into one file?

matt.fellows
2023-06-13 11:21
hey! Just an FYI that BDCT is a #pactflow specific feature. I think you?re best merging the pact files at the end of that and then uploading - does Cypress have a way of doing that?

matt.fellows
2023-06-13 11:22
there is a `--merge` feature on the `pact-broker publish` command that you could also use. But it may result in lots of build triggers so probably not encouraged

james_fraser
2023-06-13 11:23
Sorry for the wrong channel :sorry: I don?t think Cypress does, it would need to be an extra step in their Github workflow which feels a bit complicated logic-wise I?ll take a look at the `--merge` feature (with caution :smile:), I don?t think we make use of the build triggers for that service so it might be what we need

james_fraser
2023-06-13 11:23
Appreciate the help Matt!

abubics
2023-06-13 11:32
I think a workflow like that might help bootstrap new consumers. It's a lot like the "test consumer" pattern I have historically used to TDD from the API side, so a PoC could be made before the consumer started in earnest.

tjones
2023-06-13 11:58
Yeah. With tools to chop and change contract files that would be really easy. Of course, those tools don?t exist yet (at least for any framework that I know)

tjones
2023-06-13 12:00
As a hack, you might be able to give each one a different consumer name and include them all in the can-i-deploy query. This is somewhat risky though, as what if you forget to update the query?

matt.fellows
2023-06-13 12:21
The hard part is being able to compare two pact files that have the same structure, but different matchers - as the semantics on those comparisons get difficult. But you could imagine starting with a simpler version where that is disallowed, and then basic utilities to splice and dice a pact file would be :chefkiss:

james_fraser
2023-06-13 13:17
Thanks Timothy, I did have a similar thought but yeah updating the query worries me :sweat_smile: the `--merge` feature so far seems to be the ?cleanest? fix

quinton.miller
2023-06-13 16:33
Hey Everyone, I was wondering if someone knows how pact handles cleanup after setting the provider state? Does it do cleanup at all?

ran.tao
2023-06-13 21:46
has joined #general

matt.fellows
2023-06-13 21:49
Some languages have a teardown state. What language are you using? It usually shouldn't matter, what's the issue leaving it around?

prakhar.roy371
2023-06-14 05:21
has joined #general

yonatany
2023-06-14 09:57
The first section I'm adding to pact testing is based on pub-sub events via a message broker. I wonder what the best practice - is to verify the contract - to mock the API call that triggers the message broker insertion or its enough to push it at the closest point to the publish message?

john.joel.thetla
2023-06-14 10:16
has joined #general

matt.fellows
2023-06-14 10:31
Either is okay but I'd take the path that most closely mimics a unit test (so the latter)

payal.chainani
2023-06-14 10:37
Hi, I am able to publish the contracts and retrieve by following this link https://docs.pactflow.io/docs/workshops/ci-cd. Now, I want to understand how I can perform this for On Premise.

yousafn
2023-06-14 10:53
exactly the same but you point at your on prem broker url and creds instead of a hosted one

payal.chainani
2023-06-14 11:27
thank you so much

kedar.ghate
2023-06-14 14:09
Hi team, We use https://vfuk-digital.pactflow.io/ instance of pactflow. From local we are able to run pact-broker can-i-deploy command successfully. From CICD pipeline, it throws error - Error retrieving matrix. Net::HTTPClientException - 403 "Forbidden". I have verified the API token, its valid and working. Could you please suggest what could be the reason and the fix for that.

tjones
2023-06-14 14:19
Try asking in #pactflow, this is for Pact support

kedar.ghate
2023-06-14 14:20
okay

tjones
2023-06-14 14:21
I don?t know anything about pactflow, but a 403 usually means authenticated but not authorised. Are you using the wrong type of token?

kedar.ghate
2023-06-14 14:29
Token is correct, it work from my local when I run same command

drew.bowman
2023-06-14 18:05
has joined #general

andrevdrodrigues
2023-06-14 20:22
Hi team! Im trying to implement pact with grpc in my team. I managed to publish the contract in our pact-broker, however Im facing problems when trying to verify the contract. So, Im using pact-verifier-cli to verify the contract. Is it the better approach? Or is better to use the verification directly in the codebase? Thank you guys :)

tjones
2023-06-15 00:15
I don't know how fully supported grpc is - I assume you're using a plugin? The people in #protobufs would know

andrevdrodrigues
2023-06-15 07:28
Thanks a lot.

devwenzel
2023-06-15 08:26
has joined #general

greg.tyler
2023-06-15 10:21
Hi folks! I recently switched across to the new rust verifier, which is generally providing much better output that the old ruby one (aside from the verification results in Pact Broker being https://github.com/pact-foundation/pact-reference/issues/292 IMO). I?m also finding the pending/WIP pacts functionality much better, but I?ve got a query about that: How do we stop checking pending pacts when they?re outdated? e.g. I create a consumer branch `cool-new-feature`. The provider verification checks it as a pending pact and finds it absolutely cannot comply. So, sadly, I close my branch. But the provider doesn?t know this, and on each build keeps trying to check if it can now match `cool-new-feature`?s interactions. Can/should I tell Pact broker that the branch has closed and the pact doesn?t need verifying? Should I be doing `--include-wip-pacts-since={TODAY}` so it only looks at the most recently updated stuff? Am I completely misusing pending/WIP pacts?

yousafn
2023-06-15 10:30
Hey dude, I'd clean up the pacts from that branch from the broker, so they don't exist.

yousafn
2023-06-15 10:32
assuming you are closing the branch and not planning on reopening it. (do you close and delete in this situ, or just close) if you did reopen, you would anticipate a CI run proceeds again which would publish a pact which is again incompat

greg.tyler
2023-06-15 11:39
Yeah, we close and delete branch. Is there a documented way to do that? I?m imagining I need a GitHub Action that runs on branch/PR close (not merge) and sends an HTTP DELETE to the broker targeting _all_ pacts tagged with that branch name?

tjones
2023-06-15 12:34
On the one hand, sure, that seems reasonable. On the other hand, why does it matter if you?re verifying irrelevant pacts? It shouldn?t fail your build

ronen.yurik
2023-06-15 13:34
has joined #general

ronen.yurik
2023-06-15 13:39
Hi Team, quick question, we are trying pact for contract testing, it will be great to know in which stage you are using/triggering pact? is it in the PR level or once it?s been deployed to test env/staging etc?

matthew.finbury
2023-06-15 13:39
has joined #general

anthony.sharp
2023-06-15 13:43
has joined #general

greg.tyler
2023-06-15 13:45
It just takes up time in the build. It takes about a minute per pact, so if that keeps growing with every experimental PR then our release pipeline is quickly going to get very slow

mariane.leite
2023-06-15 15:25
has joined #general

matt.fellows
2023-06-15 21:55
Every build should run pact tests and publish contracts (consumer) or verify (provider)

matt.fellows
2023-06-15 21:56
> Is there a documented way to do that? I?m imagining I need a GitHub Action that runs on branch/PR close (not merge) and sends an HTTP DELETE to the broker targeting _all_ pacts tagged with that branch name? we would love to build an SCM integration for exactly this purpose - purge/delete dead branches based on closed PRs, deleted branches etc.

matt.fellows
2023-06-15 21:56
But yes, something like this is doable

matt.fellows
2023-06-15 22:10
This API route is what you want - https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/api.rb#LL36C126-L36C126 https://github.com/pact-foundation/pact_broker/blob/master/lib/pact_broker/api/resources/pact_versions_for_branch.rb TL;DR - issue a DELETE request to `/pacts/provider/provider_name/consumer/:consumer_name/branch/:branch_name` But you should probably navigate to it using the HAL relations

yousafn
2023-06-16 08:00
Hello and happy friday :blob-wave: What?s occurring in your world today?

wvkehoe
2023-06-16 10:27
has joined #general

srijan.c
2023-06-16 17:26
Hi. We're in the process of implementing pact in our company. Is there any open source project (in any language or framework) that uses pact extensively that I can read for examples and best practices?

msiles
2023-06-16 17:43
Hi, I was checking the examples here https://github.com/pact-foundation/pact-js

rost.khanyukov
2023-06-16 22:58
has joined #general

tjones
2023-06-16 23:10
Some of the open source NHS code in the uk uses it (eg their covid tracker thing from a few years ago). I don?t have any links handy, I?m afraid

mich.krzyzanowski
2023-06-17 15:22
has joined #general

f.barril
2023-06-18 16:58
has joined #general


tjones
2023-06-19 00:26
Oh yeah! Of course!

ulises.cervino
2023-06-19 13:49
bit of a general question: what?s the best strategy to select consumer versions? I?m thinking of a two step process: 1) verify all branches (this job doesn?t block roll out CI pipelines since it could very well fail a bunch of contracts) 2) verify deployed/latest-main-branch (this one does block a provider branch since a roll out with a red job here means breakages)

matt.fellows
2023-06-19 21:38
WIP and Pending Pacts enables you to do both in the same step. You could separate them out if that?s easier though


matt.fellows
2023-06-19 21:38
or the CI/CD workshop :point_down: (howtolearn)

2023-06-19 21:38
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

tjones
2023-06-20 00:48
> verify all branches You might want "verify all contracts under a certain age", plus main + deployed

tjones
2023-06-20 00:49
> (this one does block a provider branch since a roll out with a red job here means breakages) You don't actually have to block the build. You just have to block deploy.

delboy1978uk
2023-06-20 07:46
has joined #general

ulises.cervino
2023-06-20 09:57
yes, that?s what I meant, block deployments, not the build

ulises.cervino
2023-06-20 09:59
this problem stems mostly from the fact that we can?t do webhooks (networking security stuff); otherwise we?d have a way of verifying with a branch name coming from the env for instance

ulises.cervino
2023-06-20 10:54
in the guides/workshops I couldn?t find/see where exactly one can configure the pact selector to include all consumer versions (perhaps only check latest of every version), would you mind pointing me to the docs for this? Additionally, I was reading about the pending pacts features, but I?m unsure that?s what I want

ulises.cervino
2023-06-20 10:57
```While the provider build may pass, the verification results are still reported (if results publishing is enabled) to the Pact Broker as "failed", as the consumer should not be able to deploy the code that generated this contract.```

ulises.cervino
2023-06-20 10:57
wait, maybe it is exactly what I want

ulises.cervino
2023-06-20 10:57
I want in my CI/CD to only fail if mainbranch/deployed contracts can?t be verified, everything else I?m happy to just publish the result

ulises.cervino
2023-06-20 12:50
ok, it seems I?m not quite understanding how to go about this. I enabled `pending=true` like so ```enablePendingPacts = "true", providerBranch = "master"``` for pact-jvm, and then I ran my provider tests. I know there?s a consumer branch for consumer X with contracts that can?t be successfully verified (for various reasons), however it still didn?t pick up those contracts during the run. Re-reading the docs for `pending` it seems that all this does is _for the main branch/deployed_ allow for failure in cases when the consumer pushed to their main branch/deployed contracts that can?t be verified. And the point is to not block the provider from rolling out. This is good stuff if I got it right, but it doesn?t address my issue of ?publish verifications for all contracts out there?.

ulises.cervino
2023-06-20 12:51
@tjones you said ?You might want ?verify all contracts under a certain age?, plus main + deployed (edited)?, and this sounds about right. How is this achieved? And with pact-jvm, do you know?

ulises.cervino
2023-06-20 13:00
I just ran my provider tests with `includeWipPactsSince = "2023-01-01"` , and it seems like this did the trick

ulises.cervino
2023-06-20 13:01
the result was, in my IDE: 1) contracts for the branch I wasn?t verifying before were included in the run 2) the result of the tests was still `PASS` in the IDE 3) I didn?t publish because IDE but I am hopeful that when this runs in CI/CD a `failed` result will be published

tjones
2023-06-20 14:25
I believe that?s correct, although I thought the JUnit runner showed skipped for the tests that were failing. It might depend on the runner, I?m not sure.

tjones
2023-06-20 14:27
I think you might need wip pacts too? To be honest I?ve never fully understood how pending works. I believe the answers are in the CI/CD workshop linked off the pending page, but I didn?t want to do a workshop when I last needed to know.

tjones
2023-06-20 14:28
I _think_ pending just means that a contract that has never passed is allowed to fail.


tjones
2023-06-20 14:31
WIP pacts are here

tjones
2023-06-20 14:31
It looks like the documentation is better than when I last looked :raised_hands:

tjones
2023-06-20 14:32
I just re-read your last message. It sounds like you got it to work!

ulises.cervino
2023-06-20 19:15
I _think_ so. Thanks for your confirmation. The issue might also lie on the consumer?s side of things (they?re not versioning things correctly I suspect which is making this more difficult than it needs to be).

ulises.cervino
2023-06-20 19:15
thanks for your patience :slightly_smiling_face:

hammid.funsho
2023-06-20 22:18
has joined #general

matt.fellows
2023-06-20 23:28
What confuses most people is that pending and WIP are _relative_ to the provider version doing the verifying. It?s worth reading the two pages I linked above to fully appreciate the differences (https://pact-foundation.slack.com/archives/C5F4KFKR8/p1687210727448039?thread_ts=1687182566.153459&cid=C5F4KFKR8) But I think with those selectors, you will _mostly_ be able to mitigate the lack of webhooks. You could potentially even run them on a schedule, to help ?sweep up? the new consumer contracts that have come through as a sort of poor man?s webhook

ulises.cervino
2023-06-21 06:51
that?s sort of my intention: we have enough merges to the main branch (daily) to not even need a cron job of sorts; this is why I wanted to run things in 2 stages (just reiterating): 1) verify _all_ consumer contracts (maybe only latest of each); this job fails nothing, it just publishes results, this is the workaround the lack of webhooks and 2) verify main-branch/released/deployed for all consumers; this job if it fails blocks roll outs

ulises.cervino
2023-06-21 08:34
> this problem stems mostly from the fact that we can?t do webhooks (networking security stuff); otherwise we?d have a way of verifying with a branch name coming from the env for instance An alternative is for us to have a CI job that takes the branch+consumer name from an env var, and we ask consumers to trigger this job after their publish-contracts job. It?s a bit like webhooks except we don?t go via the broker.

benjamine.nidhin
2023-06-21 12:15
has joined #general

msiles
2023-06-21 15:35
GM team, I?m wondering about the process with contract testing... person in charge of the contract tests(dev/qa) should mock the provider and consumer, is that right? or should that person use the actual API code to make sure we are hitting the endpoints with the correct parameters? Currently what I?m doing is creating the provider/consumer tests and I?m defining the methods with the post/get adding the headers, etc.... but I?m not using the app code, I know what the endpoints are and I?m using Postman to get more information about headers, response, etc. This is the piece that?s not clear to me, should we mockup everything (provider/consumer)? or basically we should use the real API calls from the code? What happens if the devs change something in the actual API code and they don?t tell me, my tests will continue passing because they are not hitting the updated code. Does that make sense?

bas
2023-06-21 17:01
That?s not exactly how contract testing works. Assuming you?re referring to consumer-driven contract testing, you don?t mock anything, that?s taken care of by Pact. You write consumer tests that: ? define expectations about provider behaviour and write those to a contract ? test consumer implementation using a mock generated from the contract by Pact (you get this for free) Contract is then distributed to the provider (through a broker such as PactFlow) and the provider uses that contract to verify that its actual behaviour meets expectations written in the contract. To do so, Pact generates a mock consumer, again, automatically. This image says it all really:

msiles
2023-06-21 19:29
Thanks @bas, in that case the provider is the Real API(When I said real api I mean the code devs are using)

bas
2023-06-21 20:20
Yes, indeed.

msiles
2023-06-21 21:45
interesting, one more question?. based on this example https://github.com/pact-foundation/pact-js/tree/master/examples/e2e what should be the real api? I know it?s just an example but I took that as my base and I?m replacing some URLs to match my API, but as I said before doing that I?m mocking up the API calls.

abubics
2023-06-21 23:22
Usually, in dev, I'd start my local dev API up (in a testing mode so Pact can tell me what states to set up), and run contract verification. In CI, it's the same, just not on my local computer. That's the older way, where you expose a state-change endpoint. There are a few different options, though, depending on what the provider is written in.

matt.fellows
2023-06-22 00:04
> GM team, I?m wondering about the process with contract testing... person in charge of the contract tests(dev/qa) should mock the provider and consumer, is that right? or should that person use the actual API code to make sure we are hitting the endpoints with the correct parameters? The way to think about Pact tests is to treat them as if they were a unit test. Once you have that frame of mind, how you test becomes a lot more obvious. > Currently what I?m doing is creating the provider/consumer tests and I?m defining the methods with the post/get adding the headers, etc.... but I?m not using the app code, I know what the endpoints are and I?m using Postman to get more information about headers, response, etc. This is the piece that?s not clear to me, should we mockup everything (provider/consumer)? or basically we should use the real API calls from the code? You only mock the boundaries, but obviously you want to be testing the behaviour of the code under test. On the consumer side, this is the API client. Usually you wouldn?t have to mock too much here, except of course the API provider (and Pact will provide that mock). On the provider side, this is usually the whole API and you would mock downstream / 3rd party systems > What happens if the devs change something in the actual API code and they don?t tell me, my tests will continue passing because they are not hitting the updated code. Does that make sense? Yes, it makes sense, but you shouldn?t be doing it this way if you go back to the ?it?s a unit test?. Really, these tests should live alongside the code and would change with the code. If your contract tests continue to pass when the implementation changes, you?ve done it wrong. Contract tests aren?t regression tests or acceptance tests to prevent behaviour changes - they can and should change. Pact and the broker will ensure the various components remain compatible

matt.fellows
2023-06-22 00:05
You could possibly even query the PactFlow APIs here to dynamically determine what jobs to trigger (i.e. discover the collaborators), but I can see why you wouldn?t want to get too complicated

tjones
2023-06-22 00:45
Yep. I've done it with pipeline rules before, but it didn't feel super maintainable

msiles
2023-06-22 02:04
Thanks @matt.fellows for the detailed answers. I think this was very productive?

msiles
2023-06-22 04:23
one more thing. Regarding serverless apps, is there any difference in contract testing? or something we need to be aware of

abubics
2023-06-22 04:37
No conceptual difference :slightly_smiling_face: It depends what interfaces you have between consumer and provider, and lifecycle management might be different than long-running processes.

abubics
2023-06-22 04:40
Or, if your serverless setup has message pipelines (e.g. SQS, Websockets, etc), then you'll want to also know about Message Pact.

kuksa.vladyslav
2023-06-22 12:47
has joined #general

suryasaharan
2023-06-22 15:41
has joined #general

gabriel
2023-06-22 21:22
has joined #general

ulises.cervino
2023-06-23 10:57
:nod-hmm-yes: unsure this is easily maintainable; we?d have to keep track of API changes for instance (even if they?re far in between, at some point they might break, and then I moved to another team, etc.)

bgrgincic
2023-06-26 11:00
has joined #general

msiles
2023-06-27 00:01
Hi, probably this is a common question, I have the following test ``` const reports = await getReportByID("xxxxxxxxxxx"); return expect(reports).to.deep.equal(getReportBodyExpectation)``` and it's failing, I got ``` 1.1) has a matching body $ -> Type mismatch: Expected List [{"account":{......... but received Map {"account":{"acco``` the easy fix is removing the [ ] from my json files, but is there a nice way or something that I should take a look

abubics
2023-06-27 00:13
It's valid to use any JSON type as the root of a document, but objects give the greatest flexibility. If your endpoint represents a singular resource (not a list) then removing the list wrapper should be fine. But if it genuinely represents a list of resources, you should consider wrapping it in another object, and giving the list a field name.

matt.fellows
2023-06-27 03:02
Yep, the issue is that your consumer test is expecting an array, but your provider is returning an object

matt.fellows
2023-06-27 03:04
You need to update your test to expect the correct shape the provider actually returns (an object) or modify the API provider to actually return an object of the shape you expect (presumably by working with that team to arrange the modification)

matt.fellows
2023-06-27 03:05
> the easy fix is removing the [ ] from my json files, but is there a nice way or something that I should take a look in case it?s not clear, you never should be modifying the JSON files directly. They represent what your API client is doing (in this case, expecting an array). By removing it from the pact file, you are modifying what the contract captures and potentially deviating from reality - this is likely to result in breakages

svilen.popov
2023-06-27 09:44
has joined #general

matt982
2023-06-27 16:02
has joined #general

eltonlinconl07
2023-06-28 17:30
has joined #general

carlosmmelo
2023-06-29 07:00
has joined #general

prerit.jain849
2023-06-29 09:40
has joined #general

sssona09
2023-06-29 11:12
has joined #general

antonio.blandon
2023-06-29 20:40
has joined #general

msiles
2023-07-01 02:31
@matt.fellows what is it for? owncloud-sdk :thinking_face:

arjun
2023-07-02 04:23
has joined #general

sssona09
2023-07-03 06:16
Hi so I want to setup Pact with my .NET service.How can I set up PACT with the microservice? should i make provider tests? Since we wouldn't have a contract file at this stage, I would comment that part out for now?

abubics
2023-07-03 06:24
Probably best to ask in #pact-net, for .NET-specific questions :)

abubics
2023-07-03 06:25
For starting off with Pact in general, there are plenty of code samples and tutorials.

abubics
2023-07-03 06:25
howtolearn

2023-07-03 06:25
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

abubics
2023-07-03 06:26
I'm not a .NET person, but there should be some samples for that, once you're more familiar with the core concepts.

tjones
2023-07-03 06:36
You can set up verification even if you don't have any pacts. Some pact languages will fail if there are no pacts found, but I believe this is configurable for all.

adwait.damle
2023-07-03 06:39
has joined #general

abubics
2023-07-03 06:40
There was a second Q, I think it already migrated :scream:

sssona09
2023-07-03 06:42
ah ok that?s good! so i can start with setting up my provider tests. I won?t have a consumer expected response to compare to but i can still pretend I do?

tjones
2023-07-03 07:14
Yes, but you won't be testing anything

tjones
2023-07-03 07:15
Alternatively, you could create a fake contract with a fake client. This can help you validate that your service is doing what you think it does, but it won't give you the deployment confidence that proper consumer tests do

sssona09
2023-07-03 07:42
ah okay! that makes sense thank you

romuald.quantin
2023-07-03 11:07
Hi, we?re reviewing the Pact bi-directional flow for our company, any idea how we can turn this unknown status?

romuald.quantin
2023-07-03 11:09
Is it the ?Missing Self Verification Result? that creates this ?compatibility status unknown??

sssona09
2023-07-03 11:35
also, is it usually recommended to mock my API and database for the provider tests? or should i run my service and then test the API calls to the local server? which is more standard?

matt.fellows
2023-07-03 12:08
Thanks for raising in #pactflow after (that?s the right place)

matt.fellows
2023-07-03 12:08
Yes, it?s the missing self-verification result

matt.fellows
2023-07-03 12:09
You just need to set the flags on the publish step e.g. ```... --verification-results /path/to/results.txt \ --verification-results-content-type text/plain \ --verifier readyapi \ --verification-success```

matt.fellows
2023-07-03 12:10
```? pactflow help publish-provider-contract Usage: pactflow publish-provider-contract CONTRACT_FILE ... --provider=PROVIDER -a, --provider-app-version=PROVIDER_APP_VERSION -b, --broker-base-url=BROKER_BASE_URL Options: --provider=PROVIDER # The provider name -a, --provider-app-version=PROVIDER_APP_VERSION # The provider application version -h, [--branch=BRANCH] # Repository branch of the provider version -t, [--tag=TAG] # Tag name for provider version. Can be specified multiple times. [--specification=SPECIFICATION] # The contract specification # Default: oas [--content-type=CONTENT_TYPE] # The content type. eg. application/yml [--verification-success], [--no-verification-success] # Whether or not the self verification passed successfully. [--verification-exit-code=N] # The exit code of the verification process. Can be used instead of --verification-success|--no-verification-success for a simpler build script. [--verification-results=VERIFICATION_RESULTS] # The path to the file containing the output from the verification process [--verification-results-content-type=VERIFICATION_RESULTS_CONTENT_TYPE] # The content type of the verification output eg. text/plain, application/yaml [--verification-results-format=VERIFICATION_RESULTS_FORMAT] # The format of the verification output eg. junit, text [--verifier=VERIFIER] # The tool used to verify the provider contract [--verifier-version=VERIFIER_VERSION] # The version of the tool used to verify the provider contract -o, [--output=OUTPUT] # json or text # Default: text -b, --broker-base-url=BROKER_BASE_URL # The base URL of the Pact Broker -u, [--broker-username=BROKER_USERNAME] # Pact Broker basic auth username -p, [--broker-password=BROKER_PASSWORD] # Pact Broker basic auth password -k, [--broker-token=BROKER_TOKEN] # Pact Broker bearer token -v, [--verbose], [--no-verbose] # Verbose output. Default: false```

tjones
2023-07-03 12:32
Mock as little as possible. We might need more details to understand the question well enough to answer clearly though

stan.amsellem
2023-07-03 14:00
has joined #general

cobookman
2023-07-03 21:14
has joined #general

anshu.behera.02
2023-07-04 07:01
has joined #general

romuald.quantin
2023-07-04 08:19
Awesome, I?ll look at that, thank you @matt.fellows

adam.strawson
2023-07-04 13:24
has joined #general

2023-07-04 13:28
This message was deleted.

tjones
2023-07-04 14:52
I think you?re using #pactflow Pact has no bi-directional flow.

tjones
2023-07-04 14:53
(I haven?t used Vercel, so I don?t know about the rest of your question)

adam.strawson
2023-07-04 14:58
Ah, thanks for the clarification - I'll x-post there :+1:

mathewsa
2023-07-04 15:20
has joined #general

olopezs
2023-07-04 16:03
has joined #general

nithesh
2023-07-05 08:14
has joined #general

andre.tartarelli
2023-07-05 11:26
has joined #general

laura.huysamen
2023-07-05 12:38
has joined #general

goatleyj11
2023-07-05 12:43
has joined #general

rabrosimov
2023-07-05 14:51
Hi there! Quick question about best practices. Do we need to keep `pact.json` file in git or is it better to remove it from git? Thanks

yousafn
2023-07-05 15:23
we suggest they aren?t checked in, as they are an artefact of each ci build

lily.oconnell
2023-07-05 15:32
has joined #general

rabrosimov
2023-07-05 16:15
Thanks

eddie
2023-07-05 19:47
Hey, This page https://docs.pact.io/pact_broker/recording_deployments_and_releases#application-instances says that application instances shouldn't be used for blue/green or other long running deployments. But it doesn't say what should be used instead...

eddie
2023-07-05 19:48
We're leaning towards modelling as separate consumers (stable + canary) but wasn't sure if this is correct

mohanraj.r
2023-07-05 19:53
has joined #general

paul.caplan
2023-07-05 22:48
Hi team! Question about using Pact contracts to stub external API calls for UI integration tests running in the CI pipeline. I know, don?t do it, we?re gonna have a Bad Time? - docs make that very clear, as does https://pactflow.io/blog/a-disastrous-tale-of-ui-testing-with-pact/. We (@rabrosimov) followed the recommendation in that article, and got the https://github.com/pact-foundation/pact-mock_service#stub-service-usage running and it works like a charm, very impressive! And yet ? I?m struggling to understand the difference between this approach vs making everything a ?contract test?. For the approach of stubs to actually work, we still need a matching contract to exist supporting every UI test. I think the article is cautioning against perhaps using UI tests to somehow *generate* the contract that is being used, e.g. if we have 10 different tests that are calling same API, we would have 10 different versions of the contract for the same API (= bad). And pact stub server is better because .. it allows us to reuse a single contract across those 10 tests? But what if we had a way to reuse contracts across tests *without* using pact stub server? What we have now is: 1. Contract test for API call 1 2. Contract test for API call 2 3. Integration test for UI. Code is calling both API 1 and API 2, both calls hit back stub server, it downloads all the pacts and it matches them to the request and returns appropriate JSON response. However, we have also implemented an alternate approach that avoids the need for using the stub server. We still have a contract test for API call 1 and 2. However, we extracted the pact contract declaration (`api_client.upon_receiving('api 1')...`) to a ?shared context? (rspec ruby thing) and that shared context in the contract test. Then, in the integration test for the UI, we include the contract for both API calls, something like: ```include_context 'api_1' include_context 'api_2'``` It seems to achieve the same exact result with a slightly different way of implementing. It?s not going to automagically find all the correct matching contracts to use; on the other hand it is more explicit in terms of being able to inspect which contracts are actually being stubbed out by Pact for a given test. Any concerns with this latter approach? It seems that the key to maintainability with *either approach*, again, is to minimize the number of contracts for a given single API.

tjones
2023-07-06 00:28
You're right that the key point is maintainability. The issue with driving tests through the UI is that you won't always have the context about what exactly the API call should be when you are modifying the UI. And, if you modify the API, you don't want to modify the UI tests either

tjones
2023-07-06 00:28
if you have some way of solving that, then I suppose it's ok. It's up to you.

tjones
2023-07-06 00:29
Personally, I: ? Stub the API during UI tests (the code layer at the entry point to your client code, not at the network layer) ? Ensure that stubbed client does the same as the real client by using contract tests

tjones
2023-07-06 00:30
> Integration test for UI. Code is calling both API 1 and API 2, both calls hit back stub server, it downloads all the pacts and it matches them to the request and returns appropriate JSON response. I think this is probably just as much maintenance effort as the first-class contract test approach

tjones
2023-07-06 00:35
> It seems to achieve the same exact result with a slightly different way of implementing. Yes, I agree. I think you'll risk frustrating test maintenance with either approach.

matt.fellows
2023-07-06 01:01
> e.g. if we have 10 different tests that are calling same API, we would have 10 different versions of the contract for the same API (= bad) Yes, this is one of the key problems (and thanks for reading the guidance in advance :pray: ). If you can avoid that, half of the maintenance problems go away. In my experience, most of the pain with UI tests is pushed to the API provider. So anything you can do to improve situation that is likely to make it more workable.

matt.fellows
2023-07-06 01:02
A lot of this comes down to specificity in the tests themselves, ideally, it?s as close to a unit test context as possible (to achieve specificity) but that?s not the _only_ way. It sounds like you?re thinking about it, which is probably half the battle - going in with open eyes and looking for the problems

ianlutz
2023-07-06 01:34
has joined #general

rohit.m.patil27
2023-07-06 03:51
has joined #general

timo.schwarzer
2023-07-06 06:18
has joined #general

kuntol.banerjee
2023-07-06 06:54
has joined #general

adebakre
2023-07-06 11:28
has joined #general

paul.caplan
2023-07-06 13:35
thanks all!

grace.tree
2023-07-06 17:02
I have a question about a solution being a Pact Recipe vs being on the Pact Docs page. Who could I speak to from the Pact Foundation about this? :slightly_smiling_face:

rajkumarbapuvrs
2023-07-06 17:35
has joined #general

yousafn
2023-07-06 17:55
Hiya, sounds exciting, feel free to share details and propose a draft page - the site is open source and one github, there are instructions in the readme for running locally, if you want to see how it looks :+1: We?ve got some updates due, gRPC, api gateways, database replication/event streaming , the content is around, just not super user friendly atm

jorge.carneiro
2023-07-07 09:43
has joined #general

carlleferink
2023-07-07 12:01
has joined #general

anju.ashk
2023-07-10 07:39
has joined #general

rmahadeorathod
2023-07-10 09:48
has joined #general

ekaterina.essina
2023-07-10 09:59
has joined #general

arca.artem
2023-07-10 10:00
has joined #general

connor.stevens
2023-07-10 11:35
has joined #general

pgeurtsen
2023-07-11 07:30
has joined #general

rjurca
2023-07-11 08:22
has joined #general

frederic.vaugeois
2023-07-11 14:12
has joined #general

marko.lamberg
2023-07-11 15:27
has joined #general

lshilling
2023-07-12 09:31
has joined #general

mwilso29
2023-07-12 14:44
Hello all. Random Question. Can you upload an open api spec for a bi-directional contract test to the https://github.com/pact-foundation/pact_broker? Or is that functionality just for pactflow?

yousafn
2023-07-12 14:45
:wave: BDCT is a PactFlow only feature I?m afraid

mwilso29
2023-07-12 14:46
No worries thanks!

yousafn
2023-07-12 14:49
There are some related issues in the open source project for supporting alternate contract types https://github.com/pact-foundation/pact_broker/issues/603 https://github.com/pact-foundation/pact_broker/issues/302 https://github.com/pact-foundation/pact-specification/issues/76 Pact can support verification results provided by alternate means that a Pact provider verification, which means you _could_ perform it to some degree, although not officially supported (its an API route exposed in the pact broker)

mwilso29
2023-07-12 14:59
Is Pactflow only available online? As in it cannot be ran in the same way locally as the pact-broker can be?

yousafn
2023-07-12 15:02
The enterprise version can be used as self-hosted but all other tiers are SaaS only I am afriad

mwilso29
2023-07-12 15:54
Self-hosted was the word missing from my brain there. Thanks

tjones
2023-07-12 16:57
Pactflow is not Pact.

tjones
2023-07-12 16:58
See #pactflow

rudydc
2023-07-12 17:53
has joined #general

wesley.newcomb
2023-07-13 15:54
has joined #general

joris.vaneijden
2023-07-14 10:56
has joined #general

tushar.adsul223
2023-07-14 15:29
has joined #general

mahesh.damavarapu
2023-07-17 10:12
Hello All, When i am running provider tests. Getting the following error. Can someone help me with this please ```1) Pact Verification validates the contract provided by the consumer: Error: pactffiVerifierBrokerSourceWithSelectors(arg 10) expected an array of strings```

matt.fellows
2023-07-17 10:32
Looks like a Pact JS issue. Mind asking in #pact-js with a little more detail on the question? My guess is that you?re passing the wrong value into a property somewhere, but that bug should be caught before that problem so there is definitely a bug

francisco.almeida
2023-07-17 11:35
has joined #general

mike.lovely
2023-07-17 12:12
has joined #general

kyam.harris_pact
2023-07-17 12:51
has joined #general

drettie
2023-07-17 13:23
has joined #general

mburns
2023-07-17 13:24
has joined #general

amit.jadhav
2023-07-18 06:19
has joined #general

aljaz.klanecek
2023-07-18 08:58
has joined #general

amitw
2023-07-18 15:15
has joined #general

fkelly
2023-07-18 17:28
has joined #general

phananhdung104
2023-07-18 18:28
has joined #general

gurubabu.jampala
2023-07-19 01:02
has joined #general

ben.brugman
2023-07-19 08:06
Hi all, I am quite new to PACT and contract based testing. And i was wondering, do you have or need assertions in the unit tests that generate the PACTs? What is your view on this? Tnx

yousafn
2023-07-19 08:08
hey, Pact the framework, generates pact files. ( note none are all uppercased ) and yes, without assertions what are you testing on the consumer side? that you can call your provider. you wouldn?t be checking your code actually does something with that response. also the target of those assertions isn?t to test the provider but to test the consumer in known scenarios

ben.brugman
2023-07-19 08:41
Hi Yousaf, Thank you for your reply. just to verify, checking if the consumer can work with the response could also be handled in other tests right? or is it best practice that you enhance the existing unit tests with the creation of the Pact?

yousafn
2023-07-19 09:47
I would replace your mocked provider with pact, in your existing unit tests, otherwise it sounds like a duplication of effort

a.kravchenko357
2023-07-19 11:03
has joined #general

matt.fellows
2023-07-19 12:10
The way I think about it, is to start with the goal of writing a good set of unit tests for your API client. An important side-effect of doing this with Pact is that you also produce an API contract you can use for contract testing. I said this so many times, I put it as the golden rule here: https://docs.pact.io/consumer I think once you think about contract tests in this way, many other questions fall into place (e.g. which layer to stub)

matt.fellows
2023-07-19 12:11
So the answer would probably be ?yes?. You should have assertions, just don?t assert that the API client got the data back (because Pact will do this). Assert on the behaviour of your API client

thiagotrinta
2023-07-19 20:00
has joined #general

divya.parappanavar
2023-07-20 06:59
Hi Team, I have a query. Once the Provider publishes the verification results to Pactflow, Is there any feature in Pact for sending the notification like email, message or logs to Consumer? Or Consumer needs to login to the Pactflow account to see the status after verification result got published by Provider into Pactflow account? If any notification feature is available, Can you pls send me the link for the same.

matt.fellows
2023-07-20 07:12
see webhooks: https://docs.pact.io/pact_broker/webhooks (this applies whether or not you?re using PactFlow)

divya.parappanavar
2023-07-20 07:15
This webhook triggers the event again to verify the pact between consumer and provider still holds. What I want to know is whenever Provider publishes the verification results, will the consumer be notified with any notification like email?

matt.fellows
2023-07-20 07:21
no, there would be a lot of emails if that were the case. But there is a webhook for that and you can do what you wish with it

abubics
2023-07-20 07:23
Usually we don't need notifications from Pact infrastructure directly, because we get other kinds of feedback (e.g. broken builds) if action is required.

divya.parappanavar
2023-07-20 07:23
Ok.. So webhook is used to trigger the request automatically whenever there is a change in the Pact right?

abubics
2023-07-20 07:24
Yeah, usually the change webhook would trigger a build on the other side of the contract.

matt.fellows
2023-07-20 07:24
what do you want the consumer to do with the information that a contract has been verified? (let?s start here and work backwards)

divya.parappanavar
2023-07-20 07:26
We wanted to just inform the consumer whether the pact status is success or failure instead of Consumer logging into the Pact account and checking the status himself.

matt.fellows
2023-07-20 07:29
why do they need to know it passes? And follow up, _when_ do they need to know?

matt.fellows
2023-07-20 07:31
If you have a PR that needs a result before it can be merged, you can use the webhook to send build status checks and unlock the merge button e.g. https://pactflow.io/blog/publishing-pact-verification-statuses-to-github/ (you can use that same webhook to send slack or other notifications too)

matt.fellows
2023-07-20 07:31
to @abubics?s point though, these things should be tied to your CI/build system

divya.parappanavar
2023-07-20 07:33
Let me go through Webhook in detail. Thanks for the info.

lotem.dagan
2023-07-20 10:48
has joined #general

cmesyngi
2023-07-20 20:56
has joined #general

alan.barker
2023-07-21 09:47
has joined #general

vijaya.balla.external
2023-07-21 15:06
has joined #general

ben.brugman
2023-07-21 19:17
Thanks for the replies :pray:

dennis1125dennis
2023-07-22 02:30
has joined #general

muhammedalimutlu
2023-07-23 18:40
has joined #general

eddie
2023-07-23 23:58
Is there any general advice for consumer-driven contract tests when the request path includes a proxy/aggregator component? Our scenario is roughly SPA => BFF => ExtractionService ? The BFF (backend for frontend) acts as a _provider_ in the SPA => BFF interaction ? The BFF acts a _consumer_ in the BFF => ExtractionService interaction The BFF is basically just making requests "on behalf of " the SPA and relaying responses verbatim. There is a _logical_ contract between the SPA and the ExtractionService. It seems wasteful to set up two sets of tests - _particularly_, the provider-state setup that influences the shape of the response

abubics
2023-07-24 01:30
I think the advice has historically been "if it's just a pass-through, don't test it", but "if it has logic, test it". And there's a big grey area between those, usually :yay: Someone might have a more up-to-date answer, or even a docs/blog article to link, though . . .

dennis1125dennis
2023-07-24 01:35
Hey guys, I just joined in this Slack server, and I am very glad to meet you all. :heart_eyes: I am Dennis from Canada, and Web developer having 6 years of experience. (https://dennis-stephens.vercel.app) I want to be connected with people in this server, and maybe we'll have same fields of interests and could collaborate in the future. If you are interesting, please feel free to send a message.

eddie
2023-07-24 01:36
Sure - but it *is* important that the logical contract between the SPA and the ExtractionService gets tested - whether transitively or directly

eddie
2023-07-24 01:37
Otherwise a new build of the ExtractionService could get deployed which would break the SPA

abubics
2023-07-24 01:48
So yeah, in the grey area, there are questions like "will a smoke test suffice?" (i.e. if the service has connectivity, and we check a small number of requests, do we have confidence that the rest will be fine, too?). It greatly depends on how much logic/mapping there is.

abubics
2023-07-24 01:48
e.g. I wouldn't write full-coverage contract tests for an nginx layer

eddie
2023-07-24 01:49
So it seems our options are to either ? _lie_, and publish an interaction between the SPA and the ExtractionService (no such interaction _actually_ exists) ? It's kind of a white lie though, right? ....right? ? Publish two sets of interactions (SPA -> BFF and BFF -> ExtractionService) with the pain that this entails

abubics
2023-07-24 01:58
kinda

abubics
2023-07-24 01:59
full-coverage contract tests can be misused for brute-force confidence


abubics
2023-07-24 02:00
The directing questions will be things like ? What problem are you trying to solve? ? How much confidence are you missing? ? What options are there for increasing said confidence?

abubics
2023-07-24 02:01
So, if you have confidence that the pass-through will pass everything through leanly (e.g. a router or a switch, nginx maybe, etc), then it doesn't affect the contract, it's just an infrastructure dependency, that could be tested in other ways.

eddie
2023-07-24 02:02
> then it doesn't affect the contract, it's just an infrastructure dependency, that could be tested in other ways To be clear, I'm not worried about not testing the pass-through layer. I'm more worried that we *do* test the (logical) contract between the SPA and the ExtractionService

abubics
2023-07-24 02:02
But if there's any logic (e.g. body or URL transformations, filters on paths, WAF rules, splitting chunks of requests to different back-end services, etc), then it gets harder to decide where to draw the lines.

eddie
2023-07-24 02:03
Thanks - gives me some things to think about.

abubics
2023-07-24 02:04
that's a good start, then :sweat_smile: unfortunately, a lot of the interesting questions have very "it depends" answers :upside_down_face:

matt.fellows
2023-07-24 05:20
FYI courtesy some https://github.com/pact-foundation/docs.pact.io/pull/275 by @yousafn Nabi we have updated the Nirvana guide to reflect the use of branches, releases and environments: https://docs.pact.io/pact_nirvana. The diagrams are written in mermaid JS and are :chef-kiss: . I want to make more diagrams because the experience is so good. Anyway, please enjoy :fork_and_knife:

tjones
2023-07-24 05:33
I have a solution for this, planned but not documented, as part of https://case.contract-testing.io/

tjones
2023-07-24 05:34
Essentially the idea is that you have "transforming verifications" - where you write the contract at the SPA, do the verification at the proxy, that verification produces and a transformed contract (which is asserted the same way as a regular client contract would be)

tjones
2023-07-24 05:34
then you can verify that contract agains the real provider like you normally would

tjones
2023-07-24 05:35
ContractCase doesn't actually do this yet, but you could borrow the idea and build something custom that works for you on top of Pact

abubics
2023-07-24 05:58
Looks great, nice work :tada:

abubics
2023-07-24 06:00
(Some of the diagram lines are dark-on-dark in dark mode, and it's a bit hard to intuit the intent between the 2 diamond diagrams, but looks good at a glance!)

matt.fellows
2023-07-24 06:14
thanks

matt.fellows
2023-07-24 06:15
We started by replacing the existing diagrams, and I must admit when re-doing the two diamond ones I had the same thought

matt.fellows
2023-07-24 06:15
> Some of the diagram lines are dark-on-dark in dark mode, and it?s a bit hard to intuit Good call. I?ll see if there is a ?dark mode? in mermaid to handle it

matt.fellows
2023-07-24 06:16
yikes!

abubics
2023-07-24 06:16
It might be as simple as a title update :yay: I haven't got bandwidth to actually comprehend the diagrams right now :sweat_smile:

matt.fellows
2023-07-24 06:16
conversely, not dark-mode

abubics
2023-07-24 06:17
yeah, light mode diagrams look great! but I like having uncharred retinas :sunglasses:

abubics
2023-07-24 06:17
(of course, I just changed the mode to check)

matt.fellows
2023-07-24 06:19
OK turns out that was easily fixed. In a few mins, they should look like this in dark mode

abubics
2023-07-24 06:19
amazing!

matt.fellows
2023-07-24 06:19
more like ?phew?

matt.fellows
2023-07-24 06:27
> Essentially the idea is that you have ?transforming verifications? - where you write the contract at the SPA, do the verification at the proxy, that verification produces and a transformed contract (which is asserted the same way as a regular client contract would be) I remember you talking about it at lunch once, but I never fully followed it, specifically, how it solved the problem. There are two http://localhost:3000/recipes/apigateway (broadly) of this problem: 1. Pure transform aka the classic API gateway (often, this is pure configuration/infra). The hard problem here, usually, is that there is little code to test and it can be cumbersome to setup the testing scenarios. 2. There is some more complex logic going on (combining APIs, orchestration, choreography, etc.). The problem here, is that if you are using tools like Layer7/Apigee/Axway etc. then you?re in a real spot because they are very hard to test, but you can?t get away with just mapping or ignoring bits because they do way to much. I posited a while back that for (1) we could potentially just allow a configuration file be uploaded from the provider that documents the mapping, and we somehow ?overlay? that into the verification process. I like that terminology - and it describes a broader concept that could be reused, for sure.

tjones
2023-07-24 07:41
Most cases are like ?we swap the auth headers? or ?we change the path? - those are easy. For the rest, you?d run the mock in a capture mode. Pact doesn?t support this, of course

tjones
2023-07-24 07:42
I don?t like the idea of uploading a mapping. You?d be back in spec land.

tjones
2023-07-24 07:44
To get equivalent confidence to no proxy, you have to actually test the proxy. It gets fiddly with api gateway products that allow complicated setups, but it is not impossible

matt.fellows
2023-07-24 08:10
> For the rest, you?d run the mock in a capture mode. which mock are we talking about here? The mock that the gateway would use? i.e. you would do a VCR style test?

matt.fellows
2023-07-24 08:10
> I don?t like the idea of uploading a mapping. You?d be back in spec land. agreed, it was just an idea at the time (and it?s gone nowhere, probably in part because it?s not a good idea :laughing: )

tjones
2023-07-24 09:13
The approach looks like this: ```Mock Client (running the contract verification as normal) -> Proxy -> Mock Server (running contract definition, as you normally would at the client)``` You would run the Mock Server in a "capture" mode, where you go "ok, capture the request, and return this response"

bheemreddy181
2023-07-24 14:08
Quick question if we wanted to maintain same version for the api and don?t want to introduce more mandatory fields so we are backward compatible how do we introduce those fields ( make them optional ) ?

doug.hanke
2023-07-24 17:53
has joined #general

abubics
2023-07-25 00:05
You mean, how do you specify optional fields (e.g. to let people know they exist, but won't break tests)?

abubics
2023-07-25 00:06
also: in the request or in the response? (I can imagine some different approaches)

bheemreddy181
2023-07-25 00:13
Yes mainly in the request

abubics
2023-07-25 01:20
In a consumer request you can specify extra fields that aren't load-bearing. It's up to the provider to care about if it needs them or not. Without that, you'd probably have trouble with the grow-then-shrink approach.

abubics
2023-07-25 01:20
But if the provider starts responding differently based upon whether those optional fields are present or not, that'll be a breaking change (which you should notice by the contract changing).

bheemreddy181
2023-07-25 03:55
So we end up versioning or keeping the required field behind a feature flag ?

abubics
2023-07-25 04:46
Might be easier to explain with a concrete example.

abubics
2023-07-25 04:47
If you're saying "the consumer will always send this field" then it's not "mandatory/required". If you're saying "the provider will always expect this new field" then it's mandatory/required and also a breaking change.

abubics
2023-07-25 04:49
If the provider opportunistically uses an optional field, but behaves the same if its missing, then its not a breaking change.

abubics
2023-07-25 04:49
And you can have a test for each case.

sameswar.khuntia
2023-07-25 10:17
has joined #general

michal.mirecki
2023-07-25 10:28
has joined #general

bheemreddy181
2023-07-25 14:20
How about this - Add a new optional key - change the behavior based on this key present, retain the old behavior if the key doesn?t exist, and once all consumers start sending the key make it mandatory ( consumers should know once they start sending this eventually this will be made mandatory ) , if consumer wants to retain the old behavior then maintain this as optional

bheemreddy181
2023-07-25 14:20
@matt.fellows what do you think ?

jeremyjpark
2023-07-25 15:30
has joined #general

chetana.mahangare
2023-07-25 15:57
has joined #general

simondemartini
2023-07-25 18:28
If we have a library that's used by a bunch of apps and abstracts away the actual API calls to the provider service, -- is it recommended that the library itself writes a consumer contract? Rather than the apps that use the library? It seems to me that the library should be writing its own consumer contract and using `record-release` but I haven't seen much guidance on that on the site

remington.otoole
2023-07-25 18:47
Hello! Question for you all: When the consumer is creating a mock response of the provider using PactDslJsonBody, do we have feasibility of defining optional parameters in response body ? For example, consumer defines params A,B and C(as Optional) in mock response. Now when provider runs its unit test against this pact , the actual response of provider contains only A and B. This test should pass as param C in Pact is Optional. Could you please clarify if such type of feasibility is there in Pact or not?

kwan
2023-07-25 18:49
has joined #general

matt.fellows
2023-07-25 21:29
See howtooptional


matt.fellows
2023-07-25 22:47
> Might be easier to explain with a concrete example. I agree with this point, it would be good to understand the example

matt.fellows
2023-07-25 22:47
also, hello again Bheem! :wave:

abubics
2023-07-25 22:55
Yep, that sounds right. Just be aware that making it mandatory is technically a breaking change. If you have tests for the case where it's missing, they should change, and/or be removed.

tjones
2023-07-26 02:18
Usually you'd do it in the library, yes. Then each user of the library would publish the library contract along with its contract. There is a disadvantage to that strategy, which is that you don't know if the users of the library are actually using all of the interactions in the contract, or all of the response data

tjones
2023-07-26 02:19
The alternative is for each service to write their own contract around the library calls. The disadvantage of that approach is that the services using the library need to know the details of the request / response

simondemartini
2023-07-26 02:33
Interesting are there docs/examples of this on the pact site? I didn?t see any that I could find about libraries like this specifically

tjones
2023-07-26 03:03
I don't think so

venkatesh.civic
2023-07-26 16:49
has joined #general

bartlomiej
2023-07-26 18:06
has joined #general

wongkoonwai
2023-07-27 03:14
has joined #general

conrad.john
2023-07-27 08:37
has joined #general

ajit.kumar
2023-07-27 11:37
has joined #general

marekurbanowicz
2023-07-27 12:40
has joined #general

maciej.krakowiak
2023-07-27 13:28
has joined #general

mateusz.luty
2023-07-27 13:29
has joined #general

pact259
2023-07-27 23:19
has joined #general

guozhangliew
2023-07-28 06:29
Hi guys I published my pact with producer and consumer currently it is tag to my pull request branch do I need to tag it to my `main` as well ? how should I organise this?

matt.fellows
2023-07-28 06:55
I'm not sure I follow the question But to use branches, you would set the branch in the Pact CLI publish command (consumer side) and on the verification options (provider side)

matt.fellows
2023-07-28 06:55
Howtocli


guozhangliew
2023-07-28 06:59
so the above is the pacts I published from my CI successfully but when I created another branch my tests is failing because of ```2023-07-28T03:52:17.177190Z ERROR ThreadId(03) pact_verifier: Failed to load pact - Could not load pacts from pact broker Link/Resource was not found - No pacts were found for this provider``` thats why im curious if I need to tag my pacts to `main` so the other pull request running CI can verify on

matt.fellows
2023-07-28 06:59
How are you telling the provider build to discover the pacts?

matt.fellows
2023-07-28 07:00
What's the configuration?

guozhangliew
2023-07-28 07:01
this is how my provider is configured ``` const p = new MessageProviderPact({ messageProviders: { 'publish generate keypair': providerWithMetadata( async () => { const mockKeypair = { keyPair: { publicKey: {}, privateKey: {}, }, expiration: 1721191988872, notBefore: 1689655988872, kid: '68d371b2-0b1e-4921-9f03-06987f3645a1', alg: 'ES256', }; return getGenerateKeypairEvent({ result: mockKeypair }); }, { 'content-type': 'application/json', } ), }, logLevel: LOG_LEVEL as LogLevel, provider: 'KafkaGenerateKeyPairProvider', ...(BROKER_URL ? { // Broker validation pactBrokerUrl: BROKER_URL, pactBrokerUsername: process.env.PACT_BROKER_USERNAME, pactBrokerPassword: process.env.PACT_BROKER_PASSWORD, providerVersionBranch: process.env.GIT_BRANCH, } : { // For local validation pactUrls: [path.resolve(process.cwd(), 'pacts')], }), consumerVersionSelectors: [ { matchingBranch: true, }, ], });```

matt.fellows
2023-07-28 07:01
Do the branches line up?

matt.fellows
2023-07-28 07:03
I'd also recommend using the setup here if you missed it: https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors#recommended

guozhangliew
2023-07-28 07:05
where do I set it for the pact_broker ? Im using the pact-broker cli to publish currently ``` pact-broker publish pacts --verbose --consumer-app-version $$BUILDKITE_COMMIT --tag-with-git-branch```

guozhangliew
2023-07-28 07:06
or is this something I configure when deploying my pact-broker container?

matt.fellows
2023-07-28 07:07
I'm asking if the provider's branch matches the consumer's

guozhangliew
2023-07-28 07:08
nope it doesnt the provider is tagged on a separate branch so is the consumer

matt.fellows
2023-07-28 07:10
So the matching branch selector won't work for you

matt.fellows
2023-07-28 07:10
Have a read of the above guide, it should help

matt.fellows
2023-07-28 07:11
The issue is you're saying "find all pacts that use the same branch as me" but there are no pacts with the same branch name

matt.fellows
2023-07-28 07:11
I'd also highly recommend the CI/CD guide: howtolearn

2023-07-28 07:11
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

guozhangliew
2023-07-28 07:15
alright thanks Matt will check it out! would you also know any pacts examples done using https://buildkite.com/?

matt.fellows
2023-07-28 07:18
We'll, we use it at PactFlow but nothing publi

matt.fellows
2023-07-28 07:18
It should matter the CI you use

guozhangliew
2023-07-28 07:19
yep all good mate I will implement the concepts :ok_hand: thanks!

grace.tree
2023-07-28 10:22
Hi, I?m still working on the recipe (proposed draft will be up soon). I?m looking at doing another DevOps Playground meetup event using Pact at the end of August. Similar to the one I did last year with dotnet. This time would be on the contents of the recipe. Youtube: https://www.youtube.com/watch?v=VDigIOV7lzM Meetup: online example: https://www.meetup.com/devopsplayground/events/287778275/ Meetup inperson example: https://www.meetup.com/devopsplayground/events/287778167/ It would be in London this time. I was wondering if the Pact Foundation would be up for giving some swag/merch for the event? We like to give out stickers and things to those who attend in person. :slightly_smiling_face:

yousafn
2023-07-28 10:26
I attended the one last year, it was great. We have a good few members in London, so hopefully you may get some attendees from here. I?ve popped a link to the q in our maintainers channel https://pact-foundation.slack.com/archives/C05HCLA3C93/p1690539885322109

grace.tree
2023-07-28 10:30
thank you!

yousafn
2023-07-28 10:32
:blobwave: Happy Friday Pact peeps! A-lot has been happening in the Pact ecosystem over the last 2 months. Have a read of the latest Pact Update in our July 2023 blog post https://docs.pact.io/blog/2023/07/28/pact-open-source-update-july-2023 Want to feature in the next one? Why not give us a shout! > :wave: Hello, its July, it?s scorching so I hope you?ve got an ice cream to accompany you this episode or maybe a brolly if you are stuck in a rain-shower! > For the keener of our readers, you may note we missed our June episode. I was on holiday ( a rare treat! ) which was spent mainly away from the keyboard, with the exception of a little flurry in pact-python. > Never fear, a double-dose of Pact Open Source updates are here!

hetal.patel
2023-07-28 14:04
has joined #general

thatrandybrown
2023-07-28 16:49
has joined #general

matt.fellows
2023-07-28 23:55
Awesome, this sounds great

matt.fellows
2023-07-28 23:55
I?d love to support it however we can

michael072
2023-07-29 03:08
has joined #general

selniumtrainer
2023-07-29 08:10
has joined #general

raylincontact
2023-07-31 01:51
has joined #general

ext-damian.rudzinski
2023-07-31 10:01
has joined #general

rostas.laszlo.dev
2023-07-31 11:27
has joined #general

anubhuti.shrivastava
2023-08-01 07:35
has joined #general

pavikrish
2023-08-01 07:45
has joined #general

arnoldsi
2023-08-01 15:09
has joined #general

2023-08-01 17:39
This message was deleted.

yousafn
2023-08-01 21:30
The general advice for pretty much all classes of unit testing (and probably further up the stack) is to test in the codebase of the code being tested. For a variety of reasons, but the main over-riding one for Pact is that you want your contracts to change as an artefact of running tests on the changed code, The further away this test, the slower the feedback loop, the greater cost of change, and the potential for expectation drift (that which you present to the provider, and that of which your consumer code actually performs)

yousafn
2023-08-01 21:33
ps. Generally I wouldn?t preface questions with a quick question, as it is subjective to the reader to whom you are asking, and it may put them off.

yousafn
2023-08-01 21:34
Quick answer would be no Slightly longer answer, would be yes, its perfectly possible, but wholly unrecommended then reasons above

matt.fellows
2023-08-01 23:27
If you think of a Pact consumer test as a unit test of your API consumer, then you can see why it wouldn?t make sense to do it that way (a centralised repo)

abubics
2023-08-02 05:19
Quick question, long answer :yay:

stefan.waldhauser
2023-08-02 13:45
has joined #general

phillip.lo
2023-08-02 16:36
is the recommendation to check the can-i-deploy against all of the environments (non-prod and prod) for consumer PR pipelines or should they only check if the provider has verified their `main` branch and/or the first non-prod env? As in, if the provider has not deployed to production yet with a valid verification, the consumer shouldnt be able to merge their PR with the contract?

shadman.equebal140
2023-08-02 19:20
has joined #general

matt.fellows
2023-08-02 21:40
The ideal flow would be a `can-i-merge` check, which https://github.com/pact-foundation/pact_broker-client/issues/138 should address when merged

matt.fellows
2023-08-02 21:41
I don?t think you need to check against all environments, but it really depends on your workflow. If the consumer goes straight to prod after your PR is merged, then you definitely would want to check it?s compatible with prod (and any intermediate environment you need to ship it through)

shadman.equebal140
2023-08-03 05:36
Is it possible to verify xml responses and carry xml payload in http verification with pact. If yes, is it a direct verification like json dsl or there is some other way

matt.fellows
2023-08-03 06:17
Only some languages support XML, see https://docs.pact.io/roadmap/feature_support But it?s like JSON, yes

shadman.equebal140
2023-08-03 06:55
According to the feature support doc, XML support is there in pactgo, but you said its not there as answer to one of the question in stackoverflow. Could you clarify, please? And in pact js, the documentation says, you can build xml using xmlbuilder and then convert it to json only. Does it mean , we have to transform the xml response before verifying in producer as well as consumer

matt.fellows
2023-08-03 06:57
apologies, that looks to be a mistake - I?ve corrected it now

matt.fellows
2023-08-03 06:59
> And in pact js, the documentation says, you can build xml using xmlbuilder and then convert it to json only. If you?re referring to what?s stated https://github.com/pact-foundation/pact-js/blob/master/docs/xml.md, it?s probably just poorly worded. It?s XML. > Does it mean , we have to transform the xml response before verifying in producer as well as consumer No, it would expect the XML content-type

matt.fellows
2023-08-03 06:59
thanks for drawing attention to the docs correction

matt.fellows
2023-08-03 06:59
In the SO answer, it?s true that under the hood it supports XML, so it?s just about exposing it in the DSL. If you?re interested in conttributing, please let me know and I can give you some pointers

aravind.pai
2023-08-03 07:06
has joined #general

ganeshacse01
2023-08-03 08:10
has joined #general

br.holanda15
2023-08-03 14:35
has joined #general

phillip.lo
2023-08-03 16:25
got it thanks!

phillip.lo
2023-08-03 16:27
looks like that PR is already approved so I assume that it should be merged soon?

abarkha1
2023-08-03 22:34
has joined #general

matt.fellows
2023-08-03 23:11
Probably :wink:

boreyuk
2023-08-04 07:22
has joined #general

mike.lovely
2023-08-04 12:29
Hi. Just after some general advice. When verifying the contracts via the provider, I am running localhost [as per the example](https://github.com/pact-foundation/pact-php/blob/master/example/tests/Provider/PactVerifyTest.php#L27). However, I have now realised this means that any downstream services the provider calls might have to either be mocked or reachable in some other way. One way around this would be to call the provider on a testing environment, where all the services are running. That way, I won?t have to mock anything downstream, because it?ll already be there running (probably). Or should I really be in the habit of mocking these downstream services anyway? Is there an appropriate alternative? Such as not running the provider service but instead verifying the contracts against a spec for the provider? and just assuming that the provider and the spec for the provider are in sync? To be honest, I don?t know if I like the sound of that even if that is an option.


matt.fellows
2023-08-04 12:50
In short, stubbing downstream systems is the way to go usually

matt.fellows
2023-08-04 12:50
You want to try and think of pact tests as unit tests, as much as you can. This should get you into the right frame of mind to answer a lot of these types of questions

matt.fellows
2023-08-04 12:51

mike.lovely
2023-08-04 13:54
Yes. I have just read the "GOLDEN RULE" on writing consumer tests and that has helped my understanding :slightly_smiling_face:

evan196
2023-08-04 14:33
has joined #general

marek.fexa
2023-08-06 08:36
has joined #general

acemilyalcin
2023-08-06 16:55
has joined #general

aniket.rane
2023-08-07 02:55
has joined #general

antony
2023-08-07 08:11
has joined #general

andreas.marcec.extern
2023-08-07 14:35
has joined #general

gjourdanweil
2023-08-07 14:46
Hello folks, I was wondering if/how it's possible to define a contract in the consumer side but explicitly states that a given query parameter has to be ignored for the matching?

gjourdanweil
2023-08-07 14:46
The typical use case is when the production code adds some query parameter like an api key but this api key is a "infrastructure requirement", it's not really part of the contract with the provider.

andreas.marcec.extern
2023-08-07 15:21
Hi everyone, im currently working on putting an AWS API Gateway in front of the pact-broker in order to get some auth. The API Gateway is configured so that all requets are proxied to the application. If i use a token and curl the Endpoint directly it works fine and I receive a JSON Output. If i use my provider I receive the following error: ```Error making request - Errno::ENETDOWN Network is down - connect(2) for "http://apigateway.com" port 80 , attempt 1 of 3 Error making request - Errno::ENETDOWN Network is down - connect(2) for "http://apigateway.com" port 80 , attempt 2 of 3 Error making request - Errno::ENETDOWN Network is down - connect(2) for "http://apigateway.com" port 80 , attempt 3 of 3 /pact/lib/ruby/lib/ruby/2.2.0/net/http.rb:879:in `initialize': Network is down - connect(2) for "http://apigateway.com" port 80 (Errno::ENETDOWN)``` Auth worked fine as I would get `unauthorized` instead. I'm not sure why it's trying to connect to port 80 as the api gateway is configured with https. Does it by default work on port 80?

yousafn
2023-08-07 15:34
it depends on which image you are using, the dius/pact-broker uses 80 by default, the pact-foundation uses 9292 https://github.com/pact-foundation/pact-broker-docker#other-settings

andreas.marcec.extern
2023-08-07 15:58
We are using the pact-foundation and it's corecctly running on 9292. The error occurs when to run some pact verification with java script which is also using this: `const { Verifier } = require('@pact-foundation/pact');`

andreas.marcec.extern
2023-08-07 16:00

andreas.marcec.extern
2023-08-07 16:11
I activated some debug logs and now i found this line in the output: ```INFO: Fetching pacts for Service from https://apigateaway:443/ with the selection criteria: opening connection to http://apigateaway.com:80... opening connection to apigateaway:80...``` It's weird that it looks for port80 :think_up:

andreas.marcec.extern
2023-08-07 16:15
Looking at the output from / I can see this snippet: ```{ "_links": { "self": { "href": "http://apigateway.com", "title": "Index", "templated": false }, "pb:publish-pact": { "href": "http://apigateway.com/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}", "title": "Publish a pact", "templated": true }, "pb:publish-contracts": { "href": "http://apigateway.com/contracts/publish", "title": "Publish contracts", "templated": false },```

andreas.marcec.extern
2023-08-07 16:15
that means that after looking up the infos from / I tries to interact with it using http.. is there a way to change this?

yousafn
2023-08-07 16:48
in the link provided > ? `PACT_BROKER_BASE_URL` - optional but _strongly recommended_ when deploying the Pact Broker to production as it prevents some https://www.cloudflare.com/learning/dns/dns-cache-poisoning/. If you find that the URLs generated by the API are using an IP instead of a hostname, you can set this environment variable to force the desired base URL. Must include the port if it?s a non-standard one. eg. `https://my-broker:9292`. This can also be used if you are mounting the Docker container so that it runs on a non root context eg. `https://my-company.com/pact-broker`. Not that this setting does not change where the application is mounted within the Docker container - it just changes the links.

yousafn
2023-08-07 16:50
not sure what you have that set to, but adding the port might help. not sure why you are getting a https -> http redirection, hard to tell with more detail on how its configured

yousafn
2023-08-07 16:50
can you publish pacts fine to it?

andreas.marcec.extern
2023-08-07 17:14
Thank for the hint of the base url! That kinda works out but i'll have to make some workarounds on another place. The setup is like this: ->HTTPS API Gateway HTTP -> private ALB -> ECS Container. If i add a redirect at the alb from 80 to 443 i'm ending in a redirect for some reason. I didn't manage it to configure it that between API Gatway and ALB HTTPS requests are used

jeffreykey
2023-08-07 17:44
has joined #general

matt.fellows
2023-08-07 22:21
Looks like you?re moving in the right direction

matt.fellows
2023-08-07 22:21
More info on the ?behind a proxy? here: https://docs.pact.io/pact_broker/configuration/features#running-the-broker-behind-a-reverse-proxy (in this case, it?s API gateway but the principles I think are the same)

abubics
2023-08-08 01:00
One approach is to bundle that into the state description, rather than the interaction content. E.g. "user is logged in" or "user with active session" for auth tokens, is similar to "request has valid API key". It's a very implementation-dependent question, though . . . if your responsibilities are split between actors (like, the API never gets invalid requests, because they're intercepted by a gateway), then it's not quite a 1:1 contract.

abubics
2023-08-08 01:02
How you do the provider verification should be env-independent, though. I'd cover the extra API key header in functional/smoke tests, not unit/contract tests.

gjourdanweil
2023-08-08 06:37
My issue is more on the consumer side where I don't have control over the mock server being created from the contract.

gjourdanweil
2023-08-08 06:38
If I don't put the query parameter in the contract, the mock server is not able to find the appropriate answer.


andreas.marcec.extern
2023-08-08 08:37
Thanks guys! The hint with `PACT_BROKER_BASE_URLS` die the Trick .. It's somewhat of a special case because we point to the same service through different URLs, with a https termination in between. Setting the flag and configuring both URLS with it works

vaishali.rastogi
2023-08-08 12:29
has joined #general

michael.knoll
2023-08-08 14:02
has joined #general

michelle.he
2023-08-08 19:02
has joined #general

mohammed.a.ezzedin501
2023-08-09 11:17
has joined #general

mohammed.a.ezzedin501
2023-08-09 11:19
Hello! We have a use case where a group of contracts between a consumer and a provider are not valid anymore and need to be deleted. Deleting them from the code was not enough to inform the broker that these contracts would be deleted and not to be validated in future checks. Is there a programmatic way to do this other than manually deleting the contracts from the broker UI or API?

matt.fellows
2023-08-09 12:15
No, you would need to delete the integration via the UI or API

yousafn
2023-08-09 13:22
Hey @grace.tree - Just seen the invites go out! Yes we would love to get some stickers out. Would you want something incorporating your Panda/logo or would just Pact stickers be cool? PM me an address we can send them over to and we will get this sorted for you

yousafn
2023-08-09 14:29
you could make a set of api requests to call the same endpoints being invoked by the manual deletion via the via, and pass your creds in the header if your broker is authenticated

yousafn
2023-08-09 14:30
> Deleting them from the code was not enough to inform the broker that these contracts would be deleted and not to be validated in future checks Yeah that isn?t going to work (existing contracts and verifications would still exist), stopping publishing pacts or verification results wouldn?t help there

grace.tree
2023-08-09 14:49
Happy with either or both! Thank you for giving us some stickers to give out. :smile: The address is: DevOps Playground, GlobalLogic UK&I, 2 More London Riverside, London, SE1 2AP

jacopo
2023-08-09 15:34
has joined #general

jo.laing
2023-08-09 16:17
@gjourdanweil Hello!!! Cucumber Jo here :dancing-pickle:

paul.caplan
2023-08-09 21:50
Hi - Question about provider states. If have a state that requires a test user and some other data record associated with that test user to be created, is it better to achieve this via one single provider state, or two? For example, I could have just one state: ?A thing exists for a user? For example, I could have two states: 1. ?A user exists with username foo? 2. ?A thing exists for user with username foo? It seems that having multiple states could be preferable for reasons of modularity and reusability, i.e. each state has fewer responsibilities and could be reused in multiple tests. However, the potential concern I see is it requires hard-coding some sort of shared data into the test, e.g. a username. And under some scenarios (e.g. tests running concurrently or test data not cleaned up correctly) this could potentially cause problems.

matt.fellows
2023-08-09 23:19
I think the best practice would be to set them up as two independent states

matt.fellows
2023-08-09 23:22
> However, the potential concern I see is it requires hard-coding some sort of shared data into the test, this can actually be mitigated (to an extent) by using the value from provider state feature (see https://pactflow.io/blog/injecting-values-from-provider-states/). We really need general docs on this. > And under some scenarios (e.g. tests running concurrently or test data not cleaned up correctly) this could potentially cause problems. that could still be a problem, even if you combine states. For instance ?User A with thing X? and ?No things exist?.

enrique519
2023-08-09 23:57
has joined #general

abubics
2023-08-10 01:11
I'm interested in how this situation arose . . . was a consumer (or provider) decommissioned? Would any other scenarios would leave behind unwanted contracts or dangling pacticipants?

sheyanr
2023-08-10 02:55
has joined #general

mohammed.a.ezzedin501
2023-08-10 06:00
@abubics it rose because of functionality at the provider's side that got decommissioned

abubics
2023-08-10 06:01
As in, not a whole contract, but just some interactions disappeared?

gjourdanweil
2023-08-10 06:10
Hey, nice to see you here @jo.laing :wave:

mohammed.a.ezzedin501
2023-08-10 06:14
yes exactly. the provider used to have a functionality to do something and it does it not have it now

mohammed.a.ezzedin501
2023-08-10 06:14
basically, change of requirements :slightly_smiling_face:

abubics
2023-08-10 06:15
That sounds like a regular Pact case, and you need a strategy to remove the dependencies from the contracts.

abubics
2023-08-10 06:16
Unless you never deployed them to any environment, they're still load-bearing until they're genuinely not.

mohammed.a.ezzedin501
2023-08-10 06:18
No, the pacts were already deployed to the broker, but now that the functionality is removed, the pacts are as well removed from the code, the broker still has the old pacts as active, and when the provider runs its test, it is failing because it's trying to verify them.

mohammed.a.ezzedin501
2023-08-10 06:19
we figured maybe if we strict the verification to the provider's version (commit ID), and considering that the consumer is publishing the contracts on every commit ID (both the consumer and the provider share the same GIT repository), that might solve our issue

abubics
2023-08-10 06:21
Just to clear up some terminology ? the pact file is a contract artifact (the actual contract is conceptual) ? the contract is made up of interactions ? the contract is published to the broker ? the consumers and providers are released & deployed to environments

abubics
2023-08-10 06:21
Are you saying you published contracts & deployed consumers, but didn't deploy providers? In that case, removing the new contract versions would work, I guess, but they shouldn't break anything if you have wip/pending pacts enabled.

mohammed.a.ezzedin501
2023-08-10 06:25
Okay, given this terminology, I'll state the chronological order of the events: 1. the provider had a functionality to do some operation 2. the consumer started using this functionality, so they wrote a pact file for it, then generated the contracts and published them to the broker 3. the provider then started validating these contracts each time they deploy? 4. later, the provider stopped supporting this operation, hence the consumer had to delete these pact files 5. the contracts, however, are not automatically deleted from the broker, so the provider's tests are failing since PACT is trying to validate the old decommissioned contracts

abubics
2023-08-10 06:25
So, 1, 2, 3 sounds good :+1:

abubics
2023-08-10 06:25
4 sounds a bit off

abubics
2023-08-10 06:26
If the consumer stops needing the functionality, they can remove the tests, and the new pact files should no longer have the invalid interactions.

abubics
2023-08-10 06:27
If that's not happening, you may be generating them with a merge strategy, instead of cleaning up the old interactions (this usually doesn't happen in CI, though, only in local dev)

abubics
2023-08-10 06:28
But if you're saying all of the interactions between a consumer & provider are gone, then you have an empty contract, which probably won't delete anything from the broker. In that case, I think you would have to delete them from the broker maybe?

mohammed.a.ezzedin501
2023-08-10 06:36
> If that's not happening, you may be generating them with a merge strategy, instead of cleaning up the old interactions so you're saying, if the consumer stopped using a functionality, hence removed its pact files from its side and deployed to the broker, the new version of the contracts on the broker should squash the old one, i.e. the provider won't need to validate the contracts of the mentioned functionality anymore?

abubics
2023-08-10 06:37
It's not really about the files, it's about the tests that generate the files. But the rest of that sounds right :+1:

abubics
2023-08-10 06:37
Are your contracts consumer-driven or bi-directional, btw?

mohammed.a.ezzedin501
2023-08-10 06:38
consumer-driven

abubics
2023-08-10 06:38
ok, cool . . . otherwise my knowledge might not be all there :sweat_smile:

mohammed.a.ezzedin501
2023-08-10 06:38
hahaha no it's alright. Thanks a lot!

abubics
2023-08-10 06:42
All g, I hope it's a bit easier to follow now :pray: You definitely want to be clear about the separation between: ? the tests, ? the interaction each of the tests describes, ? the contract (Pact file), made up of interactions for a consumer-provider pair

mohammed.a.ezzedin501
2023-08-10 06:44
yes. Thanks for the clarification! made it much clearer.

matt.fellows
2023-08-10 07:52
> so you?re saying, if the consumer stopped using a functionality, hence removed its pact files from its side and deployed to the broker, the new version of the contracts on the broker should squash the old one, i.e. the provider won?t need to validate the contracts of the mentioned functionality anymore? pact file = all of the interactions between a given consumer and provider pair. interaction = test case (basically) a. If the consumer no longer talks to the provider, you need to delete the integration from the Broker b. If the consumer no longer needs _some_ of the interactions, the pact file should still be generated and sent to the broker, sans the interactions no longer required. It sounds like the scenario you?re running into is (b). If so, it sounds like you might not be using the most recent guidance for our CI/CD workflows (seen here: https://docs.pact.io/pact_nirvana)

matt.fellows
2023-08-10 07:52
But looks like you?re back on track, thanks Andras :pray:

rcalvo
2023-08-10 08:28
has joined #general

endikaposadas
2023-08-10 08:40
has joined #general

mohammed.a.ezzedin501
2023-08-10 08:57
thanks for the insight! I will definitely checkout the mentioned guidance

chinmaya.mishra
2023-08-10 10:05
has joined #general

anderson.aeb
2023-08-10 12:37
has joined #general

poojarylatika1
2023-08-10 14:17
has joined #general

connor.beck
2023-08-10 15:24
Hello, I'm hoping someone can help me understand how the idea of a "shared fixtures" solution can work when talking about supporting both UI tests and pact consumer tests. So, my understanding is that the pact consumer tests should ideally be written in such a way that they have https://docs.pact.io/consumer#choose-the-right-type-of-matching-for-the-situation. I guess my question is: should the matching rules be defined as part of the fixture, and the non-Pact stub server needs to be able to interpret and understand those matching rules; or should the fixtures be simple request and response bodies, and we somehow with pact layer matching rules on top of those simple fixtures? The only examples I've found for using fixtures to seed pact consumer tests either https://docs.gitlab.com/ee/development/testing_guide/contract/consumer_tests.html or https://blog.scottlogic.com/2017/01/10/consumer-driven-contracts-using-pact.html. Does anyone know of any good examples of how this can work (preferably in either js or jvm, but I can work with other languages :pray:)?

sebastianmsandri
2023-08-10 16:01
has joined #general

connor.beck
2023-08-10 17:53
I may also just be completely misunderstanding what "fixtures" are. Is it still a "fixture" if it's generated? Is the pact document a "fixture" if it is used to seed a stub server for the UI tests? Or do fixtures have to be statically defined, and if so, how can you define matching rules that apply to a static fixture?

biancoc
2023-08-11 14:27
has joined #general

tjones
2023-08-11 15:14
The matchers are a convenience only. You?re saying to the provider team ?hey, this test covers all cases where the data looks like X?- which means they don?t have to have the exact same test data you use

tjones
2023-08-11 15:15
There?s no testing benefit from using them, it just makes it easier for provider teams to implement/ match your tests

tjones
2023-08-11 15:17
Fixtures in this context are just a way of sharing the data you used in your pact test with the code that uses the api boundary (probably mocked). Think of it like this: Your pact test asserts that GetUser(foo) returns UserFoo Now, you can mock GetUser(foo) to return UserFoo

tjones
2023-08-11 15:17
A matching rule would not make sense in that context, so the shared fixtures are usually just the real concrete object

tjones
2023-08-11 15:18
There are no examples using (say) UI tests, because Pact isn?t a UI testing framework

tjones
2023-08-11 15:22
Tests shouldn?t run concurrently in Pact- each test needs to be independent

matt.fellows
2023-08-12 06:18
On the provider side, yes, good point

svarakantham
2023-08-14 00:19
has joined #general

carrm
2023-08-14 13:22
has joined #general

jd.courtoy
2023-08-14 16:25
has joined #general

quinton.miller
2023-08-14 19:42
We are using separate Open API Specs for each version of the provider API, meaning the spec file is unique for each version of the API. When the provider deploys their code they support all of these versions as long as the consumer supplies the version in the header when making the API call. Does BDC require all versions of the API to be in a single Open API spec file or can each version of the provider have their own spec file?

elenadoty
2023-08-14 20:01
has joined #general

quinton.miller
2023-08-14 21:09
@matt.fellows

matt.fellows
2023-08-14 21:30
Yes in that case it should be a single OAS

matt.fellows
2023-08-14 21:31
The OAS should represent the deployed unit

tjones
2023-08-14 22:58
This question belongs in #pactflow

a.adeyeye.gr
2023-08-15 08:49
has joined #general

bas.plijnaer
2023-08-15 12:32
has joined #general

liam.butler
2023-08-15 15:20
has joined #general

phillip.lo
2023-08-15 21:38
we have a monolith owned by multiple teams with many different endpoints etc. that is acting as a "provider" in the contract testing world. So far we've found that pact wants to verify every state for every contract that is in the broker against this monolith. That obviously doesn't make sense because each consumer has their own set of test states depending on the endpoints that they use so the one way we've figured out how to tell pact to only care about the correct States is to add something like ```@PactFilter( value = {"^\\/myendpoint\\d+/.*"}, filter = ByRequestPath.class)``` to the top of the respective provider test class. Is this the correct way to go about this or is there something else that we might be missing that is a little more userfriendly?

phillip.lo
2023-08-15 21:40
A little more context, since the monolith has so many "services" inside of it, there will be many provider tests each in their own class owned by different teams instead of one large provider test with every test state in it since they are all unrelated to each other

marcocbarbieri
2023-08-15 22:47
has joined #general

marcocbarbieri
2023-08-15 23:01
Hello, we have a "consumer" that communicates with a "provider" that we don't control the development or we don't have access to its code base. should I use pact on this "consumer" to validate the contract with that provider? Or do I only use Pact to validate contracts between services that implement Pact? I really want to get rid of the E2E test...

tjones
2023-08-16 00:08
You could still share the pact with the provider team

guozhangliew
2023-08-16 04:36
Hi guys may I know how I can fix this? ```pact-broker can-i-deploy --pacticipant $PACTICIPANT --version $BUILDKITE_COMMIT --to-environment $ENVIRONMENT --retry-while-unknown 30 --retry-interval 10\n' Waiting for 1 verification result to be published (maximum of 300 seconds) Computer says no ¯\_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# -----------------------------|------------|------------------------------|-----------|----------|-------- KafkaGenerateKeyPairConsumer | 1bf22d9... | KafkaGenerateKeyPairProvider | ??? | ??? | There is no verified pact between version 1bf22d9a2ff717271268a9934a0099b45e4393a9 of KafkaGenerateKeyPairConsumer and a version of KafkaGenerateKeyPairProvider currently in production (no version is currently recorded as deployed/released in this environment) ? Error: The command exited with status 1```

guozhangliew
2023-08-16 04:47
my microservice repo consist of both the provider and consumer does this mean I need publish my provider during my Pull request pipeline in order for the `can-i-deploy` command to work?

yousafn
2023-08-16 08:49
you need a provider to satisfy the consumer when asking if you can deploy to a particular environment, so if you?ve never deployed the provider before that command above will rightly fail. so yes, you would need to record your provider as deployed. as to exactly when, probably depends more on the specifics of your pipeline, deployment process and repo setup

juandiegopalacio
2023-08-16 09:00
has joined #general

tjones
2023-08-17 01:23
Generally, no, you wouldn?t filter the states

tjones
2023-08-17 01:24
I don?t think I understand your use case. Different teams own different parts of the monolith?

tjones
2023-08-17 01:25
You could do different tests per consumer?

tjones
2023-08-17 01:26
It sounds like you need your provider team(s) to agree on the states they are exposing to consumers and to communicate those to the consumer team(s)

t.vandenberk
2023-08-17 09:12
has joined #general

jianbin.lin
2023-08-17 15:07
has joined #general

phillip.lo
2023-08-17 16:11
Yep, different teams own different parts of the monolith with the potential of different teams owning different endpoints within the same controller (yes I know...) Also, we went ahead and updated the provider tests to tie them to a specific consumer with something like this at the top of the test class. ```@Provider(MONOLITH) @Consumer(MICROSERVICE)``` however, from what I can tell, you can't have a list of consumers so we'd kinda be duplicating each test for each pair of monolith to consumer. Does that sound right?

tjones
2023-08-17 16:13
This sounds like it?s more a #pact-jvm question, but you should be able to have multiple consumers in one test. Have a look at the documentation for consumer version selectors for pact jvm (I am not familiar)

phillip.lo
2023-08-17 16:14
we were filtering also since the same endpoints in the monolith are not all used by every consumer. one consumer could be using one endpoint while another endpoint is used by another consumer

phillip.lo
2023-08-17 16:14
but by default pact was trying to verify every state with every contract

tjones
2023-08-17 16:16
It should only verify the states in that contract, right?

phillip.lo
2023-08-17 16:18
Contract 1: StateA Contract 2: StateB, StateC Provider test 1: StateA Provider test 2: StateB, StateC without the above it would try and verify stateB and stateC against contract 1

tjones
2023-08-17 16:19
You shouldn?t need to think of it in terms of states or endpoints

tjones
2023-08-17 16:19
The states are part of the setup for the contract

tjones
2023-08-17 16:20
Not the verification

tjones
2023-08-17 16:20
You don?t verify states

tjones
2023-08-17 16:20
If provider test 1 doesn?t see contract 2 it should not try to set up the states from contract 2

phillip.lo
2023-08-17 16:21
Yea, I think that makes sense when the providers are different but in this case the provider for both contracts are the same (the monolith)

phillip.lo
2023-08-17 16:21
it is possible im confusing myself at this point though :smile:

tjones
2023-08-17 16:22
I think you are

tjones
2023-08-17 16:28
But that?s ok! There?s a lot happening when you first start using it

tjones
2023-08-17 16:28
But that?s ok! There?s a lot happening when you first start using it

tjones
2023-08-17 16:28
So, the states are setup per interaction. Contracts are made of interactions

tjones
2023-08-17 16:30
If the test doesn?t use a contract, the interactions in that contract won?t fire their state setups

tjones
2023-08-17 16:30
If the test doesn?t use a contract, the interactions in that contract won?t fire their state setups

phillip.lo
2023-08-17 16:31
Is that true even if both tests are annotated with the same @Provider

tjones
2023-08-17 16:32
I don?t know how tests select contracts in pact jvm

tjones
2023-08-17 16:32
But, telling it only the provider will select all the contracts

tjones
2023-08-17 16:33
Select contracts For each contract, For each interaction Setup state Test interaction Teardown state

tjones
2023-08-17 16:36
^ it?s kinda like that

phillip.lo
2023-08-17 16:37
got it. that makes sense

tjones
2023-08-17 16:38
Sorry, teardown state, not teardown interaction

tjones
2023-08-17 16:39
In general, you should not filter by states, because it will mean that you might partially verify contracts

tjones
2023-08-17 16:39
I don?t know if Pact jvm will let you publish if you have only done a partial verification, but the broker only knows about yes or no. It doesn?t know about parts of the contract

tjones
2023-08-17 16:40
So if you filter by state, and you are able to publish success, you lose the safety that Pact is supposed to give you

artur.suhaniaka
2023-08-17 20:34
has joined #general

aniruddhasingh.kushwa
2023-08-18 01:40
has joined #general

guozhangliew
2023-08-18 04:46
@yousafn is there a way I can add `KafkaGenerateKeyPairConsumer` and `KafkaGenerateKeyPairProvider` under a participant ? my microservice name is `authn` and I have `KafkaGenerateKeyPairConsumer` and `KafkaGenerateKeyPairProvider` as some of my tests. Im probably going in the wrong direction. so any advise would be appreciated :pray:

matt.fellows
2023-08-18 04:49
I don?t follow that question sorry Guo. What do you mean by adding them under a pacticipant?

guozhangliew
2023-08-18 04:53
`KafkaGenerateKeyPairConsumer` and `KafkaGenerateKeyPairProvider` are my unit tests names but I will have more unit tests in my microservice app do I need to deploy each of them independently like in this repo example? https://github.com/pactflow/example-consumer/blob/master/.github/workflows/build.yml

guozhangliew
2023-08-18 04:54
I guess my question is actually whether I can organised my consumers and providers under a single group?

matt.fellows
2023-08-18 04:54
The tests should be associated with the applications they represent. i.e. there is a one to many relationship between applications and tests

matt.fellows
2023-08-18 04:55
> I guess my question is actually whether I can organised my consumers and providers under a single group? yes, you should be able to do that

guozhangliew
2023-08-18 04:55
do I need to use the broker cli to create a group ? I cant seem to find anything related in the docs

matt.fellows
2023-08-18 04:56
no, they should be done on the client side

matt.fellows
2023-08-18 04:56
I?m not super familiar with Pact JVM but I think it?s possible

guozhangliew
2023-08-18 04:57
Im using pactjs for my typescript microservice stack do you have a similar example I can refer perhaps?

matt.fellows
2023-08-18 04:57
With Pact JS you just put the tests in whatever file you want to group them and it will all be written to the Pact file you specify. You just need to ensure the `consumer` and `provider` names match

guozhangliew
2023-08-18 05:02
but when I do a record deployment it seems that I can only specify one pacticipant (sorry if i misunderstood the meaning) which is eg `KafkaGenerateKeyPairProvider` do I have to write script to loop through all participants? do I need to prefix `KafkaGenerateKeyPairProvider` with my microservice name?

matt.fellows
2023-08-18 05:07
It?s not usual for a repository to have multiple applications (pacticipants). Usually, each repo represents a single application. Each repo is usually associated with a single build pipeline.

matt.fellows
2023-08-18 05:07
So in your case, you will need to know what you are building and wanting to deploy.

matt.fellows
2023-08-18 05:08
The application in PactFlow should represent what is independently deployed

guozhangliew
2023-08-18 05:11
ah looks like I misunderstood the meaning of a pacticipant because my microservice is the application. so I should actually run a record-deployment base on my microservice name

matt.fellows
2023-08-18 05:12
> so I should actually run a record-deployment base on my microservice name yes, it would usually be named after the thing that you deploy. There are exceptions (e.g. a monolith with logically different parts), but ignore them until you really know what you?re doing

parthiban.rajasekaran
2023-08-18 08:32
has joined #general

gowthamgopal24
2023-08-18 09:52
has joined #general

yousafn
2023-08-18 12:18
:ralph-wave: hey everyone! want to get involved in celebrating Pacts 10th birthday if so check out our lander https://pact.io/pactober and join #pactober feel free to let us know if you want to attend, participate, host or build something and we will look to help facilitate. we want it to be something for everyone and are inviting you to help shape it. if you just want to attend that is cool too! the more the merrier. tell your friends!

naimun.siraj
2023-08-18 16:50
has joined #general

yousafn
2023-08-18 17:08
> I don?t know if Pact jvm will let you publish if you have only done a partial verification, but the broker only knows about yes or no. It doesn?t know about parts of the contract this is something i need to check both in the ruby and rust core. i agree it could lead to a state of false confidence. i?ve replied in another thread but i wonder if everything being named as the same provider in the monolith is the issue. it would help you understand of all the endpoints on the big monolith, these few are being used for these scenarios as shown in a pact

yousafn
2023-08-18 17:09
sharing provider states with consumers especially as you scale is challenging and i don?t believe there is an elegant solution at least afforded to you by the pact tooling. i think this would be a good area where we could make the states more available or searchable or something in the broker

yousafn
2023-08-18 17:28
> it is possible im confusing myself at this point though :smile: heh that is definitely okay, we do it all the time. :taco: for @tjones for being super polite, friendly and awesomely helpful as always

eugeniosaulo
2023-08-18 21:28
has joined #general

pere.villega
2023-08-20 17:49
has joined #general

navin.dhanaraj
2023-08-21 00:10
has joined #general

yousafn
2023-08-21 13:49
:blobwave: Are you an MulesSoft user running MUnit? :think_up: If so, check out the latest https://docs.pact.io/recipes/munit on our site, kindly provided by @grace.tree! Got something you want to share? Why not drop in a pull request. You can find out ways you can help https://docs.pact.io/contributing#pact---how-you-can-help

grace.tree
2023-08-21 13:49
Oh it is merged in?! I still had those comments to resolve :sweat_smile:

yousafn
2023-08-21 13:50
I was in the site doing some edits, so I got them fixed up for you https://github.com/pact-foundation/docs.pact.io/pull/280#issuecomment-1686361221 Feel free to do any more tweaks if you want

yousafn
2023-08-21 13:51
Thanks again dudette!

grace.tree
2023-08-21 13:53
is there some where I could get added as a contributor for it?

yousafn
2023-08-21 13:59
There isn?t a dedicated section on the recipes page and it doesn?t support author tags like the blog does, but there is no reason not to add them! You could just add a section at the top/bottom, with a bio if you wanted? We have a few other places where contributions are listed ? https://docs.pact.io/contributing/contributors - page of contributors, mainly for languages impls ? https://docs.pact.io/blogs_videos_and_articles - articles / blogs etc, usually with names of the people, can add a link here to the recipe ? https://docs.pact.io/events - DevOps playground should get the meets listed on here, and you can add links to past events for the recordings/materials as well ? https://docs.pact.io/users/community_corner/adam_cox_interview_may2023 - we have a community corner, (new) where we can highlight people in the community, in whatever style they want. Whatever works for you, just drop in and edit where you feel is best :)

eduardo.rodrigues
2023-08-22 08:05
has joined #general

nickkeers
2023-08-22 08:35
has joined #general

christophe.laranjo
2023-08-22 17:34
has joined #general

huthayfa
2023-08-23 08:10
has joined #general

dsherwin
2023-08-23 09:20
has joined #general

marcel.novak
2023-08-23 13:53
has joined #general

davidm
2023-08-23 15:57
has joined #general


svmanikantakumar
2023-08-24 08:50
has joined #general

eomeroff
2023-08-24 13:49
has joined #general

yousafn
2023-08-24 14:27
Was raised here and I?ve just fixed it now https://github.com/pact-foundation/docs.pact.io/issues/265#issue-1711684185 Thanks dude

riley.marzka
2023-08-24 17:47
has joined #general

jared.anderson
2023-08-24 18:15
has joined #general

timofeev1valeriy
2023-08-25 08:32
has joined #general

kastala.nirosha
2023-08-25 09:17
has joined #general

kkanova
2023-08-25 12:55
has joined #general

theteea
2023-08-25 13:18
has joined #general

charlan.bettiol
2023-08-25 16:32
has joined #general

david.tu
2023-08-25 17:51
has joined #general

viktor.stephanyk
2023-08-28 12:46
has joined #general

arpit.gawande
2023-08-28 12:58
has joined #general

alexander.doppelbauer
2023-08-28 17:52
has joined #general

jayapriya.m
2023-08-29 00:22
has joined #general

grnmeadow7
2023-08-29 03:27
has joined #general

amitw
2023-08-29 09:34
So, general question Is there a way to manage "contract" tests for libraries (as opposed to services). Some context: As part of the product we build, we have some common functionality in internal libraries. One of the challenges is to know which functions are in use and which can be changed\deleted safely. I wonder if there's a way to manage that. The concept of contracts is very appealing, but the technical parts are completely different.

sayantini.basak
2023-08-29 10:02
has joined #general

matt.fellows
2023-08-29 11:45
I?ve written on it for client SDKs: https://pactflow.io/blog/should-i-write-contract-tests-for-client-sdks/ is this what you mean, or something more low level?

tjones
2023-08-29 13:33
Yes, you can absolutely use contract tests for this

tjones
2023-08-29 13:34
With pact, I think you could (mis)use message pacts to do this. It would work very well. You'd have a conceptual "message" (a function call with parameters), then your actual test would call the function instead of a message handler.

tjones
2023-08-29 13:35
Essentially, contract tests just let you tie mock expectations to what the code actually does. You can use them anywhere you have that problem.

tjones
2023-08-29 13:36
technology wise, message pact is really "function call pact" anyway. It doesn't actually send or receive messages like http pact does.

tjones
2023-08-29 13:36
to use it for messages you have to write a custom handler.

shayanadc
2023-08-29 18:19
has joined #general

shayanadc
2023-08-29 18:26
After creating my account, I noticed a message indicating that I would receive my credentials via email. However, despite multiple attempts, I have not yet received this email. Do I need to do something else??

matt.fellows
2023-08-29 22:22
This sounds like a #pactflow question. Mind moving this chat there?

kiranpatel11
2023-08-30 01:23
One of the common situation that I come across while talking about the contract testing to my teams is - How to handle the cases where there are intermediator/pass-through services between the `real` consumer and provider for the specific data ? I will try to explain through an example, ? `CartService` : is a consumer of these services - `CustomerInformationService`, `ProductCatalogService` and `PricingService`. ? For the `CartService.addItemToCart()` operation, It retrieves data from `CustomerInformationService` and `ProductCatalogService` and pass it on to the `PricingService` along with its own data, the current `cart` and `itemToBeAdded`. `PriciningService` uses these combined information to apply the discounts or other free items based on the business rules. ? In this case, `CartService` really does not dictate what information it is presented by the `CustomerInformationService` and `ProductCatalogService` and act as pretty much pass-through. Questions are - ? How the contracts are supposed to be written by the `CartService` for the information that it depends on other services? ? How the collaboration supposed to be happened ? Should `PricingService` be aware about the contract of the `CustomerInformationService` and `ProductCatalogService` ? PS: this is my first message in the PACT community after 4 years. I have my own views on the above, but would like to get community views as well.

kiranpatel11
2023-08-30 01:28
The decomposition of services in such way may be questionable, but in real world such scenarios do exists.

matt.fellows
2023-08-30 02:51
FYI `can-i-merge` is now available in the latest release!

jack.jones9512
2023-08-30 15:49
has joined #general

craftyqa
2023-08-30 16:54
has joined #general

jean-baptiste.bronisz
2023-08-31 15:48
has joined #general

razorangel
2023-08-31 18:41
has joined #general

dsharma
2023-08-31 19:11
has joined #general

eytan.hanig
2023-08-31 22:10
has joined #general

matt.fellows
2023-09-01 09:54
Nice to hear from you!

matt.fellows
2023-09-01 09:55
It's a good question, we have an article on the docs about pass through and downstream systems. But we could do with more on it

munitheja91
2023-09-01 13:14
has joined #general

alvarado.kelvin
2023-09-02 12:48
has joined #general

sautade
2023-09-04 01:23
has joined #general

gowthamgopal24
2023-09-04 04:30
Hi All, I am working on PACT Provider Verification using Pact JVM. I am stuck reading the request headers. Has anyone worked on writing Groovy scripts in pom.xml to modify the auth token during provider verification? Thanks in Advance !! Your help is much appreciated. !

tjones
2023-09-04 04:33
Try asking in #pact-jvm

joshua.ellis
2023-09-04 04:51
has joined #general

gowthamgopal24
2023-09-04 05:05
Thanks @tjones !!

bbodoque.atsistemas
2023-09-04 10:21
has joined #general

avanlent
2023-09-05 05:56
has joined #general

callum.atkinson
2023-09-05 17:00
has joined #general

emilie.bline
2023-09-05 22:27
has joined #general

me1414
2023-09-06 12:37
has joined #general

juantamosaitis2015
2023-09-06 13:24
has joined #general

ali.tariq
2023-09-06 14:51
has joined #general

anas.zakarneh
2023-09-06 15:04
has joined #general

jvillars
2023-09-06 17:53
has joined #general

kwongs
2023-09-08 01:45
has joined #general

alicankarayelli
2023-09-08 10:43
has joined #general

sgregory875
2023-09-08 12:23
has joined #general

amagana
2023-09-08 22:40
has joined #general

heverson.amorim
2023-09-09 10:43
has joined #general

vdlre1994
2023-09-11 05:55
has joined #general

rware4
2023-09-11 10:16
has joined #general

hdjikine
2023-09-11 13:55
has joined #general

andrea.paschal
2023-09-11 16:48
has joined #general

phillip.lo
2023-09-11 17:20
nice! just saw this. thanks for the update

vdlre1994
2023-09-11 17:33
Hi! I am working on PACT. I have an issue related ---> Error: Error in native callback. Has anyone experienced the same issue? How did they resolve it?

yousafn
2023-09-11 19:57
Hiya, that is an error you ideally as a user shouldn?t see, as will be from the pact core that your language implementation uses. the best advise would be to raise your question in the pact-xyz where channel for your specific language implementation. i imagine yours is #pact-js also if you let people know where version of the libraries you are, what system and what your test look likes it will help. there could be a number of reasons, and without additional detail it?s hard to advise :)

matt.fellows
2023-09-11 22:51
No worries - do please let us know if that helped things for you

olof.stalnacke
2023-09-12 05:31
has joined #general

nvangari
2023-09-12 05:39
has joined #general

nvangari
2023-09-12 05:53
Hi Team, We are facing SSL issue with Pact broker Webhook setup. As per documentation we have created SSL certificate and integrated with PACT Broker manifest .Can someone help us on this? ```ERROR: Error executing webhook OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain)``` Followed instructions as per --> https://docs.pact.io/pact_broker/configuration/settings#webhook_certificates.

2023-09-12 05:53
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

nvangari
2023-09-12 06:20
Team, do we have Pact broker Centos / RHEL based image? Current pact broker image is Alpine based OS image and facing issues with Self-Signed cerificates

matt.fellows
2023-09-12 06:27
No, we just have the Alpine image

matt.fellows
2023-09-12 06:27
What?s the issue and what?s the relationship to RHEL/Centos?

nvangari
2023-09-12 06:27
Ok, we have our in-house SSL certificates. How to bake them during runtime?


matt.fellows
2023-09-12 06:28
Is it for webhooks or something else?

matt.fellows
2023-09-12 06:28
or rather - what certificate is self-signed?

nvangari
2023-09-12 06:30
We are trying to enable webook to trigger an event from Pact broker to our CI system. So while doing that getting the below SSL issue

nvangari
2023-09-12 06:30
```ERROR: Error executing webhook OpenSSL::SSL::SSLError - SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain)```

2023-09-12 06:30
Please see these instructions on running and accessing a Pact Broker over TLS https://docs.pact.io/pact_broker/advanced_topics/using-tls/

matt.fellows
2023-09-12 06:32
yep, the link I provided above should help get you to a point where you can load certificates into PactFlow


matt.fellows
2023-09-12 06:33
Actually, I might need to check how this works with on-prem

matt.fellows
2023-09-12 06:36
I?m following up with a team member, please bare with me - I?ll aim to get back to you on this tomorrow. If you have the time, you could try to see if https://github.com/pact-foundation/pact_broker/blob/master/script/prod/insert-self-signed-certificate-from-url.rb gets you anywhere. You could of course _disable_ validation to get you by for now (https://docs.pactflow.io/docs/on-premises/environment-variables#webhooks). This is obviously not recommended

kiranpatel11
2023-09-12 07:18
@matt.fellows , since the since the pass-thru services usually don?t care about the data and often do not validate, the contract testing becomes challenging. One of the option is to validate generically without parsing the payload for specific validation is to have a shared registry for dynamic schemas such as product catalog items and validate the payload against them using the indirection.

matt.fellows
2023-09-12 07:20
Yes. We created https://pactflow.io/bi-directional-contract-testing/ in part because of this inconvenience

kiranpatel11
2023-09-12 08:05
Yes, I am aware the bi-directional contract testing. However, I am think current support is limited to the OpenApi based validation only. What I am referring to dynamic schema for cases like product-catalog above, where different products and business rules are added dynamically without application code changes, and the services involve are implemented using abstractions(like TMF Api as open standards for telecos)

rksekar5
2023-09-12 12:30
has joined #general

ying.li
2023-09-13 02:54
has joined #general

kiranpatel11
2023-09-13 04:00
May be it?s worth considering a plug-in for schema registries like confluent and apicurio.

matt.fellows
2023-09-13 05:07
Would be more than open to the idea and seeing where it takes you!

matt.fellows
2023-09-13 05:08
Coming back. Sorry, I somehow thought this was a PactFlow related question. The article above is correct then. If you are running PactFlow on-prem, then the script to load it into the DB is the current way to achieve this.

nvangari
2023-09-13 05:42
we are running pactbroker on onprem

matt.fellows
2023-09-13 05:45
cool, not PactFlow. The docs above should get you going then!

nvangari
2023-09-13 06:28
@matt.fellows, When we disabled `PACT_BROKER_DISABLE_SSL_VERIFICATION` it is throwing the following puma dependency exception during startup : ```/pact_broker/vendor/bundle/ruby/2.7.0/gems/anyway_config-2.3.0/lib/anyway/type_casting.rb:111: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby! /pact_broker/vendor/bundle/ruby/2.7.0/gems/anyway_config-2.3.0/lib/anyway/rbs.rb:40: warning: Pattern matching is experimental, and the behavior may change in future versions of Ruby! bundler: failed to load command: puma (/pact_broker/vendor/bundle/ruby/2.7.0/bin/puma)```

matt.fellows
2023-09-13 06:49
really? that seems unlikely to do with that change

yousafn
2023-09-13 10:48
I would recommend using the latest pact broker image, which is using Ruby 3.2.* as released in May

yousafn
2023-09-13 15:28
:heart: Pact as much as we do? Why not drop us a short video :video_camera: (<30s) and we will include it in our https://pact.io/pactober event. Feeling camera shy? You can just drop us a quote, like our friend jameshd.

yousafn
2023-09-13 15:29
if 30 seconds is too short, don?t be constrained :sweat_smile: you can go for longer

yousafn
2023-09-14 12:33
Anyone else struggling with the new Slack layout?

drettie
2023-09-14 13:21
has there been any recent development around listing provider states? https://github.com/pact-foundation/pact_broker/discussions/438 I'm wondering how providers are detailing states that are available for consumers to use without them having to jump into the provider code

david.hodnett
2023-09-14 18:06
has joined #general

matt.fellows
2023-09-14 22:55
Not yet, albeit we are thinking about how to support it in a new UX refresh in PactFlow, so in doing so we?ll likely have to create some APIs to support it - so we may be able to pick it up.

abubics
2023-09-15 00:07
just because this workspace is the only one I'm being A/B tested on :stuck_out_tongue: all my other workspaces still look old

abubics
2023-09-15 00:09
Until then, everyone uses regular human communication :robot_face: sounds like a cool feature, though, looking forward to seeing it

yousafn
2023-09-15 10:18
100% the worst bit is the folding of the workspaces sidebar so now i just have a generic white blob to indicate there are messages, across 12 slack workspaces :sob: i left most of them, to see if reducing the number would return it back to it pre folded state. niente I?d love to know how Slack believe making me reading every single slack message ever will somehow make me more productive

abubics
2023-09-15 10:28
Shift+Escape is your friend, friend ;D

jonatan.bjork
2023-09-15 13:30
has joined #general

jonatan.bjork_test1
2023-09-15 13:41
has joined #general

you1
2023-09-15 13:41
has joined #general

jonatan.bjork_test2
2023-09-15 13:42
has joined #general

you1634
2023-09-15 13:43
has joined #general

m_testnewinvite
2023-09-17 22:43
has joined #general

georg.duemlein
2023-09-18 04:09
has joined #general

sam647
2023-09-18 14:37
has joined #general

edward
2023-09-19 07:24
has joined #general

dbc216
2023-09-19 14:17
has joined #general

tan.k.h.usa
2023-09-20 00:31
has joined #general

tan.k.h.usa
2023-09-20 03:15
Hi, I am a newbie with contract testing and have a question to ask. A book I read said that "Contract testing can be seen as a programmatic solution to a communication problem", and presents it as a way to detect accidental or uncoordinated changes in the consumer api and provider api. A picture of the model describing the relationship and process of contract testing is attached. ( I blocked out some text bec I do not wish to copy the entire section verbatim ) That model seems to imply that the contract file is the key element that holds the process in place. In fact, it would not matter who/what created the contract file. This is very different from the advice in https://docs.pact.io/faq#can-i-generate-my-pact-file-from-something-like-swagger where the pact file is not considered key but the process of generating it in the consumer side and using it on the provider side is considered more kosher. It would seem that both scenarios are valid depending on what the engineer values since the operational aspects of Pact does not know which usage is being intended anyway.

matt.fellows
2023-09-20 03:36
Which book is that, btw?

matt.fellows
2023-09-20 03:41
Are you referring to this line in the shared link? > The reason the pact file exists is to ensure the tests in both projects are kept in sync - it is not an end in itself. The contract itself isn?t the end - the safety you get from the process is the ends game. Of course, the artifact is critically important to this process. > In fact, it would not matter who/what created the contract file. In a way, yes, but an OAS (if this is what you?re interested in persuing) is not a contract in the way Pact would define it. See the link below (schemasarenotcontracts) for a detailed exploration of that topic


tan.k.h.usa
2023-09-20 03:42
The book is "Testing Web APIs" by Mark Winteringham, 2022.

tan.k.h.usa
2023-09-20 03:47
I am both referring to the line about the pact file not being an end to itself and the opinion that writing the Pact file directly or converting from Swagger is not a good idea.

tan.k.h.usa
2023-09-20 03:53
The diagram in the book seems to emphasis the key solution is that the same Pact file is used by 2 sides, to ensure correctness/agreement.

abubics
2023-09-20 04:14
As you mentioned, they're both valid, so it depends how much reasoning power (and therefore safety) you desire. Tests that execute your code to prove it does the right thing are more powerful than schemas that only validate that the output isn't invalid.

matt.fellows
2023-09-20 04:31
Well put Andras

matt.fellows
2023-09-20 04:34
> I am both referring to the line about the pact file not being an end to itself and the opinion that writing the Pact file directly or converting from Swagger is not a good idea. If you can guarantee (to some level of accuracy) that both consumers are providers do indeed match the contract (however it is generated), then you are certainly in a good space. The problem is, OAS and other hand cranked contracts, are usually too abstract to be meaningful in reasoning about how it is used (consumer part) and if the provider supports it (provider part). Of course, Pact and consumer-driven contracts give you many other benefits - eg knowing which parts of the interface the consumer actually uses, ability to evolve over time, specification by example, network diagrams of relationships etc.

abubics
2023-09-20 05:34
I think there's an OAS approach that introspects the code to generate the schema?that's also better reasoning power than, say, a YAML file that can drift from the code, or annotated comments (in JVM land) that can also drift from the code.

matt.fellows
2023-09-20 07:12
Yes, this is true. Albeit (theoretically) you could use some scaffolding tool to produce an API with routes and models, and then use the OAS generation tool to generate a valid OAS, but have not actually written the implementation. You can imagine other variations on this also

daniel.hyun.chae
2023-09-20 13:19
has joined #general

yousafn
2023-09-21 12:56
Need some inspiration, check out some of our users testimonials about Pact https://docs.pact.io/users/testimonials If you?ve got one to add, please feel free to edit the page, or let any of us know!

yousafn
2023-09-21 12:58
:trumpet: The September Pact blog is now live https://docs.pact.io/blog/2023/09/21/pact-open-source-update-sept-2023 Be sure to check it out and see what we?ve got in store for you in the month of October, we?ve got a cracking line-up to celebrate 10 years of Pact and there is still time if you want to participate your journey with the community, any time throughout the month.

sashi.kandru
2023-09-21 13:08
HI Team, As the pact specification https://docs.pact.io/getting_started/specification#client-language-support are different for different languages. Is it ok to have all teams in an organization use one language say JS, if we want to build a centralized pipeline for all the teams? What are the disadvantages to do something like this from a contract test writing perspective?

jake.corn
2023-09-21 14:01
has joined #general

karl980
2023-09-21 16:44
has joined #general

tan.k.h.usa
2023-09-21 17:45
I just learned that PactFlow supports bidirectional contract testing where the provider pact is generated by hand or code but not from the consumer side. It introduces the idea of consumer pact and provider pact files. See https://pactflow.io/bi-directional-contract-testing/ That seems to support the idea that the pact file is the central element. Of course, I think best to solicit ideas and comments for those who have more experience here. p*http://pactflow.io* *https://pactflow.io/bi-directional-contract-testing/* Bi-directional Contract Testing enables new modes of contract capture and compliance, a broader set of use cases, and a simplified developer experience exclusively for PactFlow customers.

matt.fellows
2023-09-21 23:43
I answered in #pact-js

abubics
2023-09-22 00:11
When we mention OAS, this bi-directional contract testing is what we're talking about. It's less powerful & reliable than a consumer-driven contract with provider verification.

abubics
2023-09-22 00:13
Also, it's only available in Pactflow. That might not be a problem for you, but it's an important point for consideration (in costing, OSS contribution, etc).

doctormiguel
2023-09-22 14:31
has joined #general

doctormiguel
2023-09-22 14:45
hey folks, congrats first of all for the great work you're doing with Pact! I am new to contract testing and pact and I have a question: what's the _right_ tool to use if I want to bring by pact files and spin up a docker container and mocks out a provider?


doctormiguel
2023-09-22 14:45
is there something for gRPC as well?

tan.k.h.usa
2023-09-22 17:21
U can tell I'm still new with contract testing and Pact if I have to ask what does OAS stand for? ChatGPT tried to help but gave very funny answers.

tan.k.h.usa
2023-09-22 17:23
Found it - OAS is Open Api Specification.

tan.k.h.usa
2023-09-22 17:35
*Q) Temporal checks in Pact?* Can Pact describe temporal constraints as well as what the API call returns etc? For eg, the call should return within X ms. For example with pact-net, I can see that this is implemented in IRequestBuilderV4, but there are no temporal-like checks there.

felipe.simoes702
2023-09-22 17:37
has joined #general

suat.kose
2023-09-22 22:13
has joined #general

marius.grigoriu
2023-09-23 15:33
has joined #general

noahmcivor
2023-09-24 06:54
has joined #general

matt.fellows
2023-09-24 23:24
So if I understand correctly, you want to take a pact file and then run a stub service from the contracts - correct?


matt.fellows
2023-09-24 23:25
(the mock server is stateful, and is used for _mocks_ not _stubs_


abubics
2023-09-25 02:35
That's right :+1: OAS is kind of the newer name for Swagger, which started life as a code-and-documentation-driven schema-and-documentation generator, and has since grown into a bigger suite of automated collaboration and testing tools.

abubics
2023-09-25 02:36
No, Pact isn't intended for performance, load, or functional testing.

abubics
2023-09-25 02:37
Cool question, though :ok_hand:

abubics
2023-09-25 02:39
Pact is conceptually more like a unit-testing framework. It doesn't simulate real-world infrastructure and performance constraints, and almost never runs in a prod-like environment.

abubics
2023-09-25 02:41
You might've seen some test pyramid diagrams before, here's one of mine:

abubics
2023-09-25 02:42
performance and load testing are definitely the realm of the light-grey box, and results are only relevant for the environment they're running against

marek19922209
2023-09-25 08:09
has joined #general

doctormiguel
2023-09-25 09:18
YES! this is it!!! thanks so much!!! sorry I think I'll take the chance to review as well the difference between _mocks_ and _stubs_ :wink:

matt.fellows
2023-09-25 10:59
No worries :slightly_smiling_face:

matt.fellows
2023-09-25 10:59
TL;DR - mocks are things you use to validate behaviour, stubs do not

doctormiguel
2023-09-25 11:01
gotcha! thanks!

corey_maynard
2023-09-25 20:07
has joined #general

rammohan_mididoddi
2023-09-25 20:12
has joined #general

tan.k.h.usa
2023-09-25 20:24
@abubics Thanks for your reply. To understand your picture, what does BFF stand for? I know its' not "Best Friends Forever" like I googled. Also you mentioned light-gray box -- do u mean the box with the light gray arrow pointing to automated e2e tests?

abubics
2023-09-26 01:23
in this context, BFF means "back-end for front-end"

abubics
2023-09-26 01:24
and yes, that's right, the box with the light-grey arrow pointing to automated e2e tests :+1:

kevin
2023-09-26 02:31
has joined #general

michael.lemos1
2023-09-26 12:36
has joined #general

sliu
2023-09-27 00:00
has joined #general

matt.fellows
2023-09-27 00:11
Cross posting, as Bas is doing a :free: Pact workshop in December this year :point_right: https://pact-foundation.slack.com/archives/C01NKLH8KS4/p1695717632615069 Get on board!

ankush.hasani
2023-09-27 10:01
has joined #general

kai
2023-09-27 15:31
has joined #general

a.monteiro
2023-09-28 09:59
has joined #general

ml210993
2023-09-29 05:12
has joined #general

prempooon.hc
2023-09-29 11:35
has joined #general

jaishankar.nedunchezh
2023-09-29 17:07
has joined #general

devin.woods
2023-09-29 19:28
has joined #general

vittorio.gue
2023-09-30 10:51
has joined #general

honglu11
2023-10-01 16:47
has joined #general

idd90i
2023-10-02 10:37
has joined #general

yousafn
2023-10-02 10:41
:tada: :pact: *CELEBRATE WITH US! 10 years of Pact Open Source* :pact: :tada: Hello - :blobwave: Pactober is here! :eyes: See the full schedule for the month https://pact.io/pactober?utm_source=pact.io&utm_medium=web&utm_campaign=pactober2023&utm_content=banner. Be sure to check out the Birthday Bash main event on the 10th October featuring Keynotes from Sam Newman and J.B. Rainsberger :raised_hands::skin-tone-2: We are kicking celebrations off today at 15:00 BST with @seb983 talking about https://pact.io/pactober/2023/seb-rose Check out this teaser from J.B. :tada: Looking forward to seeing you!

lewiscowles
2023-10-02 10:51
Well done. 10 years and an acquisition is a lot to celebrate. Love J.B.R. as well


corey_maynard
2023-10-02 20:31
Hi folks, I'm quite interested in exploring and using a tool like Pact/Pactflow, and have done a bit of reading of things to try and find my way. I've got a situation where my team controls both the provider and the consumer of an application, and I'm looking to find a way to make sure that deviations in one are properly accounted for in the other. I'm sure I'm preaching to the choir when I say that obviously a unit test in Jest with a mocked adapter and a unit test in the API of a given view don't cover the actual contract between them (consumer could change to sending a parameter the provider is unaware of, provider could change the response that the consumer was expecting, etc) With that in mind, my ideal solution for things would be: ? Provider contract is generated via Swagger (I happen to be working with Django so using https://drf-spectacular.readthedocs.io/en/latest/ to document all of the endpoints) ? I've got this working and have uploaded this to Pactflow using the CLI, everything good here! ? Consumer contract is generated by tapping into the mock adapter in Jest ? Every mocked request should be stored and then merged into a contract that represents every API call that the Jest suite performed ? This is where my question begins It seems like from my understanding of reading the docs that the consumer side pattern I'm describing has been deemed an 'anti-pattern' by the pact team. I'm curious to discuss why as it seems to me as an ideal path. In this situation a passing Jest test would have performed all of the API requests that the application/component requires from the provider. That seems to me to be exactly what I'd want to have, as that would describe the total contract that the consumer needs to function. If I understand what is recommended by https://github.com/pact-foundation/jest-pact it seems to be saying that I should have a Jest test that manually defines an endpoint, and then explicitly calls a function in an API wrapper (`client.getHealth()` in their example there) to hit that defined endpoint. However, in my application we do not have an API class that holds the logic for calls. Instead we are putting that directly in the component: ```const FooComponent = () => { // useAPI is effectively a hook wrapping axios.get in this case const { isLoading, response, error } = useAPI("/bar/foo/"); .... if (isLoading) { ... } else if (error) { ... } return <p>{response.data}</p> }``` With a component structure like that how would you recommend generating a contract for the `/bar/foo/` endpoint? I don't want to write a standalone pact test as shown in the jest-pact documentation, as that would not call any production code: ```pactWith(...), provider => { ... provider.addInteraction({ ... withRequest: { method: "GET", path: "/bar/foo/" }) axios.get("/bar/foo/") // assert that the request returned 200 }``` And obviously because the above doesn't call the actual FooComponent at all it doesn't represent the contract and won't fail if the FooComponent changes. It seems to me a better solution would be something like this: ```const mock = new MockAdapter(axios); // https://www.npmjs.com/package/axios-mock-adapter describe("Test the FooComponent", () => { it("handles loading", async () => { mock.onGet("/bar/foo").reply(200, {foo: "Is good"}); render(<FooComponent />) // wait for loading message to go away // assert "Is good" appears }) it("handles error", async () => { mock.onGet("/bar/foo").reply(500, {detail: "Oops"}); render(<FooComponent />) // wait for loading message to go away // assert "Oops" appears in document }) });``` This is a functional test that tests the component and describes the API: `/bar/foo/` shall exist and when GET requested shall return a 200 response with a `foo` key that holds a string. If it can't it will return an error with a detail key. No other methods are handled on this endpoint. It would be nice if running a test like that could build a contract off of the mocked requests defined in the test. Is something like that possible? Thanks for your advice!


kevin
2023-10-02 21:20
Hi guys, I am beginner in contract testing, and checking the feasibility of using this for my team. I found many great examples about verification between 1-1 consumer and provider case in internet. But in real world, there are many situations about M consumers to N providers. And I have 2 questions: 1. when I verify a provider which have 3 sub-providers. Do I need those contracts of sub-providers is verified and up-to date first?

kevin
2023-10-02 21:33
2. When I failed in a provider verification, and then, I fixed the contract by changing the code in consumer. In this case, am I need to re-verify the consumer-side contracts of the consumer?

matt.fellows
2023-10-02 23:13
Hello! The reason that it?s an anti-pattern, is that with pure ?Pact? testing (where Pact is used to verify a contract), generating the contract from real requests will potentially create a lot of duplications (e.g. multiple similar requests with slightly different data needs but nothing structurally different, that don?t give you any more reasoning power about the needs of the consumer) Also, because you aren?t setting up the scenarios using ?states?, it will be difficult for the provider to know how to prepare itself for verificatations. If you use PactFlow?s bi-directional contract testing approach (which I think you?re alluding to with a ?provider contract? generated as a swagger file (OAS), then this problem is not a problem - it?s in fact how it is designed to work.

matt.fellows
2023-10-02 23:14
Can I ask - where did you get the impression it?s an anti-pattern? (I?m only asking because this has come up a few times lately, so I want to go and update the docs to make it clear - this is only a problem when used purely with Pact, not BDCT?

nathan
2023-10-03 00:43
has joined #general

matt.fellows
2023-10-03 02:28
Thanks for the great diagram. The answer is ?no? unless the Consumer X v3 contract test is somehow dependent on the others.

matt.fellows
2023-10-03 02:28
Each contract is really designed to be isolated from others

matt.fellows
2023-10-03 02:29
For purposes of contract verification, not necessarily. But the use of `can-i-deploy` will tease out the relationships. If any of them have somehow gotten out of sync, `can-i-deploy` will detect it and explain to you which versions of the ecosystem are incompatible, and prevent you releasing a breaking change

matt.fellows
2023-10-03 02:33
P.S. thanks for the helpful diagrams

kevin
2023-10-03 05:11
Thanks @Matt?but still not sure if I understand correctly: For contract verification, I need to run the provider with all contract requests from customer side as input. And we can mock the sub-providers for the execution. To make sure all mock servers running correctly, we need to ensure all contracts in the sub providers? side are correct and up-to-dated first, right?

matt.fellows
2023-10-03 05:15
> And we can mock the sub-providers for the execution. To make sure all mock servers running correctly, we need to ensure all contracts in the sub providers? side are correct and up-to-dated first, right? I wouldn?t recommend using the Pact mock servers for more than one layer of testing at a time. That is, during Pact provider verification you shouldn?t use Pact mock servers for downstream providers, you should just stub them using whatever makes sense for your framework/tech

matt.fellows
2023-10-03 05:17
This article could be fleshed out more, I think: https://gist.github.com/bethesque/43eef1bf47afea4445c8b8bdebf28df0

abubics
2023-10-03 05:28
btw, separate to the question, this diagram looks like it expects all contracts for provider Y to change in sync with the provider version (v2), but those versions can move faster or slower than a major version. (i.e. there can be a contract change every commit, or there could be no contract changes in a commit)

abubics
2023-10-03 05:30
In fact, as hinted in the next thread, each consumer-provider pair has a version, distinct from the participants' versions.

matt.fellows
2023-10-03 10:16
:mega: *Pactober announcement* At 3pm BST / 10am EDT today @yousafn is running a FREE online https://github.com/pact-foundation/devrel/issues/21. Saf will be taking you through an end-to-end workshop where you?ll learn all of the basics of HTTP-based consumer-driven contract testing, including matching rules, provider states, handling negative scenarios and finishing with a few steps focussed on the broker experience to give you a taste of CI/CD integration. Yousaf will run through the 13 step workshop - you can watch him take you through the workshop, play along yourself, or use the recording to help guide a workshop in your own time. It?s a FREE event, you?re welcome to bring along anybody you think would benefit Next week, he?ll continue with a message (event-driven) focussed workshop Join the workshop here :point_right: https://smartbear.zoom.us/j/96107524752 _A reminder that all of the workshops and the main event (the Birthday Bash) can be seen https://pact.io/pactober (please register for the main event). All events will be recorded and streamed to YouTube._

jonathan.ryding
2023-10-03 12:02
has joined #general

corey_maynard
2023-10-03 13:17
Hi Matt! Yeah, I definitely see how there would be 'duplicate' requests, even as you can see in my example from there would be two requests to `/foo/bar/` - but that seems like something that could be resolved through an additive deduplication before the contract is generated. Just as a swagger file describes the provider's options (`/foo/bar` returns a 200 with a JSON object with a 'foo' key, or returns a 500 with a detail key) presumably it should be possible to reduce the two mocked calls in the Jest test to describe the multiple requirements of the single API endpoint consumed? I don't fully understand the comment about states there either, the swagger document doesn't provide explicit states in it so how would it match up anyways? I also don't follow what you're saying about how using the swagger file resolves the problem? As far as the anti-pattern, I've not seen that specific verbage mentioned anywhere, but I've seen multiple sites talking about how using pact for functional testing is a no-no: ? https://docs.pact.io/consumer#use-pact-for-contract-testing-not-functional-testing-of-the-provider As one example

corey_maynard
2023-10-03 13:19
I've seen things talking about using cypress to generate a consumer's contract...how is that any different from generating it via jest tests? both are functional things - cypress is driving a browser to do actions, jest is simulating a browser

corey_maynard
2023-10-03 13:20
What it comes down to is I'm looking for a way of having my consumer generate a contract without having to manually create every interaction...since I've already got functional jest unit tests that are performing every interaction already

corey_maynard
2023-10-03 13:24
From the cypress side it seems like you're assuming that it's using network stubs: https://pactflow.io/blog/use-cypress-in-contract-testing/ - however for our product we are using cypress to test the whole stack (End to End testing). Therefore we're not mocking out the cypress requests at all, and instead are performing the cypress testing on a full live server.

corey_maynard
2023-10-03 13:35
That to me implies that the intended integration with cypress wouldn't work for us. If that's the case, and there's no way to generate a contract from mocked requests in Jest, then it seems the only way to generate a consumer contract is to create pact specific tests for every endpoint and its interactions...Which as I said before I don't think works for us because it wouldn't actually touch the production code to ensure that it is using the same structure the pact document says, and that it sounds like a ton of manual work that would need to be done. Do you guys agree? Or am I missing something here? To summarize my situation is: ? Consumer is a React application ? Consumer's requests to the provider are embedded directly in the components that use them ? Cypress is run against a live system without any mocking in place

kevin
2023-10-03 15:02
I think maybe I missed one point. In most of the situations when verification is failed in provider, we don't alter the contract being verified, right? We may fix the code in the provider until it can fulfill all the expectations of the contract, but we will not alter the contract. For consumer driven contract, the only situation we will create a new contract is when we replace the consumer with a new version, and we need to generate a new contract and verify it.

kevin
2023-10-03 17:29
So, if we don't change consumer side contract of `Consumer X`, we don't need to reverify `Parent consumer P`, right?

abubics
2023-10-04 00:01
That really depends on what's wrong. If the consumer was requesting or expecting something incorrect, it will have to change. Basically, both sides can change at any time, and the automated-integration-triggering workflow should highlight breakages (or confirm compatibility) in the minimum time possible. Then, `can-i-deploy` will tell you what's safe to deploy (right now, or together in the future)

abubics
2023-10-04 00:01
But yes, if the consumer looks correct, usually just the provider would need to change.

abubics
2023-10-04 00:02
Also, remember that Pact isn't a replacement for communication, it's just highlighting problems you were going to have anyway (which helps facilitate better communication).

gabe.hollombe
2023-10-04 03:17
has joined #general

matt.fellows
2023-10-04 05:08
For my answers, not that BDCT = bi-directional contract testing = compare a pact file against an OAS (see https://docs.pactflow.io/docs/bi-directional-contract-testing/#trade-offs) > Yeah, I definitely see how there would be ?duplicate? requests, even as you can see in my example from there would be two requests to `/foo/bar/` - but that seems like something that could be resolved through an additive deduplication before the contract is generated that might be straightforward for basic examples, but quickly gets hard - e.g. there might be different shaped payloads, or payloads with different keys that are enums etc., that are worth testing. It would be hard to de-duplicate these without being lossy. But yes, it?s plausible. > I don?t fully understand the comment about states there either, the swagger document doesn?t provide explicit states in it so how would it match up anyways? > I also don?t follow what you?re saying about how using the swagger file resolves the problem? Correct. But we don?t need states when comparing consumer requests against the spec, so the problem about ?too many? goes away, as it doesn?t create an additional burden on the provider API team. It?s only a problem if the validation happens in a Pact style (request-response) model, because the actual API call is made to the provider that needs to be able to respond accordingly - this is where the maintenance and alignment problem creeps in. See also this cautionary tale :point_right: https://pactflow.io/blog/a-disastrous-tale-of-ui-testing-with-pact/ > I?ve seen things talking about using cypress to generate a consumer?s contract...how is that any different from generating it via jest tests? both are functional things - cypress is driving a browser to do actions, jest is simulating a browser You?re right - it?s not, but it?s (and the MSW, Wiremock and similarly others) not designed for use with Pact. It?s designed for use with the BDCT capability. > From the cypress side it seems like you?re assuming that it?s using network stubs: https://pactflow.io/blog/use-cypress-in-contract-testing/ - however for our product we are using cypress to test the whole stack (End to End testing). Therefore we?re not mocking out the cypress requests at all, and instead are performing the cypress testing on a full live server. If you?re doing that, then do you need contracts? You?re testing the real thing anyway? All you?re really doing there is recording what you know (this is a simplistic view of the situation, but I want to make sure you understand the value). The point of Pact is to avoid e2e tests where you can, replacing them with faster, lightweight and reliable tests that can be used in mulitple contexts - including in cypress tests.

matt.fellows
2023-10-04 05:09
> ? Consumer?s requests to the provider are embedded directly in the components that use them this sounds like a bad practice to me, but React in general sounds like a bad practice to me :trollparrot:

pratyusha.boyapati
2023-10-04 08:35
has joined #general

mateusz.socha
2023-10-04 10:41
has joined #general

corey_maynard
2023-10-04 18:53
Regarding the cypress side, yeah, the reason I'm interested in Pact is I would like to test for broken contracts before it gets to the Cypress, which is why I was interested originally in trying to have the already existing functional Jest tests create the Pact contract. Because, you're absolutely right - Cypress is running against a live system it is validating contracts (and everything else an e2e framework would do). I was hoping that by having the Jest tests generate a contract, and having the swagger file be a contract that I could use the two of those through the CI tooling to block any PRs that break the contract as defined in the PR being tested. We aren't running Cypress on PRs (takes too long, etc), so this would allow developers to catch breaking contracts before feature merge. Sounds like a good idea to me! Unfortunately, yeah, it seems that because we're not using an API service class and our Cypress suite is doing true e2e testing, I'm not seeing a way to get a consumer pact generated in a sensible way. Defnitely still willing to be convinced otherwise, as I very much see the value that is provided by Pact here, I just don't see how my team can use it without restructuring every client side API call to a service.

matt.fellows
2023-10-05 05:01
> I was hoping that by having the Jest tests generate a contract, and having the swagger file be a contract So yes, you can do that, just not with Pact (the BDCT feature above would support it). You could by all means try if you think you can workaround those problems/limitations discussed - they aren?t insurmountable, but they are definitely something you?d need to handle

maja.vitaz
2023-10-05 10:37
has joined #general

martindjk92
2023-10-05 13:05
has joined #general

james814
2023-10-05 20:24
has joined #general

craig.kilpatrick
2023-10-06 00:33
has joined #general

prabakaranplaced
2023-10-06 08:00
has joined #general

prabakaranplaced
2023-10-06 08:02
Hi Team I want to generate PACT Json files directly from Swagger Json files using Java. Do we have any existing java based solution for this ?

yousafn
2023-10-06 12:16
Its not really a done thing, because an OpenAPI definition describes how a service should work, and provides examples of how it may be interacted with and what responses it may provide but doesn?t correlate to your actual consumers usage, which is what the pact file captures as part of the consumer contract test What use case are you trying to fulfil?

matt.fellows
2023-10-06 12:44
Just on mobile, but search http://docs.pact.io for swagger. There's a discussion there

bas
2023-10-06 13:25
In all honesty, I think this is a big, big, BIG no-go. You want your consumer contracts to express _how your customers consume your service and what they expect_. Not _how the service actually responds_. The discrepancy between those two is exactly what contract testing attempts to bring to the surface. Generating consumer contracts from provider specifications completely erases that. There might be a case for generating provider-side acceptance tests from specs (and even that is questionable in my opinion), but I really, really would advise against doing this in contract testing.

likekeys
2023-10-06 14:22
has joined #general

chris.odryna
2023-10-06 16:51
has joined #general

rezaur.rahman
2023-10-06 17:39
has joined #general

julie.laursen
2023-10-06 17:43
has joined #general

pratibha.kachi
2023-10-06 20:02
has joined #general

robert579
2023-10-06 20:22
has joined #general

matt.fellows
2023-10-06 23:17
Nailed it Bas!

sbalaranganathan
2023-10-09 12:10
has joined #general

henrik
2023-10-09 18:15
has joined #general

matt.fellows
2023-10-10 08:55
:mega: *Pactober announcement* In ~10 mins~ 5 mins (10am BST / 8pm AEDT) the main birthday event kicks off, with talks from @sam647, @bas, @lewis.prescott079, Dave Farley, @me1414 and the Pact crew. See the https://pact.io/birthday and tune in here :point_right: https://www.youtube.com/watch?v=s1LOP4Ak5SA

johnkavadias
2023-10-10 09:37
has joined #general

yousafn
2023-10-10 13:19
Want to ask a question to the legendary @me1414? Tune in now https://www.youtube.com/watch?v=s1LOP4Ak5SA and drop a question in the chat

jose-antonio.cano
2023-10-10 16:21
has joined #general

panagiotis.liaros
2023-10-11 10:15
has joined #general

ananya
2023-10-11 10:38
has joined #general

omar.sakka
2023-10-11 14:38
has joined #general

lepdiana01
2023-10-11 14:42
Hi, given a scenario where I am targeting. signup endpoint, the consumer is frontend, would the consumer test live in the frontend repo?

brandon.king
2023-10-11 18:35
has joined #general

sridhar.nayakwadi
2023-10-11 20:56
has joined #general

saroja.bhogadhi
2023-10-11 20:58
has joined #general

abubics
2023-10-11 23:14
Yep. Contract tests live like unit tests.

suat.kose
2023-10-12 12:14
Hi, I added below canIDeploy stage in my gitlab pipeline. I can see the installation log as *"pact-ruby-standalone v2.0.7 installed to /builds/xrGFoCjz/0/mpl/jetdelivery/pact"* But then, the pipeline fails due to to error -> *"/builds/xrGFoCjz/0/mpl/jetdelivery/pact/lib/ruby/bin/ruby: exec: line 6: /builds/xrGFoCjz/0/mpl/jetdelivery/pact/lib/ruby/bin.real/ruby: not found"* ```canIDeploy: stage: canIDeploy before_script: - apk add bash - apk add curl needs: - test script: - curl -fsSL https://raw.githubusercontent.com/pact-foundation/pact-ruby-standalone/master/install.sh | PACT_CLI_VERSION=v2.0.7 bash - ./pact/bin/pact-broker can-i-deploy --pacticipant Foo --latest tags: - k8s```


suat.kose
2023-10-12 12:23
Thank you! I guess it would be easier to try a debian image :grill: (if its possible for us)

yousafn
2023-10-12 12:52
it would yes, the ruby runtime is built on centos7 (with glibc) and the later rust core, is available with a musl version but this isn?t included in many of the client libraries, so we recommend debian slim based images for light weight images

chris.paul
2023-10-12 15:54
has joined #general

ryan.standley
2023-10-12 17:34
has joined #general

joseph
2023-10-12 20:58
has joined #general

pratibha.kachi
2023-10-12 21:14
Hi, If I add a field to the endpoint, what do I need to make sure consumer fails for such changes?

laurie.green
2023-10-12 22:46
has joined #general

matt.fellows
2023-10-12 23:47
why would it fail the consumer? Is this a new required field on the request?

nikesh1123
2023-10-13 10:32
has joined #general

imthu55
2023-10-13 11:05
has joined #general

aravind.pai
2023-10-13 12:12
I believe it's the opposite. If you _remove_ a field, the consumer tests will fail (assuming they were actually using that field). If you add a new field, but don't change the behaviour of existing fields, then the consumer is not affected, hence their contract tests should _not_ fail. I wonder though, if the contract tests can identify _fields_ unused by the consumer(s), so that the provider can potentially remove them. My hunch is that this should be handled by conventional code coverage, not by contract tests per se. Which leads to a potential resolution to your question. If the goal is to ensure in a somewhat automated way that the consumer uses the new field, then one possibility is, the code coverage in their tests will drop if the field is not used. However, this is perhaps better communicated by conventional means, that is, talking to the consumer's developers. (I'm assuming that was already done, and the idea described in this question is a supplement to that.)

dzianis_frydliand
2023-10-13 12:36
has joined #general

john.maynard
2023-10-13 14:35
has joined #general

cmuddam.testing
2023-10-15 06:46
has joined #general

david.vadkerti.toth
2023-10-17 08:28
has joined #general

shirley.houter
2023-10-17 08:52
has joined #general

ruth.kurniawati
2023-10-17 20:02
has joined #general

daviseago
2023-10-17 21:56
Hi, I have a question that always troubles me from using pact. 1. Pact is a great tool for contract/integration test, which is usually at the border of the system. 2. Both parties (consumer/producer) of the test needs to include Pact in their test suite so that contract testing really takes effect. 3. However, since it?s at the border, it usually means they belong to two different teams. It?s hard to impact the other team to accept the contract test and implement it. Is my understanding true? or do I miss something? Thanks

matt.fellows
2023-10-17 22:16
Is the problem that they disagree with what you have in the contract, or just don?t want to participate in the testing altogether?

daviseago
2023-10-17 22:46
the latter. They always want end-to-end test

matt.fellows
2023-10-17 23:17
so aside from all of the documentation, videos and blogs we have, no :stuck_out_tongue:


matt.fellows
2023-10-17 23:18
This is a great video from Dave Farley: https://www.youtube.com/watch?v=QFCHSEHgqFE

matt.fellows
2023-10-17 23:19
We also had Sam Newman, Dave Farley, JB Rainsberger and Seb Rose do talks on this in our Pactober event: ? Main event with Sam, Dave and JB: https://www.youtube.com/watch?v=s1LOP4Ak5SA ? https://www.youtube.com/watch?v=5vAV1lTGJyE They talk about the problems with this kind of testing too

matt.fellows
2023-10-17 23:21
Ultimately, if they don?t have pain it?s hard to convince them if they?re aren?t having problems. You can either 1. Capitalise on the pain/cost/problems - ?hey, so i can see you?re struggling. here?s a better way that will reduce the number of grey / lost hair? 2. Make an argument about ROI (reduce the time/cost of testing) 3. Make an argument from better test strategy I?ve found (1) to be the most powerful, frankly. So I?d be looking for opportunities to say ?hey, that problem/pain you have - it?s because of the way you?re testing?

balaaji196
2023-10-18 10:46
has joined #general

mpokala
2023-10-18 20:37
has joined #general

hiroki.gota
2023-10-18 22:26
has joined #general

mattisrobin
2023-10-18 22:37
has joined #general

silvimasss
2023-10-18 23:43
has joined #general

wanghedi88
2023-10-19 11:16
has joined #general

sarah.diendorfer
2023-10-19 12:34
has joined #general

ahmed.elakour
2023-10-19 12:35
has joined #general

parmin.rock
2023-10-19 14:57
has joined #general

victor.yusuf
2023-10-19 14:58
has joined #general

allen.ayala
2023-10-19 15:13
Good morning, I?m trying to pull some reports from the PactFlow DB, and I wanted to figure out whether a participant is doing CDC or BDC. Is there a way to check for this on the DB?

allen.ayala
2023-10-19 15:15
@matt.fellows

luke.dove
2023-10-19 15:46
has joined #general

lee.andrews
2023-10-19 15:52
has joined #general

yousafn
2023-10-19 16:06
Hey @allen.ayala, good morning :sunshine: Please don?t tag people directly, maintainers regularly view the forum. It?s one of our community guidelines. Secondly, could you please post via the #pactflow channel, as this is specifically a PactFlow related question. Thanks in advance dude!

mitchellp
2023-10-19 16:06
has joined #general

allen.ayala
2023-10-19 20:44
Sorry, my bad. I?ll keep that in mind

mickelback00
2023-10-19 22:25
has joined #general

philip.buttinger
2023-10-20 10:36
has joined #general

adrian.kosyra
2023-10-20 11:58
has joined #general

dave.hooson
2023-10-20 15:13
has joined #general

pavankumar.cse88
2023-10-20 17:58
has joined #general

nathan
2023-10-21 01:30
Hi, I want to turn my consumer Pact test response body objects into mocks for unit tests. The problem I have is that these mocks will have matcher objects nested in the response dictionary (python) that my unit tests won't know how to handle. Other than avoiding using matchers like `Like`, how can I "clean" these dictionaries or otherwise use them for unit tests?

matt.fellows
2023-10-21 01:59
I can think of a few approaches. You could strip the matchers off (JS had a function to do that you could review). You could just read in the generated pact file because the examples won't have matchers in them

nathan
2023-10-21 02:42
I think I prefer the idea of using the pact file. I have so far chosen to leave my pact file uncommitted, to avoid publicly committing data used in our test environment. If I continued with uncommitted pact files, I think in CI I would need to ensure consumer pact tests are run first (generating pact file), before unit test mocks can be dynamically generated via pact file.

matt.fellows
2023-10-21 04:53
one challenge with that approach, is that you would need to parse the pact file and then re-map to each test (I guess you could use the description+state to do that)

matt.fellows
2023-10-21 04:55
A nicer approach might be to have a `fixtures` directory with all of the payloads in there, e.g. ```fixtures - api1.py # contains all of the interactions for the API, or scenario or however you cut it up - api2.py ...``` Then for each Pact test, you just pull them in as is with the matchers etc. already specified For other tests, you could use them also, and create a `reify` function that strips away the matchers and pact specific stuff. This way, you know the mocks used in one part of the code base can?t drift from the other


the.m.bjorklund
2023-10-21 21:05
has joined #general

the.m.bjorklund
2023-10-21 21:09
Hi, it seems your latest release of pact-python 2.1.0 didn't get published with pypy? Was that a mistake or intentional? https://pypi.org/project/pact-python/

joshua.ellis
2023-10-21 22:36
Hi! There was a small mistake unfortunately in updating the CI publishing script and I'm working with the previous maintainers of Pact Python to fix this so that I can manually publish Pact Python 2.1. In the meantime, there are two things you can do: 1. The binary wheels are available to download from the https://github.com/pact-foundation/pact-python/releases/tag/v2.1.0 (you will just have to make sure to use the right platform/Python version combination) 2. You can also point to the `v2.1.0` tag directly `pip install -U git+https://github.com/pact-foundation/pact-python.git#v2.1.0` Please let me know how it goes :rocket:

nathan
2023-10-22 01:02
Ok I decided I agree after realizing I would have to run the tests in a certain order. So here is my python `reify` function: ```JsonType: TypeAlias = Union[None, int, str, bool, List[Any], Dict[str, Any]] PactBody: TypeAlias = Union[Dict[str, Union[JsonType, Matcher]], Matcher] def _convert_matcher_to_value(matcher: Matcher) -> JsonType: return matcher.generate()["contents"] def _reify_pact_body( body: PactBody, ) -> JsonType: if isinstance(body, list): for index, item in enumerate(body): if isinstance(item, Matcher): body[index] = _convert_matcher_to_value(matcher=item) body[index] = _reify_pact_body(body=body[index]) return body elif isinstance(body, Matcher): return _reify_pact_body(body=_convert_matcher_to_value(matcher=body)) elif isinstance(body, dict): for key, value in body.items(): if isinstance(value, Matcher): body[key] = _convert_matcher_to_value(matcher=value) body[key] = _reify_pact_body(body=body[key]) return body else: return body```

the.m.bjorklund
2023-10-22 08:59
Thanks a lot for your response! Before you answered, I actually downgraded httpx to 0.23.3 such that I could install pact-python 2.0.1. Then I got everything working :tada: Now that I installed 2.1.0 using that github link and bumped httpx to 0.25.0 I'm getting connection timeout errors when making calls to the pact service :grimacing: Just went back to 2.0.1 and 0.23.3 and it started working again. I will try to investigate a bit more to figure out what's wrong..

joshua.ellis
2023-10-22 09:17
Strange, it shouldn't be giving timeouts. Do you mind if we pick this conversation up in the #pact-python channel? And if you can share some logs and/or a small example that reproduces the error that would be amazing :smile:

thepiesaresquared
2023-10-22 09:58
has joined #general

vasile.vetisan
2023-10-22 17:50
has joined #general

sartom1994
2023-10-22 18:52
has joined #general

rebecca.fulton
2023-10-23 09:27
has joined #general

joao.jesus
2023-10-23 10:20
has joined #general

kai.moseley
2023-10-23 10:47
has joined #general

gunarajs
2023-10-23 19:23
has joined #general

ctrando
2023-10-23 21:14
has joined #general

thibault.alix
2023-10-23 22:29
has joined #general

kwapisz.bartosz
2023-10-24 08:38
has joined #general

marekurbanowicz
2023-10-24 10:02
Hi, Did anyone approach Pact+DAPR pub/sub contract testing? Everything in this setup is twisted and I am confused how to approach it in the best way. The consumer is invoked through REST API by DAPR sidecar, while producer is invoking REST API of Dapr sidecar. Anyone can share experience?

the.m.bjorklund
2023-10-24 10:11
Absolutely - I ran out of time to work on this this weekend. But will pick it up soon enough! Promise

the.m.bjorklund
2023-10-24 10:11
and thanks for all your work with Pact!

matt.fellows
2023-10-24 10:41
hmm it sounds like the pattern is pub/sub, but implementation is REST. If it?s REST, can it not be tested in the usual way? If the REST bit is simply implementation detail (e.g. hidden away by infrastructure), the bit you care about is the message that is sent and received, in which case, the usual ?message pact? advice applies


matt.fellows
2023-10-24 10:41
see some examples here :point_down: (howtoexamples)


kwapisz.bartosz
2023-10-24 10:49
Hello everyone! In my company, we are trying to understand the boundaries of the contract tests written in pacts. Of course, we've read https://docs.pact.io/consumer (and watched the awesome video placed there), but we still have some doubts. Currently, our consumer messaging tests are very naive, we just return a JSON created from a DTO object created by hand -> so in fact, any of the layers of our application is not called. ? Is there any pattern that could we use to make our tests a little more intelligent to verify whether the message is correctly handled by our service? ? Is it a good idea to mock repositories and verify if an object that we get asynchronously is correctly written to a repository? ? If not, why :)? Could you please share any articles/presentations related to such topic?

btacca
2023-10-24 12:02
has joined #general

anton.l.petersson
2023-10-24 13:54
has joined #general

jowhalen13
2023-10-24 16:27
has joined #general

tanyagorn.benjaprompa
2023-10-25 08:09
has joined #general

tanyagorn.benjaprompa
2023-10-25 08:25
Hi, anyone using webhook with event contract_requiring_verification_published? There are lots of webhook triggered by this event type. It doesn't look right to me. As I expected this to trigger only provider main branch pipeline with *latest version.* Somehow it trigger all version under provider main branch, and I end up getting a bigger list of trigger pipeline day by day. Something definitely wrong here, anyone can help point me to the right direction?

tanyagorn.benjaprompa
2023-10-25 08:34
Actually, seem like it create trigger pipeline for all version that has been *released in prod* "event_name":"contract_requiring_verification_published","provider_version_number":"1.331.0","provider_version_branch":"develop","provider_version_descriptions":["released in prod"]} but that's not I want, I just need it to trigger only latest version :cry:


matt.fellows
2023-10-25 09:35
Do you genuinely have multiple released versions at the same time, or should you be using deployments instead?

tanyagorn.benjaprompa
2023-10-25 09:45
@matt.fellows Unfortunately I cannot apply concept of _Recording deployments and releases_ to any of my projects. We automate everything except deployment part. We still deploy product to production *manually.* So I've never used *--environment* tag. However, it seem all of that has been tagged with _released in prod_. How is that possible? btw, if I cannot record deployment and releases. Does that mean I shouldn't use contract_requiring_verification_published at all and fallback to contract_content_changed, right?

matt.fellows
2023-10-25 10:00
If you can't automate it, can you not still update Pactflow manually via a CLI call?

matt.fellows
2023-10-25 10:00
And that's correct, probably it's not ideally suited to you. I'd need to re read that article

yousafn
2023-10-25 13:57
Use of that webhook `contract_requiring_verification_published` requires use of record-deployment and record-release https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event > Use of this webhook requires that: > ? the provider?s https://docs.pact.io/pact_broker/branches#pacticipant-main-branch-property is configured > ? verification results are https://docs.pact.io/pact_broker/branches#configuring-the-branch-when-publishing-verification-results or you are https://docs.pact.io/pact_broker/branches#automatic-branch-creation-from-first-tag (even if you use trunk based development, and only ever use one branch) > ? the exact commit of a provider version can be determined from the version number used to publish the verification results (ie. it either _is_ the commit, or _contains_ the commit as per the Pact Broker https://docs.pact.io/getting_started/versioning_in_the_pact_broker#guidelines) > ? any deployments and releases are recorded using the `record-deployment`https://docs.pact.io/pact_broker/recording_deployments_and_releases`record-release`https://docs.pact.io/pact_broker/recording_deployments_and_releases. We would probably need additional context about your setup, how you publish and verify contracts, whether you use branches/tags, what selectors you use for verifying, and when do you verify, and additionally how you record your releases and deployments.

yousafn
2023-10-25 13:59
> Unfortunately I cannot apply concept of _Recording deployments and releases_ to any of my projects. We automate everything except deployment part. We still deploy product to production *manually.* It is just a cli command, it can be run manually when the deployment is manually performed. (Without knowing the details on this manual deployment its hard to describe any specifics) however from Pact?s perspective its simple. It just needs someone to tell it that x version for y application is deployed to z (undeploying all other versions) or released to z (to sit alongside other versions of the application)

yousafn
2023-10-25 14:00
Also there should be additional information in the webhook passed to your pipeline, in order for your CI system to check out the correct provider builds > A webhook using the `contract_requiring_verification_published` should be configured to pass through the `${pactbroker.pactUrl}` and `${pactbroker.providerVersionNumber}` and `${pactbroker.providerVersionBranch}` to the provider verification build. The Broker then will trigger the execution of the provider version of the _main branch_, and also the provider version for every _environment_ it has been deployed to, but we need to let our CI application know what versions to build. That?s why the parameters `${pactbroker.providerVersionNumber}` and `${pactbroker.providerVersionBranch}` are needed.

benguizat
2023-10-25 14:04
has joined #general

stan196
2023-10-25 23:42
has joined #general

manalikhanna92
2023-10-26 07:09
has joined #general

aaron_carey
2023-10-26 09:26
has joined #general

ms.maheshhwari
2023-10-26 09:54
has joined #general

ohisproperties2
2023-10-26 16:34
has joined #general

anupama_enakula
2023-10-26 21:45
has joined #general

roger.liu
2023-10-27 07:15
has joined #general

roger.liu
2023-10-27 07:19
Hi. Is it considered best practice to use a dynamic date for includeWipPactsSince? The documentation only shows examples with static dates like "2020-10-31". But will it be a problem say a year from now? That it could fetch WIP pacts since that date. Rather, is it better to just configure it as something like new Date().minusDays(7) for WIP pacts within a week.

tanyagorn.benjaprompa
2023-10-27 09:25
Thanks for the context. We are just starting to use contract testing in our company. So there are lots of things that we're still struggling. For now, I decide to just stick with contract_content_change. Anyway thank you so much :pray:

yousafn
2023-10-27 12:24
Catch @alejandro.pena & José Maciñeiras live now on YouTube, wrapping up Pactober with their introduction of a new tool for automating the body generation for Pact interactions in Java https://pact.io/pactober/2023/pact-jvm-dsl https://www.youtube.com/watch?v=whXaNti7PSg

nathan
2023-10-27 12:49
Good morning! When I run the verifier locally via the Python API, what does the variable `PACT_URL` https://docs.pact.io/implementation_guides/python/readme#python-api-1 represent?

bas
2023-10-27 12:53
Looks like it?s the base URL of your provider service. IMHO the variable name is a bit confusing here.

yousafn
2023-10-27 13:01
My pleasure, and no problem, appreciate there is alot to grasp when you are new. Don?t worry though, we are here to help where we can and it is okay to ask questions

nathan
2023-10-27 13:12
Ok...I thought so, but I couldn't decide if it was the for the pact mock or not

nathan
2023-10-27 15:15
Another question - hope this is the right place to ask. When I attempt to run pact tests locally (local pact file, local provider, pact mock host), I get an error that my request headers are different than previously. How does it come to this conclusion? Am I actually pointing it to my real broker somehow?

nathan
2023-10-27 15:16
```AssertionError: An interaction with same description ("a request for a Data Context") and provider state ("the Data Context exists") but a different request headers has already been used. Please use a different description or provider state, or remove any random data in the interaction.```

nathan
2023-10-27 15:20
I think I'm misunderstanding what the pact mock host/port actually represents. ``` pact_test: pact.Pact = pact.Consumer( name=CONSUMER_NAME, version=version, tag_with_git_branch=True, auto_detect_version_properties=True, ).has_pact_with( pact.Provider(name=PROVIDER_NAME), broker_base_url=pact_broker_base_url, broker_token=broker_token, host_name=PACT_MOCK_HOST, port=PACT_MOCK_PORT, pact_dir=str(PACT_DIR.resolve()), publish_to_broker=publish_to_broker, )```

nathan
2023-10-27 15:26
Everything works fine in CI, and I think the only difference is I'm using the read-only token locally, and the read/write token in CI.

senbaga.kumarsigamani
2023-10-27 16:12
has joined #general

yousafn
2023-10-27 16:35
Hey @nathan So the pact mock, on the consumer side of your testing, will which serve as a stand-in for your real provider. You set up an interaction, which contains the request you expect your client to make, and the response you expect it to return. If your client code issues the correct request you specified, and the pact mock provider receives it, it will send the response that you setup. You can then perform unit test assertions on your system under test, given that is received a particular response from the provider. Pact python additionally has some helper functions to allow it to publish to a broker after a test run, this is why you have options such as ? version ? tag_with_git_branch ? auto_detect_version_properties ? publish_to_broker ? broken_token These really are a separate activity (publishing pacts to a broker) than the execution of the pact tests. If you are trying to publish to a broker, with the same version as a previously published pact, and the content within that pact has changed (random data perhaps) - the pact broker will inform you that you cannot do so. It may be that `publish_to_broker` is set to true. Also do you have more than one test, do those tests share the same given and when statements? ```("a request for a Data Context") and provider state ("the Data Context exists"```

yousafn
2023-10-27 16:37
yeah that is really badly named, a `PACT_URL` would normally refer to a file path or url of a pact to be verified. (as per our docs) that really should be `PROVIDER_URL` in that instance. Would happily accept a PR to update :+1:

yousafn
2023-10-27 16:37
Thanks for raising! It is all to easy to get confused and not say something, but fixing that will help others I am sure!

alejandro.ignacio
2023-10-27 17:42
has joined #general

nathan
2023-10-27 17:55
? We have test data in a local version of our provider that we can get the provider states from ? We have the ability to convert the pact response bodies with the matchers into unit tests mocks and can run unit tests ? `publish_to_broker` is only set to true in CI, because our logic is setup in such a way that the flag only gets set to true if the user has a read/write token (which we only have in CI) ? We don't have more than one test that shares the same given. It seems like there is something either different in the request that I can't find, or there is something about how this all works that I don't understand.

yousafn
2023-10-27 18:01
Okay, sounds like we might need to see some of tests so draw some conclusions, as you may be a bit of the beaten path. I?m about to sign off now for the weekend as its 7pm in the UK, but sharing some of the actual test code would be useful. Not sure why you need to the local version of the provider, is that to get the correct names of provider states they already have mapped, or is that to help in constructing the response bodies for the provider?

nathan
2023-10-27 18:10
The local version of the provider was already setup for end-to-end tests. > is that to get the correct names of provider states they already have mapped We don't have provider states mapped so maybe that is the issue. We have test data that returns a response and in the given we are just describing the state that we know exists in the test db. > or is that to help in constructing the response bodies for the provider Right now we are just writing consumer-side tests. We are using the response bodies in consumer-side unit tests. It helps with constructing the response bodies because we get the diff for actual (in the test data) vs expected response body. Right now we don't see the diffs locally though, just in CI.

devendra.patil
2023-10-27 21:40
has joined #general

ksawery.karwacki
2023-10-27 23:32
Hi. I am trying to upgrade our flow from tags to contract selectors and I stumbled upon chicken or an egg problem that was already there but I hoped that contract selector will solve it. I have working process for https://docs.pact.io/pact_nirvana/step_7 but how should I handle the first time when I publish new contract between two services? I have two repositories with branch `feature/abc` containing first contract between two services. I cannot merge consumer as it will fail `can-i-deploy` (provider supporting contract is not yet deployed on target environment). If I merge provider it won't record deployment as contract selector looks for main branch and release/deployed pacts. Pending pacts and WIP pacts won't help as this contract was already verified from branch so selector returns no contracts when run from main branch after merge, it won't fail build just because the annotation `@IgnoreNoPactsToVerify`. It seems that I have to manually verify against branch `feature/abc`, rerun deployment pipeline to register deployment and then I can start merging consumer. Is there any valid way to do that without the need to manually running verification or hardcoding branch `feature/abc` in the selector? Did I miss something?

ulises.cervino
2023-10-28 11:33
say your consumer?s branch `feature/abc` implements consuming data from a new endpoint. What?s the danger in rolling out (and recording the act) of your provider?s branch `feature/abc` assuming that it doesn?t break contracts of _already rolled out_ consumers?

ulises.cervino
2023-10-28 11:34
I personally would solve the chicken-egg problem by rolling out the provider first. Always.

ulises.cervino
2023-10-28 11:34
the dynamics completely change when you have breaking changes in `feature/abc` in both sides. That?s a trickier problem, and my general reaction is ?don?t introduce breaking changes?

ksawery.karwacki
2023-10-29 21:57
Thr problem is that typically you would use commit id to calculate pacticipant version. Merge to main branch (release) creates new merge commit. If you implement version selector as documented CI after merge will search for contract that was: ? Released to any of the environments ? Main branch of consumer Which will return nothing as the only place where the contract exists is still branch `feature/abc` of the consumer. So verification will verify against zero contracts so provider version won't be registered in pact broker. Therefore you cannot register deployment of this version as it was never created in the pact broker.

abubics
2023-10-30 00:30
> Not sure why you need to the local version of the provider This is probably the point that's being missed, afaict. Consumer tests don't need a provider, that's what Pact provides for you. (The provider needs to exist later in the workflow, for verification)

matt.fellows
2023-10-30 01:06
> I think I?m misunderstanding what the pact mock host/port actually represents. I always think it?s helpful to frame Pact as a unit testing tool (it probably technically isn?t, but that?s not relevant just yet). This way, you can understand that: 1. During consumer testing, you?re only testing the smallest possible unit of work in this context - the code that makes an API call to another service. We call this a collaboration test 2. Pact is used in this collaboration test as the API _*mock*_ - this means it not only is a test double for the API you?re calling, the _behaviour_ is also checked. a. In Pact?s case, calls to the mock are what get recorded into the pact file. This is how we can be confident what is put into the contract is a valid representation of reality 3. On the provider side, once again, we?re going to isolate the provider code. Pact will stand in for the consumer, by replaying the requests in the contract file a. It?s usually a bit wider than a unit test on the provider side, but the mentality should be the same. Stub out external dependencies (e.g. other services) to isolate the bit you need to test

ulises.cervino
2023-10-30 06:47
oh, this is a new provider then?

shenkesi.shiva
2023-10-30 06:57
has joined #general

roger.liu
2023-10-30 07:15
bump

ksawery.karwacki
2023-10-30 08:45
Yes

matt.fellows
2023-10-30 09:44
In the past, the advice was not to make it dynamic. But that advice may have changed, let me find out

ulises.cervino
2023-10-30 09:44
right, and the provider exists in the broker already?

ulises.cervino
2023-10-30 09:45
my question is: if the provider exists as a thing in the broker, and can?t verify anything, should you be able to roll it out?

guido.lenacota
2023-10-30 09:48
has joined #general

ksawery.karwacki
2023-10-30 09:50
You have to record provider deployment first as if you followed the pact nirvana (https://docs.pact.io/pact_nirvana/step_7#add-can-i-deploy-to-environments-to-your-pr-pipelines) then you won't be able to even merge consumer due to can-I-deployment failing.

yihong.wang
2023-10-30 10:01
has joined #general

nathan
2023-10-30 14:41
Ok team. Back in the office here in the US. Thanks for some of the great conversation above about how it all works. I'm going to return to the original error message after we did some debugging and figured out what the issue was.

nathan
2023-10-30 14:48
We are seeing the error message about "An interaction with same description and provider state, but a different request headers has already been used" because for some reason the mock service is not always being stopped (despite using the `pact.stop_service()` pattern in the docs after `yield`ing the pact). I think maybe the debugger is having some sort of undesirable side effects, but I'm not 100% sure if that is the cause. So changes to the test were being run against the same mock service resulting in that error message. Running this fixes the issue: ```ps aux|grep pact kill -9 <pid> for each PID listed in the output of```

rafael.espillaque
2023-10-30 15:25
hi all, I'm afraid my searching skills were not enough and I have to ask here. I'm considering Pact for Messages with the diagram I attached as our example of event-driven architecture. Imagine that we want to introduce a change in the `OrderRequested` message. In Pact, the code of the providers has to be merged first, and the code of the consumer after it. This makes sense to me but I'm struggling to see if it also makes sense for event-driven architecture. If we merged `Basket Service` first, there would be errors (or at least a queue of messages) because `Payment Service` , the consumer, doesn't understand the new changes introduced by the provider. For me, in this case, we would introduce some code to the consumer to be able to handle both the old and new versions of the `OrderRequested` message, and after that, we'd merge the code to `Basket Service`. How would you handle this scenario, please? Was it clear enough? Thanks!

ulises.cervino
2023-10-30 17:24
how so? IIUC if you roll out the provider with branch `feature/abs`, and you record the rollout, then the consumer should be able to roll out as well (branch `feature/abc` ), no?

ksawery.karwacki
2023-10-30 18:04
I do not have rollout from feature branches only from main branch where matching by branch name won't work.

ksawery.karwacki
2023-10-30 18:05
The only possible piece of code that might get this to work is this note: https://docs.pact.io/pact_nirvana/notes_1

ulises.cervino
2023-10-30 18:21
right, I see, interesting. We might actually be running into the same problem: new provider (we?re the consumer), and the provider can?t find our contracts for some reason. They?ve never rolled out, etc.

ruth.bassindale
2023-10-30 20:54
has joined #general

matt.fellows
2023-10-31 00:07
so talking to the team, if you have a good idea of how old you expect your branches to be dynamic is fine (e.g. if most branches are finished within 2 weeks then that?s the window you can work with)

roger.liu
2023-10-31 00:08
Ok thanks. I'm guessing the reason for why you might not want it to be dynamic is that it can leave out real WIP pacts that someone hasn't finished yet?

matt.fellows
2023-10-31 00:10
yeah pretty much

roger.liu
2023-10-31 00:10
Thanks.

abubics
2023-10-31 02:02
Not sure if it's a Python-specific thing, but it feels like you're doing a bunch of manual work that the library should be doing, like `pact.stop_service()` . . .

matt.fellows
2023-10-31 05:42
I think the `pact.verify()` command is what clears interactions between tests, if that?s the problem. But the `stop_service()` command should stop the underlying mock. We?d need to understand why that?s not shutting the process down, because you should defnitely not have to `kill` the process manually.

matt.fellows
2023-10-31 05:43
If there is a way you can provide a repro build (ideally with a GitHub action that demonstrates the problem), that would help with investigating further. Once you can do that, I?d suggest creating an issue here: https://github.com/pact-foundation/pact-python/issues/new/choose.

vittorio.gue
2023-10-31 12:14
Hi @rafael.espillaque ! I dont know if I understand completely your flow but in general with Pact you have to avoid breaking changes! The provide should be merged first, adding a new field for example and no consumers should fail because no one is using that field. When you remove a field instead you will have to approach it on the opposite way around it. You first want to make sure that no one is using that field anymore (thank you Pact) and then you can safely remove the field.

vittorio.gue
2023-10-31 12:14
Consumers should only care about the information they need not the entire payload if they dont use it

sgavathe
2023-10-31 22:00
has joined #general

ntthaibk
2023-11-01 04:36
has joined #general

rskilling
2023-11-01 10:23
has joined #general

victor_do_val
2023-11-01 19:08
has joined #general

james.corry
2023-11-01 19:23
has joined #general

kiranpatel11
2023-11-01 22:43
Question related to the pactfile generated from tools like wiremock or mountebank : What is the usecase for such pactfile where matchers are not present at the source itself ? Is such pactfile only targeted for bi-directional contract verification supported by pactflow ? as they are not so useful to run as tests for traditional pact provider verification. If yes, then what is the difference in validating the stubs/mocks against the `OpenAPISpecification` for the consumers and validating the tests request/response against the `OpenAPISpecification` using simple library like https://bitbucket.org/atlassian/swagger-request-validator/src/master/ ? doesn't it gives the same schema-based validation same as the bidirectional contract verification ?

matt.fellows
2023-11-01 22:48
> Is such pactfile only targeted for bi-directional contract verification supported by pactflow ? as they are not so useful to run as tests for traditional pact provider verification. that?s correct

matt.fellows
2023-11-01 22:50
> If yes, then what is the difference in validating the stubs/mocks against the `OpenAPISpecification` for the consumers and validating the tests request/response against the `OpenAPISpecification` using simple library like https://bitbucket.org/atlassian/swagger-request-validator/src/master/ ? doesn?t it gives the same schema-based validation same as the bidirectional contract verification ? Yes. In fact, we have https://github.com/pactflow/swagger-mock-validator/ repository and it?s what is used at the core of the BDCT feature. It?s then wrapped up in the familiar PactFlow workflows with tools like `record-deployment` and `can-i-deploy`. The reason for the fork, is that there are several philosophical differences in approaching the problem (e.g. how it supports keywords, and what constitutes breaking changes etc.) They obviously built it for their own internal use case where they can control certain things, whereas of course PactFlow has a much wider audience to satisfy

matt.fellows
2023-11-01 22:50
great questions, and great digging!

kiranpatel11
2023-11-01 23:03
Thanks @matt.fellows, Appreciate the quick response (as always). So with that we are still limited by the schema-based contract testing, which unfortunately does not give higher guarantee and avoid the need for `integrated tests`.

matt.fellows
2023-11-01 23:08
I don?t think Pact fully alleviates all needs for integrated tests, at least, the context matters. Probably you will still have a few of those in most cases

matt.fellows
2023-11-01 23:09
With BDCT, the guarantees are a little bit less of course, but they are usually much easier / faster to get started. I?m assuming you?ve read the https://docs.pactflow.io/docs/bi-directional-contract-testing/#trade-offs?

matt.fellows
2023-11-01 23:11
Because we track the changes on both consumer and provider over time, BDCT addresses 6,7 and 8 from https://pactflow.io/blog/schemas-are-not-contracts/ 1 is not a problem with OAS and 3,4 and 5 can be mitigated with good testing and hygiene around OAS.

kiranpatel11
2023-11-01 23:12
yes, offcourse, I have. In fact I share your articles on the topic to facilitate the discussions with collegues :slightly_smiling_face: btw, I have also experimented with https://specmatic.in/, which does the same.

kiranpatel11
2023-11-01 23:14
but I find the using the atlassian swagger-request-validator library is much easier for the brown-field cases, where teams are already invested into using tools like rest-assured, wiremocks, etc.

matt.fellows
2023-11-01 23:14
> btw, I have also experimented with https://specmatic.in/, which does the same. Would love your feedback on usage of it. One thing about it that I?d like to understand is how it tracks the consumer changes over time, and how you know what consumers use which part of the API (amongst other questions)

kiranpatel11
2023-11-01 23:17
absolutely those are valid concerns/differences....but unfortunately the user base hardly dive into such level of concerns....they simply copy/paste or record the payloads by invoking the real services and continue using until they find they are stale.

rafael.espillaque
2023-11-02 09:20
Thanks for answering! I guess my problem is that I really need a breaking change, but I wanted to solve it by adding some code in `Payment service` so that it understands both the old and the new version of the `OrderRequested` message. How would we deal with breaking changes in general?

vittorio.gue
2023-11-02 10:10
I would use expand and contract! You first add a new field for example, you start consuming it! Then you remove the old field and thats it

vittorio.gue
2023-11-02 10:12
If you want to do a breaking change you will have to use versioning of events somehow and keep publising both

nicolas.cote-nolin
2023-11-02 12:30
has joined #general

sivaganesh.sivakumar
2023-11-02 13:18
has joined #general

sivaganesh.sivakumar
2023-11-02 13:20
Hey - Question regarding the `pactfoundation/pact-cli:latest` How to run a pact message provider test by using the docker image ? There is a verifier command but no mention about how to run message provider pact test. Any pointers please ?

rafael.espillaque
2023-11-02 13:24
thanks again I need a new version of the event, but I guess I can't merge the consumer first in a way that understands both the new and old versions. Instead, I need to publish both versions from the provider. I was thinking this was not ideal because I would be duplicating Payments. If I publish `OrderRequested` and `OrderRequestedV2` , then it'd be hard to ensure that only one of them is handled if PaymentService is deployed in a "RollingUpdate" mode. Do you see any way of improving this flow?

vittorio.gue
2023-11-02 17:13
Its completely normal to deploy the provider first! You could publish both events, and update your consumers one by one to listen only for the new event! When the no one uses the old event you can update the provider to stop publishing the deprecated event!

rafael.espillaque
2023-11-02 17:22
but what if version 1.12 of `PaymentService` reacts to `OrderRequested` and creates a `PaymentProcessed` event but also version 1.13 of `PaymentService` reacts to `OrderRequestedV2` and also creates a `PaymentProcessed`? I was thinking I wouldn't be able to have multiple containers of `PaymentService` being upgraded 1 by 1 (the RollingUpdate strategy) because of this reason :thinking_face:

matt.fellows
2023-11-02 23:11
Actually, you should use this tool for verifying message pacts (if you aren?t going to use a client SDK): https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli

matt.fellows
2023-11-02 23:11
Is there a reason you can?t use a client language? (e.g. JS, JVM etc.)

id.akanksha26
2023-11-03 11:38
has joined #general

yousafn
2023-11-03 13:04
These are the reasons one would use a Pact Broker, which you would have to deal with yourself by building probably similar tooling https://docs.pact.io/pact_broker#can-i-use-pact-without-a-pact-broker > .but unfortunately the user base hardly dive into such level of concerns....they simply copy/paste or record the payloads by invoking the real services and continue using until they find they are stale. No tool, can mitigate these types of behaviours. They can be addressed by better development practises, and appropriate check points, whereby there is appropriate peer review, which can pick up and challenge bad practises. You are going to get bitten by bugs at some point, at which point. users which to get that feedback is up to them. > they simply copy/paste or record the payloads by invoking the real services and continue using until they find they are stale. This is an approach, but its reactive, rather than proactive compared to Pact?s approach to CDCT. > So with that we are still limited by the schema-based contract testing, which unfortunately does not give higher guarantee and avoid the need for `integrated tests`. This isn?t contract testing sole aim (to remove integrated tests) rather to reduce the number of, and to provide feedback sooner, reducing the size of the haystack when understanding failures. In an integrated environment, you get high levels of confidence which you will _always_ want, as your production env will be integrated, but when an error occurs, you want to be able to pinpoint to the root cause, and that is much easier in isolation. If you?ve tested in isolation, and an error occurs in an integration environment, you know that you have certain touch points which are covered by contracts and okay, and the issue exists elsewhere.

yousafn
2023-11-03 13:07
I traditionally used OpenAPI and Swagger Mock Validator to drive API changes, and allowed the consumer to validate contracts prior to publishing to a broker. The provider would then use traditional CDCT to validate consumer contracts, getting better feedback, as its testing against at least a locally running provider implementation. details of sorts here https://blog.you54f.com/2019/02/19/protecting-your-api-development-workflows-with-swagger-openapi-pact-io/

prasant.iragavarapu
2023-11-03 15:06
has joined #general

yagocre
2023-11-03 22:46
has joined #general

sivaganesh.sivakumar
2023-11-06 12:04
We are using pact-cli and using pact-js to run message provider pact. Issue is we have alphine linux gitlab runners and we are facing issues in running the tests `pact-core@14.0.5: Failed to find native module for linux-x64: TypeError: Cannot read properties of undefined (reading 'pactffiInitWithLogLevel')`

sivaganesh.sivakumar
2023-11-06 12:05
@matt.fellows

steve.blomeley
2023-11-06 14:50
has joined #general

ndomingues10
2023-11-07 10:14
has joined #general

nswetha.reddy
2023-11-07 19:21
has joined #general

kiranpatel11
2023-11-08 00:55
@yousafn, I am not debating the usefulness of the CDCT vs schema-based contract testing. I am well aware about the trade-offs. However, my original question was to understand the similarities and limitation of generating the pact files from tools like WireMock and its applicability. As confirmed by Matt, they are not meant for typical CDCT but only useful for BDCT (schema-based only atm). The same level of confidence can also be achieved with tools like swagger-validator for both tests and stubs. There are few minor differences/advantages of using central tools like pact broker, tracking the changes per env/tagging, but those are not compelling enough for brown-field cases to rewrite existing tests using pact.

aparnakrishna1115
2023-11-08 14:55
has joined #general

harry.talbot
2023-11-08 15:05
has joined #general

daniel.phillips
2023-11-08 17:18
has joined #general

yuliya.rahalski
2023-11-08 20:15
has joined #general

olivier.picaud
2023-11-08 21:51
has joined #general

sivaganesh.sivakumar
2023-11-09 09:46
Used a node docker image based on ubuntu to resolve the issue in running the pact verficiation using pact-js

joseenrique.garcia
2023-11-09 12:56
has joined #general

ashish.patel5
2023-11-09 15:20
has joined #general

cnguyen
2023-11-10 08:31
has joined #general

nam.nguyen414
2023-11-10 12:35
has joined #general

lewis
2023-11-10 16:33
has joined #general

anna.lorenzi
2023-11-10 17:42
has joined #general

nathan334
2023-11-10 18:34
has joined #general

banghung859
2023-11-15 08:38
has joined #general

ianlutz
2023-11-16 04:00
Hi, i just had a meeting where i was trying to explain that contract testing should only test the contract; ideally stub out (aka mock) the downstream software components and services as thats the concern of other tests. Of course there may be exceptions to this ideal (very small service/laziness/some other reason). The issue I was advising against, was trying to drive your apps berhavioural testing et al (say in the provider - starting at the top layer) as giant 'integration' tests through pact - thats _not_ the responsibility of PACT and you can get very complicated flakey pacts and harder to maintain code (i.e. you can get yourself into trouble). I do recall a video by @bethskurrie on youtube, that i believe covered this subject, not sure if anyone can link me it (i cant find the right one) ? or comment; am I wrong - is my advice poor ? Thanks!! :wink:


ali
2023-11-16 04:50
has joined #general

ianlutz
2023-11-16 04:53
excellent thanks!! :slightly_smiling_face:

emmanuel
2023-11-16 09:40
has joined #general

dan.corder
2023-11-16 11:37
has joined #general

vikash.kumar.singh
2023-11-16 22:58
has joined #general

barbara.szczygiel
2023-11-17 14:08
has joined #general

maria.olivero
2023-11-17 16:57
has joined #general

daviseago
2023-11-20 06:25
Thanks Matt. There may be another bigger problem in the other team. They think it?s QA?s responsibility to test the system. So they don?t have pain doing e2e test.:face_with_raised_eyebrow:

matt.fellows
2023-11-20 06:33
> Thanks Matt. There may be another bigger problem in the other team. They think it?s QA?s responsibility to test the system. So they don?t have pain doing e2e test. find the person/people who pay them. The argument is (crudely, I hope you can extrapolate) ?those people are spending time writing and maintaining tests that are more complex, expensive and painful. We can all test smarter, and they?ll be able to focus their energy on higher value tests?

guozhangliew
2023-11-20 23:06
hi @matt.fellows do we have a query all providers by a consumer from the broker?

matt.fellows
2023-11-20 23:46
You could hit the `/integrations` endpoint, which gives you the lists of integrations


matt.fellows
2023-11-20 23:48
Without the content type, you will get a dotty content type

matt.fellows
2023-11-20 23:48
if you want JSON, ensure you set `Accept: application/hal+json`

madhawa
2023-11-21 04:59
has joined #general

pascal
2023-11-21 05:25
has joined #general

srinu.innovatus
2023-11-21 08:09
has joined #general

somya.khandelwal
2023-11-21 08:39
has joined #general

radek.stolarczyk
2023-11-21 11:35
Hello, I have written a POC for Java Pactflow. One service is sending a message to another service and I would like to compare the messages. I am trying to do the same in Python. Is that possible in Python? here is my Java code: My Consumer class: ```@ExtendWith(PactConsumerTestExt.class) @PactTestFor(providerName = "ProviderCDCT", providerType = ProviderType.ASYNCH, pactVersion = PactSpecVersion.V3) public class ConsumerContractTest { @Pact(consumer = "ConsumerCDCT") public MessagePact createMyPact(MessagePactBuilder builder) { Map<String, String> metadata = new HashMap<>(); metadata.put("content-type", "application/json"); DslPart sqsBody = new PactDslJsonBody() .stringType("messageId", "1") .stringValue("receiptHandle", "testRadek") .stringType("eventSource", "aws:sqs") .stringType("awsRegion", "us-east-1") .object("messageAttributes") .closeObject(); return builder .expectsToReceive("a message with information") .withMetadata(metadata) .withContent(sqsBody) .toPact(); } //This method is needed to create the pact files. @Test @PactTestFor(pactMethod = "createMyPact") public void testMyMethod(List<Message> messages) { } }``` My Provider Class: ```@PactBroker(scheme = "https", host = "", authentication = @PactBrokerAuth(token = "")) @Provider("ProviderCDCT") @Consumer("ConsumerCDCT") public class ProviderContractTest { private final ObjectMapper objectMapper = new ObjectMapper(); @BeforeEach public void setUp(PactVerificationContext context) { context.setTarget(new MessageTestTarget(List.of("Provider"))); System.setProperty("pact.verifier.publishResults", System.getenv("PACT_BROKER_PUBLISH_VERIFICATION_RESULTS") == null ? "true" : "true"); } @TestTemplate @ExtendWith(PactVerificationInvocationContextProvider.class) void testTemplate(PactVerificationContext context) { context.verifyInteraction(); } @PactVerifyProvider("a message with information") public MessageAndMetadata providerMessage() throws Exception { Map<String, String> metadata = new HashMap<>(); metadata.put("content-type", "application/json"); Map<String, Object> mainMessage = new HashMap<>(); mainMessage.put("messageId", ""); mainMessage.put("receiptHandle", "testRadek"); mainMessage.put("eventSource", "aws:sqs"); mainMessage.put("awsRegion", "us-east-1"); mainMessage.put("messageAttributes", new HashMap<>()); return new MessageAndMetadata(objectMapper.writeValueAsBytes(mainMessage), metadata); } }```


matt.fellows
2023-11-21 12:12
hey there! Probably best asking in the language specific channel. Are you wanting to know how to do message pact with Python? Perhaps start with https://github.com/pact-foundation/pact-python/blob/master/examples/tests/test_02_message_consumer.py and https://github.com/pact-foundation/pact-python/blob/master/examples/tests/test_03_message_provider.py

matt.fellows
2023-11-21 12:12
See also #pact-python

gomathi.velayutham
2023-11-22 12:40
has joined #general

ndruzhinina
2023-11-22 14:25
has joined #general

jaspal.puri
2023-11-23 10:05
has joined #general

ogbofjnr
2023-11-23 12:25
has joined #general

ogbofjnr
2023-11-23 13:08
Hi all, I'm working on contract testing for a message broker scenario. My consumer has a modular structure with a handler->transformer (simplified). I've realized that running the test with a mocked transformer dependency won't cover some cases from the transformer. Alternatively, I'm thinking about extracting necessary assertions directly into the contract test. This way, I can manually check the contract's compliance with specific aspects of the application's functionality, including those from the transformer and other modules. However, this approach might lead to a disconnection from the actual app logic and could be prone to errors if the logic changes. Which approach is more aligned with the best practices of contract testing using Pact?

patricio.dossantos_sl
2023-11-23 20:08
has joined #general

matt.fellows
2023-11-23 23:30
In case you haven?t seen, these docs help you understand how to write / think about message pact tests: https://docs.pact.io/getting_started/how_pact_works#non-http-testing-message-pact

matt.fellows
2023-11-23 23:32
In your case, you want be to testing the equivalent ?Port? in your code - that sounds like it could be the handler and not the transformer (given you are looking to mock the transformer). Ideally, any refactoring you do is outside of the test itself, so you don?t run into the concern you have (which I would share).

matt.fellows
2023-11-23 23:33
If you could perhaps communicate via an example that would help, inconsistent terminology in our industry makes this hard to talk about :slightly_smiling_face:

juliemarierosok
2023-11-24 08:51
Hey everyone! I have a consumer contract test where I want to reflect that we expect an array with at least one element containing a boolean with value true. From the forums and docs, I understand I can use "*arrayContaining*" to reflect this. I have two questions regarding this: ? I actually want to say we want only one element to have this boolean true, all other elements must have it as false. But I believe this is not possible to reflect? ? The bigger problem, is that I don't know how to use this "arrayContaining" in the DSL, while it seems to only be possible on arrays contained within an object. The event structure we are consuming is however containing an array on top level, so no parent object. And it is this array which has this requirement. I hope my problem is understandable, and that someone could help out :slightly_smiling_face: I am using Pact JVM btw

matt.fellows
2023-11-24 10:06
For questions on syntax, probably best bet is asking in #pact-jvm

matt.fellows
2023-11-24 10:07
but on this > I actually want to say we want only one element to have this boolean true, all other elements must have it as false. But I believe this is not possible to reflect? why does it have to be this way? (I?m asking to make sure you?re not enforcing a strict/unnecessary contract on a provider)

martin.gallauner
2023-11-24 10:40
has joined #general

ogbofjnr
2023-11-24 10:59
Thank you for your insights. To provide a clearer picture based on the example from the link you shared, I'm working with a receiveProductUpdate function that serves as a port in this architectural paradigm. This function is also the focal point of the Pact test from the consumer's perspective. In my scenario, the function's logic extends through multiple services (on the port level) which are integrated via dependency injection. This leads to a critical decision point: should I test receiveProductUpdate by mocking its dependencies, or should I analyze all the interconnected services, extract their requirements, and then, instead of directly invoking receiveProductUpdate in the pact consumer test, formulate assertions based on these extracted requirements? An alternative could be to conduct an integration test, but this is quite complex and may not be feasible in all scenarios. Example in Go with 3 different options: ```_ = pact.VerifyMessageConsumer(t, message, productServiceWrapper) //cheking only productService, missing compliance with TransformerService and other dependencies func productServiceWrapper(m dsl.Message) error { productMessage := *m.Content.(*Product) productService := NewProductService(mockTransformerService) err := productService.receiveProductUpdate(productMessage) if err != nil { return err } return nil } //use real transformer and turn it to integration test func productServiceWrapper(m dsl.Message) error { productMessage := *m.Content.(*Product) productService := NewProductService(transformerService) err := productService.receiveProductUpdate(productMessage) if err != nil { return err } return nil } // bring all the requirements from services here, without calling the service directly func productServiceWrapper(m dsl.Message) error { productMessage := *m.Content.(*Product) // Validate date format (e.g., "2006-01-02") if _, err := time.Parse("2006-01-02", productMessage.Date); err != nil { return errors.New("invalid date format") } // Check if status is either "active" or "deleted" if productMessage.Status != "active" && productMessage.Status != "deleted" { return errors.New("status must be 'active' or 'deleted'") } // Additional validations according to services... return nil }```

juliemarierosok
2023-11-24 11:28
Hi Matt - We will choose the one element of the array which has the value set to true, and this contains the data important to us which we need in the rest of the flow triggered by this event. Without this one element, the event is useless to us. Should this then not also be reflected in the pact?

aschaff
2023-11-24 15:27
has joined #general

aschaff
2023-11-24 15:58
I have a question. I have heard that contract testing focuses on testing the arrows in your microservice architecture diagram (the communication between your services). I can see how it works for direct invocation API calls. But can it work for pub/sub? I have been searching for anything explaining how that would work, and I have found nothing. Is it correct to say that pub/sub is a form of service communication that cannot be tested as a contract?


bruno.petkovic99
2023-11-25 13:55
has joined #general

abubics
2023-11-27 01:22
Bringing that to a more philosophical design perspective, maybe there's a different data structure that represents that concept better? (not to say that you should refactor everything, but a less error-prone data design could also make it easy to specify in the contract, if that's your desire)

abubics
2023-11-27 01:24
e.g. a field at the top level (outside the list) that means "ID of the element that would've had a "true" value in that field" Then you avoid the chance of multiple elements having the "true" value, and a smaller footprint in the body to check for correctness.

carlrconn
2023-11-27 02:22
has joined #general

matt.fellows
2023-11-27 02:37
Yep. I?m also not so keen on enforcing constraints on _other_ values that aren?t relevant to the consumer. This seems like it could easily end in a situation where another consumer may have conflicting needs.

juliemarierosok
2023-11-27 07:49
Unfortunately, the definition of the schema for the provider is out of my team's control. I am now wondering if trying to enforce this case is out of scope for the contract tests - and maybe it does go in the direction of trying to test functional requirements, which I believe is not the point with these tests. Maybe it is enough to say the boolean attribute is mandatory with any boolean value, at least that is how it is defined in the schema. Thanks for your input!

yi.wu
2023-11-27 08:10
has joined #general

matt.fellows
2023-11-27 10:21
You're welcome!

brian_worsham
2023-11-27 14:30
has joined #general

jessie.eteng
2023-11-27 15:25
has joined #general

yousafn
2023-11-27 18:07
:blobwave: Hey all, Want to know whats been happening in the world of Pact this month? If so, check out the latest Pact blog https://docs.pact.io/blog/2023/11/22/pact-open-source-update-nov-2023 You can find out what @tien.xuan.vo and @joshua.ellis have been up to in Pact PHP and Pact Python, and how working with the Pact compatibility suite is leading to improvements in the Pact Core. You can read about #pact-nestjs author @omer.moradd latest project Automock and if you are a Bazel fan, you might want to check out @olivier.picaud?s contributions. As always thanks to everyone for their hard work, and if you fancy getting featured in a Pact blog, why not reach out. Have a great rest of your day (or start, depending on where you are in the world!)

crisciano.botelho
2023-11-27 18:57
has joined #general

ajg.public
2023-11-27 21:44
has joined #general

pratibha.kachi
2023-11-27 23:14
WE removed some fields from provider aPI , I changed my consumer tests and that passes at consumer side but provider is still failing

matt.fellows
2023-11-27 23:21
what error are you getting? It probably depends on what selectors you use in verification


matt.fellows
2023-11-28 05:11
@aschaff perhaps you could describe how DAPR works in a high level, to help us understand the question/problems?

abubics
2023-11-28 05:38
Last time I read about it, the docs (frustratingly) didn't really explain what it is :sob:

abubics
2023-11-28 05:41
iirc, it's a framework that helps you write the moving parts of a distributed system, but abstracts away some of the infra & comms for consistency, almost becoming a bus

abubics
2023-11-28 05:42
(from Wikipedia)

abubics
2023-11-28 05:42
I don't know enough about implementing things with it to say how you'd add any kind of tests

ogbofjnr
2023-11-28 07:15
@matt.fellows what do you think about it?

lukasz.lawicki
2023-11-28 10:06
has joined #general

gjourdanweil
2023-11-28 13:37
I know very little about Dapr but I believe Pact contracts exist in 2 forms: ? a part specific to HTTP ? a part for messages which is not specific to a techno (could be Kafka, PubSub, whatever I believe)

gjourdanweil
2023-11-28 13:38
The 1st is HTTP specific, don't think this fits in Dapr world if Dapr abstract HTTP

gjourdanweil
2023-11-28 13:39
The 2nd on the other hand is protocol agnostic and could fit in a Dapr world maybe?

gjourdanweil
2023-11-28 13:40
But I don't know enough Dapr to say if it needs specific integration with Dapr or if the current implementation would be posisble to use directly in Dapr context

jawad.sefiani
2023-11-28 14:08
has joined #general

aschaff
2023-11-28 15:58
DAPR uses a sidecar pattern: https://docs.dapr.io/concepts/dapr-services/sidecar/ If we need to call another endpoint from our microservice, we just call dapr client methods, which take care of everything. It seems to me that the best way to do the contract testing would be to get the dapr sidecar talking to the pact mock server. But it's unclear how to make that happen, which is why I was hoping we weren't the first to try this and someone could give us some direction or even a sample to look at.

gjourdanweil
2023-11-28 16:30
Depends what kind of contract verification you're setting up. I only do contract tests through unit tests without relying on anything started outside. (I'm used to JVM but I guess similar to .NET) (For HTTP contracts) Consumer side: unit test with pact stuff that starts a embedded server, I call my business code by pointing it to the mock server started by Pact. Here, if your code doesn't talk HTTP but only "Dapr-abstraction-over-HTTP", I don't see how you can make it work indeed. And I don't see how you would interact with a Dapr sidecar from your tests. Provider side: unit test that starts my app embedded web server and I point Pact code to my app embedded server so that it sends requests defined in the contracts and verify the response match the contract. Here I guess Dapr is not involved?

aschaff
2023-11-28 17:11
Thanks for your insight. Provider side: Yes, I believe I can test this without DAPR sidecar. Consumer side: Yes, the challenge would be getting the sidecar to talk to the mock server. I'm not sure if that is possible. I feel like maybe it is, but unfortunately I'm new to DAPR, so I'm not sure where to begin. Sounds like I really need to be posting this on a DAPR forum. I wish they used Slack! :grinning: I suppose one other thought is that I could put my own interface around the DAPR method calls and have my tests implement it with an HTTP class, by-passing DAPR. The downside to this, of course, is that I'd be writing the very kind of code that DAPR promised me I wouldn't have to. Ah, the joys of being on the bleeding edge. I hope DAPR catches on more. I really do like what I've used of it so far. But there isn't a lot of info on testing best practices.

gjourdanweil
2023-11-28 17:18
TBH I don't see that much value in over abstracting things (like Dapr does IMHO) but that's another discussion. Good to know people are using it and want to help it move in the right direction :)

elaine.silva
2023-11-28 17:50
has joined #general

aschaff
2023-11-28 21:35
Here is a follow-up. I posted on the Discord forum for DAPR. Folks there were super helpful, and I discovered that I was doing service invocation wrong (well, not the recommended way). There's a way to do it by getting an HttpClient from the dapr client. With that, I should be able to follow standard consumer side practices for contract testing. Woot! Of course, pub-sub will be a different (harder) challenge, but that can wait for the moment. I need to show some progress.

stan196
2023-11-29 01:55
Hey folks, a somewhat newbie question: What if the same value is used in multiple places across request and response? An example: we send a request to create a resource with id x123. The response can be smth like: ```{ "id": "x123", "url": "https://example.com/api/v1/entity/x123", "fullName": "entity-x123" }``` How can this be modeled in pact? If each field just specifies a regex like `x\d+` or smth, and `x123` as an example, is this enough?

matt.fellows
2023-11-29 02:33
What usually matters in a contract testing sense, is that the shape of the response is correct - usually, the specific values don?t

matt.fellows
2023-11-29 02:34
so yes, if your client expects `id` to be a regex of a specific type, then that could suffice. Be careful not to artificially constrain the response types (see this page, and this https://docs.pact.io/consumer#only-make-assertions-about-things-that-will-affect-the-consumer-if-they-change)

matt.fellows
2023-11-29 02:52
Oh, that?s great to know!

matt.fellows
2023-11-29 02:52
If you?re up for it, we?d love to see a recipe for DAPR https://docs.pact.io/implementation_guides/recipes for future DAPRs :stuck_out_tongue:

abubics
2023-11-29 03:06
To elaborate a smidge, it also depends (in this example) which values are load-bearing, and which are coincidentally the same. E.g. the `fullName` attribute is probably not being parsed or split on the `-`, so it only cosmetically seems to need the same value.

abubics
2023-11-29 03:08
On the other hand, if it's important that some of the input values appear in the output, you can set those expectations in the contract (by using stricter matchers, like exact value, instead of flexible type matching).

stan196
2023-11-29 06:26
thanks folks! The point about "what would break the consumer if it changed" is valuable indeed. I'm thinking in the example above the consumer probably doesn't care that the url contains the ID - it seems to be an implementation detail on the provider side; and consumer just cares that it is a valid url.

tomasz.myszka
2023-11-29 14:21
has joined #general

tom.willmott944
2023-11-29 14:44
has joined #general

anna.nava
2023-11-29 20:56
has joined #general

pasc.ther
2023-11-29 22:19
has joined #general

jo.laing
2023-11-30 13:35
:webinar: *Webinar* :webinar: *Show and Tell: Discover the Benefits SmartBear?s Open Source Tools Bring to the SDLC* *Tuesday, 5th December 2023 at 3:00PM GMT / 10:00AM EDT* Join Yousaf and Jo from the DevRel team at SmartBear to hear about the Open Source tools and communities at SmartBear! Expect to learn how to harness Swagger, SoapUI, Pact, and more to ace API development. :hammer_and_wrench::computer: :point_right::skin-tone-2:https://bit.ly/49KSSPZ

awade
2023-11-30 13:49
has joined #general

matt.fellows
2023-12-01 02:39
I would tend to go with Option 1, provided that there is decent test coverage (collaboration tests) between the `NewProductService` and `TransformerService`.

matt.fellows
2023-12-01 02:40
Is Transformer service itself a downstream system or another internal component? If downstream, then Option 1 for sure (and then you need contract tests between these two systems). If an internal component, then Option 2 is fine also (so long as you then stub any downstream systems of it)

ogbofjnr
2023-12-01 07:18
The transformer is just another service in the same code repo, so it's internal. What do you think about the third option? Is it viable at all? Full disclosure: in our company, the ESTEDS decided to go with the third option, which seems controversial to me, and that's why I decided to check it here. Can we conclude that it's a bad practice?

matt.fellows
2023-12-01 23:06
If I understand option 3, it?s not executing the code that would be executed in real life and thus runs the risk of testing the wrong thing, or if the code is refactored in a way that changes behaviour, it won?t be detected. So yes, I would say it?s not ideal. I can imagine potentially why you?d want to go this way and given enough guarding/other tests it could work, but in general I think it?s risky

ogbofjnr
2023-12-02 07:19
Thank you for the clarification. I appreciate that.

matt.fellows
2023-12-03 01:00
No worries!

vspallas
2023-12-03 10:18
has joined #general

nicholaspatrickshaw
2023-12-04 10:32
has joined #general

malvine.logina
2023-12-04 11:52
has joined #general

stan196
2023-12-05 00:09
Hi folks, we have an interesting case which I'm not super sure I'm approaching correctly, maybe the experts can help me wrap my head around this. ? We have services that communicate over Kafka, using https://github.com/confluentinc/confluent-kafka-go/blob/master/kafka/message.go#L72 structs. ? The difficulty here is that it's not only the message value that's a part of the contract, but also message key and headers. ? value, key and headers are all just `[]byte` objects, so the actual payload could be json, protobuf or avro, the particular example I'm looking at is with value and some of the headers encoded as protos. ? I don't think I can use `pact-protobuf` plugin since it's not a single proto message that I'm sending, but a combination of string key, a map of string to string/proto as headers and a proto value. ? I don't think there's a good way to express such contracts in Pact; I was thinking of writing some sort of a plugin that would accept configuration like this one, but ideally if it deals with e.g. protos it should refer to pact-protobuf plugin for data conversion, ie I don't want to rewrite half of that plugin inside this one. ```{ "key": "abc", "keyType": "string", "keyProto": null, // only necessary when key is protobuf "value": {...}, "valueType": "proto", "valueProto": "MyProtoMessage", "headers": [ { "name": "whatever", "type": "string", "value": "some value", "proto": null } ] }``` ? I could probably craft a separate proto representing just the kafka message specific for this service, ie where value and headers are typed, and use pact-protobuf plugin, but I'm not sure it'll deal well with headers of different types either; though that could probably be a lesser issue, maybe even refactor on the product side ? Maybe I'm tackling this from the wrong direction completely, wdyt? ? Thanks! :slightly_smiling_face:

stan196
2023-12-05 00:15
forgot to mention the alternative approach I've tried: ? added functions to convert from kafka.Message to raw json on the provider side and vice versa on the consumer side. It works reasonably ok, but it trips a bit on converting primitive types - in go json.Unmarshal always treats numbers as float64, so we're losing some fidelity since there's a bit too many conversion steps, between protos, strings and maps, using both proto and json marshalers. ? This is basically an attempt to not write a plugin, but seems like it comes with too many compromises. ? Also, this means that the types are not really part of the contract, ie the contract itself is a simple json, and it's only implied what the actual type is.

vinicius.gabriel
2023-12-05 13:59
has joined #general

stasiekps
2023-12-05 15:13
has joined #general

antal.tettinger
2023-12-05 15:50
has joined #general

gueorgui
2023-12-05 16:38
Hi folks, I was wondering if there was somewhere a handy comparison between Pact and the contract testing offering from SauceLabs? For context, we are planning to do contract testing between a Ruby on Rails provider and several consumers (mobile apps, web clients), and were initially planning to go with Pact, but found out that SauceLabs was already in use in a different part of the company, so we?re trying to figure out if it makes sense for our team to use Pact instead. Thanks in advance for your help!

bas
2023-12-05 18:09
I?m trying to wrap my head around this bit from their website. How is it consumer-driven if you generate everything from the provider spec, and not from consumer expectations?

bas
2023-12-05 18:36
Now you got me curious. I?ve requested a demo with them on Friday. Curious to see how it works.

abubics
2023-12-05 23:14
There are some red flags in those https://saucelabs.com/resources/blog/getting-started-with-api-contract-testing . . . ? "Learn what OpenAPI-driven contract testing is" ? "[...] risky shortcuts to save time, like reducing or even eliminating testing sprints." But then also some good-sounding bits: ? "Complete API contract testing must validate both the API producer (server side) and the API consumer (client side) to detect and diagnose when a contract is broken by either side." And terminology blurring: ? "This agreement ? with the formal description of the rules that govern it ? is the contract (aka, pact)."

abubics
2023-12-05 23:14
But, in the end, it sounds like schema-based double-validation, not contracts by example.

stan196
2023-12-06 00:00
Hey folks, another question on how to write a good contract test. We have a consumer that makes a call to retrieve a list of objects; it then iterates over the list of objects to find one with a matching name and proceeds to do whatever parsing/validation necessary on that particular object in the list. I realize this might not be the best interaction model to express in pact, and it would've been better to just call GET to retrieve that particular object, but it is what it is, unfortunately. I can talk to the service team to eventually change it. Still, I was wondering what would be the right way to model this in pact. Basically the contract is sorta: ? return a list of objects of the same type ? the list must contain one and only one object with name X, as described in the provider state ? it can have more elements or just that one, consumer does not care And then we probably want to separately test the case when the consumer receives a list that does not contain the given element.

abubics
2023-12-06 00:13
Is the name passed as a parameter in the request? Or is it a latent coupling that the contract couldn't definitely fulfil?

abubics
2023-12-06 00:19
You can still put contract tests around it, expressible with Pact, and they might give you more confidence in the edge cases, e.g. ? make provider states that have 0, 1, and >1 matching names ? write consumer tests that describe what happens in each state ? You can use the `like` matchers (`atLeastOneLike` and others in JS, idk what language your consumer is in) to try to constrain the logic, but it's a bit hard to put strong reasoning around that kind of interaction.

abubics
2023-12-06 00:20
Ideally, fix the API up in future, so the client doesn't have to do the work itself (e.g. an endpoint that passes the name as a param, and gets back the expected entity, or a list if that makes more sense)

abubics
2023-12-06 00:20
(or a smaller list response that just has names & IDs, then you GET the one you want by ID)

stan196
2023-12-06 00:46
thanks! > Is the name passed as a parameter in the request? Or is it a latent coupling that the contract couldn't definitely fulfil? It is a latent coupling, unfortunately. How would my pact be different if it was explicit in the request? > You can use the `like` matchers (`atLeastOneLike` and others in JS, idk what language your consumer is in) to try to constrain the logic, but it's a bit hard to put strong reasoning around that kind of interaction. so how would I express something like `a list of items, each has a name field, and for one of them the name equals X, and that item matches the template, don't care about the others`? If I do something like: ```EachLike(Map{"name": Equality("x")})``` this means the provider can respond with a list that contains multiple items with the same name? Or should my consumer not care? > Ideally, fix the API up in future, so the client doesn't have to do the work itself (e.g. an endpoint that passes the name as a param, and gets back the expected entity, or a list if that makes more sense) agreed, this would be ideal, but idk if/when the api team can get to this

abubics
2023-12-06 02:38
I don't think you can say "exactly one item matches this criteria, and no others do" with the Pact DSL

stan196
2023-12-06 02:39
gotcha. Well, I don't think it matters much since I think the consumer code will pick the first one that matches anyway.

abubics
2023-12-06 02:40
> How would my pact be different if it was explicit in the request? If an expected value in the response is supplied in the request, it's easier to demonstrate the coupling. Worst case, though, it can be coupled in the state description.

stan196
2023-12-06 02:41
ah, so it's not about that pact can somehow match against the term in the request, but more like to make the pact more readable?

abubics
2023-12-06 02:43
It's both. The contract describes the request and the response as a pair, so you can explicitly say that the request has a value that will be echoed somewhere in the response, e.g. ```GET /lol/face?name=very-important-value``` expects a response like ```{ "faces": [ { "id": int(example: 3), "name": "very-important-value" } ] }```

stan196
2023-12-06 02:44
isn't it the same with the provider state though? If we say `Given("very-important-value exists")` and expect the same response as above, isn't it the same?

abubics
2023-12-06 02:45
it's very close, yes . . . not sure if it's exactly the same

abubics
2023-12-06 02:45
I think it depends what version of state descriptors you use. A newer feature lets you supply multiple data values in state descriptions, and the name could be one.

stan196
2023-12-06 02:47
I wonder if this is a good way to describe the contract: ```{ "faces": [ { "id": int(example: 3), "name": "very-important-value" }, { "id": int(example: 5), "name": string(example: 'whatever') } ] }``` with state like `given(very-important-value exists, among others)` (but structured)

abubics
2023-12-06 02:48
Further: if it's just in the state name as a string, you don't have isolated access to it without parsing the string. If you put it in a param that's already parsed (e.g. path element, query param, or body value) then you can reuse it in the providers state implementation.

stan196
2023-12-06 02:48
and have, as you suggested above, multiple test cases - with one, zero or multiple results

abubics
2023-12-06 02:58
Yep, I think that's the starting point. Then you can champion the changes you want with these examples as supporting evidence :sunglasses:

stan196
2023-12-06 02:59
yup, that's the plan. Tests like this can help make a case for API improvements

stan196
2023-12-06 02:59
Thanks for your help!

abubics
2023-12-06 03:00
np, gl

bas
2023-12-06 05:32
That?s what my thought was as well, this sounds more like schema validation. We?ll see :)

archaanaaa8
2023-12-06 07:19
has joined #general

visaliparimi
2023-12-06 10:03
has joined #general

indrani.r
2023-12-06 10:06
has joined #general

frank.weitmann
2023-12-06 10:23
has joined #general

venketeshvenky
2023-12-06 10:40
has joined #general

bas
2023-12-06 11:41
They cancelled my demo meeting (probably because it was too obvious I wasn't going to buy anything from them)... Anyway, I was pointed to YouTube. From this short video it looks like it's indeed 'generate mocks from a spec' for the consumer and 'generate a client from a spec' for the provider, nothing consumer-driven there: https://www.youtube.com/watch?v=tRLN_hDxYGU There's also a longer video, I'll watch that later: https://www.youtube.com/watch?v=zF4wQD1_GwM

ogbofjnr
2023-12-06 13:53
Hi @matt.fellows After studying the documentation and extensive internal discussions about balancing a narrow scope in consumer tests with meaningful verification results, we've developed an approach that we hope could address these concerns. We recognize that responses in consumer-provider interactions often depend on business logic executed in lower layers of our application. To tackle this, we've come up with the idea of centralizing business logic requirements into a validation function. This is how it looks when evolving the code example from previous posts ``` // Checking only productService func productServiceWrapper(m dsl.Message) error { productMessage := *m.Content.(*Product) productService := NewProductService(mockTransformerService) err := productService.receiveProductUpdate(productMessage) if err != nil { return err } return nil } func (p *ProductService) receiveProductUpdate(product Product) error { err := validate(product) if err != nil { return err } p.transform(product) p.post(product) } func validate(product Product) error { // Validate date format (e.g., "2006-01-02") if _, err := time.Parse("2006-01-02", product.Date); err != nil { return errors.New("invalid date format") } // Check if status is either "active" or "deleted" if product.Status != "active" && product.Status != "deleted" { return errors.New("status must be 'active' or 'deleted'") } // Additional validations according to services... return nil }``` This approach aims to enhance our consumer tests with additional validation layers, reflecting the downstream business logic requirements. We believe this could keep our test scope narrow while ensuring the tests remain effective and relevant. What do you think about this approach? Can we go as far as calling only the validate() function in a Pact test instead of the handler, considering it's used in production and maintained by the developers?

gueorgui
2023-12-06 14:44
Thanks a lot! This pretty much answers my question.

matt.fellows
2023-12-07 00:12
mmm I think you?re right there. What is the actual payload sent over the wire in the end? Is it JSON with encoded protobuf in it?

stan196
2023-12-07 00:13
It's a kafka message - key is string -> bytes; value is json or protobuf -> bytes; headers are either string -> bytes, or json/proto -> bytes.

matt.fellows
2023-12-07 00:15
Yeah, that?s tricky. Currently the bodies in Pact are considered a single ?content type?. It _sounds_ like you need a Kafka message specific plugin, that can delegate content-type matching for fields of different types

kyle.r.shrader
2023-12-07 01:33
has joined #general

kyle.r.shrader
2023-12-07 01:35
The Pact YouTube https://www.youtube.com/playlist?list=PLwy9Bnco-IpdgdZce-rXeR7EF2_6T8z7S has a lot of repeated videos in it. Would the maintainer of that kindly take some time to remove duplicates? :)

matt.fellows
2023-12-07 04:04
Nice! You could possibly still call `receiveProductUpdate` and mock/stub the downstream services, but that would be roughly equivalent anyway. So the answer is probably ?yes? from me, with caveats like ?as long as you test the other bits?

matt.fellows
2023-12-07 04:04
Oh dear, thanks for letting us know. Something weird has gone on there!

matt.fellows
2023-12-07 04:08
Should be fixed now, thanks!

ajay991610
2023-12-07 05:27
has joined #general

kyle.r.shrader
2023-12-07 06:38
It's not a big deal, but there's still one dupe. #7 and #9 titled `[Contract testing 'Ask Me Anything' with Pactflow] Schema Testing with OpenAPIs on 29 July 2021`

matt.fellows
2023-12-07 06:52
ah, thanks

matt.fellows
2023-12-07 06:52
Strange. I ordered by upload and then deleted that way. Weird that one was interjected. Anywho, appreciate it!

kyle.r.shrader
2023-12-07 07:16
Likewise... Thank you. I kept noticing 5 minutes in that I'd already watched a video. :sweat_smile:

matt.fellows
2023-12-07 07:17
That Matt guy _really_ likes to repeat himself?

marko.stevanovic
2023-12-07 10:01
has joined #general

mahesh.manglani
2023-12-07 16:49
has joined #general

mahesh.manglani
2023-12-07 16:51
Hello, just wanted to know if Pact supports testing Azure Bus Service?

gerard.molina
2023-12-07 17:00
has joined #general

boyd.social
2023-12-07 17:52
has joined #general

stan196
2023-12-07 19:54
can a plugin delegate to another plugin?

matt.fellows
2023-12-07 21:41
That?s a good question. @rholshausen?

rholshausen
2023-12-07 22:01
Not yet

stan196
2023-12-07 23:28
> Currently the bodies in Pact are considered a single ?content type?. It _sounds_ like you need a Kafka message specific plugin, that can delegate content-type matching for fields of different types I'm wondering if I can bypass this whole conundrum by putting key and headers in metadata, and kafka value in a body of the request. I mean currently that's how http works - contract consists of the body, but also additional data like url, query params, headers etc; I wonder if I just put all extra data in metadata in async pact too, that might work

matt.fellows
2023-12-08 01:54
It?s worth a shot and would be more consistent with the rest of the Pact model/ecosystem I think. See how far you get!

muhd_syamil.dzulkafta
2023-12-08 05:47
has joined #general

omer.sucu
2023-12-08 10:04
has joined #general

hermoine807
2023-12-08 12:04
has joined #general

blake.norrish
2023-12-08 17:05
has joined #general

srinivas.nali
2023-12-10 09:20
hi Guys, thanks for this thread, very useful. On this use-case context, I have a doubt @matt.fellows please. Can I use the *validate* directly? since it is maintained by developer's production code and no risk of missing implemented requirements. ```// Checking only productService func productServiceWrapper(m dsl.Message) error { productMessage := *m.Content.(*Product) err := validate(productMessage) if err != nil { return err } return nil }``` so it generates the contract using production requirements code logic, without mocking (option 1) or using the dependency services (option 2).

matt.fellows
2023-12-10 20:33
As I said above, yes, assuming you have other good tests in place

robert.jelic
2023-12-10 23:02
has joined #general

srinivas.nali
2023-12-11 06:08
thanks @matt.fellows

pragna.reddy
2023-12-11 11:32
has joined #general

omer.moradd
2023-12-11 12:02
Hey Pact :wave: *I'm excited to share the news about the official launch of Automock today* :rocket: Automock is an open-source project that optimizes the unit testing process within dependency injection frameworks (like NestJS, InversifyJS and more) by providing a virtual, isolated environment and automated mock generation. It enables developers to create efficient test suites and enhance their overall testing experience. *Here's why Automock matters a lot:* - NestJS Endorsement: https://docs.nestjs.com/recipes/automock A warm welcome to the NestJS family :cat2: - Growing Popularity: Nearly 60K downloads per month on NPM are evidence of its dependability and usefulness. :chart_with_downwards_trend::muscle::skin-tone-3: *A few of Automock's most notable features are:* ? Automated Mocking: Automatically mocks class dependencies, significantly improving unit testing workflow. ? Time Efficiency: Drastically cuts down setup time, so devs can focus more on development and critical logic. ? Boilerplate Reduction: Significantly reduces repetitive coding, boosting overall code quality. Check out Automock at GitHub to learn more: https://github.com/automock/automock *Your support can make a huge difference! If you find Automock useful, please consider:* :star: Star the repository on GitHub. :arrows_counterclockwise: Repost and share within your professional circles. :speech_balloon: Provide Feedback. Your insights and suggestions are more than welcome! :mega: Spread the Word: Help other developers discover Automock. Thank you, I appreciate you coming along on this amazing journey with me :heart: Happy testing! :nerd_face:

oguzhannvarol
2023-12-11 14:13
has joined #general

ryan.quinn
2023-12-11 17:57
has joined #general

arnon
2023-12-12 09:01
has joined #general

lewis.blackwood
2023-12-12 14:04
has joined #general

ilie.cotiuga
2023-12-12 14:26
has joined #general

remyjaume
2023-12-12 15:46
has joined #general

remyjaume
2023-12-12 16:23
Hi everyone, I am looking for a way to use pact in a microservices architecture using standard MQTT. Any of you already wrote a pact-mqtt plugin? If not, any resource I could learn from? Thanks!

amelie.frappier
2023-12-12 18:55
has joined #general

flament.thom
2023-12-12 20:43
has joined #general

ckbisk
2023-12-12 22:18
has joined #general

matt.fellows
2023-12-13 02:18
Hello!

matt.fellows
2023-12-13 02:19
There is no MQTT plugin that I?m aware of (would _love_ to see one - hint hint :wink: ) For now, you could probably get away with using standard ?message Pact?. Here?s an example using AWS SNS in JS: https://docs.pactflow.io/docs/examples/aws/sns/consumer/

matt.fellows
2023-12-13 02:19
Also see our youtube channel, Yousaf recently released a workshop on message pact also

matt.fellows
2023-12-13 02:40
Congratulations Omer!

sterankin
2023-12-13 10:57
has joined #general

shane.bogdan
2023-12-13 12:06
has joined #general

sterankin
2023-12-13 12:08
I have been researching contract testing, specifically Pact and although I have watched the videos and read many articles, there are a couple of things I am not 100% clear on. Hoping someone can clarify the following. Pact simple steps: 1. The consumer writes a test with the expected response from the provider. It?s not actually calling the provider, but instead is using a mock service provided by the Pact library. Does this service know what the actual response from the provider is? Or in this test are we just mocking the desired response ourselves? What are we actually testing here if the response is dictated by the client? 2. We run the test and a pact file is generated. We push this to the pact broker during the CICD run. Does the broker do anything when it receives this file? If it does do something, if the pact file is unchanged or changed does this affect the action? 3. The provider needs to pull down the pact file(s) from the broker during their CICD builds, and verify the contract by writing verification tests, again using the Pact library. A mock provider test provider/server is loaded to run the verification against. Does the Pact library do this? Does it create the mock provider service to run the tests against? Or does it just simulate a consumer call? 4. Once the verification is complete the results are published back to the broker. Is the broker essentially a UI and a data store and doesn?t actually do any testing itself?

bas
2023-12-13 12:47
Here goes. Others will amend / correct where my answers are incomplete / incorrect :) 1. The mock provider responses are generated by Pact from the expectations you wrote down in the contract. You can use this to test whether your client can process the responses correctly in case the provider behaves as expected. 2. Not by default, other than storing / versioning the contract, but you could for example set up a webhook that triggers a provider build to verify the newest expectations / newest contract. 3. On the provider side, Pact replays the interactions from the contract against a real provider instance, not against a mock version. That?s the only way you can be sure the actual provider meets expectations written down by the consumer. 4. In consumer-driven contract testing, the broker is the single source of truth for (versions of) contracts and corresponding verification results. In bidirectional contract testing, PactFlow (because this isn?t a feature available in the OSS Pact Broker), the broker also performs the compatibility check between consumer and provider contract.

sterankin
2023-12-13 13:23
Thanks for taking the time to reply. So for 1. Assuming our client code never changes, the client test will always pass, even if the provider code changes. The client will not know about any provider changes, so the client test will always pass. (Unless of course we change our internal client business logic which breaks the test but that would be caught in a unit test, not a pact test). Is the purpose of a client pact test really just to generate a pact file and is not really testing anything? However the provider verify tests will fail if they push a change which will break the contract....

luis.nuno
2023-12-13 18:08
has joined #general

matt.fellows
2023-12-13 20:52
1. As Bas said. Think about it as _unit test_ of your API client

matt.fellows
2023-12-13 20:55
> So for 1. Assuming our client code never changes, the client test will always pass, even if the provider code changes. The client will not know about any provider changes, so the client test will always pass. (Unless of course we change our internal client business logic which breaks the test but that would be caught in a unit test, not a pact test). Is the purpose of a client pact test really just to generate a pact file and is not really testing anything? > However the provider verify tests will fail if they push a change which will break the contract.... (edited) Yes, and hopefully preventing a production issue! This is because of the information you provided in step 1. You can also use this information to remove unused fields from the provider.

matt.fellows
2023-12-13 20:56
You might also like to watch JB?s video (the last one) - or indeed the whole thing :wink: - in our recent Pactober conference: https://www.youtube.com/watch?v=s1LOP4Ak5SA He talks about the benefits of collaboration contract tests outside of just catching bugs - such as applying better pressure to your software design.

sterankin
2023-12-13 22:20
Thanks Matt I will check out that video. Originally I was using this example and running it locally. If we look at this test it doesn't actually test anything in the sense that the mock server returns what the code tells it to. so I wasn't sure if there should be some additional business logic that should be tested or if the intent of the consumer spec is simply to create a pact file and ignore the internal business logic of the consumer system: https://github.com/pact-foundation/pact-5-minute-getting-started-guide/blob/main/consumer/consumer.spec.js I will watch the video and dig more into consumer side "tests" which I guess are really generated to be executed on the provider side.

raleigh.schickel
2023-12-13 23:15
has joined #general

matt.fellows
2023-12-14 00:26
Well, that?s not entirely true

matt.fellows
2023-12-14 00:27
The client library unmarshals the result into a domain object (`Order`). That?s important, because it means it knowns how to handle the result. If it used an arbitrary API client then it would be useless

remyjaume
2023-12-14 09:45
Started having a look to resources you mentioned, after several issues with a Windows env, I'm finally ready to start. If someone is willing to join my efforts you're more than welcome :wink:

tanyagorn.benjaprompa
2023-12-14 14:28
Hi all, I'm undergoing a situation where pact-verifier failed to verify contract and have no idea what is this about. Can anyone help point me to the right direction?

matt.fellows
2023-12-14 20:52
Are you on windows?

tanyagorn.benjaprompa
2023-12-15 03:00
@matt.fellows I got this error in gitlab CI job. But the project I'm trying to verify contract against is .NET project. Should I configure anything to make it works? FYI. I had another Scala project, it works without configure anything.

matt.fellows
2023-12-15 04:57
Is the CI job on Windows or Linux? (I assume linux)

matt.fellows
2023-12-15 04:58
Perhaps you could explain more about your CI setup. Does it work locally but not on CI? What?s different about CI

matt.fellows
2023-12-15 04:58
See also https://docs.pact.io/docker (I suspect you?ll be using docker if on Gitlab)

matt.fellows
2023-12-15 04:59
Looks like you?re using an older version of Pact JS - are you porting an old project over to Gitlab or is this a new project? (and if so, why are you using an older version)

hataipat.sup
2023-12-15 05:26
has joined #general

hakan.dilaver
2023-12-15 13:54
has joined #general

eliranbardavid
2023-12-17 09:06
has joined #general

anthony.trad
2023-12-17 12:30
has joined #general

tanyagorn.benjaprompa
2023-12-18 09:54
@matt.fellows Yes, you are correct. CI job run on Linux. I cannot run .NET project so I haven't tested it locally. However, I've updated pact-cli image to the latest version. Somehow the error change to ECONNRESET: Connection reset by peer. Now I figure it out that I need to wait until application is ready... all solved. I won't be able to identify what's wrong with old image version error. Thank you so much for pointing that out. Appreciated your help.

m.mohammadi.se
2023-12-18 19:31
has joined #general

lewis.foreman
2023-12-18 21:45
has joined #general

matt.fellows
2023-12-18 22:52
No worries, glad you?re back on track!

stan196
2023-12-19 00:04
Hey folks, I've sent out a fix to pact-protobuf plugin - can I please get some reviews? thanks! :slightly_smiling_face: https://github.com/pactflow/pact-protobuf-plugin/pull/40

guozhangliew
2023-12-19 01:28
is it possible to have same names for my pacts only difference is one is provider and another is consumer?

matt.fellows
2023-12-19 01:48
No, names cannot be duplicates as they identify uniquely the application in the system. If the application is both a provider and a consumer, it _is_ the same application and not two different ones

matt.fellows
2023-12-19 01:48
Why are you wanting to do this?

guozhangliew
2023-12-19 02:12
my app published event `KEY_GENERATED` from authService and I have a subscriber in userService that subscribe `KEY_GENERATED`

matt.fellows
2023-12-19 02:13
what?s that got to do with naming of the services?

guozhangliew
2023-12-19 02:15
my app name is labeled as `auth` im going to trying naming consumer as `KEY_GENERATED_CONSUMER` and provider as `KEY_GENERATED_PROVIDER` then

matt.fellows
2023-12-19 02:32
I?m still unclear. Why are the app names not simply `authService` and `userService`?

matt.fellows
2023-12-19 02:32
What problem are you trying to solve?

eran.bergman560
2023-12-19 18:43
has joined #general

ddongre
2023-12-20 00:26
I wanted to get a consensus on how many folks here have just used the standalone pact verifier for their provider side validations. I have heard that a proper provider side implementation using the https://docs.pact.io/implementation_guides/jvm/provider/spring dependency is the best way to go since it truly enables you to run your tests independent of an environment and better for a TDD approach. I wanted to know if there were any holes in my assumption and to better understand the pact ecosystem. Thanks :pray: !!!

matt.fellows
2023-12-20 00:29
Most people would use a client SDK to do the verifications

matt.fellows
2023-12-20 00:31
Those that use https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli tend to use it for 3 reasons 1. They are verifying an unsupported language 2. They want to standardise the toolchain 3. QAs/Testers are primarily the users, and they are testing it against live systems in a black-box way (3) is definitely not ideal, but I?ve seen it before

ddongre
2023-12-20 00:34
Thanks for the quick response Matt! We will definitely use the cli initially but using the SDK is the way to go :raised_hands:

tom.dracz
2023-12-20 09:53
has joined #general

ivan.gutowski-smith
2023-12-20 10:40
has joined #general

nicolas.vaquero
2023-12-20 11:31
has joined #general

ulises.cervino
2023-12-20 15:52
hi all, are there any examples of provider tests when the provider is 100% AWS lambda code?

emailmvj
2023-12-20 16:18
has joined #general

matt.fellows
2023-12-21 01:12
As in, can you do a provide test running against a lambda? :thinking_face:

matt.fellows
2023-12-21 01:14
mm I don?t think so. I?ve done it in the past. Is it serving an HTTP interface (e.g. via gateway) or is it a direct lambda invocation?

lewiscowles
2023-12-21 07:31
So you can do this. We're currently using Connexion + Flask, running inside an AWS Lambda; which (in 2.x) uses something like `aws-wsgi` to convert to and from Lambda event payload from API Gateway and from Flask responses. Locally it just runs regular Flask in Connexion. There are ASGI examples (for starlette, expressJS, golang etc) as well; it's usually googling your framework + lambda + adapter + apigateway For PACT specifically; I'd likely use a separate entrypoint (command to launch code), so that PACT can test locally and in pipelines. Just like other applications, you likely need to configure your app into a PACT compatible state (maybe some stubbed repositories or data access layer) Ironically I still find PACT the most complex part of this setup. Currently we're using more OpenAPI contract validation than PACT for this reason. Our OpenAPI is manually authored as a result so that we are not going to have accidental changes or breakages between releases.

ulises.cervino
2023-12-21 08:02
> Our OpenAPI is manually authored as a result so that we are not going to have accidental changes or breakages between releases. (edited) :heart:

ulises.cervino
2023-12-21 08:02
I?ll reply in a moment, thanks for the info thouh

ulises.cervino
2023-12-21 08:02
though

ulises.cervino
2023-12-21 08:04
the team I?m helping tried to implement bidirectional, since they have a bunch of integ tests (semi-stubbed, etc.) that target their lambda code. However the OAS they?re working with is not supported by our pact broker (it uses `oneOf` with mappings).

ulises.cervino
2023-12-21 08:04
what I suggested to them was that they generate server stubs from their OAS and wire the lambda code to the endpoints and just be done with it (they?re still considering this option).

ulises.cervino
2023-12-21 08:05
I also suggested they drop the use of `oneOf` because it?s problematic anyway, but that?s a non-starter

ulises.cervino
2023-12-21 08:05
and right now my fear is that due to this friction they might abandon CT altogether because ?it?s hard?

lewiscowles
2023-12-21 08:08
So my rebuttal against "contract testing is hard" is that it is, but it's less hard than not contract testing

lewiscowles
2023-12-21 08:09
I cannot imagine why dropping one-of would be beneficial though. For this reason I would not have PACT use the OpenAPI, while PACT fixes it's support of valid OpenAPI

lewiscowles
2023-12-21 08:09
but it can still have manually authored cases written against an API using OpenAPI for runtime validation

ulises.cervino
2023-12-21 08:57
right, I also don?t buy the ?CT is hard? argument. I always challenge that with ?think about the alternative?.

ulises.cervino
2023-12-21 08:58
ref PACT + OAS, I?m generally against the idea of bidirectional anyway. The tech issue they?re running into is that the broker can?t makes sense of `oneOf`+`mappings` (discriminators), and so bidirectional is not working for them at all.

ulises.cervino
2023-12-21 08:58
what I?m looking for now is a small/simple thin layer they can put in front of their business logic and do standard provider verifications instead

noelmccrory
2023-12-21 12:31
has joined #general

fajfer.pawel
2023-12-21 13:39
has joined #general

praful.poudel
2023-12-21 13:44
has joined #general

pratyush.jaiswal88
2023-12-23 16:45
has joined #general

grzegorz.v.bobrowski
2023-12-24 02:37
has joined #general

grzegorz.v.bobrowski
2023-12-24 02:40
what is a max number of branches ( o sub leafs) that the contract can have?

matt.fellows
2023-12-24 03:50
I'm not aware of any limits. Do you mean contract or application? The branch is associated with an application version, not a contract (not directly, at least)

elias.coelho
2023-12-27 17:52
has joined #general

tanyagorn.benjaprompa
2023-12-28 09:45
Hello, I'm trying to check can-i-deploy between two services fraud-backoffice (current branch) and finance-api (latest from master branch). However, it's not working as expected. I'm only interested in verification result between two mentioned services, but there are other services involve. This is the command I use; pact-broker can-i-deploy --pacticipant fraud-backoffice "${PACTICIPANT_VERSION}" \ --pacticipant finance-api --latest master --retry-while-unknown=20 --retry-interval=15 I follow the document here https://github.com/pact-foundation/pact_broker-client/blob/master/README.md#can-i-deploy it should check verification result from finance-api provider only if I understand it correctly or am I just misusing the command somehow?

matt.fellows
2023-12-28 20:52
You need to use the ignore flag. It doesn't work the way you are trying to use it. It will always check all dependencies of the given pacticipant

tomer
2023-12-28 21:52
has joined #general

tanyagorn.benjaprompa
2024-01-02 02:32
I see, thanks!

christopher316
2024-01-02 20:10
has joined #general

matt.pichette
2024-01-02 20:26
has joined #general

ocean.razafiarison
2024-01-03 08:57
has joined #general

salmaan60
2024-01-03 20:14
has joined #general

devin.woods
2024-01-03 23:11
Hey there, are releases still being tagged on Dockerhub? I noticed https://github.com/pact-foundation/pact-ruby-cli/issues/124 and I am currently blocked because of it. It doesn't seem like there is any version on Dockerhub for the image past 0.56.0.6. https://hub.docker.com/r/pactfoundation/pact-cli/tags

sam.huang1
2024-01-04 03:20
has joined #general

ratnajenisha
2024-01-04 04:04
has joined #general

ratnajenisha
2024-01-04 17:43
Hey there, I have been researching contract testing and pact. We have different services in my org involving languages like perl, java, js etc. Now that pact supports java, js can anyone suggest a good way to add contract tests to perl services (perl service being at the consumer or provider end).

markkellett
2024-01-04 18:27
has joined #general

bas
2024-01-04 18:42
Assuming your services have an OpenAPI spec, bidirectional contract testing might be a solution for the Perl providers. That?s a Pactflow-only feature, though.

varghesevarampi
2024-01-05 02:10
has joined #general

lbrndmrcr
2024-01-05 11:52
has joined #general

mcarballido17
2024-01-05 20:12
has joined #general

ratnajenisha
2024-01-06 05:23
Thanks @bas

ratnajenisha
2024-01-06 05:24
Hey there, I want to try the trial version of packflow. Yet on the sign up page, the page keeps loading and doesnt create a pactflow account. Could somebody help?

yonahlipman
2024-01-07 04:00
has joined #general

x1destory
2024-01-07 19:21
has joined #general

bgrgincic
2024-01-07 21:55
Hi, I have a question regarding verifying the Provider Contract against dedicated dev environment. I am aware that provider contracts should be run against a locally running server, however I am wondering whether it's acceptable to run contract tests against an actual dev environment deployment if the local env setup is complex. The context is GraphQL API served by AWS Lambda, which also has AppSync (that may influence responses towards the consumer) and DynamoDB. To avoid this complex setup, idea is to create a CI/CD process which would: 1. Deploy latest provider version on non-live side of dev cluster 2. Run contract tests 3. If there are no violations of contract during can-i-deploy, do the actual Live switch Does this approach make sense?

matt.fellows
2024-01-07 23:48
For anyone else helping, this was answered in the other #pactflow https://pact-foundation.slack.com/archives/CLS16AVEE/p1704477812186759

matt.fellows
2024-01-07 23:49
You can still do some testing with other languages, see https://docs.pact.io/implementation_guides/other_languages

matt.fellows
2024-01-07 23:50
You could also look at creating a wrapper for perl. There is active development of Python and PHP using the core right now (see #libpact_ffi-users). The compatibility suite for implementations are documented here https://github.com/pact-foundation/pact-compatibility-suite/

matt.fellows
2024-01-07 23:52
Looks like this PR still needs some work: https://github.com/pact-foundation/pact-ruby-cli/pull/120

matt.fellows
2024-01-07 23:52
would you be up for taking a look?

matt.fellows
2024-01-07 23:53
Yes it does. It?s not ideal for the reasons you are probably aware of, but if you can?t run it locally and test the behaviour you need, it?s better than not doing it at all

matt.fellows
2024-01-07 23:54
it would be worth exploring whether or not you could get it running locally (e.g. mocking dynamo/AWS behaviour) with enough fidelity to give you confidence

bgrgincic
2024-01-08 08:24
Thanks for a quick response! Yeah, I am not happy with doing it with a real environment, will try to explore if we can somehow mock it easily after all.

christopher.tonog
2024-01-08 18:53
has joined #general

harshad.rayunipet
2024-01-09 08:06
has joined #general

yousafn
2024-01-09 08:20
there are no releases past 0.56.0.6 but yes that pr is still outstanding

yousafn
2024-01-09 08:22
ahh its failed an update to the gems. which is why it hasn?t triggered a release. will take a look this week. just a small note i am travelling abroad today so might be next Monday before its sorted, but hopefully it?s something quick

kumar.vas85
2024-01-09 09:50
has joined #general

varnit.garg2424
2024-01-09 20:48
Hi, do we have an example of github ci pipeline that includes running the tests, publishing the pact file using pact cli, can-i-deploy etc?

matt.fellows
2024-01-09 21:02
howtoexamples


matt.fellows
2024-01-09 21:02
all of these

matt.fellows
2024-01-09 21:02
plus

matt.fellows
2024-01-09 21:02
howtolearn

2024-01-09 21:02
Here are a number of useful hands-on labs that teach all of the key concepts: https://docs.pactflow.io/docs/workshops and https://docs.pact.io/implementation_guides/workshops

buckley
2024-01-09 23:04
Just want to give a shoutout to Matt for killing it in here.

matt.fellows
2024-01-09 23:35
naww, thanks mate!

shuo.diao
2024-01-09 23:54
has joined #general

stan196
2024-01-10 02:21
Hey folks, there's no pact-protobuf channel so asking here. I was looking for a way to pass metadata (e.g. via https://github.com/pact-foundation/pact-go/blob/master/message/v4/asynchronous_message.go#L161) but it doesn't look like pact-protobuf actually consumes the metadata correctly - note the `None` as the last parameter: https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/protobuf.rs#L301 I'm not familiar with this codebase enough (and have 0.1 rust experience), so not sure how to fix this properly, and how to make sure you can support matchers on metadata fields.

stan196
2024-01-10 02:29
reading more about this, it doesn't look like `withMetadata` is supposed to work with plugins at all, or is? Seems like for grpc service interaction response metadata is embedded in the message config, so maybe it would be a good idea to add `pact:metadata` key to the protobuf message I wonder?

chris.speck
2024-01-10 02:52
has joined #general

matt.fellows
2024-01-10 03:55
It looks like metadata is supported (see readme here: https://github.com/pactflow/pact-protobuf-plugin)

matt.fellows
2024-01-10 03:56
But you?re right, for plugins, it doesn?t use the `withMetadata` construct

matt.fellows
2024-01-10 03:56
It looks like you can specify it using the `responseMetadata` property in the test

stan196
2024-01-10 06:19
yeah, that seems to work for testing grpc services, but not single async messages (e.g. kafka). I'll see if I can learn enough rust to copy the parts of response implementation to the message pact too, but will take me some time probably :slightly_smiling_face:

ulises.cervino
2024-01-10 14:25
bit of an odd one: is it possible to verify single interactions (instead of entire contracts)? Context: there?s a team developing AWS lambdas and I?m trying to figure out if we can put an http proxy in between pact and the lambdas, 1 by 1, and do the verifications that way. Thanks in advance (extra info: this is all JVM stuff)

trevor.cook
2024-01-10 18:33
has joined #general

matt.fellows
2024-01-10 21:45
as in, could you verify 1 interaction at a time and accumulate the verification results? I think you can do the former, but not the latter

matt.fellows
2024-01-10 22:04
ah, I see

ulises.cervino
2024-01-11 06:56
right, group by interaction (actually group by endpoint) instead of by consumer/contract

meetbogireddyhere
2024-01-11 16:20
has joined #general

matt.fellows
2024-01-11 23:49
Are each endpoint different lambdas, is that why you want to break it down that way? Is there a reason why you can?t proxy the whole set?

matt.fellows
2024-01-12 04:22
:wave: Hello ! I?m excited to announce that the PactFlow team has been working on a new project to improve the Pact contract testing experience. We are starting with *a survey* *to better understand contract testing practitioners? current experience and expectations around AI* :brain: *.* :cool-dog:*If you are new to Pact or have knowledge and experience creating Pact tests,* we?d be grateful if you could take a few minutes to complete this survey*.* The survey will be *open until Jan 19 (next Friday).* :point_right::skin-tone-3: Simply click on https://www.surveymonkey.com/r/PactFlow_AI_desirability and share your experience and thoughts! :gift_heart: As *a small token of our appreciation* each participant will receive 20 Swag Bucks (=20 USD) that can be redeemed through the https://swag.smartbear.com/. Please kindly leave your email address at the end of the survey, so we can reach out to you to offer the token. Your feedback is invaluable in shaping the future of contract testing and PactFlow together - thank you!:pray: If you have any questions, please contact me or @ying.li (our friendly UX researcher) directly!

ulises.cervino
2024-01-12 05:31
I am also trying to proxy the whole thing :slightly_smiling_face:

ulises.cervino
2024-01-12 05:31
and yes, each lambda is a diff endpoint, but I?m looking at all options

dan.corder
2024-01-12 10:04
Hi are there any plans or support already for extending the type of response content that the framework understands? For example we have endpoints that return JWTs which pact doesn't understand so we have to specify exact responses for our pacts making them rather brittle. If the framework could understand the structure of a JWT and handle the base64 encoding then our tests could be much more like tests for plain JSON endpoints.

matt.fellows
2024-01-12 10:24
In general, yes open to extension like this

matt.fellows
2024-01-12 10:25
there are two main ways to achieve this: 1. contributions to the core (https://github.com/pact-foundation/pact-reference/tree/master/rust) 2. https://docs.pact.io/plugins/quick_start Probably, this would need to be a new matcher in the core.

david.garratt
2024-01-12 10:36
has joined #general

dan.corder
2024-01-12 10:40
Thanks for the pointers, I've never used rust before so it's going to take a while to understand what's going on there.

ulises.cervino
2024-01-12 12:09
can I get a sanity check here? I?m thinking about API version retirement. Let?s say I (provider) am supporting V1 and V2 of my API and I want to retire (delete) V1. My rough plan would then be: 1. get all consumers to stop publishing contracts for V1 (of course that their app should equally stop using V1, otherwise none of this works) 2. all consumers would, of course, be using V2 at this stage 3. because these new without-V1 contracts are being verified, they can roll out (can-i-deploy would be happy still) 4. consumers rollout 5. in a feature branch my provider stops verifying V1 API contracts, consequently all V1 code is removed 6. in theory, because all consumers have no-V1 versions rolled out (and recorder) can-i-deploy is also happy for my provider 7. provider-without-V1 rolls out (voila!)

ulises.cervino
2024-01-12 12:09
Y/n?

roger.vanburgh
2024-01-12 16:54
has joined #general

salmaan60
2024-01-12 20:59
I am interested in this approach as well. How can we make the tests run post-deployment on a dev environment?

matt.fellows
2024-01-12 21:39
A good start would be to create a feature request on the repo and we can start to shape the idea there. Also chat with us in #libpact_ffi-users

matt.fellows
2024-01-12 21:39
FYI the lead maintainer is currently on annual leave so we may need a few more days before he can help out

matt.fellows
2024-01-12 23:04
What problem are you having trying that?

salmaan60
2024-01-14 11:54
At this early stage, I don't know how to proceed with this. All the documentation on http://docs.pact.io point to running the tests pre-deployment as a unit test. Is there a guide that shows how we can run these tests after deployment?

matt.fellows
2024-01-14 21:22
Have you just tried it? The verifier doesn't care where your app is, you just give it the URL of where it's running

matt.fellows
2024-01-14 23:06
Sounds about right to me!

matt.fellows
2024-01-14 23:10
It might require a custom verifier to do this, or an update to the pact broker to support incremental verifications.

matt.fellows
2024-01-15 05:40
Let us know if that?s a path you want to consider, and we can start to establish some pointers

ulises.cervino
2024-01-15 08:08
tbh I?d rather have a realistic setup, i.e. a proxy with actual endpoints the app will call with the lambdas (maybe via aws sam) behind

sarah.omalley
2024-01-15 10:03
has joined #general

matt.fellows
2024-01-15 10:53
Yep, that?s probably better

lauren.flanagan
2024-01-15 13:51
has joined #general

salmaan60
2024-01-15 17:13
I'll give it a shot this week,

yousafn
2024-01-15 17:46
Release going out now, thanks for the heads up @devin.woods

tunga
2024-01-15 23:16
has joined #general

sayan.adak
2024-01-16 12:21
has joined #general

shobhit.agarwal
2024-01-16 12:22
has joined #general

carmen.rietdijk
2024-01-16 12:53
has joined #general

sayan.adak
2024-01-16 13:37
Hello, I have a general question regarding the implementation of Pact in our microservices (Java, Golang). Our requirement is to execute the provider test in the CI pipeline before the deployment step of the provider service, but we want to avoid making calls to the actual provider service deployed in some non-prod environment due to data issues. To address this, we plan to mock external API and DB calls. Now, my query is about where Pact will make the HTTP request. If Pact initiates the request to the application started in the CI pipeline programmatically, it could pose challenges because our application has numerous dependencies such as DB connections, Kafka setup, etc. Starting the application with all these dependencies configured could be problematic, especially since these dependencies are irrelevant for running the Pact provider test. In general, how do we effectively use Pact in such a situation? Additionally, is there a method for Pact to directly call the service method instead of making HTTP calls? Any insights or guidance on this matter would be greatly appreciated.

ulises.cervino
2024-01-16 14:33
> these dependencies are irrelevant for running the Pact provider test that?s your answer

ulises.cervino
2024-01-16 14:34
I?d just mock all of these. In principle CT is about ?the wire? (serialisation, misunderstandings with the API, e.g. PUT vs POST vs PATCH) and not so much about the actual functionality/behaviour

sayan.adak
2024-01-16 15:04
@ulises.cervino Understood!!. Could you please assist me in mocking dependencies within a Spring Boot application? I'm particularly focused on the bean configuration, where configuration values are retrieved from the application.properties file based on the environment. I need to set up an application.properties file containing JDBC URLs, usernames, passwords, AWS config credentials, etc. Alternatively, is it possible to skip the bean creation and start the application without it?

ulises.cervino
2024-01-16 15:05
I don?t have much experience with SB, but if your app is largely driven from config I guess you can put special config so that mocks instead of actual DB drivers (or kafka clients) are initialised and injected?

sayan.adak
2024-01-16 15:07
This implies that in order to establish a JDBC connection, I must run a database instance, such as MySQL.

ulises.cervino
2024-01-16 15:10
you can mock your repository too

ulises.cervino
2024-01-16 15:10
with an in-memory implementation for instance

dan.corder
2024-01-16 16:52
Thanks for the extra details, I've created https://github.com/pact-foundation/pact-reference/issues/356 which is hopefully the kind of thing that you had in mind. No worries about waiting a few days, I suspect that this won't be a trivial thing to add (assuming that you decide you want to add it at all). I'm in the UK so happy to give more details or discuss things most times between 09:00 and 17:30 UTC

sayan.adak
2024-01-16 18:04
sure thanks

matt.fellows
2024-01-16 21:16
_UPDATE: thank you for all that have responded_ :pray:_, we have now run out of the swag bucks budget - sorry! You are still able to complete the survey if you have not done so, and instead of swag bucks you will be able to walk away with smug satisfaction and a big thank you from me. If you?re in Melbourne, you can also claim a coffee catch up from me_ :coffee:

nick116
2024-01-17 09:57
has joined #general

f.barril
2024-01-17 09:58
Hi, I have this validation failing ``` "description": "Expected a String matching /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/ (like \"ce118b6e-d8e1-11e7-9296-cec278b6b50a\") but got \"8f7acb45-093b-4ead-8ef0-46670cc6aars\" at $.data.payload.account_uuid"``` I can't see the difference

joshua.ellis
2024-01-17 10:40
The uuid you got ends in `rs`, which are not valid hex digits :slightly_smiling_face:

f.barril
2024-01-17 17:01
thanks!

miguel.heitor
2024-01-18 09:03
has joined #general

anshita.tripathi
2024-01-18 11:07
has joined #general

hiroshi.fujii
2024-01-18 14:50
has joined #general

ebernardino
2024-01-19 04:08
has joined #general

hegge.m
2024-01-19 09:40
has joined #general

visser.r
2024-01-19 09:40
has joined #general

dan.corder
2024-01-19 11:20
Hi, this is likely user error somehow, but I don't know where. We have a pact that expects a response with content type `application/jwt; charset=UTF-8` the pact contains an example response body (which has been encoded into base64 by the pact framework) and also a matching rule. When I run the provider side test it fails with a message like `1.1) body: / Actual body [application/jwt, 903 bytes, starting with 65794a30655841694f694a4b563151694c434a68624763694f694a46557a4931] is not equal to the expected body [application/jwt, 1248 bytes, starting with 5a586c4b4d47565951576c506155704c566a465261557844536d686952324e70]` This is surprising for a couple of reasons: 1. The expected bytes value is the base64 encoded version of the body - it should have been base64 decoded before being compared? 2. As there is a matcher rule I would not expect the example body to be used at all - or do matchers not work with non-JSON/XML bodies?

dan.corder
2024-01-19 11:49
I've tried setting `pact.content_type.override.application.jwt=text` which does the comparison as a string, but it still doesn't use the string matching rule in the pact.

dan.corder
2024-01-19 13:34
I think it could be that my pact file isn't set up correctly so the matches aren't being found.

dan.corder
2024-01-19 16:11
So, in case it helps anyone else I needed to: 1. Fix my pact file to target the regex matcher at `body` and `$` 2. Add `System.setProperty("pact.content_type.override.application/jwt", "text");` to my tests (note that this *not* `pact.content_type.override.application.jwt` as in the docs here: https://docs.pact.io/implementation_guides/jvm/provider/junit#overriding-the-handling-of-a-body-data-type)

matt.fellows
2024-01-21 02:36
Ah, good find. Looks like we need to update the docs

matt.fellows
2024-01-21 02:38
@rholshausen does this look correct?

rholshausen
2024-01-21 22:09
LGTM


dcrivella
2024-01-21 23:51
has joined #general

dmondejar
2024-01-22 03:39
has joined #general

dan.corder
2024-01-22 09:29
Thanks for updating the docs so quickly. FWIW on the consumer side it seems that both `application.jwt` and `application/jwt` work.

matt.fellows
2024-01-22 09:58
oh, interesting. Thanks for sharing - much appreciated!

grzegorzstanek
2024-01-22 10:46
has joined #general

sumitsg004
2024-01-22 17:12
Hi All, I have an get API which responds with zip file, so in the pact method I set the expected response header to be 'application/zip'. I want to know if I can do more than just validating response header? Meaning can I set specific expectation to return a zip file? like .binaryType() or .binaryBody(). Do we have anything like this? Basically I want to do just more than setting response header expectation. Any suggestion would be helpful.

yousafn
2024-01-22 18:15
assuming you are using pact-js (there are language specific channels) there is a method `withRequestBinaryFile` there is an example here https://github.com/pact-foundation/pact-js/blob/a5c5ee12bb534f20ce57879789b127d75cdcf656/examples/v3/todo-consumer/test/consumer.spec.js#L152

yousafn
2024-01-22 18:15
albeit for an image

yousafn
2024-01-22 18:15
there are methods for binary payloads on the response side too

sumitsg004
2024-01-22 18:43
Hi, thank you for responding. I am using Java actually. Can you point me to any example for adding binary payload on response side ? If you are aware. Looking for adding expectation of binary data on response side. Thanks

alexander.maiburg
2024-01-23 09:46
Hi, after upgrading to Angular 16 we had to deactivate /skip all Pact specs due to the fact that karma is not officially supported any more. Since we have thousands of tests it is really the last option to completely replace karma with jest. In the meanwhile I managed to install and configure jest and karma so that the old tests still run with karma and the pact test get executed by jest. So far so good. The problem is, that the pact tests are still failing. Is anybody here who could point me into a direction where I could see a working example installation of Angular, running jest and karma in parallel, because there are so many different possibilities of how you setup and write the test (e. g. jest-pact with pactWith).

yousafn
2024-01-23 11:41
we dont have any official examples of unsupported configurations. if you want to create a reproducible or representative example along with the errors you are facing, we can try and help. this question is also better asked in pact-js for a more targeted audience

francois.larouche1
2024-01-23 14:31
has joined #general

sarah.souza
2024-01-23 15:24
has joined #general

ndomingues10
2024-01-23 22:00
@alexander.maiburg I thought, that jest and karma couldn't run in parallel, since they're both test runners. Maybe it's the configurations in jest and karma in the port of the URL, where your mock server will run.

matt.fellows
2024-01-24 06:17
I don?t see why both Jest and Karma couldn?t run in parallel, but also probably no need in most cases. In the latest Pact JS, by default, each test gets its own random port (assigned from the OS) so it is less likely to clash with Karma if a fixed one is used. > Is anybody here who could point me into a direction where I could see a working example installation of Angular, running jest and karma in parallel, because there are so many different possibilities of how you setup and write the test (e. g. jest-pact with pactWith). I can?t really comment on how to run jest and karma side by side, I can?t see why they?d naturally conflict if they run in separate processes. I would steer away from `jest-pact` / `pactWith` because that was aimed at solving a problem that?s now less of a problem, so vanilla `@pact-foundation/pact` is probably sufficient. If you could share the errors you are having (failing pact tests with debug logs) then we could probably point you in the right direction

sumitsg004
2024-01-24 16:22
Hi All, I am trying to create a contract pact at consumer end for a provider which returns zip file in response. Currently I am setting expectations as below .willRespondWith() .status(HttpStatus.OK.code) .headers(mapOf(HttpHeaders.CONTENT_TYPE to zipContent)) Is there way to set expectation for contents of zip file? For example, if I want set expectation that inside zip file there should be specific directory/filename is present. Not bothered about file contents, but if a file or directory is present or not inside the zip file. Is there a way to set expectations like above? Reason I want this type of validation is my service is not directly consuming zip file, but is interested in the files inside it. Atleast I want to set expectation whether certain directory and files exists inside zip file

zachary.romano
2024-01-24 19:16
has joined #general

ken.overgard
2024-01-24 19:32
has joined #general

rama.ganapa
2024-01-24 21:13
has joined #general

justin.gilroy
2024-01-24 21:46
has joined #general

naveenkarkra
2024-01-24 23:36
has joined #general

alexander.maiburg
2024-01-25 08:46
Hi Matt, thanks for your help. I?v managed it to run the test without errors. But the pact file doesn?t get generated. No matter what I try. Attached you can find a test, wrapper class and the test results. Maybe you can spot the error. Thanks! Just for clarification: 1. Adding a interaction doesn?t effect the test result? When I comment out `provider.addInteraction(...)` or change the interaction object the test is still green. 2. The interaction object defines only the content of the generated pact file? It doesn?t get tested in `provider.executeTest(...)` in any way

yangtao.ge
2024-01-25 11:07
has joined #general

salman.bilalshah
2024-01-25 11:34
has joined #general

sridhar.munendramani
2024-01-25 14:32
has joined #general

scott.anderson
2024-01-25 15:05
has joined #general

bala.kurakula
2024-01-25 17:21
has joined #general

sarah.hand
2024-01-25 17:28
has joined #general

corey.jewett
2024-01-25 18:48
has joined #general

eddjlsh94
2024-01-26 09:41
has joined #general

falkowski.b
2024-01-26 10:59
has joined #general

yash.khade
2024-01-26 18:50
has joined #general

joe.allen
2024-01-26 18:50
has joined #general

andrew.voronin
2024-01-26 18:50
has joined #general

richie.schramm
2024-01-26 18:55
has joined #general

dsteinbach77
2024-01-26 23:23
has joined #general

rachida_laghmami
2024-01-28 15:53
has joined #general

matt.fellows
2024-01-29 00:13
each call to `executeTest` should check that the interaction you setup worked as expected, and serialise the interaction to the pact file (appending to any existing interactions in that file)

matt.fellows
2024-01-29 00:14
Just checking - is this mocking the HTTP client? This would mean calls aren?t getting to the mock server, which is how pact knows you did the right thing in your unit test

matt.fellows
2024-01-29 00:15
ah! you?ve defined your own `executeTest`? this isn?t doing what you think it is

matt.fellows
2024-01-29 00:16
1. Don?t mock your HTTP calls - they need to go to the pact mock server (the URL of which can be static, or dynamic and provided in the argument to the callback in `executeTest` (found on your `provider` variable) 2. Call `executeTest`. This takes a callback where your unit test takes place. Each test gets its own dedicated mock service (so you can run in parallel if you wish) and you must call the interaction you setup in the `addInteraction` call, else the test will fail a. This is when the pact file is written to

hrushikesh.agrawal
2024-01-29 07:13
has joined #general

santos.danallanbray
2024-01-29 10:50
has joined #general

katie.andriacchi
2024-01-29 15:05
has joined #general

darren.grove
2024-01-29 15:11
has joined #general

michael.brandeis
2024-01-29 16:37
has joined #general

niki.mahurin
2024-01-29 17:51
has joined #general

maria.olivero
2024-01-29 19:22
would love to hear when/how we can get our grubby paws on the kotin, python and typescript variants of this...

arina
2024-01-29 21:48
has joined #general

eddjlsh94
2024-01-30 09:34
Is there a channel dedicated to protobuf plugins where I can get support? I'm running into a lot of undocumented cases, for example importing .proto files in .proto files, that I can't seem to work around.

abubics
2024-01-30 10:11
There is the #protobufs channel . . . but it's pretty quiet in there.

eddjlsh94
2024-01-30 10:25
Thanks Boris, I missed it somehow!

eddjlsh94
2024-01-30 10:25
Appreciate it! :heart:

tomasz.perek
2024-01-30 12:19
has joined #general

josh.marlow
2024-01-30 16:28
hi all, is it possible to modify the billing administrator for an account? our previous administrator left without handing over access and we how no longer have access to the subscription portal - thanks in advance

sofia
2024-01-30 17:12
has joined #general

wesley.williams
2024-01-30 18:02
has joined #general

matt.fellows
2024-01-30 20:40
This sounds like a #pactflow question. The answer is yes, but you'll need to submit a ticket to support (howtosupport)

2024-01-30 20:40
Please create a ticket here with the issue details so that we can properly track the resolution and the PactFlow product support team will continue to work through it with you: https://support.smartbear.com/pactflow/message

josh.marlow
2024-01-31 08:00
great - thanks matt i shall do just that

alexander.maiburg
2024-01-31 08:46
Thanks Matt, I think I got it. I?ll try to implement it and come back to you.

matt.fellows
2024-01-31 10:22
no probs!

j.sauret
2024-01-31 14:03
has joined #general

andrevdrodrigues
2024-01-31 16:38
Hi folks. Does anyone knows if bidirectional contract tests support grpc validation as well? is there any demo showing this implementation? Thanks.

yousafn
2024-01-31 17:16
it doesn?t I?m afraid, only works with OpenAPI documents on the provider side currently

andrevdrodrigues
2024-01-31 17:17
got it. thanks!

yousafn
2024-01-31 22:08
Out of interest what would you be looking for, from the provider side, comparisons from the Pact file and stored proto file, against a new proto file that a provider publishes. Is the new proto file compatible with the main and deployed/released providers? Would you be looking to further completing the loop and performing a full verification on the provider side with Pact, or would you use the comparison against a providers new proto solely?

michelle.ryals
2024-01-31 22:17
has joined #general

jyothi.kaspa
2024-01-31 23:34
has joined #general

patrika.patil
2024-02-01 16:41
has joined #general

tim.willis
2024-02-01 16:44
has joined #general

yogi.patel
2024-02-01 18:38
has joined #general

sebbmoreno
2024-02-01 21:23
has joined #general

cverma28
2024-02-02 10:30
has joined #general

cverma28
2024-02-02 11:29
Hi All, Does any one have pact java framework with BDD implementation any help to write normal pact test in BDD style

a.g.s.maxwell
2024-02-02 12:54
has joined #general

t.mazelin
2024-02-02 23:33
has joined #general

maeleeuxs
2024-02-03 10:20
has joined #general

swaroopsonline
2024-02-04 02:44
has joined #general

swaroopsonline
2024-02-04 02:47
Hey there, could anyone tell me how to login to the Pactflow for the first time. I'm awaiting the login credentials and the one time password from Smartbear, but haven't seen anything in my email.

swaroopsonline
2024-02-04 02:48
Please let me know, thanks in advance.

matt.fellows
2024-02-04 05:30
Jo Swaroop, this is best asked on #pactflow in the future. Did you get the account confirmation email? I'm assuming you've setup your SmartBear ID profile and you're waiting for the OTP during login? F so, have you checked spam?

swaroopsonline
2024-02-04 06:58
Thanks Matt, it worked after some time. I thought I would get a login ID and a password both in the email. But there seems to be other way.

jose.silva
2024-02-04 14:45
has joined #general

sonal3062000
2024-02-05 09:52
has joined #general

lorenz.ammon082
2024-02-05 14:44
has joined #general

patrick.barnes
2024-02-05 19:44
has joined #general

andrew.kostka
2024-02-05 20:24
has joined #general

allie
2024-02-05 20:25
has joined #general

bryan.anderson
2024-02-05 21:18
has joined #general

alec.abdul-rahim
2024-02-05 23:34
has joined #general

filip.olszewski
2024-02-06 12:00
has joined #general

amol.jose
2024-02-06 18:03
has joined #general

ryoshida
2024-02-07 01:47
has joined #general

tomknee1
2024-02-07 10:08
Hello, just wondering if OSS pact works with gRPC please?

eddjlsh94
2024-02-07 10:24
There's a protobuf plugin that supports gRPC

eddjlsh94
2024-02-07 10:24
There's a #protobufs channel for that stuff

tomknee1
2024-02-07 10:26
perfect thanks

matt.fellows
2024-02-07 12:17
Thanks Edd!

eddjlsh94
2024-02-07 12:32
Are there any examples of provider tests for asynchronous protobuf messages written in JVM? I'm running into a million different issues at the moment. There is a Go example but Java has so many annotations I'm not able to translate it easily... I have service A that sends a protobuf message over kafka to service B asynchronously (there's no response). I'm trying to verify that contract. I have generated a contract, but I can't work out how to set up the provider side. Actually on that note, it feels weird that the "consumer" here is sending the message to a "provider" when it's a one-way message. Is that actually correct?

pallam.sudhasrinivas1
2024-02-07 13:21
has joined #general

michal
2024-02-07 16:36
has joined #general

rholshausen
2024-02-07 22:14
No, the consumer "consumes" the message :smile: It is the other way around than with HTTP interactions

rholshausen
2024-02-07 22:16
There are a few examples in the Pactflow GitHub org: https://github.com/orgs/pactflow/repositories?q=kafka&type=all&language=&sort=

rholshausen
2024-02-07 22:16
But nothing with Protobuf, unfortunately.


niels.schuette
2024-02-08 14:18
has joined #general

jegadeesan.ponnusamy8
2024-02-08 20:42
Hi, We are using Pactflow to verify service-to-service interactions across various environments like dev, int, preprod and prod. I am facing below 2 scenarios which needs your inputs to handle it? 1. Scenario - Microservices written before implementing Pact contract tests: We do have some microservices without contract tests and now running different versions in int, preprod and prod. So when we started implementing the contract tests for these microservices in dev, the Can-I-deploy tasks starts failing in int, preprod and prod. Because, the Can-I-Deploy checks for the pacticipant starts failing with the error message ":- No pacts or verifications have been published for version 567bcba1f3be811dccdf746184fc3d7781daea62 of <<_pacticipant service name>_>". So do you know how to handle this scenario? Because it is not always mandatory that we should start implementing the contract tests from day 1 & the microservice may start interacting with a new service after sometime. 2. Scenario - Messaged based testing: The Pact tests are seems to be very strict that the provider will only be verified with the contracts published by the consumer. If I wanted to promote an event provider (i.e. a Microservice) before a consumer , the contract verification step is failing in the tests due to missing consumer contracts. Is there any way, can I make this work without the much dependency on the consumer?

matt.fellows
2024-02-08 22:15
1. The only suggestion I have is to gradually add `can-i-deploy` to match your process 2. See https://docs.pact.io/pact_nirvana/notes_1

jeremy.buchmann
2024-02-09 00:11
has joined #general

rachel.green
2024-02-09 00:15
has joined #general

jj.guo
2024-02-09 00:33
has joined #general

dipali.gulhane
2024-02-09 07:01
has joined #general

dipali.gulhane
2024-02-09 07:20
Hi there, I am new to contract testing and trying to understand how does it replace Integration tests. While going through this blog: https://pactflow.io/blog/contract-testing-vs-integration-testing/ I would like to understand more on "They focus on testing a single integration at a time without the need to deploy". Does it mean we need to write mock for provider behavior always if we are not deploying provider service? But then once I develop provider service, why will I use mock?

matt.fellows
2024-02-09 07:31
It doesn't necessarily replace integration testing, but might replace end to end integration testing. Think of Pact as a unit testing tool, then you'll see why we use mocks in consumer tests.

matt.fellows
2024-02-09 07:32
You shouldn't have external dependencies during unit tests because they make your tests nondeterministic

manoj.chaudhari
2024-02-09 09:13
has joined #general

dipali.gulhane
2024-02-09 10:32
I think, I need to rephrase my question. Steps in contract tests: 1. Write tests at consumer end. 2. Execute these tests at consumer end and generate a contract file. 3. Upload a contract file on pact-broker. This is shared with provider. 4. On provider end: Replay the same API calls as given in contract file against the provider service. Here, I am executing a provider CI/CD pipeline. So, I do not have provider instance running. Then how can I replay the tests from contract file against provider and get the results for comparison? 1. Do we need actual provider instance already running? 2. Or do we need to create a mock service to depict the behaviour of a provider service? Let?s say add_role service is trying to establish a contract with create_user service. add_role is a consumer, which expects create_user to return {userid} in response. Now I have defined a contract test saying "As a add_role, I expect userid is present is response" I will run this test in consumer (add_role service) pipeline. And I will generate a contract file. Now as part of provider pipeline, before I build create_user service, I am going to execute contract tests. But then how can I get the response back from create_user service with userid if create_user is not running? I am confused here with provider part. Could you please help.

yousafn
2024-02-09 11:34
> Here, I am executing a provider CI/CD pipeline. So, I do not have provider instance running. You start up your service with the CI pipeline, such that it can receive the requests that are being replayed by the Pact verifier

dipali.gulhane
2024-02-09 12:42
I did not get you here when you say start service with CI, unless I deploy I cannot start the service is what I understand. If possible could you please provide links to video, article, code anything which gives idea about how provider CI pipeline and provider tests are written.

yousafn
2024-02-09 12:47
https://docs.pactflow.io/docs/workshops/ci-cd/ https://docs.pactflow.io/docs/examples#demos > I did not get you here when you say start service with CI, unless I deploy I cannot start the service is what I understand It?s possible to stand up an application to run locally, or in a ci/cd system. The specifics of which are probably a discussion with your developers, I am assuming you are not directly developing the situation yourself. The specifics of which will differ depending on which language/framework you are using. All of our examples utilise this pattern. Some start the applications programmatically during a test, others start the application as a separate process


yousafn
2024-02-09 14:15
:blobwave: Hope everyone is well this Friday and looking forward to the weekend. If you are new here, or have been silent for a while, feel free to say hello and give a little intro. ? Where are you from? ? How long have you been using Pact? ? What are you up to this weekend? I'm Saf, from Leeds in the UK. I got introduced to Pact at my last role, when I was discussing contract testing and other types of testing with our team, that we would utilise in order to ensure the quality of our application. Ended up making a few pull requests, and helping out with a few issues on GitHub and Slack. Little things, go a long way, and I ended up being fortunate enough to get a job as a Developer :avocado: at PactFlow and still to spend alot of my time as an open source community shepherd for the Pact project! :happy-hearts: The even awesomer thing is the open-source family has only gotten bigger with the SmartBear acquisition with Swagger and Stoplights tools not only long being favourites of mine but now also under our stewardship at SmartBear! This weekend it's the wife's birthday, so there shall be eating, dancing and cake. Let there be cake!!

eddjlsh94
2024-02-09 15:05
Hey Saf! My name is Edd, I live in Stockholm but am originally from England. Thanks for all yours (and Matts etc) help with Pact questions :slightly_smiling_face: I'm finishing up a proof-of-concept project implementing contract testing at a finance company. Mostly gRPC/Kafka so it's been fun to learn more about Pact. Thanks again for all your support :slightly_smiling_face:

martha.chambers
2024-02-09 16:15
has joined #general

adonay.berhe
2024-02-09 16:52
has joined #general

camilo.morales
2024-02-09 16:52
has joined #general

pere.villega
2024-02-09 21:33
:wave:

stan196
2024-02-10 00:35
> 1. The only suggestion I have is to gradually add `can-i-deploy` to match your process what we did was implement can-i-deploy everywhere but use `--dry-run` flag until all pacts and verification results are published. We've also added a custom script to skip `can-i-deploy` if we're checking a version that's not present in the pact broker.

stan196
2024-02-10 00:37
Also you can have a provider running `can-i-deploy` normally up until the point where a consumer publishes their first pact, so it makes sense to onboard providers first.

stan196
2024-02-10 00:37
there's also an `--ignore` flag in `can-i-deploy` which would allow ignoring pacts with individual services as needed

matt.fellows
2024-02-11 00:24
Put another way, usually you wouldn't test against a live system with Pact. This is because it's now testing many layers of your application and is susceptible to all of the problems of e2e testing, that we're aiming to avoid with contract testing

matt.fellows
2024-02-11 10:55
> what we did was implement can-i-deploy everywhere but use `--dry-run` flag until all pacts and verification results are published. I should have mentioned this as an option, but ultimately it still relies on the knowledge to ?trust? or ?not trust? the command in order to use it. > We?ve also added a custom script to skip `can-i-deploy` if we?re checking a version that?s not present in the pact broker. (edited) clever! Are you using the `describe-version` command or a custom API call?

stan196
2024-02-11 11:03
yeah, we're using `pact-broker describe-version` , we wrote a simple shell script that checks if `describe-version` returns `Pacticipant version not found` or some other error

stan196
2024-02-11 11:05
probably an api call would've been cleaner, but I haven't thought of that tbh :sweat_smile:

konstantin.manna
2024-02-12 08:30
Is there a way to specify to use a specific consumerVersionNumber with consumer-version-selectors? https://docs.pact.io/pact_broker/advanced_topics/consumer_version_selectors do not mention it. If not, shouldn't there be? + What would the recommended workaround be (use tags/branch names instead)?

jonathan.barker
2024-02-12 08:56
has joined #general

yousafn
2024-02-12 10:10
there isn?t and you should use the recommendations on the page. why do you want to specify a specific version

yousafn
2024-02-12 10:12
deployedOrReleased and mainBranch true, along with enable pending and include wip pacts if prob the best config alongside a triggered provider job when runs when a consumer contract changes

konstantin.manna
2024-02-12 10:32
Because I assume consumerVersionNumber to be the most specific identification of a contract version, instead of relying on branch with latest and/or tags.

konstantin.manna
2024-02-12 10:43
What is the recommended approach here though? The use-case this is for is for MR/branch verification. I.e. a consumer creates a new contract in a branch/MR, uploads the contract and providers are supposed to pull exactly this version for verificaton and then upload the results so consumers know with can-i-deploy if this is cool or not

yousafn
2024-02-12 10:46
there are two verifications when consumer changes contract - the provider is provided the version when a consumer pact changes and runs a verification via webhooks https://docs.pact.io/pact_nirvana/step_6 or the provider commits - the provider uses consumer version selectors. they use named selectors, so they don?t have to be aware of the underlying version, which may change (the provider doesn?t need to aware of the exact contract version on main branch, or deployed or released versions, as the broker would provide those pacts via the consumer version selectors)

tobiasroland
2024-02-12 10:48
has joined #general

konstantin.manna
2024-02-12 10:51
So when the consumer changes contract, the provider is provided the version how? We currently use webhook to trigger provider verification, but without telling the provider what version exactly to pull for verification, it pulls something wrong/different, hence we were thinking to tell the provider which version exactly to pull for verification via the consumerVersionNumber, but if this is not possible I am unsure how to tell the provider exactly what version/contract needs to be verified and hence asking for the recommended alternative approach

yousafn
2024-02-12 10:54
recommend webhook approach is this event, showing the versions on the contract it will trigger when a consumer contract is published https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event which webhook are you using? You can see the recommended ci/cd workflow in action via this demo set https://docs.pactflow.io/docs/workshops/ci-cd/ > We currently use webhook to trigger provider verification, but without telling the provider what version exactly to pull for verification, it pulls something wrong/different, It?s probably worth providing detail on this issue, rather than looking into workarounds at the moment

konstantin.manna
2024-02-12 10:58
> which webhook are you using? Not sure how to answer this. Is there different flavors/ways of webhooks on http://pactflow.io? Let me know what details I can provide to answer it > It?s probably worth providing detail on this issue, rather than looking into workarounds at the moment What details would you like me to provide?

yousafn
2024-02-12 11:31
1. which webhook are you using https://docs.pact.io/pact_broker/webhooks#the-contract-content-changed-event or https://docs.pact.io/pact_broker/webhooks#the-contract-requiring-verification-published-event 2. Why do you think the below is the case. What is your expectation, and how is your system setup. Are you publishing with branches/tags? Are you recording deployments/releases to environments > We currently use webhook to trigger provider verification, but without telling the provider what version exactly to pull for verification, it pulls something wrong/different, The fact you?ve mentioned that is key to your original question, which I believe to be an XY problem, you are asking you solve Y, but your problem is X (probably a misconfiguration or misunderstanding of webhooks)

konstantin.manna
2024-02-12 11:41
For 1 I assume we are using the "contract published"-webhook event? (see screenshot)? On 2: Because we can see from the provider verification logs that it pull a different version than expected. See 2nd screenshot XY may be the case, I unfortunately did not set this up and am trying to make sense of it :smile:

yousafn
2024-02-12 11:46
`c3ff556` looks correct, it is the short sha for the published version. the verification task, should be provided the URL of the pact that has changed, it looks like from your logs that its retrieving two pacts. You shouldn?t provide consumer version selectors, when you provide a pact url driven by a webhook



yousafn
2024-02-12 11:48
> XY may be the case, I unfortunately did not set this up and am trying to make sense of it No worries, I can appreciate that! We can definitely try and help

yousafn
2024-02-12 11:50
btw it doesn?t show that you are using the webhook pact url value, in your provider verification task, which is why you aren?t triggering a verification against the correct pact per sai

yousafn
2024-02-12 11:51
in the CI job, we read the PACT_URL from the webhook https://github.com/pactflow/example-provider/blob/594529a11b188f55d6dc86d95355f8a947d357b3/.github/workflows/contract_requiring_verification_published.yml#L20 and use this in our verification task. optionally if you use the newer webhook, you get a provider sha, for deployed/released and main versions of the provider, retrieved in line 21 and checks out the provider code in line 36

samantha.lam
2024-02-12 12:32
has joined #general

konstantin.manna
2024-02-12 13:07
> `c3ff556` looks correct It just does out of coincidence, but usually does not > btw it doesn?t show that you are using the webhook pact url value, in your provider verification task, which is why you aren?t triggering a verification against the correct pact per sai Maybe that is the problem then? I do not see any reference/usage of the PACT_URL, so should we update our webhooks to include the pactUrl in the body and then during verification set the env var PACT_URL to its value in order to assure that the correct version is pulled and verified? I just noticed that pact_urls are marked as deprecated? Is that so or am I misunderstanding something (See screenshot)? > No worries, I can appreciate that! We can definitely try and help Thank you very much. I appreciate it :blush:

yousafn
2024-02-12 13:14
ahhh okay, thanks for the screenshot that is helpful is tracing down which tool you are using It looks like that is from the python wrapper around the pact ruby cli https://github.com/pact-foundation/pact-python/blob/f02ea24321f41ea752512a2aec83350f96ebc7a1/pact/cli/verify.py#L134 I believe it is wrapping this ruby based verifier and I am not sure why it is stating those opts are deprecated :elmo_shrug: https://github.com/pact-foundation/pact-provider-verifier as part of this standalone bundle https://github.com/pact-foundation/pact-ruby-standalone it actually forms part of our legacy pact core, written in ruby and only supports up to v2 of the pact specification. https://docs.pact.io/diagrams/ecosystem#ruby-goldberg-machine You may find that using the verifier directly rather than using via the python wrapper should provide a more up to date experience. The libraries have mainly moved over to the pact rust core https://docs.pact.io/diagrams/ecosystem#rust-goldberg-machine of which there is a standalone verifier cli which supports up to v4 of the pact specification. https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli

yousafn
2024-02-12 13:15
oh btw the python wrapper states for the depration notice `specify pacts as arguments instead` which makes sense, as the ruby verifier takes the pacts as args, rather than a separate option

yousafn
2024-02-12 13:15
so just pop them at the start of the command, the full url from the webhook

yousafn
2024-02-12 13:16
btw sorry that is probably loads of information :slightly_smiling_face:

konstantin.manna
2024-02-12 13:16
Using it from the env (PACT_URL) should still work though, is that what your saying?

yousafn
2024-02-12 13:19
I can?t see anything that will read the PACT_URL from an env var, you will need to pass the value from webhook, and pass that into the command to the verifier so something like, assume PACT_URL is populated with the value from the webhook ```pact-verifier ${PACT_URL} --hostname=app ...other opts``` or ```pact-verifier --hostname=app --pact-url=${PACT_URL} ...other opts``` Even though it is marked as deprecated the code is still in place to read from the pact-url arg.

konstantin.manna
2024-02-12 13:22
I just double checked to be safe and it seems this is what we are using on CI: Does that make sense?

konstantin.manna
2024-02-12 13:23
It mentioned something about the standalone version here:

yousafn
2024-02-12 13:26
so that is a newer rust based verifier, the newest being here https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v1.0.3 Your version appears to be this https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.10.6 it looks to have renamed provider-verifier, has it comes as pact_verifier_cli in the tar.gz

konstantin.manna
2024-02-12 13:29
So does that mean we can set the env var PACT_URL accordingly?

yousafn
2024-02-12 13:30
it takes the option `--url` which you can repeat it there are multiple. map that value to the url from the webhook

konstantin.manna
2024-02-12 13:30
Cool, let me try that

konstantin.manna
2024-02-12 13:30
Thank you so far

logi.ragnarsson
2024-02-12 15:22
has joined #general

michal.patron
2024-02-13 10:41
has joined #general

tomasz.fiechowski
2024-02-13 11:14
has joined #general

gayatree.eee
2024-02-13 13:37
Could you please share some docs explaining how this tool is supposed to work and help developers to write test cases faster

yousafn
2024-02-13 15:10
We don?t currently have public facing docs as we have been inviting users to participate in an alpha to learn more.

coletaylor017
2024-02-13 19:50
has joined #general

lachlan.austin
2024-02-13 22:44
has joined #general

rejeesh.gangadharan
2024-02-14 00:55
has joined #general

dipali.gulhane
2024-02-14 07:57
@yousafn I will go through examples thanks for the links :+1:

utku.kilincci01
2024-02-14 08:00
has joined #general

ahmadlotfygamersfield
2024-02-14 14:38
has joined #general

evan.hafers
2024-02-14 15:11
has joined #general

wiktor2.karpinski
2024-02-15 09:31
has joined #general

cae.vieira
2024-02-15 11:37
has joined #general

cae.vieira
2024-02-15 11:39
Is there any way to deploy a provider before consumer on pact-broker? Provider code: ``` err := verifier.VerifyProvider(t, provider.VerifyRequest{ BrokerURL: "http://localhost:9292", ProviderBaseURL: "http://localhost:8080", PublishVerificationResults: true, ProviderVersion: "1.0.0", Provider: "provider-service", }) // Ignoring no pacts error - No pacts found for provider 'provider-service' matching the given consumer version selectors in pact broker 'http://localhost:9292'``` Check: ```? pact-broker can-i-deploy --broker-base-url "http://localhost:9292" --pacticipant provider-service --to-environment dev --version 1.0.0 Error retrieving matrix. PactBroker::Client::Hal::ErrorResponseReturned - Error making request to http://localhost:9292/matrix status=400 {"errors":["Pacticipant provider-service not found"]}```


cae.vieira
2024-02-15 12:07
That?s perfect, thanks Matt

m.barbosa
2024-02-15 13:54
has joined #general

r_connolly
2024-02-15 20:22
has joined #general

wally.yuen
2024-02-16 00:42
has joined #general

ahmadlotfygamersfield
2024-02-16 07:47
Hello, what if i had a contract then run tests that created new one will the first be overwritten or merged or be versioned?

matt.fellows
2024-02-16 09:06
Versioned

matt.fellows
2024-02-16 09:06
Look at the guide for versioning on http://docs.pact.io

david.montero
2024-02-16 10:29
has joined #general

david.montero
2024-02-16 10:34
Hi! we are trying to implement BDCT using OAS 3.0 spec for provider. Pactflow constantly warns that self test results are missing... aren't these optional according to documentation? can-i-deploy is failing because of this, and although the consumer is compatible (all interactions are green) the pact remains unverified. Is there a way to bypass this? We won't always get contract test results (external providers), Thanks!

hristian.iliev
2024-02-16 10:37
has joined #general

matt.fellows
2024-02-16 11:13
You'll need to publish them, even if an empty file.

matt.fellows
2024-02-16 11:13
The result needs to be successful otherwise we can't provide a positive can-i-deploy result

david.montero
2024-02-16 11:52
Ok got it thanks, as you say any file suffices

v-rybam-gri
2024-02-16 13:49
has joined #general

msarayu1111
2024-02-16 13:49
has joined #general

shivanirajebhosale16
2024-02-17 10:50
has joined #general

maciej.harapinski
2024-02-19 09:42
has joined #general

d.madureira
2024-02-19 14:17
has joined #general

charlan.bettiol
2024-02-19 17:21
Hello, is everyone okay? We are carrying out studies on the implementation of contract tests in our projects here in our company, so we need to show the value of contract tests, I am having difficulty entering metrics and values ??that can show how valuable contract tests are, you Is there anything that can help me?

dpunna
2024-02-19 18:35
has joined #general

cae.vieira
2024-02-20 10:45
I can?t seem to make CI pipeline work when provider is deployed first. Getting `Computer says no` on `can-i-deploy`. Steps taken on thread.

cae.vieira
2024-02-20 10:46
Provider: 1. `VERSION=1.0.0 CI=true PACT_BROKER_BASE_URL=http://localhost:9292 make test` 2. Provider test selector: ```ConsumerVersionSelectors: []provider.Selector{ &provider.ConsumerVersionSelector{ MainBranch: true, }, &provider.ConsumerVersionSelector{ DeployedOrReleased: true, }, &provider.ConsumerVersionSelector{ MatchingBranch: true, }, },``` 3. `pact-broker create-or-update-version --broker-base-url "http://localhost:9292" --pacticipant provider-service --version 1.0.0` 4, `pact-broker can-i-deploy --broker-base-url "http://localhost:9292" --pacticipant provider-service --to-environment dev --version 1.0.0` 5. Computer says yes \o/ 6. There are no missing dependencies 7. `pact-broker record-release --pacticipant provider-service --version "1.0.0" --environment dev --broker-base-url "http://localhost:9292"` Recorded release of provider-service version 1.0.0 to dev environment in the Pact Broker.

cae.vieira
2024-02-20 10:48
Consumer: 1. `pact-broker publish "./backend/pacts/" --consumer-app-version 1.0.0 --branch "master" --broker-base-url "http://localhost:9292"` 2. `pact-broker create-or-update-version --broker-base-url "http://localhost:9292" --pacticipant consumer-service --version 1.0.0` 3. Created/updated pacticipant version 1.0.0 in the Pact Broker 4. `pact-broker can-i-deploy --broker-base-url "http://localhost:9292" --pacticipant consumer-service --to-environment dev --version "1.0.0"` Computer says no ¯\_(?)_/¯ CONSUMER | C.VERSION | PROVIDER | P.VERSION | SUCCESS? | RESULT# ---------------------|-----------|-------------------------|-----------|----------|-------- consumer-service | 1.0.0 | provider-service | ??? | ??? | There is no verified pact between version 1.0.0 of consumer-service and the version of provider-service currently in dev (1.0.0)

michael.schmidt
2024-02-20 11:01
has joined #general

yousafn
2024-02-20 11:09
you haven?t shown any steps, where you?ve actually verified the consumer pact against the provider, so the output looks correct to me

michael.schmidt
2024-02-20 11:12
Hi, is it possible to manually start verification of specific provider version and specific consumer version (without pushing new pact, use existing pact)? I do not find any verify endpoint in api browser, or any way which allows triggering the provider webhook with provider version and consumer version.

yousafn
2024-02-20 11:18
a webhook would provide the url of the changed pact, and git commits for a provider, in which to check out certain versions of their code https://docs.pact.io/pact_broker/webhooks#using-webhooks-with-the-contract_requiring_verification_published-event the execution of the jobs is out of scope of the broker, the broker would just trigger the webhook. You should have a CI job that takes the inputs pactUrl and the provider version, and then can pull the relevant pact from the broker. otherwise if you want to run it locally, just use the pact url from the contract you wish to verify and pass that into your providers verification task

cae.vieira
2024-02-20 11:21
Which steps am I missing? Or could clarify? FYI: they are both golang services using pact-go

yousafn
2024-02-20 11:24
It looks like you are missing the key part, which is verifying the consumer contract is aligned with your provider. There are two ways to verify pacts https://docs.pact.io/pact_nirvana/step_4#verifying-pacts It looks like you?ve just set up 1 and haven?t setup anything to verify the changed pact. https://docs.pact.io/pact_nirvana/step_6#add-a-new-provider-verification-job

michael.schmidt
2024-02-20 11:26
Thanks for fast reply. We do have a CI job which starts the verification and we use it also to start verification manually. But the CI pipeline which is used from webhook needs some variables and I thought it would be easier to trigger verification from pact broker. But if there is no pact broker way, we will build little verification tool for our pipeline.

yousafn
2024-02-20 11:31
np, So the PB way, is to use events which are emitted when a contract is published, or requires validation, which will trigger a registered webhook, which will call your CI system. I?m not sure as to why you want this manually. maybe you could elaborate? If this maybe to re-run a verification at will, in a representative of CI state. Do you anticipate this run would publish verification results? Or is this a way of a developer verifying an url manually without using their local machine? There is the ability to manually trigger webhooks via a test functionality in the UI, it may be able to programatically accessed

cae.vieira
2024-02-20 11:33
The `make test` on the provider would run this go test, wouldn?t this handle that verification: ``` err := verifier.VerifyProvider(t, provider.VerifyRequest{ BrokerURL: os.Getenv("PACT_BROKER_BASE_URL"), ProviderBaseURL: "http://" + serverAddress, PublishVerificationResults: os.Getenv("CI") == "true", ProviderVersion: os.Getenv("VERSION"), ProviderBranch: "master", Provider: "provider-service", ConsumerVersionSelectors: []provider.Selector{ &provider.ConsumerVersionSelector{ MainBranch: true, }, &provider.ConsumerVersionSelector{ DeployedOrReleased: true, }, &provider.ConsumerVersionSelector{ MatchingBranch: true, }, }, })```

cae.vieira
2024-02-20 11:33
Seems like I need to have a better look on the webhook part

yousafn
2024-02-20 11:36
it should grab it under `MainBranch` consumer version selector, but that would rely on you running that provider verification job again (either manually) or on the next provider change, in order for it to verify it and publish results. that time gap for feedback is usually too long, which is why you have a task utilising webhooks, your verification task should accept a pactUrl and if one exists not pass any consumer version selectors to the broker. This is a verification triggered by a pact change.

michael.schmidt
2024-02-20 12:32
In our setup we have 3 cluster (dev, test and production). The event based verification works for dev cluster, when any consumer publishes new pacts. PB triggers automatically (with registered webhook) the provider verification and all is fine for dev cluster. Also the deployed cluster versions of any services are tagged inside PB, so it knows the current version of any service across all cluster. Unfortunately days or weeks later when someone tries to publish a new provider or consumer version into the next cluster (test or production), the can-i-deploy step often tells us, there is no verified pact between the deployed cluster version and new version. I don't know why this happens, but our solution to fix this verification problem is to manually start the missing verification. But the current way for manually verification trigger with starting a pipeline is a little bit awkward and because of this I search for better solution.