These are chat archives for spring-cloud/spring-cloud

25th
Mar 2016
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 01:11
Is there a way to have all registered Feign clients use local.server.port during tests?
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 05:51
The scenario I'm consdering is using Feign clients to help me write rest integration tests against mvc controllers. Moreover, I'd like to run these tests in parallel while leveraging @WebIntegrationTest(randomPort = true). The limitation I'm running into is not being able to set the port for the many feign clients(e.g. using local.server.port) cross-cuttingly. I know I can use @RibbonClient(name="foo", configuration= StaticServerListOverrideFooConfig.class) however this means I would need to add this annotation in 10s-100s of test classes(multiple times in the cases where an integration uses more then one rest client). I'm wondering if there is some other way to propagate the local port to feign/ribbon. Any ideas are greatly appreciated.
Marcin Grzejszczak
@marcingrzejszczak
Mar 25 2016 07:48
Hmm you could set a default configuration for all feign clients that would set the ribbon servers with local.server.port
Dave Syer
@dsyer
Mar 25 2016 08:41
Do you even need Java config? You can set up a test profile and configure a server list for each service there in YML
Spencer Gibb
@spencergibb
Mar 25 2016 13:40
If eureka is on the class path, you can disable it in tests eurka.ribbon. enabled=false and then set the server list in yaml.
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 13:43
@marcingrzejszczak how would that look like, roughly?
Marcin Grzejszczak
@marcingrzejszczak
Mar 25 2016 13:45
@dsyer and @spencergibb have a better idea then mine @PedroAlvarado
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 13:49
@dsyer and @spencergibb if I'm not wrong, the yml file approach will prevent me from being able to run the tests in parallel or it will mean that I need to have a yml file per test class each with a different port which is quite a tedious exercise in my case of roughly 100 controllers.
Fabian Wallwitz
@cforce
Mar 25 2016 13:51
Did someone has an idea how I could publish rest resources as crud repository at client side?
The idea is the rest repository thought on the client'side as client for a rest repository on server side. The query of the client repo makes use of a (e.g. feign) rest client being implemented by spring rest
It could be seen as RemoteCrudRepository. Server side would therefore register resources at eureka with names an oates at RemoteRestRepository
Client side can lookup them and consume it providing REMOTE Ressource as entities via an local repository.
Marcin Grzejszczak
@marcingrzejszczak
Mar 25 2016 14:18
@PedroAlvarado as for the approach that I was thinking about - I thought abouth the @EnableFeignClients(defaultConfiguration = ...) approach where you could provide the default configuration for all feign clients
Dave Syer
@dsyer
Mar 25 2016 16:43
I also don't know why you'd want a different random port for all your tests
I guess it depends on the nature of the tests
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 16:49
@marcingrzejszczak let me give that a shot
@dsyer I'm considering running the tests in parallel and I don't wan to run into "Address already in use: bind" issues
Dave Syer
@dsyer
Mar 25 2016 17:00
Can't they all run on the same server
Pedro Alvarado
@PedroAlvarado
Mar 25 2016 17:31
@dsyer I'm using different profiles for some of the tests. My understanding is that this will cause multiple contexts/containers to be started and, hence, attempt to bind to the same port. Let me know if I'm wrong about this.
Dave Syer
@dsyer
Mar 25 2016 17:38
No, that's not wrong. I just wonder if you could make it more efficient by not having to start a new server for each one.