Hi everyone :wave: I’m experimenting with the Wir...
# wiremock-java
v
Hi everyone 👋 I’m experimenting with the WireMock gRPC extension and trying to stub gRPC services in my Python tests using Lee's example below: https://github.com/leeturner/wiremock-standalone-grpc-example My
.proto
file generates the usual
*_pb2.py
and
*_pb2_grpc.py
files, and I’m calling the service using the generated stub:
Copy code
stub = ExampleServices_pb2_grpc.AreaCalculationServiceStub(channel)
response = stub.calculateArea(example_pb2.CalculateAreaRequest(base=5, height=10))
I always get below error and it looks like WireMock doesn’t find a matching stub. status = StatusCode.UNIMPLEMENTED details = "No matching stub mapping found for gRPC request" I also observed: 1. Calling the same service through an HTTP POST mapping works as expected. 2. I generated a
.dsc
file from my
.proto
and provided it to WireMock, but it doesn’t seem to make any effect. POST method will work with or without .dsc file mounted. 👉 Question: Does the WireMock gRPC extension support requests made through the generated Python gRPC stubs (
*_pb2_grpc
), or is it only intended for raw/unary JSON request/response mappings? If it should work, could someone share an example for Python stub?
l
Hi, sorry for the delay in responding. I am not a python developer so i have never tried using python to access a gRPC resource. As far as I know, there should be no reason why it shouldn't work. It could be to do with the values you are passing into the request. In your case you are passing a
base
of
5
and a
height
of
10
. However, if you look at the stub being used in the example, it is only matching on specific numbers - https://github.com/leeturner/wiremock-standalone-grpc-example/blob/main/wiremock/mappings/mappings.json#L7 You could try setting the values you are passing to the same as in the stub matcher or remove the
bodyPatterns
part of the stub json and try with any values
v
@Lee Turner, many thanks. I understand this better now. It is working all good now also with my own grpc service mock.
🙌 1
@Lee Turner, the minor issue now is that if I make gRPC call from python stub rather than from raw requests.post, I will not get the request/response logs even running in verbose mode. I can make sure the call was successful from the response in python stub. Is that expected?
l
I am not sure to be honest, I would have expected there to be some logs in verbose mode. Is the request successful ?