Skip to content

Commit 4e97bd1

Browse files
authored
Use one environment to run int tests [main] (#3242)
1 parent efdd8b9 commit 4e97bd1

File tree

9 files changed

+198
-104
lines changed

9 files changed

+198
-104
lines changed
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
---
22
- type: replace
33
path: /instance_groups/name=diego-cell/instances
4-
value: 3
4+
value: 4

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

+13-96
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ on:
1919
name:
2020
required: true
2121
type: string
22-
pool-name:
23-
type: string
24-
default: ${{ vars.SHEPHERD_POOL_NAME }}
25-
pool-namespace:
22+
lease-id:
23+
required: true
2624
type: string
27-
default: 'official'
2825
gitRef:
2926
type: string
3027
default: ${{github.event.workflow_run.head_sha}}
@@ -50,78 +47,41 @@ jobs:
5047
ref: release-candidate
5148
path: cf-acceptance-tests
5249

53-
- name: Checkout cf-deployment
54-
uses: actions/checkout@v4
55-
with:
56-
repository: cloudfoundry/cf-deployment
57-
path: cf-deployment
58-
5950
- name: Checkout CF deployment tasks
6051
uses: actions/checkout@v4
6152
with:
6253
repository: cloudfoundry/cf-deployment-concourse-tasks
6354
path: cf-deployment-concourse-tasks
6455

65-
- id: claim-env
66-
name: Claim Environment
67-
env:
68-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
69-
pool_name: ${{ inputs.pool-name }}
70-
pool_namespace: ${{ inputs.pool-namespace }}
71-
run: |
72-
shepherd login service-account ${account_token}
73-
74-
echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
75-
lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)
76-
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
77-
# if the pool is empty.
78-
count=0
79-
while [ $count -lt 360 ] ; do
80-
sleep 30
81-
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
82-
if [ $status == "LEASED" ] ; then
83-
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
84-
break
85-
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
86-
echo "There was an error obtaining the lease. Lease status is ${status}."
87-
exit 1
88-
else
89-
echo "Waiting for environment to be ready. Lease status is ${status}."
90-
fi
91-
count=$(($count+1))
92-
done
93-
94-
env_name=$(jq -r .name metadata.json)
95-
cat metadata.json | jq -r '.name'
96-
echo "lease-id=$lease_id" >> "${GITHUB_OUTPUT}"
97-
9856
- name: Set Up Go
9957
uses: actions/setup-go@v5
10058
with:
10159
go-version-file: go.mod
10260
check-latest: true
10361

