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
21 def get_functest_cases():
23 get the list of the supported test cases
24 TODO: update the list when adding a new test case for the dashboard
26 return ["status", "vPing", "vPing_userdata", "vIMS", "Tempest", "ODL",
30 def format_functest_for_dashboard(case, results):
32 generic method calling the method corresponding to the test case
33 check that the testcase is properly declared first
34 then build the call to the specific method
36 if check_functest_case_exist(case):
37 cmd = "format_" + case + "_for_dashboard(results)"
41 print "Test cases not declared"
45 def check_functest_case_exist(case):
47 check if the testcase exists
48 if the test case is not defined or not declared in the list
51 functest_cases = get_functest_cases()
53 if (case is None or case not in functest_cases):
59 def format_status_for_dashboard(results):
60 test_data = [{'description': 'Functest status'}]
62 # define magic equation for the status....
63 # 5 suites: vPing, odl, Tempest, vIMS, Rally
64 # Which overall KPI make sense...
66 # TODO to be done and discussed
67 testcases = get_functest_cases()
68 test_data.append({'nb test suite(s) run': len(testcases)-1})
69 test_data.append({'vPing': '100%'})
70 test_data.append({'VIM status': '82%'})
71 test_data.append({'SDN Controllers': {'odl': '92%',
74 test_data.append({'VNF deployment': '95%'})
79 def format_vIMS_for_dashboard(results):
81 Post processing for the vIMS test case
83 test_data = [{'description': 'vIMS results for Dashboard'}]
85 # Graph 1: (duration_deployment_orchestrator,
86 # duration_deployment_vnf,
87 # duration_test) = f(time)
88 # ********************************
92 new_element.append({'x': data['creation_date'],
93 'y1': data['details']['orchestrator']['duration'],
94 'y2': data['details']['vIMS']['duration'],
95 'y3': data['details']['sig_test']['duration']})
97 test_data.append({'name': "vIMS orchestrator/VNF/test duration",
98 'info': {'type': "graph",
100 'y1label': 'orchestation deployment duration',
101 'y2label': 'vIMS deployment duration',
102 'y3label': 'vIMS test duration'},
103 'data_set': new_element})
105 # Graph 2: (Nb test, nb failure, nb skipped)=f(time)
106 # **************************************************
110 # Retrieve all the tests
114 vIMS_test = data['details']['sig_test']['result']
116 for data_test in vIMS_test:
117 # Calculate nb of tests run and nb of tests failed
118 # vIMS_results = get_vIMSresults(vIMS_test)
121 if data_test['result'] == "Passed":
123 elif data_test['result'] == "Failed":
125 elif data_test['result'] == "Skipped":
130 new_element.append({'x': data['creation_date'],
135 test_data.append({'name': "vIMS nb tests passed/failed/skipped",
136 'info': {'type': "graph",
138 'y1label': 'Number of tests passed',
139 'y2label': 'Number of tests failed',
140 'y3label': 'Number of tests skipped'},
141 'data_set': new_element})
143 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
144 # ********************************************************
149 vIMS_test = data['details']['sig_test']['result']
151 for data_test in vIMS_test:
156 if data_test['result'] == "Passed":
158 elif data_test['result'] == "Failed":
163 nbTests += nbTestsOK + nbTestsKO
164 nbFailures += nbTestsKO
166 test_data.append({'name': "Total number of tests run/failure tests",
167 'info': {"type": "bar"},
168 'data_set': [{'Run': nbTests,
169 'Failed': nbFailures}]})
174 def format_Tempest_for_dashboard(results):
176 Post processing for the Tempest test case
178 test_data = [{'description': 'Tempest results for Dashboard'}]
180 # Graph 1: Test_Duration = f(time)
181 # ********************************
184 new_element.append({'x': data['creation_date'],
185 'y': data['details']['duration']})
187 test_data.append({'name': "Tempest duration",
188 'info': {'type': "graph",
190 'ylabel': 'duration (s)'},
191 'data_set': new_element})
193 # Graph 2: (Nb test, nb failure)=f(time)
194 # ***************************************
197 new_element.append({'x': data['creation_date'],
198 'y1': data['details']['tests'],
199 'y2': data['details']['failures']})
201 test_data.append({'name': "Tempest nb tests/nb failures",
202 'info': {'type': "graph",
204 'y1label': 'Number of tests',
205 'y2label': 'Number of failures'},
206 'data_set': new_element})
208 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
209 # ********************************************************
214 nbTests += data['details']['tests']
215 nbFailures += data['details']['failures']
217 test_data.append({'name': "Total number of tests run/failure tests",
218 'info': {"type": "bar"},
219 'data_set': [{'Run': nbTests,
220 'Failed': nbFailures}]})
222 # Graph 4: (Success rate)=f(time)
223 # ***************************************
227 diff = (int(data['details']['tests']) - int(data['details']['failures']))
228 success_rate = 100*diff/int(data['details']['tests'])
232 new_element.append({'x': data['creation_date'],
235 test_data.append({'name': "Tempest success rate",
236 'info': {'type': "graph",
238 'y1label': 'Success rate'},
239 'data_set': new_element})
244 def format_ODL_for_dashboard(results):
246 Post processing for the ODL test case
248 test_data = [{'description': 'ODL results for Dashboard'}]
250 # Graph 1: (Nb test, nb failure)=f(time)
251 # ***************************************
255 odl_results = data['details']['details']
257 for odl in odl_results:
258 if (odl['test_status']['@status'] == "FAIL"):
260 new_element.append({'x': data['creation_date'],
261 'y1': len(odl_results),
264 test_data.append({'name': "ODL nb tests/nb failures",
265 'info': {'type': "graph",
267 'y1label': 'Number of tests',
268 'y2label': 'Number of failures'},
269 'data_set': new_element})
273 def format_ONOS_for_dashboard(results):
275 Post processing for the odl test case
277 test_data = [{'description': 'ONOS results for Dashboard'}]
278 # Graph 1: (duration FUNCvirtNet)=f(time)
279 # ***************************************
282 # default duration 0:00:08.999904
283 # consider only seconds => 09
285 t = data['details']['FUNCvirNet']['duration']
286 h, m, s = re.split(':', t)
288 new_duration = int(datetime.timedelta(hours=int(h),
290 seconds=int(s)).total_seconds())
291 new_element.append({'x': data['creation_date'],
294 test_data.append({'name': "ONOS FUNCvirNet duration ",
295 'info': {'type': "graph",
296 'xlabel': 'time (s)',
297 'ylabel': 'duration (s)'},
298 'data_set': new_element})
300 # Graph 2: (Nb test, nb failure)FuncvirtNet=f(time)
301 # ***************************************
305 onos_results = data['details']['FUNCvirNet']['status']
307 for onos in onos_results:
308 if (onos['Case result'] == "FAIL"):
310 new_element.append({'x': data['creation_date'],
311 'y1': len(onos_results),
314 test_data.append({'name': "ONOS FUNCvirNet nb tests/nb failures",
315 'info': {'type': "graph",
317 'y1label': 'Number of tests',
318 'y2label': 'Number of failures'},
319 'data_set': new_element})
321 # Graph 3: (duration FUNCvirtNetL3)=f(time)
322 # ***************************************
325 # default duration 0:00:08.999904
326 # consider only seconds => 09
328 t = data['details']['FUNCvirNetL3']['duration']
329 h, m, s = re.split(':', t)
331 new_duration = int(datetime.timedelta(hours=int(h),
333 seconds=int(s)).total_seconds())
334 new_element.append({'x': data['creation_date'],
337 test_data.append({'name': "ONOS FUNCvirNetL3 duration",
338 'info': {'type': "graph",
339 'xlabel': 'time (s)',
340 'ylabel': 'duration (s)'},
341 'data_set': new_element})
343 # Graph 4: (Nb test, nb failure)FuncvirtNetL3=f(time)
344 # ***************************************
348 onos_results = data['details']['FUNCvirNetL3']['status']
350 for onos in onos_results:
351 if (onos['Case result'] == "FAIL"):
353 new_element.append({'x': data['creation_date'],
354 'y1': len(onos_results),
357 test_data.append({'name': "ONOS FUNCvirNetL3 nb tests/nb failures",
358 'info': {'type': "graph",
360 'y1label': 'Number of tests',
361 'y2label': 'Number of failures'},
362 'data_set': new_element})
366 def format_Rally_for_dashboard(results):
368 Post processing for the Rally test case
370 test_data = [{'description': 'Rally results for Dashboard'}]
371 # Graph 1: Test_Duration = f(time)
372 # ********************************
375 summary_cursor = len(data['details']) - 1
376 new_element.append({'x': data['creation_date'],
377 'y': int(data['details'][summary_cursor]['summary']['duration'])})
379 test_data.append({'name': "rally duration",
380 'info': {'type': "graph",
382 'ylabel': 'duration (s)'},
383 'data_set': new_element})
385 # Graph 2: Success rate = f(time)
386 # ********************************
389 new_element.append({'x': data['creation_date'],
390 'y': float(data['details'][summary_cursor]['summary']['nb success'])})
392 test_data.append({'name': "rally success rate",
393 'info': {'type': "graph",
395 'ylabel': 'success rate (%)'},
396 'data_set': new_element})
401 def format_vPing_for_dashboard(results):
403 Post processing for the vPing test case
405 test_data = [{'description': 'vPing results for Dashboard'}]
407 # Graph 1: Test_Duration = f(time)
408 # ********************************
411 new_element.append({'x': data['creation_date'],
412 'y': data['details']['duration']})
414 test_data.append({'name': "vPing duration",
415 'info': {'type': "graph",
417 'ylabel': 'duration (s)'},
418 'data_set': new_element})
427 if data['details']['status'] == "OK":
430 test_data.append({'name': "vPing status",
431 'info': {"type": "bar"},
432 'data_set': [{'Nb tests': nbTest,
433 'Nb Success': nbTestOk}]})
438 def format_vPing_userdata_for_dashboard(results):
440 Post processing for the vPing_userdata test case
442 test_data = [{'description': 'vPing_userdata results for Dashboard'}]
444 # Graph 1: Test_Duration = f(time)
445 # ********************************
448 new_element.append({'x': data['creation_date'],
449 'y': data['details']['duration']})
451 test_data.append({'name': "vPing_userdata duration",
452 'info': {'type': "graph",
454 'ylabel': 'duration (s)'},
455 'data_set': new_element})
464 if data['details']['status'] == "OK":
467 test_data.append({'name': "vPing_userdata status",
468 'info': {"type": "bar"},
469 'data_set': [{'Nb tests': nbTest,
470 'Nb Success': nbTestOk}]})