aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorJingLu5 <lvjing5@huawei.com>2016-12-22 12:07:55 +0800
committerJingLu5 <lvjing5@huawei.com>2017-01-10 15:31:35 +0000
commit52ae99e54fc67614e71bf1920848bb7b16bcd153 (patch)
tree1590f685827ad1a91e550e3b013e3e25fb2dd224 /api
parent74479a22c461cc2c08f9525879481c0a86d3af84 (diff)
Create API to run test suite
JIRA: YARDSTICK-475 This API will be used to run test suite files in the test/opnfv/test_suites directory Change-Id: I208edf9abed62fd6436de988ac85bfe99c4d01bd Signed-off-by: JingLu5 <lvjing5@huawei.com>
Diffstat (limited to 'api')
-rw-r--r--api/conf.py2
-rw-r--r--api/resources/testsuites_action.py45
-rw-r--r--api/swagger/docs/release_action.yaml (renamed from api/swagger/docs/testcases.yaml)0
-rw-r--r--api/swagger/docs/testsuites_action.yaml50
-rw-r--r--api/swagger/models.py31
-rw-r--r--api/urls.py1
-rw-r--r--api/views.py14
7 files changed, 142 insertions, 1 deletions
diff --git a/api/conf.py b/api/conf.py
index df44042b1..3d9d190a0 100644
--- a/api/conf.py
+++ b/api/conf.py
@@ -24,4 +24,6 @@ TEST_CASE_PRE = 'opnfv_yardstick_'
TEST_SUITE_PATH = '../tests/opnfv/test_suites/'
+TEST_SUITE_PRE = 'opnfv_'
+
OUTPUT_CONFIG_FILE_PATH = '/etc/yardstick/yardstick.conf'
diff --git a/api/resources/testsuites_action.py b/api/resources/testsuites_action.py
new file mode 100644
index 000000000..f833dc22f
--- /dev/null
+++ b/api/resources/testsuites_action.py
@@ -0,0 +1,45 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+"""Yardstick test suite api action"""
+
+from __future__ import absolute_import
+import uuid
+import os
+import logging
+
+from api import conf
+from api.utils import common as common_utils
+
+logger = logging.getLogger(__name__)
+
+
+def runTestSuite(args):
+ try:
+ opts = args.get('opts', {})
+ testsuite = args['testsuite']
+ except KeyError:
+ return common_utils.error_handler('Lack of testsuite argument')
+
+ if 'suite' not in opts:
+ opts['suite'] = 'true'
+
+ testsuite = os.path.join(conf.TEST_SUITE_PATH,
+ conf.TEST_SUITE_PRE + testsuite + '.yaml')
+
+ task_id = str(uuid.uuid4())
+
+ command_list = ['task', 'start']
+ command_list = common_utils.get_command_list(command_list, opts, testsuite)
+ logger.debug('The command_list is: %s', command_list)
+
+ logger.debug('Start to execute command list')
+ common_utils.exec_command_task(command_list, task_id)
+
+ return common_utils.result_handler('success', task_id)
diff --git a/api/swagger/docs/testcases.yaml b/api/swagger/docs/release_action.yaml
index 7bfe5e647..7bfe5e647 100644
--- a/api/swagger/docs/testcases.yaml
+++ b/api/swagger/docs/release_action.yaml
diff --git a/api/swagger/docs/testsuites_action.yaml b/api/swagger/docs/testsuites_action.yaml
new file mode 100644
index 000000000..ebf01e4ec
--- /dev/null
+++ b/api/swagger/docs/testsuites_action.yaml
@@ -0,0 +1,50 @@
+TestSuites Actions
+
+This API may offer many actions, including runTestSuite
+
+action: runTestSuite
+This api offer the interface to run a test suite in yardstick
+we will return a task_id for querying
+you can use the returned task_id to get the result data
+---
+tags:
+ - Testsuite Action
+parameters:
+ - in: body
+ name: body
+ description: this is the input json dict
+ schema:
+ id: TestSuiteActionModel
+ required:
+ - action
+ - args
+ properties:
+ action:
+ type: string
+ description: this is action for testsuite
+ default: runTestSuite
+ args:
+ schema:
+ id: TestSuiteActionArgsModel
+ required:
+ - testsuite
+ properties:
+ testsuite:
+ type: string
+ description: this is the test suite name
+ default: smoke
+ opts:
+ schema:
+ id: TestSuiteActionArgsOptsModel
+responses:
+ 200:
+ description: A result json dict
+ schema:
+ id: result
+ properties:
+ status:
+ type: string
+ default: success
+ result:
+ type: string
+ description: task_id of this task
diff --git a/api/swagger/models.py b/api/swagger/models.py
index 7c65fbbf5..9a0157e0e 100644
--- a/api/swagger/models.py
+++ b/api/swagger/models.py
@@ -42,6 +42,37 @@ class TestCaseActionModel:
}
+# for testsuite/action runTestSuite action
+@swagger.model
+class TestSuiteActionArgsOptsTaskArgModel:
+ resource_fields = {
+ }
+
+
+@swagger.model
+class TestSuiteActionArgsOptsModel:
+ resource_fields = {
+ 'task-args': TestSuiteActionArgsOptsTaskArgModel,
+ 'keep-deploy': fields.String,
+ 'suite': fields.String
+ }
+
+@swagger.model
+class TestSuiteActionArgsModel:
+ resource_fields = {
+ 'testsuite': fields.String,
+ 'opts': TestSuiteActionArgsOptsModel
+ }
+
+
+@swagger.model
+class TestSuiteActionModel:
+ resource_fields = {
+ 'action': fields.String,
+ 'args': TestSuiteActionArgsModel
+ }
+
+
# for results
@swagger.model
class ResultModel:
diff --git a/api/urls.py b/api/urls.py
index 0fffd12db..7f9f0bb07 100644
--- a/api/urls.py
+++ b/api/urls.py
@@ -13,6 +13,7 @@ from api.utils.common import Url
urlpatterns = [
Url('/yardstick/testcases/release/action', views.ReleaseAction, 'release'),
Url('/yardstick/testcases/samples/action', views.SamplesAction, 'samples'),
+ Url('/yardstick/testsuites/action', views.TestsuitesAction, 'testsuites'),
Url('/yardstick/results', views.Results, 'results'),
Url('/yardstick/env/action', views.EnvAction, 'env')
]
diff --git a/api/views.py b/api/views.py
index ee13b47a9..bdff7c0d9 100644
--- a/api/views.py
+++ b/api/views.py
@@ -25,7 +25,7 @@ TestCaseActionArgsOptsTaskArgModel = models.TestCaseActionArgsOptsTaskArgModel
class ReleaseAction(ApiResource):
- @swag_from(os.getcwd() + '/swagger/docs/testcases.yaml')
+ @swag_from(os.getcwd() + '/swagger/docs/release_action.yaml')
def post(self):
return self._dispatch_post()
@@ -35,6 +35,18 @@ class SamplesAction(ApiResource):
return self._dispatch_post()
+TestSuiteActionModel = models.TestSuiteActionModel
+TestSuiteActionArgsModel = models.TestSuiteActionArgsModel
+TestSuiteActionArgsOptsModel = models.TestSuiteActionArgsOptsModel
+TestSuiteActionArgsOptsTaskArgModel = models.TestSuiteActionArgsOptsTaskArgModel
+
+
+class TestsuitesAction(ApiResource):
+ @swag_from(os.getcwd() + '/swagger/docs/testsuites_action.yaml')
+ def post(self):
+ return self._dispatch_post()
+
+
ResultModel = models.ResultModel