Skip to content

Commit 1abfe44

Browse files
jdgonzalezaJuan Diego Gonzaleza-bCristhian Peña
authored
Full Integration tests on GHA (#2353)
* Updates to the virtual workstation * Adds Integration tests to Github actions: - Integration tests for edge capi linux - Integration tests for min capi - Integration tests for windows - Integration tests for client credential * Updates set-outputs commands Co-authored-by: Juan Diego Gonzalez <gojuan@vmware.com> Co-authored-by: Al Berez <a@berez.co> Co-authored-by: Cristhian Peña <cpena@vmware.com>
1 parent f773611 commit 1abfe44

13 files changed

+808
-226
lines changed

.actrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--artifact-server-path /tmp/artifacts

.devcontainer/cli.code-workspace

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"folders": [
3+
{ "path": ".." },
4+
{ "path": "../../cli-ci" },
5+
{ "path": "../../cli-private" },
6+
{ "path": "../../cli-workstation" }
7+
8+
],
9+
"settings": {
10+
"github-actions.workflows.pinned.workflows": [
11+
"cli/.github/workflows/integration.yml"
12+
]
13+
},
14+
"extensions": {
15+
"recommendations": [
16+
"gitpod.gitpod-remote-ssh",
17+
"ms-vsliveshare.vsliveshare",
18+
"redhat.vscode-yaml",
19+
"golang.go",
20+
"vscodevim.vim",
21+
"ms-vscode.makefile-tools"
22+
]
23+
}
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
$ErrorActionPreference = "Stop"
2+
trap { $host.SetShouldExit(1) }
3+
4+
echo "Work Directory: $pwd"
5+
$Env:ROOT="$pwd"
6+
7+
$null = New-Item -ItemType Directory -Force -Path $Env:TEMP
8+
9+
# TODO: consider migrating choco to winget https://github.com/microsoft/winget-cli as preferred MS solution
10+
if ((Get-Command "choco" -ErrorAction SilentlyContinue) -eq $null) {
11+
Set-ExecutionPolicy Bypass -Scope Process -Force
12+
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
13+
$tempvar = (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')
14+
iex ($tempvar)
15+
}
16+
17+
function Refresh-Choco-Env {
18+
Import-Module "C:\ProgramData\chocolatey\helpers\chocolateyProfile.psm1"
19+
refreshenv
20+
cd $Env:ROOT
21+
}
22+
23+
Refresh-Choco-Env
24+
25+
$Env:GOPATH="$Env:ROOT\go"
26+
27+
$Env:PATH="$Env:HOME\go\bin;" + "$Env:PATH"
28+
$Env:PATH="$Env:GOPATH\bin;" + "$Env:PATH"
29+
$Env:PATH="$Env:GOROOT\bin;" + "$Env:PATH"
30+
$Env:PATH="$pwd;" + "$Env:PATH"
31+
$Env:PATH="$pwd\cli\out;" + "$Env:PATH"
32+
33+
# This is for DEBUG
34+
# function Get-Env-Info {
35+
# echo "Powershell: $((Get-Host).Version)"
36+
# echo "Working Directory: $pwd"
37+
# echo "GOPATH: $Env:GOPATH"
38+
# echo "PATH:"
39+
# $Env:PATH.split(";")
40+
41+
# echo "-------------"
42+
43+
# Get-ChildItem Env: | Format-Table -Wrap -AutoSize
44+
# }
45+
46+
# Get-Env-Info
47+
48+
$Env:RUN_ID=(openssl rand -hex 16)
49+
$Env:GOFLAGS = "-mod=mod"
50+
51+
if ((Get-Command "ginkgo" -ErrorAction SilentlyContinue) -eq $null) {
52+
go install -v github.com/onsi/ginkgo/ginkgo@v1.16.4
53+
}
54+
55+
$CF_INT_NAME=(Get-Content $pwd\metadata.json -Raw| Out-String | ConvertFrom-Json).name.trim()
56+
$Env:CF_INT_PASSWORD=(Get-Content $pwd\cf-password -Raw).trim()
57+
$Env:CF_INT_OIDC_PASSWORD=(Get-Content $pwd\uaa-oidc-password -Raw).trim()
58+
$Env:CF_INT_OIDC_USERNAME="admin-oidc"
59+
$Env:CF_INT_API="https://api.$CF_INT_NAME.cf-app.com"
60+
$Env:CF_DIAL_TIMEOUT=15
61+
# Enable SSL vaildation once toolsmiths supports it
62+
# $Env:SKIP_SSL_VALIDATION="false"
63+
64+
Import-Certificate -Filepath "$pwd\$CF_INT_NAME.router.ca" -CertStoreLocation "cert:\LocalMachine\root"
65+
66+
New-Item "go/src/code.cloudfoundry.org" -Type Directory
67+
New-Item -ItemType SymbolicLink -Path "$pwd/go/src/code.cloudfoundry.org/cli" -Target "$pwd/cli"
68+
69+
cd go/src/code.cloudfoundry.org/cli
70+
71+
go install github.com/akavel/rsrc@v0.10.2
72+
73+
make out/cf-cli_winx64.exe
74+
Move-Item -Path ./out/cf-cli_winx64.exe -Destination ./out/cf.exe -Force
75+
76+
ginkgo.exe -r `
77+
-nodes=16 `
78+
-flakeAttempts=2 `
79+
-slowSpecThreshold=60 `
80+
-randomizeAllSpecs `
81+
./integration/shared/isolated `
82+
./integration/v7/isolated `
83+
./integration/shared/experimental `
84+
./integration/v7/experimental `
85+
./integration/v7/push
86+
87+
if ($LASTEXITCODE -gt 0)
88+
{
89+
exit 1
90+
}
91+
92+
ginkgo.exe -r `
93+
-flakeAttempts=2 `
94+
-slowSpecThreshold=60 `
95+
-randomizeAllSpecs `
96+
./integration/shared/global `
97+
./integration/v7/global
98+
99+
if ($LASTEXITCODE -gt 0)
100+
{
101+
exit 1
102+
}

.github/workflows/cf-env-setup.yml

+209
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
name: Setup CF Environment
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
capi-version:
10+
required: true
11+
type: string
12+
outputs:
13+
environment-name:
14+
description: "Name of claimed environment"
15+
value: ${{ jobs.cf-env-setup.outputs.environment-name }}
16+
17+
jobs:
18+
cf-env-setup:
19+
name: Setting Up CF env
20+
runs-on: ubuntu-latest
21+
environment: ${{ inputs.environment }}
22+
outputs:
23+
environment-name: ${{ steps.claim-toolsmiths-env.outputs.environment-name }}
24+
steps:
25+
- id: claim-toolsmiths-env
26+
name: Claim Toolsmiths Environment
27+
env:
28+
api_token: ${{ secrets.TOOLSMITHS_API_TOKEN }}
29+
hostname: ${{ secrets.TOOLSMITHS_HOSTNAME }}
30+
notes: CF CLI Github Actions Integration Tests
31+
pool_name: cf-deployment
32+
run: |
33+
while true; do
34+
curl -s --show-error -D >(tee headers.txt >&2) -H 'Accept: application/json' \
35+
-X POST "https://${hostname}/pooled_gcp_engineering_environments/claim" \
36+
--data-urlencode "api_token=${api_token}" \
37+
--data-urlencode "pool_name=${pool_name}" \
38+
--data-urlencode "notes=${notes}" > metadata.json \
39+
|| echo "Unable to reach server, trying again in 30 seconds..."
40+
41+
ERR_500="Sorry, the Toolsmiths Environments app is currently encountering issues. Trying again in 30 seconds..."
42+
ERR_429="Sorry, Toolsmiths are out of environments in your requested pool. New environments are on their way but you can stop by the Toolsmiths slack channel for more help."
43+
ERR_409="Sorry, was not able to claim an environment. Trying again in 30 seconds..."
44+
45+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 401" headers.txt && exit 1
46+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 404" headers.txt && exit 2
47+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 500" headers.txt && echo "$ERR_500"
48+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 200" headers.txt && break
49+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 429" && echo "$ERR_429"
50+
grep -q -E "HTTP/[[:digit:]\.]{1,3} 409" && echo "$ERR_409"
51+
52+
sleep 30
53+
done
54+
55+
ENV=$(cat metadata.json | jq -r '.name')
56+
echo "environment-name=${ENV}" >> $GITHUB_OUTPUT
57+
58+
- name: 'Upload Metadata'
59+
uses: actions/upload-artifact@v3
60+
with:
61+
name: ${{ steps.claim-toolsmiths-env.outputs.environment-name }}
62+
path: metadata.json
63+
64+
- name: Checkout cli-ci
65+
uses: actions/checkout@v3
66+
with:
67+
repository: cloudfoundry/cli-ci
68+
path: cli-ci
69+
70+
- name: Checkout cf-deployment Min CAPI
71+
if: ${{ inputs.capi-version != 'edge' }}
72+
uses: actions/checkout@v3
73+
with:
74+
repository: cloudfoundry/cf-deployment
75+
path: cf-deployment
76+
ref: ${{ inputs.capi-version }}
77+
78+
- name: Checkout cf-deployment
79+
uses: actions/checkout@v3
80+
if: ${{ inputs.capi-version == 'edge' }}
81+
with:
82+
repository: cloudfoundry/cf-deployment
83+
path: cf-deployment
84+
85+
- name: Checkout CF deployment tasks
86+
uses: actions/checkout@v3
87+
with:
88+
repository: cloudfoundry/cf-deployment-concourse-tasks
89+
path: cf-deployment-concourse-tasks
90+
91+
- name: Checkout cli
92+
uses: actions/checkout@v3
93+
with:
94+
repository: cloudfoundry/cli
95+
path: cli
96+
ref: linux-min-capi-int-test
97+
98+
- name: Install Tools
99+
run: |
100+
wget https://github.com/cloudfoundry/bosh-bootloader/releases/download/v8.4.110/bbl-v8.4.110_linux_x86-64 -P /tmp
101+
mv /tmp/bbl-* /usr/local/bin/bbl
102+
chmod +x /usr/local/bin/bbl
103+
bbl --version
104+
105+
wget https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-7.0.1-linux-amd64 --output-document="/usr/local/bin/bosh"
106+
chmod +x /usr/local/bin/bosh
107+
bosh --version
108+
109+
- name: Deploy edge CAPI with Isolation Segment and OIDC Provider
110+
if: ${{ inputs.capi-version == 'edge' }}
111+
env:
112+
CF_INT_CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
113+
run: |
114+
# find latest capi
115+
FILENAME="$(aws s3 ls capi-releases --no-sign-request --recursive --region us-east-1 | sort | tail -n 1 | awk '{print $4}')"
116+
aws s3 cp s3://capi-releases/$FILENAME $FILENAME --no-sign-request --region us-east-1
117+
eval "$(bbl print-env --metadata-file metadata.json)"
118+
bosh upload-release --sha2 "$FILENAME"
119+
rm $FILENAME
120+
121+
# deploy
122+
bosh -d cf manifest > /tmp/manifest.yml
123+
bosh interpolate /tmp/manifest.yml \
124+
-o cf-deployment/operations/test/add-persistent-isolation-segment-diego-cell.yml \
125+
-o cli-ci/ci/infrastructure/operations/add-oidc-provider.yml \
126+
-o cli-ci/ci/infrastructure/operations/add-uaa-client-credentials.yml \
127+
-o cli-ci/ci/infrastructure/operations/use-latest-capi.yml \
128+
-v client-secret="${CF_INT_CLIENT_SECRET}" \
129+
> ./director.yml
130+
131+
bosh -d cf deploy director.yml -n
132+
echo "Deployed CAPI version:"
133+
bosh -d cf releases | grep capi
134+
135+
- name: Deploy MIN CAPI with Isolation Segment and OIDC Provider
136+
if: ${{ inputs.capi-version != 'edge' }}
137+
run: |
138+
# Creates vars files
139+
mkdir vars-files
140+
echo "cs = ${{ secrets.CLIENT_SECRET }}"
141+
cat << EOF > vars-files/vars.yml
142+
client-secret: ${{ secrets.CLIENT_SECRET }}
143+
EOF
144+
145+
# Copy Ops files
146+
mkdir ops-files
147+
cp cf-deployment/operations/scale-to-one-az.yml ops-files/
148+
cp cf-deployment/operations/test/add-persistent-isolation-segment-diego-cell.yml ops-files/
149+
cp cf-deployment/operations/use-compiled-releases.yml ops-files/
150+
cp cf-deployment/operations/use-internal-lookup-for-route-services.yml ops-files/
151+
cp cli-ci/ci/infrastructure/operations/add-dummy-windows-stack.yml ops-files/
152+
cp cli-ci/ci/infrastructure/operations/add-oidc-provider.yml ops-files/
153+
cp cli-ci/ci/infrastructure/operations/add-uaa-client-credentials.yml ops-files/
154+
cp cli-ci/ci/infrastructure/operations/add-uaa-client-cf-custom.yml ops-files/
155+
cp cli-ci/ci/infrastructure/operations/adjust-user-retry-attempts.yml ops-files/
156+
cp cli-ci/ci/infrastructure/operations/cli-isolation-cell-overrides.yml ops-files/
157+
cp cli-ci/ci/infrastructure/operations/default-app-memory.yml ops-files/
158+
cp cli-ci/ci/infrastructure/operations/diego-cell-instances.yml ops-files/
159+
cp cli-ci/ci/infrastructure/operations/doppler-instances.yml ops-files/
160+
cp cli-ci/ci/infrastructure/operations/enable-v3-deployments-endpoint.yml ops-files/
161+
cp cli-ci/ci/infrastructure/operations/give-cf-admin-clients-read-scope.yml ops-files/
162+
cp cli-ci/ci/infrastructure/operations/reduce-async-service-polling.yml ops-files/
163+
cp cli-ci/ci/infrastructure/operations/skip-ssl-override.yml ops-files/
164+
cp cli-ci/ci/infrastructure/operations/uaa-vm_type-override.yml ops-files/
165+
# Deletes CF-D
166+
eval "$(bbl print-env --metadata-file metadata.json)"
167+
bosh -d cf delete-deployment -n
168+
169+
# Deploy CF-D
170+
mkdir toolsmiths-env
171+
cp metadata.json toolsmiths-env/metadata
172+
cat metadata.json | jq -r .name > toolsmiths-env/name
173+
export VARS_FILES="vars.yml"
174+
export MANIFEST_FILE="cf-deployment.yml"
175+
export SYSTEM_DOMAIN=""
176+
export REGENERATE_CREDENTIALS=false
177+
export DEPLOY_WITH_UPTIME_MEASUREMENTS=false
178+
export MEASURE_SYSLOG_AVAILABILITY=false
179+
export TCP_DOMAIN=""
180+
export AVAILABLE_PORT=""
181+
export FAIL_ON_DOWNTIME=false
182+
export APP_PUSHABILITY_THRESHOLD=0
183+
export HTTP_AVAILABILITY_THRESHOLD=0
184+
export RECENT_LOGS_THRESHOLD=0
185+
export STREAMING_LOGS_THRESHOLD=0
186+
export APP_SYSLOG_AVAILABILITY_THRESHOLD=0
187+
export USE_SINGLE_APP_INSTANCE=false
188+
export BOSH_DEPLOY_ARGS=""
189+
export BOSH_LITE=false
190+
export BBL_JSON_CONFIG=""
191+
export OPS_FILES="add-persistent-isolation-segment-diego-cell.yml \
192+
use-compiled-releases.yml \
193+
cli-isolation-cell-overrides.yml \
194+
default-app-memory.yml \
195+
skip-ssl-override.yml \
196+
scale-to-one-az.yml \
197+
diego-cell-instances.yml \
198+
doppler-instances.yml \
199+
uaa-vm_type-override.yml \
200+
add-uaa-client-credentials.yml \
201+
add-dummy-windows-stack.yml \
202+
reduce-async-service-polling.yml \
203+
add-oidc-provider.yml \
204+
adjust-user-retry-attempts.yml \
205+
enable-v3-deployments-endpoint.yml \
206+
give-cf-admin-clients-read-scope.yml \
207+
add-uaa-client-cf-custom.yml \
208+
use-internal-lookup-for-route-services.yml"
209+
./cf-deployment-concourse-tasks/bosh-deploy/task

.github/workflows/unclaim-cf-env.yml .github/workflows/cf-env-unclaim.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,26 @@ on:
66
environment:
77
required: true
88
type: string
9-
identifier-for-metadata-file:
9+
toolsmith-env-name:
1010
required: true
1111
type: string
1212

1313
jobs:
14-
build-env:
14+
cf-env-unclaim:
1515
runs-on: ubuntu-latest
1616
environment: ${{ inputs.environment }}
1717

1818
steps:
19-
- name: Download metadata
20-
uses: actions/download-artifact@v3
21-
with:
22-
name: ${{ inputs.identifier-for-metadata-file }}
23-
2419
- name: Unclaim environment
2520
env:
2621
api_token: ${{ secrets.TOOLSMITHS_API_TOKEN }}
2722
hostname: ${{ secrets.TOOLSMITHS_HOSTNAME }}
2823
run: |
29-
env_name=$(cat metadata.json | jq -r .name)
30-
3124
while true; do
3225
output=$(curl -s --show-error -D >(tee headers.txt >&2) -H 'Accept: application/json' \
3326
-X POST "https://${hostname}/pooled_gcp_engineering_environments/unclaim" \
3427
--data-urlencode "api_token=${api_token}" \
35-
--data-urlencode "name=${env_name}")
28+
--data-urlencode "name=${{ inputs.toolsmith-env-name }}")
3629
3730
ERR_500="Sorry, the Toolsmiths Environments app is currently encountering issues. Trying again in 30 seconds..."
3831

0 commit comments

Comments
 (0)