use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationNonWebTests method contextLoads.
@Test
public void contextLoads() {
assertNotNull("ConsulAutoServiceRegistration was created", autoServiceRegistration);
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("consulNonWebTest");
// no port to listen, hence no registration
assertNull("service was registered", service);
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get(registration.getInstanceId());
assertNotNull("service was null", service);
assertNotEquals("service port is 0", 0, service.getPort().intValue());
assertFalse("service id contained invalid character: " + service.getId(), service.getId().contains(":"));
assertEquals("service id was wrong", registration.getInstanceId(), service.getId());
assertEquals("service name was wrong", "myTestService1-FF-something", service.getService());
assertFalse("service address must not be empty", StringUtils.isEmpty(service.getAddress()));
assertEquals("service address must equals hostname from discovery properties", discoveryProperties.getHostname(), service.getAddress());
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulServiceRegistryTests method contextLoads.
@Test
public void contextLoads() {
assertThat(autoRegistration).as("autoRegistration created erroneously").isNull();
String serviceId = "myNonAutoRegisteredService";
NewService service = new NewService();
service.setAddress("localhost");
service.setId("myNonAutoRegisteredService-A1");
service.setName(serviceId);
service.setPort(port);
service.setTags(Collections.singletonList("mytag"));
ConsulRegistration registration = new ConsulRegistration(service, this.properties);
Throwable t = null;
try {
serviceRegistry.register(registration);
assertHasInstance(serviceId);
assertStatus(registration, "UP");
// only works if query-passing = true
serviceRegistry.setStatus(registration, "OUT_OF_SERVICE");
assertEmptyInstances(serviceId);
assertStatus(registration, "OUT_OF_SERVICE");
serviceRegistry.setStatus(registration, "UP");
assertHasInstance(serviceId);
} catch (RuntimeException e) {
throw e;
} finally {
serviceRegistry.deregister(registration);
if (t == null) {
// just deregister, test already failed
assertEmptyInstances(serviceId);
}
}
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedPropsTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-B");
assertThat("service was null", service, is(notNullValue()));
assertThat("service port is discovery port", service.getPort(), equalTo(4452));
assertThat("service id was wrong", "myTestService1-B", equalTo(service.getId()));
assertThat("service name was wrong", "myTestService-B", equalTo(service.getService()));
assertThat("property hostname was wrong", "myhost", equalTo(this.properties.getHostname()));
assertThat("property ipAddress was wrong", "10.0.0.1", equalTo(this.properties.getIpAddress()));
assertThat("service address was wrong", "myhost", equalTo(service.getAddress()));
Response<List<Check>> checkResponse = consul.getHealthChecksForService("myTestService-B", QueryParams.DEFAULT);
List<Check> checks = checkResponse.getValue();
assertThat("checks was wrong size", checks, hasSize(0));
}
use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedServletContextTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-WithServletContext");
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-WithServletContext");
assertThat(service.getTags()).as("contextPath tag missing").contains("contextPath=/customContext");
}
Aggregations