summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dashboard/__init__.py0
-rw-r--r--dashboard/pushtoDB.py27
-rw-r--r--data/__init__.py0
-rw-r--r--data/ref_results/__init__.py0
-rw-r--r--data/ref_results/compute_benchmarks_indices.py10
-rw-r--r--data/ref_results/compute_suite.py50
-rw-r--r--data/ref_results/index_calculation.py2
-rw-r--r--data/ref_results/network_benchmarks_indices.py2
-rw-r--r--data/ref_results/network_suite.py30
-rw-r--r--data/ref_results/storage_benchmarks_indices.py2
-rw-r--r--data/ref_results/storage_suite.py27
-rw-r--r--data/ref_results/suite_result.py55
-rw-r--r--docker/Dockerfile5
-rwxr-xr-xdocker/run_qtip.sh14
-rw-r--r--qtip.py41
-rw-r--r--restful_server/result_handler.py22
-rw-r--r--utils/logger_utils.py2
17 files changed, 130 insertions, 159 deletions
diff --git a/dashboard/__init__.py b/dashboard/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/dashboard/__init__.py
diff --git a/dashboard/pushtoDB.py b/dashboard/pushtoDB.py
index d5458b1d..e6a4d239 100644
--- a/dashboard/pushtoDB.py
+++ b/dashboard/pushtoDB.py
@@ -3,6 +3,10 @@ import json
import datetime
import os
import sys
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('push_db').get
+
TEST_DB = 'http://testresults.opnfv.org/test/api/v1'
suite_list = [('compute_result.json', 'compute_test_suite'),
@@ -11,28 +15,25 @@ suite_list = [('compute_result.json', 'compute_test_suite'),
payload_list = {}
-def push_results_to_db(db_url, case_name, payload, logger=None, pod_name="dell-pod1"):
+def push_results_to_db(db_url, case_name, payload, installer, pod_name):
url = db_url + "/results"
creation_date = str(datetime.datetime.utcnow().isoformat())
- installer = os.environ['INSTALLER_TYPE']
- pod_name = os.environ['NODE_NAME']
params = {"project_name": "qtip", "case_name": case_name,
"pod_name": pod_name, "installer": installer, "start_date": creation_date,
"version": "test", "details": payload}
headers = {'Content-Type': 'application/json'}
- print pod_name
- print installer
- print creation_date
-
+ logger.info('pod_name:{0},installer:{1},creation_data:{2}'.format(pod_name,
+ installer,
+ creation_date))
try:
r = requests.post(url, data=json.dumps(params), headers=headers)
- print r
+ logger.info(r)
return True
except:
- print "Error:", sys.exc_info()[0]
+ logger.info("Error:{0}".format(sys.exc_info()[0]))
return False
@@ -50,13 +51,15 @@ def main():
global payload_list
populate_payload(suite_list)
if payload_list:
- print payload_list
+ logger.info(payload_list)
for suite, case in payload_list.items():
with open('results/' + suite, 'r') as result_file:
j = json.load(result_file)
- push_results_to_db(TEST_DB, case, j)
+ push_results_to_db(TEST_DB, case, j,
+ os.environ['INSTALLER_TYPE'],
+ os.environ['NODE_NAME'])
elif not payload_list:
- print 'Results not found'
+ logger.info('Results not found')
if __name__ == "__main__":
diff --git a/data/__init__.py b/data/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/data/__init__.py
diff --git a/data/ref_results/__init__.py b/data/ref_results/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/data/ref_results/__init__.py
diff --git a/data/ref_results/compute_benchmarks_indices.py b/data/ref_results/compute_benchmarks_indices.py
index 400d54ac..9012cefc 100644
--- a/data/ref_results/compute_benchmarks_indices.py
+++ b/data/ref_results/compute_benchmarks_indices.py
@@ -4,7 +4,7 @@ from result_accum import result_concat as concat
def dpi_index():
- dpi_dict = concat('../../results/dpi/')
+ dpi_dict = concat('results/dpi/')
dpi_bm_ref = get_reference('compute', 'dpi_bm')
dpi_bm_index = get_index(dpi_dict, 'dpi_bm', dpi_bm_ref, 'details', 'bps')
@@ -20,7 +20,7 @@ def dpi_index():
def dhrystone_index():
- dhrystone_dict = concat('../../results/dhrystone/')
+ dhrystone_dict = concat('results/dhrystone/')
dhrystone_single_bm_ref = get_reference('compute', 'dhrystone_bm', 'single_cpu')
dhrystone_single_bm_index = get_index(dhrystone_dict, 'dhrystone_bm', dhrystone_single_bm_ref, 'details', 'single', 'score')
@@ -46,7 +46,7 @@ def dhrystone_index():
def whetstone_index():
- whetstone_dict = concat('../../results/whetstone/')
+ whetstone_dict = concat('results/whetstone/')
whetstone_single_bm_ref = get_reference('compute', 'whetstone_bm', 'single_cpu')
whetstone_single_bm_index = get_index(whetstone_dict, 'whetstone_bm', whetstone_single_bm_ref, 'details', 'single', 'score')
@@ -72,7 +72,7 @@ def whetstone_index():
def ramspeed_index():
- ramspeed_dict = concat('../../results/ramspeed/')
+ ramspeed_dict = concat('results/ramspeed/')
ramspeed_int_bm_ref = get_reference('compute', 'ramspeed_bm', 'INTmem', 'Average (MB/s)')
ramspeed_int_bm_index = get_index(ramspeed_dict, 'ramspeed_bm', ramspeed_int_bm_ref, 'details', 'int_bandwidth', 'average')
@@ -99,7 +99,7 @@ def ramspeed_index():
def ssl_index():
- ssl_dict = concat('../../results/ssl/')
+ ssl_dict = concat('results/ssl/')
ssl_RSA512b_bm_ref = get_reference('compute', 'ssl_bm', 'RSA', '512b')
ssl_RSA1024b_bm_ref = get_reference('compute', 'ssl_bm', 'RSA', '1024b')
diff --git a/data/ref_results/compute_suite.py b/data/ref_results/compute_suite.py
deleted file mode 100644
index 7154183c..00000000
--- a/data/ref_results/compute_suite.py
+++ /dev/null
@@ -1,50 +0,0 @@
-import json
-import compute_benchmarks_indices as benchmark_indices
-
-
-compute_dict = {}
-try:
- compute_dict['DPI'] = benchmark_indices.dpi_index()
-except OSError:
- pass
-
-try:
- compute_dict['Dhrystone'] = benchmark_indices.dhrystone_index()
-except OSError:
- pass
-
-try:
- compute_dict['Whetstone'] = benchmark_indices.whetstone_index()
-except OSError:
- pass
-
-try:
- compute_dict['SSL'] = benchmark_indices.ssl_index()
-except OSError:
- pass
-
-try:
- compute_dict['RamSpeed'] = benchmark_indices.ramspeed_index()
-except OSError:
- pass
-
-compute_bench_list = ['DPI', 'Dhrystone', 'Whetstone', 'SSL', 'RamSpeed']
-l = len(compute_bench_list)
-
-temp = 0
-for benchmark in compute_bench_list:
- try:
- temp = temp + float(compute_dict[benchmark]['index'])
- except KeyError:
- l = l - 1
- pass
-
-if l == 0:
- print "No compute suite results found"
-else:
- compute_suite_index = temp / l
- compute_dict_f = {}
- compute_dict_f['index'] = compute_suite_index
- compute_dict_f['suite_results'] = compute_dict
- with open('../../results/compute_result.json', 'w+') as result_json:
- json.dump(compute_dict_f, result_json, indent=4, sort_keys=True)
diff --git a/data/ref_results/index_calculation.py b/data/ref_results/index_calculation.py
index 7dee7497..5ca4a46e 100644
--- a/data/ref_results/index_calculation.py
+++ b/data/ref_results/index_calculation.py
@@ -13,7 +13,7 @@ def compute_index(total_measured, ref_result, count):
def get_reference(*args):
- with open('./reference.json') as reference_file:
+ with open('data/ref_results/reference.json') as reference_file:
reference_djson = json.load(reference_file)
for arg in args:
ref_n = reference_djson.get(str(arg))
diff --git a/data/ref_results/network_benchmarks_indices.py b/data/ref_results/network_benchmarks_indices.py
index f4c581db..c19d18eb 100644
--- a/data/ref_results/network_benchmarks_indices.py
+++ b/data/ref_results/network_benchmarks_indices.py
@@ -4,7 +4,7 @@ from result_accum import result_concat as concat
def iperf_index():
- iperf_dict = concat('../../results/iperf/')
+ iperf_dict = concat('results/iperf/')
iperf_bm_ref = get_reference('network', 'iperf_bm', 'throughput received(b/s)')
iperf_bm_index = get_index(iperf_dict, 'iperf_bm', iperf_bm_ref, 'details', 'bandwidth', 'received_throughput')
iperf_vm_ref = get_reference('network', 'iperf_vm', 'throughput received(b/s)')
diff --git a/data/ref_results/network_suite.py b/data/ref_results/network_suite.py
deleted file mode 100644
index ae4ed107..00000000
--- a/data/ref_results/network_suite.py
+++ /dev/null
@@ -1,30 +0,0 @@
-import json
-import network_benchmarks_indices as benchmark_indices
-
-
-network_dict = {}
-try:
- network_dict['IPERF'] = benchmark_indices.iperf_index()
-except:
- pass
-
-network_bench_list = ['IPERF']
-temp = 0
-l = len(network_bench_list)
-
-for benchmark in network_bench_list:
- try:
- temp = temp + float(network_dict[benchmark]['index'])
- except:
- l = l - 1
- pass
-
-if l == 0:
- print "No network results found"
-else:
- network_suite_index = temp / len(network_bench_list)
- network_dict_f = {}
- network_dict_f['index'] = network_suite_index
- network_dict_f['suite_results'] = network_dict
- with open('../../results/network_result.json', 'w+') as result_json:
- json.dump(network_dict_f, result_json, indent=4, sort_keys=True)
diff --git a/data/ref_results/storage_benchmarks_indices.py b/data/ref_results/storage_benchmarks_indices.py
index 6c5dd435..a5aef638 100644
--- a/data/ref_results/storage_benchmarks_indices.py
+++ b/data/ref_results/storage_benchmarks_indices.py
@@ -4,7 +4,7 @@ from result_accum import result_concat as concat
def fio_index():
- fio_dict = concat('../../results/fio/')
+ fio_dict = concat('results/fio/')
fio_r_bm_ref = get_reference('storage', 'fio_bm', 'read', 'IOPS')
fio_r_bm_index = get_index(fio_dict, 'fio_bm', fio_r_bm_ref, 'details', 'job_0', 'read', 'io_ps')
fio_w_bm_ref = get_reference('storage', 'fio_bm', 'write', 'IOPS')
diff --git a/data/ref_results/storage_suite.py b/data/ref_results/storage_suite.py
deleted file mode 100644
index 38d97622..00000000
--- a/data/ref_results/storage_suite.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import json
-import storage_benchmarks_indices as benchmark_indices
-
-
-storage_dict = {}
-try:
- storage_dict['FIO'] = benchmark_indices.fio_index()
-except OSError:
- pass
-
-storage_bench_list = ['FIO']
-l = len(storage_bench_list)
-temp = 0
-for benchmark in storage_bench_list:
- try:
- temp = temp + float(storage_dict[benchmark]['index'])
- except KeyError:
- l -= 1
-if l == 0:
- print "No Storage results found"
-else:
- storage_suite_index = temp / l
- storage_dict_f = {}
- storage_dict_f['index'] = storage_suite_index
- storage_dict_f['storage_suite'] = storage_dict
- with open('../../results/storage_result.json', 'w+') as result_json:
- json.dump(storage_dict_f, result_json, indent=4, sort_keys=True)
diff --git a/data/ref_results/suite_result.py b/data/ref_results/suite_result.py
new file mode 100644
index 00000000..d0b4647f
--- /dev/null
+++ b/data/ref_results/suite_result.py
@@ -0,0 +1,55 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corp 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 json
+import importlib
+import sys
+from utils import logger_utils
+
+logger = logger_utils.QtipLogger('suite_result').get
+
+
+def get_benchmark_result(benchmark_name, suite_name):
+ benchmark_indices = importlib.import_module('{0}_benchmarks_indices'.format(suite_name))
+ methodToCall = getattr(benchmark_indices, '{0}_index'.format(benchmark_name))
+ return methodToCall()
+
+
+def get_suite_result(suite_name):
+ suite_dict = {}
+ suite_bench_list = {'compute': ['DPI', 'Dhrystone', 'Whetstone', 'SSL', 'RamSpeed'],
+ 'storage': ['FIO'],
+ 'network': ['IPERF']}
+ temp = 0
+ l = len(suite_bench_list[suite_name])
+ for benchmark in suite_bench_list[suite_name]:
+ try:
+ suite_dict[benchmark] = get_benchmark_result(benchmark.lower(), suite_name)
+ temp = temp + float(suite_dict[benchmark]['index'])
+ except OSError:
+ l = l - 1
+ pass
+
+ if l == 0:
+ logger.info("No {0} suite results found".format(suite_name))
+ return False
+ else:
+ suite_index = temp / l
+ suite_dict_f = {'index': suite_index,
+ 'suite_results': suite_dict}
+ with open('results/{0}_result.json'.format(suite_name), 'w+') as result_json:
+ json.dump(suite_dict_f, result_json, indent=4, sort_keys=True)
+ return True
+
+
+def main():
+ get_suite_result(sys.argv[1])
+
+
+if __name__ == "__main__":
+ main()
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 2b93c260..10537ecc 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -13,6 +13,7 @@ LABEL version="0.1" description="OPNFV QTIP Docker container"
ENV REPOS_DIR /home/opnfv/repos
ENV QTIP_DIR /home/opnfv/repos/qtip
ENV PYTHONPATH /home/opnfv/repos/qtip
+ENV HOME /home/opnfv
WORKDIR /home/opnfv
@@ -44,7 +45,7 @@ RUN apt-get install ansible --force-yes -y
RUN mkdir -p ${REPOS_DIR}
RUN mkdir -p /root/.ssh
-RUN mkdir -p /home/opnfv/qtip/logs
+RUN mkdir -p $HOME/qtip/logs
RUN chmod 700 /root/.ssh
#Config ansible
@@ -58,4 +59,4 @@ RUN git clone https://gerrit.opnfv.org/gerrit/releng $REPOS_DIR/releng
RUN pip install -r $REPOS_DIR/qtip/requirements.txt
-CMD cd $REPOS_DIR/qtip && python restful_server/qtip_server.py>/var/log/qtip/run.log
+CMD cd $REPOS_DIR/qtip && python restful_server/qtip_server.py>$HOME/qtip/logs/run.log
diff --git a/docker/run_qtip.sh b/docker/run_qtip.sh
index 79529e54..d766d46c 100755
--- a/docker/run_qtip.sh
+++ b/docker/run_qtip.sh
@@ -3,21 +3,21 @@ run_test_suite()
{
if [ "$TEST_CASE" == "compute" ]; then
cd ${QTIP_DIR} && python qtip.py -l default -f compute
- cd ${QTIP_DIR}/data/ref_results/ && python compute_suite.py
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py compute
elif [ "$TEST_CASE" == "storage" ]; then
cd ${QTIP_DIR} && python qtip.py -l default -f storage
- cd ${QTIP_DIR}/data/ref_results/ && python storage_suite.py
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py storage
elif [ "$TEST_CASE" == "network" ]; then
cd ${QTIP_DIR} && python qtip.py -l default -f network
- cd ${QTIP_DIR}/data/ref_results/ && python network_suite.py
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py network
elif [ "$TEST_CASE" == "all" ]; then
cd ${QTIP_DIR} && python qtip.py -l default -f compute
cd ${QTIP_DIR} && python qtip.py -l default -f storage
cd ${QTIP_DIR} && python qtip.py -l default -f network
-
- cd ${QTIP_DIR}/data/ref_results/ && python compute_suite.py
- cd ${QTIP_DIR}/data/ref_results/ && python storage_suite.py
- cd ${QTIP_DIR}/data/ref_results/ && python network_suite.py
+
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py compute
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py storage
+ cd ${QTIP_DIR} && python data/ref_results/suite_result.py network
fi
}
diff --git a/qtip.py b/qtip.py
index 094483fe..38130955 100644
--- a/qtip.py
+++ b/qtip.py
@@ -1,22 +1,19 @@
-##############################################################################
-# Copyright (c) 2015 Dell Inc 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
-##############################################################################
-from func.cli import Cli
-import os
-
-
-def main():
- os.system('./data/file_permission.sh')
- Cli()
-# os.system('cd data/ref_results && python compute_suite.py')
-# os.system('cd data/ref_results && python storage_suite.py')
-# os.system('cd data/ref_results && python network_suite.py')
-# os.system('cd data/report && python Qtip_Report.py')
-
-if __name__ == "__main__":
- main()
+##############################################################################
+# Copyright (c) 2015 Dell Inc 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
+##############################################################################
+from func.cli import Cli
+import os
+
+
+def main():
+ os.system('./data/file_permission.sh')
+ Cli()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/restful_server/result_handler.py b/restful_server/result_handler.py
new file mode 100644
index 00000000..059a2510
--- /dev/null
+++ b/restful_server/result_handler.py
@@ -0,0 +1,22 @@
+##############################################################################
+# Copyright (c) 2016 ZTE Corp 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 json
+import data.ref_results.suite_result as suite_result
+import dashboard.pushtoDB as push_to_db
+
+
+def dump_suite_result(suite_name):
+ return suite_result.get_suite_result(suite_name)
+
+
+def push_suite_result_to_db(suite_name, test_db_url, installer_type, node_name):
+ with open('results/{0}_result.json'.format(suite_name), 'r') as result_file:
+ j = json.load(result_file)
+ push_to_db.push_results_to_db(test_db_url, '{0}_test_suite'.format(suite_name),
+ j, installer_type, node_name)
diff --git a/utils/logger_utils.py b/utils/logger_utils.py
index 5efc1ef5..e8817c3c 100644
--- a/utils/logger_utils.py
+++ b/utils/logger_utils.py
@@ -59,7 +59,7 @@ class Logger(object):
class QtipLogger(Logger):
- file_path = '~/qtip/logs'
+ file_path = '{}/qtip/logs'.format(os.environ['HOME'])
def __init__(self, logger_name):
super(QtipLogger, self).__init__(logger_name)