Eric Muller
04/08/2024, 3:59 PMEric Muller
04/08/2024, 7:25 PMCody A. Ray
04/08/2024, 8:07 PMrholshausen
04/09/2024, 11:50 PMEric Muller
05/01/2024, 4:12 PMEric Muller
05/08/2024, 5:34 PMEric Muller
05/08/2024, 11:13 PMrholshausen
05/08/2024, 11:18 PMMatt (pactflow.io / pact-js / pact-go)
rholshausen
05/08/2024, 11:35 PMrholshausen
05/10/2024, 1:04 AMStanislav Vodetskyi
05/31/2024, 10:22 PMStanislav Vodetskyi
05/31/2024, 10:52 PMStanislav Vodetskyi
06/01/2024, 12:21 AMEric Muller
06/01/2024, 12:27 AMEric Muller
06/01/2024, 12:29 AMEric Muller
06/01/2024, 12:30 AMEric Muller
06/01/2024, 12:32 AMEric Muller
06/01/2024, 12:32 AMStanislav Vodetskyi
06/01/2024, 12:35 AMcargo test --lib
from under integrated_tests/imported_message
folder, my changes to the protobuf plugin library are not being respected - like do you need to literally recompile it and put it under ~/.pact/plugins/... folder?Eric Muller
06/01/2024, 12:36 AMStanislav Vodetskyi
06/01/2024, 12:36 AMStanislav Vodetskyi
06/01/2024, 12:39 AMEric Muller
06/01/2024, 12:39 AMStanislav Vodetskyi
06/01/2024, 12:39 AMEric Muller
06/01/2024, 12:42 AMStanislav Vodetskyi
06/01/2024, 12:44 AMStanislav Vodetskyi
06/01/2024, 12:44 AMStanislav Vodetskyi
06/01/2024, 1:25 AMfind_message_descriptor
function is used to resolve protobuf descriptors in multiple places, both when finding input/output messages and when building a response field.
Because this function is called from different spots, it can cause failures in different scenarios:
• If response message is in a different file from a request message - if you have request.proto
with RequestMessage
and response.proto
with ResponseMessage
and service.proto
which defines grpc service using request and response above. Existing implementation will search service.proto
first, won't find RequestMessage
, will search all available protos and pick the first one it finds, leading to semi-random failures.
• If your field type is in a different file - if you have rectangle.proto
with Rectangle
and then service.proto
with GetRectangleResponse
which contains field of type Rectangle
- existing implementation is exactly the same, though called from a different place in the code.
The fix (and I need to test it a bit more) is like so:
• when searching for file descriptors for a specific package, current implementation stops at the first file; fix is to gather all files where package matches.
Then there's a slightly different issue which I initially thought to be a root cause. When calling find_message_descriptor
here: https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/mock_server.rs#L251 - the package can be empty/nil - in such cases current implementation will search all proto files. I think a good fix here would be to default to the package name from the file descriptor. This should allow us to specify service names without specifying a package, e.g. GetRectangle
instead of rectangle/GetRectangle
or smthStanislav Vodetskyi
06/01/2024, 1:28 AMrholshausen
06/03/2024, 1:45 AMStanislav Vodetskyi
06/03/2024, 2:37 AMStanislav Vodetskyi
06/03/2024, 11:29 PMrholshausen
06/03/2024, 11:29 PMStanislav Vodetskyi
06/04/2024, 12:10 AMStanislav Vodetskyi
06/04/2024, 12:11 AMStanislav Vodetskyi
06/04/2024, 12:12 AMStanislav Vodetskyi
06/04/2024, 12:23 AMfind_message_by_name
function inside <http://protobuf.rs|protobuf.rs>
, not sure they're needed anymore, ok to delete them? or combine with the one in <http://utils.rs|utils.rs>
?
https://github.com/pactflow/pact-protobuf-plugin/blame/main/src/protobuf.rs#L2708rholshausen
06/04/2024, 12:24 AMrholshausen
06/04/2024, 5:43 AMStanislav Vodetskyi
06/04/2024, 4:29 PM"pact:proto": proto_file,
"pact:protobuf-config": {
"additionalIncludes": [ proto_include ]
},
what we can do:
"pact:protos" [ proto_files_list ]
Stanislav Vodetskyi
06/04/2024, 4:30 PMStanislav Vodetskyi
06/04/2024, 11:46 PMrholshausen
06/04/2024, 11:47 PMStanislav Vodetskyi
06/04/2024, 11:49 PMtests
which don't have package, so those tests are failing now. Let me fix it.Stanislav Vodetskyi
06/04/2024, 11:52 PMrholshausen
06/04/2024, 11:53 PMrholshausen
06/04/2024, 11:53 PMStanislav Vodetskyi
06/05/2024, 12:00 AMrholshausen
06/05/2024, 12:00 AMStanislav Vodetskyi
06/05/2024, 12:02 AMPrimary
in a different package, it might failStanislav Vodetskyi
06/05/2024, 12:03 AMStanislav Vodetskyi
06/05/2024, 6:52 AMtests
folder too to verify it all works correctly.Stanislav Vodetskyi
06/06/2024, 1:31 AMparse_proto_file
function, just to check it resolves everything correctly, but it's mostly using a 3rd party lib anyway, so we should be ok.Stanislav Vodetskyi
06/06/2024, 1:40 AMStanislav Vodetskyi
06/06/2024, 8:18 PMStanislav Vodetskyi
06/06/2024, 11:16 PM<http://mod.rs|mod.rs>
to use the new package-bound search vs searching by namerholshausen
06/06/2024, 11:17 PMStanislav Vodetskyi
06/06/2024, 11:17 PMfind_message_type_by_name
so I'm sure there are other edge cases, but baby steps 🙂Stanislav Vodetskyi
06/06/2024, 11:37 PMStanislav Vodetskyi
06/07/2024, 12:05 AMrholshausen
06/07/2024, 12:05 AMStanislav Vodetskyi
06/07/2024, 12:17 AMrholshausen
06/07/2024, 12:17 AMStanislav Vodetskyi
06/07/2024, 12:41 AMmock_server_with_no_requests
The error is:
assertion failed: `expected to be equal to <"plugin mock server failed verification:\n 1) Test/GetTest: Did not receive any requests for path 'Test/GetTest'\n">, got <"status: Unknown, message: \"transport error\", details: [], metadata: MetadataMap { headers: {} }">`, tests/mock_server_tests.rs:61:5
and when I run on my laptop (arm mac) it passesrholshausen
06/07/2024, 12:42 AMStanislav Vodetskyi
06/07/2024, 12:44 AMrholshausen
06/07/2024, 12:45 AMrholshausen
06/07/2024, 12:46 AMStanislav Vodetskyi
06/07/2024, 12:47 AMStanislav Vodetskyi
06/07/2024, 1:18 AMrholshausen
06/07/2024, 1:19 AMStanislav Vodetskyi
06/07/2024, 1:22 AMrholshausen
06/11/2024, 1:22 AMrholshausen
06/11/2024, 1:24 AMStanislav Vodetskyi
06/11/2024, 5:26 AMMatt (pactflow.io / pact-js / pact-go)
Stanislav Vodetskyi
07/20/2024, 1:13 AMsplit_name
vs last_name
and call a different utils func. I just need to clean it up and will send a PR on Monday
The other one is here: https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/utils.rs#L482
This one is a bit more challenging to fix because the pact file doesn't actually contain the definitive package.
In the code we're looking for a service descriptor based on the service name from the plugin_config
in the incoming pact, e.g.:
"pluginConfiguration": {
"protobuf": {
"descriptorKey": "0570660012c5de20fd96c4adef9e4aeb",
"service": "RouteGuide/GetFeature"
}
}
The fix would be to add package info to the plugin_config.protobuf
entry when generating pact file in consumer tests.
This will fix all new pacts, but we'll have to fallback to the old behavior when encountering old pacts, which is likely unavoildable.
I'll submit a separate PR for this one too.
Alternatively, we can try to parse the protoFile
entry under `configuration`:
"plugins": [
{
"configuration": {
"0570660012c5de20fd96c4adef9e4aeb": {
"protoDescriptors": "<contains all proto descriptors, both the service proto and additionalIncludes>",
"protoFile": "<only contains the actual proto file with the service definition>"
}
},
"name": "protobuf",
"version": "0.4.0"
}
]
but the protoFile
is a plaintext .proto
file so we'll need to either parse it into a descriptor or go line by line until we find a package
line. Both seem pretty hacky, but might be a good way to maintain backwards compatibility.
WDYT?Stanislav Vodetskyi
07/20/2024, 1:42 AMrholshausen
07/22/2024, 1:14 AMrholshausen
07/22/2024, 1:15 AMStanislav Vodetskyi
07/22/2024, 11:50 PMservice
entry from Service/Method
to package.Service/Method
but if I do this, there's no way I can distinguish between two cases. It might be better to have a separate package
field - if it's not present, revert to old behavior; if it is present but is null
in the json, use new behavior to search for service without a package. Alternatively we can check the version of the plugin from the configuration, but idk if this data is easily available in all places we need;rholshausen
07/22/2024, 11:52 PMsource protobuf file had no package specifiedIs this valid? I couldn't create a valid project without a package, but that may have been a Go restriction (but I'm not a Protobuf expect)
Stanislav Vodetskyi
07/22/2024, 11:59 PMStanislav Vodetskyi
07/22/2024, 11:59 PMgo_package
directive is mandatory, but package
is optionalStanislav Vodetskyi
07/22/2024, 11:59 PMprotoc
against it if memory serves (this was when I was fixing the previous case above)Stanislav Vodetskyi
07/23/2024, 12:16 AMlookup_service_descriptors_for_interaction()
which parses interaction config; so I can read the package
field there.
Where's the corresponding case for message interaction? I'd like to add package
field for both while I'm at it.rholshausen
07/23/2024, 12:24 AMStanislav Vodetskyi
07/23/2024, 4:25 PMrholshausen
07/23/2024, 11:47 PMStanislav Vodetskyi
07/31/2024, 12:46 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Stanislav Vodetskyi
07/31/2024, 2:14 AMMatt (pactflow.io / pact-js / pact-go)
Stanislav Vodetskyi
07/31/2024, 6:38 AMStanislav Vodetskyi
07/31/2024, 6:43 AMcompare_request
func, which calls compare_request_impl here: https://github.com/pactflow/pact-protobuf-plugin/blob/main/src/server.rs#L188
It has branching to handle both message and service paths, but I'm not sure how to trigger it for the service
case.
Message case is triggered when verifying a message (non-grpc) provider, e.g. like here: https://github.com/pact-foundation/pact-go/blob/master/examples/protobuf-message/protobuf_provider_test.go
When verifying GRPC provider, a different function is called - verify_interaction
When is the compare_contents()
called with service
pact?rholshausen
07/31/2024, 6:53 AMrholshausen
07/31/2024, 6:54 AMrholshausen
07/31/2024, 6:55 AMStanislav Vodetskyi
07/31/2024, 6:55 AMStanislav Vodetskyi
07/31/2024, 6:58 AM:
in several places in the code, but it's either not documented well, or I have missed the doc where it says how to use it.
https://github.com/pactflow/pact-protobuf-plugin/blob/2b7d5e01b150974fc9598a697e2090f8a4a66a37/src/matching.rs#L72
Is there an example or doc on what this is?Stanislav Vodetskyi
07/31/2024, 7:05 AMrholshausen
07/31/2024, 7:07 AMStanislav Vodetskyi
07/31/2024, 7:39 AMserver::generate_content()
also used for service without grpc? Cause I haven't seen it used in message tests or grpc tests.rholshausen
07/31/2024, 11:24 PMStanislav Vodetskyi
08/07/2024, 8:49 AM