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}]})
219 def format_ODL_for_dashboard(results):
221 Post processing for the ODL test case
223 test_data = [{'description': 'ODL results for Dashboard'}]
225 # Graph 1: (Nb test, nb failure)=f(time)
226 # ***************************************
230 odl_results = data['details']['details']
232 for odl in odl_results:
233 if (odl['test_status']['@status'] == "FAIL"):
235 new_element.append({'x': data['creation_date'],
236 'y1': len(odl_results),
239 test_data.append({'name': "ODL nb tests/nb failures",
240 'info': {'type': "graph",
242 'y1label': 'Number of tests',
243 'y2label': 'Number of failures'},
244 'data_set': new_element})
248 def format_ONOS_for_dashboard(results):
250 Post processing for the odl test case
252 test_data = [{'description': 'ONOS results for Dashboard'}]
253 # Graph 1: (duration FUNCvirtNet)=f(time)
254 # ***************************************
257 # default duration 0:00:08.999904
258 # consider only seconds => 09
260 t = data['details']['FUNCvirNet']['duration']
261 h, m, s = re.split(':', t)
263 new_duration = int(datetime.timedelta(hours=int(h),
265 seconds=int(s)).total_seconds())
266 new_element.append({'x': data['creation_date'],
269 test_data.append({'name': "ONOS FUNCvirNet duration ",
270 'info': {'type': "graph",
271 'xlabel': 'time (s)',
272 'ylabel': 'duration (s)'},
273 'data_set': new_element})
275 # Graph 2: (Nb test, nb failure)FuncvirtNet=f(time)
276 # ***************************************
280 onos_results = data['details']['FUNCvirNet']['status']
282 for onos in onos_results:
283 if (onos['Case result'] == "FAIL"):
285 new_element.append({'x': data['creation_date'],
286 'y1': len(onos_results),
289 test_data.append({'name': "ONOS FUNCvirNet nb tests/nb failures",
290 'info': {'type': "graph",
292 'y1label': 'Number of tests',
293 'y2label': 'Number of failures'},
294 'data_set': new_element})
296 # Graph 3: (duration FUNCvirtNetL3)=f(time)
297 # ***************************************
300 # default duration 0:00:08.999904
301 # consider only seconds => 09
303 t = data['details']['FUNCvirNetL3']['duration']
304 h, m, s = re.split(':', t)
306 new_duration = int(datetime.timedelta(hours=int(h),
308 seconds=int(s)).total_seconds())
309 new_element.append({'x': data['creation_date'],
312 test_data.append({'name': "ONOS FUNCvirNetL3 duration",
313 'info': {'type': "graph",
314 'xlabel': 'time (s)',
315 'ylabel': 'duration (s)'},
316 'data_set': new_element})
318 # Graph 4: (Nb test, nb failure)FuncvirtNetL3=f(time)
319 # ***************************************
323 onos_results = data['details']['FUNCvirNetL3']['status']
325 for onos in onos_results:
326 if (onos['Case result'] == "FAIL"):
328 new_element.append({'x': data['creation_date'],
329 'y1': len(onos_results),
332 test_data.append({'name': "ONOS FUNCvirNetL3 nb tests/nb failures",
333 'info': {'type': "graph",
335 'y1label': 'Number of tests',
336 'y2label': 'Number of failures'},
337 'data_set': new_element})
341 def format_Rally_for_dashboard(results):
343 Post processing for the Rally test case
345 test_data = [{'description': 'Rally results for Dashboard'}]
346 # Graph 1: Test_Duration = f(time)
347 # ********************************
350 summary_cursor = len(data)
351 new_element.append({'x': data['creation_date'],
352 'y': int(data['details'][summary_cursor]['summary']['duration'])})
354 test_data.append({'name': "rally duration",
355 'info': {'type': "graph",
357 'ylabel': 'duration (s)'},
358 'data_set': new_element})
360 # Graph 2: Success rate = f(time)
361 # ********************************
364 new_element.append({'x': data['creation_date'],
365 'y': float(data['details'][summary_cursor]['summary']['nb success'])})
367 test_data.append({'name': "rally success rate",
368 'info': {'type': "graph",
370 'ylabel': 'success rate (%)'},
371 'data_set': new_element})
376 def format_vPing_for_dashboard(results):
378 Post processing for the vPing test case
380 test_data = [{'description': 'vPing results for Dashboard'}]
382 # Graph 1: Test_Duration = f(time)
383 # ********************************
386 new_element.append({'x': data['creation_date'],
387 'y': data['details']['duration']})
389 test_data.append({'name': "vPing duration",
390 'info': {'type': "graph",
392 'ylabel': 'duration (s)'},
393 'data_set': new_element})
402 if data['details']['status'] == "OK":
405 test_data.append({'name': "vPing status",
406 'info': {"type": "bar"},
407 'data_set': [{'Nb tests': nbTest,
408 'Nb Success': nbTestOk}]})
413 def format_vPing_userdata_for_dashboard(results):
415 Post processing for the vPing_userdata test case
417 test_data = [{'description': 'vPing_userdata results for Dashboard'}]
419 # Graph 1: Test_Duration = f(time)
420 # ********************************
423 new_element.append({'x': data['creation_date'],
424 'y': data['details']['duration']})
426 test_data.append({'name': "vPing_userdata duration",
427 'info': {'type': "graph",
429 'ylabel': 'duration (s)'},
430 'data_set': new_element})
439 if data['details']['status'] == "OK":
442 test_data.append({'name': "vPing_userdata status",
443 'info': {"type": "bar"},
444 'data_set': [{'Nb tests': nbTest,
445 'Nb Success': nbTestOk}]})