use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedInstanceGroupTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = this.consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-WithGroup");
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.getMeta()).as("service group was wrong").containsEntry("group", "test");
ServiceInstance instance = client.choose("myTestService-WithGroup");
assertThat(instance).isNotNull();
assertThat(instance.getMetadata()).containsEntry("group", "test");
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedServiceNameTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = this.consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-CC");
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-CC");
assertThat(service.getService()).as("service name was wrong").isEqualTo("myprefix-myTestService-CC");
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationDefaultPortTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = this.consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService2-DD");
assertThat(service).as("service was null").isNotNull();
assertThat(service.getPort().intValue()).as("service port is 0").isNotEqualTo(0);
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class TtlSchedulerTests method should_send_a_check_before_ttl_for_all_services.
@Test
public void should_send_a_check_before_ttl_for_all_services() throws InterruptedException {
// Wait for TTL to expired (TTL is set to 2 seconds)
Thread.sleep(2100);
Check serviceCheck = getCheckForService("ttlScheduler");
assertThat(serviceCheck).isNotNull();
assertThat(serviceCheck.getStatus()).isEqualTo(PASSING).as("Service check is in wrong state");
Check serviceManagementCheck = getCheckForService("ttlScheduler-management");
assertThat(serviceManagementCheck).isNotNull();
assertThat(serviceManagementCheck.getStatus()).isEqualTo(PASSING).as("Service management check is in wrong state");
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationManagementServiceTests method contextLoads.
@Test
public void contextLoads() {
final Response<Map<String, Service>> response = this.consul.getAgentServices();
final Map<String, Service> services = response.getValue();
final Service service = services.get("myTestService-EE-0");
assertThat(service).as("service was null").isNotNull();
assertThat(service.getPort().intValue()).as("service port was 0").isNotEqualTo(0);
assertThat(service.getId()).as("service id was wrong").isEqualTo("myTestService-EE-0");
assertThat(service.getService()).as("service name was wrong").isEqualTo("myTestService-EE");
assertThat(StringUtils.isEmpty(service.getAddress())).as("service address must not be empty").isFalse();
assertThat(service.getAddress()).as("service address must equals hostname from discovery properties").isEqualTo(this.discoveryProperties.getHostname());
final Service managementService = services.get("myTestService-EE-0-management");
assertThat(managementService).as("management service was null").isNotNull();
assertThat(managementService.getPort().intValue()).as("management service port was wrong").isEqualTo(4452);
assertThat(managementService.getId()).as("management service id was wrong").isEqualTo("myTestService-EE-0-management");
assertThat(managementService.getService()).as("management service name was wrong").isEqualTo("myTestService-EE-management");
assertThat(StringUtils.isEmpty(managementService.getAddress())).as("management service address must not be empty").isFalse();
assertThat(managementService.getAddress()).as("management service address must equals hostname from discovery properties").isEqualTo(this.discoveryProperties.getHostname());
}
Aggregations