rackamole 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +1 -1
- data/Rakefile +3 -1
- data/aa.txt +10 -0
- data/lib/rackamole.rb +6 -5
- data/lib/rackamole/alert/emole.rb +67 -0
- data/lib/rackamole/alert/templates/rackamole/alert/emole/alert.erb +9 -0
- data/lib/rackamole/alert/twitt.rb +73 -0
- data/lib/rackamole/interceptor.rb +7 -1
- data/lib/rackamole/logger.rb +5 -2
- data/lib/rackamole/mole.rb +116 -35
- data/lib/rackamole/store.rb +4 -0
- data/lib/rackamole/store/log.rb +55 -50
- data/lib/rackamole/store/mongo_db.rb +46 -26
- data/spec/expected_results/mole_exception.log +3 -2
- data/spec/expected_results/mole_feature.log +2 -2
- data/spec/expected_results/mole_perf.log +2 -3
- data/spec/rackamole/alert/emole_spec.rb +109 -0
- data/spec/rackamole/alert/twitt_spec.rb +68 -0
- data/spec/rackamole/mole_spec.rb +61 -9
- data/spec/rackamole/store/log_spec.rb +5 -3
- data/spec/rackamole/store/mongo_db_spec.rb +12 -8
- data/z_experiments/config.rb +38 -0
- metadata +31 -2
data/spec/rackamole/mole_spec.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
2
|
-
# require 'actionpack'
|
3
2
|
|
4
3
|
describe Rack::Mole do
|
5
4
|
include Rack::Test::Methods
|
@@ -55,23 +54,23 @@ describe Rack::Mole do
|
|
55
54
|
app(
|
56
55
|
:app_name => "Test App",
|
57
56
|
:environment => :test,
|
58
|
-
:perf_threshold => 0.1,
|
59
|
-
:user_key => { :session_key => :user_id, :extractor => lambda{ |k| "
|
57
|
+
:perf_threshold => 0.1,
|
58
|
+
:user_key => { :session_key => :user_id, :extractor => lambda{ |k| "Fernand (#{k})"} },
|
60
59
|
:store => @test_store )
|
61
60
|
end
|
62
61
|
|
63
62
|
it "should set the mole meta correctly" do
|
64
|
-
get "/", nil, @test_env
|
63
|
+
get "/fred/blee", nil, @test_env
|
65
64
|
@test_store.mole_result[:app_name].should == "Test App"
|
66
65
|
@test_store.mole_result[:environment].should == :test
|
67
66
|
@test_store.mole_result[:user_id].should == 100
|
68
|
-
@test_store.mole_result[:user_name].should == '
|
67
|
+
@test_store.mole_result[:user_name].should == 'Fernand (100)'
|
69
68
|
@test_store.mole_result[:ip].should == '1.1.1.1'
|
70
69
|
@test_store.mole_result[:browser].should == 'Firefox'
|
71
70
|
@test_store.mole_result[:method].should == 'GET'
|
72
|
-
@test_store.mole_result[:url].should == 'http://example.org/'
|
73
|
-
@test_store.mole_result[:path].should == '/'
|
74
|
-
@test_store.mole_result[:
|
71
|
+
@test_store.mole_result[:url].should == 'http://example.org/fred/blee'
|
72
|
+
@test_store.mole_result[:path].should == '/fred/blee'
|
73
|
+
@test_store.mole_result[:type].should == Rackamole.feature
|
75
74
|
@test_store.mole_result[:params].should be_nil
|
76
75
|
@test_store.mole_result[:session].should_not be_nil
|
77
76
|
@test_store.mole_result[:session].should == { :user_id => '100' }
|
@@ -81,8 +80,10 @@ describe Rack::Mole do
|
|
81
80
|
begin
|
82
81
|
raise 'Oh snap!'
|
83
82
|
rescue => boom
|
84
|
-
get "/", nil, @test_env.merge( { 'mole.exception' => boom } )
|
83
|
+
get "/crap/out", nil, @test_env.merge( { 'mole.exception' => boom } )
|
84
|
+
@test_store.mole_result[:type].should == Rackamole.fault
|
85
85
|
@test_store.mole_result[:stack].should have(4).items
|
86
|
+
@test_store.mole_result[:fault].should == 'Oh snap!'
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
@@ -110,6 +111,57 @@ describe Rack::Mole do
|
|
110
111
|
end
|
111
112
|
end
|
112
113
|
|
114
|
+
describe '#alertable?' do
|
115
|
+
before( :each ) do
|
116
|
+
@filter = { :enabled => true, :features => [Rackamole.perf, Rackamole.fault] }
|
117
|
+
@rack = Rack::Mole.new( nil )
|
118
|
+
end
|
119
|
+
|
120
|
+
it "should return true if a feature can be twitted on" do
|
121
|
+
@rack.send( :alertable?, @filter, Rackamole.perf ).should == true
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should fail if the type is not in range" do
|
125
|
+
@rack.send( :alertable?, @filter, 10 ).should == false
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should fail if this is not an included feature" do
|
129
|
+
@rack.send( :alertable?, @filter, Rackamole.feature ).should == false
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should always return false if the alert is disabled" do
|
133
|
+
@filter[:enabled] = false
|
134
|
+
@rack.send( :alertable?, @filter, Rackamole.perf ).should == false
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should fail if the alert is not configured" do
|
138
|
+
@rack.send( :alertable?, nil, Rackamole.perf ).should == false
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe '#configured?' do
|
143
|
+
before( :each ) do
|
144
|
+
options = {
|
145
|
+
:twitter_auth => { :username => 'Fernand', :password => "Blee" },
|
146
|
+
:twitt_on => { :enabled => true, :features => [Rackamole.perf, Rackamole.fault] }
|
147
|
+
}
|
148
|
+
@rack = Rack::Mole.new( nil, options )
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should return true if an option is correctly configured" do
|
152
|
+
@rack.send( :configured?, :twitter_auth, [:username, :password] ).should == true
|
153
|
+
@rack.send( :configured?, :twitt_on, [:enabled, :features] ).should == true
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should fail is an option is not set" do
|
157
|
+
@rack.send( :configured?, :twitter, [:username, :password] ).should == false
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should fail is an option is not correctly configured" do
|
161
|
+
@rack.send( :configured?, :twitter_auth, [:username, :pwd] ).should == false
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
113
165
|
describe '#id_browser' do
|
114
166
|
before :all do
|
115
167
|
@rack = Rack::Mole.new( nil )
|
@@ -9,9 +9,9 @@ describe Rackamole::Store::Log do
|
|
9
9
|
@store = Rackamole::Store::Log.new( @test_file )
|
10
10
|
|
11
11
|
@args = OrderedHash.new
|
12
|
+
@args[:type] = Rackamole.feature
|
12
13
|
@args[:app_name] = "Test app"
|
13
14
|
@args[:environment] = :test
|
14
|
-
@args[:perf_issue] = false
|
15
15
|
@args[:ip] = "1.1.1.1"
|
16
16
|
@args[:browser] = "Ibrowse"
|
17
17
|
@args[:user_id] = 100
|
@@ -32,7 +32,9 @@ describe Rackamole::Store::Log do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "should mole an exception correctly" do
|
35
|
-
@args[:
|
35
|
+
@args[:type] = Rackamole.fault
|
36
|
+
@args[:fault] = "Shiet"
|
37
|
+
@args[:stack] = [ 'Oh snap!' ]
|
36
38
|
@args[:ruby_version] = 'ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.10.1]'
|
37
39
|
|
38
40
|
@store.mole( @args )
|
@@ -42,7 +44,7 @@ describe Rackamole::Store::Log do
|
|
42
44
|
end
|
43
45
|
|
44
46
|
it "should mole a performance issue correctly" do
|
45
|
-
@args[:
|
47
|
+
@args[:type] = Rackamole.perf
|
46
48
|
@store.mole( @args )
|
47
49
|
results = File.read( @test_file ).gsub( /.* Mole \:\s/, '' )
|
48
50
|
expected = File.read( File.join( File.dirname(__FILE__), %w[.. .. expected_results mole_perf.log] ) )
|
@@ -13,9 +13,10 @@ describe Rackamole::Store::MongoDb do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
before( :each ) do
|
16
|
-
@store.reset!
|
16
|
+
@store.send( :reset! )
|
17
17
|
|
18
18
|
@args = OrderedHash.new
|
19
|
+
@args[:type] = Rackamole.feature
|
19
20
|
@args[:app_name] = "Test app"
|
20
21
|
@args[:environment] = :test
|
21
22
|
@args[:perf_issue] = false
|
@@ -39,12 +40,12 @@ describe Rackamole::Store::MongoDb do
|
|
39
40
|
feature = @store.features.find_one()
|
40
41
|
feature.should_not be_nil
|
41
42
|
feature['app'].should == 'Test app'
|
42
|
-
feature['env'].should ==
|
43
|
+
feature['env'].should == 'test'
|
43
44
|
feature['ctx'].should == '/fred'
|
44
45
|
|
45
46
|
log = @store.logs.find_one()
|
46
47
|
log.should_not be_nil
|
47
|
-
log['typ'].should == Rackamole
|
48
|
+
log['typ'].should == Rackamole.feature
|
48
49
|
log['fid'].should_not be_nil
|
49
50
|
log['par'].should == { 'blee' => 'duh'.to_json }
|
50
51
|
log['ip'].should == '1.1.1.1'
|
@@ -77,7 +78,7 @@ describe Rackamole::Store::MongoDb do
|
|
77
78
|
|
78
79
|
log = @store.logs.find_one()
|
79
80
|
log.should_not be_nil
|
80
|
-
log['typ'].should == Rackamole
|
81
|
+
log['typ'].should == Rackamole.feature
|
81
82
|
log['pat'].should_not be_nil
|
82
83
|
end
|
83
84
|
|
@@ -90,7 +91,7 @@ describe Rackamole::Store::MongoDb do
|
|
90
91
|
end
|
91
92
|
|
92
93
|
it "should mole perf correctly" do
|
93
|
-
@args[:
|
94
|
+
@args[:type] = Rackamole.perf
|
94
95
|
@store.mole( @args )
|
95
96
|
|
96
97
|
@store.features.count.should == 1
|
@@ -101,11 +102,13 @@ describe Rackamole::Store::MongoDb do
|
|
101
102
|
|
102
103
|
log = @store.logs.find_one()
|
103
104
|
log.should_not be_nil
|
104
|
-
log['typ'].should == Rackamole
|
105
|
+
log['typ'].should == Rackamole.perf
|
105
106
|
end
|
106
107
|
|
107
108
|
it 'should mole an exception correctly' do
|
109
|
+
@args[:type] = Rackamole.fault
|
108
110
|
@args[:stack] = ['fred']
|
111
|
+
@args[:fault] = "Oh Snap!"
|
109
112
|
@store.mole( @args )
|
110
113
|
|
111
114
|
@store.features.count.should == 1
|
@@ -116,8 +119,9 @@ describe Rackamole::Store::MongoDb do
|
|
116
119
|
|
117
120
|
log = @store.logs.find_one()
|
118
121
|
log.should_not be_nil
|
119
|
-
log['typ'].should == Rackamole
|
120
|
-
log['sta'].should == ['fred']
|
122
|
+
log['typ'].should == Rackamole.fault
|
123
|
+
log['sta'].should == ['fred']
|
124
|
+
log['msg'].should == 'Oh Snap!'
|
121
125
|
end
|
122
126
|
|
123
127
|
it 'should keep count an similar exceptions or perf issues' do
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'yaml'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
class Fred
|
6
|
+
def method_missing( *args )
|
7
|
+
puts "Method missing -- #{args.inspect}"
|
8
|
+
self
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
Fred.new.blee( "a" ).duh( 10 )
|
13
|
+
|
14
|
+
|
15
|
+
class Blee
|
16
|
+
def initialize
|
17
|
+
@list = []
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing( *args )
|
21
|
+
@list << args
|
22
|
+
self
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
blee = Blee.new
|
27
|
+
|
28
|
+
blee.instance_eval do
|
29
|
+
hello.world
|
30
|
+
end
|
31
|
+
|
32
|
+
puts blee.to_yaml
|
33
|
+
|
34
|
+
Fred do
|
35
|
+
fred "hello"
|
36
|
+
blee 10
|
37
|
+
end
|
38
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackamole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernand Galiana
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-22 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,26 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 1.1.5
|
54
54
|
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: twitter4r
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 0.3.0
|
64
|
+
version:
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: actionmailer
|
67
|
+
type: :runtime
|
68
|
+
version_requirement:
|
69
|
+
version_requirements: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: 2.1.0
|
74
|
+
version:
|
55
75
|
- !ruby/object:Gem::Dependency
|
56
76
|
name: bones
|
57
77
|
type: :development
|
@@ -80,17 +100,23 @@ extensions: []
|
|
80
100
|
|
81
101
|
extra_rdoc_files:
|
82
102
|
- README.rdoc
|
103
|
+
- aa.txt
|
83
104
|
- aaa.txt
|
105
|
+
- lib/rackamole/alert/templates/rackamole/alert/emole/alert.erb
|
84
106
|
- samples/rails/moled/public/robots.txt
|
85
107
|
files:
|
86
108
|
- README.rdoc
|
87
109
|
- Rakefile
|
110
|
+
- aa.txt
|
88
111
|
- aaa.txt
|
89
112
|
- images/mole_logo.png
|
90
113
|
- images/mole_logo.psd
|
91
114
|
- images/mole_logo_small.png
|
92
115
|
- images/mole_logo_small.psd
|
93
116
|
- lib/rackamole.rb
|
117
|
+
- lib/rackamole/alert/emole.rb
|
118
|
+
- lib/rackamole/alert/templates/rackamole/alert/emole/alert.erb
|
119
|
+
- lib/rackamole/alert/twitt.rb
|
94
120
|
- lib/rackamole/interceptor.rb
|
95
121
|
- lib/rackamole/logger.rb
|
96
122
|
- lib/rackamole/mole.rb
|
@@ -155,6 +181,8 @@ files:
|
|
155
181
|
- spec/expected_results/mole_exception.log
|
156
182
|
- spec/expected_results/mole_feature.log
|
157
183
|
- spec/expected_results/mole_perf.log
|
184
|
+
- spec/rackamole/alert/emole_spec.rb
|
185
|
+
- spec/rackamole/alert/twitt_spec.rb
|
158
186
|
- spec/rackamole/interceptor_spec.rb
|
159
187
|
- spec/rackamole/logger_spec.rb
|
160
188
|
- spec/rackamole/mole_spec.rb
|
@@ -174,6 +202,7 @@ files:
|
|
174
202
|
- tasks/svn.rake
|
175
203
|
- tasks/test.rake
|
176
204
|
- tasks/zentest.rake
|
205
|
+
- z_experiments/config.rb
|
177
206
|
has_rdoc: true
|
178
207
|
homepage: http://rackamole.liquidrail.com
|
179
208
|
licenses: []
|