Hi. I'm trying to write a Pact test for gRPC. Can ...
# pact-jvm
j
Hi. I'm trying to write a Pact test for gRPC. Can I control the port that the Pact Mock Service Provider listens on? I would like it to mimic the standard port of the external service that it's standing in for. I've tried this annotation but I still get a random port, and I get a deprecation warning on the "port" parameter.
@PactTestFor(pactMethod = "someMethod", port="5000")
u
j
a new mock server config annotation you can use to set the port
I looked at the code you linked but I don't see any annotation setting the port? From what I understand, the example code shows how to retrieve the mock server port in order to set up the channel that will communicate with the already running port. I don't see how one sets the port with that code?
I've spent some time looking through the code for the grpc pact plug-in now and it looks like the port for the mock server is never set to any configurable value, always taking the default value of 0 and getting a random port assigned. 😞
PluginManager.kt in io.pact.plugin.drivercore0.1.2 is what led me to this conclusion. I'd be happy to be wrong though, if anyone knows another way.
@uglyog Did I misunderstand the code you linked? Is there a way to set the port? I don't see any port being set in the code you linked, the port only gets read from the MockServer.