10462
- name: Install Tools
63+
env:
64+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
10565
run: |
10666
go version
10767
10868
if [[ ${{ inputs.os }} =~ "windows" ]]
10969
then
11070
install_location=/usr/bin
11171
bbl_artifact=bbl-v8.4.110_windows.exe
112-
bosh_cli_artifact=bosh-cli-7.0.1-windows-amd64.exe
72+
bosh_cli_artifact=bosh-cli-7.7.2-windows-amd64.exe
11373
credhub_artifact=credhub-windows-2.9.4.tgz
11474
else
11575
install_location=/usr/local/bin
11676
bbl_artifact=bbl-v8.4.110_linux_x86-64
117-
bosh_cli_artifact=bosh-cli-7.0.1-linux-amd64
77+
bosh_cli_artifact=bosh-cli-7.7.2-linux-amd64
11878
credhub_artifact=credhub-linux-2.9.4.tgz
11979
fi
12080
curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.110/${bbl_artifact} --silent --location --output $install_location/bbl
12181
chmod +x $install_location/bbl
12282
bbl --version
12383
124-
curl https://s3.amazonaws.com/bosh-cli-artifacts/$bosh_cli_artifact --silent --output $install_location/bosh --location
84+
curl https://github.com/cloudfoundry/bosh-cli/releases/download/v7.7.2/$bosh_cli_artifact --silent --output $install_location/bosh --location
12585
chmod +x $install_location/bosh
12686
bosh --version
12787
@@ -134,50 +94,14 @@ jobs:
13494
apt-get update
13595
apt-get install -y build-essential unzip
13696
137-
- name: Upload latest CAPI release
138-
env:
139-
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
140-
run: |
141-
if [ -z "$capi_release_version" ]
142-
then
143-
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
144-
fi
145-
146-
echo "Latest CAPI release is $capi_release_version"
147-
148-
eval "$(bbl print-env --metadata-file metadata.json)"
149-
env_name=$(jq -r .name metadata.json)
150-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
151-
152-
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
153-
154-
- name: Deploy Isolation Segment and OIDC Provider
155-
run: |
156-
env_name=$(jq -r .name metadata.json)
157-
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
158-
eval "$(bbl print-env --metadata-file metadata.json)"
159-
160-
# deploy
161-
bosh -d cf manifest > /tmp/manifest.yml
162-
bosh interpolate /tmp/manifest.yml \
163-
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
164-
-o cf-deployment/operations/add-persistent-isolation-segment-diego-cell.yml \
165-
-o .github/ops-files/use-latest-capi.yml \
166-
-o .github/ops-files/add-oidc-provider.yml \
167-
-o .github/ops-files/add-uaa-client-credentials.yml \
168-
-o .github/ops-files/diego-cell-instances.yml \
169-
-v client-secret="${{ secrets.CLIENT_SECRET }}" \
170-
> ./director.yml
171-
172-
bosh -d cf deploy director.yml -n
173-
echo "Deployed CAPI version:"
174-
bosh -d cf releases | grep capi
97+
shepherd login service-account ${account_token}
98+
shepherd get lease ${{ inputs.lease-id }} --namespace tas-devex --json | jq .output > metadata.json
17599
176100
- name: Add CATS config
177101
if: ${{ inputs.name == 'cats' }}
178102
run: |
179103
set -eu
180-
104+
181105
ENV=$(jq -r .name metadata.json)
182106
API="$(jq -r .cf.api_url metadata.json)"
183107
DOMAIN=$(echo $API | sed "s/^api\.//")
@@ -284,6 +208,7 @@ jobs:
284208
export GOPATH=$PWD/go
285209
export PATH="$GOPATH/bin:$PATH"
286210
export PATH="$PWD/out:$PATH"
211+
export CF_INT_TEST_NAME="int"
287212
288213
make build
289214
@@ -314,20 +239,12 @@ jobs:
314239
export GOPATH=$PWD/go
315240
export PATH="$GOPATH/bin:$PATH"
316241
export PATH="$PWD/out:$PATH"
242+
export CF_INT_TEST_NAME="cc"
317243
318244
make build
319245
320246
export CF_PASSWORD=${CF_INT_PASSWORD}
321247
cf api ${CF_INT_API} --skip-ssl-validation
322248
cf auth
323249
324-
make integration-tests-full-ci
325-
326-
- name: Unclaim environment
327-
if: ${{ always() && !runner.debug }}
328-
env:
329-
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
330-
run: |
331-
shepherd login service-account ${account_token}
332-
set -x
333-
shepherd delete lease ${{ steps.claim-env.outputs.lease-id }} --namespace tas-devex
250+
make integration-tests-full-ci

.github/workflows/tests-integration.yml

