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

Use one environment to run int tests [v7] #3244

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
2 changes: 1 addition & 1 deletion .github/ops-files/diego-cell-instances.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---
- type: replace
path: /instance_groups/name=diego-cell/instances
value: 3
value: 4
142 changes: 20 additions & 122 deletions .github/workflows/tests-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,13 @@ on:
name:
required: true
type: string
pool-name:
type: string
default: ${{ vars.SHEPHERD_POOL_NAME }}
pool-namespace:
lease-id:
required: true
type: string
default: 'official'
gitRef:
type: string
default: ${{github.event.workflow_run.head_sha}}

gururajsh marked this conversation as resolved.
Show resolved Hide resolved
jobs:
run-integration-tests:
defaults:
Expand All @@ -42,92 +39,41 @@ jobs:
with:
ref: ${{inputs.gitRef}}

- name: Checkout cli-ci
uses: actions/checkout@v4
with:
repository: cloudfoundry/cli-ci
path: cli-ci

- id: read-min-capi
name: Read MIN CAPI
run: |
wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq &&\
chmod +x /usr/bin/yq
version=$(yq '.capi-version-min' build_data.yml)
echo "version=$version" >> $GITHUB_OUTPUT

- name: Checkout cf-deployment Min CAPI
if: ${{ inputs.capi-version != 'edge' }}
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-deployment
path: cf-deployment
ref: ${{ steps.read-min-capi.outputs.version }}

- name: Checkout cf-deployment
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-deployment
path: cf-deployment

- name: Checkout CF deployment tasks
uses: actions/checkout@v4
with:
repository: cloudfoundry/cf-deployment-concourse-tasks
path: cf-deployment-concourse-tasks

- id: claim-env
name: Claim Environment
- 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 }}
pool_name: ${{ inputs.pool-name }}
pool_namespace: ${{ inputs.pool-namespace }}
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)
# 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)
if [ $status == "LEASED" ] ; then
shepherd get lease ${lease_id} --namespace tas-devex --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}."
exit 1
else
echo "Waiting for environment to be ready. Lease status is ${status}."
fi
count=$(($count+1))
done

env_name=$(jq -r .name metadata.json)
cat metadata.json | jq -r '.name'
echo "lease-id=$lease_id" >> "${GITHUB_OUTPUT}"
go version

- name: Install Tools
run: |
if [[ ${{ inputs.os }} =~ "windows" ]]
then
install_location=/usr/bin
bbl_artifact=bbl-v8.4.110_windows.exe
bosh_cli_artifact=bosh-cli-7.0.1-windows-amd64.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.0.1-linux-amd64
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://s3.amazonaws.com/bosh-cli-artifacts/$bosh_cli_artifact --silent --output $install_location/bosh --location
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

Expand All @@ -138,51 +84,10 @@ jobs:
credhub --version

apt-get update
apt-get install -y build-essential

- name: Upload latest CAPI release
env:
capi_release_version: ${{ vars.CAPI_RELEASE_VERSION }}
run: |
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

echo "Latest CAPI release is $capi_release_version"

eval "$(bbl print-env --metadata-file metadata.json)"
env_name=$(jq -r .name metadata.json)
jq -r .bosh.jumpbox_private_key metadata.json > /tmp/${env_name}.priv
bosh upload-release "https://bosh.io/d/github.com/cloudfoundry/capi-release?v=$capi_release_version"
apt-get install -y build-essential unzip

- name: Deploy Isolation Segment and OIDC Provider
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 \
-o cf-deployment/operations/add-persistent-isolation-segment-diego-cell.yml \
-o .github/ops-files/use-latest-capi.yml \
-o .github/ops-files/add-oidc-provider.yml \
-o .github/ops-files/add-uaa-client-credentials.yml \
-o .github/ops-files/diego-cell-instances.yml \
-v client-secret="${{ secrets.CLIENT_SECRET }}" \
> ./director.yml

bosh -d cf deploy director.yml -n
echo "Deployed CAPI version:"
bosh -d cf releases | grep capi

- name: Set Up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
check-latest: true
shepherd login service-account ${account_token}
shepherd get lease ${{ inputs.lease-id }} --namespace tas-devex --json | jq .output > metadata.json

- name: Run Integration Tests
if: ${{ !inputs.run-with-client-creds }}
Expand All @@ -202,6 +107,7 @@ jobs:
export GOPATH=$PWD/go
export PATH="$GOPATH/bin:$PATH"
export PATH="$PWD/out:$PATH"
export CF_INT_TEST_NAME="int"

make build

Expand Down Expand Up @@ -232,20 +138,12 @@ jobs:
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

- name: Unclaim environment
if: always()
env:
account_token: ${{ secrets.SHEPHERD_SERVICE_ACCOUNT_TOKEN }}
run: |
shepherd login service-account ${account_token}
set -x
shepherd delete lease ${{ steps.claim-env.outputs.lease-id }} --namespace tas-devex
make integration-tests-full-ci
gururajsh marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading