Skip to content
This repository has been archived by the owner on Jul 27, 2023. It is now read-only.

Fix for #358 #386

Merged
merged 1 commit into from
Jun 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/itest/java/com/orbitz/consul/CatalogITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public void shouldGetTaggedAddressesForNode() throws UnknownHostException {
public void shouldRegisterService() {
String service = UUID.randomUUID().toString();
String serviceId = UUID.randomUUID().toString();
String catalogId = UUID.randomUUID().toString();

createAndCheckService(
ImmutableCatalogService.builder()
Expand All @@ -131,11 +132,14 @@ public void shouldRegisterService() {
.serviceId(serviceId)
.serviceName(service)
.servicePort(8080)
.serviceMeta(Collections.singletonMap("metakey", "metavalue"))
.putServiceMeta("metakey", "metavalue")
.putNodeMeta("a", "b")
.serviceEnableTagOverride(true)
.serviceWeights(ImmutableServiceWeights.builder().passing(42).warning(21).build())
.build(),
ImmutableCatalogRegistration.builder()
.id(catalogId)
.putNodeMeta("a", "b")
.address("localhost")
.datacenter("dc1")
.node("node")
Expand All @@ -157,6 +161,7 @@ public void shouldRegisterService() {
public void shouldRegisterServiceNoWeights() {
String service = UUID.randomUUID().toString();
String serviceId = UUID.randomUUID().toString();
String catalogId = UUID.randomUUID().toString();

createAndCheckService(
ImmutableCatalogService.builder()
Expand All @@ -168,11 +173,14 @@ public void shouldRegisterServiceNoWeights() {
.serviceId(serviceId)
.serviceName(service)
.servicePort(8080)
.serviceMeta(Collections.singletonMap("metakey", "metavalue"))
.putServiceMeta("metakey", "metavalue")
.putNodeMeta("a", "b")
.serviceEnableTagOverride(true)
.serviceWeights(ImmutableServiceWeights.builder().passing(1).warning(1).build())
.build(),
ImmutableCatalogRegistration.builder()
.id(catalogId)
.putNodeMeta("a", "b")
.address("localhost")
.datacenter("dc1")
.node("node")
Expand All @@ -196,8 +204,11 @@ public void shouldDeregisterWithDefaultDC() throws InterruptedException {

String service = UUID.randomUUID().toString();
String serviceId = UUID.randomUUID().toString();
String catalogId = UUID.randomUUID().toString();

CatalogRegistration registration = ImmutableCatalogRegistration.builder()
.id(catalogId)
.putNodeMeta("a", "b")
.address("localhost")
.datacenter("dc1")
.node("node")
Expand Down Expand Up @@ -274,8 +285,11 @@ public void shouldGetNodeInCallback() throws ExecutionException, InterruptedExce
String nodeName = "node";
String serviceName = UUID.randomUUID().toString();
String serviceId = createAutoDeregisterServiceId();
String catalogId = UUID.randomUUID().toString();

CatalogRegistration registration = ImmutableCatalogRegistration.builder()
.id(catalogId)
.putNodeMeta("a", "b")
.address("localhost")
.node(nodeName)
.service(ImmutableService.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import java.util.Map;
import java.util.Optional;
import java.util.UUID;

import com.orbitz.consul.model.agent.Check;
import com.orbitz.consul.model.health.Service;
import org.immutables.value.Value;
Expand All @@ -15,6 +19,9 @@
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class CatalogRegistration {

@JsonProperty("ID")
public abstract Optional<String> id();

@JsonProperty("Datacenter")
public abstract Optional<String> datacenter();

Expand All @@ -24,6 +31,9 @@ public abstract class CatalogRegistration {
@JsonProperty("Address")
public abstract String address();

@JsonProperty("NodeMeta")
public abstract Map<String, String> nodeMeta();

@JsonProperty("TaggedAddresses")
public abstract Optional<TaggedAddresses> taggedAddresses();

Expand All @@ -35,4 +45,7 @@ public abstract class CatalogRegistration {

@JsonProperty("WriteRequest")
public abstract Optional<WriteRequest> writeRequest();

@JsonProperty("SkipNodeUpdate")
public abstract Optional<Boolean> skipNodeUpdate();
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ public abstract class CatalogService {
public abstract List<String> getServiceTags();

@JsonProperty("ServiceMeta")
public abstract Optional<Map<String,String>> getServiceMeta();
public abstract Map<String,String> getServiceMeta();

@JsonProperty("ServiceWeights")
public abstract Optional<ServiceWeights> getServiceWeights();

@JsonProperty("NodeMeta")
public abstract Optional<Map<String,String>> getNodeMeta();
public abstract Map<String,String> getNodeMeta();
}