Hi everyone! I'm currently trying to setup the pac...
# pact-plugins
j
Hi everyone! I'm currently trying to setup the pact-protobuf plugin, I've setup a skeleton test and am trying to run it with the plugin installed but getting
pact_ffi::plugins: Failed to call out to plugin - Request to configure interaction failed: Failed to process protobuf: Failed to invoke protoc binary: exit code exit status: 1
back when running it. I've checked in the plugins dir that it has actually downloaded
protoc
and the executable is accessible - any help would be appreciated!
y
Hey, can you provide some details on your machine, is this in ci, or locally?
j
Hi Yousaf, I'm running the test locally, on a ubuntu machine. I installed the pact-plugin-cli binary and then installed the plugin through that
Also I'm trying to write consumer side tests in JS if that's relevant
y
have you got
protoc
executable on the command line?
protoc --version
https://grpc.io/docs/protoc-installation/ if that works, can you invoke the protobuf plugin directly, to run the plugin? There is a grpc example here in the pact-plugin repo, you could try that for starters to check it isn’t something in your test. https://github.com/pact-foundation/pact-plugins/pull/55
j
I don't, but I did notice one was bundled with the plugin
When I do run the executable in the plugin it does look like its starting a mock server
{"port":41785, "serverKey":"3ddf4cc4-fbcd-4a1c-9db3-b513fc0e57af"}
👍 1
y
There is, it’s a bit old (the bundled one) and doesn’t work for macos arm64 OOB, which is why I asked about platform. I think protoc does need to be available on the path, so could you try installing the protobuf-compiler and see how you get on? It may be that it is actually calling it, but can’t find your protobuf file, so protoc is failing. What does your grpc interaction look like, specifically the path to the protobuf file
also is there any logs in the pact protobuf plugin directory, post execution of your skeleton test
j
Ah! I think I've found it, looks to have been the file path to the
.proto
file. Many thanks!
🙌 1
Further to this - is there any documentation on matchers and their use that I could take a look at? I've had a look at some examples but I've only seen ones that follow this pattern
"numbers": "atLeast(1), eachValue(matching(regex, '\\d+', '100))"
for repeated fields. If say for example I had a repeated list of objects (potentially containing different types of primitive) instead of a repeated primitive as above, how would I handle that?
y
docs for matchers are here https://docs.pact.io/implementation_guides/pact_plugins/docs/matching-rule-definition-expressions although that doesn’t look to have synced in a while source is here https://github.com/pact-foundation/pact-plugins/blob/main/docs/matching-rule-definition-expressions.md you can compose expressions. If you can create an example with your scenario, it’s easier for me to visualise 👍
j
Thanks for sending that Yousaf. This is what I'm trying to do
m
hmmm. The doc seems to imply it would take the shape from
Asset
but not require that field. @rholshausen any ideas?
r
Looks like a bug. Are you using the latest version of the protobuf plugin?
👍 1
j
@rholshausen I believe this is the latest
r
Yeah, that is
j
Is it possible this worked on a previous version that I could downgrade to?
r
I'm unsure, I won't be able to tell. I looked at some recent commits, but could not see anything that would result in a regression. But there has been a lot of work in this space recently.
Better just to fix the issue
That form definitely works, there is a test for it in the plugin project: https://github.com/pactflow/pact-protobuf-plugin/blob/main/tests/each_value_tests.rs#L29
Can you provide the proto file? Or try change the example name to something like ExampleAsset?
Ah, think I see the problem. I think it should be
Copy code
"pact:match": "eachValue(matching($'Asset'))
and not
"pact-match":
💡 1
j
d'oh
😆 1
m
Perhaps we can detect invalid pact prefixes and error/warn