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
19 def get_functest_cases():
21 get the list of the supported test cases
22 TODO: update the list when adding a new test case for the dashboard
24 return ["vPing", "Tempest", "odl", "Rally"]
27 def format_functest_for_dashboard(case, results):
29 generic method calling the method corresponding to the test case
30 check that the testcase is properly declared first
31 then build the call to the specific method
33 if check_functest_case_exist(case):
34 cmd = "format_" + case + "_for_dashboard(results)"
38 print "Test cases not declared"
42 def check_functest_case_exist(case):
44 check if the testcase exists
45 if the test case is not defined or not declared in the list
48 functest_cases = get_functest_cases()
50 if (case is None or case not in functest_cases):
56 def format_Tempest_for_dashboard(results):
58 Post processing for the Tempest test case
60 test_data = [{'description': 'Tempest results for Dashboard'}]
62 # Graph 1: Test_Duration = f(time)
63 # ********************************
66 new_element.append({'x': data['creation_date'],
67 'y': data['details']['duration']})
69 test_data.append({'name': "Tempest duration",
70 'info': {'type': "graph",
72 'ylabel': 'duration (s)'},
73 'data_set': new_element})
75 # Graph 2: (Nb test, nb failure)=f(time)
76 # ***************************************
79 new_element.append({'x': data['creation_date'],
80 'y1': data['details']['tests'],
81 'y2': data['details']['failures']})
83 test_data.append({'name': "Tempest nb tests/nb failures",
84 'info': {'type': "graph",
86 'y1label': 'Number of tests',
87 'y2label': 'Number of failures'},
88 'data_set': new_element})
90 # Graph 3: bar graph Summ(nb tests run), Sum (nb tests failed)
91 # ********************************************************
96 nbTests += data['details']['tests']
97 nbFailures += data['details']['failures']
99 test_data.append({'name': "Total number of tests run/failure tests",
100 'info': {"type": "bar"},
101 'data_set': [{'Run': nbTests,
102 'Failed': nbFailures}]})
107 def format_odl_for_dashboard(results):
109 Post processing for the odl test case
111 test_data = [{'description': 'odl results for Dashboard'}]
115 def format_Rally_for_dashboard(results):
117 Post processing for the Rally test case
119 test_data = [{'description': 'Rally results for Dashboard'}]
123 def format_vPing_for_dashboard(results):
125 Post processing for the vPing test case
127 test_data = [{'description': 'vPing results for Dashboard'}]
129 # Graph 1: Test_Duration = f(time)
130 # ********************************
133 new_element.append({'x': data['creation_date'],
134 'y': data['details']['duration']})
136 test_data.append({'name': "vPing duration",
137 'info': {'type': "graph",
139 'ylabel': 'duration (s)'},
140 'data_set': new_element})
149 if data['details']['status'] == "OK":
152 test_data.append({'name': "vPing status",
153 'info': {"type": "bar"},
154 'data_set': [{'Nb tests': nbTest,
155 'Nb Success': nbTestOk}]})