From 9eb0c4a7756517c6db2aae1fb7bf3a978a544684 Mon Sep 17 00:00:00 2001 From: Shwetha Gururaj Date: Mon, 15 Jul 2024 16:57:31 -0400 Subject: [PATCH] Add CATS job to integration tests [v8] (#3022) * Integrate CATS in Integration tests workflow * Use latest capi --- .../workflows/tests-integration-reusable.yml | 129 +++++++++++++++++- .github/workflows/tests-integration.yml | 64 ++++----- .../shared/isolated/error_handling_test.go | 2 +- 3 files changed, 155 insertions(+), 40 deletions(-) diff --git a/.github/workflows/tests-integration-reusable.yml b/.github/workflows/tests-integration-reusable.yml index cff651d035c..f48692c70eb 100644 --- a/.github/workflows/tests-integration-reusable.yml +++ b/.github/workflows/tests-integration-reusable.yml @@ -28,6 +28,7 @@ on: pool-namespace: type: string default: 'official' + jobs: run-integration-tests: defaults: @@ -47,6 +48,13 @@ jobs: repository: cloudfoundry/cli-ci path: cli-ci + - name: Checkout cf-acceptance-tests + uses: actions/checkout@v4 + with: + repository: cloudfoundry/cf-acceptance-tests + ref: release-candidate + path: cf-acceptance-tests + - id: read-min-capi name: Read MIN CAPI run: | @@ -109,8 +117,16 @@ jobs: 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 run: | + go version + if [[ ${{ inputs.os }} =~ "windows" ]] then install_location=/usr/bin @@ -138,7 +154,19 @@ jobs: credhub --version apt-get update - apt-get install -y build-essential + apt-get install -y build-essential unzip + + - name: Upload latest CAPI release + if: ${{ inputs.capi-version == 'edge' }} + run: | + capi_release_version=$(curl -s https://api.github.com/repos/cloudfoundry/capi-release/releases/latest | jq -r .tag_name) + 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 if: ${{ inputs.capi-version == 'edge' }} @@ -151,7 +179,9 @@ jobs: bosh -d cf manifest > /tmp/manifest.yml bosh interpolate /tmp/manifest.yml \ -o .github/ops-files/use-cflinuxfs3.yml \ + -o cf-deployment/operations/use-internal-lookup-for-route-services.yml \ -o cf-deployment/operations/add-persistent-isolation-segment-diego-cell.yml \ + -o cli-ci/ci/infrastructure/operations/use-latest-capi.yml \ -o cli-ci/ci/infrastructure/operations/add-oidc-provider.yml \ -o cli-ci/ci/infrastructure/operations/add-uaa-client-credentials.yml \ -o cli-ci/ci/infrastructure/operations/diego-cell-instances.yml \ @@ -184,14 +214,99 @@ jobs: 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 + - 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_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 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 }} + 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 diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index a19db18c1d2..0fdc9e4714c 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -17,9 +17,14 @@ on: options: - run-integration-tests-cf-env - run-integration-tests-cf-env-with-client-creds - - run-integration-tests-cf-env-with-min-capi - # - run-integration-windows - # - run-integration-windows-client-credentials + # - run-integration-tests-cf-env-with-min-capi + - run-cats-cf-env + workflow_run: + workflows: + - "Tests" + types: + - completed + jobs: run-integration-tests-cf-env: name: Integration tests @@ -43,37 +48,32 @@ jobs: name: Integration client creds secrets: inherit - run-integration-tests-cf-env-with-min-capi: - name: MIN CAPI - if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-min-capi' }} + # run-integration-tests-cf-env-with-min-capi: + # name: MIN CAPI + # if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-tests-cf-env-with-min-capi' }} + # uses: ./.github/workflows/tests-integration-reusable.yml + # with: + # capi-version: min + # run-with-client-creds: false + # os: ubuntu-latest + # name: Integration MIN CAPI + # pool-name: cfd_16_11_0 + # pool-namespace: tas-devex + # is-pr: ${{ github.event_name != 'workflow_dispatch' }} + # secrets: inherit + + run-cats-cf-env: + name: CATS + needs: + - run-integration-tests-cf-env + - run-integration-tests-cf-env-with-client-creds + if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-cats-cf-env' }} uses: ./.github/workflows/tests-integration-reusable.yml with: - capi-version: min + capi-version: edge run-with-client-creds: false os: ubuntu-latest - name: Integration MIN CAPI - pool-name: cfd_16_11_0 - pool-namespace: tas-devex + name: cats + is-pr: ${{ github.event_name != 'workflow_dispatch' }} secrets: inherit - - #run-integration-windows: - # name: Windows - # if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-windows' }} - # uses: ./.github/workflows/tests-integration-reusable.yml - # with: - # capi-version: edge - # run-with-client-creds: false - # os: windows-latest - # name: Integration windows - # secrets: inherit - - #run-integration-windows-client-credentials: - # name: Windows with client credentials - # if: ${{ inputs.workflow == 'all' || inputs.workflow == 'run-integration-windows-client-credentials' }} - # uses: ./.github/workflows/tests-integration-reusable.yml - # with: - # capi-version: edge - # run-with-client-creds: true - # os: windows-latest - # name: Integration windows client credentials - # secrets: inherit + \ No newline at end of file diff --git a/integration/shared/isolated/error_handling_test.go b/integration/shared/isolated/error_handling_test.go index 2926bc20ca3..d3721c32685 100644 --- a/integration/shared/isolated/error_handling_test.go +++ b/integration/shared/isolated/error_handling_test.go @@ -11,7 +11,7 @@ import ( var _ = Describe("curl command", func() { It("returns the expected request", func() { session := helpers.CF("curl", "/v2/banana") - Eventually(session).Should(Say(`"error_code": "CF-NotFound"`)) + Eventually(session).Should(Say(`"error_code":"CF-NotFound"`)) Eventually(session).Should(Exit(0)) })