Skip to content

Commit 827f59e

Browse files
(PE-40379) CI to test Standard migration
1 parent 8d174a7 commit 827f59e

File tree

3 files changed

+244
-0
lines changed

3 files changed

+244
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
---
2+
name: Test Migration
3+
on:
4+
pull_request:
5+
paths:
6+
- .github/workflows/**/*
7+
- spec/**/*
8+
- lib/**/*
9+
- tasks/**/*
10+
- functions/**/*
11+
- types/**/*
12+
- plans/**/*
13+
- hiera/**/*
14+
- manifests/**/*
15+
- templates/**/*
16+
- files/**/*
17+
- metadata.json
18+
- Rakefile
19+
- Gemfile
20+
- provision.yaml
21+
- .rspec
22+
- .rubocop.yml
23+
- .puppet-lint.rc
24+
- .fixtures.yml
25+
branches: [main]
26+
workflow_dispatch: {}
27+
jobs:
28+
test-migration:
29+
name: PE ${{ matrix.version }} ${{ matrix.architecture }} on ${{ matrix.image }}
30+
PE upgrade? ${{ matrix.new_pe_version }}
31+
runs-on: ubuntu-latest
32+
env:
33+
BOLT_GEM: true
34+
BOLT_DISABLE_ANALYTICS: true
35+
LANG: en_US.UTF-8
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
architecture:
40+
- standard
41+
- standard-with-dr
42+
# - large
43+
# - extra-large
44+
# - large-with-dr
45+
# - extra-large-with-dr
46+
version: [2021.7.9, 2023.8.1, 2025.0.0]
47+
image: [almalinux-cloud/almalinux-8]
48+
include:
49+
- architecture: standard
50+
version: 2023.8.0
51+
image: almalinux-cloud/almalinux-8
52+
new_pe_version: 2025.0.0
53+
steps:
54+
- name: Checkout Source
55+
uses: actions/checkout@v4
56+
with:
57+
ref: ${{ github.head_ref }}
58+
- name: Activate Ruby 2.7
59+
uses: ruby/setup-ruby@v1
60+
with:
61+
ruby-version: '2.7'
62+
bundler-cache: true
63+
- name: Print bundle environment
64+
if: ${{ github.repository_owner == 'puppetlabs' }}
65+
run: |
66+
echo ::group::info:bundler
67+
bundle env
68+
echo ::endgroup::
69+
- name: Provision test cluster
70+
timeout-minutes: 15
71+
run: |
72+
echo ::group::prepare
73+
mkdir -p $HOME/.ssh
74+
echo 'Host *' > $HOME/.ssh/config
75+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
76+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
77+
bundle exec rake spec_prep
78+
echo ::endgroup::
79+
echo ::group::provision
80+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
81+
--modulepath spec/fixtures/modules \
82+
provider=provision_service \
83+
image=${{ matrix.image }} \
84+
architecture=${{ matrix.architecture }}-migration \
85+
--log-level trace
86+
echo ::endgroup::
87+
echo ::group::info:request
88+
cat request.json || true; echo
89+
echo ::endgroup::
90+
echo ::group::info:inventory
91+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
92+
echo ::endgroup::
93+
echo ::group::certnames
94+
bundle exec bolt plan run peadm_spec::add_inventory_hostnames \
95+
--inventory spec/fixtures/litmus_inventory.yaml \
96+
--modulepath spec/fixtures/modules \
97+
--no-host-key-check \
98+
inventory_file=spec/fixtures/litmus_inventory.yaml
99+
echo ::endgroup::
100+
- name: Output contents of litmus_inventory.yaml
101+
run: |
102+
cat spec/fixtures/litmus_inventory.yaml
103+
- name: Install PE on test cluster
104+
timeout-minutes: 120
105+
run: |
106+
bundle exec bolt plan run peadm_spec::install_test_cluster \
107+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
108+
--modulepath spec/fixtures/modules \
109+
architecture=${{ matrix.architecture }} \
110+
version=${{ matrix.version }} \
111+
console_password=${{ secrets.CONSOLE_PASSWORD }} \
112+
code_manager_auto_configure=true
113+
- name: Perform migration
114+
run: |
115+
echo ::group::prepare
116+
mkdir -p $HOME/.ssh
117+
echo 'Host *' > $HOME/.ssh/config
118+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
119+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
120+
bundle exec rake spec_prep
121+
echo ::endgroup::
122+
bundle exec bolt plan run peadm_spec::test_migration \
123+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
124+
--modulepath spec/fixtures/modules \
125+
primary_host=$(yq -r '.groups[].targets[] | select(.vars.role == "primary") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
126+
new_primary_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-primary") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
127+
new_replica_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
128+
new_primary_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-primary-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
129+
new_replica_postgresql_host=$(yq -r '.groups[].targets[] | select(.vars.role == "new-replica-pdb-postgresql") | .name // ""' spec/fixtures/litmus_inventory.yaml) \
130+
upgrade_version=${{ matrix.new_pe_version }} \
131+
--no-host-key-check
132+
- name: Tear down PE ${{ matrix.architecture }} test cluster
133+
if: ${{ always() }}
134+
continue-on-error: true
135+
run: |-
136+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
137+
echo ::group::tear_down
138+
bundle exec rake 'litmus:tear_down'
139+
echo ::endgroup::
140+
echo ::group::info:request
141+
cat request.json || true; echo
142+
echo ::endgroup::
143+
fi

spec/acceptance/peadm_spec/plans/provision_test_cluster.pp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@
5454
['primary', 'primary-pdb-postgresql', 'compiler',
5555
'replica', 'replica-pdb-postgresql', 'compiler', 'spare-replica']
5656
}
57+
'standard-migration': {
58+
['primary', 'new-primary']
59+
}
60+
'standard-with-dr-migration': {
61+
['primary', 'replica', 'new-primary', 'new-replica']
62+
}
63+
'large-migration': {
64+
['primary', 'compiler', 'new-primary']
65+
}
66+
'large-with-dr-migration': {
67+
['primary', 'compiler', 'replica', 'compiler', 'new-primary', 'new-replica']
68+
}
69+
'extra-large-migration': {
70+
['primary', 'primary-pdb-postgresql', 'compiler', 'new-primary', 'new-primary-pdb-postgresql']
71+
}
72+
'extra-large-with-dr-migration': {
73+
['primary', 'primary-pdb-postgresql', 'compiler', 'replica', 'replica-pdb-postgresql', 'compiler', 'new-primary', 'new-replica', 'new-primary-pdb-postgresql', 'new-replica-pdb-postgresql']
74+
}
5775
default: {
5876
fail_plan("Unknown architecture: ${architecture}")
5977
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
plan peadm_spec::test_migration(
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+
Optional[String] $upgrade_version = undef,
8+
) {
9+
# Convert String values to targets if they are not blank
10+
$primary_target = $primary_host ? { '' => undef, default => peadm::get_targets($primary_host, 1) }
11+
$new_primary_target = $new_primary_host ? { '' => undef, default => peadm::get_targets($new_primary_host, 1) }
12+
$new_replica_target = $new_replica_host ? { '' => undef, default => peadm::get_targets($new_replica_host, 1) }
13+
$new_primary_postgresql_target = $new_primary_postgresql_host ? { '' => undef, default => peadm::get_targets($new_primary_postgresql_host, 1) }
14+
$new_replica_postgresql_target = $new_replica_postgresql_host ? { '' => undef, default => peadm::get_targets($new_replica_postgresql_host, 1) }
15+
16+
# run infra status on the primary
17+
out::message("Running peadm::status on primary host ${primary_target}")
18+
$primary_status = run_plan('peadm::status', $primary_target, { 'format' => 'json' })
19+
out::message($primary_status)
20+
21+
if empty($primary_status['failed']) {
22+
out::message('Cluster is healthy, continuing')
23+
} else {
24+
fail_plan('Cluster is not healthy, aborting')
25+
}
26+
27+
# perform the migration
28+
run_plan('peadm::migrate',
29+
old_primary_host => $primary_target,
30+
new_primary_host => $new_primary_target,
31+
upgrade_version => $upgrade_version,
32+
replica_host => $new_replica_target,
33+
)
34+
35+
# run infra status on the new primary
36+
peadm::wait_until_service_ready('all', $new_primary_target)
37+
out::message("Running peadm::status on new primary host ${new_primary_target}")
38+
$new_primary_status = run_plan('peadm::status', $new_primary_target, { 'format' => 'json' })
39+
if empty($new_primary_status['failed']) {
40+
out::message('Migrated cluster is healthy, continuing')
41+
} else {
42+
out::message('Migrated cluster is not healthy, verify status of services')
43+
}
44+
45+
# get the config from new_primary_target and verify config looks as expected
46+
$peadm_config = run_task('peadm::get_peadm_config', $new_primary_target).first.value
47+
48+
# if new_replica_target is supplied then check that is in the expected place in the config
49+
if $new_replica_target {
50+
if $peadm_config['params']['replica_host'] == $new_replica_target {
51+
out::message("New replica host ${new_replica_target} set up correctly")
52+
} else {
53+
fail_plan("New replica host ${new_replica_target} was not set up correctly")
54+
}
55+
}
56+
57+
# if new_primary_postgresql_target is supplied then check that is in the expected place in the config
58+
if $new_primary_postgresql_target {
59+
if $peadm_config['params']['primary_postgresql_host'] == $new_primary_postgresql_target {
60+
out::message("New primary postgres host ${new_primary_postgresql_target} set up correctly")
61+
} else {
62+
fail_plan("New primary postgres host ${new_primary_postgresql_target} was not set up correctly")
63+
}
64+
}
65+
66+
# if new_replica_postgresql_target is supplied then check that is in the expected place in the config
67+
if $new_replica_postgresql_target {
68+
if $peadm_config['params']['replica_postgresql_host'] == $new_replica_postgresql_target {
69+
out::message("New primary postgres host ${new_replica_postgresql_target} set up correctly")
70+
} else {
71+
fail_plan("New primary postgres host ${new_replica_postgresql_target} was not set up correctly")
72+
}
73+
}
74+
75+
# if a new PE version was specified then check it has been upgraded
76+
if $upgrade_version and $upgrade_version != '' and !empty($upgrade_version) {
77+
if $peadm_config['pe_version'] == $upgrade_version {
78+
out::message("Upgraded to new PE version ${upgrade_version} correctly")
79+
} else {
80+
fail_plan("Failed to upgrade to new PE version ${upgrade_version} correctly")
81+
}
82+
}
83+
}

0 commit comments

Comments
 (0)