Skip to content

Commit cbdf423

Browse files
committed
(PE-37233) Adding add_compiler to test matrix
Updated add_compiler spec to check compiler has been added and puppet run before running add compiler Added test matrix for add compiler
1 parent fa0dc4c commit cbdf423

File tree

4 files changed

+167
-10
lines changed

4 files changed

+167
-10
lines changed

Diff for: .github/workflows/test-add-compiler-matrix.yml

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
name: "Add compiler matrix"
3+
4+
on:
5+
pull_request:
6+
paths:
7+
- ".github/workflows/**/*"
8+
- "spec/**/*"
9+
- "lib/**/*"
10+
- "tasks/**/*"
11+
- "functions/**/*"
12+
- "types/**/*"
13+
- "plans/**/*"
14+
- "hiera/**/*"
15+
- "manifests/**/*"
16+
- "templates/**/*"
17+
- "files/**/*"
18+
- "metadata.json"
19+
- "Rakefile"
20+
- "Gemfile"
21+
- "provision.yaml"
22+
- ".rspec"
23+
- ".rubocop.yml"
24+
- ".puppet-lint.rc"
25+
- ".fixtures.yml"
26+
branches: [main]
27+
workflow_dispatch: {}
28+
29+
jobs:
30+
test-add-compiler:
31+
name: "PE ${{ matrix.version }} ${{ matrix.architecture }} on ${{ matrix.image }}"
32+
runs-on: ubuntu-20.04
33+
env:
34+
BOLT_GEM: true
35+
BOLT_DISABLE_ANALYTICS: true
36+
LANG: "en_US.UTF-8"
37+
strategy:
38+
fail-fast: false
39+
matrix:
40+
architecture:
41+
- standard
42+
- large
43+
- extra-large
44+
version:
45+
- 2021.7.7
46+
- 2023.6.0
47+
image:
48+
- centos-7
49+
- almalinux-cloud/almalinux-8
50+
steps:
51+
- name: "Checkout Source"
52+
uses: actions/checkout@v2
53+
54+
- name: "Activate Ruby 2.7"
55+
uses: ruby/setup-ruby@v1
56+
with:
57+
ruby-version: "2.7"
58+
bundler-cache: true
59+
60+
- name: "Print bundle environment"
61+
if: ${{ github.repository_owner == 'puppetlabs' }}
62+
run: |
63+
echo ::group::info:bundler
64+
bundle env
65+
echo ::endgroup::
66+
67+
- name: "Provision test cluster"
68+
timeout-minutes: 15
69+
run: |
70+
echo ::group::prepare
71+
mkdir -p $HOME/.ssh
72+
echo 'Host *' > $HOME/.ssh/config
73+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
74+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
75+
bundle exec rake spec_prep
76+
echo ::endgroup::
77+
78+
echo ::group::provision
79+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
80+
--modulepath spec/fixtures/modules \
81+
provider=provision_service \
82+
image=${{ matrix.image }} \
83+
architecture=${{ matrix.architecture }}-with-extra-compiler
84+
echo ::endgroup::
85+
86+
echo ::group::info:request
87+
cat request.json || true; echo
88+
echo ::endgroup::
89+
90+
echo ::group::info:inventory
91+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
92+
echo ::endgroup::
93+
94+
- name: "Install PE on test cluster"
95+
timeout-minutes: 120
96+
run: |
97+
bundle exec bolt plan run peadm_spec::install_test_cluster \
98+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
99+
--modulepath spec/fixtures/modules \
100+
architecture=${{ matrix.architecture }} \
101+
version=${{ matrix.version }}
102+
103+
- name: 'Run add_compiler plan'
104+
timeout-minutes: 50
105+
run: |
106+
bundle exec bolt plan run peadm_spec::add_compiler -v \
107+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
108+
--modulepath spec/fixtures/modules \
109+
architecture=${{ matrix.architecture }}
110+
111+
- name: 'Tear down test cluster'
112+
if: ${{ always() }}
113+
continue-on-error: true
114+
run: |
115+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
116+
echo ::group::tear_down
117+
bundle exec rake 'litmus:tear_down'
118+
echo ::endgroup::
119+
120+
echo ::group::info:request
121+
cat request.json || true; echo
122+
echo ::endgroup::
123+
fi

