Skip to content

Commit 9e29589

Browse files
committed
first WIP version of test plan and workflow
1 parent 564cafe commit 9e29589

File tree

2 files changed

+162
-68
lines changed

2 files changed

+162
-68
lines changed

.github/workflows/test-backup-restore.yaml

+138-68
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,85 @@ on:
2121
required: true
2222
default: 'false'
2323

24-
env:
25-
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
26-
HONEYCOMB_DATASET: litmus tests
27-
2824
jobs:
29-
test-backup-restore:
30-
name: "PE ${{ matrix.version }} ${{ matrix.architecture }} on ${{ matrix.image }}"
25+
install-cluster-A:
26+
name: "Cluster A: PE ${{ inputs.version }} ${{ inputs.architecture }} on ${{ inputs.image }}"
27+
runs-on: ubuntu-20.04
28+
env:
29+
BOLT_GEM: true
30+
BOLT_DISABLE_ANALYTICS: true
31+
BUILDEVENT_FILE: '../buildevents.txt'
32+
LANG: 'en_US.UTF-8'
33+
34+
steps:
35+
- name: "Checkout Source"
36+
uses: actions/checkout@v2
37+
38+
- name: "Activate Ruby 2.7"
39+
uses: ruby/setup-ruby@v1
40+
with:
41+
ruby-version: "2.7"
42+
bundler-cache: true
43+
44+
- name: "Print bundle environment"
45+
if: ${{ github.repository_owner == 'puppetlabs' }}
46+
run: |
47+
echo ::group::info:bundler
48+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
49+
echo ::endgroup::
50+
51+
- name: 'Provision test cluster'
52+
timeout-minutes: 15
53+
run: |
54+
echo ::group::prepare
55+
mkdir -p $HOME/.ssh
56+
echo 'Host *' > $HOME/.ssh/config
57+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
58+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
59+
buildevents cmd $TRACE_ID $STEP_ID 'rake spec_prep' -- bundle exec rake spec_prep
60+
echo ::endgroup::
61+
62+
echo ::group::provision
63+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::provision_test_cluster' -- \
64+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
65+
--modulepath spec/fixtures/modules \
66+
provider=provision_service \
67+
image=${{ inputs.image }} \
68+
architecture=${{ inputs.architecture }}
69+
echo ::endgroup::
70+
71+
echo ::group::info:request
72+
cat request.json || true; echo
73+
echo ::endgroup::
74+
75+
echo ::group::info:inventory
76+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
77+
echo ::endgroup::
78+
79+
- name: Save inventory file A to an artifact
80+
uses: actions/upload-artifact@v2
81+
with:
82+
name: inventory_A
83+
path: spec/fixtures/litmus_inventory.yaml
84+
85+
- name: 'Install PE on test cluster'
86+
timeout-minutes: 120
87+
run: |
88+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::install_test_cluster' -- \
89+
bundle exec bolt plan run peadm_spec::install_test_cluster \
90+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
91+
--modulepath spec/fixtures/modules \
92+
architecture=${{ inputs.architecture }} \
93+
version=${{ inputs.version }}
94+
95+
install-cluster-B:
96+
name: "Cluster B: PE ${{ inputs.version }} ${{ inputs.architecture }} on ${{ inputs.image }}"
3197
runs-on: ubuntu-20.04
3298
env:
3399
BOLT_GEM: true
34100
BOLT_DISABLE_ANALYTICS: true
35101
BUILDEVENT_FILE: '../buildevents.txt'
36102
LANG: 'en_US.UTF-8'
37-
strategy:
38-
fail-fast: false
39-
matrix:
40-
architecture:
41-
- "${{ github.event.inputs.architecture }}"
42-
version:
43-
- "${{ github.event.inputs.version }}"
44-
image:
45-
- "${{ github.event.inputs.image }}"
46103

47104
steps:
48105
- name: 'Start SSH session'
@@ -52,18 +109,6 @@ jobs:
52109
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
53110
SSH_PASS: ${{ secrets.SSH_PASS }}
54111

55-
- name: "Honeycomb: Start recording"
56-
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
57-
with:
58-
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
59-
dataset: ${{ env.HONEYCOMB_DATASET }}
60-
job-status: ${{ job.status }}
61-
62-
- name: "Honeycomb: Start first step"
63-
run: |
64-
echo STEP_ID=setup-test-cluster >> $GITHUB_ENV
65-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
66-
67112
- name: "Checkout Source"
68113
uses: actions/checkout@v2
69114

