Ensure default log option max-size=10m

This commit is contained in:
Samuel Sieg
2023-03-24 09:10:36 +01:00
parent 4670db7f6d
commit 7369be48ff
7 changed files with 38 additions and 32 deletions

View File

@@ -11,7 +11,6 @@ class ConfigurationTest < ActiveSupport::TestCase
env: { "REDIS_URL" => "redis://x/y" },
servers: [ "1.1.1.1", "1.1.1.2" ],
volumes: ["/local/path:/container/path"],
logging: { "driver" => "json-file", "options" => { "max-size" => "10m" } }
}
@config = Mrsk::Configuration.new(@deploy)
@@ -210,8 +209,13 @@ class ConfigurationTest < ActiveSupport::TestCase
assert_equal ["--volume", "/local/path:/container/path"], @config.volume_args
end
test "logging_args" do
assert_equal ["--log-driver", "json-file", "--log-opt", "max-size=\"10m\""], @config.logging_args
test "logging args default" do
assert_equal ["--log-opt", "max-size=\"10m\""], @config.logging_args
end
test "logging args with custom config" do
config = Mrsk::Configuration.new(@deploy.tap { |c| c.merge!(logging: { "driver" => "local", "options" => { "max-file" => 5 } }) })
assert_equal ["--log-driver", "local", "--log-opt", "max-file=\"5\""], @config.logging_args
end
test "erb evaluation of yml config" do
@@ -238,6 +242,6 @@ 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"], :logging=>{"driver"=>"json-file", "options"=>{"max-size"=>"10m"}}, :healthcheck=>{"path"=>"/up", "port"=>3000 }}, @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"]}, :volume_args=>["--volume", "/local/path:/container/path"], :logging=>["--log-opt", "max-size=\"10m\""], :healthcheck=>{"path"=>"/up", "port"=>3000 }}, @config.to_h)
end
end