Skip to content

Commit 13e0c82

Browse files
a-bjoaopapereira
andauthored
Switch test environments to cfd bosh lites [main] (#3262)
* Switch environment to cfd-bosh-lite * Turn off set_kernel_parameters to use cfd-bosh-lite * Expose shepherd configuration via repo variables * Update secrets path to bosh-lite * Expose TEST_FLAKE_ATTEMPTS and TEST_NODES * Set default FLAKE_ATTEMPTS * Bump gha test suit timeout from 60 to 120m * Enter nodes as workflow_dispatch input * Skip steps if SHEPHERD_LEASE_ID defined * Skip scaling tests that are testing CAPI * bosh-light environment default memory is 256Mb * Fixed the issue with force update of bosh * Delete created orgs during tests * Ensure that the orgName is empty for each test * Prevent double deletion of org * Lower number of tests running using client credentials to avoid flakes * Allow user to define namespace of the leased environment * Pass namespace of the lease to the reusable workflow Co-authored-by: João Pereira <[email protected]>
1 parent 6773b07 commit 13e0c82

26 files changed

+245
-76
lines changed

.github/ops-files/diego-cell-instances.yml

+4
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
- type: replace
33
path: /instance_groups/name=diego-cell/instances
44
value: 4
5+
6+
- type: replace
7+
path: /instance_groups/name=isolated-diego-cell/jobs/name=rep/properties?/set_kernel_parameters
8+
value: false

.github/workflows/tests-integration-reusable.yml

+33-23
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# secrets.CLIENT_SECRET
44
# secrets.GITHUB_TOKEN
55
# secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
6-
# vars.SHEPHERD_POOL_NAME
6+
# vars.TEST_FLAKE_ATTEMPTS
77

88
name: "pvt: run integration tests"
99

@@ -22,17 +22,29 @@ on:
2222
lease-id:
2323
required: true
2424
type: string
25+
lease-namespace:
26+
required: false
27+
type: string
28+
default: 'tas-devex'
2529
gitRef:
2630
type: string
2731
default: ${{github.event.workflow_run.head_sha}}
28-
32+
nodes:
33+
type: string
34+
default: "12"
35+
36+
env:
37+
NODES: ${{ inputs.nodes }}
38+
FLAKE_ATTEMPTS: ${{ vars.TEST_FLAKE_ATTEMPTS || '2' }}
39+
2940
jobs:
3041
run-integration-tests:
3142
defaults:
3243
run:
3344
shell: bash
34-
runs-on: ${{ inputs.os }}
45+
runs-on: ${{ inputs.os }}
3546
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
47+
timeout-minutes: 120
3648
steps:
3749
- name: Checkout cli
3850
uses: actions/checkout@v4
@@ -61,7 +73,9 @@ jobs:
6173

6274
- name: Install Tools
6375
env:
64-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
76+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
77+
lease_namespace: ${{ inputs.lease-namespace }}
78+
lease_id: ${{ inputs.lease-id }}
6579
run: |
6680
go version
6781
@@ -95,23 +109,23 @@ jobs:
95109
apt-get install -y build-essential unzip
96110
97111
shepherd login service-account ${account_token}
98-
shepherd get lease ${{ inputs.lease-id }} --namespace tas-devex --json | jq .output > metadata.json
112+
shepherd get lease ${lease_id} --namespace ${lease_namespace} --json | jq .output > metadata.json
99113
100114
- name: Add CATS config
101115
if: ${{ inputs.name == 'cats' }}
102116
run: |
103117
set -eu
104118
105-
ENV=$(jq -r .name metadata.json)
119+
env_name=$(jq -r .name metadata.json)
106120
API="$(jq -r .cf.api_url metadata.json)"
107121
DOMAIN=$(echo $API | sed "s/^api\.//")
108122
CF_INT_USERNAME="admin"
109123
110-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
124+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
111125
eval "$(bbl print-env --metadata-file ./metadata.json)"
112126
113127
credhub login
114-
CF_INT_PASSWORD=$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)
128+
CF_INT_PASSWORD=$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)
115129
116130
cat << EOF | jq -S . > cats_config.json
117131
{
@@ -185,26 +199,24 @@ jobs:
185199
--keep-going \
186200
--randomize-all \
187201
--skip-package=helpers \
188-
--nodes="12" \
189-
--flake-attempts=2 \
202+
--nodes="${NODES}" \
203+
--flake-attempts=${FLAKE_ATTEMPTS} \
190204
--timeout="2h" \
191205
--no-color
192206
193207
- name: Run Integration Tests
194208
if: ${{ !inputs.run-with-client-creds && inputs.name != 'cats' }}
195209
run: |
196-
ENV=$(cat metadata.json | jq -r '.name')
197-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
210+
env_name=$(cat metadata.json | jq -r '.name')
211+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
198212
eval "$(bbl print-env --metadata-file ./metadata.json)"
199-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
213+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
200214
export CF_INT_OIDC_USERNAME="admin-oidc"
201-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
215+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
202216
API_URL="$(jq -r .cf.api_url metadata.json)"
203217
export CF_INT_API="https://$API_URL"
204218
export CF_DIAL_TIMEOUT=15
205219
export CF_USERNAME=admin
206-
export FLAKE_ATTEMPTS=2
207-
export NODES=16
208220
export GOPATH=$PWD/go
209221
export PATH="$GOPATH/bin:$PATH"
210222
export PATH="$PWD/out:$PATH"
@@ -224,18 +236,16 @@ jobs:
224236
CF_INT_CLIENT_ID: 'potato-face'
225237
CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
226238
run: |
227-
ENV=$(cat metadata.json | jq -r '.name')
228-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
239+
env_name=$(cat metadata.json | jq -r '.name')
240+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
229241
eval "$(bbl print-env --metadata-file ./metadata.json)"
230-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
242+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
231243
export CF_INT_OIDC_USERNAME="admin-oidc"
232-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
244+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
233245
API_URL="$(jq -r .cf.api_url metadata.json)"
234246
export CF_INT_API="https://$API_URL"
235247
export CF_DIAL_TIMEOUT=15
236248
export CF_USERNAME=admin
237-
export FLAKE_ATTEMPTS=2
238-
export NODES=16
239249
export GOPATH=$PWD/go
240250
export PATH="$GOPATH/bin:$PATH"
241251
export PATH="$PWD/out:$PATH"
@@ -247,4 +257,4 @@ jobs:
247257
cf api ${CF_INT_API} --skip-ssl-validation
248258
cf auth
249259
250-
make integration-tests-full-ci
260+
make integration-tests-ci-client-creds

.github/workflows/tests-integration.yml

+90-15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# GitHub repo level Secrets and Variables
2+
3+
# secrets.CLIENT_SECRET
4+
# secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
5+
# vars.CAPI_RELEASE_VERSION
6+
# vars.SHEPHERD_LEASE_NAMESPACE
7+
# vars.SHEPHERD_POOL_DURATION
8+
# vars.SHEPHERD_POOL_NAME
9+
# vars.SHEPHERD_POOL_NAMESPACE
10+
111
name: "Tests: Integration"
212

313
run-name: "Integration [${{ github.event_name }}: ${{ github.event.pull_request.head.sha || github.event.push.after || github.event.workflow_run.head_sha}}]: ${{ github.event.workflow_run.head_commit.message }}"
@@ -14,6 +24,30 @@ on:
1424
- run-integration-tests-cf-env
1525
- run-integration-tests-cf-env-with-client-creds
1626
- run-cats-cf-env
27+
nodes:
28+
description: Number of test nodes
29+
required: false
30+
type: string
31+
default: "12"
32+
lease_id:
33+
description: Pre-provisioned environment lease-id to use in tests
34+
required: false
35+
type: string
36+
lease_namespace:
37+
description: Pre-provisioned environment lease namespace to use in tests
38+
required: false
39+
type: string
40+
run_unit_tests:
41+
description: Run unit tests
42+
required: false
43+
type: boolean
44+
default: true
45+
reinstall_cfd:
46+
description: Force re-installation of CFD
47+
required: false
48+
type: boolean
49+
default: true
50+
1751
push:
1852
tags:
1953
- "v8.*"
@@ -31,7 +65,12 @@ on:
3165
- ".grype.yaml"
3266
- ".git*"
3367
- ".golangci.json"
68+
69+
env:
70+
SHEPHERD_LEASE_ID: ${{ inputs.lease_id }}
71+
3472
jobs:
73+
3574
get-sha:
3675
runs-on: ubuntu-latest
3776
outputs:
@@ -57,14 +96,17 @@ jobs:
5796
steps:
5897
- name: Checkout
5998
uses: actions/checkout@v4
99+
if: ${{ inputs.run_unit_tests == 'true' }}
60100
with:
61101
ref: ${{needs.get-sha.outputs.gitRef}}
62102
- name: Set Up Go
63103
uses: actions/setup-go@v5
104+
if: ${{ inputs.run_unit_tests == 'true' }}
64105
with:
65106
go-version-file: go.mod
66107
check-latest: true
67108
- name: Run Units
109+
if: ${{ inputs.run_unit_tests == 'true' }}
68110
run: make units
69111

70112
claim-env:
@@ -88,23 +130,45 @@ jobs:
88130
- name: claim
89131
id: claim
90132
env:
91-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
92-
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
93-
pool_namespace: official
133+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
134+
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
135+
pool_duration: ${{ vars.SHEPHERD_POOL_DURATION || '8h' }}
136+
pool_namespace: ${{ vars.SHEPHERD_POOL_NAMESPACE || 'official' }}
137+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
94138
run: |
95139
shepherd login service-account ${account_token}
96140
97-
echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
98-
lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)
99-
141+
if [[ -z $SHEPHERD_LEASE_ID ]]; then
142+
lease_id=$( shepherd create lease \
143+
--duration ${pool_duration} \
144+
--pool ${pool_name} \
145+
--pool-namespace ${pool_namespace} \
146+
--namespace ${lease_namespace} \
147+
--description "Claimed by CF CLI workflow ${{ github.workflow_run.url }}" \
148+
--json \
149+
| jq -r .id
150+
)
151+
else
152+
lease_id=$SHEPHERD_LEASE_ID
153+
fi
154+
155+
echo "Shepherd lease ID: ${lease_id}"
156+
100157
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
101158
# if the pool is empty.
102159
count=0
103160
while [ $count -lt 360 ] ; do
104161
sleep 30
105-
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
162+
status=$( shepherd get lease ${lease_id} \
163+
--namespace ${lease_namespace} \
164+
--json \
165+
| jq -r .status
166+
)
106167
if [ $status == "LEASED" ] ; then
107-
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
168+
shepherd get lease ${lease_id} \
169+
--namespace ${lease_namespace} \
170+
--json \
171+
| jq .output > metadata.json
108172
break
109173
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
110174
echo "There was an error obtaining the lease. Lease status is ${status}."
@@ -119,7 +183,7 @@ jobs:
119183
echo "env name is ${env_name}"
120184
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
121185
122-
cf_deployment_version=$(jq -r '."cf-deployment_version"' metadata.json)
186+
cf_deployment_version=$(jq -r '."cf_deployment_version"' metadata.json)
123187
echo "cf_deployment_version is ${cf_deployment_version}"
124188
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
125189
@@ -130,6 +194,7 @@ jobs:
130194
check-latest: true
131195

