Skip to content

Commit

Permalink
Add force remove command line option to remove health forces
Browse files Browse the repository at this point in the history
A major complaint from users of litmus are that it's incredibly
non-intuitive to remove a forced health (see issue braintree#4). Most people will
just assume `force up` is the opposite to `force down`, putting their
service's health in the wrong state.

Hopefully, adding a `force remove` will make it easier for users to
perform their expected actions.
  • Loading branch information
sleepdeprecation committed Apr 2, 2017
1 parent cc1d3e9 commit 510946d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/litmus_paper/cli/admin/force.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.description
def self.build_request(options, args)
options.merge! _default_options
opt_parser = _extend_default_parser(options) do |opts|
opts.banner = "Usage: litmusctl force <up|down|health N> [service] [options]"
opts.banner = "Usage: litmusctl force [remove] <up|down|health N> [service] [options]"
opts.on("-d", "--delete", "Remove status file") do
options[:delete] = true
end
Expand All @@ -19,6 +19,10 @@ def self.build_request(options, args)
end

opt_parser.parse! args
if args[0] == "remove"
options[:delete] = true
args.shift
end
if args[0] == "health" && !options[:delete]
direction, value, service = args
else
Expand Down
24 changes: 24 additions & 0 deletions spec/litmus_paper/cli/admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ def _litmusctl(args)
status.should_not match(/for testing/)
end

it "removes an upfile for the service with 'remove'" do
_litmusctl('force up test -r "for testing"').should match("File created")
_litmusctl('force remove up test').should match("File deleted")
status = _litmusctl('status passing_test')
status.should match(/Health: \d\d/)
status.should_not match(/for testing/)
end

it "removes a healthfile for the service" do
_litmusctl('force health 88 test -r "for testing"').should match("File created")
_litmusctl('force health test -d').should match("File deleted")
Expand All @@ -91,6 +99,22 @@ def _litmusctl(args)
status.should_not match(/for testing/)
end

it "removes a healthfile for the service with 'remove'" do
_litmusctl('force health 88 test -r "for testing"').should match("File created")
_litmusctl('force remove health test').should match("File deleted")
status = _litmusctl('status passing_test')
status.should match(/Health: \d\d/)
status.should_not match(/for testing/)
end

it "removes a downfile for the service with 'remove'" do
_litmusctl('force down test -r "for testing"').should match("File created")
_litmusctl('force remove down test').should match("File deleted")
status = _litmusctl('status passing_test')
status.should match(/Health: \d\d/)
status.should_not match(/for testing/)
end

it "returns not found if downfile doesn't exist" do
_litmusctl('force down test -d').should match("NOT FOUND")
end
Expand Down

0 comments on commit 510946d

Please sign in to comment.