-
Notifications
You must be signed in to change notification settings - Fork 288
281 lines (257 loc) · 11.2 KB
/
dm_chaos.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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
name: DM Chaos
on:
schedule:
- cron: '0 17-23 * * *' # run at minute 0 every hour from 01:00 ~ 07:00 UTC+8
workflow_dispatch:
inputs:
pr:
description: 'Which PR do you want to trigger'
required: true
default: ''
# See: https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#concurrency.
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "base"
base:
# The type of runner that the job will run on
runs-on: ubuntu-20.04
timeout-minutes: 50
strategy:
fail-fast: false
matrix:
chaos-obj:
[
"pod-failure-dm",
"pod-kill-dm",
"network-partition-dm",
"network-emulation-dm",
"io-chaos-dm",
]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Set up Go for building DM
- name: Set up Go env
uses: actions/setup-go@v3
with:
go-version: '1.21'
- name: Print Go version
run: go version
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out code
uses: actions/checkout@v2
- name: Check out code by workflow dispatch
if: ${{ github.event.inputs.pr != '' }}
uses: actions/checkout@v2
with:
ref: refs/pull/${{ github.event.inputs.pr }}/head
- name: Cache go modules
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-ticdc-${{ hashFiles('go.sum') }}
- name: Cache Tools
id: cache-tools
uses: actions/cache@v2
with:
path: tools/bin
key: ${{ runner.os }}-ticdc-tools-${{ hashFiles('tools/check/go.sum') }}
- name: Create k8s Kind Cluster
uses: helm/[email protected]
- name: Print cluster information
run: |
kubectl config view
kubectl cluster-info
kubectl get nodes
kubectl get pods -n kube-system
kubectl get sc
kubectl version
helm version
# Disable AppArmor for MySQL, see https://github.com/moby/moby/issues/7512#issuecomment-61787845
- name: Disable AppArmor for MySQL
run: |
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: Build DM binary
run: make dm-master dm-worker dmctl dm-chaos-case
# NOTE: we also copy config files into `bin` directory,
# so we only need to send `bin` as the context into docker daemon when building image.
- name: Build DM docker image
run: |
cp -r $GITHUB_WORKSPACE/dm/chaos/cases/conf/ $GITHUB_WORKSPACE/bin/
docker build -f $GITHUB_WORKSPACE/dm/chaos/manifests/Dockerfile -t dm:chaos $GITHUB_WORKSPACE/bin
docker image list
# Load DM docker image into KIND, see https://kind.sigs.k8s.io/docs/user/quick-start/#loading-an-image-into-your-cluster
- name: Load DM docker image into KIND
run: |
kind load docker-image dm:chaos --name chart-testing
# Set up upstream instances
- name: Set up sources
run: |
kubectl apply -f $GITHUB_WORKSPACE/dm/chaos/manifests/sources.yaml
kubectl get -f $GITHUB_WORKSPACE/dm/chaos/manifests/sources.yaml
kubectl describe -f $GITHUB_WORKSPACE/dm/chaos/manifests/sources.yaml
- name: Wait for sources ready # kubectl wait --all not working
run: |
kubectl wait --for=condition=Ready pod/mysql57-0 --timeout=300s || true
kubectl wait --for=condition=Ready pod/mysql8-0 --timeout=300s || true
kubectl wait --for=condition=Ready pod/mariadb-0 --timeout=300s || true
sleep 10
echo show pvc
kubectl get pvc -l app=sources -o wide
echo show pv
kubectl get pv -o wide
echo show svc
kubectl get svc -l app=sources -o wide
echo show sts
kubectl get sts -l app=sources -o wide
echo show po
kubectl get po -l app=sources -o wide
echo describe po
kubectl describe po -l app=sources
echo describe pvc
kubectl describe pvc -l app=sources
kubectl wait --for=condition=Ready pod/mysql57-0 --timeout=0s
kubectl wait --for=condition=Ready pod/mysql8-0 --timeout=0s
kubectl wait --for=condition=Ready pod/mariadb-0 --timeout=0s
# Set up downstream TiDB instance (deploy a TiDB with mockTiKV, not a TidbCluster managed by TiDB-operator)
- name: Set up TiDB
run: |
kubectl apply -f $GITHUB_WORKSPACE/dm/chaos/manifests/tidb.yaml
kubectl get -f $GITHUB_WORKSPACE/dm/chaos/manifests/tidb.yaml
kubectl describe -f $GITHUB_WORKSPACE/dm/chaos/manifests/tidb.yaml
- name: Wait for TiDB ready
run: |
kubectl wait --for=condition=Ready pod/tidb-0 --timeout=300s || true
echo show pvc
kubectl get pvc -l app=tidb -o wide
echo show pv
kubectl get pv -o wide
echo show svc
kubectl get svc -l app=tidb -o wide
echo show sts
kubectl get sts -l app=tidb -o wide
echo show po
kubectl get po -l app=tidb -o wide
echo describe po
kubectl describe po -l app=tidb
echo describe pvc
kubectl describe pvc -l app=tidb
kubectl wait --for=condition=Ready pod/tidb-0 --timeout=0s
- name: Set up DM-master
run: |
kubectl apply -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-master.yaml
kubectl get -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-master.yaml
kubectl describe -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-master.yaml
# NOTE: even some DM-master instances are not ready, we still continue and let chaos test cases to check again.
- name: Wait for DM-master ready
run: |
sleep 10
kubectl wait --for=condition=Ready pod -l app=dm-master --all --timeout=300s || true
echo "<<<<< show pvc >>>>>"
kubectl get pvc -l app=dm-master -o wide
echo "<<<<< show pv >>>>>"
kubectl get pv -o wide
echo "<<<<< show svc >>>>>"
kubectl get svc -l app=dm-master -o wide
echo "<<<<< show sts >>>>>"
kubectl get sts -l app=dm-master -o wide
echo "<<<<< show po >>>>>"
kubectl get po -l app=dm-master -o wide
echo "<<<<< describe po >>>>>"
kubectl describe po -l app=dm-master
echo "<<<<< describe pvc >>>>>"
kubectl describe pvc -l app=dm-master
echo "<<<<< show current log for dm-master-0 >>>>>"
kubectl logs dm-master-0 || true
echo "<<<<< show previous log for dm-master-0 >>>>>"
kubectl logs dm-master-0 -p || true
echo "<<<<< show current log for dm-master-1 >>>>>"
kubectl logs dm-master-1 || true
echo "<<<<< show previous log for dm-master-1 >>>>>"
kubectl logs dm-master-1 -p || true
echo "<<<<< show current log for dm-master-2 >>>>>"
kubectl logs dm-master-2 || true
echo "<<<<< show previous log for dm-master-2 >>>>>"
kubectl logs dm-master-2 -p || true
- name: Set up DM-worker
run: |
kubectl apply -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-worker.yaml
kubectl get -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-worker.yaml
kubectl describe -f $GITHUB_WORKSPACE/dm/chaos/manifests/dm-worker.yaml
# NOTE: even some DM-worker instances are not ready, we still continue and let chaos test cases to check again.
- name: Wait for DM-worker ready
run: |
sleep 10
kubectl wait --for=condition=Ready pod -l app=dm-worker --all --timeout=300s || true
echo "<<<<< show pvc >>>>>"
kubectl get pvc -l app=dm-worker -o wide
echo "<<<<< show pv >>>>>"
kubectl get pv -o wide
echo "<<<<< show svc >>>>>"
kubectl get svc -l app=dm-worker -o wide
echo "<<<<< show sts >>>>>"
kubectl get sts -l app=dm-worker -o wide
echo "<<<<< show po >>>>>"
kubectl get po -l app=dm-worker -o wide
echo "<<<<< describe po >>>>>"
kubectl describe po -l app=dm-worker
echo "<<<<< describe pvc >>>>>"
kubectl describe pvc -l app=dm-worker
echo "<<<<< show current log for dm-worker-0 >>>>>"
kubectl logs dm-worker-0 || true
echo "<<<<< show previous log for dm-worker-0 >>>>>"
kubectl logs dm-worker-0 -p || true
echo "<<<<< show current log for dm-worker-1 >>>>>"
kubectl logs dm-worker-1 || true
echo "<<<<< show previous log for worker-master-1 >>>>>"
kubectl logs dm-worker-1 -p || true
echo "<<<<< show current log for dm-worker-2 >>>>>"
kubectl logs dm-worker-2 || true
echo "<<<<< show previous log for dm-worker-2 >>>>>"
kubectl logs dm-worker-2 -p || true
# NOTE: we sleep a while when check members ready in cases before applying any chaos operations.
- name: Set up chaos test cases
run: |
kubectl apply -f $GITHUB_WORKSPACE/dm/chaos/manifests/cases.yaml
kubectl get -f $GITHUB_WORKSPACE/dm/chaos/manifests/cases.yaml
kubectl describe -f $GITHUB_WORKSPACE/dm/chaos/manifests/cases.yaml
sleep 60
- name: Encode chaos-mesh action
run: |
echo CFG_BASE64=$(base64 -w 0 $GITHUB_WORKSPACE/dm/chaos/manifests/${{ matrix.chaos-obj }}.yaml) >> $GITHUB_ENV
- name: Run chaos mesh action
uses: chaos-mesh/chaos-mesh-action@master
env:
CFG_BASE64: ${{ env.CFG_BASE64 }}
# check whether complete with 1m * 20 times.
- name: Wait for chaos test case complete
run: |
$GITHUB_WORKSPACE/dm/chaos/scripts/check-case.sh
- name: Copy logs to hack permission
if: ${{ always() }}
run: |
mkdir ./logs
kubectl get pods --no-headers -o custom-columns=":metadata.name"|grep -E "dm-"|xargs -I{} sudo kubectl cp {}:/log/{}.log ./logs/{}.log || true
kind export logs ./logs/kind --name chart-testing
sudo chown -R runner ./logs
# Update logs as artifact seems not stable, so we set `continue-on-error: true` here.
- name: Upload logs
continue-on-error: true
uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: chaos-base-logs.${{ matrix.chaos-obj }}
path: |
./logs
# send Slack notify if failed.
# NOTE: With the exception of `GITHUB_TOKEN`, secrets are not passed to the runner when a workflow is triggered from a forked repository.
- name: Slack notification
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_NOTIFY }}
uses: Ilshidur/[email protected]
with:
args: "chaos job failed, see https://github.com/pingcap/tiflow/actions/runs/{{ GITHUB_RUN_ID }}"