Skip to content

Commit 51f7e7a

Browse files
authored
Merge pull request #506 from sheenaajay/k8local
(maint) add parameters to accept different provisioning type
2 parents f75c488 + 7aa415a commit 51f7e7a

File tree

6 files changed

+79
-42
lines changed

6 files changed

+79
-42
lines changed

.github/workflows/integration_test.yml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
run: |
2626
echo STEP_ID=setup-environment >> $GITHUB_ENV
2727
echo STEP_START=$(date +%s) >> $GITHUB_ENV
28+
2829
- name: Checkout Source
2930
uses: actions/checkout@v2
3031
if: ${{ github.repository_owner == 'puppetlabs' }}
@@ -42,12 +43,14 @@ jobs:
4243
echo ::group::bundler environment
4344
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
4445
echo ::endgroup::
46+
4547
- name: "Honeycomb: Record Setup Environment time"
4648
if: ${{ github.repository_owner == 'puppetlabs' }}
4749
run: |
4850
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
4951
echo STEP_ID=Setup-Integration-Test-Matrix >> $GITHUB_ENV
5052
echo STEP_START=$(date +%s) >> $GITHUB_ENV
53+
5154
- name: Setup Integration Test Matrix
5255
id: get-matrix
5356
run: |
@@ -56,10 +59,12 @@ jobs:
5659
else
5760
echo "::set-output name=matrix::{}"
5861
fi
62+
5963
- name: "Honeycomb: Record Setup Test Matrix time"
6064
if: ${{ always() }}
6165
run: |
6266
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
67+
6368
Integration:
6469
needs:
6570
- setup_matrix
@@ -116,35 +121,33 @@ jobs:
116121
echo STEP_START=$(date +%s) >> $GITHUB_ENV
117122
- name: Provision test environment
118123
run: |
119-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::provision_cluster gcp_image=${{ matrix.platform }}
124+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::provision_cluster image_type=${{ matrix.platform }}
120125
echo ::group::=== REQUEST ===
121126
cat request.json || true
122127
echo
123128
echo ::endgroup::
124129
echo ::group::=== INVENTORY ===
125-
sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true
130+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; then
131+
FILE='spec/fixtures/litmus_inventory.yaml'
132+
elif [ -f 'inventory.yaml' ]; then
133+
FILE='inventory.yaml'
134+
fi
135+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
126136
echo ::endgroup::
127-
- name: Disable gpg check google-cloud.repo
128-
uses: nick-invision/retry@v1
129-
with:
130-
timeout_minutes: 30
131-
max_attempts: 5
132-
retry_wait_seconds: 60
133-
command: buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes::disable_gpg' -- bundle exec bolt --modulepath spec/fixtures/modules command run "sed -i 's/gpgcheck=1/gpgcheck=0/g' /etc/yum.repos.d/google-cloud.repo" --targets '*' -i ./inventory.yaml
137+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
138+
134139
- name: Puppet server setup
135140
run: |
136-
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes::puppetserver_setup' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::puppetserver_setup -i ./inventory.yaml
141+
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes::puppetserver_setup' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::puppetserver_setup collection='${{ matrix.collection }}' -i ./$INVENTORY_PATH
142+
137143
- name: Install agent
138-
uses: nick-invision/retry@v1
139-
with:
140-
timeout_minutes: 30
141-
max_attempts: 5
142-
retry_wait_seconds: 60
143-
command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
144+
run: |
145+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
144146
145147
- name: Install module
146148
run: |
147149
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
150+
148151
- name: "Honeycomb: Record deployment times"
149152
if: ${{ always() }}
150153
run: |
@@ -157,23 +160,26 @@ jobs:
157160
- name: Run integration tests
158161
run: |
159162
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes:integration' -- bundle exec rake kubernetes:integration
163+
160164
- name: "Honeycomb: Record integration testing times"
161165
if: ${{ always() }}
162166
run: |
163167
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run integration tests'
164168
echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
165169
echo STEP_START=$(date +%s) >> $GITHUB_ENV
170+
166171
- name: Remove test environment
167172
if: ${{ always() }}
168173
continue-on-error: true
169174
run: |
170-
if [ -f inventory.yaml ]; then
175+
if [ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]; then
171176
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
172177
echo ::group::=== REQUEST ===
173178
cat request.json || true
174179
echo
175180
echo ::endgroup::
176181
fi
182+
177183
- name: "Honeycomb: Record removal times"
178184
if: ${{ always() }}
179185
run: |

