Skip to content

Commit 10d7018

Browse files
authored
Merge pull request #200 from puppetlabs/SOLARCH-589
SOLARCH-589: Write an acceptance test for the PEADM upgrade plan
2 parents 8cb301c + ae79617 commit 10d7018

File tree

3 files changed

+270
-4
lines changed

3 files changed

+270
-4
lines changed
Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
---
2+
name: "Upgrade test"
3+
4+
on: push
5+
6+
# on:
7+
# workflow_dispatch:
8+
# inputs:
9+
# image:
10+
# description: 'GCP image for test cluster'
11+
# required: true
12+
# default: 'centos-7'
13+
# architecture:
14+
# description: 'PE architecture to test'
15+
# required: true
16+
# default: 'standard'
17+
# version:
18+
# description: 'PE version to install'
19+
# required: true
20+
# default: '2019.8.7'
21+
# version_to_upgrade:
22+
# description: 'PE version to upgrade'
23+
# required: true
24+
# default: '2021.2.0'
25+
# download_mode:
26+
# description: 'peadm download_mode'
27+
# required: false
28+
# default: 'direct'
29+
# ssh-debugging:
30+
# description: 'Boolean; whether or not to pause for ssh debugging'
31+
# required: true
32+
# default: 'false'
33+
34+
env:
35+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
36+
HONEYCOMB_DATASET: litmus tests
37+
38+
jobs:
39+
test-upgrade:
40+
name: "PE ${{ matrix.version }} ${{ matrix.architecture }} on ${{ matrix.image }}"
41+
runs-on: ubuntu-20.04
42+
env:
43+
BOLT_GEM: true
44+
BOLT_DISABLE_ANALYTICS: true
45+
BUILDEVENT_FILE: '../buildevents.txt'
46+
LANG: 'en_US.UTF-8'
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
architecture:
51+
- 'standard'
52+
- 'extra-large-with-dr'
53+
version:
54+
- '2019.8.8'
55+
version_to_upgrade:
56+
- '2021.3.0'
57+
image:
58+
- 'centos-7'
59+
download_mode:
60+
- 'direct'
61+
62+
steps:
63+
- name: 'Start SSH session'
64+
if: ${{ github.event.inputs.ssh-debugging == 'true' }}
65+
uses: luchihoratiu/debug-via-ssh@main
66+
with:
67+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
68+
SSH_PASS: ${{ secrets.SSH_PASS }}
69+
70+
- name: "Honeycomb: Start recording"
71+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
72+
with:
73+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
74+
dataset: ${{ env.HONEYCOMB_DATASET }}
75+
job-status: ${{ job.status }}
76+
77+
- name: "Honeycomb: Start first step"
78+
run: |
79+
echo STEP_ID=setup-test-cluster >> $GITHUB_ENV
80+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
81+
82+
- name: "Checkout Source"
83+
uses: actions/checkout@v2
84+
85+
- name: "Activate Ruby 2.7"
86+
uses: ruby/setup-ruby@v1
87+
with:
88+
ruby-version: "2.7"
89+
bundler-cache: true
90+
91+
- name: "Print bundle environment"
92+
if: ${{ github.repository_owner == 'puppetlabs' }}
93+
run: |
94+
echo ::group::info:bundler
95+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
96+
echo ::endgroup::
97+
98+
- name: "Honeycomb: Record environment setup time"
99+
if: ${{ always() }}
100+
run: |
101+
echo ::group::honeycomb
102+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Set up environment'
103+
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-provision >> $GITHUB_ENV
104+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
105+
echo ::endgroup::
106+
107+
- name: 'Provision test cluster'
108+
timeout-minutes: 15
109+
run: |
110+
echo ::group::prepare
111+
mkdir -p $HOME/.ssh
112+
echo 'Host *' > $HOME/.ssh/config
113+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
114+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
115+
buildevents cmd $TRACE_ID $STEP_ID 'rake spec_prep' -- bundle exec rake spec_prep
116+
echo ::endgroup::
117+
118+
echo ::group::provision
119+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::provision_test_cluster' -- \
120+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
121+
--modulepath spec/fixtures/modules \
122+
provider=provision_service \
123+
image=${{ matrix.image }} \
124+
architecture=${{ matrix.architecture }}
125+
echo ::endgroup::
126+
127+
echo ::group::info:request
128+
cat request.json || true; echo
129+
echo ::endgroup::
130+
131+
echo ::group::info:inventory
132+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
133+
echo ::endgroup::
134+
135+
- name: "Honeycomb: Record provision time"
136+
if: ${{ always() }}
137+
run: |
138+
echo ::group::honeycomb
139+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Provision test cluster'
140+
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-install >> $GITHUB_ENV
141+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
142+
echo ::endgroup::
143+
144+
- name: 'Install PE on test cluster'
145+
timeout-minutes: 120
146+
run: |
147+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::install_test_cluster' -- \
148+
bundle exec bolt plan run peadm_spec::install_test_cluster \
149+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
150+
--modulepath spec/fixtures/modules \
151+
architecture=${{ matrix.architecture }} \
152+
version=${{ matrix.version }}
153+
154+
- name: "Honeycomb: Record install time"
155+
if: ${{ always() }}
156+
run: |
157+
echo ::group::honeycomb
158+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Install PE on test cluster'
159+
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-tear_down >> $GITHUB_ENV
160+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
161+
echo ::endgroup::
162+
163+
- name: 'Wait as long as the file ${HOME}/pause file is present'
164+
if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }}
165+
run: |
166+
while [ -f "${HOME}/pause" ] ; do
167+
echo "${HOME}/pause present, sleeping for 60 seconds..."
168+
sleep 60
169+
done
170+
echo "${HOME}/pause absent, continuing workflow."
171+
172+
- name: 'Upgrade PE on test cluster'
173+
timeout-minutes: 120
174+
run: |
175+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::upgrade_test_cluster' -- \
176+
bundle exec bolt plan run peadm_spec::upgrade_test_cluster \
177+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
178+
--modulepath spec/fixtures/modules \
179+
architecture=${{ matrix.architecture }} \
180+
download_mode=${{ matrix.download_mode }} \
181+
version=${{ matrix.version_to_upgrade }}
182+
183+
- name: "Honeycomb: Record upgrade time"
184+
if: ${{ always() }}
185+
run: |
186+
echo ::group::honeycomb
187+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Upgrade PE on test cluster'
188+
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.version_to_upgrade }}-tear_down >> $GITHUB_ENV
189+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
190+
echo ::endgroup::
191+
192+
- name: 'Tear down test cluster'
193+
if: ${{ always() }}
194+
continue-on-error: true
195+
run: |
196+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
197+
echo ::group::tear_down
198+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
199+
echo ::endgroup::
200+
201+
echo ::group::info:request
202+
cat request.json || true; echo
203+
echo ::endgroup::
204+
fi
205+
206+
- name: "Honeycomb: Record tear down time"
207+
if: ${{ always() }}
208+
run: |
209+
echo ::group::honeycomb
210+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Tear down test cluster'
211+
echo ::endgroup::

