|
| 1 | +name: End-to-End Testing |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + types: [e2e-test] |
| 6 | + |
| 7 | +jobs: |
| 8 | + |
| 9 | + e2e-triggermesh: |
| 10 | + name: Test TriggerMesh components |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - uses: actions/checkout@v3 |
| 15 | + |
| 16 | + - name: Report e2e test start |
| 17 | + run: | |
| 18 | + curl \ |
| 19 | + -X POST \ |
| 20 | + -H "Accept: application/vnd.github+json" \ |
| 21 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 22 | + https://api.github.com/repos/triggermesh/triggermesh/statuses/${{ github.event.client_payload.commit_sha }} \ |
| 23 | + -d '{"state":"pending","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","context":"${{ github.workflow }}"}' |
| 24 | +
|
| 25 | + - name: Set up Go |
| 26 | + uses: actions/setup-go@v3 |
| 27 | + with: |
| 28 | + go-version: '1.19' |
| 29 | + |
| 30 | + - name: Go caches |
| 31 | + uses: actions/cache@v3 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.cache/go-build |
| 35 | + ~/go/pkg/mod |
| 36 | + key: ${{ github.job }}-${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} |
| 37 | + restore-keys: | |
| 38 | + ${{ github.job }}-${{ runner.os }}-go- |
| 39 | +
|
| 40 | + - name: KinD Cluster |
| 41 | + uses: container-tools/kind-action@v2 |
| 42 | + with: |
| 43 | + version: v0.13.0 |
| 44 | + knative_eventing: v1.4.0 |
| 45 | + knative_serving: v1.4.0 |
| 46 | + knative_kourier: v1.4.0 |
| 47 | + # ko loads images directly into KinD's container runtime when |
| 48 | + # KO_DOCKER_REPO is set to the rogue value "kind.local", so we have no |
| 49 | + # use for a container registry. |
| 50 | + registry: 'false' |
| 51 | + |
| 52 | + - name: Read KinD network subnet |
| 53 | + id: kind-subnet |
| 54 | + run: | |
| 55 | + kind_subnet_prefix="$(\ |
| 56 | + docker network inspect kind -f '{{ (index .IPAM.Config 0).Subnet }}' | cut -d'.' -f'1,2'\ |
| 57 | + )" |
| 58 | +
|
| 59 | + echo "Subnet prefix of 'kind' network: ${kind_subnet_prefix}" |
| 60 | + echo "::set-output name=prefix::${kind_subnet_prefix}" |
| 61 | +
|
| 62 | + - name: MetalLB load-balancer |
| 63 | + # Based on https://kind.sigs.k8s.io/docs/user/loadbalancer/ |
| 64 | + run: | |
| 65 | + kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/namespace.yaml |
| 66 | + kubectl create secret generic -n metallb-system memberlist --from-literal=secretkey="$(openssl rand -base64 128)" |
| 67 | + kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.12.1/manifests/metallb.yaml |
| 68 | + kubectl -n metallb-system wait --timeout=1m --for=condition=Available deployments.apps/controller |
| 69 | +
|
| 70 | + kubectl create -f - <<'EOM' |
| 71 | + apiVersion: v1 |
| 72 | + kind: ConfigMap |
| 73 | + metadata: |
| 74 | + namespace: metallb-system |
| 75 | + name: config |
| 76 | + data: |
| 77 | + config: | |
| 78 | + address-pools: |
| 79 | + - name: default |
| 80 | + protocol: layer2 |
| 81 | + addresses: |
| 82 | + - ${{ steps.kind-subnet.outputs.prefix }}.255.200-${{ steps.kind-subnet.outputs.prefix }}.255.250 |
| 83 | + EOM |
| 84 | +
|
| 85 | + - name: Knative default domain |
| 86 | + # Sets a magic default Knative domain that resolves to <gateway-ip>.sslip.io |
| 87 | + run: | |
| 88 | + kubectl create -f https://github.com/knative/serving/releases/download/knative-v1.0.0/serving-default-domain.yaml |
| 89 | + kubectl -n knative-serving wait --timeout=1m --for=condition=Complete jobs.batch/default-domain |
| 90 | +
|
| 91 | + - name: Deploy TriggerMesh |
| 92 | + run: | |
| 93 | + sed -i config/500-*.yaml \ |
| 94 | + -e "s|ko://github.com/triggermesh/triggermesh-event-sources-bundle/cmd/\(.*$\)|gcr.io/triggermesh/event-sources-bundle/\1:${{ github.event.client_payload.commit_sha }}|g" |
| 95 | +
|
| 96 | + kubectl apply -f config/ |
| 97 | +
|
| 98 | + kubectl -n triggermesh wait deployments.app --timeout=5m --for=condition=Available -l app.kubernetes.io/part-of=triggermesh |
| 99 | + kubectl -n knative-serving wait deployments.app --timeout=5m --for=condition=Available -l app.kubernetes.io/name=knative-serving |
| 100 | + kubectl -n knative-eventing wait deployments.app --timeout=5m --for=condition=Available -l app.kubernetes.io/name=knative-eventing |
| 101 | +
|
| 102 | + - name: Install Ginkgo |
| 103 | + run: go install github.com/onsi/ginkgo/v2/ginkgo |
| 104 | + |
| 105 | + - name: Export KUBECONFIG path |
| 106 | + run: echo "KUBECONFIG=${HOME}/.kube/config" >> $GITHUB_ENV |
| 107 | + |
| 108 | + # Allows tests to authenticate with Google Cloud using the Google Cloud SDK, |
| 109 | + # e.g. use 'gcloud' as a Git credential helper to interact with Google |
| 110 | + # Cloud Source Repositories. |
| 111 | + - name: Authenticate with Google Cloud |
| 112 | + uses: google-github-actions/auth@v1 |
| 113 | + with: |
| 114 | + credentials_json: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }} |
| 115 | + |
| 116 | + - name: Run e2e tests |
| 117 | + id: e2e |
| 118 | + env: |
| 119 | + AWS_REGION: ${{ secrets.AWS_REGION }} |
| 120 | + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 121 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 122 | + GCLOUD_SERVICEACCOUNT_KEY: ${{ secrets.GCLOUD_SERVICEACCOUNT_KEY }} |
| 123 | + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} |
| 124 | + AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} |
| 125 | + AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }} |
| 126 | + AZURE_CLIENT_SECRET: ${{ secrets.AZURE_CLIENT_SECRET }} |
| 127 | + run: ginkgo -procs=$(($(nproc)*2)) -randomize-all ./test/e2e/ |
| 128 | + |
| 129 | + - name: Report e2e test result |
| 130 | + if: always() |
| 131 | + run: | |
| 132 | + curl \ |
| 133 | + -X POST \ |
| 134 | + -H "Accept: application/vnd.github+json" \ |
| 135 | + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ |
| 136 | + https://api.github.com/repos/triggermesh/triggermesh/statuses/${{ github.event.client_payload.commit_sha }} \ |
| 137 | + -d '{"state":"${{ steps.e2e.outcome == 'success' && 'success' || 'failure' }}","target_url":"${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}","context":"${{ github.workflow }}"}' |
| 138 | +
|
| 139 | + # The KinD cluster can get shut down before all API objects created during |
| 140 | + # E2E tests have been terminated, which leaks cloud resources depending on |
| 141 | + # what test(s) are run last by Ginkgo. |
| 142 | + # To prevent that, we delay the completion of the job until all namespaces |
| 143 | + # labeled "e2e-framework" have been finalized. |
| 144 | + - name: Wait for termination of E2E namespaces |
| 145 | + if: always() && steps.e2e.outcome != 'skipped' |
| 146 | + run: | |
| 147 | + declare -i e2e_ns_count=-1 |
| 148 | +
|
| 149 | + # allow a grace period of max 300s (150*2s) |
| 150 | + for _ in $(seq 1 150); do |
| 151 | + e2e_ns_count="$(kubectl get ns -l e2e-framework -o jsonpath='{.items}' | jq '. | length')" |
| 152 | + if ! ((e2e_ns_count)); then |
| 153 | + break |
| 154 | + fi |
| 155 | +
|
| 156 | + echo -n '.' >&2 |
| 157 | + sleep 2 |
| 158 | + done |
| 159 | +
|
| 160 | + # flush stderr |
| 161 | + echo >&2 |
| 162 | +
|
| 163 | + # Final retrieval of E2E namespaces, gives us a chance to see whether |
| 164 | + # some of them were still Terminating after the grace period. |
| 165 | + kubectl get ns -l e2e-framework |
| 166 | +
|
| 167 | + - name: Collect logs |
| 168 | + id: logs |
| 169 | + if: failure() && steps.e2e.outcome == 'failure' |
| 170 | + run: | |
| 171 | + tmp_logs="$(mktemp -d)" |
| 172 | +
|
| 173 | + kubectl -n triggermesh logs --tail=-1 -l app=triggermesh-controller > "${tmp_logs}/triggermesh-controller.log" |
| 174 | +
|
| 175 | + kubectl -n knative-serving logs --tail=-1 -l app=controller > "${tmp_logs}/serving-controller.log" |
| 176 | + kubectl -n knative-serving logs --tail=-1 -l app=webhook > "${tmp_logs}/serving-webhook.log" |
| 177 | +
|
| 178 | + kubectl -n knative-eventing logs --tail=-1 -l app=eventing-controller > "${tmp_logs}/eventing-controller.log" |
| 179 | + kubectl -n knative-eventing logs --tail=-1 -l app=eventing-webhook > "${tmp_logs}/eventing-webhook.log" |
| 180 | +
|
| 181 | + echo "::set-output name=logs_dir::${tmp_logs}" |
| 182 | +
|
| 183 | + - name: Upload logs |
| 184 | + if: failure() && steps.logs.outputs.logs_dir |
| 185 | + uses: actions/upload-artifact@v3 |
| 186 | + with: |
| 187 | + name: logs |
| 188 | + path: ${{ steps.logs.outputs.logs_dir }} |
0 commit comments