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)
120 if data_test['result'] == "Passed":
122 elif data_test['result'] == "Failed":
124 elif data_test['result'] == "Skipped":
127 new_element.append({'x': data['creation_date'],
132 test_data.append({'name': "vIMS nb tests passed/failed/skipped",
133 'info': {'type': "graph",
135 'y1label': 'Number of tests passed',
136 'y2label': 'Number of tests failed',
137 'y3label': 'Number of tests skipped'},
138 'data_set': new_element})
140 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
141 # ********************************************************
146 vIMS_test = data['details']['sig_test']['result']
148 for data_test in vIMS_test:
152 if data_test['result'] == "Passed":
154 elif data_test['result'] == "Failed":
157 nbTests += nbTestsOK + nbTestsKO
158 nbFailures += nbTestsKO
160 test_data.append({'name': "Total number of tests run/failure tests",
161 'info': {"type": "bar"},
162 'data_set': [{'Run': nbTests,
163 'Failed': nbFailures}]})
168 def format_Tempest_for_dashboard(results):
170 Post processing for the Tempest test case
172 test_data = [{'description': 'Tempest results for Dashboard'}]
174 # Graph 1: Test_Duration = f(time)
175 # ********************************
178 new_element.append({'x': data['creation_date'],
179 'y': data['details']['duration']})
181 test_data.append({'name': "Tempest duration",
182 'info': {'type': "graph",
184 'ylabel': 'duration (s)'},
185 'data_set': new_element})
187 # Graph 2: (Nb test, nb failure)=f(time)
188 # ***************************************
191 new_element.append({'x': data['creation_date'],
192 'y1': data['details']['tests'],
193 'y2': data['details']['failures']})
195 test_data.append({'name': "Tempest nb tests/nb failures",
196 'info': {'type': "graph",
198 'y1label': 'Number of tests',
199 'y2label': 'Number of failures'},
200 'data_set': new_element})
202 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
203 # ********************************************************
208 nbTests += data['details']['tests']
209 nbFailures += data['details']['failures']
211 test_data.append({'name': "Total number of tests run/failure tests",
212 'info': {"type": "bar"},
213 'data_set': [{'Run': nbTests,
214 'Failed': nbFailures}]})
216 # Graph 4: (Success rate)=f(time)
217 # ***************************************
221 diff = (int(data['details']['tests']) - int(data['details']['failures']))
222 success_rate = 100*diff/int(data['details']['tests'])
226 new_element.append({'x': data['creation_date'],
229 test_data.append({'name': "Tempest success rate",
230 'info': {'type': "graph",
232 'y1label': 'Success rate'},
233 'data_set': new_element})
238 def format_ODL_for_dashboard(results):
240 Post processing for the ODL test case
242 test_data = [{'description': 'ODL results for Dashboard'}]
244 # Graph 1: (Nb test, nb failure)=f(time)
245 # ***************************************
249 odl_results = data['details']['details']
251 for odl in odl_results:
252 if (odl['test_status']['@status'] == "FAIL"):
254 new_element.append({'x': data['creation_date'],
255 'y1': len(odl_results),
258 test_data.append({'name': "ODL nb tests/nb failures",
259 'info': {'type': "graph",
261 'y1label': 'Number of tests',
262 'y2label': 'Number of failures'},
263 'data_set': new_element})
267 def format_ONOS_for_dashboard(results):
269 Post processing for the odl test case
271 test_data = [{'description': 'ONOS results for Dashboard'}]
272 # Graph 1: (duration FUNCvirtNet)=f(time)
273 # ***************************************
276 # default duration 0:00:08.999904
277 # consider only seconds => 09
279 t = data['details']['FUNCvirNet']['duration']
280 h, m, s = re.split(':', t)
282 new_duration = int(datetime.timedelta(hours=int(h),
284 seconds=int(s)).total_seconds())
285 new_element.append({'x': data['creation_date'],
288 test_data.append({'name': "ONOS FUNCvirNet duration ",
289 'info': {'type': "graph",
290 'xlabel': 'time (s)',
291 'ylabel': 'duration (s)'},
292 'data_set': new_element})
294 # Graph 2: (Nb test, nb failure)FuncvirtNet=f(time)
295 # ***************************************
299 onos_results = data['details']['FUNCvirNet']['status']
301 for onos in onos_results:
302 if (onos['Case result'] == "FAIL"):
304 new_element.append({'x': data['creation_date'],
305 'y1': len(onos_results),
308 test_data.append({'name': "ONOS FUNCvirNet nb tests/nb failures",
309 'info': {'type': "graph",
311 'y1label': 'Number of tests',
312 'y2label': 'Number of failures'},
313 'data_set': new_element})
315 # Graph 3: (duration FUNCvirtNetL3)=f(time)
316 # ***************************************
319 # default duration 0:00:08.999904
320 # consider only seconds => 09
322 t = data['details']['FUNCvirNetL3']['duration']
323 h, m, s = re.split(':', t)
325 new_duration = int(datetime.timedelta(hours=int(h),
327 seconds=int(s)).total_seconds())
328 new_element.append({'x': data['creation_date'],
331 test_data.append({'name': "ONOS FUNCvirNetL3 duration",
332 'info': {'type': "graph",
333 'xlabel': 'time (s)',
334 'ylabel': 'duration (s)'},
335 'data_set': new_element})
337 # Graph 4: (Nb test, nb failure)FuncvirtNetL3=f(time)
338 # ***************************************
342 onos_results = data['details']['FUNCvirNetL3']['status']
344 for onos in onos_results:
345 if (onos['Case result'] == "FAIL"):
347 new_element.append({'x': data['creation_date'],
348 'y1': len(onos_results),
351 test_data.append({'name': "ONOS FUNCvirNetL3 nb tests/nb failures",
352 'info': {'type': "graph",
354 'y1label': 'Number of tests',
355 'y2label': 'Number of failures'},
356 'data_set': new_element})
360 def format_Rally_for_dashboard(results):
362 Post processing for the Rally test case
364 test_data = [{'description': 'Rally results for Dashboard'}]
365 # Graph 1: Test_Duration = f(time)
366 # ********************************
369 summary_cursor = len(data)
370 new_element.append({'x': data['creation_date'],
371 'y': int(data['details'][summary_cursor]['summary']['duration'])})
373 test_data.append({'name': "rally duration",
374 'info': {'type': "graph",
376 'ylabel': 'duration (s)'},
377 'data_set': new_element})
379 # Graph 2: Success rate = f(time)
380 # ********************************
383 new_element.append({'x': data['creation_date'],
384 'y': float(data['details'][summary_cursor]['summary']['nb success'])})
386 test_data.append({'name': "rally success rate",
387 'info': {'type': "graph",
389 'ylabel': 'success rate (%)'},
390 'data_set': new_element})
395 def format_vPing_for_dashboard(results):
397 Post processing for the vPing test case
399 test_data = [{'description': 'vPing results for Dashboard'}]
401 # Graph 1: Test_Duration = f(time)
402 # ********************************
405 new_element.append({'x': data['creation_date'],
406 'y': data['details']['duration']})
408 test_data.append({'name': "vPing duration",
409 'info': {'type': "graph",
411 'ylabel': 'duration (s)'},
412 'data_set': new_element})
421 if data['details']['status'] == "OK":
424 test_data.append({'name': "vPing status",
425 'info': {"type": "bar"},
426 'data_set': [{'Nb tests': nbTest,
427 'Nb Success': nbTestOk}]})
432 def format_vPing_userdata_for_dashboard(results):
434 Post processing for the vPing_userdata test case
436 test_data = [{'description': 'vPing_userdata results for Dashboard'}]
438 # Graph 1: Test_Duration = f(time)
439 # ********************************
442 new_element.append({'x': data['creation_date'],
443 'y': data['details']['duration']})
445 test_data.append({'name': "vPing_userdata duration",
446 'info': {'type': "graph",
448 'ylabel': 'duration (s)'},
449 'data_set': new_element})
458 if data['details']['status'] == "OK":
461 test_data.append({'name': "vPing_userdata status",
462 'info': {"type": "bar"},
463 'data_set': [{'Nb tests': nbTest,
464 'Nb Success': nbTestOk}]})