Skip to content

Commit e533c3f

Browse files
rakshandabhatvimleshmishra
authored andcommitted
CP-12230 DVP Record size validation changes for setting ZFS record size (delphix#556)
* CP-12230 DVP Record size validation changes for setting ZFS record size
1 parent dfafb4c commit e533c3f

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

tools/src/main/python/dlpx/virtualization/_internal/validation_schemas/plugin_schema.json

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,15 @@
166166
"required": ["nameField", "identityFields"],
167167
"nameField": { "type": "string" },
168168
"identityFields": { "type": "array", "minItems": 1, "items": { "type": "string" } }
169+
},
170+
"recordSizeObject": {
171+
"type": "object",
172+
"properties": {
173+
"properties": {
174+
"properties": {
175+
"recordSizeInKB" : {"properties": {"type": {"enum" : ["integer"]}}}}
176+
}
177+
}
169178
}
170179
},
171180
"type": "object",
@@ -200,10 +209,24 @@
200209
]
201210
},
202211
"virtualSourceDefinition": {
203-
"$ref": "#/definitions/jsonSchema"
212+
"allOf": [
213+
{
214+
"$ref": "#/definitions/jsonSchema"
215+
},
216+
{
217+
"$ref": "#/definitions/recordSizeObject"
218+
}
219+
]
204220
},
205221
"linkedSourceDefinition": {
206-
"$ref": "#/definitions/jsonSchema"
222+
"allOf": [
223+
{
224+
"$ref": "#/definitions/jsonSchema"
225+
},
226+
{
227+
"$ref": "#/definitions/recordSizeObject"
228+
}
229+
]
207230
},
208231
"snapshotDefinition": {
209232
"$ref": "#/definitions/jsonSchema"

tools/src/test/python/dlpx/virtualization/_internal/test_schema_validator.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,56 @@ def test_bad_type_in_array(schema_file):
356356
message = err_info.value.message
357357
assert ("'strings' is not valid under any of the given schemas"
358358
in message)
359+
360+
@staticmethod
361+
@pytest.mark.parametrize('linked_source_definition',
362+
[{
363+
'type': 'object',
364+
'additionalProperties': False,
365+
'properties': {
366+
'recordSizeInKB': {
367+
'type': 'string'
368+
}
369+
}
370+
}])
371+
def test_bad_recordSizeInKB_type_string(schema_file):
372+
with pytest.raises(exceptions.SchemaValidationError) as err_info:
373+
validator = SchemaValidator(schema_file, const.PLUGIN_SCHEMA)
374+
validator.validate()
375+
376+
message = err_info.value.message
377+
assert "'string' is not one of ['integer']" in message
378+
379+
@staticmethod
380+
@pytest.mark.parametrize('virtual_source_definition',
381+
[{
382+
'type': 'object',
383+
'additionalProperties': False,
384+
'properties': {
385+
'recordSizeInKB': {
386+
'type': 'array'
387+
}
388+
}
389+
}])
390+
def test_bad_recordSizeInKB_type_array_virtual(schema_file):
391+
with pytest.raises(exceptions.SchemaValidationError) as err_info:
392+
validator = SchemaValidator(schema_file, const.PLUGIN_SCHEMA)
393+
validator.validate()
394+
395+
message = err_info.value.message
396+
assert "'array' is not one of ['integer']" in message
397+
398+
@staticmethod
399+
@pytest.mark.parametrize('virtual_source_definition',
400+
[{
401+
'type': 'object',
402+
'additionalProperties': False,
403+
'properties': {
404+
'recordSizeInKB': {
405+
'type': 'integer'
406+
}
407+
}
408+
}])
409+
def test_recordSizeInKB_type_virtual(schema_file):
410+
validator = SchemaValidator(schema_file, const.PLUGIN_SCHEMA)
411+
validator.validate()

0 commit comments

Comments
 (0)