Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch test environments to cfd bosh lites [main] #3262

Merged
merged 29 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
97e120b
Switch environment to cfd-bosh-lite
a-b Oct 7, 2024
bdff0b2
Turn off set_kernel_parameters to use cfd-bosh-lite
a-b Oct 9, 2024
a60f401
Expose shepherd configuration via repo variables
a-b Oct 9, 2024
f882d5a
Update secrets path to bosh-lite
a-b Oct 15, 2024
cfbf7c3
Control test NODES via variables
a-b Oct 16, 2024
ca1c2f6
Expose TEST_FLAKE_ATTEMPTS and TEST_NODES
a-b Oct 16, 2024
e2357c6
Set default FLAKE_ATTEMPTS
a-b Oct 17, 2024
ba29308
Bump gha test suit timeout from 60 to 120m
a-b Oct 17, 2024
2d1bd7b
Enter nodes as workflow_dispatch input
a-b Oct 17, 2024
541c05d
Pass nodes parameter as a string
a-b Oct 17, 2024
097fd48
Skip steps if SHEPHERD_LEASE_ID defined
a-b Oct 18, 2024
6717156
Skip scaling tests that are testing CAPI
joaopapereira Oct 18, 2024
b2ce5d6
bosh-light environment default memory is 256Mb
joaopapereira Oct 21, 2024
c5fc522
Expose as parameters to automate make runs easier to configure
joaopapereira Oct 21, 2024
6fc60ab
Make options easier to understand
joaopapereira Oct 21, 2024
55049bd
units jobs needs to run always but steps could be conditional
joaopapereira Oct 21, 2024
825bce3
Fix boolean check
joaopapereira Oct 21, 2024
080bc10
Change order it gets the SHEPHERD_LEASE_ID from
joaopapereira Oct 22, 2024
7fa6f9f
Fixed the issue with force update of bosh
joaopapereira Oct 22, 2024
9ef4064
Delete created orgs during tests
joaopapereira Oct 23, 2024
44e31de
Ensure that the orgName is empty for each test
joaopapereira Oct 24, 2024
949cf6c
Prevent double deletion of org
joaopapereira Oct 24, 2024
5cda0eb
Lower number of tests running using client credentials to avoid flakes
joaopapereira Oct 24, 2024
4a16286
Allow user to define namespace of the leased environment
joaopapereira Oct 24, 2024
d3fcf31
Pass namespace of the lease to the reusable workflow
joaopapereira Oct 24, 2024
f39f3d7
Ignore act files
a-b Oct 25, 2024
21376fd
Clean vars
a-b Oct 25, 2024
c131c1c
Apply suggestions from code review
a-b Oct 28, 2024
604591a
Update number of nodes
a-b Oct 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/ops-files/diego-cell-instances.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
- type: replace
path: /instance_groups/name=diego-cell/instances
value: 4

- type: replace
path: /instance_groups/name=isolated-diego-cell/jobs/name=rep/properties?/set_kernel_parameters
value: false
56 changes: 33 additions & 23 deletions .github/workflows/tests-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# secrets.CLIENT_SECRET
# secrets.GITHUB_TOKEN
# secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
# vars.SHEPHERD_POOL_NAME
# vars.TEST_FLAKE_ATTEMPTS

name: "pvt: run integration tests"

Expand All @@ -22,17 +22,29 @@ on:
lease-id:
required: true
type: string
lease-namespace:
required: false
type: string
default: 'tas-devex'
gitRef:
type: string
default: ${{github.event.workflow_run.head_sha}}

nodes:
type: string
default: "12"

env:
NODES: ${{ inputs.nodes }}
FLAKE_ATTEMPTS: ${{ vars.TEST_FLAKE_ATTEMPTS || '2' }}
a-b marked this conversation as resolved.
Show resolved Hide resolved

jobs:
run-integration-tests:
defaults:
run:
shell: bash
runs-on: ${{ inputs.os }}
runs-on: ${{ inputs.os }}
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
timeout-minutes: 120
steps:
- name: Checkout cli
uses: actions/checkout@v4
Expand Down Expand Up @@ -61,7 +73,9 @@ jobs:

- name: Install Tools
env:
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
lease_namespace: ${{ inputs.lease-namespace }}
lease_id: ${{ inputs.lease-id }}
run: |
go version

Expand Down Expand Up @@ -95,23 +109,23 @@ jobs:
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
shepherd get lease ${lease_id} --namespace ${lease_namespace} --json | jq .output > metadata.json

