Skip to content

Commit b4b5080

Browse files
author
Alan Christie
committed
Adds schema for tests
Other adjustments
1 parent 512a9ca commit b4b5080

File tree

2 files changed

+121
-4
lines changed

2 files changed

+121
-4
lines changed

decoder/job-definition-schema.yaml

Lines changed: 98 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ $schema: http://json-schema.org/draft-07/schema#
88
title: Data Manager Job Definition
99
description: >-
1010
Defines one or more jobs that can be executed
11-
by the Data manager Job Operator
11+
by the Data manager Job Operator, and tests that can be automated
12+
by the Job Tester (jote)
1213
1314
type: object
1415
properties:
@@ -91,11 +92,13 @@ definitions:
9192
type: string
9293
minLength: 1
9394
maxLength: 4096
95+
tests:
96+
$ref: '#/definitions/job-test'
9497
required:
98+
- name
9599
- version
96100
- image
97101
- command
98-
- name
99102

100103
# A Job container image
101104
# The 'type' is optional and is used to indicate
@@ -159,8 +162,7 @@ definitions:
159162
environment:
160163
type: array
161164
items:
162-
anyOf:
163-
- $ref: '#/definitions/environment-value-from'
165+
$ref: '#/definitions/environment-value-from'
164166

165167
# An Image environment from something else.
166168
environment-value-from:
@@ -260,3 +262,95 @@ definitions:
260262
minLength: 1
261263
maxLength: 63
262264
pattern: '^[a-z]([a-z0-9-]*[a-z0-9])?$'
265+
266+
# An individual Test.
267+
# Consists of a identity (i.e. 'test-filter-molecules')
268+
# followed by a Test object.
269+
job-test:
270+
type: object
271+
additionalProperties: false
272+
patternProperties:
273+
'^[a-z]{1}[a-z0-9-]{0,79}$':
274+
$ref: '#/definitions/test'
275+
minProperties: 1
276+
277+
# An individual Test
278+
test:
279+
type: object
280+
additionalProperties: false
281+
properties:
282+
run-level:
283+
type: integer
284+
minimum: 1
285+
maximum: 100
286+
ignore:
287+
type: 'null'
288+
inputs:
289+
$ref: '#/definitions/test-input'
290+
options:
291+
$ref: '#/definitions/test-option'
292+
checks:
293+
type: object
294+
properties:
295+
exitCode:
296+
type: integer
297+
outputs:
298+
type: array
299+
items:
300+
$ref: '#/definitions/test-checks-output'
301+
required:
302+
- exitCode
303+
304+
# A test input
305+
test-input:
306+
type: object
307+
additionalProperties: false
308+
patternProperties:
309+
'^[a-zA-Z]{1}[a-zA-Z0-9_-]{0,31}$':
310+
type: string
311+
312+
# A test option
313+
test-option:
314+
type: object
315+
additionalProperties: false
316+
patternProperties:
317+
'^[a-zA-Z]{1}[a-zA-Z0-9_-]{0,31}$':
318+
oneOf:
319+
- type: string
320+
- type: number
321+
322+
# Test output checks
323+
test-checks-output:
324+
type: object
325+
propertiies:
326+
name:
327+
type: string
328+
checks:
329+
type: array
330+
items:
331+
anyOf:
332+
- $ref: '#/definitions/test-checks-output-exists'
333+
- $ref: '#/definitions/test-checks-output-linecount'
334+
required:
335+
- name
336+
337+
# A test output check (for a file existing or not existing)
338+
test-checks-output-exists:
339+
type: object
340+
additionalProperties: false
341+
propertiies:
342+
exists:
343+
type: boolean
344+
required:
345+
- exists
346+
347+
# A test output check (for a file length)
348+
test-checks-output-linecount:
349+
type: object
350+
additionalProperties: false
351+
propertiies:
352+
lineCount:
353+
type: integer
354+
minimum: 0
355+
required:
356+
- lineCount

tests/test_validate_job_schema.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,26 @@ def test_validate_image_cores_32():
135135

136136
# Assert
137137
assert error is None
138+
139+
140+
def test_validate_two_basic_tests():
141+
# Arrange
142+
text: Dict[str, Any] = deepcopy(_MINIMAL)
143+
demo_job: Dict[str, Any] = text['jobs']['demo']
144+
demo_job['tests'] =\
145+
{'basic-1': {'run-level': 1,
146+
'ignore': None},
147+
'basic-2': {'run-level': 100,
148+
'inputs': {'file-1': 'blob.txt'},
149+
'options': {'param-1': 32,
150+
'param-2': 'a'},
151+
'checks': {'exitCode': 0,
152+
'outputs': [{'name': 'blob.txt',
153+
'checks': [{'exists': True},
154+
{'lineCount': 100}]}]}}}
155+
156+
# Act
157+
error = decoder.validate_job_schema(text)
158+
159+
# Assert
160+
assert error is None

0 commit comments

Comments
 (0)