felipe cesar
felipe cesar

Reputation: 55

Disabling config server for tests

I am using microservice architecture where the services are done with spring boot, to control them, I am using zuul as a proxy, eureka as register and config server as the configuration provider.

In the microservices I configure my bootstrap.yml file as follows:

spring:
  application:
    name: portal-gca-server-${MYENV:local}
  cloud:
    config:
      uri: http://localhost:9090

As seen above, the config file name that I look for in the config server is according to my environment variable, otherwise I get the local profile. This works fine, but when I run the tests on the development machine it will never work, because instead of searching for the test profile it searches for the location, because the dev machine has no environment variable. I know I could register the environment variable to run the tests but that's not the intention or else I would have to do this all the time to run tests and to run the local application.

Is there any way to solve this? I already tried to use the annotations:

webEnvironment = SpringBootTest.WebEnvironment.MOCK
@ActiveProfiles("test")
@TestPropertySource(locations="classpath:application-test.properties")

None of them any good, because the first thing the application does when executed is to fetch the information in git according to bootstrap.yml.

Has anyone ever experienced this?

Upvotes: 2

Views: 4889

Answers (1)

Sergei Golitsyn
Sergei Golitsyn

Reputation: 104

Go to your bootstrap.yml and then add :

spring:
  cloud:
    config:
     enabled: false

Upvotes: 4

Related Questions