- name: Add CATS config
if: ${{ inputs.name == 'cats' }}
run: |
set -eu

ENV=$(jq -r .name metadata.json)
env_name=$(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
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.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 -)
CF_INT_PASSWORD=$(credhub get -n /bosh-lite/cf/cf_admin_password | bosh interpolate --path /value -)

cat << EOF | jq -S . > cats_config.json
{
Expand Down Expand Up @@ -185,26 +199,24 @@ jobs:
--keep-going \
--randomize-all \
--skip-package=helpers \
--nodes="12" \
--flake-attempts=2 \
--nodes="${NODES}" \
--flake-attempts=${FLAKE_ATTEMPTS} \
--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
env_name=$(cat metadata.json | jq -r '.name')
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.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_PASSWORD="$(credhub get -n /bosh-lite/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 -)
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/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"
Expand All @@ -224,18 +236,16 @@ jobs:
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
env_name=$(cat metadata.json | jq -r '.name')
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.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_PASSWORD="$(credhub get -n /bosh-lite/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 -)
export CF_INT_OIDC_PASSWORD=$(credhub get -n /bosh-lite/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"
Expand All @@ -247,4 +257,4 @@ jobs:
cf api ${CF_INT_API} --skip-ssl-validation
cf auth

make integration-tests-full-ci
make integration-tests-ci-client-creds
105 changes: 90 additions & 15 deletions .github/workflows/tests-integration.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# GitHub repo level Secrets and Variables

# secrets.CLIENT_SECRET
# secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN
# vars.CAPI_RELEASE_VERSION
# vars.SHEPHERD_LEASE_NAMESPACE
# vars.SHEPHERD_POOL_DURATION
# vars.SHEPHERD_POOL_NAME
# vars.SHEPHERD_POOL_NAMESPACE

name: "Tests: Integration"

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 }}"
Expand All @@ -14,6 +24,30 @@ on:
- run-integration-tests-cf-env
- run-integration-tests-cf-env-with-client-creds
- run-cats-cf-env
nodes:
description: Number of test nodes
required: false
type: string
default: "12"
lease_id:
description: Pre-provisioned environment lease-id to use in tests
required: false
type: string
lease_namespace:
description: Pre-provisioned environment lease namespace to use in tests
required: false
type: string
run_unit_tests:
description: Run unit tests
required: false
type: boolean
default: true
reinstall_cfd:
description: Force re-installation of CFD
required: false
type: boolean
default: true

push:
tags:
- "v8.*"
Expand All @@ -31,7 +65,12 @@ on:
- ".grype.yaml"
- ".git*"
- ".golangci.json"

env:
SHEPHERD_LEASE_ID: ${{ inputs.lease_id }}

jobs:

get-sha:
runs-on: ubuntu-latest
outputs:
Expand All @@ -57,14 +96,17 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
if: ${{ inputs.run_unit_tests == 'true' }}
with:
ref: ${{needs.get-sha.outputs.gitRef}}
- name: Set Up Go
uses: actions/setup-go@v5
if: ${{ inputs.run_unit_tests == 'true' }}
with:
go-version-file: go.mod
check-latest: true
- name: Run Units
if: ${{ inputs.run_unit_tests == 'true' }}
run: make units

claim-env:
Expand All @@ -88,23 +130,45 @@ jobs:
- name: claim
id: claim
env:
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
pool_namespace: official
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
pool_name: ${{ vars.SHEPHERD_POOL_NAME }}
pool_duration: ${{ vars.SHEPHERD_POOL_DURATION || '8h' }}
pool_namespace: ${{ vars.SHEPHERD_POOL_NAMESPACE || 'official' }}
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
run: |
shepherd login service-account ${account_token}

echo "shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --description 'CLI GHA'"
lease_id=$(shepherd create lease --duration 8h --pool ${pool_name} --pool-namespace ${pool_namespace} --namespace tas-devex --json | jq -r .id)

if [[ -z $SHEPHERD_LEASE_ID ]]; then
lease_id=$( shepherd create lease \
--duration ${pool_duration} \
--pool ${pool_name} \
--pool-namespace ${pool_namespace} \
--namespace ${lease_namespace} \
--description "Claimed by CF CLI workflow ${{ github.workflow_run.url }}" \
--json \
| jq -r .id
)
else
lease_id=$SHEPHERD_LEASE_ID
fi

echo "Shepherd lease ID: ${lease_id}"

