rearview 1.0.1-jruby → 1.0.2-jruby
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +65 -1
- data/app/controllers/rearview/jobs_controller.rb +1 -1
- data/app/views/devise/sessions/_database_auth.html.erb +19 -0
- data/app/views/devise/sessions/_google_oauth2_auth.html.erb +3 -0
- data/app/views/devise/sessions/new.html.erb +9 -20
- data/app/views/rearview/alert_mailer/alert_email.text.erb +1 -1
- data/db/migrate/20140106161202_add_indexes.rb +7 -0
- data/lib/generators/templates/rearview.rb +22 -1
- data/lib/rearview.rb +4 -8
- data/lib/rearview/alerts/campfire_alert.rb +1 -1
- data/lib/rearview/alerts/pagerduty_alert.rb +1 -1
- data/lib/rearview/concerns/models/user.rb +6 -0
- data/lib/rearview/configuration.rb +83 -22
- data/lib/rearview/monitor_task.rb +2 -2
- data/lib/rearview/url_helper.rb +7 -0
- data/lib/rearview/version.rb +1 -1
- data/lib/tasks/rearview_tasks.rake +16 -0
- data/spec/dummy/log/development.log +113 -0
- data/spec/dummy/log/test.log +15476 -0
- data/spec/lib/rearview/alerts/campfire_alert_spec.rb +2 -2
- data/spec/lib/rearview/configuration_spec.rb +77 -12
- data/spec/lib/rearview/url_helper_spec.rb +12 -0
- data/spec/mailers/alert_mailer_spec.rb +1 -1
- data/spec/models/user_spec.rb +17 -6
- data/spec/spec_helper.rb +1 -0
- metadata +8 -6
- data/lib/rearview/sandbox.rb +0 -47
- data/lib/rearview/uri_helper.rb +0 -7
- data/spec/lib/rearview/uri_helper_spec.rb +0 -12
@@ -19,7 +19,7 @@ describe Rearview::Alerts::CampfireAlert do
|
|
19
19
|
let(:result) { { message: "alert alert!"} }
|
20
20
|
|
21
21
|
it "notifies campfire" do
|
22
|
-
Broach.expects(:speak).with("nyan", "alert alert! #{Rearview::
|
22
|
+
Broach.expects(:speak).with("nyan", "alert alert! #{Rearview::UrlHelper.job_url(job)}")
|
23
23
|
campfire_alert.alert(job, result)
|
24
24
|
end
|
25
25
|
end
|
@@ -28,7 +28,7 @@ describe Rearview::Alerts::CampfireAlert do
|
|
28
28
|
let(:result) { { } }
|
29
29
|
|
30
30
|
it "notifies campfire" do
|
31
|
-
Broach.expects(:speak).with("nyan", "Job did not provide an error description #{Rearview::
|
31
|
+
Broach.expects(:speak).with("nyan", "Job did not provide an error description #{Rearview::UrlHelper.job_url(job)}")
|
32
32
|
campfire_alert.alert(job, result)
|
33
33
|
end
|
34
34
|
end
|
@@ -2,22 +2,81 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Rearview::Configuration do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
before do
|
6
|
+
Rearview::Configuration.any_instance.stubs(:validate_sandbox_execution).returns(true)
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:config) { Rearview::Configuration.new }
|
10
|
+
|
11
|
+
context 'validation' do
|
12
|
+
it { should validate_presence_of(:graphite_url) }
|
13
|
+
it { should validate_presence_of(:pagerduty_url) }
|
14
|
+
it { should validate_presence_of(:default_from) }
|
15
|
+
it { should validate_presence_of(:sandbox_dir) }
|
16
|
+
it { should validate_presence_of(:sandbox_exec) }
|
17
|
+
it { should validate_presence_of(:sandbox_timeout) }
|
18
|
+
it { should validate_presence_of(:default_url_options) }
|
19
|
+
it { should validate_presence_of(:authentication) }
|
20
|
+
it { should validate_numericality_of(:sandbox_timeout).is_greater_than(4) }
|
21
|
+
it "should requre sandbox_dir to be a directory" do
|
22
|
+
config.sandbox_dir="/__not_likely__"
|
23
|
+
config.valid?
|
24
|
+
expect(config.errors[:sandbox_dir]).to include("is not a directory")
|
25
|
+
config.sandbox_dir = File.dirname(__FILE__)
|
26
|
+
config.valid?
|
27
|
+
expect(config.errors[:sandbox_dir]).to be_empty
|
28
|
+
end
|
29
|
+
it "should require graphite_url to be a url" do
|
30
|
+
response = stub(code: 200)
|
31
|
+
HTTParty.stubs(:get).returns(response)
|
32
|
+
config.graphite_url="ssh://fooblah"
|
33
|
+
config.valid?
|
34
|
+
expect(config.errors[:graphite_url]).to include("is not a valid URL")
|
35
|
+
config.graphite_url="fooblah"
|
36
|
+
config.valid?
|
37
|
+
expect(config.errors[:graphite_url]).to include("is not a valid URL")
|
38
|
+
config.graphite_url="http://fooblah.com"
|
39
|
+
config.valid?
|
40
|
+
expect(config.errors[:graphite_url]).to be_empty
|
41
|
+
end
|
42
|
+
it "should require pagerduty_url to be a url" do
|
43
|
+
config.pagerduty_url="ftp://fooblah"
|
44
|
+
config.valid?
|
45
|
+
expect(config.errors[:pagerduty_url]).to include("is not a valid URL")
|
46
|
+
config.pagerduty_url="HTTPS://fooblah"
|
47
|
+
config.valid?
|
48
|
+
expect(config.errors[:pagerduty_url]).to be_empty
|
49
|
+
end
|
50
|
+
it "should require graphite_url to be reachable" do
|
51
|
+
response = stub(code: 400)
|
52
|
+
HTTParty.expects(:get).with("http://graphite.mycompany-unreachable.com").returns(response)
|
53
|
+
config.graphite_url="http://graphite.mycompany-unreachable.com"
|
54
|
+
config.valid?
|
55
|
+
expect(config.errors[:graphite_url]).to include("is not a reachable URL")
|
56
|
+
response = stub(code: 200)
|
57
|
+
HTTParty.expects(:get).with("http://graphite.mycompany.com").returns(response)
|
58
|
+
config.graphite_url="http://graphite.mycompany.com"
|
59
|
+
config.valid?
|
60
|
+
expect(config.errors[:graphite_url]).to be_empty
|
15
61
|
end
|
62
|
+
pending "should require sanbox_exec to be executable"
|
16
63
|
end
|
17
64
|
|
18
|
-
context '
|
65
|
+
context '.new' do
|
66
|
+
it 'sets sensible defaults' do
|
67
|
+
expect(config.default_from).to eq("rearview@localhost")
|
68
|
+
expect(config.pagerduty_url).to eq("https://events.pagerduty.com/generic/2010-04-15/create_event.json")
|
69
|
+
expect(config.sandbox_timeout).to eq(5)
|
70
|
+
expect(config.enable_alerts).to be_true
|
71
|
+
expect(config.preload_jobs).to be_true
|
72
|
+
expect(config.enable_monitor).to be_true
|
73
|
+
expect(config.verify).to be_false
|
74
|
+
expect(config.authentication).to eq({strategy: :database})
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context '#with_argv' do
|
19
79
|
it 'processes args as command line options' do
|
20
|
-
config = Rearview::Configuration.new
|
21
80
|
expect { config.with_argv(["--no-preload","--no-alerts","--no-monitor"]) }.not_to raise_error
|
22
81
|
expect(config.preload_jobs?).to be_false
|
23
82
|
expect(config.monitor_enabled?).to be_false
|
@@ -25,5 +84,11 @@ describe Rearview::Configuration do
|
|
25
84
|
end
|
26
85
|
end
|
27
86
|
|
87
|
+
context '#dump' do
|
88
|
+
it 'dumps a stringy version of the configuration' do
|
89
|
+
expect(config.dump).not_to be_empty
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
28
93
|
end
|
29
94
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Rearview::UrlHelper do
|
4
|
+
let(:job) { stub(app_id: 1234, id: 42) }
|
5
|
+
subject { Rearview::UrlHelper }
|
6
|
+
context ".rearview_uri" do
|
7
|
+
it "returns rearview uri" do
|
8
|
+
subject.job_url(job).should eq("http://#{Rearview.config.default_url_options[:host]}:#{Rearview.config.default_url_options[:port]}/rearview/#dash/1234/expand/42")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
@@ -29,7 +29,7 @@ describe Rearview::AlertMailer do
|
|
29
29
|
expect(mail.body.encoded).to match(/Alerted On: .*/)
|
30
30
|
end
|
31
31
|
it 'has a direct link' do
|
32
|
-
expect(mail.body.encoded).to match(%r{Direct Link:
|
32
|
+
expect(mail.body.encoded).to match(%r{Direct Link: http://localhost:3000/rearview/#dash/#{job.app_id}/expand/#{job.id}})
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -8,11 +8,22 @@ describe Rearview::User do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
describe 'validations' do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
let!(:first_user) { FactoryGirl.build(:user) }
|
12
|
+
it { should validate_presence_of(:email) }
|
13
|
+
it { should validate_uniqueness_of(:email) }
|
14
|
+
end
|
15
|
+
describe '.valid_google_oauth2_email?' do
|
16
|
+
it "should not be valid unless an email is present" do
|
17
|
+
expect(Rearview::User.valid_google_oauth2_email?(nil)).to be_false
|
18
|
+
end
|
19
|
+
it "should not be valid unless :matching_emails is present" do
|
20
|
+
Rearview.config.authentication.delete(:matching_emails)
|
21
|
+
expect(Rearview::User.valid_google_oauth2_email?("foo@foo.com")).to be_false
|
22
|
+
end
|
23
|
+
it "should not be valid unless it matches the :matching_emails regexp" do
|
24
|
+
Rearview.config.authentication[:matching_emails] = /@mycompany\.com$/
|
25
|
+
expect(Rearview::User.valid_google_oauth2_email?("foo@foo.com")).to be_false
|
26
|
+
expect(Rearview::User.valid_google_oauth2_email?("foo@mycompany.com")).to be_true
|
27
|
+
end
|
17
28
|
end
|
18
29
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rearview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: jruby
|
6
6
|
authors:
|
7
7
|
- Trent Albright
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -271,6 +271,8 @@ files:
|
|
271
271
|
- app/models/rearview/job_data.rb
|
272
272
|
- app/models/rearview/job_error.rb
|
273
273
|
- app/models/rearview/user.rb
|
274
|
+
- app/views/devise/sessions/_database_auth.html.erb
|
275
|
+
- app/views/devise/sessions/_google_oauth2_auth.html.erb
|
274
276
|
- app/views/devise/sessions/new.html.erb
|
275
277
|
- app/views/devise/shared/_links.erb
|
276
278
|
- app/views/layouts/devise/sessions.html.erb
|
@@ -297,6 +299,7 @@ files:
|
|
297
299
|
- config/initializers/unlimited_strength_cryptography.rb
|
298
300
|
- config/locales/devise.en.yml
|
299
301
|
- db/migrate/20131106162900_base_schema.rb
|
302
|
+
- db/migrate/20140106161202_add_indexes.rb
|
300
303
|
- lib/rearview.rb
|
301
304
|
- lib/generators/rearview/install_generator.rb
|
302
305
|
- lib/generators/templates/README.md
|
@@ -318,8 +321,7 @@ files:
|
|
318
321
|
- lib/rearview/monitor_supervisor.rb
|
319
322
|
- lib/rearview/monitor_task.rb
|
320
323
|
- lib/rearview/results_handler.rb
|
321
|
-
- lib/rearview/
|
322
|
-
- lib/rearview/uri_helper.rb
|
324
|
+
- lib/rearview/url_helper.rb
|
323
325
|
- lib/rearview/version.rb
|
324
326
|
- lib/rearview/alerts/base.rb
|
325
327
|
- lib/rearview/alerts/campfire_alert.rb
|
@@ -2210,7 +2212,7 @@ files:
|
|
2210
2212
|
- spec/lib/rearview/monitor_task_spec.rb
|
2211
2213
|
- spec/lib/rearview/rearview_spec.rb
|
2212
2214
|
- spec/lib/rearview/results_handler_spec.rb
|
2213
|
-
- spec/lib/rearview/
|
2215
|
+
- spec/lib/rearview/url_helper_spec.rb
|
2214
2216
|
- spec/lib/rearview/alerts/campfire_alert_spec.rb
|
2215
2217
|
- spec/lib/rearview/alerts/email_alert_spec.rb
|
2216
2218
|
- spec/lib/rearview/alerts/pagerduty_alert_spec.rb
|
@@ -2328,7 +2330,7 @@ test_files:
|
|
2328
2330
|
- spec/lib/rearview/monitor_task_spec.rb
|
2329
2331
|
- spec/lib/rearview/rearview_spec.rb
|
2330
2332
|
- spec/lib/rearview/results_handler_spec.rb
|
2331
|
-
- spec/lib/rearview/
|
2333
|
+
- spec/lib/rearview/url_helper_spec.rb
|
2332
2334
|
- spec/lib/rearview/alerts/campfire_alert_spec.rb
|
2333
2335
|
- spec/lib/rearview/alerts/email_alert_spec.rb
|
2334
2336
|
- spec/lib/rearview/alerts/pagerduty_alert_spec.rb
|
data/lib/rearview/sandbox.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
|
2
|
-
module Rearview
|
3
|
-
module Sandbox
|
4
|
-
class << self
|
5
|
-
|
6
|
-
include Rearview::Logger
|
7
|
-
|
8
|
-
def valid?
|
9
|
-
valid_exec = self.valid_exec?
|
10
|
-
valid_graphite_connection = self.valid_graphite_connection?
|
11
|
-
valid_exec && valid_graphite_connection
|
12
|
-
end
|
13
|
-
|
14
|
-
def valid_exec?
|
15
|
-
script_file = File.join(Rearview.config.sandbox_dir,"verify_sandbox.rb")
|
16
|
-
cmd = Rearview.config.sandbox_exec.clone << script_file
|
17
|
-
logger.info "#{self} checking sandbox with #{cmd}"
|
18
|
-
process_builder = ProcessBuilder.new(cmd).redirectErrorStream(true)
|
19
|
-
process_builder.directory(java.io.File.new(Rearview.config.sandbox_dir.to_s))
|
20
|
-
process_builder.environment.delete("GEM_HOME")
|
21
|
-
process_builder.environment.delete("GEM_PATH")
|
22
|
-
process = process_builder.start
|
23
|
-
exit_code = process.waitFor
|
24
|
-
output = process.get_input_stream.to_io.read
|
25
|
-
logger.info "#{self} sandbox execution: \n#{output}"
|
26
|
-
unless exit_code == 0
|
27
|
-
logger.error "#{self} unable to execute in sandbox"
|
28
|
-
end
|
29
|
-
exit_code == 0
|
30
|
-
end
|
31
|
-
|
32
|
-
def valid_graphite_connection?
|
33
|
-
url = "#{Rearview.config.graphite_url}/dashboard"
|
34
|
-
logger.info "#{self} checking graphite connection to #{url}"
|
35
|
-
response = HTTParty.get(url)
|
36
|
-
unless response.code == 200
|
37
|
-
logger.error "#{self} unable to communicate with graphite"
|
38
|
-
end
|
39
|
-
response.code == 200
|
40
|
-
rescue
|
41
|
-
logger.error "#{self} unable to communicate with graphite #{$!}"
|
42
|
-
false
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/rearview/uri_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rearview::UriHelper do
|
4
|
-
let(:job) { stub(app_id: 1234, id: 42) }
|
5
|
-
subject { Rearview::UriHelper }
|
6
|
-
|
7
|
-
context ".rearview_uri" do
|
8
|
-
it "returns rearview uri" do
|
9
|
-
subject.rearview_uri(job).should eq("https://rearview.livingsocial.net/#dash/1234/expand/42")
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|