.github/workflows/nightly.yml

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
run: |
2828
echo STEP_ID=setup-environment >> $GITHUB_ENV
2929
echo STEP_START=$(date +%s) >> $GITHUB_ENV
30+
3031
- name: Checkout Source
3132
uses: actions/checkout@v2
3233
if: ${{ github.repository_owner == 'puppetlabs' }}
@@ -44,12 +45,14 @@ jobs:
4445
echo ::group::bundler environment
4546
buildevents cmd $TRACE_ID $STEP_ID 'bundle env' -- bundle env
4647
echo ::endgroup::
48+
4749
- name: "Honeycomb: Record Setup Environment time"
4850
if: ${{ github.repository_owner == 'puppetlabs' }}
4951
run: |
5052
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Environment'
5153
echo STEP_ID=Setup-Integration-Test-Matrix >> $GITHUB_ENV
5254
echo STEP_START=$(date +%s) >> $GITHUB_ENV
55+
5356
- name: Setup Integration Test Matrix
5457
id: get-matrix
5558
run: |
@@ -58,10 +61,12 @@ jobs:
5861
else
5962
echo "::set-output name=matrix::{}"
6063
fi
64+
6165
- name: "Honeycomb: Record Setup Test Matrix time"
6266
if: ${{ always() }}
6367
run: |
6468
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Setup Test Matrix'
69+
6570
Integration:
6671
needs:
6772
- setup_matrix
@@ -118,28 +123,33 @@ jobs:
118123
echo STEP_START=$(date +%s) >> $GITHUB_ENV
119124
- name: Provision test environment
120125
run: |
121-
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::provision_cluster gcp_image=${{ matrix.platform }}
126+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:provision' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::provision_cluster image_type=${{ matrix.platform }}
122127
echo ::group::=== REQUEST ===
123128
cat request.json || true
124129
echo
125130
echo ::endgroup::
126131
echo ::group::=== INVENTORY ===
127-
sed -e 's/password: .*/password: "[redacted]"/' < inventory.yaml || true
132+
if [ -f 'spec/fixtures/litmus_inventory.yaml' ]; then
133+
FILE='spec/fixtures/litmus_inventory.yaml'
134+
elif [ -f 'inventory.yaml' ]; then
135+
FILE='inventory.yaml'
136+
fi
137+
sed -e 's/password: .*/password: "[redacted]"/' < $FILE || true
128138
echo ::endgroup::
129-
- name: Install module
139+
echo INVENTORY_PATH=$FILE >> $GITHUB_ENV
140+
141+
- name: Puppet server setup
130142
run: |
131-
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes::puppetserver_setup' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::puppetserver_setup -i ./inventory.yaml
143+
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes::puppetserver_setup' -- bundle exec bolt --modulepath spec/fixtures/modules plan run kubernetes::puppetserver_setup collection='${{ matrix.collection }}' -i ./$INVENTORY_PATH
144+
132145
- name: Install agent
133-
uses: nick-invision/retry@v1
134-
with:
135-
timeout_minutes: 30
136-
max_attempts: 5
137-
retry_wait_seconds: 60
138-
command: buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
146+
run: |
147+
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_agent ${{ matrix.collection }}' -- bundle exec rake 'litmus:install_agent[${{ matrix.collection }}]'
139148
140149
- name: Install module
141150
run: |
142151
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:install_module' -- bundle exec rake 'litmus:install_module'
152+
143153
- name: "Honeycomb: Record deployment times"
144154
if: ${{ always() }}
145155
run: |
@@ -152,23 +162,26 @@ jobs:
152162
- name: Run integration tests
153163
run: |
154164
buildevents cmd $TRACE_ID $STEP_ID 'rake kubernetes:integration' -- bundle exec rake kubernetes:integration
165+
155166
- name: "Honeycomb: Record integration testing times"
156167
if: ${{ always() }}
157168
run: |
158169
buildevents step $TRACE_ID $STEP_ID $STEP_START 'Run integration tests'
159170
echo STEP_ID=${{ matrix.platform }}-${{ matrix.collection }}-4 >> $GITHUB_ENV
160171
echo STEP_START=$(date +%s) >> $GITHUB_ENV
172+
161173
- name: Remove test environment
162174
if: ${{ always() }}
163175
continue-on-error: true
164176
run: |
165-
if [ -f inventory.yaml ]; then
177+
if [ -f inventory.yaml || -f spec/fixtures/litmus_inventory.yaml ]; then
166178
buildevents cmd $TRACE_ID $STEP_ID 'rake litmus:tear_down' -- bundle exec rake 'litmus:tear_down'
167179
echo ::group::=== REQUEST ===
168180
cat request.json || true
169181
echo
170182
echo ::endgroup::
171183
fi
184+
172185
- name: "Honeycomb: Record removal times"
173186
if: ${{ always() }}
174187
run: |

