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 [v8] #3243

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
110 changes: 14 additions & 96 deletions .github/workflows/tests-integration-reusable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@ 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}}
Expand All @@ -50,78 +47,41 @@ jobs:
ref: release-candidate
path: cf-acceptance-tests

- 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
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}"

- 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.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 @@ -134,50 +94,13 @@ jobs:
apt-get update
apt-get install -y build-essential unzip

- 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"

- 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
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\.//")
Expand Down Expand Up @@ -207,6 +130,7 @@ jobs:
"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",
Expand Down Expand Up @@ -237,6 +161,7 @@ jobs:
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
Expand Down Expand Up @@ -282,6 +207,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 @@ -312,20 +238,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
Loading
Loading