132196
- name: Install Tools
197+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
133198
run: |
134199
go version
135200
@@ -149,11 +214,11 @@ jobs:
149214
apt-get install -y build-essential unzip
150215

151216
- name: Upload latest CAPI release
217+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
152218
env:
153219
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
154220
run: |
155-
if [ -z "$capi_release_version" ]
156-
then
221+
if [ -z "$capi_release_version" ]; then
157222
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
158223
fi
159224
@@ -166,19 +231,20 @@ jobs:
166231
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
167232
168233
- name: Checkout cf-deployment
234+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
169235
uses: actions/checkout@v4
170236
with:
171237
repository: cloudfoundry/cf-deployment
172238
path: cf-deployment
173239
ref: ${{steps.claim.outputs.cf_deployment_version}}
174240

175241
- name: Deploy Isolation Segment and OIDC Provider
242+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
176243
run: |
177244
env_name=$(jq -r .name metadata.json)
178245
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
179246
eval "$(bbl print-env --metadata-file metadata.json)"
180247
181-
# deploy
182248
bosh -d cf manifest > /tmp/manifest.yml
183249
bosh interpolate /tmp/manifest.yml \
184250
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
@@ -208,6 +274,8 @@ jobs:
208274
name: Integration
209275
gitRef: ${{needs.get-sha.outputs.gitRef}}
210276
lease-id: ${{ needs.claim-env.outputs.leaseid }}
277+
lease-namespace: ${{ inputs.lease_namespace }}
278+
nodes: ${{ inputs.nodes }}
211279
secrets: inherit
212280

