brontes3d-production_log_analyzer 2009022403

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. data/History.txt +34 -0
  2. data/LICENSE.txt +27 -0
  3. data/Manifest.txt +18 -0
  4. data/README.txt +147 -0
  5. data/Rakefile +17 -0
  6. data/bin/action_errors +46 -0
  7. data/bin/action_grep +19 -0
  8. data/bin/pl_analyze +36 -0
  9. data/lib/passenger_log_per_proc.rb +55 -0
  10. data/lib/production_log/action_grep.rb +41 -0
  11. data/lib/production_log/analyzer.rb +416 -0
  12. data/lib/production_log/parser.rb +228 -0
  13. data/test/test_action_grep.rb +72 -0
  14. data/test/test_analyzer.rb +425 -0
  15. data/test/test_helper.rb +68 -0
  16. data/test/test_parser.rb +420 -0
  17. data/test/test_passenger_log_per_proc.rb +88 -0
  18. data/test/test_syslogs/test.syslog.0.14.x.log +4 -0
  19. data/test/test_syslogs/test.syslog.1.2.shortname.log +4 -0
  20. data/test/test_syslogs/test.syslog.empty.log +0 -0
  21. data/test/test_syslogs/test.syslog.log +256 -0
  22. data/test/test_vanilla/test.0.14.x.log +4 -0
  23. data/test/test_vanilla/test.1.2.shortname.log +4 -0
  24. data/test/test_vanilla/test.empty.log +0 -0
  25. data/test/test_vanilla/test.log +255 -0
  26. data/test/test_vanilla/test_log_parts/1_online1-rails-59600.log +7 -0
  27. data/test/test_vanilla/test_log_parts/2_online2-rails-59628.log +11 -0
  28. data/test/test_vanilla/test_log_parts/3_online1-rails-59628.log +9 -0
  29. data/test/test_vanilla/test_log_parts/4_online1-rails-59645.log +30 -0
  30. data/test/test_vanilla/test_log_parts/5_online1-rails-59629.log +38 -0
  31. data/test/test_vanilla/test_log_parts/6_online1-rails-60654.log +32 -0
  32. data/test/test_vanilla/test_log_parts/7_online1-rails-59627.log +70 -0
  33. data/test/test_vanilla/test_log_parts/8_online1-rails-59635.log +58 -0
  34. metadata +113 -0
