aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/actions/test.py14
-rw-r--r--api/urls.py4
-rw-r--r--api/utils/common.py7
-rw-r--r--api/views.py4
4 files changed, 10 insertions, 19 deletions
diff --git a/api/actions/test.py b/api/actions/test.py
index b1dc212c2..fda0ffd32 100644
--- a/api/actions/test.py
+++ b/api/actions/test.py
@@ -7,7 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import uuid
-import json
import os
import logging
@@ -22,12 +21,7 @@ def runTestCase(args):
opts = args.get('opts', {})
testcase = args['testcase']
except KeyError:
- logger.error('Lack of testcase argument')
- result = {
- 'status': 'error',
- 'message': 'need testcase name'
- }
- return json.dumps(result)
+ return common_utils.error_handler('Lack of testcase argument')
testcase = os.path.join(conf.TEST_CASE_PATH,
conf.TEST_CASE_PRE + testcase + '.yaml')
@@ -41,8 +35,4 @@ def runTestCase(args):
logger.debug('Start to execute command list')
common_utils.exec_command_task(command_list, task_id)
- result = {
- 'status': 'success',
- 'task_id': task_id
- }
- return json.dumps(result)
+ return common_utils.result_handler('success', task_id)
diff --git a/api/urls.py b/api/urls.py
index eaaf8b6d1..323e5cb9f 100644
--- a/api/urls.py
+++ b/api/urls.py
@@ -11,7 +11,7 @@ from api.utils.common import Url
urlpatterns = [
- Url('/yardstick/test/action', views.Test, 'test'),
- Url('/yardstick/result/action', views.Result, 'result'),
+ Url('/yardstick/testcases/release/action', views.Release, 'release'),
+ Url('/yardstick/results', views.Results, 'results'),
Url('/yardstick/env/action', views.Env, 'env')
]
diff --git a/api/utils/common.py b/api/utils/common.py
index 09cfc04d4..e3e64a72b 100644
--- a/api/utils/common.py
+++ b/api/utils/common.py
@@ -8,7 +8,8 @@
##############################################################################
import collections
import logging
-import json
+
+from flask import jsonify
from api.utils.daemonthread import DaemonThread
from yardstick.cmd.cli import YardstickCLI
@@ -50,7 +51,7 @@ def error_handler(message):
'status': 'error',
'message': message
}
- return json.dumps(result)
+ return jsonify(result)
def result_handler(status, data):
@@ -58,7 +59,7 @@ def result_handler(status, data):
'status': status,
'result': data
}
- return json.dumps(result)
+ return jsonify(result)
class Url(object):
diff --git a/api/views.py b/api/views.py
index 7357625e0..065de673b 100644
--- a/api/views.py
+++ b/api/views.py
@@ -19,7 +19,7 @@ from api.actions import env as env_action
logger = logging.getLogger(__name__)
-class Test(Resource):
+class Release(Resource):
def post(self):
action = common_utils.translate_to_str(request.json.get('action', ''))
args = common_utils.translate_to_str(request.json.get('args', {}))
@@ -31,7 +31,7 @@ class Test(Resource):
return common_utils.error_handler('Wrong action')
-class Result(Resource):
+class Results(Resource):
def get(self):
args = common_utils.translate_to_str(request.args)
action = args.get('action', '')