- Secure tests on master branch after merge. - Improve build cache hit rates Due to security reason, github only allow reuse cache from - same branch - base branch - default branch Branch Feature-A could not reuse the cache from Feature-B - Developers could run the workflow in their own forked repo before make the PR, this could relieve the runners on upstream repo
125 lines
4.2 KiB
YAML
125 lines
4.2 KiB
YAML
name: Broker tests
|
|
|
|
on:
|
|
push:
|
|
branch:
|
|
- *
|
|
tags:
|
|
- v*
|
|
pull_request:
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.build_docker.outputs.version}}
|
|
steps:
|
|
- name: download jmeter
|
|
timeout-minutes: 3
|
|
env:
|
|
JMETER_VERSION: 5.3
|
|
run: |
|
|
wget --no-verbose --no-check-certificate -O /tmp/apache-jmeter.tgz https://downloads.apache.org/jmeter/binaries/apache-jmeter-$JMETER_VERSION.tgz
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: apache-jmeter.tgz
|
|
path: /tmp/apache-jmeter.tgz
|
|
- uses: actions/checkout@v2
|
|
- name: zip emqx docker image
|
|
id: build_docker
|
|
if: endsWith(github.repository, 'emqx')
|
|
run: |
|
|
## TODO: make profile a matrix dimension
|
|
PROFILE='emqx'
|
|
make "${PROFILE}-docker"
|
|
VSN="$(./pkg-vsn.sh $PROFILE)"
|
|
echo "::set-output name=version::${VSN}"
|
|
docker save -o emqx.tar emqx/emqx:${VSN}
|
|
- uses: actions/upload-artifact@v2
|
|
with:
|
|
name: emqx.tar
|
|
path: ./emqx.tar
|
|
mqtt_subscription:
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
subscription_type:
|
|
- mqtt_subscription_topic_metrics
|
|
|
|
needs: build
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: emqx.tar
|
|
path: /tmp
|
|
- name: load docker image
|
|
run: |
|
|
docker load < /tmp/emqx.tar
|
|
- name: docker compose up
|
|
timeout-minutes: 5
|
|
env:
|
|
_EMQX_DOCKER_IMAGE_TAG: emqx/emqx:${{ needs.build.outputs.version }}
|
|
run: |
|
|
docker-compose \
|
|
-f .ci/docker-compose-file/docker-compose-emqx-cluster.yaml \
|
|
up -d --build
|
|
- name: wait docker compose up
|
|
timeout-minutes: 5
|
|
run: |
|
|
while [ "$(docker inspect -f '{{ .State.Health.Status}}' node1.emqx.io)" != "healthy" ] || [ "$(docker inspect -f '{{ .State.Health.Status}}' node2.emqx.io)" != "healthy" ]; do
|
|
echo "['$(date -u +"%y-%m-%dt%h:%m:%sz")']:waiting emqx";
|
|
sleep 5;
|
|
done
|
|
while [ $(docker ps -a --filter name=client --filter exited=0 | wc -l) \
|
|
!= $(docker ps -a --filter name=client | wc -l) ]; do
|
|
sleep 1
|
|
done
|
|
docker ps -a
|
|
echo HAPROXY_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' haproxy) >> $GITHUB_ENV
|
|
- uses: actions/checkout@v2
|
|
with:
|
|
repository: emqx/emqx-fvt
|
|
ref: broker-autotest
|
|
path: scripts
|
|
- uses: actions/setup-java@v1
|
|
with:
|
|
java-version: '8.0.282' # The JDK version to make available on the path.
|
|
java-package: jdk # (jre, jdk, or jdk+fx) - defaults to jdk
|
|
architecture: x64 # (x64 or x86) - defaults to x64
|
|
- uses: actions/download-artifact@v2
|
|
with:
|
|
name: apache-jmeter.tgz
|
|
path: /tmp
|
|
- name: install jmeter
|
|
timeout-minutes: 10
|
|
env:
|
|
JMETER_VERSION: 5.3
|
|
run: |
|
|
cd /tmp && tar -xvf apache-jmeter.tgz
|
|
echo "jmeter.save.saveservice.output_format=xml" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
|
|
echo "jmeter.save.saveservice.response_data.on_error=true" >> /tmp/apache-jmeter-$JMETER_VERSION/user.properties
|
|
wget --no-verbose -O /tmp/apache-jmeter-$JMETER_VERSION/lib/ext/mqtt-xmeter-2.0.2-jar-with-dependencies.jar https://raw.githubusercontent.com/xmeter-net/mqtt-jmeter/master/Download/v2.0.2/mqtt-xmeter-2.0.2-jar-with-dependencies.jar
|
|
ln -s /tmp/apache-jmeter-$JMETER_VERSION /opt/jmeter
|
|
- name: run jmeter
|
|
run: |
|
|
/opt/jmeter/bin/jmeter.sh \
|
|
-Jjmeter.save.saveservice.output_format=xml -n \
|
|
-t scripts/broker-autotest-suite/${{ matrix.subscription_type }}.jmx \
|
|
-Demqx_ip=$HAPROXY_IP \
|
|
-l jmeter_logs/${{ matrix.subscription_type }}.jtl \
|
|
-j jmeter_logs/logs/${{ matrix.subscription_type }}.log
|
|
- name: check logs
|
|
run: |
|
|
if cat jmeter_logs/${{ matrix.subscription_type }}}.jtl | grep -e '<failure>true</failure>' > /dev/null 2>&1; then
|
|
echo "check logs filed"
|
|
exit 1
|
|
fi
|
|
- uses: actions/upload-artifact@v1
|
|
if: always()
|
|
with:
|
|
name: jmeter_logs
|
|
path: ./jmeter_logs
|