summaryrefslogtreecommitdiffstats
path: root/api/resources/samples_action.py
diff options
context:
space:
mode:
authorchenjiankun <chenjiankun1@huawei.com>2017-06-26 09:46:24 +0000
committerchenjiankun <chenjiankun1@huawei.com>2017-06-29 11:25:17 +0000
commitda62008a0a98cb8793ea42827a7da5e149edd144 (patch)
treef91e35eabe04ebb8c6618345c0fd1b76c5f37a2c /api/resources/samples_action.py
parent1ff9df7e724eb0c981aebd5f5b8aa90db0da292b (diff)
Call core code directly in the API of run test case
JIRA: YARDSTICK-688 We need to call core code directly in the API of runTestCase. It would be more stable. Change-Id: I431a85ded7cd3b20da0462f947c25d91bb99decd Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
Diffstat (limited to 'api/resources/samples_action.py')
-rw-r--r--api/resources/samples_action.py35
1 files changed, 19 insertions, 16 deletions
diff --git a/api/resources/samples_action.py b/api/resources/samples_action.py
index 3093864e0..10b9980af 100644
--- a/api/resources/samples_action.py
+++ b/api/resources/samples_action.py
@@ -11,32 +11,35 @@ import uuid
import os
import logging
-from api.utils import common as common_utils
+from api.utils.common import result_handler
+from api.utils.thread import TaskThread
from yardstick.common import constants as consts
+from yardstick.benchmark.core import Param
+from yardstick.benchmark.core.task import Task
logger = logging.getLogger(__name__)
+logger.setLevel(logging.DEBUG)
-def runTestCase(args):
+def run_test_case(args):
try:
- opts = args.get('opts', {})
- testcase_name = args['testcase']
+ case_name = args['testcase']
except KeyError:
- return common_utils.error_handler('Lack of testcase argument')
+ return result_handler(consts.API_ERROR, 'testcase must be provided')
- testcase = os.path.join(consts.SAMPLE_CASE_DIR, testcase_name + '.yaml')
+ testcase = os.path.join(consts.SAMPLE_CASE_DIR,
+ '{}.yaml'.format(case_name))
task_id = str(uuid.uuid4())
- command_list = ['task', 'start']
- command_list = common_utils.get_command_list(command_list, opts, testcase)
- logger.debug('The command_list is: %s', command_list)
-
- logger.debug('Start to execute command list')
- task_dict = {
- 'task_id': task_id,
- 'details': testcase_name
+ task_args = {
+ 'inputfile': [testcase],
+ 'task_id': task_id
}
- common_utils.exec_command_task(command_list, task_dict)
+ task_args.update(args.get('opts', {}))
+
+ param = Param(task_args)
+ task_thread = TaskThread(Task().start, param)
+ task_thread.start()
- return common_utils.result_handler('success', task_id)
+ return result_handler(consts.API_SUCCESS, {'task_id': task_id})