diff --git a/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/dependency/ZookeeperDiscoveryWithDyingDependenciesISpec.groovy b/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/dependency/ZookeeperDiscoveryWithDyingDependenciesISpec.groovy index 33a3f2a6..8b6f1bd9 100644 --- a/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/dependency/ZookeeperDiscoveryWithDyingDependenciesISpec.groovy +++ b/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/dependency/ZookeeperDiscoveryWithDyingDependenciesISpec.groovy @@ -19,6 +19,7 @@ import org.apache.curator.test.TestingServer import org.springframework.boot.autoconfigure.EnableAutoConfiguration import org.springframework.boot.builder.SpringApplicationBuilder import org.springframework.cloud.client.discovery.EnableDiscoveryClient +import org.springframework.cloud.zookeeper.discovery.PollingUtils import org.springframework.cloud.zookeeper.discovery.test.TestRibbonClient import org.springframework.context.ApplicationContext import org.springframework.context.ConfigurableApplicationContext @@ -27,9 +28,12 @@ import org.springframework.context.annotation.Import import org.springframework.util.SocketUtils import spock.lang.Issue import spock.lang.Specification +import spock.util.concurrent.PollingConditions import spock.util.environment.RestoreSystemProperties -class ZookeeperDiscoveryWithDyingDependenciesISpec extends Specification { +class ZookeeperDiscoveryWithDyingDependenciesISpec extends Specification implements PollingUtils { + + PollingConditions pollingConditions = new PollingConditions() @Issue("#45") @RestoreSystemProperties @@ -43,11 +47,14 @@ class ZookeeperDiscoveryWithDyingDependenciesISpec extends Specification { ConfigurableApplicationContext serverContext = contextWithProfile('server') ConfigurableApplicationContext clientContext = contextWithProfile('client') and: - Integer portBeforeDying = callServiceAtPortEndpoint(clientContext) + Integer serverPortBeforeDying = callServiceAtPortEndpoint(clientContext) and: serverContext = restartContext(serverContext, 'server') expect: - callServiceAtPortEndpoint(clientContext) != portBeforeDying + pollingConditions.within 5, willPass { + assert callServiceAtPortEndpoint(clientContext) != serverPortBeforeDying + } + cleanup: serverContext?.close() clientContext?.close() diff --git a/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/test/TestServiceRestClient.groovy b/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/test/TestServiceRestClient.groovy index 63692a00..76285955 100644 --- a/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/test/TestServiceRestClient.groovy +++ b/spring-cloud-zookeeper-discovery/src/test/groovy/org/springframework/cloud/zookeeper/discovery/test/TestServiceRestClient.groovy @@ -16,9 +16,11 @@ package org.springframework.cloud.zookeeper.discovery.test import groovy.transform.CompileStatic +import groovy.util.logging.Commons import org.springframework.web.client.RestTemplate @CompileStatic +@Commons class TestServiceRestClient { final RestTemplate restTemplate; @@ -28,7 +30,9 @@ class TestServiceRestClient { } public T callService(String alias, String endpoint, Class clazz) { - return restTemplate.getForObject("http://$alias/$endpoint", clazz) + String url = "http://$alias/$endpoint" + log.info("Calling [$url]") + return restTemplate.getForObject(url, clazz) } String callService(String alias, String endpoint) { diff --git a/spring-cloud-zookeeper-discovery/src/test/resources/application.yml b/spring-cloud-zookeeper-discovery/src/test/resources/application.yml new file mode 100644 index 00000000..a17ae042 --- /dev/null +++ b/spring-cloud-zookeeper-discovery/src/test/resources/application.yml @@ -0,0 +1 @@ +testInstance.ribbon.ServerListRefreshInterval: 100 \ No newline at end of file