diff --git a/src/main/java/com/DeploymentPortal/api/Manifest/schema/healthChecks.json b/src/main/java/com/DeploymentPortal/api/Manifest/schema/healthChecks.json new file mode 100644 index 00000000..e1a6b890 --- /dev/null +++ b/src/main/java/com/DeploymentPortal/api/Manifest/schema/healthChecks.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema/#", + "definitions": { + "healthCheck": { + "type": "object", + "properties": { + "type": { + "enum": ["tcp", "http"] + }, + "port": { + "enum": ["metrics","serviceport"] + }, + "successThreshold": { + "type": "integer" + }, + "initialDelaySeconds": { + "type": "integer" + }, + "periodSeconds": { + "type": "integer" + }, + "failureThreshold": { + "type": "integer" + } + } + } + }, + "type": "object", + "properties": { + "livenessCheck": { + "$ref": "#/definitions/healthCheck" + }, + "readinessCheck":{ + "allOf": [ + { + "$ref": "#/definitions/healthCheck" + }, + { + "properties": { + "path": { + "type": "string" + } + } + } + ] +} + } +} \ No newline at end of file diff --git a/src/test/java/com/DeploymentPortal/api/Manifest/SchemaTest.java b/src/test/java/com/DeploymentPortal/api/Manifest/SchemaTest.java index d96f90c2..7d5ddb59 100644 --- a/src/test/java/com/DeploymentPortal/api/Manifest/SchemaTest.java +++ b/src/test/java/com/DeploymentPortal/api/Manifest/SchemaTest.java @@ -83,4 +83,13 @@ public class SchemaTest { assertFalse(validationUtils.isJsonValid(schemaFile, jsonFile)); } + + @Test + void expectTrueWhenAllThePropertiesOfHealthChecksAreValid() throws IOException, ProcessingException { + File schemaFile = new File(schemaPath + "healthChecks.json"); + File jsonFile = new File(testData + "validHealthChecks.json"); + ValidationUtils validationUtils = new ValidationUtils(); + + assertTrue(validationUtils.isJsonValid(schemaFile, jsonFile)); + } } diff --git a/src/test/java/com/DeploymentPortal/api/Manifest/schema/TestData/validHealthChecks.json b/src/test/java/com/DeploymentPortal/api/Manifest/schema/TestData/validHealthChecks.json new file mode 100644 index 00000000..4d5b4b0b --- /dev/null +++ b/src/test/java/com/DeploymentPortal/api/Manifest/schema/TestData/validHealthChecks.json @@ -0,0 +1,19 @@ +{ + "livenessCheck": { + "type": "tcp", + "port": "metrics", + "successThreshold": 1, + "initialDelaySeconds": 120, + "periodSeconds": 15, + "failureThreshold": 5 + }, + "readinessCheck": { + "type": "http", + "port": "metrics", + "path": "/actuator/health", + "successThreshold": 1, + "initialDelaySeconds": 120, + "periodSeconds": 15, + "failureThreshold": 5 + } +} \ No newline at end of file