use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoRegistrationHealthCheckTlsSkipVerifyTests method contextLoads.
@Test
public void contextLoads() {
NewService service = this.registration.getService();
assertThat(service).as("service was null").isNotNull();
NewService.Check check = service.getCheck();
assertThat(check).as("check was null").isNotNull();
assertThat(check.getTlsSkipVerify()).as("tls_skip_verify was wrong").isEqualTo(Boolean.TRUE);
// unable to call consul api to get health check details
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class TtlSchedulerRemoveTests method should_not_send_check_if_service_removed.
@Test
public void should_not_send_check_if_service_removed() throws InterruptedException {
// wait for Ttlscheduler to send a check to consul.
Thread.sleep(1000);
Check serviceCheck = getCheckForService("ttlSchedulerRemove");
assertThat("Service check is in wrong state", serviceCheck.getStatus(), equalTo(PASSING));
// Remove service from TtlScheduler and wait for TTL to expired.
ttlScheduler.remove("ttlSchedulerRemove-id");
Thread.sleep(2100);
serviceCheck = getCheckForService("ttlSchedulerRemove");
assertThat("Service check is in wrong state", serviceCheck.getStatus(), equalTo(CRITICAL));
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationDisabledTests method contextLoads.
@Test
public void contextLoads() {
assertNull("ConsulAutoServiceRegistration was created", autoServiceRegistration);
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestNotRegisteredService2");
assertNull("service was registered", service);
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulDiscoveryClient method addInstancesToList.
private void addInstancesToList(List<ServiceInstance> instances, String serviceId, QueryParams queryParams) {
String aclToken = properties.getAclToken();
Response<List<HealthService>> services;
if (StringUtils.hasText(aclToken)) {
services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams, aclToken);
} else {
services = client.getHealthServices(serviceId, this.properties.getDefaultQueryTag(), this.properties.isQueryPassing(), queryParams);
}
for (HealthService service : services.getValue()) {
String host = findHost(service);
instances.add(new DefaultServiceInstance(serviceId, host, service.getService().getPort(), false, getMetadata(service)));
}
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoRegistration method registration.
public static ConsulAutoRegistration registration(AutoServiceRegistrationProperties autoServiceRegistrationProperties, ConsulDiscoveryProperties properties, ApplicationContext context, List<ConsulRegistrationCustomizer> registrationCustomizers, HeartbeatProperties heartbeatProperties) {
NewService service = new NewService();
String appName = getAppName(properties, context.getEnvironment());
service.setId(getInstanceId(properties, context));
if (!properties.isPreferAgentAddress()) {
service.setAddress(properties.getHostname());
}
service.setName(normalizeForDns(appName));
service.setTags(createTags(properties));
if (properties.getPort() != null) {
service.setPort(properties.getPort());
// we know the port and can set the check
setCheck(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties);
}
ConsulAutoRegistration registration = new ConsulAutoRegistration(service, autoServiceRegistrationProperties, properties, context, heartbeatProperties);
customize(registrationCustomizers, registration);
return registration;
}
Aggregations