pszymczyk / embedded-consul

Embedded Consul provides easy way to run Consul in integration tests.
Apache License 2.0
95 stars 29 forks source link

Error on close #53

Open bendg25 opened 6 years ago

bendg25 commented 6 years ago

We are seeing the following issue on shutdown, seems like either API incompatibility or no REST service available on embedded consul? Spring-consul v1.2.1 embeded-consul v1.0.0

2017/10/30 13:53:36 [ERR] http: Request GET /v1/agent/service/deregister/ourapp-ut-0, error: method GET not allowed from=127.0.0.1:54805 2017-10-30 13:53:36.387 ERROR 25876 --- [ Thread-21] o.s.c.c.d.AbstractDiscoveryLifecycle : A problem occurred attempting to stop discovery lifecycle

com.ecwid.consul.v1.OperationException: OperationException(statusCode=405, statusMessage='Method Not Allowed', statusContent='method GET not allowed') at com.ecwid.consul.v1.agent.AgentConsulClient.agentServiceDeregister(AgentConsulClient.java:254) at com.ecwid.consul.v1.ConsulClient.agentServiceDeregister(ConsulClient.java:282) at org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry.deregister(ConsulServiceRegistry.java:86) at org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry.deregister(ConsulServiceRegistry.java:41) at org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration.deregister(AbstractAutoServiceRegistration.java:55) at org.springframework.cloud.consul.serviceregistry.ConsulAutoServiceRegistration.deregister(ConsulAutoServiceRegistration.java:105)

pszymczyk commented 5 years ago

Could you prepare some project with failing test which will show this behaviour? Now it's hard to determine what is going one and what is the root cause of this issue.

piotrpolak commented 5 years ago

It happens because the spring context is closed AFTER the JUnit @AfterAll callbacks closes Consul.

As a workaround consider