4 def _convert_value(value):
5 return value if value != '' else 0
8 def _convert_duration(duration):
9 if (isinstance(duration, str) or isinstance(duration, unicode)) and ':' in duration:
10 hours, minutes, seconds = duration.split(":")
11 hours = _convert_value(hours)
12 minutes = _convert_value(minutes)
13 seconds = _convert_value(seconds)
14 int_duration = 3600 * int(hours) + 60 * int(minutes) + float(seconds)
16 int_duration = duration
20 def format_normal(testcase):
22 Look for these and leave any of those:
27 If none are present, then return False
30 testcase_details = testcase['details']
31 fields = ['duration', 'tests', 'failures']
32 if isinstance(testcase_details, dict):
33 for key, value in testcase_details.items():
37 testcase_details[key] = _convert_duration(value)
39 del testcase_details[key]
41 if 'tests' in testcase_details and 'failures' in testcase_details:
42 testcase_tests = float(testcase_details['tests'])
43 testcase_failures = float(testcase_details['failures'])
44 if testcase_tests != 0:
45 testcase_details['success_percentage'] = 100 * (testcase_tests - testcase_failures) / testcase_tests
47 testcase_details['success_percentage'] = 0
53 def format_rally(testcase):
56 details.[{summary.duration}]
57 details.[{summary.nb success}]
58 details.[{summary.nb tests}]
60 Find data for these fields
63 -> details.success_percentage
65 details = testcase['details']
69 summary = item['summary']
74 testcase['details'] = {
75 'duration': summary['duration'],
76 'tests': summary['nb tests'],
77 'success_percentage': summary['nb success']
82 def _get_statistics(orig_data, stat_fields, stat_values=None):
84 for stat_data in orig_data:
85 for field in stat_fields:
86 stat_value = stat_data[field]
87 if stat_value in test_results:
88 test_results[stat_value] += 1
90 test_results[stat_value] = 1
92 if stat_values is not None:
93 for stat_value in stat_values:
94 if stat_value not in test_results:
95 test_results[stat_value] = 0
100 def format_onos(testcase):
103 details.FUNCvirNet.duration
104 details.FUNCvirNet.status.[{Case result}]
105 details.FUNCvirNetL3.duration
106 details.FUNCvirNetL3.status.[{Case result}]
108 Find data for these fields
109 -> details.FUNCvirNet.duration
110 -> details.FUNCvirNet.tests
111 -> details.FUNCvirNet.failures
112 -> details.FUNCvirNetL3.duration
113 -> details.FUNCvirNetL3.tests
114 -> details.FUNCvirNetL3.failures
116 testcase_details = testcase['details']
118 if 'FUNCvirNet' not in testcase_details or 'FUNCvirNetL3' not in testcase_details:
121 funcvirnet_details = testcase_details['FUNCvirNet']['status']
122 funcvirnet_stats = _get_statistics(funcvirnet_details, ('Case result',), ('PASS', 'FAIL'))
123 funcvirnet_passed = funcvirnet_stats['PASS']
124 funcvirnet_failed = funcvirnet_stats['FAIL']
125 funcvirnet_all = funcvirnet_passed + funcvirnet_failed
127 funcvirnetl3_details = testcase_details['FUNCvirNetL3']['status']
128 funcvirnetl3_stats = _get_statistics(funcvirnetl3_details, ('Case result',), ('PASS', 'FAIL'))
129 funcvirnetl3_passed = funcvirnetl3_stats['PASS']
130 funcvirnetl3_failed = funcvirnetl3_stats['FAIL']
131 funcvirnetl3_all = funcvirnetl3_passed + funcvirnetl3_failed
133 testcase_details['FUNCvirNet'] = {
134 'duration': _convert_duration(testcase_details['FUNCvirNet']['duration']),
135 'tests': funcvirnet_all,
136 'failures': funcvirnet_failed
138 testcase_details['FUNCvirNetL3'] = {
139 'duration': _convert_duration(testcase_details['FUNCvirNetL3']['duration']),
140 'tests': funcvirnetl3_all,
141 'failures': funcvirnetl3_failed
146 def format_vims(testcase):
149 details.sig_test.result.[{result}]
150 details.sig_test.duration
151 details.vIMS.duration
152 details.orchestrator.duration
154 Find data for these fields
155 -> details.sig_test.duration
156 -> details.sig_test.tests
157 -> details.sig_test.failures
158 -> details.sig_test.passed
159 -> details.sig_test.skipped
160 -> details.vIMS.duration
161 -> details.orchestrator.duration
163 testcase_details = testcase['details']
164 test_results = _get_statistics(testcase_details['sig_test']['result'],
166 ('Passed', 'Skipped', 'Failed'))
167 passed = test_results['Passed']
168 skipped = test_results['Skipped']
169 failures = test_results['Failed']
170 all_tests = passed + skipped + failures
171 testcase['details'] = {
173 'duration': testcase_details['sig_test']['duration'],
175 'failures': failures,
180 'duration': testcase_details['vIMS']['duration']
183 'duration': testcase_details['orchestrator']['duration']