diff --git a/rally/api.py b/rally/api.py index 9914c54501..2ee0cb6425 100644 --- a/rally/api.py +++ b/rally/api.py @@ -253,8 +253,6 @@ class _Deployment(APIGroup): class _Task(APIGroup): - TASK_RESULT_SCHEMA = objects.task.TASK_RESULT_SCHEMA - def list(self, **filters): return [task.to_dict() for task in objects.Task.list(**filters)] diff --git a/rally/cli/commands/task.py b/rally/cli/commands/task.py index 784c588139..4679726a25 100644 --- a/rally/cli/commands/task.py +++ b/rally/cli/commands/task.py @@ -49,6 +49,81 @@ from rally.task import utils as tutils 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): error_code = 472 @@ -620,7 +695,7 @@ class TaskCommands(object): for result in tasks_results: try: jsonschema.validate( - result, api.task.TASK_RESULT_SCHEMA) + result, OLD_TASK_RESULT_SCHEMA) except jsonschema.ValidationError as e: raise FailedToLoadResults(source=task_id, msg=six.text_type(e)) diff --git a/rally/common/objects/task.py b/rally/common/objects/task.py index a152b92cfb..66cbb7dcae 100644 --- a/rally/common/objects/task.py +++ b/rally/common/objects/task.py @@ -137,96 +137,6 @@ HOOK_RESULTS_SCHEMA = { "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): """Represents a task object.