wackamole 0.0.1
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/.bnsignore +16 -0
- data/.gitignore +2 -0
- data/History.txt +4 -0
- data/README.rdoc +88 -0
- data/Rakefile +42 -0
- data/aa.rb +25 -0
- data/aaa.txt +13 -0
- data/bin/wackamole +77 -0
- data/lib/app.rb +63 -0
- data/lib/controllers/dashboard.rb +30 -0
- data/lib/controllers/features.rb +41 -0
- data/lib/controllers/logs.rb +49 -0
- data/lib/controllers/mission.rb +27 -0
- data/lib/controllers/users.rb +41 -0
- data/lib/helpers/dashboard_helper.rb +32 -0
- data/lib/helpers/features_helper.rb +13 -0
- data/lib/helpers/flash_helper.rb +16 -0
- data/lib/helpers/logs_helper.rb +116 -0
- data/lib/helpers/main_helper.rb +182 -0
- data/lib/helpers/mission_helper.rb +59 -0
- data/lib/helpers/rails_helper.rb +7 -0
- data/lib/wackamole.rb +47 -0
- data/lib/wackamole/core_ext/date_time.rb +8 -0
- data/lib/wackamole/core_ext/time.rb +9 -0
- data/lib/wackamole/models/control.rb +132 -0
- data/lib/wackamole/models/feature.rb +74 -0
- data/lib/wackamole/models/log.rb +45 -0
- data/lib/wackamole/models/mission.rb +164 -0
- data/lib/wackamole/models/mole_info.rb +94 -0
- data/lib/wackamole/models/search_filter.rb +192 -0
- data/lib/wackamole/models/user.rb +46 -0
- data/public/favicon.ico +0 -0
- data/public/images/.DS_Store +0 -0
- data/public/images/browsers/.DS_Store +0 -0
- data/public/images/browsers/MSIE 6.png +0 -0
- data/public/images/browsers/MSIE 8.0 +0 -0
- data/public/images/browsers/MSIE 8.0.png +0 -0
- data/public/images/browsers/chrome.png +0 -0
- data/public/images/browsers/firefox.png +0 -0
- data/public/images/browsers/ie 6.0.png +0 -0
- data/public/images/browsers/ie6.jpg +0 -0
- data/public/images/browsers/ie7.jpg +0 -0
- data/public/images/browsers/ie7.png +0 -0
- data/public/images/browsers/msie 6.0.png +0 -0
- data/public/images/browsers/msie 7.0.png +0 -0
- data/public/images/browsers/opera.jpg +0 -0
- data/public/images/browsers/opera.png +0 -0
- data/public/images/browsers/safari.jpg +0 -0
- data/public/images/browsers/safari.png +0 -0
- data/public/images/browsers/unknown_browser.png +0 -0
- data/public/images/close.png +0 -0
- data/public/images/error.png +0 -0
- data/public/images/fade.png +0 -0
- data/public/images/fault_big.png +0 -0
- data/public/images/fault_small.png +0 -0
- data/public/images/feature.png +0 -0
- data/public/images/h300.png +0 -0
- data/public/images/hori_large.png +0 -0
- data/public/images/info_big.png +0 -0
- data/public/images/info_small.png +0 -0
- data/public/images/loading.gif +0 -0
- data/public/images/loading1.gif +0 -0
- data/public/images/mole_error.png +0 -0
- data/public/images/more.gif +0 -0
- data/public/images/next.png +0 -0
- data/public/images/perf_big.png +0 -0
- data/public/images/perf_small.png +0 -0
- data/public/images/powered_by.png +0 -0
- data/public/images/prev.png +0 -0
- data/public/images/row_fade.png +0 -0
- data/public/images/search.png +0 -0
- data/public/images/small_logo.png +0 -0
- data/public/images/spaceball.gif +0 -0
- data/public/images/tick.png +0 -0
- data/public/images/users.png +0 -0
- data/public/images/wackamole_logo.png +0 -0
- data/public/javascripts/.DS_Store +0 -0
- data/public/javascripts/application.js +28 -0
- data/public/javascripts/g.dot.min.js +7 -0
- data/public/javascripts/g.raphael.min.js +7 -0
- data/public/javascripts/jit.js +9052 -0
- data/public/javascripts/jit.min.js +1 -0
- data/public/javascripts/jquery-ui.js +188 -0
- data/public/javascripts/jquery.example.js +160 -0
- data/public/javascripts/jquery.js +19 -0
- data/public/javascripts/jquery.tools.min.js +38 -0
- data/public/javascripts/jquery_ba-url.js +9 -0
- data/public/javascripts/jquery_min.js +19 -0
- data/public/javascripts/jquery_ui_min.js +298 -0
- data/public/javascripts/raphael.min.js +7 -0
- data/public/stylesheets/tabs-slideshow.css +95 -0
- data/public/stylesheets/wackamole.css +684 -0
- data/spec/config/bogus_test.yml +3 -0
- data/spec/config/test.yml +3 -0
- data/spec/core_ext/date_time_spec.rb +8 -0
- data/spec/core_ext/time_spec.rb +12 -0
- data/spec/data/fixtures.rb +92 -0
- data/spec/models/control_spec.rb +98 -0
- data/spec/models/feature_spec.rb +52 -0
- data/spec/models/log_spec.rb +43 -0
- data/spec/models/mission_spec.rb +225 -0
- data/spec/models/moled_info_spec.rb +30 -0
- data/spec/models/search_filter_spec.rb +151 -0
- data/spec/models/user_spec.rb +44 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/wackamole_spec.rb +20 -0
- data/tasks/bones.rake +20 -0
- data/tasks/fixtures.rake +13 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +32 -0
- data/tasks/rdoc.rake +54 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +290 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +46 -0
- data/views/dashboard/_report.erb +118 -0
- data/views/dashboard/index.erb +4 -0
- data/views/dashboard/refresh_js.erb +3 -0
- data/views/features/_rows.erb +26 -0
- data/views/features/filter.js.erb +2 -0
- data/views/features/index.erb +24 -0
- data/views/features/index.js.erb +2 -0
- data/views/layout.erb +47 -0
- data/views/logs/_array.erb +12 -0
- data/views/logs/_hash.erb +14 -0
- data/views/logs/_rows.erb +65 -0
- data/views/logs/filter.js.erb +4 -0
- data/views/logs/index.erb +13 -0
- data/views/logs/index.js.erb +2 -0
- data/views/logs/show.erb +66 -0
- data/views/mission/_report.erb +49 -0
- data/views/mission/index.erb +7 -0
- data/views/mission/refresh_js.erb +3 -0
- data/views/shared/_filter.erb +63 -0
- data/views/shared/_flash.erb +3 -0
- data/views/shared/_search.erb +25 -0
- data/views/shared/_timestamp.erb +1 -0
- data/views/shared/_wait.erb +1 -0
- data/views/shared/flash.js.erb +10 -0
- data/views/users/_rows.erb +26 -0
- data/views/users/filter.js.erb +4 -0
- data/views/users/index.erb +24 -0
- data/views/users/index.js.erb +2 -0
- metadata +347 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
|
|
3
|
+
describe Time do
|
|
4
|
+
it "should convert a time to date_id correctly" do
|
|
5
|
+
Chronic.parse( "2010-01-01 09:30:59" ).to_date_id.should == 20100101
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should convert a time to time_id correctly" do
|
|
9
|
+
Chronic.parse( "2010-01-01 10:30:59" ).to_time_id.should == "103059"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require 'rackamole'
|
|
2
|
+
|
|
3
|
+
class Fixtures
|
|
4
|
+
|
|
5
|
+
def self.test_time_id() @test_time ||= 20100101; end
|
|
6
|
+
|
|
7
|
+
def self.load_data
|
|
8
|
+
puts "Loading fixture data..."
|
|
9
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
10
|
+
load_test_dbs
|
|
11
|
+
load_bogus_dbs
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.load_test_dbs
|
|
15
|
+
con = Wackamole::Control.connection
|
|
16
|
+
%w[development test production].each{ |env| create_valid_mole_db( con, "fred", env) }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.load_bogus_dbs
|
|
20
|
+
con = Wackamole::Control.connection
|
|
21
|
+
%w[mole_blee_mdb zorg_blee_dev_mdb].each do |db_name|
|
|
22
|
+
create_db( con, db_name )
|
|
23
|
+
end
|
|
24
|
+
# create mole db with wrong cltns
|
|
25
|
+
# BOZO !! An empty db does not show up?
|
|
26
|
+
db = create_db( con, "mole_zorg_wrong_mdb" )
|
|
27
|
+
%w[features1 logs1 users1].each { |cltn| db.drop_collection( cltn );db.create_collection( cltn ) }
|
|
28
|
+
# missing cltn
|
|
29
|
+
db = create_db( con, "mole_zorg_missing_mdb" )
|
|
30
|
+
%w[features logs].each { |cltn| db.drop_collection( cltn );db.create_collection( cltn ) }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def self.create_db( con, db_name )
|
|
34
|
+
# if con.database_names.include?( db_name )
|
|
35
|
+
# con.drop_database( db_name )
|
|
36
|
+
# end
|
|
37
|
+
con.db( db_name, :strict => true )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def self.create_valid_mole_db( con, app_name, env )
|
|
41
|
+
db_name = "mole_#{app_name}_#{env}_mdb"
|
|
42
|
+
db = create_db( con, db_name )
|
|
43
|
+
%w[users features logs].each do |cltn_name|
|
|
44
|
+
db.drop_collection( cltn_name )
|
|
45
|
+
cltn = db.create_collection( cltn_name ) # :capped => false, :size => 1_000_000, :limit => 100 )
|
|
46
|
+
case cltn_name
|
|
47
|
+
when 'users' : populate_users( cltn, app_name, env )
|
|
48
|
+
when 'features' : populate_features( cltn, app_name, env )
|
|
49
|
+
when 'logs' : populate_logs( cltn, app_name, env )
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.populate_users( cltn, app_name, env )
|
|
55
|
+
10.times do |i|
|
|
56
|
+
cltn.insert( { :una => "blee_#{i}@#{app_name}.#{env}", :did => test_time_id.to_s } )
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.populate_features( cltn, app_name, env )
|
|
61
|
+
10.times do |i|
|
|
62
|
+
cltn.insert( { :env => env, :app => app_name, :did => test_time_id.to_s, :ctx => "feature_#{i}" } )
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def self.populate_logs( cltn, app_name, env )
|
|
67
|
+
features = cltn.db['features'].find( {} ).to_a
|
|
68
|
+
users = cltn.db['users'].find( {} ).to_a
|
|
69
|
+
[Rackamole.feature, Rackamole.perf, Rackamole.fault].each do |type|
|
|
70
|
+
5.times do |i|
|
|
71
|
+
cltn.insert({
|
|
72
|
+
:typ => type,
|
|
73
|
+
:fid => features[i]['_id'],
|
|
74
|
+
:uid => users[i]['_id'],
|
|
75
|
+
:did => test_time_id.to_s,
|
|
76
|
+
:tid => "070000",
|
|
77
|
+
:ip => "127.0.0.#{i}"
|
|
78
|
+
})
|
|
79
|
+
end
|
|
80
|
+
2.times do |i|
|
|
81
|
+
cltn.insert({
|
|
82
|
+
:typ => type,
|
|
83
|
+
:fid => features[5+i]['_id'],
|
|
84
|
+
:uid => users[5+i]['_id'],
|
|
85
|
+
:did => test_time_id.to_s,
|
|
86
|
+
:tid => "080000",
|
|
87
|
+
:ip => "127.0.0.#{i}"
|
|
88
|
+
})
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
|
|
3
|
+
describe Wackamole::Control do
|
|
4
|
+
describe 'errors' do
|
|
5
|
+
before( :all ) do
|
|
6
|
+
Wackamole::Control.reset!
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "should raise an error if not correctly initialized" do
|
|
10
|
+
lambda{ Wackamole::Control.connection }.should raise_error( /You must call init_config/ )
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should raise an error if invalid config file" do
|
|
14
|
+
config_file = File.join(File.dirname(__FILE__), %w[.. config blee.yml])
|
|
15
|
+
lambda {
|
|
16
|
+
Wackamole::Control.init_config( config_file, 'test' )
|
|
17
|
+
}.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- No such file or directory/ )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should raise an error if a bogus env is requested" do
|
|
21
|
+
config_file = File.join(File.dirname(__FILE__), %w[.. config test.yml])
|
|
22
|
+
lambda {
|
|
23
|
+
Wackamole::Control.init_config( config_file, 'production' )
|
|
24
|
+
}.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- Invalid environment `production/ )
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should raise an error if invalid config file content" do
|
|
28
|
+
config_file = File.join(File.dirname(__FILE__), %w[.. config bogus_test.yml])
|
|
29
|
+
lambda {
|
|
30
|
+
Wackamole::Control.init_config( config_file, 'test' )
|
|
31
|
+
}.should raise_error( /Hoy! An error occur loading the config file `#{config_file} -- Unable to find host in -/ )
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe 'connection' do
|
|
36
|
+
before :all do
|
|
37
|
+
Wackamole::Control.reset!
|
|
38
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
39
|
+
Wackamole::Control.connection.should_not be_nil
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#collection" do
|
|
43
|
+
it "should find a collection correctly" do
|
|
44
|
+
cltn = Wackamole::Control.collection( 'features', "mole_fred_development_mdb" )
|
|
45
|
+
cltn.count.should == 10
|
|
46
|
+
feature = cltn.find_one()
|
|
47
|
+
feature['app'].should == "fred"
|
|
48
|
+
feature['env'].should == "development"
|
|
49
|
+
feature['did'].should == Fixtures.test_time_id.to_s
|
|
50
|
+
feature['ctx'].should match( /feature_\d{1}/ )
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "mole databases" do
|
|
55
|
+
it "should correctly identify mole dbs" do
|
|
56
|
+
# gen_bogus_dbs
|
|
57
|
+
mole_dbs = Wackamole::Control.mole_databases
|
|
58
|
+
mole_dbs.should have(3).items
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should extra app/env correctly" do
|
|
62
|
+
Wackamole::Control.extract_app_info( "mole_fred_development_mdb" ).should == ['fred', 'development']
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it "should fail to extract app info for an invalid mole db" do
|
|
66
|
+
lambda {
|
|
67
|
+
Wackamole::Control.extract_app_info( "mole_fred_mdb" )
|
|
68
|
+
}.should raise_error( /Invalid mole db specification mole_fred_mdb/ )
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should connect to a mole databases correctly" do
|
|
72
|
+
%w[test production development].each do |env|
|
|
73
|
+
Wackamole::Control.db( "mole_fred_#{env}_mdb" )
|
|
74
|
+
feature = Wackamole::Control.collection( 'features' ).find_one()
|
|
75
|
+
feature['app'].should == "fred"
|
|
76
|
+
feature['env'].should == env
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should switch mole dbs correctly" do
|
|
81
|
+
%w[test production development].each do |env|
|
|
82
|
+
Wackamole::Control.switch_mole_db!( "fred", env )
|
|
83
|
+
feature = Wackamole::Control.collection( 'features' ).find_one()
|
|
84
|
+
feature['app'].should == "fred"
|
|
85
|
+
feature['env'].should == env
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should fail to switch if there is no mole db" do
|
|
90
|
+
lambda{ Wackamole::Control.switch_mole_db!( "blee", "test" ) }.should raise_error( /Invalid mole database mole_blee_test_mdb/ )
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
it "should fail to switch for an invalid mole db" do
|
|
94
|
+
lambda{ Wackamole::Control.switch_mole_db!( "zorg", "missing" ) }.should raise_error( /Invalid mole database mole_zorg_missing_mdb/ )
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
require 'chronic'
|
|
3
|
+
|
|
4
|
+
describe Wackamole::Feature do
|
|
5
|
+
before( :all ) do
|
|
6
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
7
|
+
Wackamole::Control.connection.should_not be_nil
|
|
8
|
+
Wackamole::Control.db( "mole_fred_test_mdb" )
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "retrieve an app info correctly" do
|
|
12
|
+
app_info = Wackamole::Feature.get_app_info
|
|
13
|
+
app_info.should_not be_nil
|
|
14
|
+
app_info.should have(2).items
|
|
15
|
+
app_info[:app_name].should == "fred"
|
|
16
|
+
app_info[:stage].should == "test"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "should paginate features correctly" do
|
|
20
|
+
cltn = Wackamole::Feature.paginate_tops( {}, 1, 5 )
|
|
21
|
+
cltn.total_entries.should == 7
|
|
22
|
+
cltn.size.should == 5
|
|
23
|
+
cltn.total_pages.should == 2
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
describe "indexes" do
|
|
27
|
+
before :all do
|
|
28
|
+
@cltn = Wackamole::Feature.features_cltn
|
|
29
|
+
@cltn.should_not be_nil
|
|
30
|
+
@cltn.drop_indexes
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should set up indexes correctly" do
|
|
34
|
+
indexes = @cltn.index_information
|
|
35
|
+
indexes.should have(1).item
|
|
36
|
+
count = Wackamole::Feature.ensure_indexes!
|
|
37
|
+
count.should == 3
|
|
38
|
+
indexes = @cltn.index_information
|
|
39
|
+
indexes.should have(3).items
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should do nothing if indexes are already present" do
|
|
43
|
+
indexes = @cltn.index_information
|
|
44
|
+
indexes.should have(3).items
|
|
45
|
+
count = Wackamole::Feature.ensure_indexes!
|
|
46
|
+
count.should == 1
|
|
47
|
+
indexes = @cltn.index_information
|
|
48
|
+
indexes.should have(3).items
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
require 'chronic'
|
|
3
|
+
|
|
4
|
+
describe Wackamole::Log do
|
|
5
|
+
before( :all ) do
|
|
6
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
7
|
+
Wackamole::Control.connection.should_not be_nil
|
|
8
|
+
Wackamole::Control.db( "mole_fred_test_mdb" )
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it "should paginate logs correctly" do
|
|
12
|
+
cltn = Wackamole::Log.paginate( {}, 1, 5 )
|
|
13
|
+
cltn.total_entries.should == 21
|
|
14
|
+
cltn.size.should == 5
|
|
15
|
+
cltn.total_pages.should == 5
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
describe "indexes" do
|
|
19
|
+
before :all do
|
|
20
|
+
@cltn = Wackamole::Log.logs_cltn
|
|
21
|
+
@cltn.should_not be_nil
|
|
22
|
+
@cltn.drop_indexes
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "should set up indexes correctly" do
|
|
26
|
+
indexes = @cltn.index_information
|
|
27
|
+
indexes.should have(1).item
|
|
28
|
+
count = Wackamole::Log.ensure_indexes!
|
|
29
|
+
count.should == 5
|
|
30
|
+
indexes = @cltn.index_information
|
|
31
|
+
indexes.should have(6).items
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should do nothing if indexes are already present" do
|
|
35
|
+
indexes = @cltn.index_information
|
|
36
|
+
indexes.should have(6).items
|
|
37
|
+
count = Wackamole::Log.ensure_indexes!
|
|
38
|
+
count.should == 0
|
|
39
|
+
indexes = @cltn.index_information
|
|
40
|
+
indexes.should have(6).items
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), %w[.. spec_helper])
|
|
2
|
+
require 'chronic'
|
|
3
|
+
|
|
4
|
+
describe Wackamole::Mission do
|
|
5
|
+
before :all do
|
|
6
|
+
Wackamole::Control.reset!
|
|
7
|
+
Wackamole::Control.init_config( File.join(File.dirname(__FILE__), %w[.. config test.yml]), 'test' )
|
|
8
|
+
Wackamole::Control.connection.should_not be_nil
|
|
9
|
+
@test_time = Chronic.parse( "2010/01/01 01:00:00" ).utc
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe '#to_type_name' do
|
|
13
|
+
it "should convert a type to a name correctly" do
|
|
14
|
+
%w[feature perf fault].each do |type|
|
|
15
|
+
name = Wackamole::Mission.to_type_name( Rackamole.send( type ) )
|
|
16
|
+
name.should == "#{type}s"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should raise an error if a type is invalid" do
|
|
21
|
+
lambda {
|
|
22
|
+
Wackamole::Mission.to_type_name( "fred" )
|
|
23
|
+
}.should raise_error( /Invalid mole log type `fred/ )
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "#rollups" do
|
|
28
|
+
before( :each ) do
|
|
29
|
+
@con = Wackamole::Control.connection
|
|
30
|
+
db = @con.db( 'wackamole_mdb' )
|
|
31
|
+
db['rollups'].remove( {} )
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
after( :each ) do
|
|
35
|
+
@con.drop_database( "mole_blee_test_mdb" )
|
|
36
|
+
@con.drop_database( "mole_blee_development_mdb" )
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should rollup statuses for a time correctly" do
|
|
40
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
41
|
+
rollups.should have(1).item
|
|
42
|
+
rollup = rollups.first
|
|
43
|
+
rollup['envs'].should have(3).items
|
|
44
|
+
envs = %w[development production test]
|
|
45
|
+
rollup['app'].should == 'fred'
|
|
46
|
+
rollup['envs'].each_pair do |env, info|
|
|
47
|
+
envs.include?( env ).should == true
|
|
48
|
+
envs = envs - [env]
|
|
49
|
+
info.keys.sort.should == %w[faults features perfs]
|
|
50
|
+
info.values.should == [2, 2, 2]
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should rollup statuses for the day correctly" do
|
|
55
|
+
rollups = Wackamole::Mission.rollups( @test_time, true )
|
|
56
|
+
rollups.should have(1).item
|
|
57
|
+
rollup = rollups.first
|
|
58
|
+
rollup['envs'].should have(3).items
|
|
59
|
+
envs = %w[development production test]
|
|
60
|
+
rollup['app'].should == 'fred'
|
|
61
|
+
rollup['envs'].each_pair do |env, info|
|
|
62
|
+
envs.include?( env ).should == true
|
|
63
|
+
envs = envs - [env]
|
|
64
|
+
info.keys.sort.should == %w[faults features perfs]
|
|
65
|
+
info.values.should == [7, 7, 7]
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it "should update a rollup correctly" do
|
|
70
|
+
Wackamole::Mission.rollups( @test_time, false )
|
|
71
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
72
|
+
rollups.should have(1).item
|
|
73
|
+
rollup = rollups.first
|
|
74
|
+
rollup['envs'].should have(3).items
|
|
75
|
+
envs = %w[development production test]
|
|
76
|
+
rollup['app'].should == 'fred'
|
|
77
|
+
rollup['envs'].each_pair do |env, info|
|
|
78
|
+
envs.include?( env ).should == true
|
|
79
|
+
envs = envs - [env]
|
|
80
|
+
info.keys.sort.should == %w[faults features perfs]
|
|
81
|
+
info.values.should == [4, 4, 4]
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "#reset!" do
|
|
86
|
+
it "should clear out a mole correctly" do
|
|
87
|
+
Fixtures.create_valid_mole_db( @con, 'blee', "test" )
|
|
88
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
89
|
+
rollup = Wackamole::Mission.rollups_cltn.find_one( { :app => 'blee' } )
|
|
90
|
+
rollup.should_not be_nil
|
|
91
|
+
%w[features perfs faults].each do |type|
|
|
92
|
+
rollup['envs']['test'][type].should == 2
|
|
93
|
+
end
|
|
94
|
+
Wackamole::Mission.reset!( 'blee', 'test', 'faults' )
|
|
95
|
+
rollup = Wackamole::Mission.rollups_cltn.find_one( { :app => 'blee' } )
|
|
96
|
+
rollup['envs']['test']['faults'].should == 0
|
|
97
|
+
%w[features perfs].each do |type|
|
|
98
|
+
rollup['envs']['test'][type].should == 2
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
describe '#clean!' do
|
|
104
|
+
before( :each ) do
|
|
105
|
+
@con.drop_database( "mole_blee_test_mdb" )
|
|
106
|
+
@con.drop_database( "mole_blee_development_mdb" )
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should update the rollups if an env is no longer in the db" do
|
|
110
|
+
Fixtures.create_valid_mole_db( @con, 'blee', "test" )
|
|
111
|
+
Fixtures.create_valid_mole_db( @con, 'blee', "development" )
|
|
112
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
113
|
+
rollups.should have(2).items
|
|
114
|
+
@con.drop_database( "mole_blee_test_mdb" )
|
|
115
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
116
|
+
rollups.should have(2).items
|
|
117
|
+
rollup = Wackamole::Mission.rollups_cltn.find_one( { :app => 'blee' } )
|
|
118
|
+
rollup.should_not be_nil
|
|
119
|
+
rollup['envs'].should have(1).item
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "should remove a rollup if an app is no longer in the db" do
|
|
123
|
+
Fixtures.create_valid_mole_db( @con, 'blee', "test" )
|
|
124
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
125
|
+
rollups.should have(2).items
|
|
126
|
+
@con.drop_database( "mole_blee_test_mdb" )
|
|
127
|
+
rollups = Wackamole::Mission.rollups( @test_time, false )
|
|
128
|
+
rollups.should have(1).items
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
describe "#comp_applications" do
|
|
134
|
+
it "should gather report for a given day correctly" do
|
|
135
|
+
report = Wackamole::Mission.comb_applications( @test_time, true )
|
|
136
|
+
report.should have(1).item
|
|
137
|
+
report['fred'].should_not be_nil
|
|
138
|
+
report['fred']['envs'].should have(3).items
|
|
139
|
+
|
|
140
|
+
envs = %w[development production test]
|
|
141
|
+
expected = { 0 => 7, 1 => 7, 2 => 7}
|
|
142
|
+
report['fred']['envs'].each_pair do |env, info|
|
|
143
|
+
envs.include?( env ).should == true
|
|
144
|
+
envs = envs - [env]
|
|
145
|
+
info.should == expected
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
it "should gather report for a given time correctly" do
|
|
150
|
+
report = Wackamole::Mission.comb_applications( @test_time, false )
|
|
151
|
+
report.should have(1).item
|
|
152
|
+
report['fred'].should_not be_nil
|
|
153
|
+
report['fred']['envs'].should have(3).items
|
|
154
|
+
|
|
155
|
+
envs = %w[development production test]
|
|
156
|
+
expected = { 0 => 2, 1 => 2, 2 => 2}
|
|
157
|
+
report['fred']['envs'].each_pair do |env, info|
|
|
158
|
+
envs.include?( env ).should == true
|
|
159
|
+
envs = envs - [env]
|
|
160
|
+
info.should == expected
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
describe "#analyse_logs" do
|
|
166
|
+
before :all do
|
|
167
|
+
@db = Wackamole::Control.switch_mole_db!( "fred", "test" )
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it "should find no analyses after 2am" do
|
|
171
|
+
test_time = Chronic.parse( "2010/01/01 02:00:00" ).utc
|
|
172
|
+
analysis = Wackamole::Mission.analyse_logs( @db, test_time, false )
|
|
173
|
+
[0, 1, 2].each{ |type| analysis[type].should == 0 }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "should analyse a log for a given time correctly" do
|
|
177
|
+
test_time = Chronic.parse( "2010/01/01 01:00:00" ).utc
|
|
178
|
+
analysis = Wackamole::Mission.analyse_logs( @db, test_time, false )
|
|
179
|
+
[0, 1, 2].each{ |type| analysis[type].should == 2 }
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
it "should analyse logs for a day correctly" do
|
|
183
|
+
analysis = Wackamole::Mission.analyse_logs( @db, @test_time, true )
|
|
184
|
+
[0, 1, 2].each{ |type| analysis[type].should == 7 }
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
describe "#amend_report" do
|
|
189
|
+
it "should amend an empty report correctly" do
|
|
190
|
+
report = {}
|
|
191
|
+
%w[development test production].each do |env|
|
|
192
|
+
%w[feature fault perf].each do |type|
|
|
193
|
+
type_num = Rackamole.send( type )
|
|
194
|
+
log = { 'typ' => type_num }
|
|
195
|
+
Wackamole::Mission.amend_report( report, "fred", env, log )
|
|
196
|
+
report['fred']['envs'][env][type_num].should == 1
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
it "should amend an existing report with no recorded info correctly" do
|
|
202
|
+
report = { "fred" => { 'envs' => {} } }
|
|
203
|
+
%w[development test production].each do |env|
|
|
204
|
+
%w[feature fault perf].each do |type|
|
|
205
|
+
type_num = Rackamole.send( type )
|
|
206
|
+
log = { 'typ' => type_num }
|
|
207
|
+
Wackamole::Mission.amend_report( report, "fred", env, log )
|
|
208
|
+
report['fred']['envs'][env][type_num].should == 1
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "should amend an existing report correctly" do
|
|
214
|
+
report = { "fred" => {'envs' => { 'test' => { 0 => 1, 1 => 1, 2 => 1 } } }}
|
|
215
|
+
%w[development test production].each do |env|
|
|
216
|
+
%w[feature fault perf].each do |type|
|
|
217
|
+
type_num = Rackamole.send( type )
|
|
218
|
+
log = { 'typ' => type_num }
|
|
219
|
+
Wackamole::Mission.amend_report( report, "fred", env, log )
|
|
220
|
+
report['fred']['envs'][env][type_num].should == (env == "test" ? 2 : 1)
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
end
|