Skip to content

Commit

Permalink
unify DB backup steps
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeni committed Jun 26, 2024
1 parent e2e9ed0 commit e5476d6
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 79 deletions.
20 changes: 0 additions & 20 deletions definitions/procedures/backup/offline/candlepin_db.rb

This file was deleted.

20 changes: 0 additions & 20 deletions definitions/procedures/backup/offline/foreman_db.rb

This file was deleted.

20 changes: 0 additions & 20 deletions definitions/procedures/backup/offline/pulpcore_db.rb

This file was deleted.

2 changes: 1 addition & 1 deletion definitions/procedures/backup/online/candlepin_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Procedures::Backup
module Online
class CandlepinDB < ForemanMaintain::Procedure
metadata do
description 'Backup Candlepin database online'
description 'Backup Candlepin database'
tags :backup
label :backup_online_candlepin_db
for_feature :candlepin_database
Expand Down
2 changes: 1 addition & 1 deletion definitions/procedures/backup/online/foreman_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Procedures::Backup
module Online
class ForemanDB < ForemanMaintain::Procedure
metadata do
description 'Backup Foreman database online'
description 'Backup Foreman database'
tags :backup
label :backup_online_foreman_db
for_feature :foreman_database
Expand Down
2 changes: 1 addition & 1 deletion definitions/procedures/backup/online/pulpcore_db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Procedures::Backup
module Online
class PulpcoreDB < ForemanMaintain::Procedure
metadata do
description 'Backup Pulpcore database online'
description 'Backup Pulpcore database'
tags :backup
label :backup_online_pulpcore_db
for_feature :pulpcore_database
Expand Down
18 changes: 8 additions & 10 deletions definitions/scenarios/backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def set_context_mapping
Procedures::Backup::Pulp => :backup_dir,
Procedures::Backup::Online::CandlepinDB => :backup_dir,
Procedures::Backup::Online::ForemanDB => :backup_dir,
Procedures::Backup::Online::PulpcoreDB => :backup_dir,
Procedures::Backup::Offline::CandlepinDB => :backup_dir,
Procedures::Backup::Offline::ForemanDB => :backup_dir,
Procedures::Backup::Offline::PulpcoreDB => :backup_dir)
Procedures::Backup::Online::PulpcoreDB => :backup_dir)
context.map(:preserve_dir,
Procedures::Backup::PrepareDirectory => :preserve_dir)
context.map(:incremental_dir,
Expand Down Expand Up @@ -90,18 +87,19 @@ def add_offline_backup_steps
add_step(Procedures::Service::Start.new(:only => ['postgresql']))
end

add_steps_with_context(
Procedures::Backup::Offline::CandlepinDB,
Procedures::Backup::Offline::ForemanDB,
Procedures::Backup::Offline::PulpcoreDB,
Procedures::Service::Start
)
add_database_backup_steps

add_steps_with_context(Procedures::Service::Start)
end

def add_online_backup_steps
add_step_with_context(Procedures::Backup::ConfigFiles, :ignore_changed_files => true,
:online_backup => true)
add_step_with_context(Procedures::Backup::Pulp, :ensure_unchanged => true)
add_database_backup_steps
end

def add_database_backup_steps
add_steps_with_context(
Procedures::Backup::Online::CandlepinDB,
Procedures::Backup::Online::ForemanDB,
Expand Down
10 changes: 4 additions & 6 deletions test/definitions/scenarios/backup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,10 @@ module Scenarios
end
assert_scenario_has_step(scenario, Procedures::Backup::ConfigFiles)
assert_scenario_has_step(scenario, Procedures::Backup::Pulp)
assert_scenario_has_step(scenario, Procedures::Backup::Offline::CandlepinDB)
assert_scenario_has_step(scenario, Procedures::Backup::Offline::ForemanDB)
assert_scenario_has_step(scenario, Procedures::Backup::Offline::PulpcoreDB)
assert_scenario_has_step(scenario, Procedures::Service::Start) do |step|
assert_empty(step.common_options[:only])
end
assert_scenario_has_step(scenario, Procedures::Backup::Online::CandlepinDB)
assert_scenario_has_step(scenario, Procedures::Backup::Online::ForemanDB)
assert_scenario_has_step(scenario, Procedures::Backup::Online::PulpcoreDB)
assert_scenario_has_step(scenario, Procedures::Service::Start)
assert_scenario_has_step(scenario, Procedures::Backup::CompressData)
end
end
Expand Down

0 comments on commit e5476d6

Please sign in to comment.