[mproxy](https://github.com/basecamp/parachute) is a custom minimal proxy designed specifically for Kamal. It has two big advantages over Traefik: 1. Imperative deployments - we tell it to switch from container A to container B, and it waits for container B to start then switches. No need to poll for health checks ourselves or mess around with forcing health checks to fail. 2. Support for multiple apps - as much as possible, configuration is supplied at runtime by the deploy command, allowing us to have multiple apps share an instance of mproxy without conflicting config.
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
require "test_helper"
|
|
|
|
class CommandsHookTest < ActiveSupport::TestCase
|
|
include ActiveSupport::Testing::TimeHelpers
|
|
|
|
setup do
|
|
freeze_time
|
|
|
|
@config = {
|
|
service: "app", image: "dhh/app", registry: { "username" => "dhh", "password" => "secret" }, servers: [ "1.1.1.1" ]
|
|
}
|
|
|
|
@performer = `whoami`.strip
|
|
@recorded_at = Time.now.utc.iso8601
|
|
end
|
|
|
|
test "run" do
|
|
assert_equal [
|
|
".kamal/hooks/foo",
|
|
{ env: {
|
|
"KAMAL_RECORDED_AT" => @recorded_at,
|
|
"KAMAL_PERFORMER" => @performer,
|
|
"KAMAL_VERSION" => "123",
|
|
"KAMAL_SERVICE_VERSION" => "app@123" } }
|
|
], new_command.run("foo")
|
|
end
|
|
|
|
test "run with custom hooks_path" do
|
|
assert_equal [
|
|
"custom/hooks/path/foo",
|
|
{ env: {
|
|
"KAMAL_RECORDED_AT" => @recorded_at,
|
|
"KAMAL_PERFORMER" => @performer,
|
|
"KAMAL_VERSION" => "123",
|
|
"KAMAL_SERVICE_VERSION" => "app@123" } }
|
|
], new_command(hooks_path: "custom/hooks/path").run("foo")
|
|
end
|
|
|
|
private
|
|
def new_command(**extra_config)
|
|
Kamal::Commands::Hook.new(Kamal::Configuration.new(@config.merge(**extra_config), version: "123"))
|
|
end
|
|
end
|