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 | |
parent | 85e3150fd9cd9c25ce11f27028e1a760e812f875 (diff) |
Upload test results to from client to web server
-rw-r--r-- | client/benchmarks/runner.py | 21 | ||||
-rw-r--r-- | client/perffarm-client.py | 3 | ||||
-rw-r--r-- | client/settings.py | 3 |
3 files changed, 25 insertions, 2 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' diff --git a/client/perffarm-client.py b/client/perffarm-client.py index 48a1916..e258bb4 100644 --- a/client/perffarm-client.py +++ b/client/perffarm-client.py @@ -54,7 +54,8 @@ if __name__ == '__main__': bin_path=('%s/bin' % (BUILD_PATH))) collectors.register('postgres', pg_collector) - runner = BenchmarkRunner(OUTPUT_DIR, cluster, collectors) + runner = BenchmarkRunner(OUTPUT_DIR, PERFFARM_URL, SECRET, + cluster, collectors) # register the three tests we currently have diff --git a/client/settings.py b/client/settings.py index 1afdfc2..16279db 100644 --- a/client/settings.py +++ b/client/settings.py @@ -2,6 +2,9 @@ import os import sys # global configuration +PERFFARM_URL = 'http://140.211.168.111:8000/upload/' +SECRET='CHANGEME' + GIT_URL = 'https://github.com/postgres/postgres.git' REPOSITORY_PATH = '/tmp/git-postgres' BUILD_PATH = '/tmp/bin-postgres' |