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
23 from api.database.v1.handlers import TasksHandler
25 LOG = logging.getLogger(__name__)
26 LOG.setLevel(logging.DEBUG)
29 TestSuiteActionModel = models.TestSuiteActionModel
30 TestSuiteActionArgsModel = models.TestSuiteActionArgsModel
31 TestSuiteActionArgsOptsModel = models.TestSuiteActionArgsOptsModel
32 TestSuiteActionArgsOptsTaskArgModel = \
33 models.TestSuiteActionArgsOptsTaskArgModel
36 class V1Testsuite(ApiResource):
38 @swag_from(os.path.join(consts.REPOS_DIR,
39 'api/swagger/docs/testsuites_action.yaml'))
41 return self._dispatch_post()
43 def run_test_suite(self, args):
45 name = args['testsuite']
47 return result_handler(consts.API_ERROR,
48 'testsuite must be provided')
50 testsuite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(name))
52 task_id = str(uuid.uuid4())
55 'inputfile': [testsuite],
59 task_args.update(args.get('opts', {}))
61 param = Param(task_args)
62 task_thread = TaskThread(Task().start, param, TasksHandler())
65 return result_handler(consts.API_SUCCESS, {'task_id': task_id})