forked from dgiot/dgiot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
U-JOHNLIU\jonhl
committed
May 18, 2021
1 parent
9bda456
commit f83db4a
Showing
648 changed files
with
90,507 additions
and
1,837 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ARG BUILD_FROM=emqx/build-env:erl23.2.7.2-emqx-2-ubuntu20.04 | ||
FROM ${BUILD_FROM} | ||
|
||
ARG EMQX_NAME=emqx | ||
|
||
COPY . /emqx | ||
|
||
WORKDIR /emqx | ||
|
||
RUN make ${EMQX_NAME}-zip || cat rebar3.crashdump | ||
|
||
RUN make ${EMQX_NAME}-pkg || cat rebar3.crashdump | ||
|
||
RUN /emqx/.ci/build_packages/tests.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#!/bin/bash | ||
set -x -e -u | ||
export CODE_PATH=${CODE_PATH:-"/emqx"} | ||
export EMQX_NAME=${EMQX_NAME:-"emqx"} | ||
export PACKAGE_PATH="${CODE_PATH}/_packages/${EMQX_NAME}" | ||
export RELUP_PACKAGE_PATH="${CODE_PATH}/relup_packages/${EMQX_NAME}" | ||
# export EMQX_NODE_NAME="emqx-on-$(uname -m)@127.0.0.1" | ||
# export EMQX_NODE_COOKIE=$(date +%s%N) | ||
|
||
emqx_prepare(){ | ||
mkdir -p "${PACKAGE_PATH}" | ||
|
||
if [ ! -d "/paho-mqtt-testing" ]; then | ||
git clone -b develop-4.0 https://hub.fastgit.org/emqx/paho.mqtt.testing.git /paho-mqtt-testing | ||
fi | ||
pip3 install pytest | ||
} | ||
|
||
emqx_test(){ | ||
cd "${PACKAGE_PATH}" | ||
|
||
for var in "$PACKAGE_PATH"/"${EMQX_NAME}"-*;do | ||
case ${var##*.} in | ||
"zip") | ||
packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.zip) | ||
unzip -q "${PACKAGE_PATH}/${packagename}" | ||
export EMQX_ZONE__EXTERNAL__SERVER__KEEPALIVE=60 \ | ||
EMQX_MQTT__MAX_TOPIC_ALIAS=10 | ||
sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins | ||
|
||
echo "running ${packagename} start" | ||
"${PACKAGE_PATH}"/emqx/bin/emqx start || ( tail "${PACKAGE_PATH}"/emqx/log/emqx.log.1 && exit 1 ) | ||
IDLE_TIME=0 | ||
while [ -z "$("${PACKAGE_PATH}"/emqx/bin/emqx_ctl status |grep 'is running'|awk '{print $1}')" ] | ||
do | ||
if [ $IDLE_TIME -gt 10 ] | ||
then | ||
echo "emqx running error" | ||
exit 1 | ||
fi | ||
sleep 10 | ||
IDLE_TIME=$((IDLE_TIME+1)) | ||
done | ||
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic | ||
"${PACKAGE_PATH}"/emqx/bin/emqx stop | ||
echo "running ${packagename} stop" | ||
rm -rf "${PACKAGE_PATH}"/emqx | ||
;; | ||
"deb") | ||
packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.deb) | ||
dpkg -i "${PACKAGE_PATH}/${packagename}" | ||
if [ "$(dpkg -l |grep emqx |awk '{print $1}')" != "ii" ] | ||
then | ||
echo "package install error" | ||
exit 1 | ||
fi | ||
|
||
echo "running ${packagename} start" | ||
running_test | ||
echo "running ${packagename} stop" | ||
|
||
dpkg -r "${EMQX_NAME}" | ||
if [ "$(dpkg -l |grep emqx |awk '{print $1}')" != "rc" ] | ||
then | ||
echo "package remove error" | ||
exit 1 | ||
fi | ||
|
||
dpkg -P "${EMQX_NAME}" | ||
if dpkg -l |grep -q emqx | ||
then | ||
echo "package uninstall error" | ||
exit 1 | ||
fi | ||
;; | ||
"rpm") | ||
packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.rpm) | ||
rpm -ivh "${PACKAGE_PATH}/${packagename}" | ||
if ! rpm -q emqx | grep -q emqx; then | ||
echo "package install error" | ||
exit 1 | ||
fi | ||
|
||
echo "running ${packagename} start" | ||
running_test | ||
echo "running ${packagename} stop" | ||
|
||
rpm -e "${EMQX_NAME}" | ||
if [ "$(rpm -q emqx)" != "package emqx is not installed" ];then | ||
echo "package uninstall error" | ||
exit 1 | ||
fi | ||
;; | ||
|
||
esac | ||
done | ||
} | ||
|
||
running_test(){ | ||
export EMQX_ZONE__EXTERNAL__SERVER__KEEPALIVE=60 \ | ||
EMQX_MQTT__MAX_TOPIC_ALIAS=10 | ||
sed -i '/emqx_telemetry/d' /var/lib/emqx/loaded_plugins | ||
|
||
emqx start || ( tail /var/log/emqx/emqx.log.1 && exit 1 ) | ||
IDLE_TIME=0 | ||
while [ -z "$(emqx_ctl status |grep 'is running'|awk '{print $1}')" ] | ||
do | ||
if [ $IDLE_TIME -gt 10 ] | ||
then | ||
echo "emqx running error" | ||
exit 1 | ||
fi | ||
sleep 10 | ||
IDLE_TIME=$((IDLE_TIME+1)) | ||
done | ||
pytest -v /paho-mqtt-testing/interoperability/test_client/V5/test_connect.py::test_basic | ||
# shellcheck disable=SC2009 # pgrep does not support Extended Regular Expressions | ||
emqx stop || kill "$(ps -ef | grep -E '\-progname\s.+emqx\s' |awk '{print $2}')" | ||
|
||
if [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = ubuntu ] \ | ||
|| [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = debian ] ;then | ||
service emqx start || ( tail /var/log/emqx/emqx.log.1 && exit 1 ) | ||
IDLE_TIME=0 | ||
while [ -z "$(emqx_ctl status |grep 'is running'|awk '{print $1}')" ] | ||
do | ||
if [ $IDLE_TIME -gt 10 ] | ||
then | ||
echo "emqx service error" | ||
exit 1 | ||
fi | ||
sleep 10 | ||
IDLE_TIME=$((IDLE_TIME+1)) | ||
done | ||
service emqx stop | ||
fi | ||
} | ||
|
||
relup_test(){ | ||
TARGET_VERSION="$1" | ||
if [ -d "${RELUP_PACKAGE_PATH}" ];then | ||
cd "${RELUP_PACKAGE_PATH }" | ||
|
||
for var in "${EMQX_NAME}"-*-"$(uname -m)".zip;do | ||
packagename=$(basename "${var}") | ||
unzip "$packagename" | ||
./emqx/bin/emqx start || ( tail emqx/log/emqx.log.1 && exit 1 ) | ||
./emqx/bin/emqx_ctl status | ||
./emqx/bin/emqx versions | ||
cp "${PACKAGE_PATH}/${EMQX_NAME}"-*-"${TARGET_VERSION}-$(uname -m)".zip ./emqx/releases | ||
./emqx/bin/emqx install "${TARGET_VERSION}" | ||
[ "$(./emqx/bin/emqx versions |grep permanent | grep -oE "[0-9].[0-9].[0-9]")" = "${TARGET_VERSION}" ] || exit 1 | ||
./emqx/bin/emqx_ctl status | ||
./emqx/bin/emqx stop | ||
rm -rf emqx | ||
done | ||
fi | ||
} | ||
|
||
emqx_prepare | ||
emqx_test | ||
# relup_test <TODO: parameterise relup target version> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
MYSQL_TAG=8 | ||
REDIS_TAG=6 | ||
MONGO_TAG=4 | ||
PGSQL_TAG=13 | ||
LDAP_TAG=2.4.50 | ||
|
||
TARGET=emqx/emqx | ||
EMQX_TAG=build-alpine-amd64 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
EMQX_NAME=emqx | ||
EMQX_CLUSTER__DISCOVERY=static | ||
EMQX_CLUSTER__STATIC__SEEDS="[email protected], [email protected]" | ||
EMQX_LISTENER__TCP__EXTERNAL__PROXY_PROTOCOL=on | ||
EMQX_LISTENER__WS__EXTERNAL__PROXY_PROTOCOL=on | ||
EMQX_LOG__LEVEL=debug | ||
EMQX_LOADED_PLUGINS=emqx_sn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
EMQX_AUTH__LDAP__SERVERS=ldap_server | ||
EMQX_AUTH__MONGO__SERVER=mongo_server:27017 | ||
EMQX_AUTH__MYSQL__SERVER=mysql_server:3306 | ||
EMQX_AUTH__MYSQL__USERNAME=root | ||
EMQX_AUTH__MYSQL__PASSWORD=public | ||
EMQX_AUTH__MYSQL__DATABASE=mqtt | ||
EMQX_AUTH__PGSQL__SERVER=pgsql_server:5432 | ||
EMQX_AUTH__PGSQL__USERNAME=root | ||
EMQX_AUTH__PGSQL__PASSWORD=public | ||
EMQX_AUTH__PGSQL__DATABASE=mqtt | ||
EMQX_AUTH__REDIS__SERVER=redis_server:6379 | ||
EMQX_AUTH__REDIS__PASSWORD=public | ||
CUTTLEFISH_ENV_OVERRIDE_PREFIX=EMQX_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
version: '3.9' | ||
|
||
services: | ||
haproxy: | ||
container_name: haproxy | ||
image: haproxy:2.3 | ||
depends_on: | ||
- emqx1 | ||
- emqx2 | ||
volumes: | ||
- ./haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg | ||
- ../../etc/certs:/usr/local/etc/haproxy/certs | ||
ports: | ||
- "18083:18083" | ||
# - "1883:1883" | ||
# - "8883:8883" | ||
# - "8083:8083" | ||
# - "8084:8084" | ||
networks: | ||
- emqx_bridge | ||
working_dir: /usr/local/etc/haproxy | ||
command: | ||
- bash | ||
- -c | ||
- | | ||
cat /usr/local/etc/haproxy/certs/cert.pem /usr/local/etc/haproxy/certs/key.pem > /usr/local/etc/haproxy/certs/emqx.pem | ||
haproxy -f /usr/local/etc/haproxy/haproxy.cfg | ||
emqx1: | ||
container_name: node1.emqx.io | ||
image: $TARGET:$EMQX_TAG | ||
env_file: | ||
- conf.cluster.env | ||
environment: | ||
- "EMQX_HOST=node1.emqx.io" | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf | ||
sed -i '/emqx_telemetry/d' /opt/emqx/data/loaded_plugins | ||
/opt/emqx/bin/emqx foreground | ||
healthcheck: | ||
test: ["CMD", "/opt/emqx/bin/emqx_ctl", "status"] | ||
interval: 5s | ||
timeout: 25s | ||
retries: 5 | ||
networks: | ||
emqx_bridge: | ||
aliases: | ||
- node1.emqx.io | ||
|
||
emqx2: | ||
container_name: node2.emqx.io | ||
image: $TARGET:$EMQX_TAG | ||
env_file: | ||
- conf.cluster.env | ||
environment: | ||
- "EMQX_HOST=node2.emqx.io" | ||
command: | ||
- /bin/sh | ||
- -c | ||
- | | ||
sed -i "s 127.0.0.1 $$(ip route show |grep "link" |awk '{print $$1}') g" /opt/emqx/etc/acl.conf | ||
sed -i '/emqx_telemetry/d' /opt/emqx/data/loaded_plugins | ||
/opt/emqx/bin/emqx foreground | ||
healthcheck: | ||
test: ["CMD", "/opt/emqx/bin/emqx", "ping"] | ||
interval: 5s | ||
timeout: 25s | ||
retries: 5 | ||
networks: | ||
emqx_bridge: | ||
aliases: | ||
- node2.emqx.io | ||
|
||
networks: | ||
emqx_bridge: | ||
driver: bridge | ||
name: emqx_bridge | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 172.100.239.0/24 | ||
gateway: 172.100.239.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
version: '3.9' | ||
|
||
services: | ||
ldap_server: | ||
container_name: ldap | ||
build: | ||
context: ../.. | ||
dockerfile: .ci/docker-compose-file/openldap/Dockerfile | ||
args: | ||
LDAP_TAG: ${LDAP_TAG} | ||
image: openldap | ||
ports: | ||
- 389:389 | ||
restart: always | ||
networks: | ||
- emqx_bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: '3.9' | ||
|
||
services: | ||
mongo_server: | ||
container_name: mongo | ||
image: mongo:${MONGO_TAG} | ||
restart: always | ||
environment: | ||
MONGO_INITDB_DATABASE: mqtt | ||
networks: | ||
- emqx_bridge | ||
command: | ||
--ipv6 | ||
--bind_ip_all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
version: '3.9' | ||
|
||
services: | ||
mongo_server: | ||
container_name: mongo | ||
image: mongo:${MONGO_TAG} | ||
restart: always | ||
environment: | ||
MONGO_INITDB_DATABASE: mqtt | ||
volumes: | ||
- ../../apps/emqx_auth_mongo/test/emqx_auth_mongo_SUITE_data/mongodb.pem/:/etc/certs/mongodb.pem | ||
networks: | ||
- emqx_bridge | ||
command: | ||
--ipv6 | ||
--bind_ip_all | ||
--sslMode requireSSL | ||
--sslPEMKeyFile /etc/certs/mongodb.pem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '3.9' | ||
|
||
services: | ||
mysql_server: | ||
container_name: mysql | ||
image: mysql:${MYSQL_TAG} | ||
restart: always | ||
environment: | ||
MYSQL_ROOT_PASSWORD: public | ||
MYSQL_DATABASE: mqtt | ||
networks: | ||
- emqx_bridge | ||
command: | ||
--bind-address "::" | ||
--character-set-server=utf8mb4 | ||
--collation-server=utf8mb4_general_ci | ||
--explicit_defaults_for_timestamp=true | ||
--lower_case_table_names=1 | ||
--max_allowed_packet=128M | ||
--skip-symbolic-links |
Oops, something went wrong.