Skip to content

Commit fa301be

Browse files
a-bjoaopapereira
andcommitted
Switch test environments to cfd bosh lites [v8]
* 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 <joao.pereira@broadcom.com>
1 parent 3cd802e commit fa301be

26 files changed

+254
-76
lines changed

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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 33 additions & 23 deletions
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: "16"
35+
36+
env:
37+
NODES: ${{ inputs.nodes }}
38+
FLAKE_ATTEMPTS: ${{ vars.TEST_FLAKE_ATTEMPTS || '4' }}
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,22 +109,22 @@ 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
104-
ENV=$(jq -r .name metadata.json)
118+
env_name=$(jq -r .name metadata.json)
105119
API="$(jq -r .cf.api_url metadata.json)"
106120
DOMAIN=$(echo $API | sed "s/^api\.//")
107121
CF_INT_USERNAME="admin"
108122
109-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
123+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
110124
eval "$(bbl print-env --metadata-file ./metadata.json)"
111125
112126
credhub login
113-
CF_INT_PASSWORD=$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)
127+
CF_INT_PASSWORD=$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)
114128
115129
cat << EOF | jq -S . > cats_config.json
116130
{
@@ -184,26 +198,24 @@ jobs:
184198
--keep-going \
185199
--randomize-all \
186200
--skip-package=helpers \
187-
--nodes="12" \
188-
--flake-attempts=2 \
201+
--nodes="${NODES}" \
202+
--flake-attempts=${FLAKE_ATTEMPTS} \
189203
--timeout="2h" \
190204
--no-color
191205
192206
- name: Run Integration Tests
193207
if: ${{ !inputs.run-with-client-creds && inputs.name != 'cats' }}
194208
run: |
195-
ENV=$(cat metadata.json | jq -r '.name')
196-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
209+
env_name=$(cat metadata.json | jq -r '.name')
210+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
197211
eval "$(bbl print-env --metadata-file ./metadata.json)"
198-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
212+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
199213
export CF_INT_OIDC_USERNAME="admin-oidc"
200-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
214+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
201215
API_URL="$(jq -r .cf.api_url metadata.json)"
202216
export CF_INT_API="https://$API_URL"
203217
export CF_DIAL_TIMEOUT=15
204218
export CF_USERNAME=admin
205-
export FLAKE_ATTEMPTS=2
206-
export NODES=16
207219
export GOPATH=$PWD/go
208220
export PATH="$GOPATH/bin:$PATH"
209221
export PATH="$PWD/out:$PATH"
@@ -223,18 +235,16 @@ jobs:
223235
CF_INT_CLIENT_ID: 'potato-face'
224236
CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
225237
run: |
226-
ENV=$(cat metadata.json | jq -r '.name')
227-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
238+
env_name=$(cat metadata.json | jq -r '.name')
239+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
228240
eval "$(bbl print-env --metadata-file ./metadata.json)"
229-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
241+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
230242
export CF_INT_OIDC_USERNAME="admin-oidc"
231-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
243+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
232244
API_URL="$(jq -r .cf.api_url metadata.json)"
233245
export CF_INT_API="https://$API_URL"
234246
export CF_DIAL_TIMEOUT=15
235247
export CF_USERNAME=admin
236-
export FLAKE_ATTEMPTS=2
237-
export NODES=16
238248
export GOPATH=$PWD/go
239249
export PATH="$GOPATH/bin:$PATH"
240250
export PATH="$PWD/out:$PATH"
@@ -246,4 +256,4 @@ jobs:
246256
cf api ${CF_INT_API} --skip-ssl-validation
247257
cf auth
248258
249-
make integration-tests-full-ci
259+
make integration-tests-ci-client-creds

.github/workflows/tests-integration.yml

Lines changed: 99 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
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_DURATION
7+
# vars.SHEPHERD_LEASE_NAMESPACE
8+
# vars.SHEPHERD_TEMPLATE_ARGUMENT
9+
# vars.SHEPHERD_TEMPLATE_NAME
10+
# vars.SHEPHERD_TEMPLATE_NAMESPACE
11+
112
name: "Tests: Integration"
213

314
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 +25,30 @@ on:
1425
- run-integration-tests-cf-env
1526
- run-integration-tests-cf-env-with-client-creds
1627
- run-cats-cf-env
28+
nodes:
29+
description: Number of test nodes
30+
required: false
31+
type: string
32+
default: "12"
33+
lease_id:
34+
description: Pre-provisioned environment lease-id to use in tests
35+
required: false
36+
type: string
37+
lease_namespace:
38+
description: Pre-provisioned environment lease namespace to use in tests
39+
required: false
40+
type: string
41+
run_unit_tests:
42+
description: Run unit tests
43+
required: false
44+
type: boolean
45+
default: true
46+
reinstall_cfd:
47+
description: Force re-installation of CFD
48+
required: false
49+
type: boolean
50+
default: true
51+
1752
push:
1853
tags:
1954
- "v8.*"
@@ -27,6 +62,10 @@ on:
2762
- "doc/**"
2863
- ".gitpod.yml"
2964
- "README.md"
65+
66+
env:
67+
SHEPHERD_LEASE_ID: ${{ inputs.lease_id }}
68+
3069
jobs:
3170
get-sha:
3271
runs-on: ubuntu-latest
@@ -53,14 +92,17 @@ jobs:
5392
steps:
5493
- name: Checkout
5594
uses: actions/checkout@v4
95+
if: ${{ inputs.run_unit_tests == 'true' }}
5696
with:
5797
ref: ${{needs.get-sha.outputs.gitRef}}
5898
- name: Set Up Go
5999
uses: actions/setup-go@v5
100+
if: ${{ inputs.run_unit_tests == 'true' }}
60101
with:
61102
go-version-file: go.mod
62103
check-latest: true
63104
- name: Run Units
105+
if: ${{ inputs.run_unit_tests == 'true' }}
64106
run: make units
65107

66108
claim-env:
@@ -84,23 +126,57 @@ jobs:
84126
- name: claim
85127
id: claim
86128
env:
87-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
88-
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
89-
pool_namespace: official
129+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
130+
template_argument: ${{ vars.SHEPHERD_TEMPLATE_ARGUMENT }}
131+
template_name: ${{ vars.SHEPHERD_TEMPLATE_NAME || 'cfd-bosh-lite@1.0' }}
132+
template_namespace: ${{ vars.SHEPHERD_TEMPLATE_NAMESPACE || 'official' }}
133+
lease_duration: ${{ vars.SHEPHERD_LEASE_DURATION || '8h' }}
134+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
90135
run: |
91136
shepherd login service-account ${account_token}
92137
93-
echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
94-
lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)
95-
138+
if [[ -z $SHEPHERD_LEASE_ID ]]; then
139+
140+
if [ -z "$template_argument" ]; then
141+
export template_argument='{"gcp_region": "us-west2",
142+
"vm_type": "n1-standard-8",
143+
"root_disk_gb": 32,
144+
"disk_pool_gb": 150,
145+
"cfd_version": "",
146+
"additional_opsfiles_b64": ""}'
147+
fi
148+
149+
lease_id=$( shepherd create lease \
150+
--template-argument "$template_argument" \
151+
--template-namespace "${template_namespace}" \
152+
--template "${template_name}" \
153+
--namespace "${lease_namespace}" \
154+
--duration "${lease_duration}" \
155+
--description "Claimed by CF CLI workflow ${{ github.workflow_run.url }}" \
156+
--json \
157+
| jq -r .id
158+
)
159+
else
160+
lease_id=$SHEPHERD_LEASE_ID
161+
fi
162+
163+
echo "Shepherd lease ID: ${lease_id}"
164+
96165
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
97166
# if the pool is empty.
98167
count=0
99168
while [ $count -lt 360 ] ; do
100169
sleep 30
101-
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
170+
status=$( shepherd get lease ${lease_id} \
171+
--namespace ${lease_namespace} \
172+
--json \
173+
| jq -r .status
174+
)
102175
if [ $status == "LEASED" ] ; then
103-
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
176+
shepherd get lease ${lease_id} \
177+
--namespace ${lease_namespace} \
178+
--json \
179+
| jq .output > metadata.json
104180
break
105181
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
106182
echo "There was an error obtaining the lease. Lease status is ${status}."
@@ -115,7 +191,7 @@ jobs:
115191
echo "env name is ${env_name}"
116192
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
117193
118-
cf_deployment_version=$(jq -r '."cf-deployment_version"' metadata.json)
194+
cf_deployment_version=$(jq -r '."cf_deployment_version"' metadata.json)
119195
echo "cf_deployment_version is ${cf_deployment_version}"
120196
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
121197
@@ -126,6 +202,7 @@ jobs:
126202
check-latest: true
127203

