Skip to content

Commit 37a7357

Browse files
a-bjoaopapereira
andcommitted
Switch test environments to cfd bosh lites
* 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 140440b commit 37a7357

23 files changed

+246
-66
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

+29-17
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,16 +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}}
32+
nodes:
33+
type: string
34+
default: "16"
35+
36+
env:
37+
NODES: ${{ inputs.nodes }}
38+
FLAKE_ATTEMPTS: ${{ vars.TEST_FLAKE_ATTEMPTS || '4' }}
39+
2840
jobs:
2941
run-integration-tests:
3042
defaults:
3143
run:
3244
shell: bash
33-
runs-on: ${{ inputs.os }}
45+
runs-on: ${{ inputs.os }}
3446
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
47+
timeout-minutes: 120
3548
steps:
3649
- name: Checkout cli
3750
uses: actions/checkout@v4
@@ -53,7 +66,9 @@ jobs:
5366

5467
- name: Install Tools
5568
env:
56-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
69+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
70+
lease_namespace: ${{ inputs.lease-namespace }}
71+
lease_id: ${{ inputs.lease-id }}
5772
run: |
5873
go version
5974
@@ -87,23 +102,21 @@ jobs:
87102
apt-get install -y build-essential unzip
88103
89104
shepherd login service-account ${account_token}
90-
shepherd get lease ${{ inputs.lease-id }} --namespace tas-devex --json | jq .output > metadata.json
105+
shepherd get lease ${lease_id} --namespace ${lease_namespace} --json | jq .output > metadata.json
91106
92107
- name: Run Integration Tests
93108
if: ${{ !inputs.run-with-client-creds }}
94109
run: |
95-
ENV=$(cat metadata.json | jq -r '.name')
96-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
110+
env_name=$(cat metadata.json | jq -r '.name')
111+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
97112
eval "$(bbl print-env --metadata-file ./metadata.json)"
98-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
113+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
99114
export CF_INT_OIDC_USERNAME="admin-oidc"
100-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
115+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
101116
API_URL="$(jq -r .cf.api_url metadata.json)"
102117
export CF_INT_API="https://$API_URL"
103118
export CF_DIAL_TIMEOUT=15
104119
export CF_USERNAME=admin
105-
export FLAKE_ATTEMPTS=2
106-
export NODES=16
107120
export GOPATH=$PWD/go
108121
export PATH="$GOPATH/bin:$PATH"
109122
export PATH="$PWD/out:$PATH"
@@ -123,18 +136,16 @@ jobs:
123136
CF_INT_CLIENT_ID: 'potato-face'
124137
CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
125138
run: |
126-
ENV=$(cat metadata.json | jq -r '.name')
127-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
139+
env_name=$(cat metadata.json | jq -r '.name')
140+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
128141
eval "$(bbl print-env --metadata-file ./metadata.json)"
129-
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
142+
export CF_INT_PASSWORD="$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)"
130143
export CF_INT_OIDC_USERNAME="admin-oidc"
131-
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
144+
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
132145
API_URL="$(jq -r .cf.api_url metadata.json)"
133146
export CF_INT_API="https://$API_URL"
134147
export CF_DIAL_TIMEOUT=15
135148
export CF_USERNAME=admin
136-
export FLAKE_ATTEMPTS=2
137-
export NODES=16
138149
export GOPATH=$PWD/go
139150
export PATH="$GOPATH/bin:$PATH"
140151
export PATH="$PWD/out:$PATH"
@@ -146,4 +157,5 @@ jobs:
146157
cf api ${CF_INT_API} --skip-ssl-validation
147158
cf auth
148159
149-
make integration-tests-full-ci
160+
make integration-tests-ci
161+
-client-creds

.github/workflows/tests-integration.yml

+103-15
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 }}"
@@ -13,6 +24,30 @@ on:
1324
- all
1425
- run-integration-tests-cf-env
1526
- run-integration-tests-cf-env-with-client-creds
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+
1651
push:
1752
tags:
1853
- "v8.*"
@@ -26,7 +61,16 @@ on:
2661
- "doc/**"
2762
- ".gitpod.yml"
2863
- "README.md"
64+
- ".github/**"
65+
- ".grype.yaml"
66+
- ".git*"
67+
- ".golangci.json"
68+
69+
env:
70+
SHEPHERD_LEASE_ID: ${{ inputs.lease_id }}
71+
2972
jobs:
73+
3074
get-sha:
3175
runs-on: ubuntu-latest
3276
outputs:
@@ -52,15 +96,18 @@ jobs:
5296
steps:
5397
- name: Checkout
5498
uses: actions/checkout@v4
99+
if: ${{ inputs.run_unit_tests == 'true' }}
55100
with:
56101
ref: ${{needs.get-sha.outputs.gitRef}}
57102
fetch-depth: 0
58103
- name: Set Up Go
59104
uses: actions/setup-go@v5
105+
if: ${{ inputs.run_unit_tests == 'true' }}
60106
with:
61107
go-version-file: go.mod
62108
check-latest: true
63109
- name: Run Units
110+
if: ${{ inputs.run_unit_tests == 'true' }}
64111
run: make units
65112