Diff for: .github/workflows/test-add-compiler.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
bundle env
6464
echo ::endgroup::
6565
66-
- name: 'Provision test cluster (specified architecture with added DR)'
66+
- name: 'Provision test cluster (specified architecture with added compiler)'
6767
timeout-minutes: 15
6868
run: |
6969
echo ::group::prepare
@@ -100,12 +100,13 @@ jobs:
100100
version=${{ matrix.version }}
101101
102102
- name: 'Run add_compiler plan'
103-
timeout-minutes: 30
103+
timeout-minutes: 50
104104
run: |
105105
bundle exec bolt plan run peadm_spec::add_compiler -v \
106106
--inventoryfile spec/fixtures/litmus_inventory.yaml \
107107
--modulepath spec/fixtures/modules \
108-
architecture=${{ matrix.architecture }}
108+
architecture=${{ matrix.architecture }} \
109+
--stream
109110
110111
- name: 'Wait as long as the file ${HOME}/pause file is present'
111112
if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }}

Diff for: spec/acceptance/peadm_spec/plans/add_compiler.pp

+37-7
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,57 @@
1010
$target.set_var('certname', $fqdn.first['stdout'].chomp)
1111
}
1212

13+
$primary_host = $t.filter |$n| { $n.vars['role'] == 'primary' }
14+
$compiler_host = $t.filter |$n| { $n.vars['role'] == 'unconfigured-compiler' }
15+
$compiler_fqdn = run_command('hostname -f', $compiler_host).first['stdout'].chomp
16+
17+
run_task('peadm::puppet_runonce', $primary_host)
18+
1319
$common_params = {
1420
avail_group_letter => 'A',
1521
}
1622

1723
$arch_params =
1824
case $architecture {
25+
'standard': {{
26+
primary_host => $primary_host,
27+
primary_postgresql_host => $primary_host,
28+
compiler_host => $compiler_host,
29+
}}
1930
'large': {{
20-
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
21-
primary_postgresql_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
22-
compiler_host => $t.filter |$n| { $n.vars['role'] == 'unconfigured-compiler' },
31+
primary_host => $primary_host,
32+
primary_postgresql_host => $primary_host,
33+
compiler_host => $compiler_host,
2334
}}
2435
'extra-large': {{
25-
primary_host => $t.filter |$n| { $n.vars['role'] == 'primary' },
36+
primary_host => $primary_host,
2637
primary_postgresql_host => $t.filter |$n| { $n.vars['role'] == 'primary-pdb-postgresql' },
27-
compiler_host => $t.filter |$n| { $n.vars['role'] == 'unconfigured-compiler' },
38+
compiler_host => $compiler_host,
2839
}}
2940
default: { fail('Invalid architecture!') }
3041
}
3142

32-
$result =
33-
run_plan('peadm::add_compiler', $arch_params + $common_params)
43+
$compiler_count_query = 'inventory[count()] { trusted.extensions.pp_auth_role = "pe_compiler"}'
44+
$query_result = run_command("/opt/puppetlabs/bin/puppet query \'${compiler_count_query}\'", $primary_host).first['stdout']
45+
$first_count = parsejson($query_result)[0]['count']
46+
47+
$result = run_plan('peadm::add_compiler', $arch_params + $common_params)
48+
49+
$query_result2 = run_command("/opt/puppetlabs/bin/puppet query \'${compiler_count_query}\'", $primary_host).first['stdout']
50+
$second_count = parsejson($query_result2)[0]['count']
51+
52+
$compiler_query = "inventory[certname] { trusted.extensions.pp_auth_role = \"pe_compiler\" and certname = \"${compiler_fqdn}\"}"
53+
54+
$compiler_json = run_command("/opt/puppetlabs/bin/puppet query \'${compiler_query}\'", $primary_host).first['stdout']
55+
$compiler = parsejson($compiler_json)
56+
57+
if $first_count + 1 != $second_count {
58+
fail('Compiler count did not increase')
59+
}
60+
61+
if $compiler == [] {
62+
fail('Compiler not found')
63+
}
3464

3565
return($result)
3666
}

Diff for: spec/acceptance/peadm_spec/plans/provision_test_cluster.pp

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
'extra-large-with-dr': {
2424
['primary', 'primary-pdb-postgresql', 'compiler', 'replica', 'replica-pdb-postgresql', 'compiler']
2525
}
26+
'standard-with-extra-compiler': {
27+
['primary', 'unconfigured-compiler']
28+
}
2629
'large-with-extra-compiler': {
2730
['primary', 'compiler', 'unconfigured-compiler']
2831
}

0 commit comments

Comments
 (0)