213281
run-integration-tests-cf-env-with-client-creds:
@@ -224,6 +292,8 @@ jobs:
224292
name: Integration client creds
225293
gitRef: ${{needs.get-sha.outputs.gitRef}}
226294
lease-id: ${{ needs.claim-env.outputs.leaseid }}
295+
lease-namespace: ${{ inputs.lease_namespace }}
296+
nodes: ${{ inputs.nodes }}
227297
secrets: inherit
228298

229299
run-cats-cf-env:
@@ -241,21 +311,26 @@ jobs:
241311
name: cats
242312
gitRef: ${{needs.get-sha.outputs.gitRef}}
243313
lease-id: ${{ needs.claim-env.outputs.leaseid }}
314+
lease-namespace: ${{ inputs.lease_namespace }}
315+
nodes: ${{ inputs.nodes }}
244316
secrets: inherit
245317

246318
unclaim-env:
247319
name: Unclaim environment
320+
if: ${{ inputs.lease_id == '' }}
248321
runs-on: ubuntu-latest
249322
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
250323
needs:
251324
- claim-env
252325
- run-cats-cf-env
253-
if: always()
254326
steps:
255327
- name: unclaim
256328
env:
257-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
329+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
330+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
258331
run: |
259332
shepherd login service-account ${account_token}
260333
set -x
261-
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
334+
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
335+
--namespace ${lease_namespace}
336+

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ integration/assets/test_plugin/test_plugin
6868

6969
### VisualStudioCode ###
7070
.vscode
71+
.secrets
72+
.vars

0 commit comments

Comments
 (0)