Skip to content

Commit 25c67e3

Browse files
(PE-40377) go back to what worked
1 parent 84b3e42 commit 25c67e3

File tree

2 files changed

+50
-42
lines changed

2 files changed

+50
-42
lines changed

.github/workflows/test-migration.yaml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,15 @@ jobs:
110110
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
111111
bundle exec rake spec_prep
112112
echo ::endgroup::
113-
primary_host=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) \
114-
new_primary_host=$(yq '.groups[].targets[] | select(.vars.role == "new-primary") | .name' spec/fixtures/litmus_inventory.yaml) \
115-
new_replica_host=$(yq '.groups[].targets[] | select(.vars.role == "new-replica") | .name // ""' spec/fixtures/litmus_inventory.yaml)
116-
new_primary_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "new-primary-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml)
117-
new_replica_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "new-replica-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml)
118-
bolt_command = "bundle exec bolt plan run peadm_spec::test_migration \
113+
bundle exec bolt plan run peadm_spec::test_migration \
119114
--inventoryfile spec/fixtures/litmus_inventory.yaml \
120115
--modulepath spec/fixtures/modules \
121-
primary_host=$primary_host \
122-
new_primary_host=new_primary_host \
123-
upgrade_version=${{ matrix.new_pe_version }} "
124-
[ -n "$new_replica_host" ] && [ "$new_replica_host" != "" ] && bolt_command="$bolt_command new_replica_host=$new_replica_host"
125-
[ -n "$new_primary_postgresql_host" ] && [ "$new_primary_postgresql_host" != "" ] && bolt_command="$bolt_command new_primary_postgresql_host=$new_primary_postgresql_host"
126-
[ -n "$new_replica_postgresql_host" ] && [ "$new_replica_postgresql_host" != "" ] && bolt_command="$bolt_command new_replica_postgresql_host=$new_replica_postgresql_host"
127-
bolt_command="$bolt_command --no-host-key-check"
128-
eval $bolt_command
116+
primary_host=$(yq -r '.groups[].targets[] | select(.vars.role == "primary") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
117+
new_primary_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-primary") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
118+
new_replica_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
119+
new_primary_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-primary-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
120+
new_replica_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
121+
--no-host-key-check
129122
- name: Install PE on test cluster
130123
timeout-minutes: 120
131124
run: |

spec/acceptance/peadm_spec/plans/test_migration.pp

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
plan peadm_spec::test_migration(
2-
Peadm::SingleTargetSpec $primary_host,
3-
Peadm::SingleTargetSpec $new_primary_host,
4-
Optional[Peadm::SingleTargetSpec] $new_replica_host = undef,
5-
Optional[Peadm::SingleTargetSpec] $new_primary_postgresql_host = undef,
6-
Optional[Peadm::SingleTargetSpec] $new_replica_postgresql_host = undef,
2+
String $primary_host,
3+
String $new_primary_host,
4+
Optional[String] $new_replica_host = undef,
5+
Optional[String] $new_primary_postgresql_host = undef,
6+
Optional[String] $new_replica_postgresql_host = undef,
77
Optional[Peadm::SingleTargetSpec] $upgrade_version = undef,
88
) {
99
out::message("primary_host:${primary_host}.")
1010
out::message("new_primary_host:${new_primary_host}.")
1111
out::message("new_replica_host:${new_replica_host}.")
1212
out::message("new_primary_postgresql_host:${new_primary_postgresql_host}.")
1313
out::message("new_replica_postgresql_host:${new_replica_postgresql_host}.")
14+
out::message("upgrade_version:${upgrade_version}.")
15+
16+
# Convert String values to Peadm::SingleTargetSpec if they are not blank
17+
$primary_target = $primary_host ? { '' => undef, default => peadm::get_targets($primary_host, 1) }
18+
$new_primary_target = $new_primary_host ? { '' => undef, default => peadm::get_targets($new_primary_host, 1) }
19+
$new_replica_target = $new_replica_host ? { '' => undef, default => peadm::get_targets($new_replica_host, 1) }
20+
$new_primary_postgresql_target = $new_primary_postgresql_host ? { '' => undef, default => peadm::get_targets($new_primary_postgresql_host, 1) }
21+
$new_replica_postgresql_target = $new_replica_postgresql_host ? { '' => undef, default => peadm::get_targets($new_replica_postgresql_host, 1) }
22+
23+
# output the targets
24+
out::message("primary_target:${primary_target}.")
25+
out::message("new_primary_target:${new_primary_target}.")
26+
out::message("new_replica_target:${new_replica_target}.")
27+
out::message("new_primary_postgresql_target:${new_primary_postgresql_target}.")
28+
out::message("new_replica_postgresql_target:${new_replica_postgresql_target}.")
1429

1530
# run infra status on the primary
16-
out::message("Running peadm::status on primary host ${primary_host}")
17-
$primary_status = run_plan('peadm::status', $primary_host, { 'format' => 'json' })
31+
out::message("Running peadm::status on primary host ${primary_target}")
32+
$primary_status = run_plan('peadm::status', $primary_target, { 'format' => 'json' })
1833
out::message($primary_status)
1934

2035
if empty($primary_status['failed']) {
@@ -25,13 +40,13 @@
2540

2641
# perform the migration
2742
run_plan('peadm::migrate',
28-
old_primary_host => $primary_host,
29-
new_primary_host => $new_primary_host,
43+
old_primary_host => $primary_target,
44+
new_primary_host => $new_primary_target,
3045
)
3146

3247
# run infra status on the new primary
33-
out::message("Running peadm::status on new primary host ${new_primary_host}")
34-
$new_primary_status = run_plan('peadm::status', $new_primary_host, { 'format' => 'json' })
48+
out::message("Running peadm::status on new primary host ${new_primary_target}")
49+
$new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' })
3550
out::message($new_primary_status)
3651

3752
if empty($new_primary_status['failed']) {
@@ -40,33 +55,33 @@
4055
fail_plan('Migrated cluster is not healthy, aborting')
4156
}
4257

43-
# get the config from new_primary_host and verify config looks as expected
44-
$result = run_task('peadm::get_peadm_config', $new_primary_host, '_catch_errors' => true).first.to_data()
58+
# get the config from new_primary_target and verify config looks as expected
59+
$result = run_task('peadm::get_peadm_config', $new_primary_target, '_catch_errors' => true).first.to_data()
4560
out::message("peadm_config: ${result}")
46-
# if new_replica_host is supplied then check that is in the expected place in the config
47-
if $new_replica_host {
48-
if $peadm_config['params']['replica_host'] == $new_replica_host {
49-
out::message("New replica host ${new_replica_host} set up correctly")
61+
# if new_replica_target is supplied then check that is in the expected place in the config
62+
if $new_replica_target {
63+
if $peadm_config['params']['replica_host'] == $new_replica_target {
64+
out::message("New replica host ${new_replica_target} set up correctly")
5065
} else {
51-
fail_plan("New replica host ${new_replica_host} was not set up correctly")
66+
fail_plan("New replica host ${new_replica_target} was not set up correctly")
5267
}
5368
}
5469
55-
# if new_primary_postgresql_host is supplied then check that is in the expected place in the config
56-
if $new_primary_postgresql_host {
57-
if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_host {
58-
out::message("New primary postgres host ${new_primary_postgresql_host} set up correctly")
70+
# if new_primary_postgresql_target is supplied then check that is in the expected place in the config
71+
if $new_primary_postgresql_target {
72+
if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_target {
73+
out::message("New primary postgres host ${new_primary_postgresql_target} set up correctly")
5974
} else {
60-
fail_plan("New primary postgres host ${new_primary_postgresql_host} was not set up correctly")
75+
fail_plan("New primary postgres host ${new_primary_postgresql_target} was not set up correctly")
6176
}
6277
}
6378
64-
# if new_replica_postgresql_host is supplied then check that is in the expected place in the config
65-
if $new_replica_postgresql_host {
66-
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_host {
67-
out::message("New primary postgres host ${new_replica_postgresql_host} set up correctly")
79+
# if new_replica_postgresql_target is supplied then check that is in the expected place in the config
80+
if $new_replica_postgresql_target {
81+
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_target {
82+
out::message("New primary postgres host ${new_replica_postgresql_target} set up correctly")
6883
} else {
69-
fail_plan("New primary postgres host ${new_replica_postgresql_host} was not set up correctly")
84+
fail_plan("New primary postgres host ${new_replica_postgresql_target} was not set up correctly")
7085
}
7186
}
7287

0 commit comments

Comments
 (0)