3 ##############################################################################
4 # Copyright (c) 2015 Dell Inc and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
15 get the list of the supported test cases
16 TODO: update the list when adding a new test case for the dashboard
18 return ["compute_test_suite","storage_test_suite","network_test_suite"]
20 def check_qtip_case_exist(case):
22 check if the testcase exists
23 if the test case is not defined or not declared in the list
26 qtip_cases = get_qtip_cases()
27 if (case is None or case not in qtip_cases):
32 def format_qtip_for_dashboard(case, results):
34 generic method calling the method corresponding to the test case
35 check that the testcase is properly declared first
36 then build the call to the specific method
38 if check_qtip_case_exist(case):
39 res = format_common_for_dashboard(case, results)
42 print "Test cases not declared"
45 def format_common_for_dashboard(case, results):
47 Common post processing
49 test_data_description = case + " results for Dashboard"
50 test_data = [{'description': test_data_description}]
53 if "network_test_suite" in case:
54 graph_name = "Throughput index"
59 # ********************************
61 for date, index in results:
62 new_element.append({'x': date,
66 test_data.append({'name': graph_name,
67 'info': {'type': "graph",
69 'y1label': 'Index Number'},
70 'data_set': new_element})
75 ############################ For local test ################################
79 from collections import defaultdict
81 def _get_results(db_url, testcase):
83 testproject = testcase["project"]
84 testcase = testcase["testcase"]
85 resultarray = defaultdict()
87 header = {'Content-Type': 'application/json'}
89 url = db_url + "/results?project="+testproject+"&case="+testcase
90 data = requests.get(url,header)
91 datajson = data.json()
92 for x in range(0, len(datajson['test_results'])):
94 rawresults = datajson['test_results'][x]['details']
95 index = rawresults['index']
96 resultarray[str(datajson['test_results'][x]['creation_date'])]=index
102 db_url = "http://testresults.opnfv.org/testapi"
103 raw_result = defaultdict()
105 raw_result = _get_results(db_url, {"project": "qtip", "testcase": "compute_test_suite"})
106 resultitems= raw_result.items()
107 result = format_qtip_for_dashboard("compute_test_suite", resultitems)
110 raw_result = _get_results(db_url, {"project": "qtip", "testcase": "storage_test_suite"})
111 resultitems= raw_result.items()
112 result = format_qtip_for_dashboard("storage_test_suite", resultitems)
115 raw_result = _get_results(db_url, {"project": "qtip", "testcase": "network_test_suite"})
116 resultitems= raw_result.items()
117 result = format_qtip_for_dashboard("network_test_suite", resultitems)
120 if __name__ == '__main__':