diff options
author | Mark Wong | 2018-08-12 00:31:40 +0000 |
---|---|---|
committer | Mark Wong | 2018-08-12 00:31:40 +0000 |
commit | 8ebbbf47ca5483d6b7ed5679aac3a792c52252c7 (patch) | |
tree | 1d267a1596cb4b7fb46b639a99a1b0185d3b8952 /client/benchmarks/runner.py | |
parent | 85e3150fd9cd9c25ce11f27028e1a760e812f875 (diff) |
Upload test results to from client to web server
Diffstat (limited to 'client/benchmarks/runner.py')
-rw-r--r-- | client/benchmarks/runner.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/client/benchmarks/runner.py b/client/benchmarks/runner.py index a0532e2..05bbe57 100644 --- a/client/benchmarks/runner.py +++ b/client/benchmarks/runner.py @@ -1,5 +1,7 @@ import json import os +import codecs +import urllib2 from multiprocessing import Process, Queue from time import gmtime, strftime @@ -11,7 +13,7 @@ from utils.logging import log class BenchmarkRunner(object): 'manages runs of all the benchmarks, including cluster restarts etc.' - def __init__(self, out_dir, cluster, collector): + def __init__(self, out_dir, url, secret, cluster, collector): '' self._output = out_dir # where to store output files @@ -19,6 +21,8 @@ class BenchmarkRunner(object): self._configs = {} # config name => (bench name, config) self._cluster = cluster self._collector = collector + self._url = url + self._secret = secret def register_benchmark(self, benchmark_name, benchmark_class): '' @@ -125,6 +129,21 @@ class BenchmarkRunner(object): with open('%s/results.json' % self._output, 'w') as f: f.write(json.dumps(r, indent=4)) + try: + self._upload_results(r) + except Exception as e: + print e + + def _upload_results(self, results): + postdata = results + post = [] + post.append(postdata) + req = urllib2.Request(self._url, json.dumps(post)) + req.add_header('Authorization', self._secret) # add token in header + req.add_header('Content-Type', 'application/json') + response = urllib2.urlopen(req) + + def run(self): 'run all the configured benchmarks' |