WireMock stub servers are registered in ZooKeeper using hostname "localhost" so it is not possible to access that service from different host.
Why there is a need to access those services? To dynamically add WireMock mapping to service using WireMock JSON API. Suppose you have deployed your service and stub runner on test environment and want to execute automated tests running on different host (e.g. pipeline server) against that environment. Because of the nature of your test data you are not able to create static mappings/stubs and there is a need to add new mappings from tests in run-time. After looking-up required service using service discovery from environment running tests right port is returned but of-course "localhost" doesn't point to same host as at the moment when this service was registered.
To solve this issue stub-runner would need to register services under hostname/address that is accessible from other hosts. So basically StubRegistry#serviceInstanceOf would need to resolve localhost address - InetAddress.getLocalHost().getHostAddress()
WireMock stub servers are registered in ZooKeeper using hostname "localhost" so it is not possible to access that service from different host.
Why there is a need to access those services? To dynamically add WireMock mapping to service using WireMock JSON API. Suppose you have deployed your service and stub runner on test environment and want to execute automated tests running on different host (e.g. pipeline server) against that environment. Because of the nature of your test data you are not able to create static mappings/stubs and there is a need to add new mappings from tests in run-time. After looking-up required service using service discovery from environment running tests right port is returned but of-course "localhost" doesn't point to same host as at the moment when this service was registered.
To solve this issue stub-runner would need to register services under hostname/address that is accessible from other hosts. So basically
StubRegistry#serviceInstanceOf
would need to resolve localhost address -InetAddress.getLocalHost().getHostAddress()