Skip to content

Commit 51b4a7b

Browse files
(PE-40377) test config checks
1 parent 4b8277e commit 51b4a7b

File tree

2 files changed

+47
-24
lines changed

2 files changed

+47
-24
lines changed

.github/workflows/test-migration.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ jobs:
125125
new_replica_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
126126
new_primary_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-primary-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
127127
new_replica_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
128+
new_pe_version= \
128129
--no-host-key-check
129130
- name: Tear down PE ${{ matrix.architecture }} test cluster
130131
if: ${{ always() }}

spec/acceptance/peadm_spec/plans/test_migration.pp

Lines changed: 46 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
String $new_replica_host,
88
String $new_primary_postgresql_host,
99
String $new_replica_postgresql_host,
10+
String $new_pe_version,
1011
) {
1112
out::message("primary_host:${primary_host}.")
1213
out::message("replica_host:${replica_host}.")
@@ -54,32 +55,53 @@
5455
# new_primary_host => $new_primary_host,
5556
# )
5657

57-
# # run infra status on the new primary
58-
# out::message("Running peadm::status on new primary host ${new_primary_host}")
59-
# $new_primary_status = run_plan('peadm::status', $new_primary_host, { 'format' => 'json' })
60-
# out::message($primary_status)
58+
# run infra status on the new primary
59+
out::message("Running peadm::status on new primary host ${new_primary_target}")
60+
$new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' })
61+
out::message($new_primary_status)
6162

62-
# if empty($new_primary_status['failed']) {
63-
# out::message('Migrated cluster is healthy, continuing')
64-
# } else {
65-
# fail_plan('Migrated cluster is not healthy, aborting')
66-
# }
63+
if empty($new_primary_status['failed']) {
64+
out::message('Migrated cluster is healthy, continuing')
65+
} else {
66+
fail_plan('Migrated cluster is not healthy, aborting')
67+
}
6768

68-
# MIGHT WANT TO ADD CHECKS HERE TO VERIFY THE NEW ARCHITECTURE IS AS EXPECTED
69+
# get the config from new_primary_target and verify config looks as expected
70+
$result = run_task('peadm::get_peadm_config', $new_primary_target, '_catch_errors' => true).first.to_data()
71+
out::message("peadm_config: ${result}")
72+
# if new_replica_host is not empty then check that is in the expected place in the config
73+
if $new_replica_host != '' {
74+
if $peadm_config['params']['replica_host'] == $new_replica_host {
75+
out::message("New replica host ${new_replica_host} set up correctly")
76+
} else {
77+
fail_plan("New replica host ${new_replica_host} was not set up correctly")
78+
}
79+
}
6980
70-
# # get the config from primary_target and verify failed_postgresql_host is removed and replacement was added
71-
# $result = run_task('peadm::get_peadm_config', $primary_target, '_catch_errors' => true).first.to_data()
72-
# $primary_postgres_host = $result['value']['params']['primary_postgresql_host']
73-
# $replica_postgres_host = $result['value']['params']['replica_postgresql_host']
81+
# if new_primary_postgresql_host is not empty then check that is in the expected place in the config
82+
if $new_primary_postgresql_host != '' {
83+
if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_host {
84+
out::message("New primary postgres host ${new_primary_postgresql_host} set up correctly")
85+
} else {
86+
fail_plan("New primary postgres host ${new_primary_postgresql_host} was not set up correctly")
87+
}
88+
}
7489
75-
# if $primary_postgres_host == $failed_postgresql_host or $replica_postgres_host == $failed_postgresql_host {
76-
# fail_plan("Failed PostgreSQL host ${failed_postgresql_host} was not removed from the PE configuration")
77-
# } else {
78-
# out::message("Failed PostgreSQL host ${failed_postgresql_host} was removed from the PE configuration")
79-
# }
80-
# if $primary_postgres_host == $replacement_postgresql_host or $replica_postgres_host == $replacement_postgresql_host {
81-
# out::message("Replacement PostgreSQL host ${replacement_postgresql_host} was added to the PE configuration")
82-
# } else {
83-
# fail_plan("Replacement PostgreSQL host ${replacement_postgresql_host} was not added the PE configuration")
84-
# }
90+
# if new_replica_postgresql_host is not empty then check that is in the expected place in the config
91+
if $new_replica_postgresql_host != '' {
92+
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_host {
93+
out::message("New primary postgres host ${new_replica_postgresql_host} set up correctly")
94+
} else {
95+
fail_plan("New primary postgres host ${new_replica_postgresql_host} was not set up correctly")
96+
}
97+
}
98+
99+
# if a new PE version was specified then check it has been upgraded
100+
if ($new_pe_version != '') {
101+
if $peadm_config['params']['pe_version'] == $new_pe_version {
102+
out::message("Upgraded to new PE version ${new_pe_version} correctly")
103+
} else {
104+
fail_plan("Failed to upgrade to new PE version ${new_pe_version} correctly")
105+
}
106+
}
85107
}

0 commit comments

Comments
 (0)