ops 1.0.0.pre → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -7
- data/lib/ops.rb +2 -3
- data/lib/ops/config.rb +8 -8
- data/lib/ops/heartbeat.rb +4 -7
- data/lib/ops/revision.rb +89 -31
- data/lib/ops/server.rb +22 -12
- data/lib/ops/server/helpers.rb +6 -14
- data/lib/ops/server/views/{env.html.erb → env.erb} +0 -0
- data/lib/ops/server/views/{layout.html.erb → layout.erb} +0 -0
- data/lib/ops/server/views/version.erb +76 -0
- data/lib/ops/version.rb +1 -1
- metadata +25 -73
- data/.gitignore +0 -18
- data/.rspec +0 -2
- data/Gemfile +0 -16
- data/Gemfile.lock +0 -129
- data/LICENSE +0 -7
- data/Rakefile +0 -28
- data/examples/rails3/.gitignore +0 -15
- data/examples/rails3/.rspec +0 -3
- data/examples/rails3/Gemfile +0 -5
- data/examples/rails3/Gemfile.lock +0 -130
- data/examples/rails3/Rakefile +0 -13
- data/examples/rails3/config.ru +0 -4
- data/examples/rails3/config/application.rb +0 -37
- data/examples/rails3/config/boot.rb +0 -6
- data/examples/rails3/config/environment.rb +0 -5
- data/examples/rails3/config/initializers/secret_token.rb +0 -1
- data/examples/rails3/config/locales/en.yml +0 -5
- data/examples/rails3/config/routes.rb +0 -3
- data/examples/rails3/public/404.html +0 -26
- data/examples/rails3/public/422.html +0 -26
- data/examples/rails3/public/500.html +0 -25
- data/examples/rails3/public/favicon.ico +0 -0
- data/examples/rails3/public/index.html +0 -14
- data/examples/rails3/public/robots.txt +0 -5
- data/examples/rails3/script/rails +0 -6
- data/examples/rails3/spec/functional/ops_routes_spec.rb +0 -69
- data/examples/rails3/spec/spec_helper.rb +0 -5
- data/examples/sample_deploys/1234/REVISION +0 -1
- data/examples/sample_deploys/1234/VERSION +0 -1
- data/examples/sample_deploys/2341/REVISION +0 -1
- data/examples/sample_deploys/2341/VERSION +0 -1
- data/examples/sample_deploys/3412/REVISION +0 -1
- data/examples/sample_deploys/3412/VERSION +0 -1
- data/examples/sample_deploys/4123/REVISION +0 -1
- data/examples/sample_deploys/4123/VERSION +0 -1
- data/examples/sinatra/.rspec +0 -3
- data/examples/sinatra/Rakefile +0 -15
- data/examples/sinatra/app.rb +0 -14
- data/examples/sinatra/config.ru +0 -20
- data/examples/sinatra/spec/functional/ops_routes_spec.rb +0 -69
- data/examples/sinatra/spec/spec_helper.rb +0 -3
- data/lib/ops/server/views/version.html.erb +0 -53
- data/ops.gemspec +0 -22
- data/spec/functional/ops_routes_spec.rb +0 -69
- data/spec/ops/config_spec.rb +0 -0
- data/spec/ops/heartbeat_spec.rb +0 -49
- data/spec/ops/revision_spec.rb +0 -42
- data/spec/ops/server_spec.rb +0 -66
- data/spec/ops/version_spec.rb +0 -7
- data/spec/ops_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -11
@@ -1,53 +0,0 @@
|
|
1
|
-
<div class="container">
|
2
|
-
<div class="spacer"></div>
|
3
|
-
<div id="host">
|
4
|
-
<div class="label">Host</div>
|
5
|
-
<div class="value"><%= hostname %></div>
|
6
|
-
</div>
|
7
|
-
<div class="spacer"></div>
|
8
|
-
<div id="environment">
|
9
|
-
<div class="label">Environment</div>
|
10
|
-
<div class="value"><%= @version.environment %></div>
|
11
|
-
</div>
|
12
|
-
<div class="spacer"></div>
|
13
|
-
<h3>Current Deploy Info</h3>
|
14
|
-
<% @version.info.each do |key, value| %>
|
15
|
-
<div class="spacer"></div>
|
16
|
-
<div>
|
17
|
-
<div class="label">
|
18
|
-
<%= key.to_s.gsub('_',' ').capitalize %>
|
19
|
-
</div>
|
20
|
-
<div class="value">
|
21
|
-
<%= value %>
|
22
|
-
</div>
|
23
|
-
</div>
|
24
|
-
<% end %>
|
25
|
-
<div class="spacer"></div>
|
26
|
-
<h3>Previous Deploy Info</h3>
|
27
|
-
<% @version.previous_info.each do |key, value| %>
|
28
|
-
<div class="spacer"></div>
|
29
|
-
<div>
|
30
|
-
<div class="label">
|
31
|
-
<%= key.to_s.gsub('_',' ').capitalize %>
|
32
|
-
</div>
|
33
|
-
<div class="value">
|
34
|
-
<%= value %>
|
35
|
-
</div>
|
36
|
-
</div>
|
37
|
-
<% end %>
|
38
|
-
<div class="spacer"></div>
|
39
|
-
<div id="headers">
|
40
|
-
<div class="label">Headers</div>
|
41
|
-
<div class="value">
|
42
|
-
<table>
|
43
|
-
<% @headers.sort_by{ |h| h.first }.each_with_index do |(header, value), i| %>
|
44
|
-
<tr class="<%= i%2==0 ? 'even' : nil %>">
|
45
|
-
<td><%= header %></td>
|
46
|
-
<td><%= value %></td>
|
47
|
-
</tr>
|
48
|
-
<% end %>
|
49
|
-
</table>
|
50
|
-
</div>
|
51
|
-
</div>
|
52
|
-
<div class="clear"></div>
|
53
|
-
</div>
|
data/ops.gemspec
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../lib/ops/version', __FILE__)
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
Gem::Specification.new do |gem|
|
6
|
-
gem.authors = ["Michael Pelz-Sherman", "Colin Rymer", "Luke Fender", "RentPath Team"]
|
7
|
-
gem.email = ["mpelzsherman@gmail.com", "colin.rymer@gmail.com", "lfender6445@gmail.com"]
|
8
|
-
gem.description = 'This gem provides standardized support for obtaining version and heartbeat information from Sinatra or Rails-based web applications.'
|
9
|
-
gem.summary = "Provide ops info endpoints."
|
10
|
-
gem.date = Date.today.to_s
|
11
|
-
gem.homepage = "http://rentpath.github.io/ops/"
|
12
|
-
gem.license = 'MIT'
|
13
|
-
gem.executables = []
|
14
|
-
gem.files = `git ls-files | grep -v myapp`.split("\n")
|
15
|
-
gem.test_files = `git ls-files -- test/*`.split("\n")
|
16
|
-
gem.name = "ops"
|
17
|
-
gem.require_paths = ["lib"]
|
18
|
-
gem.version = Ops::VERSION
|
19
|
-
gem.required_ruby_version = '>= 1.9'
|
20
|
-
gem.add_dependency 'sinatra', '>= 1.2.0'
|
21
|
-
gem.add_dependency 'sinatra-respond_to', '>= 0.7.0'
|
22
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'rack/test'
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'json'
|
5
|
-
|
6
|
-
RSpec::Matchers.define :have_content_type do |content_type|
|
7
|
-
CONTENT_HEADER_MATCHER = /^([A-Za-z]+\/[\w\-+\.]+)(;charset=(.*))?/
|
8
|
-
|
9
|
-
chain :with_charset do |charset|
|
10
|
-
@charset = charset
|
11
|
-
end
|
12
|
-
|
13
|
-
match do |response|
|
14
|
-
_, content, _, charset = *content_type_header.match(CONTENT_HEADER_MATCHER).to_a
|
15
|
-
|
16
|
-
if @charset
|
17
|
-
@charset == charset && content == content_type
|
18
|
-
else
|
19
|
-
content == content_type
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
failure_message_for_should do |response|
|
24
|
-
if @charset
|
25
|
-
"Content type #{content_type_header.inspect} should match #{content_type.inspect} with charset #{@charset}"
|
26
|
-
else
|
27
|
-
"Content type #{content_type_header.inspect} should match #{content_type.inspect}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
failure_message_for_should_not do |model|
|
32
|
-
if @charset
|
33
|
-
"Content type #{content_type_header.inspect} should not match #{content_type.inspect} with charset #{@charset}"
|
34
|
-
else
|
35
|
-
"Content type #{content_type_header.inspect} should not match #{content_type.inspect}"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def content_type_header
|
40
|
-
last_response.headers['Content-Type']
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'routes', :type => :controller do
|
45
|
-
include Rack::Test::Methods
|
46
|
-
|
47
|
-
|
48
|
-
it 'renders a env page' do
|
49
|
-
get "/ops/env"
|
50
|
-
last_response.should be_ok
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'renders a version page' do
|
54
|
-
get "/ops/version"
|
55
|
-
last_response.should be_ok
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'renders a json version page' do
|
59
|
-
get "/ops/version.json"
|
60
|
-
last_response.should be_ok
|
61
|
-
last_response.should have_content_type('application/json').with_charset('utf-8')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'renders a heartbeat page' do
|
65
|
-
get "/ops/heartbeat"
|
66
|
-
last_response.should be_ok
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
data/spec/ops/config_spec.rb
DELETED
File without changes
|
data/spec/ops/heartbeat_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ops::Heartbeat do
|
4
|
-
describe '#add' do
|
5
|
-
it 'accepts new heartbeats' do
|
6
|
-
@heartbeat = Ops::Heartbeat.new
|
7
|
-
@heartbeat.add(:test){ true }
|
8
|
-
@heartbeat.heartbeats.should have(1).items
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#check' do
|
13
|
-
before do
|
14
|
-
@heartbeat = Ops::Heartbeat.new
|
15
|
-
@heartbeat.add(:test){ true }
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns true for valid heartbeats' do
|
19
|
-
@heartbeat.check(:test).should eq(true)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns false for invalid heartbeats' do
|
23
|
-
@heartbeat.check(:invalid_test).should eq(false)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe '#heartbeats' do
|
28
|
-
it 'returns a hash of heartbeats' do
|
29
|
-
Ops::Heartbeat.new.heartbeats.should be_a Hash
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
it "offers a singleton" do
|
34
|
-
@heartbeat = Ops::Heartbeat.instance
|
35
|
-
@heartbeat.object_id.should be Ops::Heartbeat.instance.object_id
|
36
|
-
end
|
37
|
-
|
38
|
-
it "checks singleton's heartbeats" do
|
39
|
-
Ops::Heartbeat.instance.add(:test){ true }
|
40
|
-
Ops::Heartbeat.check(:test).should be true
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe Ops do
|
45
|
-
it "provides convenience method to add heartbeats" do
|
46
|
-
Ops.add_heartbeat(:convenience){ true }
|
47
|
-
Ops::Heartbeat.check(:convenience).should be true
|
48
|
-
end
|
49
|
-
end
|
data/spec/ops/revision_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Ops::Revision do
|
4
|
-
|
5
|
-
let(:create_version_file) do
|
6
|
-
@version_file = File.join(@root, 'VERSION')
|
7
|
-
File.open(@version_file, 'w') { |f| f.write('v23.24.25^{}') }
|
8
|
-
end
|
9
|
-
|
10
|
-
before do
|
11
|
-
@root = File.dirname(__FILE__)
|
12
|
-
headers = {}
|
13
|
-
settings = double("settings", {:file_root => @root, :environment => 'test'})
|
14
|
-
@version = Ops::Revision.new(headers, settings)
|
15
|
-
end
|
16
|
-
|
17
|
-
after do
|
18
|
-
File.delete(@version_file) unless @version_file.nil?
|
19
|
-
end
|
20
|
-
|
21
|
-
it "test env should have version" do
|
22
|
-
create_version_file
|
23
|
-
@version.version_or_branch.should eq("v23.24.25")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "development env should have branch" do
|
27
|
-
dev_settings = double("settings", {:file_root => @root, :environment => 'development'})
|
28
|
-
dev_version = Ops::Revision.new({}, dev_settings)
|
29
|
-
dev_version.branch_source = ->{ "* dev\nsome-topic-branch\nother-topic-branch" }
|
30
|
-
dev_version.version_or_branch.should eq('dev')
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should have request headers" do
|
34
|
-
headers = {'ABC' => '123', 'hidden' => 'x'}
|
35
|
-
settings = double("settings", {:file_root => @root, :environment => 'test'})
|
36
|
-
version = Ops::Revision.new(headers, settings)
|
37
|
-
version.headers.should eq({'ABC' => '123'})
|
38
|
-
end
|
39
|
-
|
40
|
-
# TODO: add tests for json and previous_version
|
41
|
-
|
42
|
-
end
|
data/spec/ops/server_spec.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack/test'
|
3
|
-
require 'ops/server'
|
4
|
-
|
5
|
-
class ReliableConfigService
|
6
|
-
def call(options = {})
|
7
|
-
{ foo: 'bar' }
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
class ErrorProneConfigService
|
12
|
-
def call(options = {})
|
13
|
-
raise StandardError, 'oops'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe Ops::Server do
|
18
|
-
include Rack::Test::Methods
|
19
|
-
|
20
|
-
def app
|
21
|
-
Ops::Server
|
22
|
-
end
|
23
|
-
|
24
|
-
def enable_config_service(adapter)
|
25
|
-
Ops.setup do |config|
|
26
|
-
config.config_service_adapter = adapter
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def disable_config_service
|
31
|
-
Ops.setup do |config|
|
32
|
-
config.config_service_adapter = nil
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe 'GET /config' do
|
37
|
-
describe 'when config service is enabled' do
|
38
|
-
it 'responds with response from config service' do
|
39
|
-
enable_config_service(ReliableConfigService.new)
|
40
|
-
get '/config'
|
41
|
-
last_response.status.should == 200
|
42
|
-
body = JSON.parse(last_response.body)
|
43
|
-
body.should == { 'foo' => 'bar' }
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'responds with an error from config service' do
|
47
|
-
enable_config_service(ErrorProneConfigService.new)
|
48
|
-
get '/config'
|
49
|
-
last_response.status.should == 422
|
50
|
-
body = JSON.parse(last_response.body)
|
51
|
-
body.should == { 'error' => 'oops' }
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe 'when config service is disabled' do
|
56
|
-
before do
|
57
|
-
disable_config_service
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'responds with an error' do
|
61
|
-
get '/config'
|
62
|
-
last_response.status.should == 501
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/spec/ops/version_spec.rb
DELETED
data/spec/ops_spec.rb
DELETED
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
SimpleCov.start
|
3
|
-
|
4
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
6
|
-
require 'rspec'
|
7
|
-
require 'ops'
|
8
|
-
|
9
|
-
# Requires supporting files with custom matchers and macros, etc,
|
10
|
-
# in ./support/ and its subdirectories.
|
11
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|