6 from api import ApiResource
7 from yardstick.common.utils import result_handler
8 from yardstick.common import constants as consts
9 from yardstick.benchmark.core.testsuite import Testsuite
10 from yardstick.benchmark.core import Param
12 LOG = logging.getLogger(__name__)
13 LOG.setLevel(logging.DEBUG)
16 class V2Testsuites(ApiResource):
20 testsuite_list = Testsuite().list_all(param)
23 'testsuites': testsuite_list
26 return result_handler(consts.API_SUCCESS, data)
29 return self._dispatch_post()
31 def create_suite(self, args):
33 suite_name = args['name']
35 return result_handler(consts.API_ERROR, 'name must be provided')
38 testcases = args['testcases']
40 return result_handler(consts.API_ERROR, 'testcases must be provided')
42 testcases = [{'file_name': '{}.yaml'.format(t)} for t in testcases]
44 suite = os.path.join(consts.TESTSUITE_DIR, '{}.yaml'.format(suite_name))
46 'schema': 'yardstick:suite:0.1',
48 'test_cases_dir': 'tests/opnfv/test_cases/',
49 'test_cases': testcases
52 LOG.info('write test suite')
53 with open(suite, 'w') as f:
54 yaml.dump(suite_content, f, default_flow_style=False)
56 return result_handler(consts.API_SUCCESS, {'suite': suite_name})