Merge "[task schema]Move TASK_RESULT_SCHEMA and rename to OLD_TASK_RESULT_SCHEMA"
This commit is contained in:
commit
fe049ee20f
@ -253,8 +253,6 @@ class _Deployment(APIGroup):
|
|||||||
|
|
||||||
class _Task(APIGroup):
|
class _Task(APIGroup):
|
||||||
|
|
||||||
TASK_RESULT_SCHEMA = objects.task.TASK_RESULT_SCHEMA
|
|
||||||
|
|
||||||
def list(self, **filters):
|
def list(self, **filters):
|
||||||
return [task.to_dict() for task in objects.Task.list(**filters)]
|
return [task.to_dict() for task in objects.Task.list(**filters)]
|
||||||
|
|
||||||
|
@ -49,6 +49,81 @@ from rally.task import utils as tutils
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
OLD_TASK_RESULT_SCHEMA = {
|
||||||
|
"type": "object",
|
||||||
|
"$schema": consts.JSON_SCHEMA,
|
||||||
|
"properties": {
|
||||||
|
"key": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"kw": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"name": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"pos": {
|
||||||
|
"type": "integer"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"required": ["kw", "name", "pos"]
|
||||||
|
},
|
||||||
|
"sla": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"criterion": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"detail": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"success": {
|
||||||
|
"type": "boolean"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"hooks": {"type": "array"},
|
||||||
|
"result": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"atomic_actions": {
|
||||||
|
"type": "object"
|
||||||
|
},
|
||||||
|
"duration": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"error": {
|
||||||
|
"type": "array"
|
||||||
|
},
|
||||||
|
"idle_duration": {
|
||||||
|
"type": "number"
|
||||||
|
},
|
||||||
|
"output": {"type": "object"}
|
||||||
|
},
|
||||||
|
"required": ["atomic_actions", "duration", "error",
|
||||||
|
"idle_duration"]
|
||||||
|
},
|
||||||
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"load_duration": {
|
||||||
|
"type": "number",
|
||||||
|
},
|
||||||
|
"full_duration": {
|
||||||
|
"type": "number",
|
||||||
|
},
|
||||||
|
"created_at": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": ["key", "sla", "result", "load_duration", "full_duration"],
|
||||||
|
"additionalProperties": False
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FailedToLoadTask(exceptions.RallyException):
|
class FailedToLoadTask(exceptions.RallyException):
|
||||||
error_code = 472
|
error_code = 472
|
||||||
@ -620,7 +695,7 @@ class TaskCommands(object):
|
|||||||
for result in tasks_results:
|
for result in tasks_results:
|
||||||
try:
|
try:
|
||||||
jsonschema.validate(
|
jsonschema.validate(
|
||||||
result, api.task.TASK_RESULT_SCHEMA)
|
result, OLD_TASK_RESULT_SCHEMA)
|
||||||
except jsonschema.ValidationError as e:
|
except jsonschema.ValidationError as e:
|
||||||
raise FailedToLoadResults(source=task_id,
|
raise FailedToLoadResults(source=task_id,
|
||||||
msg=six.text_type(e))
|
msg=six.text_type(e))
|
||||||
|
@ -137,96 +137,6 @@ HOOK_RESULTS_SCHEMA = {
|
|||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
}
|
}
|
||||||
|
|
||||||
TASK_RESULT_SCHEMA = {
|
|
||||||
"type": "object",
|
|
||||||
"$schema": consts.JSON_SCHEMA,
|
|
||||||
"properties": {
|
|
||||||
"key": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"kw": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"pos": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["kw", "name", "pos"]
|
|
||||||
},
|
|
||||||
"sla": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"criterion": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"detail": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"success": {
|
|
||||||
"type": "boolean"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"hooks": {"type": "array", "items": HOOK_RESULTS_SCHEMA},
|
|
||||||
"result": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"atomic_actions": {
|
|
||||||
# NOTE(chenhb): back compatible, old format is dict
|
|
||||||
"oneOf": [{"type": "array"},
|
|
||||||
{"type": "object"}]
|
|
||||||
},
|
|
||||||
"duration": {
|
|
||||||
"type": "number"
|
|
||||||
},
|
|
||||||
"error": {
|
|
||||||
"type": "array"
|
|
||||||
},
|
|
||||||
"idle_duration": {
|
|
||||||
"type": "number"
|
|
||||||
},
|
|
||||||
# NOTE(amaretskiy): "scenario_output" is deprecated
|
|
||||||
# in favor of "output"
|
|
||||||
"scenario_output": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"data": {
|
|
||||||
"type": "object"
|
|
||||||
},
|
|
||||||
"errors": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
},
|
|
||||||
"required": ["data", "errors"]
|
|
||||||
},
|
|
||||||
"output": OUTPUT_SCHEMA
|
|
||||||
},
|
|
||||||
"required": ["atomic_actions", "duration", "error",
|
|
||||||
"idle_duration"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"load_duration": {
|
|
||||||
"type": "number",
|
|
||||||
},
|
|
||||||
"full_duration": {
|
|
||||||
"type": "number",
|
|
||||||
},
|
|
||||||
"created_at": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"required": ["key", "sla", "result", "load_duration", "full_duration"],
|
|
||||||
"additionalProperties": False
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class Task(object):
|
class Task(object):
|
||||||
"""Represents a task object.
|
"""Represents a task object.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user