X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=utils%2Ftest%2Fresult_collection_api%2Fresult_collection_api.py;h=69c03b8998b83ab57a446ac234e5e5b6778b822c;hb=5691606d1ed8caa57e3001767aab7fe19612d272;hp=bb26bb25e2a9aba63ad18ef2b1a965dcb06f3d80;hpb=46fd62a707f5fc241c6701a9f787fd78c8680182;p=releng.git diff --git a/utils/test/result_collection_api/result_collection_api.py b/utils/test/result_collection_api/result_collection_api.py index bb26bb25e..69c03b899 100644 --- a/utils/test/result_collection_api/result_collection_api.py +++ b/utils/test/result_collection_api/result_collection_api.py @@ -15,29 +15,39 @@ Pre-requisites: We can launch the API with this file TODOs : + - 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 - - logging - - external configuration file + - swagger documentation - setup file - results pagination - - POST/PUT/DELETE for PODs - - POST/PUT/GET/DELETE for installers, platforms (enrich results info) + - unit tests """ import tornado.ioloop import motor +import argparse from resources.handlers import VersionHandler, PodHandler, \ - TestProjectHandler, TestCasesHandler, TestResultsHandler -from common.constants import API_LISTENING_PORT, MONGO_URL + TestProjectHandler, TestCasesHandler, TestResultsHandler, DashboardHandler +from common.config import APIConfig + + +# optionally get config file from command line +parser = argparse.ArgumentParser() +parser.add_argument("-c", "--config-file", dest='config_file', + help="Config file location") +args = parser.parse_args() +CONF = APIConfig().parse(args.config_file) # connecting to MongoDB server, and choosing database -db = motor.MotorClient(MONGO_URL).test_results_collection +client = motor.MotorClient(CONF.mongo_url) +db = client[CONF.mongo_dbname] def make_app(): @@ -50,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 @@ -70,20 +80,30 @@ 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=True, + debug=CONF.api_debug_on, ) def main(): application = make_app() - application.listen(API_LISTENING_PORT) + application.listen(CONF.api_port) tornado.ioloop.IOLoop.current().start() + if __name__ == "__main__": main()