# Give sometime for the lease to complete. Shepherd may take upto an 3 hours to create an env
# if the pool is empty.
count=0
while [ $count -lt 360 ] ; do
sleep 30
status=$(shepherd get lease ${lease_id} --namespace tas-devex --json | jq -r .status)
status=$( shepherd get lease ${lease_id} \
--namespace ${lease_namespace} \
--json \
| jq -r .status
)
if [ $status == "LEASED" ] ; then
shepherd get lease ${lease_id} --namespace tas-devex --json | jq .output > metadata.json
shepherd get lease ${lease_id} \
--namespace ${lease_namespace} \
--json \
| jq .output > metadata.json
break
elif [ $status == "FAILED" -o $status == "EXPIRED" ] ; then
echo "There was an error obtaining the lease. Lease status is ${status}."
Expand All @@ -119,7 +183,7 @@ jobs:
echo "env name is ${env_name}"
echo "leaseid=${lease_id}" >> "${GITHUB_OUTPUT}"

cf_deployment_version=$(jq -r '."cf-deployment_version"' metadata.json)
cf_deployment_version=$(jq -r '."cf_deployment_version"' metadata.json)
echo "cf_deployment_version is ${cf_deployment_version}"
echo "cf_deployment_version=${cf_deployment_version}" >> "${GITHUB_OUTPUT}"

Expand All @@ -130,6 +194,7 @@ jobs:
check-latest: true

- name: Install Tools
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
run: |
go version

Expand All @@ -149,11 +214,11 @@ jobs:
apt-get install -y build-essential unzip

- name: Upload latest CAPI release
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
env:
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
run: |
if [ -z "$capi_release_version" ]
then
if [ -z "$capi_release_version" ]; then
capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name)
fi

Expand All @@ -166,19 +231,20 @@ jobs:
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"

- name: Checkout cf-deployment
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-deployment
path: cf-deployment
ref: ${{steps.claim.outputs.cf_deployment_version}}

- name: Deploy Isolation Segment and OIDC Provider
if: ${{ (inputs.lease_id == '') || (inputs.reinstall_cfd == true) }}
run: |
env_name=$(jq -r .name metadata.json)
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
eval "$(bbl print-env --metadata-file metadata.json)"

# deploy
bosh -d cf manifest > /tmp/manifest.yml
bosh interpolate /tmp/manifest.yml \
-o cf-deployment/operations/use-internal-lookup-for-route-services.yml \
Expand Down Expand Up @@ -208,6 +274,8 @@ jobs:
name: Integration
gitRef: ${{needs.get-sha.outputs.gitRef}}
lease-id: ${{ needs.claim-env.outputs.leaseid }}
lease-namespace: ${{ inputs.lease_namespace }}
nodes: ${{ inputs.nodes }}
secrets: inherit

run-integration-tests-cf-env-with-client-creds:
Expand All @@ -224,6 +292,8 @@ jobs:
name: Integration client creds
gitRef: ${{needs.get-sha.outputs.gitRef}}
lease-id: ${{ needs.claim-env.outputs.leaseid }}
lease-namespace: ${{ inputs.lease_namespace }}
a-b marked this conversation as resolved.
Show resolved Hide resolved
nodes: ${{ inputs.nodes }}
secrets: inherit

run-cats-cf-env:
Expand All @@ -241,21 +311,26 @@ jobs:
name: cats
gitRef: ${{needs.get-sha.outputs.gitRef}}
lease-id: ${{ needs.claim-env.outputs.leaseid }}
lease-namespace: ${{ inputs.lease_namespace }}
a-b marked this conversation as resolved.
Show resolved Hide resolved
nodes: ${{ inputs.nodes }}
secrets: inherit

unclaim-env:
name: Unclaim environment
if: ${{ inputs.lease_id == '' }}
runs-on: ubuntu-latest
container: us-west2-docker.pkg.dev/shepherd-268822/shepherd2/concourse-resource:latest
needs:
- claim-env
- run-cats-cf-env
if: always()
steps:
- name: unclaim
env:
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
lease_namespace: ${{ inputs.lease_namespace || vars.SHEPHERD_LEASE_NAMESPACE || 'tas-devex' }}
run: |
shepherd login service-account ${account_token}
set -x
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} --namespace tas-devex
shepherd delete lease ${{ needs.claim-env.outputs.leaseid }} \
--namespace ${lease_namespace}

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,5 @@ integration/assets/test_plugin/test_plugin

### VisualStudioCode ###
.vscode
.secrets
.vars
Loading
Loading