Disable Consul for integration tests with SB 2.4

Viewed 483

Since new SB configuration property spring.config.import in SB 2.4, I cannot get integration tests working. Previously, I had bootstrap-test.yml with spring.cloud.consul.enabled: false and it worked nicely. Since upgrade to 2.4.3, I have spring.config.import: "consul:" in application yml, and nothing seems to disable it in application-test.yml file. I have tried every possible combination of overriding spring.config.import: "optional:consul:" and setting spring.cloud.consul.enabled: false in application-test.yml. Yet I am still getting the same error

Config data resource ... via location 'consul:' does not exist

I don´t want to use optional import in application.yml, since main should not start without it. Only thing that seemed to help was setting use-legacy-processing: true but I don´t understand why.

1 Answers

This is likely just a workaround according to the comments on the question but it works for me for the moment. Your milage may vary.

Specifying the spring.config.import property as an environment variable allowed it to not be set for the tests but to work for the point where the application was deployed.

My full setup.

  • application.yml contains normal consul enabled config.
  • application-standalone.yml just disables all properties except spring.config.import
  • spring.config.import is only added to the launch parameters.
Related