1 ##############################################################################
2 # Copyright (c) 2015 Orange
3 # guyrodrigue.koffi@orange.com / koffirodrigue@gmail.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
15 We can launch the API with this file
18 - json args validation with schemes
19 - count cases for GET on test_projects
20 - count results for GET on cases
21 - provide filtering on requests
24 - external configuration file
27 - POST/PUT/DELETE for PODs
28 - POST/PUT/GET/DELETE for installers, platforms (enrich results info)
35 from resources.handlers import VersionHandler, PodHandler, \
36 TestProjectHandler, TestCasesHandler, TestResultsHandler
37 from common.constants import API_LISTENING_PORT, MONGO_URL
39 # connecting to MongoDB server, and choosing database
40 db = motor.MotorClient(MONGO_URL).test_results_collection
44 return tornado.web.Application(
46 # GET /version => GET API version
47 (r"/version", VersionHandler),
50 # GET /pods => Get all pods
51 # GET /pods/1 => Get details on POD 1
52 (r"/pods", PodHandler),
53 (r"/pods/(\d*)", PodHandler),
57 # GET /test_projects/yardstick
58 (r"/test_projects", TestProjectHandler),
59 (r"/test_projects/([^/]+)", TestProjectHandler),
62 # GET /test_projects/qtip/cases => Get cases for qtip
64 (r"/test_projects/([^/]+)/cases", TestCasesHandler),
65 (r"/test_projects/([^/]+)/cases/([^/]+)", TestCasesHandler),
66 # (r"/test_cases/([^/]+)", TestCasesHandler),
68 # new path to avoid a long depth
69 # GET /results?project=functest&case=keystone.catalog&pod=1
70 # => get results with optional filters
72 # Push results with mandatory request payload parameters
73 # (project, case, and pod_id)
74 (r"/results", TestResultsHandler),
75 (r"/results([^/]*)", TestResultsHandler),
76 (r"/results/([^/]*)", TestResultsHandler),
84 application = make_app()
85 application.listen(API_LISTENING_PORT)
86 tornado.ioloop.IOLoop.current().start()
88 if __name__ == "__main__":