Hello team. I'm getting started using the protobuf...
# protobufs
d
Hello team. I'm getting started using the protobuf plugin for gRPC contract testing. I'm currently getting this error when my provider tests run:
Copy code
Plugin protobuf failed to validate the interaction: Plugin configuration item with key 'ea4217bffbf17f94e01b461796d57ad4' is required. Received config ["794aed6a7e746a9d0688e0a45801456b"]
I have several questions about this: • How do I debug it? When I look at the code it appears that these keys are MD5 hashes of the proto descriptors. How do I figure out what's different? • How is it failing? When I debug the tests, it appears that it's failing with a request sent to the broker. When I look at the request payload, it appears that the expected descriptor keys are there. Yet the broker still returns an error. • Why do I care about the descriptor keys? It's not immediately apparent to me why I should care if the descriptor keys are different. Isn't it possible that the protos used by the consumer and the provider to be different and yet the contracts still be satisfied?
y
Hey Dustin!
How do I debug it?
Have you set debug or trace logs, download the pact file so you can run it locally. isolate individual interactions with
PACT_DESCRIPTION="<SOME DESC>"
to see if you can isolate.
When I debug the tests, it appears that it’s failing with a request sent to the broker.
That response doesn’t look like it is coming from the broker. Do you have a copy of the pact file so you can isolate the broker from the equation.
• Why do I care about the descriptor keys? It’s not immediately apparent to me why I should care if the descriptor keys are different. Isn’t it possible that the protos used by the consumer and the provider to be different and yet the contracts still be satisfied?
There should be a description key in the pact interaction https://github.com/pact-foundation/pact-reference/blob/b55407ef2be897d286af9330506[…]python/pacts/grpc-consumer-python-area-calculator-provider.json it ties the interaction to a specific protobuf which is stored in the pact file https://github.com/pact-foundation/pact-reference/blob/b55407ef2be897d286af9330506[…]python/pacts/grpc-consumer-python-area-calculator-provider.json I think it may be due to the
key
value https://github.com/pact-foundation/pact-reference/blob/b55407ef2be897d286af9330506[…]python/pacts/grpc-consumer-python-area-calculator-provider.json which was removed in 0.4.5 of the pact_ffi https://github.com/pact-foundation/pact-reference/issues/264#issuecomment-1556582681 The metadata section in the pact should give a good indication as to which library produced it and which version. If you can provide a copy of the pact file that would be useful. Maybe try removing the
key
value if it is present and trying again
Have you generated the pact yourself or are you recently onboarding and verifying pacts which have been generated for your team? you mentioned just getting started, and a pact broker, so it might be useful to know where abouts you are
d
Thanks for your response. I've pivoted to other things for now, but I hope to follow up on your response before too long.
r
Try doing a clean before you run your consumer tests.
d
Hello team. Thank you for the suggestions. I did some debugging and I think I found something helpful. I'm currently testing multiple proto services with the same provider name. Something like this: Microservice: Module0.proto
Copy code
service Service0 {
  rpc endpoint0 (Request0) returns (Response0)
}
Module1.proto
Copy code
service Service1 {
  rpc endpoint1 (Request1) returns (Response1)
}
Then I wrote consumer tests like this:
Copy code
@PactTestFor(providerName = "microservice")
class ConsumerTest {
  @PactTestFor(pactMethod = "endpoint0")

  @PactTestFor(pactMethod = "endpoint1")
}
When I look at the contract generated, the metadata object only contains protoFile data for Module0. However, if I comment out the Service0 tests and generate a contract again, the protoFile data now contains Module1 protos. Do I have to set a new provider name for every proto file?