4finance / micro-infra-spring

Repository containing default microservice infrastructure set up using Spring configuration
Apache License 2.0
203 stars 49 forks source link

Stub services registered by stub-runner are not available from different host #569

Closed EdgarsM closed 8 years ago

EdgarsM commented 8 years ago

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()

cameleeck commented 8 years ago

Merged. Thanks for commit.