+151-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ on:
1616
- run-cats-cf-env
1717
push:
1818
tags:
19-
- "v9.*"
2019
- "v8.*"
2120
- "v7.*"
2221
pull_request_target:
2322
branches:
2423
- main
25-
- v9
2624
- v8
2725
- v7
2826
paths-ignore:
@@ -68,38 +66,171 @@ jobs:
6866
check-latest: true
6967
- name: Run Units
7068
run: make units
69+
70+
claim-env:
71+
name: Claim and Prep Environment
72+
outputs:
73+
leaseid: ${{steps.claim.outputs.leaseid}}
74+
defaults:
75+
run:
76+
shell: bash
77+
runs-on: ubuntu-latest
78+
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
79+
needs:
80+
- get-sha
81+
- units
82+
steps:
83+
- name: Checkout cli
84+
uses: actions/checkout@v4
85+
with:
86+
ref: ${{needs.get-sha.outputs.gitRef}}
87+
88+
- name: claim
89+
id: claim
90+
env:
91+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
92+
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
93+
pool_namespace: official
94+
run: |
95+
shepherd login service-account ${account_token}
96+
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+
100+
# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
101+
# if the pool is empty.
102+
count=0
103+
while [ $count -lt 360 ] ; do
104+
sleep 30
105+
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
106+
if [ $status == "LEASED" ] ; then
107+
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
108+
break
109+
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
110+
echo "There was an error obtaining the lease. Lease status is ${status}."
111+
exit 1
112+
else
113+
echo "Waiting for environment to be ready. Lease status is ${status}."
114+
fi
115+
count=$(($count+1))
116+
done
117+
118+
env_name=$(jq -r .name metadata.json)
119+
echo "env name is ${env_name}"
120+
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"
121+
122+
cf_deployment_version=$(jq -r '."cf-deployment_version"' metadata.json)
123+
echo "cf_deployment_version is ${cf_deployment_version}"
124+
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"
125+
126+
- name: Set Up Go
127+
uses: actions/setup-go@v5
128+
with:
129+
go-version-file: go.mod
130+
check-latest: true
131+
132+
- name: Install Tools
133+
run: |
134+
go version
135+
136+
install_location=/usr/local/bin
137+
bbl_artifact=bbl-v8.4.110_linux_x86-64
138+
bosh_cli_artifact=bosh-cli-7.7.2-linux-amd64
139+
140+
curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.110/${bbl_artifact} --silent --location --output $install_location/bbl
141+
chmod +x $install_location/bbl
142+
bbl --version
143+
144+
curl https://github.com/cloudfoundry/bosh-cli/releases/download/v7.7.2/$bosh_cli_artifact --silent --output $install_location/bosh --location
145+
chmod +x $install_location/bosh
146+
bosh --version
147+
148+
apt-get update
149+
apt-get install -y build-essential unzip
150+
151+
- name: Upload latest CAPI release
152+
env:
153+
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
154+
run: |
155+
if [ -z "$capi_release_version" ]
156+
then
157+
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
158+
fi
159+
160+
echo "Latest CAPI release is $capi_release_version"
161+
162+
eval "$(bbl print-env --metadata-file metadata.json)"
163+
env_name=$(jq -r .name metadata.json)
164+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
165+
166+
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
167+
168+
- name: Checkout cf-deployment
169+
uses: actions/checkout@v4
170+
with:
171+
repository: cloudfoundry/cf-deployment
172+
path: cf-deployment
173+
ref: ${{steps.claim.outputs.cf_deployment_version}}
174+
175+
- name: Deploy Isolation Segment and OIDC Provider
176+
run: |
177+
env_name=$(jq -r .name metadata.json)
178+
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
179+
eval "$(bbl print-env --metadata-file metadata.json)"
180+
181+
# deploy
182+
bosh -d cf manifest > /tmp/manifest.yml
183+
bosh interpolate /tmp/manifest.yml \
184+
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
185+
-o cf-deployment/operations/add-persistent-isolation-segment-diego-cell.yml \
186+
-o .github/ops-files/use-latest-capi.yml \
187+
-o .github/ops-files/add-oidc-provider.yml \
188+
-o .github/ops-files/add-uaa-client-credentials.yml \
189+
-o .github/ops-files/diego-cell-instances.yml \
190+
-v client-secret="${{ secrets.CLIENT_SECRET }}" \
191+
> ./director.yml
192+
193+
bosh -d cf deploy director.yml -n
194+
echo "Deployed CAPI version:"
195+
bosh -d cf releases | grep capi
196+
71197
run-integration-tests-cf-env:
72198
name: Integration tests
73199
needs:
74200
- get-sha
75201
- units
202+
- claim-env
76203
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env' }}
77204
uses: ./.github/workflows/tests-integration-reusable.yml
78205
with:
79206
run-with-client-creds: false
80207
os: ubuntu-latest
81208
name: Integration
82209
gitRef: ${{needs.get-sha.outputs.gitRef}}
210+
lease-id: ${{ needs.claim-env.outputs.leaseid }}
83211
secrets: inherit
84212

85213
run-integration-tests-cf-env-with-client-creds:
86214
name: client creds
87215
needs:
88216
- get-sha
89217
- units
218+
- claim-env
90219
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-client-creds' }}
91220
uses: ./.github/workflows/tests-integration-reusable.yml
92221
with:
93222
run-with-client-creds: true
94223
os: ubuntu-latest
95224
name: Integration client creds
96225
gitRef: ${{needs.get-sha.outputs.gitRef}}
226+
lease-id: ${{ needs.claim-env.outputs.leaseid }}
97227
secrets: inherit
98228

99229
run-cats-cf-env:
100230
name: CATS
101231
needs:
102232
- get-sha
233+
- claim-env
103234
- run-integration-tests-cf-env
104235
- run-integration-tests-cf-env-with-client-creds
105236
if: ${{ github.event_name != 'workflow_dispatch' || inputs.workflow == 'all' || inputs.workflow == 'run-cats-cf-env' }}
@@ -109,4 +240,22 @@ jobs:
109240
os: ubuntu-latest
110241
name: cats
111242
gitRef: ${{needs.get-sha.outputs.gitRef}}
243+
lease-id: ${{ needs.claim-env.outputs.leaseid }}
112244
secrets: inherit
245+
246+
unclaim-env:
247+
name: Unclaim environment
248+
runs-on: ubuntu-latest
249+
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
250+
needs:
251+
- claim-env
252+
- run-cats-cf-env
253+
if: always()
254+
steps:
255+
- name: unclaim
256+
env:
257+
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
258+
run: |
259+
shepherd login service-account ${account_token}
260+
set -x
261+
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex

0 commit comments

Comments
 (0)