diff options
Diffstat (limited to 'utils/dashboard')
-rw-r--r-- | utils/dashboard/__init__.py | 0 | ||||
-rw-r--r-- | utils/dashboard/dashboard.yaml | 15 | ||||
-rw-r--r-- | utils/dashboard/process_data.py | 79 | ||||
-rwxr-xr-x | utils/dashboard/uploader.py | 66 |
4 files changed, 0 insertions, 160 deletions
diff --git a/utils/dashboard/__init__.py b/utils/dashboard/__init__.py deleted file mode 100644 index e69de29b..00000000 --- a/utils/dashboard/__init__.py +++ /dev/null diff --git a/utils/dashboard/dashboard.yaml b/utils/dashboard/dashboard.yaml deleted file mode 100644 index 016c6d8d..00000000 --- a/utils/dashboard/dashboard.yaml +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################## -# Copyright (c) 2016 HUAWEI TECHNOLOGIES CO.,LTD and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -pod_name: REPLACE_NODE_NAME -installer: REPLACE_INSTALLER_TYPE -version: REPLACE_VERSION -target: http://REPLACE_BOTTLENECKS_DB_TARGET/results diff --git a/utils/dashboard/process_data.py b/utils/dashboard/process_data.py deleted file mode 100644 index 4be09178..00000000 --- a/utils/dashboard/process_data.py +++ /dev/null @@ -1,79 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd. and others -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - - -import sys -from rubbos_collector import RubbosCollector -from uploader import Uploader - - -def printUsage(): - print ("Usage: python process_data.py required_params(**)" - " optional_params([])") - print " ** -i|--input input_data_dir" - print " ** -s|--suite suite_name" - print " ** -c|--conf conf_file" - print " [] -o|--output output_file" - print " [] -u|--upload yes|no" - - -def process(input_dir, suite_name): - result = dict() - if suite_name == "rubbos": - result = RubbosCollector().collect_data(input_dir) - return result - - -def writeResult(output_file, result): - f = open(output_file, "w") - if isinstance(result, list): - for elem in result: - f.write(str(elem) + "\n") - f.close() - - -def uploadResult(conf, suite_name, result): - Uploader(conf).upload_result(suite_name, result) - - -def main(): - if len(sys.argv) < 7 or len(sys.argv) % 2 == 0: - printUsage() - exit(1) - i = 1 - params = dict() - while (i < len(sys.argv)): - if sys.argv[i] == "-i" or sys.argv[i] == "--input": - params["input"] = sys.argv[i + 1] - if sys.argv[i] == "-s" or sys.argv[i] == "--suite": - params["suite"] = sys.argv[i + 1] - if sys.argv[i] == "-c" or sys.argv[i] == "--conf": - params["conf"] = sys.argv[i + 1] - if sys.argv[i] == "-o" or sys.argv[i] == "--output": - params["output"] = sys.argv[i + 1] - if sys.argv[i] == "-u" or sys.argv[i] == "--upload": - params["upload"] = sys.argv[i + 1] - i = i + 2 - if not("input" in params and "suite" in params and "conf" in params): - print "Lack some required parameters." - exit(1) - - result = process(params["input"], params["suite"]) - print "Results:" - for elem in result: - print elem - - if "output" in params: - writeResult(params["output"], result) - - if "upload" in params and params["upload"].lower() == "yes": - uploadResult(params["conf"], params["suite"], result) - -if __name__ == "__main__": - main() diff --git a/utils/dashboard/uploader.py b/utils/dashboard/uploader.py deleted file mode 100755 index 97ffd38c..00000000 --- a/utils/dashboard/uploader.py +++ /dev/null @@ -1,66 +0,0 @@ -############################################################################## -# Copyright (c) 2015 Huawei Technologies Co.,Ltd. and others -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - -import sys -import json -import requests -import yaml - - -class Uploader(object): - - def __init__(self, conf): - self.headers = {'Content-type': 'application/json'} - self.timeout = 5 - self.result = { - "project_name": "bottlenecks", - "description": "bottlenecks test cases result"} - - with open(conf) as stream: - dashboard_conf = yaml.load(stream) - self.result['pod_name'] = dashboard_conf['pod_name'] - self.result['installer'] = dashboard_conf['installer'] - self.result['version'] = dashboard_conf['version'] - self.target = dashboard_conf['target'] - - def upload_result(self, case_name, raw_data): - if self.target == '': - print('No target was set, so no data will be posted.') - return - self.result["case_name"] = case_name - self.result["details"] = raw_data - - try: - print('Result to be uploaded:\n %s' % json.dumps(self.result)) - res = requests.post(self.target, - data=json.dumps(self.result), - headers=self.headers, - timeout=self.timeout) - print( - 'Test result posting finished with status code %d.' % - res.status_code) - except Exception as err: - print ('Failed to record result data: %s', err) - - -def _test(): - - # data = '{"details": [{"client": 200, "throughput": 20}, - # {"client": 300, "throughput": 20}], "case_name": "rubbos"}' - if len(sys.argv) < 2: - print ("no argumens input!!") - exit(1) - - with open(sys.argv[1], 'r') as stream: - data = json.load(stream) - Uploader().upload_result(data) - - -if __name__ == "__main__": - _test() |