uglyog
2018-04-07 05:15
has joined #pact-rust

uglyog
2018-05-02 05:05
/github subscribe pact-foundation/pact-reference releases

uglyog
2018-05-02 05:05
/github unsubscribe pact-foundation/pact-reference deployments public commits

tjones
2018-05-15 01:05
has joined #pact-rust

mboudreau
2018-05-20 23:48
has joined #pact-rust

andrewspinks
2018-05-24 11:01
has joined #pact-rust

mark.bridgett
2018-09-13 08:38
has joined #pact-rust

mark.bridgett
2018-09-13 08:39
Hey, posting here because the pact-stub is written in rust and not sure if it applies to any of the other channels. I raised an issue on the pact-stub-server issues list on github a few weeks back. Not sure if anyone saw it or had any feedback? https://github.com/pact-foundation/pact-stub-server/issues

uglyog
2018-09-13 08:47
That project is for building the docker image, so that is why nobody has looked at it. I'll create issue against the actual project and link it

mark.bridgett
2018-09-13 08:49
Oh, thanks for pointing that out. Sorry it was put in the wrong place :disappointed:

uglyog
2018-09-13 08:49
No, not your fault. It's ours for having 2 projects in different places :wink:

mcon
2018-12-13 08:29
has joined #pact-rust

damien.castelltort
2019-02-26 17:01
has joined #pact-rust

audun.halland
2019-04-25 05:54
has joined #pact-rust

j
2019-04-25 06:01
has joined #pact-rust

matt.fellows
2019-04-25 07:21
has joined #pact-rust

matt.fellows
2019-04-25 07:21
:wave:

matt.fellows
2019-04-25 07:22
I'll add my previous notes a bit later as I had spiked both JS and Go using the rust lib. The main barrier from memory was that it previously didn't serialise the pact, so this would require the language binding to do that work. Also there are a bunch of new features in the languages we'd need to assess against what's currently been built

uglyog
2019-04-25 07:24
It also contains model classes that can serialise/de-serialise to the JSON format, so those could be re-used

uglyog
2019-04-25 07:24
But language implementations should use a proper set of models to represent a pact

matt.fellows
2019-04-25 08:04
Indeed

audun.halland
2019-05-06 13:05
Hi, I have started work on converting pact-reference to tokio/async (hyper 0.12). This is quite time consuming, but fun to work with. There are a couple of architectural implications as a result, that can be discussed here or elsewhere. It?s far from done, but if anyone?s interested you can find the in-progress branch at https://github.com/audunhalland/pact-reference/tree/hyper_upgrade

matt.fellows
2019-05-06 13:08
thanks for jumping in and giving it a crack

rob.clarken
2019-06-04 22:47
has joined #pact-rust

c.metz
2019-08-07 08:54
has joined #pact-rust

c.metz
2019-08-07 08:54
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/5737262 9/how-to-define-pact-specification-matching-rule-for-single-string-body. Help would be much appreciated. We got stuck with this. Thanks!

uglyog
2019-08-07 10:20
Prob better to implement support for multi-part bodies. I answered as such in SO.

c.metz
2019-08-07 10:53
Does this mean that regex matching on a full text body is currently not possible? The regex is not too complicated in this case as we now how the consumer is generating it.

c.metz
2019-08-07 10:54
I agree that implementing multi-part body support would be better, but I am afraid we don't have time for that right now.

c.metz
2019-08-07 10:55
Ow, by the way, we use the library of the rust implementation from C++. So I think we can only use pact.json files as input.

uglyog
2019-08-07 23:35
I just checked the implementation, and it is not applying matchers to the text bodies. Can you raise a issue at the Github project for this?

c.metz
2019-08-08 07:17
Thanks for checking! I created the issue as requested.

uglyog
2019-08-10 23:37
@c.metz if you want to design a better interface to support calling from C++, we can implement that.

audun.halland
2019-08-12 06:40
No new release for pact verifier?

uglyog
2019-08-12 06:48
Sorry, I ran out of time. I was trying to remove all the old versions of hyper first

uglyog
2019-08-12 06:53
I'll see about getting it out as is

audun.halland
2019-08-12 08:22
No worries :slightly_smiling_face: I just wondered if there were any remaining blockers left or you just forgot.

audun.halland
2019-08-12 08:22
I can wait

audun.halland
2019-09-12 14:57
Hi again, as I mentioned earlier this year my goal is to use the rust verifier with a node.js provider. I wonder how to approach that. Should I download `pact_verfifier_cli` in that project and be done with it, or do you instead want to migrate of `pact-node` itself to use `pact-reference`? If you want to do that, I am also willing to help. Of course the benefit of that is that JS consumer tests will also use pact-reference.

matt.fellows
2019-09-13 00:44
:wave:


matt.fellows
2019-09-13 00:44
This process has started, but we really need to do a bit of a planning session on this. My thoughts are to put together an RFC-style document that we can share. That?s on me as the core maintainer (of JS)

matt.fellows
2019-09-13 00:45
TL;DR to get moving quickly, using the verifier CLI. If you want to be on the inside track, it?s going to be a few months of work, but would certainly appreciate helping hand

c.metz
2019-09-13 08:36
Sorry the late reply. I am currently too busy to work on that but will consider for the future. Thanks for the help!

audun.halland
2019-09-17 15:31
I did it :slightly_smiling_face: now building our CI pipeline using `pact_verifier_cli`!

matt.fellows
2019-09-17 22:34
awesome @audun.halland!

matt.fellows
2019-09-17 22:35
Publishing the results to the broker is doable without Rust, but a PR would be nice if it doesn?t exist eh @uglyog?

uglyog
2019-09-17 23:02
Yeah, PR's are awesome. @audun.halland has already done so much! I have some time this weekend, anyway. Can't believe I missed this.

audun.halland
2019-09-22 12:33
Nice :smiley:

pkuang
2019-09-30 17:53
has joined #pact-rust

audun.halland
2019-09-30 23:05
`json_pattern!` is completely awesome. I didn?t expect to be able to write consumer tests in rust that easily.

audun.halland
2019-09-30 23:09
just a side note: not that I?m really there yet, but how am I supposed to publish generated pacts from a Rust project?

uglyog
2019-09-30 23:49
ooh, you come up with the best questions :smile:

uglyog
2019-09-30 23:50
Publishing is just a PUT request to the pact broker. But I can write a CLI for you, or you can use the standard Pact CLI

uglyog
2019-09-30 23:51
Or just script it with Bash

uglyog
2019-09-30 23:51
Or Powershell, if that is your thing

audun.halland
2019-09-30 23:51
ok, curl seems like the way then, thanks

uglyog
2019-09-30 23:52
I might write a CLI anyway, because there is complexity with tagging and versions

uglyog
2019-10-03 03:02
@audun.halland You can use the pact-cli: https://hub.docker.com/r/pactfoundation/pact-cli

audun.halland
2019-10-04 23:39
Many thanks, will try that eventually. Obviously it will take some time to develop this Rust app

florian.nagel
2019-10-23 13:29
has joined #pact-rust

audun.halland
2020-02-03 11:31
It appears that the latest version has reintroduced regex errors, a bug that was previously fixed by using the `onig` lib

audun.halland
2020-02-03 12:53
Btw, did you have any progress on pact-js v3?

uglyog
2020-02-03 20:41
Hmm, that?s not good. It should still be using the onig crate. Can you check what crates where compiled?

uglyog
2020-02-03 20:47
The consumer side is working, for the provider verification side I was waiting for a PR to be merged in Neon which is the library I?m using that provides JS to Rust bindings. Looks like it has been merged now, so just need to wait for the next release of Neon

audun.halland
2020-02-03 21:37
Yes, I haven?t checked it in detail yet

audun.halland
2020-02-03 21:38
Some colleagues saw some regex related errors after upgrading verifier-cli to latest

audun.halland
2020-02-04 08:57
I?ll investigate a bit

audun.halland
2020-02-04 10:09
We can?t reproduce it now, so just forget this. What I?m misssing though is a release of linux `pact_verifier_cli` 0.7.x for my CI builds

asteffey
2020-02-04 20:45
has joined #pact-rust

uglyog
2020-02-05 21:00
I didn?t release the cli binaries because of the issue I had and wanted to test them some more. Could you not build them yourself?

uglyog
2020-02-05 21:00
I?ll have some more time this weekend

audun.halland
2020-02-05 21:19
There?s no rush, there should be no functional changes to the verifier after all, I just wondered if you had forgotten

abrinker
2020-02-24 19:36
has joined #pact-rust

abrinker
2020-03-02 19:48
Hi! I saw there was a compilation issue and came up with this fix. Happy to answer questions here or on GitHub. Not sure the protocol. This is my first contribution to Pact.

abrinker
2020-03-02 19:55
It occurs to me it may be better to add a private empty field so the type can't be constructed (private fields, no constructor) which would better avoid possible accidental instantiation in the future. I'll try that change.

abrinker
2020-03-02 20:00
I've pushed that change, and confirmed that the type is now unconstructable, so it can _only_ be used for type-level programming.

abrinker
2020-03-02 20:18
Looks like some broken tests had been hidden by the prior compilation issue. Just pushed a third commit which fixes those tests.

uglyog
2020-03-03 02:31
@abrinker we've merged your PR, and there looks like a flakey test failing which we have ignored for now

audun.halland
2020-03-03 06:31
Is it a test that's unstable on windows?

matt.fellows
2020-03-03 06:41
The one that failed for me was OSX but then also failed on Linux. It's needs some uplift to be a good test anyway so we'll figure that out

abrinker
2020-03-03 13:39
Thanks @uglyog!

uglyog
2020-03-12 23:13
> chore: remove unused import from provider_client (Matt Fellows)

uglyog
2020-03-12 23:14
Look @matt.fellows helped with a Rust component :smile:

matt.fellows
2020-03-12 23:52
I believe there are some commits in the JS repo now with Rust code :wink:

matt.fellows
2020-03-12 23:52
OK, so let?s swap - today you do marketing website and i?ll do Rust - sound good?

audun.halland
2020-03-13 00:06
cool, you commited some new stuff on v3.0.0. I can?t wait :grimacing:

uglyog
2020-03-13 00:07
I'm hoping to get the first beta out today

asteffey
2020-03-24 21:15
Per the discussion here in #pact-c-plus-plus, https://pact-foundation.slack.com/archives/CPGH2TLLX/p1584386254001600, our team is planning on making a few basic enhancements to pact-reference: ? Add a new MessagePacts struct (variant of existing `pact_matching::models::Pact`) ? Add FFI interfaces to read/verify Pacts for `match_message`, `Message`, and the new `MessagePact` to allow these to be called from C/C++ We were then planning to create a thin C++ program to use those methods to orchestrate Pact provider verification. Would this be duplicative or contrary to any of the Pact team?s current plans for C++/Rust? If so, please let us know and we can change direction.

uglyog
2020-03-24 22:12
No, the initial kickoff for the C++ integration has not happened yet, so I think you can go ahead

andrewspinks
2020-03-31 22:24
@uglyog Aggeees ago I had ago at implementing the rust native lib into the swift code base (2 years ago). It was probably 80% functionally complete (and another contributor has taken that further and finished the remaining matcher, but there are still lots of rough edges). @marko.justinek is keen to give it another crack, but I?m not sure if things have changed much since that time and it may be an easier endeavor now? I see you guys have been working on this for pact-js.

marko.justinek
2020-03-31 22:25
has joined #pact-rust

uglyog
2020-03-31 22:26
Rust support from other languages has changed, but the implementation you worked with is still much the same

marko.justinek
2020-03-31 22:26
oh hello

matt.fellows
2020-03-31 22:27
I had a bit of chat with Marko last night

uglyog
2020-03-31 22:27
For pact-js, we are using a Rust<->JS binding library

matt.fellows
2020-03-31 22:27
Two of the key files I put together back in the Go days: ? https://github.com/pact-foundation/pact-go/blob/feature/native/dsl/matcher.go - generating a v2 compatible spec (no generators) ? The native package: https://github.com/pact-foundation/pact-go/tree/feature/native/dsl/native (links to the Rust c interface)

andrewspinks
2020-03-31 22:28
ahh, right, where does that live? Or is it part of the pact-js branch?

matt.fellows
2020-03-31 22:28
That spike worked

matt.fellows
2020-03-31 22:28
It should be much easier on the consumer side, because the mock server and matching all works, and you don?t need to do the provider side

uglyog
2020-03-31 22:28
pact-js V3.0.0 branch

andrewspinks
2020-03-31 22:29
:ok_hand:

marko.justinek
2020-03-31 22:29
yeah, this should be enough to give it a crack

matt.fellows
2020-03-31 22:30
The gaps if you were coming from the Ruby implementation (from memory, need validation): 1. You need to generate the pact _before_ running the pact tests (they aren?t generated like in Ruby) 2. Pretty printing of the error diffs is something you need to do

andrewspinks
2020-03-31 22:30
Yeah, I have a spike implementation of all that already.

matt.fellows
2020-03-31 22:30
nice

andrewspinks
2020-03-31 22:31
There is a lot of tooling work that needs to go into it. e.g. how to specify the pact output location, get debug logs to users, and there was some weird linking issues with iOS (maybe that has been resolved).

andrewspinks
2020-03-31 22:32
its complicated by having to run stuff in a simulator

matt.fellows
2020-03-31 22:32
mmmm

andrewspinks
2020-03-31 22:32
specific to iOS

matt.fellows
2020-03-31 22:33
If I understand correctly, you currently run the Pact server _external_ to the simulator - I?m sure you couldn?t do that within, right?

marko.justinek
2020-03-31 22:33
correct

andrewspinks
2020-03-31 22:33
with rust, can run it in the simulator, which is what we are hoping for. Otherwise we have to rely on external ways of starting and stopping the server

matt.fellows
2020-03-31 22:33
yeah. Much nicer experience I imagine

andrewspinks
2020-03-31 22:34
it makes the setup and documentation a PITA. plus we cannot do things like pact broker integration.

uglyog
2020-03-31 22:40
Running the mock server in the simulator feels wrong to me, because the actual server won't be running on the device

marko.justinek
2020-03-31 22:48
we can run without spinning up the iOS (iPhone) simulator but that would require us to go into command line and use `xcodebuild` or `xctool` but that?s normally only used in CI, not when writing unit tests. When working in Xcode and hitting ?run tests? for iOS it automagically spins up the simulator.

marko.justinek
2020-03-31 22:49
the main idea of me giving it another crack at it is to avoid the pain of setting up the Ruby dependency, setting up the IDE environment, dealing with builds going belly up due to dependencies, having to run multiple pact-mock-services if I have multiple providers, etc.

marko.justinek
2020-03-31 22:50
also, swift from has made huge leaps from when Andy started his framework

marko.justinek
2020-03-31 22:51
anyway, I think I have a decent idea now how to proceed and Matt?s go example will be a good reference too

marko.justinek
2020-03-31 22:52
so, stay tuned and I?ll be throwing some random (mostly stupid) questions your way? maybe.

andrewspinks
2020-03-31 22:52
true, but they aren?t really meant to be e2e tests are they? I think tooling / developer ease of use might trump in this case??

matt.fellows
2020-03-31 22:52
I saw the pain that running it outside of the simulator introduces with Marko a few weeks ago. There is just so little visibility and way to link them together nicely, I can see all kinds of confusion ensuing.

matt.fellows
2020-03-31 22:53
So whilst I agree that running within the simulator isn?t ideal, it still makes a network request and will solve a lot of the ergonomics

marko.justinek
2020-03-31 22:54
LFS specific requirements and environment opened up a lot of questions and opened some more cracks that could be addressed with a new approach

marko.justinek
2020-03-31 22:54
especially, having to spin up 9 mock services if there are 9 providers :facepalm:

marko.justinek
2020-03-31 22:56
or, if the CI build gets cancelled (due to another push), the subsequent build fails because mock services are already running and the new build can?t spin them up again? can get frustrating to work with

matt.fellows
2020-03-31 22:56
yeah. The Rust experience is much nicer. It will also perform a lot better.

uglyog
2020-03-31 23:03
as long as an actual HTTP request is still being made

uglyog
2020-04-28 02:46
/github subscribe list

uglyog
2020-04-28 02:47
/github subscribe list features

kaypee90
2020-05-01 00:19
has joined #pact-rust

matt.fellows
2020-05-12 02:35
:clap:

uglyog
2020-05-12 02:35
What you clapping for?

matt.fellows
2020-05-12 02:36
binary payload matching, seems pretty cool

corey
2020-06-05 21:04
has joined #pact-rust

corey
2020-06-05 21:04
The stub server seems to want an exact body match on requests made to it but we want to be flexible on one field in particular in a JSON POST body and it doesn't seem to support falling back to the matchers specified in the pact

uglyog
2020-06-06 01:17
Can you raise an issue and be specific about the behavior you want?

corey
2020-06-10 23:20
So I realized our use case was a little... off. I resolved it by using an echo server for this use case. I may still write an issue describing the issue, especially if we decide we want to move back to the stub server for this or something else in the future.

a.smith
2020-07-16 16:26
has joined #pact-rust

