Skip to content

Commit

Permalink
Add chaos-test related files
Browse files Browse the repository at this point in the history
  • Loading branch information
chi3316 committed Sep 3, 2024
1 parent 720c87e commit 7e192ea
Show file tree
Hide file tree
Showing 3 changed files with 241 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/chaos-configs/driver.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: RocketMQ
driverClass: io.openchaos.driver.rocketmq.RocketMQDriver

endToEndLatencyCheck: true

# RocketMQ cluster configuration

# Nodes for broker
nodes:
- ${node_1}
- ${node_2}

# Nodes for nameserver
metaNodes:
- ${meta_node_1}

# RocketMQ configuration
rocketmqVersion: 5.2.0
installDir: /home/rocketmq/rocketmq-5.2.0 # you could set existent location for RocketMQ
nameServerPort: 9876

# RocketMQ client configuration
clusterName: DefaultCluster # same value as the config in broker.properties
vipChannelEnabled: false

# RocketMQ broker configuration
brokerClusterName: DefaultCluster
brokerName: rocketmq-broker-0
storePathRootDir: /home/rocketmq/store
storePathCommitLog: /home/rocketmq/store/commitlog
enableDLegerCommitLog: false
14 changes: 14 additions & 0 deletions .github/workflows/chaos-configs/pod-failure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: chaos-mesh.org/v1alpha1
kind: PodChaos
metadata:
name: pod-failure-chaos
spec:
action: pod-failure
mode: fixed
value: "2"
duration: '60s'
selector:
namespaces:
- ${ns}
labelSelectors:
"app.kubernetes.io/name": "broker"
196 changes: 196 additions & 0 deletions .github/workflows/chaos-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
# 在这里,修改启动脚本,一起启动sshd
# rocketmq/rocketmq*/rocketmq*/bin/mqbroker rocketmq/rocketmq*/rocketmq*/bin/mqnamesrv
- 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
- name: append to Dockerfile
# 修改Dockerfile,在镜像中添加sshd服务
run: |
cat <<EOL >> 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@66673f509f0a9cde2df5b4ff6243830b06ff40f1
name: Deploy rocketmq
with:
# 这里要改一下chart : 暴露22端口; 增加1个broker副本
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:
runs-on: ubuntu-latest
needs: deploy
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v2
- uses: chi3316/rocketmq-test-tool/chaos-test-runner@66673f509f0a9cde2df5b4ff6243830b06ff40f1
name: Chaos test
with:
action: "chaos-test"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
job-id: ${{ strategy.job-index }}
openchaos-driver: ".github/chaos-configs/driver.yaml"
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@66673f509f0a9cde2df5b4ff6243830b06ff40f1
name: clean
with:
action: "clean"
ask-config: "${{ secrets.ASK_CONFIG_VIRGINA }}"
test-version: "${{ matrix.version }}"
job-id: ${{ strategy.job-index }}

0 comments on commit 7e192ea

Please sign in to comment.