summaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rwxr-xr-xutils/infra_setup/heat_template/vstf_heat_template/dashboard.json6
-rwxr-xr-xutils/infra_setup/heat_template/vstf_heat_template/vstf_collector.py63
-rw-r--r--utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh5
3 files changed, 74 insertions, 0 deletions
diff --git a/utils/infra_setup/heat_template/vstf_heat_template/dashboard.json b/utils/infra_setup/heat_template/vstf_heat_template/dashboard.json
new file mode 100755
index 00000000..df6f64c3
--- /dev/null
+++ b/utils/infra_setup/heat_template/vstf_heat_template/dashboard.json
@@ -0,0 +1,6 @@
+{
+ "pod_name": "unknown-pod",
+ "installer": "fuel",
+ "version": "unknown",
+ "target": "http://213.77.62.197/results"
+} \ No newline at end of file
diff --git a/utils/infra_setup/heat_template/vstf_heat_template/vstf_collector.py b/utils/infra_setup/heat_template/vstf_heat_template/vstf_collector.py
new file mode 100755
index 00000000..b1d45434
--- /dev/null
+++ b/utils/infra_setup/heat_template/vstf_heat_template/vstf_collector.py
@@ -0,0 +1,63 @@
+##############################################################################
+# 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 os
+import argparse
+import json
+import requests
+import logging
+__author__ = "qwyang0126@gmail.com"
+__date__ = "2016-01-11"
+LOG = logging.getLogger(__name__)
+
+
+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 = json.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 == '':
+ LOG.error('No target was set, so no data will be posted.')
+ return
+ self.result["case_name"] = case_name
+ self.result["details"] = raw_data
+ try:
+ LOG.debug('Result to be uploaded:\n %s' % json.dumps(self.result, indent=4))
+ 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:
+ LOG.error('Failed to record result data: %s', err)
+
+
+if __name__ == "__main__":
+ logging.basicConfig(level=logging.DEBUG)
+ parser = argparse.ArgumentParser()
+ parser.add_argument('--config', required=True, help="basic config file for uploader, json format.")
+ parser.add_argument('--dir', required=True, help="result files for test cases")
+ args = parser.parse_args()
+ realpath = os.path.realpath(args.dir)
+ for filename in os.listdir(args.dir):
+ filepath = os.path.join(realpath, filename)
+ LOG.debug("uploading test result from file:%s", filepath)
+ with open(filepath) as stream:
+ result = eval(stream.read())
+ Uploader(args.config).upload_result(filename.lower().replace('-', ''), result)
diff --git a/utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh b/utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh
index 051f2858..d162e4cf 100644
--- a/utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh
+++ b/utils/infra_setup/heat_template/vstf_heat_template/vstf_test.sh
@@ -75,11 +75,16 @@ function fn_result(){
return 0
}
+function fn_upload(){
+ python vstf_collector.py --config dashboard.json --dir result
+}
+
function main(){
fn_parser_ipaddress
fn_vstf_test_config
fn_testing_scenario
fn_result
+ fn_upload
return 0
}