128204
- name: Install Tools
205+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
129206
run: |
130207
go version
131208
@@ -145,11 +222,11 @@ jobs:
145222
apt-get install -y build-essential unzip
146223

147224
- name: Upload latest CAPI release
225+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
148226
env:
149227
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
150228
run: |
151-
if [ -z "$capi_release_version" ]
152-
then
229+
if [ -z "$capi_release_version" ]; then
153230
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
154231
fi
155232
@@ -162,19 +239,20 @@ jobs:
162239
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
163240
164241
- name: Checkout cf-deployment
242+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
165243
uses: actions/checkout@v4
166244
with:
167245
repository: cloudfoundry/cf-deployment
168246
path: cf-deployment
169247
ref: ${{steps.claim.outputs.cf_deployment_version}}
170248

171249
- name: Deploy Isolation Segment and OIDC Provider
250+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
172251
run: |
173252
env_name=$(jq -r .name metadata.json)
174253
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
175254
eval "$(bbl print-env --metadata-file metadata.json)"
176255
177-
# deploy
178256
bosh -d cf manifest > /tmp/manifest.yml
179257
bosh interpolate /tmp/manifest.yml \
180258
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
@@ -204,6 +282,8 @@ jobs:
204282
name: Integration
205283
gitRef: ${{needs.get-sha.outputs.gitRef}}
206284
lease-id: ${{ needs.claim-env.outputs.leaseid }}
285+
lease-namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
286+
nodes: ${{ inputs.nodes }}
207287
secrets: inherit
208288

209289
run-integration-tests-cf-env-with-client-creds:
@@ -220,6 +300,7 @@ jobs:
220300
name: Integration client creds
221301
gitRef: ${{needs.get-sha.outputs.gitRef}}
222302
lease-id: ${{ needs.claim-env.outputs.leaseid }}
303+
lease-namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
223304
secrets: inherit
224305

225306
run-cats-cf-env:
@@ -237,21 +318,24 @@ jobs:
237318
name: cats
238319
gitRef: ${{needs.get-sha.outputs.gitRef}}
239320
lease-id: ${{ needs.claim-env.outputs.leaseid }}
321+
lease-namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
240322
secrets: inherit
241323

242324
unclaim-env:
243325
name: Unclaim environment
326+
if: ${{ inputs.lease_id == '' }}
244327
runs-on: ubuntu-latest
245328
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
246329
needs:
247330
- claim-env
248331
- run-cats-cf-env
249-
if: always()
250332
steps:
251333
- name: unclaim
252334
env:
253-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
335+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
336+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
254337
run: |
255338
shepherd login service-account ${account_token}
256339
set -x
257-
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
340+
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
341+
--namespace ${lease_namespace}

.gitignore

Lines changed: 2 additions & 0 deletions
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)