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