Open storperf testcase to huawei-pod2
[yardstick.git] / api / resources / testsuites_action.py
1 ##############################################################################
2 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
3 #
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
10 import uuid
11 import os
12 import logging
13
14 from api.utils.common import result_handler
15 from api.utils.thread import TaskThread
16 from yardstick.common import constants as consts
17 from yardstick.benchmark.core import Param
18 from yardstick.benchmark.core.task import Task
19
20 logger = logging.getLogger(__name__)
21 logger.setLevel(logging.DEBUG)
22
23
24 def run_test_suite(args):
25     try:
26         suite_name = args['testsuite']
27     except KeyError:
28         return result_handler(consts.API_ERROR, 'testsuite must be provided')
29
30     testsuite = os.path.join(consts.TESTSUITE_DIR,
31                              '{}.yaml'.format(suite_name))
32
33     task_id = str(uuid.uuid4())
34
35     task_args = {
36         'inputfile': [testsuite],
37         'task_id': task_id,
38         'suite': True
39     }
40     task_args.update(args.get('opts', {}))
41
42     param = Param(task_args)
43     task_thread = TaskThread(Task().start, param)
44     task_thread.start()
45
46     return result_handler(consts.API_SUCCESS, {'task_id': task_id})