aboutsummaryrefslogtreecommitdiffstats
path: root/functest/api
diff options
context:
space:
mode:
Diffstat (limited to 'functest/api')
-rw-r--r--functest/api/resources/v1/envs.py11
-rw-r--r--functest/api/resources/v1/testcases.py51
-rw-r--r--functest/api/swagger/envs_action.yaml18
-rw-r--r--functest/api/urls.py1
4 files changed, 36 insertions, 45 deletions
diff --git a/functest/api/resources/v1/envs.py b/functest/api/resources/v1/envs.py
index 65e61c4ba..3e6f05ac9 100644
--- a/functest/api/resources/v1/envs.py
+++ b/functest/api/resources/v1/envs.py
@@ -20,7 +20,6 @@ from flasgger.utils import swag_from
from functest.api.base import ApiResource
from functest.api.common import api_utils
from functest.cli.commands.cli_env import Env
-import functest.utils.functest_utils as ft_utils
ADDRESS = socket.gethostbyname(socket.gethostname())
ENDPOINT_ENVS = ('http://{}:5000/api/v1/functest/envs'.format(ADDRESS))
@@ -45,16 +44,6 @@ class V1Envs(ApiResource):
""" Used to handle post request """
return self._dispatch_post()
- def prepare(self, args): # pylint: disable=no-self-use, unused-argument
- """ Prepare environment """
-
- result_env = ft_utils.execute_command("prepare_env start")
- if not result_env == 0:
- return api_utils.result_handler(
- status=1, data="Failed to prepare env")
- return api_utils.result_handler(
- status=0, data="Prepare env successfully")
-
def update_hosts(self, hosts_info): # pylint: disable=no-self-use
""" Update hosts info """
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py
index 7cc70bbc9..01571548d 100644
--- a/functest/api/resources/v1/testcases.py
+++ b/functest/api/resources/v1/testcases.py
@@ -115,34 +115,31 @@ class V1Testcase(ApiResource):
case_name = args.get('testcase')
self._update_logging_ini(args.get('task_id'))
- if not os.path.isfile(CONST.__getattribute__('env_active')):
- raise Exception("Functest environment is not ready.")
+ try:
+ cmd = "run_tests -t {}".format(case_name)
+ runner = ft_utils.execute_command(cmd)
+ except Exception: # pylint: disable=broad-except
+ result = 'FAIL'
+ LOGGER.exception("Running test case %s failed!", case_name)
+ if runner == os.EX_OK:
+ result = 'PASS'
else:
- try:
- cmd = "run_tests -t {}".format(case_name)
- runner = ft_utils.execute_command(cmd)
- except Exception: # pylint: disable=broad-except
- result = 'FAIL'
- LOGGER.exception("Running test case %s failed!", case_name)
- if runner == os.EX_OK:
- result = 'PASS'
- else:
- result = 'FAIL'
-
- env_info = {
- 'installer': CONST.__getattribute__('INSTALLER_TYPE'),
- 'scenario': CONST.__getattribute__('DEPLOY_SCENARIO'),
- 'build_tag': CONST.__getattribute__('BUILD_TAG'),
- 'ci_loop': CONST.__getattribute__('CI_LOOP')
- }
- result = {
- 'task_id': args.get('task_id'),
- 'testcase': case_name,
- 'env_info': env_info,
- 'result': result
- }
-
- return {'result': result}
+ result = 'FAIL'
+
+ env_info = {
+ 'installer': CONST.__getattribute__('INSTALLER_TYPE'),
+ 'scenario': CONST.__getattribute__('DEPLOY_SCENARIO'),
+ 'build_tag': CONST.__getattribute__('BUILD_TAG'),
+ 'ci_loop': CONST.__getattribute__('CI_LOOP')
+ }
+ result = {
+ 'task_id': args.get('task_id'),
+ 'testcase': case_name,
+ 'env_info': env_info,
+ 'result': result
+ }
+
+ return {'result': result}
def _update_logging_ini(self, task_id): # pylint: disable=no-self-use
""" Update the log file for each task"""
diff --git a/functest/api/swagger/envs_action.yaml b/functest/api/swagger/envs_action.yaml
index 1add066ee..46faa6dea 100644
--- a/functest/api/swagger/envs_action.yaml
+++ b/functest/api/swagger/envs_action.yaml
@@ -1,8 +1,7 @@
-Prepare environment or Update hosts info
+Update hosts info
-This api offers the interface to prepare environment or update hosts info.
+This api offers the interface to update hosts info.
-action: prepare
action: update_hosts
---
tags:
@@ -14,11 +13,18 @@ parameters:
schema:
required:
- action
+ - args
properties:
action:
type: string
description: this is action for envs
- default: prepare
+ default: update_hosts
+ args:
+ type: string
+ description: Hosts info to be updated
+ default:
+ "identity.ac.dz.com": "8.20.11.22"
+ "image.ac.dz.com": "8.20.11.22"
definitions:
Environment:
type: object
@@ -29,9 +35,9 @@ definitions:
type: dict
responses:
200:
- description: Prepare environment
+ description: Update hosts info
schema:
$ref: '#/definitions/Environment'
examples:
'status': 0
- 'result': 'Prapare env successfully'
+ 'result': 'Update hosts info successfully' \ No newline at end of file
diff --git a/functest/api/urls.py b/functest/api/urls.py
index 0cc22f80f..10b7b2936 100644
--- a/functest/api/urls.py
+++ b/functest/api/urls.py
@@ -26,7 +26,6 @@ URLPATTERNS = [
Url('/api/v1/functest/envs', 'v1_envs'),
# POST /api/v1/functest/envs/action
- # {"action":"prepare"} => Prepare environment
# {"action":"update_hosts", "args": {}} => Update hosts info
Url('/api/v1/functest/envs/action', 'v1_envs'),