diff --git a/definitions/procedures/crond/start.rb b/definitions/procedures/crond/start.rb index bf90fd501..29c0914d5 100644 --- a/definitions/procedures/crond/start.rb +++ b/definitions/procedures/crond/start.rb @@ -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 diff --git a/definitions/procedures/crond/stop.rb b/definitions/procedures/crond/stop.rb index 08b213291..70023c4ac 100644 --- a/definitions/procedures/crond/stop.rb +++ b/definitions/procedures/crond/stop.rb @@ -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 diff --git a/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb b/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb index 21a664a3d..49d30c1a7 100644 --- a/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb +++ b/definitions/procedures/maintenance_mode/disable_maintenance_mode.rb @@ -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 diff --git a/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb b/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb index 1cebf197d..f500262ad 100644 --- a/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb +++ b/definitions/procedures/maintenance_mode/enable_maintenance_mode.rb @@ -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 diff --git a/definitions/scenarios/maintenance_mode.rb b/definitions/scenarios/maintenance_mode.rb index 9c85b5538..dce82e1e8 100644 --- a/definitions/scenarios/maintenance_mode.rb +++ b/definitions/scenarios/maintenance_mode.rb @@ -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 @@ -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 diff --git a/test/definitions/scenarios/maintenance_mode_test.rb b/test/definitions/scenarios/maintenance_mode_test.rb new file mode 100644 index 000000000..331adabf3 --- /dev/null +++ b/test/definitions/scenarios/maintenance_mode_test.rb @@ -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