summaryrefslogtreecommitdiffstats
path: root/utils/test/result_collection_api/result_collection_api.py
diff options
context:
space:
mode:
authorGuy Rodrigue Koffi <koffirodrigue@gmail.com>2015-09-05 06:54:21 +0200
committerGuy Rodrigue Koffi <koffirodrigue@gmail.com>2015-09-07 17:34:53 +0200
commitf0c991c665f57b2344a6b8ed23ff62d44612fc19 (patch)
treee92c5f179ba782dd3de1816aff6a2c22fc863c1a /utils/test/result_collection_api/result_collection_api.py
parentcdc94124b5a759f0461e2400af096e08a26c88d1 (diff)
Add external config support to result_collection_api
JIRA : RELENG-7 Change-Id: I2b68aac3e903b237f500bad91e3625aaf57bfdaf Signed-off-by: Guy Rodrigue Koffi <koffirodrigue@gmail.com>
Diffstat (limited to 'utils/test/result_collection_api/result_collection_api.py')
-rw-r--r--utils/test/result_collection_api/result_collection_api.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/utils/test/result_collection_api/result_collection_api.py b/utils/test/result_collection_api/result_collection_api.py
index bb26bb25e..c04e0343b 100644
--- a/utils/test/result_collection_api/result_collection_api.py
+++ b/utils/test/result_collection_api/result_collection_api.py
@@ -15,29 +15,40 @@ 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
- - 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
+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
+db = motor.MotorClient(CONF.mongo_url)
def make_app():
@@ -76,14 +87,15 @@ def make_app():
(r"/results/([^/]*)", TestResultsHandler),
],
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()