66113
claim-env:
@@ -84,23 +131,57 @@ jobs:
84131
- name: claim
85132
id: claim
86133
env:
87-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
88-
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
89-
pool_namespace: official
134+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
135+
template_argument: ${{ vars.SHEPHERD_TEMPLATE_ARGUMENT }}
136+
template_name: ${{ vars.SHEPHERD_TEMPLATE_NAME || '[email protected]' }}
137+
template_namespace: ${{ vars.SHEPHERD_TEMPLATE_NAMESPACE || 'official' }}
138+
lease_duration: ${{ vars.SHEPHERD_LEASE_DURATION || '8h' }}
139+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
90140
run: |
91141
shepherd login service-account ${account_token}
92142
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-
143+
if [[ -z $SHEPHERD_LEASE_ID ]]; then
144+
145+
if [ -z "$template_argument" ]; then
146+
export template_argument='{"gcp_region": "us-west2",
147+
"vm_type": "n1-standard-8",
148+
"root_disk_gb": 32,
149+
"disk_pool_gb": 150,
150+
"cfd_version": "",
151+
"additional_opsfiles_b64": ""}'
152+
fi
153+
154+
lease_id=$( shepherd create lease \
155+
--template-argument "$template_argument" \
156+
--template-namespace "${template_namespace}" \
157+
--template "${template_name}" \
158+
--namespace "${lease_namespace}" \
159+
--duration "${lease_duration}" \
160+
--description "Claimed by CF CLI workflow ${{ github.workflow_run.url }}" \
161+
--json \
162+
| jq -r .id
163+
)
164+
else
165+
lease_id=$SHEPHERD_LEASE_ID
166+
fi
167+
168+
echo "Shepherd lease ID: ${lease_id}"
169+
96170
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
97171
# if the pool is empty.
98172
count=0
99173
while [ $count -lt 360 ] ; do
100174
sleep 30
101-
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
175+
status=$( shepherd get lease ${lease_id} \
176+
--namespace ${lease_namespace} \
177+
--json \
178+
| jq -r .status
179+
)
102180
if [ $status == "LEASED" ] ; then
103-
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
181+
shepherd get lease ${lease_id} \
182+
--namespace ${lease_namespace} \
183+
--json \
184+
| jq .output > metadata.json
104185
break
105186
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
106187
echo "There was an error obtaining the lease. Lease status is ${status}."
@@ -115,7 +196,7 @@ jobs:
115196
echo "env name is ${env_name}"
116197
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
117198
118-
cf_deployment_version=$(jq -r '."cf-deployment_version"' metadata.json)
199+
cf_deployment_version=$(jq -r '."cf_deployment_version"' metadata.json)
119200
echo "cf_deployment_version is ${cf_deployment_version}"
120201
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
121202
@@ -126,6 +207,7 @@ jobs:
126207
check-latest: true
127208

128209
- name: Install Tools
210+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
129211
run: |
130212
go version
131213
@@ -145,11 +227,11 @@ jobs:
145227
apt-get install -y build-essential unzip
146228

147229
- name: Upload latest CAPI release
230+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
148231
env:
149232
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
150233
run: |
151-
if [ -z "$capi_release_version" ]
152-
then
234+
if [ -z "$capi_release_version" ]; then
153235
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
154236
fi
155237
@@ -162,19 +244,20 @@ jobs:
162244
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
163245
164246
- name: Checkout cf-deployment
247+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
165248
uses: actions/checkout@v4
166249
with:
167250
repository: cloudfoundry/cf-deployment
168251
path: cf-deployment
169252
ref: ${{steps.claim.outputs.cf_deployment_version}}
170253

171254
- name: Deploy Isolation Segment and OIDC Provider
255+
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
172256
run: |
173257
env_name=$(jq -r .name metadata.json)
174258
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
175259
eval "$(bbl print-env --metadata-file metadata.json)"
176260
177-
# deploy
178261
bosh -d cf manifest > /tmp/manifest.yml
179262
bosh interpolate /tmp/manifest.yml \
180263
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
@@ -204,6 +287,8 @@ jobs:
204287
name: Integration
205288
gitRef: ${{needs.get-sha.outputs.gitRef}}
206289
lease-id: ${{ needs.claim-env.outputs.leaseid }}
290+
lease-namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
291+
nodes: ${{ inputs.nodes }}
207292
secrets: inherit
208293

209294
run-integration-tests-cf-env-with-client-creds:
@@ -220,22 +305,25 @@ jobs:
220305
name: Integration client creds
221306
gitRef: ${{needs.get-sha.outputs.gitRef}}
222307
lease-id: ${{ needs.claim-env.outputs.leaseid }}
308+
lease-namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
223309
secrets: inherit
224310

225311
unclaim-env:
226312
name: Unclaim environment
313+
if: ${{ inputs.lease_id == '' }}
227314
runs-on: ubuntu-latest
228315
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
229316
needs:
230317
- claim-env
231318
- run-integration-tests-cf-env
232319
- run-integration-tests-cf-env-with-client-creds
233-
if: always()
234320
steps:
235321
- name: unclaim
236322
env:
237-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
323+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
324+
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
238325
run: |
239326
shepherd login service-account ${account_token}
240327
set -x
241-
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
328+
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
329+
--namespace ${lease_namespace}

.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

Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CF_DIAL_TIMEOUT ?= 15
22
NODES ?= 10
3+
FLAKE_ATTEMPTS ?=5
34
PACKAGES ?= api actor command types util version integration/helpers
45
LC_ALL = "en_US.UTF-8"
56

@@ -131,6 +132,7 @@ integration-selfcontained: build install-test-deps
131132

132133
integration-tests: build integration-cleanup integration-isolated integration-push integration-global integration-selfcontained ## Run all isolated, push, selfcontained, and global integration tests
133134

135+
integration-tests-ci-client-creds: build integration-cleanup integration-push integration-global integration-selfcontained
134136

135137
i: integration-tests-full
136138
integration-full-tests: integration-tests-full

0 commit comments

Comments
 (0)