1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9 from __future__ import absolute_import
14 from flasgger.utils import swag_from
16 from api import ApiResource
17 from api.utils.thread import TaskThread
18 from yardstick.common import constants as consts
19 from yardstick.common.utils import result_handler
20 from yardstick.benchmark.core import Param
21 from yardstick.benchmark.core.task import Task
22 from api.swagger import models
24 LOG = logging.getLogger(__name__)
25 LOG.setLevel(logging.DEBUG)
28 TestSuiteActionModel = models.TestSuiteActionModel
29 TestSuiteActionArgsModel = models.TestSuiteActionArgsModel
30 TestSuiteActionArgsOptsModel = models.TestSuiteActionArgsOptsModel
31 TestSuiteActionArgsOptsTaskArgModel = \
32 models.TestSuiteActionArgsOptsTaskArgModel
35 class V1Testsuite(ApiResource):
37 @swag_from(os.path.join(consts.REPOS_DIR,
38 'api/swagger/docs/testsuites_action.yaml'))
40 return self._dispatch_post()
42 def run_test_suite(self, args):
44 name = args['testsuite']
46 return result_handler(consts.API_ERROR,
47 'testsuite must be provided')
49 testsuite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(name))
51 task_id = str(uuid.uuid4())
54 'inputfile': [testsuite],
58 task_args.update(args.get('opts', {}))
60 param = Param(task_args)
61 task_thread = TaskThread(Task().start, param)
64 return result_handler(consts.API_SUCCESS, {'task_id': task_id})