request-log-analyzer 1.2.1 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/request_log_analyzer/aggregator/database.rb +59 -35
- data/lib/request_log_analyzer/controller.rb +12 -7
- data/lib/request_log_analyzer/line_definition.rb +9 -0
- data/lib/request_log_analyzer/source/log_parser.rb +4 -0
- data/spec/fixtures/header_and_footer.log +6 -0
- data/spec/integration/command_line_usage_spec.rb +0 -2
- data/spec/lib/{helper.rb → helpers.rb} +1 -3
- data/spec/lib/macros.rb +2 -0
- data/spec/lib/matchers.rb +63 -0
- data/spec/lib/testing_format.rb +6 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +13 -4
- data/spec/unit/aggregator/database_spec.rb +208 -0
- data/spec/unit/aggregator/summarizer_spec.rb +0 -2
- data/spec/unit/controller/controller_spec.rb +0 -2
- data/spec/unit/controller/log_processor_spec.rb +0 -2
- data/spec/unit/file_format/file_format_api_spec.rb +50 -71
- data/spec/unit/file_format/line_definition_spec.rb +49 -45
- data/spec/unit/file_format/merb_format_spec.rb +0 -1
- data/spec/unit/file_format/rails_format_spec.rb +0 -2
- data/spec/unit/filter/anonymize_filter_spec.rb +0 -1
- data/spec/unit/filter/field_filter_spec.rb +0 -3
- data/spec/unit/filter/filter_spec.rb +17 -0
- data/spec/unit/filter/timespan_filter_spec.rb +0 -3
- data/spec/unit/source/log_parser_spec.rb +5 -4
- data/spec/unit/source/request_spec.rb +17 -4
- data/spec/unit/tracker/duration_tracker_spec.rb +0 -6
- data/spec/unit/tracker/frequency_tracker_spec.rb +0 -6
- data/spec/unit/tracker/hourly_spread_spec.rb +0 -4
- data/spec/unit/tracker/timespan_tracker_spec.rb +0 -4
- data/spec/unit/tracker/tracker_api_spec.rb +0 -2
- data/tasks/rspec.rake +8 -1
- metadata +12 -6
- data/spec/unit/aggregator/database_inserter_spec.rb +0 -106
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Duration, 'static category' do
|
4
4
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
6
|
-
|
7
5
|
before(:each) do
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => :category)
|
9
7
|
@tracker.prepare
|
@@ -54,8 +52,6 @@ end
|
|
54
52
|
|
55
53
|
describe RequestLogAnalyzer::Tracker::Duration, 'dynamic category' do
|
56
54
|
|
57
|
-
include RequestLogAnalyzer::Spec::Helper
|
58
|
-
|
59
55
|
before(:each) do
|
60
56
|
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
61
57
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:duration => :duration, :category => @categorizer)
|
@@ -75,8 +71,6 @@ end
|
|
75
71
|
|
76
72
|
describe RequestLogAnalyzer::Tracker::Duration, 'reporting' do
|
77
73
|
|
78
|
-
include RequestLogAnalyzer::Spec::Helper
|
79
|
-
|
80
74
|
before(:each) do
|
81
75
|
@tracker = RequestLogAnalyzer::Tracker::Duration.new(:category => :category, :duration => :duration)
|
82
76
|
@tracker.prepare
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Frequency, 'static category' do
|
4
4
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
6
|
-
|
7
5
|
before(:each) do
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => :category)
|
9
7
|
@tracker.prepare
|
@@ -36,8 +34,6 @@ end
|
|
36
34
|
|
37
35
|
describe RequestLogAnalyzer::Tracker::Frequency, 'dynamic category' do
|
38
36
|
|
39
|
-
include RequestLogAnalyzer::Spec::Helper
|
40
|
-
|
41
37
|
before(:each) do
|
42
38
|
@categorizer = Proc.new { |request| request[:duration] > 0.2 ? 'slow' : 'fast' }
|
43
39
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => @categorizer)
|
@@ -59,8 +55,6 @@ end
|
|
59
55
|
|
60
56
|
describe RequestLogAnalyzer::Tracker::Frequency, 'reporting' do
|
61
57
|
|
62
|
-
include RequestLogAnalyzer::Spec::Helper
|
63
|
-
|
64
58
|
before(:each) do
|
65
59
|
@tracker = RequestLogAnalyzer::Tracker::Frequency.new(:category => :category)
|
66
60
|
@tracker.prepare
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::HourlySpread do
|
4
4
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
6
|
-
|
7
5
|
before(:each) do
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
9
7
|
@tracker.prepare
|
@@ -54,8 +52,6 @@ end
|
|
54
52
|
|
55
53
|
describe RequestLogAnalyzer::Tracker::HourlySpread, 'reporting' do
|
56
54
|
|
57
|
-
include RequestLogAnalyzer::Spec::Helper
|
58
|
-
|
59
55
|
before(:each) do
|
60
56
|
@tracker = RequestLogAnalyzer::Tracker::HourlySpread.new
|
61
57
|
@tracker.prepare
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
2
|
|
3
3
|
describe RequestLogAnalyzer::Tracker::Timespan do
|
4
4
|
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
6
|
-
|
7
5
|
before(:each) do
|
8
6
|
@tracker = RequestLogAnalyzer::Tracker::Timespan.new
|
9
7
|
@tracker.prepare
|
@@ -45,8 +43,6 @@ end
|
|
45
43
|
|
46
44
|
describe RequestLogAnalyzer::Tracker::Timespan, 'reporting' do
|
47
45
|
|
48
|
-
include RequestLogAnalyzer::Spec::Helper
|
49
|
-
|
50
46
|
before(:each) do
|
51
47
|
@tracker = RequestLogAnalyzer::Tracker::Timespan.new
|
52
48
|
@tracker.prepare
|
data/tasks/rspec.rake
CHANGED
@@ -9,4 +9,11 @@ namespace :spec do
|
|
9
9
|
t.rcov = true
|
10
10
|
t.rcov_opts = ['--exclude', '"spec/*,gems/*"', '--rails']
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
14
|
+
Spec::Rake::SpecTask.new(:fancy) do |t|
|
15
|
+
t.spec_opts = ['--options', "\"spec/spec.opts\""]
|
16
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-log-analyzer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-08-19 00:00:00 +02:00
|
14
14
|
default_executable: request-log-analyzer
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -66,6 +66,7 @@ files:
|
|
66
66
|
- spec/fixtures/decompression.log.zip
|
67
67
|
- spec/fixtures/decompression.tar.gz
|
68
68
|
- spec/fixtures/decompression.tgz
|
69
|
+
- spec/fixtures/header_and_footer.log
|
69
70
|
- spec/fixtures/merb.log
|
70
71
|
- spec/fixtures/multiple_files_1.log
|
71
72
|
- spec/fixtures/multiple_files_2.log
|
@@ -78,11 +79,14 @@ files:
|
|
78
79
|
- spec/fixtures/test_language_combined.log
|
79
80
|
- spec/fixtures/test_order.log
|
80
81
|
- spec/integration/command_line_usage_spec.rb
|
81
|
-
- spec/lib/
|
82
|
+
- spec/lib/helpers.rb
|
83
|
+
- spec/lib/macros.rb
|
84
|
+
- spec/lib/matchers.rb
|
82
85
|
- spec/lib/mocks.rb
|
83
86
|
- spec/lib/testing_format.rb
|
87
|
+
- spec/spec.opts
|
84
88
|
- spec/spec_helper.rb
|
85
|
-
- spec/unit/aggregator/
|
89
|
+
- spec/unit/aggregator/database_spec.rb
|
86
90
|
- spec/unit/aggregator/summarizer_spec.rb
|
87
91
|
- spec/unit/controller/controller_spec.rb
|
88
92
|
- spec/unit/controller/log_processor_spec.rb
|
@@ -92,6 +96,7 @@ files:
|
|
92
96
|
- spec/unit/file_format/rails_format_spec.rb
|
93
97
|
- spec/unit/filter/anonymize_filter_spec.rb
|
94
98
|
- spec/unit/filter/field_filter_spec.rb
|
99
|
+
- spec/unit/filter/filter_spec.rb
|
95
100
|
- spec/unit/filter/timespan_filter_spec.rb
|
96
101
|
- spec/unit/source/log_parser_spec.rb
|
97
102
|
- spec/unit/source/request_spec.rb
|
@@ -132,13 +137,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
137
|
requirements: []
|
133
138
|
|
134
139
|
rubyforge_project: r-l-a
|
135
|
-
rubygems_version: 1.3.
|
140
|
+
rubygems_version: 1.3.4
|
136
141
|
signing_key:
|
137
142
|
specification_version: 3
|
138
143
|
summary: A command line tool to analyze Rails logs
|
139
144
|
test_files:
|
140
145
|
- spec/integration/command_line_usage_spec.rb
|
141
|
-
- spec/unit/aggregator/
|
146
|
+
- spec/unit/aggregator/database_spec.rb
|
142
147
|
- spec/unit/aggregator/summarizer_spec.rb
|
143
148
|
- spec/unit/controller/controller_spec.rb
|
144
149
|
- spec/unit/controller/log_processor_spec.rb
|
@@ -148,6 +153,7 @@ test_files:
|
|
148
153
|
- spec/unit/file_format/rails_format_spec.rb
|
149
154
|
- spec/unit/filter/anonymize_filter_spec.rb
|
150
155
|
- spec/unit/filter/field_filter_spec.rb
|
156
|
+
- spec/unit/filter/filter_spec.rb
|
151
157
|
- spec/unit/filter/timespan_filter_spec.rb
|
152
158
|
- spec/unit/source/log_parser_spec.rb
|
153
159
|
- spec/unit/source/request_spec.rb
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
-
|
3
|
-
describe RequestLogAnalyzer::Aggregator::Database, "schema creation" do
|
4
|
-
|
5
|
-
include RequestLogAnalyzer::Spec::Helper
|
6
|
-
|
7
|
-
before(:each) do
|
8
|
-
log_parser = RequestLogAnalyzer::Source::LogParser.new(testing_format)
|
9
|
-
@database_inserter = RequestLogAnalyzer::Aggregator::Database.new(log_parser, :database => ':memory:')
|
10
|
-
end
|
11
|
-
|
12
|
-
|
13
|
-
it "should create the correct tables" do
|
14
|
-
ActiveRecord::Migration.should_receive(:create_table).with("warnings")
|
15
|
-
ActiveRecord::Migration.should_receive(:create_table).with("requests")
|
16
|
-
ActiveRecord::Migration.should_receive(:create_table).with("first_lines")
|
17
|
-
ActiveRecord::Migration.should_receive(:create_table).with("test_lines")
|
18
|
-
ActiveRecord::Migration.should_receive(:create_table).with("eval_lines")
|
19
|
-
ActiveRecord::Migration.should_receive(:create_table).with("last_lines")
|
20
|
-
|
21
|
-
ActiveRecord::Migration.should_receive(:add_index).with("eval_lines", [:request_id])
|
22
|
-
ActiveRecord::Migration.should_receive(:add_index).with("first_lines", [:request_id])
|
23
|
-
ActiveRecord::Migration.should_receive(:add_index).with("test_lines", [:request_id])
|
24
|
-
ActiveRecord::Migration.should_receive(:add_index).with("last_lines", [:request_id])
|
25
|
-
|
26
|
-
@database_inserter.prepare
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should create a default Request class" do
|
30
|
-
@database_inserter.prepare
|
31
|
-
TestingFormat::Database::Request.ancestors.should include(ActiveRecord::Base)
|
32
|
-
TestingFormat::Database::Request.column_names.should include('first_lineno')
|
33
|
-
TestingFormat::Database::Request.column_names.should include('last_lineno')
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should create associations for the default Request class" do
|
37
|
-
@database_inserter.prepare
|
38
|
-
@request = TestingFormat::Database::Request.new
|
39
|
-
@request.should respond_to(:test_lines)
|
40
|
-
@request.test_lines.should
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should create the default table names" do
|
44
|
-
@database_inserter.prepare
|
45
|
-
@database_inserter.file_format.line_definitions.each do |name, definition|
|
46
|
-
klass = TestingFormat::Database.const_get("#{name}_line".camelize)
|
47
|
-
klass.column_names.should include('id')
|
48
|
-
klass.column_names.should include('lineno')
|
49
|
-
klass.column_names.should include('request_id')
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it "should create the correct fields in the table" do
|
54
|
-
@database_inserter.prepare
|
55
|
-
|
56
|
-
TestingFormat::Database::FirstLine.column_names.should include('request_no')
|
57
|
-
TestingFormat::Database::LastLine.column_names.should include('request_no')
|
58
|
-
TestingFormat::Database::TestLine.column_names.should include('test_capture')
|
59
|
-
end
|
60
|
-
|
61
|
-
it "should create fields for provides" do
|
62
|
-
@database_inserter.prepare
|
63
|
-
TestingFormat::Database::EvalLine.column_names.should include('evaluated')
|
64
|
-
TestingFormat::Database::EvalLine.column_names.should include('greating')
|
65
|
-
TestingFormat::Database::EvalLine.column_names.should include('what')
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
describe RequestLogAnalyzer::Aggregator::Database, "record insertion" do
|
71
|
-
include RequestLogAnalyzer::Spec::Helper
|
72
|
-
|
73
|
-
before(:each) do
|
74
|
-
log_parser = RequestLogAnalyzer::Source::LogParser.new(testing_format)
|
75
|
-
@database_inserter = RequestLogAnalyzer::Aggregator::Database.new(log_parser, :database => ':memory:')
|
76
|
-
@database_inserter.prepare
|
77
|
-
|
78
|
-
@incomplete_request = testing_format.request( {:line_type => :first, :request_no => 564})
|
79
|
-
@completed_request = testing_format.request( {:line_type => :first, :request_no => 564},
|
80
|
-
{:line_type => :test, :test_capture => "awesome"},
|
81
|
-
{:line_type => :test, :test_capture => "indeed"},
|
82
|
-
{:line_type => :eval, :evaluated => { :greating => 'howdy'}, :greating => 'howdy' },
|
83
|
-
{:line_type => :last, :request_no => 564})
|
84
|
-
end
|
85
|
-
|
86
|
-
it "should insert a record in the request table" do
|
87
|
-
TestingFormat::Database::Request.count.should == 0
|
88
|
-
@database_inserter.aggregate(@incomplete_request)
|
89
|
-
TestingFormat::Database::Request.count.should == 1
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should insert records in all relevant line tables" do
|
93
|
-
@database_inserter.aggregate(@completed_request)
|
94
|
-
request = TestingFormat::Database::Request.first
|
95
|
-
request.should have(2).test_lines
|
96
|
-
request.should have(1).first_lines
|
97
|
-
request.should have(1).eval_lines
|
98
|
-
request.should have(1).last_lines
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should log a warning in the warnings table" do
|
102
|
-
TestingFormat::Database::Warning.should_receive(:create!).with(hash_including(:warning_type => 'test_warning'))
|
103
|
-
@database_inserter.warning(:test_warning, "Testing the warning system", 12)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|