-
Notifications
You must be signed in to change notification settings - Fork 928
250 lines (217 loc) · 8.19 KB
/
tests-integration-reusable.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
# GitHub repo level Secrets and Variables
# secrets.CLIENT_SECRET
# secrets.GITHUB_TOKEN
# secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
# vars.SHEPHERD_POOL_NAME
name: "pvt: run integration tests"
on:
workflow_call:
inputs:
run-with-client-creds:
required: true
type: boolean
os:
required: true
type: string
name:
required: true
type: string
lease-id:
required: true
type: string
gitRef:
type: string
default: ${{github.event.workflow_run.head_sha}}
jobs:
run-integration-tests:
defaults:
run:
shell: bash
runs-on: ${{ inputs.os }}
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
steps:
- name: Checkout cli
uses: actions/checkout@v4
with:
ref: ${{inputs.gitRef}}
- name: Checkout cf-acceptance-tests
if: ${{ inputs.name == 'cats' }}
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-acceptance-tests
ref: release-candidate
path: cf-acceptance-tests
- name: Checkout CF deployment tasks
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-deployment-concourse-tasks
path: cf-deployment-concourse-tasks
- name: Set Up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
- name: Install Tools
env:
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
run: |
go version
if [[ ${{ inputs.os }} =~ "windows" ]]
then
install_location=/usr/bin
bbl_artifact=bbl-v8.4.110_windows.exe
bosh_cli_artifact=bosh-cli-7.7.2-windows-amd64.exe
credhub_artifact=credhub-windows-2.9.4.tgz
else
install_location=/usr/local/bin
bbl_artifact=bbl-v8.4.110_linux_x86-64
bosh_cli_artifact=bosh-cli-7.7.2-linux-amd64
credhub_artifact=credhub-linux-2.9.4.tgz
fi
curl https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.110/${bbl_artifact} --silent --location --output $install_location/bbl
chmod +x $install_location/bbl
bbl --version
curl https://github.com/cloudfoundry/bosh-cli/releases/download/v7.7.2/$bosh_cli_artifact --silent --output $install_location/bosh --location
chmod +x $install_location/bosh
bosh --version
curl https://github.com/cloudfoundry/credhub-cli/releases/download/2.9.4/$credhub_artifact --silent --output /tmp/$credhub_artifact --location
tar xzvf /tmp/$credhub_artifact
mv credhub $install_location/credhub
chmod +x $install_location/credhub
credhub --version
apt-get update
apt-get install -y build-essential unzip
shepherd login service-account ${account_token}
shepherd get lease ${{ inputs.lease-id }} --namespace tas-devex --json | jq .output > metadata.json
- name: Add CATS config
if: ${{ inputs.name == 'cats' }}
run: |
set -eu
ENV=$(jq -r .name metadata.json)
API="$(jq -r .cf.api_url metadata.json)"
DOMAIN=$(echo $API | sed "s/^api\.//")
CF_INT_USERNAME="admin"
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
eval "$(bbl print-env --metadata-file ./metadata.json)"
credhub login
CF_INT_PASSWORD=$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)
cat << EOF | jq -S . > cats_config.json
{
"admin_password": "${CF_INT_PASSWORD}",
"admin_user": "${CF_INT_USERNAME}",
"api": "${API}",
"apps_domain": "${DOMAIN}",
"backend" : "diego",
"broker_start_timeout": 330,
"cf_push_timeout": 210,
"default_timeout": 120,
"long_curl_timeout": 210,
"skip_ssl_validation": true,
"use_http": true,
"include_apps": true,
"include_backend_compatibility": false,
"include_container_networking": true,
"include_detect": true,
"include_docker": true,
"include_cnb": true,
"include_internet_dependent": true,
"include_isolation_segments": true,
"isolation_segment_name": "persistent_isolation_segment",
"include_private_docker_registry": false,
"include_route_services": true,
"include_routing": true,
"include_routing_isolation_segments": false,
"include_security_groups": true,
"include_services": true,
"include_service_discovery": true,
"include_service_instance_sharing": true,
"include_ssh": true,
"include_sso": false,
"include_tasks": true,
"include_tcp_routing": true,
"include_v3": true,
"include_zipkin": true
}
EOF
make build
echo "$PWD/out" >> $GITHUB_PATH
export PATH="$PWD/out:$PATH"
cf version
export CF_USERNAME=${CF_INT_USERNAME}
export CF_PASSWORD=${CF_INT_PASSWORD}
cf api ${API} --skip-ssl-validation
cf auth
cf enable-feature-flag diego_docker
cf enable-feature-flag diego_cnb
cf enable-feature-flag service_instance_sharing
- name: Run CATS Tests
if: ${{ inputs.name == 'cats' }}
run: |
set -xeu
export CONFIG
CONFIG=$(mktemp)
original_config="${PWD}/cats_config.json"
cp ${original_config} ${CONFIG}
cd ./cf-acceptance-tests
export CF_DIAL_TIMEOUT=11
export CF_PLUGIN_HOME=$HOME
go version
./bin/test \
--keep-going \
--randomize-all \
--skip-package=helpers \
--nodes="12" \
--flake-attempts=2 \
--timeout="2h" \
--no-color
- name: Run Integration Tests
if: ${{ !inputs.run-with-client-creds && inputs.name != 'cats' }}
run: |
ENV=$(cat metadata.json | jq -r '.name')
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
eval "$(bbl print-env --metadata-file ./metadata.json)"
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
export CF_INT_OIDC_USERNAME="admin-oidc"
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
API_URL="$(jq -r .cf.api_url metadata.json)"
export CF_INT_API="https://$API_URL"
export CF_DIAL_TIMEOUT=15
export CF_USERNAME=admin
export FLAKE_ATTEMPTS=2
export NODES=16
export GOPATH=$PWD/go
export PATH="$GOPATH/bin:$PATH"
export PATH="$PWD/out:$PATH"
export CF_INT_TEST_NAME="int"
make build
export CF_PASSWORD=${CF_INT_PASSWORD}
cf api ${CF_INT_API} --skip-ssl-validation
cf auth
make integration-tests-full-ci
- name: Run Integration Tests with client credentials
if: ${{ inputs.run-with-client-creds }}
env:
CF_INT_CLIENT_ID: 'potato-face'
CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
run: |
ENV=$(cat metadata.json | jq -r '.name')
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${ENV}.priv
eval "$(bbl print-env --metadata-file ./metadata.json)"
export CF_INT_PASSWORD="$(credhub get -n /bosh-$ENV/cf/cf_admin_password | bosh interpolate --path /value -)"
export CF_INT_OIDC_USERNAME="admin-oidc"
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-$ENV/cf/uaa_oidc_admin_password | bosh interpolate --path /value -)
API_URL="$(jq -r .cf.api_url metadata.json)"
export CF_INT_API="https://$API_URL"
export CF_DIAL_TIMEOUT=15
export CF_USERNAME=admin
export FLAKE_ATTEMPTS=2
export NODES=16
export GOPATH=$PWD/go
export PATH="$GOPATH/bin:$PATH"
export PATH="$PWD/out:$PATH"
export CF_INT_TEST_NAME="cc"
make build
export CF_PASSWORD=${CF_INT_PASSWORD}
cf api ${CF_INT_API} --skip-ssl-validation
cf auth
make integration-tests-full-ci