Closed harluss closed 1 year ago
Maybe use simple discovery client (always enabled) and disable eureka for tests. https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#simplediscoveryclient
Thank you @spencergibb, that was exactly what I was looking for. Using SimpleDiscoveryClient with Eureka disabled for tests allowed me to stick to one implementation of FeignClient.
Test profile in application.yml
for the FeignClient above:
spring:
config:
activate:
on-profile: test
cloud:
discovery:
client:
simple:
instances:
hangar[0]:
uri: http://localhost:${wiremock.server.port:0}
eureka:
client:
enabled: false
Hi, I have a
FeignClient
I use with Eureka Service:Works wonders live but I can't find any information on how to mock/assign an URL for it for Integration Tests with Eureka Service disabled (
enabled: false
)? When I setup WireMock and try to run the test I get this error:If I add
url = "${feign.clients.hangar.url}"
to the Feign annotation and set matching value in test profile inapplication.yml
tests work, but when Eureka is enabled in "prod" the app crashes on startup.It seems like something simple, yet I can't find any information on how to do it. How to provide URL for each client with Eureka disabled without adding the
url
property in the annotation? Can I either provide a URL (or a list of URLs if I use multiple clients calling different microservices) to either Eureka or Load Balancer inapplication.yml
? Or how to overwrite theurl
property inapplication.yml
with values from enabled Eureka, something like `${eureka.whatever.url}?I guess I could manually create 2 beans for each client and activate one in prod and other one in tests, that I would prefer to have one implementation and just change config values based on profile. Is that even possible?
I use
spring-cloud-starter-openfeign
,spring-cloud-starter-netflix-eureka-client
andspring-cloud-contract-wiremock
(mocks) withspring-cloud-dependencies
version2021.0.5
.I would greatly appreciate any help with this.