From 510946d78952bd309fbbe7dd944c7ae7eb88f8e6 Mon Sep 17 00:00:00 2001 From: don Date: Sun, 2 Apr 2017 10:14:25 -0500 Subject: [PATCH] Add `force remove` command line option to remove health forces A major complaint from users of litmus are that it's incredibly non-intuitive to remove a forced health (see issue #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. --- lib/litmus_paper/cli/admin/force.rb | 6 +++++- spec/litmus_paper/cli/admin_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/litmus_paper/cli/admin/force.rb b/lib/litmus_paper/cli/admin/force.rb index db6b1a1..f6fe783 100644 --- a/lib/litmus_paper/cli/admin/force.rb +++ b/lib/litmus_paper/cli/admin/force.rb @@ -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 [service] [options]" + opts.banner = "Usage: litmusctl force [remove] [service] [options]" opts.on("-d", "--delete", "Remove status file") do options[:delete] = true end @@ -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 diff --git a/spec/litmus_paper/cli/admin_spec.rb b/spec/litmus_paper/cli/admin_spec.rb index a3fe815..ac16047 100644 --- a/spec/litmus_paper/cli/admin_spec.rb +++ b/spec/litmus_paper/cli/admin_spec.rb @@ -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") @@ -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