diff --git a/lib/mrsk/cli/app.rb b/lib/mrsk/cli/app.rb index 25bb8bdf..796cd367 100644 --- a/lib/mrsk/cli/app.rb +++ b/lib/mrsk/cli/app.rb @@ -6,7 +6,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base say "Start container with version #{version} using a #{MRSK.config.readiness_delay}s readiness delay (or reboot if already running)...", :magenta cli = self - + MRSK.config.roles.each do |role| on(role.hosts) do |host| execute *MRSK.auditor.record("Booted app version #{version}"), verbosity: :debug diff --git a/lib/mrsk/commands/healthcheck.rb b/lib/mrsk/commands/healthcheck.rb index 47626156..40ec2af7 100644 --- a/lib/mrsk/commands/healthcheck.rb +++ b/lib/mrsk/commands/healthcheck.rb @@ -33,11 +33,11 @@ class Mrsk::Commands::Healthcheck < Mrsk::Commands::Base private def container_name - "healthcheck-#{config.service}" + [ "healthcheck", config.service, config.destination ].compact.join("-") end def container_name_with_version - "healthcheck-#{config.service_with_version}" + "#{container_name}-#{config.version}" end def container_id diff --git a/test/commands/healthcheck_test.rb b/test/commands/healthcheck_test.rb index 54580e61..05fbc8c3 100644 --- a/test/commands/healthcheck_test.rb +++ b/test/commands/healthcheck_test.rb @@ -22,6 +22,14 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase new_command.run.join(" ") end + test "run with destination" do + @destination = "staging" + + assert_equal \ + "docker run --detach --name healthcheck-app-staging-123 --publish 3999:3000 --label service=healthcheck-app-staging dhh/app:123", + new_command.run.join(" ") + end + test "curl" do assert_equal \ "curl --silent --output /dev/null --write-out '%{http_code}' --max-time 2 http://localhost:3999/up", @@ -42,14 +50,44 @@ class CommandsHealthcheckTest < ActiveSupport::TestCase new_command.stop.join(" ") end + test "stop with destination" do + @destination = "staging" + + assert_equal \ + "docker container ls --all --filter name=healthcheck-app-staging --quiet | xargs docker stop", + new_command.stop.join(" ") + end + test "remove" do assert_equal \ "docker container ls --all --filter name=healthcheck-app --quiet | xargs docker container rm", new_command.remove.join(" ") end + test "remove with destination" do + @destination = "staging" + + assert_equal \ + "docker container ls --all --filter name=healthcheck-app-staging --quiet | xargs docker container rm", + new_command.remove.join(" ") + end + + test "logs" do + assert_equal \ + "docker container ls --all --filter name=healthcheck-app --quiet | xargs docker logs --tail 50 2>&1", + new_command.logs.join(" ") + end + + test "logs with destination" do + @destination = "staging" + + assert_equal \ + "docker container ls --all --filter name=healthcheck-app-staging --quiet | xargs docker logs --tail 50 2>&1", + new_command.logs.join(" ") + end + private def new_command - Mrsk::Commands::Healthcheck.new(Mrsk::Configuration.new(@config, version: "123")) + Mrsk::Commands::Healthcheck.new(Mrsk::Configuration.new(@config, destination: @destination, version: "123")) end end