Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Spring cloud consul when running Test

I like to run my unit test with test spring profile without consul. I'm trying to use spring.cloud.config.enabled:false and disabling EnableDiscoveryClient annotation for test profile but it doesn't work.

I'm using spring.cloud.consul 1.0.0.BUILD-SNAPSHOT. Here is the exception:

com.ecwid.consul.transport.TransportException: java.net.ConnectException: Connection refused: connect at com.ecwid.consul.transport.DefaultHttpTransport.executeRequest(DefaultHttpTransport.java:87) at com.ecwid.consul.transport.DefaultHttpTransport.makeGetRequest(DefaultHttpTransport.java:46) at com.ecwid.consul.v1.ConsulRawClient.makeGetRequest(ConsulRawClient.java:66)

like image 355
youssef Liouene Avatar asked Feb 29 '16 11:02

youssef Liouene


People also ask

How do I turn off spring cloud consul?

I use @IntegrationTest({"spring. cloud. consul. enabled=false"}) tag to disable consul for my tests, as a class tag.

What is spring cloud consul?

Spring Cloud Consul provides Consul integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.

What are the default values for spring cloud consul host?

cloud. consul. host property is pointing to 127.0. 0.1 and port to 8500 by default.


1 Answers

Try disabling Consul with spring.cloud.consul.enabled:false in your profile.

I use @IntegrationTest({"spring.cloud.consul.enabled=false"}) tag to disable consul for my tests, as a class tag. I found that on the Spring Cloud Consul GitHub issue tracker, here.

The other suggestion from that post was to use something like the following as your bootstrap.yml.

spring:
  application:
    name: <myServiceName>
  cloud:
    bus:
      enabled: false
    discovery:
      enabled: false
    consul:
      enabled: false
      config:
        enabled: false
like image 175
Tiz Avatar answered Sep 22 '22 02:09

Tiz