|
5 | 5 | inputs: |
6 | 6 | java-versions: |
7 | 7 | description: 'JSON array of Java versions to test' |
| 8 | + type: string |
8 | 9 | required: false |
9 | 10 | default: '[8, 11, 17, 21]' |
| 11 | + preview: |
| 12 | + description: 'Deploy the latest cf-deployment versions instead of the default ones' |
| 13 | + type: boolean |
| 14 | + required: false |
| 15 | + default: false |
10 | 16 | schedule: |
| 17 | + # preview run: latest versions (including CAPI) on the latest JDK only |
11 | 18 | - cron: '0 3 * * 1-5' |
| 19 | + workflow_call: |
| 20 | + inputs: |
| 21 | + java-versions: |
| 22 | + description: 'JSON array of Java versions to test' |
| 23 | + type: string |
| 24 | + required: false |
| 25 | + default: '[8, 11, 17, 21]' |
| 26 | + preview: |
| 27 | + description: 'Deploy the latest cf-deployment versions instead of the default ones' |
| 28 | + type: boolean |
| 29 | + required: false |
| 30 | + default: false |
| 31 | + |
| 32 | +permissions: |
| 33 | + contents: read |
| 34 | + |
| 35 | +# A new push supersedes the running test. The group name differs from the caller's workflow name on |
| 36 | +# purpose: a called workflow shares github.workflow with its caller, which would cancel the caller. |
| 37 | +concurrency: |
| 38 | + group: integration-test-${{ github.event_name == 'schedule' && 'schedule' || github.ref }} |
| 39 | + cancel-in-progress: true |
| 40 | + |
| 41 | +env: |
| 42 | + CF_API_HOST: api.cf.127-0-0-1.nip.io |
| 43 | + CF_UAA_HOST: uaa.cf.127-0-0-1.nip.io |
12 | 44 |
|
13 | 45 | jobs: |
14 | 46 | integration-test: |
| 47 | + # the cron trigger also fires on forks, where nobody wants a nightly KinD run |
| 48 | + if: ${{ github.event_name != 'schedule' || github.repository == 'cloudfoundry/cf-java-client' }} |
15 | 49 | runs-on: ubuntu-latest |
16 | 50 | timeout-minutes: 120 |
17 | 51 | strategy: |
18 | 52 | fail-fast: false |
19 | 53 | matrix: |
20 | | - java: ${{ fromJSON(inputs.java-versions || '[8, 11, 17, 21]') }} |
21 | | - name: Java ${{ matrix.java }} integration test |
| 54 | + java: ${{ fromJSON(inputs.java-versions || (github.event_name == 'schedule' && '[21]' || '[8, 11, 17, 21]')) }} |
| 55 | + name: Java ${{ matrix.java }} integration test${{ (inputs.preview || github.event_name == 'schedule') && ' (preview)' || '' }} |
22 | 56 | steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - - name: Prepare multi-module build |
25 | | - run: git submodule update --init --recursive |
| 57 | + - uses: actions/checkout@v7 |
| 58 | + with: |
| 59 | + submodules: recursive |
| 60 | + # Validation runs deploy the capi-release that matches SUPPORTED_API_VERSION. Preview runs |
| 61 | + # (scheduled, or started by hand with `preview`) keep the latest versions. |
| 62 | + - name: Resolve CAPI version |
| 63 | + id: capi |
| 64 | + if: ${{ !(inputs.preview || github.event_name == 'schedule') }} |
| 65 | + run: | |
| 66 | + # separate assignment, so that a failing resolver fails the step |
| 67 | + version="$(.github/scripts/resolve-capi-version.sh)" |
| 68 | + echo "version=$version" >> "$GITHUB_OUTPUT" |
| 69 | + # Overrides the capi chart version of kind-deployment (merged last by Helmfile). |
| 70 | + # kind-deployment's helmfile passes cloudController.appDomains, which the capi chart only |
| 71 | + # accepts from 1.241.0 on (1.240.0 fails its values schema), so older matches are raised to it. |
| 72 | + - name: Write CAPI values override |
| 73 | + id: values |
| 74 | + if: ${{ steps.capi.outputs.version != '' }} |
| 75 | + env: |
| 76 | + MIN_CAPI_VERSION: 1.241.0 |
| 77 | + MATCHED_CAPI_VERSION: ${{ steps.capi.outputs.version }} |
| 78 | + run: | |
| 79 | + version="$(printf '%s\n%s\n' "$MIN_CAPI_VERSION" "$MATCHED_CAPI_VERSION" | sort -V | tail -1)" |
| 80 | + if [ "$version" != "$MATCHED_CAPI_VERSION" ]; then |
| 81 | + echo "::warning::capi-release $MATCHED_CAPI_VERSION matches SUPPORTED_API_VERSION but is too old for kind-deployment, deploying $version" |
| 82 | + fi |
| 83 | + cat > "$RUNNER_TEMP/capi-values.yaml" <<EOF |
| 84 | + charts: |
| 85 | + capi: |
| 86 | + version: $version |
| 87 | + EOF |
| 88 | + echo "file=$RUNNER_TEMP/capi-values.yaml" >> "$GITHUB_OUTPUT" |
26 | 89 | # Every job gets its own Cloud Foundry on KinD, so the matrix can run in parallel. |
| 90 | + # The action deploys the kind-deployment ref given in `ref`, so keep both on the same commit. |
27 | 91 | - name: Set up Cloud Foundry |
28 | | - uses: cloudfoundry/kind-deployment/.github/actions/setup-cf@main |
| 92 | + uses: cloudfoundry/kind-deployment/.github/actions/setup-cf@8eff1a34c730d89d3c90044695cbcaba048ec68d |
29 | 93 | with: |
30 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + ref: 8eff1a34c730d89d3c90044695cbcaba048ec68d |
| 95 | + use-latest-versions: ${{ (inputs.preview || github.event_name == 'schedule') }} |
| 96 | + github-token: ${{ github.token }} |
| 97 | + additional-values-files: ${{ steps.values.outputs.file }} |
| 98 | + # Workaround: all Cloud Foundry components share one Postgres with the default max_connections |
| 99 | + # (100). Over a full test run it runs out ("too many clients already") and UAA, which every |
| 100 | + # Spring test context needs, stops working. kind-deployment doesn't expose the setting, and |
| 101 | + # it only takes effect after a restart. |
| 102 | + - name: Raise Postgres connection limit |
| 103 | + timeout-minutes: 20 |
| 104 | + run: | |
| 105 | + .github/scripts/pg-psql.sh -c "ALTER SYSTEM SET max_connections = 500" |
| 106 | + kubectl -n cf-system rollout restart statefulset/postgresql |
| 107 | + kubectl -n cf-system rollout status statefulset/postgresql --timeout=300s |
| 108 | + .github/scripts/pg-psql.sh -tc "SHOW max_connections" |
| 109 | + # The restart leaves the components with dead pooled connections (the cloud controller |
| 110 | + # answers one 500 per stale connection and does not validate them), and some of them |
| 111 | + # crash-loop for a while. Restart them all so they reconnect, wait for the rollouts and check |
| 112 | + # that the platform answers before the tests start. |
| 113 | + kubectl -n cf-system rollout restart deployment |
| 114 | + for deployment in $(kubectl -n cf-system get deployment -o name); do |
| 115 | + kubectl -n cf-system rollout status "$deployment" --timeout=600s |
| 116 | + done |
| 117 | + for url in "https://$CF_API_HOST/v3/info" "https://$CF_UAA_HOST/info"; do |
| 118 | + curl --silent --show-error --fail --insecure --output /dev/null \ |
| 119 | + --retry 60 --retry-delay 10 --retry-all-errors "$url" |
| 120 | + done |
31 | 121 | - name: Set up Java |
32 | | - uses: actions/setup-java@v3 |
| 122 | + uses: actions/setup-java@v5 |
33 | 123 | with: |
34 | 124 | distribution: liberica |
35 | 125 | java-version: ${{ matrix.java }} |
36 | 126 | - name: Cache Maven packages |
37 | | - uses: actions/cache@v3 |
| 127 | + uses: actions/cache@v6 |
38 | 128 | with: |
39 | 129 | path: ~/.m2 |
40 | 130 | key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
41 | 131 | restore-keys: ${{ runner.os }}-m2 |
42 | 132 | - name: Run integration tests |
43 | 133 | # CC_ADMIN_PASSWORD and UAA_ADMIN_SECRET are exported by setup-cf |
44 | 134 | env: |
45 | | - TEST_APIHOST: api.cf.127-0-0-1.nip.io |
| 135 | + TEST_APIHOST: ${{ env.CF_API_HOST }} |
46 | 136 | TEST_ADMIN_USERNAME: ccadmin |
47 | 137 | TEST_ADMIN_PASSWORD: ${{ env.CC_ADMIN_PASSWORD }} |
48 | 138 | TEST_ADMIN_CLIENTID: admin |
49 | 139 | TEST_ADMIN_CLIENTSECRET: ${{ env.UAA_ADMIN_SECRET }} |
50 | 140 | TEST_SKIPSSLVALIDATION: 'true' |
51 | 141 | TEST_QUOTAS_ROUTES_RESERVEDPORTS: '50' |
| 142 | + # kind-deployment has no metric registrar, which the log-cache metric tests need |
| 143 | + TEST_SKIP_METRIC_REGISTRAR: 'true' |
52 | 144 | run: ./mvnw -B -Pintegration-test test -Dgpg.skip |
| 145 | + # Failures like the UAA browser flows, log-cache or Docker pushes depend on the KinD setup, so |
| 146 | + # print what the cluster says about them. |
| 147 | + - name: Dump Cloud Foundry diagnostics |
| 148 | + if: ${{ failure() || cancelled() }} |
| 149 | + run: | |
| 150 | + echo "::group::postgres connections" |
| 151 | + .github/scripts/pg-psql.sh -c "SHOW max_connections" \ |
| 152 | + -c "SELECT datname, usename, application_name, state, count(*) FROM pg_stat_activity GROUP BY 1,2,3,4 ORDER BY 5 DESC" || true |
| 153 | + echo "::endgroup::" |
| 154 | + kubectl get pods -A -o wide || true |
| 155 | + kubectl get events -A --sort-by=.lastTimestamp | tail -n 100 || true |
| 156 | + echo "::group::describe workload pods" |
| 157 | + kubectl -n cf-workloads describe pods || true |
| 158 | + echo "::endgroup::" |
| 159 | + for pod in $(kubectl -n cf-system get pods -o name | grep -E 'uaa|capi|cloud-controller|log-cache|loggregator|rep|diego|gorouter|metric' || true); do |
| 160 | + echo "::group::logs $pod" |
| 161 | + kubectl -n cf-system logs "$pod" --all-containers --tail=1000 || true |
| 162 | + echo "::endgroup::" |
| 163 | + done |
| 164 | + echo "::group::workload pod logs" |
| 165 | + kubectl -n cf-workloads logs --all-containers --tail=200 --prefix -l '!nonexistent' --ignore-errors || true |
| 166 | + echo "::endgroup::" |
0 commit comments