Add. Shubham, Ankit | Add. Validation for all the attributes of healthchecks

This commit is contained in:
Kuamr Shubham
2020-03-10 14:24:44 +05:30
parent 58b3ef35f7
commit d2fd438180
3 changed files with 76 additions and 0 deletions

View File

@@ -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"
}
}
}
]
}
}
}

View File

@@ -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));
}
}

View File

@@ -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
}
}