Skip to content

Commit

Permalink
Health config ignore option is disregarder from the catalog
Browse files Browse the repository at this point in the history
When provisioning from the catalog the health config ignore option is
always set to true (default value).

By default we have the jackson option Include.NON_DEFAULT and false is a
defalt value for boolean/Boolean in jackson. But in Admiral the default
value for ignore health check is true. Setting NON_NULL option for
ignoreOnProvision filed.

Change-Id: I4a2d31bbf5a63e9b770060c219ff7bbd84600a0e
Reviewed-on: http://bellevue-ci.eng.vmware.com:8080/23129
Closures-Verified: jenkins <[email protected]>
CS-Verified: jenkins <[email protected]>
Upgrade-Verified: jenkins <[email protected]>
Bellevue-Verified: jenkins <[email protected]>
Reviewed-by: Sergio Sanchez <[email protected]>
  • Loading branch information
eivanova committed Dec 15, 2017
1 parent 11e0144 commit 9aed1a8
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import java.util.logging.Level;

import com.esotericsoftware.kryo.serializers.VersionFieldSerializer.Since;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import io.netty.bootstrap.Bootstrap;
Expand Down Expand Up @@ -110,6 +112,7 @@ public enum HttpVersion {
@Documentation(description = "Ignore health check on provision. Default is true.")
@UsageOption(option = PropertyUsageOption.OPTIONAL)
@JsonProperty("ignore_on_provision")
@JsonInclude(Include.NON_NULL)
public Boolean ignoreOnProvision;

/** If set to true the unhealthy containers from a description will be redeployed. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,34 @@ public void testDeserializeSerializeComplexCompositeTemplate() throws IOExceptio
assertTrue((contentCompose != null) && (!contentCompose.isEmpty()));
}

@Test
public void testSeriaizeDeserializeCompositeTemplateWithHealthCheck() throws IOException {

// Assert that healthConfig.ignoreOnProvision is serialized when false
String expectedContent = getContent("composite.simple.health.yaml");

CompositeTemplate template = deserializeCompositeTemplate(expectedContent);

ContainerDescription data = (ContainerDescription) template.components.get("hello").data;
assertNotNull(data.healthConfig);
assertEquals(false, data.healthConfig.ignoreOnProvision);

// Assert that healthConfig.ignoreOnProvision is serialized when true
data.healthConfig.ignoreOnProvision = true;
String content = serializeCompositeTemplate(template);

template = deserializeCompositeTemplate(content);

data = (ContainerDescription) template.components.get("hello").data;
assertNotNull(data.healthConfig);
assertEquals(true, data.healthConfig.ignoreOnProvision);

// Assert that healthConfig.ignoreOnProvision is not serialized when null
data.healthConfig = null;
content = serializeCompositeTemplate(template);
assertFalse(content.contains("health_config"));
}

@Test
public void testDeserializeSerializeComplexCompositeTemplateWithNetwork() throws IOException {

Expand Down
17 changes: 17 additions & 0 deletions compute/src/test/resources/compose/composite.simple.health.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
id: "hello"
status: "PUBLISHED"
name: "hello"
components:
hello:
type: "App.Container"
data:
name: "hello"
image: "registry.hub.docker.com/kitematic/hello-world-nginx"
publish_all: false
restart_policy: "always"
network_mode: "bridge"
health_config:
protocol: "COMMAND"
command: "foobar"
ignore_on_provision: false

0 comments on commit 9aed1a8

Please sign in to comment.