Allow percentage-based rolling deployments

This commit is contained in:
Kevin McConnell
2023-04-14 11:26:10 +01:00
parent a8726be20e
commit f055766918
7 changed files with 60 additions and 12 deletions

View File

@@ -38,7 +38,7 @@ class CliAppTest < CliTestCase
Mrsk::Cli::App.any_instance.stubs(:on).with([ "1.1.1.1" ]) # tag container
# Strategy is used when booting the containers
Mrsk::Cli::App.any_instance.expects(:on).with([ "1.1.1.1" ], in: :groups, limit: 3, wait: 30).with_block_given
Mrsk::Cli::App.any_instance.expects(:on).with([ "1.1.1.1" ], in: :groups, limit: 3, wait: 2).with_block_given
run_command("boot", config: :with_group_strategy)
end

View File

@@ -2,9 +2,7 @@ require "test_helper"
class CommanderTest < ActiveSupport::TestCase
setup do
@mrsk = Mrsk::Commander.new.tap do |mrsk|
mrsk.configure config_file: Pathname.new(File.expand_path("fixtures/deploy_with_roles.yml", __dir__))
end
configure_with(:deploy_with_roles)
end
test "lazy configuration" do
@@ -55,4 +53,27 @@ class CommanderTest < ActiveSupport::TestCase
assert_equal [ "web" ], @mrsk.roles_on("1.1.1.1")
assert_equal [ "workers" ], @mrsk.roles_on("1.1.1.3")
end
test "default group strategy" do
assert_empty @mrsk.group_strategy
end
test "specific limit group strategy" do
configure_with(:deploy_with_group_strategy)
assert_equal({ in: :groups, limit: 3, wait: 2 }, @mrsk.group_strategy)
end
test "percentage-based group strategy" do
configure_with(:deploy_with_precentage_group_strategy)
assert_equal({ in: :groups, limit: 1, wait: 2 }, @mrsk.group_strategy)
end
private
def configure_with(variant)
@mrsk = Mrsk::Commander.new.tap do |mrsk|
mrsk.configure config_file: Pathname.new(File.expand_path("fixtures/#{variant}.yml", __dir__))
end
end
end

View File

@@ -14,4 +14,4 @@ registry:
boot:
group_limit: 3
group_wait: 30
group_wait: 2

View File

@@ -0,0 +1,17 @@
service: app
image: dhh/app
servers:
web:
- "1.1.1.1"
- "1.1.1.2"
workers:
- "1.1.1.3"
- "1.1.1.4"
registry:
username: user
password: pw
boot:
group_limit: 25%
group_wait: 2