Merge branch 'main' into rolling-traefik-restarts
* main: Removed not needed MRSK.traefik.run command in Traefil reboot Updated README with locking directory name Include service name to lock details Configurable SSH log levels Add registry container output to debug Minor tweaks to hooks section in readme Update README.md Updated README.md to make setup examples consistent Login to the registry proactively before stoping Accessory and Traefik
This commit is contained in:
@@ -40,9 +40,10 @@ class CliAccessoryTest < CliTestCase
|
||||
end
|
||||
|
||||
test "reboot" do
|
||||
Mrsk::Commands::Registry.any_instance.expects(:login)
|
||||
Mrsk::Cli::Accessory.any_instance.expects(:stop).with("mysql")
|
||||
Mrsk::Cli::Accessory.any_instance.expects(:remove_container).with("mysql")
|
||||
Mrsk::Cli::Accessory.any_instance.expects(:boot).with("mysql")
|
||||
Mrsk::Cli::Accessory.any_instance.expects(:boot).with("mysql", login: false)
|
||||
|
||||
run_command("reboot", "mysql")
|
||||
end
|
||||
|
||||
@@ -29,9 +29,9 @@ class CliTestCase < ActiveSupport::TestCase
|
||||
|
||||
def stub_locking
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
||||
.with { |arg1, arg2| arg1 == :mkdir && arg2 == :mrsk_lock }
|
||||
.with { |arg1, arg2| arg1 == :mkdir && arg2 == "mrsk_lock-app" }
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
||||
.with { |arg1, arg2| arg1 == :rm && arg2 == "mrsk_lock/details" }
|
||||
.with { |arg1, arg2| arg1 == :rm && arg2 == "mrsk_lock-app/details" }
|
||||
end
|
||||
|
||||
def assert_hook_ran(hook, output, version:, service_version:, hosts:, command:, subcommand: nil, runtime: nil)
|
||||
|
||||
@@ -63,11 +63,11 @@ class CliMainTest < CliTestCase
|
||||
Thread.report_on_exception = false
|
||||
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
||||
.with { |*arg| arg[0..1] == [:mkdir, :mrsk_lock] }
|
||||
.raises(RuntimeError, "mkdir: cannot create directory ‘mrsk_lock’: File exists")
|
||||
.with { |*arg| arg[0..1] == [:mkdir, 'mrsk_lock-app'] }
|
||||
.raises(RuntimeError, "mkdir: cannot create directory ‘mrsk_lock-app’: File exists")
|
||||
|
||||
SSHKit::Backend::Abstract.any_instance.expects(:capture_with_debug)
|
||||
.with(:stat, :mrsk_lock, ">", "/dev/null", "&&", :cat, "mrsk_lock/details", "|", :base64, "-d")
|
||||
.with(:stat, 'mrsk_lock-app', ">", "/dev/null", "&&", :cat, "mrsk_lock-app/details", "|", :base64, "-d")
|
||||
|
||||
assert_raises(Mrsk::Cli::LockError) do
|
||||
run_command("deploy")
|
||||
@@ -78,7 +78,7 @@ class CliMainTest < CliTestCase
|
||||
Thread.report_on_exception = false
|
||||
|
||||
SSHKit::Backend::Abstract.any_instance.stubs(:execute)
|
||||
.with { |*arg| arg[0..1] == [:mkdir, :mrsk_lock] }
|
||||
.with { |*arg| arg[0..1] == [:mkdir, 'mrsk_lock-app'] }
|
||||
.raises(SocketError, "getaddrinfo: nodename nor servname provided, or not known")
|
||||
|
||||
assert_raises(SSHKit::Runner::ExecuteError) do
|
||||
|
||||
@@ -9,17 +9,18 @@ class CliTraefikTest < CliTestCase
|
||||
end
|
||||
|
||||
test "reboot" do
|
||||
Mrsk::Commands::Registry.any_instance.expects(:login).twice
|
||||
|
||||
run_command("reboot").tap do |output|
|
||||
assert_match "docker container stop traefik", output
|
||||
assert_match "docker container prune --force --filter label=org.opencontainers.image.title=Traefik", output
|
||||
assert_match "docker login", output
|
||||
assert_match "docker run --name traefik --detach --restart unless-stopped --publish 80:80 --volume /var/run/docker.sock:/var/run/docker.sock --log-opt max-size=\"10m\" #{Mrsk::Commands::Traefik::DEFAULT_IMAGE} --providers.docker --log.level=\"DEBUG\"", output
|
||||
end
|
||||
end
|
||||
|
||||
test "reboot --rolling" do
|
||||
run_command("reboot", "--rolling").tap do |output|
|
||||
assert_match "Running docker container prune --force --filter label=org.opencontainers.image.title=Traefik on 1.1.1.1", output.lines[2]
|
||||
assert_match "Running docker container prune --force --filter label=org.opencontainers.image.title=Traefik on 1.1.1.1", output.lines[3]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ class CommandsLockTest < ActiveSupport::TestCase
|
||||
|
||||
test "status" do
|
||||
assert_equal \
|
||||
"stat mrsk_lock > /dev/null && cat mrsk_lock/details | base64 -d",
|
||||
"stat mrsk_lock-app > /dev/null && cat mrsk_lock-app/details | base64 -d",
|
||||
new_command.status.join(" ")
|
||||
end
|
||||
|
||||
test "acquire" do
|
||||
assert_match \
|
||||
/mkdir mrsk_lock && echo ".*" > mrsk_lock\/details/m,
|
||||
/mkdir mrsk_lock-app && echo ".*" > mrsk_lock-app\/details/m,
|
||||
new_command.acquire("Hello", "123").join(" ")
|
||||
end
|
||||
|
||||
test "release" do
|
||||
assert_match \
|
||||
"rm mrsk_lock/details && rm -r mrsk_lock",
|
||||
"rm mrsk_lock-app/details && rm -r mrsk_lock-app",
|
||||
new_command.release.join(" ")
|
||||
end
|
||||
|
||||
|
||||
@@ -211,17 +211,21 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
assert_equal "root", @config.ssh_options[:user]
|
||||
|
||||
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "user" => "app" }) })
|
||||
assert_equal "app", @config.ssh_options[:user]
|
||||
assert_equal "app", config.ssh_options[:user]
|
||||
assert_equal 4, config.ssh_options[:logger].level
|
||||
|
||||
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "log_level" => "debug" }) })
|
||||
assert_equal 0, config.ssh_options[:logger].level
|
||||
end
|
||||
|
||||
test "ssh options with proxy host" do
|
||||
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "1.2.3.4" }) })
|
||||
assert_equal "root@1.2.3.4", @config.ssh_options[:proxy].jump_proxies
|
||||
assert_equal "root@1.2.3.4", config.ssh_options[:proxy].jump_proxies
|
||||
end
|
||||
|
||||
test "ssh options with proxy host and user" do
|
||||
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(ssh: { "proxy" => "app@1.2.3.4" }) })
|
||||
assert_equal "app@1.2.3.4", @config.ssh_options[:proxy].jump_proxies
|
||||
assert_equal "app@1.2.3.4", config.ssh_options[:proxy].jump_proxies
|
||||
end
|
||||
|
||||
test "volume_args" do
|
||||
@@ -266,7 +270,22 @@ class ConfigurationTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
test "to_h" do
|
||||
assert_equal({ :roles=>["web"], :hosts=>["1.1.1.1", "1.1.1.2"], :primary_host=>"1.1.1.1", :version=>"missing", :repository=>"dhh/app", :absolute_image=>"dhh/app:missing", :service_with_version=>"app-missing", :env_args=>["-e", "REDIS_URL=\"redis://x/y\""], :ssh_options=>{:user=>"root", :auth_methods=>["publickey"]}, :volume_args=>["--volume", "/local/path:/container/path"], :builder=>{}, :logging=>["--log-opt", "max-size=\"10m\""], :healthcheck=>{"path"=>"/up", "port"=>3000, "max_attempts" => 7 }}, @config.to_h)
|
||||
assert_equal({
|
||||
:roles=>["web"],
|
||||
:hosts=>["1.1.1.1", "1.1.1.2"],
|
||||
:primary_host=>"1.1.1.1",
|
||||
:version=>"missing",
|
||||
:repository=>"dhh/app",
|
||||
:absolute_image=>"dhh/app:missing",
|
||||
:service_with_version=>"app-missing",
|
||||
:env_args=>["-e", "REDIS_URL=\"redis://x/y\""],
|
||||
:ssh_options=>{:user=>"root", :auth_methods=>["publickey"]},
|
||||
:ssh_log_level=>4,
|
||||
:volume_args=>["--volume", "/local/path:/container/path"],
|
||||
:builder=>{},
|
||||
:logging=>["--log-opt", "max-size=\"10m\""],
|
||||
:healthcheck=>{"path"=>"/up", "port"=>3000, "max_attempts" => 7 }
|
||||
}, @config.to_h)
|
||||
end
|
||||
|
||||
test "min version is lower" do
|
||||
|
||||
@@ -11,7 +11,7 @@ class IntegrationTest < ActiveSupport::TestCase
|
||||
|
||||
teardown do
|
||||
unless passed?
|
||||
[:deployer, :vm1, :vm2, :shared, :load_balancer].each do |container|
|
||||
[:deployer, :vm1, :vm2, :shared, :load_balancer, :registry].each do |container|
|
||||
puts
|
||||
puts "Logs for #{container}:"
|
||||
docker_compose :logs, container
|
||||
|
||||
Reference in New Issue
Block a user