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
18 def get_functest_cases():
20 get the list of the supported test cases
21 TODO: update the list when adding a new test case for the dashboard
23 return ["status", "vPing", "vPing_userdata", "vIMS", "Tempest", "odl", "Rally"]
26 def format_functest_for_dashboard(case, results):
28 generic method calling the method corresponding to the test case
29 check that the testcase is properly declared first
30 then build the call to the specific method
32 if check_functest_case_exist(case):
33 cmd = "format_" + case + "_for_dashboard(results)"
37 print "Test cases not declared"
41 def check_functest_case_exist(case):
43 check if the testcase exists
44 if the test case is not defined or not declared in the list
47 functest_cases = get_functest_cases()
49 if (case is None or case not in functest_cases):
55 def format_status_for_dashboard(results):
56 test_data = [{'description': 'Functest status'}]
58 # define magic equation for the status....
59 # 5 suites: vPing, odl, Tempest, vIMS, Rally
60 # Which overall KPI make sense...
62 # TODO to be done and discussed
63 testcases = get_functest_cases()
64 test_data.append({'nb test suite(s) run': len(testcases)-1})
65 test_data.append({'vPing': '100%'})
66 test_data.append({'VIM status': '82%'})
67 test_data.append({'SDN Controllers': {'odl':'92%', 'onos':'95%', 'opencontrail':'93%'}})
68 test_data.append({'VNF deployment': '95%'})
73 def format_vIMS_for_dashboard(results):
75 Post processing for the vIMS test case
77 test_data = [{'description': 'vIMS results for Dashboard'}]
79 # Graph 1: (duration_deployment_orchestrator,
80 # duration_deployment_vnf,
81 # duration_test) = f(time)
82 # ********************************
86 new_element.append({'x': data['creation_date'],
87 'y1': data['details']['orchestrator']['duration'],
88 'y2': data['details']['vIMS']['duration'],
89 'y3': data['details']['sig_test']['duration']})
91 test_data.append({'name': "vIMS orchestrator/VNF/test duration",
92 'info': {'type': "graph",
94 'y1label': 'orchestation deployment duration',
95 'y2label': 'vIMS deployment duration',
96 'y3label': 'vIMS test duration'},
97 'data_set': new_element})
99 # Graph 2: (Nb test, nb failure, nb skipped)=f(time)
100 # **************************************************
104 # Retrieve all the tests
108 vIMS_test = data['details']['sig_test']['result']
110 for data_test in vIMS_test:
111 # Calculate nb of tests run and nb of tests failed
112 # vIMS_results = get_vIMSresults(vIMS_test)
114 if data_test['result'] == "Passed":
116 elif data_test['result'] == "Failed":
118 elif data_test['result'] == "Skipped":
121 new_element.append({'x': data['creation_date'],
126 test_data.append({'name': "vIMS nb tests passed/failed/skipped",
127 'info': {'type': "graph",
129 'y1label': 'Number of tests passed',
130 'y2label': 'Number of tests failed',
131 'y3label': 'Number of tests skipped'},
132 'data_set': new_element})
134 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
135 # ********************************************************
140 vIMS_test = data['details']['sig_test']['result']
142 for data_test in vIMS_test:
146 if data_test['result'] == "Passed":
148 elif data_test['result'] == "Failed":
151 nbTests += nbTestsOK + nbTestsKO
152 nbFailures += nbTestsKO
154 test_data.append({'name': "Total number of tests run/failure tests",
155 'info': {"type": "bar"},
156 'data_set': [{'Run': nbTests,
157 'Failed': nbFailures}]})
162 def format_Tempest_for_dashboard(results):
164 Post processing for the Tempest test case
166 test_data = [{'description': 'Tempest results for Dashboard'}]
168 # Graph 1: Test_Duration = f(time)
169 # ********************************
172 new_element.append({'x': data['creation_date'],
173 'y': data['details']['duration']})
175 test_data.append({'name': "Tempest duration",
176 'info': {'type': "graph",
178 'ylabel': 'duration (s)'},
179 'data_set': new_element})
181 # Graph 2: (Nb test, nb failure)=f(time)
182 # ***************************************
185 new_element.append({'x': data['creation_date'],
186 'y1': data['details']['tests'],
187 'y2': data['details']['failures']})
189 test_data.append({'name': "Tempest nb tests/nb failures",
190 'info': {'type': "graph",
192 'y1label': 'Number of tests',
193 'y2label': 'Number of failures'},
194 'data_set': new_element})
196 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
197 # ********************************************************
202 nbTests += data['details']['tests']
203 nbFailures += data['details']['failures']
205 test_data.append({'name': "Total number of tests run/failure tests",
206 'info': {"type": "bar"},
207 'data_set': [{'Run': nbTests,
208 'Failed': nbFailures}]})
213 def format_odl_for_dashboard(results):
215 Post processing for the odl test case
217 test_data = [{'description': 'odl results for Dashboard'}]
221 def format_Rally_for_dashboard(results):
223 Post processing for the Rally test case
225 test_data = [{'description': 'Rally results for Dashboard'}]
229 def format_vPing_for_dashboard(results):
231 Post processing for the vPing test case
233 test_data = [{'description': 'vPing results for Dashboard'}]
235 # Graph 1: Test_Duration = f(time)
236 # ********************************
239 new_element.append({'x': data['creation_date'],
240 'y': data['details']['duration']})
242 test_data.append({'name': "vPing duration",
243 'info': {'type': "graph",
245 'ylabel': 'duration (s)'},
246 'data_set': new_element})
255 if data['details']['status'] == "OK":
258 test_data.append({'name': "vPing status",
259 'info': {"type": "bar"},
260 'data_set': [{'Nb tests': nbTest,
261 'Nb Success': nbTestOk}]})
265 def format_vPing_userdata_for_dashboard(results):
267 Post processing for the vPing_userdata test case
269 test_data = [{'description': 'vPing_userdata results for Dashboard'}]
271 # Graph 1: Test_Duration = f(time)
272 # ********************************
275 new_element.append({'x': data['creation_date'],
276 'y': data['details']['duration']})
278 test_data.append({'name': "vPing_userdata duration",
279 'info': {'type': "graph",
281 'ylabel': 'duration (s)'},
282 'data_set': new_element})
291 if data['details']['status'] == "OK":
294 test_data.append({'name': "vPing_userdata status",
295 'info': {"type": "bar"},
296 'data_set': [{'Nb tests': nbTest,
297 'Nb Success': nbTestOk}]})