use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedDiscoveryPortTests method contextLoads.
@Test
public void contextLoads() {
NewService service = this.registration.getService();
assertThat(service).as("service was null").isNotNull();
assertThat(service.getPort()).as("service port is 0").isGreaterThan(0);
NewService.Check check = service.getCheck();
assertThat(check).as("check was null").isNotNull();
String httpCheck = String.format("%s://%s:%s%s", this.properties.getScheme(), this.properties.getHostname(), this.properties.getPort(), this.properties.getHealthCheckPath());
assertThat(check.getHttp()).as("http check was wrong").isEqualTo(httpCheck);
// 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 ConsulAutoServiceRegistrationCustomizedInstanceZoneTests 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-WithZone");
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-WithZone");
assertThat(service.getMeta()).as("service zone was wrong").containsEntry("myZone", "zone1");
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoServiceRegistrationCustomizedPropsTests method propertiesAreCorrect.
@Test
public void propertiesAreCorrect() {
Response<Map<String, Service>> response = this.consul.getAgentServices();
Map<String, Service> services = response.getValue();
Service service = services.get("myTestService1-B");
assertThat(service).as("service was null").isNotNull();
assertThat(service.getPort()).as("service port is discovery port").isEqualTo(4452);
assertThat("myTestService1-B").as("service id was wrong").isEqualTo(service.getId());
assertThat("myTestService-B").as("service name was wrong").isEqualTo(service.getService());
assertThat("myhost").as("property hostname was wrong").isEqualTo(this.properties.getHostname());
assertThat("10.0.0.1").as("property ipAddress was wrong").isEqualTo(this.properties.getIpAddress());
assertThat("myhost").as("service address was wrong").isEqualTo(service.getAddress());
assertThat(service.getEnableTagOverride()).as("property enableTagOverride was wrong").isTrue();
assertThat(service.getTags()).as("property tags contains the wrong values").containsExactly("mytag");
HashMap<String, String> entries = new HashMap<>();
entries.put("key1", "value1");
entries.put("key2", "value2");
entries.put("mydefaultzonemetadataname", "myzone");
entries.put("group", "mygroup");
entries.put("secure", "false");
assertThat(service.getMeta()).as("property metadata contains the wrong entries").containsExactlyInAnyOrderEntriesOf(entries);
Response<List<Check>> checkResponse = this.consul.getHealthChecksForService("myTestService-B", HealthChecksForServiceRequest.newBuilder().setQueryParams(QueryParams.DEFAULT).build());
List<Check> checks = checkResponse.getValue();
assertThat(checks).as("checks was wrong size").hasSize(0);
}
use of com.ecwid.consul.v1.agent.model.Service in project spring-cloud-consul by spring-cloud.
the class ConsulAutoRegistrationHealthCheckHeadersTests 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.getHeader()).as("header is null").isNotNull();
assertThat(check.getHeader()).as("header is empty").isNotEmpty();
assertThat(check.getHeader().get("X-Config-Token").get(0)).as("expected header value not found").isEqualTo("ACCESSTOKEN");
// 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 ConsulAutoServiceRegistrationCustomizedAgentAddressTests 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-AA");
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-AA");
assertThat(service.getService()).as("service name was wrong").isEqualTo("myprefix-myTestService-AA");
assertThat(StringUtils.isEmpty(service.getAddress())).as("service address must be empty").isTrue();
}
Aggregations