a.smith
2020-07-31 19:51
Hi :wave: What is the `description` parameter defined on `new_interaction` in the FFI library? (https://docs.rs/pact_mock_server_ffi/0.0.7/pact_mock_server_ffi/fn.new_interaction.html) Is it the same as what?s called/used to be called(?) the ?state? string?

matt.fellows
2020-08-01 09:59
It would be the scenario name I'd imagine

matt.fellows
2020-08-01 10:00
I.e. the `UponReceiving` from https://github.com/pact-foundation/pact-net

a.smith
2020-08-01 15:25
Hmmm :face_with_monocle: There is an `upon_receiving` function defined in the Rust library too, and it turns out that the `given` function takes the state string.

matt.fellows
2020-08-01 22:37
I'll try and look at the rust interfafe later today

uglyog
2020-08-02 00:55
`new_interaction` creates a new interaction, which requires the description. `upon_receiving` just sets the description for the interaction. You don't need to use it unless you are changing the description.

uglyog
2020-08-02 00:58
I think there was a flow in the C++ DSL where we needed the interaction handle in the constructor, but we did not have the description yet, so `new_interaction` was called with a default description and then `upon_receiving` was used later to update it.

florian.nagel
2020-08-20 09:07
Is there an example on how to implement provider verification in a Rust project? I know that I can just go by the http://docs.rs but I'm a much faster learner when I just see it applied. Thanks in advance!

florian.nagel
2020-08-20 09:08
Still super happy that Pact exists :D


heytaco
2020-08-25 03:57
has joined #pact-rust

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-09-13 06:14
@uglyog how does one release the latest Rust stuff? I notice the changes pulled in a while back for the tls certificates aren?t released for https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_mock_server_ffi

matt.fellows
2020-09-13 06:14
I can see the groovy script there, is that manually run or via some other automation?

uglyog
2020-09-13 06:24
It's manually run

matt.fellows
2020-09-13 06:45
I'm happy to learn. Does it need any specific dependencies to kick it off?

matt.fellows
2020-09-13 06:46
(sorry not in front of computer now but if it's just that it needs groovy I can probably work it out)

matt.fellows
2020-09-13 06:46
I assume needs GitHub creds at the least

uglyog
2020-09-13 06:51
It needs push access to Github, and a key for http://crates.io

uglyog
2020-09-13 06:52
I'm busy adding message pact support, so will be doing a release soon

matt.fellows
2020-09-13 06:57
I saw that PR but couldn't see how immediately it could be used

uglyog
2020-09-13 07:03
It can't

florian.nagel
2020-09-14 07:58
@uglyog Made my day to see new updates to the Rust libraries. Here's a taco :taco: :tada:

florian.nagel
2020-09-25 13:11
How do I authenticate the `pact_verifier_cli` to my self-hosted Pact broker?

florian.nagel
2020-09-25 13:13
I think I found it. Nvm

ashishkujoy
2020-11-16 15:10
has joined #pact-rust

uglyog
2020-11-23 23:21
@matt.fellows can you create Github releases for the two modules? They are not automatically created.

matt.fellows
2020-11-23 23:21
ah!

matt.fellows
2020-11-23 23:21
sure

matt.fellows
2020-11-23 23:22
How do you normally do that?

uglyog
2020-11-23 23:22
I just do it from Github

matt.fellows
2020-11-23 23:33
Actually, I should release a new verifier CLI too. Will do that now

matt.fellows
2020-11-23 23:34
that all look OK to you? (I removed the commit sha?s in the release notes as per the others too)

uglyog
2020-11-23 23:34
It probably needs to be automated, but I sometimes like to add a blurb at the top

matt.fellows
2020-11-23 23:35
How do you upload the CLI artifacts? Do first run the `./release.groovy` and then run the docker scripts to generate OS specific artifacts?

uglyog
2020-11-23 23:36
A GH action builds the artifacts. The ZIP file will need to be downloaded, unpacked, and then attached to the release

uglyog
2020-11-23 23:37
I got a GH action publishing the artifacts somewhere else (Pact-JS I think). We can reuse that to do it automatically

matt.fellows
2020-11-23 23:37
cool

matt.fellows
2020-11-23 23:38
chuck that on the #TODO :stuck_out_tongue:

matt.fellows
2020-11-24 00:55
so I was waiting for some build to finish for the artifacts to publish, but then realised that I need to first create a GH release to get the artifacts to publish to the release :laughing:

wuddarwin
2020-12-14 05:24
has joined #pact-rust

nouri.tawfik
2020-12-16 19:20
has joined #pact-rust

audun.halland
2021-01-04 01:17
Hey guys. I?m working on some pact verification for a rust/tokio server. Setting up https://docs.rs/pact_verifier/0.9.5/pact_verifier/fn.verify_provider.html, my state change server and actual provider server with tokio, I expect this to just work. But.. there?s a commit (https://github.com/pact-foundation/pact-reference/commit/126b4635613820bcdc827f605a63b72fcc98d7dd) that changes `verify_provider` to block internally, causing my state change server to never respond, because the tokio runtime is already busy blocking.. Also I cannot understand from the commit msg why this was changed to block. Some help?

uglyog
2021-01-04 01:22
Just looking into that commit. I think it is an issue with Neon not providing any mechanism to deal with a promise yet

audun.halland
2021-01-04 01:24
A fix could be to change the public verifier API to be blocking.

uglyog
2021-01-04 01:27
I'm working on Pact-JS today, so I'll try sort this out for you. The blocking requirement should be implemented in Pact-JS, not the downstream Rust crate.

audun.halland
2021-01-04 01:29
Not sure. There?s not really any need for the public Rust API to be async, because that would tie every user to use the tokio runtime.

audun.halland
2021-01-04 01:33
using threads in tests would be more ?universal? perhaps.

uglyog
2021-01-04 01:42
Good point about the public API. I'm going to add a blocking version so we can have both.

uglyog
2021-01-04 01:43
Looking at that blocking code, I think a join3 would actually work there. Let me play around with that.

audun.halland
2021-01-04 01:46
Nice, thanks. So you also want to keep the async tokio version (which of course cannot be allowed to block)?

uglyog
2021-01-04 01:47
Yes, because I think it is used in Pact-JS. I'll confirm that.

uglyog
2021-01-05 03:29
I've removed the block_on calls and released updated version

audun.halland
2021-01-05 06:24
thanks :pray:

audun.halland
2021-01-05 07:39
Though, I think I want to wait for full tokio 1 support, to avoid temporary duplicated dependencies. `reqwest 0.11` should be right around the corner.


audun.halland
2021-01-11 03:51
Hi, @uglyog, would you care to make a new `pact_consumer` release as well? The current version still has e.g. `regex 0.1`

vuttithatkrongyot
2021-01-20 14:49
has joined #pact-rust

vuttithatkrongyot
2021-01-20 14:52
Hi @audun.halland @uglyog, can I ask some stupid question? How can I run standalone pact mock server ( https://docs.rs/crate/pact_mock_server_cli/0.7.3) ? I means where can I get the command or source code something like this https://github.com/pact-foundation/pact-ruby-standalone/releases

vuttithatkrongyot
2021-01-20 14:52
I try to find this for the whole day please forgive me ;(


audun.halland
2021-01-20 14:58
If you mean an actual executable

uglyog
2021-01-20 22:22
There is also a docker image for it

vuttithatkrongyot
2021-02-23 10:35
Hi team!, I've a question for pact-stub-server. Is it can respond data that depends on request? sth like this ```{ "request": { "firstName": "Tony", "lastName": "Strange" }, "response": { "userFirstName": $request.firstName, "userLastName": $request.lastName } }```

matt.fellows
2021-02-23 10:42
not at the moment, but this is a great idea. We?ve talked about extending the mock into this sort of thing before - e.g. predicates/expressions etc.

matt.fellows
2021-02-23 10:42
if you?re keen, a feature request at https://pact.canny.io/ (and/or a PR would be great :stuck_out_tongue: )

vuttithatkrongyot
2021-02-23 14:25
I think you need to add more category for stub-server


lewis.thorley
2021-03-21 20:34
has joined #pact-rust

lewis.thorley
2021-03-21 20:35
Hi I was wondering if someone could help me install the Rust Mock Server CLI? Struggling to work out how to do this and I'm not sure if I've missed something obvious


uglyog
2021-03-21 21:41
Just unzip it after downloading

matt.fellows
2021-03-22 01:50
Out of interest, what do you want to do with the Mock Server CLI?


lewis.thorley
2021-03-22 22:25
My aim was to send an interaction from a dart test to the mock server for verification

lewis.thorley
2021-03-22 22:26
Will give the above a try and let you know if I have any questions. Thank you!

vuttithatkrongyot
2021-03-24 09:45
Hi team! I found this problem when I try to run pact-stub-server with -b <broker-url> Can someone help me? T_T

vuttithatkrongyot
2021-03-24 09:47
Actually, I tried to run on another laptop and it's work but cannot fetch all contract file, it keep stuck in the same contract. Not sure what the problem is xD

vuttithatkrongyot
2021-03-24 11:28
AH it's fixed now, just restart

vuttithatkrongyot
2021-03-24 11:28
I got this instead

uglyog
2021-03-24 21:51
@vuttithatkrongyot can you raise a Github issue for that?

vuttithatkrongyot
2021-03-29 04:22
Sorry, I just found that it broke because of my contract. Now it's works correctly. Thanks

audun.halland
2021-03-31 12:06
Hi, I?m developing pacts in Rust again! `pact-consumer` supports matching patterns with macros like `each_like`, `json_pattern`, `like`, and `term`. Is there a way to make a date matcher, that?s not described in the documentation?

audun.halland
2021-03-31 12:11
I realize I can use `term!(pattern, example)`, but knowing there is native support for dates deeper somewhere in the Rust libs, I?m thinking it shouldn?t be too difficult to publicly export some more patterns in pact-consumer..?

uglyog
2021-03-31 21:48
The consumer DSL needs to be updated for all of the newer features, like matching values ignoring the keys, etc.

uglyog
2021-03-31 21:49
I think it is currently on-par with the Ruby version

matt.fellows
2021-04-11 12:22
@uglyog any chance you could please grant me access to publish the FFI variants (and other packages)?

uglyog
2021-04-11 23:05
I've added you to all the things

tjones
2021-04-13 09:10
Would some of these functions help? (I don't read rust very well) https://github.com/pact-foundation/pact-js/blob/feat/v3.0.0/native/src/lib.rs

uglyog
2021-04-13 09:18
It's more the Rust consumer DSL needs to be updated for the new features

tjones
2021-04-14 05:16
Yes, I was wondering if there was anything there that could be cribbed from

uglyog
2021-04-14 05:40
Oh, yeah, definitely!

yousafn
2021-04-15 20:19
has joined #pact-rust

github
2021-04-19 00:57
GitHub app is successfully upgraded in your workspace :tada: To receive notifications in your private channels, you need to invite the GitHub app `/invite @GitHub`

abrinker
2021-04-22 20:58
Hi! I just opened a PR against the `pact-reference` repo that I'm happy to discuss here or on the PR itself. It's fairly large, and adds a new crate called `pact_matching_ffi`, exposing `pact_matching` and (with recent changes) `pact_models` over FFI, for use by other languages.

uglyog
2021-04-22 22:48
Awesome, I'll have a look today. I'll be slowly moving the models out of the matching crate into the models one. I hope that doesn't impact what you are doing

matt.fellows
2021-04-23 00:11
Thanks, it?s so nice to see such well thought out, documented and presented PRs - a work of art!

github2
2021-04-23 00:27
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.8.14_ published by uglyog

uglyog
2021-04-23 00:29
I assume we should setup the CI to build the shared libs and header for this crate and attach them to the github releases

github2
2021-04-23 00:34
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.5_ published by uglyog

matt.fellows
2021-04-23 00:37
yep. We should also publish checksums, should be fairly easy

github2
2021-04-23 00:44
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.6_ published by uglyog

github2
2021-04-23 00:46
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_ffi-v0.0.3_ published by uglyog

tien.xuan.vo
2021-04-23 04:07
has joined #pact-rust

abrinker
2021-04-23 13:51
Glad y'all like it! We knew going in that this would be a big PR up front so we wanted it to be as easy to understand as possible.

cstepanian
2021-04-23 14:05
has joined #pact-rust

github2
2021-04-25 03:44
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.0.1_ published by uglyog

github2
2021-04-25 04:14
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.9.0_ published by uglyog

tien.xuan.vo
2021-04-26 11:25
Hi, I'm trying to use DSL functions with pact-rust pact_mock_server_ffi. And I have the error above :point_up:

tien.xuan.vo
2021-04-26 11:26
This is the code https://github.com/tienvx/pact-reference/blob/add-php/php/src/consumer-1/matches.php#L14 How can I see the log of this error, and how can I fix it?

github2
2021-05-04 00:04
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.0.2_ published by uglyog

github2
2021-05-04 00:14
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.9.1_ published by uglyog

uglyog
2021-05-04 00:18
You can enable log output with the `init` function. By default it will setup logging based on the `LOG_LEVEL` environment variable. So set `LOG_LEVEL=debug` and then call `init` in your PHP script.

github2
2021-05-04 00:49
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching_ffi-v0.0.1_ published by uglyog

tien.xuan.vo
2021-05-04 05:08
Will try

tien.xuan.vo
2021-05-11 07:12
I tried, but it does not print any log output. I think this problem: > Segmentation fault (core dumped) Come from this line: > if let Some(description) = convert_cstr("description", description) {

pact544
2021-05-26 22:01
has joined #pact-rust

wayofthepie
2021-05-29 17:16
has joined #pact-rust

wayofthepie
2021-05-29 18:00
Hi Folks, just wondering if anyone knew of an example of using message based pacts? I saw that the `pact_consumer` crate doesn't support messages yet, but the functionality does seem to be in `pact_matching`. I'm currently working through it, but an example would be great if it exists, thanks!

matt.fellows
2021-05-29 22:38
@uglyog ok if I release the latest FFIs and any dependencies?

uglyog
2021-05-30 00:06
I haven't seen an example yet, I'll see if I can set one up for you.

uglyog
2021-05-30 00:07
I need to release a whole bunch of crates today

github2
2021-05-30 00:17
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.0.3_ published by uglyog

matt.fellows
2021-05-30 00:22
cool that?d be ace

uglyog
2021-05-30 00:26
Someone is also asking about a consumer message test in Rust. You up for that?

matt.fellows
2021-05-30 00:28
As in you want me to add? I can try

uglyog
2021-05-30 00:31
No, no need unless you really want to

uglyog
2021-05-30 00:32
I'll probably try sort it out today

matt.fellows
2021-05-30 00:45
I probably won't get time today so go for it. I've been dabbling about but am offline now basically

github2
2021-05-30 00:49
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.9.2_ published by uglyog

github2
2021-05-30 01:01
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching_ffi-v0.0.2_ published by uglyog

github2
2021-05-30 07:28
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching_ffi-v0.0.3_ published by uglyog

github2
2021-05-30 07:38
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server-v0.7.17_ published by uglyog

github2
2021-05-30 07:55
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server_ffi-v0.0.17_ published by uglyog

github2
2021-05-30 08:09
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_mock_server_cli-v0.7.4_ published by uglyog

github2
2021-05-30 08:22
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.7_ published by uglyog

github2
2021-05-30 08:39
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_ffi-v0.0.4_ published by uglyog

github2
2021-05-30 08:52
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.8.5_ published by uglyog

github2
2021-05-30 08:58
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_consumer-v0.7.6_ published by uglyog

wayofthepie
2021-05-30 09:03
That'd be great thanks! If not, I'll probably figure it out over the week and will write something up on it also.


artur
2021-06-01 03:19
has joined #pact-rust

cstepanian
2021-06-01 20:36
Hi folks, I'm working on a refactor and I found these two functions, `MatchingContext::matchers_for_exact_path` in `pact_matching/src/lib.rs` (https://github.com/pact-foundation/pact-reference/blob/4038e6118a162961bf55b85ea829c0e627f3c60b/rust/pact_matching/src/lib.rs#L433) and `MatchingRules::resolve_wildcard_matchers` in `pact_matching/src/models/matchingrules.rs` (https://github.com/pact-foundation/pact-reference/blob/4038e6118a162961bf55b85ea829c0e627f3c60b/rust/pact_matching/src/models/matchingrules.rs#L1376). Neither of them are directly tested, but I did find tests in `pact_matching/src/tests.rs`(but I can't find them now --- maybe they were removed recently?) and in `pact_matching/src/models/matchingrules.rs` that cover only the case where the category is "body". My questions right now: ? Are these functions actually used? I see deprecation warnings on some of the uses, but I'm not sure. ? If they are meant to stay, what exactly are they doing? It's not clear to me how the different cases are meant to work, and it concerns me that two of the cases appear to be uncovered by tests. I'm specifically curious about what check/operation is being done conceptually with the JSONPath here, since my intended refactor PR is all about the JSONPaths.

uglyog
2021-06-01 22:56
Yes, those are used. There should be tests, if not, please raise an issue for that. `matchers_for_exact_path` is used by matchers like `ArrayContains` because these matchers must not cascade down to child elements. `resolve_wildcard_matchers` is there to support deprecated matching logic which have been replaced with the `values` matching rule.

uglyog
2021-06-01 22:58
Eventually it will be removed.

uglyog
2021-06-01 22:59
There are some tests in `pact_matching/src/tests.rs`

cstepanian
2021-06-02 15:42
Alright, thanks for the info. I didn't catch the usage by ArrayContains, but had seen the deprecation warning you mention. I'm hoping to understand the concept of the "exact path" here. The code in the Body branch seems to be checking that the path weight is nonzero (which I understand to mean "matches in any capacity whatsoever") and that the lengths are equal. Is this the same as matching as much as possible? And either way, do you think this is a good candidate for refactoring into a generic operation/check on JSONPaths? I ask since I'm already refactoring. I'm just not sure what the documentation on that new function would say.

uglyog
2021-06-02 22:59
Ah, bit of history. The first matchers were designed to cascade, so that `eachLike` could be applied to all attributes of the object. That way the first matcher found by going up the tree was used.

uglyog
2021-06-02 23:03
There was a need for someone to match the values of an object, regardless of the keys (where it is treated like a map structure). As there was no mechanism to do this, a wild card type matcher was added (ending in a `*`), and if this was seen then the keys were ignored. But this caused other problems, because of the implicit nature of how the rules are setup.

uglyog
2021-06-02 23:10
So a "match only values" matching rule was added. But when matching a map, this rule must not cascade (i.e. when matching an object, don't also ignore the keys when matching child objects).

uglyog
2021-06-02 23:12
so, `resolve_wildcard_matchers` is deprecated because it has problems, but needs to be there to support older pacts (I'm of two minds on this). `matchers_for_exact_path` is used where matching rules must not cascade.

cstepanian
2021-06-03 15:03
Alright, thanks so much for the detailed background. I'm going to have to reread this carefully to wrap my head around it. On further rereading of the path weight and equal length check in `matchers_for_exact_path` and thinking about how calc_path_weight works, I think that the path weight would be zero if any token did not match, since the token weights are multiplied together in the accumulation (with `fold`). A nonzero result weight means that the path matched at least up to the length of the JSONPath. Thus you only need to check that the actual path is not longer than the JSONPath (which would mean there were un-checked tokens), to confirm that the JSONPath exactly matches the path under test. And for the purposes of this check, the particular path weight is irrelevant as long as it's not zero. Am I correctly understanding this?

uglyog
2021-06-03 22:32
Yes, that sounds correct. If I recall, I think it checks that the weighting is > 0 and that the matched path elements is equal to the path length.

uglyog
2021-06-05 04:46
@matt.fellows Your changes to `pact_verifier_cli` have resulted in `pact_verifier_cli -v` printing out the version from the FFI crate. I have fixed this in https://github.com/pact-foundation/pact-reference/commit/e8d6d84414e266d0557d6aee4f7260b70a2caf18 but it may have broken Pact-Go

matt.fellows
2021-06-05 06:21
ah crap, sorry

matt.fellows
2021-06-05 06:22
looking at your change, it should be fine - pact go doesn?t use the CLI

matt.fellows
2021-06-05 06:22
Unless I?m missing something?

uglyog
2021-06-05 06:22
No, just the function signature changed

uglyog
2021-06-05 06:23
Huh! Typical! ```$ git bisect bad 62a653cfe52f6283af38f6a8620192d2e8ea27ef is the first bad commit commit 62a653cfe52f6283af38f6a8620192d2e8ea27ef Author: Matt Fellows <matt.fellows@onegeek.com.au> Date: Thu May 27 23:40:27 2021 +1000 chore: remove unused imports rust/pact_mock_server_cli/src/server.rs | 2 +- rust/pact_verifier/src/tests.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)```

matt.fellows
2021-06-05 06:26
did it break stuff?

uglyog
2021-06-05 06:27
CLI Mock server just starts up and then exits

matt.fellows
2021-06-05 06:27
huh

matt.fellows
2021-06-05 06:28
so much for the rust compiler picking up useful bugs!

uglyog
2021-06-05 06:28
Might be because of this: ```- let (shutdown_tx, shutdown_rx) = channel::<()>(); + let (_, shutdown_rx) = channel::<()>();```

uglyog
2021-06-05 06:28
It's not waiting, because it is all async

matt.fellows
2021-06-05 06:29
I mustn?t understansd what `_` does. Does it not bind a variable at all, or just tell the compiler ?I know I don?t use it, but please stop complaining?

uglyog
2021-06-05 06:30
Yeah, I think it doesn't create a local variable, which probably causes the destructor to be invoked, and the server thread then exits

matt.fellows
2021-06-05 06:30
So `_shutdown_tx` it is?

uglyog
2021-06-05 06:34
The server future waits on that channel, so if it is de-allocated it will exit. Makes sense.

matt.fellows
2021-06-05 06:34
indeed

matt.fellows
2021-06-05 06:35
but also, holy shit. That has got to be up there with the most innocuous change I?ve made that has had a catastrophic impact on an app.

uglyog
2021-06-05 06:38
I was dreading the git bisect ending at "chore: update to Tokio xx Hyper yy and make it async"

uglyog
2021-06-05 06:38
It was a relief when I saw the bad commit

matt.fellows
2021-06-05 06:45
yeah, my commit is a fair bit easier to fix I would say

matt.fellows
2021-06-05 06:46
Probably we should add a really simple smoke check in the pipelines - e.g. see if the CLIs run

uglyog
2021-06-05 06:49
Nobody is complaining, so they probably aren't using that CLI or they haven't done a docker pull etc.

matt.fellows
2021-06-05 06:53
Yeah I?m surprised I hadn?t seen any issues :grimacing:

joaoproenca
2021-06-14 10:17
has joined #pact-rust

joaoproenca
2021-06-14 10:19
hey! I guess I was the first one to bump into that last Wednesday then :smile:

cstepanian
2021-06-15 17:07
Hello again folks, following up about my upcoming Pull Request related to refactoring JSON Paths. The situation is that my team would like to implement a feature whereby JSON Paths may include XML prefixes to disambiguate XML namespaces (a future PR). I concluded that JSON Paths would need to be changed (this PR) in such a way that they are parsed immediately upon parsing of the containing Pact structure (Request, Response, or Message), instead of being parsed lazily. That would allow XML prefixes contained in the JSON Path tokens to be resolved before matching occurs. (I considered a design where XML namespace+prefix information was passed through into matching instead, but abandoned it because it would require too many changes, and would spill out of XML-specific matching code) One behavior change included in this refactor is that parsing errors for the JSON Path expressions will occur at a different time, namely on construction/parsing of those Pact structures rather than during matching. The current codebase actually ignores parse errors, converting them into log warnings and returning a path weight of zero when matched against any path. *I'm hoping to get feedback specifically about this change to error handling*, but any other feedback is of course welcome! The work in progress is here: https://github.com/mitre/pact-reference/commit/c525f264afa48fffe4315400551a36e9ac7ec96e The diff is very large, but the gist is that I'm moving `calc_path_weight` and `matches_token` into `http://path_exp.rs` and encapsulating JSON Path operations into a new type, `JSONPath`. Other disclaimers: ? This work is based on an old version of `pact-reference/master`, but I think the diff is still representative. ? I think I was incorrect in my comment in the commit message about the potential issue where HTTP headers and query strings are plain strings rather than real JSON Paths. I later realized that all strings do eventually get parsed as if they are JSON Paths. Please let me know if you can confirm this one way or the other. Thanks very much!

uglyog
2021-06-15 22:57
I can review it when I get a chance. If the diff is large, is there a way we can split it up? I have been moving the models out of the matching crate into a separate models one, so that may affect your branch, especially if it has been long running.

cstepanian
2021-06-15 23:43
I was trying to keep it small, but the changes needed just to get it to compile kept escalating and spreading across the codebase. Turns out a lot of stuff works directly with JSON Paths :) So I'm lost on how to split it into any logical pieces, but I'm all ears. I linked directly to the diff in case you were curious, but mostly I wanted (at least for starters) to get a basic sense of whether this change fits your design and plans. In particular the error handling bit, and also whether this approach looks like a good way to get to the feature I mentioned, regarding XML prefixes in JSON Path tokens.

cstepanian
2021-06-15 23:44
And yes, I'm expecting to need to rebase and redo a bunch of this since things are moving around. Part of the reason I'm asking for this feedback now :)

uglyog
2021-06-15 23:51
Ok, I'll try review today. Creating a struct to represent the paths makes a lot of sense. I'm unsure of calling it JSONPath, though. Because they are not really JSON Paths (as in they do not conform to the spec), but are just based on them.

cstepanian
2021-06-15 23:52
Fair point about the struct name. Happy to call it something else :)

uglyog
2021-06-15 23:55
Maybe DocumentPath makes more sense, because they are paths to elements in any hierarchical document (JSON, XML, YAML) :man-shrugging:

uglyog
2021-06-16 00:55
Changes look good. Thanks for also converting to anyhow::Result as you went.

cstepanian
2021-06-16 14:56
Thanks for the review! I replied to your comments on that commit.

cstepanian
2021-06-16 14:57
Regarding the name of this new type, `DocumentPath` sounds appropriate but the golfer in me worries that it's too many characters :slightly_smiling_face: Do you think `DocPath`would be acceptable?

github2
2021-06-22 05:16
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.0.4_ published by uglyog

github2
2021-06-22 05:25
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.9.3_ published by uglyog

matt.fellows
2021-06-22 05:33
:tada:

matt.fellows
2021-06-22 05:33
thanks Ron

matt.fellows
2021-06-23 03:03
```> @pact-foundation/pact@10.0.0-beta.38 build:v3 /Users/matthewfellows/development/public/pact-js > neon build --release neon info running cargo Compiling proc-macro-nested v0.1.7 Compiling mime_guess v2.0.3 Compiling pact-js-v3 v0.0.6 (/Users/matthewfellows/development/public/pact-js/native) Compiling futures-util v0.3.15 Compiling multipart v0.17.1 Compiling h2 v0.3.3 Compiling futures-executor v0.3.15 Compiling futures v0.3.15 Compiling hyper v0.14.9 Compiling hyper-rustls v0.22.1 Compiling reqwest v0.11.4 Compiling pact_matching v0.9.3 Compiling pact_mock_server v0.7.17 Compiling pact_matching_ffi v0.0.3 Compiling pact_verifier v0.10.7 error[E0432]: unresolved import `pact_matching::models::json_utils` --> /Users/matthewfellows/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier-0.10.7/src/lib.rs:30:28 | 30 | use pact_matching::models::json_utils::json_to_string; | ^^^^^^^^^^ could not find `json_utils` in `models` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `pact_verifier````

matt.fellows
2021-06-23 03:03
So the update to matching breaks the verifier, it seems some packages have moved

matt.fellows
2021-06-23 03:04
I think i?ll need to update the `pact_verifier` package

uglyog
2021-06-23 03:04
Ah, damn, my bad

uglyog
2021-06-23 03:05
I only thought to release the matching crate

uglyog
2021-06-23 03:05
Do you want me to do that now?

matt.fellows
2021-06-23 03:10
I?m in there now

matt.fellows
2021-06-23 03:11
Just a matter of running the release script I assume?

uglyog
2021-06-23 03:14
No, it needs to be branched off the last release commit, because there are later changes that would require the model and matching crate released again

uglyog
2021-06-23 03:14
I'm doing that now

matt.fellows
2021-06-23 03:14
ah ok thanks

matt.fellows
2021-06-23 03:14
The mock service has the same problem, whilst you?re at it :laughing:

matt.fellows
2021-06-23 03:14
thx

matt.fellows
2021-06-23 03:18
If you?re feeling generous, might as well publish the latest FFIs too? (I think Adam is keen to use the new logging infra in Pact .NET)

uglyog
2021-06-23 03:19
Release all the things

github2
2021-06-23 03:19
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.8_ published by uglyog

github2
2021-06-23 03:26
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server-v0.7.18_ published by uglyog

github2
2021-06-23 03:32
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server_ffi-v0.1.0_ published by uglyog

github2
2021-06-23 03:39
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_ffi-v0.0.5_ published by uglyog

matt.fellows
2021-06-23 03:47
looking better. I think we now have a dependency on `pact_matching_ffi` , which makes sense because of the log interface: ``` @pact-foundation/pact@10.0.0-beta.38 build:v3 /Users/matthewfellows/development/public/pact-js > neon build --release neon info running cargo Compiling pact-js-v3 v0.0.6 (/Users/matthewfellows/development/public/pact-js/native) Compiling pact_mock_server_ffi v0.1.0 error[E0432]: unresolved import `pact_matching_ffi::log::fetch_log_buffer` --> /Users/matthewfellows/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_mock_server_ffi-0.1.0/src/lib.rs:92:3 | 92 | fetch_log_buffer, | ^^^^^^^^^^^^^^^^ | | | no `fetch_log_buffer` in `log` | help: a similar name exists in the module: `fetch_memory_buffer` error: aborting due to previous error For more information about this error, try `rustc --explain E0432`. error: could not compile `pact_mock_server_ffi````

uglyog
2021-06-23 03:50
Just releasing that now

github2
2021-06-23 03:53
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching_ffi-v0.0.4_ published by uglyog

uglyog
2021-06-23 03:56
I've also fixed some imports in pact-js

matt.fellows
2021-06-23 03:57
ah ok cool

matt.fellows
2021-06-23 03:57
thx

uglyog
2021-06-23 03:57
Should be all good now

matt.fellows
2021-06-23 03:58
thx :pray:

matt.fellows
2021-06-23 03:58
I?ll pull shortly

joaoproenca
2021-06-25 08:56
Hey folks. Pact-rust is the basis for the pact-ref-mock-server on DockerHub, right? Any chance we get an updated docker container with these latest developments? :slightly_smiling_face:

matt.fellows
2021-06-25 10:18
Should be able to have a look early next week. And yes, I'm pretty sure it is

matt.fellows
2021-06-25 10:18
Surprised it's not triggered automatically like the Ruby one. #TODO

scott.riley111
2021-06-25 12:09
has joined #pact-rust

scott.riley111
2021-06-25 12:11
:wave: Is there a list of supported rust versions or anything? I?ve tried to run a `cargo install pact_verifier_cli` and I?m getting an error that looks like a dependency version mismatch (error in thread)

scott.riley111
2021-06-25 12:11
``` Compiling pact_verifier_cli v0.8.5 error[E0061]: this function takes 1 argument but 0 arguments were supplied --> /Users/scottriley/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier_cli-0.8.5/src/main.rs:242:9 | 242 | match handle_cli().await { | ^^^^^^^^^^-- supplied 0 arguments | | | expected 1 argument | note: function defined here --> /Users/scottriley/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier_ffi-0.0.5/src/verifier.rs:133:14 | 133 | pub async fn handle_cli(version: &str) -> Result<(), i32> { | ^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0061`.```

scott.riley111
2021-06-25 12:12
this is on latest stable rust (`1.53.0`)

scott.riley111
2021-06-25 12:13
I?m also not sure - other than the docker image is there a way to download the already compiled binary? (I can see the readme has some release scripts for osx/windows/etc.)


matt.fellows
2021-06-25 13:10
Not sure about that error. Main seems to be passing in GH actions tho

scott.riley111
2021-06-25 13:34
ok :thumbsup: yeh I missed the verifier publishes in github

scott.riley111
2021-06-25 13:34
thanks

tien.xuan.vo
2021-06-26 13:10
Hi, I got this error when using https://github.com/pact-foundation/pact-reference/releases/download/libpact_mock_server_ffi-v0.1.0/pact_mock_server_ffi-c.h > Uncaught FFI\ParserException: undefined C type 'PactSpecification' at line 513

tien.xuan.vo
2021-06-26 16:04
Another question: We don't have something like this for pact message? > $ffi->with_specification($pactMessage, $ffi->PactSpecification_V3);

tien.xuan.vo
2021-06-26 16:53
And another question: Do we want to release new version of `pact_cli` ?

matt.fellows
2021-06-26 23:19
Don't need it for that yet, it's only v3

matt.fellows
2021-06-27 00:09
I don?t actually use that header file, not sure if it?s up to date

matt.fellows
2021-06-27 00:09
I map them to `int` (it?s an enum that is c compatible as sequential integers)

uglyog
2021-06-27 00:39
Ah! The structs and enums have been moved to a separate library. So they are not included in the header file by default.

matt.fellows
2021-06-27 01:05
Is that header created by hand or automatically? Do we need it?

uglyog
2021-06-27 01:15
automatically. But I don't think we need that enum, just an integer value would work

matt.fellows
2021-06-27 01:15
cool, that?s what I do

tien.xuan.vo
2021-06-27 01:45
My plan is to download that header file to use it in pact-php. Can I create a ticket to fix it?

uglyog
2021-06-27 01:52
I've already fixed it :smile:

matt.fellows
2021-06-27 02:11
@uglyog I saw your fix on doc comments. Don?t clean up my mess, I?m happy to update the README and doc comments next week on my OSS day if you like?

uglyog
2021-06-27 02:46
Already done.

uglyog
2021-06-27 02:47
Not the readme, I generally don't do documentation. :wink:

scott.riley111
2021-06-28 14:12
How do folks normally deal with authenticated provider endpoints when using the standalone verifier? As far as I can see I?ve got three options of: ? Load some config that disables this auth when we boot the provider app before running the verifier cli (don?t really like the idea of doing this) ? Do something in the state change endpoint to provide some auth credentials (we?d need to make sure that every interaction did some provider state setup) ? Go back to the ruby standalone verifier and use `custom-provider-header` Have I understood this correctly? (and asked in the right channel :sweat_smile:)

uglyog
2021-06-28 23:28
Normally people are using the verifier from their build, so they have control over the app and can disable the auth (using either of the methods you described).

uglyog
2021-06-28 23:28
But can you raise a github issue so we can get that option added

matt.fellows
2021-06-28 23:40
the `custom-provider-header` option doesn?t allow dynamic values though - is that sufficient?

matt.fellows
2021-06-28 23:41
one option is to use the provider state injected values, and use the state handler to return a valid auth header/token/whatever

scott.riley111
2021-06-29 08:47
ok, cool - thanks this is useful

scott.riley111
2021-06-29 08:47
I was mostly just verifying that I was on the right path

matt.fellows
2021-06-29 08:49
Thanks.

scott.riley111
2021-06-29 08:49
The custom header may work, if it supports multiple values (i.e. we?ve got some endpoints behind jwt auth, and other just behind basic)

scott.riley111
2021-06-29 08:49
we could generate a sort of ?magic jwt? and ?magic user/pass combo? per run or something and load them in in an env var

scott.riley111
2021-06-29 11:56
> one option is to use the provider state injected values, and use the state handler to return a valid auth header/token/whatever I?m not sure I understand how this would work - how would the valid auth header/token/whatever actually get injected into the requests the verifier is making?

matt.fellows
2021-06-29 12:03
there is a feature in v4 that allows a consumer to specify that certain properties/fields/path elements (anywhere a matcher can go) aren?t known at verification time, and are captured in an expression. The state handler is responsible for returning values to inject into the expression. When the verification step runs, it uses the values returned from the state handler, and puts them in the request


scott.riley111
2021-06-29 12:21
ok, cool

scott.riley111
2021-06-29 12:22
one of the first consumers we?re using this with is unfortunately using `pact-ruby` which I think is lagging behind quite a bit

matt.fellows
2021-06-29 12:31
What was your provider again? I forgot why you weren't using a framework to hide this away?

scott.riley111
2021-06-29 12:39
the provider is an old rails app

scott.riley111
2021-06-29 12:39
(i.e. rails 3.2)

matt.fellows
2021-06-29 13:08
What features are you needing from the latest of pact?

scott.riley111
2021-06-29 13:18
Things like the v3 spec?s generators

scott.riley111
2021-06-29 13:19
and the provider value injection

scott.riley111
2021-06-29 17:04
We've ended up with a proxy server that sits in front of the app and injects some auth into the requests the verifier makes, this should work ok for now

tien.xuan.vo
2021-07-04 04:41
I think interaction's description should not be required in this code: > $interaction = $ffi->new_interaction($pact, 'a simple request'); Because later we will set the same value again with: > $ffi->upon_receiving($interaction, 'a simple request (again)');

matt.fellows
2021-07-04 05:00
That's right. There was a technical reason for C++ but for others it doesn't matter

matt.fellows
2021-07-05 00:44
@uglyog as per the single FFI package :point_down:

matt.fellows
2021-07-05 00:51
So the idea I had was to just create a _new_ ffi package, that simply re-exports the useful functions of the other FFIs

matt.fellows
2021-07-05 00:51
That would have the upside of not impacting existing users, but also just means we have more packages

uglyog
2021-07-05 00:52
We should also have a plan to deprecate and remove the other libs

matt.fellows
2021-07-05 00:52
We could do the expand contract - add the new unified ffi, wait for all consumers to get on it, and then remove the old ones?

matt.fellows
2021-07-05 00:57
Side note, how do I build and use the `pact_mock_service_ffi` package locally? It always complains about the `pact_matching_ffi` lib being missing? I recall you mentioning some trick, but can?t find it

uglyog
2021-07-05 01:03
You mean `pact_mock_server_ffi`

uglyog
2021-07-05 01:03
How are you building it?

uglyog
2021-07-05 01:04
Running `cargo build` in that directory works for me

matt.fellows
2021-07-05 01:06
one sec?

matt.fellows
2021-07-05 01:07
the build works, it?s when I use the artifact

matt.fellows
2021-07-05 01:08
```--- ? Running Pact examples go test -v -tags=consumer -count=1 http://github.com/pact-foundation/pact-go/v2/examples/... dyld: Library not loaded: libpact_matching_ffi.dylib Referenced from: /var/folders/3l/vsf3kf6n3yd_p40kwn_1883c0000gn/T/go-build645829403/b001/examples.test Reason: image not found FAIL http://github.com/pact-foundation/pact-go/v2/examples 0.312s ? http://github.com/pact-foundation/pact-go/v2/examples/types [no test files] FAIL make: *** [pact] Error 1```

matt.fellows
2021-07-05 01:08
if I use one downloaded from github releases, it works

matt.fellows
2021-07-05 01:08
So I think it?s something to do with how the artifact is generated. It?s like it doesn?t contain the matching lib, and just refers to it

uglyog
2021-07-05 01:11
My copy does not link to anything else: ```$ ldd target/debug/libpact_mock_server_ffi.so linux-vdso.so.1 (0x00007ffcd57fe000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f2d4e847000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2d4e825000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2d4e6d7000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2d4e6d0000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2d4e4e4000) /lib64/ld-linux-x86-64.so.2 (0x00007f2d4fcd1000)```

uglyog
2021-07-05 01:11
Sorry, I don't have an OSX environment

matt.fellows
2021-07-05 01:12
Yeah, not sure why mine does! ```? pact-go git:(feat/message-metadata) ? otool -L /usr/local/lib/libpact_mock_server_ffi.dylib /usr/local/lib/libpact_mock_server_ffi.dylib: libpact_matching_ffi.dylib (compatibility version 0.0.0, current version 0.0.0) /System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 59306.140.5) /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0) /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1) /usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)```

matt.fellows
2021-07-05 01:12
I?ll dig further

matt.fellows
2021-07-05 01:12
It?ll be a pain to test locally if the unified FFI contains all the others

uglyog
2021-07-05 01:13
Have you upgraded your rust compiler (what version are you running?)

uglyog
2021-07-05 01:19
Maybe I should buy on old refurbished macbook to help diagnose these issues

matt.fellows
2021-07-05 01:31
(i?ll do an update now)

matt.fellows
2021-07-05 01:31
```? native git:(feat/message-metadata) ? rustup -V <aws:pact-prod> rustup 1.24.2 (755e2b07e 2021-05-12) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.53.0 (53cb7b09b 2021-06-17)````

uglyog
2021-07-05 01:33
That is the latest

matt.fellows
2021-07-05 01:33
ah

matt.fellows
2021-07-05 01:34
Rustup is now one micro version newer :wink:


matt.fellows
2021-07-05 04:05
I just spent the last hour mucking about to support an incoming JSON payload that accepts a `pactMessageMetadata` field, and a `pactMessageContents` field, which is represented as a set of `Bytes` (to allow non-JSON payloads).

matt.fellows
2021-07-05 04:06
Doing this seems to be a bad idea, because I?m going to have to make a lot of changes (I thikn) to `http://messages.rs` to know what to do when it receives different content types inside the bytes. It might not be as dramatic as that, but it does feel like double handling of that sort of logic, which I can see is already present further down the line

matt.fellows
2021-07-05 04:06
I?m going to take a lunch break, and that will pretty much be it for the day today (meetings this arvo)

matt.fellows
2021-07-05 04:07
One thought I had, was to not accept an incoming JSON payload, but retrieve metadata via HTTP headers

matt.fellows
2021-07-05 04:07
that would be fairly convenient to do, I think, but I?m not convinced it?s a nice approach

uglyog
2021-07-05 04:08
It would be a bit awkward for users

matt.fellows
2021-07-05 04:08
yeah

matt.fellows
2021-07-05 04:09
The alternative is to make it more awkward for the JSON use case (because you need to write JSON as bytes over the wire)

uglyog
2021-07-05 04:11
Actually, if the headers were prefixed, that might be ok

uglyog
2021-07-05 04:12
So each metadata field has a different header

matt.fellows
2021-07-05 04:12
that?s what I was thinking

uglyog
2021-07-05 04:12
Some people I know of have JSON as metadata values

uglyog
2021-07-05 04:13
They would need to encode it into the header value

matt.fellows
2021-07-05 04:13
specifically, the code in `make_provider_request` is I think where it would need to change. It eventually calls `match_message` which currently accepts the `Message` that needs to be ready to go (so any bytes would need to be decoded back into their correct type, and the content-type correctly parsed etc.)

matt.fellows
2021-07-05 04:13
:grimacing:

matt.fellows
2021-07-05 04:13
gah

matt.fellows
2021-07-05 04:14
so would it be `PACT_MESSAGE_METADATA_<key>=<value>`

matt.fellows
2021-07-05 04:14
k

matt.fellows
2021-07-05 04:14
I?ll give that a go, but probably tonight

uglyog
2021-07-05 04:15
It does have a nice separation between data and metadata.

uglyog
2021-07-05 04:15
Which, I suppose, is what headers actually are

tjones
2021-07-05 04:50
I was assuming that the metadata would largely be provided by the pact framework, and not by the users

tjones
2021-07-05 04:51
As in, users provide the key/values, but ?we? (as in pact-js or whatever) decide how it gets put on the wire

matt.fellows
2021-07-05 04:57
Yeah, that's mostly true

matt.fellows
2021-07-05 04:58
But also the verifier is a CLI tool

matt.fellows
2021-07-05 04:58
So users could build tools around it

matt.fellows
2021-07-05 04:58
But I think it's ok, as long as it's documented how to properly use it

matt.fellows
2021-07-05 05:10
It would be a change in the JS side Tim, but easily enough I think. Thoughts?

tjones
2021-07-05 05:46
What's the change? Using headers instead?

tjones
2021-07-05 05:46
I think that might be the commented bit. I definitely already implemented it, when I was trying to guess at how it might be handled on the rust side

tjones
2021-07-05 05:47
Shall we say: `PACT_MESSAGE_METADATA_<key>=<JSON encoded value>`?

tjones
2021-07-05 05:51
https://stackoverflow.com/a/40347926/790070 ^ We have to be a bit careful with JSON in headers

uglyog
2021-07-05 05:52
I think they should be simple values, and people who want to put JSON in need to encode/decode them themselves

uglyog
2021-07-05 05:53
Actually, now that I recall, it wasn't JSON they were using, but XML :scream:

tjones
2021-07-05 05:53
"simple values" - do you mean strings?

tjones
2021-07-05 05:53
Because without some kind of encoding ,we can't tell the difference between `0` and `"0"`

uglyog
2021-07-05 05:53
Primitives (not collections)

tjones
2021-07-05 05:55
How do we tell the difference between numbers and strings?

tjones
2021-07-05 05:56
Also primitives are different in different languages

tjones
2021-07-05 05:57
If we're expecting the consumer to handle serialisation, can we say "strings" and leave the implementation up to the user?

tjones
2021-07-05 05:57
(also, it's not quite "strings", because the headers have some restrictions)

matt.fellows
2021-07-05 06:11
Metadata is represented as a hashmap of string -> string anyway

matt.fellows
2021-07-05 06:11
> If we?re expecting the consumer to handle serialisation, can we say ?strings? and leave the implementation up to the user? That?s what I think we should do. I actually think it?s what it currently assumes also

uglyog
2021-07-05 06:26
Pact-JVM had to change that from string -> string to string -> any

uglyog
2021-07-05 06:26
We should do the same here


uglyog
2021-07-05 06:29
> This is a problem when integrating with messaging frameworks that also provide metadata with raw Object values instead of String (like IMessage of azure servicebus in my case) because you can't translate the pact Message to such a message representation then (at least not with hard workarounds.)

matt.fellows
2021-07-05 06:34
Chris. Then a header value per metadata key/value pair is not going to work, because headers are string values

uglyog
2021-07-05 06:37
I think JSON values will work (that way they retain the types). I looked at azure servicebus IMessage, and most of it is things like destination channel and correlation ids. But there are lock types and sessions as well.

uglyog
2021-07-05 06:38
99% will just be string values (like destination queue) and correlation IDs (numbers and UUIDs)

matt.fellows
2021-07-05 06:55
Sorry, was on a call Ron

matt.fellows
2021-07-05 06:56
So if each key had its own header, I don?t think that would would work, because a `0` would be represented as a `"0"`

uglyog
2021-07-05 06:56
I always thought you were a call girl, err, I mean guy

matt.fellows
2021-07-05 06:56
but if we smashed all of the metadata into a sinlgle header, then we could represent it as JSON

uglyog
2021-07-05 06:57
No, each key is a separate header, and the value is a JSON value

matt.fellows
2021-07-05 06:57
ah so then `PACT_MESSAGE_METADATA_FOO=0` = number `PACT_MESSAGE_METADATA_FOO="0"` = string?

matt.fellows
2021-07-05 06:57
k

uglyog
2021-07-05 06:58
We need the types if people are using type matchers

matt.fellows
2021-07-05 06:59
How do we do that? Do we need to encode something else into the value?

uglyog
2021-07-05 07:01
The JSON values have types


matt.fellows
2021-07-05 07:01
> The JSON values have types are you referring to the Rust side here or just commenting that if we properly encode the values the types will be correct?

uglyog
2021-07-05 07:02
When you parse a value as JSON, you get a typed value

uglyog
2021-07-05 07:02
`PACT_MESSAGE_METADATA_FOO=false` is a boolean

matt.fellows
2021-07-05 07:03
```pub struct MessagePact { /// Consumer side of the pact pub consumer: Consumer, /// Provider side of the pact pub provider: Provider, /// List of messages between the consumer and provider. pub messages: Vec<message::Message>, /// Metadata associated with this pact file. pub metadata: BTreeMap<String, BTreeMap<String, String>>, /// Specification version of this pact pub specification_version: PactSpecification, }``` Just so I?m clear, would we be changing `metadata` to be a `BTreeMap<String, BTreeMap<String, Value>>` ?

matt.fellows
2021-07-05 07:03
i.e. using the json `Value` type instead of a String?

matt.fellows
2021-07-05 07:04
Actually, I might make this two PRs

matt.fellows
2021-07-05 07:04
Step one - extract the headers into the current implementation of pure strings

matt.fellows
2021-07-05 07:04
step 2, refactor to allow richer objects

uglyog
2021-07-05 07:07
That sounds like a sensible plan

uglyog
2021-07-05 07:07
Before the night is out, you'll probably have 3 PRs

uglyog
2021-07-05 07:08
Maybe 4

uglyog
2021-07-05 07:08
Actually, I think `BTreeMap<String, Value>`

uglyog
2021-07-05 07:09
You're confusing the Pact metadata with the message metadata :smile:

matt.fellows
2021-07-05 07:09
Yes, I just realised the same thing

uglyog
2021-07-05 07:10
You could just use a `HashMap`, because order is not important

matt.fellows
2021-07-05 07:10
> Before the night is out, you?ll probably have 3 PRs When I?m in unfamiliar territory, I prefer to try and get an idea in front of others before going too far, so that I can get feedback on the general approach

matt.fellows
2021-07-05 07:10
hope it?s OK

matt.fellows
2021-07-05 07:10
I?ve appreciated the quick response on the last few (you too @tjones!)

uglyog
2021-07-05 07:11
That's the problem, 3 people's opinions -> 4 PRs

uglyog
2021-07-05 07:21
Checked the V4 model, and it already is the correct type ``` /// Metadata associated with this message. pub metadata: HashMap<String, Value>,```

tjones
2021-07-05 07:31
You have to be careful with json in headers because JSON lets you have characters you can?t have in headers. There?s a discussion and a JS workaround in the stackoverflow issue I linked

tjones
2021-07-05 07:31
headers are largely arbitrary otherwise - there?s no length requirement, and most http implementations will accept up to 8k of headers (!)

tjones
2021-07-05 07:32
I like the ?encode as JSON? approach. But we should put a warning for implementers in the spec, because `removeNewlines(JSON.stringify(foo))` is not enough.

matt.fellows
2021-07-05 07:39
base64 encoded is probably a better approach


matt.fellows
2021-07-05 08:03
I think it?s also gonig to have to be a single header. The reason is that I don?t think we?ll be able to reliably deal with strange keys (e.g. if there is a space, or hyphen)

matt.fellows
2021-07-05 08:03
(I?ll think later when back in front of laptop)

matt.fellows
2021-07-05 08:04
also I think it will mess with case

tjones
2021-07-05 11:37
We could also restrict the keys

tjones
2021-07-05 11:38
but a single header probably makes more sense

matt.fellows
2021-07-05 11:51
I think it?s easier anyway

matt.fellows
2021-07-05 22:29
FYI I made some progress on the ?support complex values? in the metadata. Tested in go

matt.fellows
2021-07-05 22:29
I need to fix the compilation in the matching_ffi package, but it works

talank
2021-07-06 03:55
has joined #pact-rust

swoichhaa
2021-07-07 11:06
has joined #pact-rust

tien.xuan.vo
2021-07-09 17:09
If header have multiple values we have to use `index` in `with_header` https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_mock_server_ffi/src/lib.rs#L775 ? I did google and I think that multiple-value header can be present by a string with comma-separated https://stackoverflow.com/questions/32667075/multiple-values-on-http-headers, so I think `index` is not needed. Is that right?

matt.fellows
2021-07-09 23:29
Rust represents it internally differently though, I think for matching purposes. @uglyog care to elaborate?

uglyog
2021-07-10 03:06
While using a comma-separated string may work (the headers will be generated in that form), there are some cases where it may not work. For instance, if using a matcher, the matcher will be applied to the whole string.

uglyog
2021-07-10 03:08
We can update it to detect a comma-separated string, but there are cases where that can cause problems. It kind of has to be done on a header by header basis. For instance, headers with date values have a comma separating the day from the month part.

github2
2021-07-11 06:47
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.0.5_ published by uglyog

github2
2021-07-11 06:56
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.9.4_ published by uglyog

github2
2021-07-11 07:04
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching_ffi-v0.0.5_ published by uglyog

github2
2021-07-11 07:11
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server-v0.7.19_ published by uglyog

github2
2021-07-11 07:18
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server_ffi-v0.1.1_ published by uglyog

github2
2021-07-11 07:31
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.9_ published by uglyog

github2
2021-07-11 07:36
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_ffi-v0.0.6_ published by uglyog

github2
2021-07-11 07:49
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.0.0_ published by uglyog

tien.xuan.vo
2021-07-11 08:47
How to set metadata for message? I got this error: > Expected message metadata 'routing_key' to have value 'And the clowns have all gone to bed' but was '' This code return the message https://github.com/pact-foundation/pact-reference/blob/master/php/src/provider-proxy.php#L30, but I don't know how to modify it to fix the error.

matt.fellows
2021-07-11 09:19
Can you please show the pact that was generated?


matt.fellows
2021-07-11 09:20
Metadata is not part of the message itself, it needs to be sent back

tien.xuan.vo
2021-07-11 09:20
But I changed `version` to `3.0.0`

matt.fellows
2021-07-11 09:21
Yep


tien.xuan.vo
2021-07-11 09:23
Thanks, I will check

matt.fellows
2021-07-11 09:23
:+1:

tien.xuan.vo
2021-07-11 09:38
This is an issue I got when using new `Pact FFI Library 0.0.0` > FFI\ParserException: ';' expected, got '<STRING>' at line 275

matt.fellows
2021-07-11 10:08
I haven't used the new all in one FFI interface yet but if you can tell us what you're doing / provide more input that might help

matt.fellows
2021-07-11 10:08
Otherwise I'll be able to test Pact Go this week sometime myself

tien.xuan.vo
2021-07-11 14:22
I think it come from `pact.h` , around these lines: ```#ifdef __cplusplus extern "C" { #endif // __cplusplus``` I think we need to generate a file `pact-c.h` like other FFI libraries

tien.xuan.vo
2021-07-11 14:37
Another thing I saw is every methods starting with `pactffi_*` , not sure it's needed

tien.xuan.vo
2021-07-11 14:47
Not sure why body's type changed from `char` to `uint8_t` ```void pactffi_message_with_contents(struct MessageHandle message, const char *content_type, const uint8_t *body, size_t size);```

tien.xuan.vo
2021-07-11 15:14
I think `pact_message_metadata` is causing problem. Slim framework (PHP) normalize header name into `pact-message-metadata` . I tested by rename in `http://message.rs` and it works. Do we consider rename it?

uglyog
2021-07-11 22:44
These were requested by @tjones

tjones
2021-07-11 22:45
It?s just a convention for ensuring that there?s no collision with other C libs.

uglyog
2021-07-11 22:45
It was requested to only have 1 header file. It needs those ifdefs to be usable in C++

uglyog
2021-07-11 22:46
This is to support binary payloads

matt.fellows
2021-07-12 00:56
In the other libraries, we don?t bother using the header files. I don?t know about PHP, but we can simply define the bits we need

matt.fellows
2021-07-12 00:56
Yep. So that tells me you probably havn?t supported binary payloads in the HTTP mock service (that?s fine, but just take note)

tien.xuan.vo
2021-07-12 01:48
Maybe separate into 2 functions: ? pactffi_message_with_contents ? pactffi_message_with_binary_contents What do you think?

tien.xuan.vo
2021-07-12 01:49
Sadly PHP only support c's header, not cpp https://www.php.net/manual/en/ffi.cdef.php

matt.fellows
2021-07-12 01:51
We don?t need both though - whether you?re sending JSON or binary, it just needs to be given an array of bytes

uglyog
2021-07-12 01:54
Oh, we will have to go back to two separate header files then.

uglyog
2021-07-12 01:55
In the short term, just comment out those lines

matt.fellows
2021-07-12 01:55
How are you defining the FFI interface Tien? In Go and JS, I can just define the functions and types I need locally

matt.fellows
2021-07-12 01:56
but it probably is best there is an up-to-date c interface - does the c bindgen give that to us for free Ron?

tien.xuan.vo
2021-07-12 01:56
I download it, both header and library files

uglyog
2021-07-12 01:56
So, before we generated two headers, one for C and one for C++

matt.fellows
2021-07-12 01:56
Also Tien - does @cfmack know you?re doing this? Might be worthing looping him in, or getting access to be able to submit PRs off the main branch? There is probably a lot of work goinsg on here, so ideally the maintainer is across it

cfmack
2021-07-12 01:56
has joined #pact-rust

uglyog
2021-07-12 01:57
But there was a discussion to only have one header (@tjones may have been in that)

uglyog
2021-07-12 01:57
Might also have been on the .Net channel

uglyog
2021-07-12 01:58
For a single header to work with C++, the C functions have to be wrapped in `extern "C" {`

tien.xuan.vo
2021-07-12 02:13
@matt.fellows no he doesn't know, I didn't submit any code yet

matt.fellows
2021-07-12 02:14
I reckon it?s worth the two of you having a chat (even just async in #pact-php or something) to try and get aligned. The work you?re doing is great, and it would be a shame if there are barriers to getting it into the main repo - so any coaching/guidance you can get now will probably save you later!

tjones
2021-07-12 02:15
I don't know about only one header. Having the C headers only feels like it makes sense to me, but there may be a reason it's good to have two. If we only have one, it'd be better to only have C rather than C++

tjones
2021-07-12 02:19
Shouldn't it be `char*`?

tjones
2021-07-12 02:20
`uint8_t*` is only probably a byte, whereas `char*` is guaranteed to be. Although, I don't think it actually matters, because we'll have 8 bit bytes on everything we're likely to be running on.

uglyog
2021-07-12 02:22
It really makes no difference, you'll have to caste one way or another. This is more an indication that it takes bytes, not characters.

tjones
2021-07-12 02:23
Fair enough :+1:

tien.xuan.vo
2021-07-13 01:09
what do you think about this?

matt.fellows
2021-07-13 01:12
In retrospect, I have no idea why I went with underscores.

matt.fellows
2021-07-13 01:14
I don?t think any language has currently implemented `_` so we could definitely change it

matt.fellows
2021-07-13 01:14
@uglyog care to weigh in?

uglyog
2021-07-13 01:17
No, fine with me. Other headers use dashes

matt.fellows
2021-07-13 01:17
exactly, NFI what I was thinking

matt.fellows
2021-07-13 01:33
I?ve just made the small change to support this, but a new release will be required before it?s in the wild. For now, you can pull down the changes locally Tien to validate

tien.xuan.vo
2021-07-13 01:39
Will do. Thanks

tien.xuan.vo
2021-07-13 01:46
It works. I can't wait for the next release

tomknee1
2021-07-15 08:43
has joined #pact-rust

github2
2021-07-21 03:42
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier_cli-v0.8.6_ published by uglyog

github2
2021-07-21 05:52
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_mock_server_cli-v0.7.5_ published by uglyog

github2
2021-07-23 01:03
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_consumer-v0.7.7_ published by uglyog

github2
2021-07-23 03:59
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.1.0_ published by uglyog

github2
2021-07-23 04:19
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.10.0_ published by uglyog

tien.xuan.vo
2021-08-04 04:42
I wonder do you forget to release new version of `Pact FFI Library 0.0.1` ?

uglyog
2021-08-04 04:50
No, there is not any major changes since `0.0.0`. Are you looking for something in particular?

tien.xuan.vo
2021-08-04 04:54
I'm impatiently waiting for 2 changes to be released: ? Separate `pact.h` and `pact-c.h` ? Change header `PACT_MESSAGE_METADATA` to `PACT-MESSAGE-METADATA`

uglyog
2021-08-04 05:03
Ok, the second one is in the changes, but we haven't created the two headers in the build yet

uglyog
2021-08-04 05:03
So releasing it now only has the `PACT_MESSAGE_METADATA` change

tien.xuan.vo
2021-08-04 05:05
I am waiting for both, so no worry, I will wait more

pedroefajardo_pactio
2021-08-09 04:21
has joined #pact-rust

pedroefajardo_pactio
2021-08-09 04:26
Had a convo with @matt.fellows in another channel Looking pointers to get started with the end goal of implementing Pact consumer framework, shooting for spec v.3, in Elixir via FFI to Rust.

marko.justinek
2021-08-09 04:38
great! How do you import libraries into Elixir? With Rust, you?d `cargo build` the `libpact_ffi` code. That would generate a framework for you (either, .so, .dll, .a, .dlyb?). How would you pull that kind of framework file into your Elixir code/project/framework?

uglyog
2021-08-09 04:39
There are some examples calling the FFI libs form other languages: https://github.com/pact-foundation/pact-reference#other-languages

marko.justinek
2021-08-09 04:42
I?ve left my future-self some notes here too https://gist.github.com/surpher/bbf88e191e9d1f01ab2e2bbb85f9b528

matt.fellows
2021-08-09 05:40
For some implementation guidance, we?ve been using GH projects to track the high level tasks. Examples: Go: https://github.com/pact-foundation/pact-go/projects/2 JS: https://github.com/pact-foundation/pact-js/projects/3 Pact Go: internal FFI bindings here https://github.com/pact-foundation/pact-go/blob/2.x.x/internal/native/mockserver/mock_server.go and an example of it running https://github.com/pact-foundation/pact-go/blob/2.x.x/internal/native/mockserver/mock_server_test.go#L125-L162. This is internal framework, but you can see how it works. Pact .NET is also in a decent state for inspiration: https://github.com/pact-foundation/pact-net/tree/feature/4.0.0


andrew.jensen
2021-08-12 16:15
has joined #pact-rust

andrew.jensen
2021-08-12 18:36
Hey @marko.justinek, I?ve been looking into Elixir bindings along with @pedroefajardo_pactio. As far as I?m aware, there are two ways to do FFI in Elixir that apply here. There?s the lower-level approach from Erlang (called NIFs), and a Rust-specific abstraction called https://github.com/rusterlium/rustler, which will execute `cargo build` with the right arguments and hide the complexity there. I?ve started a project with Elixir bindings (see #pact-elixir for details) and I?m trying to get Rustler configured, but I?ve had poor luck so far. I couldn?t get Rustler?s compilation to work, so I set it to just use a pre-built library file that I copied out of the `target` directory. But now I?m seeing errors that suggest that the file isn?t compiled with the right flags/configuration: ```$ mix run_mock_server # ... 12:28:46.949 [warn] The on_load function for module Elixir.Pact returned: {:error, {:bad_lib, 'Failed to find library init function: \'dlsym(0x7f85dd604160, _nif_init): symbol not found\''}}``` So at this point I?m thinking of going back through your gist (thanks, by the way!) and maybe dropping down to raw NIFs.

andrew.jensen
2021-08-12 20:00
Aha, looks like I misunderstood something foundational about NIFs - they require instrumentation on the Rust/C/C++ side so they play nicely with the BEAM. Here?s an article that talks about https://andrealeopardi.com/posts/using-c-from-elixir-with-nifs/, and it starts by importing a header on the C side: ```#include "erl_nif.h" ``` So I think I?ll need to create a Rust shim within the Elixir project and have that depend on the library internally.

ben.kaiser
2021-08-13 18:25
has joined #pact-rust

ben.kaiser
2021-08-13 18:30
Hi all. I have just picked up and started using the Rust pact_verifier_cli and am running into an issue. I'm attempting to use the pact_verifier_cli to verify all pacts with a certain tag ```pact_verifier_cli ... --consumer-version-selectors="{\"tag\": \"prodlkjasdlfjlsajkdf\",\"latest\": false}"``` However it appears this flag is getting ignored and the same pact is verified no matter what data I pass. I'm not sure if I'm misusing this flag or formatting the value incorrectly or if there is a product bug. Any pointers? I also just posed this same question on stack overflow before seeing this slack channel... https://stackoverflow.com/questions/68776438/pact-verifier-cli-not-honoring-consumer-version-selectors

ben.kaiser
2021-08-13 19:06
Or is this better to file on GitHub?

matt.fellows
2021-08-13 23:52
Can you please set loglevel to verbose?


ben.kaiser
2021-08-16 12:16
I did see the history on the repo and saw more selector facets were coming in the next release - cool stuff. Or are you saying the `--consumer-version-selectors` is not available in the current release? Even with this trace log level I do not get the same output - I don?t see that same `Sending JSON...` DEBUG message (https://github.com/pact-foundation/pact-reference/blame/8d6ea58bf525e7ec23824d155551e24daccc5744/rust/pact_verifier/src/pact_broker.rs#L408) - are we using the same version? ```$ pact_verifier_cli --version pact_verifier_cli 0.8.6 pact verifier version : v0.8.6 pact specification version: v3.0.0```

matt.fellows
2021-08-16 12:18
I tested with the exact same version (i.e. the current, as of today)

matt.fellows
2021-08-16 12:18
what does a `--loglevel trace` look like?

ben.kaiser
2021-08-16 12:21
```12:18:39 [DEBUG] (1) pact_verifier::pact_broker: Link URL is templated 12:18:39 [DEBUG] (1) pact_verifier::pact_broker: templated URL = https://pact-broker.eng.internal.com/pacts/provider/{provider}/latest 12:18:39 [DEBUG] (1) pact_verifier::pact_broker: Looking up value for key 'provider' 12:18:39 [DEBUG] (1) pact_verifier::pact_broker: final URL = https://pact-broker.eng.internal.com/pacts/provider/KVP/latest 12:18:39 [INFO] Fetching path '/pacts/provider/KVP/latest' from pact broker 12:18:40 [DEBUG] (1) reqwest::async_impl::client: response '200 OK' for https://pact-broker.eng.internal.com/pacts/provider/KVP/latest 12:18:40 [TRACE] (5) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [TRACE] (5) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:355] signal found waiting giver, notifying 12:18:40 [TRACE] (1) pact_verifier::pact_broker: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier-0.10.9/src/pact_broker.rs:480] with_retries: attempt 2/3 is Ok(Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("http://pact-broker.eng.internal.com")), port: None, path: "/pacts/provider/KVP/latest", query: None, fragment: None }, status: 200, headers: {"content-type": "application/hal+json;charset=utf-8", "date": "Mon, 16 Aug 2021 12:18:40 GMT", "strict-transport-security": "max-age=15724800; includeSubDomains", "vary": "Accept", "x-content-type-options": "nosniff", "x-pact-broker-version": "2.76.0", "content-length": "924", "connection": "keep-alive"} }) 12:18:40 [TRACE] (5) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [TRACE] (5) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:200] poll_want: taker wants! 12:18:40 [TRACE] (5) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [INFO] Fetching path '/pacts/provider/KVP/consumer/AE/version/635fa55deedbc8410aeff25fcea58d6c5d9ccc30' from pact broker 12:18:40 [DEBUG] (1) reqwest::async_impl::client: response '200 OK' for https://pact-broker.eng.internal.com/pacts/provider/KVP/consumer/AE/version/635fa55deedbc8410aeff25fcea58d6c5d9ccc30 12:18:40 [TRACE] (1) pact_verifier::pact_broker: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier-0.10.9/src/pact_broker.rs:480] with_retries: attempt 2/3 is Ok(Response { url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("http://pact-broker.eng.internal.com")), port: None, path: "/pacts/provider/KVP/consumer/AE/version/635fa55deedbc8410aeff25fcea58d6c5d9ccc30", query: None, fragment: None }, status: 200, headers: {"content-type": "application/hal+json;charset=utf-8", "date": "Mon, 16 Aug 2021 12:18:40 GMT", "strict-transport-security": "max-age=15724800; includeSubDomains", "vary": "Accept", "x-content-type-options": "nosniff", "x-pact-broker-version": "2.76.0", "content-length": "41720", "connection": "keep-alive"} }) 12:18:40 [TRACE] (11) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [TRACE] (11) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:355] signal found waiting giver, notifying 12:18:40 [TRACE] (11) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [TRACE] (11) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:200] poll_want: taker wants! 12:18:40 [TRACE] (11) want: [/Users/ben.kaiser/.cargo/registry/src/github.com-1ecc6299db9ec823/want-0.3.0/src/lib.rs:341] signal: Want 12:18:40 [DEBUG] (1) pact_verifier: Got pact with links [Link { name: "curies", href: None, templated: false, title```

matt.fellows
2021-08-16 12:22
is there more?

ben.kaiser
2021-08-16 12:24
i mean there are about 11k lines

matt.fellows
2021-08-16 12:24
any chance of a gist or a private DM?

matt.fellows
2021-08-16 12:25
it says it found a Pact, so just wondering what the problem is

ben.kaiser
2021-08-16 13:31
The issue is that the requests to the broker don?t appear to be passing the ConsumerVersionSelectors at all. I do not see the DEBUG statement `Sending JSON` as in your response to the StackOverflow. In hopes that the cargo library was incorrect I have also installed from Github but the output appears to be the same.

matt.fellows
2021-08-16 13:53
final update - BUG!

matt.fellows
2021-08-16 13:53
issue coming soon

ben.kaiser
2021-08-16 14:00
Thanks for the troubleshooting help Matt! https://github.com/pact-foundation/pact-reference/issues/133

github2
2021-08-17 00:16
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_models-v0.1.1_ published by uglyog

github2
2021-08-17 00:27
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_matching-v0.10.1_ published by uglyog

github2
2021-08-17 00:39
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_mock_server-v0.7.20_ published by uglyog

github2
2021-08-17 00:50
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/pact_verifier-v0.10.10_ published by uglyog

github2
2021-08-17 01:03
[pact-foundation/pact-reference] New release _https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.0.1_ published by uglyog

tjones
2021-08-18 01:29
@tien.xuan.vo: 0.0.1 is now released :tada:

tjones
2021-08-18 01:38
Some lessons from pact-js - we found it easiest to use the closest-to-c bindings we could (using node-ffi), rather than using the rust-specific bindings (which we got from neon). This was because the rust-specific bindings were less feature complete when it came to differences between the way each side handles asynchronous behaviour. Also, pragmatically the C bindings are more widely used (because they're not just for rust). Your mileage may vary

tien.xuan.vo
2021-08-18 01:59
Yay! :v:

tien.xuan.vo
2021-08-19 05:30
Maybe you forget to upload `pact-cpp.h` to the release?

tien.xuan.vo
2021-08-19 05:32
Running these commands: ```cd pact_ffi rustup run nightly cbindgen \ --config cbindgen.toml \ --crate pact_ffi \ --output include/pact.h``` I got this error:

tien.xuan.vo
2021-08-19 05:34
```ERROR: Parsing crate `pact_ffi`: couldn't run `cargo rustc --pretty=expanded`: Compile(" reference/rust/target/debug/build/ring-38bf9793e960dc3f/out` (exit status: 1)\n") ERROR: Couldn't generate bindings for /home/tien/Projects/pact-reference/rust/pact_ffi.```

tien.xuan.vo
2021-08-19 05:34
The message is too long I can't post here, it's just part of it

uglyog
2021-08-19 05:46
I thought you couldn't use that one? `pact.h` does not have any C++ preprocessor definitions

tien.xuan.vo
2021-08-19 05:56
yes, I don't use that one. Just wanna make sure it's not a mistake

tien.xuan.vo
2021-08-19 07:57
I think this is the error: `error: Unrecognized option: 'pretty'\n\nerror: could not compile `pact_ffi`\n\nCaused by:\n process didn't exit successfully: `rustc --crate-name pact_ffi --edition=2018 pact_ffi/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type cdylib --crate-type staticlib --crate-type rlib --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -Z unstable-options --pretty=expanded -C metadata=e2d01246786ccf59 -C extra-filename=-e2d01246786ccf59 --out-dir /home/tien/Projects/pact-reference/rust/target/debug/deps`

tien.xuan.vo
2021-08-19 07:57
Do you know why and how can I fix it?


mike.geeves064
2021-08-19 13:58
has joined #pact-rust

pedroefajardo_pactio
2021-08-20 16:12
hello everyone, At work we are working to implement an Elixir (wrapper?) for the Pact provider verification making calls into the Rust (core) implementation Looking for which specific functions to bind to in order to implement our wrapper. Pact-js apparently has a beta branch that already does this, does anyone know which branch that is? I am looking at https://github.com/pact-foundation/pact-js/tree/feat/ffi-core but I am not 100% sure that?s the one

andrew.jensen
2021-08-20 18:20
:hand: Interested in this as well!

pedroefajardo_pactio
2021-08-20 19:00
i meant the Pact Consumer flow but i?ve been told it is easier to start with the verification part. So, looking for info on both

marko.justinek
2021-08-20 23:00
PactSwift is using pactffi for consumer side in PactSwiftMockServer package. https://github.com/surpher/PacSwiftMockServer Sources/MockServer.swift setup, verify, finalize are the required ones for mvp

pedroefajardo_pactio
2021-08-21 00:00
thank you @marko.justinek

marko.justinek
2021-08-21 00:20
eh, only now found the link is bogus? (was typing on my mobile), here?s the permalink to the file: https://github.com/surpher/PactSwiftMockServer/blob/0a8c00bbe5fd8019ffe40cfd0618e02e1cd72a4d/Sources/MockServer.swift

marko.justinek
2021-08-21 00:25
```pactffi_create_mock_server(...) pactffi_mock_server_matched(...) pactffi_mock_server_mismatches(...) pactffi_write_pact_file(...) pactffi_cleanup_mock_server(...)``` This is the header file for the pactffi binary and what PactSwiftMockServer is using: https://github.com/surpher/PactSwiftMockServer/blob/0a8c00bbe5fd8019ffe40cfd0618e02e1cd72a4d/Sources/pact_ffi.h

marko.justinek
2021-08-21 00:29
What you use (from pactffi interface) will depend on how elixir runs your tests. I started writing PactSwift just before gradual pact build up was exposed and possible using pact_mock_server_ffi (now pactffi). PactSwift parses and generates the Pact structure as a whole and it is then passed to pactffi. XCTest also destroys my MockService instance for each and every unit test it runs so I needed a way to hold on to all the interactions (one for each unit test), and only then tell pactffi to write the contract into a file with all the interactions that were tested. You may be able to start the mock server and pass it interactions?

matt.fellows
2021-08-21 01:33
I wouldn't use JS as basis yet, take a look at https://github.com/pact-foundation/pact-go/tree/2.x.x/internal/native


matt.fellows
2021-08-21 01:35
Definitely provider side is easier first

matt.fellows
2021-08-21 01:35
Takes newline separated arguments that the CLI takes

pedroefajardo_pactio
2021-08-21 01:35
thanks @matt.fellows

marko.justinek
2021-08-21 05:47
The most basic MVP for provider verification using pactffi has just succeeded on PactSwift where pacts from local directory are used to verify a provider: ? PactSwiftMockServer package that does the actual pactffi call -> https://github.com/surpher/PactSwiftMockServer/blob/4c7982bc2d65f219573d4a89e66bb98e13ccbfdc/Sources/Verifier.swift ? To be on safe side `VerificationOptions` type is used so end users are limited to how many crazy things they can do: https://github.com/surpher/PactSwiftMockServer/blob/4c7982bc2d65f219573d4a89e66bb98e13ccbfdc/Sources/Model/VerificationOptions.swift ? PactSwift interface to end users -> https://github.com/surpher/PactSwift/blob/e76187e994e4725f2cf58fbca9b0a8d81317df0e/Sources/ProviderVerifier.swift The ?ho?up a minute? moment I had was where each of the arguments that are passed to `pactffi_verify(args: string)` needed to be on its own line! Not the key-value pair, but each word. I had key-value pairs but pactffi_verify was returning an error saying I passed invalid arguments. So what https://github.com/surpher/PactSwiftMockServer/blob/4c7982bc2d65f219573d4a89e66bb98e13ccbfdc/Sources/Model/VerificationOptions.swift#L88 is replacing all spaces with `\n`. (will need revisiting and optimising once `Verifier` gets more options etc). Hope that?ll help with understanding and planning your Elixir architecture better. :thumbsup: Here?s a verified Swift (on macOS) provider running on Vapor 4:

matt.fellows
2021-08-21 06:02
Might makes sense for this whole community of FFI integrators getting together to discuss experience, share learnings and see how we can improve (e.g. docs)

matt.fellows
2021-08-21 06:03
What do we think?

mike.geeves064
2021-08-21 09:24
That sounds like a good idea to me :slightly_smiling_face: (I'm having a very-first-steps look at the python wrapper) imo, consistency between the different implementations would be beneficial, but I'm not sure how practical that would be for different languages (error handling for example)?

mike.geeves064
2021-08-21 09:30
There are a few approach/best practice type questions I'm wondering about, such as around how tightly coupled they are and possible future proofing. For example with the error handling (I'm not sure how likely it would be, but just as an example), each implementation is having some response and error message as a result of a non-zero return code. That is susceptible to change which could be easily missed in a new version. Would that sort of thing make sense to have say another FFI call to a function providing a map of error codes and meanings for the crate's method, rather than each implementation needing to be maintained?

mike.geeves064
2021-08-21 09:33
I was thinking about that from the args example as well, if it could make sense to have an FFI call that lists the valid options, but I can't think how you could do that without losing the possibility of any nice typing :thinking_face:

tien.xuan.vo
2021-08-21 10:05
> ./pact_verifier_cli --help > > --build-url <build-url> > URL of the build to associate with the published verification results. Can you explain a bit about this option?

mike.geeves064
2021-08-21 10:44
Hi, I'm trying to take a look at the log output produced by the pact_ffi crate, specifically the verifier currently (this is for the python implementation). If I call pactffi_log_to_buffer() once it works fine, but if it is called again (this is after loading the lib again in another test) it comes back with a -1 - however it still seems to carry on logging to the buffer. I'm also getting some weirdness whereby the output comes back fine if running in debug but not running normally :thinking_face: ? should you be able to request logging to a buffer again? I can't see how to "stop" logging (calling to log to a file works ok) ? any way to flush/sync/etc to make sure the response is ready? (although I'm not sure if it's timing, adding a crude sleep doesn't help) As per other threads, I haven't seen log handling in the other ffi implementations so not sure preferred approach here (possible I've missed it somewhere), doing the same thing is probably preferable :slightly_smiling_face:

matt.fellows
2021-08-21 10:45
There's definitely a few quirks to work out

matt.fellows
2021-08-21 10:46
But now you can't call it twice. The method is clearly documented that way, but you're probably not reading that so wouldn't know!

matt.fellows
2021-08-21 10:46
I'd recommend having the rust code open so you can read the method signatures

matt.fellows
2021-08-21 10:47
Even if you don't speak rust, they should be legible

matt.fellows
2021-08-21 10:47
Also I don't think the logging methods do much on the provider side, albeit I haven't tested the new methods since they were added (they do work on the consumer side)

mike.geeves064
2021-08-21 10:49
I saw you can't call apply twice, which the log to buffer wraps up

mike.geeves064
2021-08-21 10:50
wasn't sure if there's a way around it :thinking_face:

mike.geeves064
2021-08-21 10:57
My description, wasn't very clear - the idea was that it should be separate anyway rather than intending to call it twice, a test will: 1. load lib, 2. make ffi call. The problem happens when a second test is trying to do that, I was hoping it would be closed enough to not have overlap but it seems it's still there to some extent I don't know enough about CFFI to undersand :thinking_face: Anyway, for now I'll look at the file option I think - the non FFI tests check some stdout, I'm looking at mirroring them at least to some extent

mike.geeves064
2021-08-21 12:59
What about for log levels? As far as I can see, there's no way to change the level once the logger is set initially (I'm probably focusing too much on the lower value things here, but I like to get a bit of an understanding of my surroundings before going too far). Example use case, I'd like to make sure I can control the log level when calling the lib since TRACE logs can get a bit long. I can set it, but only once (this again may be a python CFFI "issue" of me not being able to re-load the library and start again in a second test - so I've currently ended up with a bit of a singleton class which I don't really like :disappointed:)

mike.geeves064
2021-08-21 14:11
Re "Looking for which specific functions to bind to in order to implement our wrapper", for me as well it could be helpful to have some "compliance" style compatibility matrix, although idk if that would be overkill?

uglyog
2021-08-21 23:56
Unfortunately, you can't change the log level, or I haven't found a way yet. I would recommend using debug level, not trace.

uglyog
2021-08-21 23:57
This is to capture the URL of the CI build that is running the verification

uglyog
2021-08-22 05:03
@matt.fellows @mike.geeves064 @marko.justinek I've created an initial verifier FFI prototype. You can see it being using from C here: https://github.com/pact-foundation/pact-reference/blob/master/c/provider-verifcation/src/main.c#L9

uglyog
2021-08-22 05:05
Using a handle approach means we can accumulate log entries against the handle and then provide a function to retrieve them.

uglyog
2021-08-22 05:54
@mike.geeves064 @matt.fellows all the docs are available at https://docs.rs/pact_ffi/0.0.2/pact_ffi/

mike.geeves064
2021-08-22 08:26
Thanks, I'd found along with trying to understand the src in places. Ahhhh pointers! :open_mouth:

matt.fellows
2021-08-22 08:27
Nice!

matt.fellows
2021-08-22 08:28
Cc also @pact544 @yann.courtel @matt682 @tien.xuan.vo

mike.geeves064
2021-08-22 08:33
:+1: trace wasn't intentional, that came out when not specifying anything else. I'll go on the basis of not changing, don't "need" to just wondering for completeness

pact544
2021-08-22 09:07
Very nice :+1:

tien.xuan.vo
2021-08-22 10:14
It will replace this code, right? > pactffi_verify(<parameters for Pact Verifier CLI>);

mike.geeves064
2021-08-22 10:19
Apologies for essentially a rust noob question, I am just trying to play with an idea to then be able to pull something back via ffi into python, but I'm finding it far harder than expected to get a basic function working that returns a string that can be manipulated. The goal was a quick and dirty just return some JSON back as a str that could be used on the other side (I wanted to try and inspect the contents of the clap app.p.opts, for example). I've tried the following permutations of can I get anything to send back that isn't an str, but seem to have fundamentally not understood something (I remember when Java was new, I was very happy at not having to worry about pointers :smile: ). If there's a one line "you just do this" or "go read this", a pointer (ha!) would be appreciated. If it's a much more complicated "first you need to learn rust properly" I'll need to skip for now. > #[no_mangle] > pub extern "C" fn pactffi_verifier_cli_args() -> *const c_char { > let normal_str = "hello world\0"; > let string_with_a_big_s = "hello world\0".to_owned(); > let mut mut_string_with_a_big_s = "hello world\0".to_owned(); > let c_string = CString::new("hello world").unwrap(); > let c_string_to_bytes = http://c_string.as_bytes(); > let c_string_as_c_str = http://c_string.as_c_str(); > let c_string_as_c_str_to_str = http://c_string_as_c_str.to_str().unwrap(); > let c_str = CStr::from_bytes_with_nul(b"hello world c_str\0"); > > http://normal_str.as_ptr() as *const c_char // works > // http://string_with_a_big_s.as_str().as_ptr() as *const c_char // doesn't work > // http://mut_string_with_a_big_s.as_str().as_ptr() as *const c_char // doesn't work > // http://c_string.as_ptr() as *const c_char // doesn't work > // http://c_string_to_bytes.as_ptr() as *const c_char // doesn't work > // http://c_string_as_c_str.as_ptr() as *const c_char // doesn't work > // http://c_string_as_c_str_to_str.as_ptr() as *const c_char // doesn't work > // c_str.unwrap().as_ptr() as *const c_char > }

mike.geeves064
2021-08-22 10:22
So far rust is making me sad :smiling_face_with_tear: It's been a long time since I looked properly at something more low level, I have been living here for a while: https://xkcd.com/353/ :smile:

uglyog
2021-08-22 12:48
The problem is that most of the data is allocated on the stack, and so will discarded once the function returns.

uglyog
2021-08-22 12:55
```// This is a static string, probably pointing to fixed memory. let normal_str = "hello world\0"; // This creates a String Struct, which owns it's data. Will copy the string and destroy the data when the function returns let string_with_a_big_s = "hello world\0".to_owned(); // This is the same as above, but the variable is mutable (you can change it's contents). let mut mut_string_with_a_big_s = "hello world\0".to_owned(); // This creates a CString struct, which owns it's contents, but will also be disposed when the function returns. // It is the same as a String struct, but the data is NULL terminated let c_string = CString::new("hello world").unwrap(); // This gets a slice (static array) of the string bytes. Also allocated in the stack. let c_string_to_bytes = c_string.as_bytes(); // This gets a CStr slice (same as a str slice, but is NULL terminated). Still on the stack. let c_string_as_c_str = c_string.as_c_str(); // This converts the cstr slice into a str slice (array of characters, not null terminated). Still on the stack. let c_string_as_c_str_to_str = c_string_as_c_str.to_str().unwrap(); // This creates a CStr from a null terminated array of bytes. Also on the stack. let c_str = CStr::from_bytes_with_nul(b"hello world c_str\0");```

uglyog
2021-08-22 12:58
The magic method is `CString::into_raw()`

uglyog
2021-08-22 12:59
> Consumes the CString and transfers ownership of the string to a C caller.

uglyog
2021-08-22 13:00
It does this by allocating the CString struct on the Rust heap, and then returning the pointer. It won't be disposed of when the function returns.

uglyog
2021-08-22 13:01
Internally, it is using a Box, which is a smart pointer to data on the heap

matt.fellows
2021-08-22 13:04
Thanks Ron. Mike, I've definitely committed a few pointer sins to the project already so your bemusement is not uncommon

matt.fellows
2021-08-22 13:05
Boundaries are hard!

mike.geeves064
2021-08-22 13:25
Thanks thanks! I will try to digest and take another look later this eve :slightly_smiling_face: Boundaries are hard! :grinning: Funny when lessons come back, like with trig "I'll never need that when I'm older", 10 years later calculating the angle from a satellite to figure out how much "shadow" there is from a tree over a field. "I'll never need pointers again! Java is the future!" Said I 21 years ago :joy:

mike.geeves064
2021-08-22 17:49
:party_parrot: Apparently I had not tried all the possible things :smile: > let mut str_1 = "hello".to_owned(); > let str_2 = "world"; > > str_1.push_str(" "); > str_1.push_str(str_2); > > let c_str = CString::new(str_1).unwrap(); > c_str.into_raw() as *const c_char Success! Thanks for that, I can concatenate and return strings! into_raw() is indeed magical :smile: Definitely a bit of reading on heaps and stacks needed going into Rust, vs stumbling through as works well enough in py :slightly_smiling_face:

mike.geeves064
2021-08-22 18:49
This makes me laugh. It is amusing that it was so much easier creating and manipulating structs and then creating some JSON from it...than just returning a string. Tableflip :smile: I am back to having fun now

mike.geeves064
2021-08-22 20:41
I have a question/proposal on approach for some of the FFI work, very much just a poc and not in any way final code, just playing with an idea :) I've made a quick and dirty additional FFI function "pactffi_verifier_cli_args" in the Rust verifier: https://github.com/mikegeeves/pact-reference/pull/1/files#diff-acb08ed5a8b61dfc509747740c1c045f39c31f59105bb0290a36c7c911252254 This looks at the clap arguments defined in the Rust code and for now extracts: the argument long name, if there is a short single character option and the help. The function then returns this as a JSON string. It's more complicated than this ofc - multiple, defaults, types and so on - but just to demonstrate.. On the python side, for the CLI wrapper, I'm then just calling that function and using it to programatically setting up the click options for calling via CLI: https://github.com/mikegeeves/pact-python/pull/1/files#diff-4d935290cd4b707d3487eda5c7a90daf7c5f79c22d85bba238f218068d501e05 This is then nicely giving the help options without having to manually add them all in (snipped): > $ pact-verifier --help > Usage: pact-verifier [OPTIONS] > > Options: > --request-timeout TEXT Sets the HTTP request timeout in > milliseconds for requests to the target API > and for state change requests. > --include-wip-pacts-since TEXT Allow pacts that don't match given consumer > selectors (or tags) to be verified, without > causing the overall task to fail. For more > information, see https://pact.io/wip > <snip> > -u, --url TEXT URL of pact file to verify (can be repeated) > -d, --dir TEXT Directory of pact files to verify (can be > repeated) > -f, --file TEXT Pact file to verify (can be repeated) > -l, --loglevel TEXT Log level (defaults to warn) > --help Show this message and exit. The idea here being that at least some benefit from having the single library being shared is lost if there's then a dependency for each implementation to maintain the sets of arguments and descriptions and so on. It's an extra point of failure for e.g. typo fix, extra arg, arg removed, when for the most part (some more complicated arguments sure, but for the simple ones) the wrapper only really needs to dumbly pass them through. On the Rust side if there's anything bad it will handle it there. Half way could be each version just grabbing the JSON and at least then being able to identify if there is a change which may need to be actioned, that would be simple enough to test for. Thoughts? Any value in trying to progress this? There's way more to look at but I thought a quick poc to explain would be helpful for at least a discussion. No offence if the consensus is an abomination (as my first ever Rust code is for sure :smile: thank you again@uglyog !)


matt.fellows
2021-08-23 00:05
Turns out memory layout once you leave the safety of Rust is hard :stuck_out_tongue:

mike.geeves064
2021-08-23 00:12
:D CI definitely painful, I'm glad you can squash commits to hide what went on

matt.fellows
2021-08-23 00:13
hehe

mike.geeves064
2021-08-23 00:15
"why do you have 300 commits with the message 'sad face'" during a code review, fun times. Ahh which reminds me, there was a ticket for GitLab examples somewhere I think :thinking_face: (on the list of things I didn't quite get onto in the past year)

uglyog
2021-08-23 04:20
Looks fine to me. Just remember the JSON string will be allocated on the Rust heap, and will need to be freed with the `pactffi_free_string` function once done with it on the Python side.

mike.geeves064
2021-08-23 09:25
I'll have a look at some of the other option types, I've added in possible_values which seems to work ok as well. > -l, --loglevel [error|warn|info|debug|trace|none] Will look into the pactffi_free_string, I've seen the warnings that it should be used but haven't seen/tried it. Have moved the code over to http://mod.rs from http://verifier.rs, I assume it's supposed to go there instead? I am not too sure about tests for Rust at all :smile:

tjones
2021-08-23 11:34
Also, I've created #libpact_ffi-users - since there's quite a bit of discussion about the rust pact ffi bindings in the different language channels, but the discussions cover quite a bit of the same ground. Please join if this is useful or of interest to you!

tjones
2021-08-23 11:37
We also have this new guideline (on my todo list is to do a pass over the rust core and make sure we're sticking to it): https://github.com/pact-foundation/pact-specification#logging-in-a-pact-library

tien.xuan.vo
2021-08-24 14:23
Fixed by running `cargo install cbindgen` to update cbindgen from `v0.19.0` to `v0.20.0`

tien.xuan.vo
2021-08-24 16:18
I am trying this and I think some parameter are missing like: ```--state-change-url http://localhost:8000/change-state```

tien.xuan.vo
2021-08-24 16:30
Unless don't remove `pactffi_verify` so we can use parameters

matt.fellows
2021-08-24 23:14
It might be the case. I think it?s just a POC to show how that might work as a replacement for the current ?all in one? function, which is less than ideal

uglyog
2021-08-24 23:27
I haven't implemented all the options yet

mike.geeves064
2021-08-27 12:18
@uglyog to check, on the python side I am adding this to the list of FFI functions to expose: > // mock_server > void pactffi_free_string(char *); as part of the others declared like this: > PactFFI.ffi.cdef( > """ > // root crate > char *pactffi_version(void); > > // verifier > int pactffi_verify(char *); > > // mock_server > void pactffi_free_string(char *); > > // log > int pactffi_log_to_file(char *, int); > > // experimenting > char *pactffi_verifier_cli_args(void); > """ > ) and then in my python code using it, I'm then just calling it like this: > result = self.lib.pactffi_verifier_cli_args() > cli_args_json = Arguments(**json.loads(self.ffi.string(result).decode("utf-8"))) > self.lib.pactffi_free_string(result) Is that correct? It works ok, but I am not sure how to verify that the memory is being freed correctly? (I am a little nervous about the pactffi_verifier_cli itself, if there is anything else I should be doing to clean up there too :thinking_face: )

uglyog
2021-08-28 03:32
It should be good as long as you call the method. No need to verify that the Rust memory management works :smile:

mike.geeves064
2021-08-28 07:15
:+1:

uglyog
2021-08-28 07:33
Reviewed the PR. There are some minor things that can be improved, but it looks good to me

mike.geeves064
2021-08-28 07:43
Awesome, thanks. Comments/improvements to make very welcome

mike.geeves064
2021-08-30 20:53
Back at a PC so have made the updates, I'd missed a couple of the compiler warnings on /// docs for the structs which are added too. For my next attempt I may try editing in something other than pycharm which does work but possibly isn't ideal :smile: What are the conventions here on hitting merge / dealing with comments? Previously I've worked with teams where for example only the person raising a comment should then resolve them, other times the dev resolves after updating. Similar with when to merge (e.g. only after comments are all resolved, other times as soon as there's approval)

mike.geeves064
2021-08-30 21:07
@uglyog thank you for taking the time to explain detail of some basics to a newbie, appreciate it :slightly_smiling_face: :taco:

uglyog
2021-08-30 22:44
I'm happy to have the PR merged when the comments are addressed. If you're confident you've addressed them, you can resolve them

mike.geeves064
2021-08-31 09:21
:+1: done

mike.geeves064
2021-08-31 09:22
Hopefully I didn't break anything :thinking_face:

mike.geeves064
2021-08-31 09:31
Oh wait, I haven't since that was just the draft in my fork, approval needed over here: https://github.com/pact-foundation/pact-reference/pull/136

mike.geeves064
2021-08-31 09:33
I forgot initially it was just looking at my fork as a poc/explanation rather than expecting the code to actually go in :smile:

ben.kaiser
2021-09-07 15:14
I can?t quite pinpoint the issue but running a `cargo install pact_verifier_cli` today is failing whereas on 8/23 it was successful. ``` > [2/2] RUN cargo install --version 0.8.7 pact_verifier_cli: #5 0.979 Updating http://crates.io index #5 28.38 Downloading crates ... #5 28.65 Downloaded pact_verifier_cli v0.8.7 #5 29.03 Installing pact_verifier_cli v0.8.7 #5 29.81 Downloading crates ... ... #5 32.29 Compiling libc v0.2.101 #5 32.29 Compiling cfg-if v1.0.0 #5 32.29 Compiling autocfg v1.0.1 #5 32.60 Compiling proc-macro2 v1.0.29 #5 33.22 Compiling unicode-xid v0.2.2 #5 33.25 Compiling memchr v2.4.1 #5 33.25 Compiling syn v1.0.76 #5 33.39 Compiling log v0.4.14 #5 33.62 Compiling cc v1.0.70 #5 33.70 Compiling serde_derive v1.0.130 #5 33.70 Compiling serde v1.0.130 #5 34.12 Compiling once_cell v1.8.0 #5 34.18 Compiling version_check v0.9.3 #5 34.51 Compiling pin-project-lite v0.2.7 #5 34.65 Compiling futures-core v0.3.17 #5 34.72 Compiling untrusted v0.7.1 #5 34.95 Compiling parking_lot_core v0.8.5 #5 34.96 Compiling proc-macro-hack v0.5.19 #5 35.29 Compiling spin v0.5.2 #5 35.36 Compiling smallvec v1.6.1 #5 35.40 Compiling proc-macro-nested v0.1.7 #5 35.50 Compiling futures-task v0.3.17 #5 35.68 Compiling scopeguard v1.1.0 #5 35.79 Compiling futures-channel v0.3.17 #5 35.82 Compiling futures-sink v0.3.17 #5 35.84 Compiling itoa v0.4.8 #5 35.98 Compiling lazy_static v1.4.0 #5 36.07 Compiling fnv v1.0.7 #5 36.12 Compiling pin-utils v0.1.0 #5 36.14 Compiling regex-syntax v0.6.25 #5 36.22 Compiling futures-io v0.3.17 #5 36.25 Compiling slab v0.4.4 #5 36.47 Compiling hashbrown v0.11.2 #5 36.72 Compiling ppv-lite86 v0.2.10 #5 37.14 Compiling ryu v1.0.5 #5 37.22 Compiling httparse v1.5.1 #5 37.60 Compiling tinyvec_macros v0.1.0 #5 37.66 Compiling base64 v0.13.0 #5 37.73 Compiling getrandom v0.1.16 #5 38.13 Compiling matches v0.1.9 #5 38.26 Compiling semver v1.0.4 #5 38.53 Compiling percent-encoding v2.1.0 #5 38.72 Compiling pkg-config v0.3.19 #5 39.15 Compiling try-lock v0.2.3 #5 39.30 Compiling serde_json v1.0.67 #5 39.71 Compiling encoding_rs v0.8.28 #5 40.02 Compiling unicode-bidi v0.3.6 #5 40.88 Compiling httpdate v1.0.1 #5 41.64 Compiling openssl-probe v0.1.4 #5 42.24 Compiling tower-service v0.3.1 #5 42.40 Compiling mime v0.3.16 #5 42.51 Compiling ucd-trie v0.1.3 #5 43.51 Compiling strsim v0.10.0 #5 44.06 Compiling anyhow v1.0.43 #5 44.26 Compiling maplit v1.0.2 #5 44.42 Compiling ident_case v1.0.1 #5 44.61 Compiling bitflags v1.3.2 #5 44.62 Compiling minimal-lexical v0.1.3 #5 44.76 Compiling peresil v0.3.0 #5 45.00 Compiling remove_dir_all v0.5.3 #5 45.13 Compiling ipnet v2.3.1 #5 45.49 Compiling typed-arena v1.7.0 #5 45.71 Compiling either v1.6.1 #5 45.96 Compiling fixedbitset v0.4.0 #5 46.95 Compiling safemem v0.3.3 #5 47.22 Compiling indextree v4.3.1 #5 47.69 Compiling rustversion v1.0.5 #5 48.13 Compiling hex v0.4.3 #5 48.34 Compiling bytecount v0.6.2 #5 48.68 Compiling quick-error v1.2.3 #5 48.85 Compiling ansi_term v0.12.1 #5 48.88 Compiling async-trait v0.1.51 #5 49.32 Compiling difference v2.0.0 #5 49.81 Compiling termcolor v1.1.2 #5 50.49 Compiling unicode-width v0.1.8 #5 50.64 Compiling ansi_term v0.11.0 #5 50.88 Compiling vec_map v0.8.2 #5 51.10 Compiling humantime v2.1.0 #5 51.28 Compiling strsim v0.8.0 #5 51.89 Compiling zeroize v1.4.1 #5 52.19 Compiling instant v0.1.10 #5 52.30 Compiling futures-macro v0.3.17 #5 52.59 Compiling tokio v1.11.0 #5 52.72 Compiling indexmap v1.7.0 #5 52.87 Compiling futures-util v0.3.17 #5 53.00 Compiling num-traits v0.2.14 #5 53.20 Compiling num-integer v0.1.44 #5 53.64 Compiling unicase v2.6.0 #5 53.73 Compiling nom v7.0.0 #5 53.93 Compiling ring v0.16.20 #5 54.12 Compiling lock_api v0.4.5 #5 54.13 Compiling tracing-core v0.1.19 #5 54.57 Compiling tinyvec v1.3.1 #5 54.86 Compiling form_urlencoded v1.0.1 #5 55.47 Compiling onig_sys v69.7.0 #5 55.94 Compiling pest v2.1.3 #5 56.05 Compiling sxd-document v0.3.2 #5 56.20 Compiling itertools v0.10.1 #5 58.35 Compiling textwrap v0.11.0 #5 63.99 Compiling tracing v0.1.26 #5 67.20 Compiling unicode-normalization v0.1.19 #5 70.34 Compiling semver-parser v0.10.2 #5 77.09 Compiling quote v1.0.9 #5 77.70 Compiling signal-hook-registry v1.4.0 #5 78.07 Compiling num_cpus v1.13.0 #5 78.42 Compiling getrandom v0.2.3 #5 79.38 Compiling socket2 v0.4.1 #5 79.46 Compiling time v0.1.44 #5 79.75 Compiling fs2 v0.4.3 #5 80.17 Compiling atty v0.2.14 #5 80.33 Compiling aho-corasick v0.7.18 #5 80.83 Compiling buf_redux v0.8.4 #5 81.51 Compiling twoway v0.1.8 #5 82.04 Compiling mio v0.7.13 #5 83.47 Compiling want v0.3.0 #5 83.87 Compiling fern v0.6.0 #5 84.52 Compiling os_info v3.0.7 #5 86.48 Compiling lenient_semver_version_builder v0.4.2 #5 87.57 Compiling idna v0.2.3 #5 88.93 Compiling semver v0.11.0 #5 91.24 Compiling petgraph v0.6.0 #5 94.59 Compiling parking_lot v0.11.2 #5 95.99 Compiling rand_core v0.6.3 #5 96.51 Compiling uuid v0.8.2 #5 96.77 Compiling rand_core v0.5.1 #5 97.23 Compiling clap v2.33.3 #5 97.49 Compiling regex v1.5.4 #5 107.1 Compiling pact_ffi v0.0.2 #5 107.5 Compiling mime_guess v2.0.3 #5 108.7 Compiling lenient_semver_parser v0.4.2 #5 109.3 Compiling url v2.2.2 #5 114.1 Compiling sct v0.6.1 #5 114.7 Compiling webpki v0.21.4 #5 116.4 Compiling onig v6.2.0 #5 117.8 Compiling tree_magic_mini v3.0.2 #5 119.0 Compiling chrono v0.4.19 #5 123.2 Compiling rand_chacha v0.3.1 #5 123.3 Compiling darling_core v0.13.0 #5 124.1 Compiling rand_chacha v0.2.2 #5 124.7 Compiling env_logger v0.8.4 #5 129.3 Compiling tokio-macros v1.3.0 #5 129.9 Compiling thiserror-impl v1.0.29 #5 133.6 Compiling parse-zoneinfo v0.3.0 #5 133.8 Compiling lenient_semver v0.4.2 #5 133.9 Compiling ct-logs v0.8.0 #5 134.1 Compiling rustls v0.19.1 #5 134.3 Compiling webpki-roots v0.21.1 #5 134.5 Compiling simplelog v0.9.0 #5 135.3 Compiling rand v0.8.4 #5 136.9 Compiling rand v0.7.3 #5 137.4 Compiling darling_macro v0.13.0 #5 139.2 Compiling thiserror v1.0.29 #5 143.5 Compiling chrono-tz v0.5.3 #5 144.1 Compiling pact_models v0.1.3 #5 144.7 Compiling rand_regex v0.15.1 #5 145.3 Compiling tempfile v3.2.0 #5 146.9 Compiling rustls-native-certs v0.5.0 #5 146.9 Compiling darling v0.13.0 #5 147.0 Compiling futures-executor v0.3.17 #5 147.6 Compiling bytes v1.1.0 #5 149.1 Compiling serde_urlencoded v0.7.0 #5 152.8 Compiling multipart v0.17.1 #5 152.9 Compiling serde_with_macros v1.5.0 #5 154.8 Compiling futures v0.3.17 #5 156.8 Compiling http v0.2.4 #5 162.3 Compiling serde_with v1.10.0 #5 164.6 Compiling http-body v0.4.3 #5 165.0 Compiling tokio-util v0.6.8 #5 166.2 Compiling tokio-rustls v0.22.0 #5 166.5 Compiling h2 v0.3.4 #5 176.0 Compiling hyper v0.14.12 #5 184.1 Compiling hyper-rustls v0.22.1 #5 184.3 Compiling reqwest v0.11.4 #5 191.4 Compiling pact_matching v0.10.3 #5 215.7 Compiling pact_mock_server v0.7.20 #5 277.1 Compiling pact_verifier v0.10.11 #5 278.2 error[E0004]: non-exhaustive patterns: `&None` not covered #5 278.2 --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier-0.10.11/src/pact_broker.rs:293:33 #5 278.2 | #5 278.2 293 | Some(ref auth) => match auth { #5 278.2 | ^^^^ pattern `&None` not covered #5 278.2 | #5 278.2 ::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/pact_models-0.1.3/src/http_utils.rs:18:3 #5 278.2 | #5 278.2 18 | None #5 278.2 | ---- not covered #5 278.2 | #5 278.2 = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms #5 278.2 = note: the matched value is of type `&HttpAuth` #5 278.2 #5 278.2 error[E0004]: non-exhaustive patterns: `&None` not covered #5 278.2 --> /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/pact_verifier-0.10.11/src/pact_broker.rs:430:31 #5 278.2 | #5 278.2 430 | Some(ref auth) => match auth { #5 278.2 | ^^^^ pattern `&None` not covered #5 278.2 | #5 278.2 ::: /usr/local/cargo/registry/src/github.com-1ecc6299db9ec823/pact_models-0.1.3/src/http_utils.rs:18:3 #5 278.2 | #5 278.2 18 | None #5 278.2 | ---- not covered #5 278.2 | #5 278.2 = help: ensure that all possible cases are being handled, possibly by adding wildcards or more match arms #5 278.2 = note: the matched value is of type `&HttpAuth` #5 278.2 #5 278.4 error: aborting due to 2 previous errors #5 278.4 #5 278.4 For more information about this error, try `rustc --explain E0004`. #5 278.4 error: failed to compile `pact_verifier_cli v0.8.7`, intermediate artifacts can be found at `/tmp/cargo-installs3DdhF` #5 278.4 #5 278.4 Caused by: #5 278.4 could not compile `pact_verifier` #5 278.4 #5 278.4 To learn more, run the command again with --verbose. ------ executor failed running [/bin/sh -c cargo install --version 0.8.7 pact_verifier_cli]: exit code: 101```

uglyog
2021-09-07 23:18
`pact_matching` crate update was released. It must have accidentally contained a breaking change.

uglyog
2021-09-08 00:39
I have released `pact_verifier` crate, which fixes this issue

tien.xuan.vo
2021-09-19 12:35
Is `url` in `pactffi_verifier_set_provider_state` required? I'm thinking about adding this for it: ``` EXIT_SUCCESS } { EXIT_FAILURE }```

matt.fellows
2021-09-19 13:26
I don't think it is

matt.fellows
2021-09-19 13:27
What would that do? All I see is it might pass or might fail :rolling_on_the_floor_laughing:

matt.fellows
2021-09-19 13:27
But not when


tien.xuan.vo
2021-09-19 13:44
If `url` is optional, then I won't add that block of code

uglyog
2021-09-19 23:11
`url` is optional, in the sense that without it the provider states won't be invoked, they are ignored. But I think it should be required `pactffi_verifier_set_provider_state` because otherwise there is no point in calling that method.

mike.geeves064
2021-09-28 07:56
ahem. next time I will try and stick with a single message rather than the steps while going through, it looks like there is a lot but it was all just part of one thing :open_mouth:

tjones
2021-09-30 10:46
Ah yeah. Any commit message with `feat` or `fix` ends up in the changelog

mike.geeves064
2021-09-30 10:47
:slightly_smiling_face: Indeed. I come from a world where every branch was squashed during merge so just the single commit :smile: Unexpected consequence of small and frequent commits!

tjones
2021-09-30 10:50
An advantage of not squashing is that you aren't discouraged from fixing unrelated things you notice while working - you just make those separate commits, named appropriately

mike.geeves064
2021-09-30 10:52
I mean, I've never seen people discouraged from fixing unrelated things, only discouraged from taking on a code review :smile:

mike.geeves064
2021-09-30 10:54
Need to "practice" partial commits and modifying commits before pushing a bit more :thinking_face:

tjones
2021-09-30 10:59
Why not use the index? `git add` will do your partial commit

mike.geeves064
2021-09-30 11:01
I mean code chunks rather than file level

matt.fellows
2021-11-04 04:44
Any chance you could do a release of the CLI also Ron? Someone was asking for it so they could do provider verification with branches

uglyog
2021-11-04 04:50
Yeah, I have to release all the things to remove the beta versions

uglyog
2021-11-04 06:00
Just checked the changes, you only made the branches change to the FFI libs and not the CLI

uglyog
2021-11-04 06:01
Was the person asking for the change with the CLI?

matt.fellows
2021-11-04 06:02
hmm, did I not do that. Bad me

matt.fellows
2021-11-04 06:02
yes, they wanted CLI

matt.fellows
2021-11-04 06:02
Lucky they are asleep, probably, and I can delete my message telling them it?s ready :laughing:

uglyog
2021-11-04 06:03
Remember how I fixed the horrible dependency problem by duplicating the clap args?

matt.fellows
2021-11-04 06:04
:point_up:

matt.fellows
2021-11-04 06:16
?I do now

john
2021-11-09 06:00
has joined #pact-rust

tien.xuan.vo
2021-11-15 16:57
Do you miss `pact.h` and `pact-cpp.h` in this release https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.1.0 ?

uglyog
2021-11-15 22:22
Let me check, it should have been generated

uglyog
2021-11-15 23:01
Looks like the release failed to generate them. I'll update it and try work out what happened.

uglyog
2021-11-16 02:20
@matt.fellows :point_up:

matt.fellows
2021-11-16 02:24
danke

matt.fellows
2021-11-16 02:24
just need the FFI and then I?m sweet I think

tien.xuan.vo
2021-11-16 03:58
It's still missing in 0.1.1, but at least I can see them in 0.1.0. Thanks

uglyog
2021-11-16 04:03
updated

matt.fellows
2021-11-16 07:05
Heads up @tjones @yann.courtel @pact544 and @tien.xuan.vo, this release has a new pointer attribute (`interaction_type` ) on the `InteractionHandle` which resulted in a segfault for Pact Go when I ran it. Wasn?t too difficult to track down, and may not actually cause issues for you. @uglyog wondering if we should create an acceptance suite for the FFI that would catch this. I?m not that familiar with approaches here, if that?s something we can statically check or if having a fully fledged c consumer suite that links to it would be a good idea?

yann.courtel
2021-11-16 07:07
has joined #pact-rust

tjones
2021-11-16 07:11
According to rust?s package manager 0.x is a breaking change, so I think it was marked correctly (but maybe not obviously)

matt.fellows
2021-11-16 07:13
interesting. That just raises more questions, I think the FFI interface should be semver (I?m assuming that?s the case!) but we haven?t actually ever discussed that that I can recall

matt.fellows
2021-11-16 07:13
the main point was just sharing that info, so you don?t have to re-discover it

matt.fellows
2021-11-16 07:17
It looks like the kind of change that is fairly innocuous and hard to catch (i.e. the FFI API looks the same if just look at the types/signatures)

matt.fellows
2021-11-16 07:18
and because it?s FFI, it just blows up if you call it (one of the downsides of FFI)

matt.fellows
2021-11-16 07:25
Hmmm I?m also finding that the JSON bodies are being stringified in this release. I?ll create a thread, it could be something dumb I?m doing :point_down:

yann.courtel
2021-11-16 07:41
Thanks for the heads-up!

matt.fellows
2021-11-16 11:00
I have small pact acceptance suite in Pact Go that tests that go can call the main FFI methods. The one that runs through a basic lifecycle is producing this pact file: ```? native git:(2.x.x) ? cat /var/folders/xj/rmgl_kbn1qzb9953tw7lv_yc0000gn/T/pact-go123408037/test-http-consumer-test-http-provider.json <aws:pact-prod> { "consumer": { "name": "test-http-consumer" }, "interactions": [ { "description": "some interaction", "key": "8369cdf3b43ff542", "pending": false, "providerStates": [ { "name": "some state" } ], "request": { "method": "GET", "path": "/products" }, "response": { "body": { "content": "{\"age\":23,\"alive\":true,\"name\":\"some name\"}", "contentType": "*/*", "encoded": false }, "headers": { "Content-Type": [ "application/json" ] }, "matchingRules": { "body": { "$.name": { "combine": "AND", "matchers": [ { "match": "type" } ] } } }, "status": 200 }, "type": "Synchronous/HTTP" } ], "metadata": { "pactRust": { "ffi": "0.1.2", "mockserver": "0.8.2", "models": "0.2.1" }, "pactSpecification": { "version": "4.0" } }, "provider": { "name": "test-http-provider" } }```

matt.fellows
2021-11-16 11:02
there are at least 2 issues: 1. It doesn?t seem to respect the `pactffi_with_specification` method at all, and always serialises a v4 pact 2. the JSON body seems to be stringified and when it is verified the verification fails because it?s comparing text and the formatting/values are different

matt.fellows
2021-11-16 11:04
It checks the content type, but for some reason is still doing a text comparison on the response: ``` A request to do a foo returns a response which has status code 200 (OK) includes headers "Content-Type" with value "application/json" (OK) has a matching body (FAILED) [2021-11-16T11:03:06Z ERROR pact_verifier] Failed to load pact - Failed to load pact '/Users/matthewfellows/go/src/github.com/pact-foundation/pact-go/examples/pacts/PactGoV2ConsumerMatch-V2ProviderMatch.json' - No such file or directory (os error 2) Failures: 1) Verifying a pact between PactGoV3Consumer and V3Provider Given User foo exists - A request to do a foo 1.1) has a matching body $ -> Expected text 'Some(b"{\"accountBalance\":123.76,\"arrayContaining\":[\"string\",1,{\"foo\":\"bar\"}],\"datetime\":\"2020-01-01\",\"equality\":\"a thing\",\"id\":12,\"itemsMin\":[\"thereshouldbe3ofthese\",\"thereshouldbe3ofthese\",\"thereshouldbe3ofthese\"],\"itemsMinMax\":[27,27,27,27,27],\"lastName\":\"Sampson\",\"name\":\"Billy\",\"superstring\":\"foo\"}")' but received 'Some(b"\n\t\t\t{\n\t\t\t\t\"accountBalance\": 123.76,\n\t\t\t\t\"datetime\": \"2020-01-01\",\n\t\t\t\t\"equality\": \"a thing\",\n\t\t\t\t\"id\": 12,\n\t\t\t\t\"itemsMin\": [\n\t\t\t\t\t\"thereshouldbe3ofthese\",\n\t\t\t\t\t\"thereshouldbe3ofthese\",\n\t\t\t\t\t\"thereshouldbe3ofthese\"\n\t\t\t\t],\n\t\t\t\t\"itemsMinMax\": [\n\t\t\t\t\t27,\n\t\t\t\t\t27,\n\t\t\t\t\t27,\n\t\t\t\t\t27,\n\t\t\t\t\t27\n\t\t\t\t],\n\t\t\t\t\"lastName\": \"Sampson\",\n\t\t\t\t\"name\": \"Billy\",\n\t\t\t\t\"superstring\": \"foo\",\n\t\t\t\t\"arrayContaining\": [\n\t\t\t\t\t\"string\",\n\t\t\t\t\t1,\n\t\t\t\t\t{\n\t\t\t\t\t\t\"foo\": \"bar\"\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}")'```

matt.fellows
2021-11-16 11:05
(note this is a *different pact file* than what is being verified, but the other is a long longer because of matching rules. The same set of symptoms though)

matt.fellows
2021-11-16 12:00
So, I think I?ve fixed the serialisation issue. I?ll submit a WIP fix to see if it?s the root cause or just a proximate one

matt.fellows
2021-11-16 12:00
as for spec version, it seems we?ve now migrated to the `V4Pact` struct, which doesn?t have anywhere to set the spec version (because, presumably, it is always V4)

matt.fellows
2021-11-16 12:01
we track the FFI spec version here: ```pub struct PactHandleInner { pub(crate) pact: V4Pact, pub(crate) mock_server_started: bool, pub(crate) specification_version: PactSpecification }``` but because the `specification_version` property is not ever passed on to the pact itself, it obviously won?t ever serialise another version


uglyog
2021-11-16 21:45
I think the problem here is that those structs are meant to be opaque structs and the internals are not meant to be exposed via FFI. They should just be typed pointers.

uglyog
2021-11-16 21:46
I'll look into the cbingen config to see why they are exposing the internals.

matt.fellows
2021-11-16 21:48
thanks, yeah it does look like implementation detail

matt.fellows
2021-11-16 21:49
the PR fixes the JSON serialisation issue, but not sure how to tackle the spec version

uglyog
2021-11-17 00:36
Oh, I was on the assumption we were passing pointers, but the FFI functions are passing the actual structs. Sorry, my bad. I trying `#[repr(transparent)]` with the handles, which will represent the handles as an opaque type on the other side of the FFI boundary. There are integration tests that test the FFI functions from C, but they don't test all the functions, they only run on Linux agents and they only test from a simple C consumer.

matt.fellows
2021-11-17 02:21
cool, let us know. I think a general pointer type without knowing the details makes more sense from the outside so we don?t leak implementation details / break things etc.

matt.fellows
2021-11-17 02:21
but also, I know less about those details.

matt.fellows
2021-11-17 02:22
> There are integration tests that test the FFI functions from C, but they don?t test all the functions, they only run on Linux agents and they only test from a simple C consumer. what would an ideal version look like? Perhaps it?s something we can get assistance from the general community with, including others (I?m conscious you have the main maintainer responsibility and there is a _lot_ in the core at the moment)

uglyog
2021-11-17 02:38
Is the V4 pact file issue when using it with a mock server? Ie. calling `pactffi_write_pact_file`?

matt.fellows
2021-11-17 02:44
yeah

matt.fellows
2021-11-17 02:45
if you run just this test (`http_consumer_feature_test`) in the ffi package you can see the output in `/tmp/pact/http-consumer?json`

uglyog
2021-11-17 02:48
Ok, the issue is the spec version is stored against the handle, and the mock server knows nothing about that. We can change the mock server, but that will require changing a lot of the mock server functions. I'm creating a new function `pactffi_pact_handle_write_file` which takes the handle, so it knows the spec version.

matt.fellows
2021-11-17 02:50
Yeah, it?s just stored on the handle at the moment and doesn?t actually go anywhere

matt.fellows
2021-11-17 02:51
any reason not to just update the existing FFI method? Either way on an upgrade it won?t functionally work unless code is changed

uglyog
2021-11-17 02:59
We need to update all the mock server FFI methods (there are a few, based on inputs and whether it's HTTP or HTTPS). It will be a breaking change.

uglyog
2021-11-17 03:40
Previous me provided for these types of problems, and introduced the functions `start_mock_server_with_config`. So if we use those, we just need to add the spec version to the config, and no breaking changes!!! :tada:

matt.fellows
2021-11-17 03:48
Thanks last Ron

matt.fellows
2021-11-17 05:05
`s/last/past`

matt.fellows
2021-11-17 05:12
`0.1.2` is looking much better Ron

matt.fellows
2021-11-17 05:12
I?ve noticed a couple of the versions in the metadata are escaped: ``` "metadata": { "pactRust": { "ffi": "\"0.1.2\"", "mockserver": "\"0.8.3\"", "models": "0.2.1" }, "pactSpecification": { "version": "3.0.0" } },```

matt.fellows
2021-11-17 05:12
Also I have a failing message test, i?ll let you know what it found

matt.fellows
2021-11-17 05:52
the message pact fn?s seem to be getting null pointers received, just trying to work out why. Compiling locally from master I get some different output.

matt.fellows
2021-11-17 05:52
Ah, there is a 0.1.3 but not published yet. Cool, working with that FFI signature?

matt.fellows
2021-11-17 06:04
OK, the issue was that I hadn?t updated the message handle types, which meant go was sending more stuff into the method signature and causing strange issues with converting strings.

matt.fellows
2021-11-17 06:28
Looks like we have a green build, thanks Ron! :rocket:

mike.geeves064
2021-12-06 11:55
Hm, I've pushed up a tiny fix, which I think looks ok, although I'm not sure if this is the best way to add in (Rust knowledge still very low), also a little wary that this is a change of behaviour so could cause breakage, even if the current behaviour wasn't as expected I'm seeing what looks like the --state-change-teardown flag not working properly, master branch of pact-reference, unless I totally misunderstood something :smile: Default: > $ ./rust/target/debug/pact_verifier_cli -d /home/mgeeves/dev/GitHub/mikegeeves/pact-foundation/pact-python/examples/pacts --loglevel info -p 8000 -s http://localhost:8000/_pact/provider_states > > Verifying a pact between UserServiceClient and UserService > *09:32:25 [INFO] Running provider state change handler 'UserA exists and is not an administrator' for 'a request for UserA'* > Given UserA exists and is not an administrator > 09:32:25 [INFO] Running provider verification for 'a request for UserA' > 09:32:25 [INFO] Sending request to provider at http://localhost:8000/ > 09:32:25 [INFO] Received response: HTTP Response ( status: 200, headers: Some({"content-length": ["134"], "server": ["uvicorn"], "date": ["Mon", "06 Dec 2021 09:32:24 GMT"], "content-type": ["application/json"]}), body: Present(134 bytes, application/json) ) > 09:32:25 [INFO] comparing to expected response: HTTP Response ( status: 200, headers: Some({}), body: Present(134 bytes) ) > *09:32:25 [INFO] Running provider state change handler 'UserA exists and is not an administrator' for 'a request for UserA'* > *09:32:25 [INFO] Running provider state change handler 'UserA does not exist' for 'a request for UserA'* > Given UserA does not exist > 09:32:25 [INFO] Running provider verification for 'a request for UserA' > 09:32:25 [INFO] Sending request to provider at http://localhost:8000/ > 09:32:25 [INFO] Received response: HTTP Response ( status: 404, headers: Some({"content-type": ["application/json"], "content-length": ["27"], "server": ["uvicorn"], "date": ["Mon", "06 Dec 2021 09:32:24 GMT"]}), body: Present(27 bytes, application/json) ) > 09:32:25 [INFO] comparing to expected response: HTTP Response ( status: 404, headers: Some({}), body: Missing ) > *09:32:25 [INFO] Running provider state change handler 'UserA does not exist' for 'a request for UserA'* With --state-change-teardown: > $ ./rust/target/debug/pact_verifier_cli -d /home/mgeeves/dev/GitHub/mikegeeves/pact-foundation/pact-python/examples/pacts --loglevel info -p 8000 -s http://localhost:8000/_pact/provider_states --state-change-teardown > > Verifying a pact between UserServiceClient and UserService > *09:35:38 [INFO] Running provider state change handler 'UserA exists and is not an administrator' for 'a request for UserA'* > Given UserA exists and is not an administrator > 09:35:38 [INFO] Running provider verification for 'a request for UserA' > 09:35:38 [INFO] Sending request to provider at http://localhost:8000/ > 09:35:38 [INFO] Received response: HTTP Response ( status: 200, headers: Some({"content-type": ["application/json"], "date": ["Mon", "06 Dec 2021 09:35:38 GMT"], "server": ["uvicorn"], "content-length": ["134"]}), body: Present(134 bytes, application/json) ) > 09:35:38 [INFO] comparing to expected response: HTTP Response ( status: 200, headers: Some({}), body: Present(134 bytes) ) > *09:35:38 [INFO] Running provider state change handler 'UserA exists and is not an administrator' for 'a request for UserA'* > *09:35:38 [INFO] Running provider state change handler 'UserA does not exist' for 'a request for UserA'* > Given UserA does not exist > 09:35:38 [INFO] Running provider verification for 'a request for UserA' > 09:35:38 [INFO] Sending request to provider at http://localhost:8000/ > 09:35:38 [INFO] Received response: HTTP Response ( status: 404, headers: Some({"date": ["Mon", "06 Dec 2021 09:35:38 GMT"], "server": ["uvicorn"], "content-length": ["27"], "content-type": ["application/json"]}), body: Present(27 bytes, application/json) ) > 09:35:38 [INFO] comparing to expected response: HTTP Response ( status: 404, headers: Some({}), body: Missing ) > *09:35:38 [INFO] Running provider state change handler 'UserA does not exist' for 'a request for UserA'* After fix: > $ ./rust/target/debug/pact_verifier_cli -d /home/mgeeves/dev/GitHub/mikegeeves/pact-foundation/pact-python/examples/pacts --loglevel info -p 8000 -s http://localhost:8000/_pact/provider_states > > Verifying a pact between UserServiceClient and UserService > *11:43:17 [INFO] Running provider state change handler 'UserA exists and is not an administrator' for 'a request for UserA'* > Given UserA exists and is not an administrator > 11:43:17 [INFO] Running provider verification for 'a request for UserA' > 11:43:17 [INFO] Sending request to provider at http://localhost:8000/ > 11:43:17 [INFO] Received response: HTTP Response ( status: 200, headers: Some({"server": ["uvicorn"], "date": ["Mon", "06 Dec 2021 11:43:16 GMT"], "content-length": ["134"], "content-type": ["application/json"]}), body: Present(134 bytes, application/json) ) > 11:43:17 [INFO] comparing to expected response: HTTP Response ( status: 200, headers: Some({}), body: Present(134 bytes) ) > *11:43:17 [INFO] Running provider state change handler 'UserA does not exist' for 'a request for UserA'* > Given UserA does not exist > 11:43:17 [INFO] Running provider verification for 'a request for UserA' > 11:43:17 [INFO] Sending request to provider at http://localhost:8000/ > 11:43:17 [INFO] Received response: HTTP Response ( status: 404, headers: Some({"server": ["uvicorn"], "content-length": ["27"], "date": ["Mon", "06 Dec 2021 11:43:16 GMT"], "content-type": ["application/json"]}), body: Present(27 bytes, application/json) ) > 11:43:17 [INFO] comparing to expected response: HTTP Response ( status: 404, headers: Some({}), body: Missing )

mike.geeves064
2021-12-06 12:56
Ahh tests fail

uglyog
2021-12-06 21:57
I'll have a look at it for you

mike.geeves064
2021-12-06 22:01
:+1: it's not causing me any problems, I just noticed it when looking at state changes

matt.fellows
2021-12-06 23:07
Thanks for the fix!

uglyog
2021-12-07 00:18
I've merged it, but changed it to be non-async

mike.geeves064
2021-12-07 08:29
:D Rust looks interesting, still on my Todo list to learn! Typing and traits are :open_mouth:

mike.geeves064
2021-12-07 14:27
:facepalm: ah should have modified it to print "Running provider state [setup|teardown] change handler" or something, as well, I will leave that for another day because PR overhead :slightly_smiling_face: ..and meanwhile start reading the Rust book because even that tiny change took me way too long :smile:

marconota.mac
2022-01-06 10:35
has joined #pact-rust

srinagasai.krishnasan
2022-01-10 18:10
has joined #pact-rust

matt.fellows
2022-01-17 05:05
@uglyog you OK if I release the latest FFI now that you merged that PR in, or was that on your list anyway?

uglyog
2022-01-17 05:08
Before we can release FFI, we need to release the mock server and verifier crates

uglyog
2022-01-17 05:08
But I can do those (wasn't planning on it)

matt.fellows
2022-01-17 05:49
yep, I assumed I?d need to follow the dependency chain. If you can do it though that?s awesome, thank you

matt.fellows
2022-01-18 02:49
@uglyog I?m finding a few tests don?t seem to work consistently across OS versions, and they all seem to be binary payload related. e.g. https://github.com/pact-foundation/pact-js/runs/4848121252?check_suite_focus=true#step:4:7668 https://github.com/pact-foundation/pact-js-core/runs/4812794228?check_suite_focus=true#step:4:361 (not the ubuntu build passes, but osx fails)

uglyog
2022-01-18 02:52
Those use the magic mime file type DB, which is GPL so we can't include it in the libs. It is also normally not available on Windows.

matt.fellows
2022-01-18 02:54
I thought that might be the case

matt.fellows
2022-01-18 02:54
I?m wondering how we deal with it cross platform

matt.fellows
2022-01-18 02:54
Should it not take the `content-type` header first, rather than sniff the payload?

matt.fellows
2022-01-18 02:54
i.e. if there is no `content-type` , fallback to the magic mime type detection?

uglyog
2022-01-18 02:55
That is assuming the content type header will always be correct.

matt.fellows
2022-01-18 03:04
I know. In my case, the tests have consistent setup and content types in the HTTP request, but the FFI is overriding what it detects and failing the build. What do you recommend ?

matt.fellows
2022-01-18 03:04
I?d say the majority of use cases will run builds on the same OS (so unlikely to get different responses)

uglyog
2022-01-18 03:06
There is an Apache project for doing this, but it is for the JVM. I was thinking of using their config files, but porting the implementation to Rust. They are Apache v2 licensed.


matt.fellows
2022-01-18 11:55
Raised an issue to track

matt.fellows
2022-01-31 02:07
:clap: JSON output

fabio.rodrigues
2022-02-04 13:27
has joined #pact-rust

agustin.gomes
2022-02-09 13:26
has joined #pact-rust

tien.xuan.vo
2022-03-03 15:37
Do we want to move csv in pact-plugins to a new project e.g. pact-csv-plugin like we did for pact-protobuf-plugin?

ricardo.gonzaga
2022-03-03 20:06
has joined #pact-rust

uglyog
2022-03-03 22:01
That's a good idea. Then it will have it's own lifecycle

tomas.sakinis
2022-03-04 06:39
has joined #pact-rust

thomas.heilbronner
2022-03-31 08:45
has joined #pact-rust

lewiscowles
2022-04-18 19:11
has joined #pact-rust

rholshausen
2022-05-05 00:32
has joined #pact-rust

orbit
2022-05-09 18:02
has joined #pact-rust

tjones
2022-05-16 08:47
@tjones has left the channel

tomas.sakinis
2022-05-20 08:41
@tomas.sakinis has left the channel

lewiscowles
2022-05-25 08:01
Question RE: ffi. Are the builds supposed to miss libssl.1.1.so and libcrypto.1.1.so ?

matt.fellows
2022-05-25 08:02
What do you mean by "miss them"?

matt.fellows
2022-05-25 08:03
We publish shared libraries, so these if required would be expected in the target environment

matt.fellows
2022-05-25 08:05
P.s. have you slept? :scream:

lewiscowles
2022-05-25 08:20
Haha I did.

lewiscowles
2022-05-25 08:20
But I've been at this (it's bugging me) for a few hours.

lewiscowles
2022-05-25 08:21
I think this might be the wrong channel then, but there is a repo missing bundling them

lewiscowles
2022-05-25 08:21
If anyone has a link to a release with them included :pray:

uglyog
2022-05-25 08:23
libssl.1.1.so and libcrypto.1.1.so are the open-ssl libs

matt.fellows
2022-05-25 08:23
I'm assuming you're asking because something isn't working Lewis? What's the actual issue you're seeing?

matt.fellows
2022-05-25 08:24
It could be a build agent missing dependencies


lewiscowles
2022-05-25 10:48
I also believe this may not be rust specific. Because it came from someone else PR about FFI, I was a bit at sea, but finding my legs now. Sorry for all the noise. Just trying to solve this work Docker issue (that only happens in CI with pact verification)

matt.fellows
2022-05-25 11:32
Thanks, we appreciate both your efforts to solve it and your persistence


lewiscowles
2022-05-25 11:46
For 22.04?

matt.fellows
2022-05-25 11:47
Sorry, I must have linked to that from another article

lewiscowles
2022-05-25 11:48
Totally fine. I think these are for the -dev headers (although if they also compile they'll get the shared object, they are doing two things). I'm downloading a binary, which is why I did this hack https://pact-foundation.slack.com/archives/CA2S7E6KC/p1653474796723179

matt.fellows
2022-05-25 11:49
Yeah. I think we might need to consider not using openssl in that library Actually, I?ll respond on the ticket

lewiscowles
2022-05-25 11:49
I'll totally vendor those deps, but also not use the `pact-stub-server` preferring the ruby version, as the stub-server has not had a release and doesn't bundle these with itself. (A Friend said this might be openssl licensing, I said then link to another SSL)

matt.fellows
2022-05-25 11:50
I recall something about openssl vs libressl (or something). So yeah, maybe

matt.fellows
2022-05-25 11:51
But we actually have an option to not use openssl at all I think.

lewiscowles
2022-05-25 11:52
Don't forget libcrypto though. I don't know that I've ever heard of that as an issue before this morning. The stub server links both.

matt.fellows
2022-05-25 11:53
pretty sure it?s also from openssl

slacksync
2022-06-08 17:21
has joined #pact-rust


uglyog
2022-08-19 02:39
yeah, I'll fix that and re-run

duynguyenptithcm
2022-08-20 07:25
has joined #pact-rust

dwalleck
2022-08-27 16:40
has joined #pact-rust

paul.ologeh
2022-09-16 23:27
has joined #pact-rust

tien.xuan.vo
2022-09-18 09:41
For files like these: ? https://github.com/pact-foundation/pact-stub-server/releases/download/v0.5.1/pact-stub-server-linux-x86_64.gz ? https://github.com/pact-foundation/pact-reference/releases/download/libpact_ffi-v0.3.11/libpact_ffi-linux-x86_64.so.gz Is it possible and good idea to: ? Change the extension from `.gz` to `.tar.gz` or `.zip` ? This make it easier to keep original binary file name during extraction. ? Make binary file executable by default?

uglyog
2022-09-18 23:27
That might be a good idea, but it seems a waste creating an archive with a single file in it.

alex.makdessi
2022-10-06 14:49
has joined #pact-rust

paul.ologeh
2022-10-07 01:17
is there by any chance any resources or tutorials available for a full implementation of pact with rust that anyone could point me to ? just asking before I invest some time navigating things myself. The docs do appear to be a bit outdated.

uglyog
2022-10-07 01:39
Are you asking about writing consumer tests and verifying providers in Rust?

paul.ologeh
2022-10-08 00:24
yes

paul.ologeh
2022-10-08 00:27
the documentation is very much out of date and the instructions in this read me doesn?t work https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_consumer/README.md the latest version i can see in `http://docs.rs` for the pact_consumer is 0.9.7

uglyog
2022-10-10 02:54
In what way don't they work? Did you get an error? The consumer crate is being used internally, you can see the tests here https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_verifier/tests/tests.rs#L49 as well as with the plugin project, here https://github.com/pact-foundation/pact-plugins/blob/main/examples/csv/csv-consumer-rust/src/lib.rs#L51

paul.ologeh
2022-10-10 08:39
the struct `ConsumerPactBuilder` does not exist anymore on that pact consumer version

paul.ologeh
2022-10-10 08:41
also everything now has to be async. It appears that native support for building non sync pact is no longer available aswell ? or atleast will require some work around.

uglyog
2022-10-10 21:51
oh, yeah, good point

uglyog
2022-10-10 21:51
I'll update the documentation

paul.ologeh
2022-10-13 08:15
how about non async pact builders. I can see it in previous pact consumer versions. Is there a conversation about why this was removed ? I don?t really want to use tokio.

uglyog
2022-10-13 22:03
Yes, we could have non-async ones. It is only if you need to use plugins that it needs to be async, because the plugins run as a separate process

paul.ologeh
2022-10-14 07:00
will you also add support for non async ones in the same commit for updating the docs ? or do i need to make a feature request ?

uglyog
2022-10-16 22:18
I'll probably fix the builder to support non-async, then update the docs in the end as the changes may invalidate any docs that are there

paul.ologeh
2022-10-17 10:04
okay. thanks. In the mean time i will just use the old builder.

paul.ologeh
2022-10-17 16:13
do you need me to create an issue or anything ?

uglyog
2022-10-17 21:44
Yes, please. Otherwise this request could get lost (this slack only keeps 90 days of messages)

paul.ologeh
2022-11-12 20:50
thanks for doing this btw even though i forgot to raise an issue

paul.ologeh
2022-11-14 00:50
it seems that with the pact builder its not possible to have a different request/response for the same path and and http method or i don?t know how to get it done I?ve tried to build a pact with 2 different sets of requests and their responses but only one of them make it into the pact file. Here are the pacts in 2 different tests ```let pact = PactBuilder::new("Consumer", "Provider") .interaction("looks for something that doesn't exist", "", |mut i| { i.request .post() .path("/search") .content_type("application/json") .json_body(like!(json!({"key": "i_dont_exist"}))); i.response .content_type("application/json") .json_body(json!({"count": 0, "results": []})); i }) .output_dir("pact_contracts") .start_mock_server(None); let pact = PactBuilder::new("Consumer", "Provider") .interaction("looks for something that exists", "", |mut i| { i.request .post() .path("/search") .content_type("application/json") .json_body(like!(json!({"key": "i_exist"}))); i.response .content_type("application/json") .json_body(json!({"count": 1, "results": [{"i_exist"}]})); i }) .output_dir("pact_contracts") .start_mock_server(None);``` Other pact implementations seemed to get around this by using something called ?Upon Receiving? but i can?t find this anywhere in the rust docs. How am I able to achieve this ?

uglyog
2022-11-14 01:28
?Upon Receiving? sets the description for the interaction, which is the string parameter to the `interaction` function, which you have set correctly. Make sure you are not deleting the contents of the "pact_contracts" directory between the tests. That is the most common reason for this type of problem.

paul.ologeh
2022-11-15 21:37
I?ve not delete the file

paul.ologeh
2022-11-15 21:39
Are there any documented examples of what it would look like to generate a pact with multiple interactions or a pacts with different sets of payload/response pairs to the same endpoint



stevet
2022-11-16 06:53
has joined #pact-rust

stevet
2022-11-16 06:59
Hello I have just found the *pact_verifier_cli*, until now I have been using the standalone ruby provider-verifier From what I gather, the rust implementation seems to be the best moving forward? Can anyone confirm it allows injecting values from provider state callbacks? https://docs.pact.io/roadmap/feature_support says no but it seems to be in the changelog https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_verifier_cli/CHANGELOG.md

matt.fellows
2022-11-16 11:22
Yes, it doesn?t look to be documented (here: https://github.com/pact-foundation/pact-reference/tree/master/rust/pact_verifier_cli#state-change-requests) but in the state change requests, you will receive a payload with the provider state and any parameters (this endpoint will be called once per state for each tests i.e. there is a many-to-one relationship of states to tests). In the response to a state change URL, you can respond with a JSON object with any injected values. The keys in that JSON must match the keys for the value to be injected

stevet
2022-11-17 11:15
awesome, thank you

paul.ologeh
2022-11-22 18:56
Something strange is happening here. I clone the repository and run the tests locally and they still fail.

uglyog
2022-11-22 21:52
Hmm, are you running on OSX?

paul.ologeh
2022-11-22 21:52
yes

uglyog
2022-11-22 21:53
Ok, let me see if I can replicate it on an OSX machine

paul.ologeh
2022-11-22 21:55
when i do some crude debugging in the `http://pact_builder.rs` ``` pub fn push_interaction(&mut self, interaction: &dyn Interaction) -> &mut Self { trace!("Adding interaction {:?}", interaction); println!("current pact{:?}", self); println!("adding interaction {:?}", interaction); self.pact.add_interaction(interaction).unwrap(); println!("new pact{:?}", self); self }``` just to print what is happening with the pactbuilder. it looks like the interaction isn?t being saved ```current pactPactBuilder { pact: RequestResponsePact { consumer: Consumer { name: "test_two_interactions_consumer" }, provider: Provider { name: "test_two_interactions_provider" }, interactions: [], metadata: {"pactRust": {"consumer": "0.10.1", "models": "1.0.0"}, "pactSpecification": {"version": "3.0.0"}}, specification_version: V3 }, output_dir: None } adding interaction RequestResponseInteraction { id: None, description: "looks for something that doesn't exist", provider_states: [], request: Request { method: "POST", path: "/", query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"key\":\"i_dont_exist\"}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {DocPath { path_tokens: [Root], expr: "$" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }, PATH: MatchingRuleCategory { name: PATH, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } }, response: Response { status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"count\":0,\"results\":[]}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {HEADER: MatchingRuleCategory { name: HEADER, rules: {} }, BODY: MatchingRuleCategory { name: BODY, rules: {} }} }, generators: Generators { categories: {} } } } new pactPactBuilder { pact: RequestResponsePact { consumer: Consumer { name: "test_two_interactions_consumer" }, provider: Provider { name: "test_two_interactions_provider" }, interactions: [RequestResponseInteraction { id: None, description: "looks for something that doesn't exist", provider_states: [], request: Request { method: "POST", path: "/", query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"key\":\"i_dont_exist\"}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {DocPath { path_tokens: [Root], expr: "$" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }, PATH: MatchingRuleCategory { name: PATH, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } }, response: Response { status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"count\":0,\"results\":[]}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {HEADER: MatchingRuleCategory { name: HEADER, rules: {} }, BODY: MatchingRuleCategory { name: BODY, rules: {} }} }, generators: Generators { categories: {} } } }], metadata: {"pactRust": {"consumer": "0.10.1", "models": "1.0.0"}, "pactSpecification": {"version": "3.0.0"}}, specification_version: V3 }, output_dir: None } current pactPactBuilder { pact: RequestResponsePact { consumer: Consumer { name: "test_two_interactions_consumer" }, provider: Provider { name: "test_two_interactions_provider" }, interactions: [], metadata: {"pactRust": {"consumer": "0.10.1", "models": "1.0.0"}, "pactSpecification": {"version": "3.0.0"}}, specification_version: V3 }, output_dir: None } adding interaction RequestResponseInteraction { id: None, description: "looks for something that exists", provider_states: [], request: Request { method: "POST", path: "/", query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"key\":\"i_exist\"}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {DocPath { path_tokens: [Root], expr: "$" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }, PATH: MatchingRuleCategory { name: PATH, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } }, response: Response { status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"count\":1,\"results\":[\"i_exist\"]}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } } } new pactPactBuilder { pact: RequestResponsePact { consumer: Consumer { name: "test_two_interactions_consumer" }, provider: Provider { name: "test_two_interactions_provider" }, interactions: [RequestResponseInteraction { id: None, description: "looks for something that exists", provider_states: [], request: Request { method: "POST", path: "/", query: None, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"key\":\"i_exist\"}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {DocPath { path_tokens: [Root], expr: "$" }: RuleList { rules: [Type], rule_logic: And, cascaded: false }} }, PATH: MatchingRuleCategory { name: PATH, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } }, response: Response { status: 200, headers: Some({"Content-Type": ["application/json"]}), body: Present(b"{\"count\":1,\"results\":[\"i_exist\"]}", Some(ContentType { main_type: "application", sub_type: "json", attributes: {}, suffix: None }), None), matching_rules: MatchingRules { rules: {BODY: MatchingRuleCategory { name: BODY, rules: {} }, HEADER: MatchingRuleCategory { name: HEADER, rules: {} }} }, generators: Generators { categories: {} } } }], metadata: {"pactRust": {"consumer": "0.10.1", "models": "1.0.0"}, "pactSpecification": {"version": "3.0.0"}}, specification_version: V3 }, output_dir: None }```

paul.ologeh
2022-11-22 21:59
it?s probably a mac os specific issue. but it passed on your workflow https://github.com/pact-foundation/pact-reference/actions/runs/3457861379/jobs/5771709650 So i?m a bit confused. I?ve removed rust and installed it again and nothing. FYI ```pact-reference/rust on ? master [!?] via ? v1.65.0 on ?? ? rustup -V rustup 1.25.1 (bb60b1e89 2022-07-12) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.65.0 (897e37553 2022-11-02)` pact-reference/rust on ? master [!?] via ? v1.65.0 on ?? ? rustc --version rustc 1.65.0 (897e37553 2022-11-02) pact-reference/rust on ? master [!?] via ? v1.65.0 on ?? ```

uglyog
2022-11-23 00:47
It works ok on OSX for me, so that might not be the issue

uglyog
2022-11-23 00:48
Can you run it with trace logging, and send those though `RUST_LOG=trace cargo test test_two_interactions`

uglyog
2022-11-23 01:04
Maybe create a Github issue with the logs

yousafn
2022-11-29 19:16
Super stoked at the new changes to the FFI. I would imagine this kind of change should be at minor bump, not a patch, as we are introducing new features. It makes it difficult to look through a change log and say these are the new features I want, so I will update. Patch, I would expect to consume as an author without thinking and nothing should break for my end users. New features, means the author may need to do work, to bring new features to the masses. semver tag diff between patch versions https://github.com/pact-foundation/pact-reference/compare/libpact_ffi-v0.3.14...libpact_ffi-v0.3.15 For example this goldie https://github.com/pact-foundation/pact-reference/pull/229 is tucked away in a patch release https://github.com/pact-foundation/pact-reference/commit/768a132beec12daf6f1ce9e95f4b19ea86555eaa

yousafn
2022-11-29 19:17
epic work though Ron all round, smashing out the features and fixes

orbit
2022-12-01 15:45
has joined #pact-rust

j3rry.wan9
2022-12-08 06:13
has joined #pact-rust

j3rry.wan9
2022-12-12 07:18
Hello, is there an example for creating in-process Pact Mock Server programmatically using the `pact_mock_server` crate? I wanted to rewrite a legacy proxy server (written in Express.js) which 1) starts an in-process Pact Mock Server using the `pact_ffi` 2) forwards all incoming requests to Pact Mock Server first 3) then forwards those requests don't have a mapping in Pact Mock Server to a https://wiremock.org/docs/running-standalone/.

j3rry.wan9
2022-12-12 07:25
The FFI functions used to write this proxy server are `pactffi_create_mock_server` and `pactffi_mock_server_mismatches`.

uglyog
2022-12-12 08:00
Those FFI functions internally use the `pact_mock_server` crate. There are no examples using it, but there are some tests that do. See https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_mock_server/src/tests.rs#L258

j3rry.wan9
2022-12-12 20:25
Thanks! I will give it a try.

tien.xuan.vo
2023-03-06 06:12
Hi, I have one question about https://github.com/pact-foundation/pact-stub-server: I believe old Pact Stub Server (inside https://github.com/pact-foundation/pact-ruby-standalone/releases/tag/v1.91.0) has `healthCheck` feature . See https://github.com/pact-foundation/pact-php/pull/294 + https://github.com/pact-foundation/pact-php/blob/master/src/PhpPact/Standalone/StubService/Service/StubServerHttpService.php#L46 I wonder if Rust version want to add this feature? If this feature will never be in the Rust version, can I remove the code from `pact-php` (the code that use Pact Stub Server Rust version) ?

tien.xuan.vo
2023-03-08 07:02
Hi, another question about `Stub Server (Rust)` : If I run this command: ```PACT_BROKER_BASE_URL=abc ./vendor/pact-foundation/pact-php/bin/pact-stub-server/pact-stub-server --file tests/Contract/pacts/my-family-tree-relationship-my-family-tree-user.json``` I will got this error: ```2023-03-08T06:56:49.189486Z INFO main pact_verifier::pact_broker: Fetching path '/' from pact broker 2023-03-08T06:56:49.189512Z ERROR main pact_stub_server: There were errors loading the pact files. 2023-03-08T06:56:49.189515Z ERROR main pact_stub_server: - Invalid URL - relative URL without a base Error: ExitCode(unix_exit_status(3))``` I think stub server should load from the json file and ignore the env var `PACT_BROKER_BASE_URL` (and should not return that error). Is this a bug?

uglyog
2023-03-08 08:38
It was never meant to be a long running process

uglyog
2023-03-08 08:39
We can add a healthcheck, but I don't really see the value

uglyog
2023-03-08 08:41
No, that environment var is used for the `--broker-url` parameter

uglyog
2023-03-08 08:41
It is the same as adding `--broker-url abc`

tien.xuan.vo
2023-03-08 10:47
I created a PR to remove the `healthCheck` code from Pact PHP

tien.xuan.vo
2023-03-08 10:53
I mean: ? I didn't specify the `--broker-url` option manually, so I expect stub server didn't go to pact broker to look for pacts. ? the env var `PACT_BROKER_BASE_URL` was set by Github/Gitlab for the `publishing pacts` feature after running consumer's contract tests. I didn't know that it will force stub server ignore `--file` option and look for pacts on pact broker instead. It's unexpected to me.

uglyog
2023-03-08 22:22
That's how clap works (the crate that does the CLI parsing). If the env var is set, it is turning on the option

mark.ingram
2023-03-20 11:33
has joined #pact-rust

mark.ingram
2023-03-20 11:36
Hi - could you push a release up to http://crates.io for pact_consumer = 0.10.5 ? I?m hoping it?s the missing piece to support a clean ?cargo update? without pulling dupes of the other pact crates due to outdated deps.

christine.awofeso
2023-03-20 13:53
has joined #pact-rust

christine.awofeso
2023-03-20 13:57
Hi I've noticed pact_ffi_dll/0.4.1 is not available in conan. Is it possible for someone to release the package in conan. Working on a project which requires synchronous contract testing in C++ which is only available with pact v4

uglyog
2023-03-20 23:23
Done, 0.10.5 is released

uglyog
2023-03-20 23:24
The conan packages used to be released to bintray, but that has been shutdown.

uglyog
2023-03-20 23:25
There is no where to release to to now, Conan Center only supports packages that are written in C/C++

uglyog
2023-03-20 23:25
You can use the recipes from the repo, with a little bit of tweaking

mark.ingram
2023-03-21 08:50
Thanks!

adam.cox
2023-03-21 13:22
has joined #pact-rust

christine.awofeso
2023-03-22 15:48
@uglyog Do you have an example of how to create an asynchronous contract via pact ffi? I'm able to generate a synchronous contract but couldn't work out how to generate the correct asynchronous contract


christine.awofeso
2023-03-24 10:12
Thanks @uglyog can use this as a starting point and then figure out how to get the consumer contract generated for async messages

adam.cox
2023-03-29 08:46
Hi, We are facing an issue with intermittent failures when running multiple contract tests. For context we are continuing with the WebSockets plugin (consumer side is all working now :tada: ). We have some integration tests that test 4 scenarios: unexpected request, no request, request that partially matches and a matching request. All of the cases work *most* of the time. However occasionally we get a failure or two. The tests which fail are not consistent and the error we get is always ?transport error? which is coming from Tonic I believe. This error is proceeded by a few errors that look like this: ```connection error: hyper::Error(Io, Custom { kind: BrokenPipe, error: "connection closed because of a broken pipe" })``` If I run the tests with `--test-threads=1` it never fails. I have a feeling that its something to do with the plugin process already running and pact using it for all concurrent tests. Then it is being shut down before one of the tests has finished but I am not sure if that is the case or not and I am having a tough time debugging it. Any help would be appreciated. Not sure if this is better in #pact-plugins or #pact-rust, I guess that depends on what the problem turns out to be :thinking_face:

adam.cox
2023-03-29 14:18
When I am on a Teams call my CPU is slowed and there seems to be no issue. But when my laptop runs unimpeded I get the intermittent errors.

uglyog
2023-03-29 22:06
> When I am on a Teams call my CPU is slowed and there seems to be no issue Huh! That's the first time I have ever heard of Teams being useful :rolling_on_the_floor_laughing:

uglyog
2023-03-29 22:08
This smalls of a classic race condition issue. Those are going to be hard to debug. For a start, can you provide trace level logs (it will be very verbose, maybe attach as a separate file)

uglyog
2023-03-29 22:09
Can you provide the project with the tests? So I can try replicate the issue?

adam.cox
2023-03-30 09:01
Sure, sorry I should have pre-empted that question. I just need to work out a way of getting the repo to you.

adam.cox
2023-03-30 09:05
Logs are here

adam.cox
2023-03-30 09:13
The Teams thing might just be a coincidence I would be surprised if ti is actually useful, even in this case :wink:

adam.cox
2023-03-30 14:35
The repo is here: https://github.com/adamdama/pact-plugin-websockets I have added your GH users as collaborators to it

adam.cox
2023-03-30 14:36
Feel free to fork it if needed but please do not make it public. We have some compliance conversations to have about that

uglyog
2023-03-30 23:44
Yes, thanks, received the invite and we promise not to do anything until you say so :-D

uglyog
2023-03-31 04:52
I haven't been able to replicate this (no surprise there, as it seems to be load dependant). I tried both on LInux and Mac OS, but they passed with no issues. Reviewing the logs, it looks like everything is working correctly until the first test finishes, then the underlying HTTP2 client is setting it's state to `Closed` and the remaining tests can't interact with the plugin process. This seems to be all on the client side, as if there is a single HTTP2 client being shared.

uglyog
2023-03-31 04:55
Now the driver is creating a new Channel per request, so we can try a shared channel, so hopefully whatever is being dropped at the end of the test happens at the end of all the tests, but I am unable to test if that helps.

uglyog
2023-03-31 05:00
This seems to be the race condition: ```2023-03-30T09:02:47.517919Z TRACE Connection{peer=Client}:poll:FramedWrite::buffer{frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }}: h2::frame::go_away: encoding GO_AWAY; code=NO_ERROR 2023-03-30T09:02:47.517960Z TRACE Connection{peer=Client}:poll:FramedWrite::buffer{frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }}: h2::codec::framed_write: encoded go_away rem=17 2023-03-30T09:02:47.517970Z TRACE tonic::transport::service::reconnect: poll_ready; idle 2023-03-30T09:02:47.518011Z TRACE tonic::transport::service::reconnect: poll_ready; connecting 2023-03-30T09:02:47.518008Z DEBUG Connection{peer=Client}:poll: h2::proto::connection: Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library) 2023-03-30T09:02:47.518035Z TRACE hyper::client::connect::http: Http::connect; scheme=Some("http"), host=Some("127.0.0.1"), port=Some(Port(51856)) 2023-03-30T09:02:47.518048Z TRACE Connection{peer=Client}:poll: h2::proto::connection: -> already going away 2023-03-30T09:02:47.518096Z DEBUG hyper::client::connect::http: connecting to 127.0.0.1:51856 2023-03-30T09:02:47.518090Z TRACE Connection{peer=Client}:poll: h2::proto::connection: connection.state=Closing(NO_ERROR, Library) 2023-03-30T09:02:47.518126Z TRACE Connection{peer=Client}:poll: h2::proto::connection: connection closing after flush```

uglyog
2023-03-31 05:01
It's trying to open a connection (in the other test) while the HTTP2 client is in a going away state: `h2::proto::connection: -> already going away`

uglyog
2023-03-31 05:03
If it's a bit slower, it makes the connection before that, and on faster machines, it makes the connection after that state is cleaned up.

uglyog
2023-03-31 05:03
One thing to try is do a `cargo update` to make sure you have all the latest crates.

uglyog
2023-03-31 05:15
Another option is to add a retry with backoff, that way the odds will be that the retry happens after the first test has finished finishing.

uglyog
2023-03-31 05:32
Another another option is to look at the HTTP 2 keep alive settings

adam.cox
2023-03-31 08:13
OK so that sounds like a few options to me. Let me try to summarise and let me know if I am getting any of it wrong: ? Shared channel for requests - requires changes to plugin driver ? Cargo update - can be done on the WS plugin side ? Retry with backoff - requires changes to plugin driver ? HTTP2 Keep Alive - can be done on the WS plugin side. I?ll take a look at the Keep Alive and Cargo Update and report back as those are in my control

adam.cox
2023-03-31 08:14
The lack of reproducability of this issue is very frustrating. I go from periods of 20-30 runs without issue to a swathe of consistent failures

adam.cox
2023-03-31 08:14
Thanks for looking into this with me :slightly_smiling_face:

j3rry.wan9
2023-03-31 20:47
Hi, is there a reason why there is no Docker image for the latest Pact Verifier CLI 0.10.4 release? https://hub.docker.com/r/pactfoundation/pact-ref-verifier/tags

uglyog
2023-04-02 23:23
Oops! :slightly_smiling_face: let me fix that for you

j3rry.wan9
2023-04-03 00:46
Thank you!

adam.cox
2023-04-03 09:33
The cargo update didn?t seem to have any effect. I have enabled keep-alive on the plugin server now. Not sure if it has remedied the situation or not but I am not getting anymore test failures. Not sure if I trust it or not though as I might just be going through a ?success? period :face_with_spiral_eyes:

adam.cox
2023-04-03 14:40
I asked the whole team to test it and it worked for everyone who had not worked on the plugin. One team member had issues and after a reboot of his Mac the issue could no longer be reproduced.

uglyog
2023-04-05 01:33
Looks like I'm getting the same issue with our FFI based tests, but only with the protobuf plugin. The CSV plugin works fine, so it must be something one the plugin side that is causing this.


uglyog
2023-04-05 03:41
Disregard me

uglyog
2023-04-05 07:22
@adam.cox I have managed to get a similar issue with the gRPC examples when I introduced the shared channel change. I was seeing the second test failing with a transport error (but sometimes all passed). Turns out this was due to each test getting a separate Tokio runtime, and the race condition was if the second test tried to access the plugin while the first test had just finished, the connection was associated with the first test runtime which was shutting down. If the request is made before the first test finishes, it is all good because the runtime can execute the tasks, and if it is made after the first test runtime has completed the shutdown, then it seems to also be ok because it uses the connection associated with its own runtime.

adam.cox
2023-04-05 08:18
OK I think that makes sense to me. Still learning the whole tokio / async rust thing. So is the solution then to use ```Handle::current().spawn()``` For each test or something like that? Is there a way this could impact a user when running a multiple contract tests in their unit test suite? I would think so. So is it possible for us to fix this in the plugin/driver side to prevent users from having to write tests a certain way?

uglyog
2023-04-05 23:21
No, nothing like that. It's more about using globally configured objects and sharing them between the tests. Each test will have to create all the things it needs.

adam.cox
2023-04-19 13:39
Hello :slightly_smiling_face: I think I have found an inconsistency between pact_ffi and the rust implementation when creating sync message contracts. When using `pactffi_with_body` and adding a JSON body to the contract a metadata field is added with a contentType property [1]. However with the Rust implementation this property is not added [2]. Whats more is that it does not seem possible to add this metadata via the Rust SyncMessageBuilder API [2] or by using `.contents_from` [3] [1] Pact FFI: https://github.com/pact-foundation/pact-reference/blob/ac136ed57941fb09ee35cc34baf84da0c8d1409e/rust/pact_ffi/src/mock_server/handles.rs#L1286 [2] Pact-Rust: https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_consumer/src/builders/sync_message_builder.rs#L272 [3] Pact-Rust: https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_consumer/src/builders/sync_message_builder.rs#L133 This is currently causing a problem in our plugin where contracts made from rust clients look different to contracts made with C++ clients for the same requests. We can adjust the plugin to handle it but thought I would raise this here.

matt.fellows
2023-04-20 00:37
Thanks Adam. There is possibly a good reason for it, but the core maintainer (Ron) is currently off for the next couple of weeks on PTO. Would you mind please creating an issue in the pact-reference repo?

tien.xuan.vo
2023-04-21 04:30
Hi, I'm not sure which channel is the best to ask this question, so I asked here. If there are no provider states (in pact-js, set `states: []`, not sure about other language, maybe not calling `given()`), pact verifier will still call provider to setup/teardown with empty state (`""`) https://github.com/pact-foundation/pact-reference/blob/master/rust/pact_verifier/src/lib.rs#L599 Is this intended? I think it's a bit weird.

matt.fellows
2023-04-21 05:10
Yes, it was a feature request. It allows you to setup before/after hooks in the test cycle

tien.xuan.vo
2023-04-21 10:53
Thanks. So in case there are absolutely nothing to setup/teardown, I think it's a bit better to set `states: [{ description: 'Nothing to setup/teardown' }]` than `states: []` , because: ? In both cases, we need to create provider state handler anyway. ? The one with description is more clearer.

yousafn
2023-04-21 12:09
Question for any VSCode users - If you open the https://github.com/pact-foundation/pact-reference/ project, does it load for you, and show an editor window? Mine seems to be borked at the top level - I can't seem to get an editor window :doom-mad:probably a pebkac issue, especially as I have 120 extensions installed :headdesk: I rubby duckied myself whilst writing this and it was an editor option, `justify` - Now I have my editor window back yey

tien.xuan.vo
2023-04-21 12:14
Mine it's normal like opening other project

yousafn
2023-04-21 12:16
I must have changed the editor option somehow by accident, probably with some obscure key press combination and couldn't work out why. All sorted now :pray: Just thought I would still post it back

tien.xuan.vo
2023-04-26 17:40
Hi, pact-js has `url2` method, which allow to use the generator `MockServerURL` to generate url with the mock server as the base URL. It work as expected. But stub server (rust version - https://github.com/pact-foundation/pact-stub-server) doesn't support that generator. Is it expected? Here is the demo code https://github.com/tienvx/test-mock-server-url-generator

adam.cox
2023-04-26 18:58
Sorry for the late response. Yes I will open an issue for this tomorrow. I have also spotted something with the pact-standalone-verifier not exposing the scheme that has tripped us up so will open one for that as well

matt.fellows
2023-04-27 11:59
interesting. Maybe it just needs an internal version bump and new release?

matt.fellows
2023-04-27 11:59
ah, actually was released 2 weeks ago, so you?d imagine it would be there given that method was added ages ago.

matt.fellows
2023-04-27 11:59
mind raising an issue on that repo?

matt.fellows
2023-04-27 12:33
lovely, thank you

tien.xuan.vo
2023-04-27 15:53
Will do. But first I need to understand this is a bug or not (from my side). I think documents about matchers and generators are not quite clear to me (I even think there are no document for generators? There are some here https://github.com/pact-foundation/pact-specification/tree/version-4#generators but it doesn't tell *where* or *when* they are used) so I make a summary on this: According to this page https://docs.pact.io/implementation_guides/rust/pact_ffi/integrationjson, there are 3 *attributes* to worry about: ? Matcher (type, and its configuration) ? Generator (type, and its configuration) ? Example value There are 3 *entities* (that I think) use those attributes: ? Consumer's contract test (use mock server) ? Consumer's integration test (use stub server) ? Provider (called by provider verifier) I assume: ? Mock server --- (provide) -----> Example value ----- (to) ------> Consumer's contract test ? Stub server --- (provide) -----> Example value ----- (to) ------> Consumer's integration test ? Provider verifier --- (use) -----> Matcher ------ (to verify with) -----> Provider ? I *assume*, if there is generator specified (except `ProviderState` and `MockServerURL`): Mock server --- (use) ---> Generator --- (to generate random data, then send to) ---> Consumer's contract test ? If generator is `ProviderState` : Provider verifier --- (grab value from) ---> Provider state handler --- (then send it to) ----> Provider ? If generator is `MockServerURL` : Mock server --- (replace base url from) ---> Example value ----- (then send it to) -----------> Consumer's contract test I'm *assuming* that stub server (rust version) *doesn't care* about generators at all? I'm not sure, I didn't use generators other than `ProviderState` and `MockServerURL`. I think the behavior should be: ? Stub server --- (provide) -----> Example value ----- (to) ------> Consumer's integration test ? if there is generator specified (except `ProviderState` and `MockServerURL`): Stub server --- (use) ---> Generator --- (to generate random data, then send to) ---> Consumer's integration test ? If generator is `MockServerURL` : Stub server --- (replace base url from) ---> Example value ----- (then send it to) -----------> Consumer's integration test If all of my *assumptions* are correct, I will create 2 tickets for the last 2 items: ? Stub server should use generators if specified ? Stub server should replace base url if generator `MockServerURL` is specified


tien.xuan.vo
2023-05-02 03:03
I tested the generator `RandomInt` and both Mock Server and Stub Server use this generator. So I think that Stub Server doesn't replace url if generator `MockServerURL` is specified is a bug to me. I will create the ticket

tien.xuan.vo
2023-05-02 03:29
I think we should document these flows (in sequence diagram?)



tien.xuan.vo
2023-05-02 04:58
I tested with ```{ 'pact:generator:type': 'RandomInt', 'pact:matcher:type': 'integer', // value: 101, <--------------- I can't remove this, it's still needed for stub server, not sure why }``` So either my diagram is wrong (about example value on stub server), or stub server has another 'bug' here

matt.fellows
2023-05-05 11:41
Thanks Tien - I think this is all really helpful. We should include this in the maintainer guide we?re about to pick up, what do you think @uglyog?

uglyog
2023-05-08 00:39
the maintainer guide sounds like a holy grail that is going to solve all our problems

matt.fellows
2023-05-08 00:40
Well, i?m hoping it can capture some of these tricky ones that seem to trip us up

clm.whyte
2023-05-18 09:50
has joined #pact-rust

clm.whyte
2023-05-19 16:34
@clm.whyte has left the channel

tien.xuan.vo
2023-05-31 04:30
Symfony Process has a feature to https://symfony.com/doc/current/components/process.html#setting-environment-variables-for-processes any environment variable from the process. I use that feature to remove `PACT_BROKER_BASE_URL` from `pact-stub-server` process, and it will load pact file I specified. All good for me.

mark.ingram
2023-06-12 20:12
Has there ever been any discussion whether it would be desirable/feasible to slim down the transitive dependencies of the Pact crates for simpler use cases? I find myself reluctant to add Pact right now to the main project workspace as the deps added to the Cargo.lock dwarf the (admittedly simple) set that are currently used in my Axum / JSON Rest service. I wonder if I?m missing the intended usage pattern? See the attached graph from the pact_consumer crate `cargo depgraph --build-deps --filter-platform x86_64-unknown-linux-gnu --dedup-transitive-deps | dot -Tpng > pact_consumer_graph.svg`

mark.ingram
2023-06-12 20:17
things this service doesn?t have: ? any need for a plugin - `tonic` ? Date times - `chrono` / tz data plus `http://build.rs` ? XML -`sxd-document` ? Compression - `zip`, `flate`, `zstd` etc. ? TLS - `hyper-rustls` ? not sure why it depends on a CLI tool? - `clap`

mark.ingram
2023-06-12 20:19
I?m investing time in our build cacheing (via `cargo-chef`) which would mitigate the (essentially pointless) recompilation of all these crate sub trees on each commit, but it would be lovely to drop the need via a hypothetical `default-features = false`

uglyog
2023-06-13 00:44
Adding features makes sense. Please raise a issue with this request


matt.fellows
2023-08-04 05:54
Is that compatibility suite finding bugs @uglyog?


matt.fellows
2023-08-04 06:01
so it was worth it then :laughing:

uglyog
2023-08-04 06:01
Well, I don't know how many use binary data with message pacts ...

matt.fellows
2023-08-04 06:06
Can?t be many, otherwise we?d probably have seen a bug report by now

uglyog
2023-08-04 06:09
The bug has only been around for 2 years, so fairly young one

theteea
2023-08-25 13:26
has joined #pact-rust

yousafn
2023-08-29 20:36
Are these notes correct. > *Linux aarch64 (Apple M1)* Linux aarch64 != apple m1 :shrug: @uglyog

yousafn
2023-08-29 20:37
> If you need to run the Pact FFI on Apple M1 machines, you will have to use the MacOS binary dynlib and not run it via docker. You would use the macos bin dynlib natively. Via docker, I suppose they could fix to use platform linux/amd64. but thats also wider that just affecting macos users, as it affects anyone on linux aarch64 machines - rasp pies for example Happy to take a look at the aarch64 linux building issue

uglyog
2023-08-29 23:08
Yeah, that be true. Still, it's not building for them too.

uglyog
2023-08-29 23:11
> Originally there was just the 32-bit architecture, called "ARM". Then https://en.wikipedia.org/wiki/ARM_architecture_family#Armv8-A the ARMv8-A spec added a new 64-bit execution state called "AArch64", retroactively renaming the old 32-bit architecture "AArch32". Then to add a bit more confusion, in 2017 the company https://en.wikipedia.org/wiki/Arm_(company)#Name from being called "ARM" (an acronym for "Advanced RISC Machines") to just "Arm". > Support for AArch64 was added to Linux in 2012. The patchset was initially called "aarch64" but was https://lkml.org/lkml/2012/7/6/624 to "arm64". The LLVM community and Apple started working in parallel to support it in clang in 2012, the LLVM community called it "aarch64" and Apple called it "arm64". Apple open-sourced their changes and the two efforts lived together in LLVM under their different names and were eventually https://www.phoronix.com/news/MTY5ODk so LLVM/clang now just calls it "aarch64". So it is both for ARM and Apple M1 processors

yousafn
2023-08-29 23:19
Ahhh, so its affecting our aarch64/arm64 builds. the nomenclature is confusing at best xD I got confused when I saw this commit, that just disabled, the linux aarch64 builds, looked through the actions, and couldn't find the failing builds, but didn't look more than 2 pages and everything was green(ish)

yousafn
2023-08-29 23:20
more confused, because aarch64/arm64 macos binaries are there https://github.com/pact-foundation/pact-reference/releases/tag/libpact_ffi-v0.4.8

yousafn
2023-08-29 23:23
That is really interesting back story about apple and llvm working in parallel for clang support, that makes more sense looking at some of the build scripts across the various languages and tooling

uglyog
2023-08-29 23:25
It's not Macos binaries, but Linux binaries for that architecture.

uglyog
2023-08-29 23:29
For people who want to use Docker on M1 without XF86 simulation. See https://github.com/pact-foundation/pact-reference/issues/160#issuecomment-1203570468

yousafn
2023-08-29 23:34
ahh gotcha Ron. Cirrus has arm64 native runners, if you want to try building natively without cross

marko.justinek
2023-09-02 00:20
sorry guys, I have this thing on my todo where I was to add/update the build script to build one XCFramework for darwin+iOS+mac_catalyst instead of having all these `.a` bins. Just haven?t gotten to it yet. :shrug:

joshua.ellis
2023-09-04 04:56
has joined #pact-rust

yousafn
2023-09-15 10:13
don?t know if we have any freebsd users who also use Pact, i?ve never seen a request for freebsd platform, however it?s not stopping me from wanting to build pact for all the things. there is now an aarch64-unknown-freebsd image available with cross-rs. https://github.com/cross-rs/cross/pull/1271#pullrequestreview-1627783434

christine.awofeso
2023-12-18 15:58
Hi not sure if this is the right place to ask about the pact rust standalone verifier. In the organisation I am working for we want to roll out contract testing and one of the things we require is for the providers to be able to filter by the request path. This is because we don't want to run the whole provider service for each contract verification (as it would take too long). I know it's possible to filter by description and tags but we don't want to rely on the consumers to enter the right description to help the provider decide which part of the provider system to run the verification for. It would be nice if we can use the standalone verifier to filter by request path. Is this something that is possible?

matt.fellows
2023-12-18 21:57
I don?t think it?s supported currently. Note that you won?t be able to publish results to the broker this way, because the verification results are all/nothing as far as the broker is concern (i.e. you can?t incrementally publish results)

matt.fellows
2023-12-18 21:58
You could look to add the feature though if that?s what you need

christine.awofeso
2023-12-19 09:42
Hi @matt.fellows thanks for the response

christine.awofeso
2023-12-19 09:44
Are you saying that if we were to implement the feature to filter out contract by a provider and request path that we won't be able to publish verification results for those specific contracts because we didn't download all the contracts by a particular provider?

christine.awofeso
2023-12-19 10:31
Or is it only in the case where you have multiple interactions in a pact between a single consumer-provider?

matt.fellows
2023-12-19 11:52
As soon as you filter, the verification results are invalid (or at the very least, not very useful) because by definition the overall result of the test is "unverified" as some interactions weren't verified. A subsequent verification that includes the previous missing one, but excludes the just validated ones will have the same effect (only different interactions will now be unverified). I.e. you can't incrementally verify a contract

matt.fellows
2023-12-19 11:52
That could potentially be a feature we add support for, but just understand the limitation

christine.awofeso
2023-12-19 12:07
That makes sense thanks @matt.fellows

sterankin
2024-01-12 11:46
has joined #pact-rust

sterankin
2024-01-12 12:21
are there any examples of how to use the Rust FFI implementation in ruby? Since ruby only has v2 support, I need to support v4 specifications from other languages. However having never used Rust or FFI before it would be great to have an example to see how it could replace the ruby gem for a provider. At this point I have installed rust, pulled down the Rust project from Github, ran `cargo build`. I have also installed the rubygem `ffi` in the provider project.


sterankin
2024-01-12 21:26
Thanks Matt, so do I use that gem instead of the old Ruby one. It can be used to act as a provider?

matt.fellows
2024-01-12 21:27
I'm not sure, I'm just digging up examples. There's another somewhere also

sterankin
2024-01-12 21:28
Ok thanks. I was under the impression I needed to use the rust library, compile it and reference it in Ruby using the ffi gem. But that's all guesswork at this point :+1: hopefully you find something

matt.fellows
2024-01-12 21:30
You probably don't need to compile it. As we already have compiled targets. You will probably need to use an ffi gem (or another lib inbuilt or otherwise) to interface to the FFI (C interface)

matt.fellows
2024-01-12 21:31
Here's the other example repo: https://github.com/YOU54F/hello_ffi

sterankin
2024-01-15 11:28
Would be great if there were some examples of how the `pact_helper.rb` should look when using the FFI implementation, and and example of `provider_states` also

yousafn
2024-01-15 19:50
Hey @sterankin I?ve created a Ruby Gem which has a dep of the FFI gem and the pact ffi library. https://github.com/YOU54F/pact-ruby-ffi It has most of the methods exposed from the Rust FFI. I partially started to integrate it into the existing Pact Provider Verifier (Ruby based) but didn?t get very far as got distracted by other stuff but there should are some examples in this repo that may help

yousafn
2024-01-15 19:52
> Ok thanks. I was under the impression I needed to use the rust library, compile it and reference it in Ruby using the ffi gem. But that?s all guesswork at this point :+1: hopefully you find something The Pact-Reference provides shared libraries in the releases section under pact_ffi. These are shared libraries which you can load with the `ffi` gem. You need to map the methods exposed by the FFI in C (pre compiled from Rust) in Ruby, and then you can use them as though they are somewhat native to Ruby. Feel free to let us know how you get on, and happy to help answer any questions. PS. Happy for anyone to fork and hack on that repo, or start afresh :slightly_smiling_face: not precious about it

yousafn
2024-01-15 19:54
nice little example post to maybe get you started with ruby + ffi https://www.rubyguides.com/2019/05/ruby-ffi/

sterankin
2024-01-15 20:44
Thanks for that. I did get it working to a certain extent but I'm just not sure what attached methods need to be called or used, for example how would you write this using the ffi implementation: ```# In spec/service_consumers/pact_helper.rb require 'pact/provider/rspec' Pact.service_provider "Animal Service" do honours_pact_with 'Zoo App' do # This example points to a local file, however, on a real project with a continuous # integration box, you would use a [Pact Broker](https://github.com/pact-foundation/pact_broker) or publish your pacts as artifacts, # and point the pact_uri to the pact published by the last successful build. pact_uri '../zoo-app/spec/pacts/zoo_app-animal_service.json' end end```


sterankin
2024-01-18 16:01
I have been reviewing the example above and I am struggling to understand what is happening here. So you are having to manually start the mock server in code, none of it is abstracted away like the ruby gem is? If you simply want to pull down pact file from a broker, run them and publish the results can that not be achieved simply as before? ```Pact.service_provider "Provider-app" do publish_verification_results true honours_pacts_from_pact_broker do pact_broker_base_url "http://localhost:9292/" app_version "1.0.0" app_version_branch "main" app_version_tags ["foo", "bar"] end end```

yousafn
2024-01-18 16:12
> none of it is abstracted away like the ruby gem is? correct., pact-ruby provides a nice dsl to the user as shown in your example. pact-ruby-ffi gem has the glue code which allows the individual methods to be called in the rust backend core. They haven?t been integrated together yet You can either 1. utilise pact-ruby-ffi in its raw form, and call the individual methods to setup your verifier, a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L43-L47 2. integrate pact-ruby with pact-ruby-ffi, such that behind the scenes to the user, the input parameters are mapped to the relevant ffi functions. This is the ultimate aim, I would imagine, and the path of least resistance for end users of the pact-ruby library. > I have been reviewing the example above and I am struggling to understand what is happening here. So you are having to manually start the mock server in code In the code above, 1. I am using fake provider application, which I am starting before the test, so that my Pact verifier, has a real endpoint to call. a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L9-L35 2. I instantiate the pact verifier a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L36 3. I pass various options to the verifier. In this case, the provider info (name, base path, port) and the Pact source ( a file in this case) a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L43-L45 4. I then call the verifier, which will issue requests to my provider, and return the results a. https://github.com/YOU54F/pact-ruby-ffi/blob/c29c7bce58e8c87c40a894f379dfac12868e2375/spec/pactffi_verifier_spec.rb#L46

sterankin
2024-01-18 16:13
Thanks kindly for the explanation and clarification

yousafn
2024-01-18 16:17
You would need to use these functions, in order to retrieve from pacts from a broker, and publish results, the latter two aren?t shown in the above example. They are exposed in the https://github.com/YOU54F/pact-ruby-ffi/blob/main/lib/pact/ffi/verifier.rb to Ruby clients ? https://docs.rs/pact_ffi/latest/pact_ffi/verifier/fn.pactffi_verifier_set_provider_info.html ? allows you to set the ?? name: *const c_char, ?? scheme: *const c_char, ?? host: *const c_char, ?? port: c_ushort, ?? path: *const c_char ? https://docs.rs/pact_ffi/latest/pact_ffi/verifier/fn.pactffi_verifier_broker_source_with_selectors.html ? allows you to set a broker source, with consumer version selectors ? https://docs.rs/pact_ffi/latest/pact_ffi/verifier/fn.pactffi_verifier_set_publish_options.html ? publication options

matt.fellows
2024-01-18 22:17
> I have been reviewing the example above and I am struggling to understand what is happening here. So you are having to manually start the mock server in code, none of it is abstracted away like the ruby gem is? > > If you simply want to pull down pact file from a broker, run them and publish the results can that not be achieved simply as before? exactly. To elaborate, the rust core is a low level C interface that provides all of the capabilities for any language to integrate and use. e.g. Pact JS has a high level DSL for users, but under the hood it maps to all of these functions.