@@ -80,15 +125,6 @@ jobs:
80125
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
81126
echo ::endgroup::
82127
83-
- name: "Honeycomb: Record environment setup time"
84-
if: ${{ always() }}
85-
run: |
86-
echo ::group::honeycomb
87-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Set up environment'
88-
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-provision >> $GITHUB_ENV
89-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
90-
echo ::endgroup::
91-
92128
- name: 'Provision test cluster'
93129
timeout-minutes: 15
94130
run: |
@@ -105,8 +141,8 @@ jobs:
105141
bundle exec bolt plan run peadm_spec::provision_test_cluster \
106142
--modulepath spec/fixtures/modules \
107143
provider=provision_service \
108-
image=${{ matrix.image }} \
109-
architecture=${{ matrix.architecture }}
144+
image=${{ inputs.image }} \
145+
architecture=${{ inputs.architecture }}
110146
echo ::endgroup::
111147
112148
echo ::group::info:request
@@ -117,44 +153,70 @@ jobs:
117153
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
118154
echo ::endgroup::
119155
120-
- name: "Honeycomb: Record provision time"
121-
if: ${{ always() }}
122-
run: |
123-
echo ::group::honeycomb
124-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Provision test cluster'
125-
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-install >> $GITHUB_ENV
126-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
127-
echo ::endgroup::
128-
156+
- name: Save inventory file B to an artifact
157+
uses: actions/upload-artifact@v2
158+
with:
159+
name: inventory_A
160+
path: spec/fixtures/litmus_inventory.yaml
161+
129162
- name: 'Install PE on test cluster'
130163
timeout-minutes: 120
131164
run: |
132165
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::install_test_cluster' -- \
133166
bundle exec bolt plan run peadm_spec::install_test_cluster \
134167
--inventoryfile spec/fixtures/litmus_inventory.yaml \
135168
--modulepath spec/fixtures/modules \
136-
architecture=${{ matrix.architecture }} \
137-
version=${{ matrix.version }}
169+
architecture=${{ inputs.architecture }} \
170+
version=${{ inputs.version }}
171+
172+
test-backup-restore:
173+
runs-on: ubuntu-20.04
174+
env:
175+
BOLT_GEM: true
176+
BOLT_DISABLE_ANALYTICS: true
177+
BUILDEVENT_FILE: '../buildevents.txt'
178+
LANG: 'en_US.UTF-8'
179+
needs: [install-cluster-A, install-cluster-B]
138180

139-
- name: "Honeycomb: Record install time"
140-
if: ${{ always() }}
181+
steps:
182+
- name: 'Start SSH session'
183+
if: ${{ github.event.inputs.ssh-debugging == 'true' }}
184+
uses: luchihoratiu/debug-via-ssh@main
185+
with:
186+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
187+
SSH_PASS: ${{ secrets.SSH_PASS }}
188+
189+
- name: "Checkout Source"
190+
uses: actions/checkout@v2
191+
192+
- name: "Activate Ruby 2.7"
193+
uses: ruby/setup-ruby@v1
194+
with:
195+
ruby-version: "2.7"
196+
bundler-cache: true
197+
198+
- name: Download artifacts
199+
uses: actions/download-artifact@v3
200+
with:
201+
path: spec/fixtures/
202+
203+
- name: perform PE backup of cluster A
204+
timeout-minutes: 120
141205
run: |
142-
echo ::group::honeycomb
143-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Install PE on test cluster'
144-
echo STEP_ID=${{ matrix.architecture }}-${{ matrix.image }}-tear_down >> $GITHUB_ENV
145-
echo STEP_START=$(date +%s) >> $GITHUB_ENV
146-
echo ::endgroup::
206+
buildevents cmd $TRACE_ID $STEP_ID 'bolt plan run peadm_spec::test_backup' -- \
207+
bundle exec bolt plan run peadm_spec::test_backup \
208+
--inventoryfile spec/fixtures/inventory_A/litmus_inventory.yaml \
209+
--modulepath spec/fixtures/modules
147210
148-
- name: 'Wait as long as the file ${HOME}/pause file is present'
149-
if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }}
211+
- name: Wait while the pause file is present
212+
if: ${{ github.event.inputs.ssh-debugging == 'true' }}
150213
run: |
151-
while [ -f "${HOME}/pause" ] ; do
152-
echo "${HOME}/pause present, sleeping for 60 seconds..."
153-
sleep 60
154-
done
155-
echo "${HOME}/pause absent, continuing workflow."
214+
while [ -f pause ]; do
215+
echo "Waiting for pause file to be removed"
216+
sleep 10
217+
done
156218
157-
- name: 'Tear down test cluster'
219+
- name: 'Tear down cluster A'
158220
if: ${{ always() }}
159221
continue-on-error: true
160222
run: |
@@ -168,9 +230,17 @@ jobs:
168230
echo ::endgroup::
169231
fi
170232
171-
- name: "Honeycomb: Record tear down time"
233+
- name: 'Tear down cluster B'
172234
if: ${{ always() }}
235+
continue-on-error: true
173236
run: |
174-
echo ::group::honeycomb
175-
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Tear down test cluster'
176-
echo ::endgroup::
237+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
238+
echo ::group::tear_down
239+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
240+
echo ::endgroup::
241+
242+
echo ::group::info:request
243+
cat request.json || true; echo
244+
echo ::endgroup::
245+
fi
246+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
plan peadm_spec::test_backup() {
2+
$t = get_targets('*')
3+
wait_until_available($t)
4+
5+
parallelize($t) |$target| {
6+
$fqdn = run_command('hostname -f', $target)
7+
$target.set_var('certname', $fqdn.first['stdout'].chomp)
8+
}
9+
10+
# run infra status on the primary
11+
$primary_host = $t.filter |$n| { $n.vars['role'] == 'primary' }[0]
12+
out::verbose("Running peadm::status on primary host ${primary_host}")
13+
run_plan('peadm::status', $primary_host)
14+
15+
$backup_options = {
16+
'orchestrator' => true,
17+
'puppetdb' => true,
18+
'rbac' => true,
19+
'activity' => true,
20+
'ca' => true,
21+
'classifier' => true,
22+
}
23+
run_plan('peadm::backup', $primary_host, { 'output_directory' => '/tmp', 'backup' => $backup_options })
24+
}

0 commit comments

Comments
 (0)