Skip to content

Commit f45e1d8

Browse files
author
petergmurphy
committed
Add CI test for replace_failed_postgresql plan
1 parent 6f88c9a commit f45e1d8

File tree

1 file changed

+176
-0
lines changed

1 file changed

+176
-0
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
name: Test migration for failed database
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-migrate-failed-db:
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: [extra-large-with-dr]
39+
version: [2023.8.0] # can change to test multiple versions once this one works
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: Run migration
58+
run: |
59+
echo ::group::prepare
60+
mkdir -p $HOME/.ssh
61+
echo 'Host *' > $HOME/.ssh/config
62+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
63+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
64+
bundle exec rake spec_prep
65+
echo ::endgroup::
66+
bundle exec bolt plan show
67+
bundle exec bolt plan run peadm::replace_failed_postgresql \
68+
--modulepath=spec/fixtures/modules \
69+
primary_host=primary \
70+
replica_host=replica \
71+
working_postgresql_host=primary-pdb-postgresql \
72+
failed_postgresql_host=replica-pdb-postgresql \
73+
replacement_postgresql_host=primary-pdb-postgresql \
74+
--no-host-key-check
75+
- name: Provision test cluster
76+
timeout-minutes: 15
77+
run: |
78+
echo ::group::prepare
79+
mkdir -p $HOME/.ssh
80+
echo 'Host *' > $HOME/.ssh/config
81+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
82+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
83+
bundle exec rake spec_prep
84+
echo ::endgroup::
85+
echo ::group::provision
86+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
87+
--modulepath spec/fixtures/modules \
88+
provider=provision_service \
89+
image=${{ matrix.image }} \
90+
architecture=${{ matrix.architecture }} \
91+
--log-level trace
92+
echo ::endgroup::
93+
echo ::group::info:request
94+
cat request.json || true; echo
95+
echo ::endgroup::
96+
echo ::group::info:inventory
97+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
98+
echo ::endgroup::
99+
- name: Change PE inventory name
100+
run: |
101+
mv spec/fixtures/litmus_inventory.yaml spec/fixtures/litmus_inventory_PE_XL_DR.yaml
102+
- name: Install PE on test cluster
103+
timeout-minutes: 120
104+
run: |
105+
bundle exec bolt plan run peadm_spec::install_test_cluster \
106+
--inventoryfile spec/fixtures/litmus_inventory_PE_XL_DR.yaml \
107+
--modulepath spec/fixtures/modules \
108+
architecture=${{ matrix.architecture }} \
109+
version=${{ matrix.version }} \
110+
console_password=${{ secrets.CONSOLE_PASSWORD }}
111+
- name: Provision single node
112+
timeout-minutes: 15
113+
run: |
114+
echo ::group::prepare
115+
mkdir -p $HOME/.ssh
116+
echo 'Host *' > $HOME/.ssh/config
117+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
118+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
119+
bundle exec rake spec_prep
120+
echo ::endgroup::
121+
echo ::group::provision
122+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
123+
--modulepath spec/fixtures/modules \
124+
provider=provision_service \
125+
image=almalinux-cloud/almalinux-8 \
126+
architecture=standard \
127+
--log-level trace
128+
echo ::endgroup::
129+
echo ::group::info:request
130+
cat request.json || true; echo
131+
echo ::endgroup::
132+
echo ::group::info:inventory
133+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
134+
echo ::endgroup::
135+
- name: Change single node inventory name
136+
run: |
137+
mv spec/fixtures/litmus_inventory.yaml spec/fixtures/litmus_inventory_single_node.yaml
138+
# - name: Run migration
139+
# run: |
140+
# bundle exec bolt plan run peadm::replace_failed_postgresql \
141+
# --inventoryfile=spec/fixtures/litmus_inventory_PE_XL_DR.yaml \
142+
# --modulepath=spec/fixtures/modules \
143+
# primary_host=primary \
144+
# replica_host=replica \
145+
# working_postgresql_host=primary-pdb-postgresql \
146+
# failed_postgresql_host=replica-pdb-postgresql \
147+
# replacement_postgresql_host=$(yq '.groups[].targets[] | select(.vars.role == "primary") | .uri' spec/fixtures/litmus_inventory_single_node.yaml) \
148+
# --no-host-key-check
149+
- name: Tear down PE XL DR test cluster
150+
if: ${{ always() }}
151+
continue-on-error: true
152+
run: |-
153+
if [ -f spec/fixtures/litmus_inventory_PE_XL_DR.yaml ]; then
154+
mv spec/fixtures/litmus_inventory_PE_XL_DR.yaml spec/fixtures/litmus_inventory.yaml
155+
echo ::group::tear_down
156+
bundle exec rake 'litmus:tear_down'
157+
echo ::endgroup::
158+
echo ::group::info:request
159+
cat request.json || true; echo
160+
echo ::endgroup::
161+
rm -f spec/fixtures/litmus_inventory.yaml
162+
fi
163+
- name: Tear down single node
164+
if: ${{ always() }}
165+
continue-on-error: true
166+
run: |-
167+
if [ -f spec/fixtures/litmus_inventory_single_node.yaml ]; then
168+
mv spec/fixtures/litmus_inventory_single_node.yaml spec/fixtures/litmus_inventory.yaml
169+
echo ::group::tear_down
170+
bundle exec rake 'litmus:tear_down'
171+
echo ::endgroup::
172+
echo ::group::info:request
173+
cat request.json || true; echo
174+
echo ::endgroup::
175+
rm -f spec/fixtures/litmus_inventory.yaml
176+
fi

0 commit comments

Comments
 (0)