This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
249 lines (208 loc) · 9.71 KB
/
kind-e2e.yaml
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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
name: KinD e2e tests
on:
pull_request:
branches: [ 'main' ]
defaults:
run:
shell: bash
working-directory: ./src/knative.dev/eventing-kafka
jobs:
e2e-tests:
name: e2e tests
runs-on: ubuntu-latest
strategy:
fail-fast: false # Keep running if one leg fails.
matrix:
k8s-version:
- v1.17.11
- v1.18.8
- v1.19.1
test-suite:
- ./test/e2e
# TODO(https://github.com/knative/eventing/issues/4275): Enable this.
# - ./test/conformance
# Map between K8s and KinD versions.
# This is attempting to make it a bit clearer what's being tested.
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.9.0
include:
- k8s-version: v1.17.11
kind-version: v0.9.0
kind-image-sha: sha256:5240a7a2c34bf241afb54ac05669f8a46661912eab05705d660971eeb12f6555
- k8s-version: v1.18.8
kind-version: v0.9.0
kind-image-sha: sha256:f4bcc97a0ad6e7abaf3f643d890add7efe6ee4ab90baeb374b4f41a4c95567eb
- k8s-version: v1.19.1
kind-version: v0.9.0
kind-image-sha: sha256:98cf5288864662e37115e362b23e4369c8c4a408f99cbc06e58ac30ddc721600
# Add the flags we use for each of these test suites.
- test-suite: ./test/e2e
extra-test-flags: -channels=messaging.knative.dev/v1alpha1:KafkaChannel,messaging.knative.dev/v1beta1:KafkaChannel
# TODO(https://github.com/knative/eventing/issues/4275): Enable this.
# - test-suite: ./test/conformance
# extra-test-flags: -brokers=eventing.knative.dev/v1beta1:MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel,messaging.knative.dev/v1:Channel,messaging.knative.dev/v1:InMemoryChannel -sources=sources.knative.dev/v1beta1:ApiServerSource,sources.knative.dev/v1alpha2:ContainerSource,sources.knative.dev/v1beta1:PingSource
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: off
KO_DOCKER_REPO: kind.local
SYSTEM_NAMESPACE: knative-eventing
TEST_EVENTING_NAMESPACE: knative-eventing
# Use a semi-random cluster suffix, but somewhat predictable
# so reruns don't just give us a completely new value.
CLUSTER_SUFFIX: c${{ github.run_id }}.local
ARTIFACTS: ${{ github.workspace }}/artifacts
steps:
- name: Set up Go 1.18.x
uses: actions/setup-go@v2
with:
go-version: 1.18.x
- name: Install Dependencies
working-directory: ./
run: |
echo '::group:: install ko'
curl -L https://github.com/google/ko/releases/download/v0.7.0/ko_0.7.0_Linux_x86_64.tar.gz | tar xzf - ko
chmod +x ./ko
sudo mv ko /usr/local/bin
echo '::endgroup::'
- name: Check out code onto GOPATH
uses: actions/checkout@v2
with:
path: ./src/knative.dev/eventing-kafka
- name: Install KinD
run: |
set -x
# Disable swap otherwise memory enforcement doesn't work
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600009955324200
sudo swapoff -a
sudo rm -f /swapfile
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/${{ matrix.kind-version }}/kind-$(uname)-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Configure KinD Cluster
working-directory: ./src/knative.dev/eventing-kafka
run: |
set -x
# KinD configuration.
cat > kind.yaml <<EOF
apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
# This is needed in order to support projected volumes with service account tokens.
# See: https://kubernetes.slack.com/archives/CEKK1KTN2/p1600268272383600
kubeadmConfigPatches:
- |
apiVersion: kubeadm.k8s.io/v1beta2
kind: ClusterConfiguration
metadata:
name: config
apiServer:
extraArgs:
"service-account-issuer": "kubernetes.default.svc"
"service-account-signing-key-file": "/etc/kubernetes/pki/sa.key"
networking:
dnsDomain: "${CLUSTER_SUFFIX}"
nodes:
- role: control-plane
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }}
- role: worker
image: kindest/node:${{ matrix.k8s-version }}@${{ matrix.kind-image-sha }}
EOF
- name: Create KinD Cluster
working-directory: ./src/knative.dev/eventing-kafka
run: |
set -x
kind create cluster --config kind.yaml
- name: Install Strimzi
run: |
strimzi_version=`curl https://github.com/strimzi/strimzi-kafka-operator/releases/latest | awk -F 'tag/' '{print $2}' | awk -F '"' '{print $1}' 2>/dev/null`
kubectl create namespace kafka
kubectl -n kafka apply --selector strimzi.io/crd-install=true -f https://github.com/strimzi/strimzi-kafka-operator/releases/download/${strimzi_version}/strimzi-cluster-operator-${strimzi_version}.yaml
curl -L "https://github.com/strimzi/strimzi-kafka-operator/releases/download/${strimzi_version}/strimzi-cluster-operator-${strimzi_version}.yaml" \
| sed 's/namespace: .*/namespace: kafka/' \
| kubectl -n kafka apply -f -
kubectl -n kafka apply -f "https://raw.githubusercontent.com/strimzi/strimzi-kafka-operator/${strimzi_version}/examples/kafka/kafka-persistent-single.yaml"
kubectl wait deployment --all --timeout=-1s --for=condition=Available -n kafka
- name: Install Knative
env:
SERVING_VERSION: v0.18.0
KOURIER_VERSION: v0.18.0
run: |
# Prerequisites
sudo pip install yq
# Serving
kubectl apply --filename https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-crds.yaml
sleep 5
curl -L -s https://github.com/knative/serving/releases/download/$SERVING_VERSION/serving-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
sleep 60
kubectl get pod -n knative-serving
# Kourier
kubectl apply --filename https://github.com/knative-extensions/net-kourier/releases/download/$KOURIER_VERSION/kourier.yaml
kubectl patch configmap/config-network \
--namespace knative-serving \
--type merge \
--patch '{"data":{"ingress.class":"kourier.ingress.networking.knative.dev"}}'
sleep 30
kubectl get pod -n kourier-system
# Eventing
kubectl apply --filename https://knative-nightly.storage.googleapis.com/eventing/latest/eventing-crds.yaml
sleep 5
curl -L -s https://knative-nightly.storage.googleapis.com/eventing/latest/eventing-core.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
# Eventing channels
curl -L -s https://knative-nightly.storage.googleapis.com/eventing/latest/in-memory-channel.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
# Eventing broker
curl -L -s https://knative-nightly.storage.googleapis.com/eventing/latest/mt-channel-broker.yaml | yq 'del(.spec.template.spec.containers[]?.resources)' -y | yq 'del(.metadata.annotations."knative.dev/example-checksum")' -y | kubectl apply -f -
sleep 30
kubectl get pod -n knative-eventing
kubectl get pod --all-namespaces
- name: Install Test Images
- name: Install Knative Eventing Kafka
run: |
set -o pipefail
sed -i 's/REPLACE_WITH_CLUSTER_URL/my-cluster-kafka-bootstrap.kafka:9092/' config/channel/consolidated/configmaps/kafka-config.yaml
# Build and Publish our containers to the docker daemon (including test assets)
export GO111MODULE=on
export GOFLAGS=-mod=vendor
ko apply --platform=all -P \
`# Install the Kafka Channel` \
-f config/channel/consolidated/ \
`# Install the Kafka Source` \
-f config/source
# Change the cluster domain to the correct one.
sed -i "s/svc\.cluster\.local/svc\.${CLUSTER_SUFFIX}/g" test/config/config-tracing.yaml
ko apply --platform=all -Pf test/config/
- name: Upload Test Images
run: |
# Build and Publish our test images to the docker daemon.
./test/upload-test-images.sh
- name: Wait for things to be up
run: |
kubectl wait pod --for=condition=Ready -n ${SYSTEM_NAMESPACE} -l '!job-name'
- name: Run e2e Tests
run: |
# Run the tests tagged as e2e on the KinD cluster.
go test -race -count=1 -parallel=12 -timeout=30m -tags=e2e \
${{ matrix.test-suite }} ${{ matrix.extra-test-flags }}
- name: Collect system diagnostics
if: ${{ failure() }}
run: |
kubectl -n${SYSTEM_NAMESPACE} get pods
echo '::group:: describe'
kubectl -n${SYSTEM_NAMESPACE} describe pods
echo '::endgroup::'
for x in $(kubectl get pods -n${SYSTEM_NAMESPACE} -oname); do
echo "::group:: describe $x"
kubectl -n${SYSTEM_NAMESPACE} describe $x
echo '::endgroup::'
echo "::group:: $x logs"
kubectl -n${SYSTEM_NAMESPACE} logs $x --all-containers
echo '::endgroup::'
done
- name: Dump Artifacts
if: ${{ failure() }}
run: |
if [[ -d ${{ env.ARTIFACTS }} ]]; then
cd ${{ env.ARTIFACTS }}
for x in $(find . -type f); do
echo "::group:: artifact $x"
cat $x
echo '::endgroup::'
done
fi