/[eiffelstudio]/branches/eth/eve/Src/framework/auto_test/proxy/aut_online_statistics.e
ViewVC logotype

Contents of /branches/eth/eve/Src/framework/auto_test/proxy/aut_online_statistics.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86350 - (show annotations)
Thu Apr 28 11:47:15 2011 UTC (8 years, 5 months ago) by jasonw
File size: 9567 byte(s)
1. Added a walkaround in queryable query executor to break infinite loop (possible due to long query termination).
2. Ehanced AutoTest online statistics to include details of the faults that have been detected so far.

1 ´╗┐note
2 description: "Class to collect online test data"
3 author: ""
4 date: "$Date$"
5 revision: "$Revision$"
6
7 class
8 AUT_ONLINE_STATISTICS
9
10 inherit
11 SHARED_WORKBENCH
12
13 create
14 make
15
16 feature{NONE} -- Initialization
17
18 make
19 -- Initialize Current.
20 do
21 create passing_statistics.make (100)
22 passing_statistics.set_key_equality_tester (create {AUT_FEATURE_OF_TYPE_EQUALITY_TESTER}.make)
23 create failing_statistics.make (100)
24 failing_statistics.set_key_equality_tester (create {AUT_FEATURE_OF_TYPE_EQUALITY_TESTER}.make)
25 create faults.make (64)
26 faults.set_key_equality_tester (create {AUT_EXCEPTION_EQUALITY_TESTER})
27 create faults_with_detected_time.make (64)
28 faults_with_detected_time.set_key_equality_tester (create {AUT_EXCEPTION_EQUALITY_TESTER})
29 end
30
31 feature -- Access
32
33 passing_statistics: DS_HASH_TABLE [INTEGER, AUT_FEATURE_OF_TYPE]
34 -- Statistic for passing test cases
35 -- Key is the feature under test, value is the number
36 -- of passing test cases of that feature
37
38 failing_statistics: DS_HASH_TABLE [INTEGER, AUT_FEATURE_OF_TYPE]
39 -- Statistic for failing test cases
40 -- Key is the feature under test, value is the number
41 -- of failing test cases of that feature
42
43 faults: DS_HASH_TABLE [detachable STRING, AUT_EXCEPTION]
44 -- Set of found faults
45 -- Keys are faults that are found, values are
46 -- meta data (if any) associated with that fault.
47
48 faults_with_detected_time: DS_HASH_TABLE [INTEGER, AUT_EXCEPTION]
49 -- Set of detected faults and the number of times that they are detected
50 -- Keys are the detected faults, and values are the number of times that
51 -- they are detected.
52
53 last_fault_meta: detachable STRING
54 -- Meta data which will be associated with each found fault
55
56 log_file_path: STRING
57 -- Full path to the log file
58
59 output_frequency: INTEGER
60 -- The number of seconds for the statistics to be outputed once
61 -- If 0, no statistics is outputed.
62
63 feature -- Setting
64
65 set_last_fault_meta (a_meta: like last_fault_meta)
66 -- Set `last_fault_meta' with `a_meta'.
67 do
68 if a_meta = Void then
69 last_fault_meta := Void
70 else
71 last_fault_meta := a_meta.twin
72 end
73 end
74
75 set_log_file_path (a_path: STRING)
76 -- Set `log_file_path' with `a_path'.
77 do
78 log_file_path := a_path.twin
79 ensure
80 log_file_path_set: log_file_path ~ a_path
81 end
82
83 set_output_frequency (i: INTEGER)
84 -- Set `output_frequency' with `i'.
85 do
86 output_frequency := i
87 ensure
88 output_frequency_set: output_frequency = i
89 end
90
91 feature -- Basic operations
92
93 report_session_restart (a_time_until_now: INTEGER)
94 -- Report that a new testing proxy session has started.
95 -- `a_time_until_now' is the number of milliseconds since the start of current testing session.
96 do
97 last_minute_statistics.set_session_restart_count (last_minute_statistics.session_restart_count + 1)
98 end
99
100 report_test_case (a_request: AUT_REQUEST; a_time_until_now: INTEGER; a_object_count: INTEGER)
101 -- Add test case `a_request' into Current.
102 -- `a_time_until_now' is the number of milliseconds since the start of current testing session.
103 -- `a_object_count' is the number of objects in object pool.
104 local
105 l_feature: AUT_FEATURE_OF_TYPE
106 l_exception: AUT_EXCEPTION
107 l_type: TYPE_A
108 l_feat: FEATURE_I
109 l_class: CLASS_C
110 do
111 if attached {AUT_CALL_BASED_REQUEST} a_request as l_request then
112 create l_feature.make (l_request.feature_to_call, l_request.target_type)
113 if l_request.response.is_normal then
114 if l_request.response.is_exception then
115 if
116 attached {AUT_NORMAL_RESPONSE} l_request.response as l_normal_response and then
117 l_normal_response.exception /= Void
118 then
119 if l_normal_response.exception.is_test_invalid then
120 last_minute_statistics.set_invalid_test_case_count (last_minute_statistics.invalid_test_case_count + 1)
121 else
122 l_exception := l_normal_response.exception
123 if not l_exception.is_invariant_violation_on_feature_entry then
124 l_class := workbench.universe.classes_with_name (l_exception.class_name).first.compiled_representation
125 l_feat := l_class.feature_named_32 (l_exception.recipient_name)
126 if l_feat /= Void then
127 if faults.has (l_exception) then
128 -- We already detected this fault before.
129 faults_with_detected_time.force_last (faults_with_detected_time.item (l_exception) + 1, l_exception)
130 else
131 -- We detected a new fault.
132 faults.force_last (last_fault_meta, l_exception)
133 last_minute_statistics.set_fault_count (last_minute_statistics.fault_count + 1)
134 faults_with_detected_time.force_last (1, l_exception)
135 end
136 create l_feature.make (l_feat, l_class.constraint_actual_type)
137 failing_statistics.search (l_feature)
138 if failing_statistics.found then
139 failing_statistics.replace (failing_statistics.found_item + 1, l_feature)
140 else
141 failing_statistics.force_last (1, l_feature)
142 end
143 end
144 last_minute_statistics.set_failing_test_case_count (last_minute_statistics.failing_test_case_count + 1)
145 else
146 last_minute_statistics.set_invalid_test_case_count (last_minute_statistics.invalid_test_case_count + 1)
147 end
148 end
149 end
150 else
151 passing_statistics.search (l_feature)
152 if passing_statistics.found then
153 passing_statistics.replace (passing_statistics.found_item + 1, l_feature)
154 else
155 passing_statistics.force_last (1, l_feature)
156 end
157 last_minute_statistics.set_passing_test_case_count (last_minute_statistics.passing_test_case_count + 1)
158 end
159 end
160 end
161 last_minute_statistics.set_object_count (a_object_count)
162
163 -- Store statistics on file every minute.
164 if output_frequency > 0 then
165 if a_time_until_now - last_time_stamp > 1000 * output_frequency then
166 save_last_minute_statistics
167 set_last_time_stamp (a_time_until_now)
168 end
169 end
170 end
171
172 finish
173 -- Finish testing session, close opened file.
174 do
175 if log_file /= Void and then log_file.is_open_write then
176 log_file.close
177 end
178 end
179
180 feature{NONE} -- Implementation
181
182 log_file: PLAIN_TEXT_FILE
183 -- File to store loges
184
185 last_time_stamp: INTEGER
186 -- Last recorded time (in milliseconds)
187
188 set_last_time_stamp (a_stamp: INTEGER)
189 -- Set `last_time_stamp' with `a_stamp'.
190 do
191 last_time_stamp := a_stamp
192 ensure
193 last_time_stamp_set: last_time_stamp = a_stamp
194 end
195
196 last_minute_statistics: AUT_ONLINE_STATISTICS_DATA
197 -- Statistics of the last minute
198 do
199 if last_minute_statistics_internal = Void then
200 create last_minute_statistics_internal.make (0, 0, 0, 0, 0, 0)
201 end
202 Result := last_minute_statistics_internal
203 end
204
205 last_minute_statistics_internal: like last_minute_statistics
206 -- Cache for `last_minute_statistics'
207
208 save_last_minute_statistics
209 -- Save `last_minute_statistics' into log file.
210 local
211 l_message: STRING
212 do
213 if log_file = Void and then log_file_path /= Void then
214 create log_file.make_create_read_write (log_file_path)
215 log_file.put_string ("Second%TPassing test cases%TFailing test cases%TInvalid test cases%TObjects%TFaults%TProxy sessions%TFault details%N")
216 end
217 if log_file /= Void then
218 create l_message.make (1024)
219 l_message.append_integer (last_time_stamp // 1000 + 1)
220 l_message.append_character ('%T')
221 l_message.append (last_minute_statistics.out)
222
223 l_message.append_character ('%T')
224 l_message.append (fault_details)
225 l_message.append_character ('%N')
226 log_file.put_string (l_message)
227 log_file.flush
228 end
229 end
230
231 fault_details: STRING
232 -- String containing details of detected faults.
233 local
234 l_cursor: DS_HASH_TABLE_CURSOR [INTEGER, AUT_EXCEPTION]
235 do
236 create Result.make (faults_with_detected_time.count * 64)
237 from
238 l_cursor := faults_with_detected_time.new_cursor
239 l_cursor.start
240 until
241 l_cursor.after
242 loop
243 if not Result.is_empty then
244 Result.append_character (',')
245 end
246 Result.append (l_cursor.key.signature)
247 Result.append_character ('(')
248 Result.append_integer (l_cursor.item)
249 Result.append_character (')')
250 l_cursor.forth
251 end
252 end
253
254 note
255 copyright: "Copyright (c) 1984-2011, Eiffel Software"
256 license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
257 licensing_options: "http://www.eiffel.com/licensing"
258 copying: "[
259 This file is part of Eiffel Software's Eiffel Development Environment.
260
261 Eiffel Software's Eiffel Development Environment is free
262 software; you can redistribute it and/or modify it under
263 the terms of the GNU General Public License as published
264 by the Free Software Foundation, version 2 of the License
265 (available at the URL listed under "license" above).
266
267 Eiffel Software's Eiffel Development Environment is
268 distributed in the hope that it will be useful, but
269 WITHOUT ANY WARRANTY; without even the implied warranty
270 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
271 See the GNU General Public License for more details.
272
273 You should have received a copy of the GNU General Public
274 License along with Eiffel Software's Eiffel Development
275 Environment; if not, write to the Free Software Foundation,
276 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
277 ]"
278 source: "[
279 Eiffel Software
280 5949 Hollister Ave., Goleta, CA 93117 USA
281 Telephone 805-685-1006, Fax 805-685-6869
282 Website http://www.eiffel.com
283 Customer support http://support.eiffel.com
284 ]"
285 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date ID Revision

  ViewVC Help
Powered by ViewVC 1.1.23