Skip to content

Commit 13bc998

Browse files
authored
PE acceptance workflows and Idempotency Test (#63)
* PE acceptance workflows and Idempotency Test
1 parent 6c7d0ad commit 13bc998

File tree

6 files changed

+370
-1
lines changed

6 files changed

+370
-1
lines changed

.fixtures.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
fixtures:
33
repositories:
44
cron_core: "git://github.com/puppetlabs/puppetlabs-cron_core"
5-
provision: https://github.com/puppetlabs/provision.git
5+
provision: 'https://github.com/puppetlabs/provision.git'
6+
bootstrap: "https://github.com/puppetlabs/puppetlabs-bootstrap"
7+
puppet_conf: "https://github.com/puppetlabs/puppetlabs-puppet_conf"
8+
deploy_pe: 'git://github.com/jarretlavallee/puppet-deploy_pe.git'
9+
ruby_task_helper: "https://git@github.com/puppetlabs/puppetlabs-ruby_task_helper"
10+
stdlib: "https://github.com/puppetlabs/puppetlabs-stdlib.git"
11+
facts: 'https://github.com/puppetlabs/puppetlabs-facts.git'
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: "PE Latest Acceptance Testing"
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
env:
8+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
9+
HONEYCOMB_DATASET: litmus tests
10+
11+
jobs:
12+
setup_matrix:
13+
name: "Setup Test Matrix"
14+
runs-on: ubuntu-20.04
15+
outputs:
16+
matrix: ${{ steps.get-matrix.outputs.matrix }}
17+
18+
steps:
19+
- name: "Honeycomb: Start recording"
20+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
21+
with:
22+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
23+
dataset: ${{ env.HONEYCOMB_DATASET }}
24+
job-status: ${{ job.status }}
25+
26+
- name: "Honeycomb: Start first step"
27+
run: |
28+
echo STEP_ID=setup-environment >> $GITHUB_ENV
29+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30+
- name: Checkout Source
31+
uses: actions/checkout@v2
32+
if: ${{ github.repository_owner == 'puppetlabs' }}
33+
34+
- name: Activate Ruby 2.7
35+
uses: ruby/setup-ruby@v1
36+
if: ${{ github.repository_owner == 'puppetlabs' }}
37+
with:
38+
ruby-version: "2.7"
39+
bundler-cache: true
40+
41+
- name: Print bundle environment
42+
if: ${{ github.repository_owner == 'puppetlabs' }}
43+
run: |
44+
echo ::group::bundler environment
45+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
46+
echo ::endgroup::
47+
- name: "Honeycomb: Record Setup Environment time"
48+
if: ${{ github.repository_owner == 'puppetlabs' }}
49+
run: |
50+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
51+
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
52+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
53+
- name: Setup Acceptance Test Matrix
54+
id: get-matrix
55+
run: |
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2021.1.0\"]}"
57+
- name: "Honeycomb: Record Setup Test Matrix time"
58+
if: ${{ always() }}
59+
run: |
60+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
61+
Acceptance:
62+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
63+
needs:
64+
- setup_matrix
65+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
66+
67+
runs-on: ubuntu-20.04
68+
strategy:
69+
fail-fast: false
70+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
71+
72+
env:
73+
BUILDEVENT_FILE: '../buildevents.txt'
74+
75+
steps:
76+
- run: |
77+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
78+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
79+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
80+
- name: "Honeycomb: Start recording"
81+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
82+
with:
83+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
84+
dataset: ${{ env.HONEYCOMB_DATASET }}
85+
job-status: ${{ job.status }}
86+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
87+
88+
- name: "Honeycomb: start first step"
89+
run: |
90+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
91+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
92+
- name: Checkout Source
93+
uses: actions/checkout@v2
94+
95+
- name: Activate Ruby 2.7
96+
uses: ruby/setup-ruby@v1
97+
with:
98+
ruby-version: "2.7"
99+
bundler-cache: true
100+
101+
- name: Print bundle environment
102+
run: |
103+
echo ::group::bundler environment
104+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
105+
echo ::endgroup::
106+
- name: "Honeycomb: Record Setup Environment time"
107+
if: ${{ always() }}
108+
run: |
109+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
110+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
111+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
112+
- name: Provision test environment
113+
run: |
114+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
115+
echo ::group::=== REQUEST ===
116+
cat request.json || true
117+
echo
118+
echo ::endgroup::
119+
echo ::group::=== INVENTORY ===
120+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
121+
then
122+
FILE='spec/fixtures/litmus_inventory.yaml'
123+
elif [ -f 'inventory.yaml' ];
124+
then
125+
FILE='inventory.yaml'
126+
fi
127+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
128+
echo ::endgroup::
129+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
130+
- name: Install PE
131+
run: |
132+
buildevents cmd $TRACE_ID $STEP_ID 'rake deploy_pe::provision_master' -- bundle exec bolt --tmpdir /tmp --log-level debug --modulepath spec/fixtures/modules -i ./$INVENTORY_PATH plan run deploy_pe::provision_master --params '{"version":"${{ matrix.collection }}","pe_settings":{"password":"puppetlabs", "configure_tuning": false}}' --targets all
133+
134+
- name: Install module
135+
run: |
136+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
137+
- name: "Honeycomb: Record deployment times"
138+
if: ${{ always() }}
139+
run: |
140+
echo ::group::honeycomb step
141+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
142+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
143+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
144+
echo ::endgroup::
145+
- name: Run acceptance tests
146+
run: |
147+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
148+
- name: "Honeycomb: Record acceptance testing times"
149+
if: ${{ always() }}
150+
run: |
151+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
152+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
153+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
154+
- name: Remove test environment
155+
if: ${{ always() }}
156+
continue-on-error: true
157+
run: |
158+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
159+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
160+
echo ::group::=== REQUEST ===
161+
cat request.json || true
162+
echo
163+
echo ::endgroup::
164+
fi
165+
- name: "Honeycomb: Record removal times"
166+
if: ${{ always() }}
167+
run: |
168+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

.github/workflows/pe_lts_testing.yml

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: "PE LTS Acceptance Testing"
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
7+
env:
8+
HONEYCOMB_WRITEKEY: 7f3c63a70eecc61d635917de46bea4e6
9+
HONEYCOMB_DATASET: litmus tests
10+
11+
jobs:
12+
setup_matrix:
13+
name: "Setup Test Matrix"
14+
runs-on: ubuntu-20.04
15+
outputs:
16+
matrix: ${{ steps.get-matrix.outputs.matrix }}
17+
18+
steps:
19+
- name: "Honeycomb: Start recording"
20+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
21+
with:
22+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
23+
dataset: ${{ env.HONEYCOMB_DATASET }}
24+
job-status: ${{ job.status }}
25+
26+
- name: "Honeycomb: Start first step"
27+
run: |
28+
echo STEP_ID=setup-environment >> $GITHUB_ENV
29+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30+
- name: Checkout Source
31+
uses: actions/checkout@v2
32+
if: ${{ github.repository_owner == 'puppetlabs' }}
33+
34+
- name: Activate Ruby 2.7
35+
uses: ruby/setup-ruby@v1
36+
if: ${{ github.repository_owner == 'puppetlabs' }}
37+
with:
38+
ruby-version: "2.7"
39+
bundler-cache: true
40+
41+
- name: Print bundle environment
42+
if: ${{ github.repository_owner == 'puppetlabs' }}
43+
run: |
44+
echo ::group::bundler environment
45+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
46+
echo ::endgroup::
47+
- name: "Honeycomb: Record Setup Environment time"
48+
if: ${{ github.repository_owner == 'puppetlabs' }}
49+
run: |
50+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
51+
echo STEP_ID=Setup-Acceptance-Test-Matrix >> $GITHUB_ENV
52+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
53+
- name: Setup Acceptance Test Matrix
54+
id: get-matrix
55+
run: |
56+
echo "::set-output name=matrix::{\"platforms\":[{\"label\":\"CentOS-7\",\"provider\":\"provision::provision_service\",\"image\":\"centos-7\"},{\"label\":\"CentOS-8\",\"provider\":\"provision::provision_service\",\"image\":\"centos-8\"},{\"label\":\"RedHat-7\",\"provider\":\"provision::provision_service\",\"image\":\"rhel-7\"},{\"label\":\"Ubuntu-1804\",\"provider\":\"provision::provision_service\",\"image\":\"ubuntu-1804-lts\"}],\"collection\":[\"2019.8.6\"]}"
57+
- name: "Honeycomb: Record Setup Test Matrix time"
58+
if: ${{ always() }}
59+
run: |
60+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
61+
Acceptance:
62+
name: "${{matrix.platforms.label}}, ${{matrix.collection}}"
63+
needs:
64+
- setup_matrix
65+
if: ${{ needs.setup_matrix.outputs.matrix != '{}' }}
66+
67+
runs-on: ubuntu-20.04
68+
strategy:
69+
fail-fast: false
70+
matrix: ${{fromJson(needs.setup_matrix.outputs.matrix)}}
71+
72+
env:
73+
BUILDEVENT_FILE: '../buildevents.txt'
74+
75+
steps:
76+
- run: |
77+
echo 'platform=${{ matrix.platforms.image }}' >> $BUILDEVENT_FILE
78+
echo 'collection=${{ matrix.collection }}' >> $BUILDEVENT_FILE
79+
echo 'label=${{ matrix.platforms.label }}' >> $BUILDEVENT_FILE
80+
- name: "Honeycomb: Start recording"
81+
uses: puppetlabs/kvrhdn-gha-buildevents@pdk-templates-v1
82+
with:
83+
apikey: ${{ env.HONEYCOMB_WRITEKEY }}
84+
dataset: ${{ env.HONEYCOMB_DATASET }}
85+
job-status: ${{ job.status }}
86+
matrix-key: ${{ matrix.platforms.label }}-${{ matrix.collection }}
87+
88+
- name: "Honeycomb: start first step"
89+
run: |
90+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-1 >> $GITHUB_ENV
91+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
92+
- name: Checkout Source
93+
uses: actions/checkout@v2
94+
95+
- name: Activate Ruby 2.7
96+
uses: ruby/setup-ruby@v1
97+
with:
98+
ruby-version: "2.7"
99+
bundler-cache: true
100+
101+
- name: Print bundle environment
102+
run: |
103+
echo ::group::bundler environment
104+
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
105+
echo ::endgroup::
106+
- name: "Honeycomb: Record Setup Environment time"
107+
if: ${{ always() }}
108+
run: |
109+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
110+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-2 >> $GITHUB_ENV
111+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
112+
- name: Provision test environment
113+
run: |
114+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision ${{ matrix.platforms.image }}' -- bundle exec rake 'litmus:provision[${{matrix.platforms.provider}},${{ matrix.platforms.image }}]'
115+
echo ::group::=== REQUEST ===
116+
cat request.json || true
117+
echo
118+
echo ::endgroup::
119+
echo ::group::=== INVENTORY ===
120+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ];
121+
then
122+
FILE='spec/fixtures/litmus_inventory.yaml'
123+
elif [ -f 'inventory.yaml' ];
124+
then
125+
FILE='inventory.yaml'
126+
fi
127+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
128+
echo ::endgroup::
129+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
130+
- name: Install PE
131+
run: |
132+
buildevents cmd $TRACE_ID $STEP_ID 'rake deploy_pe::provision_master' -- bundle exec bolt --tmpdir /tmp --log-level debug --modulepath spec/fixtures/modules -i ./$INVENTORY_PATH plan run deploy_pe::provision_master --params '{"version":"${{ matrix.collection }}","pe_settings":{"password":"puppetlabs", "configure_tuning": false}}' --targets all
133+
134+
- name: Install module
135+
run: |
136+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
137+
- name: "Honeycomb: Record deployment times"
138+
if: ${{ always() }}
139+
run: |
140+
echo ::group::honeycomb step
141+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Deploy test system'
142+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-3 >> $GITHUB_ENV
143+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
144+
echo ::endgroup::
145+
- name: Run acceptance tests
146+
run: |
147+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:acceptance:parallel' -- bundle exec rake 'litmus:acceptance:parallel'
148+
- name: "Honeycomb: Record acceptance testing times"
149+
if: ${{ always() }}
150+
run: |
151+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run acceptance tests'
152+
echo STEP_ID=${{ matrix.platforms.image }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
153+
echo STEP_START=$(date +%s) >> $GITHUB_ENV
154+
- name: Remove test environment
155+
if: ${{ always() }}
156+
continue-on-error: true
157+
run: |
158+
if [[ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]]; then
159+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
160+
echo ::group::=== REQUEST ===
161+
cat request.json || true
162+
echo
163+
echo ::endgroup::
164+
fi
165+
- name: "Honeycomb: Record removal times"
166+
if: ${{ always() }}
167+
run: |
168+
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Remove test environment'

spec/acceptance/init_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'pe_databases class' do
4+
context 'activates module default parameters' do
5+
it 'applies the class with default parameters' do
6+
pp = <<-MANIFEST
7+
include pe_databases
8+
MANIFEST
9+
10+
# Run it twice and test for idempotency
11+
expect(apply_manifest(pp).exit_code).not_to eq(1)
12+
expect(apply_manifest(pp).exit_code).not_to eq(1)
13+
idempotent_apply(pp)
14+
end
15+
end
16+
end

spec/spec_helper_acceptance.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# frozen_string_literal: true
2+
3+
require 'puppet_litmus'
4+
PuppetLitmus.configure!
5+
6+
require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))

spec/spec_helper_acceptance_local.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
require 'singleton'
4+
require 'serverspec'
5+
require 'puppetlabs_spec_helper/module_spec_helper'

0 commit comments

Comments
 (0)