Skip to content

Commit

Permalink
explicitly define all maintenance mode steps
Browse files Browse the repository at this point in the history
Fixes: 66728e6
  • Loading branch information
evgeni committed Aug 21, 2024
1 parent 5ea48b5 commit 138cd96
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 6 deletions.
2 changes: 1 addition & 1 deletion definitions/procedures/crond/start.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Start < Procedures::Service::Base
description 'Start cron service'

for_feature :cron
tags :post_migrations, :maintenance_mode_off
tags :post_migrations

after :iptables_remove_maintenance_mode_chain
advanced_run false
Expand Down
2 changes: 1 addition & 1 deletion definitions/procedures/crond/stop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Procedures::Crond
class Stop < Procedures::Service::Base
metadata do
description 'Stop cron service'
tags :pre_migrations, :maintenance_mode_on
tags :pre_migrations
for_feature :cron

after :iptables_add_maintenance_mode_chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class DisableMaintenanceMode < ForemanMaintain::Procedure
metadata do
label :disable_maintenance_mode
description 'Remove maintenance mode table/chain from nftables/iptables'
tags :post_migrations, :maintenance_mode_off
tags :post_migrations
after :sync_plans_enable
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class EnableMaintenanceMode < ForemanMaintain::Procedure
metadata do
label :enable_maintenance_mode
description 'Add maintenance_mode tables/chain to nftables/iptables'
tags :pre_migrations, :maintenance_mode_on
tags :pre_migrations
after :sync_plans_disable
end

Expand Down
8 changes: 6 additions & 2 deletions definitions/scenarios/maintenance_mode.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ class MaintenanceModeStart < ForemanMaintain::Scenario
end

def compose
add_steps(find_procedures(:maintenance_mode_on))
add_step(Procedures::MaintenanceMode::EnableMaintenanceMode)
add_step(Procedures::Crond::Stop)
add_step(Procedures::SyncPlans::Disable)
end
end

Expand All @@ -21,7 +23,9 @@ class MaintenanceModeStop < ForemanMaintain::Scenario
end

def compose
add_steps(find_procedures(:maintenance_mode_off))
add_step(Procedures::SyncPlans::Enable)
add_step(Procedures::Crond::Start)
add_step(Procedures::MaintenanceMode::DisableMaintenanceMode)
end
end

Expand Down
61 changes: 61 additions & 0 deletions test/definitions/scenarios/maintenance_mode_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require 'test_helper'

describe "maintenance mode scenarios" do
include DefinitionsTestHelper

describe ForemanMaintain::Scenarios::MaintenanceModeStart do
let(:scenario) do
ForemanMaintain::Scenarios::MaintenanceModeStart.new
end

it 'composes all steps' do
assert_scenario_has_steps(
scenario,
Procedures::MaintenanceMode::EnableMaintenanceMode,
Procedures::Crond::Stop,
Procedures::SyncPlans::Disable,
)
end
end

describe ForemanMaintain::Scenarios::MaintenanceModeStop do
let(:scenario) do
ForemanMaintain::Scenarios::MaintenanceModeStop.new
end

it 'composes all steps' do
assert_scenario_has_steps(
scenario,
Procedures::MaintenanceMode::DisableMaintenanceMode,
Procedures::Crond::Start,
Procedures::SyncPlans::Enable,
)
end
end

describe ForemanMaintain::Scenarios::MaintenanceModeStatus do
let(:scenario) do
ForemanMaintain::Scenarios::MaintenanceModeStatus.new
end

it 'composes all steps' do
assert_scenario_has_steps(
scenario,
Checks::MaintenanceMode::CheckConsistency,
)
end
end

describe ForemanMaintain::Scenarios::IsMaintenanceMode do
let(:scenario) do
ForemanMaintain::Scenarios::IsMaintenanceMode.new
end

it 'composes all steps' do
assert_scenario_has_steps(
scenario,
Procedures::MaintenanceMode::IsEnabled,
)
end
end
end

0 comments on commit 138cd96

Please sign in to comment.