from flask import Flask
from flask_restful import Api
+from flasgger import Swagger
from api.urls import urlpatterns
from yardstick import _init_logging
app = Flask(__name__)
+Swagger(app)
+
api = Api(app)
+
reduce(lambda a, b: a.add_resource(b.resource, b.url,
endpoint=b.endpoint) or a, urlpatterns, api)
--- /dev/null
+Query task result data
+
+This api offer the interface to get the result data via task_id
+We will return a result json dict
+---
+tags:
+ - Results
+parameters:
+ -
+ in: query
+ name: action
+ type: string
+ default: getResult
+ required: true
+ -
+ in: query
+ name: measurement
+ type: string
+ description: test case name
+ required: true
+ -
+ in: query
+ name: task_id
+ type: string
+ description: the task_id you get before
+ required: true
+responses:
+ 200:
+ description: a result json dict
+ schema:
+ id: ResultModel
+ properties:
+ status:
+ type: string
+ description: the status of the certain task
+ default: success
+ result:
+ schema:
+ type: array
+ items:
+ type: object
--- /dev/null
+TestCases Actions\r
+\r
+This API may offer many actions, including runTestCase\r
+\r
+action: runTestCase\r
+This api offer the interface to run a test case in yardstick\r
+we will return a task_id for querying\r
+you can use the returned task_id to get the result data\r
+---\r
+tags:\r
+ - Release Action\r
+parameters:\r
+ - in: body\r
+ name: body\r
+ description: this is the input json dict\r
+ schema:\r
+ id: TestCaseActionModel\r
+ required:\r
+ - action\r
+ - args\r
+ properties:\r
+ action:\r
+ type: string\r
+ description: this is action for testcases\r
+ default: runTestCase\r
+ args:\r
+ schema:\r
+ id: TestCaseActionArgsModel\r
+ required:\r
+ - testcase\r
+ properties:\r
+ testcase:\r
+ type: string\r
+ description: this is the test case name\r
+ default: tc002\r
+ opts:\r
+ schema:\r
+ id: TestCaseActionArgsOptsModel\r
+responses:\r
+ 200:\r
+ description: A result json dict\r
+ schema:\r
+ id: result\r
+ properties:\r
+ status:\r
+ type: string\r
+ default: success\r
+ result:\r
+ type: string\r
+ description: task_id of this task\r
--- /dev/null
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+from flask_restful import fields
+from flask_restful_swagger import swagger
+
+
+# for testcases/action runTestCase action
+@swagger.model
+class TestCaseActionArgsOptsTaskArgModel:
+ resource_fields = {
+ }
+
+
+@swagger.model
+class TestCaseActionArgsOptsModel:
+ resource_fields = {
+ 'task-args': TestCaseActionArgsOptsTaskArgModel,
+ 'keep-deploy': fields.String,
+ 'suite': fields.String
+ }
+
+
+@swagger.model
+class TestCaseActionArgsModel:
+ resource_fields = {
+ 'testcase': fields.String,
+ 'opts': TestCaseActionArgsOptsModel
+ }
+
+
+@swagger.model
+class TestCaseActionModel:
+ resource_fields = {
+ 'action': fields.String,
+ 'args': TestCaseActionArgsModel
+ }
+
+
+# for results
+@swagger.model
+class ResultModel:
+ resource_fields = {
+ 'status': fields.String,
+ 'result': fields.List
+ }
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import logging
+import os
from flask import request
from flask_restful import Resource
+from flasgger.utils import swag_from
from api.utils import common as common_utils
+from api.swagger import models
from api.actions import test as test_action
from api.actions import samples as samples_action
from api.actions import result as result_action
logger = logging.getLogger(__name__)
+TestCaseActionModel = models.TestCaseActionModel
+TestCaseActionArgsModel = models.TestCaseActionArgsModel
+TestCaseActionArgsOptsModel = models.TestCaseActionArgsOptsModel
+TestCaseActionArgsOptsTaskArgModel = models.TestCaseActionArgsOptsTaskArgModel
+
+
class Release(Resource):
+ @swag_from(os.getcwd() + '/swagger/docs/testcases.yaml')
def post(self):
action = common_utils.translate_to_str(request.json.get('action', ''))
args = common_utils.translate_to_str(request.json.get('args', {}))
return common_utils.error_handler('Wrong action')
+ResultModel = models.ResultModel
+
+
class Results(Resource):
+ @swag_from(os.getcwd() + '/swagger/docs/results.yaml')
def get(self):
args = common_utils.translate_to_str(request.args)
action = args.get('action', '')
influxdb==3.0.0
pyroute2==0.4.10
docker-py==1.10.6
+flasgger==0.5.13
+flask-restful-swagger==0.19