aboutsummaryrefslogtreecommitdiffstats
path: root/restful_server
diff options
context:
space:
mode:
authorzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-24 14:01:46 +0800
committerzhifeng.jiang <jiang.zhifeng@zte.com.cn>2016-09-28 23:59:53 +0800
commit0d3fb3fb9aee914b425f3f8ed9c843d6052f7ada (patch)
tree54e488461673327a657cdea54c4a674f2c383db5 /restful_server
parentc4292f93f53f88a48cc3693b464dcdff6a9a0850 (diff)
Start restful server auto in docker
modification: Add start restful server in dockerfile Add result and detail_result in server job status Add job result assert in unit test JIRA:QTIP-99 Change-Id: I27108eb930eba1bb72c04216f468a81202179ee0 Signed-off-by: zhifeng.jiang <jiang.zhifeng@zte.com.cn>
Diffstat (limited to 'restful_server')
-rw-r--r--restful_server/db.py11
-rw-r--r--restful_server/qtip_server.py10
2 files changed, 15 insertions, 6 deletions
diff --git a/restful_server/db.py b/restful_server/db.py
index 916fc031..cf6ebfbb 100644
--- a/restful_server/db.py
+++ b/restful_server/db.py
@@ -7,6 +7,7 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
from datetime import datetime
+from operator import add
import uuid
jobs = {}
@@ -28,7 +29,8 @@ def create_job(args):
'end_time': None,
'state': 'processing',
'state_detail': [],
- 'result': []}
+ 'result': None,
+ 'result_detail': []}
jobs[job['job_id']] = job
return job['job_id']
@@ -54,6 +56,8 @@ def get_job_info(job_id):
def finish_job(job_id):
jobs[job_id]['end_time'] = str(datetime.now())
jobs[job_id]['state'] = 'finished'
+ jobs[job_id]['result'] = reduce(add, map(lambda x: x['result'],
+ jobs[job_id]['result_detail']))
del threads[job_id]
@@ -61,8 +65,9 @@ def update_job_state_detail(job_id, state_detail):
jobs[job_id]['state_detail'] = state_detail
-def update_job_result(job_id, result):
- jobs[job_id]['result'] = result
+def update_job_result_detail(job_id, benchmark, result):
+ result['benchmark'] = benchmark
+ jobs[job_id]['result_detail'].append(result)
def is_job_timeout(job_id):
diff --git a/restful_server/qtip_server.py b/restful_server/qtip_server.py
index b03c8f16..734a471c 100644
--- a/restful_server/qtip_server.py
+++ b/restful_server/qtip_server.py
@@ -163,8 +163,12 @@ default is 'compute'
if db.is_job_timeout(job_id) or stop_event.is_set():
break
db.update_benmark_state_in_state_detail(job_id, benchmark, 'processing')
- args_handler.prepare_and_run_benchmark(installer_type, '/home',
- args_handler.get_benchmark_path(pod_name, suite_name, benchmark))
+ result = args_handler.prepare_and_run_benchmark(installer_type,
+ '/home',
+ args_handler.get_benchmark_path(pod_name,
+ suite_name,
+ benchmark))
+ db.update_job_result_detail(job_id, benchmark, copy(result))
db.update_benmark_state_in_state_detail(job_id, benchmark, 'finished')
db.finish_job(job_id)
@@ -173,4 +177,4 @@ api.add_resource(JobList, '/api/v1.0/jobs')
api.add_resource(Job, '/api/v1.0/jobs/<string:id>')
if __name__ == "__main__":
- app.run()
+ app.run(host='0.0.0.0')