3 # Copyright (c) 2015 Orange
4 # morgan.richomme@orange.com
6 # 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
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # This script is used to build dashboard ready json results
13 # It may be used for all the test case of the Functest project
14 # a new method format_<Test_case>_for_dashboard(results)
15 # v0.1: basic example with methods for odl, Tempest, Rally and vPing
19 def get_functest_cases():
21 get the list of the supported test cases
22 TODO: update the list when adding a new test case for the dashboard
24 return ["status", "vPing", "vIMS", "Tempest", "odl", "Rally"]
27 def format_functest_for_dashboard(case, results):
29 generic method calling the method corresponding to the test case
30 check that the testcase is properly declared first
31 then build the call to the specific method
33 if check_functest_case_exist(case):
34 cmd = "format_" + case + "_for_dashboard(results)"
38 print "Test cases not declared"
42 def check_functest_case_exist(case):
44 check if the testcase exists
45 if the test case is not defined or not declared in the list
48 functest_cases = get_functest_cases()
50 if (case is None or case not in functest_cases):
56 def format_status_for_dashboard(results):
57 test_data = [{'description': 'Functest status'}]
59 # define magic equation for the status....
60 # 5 suites: vPing, odl, Tempest, vIMS, Rally
61 # Which overall KPI make sense...
63 # TODO to be done and discussed
64 testcases = get_functest_cases()
65 test_data.append({'nb test suite(s) run': len(testcases)-1})
66 # test_data.append({'nb test suite(s) failed':1})
67 # test_data.append({'test suite run': ['vPing', 'tempest', 'vIMS' ]})
68 # test_data.append({'average Openstack Tempest failure rate (%)': 10})
69 # test_data.append({'average odl failure rate (%)': 10})
74 def format_vIMS_for_dashboard(results):
76 Post processing for the vIMS test case
78 test_data = [{'description': 'vIMS results for Dashboard'}]
80 # Graph 1: (duration_deployment_orchestrator,
81 # duration_deployment_vnf,
82 # duration_test) = f(time)
83 # ********************************
87 new_element.append({'x': data['creation_date'],
88 'y1': data['details']['orchestrator']['duration'],
89 'y2': data['details']['vIMS']['duration'],
90 'y3': data['details']['sig_test']['duration']})
92 test_data.append({'name': "Tempest nb tests/nb failures",
93 'info': {'type': "graph",
95 'y1label': 'orchestation deployment duration',
96 'y2label': 'vIMS deployment duration',
97 'y3label': 'vIMS test duration'},
98 'data_set': new_element})
100 # Graph 2: (Nb test, nb failure, nb skipped)=f(time)
101 # **************************************************
105 # Retrieve all the tests
109 vIMS_test = data['details']['sig_test']['result']
111 for data_test in vIMS_test:
112 # Calculate nb of tests run and nb of tests failed
113 # vIMS_results = get_vIMSresults(vIMS_test)
115 if data_test['result'] == "Passed":
117 elif data_test['result'] == "Failed":
119 elif data_test['result'] == "Skipped":
122 new_element.append({'x': data['creation_date'],
127 test_data.append({'name': "vIMS nb tests passed/failed/skipped",
128 'info': {'type': "graph",
130 'y1label': 'Number of tests passed',
131 'y2label': 'Number of tests failed',
132 'y3label': 'Number of tests skipped'},
133 'data_set': new_element})
135 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
136 # ********************************************************
141 vIMS_test = data['details']['sig_test']['result']
143 for data_test in vIMS_test:
147 if data_test['result'] == "Passed":
149 elif data_test['result'] == "Failed":
152 nbTests += nbTestsOK + nbTestsKO
153 nbFailures += nbTestsKO
155 test_data.append({'name': "Total number of tests run/failure tests",
156 'info': {"type": "bar"},
157 'data_set': [{'Run': nbTests,
158 'Failed': nbFailures}]})
163 def format_Tempest_for_dashboard(results):
165 Post processing for the Tempest test case
167 test_data = [{'description': 'Tempest results for Dashboard'}]
169 # Graph 1: Test_Duration = f(time)
170 # ********************************
173 new_element.append({'x': data['creation_date'],
174 'y': data['details']['duration']})
176 test_data.append({'name': "Tempest duration",
177 'info': {'type': "graph",
179 'ylabel': 'duration (s)'},
180 'data_set': new_element})
182 # Graph 2: (Nb test, nb failure)=f(time)
183 # ***************************************
186 new_element.append({'x': data['creation_date'],
187 'y1': data['details']['tests'],
188 'y2': data['details']['failures']})
190 test_data.append({'name': "Tempest nb tests/nb failures",
191 'info': {'type': "graph",
193 'y1label': 'Number of tests',
194 'y2label': 'Number of failures'},
195 'data_set': new_element})
197 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
198 # ********************************************************
203 nbTests += data['details']['tests']
204 nbFailures += data['details']['failures']
206 test_data.append({'name': "Total number of tests run/failure tests",
207 'info': {"type": "bar"},
208 'data_set': [{'Run': nbTests,
209 'Failed': nbFailures}]})
214 def format_odl_for_dashboard(results):
216 Post processing for the odl test case
218 test_data = [{'description': 'odl results for Dashboard'}]
222 def format_Rally_for_dashboard(results):
224 Post processing for the Rally test case
226 test_data = [{'description': 'Rally results for Dashboard'}]
230 def format_vPing_for_dashboard(results):
232 Post processing for the vPing test case
234 test_data = [{'description': 'vPing results for Dashboard'}]
236 # Graph 1: Test_Duration = f(time)
237 # ********************************
240 new_element.append({'x': data['creation_date'],
241 'y': data['details']['duration']})
243 test_data.append({'name': "vPing duration",
244 'info': {'type': "graph",
246 'ylabel': 'duration (s)'},
247 'data_set': new_element})
256 if data['details']['status'] == "OK":
259 test_data.append({'name': "vPing status",
260 'info': {"type": "bar"},
261 'data_set': [{'Nb tests': nbTest,
262 'Nb Success': nbTestOk}]})