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
20 def get_functest_cases():
22 get the list of the supported test cases
23 TODO: update the list when adding a new test case for the dashboard
25 return ["status", "vPing", "vPing_userdata", "vIMS", "Tempest", "ODL", "ONOS", "Rally"]
28 def format_functest_for_dashboard(case, results):
30 generic method calling the method corresponding to the test case
31 check that the testcase is properly declared first
32 then build the call to the specific method
34 if check_functest_case_exist(case):
35 cmd = "format_" + case + "_for_dashboard(results)"
39 print "Test cases not declared"
43 def check_functest_case_exist(case):
45 check if the testcase exists
46 if the test case is not defined or not declared in the list
49 functest_cases = get_functest_cases()
51 if (case is None or case not in functest_cases):
57 def format_status_for_dashboard(results):
58 test_data = [{'description': 'Functest status'}]
60 # define magic equation for the status....
61 # 5 suites: vPing, odl, Tempest, vIMS, Rally
62 # Which overall KPI make sense...
64 # TODO to be done and discussed
65 testcases = get_functest_cases()
66 test_data.append({'nb test suite(s) run': len(testcases)-1})
67 test_data.append({'vPing': '100%'})
68 test_data.append({'VIM status': '82%'})
69 test_data.append({'SDN Controllers': {'odl':'92%', 'onos':'95%', 'opencontrail':'93%'}})
70 test_data.append({'VNF deployment': '95%'})
75 def format_vIMS_for_dashboard(results):
77 Post processing for the vIMS test case
79 test_data = [{'description': 'vIMS results for Dashboard'}]
81 # Graph 1: (duration_deployment_orchestrator,
82 # duration_deployment_vnf,
83 # duration_test) = f(time)
84 # ********************************
88 new_element.append({'x': data['creation_date'],
89 'y1': data['details']['orchestrator']['duration'],
90 'y2': data['details']['vIMS']['duration'],
91 'y3': data['details']['sig_test']['duration']})
93 test_data.append({'name': "vIMS orchestrator/VNF/test duration",
94 'info': {'type': "graph",
96 'y1label': 'orchestation deployment duration',
97 'y2label': 'vIMS deployment duration',
98 'y3label': 'vIMS test duration'},
99 'data_set': new_element})
101 # Graph 2: (Nb test, nb failure, nb skipped)=f(time)
102 # **************************************************
106 # Retrieve all the tests
110 vIMS_test = data['details']['sig_test']['result']
112 for data_test in vIMS_test:
113 # Calculate nb of tests run and nb of tests failed
114 # vIMS_results = get_vIMSresults(vIMS_test)
116 if data_test['result'] == "Passed":
118 elif data_test['result'] == "Failed":
120 elif data_test['result'] == "Skipped":
123 new_element.append({'x': data['creation_date'],
128 test_data.append({'name': "vIMS nb tests passed/failed/skipped",
129 'info': {'type': "graph",
131 'y1label': 'Number of tests passed',
132 'y2label': 'Number of tests failed',
133 'y3label': 'Number of tests skipped'},
134 'data_set': new_element})
136 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
137 # ********************************************************
142 vIMS_test = data['details']['sig_test']['result']
144 for data_test in vIMS_test:
148 if data_test['result'] == "Passed":
150 elif data_test['result'] == "Failed":
153 nbTests += nbTestsOK + nbTestsKO
154 nbFailures += nbTestsKO
156 test_data.append({'name': "Total number of tests run/failure tests",
157 'info': {"type": "bar"},
158 'data_set': [{'Run': nbTests,
159 'Failed': nbFailures}]})
164 def format_Tempest_for_dashboard(results):
166 Post processing for the Tempest test case
168 test_data = [{'description': 'Tempest results for Dashboard'}]
170 # Graph 1: Test_Duration = f(time)
171 # ********************************
174 new_element.append({'x': data['creation_date'],
175 'y': data['details']['duration']})
177 test_data.append({'name': "Tempest duration",
178 'info': {'type': "graph",
180 'ylabel': 'duration (s)'},
181 'data_set': new_element})
183 # Graph 2: (Nb test, nb failure)=f(time)
184 # ***************************************
187 new_element.append({'x': data['creation_date'],
188 'y1': data['details']['tests'],
189 'y2': data['details']['failures']})
191 test_data.append({'name': "Tempest nb tests/nb failures",
192 'info': {'type': "graph",
194 'y1label': 'Number of tests',
195 'y2label': 'Number of failures'},
196 'data_set': new_element})
198 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
199 # ********************************************************
204 nbTests += data['details']['tests']
205 nbFailures += data['details']['failures']
207 test_data.append({'name': "Total number of tests run/failure tests",
208 'info': {"type": "bar"},
209 'data_set': [{'Run': nbTests,
210 'Failed': nbFailures}]})
215 def format_ODL_for_dashboard(results):
217 Post processing for the ODL test case
219 test_data = [{'description': 'ODL results for Dashboard'}]
221 # Graph 1: (Nb test, nb failure)=f(time)
222 # ***************************************
226 odl_results = data['details']['details']
228 for odl in odl_results:
229 if (odl['test_status']['@status'] == "FAIL"):
231 new_element.append({'x': data['creation_date'],
232 'y1': len(odl_results),
235 test_data.append({'name': "ODL nb tests/nb failures",
236 'info': {'type': "graph",
238 'y1label': 'Number of tests',
239 'y2label': 'Number of failures'},
240 'data_set': new_element})
244 def format_ONOS_for_dashboard(results):
246 Post processing for the odl test case
248 test_data = [{'description': 'ONOS results for Dashboard'}]
249 # Graph 1: (duration)=f(time)
250 # ***************************************
253 # default duration 0:00:08.999904
254 # consider only seconds => 09
256 t = data['details']['duration']
257 h,m,s = re.split(':',t)
259 new_duration = int(datetime.timedelta(hours=int(h),minutes=int(m),seconds=int(s)).total_seconds())
260 new_element.append({'x': data['creation_date'],
263 test_data.append({'name': "ONOS duration",
264 'info': {'type': "graph",
265 'xlabel': 'time (s)',
266 'ylabel': 'duration (s)'},
267 'data_set': new_element})
271 def format_Rally_for_dashboard(results):
273 Post processing for the Rally test case
275 test_data = [{'description': 'Rally results for Dashboard'}]
279 def format_vPing_for_dashboard(results):
281 Post processing for the vPing test case
283 test_data = [{'description': 'vPing results for Dashboard'}]
285 # Graph 1: Test_Duration = f(time)
286 # ********************************
289 new_element.append({'x': data['creation_date'],
290 'y': data['details']['duration']})
292 test_data.append({'name': "vPing duration",
293 'info': {'type': "graph",
295 'ylabel': 'duration (s)'},
296 'data_set': new_element})
305 if data['details']['status'] == "OK":
308 test_data.append({'name': "vPing status",
309 'info': {"type": "bar"},
310 'data_set': [{'Nb tests': nbTest,
311 'Nb Success': nbTestOk}]})
315 def format_vPing_userdata_for_dashboard(results):
317 Post processing for the vPing_userdata test case
319 test_data = [{'description': 'vPing_userdata results for Dashboard'}]
321 # Graph 1: Test_Duration = f(time)
322 # ********************************
325 new_element.append({'x': data['creation_date'],
326 'y': data['details']['duration']})
328 test_data.append({'name': "vPing_userdata duration",
329 'info': {'type': "graph",
331 'ylabel': 'duration (s)'},
332 'data_set': new_element})
341 if data['details']['status'] == "OK":
344 test_data.append({'name': "vPing_userdata status",
345 'info': {"type": "bar"},
346 'data_set': [{'Nb tests': nbTest,
347 'Nb Success': nbTestOk}]})