3 ##############################################################################
4 # Copyright (c) 2015 Huawei Technologies Co.,Ltd and other.
6 # All rights reserved. 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
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # This script is used to build dashboard ready json results
13 # It may be used for all the test case of the Bottlenecks project
14 # a new method format_<Test_case>_for_dashboard(results)
15 # v0.1: basic example with methods for Rubbos.
19 def get_bottlenecks_cases():
21 get the list of the supported test cases
22 TODO: update the list when adding a new test case for the dashboard
27 def check_bottlenecks_case_exist(case):
29 check if the testcase exists
30 if the test case is not defined or not declared in the list
33 bottlenecks_cases = get_bottlenecks_cases()
35 if case is None or case not in bottlenecks_cases:
41 def format_bottlenecks_for_dashboard(case, results):
43 generic method calling the method corresponding to the test case
44 check that the testcase is properly declared first
45 then build the call to the specific method
47 if check_bottlenecks_case_exist(case):
48 cmd = "format_" + case + "_for_dashboard(results)"
52 print "Test cases not declared"
56 def format_rubbos_for_dashboard(results):
59 Post processing for the Rubbos test case
61 test_data = [{'description': 'Rubbos results'}]
64 # ********************************
66 for each_result in results:
67 throughput_data = [record['throughput'] for record in each_result['details']]
68 new_element.append({'x': each_result['creation_date'],
69 'y': max(throughput_data)})
71 test_data.append({'name': "Rubbos max throughput",
72 'info': {'type': "graph",
74 'ylabel': 'maximal throughput'},
75 'data_set': new_element})
84 print('Post processing for the Rubbos test case begin<--')
85 results = '[{"details":[{"client":200,"throughput":20},{"client":300,"throughput":50}],"project_name":' \
86 '"bottlenecks","pod_name":"unknown-pod","version":"unknown","installer":"fuel","description":' \
87 '"bottlenecks test cases result","_id":"56793f11514bc5068a345da4","creation_date":' \
88 '"2015-12-22 12:16:17.131438","case_name":"rubbos"},{"details":[{"client":200,"throughput":25},' \
89 '{"client":300,"throughput":52}],"project_name":"bottlenecks","pod_name":"unknown-pod","version":' \
90 '"unknown","installer":"fuel","description":"bottlenecks test cases result","_id":' \
91 '"56793f11514bc5068a345da4","creation_date":"2015-12-23 12:16:17.131438","case_name":"rubbos"}]'
93 print("the output is:")
94 print(format_rubbos_for_dashboard(json.loads(results)))
95 print('Post processing for the Rubbos test case end<--')
98 if __name__ == '__main__':