Search in sources :

Example 31 with Service

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() {
    Response<Map<String, Service>> response = consul.getAgentServices();
    Map<String, Service> services = response.getValue();
    Service service = services.get("myTestService-EE-0-management");
    assertNotNull("service was null", service);
    assertEquals("service port is not 0", 0, service.getPort().intValue());
    assertEquals("service id was wrong", "myTestService-EE-0-management", service.getId());
    assertEquals("service name was wrong", "myTestService-EE-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());
}
Also used : Service(com.ecwid.consul.v1.agent.model.Service) Map(java.util.Map) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 32 with Service

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 = consul.getAgentServices();
    Map<String, Service> services = response.getValue();
    Service service = services.get("myTestService2-DD");
    assertNotNull("service was null", service);
    assertNotEquals("service port is 0", 0, service.getPort().intValue());
}
Also used : Service(com.ecwid.consul.v1.agent.model.Service) Map(java.util.Map) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 33 with Service

use of com.ecwid.consul.v1.health.model.HealthService.Service in project spring-cloud-consul by spring-cloud.

the class ConsulAutoServiceDeRegistrationDisabledTests method checkService.

private void checkService(final boolean expected) {
    final Response<Map<String, Service>> response = consul.getAgentServices();
    final Map<String, Service> services = response.getValue();
    final Service service = services.get("myTestNotDeRegisteredService-D");
    if (expected) {
        assertNotNull("service was not registered", service);
    } else {
        assertNull("service was registered", service);
    }
}
Also used : Service(com.ecwid.consul.v1.agent.model.Service) Map(java.util.Map)

Example 34 with Service

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 = consul.getAgentServices();
    Map<String, Service> services = response.getValue();
    Service service = services.get("myTestService1-CC");
    assertNotNull("service was null", service);
    assertNotEquals("service port is 0", 0, service.getPort().intValue());
    assertEquals("service id was wrong", "myTestService1-CC", service.getId());
    assertEquals("service name was wrong", "myprefix-myTestService-CC", service.getService());
}
Also used : Service(com.ecwid.consul.v1.agent.model.Service) Map(java.util.Map) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 35 with Service

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");
}
Also used : Check(com.ecwid.consul.v1.health.model.Check) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Test (org.junit.Test)18 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 Service (com.ecwid.consul.v1.agent.model.Service)14 Map (java.util.Map)14 NewService (com.ecwid.consul.v1.agent.model.NewService)10 Check (com.ecwid.consul.v1.health.model.Check)6 HealthService (com.ecwid.consul.v1.health.model.HealthService)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 QueryParams (com.ecwid.consul.v1.QueryParams)3 CatalogService (com.ecwid.consul.v1.catalog.model.CatalogService)2 ConsulService (com.weibo.api.motan.registry.consul.ConsulService)2 JSONObject (com.alibaba.fastjson.JSONObject)1 ConsulClient (com.ecwid.consul.v1.ConsulClient)1 Service (com.ecwid.consul.v1.health.model.HealthService.Service)1 DefaultClientConfigImpl (com.netflix.client.config.DefaultClientConfigImpl)1 DefaultServiceInstance (org.springframework.cloud.client.DefaultServiceInstance)1 ConsulServer (org.springframework.cloud.consul.discovery.ConsulServer)1 ConsulServerList (org.springframework.cloud.consul.discovery.ConsulServerList)1