forked from apache/rocketmq
-
Notifications
You must be signed in to change notification settings - Fork 1
196 lines (184 loc) · 6.52 KB
/
chaos-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
name: CHAOS-TEST
on:
push:
branches: [chaos-test]
env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.httpconnectionManager.ttlSeconds=120
DOCKER_REPO: registry.cn-guangzhou.aliyuncs.com/cc-aliyun/rocketmq-ci
jobs:
dist-tar:
name: Build dist tar
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "8"
cache: "maven"
- name: Build distribution tar
run: |
mvn -Prelease-all -DskipTests -Dspotbugs.skip=true clean install -U
- uses: actions/upload-artifact@v3
name: Upload distribution tar
with:
name: rocketmq
path: distribution/target/rocketmq*/rocketmq*
docker:
if: ${{ success() }}
name: Docker images
needs: [dist-tar]
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
matrix:
base-image: ["ubuntu"]
java-version: ["8"]
steps:
- uses: actions/checkout@v3
with:
repository: apache/rocketmq-docker.git
ref: master
path: rocketmq-docker
- uses: actions/download-artifact@v3
name: Download distribution tar
with:
name: rocketmq
path: rocketmq
# Modify the startup script of broker and nameserver to start sshd together
- name: update start script
run: |
path=$(echo ./rocketmq/rocketmq*/rocketmq*/bin/)
sed -i '/^export ROCKETMQ_HOME/i if command -v ssh >/dev/null 2>&1; then\n /usr/sbin/sshd\nfi\n' $path/mqbroker
sed -i '/^export ROCKETMQ_HOME/i if command -v ssh >/dev/null 2>&1; then\n /usr/sbin/sshd\nfi\n' $path/mqnamesrv
- name: docker-login
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login registry.cn-guangzhou.aliyuncs.com --username=aliyun3982714546 --password-stdin
# Modify the Dockerfile to add the sshd service to the image
- name: append to Dockerfile
run: |
cat <<EOL >> rocketmq-docker/image-build-ci/Dockerfile-${{ matrix.base-image }}
RUN apt-get update && \\
apt-get install -y openssh-server && \\
apt-get clean
RUN mkdir /var/run/sshd && \\
mkdir -p /root/.ssh && \\
chmod 700 /root/.ssh && \\
ssh-keygen -A
RUN echo 'PermitEmptyPasswords yes' >> /etc/ssh/sshd_config
RUN passwd -d root
EOL
- name: Build and save docker images
id: build-images
run: |
cd rocketmq-docker/image-build-ci
version=${{ github.event.pull_request.number || github.ref_name }}-$(uuidgen)
mkdir versionlist
touch versionlist/"${version}-`echo ${{ matrix.base-image }} | sed -e "s/:/-/g"`"
sh ./build-image-local.sh ${version} ${{ matrix.base-image }} ${{ matrix.java-version }} ${DOCKER_REPO}
- uses: actions/upload-artifact@v3
name: Upload distribution tar
with:
name: versionlist
path: rocketmq-docker/image-build-ci/versionlist/*
list-version:
if: always()
name: List version
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- uses: actions/download-artifact@v3
name: Download versionlist
with:
name: versionlist
path: versionlist
- name: Show versions
id: show_versions
run: |
a=(`ls versionlist`)
printf '%s\n' "${a[@]}" | jq -R . | jq -s .
echo version-json=`printf '%s\n' "${a[@]}" | jq -R . | jq -s .` >> $GITHUB_OUTPUT
deploy:
if: ${{ success() }}
name: Deploy RocketMQ
needs: [list-version,docker]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
steps:
- uses: chi3316/rocketmq-test-tool/chaos-test-runner@46e1b58492a73c88fb1b97217dd8308cfafef7bb
name: Deploy rocketmq
with:
# TODO: Unable to modify the chart configuration here
action: "deploy"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
chart-git: "https://mirror.ghproxy.com/https://github.com/chi3316/rocketmq-docker"
chart-branch: "chaos-test"
chart-path: "./rocketmq-k8s-helm"
job-id: ${{ strategy.job-index }}
helm-values: |
nameserver:
image:
repository: ${{env.DOCKER_REPO}}
tag: ${{ matrix.version }}
broker:
image:
repository: ${{env.DOCKER_REPO}}
tag: ${{ matrix.version }}
proxy:
image:
repository: ${{env.DOCKER_REPO}}
tag: ${{ matrix.version }}
chaos-test:
name: Chaos test
if: ${{ success() }}
runs-on: ubuntu-latest
needs: deploy
timeout-minutes: 60
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: chi3316/rocketmq-test-tool/chaos-test-runner@46e1b58492a73c88fb1b97217dd8308cfafef7bb
name: Chaos test
with:
action: "chaos-test"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
job-id: ${{ strategy.job-index }}
openchaos-driver: ".github/chaos-configs/driver.yml"
chaos-mesh-fault-file: ".github/chaos-configs/pod-failure.yml"
fault-scheduler-interval: "60"
openchaos-args: "-t 600"
fault-durition: "60"
node-lable: "app.kubernetes.io/name=broker"
meta-node-lable: "app.kubernetes.io/name=nameserver"
- name: Upload test report
if: always()
uses: actions/upload-artifact@v4
with:
name: chaos-test-report
path: chaos-test-report/
clean:
if: always()
name: Clean
needs: [ list-version, chaos-test ]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
matrix:
version: ${{ fromJSON(needs.list-version.outputs.version-json) }}
steps:
- uses: chi3316/rocketmq-test-tool/chaos-test-runner@46e1b58492a73c88fb1b97217dd8308cfafef7bb
name: clean
with:
action: "clean"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
job-id: ${{ strategy.job-index }}