Skip to content

Commit

Permalink
(PE-40377) tune final checks
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmalloncares committed Feb 26, 2025
1 parent 92f8446 commit 718ad48
Showing 1 changed file with 6 additions and 22 deletions.
28 changes: 6 additions & 22 deletions spec/acceptance/peadm_spec/plans/test_migration.pp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
new_primary_host => $new_primary_target,
)

# Initialize a variable to track the overall success status
$all_checks_passed = true

# run infra status on the new primary
out::message("Running peadm::status on new primary host ${new_primary_target}")
$new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' })
Expand All @@ -55,21 +52,18 @@
if empty($new_primary_status['failed']) {
out::message('Migrated cluster is healthy, continuing')
} else {
out::message('FAIL: Migrated cluster is not healthy')
$all_checks_passed = false
fail_plan('Migrated cluster is not healthy, aborting')
}

# get the config from new_primary_target and verify config looks as expected
$peadm_config = run_task('peadm::get_peadm_config', $new_primary_target, '_catch_errors' => true).first.to_data()
out::message("peadm_config: ${peadm_config}")
# if new_replica_target is supplied then check that is in the expected place in the config
if $new_replica_target {
if $peadm_config['params']['replica_host'] == $new_replica_target {
out::message("New replica host ${new_replica_target} set up correctly")
} else {
out::message("FAIL: New replica host ${new_replica_target} was not set up correctly")
$all_checks_passed = false
fail_plan("New replica host ${new_replica_target} was not set up correctly")
}
}
Expand All @@ -78,8 +72,7 @@
if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_target {
out::message("New primary postgres host ${new_primary_postgresql_target} set up correctly")
} else {
out::message("FAIL: New primary postgres host ${new_primary_postgresql_target} was not set up correctly")
$all_checks_passed = false
fail_plan("New primary postgres host ${new_primary_postgresql_target} was not set up correctly")
}
}
Expand All @@ -88,25 +81,16 @@
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_target {
out::message("New primary postgres host ${new_replica_postgresql_target} set up correctly")
} else {
out::message("FAIL: New primary postgres host ${new_replica_postgresql_target} was not set up correctly")
$all_checks_passed = false
fail_plan("New primary postgres host ${new_replica_postgresql_target} was not set up correctly")
}
}
# if a new PE version was specified then check it has been upgraded
if $upgrade_version {
if $peadm_config['params']['pe_version'] == $upgrade_version {
if $peadm_config['value']['pe_version'] == $upgrade_version {
out::message("Upgraded to new PE version ${upgrade_version} correctly")
} else {
out::message("FAIL: Upgrade to new PE version ${upgrade_version} did not work correctly")
$all_checks_passed = false
fail_plan("Failed to upgrade to new PE version ${upgrade_version} correctly")
}
}
# fail plan if any of the checks failed
if $all_checks_passed {
out::message('All checks passed')
} else {
fail_plan('Migration of cluster failed')
}
}

0 comments on commit 718ad48

Please sign in to comment.