documentation/pre_post_checks.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#pre and post flight testing
1+
# Pre and post flight testing
22

33
The module as been updated to be supported by Puppetlabs [Litmus](https://github.com/puppetlabs/puppet_litmus/wiki/Overview-of-Litmus#provision).
44

@@ -8,7 +8,7 @@ Additionally some stand a lone preflight checks will be added presently.
88

99
## Setup
1010

11-
The module as been converted to Litmus as the directions found at https://github.com/puppetlabs/puppet_litmus/wiki/Converting-a-module-to-use-Litmus that means the following files have been added.
11+
The module as been converted to Litmus as the directions found at https://puppetlabs.github.io/litmus/Converting-modules-to-use-Litmus.html that means the following files have been added.
1212
``` shell
1313
\.
1414
├── spec
@@ -23,7 +23,7 @@ An update to .gitignore for the Litmus generated `.rerun.json` has also been mad
2323

2424
## Usage
2525

26-
Litmus can provision local testing via provisioning and generation of a Bolt inventory.yaml, see https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#provision-a-target-to-test-against for an example.
26+
Litmus can provision local testing via provisioning and generation of a Bolt inventory.yaml, see https://puppetlabs.github.io/litmus/Running-acceptance-tests.html for an example.
2727

2828
### Inventory
2929
when testing locally with Vagrant or VMpooler you can use the `litmus:provision` rake task to generate an inventory.yml.
@@ -122,7 +122,7 @@ end
122122
123123
```
124124

125-
For running the tests review the standard usage of Litmusfor installing and running tests https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#run-the-tests
125+
For running the tests review the standard usage of Litmusfor installing and running tests https://puppetlabs.github.io/litmus/Running-acceptance-tests.html#6-run-the-motd-acceptance-tests
126126
remember we are doing these actions from within the context of the PDK `pdk bundle exec rake ` has several sub commands.
127127

128128
```shell
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
plan peadm_spec::upgrade_test_cluster(
2+
$architecture,
3+
$version,
4+
$download_mode
5+
){
6+
7+
$t = get_targets('*')
8+
wait_until_available($t)
9+
10+
parallelize($t) |$target| {
11+
$fqdn = run_command('hostname -f', $target)
12+
$target.set_var('certname', $fqdn.first['stdout'].chomp)
13+
}
14+
15+
$common_params = {
16+
download_mode => $download_mode,
17+
version => $version,
18+
}
19+
20+
$arch_params =
21+
case $architecture {
22+
'standard': {{
23+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
24+
}}
25+
'standard-with-dr': {{
26+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
27+
replica_host => $t.filter |$n| { $n.vars['role'] == 'replica' },
28+
}}
29+
'large': {{
30+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
31+
compiler_hosts => $t.filter |$n| { $n.vars['role'] == 'compiler' },
32+
}}
33+
'large-with-dr': {{
34+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
35+
replica_host => $t.filter |$n| { $n.vars['role'] == 'replica' },
36+
compiler_hosts => $t.filter |$n| { $n.vars['role'] == 'compiler' },
37+
}}
38+
'extra-large': {{
39+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
40+
primary_postgresql_host => $t.filter |$n| { $n.vars['role'] == 'primary-pdb-postgresql' },
41+
compiler_hosts => $t.filter |$n| { $n.vars['role'] == 'compiler' },
42+
}}
43+
'extra-large-with-dr': {{
44+
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
45+
primary_postgresql_host => $t.filter |$n| { $n.vars['role'] == 'primary-pdb-postgresql' },
46+
replica_host => $t.filter |$n| { $n.vars['role'] == 'replica' },
47+
replica_postgresql_host => $t.filter |$n| { $n.vars['role'] == 'replica-pdb-postgresql' },
48+
compiler_hosts => $t.filter |$n| { $n.vars['role'] == 'compiler' },
49+
}}
50+
default: { fail('Invalid architecture!') }
51+
}
52+
53+
$params = $arch_params + $common_params
54+
run_plan('peadm::upgrade', $params)
55+
}

0 commit comments

Comments
 (0)