.github/workflows/pr_test.yml

Whitespace-only changes.

plans/provision_cluster.pp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
# Provisions machines for integration testing
44
#
55
# @example
6-
# kubernetes::provision_integration
6+
# kubernetes::provision_cluster
77
plan kubernetes::provision_cluster(
8-
Optional[String] $gcp_image = 'centos-7',
8+
Optional[String] $image_type = 'centos-7',
9+
Optional[String] $provision_type = 'provision_service',
910
) {
1011
#provision server machine, set role
11-
run_task('provision::provision_service', 'localhost',
12-
action => 'provision', platform => $gcp_image, vars => 'role: controller')
13-
run_task('provision::provision_service', 'localhost',
14-
action => 'provision', platform => $gcp_image, vars => 'role: worker1')
15-
run_task('provision::provision_service', 'localhost',
16-
action => 'provision', platform => $gcp_image, vars => 'role: worker2')
12+
run_task("provision::$provision_type", 'localhost',
13+
action => 'provision', platform => $image_type, vars => 'role: controller')
14+
run_task("provision::$provision_type", 'localhost',
15+
action => 'provision', platform => $image_type, vars => 'role: worker1')
16+
run_task("provision::$provision_type", 'localhost',
17+
action => 'provision', platform => $image_type, vars => 'role: worker2')
1718
}

plans/puppetserver_setup.pp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,25 @@
1+
# @summary Provisions machines
2+
#
3+
# Puppet Server Setup
4+
#
5+
# @example
6+
# kubernetes::puppetserver_setup
17
plan kubernetes::puppetserver_setup(
8+
Optional[String] $collection = 'puppet7-nightly'
29
) {
310
$puppet_server = get_targets('*').filter |$n| { $n.vars['role'] == 'controller' }
4-
$puppet_server_string = $puppet_server[0].name
5-
# install pe server
6-
run_task('provision::install_puppetserver', $puppet_server)
11+
12+
# get facts
13+
$puppet_server_facts = facts($puppet_server[0])
14+
$platform = $puppet_server_facts['platform']
15+
16+
# install puppet server
17+
run_task(
18+
'provision::install_puppetserver',
19+
$puppet_server,
20+
'install and configure server',
21+
{ 'collection' => $collection, 'platform' => $platform }
22+
)
723
}
824

925

spec/acceptance/integration_kubernetes_spec.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@
4545
after(:all) { reset_target_host }
4646
describe 'verify the k8 nodes' do
4747
it 'verify the k8 nodes' do
48+
run_shell('sleep 20')
4849
run_shell('KUBECONFIG=/etc/kubernetes/admin.conf kubectl get nodes') do |r|
49-
expect(r.stdout).to match(/#{hostname1} Ready master/)
50-
expect(r.stdout).to match(/#{hostname2} Ready/)
51-
expect(r.stdout).to match(/#{hostname3} Ready/)
50+
expect(r.stdout).to match(/#{hostname1}(\s)+Ready(\s)+master/)
51+
expect(r.stdout).to match(/#{hostname2}(\s)+Ready/)
52+
expect(r.stdout).to match(/#{hostname3}(\s)+Ready/)
5253
end
5354
end
5455
end

0 commit comments

Comments
 (0)