Launch Functest RestApi once the container is run 43/40343/1
authorLinda Wang <wangwulin@huawei.com>
Mon, 28 Aug 2017 06:11:23 +0000 (06:11 +0000)
committerLinda Wang <wangwulin@huawei.com>
Mon, 28 Aug 2017 06:21:35 +0000 (06:21 +0000)
And fix the handling about env prepare exception.

Change-Id: I3e590e63157182c442602367a244d7ff647f8b7d
Signed-off-by: Linda Wang <wangwulin@huawei.com>
docker/Dockerfile
functest/api/resources/v1/envs.py

index 5fa4340..45dc21e 100644 (file)
@@ -108,3 +108,5 @@ RUN sh -c 'curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -' \
     && cd /src/promise/source && npm install
 
 RUN echo ". ${FUNCTEST_DIR}/cli/functest-complete.sh" >> /root/.bashrc
+
+CMD ["functest_restapi"]
index fb76fa6..8020544 100644 (file)
@@ -33,10 +33,11 @@ class V1Envs(ApiResource):
 
     def prepare(self, args):  # pylint: disable=no-self-use, unused-argument
         """ Prepare environment """
-        try:
-            ft_utils.execute_command("prepare_env start")
-        except Exception as err:  # pylint: disable=broad-except
-            return api_utils.result_handler(status=1, data=str(err))
+
+        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")