litmus_paper 0.3.5 → 0.4.0
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/bin/litmusctl +4 -0
- data/lib/litmus_paper/app.rb +47 -27
- data/lib/litmus_paper/cli/admin/command.rb +25 -0
- data/lib/litmus_paper/cli/admin/force.rb +41 -0
- data/lib/litmus_paper/cli/admin/list.rb +21 -0
- data/lib/litmus_paper/cli/admin/status.rb +23 -0
- data/lib/litmus_paper/cli/admin.rb +19 -65
- data/lib/litmus_paper/service.rb +3 -8
- data/lib/litmus_paper/status_file.rb +30 -2
- data/lib/litmus_paper/version.rb +1 -1
- data/spec/litmus_paper/app_spec.rb +45 -27
- data/spec/litmus_paper/cli/admin_spec.rb +6 -0
- data/spec/litmus_paper/service_spec.rb +4 -4
- data/spec/litmus_paper/status_file_spec.rb +3 -10
- metadata +124 -66
data/bin/litmusctl
CHANGED
@@ -3,5 +3,9 @@
|
|
3
3
|
require 'optparse'
|
4
4
|
require 'litmus_paper'
|
5
5
|
require 'litmus_paper/cli/admin'
|
6
|
+
require 'litmus_paper/cli/admin/command'
|
7
|
+
require 'litmus_paper/cli/admin/list'
|
8
|
+
require 'litmus_paper/cli/admin/force'
|
9
|
+
require 'litmus_paper/cli/admin/status'
|
6
10
|
|
7
11
|
LitmusPaper::CLI::Admin.new.run
|
data/lib/litmus_paper/app.rb
CHANGED
@@ -1,63 +1,83 @@
|
|
1
1
|
module LitmusPaper
|
2
2
|
class App < Sinatra::Base
|
3
3
|
get "/" do
|
4
|
-
output = "Litmus Paper #{LitmusPaper::VERSION}\n"
|
4
|
+
output = "Litmus Paper #{LitmusPaper::VERSION}\n\n"
|
5
5
|
output += "Services monitored:\n"
|
6
|
-
|
6
|
+
LitmusPaper.services.each do |service_name, service|
|
7
|
+
output += "* #{service_name} (#{service.current_health.value})\n"
|
8
|
+
end
|
7
9
|
|
8
|
-
|
10
|
+
_text 200, output
|
9
11
|
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
statusfile.create(params[:reason])
|
13
|
+
delete "/down" do
|
14
|
+
_delete_status_file(StatusFile.global_down_file)
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
post "/down" do
|
18
|
+
_create_status_file(StatusFile.global_down_file)
|
17
19
|
end
|
18
20
|
|
19
|
-
delete "/
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
text 404, "NOT FOUND"
|
27
|
-
end
|
21
|
+
delete "/up" do
|
22
|
+
_delete_status_file(StatusFile.global_up_file)
|
23
|
+
end
|
24
|
+
|
25
|
+
post "/up" do
|
26
|
+
_create_status_file(StatusFile.global_up_file)
|
28
27
|
end
|
29
28
|
|
30
29
|
get "/:service/status" do
|
31
30
|
health = LitmusPaper.check_service(params[:service])
|
32
31
|
if health.nil?
|
33
|
-
|
32
|
+
_text 404, "NOT FOUND", { "X-Health" => "0" }
|
34
33
|
else
|
35
34
|
response_code = health.ok? ? 200 : 503
|
36
35
|
body = "Health: #{health.value}\n"
|
37
36
|
body << health.summary
|
38
|
-
|
37
|
+
_text response_code, body, { "X-Health" => health.value.to_s }
|
39
38
|
end
|
40
39
|
end
|
41
40
|
|
41
|
+
delete "/:service/down" do
|
42
|
+
_delete_status_file(StatusFile.service_down_file(params[:service]))
|
43
|
+
end
|
44
|
+
|
45
|
+
post "/:service/down" do
|
46
|
+
_create_status_file(StatusFile.service_down_file(params[:service]))
|
47
|
+
end
|
48
|
+
|
49
|
+
delete "/:service/up" do
|
50
|
+
_delete_status_file(StatusFile.service_up_file(params[:service]))
|
51
|
+
end
|
52
|
+
|
53
|
+
post "/:service/up" do
|
54
|
+
_create_status_file(StatusFile.service_up_file(params[:service]))
|
55
|
+
end
|
56
|
+
|
42
57
|
get "/test/error" do
|
43
58
|
raise "an error"
|
44
59
|
end
|
45
60
|
|
46
61
|
error do
|
47
|
-
|
62
|
+
_text 500, "Server Error"
|
48
63
|
end
|
49
64
|
|
50
|
-
def
|
51
|
-
|
65
|
+
def _create_status_file(status_file)
|
66
|
+
status_file.create(params[:reason])
|
67
|
+
_text 201, "File created"
|
52
68
|
end
|
53
69
|
|
54
|
-
def
|
55
|
-
|
56
|
-
|
57
|
-
|
70
|
+
def _delete_status_file(status_file)
|
71
|
+
if status_file.exists?
|
72
|
+
status_file.delete
|
73
|
+
_text 200, "File deleted"
|
58
74
|
else
|
59
|
-
|
75
|
+
_text 404, "NOT FOUND"
|
60
76
|
end
|
61
77
|
end
|
78
|
+
|
79
|
+
def _text(response_code, body, headers ={})
|
80
|
+
[response_code, { "Content-Type" => "text/plain" }.merge(headers), body]
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module LitmusPaper
|
2
|
+
module CLI
|
3
|
+
class Admin
|
4
|
+
class Command
|
5
|
+
def self._default_options
|
6
|
+
options = { :port => 9292, :host => 'localhost' }
|
7
|
+
end
|
8
|
+
|
9
|
+
def self._extend_default_parser(options, &block)
|
10
|
+
OptionParser.new do |opts|
|
11
|
+
block.call(opts)
|
12
|
+
|
13
|
+
opts.on("-p", "--port=port", Integer, "Port litmus is running on", "Default: 9292") do |port|
|
14
|
+
options[:port] = port
|
15
|
+
end
|
16
|
+
opts.on("-h", "--host=ip", String, ":Host litmus is running on", "Default: localhost") do |host|
|
17
|
+
options[:host] = host
|
18
|
+
end
|
19
|
+
opts.on("--help", "Show this help message.") { puts opts; exit }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module LitmusPaper
|
2
|
+
module CLI
|
3
|
+
class Admin
|
4
|
+
class Force < Command
|
5
|
+
def self.description
|
6
|
+
"Force services up or down"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.build_request(options, args)
|
10
|
+
options.merge! _default_options
|
11
|
+
opt_parser = _extend_default_parser(options) do |opts|
|
12
|
+
opts.banner = "Usage: litmusctl force <up|down> [service] [options]"
|
13
|
+
opts.on("-d", "--delete", "Remove status file") do
|
14
|
+
options[:delete] = true
|
15
|
+
end
|
16
|
+
opts.on("-r", "--reason=reason", String, "Reason for status file") do |reason|
|
17
|
+
options[:reason] = reason
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
opt_parser.parse! args
|
22
|
+
direction, service = args
|
23
|
+
path = service ? "/#{service}/#{direction}" : "/#{direction}"
|
24
|
+
|
25
|
+
if options[:delete]
|
26
|
+
request = Net::HTTP::Delete.new(path)
|
27
|
+
else
|
28
|
+
if !options.has_key?(:reason)
|
29
|
+
print "Reason? "
|
30
|
+
options[:reason] = STDIN.gets.chomp
|
31
|
+
end
|
32
|
+
request = Net::HTTP::Post.new(path)
|
33
|
+
request.set_form_data('reason' => options[:reason])
|
34
|
+
end
|
35
|
+
|
36
|
+
request
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module LitmusPaper
|
2
|
+
module CLI
|
3
|
+
class Admin
|
4
|
+
class List < Command
|
5
|
+
def self.description
|
6
|
+
"List services"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.build_request(options, args)
|
10
|
+
options.merge! _default_options
|
11
|
+
opt_parser = _extend_default_parser(options) do |opts|
|
12
|
+
opts.banner = "Usage: litmusctl list [options]"
|
13
|
+
end
|
14
|
+
opt_parser.parse! args
|
15
|
+
|
16
|
+
Net::HTTP::Get.new("/")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module LitmusPaper
|
2
|
+
module CLI
|
3
|
+
class Admin
|
4
|
+
class Status < Command
|
5
|
+
def self.description
|
6
|
+
"Show service status"
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.build_request(options, args)
|
10
|
+
options.merge! _default_options
|
11
|
+
opt_parser = _extend_default_parser(options) do |opts|
|
12
|
+
opts.banner = "Usage: litmusctl status <service> [options]"
|
13
|
+
end
|
14
|
+
|
15
|
+
opt_parser.parse! args
|
16
|
+
service = args.shift
|
17
|
+
|
18
|
+
Net::HTTP::Get.new("/#{service}/status")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,79 +1,33 @@
|
|
1
1
|
module LitmusPaper
|
2
2
|
module CLI
|
3
3
|
class Admin
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
options = _default_options
|
11
|
-
opt_parser = _extend_default_parser(options) do |opts|
|
12
|
-
opts.banner = "Usage: litmusctl list [options]"
|
13
|
-
end
|
14
|
-
opt_parser.parse! args
|
15
|
-
|
16
|
-
request = Net::HTTP::Get.new("/")
|
17
|
-
_litmus_request(options[:host], options[:port], request)
|
4
|
+
def self.commands
|
5
|
+
{
|
6
|
+
"list" => LitmusPaper::CLI::Admin::List,
|
7
|
+
"force" => LitmusPaper::CLI::Admin::Force,
|
8
|
+
"status" => LitmusPaper::CLI::Admin::Status
|
9
|
+
}
|
18
10
|
end
|
19
11
|
|
20
|
-
def
|
21
|
-
|
22
|
-
opt_parser = _extend_default_parser(options) do |opts|
|
23
|
-
opts.banner = "Usage: litmusctl force <up|down> [service] [options]"
|
24
|
-
opts.on("-d", "--delete", "Remove status file") do
|
25
|
-
options[:delete] = true
|
26
|
-
end
|
27
|
-
opts.on("-r", "--reason=reason", String, "Reason for status file") do |reason|
|
28
|
-
options[:reason] = reason
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
opt_parser.parse! args
|
33
|
-
direction, service = args
|
12
|
+
def run(argv = ARGV)
|
13
|
+
command_name = argv.shift
|
34
14
|
|
35
|
-
if
|
36
|
-
|
15
|
+
if command = Admin.commands[command_name]
|
16
|
+
options = {}
|
17
|
+
request = command.build_request(options, argv)
|
18
|
+
_litmus_request(options[:host], options[:port], request)
|
37
19
|
else
|
38
|
-
|
39
|
-
print "Reason? "
|
40
|
-
options[:reason] = gets.chomp
|
41
|
-
end
|
42
|
-
request = Net::HTTP::Post.new("/force/#{direction}/#{service}")
|
43
|
-
request.set_form_data('reason' => options[:reason])
|
20
|
+
_display_help
|
44
21
|
end
|
45
|
-
|
46
|
-
_litmus_request(options[:host], options[:port], request)
|
47
|
-
end
|
48
|
-
|
49
|
-
def status(args)
|
50
|
-
options = _default_options
|
51
|
-
opt_parser = _extend_default_parser(options) do |opts|
|
52
|
-
opts.banner = "Usage: litmusctl status <service> [options]"
|
53
|
-
end
|
54
|
-
|
55
|
-
opt_parser.parse! args
|
56
|
-
service = args.shift
|
57
|
-
|
58
|
-
_litmus_request(options[:host], options[:port], Net::HTTP::Get.new("/#{service}/status"))
|
59
22
|
end
|
60
23
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
OptionParser.new do |opts|
|
67
|
-
block.call(opts)
|
68
|
-
|
69
|
-
opts.on("-p", "--port=port", Integer, "Port litmus is running on", "Default: 9292") do |port|
|
70
|
-
options[:port] = port
|
71
|
-
end
|
72
|
-
opts.on("-h", "--host=ip", String, ":Host litmus is running on", "Default: localhost") do |host|
|
73
|
-
options[:host] = host
|
74
|
-
end
|
75
|
-
opts.on("--help", "Show this help message.") { puts opts; exit }
|
24
|
+
def _display_help
|
25
|
+
puts "Litmus Paper CLI v#{LitmusPaper::VERSION}\n\n"
|
26
|
+
puts "Commands:\n"
|
27
|
+
Admin.commands.keys.sort.each do |name|
|
28
|
+
puts " %-8s %s" % [name, Admin.commands[name].description]
|
76
29
|
end
|
30
|
+
puts "\nSee 'litmusctl <command> --help' for more information on a specific command"
|
77
31
|
end
|
78
32
|
|
79
33
|
def _litmus_request(host, port, request)
|
data/lib/litmus_paper/service.rb
CHANGED
@@ -30,17 +30,12 @@ module LitmusPaper
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def _health_files
|
33
|
-
@
|
34
|
-
[0, LitmusPaper::StatusFile.new('down', @name)],
|
35
|
-
[100, LitmusPaper::StatusFile.new('up', @name)],
|
36
|
-
[0, LitmusPaper::StatusFile.new('global_down')],
|
37
|
-
[100, LitmusPaper::StatusFile.new('global_up')]
|
38
|
-
]
|
33
|
+
StatusFile.priority_check_order_for_service(@name)
|
39
34
|
end
|
40
35
|
|
41
36
|
def _determine_forced_health
|
42
|
-
_health_files.map do |
|
43
|
-
ForcedHealth.new(health, status_file.content) if status_file.exists?
|
37
|
+
_health_files.map do |status_file|
|
38
|
+
ForcedHealth.new(status_file.health, status_file.content) if status_file.exists?
|
44
39
|
end.compact.first
|
45
40
|
end
|
46
41
|
end
|
@@ -1,7 +1,35 @@
|
|
1
1
|
module LitmusPaper
|
2
2
|
class StatusFile
|
3
|
-
|
4
|
-
|
3
|
+
attr_reader :health
|
4
|
+
|
5
|
+
def self.global_down_file
|
6
|
+
new("global_down", 0)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.global_up_file
|
10
|
+
new("global_up", 100)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.service_down_file(service_name)
|
14
|
+
new("#{service_name}_down", 0)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.service_up_file(service_name)
|
18
|
+
new("#{service_name}_up", 100)
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.priority_check_order_for_service(service_name)
|
22
|
+
[
|
23
|
+
global_down_file,
|
24
|
+
global_up_file,
|
25
|
+
service_down_file(service_name),
|
26
|
+
service_up_file(service_name)
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
def initialize(filename, health)
|
31
|
+
@path = File.join(LitmusPaper.config_dir, filename)
|
32
|
+
@health = health
|
5
33
|
end
|
6
34
|
|
7
35
|
def content
|
data/lib/litmus_paper/version.rb
CHANGED
@@ -23,38 +23,52 @@ describe LitmusPaper::App do
|
|
23
23
|
last_response.status.should == 200
|
24
24
|
last_response.body.should include("Litmus Paper #{LitmusPaper::VERSION}")
|
25
25
|
end
|
26
|
+
|
27
|
+
it "includes the health of the service" do
|
28
|
+
LitmusPaper.services['test'] = LitmusPaper::Service.new('test')
|
29
|
+
LitmusPaper.services['another'] = LitmusPaper::Service.new('another')
|
30
|
+
|
31
|
+
get "/"
|
32
|
+
|
33
|
+
last_response.status.should == 200
|
34
|
+
last_response.body.should include("* test (0)\n")
|
35
|
+
end
|
26
36
|
end
|
27
37
|
|
28
|
-
describe "POST /
|
38
|
+
describe "POST /up" do
|
29
39
|
it "creates a global upfile" do
|
30
40
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
31
41
|
LitmusPaper.services['test'] = test_service
|
32
42
|
|
33
|
-
post "/
|
43
|
+
post "/up", :reason => "up for testing"
|
34
44
|
last_response.status.should == 201
|
35
45
|
|
36
46
|
get "/test/status"
|
37
47
|
last_response.status.should == 200
|
38
48
|
last_response.body.should match(/up for testing/)
|
39
49
|
end
|
50
|
+
end
|
40
51
|
|
52
|
+
describe "POST /down" do
|
41
53
|
it "creates a global downfile" do
|
42
54
|
test_service = LitmusPaper::Service.new('test', [AlwaysAvailableDependency.new], [ConstantMetric.new(100)])
|
43
55
|
LitmusPaper.services['test'] = test_service
|
44
56
|
|
45
|
-
post "/
|
57
|
+
post "/down", :reason => "down for testing"
|
46
58
|
last_response.status.should == 201
|
47
59
|
|
48
60
|
get "/test/status"
|
49
61
|
last_response.status.should == 503
|
50
62
|
last_response.body.should match(/down for testing/)
|
51
63
|
end
|
64
|
+
end
|
52
65
|
|
66
|
+
describe "POST /:service/up" do
|
53
67
|
it "creates a service specific upfile" do
|
54
68
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
55
69
|
LitmusPaper.services['test'] = test_service
|
56
70
|
|
57
|
-
post "/
|
71
|
+
post "/test/up", :reason => "up for testing"
|
58
72
|
last_response.status.should == 201
|
59
73
|
|
60
74
|
get "/test/status"
|
@@ -63,18 +77,18 @@ describe LitmusPaper::App do
|
|
63
77
|
end
|
64
78
|
end
|
65
79
|
|
66
|
-
describe "DELETE /
|
80
|
+
describe "DELETE /up" do
|
67
81
|
it "removes the global upfile" do
|
68
82
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
69
83
|
LitmusPaper.services['test'] = test_service
|
70
84
|
|
71
|
-
post "/
|
85
|
+
post "/up", :reason => "up for testing"
|
72
86
|
last_response.status.should == 201
|
73
87
|
|
74
88
|
get "/test/status"
|
75
89
|
last_response.status.should == 200
|
76
90
|
|
77
|
-
delete "/
|
91
|
+
delete "/up"
|
78
92
|
last_response.status.should == 200
|
79
93
|
|
80
94
|
get "/test/status"
|
@@ -82,49 +96,53 @@ describe LitmusPaper::App do
|
|
82
96
|
last_response.body.should_not match(/up for testing/)
|
83
97
|
end
|
84
98
|
|
99
|
+
it "404s if there is no upfile" do
|
100
|
+
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
101
|
+
|
102
|
+
delete "/up"
|
103
|
+
|
104
|
+
last_response.status.should == 404
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
describe "DELETE /down" do
|
85
109
|
it "removes the global downfile" do
|
86
110
|
test_service = LitmusPaper::Service.new('test', [AlwaysAvailableDependency.new], [ConstantMetric.new(100)])
|
87
111
|
LitmusPaper.services['test'] = test_service
|
88
112
|
|
89
|
-
post "/
|
113
|
+
post "/down", :reason => "down for testing"
|
90
114
|
last_response.status.should == 201
|
91
115
|
|
92
116
|
get "/test/status"
|
93
117
|
last_response.status.should == 503
|
94
118
|
|
95
|
-
delete "/
|
119
|
+
delete "/down"
|
96
120
|
last_response.status.should == 200
|
97
121
|
|
98
122
|
get "/test/status"
|
99
123
|
last_response.should be_ok
|
100
124
|
last_response.body.should_not match(/down for testing/)
|
101
125
|
end
|
126
|
+
end
|
102
127
|
|
128
|
+
describe "DELETE /:service/up" do
|
103
129
|
it "removes a service specific upfile" do
|
104
130
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
105
131
|
LitmusPaper.services['test'] = test_service
|
106
132
|
|
107
|
-
post "/
|
133
|
+
post "/test/up", :reason => "up for testing"
|
108
134
|
last_response.status.should == 201
|
109
135
|
|
110
136
|
get "/test/status"
|
111
137
|
last_response.status.should == 200
|
112
138
|
last_response.body.should match(/up for testing/)
|
113
139
|
|
114
|
-
delete "/
|
140
|
+
delete "/test/up"
|
115
141
|
last_response.status.should == 200
|
116
142
|
|
117
143
|
get "/test/status"
|
118
144
|
last_response.status.should == 503
|
119
145
|
end
|
120
|
-
|
121
|
-
it "404s if there is no upfile" do
|
122
|
-
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
123
|
-
|
124
|
-
delete "/up"
|
125
|
-
|
126
|
-
last_response.status.should == 404
|
127
|
-
end
|
128
146
|
end
|
129
147
|
|
130
148
|
describe "GET /:service/status" do
|
@@ -165,8 +183,8 @@ describe LitmusPaper::App do
|
|
165
183
|
test_service = LitmusPaper::Service.new('test', [AlwaysAvailableDependency.new], [ConstantMetric.new(100)])
|
166
184
|
LitmusPaper.services['test'] = test_service
|
167
185
|
|
168
|
-
LitmusPaper::StatusFile.
|
169
|
-
LitmusPaper::StatusFile.
|
186
|
+
LitmusPaper::StatusFile.service_up_file("test").create("Up for testing")
|
187
|
+
LitmusPaper::StatusFile.service_down_file("test").create("Down for testing")
|
170
188
|
|
171
189
|
get "/test/status"
|
172
190
|
|
@@ -178,7 +196,7 @@ describe LitmusPaper::App do
|
|
178
196
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
179
197
|
LitmusPaper.services['test'] = test_service
|
180
198
|
|
181
|
-
LitmusPaper::StatusFile.
|
199
|
+
LitmusPaper::StatusFile.service_up_file("test").create("Up for testing")
|
182
200
|
|
183
201
|
get "/test/status"
|
184
202
|
|
@@ -190,7 +208,7 @@ describe LitmusPaper::App do
|
|
190
208
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
191
209
|
LitmusPaper.services['test'] = test_service
|
192
210
|
|
193
|
-
LitmusPaper::StatusFile.
|
211
|
+
LitmusPaper::StatusFile.service_up_file("test").create("Up for testing")
|
194
212
|
|
195
213
|
get "/test/status"
|
196
214
|
|
@@ -202,8 +220,8 @@ describe LitmusPaper::App do
|
|
202
220
|
test_service = LitmusPaper::Service.new('test', [AlwaysAvailableDependency.new], [ConstantMetric.new(100)])
|
203
221
|
LitmusPaper.services['test'] = test_service
|
204
222
|
|
205
|
-
LitmusPaper::StatusFile.
|
206
|
-
LitmusPaper::StatusFile.
|
223
|
+
LitmusPaper::StatusFile.global_down_file.create("Down for testing")
|
224
|
+
LitmusPaper::StatusFile.global_up_file.create("Up for testing")
|
207
225
|
|
208
226
|
get "/test/status"
|
209
227
|
|
@@ -215,7 +233,7 @@ describe LitmusPaper::App do
|
|
215
233
|
test_service = LitmusPaper::Service.new('test', [AlwaysAvailableDependency.new], [ConstantMetric.new(100)])
|
216
234
|
LitmusPaper.services['test'] = test_service
|
217
235
|
|
218
|
-
LitmusPaper::StatusFile.
|
236
|
+
LitmusPaper::StatusFile.global_down_file.create("Down for testing")
|
219
237
|
|
220
238
|
get "/test/status"
|
221
239
|
|
@@ -227,7 +245,7 @@ describe LitmusPaper::App do
|
|
227
245
|
test_service = LitmusPaper::Service.new('test', [NeverAvailableDependency.new], [ConstantMetric.new(100)])
|
228
246
|
LitmusPaper.services['test'] = test_service
|
229
247
|
|
230
|
-
LitmusPaper::StatusFile.
|
248
|
+
LitmusPaper::StatusFile.global_up_file.create("Up for testing")
|
231
249
|
|
232
250
|
get "/test/status"
|
233
251
|
|
@@ -14,6 +14,12 @@ describe 'litmusctl' do
|
|
14
14
|
system "kill -9 `cat /tmp/litmus.pid`"
|
15
15
|
end
|
16
16
|
|
17
|
+
describe 'help' do
|
18
|
+
it "is displayed if no command is given" do
|
19
|
+
_litmusctl('').should match("Commands:")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
describe 'list' do
|
18
24
|
it "returns the list of services running" do
|
19
25
|
_litmusctl('list').should match("test")
|
@@ -23,7 +23,7 @@ describe LitmusPaper::Service do
|
|
23
23
|
service.depends AlwaysAvailableDependency
|
24
24
|
service.measure_health ConstantMetric, :weight => 50
|
25
25
|
|
26
|
-
LitmusPaper::StatusFile.
|
26
|
+
LitmusPaper::StatusFile.service_down_file("test").create("Down for testing")
|
27
27
|
|
28
28
|
service.current_health.value.should == 0
|
29
29
|
service.current_health.summary.should == "Down for testing"
|
@@ -34,7 +34,7 @@ describe LitmusPaper::Service do
|
|
34
34
|
service.depends AlwaysAvailableDependency
|
35
35
|
service.measure_health ConstantMetric, :weight => 50
|
36
36
|
|
37
|
-
LitmusPaper::StatusFile.
|
37
|
+
LitmusPaper::StatusFile.global_down_file.create("Down for testing")
|
38
38
|
|
39
39
|
service.current_health.value.should == 0
|
40
40
|
service.current_health.summary.should == "Down for testing"
|
@@ -45,7 +45,7 @@ describe LitmusPaper::Service do
|
|
45
45
|
service.depends NeverAvailableDependency
|
46
46
|
service.measure_health ConstantMetric, :weight => 50
|
47
47
|
|
48
|
-
LitmusPaper::StatusFile.
|
48
|
+
LitmusPaper::StatusFile.service_up_file("test").create("Up for testing")
|
49
49
|
|
50
50
|
service.current_health.value.should == 100
|
51
51
|
service.current_health.summary.should == "Up for testing"
|
@@ -56,7 +56,7 @@ describe LitmusPaper::Service do
|
|
56
56
|
service.depends NeverAvailableDependency
|
57
57
|
service.measure_health ConstantMetric, :weight => 50
|
58
58
|
|
59
|
-
LitmusPaper::StatusFile.
|
59
|
+
LitmusPaper::StatusFile.global_up_file.create("Up for testing")
|
60
60
|
|
61
61
|
service.current_health.value.should == 100
|
62
62
|
service.current_health.summary.should == "Up for testing"
|
@@ -2,22 +2,15 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LitmusPaper::StatusFile do
|
4
4
|
describe "create" do
|
5
|
-
it "creates a nested file" do
|
6
|
-
status_file = LitmusPaper::StatusFile.new("foo", "bar")
|
7
|
-
status_file.create("for testing")
|
8
|
-
|
9
|
-
status_file.exists?.should == true
|
10
|
-
end
|
11
|
-
|
12
5
|
it "creates a file" do
|
13
|
-
status_file = LitmusPaper::StatusFile.new("foo")
|
6
|
+
status_file = LitmusPaper::StatusFile.new("foo", 100)
|
14
7
|
status_file.create("for testing")
|
15
8
|
|
16
9
|
status_file.exists?.should == true
|
17
10
|
end
|
18
11
|
|
19
12
|
it "writes the content" do
|
20
|
-
status_file = LitmusPaper::StatusFile.new("foo")
|
13
|
+
status_file = LitmusPaper::StatusFile.new("foo", 100)
|
21
14
|
status_file.create("for testing")
|
22
15
|
|
23
16
|
status_file.content.should == "for testing"
|
@@ -26,7 +19,7 @@ describe LitmusPaper::StatusFile do
|
|
26
19
|
|
27
20
|
describe "delete" do
|
28
21
|
it "removes the file" do
|
29
|
-
status_file = LitmusPaper::StatusFile.new("foo")
|
22
|
+
status_file = LitmusPaper::StatusFile.new("foo", 100)
|
30
23
|
status_file.create("for testing")
|
31
24
|
|
32
25
|
status_file.exists?.should be_true
|
metadata
CHANGED
@@ -1,102 +1,146 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: litmus_paper
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 15
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Braintreeps
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
|
18
|
+
date: 2012-07-17 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
17
23
|
none: false
|
18
|
-
requirements:
|
24
|
+
requirements:
|
19
25
|
- - ~>
|
20
|
-
- !ruby/object:Gem::Version
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 31
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 3
|
31
|
+
- 2
|
21
32
|
version: 1.3.2
|
33
|
+
requirement: *id001
|
22
34
|
type: :runtime
|
35
|
+
name: sinatra
|
23
36
|
prerelease: false
|
24
|
-
|
25
|
-
|
26
|
-
name: facter
|
27
|
-
requirement: &70352324742900 !ruby/object:Gem::Requirement
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
28
39
|
none: false
|
29
|
-
requirements:
|
40
|
+
requirements:
|
30
41
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 1
|
44
|
+
segments:
|
45
|
+
- 1
|
46
|
+
- 6
|
47
|
+
- 7
|
32
48
|
version: 1.6.7
|
49
|
+
requirement: *id002
|
33
50
|
type: :runtime
|
51
|
+
name: facter
|
34
52
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
name: SyslogLogger
|
38
|
-
requirement: &70352324742440 !ruby/object:Gem::Requirement
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
39
55
|
none: false
|
40
|
-
requirements:
|
56
|
+
requirements:
|
41
57
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 5
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 4
|
63
|
+
- 1
|
43
64
|
version: 1.4.1
|
65
|
+
requirement: *id003
|
44
66
|
type: :runtime
|
67
|
+
name: SyslogLogger
|
45
68
|
prerelease: false
|
46
|
-
|
47
|
-
|
48
|
-
name: rspec
|
49
|
-
requirement: &70352324741920 !ruby/object:Gem::Requirement
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
50
71
|
none: false
|
51
|
-
requirements:
|
72
|
+
requirements:
|
52
73
|
- - ~>
|
53
|
-
- !ruby/object:Gem::Version
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
hash: 43
|
76
|
+
segments:
|
77
|
+
- 2
|
78
|
+
- 9
|
79
|
+
- 0
|
54
80
|
version: 2.9.0
|
81
|
+
requirement: *id004
|
55
82
|
type: :development
|
83
|
+
name: rspec
|
56
84
|
prerelease: false
|
57
|
-
|
58
|
-
|
59
|
-
name: rack-test
|
60
|
-
requirement: &70352324741220 !ruby/object:Gem::Requirement
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
61
87
|
none: false
|
62
|
-
requirements:
|
88
|
+
requirements:
|
63
89
|
- - ~>
|
64
|
-
- !ruby/object:Gem::Version
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
hash: 5
|
92
|
+
segments:
|
93
|
+
- 0
|
94
|
+
- 6
|
95
|
+
- 1
|
65
96
|
version: 0.6.1
|
97
|
+
requirement: *id005
|
66
98
|
type: :development
|
99
|
+
name: rack-test
|
67
100
|
prerelease: false
|
68
|
-
|
69
|
-
|
70
|
-
name: rake
|
71
|
-
requirement: &70352324740620 !ruby/object:Gem::Requirement
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
72
103
|
none: false
|
73
|
-
requirements:
|
104
|
+
requirements:
|
74
105
|
- - ~>
|
75
|
-
- !ruby/object:Gem::Version
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
hash: 11
|
108
|
+
segments:
|
109
|
+
- 0
|
110
|
+
- 9
|
111
|
+
- 2
|
112
|
+
- 2
|
76
113
|
version: 0.9.2.2
|
114
|
+
requirement: *id006
|
77
115
|
type: :development
|
116
|
+
name: rake
|
78
117
|
prerelease: false
|
79
|
-
|
80
|
-
|
81
|
-
name: rake_commit
|
82
|
-
requirement: &70352324740160 !ruby/object:Gem::Requirement
|
118
|
+
- !ruby/object:Gem::Dependency
|
119
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
83
120
|
none: false
|
84
|
-
requirements:
|
121
|
+
requirements:
|
85
122
|
- - ~>
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
hash: 17
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
- 13
|
128
|
+
version: "0.13"
|
129
|
+
requirement: *id007
|
88
130
|
type: :development
|
131
|
+
name: rake_commit
|
89
132
|
prerelease: false
|
90
|
-
version_requirements: *70352324740160
|
91
133
|
description: Backend health tester for HA Services
|
92
|
-
email:
|
134
|
+
email:
|
93
135
|
- code@getbraintree.com
|
94
|
-
executables:
|
136
|
+
executables:
|
95
137
|
- litmus
|
96
138
|
- litmusctl
|
97
139
|
extensions: []
|
140
|
+
|
98
141
|
extra_rdoc_files: []
|
99
|
-
|
142
|
+
|
143
|
+
files:
|
100
144
|
- .gitignore
|
101
145
|
- .rake_commit
|
102
146
|
- .rvmrc
|
@@ -112,6 +156,10 @@ files:
|
|
112
156
|
- lib/litmus_paper.rb
|
113
157
|
- lib/litmus_paper/app.rb
|
114
158
|
- lib/litmus_paper/cli/admin.rb
|
159
|
+
- lib/litmus_paper/cli/admin/command.rb
|
160
|
+
- lib/litmus_paper/cli/admin/force.rb
|
161
|
+
- lib/litmus_paper/cli/admin/list.rb
|
162
|
+
- lib/litmus_paper/cli/admin/status.rb
|
115
163
|
- lib/litmus_paper/cli/server.rb
|
116
164
|
- lib/litmus_paper/configuration.rb
|
117
165
|
- lib/litmus_paper/dependency/haproxy_backends.rb
|
@@ -155,31 +203,41 @@ files:
|
|
155
203
|
- spec/support/stub_facter.rb
|
156
204
|
- spec/support/test.config
|
157
205
|
- spec/support/test.d.config
|
206
|
+
has_rdoc: true
|
158
207
|
homepage: https://github.com/braintree/litmus_paper
|
159
208
|
licenses: []
|
209
|
+
|
160
210
|
post_install_message:
|
161
211
|
rdoc_options: []
|
162
|
-
|
212
|
+
|
213
|
+
require_paths:
|
163
214
|
- lib
|
164
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
216
|
none: false
|
166
|
-
requirements:
|
167
|
-
- -
|
168
|
-
- !ruby/object:Gem::Version
|
169
|
-
|
170
|
-
|
217
|
+
requirements:
|
218
|
+
- - ">="
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
hash: 3
|
221
|
+
segments:
|
222
|
+
- 0
|
223
|
+
version: "0"
|
224
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
171
225
|
none: false
|
172
|
-
requirements:
|
173
|
-
- -
|
174
|
-
- !ruby/object:Gem::Version
|
175
|
-
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
hash: 3
|
230
|
+
segments:
|
231
|
+
- 0
|
232
|
+
version: "0"
|
176
233
|
requirements: []
|
234
|
+
|
177
235
|
rubyforge_project:
|
178
|
-
rubygems_version: 1.
|
236
|
+
rubygems_version: 1.3.7
|
179
237
|
signing_key:
|
180
238
|
specification_version: 3
|
181
239
|
summary: Backend health tester for HA Services, partner project of big_brother
|
182
|
-
test_files:
|
240
|
+
test_files:
|
183
241
|
- spec/litmus_paper/app_spec.rb
|
184
242
|
- spec/litmus_paper/cli/admin_spec.rb
|
185
243
|
- spec/litmus_paper/cli/server_spec.rb
|