Skip to content

Commit 47b60d0

Browse files
(PE-40377) CI for Standard migration
1 parent d86958b commit 47b60d0

File tree

3 files changed

+216
-0
lines changed

3 files changed

+216
-0
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
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+
runs-on: ubuntu-20.04
31+
env:
32+
BOLT_GEM: true
33+
BOLT_DISABLE_ANALYTICS: true
34+
LANG: en_US.UTF-8
35+
strategy:
36+
fail-fast: false
37+
matrix:
38+
architecture: [standard, large, extra-large, standard-with-dr, large-with-dr, extra-large-with-dr]
39+
version: [2021.7.9, 2023.8.1, 2025.0.0]
40+
image: [almalinux-cloud/almalinux-8]
41+
steps:
42+
- name: Checkout Source
43+
uses: actions/checkout@v4
44+
with:
45+
ref: ${{ github.head_ref }}
46+
- name: Activate Ruby 2.7
47+
uses: ruby/setup-ruby@v1
48+
with:
49+
ruby-version: '2.7'
50+
bundler-cache: true
51+
- name: Print bundle environment
52+
if: ${{ github.repository_owner == 'puppetlabs' }}
53+
run: |
54+
echo ::group::info:bundler
55+
bundle env
56+
echo ::endgroup::
57+
- name: Provision test cluster
58+
timeout-minutes: 15
59+
run: |
60+
echo ::group::prepare
61+
mkdir -p $HOME/.ssh
62+
echo 'Host *' > $HOME/.ssh/config
63+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
64+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
65+
bundle exec rake spec_prep
66+
echo ::endgroup::
67+
echo ::group::provision
68+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
69+
--modulepath spec/fixtures/modules \
70+
provider=provision_service \
71+
image=${{ matrix.image }} \
72+
architecture=${{ matrix.architecture }}-migration \
73+
--log-level trace
74+
echo ::endgroup::
75+
echo ::group::info:request
76+
cat request.json || true; echo
77+
echo ::endgroup::
78+
echo ::group::info:inventory
79+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
80+
echo ::endgroup::
81+
echo ::group::certnames
82+
bundle exec bolt plan run peadm_spec::add_inventory_hostnames \
83+
--inventory spec/fixtures/litmus_inventory.yaml \
84+
--modulepath spec/fixtures/modules \
85+
--no-host-key-check \
86+
inventory_file=spec/fixtures/litmus_inventory.yaml
87+
echo ::endgroup::
88+
- name: Output contents of litmus_inventory.yaml
89+
run: |
90+
cat spec/fixtures/litmus_inventory.yaml
91+
- name: Perform migration
92+
run: |
93+
echo ::group::prepare
94+
mkdir -p $HOME/.ssh
95+
echo 'Host *' > $HOME/.ssh/config
96+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
97+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
98+
bundle exec rake spec_prep
99+
echo ::endgroup::
100+
bundle exec bolt plan run peadm_spec::test_migration \
101+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
102+
--modulepath spec/fixtures/modules \
103+
primary_host=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .name' spec/fixtures/litmus_inventory.yaml) \
104+
replica_host=$(yq '.groups[].targets[] | select(.vars.role == "replica") | .name' spec/fixtures/litmus_inventory.yaml) \
105+
primary_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "primary-pdb-postgresql") | .name' spec/fixtures/litmus_inventory.yaml) \
106+
replica_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "replica-pdb-postgresql") | .name' spec/fixtures/litmus_inventory.yaml) \
107+
new_primary_host=$(yq '.groups[].targets[] | select(.vars.role == "new-primary") | .name' spec/fixtures/litmus_inventory.yaml) \
108+
new_replica_host=$(yq '.groups[].targets[] | select(.vars.role == "new-replica") | .name' spec/fixtures/litmus_inventory.yaml) \
109+
new_primary_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "new-primary-pdb-postgresql") | .name' spec/fixtures/litmus_inventory.yaml) \
110+
new_replica_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "new-replica-pdb-postgresql") | .name' spec/fixtures/litmus_inventory.yaml) \
111+
--no-host-key-check
112+
- name: Install PE on test cluster
113+
timeout-minutes: 120
114+
run: |
115+
bundle exec bolt plan run peadm_spec::install_test_cluster \
116+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
117+
--modulepath spec/fixtures/modules \
118+
architecture=${{ matrix.architecture }} \
119+
version=${{ matrix.version }} \
120+
console_password=${{ secrets.CONSOLE_PASSWORD }} \
121+
code_manager_auto_configure=true
122+
- name: Tear down PE ${{ matrix.architecture }} test cluster
123+
if: ${{ always() }}
124+
continue-on-error: true
125+
run: |-
126+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
127+
echo ::group::tear_down
128+
bundle exec rake 'litmus:tear_down'
129+
echo ::endgroup::
130+
echo ::group::info:request
131+
cat request.json || true; echo
132+
echo ::endgroup::
133+
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']
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: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
plan peadm_spec::test_migration(
2+
Peadm::SingleTargetSpec $primary_host,
3+
Peadm::SingleTargetSpec $replica_host,
4+
Peadm::SingleTargetSpec $primary_postgresql_host,
5+
Peadm::SingleTargetSpec $replica_postgresql_host,
6+
Peadm::SingleTargetSpec $new_primary_host,
7+
Peadm::SingleTargetSpec $new_replica_host,
8+
Peadm::SingleTargetSpec $new_primary_postgresql_host,
9+
Peadm::SingleTargetSpec $new_replica_postgresql_host,
10+
) {
11+
out::message("primary_host:${primary_host}.")
12+
out::message("replica_host:${replica_host}.")
13+
out::message("primary_postgresql_host:${primary_postgresql_host}.")
14+
out::message("replica_postgresql_host:${replica_postgresql_host}.")
15+
out::message("new_primary_host:${new_primary_host}.")
16+
out::message("new_replica_host:${new_replica_host}.")
17+
out::message("new_primary_postgresql_host:${new_primary_postgresql_host}.")
18+
out::message("new_replica_postgresql_host:${new_replica_postgresql_host}.")
19+
20+
# run infra status on the primary
21+
out::message("Running peadm::status on primary host ${primary_host}")
22+
$primary_status = run_plan('peadm::status', $primary_host, { 'format' => 'json' })
23+
out::message($primary_status)
24+
25+
if empty($primary_status['failed']) {
26+
out::message('Cluster is healthy, continuing')
27+
} else {
28+
fail_plan('Cluster is not healthy, aborting')
29+
}
30+
31+
# # perform the migration
32+
# run_plan('peadm::migrate',
33+
# old_primary_host => $primary_host,
34+
# new_primary_host => $new_primary_host,
35+
# )
36+
37+
# # run infra status on the new primary
38+
# out::message("Running peadm::status on new primary host ${new_primary_host}")
39+
# $new_primary_status = run_plan('peadm::status', $new_primary_host, { 'format' => 'json' })
40+
# out::message($primary_status)
41+
42+
# if empty($new_primary_status['failed']) {
43+
# out::message('Migrated cluster is healthy, continuing')
44+
# } else {
45+
# fail_plan('Migrated cluster is not healthy, aborting')
46+
# }
47+
48+
# MIGHT WANT TO ADD CHECKS HERE TO VERIFY THE NEW ARCHITECTURE IS AS EXPECTED
49+
50+
# # get the config from primary_host and verify failed_postgresql_host is removed and replacement was added
51+
# $result = run_task('peadm::get_peadm_config', $primary_host, '_catch_errors' => true).first.to_data()
52+
# $primary_postgres_host = $result['value']['params']['primary_postgresql_host']
53+
# $replica_postgres_host = $result['value']['params']['replica_postgresql_host']
54+
55+
# if $primary_postgres_host == $failed_postgresql_host or $replica_postgres_host == $failed_postgresql_host {
56+
# fail_plan("Failed PostgreSQL host ${failed_postgresql_host} was not removed from the PE configuration")
57+
# } else {
58+
# out::message("Failed PostgreSQL host ${failed_postgresql_host} was removed from the PE configuration")
59+
# }
60+
# if $primary_postgres_host == $replacement_postgresql_host or $replica_postgres_host == $replacement_postgresql_host {
61+
# out::message("Replacement PostgreSQL host ${replacement_postgresql_host} was added to the PE configuration")
62+
# } else {
63+
# fail_plan("Replacement PostgreSQL host ${replacement_postgresql_host} was not added the PE configuration")
64+
# }
65+
}

0 commit comments

Comments
 (0)