Add automated reporting for Tempest
[releng.git] / utils / test / result_collection_api / result_collection_api.py
index c04e034..69c03b8 100644 (file)
@@ -15,14 +15,12 @@ Pre-requisites:
 We can launch the API with this file
 
 TODOs :
-  - use POD name instead of id
   - logging
   - json args validation with schemes
   - POST/PUT/DELETE for PODs
   - POST/PUT/GET/DELETE for installers, platforms (enrich results info)
   - count cases for GET on test_projects
   - count results for GET on cases
-  - provide filtering on requests
   - include objects
   - swagger documentation
   - setup file
@@ -36,7 +34,7 @@ import motor
 import argparse
 
 from resources.handlers import VersionHandler, PodHandler, \
-    TestProjectHandler, TestCasesHandler, TestResultsHandler
+    TestProjectHandler, TestCasesHandler, TestResultsHandler, DashboardHandler
 from common.config import APIConfig
 
 
@@ -48,7 +46,8 @@ args = parser.parse_args()
 CONF = APIConfig().parse(args.config_file)
 
 # connecting to MongoDB server, and choosing database
-db = motor.MotorClient(CONF.mongo_url)
+client = motor.MotorClient(CONF.mongo_url)
+db = client[CONF.mongo_dbname]
 
 
 def make_app():
@@ -61,7 +60,7 @@ def make_app():
             # GET /pods => Get all pods
             # GET /pods/1 => Get details on POD 1
             (r"/pods", PodHandler),
-            (r"/pods/(\d*)", PodHandler),
+            (r"/pods/([^/]+)", PodHandler),
 
             # few examples:
             # GET /test_projects
@@ -81,10 +80,19 @@ def make_app():
             #   => get results with optional filters
             # POST /results =>
             # Push results with mandatory request payload parameters
-            # (project, case, and pod_id)
+            # (project, case, and pod)
             (r"/results", TestResultsHandler),
             (r"/results([^/]*)", TestResultsHandler),
             (r"/results/([^/]*)", TestResultsHandler),
+
+            # Method to manage Dashboard ready results
+            # GET /dashboard?project=functest&case=vPing&pod=opnfv-jump2
+            #  => get results in dasboard ready format
+            # get /dashboard
+            #  => get the list of project with dashboard ready results
+            (r"/dashboard", DashboardHandler),
+            (r"/dashboard([^/]*)", DashboardHandler),
+            (r"/dashboard/([^/]*)", DashboardHandler),
         ],
         db=db,
         debug=CONF.api_debug_on,