@@ -0,0 +1,68 @@
1
+ $TESTING = true
2
+
3
+ $:.unshift "#{File.dirname(__FILE__)}/../lib/"
4
+
5
+ require 'tempfile'
6
+ require 'stringio'
7
+ require 'test/unit'
8
+
9
+ require 'production_log/analyzer'
10
+ require 'production_log/parser'
11
+ require 'production_log/action_grep'
12
+
13
+ unless defined?(TestTwice)
14
+ class TestTwice < Test::Unit::TestCase
15
+
16
+ def test_true
17
+ assert true
18
+ end
19
+
20
+ def self.inherited(klass)
21
+ unless klass.name.index("SansSysLog")
22
+ @@now_defining = klass
23
+ @@duplicate = eval %Q{
24
+ class #{klass.name}SansSysLog < TestTwice
25
+ self
26
+ end
27
+ }
28
+ end
29
+ end
30
+
31
+ def self.twice_test(method_name, &block)
32
+ @@now_defining.send(:define_method, method_name, &block)
33
+ @@duplicate.send(:define_method, method_name.to_s + "_vanilla_style", &block)
34
+ end
35
+
36
+ def self.setup(&block)
37
+ @@now_defining.send(:define_method, :local_setup, &block)
38
+ @@duplicate.send(:define_method, :local_setup, &block)
39
+ end
40
+
41
+ def assert_mostly_equal(string1, string2, message = "")
42
+ a1 = string1.split("\n").sort
43
+ a2 = string2.split("\n").sort
44
+ assert_equal(a1, a2,
45
+ message.to_s + " -- difference: " + ((a1 + a2) - (a1 & a2)).inspect)
46
+ end
47
+
48
+ def test_sys_log_style?
49
+ @test_sys_log_style
50
+ end
51
+
52
+ def setup
53
+ if self.class.name.index("SansSysLog")
54
+ # LogParser.vanilla_mode!
55
+ @test_sys_log_style = false
56
+ else
57
+ # LogParser.syslog_mode!
58
+ @test_sys_log_style = true
59
+ end
60
+ local_setup
61
+ end
62
+
63
+ def local_setup
64
+ #do nothing, overriden whenever actual tests have a setup do block
65
+ end
66
+
67
+ end
68
+ end
@@ -0,0 +1,420 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ class TestLogEntry < TestTwice
4
+
5
+ setup do
6
+ @entry = LogParser::LogEntry.new <<-EOF
7
+ Processing TwinklerController#index (for 81.109.96.173 at Wed Dec 01 16:01:56 CST 2004)
8
+ Parameters: {\"action\"=>\"index\", \"controller\"=>\"twinkler\"}
9
+ Browser Load First (0.001114) SELECT * FROM browsers WHERE ubid = 'ixsXHgUo7U9PJGgBzr7e9ocaDOc=' LIMIT 1
10
+ Goal Count (0.001762) SELECT COUNT(*) FROM goals WHERE browser_id = '96181' and is_active = 1
11
+ Rendering twinkler/index within layouts/default
12
+ Rendering layouts/default (200 OK)
13
+ Completed in 0.616122 (1 reqs/sec) | Rendering: 0.242475 (39%) | DB: 0.002876 (0%)
14
+ EOF
15
+
16
+ @kong_entry = LogParser::LogEntry.new <<-EOF
17
+ Completed in 0.57672 (1 reqs/sec) | Rendering: 0.47752 (82%) | DB: 0.08223 (14%) | Rows: 75 | Queries: 32 | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: html | Response Size: 71604 | Processed: FeaturedGamesController#index | 200 OK [http://www.kongregatetrunk.com/]
18
+ EOF
19
+ end
20
+
21
+ twice_test :test_parse do
22
+ request = <<-EOF
23
+ Processing RssController#uber (for 67.18.200.5 at Mon Mar 07 00:00:25 CST 2005)
24
+ Parameters: {:id=>"author", :"rss/uber/author.html/uber/author"=>nil, :action=>"uber", :username=>"looch", :controller=>"rss"}
25
+ Cookie set: auth=dc%2FGUP20BwziF%2BApGecc0pXB0PF0obi55az63ubAFtsnOOdJPkhfJH2U09yuzQD3WtdmWnydLzFcRA78kwi7Gw%3D%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
26
+ Cookie set: ubid=kF05DqFH%2F9hRCOxTz%2Bfb8Q7UV%2FI%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
27
+ Browser Load (0.003963) SELECT * FROM browsers WHERE ubid = 'kF05DqFH/9hRCOxTz+fb8Q7UV/I=' LIMIT 1
28
+ Person Load (0.002445) SELECT * FROM people WHERE username = 'looch' AND active = '1' LIMIT 1
29
+ ProfileImage Load (0.001554) SELECT * FROM profile_images WHERE id = 2782 LIMIT 1
30
+ Rendering rss/rss2.0 (200 OK)
31
+ Completed in 0.034519 (28 reqs/sec) | Rendering: 0.011770 (34%) | DB: 0.007962 (23%)
32
+ EOF
33
+ request = request.split "\n"
34
+
35
+ entry = LogParser::LogEntry.new []
36
+
37
+ entry.parse request
38
+ assert_kind_of LogParser::LogEntry, entry
39
+ assert_equal "RssController#uber", entry.page
40
+ assert_equal 3, entry.queries.length
41
+ assert_equal ['Browser Load', 0.003963], entry.queries.first
42
+ assert_equal 0.034519, entry.request_time
43
+ end
44
+
45
+ twice_test :test_kong_style_page do
46
+ assert_equal "FeaturedGamesController#index.html", @kong_entry.page
47
+ end
48
+
49
+ twice_test :test_bad_kong_entry do
50
+ assert_nothing_raised do
51
+ bad = LogParser::LogEntry.new <<-EOF
52
+ Completed in 0.00904 (110 reqs/sec) | Rendering: 0.00572 (63%) | DB: 0.00093 (10%) | Rows: 2 | Queries: 2 | Guest | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: Accept: application/xhtml+xml | Response Size: 8637 | Processed: MyCardsController#show | 200 OK [http://www.kongregate.com/accounts/orc22/cards/688263]
53
+ EOF
54
+ end
55
+ end
56
+
57
+ twice_test :test_row_count do
58
+ assert_equal 75, @kong_entry.row_count
59
+ end
60
+
61
+ twice_test :test_query_count do
62
+ assert_equal 32, @kong_entry.query_count
63
+ end
64
+
65
+ twice_test :test_request_size do
66
+ assert_equal 0, @kong_entry.request_size
67
+ end
68
+
69
+ twice_test :test_response_size do
70
+ assert_equal 71604, @kong_entry.response_size
71
+ end
72
+
73
+ twice_test :test_page do
74
+ assert_equal "TwinklerController#index", @entry.page
75
+ end
76
+
77
+ twice_test :test_ip do
78
+ assert_equal "81.109.96.173", @entry.ip
79
+ end
80
+
81
+ twice_test :test_time do
82
+ assert_equal "Wed Dec 01 16:01:56 CST 2004", @entry.time
83
+ end
84
+
85
+ twice_test :test_queries do
86
+ expected = []
87
+ expected << ["Browser Load First", 0.001114]
88
+ expected << ["Goal Count", 0.001762]
89
+ assert_equal expected, @entry.queries
90
+ end
91
+
92
+ twice_test :test_request_time do
93
+ assert_equal 0.616122, @entry.request_time
94
+
95
+ @entry = LogParser::LogEntry.new "Processing TwinklerController#add_thing (for 144.164.232.114 at Wed Dec 01 16:01:56 CST 2004)
96
+ Completed in 0.261485 (3 reqs/sec) | DB: 0.009325 (3%)"
97
+
98
+ assert_equal 0.261485, @entry.request_time
99
+
100
+ @entry = LogParser::LogEntry.new "Completed in 13ms (View: 12, DB: 1) | 200 OK [http://www.example.com/]"
101
+ assert_equal 13/1000.0, @entry.request_time
102
+ end
103
+
104
+ twice_test :test_render_time do
105
+ assert_equal 0.242475, @entry.render_time
106
+
107
+ @entry = LogParser::LogEntry.new "Processing TwinklerController#add_thing (for 144.164.232.114 at Wed Dec 01 16:01:56 CST 2004)
108
+ Completed in 0.261485 (3 reqs/sec) | DB: 0.009325 (3%)"
109
+
110
+ assert_equal 0, @entry.render_time
111
+
112
+ @entry = LogParser::LogEntry.new 'Completed in 13ms (View: 12, DB: 1) | 200 OK [http://www.example.com/]'
113
+ assert_equal 12/1000.0, @entry.render_time
114
+ end
115
+
116
+ twice_test :test_db_time do
117
+ assert_equal 0.002876, @entry.db_time
118
+
119
+ @entry = LogParser::LogEntry.new 'Completed in 13ms (View: 12, DB: 1) | 200 OK [http://www.example.com/]'
120
+ assert_equal 1/1000.0, @entry.db_time
121
+ end
122
+
123
+ end
124
+
125
+ class TestLogParser < TestTwice
126
+
127
+ twice_test :test_class_parse_with_only_completed_at do
128
+ if test_sys_log_style?
129
+ log = StringIO.new <<-EOF
130
+ Jul 23 12:08:50 trunk rails[27221]: Completed in 0.00507 (197 reqs/sec) | Rendering: 0.00027 (5%) | DB: 0.00055 (10%) | Rows: 88 | Queries: 1 | Guest | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: all | Response Size: 3696 | Processed: RoomsController#list | 200 OK [http://kongregate.com/rooms/list]
131
+ Jul 23 12:09:18 trunk rails[27221]: Completed in 0.11838 (8 reqs/sec) | Rendering: 0.10371 (87%) | DB: 0.00671 (5%) | Rows: 103 | Queries: 20 | Guest | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: html | Response Size: 27254 | Processed: CategoriesController#show | 200 OK [http://kongregate.com/strategy-defense-games]
132
+ EOF
133
+ else
134
+ log = StringIO.new <<-EOF
135
+ Completed in 0.00507 (197 reqs/sec) | Rendering: 0.00027 (5%) | DB: 0.00055 (10%) | Rows: 88 | Queries: 1 | Guest | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: all | Response Size: 3696 | Processed: RoomsController#list | 200 OK [http://kongregate.com/rooms/list]
136
+ Completed in 0.11838 (8 reqs/sec) | Rendering: 0.10371 (87%) | DB: 0.00671 (5%) | Rows: 103 | Queries: 20 | Guest | Method: GET | Request Size: 0 | Request Type: unknown | Response Format: html | Response Size: 27254 | Processed: CategoriesController#show | 200 OK [http://kongregate.com/strategy-defense-games]
137
+ EOF
138
+ end
139
+
140
+ entries = []
141
+ LogParser.parse log do |entry|
142
+ entries << entry
143
+ end
144
+
145
+ assert_equal 2, entries.length
146
+ end
147
+
148
+ twice_test :test_class_parse do
149
+ if test_sys_log_style?
150
+ log = StringIO.new <<-EOF
151
+ Mar 7 00:00:25 online1 rails[59628]: Processing RssController#uber (for 67.18.200.5 at Mon Mar 07 00:00:25 CST 2005)
152
+ Mar 7 00:00:25 online1 rails[59628]: Parameters: {:id=>"author", :"rss/uber/author.html/uber/author"=>nil, :action=>"uber", :username=>"looch", :controller=>"rss"}
153
+ Mar 7 00:00:25 online1 rails[59628]: Cookie set: auth=dc%2FGUP20BwziF%2BApGecc0pXB0PF0obi55az63ubAFtsnOOdJPkhfJH2U09yuzQD3WtdmWnydLzFcRA78kwi7Gw%3D%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
154
+ Mar 7 00:00:25 online1 rails[59628]: Cookie set: ubid=kF05DqFH%2F9hRCOxTz%2Bfb8Q7UV%2FI%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
155
+ Mar 7 00:00:25 online1 rails[59628]: Browser Load (0.003963) SELECT * FROM browsers WHERE ubid = 'kF05DqFH/9hRCOxTz+fb8Q7UV/I=' LIMIT 1
156
+ Mar 7 00:00:25 online1 rails[59628]: Person Load (0.002445) SELECT * FROM people WHERE username = 'looch' AND active = '1' LIMIT 1
157
+ Mar 7 00:00:25 online1 rails[59628]: ProfileImage Load (0.001554) SELECT * FROM profile_images WHERE id = 2782 LIMIT 1
158
+ Mar 7 00:00:25 online1 rails[59628]: Rendering rss/rss2.0 (200 OK)
159
+ Mar 7 00:00:25 online1 rails[59628]: Completed in 0.034519 (28 reqs/sec) | Rendering: 0.011770 (34%) | DB: 0.007962 (23%)
160
+ EOF
161
+ else
162
+ log = StringIO.new <<-EOF
163
+ Processing RssController#uber (for 67.18.200.5 at Mon Mar 07 00:00:25 CST 2005)
164
+ Parameters: {:id=>"author", :"rss/uber/author.html/uber/author"=>nil, :action=>"uber", :username=>"looch", :controller=>"rss"}
165
+ Cookie set: auth=dc%2FGUP20BwziF%2BApGecc0pXB0PF0obi55az63ubAFtsnOOdJPkhfJH2U09yuzQD3WtdmWnydLzFcRA78kwi7Gw%3D%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
166
+ Cookie set: ubid=kF05DqFH%2F9hRCOxTz%2Bfb8Q7UV%2FI%3D; path=/; expires=Thu, 05 Mar 2015 06:00:25 GMT
167
+ Browser Load (0.003963) SELECT * FROM browsers WHERE ubid = 'kF05DqFH/9hRCOxTz+fb8Q7UV/I=' LIMIT 1
168
+ Person Load (0.002445) SELECT * FROM people WHERE username = 'looch' AND active = '1' LIMIT 1
169
+ ProfileImage Load (0.001554) SELECT * FROM profile_images WHERE id = 2782 LIMIT 1
170
+ Rendering rss/rss2.0 (200 OK)
171
+ Completed in 0.034519 (28 reqs/sec) | Rendering: 0.011770 (34%) | DB: 0.007962 (23%)
172
+ EOF
173
+ end
174
+
175
+ entries = []
176
+
177
+ LogParser.parse log do |entry|
178
+ entries << entry
179
+ end
180
+
181
+ assert_equal 1, entries.length
182
+ assert_equal 'RssController#uber', entries.first.page
183
+ end
184
+
185
+ twice_test :test_class_parse_components do
186
+ if test_sys_log_style?
187
+ log = StringIO.new <<-EOF
188
+ Jul 11 10:05:20 www rails[61243]: Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
189
+ Jul 11 10:05:20 www rails[61243]: Start rendering component ({:action=>"online_count", :controller=>"members"}):
190
+ Jul 11 10:05:20 www rails[34216]: Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
191
+ Jul 11 10:05:20 www rails[34216]: Start rendering component ({:action=>"online_count", :controller=>"members"}):
192
+ Jul 11 10:05:20 www rails[34216]: Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
193
+ Jul 11 10:05:20 www rails[34216]: Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
194
+ Jul 11 10:05:20 www rails[34216]: End of component rendering
195
+ Jul 11 10:05:28 www rails[34216]: Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
196
+ Jul 11 10:05:20 www rails[34216]: Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
197
+ Jul 11 10:05:20 www rails[34216]: Start rendering component ({:action=>"online_count", :controller=>"members"}):
198
+ Jul 11 10:05:20 www rails[34216]: Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
199
+ Jul 11 10:05:20 www rails[34216]: Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
200
+ Jul 11 10:05:20 www rails[34216]: End of component rendering
201
+ Jul 11 10:05:28 www rails[34216]: Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
202
+ Jul 11 10:05:20 www rails[61243]: Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
203
+ Jul 11 10:05:20 www rails[61243]: Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
204
+ Jul 11 10:05:20 www rails[61243]: End of component rendering
205
+ Jul 11 10:05:28 www rails[61243]: Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
206
+ EOF
207
+ else
208
+ log = StringIO.new <<-EOF
209
+ Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
210
+ Start rendering component ({:action=>"online_count", :controller=>"members"}):
211
+ Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
212
+ Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
213
+ End of component rendering
214
+ Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
215
+ Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
216
+ Start rendering component ({:action=>"online_count", :controller=>"members"}):
217
+ Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
218
+ Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
219
+ End of component rendering
220
+ Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
221
+ Processing ChatroomsController#launch (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
222
+ Start rendering component ({:action=>"online_count", :controller=>"members"}):
223
+ Processing MembersController#online_count (for 213.152.37.169 at Mon Jul 11 10:05:20 CDT 2005)
224
+ Completed in 0.00741 (135 reqs/sec) | DB: 0.00320 (43%)
225
+ End of component rendering
226
+ Completed in 8.65005 (0 reqs/sec) | Rendering: 8.64820 (99%) | DB: 0.00000 (0%)
227
+ EOF
228
+ end
229
+
230
+ entries = []
231
+ LogParser.parse(log) { |entry| entries << entry }
232
+
233
+ assert_equal 3, entries.length
234
+ assert_equal 'ChatroomsController#launch', entries.first.page
235
+ assert_equal 8.65005, entries.first.request_time
236
+ end
237
+
238
+ twice_test :test_class_parse_entries_with_pre_processing_garbage do
239
+ if test_sys_log_style?
240
+ log = StringIO.new <<-EOF
241
+ Jan 03 12:51:34 duo2 rails[4347]: Font Load (0.000475) SELECT * FROM fonts ORDER BY name 
242
+ Jan 03 12:51:34 duo2 rails[4347]: Processing StylesheetsController#show (for 127.0.0.1 at 2007-01-03 12:51:34) [GET]
243
+ Jan 03 12:51:34 duo2 rails[4347]: Parameters: {"action"=>"show", "id"=>"1", "controller"=>"stylesheets"}
244
+ Jan 03 12:51:34 duo2 rails[4347]: Newspaper Load (0.000970) SELECT newspapers.* FROM newspapers INNER JOIN users ON newspapers.editor_in_chief = users.id WHERE (users.login = 'geoff') LIMIT 1
245
+ Jan 03 12:51:34 duo2 rails[4347]: Layout Load (0.000501) SELECT * FROM layouts WHERE (layouts.id = 1) LIMIT 1
246
+ Jan 03 12:51:34 duo2 rails[4347]: Completed in 0.00807 (123 reqs/sec) | Rendering: 0.00006 (0%) | DB: 0.00195 (24%) | 200 OK [http://geoff.localhost.com/stylesheets/show/1/styles.css]
247
+ EOF
248
+ else
249
+ log = StringIO.new <<-EOF
250
+ Font Load (0.000475) SELECT * FROM fonts ORDER BY name 
251
+ Processing StylesheetsController#show (for 127.0.0.1 at 2007-01-03 12:51:34) [GET]
252
+ Parameters: {"action"=>"show", "id"=>"1", "controller"=>"stylesheets"}
253
+ Newspaper Load (0.000970) SELECT newspapers.* FROM newspapers INNER JOIN users ON newspapers.editor_in_chief = users.id WHERE (users.login = 'geoff') LIMIT 1
254
+ Layout Load (0.000501) SELECT * FROM layouts WHERE (layouts.id = 1) LIMIT 1
255
+ Completed in 0.00807 (123 reqs/sec) | Rendering: 0.00006 (0%) | DB: 0.00195 (24%) | 200 OK [http://geoff.localhost.com/stylesheets/show/1/styles.css]
256
+ EOF
257
+ end
258
+ entries = []
259
+ LogParser.parse(log) { |entry| entries << entry }
260
+
261
+ assert_equal 1, entries.length, "Number of entries was incorrect"
262
+ assert_equal 'StylesheetsController#show', entries.first.page
263
+ assert_equal 0.00807, entries.first.request_time
264
+ end
265
+
266
+ twice_test :test_class_parse_rails_engines_plugin do
267
+ if test_sys_log_style?
268
+ log = StringIO.new <<-EOF
269
+ Jan 03 12:24:21 duo2 rails[4277]: Trying to start engine 'login_engine' from '/Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine'
270
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/lib/login_engine to the load path
271
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views/user_notify to the load path
272
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views/user to the load path
273
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views to the load path
274
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/models to the load path
275
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/helpers to the load path
276
+ Jan 03 12:24:21 duo2 rails[4277]: adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/controllers to the load path
277
+ Jan 03 12:24:21 duo2 rails[4277]: Attempting to copy public engine files from '/Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/public'
278
+ Jan 03 12:24:21 duo2 rails[4277]: source dirs: ["/Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/public/stylesheets"]
279
+ Jan 03 12:24:22 duo2 rails[4277]: finally loading from application: 'exception_notifier.rb'
280
+ Jan 03 12:24:22 duo2 rails[4277]: requiring file 'exception_notifier_helper'
281
+ Jan 03 12:24:22 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/exception_notifier_helper.rb
282
+ Jan 03 12:24:22 duo2 rails[4277]: finally loading from application: 'exception_notifier_helper.rb'
283
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/application.rb'
284
+ Jan 03 12:24:23 duo2 rails[4277]: requiring file 'application_helper'
285
+ Jan 03 12:24:23 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/application_helper.rb
286
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'application_helper.rb'
287
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'exception_notifiable.rb'
288
+ Jan 03 12:24:23 duo2 rails[4277]: requiring file 'user_helper'
289
+ Jan 03 12:24:23 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/user_helper.rb
290
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'user_helper.rb'
291
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'user.rb'
292
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'task.rb'
293
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'client.rb'
294
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'email.rb'
295
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'worth.rb'
296
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'column_pref.rb'
297
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'timer.rb'
298
+ Jan 03 12:24:23 duo2 rails[4277]: requiring file '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/tasks_controller.rb'
299
+ Jan 03 12:24:23 duo2 rails[4277]: detected RAILS_ROOT, rewriting to 'app/controllers/tasks_controller.rb'
300
+ Jan 03 12:24:23 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/app/controllers/tasks_controller.rb
301
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/tasks_controller.rb'
302
+ Jan 03 12:24:23 duo2 rails[4277]: requiring file 'tasks_helper'
303
+ Jan 03 12:24:23 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/tasks_helper.rb
304
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'tasks_helper.rb'
305
+ Jan 03 12:24:23 duo2 rails[4277]: requiring file 'sparklines_helper'
306
+ Jan 03 12:24:23 duo2 rails[4277]: checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/sparklines_helper.rb
307
+ Jan 03 12:24:23 duo2 rails[4277]: finally loading from application: 'sparklines_helper.rb'
308
+ Jan 03 12:24:24 duo2 rails[4277]: SQL (0.000072) BEGIN
309
+ Jan 03 12:24:24 duo2 rails[4277]: SQL (0.000240) INSERT INTO sessions (`updated_at`, `session_id`, `data`) VALUES('2007-01-03 20:24:24', 'bdbb75323d5da69f707d5576e907706e', 'BAh7AA==\n')
310
+ Jan 03 12:24:24 duo2 rails[4277]: SQL (0.000400) COMMIT
311
+ Jan 03 12:24:24 duo2 rails[4277]: Processing TasksController#index (for 127.0.0.1 at 2007-01-03 12:24:24) [GET]
312
+ Jan 03 12:24:24 duo2 rails[4277]: Parameters: {"action"=>"index", "controller"=>"tasks"}
313
+ Jan 03 12:24:24 duo2 rails[4277]: Redirected to http://localhost:3000/tasks/list
314
+ Jan 03 12:24:24 duo2 rails[4277]: Completed in 0.00112 (896 reqs/sec) | DB: 0.00071 (63%) | 302 Found [http://localhost/]
315
+ EOF
316
+ else
317
+ log = StringIO.new <<-EOF
318
+ Trying to start engine 'login_engine' from '/Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine'
319
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/lib/login_engine to the load path
320
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views/user_notify to the load path
321
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views/user to the load path
322
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/views to the load path
323
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/models to the load path
324
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/helpers to the load path
325
+ adding /Users/topfunky/web/rails/repos/roughunderbelly/vendor/plugins/login_engine/app/controllers to the load path
326
+ Attempting to copy public engine files from '/Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/public'
327
+ source dirs: ["/Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/public/stylesheets"]
328
+ finally loading from application: 'exception_notifier.rb'
329
+ requiring file 'exception_notifier_helper'
330
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/exception_notifier_helper.rb
331
+ finally loading from application: 'exception_notifier_helper.rb'
332
+ finally loading from application: '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/application.rb'
333
+ requiring file 'application_helper'
334
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/application_helper.rb
335
+ finally loading from application: 'application_helper.rb'
336
+ finally loading from application: 'exception_notifiable.rb'
337
+ requiring file 'user_helper'
338
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/user_helper.rb
339
+ finally loading from application: 'user_helper.rb'
340
+ finally loading from application: 'user.rb'
341
+ finally loading from application: 'task.rb'
342
+ finally loading from application: 'client.rb'
343
+ finally loading from application: 'email.rb'
344
+ finally loading from application: 'worth.rb'
345
+ finally loading from application: 'column_pref.rb'
346
+ finally loading from application: 'timer.rb'
347
+ requiring file '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/tasks_controller.rb'
348
+ detected RAILS_ROOT, rewriting to 'app/controllers/tasks_controller.rb'
349
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/app/controllers/tasks_controller.rb
350
+ finally loading from application: '/Users/topfunky/web/rails/repos/roughunderbelly/config/../app/controllers/tasks_controller.rb'
351
+ requiring file 'tasks_helper'
352
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/tasks_helper.rb
353
+ finally loading from application: 'tasks_helper.rb'
354
+ requiring file 'sparklines_helper'
355
+ checking 'login_engine' for /Users/topfunky/web/rails/repos/roughunderbelly/config/../vendor/plugins/login_engine/sparklines_helper.rb
356
+ finally loading from application: 'sparklines_helper.rb'
357
+ SQL (0.000072) BEGIN
358
+ SQL (0.000240) INSERT INTO sessions (`updated_at`, `session_id`, `data`) VALUES('2007-01-03 20:24:24', 'bdbb75323d5da69f707d5576e907706e', 'BAh7AA==\n')
359
+ SQL (0.000400) COMMIT
360
+ Processing TasksController#index (for 127.0.0.1 at 2007-01-03 12:24:24) [GET]
361
+ Parameters: {"action"=>"index", "controller"=>"tasks"}
362
+ Redirected to http://localhost:3000/tasks/list
363
+ Completed in 0.00112 (896 reqs/sec) | DB: 0.00071 (63%) | 302 Found [http://localhost/]
364
+ EOF
365
+ end
366
+
367
+ entries = []
368
+ LogParser.parse(log) { |entry| entries << entry }
369
+
370
+ assert_equal 1, entries.length, "The number of entries was incorrect"
371
+ assert_equal 'TasksController#index', entries.first.page
372
+ assert_equal 0.00112, entries.first.request_time
373
+ end
374
+
375
+ twice_test :test_class_parse_multi do
376
+ entries = []
377
+ if test_sys_log_style?
378
+ File.open "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.log" do |fp|
379
+ LogParser.parse fp do |entry|
380
+ entries << entry
381
+ end
382
+ end
383
+ else
384
+ logs_dir = File.expand_path(File.join(File.dirname(__FILE__), 'test_vanilla','test_log_parts'))
385
+ Dir.new(logs_dir).each do |file|
386
+ unless file.to_s[0,1] == "."
387
+ File.open File.join(logs_dir, file) do |fp|
388
+ LogParser.parse fp do |entry|
389
+ entries << entry
390
+ end
391
+ end
392
+ end
393
+ end
394
+ end
395
+
396
+ assert_equal 13, entries.length
397
+ assert_equal 0.300741, entries.first.request_time
398
+
399
+ entries = entries.sort_by{|e| e.page.to_s}
400
+
401
+ redirect = entries[8]
402
+ assert_equal 'TeamsController#progress', redirect.page
403
+ assert_equal 0, redirect.render_time
404
+
405
+ last = entries[3]
406
+ assert_equal 'PeopleController#progress', last.page
407
+ assert_equal 0, last.request_time
408
+ end
409
+
410
+ twice_test :test_class_parse_0_14_x do
411
+ entries = []
412
+ File.open "#{File.dirname(__FILE__)}/test_syslogs/test.syslog.0.14.x.log" do |fp|
413
+ LogParser.parse fp do |entry|
414
+ entries << entry
415
+ end
416
+ end
417
+ end
418
+
419
+ end
420
+