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 Promise 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_promise_cases():
23 get the list of the supported test cases
24 TODO: update the list when adding a new test case for the dashboard
29 def format_promise_for_dashboard(case, results):
31 generic method calling the method corresponding to the test case
32 check that the testcase is properly declared first
33 then build the call to the specific method
35 if check_promise_case_exist(case):
36 # note we add _case because testcase and project had the same name
37 # TODO refactoring...looks fine at the beginning wit only 1 project
38 # not very ugly now and clearly not optimized...
39 cmd = "format_" + case + "_case_for_dashboard(results)"
43 print "Test cases not declared"
47 def check_promise_case_exist(case):
49 check if the testcase exists
50 if the test case is not defined or not declared in the list
53 promise_cases = get_promise_cases()
55 if (case is None or case not in promise_cases):
64 def format_promise_case_for_dashboard(results):
66 Post processing for the promise test case
68 test_data = [{'description': 'Promise results for Dashboard'}]
69 # Graph 1: (duration)=f(time)
70 # ***************************************
73 # default duration 0:00:08.999904
74 # consider only seconds => 09
76 t = data['details']['duration']
77 new_element.append({'x': data['creation_date'],
80 test_data.append({'name': "Promise duration ",
81 'info': {'type': "graph",
83 'ylabel': 'duration (s)'},
84 'data_set': new_element})
86 # Graph 2: (Nb test, nb failure)=f(time)
87 # ***************************************
91 promise_results = data['details']
92 new_element.append({'x': data['creation_date'],
93 'y1': promise_results['tests'],
94 'y2': promise_results['failures']})
96 test_data.append({'name': "Promise nb tests/nb failures",
97 'info': {'type': "graph",
99 'y1label': 'Number of tests',
100 'y2label': 'Number of failures'},
101 'data_set': new_element})