-
Notifications
You must be signed in to change notification settings - Fork 811
245 lines (230 loc) · 8.76 KB
/
e2e_test.yml
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
# This workflow defines the e2e test related jobs.
name: E2E Test
on:
workflow_dispatch: {}
pull_request:
branches:
- master
- release-*
permissions: read-all
jobs:
changed-files:
runs-on: ubuntu-20.04
outputs:
only_changed: ${{ steps.filter.outputs.only_changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Get changed files
uses: tj-actions/changed-files@v41
id: filter
with:
# Not available for frontend code for now.
files: |
.gitignore
**.md
ui/**
.github/workflows/checklink.yaml
.github/checklink_config.json
.github/workflows/ci.yml
.github/workflows/ci_skip.yml
.github/workflows/codecov_unittest.yaml
.github/workflows/integration_test.yml
.github/workflows/license_checker.yml
.github/workflows/must_update_changelog.yml
.github/workflows/release_helm_chart.yml
.github/workflows/upload_env_image.yml
.github/workflows/upload_image.yml
.github/workflows/upload_image_pr.yml
.github/workflows/upload_latest_files.yml
.github/workflows/upload_release_files.yml
- name: Show outputs
run: echo "${{ toJSON(steps.filter.outputs) }}"
build-image:
needs: changed-files
if: needs.changed-files.outputs.only_changed == 'false'
runs-on: ubuntu-20.04
steps:
- name: checkout codes
uses: actions/checkout@v4
- name: Build Chaos Mesh Build Env
if: ${{ github.event.pull_request }}
env:
IMAGE_BUILD_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-build-env-image') }}
run: |
if [ "${IMAGE_BUILD_ENV_BUILD}" = "true" ] ; then
export IMAGE_BUILD_ENV_BUILD=1;
else
export IMAGE_BUILD_ENV_BUILD=0;
fi
make image-build-env
- name: Build Chaos Mesh Dev Env
if: ${{ github.event.pull_request }}
env:
IMAGE_DEV_ENV_BUILD: ${{ contains(github.event.pull_request.labels.*.name, 'rebuild-dev-env-image') }}
run: |
if [ "${IMAGE_DEV_ENV_BUILD}" = "true" ] ; then
export IMAGE_DEV_ENV_BUILD=1;
else
export IMAGE_DEV_ENV_BUILD=0;
fi
make image-dev-env
# once the https://github.com/actions/cache/pull/498 gets merged,
# we can switch to the official cache action
- name: Restore build cache
id: cache
uses: martijnhols/actions-cache/restore@main
with:
path: cache
# don't worry about the branch, the github cache
# is only accessible in the same branch (or a pull_request
# whose target is the branch)
key: e2e-image-build-cache-${{ runner.os }}
- name: Build e2e images
env:
DOCKER_CACHE: 1
DOCKER_CACHE_DIR: ${{ github.workspace }}/cache
GO_BUILD_CACHE: ${{ github.workspace }}/cache
DOCKER_CLI_EXPERIMENTAL: enabled
run: |
docker buildx create --use --name chaos-mesh-builder
make -j4 image e2e-image
- name: save docker images
run: |
mkdir -p ./output/saved-images
docker image save ghcr.io/chaos-mesh/chaos-dashboard:latest > ./output/saved-images/chaos-dashboard.tgz
docker image save ghcr.io/chaos-mesh/chaos-daemon:latest > ./output/saved-images/chaos-daemon.tgz
docker image save ghcr.io/chaos-mesh/chaos-mesh:latest > ./output/saved-images/chaos-mesh.tgz
docker image save ghcr.io/chaos-mesh/e2e-helper:latest > ./output/saved-images/e2e-helper.tgz
- name: upload saved images
uses: actions/upload-artifact@v4
with:
name: saved-images
path: ./output/saved-images
retention-days: 7
build-e2e-binary:
needs: changed-files
if: needs.changed-files.outputs.only_changed == 'false'
runs-on: ubuntu-20.04
steps:
- name: checkout codes
uses: actions/checkout@v4
- name: Restore build cache
id: cache
uses: martijnhols/actions-cache/restore@main
with:
path: cache
key: e2e-binary-build-cache-${{ runner.os }}
- name: build e2e binary
env:
DOCKER_CACHE: 1
DOCKER_CACHE_DIR: ${{ github.workspace }}/cache
GO_BUILD_CACHE: ${{ github.workspace }}/cache
run: |
make e2e-build
- name: upload e2e binary
uses: actions/upload-artifact@v4
with:
name: e2e-binary
path: ./e2e-test/image/e2e/bin
retention-days: 7
e2e-test-matrix:
needs:
- build-image
- build-e2e-binary
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
kubernetes-version:
- v1.26.13
- v1.27.10
- v1.28.6
focus:
- "[Graceful-Shutdown] [IOChaos]"
- "[Graceful-Shutdown] [HTTPChaos]"
- "[Basic] [PodChaos]"
- "[Basic] [TimeChaos]"
- "[Basic] [IOChaos]"
- "[Basic] [HTTPChaos]"
- "[Basic] [Sidecar Config]"
- "[Basic] [NetworkChaos]"
- "[Basic] [DNSChaos]"
- "[Basic] [StressChaos]"
steps:
- name: checkout codes
uses: actions/checkout@v4
- name: download saved images
uses: actions/download-artifact@v4
with:
name: saved-images
path: ./output/saved-images
- name: download e2e binary
uses: actions/download-artifact@v4
with:
name: e2e-binary
path: ./output/e2e-binary
- name: move e2e binary
run: |
mkdir -p ./e2e-test/image/e2e/bin
mv ./output/e2e-binary/ginkgo ./e2e-test/image/e2e/bin/ginkgo
mv ./output/e2e-binary/e2e.test ./e2e-test/image/e2e/bin/e2e.test
chmod +x ./e2e-test/image/e2e/bin/ginkgo
chmod +x ./e2e-test/image/e2e/bin/e2e.test
- name: Setup minikube
uses: medyagh/setup-minikube@latest
with:
minikube-version: 1.32.0
kubernetes-version: ${{ matrix.kubernetes-version }}
- name: load image into minikube
run: |
minikube image load ./output/saved-images/chaos-dashboard.tgz
minikube image load ./output/saved-images/chaos-daemon.tgz
minikube image load ./output/saved-images/chaos-mesh.tgz
minikube image load ./output/saved-images/e2e-helper.tgz
- name: Restrict access to kubeconfig # https://github.com/helm/helm/issues/9115
run: chmod 600 ~/.kube/config
- name: Setup Helm
uses: azure/setup-helm@v3
- name: Install Chaos Mesh
# Set DOCKER_API_VERSION to 1.41 to bypass https://github.com/chaos-mesh/chaos-mesh/pull/4154#issuecomment-1704442551.
run: |
helm install --wait --create-namespace chaos-mesh helm/chaos-mesh --namespace=chaos-mesh --set images.tag=latest --set chaosDaemon.env.DOCKER_API_VERSION=1.41
- name: e2e tests
env:
FOCUS: ${{ matrix.focus }}
run: |
# because ginkgo -focus accepts the regex expression, we should use escape to represent the squared brackets and dash
export ESCAPED_FOCUS=$(echo $FOCUS | sed -e 's/\[/\\\[/g' | sed -e 's/\]/\\\]/g' | sed -e 's/\-/\\\-/g')
KUBECONFIG=~/.kube/config ./e2e-test/image/e2e/bin/ginkgo -focus="${ESCAPED_FOCUS}" ./e2e-test/image/e2e/bin/e2e.test -- --e2e-image ghcr.io/chaos-mesh/e2e-helper:latest
- name: post run - extract profile info from kubernetes
if: always()
env:
PROFILE_DIRECTORY: ./output/chaos-mesh-profile
run: |
kubectl cluster-info dump --all-namespaces --output-directory $PROFILE_DIRECTORY/manifests -o yaml
kubectl get endpoints -A -o yaml > $PROFILE_DIRECTORY/manifests/endpoints.yaml
kubectl get secrets -A -o yaml > $PROFILE_DIRECTORY/manifests/secrets.yaml
kubectl get configmaps -A -o yaml > $PROFILE_DIRECTORY/manifests/configmaps.yaml
- name: post run - upload Chaos Mesh profile info
if: always()
uses: actions/upload-artifact@v4
with:
name: profiling-${{ matrix.focus }}-k8s-${{ matrix.kubernetes-version }}
path: ./output/chaos-mesh-profile
retention-days: 7
- name: post run - upload junit test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-junit-reports-${{ matrix.focus }}-k8s-${{ matrix.kubernetes-version }}
path: "**/*.xml"
retention-days: 7
pass:
needs:
- e2e-test-matrix
name: E2E Test Passed
runs-on: ubuntu-20.04
steps:
- run: echo "🎉 E2E Test Passed!"