|
1 | 1 | 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, |
7 | 7 | Optional[Peadm::SingleTargetSpec] $upgrade_version = undef, |
8 | 8 | ) { |
9 | 9 | out::message("primary_host:${primary_host}.") |
10 | 10 | out::message("new_primary_host:${new_primary_host}.") |
11 | 11 | out::message("new_replica_host:${new_replica_host}.") |
12 | 12 | out::message("new_primary_postgresql_host:${new_primary_postgresql_host}.") |
13 | 13 | 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}.") |
14 | 29 |
|
15 | 30 | # 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' }) |
18 | 33 | out::message($primary_status) |
19 | 34 |
|
20 | 35 | if empty($primary_status['failed']) { |
|
25 | 40 |
|
26 | 41 | # perform the migration |
27 | 42 | 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, |
30 | 45 | ) |
31 | 46 |
|
32 | 47 | # 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' }) |
35 | 50 | out::message($new_primary_status) |
36 | 51 |
|
37 | 52 | if empty($new_primary_status['failed']) { |
|
40 | 55 | fail_plan('Migrated cluster is not healthy, aborting') |
41 | 56 | } |
42 | 57 |
|
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() |
45 | 60 | 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") |
50 | 65 | } 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") |
52 | 67 | } |
53 | 68 | } |
54 | 69 |
|
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") |
59 | 74 | } 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") |
61 | 76 | } |
62 | 77 | } |
63 | 78 |
|
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") |
68 | 83 | } 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") |
70 | 85 | } |
71 | 86 | } |
72 | 87 |
|
|
0 commit comments