Fixes broken tests.
Fixes gh-615
This commit is contained in:
@@ -112,6 +112,17 @@
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.awaitility</groupId>
|
||||
<artifactId>awaitility</artifactId>
|
||||
<version>4.0.3</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-test-support</artifactId>
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.cloud.consul.discovery;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -38,9 +37,8 @@ import static org.springframework.boot.test.context.SpringBootTest.WebEnvironmen
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(
|
||||
properties = { "spring.application.name=testConsulLoadBalancer",
|
||||
"spring.cloud.consul.discovery.prefer-ip-address=true", "spring.cloud.consul.discovery.tags=foo=bar" },
|
||||
@SpringBootTest(properties = { "spring.application.name=testConsulLoadBalancer",
|
||||
"spring.cloud.consul.discovery.prefer-ip-address=true", "spring.cloud.consul.discovery.metadata.foo=bar" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
@ContextConfiguration(initializers = ConsulTestcontainers.class)
|
||||
public class ConsulLoadbalancerClientTests {
|
||||
@@ -49,7 +47,6 @@ public class ConsulLoadbalancerClientTests {
|
||||
private LoadBalancerClient client;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void chooseWorks() {
|
||||
ServiceInstance instance = this.client.choose("testConsulLoadBalancer");
|
||||
assertThat(instance).isNotNull();
|
||||
@@ -66,23 +63,8 @@ public class ConsulLoadbalancerClientTests {
|
||||
@SpringBootConfiguration
|
||||
@EnableAutoConfiguration
|
||||
@EnableDiscoveryClient
|
||||
// @RibbonClient(name = "testConsulLoadBalancer", configuration =
|
||||
// MyRibbonConfig.class)
|
||||
public static class MyTestConfig {
|
||||
|
||||
}
|
||||
|
||||
public static class MyRibbonConfig {
|
||||
|
||||
public MyRibbonConfig() {
|
||||
System.err.println("here");
|
||||
}
|
||||
|
||||
// @Bean
|
||||
// public ServerListFilter<Server> ribbonServerListFilter() {
|
||||
// return servers -> servers;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.ecwid.consul.v1.QueryParams;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
import com.ecwid.consul.v1.health.HealthChecksForServiceRequest;
|
||||
import com.ecwid.consul.v1.health.model.Check;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -42,15 +41,18 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
import static com.ecwid.consul.v1.health.model.Check.CheckStatus.CRITICAL;
|
||||
import static com.ecwid.consul.v1.health.model.Check.CheckStatus.PASSING;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
|
||||
|
||||
/**
|
||||
* @author Stéphane Leroy
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = TtlSchedulerRemoveTests.TtlSchedulerRemoveTestConfig.class, properties = {
|
||||
"spring.application.name=ttlSchedulerRemove", "spring.cloud.consul.discovery.instance-id=ttlSchedulerRemove-id",
|
||||
"spring.cloud.consul.discovery.heartbeat.enabled=true", "spring.cloud.consul.discovery.heartbeat.ttlValue=2" },
|
||||
@SpringBootTest(classes = TtlSchedulerRemoveTests.TtlSchedulerRemoveTestConfig.class,
|
||||
properties = { "spring.cloud.consul.discovery.heartbeat.ttl=5s", "spring.application.name=ttlSchedulerRemove",
|
||||
"spring.cloud.consul.discovery.instance-id=ttlSchedulerRemove-id",
|
||||
"spring.cloud.consul.discovery.heartbeat.enabled=true",
|
||||
"spring.cloud.consul.discovery.heartbeat.ttlValue=2" },
|
||||
webEnvironment = RANDOM_PORT)
|
||||
@ContextConfiguration(initializers = ConsulTestcontainers.class)
|
||||
public class TtlSchedulerRemoveTests {
|
||||
@@ -62,17 +64,18 @@ public class TtlSchedulerRemoveTests {
|
||||
private TtlScheduler ttlScheduler;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void should_not_send_check_if_service_removed() throws InterruptedException {
|
||||
Thread.sleep(1000); // wait for Ttlscheduler to send a check to consul.
|
||||
Check serviceCheck = getCheckForService("ttlSchedulerRemove");
|
||||
assertThat(serviceCheck.getStatus()).as("Service check is in wrong state").isEqualTo(PASSING);
|
||||
await().untilAsserted(() -> {
|
||||
Check serviceCheck = getCheckForService("ttlSchedulerRemove");
|
||||
assertThat(serviceCheck.getStatus()).as("Service check is in wrong state").isEqualTo(PASSING);
|
||||
});
|
||||
|
||||
// Remove service from TtlScheduler and wait for TTL to expired.
|
||||
this.ttlScheduler.remove("ttlSchedulerRemove-id");
|
||||
Thread.sleep(2100);
|
||||
serviceCheck = getCheckForService("ttlSchedulerRemove");
|
||||
assertThat(serviceCheck.getStatus()).as("Service check is in wrong state").isEqualTo(CRITICAL);
|
||||
await().untilAsserted(() -> {
|
||||
Check serviceCheck = getCheckForService("ttlSchedulerRemove");
|
||||
assertThat(serviceCheck.getStatus()).as("Service check is in wrong state").isEqualTo(CRITICAL);
|
||||
});
|
||||
}
|
||||
|
||||
private Check getCheckForService(String serviceId) {
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.Map;
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import com.ecwid.consul.v1.Response;
|
||||
import com.ecwid.consul.v1.agent.model.Service;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
@@ -29,9 +28,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.client.ServiceInstance;
|
||||
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
|
||||
import org.springframework.cloud.client.serviceregistry.AutoServiceRegistrationConfiguration;
|
||||
import org.springframework.cloud.consul.ConsulAutoConfiguration;
|
||||
import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties;
|
||||
import org.springframework.cloud.consul.test.ConsulTestcontainers;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -56,10 +56,9 @@ public class ConsulAutoServiceRegistrationCustomizedInstanceGroupTests {
|
||||
private ConsulClient consul;
|
||||
|
||||
@Autowired
|
||||
private ConsulDiscoveryProperties properties;
|
||||
private LoadBalancerClient client;
|
||||
|
||||
@Test
|
||||
@Ignore // FIXME: 3.0.0
|
||||
public void contextLoads() {
|
||||
Response<Map<String, Service>> response = this.consul.getAgentServices();
|
||||
Map<String, Service> services = response.getValue();
|
||||
@@ -67,18 +66,11 @@ public class ConsulAutoServiceRegistrationCustomizedInstanceGroupTests {
|
||||
assertThat(service).as("service was null").isNotNull();
|
||||
assertThat(service.getPort().intValue()).as("service port is 0").isNotEqualTo(0);
|
||||
assertThat(service.getId()).as("service id was wrong").isEqualTo("myTestService1-WithGroup");
|
||||
assertThat(service.getTags().contains("group=test")).as("service group was wrong").isTrue();
|
||||
assertThat(service.getMeta()).as("service group was wrong").containsEntry("group", "test");
|
||||
|
||||
// ConsulServerList serverList = new ConsulServerList(this.consul,
|
||||
// this.properties);
|
||||
// DefaultClientConfigImpl config = new DefaultClientConfigImpl();
|
||||
// config.setClientName("myTestService-WithGroup");
|
||||
// serverList.initWithNiwsConfig(config);
|
||||
//
|
||||
// List<ConsulServer> servers = serverList.getInitialListOfServers();
|
||||
// assertThat(servers.size()).as("servers was wrong size").isEqualTo(1);
|
||||
// assertThat(servers.get(0).getMetaInfo().getServerGroup())
|
||||
// .as("service group was wrong").isEqualTo("test");
|
||||
ServiceInstance instance = client.choose("myTestService-WithGroup");
|
||||
assertThat(instance).isNotNull();
|
||||
assertThat(instance.getMetadata()).containsEntry("group", "test");
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
|
||||
Reference in New Issue
Block a user