use of com.ecwid.consul.v1.agent.model.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.agent.model.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.agent.model.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");
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedManagementServicePortTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService-GG-0-management");
assertNotNull("service was null", service);
assertEquals("service port is not 4452", 4452, service.getPort().intValue());
assertEquals("management port is not 0", 0, managementServerProperties.getPort().intValue());
assertEquals("service id was wrong", "myTestService-GG-0-management", service.getId());
assertEquals("service name was wrong", "myTestService-GG-management", 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.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationManagementDisabledServiceTests method contextLoads.
@Test
public void contextLoads() {
Response<Map<String, Service>> response = consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service mgmtService = services.get("myTestService-NM-0-management");
assertNull("Management service was not null", mgmtService);
Service service = services.get("myTestService1-NM");
assertNotNull("Service was not null", service);
assertNotEquals("service port was 0", 0, service.getPort().intValue());
assertEquals("service id was wrong", "myTestService1-NM", service.getId());
assertEquals("service name was wrong", "myTestService-NM", 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());
}
Aggregations