-
Notifications
You must be signed in to change notification settings - Fork 1
245 lines (200 loc) · 8.55 KB
/
Copy pathe2e.yml
File metadata and controls
245 lines (200 loc) · 8.55 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
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
name: E2E
on:
push:
branches: [main]
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: read
env:
CLUSTER_NAME: e2e
GATEWAY_API_VERSION: v1.5.1
CONTROLPLANE_IMAGE: ghcr.io/nantian-gw/nantian-controlplane:ci-${{ github.sha }}
jobs:
smoke:
name: Smoke
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Resolve dependency images
run: |
source scripts/ci/dependency-images.sh
{
echo "DATAPLANE_IMAGE=${DATAPLANE_IMAGE:-$DEFAULT_DATAPLANE_IMAGE}"
echo "DASHBOARD_IMAGE=${DASHBOARD_IMAGE:-$DEFAULT_DASHBOARD_IMAGE}"
} >>"${GITHUB_ENV}"
- name: Install Kind tooling
run: scripts/ci/install-kind-tools.sh
- name: Create kind cluster
run: scripts/ci/create-kind-cluster.sh
- name: Install Gateway API CRDs
run: scripts/ci/install-gateway-api-crds.sh
- name: Build current control-plane image
run: scripts/ci/build-controlplane-image.sh
- name: Load images into kind
run: scripts/ci/load-kind-images.sh
- name: Deploy Nantian Gateway
run: scripts/ci/deploy-kind-conformance.sh
- name: Record image versions
run: |
echo "=== Images under test ==="
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .spec.containers[] | " \(.name): \(.image)"'
echo "=== Image digests ==="
kubectl get pods -n nantian-gw -o json | jq -r '.items[] | .status.containerStatuses[] | " \(.name): \(.imageID)"'
- name: Run smoke test
run: CLUSTER_NAME="$CLUSTER_NAME" ./test/e2e/smoke/run.sh --no-cleanup
- name: Collect diagnostics on failure
if: failure()
run: ARTIFACT_DIR=tmp/e2e-diagnostics scripts/ci/collect-kind-diagnostics.sh
- name: Upload diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: e2e-diagnostics-smoke
path: tmp/e2e-diagnostics/
if-no-files-found: warn
- name: Cleanup
if: always()
run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "$CLUSTER_NAME" || true
scenarios:
name: Scenarios
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Resolve dependency images
run: |
source scripts/ci/dependency-images.sh
{
echo "DATAPLANE_IMAGE=${DATAPLANE_IMAGE:-$DEFAULT_DATAPLANE_IMAGE}"
echo "DASHBOARD_IMAGE=${DASHBOARD_IMAGE:-$DEFAULT_DASHBOARD_IMAGE}"
} >>"${GITHUB_ENV}"
- name: Install Kind tooling
run: scripts/ci/install-kind-tools.sh
- name: Create kind cluster
run: CLUSTER_NAME="${CLUSTER_NAME}-scenarios" scripts/ci/create-kind-cluster.sh
- name: Install Gateway API CRDs
run: scripts/ci/install-gateway-api-crds.sh
- name: Build current control-plane image
run: scripts/ci/build-controlplane-image.sh
- name: Build echo test image
run: |
cd test/e2e/backend/echo
docker build -t nantian-echo:latest .
- name: Load images into kind
run: CLUSTER_NAME="${CLUSTER_NAME}-scenarios" scripts/ci/load-kind-images.sh
- name: Load echo image into kind
run: kind load docker-image nantian-echo:latest --name "${CLUSTER_NAME}-scenarios"
- name: Deploy Nantian Gateway
run: CLUSTER_NAME="${CLUSTER_NAME}-scenarios" scripts/ci/deploy-kind-conformance.sh
- name: Run e2e scenarios
run: |
export CLUSTER_NAME="${CLUSTER_NAME}-scenarios"
export SKIP_SETUP=true
ECHO_IMAGE=nantian-echo:latest go test -tags=e2e -count=1 -v -timeout 30m ./test/e2e/...
- name: Collect diagnostics on failure
if: failure()
run: ARTIFACT_DIR=tmp/e2e-diagnostics CLUSTER_NAME="${CLUSTER_NAME}-scenarios" scripts/ci/collect-kind-diagnostics.sh
- name: Upload diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: e2e-diagnostics-scenarios
path: tmp/e2e-diagnostics/
if-no-files-found: warn
- name: Cleanup
if: always()
run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "${CLUSTER_NAME}-scenarios" || true
conformance:
name: Conformance
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
- name: Resolve dependency images
run: |
source scripts/ci/dependency-images.sh
{
echo "DATAPLANE_IMAGE=${DATAPLANE_IMAGE:-$DEFAULT_DATAPLANE_IMAGE}"
echo "DASHBOARD_IMAGE=${DASHBOARD_IMAGE:-$DEFAULT_DASHBOARD_IMAGE}"
} >>"${GITHUB_ENV}"
- name: Install Kind tooling
run: scripts/ci/install-kind-tools.sh
- name: Create kind cluster
run: CLUSTER_NAME="${CLUSTER_NAME}-conformance" scripts/ci/create-kind-cluster.sh
- name: Install Gateway API CRDs
run: scripts/ci/install-gateway-api-crds.sh
- name: Build current control-plane image
run: scripts/ci/build-controlplane-image.sh
- name: Load images into kind
run: CLUSTER_NAME="${CLUSTER_NAME}-conformance" scripts/ci/load-kind-images.sh
- name: Deploy Nantian Gateway
run: CLUSTER_NAME="${CLUSTER_NAME}-conformance" scripts/ci/deploy-kind-conformance.sh
- name: Create conformance GatewayClass
run: |
kubectl apply -f - <<'YAML'
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: gateway-conformance
spec:
controllerName: gateway.networking.k8s.io/nantian-gw
description: GatewayClass for Gateway API conformance tests
YAML
kubectl wait --for=condition=Accepted gatewayclass/gateway-conformance --timeout=30s || true
- name: Run conformance tests
run: |
go mod download sigs.k8s.io/gateway-api/conformance@v1.5.1
apply_file="$(go env GOMODCACHE)/sigs.k8s.io/gateway-api/conformance@v1.5.1/utils/kubernetes/apply.go"
chmod u+w "$apply_file"
python3 - "$apply_file" << 'PYEOF'
import sys
path = sys.argv[1]
content = open(path).read()
old = '\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion())\n\t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind())\n\t\terr = c.Update(ctx, uObj)'
new = '''\t\tuObj.SetResourceVersion(fetchedObj.GetResourceVersion())
\t\ttlog.Logf(t, "Updating %s %s", uObj.GetName(), uObj.GetKind())
\t\tfor i := 0; i < 5; i++ {
\t\t\tif i > 0 {
\t\t\t\ttime.Sleep(time.Duration(1<<i) * 100 * time.Millisecond)
\t\t\t\tlatest := &unstructured.Unstructured{}
\t\t\t\tlatest.SetGroupVersionKind(uObj.GroupVersionKind())
\t\t\t\tif getErr := c.Get(ctx, client.ObjectKeyFromObject(uObj), latest); getErr != nil {
\t\t\t\t\terr = getErr
\t\t\t\t\tbreak
\t\t\t\t}
\t\t\t\tuObj.SetResourceVersion(latest.GetResourceVersion())
\t\t\t}
\t\t\terr = c.Update(ctx, uObj)
\t\t\tif err == nil || !apierrors.IsConflict(err) {
\t\t\t\tbreak
\t\t\t}
\t\t}'''
content = content.replace(old, new)
# Add time import
content = content.replace(
'"testing"',
'"testing"\n\t"time"'
)
open(path, 'w').write(content)
print("Patched apply.go with conflict retry")
PYEOF
CLUSTER_NAME="${CLUSTER_NAME}-conformance" go test -tags=conformance -count=1 -v -timeout 30m ./conformance/
- name: Collect diagnostics on failure
if: failure()
run: ARTIFACT_DIR=tmp/e2e-diagnostics CLUSTER_NAME="${CLUSTER_NAME}-conformance" scripts/ci/collect-kind-diagnostics.sh
- name: Upload diagnostics
if: failure()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
with:
name: e2e-diagnostics-conformance
path: tmp/e2e-diagnostics/
if-no-files-found: warn
- name: Cleanup
if: always()
run: command -v kind >/dev/null 2>&1 && kind delete cluster --name "${CLUSTER_NAME}-conformance" || true